Skip to content

Commit b88c8f5

Browse files
committed
Auto merge of #623 - equal-l2:unify-bsd-flags, r=alexcrichton
Unify some BSD flags These BSD flags have common value in all OSes, so I've merged them into root `mod.rs`. - `O_ACCMODE` - `O_RDONLY` - `O_WRONLY` - `O_RDWR` - `O_APPEND` - `O_CREAT` - `O_TRUNC` - `O_EXCL` - `O_SYNC` - `O_NONBLOCK` - `O_SHLOCK` - `O_EXLOCK` - `O_FSYNC` - `O_NDELAY`
2 parents 50c5a33 + 1c39531 commit b88c8f5

File tree

5 files changed

+16
-40
lines changed

5 files changed

+16
-40
lines changed

src/unix/bsd/apple/mod.rs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -448,14 +448,8 @@ pub const _PC_PIPE_BUF: ::c_int = 6;
448448
pub const _PC_CHOWN_RESTRICTED: ::c_int = 7;
449449
pub const _PC_NO_TRUNC: ::c_int = 8;
450450
pub const _PC_VDISABLE: ::c_int = 9;
451-
pub const O_RDONLY: ::c_int = 0;
452-
pub const O_WRONLY: ::c_int = 1;
453-
pub const O_RDWR: ::c_int = 2;
454-
pub const O_APPEND: ::c_int = 8;
455-
pub const O_CREAT: ::c_int = 512;
456-
pub const O_EXCL: ::c_int = 2048;
457-
pub const O_NOCTTY: ::c_int = 131072;
458-
pub const O_TRUNC: ::c_int = 1024;
451+
pub const O_DSYNC: ::c_int = 0x400000;
452+
pub const O_NOCTTY: ::c_int = 0x20000;
459453
pub const O_CLOEXEC: ::c_int = 0x1000000;
460454
pub const O_DIRECTORY: ::c_int = 0x100000;
461455
pub const S_IFIFO: mode_t = 4096;
@@ -671,8 +665,6 @@ pub const AT_SYMLINK_NOFOLLOW: ::c_int = 0x0020;
671665
pub const AT_SYMLINK_FOLLOW: ::c_int = 0x0040;
672666
pub const AT_REMOVEDIR: ::c_int = 0x0080;
673667

674-
pub const O_ACCMODE: ::c_int = 3;
675-
676668
pub const TIOCMODG: ::c_ulong = 0x40047403;
677669
pub const TIOCMODS: ::c_ulong = 0x80047404;
678670
pub const TIOCM_LE: ::c_int = 0x1;
@@ -1024,10 +1016,6 @@ pub const LOCK_EX: ::c_int = 2;
10241016
pub const LOCK_NB: ::c_int = 4;
10251017
pub const LOCK_UN: ::c_int = 8;
10261018

1027-
pub const O_DSYNC: ::c_int = 4194304;
1028-
pub const O_SYNC: ::c_int = 128;
1029-
pub const O_NONBLOCK: ::c_int = 4;
1030-
10311019
pub const MAP_COPY: ::c_int = 0x0002;
10321020
pub const MAP_RENAME: ::c_int = 0x0020;
10331021
pub const MAP_NORESERVE: ::c_int = 0x0040;

src/unix/bsd/freebsdlike/mod.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -272,15 +272,7 @@ pub const FILENAME_MAX: ::c_uint = 1024;
272272
pub const L_tmpnam: ::c_uint = 1024;
273273
pub const TMP_MAX: ::c_uint = 308915776;
274274

275-
pub const O_RDONLY: ::c_int = 0;
276-
pub const O_WRONLY: ::c_int = 1;
277-
pub const O_RDWR: ::c_int = 2;
278-
pub const O_ACCMODE: ::c_int = 3;
279-
pub const O_APPEND: ::c_int = 8;
280-
pub const O_CREAT: ::c_int = 512;
281-
pub const O_EXCL: ::c_int = 2048;
282275
pub const O_NOCTTY: ::c_int = 32768;
283-
pub const O_TRUNC: ::c_int = 1024;
284276
pub const S_IFIFO: mode_t = 4096;
285277
pub const S_IFCHR: mode_t = 8192;
286278
pub const S_IFBLK: mode_t = 24576;
@@ -682,9 +674,6 @@ pub const LOCK_EX: ::c_int = 2;
682674
pub const LOCK_NB: ::c_int = 4;
683675
pub const LOCK_UN: ::c_int = 8;
684676

685-
pub const O_SYNC: ::c_int = 128;
686-
pub const O_NONBLOCK: ::c_int = 4;
687-
688677
pub const MAP_COPY: ::c_int = 0x0002;
689678
pub const MAP_RENAME: ::c_int = 0x0020;
690679
pub const MAP_NORESERVE: ::c_int = 0x0040;

src/unix/bsd/mod.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,22 @@ pub const ST_RDONLY: ::c_ulong = 1;
187187

188188
pub const NCCS: usize = 20;
189189

190+
pub const O_ACCMODE: ::c_int = 0x3;
191+
pub const O_RDONLY: ::c_int = 0;
192+
pub const O_WRONLY: ::c_int = 1;
193+
pub const O_RDWR: ::c_int = 2;
194+
pub const O_APPEND: ::c_int = 8;
195+
pub const O_CREAT: ::c_int = 512;
196+
pub const O_TRUNC: ::c_int = 1024;
197+
pub const O_EXCL: ::c_int = 2048;
190198
pub const O_ASYNC: ::c_int = 0x40;
191-
pub const O_FSYNC: ::c_int = 0x80;
192-
pub const O_NDELAY: ::c_int = 0x4;
199+
pub const O_SYNC: ::c_int = 0x80;
200+
pub const O_NONBLOCK: ::c_int = 0x4;
193201
pub const O_NOFOLLOW: ::c_int = 0x100;
202+
pub const O_SHLOCK: ::c_int = 0x10;
203+
pub const O_EXLOCK: ::c_int = 0x20;
204+
pub const O_FSYNC: ::c_int = O_SYNC;
205+
pub const O_NDELAY: ::c_int = O_NONBLOCK;
194206

195207
pub const F_GETOWN: ::c_int = 5;
196208
pub const F_SETOWN: ::c_int = 6;

src/unix/bsd/netbsdlike/mod.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -127,16 +127,7 @@ pub const BUFSIZ : ::c_uint = 1024;
127127
pub const FOPEN_MAX : ::c_uint = 20;
128128
pub const FILENAME_MAX : ::c_uint = 1024;
129129
pub const L_tmpnam : ::c_uint = 1024;
130-
pub const O_RDONLY : ::c_int = 0;
131-
pub const O_WRONLY : ::c_int = 1;
132-
pub const O_RDWR : ::c_int = 2;
133-
pub const O_ACCMODE : ::c_int = 3;
134-
pub const O_APPEND : ::c_int = 8;
135-
pub const O_CREAT : ::c_int = 512;
136-
pub const O_EXCL : ::c_int = 2048;
137130
pub const O_NOCTTY : ::c_int = 32768;
138-
pub const O_TRUNC : ::c_int = 1024;
139-
pub const O_SYNC : ::c_int = 128;
140131
pub const S_IFIFO : mode_t = 4096;
141132
pub const S_IFCHR : mode_t = 8192;
142133
pub const S_IFBLK : mode_t = 24576;
@@ -478,8 +469,6 @@ pub const LOCK_EX: ::c_int = 2;
478469
pub const LOCK_NB: ::c_int = 4;
479470
pub const LOCK_UN: ::c_int = 8;
480471

481-
pub const O_NONBLOCK : ::c_int = 4;
482-
483472
pub const IPPROTO_RAW : ::c_int = 255;
484473

485474
pub const _SC_ARG_MAX : ::c_int = 1;

src/unix/bsd/netbsdlike/netbsd/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,6 @@ pub const O_CLOEXEC: ::c_int = 0x400000;
270270
pub const O_ALT_IO: ::c_int = 0x40000;
271271
pub const O_NOSIGPIPE: ::c_int = 0x1000000;
272272
pub const O_SEARCH: ::c_int = 0x800000;
273-
pub const O_EXLOCK: ::c_int = 0x20;
274-
pub const O_SHLOCK: ::c_int = 0x10;
275273
pub const O_DIRECTORY: ::c_int = 0x200000;
276274

277275
pub const MS_SYNC : ::c_int = 0x4;

0 commit comments

Comments
 (0)