aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteven Ray <stevenray@google.com>2024-02-15 22:39:20 -0800
committerWeston Carvalho <westoncarvalho@google.com>2024-02-27 13:39:10 -0600
commit3253aeadfe144014f84a4099d33d2a2710563b0a (patch)
treeaa7355d58f7d913495a3a61e6caf72c6929825e3
parentb1fdf6dfac7e8b7ce7102f74b6df630b45d22700 (diff)
downloadlibc-3253aeadfe144014f84a4099d33d2a2710563b0a.tar.gz
Add time functions to libc for trusty
Test: build.py Change-Id: Ied89c4f28c80fc8dc8f9a04fb740b410046fddfb
-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! {