gonzui


Format: Advanced Search

mtkernel_3/kernel/tkernel/check.hbare sourcepermlink (0.01 seconds)

Search this content:

    1: /*
    2:  *----------------------------------------------------------------------
    3:  *    micro T-Kernel 3.00.00
    4:  *
    5:  *    Copyright (C) 2006-2019 by Ken Sakamura.
    6:  *    This software is distributed under the T-License 2.1.
    7:  *----------------------------------------------------------------------
    8:  *
    9:  *    Released by TRON Forum(http://www.tron.org) at 2019/12/11.
   10:  *
   11:  *----------------------------------------------------------------------
   12:  */
   13: 
   14: /*
   15:  *      check.h
   16:  *      Macro for Error Check 
   17:  */
   18: 
   19: #ifndef _CHECK_
   20: #define _CHECK_
   21: 
   22: /*
   23:  * Check object ID range (E_ID)
   24:  */
   25: #if CHK_ID
   26: #define CHECK_TSKID(tskid) {                                    \
   27:         if (!in_indp() && ((tskid) == TSK_SELF)) {             \
   28:                 return E_OBJ;                                 \
   29:         } else if (!CHK_TSKID(tskid)) {                                \
   30:                 return E_ID;                                  \
   31:         }                                                      \
   32: }
   33: #define CHECK_TSKID_SELF(tskid) {                               \
   34:         if ( !( (!in_indp() && (tskid) == TSK_SELF)            \
   35:                 || CHK_TSKID(tskid) ) ) {                     \
   36:                 return E_ID;                                  \
   37:         }                                                      \
   38: }
   39: #define CHECK_SEMID(semid) {                                    \
   40:         if (!CHK_SEMID(semid)) {                               \
   41:                 return E_ID;                                  \
   42:         }                                                      \
   43: }
   44: #define CHECK_FLGID(flgid) {                                    \
   45:         if (!CHK_FLGID(flgid)) {                               \
   46:                 return E_ID;                                  \
   47:         }                                                      \
   48: }
   49: #define CHECK_MBXID(mbxid) {                                    \
   50:         if (!CHK_MBXID(mbxid)) {                               \
   51:                 return E_ID;                                  \
   52:         }                                                      \
   53: }
   54: #define CHECK_MBFID(mbfid) {                                    \
   55:         if (!CHK_MBFID(mbfid)) {                               \
   56:                 return E_ID;                                  \
   57:         }                                                      \
   58: }
   59: #define CHECK_PORID(porid) {                                    \
   60:         if (!CHK_PORID(porid)) {                               \
   61:                 return E_ID;                                  \
   62:         }                                                      \
   63: }
   64: #define CHECK_MTXID(pisid) {                                    \
   65:         if (!CHK_MTXID(pisid)) {                               \
   66:                 return E_ID;                                  \
   67:         }                                                      \
   68: }
   69: #define CHECK_MPLID(mplid) {                                    \
   70:         if (!CHK_MPLID(mplid)) {                               \
   71:                 return E_ID;                                  \
   72:         }                                                      \
   73: }
   74: #define CHECK_MPFID(mpfid) {                                    \
   75:         if (!CHK_MPFID(mpfid)) {                               \
   76:                 return E_ID;                                  \
   77:         }                                                      \
   78: }
   79: #define CHECK_CYCID(cycid) {                                    \
   80:         if (!CHK_CYCID(cycid)) {                               \
   81:                 return E_ID;                                  \
   82:         }                                                      \
   83: }
   84: #define CHECK_ALMID(almid) {                                    \
   85:         if (!CHK_ALMID(almid)) {                               \
   86:                 return E_ID;                                  \
   87:         }                                                      \
   88: }
   89: #else /* CHK_ID */
   90: #define CHECK_TSKID(tskid)
   91: #define CHECK_TSKID_SELF(tskid)
   92: #define CHECK_SEMID(semid)
   93: #define CHECK_FLGID(flgid)
   94: #define CHECK_MBXID(mbxid)
   95: #define CHECK_MBFID(mbfid)
   96: #define CHECK_PORID(porid)
   97: #define CHECK_MTXID(pisid)
   98: #define CHECK_MPLID(mplid)
   99: #define CHECK_MPFID(mpfid)
  100: #define CHECK_CYCID(cycid)
  101: #define CHECK_ALMID(almid)
  102: #define CHECK_SSYID(ssid)
  103: #define CHECK_SSYID_ALL(ssid)
  104: #endif /* CHK_ID */
  105: 
  106: /*
  107:  * Check whether its own task is specified (E_OBJ)
  108:  */
  109: #if CHK_SELF
  110: #define CHECK_NONSELF(tskid) {                                  \
  111:         if (!in_indp() && (tskid) == knl_ctxtsk->tskid) {              \
  112:                 return E_OBJ;                                 \
  113:         }                                                      \
  114: }
  115: #else /* CHK_SELF */
  116: #define CHECK_NONSELF(tskid)
  117: #endif /* CHK_SELF */
  118: 
  119: /*
  120:  * Check task priority value (E_PAR)
  121:  */
  122: #if CHK_PAR
  123: #define CHECK_PRI(pri) {                                        \
  124:         if (!CHK_PRI(pri)) {                                   \
  125:                 return E_PAR;                                 \
  126:         }                                                      \
  127: }
  128: #define CHECK_PRI_INI(pri) {                                    \
  129:         if ((pri) != TPRI_INI && !CHK_PRI(pri)) {              \
  130:                 return E_PAR;                                 \
  131:         }                                                      \
  132: }
  133: #define CHECK_PRI_RUN(pri) {                                    \
  134:         if ((pri) != TPRI_RUN && !CHK_PRI(pri)) {              \
  135:                 return E_PAR;                                 \
  136:         }                                                      \
  137: }
  138: #else /* CHK_PAR */
  139: #define CHECK_PRI(pri)
  140: #define CHECK_PRI_INI(pri)
  141: #define CHECK_PRI_RUN(pri)
  142: #endif /* CHK_PAR */
  143: 
  144: /*
  145:  * Check timeout specification value (E_PAR)
  146:  */
  147: #if CHK_PAR
  148: #define CHECK_TMOUT(tmout) {                                    \
  149:         if (!((tmout) >= TMO_FEVR)) {                          \
  150:                 return E_PAR;                                 \
  151:         }                                                      \
  152: }
  153: #define CHECK_RELTIM(tmout) {                                   \
  154:         if(tmout >= 0x80000000UL){                             \
  155:                 return E_PAR;                                 \
  156:         }                                                      \
  157: }
  158: #else /* CHK_PAR */
  159: #define CHECK_TMOUT(tmout)
  160: #define CHECK_RELTIM(tmout)
  161: #endif /* CHK_PAR */
  162: 
  163: /*
  164:  * Check other parameter errors (E_PAR)
  165:  */
  166: #if CHK_PAR
  167: #define CHECK_PAR(exp) {                                        \
  168:         if (!(exp)) {                                          \
  169:                 return E_PAR;                                 \
  170:         }                                                      \
  171: }
  172: #else /* CHK_PAR */
  173: #define CHECK_PAR(exp)
  174: #endif /* CHK_PAR */
  175: 
  176: /*
  177:  * Check reservation attribute error (E_RSATR)
  178:  */
  179: #if CHK_RSATR
  180: #define CHECK_RSATR(atr, maxatr) {                              \
  181:         if ((atr) & ~(maxatr)) {                               \
  182:                 return E_RSATR;                                        \
  183:         }                                                      \
  184: }
  185: #else /* CHK_RSATR */
  186: #define CHECK_RSATR(atr, maxatr)
  187: #endif /* CHK_RSATR */
  188: 
  189: /*
  190:  * Check unsupported function (E_NOSPT)
  191:  */
  192: #if CHK_NOSPT
  193: #define CHECK_NOSPT(exp) {                                      \
  194:         if (!(exp)) {                                          \
  195:                 return E_NOSPT;                                       \
  196:         }                                                      \
  197: }
  198: #else /* CHK_NOSPT */
  199: #define CHECK_NOSPT(exp)
  200: #endif /* CHK_NOSPT */
  201: 
  202: /*
  203:  * Check whether task-independent part is running (E_CTX)
  204:  */
  205: #if CHK_CTX
  206: #define CHECK_INTSK() {                                         \
  207:         if (in_indp()) {                                       \
  208:                 return E_CTX;                                 \
  209:         }                                                      \
  210: }
  211: #else /* CHK_CTX */
  212: #define CHECK_INTSK()
  213: #endif /* CHK_CTX */
  214: 
  215: /*
  216:  * Check whether dispatch is in disabled state (E_CTX)
  217:  */
  218: #if CHK_CTX
  219: #define CHECK_DISPATCH() {                                      \
  220:         if (in_ddsp()) {                                       \
  221:                 return E_CTX;                                 \
  222:         }                                                      \
  223: }
  224: #define CHECK_DISPATCH_POL(tmout) {                             \
  225:         if ((tmout) != TMO_POL && in_ddsp()) {                 \
  226:                 return E_CTX;                                 \
  227:         }                                                      \
  228: }
  229: #else /* CHK_CTX */
  230: #define CHECK_DISPATCH()
  231: #define CHECK_DISPATCH_POL(tmout)
  232: #endif /* CHK_CTX */
  233: 
  234: /*
  235:  * Check other context errors (E_CTX)
  236:  */
  237: #if CHK_CTX
  238: #define CHECK_CTX(exp) {                                        \
  239:         if (!(exp)) {                                          \
  240:                 return E_CTX;                                 \
  241:         }                                                      \
  242: }
  243: #else /* CHK_CTX */
  244: #define CHECK_CTX(exp)
  245: #endif /* CHK_CTX */
  246: 
  247: #endif /* _CHECK_ */