From d5f94d73adb4aaa582cbe763ed1c8f0036398f9c Mon Sep 17 00:00:00 2001 From: Jeroen van Rijn Date: Thu, 1 Sep 2022 00:43:47 +0200 Subject: [PATCH 01/25] [sys/info] Initial version. --- core/sys/info/cpu_arm.odin | 26 ++ .../x86/cpu.odin => sys/info/cpu_intel.odin} | 32 +- core/sys/info/platform_darwin.odin | 33 ++ core/sys/info/platform_linux.odin | 54 ++++ core/sys/info/platform_windows.odin | 305 ++++++++++++++++++ core/sys/info/sysinfo.odin | 38 +++ core/sys/windows/kernel32.odin | 18 ++ core/sys/windows/types.odin | 114 +++++++ 8 files changed, 618 insertions(+), 2 deletions(-) create mode 100644 core/sys/info/cpu_arm.odin rename core/{simd/x86/cpu.odin => sys/info/cpu_intel.odin} (75%) create mode 100644 core/sys/info/platform_darwin.odin create mode 100644 core/sys/info/platform_linux.odin create mode 100644 core/sys/info/platform_windows.odin create mode 100644 core/sys/info/sysinfo.odin diff --git a/core/sys/info/cpu_arm.odin b/core/sys/info/cpu_arm.odin new file mode 100644 index 000000000..5a56e3f78 --- /dev/null +++ b/core/sys/info/cpu_arm.odin @@ -0,0 +1,26 @@ +//+build arm32, arm64 +package sysinfo + +// TODO: Set up an enum with the ARM equivalent of the above. +CPU_Feature :: enum u64 {} + +cpu_features: Maybe(CPU_Feature) +cpu_name: Maybe(string) + +@(init, private) +init_cpu_features :: proc "c" () { +} + +@(private) +_cpu_name_buf: [72]u8 + +@(init, private) +init_cpu_name :: proc "c" () { + when ODIN_ARCH == .arm32 { + copy(_cpu_name_buf, "ARM") + cpu_name = string(_cpu_name_buf[:3]) + } else { + copy(_cpu_name_buf, "ARM64") + cpu_name = string(_cpu_name_buf[:5]) + } +} \ No newline at end of file diff --git a/core/simd/x86/cpu.odin b/core/sys/info/cpu_intel.odin similarity index 75% rename from core/simd/x86/cpu.odin rename to core/sys/info/cpu_intel.odin index 14e90c0f0..eeb9c2416 100644 --- a/core/simd/x86/cpu.odin +++ b/core/sys/info/cpu_intel.odin @@ -1,5 +1,5 @@ //+build i386, amd64 -package simd_x86 +package sysinfo import "core:intrinsics" @@ -9,7 +9,6 @@ cpuid :: intrinsics.x86_cpuid // xgetbv :: proc(cx: u32) -> (eax, edx: u32) --- xgetbv :: intrinsics.x86_xgetbv - CPU_Feature :: enum u64 { aes, // AES hardware implementation (AES NI) adx, // Multi-precision add-carry instruction extensions @@ -34,6 +33,7 @@ CPU_Feature :: enum u64 { CPU_Features :: distinct bit_set[CPU_Feature; u64] cpu_features: Maybe(CPU_Features) +cpu_name: Maybe(string) @(init, private) init_cpu_features :: proc "c" () { @@ -92,3 +92,31 @@ init_cpu_features :: proc "c" () { cpu_features = set } + +@(private) +_cpu_name_buf: [72]u8 + +@(init, private) +init_cpu_name :: proc "c" () { + number_of_extended_ids, _, _, _ := cpuid(0x8000_0000, 0) + if number_of_extended_ids < 0x8000_0004 { + return + } + + _buf := transmute(^[0x12]u32)&_cpu_name_buf + _buf[ 0], _buf[ 1], _buf[ 2], _buf[ 3] = cpuid(0x8000_0002, 0) + _buf[ 4], _buf[ 5], _buf[ 6], _buf[ 7] = cpuid(0x8000_0003, 0) + _buf[ 8], _buf[ 9], _buf[10], _buf[11] = cpuid(0x8000_0004, 0) + + // Some CPUs like may include leading or trailing spaces. Trim them. + // e.g. ` Intel(R) Xeon(R) CPU E5-1650 v2 @ 3.50GHz` + + brand := string(_cpu_name_buf[:]) + for len(brand) > 0 && brand[0] == 0 || brand[0] == ' ' { + brand = brand[1:] + } + for len(brand) > 0 && brand[len(brand) - 1] == 0 || brand[len(brand) - 1] == ' ' { + brand = brand[:len(brand) - 1] + } + cpu_name = brand +} \ No newline at end of file diff --git a/core/sys/info/platform_darwin.odin b/core/sys/info/platform_darwin.odin new file mode 100644 index 000000000..0cdfd455d --- /dev/null +++ b/core/sys/info/platform_darwin.odin @@ -0,0 +1,33 @@ +// +build darwin +package sysinfo + +import sys "core:sys/darwin" +import "core:intrinsics" + +@(init, private) +init_os_version :: proc "c" () { + os_version = {} +} + +@(init) +init_ram :: proc() { + // Retrieve RAM info using `sysinfo` + + CTL_HW :: 6 + HW_MEMSIZE :: 24 + + sysctls := []int{CTL_HW, HW_MEMSIZE} + + mem_size: i64 + + if intrinsics.syscall( + uintptr(sys.System_Call_Number.sysctl), + uintptr(raw_data(sysctls)), uintptr(len(sysctls)), + uintptr(&mem_size), uintptr(size_of(mem_size))) == 0 { + return + } + ram.total_ram = int(mem_size) +} + +@(private) +sysctl :: proc(leaf: int) \ No newline at end of file diff --git a/core/sys/info/platform_linux.odin b/core/sys/info/platform_linux.odin new file mode 100644 index 000000000..05f263094 --- /dev/null +++ b/core/sys/info/platform_linux.odin @@ -0,0 +1,54 @@ +// +build linux +package sysinfo + +import "core:c" +import sys "core:sys/unix" +import "core:intrinsics" +// import "core:fmt" + +@(init, private) +init_os_version :: proc "c" () { + os_version = {} +} + +Sys_Info :: struct { + uptime: c.long, // Seconds since boot + loads: [3]c.long, // 1, 5, 15 minute load averages + totalram: c.ulong, // Total usable main memory size + freeram: c.ulong, // Available memory size + sharedram: c.ulong, // Amount of shared memory + bufferram: c.ulong, // Memory used by buffers + totalswap: c.ulong, // Total swap space size + freeswap: c.ulong, // Swap space still available + procs: c.ushort, // Number of current processes + totalhigh: c.ulong, // Total high memory size + freehigh: c.ulong, // Available high memory size + mem_unit: c.int, // Memory unit size in bytes + _padding: [20 - (2 * size_of(c.long)) - size_of(c.int)]u8, +} + +get_sysinfo :: proc "c" () -> (res: Sys_Info, ok: bool) { + si: Sys_Info + err := intrinsics.syscall(sys.SYS_sysinfo, uintptr(rawptr(&si))) + if err != 0 { + // Unable to retrieve sysinfo + return {}, false + } + return si, true +} + +@(init) +init_ram :: proc() { + // Retrieve RAM info using `sysinfo` + si, ok := get_sysinfo() + if !ok { + return + } + + ram = RAM{ + total_ram = int(si.totalram) * int(si.mem_unit), + free_ram = int(si.freeram) * int(si.mem_unit), + total_swap = int(si.totalswap) * int(si.mem_unit), + free_swap = int(si.freeswap) * int(si.mem_unit), + } +} \ No newline at end of file diff --git a/core/sys/info/platform_windows.odin b/core/sys/info/platform_windows.odin new file mode 100644 index 000000000..e5ce7f3c8 --- /dev/null +++ b/core/sys/info/platform_windows.odin @@ -0,0 +1,305 @@ +// +build windows +package sysinfo + +import sys "core:sys/windows" +import "core:intrinsics" +import "core:strings" + + +@(private) +version_string_buf: [1024]u8 + +@(init, private) +init_os_version :: proc () { + /* + NOTE(Jeroen): + `GetVersionEx` will return 6.2 for Windows 10 unless the program is manifested for Windows 10. + `RtlGetVersion` will return the true version. + + Rather than include the WinDDK, we ask the kernel directly. + `HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion` is for the minor build version (Update Build Release) + + */ + osvi: sys.OSVERSIONINFOEXW + osvi.dwOSVersionInfoSize = size_of(osvi) + status := sys.RtlGetVersion(&osvi) + + if status != 0 { + return + } + + product_type: sys.Windows_Product_Type + sys.GetProductInfo( + osvi.dwMajorVersion, osvi.dwMinorVersion, + u32(osvi.wServicePackMajor), u32(osvi.wServicePackMinor), + &product_type, + ) + + os_version = { + platform = .Windows, + major = int(osvi.dwMajorVersion), + minor = int(osvi.dwMinorVersion), + } + os_version.build[0] = int(osvi.dwBuildNumber) + + b := strings.builder_from_bytes(version_string_buf[:]) + + strings.write_string(&b, "Windows ") + + switch osvi.dwMajorVersion { + case 10: + switch osvi.wProductType { + case 1: // VER_NT_WORKSTATION: + if osvi.dwBuildNumber < 22000 { + strings.write_string(&b, "10 ") + } else { + strings.write_string(&b, "11 ") + } + format_windows_product_type(&b, product_type) + + case: // Server or Domain Controller + switch osvi.dwBuildNumber { + case 14393: + strings.write_string(&b, "2016 Server") + case 17763: + strings.write_string(&b, "2019 Server") + case 20348: + strings.write_string(&b, "2022 Server") + case: + strings.write_string(&b, "Unknown Server") + } + } + + case 6: + switch osvi.dwMinorVersion { + case 0: + switch osvi.wProductType { + case 1: // VER_NT_WORKSTATION + strings.write_string(&b, "Windows Vista ") + format_windows_product_type(&b, product_type) + case 3: + strings.write_string(&b, "Windows Server 2008") + } + + case 1: + switch osvi.wProductType { + case 1: // VER_NT_WORKSTATION: + strings.write_string(&b, "Windows 7 ") + format_windows_product_type(&b, product_type) + case 3: + strings.write_string(&b, "Windows Server 2008 R2") + } + + case 2: + switch osvi.wProductType { + case 1: // VER_NT_WORKSTATION: + strings.write_string(&b, "Windows 8 ") + format_windows_product_type(&b, product_type) + case 3: + strings.write_string(&b, "Windows Server 2012") + } + + case 3: + switch osvi.wProductType { + case 1: // VER_NT_WORKSTATION: + strings.write_string(&b, "Windows 8.1 ") + format_windows_product_type(&b, product_type) + case 3: + strings.write_string(&b, "Windows Server 2012 R2") + } + } + + case 5: + switch osvi.dwMinorVersion { + case 0: + strings.write_string(&b, "Windows 2000") + case 1: + strings.write_string(&b, "Windows XP") + case 2: + strings.write_string(&b, "Windows Server 2003") + } + } + + // Grab DisplayVersion + os_version.version = format_display_version(&b) + + // Grab build number and UBR + os_version.build[1] = format_build_number(&b, int(osvi.dwBuildNumber)) + + // Finish the string + os_version.as_string = strings.to_string(b) + + format_windows_product_type :: proc (b: ^strings.Builder, prod_type: sys.Windows_Product_Type) { + #partial switch prod_type { + case .ULTIMATE: + strings.write_string(b, "Ultimate") + + case .HOME_BASIC: + strings.write_string(b, "Home Basic") + + case .HOME_PREMIUM: + strings.write_string(b, "Home Premium") + + case .ENTERPRISE: + strings.write_string(b, "Enterprise") + + case .CORE: + strings.write_string(b, "Home Basic") + + case .HOME_BASIC_N: + strings.write_string(b, "Home Basic N") + + case .EDUCATION: + strings.write_string(b, "Education") + + case .EDUCATION_N: + strings.write_string(b, "Education N") + + case .BUSINESS: + strings.write_string(b, "Business") + + case .STANDARD_SERVER: + strings.write_string(b, "Standard Server") + + case .DATACENTER_SERVER: + strings.write_string(b, "Datacenter") + + case .SMALLBUSINESS_SERVER: + strings.write_string(b, "Windows Small Business Server") + + case .ENTERPRISE_SERVER: + strings.write_string(b, "Enterprise Server") + + case .STARTER: + strings.write_string(b, "Starter") + + case .DATACENTER_SERVER_CORE: + strings.write_string(b, "Datacenter Server Core") + + case .STANDARD_SERVER_CORE: + strings.write_string(b, "Server Standard Core") + + case .ENTERPRISE_SERVER_CORE: + strings.write_string(b, "Enterprise Server Core") + + case .BUSINESS_N: + strings.write_string(b, "Business N") + + case .HOME_SERVER: + strings.write_string(b, "Home Server") + + case .SERVER_FOR_SMALLBUSINESS: + strings.write_string(b, "Windows Server 2008 for Windows Essential Server Solutions") + + case .SMALLBUSINESS_SERVER_PREMIUM: + strings.write_string(b, "Small Business Server Premium") + + case .HOME_PREMIUM_N: + strings.write_string(b, "Home Premium N") + + case .ENTERPRISE_N: + strings.write_string(b, "Enterprise N") + + case .ULTIMATE_N: + strings.write_string(b, "Ultimate N") + + case .HYPERV: + strings.write_string(b, "HyperV") + + case .STARTER_N: + strings.write_string(b, "Starter N") + + case .PROFESSIONAL: + strings.write_string(b, "Professional") + + case .PROFESSIONAL_N: + strings.write_string(b, "Professional N") + + case: + strings.write_string(b, "Unknown Edition") + } + } + + // Grab Windows DisplayVersion (like 20H02) + format_display_version :: proc (b: ^strings.Builder) -> (version: string) { + value_type: ^sys.DWORD + display_version: [256]u16le + value_size := sys.DWORD(size_of(display_version)) + + status := sys.RegGetValueW( + sys.HKEY_LOCAL_MACHINE, + sys.L("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"), + sys.L("DisplayVersion"), + sys.RRF_RT_REG_SZ, + value_type, + raw_data(display_version[:]), + &value_size, + ) + if status != 0 { + // Couldn't retrieve DisplayVersion + return + } + + strings.write_string(b, " (version: ") + l := strings.builder_len(b^) + + for r, i in display_version { + if r == 0 { + s := strings.to_string(b^) + version = string(s[l:][:i]) + break + } + if r < 256 { + strings.write_rune(b, rune(r)) + } + } + strings.write_rune(b, ')') + return + } + + // Grab build number and UBR + format_build_number :: proc (b: ^strings.Builder, major_build: int) -> (ubr: int) { + value_type: ^sys.DWORD + _ubr: sys.DWORD + value_size := sys.DWORD(size_of(ubr)) + + status := sys.RegGetValueW( + sys.HKEY_LOCAL_MACHINE, + sys.L("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"), + sys.L("UBR"), + sys.RRF_RT_REG_DWORD, + value_type, + &_ubr, + &value_size, + ) + + if status != 0 { + // Couldn't retrieve DisplayVersion + return + } + + ubr = int(_ubr) + strings.write_string(b, ", build: ") + strings.write_int(b, major_build) + strings.write_rune(b, '.') + strings.write_int(b, ubr) + return + } +} + +@(init) +init_ram :: proc() { + state: sys.MEMORYSTATUSEX + + state.dwLength = size_of(state) + ok := sys.GlobalMemoryStatusEx(&state) + if !ok { + return + } + ram = RAM{ + total_ram = int(state.ullTotalPhys), + free_ram = int(state.ullAvailPhys), + total_swap = int(state.ullTotalPageFil), + free_swap = int(state.ullAvailPageFil), + } +} \ No newline at end of file diff --git a/core/sys/info/sysinfo.odin b/core/sys/info/sysinfo.odin new file mode 100644 index 000000000..808f0484d --- /dev/null +++ b/core/sys/info/sysinfo.odin @@ -0,0 +1,38 @@ +package sysinfo + +when !(ODIN_ARCH == .amd64 || ODIN_ARCH == .i386 || ODIN_ARCH == .arm32 || ODIN_ARCH == .arm64) { + #assert(false, "This package is unsupported on this architecture.") +} + +os_version: OS_Version +ram: RAM + +OS_Version_Platform :: enum { + Unknown, + Windows, + Linux, + MacOS, + iOS, + FreeBSD, + OpenBSD, + NetBSD, +} + +OS_Version :: struct { + platform: OS_Version_Platform, + + major: int, + minor: int, + patch: int, + build: [2]int, + version: string, + + as_string: string, +} + +RAM :: struct { + total_ram: int, + free_ram: int, + total_swap: int, + free_swap: int, +} \ No newline at end of file diff --git a/core/sys/windows/kernel32.odin b/core/sys/windows/kernel32.odin index f055b6908..03fc295dc 100644 --- a/core/sys/windows/kernel32.odin +++ b/core/sys/windows/kernel32.odin @@ -637,6 +637,13 @@ foreign kernel32 { ) -> BOOL --- } +@(default_calling_convention="stdcall") +foreign kernel32 { + GlobalMemoryStatusEx :: proc( + lpBuffer: ^MEMORYSTATUSEX, + ) -> BOOL --- +} + PBAD_MEMORY_CALLBACK_ROUTINE :: #type proc "stdcall" () @(default_calling_convention="stdcall") @@ -794,3 +801,14 @@ Control_Event :: enum DWORD { logoff = 5, shutdown = 6, } + +@(default_calling_convention="stdcall") +foreign kernel32 { + GetProductInfo :: proc( + OSMajorVersion: DWORD, + OSMinorVersion: DWORD, + SpMajorVersion: DWORD, + SpMinorVersion: DWORD, + product_type: ^Windows_Product_Type, + ) -> BOOL --- +} \ No newline at end of file diff --git a/core/sys/windows/types.odin b/core/sys/windows/types.odin index edf6e593e..1ddbe5bad 100644 --- a/core/sys/windows/types.odin +++ b/core/sys/windows/types.odin @@ -17,6 +17,7 @@ size_t :: c.size_t wchar_t :: c.wchar_t DWORD :: c_ulong +DWORDLONG :: c.ulonglong QWORD :: c.ulonglong HANDLE :: distinct LPVOID HINSTANCE :: HANDLE @@ -3265,3 +3266,116 @@ IFileSaveDialogVtbl :: struct { GetProperties: proc "stdcall" (this: ^IFileSaveDialog, ppStore: ^^IPropertyStore) -> HRESULT, ApplyProperties: proc "stdcall" (this: ^IFileSaveDialog, psi: ^IShellItem, pStore: ^IPropertyStore, hwnd: HWND, pSink: ^IFileOperationProgressSink) -> HRESULT, } + +MEMORYSTATUSEX :: struct { + dwLength: DWORD, + dwMemoryLoad: DWORD, + ullTotalPhys: DWORDLONG, + ullAvailPhys: DWORDLONG, + ullTotalPageFil: DWORDLONG, + ullAvailPageFil: DWORDLONG, + ullTotalVirtual: DWORDLONG, + ullAvailVirtual: DWORDLONG, + ullAvailExtendedVirtual: DWORDLONG, +} + +Windows_Product_Type :: enum DWORD { + BUSINESS = 0x00000006, // Business + BUSINESS_N = 0x00000010, // Business N + CLUSTER_SERVER = 0x00000012, // HPC Edition + CLUSTER_SERVER_V = 0x00000040, // Server Hyper Core V + CORE = 0x00000065, // Windows 10 Home + CORE_COUNTRYSPECIFIC = 0x00000063, // Windows 10 Home China + CORE_N = 0x00000062, // Windows 10 Home N + CORE_SINGLELANGUAGE = 0x00000064, // Windows 10 Home Single Language + DATACENTER_EVALUATION_SERVER = 0x00000050, // Server Datacenter (evaluation installation) + DATACENTER_A_SERVER_CORE = 0x00000091, // Server Datacenter, Semi-Annual Channel (core installation) + STANDARD_A_SERVER_CORE = 0x00000092, // Server Standard, Semi-Annual Channel (core installation) + DATACENTER_SERVER = 0x00000008, // Server Datacenter (full installation. For Server Core installations of Windows Server 2012 and later, use the method, Determining whether Server Core is running.) + DATACENTER_SERVER_CORE = 0x0000000C, // Server Datacenter (core installation, Windows Server 2008 R2 and earlier) + DATACENTER_SERVER_CORE_V = 0x00000027, // Server Datacenter without Hyper-V (core installation) + DATACENTER_SERVER_V = 0x00000025, // Server Datacenter without Hyper-V (full installation) + EDUCATION = 0x00000079, // Windows 10 Education + EDUCATION_N = 0x0000007A, // Windows 10 Education N + ENTERPRISE = 0x00000004, // Windows 10 Enterprise + ENTERPRISE_E = 0x00000046, // Windows 10 Enterprise E + ENTERPRISE_EVALUATION = 0x00000048, // Windows 10 Enterprise Evaluation + ENTERPRISE_N = 0x0000001B, // Windows 10 Enterprise N + ENTERPRISE_N_EVALUATION = 0x00000054, // Windows 10 Enterprise N Evaluation + ENTERPRISE_S = 0x0000007D, // Windows 10 Enterprise 2015 LTSB + ENTERPRISE_S_EVALUATION = 0x00000081, // Windows 10 Enterprise 2015 LTSB Evaluation + ENTERPRISE_S_N = 0x0000007E, // Windows 10 Enterprise 2015 LTSB N + ENTERPRISE_S_N_EVALUATION = 0x00000082, // Windows 10 Enterprise 2015 LTSB N Evaluation + ENTERPRISE_SERVER = 0x0000000A, // Server Enterprise (full installation) + ENTERPRISE_SERVER_CORE = 0x0000000E, // Server Enterprise (core installation) + ENTERPRISE_SERVER_CORE_V = 0x00000029, // Server Enterprise without Hyper-V (core installation) + ENTERPRISE_SERVER_IA64 = 0x0000000F, // Server Enterprise for Itanium-based Systems + ENTERPRISE_SERVER_V = 0x00000026, // Server Enterprise without Hyper-V (full installation) + ESSENTIALBUSINESS_SERVER_ADDL = 0x0000003C, // Windows Essential Server Solution Additional + ESSENTIALBUSINESS_SERVER_ADDLSVC = 0x0000003E, // Windows Essential Server Solution Additional SVC + ESSENTIALBUSINESS_SERVER_MGMT = 0x0000003B, // Windows Essential Server Solution Management + ESSENTIALBUSINESS_SERVER_MGMTSVC = 0x0000003D, // Windows Essential Server Solution Management SVC + HOME_BASIC = 0x00000002, // Home Basic + HOME_BASIC_E = 0x00000043, // Not supported + HOME_BASIC_N = 0x00000005, // Home Basic N + HOME_PREMIUM = 0x00000003, // Home Premium + HOME_PREMIUM_E = 0x00000044, // Not supported + HOME_PREMIUM_N = 0x0000001A, // Home Premium N + HOME_PREMIUM_SERVER = 0x00000022, // Windows Home Server 2011 + HOME_SERVER = 0x00000013, // Windows Storage Server 2008 R2 Essentials + HYPERV = 0x0000002A, // Microsoft Hyper-V Server + IOTENTERPRISE = 0x000000BC, // Windows IoT Enterprise + IOTENTERPRISE_S = 0x000000BF, // Windows IoT Enterprise LTSC + IOTUAP = 0x0000007B, // Windows 10 IoT Core + IOTUAPCOMMERCIAL = 0x00000083, // Windows 10 IoT Core Commercial + MEDIUMBUSINESS_SERVER_MANAGEMENT = 0x0000001E, // Windows Essential Business Server Management Server + MEDIUMBUSINESS_SERVER_MESSAGING = 0x00000020, // Windows Essential Business Server Messaging Server + MEDIUMBUSINESS_SERVER_SECURITY = 0x0000001F, // Windows Essential Business Server Security Server + MOBILE_CORE = 0x00000068, // Windows 10 Mobile + MOBILE_ENTERPRISE = 0x00000085, // Windows 10 Mobile Enterprise + MULTIPOINT_PREMIUM_SERVER = 0x0000004D, // Windows MultiPoint Server Premium (full installation) + MULTIPOINT_STANDARD_SERVER = 0x0000004C, // Windows MultiPoint Server Standard (full installation) + PRO_WORKSTATION = 0x000000A1, // Windows 10 Pro for Workstations + PRO_WORKSTATION_N = 0x000000A2, // Windows 10 Pro for Workstations N + PROFESSIONAL = 0x00000030, // Windows 10 Pro + PROFESSIONAL_E = 0x00000045, // Not supported + PROFESSIONAL_N = 0x00000031, // Windows 10 Pro N + PROFESSIONAL_WMC = 0x00000067, // Professional with Media Center + SB_SOLUTION_SERVER = 0x00000032, // Windows Small Business Server 2011 Essentials + SB_SOLUTION_SERVER_EM = 0x00000036, // Server For SB Solutions EM + SERVER_FOR_SB_SOLUTIONS = 0x00000033, // Server For SB Solutions + SERVER_FOR_SB_SOLUTIONS_EM = 0x00000037, // Server For SB Solutions EM + SERVER_FOR_SMALLBUSINESS = 0x00000018, // Windows Server 2008 for Windows Essential Server Solutions + SERVER_FOR_SMALLBUSINESS_V = 0x00000023, // Windows Server 2008 without Hyper-V for Windows Essential Server Solutions + SERVER_FOUNDATION = 0x00000021, // Server Foundation + SMALLBUSINESS_SERVER = 0x00000009, // Windows Small Business Server + SMALLBUSINESS_SERVER_PREMIUM = 0x00000019, // Small Business Server Premium + SMALLBUSINESS_SERVER_PREMIUM_CORE = 0x0000003F, // Small Business Server Premium (core installation) + SOLUTION_EMBEDDEDSERVER = 0x00000038, // Windows MultiPoint Server + STANDARD_EVALUATION_SERVER = 0x0000004F, // Server Standard (evaluation installation) + STANDARD_SERVER = 0x00000007, // Server Standard (full installation. For Server Core installations of Windows Server 2012 and later, use the method, Determining whether Server Core is running.) + STANDARD_SERVER_CORE = 0x0000000D, // Server Standard (core installation, Windows Server 2008 R2 and earlier) + STANDARD_SERVER_CORE_V = 0x00000028, // Server Standard without Hyper-V (core installation) + STANDARD_SERVER_V = 0x00000024, // Server Standard without Hyper-V + STANDARD_SERVER_SOLUTIONS = 0x00000034, // Server Solutions Premium + STANDARD_SERVER_SOLUTIONS_CORE = 0x00000035, // Server Solutions Premium (core installation) + STARTER = 0x0000000B, // Starter + STARTER_E = 0x00000042, // Not supported + STARTER_N = 0x0000002F, // Starter N + STORAGE_ENTERPRISE_SERVER = 0x00000017, // Storage Server Enterprise + STORAGE_ENTERPRISE_SERVER_CORE = 0x0000002E, // Storage Server Enterprise (core installation) + STORAGE_EXPRESS_SERVER = 0x00000014, // Storage Server Express + STORAGE_EXPRESS_SERVER_CORE = 0x0000002B, // Storage Server Express (core installation) + STORAGE_STANDARD_EVALUATION_SERVER = 0x00000060, // Storage Server Standard (evaluation installation) + STORAGE_STANDARD_SERVER = 0x00000015, // Storage Server Standard + STORAGE_STANDARD_SERVER_CORE = 0x0000002C, // Storage Server Standard (core installation) + STORAGE_WORKGROUP_EVALUATION_SERVER = 0x0000005F, // Storage Server Workgroup (evaluation installation) + STORAGE_WORKGROUP_SERVER = 0x00000016, // Storage Server Workgroup + STORAGE_WORKGROUP_SERVER_CORE = 0x0000002D, // Storage Server Workgroup (core installation) + ULTIMATE = 0x00000001, // Ultimate + ULTIMATE_E = 0x00000047, // Not supported + ULTIMATE_N = 0x0000001C, // Ultimate N + UNDEFINED = 0x00000000, // An unknown product + WEB_SERVER = 0x00000011, // Web Server (full installation) + WEB_SERVER_CORE = 0x0000001D, // Web Server (core installation) +} \ No newline at end of file From 7479ac48e833a967881eb9bc8ddd2dfd76c25b8d Mon Sep 17 00:00:00 2001 From: Jeroen van Rijn Date: Thu, 1 Sep 2022 02:06:05 +0200 Subject: [PATCH 02/25] [sys/info] Parse kernel/distro info. --- core/sys/info/platform_linux.odin | 88 ++++++++++++++++++++++++++++- core/sys/info/platform_windows.odin | 10 ++-- 2 files changed, 89 insertions(+), 9 deletions(-) diff --git a/core/sys/info/platform_linux.odin b/core/sys/info/platform_linux.odin index 05f263094..d1f9ca599 100644 --- a/core/sys/info/platform_linux.odin +++ b/core/sys/info/platform_linux.odin @@ -4,11 +4,93 @@ package sysinfo import "core:c" import sys "core:sys/unix" import "core:intrinsics" -// import "core:fmt" +import "core:os" +import "core:strings" +import "core:strconv" + +@(private) +version_string_buf: [1024]u8 @(init, private) -init_os_version :: proc "c" () { - os_version = {} +init_os_version :: proc () { + os_version.platform = .Linux + + // Try to parse `/etc/os-release` for `PRETTY_NAME="Ubuntu 20.04.3 LTS` + fd, err := os.open("/etc/os-release", os.O_RDONLY, 0) + if err != 0 { + return + } + defer os.close(fd) + + os_release_buf: [2048]u8 + n, read_err := os.read(fd, os_release_buf[:]) + if read_err != 0 { + return + } + release := string(os_release_buf[:n]) + + NEEDLE :: "PRETTY_NAME=\"" + pretty_start := strings.index(release, NEEDLE) + + b := strings.builder_from_bytes(version_string_buf[:]) + + if pretty_start > 0 { + for r, i in release[pretty_start + len(NEEDLE):] { + if r == '"' { + strings.write_string(&b, release[pretty_start + len(NEEDLE):][:i]) + break + } else if r == '\r' || r == '\n' { + strings.write_string(&b, "Unknown Linux Distro") + break + } + } + } + + NEW_UTS_LEN :: 64 + UTS_Name :: struct { + sys_name: [NEW_UTS_LEN + 1]u8 `fmt:"s,0"`, + node_name: [NEW_UTS_LEN + 1]u8 `fmt:"s,0"`, + release: [NEW_UTS_LEN + 1]u8 `fmt:"s,0"`, + version: [NEW_UTS_LEN + 1]u8 `fmt:"s,0"`, + machine: [NEW_UTS_LEN + 1]u8 `fmt:"s,0"`, + domain_name: [NEW_UTS_LEN + 1]u8 `fmt:"s,0"`, + } + uts: UTS_Name + + // Grab kernel info using `uname()` syscall, https://linux.die.net/man/2/uname + if intrinsics.syscall(sys.SYS_uname, uintptr(&uts)) != 0 { + return + } + + strings.write_string(&b, ", ") + strings.write_string(&b, string(cstring(&uts.sys_name[0]))) + strings.write_rune(&b, ' ') + + l := strings.builder_len(b) + strings.write_string(&b, string(cstring(&uts.release[0]))) + + // Parse kernel version, as substrings of the version info in `version_string_buf` + version_bits := strings.split_n(strings.to_string(b)[l:], "-", 2, context.temp_allocator) + if len(version_bits) > 1 { + os_version.version = version_bits[1] + } + + // Parse major, minor, patch from release info + triplet := strings.split(version_bits[0], ".", context.temp_allocator) + if len(triplet) == 3 { + major, major_ok := strconv.parse_int(triplet[0]) + minor, minor_ok := strconv.parse_int(triplet[1]) + patch, patch_ok := strconv.parse_int(triplet[2]) + + if major_ok && minor_ok && patch_ok { + os_version.major = major + os_version.minor = minor + os_version.patch = patch + } + } + + // Finish the string + os_version.as_string = strings.to_string(b) } Sys_Info :: struct { diff --git a/core/sys/info/platform_windows.odin b/core/sys/info/platform_windows.odin index e5ce7f3c8..366735963 100644 --- a/core/sys/info/platform_windows.odin +++ b/core/sys/info/platform_windows.odin @@ -20,6 +20,8 @@ init_os_version :: proc () { `HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion` is for the minor build version (Update Build Release) */ + os_version.platform = .Windows + osvi: sys.OSVERSIONINFOEXW osvi.dwOSVersionInfoSize = size_of(osvi) status := sys.RtlGetVersion(&osvi) @@ -35,15 +37,11 @@ init_os_version :: proc () { &product_type, ) - os_version = { - platform = .Windows, - major = int(osvi.dwMajorVersion), - minor = int(osvi.dwMinorVersion), - } + os_version.major = int(osvi.dwMajorVersion) + os_version.minor = int(osvi.dwMinorVersion) os_version.build[0] = int(osvi.dwBuildNumber) b := strings.builder_from_bytes(version_string_buf[:]) - strings.write_string(&b, "Windows ") switch osvi.dwMajorVersion { From 0f3cebd2b7dee02368cbdb8f92e6fb21a5a91321 Mon Sep 17 00:00:00 2001 From: Jeroen van Rijn Date: Thu, 1 Sep 2022 16:05:49 +0200 Subject: [PATCH 03/25] [sys/info] Retrieve GPU info on Windows. --- core/sys/info/platform_windows.odin | 168 ++++++++++++++++++++-------- core/sys/info/sysinfo.odin | 7 ++ 2 files changed, 127 insertions(+), 48 deletions(-) diff --git a/core/sys/info/platform_windows.odin b/core/sys/info/platform_windows.odin index 366735963..f7f689346 100644 --- a/core/sys/info/platform_windows.odin +++ b/core/sys/info/platform_windows.odin @@ -4,7 +4,9 @@ package sysinfo import sys "core:sys/windows" import "core:intrinsics" import "core:strings" +import "core:unicode/utf16" +import "core:fmt" @(private) version_string_buf: [1024]u8 @@ -220,67 +222,40 @@ init_os_version :: proc () { // Grab Windows DisplayVersion (like 20H02) format_display_version :: proc (b: ^strings.Builder) -> (version: string) { - value_type: ^sys.DWORD - display_version: [256]u16le - value_size := sys.DWORD(size_of(display_version)) - - status := sys.RegGetValueW( + dv, ok := read_reg( sys.HKEY_LOCAL_MACHINE, - sys.L("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"), - sys.L("DisplayVersion"), - sys.RRF_RT_REG_SZ, - value_type, - raw_data(display_version[:]), - &value_size, + "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", + "DisplayVersion", + string, ) - if status != 0 { - // Couldn't retrieve DisplayVersion - return - } + defer delete(dv) // It'll be interned into `version_string_buf` - strings.write_string(b, " (version: ") - l := strings.builder_len(b^) - - for r, i in display_version { - if r == 0 { - s := strings.to_string(b^) - version = string(s[l:][:i]) - break - } - if r < 256 { - strings.write_rune(b, rune(r)) - } + if ok { + strings.write_string(b, " (version: ") + l := strings.builder_len(b^) + strings.write_string(b, dv) + version = strings.to_string(b^)[l:][:len(dv)] + strings.write_rune(b, ')') } - strings.write_rune(b, ')') return } // Grab build number and UBR format_build_number :: proc (b: ^strings.Builder, major_build: int) -> (ubr: int) { - value_type: ^sys.DWORD - _ubr: sys.DWORD - value_size := sys.DWORD(size_of(ubr)) - - status := sys.RegGetValueW( + res, ok := read_reg( sys.HKEY_LOCAL_MACHINE, - sys.L("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"), - sys.L("UBR"), - sys.RRF_RT_REG_DWORD, - value_type, - &_ubr, - &value_size, + "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", + "UBR", + i32, ) - if status != 0 { - // Couldn't retrieve DisplayVersion - return + if ok { + ubr = int(res) + strings.write_string(b, ", build: ") + strings.write_int(b, major_build) + strings.write_rune(b, '.') + strings.write_int(b, ubr) } - - ubr = int(_ubr) - strings.write_string(b, ", build: ") - strings.write_int(b, major_build) - strings.write_rune(b, '.') - strings.write_int(b, ubr) return } } @@ -300,4 +275,101 @@ init_ram :: proc() { total_swap = int(state.ullTotalPageFil), free_swap = int(state.ullAvailPageFil), } +} + +@(init, private) +init_gpu_info :: proc() { + + GPU_INFO_BASE :: "SYSTEM\\ControlSet001\\Control\\Class\\{4d36e968-e325-11ce-bfc1-08002be10318}\\" + + gpu_list: [dynamic]GPU + gpu_index: int + + for { + key := fmt.tprintf("%v\\%04d", GPU_INFO_BASE, gpu_index) + + if vendor, ok := read_reg(sys.HKEY_LOCAL_MACHINE, key, "ProviderName", string); ok { + append(&gpu_list, GPU{vendor_name = vendor}) + } else { + break + } + + if desc, ok := read_reg(sys.HKEY_LOCAL_MACHINE, key, "DriverDesc", string); ok { + gpu_list[gpu_index].model_name = desc + } + + if vram, ok := read_reg(sys.HKEY_LOCAL_MACHINE, key, "HardwareInformation.qwMemorySize", i64); ok { + gpu_list[gpu_index].total_ram = int(vram) + } + gpu_index += 1 + } + gpus = gpu_list[:] +} + +@(private) +read_reg :: proc(hkey: sys.HKEY, subkey, val: string, $T: typeid) -> (res: T, ok: bool) { + BUF_SIZE :: 1024 + + if len(subkey) == 0 || len(val) == 0 { + return {}, false + } + + key_name_wide := make([]u16, BUF_SIZE, context.temp_allocator) + val_name_wide := make([]u16, BUF_SIZE, context.temp_allocator) + + utf16.encode_string(key_name_wide, subkey) + utf16.encode_string(val_name_wide, val) + + when T == string { + result_wide := make([]u16, BUF_SIZE, context.temp_allocator) + result_size := sys.DWORD(BUF_SIZE * size_of(u16)) + + status := sys.RegGetValueW( + hkey, + &key_name_wide[0], + &val_name_wide[0], + sys.RRF_RT_REG_SZ, + nil, + raw_data(result_wide[:]), + &result_size, + ) + if status != 0 { + // Couldn't retrieve string + return + } + + // Result string will be allocated for the caller. + result_utf8 := make([]u8, BUF_SIZE * 4, context.temp_allocator) + utf16.decode_to_utf8(result_utf8, result_wide[:result_size]) + return strings.clone_from_cstring(cstring(raw_data(result_utf8))), true + + } else when T == i32 { + result_size := sys.DWORD(size_of(i32)) + status := sys.RegGetValueW( + hkey, + &key_name_wide[0], + &val_name_wide[0], + sys.RRF_RT_REG_DWORD, + nil, + &res, + &result_size, + ) + return res, status == 0 + + } else when T == i64 { + result_size := sys.DWORD(size_of(i64)) + status := sys.RegGetValueW( + hkey, + &key_name_wide[0], + &val_name_wide[0], + sys.RRF_RT_REG_QWORD, + nil, + &res, + &result_size, + ) + return res, status == 0 + } else { + #assert(false, "Unhandled type for read_reg") + } + return } \ No newline at end of file diff --git a/core/sys/info/sysinfo.odin b/core/sys/info/sysinfo.odin index 808f0484d..69f9f1584 100644 --- a/core/sys/info/sysinfo.odin +++ b/core/sys/info/sysinfo.odin @@ -6,6 +6,7 @@ when !(ODIN_ARCH == .amd64 || ODIN_ARCH == .i386 || ODIN_ARCH == .arm32 || ODIN_ os_version: OS_Version ram: RAM +gpus: []GPU OS_Version_Platform :: enum { Unknown, @@ -35,4 +36,10 @@ RAM :: struct { free_ram: int, total_swap: int, free_swap: int, +} + +GPU :: struct { + vendor_name: string, + model_name: string, + total_ram: int, } \ No newline at end of file From f5d13dc5688f81c81a5054c0053cd1f20cb3904b Mon Sep 17 00:00:00 2001 From: Jeroen van Rijn Date: Fri, 2 Sep 2022 01:26:58 +0200 Subject: [PATCH 04/25] [sys/info] Add MacOS memory size --- core/sys/info/platform_darwin.odin | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/core/sys/info/platform_darwin.odin b/core/sys/info/platform_darwin.odin index 0cdfd455d..54b60b70b 100644 --- a/core/sys/info/platform_darwin.odin +++ b/core/sys/info/platform_darwin.odin @@ -3,6 +3,7 @@ package sysinfo import sys "core:sys/darwin" import "core:intrinsics" +import "core:fmt" @(init, private) init_os_version :: proc "c" () { @@ -16,17 +17,20 @@ init_ram :: proc() { CTL_HW :: 6 HW_MEMSIZE :: 24 - sysctls := []int{CTL_HW, HW_MEMSIZE} + sysctls := []i32{CTL_HW, HW_MEMSIZE} - mem_size: i64 + result: i64 + result_size := i64(size_of(result)) - if intrinsics.syscall( - uintptr(sys.System_Call_Number.sysctl), - uintptr(raw_data(sysctls)), uintptr(len(sysctls)), - uintptr(&mem_size), uintptr(size_of(mem_size))) == 0 { - return - } - ram.total_ram = int(mem_size) + res := intrinsics.syscall( + sys.unix_offset_syscall(.sysctl), + uintptr(&sysctls[0]), uintptr(2), + uintptr(&result), uintptr(&result_size), + uintptr(0), uintptr(0), + ) + fmt.println(res, result) + + ram.total_ram = int(result) } @(private) From 9e47c72b98b63a7c3780bf5e62203f537cac40b5 Mon Sep 17 00:00:00 2001 From: Jeroen van Rijn Date: Fri, 2 Sep 2022 01:45:04 +0200 Subject: [PATCH 05/25] [sys/info] Better sysctl wrapper --- core/sys/info/platform_darwin.odin | 34 +++++++++++++++--------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/core/sys/info/platform_darwin.odin b/core/sys/info/platform_darwin.odin index 54b60b70b..f0b572d2b 100644 --- a/core/sys/info/platform_darwin.odin +++ b/core/sys/info/platform_darwin.odin @@ -3,11 +3,10 @@ package sysinfo import sys "core:sys/darwin" import "core:intrinsics" -import "core:fmt" @(init, private) init_os_version :: proc "c" () { - os_version = {} + os_version.platform = .MacOS } @(init) @@ -17,21 +16,22 @@ init_ram :: proc() { CTL_HW :: 6 HW_MEMSIZE :: 24 - sysctls := []i32{CTL_HW, HW_MEMSIZE} - - result: i64 - result_size := i64(size_of(result)) - - res := intrinsics.syscall( - sys.unix_offset_syscall(.sysctl), - uintptr(&sysctls[0]), uintptr(2), - uintptr(&result), uintptr(&result_size), - uintptr(0), uintptr(0), - ) - fmt.println(res, result) - - ram.total_ram = int(result) + mib := []i32{CTL_HW, HW_MEMSIZE} + mem_size: i64 + ok := sysctl(mib, &mem_size) + ram.total_ram = int(mem_size) } @(private) -sysctl :: proc(leaf: int) \ No newline at end of file +sysctl :: proc(mib: []i32, val: ^$T) -> (ok: bool) { + mib := mib + result_size := i64(size_of(T)) + + res := intrinsics.syscall( + sys.unix_offset_syscall(.sysctl), + uintptr(raw_data(mib)), uintptr(len(mib)), + uintptr(val), uintptr(&result_size), + uintptr(0), uintptr(0), + ) + return res == 0 +} \ No newline at end of file From 45691a462282016368d1740fccb4488a331ca172 Mon Sep 17 00:00:00 2001 From: Jeroen van Rijn Date: Fri, 2 Sep 2022 02:14:48 +0200 Subject: [PATCH 06/25] [sys/info] Add sysctl MIBs for MacOS. --- core/sys/info/platform_darwin.odin | 31 ++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/core/sys/info/platform_darwin.odin b/core/sys/info/platform_darwin.odin index f0b572d2b..21153a6ad 100644 --- a/core/sys/info/platform_darwin.odin +++ b/core/sys/info/platform_darwin.odin @@ -13,9 +13,6 @@ init_os_version :: proc "c" () { init_ram :: proc() { // Retrieve RAM info using `sysinfo` - CTL_HW :: 6 - HW_MEMSIZE :: 24 - mib := []i32{CTL_HW, HW_MEMSIZE} mem_size: i64 ok := sysctl(mib, &mem_size) @@ -34,4 +31,30 @@ sysctl :: proc(mib: []i32, val: ^$T) -> (ok: bool) { uintptr(0), uintptr(0), ) return res == 0 -} \ No newline at end of file +} + +// See sysctl.h for xnu/dwrwin for details +CTL_KERN :: 1 + KERN_OSTYPE :: 1 /* string: system version */ + KERN_OSRELEASE :: 2 /* string: system release */ + KERN_OSREV :: 3 /* int: system revision */ + KERN_VERSION :: 4 /* string: compile time info */ + KERN_OSRELDATE :: 26 /* int: OS release date */ + KERN_OSVERSION :: 65 /* for build number i.e. 9A127 */ +CTL_VM :: 2 +CTL_VFS :: 3 +CTL_NET :: 4 +CTL_DEBUG :: 5 +CTL_HW :: 6 + HW_MACHINE :: 1 /* string: machine class */ + HW_MODEL :: 2 /* string: specific machine model */ + HW_NCPU :: 3 /* int: number of cpus */ + HW_BYTEORDER :: 4 /* int: machine byte order */ + HW_MACHINE_ARCH :: 12 /* string: machine architecture */ + HW_VECTORUNIT :: 13 /* int: has HW vector unit? */ + HW_MEMSIZE :: 24 /* uint64_t: physical ram size */ + HW_AVAILCPU :: 25 /* int: number of available CPUs */ + +CTL_MACHDEP :: 7 +CTL_USER :: 8 + From 1637de3ebbe8c165895e4e9642a78aa951e57fe2 Mon Sep 17 00:00:00 2001 From: Jeroen van Rijn Date: Fri, 2 Sep 2022 04:11:02 +0200 Subject: [PATCH 07/25] [sys/info] Parse xnu kernel version --- core/sys/info/platform_darwin.odin | 45 ++++++++++++++++++++++-------- 1 file changed, 34 insertions(+), 11 deletions(-) diff --git a/core/sys/info/platform_darwin.odin b/core/sys/info/platform_darwin.odin index 21153a6ad..50ec6e124 100644 --- a/core/sys/info/platform_darwin.odin +++ b/core/sys/info/platform_darwin.odin @@ -3,10 +3,33 @@ package sysinfo import sys "core:sys/darwin" import "core:intrinsics" +import "core:strconv" +import "core:strings" +import "core:fmt" @(init, private) -init_os_version :: proc "c" () { +init_os_version :: proc () { os_version.platform = .MacOS + + mib := []i32{CTL_KERN, KERN_OSRELEASE} + version_bits: [12]u8 // enough for 999.999.999\x00 + ok := sysctl(mib, &version_bits) + if !ok { + return + } + + triplet := strings.split(string(cstring(&version_bits[0])), ".", context.temp_allocator) + if len(triplet) == 3 { + major, major_ok := strconv.parse_int(triplet[0]) + minor, minor_ok := strconv.parse_int(triplet[1]) + patch, patch_ok := strconv.parse_int(triplet[2]) + + if major_ok && minor_ok && patch_ok { + os_version.major = major + os_version.minor = minor + os_version.patch = patch + } + } } @(init) @@ -14,7 +37,7 @@ init_ram :: proc() { // Retrieve RAM info using `sysinfo` mib := []i32{CTL_HW, HW_MEMSIZE} - mem_size: i64 + mem_size: u64 ok := sysctl(mib, &mem_size) ram.total_ram = int(mem_size) } @@ -35,24 +58,24 @@ sysctl :: proc(mib: []i32, val: ^$T) -> (ok: bool) { // See sysctl.h for xnu/dwrwin for details CTL_KERN :: 1 - KERN_OSTYPE :: 1 /* string: system version */ - KERN_OSRELEASE :: 2 /* string: system release */ - KERN_OSREV :: 3 /* int: system revision */ - KERN_VERSION :: 4 /* string: compile time info */ - KERN_OSRELDATE :: 26 /* int: OS release date */ - KERN_OSVERSION :: 65 /* for build number i.e. 9A127 */ + KERN_OSTYPE :: 1 // Darwin + KERN_OSRELEASE :: 2 // 21.5.0 for 12.4 Monterey + KERN_OSREV :: 3 // i32: system revision + KERN_VERSION :: 4 // Darwin Kernel Version 21.5.0: Tue Apr 26 21:08:22 PDT 2022; root:xnu-8020.121.3~4/RELEASE_X86_64 + KERN_OSRELDATE :: 26 // i32: OS release date + KERN_OSVERSION :: 65 // Build number, e.g. 21F79 CTL_VM :: 2 CTL_VFS :: 3 CTL_NET :: 4 CTL_DEBUG :: 5 CTL_HW :: 6 - HW_MACHINE :: 1 /* string: machine class */ - HW_MODEL :: 2 /* string: specific machine model */ + HW_MACHINE :: 1 // x86_64 + HW_MODEL :: 2 // MacbookPro14,1 HW_NCPU :: 3 /* int: number of cpus */ HW_BYTEORDER :: 4 /* int: machine byte order */ HW_MACHINE_ARCH :: 12 /* string: machine architecture */ HW_VECTORUNIT :: 13 /* int: has HW vector unit? */ - HW_MEMSIZE :: 24 /* uint64_t: physical ram size */ + HW_MEMSIZE :: 24 // u64 HW_AVAILCPU :: 25 /* int: number of available CPUs */ CTL_MACHDEP :: 7 From d1a204a784cc94913b589427d0de07a55e3e185a Mon Sep 17 00:00:00 2001 From: Jeroen van Rijn Date: Fri, 2 Sep 2022 21:15:34 +0200 Subject: [PATCH 08/25] [sys/info] Add detection for Catalina, Big Sur, Monterey. --- core/sys/info/platform_darwin.odin | 235 +++++++++++++++++++++++++++-- 1 file changed, 221 insertions(+), 14 deletions(-) diff --git a/core/sys/info/platform_darwin.odin b/core/sys/info/platform_darwin.odin index 50ec6e124..5a0714b8f 100644 --- a/core/sys/info/platform_darwin.odin +++ b/core/sys/info/platform_darwin.odin @@ -7,29 +7,107 @@ import "core:strconv" import "core:strings" import "core:fmt" +@(private) +version_string_buf: [1024]u8 + @(init, private) init_os_version :: proc () { os_version.platform = .MacOS - mib := []i32{CTL_KERN, KERN_OSRELEASE} - version_bits: [12]u8 // enough for 999.999.999\x00 - ok := sysctl(mib, &version_bits) + // Start building display version + b := strings.builder_from_bytes(version_string_buf[:]) + + mib := []i32{CTL_KERN, KERN_OSVERSION} + build_buf: [12]u8 + + ok := sysctl(mib, &build_buf) if !ok { + strings.write_string(&b, "macOS Unknown") + os_version.as_string = strings.to_string(b) return } - triplet := strings.split(string(cstring(&version_bits[0])), ".", context.temp_allocator) - if len(triplet) == 3 { - major, major_ok := strconv.parse_int(triplet[0]) - minor, minor_ok := strconv.parse_int(triplet[1]) - patch, patch_ok := strconv.parse_int(triplet[2]) + build := string(cstring(&build_buf[0])) - if major_ok && minor_ok && patch_ok { - os_version.major = major - os_version.minor = minor - os_version.patch = patch + // Do we have an exact match? + match: Darwin_Match + rel, exact := macos_release_map[build] + + if exact { + match = .Exact + } else { + // Match on XNU kernel version + mib = []i32{CTL_KERN, KERN_OSRELEASE} + version_bits: [12]u8 // enough for 999.999.999\x00 + have_kernel_version := sysctl(mib, &version_bits) + + major_ok, minor_ok, patch_ok: bool + + triplet := strings.split(string(cstring(&version_bits[0])), ".", context.temp_allocator) + if len(triplet) != 3 { + have_kernel_version = false + } else { + rel.darwin.x, major_ok = strconv.parse_int(triplet[0]) + rel.darwin.y, minor_ok = strconv.parse_int(triplet[1]) + rel.darwin.z, patch_ok = strconv.parse_int(triplet[2]) + + if !(major_ok && minor_ok && patch_ok) { + have_kernel_version = false + } } + + if !have_kernel_version { + // We don't know the kernel version, but we do know the build + strings.write_string(&b, "macOS Unknown (build ") + l := strings.builder_len(b) + strings.write_string(&b, build) + os_version.version = strings.to_string(b)[l:] + strings.write_rune(&b, ')') + os_version.as_string = strings.to_string(b) + return + } + rel, match = map_darwin_kernel_version_to_macos_release(build, rel.darwin) } + + os_version.major = rel.darwin.x + os_version.minor = rel.darwin.y + os_version.patch = rel.darwin.z + + strings.write_string(&b, rel.os_name) + if match == .Exact || match == .Nearest { + strings.write_rune(&b, ' ') + strings.write_string(&b, rel.release.name) + strings.write_rune(&b, ' ') + strings.write_int(&b, rel.release.version.x) + if rel.release.version.y > 0 || rel.release.version.z > 0 { + strings.write_rune(&b, '.') + strings.write_int(&b, rel.release.version.y) + } + if rel.release.version.z > 0 { + strings.write_rune(&b, '.') + strings.write_int(&b, rel.release.version.z) + } + if match == .Nearest { + strings.write_rune(&b, '?') + } + } else { + strings.write_string(&b, " Unknown") + } + + strings.write_string(&b, " (build ") + l := strings.builder_len(b) + strings.write_string(&b, build) + os_version.version = strings.to_string(b)[l:] + + strings.write_string(&b, ", kernel ") + strings.write_int(&b, rel.darwin.x) + strings.write_rune(&b, '.') + strings.write_int(&b, rel.darwin.y) + strings.write_rune(&b, '.') + strings.write_int(&b, rel.darwin.z) + strings.write_rune(&b, ')') + + os_version.as_string = strings.to_string(b) } @(init) @@ -56,12 +134,12 @@ sysctl :: proc(mib: []i32, val: ^$T) -> (ok: bool) { return res == 0 } -// See sysctl.h for xnu/dwrwin for details +// See sysctl.h for darwin/dwrwin for details CTL_KERN :: 1 KERN_OSTYPE :: 1 // Darwin KERN_OSRELEASE :: 2 // 21.5.0 for 12.4 Monterey KERN_OSREV :: 3 // i32: system revision - KERN_VERSION :: 4 // Darwin Kernel Version 21.5.0: Tue Apr 26 21:08:22 PDT 2022; root:xnu-8020.121.3~4/RELEASE_X86_64 + KERN_VERSION :: 4 // Darwin Kernel Version 21.5.0: Tue Apr 26 21:08:22 PDT 2022; root:darwin-8020.121.3~4/RELEASE_X86_64 KERN_OSRELDATE :: 26 // i32: OS release date KERN_OSVERSION :: 65 // Build number, e.g. 21F79 CTL_VM :: 2 @@ -81,3 +159,132 @@ CTL_HW :: 6 CTL_MACHDEP :: 7 CTL_USER :: 8 +@(private) +Darwin_To_Release :: struct { + darwin: [3]int, // Darwin kernel triplet + os_name: string, // OS X, MacOS + release: struct { + name: string, // Monterey, Mojave, etc. + version: [3]int, // 12.4, etc. + }, +} + +// Important: Order from lowest to highest kernel version +@(private) +macos_release_map: map[string]Darwin_To_Release = { + // MacOS Catalina + "19A583" = {{19, 0, 0}, "macOS", {"Catalina", {10, 15, 0}}}, + "19A602" = {{19, 0, 0}, "macOS", {"Catalina", {10, 15, 0}}}, + "19A603" = {{19, 0, 0}, "macOS", {"Catalina", {10, 15, 0}}}, + "19B88" = {{19, 0, 0}, "macOS", {"Catalina", {10, 15, 1}}}, + "19C57" = {{19, 2, 0}, "macOS", {"Catalina", {10, 15, 2}}}, + "19C58" = {{19, 2, 0}, "macOS", {"Catalina", {10, 15, 2}}}, + "19D76" = {{19, 3, 0}, "macOS", {"Catalina", {10, 15, 3}}}, + "19E266" = {{19, 4, 0}, "macOS", {"Catalina", {10, 15, 4}}}, + "19E287" = {{19, 4, 0}, "macOS", {"Catalina", {10, 15, 4}}}, + "19F96" = {{19, 5, 0}, "macOS", {"Catalina", {10, 15, 5}}}, + "19F101" = {{19, 5, 0}, "macOS", {"Catalina", {10, 15, 5}}}, + "19G73" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 6}}}, + "19G2021" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 6}}}, + "19H2" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, + "19H4" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, + "19H15" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, + "19H114" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, + "19H512" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, + "19H524" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, + "19H1030" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, + "19H1217" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, + "19H1323" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, + "19H1417" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, + "19H1419" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, + "19H1519" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, + "19H1615" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, + "19H1713" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, + "19H1715" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, + "19H1824" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, + "19H1922" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, + "19H2026" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, + + // MacOS Big Sur + "20A2411" = {{20, 1, 0}, "macOS", {"Big Sur", {11, 0, 0}}}, + "20B29" = {{20, 1, 0}, "macOS", {"Big Sur", {11, 0, 1}}}, + "20B50" = {{20, 1, 0}, "macOS", {"Big Sur", {11, 0, 1}}}, + "20C69" = {{20, 2, 0}, "macOS", {"Big Sur", {11, 1, 0}}}, + "20D64" = {{20, 3, 0}, "macOS", {"Big Sur", {11, 2, 0}}}, + "20D74" = {{20, 3, 0}, "macOS", {"Big Sur", {11, 2, 1}}}, + "20D75" = {{20, 3, 0}, "macOS", {"Big Sur", {11, 2, 1}}}, + "20D80" = {{20, 3, 0}, "macOS", {"Big Sur", {11, 2, 2}}}, + "20D91" = {{20, 3, 0}, "macOS", {"Big Sur", {11, 2, 3}}}, + "20E232" = {{20, 4, 0}, "macOS", {"Big Sur", {11, 3, 0}}}, + "20E241" = {{20, 4, 0}, "macOS", {"Big Sur", {11, 3, 1}}}, + "20F71" = {{20, 5, 0}, "macOS", {"Big Sur", {11, 4, 0}}}, + "20G71" = {{20, 6, 0}, "macOS", {"Big Sur", {11, 5, 0}}}, + "20G80" = {{20, 6, 0}, "macOS", {"Big Sur", {11, 5, 1}}}, + "20G95" = {{20, 6, 0}, "macOS", {"Big Sur", {11, 5, 2}}}, + "20G165" = {{20, 6, 0}, "macOS", {"Big Sur", {11, 6, 0}}}, + "20G224" = {{20, 6, 0}, "macOS", {"Big Sur", {11, 6, 1}}}, + "20G314" = {{20, 6, 0}, "macOS", {"Big Sur", {11, 6, 2}}}, + "20G415" = {{20, 6, 0}, "macOS", {"Big Sur", {11, 6, 3}}}, + "20G417" = {{20, 6, 0}, "macOS", {"Big Sur", {11, 6, 4}}}, + "20G527" = {{20, 6, 0}, "macOS", {"Big Sur", {11, 6, 5}}}, + "20G624" = {{20, 6, 0}, "macOS", {"Big Sur", {11, 6, 6}}}, + "20G630" = {{20, 6, 0}, "macOS", {"Big Sur", {11, 6, 7}}}, + "20G730" = {{20, 6, 0}, "macOS", {"Big Sur", {11, 6, 8}}}, + + // MacOS Monterey + "21A344" = {{21, 0, 1}, "macOS", {"Monterey", {12, 0, 0}}}, + "21A559" = {{21, 1, 0}, "macOS", {"Monterey", {12, 0, 1}}}, + "21C52" = {{21, 2, 0}, "macOS", {"Monterey", {12, 1, 0}}}, + "21D49" = {{21, 3, 0}, "macOS", {"Monterey", {12, 2, 0}}}, + "21D62" = {{21, 3, 0}, "macOS", {"Monterey", {12, 2, 1}}}, + "21E230" = {{21, 4, 0}, "macOS", {"Monterey", {12, 3, 0}}}, + "21E258" = {{21, 4, 0}, "macOS", {"Monterey", {12, 3, 1}}}, + "21F79" = {{21, 5, 0}, "macOS", {"Monterey", {12, 4, 0}}}, + "21F2081" = {{21, 5, 0}, "macOS", {"Monterey", {12, 4, 0}}}, + "21F2092" = {{21, 5, 0}, "macOS", {"Monterey", {12, 4, 0}}}, + "21G72" = {{21, 6, 0}, "macOS", {"Monterey", {12, 5, 0}}}, + "21G83" = {{21, 6, 0}, "macOS", {"Monterey", {12, 5, 1}}}, +} + +@(private) +Darwin_Match :: enum { + Unknown, + Exact, + Nearest, +} + +@(private) +map_darwin_kernel_version_to_macos_release :: proc(build: string, darwin: [3]int) -> (res: Darwin_To_Release, match: Darwin_Match) { + // Find exact release match if possible. + if v, v_ok := macos_release_map[build]; v_ok { + return v, .Exact + } + + nearest: Darwin_To_Release + for _, v in macos_release_map { + // Try an exact match on XNU version first. + if darwin == v.darwin { + return v, .Exact + } + + // Major kernel version needs to match exactly, + // otherwise the release is considered .Unknown + if darwin.x == v.darwin.x { + if nearest == {} { + nearest = v + } + if darwin.y >= v.darwin.y && v.darwin != nearest.darwin { + nearest = v + if darwin.z >= v.darwin.z && v.darwin != nearest.darwin { + nearest = v + } + } + } + } + + if nearest == {} { + return {darwin, "macOS", {"Unknown", {}}}, .Unknown + } else { + return nearest, .Nearest + } +} \ No newline at end of file From 0743dd195d28837896eafbf6396461b3c0179407 Mon Sep 17 00:00:00 2001 From: Jeroen van Rijn Date: Fri, 2 Sep 2022 22:46:24 +0200 Subject: [PATCH 09/25] [sys/info] Add detection for El Capitan, Sierra, High Sierra, Mojave --- core/sys/info/platform_darwin.odin | 254 +++++++++++++++++++++-------- 1 file changed, 187 insertions(+), 67 deletions(-) diff --git a/core/sys/info/platform_darwin.odin b/core/sys/info/platform_darwin.odin index 5a0714b8f..0dbd93826 100644 --- a/core/sys/info/platform_darwin.odin +++ b/core/sys/info/platform_darwin.odin @@ -172,78 +172,198 @@ Darwin_To_Release :: struct { // Important: Order from lowest to highest kernel version @(private) macos_release_map: map[string]Darwin_To_Release = { + // MacOS El Capitan + "15A284" = {{15, 0, 0}, "macOS", {"El Capitan", {10, 11, 0}}}, + "15B42" = {{15, 0, 0}, "macOS", {"El Capitan", {10, 11, 1}}}, + "15C50" = {{15, 2, 0}, "macOS", {"El Capitan", {10, 11, 2}}}, + "15D21" = {{15, 3, 0}, "macOS", {"El Capitan", {10, 11, 3}}}, + "15E65" = {{15, 4, 0}, "macOS", {"El Capitan", {10, 11, 4}}}, + "15F34" = {{15, 5, 0}, "macOS", {"El Capitan", {10, 11, 5}}}, + "15G31" = {{15, 6, 0}, "macOS", {"El Capitan", {10, 11, 6}}}, + "15G1004" = {{15, 6, 0}, "macOS", {"El Capitan", {10, 11, 6}}}, + "15G1011" = {{15, 6, 0}, "macOS", {"El Capitan", {10, 11, 6}}}, + "15G1108" = {{15, 6, 0}, "macOS", {"El Capitan", {10, 11, 6}}}, + "15G1212" = {{15, 6, 0}, "macOS", {"El Capitan", {10, 11, 6}}}, + "15G1217" = {{15, 6, 0}, "macOS", {"El Capitan", {10, 11, 6}}}, + "15G1421" = {{15, 6, 0}, "macOS", {"El Capitan", {10, 11, 6}}}, + "15G1510" = {{15, 6, 0}, "macOS", {"El Capitan", {10, 11, 6}}}, + "15G1611" = {{15, 6, 0}, "macOS", {"El Capitan", {10, 11, 6}}}, + "15G17023" = {{15, 6, 0}, "macOS", {"El Capitan", {10, 11, 6}}}, + "15G18013" = {{15, 6, 0}, "macOS", {"El Capitan", {10, 11, 6}}}, + "15G19009" = {{15, 6, 0}, "macOS", {"El Capitan", {10, 11, 6}}}, + "15G20015" = {{15, 6, 0}, "macOS", {"El Capitan", {10, 11, 6}}}, + "15G21013" = {{15, 6, 0}, "macOS", {"El Capitan", {10, 11, 6}}}, + "15G22010" = {{15, 6, 0}, "macOS", {"El Capitan", {10, 11, 6}}}, + + // MacOS Sierra + "16A323" = {{16, 0, 0}, "macOS", {"Sierra", {10, 12, 0}}}, + "16B2555" = {{16, 1, 0}, "macOS", {"Sierra", {10, 12, 1}}}, + "16B2657" = {{16, 1, 0}, "macOS", {"Sierra", {10, 12, 1}}}, + "16C67" = {{16, 3, 0}, "macOS", {"Sierra", {10, 12, 2}}}, + "16C68" = {{16, 3, 0}, "macOS", {"Sierra", {10, 12, 2}}}, + "16D32" = {{16, 4, 0}, "macOS", {"Sierra", {10, 12, 3}}}, + "16E195" = {{16, 5, 0}, "macOS", {"Sierra", {10, 12, 4}}}, + "16F73" = {{16, 6, 0}, "macOS", {"Sierra", {10, 12, 5}}}, + "16F2073" = {{16, 6, 0}, "macOS", {"Sierra", {10, 12, 5}}}, + "16G29" = {{16, 7, 0}, "macOS", {"Sierra", {10, 12, 6}}}, + "16G1036" = {{16, 7, 0}, "macOS", {"Sierra", {10, 12, 6}}}, + "16G1114" = {{16, 7, 0}, "macOS", {"Sierra", {10, 12, 6}}}, + "16G1212" = {{16, 7, 0}, "macOS", {"Sierra", {10, 12, 6}}}, + "16G1314" = {{16, 7, 0}, "macOS", {"Sierra", {10, 12, 6}}}, + "16G1408" = {{16, 7, 0}, "macOS", {"Sierra", {10, 12, 6}}}, + "16G1510" = {{16, 7, 0}, "macOS", {"Sierra", {10, 12, 6}}}, + "16G1618" = {{16, 7, 0}, "macOS", {"Sierra", {10, 12, 6}}}, + "16G1710" = {{16, 7, 0}, "macOS", {"Sierra", {10, 12, 6}}}, + "16G1815" = {{16, 7, 0}, "macOS", {"Sierra", {10, 12, 6}}}, + "16G1917" = {{16, 7, 0}, "macOS", {"Sierra", {10, 12, 6}}}, + "16G1918" = {{16, 7, 0}, "macOS", {"Sierra", {10, 12, 6}}}, + "16G2016" = {{16, 7, 0}, "macOS", {"Sierra", {10, 12, 6}}}, + "16G2127" = {{16, 7, 0}, "macOS", {"Sierra", {10, 12, 6}}}, + "16G2128" = {{16, 7, 0}, "macOS", {"Sierra", {10, 12, 6}}}, + "16G2136" = {{16, 7, 0}, "macOS", {"Sierra", {10, 12, 6}}}, + + // MacOS High Sierra + "17A365" = {{17, 0, 0}, "macOS", {"High Sierra", {10, 13, 0}}}, + "17A405" = {{17, 0, 0}, "macOS", {"High Sierra", {10, 13, 0}}}, + "17B48" = {{17, 2, 0}, "macOS", {"High Sierra", {10, 13, 1}}}, + "17B1002" = {{17, 2, 0}, "macOS", {"High Sierra", {10, 13, 1}}}, + "17B1003" = {{17, 2, 0}, "macOS", {"High Sierra", {10, 13, 1}}}, + "17C88" = {{17, 3, 0}, "macOS", {"High Sierra", {10, 13, 2}}}, + "17C89" = {{17, 3, 0}, "macOS", {"High Sierra", {10, 13, 2}}}, + "17C205" = {{17, 3, 0}, "macOS", {"High Sierra", {10, 13, 2}}}, + "17C2205" = {{17, 3, 0}, "macOS", {"High Sierra", {10, 13, 2}}}, + "17D47" = {{17, 4, 0}, "macOS", {"High Sierra", {10, 13, 3}}}, + "17D2047" = {{17, 4, 0}, "macOS", {"High Sierra", {10, 13, 3}}}, + "17D102" = {{17, 4, 0}, "macOS", {"High Sierra", {10, 13, 3}}}, + "17D2102" = {{17, 4, 0}, "macOS", {"High Sierra", {10, 13, 3}}}, + "17E199" = {{17, 5, 0}, "macOS", {"High Sierra", {10, 13, 4}}}, + "17E202" = {{17, 5, 0}, "macOS", {"High Sierra", {10, 13, 4}}}, + "17F77" = {{17, 6, 0}, "macOS", {"High Sierra", {10, 13, 5}}}, + "17G65" = {{17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, + "17G2208" = {{17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, + "17G2307" = {{17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, + "17G3025" = {{17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, + "17G4015" = {{17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, + "17G5019" = {{17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, + "17G6029" = {{17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, + "17G6030" = {{17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, + "17G7024" = {{17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, + "17G8029" = {{17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, + "17G8030" = {{17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, + "17G8037" = {{17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, + "17G9016" = {{17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, + "17G10021" = {{17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, + "17G11023" = {{17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, + "17G12034" = {{17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, + "17G13033" = {{17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, + "17G13035" = {{17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, + "17G14019" = {{17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, + "17G14033" = {{17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, + "17G14042" = {{17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, + + // MacOS Mojave + "18A391" = {{18, 0, 0}, "macOS", {"Mojave", {10, 14, 0}}}, + "18B75" = {{18, 2, 0}, "macOS", {"Mojave", {10, 14, 1}}}, + "18B2107" = {{18, 2, 0}, "macOS", {"Mojave", {10, 14, 1}}}, + "18B3094" = {{18, 2, 0}, "macOS", {"Mojave", {10, 14, 1}}}, + "18C54" = {{18, 2, 0}, "macOS", {"Mojave", {10, 14, 2}}}, + "18D42" = {{18, 2, 0}, "macOS", {"Mojave", {10, 14, 3}}}, + "18D43" = {{18, 2, 0}, "macOS", {"Mojave", {10, 14, 3}}}, + "18D109" = {{18, 2, 0}, "macOS", {"Mojave", {10, 14, 3}}}, + "18E226" = {{18, 5, 0}, "macOS", {"Mojave", {10, 14, 4}}}, + "18E227" = {{18, 5, 0}, "macOS", {"Mojave", {10, 14, 4}}}, + "18F132" = {{18, 6, 0}, "macOS", {"Mojave", {10, 14, 5}}}, + "18G84" = {{18, 7, 0}, "macOS", {"Mojave", {10, 14, 6}}}, + "18G87" = {{18, 7, 0}, "macOS", {"Mojave", {10, 14, 6}}}, + "18G95" = {{18, 7, 0}, "macOS", {"Mojave", {10, 14, 6}}}, + "18G103" = {{18, 7, 0}, "macOS", {"Mojave", {10, 14, 6}}}, + "18G1012" = {{18, 7, 0}, "macOS", {"Mojave", {10, 14, 6}}}, + "18G2022" = {{18, 7, 0}, "macOS", {"Mojave", {10, 14, 6}}}, + "18G3020" = {{18, 7, 0}, "macOS", {"Mojave", {10, 14, 6}}}, + "18G4032" = {{18, 7, 0}, "macOS", {"Mojave", {10, 14, 6}}}, + "18G5033" = {{18, 7, 0}, "macOS", {"Mojave", {10, 14, 6}}}, + "18G6020" = {{18, 7, 0}, "macOS", {"Mojave", {10, 14, 6}}}, + "18G6032" = {{18, 7, 0}, "macOS", {"Mojave", {10, 14, 6}}}, + "18G6042" = {{18, 7, 0}, "macOS", {"Mojave", {10, 14, 6}}}, + "18G7016" = {{18, 7, 0}, "macOS", {"Mojave", {10, 14, 6}}}, + "18G8012" = {{18, 7, 0}, "macOS", {"Mojave", {10, 14, 6}}}, + "18G8022" = {{18, 7, 0}, "macOS", {"Mojave", {10, 14, 6}}}, + "18G9028" = {{18, 7, 0}, "macOS", {"Mojave", {10, 14, 6}}}, + "18G9216" = {{18, 7, 0}, "macOS", {"Mojave", {10, 14, 6}}}, + "18G9323" = {{18, 7, 0}, "macOS", {"Mojave", {10, 14, 6}}}, + // MacOS Catalina - "19A583" = {{19, 0, 0}, "macOS", {"Catalina", {10, 15, 0}}}, - "19A602" = {{19, 0, 0}, "macOS", {"Catalina", {10, 15, 0}}}, - "19A603" = {{19, 0, 0}, "macOS", {"Catalina", {10, 15, 0}}}, - "19B88" = {{19, 0, 0}, "macOS", {"Catalina", {10, 15, 1}}}, - "19C57" = {{19, 2, 0}, "macOS", {"Catalina", {10, 15, 2}}}, - "19C58" = {{19, 2, 0}, "macOS", {"Catalina", {10, 15, 2}}}, - "19D76" = {{19, 3, 0}, "macOS", {"Catalina", {10, 15, 3}}}, - "19E266" = {{19, 4, 0}, "macOS", {"Catalina", {10, 15, 4}}}, - "19E287" = {{19, 4, 0}, "macOS", {"Catalina", {10, 15, 4}}}, - "19F96" = {{19, 5, 0}, "macOS", {"Catalina", {10, 15, 5}}}, - "19F101" = {{19, 5, 0}, "macOS", {"Catalina", {10, 15, 5}}}, - "19G73" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 6}}}, - "19G2021" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 6}}}, - "19H2" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, - "19H4" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, - "19H15" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, - "19H114" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, - "19H512" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, - "19H524" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, - "19H1030" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, - "19H1217" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, - "19H1323" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, - "19H1417" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, - "19H1419" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, - "19H1519" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, - "19H1615" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, - "19H1713" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, - "19H1715" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, - "19H1824" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, - "19H1922" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, - "19H2026" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, + "19A583" = {{19, 0, 0}, "macOS", {"Catalina", {10, 15, 0}}}, + "19A602" = {{19, 0, 0}, "macOS", {"Catalina", {10, 15, 0}}}, + "19A603" = {{19, 0, 0}, "macOS", {"Catalina", {10, 15, 0}}}, + "19B88" = {{19, 0, 0}, "macOS", {"Catalina", {10, 15, 1}}}, + "19C57" = {{19, 2, 0}, "macOS", {"Catalina", {10, 15, 2}}}, + "19C58" = {{19, 2, 0}, "macOS", {"Catalina", {10, 15, 2}}}, + "19D76" = {{19, 3, 0}, "macOS", {"Catalina", {10, 15, 3}}}, + "19E266" = {{19, 4, 0}, "macOS", {"Catalina", {10, 15, 4}}}, + "19E287" = {{19, 4, 0}, "macOS", {"Catalina", {10, 15, 4}}}, + "19F96" = {{19, 5, 0}, "macOS", {"Catalina", {10, 15, 5}}}, + "19F101" = {{19, 5, 0}, "macOS", {"Catalina", {10, 15, 5}}}, + "19G73" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 6}}}, + "19G2021" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 6}}}, + "19H2" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, + "19H4" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, + "19H15" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, + "19H114" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, + "19H512" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, + "19H524" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, + "19H1030" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, + "19H1217" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, + "19H1323" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, + "19H1417" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, + "19H1419" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, + "19H1519" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, + "19H1615" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, + "19H1713" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, + "19H1715" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, + "19H1824" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, + "19H1922" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, + "19H2026" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, // MacOS Big Sur - "20A2411" = {{20, 1, 0}, "macOS", {"Big Sur", {11, 0, 0}}}, - "20B29" = {{20, 1, 0}, "macOS", {"Big Sur", {11, 0, 1}}}, - "20B50" = {{20, 1, 0}, "macOS", {"Big Sur", {11, 0, 1}}}, - "20C69" = {{20, 2, 0}, "macOS", {"Big Sur", {11, 1, 0}}}, - "20D64" = {{20, 3, 0}, "macOS", {"Big Sur", {11, 2, 0}}}, - "20D74" = {{20, 3, 0}, "macOS", {"Big Sur", {11, 2, 1}}}, - "20D75" = {{20, 3, 0}, "macOS", {"Big Sur", {11, 2, 1}}}, - "20D80" = {{20, 3, 0}, "macOS", {"Big Sur", {11, 2, 2}}}, - "20D91" = {{20, 3, 0}, "macOS", {"Big Sur", {11, 2, 3}}}, - "20E232" = {{20, 4, 0}, "macOS", {"Big Sur", {11, 3, 0}}}, - "20E241" = {{20, 4, 0}, "macOS", {"Big Sur", {11, 3, 1}}}, - "20F71" = {{20, 5, 0}, "macOS", {"Big Sur", {11, 4, 0}}}, - "20G71" = {{20, 6, 0}, "macOS", {"Big Sur", {11, 5, 0}}}, - "20G80" = {{20, 6, 0}, "macOS", {"Big Sur", {11, 5, 1}}}, - "20G95" = {{20, 6, 0}, "macOS", {"Big Sur", {11, 5, 2}}}, - "20G165" = {{20, 6, 0}, "macOS", {"Big Sur", {11, 6, 0}}}, - "20G224" = {{20, 6, 0}, "macOS", {"Big Sur", {11, 6, 1}}}, - "20G314" = {{20, 6, 0}, "macOS", {"Big Sur", {11, 6, 2}}}, - "20G415" = {{20, 6, 0}, "macOS", {"Big Sur", {11, 6, 3}}}, - "20G417" = {{20, 6, 0}, "macOS", {"Big Sur", {11, 6, 4}}}, - "20G527" = {{20, 6, 0}, "macOS", {"Big Sur", {11, 6, 5}}}, - "20G624" = {{20, 6, 0}, "macOS", {"Big Sur", {11, 6, 6}}}, - "20G630" = {{20, 6, 0}, "macOS", {"Big Sur", {11, 6, 7}}}, - "20G730" = {{20, 6, 0}, "macOS", {"Big Sur", {11, 6, 8}}}, + "20A2411" = {{20, 1, 0}, "macOS", {"Big Sur", {11, 0, 0}}}, + "20B29" = {{20, 1, 0}, "macOS", {"Big Sur", {11, 0, 1}}}, + "20B50" = {{20, 1, 0}, "macOS", {"Big Sur", {11, 0, 1}}}, + "20C69" = {{20, 2, 0}, "macOS", {"Big Sur", {11, 1, 0}}}, + "20D64" = {{20, 3, 0}, "macOS", {"Big Sur", {11, 2, 0}}}, + "20D74" = {{20, 3, 0}, "macOS", {"Big Sur", {11, 2, 1}}}, + "20D75" = {{20, 3, 0}, "macOS", {"Big Sur", {11, 2, 1}}}, + "20D80" = {{20, 3, 0}, "macOS", {"Big Sur", {11, 2, 2}}}, + "20D91" = {{20, 3, 0}, "macOS", {"Big Sur", {11, 2, 3}}}, + "20E232" = {{20, 4, 0}, "macOS", {"Big Sur", {11, 3, 0}}}, + "20E241" = {{20, 4, 0}, "macOS", {"Big Sur", {11, 3, 1}}}, + "20F71" = {{20, 5, 0}, "macOS", {"Big Sur", {11, 4, 0}}}, + "20G71" = {{20, 6, 0}, "macOS", {"Big Sur", {11, 5, 0}}}, + "20G80" = {{20, 6, 0}, "macOS", {"Big Sur", {11, 5, 1}}}, + "20G95" = {{20, 6, 0}, "macOS", {"Big Sur", {11, 5, 2}}}, + "20G165" = {{20, 6, 0}, "macOS", {"Big Sur", {11, 6, 0}}}, + "20G224" = {{20, 6, 0}, "macOS", {"Big Sur", {11, 6, 1}}}, + "20G314" = {{20, 6, 0}, "macOS", {"Big Sur", {11, 6, 2}}}, + "20G415" = {{20, 6, 0}, "macOS", {"Big Sur", {11, 6, 3}}}, + "20G417" = {{20, 6, 0}, "macOS", {"Big Sur", {11, 6, 4}}}, + "20G527" = {{20, 6, 0}, "macOS", {"Big Sur", {11, 6, 5}}}, + "20G624" = {{20, 6, 0}, "macOS", {"Big Sur", {11, 6, 6}}}, + "20G630" = {{20, 6, 0}, "macOS", {"Big Sur", {11, 6, 7}}}, + "20G730" = {{20, 6, 0}, "macOS", {"Big Sur", {11, 6, 8}}}, // MacOS Monterey - "21A344" = {{21, 0, 1}, "macOS", {"Monterey", {12, 0, 0}}}, - "21A559" = {{21, 1, 0}, "macOS", {"Monterey", {12, 0, 1}}}, - "21C52" = {{21, 2, 0}, "macOS", {"Monterey", {12, 1, 0}}}, - "21D49" = {{21, 3, 0}, "macOS", {"Monterey", {12, 2, 0}}}, - "21D62" = {{21, 3, 0}, "macOS", {"Monterey", {12, 2, 1}}}, - "21E230" = {{21, 4, 0}, "macOS", {"Monterey", {12, 3, 0}}}, - "21E258" = {{21, 4, 0}, "macOS", {"Monterey", {12, 3, 1}}}, - "21F79" = {{21, 5, 0}, "macOS", {"Monterey", {12, 4, 0}}}, - "21F2081" = {{21, 5, 0}, "macOS", {"Monterey", {12, 4, 0}}}, - "21F2092" = {{21, 5, 0}, "macOS", {"Monterey", {12, 4, 0}}}, - "21G72" = {{21, 6, 0}, "macOS", {"Monterey", {12, 5, 0}}}, - "21G83" = {{21, 6, 0}, "macOS", {"Monterey", {12, 5, 1}}}, + "21A344" = {{21, 0, 1}, "macOS", {"Monterey", {12, 0, 0}}}, + "21A559" = {{21, 1, 0}, "macOS", {"Monterey", {12, 0, 1}}}, + "21C52" = {{21, 2, 0}, "macOS", {"Monterey", {12, 1, 0}}}, + "21D49" = {{21, 3, 0}, "macOS", {"Monterey", {12, 2, 0}}}, + "21D62" = {{21, 3, 0}, "macOS", {"Monterey", {12, 2, 1}}}, + "21E230" = {{21, 4, 0}, "macOS", {"Monterey", {12, 3, 0}}}, + "21E258" = {{21, 4, 0}, "macOS", {"Monterey", {12, 3, 1}}}, + "21F79" = {{21, 5, 0}, "macOS", {"Monterey", {12, 4, 0}}}, + "21F2081" = {{21, 5, 0}, "macOS", {"Monterey", {12, 4, 0}}}, + "21F2092" = {{21, 5, 0}, "macOS", {"Monterey", {12, 4, 0}}}, + "21G72" = {{21, 6, 0}, "macOS", {"Monterey", {12, 5, 0}}}, + "21G83" = {{21, 6, 0}, "macOS", {"Monterey", {12, 5, 1}}}, } @(private) From 0171c276f0880d6915254b728e9519ad5fc49256 Mon Sep 17 00:00:00 2001 From: Jeroen van Rijn Date: Sat, 3 Sep 2022 02:33:36 +0200 Subject: [PATCH 10/25] [sys/info] Support FreeBSD 13 --- core/sys/info/cpu_intel.odin | 9 +- core/sys/info/platform_darwin.odin | 11 ++- core/sys/info/platform_freebsd.odin | 145 ++++++++++++++++++++++++++++ core/sys/unix/syscalls_freebsd.odin | 7 ++ 4 files changed, 166 insertions(+), 6 deletions(-) create mode 100644 core/sys/info/platform_freebsd.odin create mode 100644 core/sys/unix/syscalls_freebsd.odin diff --git a/core/sys/info/cpu_intel.odin b/core/sys/info/cpu_intel.odin index eeb9c2416..e0b5090ca 100644 --- a/core/sys/info/cpu_intel.odin +++ b/core/sys/info/cpu_intel.odin @@ -67,8 +67,15 @@ init_cpu_features :: proc "c" () { try_set(&set, .os_xsave, 27, ecx1) try_set(&set, .rdrand, 30, ecx1) + when ODIN_OS == .FreeBSD { + // xgetbv is an illegal instruction under FreeBSD 13 + // return before probing further + cpu_features = set + return + } + os_supports_avx := false - if .os_xsave in set { + if .os_xsave in set { eax, _ := xgetbv(0) os_supports_avx = is_set(1, eax) && is_set(2, eax) } diff --git a/core/sys/info/platform_darwin.odin b/core/sys/info/platform_darwin.odin index 0dbd93826..bb80d8a65 100644 --- a/core/sys/info/platform_darwin.odin +++ b/core/sys/info/platform_darwin.odin @@ -112,12 +112,13 @@ init_os_version :: proc () { @(init) init_ram :: proc() { - // Retrieve RAM info using `sysinfo` + // Retrieve RAM info using `sysctl` mib := []i32{CTL_HW, HW_MEMSIZE} mem_size: u64 - ok := sysctl(mib, &mem_size) - ram.total_ram = int(mem_size) + if sysctl(mib, &mem_size) { + ram.total_ram = int(mem_size) + } } @(private) @@ -134,10 +135,10 @@ sysctl :: proc(mib: []i32, val: ^$T) -> (ok: bool) { return res == 0 } -// See sysctl.h for darwin/dwrwin for details +// See sysctl.h for darwin for details CTL_KERN :: 1 KERN_OSTYPE :: 1 // Darwin - KERN_OSRELEASE :: 2 // 21.5.0 for 12.4 Monterey + KERN_OSRELEASE :: 2 // 21.5.0 for 12.4 Monterey KERN_OSREV :: 3 // i32: system revision KERN_VERSION :: 4 // Darwin Kernel Version 21.5.0: Tue Apr 26 21:08:22 PDT 2022; root:darwin-8020.121.3~4/RELEASE_X86_64 KERN_OSRELDATE :: 26 // i32: OS release date diff --git a/core/sys/info/platform_freebsd.odin b/core/sys/info/platform_freebsd.odin new file mode 100644 index 000000000..bbefe9a92 --- /dev/null +++ b/core/sys/info/platform_freebsd.odin @@ -0,0 +1,145 @@ +// +build freebsd +package sysinfo + +import sys "core:sys/unix" +import "core:intrinsics" +import "core:os" +import "core:strings" +import "core:strconv" + +@(private) +version_string_buf: [1024]u8 + +@(init, private) +init_os_version :: proc () { + os_version.platform = .FreeBSD + + // TODO(Jeroen): No need to parse /etc/os-release. Use sysctl + // kern.ostype: FreeBSD + // kern.osrelease: 13.1-RELEASE-p2 + // kern.osrevision: 199506 + // kern.version: FreeBSD 13.1-RELEASE-p2 GENERIC + + // Try to parse `/etc/os-release` for `PRETTY_NAME="Ubuntu 20.04.3 LTS` + fd, err := os.open("/etc/os-release", os.O_RDONLY, 0) + if err != 0 { + return + } + defer os.close(fd) + + os_release_buf: [2048]u8 + n, read_err := os.read(fd, os_release_buf[:]) + if read_err != 0 { + return + } + release := string(os_release_buf[:n]) + + NEEDLE :: "PRETTY_NAME=\"" + pretty_start := strings.index(release, NEEDLE) + + b := strings.builder_from_bytes(version_string_buf[:]) + + if pretty_start > 0 { + for r, i in release[pretty_start + len(NEEDLE):] { + if r == '"' { + strings.write_string(&b, release[pretty_start + len(NEEDLE):][:i]) + break + } else if r == '\r' || r == '\n' { + strings.write_string(&b, "Unknown FreeBSD Distro") + break + } + } + } + + // Finish the string + os_version.as_string = strings.to_string(b) + + NEW_UTS_LEN :: 63 + UTS_Name :: struct { + sys_name: [NEW_UTS_LEN + 1]u8 `fmt:"s,0"`, + node_name: [NEW_UTS_LEN + 1]u8 `fmt:"s,0"`, + release: [NEW_UTS_LEN + 1]u8 `fmt:"s,0"`, + version: [NEW_UTS_LEN + 1]u8 `fmt:"s,0"`, + machine: [NEW_UTS_LEN + 1]u8 `fmt:"s,0"`, + domain_name: [NEW_UTS_LEN + 1]u8 `fmt:"s,0"`, + } + uts: UTS_Name + + // Grab kernel info using `uname()` syscall, https://www.freebsd.org/cgi/man.cgi?query=uname&sektion=3&n=1 + if intrinsics.syscall(sys.SYS_uname, uintptr(&uts)) != 0 { + return + } + + // Parse kernel version, as substrings of the version info in `version_string_buf` + version_bits := strings.split_n(string(cstring(&uts.node_name[0])), "-", 2, context.temp_allocator) + if len(version_bits) > 1 { + // We finished the display string, but are also using the buffer to intern the version alone. + strings.write_rune(&b, ' ') + l := strings.builder_len(b) + strings.write_string(&b, version_bits[0]) + os_version.version = strings.to_string(b)[l:] + + // Parse major, minor from node_name + triplet := strings.split(version_bits[0], ".", context.temp_allocator) + if len(triplet) == 2 { + major, major_ok := strconv.parse_int(triplet[0]) + minor, minor_ok := strconv.parse_int(triplet[1]) + + if major_ok && minor_ok { + os_version.major = major + os_version.minor = minor + } + } + } +} + +@(init) +init_ram :: proc() { + // Retrieve RAM info using `sysctl` + mib := []i32{CTL_HW, HW_PHYSMEM} + mem_size: u64 + if sysctl(mib, &mem_size) { + ram.total_ram = int(mem_size) + } +} + +@(private) +sysctl :: proc(mib: []i32, val: ^$T) -> (ok: bool) { + mib := mib + result_size := i64(size_of(T)) + + res := intrinsics.syscall(sys.SYS_sysctl, + uintptr(raw_data(mib)), uintptr(len(mib)), + uintptr(val), uintptr(&result_size), + uintptr(0), uintptr(0), + ) + return res == 0 +} + +// See /usr/include/sys/sysctl.h for details +CTL_SYSCTL :: 0 +CTL_KERN :: 1 + KERN_OSTYPE :: 1 + KERN_OSRELEASE :: 2 + KERN_OSREV :: 3 + KERN_VERSION :: 4 +CTL_VM :: 2 +CTL_VFS :: 3 +CTL_NET :: 4 +CTL_DEBUG :: 5 +CTL_HW :: 6 + HW_MACHINE :: 1 + HW_MODEL :: 2 + HW_NCPU :: 3 + HW_BYTEORDER :: 4 + HW_PHYSMEM :: 5 + HW_USERMEM :: 6 + HW_PAGESIZE :: 7 + HW_DISKNAMES :: 8 + HW_DISKSTATS :: 9 + HW_FLOATINGPT :: 10 + HW_MACHINE_ARCH :: 11 + HW_REALMEM :: 12 +CTL_MACHDEP :: 7 +CTL_USER :: 8 +CTL_P1003_1B :: 9 diff --git a/core/sys/unix/syscalls_freebsd.odin b/core/sys/unix/syscalls_freebsd.odin new file mode 100644 index 000000000..3441035cd --- /dev/null +++ b/core/sys/unix/syscalls_freebsd.odin @@ -0,0 +1,7 @@ +package unix + +// FreeBSD 13 syscall numbers +// See: https://alfonsosiciliano.gitlab.io/posts/2021-01-02-freebsd-system-calls-table.html + +SYS_uname : uintptr : 164 +SYS_sysctl : uintptr : 202 \ No newline at end of file From 7a4891b6b969a12247680f224c92b1af006b90bf Mon Sep 17 00:00:00 2001 From: Jeroen van Rijn Date: Sat, 3 Sep 2022 15:26:28 +0200 Subject: [PATCH 11/25] [sys/info] Grab FreeBSD kernel info using sysctl. --- core/sys/info/platform_freebsd.odin | 95 +++++++++++------------------ 1 file changed, 34 insertions(+), 61 deletions(-) diff --git a/core/sys/info/platform_freebsd.odin b/core/sys/info/platform_freebsd.odin index bbefe9a92..24f791d0e 100644 --- a/core/sys/info/platform_freebsd.odin +++ b/core/sys/info/platform_freebsd.odin @@ -3,7 +3,6 @@ package sysinfo import sys "core:sys/unix" import "core:intrinsics" -import "core:os" import "core:strings" import "core:strconv" @@ -14,72 +13,46 @@ version_string_buf: [1024]u8 init_os_version :: proc () { os_version.platform = .FreeBSD - // TODO(Jeroen): No need to parse /etc/os-release. Use sysctl - // kern.ostype: FreeBSD - // kern.osrelease: 13.1-RELEASE-p2 - // kern.osrevision: 199506 - // kern.version: FreeBSD 13.1-RELEASE-p2 GENERIC - - // Try to parse `/etc/os-release` for `PRETTY_NAME="Ubuntu 20.04.3 LTS` - fd, err := os.open("/etc/os-release", os.O_RDONLY, 0) - if err != 0 { - return - } - defer os.close(fd) - - os_release_buf: [2048]u8 - n, read_err := os.read(fd, os_release_buf[:]) - if read_err != 0 { - return - } - release := string(os_release_buf[:n]) - - NEEDLE :: "PRETTY_NAME=\"" - pretty_start := strings.index(release, NEEDLE) + kernel_version_buf: [129]u8 b := strings.builder_from_bytes(version_string_buf[:]) - - if pretty_start > 0 { - for r, i in release[pretty_start + len(NEEDLE):] { - if r == '"' { - strings.write_string(&b, release[pretty_start + len(NEEDLE):][:i]) - break - } else if r == '\r' || r == '\n' { - strings.write_string(&b, "Unknown FreeBSD Distro") - break - } - } - } - - // Finish the string - os_version.as_string = strings.to_string(b) - - NEW_UTS_LEN :: 63 - UTS_Name :: struct { - sys_name: [NEW_UTS_LEN + 1]u8 `fmt:"s,0"`, - node_name: [NEW_UTS_LEN + 1]u8 `fmt:"s,0"`, - release: [NEW_UTS_LEN + 1]u8 `fmt:"s,0"`, - version: [NEW_UTS_LEN + 1]u8 `fmt:"s,0"`, - machine: [NEW_UTS_LEN + 1]u8 `fmt:"s,0"`, - domain_name: [NEW_UTS_LEN + 1]u8 `fmt:"s,0"`, - } - uts: UTS_Name - - // Grab kernel info using `uname()` syscall, https://www.freebsd.org/cgi/man.cgi?query=uname&sektion=3&n=1 - if intrinsics.syscall(sys.SYS_uname, uintptr(&uts)) != 0 { + // Retrieve kernel info using `sysctl`, e.g. FreeBSD 13.1-RELEASE-p2 GENERIC + mib := []i32{CTL_KERN, KERN_VERSION} + if !sysctl(mib, &kernel_version_buf) { return } - // Parse kernel version, as substrings of the version info in `version_string_buf` - version_bits := strings.split_n(string(cstring(&uts.node_name[0])), "-", 2, context.temp_allocator) - if len(version_bits) > 1 { - // We finished the display string, but are also using the buffer to intern the version alone. - strings.write_rune(&b, ' ') - l := strings.builder_len(b) - strings.write_string(&b, version_bits[0]) - os_version.version = strings.to_string(b)[l:] + pretty_name := string(cstring(raw_data(kernel_version_buf[:]))) + pretty_name = strings.trim(pretty_name, "\n") + strings.write_string(&b, pretty_name) - // Parse major, minor from node_name + // l := strings.builder_len(b) + + // Retrieve kernel revision using `sysctl`, e.g. 199506 + mib = []i32{CTL_KERN, KERN_OSREV} + revision: int + if !sysctl(mib, &revision) { + return + } + os_version.patch = revision + + strings.write_string(&b, ", revision ") + strings.write_int(&b, revision) + + // Finalize pretty name. + os_version.as_string = strings.to_string(b) + + // Retrieve kernel release using `sysctl`, e.g. 13.1-RELEASE-p2 + mib = []i32{CTL_KERN, KERN_OSRELEASE} + if !sysctl(mib, &kernel_version_buf) { + return + } + + // Parse kernel version + release := string(cstring(raw_data(kernel_version_buf[:]))) + version_bits := strings.split_n(release, "-", 2, context.temp_allocator) + if len(version_bits) > 1 { + // Parse major, minor from KERN_OSRELEASE triplet := strings.split(version_bits[0], ".", context.temp_allocator) if len(triplet) == 2 { major, major_ok := strconv.parse_int(triplet[0]) From 4eafb0ce7fc8590f9466c8cdbe421b4211e5daaa Mon Sep 17 00:00:00 2001 From: Jeroen van Rijn Date: Sat, 3 Sep 2022 16:30:31 +0200 Subject: [PATCH 12/25] [sys/info] Move macOS sysctl to sys/unix. --- core/sys/info/platform_darwin.odin | 55 ++++-------------------------- core/sys/unix/sysctl_darwin.odin | 43 +++++++++++++++++++++++ 2 files changed, 50 insertions(+), 48 deletions(-) create mode 100644 core/sys/unix/sysctl_darwin.odin diff --git a/core/sys/info/platform_darwin.odin b/core/sys/info/platform_darwin.odin index bb80d8a65..2a2c625ee 100644 --- a/core/sys/info/platform_darwin.odin +++ b/core/sys/info/platform_darwin.odin @@ -1,11 +1,9 @@ // +build darwin package sysinfo -import sys "core:sys/darwin" -import "core:intrinsics" +import sys "core:sys/unix" import "core:strconv" import "core:strings" -import "core:fmt" @(private) version_string_buf: [1024]u8 @@ -17,10 +15,10 @@ init_os_version :: proc () { // Start building display version b := strings.builder_from_bytes(version_string_buf[:]) - mib := []i32{CTL_KERN, KERN_OSVERSION} + mib := []i32{sys.CTL_KERN, sys.KERN_OSVERSION} build_buf: [12]u8 - ok := sysctl(mib, &build_buf) + ok := sys.sysctl(mib, &build_buf) if !ok { strings.write_string(&b, "macOS Unknown") os_version.as_string = strings.to_string(b) @@ -37,9 +35,9 @@ init_os_version :: proc () { match = .Exact } else { // Match on XNU kernel version - mib = []i32{CTL_KERN, KERN_OSRELEASE} + mib = []i32{sys.CTL_KERN, sys.KERN_OSRELEASE} version_bits: [12]u8 // enough for 999.999.999\x00 - have_kernel_version := sysctl(mib, &version_bits) + have_kernel_version := sys.sysctl(mib, &version_bits) major_ok, minor_ok, patch_ok: bool @@ -114,52 +112,13 @@ init_os_version :: proc () { init_ram :: proc() { // Retrieve RAM info using `sysctl` - mib := []i32{CTL_HW, HW_MEMSIZE} + mib := []i32{sys.CTL_HW, sys.HW_MEMSIZE} mem_size: u64 - if sysctl(mib, &mem_size) { + if sys.sysctl(mib, &mem_size) { ram.total_ram = int(mem_size) } } -@(private) -sysctl :: proc(mib: []i32, val: ^$T) -> (ok: bool) { - mib := mib - result_size := i64(size_of(T)) - - res := intrinsics.syscall( - sys.unix_offset_syscall(.sysctl), - uintptr(raw_data(mib)), uintptr(len(mib)), - uintptr(val), uintptr(&result_size), - uintptr(0), uintptr(0), - ) - return res == 0 -} - -// See sysctl.h for darwin for details -CTL_KERN :: 1 - KERN_OSTYPE :: 1 // Darwin - KERN_OSRELEASE :: 2 // 21.5.0 for 12.4 Monterey - KERN_OSREV :: 3 // i32: system revision - KERN_VERSION :: 4 // Darwin Kernel Version 21.5.0: Tue Apr 26 21:08:22 PDT 2022; root:darwin-8020.121.3~4/RELEASE_X86_64 - KERN_OSRELDATE :: 26 // i32: OS release date - KERN_OSVERSION :: 65 // Build number, e.g. 21F79 -CTL_VM :: 2 -CTL_VFS :: 3 -CTL_NET :: 4 -CTL_DEBUG :: 5 -CTL_HW :: 6 - HW_MACHINE :: 1 // x86_64 - HW_MODEL :: 2 // MacbookPro14,1 - HW_NCPU :: 3 /* int: number of cpus */ - HW_BYTEORDER :: 4 /* int: machine byte order */ - HW_MACHINE_ARCH :: 12 /* string: machine architecture */ - HW_VECTORUNIT :: 13 /* int: has HW vector unit? */ - HW_MEMSIZE :: 24 // u64 - HW_AVAILCPU :: 25 /* int: number of available CPUs */ - -CTL_MACHDEP :: 7 -CTL_USER :: 8 - @(private) Darwin_To_Release :: struct { darwin: [3]int, // Darwin kernel triplet diff --git a/core/sys/unix/sysctl_darwin.odin b/core/sys/unix/sysctl_darwin.odin new file mode 100644 index 000000000..92b14e6e1 --- /dev/null +++ b/core/sys/unix/sysctl_darwin.odin @@ -0,0 +1,43 @@ +//+build darwin +package unix + +import "core:sys/darwin" +import "core:intrinsics" + +sysctl :: proc(mib: []i32, val: ^$T) -> (ok: bool) { + mib := mib + result_size := i64(size_of(T)) + + res := intrinsics.syscall( + darwin.unix_offset_syscall(.sysctl), + uintptr(raw_data(mib)), uintptr(len(mib)), + uintptr(val), uintptr(&result_size), + uintptr(0), uintptr(0), + ) + return res == 0 +} + +// See sysctl.h for darwin for details +CTL_KERN :: 1 + KERN_OSTYPE :: 1 // Darwin + KERN_OSRELEASE :: 2 // 21.5.0 for 12.4 Monterey + KERN_OSREV :: 3 // i32: system revision + KERN_VERSION :: 4 // Darwin Kernel Version 21.5.0: Tue Apr 26 21:08:22 PDT 2022; root:darwin-8020.121.3~4/RELEASE_X86_64 + KERN_OSRELDATE :: 26 // i32: OS release date + KERN_OSVERSION :: 65 // Build number, e.g. 21F79 +CTL_VM :: 2 +CTL_VFS :: 3 +CTL_NET :: 4 +CTL_DEBUG :: 5 +CTL_HW :: 6 + HW_MACHINE :: 1 // x86_64 + HW_MODEL :: 2 // MacbookPro14,1 + HW_NCPU :: 3 /* int: number of cpus */ + HW_BYTEORDER :: 4 /* int: machine byte order */ + HW_MACHINE_ARCH :: 12 /* string: machine architecture */ + HW_VECTORUNIT :: 13 /* int: has HW vector unit? */ + HW_MEMSIZE :: 24 // u64 + HW_AVAILCPU :: 25 /* int: number of available CPUs */ + +CTL_MACHDEP :: 7 +CTL_USER :: 8 \ No newline at end of file From 3f3f4fafff8c86dbf1022f5eb3b6885d1ee15e87 Mon Sep 17 00:00:00 2001 From: Jeroen van Rijn Date: Sat, 3 Sep 2022 16:53:03 +0200 Subject: [PATCH 13/25] [sys/info] Move FreeBSD sysctl to sys/unix. --- core/sys/info/platform_freebsd.odin | 60 ++++---------------------- core/sys/unix/sysctl_freebsd.odin.odin | 44 +++++++++++++++++++ 2 files changed, 53 insertions(+), 51 deletions(-) create mode 100644 core/sys/unix/sysctl_freebsd.odin.odin diff --git a/core/sys/info/platform_freebsd.odin b/core/sys/info/platform_freebsd.odin index 24f791d0e..0ca2841be 100644 --- a/core/sys/info/platform_freebsd.odin +++ b/core/sys/info/platform_freebsd.odin @@ -2,7 +2,6 @@ package sysinfo import sys "core:sys/unix" -import "core:intrinsics" import "core:strings" import "core:strconv" @@ -17,8 +16,8 @@ init_os_version :: proc () { b := strings.builder_from_bytes(version_string_buf[:]) // Retrieve kernel info using `sysctl`, e.g. FreeBSD 13.1-RELEASE-p2 GENERIC - mib := []i32{CTL_KERN, KERN_VERSION} - if !sysctl(mib, &kernel_version_buf) { + mib := []i32{sys.CTL_KERN, sys.KERN_VERSION} + if !sys.sysctl(mib, &kernel_version_buf) { return } @@ -29,9 +28,9 @@ init_os_version :: proc () { // l := strings.builder_len(b) // Retrieve kernel revision using `sysctl`, e.g. 199506 - mib = []i32{CTL_KERN, KERN_OSREV} + mib = []i32{sys.CTL_KERN, sys.KERN_OSREV} revision: int - if !sysctl(mib, &revision) { + if !sys.sysctl(mib, &revision) { return } os_version.patch = revision @@ -43,8 +42,8 @@ init_os_version :: proc () { os_version.as_string = strings.to_string(b) // Retrieve kernel release using `sysctl`, e.g. 13.1-RELEASE-p2 - mib = []i32{CTL_KERN, KERN_OSRELEASE} - if !sysctl(mib, &kernel_version_buf) { + mib = []i32{sys.CTL_KERN, sys.KERN_OSRELEASE} + if !sys.sysctl(mib, &kernel_version_buf) { return } @@ -69,50 +68,9 @@ init_os_version :: proc () { @(init) init_ram :: proc() { // Retrieve RAM info using `sysctl` - mib := []i32{CTL_HW, HW_PHYSMEM} + mib := []i32{sys.CTL_HW, sys.HW_PHYSMEM} mem_size: u64 - if sysctl(mib, &mem_size) { + if sys.sysctl(mib, &mem_size) { ram.total_ram = int(mem_size) } -} - -@(private) -sysctl :: proc(mib: []i32, val: ^$T) -> (ok: bool) { - mib := mib - result_size := i64(size_of(T)) - - res := intrinsics.syscall(sys.SYS_sysctl, - uintptr(raw_data(mib)), uintptr(len(mib)), - uintptr(val), uintptr(&result_size), - uintptr(0), uintptr(0), - ) - return res == 0 -} - -// See /usr/include/sys/sysctl.h for details -CTL_SYSCTL :: 0 -CTL_KERN :: 1 - KERN_OSTYPE :: 1 - KERN_OSRELEASE :: 2 - KERN_OSREV :: 3 - KERN_VERSION :: 4 -CTL_VM :: 2 -CTL_VFS :: 3 -CTL_NET :: 4 -CTL_DEBUG :: 5 -CTL_HW :: 6 - HW_MACHINE :: 1 - HW_MODEL :: 2 - HW_NCPU :: 3 - HW_BYTEORDER :: 4 - HW_PHYSMEM :: 5 - HW_USERMEM :: 6 - HW_PAGESIZE :: 7 - HW_DISKNAMES :: 8 - HW_DISKSTATS :: 9 - HW_FLOATINGPT :: 10 - HW_MACHINE_ARCH :: 11 - HW_REALMEM :: 12 -CTL_MACHDEP :: 7 -CTL_USER :: 8 -CTL_P1003_1B :: 9 +} \ No newline at end of file diff --git a/core/sys/unix/sysctl_freebsd.odin.odin b/core/sys/unix/sysctl_freebsd.odin.odin new file mode 100644 index 000000000..5b0bcb88d --- /dev/null +++ b/core/sys/unix/sysctl_freebsd.odin.odin @@ -0,0 +1,44 @@ +//+build freebsd +package unix + +import "core:intrinsics" + +sysctl :: proc(mib: []i32, val: ^$T) -> (ok: bool) { + mib := mib + result_size := i64(size_of(T)) + + res := intrinsics.syscall(SYS_sysctl, + uintptr(raw_data(mib)), uintptr(len(mib)), + uintptr(val), uintptr(&result_size), + uintptr(0), uintptr(0), + ) + return res == 0 +} + +// See /usr/include/sys/sysctl.h for details +CTL_SYSCTL :: 0 +CTL_KERN :: 1 + KERN_OSTYPE :: 1 + KERN_OSRELEASE :: 2 + KERN_OSREV :: 3 + KERN_VERSION :: 4 +CTL_VM :: 2 +CTL_VFS :: 3 +CTL_NET :: 4 +CTL_DEBUG :: 5 +CTL_HW :: 6 + HW_MACHINE :: 1 + HW_MODEL :: 2 + HW_NCPU :: 3 + HW_BYTEORDER :: 4 + HW_PHYSMEM :: 5 + HW_USERMEM :: 6 + HW_PAGESIZE :: 7 + HW_DISKNAMES :: 8 + HW_DISKSTATS :: 9 + HW_FLOATINGPT :: 10 + HW_MACHINE_ARCH :: 11 + HW_REALMEM :: 12 +CTL_MACHDEP :: 7 +CTL_USER :: 8 +CTL_P1003_1B :: 9 From 2f6347b92434ad03c05d2c0429d261e1cb9f2de7 Mon Sep 17 00:00:00 2001 From: Jeroen van Rijn Date: Sat, 3 Sep 2022 20:49:19 +0200 Subject: [PATCH 14/25] [sys/info] Add detection for Tiger, Leopard, Snow Leopard, Lion, Mountain Lion, Mavericks, Yosemite --- core/sys/info/platform_darwin.odin | 498 ++++++++++++++++++----------- 1 file changed, 319 insertions(+), 179 deletions(-) diff --git a/core/sys/info/platform_darwin.odin b/core/sys/info/platform_darwin.odin index 2a2c625ee..fe58d5b06 100644 --- a/core/sys/info/platform_darwin.odin +++ b/core/sys/info/platform_darwin.odin @@ -132,198 +132,338 @@ Darwin_To_Release :: struct { // Important: Order from lowest to highest kernel version @(private) macos_release_map: map[string]Darwin_To_Release = { + // MacOS Tiger + "8A428" = {{8, 0, 0}, "macOS", {"Tiger", {10, 4, 0}}}, + "8A432" = {{8, 0, 0}, "macOS", {"Tiger", {10, 4, 0}}}, + "8B15" = {{8, 1, 0}, "macOS", {"Tiger", {10, 4, 1}}}, + "8B17" = {{8, 1, 0}, "macOS", {"Tiger", {10, 4, 1}}}, + "8C46" = {{8, 2, 0}, "macOS", {"Tiger", {10, 4, 2}}}, + "8C47" = {{8, 2, 0}, "macOS", {"Tiger", {10, 4, 2}}}, + "8E102" = {{8, 2, 0}, "macOS", {"Tiger", {10, 4, 2}}}, + "8E45" = {{8, 2, 0}, "macOS", {"Tiger", {10, 4, 2}}}, + "8E90" = {{8, 2, 0}, "macOS", {"Tiger", {10, 4, 2}}}, + "8F46" = {{8, 3, 0}, "macOS", {"Tiger", {10, 4, 3}}}, + "8G32" = {{8, 4, 0}, "macOS", {"Tiger", {10, 4, 4}}}, + "8G1165" = {{8, 4, 0}, "macOS", {"Tiger", {10, 4, 4}}}, + "8H14" = {{8, 5, 0}, "macOS", {"Tiger", {10, 4, 5}}}, + "8G1454" = {{8, 5, 0}, "macOS", {"Tiger", {10, 4, 5}}}, + "8I127" = {{8, 6, 0}, "macOS", {"Tiger", {10, 4, 6}}}, + "8I1119" = {{8, 6, 0}, "macOS", {"Tiger", {10, 4, 6}}}, + "8J135" = {{8, 7, 0}, "macOS", {"Tiger", {10, 4, 7}}}, + "8J2135a" = {{8, 7, 0}, "macOS", {"Tiger", {10, 4, 7}}}, + "8K1079" = {{8, 7, 0}, "macOS", {"Tiger", {10, 4, 7}}}, + "8N5107" = {{8, 7, 0}, "macOS", {"Tiger", {10, 4, 7}}}, + "8L127" = {{8, 8, 0}, "macOS", {"Tiger", {10, 4, 8}}}, + "8L2127" = {{8, 8, 0}, "macOS", {"Tiger", {10, 4, 8}}}, + "8P135" = {{8, 9, 0}, "macOS", {"Tiger", {10, 4, 9}}}, + "8P2137" = {{8, 9, 0}, "macOS", {"Tiger", {10, 4, 9}}}, + "8R218" = {{8, 10, 0}, "macOS", {"Tiger", {10, 4, 10}}}, + "8R2218" = {{8, 10, 0}, "macOS", {"Tiger", {10, 4, 10}}}, + "8R2232" = {{8, 10, 0}, "macOS", {"Tiger", {10, 4, 10}}}, + "8S165" = {{8, 11, 0}, "macOS", {"Tiger", {10, 4, 11}}}, + "8S2167" = {{8, 11, 0}, "macOS", {"Tiger", {10, 4, 11}}}, + + // MacOS Leopard + "9A581" = {{9, 0, 0}, "macOS", {"Leopard", {10, 5, 0}}}, + "9B18" = {{9, 1, 0}, "macOS", {"Leopard", {10, 5, 1}}}, + "9B2117" = {{9, 1, 1}, "macOS", {"Leopard", {10, 5, 1}}}, + "9C31" = {{9, 2, 0}, "macOS", {"Leopard", {10, 5, 2}}}, + "9C7010" = {{9, 2, 0}, "macOS", {"Leopard", {10, 5, 2}}}, + "9D34" = {{9, 3, 0}, "macOS", {"Leopard", {10, 5, 3}}}, + "9E17" = {{9, 4, 0}, "macOS", {"Leopard", {10, 5, 4}}}, + "9F33" = {{9, 5, 0}, "macOS", {"Leopard", {10, 5, 5}}}, + "9G55" = {{9, 6, 0}, "macOS", {"Leopard", {10, 5, 6}}}, + "9G66" = {{9, 6, 0}, "macOS", {"Leopard", {10, 5, 6}}}, + "9G71" = {{9, 6, 0}, "macOS", {"Leopard", {10, 5, 6}}}, + "9J61" = {{9, 7, 0}, "macOS", {"Leopard", {10, 5, 7}}}, + "9L30" = {{9, 8, 0}, "macOS", {"Leopard", {10, 5, 8}}}, + "9L34" = {{9, 8, 0}, "macOS", {"Leopard", {10, 5, 8}}}, + + // MacOS Snow Leopard + "10A432" = {{10, 0, 0}, "macOS", {"Snow Leopard", {10, 6, 0}}}, + "10A433" = {{10, 0, 0}, "macOS", {"Snow Leopard", {10, 6, 0}}}, + "10B504" = {{10, 1, 0}, "macOS", {"Snow Leopard", {10, 6, 1}}}, + "10C540" = {{10, 2, 0}, "macOS", {"Snow Leopard", {10, 6, 2}}}, + "10D573" = {{10, 3, 0}, "macOS", {"Snow Leopard", {10, 6, 3}}}, + "10D575" = {{10, 3, 0}, "macOS", {"Snow Leopard", {10, 6, 3}}}, + "10D578" = {{10, 3, 0}, "macOS", {"Snow Leopard", {10, 6, 3}}}, + "10F569" = {{10, 4, 0}, "macOS", {"Snow Leopard", {10, 6, 4}}}, + "10H574" = {{10, 5, 0}, "macOS", {"Snow Leopard", {10, 6, 5}}}, + "10J567" = {{10, 6, 0}, "macOS", {"Snow Leopard", {10, 6, 6}}}, + "10J869" = {{10, 7, 0}, "macOS", {"Snow Leopard", {10, 6, 7}}}, + "10J3250" = {{10, 7, 0}, "macOS", {"Snow Leopard", {10, 6, 7}}}, + "10J4138" = {{10, 7, 0}, "macOS", {"Snow Leopard", {10, 6, 7}}}, + "10K540" = {{10, 8, 0}, "macOS", {"Snow Leopard", {10, 6, 8}}}, + "10K549" = {{10, 8, 0}, "macOS", {"Snow Leopard", {10, 6, 8}}}, + + // MacOS Lion + "11A511" = {{11, 0, 0}, "macOS", {"Lion", {10, 7, 0}}}, + "11A511s" = {{11, 0, 0}, "macOS", {"Lion", {10, 7, 0}}}, + "11A2061" = {{11, 0, 2}, "macOS", {"Lion", {10, 7, 0}}}, + "11A2063" = {{11, 0, 2}, "macOS", {"Lion", {10, 7, 0}}}, + "11B26" = {{11, 1, 0}, "macOS", {"Lion", {10, 7, 1}}}, + "11B2118" = {{11, 1, 0}, "macOS", {"Lion", {10, 7, 1}}}, + "11C74" = {{11, 2, 0}, "macOS", {"Lion", {10, 7, 2}}}, + "11D50" = {{11, 3, 0}, "macOS", {"Lion", {10, 7, 3}}}, + "11E53" = {{11, 4, 0}, "macOS", {"Lion", {10, 7, 4}}}, + "11G56" = {{11, 4, 2}, "macOS", {"Lion", {10, 7, 5}}}, + "11G63" = {{11, 4, 2}, "macOS", {"Lion", {10, 7, 5}}}, + + // MacOS Mountain Lion + "12A269" = {{12, 0, 0}, "macOS", {"Mountain Lion", {10, 8, 0}}}, + "12B19" = {{12, 1, 0}, "macOS", {"Mountain Lion", {10, 8, 1}}}, + "12C54" = {{12, 2, 0}, "macOS", {"Mountain Lion", {10, 8, 2}}}, + "12C60" = {{12, 2, 0}, "macOS", {"Mountain Lion", {10, 8, 2}}}, + "12C2034" = {{12, 2, 0}, "macOS", {"Mountain Lion", {10, 8, 2}}}, + "12C3104" = {{12, 2, 0}, "macOS", {"Mountain Lion", {10, 8, 2}}}, + "12D78" = {{12, 3, 0}, "macOS", {"Mountain Lion", {10, 8, 3}}}, + "12E55" = {{12, 4, 0}, "macOS", {"Mountain Lion", {10, 8, 4}}}, + "12E3067" = {{12, 4, 0}, "macOS", {"Mountain Lion", {10, 8, 4}}}, + "12E4022" = {{12, 4, 0}, "macOS", {"Mountain Lion", {10, 8, 4}}}, + "12F37" = {{12, 5, 0}, "macOS", {"Mountain Lion", {10, 8, 5}}}, + "12F45" = {{12, 5, 0}, "macOS", {"Mountain Lion", {10, 8, 5}}}, + "12F2501" = {{12, 5, 0}, "macOS", {"Mountain Lion", {10, 8, 5}}}, + "12F2518" = {{12, 5, 0}, "macOS", {"Mountain Lion", {10, 8, 5}}}, + "12F2542" = {{12, 5, 0}, "macOS", {"Mountain Lion", {10, 8, 5}}}, + "12F2560" = {{12, 5, 0}, "macOS", {"Mountain Lion", {10, 8, 5}}}, + + // MacOS Mavericks + "13A603" = {{13, 0, 0}, "macOS", {"Mavericks", {10, 9, 0}}}, + "13B42" = {{13, 0, 0}, "macOS", {"Mavericks", {10, 9, 1}}}, + "13C64" = {{13, 1, 0}, "macOS", {"Mavericks", {10, 9, 2}}}, + "13C1021" = {{13, 1, 0}, "macOS", {"Mavericks", {10, 9, 2}}}, + "13D65" = {{13, 2, 0}, "macOS", {"Mavericks", {10, 9, 3}}}, + "13E28" = {{13, 3, 0}, "macOS", {"Mavericks", {10, 9, 4}}}, + "13F34" = {{13, 4, 0}, "macOS", {"Mavericks", {10, 9, 5}}}, + "13F1066" = {{13, 4, 0}, "macOS", {"Mavericks", {10, 9, 5}}}, + "13F1077" = {{13, 4, 0}, "macOS", {"Mavericks", {10, 9, 5}}}, + "13F1096" = {{13, 4, 0}, "macOS", {"Mavericks", {10, 9, 5}}}, + "13F1112" = {{13, 4, 0}, "macOS", {"Mavericks", {10, 9, 5}}}, + "13F1134" = {{13, 4, 0}, "macOS", {"Mavericks", {10, 9, 5}}}, + "13F1507" = {{13, 4, 0}, "macOS", {"Mavericks", {10, 9, 5}}}, + "13F1603" = {{13, 4, 0}, "macOS", {"Mavericks", {10, 9, 5}}}, + "13F1712" = {{13, 4, 0}, "macOS", {"Mavericks", {10, 9, 5}}}, + "13F1808" = {{13, 4, 0}, "macOS", {"Mavericks", {10, 9, 5}}}, + "13F1911" = {{13, 4, 0}, "macOS", {"Mavericks", {10, 9, 5}}}, + + // MacOS Yosemite + "14A389" = {{14, 0, 0}, "macOS", {"Yosemite", {10, 10, 0}}}, + "14B25" = {{14, 0, 0}, "macOS", {"Yosemite", {10, 10, 1}}}, + "14C109" = {{14, 1, 0}, "macOS", {"Yosemite", {10, 10, 2}}}, + "14C1510" = {{14, 1, 0}, "macOS", {"Yosemite", {10, 10, 2}}}, + "14C2043" = {{14, 1, 0}, "macOS", {"Yosemite", {10, 10, 2}}}, + "14C1514" = {{14, 1, 0}, "macOS", {"Yosemite", {10, 10, 2}}}, + "14C2513" = {{14, 1, 0}, "macOS", {"Yosemite", {10, 10, 2}}}, + "14D131" = {{14, 3, 0}, "macOS", {"Yosemite", {10, 10, 3}}}, + "14D136" = {{14, 3, 0}, "macOS", {"Yosemite", {10, 10, 3}}}, + "14E46" = {{14, 4, 0}, "macOS", {"Yosemite", {10, 10, 4}}}, + "14F27" = {{14, 5, 0}, "macOS", {"Yosemite", {10, 10, 5}}}, + "14F1021" = {{14, 5, 0}, "macOS", {"Yosemite", {10, 10, 5}}}, + "14F1505" = {{14, 5, 0}, "macOS", {"Yosemite", {10, 10, 5}}}, + "14F1509" = {{14, 5, 0}, "macOS", {"Yosemite", {10, 10, 5}}}, + "14F1605" = {{14, 5, 0}, "macOS", {"Yosemite", {10, 10, 5}}}, + "14F1713" = {{14, 5, 0}, "macOS", {"Yosemite", {10, 10, 5}}}, + "14F1808" = {{14, 5, 0}, "macOS", {"Yosemite", {10, 10, 5}}}, + "14F1909" = {{14, 5, 0}, "macOS", {"Yosemite", {10, 10, 5}}}, + "14F1912" = {{14, 5, 0}, "macOS", {"Yosemite", {10, 10, 5}}}, + "14F2009" = {{14, 5, 0}, "macOS", {"Yosemite", {10, 10, 5}}}, + "14F2109" = {{14, 5, 0}, "macOS", {"Yosemite", {10, 10, 5}}}, + "14F2315" = {{14, 5, 0}, "macOS", {"Yosemite", {10, 10, 5}}}, + "14F2411" = {{14, 5, 0}, "macOS", {"Yosemite", {10, 10, 5}}}, + "14F2511" = {{14, 5, 0}, "macOS", {"Yosemite", {10, 10, 5}}}, + // MacOS El Capitan - "15A284" = {{15, 0, 0}, "macOS", {"El Capitan", {10, 11, 0}}}, - "15B42" = {{15, 0, 0}, "macOS", {"El Capitan", {10, 11, 1}}}, - "15C50" = {{15, 2, 0}, "macOS", {"El Capitan", {10, 11, 2}}}, - "15D21" = {{15, 3, 0}, "macOS", {"El Capitan", {10, 11, 3}}}, - "15E65" = {{15, 4, 0}, "macOS", {"El Capitan", {10, 11, 4}}}, - "15F34" = {{15, 5, 0}, "macOS", {"El Capitan", {10, 11, 5}}}, - "15G31" = {{15, 6, 0}, "macOS", {"El Capitan", {10, 11, 6}}}, - "15G1004" = {{15, 6, 0}, "macOS", {"El Capitan", {10, 11, 6}}}, - "15G1011" = {{15, 6, 0}, "macOS", {"El Capitan", {10, 11, 6}}}, - "15G1108" = {{15, 6, 0}, "macOS", {"El Capitan", {10, 11, 6}}}, - "15G1212" = {{15, 6, 0}, "macOS", {"El Capitan", {10, 11, 6}}}, - "15G1217" = {{15, 6, 0}, "macOS", {"El Capitan", {10, 11, 6}}}, - "15G1421" = {{15, 6, 0}, "macOS", {"El Capitan", {10, 11, 6}}}, - "15G1510" = {{15, 6, 0}, "macOS", {"El Capitan", {10, 11, 6}}}, - "15G1611" = {{15, 6, 0}, "macOS", {"El Capitan", {10, 11, 6}}}, - "15G17023" = {{15, 6, 0}, "macOS", {"El Capitan", {10, 11, 6}}}, - "15G18013" = {{15, 6, 0}, "macOS", {"El Capitan", {10, 11, 6}}}, - "15G19009" = {{15, 6, 0}, "macOS", {"El Capitan", {10, 11, 6}}}, - "15G20015" = {{15, 6, 0}, "macOS", {"El Capitan", {10, 11, 6}}}, - "15G21013" = {{15, 6, 0}, "macOS", {"El Capitan", {10, 11, 6}}}, - "15G22010" = {{15, 6, 0}, "macOS", {"El Capitan", {10, 11, 6}}}, + "15A284" = {{15, 0, 0}, "macOS", {"El Capitan", {10, 11, 0}}}, + "15B42" = {{15, 0, 0}, "macOS", {"El Capitan", {10, 11, 1}}}, + "15C50" = {{15, 2, 0}, "macOS", {"El Capitan", {10, 11, 2}}}, + "15D21" = {{15, 3, 0}, "macOS", {"El Capitan", {10, 11, 3}}}, + "15E65" = {{15, 4, 0}, "macOS", {"El Capitan", {10, 11, 4}}}, + "15F34" = {{15, 5, 0}, "macOS", {"El Capitan", {10, 11, 5}}}, + "15G31" = {{15, 6, 0}, "macOS", {"El Capitan", {10, 11, 6}}}, + "15G1004" = {{15, 6, 0}, "macOS", {"El Capitan", {10, 11, 6}}}, + "15G1011" = {{15, 6, 0}, "macOS", {"El Capitan", {10, 11, 6}}}, + "15G1108" = {{15, 6, 0}, "macOS", {"El Capitan", {10, 11, 6}}}, + "15G1212" = {{15, 6, 0}, "macOS", {"El Capitan", {10, 11, 6}}}, + "15G1217" = {{15, 6, 0}, "macOS", {"El Capitan", {10, 11, 6}}}, + "15G1421" = {{15, 6, 0}, "macOS", {"El Capitan", {10, 11, 6}}}, + "15G1510" = {{15, 6, 0}, "macOS", {"El Capitan", {10, 11, 6}}}, + "15G1611" = {{15, 6, 0}, "macOS", {"El Capitan", {10, 11, 6}}}, + "15G17023" = {{15, 6, 0}, "macOS", {"El Capitan", {10, 11, 6}}}, + "15G18013" = {{15, 6, 0}, "macOS", {"El Capitan", {10, 11, 6}}}, + "15G19009" = {{15, 6, 0}, "macOS", {"El Capitan", {10, 11, 6}}}, + "15G20015" = {{15, 6, 0}, "macOS", {"El Capitan", {10, 11, 6}}}, + "15G21013" = {{15, 6, 0}, "macOS", {"El Capitan", {10, 11, 6}}}, + "15G22010" = {{15, 6, 0}, "macOS", {"El Capitan", {10, 11, 6}}}, // MacOS Sierra - "16A323" = {{16, 0, 0}, "macOS", {"Sierra", {10, 12, 0}}}, - "16B2555" = {{16, 1, 0}, "macOS", {"Sierra", {10, 12, 1}}}, - "16B2657" = {{16, 1, 0}, "macOS", {"Sierra", {10, 12, 1}}}, - "16C67" = {{16, 3, 0}, "macOS", {"Sierra", {10, 12, 2}}}, - "16C68" = {{16, 3, 0}, "macOS", {"Sierra", {10, 12, 2}}}, - "16D32" = {{16, 4, 0}, "macOS", {"Sierra", {10, 12, 3}}}, - "16E195" = {{16, 5, 0}, "macOS", {"Sierra", {10, 12, 4}}}, - "16F73" = {{16, 6, 0}, "macOS", {"Sierra", {10, 12, 5}}}, - "16F2073" = {{16, 6, 0}, "macOS", {"Sierra", {10, 12, 5}}}, - "16G29" = {{16, 7, 0}, "macOS", {"Sierra", {10, 12, 6}}}, - "16G1036" = {{16, 7, 0}, "macOS", {"Sierra", {10, 12, 6}}}, - "16G1114" = {{16, 7, 0}, "macOS", {"Sierra", {10, 12, 6}}}, - "16G1212" = {{16, 7, 0}, "macOS", {"Sierra", {10, 12, 6}}}, - "16G1314" = {{16, 7, 0}, "macOS", {"Sierra", {10, 12, 6}}}, - "16G1408" = {{16, 7, 0}, "macOS", {"Sierra", {10, 12, 6}}}, - "16G1510" = {{16, 7, 0}, "macOS", {"Sierra", {10, 12, 6}}}, - "16G1618" = {{16, 7, 0}, "macOS", {"Sierra", {10, 12, 6}}}, - "16G1710" = {{16, 7, 0}, "macOS", {"Sierra", {10, 12, 6}}}, - "16G1815" = {{16, 7, 0}, "macOS", {"Sierra", {10, 12, 6}}}, - "16G1917" = {{16, 7, 0}, "macOS", {"Sierra", {10, 12, 6}}}, - "16G1918" = {{16, 7, 0}, "macOS", {"Sierra", {10, 12, 6}}}, - "16G2016" = {{16, 7, 0}, "macOS", {"Sierra", {10, 12, 6}}}, - "16G2127" = {{16, 7, 0}, "macOS", {"Sierra", {10, 12, 6}}}, - "16G2128" = {{16, 7, 0}, "macOS", {"Sierra", {10, 12, 6}}}, - "16G2136" = {{16, 7, 0}, "macOS", {"Sierra", {10, 12, 6}}}, + "16A323" = {{16, 0, 0}, "macOS", {"Sierra", {10, 12, 0}}}, + "16B2555" = {{16, 1, 0}, "macOS", {"Sierra", {10, 12, 1}}}, + "16B2657" = {{16, 1, 0}, "macOS", {"Sierra", {10, 12, 1}}}, + "16C67" = {{16, 3, 0}, "macOS", {"Sierra", {10, 12, 2}}}, + "16C68" = {{16, 3, 0}, "macOS", {"Sierra", {10, 12, 2}}}, + "16D32" = {{16, 4, 0}, "macOS", {"Sierra", {10, 12, 3}}}, + "16E195" = {{16, 5, 0}, "macOS", {"Sierra", {10, 12, 4}}}, + "16F73" = {{16, 6, 0}, "macOS", {"Sierra", {10, 12, 5}}}, + "16F2073" = {{16, 6, 0}, "macOS", {"Sierra", {10, 12, 5}}}, + "16G29" = {{16, 7, 0}, "macOS", {"Sierra", {10, 12, 6}}}, + "16G1036" = {{16, 7, 0}, "macOS", {"Sierra", {10, 12, 6}}}, + "16G1114" = {{16, 7, 0}, "macOS", {"Sierra", {10, 12, 6}}}, + "16G1212" = {{16, 7, 0}, "macOS", {"Sierra", {10, 12, 6}}}, + "16G1314" = {{16, 7, 0}, "macOS", {"Sierra", {10, 12, 6}}}, + "16G1408" = {{16, 7, 0}, "macOS", {"Sierra", {10, 12, 6}}}, + "16G1510" = {{16, 7, 0}, "macOS", {"Sierra", {10, 12, 6}}}, + "16G1618" = {{16, 7, 0}, "macOS", {"Sierra", {10, 12, 6}}}, + "16G1710" = {{16, 7, 0}, "macOS", {"Sierra", {10, 12, 6}}}, + "16G1815" = {{16, 7, 0}, "macOS", {"Sierra", {10, 12, 6}}}, + "16G1917" = {{16, 7, 0}, "macOS", {"Sierra", {10, 12, 6}}}, + "16G1918" = {{16, 7, 0}, "macOS", {"Sierra", {10, 12, 6}}}, + "16G2016" = {{16, 7, 0}, "macOS", {"Sierra", {10, 12, 6}}}, + "16G2127" = {{16, 7, 0}, "macOS", {"Sierra", {10, 12, 6}}}, + "16G2128" = {{16, 7, 0}, "macOS", {"Sierra", {10, 12, 6}}}, + "16G2136" = {{16, 7, 0}, "macOS", {"Sierra", {10, 12, 6}}}, // MacOS High Sierra - "17A365" = {{17, 0, 0}, "macOS", {"High Sierra", {10, 13, 0}}}, - "17A405" = {{17, 0, 0}, "macOS", {"High Sierra", {10, 13, 0}}}, - "17B48" = {{17, 2, 0}, "macOS", {"High Sierra", {10, 13, 1}}}, - "17B1002" = {{17, 2, 0}, "macOS", {"High Sierra", {10, 13, 1}}}, - "17B1003" = {{17, 2, 0}, "macOS", {"High Sierra", {10, 13, 1}}}, - "17C88" = {{17, 3, 0}, "macOS", {"High Sierra", {10, 13, 2}}}, - "17C89" = {{17, 3, 0}, "macOS", {"High Sierra", {10, 13, 2}}}, - "17C205" = {{17, 3, 0}, "macOS", {"High Sierra", {10, 13, 2}}}, - "17C2205" = {{17, 3, 0}, "macOS", {"High Sierra", {10, 13, 2}}}, - "17D47" = {{17, 4, 0}, "macOS", {"High Sierra", {10, 13, 3}}}, - "17D2047" = {{17, 4, 0}, "macOS", {"High Sierra", {10, 13, 3}}}, - "17D102" = {{17, 4, 0}, "macOS", {"High Sierra", {10, 13, 3}}}, - "17D2102" = {{17, 4, 0}, "macOS", {"High Sierra", {10, 13, 3}}}, - "17E199" = {{17, 5, 0}, "macOS", {"High Sierra", {10, 13, 4}}}, - "17E202" = {{17, 5, 0}, "macOS", {"High Sierra", {10, 13, 4}}}, - "17F77" = {{17, 6, 0}, "macOS", {"High Sierra", {10, 13, 5}}}, - "17G65" = {{17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, - "17G2208" = {{17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, - "17G2307" = {{17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, - "17G3025" = {{17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, - "17G4015" = {{17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, - "17G5019" = {{17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, - "17G6029" = {{17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, - "17G6030" = {{17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, - "17G7024" = {{17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, - "17G8029" = {{17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, - "17G8030" = {{17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, - "17G8037" = {{17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, - "17G9016" = {{17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, - "17G10021" = {{17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, - "17G11023" = {{17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, - "17G12034" = {{17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, - "17G13033" = {{17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, - "17G13035" = {{17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, - "17G14019" = {{17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, - "17G14033" = {{17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, - "17G14042" = {{17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, + "17A365" = {{17, 0, 0}, "macOS", {"High Sierra", {10, 13, 0}}}, + "17A405" = {{17, 0, 0}, "macOS", {"High Sierra", {10, 13, 0}}}, + "17B48" = {{17, 2, 0}, "macOS", {"High Sierra", {10, 13, 1}}}, + "17B1002" = {{17, 2, 0}, "macOS", {"High Sierra", {10, 13, 1}}}, + "17B1003" = {{17, 2, 0}, "macOS", {"High Sierra", {10, 13, 1}}}, + "17C88" = {{17, 3, 0}, "macOS", {"High Sierra", {10, 13, 2}}}, + "17C89" = {{17, 3, 0}, "macOS", {"High Sierra", {10, 13, 2}}}, + "17C205" = {{17, 3, 0}, "macOS", {"High Sierra", {10, 13, 2}}}, + "17C2205" = {{17, 3, 0}, "macOS", {"High Sierra", {10, 13, 2}}}, + "17D47" = {{17, 4, 0}, "macOS", {"High Sierra", {10, 13, 3}}}, + "17D2047" = {{17, 4, 0}, "macOS", {"High Sierra", {10, 13, 3}}}, + "17D102" = {{17, 4, 0}, "macOS", {"High Sierra", {10, 13, 3}}}, + "17D2102" = {{17, 4, 0}, "macOS", {"High Sierra", {10, 13, 3}}}, + "17E199" = {{17, 5, 0}, "macOS", {"High Sierra", {10, 13, 4}}}, + "17E202" = {{17, 5, 0}, "macOS", {"High Sierra", {10, 13, 4}}}, + "17F77" = {{17, 6, 0}, "macOS", {"High Sierra", {10, 13, 5}}}, + "17G65" = {{17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, + "17G2208" = {{17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, + "17G2307" = {{17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, + "17G3025" = {{17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, + "17G4015" = {{17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, + "17G5019" = {{17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, + "17G6029" = {{17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, + "17G6030" = {{17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, + "17G7024" = {{17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, + "17G8029" = {{17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, + "17G8030" = {{17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, + "17G8037" = {{17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, + "17G9016" = {{17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, + "17G10021" = {{17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, + "17G11023" = {{17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, + "17G12034" = {{17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, + "17G13033" = {{17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, + "17G13035" = {{17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, + "17G14019" = {{17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, + "17G14033" = {{17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, + "17G14042" = {{17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, // MacOS Mojave - "18A391" = {{18, 0, 0}, "macOS", {"Mojave", {10, 14, 0}}}, - "18B75" = {{18, 2, 0}, "macOS", {"Mojave", {10, 14, 1}}}, - "18B2107" = {{18, 2, 0}, "macOS", {"Mojave", {10, 14, 1}}}, - "18B3094" = {{18, 2, 0}, "macOS", {"Mojave", {10, 14, 1}}}, - "18C54" = {{18, 2, 0}, "macOS", {"Mojave", {10, 14, 2}}}, - "18D42" = {{18, 2, 0}, "macOS", {"Mojave", {10, 14, 3}}}, - "18D43" = {{18, 2, 0}, "macOS", {"Mojave", {10, 14, 3}}}, - "18D109" = {{18, 2, 0}, "macOS", {"Mojave", {10, 14, 3}}}, - "18E226" = {{18, 5, 0}, "macOS", {"Mojave", {10, 14, 4}}}, - "18E227" = {{18, 5, 0}, "macOS", {"Mojave", {10, 14, 4}}}, - "18F132" = {{18, 6, 0}, "macOS", {"Mojave", {10, 14, 5}}}, - "18G84" = {{18, 7, 0}, "macOS", {"Mojave", {10, 14, 6}}}, - "18G87" = {{18, 7, 0}, "macOS", {"Mojave", {10, 14, 6}}}, - "18G95" = {{18, 7, 0}, "macOS", {"Mojave", {10, 14, 6}}}, - "18G103" = {{18, 7, 0}, "macOS", {"Mojave", {10, 14, 6}}}, - "18G1012" = {{18, 7, 0}, "macOS", {"Mojave", {10, 14, 6}}}, - "18G2022" = {{18, 7, 0}, "macOS", {"Mojave", {10, 14, 6}}}, - "18G3020" = {{18, 7, 0}, "macOS", {"Mojave", {10, 14, 6}}}, - "18G4032" = {{18, 7, 0}, "macOS", {"Mojave", {10, 14, 6}}}, - "18G5033" = {{18, 7, 0}, "macOS", {"Mojave", {10, 14, 6}}}, - "18G6020" = {{18, 7, 0}, "macOS", {"Mojave", {10, 14, 6}}}, - "18G6032" = {{18, 7, 0}, "macOS", {"Mojave", {10, 14, 6}}}, - "18G6042" = {{18, 7, 0}, "macOS", {"Mojave", {10, 14, 6}}}, - "18G7016" = {{18, 7, 0}, "macOS", {"Mojave", {10, 14, 6}}}, - "18G8012" = {{18, 7, 0}, "macOS", {"Mojave", {10, 14, 6}}}, - "18G8022" = {{18, 7, 0}, "macOS", {"Mojave", {10, 14, 6}}}, - "18G9028" = {{18, 7, 0}, "macOS", {"Mojave", {10, 14, 6}}}, - "18G9216" = {{18, 7, 0}, "macOS", {"Mojave", {10, 14, 6}}}, - "18G9323" = {{18, 7, 0}, "macOS", {"Mojave", {10, 14, 6}}}, + "18A391" = {{18, 0, 0}, "macOS", {"Mojave", {10, 14, 0}}}, + "18B75" = {{18, 2, 0}, "macOS", {"Mojave", {10, 14, 1}}}, + "18B2107" = {{18, 2, 0}, "macOS", {"Mojave", {10, 14, 1}}}, + "18B3094" = {{18, 2, 0}, "macOS", {"Mojave", {10, 14, 1}}}, + "18C54" = {{18, 2, 0}, "macOS", {"Mojave", {10, 14, 2}}}, + "18D42" = {{18, 2, 0}, "macOS", {"Mojave", {10, 14, 3}}}, + "18D43" = {{18, 2, 0}, "macOS", {"Mojave", {10, 14, 3}}}, + "18D109" = {{18, 2, 0}, "macOS", {"Mojave", {10, 14, 3}}}, + "18E226" = {{18, 5, 0}, "macOS", {"Mojave", {10, 14, 4}}}, + "18E227" = {{18, 5, 0}, "macOS", {"Mojave", {10, 14, 4}}}, + "18F132" = {{18, 6, 0}, "macOS", {"Mojave", {10, 14, 5}}}, + "18G84" = {{18, 7, 0}, "macOS", {"Mojave", {10, 14, 6}}}, + "18G87" = {{18, 7, 0}, "macOS", {"Mojave", {10, 14, 6}}}, + "18G95" = {{18, 7, 0}, "macOS", {"Mojave", {10, 14, 6}}}, + "18G103" = {{18, 7, 0}, "macOS", {"Mojave", {10, 14, 6}}}, + "18G1012" = {{18, 7, 0}, "macOS", {"Mojave", {10, 14, 6}}}, + "18G2022" = {{18, 7, 0}, "macOS", {"Mojave", {10, 14, 6}}}, + "18G3020" = {{18, 7, 0}, "macOS", {"Mojave", {10, 14, 6}}}, + "18G4032" = {{18, 7, 0}, "macOS", {"Mojave", {10, 14, 6}}}, + "18G5033" = {{18, 7, 0}, "macOS", {"Mojave", {10, 14, 6}}}, + "18G6020" = {{18, 7, 0}, "macOS", {"Mojave", {10, 14, 6}}}, + "18G6032" = {{18, 7, 0}, "macOS", {"Mojave", {10, 14, 6}}}, + "18G6042" = {{18, 7, 0}, "macOS", {"Mojave", {10, 14, 6}}}, + "18G7016" = {{18, 7, 0}, "macOS", {"Mojave", {10, 14, 6}}}, + "18G8012" = {{18, 7, 0}, "macOS", {"Mojave", {10, 14, 6}}}, + "18G8022" = {{18, 7, 0}, "macOS", {"Mojave", {10, 14, 6}}}, + "18G9028" = {{18, 7, 0}, "macOS", {"Mojave", {10, 14, 6}}}, + "18G9216" = {{18, 7, 0}, "macOS", {"Mojave", {10, 14, 6}}}, + "18G9323" = {{18, 7, 0}, "macOS", {"Mojave", {10, 14, 6}}}, // MacOS Catalina - "19A583" = {{19, 0, 0}, "macOS", {"Catalina", {10, 15, 0}}}, - "19A602" = {{19, 0, 0}, "macOS", {"Catalina", {10, 15, 0}}}, - "19A603" = {{19, 0, 0}, "macOS", {"Catalina", {10, 15, 0}}}, - "19B88" = {{19, 0, 0}, "macOS", {"Catalina", {10, 15, 1}}}, - "19C57" = {{19, 2, 0}, "macOS", {"Catalina", {10, 15, 2}}}, - "19C58" = {{19, 2, 0}, "macOS", {"Catalina", {10, 15, 2}}}, - "19D76" = {{19, 3, 0}, "macOS", {"Catalina", {10, 15, 3}}}, - "19E266" = {{19, 4, 0}, "macOS", {"Catalina", {10, 15, 4}}}, - "19E287" = {{19, 4, 0}, "macOS", {"Catalina", {10, 15, 4}}}, - "19F96" = {{19, 5, 0}, "macOS", {"Catalina", {10, 15, 5}}}, - "19F101" = {{19, 5, 0}, "macOS", {"Catalina", {10, 15, 5}}}, - "19G73" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 6}}}, - "19G2021" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 6}}}, - "19H2" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, - "19H4" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, - "19H15" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, - "19H114" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, - "19H512" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, - "19H524" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, - "19H1030" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, - "19H1217" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, - "19H1323" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, - "19H1417" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, - "19H1419" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, - "19H1519" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, - "19H1615" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, - "19H1713" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, - "19H1715" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, - "19H1824" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, - "19H1922" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, - "19H2026" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, + "19A583" = {{19, 0, 0}, "macOS", {"Catalina", {10, 15, 0}}}, + "19A602" = {{19, 0, 0}, "macOS", {"Catalina", {10, 15, 0}}}, + "19A603" = {{19, 0, 0}, "macOS", {"Catalina", {10, 15, 0}}}, + "19B88" = {{19, 0, 0}, "macOS", {"Catalina", {10, 15, 1}}}, + "19C57" = {{19, 2, 0}, "macOS", {"Catalina", {10, 15, 2}}}, + "19C58" = {{19, 2, 0}, "macOS", {"Catalina", {10, 15, 2}}}, + "19D76" = {{19, 3, 0}, "macOS", {"Catalina", {10, 15, 3}}}, + "19E266" = {{19, 4, 0}, "macOS", {"Catalina", {10, 15, 4}}}, + "19E287" = {{19, 4, 0}, "macOS", {"Catalina", {10, 15, 4}}}, + "19F96" = {{19, 5, 0}, "macOS", {"Catalina", {10, 15, 5}}}, + "19F101" = {{19, 5, 0}, "macOS", {"Catalina", {10, 15, 5}}}, + "19G73" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 6}}}, + "19G2021" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 6}}}, + "19H2" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, + "19H4" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, + "19H15" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, + "19H114" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, + "19H512" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, + "19H524" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, + "19H1030" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, + "19H1217" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, + "19H1323" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, + "19H1417" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, + "19H1419" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, + "19H1519" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, + "19H1615" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, + "19H1713" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, + "19H1715" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, + "19H1824" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, + "19H1922" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, + "19H2026" = {{19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, // MacOS Big Sur - "20A2411" = {{20, 1, 0}, "macOS", {"Big Sur", {11, 0, 0}}}, - "20B29" = {{20, 1, 0}, "macOS", {"Big Sur", {11, 0, 1}}}, - "20B50" = {{20, 1, 0}, "macOS", {"Big Sur", {11, 0, 1}}}, - "20C69" = {{20, 2, 0}, "macOS", {"Big Sur", {11, 1, 0}}}, - "20D64" = {{20, 3, 0}, "macOS", {"Big Sur", {11, 2, 0}}}, - "20D74" = {{20, 3, 0}, "macOS", {"Big Sur", {11, 2, 1}}}, - "20D75" = {{20, 3, 0}, "macOS", {"Big Sur", {11, 2, 1}}}, - "20D80" = {{20, 3, 0}, "macOS", {"Big Sur", {11, 2, 2}}}, - "20D91" = {{20, 3, 0}, "macOS", {"Big Sur", {11, 2, 3}}}, - "20E232" = {{20, 4, 0}, "macOS", {"Big Sur", {11, 3, 0}}}, - "20E241" = {{20, 4, 0}, "macOS", {"Big Sur", {11, 3, 1}}}, - "20F71" = {{20, 5, 0}, "macOS", {"Big Sur", {11, 4, 0}}}, - "20G71" = {{20, 6, 0}, "macOS", {"Big Sur", {11, 5, 0}}}, - "20G80" = {{20, 6, 0}, "macOS", {"Big Sur", {11, 5, 1}}}, - "20G95" = {{20, 6, 0}, "macOS", {"Big Sur", {11, 5, 2}}}, - "20G165" = {{20, 6, 0}, "macOS", {"Big Sur", {11, 6, 0}}}, - "20G224" = {{20, 6, 0}, "macOS", {"Big Sur", {11, 6, 1}}}, - "20G314" = {{20, 6, 0}, "macOS", {"Big Sur", {11, 6, 2}}}, - "20G415" = {{20, 6, 0}, "macOS", {"Big Sur", {11, 6, 3}}}, - "20G417" = {{20, 6, 0}, "macOS", {"Big Sur", {11, 6, 4}}}, - "20G527" = {{20, 6, 0}, "macOS", {"Big Sur", {11, 6, 5}}}, - "20G624" = {{20, 6, 0}, "macOS", {"Big Sur", {11, 6, 6}}}, - "20G630" = {{20, 6, 0}, "macOS", {"Big Sur", {11, 6, 7}}}, - "20G730" = {{20, 6, 0}, "macOS", {"Big Sur", {11, 6, 8}}}, + "20A2411" = {{20, 1, 0}, "macOS", {"Big Sur", {11, 0, 0}}}, + "20B29" = {{20, 1, 0}, "macOS", {"Big Sur", {11, 0, 1}}}, + "20B50" = {{20, 1, 0}, "macOS", {"Big Sur", {11, 0, 1}}}, + "20C69" = {{20, 2, 0}, "macOS", {"Big Sur", {11, 1, 0}}}, + "20D64" = {{20, 3, 0}, "macOS", {"Big Sur", {11, 2, 0}}}, + "20D74" = {{20, 3, 0}, "macOS", {"Big Sur", {11, 2, 1}}}, + "20D75" = {{20, 3, 0}, "macOS", {"Big Sur", {11, 2, 1}}}, + "20D80" = {{20, 3, 0}, "macOS", {"Big Sur", {11, 2, 2}}}, + "20D91" = {{20, 3, 0}, "macOS", {"Big Sur", {11, 2, 3}}}, + "20E232" = {{20, 4, 0}, "macOS", {"Big Sur", {11, 3, 0}}}, + "20E241" = {{20, 4, 0}, "macOS", {"Big Sur", {11, 3, 1}}}, + "20F71" = {{20, 5, 0}, "macOS", {"Big Sur", {11, 4, 0}}}, + "20G71" = {{20, 6, 0}, "macOS", {"Big Sur", {11, 5, 0}}}, + "20G80" = {{20, 6, 0}, "macOS", {"Big Sur", {11, 5, 1}}}, + "20G95" = {{20, 6, 0}, "macOS", {"Big Sur", {11, 5, 2}}}, + "20G165" = {{20, 6, 0}, "macOS", {"Big Sur", {11, 6, 0}}}, + "20G224" = {{20, 6, 0}, "macOS", {"Big Sur", {11, 6, 1}}}, + "20G314" = {{20, 6, 0}, "macOS", {"Big Sur", {11, 6, 2}}}, + "20G415" = {{20, 6, 0}, "macOS", {"Big Sur", {11, 6, 3}}}, + "20G417" = {{20, 6, 0}, "macOS", {"Big Sur", {11, 6, 4}}}, + "20G527" = {{20, 6, 0}, "macOS", {"Big Sur", {11, 6, 5}}}, + "20G624" = {{20, 6, 0}, "macOS", {"Big Sur", {11, 6, 6}}}, + "20G630" = {{20, 6, 0}, "macOS", {"Big Sur", {11, 6, 7}}}, + "20G730" = {{20, 6, 0}, "macOS", {"Big Sur", {11, 6, 8}}}, // MacOS Monterey - "21A344" = {{21, 0, 1}, "macOS", {"Monterey", {12, 0, 0}}}, - "21A559" = {{21, 1, 0}, "macOS", {"Monterey", {12, 0, 1}}}, - "21C52" = {{21, 2, 0}, "macOS", {"Monterey", {12, 1, 0}}}, - "21D49" = {{21, 3, 0}, "macOS", {"Monterey", {12, 2, 0}}}, - "21D62" = {{21, 3, 0}, "macOS", {"Monterey", {12, 2, 1}}}, - "21E230" = {{21, 4, 0}, "macOS", {"Monterey", {12, 3, 0}}}, - "21E258" = {{21, 4, 0}, "macOS", {"Monterey", {12, 3, 1}}}, - "21F79" = {{21, 5, 0}, "macOS", {"Monterey", {12, 4, 0}}}, - "21F2081" = {{21, 5, 0}, "macOS", {"Monterey", {12, 4, 0}}}, - "21F2092" = {{21, 5, 0}, "macOS", {"Monterey", {12, 4, 0}}}, - "21G72" = {{21, 6, 0}, "macOS", {"Monterey", {12, 5, 0}}}, - "21G83" = {{21, 6, 0}, "macOS", {"Monterey", {12, 5, 1}}}, + "21A344" = {{21, 0, 1}, "macOS", {"Monterey", {12, 0, 0}}}, + "21A559" = {{21, 1, 0}, "macOS", {"Monterey", {12, 0, 1}}}, + "21C52" = {{21, 2, 0}, "macOS", {"Monterey", {12, 1, 0}}}, + "21D49" = {{21, 3, 0}, "macOS", {"Monterey", {12, 2, 0}}}, + "21D62" = {{21, 3, 0}, "macOS", {"Monterey", {12, 2, 1}}}, + "21E230" = {{21, 4, 0}, "macOS", {"Monterey", {12, 3, 0}}}, + "21E258" = {{21, 4, 0}, "macOS", {"Monterey", {12, 3, 1}}}, + "21F79" = {{21, 5, 0}, "macOS", {"Monterey", {12, 4, 0}}}, + "21F2081" = {{21, 5, 0}, "macOS", {"Monterey", {12, 4, 0}}}, + "21F2092" = {{21, 5, 0}, "macOS", {"Monterey", {12, 4, 0}}}, + "21G72" = {{21, 6, 0}, "macOS", {"Monterey", {12, 5, 0}}}, + "21G83" = {{21, 6, 0}, "macOS", {"Monterey", {12, 5, 1}}}, } @(private) From 426f02906b433e4600099fd2c516119bae8b82ba Mon Sep 17 00:00:00 2001 From: Jeroen van Rijn Date: Sun, 4 Sep 2022 20:37:38 +0200 Subject: [PATCH 15/25] [sys/info] Add OpenBSD detection support. --- core/os/os_openbsd.odin | 2 +- core/sys/info/cpu_intel.odin | 4 +- core/sys/info/platform_openbsd.odin | 69 +++++++++++++++++++ core/sys/unix/syscalls_openbsd.odin | 6 ++ ..._freebsd.odin.odin => sysctl_freebsd.odin} | 0 core/sys/unix/sysctl_openbsd.odin | 49 +++++++++++++ 6 files changed, 127 insertions(+), 3 deletions(-) create mode 100644 core/sys/info/platform_openbsd.odin create mode 100644 core/sys/unix/syscalls_openbsd.odin rename core/sys/unix/{sysctl_freebsd.odin.odin => sysctl_freebsd.odin} (100%) create mode 100644 core/sys/unix/sysctl_openbsd.odin diff --git a/core/os/os_openbsd.odin b/core/os/os_openbsd.odin index 9a3dbd874..fba079f15 100644 --- a/core/os/os_openbsd.odin +++ b/core/os/os_openbsd.odin @@ -705,4 +705,4 @@ _alloc_command_line_arguments :: proc() -> []string { res[i] = string(arg) } return res -} +} \ No newline at end of file diff --git a/core/sys/info/cpu_intel.odin b/core/sys/info/cpu_intel.odin index e0b5090ca..f1a3e7298 100644 --- a/core/sys/info/cpu_intel.odin +++ b/core/sys/info/cpu_intel.odin @@ -67,8 +67,8 @@ init_cpu_features :: proc "c" () { try_set(&set, .os_xsave, 27, ecx1) try_set(&set, .rdrand, 30, ecx1) - when ODIN_OS == .FreeBSD { - // xgetbv is an illegal instruction under FreeBSD 13 + when ODIN_OS == .FreeBSD || ODIN_OS == .OpenBSD { + // xgetbv is an illegal instruction under FreeBSD 13 & OpenBSD 7.1 // return before probing further cpu_features = set return diff --git a/core/sys/info/platform_openbsd.odin b/core/sys/info/platform_openbsd.odin new file mode 100644 index 000000000..080fad9b7 --- /dev/null +++ b/core/sys/info/platform_openbsd.odin @@ -0,0 +1,69 @@ +// +build openbsd +package sysinfo + +import sys "core:sys/unix" +import "core:strings" +import "core:strconv" + +@(private) +version_string_buf: [1024]u8 + +@(init, private) +init_os_version :: proc () { + os_version.platform = .OpenBSD + + kernel_version_buf: [1024]u8 + + b := strings.builder_from_bytes(version_string_buf[:]) + // Retrieve kernel info using `sysctl`, e.g. OpenBSD + mib := []i32{sys.CTL_KERN, sys.KERN_OSTYPE} + if !sys.sysctl(mib, &kernel_version_buf) { + return + } + os_type := string(cstring(raw_data(kernel_version_buf[:]))) + strings.write_string(&b, os_type) + + mib = []i32{sys.CTL_KERN, sys.KERN_OSRELEASE} + if !sys.sysctl(mib, &kernel_version_buf) { + return + } + + strings.write_rune(&b, ' ') + version := string(cstring(raw_data(kernel_version_buf[:]))) + strings.write_string(&b, version) + + // // Parse kernel version + triplet := strings.split(version, ".", context.temp_allocator) + if len(triplet) == 2 { + major, major_ok := strconv.parse_int(triplet[0]) + minor, minor_ok := strconv.parse_int(triplet[1]) + + if major_ok && minor_ok { + os_version.major = major + os_version.minor = minor + } + } + + // Retrieve kernel revision using `sysctl`, e.g. 199506 + mib = []i32{sys.CTL_KERN, sys.KERN_OSREV} + revision: int + if !sys.sysctl(mib, &revision) { + return + } + os_version.patch = revision + strings.write_string(&b, ", build ") + strings.write_int(&b, revision) + + // Finalize pretty name. + os_version.as_string = strings.to_string(b) +} + +@(init) +init_ram :: proc() { + // Retrieve RAM info using `sysctl` + mib := []i32{sys.CTL_HW, sys.HW_PHYSMEM64} + mem_size: u64 + if sys.sysctl(mib, &mem_size) { + ram.total_ram = int(mem_size) + } +} \ No newline at end of file diff --git a/core/sys/unix/syscalls_openbsd.odin b/core/sys/unix/syscalls_openbsd.odin new file mode 100644 index 000000000..703bc4d4e --- /dev/null +++ b/core/sys/unix/syscalls_openbsd.odin @@ -0,0 +1,6 @@ +package unix + +// OpenBSD 7.1 syscall numbers +// See: /usr/include/sys/syscall.h + +SYS_sysctl : uintptr : 202 \ No newline at end of file diff --git a/core/sys/unix/sysctl_freebsd.odin.odin b/core/sys/unix/sysctl_freebsd.odin similarity index 100% rename from core/sys/unix/sysctl_freebsd.odin.odin rename to core/sys/unix/sysctl_freebsd.odin diff --git a/core/sys/unix/sysctl_openbsd.odin b/core/sys/unix/sysctl_openbsd.odin new file mode 100644 index 000000000..b93e8f9bd --- /dev/null +++ b/core/sys/unix/sysctl_openbsd.odin @@ -0,0 +1,49 @@ +//+build openbsd +package unix + +import "core:c" +foreign import libc "system:c" + +@(default_calling_convention="c") +foreign libc { + @(link_name="sysctl") _unix_sysctl :: proc(name: [^]i32, namelen: u32, oldp: rawptr, oldlenp: ^c.size_t, newp: rawptr, newlen: c.size_t) -> i32 --- +} + +sysctl :: proc(mib: []i32, val: ^$T) -> (ok: bool) { + mib := mib + result_size := c.size_t(size_of(T)) + res := _unix_sysctl(raw_data(mib), u32(len(mib)), val, &result_size, nil, 0) + return res == 0 +} + +// See /usr/include/sys/sysctl.h for details +CTL_SYSCTL :: 0 +CTL_KERN :: 1 + KERN_OSTYPE :: 1 + KERN_OSRELEASE :: 2 + KERN_OSREV :: 3 + KERN_VERSION :: 4 +CTL_VM :: 2 +CTL_FS :: 3 +CTL_NET :: 4 +CTL_DEBUG :: 5 +CTL_HW :: 6 + HW_MACHINE :: 1 + HW_MODEL :: 2 + HW_NCPU :: 3 + HW_BYTEORDER :: 4 + HW_PHYSMEM :: 5 + HW_USERMEM :: 6 + HW_PAGESIZE :: 7 + HW_DISKNAMES :: 8 + HW_DISKSTATS :: 9 + HW_DISKCOUNT :: 10 + HW_SENSORS :: 11 + HW_CPUSPEED :: 12 + HW_SETPERF :: 13 + HW_VENDOR :: 14 + HW_PRODUCT :: 15 + HW_VERSION :: 16 + HW_SERIALNO :: 17 + HW_UUID :: 18 + HW_PHYSMEM64 :: 19 \ No newline at end of file From fb2cbe471ba60e5b75a9fc73d6287d7da076fdcc Mon Sep 17 00:00:00 2001 From: Jeroen van Rijn Date: Mon, 5 Sep 2022 15:00:29 +0200 Subject: [PATCH 16/25] odin report: Add FreeBSD OS & RAM detection. --- src/bug_report.cpp | 475 +++++++++++++++++++++++++-------------------- 1 file changed, 264 insertions(+), 211 deletions(-) diff --git a/src/bug_report.cpp b/src/bug_report.cpp index 02a2b1ba2..6fa66e02f 100644 --- a/src/bug_report.cpp +++ b/src/bug_report.cpp @@ -22,6 +22,10 @@ #include #endif +#if defined(GB_SYSTEM_FREEBSD) + #include +#endif + /* NOTE(Jeroen): This prints the Windows product edition only, to be called from `print_platform_details`. */ @@ -217,7 +221,6 @@ void report_cpu_info() { Report the amount of installed RAM. */ void report_ram_info() { - gb_printf("\tRAM: "); #if defined(GB_SYSTEM_WINDOWS) @@ -255,235 +258,213 @@ void report_ram_info() { if (sysctl(sysctls, 2, &ram_amount, &val_size, NULL, 0) != -1) { gb_printf("%lld MiB\n", ram_amount / gb_megabytes(1)); } + #elif defined(GB_SYSTEM_FREEBSD) + uint64_t ram_amount; + size_t val_size = sizeof(ram_amount); + + int sysctls[] = { CTL_HW, HW_PHYSMEM }; + if (sysctl(sysctls, 2, &ram_amount, &val_size, NULL, 0) != -1) { + gb_printf("%lu MiB\n", ram_amount / gb_megabytes(1)); + } #else gb_printf("Unknown.\n"); #endif } -/* - NOTE(Jeroen): `odin report` prints some system information for easier bug reporting. -*/ -void print_bug_report_help() { - gb_printf("Where to find more information and get into contact when you encounter a bug:\n\n"); - gb_printf("\tWebsite: https://odin-lang.org\n"); - gb_printf("\tGitHub: https://github.com/odin-lang/Odin/issues\n"); - /* - Uncomment and update URL once we have a Discord vanity URL. For now people can get here from the site. - gb_printf("\tDiscord: https://discord.com/invite/sVBPHEv\n"); - */ - gb_printf("\n\n"); - - gb_printf("Useful information to add to a bug report:\n\n"); - - gb_printf("\tOdin: %.*s", LIT(ODIN_VERSION)); - - #ifdef NIGHTLY - gb_printf("-nightly"); - #endif - - #ifdef GIT_SHA - gb_printf(":%s", GIT_SHA); - #endif - - gb_printf("\n"); - - /* - Print OS information. - */ +void report_os_info() { gb_printf("\tOS: "); #if defined(GB_SYSTEM_WINDOWS) - /* - NOTE(Jeroen): - `GetVersionEx` will return 6.2 for Windows 10 unless the program is manifested for Windows 10. - `RtlGetVersion` will return the true version. + /* + NOTE(Jeroen): + `GetVersionEx` will return 6.2 for Windows 10 unless the program is manifested for Windows 10. + `RtlGetVersion` will return the true version. - Rather than include the WinDDK, we ask the kernel directly. + Rather than include the WinDDK, we ask the kernel directly. - `HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion` is for the minor build version (Update Build Release) + `HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion` is for the minor build version (Update Build Release) - */ - OSVERSIONINFOEXW osvi; - ZeroMemory(&osvi, sizeof(OSVERSIONINFOEXW)); - osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXW); + */ + OSVERSIONINFOEXW osvi; + ZeroMemory(&osvi, sizeof(OSVERSIONINFOEXW)); + osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXW); - typedef NTSTATUS (WINAPI* RtlGetVersionPtr)(OSVERSIONINFOW*); - typedef BOOL (WINAPI* GetProductInfoPtr)(DWORD dwOSMajorVersion, DWORD dwOSMinorVersion, DWORD dwSpMajorVersion, DWORD dwSpMinorVersion, PDWORD pdwReturnedProductType); + typedef NTSTATUS (WINAPI* RtlGetVersionPtr)(OSVERSIONINFOW*); + typedef BOOL (WINAPI* GetProductInfoPtr)(DWORD dwOSMajorVersion, DWORD dwOSMinorVersion, DWORD dwSpMajorVersion, DWORD dwSpMinorVersion, PDWORD pdwReturnedProductType); - // https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/wdm/nf-wdm-rtlgetversion - RtlGetVersionPtr RtlGetVersion = (RtlGetVersionPtr)GetProcAddress(GetModuleHandle(TEXT("ntdll.dll")), "RtlGetVersion"); - // https://docs.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getproductinfo - GetProductInfoPtr GetProductInfo = (GetProductInfoPtr)GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "GetProductInfo"); + // https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/wdm/nf-wdm-rtlgetversion + RtlGetVersionPtr RtlGetVersion = (RtlGetVersionPtr)GetProcAddress(GetModuleHandle(TEXT("ntdll.dll")), "RtlGetVersion"); + // https://docs.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getproductinfo + GetProductInfoPtr GetProductInfo = (GetProductInfoPtr)GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "GetProductInfo"); - NTSTATUS status = {}; - DWORD ProductType = {}; - if (RtlGetVersion != nullptr) { - status = RtlGetVersion((OSVERSIONINFOW*)&osvi); + NTSTATUS status = {}; + DWORD ProductType = {}; + if (RtlGetVersion != nullptr) { + status = RtlGetVersion((OSVERSIONINFOW*)&osvi); + } + + if (RtlGetVersion == nullptr || status != 0x0) { + gb_printf("Windows (Unknown Version)"); + } else { + if (GetProductInfo != nullptr) { + GetProductInfo(osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.wServicePackMajor, osvi.wServicePackMinor, &ProductType); } - if (RtlGetVersion == nullptr || status != 0x0) { - gb_printf("Windows (Unknown Version)"); - } else { - if (GetProductInfo != nullptr) { - GetProductInfo(osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.wServicePackMajor, osvi.wServicePackMinor, &ProductType); - } + if (false) { + gb_printf("dwMajorVersion: %u\n", cast(unsigned)osvi.dwMajorVersion); + gb_printf("dwMinorVersion: %u\n", cast(unsigned)osvi.dwMinorVersion); + gb_printf("dwBuildNumber: %u\n", cast(unsigned)osvi.dwBuildNumber); + gb_printf("dwPlatformId: %u\n", cast(unsigned)osvi.dwPlatformId); + gb_printf("wServicePackMajor: %u\n", cast(unsigned)osvi.wServicePackMajor); + gb_printf("wServicePackMinor: %u\n", cast(unsigned)osvi.wServicePackMinor); + gb_printf("wSuiteMask: %u\n", cast(unsigned)osvi.wSuiteMask); + gb_printf("wProductType: %u\n", cast(unsigned)osvi.wProductType); + } - if (false) { - gb_printf("dwMajorVersion: %u\n", cast(unsigned)osvi.dwMajorVersion); - gb_printf("dwMinorVersion: %u\n", cast(unsigned)osvi.dwMinorVersion); - gb_printf("dwBuildNumber: %u\n", cast(unsigned)osvi.dwBuildNumber); - gb_printf("dwPlatformId: %u\n", cast(unsigned)osvi.dwPlatformId); - gb_printf("wServicePackMajor: %u\n", cast(unsigned)osvi.wServicePackMajor); - gb_printf("wServicePackMinor: %u\n", cast(unsigned)osvi.wServicePackMinor); - gb_printf("wSuiteMask: %u\n", cast(unsigned)osvi.wSuiteMask); - gb_printf("wProductType: %u\n", cast(unsigned)osvi.wProductType); - } + gb_printf("Windows "); - gb_printf("Windows "); - - switch (osvi.dwMajorVersion) { - case 10: - /* - Windows 10 (Pro), Windows 2016 Server, Windows 2019 Server, Windows 2022 Server - */ - switch (osvi.wProductType) { - case VER_NT_WORKSTATION: // Workstation - if (osvi.dwBuildNumber < 22000) { - gb_printf("10 "); - } else { - gb_printf("11 "); - } - - report_windows_product_type(ProductType); + switch (osvi.dwMajorVersion) { + case 10: + /* + Windows 10 (Pro), Windows 2016 Server, Windows 2019 Server, Windows 2022 Server + */ + switch (osvi.wProductType) { + case VER_NT_WORKSTATION: // Workstation + if (osvi.dwBuildNumber < 22000) { + gb_printf("10 "); + } else { + gb_printf("11 "); + } + + report_windows_product_type(ProductType); + break; + default: // Server or Domain Controller + switch(osvi.dwBuildNumber) { + case 14393: + gb_printf("2016 Server"); break; - default: // Server or Domain Controller - switch(osvi.dwBuildNumber) { - case 14393: - gb_printf("2016 Server"); - break; - case 17763: - gb_printf("2019 Server"); - break; - case 20348: - gb_printf("2022 Server"); - break; - default: - gb_printf("Unknown Server"); - break; + case 17763: + gb_printf("2019 Server"); + break; + case 20348: + gb_printf("2022 Server"); + break; + default: + gb_printf("Unknown Server"); + break; + } + } + break; + case 6: + switch (osvi.dwMinorVersion) { + case 0: + switch (osvi.wProductType) { + case VER_NT_WORKSTATION: + gb_printf("Windows Vista "); + report_windows_product_type(ProductType); + break; + case 3: + gb_printf("Windows Server 2008"); + break; } - } - break; - case 6: - switch (osvi.dwMinorVersion) { - case 0: - switch (osvi.wProductType) { - case VER_NT_WORKSTATION: - gb_printf("Windows Vista "); - report_windows_product_type(ProductType); - break; - case 3: - gb_printf("Windows Server 2008"); - break; - } - break; + break; - case 1: - switch (osvi.wProductType) { - case VER_NT_WORKSTATION: - gb_printf("Windows 7 "); - report_windows_product_type(ProductType); - break; - case 3: - gb_printf("Windows Server 2008 R2"); - break; - } - break; - case 2: - switch (osvi.wProductType) { - case VER_NT_WORKSTATION: - gb_printf("Windows 8 "); - report_windows_product_type(ProductType); - break; - case 3: - gb_printf("Windows Server 2012"); - break; - } - break; - case 3: - switch (osvi.wProductType) { - case VER_NT_WORKSTATION: - gb_printf("Windows 8.1 "); - report_windows_product_type(ProductType); - break; - case 3: - gb_printf("Windows Server 2012 R2"); - break; - } - break; - } - break; - case 5: - switch (osvi.dwMinorVersion) { - case 0: - gb_printf("Windows 2000"); - break; - case 1: - gb_printf("Windows XP"); - break; - case 2: - gb_printf("Windows Server 2003"); - break; - } - break; - default: - break; + case 1: + switch (osvi.wProductType) { + case VER_NT_WORKSTATION: + gb_printf("Windows 7 "); + report_windows_product_type(ProductType); + break; + case 3: + gb_printf("Windows Server 2008 R2"); + break; + } + break; + case 2: + switch (osvi.wProductType) { + case VER_NT_WORKSTATION: + gb_printf("Windows 8 "); + report_windows_product_type(ProductType); + break; + case 3: + gb_printf("Windows Server 2012"); + break; + } + break; + case 3: + switch (osvi.wProductType) { + case VER_NT_WORKSTATION: + gb_printf("Windows 8.1 "); + report_windows_product_type(ProductType); + break; + case 3: + gb_printf("Windows Server 2012 R2"); + break; + } + break; } - - /* - Grab Windows DisplayVersion (like 20H02) - */ - LPDWORD ValueType = {}; - DWORD UBR; - char DisplayVersion[256]; - DWORD ValueSize = 256; - - status = RegGetValue( - HKEY_LOCAL_MACHINE, - TEXT("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"), - TEXT("DisplayVersion"), - RRF_RT_REG_SZ, - ValueType, - DisplayVersion, - &ValueSize - ); - - if (status == 0x0) { - gb_printf(" (version: %s)", DisplayVersion); + break; + case 5: + switch (osvi.dwMinorVersion) { + case 0: + gb_printf("Windows 2000"); + break; + case 1: + gb_printf("Windows XP"); + break; + case 2: + gb_printf("Windows Server 2003"); + break; } - - /* - Now print build number. - */ - gb_printf(", build %u", cast(unsigned)osvi.dwBuildNumber); - - ValueSize = sizeof(UBR); - status = RegGetValue( - HKEY_LOCAL_MACHINE, - TEXT("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"), - TEXT("UBR"), - RRF_RT_REG_DWORD, - ValueType, - &UBR, - &ValueSize - ); - - if (status == 0x0) { - gb_printf(".%u", cast(unsigned)UBR); - } - gb_printf("\n"); + break; + default: + break; } + /* + Grab Windows DisplayVersion (like 20H02) + */ + LPDWORD ValueType = {}; + DWORD UBR; + char DisplayVersion[256]; + DWORD ValueSize = 256; + + status = RegGetValue( + HKEY_LOCAL_MACHINE, + TEXT("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"), + TEXT("DisplayVersion"), + RRF_RT_REG_SZ, + ValueType, + DisplayVersion, + &ValueSize + ); + + if (status == 0x0) { + gb_printf(" (version: %s)", DisplayVersion); + } + + /* + Now print build number. + */ + gb_printf(", build %u", cast(unsigned)osvi.dwBuildNumber); + + ValueSize = sizeof(UBR); + status = RegGetValue( + HKEY_LOCAL_MACHINE, + TEXT("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"), + TEXT("UBR"), + RRF_RT_REG_DWORD, + ValueType, + &UBR, + &ValueSize + ); + + if (status == 0x0) { + gb_printf(".%u", cast(unsigned)UBR); + } + gb_printf("\n"); + } #elif defined(GB_SYSTEM_LINUX) /* Try to parse `/etc/os-release` for `PRETTY_NAME="Ubuntu 20.04.3 LTS` @@ -542,10 +523,10 @@ void print_bug_report_help() { b32 found = 1; uint32_t major, minor; - #define osx_version_buffer 100 - char buffer[osx_version_buffer]; - size_t buffer_size = osx_version_buffer - 1; - #undef osx_version_buffer + #define freebsd_version_buffer 100 + char buffer[freebsd_version_buffer]; + size_t buffer_size = freebsd_version_buffer - 1; + #undef freebsd_version_buffer int sysctls[] = { CTL_KERN, KERN_OSRELEASE }; if (sysctl(sysctls, 2, buffer, &buffer_size, NULL, 0) == -1) { @@ -664,10 +645,82 @@ void print_bug_report_help() { } else { gb_printf("OpenBSD: Unknown\n"); } - #else - gb_printf("Unknown\n"); + #elif defined(GB_SYSTEM_FREEBSD) + #define freebsd_version_buffer 129 + char buffer[freebsd_version_buffer]; + size_t buffer_size = freebsd_version_buffer - 1; + #undef freebsd_version_buffer + int sysctls[] = { CTL_KERN, KERN_VERSION }; + if (sysctl(sysctls, 2, buffer, &buffer_size, NULL, 0) == -1) { + gb_printf("FreeBSD: Unknown\n"); + } else { + // KERN_VERSION can end in a \n, replace it with a \0 + for (int i = 0; i < buffer_size; i += 1) { + if (buffer[i] == '\n') buffer[i] = 0; + } + gb_printf("%s", &buffer[0]); + + // Retrieve kernel revision using `sysctl`, e.g. 199506 + sysctls[1] = KERN_OSREV; + uint64_t revision; + size_t revision_size = sizeof(revision); + + if (sysctl(sysctls, 2, &revision, &revision_size, NULL, 0) == -1) { + gb_printf("\n"); + } else { + gb_printf(", revision %ld\n", revision); + } + } + + // if (found) { + // gb_printf("FreeBSD ") + // } + + // // Retrieve kernel revision using `sysctl`, e.g. 199506 + // mib = []i32{sys.CTL_KERN, sys.KERN_OSREV} + // revision: int + // if !sys.sysctl(mib, &revision) { + // return + // } + // os_version.patch = revision + + // strings.write_string(&b, ", revision ") + // strings.write_int(&b, revision) + #else + gb_printf("Unknown"); #endif +} + +// NOTE(Jeroen): `odin report` prints some system information for easier bug reporting. +void print_bug_report_help() { + gb_printf("Where to find more information and get into contact when you encounter a bug:\n\n"); + gb_printf("\tWebsite: https://odin-lang.org\n"); + gb_printf("\tGitHub: https://github.com/odin-lang/Odin/issues\n"); + /* + Uncomment and update URL once we have a Discord vanity URL. For now people can get here from the site. + gb_printf("\tDiscord: https://discord.com/invite/sVBPHEv\n"); + */ + gb_printf("\n\n"); + + gb_printf("Useful information to add to a bug report:\n\n"); + + gb_printf("\tOdin: %.*s", LIT(ODIN_VERSION)); + + #ifdef NIGHTLY + gb_printf("-nightly"); + #endif + + #ifdef GIT_SHA + gb_printf(":%s", GIT_SHA); + #endif + + gb_printf("\n"); + + /* + Print OS information. + */ + report_os_info(); /* Now print CPU info. @@ -678,4 +731,4 @@ void print_bug_report_help() { And RAM info. */ report_ram_info(); -} +} \ No newline at end of file From 590615ba525608092822cd0b3cee0e1052bfe34c Mon Sep 17 00:00:00 2001 From: Jeroen van Rijn Date: Mon, 5 Sep 2022 18:06:34 +0200 Subject: [PATCH 17/25] [odin report] Improve macOS detection. --- src/bug_report.cpp | 537 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 405 insertions(+), 132 deletions(-) diff --git a/src/bug_report.cpp b/src/bug_report.cpp index 6fa66e02f..f4f1b51be 100644 --- a/src/bug_report.cpp +++ b/src/bug_report.cpp @@ -246,24 +246,24 @@ void report_ram_info() { uint64_t ram_amount; size_t val_size = sizeof(ram_amount); - int sysctls[] = { CTL_HW, HW_MEMSIZE }; - if (sysctl(sysctls, 2, &ram_amount, &val_size, NULL, 0) != -1) { + int mibs[] = { CTL_HW, HW_MEMSIZE }; + if (sysctl(mibs, 2, &ram_amount, &val_size, NULL, 0) != -1) { gb_printf("%lld MiB\n", ram_amount / gb_megabytes(1)); } #elif defined(GB_SYSTEM_OPENBSD) uint64_t ram_amount; size_t val_size = sizeof(ram_amount); - int sysctls[] = { CTL_HW, HW_PHYSMEM64 }; - if (sysctl(sysctls, 2, &ram_amount, &val_size, NULL, 0) != -1) { + int mibs[] = { CTL_HW, HW_PHYSMEM64 }; + if (sysctl(mibs, 2, &ram_amount, &val_size, NULL, 0) != -1) { gb_printf("%lld MiB\n", ram_amount / gb_megabytes(1)); } #elif defined(GB_SYSTEM_FREEBSD) uint64_t ram_amount; size_t val_size = sizeof(ram_amount); - int sysctls[] = { CTL_HW, HW_PHYSMEM }; - if (sysctl(sysctls, 2, &ram_amount, &val_size, NULL, 0) != -1) { + int mibs[] = { CTL_HW, HW_PHYSMEM }; + if (sysctl(mibs, 2, &ram_amount, &val_size, NULL, 0) != -1) { gb_printf("%lu MiB\n", ram_amount / gb_megabytes(1)); } #else @@ -520,123 +520,411 @@ void report_os_info() { gb_printf(", %s %s\n", info->sysname, info->release); #elif defined(GB_SYSTEM_OSX) - b32 found = 1; - uint32_t major, minor; + struct Darwin_To_Release { + const char* build; // 21G83 + int darwin[3]; // Darwin kernel triplet + const char* os_name; // OS X, MacOS + struct { + const char* name; // Monterey, Mojave, etc. + int version[3]; // 12.4, etc. + } release; + }; - #define freebsd_version_buffer 100 - char buffer[freebsd_version_buffer]; - size_t buffer_size = freebsd_version_buffer - 1; - #undef freebsd_version_buffer + Darwin_To_Release macos_release_map[] = { + {"8A428", { 8, 0, 0}, "macOS", {"Tiger", {10, 4, 0}}}, + {"8A432", { 8, 0, 0}, "macOS", {"Tiger", {10, 4, 0}}}, + {"8B15", { 8, 1, 0}, "macOS", {"Tiger", {10, 4, 1}}}, + {"8B17", { 8, 1, 0}, "macOS", {"Tiger", {10, 4, 1}}}, + {"8C46", { 8, 2, 0}, "macOS", {"Tiger", {10, 4, 2}}}, + {"8C47", { 8, 2, 0}, "macOS", {"Tiger", {10, 4, 2}}}, + {"8E102", { 8, 2, 0}, "macOS", {"Tiger", {10, 4, 2}}}, + {"8E45", { 8, 2, 0}, "macOS", {"Tiger", {10, 4, 2}}}, + {"8E90", { 8, 2, 0}, "macOS", {"Tiger", {10, 4, 2}}}, + {"8F46", { 8, 3, 0}, "macOS", {"Tiger", {10, 4, 3}}}, + {"8G32", { 8, 4, 0}, "macOS", {"Tiger", {10, 4, 4}}}, + {"8G1165", { 8, 4, 0}, "macOS", {"Tiger", {10, 4, 4}}}, + {"8H14", { 8, 5, 0}, "macOS", {"Tiger", {10, 4, 5}}}, + {"8G1454", { 8, 5, 0}, "macOS", {"Tiger", {10, 4, 5}}}, + {"8I127", { 8, 6, 0}, "macOS", {"Tiger", {10, 4, 6}}}, + {"8I1119", { 8, 6, 0}, "macOS", {"Tiger", {10, 4, 6}}}, + {"8J135", { 8, 7, 0}, "macOS", {"Tiger", {10, 4, 7}}}, + {"8J2135a", { 8, 7, 0}, "macOS", {"Tiger", {10, 4, 7}}}, + {"8K1079", { 8, 7, 0}, "macOS", {"Tiger", {10, 4, 7}}}, + {"8N5107", { 8, 7, 0}, "macOS", {"Tiger", {10, 4, 7}}}, + {"8L127", { 8, 8, 0}, "macOS", {"Tiger", {10, 4, 8}}}, + {"8L2127", { 8, 8, 0}, "macOS", {"Tiger", {10, 4, 8}}}, + {"8P135", { 8, 9, 0}, "macOS", {"Tiger", {10, 4, 9}}}, + {"8P2137", { 8, 9, 0}, "macOS", {"Tiger", {10, 4, 9}}}, + {"8R218", { 8, 10, 0}, "macOS", {"Tiger", {10, 4, 10}}}, + {"8R2218", { 8, 10, 0}, "macOS", {"Tiger", {10, 4, 10}}}, + {"8R2232", { 8, 10, 0}, "macOS", {"Tiger", {10, 4, 10}}}, + {"8S165", { 8, 11, 0}, "macOS", {"Tiger", {10, 4, 11}}}, + {"8S2167", { 8, 11, 0}, "macOS", {"Tiger", {10, 4, 11}}}, + {"9A581", { 9, 0, 0}, "macOS", {"Leopard", {10, 5, 0}}}, + {"9B18", { 9, 1, 0}, "macOS", {"Leopard", {10, 5, 1}}}, + {"9B2117", { 9, 1, 1}, "macOS", {"Leopard", {10, 5, 1}}}, + {"9C31", { 9, 2, 0}, "macOS", {"Leopard", {10, 5, 2}}}, + {"9C7010", { 9, 2, 0}, "macOS", {"Leopard", {10, 5, 2}}}, + {"9D34", { 9, 3, 0}, "macOS", {"Leopard", {10, 5, 3}}}, + {"9E17", { 9, 4, 0}, "macOS", {"Leopard", {10, 5, 4}}}, + {"9F33", { 9, 5, 0}, "macOS", {"Leopard", {10, 5, 5}}}, + {"9G55", { 9, 6, 0}, "macOS", {"Leopard", {10, 5, 6}}}, + {"9G66", { 9, 6, 0}, "macOS", {"Leopard", {10, 5, 6}}}, + {"9G71", { 9, 6, 0}, "macOS", {"Leopard", {10, 5, 6}}}, + {"9J61", { 9, 7, 0}, "macOS", {"Leopard", {10, 5, 7}}}, + {"9L30", { 9, 8, 0}, "macOS", {"Leopard", {10, 5, 8}}}, + {"9L34", { 9, 8, 0}, "macOS", {"Leopard", {10, 5, 8}}}, + {"10A432", {10, 0, 0}, "macOS", {"Snow Leopard", {10, 6, 0}}}, + {"10A433", {10, 0, 0}, "macOS", {"Snow Leopard", {10, 6, 0}}}, + {"10B504", {10, 1, 0}, "macOS", {"Snow Leopard", {10, 6, 1}}}, + {"10C540", {10, 2, 0}, "macOS", {"Snow Leopard", {10, 6, 2}}}, + {"10D573", {10, 3, 0}, "macOS", {"Snow Leopard", {10, 6, 3}}}, + {"10D575", {10, 3, 0}, "macOS", {"Snow Leopard", {10, 6, 3}}}, + {"10D578", {10, 3, 0}, "macOS", {"Snow Leopard", {10, 6, 3}}}, + {"10F569", {10, 4, 0}, "macOS", {"Snow Leopard", {10, 6, 4}}}, + {"10H574", {10, 5, 0}, "macOS", {"Snow Leopard", {10, 6, 5}}}, + {"10J567", {10, 6, 0}, "macOS", {"Snow Leopard", {10, 6, 6}}}, + {"10J869", {10, 7, 0}, "macOS", {"Snow Leopard", {10, 6, 7}}}, + {"10J3250", {10, 7, 0}, "macOS", {"Snow Leopard", {10, 6, 7}}}, + {"10J4138", {10, 7, 0}, "macOS", {"Snow Leopard", {10, 6, 7}}}, + {"10K540", {10, 8, 0}, "macOS", {"Snow Leopard", {10, 6, 8}}}, + {"10K549", {10, 8, 0}, "macOS", {"Snow Leopard", {10, 6, 8}}}, + {"11A511", {11, 0, 0}, "macOS", {"Lion", {10, 7, 0}}}, + {"11A511s", {11, 0, 0}, "macOS", {"Lion", {10, 7, 0}}}, + {"11A2061", {11, 0, 2}, "macOS", {"Lion", {10, 7, 0}}}, + {"11A2063", {11, 0, 2}, "macOS", {"Lion", {10, 7, 0}}}, + {"11B26", {11, 1, 0}, "macOS", {"Lion", {10, 7, 1}}}, + {"11B2118", {11, 1, 0}, "macOS", {"Lion", {10, 7, 1}}}, + {"11C74", {11, 2, 0}, "macOS", {"Lion", {10, 7, 2}}}, + {"11D50", {11, 3, 0}, "macOS", {"Lion", {10, 7, 3}}}, + {"11E53", {11, 4, 0}, "macOS", {"Lion", {10, 7, 4}}}, + {"11G56", {11, 4, 2}, "macOS", {"Lion", {10, 7, 5}}}, + {"11G63", {11, 4, 2}, "macOS", {"Lion", {10, 7, 5}}}, + {"12A269", {12, 0, 0}, "macOS", {"Mountain Lion", {10, 8, 0}}}, + {"12B19", {12, 1, 0}, "macOS", {"Mountain Lion", {10, 8, 1}}}, + {"12C54", {12, 2, 0}, "macOS", {"Mountain Lion", {10, 8, 2}}}, + {"12C60", {12, 2, 0}, "macOS", {"Mountain Lion", {10, 8, 2}}}, + {"12C2034", {12, 2, 0}, "macOS", {"Mountain Lion", {10, 8, 2}}}, + {"12C3104", {12, 2, 0}, "macOS", {"Mountain Lion", {10, 8, 2}}}, + {"12D78", {12, 3, 0}, "macOS", {"Mountain Lion", {10, 8, 3}}}, + {"12E55", {12, 4, 0}, "macOS", {"Mountain Lion", {10, 8, 4}}}, + {"12E3067", {12, 4, 0}, "macOS", {"Mountain Lion", {10, 8, 4}}}, + {"12E4022", {12, 4, 0}, "macOS", {"Mountain Lion", {10, 8, 4}}}, + {"12F37", {12, 5, 0}, "macOS", {"Mountain Lion", {10, 8, 5}}}, + {"12F45", {12, 5, 0}, "macOS", {"Mountain Lion", {10, 8, 5}}}, + {"12F2501", {12, 5, 0}, "macOS", {"Mountain Lion", {10, 8, 5}}}, + {"12F2518", {12, 5, 0}, "macOS", {"Mountain Lion", {10, 8, 5}}}, + {"12F2542", {12, 5, 0}, "macOS", {"Mountain Lion", {10, 8, 5}}}, + {"12F2560", {12, 5, 0}, "macOS", {"Mountain Lion", {10, 8, 5}}}, + {"13A603", {13, 0, 0}, "macOS", {"Mavericks", {10, 9, 0}}}, + {"13B42", {13, 0, 0}, "macOS", {"Mavericks", {10, 9, 1}}}, + {"13C64", {13, 1, 0}, "macOS", {"Mavericks", {10, 9, 2}}}, + {"13C1021", {13, 1, 0}, "macOS", {"Mavericks", {10, 9, 2}}}, + {"13D65", {13, 2, 0}, "macOS", {"Mavericks", {10, 9, 3}}}, + {"13E28", {13, 3, 0}, "macOS", {"Mavericks", {10, 9, 4}}}, + {"13F34", {13, 4, 0}, "macOS", {"Mavericks", {10, 9, 5}}}, + {"13F1066", {13, 4, 0}, "macOS", {"Mavericks", {10, 9, 5}}}, + {"13F1077", {13, 4, 0}, "macOS", {"Mavericks", {10, 9, 5}}}, + {"13F1096", {13, 4, 0}, "macOS", {"Mavericks", {10, 9, 5}}}, + {"13F1112", {13, 4, 0}, "macOS", {"Mavericks", {10, 9, 5}}}, + {"13F1134", {13, 4, 0}, "macOS", {"Mavericks", {10, 9, 5}}}, + {"13F1507", {13, 4, 0}, "macOS", {"Mavericks", {10, 9, 5}}}, + {"13F1603", {13, 4, 0}, "macOS", {"Mavericks", {10, 9, 5}}}, + {"13F1712", {13, 4, 0}, "macOS", {"Mavericks", {10, 9, 5}}}, + {"13F1808", {13, 4, 0}, "macOS", {"Mavericks", {10, 9, 5}}}, + {"13F1911", {13, 4, 0}, "macOS", {"Mavericks", {10, 9, 5}}}, + {"14A389", {14, 0, 0}, "macOS", {"Yosemite", {10, 10, 0}}}, + {"14B25", {14, 0, 0}, "macOS", {"Yosemite", {10, 10, 1}}}, + {"14C109", {14, 1, 0}, "macOS", {"Yosemite", {10, 10, 2}}}, + {"14C1510", {14, 1, 0}, "macOS", {"Yosemite", {10, 10, 2}}}, + {"14C2043", {14, 1, 0}, "macOS", {"Yosemite", {10, 10, 2}}}, + {"14C1514", {14, 1, 0}, "macOS", {"Yosemite", {10, 10, 2}}}, + {"14C2513", {14, 1, 0}, "macOS", {"Yosemite", {10, 10, 2}}}, + {"14D131", {14, 3, 0}, "macOS", {"Yosemite", {10, 10, 3}}}, + {"14D136", {14, 3, 0}, "macOS", {"Yosemite", {10, 10, 3}}}, + {"14E46", {14, 4, 0}, "macOS", {"Yosemite", {10, 10, 4}}}, + {"14F27", {14, 5, 0}, "macOS", {"Yosemite", {10, 10, 5}}}, + {"14F1021", {14, 5, 0}, "macOS", {"Yosemite", {10, 10, 5}}}, + {"14F1505", {14, 5, 0}, "macOS", {"Yosemite", {10, 10, 5}}}, + {"14F1509", {14, 5, 0}, "macOS", {"Yosemite", {10, 10, 5}}}, + {"14F1605", {14, 5, 0}, "macOS", {"Yosemite", {10, 10, 5}}}, + {"14F1713", {14, 5, 0}, "macOS", {"Yosemite", {10, 10, 5}}}, + {"14F1808", {14, 5, 0}, "macOS", {"Yosemite", {10, 10, 5}}}, + {"14F1909", {14, 5, 0}, "macOS", {"Yosemite", {10, 10, 5}}}, + {"14F1912", {14, 5, 0}, "macOS", {"Yosemite", {10, 10, 5}}}, + {"14F2009", {14, 5, 0}, "macOS", {"Yosemite", {10, 10, 5}}}, + {"14F2109", {14, 5, 0}, "macOS", {"Yosemite", {10, 10, 5}}}, + {"14F2315", {14, 5, 0}, "macOS", {"Yosemite", {10, 10, 5}}}, + {"14F2411", {14, 5, 0}, "macOS", {"Yosemite", {10, 10, 5}}}, + {"14F2511", {14, 5, 0}, "macOS", {"Yosemite", {10, 10, 5}}}, + {"15A284", {15, 0, 0}, "macOS", {"El Capitan", {10, 11, 0}}}, + {"15B42", {15, 0, 0}, "macOS", {"El Capitan", {10, 11, 1}}}, + {"15C50", {15, 2, 0}, "macOS", {"El Capitan", {10, 11, 2}}}, + {"15D21", {15, 3, 0}, "macOS", {"El Capitan", {10, 11, 3}}}, + {"15E65", {15, 4, 0}, "macOS", {"El Capitan", {10, 11, 4}}}, + {"15F34", {15, 5, 0}, "macOS", {"El Capitan", {10, 11, 5}}}, + {"15G31", {15, 6, 0}, "macOS", {"El Capitan", {10, 11, 6}}}, + {"15G1004", {15, 6, 0}, "macOS", {"El Capitan", {10, 11, 6}}}, + {"15G1011", {15, 6, 0}, "macOS", {"El Capitan", {10, 11, 6}}}, + {"15G1108", {15, 6, 0}, "macOS", {"El Capitan", {10, 11, 6}}}, + {"15G1212", {15, 6, 0}, "macOS", {"El Capitan", {10, 11, 6}}}, + {"15G1217", {15, 6, 0}, "macOS", {"El Capitan", {10, 11, 6}}}, + {"15G1421", {15, 6, 0}, "macOS", {"El Capitan", {10, 11, 6}}}, + {"15G1510", {15, 6, 0}, "macOS", {"El Capitan", {10, 11, 6}}}, + {"15G1611", {15, 6, 0}, "macOS", {"El Capitan", {10, 11, 6}}}, + {"15G17023", {15, 6, 0}, "macOS", {"El Capitan", {10, 11, 6}}}, + {"15G18013", {15, 6, 0}, "macOS", {"El Capitan", {10, 11, 6}}}, + {"15G19009", {15, 6, 0}, "macOS", {"El Capitan", {10, 11, 6}}}, + {"15G20015", {15, 6, 0}, "macOS", {"El Capitan", {10, 11, 6}}}, + {"15G21013", {15, 6, 0}, "macOS", {"El Capitan", {10, 11, 6}}}, + {"15G22010", {15, 6, 0}, "macOS", {"El Capitan", {10, 11, 6}}}, + {"16A323", {16, 0, 0}, "macOS", {"Sierra", {10, 12, 0}}}, + {"16B2555", {16, 1, 0}, "macOS", {"Sierra", {10, 12, 1}}}, + {"16B2657", {16, 1, 0}, "macOS", {"Sierra", {10, 12, 1}}}, + {"16C67", {16, 3, 0}, "macOS", {"Sierra", {10, 12, 2}}}, + {"16C68", {16, 3, 0}, "macOS", {"Sierra", {10, 12, 2}}}, + {"16D32", {16, 4, 0}, "macOS", {"Sierra", {10, 12, 3}}}, + {"16E195", {16, 5, 0}, "macOS", {"Sierra", {10, 12, 4}}}, + {"16F73", {16, 6, 0}, "macOS", {"Sierra", {10, 12, 5}}}, + {"16F2073", {16, 6, 0}, "macOS", {"Sierra", {10, 12, 5}}}, + {"16G29", {16, 7, 0}, "macOS", {"Sierra", {10, 12, 6}}}, + {"16G1036", {16, 7, 0}, "macOS", {"Sierra", {10, 12, 6}}}, + {"16G1114", {16, 7, 0}, "macOS", {"Sierra", {10, 12, 6}}}, + {"16G1212", {16, 7, 0}, "macOS", {"Sierra", {10, 12, 6}}}, + {"16G1314", {16, 7, 0}, "macOS", {"Sierra", {10, 12, 6}}}, + {"16G1408", {16, 7, 0}, "macOS", {"Sierra", {10, 12, 6}}}, + {"16G1510", {16, 7, 0}, "macOS", {"Sierra", {10, 12, 6}}}, + {"16G1618", {16, 7, 0}, "macOS", {"Sierra", {10, 12, 6}}}, + {"16G1710", {16, 7, 0}, "macOS", {"Sierra", {10, 12, 6}}}, + {"16G1815", {16, 7, 0}, "macOS", {"Sierra", {10, 12, 6}}}, + {"16G1917", {16, 7, 0}, "macOS", {"Sierra", {10, 12, 6}}}, + {"16G1918", {16, 7, 0}, "macOS", {"Sierra", {10, 12, 6}}}, + {"16G2016", {16, 7, 0}, "macOS", {"Sierra", {10, 12, 6}}}, + {"16G2127", {16, 7, 0}, "macOS", {"Sierra", {10, 12, 6}}}, + {"16G2128", {16, 7, 0}, "macOS", {"Sierra", {10, 12, 6}}}, + {"16G2136", {16, 7, 0}, "macOS", {"Sierra", {10, 12, 6}}}, + {"17A365", {17, 0, 0}, "macOS", {"High Sierra", {10, 13, 0}}}, + {"17A405", {17, 0, 0}, "macOS", {"High Sierra", {10, 13, 0}}}, + {"17B48", {17, 2, 0}, "macOS", {"High Sierra", {10, 13, 1}}}, + {"17B1002", {17, 2, 0}, "macOS", {"High Sierra", {10, 13, 1}}}, + {"17B1003", {17, 2, 0}, "macOS", {"High Sierra", {10, 13, 1}}}, + {"17C88", {17, 3, 0}, "macOS", {"High Sierra", {10, 13, 2}}}, + {"17C89", {17, 3, 0}, "macOS", {"High Sierra", {10, 13, 2}}}, + {"17C205", {17, 3, 0}, "macOS", {"High Sierra", {10, 13, 2}}}, + {"17C2205", {17, 3, 0}, "macOS", {"High Sierra", {10, 13, 2}}}, + {"17D47", {17, 4, 0}, "macOS", {"High Sierra", {10, 13, 3}}}, + {"17D2047", {17, 4, 0}, "macOS", {"High Sierra", {10, 13, 3}}}, + {"17D102", {17, 4, 0}, "macOS", {"High Sierra", {10, 13, 3}}}, + {"17D2102", {17, 4, 0}, "macOS", {"High Sierra", {10, 13, 3}}}, + {"17E199", {17, 5, 0}, "macOS", {"High Sierra", {10, 13, 4}}}, + {"17E202", {17, 5, 0}, "macOS", {"High Sierra", {10, 13, 4}}}, + {"17F77", {17, 6, 0}, "macOS", {"High Sierra", {10, 13, 5}}}, + {"17G65", {17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, + {"17G2208", {17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, + {"17G2307", {17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, + {"17G3025", {17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, + {"17G4015", {17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, + {"17G5019", {17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, + {"17G6029", {17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, + {"17G6030", {17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, + {"17G7024", {17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, + {"17G8029", {17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, + {"17G8030", {17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, + {"17G8037", {17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, + {"17G9016", {17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, + {"17G10021", {17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, + {"17G11023", {17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, + {"17G12034", {17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, + {"17G13033", {17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, + {"17G13035", {17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, + {"17G14019", {17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, + {"17G14033", {17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, + {"17G14042", {17, 7, 0}, "macOS", {"High Sierra", {10, 13, 6}}}, + {"18A391", {18, 0, 0}, "macOS", {"Mojave", {10, 14, 0}}}, + {"18B75", {18, 2, 0}, "macOS", {"Mojave", {10, 14, 1}}}, + {"18B2107", {18, 2, 0}, "macOS", {"Mojave", {10, 14, 1}}}, + {"18B3094", {18, 2, 0}, "macOS", {"Mojave", {10, 14, 1}}}, + {"18C54", {18, 2, 0}, "macOS", {"Mojave", {10, 14, 2}}}, + {"18D42", {18, 2, 0}, "macOS", {"Mojave", {10, 14, 3}}}, + {"18D43", {18, 2, 0}, "macOS", {"Mojave", {10, 14, 3}}}, + {"18D109", {18, 2, 0}, "macOS", {"Mojave", {10, 14, 3}}}, + {"18E226", {18, 5, 0}, "macOS", {"Mojave", {10, 14, 4}}}, + {"18E227", {18, 5, 0}, "macOS", {"Mojave", {10, 14, 4}}}, + {"18F132", {18, 6, 0}, "macOS", {"Mojave", {10, 14, 5}}}, + {"18G84", {18, 7, 0}, "macOS", {"Mojave", {10, 14, 6}}}, + {"18G87", {18, 7, 0}, "macOS", {"Mojave", {10, 14, 6}}}, + {"18G95", {18, 7, 0}, "macOS", {"Mojave", {10, 14, 6}}}, + {"18G103", {18, 7, 0}, "macOS", {"Mojave", {10, 14, 6}}}, + {"18G1012", {18, 7, 0}, "macOS", {"Mojave", {10, 14, 6}}}, + {"18G2022", {18, 7, 0}, "macOS", {"Mojave", {10, 14, 6}}}, + {"18G3020", {18, 7, 0}, "macOS", {"Mojave", {10, 14, 6}}}, + {"18G4032", {18, 7, 0}, "macOS", {"Mojave", {10, 14, 6}}}, + {"18G5033", {18, 7, 0}, "macOS", {"Mojave", {10, 14, 6}}}, + {"18G6020", {18, 7, 0}, "macOS", {"Mojave", {10, 14, 6}}}, + {"18G6032", {18, 7, 0}, "macOS", {"Mojave", {10, 14, 6}}}, + {"18G6042", {18, 7, 0}, "macOS", {"Mojave", {10, 14, 6}}}, + {"18G7016", {18, 7, 0}, "macOS", {"Mojave", {10, 14, 6}}}, + {"18G8012", {18, 7, 0}, "macOS", {"Mojave", {10, 14, 6}}}, + {"18G8022", {18, 7, 0}, "macOS", {"Mojave", {10, 14, 6}}}, + {"18G9028", {18, 7, 0}, "macOS", {"Mojave", {10, 14, 6}}}, + {"18G9216", {18, 7, 0}, "macOS", {"Mojave", {10, 14, 6}}}, + {"18G9323", {18, 7, 0}, "macOS", {"Mojave", {10, 14, 6}}}, + {"19A583", {19, 0, 0}, "macOS", {"Catalina", {10, 15, 0}}}, + {"19A602", {19, 0, 0}, "macOS", {"Catalina", {10, 15, 0}}}, + {"19A603", {19, 0, 0}, "macOS", {"Catalina", {10, 15, 0}}}, + {"19B88", {19, 0, 0}, "macOS", {"Catalina", {10, 15, 1}}}, + {"19C57", {19, 2, 0}, "macOS", {"Catalina", {10, 15, 2}}}, + {"19C58", {19, 2, 0}, "macOS", {"Catalina", {10, 15, 2}}}, + {"19D76", {19, 3, 0}, "macOS", {"Catalina", {10, 15, 3}}}, + {"19E266", {19, 4, 0}, "macOS", {"Catalina", {10, 15, 4}}}, + {"19E287", {19, 4, 0}, "macOS", {"Catalina", {10, 15, 4}}}, + {"19F96", {19, 5, 0}, "macOS", {"Catalina", {10, 15, 5}}}, + {"19F101", {19, 5, 0}, "macOS", {"Catalina", {10, 15, 5}}}, + {"19G73", {19, 6, 0}, "macOS", {"Catalina", {10, 15, 6}}}, + {"19G2021", {19, 6, 0}, "macOS", {"Catalina", {10, 15, 6}}}, + {"19H2", {19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, + {"19H4", {19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, + {"19H15", {19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, + {"19H114", {19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, + {"19H512", {19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, + {"19H524", {19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, + {"19H1030", {19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, + {"19H1217", {19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, + {"19H1323", {19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, + {"19H1417", {19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, + {"19H1419", {19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, + {"19H1519", {19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, + {"19H1615", {19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, + {"19H1713", {19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, + {"19H1715", {19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, + {"19H1824", {19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, + {"19H1922", {19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, + {"19H2026", {19, 6, 0}, "macOS", {"Catalina", {10, 15, 7}}}, + {"20A2411", {20, 1, 0}, "macOS", {"Big Sur", {11, 0, 0}}}, + {"20B29", {20, 1, 0}, "macOS", {"Big Sur", {11, 0, 1}}}, + {"20B50", {20, 1, 0}, "macOS", {"Big Sur", {11, 0, 1}}}, + {"20C69", {20, 2, 0}, "macOS", {"Big Sur", {11, 1, 0}}}, + {"20D64", {20, 3, 0}, "macOS", {"Big Sur", {11, 2, 0}}}, + {"20D74", {20, 3, 0}, "macOS", {"Big Sur", {11, 2, 1}}}, + {"20D75", {20, 3, 0}, "macOS", {"Big Sur", {11, 2, 1}}}, + {"20D80", {20, 3, 0}, "macOS", {"Big Sur", {11, 2, 2}}}, + {"20D91", {20, 3, 0}, "macOS", {"Big Sur", {11, 2, 3}}}, + {"20E232", {20, 4, 0}, "macOS", {"Big Sur", {11, 3, 0}}}, + {"20E241", {20, 4, 0}, "macOS", {"Big Sur", {11, 3, 1}}}, + {"20F71", {20, 5, 0}, "macOS", {"Big Sur", {11, 4, 0}}}, + {"20G71", {20, 6, 0}, "macOS", {"Big Sur", {11, 5, 0}}}, + {"20G80", {20, 6, 0}, "macOS", {"Big Sur", {11, 5, 1}}}, + {"20G95", {20, 6, 0}, "macOS", {"Big Sur", {11, 5, 2}}}, + {"20G165", {20, 6, 0}, "macOS", {"Big Sur", {11, 6, 0}}}, + {"20G224", {20, 6, 0}, "macOS", {"Big Sur", {11, 6, 1}}}, + {"20G314", {20, 6, 0}, "macOS", {"Big Sur", {11, 6, 2}}}, + {"20G415", {20, 6, 0}, "macOS", {"Big Sur", {11, 6, 3}}}, + {"20G417", {20, 6, 0}, "macOS", {"Big Sur", {11, 6, 4}}}, + {"20G527", {20, 6, 0}, "macOS", {"Big Sur", {11, 6, 5}}}, + {"20G624", {20, 6, 0}, "macOS", {"Big Sur", {11, 6, 6}}}, + {"20G630", {20, 6, 0}, "macOS", {"Big Sur", {11, 6, 7}}}, + {"20G730", {20, 6, 0}, "macOS", {"Big Sur", {11, 6, 8}}}, + {"21A344", {21, 0, 1}, "macOS", {"Monterey", {12, 0, 0}}}, + {"21A559", {21, 1, 0}, "macOS", {"Monterey", {12, 0, 1}}}, + {"21C52", {21, 2, 0}, "macOS", {"Monterey", {12, 1, 0}}}, + {"21D49", {21, 3, 0}, "macOS", {"Monterey", {12, 2, 0}}}, + {"21D62", {21, 3, 0}, "macOS", {"Monterey", {12, 2, 1}}}, + {"21E230", {21, 4, 0}, "macOS", {"Monterey", {12, 3, 0}}}, + {"21E258", {21, 4, 0}, "macOS", {"Monterey", {12, 3, 1}}}, + {"21F79", {21, 5, 0}, "macOS", {"Monterey", {12, 4, 0}}}, + {"21F2081", {21, 5, 0}, "macOS", {"Monterey", {12, 4, 0}}}, + {"21F2092", {21, 5, 0}, "macOS", {"Monterey", {12, 4, 0}}}, + {"21G72", {21, 6, 0}, "macOS", {"Monterey", {12, 5, 0}}}, + {"21G83", {21, 6, 0}, "macOS", {"Monterey", {12, 5, 1}}}, + }; - int sysctls[] = { CTL_KERN, KERN_OSRELEASE }; - if (sysctl(sysctls, 2, buffer, &buffer_size, NULL, 0) == -1) { - found = 0; + + b32 build_found = 1; + b32 darwin_found = 1; + uint32_t major, minor, patch; + + #define MACOS_VERSION_BUFFER_SIZE 100 + char build_buffer[MACOS_VERSION_BUFFER_SIZE]; + char darwin_buffer[MACOS_VERSION_BUFFER_SIZE]; + size_t build_buffer_size = MACOS_VERSION_BUFFER_SIZE - 1; + size_t darwin_buffer_size = MACOS_VERSION_BUFFER_SIZE - 1; + #undef MACOS_VERSION_BUFFER_SIZE + + int build_mibs[] = { CTL_KERN, KERN_OSVERSION }; + if (sysctl(build_mibs, 2, build_buffer, &build_buffer_size, NULL, 0) == -1) { + build_found = 0; + } + + int darwin_mibs[] = { CTL_KERN, KERN_OSRELEASE }; + if (sysctl(darwin_mibs, 2, darwin_buffer, &darwin_buffer_size, NULL, 0) == -1) { + gb_printf("macOS Unknown\n"); + return; } else { - if (sscanf(buffer, "%u.%u", &major, &minor) != 2) { - found = 0; + if (sscanf(darwin_buffer, "%u.%u.%u", &major, &minor, &patch) != 3) { + darwin_found = 0; } } - if (found) { - switch (major) { - case 21: - /* - macOS Big Sur and newer - */ - major -= 9; + // Scan table for match on BUILD + int macos_release_count = sizeof(macos_release_map) / sizeof(macos_release_map[0]); + Darwin_To_Release match = {}; - gb_printf("macOS 12.0.%d Monterey\n", minor); + for (int build = 0; build < macos_release_count; build++) { + Darwin_To_Release rel = macos_release_map[build]; - break; - case 20: - /* - macOS Big Sur and newer - */ - major -= 9; - - gb_printf("macOS 11.%d Big Sur\n", minor); - - break; - case 14: - /* - macOS 10.1.1 and newer - */ - major -= 4; - - switch (minor) { - case 1: - gb_printf("macOS Puma 10.1\n"); - break; - - case 2: - gb_printf("macOS Jaguar 10.2\n"); - break; - - case 3: - gb_printf("macOS Panther 10.3\n"); - break; - - case 4: - gb_printf("macOS Tiger 10.4\n"); - break; - - case 5: - gb_printf("macOS Leopard 10.5\n"); - break; - - case 6: - gb_printf("macOS Snow Leopard 10.6\n"); - break; - - case 7: - gb_printf("macOS Lion 10.7\n"); - break; - - case 8: - gb_printf("macOS Mountain Lion 10.8\n"); - break; - - case 9: - gb_printf("macOS Mavericks 10.9\n"); - break; - - case 10: - gb_printf("macOS Yosemite 10.10\n"); - break; - - case 11: - gb_printf("macOS El Capitan 10.11\n"); - break; - - case 12: - gb_printf("macOS Sierra 10.12\n"); - break; - - case 13: - gb_printf("macOS High Sierra 10.13\n"); - break; - - case 14: - gb_printf("macOS Mojave 10.14\n"); - break; - - case 15: - gb_printf("macOS Catalina 10.15\n"); - break; - - default: - gb_printf("macOS %d.%d\n", major, minor); - break; - } - - break; - default: - gb_printf("macOS Unknown (kernel version %d.%d)\n", major, minor); + // Do we have an exact match on the BUILD? + if (gb_strcmp(rel.build, (const char *)build_buffer) == 0) { + match = rel; break; } - } else { - gb_printf("macOS: Unknown\n"); - } + + // Do we have an exact Darwin match? + if (rel.darwin[0] == major && rel.darwin[1] == minor && rel.darwin[2] == patch) { + match = rel; + break; + } + + // Major kernel version needs to match exactly, + if (rel.darwin[0] == major) { + // No major version match yet. + if (!match.os_name) { + match = rel; + } + if (minor >= rel.darwin[1]) { + match = rel; + if (patch >= rel.darwin[2]) { + match = rel; + } + } + } + } + + if (match.os_name) { + gb_printf("%s %s %d", match.os_name, match.release.name, match.release.version[0]); + if (match.release.version[1] > 0 || match.release.version[2] > 0) { + gb_printf(".%d", match.release.version[1]); + } + if (match.release.version[2] > 0) { + gb_printf(".%d", match.release.version[2]); + } + if (build_found) { + gb_printf(" (build: %s, kernel: %d.%d.%d)\n", build_buffer, match.darwin[0], match.darwin[1], match.darwin[2]); + } else { + gb_printf(" (build: %s?, kernel: %d.%d.%d)\n", match.build, match.darwin[0], match.darwin[1], match.darwin[2]); + } + return; + } + + if (build_found && darwin_found) { + gb_printf("macOS Unknown (build: %s, kernel: %d.%d.%d)\n", build_buffer, major, minor, patch); + return; + } else if (build_found) { + gb_printf("macOS Unknown (build: %s)\n", build_buffer); + return; + } else if (darwin_found) { + gb_printf("macOS Unknown (kernel: %d.%d.%d)\n", major, minor, patch); + return; + } #elif defined(GB_SYSTEM_OPENBSD) struct utsname un; @@ -651,8 +939,8 @@ void report_os_info() { size_t buffer_size = freebsd_version_buffer - 1; #undef freebsd_version_buffer - int sysctls[] = { CTL_KERN, KERN_VERSION }; - if (sysctl(sysctls, 2, buffer, &buffer_size, NULL, 0) == -1) { + int mibs[] = { CTL_KERN, KERN_VERSION }; + if (sysctl(mibs, 2, buffer, &buffer_size, NULL, 0) == -1) { gb_printf("FreeBSD: Unknown\n"); } else { // KERN_VERSION can end in a \n, replace it with a \0 @@ -662,31 +950,16 @@ void report_os_info() { gb_printf("%s", &buffer[0]); // Retrieve kernel revision using `sysctl`, e.g. 199506 - sysctls[1] = KERN_OSREV; + mibs[1] = KERN_OSREV; uint64_t revision; size_t revision_size = sizeof(revision); - if (sysctl(sysctls, 2, &revision, &revision_size, NULL, 0) == -1) { + if (sysctl(mibs, 2, &revision, &revision_size, NULL, 0) == -1) { gb_printf("\n"); } else { gb_printf(", revision %ld\n", revision); } } - - // if (found) { - // gb_printf("FreeBSD ") - // } - - // // Retrieve kernel revision using `sysctl`, e.g. 199506 - // mib = []i32{sys.CTL_KERN, sys.KERN_OSREV} - // revision: int - // if !sys.sysctl(mib, &revision) { - // return - // } - // os_version.patch = revision - - // strings.write_string(&b, ", revision ") - // strings.write_int(&b, revision) #else gb_printf("Unknown"); #endif From 1ca641f718cd025de508ac42e366b1a00f422539 Mon Sep 17 00:00:00 2001 From: Jeroen van Rijn Date: Mon, 5 Sep 2022 18:39:57 +0200 Subject: [PATCH 18/25] [sys/info] Add doc.odin with explanation. --- core/sys/info/doc.odin | 78 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 core/sys/info/doc.odin diff --git a/core/sys/info/doc.odin b/core/sys/info/doc.odin new file mode 100644 index 000000000..81e437cf8 --- /dev/null +++ b/core/sys/info/doc.odin @@ -0,0 +1,78 @@ +/* + Copyright 2022 Jeroen van Rijn . + Made available under Odin's BSD-3 license. + + Package `core:sys/info` gathers system information on: + Windows, Linux, macOS, FreeBSD & OpenBSD. + + Simply import the package and you'll have access to the OS version, RAM amount + and CPU information. + + On Windows, GPUs will also be enumerated using the registry. + + CPU feature flags can be tested against `cpu_features`, where applicable, e.g. + `if .aes in si.aes { ... }` +*/ +// +ignore +package sysinfo + +import "core:fmt" +import si "core:sys/info" + +main :: proc() { + fmt.printf("Odin: %v\n", ODIN_VERSION) + fmt.printf("OS: %v\n", si.os_version.as_string) + fmt.printf("OS: %#v\n", si.os_version) + fmt.printf("CPU: %v\n", si.cpu_name) + fmt.printf("RAM: %v MiB\n", si.ram.total_ram / 1024 / 1024) + + fmt.println() + for gpu, i in si.gpus { + fmt.printf("GPU #%v:\n", i) + fmt.printf("\tVendor: %v\n", gpu.vendor_name) + fmt.printf("\tModel: %v\n", gpu.model_name) + fmt.printf("\tVRAM: %v MiB\n", gpu.total_ram / 1024 / 1024) + } +} + +/* + Example Windows output: + Odin: dev-2022-09 + OS: Windows 10 Professional (version: 20H2), build: 19042.1466 + OS: OS_Version{ + platform = "Windows", + major = 10, + minor = 0, + patch = 0, + build = [ + 19042, + 1466, + ], + version = "20H2", + as_string = "Windows 10 Professional (version: 20H2), build: 19042.1466", + } + CPU: AMD Ryzen 7 1800X Eight-Core Processor + RAM: 65469 MiB + + GPU #0: + Vendor: Advanced Micro Devices, Inc. + Model: Radeon RX Vega + VRAM: 8176 MiB + + Example macOS output: + ODIN: dev-2022-09 + OS: OS_Version{ + platform = "MacOS", + major = 21, + minor = 5, + patch = 0, + build = [ + 0, + 0, + ], + version = "21F79", + as_string = "macOS Monterey 12.4 (build 21F79, kernel 21.5.0)", + } + CPU: Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz + RAM: 8192 MiB +*/ From cade30b1178dd8648c3b1036a2f3cb12feabba19 Mon Sep 17 00:00:00 2001 From: Jeroen van Rijn Date: Mon, 5 Sep 2022 18:48:50 +0200 Subject: [PATCH 19/25] [sys/info] Add to examples\all --- examples/all/all_main.odin | 3 +++ 1 file changed, 3 insertions(+) diff --git a/examples/all/all_main.odin b/examples/all/all_main.odin index 9f347fad3..1f56431c1 100644 --- a/examples/all/all_main.odin +++ b/examples/all/all_main.odin @@ -109,6 +109,8 @@ import i18n "core:text/i18n" import thread "core:thread" import time "core:time" +import sysinfo "core:sys/info" + import unicode "core:unicode" import utf8 "core:unicode/utf8" import utf8string "core:unicode/utf8/utf8string" @@ -206,6 +208,7 @@ _ :: scanner _ :: i18n _ :: thread _ :: time +_ :: sysinfo _ :: unicode _ :: utf8 _ :: utf8string From a70ea6579d62962bb7414ca218347d620858082e Mon Sep 17 00:00:00 2001 From: Jeroen van Rijn Date: Mon, 5 Sep 2022 18:55:33 +0200 Subject: [PATCH 20/25] Silence -vet. --- core/sys/unix/sysctl_darwin.odin | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/sys/unix/sysctl_darwin.odin b/core/sys/unix/sysctl_darwin.odin index 92b14e6e1..f9530b86f 100644 --- a/core/sys/unix/sysctl_darwin.odin +++ b/core/sys/unix/sysctl_darwin.odin @@ -4,6 +4,8 @@ package unix import "core:sys/darwin" import "core:intrinsics" +_ :: darwin + sysctl :: proc(mib: []i32, val: ^$T) -> (ok: bool) { mib := mib result_size := i64(size_of(T)) From 4b23decb08a39b64aa329b2ff3a196c748595ecf Mon Sep 17 00:00:00 2001 From: Jeroen van Rijn Date: Mon, 5 Sep 2022 19:04:18 +0200 Subject: [PATCH 21/25] Silence vet some more. --- core/sys/info/cpu_arm.odin | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/sys/info/cpu_arm.odin b/core/sys/info/cpu_arm.odin index 5a56e3f78..f66f0e780 100644 --- a/core/sys/info/cpu_arm.odin +++ b/core/sys/info/cpu_arm.odin @@ -17,10 +17,10 @@ _cpu_name_buf: [72]u8 @(init, private) init_cpu_name :: proc "c" () { when ODIN_ARCH == .arm32 { - copy(_cpu_name_buf, "ARM") + copy(_cpu_name_buf[:], "ARM") cpu_name = string(_cpu_name_buf[:3]) } else { - copy(_cpu_name_buf, "ARM64") + copy(_cpu_name_buf[:], "ARM64") cpu_name = string(_cpu_name_buf[:5]) } } \ No newline at end of file From b6ed1177269f62b5fdf879a50c32d636dbc73b76 Mon Sep 17 00:00:00 2001 From: Jeroen van Rijn Date: Mon, 5 Sep 2022 19:18:18 +0200 Subject: [PATCH 22/25] [sys/info] Indentation nitpick. --- core/sys/info/cpu_intel.odin | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/sys/info/cpu_intel.odin b/core/sys/info/cpu_intel.odin index f1a3e7298..8cd723203 100644 --- a/core/sys/info/cpu_intel.odin +++ b/core/sys/info/cpu_intel.odin @@ -75,7 +75,7 @@ init_cpu_features :: proc "c" () { } os_supports_avx := false - if .os_xsave in set { + if .os_xsave in set { eax, _ := xgetbv(0) os_supports_avx = is_set(1, eax) && is_set(2, eax) } From a5a93473085dea8659be825a91bbfd01b7166474 Mon Sep 17 00:00:00 2001 From: Jeroen van Rijn Date: Mon, 5 Sep 2022 21:59:56 +0200 Subject: [PATCH 23/25] Improve error message when you use -file as the verb. --- src/main.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index ef1b8dda1..31371b565 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2727,7 +2727,12 @@ int main(int arg_count, char const **arg_ptr) { if (!single_file_package) { gb_printf_err("ERROR: `%.*s %.*s` takes a package as its first argument.\n", LIT(args[0]), LIT(command)); - gb_printf_err("Did you mean `%.*s %.*s %.*s -file`?\n", LIT(args[0]), LIT(command), LIT(init_filename)); + if (init_filename == "-file") { + gb_printf_err("Did you mean `%.*s %.*s -file`?\n", LIT(args[0]), LIT(command)); + } else { + gb_printf_err("Did you mean `%.*s %.*s %.*s -file`?\n", LIT(args[0]), LIT(command), LIT(init_filename)); + } + gb_printf_err("The `-file` flag tells it to treat a file as a self-contained package.\n"); return 1; } else { From fc2cd3e1d597c7a004bc39bae97fad2beddd9fe1 Mon Sep 17 00:00:00 2001 From: Jeroen van Rijn Date: Mon, 5 Sep 2022 22:28:16 +0200 Subject: [PATCH 24/25] Add `help` verb, e.g. `odin help build`. --- src/main.cpp | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 31371b565..103b0a81b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -590,8 +590,8 @@ void usage(String argv0) { print_usage_line(1, "version print version"); print_usage_line(1, "report print information useful to reporting a bug"); print_usage_line(0, ""); - print_usage_line(0, "For further details on a command, use -help after the command name"); - print_usage_line(1, "e.g. odin build -help"); + print_usage_line(0, "For further details on a command, invoke command help:"); + print_usage_line(1, "e.g. `odin build -help` or `odin help build`"); } enum BuildFlagKind { @@ -1963,13 +1963,13 @@ void print_show_help(String const arg0, String const &command) { print_usage_line(2, "Parse and type check .odin file(s) and then remove unneeded semicolons from the entire project"); } - bool doc = command == "doc"; - bool build = command == "build"; - bool run_or_build = command == "run" || command == "build" || command == "test"; - bool test_only = command == "test"; + bool doc = command == "doc"; + bool build = command == "build"; + bool run_or_build = command == "run" || command == "build" || command == "test"; + bool test_only = command == "test"; bool strip_semicolon = command == "strip-semicolon"; - bool check_only = command == "check" || strip_semicolon; - bool check = run_or_build || check_only; + bool check_only = command == "check" || strip_semicolon; + bool check = run_or_build || check_only; print_usage_line(0, ""); print_usage_line(1, "Flags"); @@ -2085,7 +2085,7 @@ void print_show_help(String const arg0, String const &command) { print_usage_line(3, "-build-mode:shared Build as a dynamically linked library"); print_usage_line(3, "-build-mode:obj Build as an object file"); print_usage_line(3, "-build-mode:object Build as an object file"); - print_usage_line(3, "-build-mode:assembly Build as an object file"); + print_usage_line(3, "-build-mode:assembly Build as an assembly file"); print_usage_line(3, "-build-mode:assembler Build as an assembly file"); print_usage_line(3, "-build-mode:asm Build as an assembly file"); print_usage_line(3, "-build-mode:llvm-ir Build as an LLVM IR file"); @@ -2701,6 +2701,14 @@ int main(int arg_count, char const **arg_ptr) { build_context.command_kind = Command_bug_report; print_bug_report_help(); return 0; + } else if (command == "help") { + if (args.count <= 2) { + usage(args[0]); + return 1; + } else { + print_show_help(args[0], args[2]); + return 0; + } } else { usage(args[0]); return 1; From e6b91d3d7c9474ef067fafbd0f9724f6217a6d8b Mon Sep 17 00:00:00 2001 From: Hasen Judy Date: Tue, 6 Sep 2022 16:56:17 +0900 Subject: [PATCH 25/25] Remove the workaround for NSWindow initWithContentFrame Reverts #1841 Resolves #1825 --- vendor/darwin/Foundation/NSWindow.odin | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/vendor/darwin/Foundation/NSWindow.odin b/vendor/darwin/Foundation/NSWindow.odin index 330af6012..2efbe8ba3 100644 --- a/vendor/darwin/Foundation/NSWindow.odin +++ b/vendor/darwin/Foundation/NSWindow.odin @@ -103,18 +103,7 @@ Window_alloc :: proc() -> ^Window { @(objc_type=Window, objc_name="initWithContentRect") Window_initWithContentRect :: proc (self: ^Window, contentRect: Rect, styleMask: WindowStyleMask, backing: BackingStoreType, doDefer: bool) -> ^Window { - self := self - // HACK: due to a compiler bug, the generated calling code does not - // currently work for this message. Has to do with passing a struct along - // with other parameters, so we don't send the rect here. - // Omiting the rect argument here actually works, because of how the C - // calling conventions are defined. - self = msgSend(^Window, self, "initWithContentRect:styleMask:backing:defer:", styleMask, backing, doDefer) - - // apply the contentRect now, since we did not pass it to the init call - msgSend(nil, self, "setContentSize:", contentRect.size) - msgSend(nil, self, "setFrameOrigin:", contentRect.origin) - return self + return msgSend(^Window, self, "initWithContentRect:styleMask:backing:defer:", contentRect, styleMask, backing, doDefer) } @(objc_type=Window, objc_name="contentView") Window_contentView :: proc(self: ^Window) -> ^View {