extern "C" CDECL uintptr_t upcall_malloc(type_desc *td, uintptr_t size) { rust_task *task = rust_get_current_task(); s_malloc_args args = {task, 0, td, size}; UPCALL_SWITCH_STACK(task, &args, upcall_s_malloc); return args.retval; }
/** The exception handling personality function. It figures out what to do with each landing pad. Just a stack-switching wrapper around the C++ personality function. */ extern "C" _Unwind_Reason_Code upcall_rust_personality(int version, _Unwind_Action actions, uint64_t exception_class, _Unwind_Exception *ue_header, _Unwind_Context *context) { s_rust_personality_args args = {(_Unwind_Reason_Code)0, version, actions, exception_class, ue_header, context}; rust_task *task = rust_try_get_current_task(); if (task == NULL) { // Assuming we're running with the new scheduler upcall_s_rust_personality(&args); return args.retval; } // The personality function is run on the stack of the // last function that threw or landed, which is going // to sometimes be the C stack. If we're on the Rust stack // then switch to the C stack. if (task->on_rust_stack()) { UPCALL_SWITCH_STACK(task, &args, upcall_s_rust_personality); } else { upcall_s_rust_personality(&args); } return args.retval; }
extern "C" void upcall_cmp_type(int8_t *result, const type_desc *tydesc, const type_desc **subtydescs, uint8_t *data_0, uint8_t *data_1, uint8_t cmp_type) { s_cmp_type_args args = {result, tydesc, subtydescs, data_0, data_1, cmp_type}; UPCALL_SWITCH_STACK(&args, upcall_s_cmp_type); }
extern "C" CDECL rust_opaque_box* upcall_str_new_shared(const char *cstr, size_t len) { rust_task *task = rust_get_current_task(); s_str_new_shared_args args = { task, cstr, len, 0 }; UPCALL_SWITCH_STACK(task, &args, upcall_s_str_new_shared); return args.retval; }
extern "C" CDECL void upcall_fail(char const *expr, char const *file, size_t line) { s_fail_args args = {expr,file,line}; UPCALL_SWITCH_STACK(&args, upcall_s_fail); }
extern "C" void upcall_cmp_type(int8_t *result, const type_desc *tydesc, uint8_t *data_0, uint8_t *data_1, uint8_t cmp_type) { rust_task *task = rust_get_current_task(); s_cmp_type_args args = {result, tydesc, data_0, data_1, cmp_type}; UPCALL_SWITCH_STACK(task, &args, upcall_s_cmp_type); }
extern "C" CDECL void upcall_fail(char const *expr, char const *file, size_t line) { rust_task *task = rust_get_current_task(); s_fail_args args = {task,expr,file,line}; UPCALL_SWITCH_STACK(task, &args, upcall_s_fail); }
extern "C" CDECL void upcall_trace(char const *msg, char const *file, size_t line) { rust_task *task = rust_get_current_task(); s_trace_args args = {task,msg,file,line}; UPCALL_SWITCH_STACK(task, &args, upcall_s_trace); }
extern "C" CDECL type_desc * upcall_get_type_desc(void *curr_crate, // ignored, legacy compat. size_t size, size_t align, size_t n_descs, type_desc const **descs, uintptr_t n_obj_params) { s_get_type_desc_args args = {0,size,align,n_descs,descs,n_obj_params}; UPCALL_SWITCH_STACK(&args, upcall_s_get_type_desc); return args.retval; }
extern "C" CDECL void upcall_fail(char const *expr, char const *file, size_t line) { rust_task *task = rust_try_get_current_task(); if (task == NULL) { // FIXME #5161: Need to think about what to do here printf("failure outside of a task"); abort(); } s_fail_args args = {task,expr,file,line}; UPCALL_SWITCH_STACK(task, &args, upcall_s_fail); }
extern "C" CDECL void upcall_free(void* ptr) { rust_task *task = rust_get_current_task(); s_free_args args = {task,ptr}; UPCALL_SWITCH_STACK(task, &args, upcall_s_free); }
extern "C" CDECL void * upcall_dynastack_alloc(size_t sz) { s_dynastack_alloc_args args = {0, sz}; UPCALL_SWITCH_STACK(&args, upcall_s_dynastack_alloc); return args.retval; }
extern "C" void upcall_log_type(const type_desc *tydesc, uint8_t *data, uint32_t level) { rust_task *task = rust_get_current_task(); s_log_type_args args = {tydesc, data, level}; UPCALL_SWITCH_STACK(task, &args, upcall_s_log_type); }
extern "C" CDECL void * upcall_dynastack_alloc_2(size_t sz, type_desc *ty) { s_dynastack_alloc_2_args args = {0, sz, ty}; UPCALL_SWITCH_STACK(&args, upcall_s_dynastack_alloc_2); return args.retval; }
extern "C" CDECL void * upcall_new_stack(size_t stk_sz, void *args_addr, size_t args_sz) { s_new_stack_args args = {NULL, stk_sz, args_addr, args_sz}; UPCALL_SWITCH_STACK(&args, upcall_s_new_stack); return args.result; }
extern "C" void upcall_log_type(const type_desc *tydesc, uint8_t *data, uint32_t level) { s_log_type_args args = {tydesc, data, level}; UPCALL_SWITCH_STACK(&args, upcall_s_log_type); }
extern "C" CDECL void upcall_del_stack() { UPCALL_SWITCH_STACK(NULL, upcall_s_del_stack); }
extern "C" CDECL rust_vec* upcall_str_concat(rust_vec* lhs, rust_vec* rhs) { s_str_concat_args args = {lhs, rhs, 0}; UPCALL_SWITCH_STACK(&args, upcall_s_str_concat); return args.retval; }
extern "C" CDECL void * upcall_dynastack_mark() { s_dynastack_mark_args args = {0}; UPCALL_SWITCH_STACK(&args, upcall_s_dynastack_mark); return args.retval; }
extern "C" CDECL void upcall_shared_free(void* ptr) { s_shared_free_args args = {ptr}; UPCALL_SWITCH_STACK(&args, upcall_s_shared_free); }
extern "C" CDECL uintptr_t upcall_shared_malloc(size_t nbytes) { s_shared_malloc_args args = {0, nbytes}; UPCALL_SWITCH_STACK(&args, upcall_s_shared_malloc); return args.retval; }
extern "C" CDECL uintptr_t upcall_malloc(type_desc *td) { s_malloc_args args = {0, td}; UPCALL_SWITCH_STACK(&args, upcall_s_malloc); return args.retval; }
extern "C" CDECL void * upcall_shared_realloc(void *ptr, size_t size) { s_shared_realloc_args args = {NULL, ptr, size}; UPCALL_SWITCH_STACK(&args, upcall_s_shared_realloc); return args.retval; }
extern "C" CDECL void upcall_free_shared_type_desc(type_desc *td) { if (td) { UPCALL_SWITCH_STACK(td, upcall_s_free_shared_type_desc); } }
extern "C" CDECL void upcall_vec_grow(rust_vec** vp, size_t new_sz) { s_vec_grow_args args = {vp, new_sz}; UPCALL_SWITCH_STACK(&args, upcall_s_vec_grow); }
extern "C" CDECL type_desc * upcall_create_shared_type_desc(type_desc *td) { s_create_shared_type_desc_args args = { td, 0 }; UPCALL_SWITCH_STACK(&args, upcall_s_create_shared_type_desc); return args.res; }