More style fixes.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@12804 27425a3e-05d8-49a3-a47f-9c15f0e5edd8
This commit is contained in:
Giovanni Di Sirio 2019-05-18 11:00:00 +00:00
parent c8bbce5f31
commit a4a4057dd9
2 changed files with 209 additions and 210 deletions

View File

@ -1,208 +1,208 @@
/* /*
ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio. ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio.
This file is part of ChibiOS. This file is part of ChibiOS.
ChibiOS is free software; you can redistribute it and/or modify ChibiOS is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or the Free Software Foundation; either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
ChibiOS is distributed in the hope that it will be useful, ChibiOS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
/** /**
* @file chpipes.h * @file chpipes.h
* @brief Pipes macros and structures. * @brief Pipes macros and structures.
* *
* @addtogroup oslib_pipes * @addtogroup oslib_pipes
* @{ * @{
*/ */
#ifndef CHPIPES_H #ifndef CHPIPES_H
#define CHPIPES_H #define CHPIPES_H
#if (CH_CFG_USE_PIPES == TRUE) || defined(__DOXYGEN__) #if (CH_CFG_USE_PIPES == TRUE) || defined(__DOXYGEN__)
/*===========================================================================*/ /*===========================================================================*/
/* Module constants. */ /* Module constants. */
/*===========================================================================*/ /*===========================================================================*/
/*===========================================================================*/ /*===========================================================================*/
/* Module pre-compile time settings. */ /* Module pre-compile time settings. */
/*===========================================================================*/ /*===========================================================================*/
/*===========================================================================*/ /*===========================================================================*/
/* Derived constants and error checks. */ /* Derived constants and error checks. */
/*===========================================================================*/ /*===========================================================================*/
/*===========================================================================*/ /*===========================================================================*/
/* Module data structures and types. */ /* Module data structures and types. */
/*===========================================================================*/ /*===========================================================================*/
/** /**
* @brief Structure representing a pipe object. * @brief Structure representing a pipe object.
*/ */
typedef struct { typedef struct {
uint8_t *buffer; /**< @brief Pointer to the pipe uint8_t *buffer; /**< @brief Pointer to the pipe
buffer. */ buffer. */
uint8_t *top; /**< @brief Pointer to the location uint8_t *top; /**< @brief Pointer to the location
after the buffer. */ after the buffer. */
uint8_t *wrptr; /**< @brief Write pointer. */ uint8_t *wrptr; /**< @brief Write pointer. */
uint8_t *rdptr; /**< @brief Read pointer. */ uint8_t *rdptr; /**< @brief Read pointer. */
size_t cnt; /**< @brief Bytes in the pipe. */ size_t cnt; /**< @brief Bytes in the pipe. */
bool reset; /**< @brief True if in reset state. */ bool reset; /**< @brief True if in reset state. */
thread_reference_t wtr; /**< @brief Waiting writer. */ thread_reference_t wtr; /**< @brief Waiting writer. */
thread_reference_t rtr; /**< @brief Waiting reader. */ thread_reference_t rtr; /**< @brief Waiting reader. */
#if (CH_CFG_USE_MUTEXES == TRUE) || defined(__DOXYGEN__) #if (CH_CFG_USE_MUTEXES == TRUE) || defined(__DOXYGEN__)
mutex_t cmtx; /**< @brief Common access mutex. */ mutex_t cmtx; /**< @brief Common access mutex. */
mutex_t wmtx; /**< @brief Write access mutex. */ mutex_t wmtx; /**< @brief Write access mutex. */
mutex_t rmtx; /**< @brief Read access mutex. */ mutex_t rmtx; /**< @brief Read access mutex. */
#else #else
semaphore_t csem; /**< @brief Common access semaphore.*/ semaphore_t csem; /**< @brief Common access semaphore.*/
semaphore_t wsem; /**< @brief Write access semaphore. */ semaphore_t wsem; /**< @brief Write access semaphore. */
semaphore_t rsem; /**< @brief Read access semaphore. */ semaphore_t rsem; /**< @brief Read access semaphore. */
#endif #endif
} pipe_t; } pipe_t;
/*===========================================================================*/ /*===========================================================================*/
/* Module macros. */ /* Module macros. */
/*===========================================================================*/ /*===========================================================================*/
/** /**
* @brief Data part of a static pipe initializer. * @brief Data part of a static pipe initializer.
* @details This macro should be used when statically initializing a * @details This macro should be used when statically initializing a
* pipe that is part of a bigger structure. * pipe that is part of a bigger structure.
* *
* @param[in] name the name of the pipe variable * @param[in] name the name of the pipe variable
* @param[in] buffer pointer to the pipe buffer array of @p uint8_t * @param[in] buffer pointer to the pipe buffer array of @p uint8_t
* @param[in] size number of @p uint8_t elements in the buffer array * @param[in] size number of @p uint8_t elements in the buffer array
*/ */
#if (CH_CFG_USE_MUTEXES == TRUE) || defined(__DOXYGEN__) #if (CH_CFG_USE_MUTEXES == TRUE) || defined(__DOXYGEN__)
#define _PIPE_DATA(name, buffer, size) { \ #define _PIPE_DATA(name, buffer, size) { \
(uint8_t *)(buffer), \ (uint8_t *)(buffer), \
(uint8_t *)(buffer) + size, \ (uint8_t *)(buffer) + size, \
(uint8_t *)(buffer), \ (uint8_t *)(buffer), \
(uint8_t *)(buffer), \ (uint8_t *)(buffer), \
(size_t)0, \ (size_t)0, \
false, \ false, \
NULL, \ NULL, \
NULL, \ NULL, \
_MUTEX_DATA(name.cmtx), \ _MUTEX_DATA(name.cmtx), \
_MUTEX_DATA(name.wmtx), \ _MUTEX_DATA(name.wmtx), \
_MUTEX_DATA(name.rmtx), \ _MUTEX_DATA(name.rmtx), \
} }
#else /* CH_CFG_USE_MUTEXES == FALSE */ #else /* CH_CFG_USE_MUTEXES == FALSE */
#define _PIPE_DATA(name, buffer, size) { \ #define _PIPE_DATA(name, buffer, size) { \
(uint8_t *)(buffer), \ (uint8_t *)(buffer), \
(uint8_t *)(buffer) + size, \ (uint8_t *)(buffer) + size, \
(uint8_t *)(buffer), \ (uint8_t *)(buffer), \
(uint8_t *)(buffer), \ (uint8_t *)(buffer), \
(size_t)0, \ (size_t)0, \
false, \ false, \
NULL, \ NULL, \
NULL, \ NULL, \
_SEMAPHORE_DATA(name.csem, (cnt_t)1), \ _SEMAPHORE_DATA(name.csem, (cnt_t)1), \
_SEMAPHORE_DATA(name.wsem, (cnt_t)1), \ _SEMAPHORE_DATA(name.wsem, (cnt_t)1), \
_SEMAPHORE_DATA(name.rsem, (cnt_t)1), \ _SEMAPHORE_DATA(name.rsem, (cnt_t)1), \
} }
#endif /* CH_CFG_USE_MUTEXES == FALSE */ #endif /* CH_CFG_USE_MUTEXES == FALSE */
/** /**
* @brief Static pipe initializer. * @brief Static pipe initializer.
* @details Statically initialized pipes require no explicit * @details Statically initialized pipes require no explicit
* initialization using @p chPipeObjectInit(). * initialization using @p chPipeObjectInit().
* *
* @param[in] name the name of the pipe variable * @param[in] name the name of the pipe variable
* @param[in] buffer pointer to the pipe buffer array of @p uint8_t * @param[in] buffer pointer to the pipe buffer array of @p uint8_t
* @param[in] size number of @p uint8_t elements in the buffer array * @param[in] size number of @p uint8_t elements in the buffer array
*/ */
#define PIPE_DECL(name, buffer, size) \ #define PIPE_DECL(name, buffer, size) \
pipe_t name = _PIPE_DATA(name, buffer, size) pipe_t name = _PIPE_DATA(name, buffer, size)
/*===========================================================================*/ /*===========================================================================*/
/* External declarations. */ /* External declarations. */
/*===========================================================================*/ /*===========================================================================*/
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
void chPipeObjectInit(pipe_t *pp, uint8_t *buf, size_t n); void chPipeObjectInit(pipe_t *pp, uint8_t *buf, size_t n);
void chPipeReset(pipe_t *pp); void chPipeReset(pipe_t *pp);
size_t chPipeWriteTimeout(pipe_t *pp, const uint8_t *bp, size_t chPipeWriteTimeout(pipe_t *pp, const uint8_t *bp,
size_t n, sysinterval_t timeout); size_t n, sysinterval_t timeout);
size_t chPipeReadTimeout(pipe_t *pp, uint8_t *bp, size_t chPipeReadTimeout(pipe_t *pp, uint8_t *bp,
size_t n, sysinterval_t timeout); size_t n, sysinterval_t timeout);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
/*===========================================================================*/ /*===========================================================================*/
/* Module inline functions. */ /* Module inline functions. */
/*===========================================================================*/ /*===========================================================================*/
/** /**
* @brief Returns the pipe buffer size as number of bytes. * @brief Returns the pipe buffer size as number of bytes.
* *
* @param[in] pp the pointer to an initialized @p pipe_t object * @param[in] pp the pointer to an initialized @p pipe_t object
* @return The size of the pipe. * @return The size of the pipe.
* *
* @api * @api
*/ */
static inline size_t chPipeGetSize(const pipe_t *pp) { static inline size_t chPipeGetSize(const pipe_t *pp) {
/*lint -save -e9033 [10.8] Perfectly safe pointers /*lint -save -e9033 [10.8] Perfectly safe pointers
arithmetic.*/ arithmetic.*/
return (size_t)(pp->top - pp->buffer); return (size_t)(pp->top - pp->buffer);
/*lint -restore*/ /*lint -restore*/
} }
/** /**
* @brief Returns the number of used byte slots into a pipe. * @brief Returns the number of used byte slots into a pipe.
* *
* @param[in] pp the pointer to an initialized @p pipe_t object * @param[in] pp the pointer to an initialized @p pipe_t object
* @return The number of queued bytes. * @return The number of queued bytes.
* *
* @api * @api
*/ */
static inline size_t chPipeGetUsedCount(const pipe_t *pp) { static inline size_t chPipeGetUsedCount(const pipe_t *pp) {
return pp->cnt; return pp->cnt;
} }
/** /**
* @brief Returns the number of free byte slots into a pipe. * @brief Returns the number of free byte slots into a pipe.
* *
* @param[in] pp the pointer to an initialized @p pipe_t object * @param[in] pp the pointer to an initialized @p pipe_t object
* @return The number of empty byte slots. * @return The number of empty byte slots.
* *
* @api * @api
*/ */
static inline size_t chPipeGetFreeCount(const pipe_t *pp) { static inline size_t chPipeGetFreeCount(const pipe_t *pp) {
return chPipeGetSize(pp) - chPipeGetUsedCount(pp); return chPipeGetSize(pp) - chPipeGetUsedCount(pp);
} }
/** /**
* @brief Terminates the reset state. * @brief Terminates the reset state.
* *
* @param[in] pp the pointer to an initialized @p pipe_t object * @param[in] pp the pointer to an initialized @p pipe_t object
* *
* @api * @api
*/ */
static inline void chPipeResume(pipe_t *pp) { static inline void chPipeResume(pipe_t *pp) {
pp->reset = false; pp->reset = false;
} }
#endif /* CH_CFG_USE_PIPES == TRUE */ #endif /* CH_CFG_USE_PIPES == TRUE */
#endif /* CHPIPES_H */ #endif /* CHPIPES_H */
/** @} */ /** @} */

View File

@ -160,7 +160,6 @@ static void dyn_release_object_heap(dyn_element_t *dep,
chDbgCheck(dep != NULL); chDbgCheck(dep != NULL);
chDbgAssert(dep->refs > (ucnt_t)0, "invalid references number"); chDbgAssert(dep->refs > (ucnt_t)0, "invalid references number");
dep->refs--; dep->refs--;
if (dep->refs == (ucnt_t)0) { if (dep->refs == (ucnt_t)0) {
dep = dyn_list_unlink(dep, dlp); dep = dyn_list_unlink(dep, dlp);
@ -381,7 +380,7 @@ registered_object_t *chFactoryFindObjectByPointer(void *objp) {
* *
* @api * @api
*/ */
void chFactoryReleaseObject(registered_object_t *rop){ void chFactoryReleaseObject(registered_object_t *rop) {
F_LOCK(); F_LOCK();