Merge branch 'header-spec-link-cleanup' into 'master'
Header spec link cleanup See merge request redox-os/relibc!835
This commit is contained in:
@@ -1,10 +1,13 @@
|
||||
// langinfo.h implementation for Redox, following the POSIX standard.
|
||||
// Following https://pubs.opengroup.org/onlinepubs/7908799/xsh/langinfo.h.html
|
||||
//
|
||||
//! `langinfo.h` implementation.
|
||||
//!
|
||||
//! See <https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/langinfo.h.html>.
|
||||
|
||||
// TODO : involve loading locale data. Currently, the implementation only supports the "C" locale.
|
||||
|
||||
use core::ffi::c_char;
|
||||
|
||||
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/langinfo.h.html>.
|
||||
///
|
||||
/// POSIX type for items used with `nl_langinfo`
|
||||
/// In practice, this is an integer index into the string table.
|
||||
pub type nl_item = i32;
|
||||
@@ -130,10 +133,12 @@ pub const RADIXCHAR: nl_item = 50;
|
||||
pub const THOUSEP: nl_item = 51;
|
||||
pub const YESEXPR: nl_item = 52;
|
||||
pub const NOEXPR: nl_item = 53;
|
||||
pub const YESSTR: nl_item = 54; // Legaxy
|
||||
pub const YESSTR: nl_item = 54; // Legacy
|
||||
pub const NOSTR: nl_item = 55; // Legacy
|
||||
pub const CRNCYSTR: nl_item = 56;
|
||||
|
||||
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/nl_langinfo.html>.
|
||||
///
|
||||
/// Get a string from the langinfo table
|
||||
///
|
||||
/// # Safety
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
//! limits.h implementation for relibc
|
||||
//! Following https://pubs.opengroup.org/onlinepubs/7908799/xsh/limits.h.html
|
||||
//! `limits.h` implementation.
|
||||
//!
|
||||
//! See <https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/limits.h.html>.
|
||||
|
||||
use core::ffi::c_long;
|
||||
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
/// `monetary.h` implementation.
|
||||
///
|
||||
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/monetary.h.html>.
|
||||
///
|
||||
/// We should provide a strfmon() implementation that formats a monetary value,
|
||||
/// according to the current locale (TODO).
|
||||
//! `monetary.h` implementation.
|
||||
//!
|
||||
//! See <https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/monetary.h.html>.
|
||||
|
||||
// We should provide a strfmon() implementation that formats a monetary value,
|
||||
// according to the current locale (TODO).
|
||||
|
||||
use alloc::string::{String, ToString};
|
||||
use core::{ffi::CStr, ptr, slice, str};
|
||||
|
||||
|
||||
@@ -252,7 +252,7 @@ pub extern "C" fn getpwent() -> *mut passwd {
|
||||
|
||||
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/getpwnam.html>.
|
||||
#[unsafe(no_mangle)]
|
||||
pub extern "C" fn getpwnam(name: *const c_char) -> *mut passwd {
|
||||
pub unsafe extern "C" fn getpwnam(name: *const c_char) -> *mut passwd {
|
||||
pwd_lookup(|parts| unsafe { strcmp(parts.pw_name, name) } == 0, None)
|
||||
.map(|res| res.into_global())
|
||||
.unwrap_or(ptr::null_mut())
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
// This is syslog.h implemented based on POSIX.1-2017
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/syslog.h.html
|
||||
//! `syslog.h` implementation.
|
||||
//!
|
||||
//! See <https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/syslog.h.html>.
|
||||
|
||||
// Exported as both syslog.h and sys/syslog.h.
|
||||
|
||||
#[cfg(target_os = "redox")]
|
||||
#[path = "redox.rs"]
|
||||
@@ -13,7 +16,10 @@ pub mod logger;
|
||||
|
||||
use core::ffi::VaList;
|
||||
|
||||
use crate::{c_str::CStr, platform::types::*};
|
||||
use crate::{
|
||||
c_str::CStr,
|
||||
platform::types::{c_char, c_int},
|
||||
};
|
||||
use logger::{LOGGER, Priority};
|
||||
|
||||
/// Record the caller's PID in log messages.
|
||||
@@ -74,6 +80,7 @@ pub const extern "C" fn LOG_MASK(p: c_int) -> c_int {
|
||||
1 << p
|
||||
}
|
||||
|
||||
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/closelog.html>.
|
||||
#[unsafe(no_mangle)]
|
||||
pub extern "C" fn setlogmask(mask: c_int) -> c_int {
|
||||
let mut params = LOGGER.lock();
|
||||
@@ -86,6 +93,7 @@ pub extern "C" fn setlogmask(mask: c_int) -> c_int {
|
||||
old
|
||||
}
|
||||
|
||||
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/closelog.html>.
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn openlog(ident: *const c_char, opt: c_int, facility: c_int) {
|
||||
let ident = unsafe { CStr::from_nullable_ptr(ident) };
|
||||
@@ -107,6 +115,9 @@ pub unsafe extern "C" fn openlog(ident: *const c_char, opt: c_int, facility: c_i
|
||||
}
|
||||
}
|
||||
|
||||
/// See <https://www.man7.org/linux/man-pages/man3/vsyslog.3.html>.
|
||||
///
|
||||
/// Non-POSIX, 4.3BSD-Reno.
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn vsyslog(priority: c_int, message: *const c_char, mut ap: VaList) {
|
||||
let Some(message) = CStr::from_nullable_ptr(message) else {
|
||||
@@ -122,11 +133,13 @@ pub unsafe extern "C" fn vsyslog(priority: c_int, message: *const c_char, mut ap
|
||||
}
|
||||
}
|
||||
|
||||
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/closelog.html>.
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn syslog(priority: c_int, message: *const c_char, mut __valist: ...) {
|
||||
vsyslog(priority, message, __valist.as_va_list());
|
||||
}
|
||||
|
||||
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/closelog.html>.
|
||||
#[unsafe(no_mangle)]
|
||||
pub extern "C" fn closelog() {
|
||||
LOGGER.lock().close();
|
||||
|
||||
@@ -1 +1,3 @@
|
||||
//! sys/types.h
|
||||
//! `sys/types.h` implementation.
|
||||
//!
|
||||
//! See <https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/sys_types.h.html>.
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
//! tar.h implementation for Redox, following POSIX.1-1990 specification
|
||||
//! and https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/tar.h.html
|
||||
//! `tar.h` implementation.
|
||||
//!
|
||||
//! See <https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/tar.h.html>.
|
||||
|
||||
use core::slice;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user