x86/include: remove dead __GNUC__ conditionals
Subsystems (2)
Rasmus Villemoes
reviewerPATCH 1/2 x86/include: remove dead __GNUC__ conditionals
We require gcc >= 4.6, so these can be removed.
Signed-off-by Rasmus Villemoes <[email protected]>
--- arch/x86/include/asm/bitops.h | 6 ------ arch/x86/include/asm/string_32.h | 20 -------------------- arch/x86/include/asm/string_64.h | 15 --------------- 3 files changed, 41 deletions(-)
arch/x86/include/asm/bitops.h +0 -6
@@ -36,13 +36,7 @@* bit 0 is the LSB of addr; bit 32 is the LSB of (addr+1). */ -#if __GNUC__ <4 || (__GNUC__ ==4 && __GNUC_MINOR__ <1 ) -/* Technically wrong, but this avoids compilation errors on some gcc -versions. */ -#define BITOP_ADDR (x) "=m" (*(volatile long *) (x)) -#else #define BITOP_ADDR (x) "+m" (*(volatile long *) (x)) -#endif #define ADDR BITOP_ADDR(addr)
arch/x86/include/asm/string_32.h +0 -20
@@ -179,14 +179,7 @@ static inline void *__memcpy3d(void *to, const void *from, size_t len)* No 3D Now! */ -#if (__GNUC__ >=4 )#define memcpy (t, f, n) __builtin_memcpy(t, f, n) -#else -#define memcpy (t, f, n) \ - (__builtin_constant_p((n)) \ - ? __constant_memcpy((t), (f), (n)) \ - : __memcpy((t), (f), (n))) -#endif #endif #endif /* !CONFIG_FORTIFY_SOURCE */
@@ -282,12 +275,7 @@ void *__constant_c_and_count_memset(void *s, unsigned long pattern, {int d0, d1; -#if __GNUC__ ==4 && __GNUC_MINOR__ ==0 -/* Workaround for broken gcc 4.0 */ - register unsigned long eax asm("%eax") = pattern; -#else unsigned long eax = pattern; -#endif switch (count %4 ) {case 0 :
@@ -321,15 +309,7 @@ void *__constant_c_and_count_memset(void *s, unsigned long pattern,#define __HAVE_ARCH_MEMSETextern void *memset (void *,int ,size_t );#ifndef CONFIG_FORTIFY_SOURCE -#if (__GNUC__ >=4 )#define memset (s, c, count) __builtin_memset(s, c, count) -#else -#define memset (s, c, count) \ - (__builtin_constant_p(c) \ - ? __constant_c_x_memset((s), (0x01010101UL * (unsigned char)(c)), \ - (count)) \ - : __memset((s), (c), (count))) -#endif #endif /* !CONFIG_FORTIFY_SOURCE */ #define __HAVE_ARCH_MEMSET16
arch/x86/include/asm/string_64.h +0 -15
@@ -14,21 +14,6 @@extern void *memcpy (void *to,const void *from,size_t len);extern void *__memcpy (void *to,const void *from,size_t len); -#ifndef CONFIG_FORTIFY_SOURCE -#if (__GNUC__ ==4 && __GNUC_MINOR__ <3 ) || __GNUC__ <4 -#define memcpy (dst, src, len) \ -({ \ - size_t __len = (len); \ - void *__ret; \ - if (__builtin_constant_p(len) && __len >= 64) \ - __ret = __memcpy((dst), (src), __len); \ - else \ - __ret = __builtin_memcpy((dst), (src), __len); \ - __ret; \ -}) -#endif -#endif /* !CONFIG_FORTIFY_SOURCE */ -#define __HAVE_ARCH_MEMSETvoid *memset (void *s,int c,size_t n);void *__memset (void *s,int c,size_t n);
Signature · 1 line
2.20.1
Rasmus Villemoes
reviewerPATCH 2/2 x86: string_32.h: remove unused macro and inlines
Nothing refers to the __constant_c_x_memset macro anymore, and when we remove that, the two referenced static inline functions become orphan.
Signed-off-by Rasmus Villemoes <[email protected]>
--- arch/x86/include/asm/string_32.h | 84 -------------------------------- 1 file changed, 84 deletions(-)
arch/x86/include/asm/string_32.h +0 -84
@@ -209,29 +209,6 @@ static inline void *__memset_generic(void *s, char c, size_t count)/* we might want to write optimized versions of these later */ #define __constant_count_memset (s, c, count) __memset_generic((s), (c), (count)) -/* -* memset(x, 0, y) is a reasonably common thing to do, so we want to fill -* things 32 bits at a time even when we don't know the size of the -* area at compile-time.. -*/ -static __always_inline -void *__constant_c_memset(void *s, unsigned long c, size_t count) -{ -int d0, d1; - asmvolatile ("rep ; stosl\n\t" -"testb $2,%b3\n\t" -"je 1f\n\t" -"stosw\n" -"1:\ttestb $1,%b3\n\t" -"je 2f\n\t" -"stosb\n" -"2:" - :"=&c" (d0),"=&D" (d1) - :"a" (c),"q" (count),"0" (count/4 ),"1" ((long )s) - :"memory" ); -return s; -} -/* Added by Gertjan van Wingerde to make minix and sysv module work */ #define __HAVE_ARCH_STRNLENextern size_t strnlen (const char *s,size_t count);
@@ -240,67 +217,6 @@ extern size_t strnlen(const char *s, size_t count);#define __HAVE_ARCH_STRSTRextern char *strstr (const char *cs,const char *ct); -/* -* This looks horribly ugly, but the compiler can optimize it totally, -* as we by now know that both pattern and count is constant.. -*/ -static __always_inline -void *__constant_c_and_count_memset(void *s, unsigned long pattern, -size_t count) -{ -switch (count) { -case 0 : -return s; -case 1 : - *(unsigned char *)s = pattern &0xff ; -return s; -case 2 : - *(unsigned short *)s = pattern &0xffff ; -return s; -case 3 : - *(unsigned short *)s = pattern &0xffff ; - *((unsigned char *)s +2 ) = pattern &0xff ; -return s; -case 4 : - *(unsigned long *)s = pattern; -return s; - } - -#define COMMON (x) \ - asm volatile("rep ; stosl" \ - x \ - : "=&c" (d0), "=&D" (d1) \ - : "a" (eax), "0" (count/4), "1" ((long)s) \ - : "memory") - - { -int d0, d1; -unsigned long eax = pattern; - -switch (count %4 ) { -case 0 : -COMMON ("" ); -return s; -case 1 : -COMMON ("\n\tstosb" ); -return s; -case 2 : -COMMON ("\n\tstosw" ); -return s; -default : -COMMON ("\n\tstosw\n\tstosb" ); -return s; - } - } - -#undef COMMON -} - -#define __constant_c_x_memset (s, c, count) \ - (__builtin_constant_p(count) \ - ? __constant_c_and_count_memset((s), (c), (count)) \ - : __constant_c_memset((s), (c), (count))) -#define __memset (s, c, count) \ (__builtin_constant_p(count) \ ? __constant_count_memset((s), (c), (count)) \
Signature · 1 line
2.20.1
tip-bot for Rasmus Villemoes
merge bot[tip:x86/asm] x86/asm: Remove unused __constant_c_x_memset() macro and inlines
x86/asm: Remove unused __constant_c_x_memset() macro and inlines
Commit-ID: 2e905c7abdcd5ff09b9df33d25eb7148c85bed2a Gitweb: https://git.kernel.org/tip/2e905c7abdcd5ff09b9df33d25eb7148c85bed2a Author: Rasmus Villemoes <[email protected]> AuthorDate: Fri, 11 Jan 2019 09:49:31 +0100 Committer: Borislav Petkov <[email protected]> CommitDate: Sat, 12 Jan 2019 17:54:49 +0100
x86/asm: Remove unused __constant_c_x_memset() macro and inlines
Nothing refers to the __constant_c_x_memset() macro anymore. Remove it and the two referenced static inline functions.
Signed-off-by Rasmus Villemoes <[email protected]>
Signed-off-by Borislav Petkov <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc x86-ml <[email protected]>
--- arch/x86/include/asm/string_32.h | 84 ---------------------------------------- 1 file changed, 84 deletions(-)
arch/x86/include/asm/string_32.h +0 -84
@@ -209,29 +209,6 @@ static inline void *__memset_generic(void *s, char c, size_t count)/* we might want to write optimized versions of these later */ #define __constant_count_memset (s, c, count) __memset_generic((s), (c), (count)) -/* -* memset(x, 0, y) is a reasonably common thing to do, so we want to fill -* things 32 bits at a time even when we don't know the size of the -* area at compile-time.. -*/ -static __always_inline -void *__constant_c_memset(void *s, unsigned long c, size_t count) -{ -int d0, d1; - asmvolatile ("rep ; stosl\n\t" -"testb $2,%b3\n\t" -"je 1f\n\t" -"stosw\n" -"1:\ttestb $1,%b3\n\t" -"je 2f\n\t" -"stosb\n" -"2:" - :"=&c" (d0),"=&D" (d1) - :"a" (c),"q" (count),"0" (count/4 ),"1" ((long )s) - :"memory" ); -return s; -} -/* Added by Gertjan van Wingerde to make minix and sysv module work */ #define __HAVE_ARCH_STRNLENextern size_t strnlen (const char *s,size_t count);
@@ -240,67 +217,6 @@ extern size_t strnlen(const char *s, size_t count);#define __HAVE_ARCH_STRSTRextern char *strstr (const char *cs,const char *ct); -/* -* This looks horribly ugly, but the compiler can optimize it totally, -* as we by now know that both pattern and count is constant.. -*/ -static __always_inline -void *__constant_c_and_count_memset(void *s, unsigned long pattern, -size_t count) -{ -switch (count) { -case 0 : -return s; -case 1 : - *(unsigned char *)s = pattern &0xff ; -return s; -case 2 : - *(unsigned short *)s = pattern &0xffff ; -return s; -case 3 : - *(unsigned short *)s = pattern &0xffff ; - *((unsigned char *)s +2 ) = pattern &0xff ; -return s; -case 4 : - *(unsigned long *)s = pattern; -return s; - } - -#define COMMON (x) \ - asm volatile("rep ; stosl" \ - x \ - : "=&c" (d0), "=&D" (d1) \ - : "a" (eax), "0" (count/4), "1" ((long)s) \ - : "memory") - - { -int d0, d1; -unsigned long eax = pattern; - -switch (count %4 ) { -case 0 : -COMMON ("" ); -return s; -case 1 : -COMMON ("\n\tstosb" ); -return s; -case 2 : -COMMON ("\n\tstosw" ); -return s; -default : -COMMON ("\n\tstosw\n\tstosb" ); -return s; - } - } - -#undef COMMON -} - -#define __constant_c_x_memset (s, c, count) \ - (__builtin_constant_p(count) \ - ? __constant_c_and_count_memset((s), (c), (count)) \ - : __constant_c_memset((s), (c), (count))) -#define __memset (s, c, count) \ (__builtin_constant_p(count) \ ? __constant_count_memset((s), (c), (count)) \
tip-bot for Rasmus Villemoes
merge bot[tip:x86/asm] x86/asm: Remove dead __GNUC__ conditionals
In reply to Rasmus Villemoesx86/asm: Remove dead __GNUC__ conditionals
Commit-ID: 88ca66d8540ca26119b1428cddb96b37925bdf01 Gitweb: https://git.kernel.org/tip/88ca66d8540ca26119b1428cddb96b37925bdf01 Author: Rasmus Villemoes <[email protected]> AuthorDate: Fri, 11 Jan 2019 09:49:30 +0100 Committer: Borislav Petkov <[email protected]> CommitDate: Sat, 12 Jan 2019 17:50:48 +0100
x86/asm: Remove dead __GNUC__ conditionals
The minimum supported gcc version is >= 4.6, so these can be removed.
Signed-off-by Rasmus Villemoes <[email protected]>
Signed-off-by Borislav Petkov <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
Cc Dan Williams <[email protected]>
Cc Geert Uytterhoeven <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Matthew Wilcox <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc x86-ml <[email protected]>
--- arch/x86/include/asm/bitops.h | 6 ------ arch/x86/include/asm/string_32.h | 20 -------------------- arch/x86/include/asm/string_64.h | 15 --------------- 3 files changed, 41 deletions(-)
arch/x86/include/asm/bitops.h +0 -6
@@ -36,13 +36,7 @@* bit 0 is the LSB of addr; bit 32 is the LSB of (addr+1). */ -#if __GNUC__ <4 || (__GNUC__ ==4 && __GNUC_MINOR__ <1 ) -/* Technically wrong, but this avoids compilation errors on some gcc -versions. */ -#define BITOP_ADDR (x) "=m" (*(volatile long *) (x)) -#else #define BITOP_ADDR (x) "+m" (*(volatile long *) (x)) -#endif #define ADDR BITOP_ADDR(addr)
arch/x86/include/asm/string_32.h +0 -20
@@ -179,14 +179,7 @@ static inline void *__memcpy3d(void *to, const void *from, size_t len)* No 3D Now! */ -#if (__GNUC__ >=4 )#define memcpy (t, f, n) __builtin_memcpy(t, f, n) -#else -#define memcpy (t, f, n) \ - (__builtin_constant_p((n)) \ - ? __constant_memcpy((t), (f), (n)) \ - : __memcpy((t), (f), (n))) -#endif #endif #endif /* !CONFIG_FORTIFY_SOURCE */
@@ -282,12 +275,7 @@ void *__constant_c_and_count_memset(void *s, unsigned long pattern, {int d0, d1; -#if __GNUC__ ==4 && __GNUC_MINOR__ ==0 -/* Workaround for broken gcc 4.0 */ - register unsigned long eax asm("%eax") = pattern; -#else unsigned long eax = pattern; -#endif switch (count %4 ) {case 0 :
@@ -321,15 +309,7 @@ void *__constant_c_and_count_memset(void *s, unsigned long pattern,#define __HAVE_ARCH_MEMSETextern void *memset (void *,int ,size_t );#ifndef CONFIG_FORTIFY_SOURCE -#if (__GNUC__ >=4 )#define memset (s, c, count) __builtin_memset(s, c, count) -#else -#define memset (s, c, count) \ - (__builtin_constant_p(c) \ - ? __constant_c_x_memset((s), (0x01010101UL * (unsigned char)(c)), \ - (count)) \ - : __memset((s), (c), (count))) -#endif #endif /* !CONFIG_FORTIFY_SOURCE */ #define __HAVE_ARCH_MEMSET16
arch/x86/include/asm/string_64.h +0 -15
@@ -14,21 +14,6 @@extern void *memcpy (void *to,const void *from,size_t len);extern void *__memcpy (void *to,const void *from,size_t len); -#ifndef CONFIG_FORTIFY_SOURCE -#if (__GNUC__ ==4 && __GNUC_MINOR__ <3 ) || __GNUC__ <4 -#define memcpy (dst, src, len) \ -({ \ - size_t __len = (len); \ - void *__ret; \ - if (__builtin_constant_p(len) && __len >= 64) \ - __ret = __memcpy((dst), (src), __len); \ - else \ - __ret = __builtin_memcpy((dst), (src), __len); \ - __ret; \ -}) -#endif -#endif /* !CONFIG_FORTIFY_SOURCE */ -#define __HAVE_ARCH_MEMSETvoid *memset (void *s,int c,size_t n);void *__memset (void *s,int c,size_t n);