From 9149c87ec724ed4e3f45762e771c12f81c3f5a33 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Fri, 23 Sep 2016 06:52:33 +0200 Subject: 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 adaf8091d3..9fe28c4a3f 100644 --- a/cpukit/score/cpu/arm/rtems/score/cpu.h +++ b/cpukit/score/cpu/arm/rtems/score/cpu.h @@ -245,10 +245,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; diff --git a/cpukit/score/cpu/bfin/rtems/score/cpu.h b/cpukit/score/cpu/bfin/rtems/score/cpu.h index 19b1f03fe2..1437277dc5 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 9a6428aab4..2954628a58 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 6cfeee6b9b..8fc62ca6e0 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 fe948aebf9..24e56251e9 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 f56e9d7790..8a29446e8e 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 a426647580..65259e3344 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 59150aceae..c5ea5e3bf1 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 3211c3b526..9d83d7aaf0 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 4c56de0a16..3389a8c51d 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 8309bb8b80..a2ae652f60 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 33717bc6e2..4850cd67c7 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 b7be5ad0a4..4b14302a2c 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 53c7eb5f77..562fc4402e 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 d2fc81fd45..e0d05b816f 100644 --- a/cpukit/score/cpu/sparc64/rtems/score/cpu.h +++ b/cpukit/score/cpu/sparc64/rtems/score/cpu.h @@ -220,10 +220,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; diff --git a/cpukit/score/cpu/v850/rtems/score/cpu.h b/cpukit/score/cpu/v850/rtems/score/cpu.h index de655c0f8c..dc7bbaf0f6 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 8d47aaca4f..cb28cd98c4 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 15b49c72e1..53e6326abd 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( -- cgit v1.2.3