示例#1
0
  /** Updates logical and physical processor counts from sysctl calls */
  private void calculateProcessorCounts() {
    IntByReference size = new IntByReference(SystemB.INT_SIZE);
    Pointer p = new Memory(size.getValue());

    // Get number of logical processors
    if (0 != SystemB.INSTANCE.sysctlbyname("hw.logicalcpu", p, size, null, 0)) {
      LOG.error("Failed to get number of logical CPUs. Error code: " + Native.getLastError());
      this.logicalProcessorCount = 1;
    } else this.logicalProcessorCount = p.getInt(0);

    // Get number of physical processors
    if (0 != SystemB.INSTANCE.sysctlbyname("hw.physicalcpu", p, size, null, 0)) {
      LOG.error("Failed to get number of physical CPUs. Error code: " + Native.getLastError());
      this.physicalProcessorCount = 1;
    } else this.physicalProcessorCount = p.getInt(0);
  }
示例#2
0
 /** {@inheritDoc} */
 @Override
 public String getFamily() {
   if (this.cpuFamily == null) {
     IntByReference size = new IntByReference(SystemB.INT_SIZE);
     Pointer p = new Memory(size.getValue());
     if (0 != SystemB.INSTANCE.sysctlbyname("machdep.cpu.family", p, size, null, 0)) {
       LOG.error("Failed to get Family. Error code: " + Native.getLastError());
       return "";
     }
     this.cpuFamily = Integer.toString(p.getInt(0));
   }
   return this.cpuFamily;
 }
示例#3
0
 /** {@inheritDoc} */
 @Override
 public boolean isCpu64bit() {
   if (this.cpu64 == null) {
     IntByReference size = new IntByReference(SystemB.INT_SIZE);
     Pointer p = new Memory(size.getValue());
     if (0 != SystemB.INSTANCE.sysctlbyname("hw.cpu64bit_capable", p, size, null, 0)) {
       LOG.error("Failed to get 64Bit_capable. Error code: " + Native.getLastError());
       return false;
     }
     this.cpu64 = p.getInt(0) != 0;
   }
   return this.cpu64.booleanValue();
 }
示例#4
0
 public final int getInt(long offset) {
   checkBounds(offset, 4);
   return ptr.getInt(offset);
 }