diff --git a/src/header/limits/mod.rs b/src/header/limits/mod.rs index cde6c86caf..78267ca3f3 100644 --- a/src/header/limits/mod.rs +++ b/src/header/limits/mod.rs @@ -1,6 +1,8 @@ //! limits.h implementation for relibc //! Following https://pubs.opengroup.org/onlinepubs/7908799/xsh/limits.h.html +use core::ffi::c_long; + pub const HOST_NAME_MAX: usize = 64; pub const NAME_MAX: usize = 255; pub const PASS_MAX: usize = 128; @@ -13,44 +15,56 @@ pub const NGROUPS_MAX: usize = 65536; pub const PAGE_SIZE: usize = 4096; // These POSIX symbols must have these values regardless of OS -pub const _POSIX_AIO_LISTIO_MAX: usize = 2; -pub const _POSIX_AIO_MAX: usize = 1; -pub const _POSIX_ARG_MAX: usize = 4096; -pub const _POSIX_CHILD_MAX: usize = 25; -pub const _POSIX_CLOCKRES_MIN: usize = 20000000; -pub const _POSIX_DELAYTIMER_MAX: usize = 32; -pub const _POSIX_HOST_NAME_MAX: usize = 255; -pub const _POSIX_LINK_MAX: usize = 8; -pub const _POSIX_LOGIN_NAME_MAX: usize = 9; -pub const _POSIX_MAX_CANON: usize = 255; -pub const _POSIX_MAX_INPUT: usize = 255; -pub const _POSIX_NAME_MAX: usize = 14; -pub const _POSIX_NGROUPS_MAX: usize = 8; -pub const _POSIX_OPEN_MAX: usize = 20; -pub const _POSIX_PATH_MAX: usize = 256; -pub const _POSIX_PIPE_BUF: usize = 512; -pub const _POSIX_RE_DUP_MAX: usize = 255; -pub const _POSIX_RTSIG_MAX: usize = 8; -pub const _POSIX_SEM_NSEMS_MAX: usize = 256; -pub const _POSIX_SEM_VALUE_MAX: usize = 32767; -pub const _POSIX_SIGQUEUE_MAX: usize = 32; -pub const _POSIX_SSIZE_MAX: usize = 32767; -pub const _POSIX_STREAM_MAX: usize = 8; -pub const _POSIX_SYMLINK_MAX: usize = 255; -pub const _POSIX_SYMLOOP_MAX: usize = 8; -pub const _POSIX_THREAD_DESTRUCTOR_ITERATIONS: usize = 4; -pub const _POSIX_THREAD_KEYS_MAX: usize = 128; -pub const _POSIX_THREAD_THREADS_MAX: usize = 64; -pub const _POSIX_TIMER_MAX: usize = 32; -pub const _POSIX_TTY_NAME_MAX: usize = 9; -pub const _POSIX_TZNAME_MAX: usize = 6; +pub const _POSIX_AIO_LISTIO_MAX: c_long = 2; +pub const _POSIX_AIO_MAX: c_long = 1; +pub const _POSIX_ARG_MAX: c_long = 4096; +pub const _POSIX_CHILD_MAX: c_long = 25; +pub const _POSIX_CLOCKRES_MIN: c_long = 20000000; +pub const _POSIX_DELAYTIMER_MAX: c_long = 32; +pub const _POSIX_HOST_NAME_MAX: c_long = 255; +pub const _POSIX_LINK_MAX: c_long = 8; +pub const _POSIX_LOGIN_NAME_MAX: c_long = 9; +pub const _POSIX_MAX_CANON: c_long = 255; +pub const _POSIX_MAX_INPUT: c_long = 255; +pub const _POSIX_NAME_MAX: c_long = 14; +pub const _POSIX_NGROUPS_MAX: c_long = 8; +pub const _POSIX_OPEN_MAX: c_long = 20; +pub const _POSIX_PATH_MAX: c_long = 256; +pub const _POSIX_PIPE_BUF: c_long = 512; +pub const _POSIX_RE_DUP_MAX: c_long = 255; +pub const _POSIX_RTSIG_MAX: c_long = 8; +pub const _POSIX_SEM_NSEMS_MAX: c_long = 256; +pub const _POSIX_SEM_VALUE_MAX: c_long = 32767; +pub const _POSIX_SIGQUEUE_MAX: c_long = 32; +pub const _POSIX_SSIZE_MAX: c_long = 32767; +pub const _POSIX_STREAM_MAX: c_long = 8; +pub const _POSIX_SYMLINK_MAX: c_long = 255; +pub const _POSIX_SYMLOOP_MAX: c_long = 8; +pub const _POSIX_THREAD_DESTRUCTOR_ITERATIONS: c_long = 4; +pub const _POSIX_THREAD_KEYS_MAX: c_long = 128; +pub const _POSIX_THREAD_THREADS_MAX: c_long = 64; +pub const _POSIX_TIMER_MAX: c_long = 32; +pub const _POSIX_TTY_NAME_MAX: c_long = 9; +pub const _POSIX_TZNAME_MAX: c_long = 6; -pub const _POSIX2_BC_BASE_MAX: usize = 99; -pub const _POSIX2_BC_DIM_MAX: usize = 2048; -pub const _POSIX2_BC_SCALE_MAX: usize = 99; -pub const _POSIX2_BC_STRING_MAX: usize = 1000; -pub const _POSIX2_CHARCLASS_NAME_MAX: usize = 14; -pub const _POSIX2_COLL_WEIGHTS_MAX: usize = 2; -pub const _POSIX2_EXPR_NEST_MAX: usize = 32; -pub const _POSIX2_LINE_MAX: usize = 2048; -pub const _POSIX2_RE_DUP_MAX: usize = 255; +pub const _POSIX2_BC_BASE_MAX: c_long = 99; +pub const _POSIX2_BC_DIM_MAX: c_long = 2048; +pub const _POSIX2_BC_SCALE_MAX: c_long = 99; +pub const _POSIX2_BC_STRING_MAX: c_long = 1000; +pub const _POSIX2_CHARCLASS_NAME_MAX: c_long = 14; +pub const _POSIX2_COLL_WEIGHTS_MAX: c_long = 2; +pub const _POSIX2_EXPR_NEST_MAX: c_long = 32; +pub const _POSIX2_LINE_MAX: c_long = 2048; +pub const _POSIX2_RE_DUP_MAX: c_long = 255; + +// These symbols must be at least the POSIX values, and sysconf will return the actual value between +// the posix minimum and this maximum. +pub const BC_BASE_MAX: c_long = _POSIX2_BC_BASE_MAX; +pub const BC_DIM_MAX: c_long = _POSIX2_BC_DIM_MAX; +pub const BC_SCALE_MAX: c_long = _POSIX2_BC_SCALE_MAX; +pub const BC_STRING_MAX: c_long = _POSIX2_BC_STRING_MAX; +pub const CHARCLASS_NAME_MAX: c_long = _POSIX2_CHARCLASS_NAME_MAX; +pub const COLL_WEIGHTS_MAX: c_long = _POSIX2_COLL_WEIGHTS_MAX; +pub const EXPR_NEST_MAX: c_long = _POSIX2_EXPR_NEST_MAX; +pub const LINE_MAX: c_long = _POSIX2_LINE_MAX; +pub const RE_DUP_MAX: c_long = _POSIX2_RE_DUP_MAX; \ No newline at end of file diff --git a/src/header/unistd/sysconf/linux.rs b/src/header/unistd/sysconf/linux.rs index 2434e8c429..f98fc465fc 100644 --- a/src/header/unistd/sysconf/linux.rs +++ b/src/header/unistd/sysconf/linux.rs @@ -8,21 +8,12 @@ use core::{ use crate::{ header::{ errno, - limits::{HOST_NAME_MAX, PAGE_SIZE}, + limits::*, signal, }, platform, }; -pub const _POSIX2_BC_BASE_MAX: c_long = 99; -pub const _POSIX2_BC_DIM_MAX: c_long = 2048; -pub const _POSIX2_BC_SCALE_MAX: c_long = 99; -pub const _POSIX2_BC_STRING_MAX: c_long = 1000; -pub const _POSIX2_CHARCLASS_NAME_MAX: c_long = 14; -pub const _POSIX2_COLL_WEIGHTS_MAX: c_long = 2; -pub const _POSIX2_EXPR_NEST_MAX: c_long = 32; -pub const _POSIX2_LINE_MAX: c_long = 2048; -pub const _POSIX2_RE_DUP_MAX: c_long = 255; pub const _XOPEN_IOV_MAX: c_long = 16; pub const _XOPEN_NAME_MAX: c_long = 255; pub const _XOPEN_PATH_MAX: c_long = 1024; @@ -182,7 +173,7 @@ pub(super) fn sysconf_impl(name: c_int) -> c_long { _SC_CLK_TCK => 100, // TODO: getrlimit _SC_CHILD_MAX => -1, - _SC_NGROUPS_MAX => 32, + _SC_NGROUPS_MAX => NGROUPS_MAX as c_long, // TODO: getrlimit _SC_OPEN_MAX => -1, _SC_STREAM_MAX => -1, @@ -223,14 +214,14 @@ pub(super) fn sysconf_impl(name: c_int) -> c_long { _SC_SEM_VALUE_MAX => -1, _SC_SIGQUEUE_MAX => -1, _SC_TIMER_MAX => -1, - _SC_BC_BASE_MAX => _POSIX2_BC_BASE_MAX, - _SC_BC_DIM_MAX => _POSIX2_BC_DIM_MAX, - _SC_BC_SCALE_MAX => _POSIX2_BC_SCALE_MAX, - _SC_BC_STRING_MAX => _POSIX2_BC_STRING_MAX, - _SC_COLL_WEIGHTS_MAX => _POSIX2_COLL_WEIGHTS_MAX, - _SC_EXPR_NEST_MAX => -1, - _SC_LINE_MAX => -1, - _SC_RE_DUP_MAX => _POSIX2_RE_DUP_MAX, + _SC_BC_BASE_MAX => BC_BASE_MAX, + _SC_BC_DIM_MAX => BC_DIM_MAX, + _SC_BC_SCALE_MAX => BC_SCALE_MAX, + _SC_BC_STRING_MAX => BC_STRING_MAX, + _SC_COLL_WEIGHTS_MAX => COLL_WEIGHTS_MAX, + _SC_EXPR_NEST_MAX => EXPR_NEST_MAX, + _SC_LINE_MAX => LINE_MAX, + _SC_RE_DUP_MAX => RE_DUP_MAX, _SC_2_VERSION => _POSIX_VERSION, _SC_2_C_BIND => _POSIX_VERSION, _SC_2_C_DEV => -1,