ObjFW  Check-in [acb2130974]

Overview
Comment:OFSystemInfo: Use cpuid to get CPU model
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: acb2130974981c1b37832d7b6611768244b837b44153b3ac2720c9c6c5c0cdcb
User & Date: js on 2020-11-02 00:53:11
Other Links: manifest | tags
Context
2020-11-02
00:56
OFSystemInfo: Minor cleanup check-in: 9903dedecb user: js tags: trunk
00:53
OFSystemInfo: Use cpuid to get CPU model check-in: acb2130974 user: js tags: trunk
2020-11-01
13:08
Clean up .travis.yml by moving out scripts check-in: 74857232b0 user: js tags: trunk
Changes

Modified src/OFSystemInfo.m from [3f56016e9e] to [3a242f30a6].

549
550
551
552
553
554
555
















556
557
558
559
560
561
562
563
#else
	return nil;
#endif
}

+ (OFString *)CPUModel
{
















#if defined(OF_MACOS) || defined(OF_NETBSD)
	char value[256];
	size_t length = sizeof(value);

# if defined(OF_MACOS)
	if (sysctlbyname("machdep.cpu.brand_string",
# elif defined(OF_NETBSD)
	if (sysctlbyname("machdep.cpu_brand",







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|







549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
#else
	return nil;
#endif
}

+ (OFString *)CPUModel
{
#if defined(OF_X86_64_ASM) || defined(OF_X86_ASM)
	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);

		buffer[i++] = regs.eax;
		buffer[i++] = regs.ebx;
		buffer[i++] = regs.ecx;
		buffer[i++] = regs.edx;
	}

	return [OFString stringWithCString: (char *)buffer
				  encoding: OF_STRING_ENCODING_ASCII];
#elif defined(OF_MACOS) || defined(OF_NETBSD)
	char value[256];
	size_t length = sizeof(value);

# if defined(OF_MACOS)
	if (sysctlbyname("machdep.cpu.brand_string",
# elif defined(OF_NETBSD)
	if (sysctlbyname("machdep.cpu_brand",