Changeset 6616ccd3
- Timestamp:
- May 25, 2011 9:05:20 PM (10 years ago)
- Branches:
- master
- Children:
- f5f4f14b
- Parents:
- 075f89f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
core/java/src/net/i2p/util/NativeBigInteger.java
r075f89f r6616ccd3 118 118 private static final boolean _isOS2 = System.getProperty("os.name").startsWith("OS/2"); 119 119 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 123 123 /* libjbigi.so vs jbigi.dll */ 124 124 private static final String _libPrefix = (_isWin || _isOS2 ? "" : "lib"); … … 139 139 */ 140 140 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"); 142 153 if (is64) 143 154 return JBIGI_OPTIMIZATION_ATHLON64; … … 483 494 outFile = new File(I2PAppContext.getGlobalContext().getTempDir(), filename); 484 495 fos = new FileOutputStream(outFile); 485 // wtf this was 4096*1024 which is really excessive for a roughly 50KB file486 496 byte buf[] = new byte[4096]; 487 497 while (true) { … … 517 527 } 518 528 529 /** 530 * @return may be null if optimized is true 531 */ 519 532 private static final String getResourceName(boolean optimized) { 520 String pref = _libPrefix;521 533 String middle = getMiddleName(optimized); 522 String suff = _libSuffix; 523 if(pref == null || middle == null || suff == null) 534 if (middle == null) 524 535 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) { 530 543 String sAppend; 531 if(optimized) 532 { 533 if(sCPUType == null) 544 if (optimized) { 545 if (sCPUType == null) 534 546 return null; 535 else536 sAppend = "-"+sCPUType;537 }else538 sAppend = "-none";547 sAppend = "-" + sCPUType; 548 } else { 549 sAppend = "-none"; 550 } 539 551 540 552 if(_isWin) 541 553 return "jbigi-windows"+sAppend; // The convention on Windows 542 if(_isLinux)543 return "jbigi-linux"+sAppend; // The convention on linux...544 554 if(_isFreebsd) 545 555 return "jbigi-freebsd"+sAppend; // The convention on freebsd... … … 548 558 if(_isOS2) 549 559 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; 551 563 } 552 564 }
Note: See TracChangeset
for help on using the changeset viewer.