diff --git a/sys/sys/cdefs.h b/sys/sys/cdefs.h index 64795f2a68c7..ab7d59d2546a 100644 --- a/sys/sys/cdefs.h +++ b/sys/sys/cdefs.h @@ -212,7 +212,6 @@ #define __unused #define __packed #define __aligned(x) -#define __arg_type_tag(arg_kind, arg_idx, type_tag_idx) #define __section(x) #define __weak #else @@ -237,12 +236,6 @@ #define __aligned(x) __attribute__((__aligned__(x))) #define __section(x) __attribute__((__section__(x))) #endif -#if __has_attribute(argument_with_type_tag) -#define __arg_type_tag(arg_kind, arg_idx, type_tag_idx) \ - __attribute__((__argument_with_type_tag__(arg_kind, arg_idx, type_tag_idx))) -#else -#define __arg_type_tag(arg_kind, arg_idx, type_tag_idx) -#endif #if defined(__INTEL_COMPILER) #define __dead2 __attribute__((__noreturn__)) #define __pure2 __attribute__((__const__)) @@ -775,6 +768,24 @@ #define __NO_TLS 1 #endif +/* + * Type Safety Checking + * + * Clang provides additional attributes to enable checking type safety + * properties that cannot be enforced by the C type system. + */ + +#if __has_attribute(argument_with_type_tag) && \ + __has_attribute(type_tag_for_datatype) && !defined(lint) +#define __arg_type_tag(arg_kind, arg_idx, type_tag_idx) \ + __attribute__((__argument_with_type_tag__(arg_kind, arg_idx, type_tag_idx))) +#define __datatype_type_tag(kind, type) \ + __attribute__((__type_tag_for_datatype__(kind, type))) +#else +#define __arg_type_tag(arg_kind, arg_idx, type_tag_idx) +#define __datatype_type_tag(kind, type) +#endif + /* * Lock annotations. *