From patchwork Mon Nov 21 17:42:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zack Weinberg X-Patchwork-Id: 17674 Received: (qmail 65809 invoked by alias); 21 Nov 2016 17:42:13 -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 65796 invoked by uid 89); 21 Nov 2016 17:42:12 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.3 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=no version=3.3.2 spammy=errnoh, errno.h, UD:wchar.h, wchar.h X-HELO: mail-qt0-f193.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:from:message-id:date:user-agent :mime-version:content-transfer-encoding; bh=BLEXFQ+aE4RM1luK7MfFJWwhCh6Xrq3avi/KD4OjhdM=; b=JpgsTk4B3u+SiGRNr7TyD8E04uwhUlE0h5fo7OjAiJJRIFyHN0TkhelhxKkRNiLsHc lP7/IJMoYUUJpTCz77HGMdxoYGPTi3D+iM45h5e2riiHtJP1xBJuu1f7NX8DeraBlkQz 0GwS6jp6sbXH08s5u4354+ho+j7K6JkiZ0IKENPr5mIDUags08CfU3k7MQixyQy8imy4 fOZ/rttcZXDHhbiQazxAhbZr9Bnm3OPoKXKv/otOzNevN2gBbWOpMHbTUw5mgPaZcHPf MNkzSSIK6IZRs875ryK5o3mwTvxr4wltLewhmfnTvDDXL4biJnRe9D75kV15z5XVx5oW kg+g== X-Gm-Message-State: AKaTC01vnuYQZ3tlSjMYYnwFcEhIIrbjtOei+cdn3r98c4f9ZU13//j5Ces2vz32MQMY3Q== X-Received: by 10.237.61.202 with SMTP id j10mr9841166qtf.121.1479750128578; Mon, 21 Nov 2016 09:42:08 -0800 (PST) Subject: [PATCH] Always suppress libc-internal declarations for C++ code. To: GNU C Library From: Zack Weinberg X-Forwarded-Message-Id: Message-ID: <2bd51680-f831-14a3-ed52-ceeec6eb9709@panix.com> Date: Mon, 21 Nov 2016 12:42:06 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.4.0 MIME-Version: 1.0 C++ is only used for tests, and some of the internal declarations are not C++-safe. Rather than playing whack-a-mole with problems, just turn on _ISOMAC mode for all C++ code. (It might make sense to do this for all IS_IN(nonlib) code as well, and it might also make sense to suppress most of libc-symbols.h in either or both cases, but when I tried that it looked to have more fallout than I feel like dealing with today.) This flushed out some minor problems: test-skeleton.c uses uintptr_t but wasn't including , libio.h tested _GNU_SOURCE instead of __USE_GNU in one place. Tested on x86_64-linux-gnu and compile-tested on everything else using Joseph's build-many-glibcs script. OK? zw * include/libc-symbols.h: Define _ISOMAC when __cplusplus is defined. * include/errno.h, include/stdio.h, include/stdlib.h * include/time.h, include/unistd.h, include/wchar.h: No need to check __cplusplus nor use __BEGIN_DECLS/__END_DECLS. * test-skeleton.c: Include when thread-testing API is activated. * libio/libio.h: Use __USE_GNU, not _GNU_SOURCE. --- include/errno.h | 2 +- include/libc-symbols.h | 9 +++++++++ include/stdio.h | 5 ----- include/stdlib.h | 4 ---- include/time.h | 4 ---- include/unistd.h | 3 --- include/wchar.h | 2 -- libio/libio.h | 2 +- test-skeleton.c | 1 + 9 files changed, 12 insertions(+), 20 deletions(-) diff --git a/include/errno.h b/include/errno.h index 7df41df..73fc32e 100644 --- a/include/errno.h +++ b/include/errno.h @@ -2,7 +2,7 @@ #include -#if defined _ERRNO_H && !defined _ISOMAC && !defined __cplusplus +#if defined _ERRNO_H && !defined _ISOMAC # if IS_IN (rtld) # include diff --git a/include/libc-symbols.h b/include/libc-symbols.h index 1c91f2e..a7d96cc 100644 --- a/include/libc-symbols.h +++ b/include/libc-symbols.h @@ -76,6 +76,15 @@ #define HAVE_ISWCTYPE 1 #define ENABLE_NLS 1 +/* As C++ is only used in tests, and the internal-use declarations + found in wrapper headers in include/ are not always C++-safe, + instruct those headers not to provide any of those declarations + when compiling C++. */ + +#ifdef __cplusplus +# define _ISOMAC 1 +#endif + /* The symbols in all the user (non-_) macros are C symbols. */ #ifndef __SYMBOL_PREFIX diff --git a/include/stdio.h b/include/stdio.h index 30e737e..266c3bb 100644 --- a/include/stdio.h +++ b/include/stdio.h @@ -5,7 +5,6 @@ # include /* Now define the internal interfaces. */ -__BEGIN_DECLS extern int __fcloseall (void); extern int __snprintf (char *__restrict __s, size_t __maxlen, @@ -30,7 +29,6 @@ extern int __vsscanf (const char *__restrict __s, _G_va_list __arg) __attribute__ ((__format__ (__scanf__, 2, 0))); -# ifndef __cplusplus extern int __sprintf_chk (char *, int, size_t, const char *, ...) __THROW; extern int __snprintf_chk (char *, size_t, int, size_t, const char *, ...) __THROW; @@ -52,7 +50,6 @@ extern int __obstack_printf_chk (struct obstack *, int, const char *, ...) __THROW; extern int __obstack_vprintf_chk (struct obstack *, int, const char *, _G_va_list) __THROW; -# endif extern int __isoc99_fscanf (FILE *__restrict __stream, const char *__restrict __format, ...) __wur; @@ -202,7 +199,5 @@ gets (char *__str) extern FILE * __fmemopen (void *buf, size_t len, const char *mode); libc_hidden_proto (__fmemopen) -__END_DECLS # endif - #endif diff --git a/include/stdlib.h b/include/stdlib.h index 352339e..8039876 100644 --- a/include/stdlib.h +++ b/include/stdlib.h @@ -13,8 +13,6 @@ #if !defined __Need_M_And_C && !defined _ISOMAC # include -__BEGIN_DECLS - extern __typeof (strtol_l) __strtol_l; extern __typeof (strtoul_l) __strtoul_l; extern __typeof (strtoll_l) __strtoll_l; @@ -265,8 +263,6 @@ extern __typeof (unsetenv) unsetenv attribute_hidden; extern __typeof (__strtoul_internal) __strtoul_internal attribute_hidden; # endif -__END_DECLS - #endif #undef __Need_M_And_C diff --git a/include/time.h b/include/time.h index 684ceb8..8fe1818 100644 --- a/include/time.h +++ b/include/time.h @@ -4,8 +4,6 @@ #ifndef _ISOMAC # include -__BEGIN_DECLS - extern __typeof (strftime_l) __strftime_l; libc_hidden_proto (__strftime_l) extern __typeof (strptime_l) __strptime_l; @@ -112,7 +110,5 @@ extern double __difftime (time_t time1, time_t time0); actual clock ID. */ #define CLOCK_IDFIELD_SIZE 3 -__END_DECLS - #endif #endif diff --git a/include/unistd.h b/include/unistd.h index 16d68a1..fbcea1b 100644 --- a/include/unistd.h +++ b/include/unistd.h @@ -2,7 +2,6 @@ # include # ifndef _ISOMAC -__BEGIN_DECLS libc_hidden_proto (_exit, __noreturn__) rtld_hidden_proto (_exit, __noreturn__) @@ -188,7 +187,5 @@ extern int __getlogin_r_loginuid (char *name, size_t namesize) extern __typeof (__access) __access_noerrno attribute_hidden; # endif -__END_DECLS # endif - #endif diff --git a/include/wchar.h b/include/wchar.h index 6272130..e2579a1 100644 --- a/include/wchar.h +++ b/include/wchar.h @@ -172,7 +172,6 @@ extern int __vfwprintf (__FILE *__restrict __s, const wchar_t *__restrict __format, __gnuc_va_list __arg) /* __attribute__ ((__format__ (__wprintf__, 2, 0))) */; -#ifndef __cplusplus extern int __vfwprintf_chk (FILE *__restrict __s, int __flag, const wchar_t *__restrict __format, __gnuc_va_list __arg) @@ -184,7 +183,6 @@ extern int __vswprintf_chk (wchar_t *__restrict __s, size_t __n, /* __attribute__ ((__format__ (__wprintf__, 5, 0))) */; libc_hidden_proto (__vfwprintf_chk) libc_hidden_proto (__vswprintf_chk) -#endif extern int __isoc99_fwscanf (__FILE *__restrict __stream, const wchar_t *__restrict __format, ...); diff --git a/libio/libio.h b/libio/libio.h index efd09f1..f4ead83 100644 --- a/libio/libio.h +++ b/libio/libio.h @@ -353,7 +353,7 @@ typedef int __io_seek_fn (void *__cookie, _IO_off64_t *__pos, int __w); typedef int __io_close_fn (void *__cookie); -#ifdef _GNU_SOURCE +#ifdef __USE_GNU /* User-visible names for the above. */ typedef __io_read_fn cookie_read_function_t; typedef __io_write_fn cookie_write_function_t; diff --git a/test-skeleton.c b/test-skeleton.c index fa457be..c7954ca 100644 --- a/test-skeleton.c +++ b/test-skeleton.c @@ -611,6 +611,7 @@ main (int argc, char *argv[]) /* The following functionality is only available if was included before this file. */ #ifdef _PTHREAD_H +#include /* Call pthread_sigmask with error checking. */ static void -- 2.10.2