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)
Tue, Oct 13, 7:52 PM
Unknown Object (File)
Sat, Oct 10, 9:51 PM
Unknown Object (File)
Wed, Oct 7, 3:00 AM
Unknown Object (File)
Tue, Oct 6, 6:22 PM
Unknown Object (File)
Fri, Oct 2, 9:02 PM
Unknown Object (File)
Sep 16 2026, 1:11 AM
Unknown Object (File)
Sep 11 2026, 9:03 PM
Unknown Object (File)
Sep 7 2026, 3:21 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.