File tree 9 files changed +28
-24
lines changed
oak_enclave_runtime_support
oak_restricted_kernel_sdk
oak_restricted_kernel_sdk_proc_macro/src
9 files changed +28
-24
lines changed Original file line number Diff line number Diff line change @@ -103,7 +103,7 @@ oak_containers_sdk = { path = "./oak_containers_sdk" }
103
103
oak_core = { path = " ./oak_core" }
104
104
oak_crypto = { path = " ./oak_crypto" }
105
105
oak_dice = { path = " ./oak_dice" }
106
- oak_enclave_runtime_support = { path = " ./oak_enclave_runtime_support" }
106
+ oak_enclave_runtime_support = { path = " ./oak_enclave_runtime_support" , default-features = false }
107
107
oak_functions_abi = { path = " ./oak_functions_abi" }
108
108
oak_functions_client = { path = " ./oak_functions_client" }
109
109
oak_functions_launcher = { path = " ./oak_functions_launcher" }
Original file line number Diff line number Diff line change @@ -5,6 +5,10 @@ authors = ["Andri Saar <andrisaar@google.com>"]
5
5
edition = " 2021"
6
6
license = " Apache-2.0"
7
7
8
+ [features ]
9
+ default = [" global_allocator" ]
10
+ global_allocator = []
11
+
8
12
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
9
13
[dependencies ]
10
14
libm = " *"
Original file line number Diff line number Diff line change 6
6
7
7
Runtime support library for applications built for Oak Restricted Kernel.
8
8
9
- For now, the runtime support library only sets up the global heap allocator.
9
+ For now, the runtime support library provides a global heap allocator.
Original file line number Diff line number Diff line change @@ -79,14 +79,18 @@ impl GrowableHeap {
79
79
}
80
80
}
81
81
82
- pub unsafe fn init ( & mut self ) { }
83
-
82
+ #[ allow( clippy:: result_unit_err) ]
84
83
pub fn allocate ( & mut self , layout : Layout ) -> Result < NonNull < u8 > , ( ) > {
85
84
self . heap
86
85
. allocate ( layout)
87
86
. ok_or_else ( || log:: error!( "failed to allocate memory with layout: {:?}" , layout) )
88
87
}
89
88
89
+ /// # Safety
90
+ ///
91
+ /// - `ptr` must denote a memory block previously allocated via `self`.
92
+ /// - The memory block must have been allocated with the same alignment ([`Layout::align`]) as
93
+ /// `align`.
90
94
pub unsafe fn deallocate ( & mut self , ptr : NonNull < u8 > , align : usize ) {
91
95
self . heap . deallocate ( ptr, align)
92
96
}
Original file line number Diff line number Diff line change 18
18
19
19
use heap:: LockedGrowableHeap ;
20
20
21
- mod heap;
21
+ pub mod heap;
22
22
mod libm;
23
23
24
- #[ cfg_attr( not( test) , global_allocator) ]
24
+ #[ cfg( feature = "global_allocator" ) ]
25
+ #[ global_allocator]
25
26
static ALLOCATOR : LockedGrowableHeap = LockedGrowableHeap :: empty ( ) ;
26
27
27
- pub fn init ( ) {
28
- unsafe {
29
- ALLOCATOR . lock ( ) . init ( ) ;
30
- }
31
- }
28
+ #[ deprecated( note = "please make use of `oak_restricted_kernel_sdk::entrypoint` instead." ) ]
29
+ pub fn init ( ) { }
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ oak_crypto = { workspace = true }
17
17
oak_core = { workspace = true }
18
18
oak_dice = { workspace = true }
19
19
oak_restricted_kernel_interface = { workspace = true }
20
- oak_enclave_runtime_support = { workspace = true }
20
+ oak_enclave_runtime_support = { default-features = false , workspace = true }
21
21
oak_restricted_kernel_sdk_proc_macro = { workspace = true }
22
22
oak_restricted_kernel_dice = { workspace = true , optional = true }
23
23
oak_stage0_dice = { workspace = true , optional = true }
Original file line number Diff line number Diff line change @@ -22,20 +22,16 @@ mod channel;
22
22
mod dice;
23
23
mod logging;
24
24
25
+ pub mod utils {
26
+ pub use oak_core:: * ;
27
+ pub use oak_enclave_runtime_support:: heap;
28
+ }
29
+
25
30
pub use channel:: * ;
26
31
pub use dice:: * ;
27
32
pub use logging:: StderrLogger ;
28
- use logging:: STDERR_LOGGER ;
29
- pub use oak_core as utils;
30
33
pub use oak_restricted_kernel_sdk_proc_macro:: entrypoint;
31
34
32
- /// Initialization function that sets up the allocator and logger.
33
- pub fn init ( log_level : log:: LevelFilter ) {
34
- log:: set_logger ( & STDERR_LOGGER ) . expect ( "failed to set logger" ) ;
35
- log:: set_max_level ( log_level) ;
36
- oak_enclave_runtime_support:: init ( ) ;
37
- }
38
-
39
35
pub fn alloc_error_handler ( layout : :: core:: alloc:: Layout ) -> ! {
40
36
panic ! ( "error allocating memory: {:#?}" , layout) ;
41
37
}
Original file line number Diff line number Diff line change @@ -18,8 +18,6 @@ use core::fmt::Write;
18
18
19
19
use oak_restricted_kernel_interface:: syscall:: { fsync, write} ;
20
20
21
- pub static STDERR_LOGGER : StderrLogger = StderrLogger { } ;
22
-
23
21
struct Stderr { }
24
22
25
23
impl Stderr {
Original file line number Diff line number Diff line change @@ -62,11 +62,15 @@ fn process_entry_fn(entry_fn: ItemFn) -> TokenStream {
62
62
let generated = quote ! {
63
63
#entry_fn
64
64
65
+ #[ global_allocator]
66
+ static ALLOCATOR : oak_restricted_kernel_sdk:: utils:: heap:: LockedGrowableHeap = oak_restricted_kernel_sdk:: utils:: heap:: LockedGrowableHeap :: empty( ) ;
67
+
65
68
static LOGGER : oak_restricted_kernel_sdk:: StderrLogger = oak_restricted_kernel_sdk:: StderrLogger { } ;
66
69
67
70
#[ no_mangle]
68
71
fn _start( ) -> ! {
69
- oak_restricted_kernel_sdk:: init( log:: LevelFilter :: Debug ) ;
72
+ log:: set_logger( & LOGGER ) . expect( "failed to set logger" ) ;
73
+ log:: set_max_level( log:: LevelFilter :: Debug ) ;
70
74
log:: info!( "In main!" ) ;
71
75
#entry_fn_name( ) ;
72
76
}
You can’t perform that action at this time.
0 commit comments