[rtems commit] score: Fix C/C++ compatibility issue

Sebastian Huber sebh at rtems.org
Fri Sep 23 04:57:59 UTC 2016


Module:    rtems
Branch:    master
Commit:    9149c87ec724ed4e3f45762e771c12f81c3f5a33
Changeset: http://git.rtems.org/rtems/commit/?id=9149c87ec724ed4e3f45762e771c12f81c3f5a33

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Fri Sep 23 06:52:33 2016 +0200

score: Fix C/C++ compatibility issue

Only use CPU_Per_CPU_control if it contains at least one filed.  In GNU
C empty structures have a size of zero.  In C++ structures have a
non-zero size.  In case CPU_PER_CPU_CONTROL_SIZE is defined to zero,
then this structure is not used anymore.

---

 cpukit/score/cpu/arm/rtems/score/cpu.h      |  4 ----
 cpukit/score/cpu/bfin/rtems/score/cpu.h     |  4 ----
 cpukit/score/cpu/epiphany/rtems/score/cpu.h |  3 ---
 cpukit/score/cpu/i386/rtems/score/cpu.h     |  4 ----
 cpukit/score/cpu/lm32/rtems/score/cpu.h     |  4 ----
 cpukit/score/cpu/m32c/rtems/score/cpu.h     |  4 ----
 cpukit/score/cpu/m68k/rtems/score/cpu.h     |  4 ----
 cpukit/score/cpu/mips/rtems/score/cpu.h     |  4 ----
 cpukit/score/cpu/moxie/rtems/score/cpu.h    |  4 ----
 cpukit/score/cpu/nios2/rtems/score/cpu.h    |  4 ----
 cpukit/score/cpu/no_cpu/rtems/score/cpu.h   |  6 +++++-
 cpukit/score/cpu/or1k/rtems/score/cpu.h     |  3 ---
 cpukit/score/cpu/powerpc/rtems/score/cpu.h  |  4 ----
 cpukit/score/cpu/sh/rtems/score/cpu.h       |  4 ----
 cpukit/score/cpu/sparc64/rtems/score/cpu.h  |  4 ----
 cpukit/score/cpu/v850/rtems/score/cpu.h     |  4 ----
 cpukit/score/include/rtems/score/percpu.h   | 10 ++++++----
 cpukit/score/src/percpuasm.c                | 10 ++++++----
 18 files changed, 17 insertions(+), 67 deletions(-)

diff --git a/cpukit/score/cpu/arm/rtems/score/cpu.h b/cpukit/score/cpu/arm/rtems/score/cpu.h
index adaf809..9fe28c4 100644
--- a/cpukit/score/cpu/arm/rtems/score/cpu.h
+++ b/cpukit/score/cpu/arm/rtems/score/cpu.h
@@ -246,10 +246,6 @@ extern "C" {
 /**@{**/
 
 typedef struct {
-  /* There is no CPU specific per-CPU state */
-} CPU_Per_CPU_control;
-
-typedef struct {
 #if defined(ARM_MULTILIB_ARCH_V4)
   uint32_t register_cpsr;
   uint32_t register_r4;
diff --git a/cpukit/score/cpu/bfin/rtems/score/cpu.h b/cpukit/score/cpu/bfin/rtems/score/cpu.h
index 19b1f03..1437277 100644
--- a/cpukit/score/cpu/bfin/rtems/score/cpu.h
+++ b/cpukit/score/cpu/bfin/rtems/score/cpu.h
@@ -368,10 +368,6 @@ extern "C" {
 
 #ifndef ASM
 
-typedef struct {
-  /* There is no CPU specific per-CPU state */
-} CPU_Per_CPU_control;
-
 /**
  * @defgroup CPUContext Processor Dependent Context Management
  *
diff --git a/cpukit/score/cpu/epiphany/rtems/score/cpu.h b/cpukit/score/cpu/epiphany/rtems/score/cpu.h
index 9a6428a..2954628 100644
--- a/cpukit/score/cpu/epiphany/rtems/score/cpu.h
+++ b/cpukit/score/cpu/epiphany/rtems/score/cpu.h
@@ -680,9 +680,6 @@ void _CPU_Context_Initialize(
 
 #define CPU_USE_GENERIC_BITFIELD_CODE TRUE
 
-typedef struct {
-/* There is no CPU specific per-CPU state */
-} CPU_Per_CPU_control;
 #endif /* ASM */
 
 /**
diff --git a/cpukit/score/cpu/i386/rtems/score/cpu.h b/cpukit/score/cpu/i386/rtems/score/cpu.h
index 6cfeee6..8fc62ca 100644
--- a/cpukit/score/cpu/i386/rtems/score/cpu.h
+++ b/cpukit/score/cpu/i386/rtems/score/cpu.h
@@ -141,10 +141,6 @@ extern "C" {
 
 #ifndef ASM
 
-typedef struct {
-  /* There is no CPU specific per-CPU state */
-} CPU_Per_CPU_control;
-
 /*
  *  Basic integer context for the i386 family.
  */
diff --git a/cpukit/score/cpu/lm32/rtems/score/cpu.h b/cpukit/score/cpu/lm32/rtems/score/cpu.h
index fe948ae..24e5625 100644
--- a/cpukit/score/cpu/lm32/rtems/score/cpu.h
+++ b/cpukit/score/cpu/lm32/rtems/score/cpu.h
@@ -360,10 +360,6 @@ extern "C" {
 
 /* may need to put some structures here.  */
 
-typedef struct {
-  /* There is no CPU specific per-CPU state */
-} CPU_Per_CPU_control;
-
 /**
  * @defgroup CPUContext Processor Dependent Context Management
  *
diff --git a/cpukit/score/cpu/m32c/rtems/score/cpu.h b/cpukit/score/cpu/m32c/rtems/score/cpu.h
index f56e9d7..8a29446 100644
--- a/cpukit/score/cpu/m32c/rtems/score/cpu.h
+++ b/cpukit/score/cpu/m32c/rtems/score/cpu.h
@@ -383,10 +383,6 @@ extern "C" {
 
 /* may need to put some structures here.  */
 
-typedef struct {
-  /* There is no CPU specific per-CPU state */
-} CPU_Per_CPU_control;
-
 /**
  * @defgroup CPUContext Processor Dependent Context Management
  *
diff --git a/cpukit/score/cpu/m68k/rtems/score/cpu.h b/cpukit/score/cpu/m68k/rtems/score/cpu.h
index a426647..65259e3 100644
--- a/cpukit/score/cpu/m68k/rtems/score/cpu.h
+++ b/cpukit/score/cpu/m68k/rtems/score/cpu.h
@@ -129,10 +129,6 @@ extern "C" {
 
 /* structures */
 
-typedef struct {
-  /* There is no CPU specific per-CPU state */
-} CPU_Per_CPU_control;
-
 /*
  *  Basic integer context for the m68k family.
  */
diff --git a/cpukit/score/cpu/mips/rtems/score/cpu.h b/cpukit/score/cpu/mips/rtems/score/cpu.h
index 59150ac..c5ea5e3 100644
--- a/cpukit/score/cpu/mips/rtems/score/cpu.h
+++ b/cpukit/score/cpu/mips/rtems/score/cpu.h
@@ -361,10 +361,6 @@ extern "C" {
 
 #ifndef ASM
 
-typedef struct {
-  /* There is no CPU specific per-CPU state */
-} CPU_Per_CPU_control;
-
 /* WARNING: If this structure is modified, the constants in cpu.h must be updated. */
 #if (__mips == 1) || (__mips == 32)
 #define __MIPS_REGISTER_TYPE     uint32_t
diff --git a/cpukit/score/cpu/moxie/rtems/score/cpu.h b/cpukit/score/cpu/moxie/rtems/score/cpu.h
index 3211c3b..9d83d7a 100644
--- a/cpukit/score/cpu/moxie/rtems/score/cpu.h
+++ b/cpukit/score/cpu/moxie/rtems/score/cpu.h
@@ -297,10 +297,6 @@ extern "C" {
 
 /* may need to put some structures here.  */
 
-typedef struct {
-  /* There is no CPU specific per-CPU state */
-} CPU_Per_CPU_control;
-
 /*
  * Contexts
  *
diff --git a/cpukit/score/cpu/nios2/rtems/score/cpu.h b/cpukit/score/cpu/nios2/rtems/score/cpu.h
index 4c56de0..3389a8c 100644
--- a/cpukit/score/cpu/nios2/rtems/score/cpu.h
+++ b/cpukit/score/cpu/nios2/rtems/score/cpu.h
@@ -113,10 +113,6 @@ extern "C" {
 
 #ifndef ASM
 
-typedef struct {
-  /* There is no CPU specific per-CPU state */
-} CPU_Per_CPU_control;
-
 /**
  * @brief Thread register context.
  *
diff --git a/cpukit/score/cpu/no_cpu/rtems/score/cpu.h b/cpukit/score/cpu/no_cpu/rtems/score/cpu.h
index 8309bb8..a2ae652 100644
--- a/cpukit/score/cpu/no_cpu/rtems/score/cpu.h
+++ b/cpukit/score/cpu/no_cpu/rtems/score/cpu.h
@@ -411,7 +411,11 @@ extern "C" {
  * @brief The CPU specific per-CPU control.
  *
  * The CPU port can place here all state information that must be available and
- * maintained for each CPU in the system.
+ * maintained for each processor in the system.  This structure must contain at
+ * least one field for C/C++ compatibility.  In GNU C empty structures have a
+ * size of zero.  In C++ structures have a non-zero size.  In case
+ * CPU_PER_CPU_CONTROL_SIZE is defined to zero, then this structure is not
+ * used.
  */
 typedef struct {
   /* CPU specific per-CPU state */
diff --git a/cpukit/score/cpu/or1k/rtems/score/cpu.h b/cpukit/score/cpu/or1k/rtems/score/cpu.h
index 33717bc..4850cd67 100644
--- a/cpukit/score/cpu/or1k/rtems/score/cpu.h
+++ b/cpukit/score/cpu/or1k/rtems/score/cpu.h
@@ -675,9 +675,6 @@ void _CPU_Context_Initialize(
 
 #define CPU_USE_GENERIC_BITFIELD_CODE TRUE
 
-typedef struct {
-/* There is no CPU specific per-CPU state */
-} CPU_Per_CPU_control;
 #endif /* ASM */
 
 #define CPU_SIZEOF_POINTER 4
diff --git a/cpukit/score/cpu/powerpc/rtems/score/cpu.h b/cpukit/score/cpu/powerpc/rtems/score/cpu.h
index b7be5ad..4b14302 100644
--- a/cpukit/score/cpu/powerpc/rtems/score/cpu.h
+++ b/cpukit/score/cpu/powerpc/rtems/score/cpu.h
@@ -228,10 +228,6 @@ extern "C" {
 
 #ifndef ASM
 
-typedef struct {
-  /* There is no CPU specific per-CPU state */
-} CPU_Per_CPU_control;
-
 /*
  * Non-volatile context according to E500ABIUG, EABI and 32-bit TLS (according
  * to "Power Architecture 32-bit Application Binary Interface Supplement 1.0 -
diff --git a/cpukit/score/cpu/sh/rtems/score/cpu.h b/cpukit/score/cpu/sh/rtems/score/cpu.h
index 53c7eb5..562fc44 100644
--- a/cpukit/score/cpu/sh/rtems/score/cpu.h
+++ b/cpukit/score/cpu/sh/rtems/score/cpu.h
@@ -268,10 +268,6 @@ extern "C" {
 
 /* may need to put some structures here.  */
 
-typedef struct {
-  /* There is no CPU specific per-CPU state */
-} CPU_Per_CPU_control;
-
 /*
  * Contexts
  *
diff --git a/cpukit/score/cpu/sparc64/rtems/score/cpu.h b/cpukit/score/cpu/sparc64/rtems/score/cpu.h
index d2fc81f..e0d05b8 100644
--- a/cpukit/score/cpu/sparc64/rtems/score/cpu.h
+++ b/cpukit/score/cpu/sparc64/rtems/score/cpu.h
@@ -221,10 +221,6 @@ extern "C" {
 #ifndef ASM
 
 typedef struct {
-  /* There is no CPU specific per-CPU state */
-} CPU_Per_CPU_control;
-
-typedef struct {
   uint64_t    l0;
   uint64_t    l1;
   uint64_t    l2;
diff --git a/cpukit/score/cpu/v850/rtems/score/cpu.h b/cpukit/score/cpu/v850/rtems/score/cpu.h
index de655c0..dc7bbaf 100644
--- a/cpukit/score/cpu/v850/rtems/score/cpu.h
+++ b/cpukit/score/cpu/v850/rtems/score/cpu.h
@@ -350,10 +350,6 @@ extern "C" {
 
 #define CPU_MAXIMUM_PROCESSORS 32
 
-typedef struct {
-  /* There is no CPU specific per-CPU state */
-} CPU_Per_CPU_control;
-
 /**
  * @defgroup CPUContext Processor Dependent Context Management
  *
diff --git a/cpukit/score/include/rtems/score/percpu.h b/cpukit/score/include/rtems/score/percpu.h
index 8d47aac..cb28cd9 100644
--- a/cpukit/score/include/rtems/score/percpu.h
+++ b/cpukit/score/include/rtems/score/percpu.h
@@ -260,10 +260,12 @@ typedef enum {
  *  This structure is used to hold per core state information.
  */
 typedef struct Per_CPU_Control {
-  /**
-   * @brief CPU port specific control.
-   */
-  CPU_Per_CPU_control cpu_per_cpu;
+  #if CPU_PER_CPU_CONTROL_SIZE > 0
+    /**
+     * @brief CPU port specific control.
+     */
+    CPU_Per_CPU_control cpu_per_cpu;
+  #endif
 
   #if (CPU_ALLOCATE_INTERRUPT_STACK == TRUE) || \
       (CPU_HAS_SOFTWARE_INTERRUPT_STACK == TRUE)
diff --git a/cpukit/score/src/percpuasm.c b/cpukit/score/src/percpuasm.c
index 15b49c7..53e6326 100644
--- a/cpukit/score/src/percpuasm.c
+++ b/cpukit/score/src/percpuasm.c
@@ -64,10 +64,12 @@ RTEMS_STATIC_ASSERT(
   );
 #endif
 
-RTEMS_STATIC_ASSERT(
-  sizeof( CPU_Per_CPU_control ) == CPU_PER_CPU_CONTROL_SIZE,
-  CPU_PER_CPU_CONTROL_SIZE
-);
+#if CPU_PER_CPU_CONTROL_SIZE > 0
+  RTEMS_STATIC_ASSERT(
+    sizeof( CPU_Per_CPU_control ) == CPU_PER_CPU_CONTROL_SIZE,
+    CPU_PER_CPU_CONTROL_SIZE
+  );
+#endif
 
 #if defined( RTEMS_SMP )
   RTEMS_STATIC_ASSERT(




More information about the vc mailing list