split out suseconds_t for namespace pollution reduction preparation

This commit is contained in:
auronandace
2026-05-04 13:38:33 +01:00
parent 76f5c6a882
commit 1cd9d8769d
5 changed files with 36 additions and 9 deletions
+18
View File
@@ -0,0 +1,18 @@
# POSIX header spec: https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/sys_types.h.html
#
# This type is split out to prevent importing all of sys/types.h into other headers.
#
# POSIX headers that require suseconds_t:
# - sys/select.h
# - sys/time.h
# - sys/types.h (where it should be defined)
sys_includes = []
include_guard = "_RELIBC_BITS_SUSECONDS_T_H"
language = "C"
style = "type"
no_includes = true
cpp_compat = true
[export]
include = ["suseconds_t"]
[enum]
prefix_with_name = true
+14
View File
@@ -0,0 +1,14 @@
#[cfg(target_os = "linux")]
use crate::platform::types::c_long;
#[cfg(not(target_os = "linux"))]
use crate::platform::types::c_int;
#[cfg(target_os = "linux")]
#[allow(non_camel_case_types)]
/// Used for time in microseconds.
pub type suseconds_t = c_long;
#[cfg(not(target_os = "linux"))]
#[allow(non_camel_case_types)]
/// Used for time in microseconds.
pub type suseconds_t = c_int;
+2
View File
@@ -15,6 +15,8 @@ pub mod bits_safamily_t;
pub mod bits_sigset_t;
#[path = "bits_socklen-t/mod.rs"]
pub mod bits_socklen_t;
#[path = "bits_suseconds-t/mod.rs"]
pub mod bits_suseconds_t;
#[path = "bits_time-t/mod.rs"]
pub mod bits_time_t;
pub mod bits_timespec;
+1 -1
View File
@@ -1,6 +1,7 @@
sys_includes = ["stddef.h"]
# TODO: figure out how to export void* type
after_includes = """
#include <bits/suseconds-t.h>
#include <bits/time-t.h>
typedef void* timer_t;
@@ -25,7 +26,6 @@ include = [
"id_t",
"ssize_t",
"useconds_t",
"suseconds_t",
"clock_t",
"clockid_t",
"blkcnt_t",
+1 -8
View File
@@ -7,7 +7,7 @@
//! <https://pubs.opengroup.org/onlinepubs/009695399/basedefs/sys/types.h.html>
//! for the old specification.
pub use crate::header::bits_time_t::time_t;
pub use crate::header::{bits_suseconds_t::suseconds_t, bits_time_t::time_t};
use crate::platform::types::{
c_char, c_int, c_long, c_longlong, c_uchar, c_uint, c_ulong, c_ulonglong, c_ushort,
};
@@ -42,13 +42,6 @@ pub type id_t = c_uint;
pub type ssize_t = c_long;
pub type useconds_t = c_uint;
#[cfg(target_os = "linux")]
/// Used for time in microseconds.
pub type suseconds_t = c_long;
#[cfg(not(target_os = "linux"))]
/// Used for time in microseconds.
pub type suseconds_t = c_int;
/// Used for system times in clock ticks or CLOCKS_PER_SEC.
pub type clock_t = c_long;
/// Used for clock ID type in the clock and timer functions.