Add _STRING_INLINE_unaligned
Commit Message
As discussed in https://sourceware.org/ml/libc-alpha/2015-10/msg00403.html ,
the setting of _STRING_ARCH_unaligned currently controls the external
GLIBC ABI as well as selecting the use of unaligned accesses withing GLIBC.
Since _STRING_ARCH_unaligned was recently changed for AArch64, this
would potentially break the ABI in GLIBC 2.23, so split the uses and add
_STRING_INLINE_unaligned to select the string ABI. This setting must be fixed for
each target, while _STRING_ARCH_unaligned may be changed from release to release.
Built and tested on AArch64, x86 and x64. OK for GLIBC 2.23?
ChangeLog:
2016-01-08 Wilco Dijkstra <wdijkstr@arm.com>
* bits/string.h (_STRING_INLINE_unaligned): New define.
* string/string-inlines.c: Use _STRING_INLINE_unaligned.
* string/bits/string2.h (_STRING_ARCH_unaligned): Remove
unused conditional includes.
* sysdeps/aarch64/bits/string.h (_STRING_INLINE_unaligned): Add define.
* sysdeps/m68k/m680x0/m68020/bits/string.h
(_STRING_INLINE_unaligned): Likewise.
* sysdeps/sparc/bits/string.h (_STRING_INLINE_unaligned): Likewise.
* sysdeps/s390/bits/string.h (_STRING_INLINE_unaligned): Likewise.
* sysdeps/x86/bits/string.h (_STRING_INLINE_unaligned): Likewise.
@@ -11,4 +11,11 @@
/* Define if architecture can access unaligned multi-byte variables. */
#define _STRING_ARCH_unaligned 0
+/* Define whether to use the unaligned string inline ABI.
+ The string inline functions are an external ABI, thus cannot be changed
+ after the first release of a new target (unlike _STRING_ARCH_unaligned
+ which may be changed from release to release). Targets must support
+ unaligned accesses in hardware if either define is set to true. */
+#define _STRING_INLINE_unaligned 0
+
#endif /* bits/string.h */
@@ -46,13 +46,6 @@
# endif
#endif
-#if _STRING_ARCH_unaligned
-/* If we can do unaligned memory accesses we must know the endianess. */
-# include <endian.h>
-# include <bits/types.h>
-
-#endif
-
/* Dereferencing a pointer arg to run sizeof on it fails for the void
pointer case, so we use this instead.
Note that __x is evaluated twice. */
@@ -48,7 +48,7 @@ __STRING2_COPY_TYPE (8);
# undef __STRING2_COPY_TYPE
-#if _STRING_ARCH_unaligned
+#if _STRING_INLINE_unaligned
__STRING_INLINE void *__mempcpy_small (void *, char, char, char, char,
__uint16_t, __uint16_t, __uint32_t,
__uint32_t, size_t);
@@ -165,7 +165,7 @@ __mempcpy_small (void *__dest, char __src1,
}
#endif
-# if _STRING_ARCH_unaligned
+# if _STRING_INLINE_unaligned
__STRING_INLINE char *
__strcpy_small (char *__dest,
__uint16_t __src0_2, __uint16_t __src4_2,
@@ -270,7 +270,7 @@ __strcpy_small (char *__dest,
#endif
-#if _STRING_ARCH_unaligned
+#if _STRING_INLINE_unaligned
__STRING_INLINE char *
__stpcpy_small (char *__dest,
__uint16_t __src0_2, __uint16_t __src4_2,
@@ -22,3 +22,6 @@
/* AArch64 implementations support efficient unaligned access. */
#define _STRING_ARCH_unaligned 1
+
+/* AArch64 uses the aligned string inline ABI. */
+#define _STRING_INLINE_unaligned 0
@@ -23,3 +23,6 @@
/* Currently the only purpose of this file is to tell the generic inline
macros that unaligned memory access is possible. */
#define _STRING_ARCH_unaligned 1
+
+/* Use the unaligned string inline ABI. */
+#define _STRING_INLINE_unaligned 1
@@ -24,6 +24,9 @@
/* The s390 processors can access unaligned multi-byte variables. */
#define _STRING_ARCH_unaligned 1
+/* Use the unaligned string inline ABI. */
+#define _STRING_INLINE_unaligned 1
+
/* We only provide optimizations if the user selects them and if
GNU CC is used. */
#if !defined __NO_STRING_INLINES && defined __USE_STRING_INLINES \
@@ -23,6 +23,9 @@
/* Define if architecture can access unaligned multi-byte variables. */
#define _STRING_ARCH_unaligned 0
+/* sparc uses the aligned string inline ABI. */
+#define _STRING_INLINE_unaligned 0
+
/* sparc32 and sparc64 strchr(x, '\0') perform better than
__rawmemchr(x, '\0'). */
#define _HAVE_STRING_ARCH_strchr 1
@@ -23,6 +23,9 @@
/* The ix86 processors can access unaligned multi-byte variables. */
#define _STRING_ARCH_unaligned 1
+/* Use the unaligned string inline ABI. */
+#define _STRING_INLINE_unaligned 1
+
/* Enable inline functions only for i486 or better when compiling for
ia32. */
#if !defined __x86_64__ && (defined __i486__ || defined __pentium__ \