Skip to content

Commit

Permalink
compiler.h: unify __UNIQUE_ID
Browse files Browse the repository at this point in the history
commit 6f33d58 ("__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 b41c29b ("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/[email protected]
Signed-off-by: Nick Desaulniers <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: Jan Beulich <[email protected]>
Cc: Luc Van Oostenryck <[email protected]>
Cc: Michal rarek <[email protected]>
Cc: Nathan Chancellor <[email protected]>
Cc: Paul Russel <[email protected]>
Cc: Tom Rix <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
  • Loading branch information
nickdesaulniers authored and akpm00 committed Oct 4, 2023
1 parent c0d2f4c commit a8306f2
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 11 deletions.
5 changes: 0 additions & 5 deletions include/linux/compiler-clang.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@
#undef __cleanup
#define __cleanup(func) __maybe_unused __attribute__((__cleanup__(func)))

/* same as gcc, this was present in clang-2.6 so we can assume it works
* with any version that can compile the kernel
*/
#define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)

/* all clang versions usable with the kernel support KASAN ABI version 5 */
#define KASAN_ABI_VERSION 5

Expand Down
2 changes: 0 additions & 2 deletions include/linux/compiler-gcc.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@
#define __noretpoline __attribute__((__indirect_branch__("keep")))
#endif

#define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)

#if defined(LATENT_ENTROPY_PLUGIN) && !defined(__CHECKER__)
#define __latent_entropy __attribute__((latent_entropy))
#endif
Expand Down
5 changes: 1 addition & 4 deletions include/linux/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,7 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val,
__asm__ ("" : "=r" (var) : "0" (var))
#endif

/* Not-quite-unique ID. */
#ifndef __UNIQUE_ID
# define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __LINE__)
#endif
#define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)

/**
* data_race - mark an expression as containing intentional data races
Expand Down

0 comments on commit a8306f2

Please sign in to comment.