Exploring GNU extensions in the Linux kernel | MaskRay

submited by
Style Pass
2024-05-13 06:30:08

The Linux kernel is written in C, but it also leverages extensions provided by GCC. In 2022, it moved from GCC/Clang -std=gnu89 to -std=gnu11. This article explores my notes on how these GNU extensions are utilized within the kernel.

Bytecode interpreters often leverage this extension. BPF, for instance, utilizes this extension. We can also see this extension in drm_exec_retry_on_contention for the Direct Rendering Manager.

When it comes to Position-Dependent Code (PDC), a switch statement with a default label marked as __builtin_unreachable can be just as efficient as using labels as values. However, for Position-Independent Code (PIC), absolute addresses offer a slight performance edge, although at the cost of requiring more dynamic relocations.

If the member declaration list does not contain any named members, either directly or via an anonymous structure or anonymous union, the behavior is undefined.

Leave a Comment