mirror of
https://github.com/Noratrieb/libuwuc.git
synced 2026-01-16 20:55:05 +01:00
make errno a static instead of TLS
This commit is contained in:
parent
00f78e9749
commit
7a16d84b25
15 changed files with 57 additions and 55 deletions
|
|
@ -1,18 +1,20 @@
|
|||
use core::{cell::UnsafeCell, ptr::addr_of};
|
||||
|
||||
#[thread_local]
|
||||
static ERRNO: UnsafeCell<i32> = UnsafeCell::new(0);
|
||||
use crate::utils::SyncUnsafeCell;
|
||||
|
||||
// Todo: This should be a thread local once we have threads.
|
||||
static ERRNO: SyncUnsafeCell<i32> = SyncUnsafeCell(UnsafeCell::new(0));
|
||||
|
||||
pub fn errno_location() -> *const i32 {
|
||||
addr_of!(ERRNO).cast()
|
||||
}
|
||||
|
||||
pub fn errno() -> i32 {
|
||||
unsafe { *ERRNO.get() }
|
||||
unsafe { *ERRNO.0.get() }
|
||||
}
|
||||
|
||||
pub fn set_errno(errno: i32) {
|
||||
unsafe { ERRNO.get().write(errno) }
|
||||
unsafe { ERRNO.0.get().write(errno) }
|
||||
}
|
||||
|
||||
pub const EPERM: i32 = 1; /* Operation not permitted */
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
|
||||
|
|
@ -13,7 +13,6 @@ pub unsafe extern "C" fn memcmp(s1: *const u8, s2: *const u8, size: usize) -> i3
|
|||
libuwuc::mem::memcmp(s1, s2, size)
|
||||
}
|
||||
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn bcmp(s1: *const u8, s2: *const u8, size: usize) -> i32 {
|
||||
libuwuc::mem::memcmp(s1, s2, size)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
//@ignore doens't initialize fs yet
|
||||
#include <errno.h>
|
||||
|
||||
int main(void) {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,8 @@ int main(int argc, char *argv[]) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
char *env2 = getenv("__some absolutely NONSENSE that no one would ever define please..");
|
||||
char *env2 = getenv(
|
||||
"__some absolutely NONSENSE that no one would ever define please..");
|
||||
if (env2) {
|
||||
return 1;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue