Skip to content

Commit 2966fbc

Browse files
committed
Auto merge of #58043 - jethrogb:jb/sgx-usercallnrs, r=joshtriplett
Fix `std::os::fortanix_sgx::usercalls::raw::UsercallNrs` It was 0-indexed but should be 1-indexed. This PR just removes the duplicate code and re-exports the internal enum. Fixes fortanix/rust-sgx#88 r? @joshtriplett
2 parents ec7ecb3 + a90b23f commit 2966fbc

File tree

2 files changed

+10
-20
lines changed

2 files changed

+10
-20
lines changed

src/libstd/os/fortanix_sgx/mod.rs

+1-16
Original file line numberDiff line numberDiff line change
@@ -21,26 +21,11 @@ pub mod usercalls {
2121

2222
/// Lowest-level interfaces to usercalls and usercall ABI type definitions.
2323
pub mod raw {
24-
use sys::abi::usercalls::raw::invoke_with_usercalls;
25-
pub use sys::abi::usercalls::raw::do_usercall;
24+
pub use sys::abi::usercalls::raw::{do_usercall, Usercalls as UsercallNrs};
2625
pub use sys::abi::usercalls::raw::{accept_stream, alloc, async_queues, bind_stream, close,
2726
connect_stream, exit, flush, free, insecure_time,
2827
launch_thread, read, read_alloc, send, wait, write};
2928

30-
macro_rules! define_usercallnrs {
31-
($(fn $f:ident($($n:ident: $t:ty),*) $(-> $r:ty)*; )*) => {
32-
/// Usercall numbers as per the ABI.
33-
#[repr(C)]
34-
#[unstable(feature = "sgx_platform", issue = "56975")]
35-
#[derive(Copy, Clone, Hash, PartialEq, Eq, Debug)]
36-
#[allow(missing_docs)]
37-
pub enum UsercallNrs {
38-
$($f,)*
39-
}
40-
};
41-
}
42-
invoke_with_usercalls!(define_usercallnrs);
43-
4429
// fortanix-sgx-abi re-exports
4530
pub use sys::abi::usercalls::raw::{ByteBuffer, FifoDescriptor, Return, Usercall};
4631
pub use sys::abi::usercalls::raw::Error;

src/libstd/sys/sgx/abi/usercalls/raw.rs

+9-4
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,15 @@ trait ReturnValue {
4141
macro_rules! define_usercalls {
4242
// Using `$r:tt` because `$r:ty` doesn't match ! in `clobber_diverging`
4343
($(fn $f:ident($($n:ident: $t:ty),*) $(-> $r:tt)*; )*) => {
44-
#[repr(C)]
45-
#[allow(non_camel_case_types)]
46-
enum Usercalls {
47-
__enclave_usercalls_invalid,
44+
/// Usercall numbers as per the ABI.
45+
#[repr(u64)]
46+
#[unstable(feature = "sgx_platform", issue = "56975")]
47+
#[derive(Copy, Clone, Hash, PartialEq, Eq, Debug)]
48+
#[allow(missing_docs, non_camel_case_types)]
49+
#[non_exhaustive]
50+
pub enum Usercalls {
51+
#[doc(hidden)]
52+
__enclave_usercalls_invalid = 0,
4853
$($f,)*
4954
}
5055

0 commit comments

Comments
 (0)