From patchwork Fri Jan 8 17:37:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wilco Dijkstra X-Patchwork-Id: 10296 Received: (qmail 54587 invoked by alias); 8 Jan 2016 17:37:57 -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 54245 invoked by uid 89); 8 Jan 2016 17:37:56 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL, BAYES_00, KAM_LOTSOFHASH, SPF_PASS autolearn=no version=3.3.2 spammy=233, H*r:15.1.365, H*RU:15.1.365.19, Hx-spam-relays-external:15.1.365.19 X-HELO: eu-smtp-delivery-143.mimecast.com From: Wilco Dijkstra To: 'GNU C Library' CC: nd Subject: [PATCH] Add _STRING_INLINE_unaligned Date: Fri, 8 Jan 2016 17:37:46 +0000 Message-ID: x-microsoft-exchange-diagnostics: 1; AM3PR08MB0086; 5:8g7gK/nGODd5q5gpd9/aDSgI7eYAPfxHsLnngJhsHqZ5stG6rE1ihtqeNfOaSSln5UtEUE+sGAyTmDmQ6q7MGKnyzf1XqDFBpz7ZL9/OLlTFeQjoGa/WGcyTgK+MPzgc6nW5jQbNPMX4PhKC4KZiDA==; 24:edXIi68OaSLGP4Gb06pzffT3K65fjZauxQoMM4oOFwOh4n1004xRQGhYLA9LWS/ZWKX1cAKBZhbiMKOqdRO0xYcVepeiTQwCx8yzEmMgOS0=; 20:NpGdMRExSlqi2a2wFr9TSG5oNE5y40pCNfsdLvJxkeMqVuA0XtRRUN/7bD8vrpS5Mc+rEq3JHy7KbWy1WTXFILc2mfYs8OaJbNWQKtRmNTT1ev5MScSo6rwiUvyxnKC8Za9zuy3bgoBQE9tPKbMof1Nm4X7qJBCs4crCJy1P2qk= x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:AM3PR08MB0086; x-ms-office365-filtering-correlation-id: 6352a80d-df30-4def-1309-08d318526c16 nodisclaimer: True x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(180628864354917); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(8121501046)(520078)(3002001)(10201501046); SRVR:AM3PR08MB0086; BCL:0; PCL:0; RULEID:; SRVR:AM3PR08MB0086; x-forefront-prvs: 0815F8251E x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6009001)(377424004)(189002)(54534003)(199003)(81156007)(54356999)(575784001)(229853001)(86362001)(3846002)(1220700001)(586003)(102836003)(97736004)(92566002)(1096002)(6116002)(5001960100002)(110136002)(5002640100001)(5003600100002)(76576001)(5008740100001)(106116001)(106356001)(105586002)(33656002)(101416001)(19580395003)(450100001)(87936001)(50986999)(74316001)(189998001)(19580405001)(66066001)(4326007)(40100003)(5004730100002)(5250100002)(2906002)(2900100001)(15975445007); DIR:OUT; SFP:1101; SCL:1; SRVR:AM3PR08MB0086; H:AM3PR08MB0088.eurprd08.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; spamdiagnosticoutput: 1:23 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Jan 2016 17:37:46.6642 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM3PR08MB0086 X-MC-Unique: c5We7RRnQeuNentn_OxcWA-1 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. 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 -# include - -#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__ \