Differences From Artifact [97e07274dd]:
- File
src/OFSystemInfo.m
— part of check-in
[e73d0702d0]
at
2020-11-02 01:11:34
on branch trunk
— OFSystemInfo: Do not use sysctl to get CPU vendor
The sysctl name is specific to x86 on macOS and NetBSD, so cannot be
used for other architectures and the CPU vendor on x86 can just be
obtained via cpuid. (user: js, size: 15997) [annotate] [blame] [check-ins using] [more...]
To Artifact [6b81ef8011]:
- File
src/OFSystemInfo.m
— part of check-in
[c859e2230c]
at
2020-12-12 22:31:19
on branch trunk
— Remove OF_*_ASM defines
Duplicating defines for every CPU architecture is not very useful. (user: js, size: 16061) [annotate] [blame] [check-ins using] [more...]
︙ | ︙ | |||
240 241 242 243 244 245 246 | #if defined(OF_X86_64) || defined(OF_X86) static OF_INLINE struct x86_regs OF_CONST_FUNC x86_cpuid(uint32_t eax, uint32_t ecx) { struct x86_regs regs; | | | | 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 | #if defined(OF_X86_64) || defined(OF_X86) static OF_INLINE struct x86_regs OF_CONST_FUNC x86_cpuid(uint32_t eax, uint32_t ecx) { struct x86_regs regs; # if defined(OF_X86_64) && defined(__GNUC__) __asm__ ( "cpuid" : "=a"(regs.eax), "=b"(regs.ebx), "=c"(regs.ecx), "=d"(regs.edx) : "a"(eax), "c"(ecx) ); # elif defined(OF_X86) && defined(__GNUC__) /* * This workaround is required by older GCC versions when using -fPIC, * as ebx is a special register in PIC code. Yes, GCC is indeed not * able to just push a register onto the stack before the __asm__ block * and to pop it afterwards. */ __asm__ ( |
︙ | ︙ | |||
528 529 530 531 532 533 534 | return [var stringByAppendingPathComponent: @".config"]; # endif } #endif + (OFString *)CPUVendor { | | | | 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 | return [var stringByAppendingPathComponent: @".config"]; # endif } #endif + (OFString *)CPUVendor { #if (defined(OF_X86_64) || defined(OF_X86)) && defined(__GNUC__) struct x86_regs regs = x86_cpuid(0, 0); uint32_t buffer[3]; if (regs.eax == 0) return nil; buffer[0] = regs.ebx; buffer[1] = regs.edx; buffer[2] = regs.ecx; return [OFString stringWithCString: (char *)buffer encoding: OF_STRING_ENCODING_ASCII length: 12]; #else return nil; #endif } + (OFString *)CPUModel { #if (defined(OF_X86_64) || defined(OF_X86)) && defined(__GNUC__) uint32_t buffer[12]; size_t i; i = 0; for (uint32_t eax = 0x80000002; eax <= 0x80000004; eax++) { struct x86_regs regs = x86_cpuid(eax, 0); |
︙ | ︙ |