diff options
author | bors <bors@rust-lang.org> | 2018-07-31 01:25:13 +0000 |
---|---|---|
committer | bors <bors@rust-lang.org> | 2018-07-31 01:25:13 +0000 |
commit | e1ebfafc2f011216287c61ce8ff492f57dddee36 (patch) | |
tree | d2129972bb2c9856b428e84f0bec120b78bfdfc8 /libc-test | |
parent | 8565755356f23baf6b2df933ff734ce2f00c8d9b (diff) | |
parent | 86e83947ae58b085f4293cb5ae0860a66e03cdd1 (diff) | |
download | rust-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.
Diffstat (limited to 'libc-test')
0 files changed, 0 insertions, 0 deletions