GitLab will be upgraded on June 2nd 2020 at 2.00 pm (AEDT) to 3.00 pm (AEDT) due to Critical Security Patch Availability. During the update, GitLab and Mattermost services will not be available. If you have any concerns with this, please talk to local Gitlab admin team.

Commit 4bd070a0 authored by John Zhang's avatar John Zhang

use ctypes to allocate memory and pass parameter

parent 8e883f6e
#include <stdint.h>
extern uint32_t test_fnc(uint32_t* pi32);
int entry() {
uint32_t i;
return test_fnc(&i);
}
......@@ -47,9 +47,9 @@ int main(int argc, char** argv) {
id_356 = bldr_26->gen_sym(bldr_26, "@i32");
bldr_26->new_type_int(bldr_26, id_356, 32);
id_357 = bldr_26->gen_sym(bldr_26, "@pi8");
bldr_26->new_type_uptr(bldr_26, id_357, 8);
bldr_26->new_type_uptr(bldr_26, id_357, id_355);
id_358 = bldr_26->gen_sym(bldr_26, "@pi32");
bldr_26->new_type_uptr(bldr_26, id_358, 32);
bldr_26->new_type_uptr(bldr_26, id_358, id_356);
id_359 = bldr_26->gen_sym(bldr_26, "@1_i8");
bldr_26->new_const_int(bldr_26, id_359, id_355, 1);
id_360 = bldr_26->gen_sym(bldr_26, "@0x8d_i8");
......@@ -95,7 +95,7 @@ int main(int argc, char** argv) {
bldr_26->new_bb(bldr_26, id_367, (MuID [1]){id_368}, (MuTypeNode [1]){id_358}, 1, MU_NO_ID, (MuInstNode [10]){id_374, id_375, id_376, id_377, id_378, id_379, id_380, id_381, id_382, id_383}, 10);
bldr_26->new_func_ver(bldr_26, id_366, id_365, (MuBBNode [1]){id_367}, 1);
bldr_26->load(bldr_26);
mu_26->compile_to_sharedlib(mu_26, "test_uptr_bytestore_load.dylib", (char**){&"entry_test_uptr_bytestore_load.c"}, 1);
mu_26->compile_to_sharedlib(mu_26, "test_uptr_bytestore_load.dylib", NULL, 0);
printf("%s\n", "test_uptr_bytestore_load.dylib");
return 0;
}
......@@ -3,5 +3,11 @@ import ctypes
def test_uptr_bytestore_load():
fn = get_fncptr("test_uptr_bytestore_load", "entry", restype=ctypes.c_uint32)
assert fn() == 0x8d9f9c1d
fn = get_fncptr("test_uptr_bytestore_load", "test_fnc",
argtypes=[ctypes.POINTER(ctypes.c_uint32)],
restype=ctypes.c_uint32)
# allocate memory through ctypes
ui32 = ctypes.c_uint32()
assert fn(ctypes.byref(ui32)) == 0x8d9f9c1d
assert ui32.value == 0x8d9f9c1d
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment