ObjFW  Check-in [2fc1016631]

Overview
Comment:OFSystemInfo: Work around GCC picking ebx for "=r"

Newer GCC versions on Windows use ebx for "=r", which results in a
movl %ebx, %ebx. %ebx is then destroyed by the popl %ebx that follows.
To work around this, force the use of %edi instead ("=D").

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 2fc10166319846f8cba5ee7a6fc5da6d7631c76ab3174ccae927ffd30ad14a8c
User & Date: js on 2018-12-02 20:11:04
Other Links: manifest | tags
Context
2018-12-07
01:33
OFStream: Use a delegate for async operations check-in: d16ad96cbd user: js tags: trunk
2018-12-02
20:11
OFSystemInfo: Work around GCC picking ebx for "=r" check-in: 2fc1016631 user: js tags: trunk
2018-12-01
21:32
ofarc: Fix a typo check-in: e62556c4a5 user: js tags: trunk
Changes

Modified src/OFSystemInfo.m from [b0d88583f9] to [f32302ffd0].

244
245
246
247
248
249
250
251
252
253
254




255
256
257

258
259
260
261


262
263
264
265
266
267
268
244
245
246
247
248
249
250




251
252
253
254
255
256

257
258



259
260
261
262
263
264
265
266
267







-
-
-
-
+
+
+
+


-
+

-
-
-
+
+







	__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.
	 * 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__ (
	    "pushl	%%ebx\n\t"
	    "xchgl	%%ebx, %%edi\n\t"
	    "cpuid\n\t"
	    "movl	%%ebx, %1\n\t"
	    "popl	%%ebx"
	    : "=a"(regs.eax), "=r"(regs.ebx), "=c"(regs.ecx), "=d"(regs.edx)
	    "xchgl	%%edi, %%ebx"
	    : "=a"(regs.eax), "=D"(regs.ebx), "=c"(regs.ecx), "=d"(regs.edx)
	    : "a"(eax), "c"(ecx)
	);
# else
	memset(&regs, 0, sizeof(regs));
# endif

	return regs;