@@ -238,9 +238,9 @@ mod consts {
238238 }
239239 ) ;
240240
241- bitflags ! (
242- pub struct FdFlag : c_int {
243- const FD_CLOEXEC = 1 ;
241+ libc_bitflags ! (
242+ pub flags FdFlag : c_int {
243+ FD_CLOEXEC
244244 }
245245 ) ;
246246
@@ -255,182 +255,55 @@ mod consts {
255255
256256}
257257
258- #[ cfg( any( target_os = "macos" , target_os = "ios" ) ) ]
259- mod consts {
260- use libc:: { self , c_int} ;
261-
262- bitflags ! (
263- pub struct OFlag : c_int {
264- const O_ACCMODE = libc:: O_ACCMODE ;
265- const O_RDONLY = libc:: O_RDONLY ;
266- const O_WRONLY = libc:: O_WRONLY ;
267- const O_RDWR = libc:: O_RDWR ;
268- const O_CREAT = libc:: O_CREAT ;
269- const O_EXCL = libc:: O_EXCL ;
270- const O_NOCTTY = libc:: O_NOCTTY ;
271- const O_TRUNC = libc:: O_TRUNC ;
272- const O_APPEND = libc:: O_APPEND ;
273- const O_NONBLOCK = libc:: O_NONBLOCK ;
274- const O_DSYNC = libc:: O_DSYNC ;
275- const O_DIRECTORY = libc:: O_DIRECTORY ;
276- const O_NOFOLLOW = libc:: O_NOFOLLOW ;
277- const O_CLOEXEC = libc:: O_CLOEXEC ;
278- const O_SYNC = libc:: O_SYNC ;
279- const O_NDELAY = O_NONBLOCK . bits;
280- const O_FSYNC = libc:: O_FSYNC ;
281- }
282- ) ;
283-
284- bitflags ! (
285- pub struct FdFlag : c_int {
286- const FD_CLOEXEC = 1 ;
287- }
288- ) ;
289- }
290-
291- #[ cfg( target_os = "freebsd" ) ]
258+ #[ cfg( any( target_os = "netbsd" , target_os = "dragonfly" , target_os = "openbsd" ,
259+ target_os = "freebsd" , target_os = "macos" , target_os = "ios" ) ) ]
292260mod consts {
293- use libc:: { self , c_int} ;
261+ use libc:: { self , c_int} ;
294262
295- bitflags ! (
296- pub struct OFlag : c_int {
297- const O_ACCMODE = libc:: O_ACCMODE ;
298- const O_RDONLY = libc:: O_RDONLY ;
299- const O_WRONLY = libc:: O_WRONLY ;
300- const O_RDWR = libc:: O_RDWR ;
301- const O_CREAT = libc:: O_CREAT ;
302- const O_EXCL = libc:: O_EXCL ;
303- const O_NOCTTY = libc:: O_NOCTTY ;
304- const O_TRUNC = libc:: O_TRUNC ;
305- const O_APPEND = libc:: O_APPEND ;
306- const O_NONBLOCK = libc:: O_NONBLOCK ;
307- const O_DIRECTORY = 0x0020000 ;
308- const O_NOFOLLOW = libc:: O_NOFOLLOW ;
309- const O_CLOEXEC = libc:: O_CLOEXEC ;
310- const O_SYNC = libc:: O_SYNC ;
311- const O_NDELAY = libc:: O_NDELAY ;
312- const O_FSYNC = libc:: O_FSYNC ;
313- const O_SHLOCK = 0x0000080 ;
314- const O_EXLOCK = 0x0000020 ;
315- const O_DIRECT = 0x0010000 ;
316- const O_EXEC = 0x0040000 ;
317- const O_TTY_INIT = 0x0080000 ;
318- }
319- ) ;
320-
321- bitflags ! (
322- pub struct FdFlag : c_int {
323- const FD_CLOEXEC = 1 ;
324- }
325- ) ;
326- }
327-
328- #[ cfg( target_os = "openbsd" ) ]
329- mod consts {
330- use libc:: { self , c_int} ;
331-
332- bitflags ! (
263+ libc_bitflags ! (
333264 pub flags OFlag : c_int {
334- const O_ACCMODE = libc:: O_ACCMODE ,
335- const O_RDONLY = libc:: O_RDONLY ,
336- const O_WRONLY = libc:: O_WRONLY ,
337- const O_RDWR = libc:: O_RDWR ,
338- const O_CREAT = libc:: O_CREAT ,
339- const O_EXCL = libc:: O_EXCL ,
340- const O_NOCTTY = libc:: O_NOCTTY ,
341- const O_TRUNC = libc:: O_TRUNC ,
342- const O_APPEND = libc:: O_APPEND ,
343- const O_NONBLOCK = libc:: O_NONBLOCK ,
344- const O_DIRECTORY = 0x0020000 ,
345- const O_NOFOLLOW = libc:: O_NOFOLLOW ,
346- const O_CLOEXEC = libc:: O_CLOEXEC ,
347- const O_SYNC = libc:: O_SYNC ,
348- const O_NDELAY = libc:: O_NDELAY ,
349- const O_FSYNC = libc:: O_FSYNC ,
350- const O_SHLOCK = 0x0000080 ,
351- const O_EXLOCK = 0x0000020 ,
265+ O_ACCMODE ,
266+ O_RDONLY ,
267+ O_WRONLY ,
268+ O_RDWR ,
269+ O_NONBLOCK ,
270+ O_APPEND ,
271+ O_SHLOCK ,
272+ O_EXLOCK ,
273+ O_ASYNC ,
274+ O_SYNC ,
275+ O_NOFOLLOW ,
276+ O_CREAT ,
277+ O_TRUNC ,
278+ O_EXCL ,
279+ O_NOCTTY ,
280+ O_DIRECTORY ,
281+ O_CLOEXEC ,
282+ O_FSYNC ,
283+ O_NDELAY ,
284+ #[ cfg( any( target_os = "netbsd" , target_os = "openbsd" , target_os = "macos" ,
285+ target_os = "ios" ) ) ]
286+ O_DSYNC ,
287+ #[ cfg( any( target_os = "netbsd" , target_os = "dragonfly" , target_os = "freebsd" ) ) ]
288+ O_DIRECT ,
289+ #[ cfg( any( target_os = "netbsd" , target_os = "openbsd" ) ) ]
290+ O_RSYNC ,
291+ #[ cfg( target_os = "freebsd" ) ]
292+ O_EXEC ,
293+ #[ cfg( target_os = "freebsd" ) ]
294+ O_TTY_INIT ,
295+ #[ cfg( target_os = "netbsd" ) ]
296+ O_ALT_IO ,
297+ #[ cfg( target_os = "netbsd" ) ]
298+ O_NOSIGPIPE ,
299+ #[ cfg( target_os = "netbsd" ) ]
300+ O_SEARCH ,
352301 }
353302 ) ;
354303
355- bitflags ! (
304+ libc_bitflags ! (
356305 pub flags FdFlag : c_int {
357- const FD_CLOEXEC = 1
358- }
359- ) ;
360- }
361-
362- #[ cfg( target_os = "netbsd" ) ]
363- mod consts {
364- use libc:: c_int;
365-
366- bitflags ! (
367- pub struct OFlag : c_int {
368- const O_ACCMODE = 0x0000003 ;
369- const O_RDONLY = 0x0000000 ;
370- const O_WRONLY = 0x0000001 ;
371- const O_RDWR = 0x0000002 ;
372- const O_NONBLOCK = 0x0000004 ;
373- const O_APPEND = 0x0000008 ;
374- const O_SHLOCK = 0x0000010 ;
375- const O_EXLOCK = 0x0000020 ;
376- const O_ASYNC = 0x0000040 ;
377- const O_SYNC = 0x0000080 ;
378- const O_NOFOLLOW = 0x0000100 ;
379- const O_CREAT = 0x0000200 ;
380- const O_TRUNC = 0x0000400 ;
381- const O_EXCL = 0x0000800 ;
382- const O_NOCTTY = 0x0008000 ;
383- const O_DSYNC = 0x0010000 ;
384- const O_RSYNC = 0x0020000 ;
385- const O_ALT_IO = 0x0040000 ;
386- const O_DIRECT = 0x0080000 ;
387- const O_NOSIGPIPE = 0x0100000 ;
388- const O_DIRECTORY = 0x0200000 ;
389- const O_CLOEXEC = 0x0400000 ;
390- const O_SEARCH = 0x0800000 ;
391- const O_FSYNC = O_SYNC . bits;
392- const O_NDELAY = O_NONBLOCK . bits;
393- }
394- ) ;
395-
396- bitflags ! (
397- pub struct FdFlag : c_int {
398- const FD_CLOEXEC = 1 ;
399- }
400- ) ;
401- }
402-
403- #[ cfg( target_os = "dragonfly" ) ]
404- mod consts {
405- use libc:: c_int;
406-
407- bitflags ! (
408- pub struct OFlag : c_int {
409- const O_ACCMODE = 0x0000003 ;
410- const O_RDONLY = 0x0000000 ;
411- const O_WRONLY = 0x0000001 ;
412- const O_RDWR = 0x0000002 ;
413- const O_CREAT = 0x0000200 ;
414- const O_EXCL = 0x0000800 ;
415- const O_NOCTTY = 0x0008000 ;
416- const O_TRUNC = 0x0000400 ;
417- const O_APPEND = 0x0000008 ;
418- const O_NONBLOCK = 0x0000004 ;
419- const O_DIRECTORY = 0x8000000 ; // different from FreeBSD!
420- const O_NOFOLLOW = 0x0000100 ;
421- const O_CLOEXEC = 0x0020000 ; // different from FreeBSD!
422- const O_SYNC = 0x0000080 ;
423- const O_NDELAY = O_NONBLOCK . bits;
424- const O_FSYNC = O_SYNC . bits;
425- const O_SHLOCK = 0x0000010 ; // different from FreeBSD!
426- const O_EXLOCK = 0x0000020 ;
427- const O_DIRECT = 0x0010000 ;
428- }
429- ) ;
430-
431- bitflags ! (
432- pub struct FdFlag : c_int {
433- const FD_CLOEXEC = 1 ;
306+ FD_CLOEXEC
434307 }
435308 ) ;
436309}
0 commit comments