From dc2e747b2a722e9e023fda94f3a9483116ece986 Mon Sep 17 00:00:00 2001 From: Jessica Hamilton Date: Sat, 2 Sep 2017 08:56:52 +1200 Subject: [PATCH 1/5] haiku: time_t is now 64-bit on x86_64. --- src/unix/haiku/b32.rs | 1 + src/unix/haiku/b64.rs | 1 + src/unix/haiku/mod.rs | 1 - 3 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/unix/haiku/b32.rs b/src/unix/haiku/b32.rs index 9b0b338b..cce88648 100644 --- a/src/unix/haiku/b32.rs +++ b/src/unix/haiku/b32.rs @@ -1,2 +1,3 @@ pub type c_long = i32; pub type c_ulong = u32; +pub type time_t = i32; diff --git a/src/unix/haiku/b64.rs b/src/unix/haiku/b64.rs index 5d63ce9c..3e66f14c 100644 --- a/src/unix/haiku/b64.rs +++ b/src/unix/haiku/b64.rs @@ -1,2 +1,3 @@ pub type c_ulong = u64; pub type c_long = i64; +pub type time_t = i64; diff --git a/src/unix/haiku/mod.rs b/src/unix/haiku/mod.rs index a659f73e..563142e5 100644 --- a/src/unix/haiku/mod.rs +++ b/src/unix/haiku/mod.rs @@ -9,7 +9,6 @@ pub type speed_t = ::c_uint; pub type c_char = i8; pub type clock_t = i32; pub type clockid_t = i32; -pub type time_t = i32; pub type suseconds_t = i32; pub type wchar_t = i32; pub type off_t = i64; From ab7925f8ea6fc8dc343ff3cbb9299ed6a8667ce4 Mon Sep 17 00:00:00 2001 From: Jessica Hamilton Date: Sat, 2 Sep 2017 08:57:45 +1200 Subject: [PATCH 2/5] haiku: add missing pthread_create. --- src/unix/haiku/mod.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/unix/haiku/mod.rs b/src/unix/haiku/mod.rs index 563142e5..2d0c8a57 100644 --- a/src/unix/haiku/mod.rs +++ b/src/unix/haiku/mod.rs @@ -636,7 +636,7 @@ pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { }; pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { flags: 0, - owner: 0, + owner: -1, lock_sem: 0, lock_count: 0, reader_count: 0, @@ -794,6 +794,10 @@ f! { extern { pub fn clock_gettime(clk_id: ::c_int, tp: *mut ::timespec) -> ::c_int; pub fn clock_settime(clk_id: ::c_int, tp: *const ::timespec) -> ::c_int; + pub fn pthread_create(thread: *mut ::pthread_t, + attr: *const ::pthread_attr_t, + f: extern fn(*mut ::c_void) -> *mut ::c_void, + value: *mut ::c_void) -> ::c_int; pub fn pthread_attr_getguardsize(attr: *const ::pthread_attr_t, guardsize: *mut ::size_t) -> ::c_int; pub fn pthread_attr_getstack(attr: *const ::pthread_attr_t, From b24c5888cdb0ae81bd9fd449f459f617f758d8c3 Mon Sep 17 00:00:00 2001 From: Jessica Hamilton Date: Fri, 1 Sep 2017 22:43:32 -0500 Subject: [PATCH 3/5] haiku: add missing SOCK_SEQPACKET. --- src/unix/haiku/mod.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/unix/haiku/mod.rs b/src/unix/haiku/mod.rs index 2d0c8a57..c193f2dd 100644 --- a/src/unix/haiku/mod.rs +++ b/src/unix/haiku/mod.rs @@ -553,7 +553,6 @@ pub const IFF_LOOPBACK: ::c_int = 0x0008; pub const AF_UNIX: ::c_int = 9; pub const AF_INET: ::c_int = 1; pub const AF_INET6: ::c_int = 6; -pub const SOCK_RAW: ::c_int = 3; pub const IP_MULTICAST_TTL: ::c_int = 10; pub const IP_MULTICAST_LOOP: ::c_int = 11; pub const IP_TTL: ::c_int = 4; @@ -661,6 +660,8 @@ pub const RUSAGE_CHILDREN: ::c_int = -1; pub const SOCK_STREAM: ::c_int = 1; pub const SOCK_DGRAM: ::c_int = 2; +pub const SOCK_RAW: ::c_int = 3; +pub const SOCK_SEQPACKET: ::c_int = 5; pub const SOL_SOCKET: ::c_int = -1; pub const SO_ACCEPTCONN: ::c_int = 0x00000001; From 07a430325c23f778d4d5db303a844700b222f194 Mon Sep 17 00:00:00 2001 From: Jessica Hamilton Date: Sat, 2 Sep 2017 04:29:42 -0500 Subject: [PATCH 4/5] haiku: add missing POSIX errors, reorder to match header. --- src/unix/haiku/mod.rs | 115 +++++++++++++++++++++++------------------- 1 file changed, 62 insertions(+), 53 deletions(-) diff --git a/src/unix/haiku/mod.rs b/src/unix/haiku/mod.rs index c193f2dd..bce79e7a 100644 --- a/src/unix/haiku/mod.rs +++ b/src/unix/haiku/mod.rs @@ -458,86 +458,95 @@ pub const MS_ASYNC: ::c_int = 0x01; pub const MS_INVALIDATE: ::c_int = 0x04; pub const MS_SYNC: ::c_int = 0x02; -pub const EPERM : ::c_int = -2147483633; -pub const ENOENT : ::c_int = -2147459069; -pub const ESRCH : ::c_int = -2147454963; -pub const EINTR : ::c_int = -2147483638; -pub const EIO : ::c_int = -2147483647; -pub const ENXIO : ::c_int = -2147454965; pub const E2BIG : ::c_int = -2147454975; -pub const ENOEXEC : ::c_int = -2147478782; -pub const EBADF : ::c_int = -2147459072; pub const ECHILD : ::c_int = -2147454974; pub const EDEADLK : ::c_int = -2147454973; -pub const ENOMEM : ::c_int = -2147454976; -pub const EACCES : ::c_int = -2147483646; -pub const EFAULT : ::c_int = -2147478783; -// pub const ENOTBLK : ::c_int = 15; -pub const EBUSY : ::c_int = -2147483634; -pub const EEXIST : ::c_int = -2147459070; -pub const EXDEV : ::c_int = -2147459061; -pub const ENODEV : ::c_int = -2147454969; -pub const ENOTDIR : ::c_int = -2147459067; -pub const EISDIR : ::c_int = -2147459063; -pub const EINVAL : ::c_int = -2147483643; -pub const ENFILE : ::c_int = -2147454970; -pub const EMFILE : ::c_int = -2147459062; -pub const ENOTTY : ::c_int = -2147454966; -pub const ETXTBSY : ::c_int = -2147454917; pub const EFBIG : ::c_int = -2147454972; -pub const ENOSPC : ::c_int = -2147459065; -pub const ESPIPE : ::c_int = -2147454964; -pub const EROFS : ::c_int = -2147459064; pub const EMLINK : ::c_int = -2147454971; -pub const EPIPE : ::c_int = -2147459059; +pub const ENFILE : ::c_int = -2147454970; +pub const ENODEV : ::c_int = -2147454969; +pub const ENOLCK : ::c_int = -2147454968; +pub const ENOSYS : ::c_int = -2147454967; +pub const ENOTTY : ::c_int = -2147454966; +pub const ENXIO : ::c_int = -2147454965; +pub const ESPIPE : ::c_int = -2147454964; +pub const ESRCH : ::c_int = -2147454963; +pub const EFPOS : ::c_int = -2147457962; +pub const ESIGPARM : ::c_int = -2147457961; pub const EDOM : ::c_int = -2147454960; pub const ERANGE : ::c_int = -2147454959; -pub const EAGAIN : ::c_int = -2147483637; -pub const EWOULDBLOCK : ::c_int = -2147483637; - -pub const EINPROGRESS : ::c_int = -2147454940; -pub const EALREADY : ::c_int = -2147454939; -pub const ENOTSOCK : ::c_int = -2147454932; -pub const EDESTADDRREQ : ::c_int = -2147454928; -pub const EMSGSIZE : ::c_int = -2147454934; pub const EPROTOTYPE : ::c_int = -2147454958; -pub const ENOPROTOOPT : ::c_int = -2147454942; pub const EPROTONOSUPPORT : ::c_int = -2147454957; -pub const EOPNOTSUPP : ::c_int = -2147454933; pub const EPFNOSUPPORT : ::c_int = -2147454956; pub const EAFNOSUPPORT : ::c_int = -2147454955; pub const EADDRINUSE : ::c_int = -2147454954; pub const EADDRNOTAVAIL : ::c_int = -2147454953; -pub const ENETDOWN : ::c_int = -2147454953; +pub const ENETDOWN : ::c_int = -2147454952; pub const ENETUNREACH : ::c_int = -2147454951; pub const ENETRESET : ::c_int = -2147454950; pub const ECONNABORTED : ::c_int = -2147454949; pub const ECONNRESET : ::c_int = -2147454948; -pub const ENOBUFS : ::c_int = -2147454941; pub const EISCONN : ::c_int = -2147454947; pub const ENOTCONN : ::c_int = -2147454946; pub const ESHUTDOWN : ::c_int = -2147454945; -pub const ETIMEDOUT : ::c_int = -2147483639; pub const ECONNREFUSED : ::c_int = -2147454944; -pub const ELOOP : ::c_int = -2147459060; -pub const ENAMETOOLONG : ::c_int = -2147459068; -pub const EHOSTDOWN : ::c_int = -2147454931; pub const EHOSTUNREACH : ::c_int = -2147454943; -pub const ENOTEMPTY : ::c_int = -2147459066; -pub const EDQUOT : ::c_int = -2147454927; -pub const ESTALE : ::c_int = -2147454936; -pub const ENOLCK : ::c_int = -2147454968; -pub const ENOSYS : ::c_int = -2147454967; -pub const EIDRM : ::c_int = -2147454926; -pub const ENOMSG : ::c_int = -2147454937; -pub const EOVERFLOW : ::c_int = -2147454935; -pub const ECANCELED : ::c_int = -2147454929; +pub const ENOPROTOOPT : ::c_int = -2147454942; +pub const ENOBUFS : ::c_int = -2147454941; +pub const EINPROGRESS : ::c_int = -2147454940; +pub const EALREADY : ::c_int = -2147454939; pub const EILSEQ : ::c_int = -2147454938; -pub const ENOATTR : ::c_int = -2147454916; +pub const ENOMSG : ::c_int = -2147454937; +pub const ESTALE : ::c_int = -2147454936; +pub const EOVERFLOW : ::c_int = -2147454935; +pub const EMSGSIZE : ::c_int = -2147454934; +pub const EOPNOTSUPP : ::c_int = -2147454933; +pub const ENOTSOCK : ::c_int = -2147454932; +pub const EHOSTDOWN : ::c_int = -2147454931; pub const EBADMSG : ::c_int = -2147454930; +pub const ECANCELED : ::c_int = -2147454929; +pub const EDESTADDRREQ : ::c_int = -2147454928; +pub const EDQUOT : ::c_int = -2147454927; +pub const EIDRM : ::c_int = -2147454926; pub const EMULTIHOP : ::c_int = -2147454925; +pub const ENODATA : ::c_int = -2147454924; pub const ENOLINK : ::c_int = -2147454923; +pub const ENOSR : ::c_int = -2147454922; +pub const ENOSTR : ::c_int = -2147454921; +pub const ENOTSUP : ::c_int = -2147454920; pub const EPROTO : ::c_int = -2147454919; +pub const ETIME : ::c_int = -2147454918; +pub const ETXTBSY : ::c_int = -2147454917; +pub const ENOATTR : ::c_int = -2147454916; + +// INT_MIN +pub const ENOMEM : ::c_int = -2147454976; + +// POSIX errors that can be mapped to BeOS error codes +pub const EACCES : ::c_int = -2147483646; +pub const EINTR : ::c_int = -2147483638; +pub const EIO : ::c_int = -2147483647; +pub const EBUSY : ::c_int = -2147483634; +pub const EFAULT : ::c_int = -2147478783; +pub const ETIMEDOUT : ::c_int = -2147483639; +pub const EAGAIN : ::c_int = -2147483637; +pub const EWOULDBLOCK : ::c_int = -2147483637; +pub const EBADF : ::c_int = -2147459072; +pub const EEXIST : ::c_int = -2147459070; +pub const EINVAL : ::c_int = -2147483643; +pub const ENAMETOOLONG : ::c_int = -2147459068; +pub const ENOENT : ::c_int = -2147459069; +pub const EPERM : ::c_int = -2147483633; +pub const ENOTDIR : ::c_int = -2147459067; +pub const EISDIR : ::c_int = -2147459063; +pub const ENOTEMPTY : ::c_int = -2147459066; +pub const ENOSPC : ::c_int = -2147459065; +pub const EROFS : ::c_int = -2147459064; +pub const EMFILE : ::c_int = -214745962; +pub const EXDEV : ::c_int = -2147459061; +pub const ELOOP : ::c_int = -2147459060; +pub const ENOEXEC : ::c_int = -2147478782; +pub const EPIPE : ::c_int = -2147459059; pub const IPPROTO_RAW: ::c_int = 255; From 17c74f499d6dac53ee260738537bd10617426a97 Mon Sep 17 00:00:00 2001 From: Jessica Hamilton Date: Sat, 2 Sep 2017 06:50:49 -0500 Subject: [PATCH 5/5] haiku: res_init link name is __res_init. --- src/unix/mod.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/unix/mod.rs b/src/unix/mod.rs index fcbc3ebe..cacc3932 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -708,7 +708,8 @@ extern { #[cfg_attr(any( all(target_os = "linux", not(target_env = "musl")), target_os = "freebsd", - target_os = "dragonfly"), + target_os = "dragonfly", + target_os = "haiku"), link_name = "__res_init")] #[cfg_attr(any(target_os = "macos", target_os = "ios"), link_name = "res_9_init")]