Page MenuHomeFreeBSD

stddef.h: centralize definition of offsetof()
ClosedPublic

Authored by brooks on Feb 16 2026, 1:49 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Mar 22, 4:36 AM
Unknown Object (File)
Sun, Mar 22, 4:36 AM
Unknown Object (File)
Fri, Mar 20, 7:28 PM
Unknown Object (File)
Wed, Mar 18, 3:42 AM
Unknown Object (File)
Fri, Mar 13, 3:32 PM
Unknown Object (File)
Fri, Mar 13, 3:32 PM
Unknown Object (File)
Wed, Mar 11, 11:24 AM
Unknown Object (File)
Wed, Mar 11, 9:55 AM
Subscribers

Details

Summary

Move to sys/_offsetof.h and use builtin_offsetof() instead of
offsetof to avoid reintroducing sys/cdefs.h polution in stddef.h.

This has the side effect of allowing sys/stddef.h to be included after
stddef.h which can happen in compatability headers.

Effort: CHERI upstreaming
Sponsored by: DARPA, AFRL

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 70749
Build 67632: arc lint + arc unit

Event Timeline

The change by itself is fine.

This is a related comment. sys/stddef.h definition for offsetof() uses offsetof() instead of builtin_offsetof(). Then, should we have e.g. sys/_offsetof.h with include guard, then this issue would be handled automatically?

This revision is now accepted and ready to land.Feb 16 2026, 2:32 PM
brooks retitled this revision from sys/stddef.h: guard offsetof definition to stddef.h: centralize definition of offsetof().Feb 18 2026, 2:39 PM
brooks edited the summary of this revision. (Show Details)
This revision now requires review to proceed.Feb 18 2026, 2:40 PM
This revision is now accepted and ready to land.Feb 18 2026, 2:58 PM
This revision was automatically updated to reflect the committed changes.