diff --git a/src/header/unistd/sysconf.rs b/src/header/unistd/sysconf.rs index dd61586ff5..0db38b0bbe 100644 --- a/src/header/unistd/sysconf.rs +++ b/src/header/unistd/sysconf.rs @@ -8,6 +8,9 @@ mod sys; #[path = "sysconf/linux.rs"] mod sys; +pub mod constants; + +pub use constants::*; pub use sys::*; use core::ffi::{c_int, c_long}; diff --git a/src/header/unistd/sysconf/constants.rs b/src/header/unistd/sysconf/constants.rs new file mode 100644 index 0000000000..4e8d124ddb --- /dev/null +++ b/src/header/unistd/sysconf/constants.rs @@ -0,0 +1,48 @@ +// This file holds the sysconf constants with the same values +// across both linux and redox. +// TODO: add more as redox starts to support them. + +use crate::platform::types::c_int; + +// POSIX.1 { +pub const _SC_ARG_MAX: c_int = 0; +pub const _SC_CHILD_MAX: c_int = 1; +pub const _SC_CLK_TCK: c_int = 2; +pub const _SC_NGROUPS_MAX: c_int = 3; +pub const _SC_OPEN_MAX: c_int = 4; +pub const _SC_STREAM_MAX: c_int = 5; +pub const _SC_TZNAME_MAX: c_int = 6; +// ... +pub const _SC_TIMERS: c_int = 11; +// ... +pub const _SC_SEMAPHORES: c_int = 21; +pub const _SC_SHARED_MEMORY_OBJECTS: c_int = 22; +// ... +pub const _SC_VERSION: c_int = 29; +pub const _SC_PAGESIZE: c_int = 30; +pub const _SC_PAGE_SIZE: c_int = 30; +// ... +pub const _SC_RE_DUP_MAX: c_int = 44; +// ... +pub const _SC_THREADS: c_int = 67; +pub const _SC_GETGR_R_SIZE_MAX: c_int = 69; +pub const _SC_GETPW_R_SIZE_MAX: c_int = 70; +pub const _SC_LOGIN_NAME_MAX: c_int = 71; +pub const _SC_TTY_NAME_MAX: c_int = 72; +// ... +pub const _SC_THREAD_ATTR_STACKADDR: c_int = 77; +pub const _SC_THREAD_ATTR_STACKSIZE: c_int = 78; +// ... +pub const _SC_BARRIERS: c_int = 133; +// ... +pub const _SC_MONOTONIC_CLOCK: c_int = 149; +// ... +pub const _SC_SHELL: c_int = 157; +// ... +pub const _SC_TIMEOUTS: c_int = 164; +// ... +pub const _SC_SYMLOOP_MAX: c_int = 173; +// ... +pub const _SC_HOST_NAME_MAX: c_int = 180; +// ... +// } POSIX.1 diff --git a/src/header/unistd/sysconf/linux.rs b/src/header/unistd/sysconf/linux.rs index 16426c0f6c..3e0d85ba31 100644 --- a/src/header/unistd/sysconf/linux.rs +++ b/src/header/unistd/sysconf/linux.rs @@ -6,7 +6,7 @@ use core::{ }; use crate::{ - header::{errno, limits::*, signal}, + header::{errno, limits::*, signal, unistd::sysconf::constants::*}, platform, }; @@ -14,18 +14,10 @@ pub const _XOPEN_IOV_MAX: c_long = 16; pub const _XOPEN_NAME_MAX: c_long = 255; pub const _XOPEN_PATH_MAX: c_long = 1024; -pub const _SC_ARG_MAX: c_int = 0; -pub const _SC_CHILD_MAX: c_int = 1; -pub const _SC_CLK_TCK: c_int = 2; -pub const _SC_NGROUPS_MAX: c_int = 3; -pub const _SC_OPEN_MAX: c_int = 4; -pub const _SC_STREAM_MAX: c_int = 5; -pub const _SC_TZNAME_MAX: c_int = 6; pub const _SC_JOB_CONTROL: c_int = 7; pub const _SC_SAVED_IDS: c_int = 8; -pub const _SC_REALTIME_SIGNALS: c_int = 9; +pub const _SC_REALTIME_SIGNALS: c_int = 9; // 191 on redox pub const _SC_PRIORITY_SCHEDULING: c_int = 10; -pub const _SC_TIMERS: c_int = 11; pub const _SC_ASYNCHRONOUS_IO: c_int = 12; pub const _SC_PRIORITIZED_IO: c_int = 13; pub const _SC_SYNCHRONIZED_IO: c_int = 14; @@ -35,21 +27,16 @@ pub const _SC_MEMLOCK: c_int = 17; pub const _SC_MEMLOCK_RANGE: c_int = 18; pub const _SC_MEMORY_PROTECTION: c_int = 19; pub const _SC_MESSAGE_PASSING: c_int = 20; -pub const _SC_SEMAPHORES: c_int = 21; -pub const _SC_SHARED_MEMORY_OBJECTS: c_int = 22; pub const _SC_AIO_LISTIO_MAX: c_int = 23; pub const _SC_AIO_MAX: c_int = 24; pub const _SC_AIO_PRIO_DELTA_MAX: c_int = 25; pub const _SC_DELAYTIMER_MAX: c_int = 26; pub const _SC_MQ_OPEN_MAX: c_int = 27; pub const _SC_MQ_PRIO_MAX: c_int = 28; -pub const _SC_VERSION: c_int = 29; -pub const _SC_PAGE_SIZE: c_int = 30; -pub const _SC_PAGESIZE: c_int = 30; pub const _SC_RTSIG_MAX: c_int = 31; pub const _SC_SEM_NSEMS_MAX: c_int = 32; pub const _SC_SEM_VALUE_MAX: c_int = 33; -pub const _SC_SIGQUEUE_MAX: c_int = 34; +pub const _SC_SIGQUEUE_MAX: c_int = 34; // 190 on redox pub const _SC_TIMER_MAX: c_int = 35; pub const _SC_BC_BASE_MAX: c_int = 36; pub const _SC_BC_DIM_MAX: c_int = 37; @@ -58,7 +45,6 @@ pub const _SC_BC_STRING_MAX: c_int = 39; pub const _SC_COLL_WEIGHTS_MAX: c_int = 40; pub const _SC_EXPR_NEST_MAX: c_int = 42; pub const _SC_LINE_MAX: c_int = 43; -pub const _SC_RE_DUP_MAX: c_int = 44; pub const _SC_2_VERSION: c_int = 46; pub const _SC_2_C_BIND: c_int = 47; pub const _SC_2_C_DEV: c_int = 48; @@ -68,26 +54,19 @@ pub const _SC_2_SW_DEV: c_int = 51; pub const _SC_2_LOCALEDEF: c_int = 52; pub const _SC_UIO_MAXIOV: c_int = 60; pub const _SC_IOV_MAX: c_int = 60; -pub const _SC_THREADS: c_int = 67; pub const _SC_THREAD_SAFE_FUNCTIONS: c_int = 68; -pub const _SC_GETGR_R_SIZE_MAX: c_int = 69; -pub const _SC_GETPW_R_SIZE_MAX: c_int = 70; -pub const _SC_LOGIN_NAME_MAX: c_int = 71; -pub const _SC_TTY_NAME_MAX: c_int = 72; pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: c_int = 73; pub const _SC_THREAD_KEYS_MAX: c_int = 74; pub const _SC_THREAD_STACK_MIN: c_int = 75; pub const _SC_THREAD_THREADS_MAX: c_int = 76; -pub const _SC_THREAD_ATTR_STACKADDR: c_int = 77; -pub const _SC_THREAD_ATTR_STACKSIZE: c_int = 78; pub const _SC_THREAD_PRIORITY_SCHEDULING: c_int = 79; pub const _SC_THREAD_PRIO_INHERIT: c_int = 80; pub const _SC_THREAD_PRIO_PROTECT: c_int = 81; pub const _SC_THREAD_PROCESS_SHARED: c_int = 82; -pub const _SC_NPROCESSORS_CONF: c_int = 83; -pub const _SC_NPROCESSORS_ONLN: c_int = 84; -pub const _SC_PHYS_PAGES: c_int = 85; -pub const _SC_AVPHYS_PAGES: c_int = 86; +pub const _SC_NPROCESSORS_CONF: c_int = 83; // 57 on redox +pub const _SC_NPROCESSORS_ONLN: c_int = 84; // 58 on redox +pub const _SC_PHYS_PAGES: c_int = 85; // 59 on redox +pub const _SC_AVPHYS_PAGES: c_int = 86; // 60 on redox pub const _SC_ATEXIT_MAX: c_int = 87; pub const _SC_PASS_MAX: c_int = 88; pub const _SC_XOPEN_VERSION: c_int = 89; @@ -110,33 +89,27 @@ pub const _SC_XOPEN_LEGACY: c_int = 129; pub const _SC_XOPEN_REALTIME: c_int = 130; pub const _SC_XOPEN_REALTIME_THREADS: c_int = 131; pub const _SC_ADVISORY_INFO: c_int = 132; -pub const _SC_BARRIERS: c_int = 133; pub const _SC_CLOCK_SELECTION: c_int = 137; pub const _SC_CPUTIME: c_int = 138; pub const _SC_THREAD_CPUTIME: c_int = 139; -pub const _SC_MONOTONIC_CLOCK: c_int = 149; pub const _SC_READER_WRITER_LOCKS: c_int = 153; pub const _SC_SPIN_LOCKS: c_int = 154; pub const _SC_REGEXP: c_int = 155; -pub const _SC_SHELL: c_int = 157; pub const _SC_SPAWN: c_int = 159; pub const _SC_SPORADIC_SERVER: c_int = 160; pub const _SC_THREAD_SPORADIC_SERVER: c_int = 161; -pub const _SC_TIMEOUTS: c_int = 164; pub const _SC_TYPED_MEMORY_OBJECTS: c_int = 165; pub const _SC_2_PBS: c_int = 168; pub const _SC_2_PBS_ACCOUNTING: c_int = 169; pub const _SC_2_PBS_LOCATE: c_int = 170; pub const _SC_2_PBS_MESSAGE: c_int = 171; pub const _SC_2_PBS_TRACK: c_int = 172; -pub const _SC_SYMLOOP_MAX: c_int = 173; pub const _SC_STREAMS: c_int = 174; pub const _SC_2_PBS_CHECKPOINT: c_int = 175; pub const _SC_V6_ILP32_OFF32: c_int = 176; pub const _SC_V6_ILP32_OFFBIG: c_int = 177; pub const _SC_V6_LP64_OFF64: c_int = 178; pub const _SC_V6_LPBIG_OFFBIG: c_int = 179; -pub const _SC_HOST_NAME_MAX: c_int = 180; pub const _SC_TRACE: c_int = 181; pub const _SC_TRACE_EVENT_FILTER: c_int = 182; pub const _SC_TRACE_INHERIT: c_int = 183; diff --git a/src/header/unistd/sysconf/redox.rs b/src/header/unistd/sysconf/redox.rs index 9396db1326..1d2b457e4f 100644 --- a/src/header/unistd/sysconf/redox.rs +++ b/src/header/unistd/sysconf/redox.rs @@ -3,7 +3,7 @@ use core::convert::TryInto; use crate::{ error::Errno, fs::File, - header::{errno, fcntl, limits, sys_statvfs}, + header::{errno, fcntl, limits, sys_statvfs, unistd::sysconf::constants::*}, io::Read, out::Out, platform::{ @@ -12,56 +12,13 @@ use crate::{ }, }; -// POSIX.1 { -pub const _SC_ARG_MAX: c_int = 0; -pub const _SC_CHILD_MAX: c_int = 1; -pub const _SC_CLK_TCK: c_int = 2; -pub const _SC_NGROUPS_MAX: c_int = 3; -pub const _SC_OPEN_MAX: c_int = 4; -pub const _SC_STREAM_MAX: c_int = 5; -pub const _SC_TZNAME_MAX: c_int = 6; -// ... -pub const _SC_TIMERS: c_int = 11; -// ... -pub const _SC_SHARED_MEMORY_OBJECTS: c_int = 22; -// ... -pub const _SC_VERSION: c_int = 29; -pub const _SC_PAGESIZE: c_int = 30; -pub const _SC_PAGE_SIZE: c_int = 30; -// ... -pub const _SC_RE_DUP_MAX: c_int = 44; - +// TODO why are these numbered differently to linux? pub const _SC_NPROCESSORS_CONF: c_int = 57; pub const _SC_NPROCESSORS_ONLN: c_int = 58; pub const _SC_PHYS_PAGES: c_int = 59; pub const _SC_AVPHYS_PAGES: c_int = 60; - -// ... -pub const _SC_THREADS: c_int = 67; -pub const _SC_GETGR_R_SIZE_MAX: c_int = 69; -pub const _SC_GETPW_R_SIZE_MAX: c_int = 70; -pub const _SC_LOGIN_NAME_MAX: c_int = 71; -pub const _SC_TTY_NAME_MAX: c_int = 72; -// ... -pub const _SC_THREAD_ATTR_STACKADDR: c_int = 77; -pub const _SC_THREAD_ATTR_STACKSIZE: c_int = 78; -// ... -pub const _SC_MONOTONIC_CLOCK: c_int = 149; -pub const _SC_SEMAPHORES: c_int = 21; -// ... -pub const _SC_BARRIERS: c_int = 133; -// ... -pub const _SC_SHELL: c_int = 157; -// ... -pub const _SC_TIMEOUTS: c_int = 164; -// ... -pub const _SC_SYMLOOP_MAX: c_int = 173; -// ... -pub const _SC_HOST_NAME_MAX: c_int = 180; -// ... pub const _SC_SIGQUEUE_MAX: c_int = 190; pub const _SC_REALTIME_SIGNALS: c_int = 191; -// } POSIX.1 pub(super) fn sysconf_impl(name: c_int) -> c_long { //TODO: Real values