Changeset 2461b95


Ignore:
Timestamp:
Sep 18, 2011 4:25:13 PM (9 years ago)
Author:
kytv <kytv@…>
Branches:
master
Children:
2261039
Parents:
7f6c4fa
Message:

Add NetBSD support to NBI and CPUID

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • core/java/src/freenet/support/CPUInformation/CPUID.java

    r7f6c4fa r2461b95  
    2121 * A good resource for information about the CPUID instruction can be found here:
    2222 * http://www.paradicesoftware.com/specs/cpuid/index.htm
    23  * 
     23 *
    2424 * free (adj.): unencumbered; not under the control of others
    25  * Written by Iakin in 2004 and released into the public domain 
    26  * with no warranty of any kind, either expressed or implied. 
    27  * It probably won't make your computer catch on fire, or eat 
     25 * Written by Iakin in 2004 and released into the public domain
     26 * with no warranty of any kind, either expressed or implied.
     27 * It probably won't make your computer catch on fire, or eat
    2828 * your children, but it might. Use at your own risk.
    2929*/
     
    3333    /** did we load the native lib correctly? */
    3434    private static boolean _nativeOk = false;
    35    
    36     /** 
    37      * do we want to dump some basic success/failure info to stderr during 
     35
     36    /**
     37     * do we want to dump some basic success/failure info to stderr during
    3838     * initialization?  this would otherwise use the Log component, but this makes
    3939     * it easier for other systems to reuse this class
     
    5555    private static final boolean isLinux = System.getProperty("os.name").toLowerCase().contains("linux");
    5656    private static final boolean isFreebsd = System.getProperty("os.name").toLowerCase().contains("freebsd");
     57    private static final boolean isNetbsd = System.getProperty("os.name").toLowerCase().contains("netbsd");
    5758    private static final boolean isSunos = System.getProperty("os.name").toLowerCase().contains("sunos");
    5859    private static final boolean isMac = System.getProperty("os.name").startsWith("Mac");
     
    7576    {
    7677        loadNative();
    77     }   
     78    }
    7879    //A class that can (amongst other things I assume) represent the state of the
    7980    //different CPU registers after a call to the CPUID assembly method
     
    9192        }
    9293    }
    93    
     94
    9495    /**Calls the indicated CPUID function and returns the result of the execution
    95      * 
     96     *
    9697     * @param iFunction The CPUID function to call, should be 0 or larger
    9798     * @return The contents of the CPU registers after the call to the CPUID function
     
    108109        sb.append((char)((c.EBX >> 16) & 0xFF));
    109110        sb.append((char)((c.EBX >> 24) & 0xFF));
    110        
     111
    111112        sb.append((char)( c.EDX        & 0xFF));
    112113        sb.append((char)((c.EDX >> 8)  & 0xFF));
    113114        sb.append((char)((c.EDX >> 16) & 0xFF));
    114115        sb.append((char)((c.EDX >> 24) & 0xFF));
    115        
     116
    116117        sb.append((char)( c.ECX        & 0xFF));
    117118        sb.append((char)((c.ECX >> 8)  & 0xFF));
    118119        sb.append((char)((c.ECX >> 16) & 0xFF));
    119120        sb.append((char)((c.ECX >> 24) & 0xFF));
    120    
     121
    121122        return sb.toString();
    122123    }
     
    164165    {
    165166        CPUIDResult c = doCPUID(0x80000001);
    166         return c.EBX;   
     167        return c.EBX;
    167168    }
    168169    static int getExtendedECXCPUFlags()
     
    178179        return c.EDX;
    179180    }
    180    
     181
    181182    /**
    182183     * Returns a CPUInfo item for the current type of CPU
     
    201202        throw new UnknownCPUException("Unknown CPU type: '"+getCPUVendorID()+"'");
    202203    }
    203    
     204
    204205
    205206    public static void main(String args[])
     
    215216        System.out.println("CPU Stepping: " + getCPUStepping());
    216217        System.out.println("CPU Flags: 0x" + Integer.toHexString(getEDXCPUFlags()));
    217        
     218
    218219        CPUInfo c = getInfo();
    219220        System.out.println(" **More CPUInfo**");
     
    239240            System.out.println("  Is Athlon-compatible: "+((AMDCPUInfo)c).IsAthlonCompatible());
    240241        }
    241        
    242     }
    243    
     242
     243    }
     244
    244245    /**
    245246     * <p>Do whatever we can to load up the native library.
     
    280281        }
    281282    }
    282    
    283     /** 
     283
     284    /**
    284285     * <p>Try loading it from an explictly built jcpuid.dll / libjcpuid.so</p>
    285286     * The file name must be (e.g. on linux) either libjcpuid.so or libjcpuid-x86-linux.so.
     
    312313        //}
    313314    }
    314    
     315
    315316    /**
    316317     * <p>Check all of the jars in the classpath for the jcpuid dll/so.
    317318     * This file should be stored in the resource in the same package as this class.
    318      * 
     319     *
    319320     * <p>This is a pretty ugly hack, using the general technique illustrated by the
    320      * onion FEC libraries.  It works by pulling the resource, writing out the 
     321     * onion FEC libraries.  It works by pulling the resource, writing out the
    321322     * byte stream to a temporary file, loading the native library from that file.
    322323     * We then attempt to copy the file from the temporary dir to the base install dir,
     
    339340                return true;
    340341        }
    341        
     342
    342343        // now try 32 bit
    343344        resourceName = getResourceName();
     
    406407        return true;
    407408    }
    408    
     409
    409410    /** @return non-null */
    410411    private static final String getResourceName()
     
    412413        return getLibraryPrefix()+getLibraryMiddlePart()+"."+getLibrarySuffix();
    413414    }
    414    
     415
    415416    /**
    416417     * @return null if not on a 64 bit platform
     
    422423        return getLibraryPrefix() + get64LibraryMiddlePart() + "." + getLibrarySuffix();
    423424    }
    424    
     425
    425426    private static final String getLibraryPrefix()
    426427    {
     
    430431            return "lib";
    431432    }
    432    
     433
    433434    private static final String getLibraryMiddlePart(){
    434435        if(isWindows)
     
    441442        if(isFreebsd)
    442443            return "jcpuid-x86-freebsd"; // The convention on freebsd...
     444        if(isNetbsd)
     445            return "jcpuid-x86-netbsd"; // The convention on netbsd...
    443446        if(isSunos)
    444447            return "jcpuid-x86-solaris"; // The convention on SunOS
     
    447450        return "jcpuid-x86-linux";
    448451    }
    449    
     452
    450453    /** @since 0.8.7 */
    451454    private static final String get64LibraryMiddlePart() {
     
    454457        if(isFreebsd)
    455458            return "jcpuid-x86_64-freebsd";
     459        if(isNetbsd)
     460            return "jcpuid-x86_64-netbsd";
    456461        if(isMac){
    457462            if(isX86){
     
    464469        return "jcpuid-x86_64-linux";
    465470    }
    466    
     471
    467472    private static final String getLibrarySuffix()
    468473    {
  • core/java/src/net/i2p/util/NativeBigInteger.java

    r7f6c4fa r2461b95  
    148148     */
    149149    private final static String JBIGI_OPTIMIZATION_ARM        = "arm";
    150     private final static String JBIGI_OPTIMIZATION_PPC        = "ppc";
     150    private final static String JBIGI_OPTIMIZATION_PPC        = "ppc";
    151151
    152152    /**
     
    158158    private static final boolean _isLinux = System.getProperty("os.name").toLowerCase().contains("linux");
    159159    private static final boolean _isFreebsd = System.getProperty("os.name").toLowerCase().contains("freebsd");
     160    private static final boolean _isNetbsd = System.getProperty("os.name").toLowerCase().contains("netbsd");
    160161    private static final boolean _isSunos = System.getProperty("os.name").toLowerCase().contains("sunos");
    161162    private static final boolean _isAndroid = System.getProperty("java.vendor").contains("Android");
     
    757758        if(_isFreebsd)
    758759            return "jbigi-freebsd-";
     760        if(_isNetbsd)
     761            return "jbigi-netbsd-";
    759762        if(_isMac)
    760763            return "jbigi-osx-";
  • history.txt

    r7f6c4fa r2461b95  
     12011-09-18 kytv
     2 * Add NetBSD to NBI and CPUID
     3
    142011-09-16 zzz
    25  * Console: Home page flag spacing
Note: See TracChangeset for help on using the changeset viewer.