This is the mail archive of the glibc-cvs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

GNU C Library master sources branch master updated. glibc-2.22-190-g75dd0a8


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, master has been updated
       via  75dd0a8f3db2813196db08928b1b6bb200230695 (commit)
       via  d226114b9bfce2ea729f9c7b736aa5d509b2a73c (commit)
      from  37430363b865f2423bd58b4f0eaa779845ed7e71 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=75dd0a8f3db2813196db08928b1b6bb200230695

commit 75dd0a8f3db2813196db08928b1b6bb200230695
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Thu Aug 27 09:06:26 2015 -0700

    Detect and select i586/i686 implementation at run-time
    
    We detect i586 and i686 features at run-time by checking CX8 and CMOV
    CPUID features bits.  We can use these information to select the best
    implementation in ix86 multiarch.  HAS_I586/HAS_I686 is true if i586/i686
    instructions are available on the processor.
    
    Due to the reordering and the other nifty extensions in i686, it is not
    really good to use heavily i586 optimized code on an i686.  It's better
    to use i486 code if it isn't an i586.  USE_I586/USE_I686 is true if
    i586/i686 implementation should be used for the processor.  USE_I586
    is true only if i686 instructions aren't available.  If i686 instructions
    are available, we always choose i686 or i486 implementation, in that order,
    and we never choose i586 implementation for i686-class processors.
    
    	* sysdeps/i386/init-arch.h: New file.
    	* sysdeps/i386/i586/init-arch.h: Likewise.
    	* sysdeps/i386/i686/init-arch.h: Likewise.
    	* sysdeps/x86/cpu-features.c (init_cpu_features): Set bit_I586
    	bit if CX8 is available.  Set bit_I686 bit if CMOV is available.
    	* sysdeps/x86/cpu-features.h (bit_I586): New.
    	(bit_I686): Likewise.
    	(bit_CX8): Likewise.
    	(bit_CMOV): Likewise.
    	(index_CX8): Likewise.
    	(index_CMOV): Likewise.
    	(index_I586): Likewise.
    	(index_I686): Likewise.
    	(reg_CX8): Likewise.
    	(reg_CMOV): Likewise.
    	(HAS_I586): Defined as HAS_ARCH_FEATURE (I586) if i586 isn't
    	available at compile-time.
    	(HAS_I686): Defined as HAS_ARCH_FEATURE (I686) if i686 isn't
    	available at compile-time.
    	* sysdeps/x86/init-arch.h (USE_I586): New macro.
    	(USE_I686): Likewise.

diff --git a/ChangeLog b/ChangeLog
index df391c2..844bbf7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,29 @@
 2015-08-27  H.J. Lu  <hongjiu.lu@intel.com>
 
+	* sysdeps/i386/init-arch.h: New file.
+	* sysdeps/i386/i586/init-arch.h: Likewise.
+	* sysdeps/i386/i686/init-arch.h: Likewise.
+	* sysdeps/x86/cpu-features.c (init_cpu_features): Set bit_I586
+	bit if CX8 is available.  Set bit_I686 bit if CMOV is available.
+	* sysdeps/x86/cpu-features.h (bit_I586): New.
+	(bit_I686): Likewise.
+	(bit_CX8): Likewise.
+	(bit_CMOV): Likewise.
+	(index_CX8): Likewise.
+	(index_CMOV): Likewise.
+	(index_I586): Likewise.
+	(index_I686): Likewise.
+	(reg_CX8): Likewise.
+	(reg_CMOV): Likewise.
+	(HAS_I586): Defined as HAS_ARCH_FEATURE (I586) if i586 isn't
+	available at compile-time.
+	(HAS_I686): Defined as HAS_ARCH_FEATURE (I686) if i686 isn't
+	available at compile-time.
+	* sysdeps/x86/init-arch.h (USE_I586): New macro.
+	(USE_I686): Likewise.
+
+2015-08-27  H.J. Lu  <hongjiu.lu@intel.com>
+
 	* sysdeps/i386/bcopy.S: New file.
 	* sysdeps/i386/bzero.S: Likewise.
 	* sysdeps/i386/memcpy.S: Likewise.
diff --git a/sysdeps/x86/init-arch.h b/sysdeps/i386/i586/init-arch.h
similarity index 78%
copy from sysdeps/x86/init-arch.h
copy to sysdeps/i386/i586/init-arch.h
index 2b9988e..50c43a2 100644
--- a/sysdeps/x86/init-arch.h
+++ b/sysdeps/i386/i586/init-arch.h
@@ -1,5 +1,5 @@
-/* This file is part of the GNU C Library.
-   Copyright (C) 2008-2015 Free Software Foundation, Inc.
+/* Copyright (C) 2015 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
@@ -15,8 +15,5 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#ifdef  __ASSEMBLER__
-# include <cpu-features.h>
-#else
-# include <ldsodefs.h>
-#endif
+#define MINIMUM_ISA 586
+#include <sysdeps/x86/init-arch.h>
diff --git a/sysdeps/x86/init-arch.h b/sysdeps/i386/i686/init-arch.h
similarity index 78%
copy from sysdeps/x86/init-arch.h
copy to sysdeps/i386/i686/init-arch.h
index 2b9988e..b4a2735 100644
--- a/sysdeps/x86/init-arch.h
+++ b/sysdeps/i386/i686/init-arch.h
@@ -1,5 +1,5 @@
-/* This file is part of the GNU C Library.
-   Copyright (C) 2008-2015 Free Software Foundation, Inc.
+/* Copyright (C) 2015 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
@@ -15,8 +15,5 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#ifdef  __ASSEMBLER__
-# include <cpu-features.h>
-#else
-# include <ldsodefs.h>
-#endif
+#define MINIMUM_ISA 686
+#include <sysdeps/x86/init-arch.h>
diff --git a/sysdeps/x86/init-arch.h b/sysdeps/i386/init-arch.h
similarity index 78%
copy from sysdeps/x86/init-arch.h
copy to sysdeps/i386/init-arch.h
index 2b9988e..0c74ddc 100644
--- a/sysdeps/x86/init-arch.h
+++ b/sysdeps/i386/init-arch.h
@@ -1,5 +1,5 @@
-/* This file is part of the GNU C Library.
-   Copyright (C) 2008-2015 Free Software Foundation, Inc.
+/* Copyright (C) 2015 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
@@ -15,8 +15,5 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#ifdef  __ASSEMBLER__
-# include <cpu-features.h>
-#else
-# include <ldsodefs.h>
-#endif
+#define MINIMUM_ISA 486
+#include <sysdeps/x86/init-arch.h>
diff --git a/sysdeps/x86/cpu-features.c b/sysdeps/x86/cpu-features.c
index 40575de..b03451d 100644
--- a/sysdeps/x86/cpu-features.c
+++ b/sysdeps/x86/cpu-features.c
@@ -150,6 +150,14 @@ init_cpu_features (struct cpu_features *cpu_features)
   else
     kind = arch_kind_other;
 
+  /* Support i586 if CX8 is available.  */
+  if (HAS_CPU_FEATURE (CX8))
+    cpu_features->feature[index_I586] |= bit_I586;
+
+  /* Support i686 if CMOV is available.  */
+  if (HAS_CPU_FEATURE (CMOV))
+    cpu_features->feature[index_I686] |= bit_I686;
+
   if (cpu_features->max_cpuid >= 7)
     __cpuid_count (7, 0,
 		   cpu_features->cpuid[COMMON_CPUID_INDEX_7].eax,
diff --git a/sysdeps/x86/cpu-features.h b/sysdeps/x86/cpu-features.h
index 6e70624..80edbee 100644
--- a/sysdeps/x86/cpu-features.h
+++ b/sysdeps/x86/cpu-features.h
@@ -31,10 +31,14 @@
 #define bit_AVX_Fast_Unaligned_Load	(1 << 11)
 #define bit_AVX512F_Usable		(1 << 12)
 #define bit_AVX512DQ_Usable		(1 << 13)
+#define bit_I586			(1 << 14)
+#define bit_I686			(1 << 15)
 
 /* CPUID Feature flags.  */
 
 /* COMMON_CPUID_INDEX_1.  */
+#define bit_CX8		(1 << 8)
+#define bit_CMOV	(1 << 15)
 #define bit_SSE2	(1 << 26)
 #define bit_SSSE3	(1 << 9)
 #define bit_SSE4_1	(1 << 19)
@@ -69,6 +73,8 @@
 # include <ifunc-defines.h>
 # include <rtld-global-offsets.h>
 
+# define index_CX8	COMMON_CPUID_INDEX_1*CPUID_SIZE+CPUID_EDX_OFFSET
+# define index_CMOV	COMMON_CPUID_INDEX_1*CPUID_SIZE+CPUID_EDX_OFFSET
 # define index_SSE2	COMMON_CPUID_INDEX_1*CPUID_SIZE+CPUID_EDX_OFFSET
 # define index_SSSE3	COMMON_CPUID_INDEX_1*CPUID_SIZE+CPUID_ECX_OFFSET
 # define index_SSE4_1	COMMON_CPUID_INDEX_1*CPUID_SIZE+CPUID_ECX_OFFSET
@@ -89,6 +95,8 @@
 # define index_AVX_Fast_Unaligned_Load	FEATURE_INDEX_1*FEATURE_SIZE
 # define index_AVX512F_Usable		FEATURE_INDEX_1*FEATURE_SIZE
 # define index_AVX512DQ_Usable		FEATURE_INDEX_1*FEATURE_SIZE
+# define index_I586			FEATURE_INDEX_1*FEATURE_SIZE
+# define index_I686			FEATURE_INDEX_1*FEATURE_SIZE
 
 # if defined (_LIBC) && !IS_IN (nonlib)
 #  ifdef __x86_64__
@@ -193,6 +201,8 @@ extern const struct cpu_features *__get_cpu_features (void)
 # define HAS_ARCH_FEATURE(name) \
   ((__get_cpu_features ()->feature[index_##name] & (bit_##name)) != 0)
 
+# define index_CX8		COMMON_CPUID_INDEX_1
+# define index_CMOV		COMMON_CPUID_INDEX_1
 # define index_SSE2		COMMON_CPUID_INDEX_1
 # define index_SSSE3		COMMON_CPUID_INDEX_1
 # define index_SSE4_1		COMMON_CPUID_INDEX_1
@@ -207,6 +217,8 @@ extern const struct cpu_features *__get_cpu_features (void)
 # define index_POPCOUNT		COMMON_CPUID_INDEX_1
 # define index_OSXSAVE		COMMON_CPUID_INDEX_1
 
+# define reg_CX8		edx
+# define reg_CMOV		edx
 # define reg_SSE2		edx
 # define reg_SSSE3		ecx
 # define reg_SSE4_1		ecx
@@ -234,6 +246,8 @@ extern const struct cpu_features *__get_cpu_features (void)
 # define index_AVX_Fast_Unaligned_Load	FEATURE_INDEX_1
 # define index_AVX512F_Usable		FEATURE_INDEX_1
 # define index_AVX512DQ_Usable		FEATURE_INDEX_1
+# define index_I586			FEATURE_INDEX_1
+# define index_I686			FEATURE_INDEX_1
 
 #endif	/* !__ASSEMBLER__ */
 
@@ -242,7 +256,7 @@ extern const struct cpu_features *__get_cpu_features (void)
 #elif defined __i586__ || defined __pentium__
 # define HAS_CPUID 1
 # define HAS_I586 1
-# define HAS_I686 0
+# define HAS_I686 HAS_ARCH_FEATURE (I686)
 #elif (defined __i686__ || defined __pentiumpro__		\
        || defined __pentium4__ || defined __nocona__		\
        || defined __atom__ || defined __core2__			\
@@ -261,8 +275,8 @@ extern const struct cpu_features *__get_cpu_features (void)
 # define HAS_I686 1
 #else
 # define HAS_CPUID 0
-# define HAS_I586 0
-# define HAS_I686 0
+# define HAS_I586 HAS_ARCH_FEATURE (I586)
+# define HAS_I686 HAS_ARCH_FEATURE (I686)
 #endif
 
 #endif  /* cpu_features_h */
diff --git a/sysdeps/x86/init-arch.h b/sysdeps/x86/init-arch.h
index 2b9988e..55897fa 100644
--- a/sysdeps/x86/init-arch.h
+++ b/sysdeps/x86/init-arch.h
@@ -20,3 +20,16 @@
 #else
 # include <ldsodefs.h>
 #endif
+
+#ifndef __x86_64__
+/* Due to the reordering and the other nifty extensions in i686, it is
+   not really good to use heavily i586 optimized code on an i686.  It's
+   better to use i486 code if it isn't an i586.  */
+# if MINIMUM_ISA == 686
+#  define USE_I586 0
+#  define USE_I686 1
+# else
+#  define USE_I586 (HAS_ARCH_FEATURE (I586) && !HAS_ARCH_FEATURE (I686))
+#  define USE_I686 HAS_ARCH_FEATURE (I686)
+# endif
+#endif

http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=d226114b9bfce2ea729f9c7b736aa5d509b2a73c

commit d226114b9bfce2ea729f9c7b736aa5d509b2a73c
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Thu Aug 27 09:04:40 2015 -0700

    Add i386 memset and memcpy assembly functions
    
    Add i386 memset and memcpy assembly functions with REP MOVSB/STOSB
    instructions.
    
    	* sysdeps/i386/bcopy.S: New file.
    	* sysdeps/i386/bzero.S: Likewise.
    	* sysdeps/i386/memcpy.S: Likewise.
    	* sysdeps/i386/memmove.S: Likewise.
    	* sysdeps/i386/mempcpy.S: Likewise.
    	* sysdeps/i386/memset.S: Likewise.
    	* sysdeps/i386/bzero.c: Removed.
    	* sysdeps/i386/memset.c: Likewise.
    	* sysdeps/i386/i586/memcpy_chk.S: Likewise.
    	* sysdeps/i386/i586/mempcpy_chk.S: Likewise.
    	* sysdeps/i386/i586/memset_chk.S: Likewise.
    	* sysdeps/i386/i686/memcpy_chk.S: Moved to ...
    	* sysdeps/i386/memcpy_chk.S: Here.
    	* sysdeps/i386/i686/memmove_chk.S: Moved to ...
    	* sysdeps/i386/memmove_chk.S: Here.
    	* sysdeps/i386/i686/mempcpy_chk.S: Moved to ...
    	* sysdeps/i386/mempcpy_chk.S: Likewise.
    	* sysdeps/i386/i686/memset_chk.S: Moved to ...
    	* sysdeps/i386/memset_chk.S: Likewise.

diff --git a/ChangeLog b/ChangeLog
index 8e65558..df391c2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,25 @@
+2015-08-27  H.J. Lu  <hongjiu.lu@intel.com>
+
+	* sysdeps/i386/bcopy.S: New file.
+	* sysdeps/i386/bzero.S: Likewise.
+	* sysdeps/i386/memcpy.S: Likewise.
+	* sysdeps/i386/memmove.S: Likewise.
+	* sysdeps/i386/mempcpy.S: Likewise.
+	* sysdeps/i386/memset.S: Likewise.
+	* sysdeps/i386/bzero.c: Removed.
+	* sysdeps/i386/memset.c: Likewise.
+	* sysdeps/i386/i586/memcpy_chk.S: Likewise.
+	* sysdeps/i386/i586/mempcpy_chk.S: Likewise.
+	* sysdeps/i386/i586/memset_chk.S: Likewise.
+	* sysdeps/i386/i686/memcpy_chk.S: Moved to ...
+	* sysdeps/i386/memcpy_chk.S: Here.
+	* sysdeps/i386/i686/memmove_chk.S: Moved to ...
+	* sysdeps/i386/memmove_chk.S: Here.
+	* sysdeps/i386/i686/mempcpy_chk.S: Moved to ...
+	* sysdeps/i386/mempcpy_chk.S: Likewise.
+	* sysdeps/i386/i686/memset_chk.S: Moved to ...
+	* sysdeps/i386/memset_chk.S: Likewise.
+
 2015-08-27  Steve Ellcey  <sellcey@imgtec.com>
 
 	* soft-fp/fmasf4.c: Add include of sys/cdefs.h.
diff --git a/sysdeps/i386/bcopy.S b/sysdeps/i386/bcopy.S
new file mode 100644
index 0000000..12b8ddb
--- /dev/null
+++ b/sysdeps/i386/bcopy.S
@@ -0,0 +1,4 @@
+#define USE_AS_MEMMOVE
+#define USE_AS_BCOPY
+#define MEMCPY		bcopy
+#include "memcpy.S"
diff --git a/sysdeps/i386/bzero.S b/sysdeps/i386/bzero.S
new file mode 100644
index 0000000..c8dd47b
--- /dev/null
+++ b/sysdeps/i386/bzero.S
@@ -0,0 +1,5 @@
+#define USE_AS_BZERO
+#define memset __bzero
+#include "memset.S"
+
+weak_alias (__bzero, bzero)
diff --git a/sysdeps/i386/bzero.c b/sysdeps/i386/bzero.c
deleted file mode 100644
index 1a89444..0000000
--- a/sysdeps/i386/bzero.c
+++ /dev/null
@@ -1,82 +0,0 @@
-/* bzero -- set a block of memory to zero.  For Intel 80x86, x>=3.
-   This file is part of the GNU C Library.
-   Copyright (C) 1991-2015 Free Software Foundation, Inc.
-   Contributed by Torbjorn Granlund (tege@sics.se).
-
-   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, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <string.h>
-#include <memcopy.h>
-
-#undef	bzero
-#undef	__bzero
-
-#ifdef	__GNUC__
-
-void
-__bzero (dstpp, len)
-     void *dstpp;
-     size_t len;
-{
-  /* N.B.: This code is almost verbatim from memset.c.  */
-  int d0;
-  unsigned long int dstp = (unsigned long int) dstpp;
-
-  /* This explicit register allocation
-     improves code very much indeed.  */
-  register op_t x asm ("ax");
-
-  x = 0;
-
-  /* Clear the direction flag, so filling will move forward.  */
-  asm volatile ("cld");
-
-  /* This threshold value is optimal.  */
-  if (len >= 12)
-    {
-      /* Adjust LEN for the bytes handled in the first loop.  */
-      len -= (-dstp) % OPSIZ;
-
-      /* There are at least some bytes to set.
-	 No need to test for LEN == 0 in this alignment loop.  */
-
-      /* Fill bytes until DSTP is aligned on a longword boundary.  */
-      asm volatile ("rep\n"
-		    "stosb" /* %0, %2, %3 */ :
-		    "=D" (dstp), "=c" (d0) :
-		    "0" (dstp), "1" ((-dstp) % OPSIZ), "a" (x) :
-		    "memory");
-
-      /* Fill longwords.  */
-      asm volatile ("rep\n"
-		    "stosl" /* %0, %2, %3 */ :
-		    "=D" (dstp), "=c" (d0) :
-		    "0" (dstp), "1" (len / OPSIZ), "a" (x) :
-		    "memory");
-      len %= OPSIZ;
-    }
-
-  /* Write the last few bytes.  */
-  asm volatile ("rep\n"
-		"stosb" /* %0, %2, %3 */ :
-		"=D" (dstp), "=c" (d0) :
-		"0" (dstp), "c" (len), "a" (x) :
-		"memory");
-}
-weak_alias (__bzero, bzero)
-
-#else
-#include <string/bzero.c>
-#endif
diff --git a/sysdeps/i386/i586/memcpy_chk.S b/sysdeps/i386/i586/memcpy_chk.S
deleted file mode 100644
index ab8a95c..0000000
--- a/sysdeps/i386/i586/memcpy_chk.S
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdeps/i386/i686/memcpy_chk.S>
diff --git a/sysdeps/i386/i586/mempcpy_chk.S b/sysdeps/i386/i586/mempcpy_chk.S
deleted file mode 100644
index 9a1de1d..0000000
--- a/sysdeps/i386/i586/mempcpy_chk.S
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdeps/i386/i686/mempcpy_chk.S>
diff --git a/sysdeps/i386/i586/memset_chk.S b/sysdeps/i386/i586/memset_chk.S
deleted file mode 100644
index 09f9d42..0000000
--- a/sysdeps/i386/i586/memset_chk.S
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdeps/i386/i686/memset_chk.S>
diff --git a/sysdeps/i386/memcpy.S b/sysdeps/i386/memcpy.S
new file mode 100644
index 0000000..5f0196e
--- /dev/null
+++ b/sysdeps/i386/memcpy.S
@@ -0,0 +1,95 @@
+/* memcpy with REP MOVSB/STOSB
+   Copyright (C) 2015 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, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <sysdep.h>
+#include "asm-syntax.h"
+
+#ifndef MEMCPY
+# define MEMCPY		memcpy
+# define MEMCPY_CHK	__memcpy_chk
+#endif
+
+#ifdef USE_AS_BCOPY
+# define STR2		12
+# define STR1		STR2+4
+# define N     		STR1+4
+#else
+# define STR1		12
+# define STR2		STR1+4
+# define N     		STR2+4
+#endif
+
+#define CFI_PUSH(REG)						\
+  cfi_adjust_cfa_offset (4);					\
+  cfi_rel_offset (REG, 0)
+
+#define CFI_POP(REG)						\
+  cfi_adjust_cfa_offset (-4);					\
+  cfi_restore (REG)
+
+#define PUSH(REG)	pushl REG; CFI_PUSH (REG)
+#define POP(REG)	popl REG; CFI_POP (REG)
+
+	.text
+#if defined SHARED && IS_IN (libc) && !defined USE_AS_BCOPY
+ENTRY (MEMCPY_CHK)
+	movl	12(%esp), %eax
+	cmpl	%eax, 16(%esp)
+	jb	HIDDEN_JUMPTARGET (__chk_fail)
+END (MEMCPY_CHK)
+#endif
+ENTRY (MEMCPY)
+	PUSH	(%esi)
+	PUSH	(%edi)
+	movl	N(%esp), %ecx
+	movl	STR1(%esp), %edi
+	movl	STR2(%esp), %esi
+	mov	%edi, %eax
+#ifdef USE_AS_MEMPCPY
+	add	%ecx, %eax
+#endif
+
+#ifdef USE_AS_MEMMOVE
+	cmp	%esi, %edi
+	ja	L(copy_backward)
+	je	L(bwd_write_0bytes)
+#endif
+
+	rep	movsb
+	POP	(%edi)
+	POP	(%esi)
+	ret
+
+#ifdef USE_AS_MEMMOVE
+L(copy_backward):
+	lea	-1(%edi,%ecx), %edi
+	lea	-1(%esi,%ecx), %esi
+	std
+	rep	movsb
+	cld
+L(bwd_write_0bytes):
+	POP	(%edi)
+	POP	(%esi)
+	ret
+#endif
+
+END (MEMCPY)
+
+#ifndef USE_AS_BCOPY
+libc_hidden_builtin_def (MEMCPY)
+#endif
diff --git a/sysdeps/i386/i686/memcpy_chk.S b/sysdeps/i386/memcpy_chk.S
similarity index 92%
rename from sysdeps/i386/i686/memcpy_chk.S
rename to sysdeps/i386/memcpy_chk.S
index cdf807f..b3b25de 100644
--- a/sysdeps/i386/i686/memcpy_chk.S
+++ b/sysdeps/i386/memcpy_chk.S
@@ -1,4 +1,4 @@
-/* Checking memcpy for i686.
+/* Checking memcpy for i386.
    Copyright (C) 2004-2015 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
@@ -16,10 +16,10 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <sysdep.h>
-#include "asm-syntax.h"
+#ifndef SHARED
+# include <sysdep.h>
+# include "asm-syntax.h"
 
-#ifndef PIC
 	/* For libc.so this is defined in memcpy.S.
 	   For libc.a, this is a separate source to avoid
 	   memcpy bringing in __chk_fail and all routines
diff --git a/sysdeps/i386/memmove.S b/sysdeps/i386/memmove.S
new file mode 100644
index 0000000..60a45d2
--- /dev/null
+++ b/sysdeps/i386/memmove.S
@@ -0,0 +1,4 @@
+#define USE_AS_MEMMOVE
+#define MEMCPY		memmove
+#define MEMCPY_CHK	__memmove_chk
+#include "memcpy.S"
diff --git a/sysdeps/i386/i686/memmove_chk.S b/sysdeps/i386/memmove_chk.S
similarity index 78%
rename from sysdeps/i386/i686/memmove_chk.S
rename to sysdeps/i386/memmove_chk.S
index 64bf9e0..26d2abd 100644
--- a/sysdeps/i386/i686/memmove_chk.S
+++ b/sysdeps/i386/memmove_chk.S
@@ -1,4 +1,4 @@
-/* Checking memmove for x86-64.
+/* Checking memmove for i386
    Copyright (C) 2004-2015 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
@@ -16,14 +16,13 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <sysdep.h>
-#include "asm-syntax.h"
+#ifndef SHARED
+# include <sysdep.h>
+# include "asm-syntax.h"
 
-#ifndef PIC
-	/* For libc.so this is defined in memmove.S.
-	   For libc.a, this is a separate source to avoid
-	   memmove bringing in __chk_fail and all routines
-	   it calls.  */
+/* For libc.so this is defined in memmove.S.  For libc.a, this is a
+   separate source to avoid memmove bringing in __chk_fail and all
+   routines it calls.  */
         .text
 ENTRY (__memmove_chk)
 	movl	12(%esp), %eax
diff --git a/sysdeps/i386/mempcpy.S b/sysdeps/i386/mempcpy.S
new file mode 100644
index 0000000..61addb7
--- /dev/null
+++ b/sysdeps/i386/mempcpy.S
@@ -0,0 +1,7 @@
+#define USE_AS_MEMPCPY
+#define MEMCPY		__mempcpy
+#define MEMCPY_CHK	__mempcpy_chk
+#include "memcpy.S"
+
+weak_alias (__mempcpy, mempcpy)
+libc_hidden_builtin_def (mempcpy)
diff --git a/sysdeps/i386/i686/mempcpy_chk.S b/sysdeps/i386/mempcpy_chk.S
similarity index 78%
rename from sysdeps/i386/i686/mempcpy_chk.S
rename to sysdeps/i386/mempcpy_chk.S
index a61757b..05f86c3 100644
--- a/sysdeps/i386/i686/mempcpy_chk.S
+++ b/sysdeps/i386/mempcpy_chk.S
@@ -1,4 +1,4 @@
-/* Checking mempcpy for x86-64.
+/* Checking mempcpy for i386
    Copyright (C) 2004-2015 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
@@ -16,14 +16,13 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <sysdep.h>
-#include "asm-syntax.h"
+#ifndef SHARED
+# include <sysdep.h>
+# include "asm-syntax.h"
 
-#ifndef PIC
-	/* For libc.so this is defined in mempcpy.S.
-	   For libc.a, this is a separate source to avoid
-	   mempcpy bringing in __chk_fail and all routines
-	   it calls.  */
+/* For libc.so this is defined in mempcpy.S.  For libc.a, this is a
+   separate source to avoid mempcpy bringing in __chk_fail and all
+   routines it calls.  */
         .text
 ENTRY (__mempcpy_chk)
 	movl	12(%esp), %eax
diff --git a/sysdeps/i386/memset.S b/sysdeps/i386/memset.S
new file mode 100644
index 0000000..21b3430
--- /dev/null
+++ b/sysdeps/i386/memset.S
@@ -0,0 +1,68 @@
+/* memset with REP MOVSB/STOSB
+   Copyright (C) 2015 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, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <sysdep.h>
+
+#define CFI_PUSH(REG)						\
+  cfi_adjust_cfa_offset (4);					\
+  cfi_rel_offset (REG, 0)
+
+#define CFI_POP(REG)						\
+  cfi_adjust_cfa_offset (-4);					\
+  cfi_restore (REG)
+
+#define PUSH(REG)	pushl REG; CFI_PUSH (REG)
+#define POP(REG)	popl REG; CFI_POP (REG)
+
+#define STR1  8
+#ifdef USE_AS_BZERO
+#define N     STR1+4
+#else
+#define STR2  STR1+4
+#define N     STR2+4
+#endif
+
+	.text
+#if defined SHARED && IS_IN (libc) && !defined USE_AS_BZERO
+ENTRY (__memset_chk)
+	movl	12(%esp), %eax
+	cmpl	%eax, 16(%esp)
+	jb	HIDDEN_JUMPTARGET (__chk_fail)
+END (__memset_chk)
+#endif
+ENTRY (memset)
+	PUSH    (%edi)
+	movl	N(%esp), %ecx
+	movl	STR1(%esp), %edi
+#ifdef USE_AS_BZERO
+	xor	%eax, %eax
+#else
+	movzbl	STR2(%esp), %eax
+	mov	%edi, %edx
+#endif
+	rep	stosb
+#ifndef USE_AS_BZERO
+	mov	%edx, %eax
+#endif
+	POP     (%edi)
+	ret
+END (memset)
+
+#ifndef USE_AS_BZERO
+libc_hidden_builtin_def (memset)
+#endif
diff --git a/sysdeps/i386/memset.c b/sysdeps/i386/memset.c
deleted file mode 100644
index bf11590..0000000
--- a/sysdeps/i386/memset.c
+++ /dev/null
@@ -1,85 +0,0 @@
-/* Set a block of memory to some byte value.
-   For Intel 80x86, x>=3.
-   Copyright (C) 1991-2015 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-   Contributed by Torbjorn Granlund (tege@sics.se).
-
-   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, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <string.h>
-#include <memcopy.h>
-
-#ifdef	__GNUC__
-
-#undef memset
-
-void *
-memset (void *dstpp, int c, size_t len)
-{
-  int d0;
-  unsigned long int dstp = (unsigned long int) dstpp;
-
-  /* This explicit register allocation
-     improves code very much indeed.  */
-  register op_t x asm("ax");
-
-  x = (unsigned char) c;
-
-  /* Clear the direction flag, so filling will move forward.  */
-  asm volatile("cld");
-
-  /* This threshold value is optimal.  */
-  if (len >= 12)
-    {
-      /* Fill X with four copies of the char we want to fill with.  */
-      x |= (x << 8);
-      x |= (x << 16);
-
-      /* Adjust LEN for the bytes handled in the first loop.  */
-      len -= (-dstp) % OPSIZ;
-
-      /* There are at least some bytes to set.
-	 No need to test for LEN == 0 in this alignment loop.  */
-
-      /* Fill bytes until DSTP is aligned on a longword boundary.  */
-      asm volatile("rep\n"
-		   "stosb" /* %0, %2, %3 */ :
-		   "=D" (dstp), "=c" (d0) :
-		   "0" (dstp), "1" ((-dstp) % OPSIZ), "a" (x) :
-		   "memory");
-
-      /* Fill longwords.  */
-      asm volatile("rep\n"
-		   "stosl" /* %0, %2, %3 */ :
-		   "=D" (dstp), "=c" (d0) :
-		   "0" (dstp), "1" (len / OPSIZ), "a" (x) :
-		   "memory");
-      len %= OPSIZ;
-    }
-
-  /* Write the last few bytes.  */
-  asm volatile("rep\n"
-	       "stosb" /* %0, %2, %3 */ :
-	       "=D" (dstp), "=c" (d0) :
-	       "0" (dstp), "1" (len), "a" (x) :
-	       "memory");
-
-  return dstpp;
-}
-libc_hidden_builtin_def (memset)
-
-#else
-#include <string/memset.c>
-#endif
diff --git a/sysdeps/i386/i686/memset_chk.S b/sysdeps/i386/memset_chk.S
similarity index 79%
rename from sysdeps/i386/i686/memset_chk.S
rename to sysdeps/i386/memset_chk.S
index da982fd..2312d32 100644
--- a/sysdeps/i386/i686/memset_chk.S
+++ b/sysdeps/i386/memset_chk.S
@@ -1,4 +1,4 @@
-/* Checking memset for i686.
+/* Checking memset for i386.
    Copyright (C) 2004-2015 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
@@ -16,14 +16,13 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <sysdep.h>
-#include "asm-syntax.h"
-
 #ifndef SHARED
-	/* For libc.so this is defined in memset.S.
-	   For libc.a, this is a separate source to avoid
-	   memset bringing in __chk_fail and all routines
-	   it calls.  */
+# include <sysdep.h>
+# include "asm-syntax.h"
+
+/* For libc.so this is defined in memset.S.  For libc.a, this is a
+   separate source to avoid memset bringing in __chk_fail and all
+   routines it calls.  */
         .text
 ENTRY (__memset_chk)
 	movl	12(%esp), %eax

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog                       |   46 +++++++++++++++++++
 sysdeps/i386/bcopy.S            |    4 ++
 sysdeps/i386/bzero.S            |    5 ++
 sysdeps/i386/bzero.c            |   82 ---------------------------------
 sysdeps/i386/i586/init-arch.h   |   19 ++++++++
 sysdeps/i386/i586/memcpy_chk.S  |    1 -
 sysdeps/i386/i586/mempcpy_chk.S |    1 -
 sysdeps/i386/i586/memset_chk.S  |    1 -
 sysdeps/i386/i686/init-arch.h   |   19 ++++++++
 sysdeps/i386/i686/memcpy_chk.S  |   34 --------------
 sysdeps/i386/i686/memmove_chk.S |   34 --------------
 sysdeps/i386/i686/mempcpy_chk.S |   34 --------------
 sysdeps/i386/i686/memset_chk.S  |   34 --------------
 sysdeps/i386/init-arch.h        |   19 ++++++++
 sysdeps/i386/memcpy.S           |   95 +++++++++++++++++++++++++++++++++++++++
 sysdeps/i386/memcpy_chk.S       |   34 ++++++++++++++
 sysdeps/i386/memmove.S          |    4 ++
 sysdeps/i386/memmove_chk.S      |   33 +++++++++++++
 sysdeps/i386/mempcpy.S          |    7 +++
 sysdeps/i386/mempcpy_chk.S      |   33 +++++++++++++
 sysdeps/i386/memset.S           |   68 ++++++++++++++++++++++++++++
 sysdeps/i386/memset.c           |   85 ----------------------------------
 sysdeps/i386/memset_chk.S       |   33 +++++++++++++
 sysdeps/x86/cpu-features.c      |    8 +++
 sysdeps/x86/cpu-features.h      |   20 +++++++-
 sysdeps/x86/init-arch.h         |   13 +++++
 26 files changed, 457 insertions(+), 309 deletions(-)
 create mode 100644 sysdeps/i386/bcopy.S
 create mode 100644 sysdeps/i386/bzero.S
 delete mode 100644 sysdeps/i386/bzero.c
 create mode 100644 sysdeps/i386/i586/init-arch.h
 delete mode 100644 sysdeps/i386/i586/memcpy_chk.S
 delete mode 100644 sysdeps/i386/i586/mempcpy_chk.S
 delete mode 100644 sysdeps/i386/i586/memset_chk.S
 create mode 100644 sysdeps/i386/i686/init-arch.h
 delete mode 100644 sysdeps/i386/i686/memcpy_chk.S
 delete mode 100644 sysdeps/i386/i686/memmove_chk.S
 delete mode 100644 sysdeps/i386/i686/mempcpy_chk.S
 delete mode 100644 sysdeps/i386/i686/memset_chk.S
 create mode 100644 sysdeps/i386/init-arch.h
 create mode 100644 sysdeps/i386/memcpy.S
 create mode 100644 sysdeps/i386/memcpy_chk.S
 create mode 100644 sysdeps/i386/memmove.S
 create mode 100644 sysdeps/i386/memmove_chk.S
 create mode 100644 sysdeps/i386/mempcpy.S
 create mode 100644 sysdeps/i386/mempcpy_chk.S
 create mode 100644 sysdeps/i386/memset.S
 delete mode 100644 sysdeps/i386/memset.c
 create mode 100644 sysdeps/i386/memset_chk.S


hooks/post-receive
-- 
GNU C Library master sources


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]