init ems server code
This commit is contained in:
127
plat/public/src/include/pub_base.h
Normal file
127
plat/public/src/include/pub_base.h
Normal file
@@ -0,0 +1,127 @@
|
||||
//////////////////////////////////////////////////
|
||||
//Title : pub_basic.c
|
||||
//Auhtor : Liu Wei
|
||||
//Desc : public basic function
|
||||
//Created : 2007-06-23
|
||||
//Revision :
|
||||
//
|
||||
//Revision :
|
||||
//
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
#ifndef _PUB_BASE_H_
|
||||
#define _PUB_BASE_H_
|
||||
|
||||
typedef struct VALUE_STRING
|
||||
{
|
||||
u32 dValue;
|
||||
u8 *pStr;
|
||||
} StringVal;
|
||||
|
||||
#define ALPHA_TABLE_LOWER "abcdefghijklmnopqrstuvwsyz"
|
||||
#define ALPHA_TABLE_UPPER "ABCDEFGHIJKLMNOPQRSTUVWSYZ"
|
||||
|
||||
#define NOTSO(n) ( !(n) )
|
||||
#define IsNull(n) ( ((n) == NULL) )
|
||||
#define CNULL '\0'
|
||||
#define IsChNull(ch) ( ch==CNULL )
|
||||
#define STR_CHECK_LAST(str,ch) ( str[strlen(str)-1] == ch )
|
||||
#define STR_CHECK_FIRST(str,ch) ( str[0] == ch )
|
||||
#define STR_CUT_LAST(str) ( str[strlen(str)-1] = CNULL )
|
||||
|
||||
|
||||
#define BitSet(arg,posn) ((arg) | (1L << (posn)))
|
||||
#define BitClr(arg,posn) ((arg) & ~(1L << (posn)))
|
||||
#define BitFlp(arg,posn) ((arg) ^ (1L << (posn)))
|
||||
#define BitTst(arg,posn) (!(!((arg) & (1L << (posn)))))
|
||||
|
||||
|
||||
#define HexToChar(ch) ( (ch) + ( ((ch) > 9)? 'A'-10 : '0') )
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef MAX
|
||||
#define MAX(a, b) ( (a) > (b) ? (a) : (b) )
|
||||
#define MIN(a, b) ( (a) < (b) ? (a) : (b) )
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Name : GET_U8 GET_U16 GET_U32
|
||||
// Function : Return the u8 /u16 / u32 value of the pointer memery
|
||||
// Parameter: x : pointer
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
#define GET_U8( x ) ( *( (u8 *) (x) ) )
|
||||
#define GET_U16( x ) ( *( (u16 *) (x) ) )
|
||||
#define GET_U32( x ) ( *( (u32 *) (x) ) )
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
#define U16_LOW_BYTE ( x ) ( (u8 )( ((u16) (x) ) & 0xFF ) )
|
||||
#define U16_HIG_BYTE ( x ) ( (u8 )( ((u16) (x) ) >> 8 ) )
|
||||
|
||||
#define LSB_BYTE2WORD( uVal ) ( (((u16) (uVal)[0]) * 256) + (uVal)[1] )
|
||||
#define MSB_BYTE2WORD( uVal ) ( (((u16) (uVal)[1]) * 256) + (uVal)[0] )
|
||||
|
||||
#define LSB_WORD2BYTE( wVal , uVal ) \
|
||||
(uVal)[0] = ((wVal) / 256); \
|
||||
(uVal)[1] = ((wVal) & 0xFF )
|
||||
|
||||
#define MSB_WORD2BYTE( wVal , uVal ) \
|
||||
(uVal)[1] = ((wVal) / 256 ); \
|
||||
(uVal)[0] = ((wVal) & 0xFF)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Name : ARR_SIZE
|
||||
// Function : Return array size of a
|
||||
// Parameter: a : array
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
#define ARR_SIZE( a ) ( sizeof( (a) ) / sizeof( (a[0]) ) )
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Name : STR
|
||||
// Function : Convert the s to string
|
||||
// Parameter: a : a value you want to Convert to string but no need ""
|
||||
// e.g. : printf(STR(if(NOTSO(a)) return 0));
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
#define STR(s) #s
|
||||
#define FILL_VALSTR(n) {n,#n}
|
||||
#define GET_FILE_NAME(fn) \
|
||||
{ \
|
||||
static char fn[] = STR(_FILE_); \
|
||||
}
|
||||
|
||||
#define GetValueString(i,p,Maxtrix,IdMax) \
|
||||
{ \
|
||||
if( (i) >= (IdMax) ) \
|
||||
{ \
|
||||
(p) = Maxtrix[(IdMax)].pStr; \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
(p) = Maxtrix[(i)].pStr; \
|
||||
} \
|
||||
}
|
||||
|
||||
#define GET_MODULE_VER(x) (x##_VERSION)
|
||||
|
||||
#define FPOS( type, field ) \
|
||||
/*lint -e545 */ ( ( dword ) & ( ( type * ) 0 )->field ) /*lint +e545 */
|
||||
|
||||
#define FSIZ( type, field ) sizeof( ((type *) 0)->field )
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// DivRndUp: Divide and Round Up ///
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define DivRndUp(Num,Div) ( ((Num) % (Div))?((Num)/(Div) + 1):((Num)/(Div)) )
|
||||
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user