Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

compiler.h: unify __UNIQUE_ID

commit 6f33d58794ef ("__UNIQUE_ID()")
added a fallback definition of __UNIQUE_ID because gcc 4.2 and older did
not support __COUNTER__.

Also, this commit is effectively a revert of
commit b41c29b0527c ("Kbuild: provide a __UNIQUE_ID for clang")
which mentions clang 2.6+ supporting __COUNTER__.

Documentation/process/changes.rst currently lists the minimum supported
version of these compilers as:
- gcc: 5.1
- clang: 11.0.0
It should be safe to say that __COUNTER__ is well supported by this
point.

Link: https://lkml.kernel.org/r/20230831-unique_id-v1-1-28bacd18eb1d@google.com
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Cc: Michal rarek <mmarek@suse.com>
Cc: Nathan Chancellor <nathan@kernel.org>
Cc: Paul Russel <rusty@rustcorp.com.au>
Cc: Tom Rix <trix@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Nick Desaulniers and committed by
Andrew Morton
a8306f2d c0d2f4ce

+1 -11
-5
include/linux/compiler-clang.h
··· 14 14 #undef __cleanup 15 15 #define __cleanup(func) __maybe_unused __attribute__((__cleanup__(func))) 16 16 17 - /* same as gcc, this was present in clang-2.6 so we can assume it works 18 - * with any version that can compile the kernel 19 - */ 20 - #define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__) 21 - 22 17 /* all clang versions usable with the kernel support KASAN ABI version 5 */ 23 18 #define KASAN_ABI_VERSION 5 24 19
-2
include/linux/compiler-gcc.h
··· 39 39 #define __noretpoline __attribute__((__indirect_branch__("keep"))) 40 40 #endif 41 41 42 - #define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__) 43 - 44 42 #if defined(LATENT_ENTROPY_PLUGIN) && !defined(__CHECKER__) 45 43 #define __latent_entropy __attribute__((latent_entropy)) 46 44 #endif
+1 -4
include/linux/compiler.h
··· 177 177 __asm__ ("" : "=r" (var) : "0" (var)) 178 178 #endif 179 179 180 - /* Not-quite-unique ID. */ 181 - #ifndef __UNIQUE_ID 182 - # define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __LINE__) 183 - #endif 180 + #define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__) 184 181 185 182 /** 186 183 * data_race - mark an expression as containing intentional data races