Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Jnaerator, bridj] Problem with bit fields in C struct. #496

@mcolmant

Description

@mcolmant

Hello,

I have another problem with jnaerator and bridj. There is a snippet of one structure in the header file:

typedef struct perf_event_attr {
        ...
    uint64_t    disabled       :  1,
            inherit        :  1,
            pinned         :  1,
            ...
            exclude_callchain_kernel : 1,
            exclude_callchain_user   : 1,
            __reserved_1   : 41;
        ...
}

Jnaerator generates the corresponding binding for bridj in a java class:

@Field(6) 
@Bits(1) 
public long disabled() {
    return this.io.getLongField(this, 6);
}
@Field(6) 
@Bits(1) 
public perf_event_attr disabled(long disabled) {
    this.io.setLongField(this, 6, disabled);
    return this;
}
@Field(7) 
@Bits(1) 
public long inherit() {
    return this.io.getLongField(this, 7);
}
@Field(7) 
@Bits(1) 
public perf_event_attr inherit(long inherit) {
    this.io.setLongField(this, 7, inherit);
    return this;
}
...

The problem appeared when I want to set one of the field. Indeed, if I call one of the setter with a long, it erases also the others and so, I don't have the expected values.

Thanks for your help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions