This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
[PATCH] pthread_atfork() is defined in both unistd.h and pthread.h
- From: GOTO Masanori <gotom at debian dot or dot jp>
- To: libc-alpha at sources dot redhat dot com
- Cc: gotom at debian dot or dot jp
- Date: Mon, 31 Mar 2003 20:15:01 +0900
- Subject: [PATCH] pthread_atfork() is defined in both unistd.h and pthread.h
Both unistd.h and pthread.h have the duplicate prototype definition of
pthread_atfork(), if __USE_POSIX199309 is enabled. So if a program
includes both headers pthread.h and unistd.h, and it's compiled with
the gcc warning option "-Wsystem-headers -Wredundant-decls", then it
gets warnings:
gotom at celesta> cat test1.c
#include <pthread.h>
#include <unistd.h>
void f(){}
gotom at celesta> gcc -c -Wsystem-headers -Wredundant-decls test1.c
In file included from test1.c:2:
/usr/include/unistd.h:1003: warning: redundant redeclaration of `pthread_atfork' in same scope
/usr/include/pthread.h:674: warning: previous declaration of `pthread_atfork'
This patch eliminates these warnings.
Regards,
-- gotom
2003-03-31 GOTO Masanori <gotom at debian dot or dot jp>
* posix/unistd.h: Define _PTHREAD_ATFORK_DEFINED not to include the
duplicate prototype definition of pthread_atfork().
* linuxthreads/sysdeps/pthread/pthread.h: Likewise.
--- posix/unistd.h 2002-10-14 10:03:00.000000000 +0900
+++ posix/unistd.h.new 2003-03-31 19:55:22.000000000 +0900
@@ -985,7 +985,7 @@
#endif
-#ifdef __USE_POSIX199309
+#if defined(__USE_POSIX199309) && !defined(_PTHREAD_ATFORK_DEFINED)
/* This function is only available if the system has POSIX threads. */
/* Install handlers to be called when a new process is created with FORK.
@@ -1001,6 +1001,7 @@
extern int pthread_atfork (void (*__prepare) (void),
void (*__parent) (void),
void (*__child) (void)) __THROW;
+# define _PTHREAD_ATFORK_DEFINED
#endif
__END_DECLS
--- linuxthreads/sysdeps/pthread/pthread.h 2003-01-05 20:52:38.000000000 +0900
+++ linuxthreads/sysdeps/pthread/pthread.h.new 2003-03-31 19:56:20.000000000 +0900
@@ -655,6 +655,7 @@
#include <bits/sigthread.h>
+#ifndef _PTHREAD_ATFORK_DEFINED
/* Functions for handling process creation and process execution. */
/* Install handlers to be called when a new process is created with FORK.
@@ -671,6 +672,8 @@
extern int pthread_atfork (void (*__prepare) (void),
void (*__parent) (void),
void (*__child) (void)) __THROW;
+# define _PTHREAD_ATFORK_DEFINED
+#endif
/* Terminate all threads in the program except the calling process.
Should be called just before invoking one of the exec*() functions. */