Changeset 6616ccd3


Ignore:
Timestamp:
May 25, 2011 9:05:20 PM (9 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
f5f4f14b
Parents:
075f89f
Message:

cleanup in prep for more changes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • core/java/src/net/i2p/util/NativeBigInteger.java

    r075f89f r6616ccd3  
    118118    private static final boolean _isOS2 = System.getProperty("os.name").startsWith("OS/2");
    119119    private static final boolean _isMac = System.getProperty("os.name").startsWith("Mac");
    120     private static final boolean _isLinux = System.getProperty("os.name").toLowerCase().indexOf("linux") != -1;
    121     private static final boolean _isFreebsd = System.getProperty("os.name").toLowerCase().indexOf("freebsd") != -1;
    122     private static final boolean _isNix = !(_isWin || _isMac || _isOS2);
     120    private static final boolean _isLinux = System.getProperty("os.name").toLowerCase().contains("linux");
     121    private static final boolean _isFreebsd = System.getProperty("os.name").toLowerCase().contains("freebsd");
     122
    123123    /* libjbigi.so vs jbigi.dll */
    124124    private static final String _libPrefix = (_isWin || _isOS2 ? "" : "lib");
     
    139139      */
    140140    private static String resolveCPUType() {
    141         boolean is64 = (-1 != System.getProperty("os.arch").indexOf("64"));
     141        /*
     142         * This isn't always correct.
     143         * http://stackoverflow.com/questions/807263/how-do-i-detect-which-kind-of-jre-is-installed-32bit-vs-64bit
     144         * http://mark.koli.ch/2009/10/javas-osarch-system-property-is-the-bitness-of-the-jre-not-the-operating-system.html
     145         * http://mark.koli.ch/2009/10/reliably-checking-os-bitness-32-or-64-bit-on-windows-with-a-tiny-c-app.html
     146         * sun.arch.data.model not on all JVMs
     147         * sun.arch.data.model == 64 => 64 bit processor
     148         * sun.arch.data.model == 32 => A 32 bit JVM but could be either 32 or 64 bit processor or libs
     149         * os.arch contains "64" could be 32 or 64 bit libs
     150         */
     151        boolean is64 = "64".equals(System.getProperty("sun.arch.data.model")) ||
     152                       System.getProperty("os.arch").contains("64");
    142153        if (is64)
    143154            return JBIGI_OPTIMIZATION_ATHLON64;
     
    483494            outFile = new File(I2PAppContext.getGlobalContext().getTempDir(), filename);
    484495            fos = new FileOutputStream(outFile);
    485             // wtf this was 4096*1024 which is really excessive for a roughly 50KB file
    486496            byte buf[] = new byte[4096];
    487497            while (true) {
     
    517527    }
    518528   
     529    /**
     530     *  @return may be null if optimized is true
     531     */
    519532    private static final String getResourceName(boolean optimized) {
    520         String pref = _libPrefix;
    521533        String middle = getMiddleName(optimized);
    522         String suff = _libSuffix;
    523         if(pref == null || middle == null || suff == null)
     534        if (middle == null)
    524535            return null;
    525         return pref+middle+suff;
    526     }
    527    
    528     private static final String getMiddleName(boolean optimized){
    529        
     536        return _libPrefix + middle + _libSuffix;
     537    }
     538   
     539    /**
     540     *  @return may be null if optimized is true; returns jbigi-xxx-none if optimize is false
     541     */
     542    private static final String getMiddleName(boolean optimized) {
    530543        String sAppend;
    531         if(optimized)
    532         {
    533             if(sCPUType == null)
     544        if (optimized) {
     545            if (sCPUType == null)
    534546                return null;
    535             else
    536                 sAppend = "-"+sCPUType;       
    537         }else
    538                sAppend = "-none";
     547            sAppend = "-" + sCPUType;       
     548        } else {
     549            sAppend = "-none";
     550        }
    539551
    540552        if(_isWin)
    541553             return "jbigi-windows"+sAppend; // The convention on Windows
    542         if(_isLinux)
    543             return "jbigi-linux"+sAppend; // The convention on linux...
    544554        if(_isFreebsd)
    545555            return "jbigi-freebsd"+sAppend; // The convention on freebsd...
     
    548558        if(_isOS2)
    549559            return "jbigi-os2"+sAppend;
    550         throw new RuntimeException("Dont know jbigi library name for os type '"+System.getProperty("os.name")+"'");
     560        //throw new RuntimeException("Dont know jbigi library name for os type '"+System.getProperty("os.name")+"'");
     561        // use linux as the default, don't throw exception
     562        return "jbigi-linux" + sAppend;
    551563    }
    552564}
Note: See TracChangeset for help on using the changeset viewer.