Next: , Previous: , Up: The type section   [Contents][Index]


2.3.4 Integer types

Integral types are all represented as types of kind CTF_K_INTEGER. These types fill out ctt_size in the ctf_stype_t with the size in bytes of the integral type in question. They are always represented by ctf_stype_t, never ctf_type_t. Their variable-length data is one uint32_t in length: vlen in the info word should be disregarded and is always zero.

The variable-length data for integers has multiple items packed into it much like the info word does.

Bit offsetNameDescription
24–31EncodingThe desired display representation of this integer. You can extract this field with the CTF_INT_ENCODING macro. See below.
16–23OffsetThe offset of this integral type in bits from the start of its enclosing structure field, adjusted for endianness: see section Structs and unions. You can extract this field with the CTF_INT_OFFSET macro.
0–15Bit-widthThe width of this integral type in bits. You can extract this field with the CTF_INT_BITS macro.

If you choose, bitfields can be represented using the things above as a sort of integral type with the isroot bit flipped off and the offset and bits values set in the vlen word: you can populate it with the CTF_INT_DATA macro. (But it may be more convenient to represent them using slices of a full-width integer: see section Slices.)

Integers that are bitfields usually have a ctt_size rounded up to the nearest power of two in bytes, for natural alignment (e.g. a 17-bit integer would have a ctt_size of 4). However, not all types are naturally aligned on all architectures: packed structures may in theory use integral bitfields with different ctt_size, though this is rarely observed.

The encoding for integers is a bit-field comprised of the values below, which consumers can use to decide how to display values of this type:

OffsetNameDescription
0x01CTF_INT_SIGNEDIf set, this is a signed int: if false, unsigned.
0x02CTF_INT_CHARIf set, this is a char type. It is platform-dependent whether unadorned char is signed or not: the CTF_CHAR macro produces an integral type suitable for the definition of char on this platform.
0x04CTF_INT_BOOLIf set, this is a boolean type. (It is theoretically possible to turn this and CTF_INT_CHAR on at the same time, but it is not clear what this would mean.)
0x08CTF_INT_VARARGSIf set, this is a varargs-promoted value in a K&R function definition. This is not currently produced or consumed by anything that we know of: it is set aside for future use.

The GCC “Complex int” and fixed-point extensions are not yet supported: references to such types will be emitted as type 0.


Next: , Previous: , Up: The type section   [Contents][Index]