This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Handle gcc -std=c99 -D_XOPEN_SOURCE=600 [BZ #284]


Hi!

The c99 script (which is part of XPG6) uses gcc -std=c99.
Unfortunately -std=c99 defines also __STRICT_ANSI__ and
eventhough -D_XOPEN_SOURCE=600 per XPG6 should enable -D_POSIX_SOURCE
and -D_POSIX_C_SOURCE=200112L, when __STRICT_ANSI__ it doesn't do so.

I think it would be better if gcc -std=c99 did not define __STRICT_ANSI__,
only gcc -std=c99 -ansi did, because otherwise there is no way to
request ISO C99 language features and XPG6, but not GNU C99 language
extensions.

The c99 script could be changed to use gcc -std=c99 -U__STRICT_ANSI "$@",
but still there are many people who will use
gcc -std=c99 -D_XOPEN_SOURCE=600.

Or as done in the patch below __STRICT_ANSI__ can be ignored if
_XOPEN_SOURCE is defined for the purpose of defining _POSIX_SOURCE
and _POSIX_C_SOURCE.

The __clockid_t change is IMHO useful no matter what solution is chosen,
NPTL pthread.h already uses __clockid_t in a couple of other places
surrounded by __USE_XOPEN2K.

2004-07-23  Jakub Jelinek  <jakub@redhat.com>

	[BZ #284]
	* include/features.h (_POSIX_SOURCE, _POSIX_C_SOURCE): Define
	if _XOPEN_SOURCE >= 500 even if __STRICT_ANSI__ is defined.
linuxthreads/
	* sysdeps/pthread/pthread.h (pthread_getcpuclockid): Use __clockid_t
	instead of clockid_t.
nptl/
	* sysdeps/pthread/pthread.h (pthread_getcpuclockid): Use __clockid_t
	instead of clockid_t.

--- libc/include/features.h.jj	2003-05-17 02:38:00.000000000 +0200
+++ libc/include/features.h	2004-07-23 20:12:52.086150557 +0200
@@ -162,8 +162,8 @@
 
 /* If none of the ANSI/POSIX macros are defined, use POSIX.1 and POSIX.2
    (and IEEE Std 1003.1b-1993 unless _XOPEN_SOURCE is defined).  */
-#if (!defined __STRICT_ANSI__ && !defined _POSIX_SOURCE && \
-     !defined _POSIX_C_SOURCE)
+#if ((!defined __STRICT_ANSI__ || (_XOPEN_SOURCE - 0) >= 500) && \
+     !defined _POSIX_SOURCE && !defined _POSIX_C_SOURCE)
 # define _POSIX_SOURCE	1
 # if defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) < 500
 #  define _POSIX_C_SOURCE	2
--- libc/linuxthreads/sysdeps/pthread/pthread.h.jj	2003-12-29 00:50:52.000000000 +0100
+++ libc/linuxthreads/sysdeps/pthread/pthread.h	2004-07-23 18:59:27.759397642 +0200
@@ -648,7 +648,7 @@ extern void _pthread_cleanup_pop_restore
 #ifdef __USE_XOPEN2K
 /* Get ID of CPU-time clock for thread THREAD_ID.  */
 extern int pthread_getcpuclockid (pthread_t __thread_id,
-				  clockid_t *__clock_id) __THROW;
+				  __clockid_t *__clock_id) __THROW;
 #endif
 
 
--- libc/nptl/sysdeps/pthread/pthread.h.jj	2004-03-22 14:45:56.000000000 +0100
+++ libc/nptl/sysdeps/pthread/pthread.h	2004-07-23 18:58:50.252951923 +0200
@@ -915,7 +915,7 @@ extern int pthread_setspecific (pthread_
 #ifdef __USE_XOPEN2K
 /* Get ID of CPU-time clock for thread THREAD_ID.  */
 extern int pthread_getcpuclockid (pthread_t __thread_id,
-				  clockid_t *__clock_id) __THROW;
+				  __clockid_t *__clock_id) __THROW;
 #endif
 
 

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]