mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 12:53:13 +00:00
Clean up src/libc.rs some
Update the CVAR!() macro and use it more.
This commit is contained in:
parent
2ca92cd52d
commit
84be043f31
1 changed files with 8 additions and 51 deletions
59
src/libc.rs
59
src/libc.rs
|
@ -3,34 +3,6 @@ use std::sync::atomic::AtomicPtr;
|
|||
use libc::{c_char, c_int};
|
||||
use once_cell::sync::Lazy;
|
||||
|
||||
pub fn MB_CUR_MAX() -> usize {
|
||||
unsafe { C_MB_CUR_MAX() }
|
||||
}
|
||||
extern "C" {
|
||||
fn C_MB_CUR_MAX() -> usize;
|
||||
}
|
||||
|
||||
pub fn ST_LOCAL() -> u64 {
|
||||
unsafe { C_ST_LOCAL() }
|
||||
}
|
||||
extern "C" {
|
||||
fn C_ST_LOCAL() -> u64;
|
||||
}
|
||||
|
||||
pub fn MNT_LOCAL() -> u64 {
|
||||
unsafe { C_MNT_LOCAL() }
|
||||
}
|
||||
extern "C" {
|
||||
fn C_MNT_LOCAL() -> u64;
|
||||
}
|
||||
|
||||
pub fn _CS_PATH() -> i32 {
|
||||
unsafe { C_CS_PATH() }
|
||||
}
|
||||
extern "C" {
|
||||
fn C_CS_PATH() -> i32;
|
||||
}
|
||||
|
||||
pub static _PATH_BSHELL: AtomicPtr<c_char> = AtomicPtr::new(std::ptr::null_mut());
|
||||
extern "C" {
|
||||
pub fn C_PATH_BSHELL() -> *const c_char;
|
||||
|
@ -54,11 +26,19 @@ extern "C" {
|
|||
macro_rules! CVAR {
|
||||
($cfn:ident, $cvar:ident, $type:ident) => {
|
||||
pub fn $cvar() -> $type {
|
||||
extern "C" {
|
||||
fn $cfn() -> $type;
|
||||
}
|
||||
unsafe { $cfn() }
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
CVAR!(C_MB_CUR_MAX, MB_CUR_MAX, usize);
|
||||
CVAR!(C_ST_LOCAL, ST_LOCAL, u64);
|
||||
CVAR!(C_MNT_LOCAL, MNT_LOCAL, u64);
|
||||
CVAR!(C_CS_PATH, _CS_PATH, i32);
|
||||
|
||||
CVAR!(C_RLIMIT_SBSIZE, RLIMIT_SBSIZE, i32);
|
||||
CVAR!(C_RLIMIT_CORE, RLIMIT_CORE, i32);
|
||||
CVAR!(C_RLIMIT_DATA, RLIMIT_DATA, i32);
|
||||
|
@ -79,26 +59,3 @@ CVAR!(C_RLIMIT_RTTIME, RLIMIT_RTTIME, i32);
|
|||
CVAR!(C_RLIMIT_KQUEUES, RLIMIT_KQUEUES, i32);
|
||||
CVAR!(C_RLIMIT_NPTS, RLIMIT_NPTS, i32);
|
||||
CVAR!(C_RLIMIT_NTHR, RLIMIT_NTHR, i32);
|
||||
|
||||
extern "C" {
|
||||
fn C_RLIMIT_SBSIZE() -> i32; // ifndef: -1
|
||||
fn C_RLIMIT_CORE() -> i32;
|
||||
fn C_RLIMIT_DATA() -> i32;
|
||||
fn C_RLIMIT_NICE() -> i32; // ifndef: -1
|
||||
fn C_RLIMIT_FSIZE() -> i32;
|
||||
fn C_RLIMIT_SIGPENDING() -> i32; // ifndef: -1
|
||||
fn C_RLIMIT_MEMLOCK() -> i32; // ifndef: -1
|
||||
fn C_RLIMIT_RSS() -> i32; // ifndef: -1
|
||||
fn C_RLIMIT_NOFILE() -> i32;
|
||||
fn C_RLIMIT_MSGQUEUE() -> i32; // ifndef: -1
|
||||
fn C_RLIMIT_RTPRIO() -> i32; // ifndef: -1
|
||||
fn C_RLIMIT_STACK() -> i32;
|
||||
fn C_RLIMIT_CPU() -> i32;
|
||||
fn C_RLIMIT_NPROC() -> i32; // ifndef: -1
|
||||
fn C_RLIMIT_AS() -> i32; // ifndef: -1
|
||||
fn C_RLIMIT_SWAP() -> i32; // ifndef: -1
|
||||
fn C_RLIMIT_RTTIME() -> i32; // ifndef: -1
|
||||
fn C_RLIMIT_KQUEUES() -> i32; // ifndef: -1
|
||||
fn C_RLIMIT_NPTS() -> i32; // ifndef: -1
|
||||
fn C_RLIMIT_NTHR() -> i32; // ifndef: -1
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue