From bd50e599b64e7a1a40cd102e3b577fec6ba25016 Mon Sep 17 00:00:00 2001 From: Sebastian Humenda Date: Mon, 7 Aug 2017 19:15:21 +0200 Subject: [PATCH 01/10] Improve types for uclibc/x86_64 * fix dirent, dirent64 * port pthread_attr_t * add l4re-specific pthread code --- src/unix/uclibc/x86_64/mod.rs | 79 ++++++++++++++++++++++++++--------- 1 file changed, 59 insertions(+), 20 deletions(-) diff --git a/src/unix/uclibc/x86_64/mod.rs b/src/unix/uclibc/x86_64/mod.rs index 603efb10fcfa..3f57db2619c8 100644 --- a/src/unix/uclibc/x86_64/mod.rs +++ b/src/unix/uclibc/x86_64/mod.rs @@ -22,7 +22,29 @@ pub type wchar_t = ::c_int; //pub type d_ino = ::c_ulong; pub type nfds_t = ::c_ulong; +// L4Re specifics +// Some of these aren't actually part of the libc, but of l4sys, but since libc +// depends on l4sys on this platform, we should dump the few important +// definitions here. +pub type l4_umword_t = ::c_ulong; // Unsigned machine word. + s! { + pub struct dirent { + pub d_ino: ::ino64_t, + pub d_off: ::off64_t, + pub d_reclen: u16, + pub d_type: u8, + pub d_name: [::c_char; 256], + } + + pub struct dirent64 { + pub d_ino: ::ino64_t, + pub d_off: ::off64_t, + pub d_reclen: u16, + pub d_type: u8, + pub d_name: [::c_char; 256], + } + pub struct ipc_perm { pub __key: ::key_t, pub uid: ::uid_t, @@ -37,6 +59,43 @@ s! { __unused2: ::c_ulong } + /// CPU sets. + pub struct l4_sched_cpu_set_t { + // from the L4Re docs + /// Combination of granularity and offset. + /// + /// The granularity defines how many CPUs each bit in map describes. + /// The offset is the numer of the first CPU described by the first + /// bit in the bitmap. + /// offset must be a multiple of 2^graularity. + /// + /// | MSB | LSB | + /// | ---------------- | ------------------- | + /// | 8bit granularity | 24bit offset .. | + gran_offset: l4_umword_t , + /// Bitmap of CPUs. + map: l4_umword_t , + } + + pub struct pthread_attr_t { + __detachstate: ::c_int, + __schedpolicy: ::c_int, + __schedparam: __sched_param, + __inheritsched: ::c_int, + __scope: ::c_int, + __guardsize: ::size_t, + __stackaddr_set: ::c_int, + __stackaddr: *mut ::c_void, // better don't use it + __stacksize: ::size_t, + // L4Re specifics + affinity: l4_sched_cpu_set_t, + create_flags: ::c_uint, + } + + pub struct __sched_param { + __sched_priority: ::c_int, + } + pub struct siginfo_t { si_signo: ::c_int, // signal number si_errno: ::c_int, // if not zero: error value of signal, see errno.h @@ -147,26 +206,6 @@ s! { __f_spare: [::c_int; 6], } - pub struct dirent { // Todo - pub d_ino: ::ino64_t, - pub d_off: ::off64_t, - d_reclen: u16, - pub d_type: u8, - pub d_name: [i8; 256], - } - - pub struct dirent64 { // - pub d_ino: ::ino64_t, - pub d_off: ::off64_t, - pub d_reclen: u16, - pub d_type: u8, - pub d_name: [i8; 256], - } - - pub struct pthread_attr_t { // ToDo - __size: [u64; 7] - } - pub struct sigaction { // TODO!! pub sa_sigaction: ::sighandler_t, pub sa_mask: ::sigset_t, From 86cb2a2c2b55fca6cdff3d67477c556b386c28de Mon Sep 17 00:00:00 2001 From: Sebastian Humenda Date: Tue, 8 Aug 2017 12:27:47 +0200 Subject: [PATCH 02/10] add more uclibc constants --- src/unix/uclibc/x86_64/mod.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/unix/uclibc/x86_64/mod.rs b/src/unix/uclibc/x86_64/mod.rs index 3f57db2619c8..8c7359d7ec02 100644 --- a/src/unix/uclibc/x86_64/mod.rs +++ b/src/unix/uclibc/x86_64/mod.rs @@ -381,9 +381,26 @@ s! { } // constants +pub const EADDRINUSE: ::c_int = 98; // Address already in use +pub const EADDRNOTAVAIL: ::c_int = 99; // Cannot assign requested address +pub const ECONNABORTED: ::c_int = 103; // Software caused connection abort +pub const ECONNREFUSED: ::c_int = 111; // Connection refused +pub const ECONNRESET: ::c_int = 104; // Connection reset by peer +pub const EDEADLK: ::c_int = 35; // Resource deadlock would occur +pub const ENOSYS: ::c_int = 38; // Function not implemented +pub const ENOTCONN: ::c_int = 107; // Transport endpoint is not connected +pub const ETIMEDOUT: ::c_int = 110; // connection timed out +pub const O_APPEND: ::c_int = 02000; +pub const O_ACCMODE: ::c_int = 0003; pub const O_CLOEXEC: ::c_int = 0x80000; +pub const O_CREAT: ::c_int = 0100; pub const O_DIRECTORY: ::c_int = 0200000; +pub const O_EXCL: ::c_int = 0200; +pub const O_NONBLOCK: ::c_int = 04000; +pub const O_TRUNC: ::c_int = 01000; pub const NCCS: usize = 32; +pub const PTHREAD_STACK_MIN: ::c_int = 16384; +pub const SIG_SETMASK: ::c_int = 2; // Set the set of blocked signals pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; pub const PTHREAD_MUTEX_NORMAL: ::c_int = 0; From e412497d3e0dd03d32417544936b9be672e0b33a Mon Sep 17 00:00:00 2001 From: Sebastian Humenda Date: Tue, 8 Aug 2017 14:06:28 +0200 Subject: [PATCH 03/10] Move L4Re-specific code into separate module. --- src/unix/uclibc/x86_64/l4re.rs | 43 ++++++++++++++++++++++++++++++++++ src/unix/uclibc/x86_64/mod.rs | 42 ++++++++++----------------------- 2 files changed, 55 insertions(+), 30 deletions(-) create mode 100644 src/unix/uclibc/x86_64/l4re.rs diff --git a/src/unix/uclibc/x86_64/l4re.rs b/src/unix/uclibc/x86_64/l4re.rs new file mode 100644 index 000000000000..06a9f09b142a --- /dev/null +++ b/src/unix/uclibc/x86_64/l4re.rs @@ -0,0 +1,43 @@ +/// L4Re specifics +/// This module contains definitions required by various L4Re libc backends. +/// These are formally not part of the libc, but are a dependency of the libc +/// and hence we should provide them here. + +pub type l4_umword_t = ::c_ulong; // Unsigned machine word. + +s! { + /// CPU sets. + pub struct l4_sched_cpu_set_t { + // from the L4Re docs + /// Combination of granularity and offset. + /// + /// The granularity defines how many CPUs each bit in map describes. + /// The offset is the numer of the first CPU described by the first + /// bit in the bitmap. + /// offset must be a multiple of 2^graularity. + /// + /// | MSB | LSB | + /// | ---------------- | ------------------- | + /// | 8bit granularity | 24bit offset .. | + gran_offset: l4_umword_t , + /// Bitmap of CPUs. + map: l4_umword_t , + } +} + +#[cfg(target_os = "l4re")] +pub struct pthread_attr_t { + pub __detachstate: ::c_int, + pub __schedpolicy: ::c_int, + pub __schedparam: super::__sched_param, + pub __inheritsched: ::c_int, + pub __scope: ::c_int, + pub __guardsize: ::size_t, + pub __stackaddr_set: ::c_int, + pub __stackaddr: *mut ::c_void, // better don't use it + pub __stacksize: ::size_t, + // L4Re specifics + pub affinity: l4_sched_cpu_set_t, + pub create_flags: ::c_uint, +} + diff --git a/src/unix/uclibc/x86_64/mod.rs b/src/unix/uclibc/x86_64/mod.rs index 8c7359d7ec02..b5de65a91676 100644 --- a/src/unix/uclibc/x86_64/mod.rs +++ b/src/unix/uclibc/x86_64/mod.rs @@ -1,5 +1,5 @@ -//! Definitions for l4re-uclibc on 64bit systems - +//! Definitions for uclibc on 64bit systems +//! pub type blkcnt_t = i64; pub type blksize_t = i64; pub type clock_t = i64; @@ -22,12 +22,6 @@ pub type wchar_t = ::c_int; //pub type d_ino = ::c_ulong; pub type nfds_t = ::c_ulong; -// L4Re specifics -// Some of these aren't actually part of the libc, but of l4sys, but since libc -// depends on l4sys on this platform, we should dump the few important -// definitions here. -pub type l4_umword_t = ::c_ulong; // Unsigned machine word. - s! { pub struct dirent { pub d_ino: ::ino64_t, @@ -59,24 +53,7 @@ s! { __unused2: ::c_ulong } - /// CPU sets. - pub struct l4_sched_cpu_set_t { - // from the L4Re docs - /// Combination of granularity and offset. - /// - /// The granularity defines how many CPUs each bit in map describes. - /// The offset is the numer of the first CPU described by the first - /// bit in the bitmap. - /// offset must be a multiple of 2^graularity. - /// - /// | MSB | LSB | - /// | ---------------- | ------------------- | - /// | 8bit granularity | 24bit offset .. | - gran_offset: l4_umword_t , - /// Bitmap of CPUs. - map: l4_umword_t , - } - + #[cfg(not(target_os = "l4re"))] pub struct pthread_attr_t { __detachstate: ::c_int, __schedpolicy: ::c_int, @@ -87,9 +64,6 @@ s! { __stackaddr_set: ::c_int, __stackaddr: *mut ::c_void, // better don't use it __stacksize: ::size_t, - // L4Re specifics - affinity: l4_sched_cpu_set_t, - create_flags: ::c_uint, } pub struct __sched_param { @@ -399,7 +373,7 @@ pub const O_EXCL: ::c_int = 0200; pub const O_NONBLOCK: ::c_int = 04000; pub const O_TRUNC: ::c_int = 01000; pub const NCCS: usize = 32; -pub const PTHREAD_STACK_MIN: ::c_int = 16384; +pub const PTHREAD_STACK_MIN: usize = 16384; pub const SIG_SETMASK: ::c_int = 2; // Set the set of blocked signals pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; @@ -415,3 +389,11 @@ pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; extern { pub fn memalign(align: ::size_t, size: ::size_t) -> *mut ::c_void; } + +cfg_if! { + if #[cfg(target_os = "l4re")] { + mod l4re; + pub use self::l4re::*; + } else { } +} + From 85f181c953a62f484790497f4dbb7dd1a27c72f5 Mon Sep 17 00:00:00 2001 From: Sebastian Humenda Date: Wed, 9 Aug 2017 14:18:32 +0200 Subject: [PATCH 04/10] Do not link libraries on l4re by default L4Re builds don't have default libraries. The L4Re build system controls compilation and passes linker flags using -Z itself. --- 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 cb66c049fd01..3bae7f19fbdc 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -230,8 +230,9 @@ pub const INADDR_BROADCAST: in_addr_t = 4294967295; pub const INADDR_NONE: in_addr_t = 4294967295; cfg_if! { - if #[cfg(dox)] { + if #[cfg(any(dox, target_os = "l4re"))] { // on dox builds don't pull in anything + // L4Re builds pass the required libs using -Z to the compiler. } else if #[cfg(all(not(stdbuild), feature = "use_std"))] { // cargo build, don't pull in anything extra as the libstd dep // already pulls in all libs. From 203f705e89aff60580bddde24799a5bc383bf7eb Mon Sep 17 00:00:00 2001 From: Jose Narvaez Date: Sun, 6 Aug 2017 23:38:54 +0100 Subject: [PATCH 05/10] Add some permission and misc (mostly 'mode_t' related) constants to Redox. --- src/redox.rs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/redox.rs b/src/redox.rs index f4f6178cfc31..0d189713c612 100644 --- a/src/redox.rs +++ b/src/redox.rs @@ -52,6 +52,37 @@ pub const STDIN_FILENO: ::c_int = 0; pub const STDOUT_FILENO: ::c_int = 1; pub const STDERR_FILENO: ::c_int = 2; +pub const EXIT_FAILURE: ::c_int = 1; +pub const EXIT_SUCCESS: ::c_int = 0; + +pub const S_ISUID: ::c_int = 0x800; +pub const S_ISGID: ::c_int = 0x400; +pub const S_ISVTX: ::c_int = 0x200; + +pub const S_IFIFO: mode_t = 4096; +pub const S_IFCHR: mode_t = 8192; +pub const S_IFBLK: mode_t = 24576; +pub const S_IFDIR: mode_t = 16384; +pub const S_IFREG: mode_t = 32768; +pub const S_IFLNK: mode_t = 40960; +pub const S_IFSOCK: mode_t = 49152; +pub const S_IFMT: mode_t = 61440; +pub const S_IEXEC: mode_t = 64; +pub const S_IWRITE: mode_t = 128; +pub const S_IREAD: mode_t = 256; +pub const S_IRWXU: mode_t = 448; +pub const S_IXUSR: mode_t = 64; +pub const S_IWUSR: mode_t = 128; +pub const S_IRUSR: mode_t = 256; +pub const S_IRWXG: mode_t = 56; +pub const S_IXGRP: mode_t = 8; +pub const S_IWGRP: mode_t = 16; +pub const S_IRGRP: mode_t = 32; +pub const S_IRWXO: mode_t = 7; +pub const S_IXOTH: mode_t = 1; +pub const S_IWOTH: mode_t = 2; +pub const S_IROTH: mode_t = 4; + extern { pub fn memalign(align: ::size_t, size: ::size_t) -> *mut ::c_void; pub fn read(fd: ::c_int, buf: *mut ::c_void, count: ::size_t) From a6a2a5ee885238c2db6a0316ee9e78b18fc81c6b Mon Sep 17 00:00:00 2001 From: Jose Narvaez Date: Mon, 7 Aug 2017 19:19:27 +0100 Subject: [PATCH 06/10] Changed Redox 'mode_t' constants to Hexadecimal. --- src/redox.rs | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/src/redox.rs b/src/redox.rs index 0d189713c612..7ff4ea05fdb8 100644 --- a/src/redox.rs +++ b/src/redox.rs @@ -59,29 +59,29 @@ pub const S_ISUID: ::c_int = 0x800; pub const S_ISGID: ::c_int = 0x400; pub const S_ISVTX: ::c_int = 0x200; -pub const S_IFIFO: mode_t = 4096; -pub const S_IFCHR: mode_t = 8192; -pub const S_IFBLK: mode_t = 24576; -pub const S_IFDIR: mode_t = 16384; -pub const S_IFREG: mode_t = 32768; -pub const S_IFLNK: mode_t = 40960; -pub const S_IFSOCK: mode_t = 49152; -pub const S_IFMT: mode_t = 61440; -pub const S_IEXEC: mode_t = 64; -pub const S_IWRITE: mode_t = 128; -pub const S_IREAD: mode_t = 256; -pub const S_IRWXU: mode_t = 448; -pub const S_IXUSR: mode_t = 64; -pub const S_IWUSR: mode_t = 128; -pub const S_IRUSR: mode_t = 256; -pub const S_IRWXG: mode_t = 56; -pub const S_IXGRP: mode_t = 8; -pub const S_IWGRP: mode_t = 16; -pub const S_IRGRP: mode_t = 32; -pub const S_IRWXO: mode_t = 7; -pub const S_IXOTH: mode_t = 1; -pub const S_IWOTH: mode_t = 2; -pub const S_IROTH: mode_t = 4; +pub const S_IFIFO: mode_t = 0x1000; +pub const S_IFCHR: mode_t = 0x2000; +pub const S_IFBLK: mode_t = 0x6000; +pub const S_IFDIR: mode_t = 0x4000; +pub const S_IFREG: mode_t = 0x8000; +pub const S_IFLNK: mode_t = 0xA000; +pub const S_IFSOCK: mode_t = 0xC000; +pub const S_IFMT: mode_t = 0xF000; +pub const S_IEXEC: mode_t = 0x40; +pub const S_IWRITE: mode_t = 0x80; +pub const S_IREAD: mode_t = 0x100; +pub const S_IRWXU: mode_t = 0x1C0; +pub const S_IXUSR: mode_t = 0x40; +pub const S_IWUSR: mode_t = 0x80; +pub const S_IRUSR: mode_t = 0x100; +pub const S_IRWXG: mode_t = 0x38; +pub const S_IXGRP: mode_t = 0x8; +pub const S_IWGRP: mode_t = 0x10; +pub const S_IRGRP: mode_t = 0x20; +pub const S_IRWXO: mode_t = 0x7; +pub const S_IXOTH: mode_t = 0x1; +pub const S_IWOTH: mode_t = 0x2; +pub const S_IROTH: mode_t = 0x4; extern { pub fn memalign(align: ::size_t, size: ::size_t) -> *mut ::c_void; From abfd80c50c547a9a635902db61c17b93bea1309a Mon Sep 17 00:00:00 2001 From: Sebastian Humenda Date: Wed, 16 Aug 2017 16:39:15 +0200 Subject: [PATCH 07/10] Improve x86_64/uclibc stat/signal struct definitions * correct sigaction * correct stat, alias stat64 * remove doubled statvfs definition --- src/unix/uclibc/x86_64/mod.rs | 86 ++++++++--------------------------- 1 file changed, 18 insertions(+), 68 deletions(-) diff --git a/src/unix/uclibc/x86_64/mod.rs b/src/unix/uclibc/x86_64/mod.rs index b5de65a91676..f72acf2bc077 100644 --- a/src/unix/uclibc/x86_64/mod.rs +++ b/src/unix/uclibc/x86_64/mod.rs @@ -14,12 +14,12 @@ pub type nlink_t = ::c_uint; pub type off_t = ::c_long; pub type rlim_t = c_ulong; pub type rlim64_t = u64; +// [uClibc docs] Note stat64 has the same shape as stat for x86-64. +pub type stat64 = stat; pub type suseconds_t = ::c_long; pub type time_t = ::c_int; pub type wchar_t = ::c_int; -// ToDo, used? -//pub type d_ino = ::c_ulong; pub type nfds_t = ::c_ulong; s! { @@ -136,57 +136,33 @@ s! { // __align: [u32; 0], // } - pub struct stat { // ToDo + pub struct stat { pub st_dev: ::c_ulong, - st_pad1: [::c_long; 2], pub st_ino: ::ino_t, - pub st_mode: ::mode_t, + // According to uclibc/libc/sysdeps/linux/x86_64/bits/stat.h, order of nlink and mode are + // swapped on 64 bit systems. pub st_nlink: ::nlink_t, + pub st_mode: ::mode_t, pub st_uid: ::uid_t, pub st_gid: ::gid_t, - pub st_rdev: u64, - pub st_pad2: [u64; 1], - pub st_size: off_t, - st_pad3: ::c_long, + pub st_rdev: ::c_ulong, // dev_t + pub st_size: off_t, // file size + pub st_blksize: ::blksize_t, + pub st_blocks: ::blkcnt_t, pub st_atime: ::time_t, - pub st_atime_nsec: ::c_long, + pub st_atime_nsec: ::c_ulong, pub st_mtime: ::time_t, - pub st_mtime_nsec: ::c_long, + pub st_mtime_nsec: ::c_ulong, pub st_ctime: ::time_t, - pub st_ctime_nsec: ::c_long, - pub st_blksize: ::blksize_t, - st_pad4: ::c_long, - pub st_blocks: ::blkcnt_t, - st_pad5: [::c_long; 7], - } - - pub struct statvfs { // ToDo: broken - pub f_bsize: ::c_ulong, - pub f_frsize: ::c_ulong, - pub f_blocks: ::fsblkcnt_t, - pub f_bfree: ::fsblkcnt_t, - pub f_bavail: ::fsblkcnt_t, - pub f_files: ::fsfilcnt_t, - pub f_ffree: ::fsfilcnt_t, - pub f_favail: ::fsfilcnt_t, - #[cfg(target_endian = "little")] - pub f_fsid: ::c_ulong, - #[cfg(target_pointer_width = "32")] - __f_unused: ::c_int, - #[cfg(target_endian = "big")] - pub f_fsid: ::c_ulong, - pub f_flag: ::c_ulong, - pub f_namemax: ::c_ulong, - __f_spare: [::c_int; 6], + pub st_ctime_nsec: ::c_ulong, + st_pad4: [::c_long; 3] } - pub struct sigaction { // TODO!! - pub sa_sigaction: ::sighandler_t, + pub struct sigaction { + pub sa_handler: ::sighandler_t, + pub sa_flags: ::c_ulong, + pub sa_restorer: *mut ::c_void, pub sa_mask: ::sigset_t, - #[cfg(target_arch = "sparc64")] - __reserved0: ::c_int, - pub sa_flags: ::c_int, - _restorer: *mut ::c_void, } pub struct stack_t { // ToDo @@ -311,27 +287,6 @@ s! { __unused5: *mut ::c_void, } - pub struct stat64 { // ToDo - pub st_dev: ::dev_t, - pub st_ino: ::ino64_t, - pub st_nlink: ::nlink_t, - pub st_mode: ::mode_t, - pub st_uid: ::uid_t, - pub st_gid: ::gid_t, - __pad0: ::c_int, - pub st_rdev: ::dev_t, - pub st_size: ::off_t, - pub st_blksize: ::blksize_t, - pub st_blocks: ::blkcnt64_t, - pub st_atime: ::time_t, - pub st_atime_nsec: ::c_long, - pub st_mtime: ::time_t, - pub st_mtime_nsec: ::c_long, - pub st_ctime: ::time_t, - pub st_ctime_nsec: ::c_long, - __reserved: [::c_long; 3], - } - pub struct rlimit64 { // ToDo pub rlim_cur: rlim64_t, pub rlim_max: rlim64_t, @@ -344,11 +299,6 @@ s! { bits: [u64; 16], } - pub struct timespec { // ToDo - tv_sec: time_t, // seconds - tv_nsec: ::c_ulong, // nanoseconds - } - pub struct fsid_t { // ToDo __val: [::c_int; 2], } From 3a1c83cf3ce2f1ec047c6d17fb8ad25fea890338 Mon Sep 17 00:00:00 2001 From: Sebastian Humenda Date: Thu, 17 Aug 2017 09:20:03 +0200 Subject: [PATCH 08/10] Remove superflouos doc comments --- src/unix/mod.rs | 1 - src/unix/uclibc/x86_64/l4re.rs | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 32c51eec83e4..9ad121e90b05 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -232,7 +232,6 @@ pub const INADDR_NONE: in_addr_t = 4294967295; cfg_if! { if #[cfg(any(dox, target_os = "l4re"))] { // on dox builds don't pull in anything - // L4Re builds pass the required libs using -Z to the compiler. } else if #[cfg(all(not(stdbuild), feature = "use_std"))] { // cargo build, don't pull in anything extra as the libstd dep // already pulls in all libs. diff --git a/src/unix/uclibc/x86_64/l4re.rs b/src/unix/uclibc/x86_64/l4re.rs index 06a9f09b142a..9c517b2b6395 100644 --- a/src/unix/uclibc/x86_64/l4re.rs +++ b/src/unix/uclibc/x86_64/l4re.rs @@ -1,7 +1,7 @@ /// L4Re specifics /// This module contains definitions required by various L4Re libc backends. -/// These are formally not part of the libc, but are a dependency of the libc -/// and hence we should provide them here. +/// Some of them are formally not part of the libc, but are a dependency of the libc and hence we +/// should provide them here. pub type l4_umword_t = ::c_ulong; // Unsigned machine word. From dc0a1826698980f6578b7d2b0f0c6f50ed133469 Mon Sep 17 00:00:00 2001 From: Sebastian Humenda Date: Thu, 17 Aug 2017 12:58:46 +0200 Subject: [PATCH 09/10] adjust value for minimal thread stack size --- src/unix/uclibc/x86_64/l4re.rs | 7 +++++-- src/unix/uclibc/x86_64/mod.rs | 6 +++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/unix/uclibc/x86_64/l4re.rs b/src/unix/uclibc/x86_64/l4re.rs index 9c517b2b6395..f047a82e004e 100644 --- a/src/unix/uclibc/x86_64/l4re.rs +++ b/src/unix/uclibc/x86_64/l4re.rs @@ -1,7 +1,7 @@ /// L4Re specifics /// This module contains definitions required by various L4Re libc backends. -/// Some of them are formally not part of the libc, but are a dependency of the libc and hence we -/// should provide them here. +/// Some of them are formally not part of the libc, but are a dependency of the +/// libc and hence we should provide them here. pub type l4_umword_t = ::c_ulong; // Unsigned machine word. @@ -41,3 +41,6 @@ pub struct pthread_attr_t { pub create_flags: ::c_uint, } +// L4Re requires a min stack size of 64k; that isn't defined in uClibc, but +// somewhere in the core libraries. uClibc wants 16k, but that's not enough. +pub const PTHREAD_STACK_MIN: usize = 65536; diff --git a/src/unix/uclibc/x86_64/mod.rs b/src/unix/uclibc/x86_64/mod.rs index f72acf2bc077..29cefca2f930 100644 --- a/src/unix/uclibc/x86_64/mod.rs +++ b/src/unix/uclibc/x86_64/mod.rs @@ -139,8 +139,8 @@ s! { pub struct stat { pub st_dev: ::c_ulong, pub st_ino: ::ino_t, - // According to uclibc/libc/sysdeps/linux/x86_64/bits/stat.h, order of nlink and mode are - // swapped on 64 bit systems. + // According to uclibc/libc/sysdeps/linux/x86_64/bits/stat.h, order of + // nlink and mode are swapped on 64 bit systems. pub st_nlink: ::nlink_t, pub st_mode: ::mode_t, pub st_uid: ::uid_t, @@ -323,8 +323,8 @@ pub const O_EXCL: ::c_int = 0200; pub const O_NONBLOCK: ::c_int = 04000; pub const O_TRUNC: ::c_int = 01000; pub const NCCS: usize = 32; -pub const PTHREAD_STACK_MIN: usize = 16384; pub const SIG_SETMASK: ::c_int = 2; // Set the set of blocked signals +pub const PTHREAD_STACK_MIN: usize = 16384; pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; pub const PTHREAD_MUTEX_NORMAL: ::c_int = 0; From cc5883410ec1ce6778b4d6f02dbbebd54692c007 Mon Sep 17 00:00:00 2001 From: Sebastian Humenda Date: Fri, 18 Aug 2017 11:57:48 +0200 Subject: [PATCH 10/10] Make more clear why no libraries are linked to L4Re --- src/unix/mod.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 9ad121e90b05..bf6f0a7d460d 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -230,8 +230,10 @@ pub const INADDR_BROADCAST: in_addr_t = 4294967295; pub const INADDR_NONE: in_addr_t = 4294967295; cfg_if! { - if #[cfg(any(dox, target_os = "l4re"))] { + if #[cfg(dox)] { // on dox builds don't pull in anything + } else if #[cfg(target_os = "l4re")] { + // required libraries for L4Re are linked externally, ATM } else if #[cfg(all(not(stdbuild), feature = "use_std"))] { // cargo build, don't pull in anything extra as the libstd dep // already pulls in all libs.