[Glibc-bsd-commits] r5963 - in trunk/glibc-ports-2.23/kfreebsd: i386 x86_64
aurel32 at alioth.debian.org
aurel32 at alioth.debian.org
Tue Mar 22 10:35:20 UTC 2016
Author: aurel32
Date: 2016-03-22 10:35:19 +0000 (Tue, 22 Mar 2016)
New Revision: 5963
Modified:
trunk/glibc-ports-2.23/kfreebsd/i386/dl-machine.h
trunk/glibc-ports-2.23/kfreebsd/x86_64/dl-machine.h
Log:
dl-machine.h: call parent dl_platform_init
Call the dl_platform_init from dl_platform_kfreebsd_x86_64_init and
dl_platform_kfreebsd_i386_init. Use the values from dl_x86_cpu_features
instead of calling cpuid ourselves.
Modified: trunk/glibc-ports-2.23/kfreebsd/i386/dl-machine.h
===================================================================
--- trunk/glibc-ports-2.23/kfreebsd/i386/dl-machine.h 2016-03-20 23:37:07 UTC (rev 5962)
+++ trunk/glibc-ports-2.23/kfreebsd/i386/dl-machine.h 2016-03-22 10:35:19 UTC (rev 5963)
@@ -49,97 +49,32 @@
#include_next <dl-machine.h>
-#undef DL_PLATFORM_INIT
-#define DL_PLATFORM_INIT dl_platform_kfreebsd_i386_init ()
-
#ifndef _DL_MACHINE_KFREEBSD
#define _DL_MACHINE_KFREEBSD
-#define X86_EFLAGS_AC 0x00040000 /* Alignment Check */
-#define X86_EFLAGS_ID 0x00200000 /* CPUID detection flag */
-
-static inline int try_flip_flags(int val)
-{
- int ret;
- __asm__(
- "pushfl\n\t"
- "pushfl\n\t"
- "popl %%ecx\n\t"
- "xorl %%ecx,%%eax\n\t"
- "pushl %%eax\n\t"
- "popfl\n\t"
- "pushfl\n\t"
- "popl %%eax\n\t"
- "xorl %%ecx,%%eax\n\t"
- "popfl\n\t"
- : "=a" (ret)
- : "0" (val)
- : "cx"
- );
- return ret;
-}
-
-static inline void cpuid(int op, int *eax, int *edx)
-{
- __asm__(
- "push %%ebx\n\t"
- "cpuid\n\t"
- "pop %%ebx\n\t"
- : "=a" (*eax),
- "=d" (*edx)
- : "0" (op)
- : "cx"
- );
-}
-
static inline void __attribute__ ((unused))
dl_platform_kfreebsd_i386_init (void)
{
+ /* This calls cpuid and and fills dl_x86_cpu_features */
+ DL_PLATFORM_INIT;
+
/* we don't have reasonable AT_PLATFORM from kernel
try to use cpuid to get one, also guess AT_HWCAP */
-
- int val, hwcap;
-
- val = try_flip_flags(X86_EFLAGS_AC | X86_EFLAGS_ID);
-
- if (!(val & X86_EFLAGS_AC))
+ GLRO(dl_hwcap) = GLRO(dl_x86_cpu_features).cpuid[COMMON_CPUID_INDEX_1].edx;
+ switch (GLRO(dl_hwcap) & 0xf00)
{
- /* 386 */
- GLRO(dl_platform) = GLRO(dl_x86_platforms)[0];
- GLRO(dl_hwcap) = 0;
- }
- else if (!(val & X86_EFLAGS_ID))
- {
- /* 486 */
+ case 0x400: /* 486 */
GLRO(dl_platform) = GLRO(dl_x86_platforms)[1];
- GLRO(dl_hwcap) = 0;
+ break;
+ case 0x500: /* 586 */
+ GLRO(dl_platform) = GLRO(dl_x86_platforms)[2];
+ break;
+ default: /* 686 */
+ GLRO(dl_platform) = GLRO(dl_x86_platforms)[3];
}
- else
- {
- cpuid(0, &val, &hwcap);
- if (val == 0)
- {
- /* 486 */
- GLRO(dl_platform) = GLRO(dl_x86_platforms)[1];
- GLRO(dl_hwcap) = 0;
- }
- else
- {
- cpuid(1, &val, &hwcap);
- GLRO(dl_hwcap) = hwcap;
- switch (val & 0xf00)
- {
- case 0x400: /* 486 */
- GLRO(dl_platform) = GLRO(dl_x86_platforms)[1];
- break;
- case 0x500: /* 586 */
- GLRO(dl_platform) = GLRO(dl_x86_platforms)[2];
- break;
- default: /* 686 */
- GLRO(dl_platform) = GLRO(dl_x86_platforms)[3];
- }
- }
- }
}
+#undef DL_PLATFORM_INIT
+#define DL_PLATFORM_INIT dl_platform_kfreebsd_i386_init ()
+
#endif
Modified: trunk/glibc-ports-2.23/kfreebsd/x86_64/dl-machine.h
===================================================================
--- trunk/glibc-ports-2.23/kfreebsd/x86_64/dl-machine.h 2016-03-20 23:37:07 UTC (rev 5962)
+++ trunk/glibc-ports-2.23/kfreebsd/x86_64/dl-machine.h 2016-03-22 10:35:19 UTC (rev 5963)
@@ -98,36 +98,22 @@
#endif
-#undef DL_PLATFORM_INIT
-#define DL_PLATFORM_INIT dl_platform_kfreebsd_x86_64_init ()
-
#ifndef _DL_MACHINE_KFREEBSD
#define _DL_MACHINE_KFREEBSD
-static inline void cpuid(long op, long *rax, long *rdx)
-{
- __asm__(
- "push %%rbx\n\t"
- "cpuid\n\t"
- "pop %%rbx\n\t"
- : "=a" (*rax),
- "=d" (*rdx)
- : "0" (op)
- : "rcx"
- );
-}
-
static inline void __attribute__ ((unused))
dl_platform_kfreebsd_x86_64_init (void)
{
+ /* This calls cpuid and and fills dl_x86_cpu_features */
+ DL_PLATFORM_INIT;
+
/* we don't have reasonable AT_PLATFORM from kernel
use cpuid to guess AT_HWCAP */
-
- long val, hwcap;
-
- cpuid(1, &val, &hwcap);
- GLRO(dl_hwcap) = hwcap;
+ GLRO(dl_hwcap) = GLRO(dl_x86_cpu_features).cpuid[COMMON_CPUID_INDEX_1].edx;
GLRO(dl_platform) = ELF_MACHINE_NAME;
}
+#undef DL_PLATFORM_INIT
+#define DL_PLATFORM_INIT dl_platform_kfreebsd_x86_64_init ()
+
#endif
More information about the Glibc-bsd-commits
mailing list