Alignment not supported?

정인배(Inbae Jeong) kukyakya@gmail.com
Sun Jan 1 00:00:00 GMT 2017


Sorry for being too short. It's JIT mailing list so I thought everyone
would expect it to be related to gccjit.

I'm writing a small JITed interpreter and trying to call an external C
function (actually it is an external "C" C++ function) of which one of
the parameters is a struct containing an aligned member variable.

To make a struct type with gccjit, it will be somewhat like this:

struct my_arg {
    int a;
    alignas(32) int b;
};

1: gcc_jit_type *int_type  = gcc_jit_context_get_type(ctxt, GCC_JIT_TYPE_INT)
2: gcc_jit_field *field_a    = gcc_jit_context_new_field(ctxt, NULL,
int_type, "a");
3: gcc_jit_field *field_b    = gcc_jit_context_new_field(ctxt, NULL,
int_type, "b"); // How do I specify the alignment?
4: gcc_jit_field *fields[2] = {field_a, field_b};
5: gcc_jit_struct *my_arg   = gcc_jit_context_new_struct_type(ctxt,
NULL, "my_arg", 2, fields);


Maybe the alignment should be specified in line 3 or a new int type
has to be made with alignment specification, if supported. However I
don't see anything about alignment in the gccjit manual.




2017-03-25 22:41 GMT+09:00 Florian Weimer <fw@deneb.enyo.de>:
> * 정인배:
>
>> I need to align a type for calling an external function.
>>
>> How do I set the alignment for a type like the struct below?
>>
>> struct my_arg {
>> int a;
>> alignas(32) int b;
>> };
>>
>> I don't see any option for giving the alignment requirement to b.
>
> This should work:
>
> struct my_arg {
>   int a;
>   int b __attribute__ ((aligned (32)));
> };



More information about the Jit mailing list