This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


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

Re: [PATCH] Make sys/timerfd.h usable without __USE_POSIX199309


Ulrich Drepper wrote:

> You're using a non-standard header which ideally would
> not make anything available unless you select _GNU_SOURCE (or some
> _BSD_SOURCE etc, but in this case the file is not of that origin).
>
> It's just not worth it to add all these extra #ifdefs.  Programmers
> have to realize that without any _*_SOURCE macros defined the default
> environment is ISO C and then you must not include any system headers
> other than the standard headers.

Thanks for explaining.  I believe it is worth it to add that extra
#ifdef, so programmers can understand why their code is failing.  So
how about this?

This way, programmers can get used to needing to set _GNU_SOURCE before
using sys/timerfd.h, so if it gets standardized, glibc won't have to
break any programs to avoid namespace polution.

2011-10-16  Jonathan Nieder  <jrnieder@gmail.com>

	* sysdeps/unix/sysv/linux/sys/timerfd.h (everything): Only
	declare under _GNU_SOURCE.
	* sysdeps/unix/sysv/linux/sparc/sys/timerfd.h: Likewise.
---
 sysdeps/unix/sysv/linux/sparc/sys/timerfd.h |    5 ++++-
 sysdeps/unix/sysv/linux/sys/timerfd.h       |    5 ++++-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/sysdeps/unix/sysv/linux/sparc/sys/timerfd.h b/sysdeps/unix/sysv/linux/sparc/sys/timerfd.h
index 833d050..a588c35 100644
--- a/sysdeps/unix/sysv/linux/sparc/sys/timerfd.h
+++ b/sysdeps/unix/sysv/linux/sparc/sys/timerfd.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2008 Free Software Foundation, Inc.
+/* Copyright (C) 2008, 2011 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -19,9 +19,11 @@
 #ifndef	_SYS_TIMERFD_H
 #define	_SYS_TIMERFD_H	1
 
+#include <features.h>
 #include <time.h>
 
 
+#ifdef __USE_GNU
 /* Bits to be set in the FLAGS parameter of `timerfd_create'.  */
 enum
   {
@@ -56,5 +58,6 @@ extern int timerfd_settime (int __ufd, int __flags,
 extern int timerfd_gettime (int __ufd, struct itimerspec *__otmr) __THROW;
 
 __END_DECLS
+#endif /* __USE_GNU */
 
 #endif /* sys/timerfd.h */
diff --git a/sysdeps/unix/sysv/linux/sys/timerfd.h b/sysdeps/unix/sysv/linux/sys/timerfd.h
index c1bb06f..20340ab 100644
--- a/sysdeps/unix/sysv/linux/sys/timerfd.h
+++ b/sysdeps/unix/sysv/linux/sys/timerfd.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2008 Free Software Foundation, Inc.
+/* Copyright (C) 2008, 2011 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -19,9 +19,11 @@
 #ifndef	_SYS_TIMERFD_H
 #define	_SYS_TIMERFD_H	1
 
+#include <features.h>
 #include <time.h>
 
 
+#ifdef __USE_GNU
 /* Bits to be set in the FLAGS parameter of `timerfd_create'.  */
 enum
   {
@@ -56,5 +58,6 @@ extern int timerfd_settime (int __ufd, int __flags,
 extern int timerfd_gettime (int __ufd, struct itimerspec *__otmr) __THROW;
 
 __END_DECLS
+#endif /* __USE_GNU */
 
 #endif /* sys/timerfd.h */
-- 
1.7.7


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