From 011329ed906cfbf1d019e1a06cd000f2494451ee Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Mon, 2 Oct 2017 13:43:36 +0000 Subject: Added compile time safety check. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@10744 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/common/oslib/include/chfactory.h | 4 ++ os/common/oslib/include/chfifo.h | 128 +++++++++++++++++++++++++++++++++++ os/common/oslib/include/chheap.h | 4 ++ os/common/oslib/include/chmboxes.h | 4 ++ os/common/oslib/include/chmemcore.h | 4 ++ os/common/oslib/include/chmempools.h | 4 ++ 6 files changed, 148 insertions(+) create mode 100644 os/common/oslib/include/chfifo.h (limited to 'os/common/oslib/include') diff --git a/os/common/oslib/include/chfactory.h b/os/common/oslib/include/chfactory.h index ae975d3bd..f4fbf8161 100644 --- a/os/common/oslib/include/chfactory.h +++ b/os/common/oslib/include/chfactory.h @@ -28,6 +28,10 @@ #ifndef CHFACTORY_H #define CHFACTORY_H +#if !defined(CH_CFG_USE_FACTORY) +#define CH_CFG_USE_FACTORY FALSE +#endif + #if (CH_CFG_USE_FACTORY == TRUE) || defined(__DOXYGEN__) /*===========================================================================*/ diff --git a/os/common/oslib/include/chfifo.h b/os/common/oslib/include/chfifo.h new file mode 100644 index 000000000..f1ca6637c --- /dev/null +++ b/os/common/oslib/include/chfifo.h @@ -0,0 +1,128 @@ +/* + ChibiOS - Copyright (C) 2006..2016 Giovanni Di Sirio. + + This file is part of ChibiOS. + + ChibiOS is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file chfifo.h + * @brief Objects FIFO structures and macros. + * + * @addtogroup objects_fifo + * @{ + */ + +#ifndef CHFIFO_H +#define CHFIFO_H + +#if !defined(CH_CFG_USE_FIFO) +#define CH_CFG_USE_FIFO FALSE +#endif + +#if (CH_CFG_USE_FIFO == TRUE) || defined(__DOXYGEN__) + +/*===========================================================================*/ +/* Module constants. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Module pre-compile time settings. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Derived constants and error checks. */ +/*===========================================================================*/ + +#if CH_CFG_USE_MEMPOOLS == FALSE +#error "CH_CFG_USE_FIFO requires CH_CFG_USE_MEMPOOLS" +#endif + +#if CH_CFG_USE_SEMAPHORES == FALSE +#error "CH_CFG_USE_FIFO requires CH_CFG_USE_SEMAPHORES" +#endif + +/*===========================================================================*/ +/* Module data structures and types. */ +/*===========================================================================*/ + +/** + * @brief Type of an objects FIFO. + */ +typedef struct { + /** + * @brief Pool of the free objects. + */ + guarded_memory_pool_t free; + /** + * @brief Mailbox of the sent objects. + */ + mailbox_t mbx; +} objects_fifo_t; + +/*===========================================================================*/ +/* Module macros. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* External declarations. */ +/*===========================================================================*/ + +#ifdef __cplusplus +extern "C" { +#endif + void *chFifoAllocObjectI(objects_fifo_t *ofp); + void *chFifoAllocObjectTimeout(objects_fifo_t *ofp, + systime_t timeout); + msg_t chFifoReleaseObjectI(objects_fifo_t *ofp, + void *objp); + msg_t chFifoReleaseObject(objects_fifo_t *ofp, + void *objp); + msg_t chFifoPostObjectI(objects_fifo_t *ofp, + void *objp); + msg_t chFifoPostObjectS(objects_fifo_t *ofp, + void *objp); + msg_t chFifoPostObject(objects_fifo_t *ofp, void *obj); + msg_t chFifoFetchObjectI(objects_fifo_t *ofp, + void **objpp); + msg_t chFifoFetchObjectS(objects_fifo_t *ofp, + void **objpp); + msg_t chFifoFetchObjectTimeout(objects_fifo_t *ofp, + void **objpp, + systime_t timeout); +#ifdef __cplusplus +} +#endif + +/*===========================================================================*/ +/* Module inline functions. */ +/*===========================================================================*/ + +/** + * @brief Initializes a mail object. + * + * @param[out] mop pointer to a @p mail_t structure + * + * @init + */ +static inline void chMailObjectInit(mail_t *mop) { + +} + +#endif /* CH_CFG_USE_FIFO == TRUE */ + +#endif /* CHFIFO_H */ + +/** @} */ diff --git a/os/common/oslib/include/chheap.h b/os/common/oslib/include/chheap.h index 0b259a329..7c85efe7f 100644 --- a/os/common/oslib/include/chheap.h +++ b/os/common/oslib/include/chheap.h @@ -28,6 +28,10 @@ #ifndef CHHEAP_H #define CHHEAP_H +#if !defined(CH_CFG_USE_HEAP) +#define CH_CFG_USE_HEAP FALSE +#endif + #if (CH_CFG_USE_HEAP == TRUE) || defined(__DOXYGEN__) /*===========================================================================*/ diff --git a/os/common/oslib/include/chmboxes.h b/os/common/oslib/include/chmboxes.h index e3c16c78d..c31948296 100644 --- a/os/common/oslib/include/chmboxes.h +++ b/os/common/oslib/include/chmboxes.h @@ -28,6 +28,10 @@ #ifndef CHMBOXES_H #define CHMBOXES_H +#if !defined(CH_CFG_USE_MAILBOXES) +#define CH_CFG_USE_MAILBOXES FALSE +#endif + #if (CH_CFG_USE_MAILBOXES == TRUE) || defined(__DOXYGEN__) /*===========================================================================*/ diff --git a/os/common/oslib/include/chmemcore.h b/os/common/oslib/include/chmemcore.h index 759cee78d..aaaf22a9f 100644 --- a/os/common/oslib/include/chmemcore.h +++ b/os/common/oslib/include/chmemcore.h @@ -28,6 +28,10 @@ #ifndef CHMEMCORE_H #define CHMEMCORE_H +#if !defined(CH_CFG_USE_MEMCORE) +#define CH_CFG_USE_MEMCORE FALSE +#endif + #if (CH_CFG_USE_MEMCORE == TRUE) || defined(__DOXYGEN__) /*===========================================================================*/ diff --git a/os/common/oslib/include/chmempools.h b/os/common/oslib/include/chmempools.h index e9a7af31b..ab763b401 100644 --- a/os/common/oslib/include/chmempools.h +++ b/os/common/oslib/include/chmempools.h @@ -28,6 +28,10 @@ #ifndef CHMEMPOOLS_H #define CHMEMPOOLS_H +#if !defined(CH_CFG_USE_MEMPOOLS) +#define CH_CFG_USE_MEMPOOLS FALSE +#endif + #if (CH_CFG_USE_MEMPOOLS == TRUE) || defined(__DOXYGEN__) /*===========================================================================*/ -- cgit v1.2.3