[PATCH] Remove register keyword from public header files

Sebastian Huber sebastian.huber at embedded-brains.de
Mon Apr 16 05:38:08 UTC 2018


The following code

  void f(void)
  {
    register int i;
  }

gives a warning with GCC and -std=c++17

  test.cc: In function ‘void f()’:
  test.cc:3:15: warning: ISO C++1z does not allow ‘register’ storage class
  specifier [-Wregister]
    register int i;
		       ^

and clang with -std=c++14

  test.cc:3:3: warning: 'register' storage class specifier is deprecated
  and incompatible with C++1z [-Wdeprecated-register]
    register int i;
    ^~~~~~~~~
  1 warning generated.

Remove the use of the register keyword at least in the public header
files for C++ compatibility.

Close #3397.
---
 cpukit/score/cpu/i386/include/rtems/score/cpu.h    |  4 +--
 cpukit/score/cpu/i386/include/rtems/score/i386.h   | 42 +++++++++++-----------
 .../cpu/i386/include/rtems/score/interrupts.h      |  2 +-
 cpukit/score/cpu/lm32/include/rtems/score/lm32.h   | 10 +++---
 cpukit/score/cpu/m68k/include/rtems/score/cpu.h    |  6 ++--
 cpukit/score/cpu/m68k/include/rtems/score/m68k.h   |  8 ++---
 cpukit/score/cpu/mips/include/rtems/score/mips.h   | 16 ++++-----
 cpukit/score/cpu/powerpc/include/rtems/score/cpu.h |  4 +--
 cpukit/score/cpu/riscv/include/rtems/score/cpu.h   |  2 +-
 cpukit/score/cpu/sh/include/rtems/score/sh.h       |  8 ++---
 cpukit/score/cpu/sparc/include/rtems/score/sparc.h |  2 +-
 11 files changed, 52 insertions(+), 52 deletions(-)

diff --git a/cpukit/score/cpu/i386/include/rtems/score/cpu.h b/cpukit/score/cpu/i386/include/rtems/score/cpu.h
index 777439c6e0..42958c00f0 100644
--- a/cpukit/score/cpu/i386/include/rtems/score/cpu.h
+++ b/cpukit/score/cpu/i386/include/rtems/score/cpu.h
@@ -522,8 +522,8 @@ extern void _CPU_Fatal_halt(uint32_t source, uint32_t error)
 
 #define _CPU_Bitfield_Find_first_bit( _value, _output ) \
   { \
-    register uint16_t __value_in_register = ( _value ); \
-    uint16_t          __output = 0; \
+    uint16_t __value_in_register = ( _value ); \
+    uint16_t __output = 0; \
     __asm__ volatile ( "bsfw    %0,%1 " \
                     : "=r" ( __value_in_register ), "=r" ( __output ) \
                     : "0"  ( __value_in_register ), "1"  ( __output ) \
diff --git a/cpukit/score/cpu/i386/include/rtems/score/i386.h b/cpukit/score/cpu/i386/include/rtems/score/i386.h
index 2555d13b8b..4b94e6feeb 100644
--- a/cpukit/score/cpu/i386/include/rtems/score/i386.h
+++ b/cpukit/score/cpu/i386/include/rtems/score/i386.h
@@ -136,7 +136,7 @@ static inline uint16_t i386_swap_u16(
  */
 static inline unsigned int i386_get_cr0(void)
 {
-  register unsigned int segment = 0;
+  unsigned int segment = 0;
 
   __asm__ volatile ( "movl %%cr0,%0" : "=r" (segment) : "0" (segment) );
 
@@ -150,7 +150,7 @@ static inline void i386_set_cr0(unsigned int segment)
 
 static inline unsigned int i386_get_cr2(void)
 {
-  register unsigned int segment = 0;
+  unsigned int segment = 0;
 
   __asm__ volatile ( "movl %%cr2,%0" : "=r" (segment) : "0" (segment) );
 
@@ -159,7 +159,7 @@ static inline unsigned int i386_get_cr2(void)
 
 static inline unsigned int i386_get_cr3(void)
 {
-  register unsigned int segment = 0;
+  unsigned int segment = 0;
 
   __asm__ volatile ( "movl %%cr3,%0" : "=r" (segment) : "0" (segment) );
 
@@ -243,7 +243,7 @@ int i386_Physical_to_real(
 
 static __inline__ unsigned short i386_get_cs(void)
 {
-  register unsigned short segment = 0;
+  unsigned short segment = 0;
 
   __asm__ volatile ( "movw %%cs,%0" : "=r" (segment) : "0" (segment) );
 
@@ -252,7 +252,7 @@ static __inline__ unsigned short i386_get_cs(void)
 
 static __inline__ unsigned short i386_get_ds(void)
 {
-  register unsigned short segment = 0;
+  unsigned short segment = 0;
 
   __asm__ volatile ( "movw %%ds,%0" : "=r" (segment) : "0" (segment) );
 
@@ -261,7 +261,7 @@ static __inline__ unsigned short i386_get_ds(void)
 
 static __inline__ unsigned short i386_get_es(void)
 {
-  register unsigned short segment = 0;
+  unsigned short segment = 0;
 
   __asm__ volatile ( "movw %%es,%0" : "=r" (segment) : "0" (segment) );
 
@@ -270,7 +270,7 @@ static __inline__ unsigned short i386_get_es(void)
 
 static __inline__ unsigned short i386_get_ss(void)
 {
-  register unsigned short segment = 0;
+  unsigned short segment = 0;
 
   __asm__ volatile ( "movw %%ss,%0" : "=r" (segment) : "0" (segment) );
 
@@ -279,7 +279,7 @@ static __inline__ unsigned short i386_get_ss(void)
 
 static __inline__ unsigned short i386_get_fs(void)
 {
-  register unsigned short segment = 0;
+  unsigned short segment = 0;
 
   __asm__ volatile ( "movw %%fs,%0" : "=r" (segment) : "0" (segment) );
 
@@ -288,7 +288,7 @@ static __inline__ unsigned short i386_get_fs(void)
 
 static __inline__ unsigned short i386_get_gs(void)
 {
-  register unsigned short segment = 0;
+  unsigned short segment = 0;
 
   __asm__ volatile ( "movw %%gs,%0" : "=r" (segment) : "0" (segment) );
 
@@ -300,29 +300,29 @@ static __inline__ unsigned short i386_get_gs(void)
  */
 
 #define i386_outport_byte( _port, _value ) \
-do { register unsigned short __port  = _port; \
-     register unsigned char  __value = _value; \
+do { unsigned short __port  = _port; \
+     unsigned char  __value = _value; \
      \
      __asm__ volatile ( "outb %0,%1" : : "a" (__value), "d" (__port) ); \
    } while (0)
 
 #define i386_outport_word( _port, _value ) \
-do { register unsigned short __port  = _port; \
-     register unsigned short __value = _value; \
+do { unsigned short __port  = _port; \
+     unsigned short __value = _value; \
      \
      __asm__ volatile ( "outw %0,%1" : : "a" (__value), "d" (__port) ); \
    } while (0)
 
 #define i386_outport_long( _port, _value ) \
-do { register unsigned short __port  = _port; \
-     register unsigned int  __value = _value; \
+do { unsigned short __port  = _port; \
+     unsigned int  __value = _value; \
      \
      __asm__ volatile ( "outl %0,%1" : : "a" (__value), "d" (__port) ); \
    } while (0)
 
 #define i386_inport_byte( _port, _value ) \
-do { register unsigned short __port  = _port; \
-     register unsigned char  __value = 0; \
+do { unsigned short __port  = _port; \
+     unsigned char  __value = 0; \
      \
      __asm__ volatile ( "inb %1,%0" : "=a" (__value) \
                                 : "d"  (__port) \
@@ -331,8 +331,8 @@ do { register unsigned short __port  = _port; \
    } while (0)
 
 #define i386_inport_word( _port, _value ) \
-do { register unsigned short __port  = _port; \
-     register unsigned short __value = 0; \
+do { unsigned short __port  = _port; \
+     unsigned short __value = 0; \
      \
      __asm__ volatile ( "inw %1,%0" : "=a" (__value) \
                                 : "d"  (__port) \
@@ -341,8 +341,8 @@ do { register unsigned short __port  = _port; \
    } while (0)
 
 #define i386_inport_long( _port, _value ) \
-do { register unsigned short __port  = _port; \
-     register unsigned int  __value = 0; \
+do { unsigned short __port  = _port; \
+     unsigned int  __value = 0; \
      \
      __asm__ volatile ( "inl %1,%0" : "=a" (__value) \
                                 : "d"  (__port) \
diff --git a/cpukit/score/cpu/i386/include/rtems/score/interrupts.h b/cpukit/score/cpu/i386/include/rtems/score/interrupts.h
index 6067254509..b682772617 100644
--- a/cpukit/score/cpu/i386/include/rtems/score/interrupts.h
+++ b/cpukit/score/cpu/i386/include/rtems/score/interrupts.h
@@ -62,7 +62,7 @@ typedef int  (*rtems_raw_irq_is_enabled)	(const struct __rtems_raw_irq_connect_d
 
 #define i386_get_interrupt_level( _level ) \
   do { \
-    register uint32_t   _eflags; \
+    uint32_t   _eflags; \
     \
     __asm__ volatile ( "pushf ; \
                     pop %0" \
diff --git a/cpukit/score/cpu/lm32/include/rtems/score/lm32.h b/cpukit/score/cpu/lm32/include/rtems/score/lm32.h
index e8fecdf2f6..70d8bab735 100644
--- a/cpukit/score/cpu/lm32/include/rtems/score/lm32.h
+++ b/cpukit/score/cpu/lm32/include/rtems/score/lm32.h
@@ -73,7 +73,7 @@ extern "C" {
   __asm__ volatile ("rcsr %0, ip":"=r"(_ip));
 
 #define lm32_disable_interrupts( _level ) \
-  do { register uint32_t ie; \
+  do { uint32_t ie; \
     __asm__ volatile ("rcsr %0,ie":"=r"(ie)); \
     (_level) = ie; \
     ie &= (~0x0001); \
@@ -84,28 +84,28 @@ extern "C" {
   __asm__ volatile ("wcsr ie,%0"::"r"(_level));
 
 #define lm32_flash_interrupts( _level ) \
-  do { register uint32_t ie; \
+  do { uint32_t ie; \
     __asm__ volatile ("wcsr ie,%0"::"r"(_level)); \
     ie = (_level) & (~0x0001); \
     __asm__ volatile ("wcsr ie,%0"::"r"(ie)); \
   } while (0)
 
 #define lm32_interrupt_unmask( _mask ) \
-  do { register uint32_t im; \
+  do { uint32_t im; \
     __asm__ volatile ("rcsr %0,im":"=r"(im)); \
     im |= _mask; \
     __asm__ volatile ("wcsr im,%0"::"r"(im)); \
   } while (0)
 
 #define lm32_interrupt_mask( _mask ) \
-  do { register uint32_t im; \
+  do { uint32_t im; \
     __asm__ volatile ("rcsr %0,im":"=r"(im)); \
     im &= ~(_mask); \
     __asm__ volatile ("wcsr im,%0"::"r"(im)); \
   } while (0)
 
 #define lm32_interrupt_ack( _mask ) \
-  do { register uint32_t ip = _mask; \
+  do { uint32_t ip = _mask; \
     __asm__ volatile ("wcsr ip,%0"::"r"(ip)); \
   } while (0)
 
diff --git a/cpukit/score/cpu/m68k/include/rtems/score/cpu.h b/cpukit/score/cpu/m68k/include/rtems/score/cpu.h
index fc6847f37e..9b140d0da3 100644
--- a/cpukit/score/cpu/m68k/include/rtems/score/cpu.h
+++ b/cpukit/score/cpu/m68k/include/rtems/score/cpu.h
@@ -501,7 +501,7 @@ extern const unsigned char _CPU_m68k_BFFFO_table[256];
 
 #define _CPU_Bitfield_Find_first_bit( _value, _output ) \
   { \
-    register int dumby; \
+    int dumby; \
     \
     __asm__ volatile ( \
        "   clr.l   %1\n"         \
@@ -521,7 +521,7 @@ extern const unsigned char _CPU_m68k_BFFFO_table[256];
 #elif ( M68K_HAS_EXTB_L == 1 )
 #define _CPU_Bitfield_Find_first_bit( _value, _output ) \
   { \
-    register int dumby; \
+    int dumby; \
     \
     __asm__ volatile ( "   move.w  %2,%1\n"        \
        "   lsr.w   #8,%1\n"        \
@@ -539,7 +539,7 @@ extern const unsigned char _CPU_m68k_BFFFO_table[256];
 #else
 #define _CPU_Bitfield_Find_first_bit( _value, _output ) \
   { \
-    register int dumby; \
+    int dumby; \
     \
     __asm__ volatile ( "   move.w  %2,%1\n"        \
        "   lsr.w   #8,%1\n"        \
diff --git a/cpukit/score/cpu/m68k/include/rtems/score/m68k.h b/cpukit/score/cpu/m68k/include/rtems/score/m68k.h
index 818578c078..f37d978ab9 100644
--- a/cpukit/score/cpu/m68k/include/rtems/score/m68k.h
+++ b/cpukit/score/cpu/m68k/include/rtems/score/m68k.h
@@ -334,7 +334,7 @@ extern "C" {
 
 #if ( defined(__mcoldfire__) )
 #define m68k_disable_interrupts( _level ) \
-   do { register uint32_t   _tmpsr = 0x0700; \
+   do { uint32_t   _tmpsr = 0x0700; \
         __asm__ volatile ( "move.w %%sr,%0\n\t" \
  		       "or.l   %0,%1\n\t" \
  		       "move.w %1,%%sr" \
@@ -354,7 +354,7 @@ extern "C" {
 
 #if ( defined(__mcoldfire__) )
 #define m68k_flash_interrupts( _level ) \
-   do { register uint32_t   _tmpsr = 0x0700; \
+   do { uint32_t   _tmpsr = 0x0700; \
 	asm volatile ( "move.w %2,%%sr\n\t" \
 		       "or.l   %2,%1\n\t" \
 		       "move.w %1,%%sr" \
@@ -371,7 +371,7 @@ extern "C" {
 
 #define m68k_get_interrupt_level( _level ) \
   do { \
-    register uint32_t   _tmpsr; \
+    uint32_t   _tmpsr; \
     \
     __asm__ volatile( "move.w %%sr,%0" : "=d" (_tmpsr)); \
     _level = (_tmpsr & 0x0700) >> 8; \
@@ -379,7 +379,7 @@ extern "C" {
 
 #define m68k_set_interrupt_level( _newlevel ) \
   do { \
-    register uint32_t   _tmpsr; \
+    uint32_t   _tmpsr; \
     \
     __asm__ volatile( "move.w  %%sr,%0" : "=d" (_tmpsr)); \
     _tmpsr = (_tmpsr & 0xf8ff) | ((_newlevel) << 8); \
diff --git a/cpukit/score/cpu/mips/include/rtems/score/mips.h b/cpukit/score/cpu/mips/include/rtems/score/mips.h
index 4c2c53fa6d..3b6115e9b6 100644
--- a/cpukit/score/cpu/mips/include/rtems/score/mips.h
+++ b/cpukit/score/cpu/mips/include/rtems/score/mips.h
@@ -136,7 +136,7 @@ extern "C" {
 
 #define mips_set_sr( _x ) \
   do { \
-    register unsigned int __x = (_x); \
+    unsigned int __x = (_x); \
     __asm__ volatile( "mtc0 %0, $12; nop" : : "r" (__x) ); \
   } while (0)
 
@@ -153,7 +153,7 @@ extern "C" {
 
 #define mips_set_cause( _x ) \
   do { \
-    register unsigned int __x = (_x); \
+    unsigned int __x = (_x); \
     __asm__ volatile( "mtc0 %0, $13; nop" : : "r" (__x) ); \
   } while (0)
 
@@ -172,7 +172,7 @@ extern "C" {
 
 #define mips_set_dcic( _x ) \
   do { \
-    register unsigned int __x = (_x); \
+    unsigned int __x = (_x); \
     __asm__ volatile( "mtc0 %0, $7; nop" : : "r" (__x) ); \
   } while (0)
 
@@ -193,8 +193,8 @@ extern "C" {
 
 #define mips_set_bpcrm( _x, _y ) \
   do { \
-    register unsigned int __x = (_x); \
-    register unsigned int __y = (_y); \
+    unsigned int __x = (_x); \
+    unsigned int __y = (_y); \
     __asm__ volatile( "mtc0 %0, $11; nop" : : "r" (__y) ); \
     __asm__ volatile( "mtc0 %0, $3; nop" : : "r" (__x) ); \
   } while (0)
@@ -218,8 +218,8 @@ extern "C" {
 
 #define mips_set_bdarm( _x, _y ) \
   do { \
-    register unsigned int __x = (_x); \
-    register unsigned int __y = (_y); \
+    unsigned int __x = (_x); \
+    unsigned int __y = (_y); \
     __asm__ volatile( "mtc0 %0, $9; nop" : : "r" (__y) ); \
     __asm__ volatile( "mtc0 %0, $5; nop" : : "r" (__x) ); \
   } while (0)
@@ -244,7 +244,7 @@ extern "C" {
 
 #define mips_set_fcr31( _x ) \
   do { \
-    register unsigned int __x = (_x); \
+    unsigned int __x = (_x); \
     __asm__ volatile( "ctc1 %0, $31; nop" : : "r" (__x) ); \
   } while(0)
 
diff --git a/cpukit/score/cpu/powerpc/include/rtems/score/cpu.h b/cpukit/score/cpu/powerpc/include/rtems/score/cpu.h
index 02560695bd..31e74aba95 100644
--- a/cpukit/score/cpu/powerpc/include/rtems/score/cpu.h
+++ b/cpukit/score/cpu/powerpc/include/rtems/score/cpu.h
@@ -661,7 +661,7 @@ RTEMS_INLINE_ROUTINE bool _CPU_ISR_Is_enabled( uint32_t level )
 
 static inline uint32_t   _CPU_ISR_Get_level( void )
 {
-  register unsigned int msr;
+  uint32_t msr;
   _CPU_MSR_GET(msr);
   if (msr & MSR_EE) return 0;
   else	return 1;
@@ -669,7 +669,7 @@ static inline uint32_t   _CPU_ISR_Get_level( void )
 
 static inline void _CPU_ISR_Set_level( uint32_t   level )
 {
-  register unsigned int msr;
+  uint32_t msr;
   _CPU_MSR_GET(msr);
   if (!(level & CPU_MODES_INTERRUPT_MASK)) {
     msr |= ppc_interrupt_get_disable_mask();
diff --git a/cpukit/score/cpu/riscv/include/rtems/score/cpu.h b/cpukit/score/cpu/riscv/include/rtems/score/cpu.h
index ada46ef9ee..6f286e0bd8 100644
--- a/cpukit/score/cpu/riscv/include/rtems/score/cpu.h
+++ b/cpukit/score/cpu/riscv/include/rtems/score/cpu.h
@@ -158,7 +158,7 @@ Context_Control_fp  _CPU_Null_fp_context;
 
 static inline unsigned long riscv_interrupt_disable( void )
 {
-  register unsigned long status = read_csr(mstatus);
+  unsigned long status = read_csr(mstatus);
   clear_csr(mstatus, MSTATUS_MIE);
   return status;
 }
diff --git a/cpukit/score/cpu/sh/include/rtems/score/sh.h b/cpukit/score/cpu/sh/include/rtems/score/sh.h
index 4e26478b8b..6ac5ef1382 100644
--- a/cpukit/score/cpu/sh/include/rtems/score/sh.h
+++ b/cpukit/score/cpu/sh/include/rtems/score/sh.h
@@ -170,7 +170,7 @@ extern "C" {
 
 #define sh_get_interrupt_level( _level ) \
 { \
-  register uint32_t   _tmpsr ; \
+  uint32_t   _tmpsr ; \
   \
   __asm__ volatile( "stc sr, %0" : "=r" (_tmpsr) ); \
   _level = (_tmpsr & 0xf0) >> 4 ; \
@@ -178,7 +178,7 @@ extern "C" {
 
 #define sh_set_interrupt_level( _newlevel ) \
 { \
-  register uint32_t   _tmpsr; \
+  uint32_t   _tmpsr; \
   \
   __asm__ volatile ( "stc sr, %0" : "=r" (_tmpsr) ); \
   _tmpsr = ( _tmpsr & ~0xf0 ) | ((_newlevel) << 4) ; \
@@ -194,7 +194,7 @@ static inline uint32_t sh_swap_u32(
   uint32_t value
 )
 {
-  register uint32_t swapped;
+  uint32_t swapped;
 
   __asm__ volatile (
     "swap.b %1,%0; "
@@ -210,7 +210,7 @@ static inline uint16_t sh_swap_u16(
   uint16_t value
 )
 {
-  register uint16_t swapped ;
+  uint16_t swapped ;
 
   __asm__ volatile ( "swap.b %1,%0" : "=r" (swapped) : "r"  (value) );
 
diff --git a/cpukit/score/cpu/sparc/include/rtems/score/sparc.h b/cpukit/score/cpu/sparc/include/rtems/score/sparc.h
index 47d8e6f0bd..4846520b46 100644
--- a/cpukit/score/cpu/sparc/include/rtems/score/sparc.h
+++ b/cpukit/score/cpu/sparc/include/rtems/score/sparc.h
@@ -390,7 +390,7 @@ void sparc_syscall_exit(uint32_t exitcode1, uint32_t exitcode2)
  */
 #define sparc_get_interrupt_level( _level ) \
   do { \
-    register uint32_t   _psr_level = 0; \
+    uint32_t _psr_level = 0; \
     \
     sparc_get_psr( _psr_level ); \
     (_level) = \
-- 
2.12.3



More information about the devel mailing list