From patchwork Mon Nov 28 16:00:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zack Weinberg X-Patchwork-Id: 17999 Received: (qmail 66084 invoked by alias); 28 Nov 2016 16:00:26 -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 65904 invoked by uid 89); 28 Nov 2016 16:00:18 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.5 required=5.0 tests=AWL, BAYES_00, KAM_STOCKGEN, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 spammy=H*r:166.84.1, H*r:sk:mailbac, H*m:panix, 2, 7 X-HELO: l2mail1.panix.com From: Zack Weinberg To: libc-alpha@sourceware.org Subject: [PATCH 2/5] Always suppress libc-internal declarations for C++ code. Date: Mon, 28 Nov 2016 11:00:04 -0500 Message-Id: <20161128160007.13994-3-zackw@panix.com> In-Reply-To: <20161128160007.13994-2-zackw@panix.com> References: <20161128160007.13994-1-zackw@panix.com> <20161128160007.13994-2-zackw@panix.com> 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 well make sense to enable _ISOMAC for all IS_IN (nonlib) code and/or to suppress most of libc-symbols.h itself in that mode, but when I tried that, lots of stuff broke. This is safe in the present state of the tree. 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. --- 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 -- 7 files changed, 10 insertions(+), 19 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, ...);