1 #ifndef LUCET_SANDBOX_H 2 #define LUCET_SANDBOX_H 3 4 #include <stdint.h> 5 #include <stdlib.h> 6 7 #ifdef __cplusplus 8 extern "C" { 9 #endif 10 11 struct LucetSandboxInstance; 12 typedef struct LucetSandboxInstance LucetSandboxInstance; 13 14 enum LucetValueType { 15 LucetValueType_I32, 16 LucetValueType_I64, 17 LucetValueType_F32, 18 LucetValueType_F64, 19 LucetValueType_Void 20 }; 21 22 typedef struct { 23 enum LucetValueType val_type; 24 union { 25 uint32_t u32; 26 uint64_t u64; 27 float f32; 28 double f64; 29 }; 30 } LucetValue; 31 32 typedef struct { 33 enum LucetValueType ret; 34 uint32_t parameter_cnt; 35 LucetValueType *parameters; 36 } LucetFunctionSignature; 37 38 typedef struct { 39 uint64_t ty; 40 uint64_t rf; 41 } LucetFunctionTableElement; 42 43 typedef struct { 44 LucetFunctionTableElement *data; 45 size_t length; 46 } LucetFunctionTable; 47 48 void lucet_ensure_linked(); 49 LucetSandboxInstance *lucet_load_module(const char *lucet_module_path, 50 bool allow_stdio); 51 void lucet_drop_module(LucetSandboxInstance *inst); 52 53 void* lucet_lookup_function(LucetSandboxInstance *inst, 54 const char *fn_name); 55 void lucet_set_curr_instance(LucetSandboxInstance *inst); 56 void lucet_clear_curr_instance(LucetSandboxInstance *inst); 57 58 uintptr_t lucet_get_reserved_callback_slot_val(void *inst, 59 uint32_t slot_number); 60 LucetFunctionTable lucet_get_function_pointer_table(void *inst); 61 int32_t lucet_get_function_type_index(void *inst, LucetFunctionSignature csig); 62 63 void *lucet_get_heap_base(LucetSandboxInstance *inst); 64 size_t lucet_get_heap_size(LucetSandboxInstance *inst); 65 uint32_t lucet_get_export_function_id(void *inst, void *unsandboxed_ptr); 66 67 #ifdef __cplusplus 68 } 69 #endif 70 71 #endif