You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@teaclave.apache.org by rd...@apache.org on 2022/11/15 01:14:49 UTC

[incubator-teaclave-sgx-sdk] 02/03: Add epoll_create for sgx_libc

This is an automated email from the ASF dual-hosted git repository.

rduan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-teaclave-sgx-sdk.git

commit 5346c066d04da618056f116d859be62ad5163eb2
Author: volcano0dr <vo...@163.com>
AuthorDate: Sat Nov 5 17:54:27 2022 +0800

    Add epoll_create for sgx_libc
---
 sgx_libc/src/android/mod.rs        | 2 +-
 sgx_libc/src/linux/x86_64/mod.rs   | 4 +---
 sgx_libc/src/linux/x86_64/ocall.rs | 8 ++++++++
 3 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/sgx_libc/src/android/mod.rs b/sgx_libc/src/android/mod.rs
index 49d57470..010f4f33 100644
--- a/sgx_libc/src/android/mod.rs
+++ b/sgx_libc/src/android/mod.rs
@@ -22,4 +22,4 @@ cfg_if! {
     } else {
 
     }
-}
\ No newline at end of file
+}
diff --git a/sgx_libc/src/linux/x86_64/mod.rs b/sgx_libc/src/linux/x86_64/mod.rs
index 213c2064..104ebb87 100644
--- a/sgx_libc/src/linux/x86_64/mod.rs
+++ b/sgx_libc/src/linux/x86_64/mod.rs
@@ -1649,9 +1649,7 @@ pub unsafe fn CMSG_NXTHDR(mhdr: *const msghdr, cmsg: *const cmsghdr) -> *mut cms
     };
     let next = (cmsg as usize + CMSG_ALIGN((*cmsg).cmsg_len)) as *mut cmsghdr;
     let max = (*mhdr).msg_control as usize + (*mhdr).msg_controllen;
-    if (next.offset(1)) as usize > max
-        || next as usize + CMSG_ALIGN((*next).cmsg_len) > max
-    {
+    if (next.offset(1)) as usize > max || next as usize + CMSG_ALIGN((*next).cmsg_len) > max {
         ptr::null_mut::<cmsghdr>()
     } else {
         next as *mut cmsghdr
diff --git a/sgx_libc/src/linux/x86_64/ocall.rs b/sgx_libc/src/linux/x86_64/ocall.rs
index 422a5f82..b2da65dc 100644
--- a/sgx_libc/src/linux/x86_64/ocall.rs
+++ b/sgx_libc/src/linux/x86_64/ocall.rs
@@ -3599,6 +3599,14 @@ pub unsafe fn poll(fds: *mut pollfd, nfds: nfds_t, timeout: c_int) -> c_int {
     result
 }
 
+pub unsafe fn epoll_create(size: c_int) -> c_int {
+    if size <= 0 {
+        set_errno(EINVAL);
+        return -1;
+    }
+    epoll_create1(0)
+}
+
 pub unsafe fn epoll_create1(flags: c_int) -> c_int {
     let mut result: c_int = 0;
     let mut error: c_int = 0;


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@teaclave.apache.org
For additional commands, e-mail: commits-help@teaclave.apache.org