11 create_code (gcc_jit_context
*ctxt
, void *user_data
)
13 /* Let's try to inject the equivalent of:
17 return sizeof(int32_t);
21 gcc_jit_context_get_int_type (ctxt
, 4, 1);
22 gcc_jit_type
*int_type
=
23 gcc_jit_context_get_type (ctxt
, GCC_JIT_TYPE_INT
);
25 gcc_jit_function
*func
=
26 gcc_jit_context_new_function (ctxt
,
28 GCC_JIT_FUNCTION_EXPORTED
,
33 gcc_jit_block
*initial
=
34 gcc_jit_function_new_block (func
, "initial");
36 gcc_jit_block_end_with_return(initial
, NULL
,
37 gcc_jit_context_new_sizeof(ctxt
, int32
));
41 verify_code (gcc_jit_context
*ctxt
, gcc_jit_result
*result
)
43 typedef int (*my_sizeof_type
) ();
44 CHECK_NON_NULL (result
);
45 my_sizeof_type my_sizeof
=
46 (my_sizeof_type
)gcc_jit_result_get_code (result
, "my_sizeof");
47 CHECK_NON_NULL (my_sizeof
);
48 int val
= my_sizeof ();