diff --git a/kernel/microkernel/cmdPkt.c b/kernel/microkernel/cmdPkt.c index 247afc07ea5..61306f38106 100644 --- a/kernel/microkernel/cmdPkt.c +++ b/kernel/microkernel/cmdPkt.c @@ -60,12 +60,12 @@ that have an ISR component should use their own command packet set. /* * generate build error by defining a negative-size array if the hard-coded - * command packet size is smaller than the actual size; otherwise, define + * command packet size differs from the actual size; otherwise, define * a zero-element array that gets thrown away by linker */ uint32_t _k_test_cmd_pkt_size - [0 - ((CMD_PKT_SIZE_IN_WORDS * sizeof(uint32_t)) < sizeof(struct k_args))]; + [0 - ((CMD_PKT_SIZE_IN_WORDS * sizeof(uint32_t)) != sizeof(struct k_args))]; /******************************************************************************* * diff --git a/kernel/microkernel/include/kernel_struct.h b/kernel/microkernel/include/kernel_struct.h index d702873a83e..f1c5d7d2cc1 100644 --- a/kernel/microkernel/include/kernel_struct.h +++ b/kernel/microkernel/include/kernel_struct.h @@ -448,12 +448,23 @@ union k_args_args { struct k_chack ChAck; }; +/* + * The size of the k_args structure must be equivalent to ... + * CMD_PKT_SIZE_IN_WORDS * sizeof(uint32_t) + * To this end the entire structure is packed. This ensures that the compiler + * aligns 'Args' to a 4-byte boundary. If left unpacked, then some compilers + * may provide an extra 4 bytes of padding to align it to an 8-byte boundary, + * thereby violating the previously stated equivalence. + */ struct k_args { struct k_args *Forw; struct k_args **Head; kpriority_t Prio; - bool alloc; /* true if allocated via GETARGS(); else false */ - K_COMM Comm; + + /* 'alloc' is true if k_args is allocated via GETARGS() */ + bool alloc __aligned(4); + K_COMM Comm __aligned(4); + K_CREF Ctxt; union { int32_t ticks; @@ -461,7 +472,7 @@ struct k_args { int rcode; } Time; K_ARGS_ARGS Args; -}; +} __packed; /* ---------------------------------------------------------------------- */ /* KERNEL OBJECT STRUCTURES */