aboutsummaryrefslogtreecommitdiffstats
path: root/main/uclibc/0010-define-O_CLOEXEC.patch
blob: 6db4dbbed08ec9c8722e72df140197dfa5aa11da (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
Backported from the below upstream commit by Timo Teräs. Changes
to non-header files were removed.

From b8f1f91cc6d7b579fdb2370ab046565f9930aa09 Mon Sep 17 00:00:00 2001
From: Mike Frysinger <vapier@gentoo.org>
Date: Wed, 7 Oct 2009 22:51:55 -0400
Subject: [PATCH] clean up O_CLOEXEC handling

Drop the "#ifndef O_CLOEXEC" cruft, enable O_CLOEXEC in most fcntl.h
headers, and import __ASSUME_O_CLOEXEC from glibc.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
 libc/misc/dirent/opendir.c                       |    8 +++-----
 libc/misc/utmp/utent.c                           |   21 ++++-----------------
 libc/pwd_grp/lckpwdf.c                           |    8 +++-----
 libc/sysdeps/linux/alpha/bits/fcntl.h            |    2 --
 libc/sysdeps/linux/arm/bits/fcntl.h              |    2 --
 libc/sysdeps/linux/avr32/bits/fcntl.h            |    1 +
 libc/sysdeps/linux/bfin/bits/fcntl.h             |    2 ++
 libc/sysdeps/linux/common/bits/kernel-features.h |    8 ++++++++
 libc/sysdeps/linux/cris/bits/fcntl.h             |    1 +
 libc/sysdeps/linux/frv/bits/fcntl.h              |    2 ++
 libc/sysdeps/linux/hppa/bits/fcntl.h             |    1 +
 libc/sysdeps/linux/i386/bits/fcntl.h             |    2 --
 libc/sysdeps/linux/ia64/bits/fcntl.h             |    2 --
 libc/sysdeps/linux/m68k/bits/fcntl.h             |    1 +
 libc/sysdeps/linux/microblaze/bits/fcntl.h       |    2 ++
 libc/sysdeps/linux/mips/bits/fcntl.h             |    1 +
 libc/sysdeps/linux/powerpc/bits/fcntl.h          |    2 --
 libc/sysdeps/linux/sh/bits/fcntl.h               |    2 --
 libc/sysdeps/linux/sh64/bits/fcntl.h             |    2 ++
 libc/sysdeps/linux/sparc/bits/fcntl.h            |    2 --
 libc/sysdeps/linux/x86_64/bits/fcntl.h           |    2 --
 libc/sysdeps/linux/xtensa/bits/fcntl.h           |    1 +
 22 files changed, 32 insertions(+), 43 deletions(-)

diff --git a/libc/sysdeps/linux/alpha/bits/fcntl.h b/libc/sysdeps/linux/alpha/bits/fcntl.h
index 2a6b9ea..649c563 100644
--- a/libc/sysdeps/linux/alpha/bits/fcntl.h
+++ b/libc/sysdeps/linux/alpha/bits/fcntl.h
@@ -50,9 +50,7 @@
 # define O_NOFOLLOW	0200000	/* Do not follow links.  */
 # define O_DIRECT	02000000 /* Direct disk access.  */
 # define O_NOATIME	04000000 /* Do not set atime.  */
-# if 0
 # define O_CLOEXEC      010000000 /* Set close_on_exec.  */
-# endif
 #endif
 
 #ifdef __USE_LARGEFILE64
diff --git a/libc/sysdeps/linux/arm/bits/fcntl.h b/libc/sysdeps/linux/arm/bits/fcntl.h
index 86cea4b..7cc5a9d 100644
--- a/libc/sysdeps/linux/arm/bits/fcntl.h
+++ b/libc/sysdeps/linux/arm/bits/fcntl.h
@@ -50,9 +50,7 @@
 # define O_NOFOLLOW	0100000	/* Do not follow links.	 */
 # define O_DIRECT	0200000	/* Direct disk access.	*/
 # define O_NOATIME     01000000 /* Do not set atime.  */
-# if 0
 # define O_CLOEXEC     02000000 /* Set close_on_exec.  */
-# endif
 #endif
 
 /* For now Linux has synchronisity options for data and read operations.
diff --git a/libc/sysdeps/linux/avr32/bits/fcntl.h b/libc/sysdeps/linux/avr32/bits/fcntl.h
index 2301e22..767243e 100644
--- a/libc/sysdeps/linux/avr32/bits/fcntl.h
+++ b/libc/sysdeps/linux/avr32/bits/fcntl.h
@@ -30,6 +30,7 @@
 # define O_DIRECTORY	00200000	/* direct disk access */
 # define O_NOFOLLOW	00400000	/* don't follow links */
 # define O_NOATIME	01000000	/* don't set atime */
+# define O_CLOEXEC	02000000	/* set close_on_exec */
 #endif
 
 #ifdef __USE_LARGEFILE64
diff --git a/libc/sysdeps/linux/bfin/bits/fcntl.h b/libc/sysdeps/linux/bfin/bits/fcntl.h
index 7d0bcf9..f019b71 100644
--- a/libc/sysdeps/linux/bfin/bits/fcntl.h
+++ b/libc/sysdeps/linux/bfin/bits/fcntl.h
@@ -48,6 +48,8 @@
 # define O_DIRECTORY	 040000	/* Must be a directory.	 */
 # define O_NOFOLLOW	0100000	/* Do not follow links.	 */
 # define O_DIRECT	0200000	/* Direct disk access.	*/
+# define O_NOATIME	01000000	/* don't set atime */
+# define O_CLOEXEC	02000000	/* set close_on_exec */
 #endif
 
 /* For now Linux has synchronisity options for data and read operations.
diff --git a/libc/sysdeps/linux/common/bits/kernel-features.h b/libc/sysdeps/linux/common/bits/kernel-features.h
index 5216d7b..8829734 100644
--- a/libc/sysdeps/linux/common/bits/kernel-features.h
+++ b/libc/sysdeps/linux/common/bits/kernel-features.h
@@ -70,6 +70,14 @@
 # define __ASSUME_GETDENTS32_D_TYPE 1
 #endif
 
+/* Support for various CLOEXEC and NONBLOCK flags was added for x86,
+   x86-64, PPC, IA-64, SPARC< and S390 in 2.6.23.  */
+#if __LINUX_KERNEL_VERSION >= 0x020617 \
+    && (defined __i386__ || defined __x86_64__ || defined __powerpc__ \
+	|| defined __ia64__ || defined __sparc__ || defined __s390__)
+# define __ASSUME_O_CLOEXEC 1
+#endif
+
 /* These features were surely available with 2.4.12.  */
 #if __LINUX_KERNEL_VERSION >= 132108 && defined __mc68000__
 # define __ASSUME_MMAP2_SYSCALL		1
diff --git a/libc/sysdeps/linux/cris/bits/fcntl.h b/libc/sysdeps/linux/cris/bits/fcntl.h
index a2106ef..29443ba 100644
--- a/libc/sysdeps/linux/cris/bits/fcntl.h
+++ b/libc/sysdeps/linux/cris/bits/fcntl.h
@@ -50,6 +50,7 @@
 # define O_DIRECTORY	0200000	/* Must be a directory.	 */
 # define O_NOFOLLOW	0400000	/* Do not follow links.	 */
 # define O_NOATIME	01000000 /* Do not set atime.  */
+# define O_CLOEXEC	02000000 /* set close_on_exec */
 #endif
 
 /* For now Linux has synchronisity options for data and read operations.
diff --git a/libc/sysdeps/linux/frv/bits/fcntl.h b/libc/sysdeps/linux/frv/bits/fcntl.h
index 06e8860..d437175 100644
--- a/libc/sysdeps/linux/frv/bits/fcntl.h
+++ b/libc/sysdeps/linux/frv/bits/fcntl.h
@@ -45,6 +45,8 @@
 # define O_DIRECT	 040000	/* Direct disk access.  */
 # define O_DIRECTORY	0200000	/* Must be a directory.  */
 # define O_NOFOLLOW	0400000	/* Do not follow links.  */
+# define O_NOATIME	01000000 /* don't set atime */
+# define O_CLOEXEC	02000000 /* set close_on_exec */
 #endif
 
 /* For now Linux has synchronisity options for data and read operations.
diff --git a/libc/sysdeps/linux/hppa/bits/fcntl.h b/libc/sysdeps/linux/hppa/bits/fcntl.h
index cc23bf8..86e3b6f 100644
--- a/libc/sysdeps/linux/hppa/bits/fcntl.h
+++ b/libc/sysdeps/linux/hppa/bits/fcntl.h
@@ -50,6 +50,7 @@
 # define O_DIRECTORY	00010000 /* Must be a directory. */
 # define O_NOFOLLOW	00000200 /* Do not follow links. */
 # define O_NOATIME	04000000 /* Do not set atime. */
+# define O_CLOEXEC	010000000 /* set close_on_exec */
 #endif
 
 #ifdef __USE_LARGEFILE64
diff --git a/libc/sysdeps/linux/i386/bits/fcntl.h b/libc/sysdeps/linux/i386/bits/fcntl.h
index 7f0b552..22e073b 100644
--- a/libc/sysdeps/linux/i386/bits/fcntl.h
+++ b/libc/sysdeps/linux/i386/bits/fcntl.h
@@ -50,9 +50,7 @@
 # define O_DIRECTORY	0200000	/* Must be a directory.	 */
 # define O_NOFOLLOW	0400000	/* Do not follow links.	 */
 # define O_NOATIME     01000000 /* Do not set atime.  */
-# if 0
 # define O_CLOEXEC     02000000 /* Set close_on_exec.  */
-# endif
 #endif
 
 /* For now Linux has synchronisity options for data and read operations.
diff --git a/libc/sysdeps/linux/ia64/bits/fcntl.h b/libc/sysdeps/linux/ia64/bits/fcntl.h
index d134c4b..85a55f6 100644
--- a/libc/sysdeps/linux/ia64/bits/fcntl.h
+++ b/libc/sysdeps/linux/ia64/bits/fcntl.h
@@ -49,9 +49,7 @@
 # define O_DIRECTORY	0200000	/* must be a directory */
 # define O_NOFOLLOW	0400000 /* don't follow links */
 # define O_NOATIME	01000000 /* Do not set atime.  */
-# if 0
 # define O_CLOEXEC	02000000 /* Set close_on_exec.  */
-# endif
 #endif
 
 #ifdef __USE_LARGEFILE64
diff --git a/libc/sysdeps/linux/m68k/bits/fcntl.h b/libc/sysdeps/linux/m68k/bits/fcntl.h
index d36198d..e564b42 100644
--- a/libc/sysdeps/linux/m68k/bits/fcntl.h
+++ b/libc/sysdeps/linux/m68k/bits/fcntl.h
@@ -49,6 +49,7 @@
 # define O_NOFOLLOW	0100000	/* Do not follow links.	 */
 # define O_DIRECT	0200000	/* Direct disk access.	*/
 # define O_NOATIME	01000000 /* Do not set atime.  */
+# define O_CLOEXEC	02000000 /* set close_on_exec */
 #endif
 
 /* For now Linux has synchronisity options for data and read operations.
diff --git a/libc/sysdeps/linux/microblaze/bits/fcntl.h b/libc/sysdeps/linux/microblaze/bits/fcntl.h
index c8aeb91..bb6727a 100644
--- a/libc/sysdeps/linux/microblaze/bits/fcntl.h
+++ b/libc/sysdeps/linux/microblaze/bits/fcntl.h
@@ -45,6 +45,8 @@
 # define O_DIRECTORY	 040000	/* Must be a directory.	 */
 # define O_NOFOLLOW	0100000	/* Do not follow links.	 */
 # define O_DIRECT	0200000	/* Direct disk access.	*/
+# define O_NOATIME	01000000 /* Do not set atime.  */
+# define O_CLOEXEC	02000000 /* set close_on_exec */
 #endif
 
 /* For now Linux has synchronisity options for data and read operations.
diff --git a/libc/sysdeps/linux/mips/bits/fcntl.h b/libc/sysdeps/linux/mips/bits/fcntl.h
index ef015a4..f0072fd 100644
--- a/libc/sysdeps/linux/mips/bits/fcntl.h
+++ b/libc/sysdeps/linux/mips/bits/fcntl.h
@@ -51,6 +51,7 @@
 # define O_DIRECT	0x8000	/* Direct disk access hint.  */
 # define O_DIRECTORY	0x10000	/* Must be a directory.	 */
 # define O_NOATIME	0x40000	/* Do not set atime.  */
+# define O_CLOEXEC	02000000 /* set close_on_exec */
 #endif
 
 /* For now Linux has no synchronisity options for data and read operations.
diff --git a/libc/sysdeps/linux/powerpc/bits/fcntl.h b/libc/sysdeps/linux/powerpc/bits/fcntl.h
index ceb75b4..0759c6a 100644
--- a/libc/sysdeps/linux/powerpc/bits/fcntl.h
+++ b/libc/sysdeps/linux/powerpc/bits/fcntl.h
@@ -50,9 +50,7 @@
 # define O_DIRECTORY	 040000	/* Must be a directory.	 */
 # define O_NOFOLLOW	0100000	/* Do not follow links.	 */
 # define O_NOATIME	01000000 /* Do not set atime.  */
-# if 0
 # define O_CLOEXEC	02000000 /* Set close_on_exec.  */
-# endif
 #endif
 
 #ifdef __USE_LARGEFILE64
diff --git a/libc/sysdeps/linux/sh/bits/fcntl.h b/libc/sysdeps/linux/sh/bits/fcntl.h
index 570484c..adb7377 100644
--- a/libc/sysdeps/linux/sh/bits/fcntl.h
+++ b/libc/sysdeps/linux/sh/bits/fcntl.h
@@ -50,9 +50,7 @@
 # define O_DIRECTORY	0200000	/* Must be a directory.	 */
 # define O_NOFOLLOW	0400000	/* Do not follow links.	 */
 # define O_NOATIME     01000000 /* Do not set atime.  */
-# if 0
 # define O_CLOEXEC     02000000 /* Set close_on_exec.  */
-# endif
 #endif
 
 /* For now Linux has synchronisity options for data and read operations.
diff --git a/libc/sysdeps/linux/sh64/bits/fcntl.h b/libc/sysdeps/linux/sh64/bits/fcntl.h
index 06e8860..156df97 100644
--- a/libc/sysdeps/linux/sh64/bits/fcntl.h
+++ b/libc/sysdeps/linux/sh64/bits/fcntl.h
@@ -45,6 +45,8 @@
 # define O_DIRECT	 040000	/* Direct disk access.  */
 # define O_DIRECTORY	0200000	/* Must be a directory.  */
 # define O_NOFOLLOW	0400000	/* Do not follow links.  */
+# define O_NOATIME	01000000 /* Do not set atime.  */
+# define O_CLOEXEC	02000000 /* set close_on_exec */
 #endif
 
 /* For now Linux has synchronisity options for data and read operations.
diff --git a/libc/sysdeps/linux/sparc/bits/fcntl.h b/libc/sysdeps/linux/sparc/bits/fcntl.h
index 29c09a9..31a6d9b 100644
--- a/libc/sysdeps/linux/sparc/bits/fcntl.h
+++ b/libc/sysdeps/linux/sparc/bits/fcntl.h
@@ -49,9 +49,7 @@
 # define O_NOFOLLOW	0x20000 /* don't follow links */
 # define O_DIRECT	0x100000 /* direct disk access hint */
 # define O_NOATIME	0x200000 /* Do not set atime.  */
-# if 0
 # define O_CLOEXEC	0x400000 /* Set close_on_exit.  */
-# endif
 #endif
 
 #ifdef __USE_LARGEFILE64
diff --git a/libc/sysdeps/linux/x86_64/bits/fcntl.h b/libc/sysdeps/linux/x86_64/bits/fcntl.h
index be00e4a..f1cf388 100644
--- a/libc/sysdeps/linux/x86_64/bits/fcntl.h
+++ b/libc/sysdeps/linux/x86_64/bits/fcntl.h
@@ -50,9 +50,7 @@
 # define O_DIRECTORY	0200000	/* Must be a directory.	 */
 # define O_NOFOLLOW	0400000	/* Do not follow links.	 */
 # define O_NOATIME     01000000 /* Do not set atime.  */
-# if 0
 # define O_CLOEXEC     02000000 /* Set close_on_exec.  */
-# endif
 #endif
 
 /* For now Linux has synchronisity options for data and read operations.
diff --git a/libc/sysdeps/linux/xtensa/bits/fcntl.h b/libc/sysdeps/linux/xtensa/bits/fcntl.h
index a89362e..921a626 100644
--- a/libc/sysdeps/linux/xtensa/bits/fcntl.h
+++ b/libc/sysdeps/linux/xtensa/bits/fcntl.h
@@ -50,6 +50,7 @@
 # define O_DIRECTORY	0200000	/* Must be a directory.	 */
 # define O_NOFOLLOW	0400000	/* Do not follow links.	 */
 # define O_NOATIME     01000000 /* Do not set atime.  */
+# define O_CLOEXEC     02000000 /* set close_on_exec */
 #endif
 
 /* For now Linux has synchronisity options for data and read operations.
-- 
1.7.0.4