summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2018-07-31 01:25:13 +0000
committerbors <bors@rust-lang.org>2018-07-31 01:25:13 +0000
commite1ebfafc2f011216287c61ce8ff492f57dddee36 (patch)
treed2129972bb2c9856b428e84f0bec120b78bfdfc8
parent8565755356f23baf6b2df933ff734ce2f00c8d9b (diff)
parent86e83947ae58b085f4293cb5ae0860a66e03cdd1 (diff)
downloadrust-libc-e1ebfafc2f011216287c61ce8ff492f57dddee36.tar.gz
Auto merge of #1049 - alecmocatta:master, r=alexcrichton
Add the FIO* consts for *-apple-* Previously only FIONREAD was implemented for x86_64 apple. The constant is shared between i{3..6}86 and x86_64, so I've moved it into the shared module rather than the 64 bit specific one. They're defined like this in sys/filio.h: ``` #define FIOCLEX _IO('f', 1) /* set close on exec on fd */ #define FIONCLEX _IO('f', 2) /* remove close on exec */ #define FIONREAD _IOR('f', 127, int) /* get # bytes to read */ #define FIONBIO _IOW('f', 126, int) /* set/clear non-blocking i/o */ #define FIOASYNC _IOW('f', 125, int) /* set/clear async i/o */ #define FIOSETOWN _IOW('f', 124, int) /* set owner */ #define FIOGETOWN _IOR('f', 123, int) /* get owner */ #define FIODTYPE _IOR('f', 122, int) /* get d_type */ ``` Rather than decipher the C macros I got the values like so: ``` #include <stdio.h> #include <sys/ioctl.h> int main() { printf("pub const FIOCLEX: ::c_uint = 0x%x;\n", FIOCLEX); printf("pub const FIONCLEX: ::c_uint = 0x%x;\n", FIONCLEX); printf("pub const FIONREAD: ::c_ulong = 0x%lx;\n", FIONREAD); printf("pub const FIONBIO: ::c_ulong = 0x%lx;\n", FIONBIO); printf("pub const FIOASYNC: ::c_ulong = 0x%lx;\n", FIOASYNC); printf("pub const FIOSETOWN: ::c_ulong = 0x%lx;\n", FIOSETOWN); printf("pub const FIOGETOWN: ::c_ulong = 0x%lx;\n", FIOGETOWN); printf("pub const FIODTYPE: ::c_ulong = 0x%lx;\n", FIODTYPE); } $ gcc --target=i686-apple-darwin -o x x.c && file ./x && ./x ./x: Mach-O executable i386 pub const FIOCLEX: ::c_uint = 0x20006601; pub const FIONCLEX: ::c_uint = 0x20006602; pub const FIONREAD: ::c_ulong = 0x4004667f; pub const FIONBIO: ::c_ulong = 0x8004667e; pub const FIOASYNC: ::c_ulong = 0x8004667d; pub const FIOSETOWN: ::c_ulong = 0x8004667c; pub const FIOGETOWN: ::c_ulong = 0x4004667b; pub const FIODTYPE: ::c_ulong = 0x4004667a; $ gcc --target=x86_64-apple-darwin -o x x.c && file ./x && ./x ./x: Mach-O 64-bit executable x86_64 pub const FIOCLEX: ::c_uint = 0x20006601; pub const FIONCLEX: ::c_uint = 0x20006602; pub const FIONREAD: ::c_ulong = 0x4004667f; pub const FIONBIO: ::c_ulong = 0x8004667e; pub const FIOASYNC: ::c_ulong = 0x8004667d; pub const FIOSETOWN: ::c_ulong = 0x8004667c; pub const FIOGETOWN: ::c_ulong = 0x4004667b; pub const FIODTYPE: ::c_ulong = 0x4004667a; ``` I'm just awaiting an XCode install to check they're the same on arm.
-rw-r--r--src/unix/bsd/apple/b64.rs2
-rw-r--r--src/unix/bsd/apple/mod.rs7
2 files changed, 7 insertions, 2 deletions
diff --git a/src/unix/bsd/apple/b64.rs b/src/unix/bsd/apple/b64.rs
index 2b34f85345..ca98f20952 100644
--- a/src/unix/bsd/apple/b64.rs
+++ b/src/unix/bsd/apple/b64.rs
@@ -63,5 +63,3 @@ pub const __PTHREAD_RWLOCKATTR_SIZE__: usize = 16;
pub const TIOCTIMESTAMP: ::c_ulong = 0x40107459;
pub const TIOCDCDTIMESTAMP: ::c_ulong = 0x40107458;
-
-pub const FIONREAD: ::c_ulong = 0x4004667f;
diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs
index ffa626926a..4849d7f0f5 100644
--- a/src/unix/bsd/apple/mod.rs
+++ b/src/unix/bsd/apple/mod.rs
@@ -1085,6 +1085,13 @@ pub const TIOCPTYGRANT: ::c_uint = 0x20007454;
pub const TIOCPTYGNAME: ::c_uint = 0x40807453;
pub const TIOCPTYUNLK: ::c_uint = 0x20007452;
+pub const FIONCLEX: ::c_uint = 0x20006602;
+pub const FIONREAD: ::c_ulong = 0x4004667f;
+pub const FIOASYNC: ::c_ulong = 0x8004667d;
+pub const FIOSETOWN: ::c_ulong = 0x8004667c;
+pub const FIOGETOWN: ::c_ulong = 0x4004667b;
+pub const FIODTYPE: ::c_ulong = 0x4004667a;
+
pub const B0: speed_t = 0;
pub const B50: speed_t = 50;
pub const B75: speed_t = 75;