From patchwork Thu Jan 14 19:24:40 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 10384 Received: (qmail 14383 invoked by alias); 14 Jan 2016 19:24:46 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 14353 invoked by uid 89); 14 Jan 2016 19:24:45 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.2 required=5.0 tests=AWL, BAYES_50, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=87, Renamed, 1, 24, 2015-2016 X-HELO: mail-qk0-f171.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=90ePuhbhT461qu82TN1/iAv41T6/mCf1RX0XSUqN8t0=; b=I2L3py5QoeW4dMwV6mg88FKz7bzGmVgVphTB1dX5wFTPtdKNSA+O0HpN7nFX2q3uf1 HAjm3spQU2ohGuO4GF43YqzUGDsh4hu0JfmnARW5Qy/aIUyhZ0S4lCNXuXiT/RePBeXD DJHZjkxDWfZBDje0sa6ih0iqxrFVOtlWLj07v0QfOHfm61eyBZgPRsQZYDf4Jxkol2ke YurNdho9N9IsW+3rT8kwU2a6VsqVvoB9skd527eh+I44NwEVwnaTw2V19KdmJTR3+UBG sqlaEXbpQwL/VaV45VFu3nG5jAXbdoDP13gYh0xm39Fmy7GB2XK+RsOY3gTdQf2IidEe MIgw== X-Gm-Message-State: ALoCoQmCXo+Oe4/i+QK6/ep8KsazvUiNKYEE2V6gXRsReAkegqD92hVWw0bgEYdENSTjycDM/RCnAX+pY51gGmEcG/MjQXCEiA== MIME-Version: 1.0 X-Received: by 10.55.76.15 with SMTP id z15mr7964511qka.32.1452799480306; Thu, 14 Jan 2016 11:24:40 -0800 (PST) In-Reply-To: References: Date: Thu, 14 Jan 2016 11:24:40 -0800 Message-ID: Subject: Re: [PATCH] Add _STRING_INLINE_unaligned From: "H.J. Lu" To: Wilco Dijkstra Cc: GNU C Library , nd On Fri, Jan 8, 2016 at 9:37 AM, Wilco Dijkstra 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 > > * 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. From d00caa24e1fcda5e317e7dd825a4fa023aa27583 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" 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 , 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 for glibc build. [BZ #19462] * bits/string.h (_STRING_ARCH_unaligned): Removed. * include/string.h: Include . * 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 + /* Now the real definitions. We do this here since some of the functions above are defined as macros in the headers. */ #include 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 - . */ - -#ifndef _STRING_H -# error "Never use directly; include 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 + . */ + +/* 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 + . */ + +/* 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 - . */ - -#ifndef _STRING_H -# error "Never use directly; include 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 + . */ + +/* 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 directly; include 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 + . */ + +/* 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 directly; include 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 directly; include 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 + . */ + +/* The ix86 processors can access unaligned multi-byte variables. */ +#define _STRING_ARCH_unaligned 1 -- 2.5.0