[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[commits] r8750 - in /trunk/libc: ./ debug/ malloc/ nptl/ sysdeps/i386/ sysdeps/i386/i686/ sysdeps/i386/i686/multiarch/ sysdeps/ia64/ ...
- To: commits@xxxxxxxxxx
- Subject: [commits] r8750 - in /trunk/libc: ./ debug/ malloc/ nptl/ sysdeps/i386/ sysdeps/i386/i686/ sysdeps/i386/i686/multiarch/ sysdeps/ia64/ ...
- From: joseph@xxxxxxxxxx
- Date: Mon, 03 Aug 2009 13:36:46 -0000
Author: joseph
Date: Mon Aug 3 06:36:46 2009
New Revision: 8750
Log:
Merge changes between r8731 and r8749 from /fsf/trunk.
Added:
trunk/libc/debug/tst-longjmp_chk2.c
- copied unchanged from r8749, fsf/trunk/libc/debug/tst-longjmp_chk2.c
trunk/libc/sysdeps/i386/i686/cacheinfo.c
- copied unchanged from r8749, fsf/trunk/libc/sysdeps/i386/i686/cacheinfo.c
trunk/libc/sysdeps/i386/i686/multiarch/
- copied from r8749, fsf/trunk/libc/sysdeps/i386/i686/multiarch/
trunk/libc/sysdeps/unix/sysv/linux/i386/____longjmp_chk.S
- copied unchanged from r8749, fsf/trunk/libc/sysdeps/unix/sysv/linux/i386/____longjmp_chk.S
trunk/libc/sysdeps/unix/sysv/linux/i386/i686/
- copied from r8749, fsf/trunk/libc/sysdeps/unix/sysv/linux/i386/i686/
trunk/libc/sysdeps/unix/sysv/linux/x86_64/____longjmp_chk.S
- copied unchanged from r8749, fsf/trunk/libc/sysdeps/unix/sysv/linux/x86_64/____longjmp_chk.S
Modified:
trunk/libc/ChangeLog
trunk/libc/debug/Makefile
trunk/libc/malloc/Makefile
trunk/libc/nptl/ChangeLog
trunk/libc/nptl/descr.h
trunk/libc/sysdeps/i386/____longjmp_chk.S
trunk/libc/sysdeps/i386/__longjmp.S
trunk/libc/sysdeps/i386/configure
trunk/libc/sysdeps/i386/configure.in
trunk/libc/sysdeps/i386/i686/Makefile
trunk/libc/sysdeps/ia64/backtrace.c
trunk/libc/sysdeps/x86_64/____longjmp_chk.S
trunk/libc/sysdeps/x86_64/__longjmp.S
trunk/libc/sysdeps/x86_64/cacheinfo.c
trunk/libc/sysdeps/x86_64/multiarch/init-arch.c
trunk/libc/sysdeps/x86_64/multiarch/init-arch.h
trunk/libc/sysdeps/x86_64/multiarch/sched_cpucount.c
Modified: trunk/libc/ChangeLog
==============================================================================
--- trunk/libc/ChangeLog (original)
+++ trunk/libc/ChangeLog Mon Aug 3 06:36:46 2009
@@ -1,3 +1,74 @@
+2009-08-02 Ulrich Drepper <drepper@xxxxxxxxxx>
+
+ * sysdeps/i386/configure.in: Add test for <cpuid.h>.
+
+2009-07-31 Ulrich Drepper <drepper@xxxxxxxxxx>
+
+ * sysdeps/unix/sysv/linux/x86_64/____longjmp_chk.S (longjmp_msg): Yet
+ another rewrite. Much smaller and faster.
+ * sysdeps/unix/sysv/linux/i386/____longjmp_chk.S: Likewise.
+
+ * sysdeps/unix/sysv/linux/x86_64/____longjmp_chk.S (longjmp_msg): Get
+ ss_flags from the correct location.
+
+2009-07-31 H.J. Lu <hongjiu.lu@xxxxxxxxx>
+
+ * sysdeps/i386/i686/Makefile (sysdep_routines): Add cacheinfo.
+ * sysdeps/i386/i686/cacheinfo.c: New file.
+ * sysdeps/i386/i686/multiarch/Makefile: New file.
+ * sysdeps/i386/i686/multiarch/ifunc-defines.sym: New file.
+ * sysdeps/i386/i686/multiarch/init-arch.c: New file.
+ * sysdeps/i386/i686/multiarch/init-arch.h: New file.
+ * sysdeps/i386/i686/multiarch/sched_cpucount.c: New file.
+ * sysdeps/unix/sysv/linux/i386/i686/sysconf.c: New file.
+ * sysdeps/x86_64/cacheinfo.c: Include <cpuid.h>.
+ (__cpuid_count): New. Provide the default.
+ (__x86_64_prefetchw): Define only if DISABLE_PREFETCHW is not defined.
+ (__x86_64_preferred_memory_instruction): Define only if
+ DISABLE_PREFERRED_MEMORY_INSTRUCTION is not defined.
+ (intel_check_word): Use __cpuid.
+ (handle_intel): Likewise.
+ (handle_amd): Likewise.
+ (__cache_sysconf): Likewise.
+ (init_cacheinfo): Updated. Use __cpuid and __cpuid_count.
+ (__cache_sysconf): Likewise.
+ (init_cacheinfo): Updated. Use __cpuid and __cpuid_count.
+ * sysdeps/x86_64/multiarch/init-arch.c: Include <cpuid.h>.
+ (get_common_indeces): Use __cpuid.
+ (__init_cpu_features): Likewise. Disable SSSE3 on Atom only
+ if ENABLE_SSSE3_ON_ATOM is not defined.
+ * sysdeps/x86_64/multiarch/init-arch.h (HAS_SSE2): Define.
+ * sysdeps/x86_64/multiarch/sched_cpucount.c (POPCNT): Use
+ popcnt instead of popcntq.
+
+2009-07-31 Jakub Jelinek <jakub@xxxxxxxxxx>
+
+ * malloc/Makefile (CFLAGS-obstack.c): Add $(uses-callbacks).
+
+2009-07-30 Ulrich Drepper <drepper@xxxxxxxxxx>
+
+ * sysdeps/unix/sysv/linux/i386/____longjmp_chk.S: New file.
+ * sysdeps/i386/____longjmp_chk.S: Remove all code. This is now a file
+ which always causes a compile error.
+
+ * sysdeps/i386/__longjmp.S: Remove bound-checking pointer support.
+
+ * sysdeps/unix/sysv/linux/x86_64/____longjmp_chk.S: New file. Content
+ comes from...
+ * sysdeps/x86_64/____longjmp_chk.S: ...here. This is now a file
+ which always causes a compile error.
+
+ * debug/Makefile (tests): Add tst-longjmp_chk2.
+ * debug/tst-longjmp_chk2.c: New file.
+
+ * sysdeps/x86_64/__longjmp.S: Remove CHECK_RSP handling. Fix CFI.
+ Remove incorrect use of BP_SYM.
+ * sysdeps/x86_64/____longjmp_chk.S: Rewrite. Complete implementation
+ here now since it is more complex than just a simple check.
+
+ * sysdeps/ia64/backtrace.c (backtrace_helper): Stop backtrace when
+ we make no more progress.
+
2009-07-29 Ulrich Drepper <drepper@xxxxxxxxxx>
* math/s_fma.c: Don't define alias if __fma is a macro.
Modified: trunk/libc/debug/Makefile
==============================================================================
--- trunk/libc/debug/Makefile (original)
+++ trunk/libc/debug/Makefile Mon Aug 3 06:36:46 2009
@@ -92,6 +92,8 @@
CFLAGS-recvfrom_chk.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-tst-longjmp_chk.c = -fexceptions -fasynchronous-unwind-tables \
-D_FORTIFY_SOURCE=1
+CFLAGS-tst-longjmp_chk2.c = -fexceptions -fasynchronous-unwind-tables \
+ -D_FORTIFY_SOURCE=1
# We know these tests have problems with format strings, this is what
# we are testing. Disable that warning.
@@ -129,7 +131,7 @@
# backtrace_symbols only works if we link with -rdynamic.
LDFLAGS-tst-backtrace2 = -rdynamic
-tests = tst-longjmp_chk test-strcpy_chk test-stpcpy_chk
+tests = tst-longjmp_chk test-strcpy_chk test-stpcpy_chk tst-longjmp_chk2
tests-$(OPTION_EGLIBC_LOCALE_CODE) \
+= tst-chk1 tst-chk2 tst-chk3 tst-lfschk1 tst-lfschk2 tst-lfschk3
tests-$(OPTION_EGLIBC_BACKTRACE) += backtrace-tst tst-backtrace2
Modified: trunk/libc/malloc/Makefile
==============================================================================
--- trunk/libc/malloc/Makefile (original)
+++ trunk/libc/malloc/Makefile Mon Aug 3 06:36:46 2009
@@ -104,6 +104,7 @@
include ../Rules
CFLAGS-mcheck-init.c = $(PIC-ccflag)
+CFLAGS-obstack.c = $(uses-callbacks)
$(objpfx)libmcheck.a: $(objpfx)mcheck-init.o
-rm -f $@
Modified: trunk/libc/nptl/ChangeLog
==============================================================================
--- trunk/libc/nptl/ChangeLog (original)
+++ trunk/libc/nptl/ChangeLog Mon Aug 3 06:36:46 2009
@@ -1,3 +1,7 @@
+2009-07-31 Ulrich Drepper <drepper@xxxxxxxxxx>
+
+ * descr.h: Better definition of *_BITMASK macros for cancellation.
+
2009-07-29 Ulrich Drepper <drepper@xxxxxxxxxx>
* sysdeps/x86_64/tls.h (TLS_TCB_ALIGN): Define explicitly to 32.
Modified: trunk/libc/nptl/descr.h
==============================================================================
--- trunk/libc/nptl/descr.h (original)
+++ trunk/libc/nptl/descr.h Mon Aug 3 06:36:46 2009
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002-2006, 2007, 2008 Free Software Foundation, Inc.
+/* Copyright (C) 2002-2006, 2007, 2008, 2009 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@xxxxxxxxxx>, 2002.
@@ -243,25 +243,25 @@
int cancelhandling;
/* Bit set if cancellation is disabled. */
#define CANCELSTATE_BIT 0
-#define CANCELSTATE_BITMASK 0x01
+#define CANCELSTATE_BITMASK (0x01 << CANCELSTATE_BIT)
/* Bit set if asynchronous cancellation mode is selected. */
#define CANCELTYPE_BIT 1
-#define CANCELTYPE_BITMASK 0x02
+#define CANCELTYPE_BITMASK (0x01 << CANCELTYPE_BIT)
/* Bit set if canceling has been initiated. */
#define CANCELING_BIT 2
-#define CANCELING_BITMASK 0x04
+#define CANCELING_BITMASK (0x01 << CANCELING_BIT)
/* Bit set if canceled. */
#define CANCELED_BIT 3
-#define CANCELED_BITMASK 0x08
+#define CANCELED_BITMASK (0x01 << CANCELED_BIT)
/* Bit set if thread is exiting. */
#define EXITING_BIT 4
-#define EXITING_BITMASK 0x10
+#define EXITING_BITMASK (0x01 << EXITING_BIT)
/* Bit set if thread terminated and TCB is freed. */
#define TERMINATED_BIT 5
-#define TERMINATED_BITMASK 0x20
+#define TERMINATED_BITMASK (0x01 << TERMINATED_BIT)
/* Bit set if thread is supposed to change XID. */
#define SETXID_BIT 6
-#define SETXID_BITMASK 0x40
+#define SETXID_BITMASK (0x01 << SETXID_BIT)
/* Mask for the rest. Helps the compiler to optimize. */
#define CANCEL_RESTMASK 0xffffff80
Modified: trunk/libc/sysdeps/i386/____longjmp_chk.S
==============================================================================
--- trunk/libc/sysdeps/i386/____longjmp_chk.S (original)
+++ trunk/libc/sysdeps/i386/____longjmp_chk.S Mon Aug 3 06:36:46 2009
@@ -1,45 +1,1 @@
-/* Copyright (C) 2001,2004,2005,2006,2009 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
-
- .section .rodata.str1.1,"aMS",@progbits,1
- .type longjmp_msg,@object
-longjmp_msg:
- .string "longjmp causes uninitialized stack frame"
- .size longjmp_msg, .-longjmp_msg
-
-
-#define __longjmp ____longjmp_chk
-
-#ifdef PIC
-# define CALL_FAIL movl %ebx, %ecx; \
- cfi_register(%ebx,%ecx); \
- LOAD_PIC_REG (bx); \
- leal longjmp_msg@GOTOFF(%ebx), %eax; \
- call __GI___fortify_fail@PLT
-#else
-# define CALL_FAIL movl $longjmp_msg, %eax; \
- call __fortify_fail
-#endif
-
-#define CHECK_ESP(reg) \
- cmpl reg, %esp; \
- jbe .Lok; \
- CALL_FAIL; \
-.Lok:
-
-#include "__longjmp.S"
+#error "OS-specific version needed"
Modified: trunk/libc/sysdeps/i386/__longjmp.S
==============================================================================
--- trunk/libc/sysdeps/i386/__longjmp.S (original)
+++ trunk/libc/sysdeps/i386/__longjmp.S Mon Aug 3 06:36:46 2009
@@ -21,20 +21,11 @@
#include <sysdep.h>
#include <jmpbuf-offsets.h>
#include <asm-syntax.h>
-#include <bp-sym.h>
-#include <bp-asm.h>
-
-#define PARMS LINKAGE /* no space for saved regs */
-#define JBUF PARMS
-#define VAL JBUF+PTR_SIZE
.text
-ENTRY (BP_SYM (__longjmp))
- ENTER
-
+ENTRY (__longjmp)
#ifdef PTR_DEMANGLE
- movl JBUF(%esp), %eax /* User's jmp_buf in %eax. */
- CHECK_BOUNDS_BOTH_WIDE (%eax, JBUF(%esp), $JB_SIZE)
+ movl 4(%esp), %eax /* User's jmp_buf in %eax. */
/* Save the return address now. */
movl (JB_PC*4)(%eax), %edx
@@ -42,9 +33,6 @@
movl (JB_SP*4)(%eax), %ecx
PTR_DEMANGLE (%edx)
PTR_DEMANGLE (%ecx)
-# ifdef CHECK_ESP
- CHECK_ESP (%ecx)
-# endif
cfi_def_cfa(%eax, 0)
cfi_register(%eip, %edx)
cfi_register(%esp, %ecx)
@@ -62,18 +50,11 @@
cfi_restore(%edi)
cfi_restore(%ebp)
- movl VAL(%esp), %eax /* Second argument is return value. */
+ movl 8(%esp), %eax /* Second argument is return value. */
movl %ecx, %esp
#else
- movl JBUF(%esp), %ecx /* User's jmp_buf in %ecx. */
- CHECK_BOUNDS_BOTH_WIDE (%ecx, JBUF(%esp), $JB_SIZE)
-
-# ifdef CHECK_ESP
- movl (JB_SP*4)(%ecx), %eax
- CHECK_ESP (%eax)
-# endif
-
- movl VAL(%esp), %eax /* Second argument is return value. */
+ movl 4(%esp), %ecx /* User's jmp_buf in %ecx. */
+ movl 8(%esp), %eax /* Second argument is return value. */
/* Save the return address now. */
movl (JB_PC*4)(%ecx), %edx
/* Restore registers. */
@@ -85,4 +66,4 @@
#endif
/* Jump to saved PC. */
jmp *%edx
-END (BP_SYM (__longjmp))
+END (__longjmp)
Modified: trunk/libc/sysdeps/i386/configure
==============================================================================
--- trunk/libc/sysdeps/i386/configure (original)
+++ trunk/libc/sysdeps/i386/configure Mon Aug 3 06:36:46 2009
@@ -32,6 +32,51 @@
# This file is generated from configure.in by Autoconf. DO NOT EDIT!
# Local configure fragment for sysdeps/i386.
+
+
+{ $as_echo "$as_me:$LINENO: checking if gcc provides <cpuid.h>" >&5
+$as_echo_n "checking if gcc provides <cpuid.h>... " >&6; }
+if test "${libc_cv_gcc_cpuid+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+#include <cpuid.h>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ libc_cv_gcc_cpuid=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ libc_cv_gcc_cpuid=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:$LINENO: result: $libc_cv_gcc_cpuid" >&5
+$as_echo "$libc_cv_gcc_cpuid" >&6; }
+if test $libc_cv_gcc_cpuid != yes; then
+ { { $as_echo "$as_me:$LINENO: error: gcc must provide the <cpuid.h> header" >&5
+$as_echo "$as_me: error: gcc must provide the <cpuid.h> header" >&2;}
+ { (exit 1); exit 1; }; }
+fi
{ $as_echo "$as_me:$LINENO: checking if -g produces usable source locations for assembler-with-cpp" >&5
$as_echo_n "checking if -g produces usable source locations for assembler-with-cpp... " >&6; }
Modified: trunk/libc/sysdeps/i386/configure.in
==============================================================================
--- trunk/libc/sysdeps/i386/configure.in (original)
+++ trunk/libc/sysdeps/i386/configure.in Mon Aug 3 06:36:46 2009
@@ -1,5 +1,12 @@
GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
# Local configure fragment for sysdeps/i386.
+
+AC_CACHE_CHECK([if gcc provides <cpuid.h>], libc_cv_gcc_cpuid, [dnl
+AC_COMPILE_IFELSE([#include <cpuid.h>], libc_cv_gcc_cpuid=yes,
+ libc_cv_gcc_cpuid=no)])
+if test $libc_cv_gcc_cpuid != yes; then
+ AC_MSG_ERROR([gcc must provide the <cpuid.h> header])
+fi
AC_CACHE_CHECK(if -g produces usable source locations for assembler-with-cpp,
libc_cv_cpp_asm_debuginfo, [dnl
Modified: trunk/libc/sysdeps/i386/i686/Makefile
==============================================================================
--- trunk/libc/sysdeps/i386/i686/Makefile (original)
+++ trunk/libc/sysdeps/i386/i686/Makefile Mon Aug 3 06:36:46 2009
@@ -5,3 +5,7 @@
# So that we can test __m128's alignment
stack-align-test-flags += -msse
+
+ifeq ($(subdir),string)
+sysdep_routines += cacheinfo
+endif
Modified: trunk/libc/sysdeps/ia64/backtrace.c
==============================================================================
--- trunk/libc/sysdeps/ia64/backtrace.c (original)
+++ trunk/libc/sysdeps/ia64/backtrace.c Mon Aug 3 06:36:46 2009
@@ -1,5 +1,5 @@
/* Return backtrace of current program state.
- Copyright (C) 2003, 2004, 2005, 2007 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2004, 2005, 2007, 2009 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Jakub Jelinek <jakub@xxxxxxxxxx>, 2003.
@@ -61,7 +61,13 @@
/* We are first called with address in the __backtrace function.
Skip it. */
if (arg->cnt != -1)
- arg->array[arg->cnt] = (void *) unwind_getip (ctx);
+ {
+ arg->array[arg->cnt] = (void *) unwind_getip (ctx);
+
+ /* Check whether we make any progress. */
+ if (arg->cnt > 0 && arg->array[arg->cnt - 1] == arg->array[arg->cnt])
+ return _URC_END_OF_STACK;
+ }
if (++arg->cnt == arg->size)
return _URC_END_OF_STACK;
return _URC_NO_REASON;
Modified: trunk/libc/sysdeps/x86_64/____longjmp_chk.S
==============================================================================
--- trunk/libc/sysdeps/x86_64/____longjmp_chk.S (original)
+++ trunk/libc/sysdeps/x86_64/____longjmp_chk.S Mon Aug 3 06:36:46 2009
@@ -1,42 +1,1 @@
-/* Copyright (C) 2001,2004,2005,2006,2009 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
-
- .section .rodata.str1.1,"aMS",@progbits,1
- .type longjmp_msg,@object
-longjmp_msg:
- .string "longjmp causes uninitialized stack frame"
- .size longjmp_msg, .-longjmp_msg
-
-
-#define __longjmp ____longjmp_chk
-
-#ifdef PIC
-# define CALL_FAIL leaq longjmp_msg(%rip), %rdi; \
- call __GI___fortify_fail
-#else
-# define CALL_FAIL movq $longjmp_msg, %rdi; \
- call __fortify_fail
-#endif
-
-#define CHECK_RSP(reg) \
- cmpq reg, %rsp; \
- jbe .Lok; \
- CALL_FAIL; \
-.Lok:
-
-#include "__longjmp.S"
+#error "OS-specific version needed"
Modified: trunk/libc/sysdeps/x86_64/__longjmp.S
==============================================================================
--- trunk/libc/sysdeps/x86_64/__longjmp.S (original)
+++ trunk/libc/sysdeps/x86_64/__longjmp.S Mon Aug 3 06:36:46 2009
@@ -34,16 +34,12 @@
PTR_DEMANGLE (%r9)
PTR_DEMANGLE (%rdx)
#endif
-#ifdef CHECK_RSP
- CHECK_RSP (%r8)
-#endif
/* We add unwind information for the target here. */
cfi_def_cfa(%rdi, 0)
cfi_register(%rsp,%r8)
cfi_register(%rbp,%r9)
cfi_register(%rip,%rdx)
cfi_offset(%rbx,JB_RBX*8)
- cfi_offset(%rbp,JB_RBP*8)
cfi_offset(%r12,JB_R12*8)
cfi_offset(%r13,JB_R13*8)
cfi_offset(%r14,JB_R14*8)
@@ -58,4 +54,4 @@
movq %r8,%rsp
movq %r9,%rbp
jmpq *%rdx
-END (BP_SYM (__longjmp))
+END (__longjmp)
Modified: trunk/libc/sysdeps/x86_64/cacheinfo.c
==============================================================================
--- trunk/libc/sysdeps/x86_64/cacheinfo.c (original)
+++ trunk/libc/sysdeps/x86_64/cacheinfo.c Mon Aug 3 06:36:46 2009
@@ -22,6 +22,26 @@
#include <stdbool.h>
#include <stdlib.h>
#include <unistd.h>
+#include <cpuid.h>
+
+#ifndef __cpuid_count
+/* FIXME: Provide __cpuid_count if it isn't defined. Copied from gcc
+ 4.4.0. Remove this if gcc 4.4 is the minimum requirement. */
+# if defined(__i386__) && defined(__PIC__)
+/* %ebx may be the PIC register. */
+# define __cpuid_count(level, count, a, b, c, d) \
+ __asm__ ("xchg{l}\t{%%}ebx, %1\n\t" \
+ "cpuid\n\t" \
+ "xchg{l}\t{%%}ebx, %1\n\t" \
+ : "=a" (a), "=r" (b), "=c" (c), "=d" (d) \
+ : "0" (level), "2" (count))
+# else
+# define __cpuid_count(level, count, a, b, c, d) \
+ __asm__ ("cpuid\n\t" \
+ : "=a" (a), "=b" (b), "=c" (c), "=d" (d) \
+ : "0" (level), "2" (count))
+# endif
+#endif
#ifdef USE_MULTIARCH
# include "multiarch/init-arch.h"
@@ -176,9 +196,7 @@
unsigned int ebx;
unsigned int ecx;
unsigned int edx;
- asm volatile ("cpuid"
- : "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx)
- : "0" (1));
+ __cpuid (1, eax, ebx, ecx, edx);
family = ((eax >> 20) & 0xff) + ((eax >> 8) & 0xf);
model = (((eax >>16) & 0xf) << 4) + ((eax >> 4) & 0xf);
@@ -250,9 +268,7 @@
unsigned int ebx;
unsigned int ecx;
unsigned int edx;
- asm volatile ("cpuid"
- : "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx)
- : "0" (2));
+ __cpuid (2, eax, ebx, ecx, edx);
/* The low byte of EAX in the first round contain the number of
rounds we have to make. At least one, the one we are already
@@ -296,9 +312,7 @@
unsigned int ebx;
unsigned int ecx;
unsigned int edx;
- asm volatile ("cpuid"
- : "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx)
- : "0" (0x80000000));
+ __cpuid (0x80000000, eax, ebx, ecx, edx);
/* No level 4 cache (yet). */
if (name > _SC_LEVEL3_CACHE_LINESIZE)
@@ -308,9 +322,7 @@
if (eax < fn)
return 0;
- asm volatile ("cpuid"
- : "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx)
- : "0" (fn));
+ __cpuid (fn, eax, ebx, ecx, edx);
if (name < _SC_LEVEL1_DCACHE_SIZE)
{
@@ -424,9 +436,7 @@
unsigned int ebx;
unsigned int ecx;
unsigned int edx;
- asm volatile ("cpuid"
- : "=a" (max_cpuid), "=b" (ebx), "=c" (ecx), "=d" (edx)
- : "0" (0));
+ __cpuid (0, max_cpuid, ebx, ecx, edx);
#endif
if (is_intel)
@@ -449,9 +459,13 @@
L2 or L3 size. */
long int __x86_64_shared_cache_size_half attribute_hidden = 1024 * 1024 / 2;
long int __x86_64_shared_cache_size attribute_hidden = 1024 * 1024;
+
+#ifndef DISABLE_PREFETCHW
/* PREFETCHW support flag for use in memory and string routines. */
int __x86_64_prefetchw attribute_hidden;
-
+#endif
+
+#ifndef DISABLE_PREFERRED_MEMORY_INSTRUCTION
/* Instructions preferred for memory and string routines.
0: Regular instructions
@@ -461,6 +475,7 @@
*/
int __x86_64_preferred_memory_instruction attribute_hidden;
+#endif
static void
@@ -483,9 +498,7 @@
__init_cpu_features ();
#else
int max_cpuid;
- asm volatile ("cpuid"
- : "=a" (max_cpuid), "=b" (ebx), "=c" (ecx), "=d" (edx)
- : "0" (0));
+ __cpuid (0, max_cpuid, ebx, ecx, edx);
#endif
if (is_intel)
@@ -509,17 +522,17 @@
ecx = __cpu_features.cpuid[COMMON_CPUID_INDEX_1].ecx;
edx = __cpu_features.cpuid[COMMON_CPUID_INDEX_1].edx;
#else
- asm volatile ("cpuid"
- : "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx)
- : "0" (1));
-#endif
-
+ __cpuid (1, eax, ebx, ecx, edx);
+#endif
+
+#ifndef DISABLE_PREFERRED_MEMORY_INSTRUCTION
/* Intel prefers SSSE3 instructions for memory/string routines
if they are avaiable. */
if ((ecx & 0x200))
__x86_64_preferred_memory_instruction = 3;
else
__x86_64_preferred_memory_instruction = 2;
+#endif
/* Figure out the number of logical threads that share the
highest cache level. */
@@ -530,9 +543,7 @@
/* Query until desired cache level is enumerated. */
do
{
- asm volatile ("cpuid"
- : "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx)
- : "0" (4), "2" (i++));
+ __cpuid_count (4, i++, eax, ebx, ecx, edx);
/* There seems to be a bug in at least some Pentium Ds
which sometimes fail to iterate all cache parameters.
@@ -566,9 +577,7 @@
shared = handle_amd (_SC_LEVEL3_CACHE_SIZE);
/* Get maximum extended function. */
- asm volatile ("cpuid"
- : "=a" (max_cpuid_ex), "=b" (ebx), "=c" (ecx), "=d" (edx)
- : "0" (0x80000000));
+ __cpuid (0x80000000, max_cpuid_ex, ebx, ecx, edx);
if (shared <= 0)
/* No shared L3 cache. All we have is the L2 cache. */
@@ -579,10 +588,7 @@
if (max_cpuid_ex >= 0x80000008)
{
/* Get width of APIC ID. */
- asm volatile ("cpuid"
- : "=a" (max_cpuid_ex), "=b" (ebx), "=c" (ecx),
- "=d" (edx)
- : "0" (0x80000008));
+ __cpuid (0x80000008, max_cpuid_ex, ebx, ecx, edx);
threads = 1 << ((ecx >> 12) & 0x0f);
}
@@ -590,10 +596,7 @@
{
/* If APIC ID width is not available, use logical
processor count. */
- asm volatile ("cpuid"
- : "=a" (max_cpuid_ex), "=b" (ebx), "=c" (ecx),
- "=d" (edx)
- : "0" (0x00000001));
+ __cpuid (0x00000001, max_cpuid_ex, ebx, ecx, edx);
if ((edx & (1 << 28)) != 0)
threads = (ebx >> 16) & 0xff;
@@ -608,15 +611,15 @@
shared += core;
}
+#ifndef DISABLE_PREFETCHW
if (max_cpuid_ex >= 0x80000001)
{
- asm volatile ("cpuid"
- : "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx)
- : "0" (0x80000001));
+ __cpuid (0x80000001, eax, ebx, ecx, edx);
/* PREFETCHW || 3DNow! */
if ((ecx & 0x100) || (edx & 0x80000000))
__x86_64_prefetchw = -1;
}
+#endif
}
if (data > 0)
Modified: trunk/libc/sysdeps/x86_64/multiarch/init-arch.c
==============================================================================
--- trunk/libc/sysdeps/x86_64/multiarch/init-arch.c (original)
+++ trunk/libc/sysdeps/x86_64/multiarch/init-arch.c Mon Aug 3 06:36:46 2009
@@ -18,6 +18,7 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
+#include <cpuid.h>
#include "init-arch.h"
@@ -27,12 +28,10 @@
static void
get_common_indeces (void)
{
- asm volatile ("cpuid"
- : "=a" (__cpu_features.cpuid[COMMON_CPUID_INDEX_1].eax),
- "=b" (__cpu_features.cpuid[COMMON_CPUID_INDEX_1].ebx),
- "=c" (__cpu_features.cpuid[COMMON_CPUID_INDEX_1].ecx),
- "=d" (__cpu_features.cpuid[COMMON_CPUID_INDEX_1].edx)
- : "0" (1));
+ __cpuid (1, __cpu_features.cpuid[COMMON_CPUID_INDEX_1].eax,
+ __cpu_features.cpuid[COMMON_CPUID_INDEX_1].ebx,
+ __cpu_features.cpuid[COMMON_CPUID_INDEX_1].ecx,
+ __cpu_features.cpuid[COMMON_CPUID_INDEX_1].edx);
unsigned int eax = __cpu_features.cpuid[COMMON_CPUID_INDEX_1].eax;
__cpu_features.family = (eax >> 8) & 0x0f;
@@ -47,10 +46,7 @@
unsigned int ecx;
unsigned int edx;
- asm volatile ("cpuid"
- : "=a" (__cpu_features.max_cpuid), "=b" (ebx), "=c" (ecx),
- "=d" (edx)
- : "0" (0));
+ __cpuid (0, __cpu_features.max_cpuid, ebx, ecx, edx);
/* This spells out "GenuineIntel". */
if (ebx == 0x756e6547 && ecx == 0x6c65746e && edx == 0x49656e69)
@@ -71,9 +67,11 @@
{
__cpu_features.model += extended_model;
+#ifndef ENABLE_SSSE3_ON_ATOM
if (__cpu_features.model == 0x1c)
/* Avoid SSSE3 on Atom since it is slow. */
__cpu_features.cpuid[COMMON_CPUID_INDEX_1].ecx &= ~(1 << 9);
+#endif
}
}
/* This spells out "AuthenticAMD". */
Modified: trunk/libc/sysdeps/x86_64/multiarch/init-arch.h
==============================================================================
--- trunk/libc/sysdeps/x86_64/multiarch/init-arch.h (original)
+++ trunk/libc/sysdeps/x86_64/multiarch/init-arch.h Mon Aug 3 06:36:46 2009
@@ -61,6 +61,9 @@
/* Following are the feature tests used throughout libc. */
#ifndef NOT_IN_libc
+# define HAS_SSE2 \
+ ((__cpu_features.cpuid[COMMON_CPUID_INDEX_1].edx & (1 << 26)) != 0)
+
# define HAS_POPCOUNT \
((__cpu_features.cpuid[COMMON_CPUID_INDEX_1].ecx & (1 << 23)) != 0)
@@ -70,6 +73,9 @@
# define HAS_FMA \
((__cpu_features.cpuid[COMMON_CPUID_INDEX_1].ecx & (1 << 12)) != 0)
#else
+# define HAS_SSE2 \
+ ((__get_cpu_features ()->cpuid[COMMON_CPUID_INDEX_1].edx & (1 << 26)) != 0)
+
# define HAS_POPCOUNT \
((__get_cpu_features ()->cpuid[COMMON_CPUID_INDEX_1].ecx & (1 << 23)) != 0)
Modified: trunk/libc/sysdeps/x86_64/multiarch/sched_cpucount.c
==============================================================================
--- trunk/libc/sysdeps/x86_64/multiarch/sched_cpucount.c (original)
+++ trunk/libc/sysdeps/x86_64/multiarch/sched_cpucount.c Mon Aug 3 06:36:46 2009
@@ -27,7 +27,7 @@
#define POPCNT(l) \
({ __cpu_mask r; \
- asm ("popcntq %1, %0" : "=r" (r) : "0" (l));\
+ asm ("popcnt %1, %0" : "=r" (r) : "0" (l));\
r; })
#define __sched_cpucount static popcount_cpucount
#include <posix/sched_cpucount.c>