gonzui


Format: Advanced Search

tkernel_2/include/tk/util.hbare sourcepermlink (0.02 seconds)

Search this content:

    1: /*
    2:  *----------------------------------------------------------------------
    3:  *    T-Kernel 2.0 Software Package
    4:  *
    5:  *    Copyright 2011 by Ken Sakamura.
    6:  *    This software is distributed under the latest version of T-License 2.x.
    7:  *----------------------------------------------------------------------
    8:  *
    9:  *    Released by T-Engine Forum(http://www.t-engine.org/) at 2011/05/17.
   10:  *    Modified by TRON Forum(http://www.tron.org/) at 2015/06/01.
   11:  *
   12:  *----------------------------------------------------------------------
   13:  */
   14: 
   15: /*
   16:  *      @(#)util.h (T-Kernel)
   17:  *
   18:  *      General Utilities
   19:  */
   20: 
   21: #ifndef __TK_UTIL_H__
   22: #define __TK_UTIL_H__
   23: 
   24: #include <basic.h>
   25: #include <tk/typedef.h>
   26: 
   27: #ifdef __cplusplus
   28: extern "C" {
   29: #endif
   30: 
   31: /*
   32:  * Fast Lock
   33:  */
   34: typedef struct {
   35:         W      cnt;
   36:         ID     id;
   37: } FastLock;
   38: 
   39: IMPORT ER CreateLock( FastLock *lock, CONST UB *name );
   40: IMPORT void DeleteLock( FastLock *lock );
   41: IMPORT void Lock( FastLock *lock );
   42: IMPORT void Unlock( FastLock *lock );
   43: 
   44: /*
   45:  * Multi Lock
   46:  *      Can use the maximum of 32 independent locks with a single FastMLock.
   47:  *      Divided by the lock number (no). Can specify 0-31 for 'no.'
   48:  *      (Slightly less efficient than FastLock)
   49:  */
   50: typedef struct {
   51:         UINT   flg;
   52:         INT    wai;
   53:         ID     id;
   54: } FastMLock;
   55: 
   56: IMPORT ER CreateMLock( FastMLock *lock, CONST UB *name );
   57: IMPORT ER DeleteMLock( FastMLock *lock );
   58: IMPORT ER MLockTmo( FastMLock *lock, INT no, TMO tmout );
   59: IMPORT ER MLockTmo_u( FastMLock *lock, INT no, TMO_U tmout_u );
   60: IMPORT ER MLock( FastMLock *lock, INT no );
   61: IMPORT ER MUnlock( FastMLock *lock, INT no );
   62: 
   63: /*
   64:  * 4-character object name
   65:  *      (Example)
   66:  *      T_CTSK       ctsk;
   67:  *      SetOBJNAME(ctsk.exinf, "TEST");
   68:  */
   69: union objname {
   70:         char   s[4];
   71:         void   *i;
   72: };
   73: 
   74: #define SetOBJNAME(exinf, name)                                 \
   75:         {                                                      \
   76:                 const static union objname _nm = { name };    \
   77:                 exinf = _nm.i;                                        \
   78:         }
   79: 
   80: #ifdef __cplusplus
   81: }
   82: #endif
   83: #endif /* __TK_UTIL_H__ */