* [PATCH] Always suppress libc-internal declarations for C++ code.
@ 2016-11-21 17:42 Zack Weinberg
2016-11-27 6:50 ` Mike Frysinger
0 siblings, 1 reply; 4+ messages in thread
From: Zack Weinberg @ 2016-11-21 17:42 UTC (permalink / raw)
To: GNU C Library
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 <stdint.h>, 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 <stdint.h> 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 <stdlib/errno.h>
-#if defined _ERRNO_H && !defined _ISOMAC && !defined __cplusplus
+#if defined _ERRNO_H && !defined _ISOMAC
# if IS_IN (rtld)
# include <dl-sysdep.h>
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 <libio/stdio.h>
/* 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 <sys/stat.h>
-__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 <xlocale.h>
-__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 <posix/unistd.h>
# 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 <pthread.h> was
included before this file. */
#ifdef _PTHREAD_H
+#include <stdint.h>
/* Call pthread_sigmask with error checking. */
static void
--
2.10.2
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Always suppress libc-internal declarations for C++ code.
2016-11-21 17:42 [PATCH] Always suppress libc-internal declarations for C++ code Zack Weinberg
@ 2016-11-27 6:50 ` Mike Frysinger
2016-11-27 17:37 ` Zack Weinberg
0 siblings, 1 reply; 4+ messages in thread
From: Mike Frysinger @ 2016-11-27 6:50 UTC (permalink / raw)
To: Zack Weinberg; +Cc: GNU C Library
[-- Attachment #1: Type: text/plain, Size: 355 bytes --]
On 21 Nov 2016 12:42, Zack Weinberg wrote:
> This flushed out some minor problems: test-skeleton.c uses uintptr_t
> but wasn't including <stdint.h>
seems like this should be installed as obvious by itself
> libio.h tested _GNU_SOURCE instead of __USE_GNU in one place.
makes sense regardless too
a quick grep shows fnmatch.h has a similar error
-mike
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Always suppress libc-internal declarations for C++ code.
2016-11-27 6:50 ` Mike Frysinger
@ 2016-11-27 17:37 ` Zack Weinberg
2016-11-27 20:49 ` Mike Frysinger
0 siblings, 1 reply; 4+ messages in thread
From: Zack Weinberg @ 2016-11-27 17:37 UTC (permalink / raw)
To: GNU C Library
On Sun, Nov 27, 2016 at 1:50 AM, Mike Frysinger <vapier@gentoo.org> wrote:
> On 21 Nov 2016 12:42, Zack Weinberg wrote:
>> This flushed out some minor problems: test-skeleton.c uses uintptr_t
>> but wasn't including <stdint.h>
>
> seems like this should be installed as obvious by itself
Done (patch appended)
>> libio.h tested _GNU_SOURCE instead of __USE_GNU in one place.
>
> makes sense regardless too
Also done
> a quick grep shows fnmatch.h has a similar error
Isn't fnmatch.h shared with gnulib? I don't feel like I understand
the constraints on code shared with gnulib, certainly not enough to
call it "obvious." Also, some of the conditionals in there don't make
sense to me ("#if !defined _POSIX_C_SOURCE || _POSIX_C_SOURCE < 2 ||
defined _GNU_SOURCE" -- what's that even supposed to do?)
zw
* libio/libio.h: Use __USE_GNU, not _GNU_SOURCE, in a conditional.
* test-skeleton.c: Include stdint.h to ensure uintptr_t is available.
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
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..154096f 100644
--- a/test-skeleton.c
+++ b/test-skeleton.c
@@ -33,6 +33,7 @@
#include <sys/wait.h>
#include <sys/param.h>
#include <time.h>
+#include <stdint.h>
/* The test function is normally called `do_test' and it is called
with argc and argv as the arguments. We nevertheless provide the
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Always suppress libc-internal declarations for C++ code.
2016-11-27 17:37 ` Zack Weinberg
@ 2016-11-27 20:49 ` Mike Frysinger
0 siblings, 0 replies; 4+ messages in thread
From: Mike Frysinger @ 2016-11-27 20:49 UTC (permalink / raw)
To: Zack Weinberg; +Cc: GNU C Library
[-- Attachment #1: Type: text/plain, Size: 1016 bytes --]
On 27 Nov 2016 12:37, Zack Weinberg wrote:
> On Sun, Nov 27, 2016 at 1:50 AM, Mike Frysinger <vapier@gentoo.org> wrote:
> > On 21 Nov 2016 12:42, Zack Weinberg wrote:
> >> This flushed out some minor problems: test-skeleton.c uses uintptr_t
> >> but wasn't including <stdint.h>
> >
> > seems like this should be installed as obvious by itself
>
> Done (patch appended)
>
> >> libio.h tested _GNU_SOURCE instead of __USE_GNU in one place.
> >
> > makes sense regardless too
>
> Also done
these two patches look fine
> > a quick grep shows fnmatch.h has a similar error
>
> Isn't fnmatch.h shared with gnulib? I don't feel like I understand
> the constraints on code shared with gnulib, certainly not enough to
> call it "obvious." Also, some of the conditionals in there don't make
> sense to me ("#if !defined _POSIX_C_SOURCE || _POSIX_C_SOURCE < 2 ||
> defined _GNU_SOURCE" -- what's that even supposed to do?)
i've sent a sep patch for that so we can discuss it there ;)
-mike
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-11-27 20:49 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-21 17:42 [PATCH] Always suppress libc-internal declarations for C++ code Zack Weinberg
2016-11-27 6:50 ` Mike Frysinger
2016-11-27 17:37 ` Zack Weinberg
2016-11-27 20:49 ` Mike Frysinger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).