ObjFW  Check-in [406dfede9e]

Overview
Comment:OFSystemInfo: Work around GCC being stupid
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 406dfede9ebc449d121a5abccacfbf870cfb759ef3ebf0e9fde923dd08e0949c
User & Date: js on 2015-04-11 12:59:19
Other Links: manifest | tags
Context
2015-04-11
13:46
configure.ac: Add defines necessary for Solaris check-in: 42af51eab4 user: js tags: trunk
12:59
OFSystemInfo: Work around GCC being stupid check-in: 406dfede9e user: js tags: trunk
12:56
OFMapTable.m: Fix a missing include check-in: dc43cd0d1b user: js tags: trunk
Changes

Modified src/OFSystemInfo.m from [6148f51021] to [2207aef52d].

55
56
57
58
59
60
61
62
63
64
65
66















67
68
69
70
71
72
73
static size_t numberOfCPUs;

static OF_INLINE struct cpuid_regs OF_CONST_FUNC
cpuid(uint32_t eax, uint32_t ecx)
{
	struct cpuid_regs regs;

#if defined(OF_X86_64_ASM) || defined(OF_X86_ASM)
	__asm__(
	    "cpuid"
	    : "=a"(regs.eax), "=b"(regs.ebx), "=c"(regs.ecx), "=d"(regs.edx)
	    : "a"(eax), "c"(ecx)















	);
#else
	regs.eax = regs.ebx = regs.ecx = regs.edx = 0;
#endif

	return regs;
}







|




>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
static size_t numberOfCPUs;

static OF_INLINE struct cpuid_regs OF_CONST_FUNC
cpuid(uint32_t eax, uint32_t ecx)
{
	struct cpuid_regs regs;

#if defined(OF_X86_64_ASM)
	__asm__(
	    "cpuid"
	    : "=a"(regs.eax), "=b"(regs.ebx), "=c"(regs.ecx), "=d"(regs.edx)
	    : "a"(eax), "c"(ecx)
	);
#elif defined(OF_X86_ASM)
	/*
	 * This workaround is required by GCC 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__(
	    "pushl	%%ebx\n\t"
	    "cpuid\n\t"
	    "movl	%%ebx, %1\n\t"
	    "popl	%%ebx"
	    : "=a"(regs.eax), "=r"(regs.ebx), "=c"(regs.ecx), "=d"(regs.edx)
	    : "a"(eax), "c"(ecx)
	);
#else
	regs.eax = regs.ebx = regs.ecx = regs.edx = 0;
#endif

	return regs;
}