From a9cf40113a38e9c7f38df0bfd92f322ff5cb3914 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Fri, 23 May 2025 11:42:49 -0500 Subject: [PATCH] sparc/include/.../cpuimpl.h: Correct global file scope register use The register keyword was never more than a suggestion but in more recent versions of C and C++, it has been reduced to a reserved keyword with no semantics. GCC has a documented extension for global register variables. Add the __extension__ keyword to avoid warnings. See Issue #5250 for a more detailed discussion including a link to a discussion on the GCC mailing list. The use of g6 as a pointer to the per CPU information is documented in the SPARC chapter of the CPU Supplement Guide. Closes #5250. --- cpukit/score/cpu/sparc/include/rtems/score/cpuimpl.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cpukit/score/cpu/sparc/include/rtems/score/cpuimpl.h b/cpukit/score/cpu/sparc/include/rtems/score/cpuimpl.h index 3f933cb12b..7d693172ca 100644 --- a/cpukit/score/cpu/sparc/include/rtems/score/cpuimpl.h +++ b/cpukit/score/cpu/sparc/include/rtems/score/cpuimpl.h @@ -216,8 +216,16 @@ typedef struct { /** * @brief The pointer to the current per-CPU control is available via register * g6. + * + * @note Older C and C++ standards have made the register keyword a hint + * at block scope level. C17 defines register as a reserved keyword with + * no meaning. Using __extension__ allows the GNU behavior for global + * file scope. See RTEMS Issue 5250 + * (https://gitlab.rtems.org/rtems/rtos/rtems/-/issues/5250) for a detailed + * discussion. */ -register struct Per_CPU_Control *_SPARC_Per_CPU_current __asm__( "g6" ); +__extension__ register struct + Per_CPU_Control *_SPARC_Per_CPU_current __asm__( "g6" ); #define _CPU_Get_current_per_CPU_control() _SPARC_Per_CPU_current