Skip to content

Commit 3c91010

Browse files
committed
haiku: add missing definitions found from building nix.
1 parent ee8a490 commit 3c91010

File tree

1 file changed

+221
-43
lines changed

1 file changed

+221
-43
lines changed

src/unix/haiku/mod.rs

Lines changed: 221 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,14 @@ s! {
169169
pub c_cc: [::cc_t; ::NCCS],
170170
}
171171

172+
pub struct flock {
173+
pub l_type: ::c_short,
174+
pub l_whence: ::c_short,
175+
pub l_start: ::off_t,
176+
pub l_len: ::off_t,
177+
pub l_pid: ::pid_t,
178+
}
179+
172180
pub struct stat {
173181
pub st_dev: dev_t,
174182
pub st_ino: ino_t,
@@ -290,6 +298,14 @@ s! {
290298
sa_userdata: *mut ::c_void,
291299
}
292300

301+
pub struct sigevent {
302+
pub sigev_notify: ::c_int,
303+
pub sigev_signo: ::c_int,
304+
pub sigev_value: ::sigval,
305+
__unused1: *mut ::c_void, // actually a function pointer
306+
pub sigev_notify_attributes: *mut ::pthread_attr_t,
307+
}
308+
293309
pub struct sem_t {
294310
pub se_type: i32,
295311
pub se_named_id: i32, // this is actually a union
@@ -330,6 +346,27 @@ pub const F_GETFD: ::c_int = 0x0002;
330346
pub const F_SETFD: ::c_int = 0x0004;
331347
pub const F_GETFL: ::c_int = 0x0008;
332348
pub const F_SETFL: ::c_int = 0x0010;
349+
pub const F_GETLK: ::c_int = 0x0020;
350+
pub const F_SETLK: ::c_int = 0x0080;
351+
pub const F_SETLKW: ::c_int = 0x0100;
352+
pub const F_DUPFD_CLOEXEC: ::c_int = 0x0200;
353+
354+
pub const AT_FDCWD: ::c_int = -1;
355+
pub const AT_SYMLINK_NOFOLLOW: ::c_int = 0x01;
356+
pub const AT_SYMLINK_FOLLOW: ::c_int = 0x02;
357+
pub const AT_REMOVEDIR: ::c_int = 0x04;
358+
pub const AT_EACCESS: ::c_int = 0x08;
359+
360+
pub const POLLIN: ::c_short = 0x0001;
361+
pub const POLLOUT: ::c_short = 0x0002;
362+
pub const POLLRDNORM: ::c_short = POLLIN;
363+
pub const POLLWRNORM: ::c_short = POLLOUT;
364+
pub const POLLRDBAND: ::c_short = 0x0008;
365+
pub const POLLWRBAND: ::c_short = 0x0010;
366+
pub const POLLPRI: ::c_short = 0x0020;
367+
pub const POLLERR: ::c_short = 0x0004;
368+
pub const POLLHUP: ::c_short = 0x0080;
369+
pub const POLLNVAL: ::c_short = 0x1000;
333370

334371
pub const PTHREAD_CREATE_JOINABLE: ::c_int = 0;
335372
pub const PTHREAD_CREATE_DETACHED: ::c_int = 1;
@@ -349,6 +386,8 @@ pub const RLIMIT_NLIMITS: ::c_int = 8;
349386

350387
pub const RUSAGE_SELF: ::c_int = 0;
351388

389+
pub const RTLD_LAXY: ::c_int = 0;
390+
352391
pub const NCCS: usize = 11;
353392

354393
pub const O_RDONLY: ::c_int = 0x0000;
@@ -431,6 +470,14 @@ pub const SIGXCPU: ::c_int = 28;
431470
pub const SIGXFSZ: ::c_int = 29;
432471
pub const SIGBUS: ::c_int = 30;
433472

473+
pub const SIG_BLOCK: ::c_int = 1;
474+
pub const SIG_UNBLOCK: ::c_int = 2;
475+
pub const SIG_SETMASK: ::c_int = 3;
476+
477+
pub const SIGEV_NONE: ::c_int = 0;
478+
pub const SIGEV_SIGNAL: ::c_int = 1;
479+
pub const SIGEV_THREAD: ::c_int = 2;
480+
434481
pub const EAI_SYSTEM: ::c_int = 11;
435482

436483
pub const PROT_NONE: ::c_int = 0;
@@ -450,7 +497,9 @@ pub const LC_MESSAGES: ::c_int = 6;
450497
pub const MAP_FILE: ::c_int = 0x00;
451498
pub const MAP_SHARED: ::c_int = 0x01;
452499
pub const MAP_PRIVATE: ::c_int = 0x02;
453-
pub const MAP_FIXED: ::c_int = 0x004;
500+
pub const MAP_FIXED: ::c_int = 0x04;
501+
pub const MAP_ANONYMOUS: ::c_int = 0x08;
502+
pub const MAP_ANON: ::c_int = MAP_ANONYMOUS;
454503

455504
pub const MAP_FAILED: *mut ::c_void = !0 as *mut ::c_void;
456505

@@ -559,9 +608,20 @@ pub const MADV_DONTNEED: ::c_int = 5;
559608

560609
pub const IFF_LOOPBACK: ::c_int = 0x0008;
561610

562-
pub const AF_UNIX: ::c_int = 9;
611+
pub const AF_UNSEC: ::c_int = 0;
563612
pub const AF_INET: ::c_int = 1;
564-
pub const AF_INET6: ::c_int = 6;
613+
pub const AF_APPLETALK: ::c_int = 2;
614+
pub const AF_ROUTE: ::c_int = 3;
615+
pub const AF_LINK: ::c_int = 4;
616+
pub const AF_INET6: ::c_int = 5;
617+
pub const AF_DLI: ::c_int = 6;
618+
pub const AF_IPX: ::c_int = 7;
619+
pub const AF_NOTIFY: ::c_int = 8;
620+
pub const AF_LOCAL: ::c_int = 9;
621+
pub const AF_UNIX: ::c_int = AF_LOCAL;
622+
pub const AF_BLUETOOTH: ::c_int = 10;
623+
pub const AF_MAX: ::c_int = 11;
624+
565625
pub const IP_MULTICAST_TTL: ::c_int = 10;
566626
pub const IP_MULTICAST_LOOP: ::c_int = 11;
567627
pub const IP_TTL: ::c_int = 4;
@@ -579,9 +639,17 @@ pub const IPV6_JOIN_GROUP: ::c_int = 28;
579639
pub const IPV6_LEAVE_GROUP: ::c_int = 29;
580640
pub const IPV6_V6ONLY: ::c_int = 30;
581641

582-
pub const SO_DEBUG: ::c_int = 0x00000004;
583-
584-
pub const MSG_PEEK: ::c_int = 0x2;
642+
pub const MSG_OOB: ::c_int = 0x0001;
643+
pub const MSG_PEEK: ::c_int = 0x0002;
644+
pub const MSG_DONTROUTE: ::c_int = 0x0004;
645+
pub const MSG_EOR: ::c_int = 0x0008;
646+
pub const MSG_TRUNC: ::c_int = 0x0010;
647+
pub const MSG_CTRUNC: ::c_int = 0x0020;
648+
pub const MSG_WAITALL: ::c_int = 0x0040;
649+
pub const MSG_DONTWAIT: ::c_int = 0x0080;
650+
pub const MSG_BCAST: ::c_int = 0x0100;
651+
pub const MSG_MCAST: ::c_int = 0x0200;
652+
pub const MSG_EOF: ::c_int = 0x0400;
585653
pub const MSG_NOSIGNAL: ::c_int = 0x0800;
586654

587655
pub const SHUT_RD: ::c_int = 0;
@@ -597,10 +665,16 @@ pub const SIGSTKSZ: ::size_t = 16384;
597665

598666
pub const PATH_MAX: ::c_int = 1024;
599667

600-
pub const SA_NODEFER: ::c_int = 0x08;
668+
pub const SA_NOCLDSTOP: ::c_int = 0x01;
669+
pub const SA_NOCLDWAIT: ::c_int = 0x02;
601670
pub const SA_RESETHAND: ::c_int = 0x04;
671+
pub const SA_NODEFER: ::c_int = 0x08;
602672
pub const SA_RESTART: ::c_int = 0x10;
603-
pub const SA_NOCLDSTOP: ::c_int = 0x01;
673+
pub const SA_ONSTACK: ::c_int = 0x20;
674+
pub const SA_SIGINFO: ::c_int = 0x40;
675+
pub const SA_NOMASK: ::c_int = SA_NODEFER;
676+
pub const SA_STACK: ::c_int = SA_ONSTACK;
677+
pub const SA_ONESHOT: ::c_int = SA_RESETHAND;
604678

605679
pub const FD_SETSIZE: usize = 1024;
606680

@@ -718,12 +792,6 @@ pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 3;
718792

719793
pub const FIOCLEX: c_ulong = 0; // TODO: does not exist on Haiku!
720794

721-
pub const SA_ONSTACK: c_ulong = 0x20;
722-
pub const SA_SIGINFO: c_ulong = 0x40;
723-
pub const SA_NOCLDWAIT: c_ulong = 0x02;
724-
725-
pub const SIG_SETMASK: ::c_int = 3;
726-
727795
pub const RUSAGE_CHILDREN: ::c_int = -1;
728796

729797
pub const SOCK_STREAM: ::c_int = 1;
@@ -734,6 +802,7 @@ pub const SOCK_SEQPACKET: ::c_int = 5;
734802
pub const SOL_SOCKET: ::c_int = -1;
735803
pub const SO_ACCEPTCONN: ::c_int = 0x00000001;
736804
pub const SO_BROADCAST: ::c_int = 0x00000002;
805+
pub const SO_DEBUG: ::c_int = 0x00000004;
737806
pub const SO_DONTROUTE: ::c_int = 0x00000008;
738807
pub const SO_KEEPALIVE: ::c_int = 0x00000010;
739808
pub const SO_OOBINLINE: ::c_int = 0x00000020;
@@ -753,6 +822,8 @@ pub const SO_NONBLOCK: ::c_int = 0x40000009;
753822
pub const SO_BINDTODEVICE: ::c_int = 0x4000000a;
754823
pub const SO_PEERCRED: ::c_int = 0x4000000b;
755824

825+
pub const SCM_RIGHTS: ::c_int = 0x01;
826+
756827
pub const NI_MAXHOST: ::size_t = 1025;
757828

758829
pub const WNOHANG: ::c_int = 0x01;
@@ -779,34 +850,83 @@ pub const VSWTCH: usize = 7;
779850
pub const VSTART: usize = 8;
780851
pub const VSTOP: usize = 9;
781852
pub const VSUSP: usize = 10;
782-
pub const OLCUC: ::tcflag_t = 0o000002;
783-
pub const OCRNL: ::tcflag_t = 0o000010;
784-
pub const ONOCR: ::tcflag_t = 0o000020;
785-
pub const ONLRET: ::tcflag_t = 0o000040;
786-
pub const OFILL: ::tcflag_t = 0o000100;
787-
pub const OFDEL: ::tcflag_t = 0o000200;
788-
pub const NLDLY: ::tcflag_t = 0o000400;
789-
pub const NL0: ::tcflag_t = 0o000000;
790-
pub const NL1: ::tcflag_t = 0o000400;
791-
pub const CRDLY: ::tcflag_t = 0o003000;
792-
pub const CR0: ::tcflag_t = 0o000000;
793-
pub const CR1: ::tcflag_t = 0o001000;
794-
pub const CR2: ::tcflag_t = 0o002000;
795-
pub const CR3: ::tcflag_t = 0o003000;
796-
pub const TABDLY: ::tcflag_t = 0o014000;
797-
pub const TAB0: ::tcflag_t = 0o000000;
798-
pub const TAB1: ::tcflag_t = 0o004000;
799-
pub const TAB2: ::tcflag_t = 0o010000;
800-
pub const TAB3: ::tcflag_t = 0o014000;
801-
pub const BSDLY: ::tcflag_t = 0o020000;
802-
pub const BS0: ::tcflag_t = 0o000000;
803-
pub const BS1: ::tcflag_t = 0o020000;
804-
pub const FFDLY: ::tcflag_t = 0o100000;
805-
pub const FF0: ::tcflag_t = 0o000000;
806-
pub const FF1: ::tcflag_t = 0o100000;
807-
pub const VTDLY: ::tcflag_t = 0o040000;
808-
pub const VT0: ::tcflag_t = 0o000000;
809-
pub const VT1: ::tcflag_t = 0o040000;
853+
854+
pub const IGNBRK: ::tcflag_t = 0x01;
855+
pub const BRKINT: ::tcflag_t = 0x02;
856+
pub const IGNPAR: ::tcflag_t = 0x04;
857+
pub const PARMRK: ::tcflag_t = 0x08;
858+
pub const INPCK: ::tcflag_t = 0x10;
859+
pub const ISTRIP: ::tcflag_t = 0x20;
860+
pub const INLCR: ::tcflag_t = 0x40;
861+
pub const IGNCR: ::tcflag_t = 0x80;
862+
pub const ICRNL: ::tcflag_t = 0x100;
863+
pub const IUCLC: ::tcflag_t = 0x200;
864+
pub const IXON: ::tcflag_t = 0x400;
865+
pub const IXANY: ::tcflag_t = 0x800;
866+
pub const IXOFF: ::tcflag_t = 0x1000;
867+
868+
pub const OPOST: ::tcflag_t = 0x00000001;
869+
pub const OLCUC: ::tcflag_t = 0x00000002;
870+
pub const ONLCR: ::tcflag_t = 0x00000004;
871+
pub const OCRNL: ::tcflag_t = 0x00000008;
872+
pub const ONOCR: ::tcflag_t = 0x00000010;
873+
pub const ONLRET: ::tcflag_t = 0x00000020;
874+
pub const OFILL: ::tcflag_t = 0x00000040;
875+
pub const OFDEL: ::tcflag_t = 0x00000080;
876+
pub const NLDLY: ::tcflag_t = 0x00000100;
877+
pub const NL0: ::tcflag_t = 0x00000000;
878+
pub const NL1: ::tcflag_t = 0x00000100;
879+
pub const CRDLY: ::tcflag_t = 0x00000600;
880+
pub const CR0: ::tcflag_t = 0x00000000;
881+
pub const CR1: ::tcflag_t = 0x00000200;
882+
pub const CR2: ::tcflag_t = 0x00000400;
883+
pub const CR3: ::tcflag_t = 0x00000600;
884+
pub const TABDLY: ::tcflag_t = 0x00001800;
885+
pub const TAB0: ::tcflag_t = 0x00000000;
886+
pub const TAB1: ::tcflag_t = 0x00000800;
887+
pub const TAB2: ::tcflag_t = 0x00001000;
888+
pub const TAB3: ::tcflag_t = 0x00001800;
889+
pub const BSDLY: ::tcflag_t = 0x00002000;
890+
pub const BS0: ::tcflag_t = 0x00000000;
891+
pub const BS1: ::tcflag_t = 0x00002000;
892+
pub const VTDLY: ::tcflag_t = 0x00004000;
893+
pub const VT0: ::tcflag_t = 0x00000000;
894+
pub const VT1: ::tcflag_t = 0x00004000;
895+
pub const FFDLY: ::tcflag_t = 0x00008000;
896+
pub const FF0: ::tcflag_t = 0x00000000;
897+
pub const FF1: ::tcflag_t = 0x00008000;
898+
899+
pub const CSIZE: ::tcflag_t = 0x00000020;
900+
pub const CS5: ::tcflag_t = 0x00000000;
901+
pub const CS6: ::tcflag_t = 0x00000000;
902+
pub const CS7: ::tcflag_t = 0x00000000;
903+
pub const CS8: ::tcflag_t = 0x00000020;
904+
pub const CSTOPB: ::tcflag_t = 0x00000040;
905+
pub const CREAD: ::tcflag_t = 0x00000080;
906+
pub const PARENB: ::tcflag_t = 0x00000100;
907+
pub const PARODD: ::tcflag_t = 0x00000200;
908+
pub const HUPCL: ::tcflag_t = 0x00000400;
909+
pub const CLOCAL: ::tcflag_t = 0x00000800;
910+
pub const XLOBLK: ::tcflag_t = 0x00001000;
911+
pub const CTSFLOW: ::tcflag_t = 0x00002000;
912+
pub const RTSFLOW: ::tcflag_t = 0x00004000;
913+
pub const CRTSCTS: ::tcflag_t = RTSFLOW | CTSFLOW;
914+
915+
pub const ISIG: ::tcflag_t = 0x00000001;
916+
pub const ICANON: ::tcflag_t = 0x00000002;
917+
pub const XCASE: ::tcflag_t = 0x00000004;
918+
pub const ECHO: ::tcflag_t = 0x00000008;
919+
pub const ECHOE: ::tcflag_t = 0x00000010;
920+
pub const ECHOK: ::tcflag_t = 0x00000020;
921+
pub const ECHONL: ::tcflag_t = 0x00000040;
922+
pub const NOFLSH: ::tcflag_t = 0x00000080;
923+
pub const TOSTOP: ::tcflag_t = 0x00000100;
924+
pub const IEXTEN: ::tcflag_t = 0x00000200;
925+
pub const ECHOCTL: ::tcflag_t = 0x00000400;
926+
pub const ECHOPRT: ::tcflag_t = 0x00000800;
927+
pub const ECHOKE: ::tcflag_t = 0x00001000;
928+
pub const FLUSHO: ::tcflag_t = 0x00002000;
929+
pub const PENDIN: ::tcflag_t = 0x00004000;
810930

811931
pub const TCGB_CTS: ::c_int = 0x01;
812932
pub const TCGB_DSR: ::c_int = 0x02;
@@ -820,6 +940,40 @@ pub const TIOCM_DSR: ::c_int = TCGB_DSR;
820940
pub const TIOCM_DTR: ::c_int = 0x10;
821941
pub const TIOCM_RTS: ::c_int = 0x20;
822942

943+
pub const B0: speed_t = 0x00;
944+
pub const B50: speed_t = 0x01;
945+
pub const B75: speed_t = 0x02;
946+
pub const B110: speed_t = 0x03;
947+
pub const B134: speed_t = 0x04;
948+
pub const B150: speed_t = 0x05;
949+
pub const B200: speed_t = 0x06;
950+
pub const B300: speed_t = 0x07;
951+
pub const B600: speed_t = 0x08;
952+
pub const B1200: speed_t = 0x09;
953+
pub const B1800: speed_t = 0x0A;
954+
pub const B2400: speed_t = 0x0B;
955+
pub const B4800: speed_t = 0x0C;
956+
pub const B9600: speed_t = 0x0D;
957+
pub const B19200: speed_t = 0x0E;
958+
pub const B38400: speed_t = 0x0F;
959+
pub const B57600: speed_t = 0x10;
960+
pub const B115200: speed_t = 0x11;
961+
pub const B230400: speed_t = 0x12;
962+
pub const B31250: speed_t = 0x13;
963+
964+
pub const TCSANOW: ::c_int = 0x01;
965+
pub const TCSADRAIN: ::c_int = 0x02;
966+
pub const TCSAFLUSH: ::c_int = 0x04;
967+
968+
pub const TCOOFF: ::c_int = 0x01;
969+
pub const TCOON: ::c_int = 0x02;
970+
pub const TCIOFF: ::c_int = 0x04;
971+
pub const TCION: ::c_int = 0x08;
972+
973+
pub const TCIFLUSH: ::c_int = 0x01;
974+
pub const TCOFLUSH: ::c_int = 0x02;
975+
pub const TCIOFLUSH: ::c_int = 0x03;
976+
823977
f! {
824978
pub fn FD_CLR(fd: ::c_int, set: *mut fd_set) -> () {
825979
let fd = fd as usize;
@@ -848,16 +1002,37 @@ f! {
8481002
}
8491003

8501004
pub fn WIFEXITED(status: ::c_int) -> bool {
851-
(status >> 8) == 0
1005+
(status & !0xff) == 0
8521006
}
8531007

8541008
pub fn WEXITSTATUS(status: ::c_int) -> ::c_int {
8551009
(status & 0xff)
8561010
}
8571011

1012+
pub fn WIFSIGNALED(status: ::c_int) -> bool {
1013+
((status >> 8) & 0xff) != 0
1014+
}
1015+
8581016
pub fn WTERMSIG(status: ::c_int) -> ::c_int {
8591017
(status >> 8) & 0xff
8601018
}
1019+
1020+
pub fn WIFSTOPPED(status: ::c_int) -> bool {
1021+
((status >> 16) & 0xff) != 0
1022+
}
1023+
1024+
pub fn WSTOPSIG(status: ::c_int) -> ::c_int {
1025+
(status >> 16) & 0xff
1026+
}
1027+
1028+
// actually WIFCORED, but this is used everywhere else
1029+
pub fn WCOREDUMP(status: ::c_int) -> bool {
1030+
(status & 0x10000) != 0
1031+
}
1032+
1033+
pub fn WIFCONTINUED(status: ::c_int) -> bool {
1034+
(status & 0x20000) != 0
1035+
}
8611036
}
8621037

8631038
#[link(name = "bsd")]
@@ -907,6 +1082,8 @@ extern {
9071082
pub fn posix_madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int)
9081083
-> ::c_int;
9091084

1085+
pub fn shm_open(name: *const ::c_char, oflag: ::c_int, mode: ::mode_t)
1086+
-> ::c_int;
9101087
pub fn shm_unlink(name: *const ::c_char) -> ::c_int;
9111088

9121089
pub fn seekdir(dirp: *mut ::DIR, loc: ::c_long);
@@ -1005,6 +1182,7 @@ extern {
10051182
name: *mut ::c_char,
10061183
termp: *mut termios,
10071184
winp: *mut ::winsize) -> ::pid_t;
1185+
pub fn sethostname(name: *const ::c_char, len: ::size_t) -> ::c_int;
10081186
}
10091187

10101188
cfg_if! {

0 commit comments

Comments
 (0)