mc_sgx_alloc/lib.rs
1// Copyright (c) 2022 The MobileCoin Foundation
2
3#![doc = include_str!("../README.md")]
4#![deny(missing_docs, missing_debug_implementations)]
5#![no_std]
6
7extern crate alloc;
8
9mod allocator;
10
11pub use crate::allocator::Allocator;
12
13/// Defines a global allocator for use in an SGX enclave.
14///
15/// This should only be used in one place in the enclave binary.
16///
17/// The macro takes one argument, the name of the static allocator object.
18///
19/// # Example
20///
21/// ```
22/// mc_sgx_alloc::allocator!(ALLOCATOR_NAME);
23/// ```
24#[macro_export]
25macro_rules! allocator {
26 ($name:ident) => {
27 #[global_allocator]
28 static $name: $crate::Allocator = $crate::Allocator;
29 };
30}