linux/scripts/atomic
Mark Rutland 630399469f locking/atomic: scripts: simplify raw_atomic_long*() definitions
Currently, atomic-long is split into two sections, one defining the
raw_atomic_long_*() ops for CONFIG_64BIT, and one defining the raw
atomic_long_*() ops for !CONFIG_64BIT.

With many lines elided, this looks like:

| #ifdef CONFIG_64BIT
| ...
| static __always_inline bool
| raw_atomic_long_try_cmpxchg(atomic_long_t *v, long *old, long new)
| {
|         return raw_atomic64_try_cmpxchg(v, (s64 *)old, new);
| }
| ...
| #else /* CONFIG_64BIT */
| ...
| static __always_inline bool
| raw_atomic_long_try_cmpxchg(atomic_long_t *v, long *old, long new)
| {
|         return raw_atomic_try_cmpxchg(v, (int *)old, new);
| }
| ...
| #endif

The two definitions are spread far apart in the file, and duplicate the
prototype, making it hard to have a legible set of kerneldoc comments.

Make this simpler by defining the C prototype once, and writing the two
definitions inline. For example, the above becomes:

| static __always_inline bool
| raw_atomic_long_try_cmpxchg(atomic_long_t *v, long *old, long new)
| {
| #ifdef CONFIG_64BIT
|         return raw_atomic64_try_cmpxchg(v, (s64 *)old, new);
| #else
|         return raw_atomic_try_cmpxchg(v, (int *)old, new);
| #endif
| }

As we now always have a single copy of the C prototype wrapping all the
potential definitions, we now have an obvious single location for kerneldoc
comments. As a bonus, both the script and the generated file are
somewhat shorter.

There should be no functional change as a result of this patch.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/r/20230605070124.3741859-23-mark.rutland@arm.com
2023-06-05 09:57:22 +02:00
..
fallbacks locking/atomic: scripts: restructure fallback ifdeffery 2023-06-05 09:57:21 +02:00
atomic-tbl.sh locking/atomics: Change 'fold' to 'grep' 2019-02-11 14:27:33 +01:00
atomics.tbl atomics: Provide atomic_add_negative() variants 2023-03-28 10:39:29 +02:00
gen-atomic-fallback.sh locking/atomic: scripts: restructure fallback ifdeffery 2023-06-05 09:57:21 +02:00
gen-atomic-instrumented.sh locking/atomic: scripts: add trivial raw_atomic*_<op>() 2023-06-05 09:57:19 +02:00
gen-atomic-long.sh locking/atomic: scripts: simplify raw_atomic_long*() definitions 2023-06-05 09:57:22 +02:00
gen-atomics.sh locking/atomic: scripts: restructure fallback ifdeffery 2023-06-05 09:57:21 +02:00