Skip to content

Commit 080f7af

Browse files
authored
Merge pull request #11 from AzureMarker/feature/sysconf
Implement sysconf to support std threads
2 parents ac27616 + 2a14bdd commit 080f7af

1 file changed

Lines changed: 15 additions & 6 deletions

File tree

src/lib.rs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ use core::convert::TryFrom;
44
use core::mem::MaybeUninit;
55
use core::ptr;
66

7-
extern crate libc;
8-
97
// avoid conflicting a real POSIX errno by using a value < 0
108
// should we define this in ctru-sys somewhere or something?
119
const ECTRU: libc::c_int = -1;
@@ -22,7 +20,7 @@ extern "C" {
2220
}
2321

2422
#[no_mangle]
25-
extern "C" fn posix_memalign(
23+
pub extern "C" fn posix_memalign(
2624
memptr: *mut *mut libc::c_void,
2725
align: libc::size_t,
2826
size: libc::size_t,
@@ -35,7 +33,7 @@ extern "C" fn posix_memalign(
3533
}
3634

3735
#[no_mangle]
38-
unsafe extern "C" fn realpath(
36+
pub unsafe extern "C" fn realpath(
3937
path: *const libc::c_char,
4038
mut resolved_path: *mut libc::c_char,
4139
) -> *mut libc::c_char {
@@ -51,7 +49,7 @@ unsafe extern "C" fn realpath(
5149
}
5250

5351
#[no_mangle]
54-
unsafe extern "C" fn clock_gettime(
52+
pub unsafe extern "C" fn clock_gettime(
5553
clock_id: libc::clockid_t,
5654
tp: *mut libc::timespec,
5755
) -> libc::c_int {
@@ -93,7 +91,7 @@ unsafe extern "C" fn clock_gettime(
9391
}
9492

9593
#[no_mangle]
96-
unsafe extern "C" fn getrandom(
94+
pub unsafe extern "C" fn getrandom(
9795
buf: *mut libc::c_void,
9896
mut buflen: libc::size_t,
9997
flags: libc::c_uint,
@@ -133,3 +131,14 @@ unsafe extern "C" fn getrandom(
133131
-1
134132
}
135133
}
134+
135+
#[no_mangle]
136+
pub extern "C" fn sysconf(name: libc::c_int) -> libc::c_long {
137+
match name {
138+
libc::_SC_PAGESIZE => 0x1000,
139+
_ => {
140+
unsafe { *__errno() = libc::EINVAL };
141+
-1
142+
}
143+
}
144+
}

0 commit comments

Comments
 (0)