+1
Cargo.toml
+1
Cargo.toml
+5
-1
src/header/libgen/mod.rs
+5
-1
src/header/libgen/mod.rs
···
1
-
//! libgen implementation for Redox, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/libgen.h.html
2
3
#![deny(unsafe_op_in_unsafe_fn)]
4
···
6
7
use crate::header::string::strlen;
8
9
#[unsafe(no_mangle)]
10
pub unsafe extern "C" fn basename(str: *mut c_char) -> *mut c_char {
11
if str.is_null() || unsafe { strlen(str) == 0 } {
···
28
}
29
}
30
31
#[unsafe(no_mangle)]
32
pub unsafe extern "C" fn dirname(str: *mut c_char) -> *mut c_char {
33
if str.is_null() || unsafe { strlen(str) == 0 } {
···
1
+
//! `libgen.h` implementation.
2
+
//!
3
+
//! See <https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/libgen.h.html>.
4
5
#![deny(unsafe_op_in_unsafe_fn)]
6
···
8
9
use crate::header::string::strlen;
10
11
+
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/basename.html>.
12
#[unsafe(no_mangle)]
13
pub unsafe extern "C" fn basename(str: *mut c_char) -> *mut c_char {
14
if str.is_null() || unsafe { strlen(str) == 0 } {
···
31
}
32
}
33
34
+
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/dirname.html>.
35
#[unsafe(no_mangle)]
36
pub unsafe extern "C" fn dirname(str: *mut c_char) -> *mut c_char {
37
if str.is_null() || unsafe { strlen(str) == 0 } {
+12
-3
src/header/sys_resource/mod.rs
+12
-3
src/header/sys_resource/mod.rs
···
1
-
//! sys/resource.h implementation for Redox, following
2
-
//! http://pubs.opengroup.org/onlinepubs/7908799/xsh/sysresource.h.html
3
4
use crate::{
5
error::ResultExt,
6
header::sys_time::timeval,
7
out::Out,
8
-
platform::{Pal, Sys, types::*},
9
};
10
11
// Exported in bits file
···
67
pub const PRIO_PGRP: c_int = 1;
68
pub const PRIO_USER: c_int = 2;
69
70
#[unsafe(no_mangle)]
71
pub unsafe extern "C" fn getpriority(which: c_int, who: id_t) -> c_int {
72
let r = Sys::getpriority(which, who).or_minus_one_errno();
···
76
20 - r
77
}
78
79
#[unsafe(no_mangle)]
80
pub unsafe extern "C" fn setpriority(which: c_int, who: id_t, nice: c_int) -> c_int {
81
Sys::setpriority(which, who, nice)
···
83
.or_minus_one_errno()
84
}
85
86
#[unsafe(no_mangle)]
87
pub unsafe extern "C" fn getrlimit(resource: c_int, rlp: *mut rlimit) -> c_int {
88
let rlp = Out::nonnull(rlp);
···
92
.or_minus_one_errno()
93
}
94
95
#[unsafe(no_mangle)]
96
pub unsafe extern "C" fn setrlimit(resource: c_int, rlp: *const rlimit) -> c_int {
97
Sys::setrlimit(resource, rlp)
···
99
.or_minus_one_errno()
100
}
101
102
#[unsafe(no_mangle)]
103
pub unsafe extern "C" fn getrusage(who: c_int, r_usage: *mut rusage) -> c_int {
104
Sys::getrusage(who, Out::nonnull(r_usage))
···
1
+
//! `sys/resource.h` implementation.
2
+
//!
3
+
//! See <https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/sys_resource.h.html>.
4
5
use crate::{
6
error::ResultExt,
7
header::sys_time::timeval,
8
out::Out,
9
+
platform::{
10
+
Pal, Sys,
11
+
types::{c_int, c_long, id_t},
12
+
},
13
};
14
15
// Exported in bits file
···
71
pub const PRIO_PGRP: c_int = 1;
72
pub const PRIO_USER: c_int = 2;
73
74
+
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/getpriority.html>.
75
#[unsafe(no_mangle)]
76
pub unsafe extern "C" fn getpriority(which: c_int, who: id_t) -> c_int {
77
let r = Sys::getpriority(which, who).or_minus_one_errno();
···
81
20 - r
82
}
83
84
+
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/setpriority.html>.
85
#[unsafe(no_mangle)]
86
pub unsafe extern "C" fn setpriority(which: c_int, who: id_t, nice: c_int) -> c_int {
87
Sys::setpriority(which, who, nice)
···
89
.or_minus_one_errno()
90
}
91
92
+
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/getrlimit.html>.
93
#[unsafe(no_mangle)]
94
pub unsafe extern "C" fn getrlimit(resource: c_int, rlp: *mut rlimit) -> c_int {
95
let rlp = Out::nonnull(rlp);
···
99
.or_minus_one_errno()
100
}
101
102
+
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/setrlimit.html>.
103
#[unsafe(no_mangle)]
104
pub unsafe extern "C" fn setrlimit(resource: c_int, rlp: *const rlimit) -> c_int {
105
Sys::setrlimit(resource, rlp)
···
107
.or_minus_one_errno()
108
}
109
110
+
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/getrusage.html>.
111
#[unsafe(no_mangle)]
112
pub unsafe extern "C" fn getrusage(who: c_int, r_usage: *mut rusage) -> c_int {
113
Sys::getrusage(who, Out::nonnull(r_usage))
+1
include/sys/types_internal.h
+1
include/sys/types_internal.h
+1
src/platform/types.rs
+1
src/platform/types.rs
+2
-2
tests/dirent/posix_getdents.c
+2
-2
tests/dirent/posix_getdents.c
···
14
char buffer[BUFFER_SIZE];
15
long nread;
16
long bpos;
17
-
struct dirent *d;
18
19
for (;;) {
20
nread = posix_getdents(fd, buffer, BUFFER_SIZE, 0);
···
26
}
27
28
for (bpos = 0; bpos < nread;) {
29
-
d = (struct dirent *) (buffer + bpos);
30
printf(" ino = %-10lu name = %s\n", (unsigned long)d->d_ino, d->d_name);
31
bpos += d->d_reclen;
32
}
···
14
char buffer[BUFFER_SIZE];
15
long nread;
16
long bpos;
17
+
struct posix_dent *d;
18
19
for (;;) {
20
nread = posix_getdents(fd, buffer, BUFFER_SIZE, 0);
···
26
}
27
28
for (bpos = 0; bpos < nread;) {
29
+
d = (struct posix_dent *) (buffer + bpos);
30
printf(" ino = %-10lu name = %s\n", (unsigned long)d->d_ino, d->d_name);
31
bpos += d->d_reclen;
32
}
+7
-2
src/header/assert/mod.rs
+7
-2
src/header/assert/mod.rs
···
1
-
//! assert implementation for Redox, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/assert.h.html
2
3
// TODO: set this for entire crate when possible
4
#![deny(unsafe_op_in_unsafe_fn)]
5
6
-
use crate::{c_str::CStr, platform::types::*};
7
8
#[unsafe(no_mangle)]
9
pub unsafe extern "C" fn __assert_fail(
···
1
+
//! `assert.h` implementation.
2
+
//!
3
+
//! See <https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/assert.h.html>.
4
5
// TODO: set this for entire crate when possible
6
#![deny(unsafe_op_in_unsafe_fn)]
7
8
+
use crate::{
9
+
c_str::CStr,
10
+
platform::types::{c_char, c_int},
11
+
};
12
13
#[unsafe(no_mangle)]
14
pub unsafe extern "C" fn __assert_fail(
+13
-2
src/header/fcntl/mod.rs
+13
-2
src/header/fcntl/mod.rs
···
1
-
//! fcntl implementation for Redox, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/fcntl.h.html
2
3
#![deny(unsafe_op_in_unsafe_fn)]
4
5
use crate::{
6
c_str::CStr,
7
error::ResultExt,
8
-
platform::{Pal, Sys, types::*},
9
};
10
11
pub use self::sys::*;
···
36
pub const F_TLOCK: c_int = 2;
37
pub const F_TEST: c_int = 3;
38
39
#[unsafe(no_mangle)]
40
pub unsafe extern "C" fn creat(path: *const c_char, mode: mode_t) -> c_int {
41
unsafe { open(path, O_WRONLY | O_CREAT | O_TRUNC, mode) }
42
}
43
#[repr(C)]
44
#[derive(Clone, Copy, Default)]
45
pub struct flock {
···
49
pub l_len: off_t,
50
pub l_pid: pid_t,
51
}
52
#[unsafe(no_mangle)]
53
pub unsafe extern "C" fn fcntl(fildes: c_int, cmd: c_int, mut __valist: ...) -> c_int {
54
// c_ulonglong
···
62
Sys::fcntl(fildes, cmd, arg).or_minus_one_errno()
63
}
64
65
#[unsafe(no_mangle)]
66
pub unsafe extern "C" fn open(path: *const c_char, oflag: c_int, mut __valist: ...) -> c_int {
67
let mode = if oflag & O_CREAT == O_CREAT
···
1
+
//! `fcntl.h` implementation.
2
+
//!
3
+
//! See <https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/fcntl.h.html>.
4
5
#![deny(unsafe_op_in_unsafe_fn)]
6
7
use crate::{
8
c_str::CStr,
9
error::ResultExt,
10
+
platform::{
11
+
Pal, Sys,
12
+
types::{c_char, c_int, c_short, c_ulonglong, mode_t, off_t, pid_t},
13
+
},
14
};
15
16
pub use self::sys::*;
···
41
pub const F_TLOCK: c_int = 2;
42
pub const F_TEST: c_int = 3;
43
44
+
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/creat.html>.
45
#[unsafe(no_mangle)]
46
pub unsafe extern "C" fn creat(path: *const c_char, mode: mode_t) -> c_int {
47
unsafe { open(path, O_WRONLY | O_CREAT | O_TRUNC, mode) }
48
}
49
+
50
+
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/fcntl.h.html>.
51
#[repr(C)]
52
#[derive(Clone, Copy, Default)]
53
pub struct flock {
···
57
pub l_len: off_t,
58
pub l_pid: pid_t,
59
}
60
+
61
+
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/fcntl.html>.
62
#[unsafe(no_mangle)]
63
pub unsafe extern "C" fn fcntl(fildes: c_int, cmd: c_int, mut __valist: ...) -> c_int {
64
// c_ulonglong
···
72
Sys::fcntl(fildes, cmd, arg).or_minus_one_errno()
73
}
74
75
+
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/open.html>.
76
#[unsafe(no_mangle)]
77
pub unsafe extern "C" fn open(path: *const c_char, oflag: c_int, mut __valist: ...) -> c_int {
78
let mode = if oflag & O_CREAT == O_CREAT
+2
src/out.rs
+2
src/out.rs
···
205
pub unsafe trait CastSlice<U> {}
206
unsafe impl CastSlice<i8> for u8 {}
207
unsafe impl CastSlice<u8> for i8 {}
208
+
unsafe impl CastSlice<u8> for u8 {}
209
+
unsafe impl CastSlice<i8> for i8 {}
210
211
impl<T: ?Sized> fmt::Pointer for Out<'_, T> {
212
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+35
-35
flake.lock
+35
-35
flake.lock
···
1
{
2
"nodes": {
3
-
"crane": {
4
"locked": {
5
-
"lastModified": 1759893430,
6
-
"narHash": "sha256-yAy4otLYm9iZ+NtQwTMEbqHwswSFUbhn7x826RR6djw=",
7
-
"owner": "ipetkov",
8
-
"repo": "crane",
9
-
"rev": "1979a2524cb8c801520bd94c38bb3d5692419d93",
10
-
"type": "github"
11
},
12
"original": {
13
-
"owner": "ipetkov",
14
-
"repo": "crane",
15
-
"type": "github"
16
}
17
},
18
"fenix": {
···
23
"rust-analyzer-src": "rust-analyzer-src"
24
},
25
"locked": {
26
-
"lastModified": 1760164678,
27
-
"narHash": "sha256-yxcfwZCysR6zPaFv7is3/FWd1h0h6kXME0vueSwTBhU=",
28
"owner": "nix-community",
29
"repo": "fenix",
30
-
"rev": "2579f163559b902959cc420a6d3bfbd98c46a323",
31
"type": "github"
32
},
33
"original": {
···
85
"type": "github"
86
}
87
},
88
"root": {
89
"inputs": {
90
-
"crane": "crane",
91
"fenix": "fenix",
92
"flake-parts": "flake-parts",
93
"nixpkgs": "nixpkgs",
94
-
"src": "src"
95
}
96
},
97
"rust-analyzer-src": {
98
"flake": false,
99
"locked": {
100
-
"lastModified": 1760090851,
101
-
"narHash": "sha256-XGkBjf4Dzg6tXd0KGgKzeW4oVX/iLzLhD3rQ1cATpqM=",
102
"owner": "rust-lang",
103
"repo": "rust-analyzer",
104
-
"rev": "b93180b4f2cb3c81ac7f17f46e3dfcb30ecc7843",
105
"type": "github"
106
},
107
"original": {
···
110
"repo": "rust-analyzer",
111
"type": "github"
112
}
113
-
},
114
-
"src": {
115
-
"flake": false,
116
-
"locked": {
117
-
"dirtyRev": "6b876cbb804222723fecf81b60e0fa25ca677bf9-dirty",
118
-
"dirtyShortRev": "6b876cbb-dirty",
119
-
"lastModified": 1760200962,
120
-
"narHash": "sha256-pIC0DTMgB3eQIteVqJ65cHyqhvLyl336qqtKBKhh71w=",
121
-
"submodules": true,
122
-
"type": "git",
123
-
"url": "file:.?submodules=1"
124
-
},
125
-
"original": {
126
-
"submodules": true,
127
-
"type": "git",
128
-
"url": "file:.?submodules=1"
129
-
}
130
}
131
},
132
"root": "root",
···
1
{
2
"nodes": {
3
+
"dlmalloc": {
4
+
"flake": false,
5
"locked": {
6
+
"lastModified": 1742946635,
7
+
"narHash": "sha256-yD3T9/5Ttv22SXBsEsVSW9Ww7KZ/uZNtauyacP5Od0c=",
8
+
"ref": "refs/heads/main",
9
+
"rev": "e4ba8493497c72e15f2b9d428e1dea17e26bf188",
10
+
"revCount": 132,
11
+
"type": "git",
12
+
"url": "https://gitlab.redox-os.org/redox-os/dlmalloc-rs.git"
13
},
14
"original": {
15
+
"type": "git",
16
+
"url": "https://gitlab.redox-os.org/redox-os/dlmalloc-rs.git"
17
}
18
},
19
"fenix": {
···
24
"rust-analyzer-src": "rust-analyzer-src"
25
},
26
"locked": {
27
+
"lastModified": 1760337631,
28
+
"narHash": "sha256-3nvEN2lEpWtM1x7nfuiwpYHLNDgEUiWeBbyvy4vtVw8=",
29
"owner": "nix-community",
30
"repo": "fenix",
31
+
"rev": "fee7cf67cbd80a74460563388ac358b394014238",
32
"type": "github"
33
},
34
"original": {
···
86
"type": "github"
87
}
88
},
89
+
"openlibm": {
90
+
"flake": false,
91
+
"locked": {
92
+
"lastModified": 1757301398,
93
+
"narHash": "sha256-jQoqfKE6CeXg/Gjy8O7wtlDQzxORRUqU56AoquCG7Y0=",
94
+
"ref": "refs/heads/master",
95
+
"rev": "f5ed774593458e116e69731a3ffa59e2a6408d4e",
96
+
"revCount": 593,
97
+
"type": "git",
98
+
"url": "https://gitlab.redox-os.org/redox-os/openlibm.git"
99
+
},
100
+
"original": {
101
+
"type": "git",
102
+
"url": "https://gitlab.redox-os.org/redox-os/openlibm.git"
103
+
}
104
+
},
105
"root": {
106
"inputs": {
107
+
"dlmalloc": "dlmalloc",
108
"fenix": "fenix",
109
"flake-parts": "flake-parts",
110
"nixpkgs": "nixpkgs",
111
+
"openlibm": "openlibm"
112
}
113
},
114
"rust-analyzer-src": {
115
"flake": false,
116
"locked": {
117
+
"lastModified": 1760260966,
118
+
"narHash": "sha256-pOVvZz/aa+laeaUKyE6PtBevdo4rywMwjhWdSZE/O1c=",
119
"owner": "rust-lang",
120
"repo": "rust-analyzer",
121
+
"rev": "c5181dbbe33af6f21b9d83e02fdb6fda298a3b65",
122
"type": "github"
123
},
124
"original": {
···
127
"repo": "rust-analyzer",
128
"type": "github"
129
}
130
}
131
},
132
"root": "root",
+1
-1
src/header/_aio/mod.rs
+1
-1
src/header/_aio/mod.rs
+17
src/header/signal/mod.rs
+17
src/header/signal/mod.rs
···
37
pub const SI_QUEUE: c_int = -1;
38
pub const SI_USER: c_int = 0;
39
40
#[repr(C)]
41
#[derive(Clone, Debug)]
42
/// cbindgen:ignore
···
55
pub ss_size: size_t,
56
}
57
58
// FIXME: This struct is wrong on Linux
59
#[repr(C)]
60
#[derive(Clone, Copy)]
···
525
string.as_bytes().len(),
526
);
527
}
···
37
pub const SI_QUEUE: c_int = -1;
38
pub const SI_USER: c_int = 0;
39
40
+
pub const SIGEV_SIGNAL: c_int = 0;
41
+
pub const SIGEV_NONE: c_int = 1;
42
+
pub const SIGEV_THREAD: c_int = 2;
43
+
44
#[repr(C)]
45
#[derive(Clone, Debug)]
46
/// cbindgen:ignore
···
59
pub ss_size: size_t,
60
}
61
62
+
#[repr(C)]
63
+
#[derive(Clone)]
64
+
pub struct sigevent {
65
+
pub sigev_value: sigval,
66
+
pub sigev_signo: c_int,
67
+
pub sigev_notify: c_int,
68
+
pub sigev_notify_function: Option<extern "C" fn(sigval)>,
69
+
pub sigev_notify_attributes: *mut pthread_attr_t,
70
+
}
71
+
72
// FIXME: This struct is wrong on Linux
73
#[repr(C)]
74
#[derive(Clone, Copy)]
···
539
string.as_bytes().len(),
540
);
541
}
542
+
543
+
#[unsafe(no_mangle)]
544
+
pub unsafe extern "C" fn cbindgen_stupid_struct_sigevent_for_timer(a: sigevent) {}
+4
-1
src/header/time/cbindgen.toml
+4
-1
src/header/time/cbindgen.toml
+2
src/header/time/constants.rs
+2
src/header/time/constants.rs