This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH] Add _STRING_INLINE_unaligned
- From: Wilco Dijkstra <Wilco dot Dijkstra at arm dot com>
- To: 'GNU C Library' <libc-alpha at sourceware dot org>
- Cc: nd <nd at arm dot com>
- Date: Fri, 8 Jan 2016 17:37:46 +0000
- Subject: [PATCH] Add _STRING_INLINE_unaligned
- Authentication-results: sourceware.org; auth=none
- Nodisclaimer: True
- Spamdiagnosticmetadata: NSPM
- Spamdiagnosticoutput: 1:23
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.
diff --git a/bits/string.h b/bits/string.h
index b88a6bc601803f68a19531d86ce7acdaec65b93b..738d9994a6d4b8df0899a45171fd467156f0fec1 100644
--- a/bits/string.h
+++ b/bits/string.h
@@ -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 */
diff --git a/string/bits/string2.h b/string/bits/string2.h
index f8ea1f9538c19427edae933a9c2fcf111b226bb5..cff529728b7d31f207c6c43aedae4a1b0df4b4b4 100644
--- a/string/bits/string2.h
+++ b/string/bits/string2.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. */
diff --git a/string/string-inlines.c b/string/string-inlines.c
index 432d58d8c69771d52e10218cebb8ec125c36faa9..4e91329df22b9c604fff1e833212a8b778c36390 100644
--- a/string/string-inlines.c
+++ b/string/string-inlines.c
@@ -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,
diff --git a/sysdeps/aarch64/bits/string.h b/sysdeps/aarch64/bits/string.h
index 5221e69e27610527c89233b3ac74e9c569855694..01421ed28103939a98b0ed3555917ac2aa43254e 100644
--- a/sysdeps/aarch64/bits/string.h
+++ b/sysdeps/aarch64/bits/string.h
@@ -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
diff --git a/sysdeps/m68k/m680x0/m68020/bits/string.h b/sysdeps/m68k/m680x0/m68020/bits/string.h
index b593f4a81f3ad15abe3f3079a8f1350d419caf2b..2fdfc6bf7ba93fd7b73913cf86700facc905bf2b 100644
--- a/sysdeps/m68k/m680x0/m68020/bits/string.h
+++ b/sysdeps/m68k/m680x0/m68020/bits/string.h
@@ -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
diff --git a/sysdeps/s390/bits/string.h b/sysdeps/s390/bits/string.h
index d99039ef89bc797e279ae6f1b37202c1613f3393..7c407f3f4cf5e54972797947d389dc4da998c312 100644
--- a/sysdeps/s390/bits/string.h
+++ b/sysdeps/s390/bits/string.h
@@ -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 \
diff --git a/sysdeps/sparc/bits/string.h b/sysdeps/sparc/bits/string.h
index 4eb94473fbfb4018afd6e92bb3410d6cd2c0032e..1c0603823ec5df48ccaf80388258b7ec92893bc1 100644
--- a/sysdeps/sparc/bits/string.h
+++ b/sysdeps/sparc/bits/string.h
@@ -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
diff --git a/sysdeps/x86/bits/string.h b/sysdeps/x86/bits/string.h
index 4973620b83e34ae39cd6f8a599e7c9e7e7eed6c2..30c4517f37a63ad15d7a44bba60b19d441a737fe 100644
--- a/sysdeps/x86/bits/string.h
+++ b/sysdeps/x86/bits/string.h
@@ -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__ \