lib/sys/unix/sys/cpu.rb in sys-cpu-1.0.6 vs lib/sys/unix/sys/cpu.rb in sys-cpu-1.1.0

- old
+ new

@@ -18,34 +18,45 @@ HW_MACHINE = 1 # Machine class HW_MODEL = 2 # Specific machine model HW_NCPU = 3 # Number of CPU's HW_CPU_FREQ = 15 # CPU frequency - if RbConfig::CONFIG['host_os'] =~ /bsd/ + private_constant :CTL_HW, :HW_MACHINE, :HW_MODEL, :HW_NCPU, :HW_CPU_FREQ + + if RbConfig::CONFIG['host_os'] =~ /bsd|dragonfly/ HW_MACHINE_ARCH = 11 # Machine architecture else HW_MACHINE_ARCH = 12 # Machine architecture end + private_constant :HW_MACHINE_ARCH + SI_MACHINE = 5 SI_ARCHITECTURE = 6 SC_NPROCESSORS_ONLN = 15 + private_constant :SI_MACHINE, :SI_ARCHITECTURE, :SC_NPROCESSORS_ONLN + P_OFFLINE = 1 P_ONLINE = 2 P_FAULTED = 4 P_POWEROFF = 5 P_NOINTR = 6 P_SPARE = 7 + private_constant :P_OFFLINE, :P_ONLINE, :P_FAULTED, :P_POWEROFF, :P_NOINTR, :P_SPARE + CPU_ARCH_ABI64 = 0x01000000 CPU_TYPE_X86 = 7 CPU_TYPE_X86_64 = (CPU_TYPE_X86 | CPU_ARCH_ABI64) CPU_TYPE_SPARC = 14 CPU_TYPE_POWERPC = 18 CPU_TYPE_POWERPC64 = CPU_TYPE_POWERPC | CPU_ARCH_ABI64 + private_constant :CPU_ARCH_ABI64, :CPU_TYPE_X86, :CPU_TYPE_X86_64 + private_constant :CPU_TYPE_SPARC, :CPU_TYPE_POWERPC, :CPU_TYPE_POWERPC64 + begin attach_function( :sysctl, %i[pointer uint pointer pointer pointer size_t], :int @@ -232,10 +243,10 @@ optr = FFI::MemoryPointer.new(:long) size = FFI::MemoryPointer.new(:size_t) size.write_long(optr.size) - if RbConfig::CONFIG['host_os'] =~ /bsd/i + if RbConfig::CONFIG['host_os'] =~ /bsd|dragonfly/i name = 'hw.clockrate' else name = 'hw.cpufrequency' end