split out time_t to prepare for reducing namespace pollution

This commit is contained in:
auronandace
2026-05-03 08:30:35 +01:00
parent fc0aa8471a
commit 8d2bcee829
5 changed files with 30 additions and 3 deletions
+21
View File
@@ -0,0 +1,21 @@
# 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 time_t:
# - sched.h
# - sys/select.h
# - sys/stat.h
# - sys/time.h
# - sys/types.h (where it should be defined)
# - time.h
sys_includes = []
include_guard = "_RELIBC_BITS_TIME_T_H"
language = "C"
style = "type"
no_includes = true
cpp_compat = true
[export]
include = ["time_t"]
[enum]
prefix_with_name = true
+5
View File
@@ -0,0 +1,5 @@
use crate::platform::types::c_longlong;
/// Used for time in seconds.
#[allow(non_camel_case_types)]
pub type time_t = c_longlong;
+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_time-t/mod.rs"]
pub mod bits_time_t;
pub mod bits_timespec;
// complex.h implemented in C
pub mod cpio;
+1 -1
View File
@@ -1,6 +1,7 @@
sys_includes = ["stddef.h"]
# TODO: figure out how to export void* type
after_includes = """
#include <bits/time-t.h>
typedef void* timer_t;
"""
@@ -23,7 +24,6 @@ include = [
"pid_t",
"id_t",
"ssize_t",
"time_t",
"useconds_t",
"suseconds_t",
"clock_t",
+1 -2
View File
@@ -10,6 +10,7 @@
use crate::platform::types::{
c_char, c_int, c_long, c_longlong, c_uchar, c_uint, c_ulong, c_ulonglong, c_ushort,
};
pub use crate::header::bits_time_t::time_t;
/// Used for block sizes.
pub type blksize_t = c_long;
@@ -39,8 +40,6 @@ pub type pid_t = c_int;
pub type id_t = c_uint;
/// Used for a count of bytes or an error indication.
pub type ssize_t = c_long;
/// Used for time in seconds.
pub type time_t = c_longlong;
pub type useconds_t = c_uint;
#[cfg(target_os = "linux")]