|
xkbcommon 1.14.0-beta2
Reference library implementing the XKB specification for parsing keyboard descriptions and handling keyboard state
|
Data Structures | |
| struct | xkb_keymap_serialize_config |
| struct | xkb_keymap_serialize_result |
| struct | xkb_keymap_key_iterator_config |
| struct | xkb_event_components |
| struct | xkb_event_pointer_motion |
| struct | xkb_event_pointer_button |
| struct | xkb_events_config |
| struct | xkb_machine_builder_config |
| struct | xkb_machine_builder_a11y_update |
| struct | xkb_machine_builder_mods_remap_update |
| struct | xkb_machine_builder_shortcut_override_update |
| struct | xkb_state_components_update |
| struct | xkb_layout_policy_update |
| struct | xkb_state_update |
Explains how extensible structures maintain ABI compatibility across library releases.
To guarantee long-term backward and forward compatibility of the ABI, functions across this library accept extensible structures that share a common ABI contract.
Every extensible structure begins with a mandatory uint32_t size first field and must not contain any implicit padding: every alignment gap is filled explicitly with a reserved field, each sized for the platform with the strictest alignment requirements and verified via static_assert.
size specifies the byte size of the structure, as provided by the caller. It has a fixed-width type uint32_t so that its representation is independent of the platform’s native size_t width.
A structure’s reserved fields (reserved0, reserved1, …) either fill an alignment gap or pre-allocate space for a future field. They are numbered in declaration order; when one is later repurposed (see Compatibility guarantees), remaining reserved fields keep their names.
When initializing an extensible structure, callers must:
Example with omitted initializer
Example with memset()
When a function receives an extensible structure, it uses the caller- provided size to determine which fields are present, and validates any reserved field covered by that size:
The caller was built against an older header: caller’s size < library’s. Only the fields covered by size are read; the library never accesses memory past that boundary. Fields beyond it are treated as unset and fall back to their default behavior.
In the unlikely case that a missing field has no safe default for the requested operation, the call fails with XKB_ERROR_ABI_BACKWARD_COMPAT.
This contract holds as long as fields are only ever appended to an extensible structure: never removed, reordered, or resized. A reserved field may later be repurposed by renaming it and giving it a new ABI-compatible type, so that the structure’s layout is unchanged. Under these rules: