diff options
Diffstat (limited to 'project/dclib')
| -rw-r--r-- | project/dclib/dclib-basics.c | 4 | ||||
| -rw-r--r-- | project/dclib/dclib-basics.h | 5 | ||||
| -rw-r--r-- | project/dclib/dclib-debug.c | 2 | ||||
| -rw-r--r-- | project/dclib/dclib-debug.h | 9 | ||||
| -rw-r--r-- | project/dclib/dclib-numeric.c | 41 | ||||
| -rw-r--r-- | project/dclib/dclib-tables.c | 8 | ||||
| -rw-r--r-- | project/dclib/lib-bmg.c | 1 | ||||
| -rw-r--r-- | project/dclib/lib-bmg.h | 8 |
8 files changed, 65 insertions, 13 deletions
diff --git a/project/dclib/dclib-basics.c b/project/dclib/dclib-basics.c index 094c189..569e4d5 100644 --- a/project/dclib/dclib-basics.c +++ b/project/dclib/dclib-basics.c @@ -3218,7 +3218,7 @@ void PrepareEditArgManager ( ArgManager_t *am, int needed_space ) uint AppendArgManager ( ArgManager_t *am, ccp arg1, ccp arg2, bool move_arg ) { DASSERT(am); - PRINT("AppendArgManager(,%s,%s,%d)\n",arg1,arg2,move_arg); + PRINT("AppendArgManager(,%s,%s,%d)\n",arg1?arg1:"",arg2?arg2:"",move_arg); return InsertArgManager(am,am->argc,arg1,arg2,move_arg); } @@ -3253,7 +3253,7 @@ uint InsertArgManager ( ArgManager_t *am, int pos, ccp arg1, ccp arg2, bool move_arg ) { DASSERT(am); - PRINT("InsertArgManager(,%d,%s,%s,%d)\n",pos,arg1,arg2,move_arg); + PRINT("InsertArgManager(,%d,%s,%s,%d)\n",pos,arg1?arg1:"",arg2?arg2:"",move_arg); pos = CheckIndex1(am->argc,pos); const int n = (arg1!=0) + (arg2!=0); diff --git a/project/dclib/dclib-basics.h b/project/dclib/dclib-basics.h index dd56ecb..b47e74a 100644 --- a/project/dclib/dclib-basics.h +++ b/project/dclib/dclib-basics.h @@ -80,6 +80,8 @@ #define SIZEOFRANGE(type,a,b) \ ( offsetof(type,b) + sizeof(((type*)0)->b) - offsetof(type,a) ) +#define NUM_OF_ELEMENTS(a) (sizeof(a)/sizeof(*(a))) + #define END_OF_VAR(v) ((void*)( (char*)(v) + sizeof(v) )) #define PTR_DISTANCE(a,b) ( (char*)(a) - (char*)(b) ) @@ -817,11 +819,14 @@ static inline mem_t MemByE ( ccp str, ccp end ) // Index helpers // For the 'End' variants, index 0 is end_of_source +// For the 'ex' variants, index 0 is end_of_source, but only for parem 'p_end' int CheckIndex1 ( int max, int index ); int CheckIndex1End ( int max, int index ); int CheckIndex2 ( int max, int * p_begin, int * p_end ); int CheckIndex2End ( int max, int * p_begin, int * p_end ); +int CheckIndex2 ( int max, int * p_begin, int * p_end ); +int CheckIndex2ex ( int max, int * p_begin, int * p_end ); int CheckIndexC ( int max, int * p_begin, int count ); int CheckIndexCEnd ( int max, int * p_begin, int count ); diff --git a/project/dclib/dclib-debug.c b/project/dclib/dclib-debug.c index fd32321..c6142a7 100644 --- a/project/dclib/dclib-debug.c +++ b/project/dclib/dclib-debug.c @@ -56,6 +56,8 @@ ccp TRACE_PREFIX = ""; FILE *TRACE_FILE = 0; FILE *MEM_LOG_FILE = 0; +int enable_ydebug = 0; + ccp (*GetErrorNameHook)( int stat, ccp ret_not_found ) = 0; ccp (*GetErrorTextHook)( int stat, ccp ret_not_found ) = 0; diff --git a/project/dclib/dclib-debug.h b/project/dclib/dclib-debug.h index b10c1b8..9b41751 100644 --- a/project/dclib/dclib-debug.h +++ b/project/dclib/dclib-debug.h @@ -287,6 +287,10 @@ __attribute__ ((__format__(__printf__,1,2))); // xTRACELINE // xBINGO // +// The macros with a preceding 'y' are active if enable_ydebug>0: +// yTRACELINE +// yBINGO +// /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// @@ -487,6 +491,7 @@ void WAIT_ARG_FUNC ( ccp format, va_list arg ); #undef BINGOD #undef xBINGO +#undef YBINGO #undef PRINT_TIME // always disabled @@ -544,6 +549,10 @@ void WAIT_ARG_FUNC ( ccp format, va_list arg ); #define xBINGO BINGO_FUNC(__FUNCTION__,__LINE__,__FILE__) #define xTRACELINE TRACE_FUNC("%s() line #%d @ %s\n",__FUNCTION__,__LINE__,__FILE__) +extern int enable_ydebug; +#define yBINGO if (enable_ydebug) BINGO_FUNC(__FUNCTION__,__LINE__,__FILE__) +#define yTRACELINE f (enable_ydebug) TRACE_FUNC("%s() line #%d @ %s\n",__FUNCTION__,__LINE__,__FILE__) + #undef PRINTF #define PRINTF PRINT diff --git a/project/dclib/dclib-numeric.c b/project/dclib/dclib-numeric.c index 7c23129..cf3fe15 100644 --- a/project/dclib/dclib-numeric.c +++ b/project/dclib/dclib-numeric.c @@ -902,6 +902,41 @@ int CheckIndex2End ( int max, int * p_begin, int * p_end ) /////////////////////////////////////////////////////////////////////////////// +int CheckIndex2ex ( int max, int * p_begin, int * p_end ) +{ + DASSERT( max >= 0 ); + DASSERT(p_begin); + DASSERT(p_end); + + int begin = *p_begin; + if ( begin < 0 ) + { + begin += max; + if ( begin < 0 ) + begin = 0; + } + else if ( begin > max ) + begin = max; + + int end = *p_end; + if ( end <= 0 ) + { + end += max; + // don't check for 'end<0' here, because 'end<begin' is checked later + } + else if ( end > max ) + end = max; + + if ( end < begin ) + end = begin; + + *p_begin = begin; + *p_end = end; + return end - begin; +} + +/////////////////////////////////////////////////////////////////////////////// + int CheckIndexC ( int max, int * p_begin, int count ) { DASSERT( max >= 0 ); @@ -9928,7 +9963,7 @@ char * PrintIP4ByMode void StartProgress ( progress_t *pr, u_msec_t interval_msec ) { - DASSERT(PR); + DASSERT(pr); ResetProgress(pr); pr->interval_msec = interval_msec; pr->start_msec = GetTimerMSec(); @@ -9938,7 +9973,7 @@ void StartProgress ( progress_t *pr, u_msec_t interval_msec ) bool CheckProgress ( progress_t *pr ) { - DASSERT(PR); + DASSERT(pr); if ( pr->interval_msec > 0 && pr->counter != pr->last_counter ) { const u_msec_t now = GetTimerMSec(); @@ -9956,7 +9991,7 @@ bool CheckProgress ( progress_t *pr ) bool FinalProgress ( progress_t *pr ) { - DASSERT(PR); + DASSERT(pr); if ( pr->interval_msec > 0 && pr->counter != pr->last_counter ) { pr->last_log_msec = GetTimerMSec(); diff --git a/project/dclib/dclib-tables.c b/project/dclib/dclib-tables.c index fd716cf..d4a5efd 100644 --- a/project/dclib/dclib-tables.c +++ b/project/dclib/dclib-tables.c @@ -438,10 +438,10 @@ const sizeof_info_t sizeof_info_linux[] = SIZEOF_INFO_TITLE("Basic C types") SIZEOF_INFO_ENTRY(char) SIZEOF_INFO_ENTRY(wchar_t) - SIZEOF_INFO_ENTRY(short) + SIZEOF_INFO_ENTRY(short int) SIZEOF_INFO_ENTRY(int) - SIZEOF_INFO_ENTRY(long) - SIZEOF_INFO_ENTRY(long long) + SIZEOF_INFO_ENTRY(long int) + SIZEOF_INFO_ENTRY(long long int) #ifdef __SIZEOF_INT128__ SIZEOF_INFO_ENTRY(__int128_t) #endif @@ -451,6 +451,8 @@ const sizeof_info_t sizeof_info_linux[] = SIZEOF_INFO_ENTRY(void*) SIZEOF_INFO_TITLE("Linux C types") + SIZEOF_INFO_ENTRY(intptr_t) + SIZEOF_INFO_ENTRY(ptrdiff_t) SIZEOF_INFO_ENTRY(size_t) //SIZEOF_INFO_ENTRY(ssize_t) SIZEOF_INFO_ENTRY(off_t) diff --git a/project/dclib/lib-bmg.c b/project/dclib/lib-bmg.c index aaeb8b8..235ae46 100644 --- a/project/dclib/lib-bmg.c +++ b/project/dclib/lib-bmg.c @@ -6084,7 +6084,6 @@ bool PatchFillBMG bmg_item_t * dptr = InsertItemBMG(bmg,mid,0,0,&old_item); if ( !old_item || !dptr->len ) { -// [[%04x-]] no access to lecode_04x const uint len = snprintf(buf,sizeof(buf),"_T%03X_",mid-ctb.track_name1.beg); AssignItemTextBMG(dptr,buf,len); diff --git a/project/dclib/lib-bmg.h b/project/dclib/lib-bmg.h index 7614558..d5822fa 100644 --- a/project/dclib/lib-bmg.h +++ b/project/dclib/lib-bmg.h @@ -151,22 +151,22 @@ enum MID_LE_ALT_ARENA_BEG = 0x6400, // alternate BMG of MID_LE_TRACK_BEG for arenas MID_LE_ALT_ARENA_END = 0x6480, - MID_LE_TRACK_BEG = 0x7000, + MID_LE_TRACK_BEG = 0x7000, // resevrved 0x7000 .. 0xafff MID_LE_TRACK_END = MID_LE_TRACK_BEG + BMG_N_LE_TRACK, MID_LE_ARENA_BEG = MID_LE_TRACK_BEG + BMG_N_TRACK, MID_LE_ARENA_END = MID_LE_ARENA_BEG + BMG_N_LE_ARENA, - MID_LE_CUP_BEG = 0xc000, + MID_LE_CUP_BEG = 0xb000, MID_LE_RCUP_BEG = MID_LE_CUP_BEG, MID_LE_RCUP_END = MID_LE_RCUP_BEG + BMG_N_LE_RCUP, MID_LE_BCUP_BEG = MID_LE_RCUP_END, MID_LE_BCUP_END = MID_LE_BCUP_BEG + BMG_N_LE_BCUP, MID_LE_CUP_END = MID_LE_BCUP_END, - MID_LE_CUP_REF_BEG = 0xd000, + MID_LE_CUP_REF_BEG = 0xc000, // resevrved 0xc000 .. 0xffff MID_LE_CUP_REF_END = MID_LE_CUP_REF_BEG + BMG_N_LE_TRACK, - MID_LE_BEG = MID_LE_TRACK_BEG, + MID_LE_BEG = MID_LE_ALT_ARENA_BEG, MID_LE_END = MID_LE_CUP_REF_END, |
