        -:    0:Source:../../../os/rt/include/chregistry.h
        -:    0:Programs:16
        -:    1:/*
        -:    2:    ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio.
        -:    3:
        -:    4:    This file is part of ChibiOS.
        -:    5:
        -:    6:    ChibiOS is free software; you can redistribute it and/or modify
        -:    7:    it under the terms of the GNU General Public License as published by
        -:    8:    the Free Software Foundation; either version 3 of the License, or
        -:    9:    (at your option) any later version.
        -:   10:
        -:   11:    ChibiOS is distributed in the hope that it will be useful,
        -:   12:    but WITHOUT ANY WARRANTY; without even the implied warranty of
        -:   13:    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
        -:   14:    GNU General Public License for more details.
        -:   15:
        -:   16:    You should have received a copy of the GNU General Public License
        -:   17:    along with this program.  If not, see <http://www.gnu.org/licenses/>.
        -:   18:*/
        -:   19:
        -:   20:/**
        -:   21: * @file    chregistry.h
        -:   22: * @brief   Threads registry macros and structures.
        -:   23: *
        -:   24: * @addtogroup registry
        -:   25: * @{
        -:   26: */
        -:   27:
        -:   28:#ifndef _CHREGISTRY_H_
        -:   29:#define _CHREGISTRY_H_
        -:   30:
        -:   31:#if (CH_CFG_USE_REGISTRY == TRUE) || defined(__DOXYGEN__)
        -:   32:
        -:   33:/*===========================================================================*/
        -:   34:/* Module constants.                                                         */
        -:   35:/*===========================================================================*/
        -:   36:
        -:   37:/*===========================================================================*/
        -:   38:/* Module pre-compile time settings.                                         */
        -:   39:/*===========================================================================*/
        -:   40:
        -:   41:/*===========================================================================*/
        -:   42:/* Derived constants and error checks.                                       */
        -:   43:/*===========================================================================*/
        -:   44:
        -:   45:/*===========================================================================*/
        -:   46:/* Module data structures and types.                                         */
        -:   47:/*===========================================================================*/
        -:   48:
        -:   49:/**
        -:   50: * @brief   ChibiOS/RT memory signature record.
        -:   51: */
        -:   52:typedef struct {
        -:   53:  char      ch_identifier[4];       /**< @brief Always set to "main".       */
        -:   54:  uint8_t   ch_zero;                /**< @brief Must be zero.               */
        -:   55:  uint8_t   ch_size;                /**< @brief Size of this structure.     */
        -:   56:  uint16_t  ch_version;             /**< @brief Encoded ChibiOS/RT version. */
        -:   57:  uint8_t   ch_ptrsize;             /**< @brief Size of a pointer.          */
        -:   58:  uint8_t   ch_timesize;            /**< @brief Size of a @p systime_t.     */
        -:   59:  uint8_t   ch_threadsize;          /**< @brief Size of a @p thread_t.      */
        -:   60:  uint8_t   cf_off_prio;            /**< @brief Offset of @p p_prio field.  */
        -:   61:  uint8_t   cf_off_ctx;             /**< @brief Offset of @p p_ctx field.   */
        -:   62:  uint8_t   cf_off_newer;           /**< @brief Offset of @p p_newer field. */
        -:   63:  uint8_t   cf_off_older;           /**< @brief Offset of @p p_older field. */
        -:   64:  uint8_t   cf_off_name;            /**< @brief Offset of @p p_name field.  */
        -:   65:  uint8_t   cf_off_stklimit;        /**< @brief Offset of @p p_stklimit
        -:   66:                                                field.                      */
        -:   67:  uint8_t   cf_off_state;           /**< @brief Offset of @p p_state field. */
        -:   68:  uint8_t   cf_off_flags;           /**< @brief Offset of @p p_flags field. */
        -:   69:  uint8_t   cf_off_refs;            /**< @brief Offset of @p p_refs field.  */
        -:   70:  uint8_t   cf_off_preempt;         /**< @brief Offset of @p p_preempt
        -:   71:                                                field.                      */
        -:   72:  uint8_t   cf_off_time;            /**< @brief Offset of @p p_time field.  */
        -:   73:} chdebug_t;
        -:   74:
        -:   75:/*===========================================================================*/
        -:   76:/* Module macros.                                                            */
        -:   77:/*===========================================================================*/
        -:   78:
        -:   79:/**
        -:   80: * @brief   Removes a thread from the registry list.
        -:   81: * @note    This macro is not meant for use in application code.
        -:   82: *
        -:   83: * @param[in] tp        thread to remove from the registry
        -:   84: */
        -:   85:#define REG_REMOVE(tp) {                                                    \
        -:   86:  (tp)->p_older->p_newer = (tp)->p_newer;                                   \
        -:   87:  (tp)->p_newer->p_older = (tp)->p_older;                                   \
        -:   88:}
        -:   89:
        -:   90:/**
        -:   91: * @brief   Adds a thread to the registry list.
        -:   92: * @note    This macro is not meant for use in application code.
        -:   93: *
        -:   94: * @param[in] tp        thread to add to the registry
        -:   95: */
        -:   96:#define REG_INSERT(tp) {                                                    \
        -:   97:  (tp)->p_newer = (thread_t *)&ch.rlist;                                    \
        -:   98:  (tp)->p_older = ch.rlist.r_older;                                         \
        -:   99:  (tp)->p_older->p_newer = (tp);                                            \
        -:  100:  ch.rlist.r_older = (tp);                                                  \
        -:  101:}
        -:  102:
        -:  103:/*===========================================================================*/
        -:  104:/* External declarations.                                                    */
        -:  105:/*===========================================================================*/
        -:  106:
        -:  107:#ifdef __cplusplus
        -:  108:extern "C" {
        -:  109:#endif
        -:  110:  extern ROMCONST chdebug_t ch_debug;
        -:  111:  thread_t *chRegFirstThread(void);
        -:  112:  thread_t *chRegNextThread(thread_t *tp);
        -:  113:#ifdef __cplusplus
        -:  114:}
        -:  115:#endif
        -:  116:
        -:  117:#endif /* CH_CFG_USE_REGISTRY == TRUE */
        -:  118:
        -:  119:/*===========================================================================*/
        -:  120:/* Module inline functions.                                                  */
        -:  121:/*===========================================================================*/
        -:  122:
        -:  123:/**
        -:  124: * @brief   Sets the current thread name.
        -:  125: * @pre     This function only stores the pointer to the name if the option
        -:  126: *          @p CH_CFG_USE_REGISTRY is enabled else no action is performed.
        -:  127: *
        -:  128: * @param[in] name      thread name as a zero terminated string
        -:  129: *
        -:  130: * @api
        -:  131: */
function chRegSetThreadName called 1 returned 100% blocks executed 100%
        1:  132:static inline void chRegSetThreadName(const char *name) {
        -:  133:
        -:  134:#if CH_CFG_USE_REGISTRY == TRUE
        1:  135:  ch.rlist.r_current->p_name = name;
        -:  136:#else
        -:  137:  (void)name;
        -:  138:#endif
        1:  139:}
        -:  140:
        -:  141:/**
        -:  142: * @brief   Returns the name of the specified thread.
        -:  143: * @pre     This function only returns the pointer to the name if the option
        -:  144: *          @p CH_CFG_USE_REGISTRY is enabled else @p NULL is returned.
        -:  145: *
        -:  146: * @param[in] tp        pointer to the thread
        -:  147: *
        -:  148: * @return              Thread name as a zero terminated string.
        -:  149: * @retval NULL         if the thread name has not been set.
        -:  150: *
        -:  151: */
        -:  152:static inline const char *chRegGetThreadNameX(thread_t *tp) {
        -:  153:
        -:  154:#if CH_CFG_USE_REGISTRY == TRUE
        -:  155:  return tp->p_name;
        -:  156:#else
        -:  157:  (void)tp;
        -:  158:  return NULL;
        -:  159:#endif
        -:  160:}
        -:  161:
        -:  162:/**
        -:  163: * @brief   Changes the name of the specified thread.
        -:  164: * @pre     This function only stores the pointer to the name if the option
        -:  165: *          @p CH_CFG_USE_REGISTRY is enabled else no action is performed.
        -:  166: *
        -:  167: * @param[in] tp        pointer to the thread
        -:  168: * @param[in] name      thread name as a zero terminated string
        -:  169: *
        -:  170: * @xclass
        -:  171: */
function chRegSetThreadNameX called 1 returned 100% blocks executed 100%
        1:  172:static inline void chRegSetThreadNameX(thread_t *tp, const char *name) {
        -:  173:
        -:  174:#if CH_CFG_USE_REGISTRY == TRUE
        1:  175:  tp->p_name = name;
        -:  176:#else
        -:  177:  (void)tp;
        -:  178:  (void)name;
        -:  179:#endif
        1:  180:}
        -:  181:
        -:  182:#endif /* _CHREGISTRY_H_ */
        -:  183:
        -:  184:/** @} */
