Annotation Interface CBitfield

@Retention(RUNTIME) @Target(METHOD) public @interface CBitfield
Denotes a method as a bitfield access of a C struct.

If the method has a non-void return type, it is a get-method of the field. Calls of the method are replaced with a memory read. The possible signatures are FieldType getFieldName([LocationIdentity locationIdentity]);

If the method has the return type void, it is a set-method of the field. Calls of the method are replaced with memory accesses. The possible signatures are void setFieldName(FieldType value, [LocationIdentity locationIdentity]); Most architectures do not provide write instructions on the bit-level. Therefore, the memory write of the new value is preceded by a memory read of the old value. This makes bitfield writes non-atomic.

The receiver is the pointer to the struct that is accessed, i.e., the base address of the memory access.

The FieldType must be a primitive integer type or a word type.

The optional parameter locationIdentity specifies the LocationIdentity to be used for the memory access. Two memory accesses with two different location identities are guaranteed to not alias. Note that UniqueLocationIdentity annotation, cannot be used on bitfields.

Multiple accessor methods, with different signatures according to the rules of allowed signatures, are allowed for a single field.

  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Specifies the field name inside the C struct.
  • Element Details

    • value

      String value
      Specifies the field name inside the C struct. If no name is provided, the method name is used as the field name. A possible "get" or "set" prefix of the method name is removed.