We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5907a12 commit 1f92cc1Copy full SHA for 1f92cc1
1 file changed
libcc2rs/src/compat.rs
@@ -1,7 +1,12 @@
1
// Copyright (c) 2022-present INESC-ID.
2
// Distributed under the MIT license that can be found in the LICENSE file.
3
4
+use std::cell::RefCell;
5
use std::ffi::c_void;
6
+use std::rc::Rc;
7
+
8
+use crate::rc::Ptr;
9
+use crate::{AsPointer, Value};
10
11
unsafe extern "C" {
12
#[cfg(target_os = "linux")]
@@ -43,3 +48,11 @@ pub unsafe fn malloc_usable_size(ptr: *mut c_void) -> usize {
43
48
pub unsafe fn cpp2rust_errno() -> *mut i32 {
44
49
unsafe { platform_errno_location() }
45
50
}
51
52
+thread_local! {
53
+ static ERRNO: Value<i32> = Rc::new(RefCell::new(0));
54
+}
55
56
+pub fn cpp2rust_errno() -> Ptr<i32> {
57
+ ERRNO.with(AsPointer::as_pointer)
58
0 commit comments