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.
This commit is contained in:
Joel Sherrill
2025-05-23 11:42:49 -05:00
committed by Chris Johns
parent 7ec18af86c
commit a9cf40113a

View File

@@ -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