Browse Source

include: Remove PACKED attribute from SIGNAL_CONTEXT_*

GCC 9 is complaining because SIGNAL_CONTEXT_{X86,ARM} has the PACKED
attribute, causing FPU_CONTEXT not to meet its own alignment
requirement. There's no need for these structures to be packed. Remove
the packing so the FpuContext member can be padded out to the proper
alignment.

I checked for field offsets and sizes in x86.inc and arm.inc, but didn't
see anything that looked like it was affected by this. Found and removed
a duplicate definition in x86.inc. Interestingly, SIGNAL_CONTEXT_X64
was already not marked PACKED.

TRAP_FRAME is the same way. Although those offsets are used by assembly,
there's no odd ways to pack those structures really. They're unlikely to
break without the PACKED attribute, and having the PACKED attribute
probably did harm in the C world where the compiler was using kit gloves
to access potentially unaligned members.
Evan Green 3 years ago
parent
commit
7327104ffb
3 changed files with 60 additions and 65 deletions
  1. 1 5
      include/minoca/kernel/arm.h
  2. 59 59
      include/minoca/kernel/x86.h
  3. 0 1
      include/minoca/kernel/x86.inc

+ 1 - 5
include/minoca/kernel/arm.h

@@ -724,15 +724,11 @@ Members:
 
 --*/
 
-#pragma pack(push, 1)
-
 typedef struct _SIGNAL_CONTEXT_ARM {
     SIGNAL_CONTEXT Common;
     TRAP_FRAME TrapFrame;
     FPU_CONTEXT FpuContext;
-} PACKED SIGNAL_CONTEXT_ARM, *PSIGNAL_CONTEXT_ARM;
-
-#pragma pack(pop)
+} SIGNAL_CONTEXT_ARM, *PSIGNAL_CONTEXT_ARM;
 
 /*++
 

+ 59 - 59
include/minoca/kernel/x86.h

@@ -360,65 +360,6 @@ struct _FPU_CONTEXT {
 
 /*++
 
-Structure Description:
-
-    This structure outlines a trap frame that will be generated during most
-    interrupts and exceptions.
-
-Members:
-
-    Registers - Stores the current state of the machine's registers. These
-        values will be restored upon completion of the interrupt or exception.
-
---*/
-
-struct _TRAP_FRAME {
-    ULONG Ds;
-    ULONG Es;
-    ULONG Fs;
-    ULONG Gs;
-    ULONG Ss;
-    ULONG Eax;
-    ULONG Ebx;
-    ULONG Ecx;
-    ULONG Edx;
-    ULONG Esi;
-    ULONG Edi;
-    ULONG Ebp;
-    ULONG ErrorCode;
-    ULONG Eip;
-    ULONG Cs;
-    ULONG Eflags;
-    ULONG Esp;
-} PACKED;
-
-/*++
-
-Structure Description:
-
-    This structure outlines the register state saved by the kernel when a
-    user mode signal is dispatched. This generally contains 1) control
-    registers which are clobbered by switching to the signal handler, and
-    2) volatile registers.
-
-Members:
-
-    Common - Stores the common signal context information.
-
-    TrapFrame - Stores the general register state.
-
-    FpuContext - Stores the FPU state.
-
---*/
-
-typedef struct _SIGNAL_CONTEXT_X86 {
-    SIGNAL_CONTEXT Common;
-    TRAP_FRAME TrapFrame;
-    FPU_CONTEXT FpuContext;
-} PACKED SIGNAL_CONTEXT_X86, *PSIGNAL_CONTEXT_X86;
-
-/*++
-
 Structure Description:
 
     This structure contains the state of the processor, including both the
@@ -515,6 +456,65 @@ struct _PROCESSOR_CONTEXT {
 
 #pragma pack(pop)
 
+/*++
+
+Structure Description:
+
+    This structure outlines a trap frame that will be generated during most
+    interrupts and exceptions.
+
+Members:
+
+    Registers - Stores the current state of the machine's registers. These
+        values will be restored upon completion of the interrupt or exception.
+
+--*/
+
+struct _TRAP_FRAME {
+    ULONG Ds;
+    ULONG Es;
+    ULONG Fs;
+    ULONG Gs;
+    ULONG Ss;
+    ULONG Eax;
+    ULONG Ebx;
+    ULONG Ecx;
+    ULONG Edx;
+    ULONG Esi;
+    ULONG Edi;
+    ULONG Ebp;
+    ULONG ErrorCode;
+    ULONG Eip;
+    ULONG Cs;
+    ULONG Eflags;
+    ULONG Esp;
+};
+
+/*++
+
+Structure Description:
+
+    This structure outlines the register state saved by the kernel when a
+    user mode signal is dispatched. This generally contains 1) control
+    registers which are clobbered by switching to the signal handler, and
+    2) volatile registers.
+
+Members:
+
+    Common - Stores the common signal context information.
+
+    TrapFrame - Stores the general register state.
+
+    FpuContext - Stores the FPU state.
+
+--*/
+
+typedef struct _SIGNAL_CONTEXT_X86 {
+    SIGNAL_CONTEXT Common;
+    TRAP_FRAME TrapFrame;
+    FPU_CONTEXT FpuContext;
+} SIGNAL_CONTEXT_X86, *PSIGNAL_CONTEXT_X86;
+
 typedef
 VOID
 (*PAR_SAVE_RESTORE_FPU_CONTEXT) (

+ 0 - 1
include/minoca/kernel/x86.inc

@@ -100,7 +100,6 @@ Environment:
 #define TRAP_FRAME_SIZE     68
 
 #define PROCESSOR_CONTEXT_SIZE 0x60
-#define SIGNAL_CONTEXT_SIZE 32
 
 //
 // Define the minimum and maximum external interrupt vectors.