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]

[PATCH 1/3] Avoid duplication of _CLOEXEC and _NONBLOCK values


This patch define all the _CLOEXEC and _NONBLOCK derived values as O_CLOEXEC and
O_NONBLOCK respectively. This avoids a lot of header duplication and a handfull of
obsolete files can be removed.

I'll send separate patch to libc-ports.

2010-08-26  Guy Martin <gmsoft@tuxicoman.be>
	* sysdeps/unix/sysv/linux/bits/socket.h: Define SOCK_CLOEXEC and
	SOCK_NONBLOCK as O_CLOEXEC and O_NONBLOCK respectively instead of
	keeping a separate copy for each value.
	* sysdeps/unix/sysv/linux/sys/epoll.h: Likewise for EPOLL_CLOEXEC and
	EPOLL_NONBLOCK.
	* sysdeps/unix/sysv/linux/sys/eventfd.h: Likewise for EFD_CLOEXEC and
	EFD_NONBLOCK.
	* sysdeps/unix/sysv/linux/sys/inotify.h: Likewise for IN_CLOEXEC and
	IN_NONBLOCK.
	* sysdeps/unix/sysv/linux/sys/signalfd.h: Likewise for SFD_CLOEXEC and
	SFD_NONBLOCK.
	* sysdeps/unix/sysv/linux/sys/timerfd.h: Likeswis for TFD_CLOEXEC and
	TFD_NONBLOCK.

Signed-off-by: Guy Martin <gmsoft@tuxicoman.be>

---
 sysdeps/unix/sysv/linux/bits/socket.h  |    5 +++--
 sysdeps/unix/sysv/linux/sys/epoll.h    |    8 +++++---
 sysdeps/unix/sysv/linux/sys/eventfd.h  |    7 ++++---
 sysdeps/unix/sysv/linux/sys/inotify.h  |    7 ++++---
 sysdeps/unix/sysv/linux/sys/signalfd.h |    8 +++++---
 sysdeps/unix/sysv/linux/sys/timerfd.h  |    7 ++++---
 6 files changed, 25 insertions(+), 17 deletions(-)

diff --git a/sysdeps/unix/sysv/linux/bits/socket.h b/sysdeps/unix/sysv/linux/bits/socket.h
index dba3a39..7a9cf25 100644
--- a/sysdeps/unix/sysv/linux/bits/socket.h
+++ b/sysdeps/unix/sysv/linux/bits/socket.h
@@ -29,6 +29,7 @@
 #include <stddef.h>
 
 #include <sys/types.h>
+#include <fcntl.h>
 
 /* Type for length arguments in socket calls.  */
 #ifndef __socklen_t_defined
@@ -62,10 +63,10 @@ enum __socket_type
   /* Flags to be ORed into the type parameter of socket and socketpair and
      used for the flags parameter of paccept.  */
 
-  SOCK_CLOEXEC = 02000000,	/* Atomically set close-on-exec flag for the
+  SOCK_CLOEXEC = O_CLOEXEC,	/* Atomically set close-on-exec flag for the
 				   new descriptor(s).  */
 #define SOCK_CLOEXEC SOCK_CLOEXEC
-  SOCK_NONBLOCK = 04000		/* Atomically mark descriptor(s) as
+  SOCK_NONBLOCK = O_NONBLOCK	/* Atomically mark descriptor(s) as
 				   non-blocking.  */
 #define SOCK_NONBLOCK SOCK_NONBLOCK
 };
diff --git a/sysdeps/unix/sysv/linux/sys/epoll.h b/sysdeps/unix/sysv/linux/sys/epoll.h
index ca1d3d0..39aa731 100644
--- a/sysdeps/unix/sysv/linux/sys/epoll.h
+++ b/sysdeps/unix/sysv/linux/sys/epoll.h
@@ -1,4 +1,5 @@
-/* Copyright (C) 2002-2006, 2007, 2008, 2009 Free Software Foundation, Inc.
+/* Copyright (C) 2002-2006, 2007, 2008, 2009, 2010
+   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
@@ -21,6 +22,7 @@
 
 #include <stdint.h>
 #include <sys/types.h>
+#include <fcntl.h>
 
 /* Get __sigset_t.  */
 #include <bits/sigset.h>
@@ -34,9 +36,9 @@ typedef __sigset_t sigset_t;
 /* Flags to be passed to epoll_create1.  */
 enum
   {
-    EPOLL_CLOEXEC = 02000000,
+    EPOLL_CLOEXEC = O_CLOEXEC,
 #define EPOLL_CLOEXEC EPOLL_CLOEXEC
-    EPOLL_NONBLOCK = 04000
+    EPOLL_NONBLOCK = O_NONBLOCK
 #define EPOLL_NONBLOCK EPOLL_NONBLOCK
   };
 
diff --git a/sysdeps/unix/sysv/linux/sys/eventfd.h b/sysdeps/unix/sysv/linux/sys/eventfd.h
index d942df4..b147d95 100644
--- a/sysdeps/unix/sysv/linux/sys/eventfd.h
+++ b/sysdeps/unix/sysv/linux/sys/eventfd.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc.
+/* Copyright (C) 2007, 2008, 2009, 2010 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
@@ -20,6 +20,7 @@
 #define	_SYS_EVENTFD_H	1
 
 #include <stdint.h>
+#include <fcntl.h>
 
 
 /* Type for event counter.  */
@@ -30,9 +31,9 @@ enum
   {
     EFD_SEMAPHORE = 1,
 #define EFD_SEMAPHORE EFD_SEMAPHORE
-    EFD_CLOEXEC = 02000000,
+    EFD_CLOEXEC = O_CLOEXEC,
 #define EFD_CLOEXEC EFD_CLOEXEC
-    EFD_NONBLOCK = 04000
+    EFD_NONBLOCK = O_NONBLOCK
 #define EFD_NONBLOCK EFD_NONBLOCK
   };
 
diff --git a/sysdeps/unix/sysv/linux/sys/inotify.h b/sysdeps/unix/sysv/linux/sys/inotify.h
index 8b3a852..e4b5ab3 100644
--- a/sysdeps/unix/sysv/linux/sys/inotify.h
+++ b/sysdeps/unix/sysv/linux/sys/inotify.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2005, 2006, 2008, 2009 Free Software Foundation, Inc.
+/* Copyright (C) 2005, 2006, 2008, 2009, 2010 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
@@ -20,14 +20,15 @@
 #define	_SYS_INOTIFY_H	1
 
 #include <stdint.h>
+#include <fcntl.h>
 
 
 /* Flags for the parameter of inotify_init1.  */
 enum
   {
-    IN_CLOEXEC = 02000000,
+    IN_CLOEXEC = O_CLOEXEC,
 #define IN_CLOEXEC IN_CLOEXEC
-    IN_NONBLOCK = 04000
+    IN_NONBLOCK = O_NONBLOCK
 #define IN_NONBLOCK IN_NONBLOCK
   };
 
diff --git a/sysdeps/unix/sysv/linux/sys/signalfd.h b/sysdeps/unix/sysv/linux/sys/signalfd.h
index eeb27ee..2af669b 100644
--- a/sysdeps/unix/sysv/linux/sys/signalfd.h
+++ b/sysdeps/unix/sysv/linux/sys/signalfd.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2007, 2008 Free Software Foundation, Inc.
+/* Copyright (C) 2007, 2008, 2010 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,6 +19,8 @@
 #ifndef	_SYS_SIGNALFD_H
 #define	_SYS_SIGNALFD_H	1
 
+#include <fcntl.h>
+
 #define __need_sigset_t
 #include <signal.h>
 #include <stdint.h>
@@ -48,9 +50,9 @@ struct signalfd_siginfo
 /* Flags for signalfd.  */
 enum
   {
-    SFD_CLOEXEC = 02000000,
+    SFD_CLOEXEC = O_CLOEXEC,
 #define SFD_CLOEXEC SFD_CLOEXEC
-    SFD_NONBLOCK = 04000
+    SFD_NONBLOCK = O_NONBLOCK
 #define SFD_NONBLOCK SFD_NONBLOCK
   };
 
diff --git a/sysdeps/unix/sysv/linux/sys/timerfd.h b/sysdeps/unix/sysv/linux/sys/timerfd.h
index c1bb06f..fe0f1b3 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, 2010 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
@@ -20,14 +20,15 @@
 #define	_SYS_TIMERFD_H	1
 
 #include <time.h>
+#include <fcntl.h>
 
 
 /* Bits to be set in the FLAGS parameter of `timerfd_create'.  */
 enum
   {
-    TFD_CLOEXEC = 02000000,
+    TFD_CLOEXEC = O_CLOEXEC,
 #define TFD_CLOEXEC TFD_CLOEXEC
-    TFD_NONBLOCK = 04000
+    TFD_NONBLOCK = O_NONBLOCK
 #define TFD_NONBLOCK TFD_NONBLOCK
   };
 


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