From patchwork Mon Dec 7 23:41:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Myers X-Patchwork-Id: 41339 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A8F58386EC18; Mon, 7 Dec 2020 23:41:37 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from esa1.mentor.iphmx.com (esa1.mentor.iphmx.com [68.232.129.153]) by sourceware.org (Postfix) with ESMTPS id 33940385803E for ; Mon, 7 Dec 2020 23:41:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 33940385803E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=joseph_myers@mentor.com IronPort-SDR: e81uP4Lz5M7K92rTHD7dTINbMmk5cwGw4PVedGrsqq8BChvnuyqr1bwB1G4WiTYu2NA/Zv55Bu 6tAaQ9llBm72lxspV/XSVZ7akuuIhT6e3o5ye2J1DJacjSwQsRQh5HsAOuIEow9yb0PUwPEj9i GECkzaFDZmzLTkurgAe2qTn0g9tom/8nJwh81pdRusTlk1e/VElbEhV4/gBPGfKd8Ir54hB3yO Asb6Fi821JgYgWba1IZwFr7T6XrGVGkWGJyJHzJTuVjDhzz3ypS1JofU3xNlOpXkBTiaEL6syJ 7uk= X-IronPort-AV: E=Sophos;i="5.78,401,1599552000"; d="scan'208";a="58196094" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa1.mentor.iphmx.com with ESMTP; 07 Dec 2020 15:41:32 -0800 IronPort-SDR: ySgQM52/RTpfS1c6th75VQfaU/1IfchfDyAppWZwfn8esCdQCRLBkPxkfF6lbWd1G3hPnaGaB3 JrCtVTa10uhN5kfPoZD/iLXOkB2FH4uGpscY8h6Qdy0E5UY9mhJ+V35lzJsfGcuZj4b184CzST 0VyoZXI0LY8kiMPYrXUUWvPiPs/TWC9XagUcL8WgInjmSaTnRsYwsfkjrmJIUBBqWWW76tmz6y UxMwnj4UuBZYeNxdNROhRAgjXx9SdeAD9df7KzNa0MXWl95hjDafaaGRXRgNsozs8zYAA8UPQA d7E= Date: Mon, 7 Dec 2020 23:41:25 +0000 From: Joseph Myers X-X-Sender: jsm28@digraph.polyomino.org.uk To: Subject: Make strtoimax, strtoumax, wcstoimax, wcstoumax into aliases Message-ID: User-Agent: Alpine 2.22 (DEB 394 2020-01-19) MIME-Version: 1.0 X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: SVR-IES-MBX-07.mgc.mentorg.com (139.181.222.7) To svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) X-Spam-Status: No, score=-3130.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, KAM_SHORT, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" The functions strtoimax, strtoumax, wcstoimax, wcstoumax currently have three implementations each (wordsize-32, wordsize-64 and dummy implementation in stdlib/ using #error), defining the functions as thin wrappers round corresponding *_internal functions. Simplify the code by changing them into aliases of functions such as strtol and wcstoull. This is more consistent with how e.g. imaxdiv is handled. Tested for x86_64 and x86. --- I propose to remove the inline functions in inttypes.h in a separate patch (matching the removal from stdlib.h and wchar.h in commit 9b2e9577b228350b15d88303b00097dd58e8d29b in 2007). diff --git a/stdlib/Makefile b/stdlib/Makefile index f8a1660186..29b7cd7071 100644 --- a/stdlib/Makefile +++ b/stdlib/Makefile @@ -56,7 +56,6 @@ routines := \ system canonicalize \ a64l l64a \ rpmatch strfmon strfmon_l getsubopt xpg_basename fmtmsg \ - strtoimax strtoumax wcstoimax wcstoumax \ getcontext setcontext makecontext swapcontext aux = grouping groupingwc tens_in_limb diff --git a/stdlib/strtoimax.c b/stdlib/strtoimax.c deleted file mode 100644 index f1de70f320..0000000000 --- a/stdlib/strtoimax.c +++ /dev/null @@ -1 +0,0 @@ -#error "The correct implementation must be chosen based on the `intmax_t' type" diff --git a/stdlib/strtoll.c b/stdlib/strtoll.c index b156665fc7..a6b693a341 100644 --- a/stdlib/strtoll.c +++ b/stdlib/strtoll.c @@ -30,4 +30,5 @@ compat_symbol (libc, __strtoll_internal, __strtoq_internal, GLIBC_2_0); # endif weak_alias (strtoll, strtoq) +weak_alias (strtoll, strtoimax) #endif diff --git a/stdlib/strtoull.c b/stdlib/strtoull.c index b4bf9a97d9..dd57aa550c 100644 --- a/stdlib/strtoull.c +++ b/stdlib/strtoull.c @@ -30,4 +30,5 @@ compat_symbol (libc, __strtoull_internal, __strtouq_internal, GLIBC_2_0); # endif weak_alias (strtoull, strtouq) +weak_alias (strtoull, strtoumax) #endif diff --git a/stdlib/strtoumax.c b/stdlib/strtoumax.c deleted file mode 100644 index 508cb19f8c..0000000000 --- a/stdlib/strtoumax.c +++ /dev/null @@ -1 +0,0 @@ -#error "The correct implementation must be chosen based on the `uintmax_t' type" diff --git a/stdlib/wcstoimax.c b/stdlib/wcstoimax.c deleted file mode 100644 index f1de70f320..0000000000 --- a/stdlib/wcstoimax.c +++ /dev/null @@ -1 +0,0 @@ -#error "The correct implementation must be chosen based on the `intmax_t' type" diff --git a/stdlib/wcstoumax.c b/stdlib/wcstoumax.c deleted file mode 100644 index 508cb19f8c..0000000000 --- a/stdlib/wcstoumax.c +++ /dev/null @@ -1 +0,0 @@ -#error "The correct implementation must be chosen based on the `uintmax_t' type" diff --git a/sysdeps/wordsize-32/strtoimax.c b/sysdeps/wordsize-32/strtoimax.c deleted file mode 100644 index be1b71ee2c..0000000000 --- a/sysdeps/wordsize-32/strtoimax.c +++ /dev/null @@ -1,27 +0,0 @@ -/* Convert string to maximal integer. - Copyright (C) 1997-2020 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper , 1997. - - 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 - . */ - -#include -#include - -intmax_t -strtoimax (const char *__restrict nptr, char **__restrict endptr, int base) -{ - return __strtoll_internal (nptr, endptr, base, 0); -} diff --git a/sysdeps/wordsize-32/strtoumax.c b/sysdeps/wordsize-32/strtoumax.c deleted file mode 100644 index c6f090cfc5..0000000000 --- a/sysdeps/wordsize-32/strtoumax.c +++ /dev/null @@ -1,28 +0,0 @@ -/* Convert string to maximal unsigned integer. - Copyright (C) 1997-2020 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper , 1997. - - 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 - . */ - -#include -#include - -uintmax_t -strtoumax (const char *__restrict nptr, char **__restrict endptr, int base) -{ - return __strtoull_internal (nptr, endptr, base, 0); -} -libc_hidden_def (strtoumax) diff --git a/sysdeps/wordsize-32/wcstoimax.c b/sysdeps/wordsize-32/wcstoimax.c deleted file mode 100644 index ce7255859b..0000000000 --- a/sysdeps/wordsize-32/wcstoimax.c +++ /dev/null @@ -1,28 +0,0 @@ -/* Convert wide-character string to maximal integer. - Copyright (C) 1997-2020 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper , 1997. - - 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 - . */ - -#include -#include - -intmax_t -wcstoimax (const wchar_t *__restrict nptr, wchar_t **__restrict endptr, - int base) -{ - return __wcstoll_internal (nptr, endptr, base, 0); -} diff --git a/sysdeps/wordsize-32/wcstoumax.c b/sysdeps/wordsize-32/wcstoumax.c deleted file mode 100644 index ee47b250dc..0000000000 --- a/sysdeps/wordsize-32/wcstoumax.c +++ /dev/null @@ -1,28 +0,0 @@ -/* Convert wide-character string to maximal unsigned integer. - Copyright (C) 1997-2020 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper , 1997. - - 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 - . */ - -#include -#include - -uintmax_t -wcstoumax (const wchar_t *__restrict nptr, wchar_t **__restrict endptr, - int base) -{ - return __wcstoull_internal (nptr, endptr, base, 0); -} diff --git a/sysdeps/wordsize-64/strtoimax.c b/sysdeps/wordsize-64/strtoimax.c deleted file mode 100644 index 9df5f2f250..0000000000 --- a/sysdeps/wordsize-64/strtoimax.c +++ /dev/null @@ -1,27 +0,0 @@ -/* Convert string to maximal integer. - Copyright (C) 1997-2020 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper , 1997. - - 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 - . */ - -#include -#include - -intmax_t -strtoimax (const char *__restrict nptr, char **__restrict endptr, int base) -{ - return __strtol_internal (nptr, endptr, base, 0); -} diff --git a/sysdeps/wordsize-64/strtol.c b/sysdeps/wordsize-64/strtol.c index ac17bbe4c8..a1b2374153 100644 --- a/sysdeps/wordsize-64/strtol.c +++ b/sysdeps/wordsize-64/strtol.c @@ -14,3 +14,4 @@ weak_alias (strtol, strtoll) libc_hidden_ver (strtol, strtoll) weak_alias (strtol, strtoq) libc_hidden_ver (strtol, strtoq) +weak_alias (strtol, strtoimax) diff --git a/sysdeps/wordsize-64/strtoul.c b/sysdeps/wordsize-64/strtoul.c index 401882ce0d..856aa11dee 100644 --- a/sysdeps/wordsize-64/strtoul.c +++ b/sysdeps/wordsize-64/strtoul.c @@ -12,3 +12,4 @@ strong_alias (__strtoul_internal, __strtoull_internal) libc_hidden_ver (__strtoul_internal, __strtoull_internal) weak_alias (strtoul, strtoull) weak_alias (strtoul, strtouq) +weak_alias (strtoul, strtoumax) diff --git a/sysdeps/wordsize-64/strtoumax.c b/sysdeps/wordsize-64/strtoumax.c deleted file mode 100644 index aad697bb40..0000000000 --- a/sysdeps/wordsize-64/strtoumax.c +++ /dev/null @@ -1,28 +0,0 @@ -/* Convert string to maximal unsigned integer. - Copyright (C) 1997-2020 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper , 1997. - - 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 - . */ - -#include -#include - -uintmax_t -strtoumax (const char *__restrict nptr, char **__restrict endptr, int base) -{ - return __strtoul_internal (nptr, endptr, base, 0); -} -libc_hidden_def (strtoumax) diff --git a/sysdeps/wordsize-64/wcstoimax.c b/sysdeps/wordsize-64/wcstoimax.c deleted file mode 100644 index 6a91737936..0000000000 --- a/sysdeps/wordsize-64/wcstoimax.c +++ /dev/null @@ -1,28 +0,0 @@ -/* Convert wide-character string to maximal integer. - Copyright (C) 1997-2020 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper , 1997. - - 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 - . */ - -#include -#include - -intmax_t -wcstoimax (const wchar_t *__restrict nptr, wchar_t **__restrict endptr, - int base) -{ - return __wcstol_internal (nptr, endptr, base, 0); -} diff --git a/sysdeps/wordsize-64/wcstol.c b/sysdeps/wordsize-64/wcstol.c index b10895a82b..f99c273d95 100644 --- a/sysdeps/wordsize-64/wcstol.c +++ b/sysdeps/wordsize-64/wcstol.c @@ -12,3 +12,4 @@ strong_alias (__wcstol_internal, __wcstoll_internal) libc_hidden_ver (__wcstol_internal, __wcstoll_internal) weak_alias (wcstol, wcstoll) weak_alias (wcstol, wcstoq) +weak_alias (wcstol, wcstoimax) diff --git a/sysdeps/wordsize-64/wcstoul.c b/sysdeps/wordsize-64/wcstoul.c index 2becb80744..e1458e17f3 100644 --- a/sysdeps/wordsize-64/wcstoul.c +++ b/sysdeps/wordsize-64/wcstoul.c @@ -12,3 +12,4 @@ strong_alias (__wcstoul_internal, __wcstoull_internal) libc_hidden_ver (__wcstoul_internal, __wcstoull_internal) weak_alias (wcstoul, wcstoull) weak_alias (wcstoul, wcstouq) +weak_alias (wcstoul, wcstoumax) diff --git a/sysdeps/wordsize-64/wcstoumax.c b/sysdeps/wordsize-64/wcstoumax.c deleted file mode 100644 index c11053c5b6..0000000000 --- a/sysdeps/wordsize-64/wcstoumax.c +++ /dev/null @@ -1,28 +0,0 @@ -/* Convert wide-character string to maximal unsigned integer. - Copyright (C) 1997-2020 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper , 1997. - - 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 - . */ - -#include -#include - -uintmax_t -wcstoumax (const wchar_t *__restrict nptr, wchar_t **__restrict endptr, - int base) -{ - return __wcstoul_internal (nptr, endptr, base, 0); -} diff --git a/wcsmbs/wcstoll.c b/wcsmbs/wcstoll.c index 9f5ea00ef6..2871db8884 100644 --- a/wcsmbs/wcstoll.c +++ b/wcsmbs/wcstoll.c @@ -22,3 +22,4 @@ #include "wcstol.c" weak_alias (wcstoll, wcstoq) +weak_alias (wcstoll, wcstoimax) diff --git a/wcsmbs/wcstoull.c b/wcsmbs/wcstoull.c index 7ba8ebde83..b9080302f3 100644 --- a/wcsmbs/wcstoull.c +++ b/wcsmbs/wcstoull.c @@ -22,3 +22,4 @@ #include "wcstoul.c" weak_alias (wcstoull, wcstouq) +weak_alias (wcstoull, wcstoumax)