Changeset View
Changeset View
Standalone View
Standalone View
sys/sys/cdefs.h
Show First 20 Lines • Show All 926 Lines • ▼ Show 20 Lines | |||||||||||||
#define __builtin_align_down(x, align) \ | #define __builtin_align_down(x, align) \ | ||||||||||||
((__typeof__(x))((x)&(~((align)-1)))) | ((__typeof__(x))((x)&(~((align)-1)))) | ||||||||||||
#endif | #endif | ||||||||||||
#define __align_up(x, y) __builtin_align_up(x, y) | #define __align_up(x, y) __builtin_align_up(x, y) | ||||||||||||
#define __align_down(x, y) __builtin_align_down(x, y) | #define __align_down(x, y) __builtin_align_down(x, y) | ||||||||||||
#define __is_aligned(x, y) __builtin_is_aligned(x, y) | #define __is_aligned(x, y) __builtin_is_aligned(x, y) | ||||||||||||
#ifdef _KERNEL | |||||||||||||
kib: The general intent with sys/cdefs.h is to provide common facilities to adjust to compiler… | |||||||||||||
mjgAuthorUnsubmitted Done Inline Actionsperhaps this should land in sys/types.h then? again under _KERNEL mjg: perhaps this should land in sys/types.h then? again under _KERNEL | |||||||||||||
mjgAuthorUnsubmitted Done Inline Actionspoint being, arguably it is a new type mjg: point being, arguably it is a new type | |||||||||||||
kibUnsubmitted Not Done Inline Actionssys/types.h indeed sound not bad, but I do not agree with the _KERNEL braces. The type name should be put into impl namespace, and be accessible to any consumer. Note that we have usermode that wants the struct vnode definition. kib: sys/types.h indeed sound not bad, but I do not agree with the _KERNEL braces. The type name… | |||||||||||||
/* | |||||||||||||
* TODO: figure out how to do checking at compilation time that consumers don't | |||||||||||||
* use mere 'enum' | |||||||||||||
arichardsonUnsubmitted Not Done Inline ActionsPlain "enum" appears to work fine with both. arichardson: Plain "enum" appears to work fine with both. | |||||||||||||
*/ | |||||||||||||
#if defined(__clang__) || (defined(__GNUC__) && __GNUC__ >= 13) | |||||||||||||
#define enum_uint8_decl(name) enum name : uint8_t | |||||||||||||
#define enum_uint8(name) enum name | |||||||||||||
#else | |||||||||||||
/* | |||||||||||||
* Note: there is no real size checking here, but the code below is uspposed to | |||||||||||||
kibUnsubmitted Not Done Inline Actions
kib: | |||||||||||||
* die off. | |||||||||||||
arichardsonUnsubmitted Not Done Inline Actions
arichardson: | |||||||||||||
*/ | |||||||||||||
#define enum_uint8_decl(name) enum __attribute__((packed)) name | |||||||||||||
#define enum_uint8(name) enum __attribute__((packed)) name | |||||||||||||
arichardsonUnsubmitted Not Done Inline ActionsI looks like this is unnecessary, GCC 9 only needs it on the enum def, uses will automatically be sized correctly: arichardson: I looks like this is unnecessary, GCC 9 only needs it on the enum def, uses will automatically… | |||||||||||||
#endif | |||||||||||||
#endif | |||||||||||||
#endif /* !_SYS_CDEFS_H_ */ | #endif /* !_SYS_CDEFS_H_ */ |
The general intent with sys/cdefs.h is to provide common facilities to adjust to compiler quirks, for any compilation environment. Also, you explicitly use types (uint8_t) provided by cdefs.h conumers, while sys/cdefs.h is supposed to be self-contained: it is the root of all header dependencies.
Put your hack into implementation namespace (prepend with two _) and find a better way to deal with type dependency.