Eliminate public use of non-public command packet structure

Hard-codes the size of the command packet structure so that the
public microkernel semaphore API can utilize command packet sets
without utilizing non-public microkernel API information.

Also adds code to generate a build error if the hard-coded size
is too small, just in case the size of the command packet changes.
(Can't check for size equality, since the structure size may vary
from one compiler to the next. If the value is too large any extra
space in the command packet set will simply go unused.)

Change-Id: I69e7c2f08e3fe75d74bd712459d5587e22443c04
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
This commit is contained in:
Allan Stephens 2015-05-13 17:29:14 -04:00 committed by Anas Nashif
commit b9e5ff8f9e
2 changed files with 12 additions and 3 deletions

View file

@ -39,11 +39,11 @@ extern "C" {
/* includes */ /* includes */
#include <microkernel/k_struct.h> #include <microkernel/k_types.h>
/* defines */ /* define size of command packet (without exposing its internal structure) */
#define CMD_PKT_SIZE_IN_WORDS (sizeof(struct k_args) / sizeof(uint32_t)) #define CMD_PKT_SIZE_IN_WORDS (19)
/******************************************************************************* /*******************************************************************************
* *

View file

@ -61,6 +61,15 @@ that have an ISR component should use their own command packet set.
#include <minik.h> #include <minik.h>
#include <sections.h> #include <sections.h>
/*
* generate build error by defining a negative-size array if the hard-coded
* command packet size is smaller than 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))];
/******************************************************************************* /*******************************************************************************
* *
* _cmd_pkt_get - get the next command packet * _cmd_pkt_get - get the next command packet