Merge branch 'limits.h-more-limits' into 'master'
limits.h: add more constants See merge request redox-os/relibc!1188
This commit is contained in:
@@ -7,7 +7,6 @@ use crate::platform::types::{
|
||||
c_ushort, ssize_t,
|
||||
};
|
||||
|
||||
pub const HOST_NAME_MAX: usize = 64;
|
||||
pub const NAME_MAX: usize = 255;
|
||||
pub const PASS_MAX: usize = 128;
|
||||
pub const PATH_MAX: usize = 4096;
|
||||
@@ -115,6 +114,16 @@ 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;
|
||||
pub const HOST_NAME_MAX: c_long = _POSIX_HOST_NAME_MAX;
|
||||
pub const LOGIN_NAME_MAX: c_long = 255;
|
||||
pub const GETENTROPY_MAX: c_long = 256;
|
||||
pub const LINK_MAX: c_long = 127;
|
||||
pub const PIPE_BUF: c_long = 4096;
|
||||
pub const FILESIZEBITS: c_long = 64;
|
||||
pub const MAX_CANON: c_long = _POSIX_MAX_CANON;
|
||||
pub const MAX_INPUT: c_long = _POSIX_MAX_INPUT;
|
||||
pub const SYMLINK_MAX: c_long = _POSIX_SYMLINK_MAX;
|
||||
pub const POSIX_ALLOC_SIZE_MIN: c_long = 4096;
|
||||
|
||||
pub const PTHREAD_DESTRUCTOR_ITERATIONS: c_long = _POSIX_THREAD_DESTRUCTOR_ITERATIONS;
|
||||
// TODO: What should this limit be? Both glibc and musl have it as 1024
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
use crate::{
|
||||
header::{errno, termios::_POSIX_VDISABLE},
|
||||
header::{
|
||||
errno,
|
||||
limits::{
|
||||
FILESIZEBITS, LINK_MAX, MAX_CANON, MAX_INPUT, NAME_MAX, PATH_MAX, PIPE_BUF,
|
||||
POSIX_ALLOC_SIZE_MIN, SYMLINK_MAX,
|
||||
},
|
||||
termios::_POSIX_VDISABLE,
|
||||
},
|
||||
platform::{
|
||||
self,
|
||||
types::{c_char, c_int, c_long},
|
||||
@@ -32,12 +39,12 @@ pub const _PC_2_SYMLINKS: c_int = 20;
|
||||
fn pc(name: c_int) -> c_long {
|
||||
// Settings from musl, some adjusted
|
||||
match name {
|
||||
_PC_LINK_MAX => 127,
|
||||
_PC_MAX_CANON => 255,
|
||||
_PC_MAX_INPUT => 255,
|
||||
_PC_NAME_MAX => 255,
|
||||
_PC_PATH_MAX => 4096,
|
||||
_PC_PIPE_BUF => 4096,
|
||||
_PC_LINK_MAX => LINK_MAX.try_into().unwrap_or(-1),
|
||||
_PC_MAX_CANON => MAX_CANON.try_into().unwrap_or(-1),
|
||||
_PC_MAX_INPUT => MAX_INPUT.try_into().unwrap_or(-1),
|
||||
_PC_NAME_MAX => NAME_MAX.try_into().unwrap_or(-1),
|
||||
_PC_PATH_MAX => PATH_MAX.try_into().unwrap_or(-1),
|
||||
_PC_PIPE_BUF => PIPE_BUF.try_into().unwrap_or(-1),
|
||||
_PC_CHOWN_RESTRICTED => 1,
|
||||
_PC_NO_TRUNC => 1,
|
||||
_PC_VDISABLE => _POSIX_VDISABLE.into(),
|
||||
@@ -45,13 +52,13 @@ fn pc(name: c_int) -> c_long {
|
||||
_PC_ASYNC_IO => -1,
|
||||
_PC_PRIO_IO => -1,
|
||||
_PC_SOCK_MAXBUF => -1,
|
||||
_PC_FILESIZEBITS => 64,
|
||||
_PC_FILESIZEBITS => FILESIZEBITS.into(),
|
||||
_PC_REC_INCR_XFER_SIZE => -1,
|
||||
_PC_REC_MAX_XFER_SIZE => -1,
|
||||
_PC_REC_MIN_XFER_SIZE => 4096,
|
||||
_PC_REC_XFER_ALIGN => 4096,
|
||||
_PC_ALLOC_SIZE_MIN => 4096,
|
||||
_PC_SYMLINK_MAX => -1,
|
||||
_PC_ALLOC_SIZE_MIN => POSIX_ALLOC_SIZE_MIN.try_into().unwrap_or(-1),
|
||||
_PC_SYMLINK_MAX => SYMLINK_MAX.try_into().unwrap_or(-1),
|
||||
_PC_2_SYMLINKS => 1,
|
||||
_ => {
|
||||
platform::ERRNO.set(errno::EINVAL);
|
||||
|
||||
@@ -93,7 +93,7 @@ pub(super) fn sysconf_impl(name: c_int) -> c_long {
|
||||
_SC_TIMEOUTS => 202405,
|
||||
_SC_TIMERS => 202405,
|
||||
_SC_SYMLOOP_MAX => -1,
|
||||
_SC_HOST_NAME_MAX => 64,
|
||||
_SC_HOST_NAME_MAX => limits::HOST_NAME_MAX.try_into().unwrap_or(-1),
|
||||
_SC_NPROCESSORS_CONF => get_cpu_count().unwrap_or(None).unwrap_or(1),
|
||||
_SC_NPROCESSORS_ONLN => get_cpu_count().unwrap_or(None).unwrap_or(1),
|
||||
_SC_PHYS_PAGES => get_mem_stat().map(|s| s.f_blocks as c_long).unwrap_or(-1),
|
||||
|
||||
Reference in New Issue
Block a user