libc: more header stubs

This commit is contained in:
Mark Poliakov 2024-11-12 17:50:38 +02:00
parent 312deb8a56
commit c957a603e0
13 changed files with 370 additions and 68 deletions

View File

@ -0,0 +1,14 @@
language = "C"
style = "Tag"
sys_includes = ["stddef.h", "sys/types.h"]
no_includes = true
include_guard = "_GRP_H"
usize_type = "size_t"
isize_type = "ssize_t"
[export]
include = ["group"]
exclude = []

View File

@ -0,0 +1,57 @@
use core::ffi::{c_char, c_int};
use super::sys_types::gid_t;
#[repr(C)]
pub struct group {
pub gr_name: *mut c_char,
pub gr_gid: gid_t,
pub gr_mem: *mut *mut c_char,
}
#[no_mangle]
unsafe extern "C" fn endgrent() {
todo!()
}
#[no_mangle]
unsafe extern "C" fn getgrent() -> *mut group {
todo!()
}
#[no_mangle]
unsafe extern "C" fn getgrgid(_gid: gid_t) -> *mut group {
todo!()
}
#[no_mangle]
unsafe extern "C" fn getgrgid_r(
_gid: gid_t,
_group: *mut group,
_buf: *mut c_char,
_buflen: usize,
_result: *mut *mut group,
) -> c_int {
todo!()
}
#[no_mangle]
unsafe extern "C" fn getgrnam(_name: *const c_char) -> *mut group {
todo!()
}
#[no_mangle]
unsafe extern "C" fn getgrnam_r(
_name: *const c_char,
_group: *mut group,
_buf: *mut c_char,
_buflen: usize,
_result: *mut *mut group,
) -> c_int {
todo!()
}
#[no_mangle]
unsafe extern "C" fn setgrent() {
todo!()
}

View File

@ -0,0 +1,10 @@
language = "C"
style = "Type"
sys_includes = []
no_includes = true
include_guard = "_LIBGEN_H"
usize_type = "size_t"
isize_type = "ssize_t"

View File

@ -0,0 +1,11 @@
use core::ffi::c_char;
#[no_mangle]
unsafe extern "C" fn basename(_path: *mut c_char) -> *mut c_char {
todo!()
}
#[no_mangle]
unsafe extern "C" fn dirname(_path: *mut c_char) -> *mut c_char {
todo!()
}

View File

@ -1,103 +1,120 @@
#![allow(non_camel_case_types, non_upper_case_globals)]
// <aio.h> -
// <arpa/inet.h> -
// <assert.h> +
// - not yet implemented
// = partially implemented
// + fully implemented
// ! out of scope for now
// Network
// <arpa/inet.h> !
// <ndbm.h> !
// <net/if.h> !
// <netdb.h> !
// <netinet/in.h> !
// <netinet/tcp.h> !
// <nl_types.h> !
// <sys/socket.h> !
// <sys/un.h> !
// Math
// <complex.h> -
// <cpio.h> -
// <ctype.h> +
// <dirent.h> +
// <dlfcn.h> -
// <errno.h> +
// <fcntl.h> +
// <fenv.h> -
// <float.h> -
// <fmtmsg.h> -
// <math.h> -
// <tgmath.h> -
// I/O utilities
// <cpio.h> !
// <fmtmsg.h> !
// <fnmatch.h> -
// <ftw.h> -
// <glob.h> -
// <grp.h> -
// <iconv.h> -
// <inttypes.h> +
// <iso646.h> -
// <langinfo.h> -
// <libgen.h> -
// <limits.h> ?
// <locale.h> =
// <math.h> -
// <monetary.h> -
// <mqueue.h> -
// <ndbm.h> -
// <net/if.h> -
// <netdb.h> -
// <netinet/in.h> -
// <netinet/tcp.h> -
// <nl_types.h> -
// <mqueue.h> !
// <stdlib.h> =
// <stropts.h> !
// <sys/uio.h> !
// <tar.h> !
// I/O
// <aio.h> !
// <dirent.h> +
// <fcntl.h> +
// <poll.h> -
// <pthread.h> -
// <stdio.h> +
// <sys/select.h> -
// <sys/shm.h> -
// <sys/stat.h> =
// <sys/statvfs.h> -
// <syslog.h> !
// <termios.h> -
// <trace.h> !
// <unistd.h> ~
// Misc utilities
// <assert.h> +
// <dlfcn.h> !
// <errno.h> +
// <grp.h> =
// <libgen.h> =
// <pwd.h> =
// <regex.h> -
// <sched.h> -
// <search.h> -
// <semaphore.h> -
// <sched.h> =
// <search.h> !
// <sys/resource.h> =
// <sys/time.h> =
// <sys/times.h> =
// <sys/types.h> +
// <sys/utsname.h> =
// <time.h> =
// <utmpx.h> !
// Process utilities
// <pthread.h> !
// <semaphore.h> !
// <setjmp.h> +
// <signal.h> =
// <spawn.h> -
// <stdarg.h> +
// <stdbool.h> +
// <stddef.h> +
// <stdint.h> +
// <stdio.h> +
// <stdlib.h> -
// <string.h> +
// <strings.h> -
// <stropts.h> -
// <sys/ipc.h> -
// <sys/ipc.h> !
// <sys/mman.h> -
// <sys/msg.h> -
// <sys/resource.h> -
// <sys/select.h> -
// <sys/sem.h> -
// <sys/shm.h> -
// <sys/socket.h> -
// <sys/stat.h> =
// <sys/statvfs.h> -
// <sys/time.h> =
// <sys/times.h> -
// <sys/types.h> +
// <sys/uio.h> -
// <sys/un.h> -
// <sys/utsname.h> -
// <sys/msg.h> !
// <sys/sem.h> !
// <sys/wait.h> -
// <syslog.h> -
// <tar.h> -
// <termios.h> -
// <tgmath.h> -
// <time.h> =
// <trace.h> -
// <ulimit.h> -
// <unistd.h> ~
// <utime.h> -
// <utmpx.h> -
// Locale & string utilities
// <ctype.h> +
// <iconv.h> -
// <langinfo.h> -
// <locale.h> =
// <monetary.h> -
// <regex.h> -
// <string.h> +
// <strings.h> =
// <wchar.h> -
// <wctype.h> -
// <wordexp.h> -
// <wordexp.h> !
pub mod ctype;
pub mod dirent;
pub mod errno;
pub mod fcntl;
pub mod grp;
pub mod libgen;
pub mod locale;
pub mod pwd;
pub mod sched;
pub mod setjmp;
pub mod signal;
pub mod stdio;
pub mod stdlib;
pub mod string;
pub mod strings;
pub mod unistd;
pub mod signal;
pub mod time;
pub mod unistd;
pub mod sys_types;
pub mod sys_resource;
pub mod sys_stat;
pub mod sys_time;
pub mod sys_times;
pub mod sys_types;
pub mod sys_utsname;

View File

@ -0,0 +1,10 @@
language = "C"
style = "Tag"
sys_includes = ["sys/types.h", "time.h"]
no_includes = true
include_guard = "_SCHED_H"
usize_type = "size_t"
isize_type = "ssize_t"

View File

@ -0,0 +1,61 @@
use core::ffi::c_int;
use super::{sys_time::__ygg_timespec_t, sys_types::pid_t};
#[repr(C)]
pub struct sched_param {
pub sched_priority: c_int,
pub sched_ss_low_priority: c_int,
pub sched_ss_repl_period: __ygg_timespec_t,
pub sched_ss_init_budget: __ygg_timespec_t,
pub sched_ss_max_repl: c_int,
}
pub const SCHED_FIFO: c_int = 0;
pub const SCHED_RR: c_int = 1;
pub const SCHED_SPORADIC: c_int = 2;
pub const SCHED_OTHER: c_int = -1;
#[no_mangle]
unsafe extern "C" fn sched_get_priority_max(_policy: c_int) -> c_int {
todo!()
}
#[no_mangle]
unsafe extern "C" fn sched_get_priority_min(_policy: c_int) -> c_int {
todo!()
}
#[no_mangle]
unsafe extern "C" fn sched_getparam(_pid: pid_t, _param: *mut sched_param) -> c_int {
todo!()
}
#[no_mangle]
unsafe extern "C" fn sched_getscheduler(_pid: pid_t) -> c_int {
todo!()
}
#[no_mangle]
unsafe extern "C" fn sched_rr_get_interval(_pid: pid_t, _timespec: *mut __ygg_timespec_t) -> c_int {
todo!()
}
#[no_mangle]
unsafe extern "C" fn sched_setparam(_pid: pid_t, _param: *const sched_param) -> c_int {
todo!()
}
#[no_mangle]
unsafe extern "C" fn sched_setscheduler(
_pid: pid_t,
_policy: c_int,
_param: *const sched_param,
) -> c_int {
todo!()
}
#[no_mangle]
unsafe extern "C" fn sched_yield() -> c_int {
todo!()
}

View File

@ -0,0 +1,13 @@
language = "C"
style = "Tag"
sys_includes = ["stdint.h", "sys/types.h", "sys/time.h"]
no_includes = true
include_guard = "_SYS_RESOURCE_H"
usize_type = "size_t"
isize_type = "ssize_t"
[export]
include = ["rlimit", "rusage"]

View File

@ -0,0 +1,60 @@
use core::ffi::c_int;
use super::{sys_time::__ygg_timeval_t, sys_types::id_t};
pub type rlim_t = u64;
pub const PRIO_PROCESS: c_int = 0;
pub const PRIO_PGRP: c_int = 1;
pub const PRIO_USER: c_int = 2;
pub const RLIM_INFINITY: rlim_t = u64::MAX;
pub const RLIM_SAVED_MAX: rlim_t = RLIM_INFINITY;
pub const RLIM_SAVED_CUR: rlim_t = RLIM_INFINITY;
pub const RUSAGE_SELF: c_int = 0;
pub const RLIMIT_CORE: c_int = 1;
pub const RLIMIT_CPU: c_int = 2;
pub const RLIMIT_DATA: c_int = 3;
pub const RLIMIT_FSIZE: c_int = 4;
pub const RLIMIT_NOFILE: c_int = 5;
pub const RLIMIT_STACK: c_int = 6;
pub const RLIMIT_AS: c_int = 7;
#[repr(C)]
pub struct rlimit {
pub rlim_cur: rlim_t,
pub rlim_max: rlim_t
}
#[repr(C)]
pub struct rusage {
pub ru_utime: __ygg_timeval_t,
pub ru_stime: __ygg_timeval_t
}
#[no_mangle]
unsafe extern "C" fn getpriority(_which: c_int, _who: id_t) -> c_int {
todo!()
}
#[no_mangle]
unsafe extern "C" fn getrlimit(_which: c_int, _rlimit: *mut rlimit) -> c_int {
todo!()
}
#[no_mangle]
unsafe extern "C" fn getrusage(_which: c_int, _rusage: *mut rusage) -> c_int {
todo!()
}
#[no_mangle]
unsafe extern "C" fn setpriority(_which: c_int, _who: id_t, _prio: c_int) -> c_int {
todo!()
}
#[no_mangle]
unsafe extern "C" fn setrlimit(_which: c_int, _rlimit: *const rlimit) -> c_int {
todo!()
}

View File

@ -0,0 +1,10 @@
language = "C"
style = "Tag"
sys_includes = ["sys/types.h"]
no_includes = true
include_guard = "_SYS_TIMES_H"
usize_type = "size_t"
isize_type = "ssize_t"

View File

@ -0,0 +1,14 @@
use super::sys_types::clock_t;
#[repr(C)]
pub struct tms {
pub tms_utime: clock_t,
pub tms_stime: clock_t,
pub tms_cutime: clock_t,
pub tms_cstime: clock_t,
}
#[no_mangle]
unsafe extern "C" fn times(_times: *mut tms) -> clock_t {
todo!()
}

View File

@ -0,0 +1,10 @@
language = "C"
style = "Tag"
sys_includes = []
no_includes = true
include_guard = "_SYS_UTSNAME_H"
usize_type = "size_t"
isize_type = "ssize_t"

View File

@ -0,0 +1,15 @@
use core::ffi::{c_char, c_int};
#[repr(C)]
pub struct utsname {
pub sysname: [c_char; 64],
pub nodename: [c_char; 64],
pub release: [c_char; 64],
pub version: [c_char; 64],
pub machine: [c_char; 64],
}
#[no_mangle]
unsafe extern "C" fn uname(_uname: *mut utsname) -> c_int {
todo!()
}