Merge branch 'systypes-internals' into 'master'

move internal types from C to rust

See merge request redox-os/relibc!1221
This commit is contained in:
Jeremy Soller
2026-04-23 09:10:51 -06:00
5 changed files with 122 additions and 40 deletions
-39
View File
@@ -1,39 +0,0 @@
#ifndef _SYS_TYPES_INTERNAL_H
#define _SYS_TYPES_INTERNAL_H
#include <stddef.h>
typedef long blksize_t;
typedef unsigned long long dev_t;
typedef unsigned long long ino_t;
typedef unsigned short reclen_t;
typedef int gid_t;
typedef int uid_t;
typedef int mode_t;
typedef unsigned long nlink_t;
typedef long long off_t;
typedef int pid_t;
typedef unsigned id_t;
typedef long ssize_t;
typedef long long time_t;
typedef unsigned int useconds_t;
#if defined(__linux__)
typedef long suseconds_t;
#else
typedef int suseconds_t;
#endif
typedef long clock_t;
typedef int clockid_t;
typedef void* timer_t;
typedef long long blkcnt_t;
typedef unsigned long int fsblkcnt_t;
typedef unsigned long int fsfilcnt_t;
typedef unsigned char u_char, uchar;
typedef unsigned short u_short, ushort;
typedef unsigned int u_int, uint;
typedef unsigned long u_long, ulong;
typedef long long quad_t;
typedef unsigned long long u_quad_t;
typedef char *caddr_t;
#endif /* _SYS_TYPES_INTERNAL_H */
+2
View File
@@ -116,6 +116,8 @@ pub mod sys_procfs;
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_uio;
pub mod sys_un;
pub mod sys_utsname;
+1 -1
View File
@@ -10,7 +10,7 @@
no_includes = true
sys_includes = [
# Import most necessary, internal types first
"sys/types_internal.h",
"sys/types/internal.h",
"bits/pthread.h",
"features.h",
@@ -0,0 +1,45 @@
sys_includes = ["stddef.h"]
# TODO: figure out how to export void* type
after_includes = """
typedef void* timer_t;
"""
include_guard = "_RELIBC_SYS_TYPES_INTERNAL_H"
language = "C"
style = "Type"
no_includes = true
[export]
include = [
"blksize_t",
"dev_t",
"ino_t",
"reclen_t",
"gid_t",
"uid_t",
"mode_t",
"nlink_t",
"off_t",
"pid_t",
"id_t",
"ssize_t",
"time_t",
"useconds_t",
"suseconds_t",
"clock_t",
"clockid_t",
"blkcnt_t",
"fsblkcnt_t",
"fsfilcnt_t",
"u_char",
"uchar",
"u_short",
"ushort",
"u_int",
"uint",
"u_long",
"ulong",
"quad_t",
"u_quad_t",
"caddr_t"
]
+74
View File
@@ -0,0 +1,74 @@
//! `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.
use crate::platform::types::{
c_char, c_int, c_long, c_longlong, c_uchar, c_uint, c_ulong, c_ulonglong, c_ushort,
};
/// Used for block sizes.
pub type blksize_t = c_long;
/// Used for device IDs.
pub type dev_t = c_ulonglong;
/// Used for serial numbers.
pub type ino_t = c_ulonglong;
/// Used for directory entry lengths.
pub type reclen_t = c_ushort;
/// Used for group IDs.
pub type gid_t = c_int;
/// Used for user IDs.
pub type uid_t = c_int;
/// Used for some file attributes.
pub type mode_t = c_int;
/// Used for link counts.
pub type nlink_t = c_ulong;
/// Used for file sizes.
pub type off_t = c_longlong;
/// Used for process IDs and process group IDs.
pub type pid_t = c_int;
/// Used as a general identifier; can be used to contain at least a pid_t, uid_t, or gid_t.
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")]
/// 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.
pub type clockid_t = c_int;
// timer_t in cbindgen after_includes (how to export void* type?)
/// Used for file block counts.
pub type blkcnt_t = c_longlong;
/// Used for file system block counts.
pub type fsblkcnt_t = c_ulong;
/// Used for file system file counts.
pub type fsfilcnt_t = c_ulong;
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;