aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWeston Carvalho <westoncarvalho@google.com>2024-03-28 21:36:37 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2024-03-28 21:36:37 +0000
commitdc96b1010e04b4a70f85ce7529b8eb3e765cd5fb (patch)
treeaa7355d58f7d913495a3a61e6caf72c6929825e3
parent8817138a2e18b0a7bf94b78f4b598bb3b75234e0 (diff)
parent3253aeadfe144014f84a4099d33d2a2710563b0a (diff)
downloadlibc-dc96b1010e04b4a70f85ce7529b8eb3e765cd5fb.tar.gz
Merge "Add time functions to libc for trusty" into main
-rw-r--r--patches/trusty.patch15
-rw-r--r--src/trusty.rs9
2 files changed, 21 insertions, 3 deletions
diff --git a/patches/trusty.patch b/patches/trusty.patch
index 1599f06e..d1591ea9 100644
--- a/patches/trusty.patch
+++ b/patches/trusty.patch
@@ -1,5 +1,5 @@
diff --git b/src/lib.rs a/src/lib.rs
-index 62748d279..4d8822ec2 100644
+index dd9b9df1..a0a0372d 100644
--- b/src/lib.rs
+++ a/src/lib.rs
@@ -145,6 +145,12 @@ cfg_if! {
@@ -17,10 +17,10 @@ index 62748d279..4d8822ec2 100644
pub use fixed_width_ints::*;
diff --git b/src/trusty.rs a/src/trusty.rs
new file mode 100644
-index 000000000..140fa6dfe
+index 00000000..7f1c6399
--- /dev/null
+++ a/src/trusty.rs
-@@ -0,0 +1,89 @@
+@@ -0,0 +1,98 @@
+#[cfg(feature = "trusty_sys")]
+extern crate trusty_sys;
+
@@ -74,6 +74,13 @@ index 000000000..140fa6dfe
+
+pub type time_t = c_long;
+
++pub type clockid_t = c_int;
++pub const CLOCK_REALTIME: clockid_t = 0;
++pub struct timespec {
++ pub tv_sec: time_t,
++ pub tv_nsec: c_long,
++}
++
+pub const STDOUT_FILENO: ::c_int = 1;
+pub const STDERR_FILENO: ::c_int = 2;
+
@@ -102,6 +109,8 @@ index 000000000..140fa6dfe
+ offset: off_t,
+ ) -> *mut ::c_void;
+ pub fn munmap(addr: *mut ::c_void, len: ::size_t) -> ::c_int;
++ pub fn clock_gettime(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int;
++ pub fn nanosleep(rqtp: *const ::timespec, rmtp: *mut ::timespec) -> ::c_int;
+}
+
+s! {
diff --git a/src/trusty.rs b/src/trusty.rs
index c8d297d2..fcb5894a 100644
--- a/src/trusty.rs
+++ b/src/trusty.rs
@@ -51,6 +51,13 @@ pub type c_int64_t = i64;
pub type time_t = c_long;
+pub type clockid_t = c_int;
+pub const CLOCK_REALTIME: clockid_t = 0;
+pub struct timespec {
+ pub tv_sec: time_t,
+ pub tv_nsec: c_long,
+}
+
pub const STDOUT_FILENO: ::c_int = 1;
pub const STDERR_FILENO: ::c_int = 2;
@@ -79,6 +86,8 @@ extern "C" {
offset: off_t,
) -> *mut ::c_void;
pub fn munmap(addr: *mut ::c_void, len: ::size_t) -> ::c_int;
+ pub fn clock_gettime(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int;
+ pub fn nanosleep(rqtp: *const ::timespec, rmtp: *mut ::timespec) -> ::c_int;
}
s! {