Page MenuHomeFreeBSD

stddef.h: centralize definition of offsetof()
ClosedPublic

Authored by brooks on Feb 16 2026, 1:49 PM.
Tags
None
Referenced Files
F163022656: D55307.diff
Sun, Jul 19, 7:24 AM
Unknown Object (File)
Wed, Jul 15, 7:08 AM
Unknown Object (File)
Wed, Jul 15, 7:08 AM
Unknown Object (File)
Tue, Jul 14, 5:02 PM
Unknown Object (File)
Tue, Jul 14, 3:46 PM
Unknown Object (File)
Sun, Jul 12, 5:45 AM
Unknown Object (File)
Mon, Jul 6, 8:15 AM
Unknown Object (File)
Sun, Jul 5, 10:06 PM
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 70696
Build 67579: 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.