refactor sys_types_internal to reduce namespace pollution
This commit is contained in:
+1
-1
@@ -177,7 +177,7 @@ pub mod sys_random;
|
||||
pub mod sys_syslog;
|
||||
pub mod sys_types;
|
||||
#[allow(non_camel_case_types)]
|
||||
pub mod sys_types_internal;
|
||||
pub mod sys_types_extra;
|
||||
pub mod sys_uio;
|
||||
pub mod sys_un;
|
||||
pub mod sys_utsname;
|
||||
|
||||
@@ -5,11 +5,13 @@ use core::{
|
||||
|
||||
use bitflags;
|
||||
|
||||
use crate::header::{
|
||||
bits_sigset_t::sigset_t,
|
||||
errno::EINVAL,
|
||||
sched::{SCHED_FIFO, SCHED_OTHER, SCHED_RR, sched_param},
|
||||
sys_types_internal::pid_t,
|
||||
use crate::{
|
||||
header::{
|
||||
bits_sigset_t::sigset_t,
|
||||
errno::EINVAL,
|
||||
sched::{SCHED_FIFO, SCHED_OTHER, SCHED_RR, sched_param},
|
||||
},
|
||||
platform::types::pid_t,
|
||||
};
|
||||
|
||||
bitflags::bitflags! {
|
||||
|
||||
@@ -2,15 +2,41 @@
|
||||
#
|
||||
# There are no spec quotations relating to includes
|
||||
#
|
||||
# - sys/types/internal.h are fundamental C types
|
||||
# - sys/types/internal.h brings in features.h for deprecated annotations for useconds_t
|
||||
# - bits/pthread.h is separate for convenience
|
||||
sys_includes = [
|
||||
# Import most necessary, internal types first
|
||||
"sys/types/internal.h",
|
||||
"bits/pthread.h",
|
||||
]
|
||||
# TODO figure out how to handle useconds namespace pollution
|
||||
#
|
||||
# bits/useconds-t.h brings in features.h for deprecated annotation
|
||||
# bits/pthread.h is separate for convenience
|
||||
include_guard = "_RELIBC_SYS_TYPES_H"
|
||||
after_includes = """
|
||||
#include <bits/clock-t.h>
|
||||
#include <bits/clockid-t.h>
|
||||
#include <bits/dev-t.h>
|
||||
#include <bits/gid-t.h>
|
||||
#include <bits/id-t.h>
|
||||
#include <bits/ino-t.h>
|
||||
#include <bits/key-t.h>
|
||||
#include <bits/mode-t.h>
|
||||
#include <bits/nlink-t.h>
|
||||
#include <bits/off-t.h>
|
||||
#include <bits/pid-t.h>
|
||||
#include <bits/reclen-t.h>
|
||||
#include <bits/size-t.h> // for size_t from stddef.h
|
||||
#include <bits/ssize-t.h>
|
||||
#include <bits/suseconds-t.h>
|
||||
#include <bits/sys/stat.h> // for blkcnt_t and blksize_t
|
||||
#include <bits/sys/statvfs.h> // for fsblkcnt_t and fsfilcnt_t
|
||||
#include <bits/time-t.h>
|
||||
#include <bits/timer-t.h>
|
||||
#include <bits/uid-t.h>
|
||||
#include <bits/useconds-t.h> // from older POSIX
|
||||
|
||||
// Non-POSIX extras musl has guarded
|
||||
#if defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
|
||||
#include <sys/types/extra.h>
|
||||
#endif
|
||||
|
||||
#include <bits/pthread.h>
|
||||
"""
|
||||
no_includes = true
|
||||
language = "C"
|
||||
|
||||
|
||||
@@ -6,3 +6,28 @@
|
||||
//! removed in the Open Group Base Specifications Issue 7, see
|
||||
//! <https://pubs.opengroup.org/onlinepubs/009695399/basedefs/sys/types.h.html>
|
||||
//! for the old specification.
|
||||
|
||||
#[expect(deprecated)]
|
||||
pub use crate::header::bits_useconds_t::useconds_t;
|
||||
pub use crate::header::{
|
||||
bits_clock_t::clock_t,
|
||||
bits_clockid_t::clockid_t,
|
||||
bits_dev_t::dev_t,
|
||||
bits_gid_t::gid_t,
|
||||
bits_id_t::id_t,
|
||||
bits_ino_t::ino_t,
|
||||
bits_key_t::key_t,
|
||||
bits_mode_t::mode_t,
|
||||
bits_nlink_t::nlink_t,
|
||||
bits_off_t::off_t,
|
||||
bits_pid_t::pid_t,
|
||||
bits_reclen_t::reclen_t,
|
||||
bits_size_t::size_t,
|
||||
bits_ssize_t::ssize_t,
|
||||
bits_suseconds_t::suseconds_t,
|
||||
bits_sys_stat::{blkcnt_t, blksize_t},
|
||||
bits_sys_statvfs::{fsblkcnt_t, fsfilcnt_t},
|
||||
bits_time_t::time_t,
|
||||
bits_timer_t::timer_t,
|
||||
bits_uid_t::uid_t,
|
||||
};
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
include_guard = "_RELIBC_SYS_TYPES_EXTRA_H"
|
||||
language = "C"
|
||||
no_includes = true
|
||||
|
||||
[export]
|
||||
include = [
|
||||
"u_char",
|
||||
"uchar",
|
||||
"u_short",
|
||||
"ushort",
|
||||
"u_int",
|
||||
"uint",
|
||||
"u_long",
|
||||
"ulong",
|
||||
"quad_t",
|
||||
"u_quad_t",
|
||||
"caddr_t"
|
||||
]
|
||||
@@ -0,0 +1,26 @@
|
||||
//! Non-POSIX extras for `sys/types.h` implementation.
|
||||
|
||||
use crate::platform::types::{c_char, c_longlong, c_uchar, c_uint, c_ulong, c_ulonglong, c_ushort};
|
||||
|
||||
/// Intended as a convenience type.
|
||||
pub type u_char = c_uchar;
|
||||
/// Sys V compatibility type.
|
||||
pub type uchar = c_uchar;
|
||||
/// Intended as a convenience type.
|
||||
pub type u_short = c_ushort;
|
||||
/// Sys V compatibility type.
|
||||
pub type ushort = c_ushort;
|
||||
/// Intended as a convenience type.
|
||||
pub type u_int = c_uint;
|
||||
/// Sys V compatibility type.
|
||||
pub type uint = c_uint;
|
||||
/// Intended as a convenience type.
|
||||
pub type u_long = c_ulong;
|
||||
/// Sys V compatibility type.
|
||||
pub type ulong = c_ulong;
|
||||
/// Always 64bit, always `long long`.
|
||||
pub type quad_t = c_longlong;
|
||||
/// Always 64bit, always `unsigned long long`.
|
||||
pub type u_quad_t = c_ulonglong;
|
||||
/// Legacy BSD type.
|
||||
pub type caddr_t = *mut c_char;
|
||||
@@ -1,42 +0,0 @@
|
||||
# bits/useconds-t.h brings in features.h for deprecated annotation
|
||||
after_includes = """
|
||||
#include <bits/clock-t.h>
|
||||
#include <bits/clockid-t.h>
|
||||
#include <bits/dev-t.h>
|
||||
#include <bits/gid-t.h>
|
||||
#include <bits/id-t.h>
|
||||
#include <bits/ino-t.h>
|
||||
#include <bits/key-t.h>
|
||||
#include <bits/mode-t.h>
|
||||
#include <bits/nlink-t.h>
|
||||
#include <bits/off-t.h>
|
||||
#include <bits/pid-t.h>
|
||||
#include <bits/reclen-t.h>
|
||||
#include <bits/size-t.h> // for size_t from stddef.h
|
||||
#include <bits/ssize-t.h>
|
||||
#include <bits/suseconds-t.h>
|
||||
#include <bits/sys/stat.h> // for blkcnt_t and blksize_t
|
||||
#include <bits/sys/statvfs.h> // for fsblkcnt_t and fsfilcnt_t
|
||||
#include <bits/time-t.h>
|
||||
#include <bits/timer-t.h>
|
||||
#include <bits/uid-t.h>
|
||||
#include <bits/useconds-t.h> // from older POSIX
|
||||
"""
|
||||
include_guard = "_RELIBC_SYS_TYPES_INTERNAL_H"
|
||||
language = "C"
|
||||
no_includes = true
|
||||
|
||||
[export]
|
||||
include = [
|
||||
"u_char",
|
||||
"uchar",
|
||||
"u_short",
|
||||
"ushort",
|
||||
"u_int",
|
||||
"uint",
|
||||
"u_long",
|
||||
"ulong",
|
||||
"quad_t",
|
||||
"u_quad_t",
|
||||
"caddr_t"
|
||||
]
|
||||
@@ -1,46 +0,0 @@
|
||||
//! `sys/types.h` implementation.
|
||||
//!
|
||||
//! See <https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/sys_types.h.html>.
|
||||
//!
|
||||
//! Note that the `useconds_t` type provided in the `sys/types.h` header was
|
||||
//! removed in the Open Group Base Specifications Issue 7, see
|
||||
//! <https://pubs.opengroup.org/onlinepubs/009695399/basedefs/sys/types.h.html>
|
||||
//! for the old specification.
|
||||
|
||||
#[expect(deprecated)]
|
||||
pub use crate::header::bits_useconds_t::useconds_t;
|
||||
pub use crate::header::{
|
||||
bits_clock_t::clock_t,
|
||||
bits_clockid_t::clockid_t,
|
||||
bits_dev_t::dev_t,
|
||||
bits_gid_t::gid_t,
|
||||
bits_id_t::id_t,
|
||||
bits_ino_t::ino_t,
|
||||
bits_key_t::key_t,
|
||||
bits_mode_t::mode_t,
|
||||
bits_nlink_t::nlink_t,
|
||||
bits_off_t::off_t,
|
||||
bits_pid_t::pid_t,
|
||||
bits_reclen_t::reclen_t,
|
||||
bits_size_t::size_t,
|
||||
bits_ssize_t::ssize_t,
|
||||
bits_suseconds_t::suseconds_t,
|
||||
bits_sys_stat::{blkcnt_t, blksize_t},
|
||||
bits_sys_statvfs::{fsblkcnt_t, fsfilcnt_t},
|
||||
bits_time_t::time_t,
|
||||
bits_timer_t::timer_t,
|
||||
bits_uid_t::uid_t,
|
||||
};
|
||||
use crate::platform::types::{c_char, c_longlong, c_uchar, c_uint, c_ulong, c_ulonglong, c_ushort};
|
||||
|
||||
pub type u_char = c_uchar;
|
||||
pub type uchar = c_uchar;
|
||||
pub type u_short = c_ushort;
|
||||
pub type ushort = c_ushort;
|
||||
pub type u_int = c_uint;
|
||||
pub type uint = c_uint;
|
||||
pub type u_long = c_ulong;
|
||||
pub type ulong = c_ulong;
|
||||
pub type quad_t = c_longlong;
|
||||
pub type u_quad_t = c_ulonglong;
|
||||
pub type caddr_t = *mut c_char;
|
||||
Reference in New Issue
Block a user