From patchwork Thu Feb 1 20:35:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Myers X-Patchwork-Id: 25735 Received: (qmail 112710 invoked by alias); 1 Feb 2018 20:35: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 112696 invoked by uid 89); 1 Feb 2018 20:35:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS, URIBL_RED autolearn=ham version=3.3.2 spammy= X-HELO: relay1.mentorg.com Date: Thu, 1 Feb 2018 20:35:38 +0000 From: Joseph Myers To: Subject: Fix non-__GNUC__ definitions of __inline and __restrict (bug 17721) Message-ID: User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 X-ClientProxiedBy: svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) To svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) Bug 17721 reports that the non-__GNUC__ definitions of __inline and __restrict are suboptimal, in that they are defined to empty when they could be defined to inline and restrict for appropriate language versions. This patch makes those fixes. Tested for x86_64 (however, I have not done any testing with an actual non-__GNUC__ compiler and it's likely such compilers may have other problems with glibc headers). 2018-02-01 Joseph Myers [BZ #17721] * misc/sys/cdefs.h [!__GNUC__ && (__cplusplus || (__STDC_VERSION__ && __STDC_VERSION__ >= 199901L))] (__inline): Define to inline. [!__GNUC_PREREQ (2,92) && __STDC_VERSION__ && __STDC_VERSION__ >= 199901L] (__restrict): Define to restrict. Reviewed-by: Adhemerval Zanella diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h index af103fd..e80a45c 100644 --- a/misc/sys/cdefs.h +++ b/misc/sys/cdefs.h @@ -72,7 +72,12 @@ #else /* Not GCC. */ -# define __inline /* No inline functions. */ +# if (defined __cplusplus \ + || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L)) +# define __inline inline +# else +# define __inline /* No inline functions. */ +# endif # define __THROW # define __THROWNL @@ -368,7 +373,11 @@ /* __restrict is known in EGCS 1.2 and above. */ #if !__GNUC_PREREQ (2,92) -# define __restrict /* Ignore */ +# if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L +# define __restrict restrict +# else +# define __restrict /* Ignore */ +# endif #endif /* ISO C99 also allows to declare arrays as non-overlapping. The syntax is