Patchwork Add _STRING_INLINE_unaligned

login
register
mail settings
Submitter H.J. Lu
Date Jan. 14, 2016, 7:24 p.m.
Message ID <CAMe9rOrGzoQ9YOaA62V9YjZJfNKZM1J2g6YkRfYxA2_vOxi52A@mail.gmail.com>
Download mbox | patch
Permalink /patch/10384/
State New
Headers show

Comments

H.J. Lu - Jan. 14, 2016, 7:24 p.m.
On Fri, Jan 8, 2016 at 9:37 AM, Wilco Dijkstra <Wilco.Dijkstra@arm.com> wrote:
> 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.
>
>
>

This patch can't be applied since it has odd characters.

Here is a patch to support -Os build.  Tested on x86-64 and
i686 without any code changes.

Can you combine your patch with mine to move
_STRING_ARCH_unaligned to string_private.h and add
STRING_INLINE_unaligned to bits/string.h?

Thanks.

Patch

From d00caa24e1fcda5e317e7dd825a4fa023aa27583 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Wed, 13 Jan 2016 17:26:00 -0800
Subject: [PATCH] Add string_private.h to define _STRING_ARCH_unaligned

_STRING_ARCH_unaligned is used unconditionally in glibc.  But
<bits/string.h>, which defines _STRING_ARCH_unaligned, isn't
included with -Os.  Since _STRING_ARCH_unaligned is internal to
glibc and may change between glibc releases, it should be made
private to glibc.  This patch adds string_private.h to define
_STRING_ARCH_unaligned, which is included unconditionally from
internal <string.h> for glibc build.

	[BZ #19462]
	* bits/string.h (_STRING_ARCH_unaligned): Removed.
	* include/string.h: Include <string_private.h>.
	* sysdeps/aarch64/bits/string.h: Renamed to ...
	* sysdeps/aarch64/string_private.h: This.
	* sysdeps/generic/string_private.h: New file.
	* sysdeps/s390/string_private.h: Likewise.
	* sysdeps/x86/string_private.h: Likewise.
	* sysdeps/m68k/m680x0/m68020/bits/string.h: Renamed to ...
	* sysdeps/m68k/m680x0/m68020/string_private.h: This.
	* sysdeps/s390/bits/string.h (_STRING_ARCH_unaligned): Removed.
	* sysdeps/sparc/bits/string.h (_STRING_ARCH_unaligned): Likewise.
	* sysdeps/x86/bits/string.h (_STRING_ARCH_unaligned): Likewise.
---
 bits/string.h                               |  3 ---
 include/string.h                            |  3 +++
 sysdeps/aarch64/bits/string.h               | 24 ------------------------
 sysdeps/aarch64/string_private.h            | 20 ++++++++++++++++++++
 sysdeps/generic/string_private.h            | 21 +++++++++++++++++++++
 sysdeps/m68k/m680x0/m68020/bits/string.h    | 25 -------------------------
 sysdeps/m68k/m680x0/m68020/string_private.h | 21 +++++++++++++++++++++
 sysdeps/s390/bits/string.h                  |  3 ---
 sysdeps/s390/string_private.h               | 20 ++++++++++++++++++++
 sysdeps/sparc/bits/string.h                 |  3 ---
 sysdeps/x86/bits/string.h                   |  3 ---
 sysdeps/x86/string_private.h                | 20 ++++++++++++++++++++
 12 files changed, 105 insertions(+), 61 deletions(-)
 delete mode 100644 sysdeps/aarch64/bits/string.h
 create mode 100644 sysdeps/aarch64/string_private.h
 create mode 100644 sysdeps/generic/string_private.h
 delete mode 100644 sysdeps/m68k/m680x0/m68020/bits/string.h
 create mode 100644 sysdeps/m68k/m680x0/m68020/string_private.h
 create mode 100644 sysdeps/s390/string_private.h
 create mode 100644 sysdeps/x86/string_private.h

diff --git a/bits/string.h b/bits/string.h
index b88a6bc..faa6870 100644
--- a/bits/string.h
+++ b/bits/string.h
@@ -8,7 +8,4 @@ 
 #ifndef _BITS_STRING_H
 #define _BITS_STRING_H	1
 
-/* Define if architecture can access unaligned multi-byte variables.  */
-#define _STRING_ARCH_unaligned   0
-
 #endif /* bits/string.h */
diff --git a/include/string.h b/include/string.h
index a684fd9..e145bfd 100644
--- a/include/string.h
+++ b/include/string.h
@@ -46,6 +46,9 @@  extern int __ffs (int __i) __attribute__ ((const));
 extern char *__strerror_r (int __errnum, char *__buf, size_t __buflen);
 #endif
 
+/* Get _STRING_ARCH_unaligned.  */
+#include <string_private.h>
+
 /* Now the real definitions.  We do this here since some of the functions
    above are defined as macros in the headers.  */
 #include <string/string.h>
diff --git a/sysdeps/aarch64/bits/string.h b/sysdeps/aarch64/bits/string.h
deleted file mode 100644
index 3c2a50b..0000000
--- a/sysdeps/aarch64/bits/string.h
+++ /dev/null
@@ -1,24 +0,0 @@ 
-/* Optimized, inlined string functions.  AArch64 version.
-   Copyright (C) 2015-2016 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/>.  */
-
-#ifndef _STRING_H
-# error "Never use <bits/string.h> directly; include <string.h> instead."
-#endif
-
-/* AArch64 implementations support efficient unaligned access.  */
-#define _STRING_ARCH_unaligned 1
diff --git a/sysdeps/aarch64/string_private.h b/sysdeps/aarch64/string_private.h
new file mode 100644
index 0000000..7e2af74
--- /dev/null
+++ b/sysdeps/aarch64/string_private.h
@@ -0,0 +1,20 @@ 
+/* Define _STRING_ARCH_unaligned.  AArch64 version.
+   Copyright (C) 2016 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/>.  */
+
+/* AArch64 implementations support efficient unaligned access.  */
+#define _STRING_ARCH_unaligned   1
diff --git a/sysdeps/generic/string_private.h b/sysdeps/generic/string_private.h
new file mode 100644
index 0000000..c880aae
--- /dev/null
+++ b/sysdeps/generic/string_private.h
@@ -0,0 +1,21 @@ 
+/* Define _STRING_ARCH_unaligned.  Generic version.
+   Copyright (C) 2016 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/>.  */
+
+/* Define to 1 if architecture can access unaligned multi-byte
+   variables.  */
+#define _STRING_ARCH_unaligned   0
diff --git a/sysdeps/m68k/m680x0/m68020/bits/string.h b/sysdeps/m68k/m680x0/m68020/bits/string.h
deleted file mode 100644
index 88505bb..0000000
--- a/sysdeps/m68k/m680x0/m68020/bits/string.h
+++ /dev/null
@@ -1,25 +0,0 @@ 
-/* Optimized, inlined string functions.  m680x0 version, x >= 2.
-   Copyright (C) 1997-2016 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/>.  */
-
-#ifndef _STRING_H
-# error "Never use <bits/string.h> directly; include <string.h> instead."
-#endif
-
-/* 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
diff --git a/sysdeps/m68k/m680x0/m68020/string_private.h b/sysdeps/m68k/m680x0/m68020/string_private.h
new file mode 100644
index 0000000..6846663
--- /dev/null
+++ b/sysdeps/m68k/m680x0/m68020/string_private.h
@@ -0,0 +1,21 @@ 
+/* Define _STRING_ARCH_unaligned.  m680x0 version, x >= 2.
+   Copyright (C) 2016 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/>.  */
+
+/* Tell the generic inline macros that unaligned memory access is
+   possible.  */
+#define _STRING_ARCH_unaligned   1
diff --git a/sysdeps/s390/bits/string.h b/sysdeps/s390/bits/string.h
index 09201d9..8e4d605 100644
--- a/sysdeps/s390/bits/string.h
+++ b/sysdeps/s390/bits/string.h
@@ -21,9 +21,6 @@ 
 # error "Never use <bits/string.h> directly; include <string.h> instead."
 #endif
 
-/* The s390 processors can access unaligned multi-byte variables.  */
-#define _STRING_ARCH_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/s390/string_private.h b/sysdeps/s390/string_private.h
new file mode 100644
index 0000000..9e11eee
--- /dev/null
+++ b/sysdeps/s390/string_private.h
@@ -0,0 +1,20 @@ 
+/* Define _STRING_ARCH_unaligned.  S/390 version.
+   Copyright (C) 2016 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/>.  */
+
+/* The s390 processors can access unaligned multi-byte variables.  */
+#define _STRING_ARCH_unaligned   1
diff --git a/sysdeps/sparc/bits/string.h b/sysdeps/sparc/bits/string.h
index 3054f62..336b58e 100644
--- a/sysdeps/sparc/bits/string.h
+++ b/sysdeps/sparc/bits/string.h
@@ -20,9 +20,6 @@ 
 # error "Never use <bits/string.h> directly; include <string.h> instead."
 #endif
 
-/* Define if architecture can access unaligned multi-byte variables.  */
-#define _STRING_ARCH_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 1a0682b..b952d38 100644
--- a/sysdeps/x86/bits/string.h
+++ b/sysdeps/x86/bits/string.h
@@ -20,9 +20,6 @@ 
 # error "Never use <bits/string.h> directly; include <string.h> instead."
 #endif
 
-/* The ix86 processors can access unaligned multi-byte variables.  */
-#define _STRING_ARCH_unaligned	1
-
 /* Enable inline functions only for i486 or better when compiling for
    ia32.  */
 #if !defined __x86_64__ && (defined __i486__ || defined __pentium__	      \
diff --git a/sysdeps/x86/string_private.h b/sysdeps/x86/string_private.h
new file mode 100644
index 0000000..e7281eb
--- /dev/null
+++ b/sysdeps/x86/string_private.h
@@ -0,0 +1,20 @@ 
+/* Define _STRING_ARCH_unaligned.  i486/x86-64 version.
+   Copyright (C) 2016 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/>.  */
+
+/* The ix86 processors can access unaligned multi-byte variables.  */
+#define _STRING_ARCH_unaligned   1
-- 
2.5.0