History

Compiler Attributes: counted_by: Adjust name and identifier expansion

GCC and Clang's current RFCs name this attribute "counted_by", and have moved away from using a string for the member name. Update the kernel's macros to match. Additionally provide a UAPI no-op macro for UAPI structs that will gain annotations.

Kees Cook committed 3 years ago

Commit c8248fa1 parent be8dffa2 files · +17 −13Browse files

Unified · Split

2 files
  1. include/linux/compiler_attributes.h +13 −13
  2. include/uapi/linux/stddef.h +4 −0
include/linux/compiler_attributes.h+13−13
@@ -94,6 +94,19 @@ · 93 unmodified lines
9494 # define __copy(symbol)
9595 #endif
9696
97+/*
98+ * Optional: only supported since gcc >= 14
99+ * Optional: only supported since clang >= 18
100+ *
101+ * gcc: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108896
102+ * clang: https://reviews.llvm.org/D148381
103+ */
104+#if __has_attribute(__counted_by__)
105+# define __counted_by(member) __attribute__((__counted_by__(member)))
106+#else
107+# define __counted_by(member)
108+#endif
109+
97110 /*
98111 * Optional: not supported by gcc
99112 * Optional: only supported since clang >= 14.0
@@ -129,19 +142,6 @@ · 29 unmodified lines
129142 # define __designated_init
130143 #endif
131144
132−/*
133− * Optional: only supported since gcc >= 14
134− * Optional: only supported since clang >= 17
135− *
136− * gcc: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108896
137− * clang: https://reviews.llvm.org/D148381
138− */
139−#if __has_attribute(__element_count__)
140−# define __counted_by(member) __attribute__((__element_count__(#member)))
141−#else
142−# define __counted_by(member)
143−#endif
144−
145145 /*
146146 * Optional: only supported since clang >= 14.0
147147 *
include/uapi/linux/stddef.h+4−0
@@ -45,3 +45,7 @@ · 44 unmodified lines
4545 TYPE NAME[]; \
4646 }
4747 #endif
48+
49+#ifndef __counted_by
50+#define __counted_by(m)
51+#endif

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t