From 55c7fc79c0945dddd4964f9263e7449d196a78a3 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Sun, 20 Aug 2023 15:56:58 +0200 Subject: [PATCH 001/258] cleanup yacc project code rename symbols to be more consistent over project --- bld/yacc/c/elimunit.c | 10 +++---- bld/yacc/c/genc.c | 38 ++++++++++++------------ bld/yacc/c/genobj.c | 24 +++++++-------- bld/yacc/c/gensmall.c | 13 ++++---- bld/yacc/c/gentable.c | 14 ++++----- bld/yacc/c/lalr1.c | 42 +++++++++++++------------- bld/yacc/c/lr0.c | 20 ++++++------- bld/yacc/c/recover.c | 69 ++++++++++++++++++++++--------------------- bld/yacc/c/sentence.c | 22 +++++++------- bld/yacc/h/yacc.h | 2 +- 10 files changed, 129 insertions(+), 125 deletions(-) diff --git a/bld/yacc/c/elimunit.c b/bld/yacc/c/elimunit.c index 204938ac6c..3ce7bbeeff 100644 --- a/bld/yacc/c/elimunit.c +++ b/bld/yacc/c/elimunit.c @@ -288,15 +288,15 @@ static a_sym *onlyOneReduction( a_state *state ) return( save_pro->sym ); } -static void removeParent( a_state *child, a_state *parent ) +static void removeParent( a_state *state, a_state *parent ) { a_parent **prev; a_parent *curr; - if( child->parents == NULL ) { + if( state->parents == NULL ) { return; } - prev = &(child->parents); + prev = &(state->parents); for( curr = *prev; curr != NULL; curr = curr->next ) { if( curr->state == parent ) { *prev = curr->next; @@ -305,9 +305,9 @@ static void removeParent( a_state *child, a_state *parent ) } prev = &(curr->next); } - if( child->parents == NULL ) { + if( state->parents == NULL ) { ++deadStates; - Dead( child ); + Dead( state ); } } diff --git a/bld/yacc/c/genc.c b/bld/yacc/c/genc.c index 7dfb49490c..e892c1d390 100644 --- a/bld/yacc/c/genc.c +++ b/bld/yacc/c/genc.c @@ -69,11 +69,11 @@ static void preamble( FILE *fp ) static void prolog( FILE *fp, int i ) { a_name name; - a_state * x; + a_state *state; fprintf( fp, "\nint YYNEAR state%d( parse_stack * yysp, unsigned token )\n/*\n", i ); - x = statetab[i]; - for( name.item = x->name.item; *name.item != NULL; ++name.item ) { + state = statetab[i]; + for( name.item = state->name.item; *name.item != NULL; ++name.item ) { showitem( fp, *name.item, " ." ); } fprintf( fp, "*/\n{\n" ); @@ -154,9 +154,9 @@ static a_state * unique_shift( a_pro * reduced ) * See if there is a unique shift when this state is reduced */ { - a_state * shift_to; - a_state * test; - a_shift_action * tx; + a_state *shift_to; + a_state *test; + a_shift_action *tx; int i; shift_to = NULL; @@ -202,7 +202,7 @@ static void reduce( FILE *fp, int production, int error ) copyact( pro, "\t" ); // fprintf( fp, "\tactions( %d, yysp );\n", production ); if( (shift_to = unique_shift( pro )) != NULL ) { - fprintf( fp, "\tyysp[0].state = state%d;\n", shift_to->sidx ); + fprintf( fp, "\tyysp[0].state = state%d;\n", shift_to->idx ); } else { fprintf( fp, "\t(*yysp[-1].state) ( yysp, %d );\n", pro->sym->token ); } @@ -318,7 +318,7 @@ void genobj( FILE *fp ) set_size *mp; a_sym *sym; a_pro *pro; - a_state *x; + a_state *state; a_shift_action *tx; a_reduce_action *rx; int i, j, ntoken, dtoken, ptoken; @@ -351,15 +351,15 @@ void genobj( FILE *fp ) for( s = actions + ntoken; --s >= actions; ) { *s = error; } - x = statetab[i]; + state = statetab[i]; q = token; - for( tx = x->trans; (sym = tx->sym) != NULL; ++tx ) { + for( tx = state->trans; (sym = tx->sym) != NULL; ++tx ) { tokval = sym->token; *q++ = tokval; - actions[tokval] = tx->state->sidx; + actions[tokval] = tx->state->idx; } max_savings = 0; - for( rx = x->redun; (pro = rx->pro) != NULL; ++rx ) { + for( rx = state->redun; (pro = rx->pro) != NULL; ++rx ) { if( (savings = (mp = Members( rx->follow )) - setmembers) == 0 ) continue; redun = pro->pidx + nstate; @@ -399,11 +399,11 @@ void genobj( FILE *fp ) if( other[i] != error && other[i] != other[j] ) continue; savings = 0; - x = statetab[j]; + state = statetab[j]; p = test; q = test + ntoken; - for( tx = x->trans; (sym = tx->sym) != NULL; ++tx ) - if( actions[sym->token] == tx->state->sidx ) { + for( tx = state->trans; (sym = tx->sym) != NULL; ++tx ) + if( actions[sym->token] == tx->state->idx ) { ++savings; *p++ = sym->token; } else { @@ -411,7 +411,7 @@ void genobj( FILE *fp ) --savings; *--q = sym->token; } - for( rx = x->redun; (pro = rx->pro) != NULL; ++rx ) { + for( rx = state->redun; (pro = rx->pro) != NULL; ++rx ) { if( (redun = pro->pidx + nstate) == other[j] ) redun = error; redun = pro->pidx + nstate; @@ -490,8 +490,8 @@ void genobj( FILE *fp ) putnum( fp, "YYNOACTION", error - nstate + dtoken ); putnum( fp, "YYEOFTOKEN", eofsym->token ); putnum( fp, "YYERRTOKEN", errsym->token ); - putnum( fp, "YYERR", errstate->sidx ); - fprintf( fp, "#define YYSTART state%d\n", startstate->sidx ); - fprintf( fp, "#define YYSTOP state%d\n", eofsym->enter->sidx ); + putnum( fp, "YYERR", errstate->idx ); + fprintf( fp, "#define YYSTART state%d\n", startstate->idx ); + fprintf( fp, "#define YYSTOP state%d\n", eofsym->state->idx ); printf( "%u states, %u with defaults, %u with parents\n", nstate, num_default, num_parent ); } diff --git a/bld/yacc/c/genobj.c b/bld/yacc/c/genobj.c index 8488b811f5..64871e684a 100644 --- a/bld/yacc/c/genobj.c +++ b/bld/yacc/c/genobj.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -60,7 +60,7 @@ void genobj( FILE *fp ) a_sym *sym; a_pro *pro; an_item *item; - a_state *x; + a_state *state; a_shift_action *tx; a_reduce_action *rx; int i, j; @@ -72,28 +72,28 @@ void genobj( FILE *fp ) label = OPTENTRY( nstate - 1 ); - emitins( JMP, TOKENTRY( startstate->sidx ) ); + emitins( JMP, TOKENTRY( startstate->idx ) ); target = CALLOC( nsym, short ); for( i = 0; i < nsym; ++i ) target[i] = DEFAULT; symbol = CALLOC( nsym, short ); for( i = 0; i < nstate; ++i ) { - x = statetab[i]; + state = statetab[i]; q = symbol; - for( tx = x->trans; (sym = tx->sym) != NULL; ++tx ) { + for( tx = state->trans; (sym = tx->sym) != NULL; ++tx ) { if( sym == eofsym ) { action = ACCEPT; } else if( sym->idx < nterm ) { - action = TOKENTRY(tx->state->sidx); + action = TOKENTRY(tx->state->idx); } else { - action = OPTENTRY(tx->state->sidx); + action = OPTENTRY(tx->state->idx); } *q++ = sym->idx; target[sym->idx] = action; } max_savings = 0; - for( rx = x->redun; (pro = rx->pro) != NULL; ++rx ) { + for( rx = state->redun; (pro = rx->pro) != NULL; ++rx ) { if( (savings = (mp = Members( rx->follow )) - setmembers) == 0 ) continue; action = PROENTRY( pro->pidx ); @@ -115,10 +115,10 @@ void genobj( FILE *fp ) } } - emitins( LBL, TOKENTRY( x->sidx ) ); + emitins( LBL, TOKENTRY( state->idx ) ); emitins( SCAN, 0 ); - emitins( LBL, OPTENTRY( x->sidx ) ); - emitins( CALL, VBLENTRY( x->sidx ) ); + emitins( LBL, OPTENTRY( state->idx ) ); + emitins( CALL, VBLENTRY( state->idx ) ); q = symbol; for( j = nterm; j < nsym; ++j ) { if( target[j] != DEFAULT ) { @@ -131,7 +131,7 @@ void genobj( FILE *fp ) target[*p] = DEFAULT; } } - emitins( LBL, VBLENTRY( x->sidx ) ); + emitins( LBL, VBLENTRY( state->idx ) ); q = symbol; for( j = 0; j < nterm; ++j ) { diff --git a/bld/yacc/c/gensmall.c b/bld/yacc/c/gensmall.c index ae660cb0cd..163af4dc8d 100644 --- a/bld/yacc/c/gensmall.c +++ b/bld/yacc/c/gensmall.c @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -129,7 +130,7 @@ void genobj( FILE *fp ) short *p; set_size *mp; a_pro *pro; - a_state *x; + a_state *state; a_reduce_action *rx; a_reduce_action *default_reduction; a_shift_action *tx; @@ -157,14 +158,14 @@ void genobj( FILE *fp ) table = NULL; for( i = 0; i < nstate; ++i ) { state_base[i] = base; - x = statetab[i]; - for( tx = x->trans; (sym = tx->sym) != NULL; ++tx ) { - add_table( sym->idx, ACTION_SHIFT | tx->state->sidx ); + state = statetab[i]; + for( tx = state->trans; (sym = tx->sym) != NULL; ++tx ) { + add_table( sym->idx, ACTION_SHIFT | tx->state->idx ); ++base; } default_reduction = NULL; max_savings = 0; - for( rx = x->redun; rx->pro != NULL; ++rx ) { + for( rx = state->redun; rx->pro != NULL; ++rx ) { if( (savings = Members( rx->follow ) - setmembers) == 0 ) continue; if( max_savings < savings ) { @@ -193,7 +194,7 @@ void genobj( FILE *fp ) printf( "avg: %u max: %u\n", sum / nstate, max ); dump_define( fp, "YYANYTOKEN", any_token ); dump_define( fp, "YYEOFTOKEN", eofsym->token ); - dump_define( fp, "YYSTART", startstate->sidx ); + dump_define( fp, "YYSTART", startstate->idx ); begin_table( fp, "YYACTTYPE", "yybasetab" ); for( i = 0; i < nstate; ++i ) { puttab( fp, FITS_A_WORD, state_base[i] ); diff --git a/bld/yacc/c/gentable.c b/bld/yacc/c/gentable.c index efb03652bf..64572d87e9 100644 --- a/bld/yacc/c/gentable.c +++ b/bld/yacc/c/gentable.c @@ -178,7 +178,7 @@ void genobj( FILE *fp ) a_sym *sym; a_pro *pro; an_item *item; - a_state *x; + a_state *state; a_shift_action *tx; a_reduce_action *rx; index_n i, j; @@ -231,14 +231,14 @@ void genobj( FILE *fp ) parent_base = 0; for( i = nstate; i > 0; ) { --i; - x = statetab[i]; + state = statetab[i]; q = tokens; - for( tx = x->trans; (sym = tx->sym) != NULL; ++tx ) { + for( tx = state->trans; (sym = tx->sym) != NULL; ++tx ) { *q++ = sym->token; actions[sym->token] = tx->state->idx; } max_savings = 0; - for( rx = x->redun; (pro = rx->pro) != NULL; ++rx ) { + for( rx = state->redun; (pro = rx->pro) != NULL; ++rx ) { if( (savings = (set_size)((mp = Members( rx->follow )) - setmembers)) == 0 ) continue; redun = pro->pidx + nstate; @@ -273,17 +273,17 @@ void genobj( FILE *fp ) parent[i] = nstate; for( j = nstate; --j > i; ) { if( abs( size[j] - size[i] ) < min_len ) { - x = statetab[j]; + state = statetab[j]; p = test; q = test + ntoken; - for( tx = x->trans; (sym = tx->sym) != NULL; ++tx ) { + for( tx = state->trans; (sym = tx->sym) != NULL; ++tx ) { if( actions[sym->token] == tx->state->idx ) { *p++ = sym->token; } else { *--q = sym->token; } } - for( rx = x->redun; (pro = rx->pro) != NULL; ++rx ) { + for( rx = state->redun; (pro = rx->pro) != NULL; ++rx ) { redun = pro->pidx + nstate; if( redun == other[j] ) redun = error; diff --git a/bld/yacc/c/lalr1.c b/bld/yacc/c/lalr1.c index 7766bd4e41..75ec2949ed 100644 --- a/bld/yacc/c/lalr1.c +++ b/bld/yacc/c/lalr1.c @@ -79,11 +79,11 @@ static void Reads( a_look *x ) static void CalcReads( void ) { - a_state *x; + a_state *state; a_look *p; - for( x = statelist; x != NULL; x = x->next ) { - for( p = x->look; p->trans != NULL; ++p ) { + for( state = statelist; state != NULL; state = state->next ) { + for( p = state->look; p->trans != NULL; ++p ) { if( p->depth == 0 ) { Reads( p ); } @@ -155,7 +155,8 @@ static void Includes( a_look *x ) static void CalcIncludes( void ) { - a_state *x, *y; + a_state *state; + a_state *state1; a_shift_action *tx; a_look *p, *q; a_sym *sym; @@ -163,8 +164,8 @@ static void CalcIncludes( void ) an_item *nullable, *item; a_link *free; - for( x = statelist; x != NULL; x = x->next ) { - for( p = x->look; p->trans != NULL; ++p ) { + for( state = statelist; state != NULL; state = state->next ) { + for( p = state->look; p->trans != NULL; ++p ) { p->depth = 0; for( pro = p->trans->sym->pro; pro != NULL; pro = pro->next ) { nullable = pro->items; @@ -173,15 +174,15 @@ static void CalcIncludes( void ) nullable = item; } } - y = x; + state1 = state; for( item = pro->items; (sym = item->p.sym) != NULL; ++item ) { if( sym->pro == NULL ) { - for( tx = y->trans; tx->sym != sym; ) { + for( tx = state1->trans; tx->sym != sym; ) { ++tx; } - y = tx->state; + state1 = tx->state; } else { - for( q = y->look; q->trans->sym != sym; ) { + for( q = state1->look; q->trans->sym != sym; ) { ++q; } if( item >= nullable ) { @@ -190,14 +191,14 @@ static void CalcIncludes( void ) free->next = q->include; q->include = free; } - y = q->trans->state; + state1 = q->trans->state; } } } } } - for( x = statelist; x != NULL; x = x->next ) { - for( p = x->look; p->trans != NULL; ++p ) { + for( state = statelist; state != NULL; state = state->next ) { + for( p = state->look; p->trans != NULL; ++p ) { if( p->depth == 0 ) { Includes( p ); } @@ -207,7 +208,8 @@ static void CalcIncludes( void ) static void Lookback( void ) { - a_state *x, *y; + a_state *state; + a_state *state1; a_shift_action *tx; a_look *p; a_reduce_action *rx; @@ -215,17 +217,17 @@ static void Lookback( void ) a_pro *pro; an_item *item; - for( x = statelist; x != NULL; x = x->next ) { - for( p = x->look; p->trans != NULL; ++p ) { + for( state = statelist; state != NULL; state = state->next ) { + for( p = state->look; p->trans != NULL; ++p ) { for( pro = p->trans->sym->pro; pro != NULL; pro = pro->next ) { - y = x; + state1 = state; for( item = pro->items; (sym = item->p.sym) != NULL; ++item ) { - for( tx = y->trans; tx->sym != sym; ) { + for( tx = state1->trans; tx->sym != sym; ) { ++tx; } - y = tx->state; + state1 = tx->state; } - for( rx = y->redun; rx->pro != NULL && rx->pro != pro; ) { + for( rx = state1->redun; rx->pro != NULL && rx->pro != pro; ) { ++rx; } Union( rx->follow, p->follow ); diff --git a/bld/yacc/c/lr0.c b/bld/yacc/c/lr0.c index 329c164d48..cb78471a9b 100644 --- a/bld/yacc/c/lr0.c +++ b/bld/yacc/c/lr0.c @@ -53,7 +53,7 @@ static a_state *addState( a_state **state, an_item **s, an_item **q, a_state *pa Mark( *p ); } kersize = (unsigned short)( q - s ); - for( ; *state != NULL; state = &(*state)->same_state_sym ) { + for( ; *state != NULL; state = &(*state)->sym_next ) { if( (*state)->kersize == kersize ) { p = (*state)->items; for( t = p + kersize; p != t; ++p ) { @@ -137,7 +137,7 @@ static bool itemlt( void *_a, void *_b ) } } -static void Complete( a_state *x, an_item **s ) +static void Complete( a_state *state, an_item **s ) { an_item **p, **q; a_reduce_action *rx; @@ -146,7 +146,7 @@ static void Complete( a_state *x, an_item **s ) index_n n; q = s; - for( p = x->items; *p != NULL; ++p ) { + for( p = state->items; *p != NULL; ++p ) { Mark( *p ); *q++ = *p; } @@ -170,12 +170,12 @@ static void Complete( a_state *x, an_item **s ) n = (index_n)( p - s ); nredun += n; rx = CALLOC( n + 1, a_reduce_action ); - x->redun = rx; + state->redun = rx; for( p = s; p < q && (*p)->p.sym == NULL; ++p ) { (rx++)->pro = (*p)[1].p.pro; } if( p == q ) { - x->trans = CALLOC( 1, a_shift_action ); + state->trans = CALLOC( 1, a_shift_action ); } else { n = 1; s = p; @@ -185,7 +185,7 @@ static void Complete( a_state *x, an_item **s ) } } tx = CALLOC( n + 1, a_shift_action ); - x->trans = tx; + state->trans = tx; do { tx->sym = (*s)->p.sym; if( tx->sym->pro != NULL ) { @@ -194,7 +194,7 @@ static void Complete( a_state *x, an_item **s ) for( p = s; p < q && (*p)->p.sym == tx->sym; ++p ) { ++*p; } - tx->state = addState( &tx->sym->state, s, p, x ); + tx->state = addState( &tx->sym->state, s, p, state ); s = p; ++tx; } while( s < q ); @@ -203,7 +203,7 @@ static void Complete( a_state *x, an_item **s ) void lr0( void ) { - a_state *x; + a_state *state; an_item **s; nvtrans = 0; @@ -212,8 +212,8 @@ void lr0( void ) statetail = &statelist; *s = startsym->pro->items; startstate = addState( &startsym->state, s, s + 1, NULL ); - for( x = statelist; x != NULL; x = x->next ) { - Complete( x, s ); + for( state = statelist; state != NULL; state = state->next ) { + Complete( state, s ); } errstate = addState( &errsym->state, s, s, NULL ); Complete( errstate, s ); diff --git a/bld/yacc/c/recover.c b/bld/yacc/c/recover.c index faba360ef2..a1e9f26cf9 100644 --- a/bld/yacc/c/recover.c +++ b/bld/yacc/c/recover.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -33,11 +33,24 @@ #include "yacc.h" +static a_state *AddErrState( a_state **enter, a_state **s, a_state **t ) +{ + if( t == s ) { + return( NULL ); + } else if( t == s + 1 ) { + Unmark( **s ); + return( *s ); + } else { + return( AddState( enter, s, t ) ); + } +} + static AddError() { a_sym *xsym, *sym; a_pro *xpro, *pro; - a_state *x, **s, **t, *AddErrState(); + a_state *state; + a_state **s, **t; a_shift_action *tx, *ty, *trans; a_reduce_action *rx, *ry, *redun; int i; @@ -55,31 +68,31 @@ static AddError() s = CALLOC( nstate, a_state * ); at = CALLOC( nstate, short ); s = t = CALLOC( nstate + 1, a_state * ); - for( x = statelist; x != NULL; x = x->next ) { - Mark( *x ); - *t++ = x; + for( state = statelist; state != NULL; state = state->next ) { + Mark( *state ); + *t++ = state; } restart = AddErrState( &errsym->enter, s, t ); - for( x = restart; x != NULL; x = x->next ) { + for( state = restart; state != NULL; state = state->next ) { Clear( defined ); Clear( conflict ); xpro = NULL; - for( i = 0; i < x->kersize; ++i ) { + for( i = 0; i < state->kersize; ++i ) { at[i] = 0; - pro = x->name.state[i]->redun->pro; + pro = state->name.state[i]->redun->pro; if( pro > xpro ) { xpro = pro; } } redun->pro = errpro; rx = redun + 1; - if( x != restart ) - while( xpro ) { + if( state != restart ) + while( xpro != NULL ) { pro = xpro; xpro = NULL; Clear( rx->follow ); - for( i = 0; i < x->kersize; ++i ) { - ry = &x->name.state[i]->redun[at[i]]; + for( i = 0; i < state->kersize; ++i ) { + ry = &state->name.state[i]->redun[at[i]]; if( ry->pro == pro ) { Union( rx->follow, ry->follow ); ++(at[i]); @@ -95,20 +108,20 @@ static AddError() ++rx; } xsym = NULL; - for( i = 0; i < x->kersize; ++i ) { + for( i = 0; i < state->kersize; ++i ) { at[i] = 0; - sym = x->name.state[i]->trans->sym; + sym = state->name.state[i]->trans->sym; if( sym > xsym ) { xsym = sym; } } tx = trans; - while( xsym ) { + while( xsym != NULL ) { sym = xsym; xsym = NULL; t = s; - for( i = 0; i < x->kersize; ++i ) { - ty = &x->name.state[i]->trans[at[i]]; + for( i = 0; i < state->kersize; ++i ) { + ty = &state->name.state[i]->trans[at[i]]; if( ty->sym == sym ) { if( !IsMarked( *ty->state ) ) { Mark( *ty->state ); @@ -138,8 +151,8 @@ static AddError() tx->state = AddErrState( &errsym->enter, s, t ); ++tx; } - x->trans = CALLOC( tx - trans + 1, a_shift_action ); - memcpy( x->trans, trans, ((char *) tx) - ((char *) trans) ); + state->trans = CALLOC( tx - trans + 1, a_shift_action ); + memcpy( state->trans, trans, (char *)tx - (char *)trans ); if( Empty( conflict ) ) { redun->pro = NULL; i = 0; @@ -154,15 +167,15 @@ static AddError() ++i; } } - x->redun = CALLOC( i + 1, a_reduce_action ); + state->redun = CALLOC( i + 1, a_reduce_action ); if( i > 0 ) { rset = AllocSet( i ); rx = redun; while( i > 0 ) { if( rx->pro != NULL ) { --i; - x->redun[i].pro = rx->pro; - x->redun[i].follow = rset; + state->redun[i].pro = rx->pro; + state->redun[i].follow = rset; Assign( rset, rx->follow ); rset += GetSetSize( 1 ); } @@ -177,15 +190,3 @@ static AddError() FREE( at ); } -static a_state *AddErrState( enter, s, t ) - a_state **enter, **s, **t; -{ - if( t == s ) { - return( NULL ); - } else if( t == s + 1 ) { - Unmark( **s ); - return( *s ); - } else { - return( AddState( enter, s, t ) ); - } -} diff --git a/bld/yacc/c/sentence.c b/bld/yacc/c/sentence.c index c163024bfc..71da26303a 100644 --- a/bld/yacc/c/sentence.c +++ b/bld/yacc/c/sentence.c @@ -174,16 +174,16 @@ static void doRunUntilShift( traceback **h, a_sym *sym, traceback **ht, unsigned index_n sym_idx; a_sym *chk_sym; a_state *state; - a_state *top; + a_state *top_state; a_reduce_action *raction; for( ; *h != NULL; ) { - top = (*h)->state; - if( top == NULL ) { + top_state = (*h)->state; + if( top_state == NULL ) { flushStack( h ); break; } - state = findNewShiftState( top, sym ); + state = findNewShiftState( top_state, sym ); if( state != NULL ) { pushTrace( h, state, sym ); pushTrace( ht, NULL, sym ); @@ -191,15 +191,15 @@ static void doRunUntilShift( traceback **h, a_sym *sym, traceback **ht, unsigned break; } for( ; *h != NULL; ) { - top = (*h)->state; - if( top->redun->pro == NULL ) + top_state = (*h)->state; + if( top_state->redun->pro == NULL ) break; - performReduce( h, top->redun->pro ); + performReduce( h, top_state->redun->pro ); } break; } sym_idx = sym->idx; - for( raction = top->redun; raction->pro != NULL; ++raction ) { + for( raction = top_state->redun; raction->pro != NULL; ++raction ) { if( IsBitSet( raction->follow, sym_idx ) ) { performReduce( h, raction->pro ); break; @@ -213,12 +213,12 @@ static void doRunUntilShift( traceback **h, a_sym *sym, traceback **ht, unsigned flushStack( h ); break; } - if( top->redun->pro != NULL ) { - performReduce( h, top->redun->pro ); + if( top_state->redun->pro != NULL ) { + performReduce( h, top_state->redun->pro ); } else { if( count ) { --count; - chk_sym = findNewShiftSym( top, ht ); + chk_sym = findNewShiftSym( top_state, ht ); } else { chk_sym = NULL; } diff --git a/bld/yacc/h/yacc.h b/bld/yacc/h/yacc.h index 5a40b18531..6ea757b556 100644 --- a/bld/yacc/h/yacc.h +++ b/bld/yacc/h/yacc.h @@ -194,7 +194,7 @@ struct a_state { a_reduce_action *default_reduction; a_parent *parents; a_look *look; - a_state *same_state_sym; + a_state *sym_next; unsigned short kersize; action_n idx; /* index of state [0..nstates] */ flags flag; From 01836cd806660f926cf5a2b0897357e959912a5d Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Sun, 20 Aug 2023 19:52:49 +0200 Subject: [PATCH 002/258] reformat source file --- bld/yacc/c/genc.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/bld/yacc/c/genc.c b/bld/yacc/c/genc.c index e892c1d390..cb7652585f 100644 --- a/bld/yacc/c/genc.c +++ b/bld/yacc/c/genc.c @@ -79,13 +79,13 @@ static void prolog( FILE *fp, int i ) fprintf( fp, "*/\n{\n" ); } -static void copyact( a_pro * pro, char * indent ) +static void copyact( a_pro *pro, char *indent ) { char *s; char *type; int i; - a_sym * lhs; - an_item * rhs; + a_sym *lhs; + an_item *rhs; unsigned n; int only_default_type; @@ -149,8 +149,8 @@ static void copyact( a_pro * pro, char * indent ) fprintf( fp, "\n%s};\n", indent ); } -static a_state * unique_shift( a_pro * reduced ) -/*********************************************** +static a_state *unique_shift( a_pro *reduced ) +/********************************************* * See if there is a unique shift when this state is reduced */ { @@ -184,9 +184,9 @@ static a_state * unique_shift( a_pro * reduced ) static void reduce( FILE *fp, int production, int error ) { int plen; - an_item * item; - a_pro * pro; - a_state * shift_to; + an_item *item; + a_pro *pro; + a_state *shift_to; if( production == error ) { fprintf( fp, "\treturn( ERROR );\n" ); From 60a928e40c475011d897e0c84c9d3dcc770b875b Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Sun, 20 Aug 2023 20:42:02 +0200 Subject: [PATCH 003/258] fix for issue #1125 (Thanks @MikeyG) --- bld/os2api/incl32/bsedos.mh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bld/os2api/incl32/bsedos.mh b/bld/os2api/incl32/bsedos.mh index 31129694a2..b569b97cca 100644 --- a/bld/os2api/incl32/bsedos.mh +++ b/bld/os2api/incl32/bsedos.mh @@ -1019,6 +1019,12 @@ APIRET APIENTRY DosReplaceModule(PCSZ,PCSZ,PCSZ); #define NPSS_WAIT 0x0001 +#define NP_NBLK 0x8000 +#define NP_SERVER 0x4000 +#define NP_WMESG 0x0400 +#define NP_RMESG 0x0100 +#define NP_ICOUNT 0x00FF + typedef LHANDLE HPIPE, *PHPIPE; typedef struct _AVAILDATA { From c539506264d46899b54c9a5562b56707974fc716 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Tue, 22 Aug 2023 15:49:08 +0200 Subject: [PATCH 004/258] correct wipfc build make file --- bld/wipfc/configure | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bld/wipfc/configure b/bld/wipfc/configure index c40e900897..8c334014b4 100755 --- a/bld/wipfc/configure +++ b/bld/wipfc/configure @@ -2494,7 +2494,7 @@ program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"` # expand $ac_aux_dir to an absolute path am_aux_dir=`cd $ac_aux_dir && pwd` -test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing" +test x"${MISSING+set}" = xset || MISSING="\${SHELL} \"$am_aux_dir/missing\"" # Use eval to expand $SHELL if eval "$MISSING --run true"; then am_missing_run="$MISSING --run " @@ -2684,7 +2684,7 @@ AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} -install_sh=${install_sh-"\$(SHELL) $am_aux_dir/install-sh"} +install_sh=${install_sh-"\$(SHELL) \"$am_aux_dir/install-sh\""} # Installed binaries are usually stripped using `strip' when the user # run `make install-strip'. However `strip' might not be the right From a5f5be49649fe14c3b7b771adc9bb759502fcfd1 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Wed, 23 Aug 2023 08:25:49 +0200 Subject: [PATCH 005/258] fix incorrect build of 16-bit Windows on-line help and documentation --- docs/mif/master.mif | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/mif/master.mif b/docs/mif/master.mif index ffca963dbf..53c698bebf 100644 --- a/docs/mif/master.mif +++ b/docs/mif/master.mif @@ -265,7 +265,7 @@ $(wikidir): .rtf.hlp : @%make compile_hpj_win - $(whc) $[@ + $(whc) $*.hpj {$(root_books)}.gml.rtf & {$(root_books)}.gml.gh : @@ -645,7 +645,7 @@ compile_hpj_win : .PROCEDURE @%append $*.hpj CONTENTS=table_of_contents @%append $*.hpj Title=$($^&_book_title) Help @%append $*.hpj COPYRIGHT=Copyright 2002-$(curr_year) Open Watcom Contributors, 1996 Sybase, Inc. and its subsidiaries. All rights reserved. - @%append $*.hpj BMROOT=$($^&_book_bmroot) + @%append $*.hpj BMROOT=$($^&_book_bmroot:/=\) @%append $*.hpj OLDKEYPHRASE=NO @%append $*.hpj ROOT=. @%append $*.hpj [Config] From bc4e13c7eb30474e18416f07d25d4ce79dd7f2c7 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Wed, 23 Aug 2023 09:04:24 +0200 Subject: [PATCH 006/258] add ppc support for linux system calls --- bld/clib/h/sysppc.h | 570 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 570 insertions(+) create mode 100644 bld/clib/h/sysppc.h diff --git a/bld/clib/h/sysppc.h b/bld/clib/h/sysppc.h new file mode 100644 index 0000000000..47bfd8be7f --- /dev/null +++ b/bld/clib/h/sysppc.h @@ -0,0 +1,570 @@ +/**************************************************************************** +* +* Open Watcom Project +* +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. +* +* ======================================================================== +* +* Description: Linux system calls interface - PPC specifics. +* +****************************************************************************/ + + +/* On PPC, the system call number is specified in r0. + * There is a maximum of 6 integer parameters to a syscall, passed in r3-r8. + * For the sc instruction, both a value and an error condition are returned. + * cr0.SO is the error condition, and r3 is the return value. + * When cr0.SO is clear, the syscall succeeded and r3 is the return value. + * When cr0.SO is set, the syscall failed and r3 is the error value (that + * normally corresponds to errno). + * + * Return value or error number are both returned in + * register v0 (regular function return register). Register a3 + * (fourth argument register) specifies whether the return value was an + * error or not: zero a3 means valid return value, nonzero a3 means error + * number. Don't look at me, I didn't invent this. + * + * To fix this 64-bit value is used for returning from sys_call.. routines. + * High 32-bit contains value/error flag and low 32-bit contains value. + */ + +#include "rterrno.h" + +typedef unsigned long long syscall_res; + +/* macros to access sys_call.. routines return/error value */ + +#define __syscall_iserror( res ) ((res)>>32) +#define __syscall_errno( res ) ((res)&0xFFFFFFFF) +#define __syscall_val( type, res ) ((type)((res)&0xFFFFFFFF)) + +#define __syscall_retcode( res, val ) \ + if( __syscall_iserror( res ) & (1 << 28)) { \ + _RWD_errno = __syscall_errno( res ); \ + res = (syscall_res)(val); \ + } + +#define __syscall_return( type, res ) \ + __syscall_retcode( res, -1 ) \ + return( __syscall_val( type, res ) ); + +#define __syscall_return_pointer( type, res ) \ + __syscall_retcode( res, 0 ) \ + return( __syscall_val( type, res ) ); + +/* + * Linux system call numbers + */ + +#define SYS_restart_syscall 0 +#define SYS_exit 1 +#define SYS_fork 2 /* ppc */ +#define SYS_read 3 +#define SYS_write 4 +#define SYS_open 5 +#define SYS_close 6 +#define SYS_waitpid 7 +#define SYS_creat 8 +#define SYS_link 9 +#define SYS_unlink 10 +#define SYS_execve 11 +#define SYS_chdir 12 +#define SYS_time 13 +#define SYS_mknod 14 +#define SYS_chmod 15 +#define SYS_lchown 16 +#define SYS_break 17 +#define SYS_oldstat 18 +#define SYS_lseek 19 +#define SYS_getpid 20 +#define SYS_mount 21 +#define SYS_umount 22 +#define SYS_setuid 23 +#define SYS_getuid 24 +#define SYS_stime 25 +#define SYS_ptrace 26 +#define SYS_alarm 27 +#define SYS_oldfstat 28 +#define SYS_pause 29 +#define SYS_utime 30 +#define SYS_stty 31 +#define SYS_gtty 32 +#define SYS_access 33 +#define SYS_nice 34 +#define SYS_ftime 35 +#define SYS_sync 36 +#define SYS_kill 37 +#define SYS_rename 38 +#define SYS_mkdir 39 +#define SYS_rmdir 40 +#define SYS_dup 41 +#define SYS_pipe 42 +#define SYS_times 43 +#define SYS_prof 44 +#define SYS_brk 45 +#define SYS_setgid 46 +#define SYS_getgid 47 +#define SYS_signal 48 +#define SYS_geteuid 49 +#define SYS_getegid 50 +#define SYS_acct 51 +#define SYS_umount2 52 +#define SYS_lock 53 +#define SYS_ioctl 54 +#define SYS_fcntl 55 +#define SYS_mpx 56 +#define SYS_setpgid 57 +#define SYS_ulimit 58 +#define SYS_oldolduname 59 +#define SYS_umask 60 +#define SYS_chroot 61 +#define SYS_ustat 62 +#define SYS_dup2 63 +#define SYS_getppid 64 +#define SYS_getpgrp 65 +#define SYS_setsid 66 +#define SYS_sigaction 67 +#define SYS_sgetmask 68 +#define SYS_ssetmask 69 +#define SYS_setreuid 70 +#define SYS_setregid 71 +#define SYS_sigsuspend 72 +#define SYS_sigpending 73 +#define SYS_sethostname 74 +#define SYS_setrlimit 75 +#define SYS_getrlimit 76 +#define SYS_getrusage 77 +#define SYS_gettimeofday 78 +#define SYS_settimeofday 79 +#define SYS_getgroups 80 +#define SYS_setgroups 81 +#define SYS_select 82 /* ppc */ +#define SYS_symlink 83 +#define SYS_oldlstat 84 +#define SYS_readlink 85 +#define SYS_uselib 86 +#define SYS_swapon 87 +#define SYS_reboot 88 +#define SYS_readdir 89 +#define SYS_mmap 90 +#define SYS_munmap 91 +#define SYS_truncate 92 +#define SYS_ftruncate 93 +#define SYS_fchmod 94 +#define SYS_fchown 95 +#define SYS_getpriority 96 +#define SYS_setpriority 97 +#define SYS_profil 98 +#define SYS_statfs 99 +#define SYS_fstatfs 100 +#define SYS_ioperm 101 +#define SYS_socketcall 102 +#define SYS_syslog 103 +#define SYS_setitimer 104 +#define SYS_getitimer 105 +#define SYS_stat 106 +#define SYS_lstat 107 +#define SYS_fstat 108 +#define SYS_olduname 109 +#define SYS_iopl 110 +#define SYS_vhangup 111 +#define SYS_idle 112 +#define SYS_vm86 113 +#define SYS_wait4 114 +#define SYS_swapoff 115 +#define SYS_sysinfo 116 +#define SYS_ipc 117 +#define SYS_fsync 118 +#define SYS_sigreturn 119 +#define SYS_clone 120 /* ppc */ +#define SYS_setdomainname 121 +#define SYS_uname 122 +#define SYS_modify_ldt 123 +#define SYS_adjtimex 124 +#define SYS_mprotect 125 +#define SYS_sigprocmask 126 +#define SYS_create_module 127 +#define SYS_init_module 128 +#define SYS_delete_module 129 +#define SYS_get_kernel_syms 130 +#define SYS_quotactl 131 +#define SYS_getpgid 132 +#define SYS_fchdir 133 +#define SYS_bdflush 134 +#define SYS_sysfs 135 +#define SYS_personality 136 +#define SYS_afs_syscall 137 +#define SYS_setfsuid 138 +#define SYS_setfsgid 139 +#define SYS__llseek 140 +#define SYS_getdents 141 +#define SYS__newselect 142 +#define SYS_flock 143 +#define SYS_msync 144 +#define SYS_readv 145 +#define SYS_writev 146 +#define SYS_getsid 147 +#define SYS_fdatasync 148 +#define SYS__sysctl 149 +#define SYS_mlock 150 +#define SYS_munlock 151 +#define SYS_mlockall 152 +#define SYS_munlockall 153 +#define SYS_sched_setparam 154 +#define SYS_sched_getparam 155 +#define SYS_sched_setscheduler 156 +#define SYS_sched_getscheduler 157 +#define SYS_sched_yield 158 +#define SYS_sched_get_priority_max 159 +#define SYS_sched_get_priority_min 160 +#define SYS_sched_rr_get_interval 161 +#define SYS_nanosleep 162 +#define SYS_mremap 163 +#define SYS_setresuid 164 +#define SYS_getresuid 165 +#define SYS_query_module 166 +#define SYS_poll 167 +#define SYS_nfsservctl 168 +#define SYS_setresgid 169 +#define SYS_getresgid 170 +#define SYS_prctl 171 +#define SYS_rt_sigreturn 172 +#define SYS_rt_sigaction 173 +#define SYS_rt_sigprocmask 174 +#define SYS_rt_sigpending 175 +#define SYS_rt_sigtimedwait 176 +#define SYS_rt_sigqueueinfo 177 +#define SYS_rt_sigsuspend 178 +#define SYS_pread64 179 +#define SYS_pwrite64 180 +#define SYS_chown 181 +#define SYS_getcwd 182 +#define SYS_capget 183 +#define SYS_capset 184 +#define SYS_sigaltstack 185 +#define SYS_sendfile 186 +#define SYS_getpmsg 187 +#define SYS_putpmsg 188 +#define SYS_vfork 189 /* ppc */ +#define SYS_ugetrlimit 190 +#define SYS_readahead 191 +#define SYS_mmap2 192 +#define SYS_truncate64 193 +#define SYS_ftruncate64 194 +#define SYS_stat64 195 +#define SYS_lstat64 196 +#define SYS_fstat64 197 +#define SYS_pciconfig_read 198 +#define SYS_pciconfig_write 199 +#define SYS_pciconfig_iobase 200 +#define SYS_multiplexer 201 +#define SYS_getdents64 202 +#define SYS_pivot_root 203 +#define SYS_fcntl64 204 +#define SYS_madvise 205 +#define SYS_mincore 206 +#define SYS_gettid 207 +#define SYS_tkill 208 +#define SYS_setxattr 209 +#define SYS_lsetxattr 210 +#define SYS_fsetxattr 211 +#define SYS_getxattr 212 +#define SYS_lgetxattr 213 +#define SYS_fgetxattr 214 +#define SYS_listxattr 215 +#define SYS_llistxattr 216 +#define SYS_flistxattr 217 +#define SYS_removexattr 218 +#define SYS_lremovexattr 219 +#define SYS_fremovexattr 220 +#define SYS_futex 221 +#define SYS_sched_setaffinity 222 +#define SYS_sched_getaffinity 223 +//#define SYS_ni_syscall 224 +#define SYS_tuxcall 225 +#define SYS_sendfile64 226 +#define SYS_io_setup 227 +#define SYS_io_destroy 228 +#define SYS_io_getevents 229 +#define SYS_io_submit 230 +#define SYS_io_cancel 231 +#define SYS_set_tid_address 232 +#define SYS_fadvise64 233 +#define SYS_exit_group 234 +#define SYS_lookup_dcookie 235 +#define SYS_epoll_create 236 +#define SYS_epoll_ctl 237 +#define SYS_epoll_wait 238 +#define SYS_remap_file_pages 239 +#define SYS_timer_create 240 +#define SYS_timer_settime 241 +#define SYS_timer_gettime 242 +#define SYS_timer_getoverrun 243 +#define SYS_timer_delete 244 +#define SYS_clock_settime 245 +#define SYS_clock_gettime 246 +#define SYS_clock_getres 247 +#define SYS_clock_nanosleep 248 +#define SYS_swapcontext 249 +#define SYS_tgkill 250 +#define SYS_utimes 251 +#define SYS_statfs64 252 +#define SYS_fstatfs64 253 +#define SYS_fadvise64_64 254 /* ppc */ +#define SYS_rtas 255 +#define SYS_sys_debug_setcontext 256 +//#define SYS_ni_syscall 257 +#define SYS_migrate_pages 258 +#define SYS_mbind 259 +#define SYS_get_mempolicy 260 +#define SYS_set_mempolicy 261 +#define SYS_mq_open 262 +#define SYS_mq_unlink 263 +#define SYS_mq_timedsend 264 +#define SYS_mq_timedreceive 265 +#define SYS_mq_notify 266 +#define SYS_mq_getsetattr 267 +#define SYS_kexec_load 268 +#define SYS_add_key 269 +#define SYS_request_key 270 +#define SYS_keyctl 271 +#define SYS_waitid 272 +#define SYS_ioprio_set 273 +#define SYS_ioprio_get 274 +#define SYS_inotify_init 275 +#define SYS_inotify_add_watch 276 +#define SYS_inotify_rm_watch 277 +#define SYS_spu_run 278 +#define SYS_spu_create 279 +#define SYS_pselect6 280 +#define SYS_ppoll 281 +#define SYS_unshare 282 +#define SYS_splice 283 +#define SYS_tee 284 +#define SYS_vmsplice 285 +#define SYS_openat 286 +#define SYS_mkdirat 287 +#define SYS_mknodat 288 +#define SYS_fchownat 289 +#define SYS_futimesat 290 +#define SYS_fstatat64 291 +#define SYS_unlinkat 292 +#define SYS_renameat 293 +#define SYS_linkat 294 +#define SYS_symlinkat 295 +#define SYS_readlinkat 296 +#define SYS_fchmodat 297 +#define SYS_faccessat 298 +#define SYS_get_robust_list 299 +#define SYS_set_robust_list 300 +#define SYS_move_pages 301 +#define SYS_getcpu 302 +#define SYS_epoll_pwait 303 +#define SYS_utimensat 304 +#define SYS_signalfd 305 +#define SYS_timerfd_create 306 +#define SYS_eventfd 307 +#define SYS_sync_file_range2 308 +#define SYS_fallocate 309 +#define SYS_subpage_prot 310 +#define SYS_timerfd_settime 311 +#define SYS_timerfd_gettime 312 +#define SYS_signalfd4 313 +#define SYS_eventfd2 314 +#define SYS_epoll_create1 315 +#define SYS_dup3 316 +#define SYS_pipe2 317 +#define SYS_inotify_init1 318 +#define SYS_perf_event_open 319 +#define SYS_preadv 320 +#define SYS_pwritev 321 +#define SYS_rt_tgsigqueueinfo 322 +#define SYS_fanotify_init 323 +#define SYS_fanotify_mark 324 +#define SYS_prlimit64 325 +#define SYS_socket 326 +#define SYS_bind 327 +#define SYS_connect 328 +#define SYS_listen 329 +#define SYS_accept 330 +#define SYS_getsockname 331 +#define SYS_getpeername 332 +#define SYS_socketpair 333 +#define SYS_send 334 +#define SYS_sendto 335 +#define SYS_recv 336 +#define SYS_recvfrom 337 +#define SYS_shutdown 338 +#define SYS_setsockopt 339 +#define SYS_getsockopt 340 +#define SYS_sendmsg 341 +#define SYS_recvmsg 342 +#define SYS_recvmmsg 343 +#define SYS_accept4 344 +#define SYS_name_to_handle_at 345 +#define SYS_open_by_handle_at 346 +#define SYS_clock_adjtime 347 +#define SYS_syncfs 348 +#define SYS_sendmmsg 349 +#define SYS_setns 350 +#define SYS_process_vm_readv 351 +#define SYS_process_vm_writev 352 +#define SYS_finit_module 353 +#define SYS_kcmp 354 +#define SYS_sched_setattr 355 +#define SYS_sched_getattr 356 +#define SYS_renameat2 357 +#define SYS_seccomp 358 +#define SYS_getrandom 359 +#define SYS_memfd_create 360 +#define SYS_bpf 361 +#define SYS_execveat 362 +#define SYS_switch_endian 363 +#define SYS_userfaultfd 364 +#define SYS_membarrier 365 +//#define SYS_ni_syscall 366 +//#define SYS_ni_syscall 367 +//#define SYS_ni_syscall 368 +//#define SYS_ni_syscall 369 +//#define SYS_ni_syscall 370 +//#define SYS_ni_syscall 371 +//#define SYS_ni_syscall 372 +//#define SYS_ni_syscall 373 +//#define SYS_ni_syscall 374 +//#define SYS_ni_syscall 375 +//#define SYS_ni_syscall 376 +//#define SYS_ni_syscall 377 +#define SYS_mlock2 378 +#define SYS_copy_file_range 379 +#define SYS_preadv2 380 +#define SYS_pwritev2 381 +#define SYS_kexec_file_load 382 +#define SYS_statx 383 +#define SYS_pkey_alloc 384 +#define SYS_pkey_free 385 +#define SYS_pkey_mprotect 386 +#define SYS_rseq 387 +#define SYS_io_pgetevents 388 +//#define SYS_ni_syscall 389 +//#define SYS_ni_syscall 390 +//#define SYS_ni_syscall 391 +//#define SYS_ni_syscall 392 +#define SYS_semctl 393 +#define SYS_semget 394 +#define SYS_shmget 395 +#define SYS_shmctl 396 +#define SYS_shmat 397 +#define SYS_shmdt 398 +#define SYS_msgget 399 +#define SYS_msgsnd 400 +#define SYS_msgrcv 401 +#define SYS_msgctl 402 +#define SYS_clock_gettime64 403 +#define SYS_clock_settime64 404 +#define SYS_clock_adjtime64 405 +#define SYS_clock_getres_time64 406 +#define SYS_clock_nanosleep_time64 407 +#define SYS_timer_gettime64 408 +#define SYS_timer_settime64 409 +#define SYS_timerfd_gettime64 410 +#define SYS_timerfd_settime64 411 +#define SYS_utimensat_time64 412 +#define SYS_pselect6_time64 413 +#define SYS_ppoll_time64 414 +//#define SYS_ni_syscall 415 +#define SYS_io_pgetevents_time64 416 +#define SYS_recvmmsg_time64 417 +#define SYS_mq_timedsend_time64 418 +#define SYS_mq_timedreceive_time64 419 +#define SYS_semtimedop_time64 420 +#define SYS_rt_sigtimedwait_time64 421 +#define SYS_futex_time64 422 +#define SYS_sched_rr_get_interval_time64 423 +#define SYS_pidfd_send_signal 424 +#define SYS_io_uring_setup 425 +#define SYS_io_uring_enter 426 +#define SYS_io_uring_register 427 +#define SYS_open_tree 428 +#define SYS_move_mount 429 +#define SYS_fsopen 430 +#define SYS_fsconfig 431 +#define SYS_fsmount 432 +#define SYS_fspick 433 +#define SYS_pidfd_open 434 +#define SYS_clone3 435 +#define SYS_close_range 436 +#define SYS_openat2 437 +#define SYS_pidfd_getfd 438 +#define SYS_faccessat2 439 +#define SYS_process_madvise 440 +#define SYS_epoll_pwait2 441 +#define SYS_mount_setattr 442 +#define SYS_quotactl_fd 443 +#define SYS_landlock_create_ruleset 444 +#define SYS_landlock_add_rule 445 +#define SYS_landlock_restrict_self 446 +//#define SYS_ni_syscall 447 +#define SYS_process_mrelease 448 +#define SYS_futex_waitv 449 + +/* + * Inline assembler for calling Linux system calls + */ + +syscall_res sys_call0( u_long func ); +#pragma aux sys_call0 = \ + "sc" \ + "mr 4,0" \ + __parm [$r0] \ + __value [$r4 $r3]; + +syscall_res sys_call1( u_long func, u_long r_3 ); +#pragma aux sys_call1 = \ + "sc" \ + "mr 4,0" \ + __parm [$r0] [$r3] \ + __value [$r4 $r3]; + +void sys_call1n( u_long func, u_long r_3 ); +#pragma aux sys_call1n = \ + "sc" \ + __parm [$r0] [$r3]; + +syscall_res sys_call2( u_long func, u_long r_3, u_long r_4 ); +#pragma aux sys_call2 = \ + "sc" \ + "mr 4,0" \ + __parm [$r0] [$r3] [$r4] \ + __value [$r4 $r3]; + +syscall_res sys_call3( u_long func, u_long r_3, u_long r_4, u_long r_5 ); +#pragma aux sys_call3 = \ + "sc" \ + "mr 4,0" \ + __parm [$r0] [$r3] [$r4] [$r5] \ + __value [$r4 $r3]; + +syscall_res sys_call4( u_long func, u_long r_3, u_long r_4, u_long r_5, u_long r_6 ); +#pragma aux sys_call4 = \ + "sc" \ + "mr 4,0" \ + __parm [$r0] [$r3] [$r4] [$r5] [$r6] \ + __value [$r4 $r3]; + +syscall_res sys_call5( u_long func, u_long r_3, u_long r_4, u_long r_5, u_long r_6, u_long r_7 ); +#pragma aux sys_call5 = \ + "sc" \ + "mr 4,0" \ + __parm [$r0] [$r3] [$r4] [$r5] [$r6] [$r7] \ + __value [$r4 $r3]; + +syscall_res sys_call6( u_long func, u_long r_3, u_long r_4, u_long r_5, u_long r_6, u_long r_7, u_long r_8 ); +#pragma aux sys_call6 = \ + "sc" \ + "mr 4,0" \ + __parm [$r0] [$r3] [$r4] [$r5] [$r6] [$r7] [$r8] \ + __value [$r4 $r3]; + +#define _sys_exit(rc) sys_call1n(SYS_exit, rc) +#define _sys_exit_group(rc) sys_call1n(SYS_exit_group, rc) From d159411ae7ad525ed3297b884754dfa037f2e434 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Mal=C3=A1k?= Date: Wed, 23 Aug 2023 13:27:29 +0200 Subject: [PATCH 007/258] add Delete Old Workflow runs action --- .github/workflows/runsdel.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 .github/workflows/runsdel.yml diff --git a/.github/workflows/runsdel.yml b/.github/workflows/runsdel.yml new file mode 100644 index 0000000000..5ec381a755 --- /dev/null +++ b/.github/workflows/runsdel.yml @@ -0,0 +1,19 @@ +name: Delete old workflow runs +on: + schedule: + - cron: '0 0 1 * *' +# Run monthly, at 00:00 on the 1st day of month. + +jobs: + del_runs: + runs-on: ubuntu-latest + permissions: + actions: write + steps: + - name: Delete workflow runs + uses: Mattraks/delete-workflow-runs@v2 + with: + token: ${{ github.token }} + repository: ${{ github.repository }} + retain_days: 60 + keep_minimum_runs: 60 From e5cd396b2d41fcf339fdc550eb82b262c2d87345 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Mal=C3=A1k?= Date: Wed, 23 Aug 2023 13:29:05 +0200 Subject: [PATCH 008/258] Update runsdel.yml update action name --- .github/workflows/runsdel.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/runsdel.yml b/.github/workflows/runsdel.yml index 5ec381a755..42bb19f0cc 100644 --- a/.github/workflows/runsdel.yml +++ b/.github/workflows/runsdel.yml @@ -1,4 +1,4 @@ -name: Delete old workflow runs +name: Delete Old (Workflow Runs) on: schedule: - cron: '0 0 1 * *' From 1721bd5573d2d2dcd1c2ba1b75139ada02053a85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Mal=C3=A1k?= Date: Wed, 23 Aug 2023 13:36:54 +0200 Subject: [PATCH 009/258] enable manual run --- .github/workflows/runsdel.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/runsdel.yml b/.github/workflows/runsdel.yml index 42bb19f0cc..d572efda12 100644 --- a/.github/workflows/runsdel.yml +++ b/.github/workflows/runsdel.yml @@ -3,6 +3,7 @@ on: schedule: - cron: '0 0 1 * *' # Run monthly, at 00:00 on the 1st day of month. + workflow_dispatch: jobs: del_runs: From 84391d48e07856ea9e334e18fd91407ba1b524aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Mal=C3=A1k?= Date: Wed, 23 Aug 2023 18:17:53 +0200 Subject: [PATCH 010/258] set limits lower delete if older then 45 days and count > 45 --- .github/workflows/runsdel.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/runsdel.yml b/.github/workflows/runsdel.yml index d572efda12..71291809b8 100644 --- a/.github/workflows/runsdel.yml +++ b/.github/workflows/runsdel.yml @@ -16,5 +16,5 @@ jobs: with: token: ${{ github.token }} repository: ${{ github.repository }} - retain_days: 60 - keep_minimum_runs: 60 + retain_days: 45 + keep_minimum_runs: 45 From d354df6a2d9c9e1a41e74120eca0cbe6a4eeedca Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Fri, 25 Aug 2023 00:29:02 +0200 Subject: [PATCH 011/258] remove old debugger version support --- bld/dig/c/dipman.c | 10 +------ bld/dig/c/dos/trpld.c | 4 --- bld/dig/c/dsx/trpld.c | 4 --- bld/dig/c/linux/trpld_pe.c | 4 --- bld/dig/c/linux/trpld_so.c | 4 --- bld/dig/c/madman.c | 6 +---- bld/dig/c/nt/trpld.c | 8 ------ bld/dig/c/os2/trpld.c | 4 --- bld/dig/c/qnx/trpld.c | 4 --- bld/dig/c/rdos/trpld.c | 10 +------ bld/dig/c/win/trpld.c | 8 ------ bld/dip/codeview/builder.ctl | 4 --- bld/dip/dwarf/builder.ctl | 4 --- bld/dip/export/builder.ctl | 4 --- bld/dip/hllcv/builder.ctl | 4 --- bld/dip/mapsym/builder.ctl | 4 --- bld/dip/master.mif | 18 ------------- bld/dip/watcom/builder.ctl | 4 --- bld/mad/axp/builder.ctl | 4 --- bld/mad/master.mif | 7 ----- bld/mad/mps/builder.ctl | 4 --- bld/mad/ppc/builder.ctl | 4 --- bld/mad/x86/builder.ctl | 4 --- bld/sdk/drwat/master.mif | 3 --- bld/trap/lcl/dos/dosx/c/dosxlink.c | 43 +++++++++--------------------- bld/trap/master.mif | 18 ------------- bld/wprof/c/aboutmsg.c | 2 +- bld/wprof/master.mif | 3 --- bld/wv/c/dbgparse.c | 16 +---------- bld/wv/master.mif | 3 --- bld/wv/rfx/master.mif | 3 --- bld/wv/ssl/master.mif | 7 ----- bld/wv/wvobjs.mif | 3 +-- build/mif/dllbase.mif | 4 --- distrib/ow/master.mif | 3 --- 35 files changed, 19 insertions(+), 220 deletions(-) diff --git a/bld/dig/c/dipman.c b/bld/dig/c/dipman.c index e516b87c17..9eadc42f61 100644 --- a/bld/dig/c/dipman.c +++ b/bld/dig/c/dipman.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -133,19 +133,11 @@ static const unsigned_8 MgrHdlSize[] = { }; char DIPDefaults[] = { -#ifdef USE_FILENAME_VERSION - "dwarf" QUOTED( USE_FILENAME_VERSION ) "\0" - "watcom" QUOTED( USE_FILENAME_VERSION ) "\0" - "codevi" QUOTED( USE_FILENAME_VERSION ) "\0" - "mapsym" QUOTED( USE_FILENAME_VERSION ) "\0" - "export" QUOTED( USE_FILENAME_VERSION ) "\0" -#else "dwarf\0" "watcom\0" "codeview\0" "mapsym\0" "export\0" -#endif "\0" }; diff --git a/bld/dig/c/dos/trpld.c b/bld/dig/c/dos/trpld.c index 67ee283b95..c24727e09f 100644 --- a/bld/dig/c/dos/trpld.c +++ b/bld/dig/c/dos/trpld.c @@ -134,10 +134,6 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) } *p++ = chr; } -#ifdef USE_FILENAME_VERSION - *p++ = ( USE_FILENAME_VERSION / 10 ) + '0'; - *p++ = ( USE_FILENAME_VERSION % 10 ) + '0'; -#endif *p = '\0'; sprintf( buff, "%s '%s'", TC_ERR_CANT_LOAD_TRAP, filename ); if( DIGLoader( Find )( DIG_FILETYPE_EXE, filename, p - filename, "trp", filename, sizeof( filename ) ) == 0 ) { diff --git a/bld/dig/c/dsx/trpld.c b/bld/dig/c/dsx/trpld.c index f0f24fec96..edb4ed4682 100644 --- a/bld/dig/c/dsx/trpld.c +++ b/bld/dig/c/dsx/trpld.c @@ -497,10 +497,6 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) } *p++ = chr; } -#ifdef USE_FILENAME_VERSION - *p++ = ( USE_FILENAME_VERSION / 10 ) + '0'; - *p++ = ( USE_FILENAME_VERSION % 10 ) + '0'; -#endif *p = '\0'; sprintf( buff, "%s '%s'", TC_ERR_CANT_LOAD_TRAP, filename ); if( DIGLoader( Find )( DIG_FILETYPE_EXE, filename, p - filename, "trp", filename, sizeof( filename ) ) == 0 ) { diff --git a/bld/dig/c/linux/trpld_pe.c b/bld/dig/c/linux/trpld_pe.c index fc4c95dd71..273d48db7b 100644 --- a/bld/dig/c/linux/trpld_pe.c +++ b/bld/dig/c/linux/trpld_pe.c @@ -102,10 +102,6 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) #endif } #if !defined( BUILTIN_TRAP_FILE ) - #ifdef USE_FILENAME_VERSION - *p++ = ( USE_FILENAME_VERSION / 10 ) + '0'; - *p++ = ( USE_FILENAME_VERSION % 10 ) + '0'; - #endif *p = '\0'; sprintf( buff, "%s '%s'", TC_ERR_CANT_LOAD_TRAP, filename ); if( DIGLoader( Find )( DIG_FILETYPE_EXE, filename, p - filename, "trp", filename, sizeof( filename ) ) == 0 ) { diff --git a/bld/dig/c/linux/trpld_so.c b/bld/dig/c/linux/trpld_so.c index 9ac80d72a2..3ed90961f3 100644 --- a/bld/dig/c/linux/trpld_so.c +++ b/bld/dig/c/linux/trpld_so.c @@ -104,10 +104,6 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) #endif } #if !defined( BUILTIN_TRAP_FILE ) - #ifdef USE_FILENAME_VERSION - *p++ = ( USE_FILENAME_VERSION / 10 ) + '0'; - *p++ = ( USE_FILENAME_VERSION % 10 ) + '0'; - #endif *p = '\0'; sprintf( buff, "%s '%s'", TC_ERR_CANT_LOAD_TRAP, filename ); if( DIGLoader( Find )( DIG_FILETYPE_EXE, filename, p - filename, "so", filename, sizeof( filename ) ) == 0 ) { diff --git a/bld/dig/c/madman.c b/bld/dig/c/madman.c index c8a816b2e4..b74b27355f 100644 --- a/bld/dig/c/madman.c +++ b/bld/dig/c/madman.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -197,11 +197,7 @@ mad_status MADInit( void ) const char *base_name; const char *desc; } list[] = { -#ifdef USE_FILENAME_VERSION - #define pick(enum,base_name,desc) {enum,base_name QUOTED(USE_FILENAME_VERSION),desc}, -#else #define pick(enum,base_name,desc) {enum,base_name,desc}, -#endif #include "digarch.h" #undef pick }; diff --git a/bld/dig/c/nt/trpld.c b/bld/dig/c/nt/trpld.c index 0c019868a7..94418a9c19 100644 --- a/bld/dig/c/nt/trpld.c +++ b/bld/dig/c/nt/trpld.c @@ -118,20 +118,12 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) have_ext = false; break; case '.': -#ifdef USE_FILENAME_VERSION - *p++ = ( USE_FILENAME_VERSION / 10 ) + '0'; - *p++ = ( USE_FILENAME_VERSION % 10 ) + '0'; -#endif have_ext = true; break; } *p++ = chr; } if( !have_ext ) { -#ifdef USE_FILENAME_VERSION - *p++ = ( USE_FILENAME_VERSION / 10 ) + '0'; - *p++ = ( USE_FILENAME_VERSION % 10 ) + '0'; -#endif *p++ = '.'; *p++ = 'd'; *p++ = 'l'; diff --git a/bld/dig/c/os2/trpld.c b/bld/dig/c/os2/trpld.c index a6c23411e9..64e412ca82 100644 --- a/bld/dig/c/os2/trpld.c +++ b/bld/dig/c/os2/trpld.c @@ -136,10 +136,6 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) *p++ = '6'; } } -#endif -#ifdef USE_FILENAME_VERSION - *p++ = ( USE_FILENAME_VERSION / 10 ) + '0'; - *p++ = ( USE_FILENAME_VERSION % 10 ) + '0'; #endif *p = '\0'; #ifndef _M_I86 diff --git a/bld/dig/c/qnx/trpld.c b/bld/dig/c/qnx/trpld.c index 12073ffd25..ffb40a7a8c 100644 --- a/bld/dig/c/qnx/trpld.c +++ b/bld/dig/c/qnx/trpld.c @@ -95,10 +95,6 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) } *p++ = chr; } -#ifdef USE_FILENAME_VERSION - *p++ = ( USE_FILENAME_VERSION / 10 ) + '0'; - *p++ = ( USE_FILENAME_VERSION % 10 ) + '0'; -#endif *p = '\0'; sprintf( buff, "%s '%s'", TC_ERR_CANT_LOAD_TRAP, filename ); if( DIGLoader( Find )( DIG_FILETYPE_EXE, filename, p - filename, "trp", filename, sizeof( filename ) ) ) { diff --git a/bld/dig/c/rdos/trpld.c b/bld/dig/c/rdos/trpld.c index 64ed930c3b..f5cc419138 100644 --- a/bld/dig/c/rdos/trpld.c +++ b/bld/dig/c/rdos/trpld.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -78,20 +78,12 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) have_ext = false; break; case '.': -#ifdef USE_FILENAME_VERSION - *p++ = ( USE_FILENAME_VERSION / 10 ) + '0'; - *p++ = ( USE_FILENAME_VERSION % 10 ) + '0'; -#endif have_ext = true; break; } *p++ = chr; } if( !have_ext ) { -#ifdef USE_FILENAME_VERSION - *p++ = ( USE_FILENAME_VERSION / 10 ) + '0'; - *p++ = ( USE_FILENAME_VERSION % 10 ) + '0'; -#endif *p++ = '.'; *p++ = 'd'; *p++ = 'l'; diff --git a/bld/dig/c/win/trpld.c b/bld/dig/c/win/trpld.c index ad6077d085..6f0da056ba 100644 --- a/bld/dig/c/win/trpld.c +++ b/bld/dig/c/win/trpld.c @@ -103,20 +103,12 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) have_ext = false; break; case '.': -#ifdef USE_FILENAME_VERSION - *p++ = ( USE_FILENAME_VERSION / 10 ) + '0'; - *p++ = ( USE_FILENAME_VERSION % 10 ) + '0'; -#endif have_ext = true; break; } *p++ = chr; } if( !have_ext ) { -#ifdef USE_FILENAME_VERSION - *p++ = ( USE_FILENAME_VERSION / 10 ) + '0'; - *p++ = ( USE_FILENAME_VERSION % 10 ) + '0'; -#endif *p++ = '.'; *p++ = 'd'; *p++ = 'l'; diff --git a/bld/dip/codeview/builder.ctl b/bld/dip/codeview/builder.ctl index 322f388776..74b4c47592 100644 --- a/bld/dip/codeview/builder.ctl +++ b/bld/dip/codeview/builder.ctl @@ -7,10 +7,6 @@ set PROJDIR= [ INCLUDE "/build/prolog.ctl" ] -[ BLOCK .. .1. ] -#===================================== - set PROJNAME=codevi - [ BLOCK .. .1. ] #============================ [ INCLUDE "/build/deflib.ctl" ] diff --git a/bld/dip/dwarf/builder.ctl b/bld/dip/dwarf/builder.ctl index 98f3c2963e..39d1024b3e 100644 --- a/bld/dip/dwarf/builder.ctl +++ b/bld/dip/dwarf/builder.ctl @@ -7,10 +7,6 @@ set PROJDIR= [ INCLUDE "/build/prolog.ctl" ] -[ BLOCK .. .1. ] -#===================================== - set PROJNAME=dwarf - [ BLOCK .. .1. ] #============================ [ INCLUDE "/build/deflib.ctl" ] diff --git a/bld/dip/export/builder.ctl b/bld/dip/export/builder.ctl index 9567ebd473..2e55f984c1 100644 --- a/bld/dip/export/builder.ctl +++ b/bld/dip/export/builder.ctl @@ -7,10 +7,6 @@ set PROJDIR= [ INCLUDE "/build/prolog.ctl" ] -[ BLOCK .. .1. ] -#===================================== - set PROJNAME=export - [ BLOCK .. .1. ] #============================ [ INCLUDE "/build/deflib.ctl" ] diff --git a/bld/dip/hllcv/builder.ctl b/bld/dip/hllcv/builder.ctl index 87e65e51a1..e722c07ffa 100644 --- a/bld/dip/hllcv/builder.ctl +++ b/bld/dip/hllcv/builder.ctl @@ -7,10 +7,6 @@ set PROJDIR= [ INCLUDE "/build/prolog.ctl" ] -[ BLOCK .. .1. ] -#===================================== - set PROJNAME=hllcv - [ BLOCK .. .1. ] #============================ [ INCLUDE "/build/deflib.ctl" ] diff --git a/bld/dip/mapsym/builder.ctl b/bld/dip/mapsym/builder.ctl index ca4d999e1f..0c4a9f35f8 100644 --- a/bld/dip/mapsym/builder.ctl +++ b/bld/dip/mapsym/builder.ctl @@ -7,10 +7,6 @@ set PROJDIR= [ INCLUDE "/build/prolog.ctl" ] -[ BLOCK .. .1. ] -#===================================== - set PROJNAME=mapsym - [ BLOCK .. .1. ] #============================ [ INCLUDE "/build/deflib.ctl" ] diff --git a/bld/dip/master.mif b/bld/dip/master.mif index d1763a66e6..ff83908392 100644 --- a/bld/dip/master.mif +++ b/bld/dip/master.mif @@ -14,22 +14,7 @@ dip_nofpu = 1 sys_dll = 1 !endif -!ifdef %OWUSE_FILENAME_VERSION -dllname_codeview = codevi$(bld_ver) -dllname_dwarf = dwarf$(bld_ver) -dllname_export = export$(bld_ver) -dllname_hllcv = hllcv$(bld_ver) -dllname_javavm = javavm$(bld_ver) -dllname_mapsym = mapsym$(bld_ver) -dllname_watcom = watcom$(bld_ver) -############## -# add new module -#dllname_skel = skel$(bld_ver) -############## -dllname = $(dllname_$(dip_format)) -!else dllname = $(dip_format) -!endif !include cproj.mif !include defrule.mif @@ -48,9 +33,6 @@ dllname = $(dip_format) inc_dirs = -I"../h" $(dwarfr_inc_dirs) -I"$(lib_misc_dir)/h" $(extra_incs) -I"$(dig_dir)/h" extra_cpp_flags = -DINSIDE_DIP $(extra_cppflags) -!ifdef %OWUSE_FILENAME_VERSION -extra_cpp_flags += -DUSE_FILENAME_VERSION=$(bld_ver) -!endif extra_c_flags_i86 = -zc -zu diff --git a/bld/dip/watcom/builder.ctl b/bld/dip/watcom/builder.ctl index 707dfee34e..7955a780e8 100644 --- a/bld/dip/watcom/builder.ctl +++ b/bld/dip/watcom/builder.ctl @@ -7,10 +7,6 @@ set PROJDIR= [ INCLUDE "/build/prolog.ctl" ] -[ BLOCK .. .1. ] -#===================================== - set PROJNAME=watcom - [ BLOCK .. .1. ] #============================ [ INCLUDE "/build/deflib.ctl" ] diff --git a/bld/mad/axp/builder.ctl b/bld/mad/axp/builder.ctl index 59d968b5c1..3077c3164e 100644 --- a/bld/mad/axp/builder.ctl +++ b/bld/mad/axp/builder.ctl @@ -7,10 +7,6 @@ set PROJDIR= [ INCLUDE "/build/prolog.ctl" ] -[ BLOCK .. .1. ] -#======================================= - set PROJNAME=madaxp - [ BLOCK .. .1. ] #=========================== [ INCLUDE "/build/deflib.ctl" ] diff --git a/bld/mad/master.mif b/bld/mad/master.mif index 244e790a1e..62930da72a 100644 --- a/bld/mad/master.mif +++ b/bld/mad/master.mif @@ -32,9 +32,6 @@ sys_dll = 1 inc_dirs = -I. -I"../h" -I"../../h" -I"$(dig_dir)/h" $(dis_includes) $(extra_incs) extra_cpp_flags = $(dig_arch_cpp_flags) -!ifdef %OWUSE_FILENAME_VERSION -extra_cpp_flags += -DUSE_FILENAME_VERSION=$(bld_ver) -!endif extra_c_flags_i86 = -zu extra_c_flags_win = -zc @@ -57,11 +54,7 @@ extra_l_flags_dll_nt_axp = op dosseg # # names # -!ifdef %OWUSE_FILENAME_VERSION -dlltarg_name = mad$(dig_arch)$(bld_ver) -!else dlltarg_name = mad$(dig_arch) -!endif verrc_dll = $(dlltarg_name) !include verrc.mif diff --git a/bld/mad/mps/builder.ctl b/bld/mad/mps/builder.ctl index 3155f1a44f..cf2f2f5b24 100644 --- a/bld/mad/mps/builder.ctl +++ b/bld/mad/mps/builder.ctl @@ -7,10 +7,6 @@ set PROJDIR= [ INCLUDE "/build/prolog.ctl" ] -[ BLOCK .. .1. ] -#======================================= - set PROJNAME=madmps - [ BLOCK .. .1. ] #=========================== [ INCLUDE "/build/deflib.ctl" ] diff --git a/bld/mad/ppc/builder.ctl b/bld/mad/ppc/builder.ctl index 01441b25be..9eccd4a4c4 100644 --- a/bld/mad/ppc/builder.ctl +++ b/bld/mad/ppc/builder.ctl @@ -7,10 +7,6 @@ set PROJDIR= [ INCLUDE "/build/prolog.ctl" ] -[ BLOCK .. .1. ] -#======================================= - set PROJNAME=madppc - [ BLOCK .. .1. ] #=========================== [ INCLUDE "/build/deflib.ctl" ] diff --git a/bld/mad/x86/builder.ctl b/bld/mad/x86/builder.ctl index 03d68396e1..69c45ce96d 100644 --- a/bld/mad/x86/builder.ctl +++ b/bld/mad/x86/builder.ctl @@ -7,10 +7,6 @@ set PROJDIR= [ INCLUDE "/build/prolog.ctl" ] -[ BLOCK .. .1. ] -#======================================= - set PROJNAME=madx86 - [ BLOCK .. .1. ] #=========================== [ INCLUDE "/build/deflib.ctl" ] diff --git a/bld/sdk/drwat/master.mif b/bld/sdk/drwat/master.mif index 2213608c0c..b71be66b34 100644 --- a/bld/sdk/drwat/master.mif +++ b/bld/sdk/drwat/master.mif @@ -39,9 +39,6 @@ extra_cpp_flags = $(dig_arch_cpp_flags) !ifeq drwatcom_95 1 extra_cpp_flags += -DCHICAGO !endif -!ifdef %OWUSE_FILENAME_VERSION -extra_cpp_flags += -DUSE_FILENAME_VERSION=$(bld_ver) -!endif extra_cpp_flags_nt = -DNOUSE3D diff --git a/bld/trap/lcl/dos/dosx/c/dosxlink.c b/bld/trap/lcl/dos/dosx/c/dosxlink.c index 5ea9cb98d7..fd6b83cd42 100644 --- a/bld/trap/lcl/dos/dosx/c/dosxlink.c +++ b/bld/trap/lcl/dos/dosx/c/dosxlink.c @@ -106,36 +106,19 @@ #error Extender and helper names not defined #endif - #ifdef USE_FILENAME_VERSION - #if defined(ACAD) - #define HELPNAME "" - #elif defined(PHARLAP) - #define HELPNAME "PLSHEL" QUOTED( USE_FILENAME_VERSION ) ".EXP" - #define HELPNAME_DS "PEDHEL" QUOTED( USE_FILENAME_VERSION ) ".EXP" - #define HELPNAME_NS "PENHEL" QUOTED( USE_FILENAME_VERSION ) ".EXP" /* not supported yet */ - #elif defined(DOS4G) - /* name must be RSIHELP, it is checked by DOS4G extender */ - #define HELPNAME "RSIHELP.EXP" - #elif defined(CAUSEWAY) - #define HELPNAME "CWHEL" QUOTED( USE_FILENAME_VERSION ) ".EXE" - #elif defined(HX) - #define HELPNAME "HXHEL" QUOTED( USE_FILENAME_VERSION ) ".EXE" - #endif - #else - #if defined(ACAD) - #define HELPNAME "" - #elif defined(PHARLAP) - #define HELPNAME "PLSHELP.EXP" - #define HELPNAME_DS "PEDHELP.EXP" - #define HELPNAME_NS "PENHELP.EXP" /* not supported yet */ - #elif defined(DOS4G) - /* name must be RSIHELP, it is checked by DOS4G extender */ - #define HELPNAME "RSIHELP.EXP" - #elif defined(CAUSEWAY) - #define HELPNAME "CWHELP.EXE" - #elif defined(HX) - #define HELPNAME "HXHELP.EXE" - #endif + #if defined(ACAD) + #define HELPNAME "" + #elif defined(PHARLAP) + #define HELPNAME "PLSHELP.EXP" + #define HELPNAME_DS "PEDHELP.EXP" + #define HELPNAME_NS "PENHELP.EXP" /* not supported yet */ + #elif defined(DOS4G) + /* name must be RSIHELP, it is checked by DOS4G extender */ + #define HELPNAME "RSIHELP.EXP" + #elif defined(CAUSEWAY) + #define HELPNAME "CWHELP.EXE" + #elif defined(HX) + #define HELPNAME "HXHELP.EXE" #endif #define MK_LINEAR(p) ( ( (long)_FP_SEG( (void __far *)(p) ) << 4 ) + _FP_OFF( (void __far *)(p) ) ) diff --git a/bld/trap/master.mif b/bld/trap/master.mif index e0d5e374d8..d20c19a512 100644 --- a/bld/trap/master.mif +++ b/bld/trap/master.mif @@ -109,11 +109,6 @@ srv_prefix = $(srv) ! ifndef name name = std ! endif -! ifndef test -! ifdef %OWUSE_FILENAME_VERSION -name = $(name)$(bld_ver) -! endif -! endif !else ifdef name !else ifeq which SERVER ! ifdef remote_link @@ -124,19 +119,9 @@ name = $(srv_prefix)serv ! endif ! else name = $(srv_prefix)help -! ifndef test -! ifdef %OWUSE_FILENAME_VERSION -name = $(srv_prefix)hel$(bld_ver) -! endif -! endif ! endif !else name = $(srv) -! ifndef test -! ifdef %OWUSE_FILENAME_VERSION -name = $(srv)$(bld_ver) -! endif -! endif !endif !ifdef test @@ -162,9 +147,6 @@ dig_arch = $(target_cpu) # cflags stuff ############### extra_cpp_flags = -D$(which) $(dig_arch_cpp_flags) $(extra_cppflags) -!ifdef %OWUSE_FILENAME_VERSION -extra_cpp_flags += -DUSE_FILENAME_VERSION=$(bld_ver) -!endif !ifndef test !ifdef builtin_trap extra_cpp_flags += -DBUILTIN_TRAP_FILE diff --git a/bld/wprof/c/aboutmsg.c b/bld/wprof/c/aboutmsg.c index a6ed8eec5c..0ba92970ee 100644 --- a/bld/wprof/c/aboutmsg.c +++ b/bld/wprof/c/aboutmsg.c @@ -43,7 +43,7 @@ static char *AboutMessage[] = { "", - banner1t( "Execution Profiler" ), + banner1t( "Execution Profiler" STR_BITNESS ), banner1v( _WPROF_VERSION_ ), banner2, banner2a( 1987 ), diff --git a/bld/wprof/master.mif b/bld/wprof/master.mif index 612ddc93bd..b759824b87 100644 --- a/bld/wprof/master.mif +++ b/bld/wprof/master.mif @@ -34,9 +34,6 @@ inc_dirs = -I"../h" -I"$(wsample_dir)/h" $(aui_inc_dirs) $(gui_inc_dirs) $(ui_in $(commonui_inc_dirs) $(wpi_inc_dirs) $(hlpview_inc_dirs) -I"$(dig_dir)/h" extra_cpp_flags = $(dig_arch_cpp_flags) -!ifdef %OWUSE_FILENAME_VERSION -extra_cpp_flags += -DUSE_FILENAME_VERSION=$(bld_ver) -!endif !ifeq sys_windowed 1 extra_cpp_flags += -DGUI_IS_GUI extra_cpp_flags_os2 = -D__OS2_PM__ diff --git a/bld/wv/c/dbgparse.c b/bld/wv/c/dbgparse.c index fcf2b584a9..1b37f02f59 100644 --- a/bld/wv/c/dbgparse.c +++ b/bld/wv/c/dbgparse.c @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -311,23 +312,8 @@ bool LangLoad( const char *lang, size_t langlen ) { file_handle fh; bool ret; -#ifdef USE_FILENAME_VERSION - char lang_fname[13]; - size_t len; - #define STRXX(x) #x - #define STRX(x) STRXX(x) - - len = langlen; - if( len > 6 ) { - len = 6; - } - memcpy( lang_fname, lang, len ); - strcpy( lang_fname + len, STRX( USE_FILENAME_VERSION ) ); - fh = LocalPathOpen( lang_fname, len + 2, "prs" ); -#else fh = LocalPathOpen( lang, langlen, "prs" ); -#endif if( fh == NIL_HANDLE ) return( false ); ret = ReadAllSections( fh ); diff --git a/bld/wv/master.mif b/bld/wv/master.mif index 87cb47dfeb..b5706380c6 100644 --- a/bld/wv/master.mif +++ b/bld/wv/master.mif @@ -93,9 +93,6 @@ extra_cpp_flags += -D__NOUI__ !ifeq release 0 extra_cpp_flags += -DAUI_DBG !endif -!ifdef %OWUSE_FILENAME_VERSION -extra_cpp_flags += -DUSE_FILENAME_VERSION=$(bld_ver) -!endif !ifeq sys_windowed 1 extra_cpp_flags += -DGUI_IS_GUI -DUI_GUI extra_cpp_flags_os2 = -D__OS2_PM__ diff --git a/bld/wv/rfx/master.mif b/bld/wv/rfx/master.mif index 6a6af79453..e04cdf2ead 100644 --- a/bld/wv/rfx/master.mif +++ b/bld/wv/rfx/master.mif @@ -25,9 +25,6 @@ dig_arch = $(host_cpu) inc_dirs = -I.. -I"$(wv_dir)/h" -I"$(dig_dir)/h" -I"$(dig_dir)/c" -I"$(clib_dir)/h" extra_cpp_flags = -DBUILD_RFX -!ifdef %OWUSE_FILENAME_VERSION -extra_cpp_flags += -DUSE_FILENAME_VERSION=$(bld_ver) -!endif # # aflags diff --git a/bld/wv/ssl/master.mif b/bld/wv/ssl/master.mif index 28b1416565..5a71baf9ef 100644 --- a/bld/wv/ssl/master.mif +++ b/bld/wv/ssl/master.mif @@ -4,17 +4,10 @@ proj_name = wd_ssl !include cproj.mif -!ifdef %OWUSE_FILENAME_VERSION -fortran_prs = fortra$(bld_ver).prs -cpp_prs = cpp$(bld_ver).prs -c_prs = c$(bld_ver).prs -java_prs = java$(bld_ver).prs -!else fortran_prs = fortran.prs cpp_prs = cpp.prs c_prs = c.prs java_prs = java.prs -!endif prs_list = & $(fortran_prs) & diff --git a/bld/wv/wvobjs.mif b/bld/wv/wvobjs.mif index 8e56985ff1..c79ee1606e 100644 --- a/bld/wv/wvobjs.mif +++ b/bld/wv/wvobjs.mif @@ -87,8 +87,7 @@ eng_objs = & $(_subdir_)dbgupdt.obj & $(_subdir_)symcomp.obj & $(_subdir_)litwdeng.obj & - $(_subdir_)dbgcapt.obj & - $(_subdir_)autoenv.obj + $(_subdir_)dbgcapt.obj eng_objs_dos386 = & $(_subdir_)dsxfork.obj & diff --git a/build/mif/dllbase.mif b/build/mif/dllbase.mif index 4f652eef00..f227aefbe6 100644 --- a/build/mif/dllbase.mif +++ b/build/mif/dllbase.mif @@ -1,9 +1,5 @@ # toggle debugger DLL's base -!ifdef %OWUSE_FILENAME_VERSION -dll_start = 80000 -!else dll_start = 00000 -!endif # NT rtdll_dllbase_winnt_386_mathlib = op offset=0x6ff00000 # mtxxxx.dll (run-time DLL math library) rtdll_dllbase_winnt_386_clib = op offset=0x6fe00000 # clbxxxx.dll (run-time DLL C library) diff --git a/distrib/ow/master.mif b/distrib/ow/master.mif index e1c715d974..71d87378e9 100644 --- a/distrib/ow/master.mif +++ b/distrib/ow/master.mif @@ -73,9 +73,6 @@ mkinf_opt =-dIncl64=0 langdat_keys = -k ntx64 -k lx64 mkinf_opt =-dIncl64=1 !endif -!ifdef %OWUSE_FILENAME_VERSION -langdat_keys += -k newdbg -!endif #mkinf_opt_linux = -utf8 From 123da643fbbe12abf7212f211a5d2f4395d83f01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Mal=C3=A1k?= Date: Fri, 25 Aug 2023 05:36:09 +0200 Subject: [PATCH 012/258] remove unwanted change --- bld/wv/wvobjs.mif | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bld/wv/wvobjs.mif b/bld/wv/wvobjs.mif index c79ee1606e..8e56985ff1 100644 --- a/bld/wv/wvobjs.mif +++ b/bld/wv/wvobjs.mif @@ -87,7 +87,8 @@ eng_objs = & $(_subdir_)dbgupdt.obj & $(_subdir_)symcomp.obj & $(_subdir_)litwdeng.obj & - $(_subdir_)dbgcapt.obj + $(_subdir_)dbgcapt.obj & + $(_subdir_)autoenv.obj eng_objs_dos386 = & $(_subdir_)dsxfork.obj & From 8ae72e2c663de353fbc1312994546c40481b1518 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Fri, 25 Aug 2023 18:12:52 +0200 Subject: [PATCH 013/258] add DIGLoaderFind function implementation for Dr.Watcom --- bld/sdk/drwat/nt/digcli.c | 36 +++++++++++++++++++++++++++++++++++- bld/sdk/drwat/win/digcli.c | 35 ++++++++++++++++++++++++++++++++--- 2 files changed, 67 insertions(+), 4 deletions(-) diff --git a/bld/sdk/drwat/nt/digcli.c b/bld/sdk/drwat/nt/digcli.c index 14f34b5a9f..36a60c18b6 100644 --- a/bld/sdk/drwat/nt/digcli.c +++ b/bld/sdk/drwat/nt/digcli.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -36,9 +36,13 @@ #include #include #include +#include "digld.h" #include "dip.h" #include "dipimp.h" #include "madregs.h" +#include "pathgrp2.h" + +#include "clibext.h" /* @@ -207,3 +211,33 @@ unsigned DIGCLIENTRY( MachineData )( address addr, dig_info_type info_type, dig_ } return( 0 ); } + +size_t DIGLoader( Find )( dig_filetype ftype, const char *name, size_t name_len, const char *defext, char *result, size_t result_len ) +/************************************************************************************************************************************/ +{ + const char *ext; + char filename[256]; + pgroup2 pg; + size_t len; + + /* unused parameters */ (void)ftype; + + len = 0; + if( result_len > 0 ) { + result_len--; + strncpy( filename, name, name_len ); + filename[name_len] = '\0'; + _splitpath2( filename, pg.buffer, &pg.drive, &pg.dir, &pg.fname, &pg.ext ); + ext = pg.ext; + if( ext == NULL || *ext == '\0' ) { + ext = defext; + } + _makepath( filename, pg.drive, pg.dir, pg.fname, ext ); + len = strlen( filename ); + if( len > result_len ) + len = result_len; + strncpy( result, filename, len ); + result[len] = '\0'; + } + return( len ); +} diff --git a/bld/sdk/drwat/win/digcli.c b/bld/sdk/drwat/win/digcli.c index 4865a8ca98..3bbd17b908 100644 --- a/bld/sdk/drwat/win/digcli.c +++ b/bld/sdk/drwat/win/digcli.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -38,13 +38,12 @@ #include #include #include "sopen.h" +#include "digld.h" #include "dip.h" #include "dipimp.h" -#if 0 #include "pathgrp2.h" #include "clibext.h" -#endif //#define DEBUGOUT( x ) LBPrintf( ListBox, x ); @@ -220,3 +219,33 @@ unsigned DIGCLIENTRY( MachineData )( address addr, dig_info_type info_type, dig_ return( 0 ); } + +size_t DIGLoader( Find )( dig_filetype ftype, const char *name, size_t name_len, const char *defext, char *result, size_t result_len ) +/************************************************************************************************************************************/ +{ + const char *ext; + char filename[256]; + pgroup2 pg; + size_t len; + + /* unused parameters */ (void)ftype; + + len = 0; + if( result_len > 0 ) { + result_len--; + strncpy( filename, name, name_len ); + filename[name_len] = '\0'; + _splitpath2( filename, pg.buffer, &pg.drive, &pg.dir, &pg.fname, &pg.ext ); + ext = pg.ext; + if( ext == NULL || *ext == '\0' ) { + ext = defext; + } + _makepath( filename, pg.drive, pg.dir, pg.fname, ext ); + len = strlen( filename ); + if( len > result_len ) + len = result_len; + strncpy( result, filename, len ); + result[len] = '\0'; + } + return( len ); +} From d6a9c934801a6c7437194131564ff94f1f335c3d Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Fri, 25 Aug 2023 18:16:38 +0200 Subject: [PATCH 014/258] add DIGLoaderFind function implementation for all debugger platforms --- bld/wv/c/dbgfile.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bld/wv/c/dbgfile.c b/bld/wv/c/dbgfile.c index 2faa0a3d1d..a63e4bcc25 100644 --- a/bld/wv/c/dbgfile.c +++ b/bld/wv/c/dbgfile.c @@ -733,7 +733,6 @@ void PathInit( void ) #endif } -#if defined( __DOS__ ) || defined( __UNIX__ ) static size_t MakeName( const char *path, const char *name, size_t nlen, char *res, size_t rlen ) { char *p; @@ -830,6 +829,7 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *name, size_t name_len, return( len ); } +#if defined( __DOS__ ) || defined( __UNIX__ ) FILE *DIGLoader( Open )( const char *filename ) { return( fopen( filename, "rb" ) ); From b6ef59f1212eea1ce54fb5a9a05f8854978c0111 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Fri, 25 Aug 2023 18:20:33 +0200 Subject: [PATCH 015/258] add DIGLoaderFind function implementation for all trap platforms --- bld/trap/common/nt/ntdigl.c | 63 ++++++++++++++++++++++++++++++- bld/trap/common/os2/os2digl.c | 63 ++++++++++++++++++++++++++++++- bld/trap/common/os2v2/os22digl.c | 64 +++++++++++++++++++++++++++++++- bld/trap/common/rdos/rdosdigl.c | 63 ++++++++++++++++++++++++++++++- bld/trap/common/win/windigl.c | 63 ++++++++++++++++++++++++++++++- 5 files changed, 306 insertions(+), 10 deletions(-) diff --git a/bld/trap/common/nt/ntdigl.c b/bld/trap/common/nt/ntdigl.c index 0f48999e82..71236a7163 100644 --- a/bld/trap/common/nt/ntdigl.c +++ b/bld/trap/common/nt/ntdigl.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -31,4 +31,63 @@ ****************************************************************************/ -// Nothing to do here +#include +#include +#include "digld.h" +#include "servio.h" + + +size_t DIGLoader( Find )( dig_filetype ftype, const char *name, size_t name_len, const char *defext, char *result, size_t result_len ) +/************************************************************************************************************************************/ +{ + bool has_ext; + bool has_path; + char *p; + char trpfile[256]; + char c; + size_t len; + + /* unused parameters */ (void)ftype; + + has_ext = false; + has_path = false; + p = trpfile; + while( name_len-- > 0 ) { + c = *name++; + *p++ = c; + switch( c ) { + case '.': + has_ext = true; + break; + case '/': + case '\\': + has_ext = false; + /* fall through */ + case ':': + has_path = true; + break; + } + } + if( !has_ext ) { + *p++ = '.'; + while( (*p++ = *defext++) != '\0' ) { + /* nothing to do */ + } + } + *p = '\0'; + p = trpfile; + if( !has_path ) { + _searchenv( trpfile, "PATH", RWBuff ); + p = RWBuff; + } + len = strlen( p ); + if( result_len > 0 ) { + result_len--; + if( result_len > len ) + result_len = len; + if( result_len > 0 ) + strncpy( result, p, result_len ); + result[result_len] = '\0'; + } + return( len ); +} diff --git a/bld/trap/common/os2/os2digl.c b/bld/trap/common/os2/os2digl.c index 0f48999e82..71236a7163 100644 --- a/bld/trap/common/os2/os2digl.c +++ b/bld/trap/common/os2/os2digl.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -31,4 +31,63 @@ ****************************************************************************/ -// Nothing to do here +#include +#include +#include "digld.h" +#include "servio.h" + + +size_t DIGLoader( Find )( dig_filetype ftype, const char *name, size_t name_len, const char *defext, char *result, size_t result_len ) +/************************************************************************************************************************************/ +{ + bool has_ext; + bool has_path; + char *p; + char trpfile[256]; + char c; + size_t len; + + /* unused parameters */ (void)ftype; + + has_ext = false; + has_path = false; + p = trpfile; + while( name_len-- > 0 ) { + c = *name++; + *p++ = c; + switch( c ) { + case '.': + has_ext = true; + break; + case '/': + case '\\': + has_ext = false; + /* fall through */ + case ':': + has_path = true; + break; + } + } + if( !has_ext ) { + *p++ = '.'; + while( (*p++ = *defext++) != '\0' ) { + /* nothing to do */ + } + } + *p = '\0'; + p = trpfile; + if( !has_path ) { + _searchenv( trpfile, "PATH", RWBuff ); + p = RWBuff; + } + len = strlen( p ); + if( result_len > 0 ) { + result_len--; + if( result_len > len ) + result_len = len; + if( result_len > 0 ) + strncpy( result, p, result_len ); + result[result_len] = '\0'; + } + return( len ); +} diff --git a/bld/trap/common/os2v2/os22digl.c b/bld/trap/common/os2v2/os22digl.c index 0f48999e82..70eafc1c4d 100644 --- a/bld/trap/common/os2v2/os22digl.c +++ b/bld/trap/common/os2v2/os22digl.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -31,4 +31,64 @@ ****************************************************************************/ -// Nothing to do here +#include +#include +#include "digld.h" +#include "servio.h" + + +size_t DIGLoader( Find )( dig_filetype ftype, const char *name, size_t name_len, const char *defext, char *result, size_t result_len ) +/************************************************************************************************************************************/ +{ + bool has_ext; + bool has_path; + char *p; + char trpfile[256]; + char c; + size_t len; + + /* unused parameters */ (void)ftype; + + has_ext = false; + has_path = false; + p = trpfile; + while( name_len-- > 0 ) { + c = *name++; + *p++ = c; + switch( c ) { + case '.': + has_ext = true; + break; + case '/': + case '\\': + has_ext = false; + /* fall through */ + case ':': + has_path = true; + break; + } + } + if( !has_ext ) { + *p++ = '.'; + while( (*p++ = *defext++) != '\0' ) { + /* nothing to do */ + } + } + *p = '\0'; + p = trpfile; + if( !has_path ) { + _searchenv( trpfile, "PATH", RWBuff ); + p = RWBuff; + } + len = strlen( p ); + if( result_len > 0 ) { + result_len--; + if( result_len > len ) + result_len = len; + if( result_len > 0 ) + strncpy( result, p, result_len ); + result[result_len] = '\0'; + } + return( len ); +} + diff --git a/bld/trap/common/rdos/rdosdigl.c b/bld/trap/common/rdos/rdosdigl.c index 0f48999e82..71236a7163 100644 --- a/bld/trap/common/rdos/rdosdigl.c +++ b/bld/trap/common/rdos/rdosdigl.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -31,4 +31,63 @@ ****************************************************************************/ -// Nothing to do here +#include +#include +#include "digld.h" +#include "servio.h" + + +size_t DIGLoader( Find )( dig_filetype ftype, const char *name, size_t name_len, const char *defext, char *result, size_t result_len ) +/************************************************************************************************************************************/ +{ + bool has_ext; + bool has_path; + char *p; + char trpfile[256]; + char c; + size_t len; + + /* unused parameters */ (void)ftype; + + has_ext = false; + has_path = false; + p = trpfile; + while( name_len-- > 0 ) { + c = *name++; + *p++ = c; + switch( c ) { + case '.': + has_ext = true; + break; + case '/': + case '\\': + has_ext = false; + /* fall through */ + case ':': + has_path = true; + break; + } + } + if( !has_ext ) { + *p++ = '.'; + while( (*p++ = *defext++) != '\0' ) { + /* nothing to do */ + } + } + *p = '\0'; + p = trpfile; + if( !has_path ) { + _searchenv( trpfile, "PATH", RWBuff ); + p = RWBuff; + } + len = strlen( p ); + if( result_len > 0 ) { + result_len--; + if( result_len > len ) + result_len = len; + if( result_len > 0 ) + strncpy( result, p, result_len ); + result[result_len] = '\0'; + } + return( len ); +} diff --git a/bld/trap/common/win/windigl.c b/bld/trap/common/win/windigl.c index 0f48999e82..71236a7163 100644 --- a/bld/trap/common/win/windigl.c +++ b/bld/trap/common/win/windigl.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -31,4 +31,63 @@ ****************************************************************************/ -// Nothing to do here +#include +#include +#include "digld.h" +#include "servio.h" + + +size_t DIGLoader( Find )( dig_filetype ftype, const char *name, size_t name_len, const char *defext, char *result, size_t result_len ) +/************************************************************************************************************************************/ +{ + bool has_ext; + bool has_path; + char *p; + char trpfile[256]; + char c; + size_t len; + + /* unused parameters */ (void)ftype; + + has_ext = false; + has_path = false; + p = trpfile; + while( name_len-- > 0 ) { + c = *name++; + *p++ = c; + switch( c ) { + case '.': + has_ext = true; + break; + case '/': + case '\\': + has_ext = false; + /* fall through */ + case ':': + has_path = true; + break; + } + } + if( !has_ext ) { + *p++ = '.'; + while( (*p++ = *defext++) != '\0' ) { + /* nothing to do */ + } + } + *p = '\0'; + p = trpfile; + if( !has_path ) { + _searchenv( trpfile, "PATH", RWBuff ); + p = RWBuff; + } + len = strlen( p ); + if( result_len > 0 ) { + result_len--; + if( result_len > len ) + result_len = len; + if( result_len > 0 ) + strncpy( result, p, result_len ); + result[result_len] = '\0'; + } + return( len ); +} From 690806ea2f2f071b45fde800f72ec496e85548b1 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Fri, 25 Aug 2023 18:40:28 +0200 Subject: [PATCH 016/258] add DIGLoaderFind function implementation for all wprof platforms --- bld/wprof/c/utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bld/wprof/c/utils.c b/bld/wprof/c/utils.c index 75187369d5..2e43e35f08 100644 --- a/bld/wprof/c/utils.c +++ b/bld/wprof/c/utils.c @@ -149,7 +149,6 @@ char *FindHelpFile( char *fullname, const char *help_name ) return( fullname ); } -#if defined( __UNIX__ ) || defined( __DOS__ ) size_t DIGLoader( Find )( dig_filetype ftype, const char *name, size_t name_len, const char *defext, char *result, size_t result_len ) /************************************************************************************************************************************/ { @@ -185,6 +184,7 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *name, size_t name_len, return( len ); } +#if defined( __UNIX__ ) || defined( __DOS__ ) FILE *DIGLoader( Open )( const char *filename ) /*********************************************/ { From 81feccb841a1f10dc828724a2aa7d69cfa6bc4c5 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Fri, 25 Aug 2023 23:25:44 +0200 Subject: [PATCH 017/258] cleanup debugger code use NULLCHAR macro for string terminator --- bld/wv/c/dbgfile.c | 4 ++-- bld/wv/c/dbgprog.c | 4 ++-- bld/wv/c/dbgshow.c | 4 ++-- bld/wv/c/dlgnewws.c | 4 ++-- bld/wv/nt/c/ntdbgpb.c | 4 ++-- bld/wv/rfx/localnt.c | 8 ++++---- bld/wv/rfx/localos2.c | 4 ++-- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/bld/wv/c/dbgfile.c b/bld/wv/c/dbgfile.c index a63e4bcc25..53dc2b2c5e 100644 --- a/bld/wv/c/dbgfile.c +++ b/bld/wv/c/dbgfile.c @@ -747,7 +747,7 @@ static size_t MakeName( const char *path, const char *name, size_t nlen, char *r --rlen; // save space for terminator len = 0; if( path != NULL ) { - while( len < rlen && *path != '\0' ) { + while( len < rlen && *path != NULLCHAR ) { *p++ = *path++; ++len; } @@ -824,7 +824,7 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *name, size_t name_len, result_len = len; if( result_len > 0 ) strncpy( result, p, result_len ); - result[result_len] = '\0'; + result[result_len] = NULLCHAR; } return( len ); } diff --git a/bld/wv/c/dbgprog.c b/bld/wv/c/dbgprog.c index 191fddde2a..6f2c3dfa5b 100644 --- a/bld/wv/c/dbgprog.c +++ b/bld/wv/c/dbgprog.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -1561,7 +1561,7 @@ bool SymUserModLoad( const char *fname, address *loadaddr ) map_entry **owner; map_entry *curr; - if( *fname == '\0' ) + if( *fname == NULLCHAR ) return( true ); image = DoCreateImage( fname, fname ); diff --git a/bld/wv/c/dbgshow.c b/bld/wv/c/dbgshow.c index da4ba487b2..fe2def87b5 100644 --- a/bld/wv/c/dbgshow.c +++ b/bld/wv/c/dbgshow.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -151,7 +151,7 @@ void DoConfig( const char *cmd, const char *name_tab, void(**jmp_tab)( void ), b *ptr++ = ' '; if( ScanEOC() ) { /* show configuration on everything */ - while( name_tab[0] != '\0' ) { + while( name_tab[0] != NULLCHAR ) { p = ptr; for( ;; ) { *p = tolower( *name_tab++ ); diff --git a/bld/wv/c/dlgnewws.c b/bld/wv/c/dlgnewws.c index 938d6d0d33..ab85186931 100644 --- a/bld/wv/c/dlgnewws.c +++ b/bld/wv/c/dlgnewws.c @@ -89,11 +89,11 @@ static bool newSymGUIEventProc( gui_window *gui, gui_event gui_ev, void *param ) case GUI_INIT_DIALOG: GUISetText( gui, CTL_EDIT, dlgnew->buff ); GUISetFocus( gui, CTL_EDIT ); - dlgnew->buff[0] = '\0'; + dlgnew->buff[0] = NULLCHAR; return( true ); case GUI_CONTROL_CLICKED: GUI_GETID( param, id ); - dlgnew->buff[0] = '\0'; + dlgnew->buff[0] = NULLCHAR; switch( id ) { case CTL_OK: GUIDlgBuffGetText( gui, CTL_EDIT, dlgnew->buff, dlgnew->buff_len ); diff --git a/bld/wv/nt/c/ntdbgpb.c b/bld/wv/nt/c/ntdbgpb.c index c9e3aa1fde..e7ef5e533d 100644 --- a/bld/wv/nt/c/ntdbgpb.c +++ b/bld/wv/nt/c/ntdbgpb.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -53,7 +53,7 @@ BOOL CALLBACK FindPidPB( HWND hwnd, LPARAM lParam ) lParam=lParam; len = GetClassName( hwnd, buff, sizeof( buff ) ); - buff[len] = '\0'; + buff[len] = NULLCHAR; if( strstr( buff, "PBFRAME" ) != NULL ) { GetWindowThreadProcessId(hwnd, &PidPB ); } diff --git a/bld/wv/rfx/localnt.c b/bld/wv/rfx/localnt.c index 4fadbbb722..72630e6124 100644 --- a/bld/wv/rfx/localnt.c +++ b/bld/wv/rfx/localnt.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2015-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2015-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -133,7 +133,7 @@ error_handle LocalSetDrv( int drv ) dir[0] = drv + 'A'; dir[1] = '\\'; dir[2] = '.'; - dir[3] = '\0'; + dir[3] = NULLCHAR; if( SetCurrentDirectory( dir ) ) { rc = GetCurrentDirectory( sizeof( dir ), dir ); @@ -247,10 +247,10 @@ static void makeDTARFX( rfx_find *info, LPWIN32_FIND_DATA ffd ) info->size = ffd->nFileSizeLow; #if RFX_NAME_MAX < MAX_PATH strncpy( info->name, ffd->cFileName, RFX_NAME_MAX ); - info->name[RFX_NAME_MAX] = '\0'; + info->name[RFX_NAME_MAX] = NULLCHAR; #else strncpy( info->name, ffd->cFileName, MAX_PATH - 1 ); - info->name[MAX_PATH - 1] = '\0'; + info->name[MAX_PATH - 1] = NULLCHAR; #endif } diff --git a/bld/wv/rfx/localos2.c b/bld/wv/rfx/localos2.c index 19460ee3fc..7ff14046c0 100644 --- a/bld/wv/rfx/localos2.c +++ b/bld/wv/rfx/localos2.c @@ -286,10 +286,10 @@ static void makeDTARFX( rfx_find *info, FINDBUF *findbuf ) info->size = findbuf->cbFile; #if RFX_NAME_MAX < CCHMAXPATHCOMP strncpy( info->name, findbuf->achName, RFX_NAME_MAX ); - info->name[RFX_NAME_MAX] = '\0'; + info->name[RFX_NAME_MAX] = NULLCHAR; #else strncpy( info->name, findbuf->achName, CCHMAXPATHCOMP ); - info->name[CCHMAXPATHCOMP] = '\0'; + info->name[CCHMAXPATHCOMP] = NULLCHAR; #endif } From 79c8118f91c0caee237e6c7beccd05737a4972ec Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Sat, 26 Aug 2023 00:07:39 +0200 Subject: [PATCH 018/258] rename symbols for consistency --- bld/dig/c/dsx/dipld.c | 6 +++--- bld/dig/c/dsx/madld.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bld/dig/c/dsx/dipld.c b/bld/dig/c/dsx/dipld.c index a0ad90d2da..c6240886a5 100644 --- a/bld/dig/c/dsx/dipld.c +++ b/bld/dig/c/dsx/dipld.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -52,7 +52,7 @@ void DIPSysUnload( dip_sys_handle *sys_hdl ) } } -dip_status DIPSysLoad( const char *name, dip_client_routines *cli, dip_imp_routines **imp, dip_sys_handle *sys_hdl ) +dip_status DIPSysLoad( const char *base_name, dip_client_routines *cli, dip_imp_routines **imp, dip_sys_handle *sys_hdl ) { FILE *fp; imp_header *dip; @@ -61,7 +61,7 @@ dip_status DIPSysLoad( const char *name, dip_client_routines *cli, dip_imp_routi char filename[_MAX_PATH]; *sys_hdl = NULL_SYSHDL; - if( DIGLoader( Find )( DIG_FILETYPE_EXE, name, strlen( name ), "dip", filename, sizeof( filename ) ) == 0 ) { + if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, strlen( base_name ), "dip", filename, sizeof( filename ) ) == 0 ) { return( DS_ERR | DS_FOPEN_FAILED ); } fp = DIGLoader( Open )( filename ); diff --git a/bld/dig/c/dsx/madld.c b/bld/dig/c/dsx/madld.c index ab5de89d7f..61cee81e38 100644 --- a/bld/dig/c/dsx/madld.c +++ b/bld/dig/c/dsx/madld.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2017 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -52,7 +52,7 @@ void MADSysUnload( mad_sys_handle *sys_hdl ) } } -mad_status MADSysLoad( const char *name, mad_client_routines *cli, +mad_status MADSysLoad( const char *base_name, mad_client_routines *cli, mad_imp_routines **imp, mad_sys_handle *sys_hdl ) { FILE *fp; @@ -62,7 +62,7 @@ mad_status MADSysLoad( const char *name, mad_client_routines *cli, char filename[256]; *sys_hdl = NULL_SYSHDL; - if( DIGLoader( Find )( DIG_FILETYPE_EXE, name, strlen( name ), "mad", filename, sizeof( filename ) ) == 0 ) { + if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, strlen( base_name ), "mad", filename, sizeof( filename ) ) == 0 ) { return( MS_ERR | MS_FOPEN_FAILED ); } fp = DIGLoader( Open )( filename ); From 1f625e7dbc734a3020088c4882ba8827080f1a7a Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Sat, 26 Aug 2023 09:52:52 +0200 Subject: [PATCH 019/258] cleanup trap module loader code --- bld/dig/c/dos/trpld.c | 33 +++++++++++++------------- bld/dig/c/dsx/trpld.c | 33 +++++++++++++------------- bld/dig/c/linux/trpld_pe.c | 24 +++++++++---------- bld/dig/c/linux/trpld_so.c | 21 +++++++++-------- bld/dig/c/nov/trpld.c | 12 ++++++---- bld/dig/c/nt/trpld.c | 15 ++++++------ bld/dig/c/os2/trpld.c | 40 +++++++++++++++----------------- bld/dig/c/qnx/trpld.c | 23 +++++++++--------- bld/dig/c/rdos/trpld.c | 13 ++++++----- bld/dig/c/win/trpld.c | 15 ++++++------ bld/trap/common/os2v2/os22digl.c | 4 ++-- 11 files changed, 121 insertions(+), 112 deletions(-) diff --git a/bld/dig/c/dos/trpld.c b/bld/dig/c/dos/trpld.c index c24727e09f..0c30b71bc2 100644 --- a/bld/dig/c/dos/trpld.c +++ b/bld/dig/c/dos/trpld.c @@ -121,35 +121,34 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) FILE *fp; trap_init_func *init_func; char filename[256]; - char *p; - char chr; + const char *trpname; + const char *err; + size_t len; if( parms == NULL || *parms == '\0' ) parms = DEFAULT_TRP_NAME; - p = filename; - for( ; (chr = *parms) != '\0'; parms++ ) { - if( chr == TRAP_PARM_SEPARATOR ) { + trpname = parms; + len = 0; + for( ; *parms != '\0'; parms++ ) { + if( *parms == TRAP_PARM_SEPARATOR ) { parms++; break; } - *p++ = chr; + len++; } - *p = '\0'; - sprintf( buff, "%s '%s'", TC_ERR_CANT_LOAD_TRAP, filename ); - if( DIGLoader( Find )( DIG_FILETYPE_EXE, filename, p - filename, "trp", filename, sizeof( filename ) ) == 0 ) { + if( DIGLoader( Find )( DIG_FILETYPE_EXE, trpname, len, "trp", filename, sizeof( filename ) ) == 0 ) { + sprintf( buff, "%s '%s'", TC_ERR_CANT_LOAD_TRAP, trpname ); return( buff ); } - sprintf( buff, "%s '%s'", TC_ERR_CANT_LOAD_TRAP, filename ); fp = DIGLoader( Open )( filename ); if( fp == NULL ) { + sprintf( buff, "%s '%s'", TC_ERR_CANT_LOAD_TRAP, filename ); return( buff ); } - p = ReadInTrap( fp ); + buff[0] = '\0'; + err = ReadInTrap( fp ); DIGLoader( Close )( fp ); - if( p != NULL ) { - strcpy( buff, p ); - } else { - strcpy( buff, TC_ERR_WRONG_TRAP_VERSION ); + if( err == NULL ) { if( TrapCode->signature == TRAP_SIGNATURE ) { init_func = _MK_FP( _FP_SEG( TrapCode ), TrapCode->init_off ); FiniFunc = _MK_FP( _FP_SEG( TrapCode ), TrapCode->fini_off ); @@ -160,10 +159,12 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) TrapVer = *trap_ver; return( NULL ); } - strcpy( buff, TC_ERR_WRONG_TRAP_VERSION ); } } + err = TC_ERR_WRONG_TRAP_VERSION; } + if( buff[0] == '\0' ) + strcpy( buff, err ); KillTrap(); return( buff ); } diff --git a/bld/dig/c/dsx/trpld.c b/bld/dig/c/dsx/trpld.c index edb4ed4682..e9deb56b28 100644 --- a/bld/dig/c/dsx/trpld.c +++ b/bld/dig/c/dsx/trpld.c @@ -484,22 +484,23 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) FILE *fp; trap_file_header __far *head; char filename[256]; - char *p; - char chr; + const char *trpname; + const char *err; + size_t len; if( parms == NULL || *parms == '\0' ) parms = DEFAULT_TRP_NAME; - p = filename; - for( ; (chr = *parms) != '\0'; parms++ ) { - if( chr == TRAP_PARM_SEPARATOR ) { + trpname = parms; + len = 0; + for( ; *parms != '\0'; parms++ ) { + if( *parms == TRAP_PARM_SEPARATOR ) { parms++; break; } - *p++ = chr; + len++; } - *p = '\0'; - sprintf( buff, "%s '%s'", TC_ERR_CANT_LOAD_TRAP, filename ); - if( DIGLoader( Find )( DIG_FILETYPE_EXE, filename, p - filename, "trp", filename, sizeof( filename ) ) == 0 ) { + if( DIGLoader( Find )( DIG_FILETYPE_EXE, trpname, len, "trp", filename, sizeof( filename ) ) == 0 ) { + sprintf( buff, "%s '%s'", TC_ERR_CANT_LOAD_TRAP, trpname ); return( buff ); } sprintf( buff, "%s '%s'", TC_ERR_CANT_LOAD_TRAP, filename ); @@ -507,13 +508,11 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) if( fp == NULL ) { return( buff ); } - p = ReadInTrap( fp ); + buff[0] = '\0'; + err = ReadInTrap( fp ); DIGLoader( Close )( fp ); - if( p == NULL ) { - if( (p = SetTrapHandler()) != NULL || (p = CopyEnv()) != NULL ) { - strcpy( buff, p ); - } else { - strcpy( buff, TC_ERR_WRONG_TRAP_VERSION ); + if( err == NULL ) { + if( (err = SetTrapHandler()) == NULL && (err = CopyEnv()) == NULL ) { head = EXTENDER_RM2PM( TrapMem.rm, 0 ); if( head->sig == TRAP_SIGNATURE ) { PMData->initfunc.s.offset = head->init; @@ -528,11 +527,13 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) ReqFunc = DoTrapAccess; return( NULL ); } - strcpy( buff, TC_ERR_WRONG_TRAP_VERSION ); } } + err = TC_ERR_WRONG_TRAP_VERSION; } } + if( buff[0] == '\0' ) + strcpy( buff, err ); KillTrap(); return( buff ); } diff --git a/bld/dig/c/linux/trpld_pe.c b/bld/dig/c/linux/trpld_pe.c index 273d48db7b..a67f3db3e2 100644 --- a/bld/dig/c/linux/trpld_pe.c +++ b/bld/dig/c/linux/trpld_pe.c @@ -80,31 +80,31 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) { trap_load_func *ld_func; const trap_requests *trap_funcs; - char chr; #if !defined( BUILTIN_TRAP_FILE ) FILE *fp; char filename[_MAX_PATH]; - char *p; + const char *trpname; + size_t len; #endif if( parms == NULL || *parms == '\0' ) parms = DEFAULT_TRP_NAME; #if !defined( BUILTIN_TRAP_FILE ) - p = filename; + trpname = parms; + len = 0; #endif - for( ; (chr = *parms) != '\0'; parms++ ) { - if( chr == TRAP_PARM_SEPARATOR ) { + for( ; *parms != '\0'; parms++ ) { + if( *parms == TRAP_PARM_SEPARATOR ) { parms++; break; } #if !defined( BUILTIN_TRAP_FILE ) - *p++ = chr; + len++; #endif } #if !defined( BUILTIN_TRAP_FILE ) - *p = '\0'; - sprintf( buff, "%s '%s'", TC_ERR_CANT_LOAD_TRAP, filename ); - if( DIGLoader( Find )( DIG_FILETYPE_EXE, filename, p - filename, "trp", filename, sizeof( filename ) ) == 0 ) { + if( DIGLoader( Find )( DIG_FILETYPE_EXE, trpname, len, "trp", filename, sizeof( filename ) ) == 0 ) { + sprintf( buff, "%s '%s'", TC_ERR_CANT_LOAD_TRAP, trpname ); return( buff ); } sprintf( buff, "%s '%s'", TC_ERR_CANT_LOAD_TRAP, filename ); @@ -117,11 +117,10 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) if( TrapFile == NULL ) { return( buff ); } - strcpy( buff, TC_ERR_WRONG_TRAP_VERSION ); + buff[0] = '\0'; ld_func = (trap_load_func *)PE_getProcAddress( TrapFile, "TrapLoad_" ); if( ld_func != NULL ) { #else - strcpy( buff, TC_ERR_WRONG_TRAP_VERSION ); ld_func = TrapLoad; #endif trap_funcs = ld_func( &TrapCallbacks ); @@ -134,12 +133,13 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) TrapVer = *trap_ver; return( NULL ); } - strcpy( buff, TC_ERR_WRONG_TRAP_VERSION ); } } #if !defined( BUILTIN_TRAP_FILE ) } #endif + if( buff[0] == '\0' ) + strcpy( buff, TC_ERR_WRONG_TRAP_VERSION ); KillTrap(); return( buff ); } diff --git a/bld/dig/c/linux/trpld_so.c b/bld/dig/c/linux/trpld_so.c index 3ed90961f3..b46f194531 100644 --- a/bld/dig/c/linux/trpld_so.c +++ b/bld/dig/c/linux/trpld_so.c @@ -83,16 +83,17 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) FILE *fp; trap_load_func *ld_func; const trap_requests *trap_funcs; - char chr; #if !defined( BUILTIN_TRAP_FILE ) char filename[_MAX_PATH]; - char *p; + const char *trpname; + size_t len; #endif if( parms == NULL || *parms == '\0' ) parms = DEFAULT_TRP_NAME; #if !defined( BUILTIN_TRAP_FILE ) - p = filename; + trpname = parms; + len = 0; #endif for( ; (chr = *parms) != '\0'; parms++ ) { if( chr == TRAP_PARM_SEPARATOR ) { @@ -100,13 +101,12 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) break; } #if !defined( BUILTIN_TRAP_FILE ) - *p++ = chr; + len++; #endif } #if !defined( BUILTIN_TRAP_FILE ) - *p = '\0'; - sprintf( buff, "%s '%s'", TC_ERR_CANT_LOAD_TRAP, filename ); - if( DIGLoader( Find )( DIG_FILETYPE_EXE, filename, p - filename, "so", filename, sizeof( filename ) ) == 0 ) { + if( DIGLoader( Find )( DIG_FILETYPE_EXE, trpname, len, "so", filename, sizeof( filename ) ) == 0 ) { + sprintf( buff, "%s '%s'", TC_ERR_CANT_LOAD_TRAP, trpname ); return( buff ); } sprintf( buff, "%s '%s'", TC_ERR_CANT_LOAD_TRAP, filename ); @@ -120,11 +120,11 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) puts( dlerror() ); return( buff ); } - strcpy( buff, TC_ERR_WRONG_TRAP_VERSION ); + buff[0] = '\0'; ld_func = (trap_load_func *)dlsym( TrapFile, "TrapLoad" ); if( ld_func != NULL ) { #else - strcpy( buff, TC_ERR_WRONG_TRAP_VERSION ); + buff[0] = '\0'; ld_func = TrapLoad; #endif trap_funcs = ld_func( &TrapCallbacks ); @@ -137,12 +137,13 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) TrapVer = *trap_ver; return( NULL ); } - strcpy( buff, TC_ERR_WRONG_TRAP_VERSION ); } } #if !defined( BUILTIN_TRAP_FILE ) } #endif + if( buff[0] == '\0' ) + strcpy( buff, TC_ERR_WRONG_TRAP_VERSION ); KillTrap(); return( buff ); } diff --git a/bld/dig/c/nov/trpld.c b/bld/dig/c/nov/trpld.c index 5b75fba381..83e2af7c0c 100644 --- a/bld/dig/c/nov/trpld.c +++ b/bld/dig/c/nov/trpld.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -44,15 +44,19 @@ void KillTrap( void ) char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) { - char chr; + const char *trpname; + size_t len; if( parms == NULL || *parms == '\0' ) parms = DEFAULT_TRP_NAME; - for( ; (chr = *parms) != '\0'; parms++ ) { - if( chr == TRAP_PARM_SEPARATOR ) { + trpname = parms; + len = 0; + for( ; *parms != '\0'; parms++ ) { + if( *parms == TRAP_PARM_SEPARATOR ) { parms++; break; } + len++; } *trap_ver = TrapInit( parms, buff, trap_ver->remote ); if( buff[0] == '\0' ) { diff --git a/bld/dig/c/nt/trpld.c b/bld/dig/c/nt/trpld.c index 94418a9c19..11e15658fd 100644 --- a/bld/dig/c/nt/trpld.c +++ b/bld/dig/c/nt/trpld.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -96,7 +96,7 @@ void KillTrap( void ) char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) { - char trpfile[256]; + char filename[256]; char *p; bool have_ext; char chr; @@ -105,7 +105,7 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) if( parms == NULL || *parms == '\0' ) parms = DEFAULT_TRP_NAME; have_ext = false; - p = trpfile; + p = filename; for( ; (chr = *parms) != '\0'; parms++ ) { if( chr == TRAP_PARM_SEPARATOR ) { parms++; @@ -130,9 +130,9 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) *p++ = 'l'; } *p = '\0'; - TrapFile = LoadLibrary( trpfile ); + TrapFile = LoadLibrary( filename ); if( TrapFile == NULL ) { - sprintf( buff, "%s '%s'", TC_ERR_CANT_LOAD_TRAP, trpfile ); + sprintf( buff, "%s '%s'", TC_ERR_CANT_LOAD_TRAP, filename ); return( buff ); } init_func = (trap_init_func *)GetProcAddress( TrapFile, (LPSTR)1 ); @@ -141,7 +141,7 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) TRAP_EXTFUNC_PTR( InfoFunction ) = (TRAP_EXTFUNC_TYPE( InfoFunction ))GetProcAddress( TrapFile, (LPSTR)4 ); TRAP_EXTFUNC_PTR( InterruptProgram ) = (TRAP_EXTFUNC_TYPE( InterruptProgram ))GetProcAddress( TrapFile, (LPSTR)5 ); TRAP_EXTFUNC_PTR( Terminate ) = (TRAP_EXTFUNC_TYPE( Terminate ))GetProcAddress( TrapFile, (LPSTR)6 ); - strcpy( buff, TC_ERR_WRONG_TRAP_VERSION ); + buff[0] = '\0'; if( init_func != NULL && FiniFunc != NULL && ReqFunc != NULL ) { *trap_ver = init_func( parms, buff, trap_ver->remote ); if( buff[0] == '\0' ) { @@ -149,9 +149,10 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) TrapVer = *trap_ver; return( NULL ); } - strcpy( buff, TC_ERR_WRONG_TRAP_VERSION ); } } + if( buff[0] == '\0' ) + strcpy( buff, TC_ERR_WRONG_TRAP_VERSION ); KillTrap(); return( buff ); } diff --git a/bld/dig/c/os2/trpld.c b/bld/dig/c/os2/trpld.c index 64e412ca82..58a54c82c5 100644 --- a/bld/dig/c/os2/trpld.c +++ b/bld/dig/c/os2/trpld.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -105,14 +105,12 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) char *p; char chr; trap_init_func *init_func; - char trpfile[CCHMAXPATH]; -#ifndef _M_I86 + char filename[CCHMAXPATH]; char trpname[CCHMAXPATH]; -#endif if( parms == NULL || *parms == '\0' ) parms = DEFAULT_TRP_NAME; - p = trpfile; + p = trpname; for( ; (chr = *parms) != '\0'; parms++ ) { if( chr == TRAP_PARM_SEPARATOR ) { parms++; @@ -120,41 +118,40 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) } *p++ = chr; } + *p = '\0'; #ifdef _M_I86 - if( LOW( trpfile[0] ) == 's' && LOW( trpfile[1] ) == 't' - && LOW( trpfile[2] ) == 'd' && trpfile[3] == '\0' ) { + if( LOW( trpname[0] ) == 's' && LOW( trpname[1] ) == 't' + && LOW( trpname[2] ) == 'd' && trpname[3] == '\0' ) { unsigned version; char os2ver; DosGetVersion( (PUSHORT)&version ); os2ver = version >> 8; if( os2ver >= 20 ) { - *p++ = '3'; - *p++ = '2'; + strcpy( trpname, "std32" ); } else { - *p++ = '1'; - *p++ = '6'; + strcpy( trpname, "std16" ); } } #endif - *p = '\0'; -#ifndef _M_I86 /* To prevent conflicts with the 16-bit DIP DLLs, the 32-bit versions have the "D32" * extension. We will search for them along the PATH (not in LIBPATH); */ - strcpy( trpname, trpfile ); +#ifdef _M_I86 + strcat( trpname, ".DLL" ); +#else strcat( trpname, ".D32" ); - _searchenv( trpname, "PATH", trpfile ); - if( *trpfile == '\0' ) { +#endif + _searchenv( trpname, "PATH", filename ); + if( *filename == '\0' ) { sprintf( buff, "%s '%s'", TC_ERR_CANT_LOAD_TRAP, trpname ); return( buff ); } -#endif - if( LOAD_MODULE( trpfile, TrapFile ) ) { - sprintf( buff, "%s '%s'", TC_ERR_CANT_LOAD_TRAP, trpfile ); + if( LOAD_MODULE( filename, TrapFile ) ) { + sprintf( buff, "%s '%s'", TC_ERR_CANT_LOAD_TRAP, filename ); return( buff ); } - strcpy( buff, TC_ERR_WRONG_TRAP_VERSION ); + buff[0] = '\0'; if( GET_PROC_ADDRESS( TrapFile, 1, init_func ) && GET_PROC_ADDRESS( TrapFile, 2, FiniFunc ) && GET_PROC_ADDRESS( TrapFile, 3, ReqFunc ) ) { @@ -170,9 +167,10 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) TrapVer = *trap_ver; return( NULL ); } - strcpy( buff, TC_ERR_WRONG_TRAP_VERSION ); } } + if( buff[0] == '\0' ) + strcpy( buff, TC_ERR_WRONG_TRAP_VERSION ); KillTrap(); return( buff ); } diff --git a/bld/dig/c/qnx/trpld.c b/bld/dig/c/qnx/trpld.c index ffb40a7a8c..cf3f0c47f6 100644 --- a/bld/dig/c/qnx/trpld.c +++ b/bld/dig/c/qnx/trpld.c @@ -82,22 +82,22 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) trap_load_func *ld_func; const trap_requests *trap_funcs; char filename[256]; - char *p; - char chr; + const char *trpname; + size_t len; if( parms == NULL || *parms == '\0' ) parms = DEFAULT_TRP_NAME; - p = filename; - for( ; (chr = *parms) != '\0'; parms++ ) { - if( chr == TRAP_PARM_SEPARATOR ) { + trpname = parms;; + len = 0; + for( ; *parms != '\0'; parms++ ) { + if( *parms == TRAP_PARM_SEPARATOR ) { parms++; break; } - *p++ = chr; + len++; } - *p = '\0'; - sprintf( buff, "%s '%s'", TC_ERR_CANT_LOAD_TRAP, filename ); - if( DIGLoader( Find )( DIG_FILETYPE_EXE, filename, p - filename, "trp", filename, sizeof( filename ) ) ) { + if( DIGLoader( Find )( DIG_FILETYPE_EXE, trpname, len, "trp", filename, sizeof( filename ) ) ) { + sprintf( buff, "%s '%s'", TC_ERR_CANT_LOAD_TRAP, trpname ); return( buff ); } sprintf( buff, "%s '%s'", TC_ERR_CANT_LOAD_TRAP, filename ); @@ -108,10 +108,10 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) TrapCode = ReadInImp( fp ); DIGLoader( Close )( fp ); if( TrapCode != NULL ) { + buff[0] = '\0'; #ifdef __WATCOMC__ if( TrapCode->sig == TRAPSIG ) { #endif - strcpy( buff, TC_ERR_BAD_TRAP_FILE ); ld_func = (trap_load_func *)TrapCode->init_rtn; trap_funcs = ld_func( &TrapCallbacks ); if( trap_funcs != NULL ) { @@ -123,12 +123,13 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) TrapVer = *trap_ver; return( NULL ); } - strcpy( buff, TC_ERR_BAD_TRAP_FILE ); } } #ifdef __WATCOMC__ } #endif + if( buff[0] == '\0' ) + strcpy( buff, TC_ERR_BAD_TRAP_FILE ); KillTrap(); } return( buff ); diff --git a/bld/dig/c/rdos/trpld.c b/bld/dig/c/rdos/trpld.c index f5cc419138..8307ea6a92 100644 --- a/bld/dig/c/rdos/trpld.c +++ b/bld/dig/c/rdos/trpld.c @@ -56,7 +56,7 @@ void KillTrap( void ) char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) { - char trpfile[256]; + char filename[256]; char *p; char chr; bool have_ext; @@ -65,7 +65,7 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) if( parms == NULL || *parms == '\0' ) parms = DEFAULT_TRP_NAME; have_ext = false; - p = trpfile; + p = filename; for( ; (chr = *parms) != '\0'; parms++ ) { if( chr == TRAP_PARM_SEPARATOR ) { parms++; @@ -90,16 +90,16 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) *p++ = 'l'; } *p = '\0'; - TrapFile = RdosLoadDll( trpfile ); + TrapFile = RdosLoadDll( filename ); if( TrapFile == NULL ) { - sprintf( buff, "%s '%s'", TC_ERR_CANT_LOAD_TRAP, trpfile ); + sprintf( buff, "%s '%s'", TC_ERR_CANT_LOAD_TRAP, filename ); return( buff ); } + buff[0] = '\0'; init_func = RdosGetModuleProc( TrapFile, "TrapInit_" ); FiniFunc = RdosGetModuleProc( TrapFile, "TrapFini_" ); ReqFunc = RdosGetModuleProc( TrapFile, "TrapRequest_" ); // LibListFunc = RdosGetModuleProc( TrapFile, "TrapLibList_" ); - strcpy( buff, TC_ERR_WRONG_TRAP_VERSION ); if( init_func != NULL && FiniFunc != NULL && ReqFunc != NULL /* && LibListFunc != NULL */ ) { *trap_ver = init_func( parms, buff, trap_ver->remote ); if( buff[0] == '\0' ) { @@ -107,9 +107,10 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) TrapVer = *trap_ver; return( NULL ); } - strcpy( buff, TC_ERR_WRONG_TRAP_VERSION ); } } + if( buff[0] == '\0' ) + strcpy( buff, TC_ERR_WRONG_TRAP_VERSION ); KillTrap(); return( buff ); } diff --git a/bld/dig/c/win/trpld.c b/bld/dig/c/win/trpld.c index 6f0da056ba..b9424445c9 100644 --- a/bld/dig/c/win/trpld.c +++ b/bld/dig/c/win/trpld.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -80,7 +80,7 @@ void KillTrap( void ) char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) { - char trpfile[256]; + char filename[256]; char *p; char chr; bool have_ext; @@ -90,7 +90,7 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) if( parms == NULL || *parms == '\0' ) parms = DEFAULT_TRP_NAME; have_ext = false; - p = trpfile; + p = filename; for( ; (chr = *parms) != '\0'; parms++ ) { if( chr == TRAP_PARM_SEPARATOR ) { parms++; @@ -124,13 +124,14 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) toolhelp = 0; } prev = SetErrorMode( SEM_NOOPENFILEERRORBOX ); - TrapFile = LoadLibrary( trpfile ); + TrapFile = LoadLibrary( filename ); SetErrorMode( prev ); if( (UINT)TrapFile < 32 ) { TrapFile = 0; - sprintf( buff, "%s '%s'", TC_ERR_CANT_LOAD_TRAP, trpfile ); + sprintf( buff, "%s '%s'", TC_ERR_CANT_LOAD_TRAP, filename ); return( buff ); } + buff[0] = '\0'; init_func = (trap_init_func *)GetProcAddress( TrapFile, (LPSTR)2 ); FiniFunc = (trap_fini_func *)GetProcAddress( TrapFile, (LPSTR)3 ); ReqFunc = (trap_req_func *)GetProcAddress( TrapFile, (LPSTR)4 ); @@ -140,7 +141,6 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) TRAP_EXTFUNC_PTR( GetHwndFunc ) = (TRAP_EXTFUNC_TYPE( GetHwndFunc ))GetProcAddress( TrapFile, (LPSTR)8 ); TRAP_EXTFUNC_PTR( SetHardMode ) = (TRAP_EXTFUNC_TYPE( SetHardMode ))GetProcAddress( TrapFile, (LPSTR)12 ); TRAP_EXTFUNC_PTR( UnLockInput ) = (TRAP_EXTFUNC_TYPE( UnLockInput ))GetProcAddress( TrapFile, (LPSTR)13 ); - strcpy( buff, TC_ERR_WRONG_TRAP_VERSION ); if( init_func != NULL && FiniFunc != NULL && ReqFunc != NULL ) { *trap_ver = init_func( parms, buff, trap_ver->remote ); if( buff[0] == '\0' ) { @@ -148,9 +148,10 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) TrapVer = *trap_ver; return( NULL ); } - strcpy( buff, TC_ERR_WRONG_TRAP_VERSION ); } } + if( buff[0] == '\0' ) + strcpy( buff, TC_ERR_WRONG_TRAP_VERSION ); KillTrap(); return( buff ); } diff --git a/bld/trap/common/os2v2/os22digl.c b/bld/trap/common/os2v2/os22digl.c index 70eafc1c4d..d77b8ee958 100644 --- a/bld/trap/common/os2v2/os22digl.c +++ b/bld/trap/common/os2v2/os22digl.c @@ -62,7 +62,7 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *name, size_t name_len, case '/': case '\\': has_ext = false; - /* fall through */ + /* fall through */ case ':': has_path = true; break; @@ -71,7 +71,7 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *name, size_t name_len, if( !has_ext ) { *p++ = '.'; while( (*p++ = *defext++) != '\0' ) { - /* nothing to do */ + ; /* nothing to do */ } } *p = '\0'; From 9deef2005cb940ff2a0c67850ea1e4abe2516d82 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Sat, 26 Aug 2023 10:43:45 +0200 Subject: [PATCH 020/258] reformat source files --- bld/dig/c/dos/trpld.c | 2 +- bld/dig/c/dsx/dipld.c | 10 ++- bld/dig/c/dsx/ldimp.c | 6 +- bld/dig/c/dsx/madld.c | 2 +- bld/dig/c/dsx/trpld.c | 38 +++++----- bld/dig/c/linux/dipld_so.c | 3 +- bld/dig/c/linux/madld_so.c | 3 +- bld/dig/c/linux/peloader.c | 141 ++++++++++++++++++++++++------------- bld/dig/c/linux/trpld_pe.c | 2 +- bld/dig/c/linux/trpld_so.c | 2 +- bld/dig/c/nov/trpld.c | 1 + bld/dig/c/nt/dipld.c | 3 +- bld/dig/c/nt/madld.c | 4 +- bld/dig/c/nt/trpld.c | 1 + bld/dig/c/os2/dipld.c | 6 +- bld/dig/c/os2/madld.c | 6 +- bld/dig/c/os2/trpld.c | 4 +- bld/dig/c/qnx/pillld.c | 4 +- bld/dig/c/rdos/dipld.c | 3 +- bld/dig/c/rdos/madld.c | 4 +- bld/dig/c/rdos/trpld.c | 1 + bld/dig/c/win/dipld.c | 3 +- bld/dig/c/win/madld.c | 3 +- bld/dig/c/win/trpld.c | 1 + 24 files changed, 164 insertions(+), 89 deletions(-) diff --git a/bld/dig/c/dos/trpld.c b/bld/dig/c/dos/trpld.c index 0c30b71bc2..e0c6691e5b 100644 --- a/bld/dig/c/dos/trpld.c +++ b/bld/dig/c/dos/trpld.c @@ -37,9 +37,9 @@ #include #include "tinyio.h" #include "exedos.h" +#include "digld.h" #include "trpld.h" #include "tcerr.h" -#include "digld.h" #define TRAP_SIGNATURE 0xDEAF diff --git a/bld/dig/c/dsx/dipld.c b/bld/dig/c/dsx/dipld.c index c6240886a5..18e878a52c 100644 --- a/bld/dig/c/dsx/dipld.c +++ b/bld/dig/c/dsx/dipld.c @@ -33,19 +33,21 @@ #include #include #include +#include "digld.h" #include "dip.h" #include "dipimp.h" #include "dipsys.h" #include "ldimp.h" #include "dbgmod.h" -#include "digld.h" #define DIPSIG 0x00504944UL // "DIP" void DIPSysUnload( dip_sys_handle *sys_hdl ) { - /* We should unload the symbols here but it's not worth the trouble */ + /* + * We should unload the symbols here but it's not worth the trouble + */ if( *sys_hdl != NULL_SYSHDL ) { DIGCli( Free )( *sys_hdl ); *sys_hdl = NULL_SYSHDL; @@ -76,7 +78,9 @@ dip_status DIPSysLoad( const char *base_name, dip_client_routines *cli, dip_imp_ if( dip->sig == DIPSIG ) { #endif #ifdef WATCOM_DEBUG_SYMBOLS - /* Look for symbols in separate .sym files, not the .dip itself */ + /* + * Look for symbols in separate .sym files, not the .dip itself + */ strcpy( filename + strlen( filename ) - 4, ".sym" ); DebuggerLoadUserModule( filename, GetCS(), (unsigned long)dip ); #endif diff --git a/bld/dig/c/dsx/ldimp.c b/bld/dig/c/dsx/ldimp.c index d12b6b8f1d..7432e2d52a 100644 --- a/bld/dig/c/dsx/ldimp.c +++ b/bld/dig/c/dsx/ldimp.c @@ -33,7 +33,8 @@ ****************************************************************************/ -/* Usage of the Prarlap executable Loader +/* + * Usage of the Prarlap executable Loader * * Host OS TRAP MAD DIP * @@ -104,7 +105,8 @@ imp_header *ReadInImp( FILE *fp ) hdr.num_relocs -= bunch; } #ifdef __LINUX__ - /* On some platforms (such as AMD64 or x86 with NX bit), it is required + /* + * On some platforms (such as AMD64 or x86 with NX bit), it is required * to map the code pages loaded from the BPD as executable, otherwise * a segfault will occur when attempting to run any BPD code. */ diff --git a/bld/dig/c/dsx/madld.c b/bld/dig/c/dsx/madld.c index 61cee81e38..e70b2c6443 100644 --- a/bld/dig/c/dsx/madld.c +++ b/bld/dig/c/dsx/madld.c @@ -34,12 +34,12 @@ #include #include #include +#include "digld.h" #include "mad.h" #include "madimp.h" #include "madcli.h" #include "madsys.h" #include "ldimp.h" -#include "digld.h" #define MADSIG 0x0044414DUL // "MAD" diff --git a/bld/dig/c/dsx/trpld.c b/bld/dig/c/dsx/trpld.c index e9deb56b28..717df44542 100644 --- a/bld/dig/c/dsx/trpld.c +++ b/bld/dig/c/dsx/trpld.c @@ -38,12 +38,12 @@ #include #include "dsxutil.h" #include "exedos.h" +#include "digcli.h" +#include "digld.h" #include "trpld.h" #include "trpcore.h" #include "trpsys.h" #include "tcerr.h" -#include "digcli.h" -#include "digld.h" #include "envlkup.h" #include "realmod.h" @@ -134,12 +134,12 @@ extern void DoRawSwitchToRM( unsigned, unsigned, unsigned ); extern void BackFromRealMode( void ); /* - We zero out the registers here so that there isn't any garbage - in the high word of them in 16-bit code. It turns out that the - Pentium sometimes uses the full 32-bit registers even - when the instruction specifies the 16-bit version (e.g string - instructions. -*/ + * We zero out the registers here so that there isn't any garbage + * in the high word of them in 16-bit code. It turns out that the + * Pentium sometimes uses the full 32-bit registers even + * when the instruction specifies the 16-bit version (e.g string + * instructions. + */ extern void DoIntSwitchToRM( void ); #pragma aux DoIntSwitchToRM = \ "pushad" \ @@ -170,9 +170,10 @@ static char pkg_entry[] = "D32NullPtrCheck"; #pragma aux extension_routine __parm [__eax] [__edx] [__ebx] __value [__eax] static extension_routine __far *RSI_extensions; -/* These are static because I'm not conversant with your inline asm - facility, and this accomplished the desired result... -*/ +/* + * These are static because I'm not conversant with your inline asm + * facility, and this accomplished the desired result... + */ static P1616 _D32NullPtrCheck; @@ -187,9 +188,10 @@ static P1616 __cdecl find_entry( void ) return (retval); } -/* Returns 16:16 pointer to MONITOR array, describing state of hardware - breakpoints. You shouldn't care about the return value during your init. -*/ +/* + * Returns 16:16 pointer to MONITOR array, describing state of hardware + * breakpoints. You shouldn't care about the return value during your init. + */ static int __cdecl D32NullPtrCheck( unsigned short on ) { static int old_state; @@ -226,7 +228,9 @@ void SaveOrigVectors( void ) PMExceptSaveList[i] = i; #endif old = D32NullPtrCheck( 0 ); - /* haven't moved things yet, so PMData isn't set up */ + /* + * haven't moved things yet, so PMData isn't set up + */ p = (rm_data *)RMDataStart; for( i = 0; i < NUM_VECTS; ++i ) { p->orig_vects[i].a = MyGetRMVector( i ); @@ -458,7 +462,9 @@ static trap_retval DoTrapAccess( trap_elen num_in_mx, in_mx_entry_p mx_in, trap_ return( REQUEST_FAILED ); } if( mx_out != NULL ) { - /* msgptr is pointing at the start of the output buffer */ + /* + * msgptr is pointing at the start of the output buffer + */ j = 0; for( len = callstruct->retlen; len != 0; len -= copy ) { copy = len; diff --git a/bld/dig/c/linux/dipld_so.c b/bld/dig/c/linux/dipld_so.c index 1c79ef82f6..fa83085266 100644 --- a/bld/dig/c/linux/dipld_so.c +++ b/bld/dig/c/linux/dipld_so.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -33,6 +33,7 @@ #include #include #include +#include "digld.h" #include "dip.h" #include "dipimp.h" #include "dipsys.h" diff --git a/bld/dig/c/linux/madld_so.c b/bld/dig/c/linux/madld_so.c index aca022bb3b..7216ed8098 100644 --- a/bld/dig/c/linux/madld_so.c +++ b/bld/dig/c/linux/madld_so.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2017 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -33,6 +33,7 @@ #include #include #include +#include "digld.h" #include "mad.h" #include "madimp.h" #include "madcli.h" diff --git a/bld/dig/c/linux/peloader.c b/bld/dig/c/linux/peloader.c index da4dd34e93..92fca09b2e 100644 --- a/bld/dig/c/linux/peloader.c +++ b/bld/dig/c/linux/peloader.c @@ -75,15 +75,17 @@ static bool PE_readHeader( u_long ne_header_off; u_long signature; - /* Read the EXE header and check for valid header signature */ + /* + * Read the EXE header and check for valid header signature + */ result = PE_invalidDLLImage; if( DIGLoader( Seek )( fp, startOffset, SEEK_SET ) || DIGLoader( Read )( fp, &exehdr, sizeof( exehdr ) ) || ( exehdr.signature != EXESIGN_DOS ) || !NE_HEADER_FOLLOWS( exehdr.reloc ) ) return( false ); - - /* Now seek to the start of the PE header defined at offset 0x3C + /* + * Now seek to the start of the PE header defined at offset 0x3C * in the MS-DOS EXE header, and read the signature and check it. */ if( DIGLoader( Seek )( fp, startOffset + NE_HEADER_OFFSET, SEEK_SET ) @@ -93,8 +95,9 @@ static bool PE_readHeader( || DIGLoader( Read )( fp, &signature, sizeof( signature ) ) || signature != EXESIGN_PE ) return( false ); - - /* Now read the PE file header and check that it is correct */ + /* + * Now read the PE file header and check that it is correct + */ if( DIGLoader( Read )( fp, filehdr, sizeof( *filehdr ) ) ) return( false ); if( filehdr->Machine != IMAGE_FILE_MACHINE_I386 ) @@ -107,8 +110,9 @@ static bool PE_readHeader( return( false ); if( opthdr->Magic != 0x10B ) return( false ); - - /* Success, so return true! */ + /* + * Success, so return true! + */ return( true ); } @@ -138,11 +142,14 @@ u_long PE_getFileSize( FILE *fp, u_long startOffset ) u_long size; int i; - /* Read the PE file headers from disk */ + /* + * Read the PE file headers from disk + */ if( !PE_readHeader( fp, startOffset, &filehdr, &opthdr ) ) return( 0xFFFFFFFF ); - - /* Scan all the section headers summing up the total size */ + /* + * Scan all the section headers summing up the total size + */ size = opthdr.SizeOfHeaders; for( i = 0; i < filehdr.NumberOfSections; i++ ) { if( DIGLoader( Read )( fp, §hdr, sizeof( secthdr ) ) ) @@ -201,11 +208,14 @@ PE_MODULE * PE_loadLibraryExt( void *reloc = NULL; BASE_RELOCATION *baseReloc; - /* Read the PE file headers from disk */ + /* + * Read the PE file headers from disk + */ if( !PE_readHeader( fp, startOffset, &filehdr, &opthdr ) ) return( NULL ); - - /* Scan all the section headers and find the necessary sections */ + /* + * Scan all the section headers and find the necessary sections + */ text_raw_off = text_base = text_size = text_end = 0; data_raw_off = data_base = data_size = data_virt_size = data_end = 0; bss_raw_off = bss_base = bss_size = bss_end = 0; @@ -218,51 +228,65 @@ PE_MODULE * PE_loadLibraryExt( if( i == 0 ) image_base = secthdr.VirtualAddress; if( strcmp( secthdr.Name, ".edata" ) == 0 || strcmp( secthdr.Name, ".rdata" ) == 0 ) { - /* Exports section */ + /* + * Exports section + */ export_raw_off = secthdr.PointerToRawData; export_base = secthdr.VirtualAddress; export_size = secthdr.SizeOfRawData; export_end = export_base + export_size; } else if( strcmp( secthdr.Name, ".idata" ) == 0 ) { - /* Imports section */ + /* + * Imports section + */ import_raw_off = secthdr.PointerToRawData; import_base = secthdr.VirtualAddress; import_size = secthdr.SizeOfRawData; import_end = import_base + import_size; } else if( strcmp( secthdr.Name, ".reloc" ) == 0 ) { - /* Relocations section */ + /* + * Relocations section + */ reloc_raw_off = secthdr.PointerToRawData; reloc_base = secthdr.VirtualAddress; reloc_size = secthdr.SizeOfRawData; } else if( text_raw_off == 0 && (secthdr.Characteristics & IMAGE_SCN_CNT_CODE) ) { - /* Code section */ + /* + * Code section + */ text_raw_off = secthdr.PointerToRawData; text_base = secthdr.VirtualAddress; text_size = secthdr.SizeOfRawData; text_end = text_base + text_size; } else if( data_raw_off == 0 && (secthdr.Characteristics & IMAGE_SCN_CNT_INITIALIZED_DATA) ) { - /* Data section */ + /* + * Data section + */ data_raw_off = secthdr.PointerToRawData; data_base = secthdr.VirtualAddress; data_size = secthdr.SizeOfRawData; data_virt_size = secthdr.VirtualSize; data_end = data_base + data_size; } else if( bss_raw_off == 0 && (secthdr.Characteristics & IMAGE_SCN_CNT_UNINITIALIZED_DATA) ) { - /* BSS data section */ + /* + * BSS data section + */ bss_raw_off = secthdr.PointerToRawData; bss_base = secthdr.VirtualAddress; bss_size = secthdr.SizeOfRawData; bss_end = bss_base + bss_size; } } - - /* Check to make sure that we have all the sections we need */ + /* + * Check to make sure that we have all the sections we need + */ if( text_raw_off == 0 || data_raw_off == 0 || export_raw_off == 0 || reloc_raw_off == 0 ) { result = PE_invalidDLLImage; goto Error; } - - /* Make sure the .reloc section is after everything else we load! */ + /* + * Make sure the .reloc section is after everything else we load! + */ image_end = bss_end; if( image_end < data_end ) image_end = data_end; @@ -276,8 +300,8 @@ PE_MODULE * PE_loadLibraryExt( result = PE_unknownImageFormat; goto Error; } - - /* Find the size of the image sections to load and allocate memory for + /* + * Find the size of the image sections to load and allocate memory for * them. We only load section data up to the .reloc section, and then * ignore everything else after that (eventually we might need to handle * the .rsrc section separately). @@ -290,8 +314,9 @@ PE_MODULE * PE_loadLibraryExt( result = PE_outOfMemory; goto Error; } - - /* Setup all the pointers into our loaded executeable image */ + /* + * Setup all the pointers into our loaded executeable image + */ image_ptr = (u_char *)__ROUND_UP_SIZE_4K( (u_long)hMod + sizeof( PE_MODULE ) ); hMod->pbase = image_ptr; hMod->ptext = image_ptr + ( text_base - image_base ); @@ -314,15 +339,17 @@ PE_MODULE * PE_loadLibraryExt( hMod->exportBase = export_base; hMod->exportDir = opthdr.DataDirectory[0].RelVirtualAddress - export_base; hMod->modname = NULL; - - /* Now read the section images from disk */ + /* + * Now read the section images from disk + */ result = PE_invalidDLLImage; DIGLoader( Seek )( fp, startOffset + text_raw_off, SEEK_SET ); if( DIGLoader( Read )( fp, hMod->ptext, text_size ) ) goto Error; DIGLoader( Seek )( fp, startOffset + data_raw_off, SEEK_SET ); if( data_virt_size ) { - /* Some linkers will put uninitalised data at the end + /* + * Some linkers will put uninitalised data at the end * of the primary data section, so we first must clear * the data section to zeros for the entire length of * VirtualSize, which can be longer than the size on disk. @@ -346,20 +373,25 @@ PE_MODULE * PE_loadLibraryExt( DIGLoader( Seek )( fp, startOffset + reloc_raw_off, SEEK_SET ); if( DIGLoader( Read )( fp, reloc, reloc_size ) ) goto Error; - - /* Make sure the BSS section is cleared to zero if it exists */ + /* + * Make sure the BSS section is cleared to zero if it exists + */ if( hMod->pbss ) memset( hMod->pbss, 0, bss_size ); - - /* Now perform relocations on all sections in the image */ + /* + * Now perform relocations on all sections in the image + */ delta = (u_long)image_ptr - opthdr.ImageBase - image_base; baseReloc = (BASE_RELOCATION*)reloc; for( ;; ) { - /* Check for termination condition */ + /* + * Check for termination condition + */ if( baseReloc->PageRVA == 0 || baseReloc->BlockSize == 0 ) break; - - /* Do fixups */ + /* + * Do fixups + */ numFixups = ( baseReloc->BlockSize - sizeof( BASE_RELOCATION ) ) / sizeof( u_short ); fixup = (u_short*)( baseReloc + 1 ); pageOffset = baseReloc->PageRVA - image_base; @@ -371,19 +403,21 @@ PE_MODULE * PE_loadLibraryExt( } fixup++; } - - /* Move to next relocation block */ + /* + * Move to next relocation block + */ baseReloc = (BASE_RELOCATION*)( (u_long)baseReloc + baseReloc->BlockSize ); } - - /* On some platforms (such as AMD64 or x86 with NX bit), it is required + /* + * On some platforms (such as AMD64 or x86 with NX bit), it is required * to map the code pages loaded from the BPD as executable, otherwise * a segfault will occur when attempting to run any BPD code. */ if( mprotect( (void*)image_ptr, image_size, PROT_READ | PROT_WRITE | PROT_EXEC ) != 0 ) goto Error; - - /* Clean up, close the file and return the loaded module handle */ + /* + * Clean up, close the file and return the loaded module handle + */ free( reloc ); result = PE_ok; return( hMod ); @@ -426,14 +460,16 @@ PE_MODULE * PE_loadLibraryFile( FILE *fp, const char *szDLLName ) return( NULL ); } hMod = PE_loadLibraryExt( fp, 0, &size ); - - /* Notify the Watcom Debugger of module load and let it load symbolic info */ + /* + * Notify the Watcom Debugger of module load and let it load symbolic info + */ #ifdef WATCOM_DEBUG_SYMBOLS if( hMod != NULL ) { u_long size; char *modname; - /* Store the file name in the hMod structure; this must be the real + /* + * Store the file name in the hMod structure; this must be the real * file name where the debugger will try to load symbolic info from */ size = strlen( szDLLName ) + 1; @@ -486,15 +522,18 @@ void * PE_getProcAddress( u_short *OrdinalTable; char *name; - /* Find the address of the pexport tables from the pexport section */ + /* + * Find the address of the pexport tables from the pexport section + */ if( hModule == NULL ) return( NULL ); exports = (EXPORT_DIRECTORY *)( hModule->pexport + hModule->exportDir ); AddressTable = (u_long *)( hModule->pexport + exports->AddressTableRVA - hModule->exportBase ); NameTable = (u_long*)( hModule->pexport + exports->NameTableRVA - hModule->exportBase ); OrdinalTable = (u_short*)( hModule->pexport + exports->OrdinalTableRVA - hModule->exportBase ); - - /* Search the pexport name table to find the function name */ + /* + * Search the pexport name table to find the function name + */ for( i = 0; i < exports->NumberOfNamePointers; i++ ) { name = (char*)( hModule->pexport + NameTable[i] - hModule->exportBase ); if( strcmp( name, szProcName ) == 0 ) { @@ -528,7 +567,9 @@ PE_getProcAddress, PE_loadLibrary void PE_freeLibrary( PE_MODULE *hModule ) { if( hModule != NULL ) { - /* Notify the Watcom Debugger of module load and let it remove symbolic info */ + /* + * Notify the Watcom Debugger of module load and let it remove symbolic info + */ #ifdef WATCOM_DEBUG_SYMBOLS if( hModule->modname ) { DebuggerUnloadUserModule( hModule->modname ); diff --git a/bld/dig/c/linux/trpld_pe.c b/bld/dig/c/linux/trpld_pe.c index a67f3db3e2..9c86d2a4c0 100644 --- a/bld/dig/c/linux/trpld_pe.c +++ b/bld/dig/c/linux/trpld_pe.c @@ -33,10 +33,10 @@ #include #include #include +#include "digld.h" #include "trpld.h" #include "tcerr.h" #include "peloader.h" -#include "digld.h" #ifndef __WATCOMC__ diff --git a/bld/dig/c/linux/trpld_so.c b/bld/dig/c/linux/trpld_so.c index b46f194531..1894006a54 100644 --- a/bld/dig/c/linux/trpld_so.c +++ b/bld/dig/c/linux/trpld_so.c @@ -34,9 +34,9 @@ #include #include #include +#include "digld.h" #include "trpld.h" #include "tcerr.h" -#include "digld.h" #include "clibext.h" diff --git a/bld/dig/c/nov/trpld.c b/bld/dig/c/nov/trpld.c index 83e2af7c0c..08e511af91 100644 --- a/bld/dig/c/nov/trpld.c +++ b/bld/dig/c/nov/trpld.c @@ -32,6 +32,7 @@ #include +#include "digld.h" #include "trpld.h" #include "trpcomm.h" #include "tcerr.h" diff --git a/bld/dig/c/nt/dipld.c b/bld/dig/c/nt/dipld.c index eb09aee8bd..f1c59ab9c3 100644 --- a/bld/dig/c/nt/dipld.c +++ b/bld/dig/c/nt/dipld.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -34,6 +34,7 @@ #include #include #include +#include "digld.h" #include "dip.h" #include "dipimp.h" #include "dipsys.h" diff --git a/bld/dig/c/nt/madld.c b/bld/dig/c/nt/madld.c index c6413487c1..353b7517d5 100644 --- a/bld/dig/c/nt/madld.c +++ b/bld/dig/c/nt/madld.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2017 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -35,11 +35,13 @@ #include #include #include +#include "digld.h" #include "mad.h" #include "madimp.h" #include "madcli.h" #include "madsys.h" + void MADSysUnload( mad_sys_handle *sys_hdl ) { if( *sys_hdl != NULL_SYSHDL ) { diff --git a/bld/dig/c/nt/trpld.c b/bld/dig/c/nt/trpld.c index 11e15658fd..09674bbc5c 100644 --- a/bld/dig/c/nt/trpld.c +++ b/bld/dig/c/nt/trpld.c @@ -35,6 +35,7 @@ #include #include #include +#include "digld.h" #include "trpld.h" #include "trpsys.h" #include "tcerr.h" diff --git a/bld/dig/c/os2/dipld.c b/bld/dig/c/os2/dipld.c index 1f9064670f..b851bc6c23 100644 --- a/bld/dig/c/os2/dipld.c +++ b/bld/dig/c/os2/dipld.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2017 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -36,6 +36,7 @@ #define INCL_DOSMODULEMGR #define INCL_DOSMISC #include +#include "digld.h" #include "dip.h" #include "dipimp.h" #include "dipsys.h" @@ -67,7 +68,8 @@ dip_status DIPSysLoad( const char *base_name, dip_client_routines *cli, dip_imp_ char dippath[CCHMAXPATH]; *sys_hdl = NULL_SYSHDL; - /* To prevent conflicts with the 16-bit DIP DLLs, the 32-bit versions have the "D32" + /* + * To prevent conflicts with the 16-bit DIP DLLs, the 32-bit versions have the "D32" * extension. We will search for them along the PATH (not in LIBPATH); */ strcpy( dipname, base_name ); diff --git a/bld/dig/c/os2/madld.c b/bld/dig/c/os2/madld.c index 6366b8198d..1746cd101a 100644 --- a/bld/dig/c/os2/madld.c +++ b/bld/dig/c/os2/madld.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2017 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -36,6 +36,7 @@ #define INCL_DOSMODULEMGR #define INCL_DOSMISC #include +#include "digld.h" #include "mad.h" #include "madimp.h" #include "madsys.h" @@ -67,7 +68,8 @@ mad_status MADSysLoad( const char *base_name, mad_client_routines *cli, mad_imp_ char madpath[CCHMAXPATH]; *sys_hdl = NULL_SYSHDL; - /* To prevent conflicts with the 16-bit MAD DLLs, the 32-bit versions have the "D32" + /* + * To prevent conflicts with the 16-bit MAD DLLs, the 32-bit versions have the "D32" * extension. We will search for them along the PATH (not in LIBPATH); */ strcpy( madname, base_name ); diff --git a/bld/dig/c/os2/trpld.c b/bld/dig/c/os2/trpld.c index 58a54c82c5..bf32c6019d 100644 --- a/bld/dig/c/os2/trpld.c +++ b/bld/dig/c/os2/trpld.c @@ -36,6 +36,7 @@ #define INCL_DOSMODULEMGR #define INCL_DOSMISC #include +#include "digld.h" #include "trpld.h" #include "trpsys.h" #include "tcerr.h" @@ -134,7 +135,8 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) } } #endif - /* To prevent conflicts with the 16-bit DIP DLLs, the 32-bit versions have the "D32" + /* + * To prevent conflicts with the 16-bit DIP DLLs, the 32-bit versions have the "D32" * extension. We will search for them along the PATH (not in LIBPATH); */ #ifdef _M_I86 diff --git a/bld/dig/c/qnx/pillld.c b/bld/dig/c/qnx/pillld.c index 39f695b793..f72815a867 100644 --- a/bld/dig/c/qnx/pillld.c +++ b/bld/dig/c/qnx/pillld.c @@ -76,7 +76,9 @@ int PILLSysLoad( const char *name, const pill_client_routines *cli, init_func = (pill_init_func *)pill->init_rtn; lh->rtns = init_func( cli, msg ); if( lh->rtns == NULL ) { - /* don't free DLL yet, we need the message processor */ + /* + * don't free DLL yet, we need the message processor + */ msg->source = lh; return( 0 ); } diff --git a/bld/dig/c/rdos/dipld.c b/bld/dig/c/rdos/dipld.c index 1b80948fde..3da8b91f51 100644 --- a/bld/dig/c/rdos/dipld.c +++ b/bld/dig/c/rdos/dipld.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -34,6 +34,7 @@ #include #include #include +#include "digld.h" #include "dip.h" #include "dipimp.h" #include "dipsys.h" diff --git a/bld/dig/c/rdos/madld.c b/bld/dig/c/rdos/madld.c index 68708fe80b..877b81cb51 100644 --- a/bld/dig/c/rdos/madld.c +++ b/bld/dig/c/rdos/madld.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2017 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -35,11 +35,13 @@ #include #include #include +#include "digld.h" #include "mad.h" #include "madimp.h" #include "madcli.h" #include "madsys.h" + void MADSysUnload( mad_sys_handle *sys_hdl ) { if( *sys_hdl != NULL_SYSHDL ) { diff --git a/bld/dig/c/rdos/trpld.c b/bld/dig/c/rdos/trpld.c index 8307ea6a92..1b9f8874a9 100644 --- a/bld/dig/c/rdos/trpld.c +++ b/bld/dig/c/rdos/trpld.c @@ -34,6 +34,7 @@ #include #include #include +#include "digld.h" #include "trpld.h" #include "tcerr.h" diff --git a/bld/dig/c/win/dipld.c b/bld/dig/c/win/dipld.c index 5010bdde47..12ad108710 100644 --- a/bld/dig/c/win/dipld.c +++ b/bld/dig/c/win/dipld.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -36,6 +36,7 @@ #include #include #include "watcom.h" +#include "digld.h" #include "dip.h" #include "dipimp.h" #include "dipsys.h" diff --git a/bld/dig/c/win/madld.c b/bld/dig/c/win/madld.c index a2c01ffadd..ddbce9362e 100644 --- a/bld/dig/c/win/madld.c +++ b/bld/dig/c/win/madld.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -36,6 +36,7 @@ #include #include #include "watcom.h" +#include "digld.h" #include "mad.h" #include "madimp.h" #include "madcli.h" diff --git a/bld/dig/c/win/trpld.c b/bld/dig/c/win/trpld.c index b9424445c9..856afa1ed2 100644 --- a/bld/dig/c/win/trpld.c +++ b/bld/dig/c/win/trpld.c @@ -36,6 +36,7 @@ #include #include #include +#include "digld.h" #include "trpld.h" #include "trpsys.h" #include "tcerr.h" From ee38fdd5031743eef581c2750dda8d292cbd082e Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Sat, 26 Aug 2023 14:03:38 +0200 Subject: [PATCH 021/258] correct build break in loader for linux SO trap --- bld/dig/c/linux/trpld_so.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bld/dig/c/linux/trpld_so.c b/bld/dig/c/linux/trpld_so.c index 1894006a54..ae82c3f349 100644 --- a/bld/dig/c/linux/trpld_so.c +++ b/bld/dig/c/linux/trpld_so.c @@ -95,8 +95,8 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) trpname = parms; len = 0; #endif - for( ; (chr = *parms) != '\0'; parms++ ) { - if( chr == TRAP_PARM_SEPARATOR ) { + for( ; *parms != '\0'; parms++ ) { + if( *parms == TRAP_PARM_SEPARATOR ) { parms++; break; } From 6d0bcac307367fc334f1cc363a7e2e7e6407079c Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Sat, 26 Aug 2023 23:33:41 +0200 Subject: [PATCH 022/258] rename symbols for consistency --- bld/dig/c/dos/trpld.c | 8 ++++---- bld/dig/c/dsx/trpld.c | 8 ++++---- bld/dig/c/linux/dipld_so.c | 16 ++++++---------- bld/dig/c/linux/madld_so.c | 16 ++++++---------- bld/dig/c/linux/trpld_pe.c | 8 ++++---- bld/dig/c/linux/trpld_so.c | 8 ++++---- bld/dig/c/qnx/pillld.c | 4 ++-- bld/dig/c/qnx/trpld.c | 8 ++++---- bld/dig/h/digld.h | 2 +- 9 files changed, 35 insertions(+), 43 deletions(-) diff --git a/bld/dig/c/dos/trpld.c b/bld/dig/c/dos/trpld.c index e0c6691e5b..2829304ca9 100644 --- a/bld/dig/c/dos/trpld.c +++ b/bld/dig/c/dos/trpld.c @@ -121,13 +121,13 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) FILE *fp; trap_init_func *init_func; char filename[256]; - const char *trpname; + const char *base_name; const char *err; size_t len; if( parms == NULL || *parms == '\0' ) parms = DEFAULT_TRP_NAME; - trpname = parms; + base_name = parms; len = 0; for( ; *parms != '\0'; parms++ ) { if( *parms == TRAP_PARM_SEPARATOR ) { @@ -136,8 +136,8 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) } len++; } - if( DIGLoader( Find )( DIG_FILETYPE_EXE, trpname, len, "trp", filename, sizeof( filename ) ) == 0 ) { - sprintf( buff, "%s '%s'", TC_ERR_CANT_LOAD_TRAP, trpname ); + if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, len, "trp", filename, sizeof( filename ) ) == 0 ) { + sprintf( buff, "%s '%s'", TC_ERR_CANT_LOAD_TRAP, base_name ); return( buff ); } fp = DIGLoader( Open )( filename ); diff --git a/bld/dig/c/dsx/trpld.c b/bld/dig/c/dsx/trpld.c index 717df44542..0e08ba286b 100644 --- a/bld/dig/c/dsx/trpld.c +++ b/bld/dig/c/dsx/trpld.c @@ -490,13 +490,13 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) FILE *fp; trap_file_header __far *head; char filename[256]; - const char *trpname; + const char *base_name; const char *err; size_t len; if( parms == NULL || *parms == '\0' ) parms = DEFAULT_TRP_NAME; - trpname = parms; + base_name = parms; len = 0; for( ; *parms != '\0'; parms++ ) { if( *parms == TRAP_PARM_SEPARATOR ) { @@ -505,8 +505,8 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) } len++; } - if( DIGLoader( Find )( DIG_FILETYPE_EXE, trpname, len, "trp", filename, sizeof( filename ) ) == 0 ) { - sprintf( buff, "%s '%s'", TC_ERR_CANT_LOAD_TRAP, trpname ); + if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, len, "trp", filename, sizeof( filename ) ) == 0 ) { + sprintf( buff, "%s '%s'", TC_ERR_CANT_LOAD_TRAP, base_name ); return( buff ); } sprintf( buff, "%s '%s'", TC_ERR_CANT_LOAD_TRAP, filename ); diff --git a/bld/dig/c/linux/dipld_so.c b/bld/dig/c/linux/dipld_so.c index fa83085266..81dc8a97fe 100644 --- a/bld/dig/c/linux/dipld_so.c +++ b/bld/dig/c/linux/dipld_so.c @@ -53,20 +53,16 @@ dip_status DIPSysLoad( const char *base_name, dip_client_routines *cli, dip_imp_ { dip_sys_handle shlib; dip_init_func *init_func; - char newpath[_MAX_PATH]; - char full_path[_MAX_PATH]; + char filename[_MAX_PATH]; dip_status ds; *sys_hdl = NULL_SYSHDL; - strcpy( newpath, base_name ); - strcat( newpath, ".so" ); - shlib = dlopen( newpath, RTLD_NOW ); + if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, strlen( base_name ), "so", filename, sizeof( filename ) ) == 0 ) { + return( DS_ERR | DS_FOPEN_FAILED ); + } + shlib = dlopen( filename, RTLD_NOW ); if( shlib == NULL_SYSHDL ) { - _searchenv( newpath, "PATH", full_path ); - shlib = dlopen( full_path, RTLD_NOW ); - if( shlib == NULL_SYSHDL ) { - return( DS_ERR | DS_FOPEN_FAILED ); - } + return( DS_ERR | DS_FOPEN_FAILED ); } ds = DS_ERR | DS_INVALID_DIP; init_func = (dip_init_func *)dlsym( shlib, "DIPLOAD" ); diff --git a/bld/dig/c/linux/madld_so.c b/bld/dig/c/linux/madld_so.c index 7216ed8098..aed8c1ea90 100644 --- a/bld/dig/c/linux/madld_so.c +++ b/bld/dig/c/linux/madld_so.c @@ -54,20 +54,16 @@ mad_status MADSysLoad( const char *base_name, mad_client_routines *cli, mad_imp_ { mad_sys_handle shlib; mad_init_func *init_func; - char newpath[_MAX_PATH]; - char full_path[_MAX_PATH]; + char filename[_MAX_PATH]; mad_status status; *sys_hdl = NULL_SYSHDL; - strcpy( newpath, base_name ); - strcat( newpath, ".so" ); - shlib = dlopen( newpath, RTLD_NOW ); + if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, strlen( base_name ), "so", filename, sizeof( filename ) ) == 0 ) { + return( MS_ERR | MS_FOPEN_FAILED ); + } + shlib = dlopen( filename, RTLD_NOW ); if( shlib == NULL ) { - _searchenv( newpath, "PATH", full_path ); - shlib = dlopen( full_path, RTLD_NOW ); - if( shlib == NULL ) { - return( MS_ERR | MS_FOPEN_FAILED ); - } + return( MS_ERR | MS_FOPEN_FAILED ); } status = MS_ERR | MS_INVALID_MAD; init_func = (mad_init_func *)dlsym( shlib, "MADLOAD" ); diff --git a/bld/dig/c/linux/trpld_pe.c b/bld/dig/c/linux/trpld_pe.c index 9c86d2a4c0..3f5547e0c6 100644 --- a/bld/dig/c/linux/trpld_pe.c +++ b/bld/dig/c/linux/trpld_pe.c @@ -83,14 +83,14 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) #if !defined( BUILTIN_TRAP_FILE ) FILE *fp; char filename[_MAX_PATH]; - const char *trpname; + const char *base_name; size_t len; #endif if( parms == NULL || *parms == '\0' ) parms = DEFAULT_TRP_NAME; #if !defined( BUILTIN_TRAP_FILE ) - trpname = parms; + base_name = parms; len = 0; #endif for( ; *parms != '\0'; parms++ ) { @@ -103,8 +103,8 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) #endif } #if !defined( BUILTIN_TRAP_FILE ) - if( DIGLoader( Find )( DIG_FILETYPE_EXE, trpname, len, "trp", filename, sizeof( filename ) ) == 0 ) { - sprintf( buff, "%s '%s'", TC_ERR_CANT_LOAD_TRAP, trpname ); + if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, len, "trp", filename, sizeof( filename ) ) == 0 ) { + sprintf( buff, "%s '%s'", TC_ERR_CANT_LOAD_TRAP, base_name ); return( buff ); } sprintf( buff, "%s '%s'", TC_ERR_CANT_LOAD_TRAP, filename ); diff --git a/bld/dig/c/linux/trpld_so.c b/bld/dig/c/linux/trpld_so.c index ae82c3f349..c0f788329e 100644 --- a/bld/dig/c/linux/trpld_so.c +++ b/bld/dig/c/linux/trpld_so.c @@ -85,14 +85,14 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) const trap_requests *trap_funcs; #if !defined( BUILTIN_TRAP_FILE ) char filename[_MAX_PATH]; - const char *trpname; + const char *base_name; size_t len; #endif if( parms == NULL || *parms == '\0' ) parms = DEFAULT_TRP_NAME; #if !defined( BUILTIN_TRAP_FILE ) - trpname = parms; + base_name = parms; len = 0; #endif for( ; *parms != '\0'; parms++ ) { @@ -105,8 +105,8 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) #endif } #if !defined( BUILTIN_TRAP_FILE ) - if( DIGLoader( Find )( DIG_FILETYPE_EXE, trpname, len, "so", filename, sizeof( filename ) ) == 0 ) { - sprintf( buff, "%s '%s'", TC_ERR_CANT_LOAD_TRAP, trpname ); + if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, len, "so", filename, sizeof( filename ) ) == 0 ) { + sprintf( buff, "%s '%s'", TC_ERR_CANT_LOAD_TRAP, base_name ); return( buff ); } sprintf( buff, "%s '%s'", TC_ERR_CANT_LOAD_TRAP, filename ); diff --git a/bld/dig/c/qnx/pillld.c b/bld/dig/c/qnx/pillld.c index f72815a867..aa3f6a586d 100644 --- a/bld/dig/c/qnx/pillld.c +++ b/bld/dig/c/qnx/pillld.c @@ -42,7 +42,7 @@ #include "qnxload.h" -int PILLSysLoad( const char *name, const pill_client_routines *cli, +int PILLSysLoad( const char *base_name, const pill_client_routines *cli, link_handle *lh, link_message *msg ) { FILE *fp; @@ -52,7 +52,7 @@ int PILLSysLoad( const char *name, const pill_client_routines *cli, msg->source = NULL; msg->id = LM_SYSTEM_ERROR; - if( DIGLoader( Find )( DIG_FILETYPE_EXE, name, strlen( name ), "pil", filename, sizeof( filename ) + 1 ) == 0 ) { + if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, strlen( base_name ), "pil", filename, sizeof( filename ) ) == 0 ) { return( 0 ); } fp = DIGLoader( Open )( filename ); diff --git a/bld/dig/c/qnx/trpld.c b/bld/dig/c/qnx/trpld.c index cf3f0c47f6..2d6b182a6a 100644 --- a/bld/dig/c/qnx/trpld.c +++ b/bld/dig/c/qnx/trpld.c @@ -82,12 +82,12 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) trap_load_func *ld_func; const trap_requests *trap_funcs; char filename[256]; - const char *trpname; + const char *base_name; size_t len; if( parms == NULL || *parms == '\0' ) parms = DEFAULT_TRP_NAME; - trpname = parms;; + base_name = parms;; len = 0; for( ; *parms != '\0'; parms++ ) { if( *parms == TRAP_PARM_SEPARATOR ) { @@ -96,8 +96,8 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) } len++; } - if( DIGLoader( Find )( DIG_FILETYPE_EXE, trpname, len, "trp", filename, sizeof( filename ) ) ) { - sprintf( buff, "%s '%s'", TC_ERR_CANT_LOAD_TRAP, trpname ); + if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, len, "trp", filename, sizeof( filename ) ) ) { + sprintf( buff, "%s '%s'", TC_ERR_CANT_LOAD_TRAP, base_name ); return( buff ); } sprintf( buff, "%s '%s'", TC_ERR_CANT_LOAD_TRAP, filename ); diff --git a/bld/dig/h/digld.h b/bld/dig/h/digld.h index 147a7b82cb..a1d327eb9c 100644 --- a/bld/dig/h/digld.h +++ b/bld/dig/h/digld.h @@ -36,7 +36,7 @@ #define DIGLoader(n) DIGLoader ## n -extern size_t DIGLoader( Find )( dig_filetype ftype, const char *name, size_t name_len, const char *defext, char *buff, size_t buff_size ); +extern size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base_name_len, const char *defext, char *filename, size_t filename_len ); extern FILE *DIGLoader( Open )( const char *filename ); extern int DIGLoader( Close )( FILE *fp ); extern int DIGLoader( Read )( FILE *fp, void *buff, size_t len ); From 06c1429563e7ca37eaa904ad790a3c589e611a19 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Sun, 27 Aug 2023 02:35:38 +0200 Subject: [PATCH 023/258] rename KillTrap to UnLoadTrap to be more transparent --- bld/dig/c/dos/trpld.c | 4 ++-- bld/dig/c/dsx/trpld.c | 4 ++-- bld/dig/c/linux/trpld_pe.c | 4 ++-- bld/dig/c/linux/trpld_so.c | 4 ++-- bld/dig/c/nov/trpld.c | 4 ++-- bld/dig/c/nt/trpld.c | 4 ++-- bld/dig/c/os2/trpld.c | 4 ++-- bld/dig/c/qnx/trpld.c | 4 ++-- bld/dig/c/rdos/trpld.c | 4 ++-- bld/dig/c/win/trpld.c | 4 ++-- bld/dig/h/trpld.h | 4 ++-- bld/trap/common/serv.c | 4 ++-- bld/trap/common/servw.c | 2 +- bld/wv/c/remmisc.c | 8 ++++---- 14 files changed, 29 insertions(+), 29 deletions(-) diff --git a/bld/dig/c/dos/trpld.c b/bld/dig/c/dos/trpld.c index 2829304ca9..f5c6042104 100644 --- a/bld/dig/c/dos/trpld.c +++ b/bld/dig/c/dos/trpld.c @@ -103,7 +103,7 @@ static char *ReadInTrap( FILE *fp ) return( NULL ); } -void KillTrap( void ) +void UnLoadTrap( void ) { ReqFunc = NULL; if( FiniFunc != NULL ) { @@ -165,6 +165,6 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) } if( buff[0] == '\0' ) strcpy( buff, err ); - KillTrap(); + UnLoadTrap(); return( buff ); } diff --git a/bld/dig/c/dsx/trpld.c b/bld/dig/c/dsx/trpld.c index 0e08ba286b..f30ae0939c 100644 --- a/bld/dig/c/dsx/trpld.c +++ b/bld/dig/c/dsx/trpld.c @@ -540,11 +540,11 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) } if( buff[0] == '\0' ) strcpy( buff, err ); - KillTrap(); + UnLoadTrap(); return( buff ); } -void KillTrap( void ) +void UnLoadTrap( void ) { if( IntrState != IS_NONE ) { GoToRealMode( RMTrapFini ); diff --git a/bld/dig/c/linux/trpld_pe.c b/bld/dig/c/linux/trpld_pe.c index 3f5547e0c6..080379b5e6 100644 --- a/bld/dig/c/linux/trpld_pe.c +++ b/bld/dig/c/linux/trpld_pe.c @@ -61,7 +61,7 @@ const static trap_callbacks TrapCallbacks = { signal, }; -void KillTrap( void ) +void UnLoadTrap( void ) { ReqFunc = NULL; if( FiniFunc != NULL ) { @@ -140,6 +140,6 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) #endif if( buff[0] == '\0' ) strcpy( buff, TC_ERR_WRONG_TRAP_VERSION ); - KillTrap(); + UnLoadTrap(); return( buff ); } diff --git a/bld/dig/c/linux/trpld_so.c b/bld/dig/c/linux/trpld_so.c index c0f788329e..940ff8a210 100644 --- a/bld/dig/c/linux/trpld_so.c +++ b/bld/dig/c/linux/trpld_so.c @@ -63,7 +63,7 @@ const static trap_callbacks TrapCallbacks = { signal, }; -void KillTrap( void ) +void UnLoadTrap( void ) { ReqFunc = NULL; if( FiniFunc != NULL ) { @@ -144,6 +144,6 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) #endif if( buff[0] == '\0' ) strcpy( buff, TC_ERR_WRONG_TRAP_VERSION ); - KillTrap(); + UnLoadTrap(); return( buff ); } diff --git a/bld/dig/c/nov/trpld.c b/bld/dig/c/nov/trpld.c index 08e511af91..b970d7aee4 100644 --- a/bld/dig/c/nov/trpld.c +++ b/bld/dig/c/nov/trpld.c @@ -38,7 +38,7 @@ #include "tcerr.h" -void KillTrap( void ) +void UnLoadTrap( void ) { TrapFini(); } @@ -68,6 +68,6 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) } strcpy( buff, TC_ERR_WRONG_TRAP_VERSION ); } - KillTrap(); + UnLoadTrap(); return( buff ); } diff --git a/bld/dig/c/nt/trpld.c b/bld/dig/c/nt/trpld.c index 09674bbc5c..f16bd5414d 100644 --- a/bld/dig/c/nt/trpld.c +++ b/bld/dig/c/nt/trpld.c @@ -79,7 +79,7 @@ bool TRAP_EXTFUNC( Terminate )( void ) return( false ); } -void KillTrap( void ) +void UnLoadTrap( void ) { ReqFunc = NULL; TRAP_EXTFUNC_PTR( InfoFunction ) = NULL; @@ -154,6 +154,6 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) } if( buff[0] == '\0' ) strcpy( buff, TC_ERR_WRONG_TRAP_VERSION ); - KillTrap(); + UnLoadTrap(); return( buff ); } diff --git a/bld/dig/c/os2/trpld.c b/bld/dig/c/os2/trpld.c index bf32c6019d..4544f0f478 100644 --- a/bld/dig/c/os2/trpld.c +++ b/bld/dig/c/os2/trpld.c @@ -86,7 +86,7 @@ char TRAP_EXTFUNC( TellHardMode )( char hard ) return( 0 ); } -void KillTrap( void ) +void UnLoadTrap( void ) { ReqFunc = NULL; TRAP_EXTFUNC_PTR( TellHandles ) = NULL; @@ -173,6 +173,6 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) } if( buff[0] == '\0' ) strcpy( buff, TC_ERR_WRONG_TRAP_VERSION ); - KillTrap(); + UnLoadTrap(); return( buff ); } diff --git a/bld/dig/c/qnx/trpld.c b/bld/dig/c/qnx/trpld.c index 2d6b182a6a..f98fa2aad1 100644 --- a/bld/dig/c/qnx/trpld.c +++ b/bld/dig/c/qnx/trpld.c @@ -63,7 +63,7 @@ const static trap_callbacks TrapCallbacks = { static imp_header *TrapCode = NULL; static trap_fini_func *FiniFunc = NULL; -void KillTrap( void ) +void UnLoadTrap( void ) { ReqFunc = NULL; if( FiniFunc != NULL ) { @@ -130,7 +130,7 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) #endif if( buff[0] == '\0' ) strcpy( buff, TC_ERR_BAD_TRAP_FILE ); - KillTrap(); + UnLoadTrap(); } return( buff ); } diff --git a/bld/dig/c/rdos/trpld.c b/bld/dig/c/rdos/trpld.c index 1b9f8874a9..8050e0484f 100644 --- a/bld/dig/c/rdos/trpld.c +++ b/bld/dig/c/rdos/trpld.c @@ -42,7 +42,7 @@ static int TrapFile = 0; static trap_fini_func *FiniFunc = NULL; -void KillTrap( void ) +void UnLoadTrap( void ) { ReqFunc = NULL; if( FiniFunc != NULL ) { @@ -112,6 +112,6 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) } if( buff[0] == '\0' ) strcpy( buff, TC_ERR_WRONG_TRAP_VERSION ); - KillTrap(); + UnLoadTrap(); return( buff ); } diff --git a/bld/dig/c/win/trpld.c b/bld/dig/c/win/trpld.c index 856afa1ed2..1db81cf90f 100644 --- a/bld/dig/c/win/trpld.c +++ b/bld/dig/c/win/trpld.c @@ -56,7 +56,7 @@ static trap_fini_func *FiniFunc = NULL; static HINSTANCE TrapFile = 0; static HINSTANCE toolhelp = 0; -void KillTrap( void ) +void UnLoadTrap( void ) { ReqFunc = NULL; TRAP_EXTFUNC_PTR( InputHook ) = NULL; @@ -153,7 +153,7 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) } if( buff[0] == '\0' ) strcpy( buff, TC_ERR_WRONG_TRAP_VERSION ); - KillTrap(); + UnLoadTrap(); return( buff ); } diff --git a/bld/dig/h/trpld.h b/bld/dig/h/trpld.h index 2fceecc8a1..8690285d76 100644 --- a/bld/dig/h/trpld.h +++ b/bld/dig/h/trpld.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -51,10 +51,10 @@ extern int CloseTrapTraceFile( void ); /* Client interface routines */ extern char *LoadDumbTrap( trap_version * ); extern char *LoadTrap( const char *, char *, trap_version * ); +extern void UnLoadTrap( void ); extern void TrapSetFailCallBack( void (*func)(void) ); extern unsigned TrapAccess( trap_elen, in_mx_entry_p, trap_elen, mx_entry_p ); extern unsigned TrapSimpleAccess( trap_elen, in_data_p, trap_elen, out_data_p ); -extern void KillTrap( void ); extern trap_load_func TrapLoad; /* Client support routines */ diff --git a/bld/trap/common/serv.c b/bld/trap/common/serv.c index b25ac66061..b55688e388 100644 --- a/bld/trap/common/serv.c +++ b/bld/trap/common/serv.c @@ -125,7 +125,7 @@ int main( int argc, char **argv ) if( KeyPress() ) { key = KeyGet(); if( key == 'q' || key == 'Q' ) { - KillTrap(); + UnLoadTrap(); RemoteUnLink(); ServTerminate( 0 ); // never return @@ -146,7 +146,7 @@ int main( int argc, char **argv ) OutputLine( "" ); RemoteDisco(); if( OneShot ) { - KillTrap(); + UnLoadTrap(); RemoteUnLink(); ServTerminate( 0 ); // never return diff --git a/bld/trap/common/servw.c b/bld/trap/common/servw.c index 4946b92295..1a416e2f8c 100644 --- a/bld/trap/common/servw.c +++ b/bld/trap/common/servw.c @@ -87,7 +87,7 @@ int PASCAL WinMain( HINSTANCE this_inst, HINSTANCE prev_inst, LPSTR cmdline, int } if( Linked ) RemoteUnLink(); - KillTrap(); + UnLoadTrap(); return( msg.wParam ); diff --git a/bld/wv/c/remmisc.c b/bld/wv/c/remmisc.c index 118ac145d7..5fd77ba986 100644 --- a/bld/wv/c/remmisc.c +++ b/bld/wv/c/remmisc.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -68,7 +68,7 @@ trap_elen MaxPacketLen; static void TrapFailed( void ) { - KillTrap(); + UnLoadTrap(); StartupErr( LIT_ENG( ERR_REMOTE_LINK_BROKEN ) ); } @@ -148,7 +148,7 @@ void InitTrap( const char *parms ) TrapAccess( 1, in, 2, out ); MaxPacketLen = ret.max_msg_size; if( buff[0] != NULLCHAR ) { - KillTrap(); + UnLoadTrap(); InitTrapError = true; StartupErr( buff ); } @@ -218,7 +218,7 @@ void FiniTrap( void ) acc.req = REQ_DISCONNECT; TrapSimpleAccess( sizeof( acc ), &acc, 0, NULL ); RestoreHandlers(); - KillTrap(); + UnLoadTrap(); GrabHandlers(); #if !defined( BUILD_RFX ) FiniSuppServices(); From d245d5a8974c4dce47454c3e3e6e450feb640a5c Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Sun, 27 Aug 2023 04:27:39 +0200 Subject: [PATCH 024/258] move header file to correct location --- bld/{wv/dsx => dig}/h/dsxutil.h | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename bld/{wv/dsx => dig}/h/dsxutil.h (100%) diff --git a/bld/wv/dsx/h/dsxutil.h b/bld/dig/h/dsxutil.h similarity index 100% rename from bld/wv/dsx/h/dsxutil.h rename to bld/dig/h/dsxutil.h From 48ef1aef4cfeee6dc7c3a4313b18dcf7353b23ac Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Sun, 27 Aug 2023 04:35:49 +0200 Subject: [PATCH 025/258] correct trap message format --- bld/dig/c/dos/trpld.c | 8 +++++--- bld/dig/c/dsx/trpld.c | 8 +++++--- bld/dig/c/nt/trpld.c | 2 +- bld/dig/c/os2/trpld.c | 4 ++-- bld/dig/c/qnx/trpld.c | 4 ++-- bld/dig/c/rdos/trpld.c | 2 +- bld/dig/c/win/trpld.c | 2 +- 7 files changed, 17 insertions(+), 13 deletions(-) diff --git a/bld/dig/c/dos/trpld.c b/bld/dig/c/dos/trpld.c index f5c6042104..a5778d279c 100644 --- a/bld/dig/c/dos/trpld.c +++ b/bld/dig/c/dos/trpld.c @@ -137,18 +137,20 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) len++; } if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, len, "trp", filename, sizeof( filename ) ) == 0 ) { - sprintf( buff, "%s '%s'", TC_ERR_CANT_LOAD_TRAP, base_name ); + sprintf( buff, TC_ERR_CANT_LOAD_TRAP, base_name ); return( buff ); } fp = DIGLoader( Open )( filename ); if( fp == NULL ) { - sprintf( buff, "%s '%s'", TC_ERR_CANT_LOAD_TRAP, filename ); + sprintf( buff, TC_ERR_CANT_LOAD_TRAP, filename ); return( buff ); } buff[0] = '\0'; err = ReadInTrap( fp ); DIGLoader( Close )( fp ); - if( err == NULL ) { + if( err == TC_ERR_CANT_LOAD_TRAP ) { + sprintf( buff, TC_ERR_CANT_LOAD_TRAP, filename ); + } else if( err == NULL ) { if( TrapCode->signature == TRAP_SIGNATURE ) { init_func = _MK_FP( _FP_SEG( TrapCode ), TrapCode->init_off ); FiniFunc = _MK_FP( _FP_SEG( TrapCode ), TrapCode->fini_off ); diff --git a/bld/dig/c/dsx/trpld.c b/bld/dig/c/dsx/trpld.c index f30ae0939c..cbcc2458b9 100644 --- a/bld/dig/c/dsx/trpld.c +++ b/bld/dig/c/dsx/trpld.c @@ -506,18 +506,20 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) len++; } if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, len, "trp", filename, sizeof( filename ) ) == 0 ) { - sprintf( buff, "%s '%s'", TC_ERR_CANT_LOAD_TRAP, base_name ); + sprintf( buff, TC_ERR_CANT_LOAD_TRAP, base_name ); return( buff ); } - sprintf( buff, "%s '%s'", TC_ERR_CANT_LOAD_TRAP, filename ); fp = DIGLoader( Open )( filename ); if( fp == NULL ) { + sprintf( buff, TC_ERR_CANT_LOAD_TRAP, filename ); return( buff ); } buff[0] = '\0'; err = ReadInTrap( fp ); DIGLoader( Close )( fp ); - if( err == NULL ) { + if( err == TC_ERR_CANT_LOAD_TRAP ) { + sprintf( buff, TC_ERR_CANT_LOAD_TRAP, filename ); + } else if( err == NULL ) { if( (err = SetTrapHandler()) == NULL && (err = CopyEnv()) == NULL ) { head = EXTENDER_RM2PM( TrapMem.rm, 0 ); if( head->sig == TRAP_SIGNATURE ) { diff --git a/bld/dig/c/nt/trpld.c b/bld/dig/c/nt/trpld.c index f16bd5414d..f2501eca67 100644 --- a/bld/dig/c/nt/trpld.c +++ b/bld/dig/c/nt/trpld.c @@ -133,7 +133,7 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) *p = '\0'; TrapFile = LoadLibrary( filename ); if( TrapFile == NULL ) { - sprintf( buff, "%s '%s'", TC_ERR_CANT_LOAD_TRAP, filename ); + sprintf( buff, TC_ERR_CANT_LOAD_TRAP, filename ); return( buff ); } init_func = (trap_init_func *)GetProcAddress( TrapFile, (LPSTR)1 ); diff --git a/bld/dig/c/os2/trpld.c b/bld/dig/c/os2/trpld.c index 4544f0f478..0f0a765abd 100644 --- a/bld/dig/c/os2/trpld.c +++ b/bld/dig/c/os2/trpld.c @@ -146,11 +146,11 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) #endif _searchenv( trpname, "PATH", filename ); if( *filename == '\0' ) { - sprintf( buff, "%s '%s'", TC_ERR_CANT_LOAD_TRAP, trpname ); + sprintf( buff, TC_ERR_CANT_LOAD_TRAP, trpname ); return( buff ); } if( LOAD_MODULE( filename, TrapFile ) ) { - sprintf( buff, "%s '%s'", TC_ERR_CANT_LOAD_TRAP, filename ); + sprintf( buff, TC_ERR_CANT_LOAD_TRAP, filename ); return( buff ); } buff[0] = '\0'; diff --git a/bld/dig/c/qnx/trpld.c b/bld/dig/c/qnx/trpld.c index f98fa2aad1..508af1074b 100644 --- a/bld/dig/c/qnx/trpld.c +++ b/bld/dig/c/qnx/trpld.c @@ -97,10 +97,10 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) len++; } if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, len, "trp", filename, sizeof( filename ) ) ) { - sprintf( buff, "%s '%s'", TC_ERR_CANT_LOAD_TRAP, base_name ); + sprintf( buff, TC_ERR_CANT_LOAD_TRAP, base_name ); return( buff ); } - sprintf( buff, "%s '%s'", TC_ERR_CANT_LOAD_TRAP, filename ); + sprintf( buff, TC_ERR_CANT_LOAD_TRAP, filename ); fp = DIGLoader( Open )( filename ); if( fp == NULL ) { return( buff ); diff --git a/bld/dig/c/rdos/trpld.c b/bld/dig/c/rdos/trpld.c index 8050e0484f..aa9b090932 100644 --- a/bld/dig/c/rdos/trpld.c +++ b/bld/dig/c/rdos/trpld.c @@ -93,7 +93,7 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) *p = '\0'; TrapFile = RdosLoadDll( filename ); if( TrapFile == NULL ) { - sprintf( buff, "%s '%s'", TC_ERR_CANT_LOAD_TRAP, filename ); + sprintf( buff, TC_ERR_CANT_LOAD_TRAP, filename ); return( buff ); } buff[0] = '\0'; diff --git a/bld/dig/c/win/trpld.c b/bld/dig/c/win/trpld.c index 1db81cf90f..13084b0669 100644 --- a/bld/dig/c/win/trpld.c +++ b/bld/dig/c/win/trpld.c @@ -129,7 +129,7 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) SetErrorMode( prev ); if( (UINT)TrapFile < 32 ) { TrapFile = 0; - sprintf( buff, "%s '%s'", TC_ERR_CANT_LOAD_TRAP, filename ); + sprintf( buff, TC_ERR_CANT_LOAD_TRAP, filename ); return( buff ); } buff[0] = '\0'; From ddc7fb60ba7834e413858bdfee2b0d5fcf142363 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Sun, 27 Aug 2023 12:14:41 +0200 Subject: [PATCH 026/258] correct mistake in default file extension processing use bool type where it is possible --- bld/trap/common/dos/dosdigl.c | 2 +- bld/trap/common/dos/dospath.c | 20 ++--- bld/trap/common/linux/lnxdigl.c | 2 +- bld/trap/common/nt/ntdigl.c | 6 +- bld/trap/common/nt/ntpath.c | 20 ++--- bld/trap/common/nto/ntodigl.c | 4 +- bld/trap/common/os2/os2digl.c | 6 +- bld/trap/common/os2/os2path.c | 20 ++--- bld/trap/common/os2v2/os22digl.c | 6 +- bld/trap/common/os2v2/os22path.c | 20 ++--- bld/trap/common/qnx/qnxdigl.c | 4 +- bld/trap/common/rdos/rdosdigl.c | 6 +- bld/trap/common/win/windigl.c | 6 +- bld/trap/common/win/winpath.c | 20 ++--- bld/trap/lcl/os2v2/c/accmisc.c | 2 +- bld/trap/lcl/os2v2/c/os2v2acc.c | 36 ++++----- bld/trap/lcl/os2v2/c/pgmexec.c | 130 +++++++++++++++---------------- bld/trap/lcl/os2v2/c/pmhelp.c | 9 ++- bld/trap/lcl/os2v2/test/dbg.c | 2 +- bld/wv/c/dbgfile.c | 62 +++++++-------- 20 files changed, 183 insertions(+), 200 deletions(-) diff --git a/bld/trap/common/dos/dosdigl.c b/bld/trap/common/dos/dosdigl.c index 43dc5574da..9cc6ce265b 100644 --- a/bld/trap/common/dos/dosdigl.c +++ b/bld/trap/common/dos/dosdigl.c @@ -76,7 +76,7 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *name, size_t name_len, break; } } - if( !has_ext ) { + if( !has_ext && *defext != NULLCHAR ) { *p++ = '.'; p = StrCopyDst( defext, p ); } diff --git a/bld/trap/common/dos/dospath.c b/bld/trap/common/dos/dospath.c index de4f0570a5..97e450b30b 100644 --- a/bld/trap/common/dos/dospath.c +++ b/bld/trap/common/dos/dospath.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -110,27 +110,27 @@ unsigned long FindFilePath( dig_filetype file_type, const char *pgm, char *buffe char *p2; const char *p3; tiny_ret_t rc; - int have_ext; - int have_path; + bool has_ext; + bool has_path; const char *ext_list; - have_ext = 0; - have_path = 0; + has_ext = false; + has_path = false; for( p3 = pgm, p2 = buffer; (*p2 = *p3) != '\0'; ++p3, ++p2 ) { switch( *p3 ) { case '\\': case '/': case ':': - have_path = 1; - have_ext = 0; + has_path = true; + has_ext = false; break; case '.': - have_ext = 1; + has_ext = true; break; } } ext_list = "\0"; - if( have_ext == 0 && file_type == DIG_FILETYPE_EXE ) { + if( !has_ext && file_type == DIG_FILETYPE_EXE ) { #if defined( DOSXTRAP ) #if defined( DOS4G ) ext_list = ".exe\0"; @@ -142,7 +142,7 @@ unsigned long FindFilePath( dig_filetype file_type, const char *pgm, char *buffe #endif } rc = TryPath( buffer, p2, ext_list ); - if( TINY_OK( rc ) || have_path ) + if( TINY_OK( rc ) || has_path ) return( rc ); path = DOSEnvFind( "PATH" ); if( path == NULL ) diff --git a/bld/trap/common/linux/lnxdigl.c b/bld/trap/common/linux/lnxdigl.c index 527465ea1e..05e75fcf6d 100644 --- a/bld/trap/common/linux/lnxdigl.c +++ b/bld/trap/common/linux/lnxdigl.c @@ -67,7 +67,7 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *name, size_t name_len, break; } } - if( !has_ext ) { + if( !has_ext && *defext != NULLCHAR ) { *p++ = '.'; p = StrCopyDst( defext, p ); } diff --git a/bld/trap/common/nt/ntdigl.c b/bld/trap/common/nt/ntdigl.c index 71236a7163..36aa5b92d7 100644 --- a/bld/trap/common/nt/ntdigl.c +++ b/bld/trap/common/nt/ntdigl.c @@ -68,11 +68,9 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *name, size_t name_len, break; } } - if( !has_ext ) { + if( !has_ext && *defext != NULLCHAR ) { *p++ = '.'; - while( (*p++ = *defext++) != '\0' ) { - /* nothing to do */ - } + p = StrCopyDst( defext, p ); } *p = '\0'; p = trpfile; diff --git a/bld/trap/common/nt/ntpath.c b/bld/trap/common/nt/ntpath.c index eb5b89e089..bad10441de 100644 --- a/bld/trap/common/nt/ntpath.c +++ b/bld/trap/common/nt/ntpath.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -71,36 +71,36 @@ unsigned long FindFilePath( dig_filetype file_type, const char *pgm, char *buffe { const char *p; char *p2; - BOOL have_ext; - BOOL have_path; + bool has_ext; + bool has_path; char *envbuf; DWORD envlen; unsigned long rc; const char *ext_list; - have_ext = FALSE; - have_path = FALSE; + has_ext = false; + has_path = false; for( p = pgm, p2 = buffer; (*p2 = *p) != 0; ++p, ++p2 ) { switch( *p ) { case '\\': case '/': case ':': - have_path = TRUE; - have_ext = FALSE; + has_path = true; + has_ext = false; break; case '.': - have_ext = TRUE; + has_ext = true; break; } } ext_list = "\0"; - if( have_ext == 0 && file_type == DIG_FILETYPE_EXE ) { + if( !has_ext && file_type == DIG_FILETYPE_EXE ) { ext_list = ".com\0.exe\0"; } if( !tryPath( buffer, p2, ext_list ) ) { return( 0 ); } - if( have_path ) { + if( has_path ) { return( ERROR_FILE_NOT_FOUND ); } envlen = GetEnvironmentVariable( "PATH", NULL, 0 ); diff --git a/bld/trap/common/nto/ntodigl.c b/bld/trap/common/nto/ntodigl.c index 30b4c2f035..8838a3c4c3 100644 --- a/bld/trap/common/nto/ntodigl.c +++ b/bld/trap/common/nto/ntodigl.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -71,7 +71,7 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *name, size_t name_len, break; } } - if( !has_ext ) { + if( !has_ext && *defext != NULLCHAR ) { *p++ = '.'; p = StrCopyDst( defext, p ); } diff --git a/bld/trap/common/os2/os2digl.c b/bld/trap/common/os2/os2digl.c index 71236a7163..36aa5b92d7 100644 --- a/bld/trap/common/os2/os2digl.c +++ b/bld/trap/common/os2/os2digl.c @@ -68,11 +68,9 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *name, size_t name_len, break; } } - if( !has_ext ) { + if( !has_ext && *defext != NULLCHAR ) { *p++ = '.'; - while( (*p++ = *defext++) != '\0' ) { - /* nothing to do */ - } + p = StrCopyDst( defext, p ); } *p = '\0'; p = trpfile; diff --git a/bld/trap/common/os2/os2path.c b/bld/trap/common/os2/os2path.c index fe370b3ddf..0efcbdfba7 100644 --- a/bld/trap/common/os2/os2path.c +++ b/bld/trap/common/os2/os2path.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -79,31 +79,31 @@ unsigned long FindFilePath( dig_filetype file_type, const char *pgm, char *buffe const char *p; char *p2; unsigned long rc; - int have_ext; - int have_path; + bool has_ext; + bool has_path; const char *ext_list; - have_ext = 0; - have_path = 0; + has_ext = false; + has_path = false; for( p = pgm, p2 = buffer; (*p2 = *p) != '\0'; ++p, ++p2 ) { switch( *p ) { case '\\': case '/': case ':': - have_path = 1; - have_ext = 0; + has_path = true; + has_ext = false; break; case '.': - have_ext = 1; + has_ext = true; break; } } ext_list = "\0"; - if( have_ext == 0 && file_type == DIG_FILETYPE_EXE ) { + if( !has_ext && file_type == DIG_FILETYPE_EXE ) { ext_list = ".exe\0"; } rc = TryPath( buffer, p2, ext_list ); - if( rc == 0 || have_path ) + if( rc == 0 || has_path ) return( rc ); if( DosScanEnv( "PATH", (PSZ FAR *)&p ) != 0 ) return( rc ); diff --git a/bld/trap/common/os2v2/os22digl.c b/bld/trap/common/os2v2/os22digl.c index d77b8ee958..2bb0bbc05f 100644 --- a/bld/trap/common/os2v2/os22digl.c +++ b/bld/trap/common/os2v2/os22digl.c @@ -68,11 +68,9 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *name, size_t name_len, break; } } - if( !has_ext ) { + if( !has_ext && *defext != NULLCHAR ) { *p++ = '.'; - while( (*p++ = *defext++) != '\0' ) { - ; /* nothing to do */ - } + p = StrCopyDst( defext, p ); } *p = '\0'; p = trpfile; diff --git a/bld/trap/common/os2v2/os22path.c b/bld/trap/common/os2v2/os22path.c index cbe28ea4fc..8b7c64b487 100644 --- a/bld/trap/common/os2v2/os22path.c +++ b/bld/trap/common/os2v2/os22path.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -76,31 +76,31 @@ unsigned long FindFilePath( dig_filetype file_type, const char *pgm, char *buffe const char *p; char *p2; unsigned long rc; - int have_ext; - int have_path; + bool has_ext; + bool has_path; const char *ext_list; - have_ext = 0; - have_path = 0; + has_ext = false; + has_path = false; for( p = pgm, p2 = buffer; (*p2 = *p) != '\0'; ++p, ++p2 ) { switch( *p ) { case '\\': case '/': case ':': - have_path = 1; - have_ext = 0; + has_path = true; + has_ext = false; break; case '.': - have_ext = 1; + has_ext = true; break; } } ext_list = "\0"; - if( have_ext == 0 && file_type == DIG_FILETYPE_EXE ) { + if( !has_ext && file_type == DIG_FILETYPE_EXE ) { ext_list = ".exe\0"; } rc = TryPath( buffer, p2, ext_list ); - if( rc == 0 || have_path ) + if( rc == 0 || has_path ) return( rc ); if( DosScanEnv( "PATH", &p2 ) != 0 ) return( rc ); diff --git a/bld/trap/common/qnx/qnxdigl.c b/bld/trap/common/qnx/qnxdigl.c index 8d75dd52ac..982ea4be32 100644 --- a/bld/trap/common/qnx/qnxdigl.c +++ b/bld/trap/common/qnx/qnxdigl.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -71,7 +71,7 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *name, size_t name_len, break; } } - if( !has_ext ) { + if( !has_ext && *defext != NULLCHAR ) { *p++ = '.'; p = StrCopyDst( defext, p ); } diff --git a/bld/trap/common/rdos/rdosdigl.c b/bld/trap/common/rdos/rdosdigl.c index 71236a7163..36aa5b92d7 100644 --- a/bld/trap/common/rdos/rdosdigl.c +++ b/bld/trap/common/rdos/rdosdigl.c @@ -68,11 +68,9 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *name, size_t name_len, break; } } - if( !has_ext ) { + if( !has_ext && *defext != NULLCHAR ) { *p++ = '.'; - while( (*p++ = *defext++) != '\0' ) { - /* nothing to do */ - } + p = StrCopyDst( defext, p ); } *p = '\0'; p = trpfile; diff --git a/bld/trap/common/win/windigl.c b/bld/trap/common/win/windigl.c index 71236a7163..36aa5b92d7 100644 --- a/bld/trap/common/win/windigl.c +++ b/bld/trap/common/win/windigl.c @@ -68,11 +68,9 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *name, size_t name_len, break; } } - if( !has_ext ) { + if( !has_ext && *defext != NULLCHAR ) { *p++ = '.'; - while( (*p++ = *defext++) != '\0' ) { - /* nothing to do */ - } + p = StrCopyDst( defext, p ); } *p = '\0'; p = trpfile; diff --git a/bld/trap/common/win/winpath.c b/bld/trap/common/win/winpath.c index d4ea76942c..d7651f1c9f 100644 --- a/bld/trap/common/win/winpath.c +++ b/bld/trap/common/win/winpath.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -95,31 +95,31 @@ unsigned long FindFilePath( dig_filetype file_type, const char *pgm, char *buffe char *p2; const char *p3; tiny_ret_t rc; - int have_ext; - int have_path; + bool has_ext; + bool has_path; const char *ext_list; - have_ext = 0; - have_path = 0; + has_ext = false; + has_path = false; for( p3 = pgm, p2 = buffer; (*p2 = *p3) != '\0'; ++p3, ++p2 ) { switch( *p3 ) { case '\\': case '/': case ':': - have_path = 1; - have_ext = 0; + has_path = true; + has_ext = false; break; case '.': - have_ext = 1; + has_ext = true; break; } } ext_list = "\0"; - if( have_ext == 0 && file_type == DIG_FILETYPE_EXE ) { + if( !has_ext && file_type == DIG_FILETYPE_EXE ) { ext_list = ".com\0.exe\0"; } rc = TryPath( buffer, p2, ext_list ); - if( TINY_OK( rc ) || have_path ) + if( TINY_OK( rc ) || has_path ) return( rc ); path = DOSEnvFind( "PATH" ); if( path == NULL ) diff --git a/bld/trap/lcl/os2v2/c/accmisc.c b/bld/trap/lcl/os2v2/c/accmisc.c index 39cf0e6a6b..24a6fa85b1 100644 --- a/bld/trap/lcl/os2v2/c/accmisc.c +++ b/bld/trap/lcl/os2v2/c/accmisc.c @@ -56,7 +56,7 @@ * globals */ PID Pid = 0; -bool AtEnd = FALSE; +bool AtEnd = false; ULONG SID; /* Session ID */ bool Remote; char UtilBuff[BUFF_SIZE]; diff --git a/bld/trap/lcl/os2v2/c/os2v2acc.c b/bld/trap/lcl/os2v2/c/os2v2acc.c index 676988c4b4..462b7cf871 100644 --- a/bld/trap/lcl/os2v2/c/os2v2acc.c +++ b/bld/trap/lcl/os2v2/c/os2v2acc.c @@ -409,10 +409,10 @@ bool DebugExecute( uDB_t *buff, ULONG cmd, bool stop_on_module_load ) break; } } - return( FALSE ); + return( false ); } } -// return( FALSE ); +// return( false ); } @@ -957,7 +957,7 @@ static bool ExecuteUntilLinearAddressHit( ULONG lin ) splice_bp_lin_addr = lin; do { ExceptNum = 0; - DebugExecute( &Buff, DBG_C_Go, TRUE ); + DebugExecute( &Buff, DBG_C_Go, true ); if( ExceptNum == 0 ) { rc = true; // DLL loaded /* Breaking on DLL load means that this routine does not @@ -1053,7 +1053,7 @@ trap_retval TRAP_CORE( Prog_load )( void ) ExceptNum = -1; ret = GetOutPtr( 0 ); ret->err = 0; - AtEnd = FALSE; + AtEnd = false; TaskFS = 0; attach_pid = -1; src = name = GetInPtr( sizeof( prog_load_req ) ); @@ -1133,7 +1133,7 @@ trap_retval TRAP_CORE( Prog_load )( void ) Buff.Pid = Pid; Buff.Tid = 1; if( !isAttached ) { - DebugExecute( &Buff, DBG_C_Stop, FALSE ); + DebugExecute( &Buff, DBG_C_Stop, false ); if( Buff.Cmd != DBG_N_Success ) { ret->err = 14; /* can't load */ return( sizeof( *ret ) ); @@ -1314,7 +1314,7 @@ trap_retval TRAP_CORE( Clear_watch )( void ) *dst = *src; ++dst; } else { - DebugExecute( &Buff, DBG_C_Stop, FALSE ); + DebugExecute( &Buff, DBG_C_Stop, false ); Buff.Cmd = DBG_C_ClearWatch; Buff.Index = 0; // src->id; CallDosDebug( &Buff ); @@ -1372,7 +1372,7 @@ static trap_conditions MapReturn( trap_conditions conditions ) Buff.Pid = Pid; CallDosDebug( &Buff ); default: - AtEnd = TRUE; + AtEnd = true; CanExecTask = false; return( conditions | COND_TERMINATE ); } @@ -1387,7 +1387,7 @@ static bool setDebugRegs( void ) word size; if( DRegsCount() > 4 ) { - return( FALSE ); + return( false ); } for( wp = WatchPoints, i = WatchCount; i-- > 0; wp++ ) { linear = wp->linear; @@ -1404,7 +1404,7 @@ static bool setDebugRegs( void ) linear += size; } } - return( TRUE ); + return( true ); } static bool CheckWatchPoints( void ) @@ -1428,13 +1428,13 @@ static bool CheckWatchPoints( void ) static void watchSingleStep(void) { - DebugExecute( &Buff, DBG_C_SStep, TRUE ); + DebugExecute( &Buff, DBG_C_SStep, true ); while( Buff.Cmd == DBG_N_SStep ) { if( CheckWatchPoints() ) { Buff.Cmd = DBG_N_Watchpoint; break; } - DebugExecute( &Buff, DBG_C_SStep, TRUE ); + DebugExecute( &Buff, DBG_C_SStep, true ); } } @@ -1483,7 +1483,7 @@ static unsigned progRun( bool step ) ret->program_counter.offset = lastEIP; return( sizeof( *ret ) ); } - BrkPending = FALSE; + BrkPending = false; // Set exception handler and don't forget to set signal focus! DosSetExceptionHandler( &RegRec ); @@ -1492,11 +1492,11 @@ static unsigned progRun( bool step ) if( AtEnd ) { Buff.Cmd = DBG_N_ProcTerm; } else if( step ) { - DebugExecute( &Buff, DBG_C_SStep, TRUE ); + DebugExecute( &Buff, DBG_C_SStep, true ); } else if( !setDebugRegs() ) { watchSingleStep(); } else { - DebugExecute( &Buff, DBG_C_Go, TRUE ); + DebugExecute( &Buff, DBG_C_Go, true ); if( Buff.Cmd == DBG_N_Success ) { Buff.Cmd = DBG_N_ProcTerm; } @@ -1516,7 +1516,7 @@ static unsigned progRun( bool step ) lastEIP = ret->program_counter.offset = Buff.EIP; //runret->thread = Buff.Tid; //if( runret->returnvalue == TRAP_TERMINATE ) { - // AtEnd = TRUE; + // AtEnd = true; // CanExecTask = false; //} return( sizeof( *ret ) ); @@ -1527,7 +1527,7 @@ trap_retval TRAP_CORE( Prog_go )( void ) trap_elen rc; PMUnLock(); - rc = progRun( FALSE ); + rc = progRun( false ); PMLock( Buff.Pid, Buff.Tid ); return( rc ); } @@ -1537,7 +1537,7 @@ trap_retval TRAP_CORE( Prog_step )( void ) trap_elen rc; PMUnLock(); - rc = progRun( TRUE ); + rc = progRun( true ); PMLock( Buff.Pid, Buff.Tid ); return( rc ); } @@ -1743,7 +1743,7 @@ trap_version TRAPENTRY TrapInit( const char *parms, char *err, bool remote ) err[0] = '\0'; ver.major = TRAP_MAJOR_VERSION; ver.minor = TRAP_MINOR_VERSION; - ver.remote = FALSE; + ver.remote = false; SaveStdIn = NIL_DOS_HANDLE; SaveStdOut = NIL_DOS_HANDLE; Screen = DEBUG_SCREEN; diff --git a/bld/trap/lcl/os2v2/c/pgmexec.c b/bld/trap/lcl/os2v2/c/pgmexec.c index 73f315b29c..8a800b5f34 100644 --- a/bld/trap/lcl/os2v2/c/pgmexec.c +++ b/bld/trap/lcl/os2v2/c/pgmexec.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -95,67 +95,61 @@ bool CausePgmToLoadHelperDLL( ULONG startLinear ) char szHelperDLL[BUFF_SIZE]; bool rc; + rc = false; /* * save a chunk of the program's code, and put in LoadThisDLL instead */ - if( DosQueryModuleHandle( "wdsplice", &hmodHelper ) != 0 ) - return( FALSE ); - - if( DosQueryModuleName( hmodHelper, BUFF_SIZE, szHelperDLL ) != 0 ) - return( FALSE ); - - codesize = (char *)EndLoadHelperDLL - (char *)LoadHelperDLL; - if( codesize > LOAD_HELPER_DLL_SIZE ) - return( FALSE ); - ReadLinear( savecode, startLinear, codesize ); - if( Buff.Cmd != DBG_N_Success ) - return( FALSE ); - WriteLinear( (char*)LoadHelperDLL, startLinear, codesize ); - - /* - * set up the stack for the routine LoadHelperDLL; first set up - * the stack contents in temporary buffer, then copy it onto - * debuggee's real stack - */ - dll_name_len = (strlen(szHelperDLL) + 3) & ~3; // DWORD align - size = sizeof(loadstack_t) + dll_name_len; - loadstack = (loadstack_t*)TempStack; - Buff.ESP -= size; - strcpy( (char *)loadstack->load_name, szHelperDLL ); - // Offsets must be relative to where loadstack will end up! - loadstack->mod_name = (PSZ)(MakeItFlatNumberOne( Buff.SS, Buff.ESP ) + 20); - loadstack->phmod = (HMODULE*)(MakeItFlatNumberOne( Buff.SS, Buff.ESP ) + 16); - loadstack->fail_name = loadstack->mod_name; // Reuse buffer - loadstack->fail_len = dll_name_len; - len = WriteBuffer( (char *)loadstack, Buff.SS, Buff.ESP, size ); - if( len != size ) - return( FALSE ); - - /* - * set up flat CS:EIP, SS:ESP for execution; note that this works for - * 16-bit apps as well - */ - Buff.EIP = startLinear; - Buff.CS = FlatCS; - Buff.ESP = MakeItFlatNumberOne( Buff.SS, Buff.ESP ); - Buff.SS = FlatDS; - Buff.DS = FlatDS; - Buff.ES = FlatDS; - - /* - * execute LoadThisDLL on behalf of the program - */ - WriteRegs( &Buff ); - DebugExecute( &Buff, DBG_C_Go, FALSE ); - if( Buff.Cmd != DBG_N_Breakpoint ) { - rc = FALSE; - } else { - rc = TRUE; + if( DosQueryModuleHandle( "wdsplice", &hmodHelper ) == 0 ) { + if( DosQueryModuleName( hmodHelper, BUFF_SIZE, szHelperDLL ) == 0 ) { + codesize = (char *)EndLoadHelperDLL - (char *)LoadHelperDLL; + if( codesize <= LOAD_HELPER_DLL_SIZE ) { + ReadLinear( savecode, startLinear, codesize ); + if( Buff.Cmd == DBG_N_Success ) { + WriteLinear( (char*)LoadHelperDLL, startLinear, codesize ); + /* + * set up the stack for the routine LoadHelperDLL; first set up + * the stack contents in temporary buffer, then copy it onto + * debuggee's real stack + */ + dll_name_len = (strlen(szHelperDLL) + 3) & ~3; // DWORD align + size = sizeof(loadstack_t) + dll_name_len; + loadstack = (loadstack_t*)TempStack; + Buff.ESP -= size; + strcpy( (char *)loadstack->load_name, szHelperDLL ); + // Offsets must be relative to where loadstack will end up! + loadstack->mod_name = (PSZ)(MakeItFlatNumberOne( Buff.SS, Buff.ESP ) + 20); + loadstack->phmod = (HMODULE*)(MakeItFlatNumberOne( Buff.SS, Buff.ESP ) + 16); + loadstack->fail_name = loadstack->mod_name; // Reuse buffer + loadstack->fail_len = dll_name_len; + len = WriteBuffer( (char *)loadstack, Buff.SS, Buff.ESP, size ); + if( len == size ) { + /* + * set up flat CS:EIP, SS:ESP for execution; note that this works for + * 16-bit apps as well + */ + Buff.EIP = startLinear; + Buff.CS = FlatCS; + Buff.ESP = MakeItFlatNumberOne( Buff.SS, Buff.ESP ); + Buff.SS = FlatDS; + Buff.DS = FlatDS; + Buff.ES = FlatDS; + /* + * execute LoadThisDLL on behalf of the program + */ + WriteRegs( &Buff ); + DebugExecute( &Buff, DBG_C_Go, false ); + if( Buff.Cmd == DBG_N_Breakpoint ) { + rc = true; + } + /* + * put back original memory contents + */ + WriteLinear( savecode, startLinear, codesize ); + } + } + } + } } - /* - * put back original memory contents - */ - WriteLinear( savecode, startLinear, codesize ); return( rc ); } @@ -170,7 +164,7 @@ static long TaskExecute( excfn rtn ) if( CanExecTask ) { ULONG oldExcNum = ExceptNum; - ExpectingAFault = TRUE; + ExpectingAFault = true; Buff.CS = FlatCS; Buff.EIP = (ULONG)rtn; Buff.SS = FlatDS; @@ -184,10 +178,10 @@ static long TaskExecute( excfn rtn ) if( Buff.Cmd != DBG_N_Success ) { retval = -1; } else { - DebugExecute( &Buff, DBG_C_Go, FALSE ); + DebugExecute( &Buff, DBG_C_Go, false ); retval = Buff.EAX; } - ExpectingAFault = FALSE; + ExpectingAFault = false; ExceptNum = oldExcNum; return( retval ); } else { @@ -256,10 +250,9 @@ bool TaskReadWord( USHORT seg, ULONG off, USHORT *data ) Buff.EBX = off; Buff.GS = seg; TaskExecute( (excfn)DoReadWord ); - if( Buff.Cmd != DBG_N_Breakpoint ) { - rc = FALSE; - } else { - rc = TRUE; + rc = false; + if( Buff.Cmd == DBG_N_Breakpoint ) { + rc = true; *data = (USHORT)Buff.EAX; } WriteRegs( &save ); @@ -277,10 +270,9 @@ bool TaskWriteWord( USHORT seg, ULONG off, USHORT data ) Buff.EBX = off; Buff.GS = seg; TaskExecute( (excfn)DoWriteWord ); - if( Buff.Cmd != DBG_N_Breakpoint ) { - rc = FALSE; - } else { - rc = TRUE; + rc = false; + if( Buff.Cmd == DBG_N_Breakpoint ) { + rc = true; } WriteRegs( &save ); return( rc ); diff --git a/bld/trap/lcl/os2v2/c/pmhelp.c b/bld/trap/lcl/os2v2/c/pmhelp.c index bd99e26a6d..e3a290d696 100644 --- a/bld/trap/lcl/os2v2/c/pmhelp.c +++ b/bld/trap/lcl/os2v2/c/pmhelp.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -42,6 +42,7 @@ #include #include #include +#include "bool.h" #include "wdpmhelp.rh" #include "wdpmhelp.h" #include "trperr.h" @@ -59,7 +60,7 @@ static HFILE InStream; static HFILE OutStream; static HWND hwndClient; static HWND hwndFrame; -static BOOL Locked = FALSE; +static bool Locked = false; static PID PidDebugee; // These two seem unused? static TID TidDebugee; @@ -118,7 +119,7 @@ static void UnLockIt( void ) WinThreadAssocQueue( Hab, Hmq ); WinLockInput( 0, 0 ); WinThreadAssocQueue( Hab, NULLHANDLE ); - Locked = FALSE; + Locked = false; } } @@ -134,7 +135,7 @@ static void LockIt( void ) WinThreadAssocQueue( Hab, Hmq ); WinLockInput( 0, 1 ); WinThreadAssocQueue( Hab, NULLHANDLE ); - Locked = TRUE; + Locked = true; } } diff --git a/bld/trap/lcl/os2v2/test/dbg.c b/bld/trap/lcl/os2v2/test/dbg.c index d0999dc2fd..df6b41ef72 100644 --- a/bld/trap/lcl/os2v2/test/dbg.c +++ b/bld/trap/lcl/os2v2/test/dbg.c @@ -122,7 +122,7 @@ int RunIt() trap_types trap; for( ;; ) { - switch( trap = DoRunProg( FALSE, &why ) ) { + switch( trap = DoRunProg( false, &why ) ) { case TRAP_SKIP: if( why & CHANGE_LIBRARIES ) { AddLibInfo(); diff --git a/bld/wv/c/dbgfile.c b/bld/wv/c/dbgfile.c index 53dc2b2c5e..f0d5e08fdf 100644 --- a/bld/wv/c/dbgfile.c +++ b/bld/wv/c/dbgfile.c @@ -476,15 +476,15 @@ file_handle LclStringToFullName( const char *name, size_t len, char *full ) /* * */ -static file_handle FullPathOpenInternal( const char *name, size_t name_len, const char *ext, +static file_handle FullPathOpenInternal( const char *name, size_t name_len, const char *defext, char *result, size_t result_len, bool force_local ) { char buffer[TXT_LEN]; char *p; const char *p1; obj_attrs oattrs; - bool have_ext; - bool have_path; + bool has_ext; + bool has_path; const file_components *file; file_handle fh; char c; @@ -493,8 +493,8 @@ static file_handle FullPathOpenInternal( const char *name, size_t name_len, cons p1 = FileLoc( name, &oattrs ); name_len -= p1 - name; name = p1; - have_ext = false; - have_path = false; + has_ext = false; + has_path = false; if( force_local ) { oattrs &= ~OP_REMOTE; oattrs |= OP_LOCAL; @@ -509,21 +509,21 @@ static file_handle FullPathOpenInternal( const char *name, size_t name_len, cons c = *name++; *p++ = c; if( CHK_PATH_SEP( c, file ) ) { - have_ext = false; - have_path = true; + has_ext = false; + has_path = true; } else if( c == file->ext_separator ) { - have_ext = true; + has_ext = true; } } - if( !have_ext ) { + if( !has_ext && *defext != NULLCHAR ) { *p++ = file->ext_separator; - p = StrCopyDst( ext, p ); + p = StrCopyDst( defext, p ); } *p = NULLCHAR; if( oattrs & OP_REMOTE ) { RemoteStringToFullName( DIG_FILETYPE_PRS, buffer, result, (trap_elen)result_len ); fh = FileOpen( result, OP_READ | OP_REMOTE ); - } else if( have_path ) { + } else if( has_path ) { StrCopyDst( buffer, result ); fh = FileOpen( buffer, OP_READ ); } else { @@ -538,35 +538,35 @@ static file_handle FullPathOpenInternal( const char *name, size_t name_len, cons return( fh ); } -file_handle FullPathOpen( const char *name, size_t name_len, const char *ext, char *result, size_t result_len ) +file_handle FullPathOpen( const char *name, size_t name_len, const char *defext, char *result, size_t result_len ) { - return( FullPathOpenInternal( name, name_len, ext, result, result_len, false ) ); + return( FullPathOpenInternal( name, name_len, defext, result, result_len, false ) ); } -file_handle LocalFullPathOpen( const char *name, size_t name_len, const char *ext, char *result, size_t result_len ) +file_handle LocalFullPathOpen( const char *name, size_t name_len, const char *defext, char *result, size_t result_len ) { - return( FullPathOpenInternal( name, name_len, ext, result, result_len, true ) ); + return( FullPathOpenInternal( name, name_len, defext, result, result_len, true ) ); } -static file_handle PathOpenInternal( const char *name, size_t name_len, const char *ext, bool force_local ) +static file_handle PathOpenInternal( const char *name, size_t name_len, const char *defext, bool force_local ) { char result[TXT_LEN]; if( force_local ) { - return( LocalFullPathOpen( name, name_len, ext, result, TXT_LEN ) ); + return( LocalFullPathOpen( name, name_len, defext, result, TXT_LEN ) ); } else { - return( FullPathOpen( name, name_len, ext, result, TXT_LEN ) ); + return( FullPathOpen( name, name_len, defext, result, TXT_LEN ) ); } } -file_handle PathOpen( const char *name, size_t name_len, const char *ext ) +file_handle PathOpen( const char *name, size_t name_len, const char *defext ) { - return( PathOpenInternal( name, name_len, ext, false ) ); + return( PathOpenInternal( name, name_len, defext, false ) ); } -file_handle LocalPathOpen( const char *name, size_t name_len, const char *ext ) +file_handle LocalPathOpen( const char *name, size_t name_len, const char *defext ) { - return( PathOpenInternal( name, name_len, ext, true ) ); + return( PathOpenInternal( name, name_len, defext, true ) ); } #if !defined( BUILD_RFX ) @@ -770,33 +770,33 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *name, size_t name_len, char buffer[TXT_LEN]; char filename[TXT_LEN]; char *p; - bool have_ext; - bool have_path; + bool has_ext; + bool has_path; char c; char_ring *curr; size_t len; /* unused parameters */ (void)ftype; - have_ext = false; - have_path = false; + has_ext = false; + has_path = false; p = buffer; while( name_len-- > 0 ) { c = *name++; *p++ = c; if( CHK_PATH_SEP( c, &LclFile ) ) { - have_ext = false; - have_path = true; + has_ext = false; + has_path = true; } else if( c == LclFile.ext_separator ) { - have_ext = true; + has_ext = true; } } - if( !have_ext ) { + if( !has_ext && *defext != NULLCHAR ) { *p++ = LclFile.ext_separator; p = StrCopyDst( defext, p ); } *p = NULLCHAR; - if( have_path ) { + if( has_path ) { p = buffer; } else { // check open file in current directory or in full path From 35fc3a3749145a3a0e0a7fc7bafb6ea7b3e314c2 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Sun, 27 Aug 2023 15:27:53 +0200 Subject: [PATCH 027/258] correct build break macro NULLCHAR is not defined for dig/mad/trp, use C terminator --- bld/trap/common/dos/dosdigl.c | 2 +- bld/trap/common/linux/lnxdigl.c | 42 ++++++++++++++++++++------------ bld/trap/common/nt/ntdigl.c | 3 ++- bld/trap/common/nto/ntodigl.c | 2 +- bld/trap/common/os2/os2digl.c | 2 +- bld/trap/common/os2v2/os22digl.c | 3 ++- bld/trap/common/qnx/qnxdigl.c | 2 +- bld/trap/common/rdos/rdosdigl.c | 3 ++- bld/trap/common/rdos/rdospath.c | 11 ++++++++- bld/trap/common/rdos/rdospath.h | 3 ++- bld/trap/common/win/windigl.c | 3 ++- 11 files changed, 51 insertions(+), 25 deletions(-) diff --git a/bld/trap/common/dos/dosdigl.c b/bld/trap/common/dos/dosdigl.c index 9cc6ce265b..b7d4d7f9f6 100644 --- a/bld/trap/common/dos/dosdigl.c +++ b/bld/trap/common/dos/dosdigl.c @@ -76,7 +76,7 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *name, size_t name_len, break; } } - if( !has_ext && *defext != NULLCHAR ) { + if( !has_ext && *defext != '\0' ) { *p++ = '.'; p = StrCopyDst( defext, p ); } diff --git a/bld/trap/common/linux/lnxdigl.c b/bld/trap/common/linux/lnxdigl.c index 05e75fcf6d..98ab7b0080 100644 --- a/bld/trap/common/linux/lnxdigl.c +++ b/bld/trap/common/linux/lnxdigl.c @@ -31,21 +31,24 @@ ****************************************************************************/ +#include #include #include #include +#include "digcli.h" #include "digld.h" #include "lnxpath.h" #include "servio.h" -size_t DIGLoader( Find )( dig_filetype ftype, const char *name, size_t name_len, const char *defext, char *result, size_t result_len ) +size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base_name_len, +const char *defext, char *filename, size_t filename_len ) /************************************************************************************************************************************/ { bool has_ext; bool has_path; char *p; - char trpfile[256]; + char fname[256]; char c; size_t len; @@ -53,9 +56,9 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *name, size_t name_len, has_ext = false; has_path = false; - p = trpfile; - while( name_len-- > 0 ) { - c = *name++; + p = fname; + while( base_name_len-- > 0 ) { + c = *base_name++; *p++ = c; switch( c ) { case '.': @@ -67,26 +70,26 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *name, size_t name_len, break; } } - if( !has_ext && *defext != NULLCHAR ) { + if( !has_ext && *defext != '\0' ) { *p++ = '.'; p = StrCopyDst( defext, p ); } *p = '\0'; if( has_path ) { - p = trpfile; - } else if( FindFilePath( DIG_FILETYPE_DBG, trpfile, RWBuff ) ) { + p = fname; + } else if( FindFilePath( DIG_FILETYPE_DBG, fname, RWBuff ) ) { p = RWBuff; } else { p = ""; } len = strlen( p ); - if( result_len > 0 ) { - result_len--; - if( result_len > len ) - result_len = len; - if( result_len > 0 ) - strncpy( result, p, result_len ); - result[result_len] = '\0'; + if( filename_len > 0 ) { + filename_len--; + if( filename_len > len ) + filename_len = len; + if( filename_len > 0 ) + strncpy( filename, p, filename_len ); + filename[filename_len] = '\0'; } return( len ); } @@ -111,3 +114,12 @@ int DIGLoader( Close )( FILE *fp ) return( fclose( fp ) ); } +void *DIGCLIENTRY( Alloc )( size_t amount ) +{ + return( malloc( amount ) ); +} + +void DIGCLIENTRY( Free )( void *p ) +{ + free( p ); +} diff --git a/bld/trap/common/nt/ntdigl.c b/bld/trap/common/nt/ntdigl.c index 36aa5b92d7..3626072c6b 100644 --- a/bld/trap/common/nt/ntdigl.c +++ b/bld/trap/common/nt/ntdigl.c @@ -34,6 +34,7 @@ #include #include #include "digld.h" +#include "ntpath.h" #include "servio.h" @@ -68,7 +69,7 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *name, size_t name_len, break; } } - if( !has_ext && *defext != NULLCHAR ) { + if( !has_ext && *defext != '\0' ) { *p++ = '.'; p = StrCopyDst( defext, p ); } diff --git a/bld/trap/common/nto/ntodigl.c b/bld/trap/common/nto/ntodigl.c index 8838a3c4c3..77ab24cf7d 100644 --- a/bld/trap/common/nto/ntodigl.c +++ b/bld/trap/common/nto/ntodigl.c @@ -71,7 +71,7 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *name, size_t name_len, break; } } - if( !has_ext && *defext != NULLCHAR ) { + if( !has_ext && *defext != '\0' ) { *p++ = '.'; p = StrCopyDst( defext, p ); } diff --git a/bld/trap/common/os2/os2digl.c b/bld/trap/common/os2/os2digl.c index 36aa5b92d7..da7fede732 100644 --- a/bld/trap/common/os2/os2digl.c +++ b/bld/trap/common/os2/os2digl.c @@ -68,7 +68,7 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *name, size_t name_len, break; } } - if( !has_ext && *defext != NULLCHAR ) { + if( !has_ext && *defext != '\0' ) { *p++ = '.'; p = StrCopyDst( defext, p ); } diff --git a/bld/trap/common/os2v2/os22digl.c b/bld/trap/common/os2v2/os22digl.c index 2bb0bbc05f..51e8636e41 100644 --- a/bld/trap/common/os2v2/os22digl.c +++ b/bld/trap/common/os2v2/os22digl.c @@ -34,6 +34,7 @@ #include #include #include "digld.h" +#include "os22path.h" #include "servio.h" @@ -68,7 +69,7 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *name, size_t name_len, break; } } - if( !has_ext && *defext != NULLCHAR ) { + if( !has_ext && *defext != '\0' ) { *p++ = '.'; p = StrCopyDst( defext, p ); } diff --git a/bld/trap/common/qnx/qnxdigl.c b/bld/trap/common/qnx/qnxdigl.c index 982ea4be32..205492dd3b 100644 --- a/bld/trap/common/qnx/qnxdigl.c +++ b/bld/trap/common/qnx/qnxdigl.c @@ -71,7 +71,7 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *name, size_t name_len, break; } } - if( !has_ext && *defext != NULLCHAR ) { + if( !has_ext && *defext != '\0' ) { *p++ = '.'; p = StrCopyDst( defext, p ); } diff --git a/bld/trap/common/rdos/rdosdigl.c b/bld/trap/common/rdos/rdosdigl.c index 36aa5b92d7..8473698c03 100644 --- a/bld/trap/common/rdos/rdosdigl.c +++ b/bld/trap/common/rdos/rdosdigl.c @@ -34,6 +34,7 @@ #include #include #include "digld.h" +#include "rdospath.h" #include "servio.h" @@ -68,7 +69,7 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *name, size_t name_len, break; } } - if( !has_ext && *defext != NULLCHAR ) { + if( !has_ext && *defext != '\0' ) { *p++ = '.'; p = StrCopyDst( defext, p ); } diff --git a/bld/trap/common/rdos/rdospath.c b/bld/trap/common/rdos/rdospath.c index b665750b7d..7a83e834f7 100644 --- a/bld/trap/common/rdos/rdospath.c +++ b/bld/trap/common/rdos/rdospath.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -32,3 +32,12 @@ #include "rdospath.h" + + +char *StrCopyDst( const char *src, char *dst ) +{ + while( (*dst = *src++) != '\0' ) { + dst++; + } + return( dst ); +} diff --git a/bld/trap/common/rdos/rdospath.h b/bld/trap/common/rdos/rdospath.h index 8c23f144b7..f79757e8da 100644 --- a/bld/trap/common/rdos/rdospath.h +++ b/bld/trap/common/rdos/rdospath.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -31,3 +31,4 @@ ****************************************************************************/ +extern char *StrCopyDst( const char *src, char *dst ); diff --git a/bld/trap/common/win/windigl.c b/bld/trap/common/win/windigl.c index 36aa5b92d7..e591b8e83d 100644 --- a/bld/trap/common/win/windigl.c +++ b/bld/trap/common/win/windigl.c @@ -34,6 +34,7 @@ #include #include #include "digld.h" +#include "winpath.h" #include "servio.h" @@ -68,7 +69,7 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *name, size_t name_len, break; } } - if( !has_ext && *defext != NULLCHAR ) { + if( !has_ext && *defext != '\0' ) { *p++ = '.'; p = StrCopyDst( defext, p ); } From bced1212a5065940621707d76aa79ce0b4205f78 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Mon, 28 Aug 2023 08:04:06 +0200 Subject: [PATCH 028/258] reformat comments in source files --- bld/dip/c/dipimp.c | 11 +- bld/dip/codeview/c/cvcue.c | 32 +- bld/dip/codeview/c/cvld.c | 16 +- bld/dip/codeview/c/cvmisc.c | 16 +- bld/dip/codeview/c/cvmod.c | 16 +- bld/dip/codeview/c/cvsym.c | 148 +++++--- bld/dip/codeview/c/cvvirt.c | 44 ++- bld/dip/dipdump/c/dipcli.c | 5 +- bld/dip/dipdump/c/dipdump.c | 310 ++++++++-------- bld/dip/dwarf/c/dfaddr.c | 139 +++---- bld/dip/dwarf/c/dfaddsym.c | 62 ++-- bld/dip/dwarf/c/dfcue.c | 130 +++---- bld/dip/dwarf/c/dfhash.c | 21 +- bld/dip/dwarf/c/dfld.c | 48 ++- bld/dip/dwarf/c/dfline.c | 37 +- bld/dip/dwarf/c/dfloc.c | 315 ++++++++++------ bld/dip/dwarf/c/dfmisc.c | 51 +-- bld/dip/dwarf/c/dfmod.c | 77 ++-- bld/dip/dwarf/c/dfmodbld.c | 15 +- bld/dip/dwarf/c/dfscope.c | 22 +- bld/dip/dwarf/c/dfsegs.c | 26 +- bld/dip/dwarf/c/dfsym.c | 258 +++++++------ bld/dip/dwarf/c/dftype.c | 242 ++++++------ bld/dip/dwarf/c/stub.c | 5 +- bld/dip/dwarf/h/dfdip.h | 24 +- bld/dip/dwarf/h/dfmodinf.h | 5 +- bld/dip/export/c/expcue.c | 6 +- bld/dip/export/c/expld.c | 97 +++-- bld/dip/export/c/expmisc.c | 6 +- bld/dip/export/c/expmod.c | 9 +- bld/dip/export/c/expsym.c | 7 +- bld/dip/export/c/exptype.c | 6 +- bld/dip/export/h/exp.h | 13 +- bld/dip/hllcv/c/hllcue.c | 270 ++++++++------ bld/dip/hllcv/c/hllld.c | 194 +++++----- bld/dip/hllcv/c/hllloc.c | 5 +- bld/dip/hllcv/c/hllmisc.c | 48 +-- bld/dip/hllcv/c/hllmod.c | 128 ++++--- bld/dip/hllcv/c/hllsym.c | 277 ++++++++------ bld/dip/hllcv/c/hlltype.c | 137 ++++--- bld/dip/hllcv/c/hllvirt.c | 105 +++--- bld/dip/hllcv/h/hllinfo.h | 9 +- bld/dip/javavm/c/jvmcue.c | 22 +- bld/dip/javavm/c/jvmmisc.c | 6 +- bld/dip/javavm/c/jvmmod.c | 6 +- bld/dip/javavm/c/jvmsupp.c | 5 +- bld/dip/javavm/c/jvmsym.c | 49 ++- bld/dip/mapsym/c/msymcue.c | 5 +- bld/dip/mapsym/c/msymld.c | 61 +-- bld/dip/mapsym/c/msymtype.c | 4 +- bld/dip/mapsym/h/msym.h | 13 +- bld/dip/mapsym/util/symdump.c | 30 +- bld/dip/skel/c/skelcue.c | 230 ++++++------ bld/dip/skel/c/skelld.c | 67 ++-- bld/dip/skel/c/skelmisc.c | 59 +-- bld/dip/skel/c/skelmod.c | 127 ++++--- bld/dip/skel/c/skelsym.c | 677 +++++++++++++++++----------------- bld/dip/skel/c/skeltype.c | 312 ++++++++-------- bld/dip/skel/h/skel.h | 43 ++- bld/dip/watcom/c/wataddr.c | 36 +- bld/dip/watcom/c/watdmnd.c | 68 ++-- bld/dip/watcom/c/watgbl.c | 65 ++-- bld/dip/watcom/c/watlcl.c | 41 +- bld/dip/watcom/c/watldsym.c | 68 ++-- bld/dip/watcom/c/watlnum.c | 41 +- bld/dip/watcom/c/watloc.c | 17 +- bld/dip/watcom/c/watmod.c | 80 ++-- bld/dip/watcom/c/wattype.c | 52 ++- bld/dip/watcom/h/dbcue.h | 5 +- bld/dip/watcom/h/dipwat.h | 14 +- bld/dip/watcom/h/watlcl.h | 23 +- bld/dip/watcom/h/watloc.h | 38 +- bld/dip/watcom/h/wattype.h | 9 +- 73 files changed, 3251 insertions(+), 2414 deletions(-) diff --git a/bld/dip/c/dipimp.c b/bld/dip/c/dipimp.c index 13ba9a47eb..02622a5405 100644 --- a/bld/dip/c/dipimp.c +++ b/bld/dip/c/dipimp.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -255,7 +255,9 @@ void DCStatus( dip_status ds ) dig_arch DCCurrArch( void ) { - /* check for old client */ + /* + * check for old client + */ if( DIPClient->sizeof_struct < offsetof(dip_client_routines,CurrArch) ) return( DIG_ARCH_X86 ); return( DIPClient->CurrArch() ); @@ -290,9 +292,8 @@ void DIGENTRY DIPUNLOAD( void ) int PASCAL WinMain( HINSTANCE this_inst, HINSTANCE prev_inst, LPSTR cmdline, int cmdshow ) /***************************************************************************************** - - Initialization, message loop. -*/ + * Initialization, message loop. + */ { MSG msg; FARPROC *func; diff --git a/bld/dip/codeview/c/cvcue.c b/bld/dip/codeview/c/cvcue.c index 5aacd82757..37515b3ebe 100644 --- a/bld/dip/codeview/c/cvcue.c +++ b/bld/dip/codeview/c/cvcue.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2018 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -64,9 +64,9 @@ walk_result DIPIMPENTRY( WalkFileList )( imp_image_handle *iih, imp_mod_handle i file_tab_size = file_tab_count * sizeof( unsigned_32 ); hdr = VMBlock( iih, cde->lfo, sizeof( *hdr ) + file_tab_size ); /* - Make a copy of the file table offset so that we don't have to worry - about the VM system throwing it out. - */ + * Make a copy of the file table offset so that we don't have to worry + * about the VM system throwing it out. + */ file_off = walloca( file_tab_size ); memcpy( file_off, &hdr->baseSrcFile[0], file_tab_size ); icueh->imh = imh; @@ -114,8 +114,10 @@ size_t DIPIMPENTRY( CueFile )( imp_image_handle *iih, imp_cue_handle *icueh, cha p = VMBlock( iih, offset, sizeof( unsigned_16 ) ); if( p == NULL ) return( 0 ); - /* Doc says the length is unsigned_16, cvpack says unsigned_8. */ - /* testing on real files confirm unsigned_8 */ + /* + * Doc says the length is unsigned_16, cvpack says unsigned_8. + * testing on real files confirm unsigned_8 + */ name_len = *(unsigned_8 *)p; p = VMBlock( iih, offset + sizeof( unsigned_8 ), name_len ); if( p == NULL ) @@ -228,8 +230,10 @@ static dip_status AdjBackward( imp_image_handle *iih, unsigned long bias, imp_cu if( lp == NULL ) return( DS_ERR | DS_FAIL ); for( ;; ) { - /* if icueh->pair went negative, the following compare will fail - because of unsigned comparison */ + /* + * if icueh->pair went negative, the following compare will fail + * because of unsigned comparison + */ if( icueh->pair < lp->cPair ) return( ds ); fp = VMBlock( iih, icueh->file, sizeof( *fp ) ); @@ -326,8 +330,10 @@ search_result DIPIMPENTRY( LineCue )( imp_image_handle *iih, imp_mod_handle imh, fp = VMBlock( iih, file, sizeof( *fp ) + num_segs * sizeof( unsigned_32 ) ); if( fp == NULL ) return( SR_NONE ); - /* make a copy of the line/offset table so that we don't have to worry - about the VM system throwing it out */ + /* + * make a copy of the line/offset table so that we don't have to worry + * about the VM system throwing it out + */ line_off = walloca( num_segs * sizeof( unsigned_32 ) ); memcpy( line_off, &fp->baseSrcLn[0], num_segs * sizeof( unsigned_32 ) ); best_line = (unsigned long)-1L; @@ -452,7 +458,8 @@ static search_result SearchFile( imp_image_handle *iih, address addr, imp_cue_ha continue; if( (ranges[seg_idx].start != 0 || ranges[seg_idx].end != 0) && (addr.mach.offset < ranges[seg_idx].start + curr_addr.mach.offset - /* The next condition is commented out. Digital Mars tools are known to + /* + * The next condition is commented out. Digital Mars tools are known to * emit buggy CV4 data where the upper range does not cover all code, * causing us to fail finding last addresses within a module. */ @@ -471,7 +478,8 @@ static search_result SearchFile( imp_image_handle *iih, address addr, imp_cue_ha } } } - /* We abuse the SR_FAIL return code to really mean SR_CONTINUE (ie. continue + /* + * We abuse the SR_FAIL return code to really mean SR_CONTINUE (ie. continue * searching other files). A SR_CONTINUE code is not defined because it does * not make sense as a return value for DIPImpAddrCue() */ diff --git a/bld/dip/codeview/c/cvld.c b/bld/dip/codeview/c/cvld.c index 32eea407aa..04e6e14372 100644 --- a/bld/dip/codeview/c/cvld.c +++ b/bld/dip/codeview/c/cvld.c @@ -35,7 +35,9 @@ #include "exepe.h" #include "exedos.h" -/* WD looks for this symbol to determine module bitness */ +/* + * WD looks for this symbol to determine module bitness + */ #if !defined( __WINDOWS__ ) int __nullarea; #if defined( __WATCOMC__ ) @@ -44,8 +46,8 @@ int __nullarea; #endif /* - Loading/unloading symbolic information. -*/ + * Loading/unloading symbolic information. + */ imp_image_handle *ImageList; @@ -58,12 +60,16 @@ static void Cleanup( imp_image_handle *iih ) for( owner = &ImageList; (curr = *owner) != NULL; owner = &curr->next_image ) { if( curr == iih ) { - /* if found then remove it from list */ + /* + * if found then remove it from list + */ *owner = curr->next_image; break; } } - /* destroy entry */ + /* + * destroy entry + */ if( iih->directory != NULL ) { blocks = BLOCK_FACTOR( iih->dir_count, DIRECTORY_BLOCK_ENTRIES ); for( i = 0; i < blocks; ++i ) { diff --git a/bld/dip/codeview/c/cvmisc.c b/bld/dip/codeview/c/cvmisc.c index 0198a03588..2dd95e2e52 100644 --- a/bld/dip/codeview/c/cvmisc.c +++ b/bld/dip/codeview/c/cvmisc.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -33,8 +33,8 @@ #include "cvinfo.h" /* - Misc. stuff. -*/ + * Misc. stuff. + */ const char DIPImp( Name )[] = "CodeView"; @@ -245,12 +245,16 @@ void NYI( void ) { volatile int a = 0; volatile int b = 0; - - a /= b; /* cause a fault */ + /* + * cause a fault + */ + a /= b; } void Confused( void ) { - /* don't know what's happening */ + /* + * don't know what's happening + */ NYI(); } diff --git a/bld/dip/codeview/c/cvmod.c b/bld/dip/codeview/c/cvmod.c index 033e489911..fbd78cb5c2 100644 --- a/bld/dip/codeview/c/cvmod.c +++ b/bld/dip/codeview/c/cvmod.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -220,11 +220,11 @@ search_result ImpAddrMod( imp_image_handle *iih, address a, imp_mod_handle *imh --left; } /* - We know the address is in the image. If it's an executable - segment, we can find the module by checking all the sstModule - sections and look at the code section information. If it's a - data segment, or we can't find it, return IMH_GBL. - */ + * We know the address is in the image. If it's an executable + * segment, we can find the module by checking all the sstModule + * sections and look at the code section information. If it's a + * data segment, or we can't find it, return IMH_GBL. + */ *imh = IMH_GBL; if( map->u.b.fExecute ) { d.d = &a; @@ -275,7 +275,9 @@ dip_status DIPIMPENTRY( ModDefault )( imp_image_handle *iih, imp_mod_handle imh, case DK_INT: ti->kind = TK_INTEGER; ti->modifier = TM_SIGNED; - /* size is OK */ + /* + * size is OK + */ break; case DK_DATA_PTR: if( comp_info->flags.f.AmbientData != AMBIENT_NEAR ) { diff --git a/bld/dip/codeview/c/cvsym.c b/bld/dip/codeview/c/cvsym.c index d719ed7208..ab07f4e39d 100644 --- a/bld/dip/codeview/c/cvsym.c +++ b/bld/dip/codeview/c/cvsym.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -287,7 +287,9 @@ dip_status ImpSymLocation( imp_image_handle *iih, imp_sym_handle *ish, location_ addr48_off off48; } tmp; - //NYI: parameters when at the start of a routine. + /* + * NYI: parameters when at the start of a routine. + */ if( ish->containing_type != 0 ) { return( TypeSymGetAddr( iih, ish, lc, ll ) ); } @@ -546,7 +548,9 @@ static dip_status ScopeFindFirst( imp_image_handle *iih, imp_mod_handle imh, chk += p->common.length + sizeof( p->common.length ); len -= p->common.length + sizeof( p->common.length ); } - /* found first scope block, now find correct offset */ + /* + * found first scope block, now find correct offset + */ for( ;; ) { ds = ScopeFillIn( iih, chk, scope, NULL ); if( ds != DS_OK ) @@ -559,7 +563,9 @@ static dip_status ScopeFindFirst( imp_image_handle *iih, imp_mod_handle imh, return( DS_FAIL ); chk = scope->next; } - /* found enclosing scope block, now find smallest one */ + /* + * found enclosing scope block, now find smallest one + */ chk = scope->scope; new.cde = scope->cde; for( ;; ) { @@ -567,21 +573,31 @@ static dip_status ScopeFindFirst( imp_image_handle *iih, imp_mod_handle imh, if( ds & DS_ERR ) return( ds ); if( ds == DS_OK ) { - /* new scope */ + /* + * new scope + */ if( !(addr.mach.offset >= new.start.mach.offset && addr.mach.offset < (new.start.mach.offset + new.len)) ) { - /* out of range */ + /* + * out of range + */ chk = new.end; } else if( !(new.start.mach.offset >= scope->start.mach.offset && (new.start.mach.offset + new.len) <= (scope->start.mach.offset + scope->len)) ) { - /* not smaller */ + /* + * not smaller + */ chk = new.end; } else { - /* inner scope */ + /* + * inner scope + */ *scope = new; } } else if( p->common.code == S_END ) { - /* all done */ + /* + * all done + */ return( DS_OK ); } p = VMBlock( iih, chk, sizeof( p->common ) ); @@ -641,7 +657,9 @@ static walk_result ScopeOneSymbol( imp_image_handle *iih, cv_directory_entry *cd case S_THUNK32: case S_BLOCK32: case S_WITH32: - /* not interested in these */ + /* + * not interested in these + */ break; case S_ENTRYTHIS: curr += sizeof( s_common ); @@ -649,9 +667,9 @@ static walk_result ScopeOneSymbol( imp_image_handle *iih, cv_directory_entry *cd default: if( ds == DS_OK && scope != NULL ) { /* - starting a new scope and not doing file scope - symbols -- skip scope start symbol - */ + * starting a new scope and not doing file scope + * symbols -- skip scope start symbol + */ break; } ish.imh = cde->iMod; @@ -676,7 +694,9 @@ static walk_result ScopeWalkOne( imp_image_handle *iih, scope_info *scope, p = VMBlock( iih, curr, sizeof( p->common ) ); if( p == NULL ) return( WR_FAIL ); - /* skip over first scope start symbol */ + /* + * skip over first scope start symbol + */ curr += p->common.length + sizeof( p->common.length ); for( ;; ) { p = VMBlock( iih, curr, sizeof( p->common ) ); @@ -827,7 +847,9 @@ static search_result TableSearchForAddr( imp_image_handle *iih, if( offset_count == 0 ) continue; curr.base += base + num_segs * sizeof( unsigned_32 ); - //NYI: offsets are sorted, so we can binary search this sucker + /* + * NYI: offsets are sorted, so we can binary search this sucker + */ curr.off = 0; new_off = 0; for( count = 0; count < offset_count; ++count ) { @@ -863,7 +885,9 @@ static search_result TableSearchForAddr( imp_image_handle *iih, *best_off = best.off; return( (best.off == a.mach.offset) ? SR_EXACT : SR_CLOSEST ); default: - //NYI: what to do when don't have hash function? */ + /* + * NYI: what to do when don't have hash function? + */ return( SR_NONE ); } } @@ -962,12 +986,16 @@ static search_result TableSearchForName( imp_image_handle *iih, if( scompn( name, curr, curr_len ) != 0 ) { continue; } - /* Got one! */ + /* + * Got one! + */ switch( create( iih, sp, ish, d ) ) { case SR_FAIL: return( SR_FAIL ); case SR_CLOSEST: - /* means we found one, but keep on going */ + /* + * means we found one, but keep on going + */ sr = SR_EXACT; break; case SR_EXACT: @@ -976,7 +1004,9 @@ static search_result TableSearchForName( imp_image_handle *iih, } return( sr ); default: - //NYI: What to do if don't have hash table + /* + * NYI: What to do if don't have hash table + */ return( SR_NONE ); } } @@ -1053,7 +1083,9 @@ static walk_result TableWalkSym( imp_image_handle *iih, imp_sym_handle *ish, case S_ALIGN: case S_PROCREF: case S_DATAREF: - /* not interested */ + /* + * not interested + */ break; case S_PUB16: case S_PUB32: @@ -1162,7 +1194,9 @@ static walk_result DoWalkSymList( imp_image_handle *iih, if( ds != DS_OK ) return( WR_CONTINUE ); if( sc_block->unique & SCOPE_CLASS_FLAG ) { - /* Walk the member function class scope */ + /* + * Walk the member function class scope + */ ds = TypeIndexFillIn( iih, SymTypeIdx( iih, p ), &ith ); if( ds & DS_ERR ) return( WR_FAIL ); @@ -1244,7 +1278,9 @@ static size_t ImpSymName( imp_image_handle *iih, imp_sym_handle *ish, location_c } if( snt == SNT_DEMANGLED ) return( 0 ); - /* SNT_SOURCE: */ + /* + * SNT_SOURCE: + */ if( SymGetName( iih, ish, &name, &len, NULL ) != DS_OK ) return( 0 ); return( NameCopy( buff, name, buff_size, len ) ); @@ -1381,10 +1417,12 @@ dip_status DIPIMPENTRY( SymInfo )( imp_image_handle *iih, si->prolog_size = p->lproc16.f.debug_start; si->epilog_size = p->lproc16.f.proc_length - p->lproc16.f.debug_end; si->rtn_size = p->lproc16.f.proc_length; - //NYI: fill in si->rtn_calloc - //NYI: fill in si->rtn_modifier - //NYI: fill in si->ret_size - //NYI: fill in si->num_parms + /* + * NYI: fill in si->rtn_calloc + * NYI: fill in si->rtn_modifier + * NYI: fill in si->ret_size + * NYI: fill in si->num_parms + */ break; case S_GPROC32: si->is_global = 1; @@ -1400,10 +1438,12 @@ dip_status DIPIMPENTRY( SymInfo )( imp_image_handle *iih, si->prolog_size = p->lproc32.f.debug_start; si->epilog_size = p->lproc32.f.proc_length - p->lproc32.f.debug_end; si->rtn_size = p->lproc32.f.proc_length; - //NYI: fill in si->rtn_calloc - //NYI: fill in si->rtn_modifier - //NYI: fill in si->ret_size - //NYI: fill in si->num_parms + /* + * NYI: fill in si->rtn_calloc + * NYI: fill in si->rtn_modifier + * NYI: fill in si->ret_size + * NYI: fill in si->num_parms + */ break; case S_LABEL16: case S_LABEL32: @@ -1455,11 +1495,15 @@ dip_status DIPIMPENTRY( SymParmLocation )( imp_image_handle *iih, if( n > parm_count ) return( DS_NO_PARM ); if( n == 0 ) { - /* return value */ + /* + * return value + */ p = VMRecord( iih, ish->handle + ish->len ); if( p == NULL ) return( DS_ERR | DS_FAIL ); - /* WARNING: assuming that S_RETURN directly follows func defn */ + /* + * WARNING: assuming that S_RETURN directly follows func defn + */ if( p->common.code == S_RETURN ) { switch( p->return_.f.style ) { case CVRET_VOID: @@ -1471,13 +1515,17 @@ dip_status DIPIMPENTRY( SymParmLocation )( imp_image_handle *iih, case CVRET_CALLOC_FAR: case CVRET_RALLOC_NEAR: case CVRET_RALLOC_FAR: - //NYI: have to handle these suckers + /* + * NYI: have to handle these suckers + */ NYI(); break; } return( DS_ERR | DS_BAD_LOCATION ); } - /* find out about return type */ + /* + * find out about return type + */ ds = TypeIndexFillIn( iih, type, &ith ); if( ds != DS_OK ) return( ds ); @@ -1532,7 +1580,9 @@ dip_status DIPIMPENTRY( SymParmLocation )( imp_image_handle *iih, return( DS_ERR | DS_FAIL ); case TK_STRUCT: case TK_ARRAY: - //NYI: have to handle these suckers + /* + * NYI: have to handle these suckers + */ NYI(); break; } @@ -1541,7 +1591,9 @@ dip_status DIPIMPENTRY( SymParmLocation )( imp_image_handle *iih, switch( call ) { case CV_NEARC: case CV_FARC: - /* all on stack */ + /* + * all on stack + */ return( DS_NO_PARM ); case CV_NEARPASCAL: case CV_FARPASCAL: @@ -1555,7 +1607,9 @@ dip_status DIPIMPENTRY( SymParmLocation )( imp_image_handle *iih, case CV_MIPS: case CV_AXP: case CV_GENERIC: - //NYI: have to handle all of these suckers + /* + * NYI: have to handle all of these suckers + */ NYI(); break; } @@ -1626,7 +1680,9 @@ dip_status DIPIMPENTRY( SymObjLocation )( imp_image_handle *iih, break; check = next; } - /* We have a 'this' pointer! Repeat, we have a this pointer! */ + /* + * We have a 'this' pointer! Repeat, we have a this pointer! + */ ds = ImpSymLocation( iih, &parm, lc, ll ); if( ds != DS_OK ) return( ds ); @@ -1711,7 +1767,9 @@ static walk_result SymFind( imp_image_handle *iih, sym_walk_info swi, if( scompn( li->name.start, name, len ) != 0 ) { return( WR_CONTINUE ); } - /* Got one! */ + /* + * Got one! + */ new_ish = DCSymCreate( iih, sd->d ); if( new_ish == NULL ) return( WR_FAIL ); @@ -1750,7 +1808,9 @@ static search_result SymCreate( imp_image_handle *iih, s_all *p, if( new_ish == NULL ) return( SR_FAIL ); *new_ish = *ish; - /* keep on looking for more */ + /* + * keep on looking for more + */ return( SR_CLOSEST ); } @@ -1796,7 +1856,9 @@ static search_result DoLookupSym( imp_image_handle *iih, break; case SS_SCOPED: if( ImpAddrMod( iih, *(address *)source, &ish.imh ) == SR_NONE ) { - /* just check the global symbols */ + /* + * just check the global symbols + */ break; } if( MH2IMH( data.li.mod ) != ish.imh && MH2IMH( data.li.mod ) != IMH_NOMOD ) { @@ -1953,7 +2015,9 @@ search_result DIPIMPENTRY( ScopeOuter )( imp_image_handle *iih, case S_LPROC16: case S_GPROC32: case S_LPROC32: - /* Might be a member function. We'll let WalkSym figure it out. */ + /* + * Might be a member function. We'll let WalkSym figure it out. + */ *out = *in; out->unique |= SCOPE_CLASS_FLAG; return( SR_CLOSEST ); diff --git a/bld/dip/codeview/c/cvvirt.c b/bld/dip/codeview/c/cvvirt.c index 058c58b757..78f314ea84 100644 --- a/bld/dip/codeview/c/cvvirt.c +++ b/bld/dip/codeview/c/cvvirt.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -147,10 +147,14 @@ void *VMBlock( imp_image_handle *iih, virt_mem start, size_t len ) pg_start = start & ~(virt_mem)(VM_PAGE_SIZE - 1); pg = iih->virt[dir_idx][pg_idx]; if( pg == NULL || ( pg->block->len - pg->offset ) < len ) { - /* unloaded previously loaded block */ + /* + * unloaded previously loaded block + */ if( pg != NULL ) { tmp_idx = dir_idx; - /* find first page of the block */ + /* + * find first page of the block + */ i = pg_idx; for( ;; ) { iih->virt[tmp_idx][i] = NULL; @@ -171,7 +175,9 @@ void *VMBlock( imp_image_handle *iih, virt_mem start, size_t len ) DCStatus( DS_ERR | DS_NO_MEM ); return( NULL ); } - /* set up new page table entries */ + /* + * set up new page table entries + */ block = (loaded_block *)&pg[num_pages]; tmp_idx = dir_idx; for( j = pg_idx, i = 0; i < num_pages; ++j, ++i ) { @@ -183,7 +189,9 @@ void *VMBlock( imp_image_handle *iih, virt_mem start, size_t len ) } if( iih->virt[tmp_idx] == NULL ) { if( !InitPageDir( iih, tmp_idx ) ) { - /* unwind the setup already done */ + /* + * unwind the setup already done + */ num_pages = i; for( i = 0; i < num_pages; ++i, ++pg_idx ) { if( pg_idx >= DIR_SIZE ) { @@ -198,16 +206,18 @@ void *VMBlock( imp_image_handle *iih, virt_mem start, size_t len ) } if( iih->virt[tmp_idx][j] != NULL ) { /* - We just ran into another allocated block, so we have - to kill all the pages mapped in by it. We know that - if the page pointer is non-NULL, it will be offset==0 - since KillPages will clean out the others. - */ + * We just ran into another allocated block, so we have + * to kill all the pages mapped in by it. We know that + * if the page pointer is non-NULL, it will be offset==0 + * since KillPages will clean out the others. + */ KillPages( iih, tmp_idx, j ); } iih->virt[tmp_idx][j] = &pg[i]; } - /* read in new block */ + /* + * read in new block + */ len = num_pages * VM_PAGE_SIZE; block->len = len; pg_start += iih->bias; @@ -215,7 +225,9 @@ void *VMBlock( imp_image_handle *iih, virt_mem start, size_t len ) DCStatus( DS_ERR | DS_FSEEK_FAILED ); return( NULL ); } - /* last block might be a short read */ + /* + * last block might be a short read + */ if( DCRead( iih->sym_fp, pg->block->data, len ) == DIG_RW_ERROR ) { DCStatus( DS_ERR | DS_FREAD_FAILED ); return( NULL ); @@ -224,7 +236,9 @@ void *VMBlock( imp_image_handle *iih, virt_mem start, size_t len ) } ++TimeStamp; if( TimeStamp == 0 ) { - /* deal with wrap-around */ + /* + * deal with wrap-around + */ for( iih = ImageList; iih != NULL; iih = iih->next_image ) { if( iih->virt != NULL ) { for( i = iih->vm_dir_num; i-- > 0; ) { @@ -271,7 +285,9 @@ unsigned VMShrink( void ) kill_i = 0; kill_j = 0; kill_iih = NULL; - /* search oldest page by time_stamp */ + /* + * search oldest page by time_stamp + */ for( iih = ImageList; iih != NULL; iih = iih->next_image ) { if( iih->virt != NULL ) { for( i = iih->vm_dir_num-1; i >= 0; --i ) { diff --git a/bld/dip/dipdump/c/dipcli.c b/bld/dip/dipdump/c/dipcli.c index f3cf5609be..63dd64c4f0 100644 --- a/bld/dip/dipdump/c/dipcli.c +++ b/bld/dip/dipdump/c/dipcli.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -142,8 +142,9 @@ void DIPCLIENTRY( AddrSection )( address *addr ) */ void DIPCLIENTRY( Status )( dip_status ds ) { - dprintf(( "DIPCliStatus: status=%d\n", ds )); /* unused parameters */ (void)ds; + + dprintf(( "DIPCliStatus: status=%d\n", ds )); } /* diff --git a/bld/dip/dipdump/c/dipdump.c b/bld/dip/dipdump/c/dipdump.c index f7291bd74b..e8e3efedf2 100644 --- a/bld/dip/dipdump/c/dipdump.c +++ b/bld/dip/dipdump/c/dipdump.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -43,7 +43,7 @@ #include "dipdump.h" -/** +/* * Options */ static struct { @@ -51,7 +51,8 @@ static struct { } Opts = { 1 }; -/** +static int ErrorMsg( const char *pszFormat, ... ) +/************************************************ * Prints an error message. * * @returns Appropriate exit code for an error. @@ -59,7 +60,6 @@ static struct { * @param pszFormat The format string (passed to vfprintf). * @param ... Format arguments. */ -static int ErrorMsg( const char *pszFormat, ... ) { va_list va; @@ -70,13 +70,13 @@ static int ErrorMsg( const char *pszFormat, ... ) return( 1 ); } -/** +static void InfoMsg( const char *pszFormat, ... ) +/************************************************ * Prints an informational message. * * @param pszFormat The format string (passed to vfprintf). * @param ... Format arguments. */ -static void InfoMsg( const char *pszFormat, ... ) { va_list va; @@ -86,12 +86,12 @@ static void InfoMsg( const char *pszFormat, ... ) va_end( va ); } -/** +static const char *GetTypeKind( type_kind kind ) +/*********************************************** * Get type kind name. * @returns type kind name (readonly). * @param kind The type kind. */ -static const char *GetTypeKind(type_kind kind) { switch( kind ) { case TK_NONE: return( "TK_NONE" ); @@ -115,13 +115,13 @@ static const char *GetTypeKind(type_kind kind) } } -/** +static const char *GetTypeModifier( dig_type_info *ti ) +/****************************************************** * Get type modifier name. * @returns type modifier name (readonly). * @param modifier The type modifier. * @param kind The type kind (needed to understand the modifier). */ -static const char *GetTypeModifier( dig_type_info *ti ) { if( ti->modifier == TM_NONE ) { return( ( ti->deref ) ? "TM_NONE|TM_FLAG_DEREF" : "TM_NONE" ); @@ -172,12 +172,12 @@ static const char *GetTypeModifier( dig_type_info *ti ) } } -/** +static const char *GetTypeTag( symbol_type tag ) +/*********************************************** * Get the tag name. * @returns tag name. (readonly) * @param tag The tag. */ -static const char *GetTypeTag( symbol_type tag ) { switch( tag ) { case ST_NONE: return( "ST_NONE" ); @@ -194,7 +194,8 @@ static const char *GetTypeTag( symbol_type tag ) } } -/** +static walk_result Sym2Callback( sym_walk_info swi, sym_handle *sym, void *_idx ) +/******************************************************************************** * WalkSymList callback, the module pass. * * @returns WR_CONTINUE; @@ -202,7 +203,6 @@ static const char *GetTypeTag( symbol_type tag ) * @param sym The Symbol. * @param _idx Pointer to the symbol index number. */ -static walk_result Sym2Callback( sym_walk_info swi, sym_handle *sym, void *_idx ) { int *idx = (int *)_idx; char buff[2048]; @@ -212,10 +212,13 @@ static walk_result Sym2Callback( sym_walk_info swi, sym_handle *sym, void *_idx sym_info sinfo; int i; - /* index */ + /* + * index + */ printf( "%5d ", ++*idx ); - - /* symbol info */ + /* + * symbol info + */ ds = DIPSymInfo( sym, NULL, &sinfo ); if( ds == DS_OK ) { switch( sinfo.kind ) { @@ -233,8 +236,9 @@ static walk_result Sym2Callback( sym_walk_info swi, sym_handle *sym, void *_idx memset( &sinfo, 0, sizeof( sinfo ) ); sinfo.kind= SK_NONE; } - - /* location (i.e. address) */ + /* + * location (i.e. address) + */ ll.num = MAX_LOC_ENTRIES; ds = DIPSymLocation( sym, NULL, &ll ); if( ds == DS_OK ) { @@ -266,8 +270,9 @@ static walk_result Sym2Callback( sym_walk_info swi, sym_handle *sym, void *_idx printf( "status=%#x ", ds ); ll.num = 0; } - - /* swi */ + /* + * swi + */ switch( swi ) { case SWI_SYMBOL: printf( "SYMBOL " ); @@ -282,9 +287,10 @@ static walk_result Sym2Callback( sym_walk_info swi, sym_handle *sym, void *_idx printf( "%#d ", swi ); break; } - - /* finally, the name. */ - /* try get the name */ + /* + * finally, the name. + * try get the name + */ buff[0] = '\0'; len = DIPSymName( sym, NULL, SNT_DEMANGLED, buff, sizeof( buff ) ); if( len == 0 ) { @@ -298,9 +304,9 @@ static walk_result Sym2Callback( sym_walk_info swi, sym_handle *sym, void *_idx } else { printf( "(len=%u)\n", len ); } - - - /* Get more stuff, mainly to test the APIs. */ + /* + * Get more stuff, mainly to test the APIs. + */ if( 1 ) { type_handle *th = alloca( DIPHandleSize( HK_TYPE ) ); @@ -308,9 +314,9 @@ static walk_result Sym2Callback( sym_walk_info swi, sym_handle *sym, void *_idx if( ds ) { } } - - - /* more locations. */ + /* + * more locations. + */ for( i = 1; i < ll.num; i++ ) { if( ll.e[0].type == LT_ADDR ) { printf( " %04x:%08lx\n", @@ -319,22 +325,20 @@ static walk_result Sym2Callback( sym_walk_info swi, sym_handle *sym, void *_idx printf( " %p\n", ll.e[i].u.p); /// what's this? } } - /* * Perform alternative lookups to the those interfaces. */ - return( WR_CONTINUE ); } -/** +static walk_result Type2Callback( type_handle *th, void *_idx ) +/************************************************************** * WalkTypeList callback. * * @returns WR_CONTINUE * @param th The type handle. * @param _idx Pointer to the current module index. */ -static walk_result Type2Callback( type_handle *th, void *_idx ) { int *idx = (int *)_idx; char buff[2048]; @@ -347,15 +351,18 @@ static walk_result Type2Callback( type_handle *th, void *_idx ) /** @todo all this needs some serious work */ - /* type name. */ + /* + * type name. + */ len = DIPTypeName( th, 0, &tag, buff, sizeof( buff ) ); if( len > 0 ) { printf( "tag=%d %-13s name=%s\n" " ", tag, GetTypeTag( tag ), buff ); } - - /* type info */ + /* + * type info + */ ds = DIPTypeInfo( th, NULL, &ti ); if( ds == DS_OK ) { printf( "size=%#06lx kind=%2d %-12s modifier=%#04x deref=%d %s\n", @@ -388,7 +395,12 @@ static walk_result Type2Callback( type_handle *th, void *_idx ) return( WR_CONTINUE ); } -/** +static void CompareCues( cue_handle *cueh1, cue_handle *cueh2, + search_result expected_rc, search_result actual_rc, + bool exp_exact_line, bool exp_le_line, + bool exp_exact_addr, bool exp_le_addr, + const char *operation ) +/*************************************************************************** * Compares two cues, the first one being the one which information we use * searching for the 2nd. * @@ -402,11 +414,6 @@ static walk_result Type2Callback( type_handle *th, void *_idx ) * @param exp_le_line Set if we're to expect a less or equal address. * @param operation The name of the search operation. */ -static void CompareCues( cue_handle *cueh1, cue_handle *cueh2, - search_result expected_rc, search_result actual_rc, - bool exp_exact_line, bool exp_le_line, - bool exp_exact_addr, bool exp_le_addr, - const char *operation ) { if( actual_rc != expected_rc ) { printf( "FAILED: %s returned %d instead of %d\n", operation, actual_rc, expected_rc ); @@ -434,14 +441,14 @@ static void CompareCues( cue_handle *cueh1, cue_handle *cueh2, } } -/** +static walk_result File2Callback( cue_handle *cueh1, void *ignored ) +/******************************************************************* * WalkFileList callback, the module pass. * * @returns WR_CONTINUE * @param cue The file. * @param ignored Unused user argument. */ -static walk_result File2Callback( cue_handle *cueh1, void *ignored ) { address prev_addr = {0}; long prev_line = -1; @@ -457,7 +464,9 @@ static walk_result File2Callback( cue_handle *cueh1, void *ignored ) /* unused parameters */ (void)ignored; - /* filename */ + /* + * filename + */ buff[0] = '\0'; len = DIPCueFile( cueh1, buff, sizeof( buff ) ); if( len > 0 ) { @@ -465,20 +474,21 @@ static walk_result File2Callback( cue_handle *cueh1, void *ignored ) } else { printf( " %lx (len=%u)\n", file_id, len ); } - - /* check the LineCue function */ + /* + * check the LineCue function + */ if( Opts.do_cue_tests ) { search_rc = DIPLineCue( mod, file_id, 0, 0, cueh2 ); CompareCues( cueh1, cueh2, SR_EXACT, search_rc, true, false, true, false, "DIPLineCue(,,0,)" ); } - - /* lines */ + /* + * lines + */ do { long line = DIPCueLine( cueh1 ); unsigned column = DIPCueColumn( cueh1 ); address addr = DIPCueAddr( cueh1 ); - printf( " Line %5ld ", line ); if( column ) { printf( "Col %2d ", column ); @@ -487,8 +497,9 @@ static walk_result File2Callback( cue_handle *cueh1, void *ignored ) prev_line >= 0 && addr.mach.offset < prev_addr.mach.offset ? "^" : prev_line >= 0 && line < prev_line ? "!" : "" ); - - /* do tests */ + /* + * do tests + */ if( Opts.do_cue_tests ) { if( DIPCueFileId( cueh1 ) != file_id ) { printf( "ERROR: file id changed! new:%#lx old:%#lx\n", (long)DIPCueFileId( cueh1 ), (long)file_id ); @@ -496,8 +507,9 @@ static walk_result File2Callback( cue_handle *cueh1, void *ignored ) if( DIPCueMod( cueh1 ) != mod ) { printf( "ERROR: module changed! new:%#lx old:%#lx\n", (long)DIPCueMod( cueh1 ), (long)file_id ); } - - /* line searches */ + /* + * line searches + */ search_rc = DIPLineCue( mod, file_id, line, 0, cueh2 ); CompareCues( cueh1, cueh2, SR_EXACT, search_rc, true, false, false, false, "DIPLineCue(,,n,)" ); if( line > prev_line + 1 && prev_line >= 0 ) { @@ -505,14 +517,15 @@ static walk_result File2Callback( cue_handle *cueh1, void *ignored ) CompareCues( prev_cueh, cueh2, prev_line == line - 1 ? SR_EXACT : SR_CLOSEST, search_rc, true, false, false, false, "DIPLineCue(,,n-1,)" ); } - - /* address searches */ + /* + * address searches + */ search_rc = DIPAddrCue( mod, addr, cueh2 ); CompareCues( cueh1, cueh2, SR_EXACT, search_rc, false, false, true, false, "DIPAddrCue(,,n,)" ); } - - - /* next */ + /* + * next + */ ds = DIPCueAdjust( cueh1, 1, next_cueh ); prev_cueh = cueh1; cueh1 = next_cueh; @@ -524,21 +537,21 @@ static walk_result File2Callback( cue_handle *cueh1, void *ignored ) return( WR_CONTINUE ); } -/** +static walk_result Mod2Callback( mod_handle mh, void *_idx ) +/*********************************************************** * WalkModList callback, pass 2. * * @returns WR_CONTINUE * @param mh The module. * @param ignored Pointer to the current module index. */ -static walk_result Mod2Callback( mod_handle mh, void *_idx ) { walk_result walkres; int i; int need_trailing_newline = 0; int *idx = (int *)_idx; - ++*idx; + ++*idx; /* * Linenumbers. */ @@ -553,7 +566,6 @@ static walk_result Mod2Callback( mod_handle mh, void *_idx ) "\n" ); need_trailing_newline = 1; } - /* * Types */ @@ -570,8 +582,6 @@ static walk_result Mod2Callback( mod_handle mh, void *_idx ) "\n" ); need_trailing_newline = 1; } - - /* * Symbols. */ @@ -593,7 +603,8 @@ static walk_result Mod2Callback( mod_handle mh, void *_idx ) return( WR_CONTINUE ); } -/** +static walk_result SymCallback( sym_walk_info swi, sym_handle *sym, void *_idx ) +/******************************************************************************* * WalkSymList callback. * * @returns WR_CONTINUE; @@ -601,7 +612,6 @@ static walk_result Mod2Callback( mod_handle mh, void *_idx ) * @param sym The Symbol. * @param _idx Pointer to the symbol index number. */ -static walk_result SymCallback( sym_walk_info swi, sym_handle *sym, void *_idx ) { #if 1 return( Sym2Callback( swi, sym, _idx ) ); @@ -613,10 +623,13 @@ static walk_result SymCallback( sym_walk_info swi, sym_handle *sym, void *_idx ) location_list ll = {0}; int i; - /* index */ + /* + * index + */ printf( "%5d ", ++*idx ); - - /* location (i.e. address) */ + /* + * location (i.e. address) + */ ll.num = MAX_LOC_ENTRIES; ds = SymLocation( sym, NULL, &ll ); if( ds == DS_OK ) { @@ -633,8 +646,9 @@ static walk_result SymCallback( sym_walk_info swi, sym_handle *sym, void *_idx ) printf( "status=%#x ", ds ); ll.num = 0; } - - /* swi */ + /* + * swi + */ switch( swi ) { case SWI_SYMBOL: printf("SYMBOL "); @@ -649,9 +663,10 @@ static walk_result SymCallback( sym_walk_info swi, sym_handle *sym, void *_idx ) printf("%#d ", swi); break; } - - /* finally, the name. */ - /* try get the name */ + /* + * finally, the name. + * try get the name + */ buff[0] = '\0'; len = DIPSymName( sym, NULL, SNT_DEMANGLED, buff, sizeof( buff ) ); if( len == 0 ) { @@ -665,8 +680,9 @@ static walk_result SymCallback( sym_walk_info swi, sym_handle *sym, void *_idx ) } else { printf( "(len=%u)\n", len ); } - - /* more locations. */ + /* + * more locations. + */ for( i = 1; i < ll.num; i++ ) { if( ll.e[0].type == LT_ADDR ) { printf( " %04x:%08lx\n", @@ -680,14 +696,14 @@ static walk_result SymCallback( sym_walk_info swi, sym_handle *sym, void *_idx ) #endif } -/** +static walk_result ModCallback( mod_handle mh, void *_idx ) +/********************************************************** * WalkModList callback. * * @returns WR_CONTINUE * @param mh The module. * @param _idx Pointer to the current module index. */ -static walk_result ModCallback( mod_handle mh, void *_idx ) { int *idx = (int *)_idx; char buff[2048]; @@ -696,20 +712,23 @@ static walk_result ModCallback( mod_handle mh, void *_idx ) address addr = {0}; printf( "%5d ", ++*idx ); - - /* address */ + /* + * address + */ addr = DIPModAddr( mh ); printf( "%04x:%08lx ", addr.mach.segment, (long)addr.mach.offset ); - - /* what info do we have? */ + /* + * what info do we have? + */ printf( "%c%c%c%c ", DIPModHasInfo( mh, HK_IMAGE ) == DS_OK ? 'I' : '-', DIPModHasInfo( mh, HK_TYPE ) == DS_OK ? 'T' : '-', DIPModHasInfo( mh, HK_CUE ) == DS_OK ? 'C' : '-', DIPModHasInfo( mh, HK_SYM ) == DS_OK ? 'S' : '-' ); - - /* language and name */ + /* + * language and name + */ lang = DIPModSrcLang( mh ); len = DIPModName( mh, buff, sizeof(buff) ); if( len == 0 ) { @@ -720,7 +739,8 @@ static walk_result ModCallback( mod_handle mh, void *_idx ) return( WR_CONTINUE ); } -/** +static int DumpIt( const char *file, mod_handle mh, process_info *proc ) +/*********************************************************************** * Dumps the loaded debug info. * * @returns 0 on success, exit code on failure. @@ -728,7 +748,6 @@ static walk_result ModCallback( mod_handle mh, void *_idx ) * @param mh The DIP/DIG module handle. * @param proc The process which the module is loaded into. */ -static int DumpIt( const char *file, mod_handle mh, process_info *proc ) { walk_result walkres; struct stat s; @@ -738,6 +757,8 @@ static int DumpIt( const char *file, mod_handle mh, process_info *proc ) /* unused parameters */ (void)proc; + /* unused variables */ (void)len; (void)buff; + /* * Module. */ @@ -756,87 +777,83 @@ static int DumpIt( const char *file, mod_handle mh, process_info *proc ) } printf( "DIP = %s\n", DIPImageName( mh ) ); -#if 0 /* crashes codeview, nothing on dwarf. */ +#if 0 + /* + * crashes codeview, nothing on dwarf. + */ buff[0] = '\0'; len = DIPModName( mh, buff, sizeof( buff ) ); if( len ) { printf( "module name = %s\n", buff ); } -#else - len = len; - (void)buff; #endif printf( "\n" "\n" ); - +#if 1 /* * Compiled units? */ - if( 1 ) { - printf( " Compiled Units\n" - "================\n" - "\n" - "index seg:offset info lang name\n" - "---------------------------------------\n"); - i = 0; - walkres = DIPWalkModList( mh, ModCallback, &i ); - printf( "\n" - "\n" ); - } + printf( " Compiled Units\n" + "================\n" + "\n" + "index seg:offset info lang name\n" + "---------------------------------------\n"); + i = 0; + walkres = DIPWalkModList( mh, ModCallback, &i ); + printf( "\n" + "\n" ); +#endif #if 0 /* * Types. * This crashes DWARF, and with codeview it'll only work on one special module. */ - if( 1 ) { - printf( " Types\n" - "=======\n" - "\n" - "index seg:offset info lang name\n" - "---------------------------------------\n"); - i = 0; - walkres = DIPWalkTypeList( /*mh*/ IMH_GBL, TypeCallback, &i ); - printf( "\n" - "\n" ); - } + printf( " Types\n" + "=======\n" + "\n" + "index seg:offset info lang name\n" + "---------------------------------------\n"); + i = 0; + walkres = DIPWalkTypeList( /*mh*/ IMH_GBL, TypeCallback, &i ); + printf( "\n" + "\n" ); #endif +#if 1 /* * Global (?) Symbols. */ - if( 1 ) { - printf( " Global Symbols\n" - "================\n" - "\n" - "index kind seg:offset info lng name\n" - "------------------------------------------\n"); - i = 0; - walkres = DIPWalkSymList( SS_MODULE, &mh, SymCallback, &i ); - printf( "\n" - "\n" ); - } - + printf( " Global Symbols\n" + "================\n" + "\n" + "index kind seg:offset info lng name\n" + "------------------------------------------\n"); + i = 0; + walkres = DIPWalkSymList( SS_MODULE, &mh, SymCallback, &i ); + printf( "\n" + "\n" ); +#endif +#if 1 /* * Iterate compiled modules and dump their line numbers and symbols. */ - if( 1 ) { - i = 0; - walkres = DIPWalkModList( mh, Mod2Callback, &i ); - } + i = 0; + walkres = DIPWalkModList( mh, Mod2Callback, &i ); +#endif printf("\n"); return( 0 ); } -/** +static bool InitDIP( char **dips ) +/********************************* * Initializes DIP. * * @returns success indicator. * @param dips Pointer to an array of dip names terminated by a NULL entry. */ -static bool InitDIP( char **dips ) { bool rc = false; @@ -882,23 +899,23 @@ static bool InitDIP( char **dips ) return( rc ); } -/** +static void TermDIP( void ) +/************************** * Terminates the DIP manager. */ -static void TermDIP( void ) { /// @todo implement me } -/** +static int DumpFile( const char *file, char **dips ) +/*************************************************** * Dumps the debug information in a file. * * @returns 0 on success, exit code on failure. * @param file The filename. * @param dips The dips to load and use. */ -static int DumpFile( const char *file, char **dips ) { int rc = 1; FILE *fp; @@ -910,7 +927,6 @@ static int DumpFile( const char *file, char **dips ) if( fp == NULL ) { return( ErrorMsg( "Failed to open '%s'\n", file ) ); } - /* * Init DIP, create a process and load the file into the process. */ @@ -931,12 +947,10 @@ static int DumpFile( const char *file, char **dips ) if( mh != NO_MOD ) { DIPMapInfo( mh, NULL ); InfoMsg( "DIP opened '%s' at prty=%d, mh=%lx\n", file, priority, (long)mh ); - /* * Enumerate the debug info. */ rc = DumpIt( file, mh, proc ); - /* * Cleanup. */ @@ -954,7 +968,9 @@ static int DumpFile( const char *file, char **dips ) static int PrintUsage( void ) -/* Prints the dipdump usage instructions and and copyright message. */ +/**************************** + * Prints the dipdump usage instructions and and copyright message. + */ { printf( "Usage: dipdump [-h?] [-d] files...\n" "dipdump reads and dumps debugging information\n" @@ -973,7 +989,9 @@ int main( int argc, char **argv ) int rc; // char *s; - /* Process command line options */ + /* + * Process command line options + */ if( argc < 2 ) { return( PrintUsage() ); } @@ -997,7 +1015,9 @@ int main( int argc, char **argv ) } #if 0 - /* Add default DIPs at end of list. */ + /* + * Add default DIPs at end of list. + */ s = DIPDefaults; while( *s ) { if( next_dip >= sizeof( dips ) / sizeof( dips[0] ) ) { @@ -1011,7 +1031,9 @@ int main( int argc, char **argv ) #if defined( __UNIX__ ) || defined( __DOS__ ) PathInit(); #endif - /* Try to dump debug info for all remaining arguments */ + /* + * Try to dump debug info for all remaining arguments + */ rc = 0; while( argv[optind] ) { rc = DumpFile( argv[optind], dips ); diff --git a/bld/dip/dwarf/c/dfaddr.c b/bld/dip/dwarf/c/dfaddr.c index 2bd5fcd3f2..81e00dfeaf 100644 --- a/bld/dip/dwarf/c/dfaddr.c +++ b/bld/dip/dwarf/c/dfaddr.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -74,8 +74,9 @@ static void InitSegOff( void *_new ) static seg_blk_head *GetSegOffBlk( void ) -/***************************************/ -// Alloc a seg_info blk for seg routines +/**************************************** + * Alloc a seg_info blk for seg routines + */ { seg_blk_off *new; @@ -93,31 +94,29 @@ typedef struct { unsigned_16 last; } off_cmp; -/* JBS 2001/03/08 - - Let's say the table looks like this. - - offset:32 len:32 map_offset:32 map_seg:16 im:16 - [1000] [10] [x] [x] [x] - [1010] [22] [x] [x] [x] - [1032] [10] [x] [x] [x] - [2000] [14] [x] [x] [x] - - If we look up offset 1000, then we return 0 (meaning a match was found). - If we look up offset 1002, then we return 0 (meaning a match was found) - because it falls in the range of 1000-1009. - If we look up offset 1050, then we return 1 (meaning no match was found) - because it does not fall in the range of 1032-1041 - and it is below 2000. - If we look up offset 0640, then we return -1 (meaning no match was found) - and it is below 1000. - - So 0 means "in range", - 1 means "above range", and - -1 means "below range". - -*/ - +/* + * Let's say the table looks like this. + * + * offset:32 len:32 map_offset:32 map_seg:16 im:16 + * [1000] [10] [x] [x] [x] + * [1010] [22] [x] [x] [x] + * [1032] [10] [x] [x] [x] + * [2000] [14] [x] [x] [x] + * + * If we look up offset 1000, then we return 0 (meaning a match was found). + * If we look up offset 1002, then we return 0 (meaning a match was found) + * because it falls in the range of 1000-1009. + * If we look up offset 1050, then we return 1 (meaning no match was found) + * because it does not fall in the range of 1032-1041 + * and it is below 2000. + * If we look up offset 0640, then we return -1 (meaning no match was found) + * and it is below 1000. + * + * So 0 means "in range", + * 1 means "above range", and + * -1 means "below range". + * + */ static long BlkOffRangeSearch( off_cmp *cmp ) /*******************************************/ @@ -134,22 +133,20 @@ static long BlkOffRangeSearch( off_cmp *cmp ) return( 0 ); cmp->base++; } - /* So the offset is greater than the current one but it could fall - within the range of the current one - */ + /* + * So the offset is greater than the current one but it could fall + * within the range of the current one + */ return( 1 ); } -/* JBS 2001/03/09 - - BlkOffSearch is like BlkOffRangeSearch except that it doesn't do range - checking. - - If we look up offset 1002, then we return -1 (meaning it goes before 1010). -*/ - static long BlkOffSearch( off_cmp *cmp ) -/**************************************/ +/*************************************** + * BlkOffSearch is like BlkOffRangeSearch except that it doesn't do range + * checking. + * + * If we look up offset 1002, then we return -1 (meaning it goes before 1010). + */ { unsigned_16 ctr; @@ -161,15 +158,16 @@ static long BlkOffSearch( off_cmp *cmp ) return( 0 ); cmp->base++; } - /* So the offset is greater than the current one but it could fall - within the range of the current one - */ + /* + * So the offset is greater than the current one but it could fall + * within the range of the current one + */ return( 1 ); } /* - Mike's old flawed binary search (did not work with addresses >= 0x80000000) -*/ + * Mike's old flawed binary search (did not work with addresses >= 0x80000000) + */ // static long BlkOffSearch( off_cmp *cmp ) { // /****************************************/ @@ -211,11 +209,12 @@ static long BlkOffSearch( off_cmp *cmp ) // } static void AddSortOffset( seg_info *ctl, off_info *new ) -/********************************************************/ -// blocks are in decreasing order -// within a block entries are in increasing order (history). -// it would be better to keep in decreasing order so we could shuffle up -// and not have mem overlap problems +/********************************************************* + * blocks are in decreasing order + * within a block entries are in increasing order (history). + * it would be better to keep in decreasing order so we could shuffle up + * and not have mem overlap problems + */ { off_blk *blk; off_info *info; @@ -295,8 +294,9 @@ static void AddSortOffset( seg_info *ctl, off_info *new ) void AddMapAddr( seg_list *list, void *dcmap, off_info *new ) -/***********************************************************/ -// Add a new address to map +/************************************************************ + * Add a new address to map + */ { static seg_ctl SegCtl = { GetSegOffBlk, InitSegOff }; addr_ptr a; @@ -313,7 +313,9 @@ void AddMapAddr( seg_list *list, void *dcmap, off_info *new ) #ifdef DEBUG static bool CheckInfo( seg_info *ctl ) -/**Internal check to see if sorted***/ +/************************************* + * Internal check to see if sorted + */ { unsigned_16 rem; unsigned_16 blk_count; @@ -355,8 +357,9 @@ static bool CheckInfo( seg_info *ctl ) static bool ChkOffsets( void *d, seg_info *ctl ) -/**********************************************/ -// Sort a seg's offsets +/*********************************************** + * Sort a seg's offsets + */ { d = d; if( !CheckInfo( ctl ) ) { @@ -366,7 +369,9 @@ static bool ChkOffsets( void *d, seg_info *ctl ) } void DmpBlk( off_blk *blk, int count ) -/***** Print contents of blk ********/ +/************************************* + * Print contents of blk + */ { off_info *info; @@ -478,8 +483,9 @@ void SortMapAddr( seg_list *ctl ) bool Real2Map( seg_list *ctl, address *what ) -/*******************************************/ -// convert a map address found in dbg to real address in image +/******************************************** + * convert a map address found in dbg to real address in image + */ { bool ret; off_info *off; @@ -498,16 +504,18 @@ bool Real2Map( seg_list *ctl, address *what ) void InitAddrInfo( seg_list *list ) -/*********************************/ -//Init seg_ctl with addr info +/********************************** + * Init seg_ctl with addr info + */ { InitSegList( list, sizeof( seg_off ) ); } static bool FreeSegOffsets( void *d, void *_curr ) -/************************************************/ -// Free all offset blocks for a segment +/************************************************* + * Free all offset blocks for a segment + */ { seg_info *curr = (seg_info *)_curr; off_blk *blk, *next; @@ -523,9 +531,10 @@ static bool FreeSegOffsets( void *d, void *_curr ) void FiniAddrInfo( seg_list *ctl ) -/********************************/ -//Free all offset blocks for a segment -//Free all segment blocks +/********************************* + * Free all offset blocks for a segment + * Free all segment blocks + */ { SegWalk( ctl, FreeSegOffsets, NULL ); FiniSegList( ctl ); diff --git a/bld/dip/dwarf/c/dfaddsym.c b/bld/dip/dwarf/c/dfaddsym.c index 16d411234e..c502420249 100644 --- a/bld/dip/dwarf/c/dfaddsym.c +++ b/bld/dip/dwarf/c/dfaddsym.c @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -72,9 +73,10 @@ typedef struct { } off_cmp; static off_info *AddMapOffset( seg_off *ctl, off_info *new ) -/**********************************************************/ -// Add a new offset to the last block if full alloc a new one -// bump the item count +/*********************************************************** + * Add a new offset to the last block if full alloc a new one + * bump the item count + */ { off_blk *blk; off_info *next; @@ -104,8 +106,9 @@ static void InitSegOff( void *_newseg ) static seg_blk_head *GetSegOffBlk( void ) -/*************************************/ -// Alloc a seg_info blk for seg routines +/**************************************** + * Alloc a seg_info blk for seg routines + */ { seg_blk_off *new; @@ -117,8 +120,9 @@ static seg_blk_head *GetSegOffBlk( void ) void AddAddrSym( seg_list *list, addrsym_info *new ) -/**************************************************/ -// Add a new address to map +/*************************************************** + * Add a new address to map + */ { static seg_ctl SegCtl = { GetSegOffBlk, InitSegOff }; off_info data; @@ -132,8 +136,9 @@ void AddAddrSym( seg_list *list, addrsym_info *new ) static long BlkOffSearch( off_cmp *cmp ) -/***************************************/ -// Do a B-search on the blk +/**************************************** + * Do a B-search on the blk + */ { off_info *curr; off_info *base; @@ -163,10 +168,11 @@ static long BlkOffSearch( off_cmp *cmp ) return( key - curr->map_offset ); } -// This is a bit screwy, maybe I should do something like dfaddr -// so the blocks are in sorted order int FindAddrSym( seg_list *addr_map, addr_ptr *mach, addrsym_info *ret ) -/***********************************************************************/ +/************************************************************************ + * This is a bit screwy, maybe I should do something like dfaddr + * so the blocks are in sorted order + */ { off_blk *blk; off_info *info; @@ -211,8 +217,9 @@ int FindAddrSym( seg_list *addr_map, addr_ptr *mach, addrsym_info *ret ) static int OffCmp( void const *_off1, void const *_off2 ) -/********************************************************/ -// Compare to offsets +/********************************************************* + * Compare to offsets + */ { off_info const *off1 = _off1; off_info const *off2 = _off2; @@ -226,8 +233,9 @@ static int OffCmp( void const *_off1, void const *_off2 ) static bool SortOffsets( void *d, void *_ctl ) -/********************************************/ -// Sort a seg's offsets +/********************************************* + * Sort a seg's offsets + */ { seg_info *ctl = (seg_info *)_ctl; off_blk *blk; @@ -266,8 +274,9 @@ struct wlk_glue { }; static bool WalkOffsets( void *_wlk, void *_ctl ) -/***********************************************/ -// Sort a seg's offsets +/************************************************ + * Sort a seg's offsets + */ { seg_info *ctl = (seg_info *)_ctl; struct wlk_glue *wlk = _wlk; @@ -309,16 +318,18 @@ bool WlkAddrSyms( seg_list *ctl, WLKADDRSYM fn, void *d ) void InitAddrSym( seg_list *list ) -/*********************************/ -// Init seg_ctl with addr info +/********************************** + * Init seg_ctl with addr info + */ { InitSegList( list, sizeof( seg_off ) ); } static bool FreeSegOffsets( void *d, void *_curr ) -/************************************************/ -// Free all offset blocks for a segment +/************************************************* + * Free all offset blocks for a segment + */ { seg_info *curr = (seg_info *)_curr; off_blk *blk, *next; @@ -334,9 +345,10 @@ static bool FreeSegOffsets( void *d, void *_curr ) void FiniAddrSym( seg_list *ctl ) -/********************************/ -//Free all offset blocks for a segment -//Free all segment blocks +/********************************* + * Free all offset blocks for a segment + * Free all segment blocks + */ { SegWalk( ctl, FreeSegOffsets, NULL ); FiniSegList( ctl ); diff --git a/bld/dip/dwarf/c/dfcue.c b/bld/dip/dwarf/c/dfcue.c index dafb6c5831..68b7392661 100644 --- a/bld/dip/dwarf/c/dfcue.c +++ b/bld/dip/dwarf/c/dfcue.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2018 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -40,10 +40,9 @@ #include "dfcue.h" -/************************/ -/*** cue cache **********/ -/************************/ - +/************************ + *** cue cache ********** + ************************/ void InitImpCueInfo( imp_image_handle *iih ) /******************************************/ @@ -88,12 +87,13 @@ bool FiniImpCueInfo( imp_image_handle *iih ) imp_mod_handle DIPIMPENTRY( CueMod )( imp_image_handle *iih, imp_cue_handle *icueh ) -/**********************************************************************************/ +/*********************************************************************************** + * Return the module the source cue comes from. + */ { /* unused parameters */ (void)iih; - /* Return the module the source cue comes from. */ - return( icueh->imh ); + return( icueh->imh ); } @@ -126,7 +126,8 @@ static bool ACueFile( void *_info, dr_line_file *curr ) strcat( info->ret, "/"); strcat( info->ret, curr->name ); } else { - /* This should be an error, but it isn't fatal as we should + /* + * This should be an error, but it isn't fatal as we should * never get here in practice. */ info->ret = DCAlloc( strlen( curr->name ) + 1 ); @@ -164,7 +165,9 @@ static bool ACueDir( void *_info, dr_line_dir *curr ) static bool IsRelPathname( const char *name ) /*******************************************/ { - /* Detect UNIX or DOS style relative pathnames */ + /* + * Detect UNIX or DOS style relative pathnames + */ if( (name[0] == '/') || (name[0] == '\\') ) { return( false ); } @@ -201,8 +204,9 @@ size_t DIPIMPENTRY( CueFile )( imp_image_handle *iih, imp_cue_handle *icueh, cha wlk.dirs = NULL; DRWalkLFiles( stmts, ACueFile, &wlk, ACueDir, &wlk ); name = wlk.ret; - - // Free directory and file table information + /* + * Free directory and file table information + */ for( i = 0; i < wlk.num_dirs; i++ ) { DCFree( wlk.dirs[i].name ); } @@ -212,8 +216,10 @@ size_t DIPIMPENTRY( CueFile )( imp_image_handle *iih, imp_cue_handle *icueh, cha DCStatus( DS_FAIL ); return( 0 ); } - // If compilation unit has a DW_AT_comp_dir attribute, we need to - // stuff that in front of the file pathname, unless that is absolute + /* + * If compilation unit has a DW_AT_comp_dir attribute, we need to + * stuff that in front of the file pathname, unless that is absolute + */ len = DRGetCompDirBuff( cu_tag, buff, buff_size ); if( ( len > 1 ) && IsRelPathname( name ) ) { // Ignore empty comp dirs len = NameCopy( buff, "/", buff_size, len ); @@ -255,7 +261,7 @@ static bool FirstCue( drmem_hdl stmts, uint_16 fno, imp_cue_handle *icueh ) if( cont == false ) { icueh->fno = wlk.first.file; icueh->line = wlk.first.line; -// icueh->col = wlk.first.col; +// icueh->col = wlk.first.col; icueh->col = 0; icueh->a = NilAddr; icueh->a.mach.segment = wlk.first.seg; @@ -336,9 +342,9 @@ cue_fileid DIPIMPENTRY( CueFileId )( imp_image_handle *iih, imp_cue_handle *icue return( icueh->fno ); } -/*******************************/ -/*** Load Cue map find cues ***/ -/*******************************/ +/******************************* + *** Load Cue map find cues *** + *******************************/ typedef struct { address ret; @@ -371,25 +377,24 @@ static void LoadCueMap( drmem_hdl stmts, address *addr, cue_list *list ) } -/* - Adjust the 'src' cue by 'adj' amount and return the result in 'dst'. - That is, If you get called with "DIPImpCueAdjust( iih, src, 1, dst )", - the 'dst' handle should be filled in with implementation cue handle - representing the source cue immediately following the 'src' cue. - Passing in an 'adj' of -1 will get the immediately preceeding source - cue. The list of source cues for each file are considered a ring, - so if 'src' is the first cue in a file, an 'adj' of -1 will return - the last source cue FOR THAT FILE. The cue adjust never crosses a - file boundry. Also, if 'src' is the last cue in a file, and 'adj' of - 1 will get the first source cue FOR THAT FILE. If an adjustment - causes a wrap from begining to end or vice versa, you should return - DS_WRAPPED status (NOTE: DS_ERR should *not* be or'd in, nor should - DCStatus be called in this case). Otherwise DS_OK should be returned - unless an error occurred. -*/ dip_status DIPIMPENTRY( CueAdjust )( imp_image_handle *iih, imp_cue_handle *src_icueh, int adj, imp_cue_handle *dst_icueh ) -/************************************************************************************/ +/************************************************************************************* + * Adjust the 'src' cue by 'adj' amount and return the result in 'dst'. + * That is, If you get called with "DIPImpCueAdjust( iih, src, 1, dst )", + * the 'dst' handle should be filled in with implementation cue handle + * representing the source cue immediately following the 'src' cue. + * Passing in an 'adj' of -1 will get the immediately preceeding source + * cue. The list of source cues for each file are considered a ring, + * so if 'src' is the first cue in a file, an 'adj' of -1 will return + * the last source cue FOR THAT FILE. The cue adjust never crosses a + * file boundry. Also, if 'src' is the last cue in a file, and 'adj' of + * 1 will get the first source cue FOR THAT FILE. If an adjustment + * causes a wrap from begining to end or vice versa, you should return + * DS_WRAPPED status (NOTE: DS_ERR should *not* be or'd in, nor should + * DCStatus be called in this case). Otherwise DS_OK should be returned + * unless an error occurred. + */ { drmem_hdl stmts; dfline_search start_state; @@ -461,26 +466,27 @@ unsigned long DIPIMPENTRY( CueLine )( imp_image_handle *iih, imp_cue_handle *icu unsigned DIPIMPENTRY( CueColumn )( imp_image_handle *iih, imp_cue_handle *icueh ) -/*******************************************************************************/ +/******************************************************************************** + * Return the column number of source cue. Return zero if there + * is no column number associated with the cue, or an error occurs in + * getting the information. + */ { /* unused parameters */ (void)iih; - /* Return the column number of source cue. Return zero if there - * is no column number associated with the cue, or an error occurs in - * getting the information. - */ return( icueh->col ); } address DIPIMPENTRY( CueAddr )( imp_image_handle *iih, imp_cue_handle *icueh ) -/****************************************************************************/ +/***************************************************************************** + * Return the address of source cue. Return NilAddr if there + * is no address associated with the cue, or an error occurs in + * getting the information. + */ { address ret; - /* Return the address of source cue. Return NilAddr if there - * is no address associated with the cue, or an error occurs in - * getting the information. - */ + ret = icueh->a; DCMapAddr( &ret.mach, iih->dcmap ); return( ret ); @@ -489,13 +495,13 @@ address DIPIMPENTRY( CueAddr )( imp_image_handle *iih, imp_cue_handle *icueh ) search_result DIPIMPENTRY( AddrCue )( imp_image_handle *iih, imp_mod_handle imh, address addr, imp_cue_handle *icueh ) -/***********************************************************************/ +/************************************************************************ + * Search for the closest cue in the given module that has an address + * less then or equal to the given address. If there is no such cue + * return SR_NONE. If there is one exactly at the address return + * SR_EXACT. Otherwise, return SR_CLOSEST. + */ { - /* Search for the closest cue in the given module that has an address - * less then or equal to the given address. If there is no such cue - * return SR_NONE. If there is one exactly at the address return - * SR_EXACT. Otherwise, return SR_CLOSEST. - */ address map_addr; search_result ret; cue_list *cue_map; @@ -622,20 +628,20 @@ search_result DIPIMPENTRY( LineCue )( imp_image_handle *iih, int DIPIMPENTRY( CueCmp )( imp_image_handle *iih, imp_cue_handle *icueh1, imp_cue_handle *icueh2 ) -/************************************************************************************************/ +/************************************************************************************************* + * Compare two cue handles and return 0 if they refer to the same + * information. If they refer to differnt things return either a + * positive or negative value to impose an 'order' on the information. + * The value should obey the following constraints. + * Given three handles H1, H2, H3: + * - if H1 < H2 then H1 is always < H2 + * - if H1 < H2 and H2 < H3 then H1 is < H3 + * The reason for the constraints is so that a client can sort a + * list of handles and binary search them. + */ { /* unused parameters */ (void)iih; - /* Compare two cue handles and return 0 if they refer to the same - * information. If they refer to differnt things return either a - * positive or negative value to impose an 'order' on the information. - * The value should obey the following constraints. - * Given three handles H1, H2, H3: - * - if H1 < H2 then H1 is always < H2 - * - if H1 < H2 and H2 < H3 then H1 is < H3 - * The reason for the constraints is so that a client can sort a - * list of handles and binary search them. - */ if( icueh1->imh < icueh2->imh ) return( -1 ); if( icueh1->imh > icueh2->imh ) diff --git a/bld/dip/dwarf/c/dfhash.c b/bld/dip/dwarf/c/dfhash.c index 15090be601..c2413a3f9a 100644 --- a/bld/dip/dwarf/c/dfhash.c +++ b/bld/dip/dwarf/c/dfhash.c @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -128,9 +129,10 @@ struct name_ctl { }; -// hashpjw out of dragon book static uint_32 elf_hash( char const *name ) -/*****************************************/ +/****************************************** + * hashpjw out of dragon book + */ { uint_32 h; uint_32 g; @@ -167,8 +169,9 @@ name_ctl *InitHashName( void ) void FiniHashName( name_ctl *ctl ) -/********************************/ -// Kill hash table +/********************************* + * Kill hash table + */ { unsigned bnum; unsigned vacant; @@ -202,8 +205,9 @@ void FiniHashName( name_ctl *ctl ) void AddHashName( name_ctl *ctl, const char *name, drmem_hdl sym ) -/****************************************************************/ -// Add name, sym to foray +/***************************************************************** + * Add name, sym to foray + */ { uint_32 key; int bnum; @@ -235,8 +239,9 @@ void AddHashName( name_ctl *ctl, const char *name, drmem_hdl sym ) bool FindHashWalk( name_ctl *ctl, name_wlk *wlk ) -/***********************************************/ -// Walk all entries that hash to same key +/************************************************ + * Walk all entries that hash to same key + */ { uint_32 key; int bnum; diff --git a/bld/dip/dwarf/c/dfld.c b/bld/dip/dwarf/c/dfld.c index c879721cd5..c7ebf5f9c1 100644 --- a/bld/dip/dwarf/c/dfld.c +++ b/bld/dip/dwarf/c/dfld.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -93,8 +93,9 @@ static void ByteSwapShdr( Elf32_Shdr *elf_sec, bool byteswap ) static dip_status GetSectInfo( FILE *fp, unsigned long *sizes, unsigned long *bases, bool *byteswap ) -/***************************************************************************************************/ -// Fill in the starting offset & length of the dwarf sections +/**************************************************************************************************** + * Fill in the starting offset & length of the dwarf sections + */ { TISTrailer dbg_head; Elf32_Ehdr elf_head; @@ -114,7 +115,9 @@ static dip_status GetSectInfo( FILE *fp, unsigned long *sizes, unsigned long *ba return( DS_FAIL ); } if( dbg_head.signature != TIS_TRAILER_SIGNATURE ) { - /* Seek to start of file and hope it's in ELF format */ + /* + * Seek to start of file and hope it's in ELF format + */ start = 0; DCSeek( fp, 0, DIG_SEEK_ORG ); break; @@ -189,7 +192,9 @@ static dip_status GetSectInfo( FILE *fp, unsigned long *sizes, unsigned long *ba if( sizes[DR_DEBUG_INFO] == 0 || sizes[DR_DEBUG_ABBREV] == 0 || sizes[DR_DEBUG_ARANGES] == 0 ) { - /* NOTE: aranges shouldn't be required to work, but currently is. */ + /* + * NOTE: aranges shouldn't be required to work, but currently is. + */ return( DS_FAIL ); } return( DS_OK ); @@ -245,7 +250,9 @@ static void DWRErr( dr_except code ) /**********************************/ { #if !defined( NDEBUG ) && defined( __WATCOMC__ ) && defined( __386__ ) - // for easier debugging + /* + * for easier debugging + */ __asm int 3; #endif switch( code ) { @@ -314,11 +321,14 @@ static void FiniDwarf( imp_image_handle *iih ) } } -/* Loading/unloading symbolic information. */ +/* + * Loading/unloading symbolic information. + */ static bool APubName( void *_iih, dr_pubname_data *curr ) -/*******************************************************/ -// Add name from pubdefs to global name hash +/******************************************************** + * Add name from pubdefs to global name hash + */ { imp_image_handle *iih = _iih; @@ -331,8 +341,9 @@ static bool APubName( void *_iih, dr_pubname_data *curr ) static bool AModHash( drmem_hdl sym, void *_iih, dr_search_context *cont ) -/************************************************************************/ -// Add any global symbol to the hash +/************************************************************************* + * Add any global symbol to the hash + */ { imp_image_handle *iih = _iih; // unsigned len; @@ -350,8 +361,9 @@ static bool AModHash( drmem_hdl sym, void *_iih, dr_search_context *cont ) static walk_result ModGlbSymHash( imp_image_handle *iih, imp_mod_handle imh, void *d ) -/************************************************************************************/ -// Add module's global syms to the name hash +/************************************************************************************* + * Add module's global syms to the name hash + */ { /* unused parameters */ (void)d; @@ -361,8 +373,9 @@ static walk_result ModGlbSymHash( imp_image_handle *iih, imp_mod_handle imh, voi static void LoadGlbHash( imp_image_handle *iih ) -/**********************************************/ -// Load a name hash of all the gobal symbols +/*********************************************** + * Load a name hash of all the gobal symbols + */ { DRSetDebug( iih->dwarf->handle ); /* must do at each interface */ if( iih->has_pubnames ) { @@ -449,8 +462,9 @@ static bool ARangeItem( void *_info, dr_arange_data *arange ) void DIPIMPENTRY( MapInfo )( imp_image_handle *iih, void *d ) -/***********************************************************/ -// Read in address ranges and build map +/************************************************************ + * Read in address ranges and build map + */ { a_walk_info info; diff --git a/bld/dip/dwarf/c/dfline.c b/bld/dip/dwarf/c/dfline.c index 610d30d7a0..0f70806829 100644 --- a/bld/dip/dwarf/c/dfline.c +++ b/bld/dip/dwarf/c/dfline.c @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -59,15 +60,16 @@ struct seg_cue { -void InitCueList( cue_list *ctl ) { +void InitCueList( cue_list *ctl ) /*********************************/ - +{ ctl->head = NULL; } seg_cue *InitSegCue( cue_list *ctl, addr_seg seg, addr_off offset ) -/*****************************************************************/ -/* Keep in asending order seg:offset */ +/****************************************************************** + * Keep in asending order seg:offset + */ { seg_cue *curr; seg_cue **lnk; @@ -89,9 +91,10 @@ seg_cue *InitSegCue( cue_list *ctl, addr_seg seg, addr_off offset ) } void AddCue( seg_cue *ctl, dr_line_data *new ) -/********************************************/ -// Add a new offset to the last block if full alloc a new one -// bump the item count +/********************************************* + * Add a new offset to the last block if full alloc a new one + * bump the item count + */ { cue_blk *blk, **lnk; cue_info *next; @@ -131,9 +134,11 @@ typedef struct{ }off_cmp; -static long BlkOffSearch( off_cmp *cmp ) { -/****************************************/ -// Do a B-search on the blk +static long BlkOffSearch( off_cmp *cmp ) +/***************************************** + * Do a B-search on the blk + */ +{ cue_info *curr; cue_info *base; addr_off key; @@ -417,8 +422,9 @@ dfline_find FindCue( cue_list *list, cue_item *item, dfline_search what ) } static void FreeSegCue( seg_cue *curr ) -/***********************************************/ -// Free all offset blocks for a segment +/************************************** + * Free all offset blocks for a segment + */ { cue_blk *blk, *next; @@ -429,9 +435,10 @@ static void FreeSegCue( seg_cue *curr ) } void FiniCueInfo( cue_list *list ) -/*********************************/ -//Free all offset blocks for a line segment -//Free all line segments +/********************************** + * Free all offset blocks for a line segment + * Free all line segments + */ { seg_cue *ctl; diff --git a/bld/dip/dwarf/c/dfloc.c b/bld/dip/dwarf/c/dfloc.c index 35fa63f890..dbdf46967a 100644 --- a/bld/dip/dwarf/c/dfloc.c +++ b/bld/dip/dwarf/c/dfloc.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -171,74 +171,77 @@ typedef enum { #undef DW_REG }dw_axp_regs; -/* WARNING: Must be kept in sync with dwregaxp.h included above */ - +/* + * WARNING: Must be kept in sync with dwregaxp.h included above + */ static uint_16 const CLRegAXP[DW_AXP_MAX] = { - /* Alpha architecture */ - CI_AXP_r0, //DW_AXP_r0 - CI_AXP_r1, //DW_AXP_r1 - CI_AXP_r2, //DW_AXP_r2 - CI_AXP_r3, //DW_AXP_r3 - CI_AXP_r4, //DW_AXP_r4 - CI_AXP_r5, //DW_AXP_r5 - CI_AXP_r6, //DW_AXP_r6 - CI_AXP_r7, //DW_AXP_r7 - CI_AXP_r8, //DW_AXP_r8 - CI_AXP_r9, //DW_AXP_r9 - CI_AXP_r10, //DW_AXP_r10 - CI_AXP_r11, //DW_AXP_r11 - CI_AXP_r12, //DW_AXP_r12 - CI_AXP_r13, //DW_AXP_r13 - CI_AXP_r14, //DW_AXP_r14 - CI_AXP_r15, //DW_AXP_r15 - CI_AXP_r16, //DW_AXP_r16 - CI_AXP_r17, //DW_AXP_r17 - CI_AXP_r18, //DW_AXP_r18 - CI_AXP_r19, //DW_AXP_r19 - CI_AXP_r20, //DW_AXP_r20 - CI_AXP_r21, //DW_AXP_r21 - CI_AXP_r22, //DW_AXP_r22 - CI_AXP_r23, //DW_AXP_r23 - CI_AXP_r24, //DW_AXP_r24 - CI_AXP_r25, //DW_AXP_r25 - CI_AXP_r26, //DW_AXP_r26 - CI_AXP_r27, //DW_AXP_r27 - CI_AXP_r28, //DW_AXP_r28 - CI_AXP_r29, //DW_AXP_r29 - CI_AXP_r30, //DW_AXP_r30 - CI_AXP_r31, //DW_AXP_r31 - CI_AXP_f0, //DW_AXP_f0 - CI_AXP_f1, //DW_AXP_f1 - CI_AXP_f2, //DW_AXP_f2 - CI_AXP_f3, //DW_AXP_f3 - CI_AXP_f4, //DW_AXP_f4 - CI_AXP_f5, //DW_AXP_f5 - CI_AXP_f6, //DW_AXP_f6 - CI_AXP_f7, //DW_AXP_f7 - CI_AXP_f8, //DW_AXP_f8 - CI_AXP_f9, //DW_AXP_f9 - CI_AXP_f10, //DW_AXP_f10 - CI_AXP_f11, //DW_AXP_f11 - CI_AXP_f12, //DW_AXP_f12 - CI_AXP_f13, //DW_AXP_f13 - CI_AXP_f14, //DW_AXP_f14 - CI_AXP_f15, //DW_AXP_f15 - CI_AXP_f16, //DW_AXP_f16 - CI_AXP_f17, //DW_AXP_f17 - CI_AXP_f18, //DW_AXP_f18 - CI_AXP_f19, //DW_AXP_f19 - CI_AXP_f20, //DW_AXP_f20 - CI_AXP_f21, //DW_AXP_f21 - CI_AXP_f22, //DW_AXP_f22 - CI_AXP_f23, //DW_AXP_f23 - CI_AXP_f24, //DW_AXP_f24 - CI_AXP_f25, //DW_AXP_f25 - CI_AXP_f26, //DW_AXP_f26 - CI_AXP_f27, //DW_AXP_f27 - CI_AXP_f28, //DW_AXP_f28 - CI_AXP_f29, //DW_AXP_f29 - CI_AXP_f30, //DW_AXP_f30 - CI_AXP_f31, //DW_AXP_f31 + /* + * Alpha architecture + */ + CI_AXP_r0, //DW_AXP_r0 + CI_AXP_r1, //DW_AXP_r1 + CI_AXP_r2, //DW_AXP_r2 + CI_AXP_r3, //DW_AXP_r3 + CI_AXP_r4, //DW_AXP_r4 + CI_AXP_r5, //DW_AXP_r5 + CI_AXP_r6, //DW_AXP_r6 + CI_AXP_r7, //DW_AXP_r7 + CI_AXP_r8, //DW_AXP_r8 + CI_AXP_r9, //DW_AXP_r9 + CI_AXP_r10, //DW_AXP_r10 + CI_AXP_r11, //DW_AXP_r11 + CI_AXP_r12, //DW_AXP_r12 + CI_AXP_r13, //DW_AXP_r13 + CI_AXP_r14, //DW_AXP_r14 + CI_AXP_r15, //DW_AXP_r15 + CI_AXP_r16, //DW_AXP_r16 + CI_AXP_r17, //DW_AXP_r17 + CI_AXP_r18, //DW_AXP_r18 + CI_AXP_r19, //DW_AXP_r19 + CI_AXP_r20, //DW_AXP_r20 + CI_AXP_r21, //DW_AXP_r21 + CI_AXP_r22, //DW_AXP_r22 + CI_AXP_r23, //DW_AXP_r23 + CI_AXP_r24, //DW_AXP_r24 + CI_AXP_r25, //DW_AXP_r25 + CI_AXP_r26, //DW_AXP_r26 + CI_AXP_r27, //DW_AXP_r27 + CI_AXP_r28, //DW_AXP_r28 + CI_AXP_r29, //DW_AXP_r29 + CI_AXP_r30, //DW_AXP_r30 + CI_AXP_r31, //DW_AXP_r31 + CI_AXP_f0, //DW_AXP_f0 + CI_AXP_f1, //DW_AXP_f1 + CI_AXP_f2, //DW_AXP_f2 + CI_AXP_f3, //DW_AXP_f3 + CI_AXP_f4, //DW_AXP_f4 + CI_AXP_f5, //DW_AXP_f5 + CI_AXP_f6, //DW_AXP_f6 + CI_AXP_f7, //DW_AXP_f7 + CI_AXP_f8, //DW_AXP_f8 + CI_AXP_f9, //DW_AXP_f9 + CI_AXP_f10, //DW_AXP_f10 + CI_AXP_f11, //DW_AXP_f11 + CI_AXP_f12, //DW_AXP_f12 + CI_AXP_f13, //DW_AXP_f13 + CI_AXP_f14, //DW_AXP_f14 + CI_AXP_f15, //DW_AXP_f15 + CI_AXP_f16, //DW_AXP_f16 + CI_AXP_f17, //DW_AXP_f17 + CI_AXP_f18, //DW_AXP_f18 + CI_AXP_f19, //DW_AXP_f19 + CI_AXP_f20, //DW_AXP_f20 + CI_AXP_f21, //DW_AXP_f21 + CI_AXP_f22, //DW_AXP_f22 + CI_AXP_f23, //DW_AXP_f23 + CI_AXP_f24, //DW_AXP_f24 + CI_AXP_f25, //DW_AXP_f25 + CI_AXP_f26, //DW_AXP_f26 + CI_AXP_f27, //DW_AXP_f27 + CI_AXP_f28, //DW_AXP_f28 + CI_AXP_f29, //DW_AXP_f29 + CI_AXP_f30, //DW_AXP_f30 + CI_AXP_f31, //DW_AXP_f31 }; typedef enum { @@ -254,10 +257,13 @@ typedef struct { unsigned len : 8; } ppcreg_entry; -/* WARNING: Must be kept in sync with dwregppc.h included above */ - +/* + * WARNING: Must be kept in sync with dwregppc.h included above + */ static ppcreg_entry const CLRegPPC[DW_PPC_MAX] = { - /* PowerPC architecture */ + /* + * PowerPC architecture + */ { CI_PPC_r0, 0, 32 }, //DW_PPC_r0 { CI_PPC_r1, 0, 32 }, //DW_PPC_r1 { CI_PPC_r2, 0, 32 }, //DW_PPC_r2 @@ -337,10 +343,13 @@ typedef struct { unsigned len : 8; } mipsreg_entry; -/* WARNING: Must be kept in sync with dwregmips.h included above */ - +/* + * WARNING: Must be kept in sync with dwregmips.h included above + */ static mipsreg_entry const CLRegMIPS[DW_MIPS_MAX] = { - /* MIPS architecture */ + /* + * MIPS architecture + */ { CI_MIPS_r0, 0, 32 }, //DW_MIPS_r0 { CI_MIPS_r1, 0, 32 }, //DW_MIPS_r1 { CI_MIPS_r2, 0, 32 }, //DW_MIPS_r2 @@ -408,8 +417,8 @@ static mipsreg_entry const CLRegMIPS[DW_MIPS_MAX] = { }; /* - Stuff dealing with evaluating dwarf location expr's -*/ + * Stuff dealing with evaluating dwarf location expr's + */ typedef struct { imp_image_handle *iih; @@ -424,10 +433,12 @@ typedef struct { } loc_handle; static dr_loc_kind Init( void *_d, uint_32 *where ) +/************************************************** + * Set location expr initial value + */ { loc_handle *d = _d; -// Set location expr initial value switch( d->init ) { case DR_LOC_NONE: break; @@ -442,9 +453,11 @@ static dr_loc_kind Init( void *_d, uint_32 *where ) static bool Ref( void *_d, uint_32 offset, uint_32 size, dr_loc_kind kind ) +/************************************************************************** + * Collect a reference from location expr and stuff in ret ll + * Assume d->ll init num == 0, flags == 0 + */ { -// Collect a reference from location expr and stuff in ret ll -// Assume d->ll init num == 0, flags == 0 loc_handle *d = _d; location_list tmp, *ll; @@ -469,9 +482,11 @@ static bool Ref( void *_d, uint_32 offset, uint_32 size, dr_loc_kind kind ) break; case DIG_ARCH_PPC: areg = CLRegPPC[offset].ci; - // This should really be dynamic; anyway the registers are really - // stored as 64-bit values, so if we want to get at the lower 32 - // bits only, we need to start 32 bits into the storage. + /* + * This should really be dynamic; anyway the registers are really + * stored as 64-bit values, so if we want to get at the lower 32 + * bits only, we need to start 32 bits into the storage. + */ #if defined( __BIG_ENDIAN__ ) if( CLRegPPC[offset].len == 32 ) { start = 32; @@ -484,7 +499,9 @@ static bool Ref( void *_d, uint_32 offset, uint_32 size, dr_loc_kind kind ) break; case DIG_ARCH_MIPS: areg = CLRegMIPS[offset].ci; - // See PowerPC comments above + /* + * See PowerPC comments above + */ #if defined( __BIG_ENDIAN__ ) if( CLRegMIPS[offset].len == 32 ) { start = 32; @@ -514,9 +531,12 @@ static bool Ref( void *_d, uint_32 offset, uint_32 size, dr_loc_kind kind ) } -static bool DRef( void *_d, uint_32 *where, uint_32 offset, uint_32 size ) { -// Dereference a value use default address space -// The offset on top of the stack is relative to it +static bool DRef( void *_d, uint_32 *where, uint_32 offset, uint_32 size ) +/************************************************************************* + * Dereference a value use default address space + * The offset on top of the stack is relative to it + */ +{ loc_handle *d = _d; address a; location_list tmp; @@ -544,8 +564,10 @@ static bool DRef( void *_d, uint_32 *where, uint_32 offset, uint_32 size ) { } static bool DRefX( void *_d, uint_32 *where, uint_32 offset, uint_32 seg, uint_16 size ) +/*************************************************************************************** + * Dereference an extended address + */ { -// Dereference an extended address loc_handle *d = _d; address a; location_list tmp; @@ -554,7 +576,7 @@ static bool DRefX( void *_d, uint_32 *where, uint_32 offset, uint_32 seg, uint_1 a = NilAddr; a.mach.segment = seg; a.mach.offset = offset; -// DCMapAddr( &a.mach, d->iih->dcmap ); +// DCMapAddr( &a.mach, d->iih->dcmap ); LocationCreate( &ll, LT_ADDR, &a ); ll.e[0].bit_length = size * 8; LocationCreate( &tmp, LT_INTERNAL, where ); @@ -567,12 +589,14 @@ static bool DRefX( void *_d, uint_32 *where, uint_32 offset, uint_32 seg, uint_1 } static bool Frame( void *_d, uint_32 *where ) +/******************************************** + * Get frame location + */ { loc_handle *d = _d; location_list ll; // dig_arch arch; -// Get frame location // arch = DCCurrArch(); DCCurrArch(); d->ds = SafeDCItemLocation( d->lc, CI_FRAME, &ll ); @@ -586,8 +610,10 @@ static bool Frame( void *_d, uint_32 *where ) } static bool Reg( void *_d, uint_32 *where, uint_16 reg ) +/******************************************************* + * get value of reg + */ { -// get value of reg loc_handle *d = _d; location_list ll; location_list tmp; @@ -606,7 +632,9 @@ static bool Reg( void *_d, uint_32 *where, uint_16 reg ) case DIG_ARCH_AXP: areg = CLRegAXP[reg]; start = 0; - /* a massive kludge here */ + /* + * a massive kludge here + */ if( areg >= CI_AXP_f0 && areg <= CI_AXP_f31 ) { size = 64; } else { @@ -615,7 +643,9 @@ static bool Reg( void *_d, uint_32 *where, uint_16 reg ) break; case DIG_ARCH_PPC: areg = CLRegPPC[reg].ci; - /* yep, another and even worse kludge */ + /* + * yep, another and even worse kludge + */ #if defined( __BIG_ENDIAN__ ) if( CLRegPPC[reg].len == 32 ) { start = 32; @@ -629,7 +659,9 @@ static bool Reg( void *_d, uint_32 *where, uint_16 reg ) break; case DIG_ARCH_MIPS: areg = CLRegMIPS[reg].ci; - /* just as bad as PPC */ + /* + * just as bad as PPC + */ #if defined( __BIG_ENDIAN__ ) if( CLRegMIPS[reg].len == 32 ) { start = 32; @@ -682,8 +714,10 @@ static bool Reg( void *_d, uint_32 *where, uint_16 reg ) } static bool ACon( void *_d, uint_32 *where, bool isfar ) +/******************************************************* + * relocate a map address constant + */ { -// relocate a map address constant loc_handle *d = _d; d->base.mach.offset = where[0]; @@ -701,13 +735,17 @@ static bool ACon( void *_d, uint_32 *where, bool isfar ) } static bool Live( void *_d, uint_32 *where ) +/******************************************* + * find the appropriate live range + */ { -// find the appropriate live range loc_handle *d = _d; location_list ll; // dip_status ds; -// Get execution location + /* + * Get execution location + */ // ds = SafeDCItemLocation( d->lc, CI_EXECUTION, &ll ); SafeDCItemLocation( d->lc, CI_EXECUTION, &ll ); d->ds = DS_OK; @@ -734,17 +772,20 @@ static dr_loc_callbck_def const CallBck = { Live }; -static bool IsEntry( imp_image_handle *iih, location_context *lc ) { - /* - Determine if we are at function entry - */ +static bool IsEntry( imp_image_handle *iih, location_context *lc ) +/***************************************************************** + * Determine if we are at function entry + */ +{ location_list ll; addrsym_info info; dip_status ds; seg_list *addr_sym; imp_mod_handle imh; -// Get execution location + /* + * Get execution location + */ ds = SafeDCItemLocation( lc, CI_EXECUTION, &ll ); if( ds != DS_OK ) { return( false ); @@ -806,8 +847,10 @@ dip_status EvalLocation( imp_image_handle *iih, location_context *lc, drmem_hdl } static bool NoFrame( void *_d, uint_32 *where ) +/********************************************** + * For EvalParmLocation frame not valid + */ { -//For EvalParmLocation frame not valid loc_handle *d = _d; d->ds = DS_FAIL; @@ -816,9 +859,11 @@ static bool NoFrame( void *_d, uint_32 *where ) } static bool FakeLive( void *_d, uint_32 *where ) +/*********************************************** + * force loc to take first addr in live range hopefully the parm on entry + * Get execution location + */ { -// force loc to take first addr in live range hopefully the parm on entry -// Get execution location loc_handle *d = _d; d->ds = DS_OK; @@ -827,10 +872,12 @@ static bool FakeLive( void *_d, uint_32 *where ) } static bool RegOnlyRef( void *_d, uint_32 offset, uint_32 size, dr_loc_kind kind ) +/********************************************************************************* + * Collect a reference from location expr and stuff in ret ll + * Assume d->ll init num == 0, flags == 0 + * if not reg return false parmloc requirement + */ { -// Collect a reference from location expr and stuff in ret ll -// Assume d->ll init num == 0, flags == 0 -// if not reg return false parmloc requirement loc_handle *d = _d; location_list tmp, *ll; @@ -884,7 +931,7 @@ dip_status EvalParmLocation( imp_image_handle *iih, location_context *lc, drmem_ d.ds = DS_FAIL; } } -// LocationLast( ll ); +// LocationLast( ll ); return( d.ds ); } @@ -908,13 +955,16 @@ dip_status EvalRetLocation( imp_image_handle *iih, location_context *lc, drmem_h d.ds = DS_FAIL; } } -// LocationLast( ll ); +// LocationLast( ll ); return( d.ds ); } -static dr_loc_kind AdjInit( void *_d, uint_32 *where ) { -// Set location expr initial value +static dr_loc_kind AdjInit( void *_d, uint_32 *where ) +/***************************************************** + * Set location expr initial value + */ +{ loc_handle *d = _d; switch( d->init ) { @@ -941,7 +991,9 @@ static dr_loc_callbck_def const AdjBck = { }; dip_status EvalLocAdj( imp_image_handle *iih, location_context *lc, drmem_hdl sym, address *addr ) -// locations are relative to the object +/************************************************************************************************* + * locations are relative to the object + */ { loc_handle d; location_list ll; @@ -960,7 +1012,8 @@ dip_status EvalLocAdj( imp_image_handle *iih, location_context *lc, drmem_hdl sy d.ds = DS_FAIL; } } - /* DWARF V2 spec is unclear at best, but DWARF V3 spells out that + /* + * DWARF V2 spec is unclear at best, but DWARF V3 spells out that * DW_AT_data_member_location may be a location expression, in which * case the address of the "base" needs to be pushed on the stack and * the expression is expected to include a plus operator to add to it. @@ -984,7 +1037,9 @@ dip_status EvalLocAdj( imp_image_handle *iih, location_context *lc, drmem_hdl sy } static bool Val( void *_d, uint_32 offset, uint_32 size, dr_loc_kind kind ) -// Assume top of stack is value to get +/************************************************************************** + * Assume top of stack is value to get + */ { loc_handle *d = _d; @@ -1059,7 +1114,9 @@ typedef struct { } nop_loc_handle; static dr_loc_kind NOPInit( void *d, uint_32 *where ) -// Set location expr initial value +/**************************************************** + * Set location expr initial value + */ { /* unused parameters */ (void)d; (void)where; @@ -1078,7 +1135,9 @@ static bool NOPRef( void *_d, uint_32 offset, uint_32 size, dr_loc_kind kind ) } static bool NOPDRef( void *_d, uint_32 *where, uint_32 offset, uint_32 size ) -// Dereference a value use default address space +/**************************************************************************** + * Dereference a value use default address space + */ { nop_loc_handle *d = _d; @@ -1089,7 +1148,9 @@ static bool NOPDRef( void *_d, uint_32 *where, uint_32 offset, uint_32 size ) } static bool NOPDRefX( void *_d, uint_32 *where, uint_32 offset, uint_32 seg, uint_16 size ) -// Dereference an extended address +/****************************************************************************************** + * Dereference an extended address + */ { nop_loc_handle *d = _d; @@ -1118,7 +1179,9 @@ static bool NOPReg( void *_d, uint_32 *where, uint_16 reg ) } static bool NOPACon( void *_d, uint_32 *where, bool isfar ) -// relocate a map address constant +/********************************************************** + * relocate a map address constant + */ { /* unused parameters */ (void)where; (void)isfar; @@ -1128,7 +1191,9 @@ static bool NOPACon( void *_d, uint_32 *where, bool isfar ) } static bool NOPLive( void *_d, uint_32 *where ) -// find the appropriate live range +/********************************************** + * find the appropriate live range + */ { nop_loc_handle *d = _d; @@ -1148,7 +1213,9 @@ static dr_loc_callbck_def const NOPCallBck = { }; bool EvalOffset( imp_image_handle *iih, drmem_hdl sym, uint_32 *val ) -//Evaluate location expr to an offset off frame +/******************************************************************** + * Evaluate location expr to an offset off frame + */ { nop_loc_handle d; bool ret; @@ -1171,7 +1238,9 @@ bool EvalOffset( imp_image_handle *iih, drmem_hdl sym, uint_32 *val ) } bool EvalSeg( imp_image_handle *iih, drmem_hdl sym, addr_seg *val ) -//Evaluate location expr to an offset off frame +/****************************************************************** + * Evaluate location expr to an offset off frame + */ { nop_loc_handle d; bool ret; @@ -1194,7 +1263,9 @@ bool EvalSeg( imp_image_handle *iih, drmem_hdl sym, addr_seg *val ) } bool EvalSymOffset( imp_image_handle *iih, drmem_hdl sym, uint_32 *val ) -//Evaluate sym's map offset +/*********************************************************************** + * Evaluate sym's map offset + */ { nop_loc_handle d; bool ret; diff --git a/bld/dip/dwarf/c/dfmisc.c b/bld/dip/dwarf/c/dfmisc.c index ee30fec08c..b9e4037364 100644 --- a/bld/dip/dwarf/c/dfmisc.c +++ b/bld/dip/dwarf/c/dfmisc.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -40,16 +40,17 @@ /* - Misc. stuff. -*/ + * Misc. stuff. + */ char const DIPImp( Name )[] = "DWARF"; df_cleaner *Cleaners; static void CallCleaners( void ) -/******************************/ -//Call all stacked resource cleanup +/******************************* + * Call all stacked resource cleanup + */ { while( Cleaners != NULL ) { Cleaners->rtn( Cleaners->d ); @@ -58,11 +59,11 @@ static void CallCleaners( void ) } unsigned DIPIMPENTRY( HandleSize )( handle_kind hk ) +/*************************************************** + * Return the sizes of the individual handle types. This version + * should be OK as given. + */ { -/* - Return the sizes of the individual handle types. This version - should be OK as given. -*/ static unsigned_8 Sizes[] = { #define pick(enum,hsize,ihsize,wvihsize,cvdmndtype,wdmndtype) ihsize, #include "diphndls.h" @@ -94,11 +95,11 @@ void DFFreeImage( imp_image_handle *iih ) } dip_status DIPIMPENTRY( MoreMem )( size_t size ) +/*********************************************** + * Return DS_OK if you could release some memory, DS_FAIL if you + * couldn't. + */ { -/* - Return DS_OK if you could release some memory, DS_FAIL if you - couldn't. -*/ imp_image_handle *curr; dip_status ds; @@ -119,12 +120,12 @@ dip_status DIPIMPENTRY( MoreMem )( size_t size ) return( ds ); } -dip_status DIPImp( Startup )(void) +dip_status DIPImp( Startup )( void ) +/*********************************** + * Return DS_OK if startup initialization went OK, or a DS_ERR | DS_? + * constant if something went wrong. + */ { -/* - Return DS_OK if startup initialization went OK, or a DS_ERR | DS_? - constant if something went wrong. -*/ Cleaners = NULL; Images = NULL; DRInit(); @@ -132,19 +133,19 @@ dip_status DIPImp( Startup )(void) } void DIPIMPENTRY( Shutdown )( void ) +/*********************************** + * Shutting down and unloading. Last chance to free up stuff. + */ { -/* - Shutting down and unloading. Last chance to free up stuff. -*/ Images = NULL; DRFini(); } void DIPIMPENTRY( Cancel )( void ) +/********************************* + * The client is about to longjmp, and may bypass + * returns through the DIP. All handles remain valid though. + */ { -/* - The client is about to longjmp, and may bypass - returns through the DIP. All handles remain valid though. -*/ CallCleaners(); } diff --git a/bld/dip/dwarf/c/dfmod.c b/bld/dip/dwarf/c/dfmod.c index 3399533e74..c9b3c3bb50 100644 --- a/bld/dip/dwarf/c/dfmod.c +++ b/bld/dip/dwarf/c/dfmod.c @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -37,15 +38,17 @@ #include "dfaddr.h" #include "dfaddsym.h" -//NYI: should be OS && location sensitive +/* + * NYI: should be OS && location sensitive + */ #define IS_PATH_CHAR( c ) ((c)=='\\'||(c)=='/'||(c)==':') #define EXT_CHAR '.' #define MAX_PATH 256 static void GetModName( const char *path, char *buff ) -/****************************************************/ -/* find the module name from the path */ -/**********************************************/ +/***************************************************** + * find the module name from the path + */ { const char *start; const char *end; @@ -80,9 +83,10 @@ static void GetModName( const char *path, char *buff ) } static bool ModFill( void *_mod, drmem_hdl mod_handle ) -/*****************************************************/ -// fill in mod_handle for dip to dwarf mod map -// pick up general info about mod while here for later calls +/****************************************************** + * fill in mod_handle for dip to dwarf mod map + * pick up general info about mod while here for later calls + */ { mod_list *mod = _mod; char fname[MAX_PATH]; @@ -151,8 +155,9 @@ static bool ModFill( void *_mod, drmem_hdl mod_handle ) } dip_status InitModMap( imp_image_handle *iih ) -/************************************************/ -// Make the imp_mod_handle to drmem_hdl map +/************************************************* + * Make the imp_mod_handle to drmem_hdl map + */ { mod_list list; dip_status ds; @@ -179,8 +184,9 @@ dip_status InitModMap( imp_image_handle *iih ) } bool ClearMods( imp_image_handle *iih ) -/****************************************/ -// free any cached mem for modules +/***************************************** + * free any cached mem for modules + */ { im_idx i; bool ret; @@ -199,8 +205,9 @@ bool ClearMods( imp_image_handle *iih ) } void FiniModMap( imp_image_handle *iih ) -/*****************************************/ -// Make the imp_mod_handle to drmem_hdl map +/****************************************** + * Make the imp_mod_handle to drmem_hdl map + */ { im_idx i; mod_info *modinfo; @@ -220,8 +227,9 @@ void FiniModMap( imp_image_handle *iih ) } imp_mod_handle Dwarf2Mod( imp_image_handle *iih, drmem_hdl mod_handle ) -/***********************************************************************/ -// Look up mod_handle in mod_map +/************************************************************************ + * Look up mod_handle in mod_map + */ { im_idx i; mod_info *modinfo; @@ -237,8 +245,9 @@ imp_mod_handle Dwarf2Mod( imp_image_handle *iih, drmem_hdl mod_handle ) } imp_mod_handle DwarfMod( imp_image_handle *iih, drmem_hdl dr_sym ) -/******************************************************************/ -// find the imp_mod_handle where a dwarf dbginfo comes from +/******************************************************************* + * find the imp_mod_handle where a dwarf dbginfo comes from + */ { im_idx i; im_idx last; @@ -258,8 +267,9 @@ imp_mod_handle DwarfMod( imp_image_handle *iih, drmem_hdl dr_sym ) } imp_mod_handle CuTag2Mod( imp_image_handle *iih, drmem_hdl cu_tag ) -/*******************************************************************/ -// Look up cu_tag in mod_map +/******************************************************************** + * Look up cu_tag in mod_map + */ { im_idx i; mod_info *modinfo; @@ -483,11 +493,11 @@ address DIPIMPENTRY( ModAddr )( imp_image_handle *iih, imp_mod_handle imh ) } dip_status DIPIMPENTRY( ModInfo )( imp_image_handle *iih, imp_mod_handle imh, handle_kind hk ) +/********************************************************************************************* + * Return DS_OK if the module has the kind of information indicated + * by 'hk', DS_FAIL if it does not. + */ { - /* - Return DS_OK if the module has the kind of information indicated - by 'hk', DS_FAIL if it does not. - */ dip_status ds; drmem_hdl stmts; mod_info *modinfo; @@ -532,18 +542,21 @@ dip_status DIPIMPENTRY( ModInfo )( imp_image_handle *iih, imp_mod_handle imh, ha return( ds ); } -dip_status DIPIMPENTRY( ModDefault )( imp_image_handle *iih, imp_mod_handle imh, default_kind dk, dig_type_info *ti ) +dip_status DIPIMPENTRY( ModDefault )( imp_image_handle *iih, imp_mod_handle imh, + default_kind dk, dig_type_info *ti ) +/******************************************************************************* + * Return the default type information for indicated type. The + * client uses this to figure out how big a default 'int', code pointer, + * and data pointer should be. The information depends on whether + * the 16 or 32-bit compiler was used, and what memory model the + * source file was compiled with. + */ { - /* - Return the default type information for indicated type. The - client uses this to figure out how big a default 'int', code pointer, - and data pointer should be. The information depends on whether - the 16 or 32-bit compiler was used, and what memory model the - source file was compiled with. - */ mod_info *modinfo; -//TODO: finish + /* + * TODO: finish + */ modinfo = IMH2MODI( iih, imh ); ti->size = modinfo->addr_size; ti->deref = false; diff --git a/bld/dip/dwarf/c/dfmodbld.c b/bld/dip/dwarf/c/dfmodbld.c index 27c112bc42..0076de2540 100644 --- a/bld/dip/dwarf/c/dfmodbld.c +++ b/bld/dip/dwarf/c/dfmodbld.c @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -49,9 +50,10 @@ void InitModList( mod_list *list ) mod_info *NextModInfo( mod_list *list ) -/**************************************/ -// Get next mod info in list -// bump the item count +/*************************************** + * Get next mod info in list + * bump the item count + */ { mod_blk *blk; mod_info *next; @@ -73,9 +75,10 @@ mod_info *NextModInfo( mod_list *list ) } mod_info *FiniModInfo( mod_list *list ) -/**************************************/ -//Free all offset blocks for a line segment -//Free all line segments +/*************************************** + * Free all offset blocks for a line segment + * Free all line segments + */ { mod_info *new, *cpy; mod_blk *curr, *next; diff --git a/bld/dip/dwarf/c/dfscope.c b/bld/dip/dwarf/c/dfscope.c index 587a4b7cf5..716dd3318e 100644 --- a/bld/dip/dwarf/c/dfscope.c +++ b/bld/dip/dwarf/c/dfscope.c @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -38,7 +39,9 @@ scope_node *FindScope( scope_node *last, addr_off in ) -/***** find the down scope of start, len ************/ +/***************************************************** + * find the down scope of start, len + */ { scope_node *down; @@ -49,7 +52,9 @@ scope_node *FindScope( scope_node *last, addr_off in ) } last = last->down; } - /* climp up and across tree until you fall out */ + /* + * find the down scope of start, len climp up and across tree until you fall out + */ while( last != NULL ) { //look for containing down scope if( last->start <= in && in < last->end ) { down = last; // if containing go up the branch @@ -61,11 +66,16 @@ scope_node *FindScope( scope_node *last, addr_off in ) return( down ); } -static void FreeScope( scope_node *last ) { -/** find the down scope of start, len*****/ +static void FreeScope( scope_node *last ) +/**************************************** + * find the down scope of start, len + */ +{ scope_node *old; - /* climp up and across free across and down */ + /* + * climp up and across free across and down + */ while( last != NULL ) { //look for containing down scope if( last->up != NULL ) { old = last; @@ -75,7 +85,7 @@ static void FreeScope( scope_node *last ) { if( last->next != NULL ) { old = last; last = last->next; - }else{/* done this level */ + }else{ /* done this level */ old = last; last = last->down; } diff --git a/bld/dip/dwarf/c/dfsegs.c b/bld/dip/dwarf/c/dfsegs.c index efac4e726b..70e39bb5f0 100644 --- a/bld/dip/dwarf/c/dfsegs.c +++ b/bld/dip/dwarf/c/dfsegs.c @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -43,8 +44,9 @@ void InitSegList( seg_list *ctl, unsigned_16 item_size ) } void FiniSegList( seg_list *ctl ) -/*******************************/ -// Free segment blocks +/******************************** + * Free segment blocks + */ { seg_blk_head *blk, *next; @@ -182,8 +184,9 @@ static int BlkSegSearch( seg_cmp *cmp ) seg_entry *FindRealSeg( seg_list *ctl, addr_seg seg ) -/***************************************************/ -// Find real seg seg_entry +/**************************************************** + * Find real seg seg_entry + */ { seg_entry *info; seg_blk_head *blk; @@ -211,8 +214,9 @@ seg_entry *FindRealSeg( seg_list *ctl, addr_seg seg ) bool SegWalk( seg_list *ctl, SEGWLK wlk, void *d ) -/************************************************/ -// Walk all the segments with wlk( d, info ) +/************************************************* + * Walk all the segments with wlk( d, info ) + */ { seg_blk_head *blk; seg_entry *info; @@ -240,8 +244,9 @@ bool SegWalk( seg_list *ctl, SEGWLK wlk, void *d ) } static int SegCmp( void const *_seg1, void const *_seg2 ) -/********************************************************/ -//Compare segments +/********************************************************* + * Compare segments + */ { seg_entry const *seg1 = _seg1; seg_entry const *seg2 = _seg2; @@ -254,8 +259,9 @@ static int SegCmp( void const *_seg1, void const *_seg2 ) } void SortSegReal( seg_list *ctl ) -/**********************************/ -//Sort a seg's real address +/*********************************** + * Sort a seg's real address + */ { seg_blk_head *blk; unsigned_16 blk_count; diff --git a/bld/dip/dwarf/c/dfsym.c b/bld/dip/dwarf/c/dfsym.c index 0e2ba97a20..139b67b4f9 100644 --- a/bld/dip/dwarf/c/dfsym.c +++ b/bld/dip/dwarf/c/dfsym.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -51,42 +51,45 @@ imp_mod_handle DIPIMPENTRY( SymMod )( imp_image_handle *iih, imp_sym_handle *ish { /* unused parameters */ (void)iih; - /* Return the module that the implementation symbol handle comes from. */ + /* + * Return the module that the implementation symbol handle comes from. + */ return( ish->imh ); } size_t DIPIMPENTRY( SymName )( imp_image_handle *iih, imp_sym_handle *ish, location_context *lc, symbol_name_type snt, char *buff, size_t buff_size ) -/****************************************************************************/ +/***************************************************************************** + * SNT_SOURCE: + * The name of the symbol as it appears in the source code. + * + * SNT_OBJECT: + * The name of the symbol as it appeared to the linker. + * + * SNT_DEMANGLED: + * C++ names, with full typing (essentially it looks like + * a function prototype). If the symbol is not a C++ symbol + * (not mangled), return zero for the length. + * + * SNT_EXPRESSION: + * Return whatever character string is necessary such that + * when scanned in an expression, the symbol handle can + * be reconstructed. + * + * SNT_SCOPED: + * The scoped name of the symbol as it appears in the source code. + */ { - /* - SNT_SOURCE: - The name of the symbol as it appears in the source code. - - SNT_OBJECT: - The name of the symbol as it appeared to the linker. - - SNT_DEMANGLED: - C++ names, with full typing (essentially it looks like - a function prototype). If the symbol is not a C++ symbol - (not mangled), return zero for the length. - - SNT_EXPRESSION: - Return whatever character string is necessary such that - when scanned in an expression, the symbol handle can - be reconstructed. - - SNT_SCOPED: - The scoped name of the symbol as it appears in the source code. - */ char *name; size_t demangled_len; size_t len = 0; /* unused parameters */ (void)lc; -//TODO: what's lc for? + /* + * TODO: what's lc for? + */ DRSetDebug( iih->dwarf->handle ); /* must do at each call into dwarf */ switch( snt ) { case SNT_SOURCE: @@ -149,9 +152,10 @@ size_t DIPIMPENTRY( SymName )( imp_image_handle *iih, imp_sym_handle *ish, dip_status DIPIMPENTRY( SymType )( imp_image_handle *iih, imp_sym_handle *ish, imp_type_handle *ith ) -/*************************************************************/ +/************************************************************** + * Get the implementation type handle for the type of the given symbol. + */ { - /* Get the implementation type handle for the type of the given symbol. */ dip_status ds; DRSetDebug( iih->dwarf->handle ); /* must do at each call into DWARF */ @@ -196,9 +200,10 @@ struct mod_wlk { }; static bool AMod( drmem_hdl sym, void *_d, dr_search_context *cont ) -/******************************************************************/ +/******************************************************************* + * TODO: no segments, better TAG_label + */ { -//TODO: no segments, better TAG_label struct mod_wlk *d = _d; uint_32 offset; addr_seg seg; @@ -322,9 +327,10 @@ static addr_seg GetCodeSeg( imp_image_handle *iih ) dip_status DIPIMPENTRY( SymLocation )( imp_image_handle *iih, imp_sym_handle *ish, location_context *lc, location_list *ll ) -/****************************************************************************/ +/***************************************************************************** + * Get the location of the given symbol. + */ { - /* Get the location of the given symbol. */ dip_status ds; address base; /* base segment & offset */ addr_seg seg; @@ -423,20 +429,20 @@ dip_status DIPIMPENTRY( SymLocation )( imp_image_handle *iih, dip_status DIPIMPENTRY( SymValue )( imp_image_handle *iih, imp_sym_handle *ish, location_context *ic, void *buff ) -/*********************************************************************/ +/********************************************************************** + * Copy the value of a constant symbol into 'buff'. You can get the + * size required by doing a SymType followed by a TypeInfo. + */ { - uint_32 value; + uint_64 value; /* unused parameters */ (void)ic; - /* Copy the value of a constant symbol into 'buff'. You can get the - * size required by doing a SymType followed by a TypeInfo. - */ if( ish->sclass != SYM_ENUM ) { return( DS_FAIL ); } DRSetDebug( iih->dwarf->handle ); /* must do at each call into DWARF */ - if( !DRConstValAT( ish->sym, &value ) ) { + if( !DRConstValAT64( ish->sym, &value ) ) { return( DS_FAIL ); } switch( ish->f.einfo.size ) { @@ -449,6 +455,9 @@ dip_status DIPIMPENTRY( SymValue )( imp_image_handle *iih, case 4: *(uint_32 *)buff = value; break; + case 8: + *(uint_64 *)buff = value; + break; default: return( DS_FAIL ); } @@ -458,9 +467,10 @@ dip_status DIPIMPENTRY( SymValue )( imp_image_handle *iih, dip_status DIPIMPENTRY( SymInfo )( imp_image_handle *iih, imp_sym_handle *ish, location_context *lc, sym_info *si ) -/***********************************************************************/ +/************************************************************************ + * Get some generic information about a symbol. + */ { - /* Get some generic information about a symbol. */ uint_32 num1; uint_32 num2; dr_ptr addr_class; @@ -599,9 +609,10 @@ static bool ARet( drmem_hdl var, int index, void *_var_ptr ) drmem_hdl GetRet( imp_image_handle *iih, drmem_hdl proc ) -/*******************************************************/ +/******************************************************** + * Find handle of Watcom return symbol. + */ { - /* Find handle of Watcom return symbol. */ drmem_hdl ret = DRMEM_HDL_NULL; DRSetDebug( iih->dwarf->handle ); /* must do at each call into DWARF */ @@ -615,16 +626,17 @@ drmem_hdl GetRet( imp_image_handle *iih, drmem_hdl proc ) dip_status DIPIMPENTRY( SymParmLocation )( imp_image_handle *iih, imp_sym_handle *ish, location_context *lc, location_list *ll, unsigned n ) -/*******************************************************************/ +/******************************************************************* + * Get information about where a routine's parameters/return value + * are located. + * If the 'n' parameter is zero, fill in the location list structure + * pointed at by 'll' with the information on the location of the + * function's return value. Otherwise fill it in with the location + * of the n'th parameter. + * + * TODO: brian only wants regs for now + */ { - /* Get information about where a routine's parameters/return value - * are located. - * If the 'n' parameter is zero, fill in the location list structure - * pointed at by 'll' with the information on the location of the - * function's return value. Otherwise fill it in with the location - * of the n'th parameter. - */ -//TODO: brian only wants regs for now drmem_hdl parm; dip_status ds; @@ -671,9 +683,10 @@ static bool AThis( drmem_hdl var, int index, void *_var_ptr ) static drmem_hdl GetThis( imp_image_handle *iih, drmem_hdl proc ) -/***************************************************************/ +/**************************************************************** + * Return handle of the this parmeter. + */ { - /* Return handle of the this parmeter. */ drmem_hdl ret = DRMEM_HDL_NULL; DRSetDebug( iih->dwarf->handle ); /* must do at each call into DWARF */ @@ -686,14 +699,14 @@ static drmem_hdl GetThis( imp_image_handle *iih, drmem_hdl proc ) dip_status DIPIMPENTRY( SymObjType )( imp_image_handle *iih, imp_sym_handle *ish, imp_type_handle *ith, dig_type_info *ti ) -/********************************************************************************/ +/********************************************************************************* + * Fill in the imp_type_handle with the type of the 'this' object + * for a C++ member function. + * If 'ti' is not NULL, fill in the dig_type_info with the kind of 'this' + * pointer that the routine is expecting (near/far, 16/32). If the + * routine is a static member, set ti->kind to TK_NONE. + */ { - /* Fill in the imp_type_handle with the type of the 'this' object - * for a C++ member function. - * If 'ti' is not NULL, fill in the dig_type_info with the kind of 'this' - * pointer that the routine is expecting (near/far, 16/32). If the - * routine is a static member, set ti->kind to TK_NONE. - */ drmem_hdl dr_this; drmem_hdl dr_type; dr_typeinfo typeinfo; @@ -730,12 +743,12 @@ dip_status DIPIMPENTRY( SymObjType )( imp_image_handle *iih, dip_status DIPIMPENTRY( SymObjLocation )( imp_image_handle *iih, imp_sym_handle *ish, location_context *lc, location_list *ll ) -/***********************************************************************/ +/************************************************************************* + * Fill in the location list with the location of the '*this' object + * for a C++ member function. Return DS_FAIL if it's a static member + * function. + */ { - /* Fill in the location list with the location of the '*this' object - * for a C++ member function. Return DS_FAIL if it's a static member - * function. - */ drmem_hdl dr_this; drmem_hdl dr_type; dr_typeinfo typeinfo; @@ -814,13 +827,13 @@ dip_status DIPIMPENTRY( SymObjLocation )( imp_image_handle *iih, search_result DIPIMPENTRY( AddrSym )( imp_image_handle *iih, imp_mod_handle imh, address a, imp_sym_handle *ish ) -/**************************************************************************/ +/*************************************************************************** + * Search the given module for a symbol who's address is greater than + * or equal to 'addr'. If none is found return SR_NONE. If you find + * a symbol at that address exactly, fill in '*ish' and return SR_EXACT. + * Otherwise, fill in '*ish' and return SR_CLOSEST. + */ { - /* Search the given module for a symbol who's address is greater than - * or equal to 'addr'. If none is found return SR_NONE. If you find - * a symbol at that address exactly, fill in '*ish' and return SR_EXACT. - * Otherwise, fill in '*ish' and return SR_CLOSEST. - */ addrsym_info info; search_result ret; seg_list *addr_sym; @@ -847,9 +860,9 @@ search_result DIPIMPENTRY( AddrSym )( imp_image_handle *iih, return( ret ); } -/**********************************/ -/* Walk inner and outer blocks */ -/*********************************/ +/********************************* + * Walk inner and outer blocks * + *********************************/ static bool InBlk( drmem_hdl blk, int depth, void *_ctl ) /*******************************************************/ @@ -937,37 +950,37 @@ static search_result DFAddrScope( imp_image_handle *iih, search_result DIPIMPENTRY( AddrScope )( imp_image_handle *iih, imp_mod_handle imh, address addr, scope_block *scope ) -/********************************************************************/ +/********************************************************************* + * Find the range of the lexical scope block enclosing 'addr' in + * module 'imh'. If there is no such scope, return SR_NONE. Otherwise + * fill in scope->start with the address of the start of the lexical + * block and scope->len with the size of the block. Fill in + * scope->unique with something that uniquely identifies the lexical + * block in question. This is used to disamibiguate between blocks + * that start at the same address and have the same length. The value + * should be chosen so that + * 1. It remains valid and consistant across a DIPUnloadInfo + * and DIPLoadInfo of the same information. + * 2. It remains the same whether the scope_block was obtained + * by DIPImpAddrScope or DIPImpScopeOuter. + * Then return SR_EXACT/SR_CLOSEST as appropriate. + */ { - /* Find the range of the lexical scope block enclosing 'addr' in - * module 'imh'. If there is no such scope, return SR_NONE. Otherwise - * fill in scope->start with the address of the start of the lexical - * block and scope->len with the size of the block. Fill in - * scope->unique with something that uniquely identifies the lexical - * block in question. This is used to disamibiguate between blocks - * that start at the same address and have the same length. The value - * should be chosen so that - * 1. It remains valid and consistant across a DIPUnloadInfo - * and DIPLoadInfo of the same information. - * 2. It remains the same whether the scope_block was obtained - * by DIPImpAddrScope or DIPImpScopeOuter. - * Then return SR_EXACT/SR_CLOSEST as appropriate. - */ return( DFAddrScope( iih, imh, addr, scope ) ); } static search_result DFScopeOuter( imp_image_handle *iih, imp_mod_handle imh, scope_block *in, scope_block *out ) -/*********************************************************************/ +/********************************************************************** + * Given the scope_block pointed to by 'in' in the module 'imh', find + * the parent lexical block of it and fill in the scope_block pointed + * to by 'out' with the information. Return SR_EXACT/SR_CLOSEST as + * appropriate. Return SR_NONE if there is no parent block. + * Make sure that the case where 'in' and 'out' point to the same + * address is handled. + */ { - /* Given the scope_block pointed to by 'in' in the module 'imh', find - * the parent lexical block of it and fill in the scope_block pointed - * to by 'out' with the information. Return SR_EXACT/SR_CLOSEST as - * appropriate. Return SR_NONE if there is no parent block. - * Make sure that the case where 'in' and 'out' point to the same - * address is handled. - */ drmem_hdl what; search_result ret; address addr; @@ -1072,9 +1085,9 @@ search_result DIPIMPENTRY( ScopeOuter )( imp_image_handle *iih, return( ret ); } -/**********************************************/ -/* Walk or Search various scopes for symbols */ -/**********************************************/ +/********************************************** + * Walk or Search various scopes for symbols * + **********************************************/ typedef struct { imp_mod_handle imh; @@ -1231,9 +1244,12 @@ static bool ASymLookup( drmem_hdl var, int index, void *_df ) len = DRGetNameBuff( var, df->buff, df->len ); if( len == df->len && df->scompn( df->buff, df->li->name.start, df->li->name.len ) == 0 ) { - /* Found symbol by name */ + /* + * Found symbol by name + */ if( !DRIsFunc( var ) && !DRIsStatic( var ) && !DRIsSymDefined( var ) ) { - /* If symbol is a global variable declaration, ignore it; it + /* + * If symbol is a global variable declaration, ignore it; it * won't have location information and will likely be found in * another module. */ @@ -1296,11 +1312,11 @@ static bool WalkModSymList( blk_wlk *df, DRWLKBLK fn, imp_mod_handle imh ) static bool WalkScopedSymList( blk_wlk *df, DRWLKBLK fn, address *addr ) -/**********************************************************************/ +/*********************************************************************** + * Walk inner to outer function scopes, then containing class + * if present, then module scope. + */ { - /* Walk inner to outer function scopes, then containing class - * if present, then module scope. - */ imp_image_handle *iih; scope_block scope; drmem_hdl cu_tag; @@ -1574,11 +1590,11 @@ typedef struct { } strvo; static unsigned StrVCopy( strvo *dst, strvi *src ) -/************************************************/ +/************************************************* + * Copy source until null char or source runs out + * to dest until it runs out, return total length of source + */ { - /* Copy source until null char or source runs out - * to dest until it runs out, return total length of source - */ unsigned total; total = src->len; @@ -1690,7 +1706,9 @@ static search_result DoLookupSym( imp_image_handle *iih, symbol_source ss, void return( SR_EXACT ); } if( li->type == ST_OPERATOR ) { -//TODO this operator + /* + * TODO this operator + */ // src = li->name.start; // len = li->name.len; return( SR_NONE ); @@ -1779,20 +1797,20 @@ search_result DIPIMPENTRY( LookupSymEx )( imp_image_handle *iih, int DIPIMPENTRY( SymCmp )( imp_image_handle *iih, imp_sym_handle *ish1, imp_sym_handle *ish2 ) -/********************************************************************************************/ +/********************************************************************************************* + * Compare two sym handles and return 0 if they refer to the same + * information. If they refer to differnt things return either a + * positive or negative value to impose an 'order' on the information. + * The value should obey the following constraints. + * Given three handles H1, H2, H3: + * - if H1 < H2 then H1 is always < H2 + * - if H1 < H2 and H2 < H3 then H1 is < H3 + * The reason for the constraints is so that a client can sort a + * list of handles and binary search them. + */ { /* unused parameters */ (void)iih; - /* Compare two sym handles and return 0 if they refer to the same - * information. If they refer to differnt things return either a - * positive or negative value to impose an 'order' on the information. - * The value should obey the following constraints. - * Given three handles H1, H2, H3: - * - if H1 < H2 then H1 is always < H2 - * - if H1 < H2 and H2 < H3 then H1 is < H3 - * The reason for the constraints is so that a client can sort a - * list of handles and binary search them. - */ if( ish1->sym < ish2->sym ) return( -1 ); if( ish1->sym > ish2->sym ) diff --git a/bld/dip/dwarf/c/dftype.c b/bld/dip/dwarf/c/dftype.c index 64b275edba..bbe4c488d8 100644 --- a/bld/dip/dwarf/c/dftype.c +++ b/bld/dip/dwarf/c/dftype.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -132,9 +132,9 @@ static bool GetStrLen( imp_image_handle *iih, return( true ); } -/***********************/ -/* Walk array dims */ -/***********************/ +/*********************** + * Walk array dims * + ***********************/ typedef struct { dig_type_bound low; dig_type_size count; @@ -229,9 +229,10 @@ static void GetArraySubSize( imp_image_handle *iih, static void InitTypeHandle( imp_image_handle *iih, imp_type_handle *ith, location_context *lc ) -/***********************************************************************/ -//Set type handle to the base state -//If array poise at first index +/************************************************* + * Set type handle to the base state + * If array poise at first index + */ { imp_type_handle sub_ith; dr_array_info info; @@ -364,20 +365,20 @@ walk_result DIPIMPENTRY( WalkTypeList )( imp_image_handle *iih, imp_mod_handle i } imp_mod_handle DIPIMPENTRY( TypeMod )( imp_image_handle *iih, imp_type_handle *ith ) +/*********************************************************************************** + * Return the module that the type handle comes from. + */ { /* unused parameters */ (void)iih; - /* - Return the module that the type handle comes from. - */ return( ith->imh ); } void MapImpTypeInfo( dr_typeinfo *typeinfo, dig_type_info *ti ) +/************************************************************** + * Map dwarf info to dip imp + */ { - /* - Map dwarf info to dip imp - */ type_kind kind; switch( typeinfo->kind ) { @@ -478,13 +479,12 @@ void MapImpTypeInfo( dr_typeinfo *typeinfo, dig_type_info *ti ) dip_status DIPIMPENTRY( TypeInfo )( imp_image_handle *iih, imp_type_handle *ith, location_context *lc, dig_type_info *ti ) +/****************************************************************************** + * Fill in the type information for the type handle. The location + * context is being passed in because it might be needed to calculate + * the size of the type (variable dimensioned arrays and the like). + */ { - /* - Fill in the type information for the type handle. The location - context is being passed in because it might be needed to calculate - the size of the type (variable dimensioned arrays and the like). - */ - InitTypeHandle( iih, ith, lc ); MapImpTypeInfo( &ith->typeinfo, ti ); if( ti->kind == TK_INTEGER ) { // this can be removed when 10.5 gets updated @@ -505,15 +505,15 @@ dip_status DIPIMPENTRY( TypeInfo )( imp_image_handle *iih, dip_status DIPIMPENTRY( TypeBase )( imp_image_handle *iih, imp_type_handle *ith, imp_type_handle *base_ith, location_context *lc, location_list *ll ) +/*********************************************************************** + * Given an implementation type handle, fill in 'base' with the + * base type of the handle. + */ { drmem_hdl btype; /* unused parameters */ (void)lc; (void)ll; - /* - Given an implementation type handle, fill in 'base' with the - base type of the handle. - */ if( base_ith != ith ) { *base_ith = *ith; } @@ -538,18 +538,18 @@ dip_status DIPIMPENTRY( TypeBase )( imp_image_handle *iih, } typedef struct { - int_32 low; - int_32 high; + int_64 low; + int_64 high; } enum_range; static bool AEnum( drmem_hdl var, int index, void *_de ) { enum_range *de = _de; - int_32 value; + int_64 value; /* unused parameters */ (void)index; - if( !DRConstValAT( var, (uint_32 *)&value ) ) { + if( !DRConstValAT64( var, (uint_64 *)&value ) ) { return( false ); } if( value < de->low ) { @@ -561,23 +561,25 @@ static bool AEnum( drmem_hdl var, int index, void *_de ) } static bool ArrayEnumType( drmem_hdl tenu, int index, void *_df ) -/****************************************************************/ -// Find low, high bounds of enum +/**************************************************************** + * Find low, high bounds of enum + * + * TODO:unsigned range + */ { -//TODO:unsigned range array_wlk_wlk *df = _df; enum_range de; - int_32 count; + int_64 count; /* unused parameters */ (void)index; - de.low = _I32_MIN; - de.high = _I32_MAX; + de.low = _I64_MIN; + de.high = _I64_MAX; if( !DRWalkEnum( tenu, AEnum, &de ) ) { return( false ); } df->low = de.low; - count = de.high-de.low+1; + count = de.high - de.low + 1; df->count *= count; df->dim++; @@ -623,8 +625,9 @@ static bool GetSymVal( imp_image_handle *iih, } static bool GetDrVal( array_wlk_wlk *df, dr_val32 *val, int_32 *ret ) -/*******************************************************************/ -// extract the value from val +/******************************************************************** + * extract the value from val + */ { switch( val->val_class ) { case DR_VAL_INT: @@ -652,12 +655,15 @@ static bool ArraySubRange( drmem_hdl tsub, int index, void *_df ) /* unused parameters */ (void)index; DRGetSubrangeInfo( tsub, &info ); - /* DWARF 2.0 specifies lower bound defaults for C/C++ (0) and FORTRAN (1) */ + /* + * DWARF 2.0 specifies lower bound defaults for C/C++ (0) and FORTRAN (1) + */ if( info.low.val_class == DR_VAL_NOT ) { - if( IMH2MODI( df->iih, df->ith->imh )->lang == DR_LANG_FORTRAN ) + if( IMH2MODI( df->iih, df->ith->imh )->lang == DR_LANG_FORTRAN ) { low = 1; - else + } else { low = 0; + } } else { GetDrVal( df, &info.low, &low ); } @@ -666,8 +672,8 @@ static bool ArraySubRange( drmem_hdl tsub, int index, void *_df ) return( false ); } GetDrVal( df, &info.high, &high ); - count = high - low +1; - }else{ + count = high - low + 1; + } else { GetDrVal( df, &info.count, &count ); } df->low = low; @@ -679,15 +685,14 @@ static bool ArraySubRange( drmem_hdl tsub, int index, void *_df ) dip_status DIPIMPENTRY( TypeArrayInfo )( imp_image_handle *iih, imp_type_handle *array_ith, location_context *lc, array_info *ai, imp_type_handle *index_ith ) +/************************************************************************ + * Given an implemenation type handle that represents an array type, + * get information about the array shape and index type. The location + * context is for variable dimensioned arrays again. The 'index' + * parameter is filled in with the type of variable used to subscript + * the array. It may be NULL, in which case no information is returned. + */ { - /* - Given an implemenation type handle that represents an array type, - get information about the array shape and index type. The location - context is for variable dimensioned arrays again. The 'index' - parameter is filled in with the type of variable used to subscript - the array. It may be NULL, in which case no information is returned. - */ - DRSetDebug( iih->dwarf->handle ); /* must do at each call into dwarf */ if( array_ith->state == DF_NOT ) { InitTypeHandle( iih, array_ith, lc ); @@ -722,12 +727,12 @@ dip_status DIPIMPENTRY( TypeArrayInfo )( imp_image_handle *iih, } /* - Given an implementation type handle that represents a procedure type, - get information about the return and parameter types. If the 'n' - parameter is zero, store the return type handle into the 'parm' - variable. Otherwise store the handle for the n'th parameter in - 'parm'. -*/ + * Given an implementation type handle that represents a procedure type, + * get information about the return and parameter types. If the 'n' + * parameter is zero, store the return type handle into the 'parm' + * variable. Otherwise store the handle for the n'th parameter in + * 'parm'. + */ typedef struct { int count; int last; @@ -751,8 +756,9 @@ static bool AParm( drmem_hdl var, int index, void *_df ) } drmem_hdl GetParmN( imp_image_handle *iih, drmem_hdl proc, int count ) -/********************************************************************/ -// return handle of the n parm +/********************************************************************* + * return handle of the n parm + */ { parm_wlk df; drmem_hdl ret; @@ -769,8 +775,9 @@ drmem_hdl GetParmN( imp_image_handle *iih, drmem_hdl proc, int count ) } int GetParmCount( imp_image_handle *iih, drmem_hdl proc ) -/*******************************************************/ -// return handle of the n parm +/******************************************************** + * return handle of the n parm + */ { parm_wlk df; @@ -809,14 +816,14 @@ dip_status DIPIMPENTRY( TypeProcInfo )( imp_image_handle *iih, dip_status DIPIMPENTRY( TypePtrAddrSpace )( imp_image_handle *iih, imp_type_handle *ith, location_context *lc, address *a ) +/*************************************************************************** + * Given an implementation type handle that represents a pointer type, + * get information about any implied address space for that pointer + * (based pointer cruft). If there is an implied address space for + * the pointer, fill in *a with the information and return DS_OK. + * Otherwise return DS_FAIL. + */ { - /* - Given an implementation type handle that represents a pointer type, - get information about any implied address space for that pointer - (based pointer cruft). If there is an implied address space for - the pointer, fill in *a with the information and return DS_OK. - Otherwise return DS_FAIL. - */ dip_status ds; ds = EvalBasedPtr( iih, lc, ith->type, a ); @@ -834,9 +841,10 @@ int DIPIMPENTRY( TypeCmp )( imp_image_handle *iih, imp_type_handle *ith1, imp_ty return( 1 ); return( 0 ); } -/*****************************/ -/* Structure Enum Walks */ -/*****************************/ + +/***************************** + * Structure Enum Walks * + *****************************/ typedef struct inh_vbase { struct inh_vbase *next; drmem_hdl base; @@ -876,8 +884,9 @@ typedef union { static bool AddBase( drmem_hdl base, inh_vbase **lnk ) -/****************************************************/ -//if base not in list add return false +/***************************************************** + * if base not in list add return false + */ { inh_vbase *cur; @@ -898,8 +907,9 @@ static bool AddBase( drmem_hdl base, inh_vbase **lnk ) } static bool FreeBases( void *_lnk ) -/*********************************/ -//Free bases +/********************************** + * Free bases + */ { inh_vbase **lnk = _lnk; inh_vbase *cur; @@ -977,9 +987,10 @@ static bool AMem( drmem_hdl var, int index, void *_d ) } static bool AInherit( drmem_hdl inh, int index, void *_d ) -/********************************************************/ +/********************************************************* + * TODO: Need to track virtual base as not to visit same place twice + */ { -//TODO: Need to track virtual base as not to visit same place twice type_wlk_wlk *d = _d; bool cont; drmem_hdl btype; @@ -1075,8 +1086,9 @@ static bool AMemLookup( drmem_hdl var, int index, void *_d ) } static bool AInheritLookup( drmem_hdl inh, int index, void *_d ) -/**************************************************************/ -//Push inherit handle and search +/*************************************************************** + * Push inherit handle and search + */ { type_wlk_lookup *d = _d; drmem_hdl btype; @@ -1200,7 +1212,9 @@ walk_result WalkTypeSymList( imp_image_handle *iih, imp_type_handle *ith, } search_result SearchMbr( imp_image_handle *iih, imp_type_handle *ith, lookup_item *li, void *d ) -//Search for matching lookup item +/*********************************************************************************************** + * Search for matching lookup item + */ { drmem_hdl btype; type_wlk_lookup df; @@ -1250,13 +1264,14 @@ search_result SearchMbr( imp_image_handle *iih, imp_type_handle *ith, lookup_ite Cleaners = cleanup.prev; // pop cleanup return( df.sr ); } -/*********************************************/ -/* Search for a derived type then eval loc */ -/*********************************************/ + +/********************************************* + * Search for a derived type then eval loc * + *********************************************/ typedef struct inh_path { struct inh_path *next; drmem_hdl inh; -}inh_path; +} inh_path; typedef struct type_wlk_inherit { imp_image_handle *iih; @@ -1281,8 +1296,9 @@ static DRWLKBLK InheritWlk[DR_WLKBLK_STRUCT] = { static bool AInhFind( drmem_hdl inh, int index, void *_df ) -/*********************************************************/ -//Push inherit handle and search +/********************************************************** + * Push inherit handle and search + */ { type_wlk_inherit *df = _df; drmem_hdl dr_derived; @@ -1334,42 +1350,42 @@ dip_status DFBaseAdjust( imp_image_handle *iih, drmem_hdl base, drmem_hdl deriv dip_status DIPIMPENTRY( TypeThunkAdjust )( imp_image_handle *iih, imp_type_handle *base_ith, imp_type_handle *derived_ith, location_context *lc, address *addr ) +/******************************************************************************* + * When you convert a pointer to a C++ class to a pointer at one + * of its derived classes you have to adjust the pointer so that + * it points at the start of the derived class. The 'derived' type + * may not actually be a derived type of 'base'. In that case, return + * DS_FAIL and nothing to 'addr'. If it is a derived type, let 'disp' + * be the displacement between the 'base' type and the 'derived' type. + * You need to do the following. "addr->mach.offset += disp;". + */ { - /* - When you convert a pointer to a C++ class to a pointer at one - of its derived classes you have to adjust the pointer so that - it points at the start of the derived class. The 'derived' type - may not actually be a derived type of 'base'. In that case, return - DS_FAIL and nothing to 'addr'. If it is a derived type, let 'disp' - be the displacement between the 'base' type and the 'derived' type. - You need to do the following. "addr->mach.offset += disp;". - */ return( DFBaseAdjust( iih, base_ith->type, derived_ith->type, lc, addr ) ); } size_t DIPIMPENTRY( TypeName )( imp_image_handle *iih, imp_type_handle *ith, unsigned num, symbol_type *tag, char *buff, size_t buff_size ) +/***************************************************************************** + * Given the imp_type_handle, copy the name of the type into 'buff'. + * Do not copy more than 'buff_size' - 1 characters into the buffer and + * append a trailing '\0' character. Return the real length + * of the type name (not including the trailing '\0' character) even + * if you had to truncate it to fit it into the buffer. If something + * went wrong and you can't get the type name, call DCStatus and + * return zero. NOTE: the client might pass in zero for 'buff_size'. In that + * case, just return the length of the module name and do not attempt + * to put anything into the buffer. + * + * Since there can be a "string" of typedef names associated with + * a type_handle, the 'num' parm indicates which one of the names + * the client wants returned. Zero is the first type name, one is + * the second, etc. Fill in '*tag' with ST_ENUM_TAG, ST_UNION_TAG, + * ST_STRUCT_TAG, ST_CLASS_TAG if the name is a enum, union, struct, + * or class tag name respectively. If not, set '*tag' to ST_NONE. + * + * If the type does not have a name, return zero. + */ { - /* - Given the imp_type_handle, copy the name of the type into 'buff'. - Do not copy more than 'buff_size' - 1 characters into the buffer and - append a trailing '\0' character. Return the real length - of the type name (not including the trailing '\0' character) even - if you had to truncate it to fit it into the buffer. If something - went wrong and you can't get the type name, call DCStatus and - return zero. NOTE: the client might pass in zero for 'buff_size'. In that - case, just return the length of the module name and do not attempt - to put anything into the buffer. - - Since there can be a "string" of typedef names associated with - a type_handle, the 'num' parm indicates which one of the names - the client wants returned. Zero is the first type name, one is - the second, etc. Fill in '*tag' with ST_ENUM_TAG, ST_UNION_TAG, - ST_STRUCT_TAG, ST_CLASS_TAG if the name is a enum, union, struct, - or class tag name respectively. If not, set '*tag' to ST_NONE. - - If the type does not have a name, return zero. - */ char *name = NULL; drmem_hdl dr_type; dr_typeinfo typeinfo; diff --git a/bld/dip/dwarf/c/stub.c b/bld/dip/dwarf/c/stub.c index fde53cf561..9a9c63eef7 100644 --- a/bld/dip/dwarf/c/stub.c +++ b/bld/dip/dwarf/c/stub.c @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -48,7 +49,9 @@ void __FPE_exception( void ); void __FPE_exception( void ) {}; #endif -/* WD looks for this symbol to determine module bitness */ +/* + * WD looks for this symbol to determine module bitness + */ #if !defined( __NT__ ) int __nullarea; #pragma aux __nullarea "*"; diff --git a/bld/dip/dwarf/h/dfdip.h b/bld/dip/dwarf/h/dfdip.h index b202f13374..ecf9a35137 100644 --- a/bld/dip/dwarf/h/dfdip.h +++ b/bld/dip/dwarf/h/dfdip.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -80,7 +81,9 @@ typedef struct { } mem_minfo; struct imp_sym_handle { - /* any stuff for getting information on symbols */ + /* + * any stuff for getting information on symbols + */ sym_sclass sclass; imp_mod_handle imh; unsigned size; @@ -110,7 +113,9 @@ typedef struct { struct imp_type_handle { - /* any stuff for getting information on types */ + /* + * any stuff for getting information on types + */ imp_mod_handle imh; drmem_hdl type; dr_typeinfo typeinfo; @@ -120,7 +125,9 @@ struct imp_type_handle { }; struct imp_cue_handle { - /* any stuff for getting information on source line cues */ + /* + * any stuff for getting information on source line cues + */ imp_mod_handle imh; address a; uint_16 fno; @@ -128,11 +135,12 @@ struct imp_cue_handle { uint_16 col; }; -/* Remember that that imp_[sym/type/cue]_handle's may be freely copied and - destroyed by clients. No pointers to allocated memory unless there's - another pointer somewhere else to free that memory. Clients don't have - tell you how long they're hanging on to a handle either. Nasty bunch. */ - +/* + * Remember that that imp_[sym/type/cue]_handle's may be freely copied and + * destroyed by clients. No pointers to allocated memory unless there's + * another pointer somewhere else to free that memory. Clients don't have + * tell you how long they're hanging on to a handle either. Nasty bunch. + */ typedef struct dwarf_info dwarf_info; // private type typedef struct mod_info mod_info; // private type diff --git a/bld/dip/dwarf/h/dfmodinf.h b/bld/dip/dwarf/h/dfmodinf.h index 7a435a0ac9..3e2f498900 100644 --- a/bld/dip/dwarf/h/dfmodinf.h +++ b/bld/dip/dwarf/h/dfmodinf.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -30,7 +31,9 @@ ****************************************************************************/ -/* mod info definition */ +/* + * mod info definition + */ struct mod_info { seg_list addr_sym[1]; drmem_hdl mod_handle; diff --git a/bld/dip/export/c/expcue.c b/bld/dip/export/c/expcue.c index 7945be6faf..12ca906ca4 100644 --- a/bld/dip/export/c/expcue.c +++ b/bld/dip/export/c/expcue.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2018 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -34,8 +34,8 @@ #include "exp.h" /* - Stuff for source line cues -*/ + * Stuff for source line cues + */ walk_result DIPIMPENTRY( WalkFileList )( imp_image_handle *iih, imp_mod_handle imh, DIP_IMP_CUE_WALKER *wk, imp_cue_handle *icueh, void *d ) diff --git a/bld/dip/export/c/expld.c b/bld/dip/export/c/expld.c index f799536f1e..be09330c67 100644 --- a/bld/dip/export/c/expld.c +++ b/bld/dip/export/c/expld.c @@ -42,11 +42,11 @@ #if defined( __WATCOMC__ ) && defined( __386__ ) - -/* WD looks for this symbol to determine module bitness */ +/* + * WD looks for this symbol to determine module bitness + */ int __nullarea; #pragma aux __nullarea "*"; - #endif static struct { @@ -264,7 +264,9 @@ static dip_status ProcTable( FILE *fp, imp_image_handle *iih, unsigned resident return( ds ); } } else if( ord != 0 ) { - /* this is putting in entry number, we'll get real addr later */ + /* + * this is putting in entry number, we'll get real addr later + */ ds = AddSymbol( iih, 0, ord, len, buff ); if( ds != DS_OK ) { return( ds ); @@ -318,7 +320,9 @@ static dip_status TryNE( FILE *fp, imp_image_handle *iih, unsigned_32 ne_header_ return( ds ); } } - /* change all the symbol addresses from entry numbers to seg/offsets */ + /* + * change all the symbol addresses from entry numbers to seg/offsets + */ if( BSeek( fp, ne_header_off + nehdr.entry_off, DIG_SEEK_ORG ) != ne_header_off + nehdr.entry_off ) { return( DS_ERR | DS_FSEEK_FAILED ); } @@ -408,7 +412,9 @@ static dip_status TryLX( FILE *fp, imp_image_handle *iih, unsigned_32 ne_header_ return( ds ); } } - /* change all the symbol addresses from entry numbers to seg/offsets */ + /* + * change all the symbol addresses from entry numbers to seg/offsets + */ if( BSeek( fp, ne_header_off + lxhdr.entry_off, DIG_SEEK_ORG ) != ne_header_off + lxhdr.entry_off ) { return( DS_ERR | DS_FSEEK_FAILED ); } @@ -447,7 +453,9 @@ static dip_status TryLX( FILE *fp, imp_image_handle *iih, unsigned_32 ne_header_ if( BRead( fp, &entry.fwd, sizeof( entry.fwd ) ) != sizeof( entry.fwd ) ) { return( DS_ERR | DS_FREAD_FAILED ); } - /* don't know how to handle these */ + /* + * don't know how to handle these + */ entry.fwd.e32_flags &= ~ENTRY_EXPORTED; break; } @@ -514,7 +522,9 @@ static char *PECacheName( pe_export_info *exp, unsigned long rva ) if( rva < exp->cache_name_rva || rva >= exp->cache_name_rva + exp->cache_name_len || memchr( &exp->name_cache[off], '\0', exp->cache_name_len - off ) == NULL ) { - /* Name is not fully in the cache. Have to read it in. */ + /* + * Name is not fully in the cache. Have to read it in. + */ exp->cache_name_rva = rva; exp->cache_name_len = PE_DIRECTORY( *(exp->pehdr), PE_TBL_EXPORT ).rva + PE_DIRECTORY( *(exp->pehdr), PE_TBL_EXPORT ).size - rva; @@ -530,7 +540,9 @@ static char *PECacheName( pe_export_info *exp, unsigned long rva ) DCStatus( DS_ERR | DS_FREAD_FAILED ); return( NULL ); } - /* Assuming a single name is < NAME_CACHE_SIZE */ + /* + * Assuming a single name is < NAME_CACHE_SIZE + */ off = 0; } return( (char *)&exp->name_cache[off] ); @@ -563,15 +575,21 @@ static dip_status PEExportBlock( imp_image_handle *iih, pe_export_info *exp, uns export_rva = PE_DIRECTORY( *(exp->pehdr), PE_TBL_EXPORT ).rva; export_size = PE_DIRECTORY( *(exp->pehdr), PE_TBL_EXPORT ).size; for( i = 0; i < num; ++i ) { - /* MS document lies about bias in export ordinal table! */ + /* + * MS document lies about bias in export ordinal table! + */ exp_rva = exp->eat[exp->ords[i] /*- dir->ordinal_base*/]; if( exp_rva < export_rva || exp_rva >= ( export_rva + export_size ) ) { - /* not a forwarder entry */ + /* + * not a forwarder entry + */ for( j = 0; j < num_objects; ++j ) { if( exp_rva >= exp->obj[j].rva && exp_rva < (exp->obj[j].rva + ObjSize( &exp->obj[j] )) ) { - /* found the object */ + /* + * found the object + */ name = PECacheName( exp, exp->name_ptrs[i] ); if( name == NULL ) { return( DS_ERR | DS_FAIL ); @@ -710,14 +728,20 @@ static dip_status TryStub( FILE *fp, imp_image_handle *iih ) } switch( signature ) { case EXESIGN_NE: - /* Hey, it's an NE executable */ + /* + * Hey, it's an NE executable + */ return( TryNE( fp, iih, ne_header_off ) ); case EXESIGN_LE: case EXESIGN_LX: - /* Hey, it's an LX/LE executable */ + /* + * Hey, it's an LX/LE executable + */ return( TryLX( fp, iih, ne_header_off ) ); default: - /* Hey, it can be a PE executable (or Pharlap's variant of it) */ + /* + * Hey, it can be a PE executable (or Pharlap's variant of it) + */ return( TryPE( fp, iih, ne_header_off ) ); } } @@ -746,7 +770,9 @@ static dip_status TryNLM( FILE *fp, imp_image_handle *iih ) return( DS_FAIL ); } if( nlmhdr.version > NLM_VERSION ) { - /* one of those funky packed NLM's */ + /* + * one of those funky packed NLM's + */ return( DS_FAIL ); } ds = AddName( iih, nlmhdr.moduleName[0], &nlmhdr.moduleName[1] ); @@ -766,7 +792,9 @@ static dip_status TryNLM( FILE *fp, imp_image_handle *iih ) } } if( nlmhdr.numberOfDebugRecords != 0 ) { - /* use the Novell style debugging information */ + /* + * use the Novell style debugging information + */ if( BSeek( fp, nlmhdr.debugInfoOffset, DIG_SEEK_ORG ) != nlmhdr.debugInfoOffset ) { return( DS_ERR | DS_FSEEK_FAILED ); } @@ -914,7 +942,9 @@ static dip_status TryELF( FILE *fp, imp_image_handle *iih ) if( elfhdr.e_phoff == 0 || elfhdr.e_shoff == 0 ) { return( DS_FAIL ); } - /* Add address blocks */ + /* + * Add address blocks + */ off = elfhdr.e_phoff; i = 0; for( i = 0; i < elfhdr.e_phnum; ++i ) { @@ -940,7 +970,9 @@ static dip_status TryELF( FILE *fp, imp_image_handle *iih ) } off += elfhdr.e_phentsize; } - /* Add Symbols */ + /* + * Add Symbols + */ sect = walloca( elfhdr.e_shnum * sizeof( *sect ) ); off = elfhdr.e_shoff; for( i = 0; i < elfhdr.e_shnum; ++i ) { @@ -954,7 +986,9 @@ static dip_status TryELF( FILE *fp, imp_image_handle *iih ) off += elfhdr.e_shentsize; } - /* If there is a SHT_SYMTAB section use that, otherwise SHT_DYNSYM */ + /* + * If there is a SHT_SYMTAB section use that, otherwise SHT_DYNSYM + */ tab_type = SHT_NULL; for( i = 1; i < elfhdr.e_shnum; ++i ) { switch( sect[i].sh_type ) { @@ -968,7 +1002,9 @@ static dip_status TryELF( FILE *fp, imp_image_handle *iih ) } } if( tab_type == SHT_NULL ) { - /* We didn't find any symbol tables - must be stripped */ + /* + * We didn't find any symbol tables - must be stripped + */ ImpUnloadInfo( iih ); return( DS_FAIL ); } @@ -1011,7 +1047,9 @@ static dip_status TryELF( FILE *fp, imp_image_handle *iih ) ds = DS_OK; switch( ELF32_ST_TYPE( sym.st_info ) ) { case STT_FILE: - /* Make first filename we see be the module name */ + /* + * Make first filename we see be the module name + */ if( iih->name == NULL ) { ds = AddName( iih, len, name ); } @@ -1020,7 +1058,8 @@ static dip_status TryELF( FILE *fp, imp_image_handle *iih ) if( sym.st_shndx < elfhdr.e_shnum ) { addr_seg seg; - /* Take a guess: If pointing to an executable section, + /* + * Take a guess: If pointing to an executable section, * symbol is probably code. */ if( sect[sym.st_shndx].sh_flags & SHF_EXECINSTR ) @@ -1051,12 +1090,16 @@ static dip_status TryELF( FILE *fp, imp_image_handle *iih ) } DCFree( strings ); if( iih->gbl == NULL ) { - /* We didn't find any symbols - must be stripped */ + /* + * We didn't find any symbols - must be stripped + */ ImpUnloadInfo( iih ); return( DS_FAIL ); } - /* No module name yet, make something up */ + /* + * No module name yet, make something up + */ if( iih->name == NULL ) { static char unknown[] = "Unknown000"; @@ -1105,7 +1148,9 @@ dip_status DIPIMPENTRY( LoadInfo )( FILE *fp, imp_image_handle *iih ) ds = Try[i]( fp, iih ); if( ds & DS_ERR ) { DCStatus( ds ); - /* clean up any allocations */ + /* + * clean up any allocations + */ ImpUnloadInfo( iih ); return( ds ); } diff --git a/bld/dip/export/c/expmisc.c b/bld/dip/export/c/expmisc.c index b9694d8519..80b593794b 100644 --- a/bld/dip/export/c/expmisc.c +++ b/bld/dip/export/c/expmisc.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -35,8 +35,8 @@ /* - Misc. stuff. -*/ + * Misc. stuff. + */ const char DIPImp( Name )[] = "EXPORTS"; diff --git a/bld/dip/export/c/expmod.c b/bld/dip/export/c/expmod.c index 451c8da12a..58da5e3879 100644 --- a/bld/dip/export/c/expmod.c +++ b/bld/dip/export/c/expmod.c @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -33,10 +34,10 @@ #include "exp.h" /* - Stuff dealing with module handles -*/ -walk_result DIPIMPENTRY( WalkModList )( imp_image_handle *iih, - DIP_IMP_MOD_WALKER *wk, void *d ) + * Stuff dealing with module handles + */ + +walk_result DIPIMPENTRY( WalkModList )( imp_image_handle *iih, DIP_IMP_MOD_WALKER *wk, void *d ) { return( wk( iih, IMH_EXPORT, d ) ); } diff --git a/bld/dip/export/c/expsym.c b/bld/dip/export/c/expsym.c index ebd3423af5..cef37d944a 100644 --- a/bld/dip/export/c/expsym.c +++ b/bld/dip/export/c/expsym.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -40,9 +40,8 @@ /* - Stuff dealing with symbol handles. -*/ - + * Stuff dealing with symbol handles. + */ static walk_result DoWalkSymList( imp_image_handle *iih, symbol_source ss, void *source, DIP_IMP_SYM_WALKER *wk, diff --git a/bld/dip/export/c/exptype.c b/bld/dip/export/c/exptype.c index 8ed66653a6..5a3ac6f0e9 100644 --- a/bld/dip/export/c/exptype.c +++ b/bld/dip/export/c/exptype.c @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -34,9 +35,8 @@ /* - Stuff dealing with type handles. -*/ - + * Stuff dealing with type handles. + */ walk_result DIPIMPENTRY( WalkTypeList )( imp_image_handle *iih, imp_mod_handle imh, DIP_IMP_TYPE_WALKER *wk, imp_type_handle *ith, diff --git a/bld/dip/export/h/exp.h b/bld/dip/export/h/exp.h index e379323748..473d5b0776 100644 --- a/bld/dip/export/h/exp.h +++ b/bld/dip/export/h/exp.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -49,17 +50,23 @@ typedef struct exp_block exp_block; typedef struct exp_hunk exp_hunk; struct imp_sym_handle { - /* any stuff for getting information on symbols */ + /* + * any stuff for getting information on symbols + */ exp_sym *p; }; struct imp_type_handle { - /* any stuff for getting information on types */ + /* + * any stuff for getting information on types + */ unsigned_8 code; }; struct imp_cue_handle { - /* any stuff for getting information on source line cues */ + /* + * any stuff for getting information on source line cues + */ void *p; }; diff --git a/bld/dip/hllcv/c/hllcue.c b/bld/dip/hllcv/c/hllcue.c index bcb7f4045b..40e5904c6d 100644 --- a/bld/dip/hllcv/c/hllcue.c +++ b/bld/dip/hllcv/c/hllcue.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2018 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -35,10 +35,10 @@ #include "walloca.h" -/* +static unsigned hllLinnumSize( imp_cue_handle *icueh ) +/***************************************************** * Gets the size of a line number entry. */ -static unsigned hllLinnumSize( imp_cue_handle *icueh ) { switch( icueh->style ) { case HLL_LINE_STYLE_SRC_LINES: @@ -117,10 +117,10 @@ static int hllLinnumCmpHL3(const void *_e1, const void *_e2) return 0; } -/* +static void hllLinnumDtor( imp_image_handle *iih, void *entries ) +/**************************************************************** * VM destructure callback for tracking sorted linnum blocks. */ -static void hllLinnumDtor( imp_image_handle *iih, void *entries ) { int i; for( i = 0; i < HLLINFO_NUM_SORTED; i++ ) { @@ -131,7 +131,8 @@ static void hllLinnumDtor( imp_image_handle *iih, void *entries ) } } -/* +static void *hllGetSortedLinnums( imp_image_handle *iih, imp_cue_handle *icueh ) +/******************************************************************************* * Load and sort the linenumbers in walk order. * * We should not assume that the line numbers are sorted in any helpful @@ -140,7 +141,6 @@ static void hllLinnumDtor( imp_image_handle *iih, void *entries ) * return them as if they were ordered by [sfi,] line. So, since I'm lazy * (don't sue me) we'll do that. */ -static void *hllGetSortedLinnums( imp_image_handle *iih, imp_cue_handle *icueh ) { const unsigned entry_size = hllLinnumSize( icueh ); void *entries; @@ -150,15 +150,17 @@ static void *hllGetSortedLinnums( imp_image_handle *iih, imp_cue_handle *icueh ) if( !entries ) { return( NULL ); } - - /* already sorted? */ + /* + * already sorted? + */ for( i = 0; i < HLLINFO_NUM_SORTED; i++ ) { if( iih->sorted_linnum_blocks[i] == entries ) { return( entries ); } } - - /* sort and register a destructor */ + /* + * sort and register a destructor + */ switch( icueh->style ) { case HLL_LINE_STYLE_SRC_LINES: case HLL_LINE_STYLE_SRC_LINES_SEG_16: @@ -194,17 +196,17 @@ static void *hllGetSortedLinnums( imp_image_handle *iih, imp_cue_handle *icueh ) } -/* - * Walk the list of source files of a module. - */ walk_result DIPIMPENTRY( WalkFileList )( imp_image_handle *iih, imp_mod_handle imh, DIP_IMP_CUE_WALKER *wk, imp_cue_handle *icueh, void *d ) +/********************************************************************************** + * Walk the list of source files of a module. + */ { hll_dir_entry *hde; - //hl4_linnum_first *hdr4; - //hl4_filetab_entry *fp4; - //unsigned file_tab_count; - //unsigned i; +// hl4_linnum_first *hdr4; +// hl4_filetab_entry *fp4; +// unsigned file_tab_count; +// unsigned i; walk_result wr; /* @@ -212,6 +214,9 @@ walk_result DIPIMPENTRY( WalkFileList )( imp_image_handle *iih, imp_mod_handle i */ hde = hllFindDirEntry( iih, imh, hll_sstSrcLines ); if( hde ) { + unsigned_32 pos; + const unsigned_32 entry_size = sizeof( cv3_linnum_entry_16 ); + /* * while( more data ) { * +0 DB filename len @@ -223,9 +228,6 @@ walk_result DIPIMPENTRY( WalkFileList )( imp_image_handle *iih, imp_mod_handle i * } * } */ - unsigned_32 pos; - const unsigned_32 entry_size = sizeof( cv3_linnum_entry_16 ); - icueh->style = HLL_LINE_STYLE_SRC_LINES; icueh->imh = imh; icueh->cur_line = 0; @@ -234,7 +236,9 @@ walk_result DIPIMPENTRY( WalkFileList )( imp_image_handle *iih, imp_mod_handle i while( pos < hde->cb ) { unsigned_8 name_len; - /* read the header */ + /* + * read the header + */ icueh->num_lines = 0; if( !VMSsGetU8( iih, hde, pos, &name_len ) || !VMSsGetU16( iih, hde, pos + 1 + name_len, (unsigned_16 *)&icueh->num_lines ) @@ -258,12 +262,14 @@ walk_result DIPIMPENTRY( WalkFileList )( imp_image_handle *iih, imp_mod_handle i } } } - /* * Old line numbers. */ hde = hllFindDirEntry( iih, imh, hll_sstSrcLnSeg ); if( hde ) { + unsigned_32 pos; + unsigned_32 entry_size; + /* * while( more data ) { * +0 DB filename len @@ -281,11 +287,8 @@ walk_result DIPIMPENTRY( WalkFileList )( imp_image_handle *iih, imp_mod_handle i * } * } */ - unsigned_32 pos; - unsigned_32 entry_size; - if( iih->format_lvl == HLL_LVL_NB00 - || iih->format_lvl == HLL_LVL_NB02 ) { + || iih->format_lvl == HLL_LVL_NB02 ) { entry_size = sizeof( cv3_linnum_entry_16 ); icueh->style = HLL_LINE_STYLE_SRC_LINES_SEG_16; } else { @@ -298,7 +301,9 @@ walk_result DIPIMPENTRY( WalkFileList )( imp_image_handle *iih, imp_mod_handle i while( pos < hde->cb ) { unsigned_8 name_len; - /* read the header */ + /* + * read the header + */ icueh->num_lines = 0; if( !VMSsGetU8( iih, hde, pos, &name_len ) || !VMSsGetU16( iih, hde, pos + 1 + name_len, &icueh->segment ) @@ -323,7 +328,6 @@ walk_result DIPIMPENTRY( WalkFileList )( imp_image_handle *iih, imp_mod_handle i } } } - /* * HLL line numbers - 4 variations. * @@ -351,25 +355,26 @@ walk_result DIPIMPENTRY( WalkFileList )( imp_image_handle *iih, imp_mod_handle i num_files = 0; end_files = 0; first_sfi = 0; - /* * Find the two tables. */ switch( hllGetModStyle( iih, imh ) ) { + case HLL_STYLE_HL01: /* * In HLL V1, there is only one block which starts with * line numbers, continues with paths and finishes off * with files. + * * FIXME: Not 100% sure about the number of blocks. Needs testing. */ - case HLL_STYLE_HL01: { hl1_linnum_first *first; hl1_filetab_hdr *hdr; icueh->style = HLL_LINE_STYLE_HLL_01; - - /* get the 'first' record. */ + /* + * get the 'first' record. + */ first = VMSsBlock( iih, hde, pos, sizeof( *first ) ); if( !first ) { return( WR_FAIL ); @@ -378,7 +383,6 @@ walk_result DIPIMPENTRY( WalkFileList )( imp_image_handle *iih, imp_mod_handle i hllConfused(); /* see ASSUMPTION above */ return( WR_FAIL ); } - end_files = hde->cb; icueh->segment = 1; icueh->lines = pos + sizeof( *first ); @@ -386,8 +390,9 @@ walk_result DIPIMPENTRY( WalkFileList )( imp_image_handle *iih, imp_mod_handle i icueh->file = icueh->lines + icueh->num_lines * sizeof( hl1_linnum_entry ) + first->num_path_entries * sizeof( hl1_pathtab_entry ); - - /* get the file table header */ + /* + * get the file table header + */ hdr = VMSsBlock( iih, hde, icueh->file, sizeof( *hdr ) ); if( !hdr ) { return( WR_FAIL ); @@ -400,20 +405,23 @@ walk_result DIPIMPENTRY( WalkFileList )( imp_image_handle *iih, imp_mod_handle i } break; - /* - * We got segments in the header now and it's possible to - * have several chunks of linenumbers and paths. We will - * only deal with the first chunk. - * FIXME: Not 100% sure about > 1 blocks and entry types. Needs testing. - */ case HLL_STYLE_HL02: + /* + * We got segments in the header now and it's possible to + * have several chunks of linenumbers and paths. We will + * only deal with the first chunk. + * + * FIXME: Not 100% sure about > 1 blocks and entry types. Needs testing. + */ icueh->style = HLL_LINE_STYLE_HLL_02; while( pos < hde->cb && ( !icueh->lines || !icueh->file ) ) { hl2_linnum_first *first; hl1_filetab_hdr *hdr; unsigned_32 pos_next; - /* get the 'first' record. */ + /* + * get the 'first' record. + */ first = VMSsBlock( iih, hde, pos, sizeof( *first ) ); if( !first ) { return( WR_FAIL ); @@ -437,13 +445,13 @@ walk_result DIPIMPENTRY( WalkFileList )( imp_image_handle *iih, imp_mod_handle i icueh->file = icueh->lines + icueh->num_lines * sizeof( hl1_linnum_entry ); end_files = icueh->file + first->file_tab_size; - - /* get the file table header */ + /* + * get the file table header + */ hdr = VMSsBlock( iih, hde, icueh->file, sizeof( *hdr ) ); if( !hdr ) { return( WR_FAIL ); } - num_files = hdr->num_files; first_sfi = hdr->first_sfi; } @@ -452,18 +460,21 @@ walk_result DIPIMPENTRY( WalkFileList )( imp_image_handle *iih, imp_mod_handle i } break; + case HLL_STYLE_HL03: /* * Like HLL V2 except that the line number entry has changed. + * * FIXME: Not 100% sure about > 1 blocks and entry types. Needs testing. */ - case HLL_STYLE_HL03: icueh->style = HLL_LINE_STYLE_HLL_03; while( pos < hde->cb && ( !icueh->lines || !icueh->file ) ) { hl2_linnum_first *first; hl1_filetab_hdr *hdr; unsigned_32 pos_next; - /* get the 'first' record. */ + /* + * get the 'first' record. + */ first = VMSsBlock( iih, hde, pos, sizeof( *first ) ); if( !first ) { return( WR_FAIL ); @@ -487,13 +498,13 @@ walk_result DIPIMPENTRY( WalkFileList )( imp_image_handle *iih, imp_mod_handle i icueh->file = pos + sizeof( *first ) + icueh->num_lines * sizeof( hl3_linnum_entry ); end_files = icueh->file + first->file_tab_size; - - /* get the file table header */ + /* + * get the file table header + */ hdr = VMSsBlock( iih, hde, icueh->file, sizeof( *hdr ) ); if( !hdr ) { return( WR_FAIL ); } - num_files = hdr->num_files; first_sfi = hdr->first_sfi; } @@ -522,7 +533,9 @@ walk_result DIPIMPENTRY( WalkFileList )( imp_image_handle *iih, imp_mod_handle i hl1_filetab_hdr *hdr; unsigned_32 pos_next; - /* get the 'first' record. */ + /* + * get the 'first' record. + */ first = VMSsBlock( iih, hde, pos, sizeof( *first ) ); if( !first ) { return( WR_FAIL ); @@ -545,8 +558,9 @@ walk_result DIPIMPENTRY( WalkFileList )( imp_image_handle *iih, imp_mod_handle i case HLL_LNE_TYPE_FILE_TABLE: icueh->file = pos + sizeof( *first ); end_files = icueh->file + first->files.file_tab_size; - - /* get the file table header */ + /* + * get the file table header + */ hdr = VMSsBlock( iih, hde, icueh->file, sizeof( *hdr ) ); if( !hdr ) { return( WR_FAIL ); @@ -566,7 +580,6 @@ walk_result DIPIMPENTRY( WalkFileList )( imp_image_handle *iih, imp_mod_handle i } break; } - /* * Check and adjust the offsets */ @@ -579,7 +592,6 @@ walk_result DIPIMPENTRY( WalkFileList )( imp_image_handle *iih, imp_mod_handle i icueh->u.hll.last = 0; first_sfi++; /* one based */ - /* * Iterate the two tables in parallel. */ @@ -592,7 +604,9 @@ walk_result DIPIMPENTRY( WalkFileList )( imp_image_handle *iih, imp_mod_handle i unsigned_16 sfi; unsigned_8 file_len; - /* get the line numbers (again). */ + /* + * get the line numbers (again). + */ entries = hllGetSortedLinnums( iih, icueh ); if( !entries ) { return( WR_FAIL ); @@ -601,7 +615,9 @@ walk_result DIPIMPENTRY( WalkFileList )( imp_image_handle *iih, imp_mod_handle i ? entries[icueh->u.hll.first].hl1.sfi : entries[icueh->u.hll.first].hl3.sfi; if( sfi == i + first_sfi) { - /* find the end of the line numbers for this file. */ + /* + * find the end of the line numbers for this file. + */ icueh->u.hll.last = icueh->u.hll.first + 1; while( icueh->u.hll.last < icueh->num_lines && ( icueh->style < HLL_LINE_STYLE_HLL_03 @@ -612,21 +628,24 @@ walk_result DIPIMPENTRY( WalkFileList )( imp_image_handle *iih, imp_mod_handle i } icueh->u.hll.last--; icueh->file = hde->lfo + pos; - - /* do the callback */ + /* + * do the callback + */ wr = wk( iih, icueh, d ); if( wr != WR_CONTINUE ) { return( wr ); } - - /* advance the current (hll) line number. */ + /* + * advance the current (hll) line number. + */ if( ++icueh->u.hll.last >= icueh->num_lines ) { break; } icueh->cur_line = icueh->u.hll.first = icueh->u.hll.last; } - - /* next file name */ + /* + * next file name + */ if( !VMSsGetU8( iih, hde, pos, &file_len ) ) { return( WR_FAIL ); } @@ -638,20 +657,19 @@ walk_result DIPIMPENTRY( WalkFileList )( imp_image_handle *iih, imp_mod_handle i return( WR_CONTINUE ); } -/* +imp_mod_handle DIPIMPENTRY( CueMod )( imp_image_handle *iih, imp_cue_handle *icueh ) +/*********************************************************************************** * Get the module of a cue. */ -imp_mod_handle DIPIMPENTRY( CueMod )( imp_image_handle *iih, imp_cue_handle *icueh ) { iih = iih; return( icueh->imh ); } -/* +size_t DIPIMPENTRY( CueFile )( imp_image_handle *iih, imp_cue_handle *icueh, char *buff, size_t buff_size ) +/********************************************************************************************************** * Get the filename of a cue. */ -size_t DIPIMPENTRY( CueFile )( imp_image_handle *iih, imp_cue_handle *icueh, - char *buff, size_t buff_size ) { unsigned_8 name_len; const char *file_name; @@ -664,24 +682,26 @@ size_t DIPIMPENTRY( CueFile )( imp_image_handle *iih, imp_cue_handle *icueh, return( 0 ); } -/* +cue_fileid DIPIMPENTRY( CueFileId )( imp_image_handle *iih, imp_cue_handle *icueh ) +/********************************************************************************** * Get the 'file id'. */ -cue_fileid DIPIMPENTRY( CueFileId )( imp_image_handle *iih, imp_cue_handle *icueh ) { /* unused parameters */ (void)iih; return( icueh->file ); } -/* +unsigned long DIPIMPENTRY( CueLine )( imp_image_handle *iih, imp_cue_handle *icueh ) +/*********************************************************************************** * Get the linenumber. */ -unsigned long DIPIMPENTRY( CueLine )( imp_image_handle *iih, imp_cue_handle *icueh ) { unsigned_8 * entries; - /* Load and sort the line number. */ + /* + * Load and sort the line number. + */ entries = hllGetSortedLinnums( iih, icueh ); if( !entries ) { return( DS_ERR | DS_FAIL ); @@ -726,31 +746,34 @@ unsigned long DIPIMPENTRY( CueLine )( imp_image_handle *iih, imp_cue_handle *icu return( 0 ); } -/* +unsigned DIPIMPENTRY( CueColumn )( imp_image_handle *iih, imp_cue_handle *icueh ) +/******************************************************************************** * Get the column number - we've got no such information. */ -unsigned DIPIMPENTRY( CueColumn )( imp_image_handle *iih, imp_cue_handle *icueh ) { /* unused parameters */ (void)iih; (void)icueh; return( 0 ); } -/* +address DIPIMPENTRY( CueAddr )( imp_image_handle *iih, imp_cue_handle *icueh ) +/***************************************************************************** * Get the address. */ -address DIPIMPENTRY( CueAddr )( imp_image_handle *iih, imp_cue_handle *icueh ) { unsigned_8 *entries; address addr; - /* Load and sort the line number. */ + /* + * Load and sort the line number. + */ entries = hllGetSortedLinnums( iih, icueh ); if( !entries ) { return( NilAddr ); } - - /* get addr.offset */ + /* + * get addr.offset + */ switch( icueh->style ) { case HLL_LINE_STYLE_SRC_LINES: case HLL_LINE_STYLE_SRC_LINES_SEG_16: @@ -787,8 +810,9 @@ address DIPIMPENTRY( CueAddr )( imp_image_handle *iih, imp_cue_handle *icueh ) } break; } - - /* Construct the address and return. */ + /* + * Construct the address and return. + */ addr.indirect = 0; addr.sect_id = 0; addr.mach.segment = icueh->segment; @@ -796,7 +820,9 @@ address DIPIMPENTRY( CueAddr )( imp_image_handle *iih, imp_cue_handle *icueh ) return( addr ); } -/* +dip_status DIPIMPENTRY( CueAdjust )( imp_image_handle *iih, imp_cue_handle *src_icueh, + int adj, imp_cue_handle *dst_icueh ) +/************************************************************************************* * Adjust the 'src' cue by 'adj' amount and return the result in 'dst'. * * That is, If you get called with "DIPImpCueAdjust( iih, src, 1, dst )", @@ -816,8 +842,6 @@ address DIPIMPENTRY( CueAddr )( imp_image_handle *iih, imp_cue_handle *icueh ) * Reminder: A cue is a source file location. For HLL/CV it's a line for * which code was generated. */ -dip_status DIPIMPENTRY( CueAdjust )( imp_image_handle *iih, imp_cue_handle *src_icueh, - int adj, imp_cue_handle *dst_icueh ) { dip_status ds; @@ -825,7 +849,6 @@ dip_status DIPIMPENTRY( CueAdjust )( imp_image_handle *iih, imp_cue_handle *src_ HLL_LOG(( "DIPImpCueAdjust: ic=%p:{cur_line=%lu file=%#lx} adj=%d aic=%p", src_icueh, (long)ic->cur_line, (long)src_icueh->file, adj, dst_icueh )); - /* * Since we sort the linnumbers this walking is extremely simple. */ @@ -885,7 +908,9 @@ dip_status DIPIMPENTRY( CueAdjust )( imp_image_handle *iih, imp_cue_handle *src_ return( ds ); } -/* line search state data */ +/************************** + * line search state data * + **************************/ typedef struct { cue_fileid file; /* The file we're looking for. */ unsigned_16 line; /* The line we're looking for. */ @@ -893,11 +918,10 @@ typedef struct { search_result rc; /* The search result. */ } hll_find_line_cue_in_file; - -/* +static walk_result hllFindLineCueInFile( imp_image_handle *iih, imp_cue_handle *icueh, void *_state ) +/**************************************************************************************************** * Search a file for a line number in a file. */ -static walk_result hllFindLineCueInFile( imp_image_handle *iih, imp_cue_handle *icueh, void *_state ) { hll_find_line_cue_in_file *state = _state; unsigned_16 entry_size; @@ -913,7 +937,6 @@ static walk_result hllFindLineCueInFile( imp_image_handle *iih, imp_cue_handle * if( icueh->file != state->file && state->file != 0 ) { return( WR_CONTINUE ); } - /* * Simple first line query? */ @@ -922,7 +945,6 @@ static walk_result hllFindLineCueInFile( imp_image_handle *iih, imp_cue_handle * state->rc = SR_EXACT; return( WR_STOP ); } - /* * Do a binary search for the line number. * @@ -957,7 +979,6 @@ static walk_result hllFindLineCueInFile( imp_image_handle *iih, imp_cue_handle * last = i ? i - 1 : 0; } } - /* * We adjust the result, partly because I didn't proove that the search code * is 100% exact, and mainly because there can be multiplentries for the same line. @@ -989,8 +1010,9 @@ static walk_result hllFindLineCueInFile( imp_image_handle *iih, imp_cue_handle * line_num = prev; i--; } - - /* Set the return values on success. */ + /* + * Set the return values on success. + */ if( *line_num <= state->line ) { state->rc = *line_num == state->line ? SR_EXACT : SR_CLOSEST; state->best_icueh = *icueh; @@ -999,7 +1021,10 @@ static walk_result hllFindLineCueInFile( imp_image_handle *iih, imp_cue_handle * return( WR_STOP ); } -/* +search_result DIPIMPENTRY( LineCue )( imp_image_handle *iih, imp_mod_handle imh, + cue_fileid file, unsigned long line, + unsigned column, imp_cue_handle *icueh ) +/******************************************************************************* * Search for a source cue in the given module. * * If 'file' is zero, use the main source file of the module. @@ -1015,9 +1040,6 @@ static walk_result hllFindLineCueInFile( imp_image_handle *iih, imp_cue_handle * * passed in values and return SR_CLOSEST. If there are no cues with * the proper characteristics, return SR_NONE */ -search_result DIPIMPENTRY( LineCue )( imp_image_handle *iih, imp_mod_handle imh, - cue_fileid file, unsigned long line, - unsigned column, imp_cue_handle *icueh ) { /* unused parameters */ (void)column; @@ -1048,7 +1070,9 @@ search_result DIPIMPENTRY( LineCue )( imp_image_handle *iih, imp_mod_handle imh, } -/* Address search state data */ +/***************************** + * Address search state data * + *****************************/ typedef struct { address addr; /* what we're looking for. */ unsigned_32 best_delta; /* The delta between addr and the best cue. */ @@ -1056,10 +1080,10 @@ typedef struct { } hll_find_addr_cue_in_file; -/* +static walk_result hllFindAddrCueInFile( imp_image_handle *iih, imp_cue_handle *icueh, void *_state ) +/**************************************************************************************************** * Search a file for the line number closes to a given address. */ -static walk_result hllFindAddrCueInFile( imp_image_handle *iih, imp_cue_handle *icueh, void *_state ) { hll_find_addr_cue_in_file *state = _state; void *entries; @@ -1075,13 +1099,14 @@ static walk_result hllFindAddrCueInFile( imp_image_handle *iih, imp_cue_handle * if( addr.mach.segment != state->addr.mach.segment ) { return( WR_CONTINUE ); } - /* logical mapping offset. */ + /* + * logical mapping offset. + */ if( icueh->segment <= iih->seg_count ) { map_offset = iih->segments[icueh->segment - 1].map.offset; } else { map_offset = 0; } - /* * Traverse the line numbers. */ @@ -1129,8 +1154,8 @@ static walk_result hllFindAddrCueInFile( imp_image_handle *iih, imp_cue_handle * } } break; - - /* Being kind of lazy, we realize that hl1_linnum_entry and hl3_linnum_entry + /* + * Being kind of lazy, we realize that hl1_linnum_entry and hl3_linnum_entry * only differs in the file index size and the flag field. So, since we'll * be accessing the offset only, we can use hl1_linnum_entry for all the HLL * stuff. @@ -1164,26 +1189,25 @@ static walk_result hllFindAddrCueInFile( imp_image_handle *iih, imp_cue_handle * return( WR_CONTINUE ); } -/* +search_result DIPIMPENTRY( AddrCue )( imp_image_handle *iih, imp_mod_handle imh, + address addr, imp_cue_handle *icueh ) +/******************************************************************************* * Search for the closest cue in the given module that has an address * less then or equal to the given address. If there is no such cue * return SR_NONE. If there is one exactly at the address return * SR_EXACT. Otherwise, return SR_CLOSEST. + * + * It's likely that the line number information of a module, at least HLL, + * origianlly is sorted by address. That could enable us to do a binary + * search of the table. + * + * However, since we're resorting the line numbers for greatly + * simplifying the walking done by DIPImpCueAdjust, we'll have to do + * a linear search here. Should this function prove more frequently + * used and suffer heavily performance wise from this, we should + * reconsider the DIPImpCueAdjust and DIPImpWalkFileList implementations. */ -search_result DIPIMPENTRY( AddrCue )( imp_image_handle *iih, imp_mod_handle imh, - address addr, imp_cue_handle *icueh ) { - /* - * It's likely that the line number information of a module, at least HLL, - * origianlly is sorted by address. That could enable us to do a binary - * search of the table. - * - * However, since we're resorting the line numbers for greatly - * simplifying the walking done by DIPImpCueAdjust, we'll have to do - * a linear search here. Should this function prove more frequently - * used and suffer heavily performance wise from this, we should - * reconsider the DIPImpCueAdjust and DIPImpWalkFileList implementations. - */ walk_result walk_rc; search_result rc; hll_find_addr_cue_in_file state = {0}; @@ -1205,7 +1229,8 @@ search_result DIPIMPENTRY( AddrCue )( imp_image_handle *iih, imp_mod_handle imh, return( rc ); } -/* +int DIPIMPENTRY( CueCmp )( imp_image_handle *iih, imp_cue_handle *icueh1, imp_cue_handle *icueh2 ) +/************************************************************************************************* * Compare two cue handles and return 0 if they refer to the same information. * * If they refer to differnt things return either a positive or negative value @@ -1216,7 +1241,6 @@ search_result DIPIMPENTRY( AddrCue )( imp_image_handle *iih, imp_mod_handle imh, * The reason for the constraints is so that a client can sort a list of handles * and binary search them. */ -int DIPIMPENTRY( CueCmp )( imp_image_handle *iih, imp_cue_handle *icueh1, imp_cue_handle *icueh2 ) { /* unused parameters */ (void)iih; diff --git a/bld/dip/hllcv/c/hllld.c b/bld/dip/hllcv/c/hllld.c index abe55294c5..79e2633ef3 100644 --- a/bld/dip/hllcv/c/hllld.c +++ b/bld/dip/hllcv/c/hllld.c @@ -48,7 +48,9 @@ typedef union { debug_directory dbg_dir; } hll_buf; -/* WD looks for this symbol to determine module bitness */ +/* + * WD looks for this symbol to determine module bitness + */ int __nullarea; #ifdef __WATCOMC__ #pragma aux __nullarea "*"; @@ -56,25 +58,28 @@ int __nullarea; imp_image_handle *ImageList; -/* +static void Cleanup( imp_image_handle *iih ) +/******************************************* * Frees resources associated with a image handle. */ -static void Cleanup( imp_image_handle *iih ) { imp_image_handle **owner; imp_image_handle *curr; unsigned blocks; unsigned i; - /* unlink it */ + /* + * unlink it + */ for( owner = &ImageList; (curr = *owner) != NULL; owner = &curr->next_image ) { if( curr == iih ) { *owner = curr->next_image; break; } } - - /* free memory */ + /* + * free memory + */ if( iih->directory != NULL ) { blocks = BLOCK_FACTOR( iih->dir_count, DIRECTORY_BLOCK_ENTRIES ); for( i = 0; i < blocks; ++i ) { @@ -88,12 +93,12 @@ static void Cleanup( imp_image_handle *iih ) VMFini( iih ); } -/* +static dip_status LoadDirectory( imp_image_handle *iih, unsigned long offent ) +/***************************************************************************** * Loads the HLL directory. * * 'offent' is the file offset of the first directory entry. */ -static dip_status LoadDirectory( imp_image_handle *iih, unsigned long offent ) { unsigned block_count; unsigned i; @@ -111,8 +116,9 @@ static dip_status LoadDirectory( imp_image_handle *iih, unsigned long offent ) return( DS_ERR | DS_NO_MEM ); } memset( iih->directory, 0, block_count * sizeof( void * ) ); - - /* skip to the first entry */ + /* + * skip to the first entry + */ if( DCSeek( iih->sym_fp, offent, DIG_SEEK_ORG ) ) { return( DS_ERR | DS_FSEEK_FAILED ); } @@ -134,7 +140,9 @@ static dip_status LoadDirectory( imp_image_handle *iih, unsigned long offent ) return( DS_ERR | DS_FREAD_FAILED ); } } else { - /* Slow but simple. */ + /* + * Slow but simple. + */ unsigned j; hll_dir_entry *ent = iih->directory[i]; @@ -155,29 +163,30 @@ static dip_status LoadDirectory( imp_image_handle *iih, unsigned long offent ) return( DS_OK ); } -/* +static bool IsHllSignature( hll_trailer *hdr ) +/********************************************* * Checks for HLL signature. * (BUF must pointer to 4 valid bytes.) */ -static bool IsHllSignature( hll_trailer *hdr ) { return( !memcmp( hdr, HLL_NB04, HLL_SIG_SIZE ) || !memcmp( hdr, HLL_NB02, HLL_SIG_SIZE ) || !memcmp( hdr, HLL_NB00, HLL_SIG_SIZE ) ); } -/* +static dip_status FoundHLLSignature( imp_image_handle *iih, unsigned long off, unsigned long size ) +/************************************************************************************************** * Validates the signatures of a HLL debug info block, determining * the length if necessary. */ -static dip_status FoundHLLSignature( imp_image_handle *iih, unsigned long off, - unsigned long size ) { dip_status ds; hll_trailer hdr; unsigned long off_dirent, off_trailer; - /* read the header. */ + /* + * read the header. + */ ds = DCReadAt( iih->sym_fp, &hdr, sizeof( hdr ), off ); if( ds & DS_ERR) { return( ds ); @@ -185,7 +194,6 @@ static dip_status FoundHLLSignature( imp_image_handle *iih, unsigned long off, if( !IsHllSignature( &hdr ) ) { return( DS_FAIL ); } - /* * Read the directory info - both to verify it and to find the trailer. */ @@ -205,9 +213,11 @@ static dip_status FoundHLLSignature( imp_image_handle *iih, unsigned long off, off_dirent += sizeof( dir_hdr ); off_trailer = off_dirent + sizeof( hll_dir_entry ) * dir_hdr.cDir; } else { - /* Old CV3 directory. */ cv3_dirinfo dir_hdr; + /* + * Old CV3 directory. + */ ds = DCReadAt( iih->sym_fp, &dir_hdr, sizeof( dir_hdr ), off_dirent ); if( ds & DS_ERR) { return( ds ); @@ -216,20 +226,21 @@ static dip_status FoundHLLSignature( imp_image_handle *iih, unsigned long off, off_dirent += sizeof( dir_hdr ); off_trailer = off_dirent + sizeof( cv3_dir_entry ) * dir_hdr.cDir; } - - /* is the trailer following the directory? It usually is with wlink. */ + /* + * is the trailer following the directory? It usually is with wlink. + */ ds = DCReadAt( iih->sym_fp, &hdr, sizeof( hdr ), off_trailer ); if( ds & DS_ERR) { return( ds ); } if( !IsHllSignature( &hdr ) ) { + unsigned long cur; + unsigned overlap = 0; + /* * No it isn't, seek from the end (off + size). * Adjust the length first. */ - unsigned long cur; - unsigned overlap = 0; - DCSeek( iih->sym_fp, 0, DIG_SEEK_END ); cur = DCTell( iih->sym_fp ); if( cur > size + off && size + off > size ) { @@ -242,7 +253,9 @@ static dip_status FoundHLLSignature( imp_image_handle *iih, unsigned long off, size_t to_read; char *ptr; - /* read block */ + /* + * read block + */ to_read = 1024 + overlap; cur -= 1024; if( cur < off_trailer ) { @@ -256,8 +269,9 @@ static dip_status FoundHLLSignature( imp_image_handle *iih, unsigned long off, if( ds & DS_ERR ) { return( ds ); } - - /* search it */ + /* + * search it + */ for( ptr = &buf[to_read - sizeof( hdr )]; ptr >= &buf[0]; ptr-- ) { if( IsHllSignature( (hll_trailer *)ptr ) ) { off_trailer = cur + ptr - &buf[0]; @@ -265,12 +279,12 @@ static dip_status FoundHLLSignature( imp_image_handle *iih, unsigned long off, break; } } - - /* next */ + /* + * next + */ overlap = sizeof( hdr ); } while( hdr.signature[0] == 0 ); } - /* * Validate the trailer offset (=size). */ @@ -278,7 +292,6 @@ static dip_status FoundHLLSignature( imp_image_handle *iih, unsigned long off, || hdr.offset != off_trailer - off + sizeof( hdr ) ) { return( DS_FAIL ); } - /* * We're good. */ @@ -293,7 +306,6 @@ static dip_status FoundHLLSignature( imp_image_handle *iih, unsigned long off, } else { hllConfused(); } - /* * Since we already know where the directory is, we load it here. */ @@ -301,10 +313,10 @@ static dip_status FoundHLLSignature( imp_image_handle *iih, unsigned long off, return( ds ); } -/* +static dip_status FindHLLInPEImage( imp_image_handle *iih, unsigned long ne_header_off ) +/*************************************************************************************** * Deals with 32-bit PE images. */ -static dip_status FindHLLInPEImage( imp_image_handle *iih, unsigned long ne_header_off ) { dip_status ds; unsigned_32 debug_rva; @@ -314,7 +326,9 @@ static dip_status FindHLLInPEImage( imp_image_handle *iih, unsigned long ne_head unsigned_32 sh_off; hll_buf buf; - /* read the header */ + /* + * read the header + */ ds = DCReadAt( iih->sym_fp, &buf.pe, PE_HDR_SIZE, ne_header_off ); if( ds & DS_ERR ) { return( ds ); @@ -331,7 +345,6 @@ static dip_status FindHLLInPEImage( imp_image_handle *iih, unsigned long ne_head } iih->is_32bit = 1; image_base = PE( buf.pe, image_base ); - /* * Translate the rva to a file offset and read necessary * segment information at the same time. @@ -348,22 +361,24 @@ static dip_status FindHLLInPEImage( imp_image_handle *iih, unsigned long ne_head if( ds & DS_ERR ) { return( ds ); } - - /* collect segment info. */ + /* + * collect segment info. + */ iih->segments[i].is_executable = !!( buf.sh.flags & PE_OBJ_CODE ); iih->segments[i].ovl = 0; iih->segments[i].map.offset = 0; iih->segments[i].map.segment = i + 1; iih->segments[i].size = buf.sh.virtual_size; // FIXME: alignment? iih->segments[i].address = buf.sh.rva + image_base; - - /* is the debug directory section? */ + /* + * is the debug directory section? + */ if( !iih->bias && debug_rva - buf.sh.rva < buf.sh.virtual_size ) { unsigned_32 debug_off; int left; - debug_off = buf.sh.physical_offset + debug_rva - buf.sh.rva; + debug_off = buf.sh.physical_offset + debug_rva - buf.sh.rva; /* * The IBM linker screw up here. It will omit the debug * directory and put the debug info there instead. @@ -381,14 +396,17 @@ static dip_status FindHLLInPEImage( imp_image_handle *iih, unsigned long ne_head left = 16; for( ;; ) { if( buf.dbg_dir.debug_type == DEBUG_TYPE_CODEVIEW ) { - /* found something? */ + /* + * found something? + */ ds = FoundHLLSignature( iih, buf.dbg_dir.data_seek, buf.dbg_dir.data_seek ); if( ds == DS_OK || ds & DS_ERR ) { break; } } - - /* next */ + /* + * next + */ --left; if( left <= 0) { break; @@ -407,11 +425,11 @@ static dip_status FindHLLInPEImage( imp_image_handle *iih, unsigned long ne_head return( iih->bias ? DS_OK : DS_FAIL ); } -/* +static dip_status FindHLLInLXImage( imp_image_handle *iih, unsigned long ne_header_off ) +/*************************************************************************************** * Deals with LX and LE images. * We must try grab information from the object table. */ -static dip_status FindHLLInLXImage( imp_image_handle *iih, unsigned long ne_header_off ) { union { os2_flat_header flat; @@ -419,7 +437,9 @@ static dip_status FindHLLInLXImage( imp_image_handle *iih, unsigned long ne_head } buf; dip_status ds; - /* read the header */ + /* + * read the header + */ ds = DCReadAt( iih->sym_fp, &buf.flat, sizeof( buf.flat ), ne_header_off ); if( ds & DS_ERR ) { return( ds ); @@ -461,18 +481,20 @@ static dip_status FindHLLInLXImage( imp_image_handle *iih, unsigned long ne_head return( ds ); } -/* +static dip_status TryFindInImage( imp_image_handle *iih ) +/******************************************************** * Tries to find the HLL/CV debug info in a image which format we know. * This function knows about LX, LE, PE and watcom symfile images. */ -static dip_status TryFindInImage( imp_image_handle *iih ) { hll_buf buf; bool have_mz_header = false; unsigned_32 ne_header_off; dip_status ds; - /* Read the image header. */ + /* + * Read the image header. + */ ds = DCReadAt( iih->sym_fp, &buf.signature, sizeof( buf.signature ), 0 ); if( ds & DS_ERR ) { return( ds ); @@ -480,7 +502,9 @@ static dip_status TryFindInImage( imp_image_handle *iih ) ne_header_off = 0; if( buf.signature16 == DOS_SIGNATURE ) { have_mz_header = true; - /* read the new exe header */ + /* + * read the new exe header + */ ds = DCReadAt( iih->sym_fp, &ne_header_off, sizeof( ne_header_off ), NE_HEADER_OFFSET ); if( ds & DS_ERR ) { return( ds ); @@ -490,7 +514,6 @@ static dip_status TryFindInImage( imp_image_handle *iih ) return( ds ); } } - /* * LE/LX executable - Use the debug_off/len members of the header. */ @@ -498,14 +521,12 @@ static dip_status TryFindInImage( imp_image_handle *iih ) || buf.signature16 == EXESIGN_LE ) { return( FindHLLInLXImage( iih, ne_header_off ) ); } - /* * PE executable - Use or scan the debug directory. */ if( buf.signature32 == EXESIGN_PE ) { return( FindHLLInPEImage( iih, ne_header_off ) ); } - /* * NE and MZ executables do not contain any special information * in the header. TryFindTrailer() will have to pick up the debug data. @@ -513,30 +534,29 @@ static dip_status TryFindInImage( imp_image_handle *iih ) if( (buf.signature16 == EXESIGN_NE) || have_mz_header ) { iih->is_32bit = 0; } - /* * ELF executable - ?????? */ - /* * A watcom .sym file. */ if( IsHllSignature( &buf.hdr ) ) { return( FoundHLLSignature( iih, ne_header_off, ~0UL ) ); } - - /* no idea what this is.. */ + /* + * no idea what this is.. + */ return( DS_FAIL ); } -/* +static dip_status TryFindTrailer( imp_image_handle *iih ) +/******************************************************** * Checks if there is a tailing HLL signature in the file. * * This may work not work on executable images because of file alignments * imposed by the linker (ilink at least). However, TryFindInImage will * deal with those formats, so it doesn't really matter here. */ -static dip_status TryFindTrailer( imp_image_handle *iih ) { hll_trailer hdr; unsigned long pos; @@ -556,13 +576,13 @@ static dip_status TryFindTrailer( imp_image_handle *iih ) return( FoundHLLSignature( iih, pos, hdr.offset - sizeof( hdr ) ) ); } -/* +static dip_status FindHLL( imp_image_handle *iih ) +/************************************************* * Tries to locate HLL debug info within the specified file. * * Returns DS_OK if found, with '*offp' set to the offset of the debug info * (relative to the start of the file) and '*sizep' set to the size of it. */ -static dip_status FindHLL( imp_image_handle *iih ) { dip_status ds; @@ -590,15 +610,16 @@ static walk_result FindCompUnit( imp_image_handle *iih, } #endif -/* +dip_status DIPIMPENTRY( LoadInfo )( FILE *fp, imp_image_handle *iih ) +/******************************************************************** * Load debug info if it's in the HLL/CV format. */ -dip_status DIPIMPENTRY( LoadInfo )( FILE *fp, imp_image_handle *iih ) - { dip_status ds; - /* Init the module handle. */ + /* + * Init the module handle. + */ memset( iih, 0, sizeof( *iih ) ); iih->arch = DIG_ARCH_X86; /* No known non-x86 support */ iih->sym_fp = fp; @@ -606,14 +627,16 @@ dip_status DIPIMPENTRY( LoadInfo )( FILE *fp, imp_image_handle *iih ) iih->format_lvl = HLL_LVL_NB04; iih->next_image = ImageList; ImageList = iih; - - /* Read basic HLL and executable image bits. */ + /* + * Read basic HLL and executable image bits. + */ ds = FindHLL( iih ); if( ds == DS_OK ) { ds = VMInit( iih, iih->size ); } - - /* Make sure we've got segment mappings. (FIXME: scan module headers) */ + /* + * Make sure we've got segment mappings. (FIXME: scan module headers) + */ if( ds == DS_OK && !iih->segments ) { iih->seg_count = 2; iih->segments = DCAlloc( sizeof( hllinfo_seg ) * iih->seg_count ); @@ -628,10 +651,12 @@ dip_status DIPIMPENTRY( LoadInfo )( FILE *fp, imp_image_handle *iih ) ds = DS_ERR | DS_NO_MEM; } } - - /* Locate global types. If none, we've types per module. */ + /* + * Locate global types. If none, we've types per module. + */ if( ds == DS_OK ) { -/* FIXME +#if 0 +/* FIXME */ hll_debug_dir *cde; cde = FindDirEntry( iih, IMH_GBL, sstGlobalTypes ); if( cde != NULL ) { @@ -644,11 +669,12 @@ dip_status DIPIMPENTRY( LoadInfo )( FILE *fp, imp_image_handle *iih ) + offsetof( cv_sst_global_types_header, offType ) + hdr->cType * sizeof( hdr->offType[0] ); } - */ +#endif } iih->sym_fp = NULL; - - /* We're done - clean up on failure. */ + /* + * We're done - clean up on failure. + */ if( ds != DS_OK ) { DCStatus( ds ); Cleanup( iih ); @@ -656,10 +682,10 @@ dip_status DIPIMPENTRY( LoadInfo )( FILE *fp, imp_image_handle *iih ) return( ds ); } -/* +void DIPIMPENTRY( MapInfo )( imp_image_handle *iih, void *d ) +/************************************************************ * Lets the DIP user setup segment mappings. */ -void DIPIMPENTRY( MapInfo )( imp_image_handle *iih, void *d ) { unsigned i; @@ -668,10 +694,10 @@ void DIPIMPENTRY( MapInfo )( imp_image_handle *iih, void *d ) } } -/* +bool hllIsSegExecutable( imp_image_handle *iih, unsigned segment ) +/***************************************************************** * Checks if a segment is executable. */ -bool hllIsSegExecutable( imp_image_handle *iih, unsigned segment ) { if( segment <= iih->seg_count && iih->segments[segment - 1].is_executable ) { return( true ); @@ -679,10 +705,10 @@ bool hllIsSegExecutable( imp_image_handle *iih, unsigned segment ) return( false ); } -/* +void hllMapLogical( imp_image_handle *iih, address *a ) +/****************************************************** * Maps an address. */ -void hllMapLogical( imp_image_handle *iih, address *a ) { if( a->mach.segment <= iih->seg_count ) { hllinfo_seg *seg = &iih->segments[a->mach.segment - 1]; @@ -693,10 +719,10 @@ void hllMapLogical( imp_image_handle *iih, address *a ) } } -/* +void DIPIMPENTRY( UnloadInfo )( imp_image_handle *iih ) +/****************************************************** * Free the image. */ -void DIPIMPENTRY( UnloadInfo )( imp_image_handle *iih ) { Cleanup( iih ); } diff --git a/bld/dip/hllcv/c/hllloc.c b/bld/dip/hllcv/c/hllloc.c index cf3add6e0d..468d25acd5 100644 --- a/bld/dip/hllcv/c/hllloc.c +++ b/bld/dip/hllcv/c/hllloc.c @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -31,7 +32,9 @@ #include "hllinfo.h" -/* FIXME: kick out these! They are all WRONG! */ +/* + * FIXME: kick out these! They are all WRONG! + */ #include "cv4w.h" enum { diff --git a/bld/dip/hllcv/c/hllmisc.c b/bld/dip/hllcv/c/hllmisc.c index 89b0e467e1..2974b502ca 100644 --- a/bld/dip/hllcv/c/hllmisc.c +++ b/bld/dip/hllcv/c/hllmisc.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -32,7 +32,9 @@ #include "hllinfo.h" -/* FIXME: kick out these! */ +/* + * FIXME: kick out these! + */ #include "cv4w.h" enum { @@ -46,10 +48,10 @@ CV_LAST_REG const char DIPImp( Name )[] = "HLL/CV"; -/* +unsigned DIPIMPENTRY( HandleSize )( handle_kind hk ) +/*************************************************** * Get the size of a handle. */ -unsigned DIPIMPENTRY( HandleSize )( handle_kind hk ) { static unsigned_8 Sizes[] = { #define pick(enum,hsize,ihsize,wvihsize,cvdmndtype,wdmndtype) ihsize, @@ -60,41 +62,41 @@ unsigned DIPIMPENTRY( HandleSize )( handle_kind hk ) return( Sizes[hk] ); } -/* +dip_status DIPIMPENTRY( MoreMem )( size_t size ) +/*********************************************** * Free memory. */ -dip_status DIPIMPENTRY( MoreMem )( size_t size ) { size = size; return( (VMShrink() != 0) ? DS_OK : DS_FAIL ); } -/* +dip_status DIPImp( Startup )( void ) +/*********************************** * Module startup. */ -dip_status DIPImp( Startup )(void) { return( DS_OK ); } -/* +void DIPIMPENTRY( Shutdown )( void ) +/*********************************** * Module shutdown. */ -void DIPIMPENTRY( Shutdown )( void ) { } -/* +void DIPIMPENTRY( Cancel )( void ) +/********************************* * ? */ -void DIPIMPENTRY( Cancel )( void ) { } -/* +size_t hllNameCopy( char *buff, const char *src, size_t buff_size, size_t len ) +/****************************************************************************** * Creates a zero terminated string. */ -size_t hllNameCopy( char *buff, const char *src, size_t buff_size, size_t len ) { if( buff_size > 0 ) { --buff_size; @@ -106,10 +108,10 @@ size_t hllNameCopy( char *buff, const char *src, size_t buff_size, size_t len ) return( len ); } -/* +hll_dir_entry *hllFindDirEntry( imp_image_handle *iih, imp_mod_handle imh, hll_sst sst ) +/*************************************************************************************** * Finds a subsection directory entry for a specific module. */ -hll_dir_entry *hllFindDirEntry( imp_image_handle *iih, imp_mod_handle imh, hll_sst sst ) { unsigned i; unsigned block; @@ -136,13 +138,13 @@ hll_dir_entry *hllFindDirEntry( imp_image_handle *iih, imp_mod_handle imh, hll_s return( NULL ); } -/* +walk_result hllWalkDirList( imp_image_handle *iih, hll_sst sst, DIP_DIR_WALKER *wk, void *d ) +/******************************************************************************************** * Walks the subsection directory. * * Use 'sst' to limit the callbacks to one specific type. A 'sst' of 0 * means everything. */ -walk_result hllWalkDirList( imp_image_handle *iih, hll_sst sst, DIP_DIR_WALKER *wk, void *d ) { unsigned i; unsigned block; @@ -278,13 +280,15 @@ dip_status hllDoIndirection( imp_image_handle *iih, dig_type_info *ti, return( DS_OK ); } -/* +void hllConfused( void ) +/*********************** * Don't know what's happening. */ -void hllConfused() { volatile int a = 0; volatile int b = 0; - - a /= b; /* cause a fault */ + /* + * cause a fault + */ + a /= b; } diff --git a/bld/dip/hllcv/c/hllmod.c b/bld/dip/hllcv/c/hllmod.c index 95d46f1292..f7bcbd49b9 100644 --- a/bld/dip/hllcv/c/hllmod.c +++ b/bld/dip/hllcv/c/hllmod.c @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -32,26 +33,28 @@ #include "hllinfo.h" -/* Arguments passed to GlueModWalk. */ +/************************************ + * Arguments passed to GlueModWalk. * + ************************************/ struct glue_mod_walk { DIP_IMP_MOD_WALKER *wk; void *d; imp_mod_handle imh; }; -/* +static walk_result GlueModWalk( imp_image_handle *iih, hll_dir_entry *hdd, void *d ) +/*********************************************************************************** * Glue function for the module walk. */ -static walk_result GlueModWalk( imp_image_handle *iih, hll_dir_entry *hdd, void *d ) { struct glue_mod_walk *md = d; return( md->wk( iih, hdd->iMod, md->d ) ); } -/* +walk_result DIPIMPENTRY( WalkModList )( imp_image_handle *iih, DIP_IMP_MOD_WALKER *wk, void *d ) +/*********************************************************************************************** * Walk modules. */ -walk_result DIPIMPENTRY( WalkModList )( imp_image_handle *iih, DIP_IMP_MOD_WALKER *wk, void *d ) { struct glue_mod_walk md; walk_result wr; @@ -65,30 +68,39 @@ walk_result DIPIMPENTRY( WalkModList )( imp_image_handle *iih, DIP_IMP_MOD_WALKE return( wr ); } -//NYI: should be OS && location sensitive +/* + * NYI: should be OS && location sensitive + */ #define IS_PATH_CHAR( c ) ( (c) == '\\' || (c) == '/' || (c) == ':') #define EXT_CHAR '.' -/* The name of the fictive global module. */ +/* + * The name of the fictive global module. + */ #define GBL_NAME "__global" -/* +static size_t StripAndCopyName( unsigned_8 *name, char *buff, size_t buff_size ) +/******************************************************************************* * Strips path and extension from the name and copies into the specified buffer. + * + * FIXME there should be generic functions for stripping this stuff! */ -static size_t StripAndCopyName( unsigned_8 *name, char *buff, size_t buff_size ) { char *start = (char *)&name[1]; char *end = start + *name; char *cur = end - 1; - /* FIXME there should be generic functions for stripping this stuff! */ - /* strip path */ - for( cur = end - 1; cur >= start && !IS_PATH_CHAR( *cur ); cur-- ) - /* nothing */; + /* + * strip path + */ + for( cur = end - 1; cur >= start && !IS_PATH_CHAR( *cur ); cur-- ) { + /* do nothing */; + } start = cur + 1; - - /* strip extension */ + /* + * strip extension + */ for( cur = end - 1; cur > start; cur-- ) { if( *cur == EXT_CHAR ) { end = cur; @@ -98,15 +110,17 @@ static size_t StripAndCopyName( unsigned_8 *name, char *buff, size_t buff_size ) return( hllNameCopy( buff, start, buff_size, end - start ) ); } -/* - * Gets the module name. - */ size_t DIPIMPENTRY( ModName )( imp_image_handle *iih, imp_mod_handle imh, char *buff, size_t buff_size ) +/************************************************************************ + * Gets the module name. + */ { hll_dir_entry *hdd; - /* the fictive global module. */ + /* + * the fictive global module. + */ if( imh == IMH_GBL ) { return( hllNameCopy( buff, GBL_NAME, buff_size, sizeof( GBL_NAME ) - 1 ) ); } @@ -131,10 +145,10 @@ size_t DIPIMPENTRY( ModName )( imp_image_handle *iih, imp_mod_handle imh, return( 0 ); } -/* +hll_ssr_cuinfo *hllGetCompInfo( imp_image_handle *iih, imp_mod_handle imh ) +/************************************************************************** * Gets the compiler unit infomation record (unit = module, so for a module). */ -hll_ssr_cuinfo *hllGetCompInfo( imp_image_handle *iih, imp_mod_handle imh ) { hll_dir_entry *hdd = hllFindDirEntry( iih, imh, hll_sstSymbols ); if( hdd != NULL ) { @@ -152,10 +166,10 @@ hll_ssr_cuinfo *hllGetCompInfo( imp_image_handle *iih, imp_mod_handle imh ) return( NULL ); } -/* +char *DIPIMPENTRY( ModSrcLang )( imp_image_handle *iih, imp_mod_handle imh ) +/*************************************************************************** * Gets the source language for a module. */ -char *DIPIMPENTRY( ModSrcLang )( imp_image_handle *iih, imp_mod_handle imh ) { hll_ssr_cuinfo *cuinfo = hllGetCompInfo( iih, imh ); if( cuinfo != NULL ) { @@ -175,11 +189,10 @@ char *DIPIMPENTRY( ModSrcLang )( imp_image_handle *iih, imp_mod_handle imh ) return( "c" ); } -/* +dip_status DIPIMPENTRY( ModInfo )( imp_image_handle *iih, imp_mod_handle imh, handle_kind hk ) +/********************************************************************************************* * Checks if the specified information is available for this module. */ -dip_status DIPIMPENTRY( ModInfo )( imp_image_handle *iih, imp_mod_handle imh, - handle_kind hk ) { hll_dir_entry *hdd; @@ -208,16 +221,18 @@ dip_status DIPIMPENTRY( ModInfo )( imp_image_handle *iih, imp_mod_handle imh, } -/* Arguments passed to FindModNB04. */ +/************************************ + * Arguments passed to FindModNB04. * + ************************************/ struct find_mod { address *a; imp_mod_handle imh; }; -/* +static walk_result FindModNB04( imp_image_handle *iih, hll_dir_entry *hdd, void *d ) +/*********************************************************************************** * ImpAddrMod worker called for each module subsection. */ -static walk_result FindModNB04( imp_image_handle *iih, hll_dir_entry *hdd, void *d ) { struct find_mod *args = d; address *a = args->a; @@ -252,10 +267,10 @@ static walk_result FindModNB04( imp_image_handle *iih, hll_dir_entry *hdd, void return( WR_CONTINUE ); } -/* +search_result hllAddrMod( imp_image_handle *iih, address a, imp_mod_handle *imh ) +/******************************************************************************** * Finds the module which contains the address 'a'. */ -search_result hllAddrMod( imp_image_handle *iih, address a, imp_mod_handle *imh ) { unsigned seg; @@ -266,7 +281,6 @@ search_result hllAddrMod( imp_image_handle *iih, address a, imp_mod_handle *imh if( iih->segments[seg].ovl == a.sect_id && iih->segments[seg].map.segment == a.mach.segment && a.mach.offset - iih->segments[seg].map.offset < iih->segments[seg].size ) { - /* * Find the address among the module sections. * If not found in any, we return the global handle since @@ -286,18 +300,18 @@ search_result hllAddrMod( imp_image_handle *iih, address a, imp_mod_handle *imh return( SR_NONE ); } -/* +search_result DIPIMPENTRY( AddrMod )( imp_image_handle *iih, address a, imp_mod_handle *imh ) +/******************************************************************************************** * Finds the module which contains the address 'a'. */ -search_result DIPIMPENTRY( AddrMod )( imp_image_handle *iih, address a, imp_mod_handle *imh ) { return( hllAddrMod( iih, a, imh ) ); } -/* +address DIPIMPENTRY( ModAddr )( imp_image_handle *iih, imp_mod_handle imh ) +/************************************************************************** * Gets the module address. */ -address DIPIMPENTRY( ModAddr )( imp_image_handle *iih, imp_mod_handle imh ) { hll_dir_entry *hdd = hllFindDirEntry( iih, imh, hll_sstModule ); if( hdd != NULL) { @@ -345,24 +359,24 @@ address DIPIMPENTRY( ModAddr )( imp_image_handle *iih, imp_mod_handle imh ) return( NilAddr ); } -/* - * Construct default dig_type_info for a module. - */ dip_status DIPIMPENTRY( ModDefault )( imp_image_handle *iih, imp_mod_handle imh, default_kind dk, dig_type_info *ti ) +/******************************************************************************* + * Construct default dig_type_info for a module. + * + * Get the module entry and figure if it's a 16-bit or 32-bit module. + * + * FIXME: We need to record the kind executable image, segment type and + * whatever else which could give of heuristics to decide here. + */ { - /* - * Get the module entry and figure if it's a 16-bit or 32-bit module. - * - * FIXME: We need to record the kind executable image, segment type and - * whatever else which could give of heuristics to decide here. - */ hll_dir_entry *hdd = hllFindDirEntry( iih, imh, hll_sstModule ); if( hdd == NULL && imh != IMH_GBL ) { return( DS_FAIL ); } - /* ASSUMES everything is 32-bit for now */ - + /* + * ASSUMES everything is 32-bit for now + */ ti->kind = TK_POINTER; ti->size = sizeof( addr48_off ); /*FIXME: 16-bit: sizeof( addr32_off )*/ ti->modifier = TM_NEAR; @@ -371,29 +385,35 @@ dip_status DIPIMPENTRY( ModDefault )( imp_image_handle *iih, imp_mod_handle imh, case DK_INT: ti->kind = TK_INTEGER; ti->modifier = TM_SIGNED; - /* size is OK */ + /* + * size is OK + */ break; case DK_DATA_PTR: - /*if( comp_info->flags.f.AmbientData != AMBIENT_NEAR ) { +#if 0 + if( comp_info->flags.f.AmbientData != AMBIENT_NEAR ) { ti->modifier = TM_FAR; ti->size += sizeof( addr_seg ); - } */ + } +#endif break; case DK_CODE_PTR: - /*if( comp_info->flags.f.AmbientCode != AMBIENT_NEAR ) { +#if 0 + if( comp_info->flags.f.AmbientCode != AMBIENT_NEAR ) { ti->modifier = TM_FAR; ti->size += sizeof( addr_seg ); - }*/ + } +#endif break; } return( DS_OK ); } -/* +hll_style hllGetModStyle( imp_image_handle *iih, imp_mod_handle imh ) +/******************************************************************** * Gets the debug style of a module. */ -hll_style hllGetModStyle( imp_image_handle *iih, imp_mod_handle imh ) { hll_dir_entry *hdd = hllFindDirEntry( iih, imh, hll_sstModule ); if( hdd ) { diff --git a/bld/dip/hllcv/c/hllsym.c b/bld/dip/hllcv/c/hllsym.c index e53903589e..fdf2229203 100644 --- a/bld/dip/hllcv/c/hllsym.c +++ b/bld/dip/hllcv/c/hllsym.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -38,11 +38,10 @@ #define SCOPE_CLASS_FLAG 0x80000000UL #define SCOPE_UNIQUE_MASK (~SCOPE_CLASS_FLAG) -/* +dip_status hllSymFillIn( imp_image_handle *iih, imp_sym_handle *ish, unsigned_16 seg, virt_mem h, unsigned len ) +/*************************************************************************************************************** * Fill in a symbol handle for a symbol scope record. */ -dip_status hllSymFillIn( imp_image_handle *iih, imp_sym_handle *ish, unsigned_16 seg, - virt_mem h, unsigned len ) { /* unused parameters */ (void)iih; @@ -58,10 +57,10 @@ dip_status hllSymFillIn( imp_image_handle *iih, imp_sym_handle *ish, unsigned_16 } #if 0 -/* +static dip_status cv3SymFillIn( imp_image_handle *iih, imp_sym_handle *ish, virt_mem h, unsigned len ) +/***************************************************************************************************** * Fill in a symbol handle for a symbol scope record. */ -static dip_status cv3SymFillIn( imp_image_handle *iih, imp_sym_handle *ish, virt_mem h, unsigned len ) { ish->type = HLL_SYM_TYPE_CV3_SSR; ish->segment = 0; //FIXME @@ -77,11 +76,11 @@ static dip_status cv3SymFillIn( imp_image_handle *iih, imp_sym_handle *ish, virt #define GET_NAME_PTR(x) ((char *)&(x) + sizeof( x )) -/* - * Get the name in a SSR record. - */ static dip_status hllSymGetName( imp_image_handle *iih, imp_sym_handle *ish, const char **name_p, size_t *name_len_p ) +/*************************************************************************** + * Get the name in a SSR record. + */ { hll_ssr_all *ssr; @@ -208,14 +207,14 @@ static dip_status hllSymGetName( imp_image_handle *iih, imp_sym_handle *ish, return( DS_OK ); } -/* - * Gets the symbol index. - */ #define DEFTYPE( t ) \ if( idx == 0 ) \ idx = t; static unsigned hllSymTypeIdx( imp_image_handle *iih, hll_ssr_all *p ) +/********************************************************************* + * Gets the symbol index. + */ { unsigned idx; @@ -359,11 +358,11 @@ static unsigned hllSymTypeIdx( imp_image_handle *iih, hll_ssr_all *p ) return( idx ); } -/* - * Get the location of the given symbol. - */ dip_status hllSymLocation( imp_image_handle *iih, imp_sym_handle *ish, location_context *lc, location_list *ll ) +/********************************************************************* + * Get the location of the given symbol. + */ { address addr = { 0 }; void *p; @@ -495,18 +494,19 @@ dip_status hllSymLocation( imp_image_handle *iih, imp_sym_handle *ish, case HLL_SSR_CU_FUNC_NUM: return( DS_FAIL ); } - } else { - /* FIXME: CV3 */ + /* + * FIXME: CV3 + */ return( DS_FAIL ); } - - /* (addresses only, the others return) */ + /* + * (addresses only, the others return) + */ hllMapLogical( iih, &addr ); hllLocationCreate( ll, LT_ADDR, &addr ); return( DS_OK ); - #if 0 address addr; s_all *p; @@ -724,7 +724,9 @@ static dip_status ScopeFindFirst( imp_image_handle *iih, imp_mod_handle imh, chk += p->common.length + sizeof( p->common.length ); len -= p->common.length + sizeof( p->common.length ); } - /* found first scope block, now find correct offset */ + /* + * found first scope block, now find correct offset + */ for( ;; ) { ds = hllScopeFillIn( iih, chk, scope, NULL ); if( ds != DS_OK ) @@ -737,7 +739,9 @@ static dip_status ScopeFindFirst( imp_image_handle *iih, imp_mod_handle imh, return( DS_FAIL ); chk = scope->next; } - /* found enclosing scope block, now find smallest one */ + /* + * found enclosing scope block, now find smallest one + */ chk = scope->scope; new.cde = scope->cde; for( ;; ) { @@ -745,21 +749,31 @@ static dip_status ScopeFindFirst( imp_image_handle *iih, imp_mod_handle imh, if( ds & DS_ERR ) return( ds ); if( ds == DS_OK ) { - /* new scope */ + /* + * new scope + */ if( !(addr.mach.offset >= new.start.mach.offset && addr.mach.offset < (new.start.mach.offset + new.len)) ) { - /* out of range */ + /* + * out of range + */ chk = new.end; } else if( !(new.start.mach.offset >= scope->start.mach.offset && (new.start.mach.offset+new.len) <= (scope->start.mach.offset+scope->len)) ) { - /* not smaller */ + /* + * not smaller + */ chk = new.end; } else { - /* inner scope */ + /* + * inner scope + */ *scope = new; } } else if( p->common.code == S_END ) { - /* all done */ + /* + * all done + */ return( DS_OK ); } p = VMBlock( iih, chk, sizeof( p->common ) ); @@ -778,14 +792,14 @@ static dip_status ScopeFindNext( imp_image_handle *iih, scope_info *scope ) #endif -/* - * Process one global symbol. - * If 'scope' is a non-zero, symbols starting a scope will be skipped. - */ static walk_result hllScopeOneModSymbol( imp_image_handle *iih, hll_dir_entry *hde, scope_info *scope, DIP_IMP_SYM_WALKER *wk, void *d, unsigned_32 *posp, unsigned_16 *depthp, unsigned_16 *segp ) +/********************************************************************************** + * Process one global symbol. + * If 'scope' is a non-zero, symbols starting a scope will be skipped. + */ { walk_result wr = WR_CONTINUE; hll_ssr_all *ssr; @@ -827,9 +841,9 @@ static walk_result hllScopeOneModSymbol( imp_image_handle *iih, hll_dir_entry *h //don't know about the next ones... if( ds == DS_OK && scope != NULL ) { /* - starting a new scope and not doing file scope - symbols -- skip scope start symbol - */ + * starting a new scope and not doing file scope + * symbols -- skip scope start symbol + */ wr = WR_CONTINUE; } else { imp_sym_handle ish; @@ -868,7 +882,9 @@ static walk_result hllScopeOneModSymbol( imp_image_handle *iih, hll_dir_entry *h case HLL_SSR_ARRAY_SYM: //?? case HLL_SSR_CU_INFO: case HLL_SSR_CU_FUNC_NUM: - /* not interested in these */ + /* + * not interested in these + */ break; } return( wr ); @@ -886,7 +902,9 @@ static walk_result ScopeWalkOne( imp_image_handle *iih, scope_info *scope, p = VMBlock( iih, curr, sizeof( p->common ) ); if( p == NULL ) return( WR_FAIL ); - /* skip over first scope start symbol */ + /* + * skip over first scope start symbol + */ curr += p->common.length + sizeof( p->common.length ); for( ;; ) { p = VMBlock( iih, curr, sizeof( p->common ) ); @@ -975,7 +993,9 @@ static walk_result hllScopeWalkFile( imp_image_handle *iih, wr = hllScopeOneModSymbol( iih, hde, NULL, wk, d, &pos, &depth, &seg ); } } else { - /* FIXME: CV3 */ + /* + * FIXME: CV3 + */ } return( wr ); @@ -1173,12 +1193,16 @@ static search_result TableSearchForName( imp_image_handle *iih, if( scompn( name, curr, curr_len ) != 0 ) { continue; } - /* Got one! */ + /* + * Got one! + */ switch( create( iih, sp, ish, d ) ) { case SR_FAIL: return( SR_FAIL ); case SR_CLOSEST: - /* means we found one, but keep on going */ + /* + * means we found one, but keep on going + */ sr = SR_EXACT; break; case SR_EXACT: @@ -1238,12 +1262,12 @@ dip_status hllSymFindMatchingSym( imp_image_handle *iih, return( DS_FAIL ); } -/* - * Walks the publics subsection for a module. - */ static walk_result hllWalkModulePublics( imp_image_handle *iih, hll_dir_entry *hde, DIP_IMP_SYM_WALKER *wk, imp_sym_handle *ish, void *d) +/*********************************************************************************** + * Walks the publics subsection for a module. + */ { unsigned off_name_len; unsigned_32 pos; @@ -1262,7 +1286,9 @@ static walk_result hllWalkModulePublics( imp_image_handle *iih, unsigned_8 name_len; walk_result wr; - /* get the record length and make sure it's all valid. */ + /* + * get the record length and make sure it's all valid. + */ if( !VMSsGetU8( iih, hde, pos + off_name_len, &name_len ) ) { return( WR_FAIL ); } @@ -1271,8 +1297,9 @@ static walk_result hllWalkModulePublics( imp_image_handle *iih, if( pub == NULL ) { return( WR_FAIL ); } - - /* construct a symbol handle and feed it to the walker function. */ + /* + * construct a symbol handle and feed it to the walker function. + */ ish->type = HLL_SYM_TYPE_PUB; ish->handle = pos + hde->lfo; ish->len = len; @@ -1308,12 +1335,12 @@ static walk_result WalkGlue( imp_image_handle *iih, sym_walk_info swi, return( gd->wk( iih, swi, gd->ish, gd->d ) ); } -/* +static walk_result hllWalkModuleGlobals( imp_image_handle *iih, + hll_dir_entry *hde, void *d ) +/********************************************************************* * Module walker callback which will in turn walk the global * symbols of a module. */ -static walk_result hllWalkModuleGlobals( imp_image_handle *iih, - hll_dir_entry *hde, void *d ) { struct glue_info *gd = d; walk_result wr = WR_CONTINUE; @@ -1331,6 +1358,9 @@ static walk_result hllWalkModuleGlobals( imp_image_handle *iih, } +static walk_result hllWalkSymList( imp_image_handle *iih, symbol_source ss, + void *source, DIP_IMP_SYM_WALKER *wk, + imp_sym_handle *ish, void *d ) /* * Walk the list of symbols. * @@ -1404,9 +1434,6 @@ static walk_result hllWalkModuleGlobals( imp_image_handle *iih, * } * } */ -static walk_result hllWalkSymList( imp_image_handle *iih, symbol_source ss, - void *source, DIP_IMP_SYM_WALKER *wk, - imp_sym_handle *ish, void *d ) { struct glue_info glue; imp_mod_handle imh; @@ -1421,13 +1448,13 @@ static walk_result hllWalkSymList( imp_image_handle *iih, symbol_source ss, glue.ish = ish; glue.d = d; switch( ss ) { + case SS_MODULE: /* * The 'source' is a pointer to an imp_mod_handle. If the * '*(imp_mod_handle *)source' is IMH_NOMOD, the list is all the module * scope & global symbols in the image, otherwise it is the list of * module scope & global symbols in the indicated module. */ - case SS_MODULE: imh = *(imp_mod_handle *)source; if( imh == IMH_NOMOD ) { wr = hllWalkDirList( iih, hll_sstModule, &hllWalkModuleGlobals, &glue ); @@ -1461,7 +1488,9 @@ static walk_result hllWalkSymList( imp_image_handle *iih, symbol_source ss, if( ds != DS_OK ) return( WR_CONTINUE ); if( sc_block->unique & SCOPE_CLASS_FLAG ) { - /* Walk the member function class scope */ + /* + * Walk the member function class scope + */ ds = hllTypeIndexFillIn( iih, hllSymTypeIdx( iih, p ), &ith ); if( ds & DS_ERR ) return( WR_FAIL ); @@ -1483,37 +1512,39 @@ static walk_result hllWalkSymList( imp_image_handle *iih, symbol_source ss, return( WR_FAIL ); } -/* - * Walk a symbol list. - */ walk_result DIPIMPENTRY( WalkSymList )( imp_image_handle *iih, symbol_source ss, void *source, DIP_IMP_SYM_WALKER *wk, imp_sym_handle *ish, void *d ) +/******************************************************************************* + * Walk a symbol list. + */ { return( hllWalkSymList( iih, ss, source, wk, ish, d ) ); } -/* - * Walk a symbol list, new api. - */ walk_result DIPIMPENTRY( WalkSymListEx )( imp_image_handle *iih, symbol_source ss, void *source, DIP_IMP_SYM_WALKER *wk, imp_sym_handle *ish, location_context *lc, void *d ) +/************************************************************************************* + * Walk a symbol list, new api. + */ { lc=lc; return( hllWalkSymList( iih, ss, source, wk, ish, d ) ); } -/* +imp_mod_handle DIPIMPENTRY( SymMod )( imp_image_handle *iih, imp_sym_handle *ish ) +/********************************************************************************* * Get the module of a symbol. */ -imp_mod_handle DIPIMPENTRY( SymMod )( imp_image_handle *iih, imp_sym_handle *ish ) { iih = iih; return( ish->imh ); } +static size_t hllSymName( imp_image_handle *iih, imp_sym_handle *ish, + location_context *lc, symbol_name_type snt, char *buff, size_t buff_size ) /* * Given the imp_sym_handle, copy the name of the symbol into 'buff'. * @@ -1544,8 +1575,6 @@ imp_mod_handle DIPIMPENTRY( SymMod )( imp_image_handle *iih, imp_sym_handle *ish * when scanned in an expression, the symbol handle can * be reconstructed. Deprecated - never used. */ -static size_t hllSymName( imp_image_handle *iih, imp_sym_handle *ish, - location_context *lc, symbol_name_type snt, char *buff, size_t buff_size ) { const char *name = NULL; size_t name_len; @@ -1559,8 +1588,9 @@ static size_t hllSymName( imp_image_handle *iih, imp_sym_handle *ish, if( snt != SNT_OBJECT && snt != SNT_DEMANGLED ) { return( 0 ); } - - /* get the name */ + /* + * get the name + */ if( HLL_IS_LVL_32BIT( iih->format_lvl ) ) { off_name = offsetof( hll_public, name_len ) + 1; } else { @@ -1568,8 +1598,9 @@ static size_t hllSymName( imp_image_handle *iih, imp_sym_handle *ish, } name_len = ish->len - off_name; name = VMBlock( iih, ish->handle + off_name, name_len); - - /* demangle... */ + /* + * demangle... + */ if( snt == SNT_DEMANGLED && name != NULL ) { if( __is_mangled( name, name_len ) ) { return( __demangle_l( name, name_len, buff, buff_size ) ); @@ -1586,7 +1617,7 @@ static size_t hllSymName( imp_image_handle *iih, imp_sym_handle *ish, switch( snt ) { case SNT_EXPRESSION: return( 0 ); -/* +#if 0 case SNT_OBJECT: case SNT_DEMANGLED: ds = hllSymLocation( iih, ish, lc, &ll ); @@ -1608,7 +1639,7 @@ static size_t hllSymName( imp_image_handle *iih, imp_sym_handle *ish, if( !__is_mangled( name, len ) ) return( 0 ); return( __demangle_l( name, len, buff, buff_size ) ); -*/ +#endif case SNT_SOURCE: if( hllSymGetName( iih, ish, &name, &name_len ) != DS_OK ) { return( 0 ); @@ -1629,19 +1660,19 @@ static size_t hllSymName( imp_image_handle *iih, imp_sym_handle *ish, return( hllNameCopy( buff, name, buff_size, name_len ) ); } -/* - * Get the symbol name. - */ size_t DIPIMPENTRY( SymName )( imp_image_handle *iih, imp_sym_handle *ish, location_context *lc, symbol_name_type snt, char *buff, size_t buff_size ) +/***************************************************************************** + * Get the symbol name. + */ { return( hllSymName( iih, ish, lc, snt, buff, buff_size ) ); } -/* +dip_status hllSymType( imp_image_handle *iih, imp_sym_handle *ish, imp_type_handle *ith ) +/**************************************************************************************** * Get the type of the given symbol. */ -dip_status hllSymType( imp_image_handle *iih, imp_sym_handle *ish, imp_type_handle *ith ) { unsigned type_idx; void *p; @@ -1649,7 +1680,6 @@ dip_status hllSymType( imp_image_handle *iih, imp_sym_handle *ish, imp_type_hand if( ish->containing_type != 0 ) { return( hllTypeSymGetType( iih, ish, ith ) ); } - /* * Load the record, get the type index and create a type handle from that */ @@ -1664,7 +1694,6 @@ dip_status hllSymType( imp_image_handle *iih, imp_sym_handle *ish, imp_type_hand } else { type_idx = pub->cv3.type; } - } else if( ish->type == HLL_SYM_TYPE_HLL_SSR ) { type_idx = hllSymTypeIdx( iih, p ); } else { @@ -1674,36 +1703,37 @@ dip_status hllSymType( imp_image_handle *iih, imp_sym_handle *ish, imp_type_hand return( hllTypeIndexFillIn( iih, type_idx, ith ) ); } -/* +dip_status DIPIMPENTRY( SymType )( imp_image_handle *iih, imp_sym_handle *ish, imp_type_handle *ith ) +/**************************************************************************************************** * Get the type of the given symbol. */ -dip_status DIPIMPENTRY( SymType )( imp_image_handle *iih, imp_sym_handle *ish, - imp_type_handle *ith ) { return( hllSymType( iih, ish, ith ) ); } -/* - * Get the location of the given symbol. - */ dip_status DIPIMPENTRY( SymLocation )( imp_image_handle *iih, imp_sym_handle *ish, location_context *lc, location_list *ll ) +/********************************************************************************* + * Get the location of the given symbol. + */ { return( hllSymLocation( iih, ish, lc, ll ) ); } -/* - * Copy the value of a constant symbol into 'buff'. - */ dip_status hllSymValue( imp_image_handle *iih, imp_sym_handle *ish, location_context *lc, void *buff ) +/****************************************************************** + * Copy the value of a constant symbol into 'buff'. + */ { void *p; /* unused parameters */ (void)lc; (void)buff; - /* Doesn't apply to publics. */ + /* + * Doesn't apply to publics. + */ if( ish->type == HLL_SYM_TYPE_PUB ) { return( DS_FAIL ); } @@ -1714,12 +1744,16 @@ dip_status hllSymValue( imp_image_handle *iih, imp_sym_handle *ish, hll_ssr_all *ssr = p; switch( ssr->common.code ) { case HLL_SSR_CONSTANT: - /* FIXME */ + /* + * FIXME + */ break; } } else { - /* FIXME: CV3 */ + /* + * FIXME: CV3 + */ } } @@ -1756,21 +1790,21 @@ dip_status hllSymValue( imp_image_handle *iih, imp_sym_handle *ish, #endif } -/* +dip_status DIPIMPENTRY( SymValue )( imp_image_handle *iih, imp_sym_handle *ish, + location_context *lc, void *buff ) +/****************************************************************************** * Copy the value of a constant symbol into 'buff'. You can get the * size required by doing a SymType followed by a TypeInfo. */ -dip_status DIPIMPENTRY( SymValue )( imp_image_handle *iih, imp_sym_handle *ish, - location_context *lc, void *buff ) { return( hllSymValue( iih, ish, lc, buff ) ); } -/* - * Get some generic information about a symbol. - */ dip_status DIPIMPENTRY( SymInfo )( imp_image_handle *iih, imp_sym_handle *ish, location_context *lc, sym_info *si ) +/***************************************************************************** + * Get some generic information about a symbol. + */ { void *p; @@ -1779,8 +1813,9 @@ dip_status DIPIMPENTRY( SymInfo )( imp_image_handle *iih, imp_sym_handle *ish, if( ish->containing_type != 0 ) { return( hllTypeSymGetInfo( iih, ish, lc, si ) ); } - - /* get the record. */ + /* + * get the record. + */ p = VMBlock( iih, ish->handle, ish->len ); if( p == NULL ) { return( DS_FAIL ); @@ -1826,12 +1861,14 @@ dip_status DIPIMPENTRY( SymInfo )( imp_image_handle *iih, imp_sym_handle *ish, si->prolog_size = ssr->proc.prologue_len; si->epilog_size = ssr->proc.len - ssr->proc.prologue_body_len; si->rtn_size = ssr->proc.len; - /* FIXME: +#if 0 + /* FIXME: */ si->num_parms si->rtn_calloc si->ret_modifier si->ret_size - si->is_static */ + si->is_static +#endif break; case HLL_SSR_CONSTANT: @@ -2016,11 +2053,15 @@ dip_status DIPIMPENTRY( SymParmLocation )( imp_image_handle *iih, if( n > parm_count ) return( DS_NO_PARM ); if( n == 0 ) { - /* return value */ + /* + * return value + */ p = VMRecord( iih, ish->handle + ish->len, NULL, 0 ); if( p == NULL ) return( DS_ERR | DS_FAIL ); - /* WARNING: assuming that S_RETURN directly follows func defn */ + /* + * WARNING: assuming that S_RETURN directly follows func defn + */ if( p->common.code == S_RETURN ) { switch( p->return_.f.style ) { case CVRET_VOID: @@ -2038,7 +2079,9 @@ dip_status DIPIMPENTRY( SymParmLocation )( imp_image_handle *iih, } return( DS_ERR | DS_BAD_LOCATION ); } - /* find out about return type */ + /* + * find out about return type + */ ds = hllTypeIndexFillIn( iih, type, &ith ); if( ds != DS_OK ) return( ds ); @@ -2102,7 +2145,9 @@ dip_status DIPIMPENTRY( SymParmLocation )( imp_image_handle *iih, switch( call ) { case CV_NEARC: case CV_FARC: - /* all on stack */ + /* + * all on stack + */ return( DS_NO_PARM ); case CV_NEARPASCAL: case CV_FARPASCAL: @@ -2116,7 +2161,9 @@ dip_status DIPIMPENTRY( SymParmLocation )( imp_image_handle *iih, case CV_MIPS: case CV_AXP: case CV_GENERIC: - //NYI: have to handle all of these suckers + /* + * NYI: have to handle all of these suckers + */ NYI(); break; } @@ -2198,7 +2245,9 @@ dip_status DIPIMPENTRY( SymObjLocation )( imp_image_handle *iih, break; check = next; } - /* We have a 'this' pointer! Repeat, we have a this pointer! */ + /* + * We have a 'this' pointer! Repeat, we have a this pointer! + */ ds = hllSymLocation( iih, &parm, lc, ll ); if( ds != DS_OK ) return( ds ); @@ -2293,7 +2342,9 @@ static walk_result SymFind( imp_image_handle *iih, sym_walk_info swi, if( scompn( li->name.start, name, len ) != 0 ) { return( WR_CONTINUE ); } - /* Got one! */ + /* + * Got one! + */ new = DCSymCreate( iih, sd->d ); if( new == NULL ) return( WR_FAIL ); @@ -2331,7 +2382,9 @@ static search_result SymCreate( imp_image_handle *iih, s_all *p, if( new == NULL ) return( SR_FAIL ); *new = *ish; - /* keep on looking for more */ + /* + * keep on looking for more + */ return( SR_CLOSEST ); } @@ -2376,7 +2429,9 @@ static search_result DoLookupSym( imp_image_handle *iih, break; case SS_SCOPED: if( ImpAddrMod( iih, *(address *)source, &ish.imh ) == SR_NONE ) { - /* just check the global symbols */ + /* + * just check the global symbols + */ break; } if( MH2IMH( data.li.mod ) != ish.imh && MH2IMH( data.li.mod ) != IMH_NOMOD ) { @@ -2554,7 +2609,9 @@ search_result DIPIMPENTRY( ScopeOuter )( imp_image_handle *iih, case S_LPROC16: case S_GPROC32: case S_LPROC32: - /* Might be a member function. We'll let WalkSym figure it out. */ + /* + * Might be a member function. We'll let WalkSym figure it out. + */ *out = *in; out->unique |= SCOPE_CLASS_FLAG; return( SR_CLOSEST ); @@ -2576,7 +2633,8 @@ search_result DIPIMPENTRY( ScopeOuter )( imp_image_handle *iih, #endif } -/* +int DIPIMPENTRY( SymCmp )( imp_image_handle *iih, imp_sym_handle *ish1, imp_sym_handle *ish2 ) +/********************************************************************************************* * Compare two sym handles and return 0 if they refer to the same * information. If they refer to differnt things return either a * positive or negative value to impose an 'order' on the information. @@ -2588,7 +2646,6 @@ search_result DIPIMPENTRY( ScopeOuter )( imp_image_handle *iih, * The reason for the constraints is so that a client can sort a * list of handles and binary search them. */ -int DIPIMPENTRY( SymCmp )( imp_image_handle *iih, imp_sym_handle *ish1, imp_sym_handle *ish2 ) { /* unused parameters */ (void)iih; diff --git a/bld/dip/hllcv/c/hlltype.c b/bld/dip/hllcv/c/hlltype.c index 6e871e2062..9bb9fbf28f 100644 --- a/bld/dip/hllcv/c/hlltype.c +++ b/bld/dip/hllcv/c/hlltype.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -33,16 +33,18 @@ #include "hllinfo.h" #include "walloca.h" -/* FIXME: kick out these! */ +/* + * FIXME: kick out these! + */ #include "cv4w.h" enum { -#define _CVREG( name, num ) CV_X86_##name = num, -#include "cv4intl.h" -#undef _CVREG -#define _CVREG( name, num ) CV_AXP_##name = num, -#include "cv4axp.h" -CV_LAST_REG + #define _CVREG( name, num ) CV_X86_##name = num, + #include "cv4intl.h" + #undef _CVREG + #define _CVREG( name, num ) CV_AXP_##name = num, + #include "cv4axp.h" + CV_LAST_REG }; @@ -67,9 +69,9 @@ static dip_status TypeVMGetName( imp_image_handle *iih, virt_mem base, return( DS_OK ); } /* - The "+ sizeof( unsigned_32 )" is to make sure that the GetNumLeaf's - have enough stuff mapped in to work. - */ + * The "+ sizeof( unsigned_32 )" is to make sure that the GetNumLeaf's + * have enough stuff mapped in to work. + */ p = VMBlock( iih, base, sizeof( *p ) + sizeof( unsigned_32 ) ); if( p == NULL ) return( DS_ERR | DS_FAIL ); @@ -125,7 +127,9 @@ static dip_status TypeVMGetName( imp_image_handle *iih, virt_mem base, *name_len_p = 0; return( DS_OK ); } - /* A name can't be longer than 255 bytes */ + /* + * A name can't be longer than 255 bytes + */ p = VMBlock( iih, base, 256 + skip ); if( p == NULL ) return( DS_ERR | DS_FAIL ); @@ -350,10 +354,10 @@ static walk_result TypeListWalk( imp_image_handle *iih, virt_mem head, len += (unsigned_8 *)hllGetNumLeaf( ptr, &val ) - (unsigned_8 *)ptr; if( list->prev != NULL ) { /* - If we're processing an inherited class, we want to - ignore any virtual base classes. They'll get handled - by the most derived class. - */ + * If we're processing an inherited class, we want to + * ignore any virtual base classes. They'll get handled + * by the most derived class. + */ list->curr += len; continue; } @@ -475,7 +479,9 @@ static void TypePrimitiveInfo( unsigned idx, dig_type_info *ti ) break; case 0x5: case 0x6: - /* Basic string: what size? */ + /* + * Basic string: what size? + */ ti->size = 0; ti->kind = TK_STRING; break; @@ -554,7 +560,9 @@ static void TypePrimitiveInfo( unsigned idx, dig_type_info *ti ) } break; case 0x0f: - /* my own invention: T_CODE_LBL*, T_DATA_LBL* */ + /* + * my own invention: T_CODE_LBL*, T_DATA_LBL* + */ ti->kind = (prim.s & 0x08) ? TK_DATA : TK_CODE; ti->size = 1 << prim.f.size; break; @@ -719,7 +727,9 @@ static walk_result FindVTab( imp_image_handle *iih, sym_walk_info swi, case SWI_INHERIT_END: return( WR_STOP ); } - /* SWI_SYMBOL: */ + /* + * SWI_SYMBOL: + */ switch( p->common.code ) { case LF_VFUNCTAB: vd->disp = 0; @@ -810,7 +820,9 @@ static dip_status VFuncLocation( imp_image_handle *iih, imp_sym_handle *ish, switch( vfshape ) { case CV_VTNEAR: case CV_VTNEAR32: - /* since it's a code item, the default addr space is CI_EXECUTION */ + /* + * since it's a code item, the default addr space is CI_EXECUTION + */ save = ll->e[0].u.addr.mach.offset; ds = DCItemLocation( lc, CI_EXECUTION, ll ); if( ds != DS_OK ) @@ -832,13 +844,15 @@ static dip_status MatchSymLocation( imp_image_handle *iih, imp_sym_handle *ish, dip_status ds; /* - Have to lookup "::" with given type index to get - address. Ugh :-(. - */ + * Have to lookup "::" with given type index to get + * address. Ugh :-(. + */ ds = TypeVMGetName( iih, ish->handle, &name, &len, NULL ); if( ds != DS_OK ) return( ds ); - /* name can't be longer than 256 because of CV format */ + /* + * name can't be longer than 256 because of CV format + */ buff = walloca( len + (SCOPE_TOKEN_LEN + 256) ); start = &buff[SCOPE_TOKEN_LEN+256]; buff = &start[len]; @@ -870,14 +884,18 @@ dip_status hllTypeSymGetAddr( imp_image_handle *iih, imp_sym_handle *ish, p = VMBlock( iih, ish->handle, sizeof( *p ) + sizeof( unsigned_32 ) * 2 ); switch( p->common.code ) { case LF_MEMBER: - /* save type index from scurges of VM system */ + /* + * save type index from scurges of VM system + */ idx = p->member.f.type; hllGetNumLeaf( &p->member + 1, &val ); ds = DCItemLocation( lc, CI_OBJECT, ll ); if( ds != DS_OK ) return( ds ); if( ish->adjustor_type != 0 ) { - /* have to fish displacement out of virtual base table */ + /* + * have to fish displacement out of virtual base table + */ ds = GetVirtBaseDisp( iih, ish->adjustor_type, lc, *ll, &disp ); if( ds != DS_OK ) return( ds ); @@ -885,7 +903,9 @@ dip_status hllTypeSymGetAddr( imp_image_handle *iih, imp_sym_handle *ish, } hllLocationAdd( ll, (ish->adjustor_offset + val.int_val) * 8 ); if( idx >= CV_FIRST_USER_TYPE ) { - /* have to check type in case it's a bit field */ + /* + * have to check type in case it's a bit field + */ ds = hllTypeIndexFillIn( iih, idx, &base_ith ); if( ds != DS_OK ) return( ds ); @@ -940,7 +960,9 @@ dip_status hllTypeSymGetType( imp_image_handle *iih, imp_sym_handle *ish, case LF_MEMBER: idx = p->member.f.type; if( idx >= CV_FIRST_USER_TYPE ) { - /* have to check type in case it's a bit field */ + /* + * have to check type in case it's a bit field + */ ds = hllTypeIndexFillIn( iih, idx, ith ); if( ds != DS_OK ) return( ds ); @@ -967,7 +989,9 @@ dip_status hllTypeSymGetType( imp_image_handle *iih, imp_sym_handle *ish, ith->array_dim = 0; return( DS_OK ); default: - /* type name */ + /* + * type name + */ ith->handle = ish->handle; ith->idx = UNKNOWN_TYPE_IDX; ith->array_dim = 0; @@ -984,21 +1008,25 @@ dip_status hllTypeSymGetValue( imp_image_handle *iih, imp_sym_handle *ish, lc = lc; /* - The "+ sizeof( unsigned_32 )" is to make sure that the hllGetNumLeaf - has enough stuff mapped in to work. - */ + * The "+ sizeof( unsigned_32 )" is to make sure that the hllGetNumLeaf + * has enough stuff mapped in to work. + */ p = VMBlock( iih, ish->handle, sizeof( *p ) + sizeof( unsigned_32 ) ); if( p == NULL ) return( DS_ERR | DS_FAIL ); switch( p->common.code ) { case LF_ENUMERATE: hllGetNumLeaf( &p->enumerate + 1, &val ); - /* make sure everything is mapped in */ + /* + * make sure everything is mapped in + */ p = VMBlock( iih, ish->handle, val.size + sizeof( *p ) + sizeof( unsigned_32 ) ); if( p == NULL ) return( DS_ERR | DS_FAIL ); - /* VM might have shifted things around */ + /* + * VM might have shifted things around + */ hllGetNumLeaf( &p->enumerate + 1, &val ); memcpy( buff, val.valp, val.size ); return( DS_OK ); @@ -1124,7 +1152,9 @@ static walk_result WalkGlue( imp_image_handle *iih, sym_walk_info swi, } return( WR_CONTINUE ); } - /* SWI_SYMBOL: */ + /* + * SWI_SYMBOL: + */ switch( p->common.code ) { case LF_MEMBER: case LF_STMEMBER: @@ -1318,7 +1348,9 @@ static walk_result SymSearch( imp_image_handle *iih, sym_walk_info swi, } return( WR_CONTINUE ); } - /* SWI_SYMBOL */ + /* + * SWI_SYMBOL + */ switch( p->common.code ) { case LF_MEMBER: case LF_STMEMBER: @@ -1450,7 +1482,9 @@ imp_mod_handle DIPIMPENTRY( TypeMod )( imp_image_handle *iih, imp_type_handle *i static int IsFortranModule( imp_image_handle *iih, location_context *lc ) { - /* No fortran support */ + /* + * No fortran support + */ iih = iih; lc = lc; return( 0 ); @@ -1477,7 +1511,9 @@ dip_status hllTypeInfo( imp_image_handle *iih, imp_type_handle *ith, TypePrimitiveInfo( real.idx, ti ); return( DS_OK ); } - /* map in enough to get integer values from numeric leaves */ + /* + * map in enough to get integer values from numeric leaves + */ p = VMBlock( iih, real.handle, sizeof( *p ) + sizeof( unsigned_32 ) * 2 ); if( p == NULL ) return( DS_ERR | DS_FAIL ); @@ -1719,7 +1755,8 @@ static dip_status GetBound( imp_image_handle *iih, virt_mem vm, unsigned size, { /* unused parameters */ (void)iih; (void)vm; (void)size; (void)lc; (void)bound; -#if 0 /* FIXME */ +#if 0 + /* FIXME */ dip_status ds; imp_sym_handle bnd; bound_data data; @@ -1878,7 +1915,9 @@ static dip_status hllTypeArrayInfo( imp_image_handle *iih, ai->stride = 0; ai->num_dims = 0; ai->column_major = IsFortranModule( iih, lc ); - /* map in enough to get integer values from numeric leaves */ + /* + * map in enough to get integer values from numeric leaves + */ p = VMBlock( iih, real.handle, sizeof( *p ) + sizeof( unsigned_32 ) * 2 ); if( p == NULL ) return( DS_ERR | DS_FAIL ); @@ -2002,7 +2041,7 @@ dip_status DIPIMPENTRY( TypeProcInfo )( imp_image_handle *iih, dip_status DIPIMPENTRY( TypePtrAddrSpace )( imp_image_handle *iih, imp_type_handle *ith, location_context *lc, address *a ) { - /* unised parameters */ (void)iih; (void)ith; (void)lc; (void)a; + /* unused parameters */ (void)iih; (void)ith; (void)lc; (void)a; #if 0 lf_all *p; @@ -2080,7 +2119,9 @@ dip_status DIPIMPENTRY( TypePtrAddrSpace )( imp_image_handle *iih, a->mach.offset = 0; return( DS_OK ); case CV_BASETYPE: - //NYI: ???? + /* + * NYI: ???? + */ /* fall through */ case CV_BASESELF: return( DS_OK ); @@ -2123,7 +2164,9 @@ static walk_result ThunkSearch( imp_image_handle *iih, sym_walk_info swi, case SWI_SYMBOL: return( WR_CONTINUE ); } - /* SWI_INHERIT_START */ + /* + * SWI_INHERIT_START + */ p = VMBlock( iih, list->curr, list->len ); if( p == NULL ) return( WR_FAIL ); @@ -2211,7 +2254,7 @@ dip_status DIPIMPENTRY( TypeThunkAdjust )( imp_image_handle *iih, int DIPIMPENTRY( TypeCmp )( imp_image_handle *iih, imp_type_handle *ith1, imp_type_handle *ith2 ) { - /* unised parameters */ (void)iih; + /* unused parameters */ (void)iih; if( ith2->idx < ith1->idx ) return( -1 ); @@ -2260,21 +2303,21 @@ size_t DIPIMPENTRY( TypeName )( imp_image_handle *iih, imp_type_handle *ith, dip_status DIPIMPENTRY( TypeAddRef )( imp_image_handle *iih, imp_type_handle *ith ) { - /* unised parameters */ (void)iih; (void)ith; + /* unused parameters */ (void)iih; (void)ith; return( DS_OK ); } dip_status DIPIMPENTRY( TypeRelease )( imp_image_handle *iih, imp_type_handle *ith ) { - /* unised parameters */ (void)iih; (void)ith; + /* unused parameters */ (void)iih; (void)ith; return( DS_OK ); } dip_status DIPIMPENTRY( TypeFreeAll )( imp_image_handle *iih ) { - /* unised parameters */ (void)iih; + /* unused parameters */ (void)iih; return( DS_OK ); } diff --git a/bld/dip/hllcv/c/hllvirt.c b/bld/dip/hllcv/c/hllvirt.c index cba2f562f0..f91bd1709b 100644 --- a/bld/dip/hllcv/c/hllvirt.c +++ b/bld/dip/hllcv/c/hllvirt.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -100,24 +100,28 @@ void VMFini( imp_image_handle *iih ) } } -/* - * Adds a destructor to a block. - */ dip_status VMAddDtor( imp_image_handle *iih, virt_mem start, void ( *dtor )( imp_image_handle *iih, void *user ), void *user ) +/************************************************************************* + * Adds a destructor to a block. + */ { unsigned dir_idx; unsigned pg_idx; virt_page *pg; - /* locate the block. */ + /* + * locate the block. + */ dir_idx = GET_DIR( start ); if( iih->virt[dir_idx] != NULL ) { pg_idx = GET_PAGE( start ); pg = iih->virt[dir_idx][pg_idx]; if( pg != NULL ) { - /* create a new dtor node and link it in */ + /* + * create a new dtor node and link it in + */ vm_dtor *node = DCAlloc( sizeof( *node ) ); if( node != NULL ) { node->user = user; @@ -133,20 +137,23 @@ dip_status VMAddDtor( imp_image_handle *iih, virt_mem start, return( DS_ERR | DS_FAIL ); } -/* +static void vmFreeBlock( imp_image_handle *iih, virt_page *pg ) +/************************************************************** * Check for destructors and free the block. */ -static void vmFreeBlock( imp_image_handle *iih, virt_page *pg ) { - /* check for destructors */ + /* + * check for destructors + */ while( pg->block->first_dtor ) { struct vm_dtor *cur = pg->block->first_dtor; pg->block->first_dtor = cur->next; cur->dtor( iih, cur->user ); DCFree( cur ); } - - /* free */ + /* + * free + */ DCFree( pg ); } @@ -205,10 +212,14 @@ void *VMBlock( imp_image_handle *iih, virt_mem start, size_t len ) pg_start = start & ~(virt_mem)(VM_PAGE_SIZE - 1); pg = iih->virt[dir_idx][pg_idx]; if( pg == NULL || (pg->block->len - pg->offset) < len ) { - /* unloaded previously loaded block */ + /* + * unloaded previously loaded block + */ if( pg != NULL ) { tmp_idx = dir_idx; - /* find first page of the block */ + /* + * find first page of the block + */ i = pg_idx; for( ;; ) { iih->virt[tmp_idx][i] = NULL; @@ -229,7 +240,9 @@ void *VMBlock( imp_image_handle *iih, virt_mem start, size_t len ) DCStatus( DS_ERR | DS_NO_MEM ); return( NULL ); } - /* set up new page table entries */ + /* + * set up new page table entries + */ block = (loaded_block *)&pg[num_pages]; tmp_idx = dir_idx; for( j = pg_idx, pageno = 0; pageno < num_pages; ++j, ++pageno ) { @@ -241,7 +254,9 @@ void *VMBlock( imp_image_handle *iih, virt_mem start, size_t len ) } if( iih->virt[tmp_idx] == NULL ) { if( !InitPageDir( iih, tmp_idx ) ) { - /* unwind the setup already done */ + /* + * unwind the setup already done + */ num_pages = pageno; for( pageno = 0; pageno < num_pages; ++pageno, ++pg_idx ) { if( pg_idx >= DIR_SIZE ) { @@ -256,16 +271,18 @@ void *VMBlock( imp_image_handle *iih, virt_mem start, size_t len ) } if( iih->virt[tmp_idx][j] != NULL ) { /* - We just ran into another allocated block, so we have - to kill all the pages mapped in by it. We know that - if the page pointer is non-NULL, it will be offset==0 - since KillPages will clean out the others. - */ + * We just ran into another allocated block, so we have + * to kill all the pages mapped in by it. We know that + * if the page pointer is non-NULL, it will be offset==0 + * since KillPages will clean out the others. + */ KillPages( iih, tmp_idx, j ); } iih->virt[tmp_idx][j] = &pg[pageno]; } - /* read in new block */ + /* + * read in new block + */ len = num_pages * VM_PAGE_SIZE; block->len = len; block->first_dtor = NULL; @@ -274,7 +291,9 @@ void *VMBlock( imp_image_handle *iih, virt_mem start, size_t len ) DCStatus( DS_ERR | DS_FSEEK_FAILED ); return( NULL ); } - /* last block might be a short read */ + /* + * last block might be a short read + */ if( DCRead( iih->sym_fp, pg->block->data, len ) == DIG_RW_ERROR ) { DCStatus( DS_ERR | DS_FREAD_FAILED ); return( NULL ); @@ -283,7 +302,9 @@ void *VMBlock( imp_image_handle *iih, virt_mem start, size_t len ) } ++TimeStamp; if( TimeStamp == 0 ) { - /* deal with wrap-around */ + /* + * deal with wrap-around + */ for( iih = ImageList; iih != NULL; iih = iih->next_image ) { if( iih->virt != NULL ) { for( i = iih->vm_dir_num - 1; i >= 0; --i ) { @@ -304,10 +325,10 @@ void *VMBlock( imp_image_handle *iih, virt_mem start, size_t len ) return( &pg->block->data[(start & (VM_PAGE_SIZE - 1)) + pg->offset] ); } -/* +bool VMGetU8( imp_image_handle *iih, virt_mem start, unsigned_8 *valp ) +/********************************************************************** * Get a 8-bit value. */ -bool VMGetU8( imp_image_handle *iih, virt_mem start, unsigned_8 *valp ) { unsigned_8 *ptr = VMBlock( iih, start, sizeof(*valp) ); if( ptr ) { @@ -317,10 +338,10 @@ bool VMGetU8( imp_image_handle *iih, virt_mem start, unsigned_8 *valp ) return( false ); } -/* +bool VMGetU16( imp_image_handle *iih, virt_mem start, unsigned_16 *valp ) +/************************************************************************ * Get a 16-bit value. */ -bool VMGetU16( imp_image_handle *iih, virt_mem start, unsigned_16 *valp ) { unsigned_16 *ptr = VMBlock( iih, start, sizeof(*valp) ); if( ptr ) { @@ -330,10 +351,10 @@ bool VMGetU16( imp_image_handle *iih, virt_mem start, unsigned_16 *valp ) return( false ); } -/* +bool VMGetU32( imp_image_handle *iih, virt_mem start, unsigned_32 *valp ) +/************************************************************************ * Get a 32-bit value. */ -bool VMGetU32( imp_image_handle *iih, virt_mem start, unsigned_32 *valp ) { unsigned_32 *ptr = VMBlock( iih, start, sizeof(*valp) ); if( ptr ) { @@ -343,11 +364,11 @@ bool VMGetU32( imp_image_handle *iih, virt_mem start, unsigned_32 *valp ) return( false ); } -/* +void *VMRecord( imp_image_handle *iih, virt_mem rec_off, virt_mem *next_rec, unsigned_16 *sizep ) +/************************************************************************************************ * Gets a symbol scope table record. * Returns pointer to a hll_ssr_common structure on success. */ -void *VMRecord( imp_image_handle *iih, virt_mem rec_off, virt_mem *next_rec, unsigned_16 *sizep ) { unsigned_16 size = 0; unsigned_8 *p; @@ -372,10 +393,10 @@ void *VMRecord( imp_image_handle *iih, virt_mem rec_off, virt_mem *next_rec, uns return( p ); } -/* +void *VMSsBlock( imp_image_handle *iih, hll_dir_entry *hde, virt_mem start, size_t len ) +/*************************************************************************************** * Get a block within a section. */ -void *VMSsBlock( imp_image_handle *iih, hll_dir_entry *hde, virt_mem start, size_t len ) { if( start < hde->cb && start + len <= hde->cb ) { return( VMBlock( iih, hde->lfo + start, len ) ); @@ -383,10 +404,10 @@ void *VMSsBlock( imp_image_handle *iih, hll_dir_entry *hde, virt_mem start, size return( NULL ); } -/* +bool VMSsGetU8( imp_image_handle *iih, hll_dir_entry *hde, virt_mem start, unsigned_8 *valp ) +/******************************************************************************************** * Get a 8-bit value. */ -bool VMSsGetU8( imp_image_handle *iih, hll_dir_entry *hde, virt_mem start, unsigned_8 *valp ) { if( start < hde->cb ) { unsigned_8 *ptr = VMBlock( iih, hde->lfo + start, sizeof(*valp) ); @@ -398,10 +419,10 @@ bool VMSsGetU8( imp_image_handle *iih, hll_dir_entry *hde, virt_mem start, unsig return( false ); } -/* +bool VMSsGetU16( imp_image_handle *iih, hll_dir_entry *hde, virt_mem start, unsigned_16 *valp ) +/********************************************************************************************** * Get a 16-bit value. */ -bool VMSsGetU16( imp_image_handle *iih, hll_dir_entry *hde, virt_mem start, unsigned_16 *valp ) { if( start <= hde->cb - sizeof(*valp) ) { unsigned_16 *ptr = VMBlock( iih, hde->lfo + start, sizeof(*valp) ); @@ -413,10 +434,10 @@ bool VMSsGetU16( imp_image_handle *iih, hll_dir_entry *hde, virt_mem start, unsi return( false ); } -/* +bool VMSsGetU32( imp_image_handle *iih, hll_dir_entry *hde, virt_mem start, unsigned_32 *valp ) +/********************************************************************************************** * Get a 32-bit value. */ -bool VMSsGetU32( imp_image_handle *iih, hll_dir_entry *hde, virt_mem start, unsigned_32 *valp ) { if( start <= hde->cb - sizeof(*valp) ) { unsigned_32 *ptr = VMBlock( iih, hde->lfo + start, sizeof(*valp) ); @@ -428,12 +449,12 @@ bool VMSsGetU32( imp_image_handle *iih, hll_dir_entry *hde, virt_mem start, unsi return( false ); } -/* +void *VMSsRecord( imp_image_handle *iih, hll_dir_entry *hde, unsigned_32 rec_off, + unsigned_32 *next_rec, unsigned_16 *sizep ) +/******************************************************************************** * Gets a symbol scope table record. * Returns pointer to a hll_ssr_common structure on success. */ -void *VMSsRecord( imp_image_handle *iih, hll_dir_entry *hde, unsigned_32 rec_off, - unsigned_32 *next_rec, unsigned_16 *sizep ) { unsigned_16 size = 0; unsigned_8 *p = NULL; diff --git a/bld/dip/hllcv/h/hllinfo.h b/bld/dip/hllcv/h/hllinfo.h index 29c4a41d83..b6a2fb4e09 100644 --- a/bld/dip/hllcv/h/hllinfo.h +++ b/bld/dip/hllcv/h/hllinfo.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -115,7 +116,9 @@ typedef struct { unsigned is_16bit : 1; /* Set if this is a 16-bit segment. (not 100%?) */ } hllinfo_seg; -/* The NB level. */ +/* + * The NB level. + */ typedef enum { HLL_LVL_NB00 = 1, /* 16-bit codeview. */ HLL_LVL_NB00_32BIT, /* 32-bit codeview (cl386). */ @@ -123,7 +126,9 @@ typedef enum { HLL_LVL_NB04 /* 32-bit HLL */ } hllinfo_level; -/* Checks if the format level is 32-bit or 16-bit. */ +/* + * Checks if the format level is 32-bit or 16-bit. + */ #define HLL_IS_LVL_32BIT( format_lvl ) ( (format_lvl) == HLL_LVL_NB04 \ || (format_lvl) == HLL_LVL_NB00_32BIT ) diff --git a/bld/dip/javavm/c/jvmcue.c b/bld/dip/javavm/c/jvmcue.c index fae7057762..7d62ae51e6 100644 --- a/bld/dip/javavm/c/jvmcue.c +++ b/bld/dip/javavm/c/jvmcue.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2018 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -70,7 +70,9 @@ size_t DIPIMPENTRY( CueFile )( imp_image_handle *iih, size_t len; size_t class_len = 0; - /* Stick the package name on the front of the source file name */ + /* + * Stick the package name on the front of the source file name + */ name = GetPointer( icueh->cc + offsetof( ClassClass, name ) ); class_len = GetString( name, NameBuff, sizeof( NameBuff ) ); for( ;; ) { @@ -138,7 +140,9 @@ dip_status DIPIMPENTRY( CueAdjust )( imp_image_handle *iih, dst_icueh->ln_idx += adj; return( ds ); } - /* have to back up to previous method */ + /* + * have to back up to previous method + */ adj += backup; mb_idx = dst_icueh->mb_idx; if( mb_idx == 0 ) @@ -146,7 +150,9 @@ dip_status DIPIMPENTRY( CueAdjust )( imp_image_handle *iih, FillInLastIC( dst_icueh, mb_idx - 1 ); backup = dst_icueh->ln_idx + 1; } - /* have to wrap around to last method */ + /* + * have to wrap around to last method + */ ds = DS_WRAPPED; FillInLastIC( dst_icueh, GetNumMethods( dst_icueh ) - 1 ); backup = dst_icueh->ln_idx + 1; @@ -162,13 +168,17 @@ dip_status DIPIMPENTRY( CueAdjust )( imp_image_handle *iih, return( ds ); } adj -= mb.line_number_table_length - dst_icueh->ln_idx; - /* advance to next method */ + /* + * advance to next method + */ mb_idx = dst_icueh->mb_idx; if( mb_idx >= GetNumMethods( dst_icueh ) ) break; FillInFirstIC( dst_icueh, mb_idx + 1 ); } - /* have to wrap around to first method */ + /* + * have to wrap around to first method + */ ds = DS_WRAPPED; FillInFirstIC( dst_icueh, 0 ); } diff --git a/bld/dip/javavm/c/jvmmisc.c b/bld/dip/javavm/c/jvmmisc.c index 58a0ef837f..2a1c38fadf 100644 --- a/bld/dip/javavm/c/jvmmisc.c +++ b/bld/dip/javavm/c/jvmmisc.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -34,8 +34,8 @@ #include "jvmdip.h" /* - Misc. stuff. -*/ + * Misc. stuff. + */ const char DIPImp( Name )[] = "Java"; diff --git a/bld/dip/javavm/c/jvmmod.c b/bld/dip/javavm/c/jvmmod.c index 4bd6b49207..063f6a0289 100644 --- a/bld/dip/javavm/c/jvmmod.c +++ b/bld/dip/javavm/c/jvmmod.c @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -34,8 +35,9 @@ /* - This guy needs to be *FAST*. He's called from all over. -*/ + * This guy needs to be *FAST*. He's called from all over. + */ + search_result FindMBIndex( imp_image_handle *iih, addr_off off, unsigned *idx ) { ji_ptr code_start; diff --git a/bld/dip/javavm/c/jvmsupp.c b/bld/dip/javavm/c/jvmsupp.c index 1fd37cfa94..91ab6462c5 100644 --- a/bld/dip/javavm/c/jvmsupp.c +++ b/bld/dip/javavm/c/jvmsupp.c @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -200,8 +201,8 @@ unsigned long GetU32( ji_ptr off ) } /* - Tell the trap file to do a FindClass on the given class name -*/ + * Tell the trap file to do a FindClass on the given class name + */ ji_ptr GetClass( ji_ptr off ) { location_list src; diff --git a/bld/dip/javavm/c/jvmsym.c b/bld/dip/javavm/c/jvmsym.c index e576a01ce4..5780111b4f 100644 --- a/bld/dip/javavm/c/jvmsym.c +++ b/bld/dip/javavm/c/jvmsym.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -62,7 +62,9 @@ static walk_result WalkObject( imp_image_handle *iih, bool statics_only, iih->object_class = super; } } - /* Don't bother walking java.lang.Object fields - nothing interesting */ + /* + * Don't bother walking java.lang.Object fields - nothing interesting + */ if( super != iih->object_class ) { wr = wk( iih, SWI_INHERIT_START, ish, d ); if( wr == WR_CONTINUE ) { @@ -73,7 +75,9 @@ static walk_result WalkObject( imp_image_handle *iih, bool statics_only, } } } - /* walk the fields */ + /* + * walk the fields + */ block = GetPointer( clazz + offsetof( ClassClass, fields ) ); num = GetU16( clazz + offsetof( ClassClass, fields_count ) ); ish->kind = JS_FIELD; @@ -90,14 +94,18 @@ static walk_result WalkObject( imp_image_handle *iih, bool statics_only, return( wr ); } } - /* walk the methods */ + /* + * walk the methods + */ block = GetPointer( clazz + offsetof( ClassClass, methods ) ); num = GetU16( clazz + offsetof( ClassClass, methods_count ) ); ish->kind = JS_METHOD; for( i = 0; i < num; ++i ) { acc = GetU16( block + offsetof( struct methodblock, fb.access ) ); if( !(acc & ACC_NATIVE) ) { - /* Don't bother telling debugger about native methods */ + /* + * Don't bother telling debugger about native methods + */ ish->u.mb = block; wr = wk( iih, SWI_SYMBOL, ish, d ); if( wr != WR_CONTINUE ) { @@ -212,7 +220,9 @@ walk_result DIPIMPENTRY( WalkSymList )( imp_image_handle *iih, } return( wr ); case SS_MODULE: - /* no module scope symbols in Java */ + /* + * no module scope symbols in Java + */ break; case SS_SCOPED: a = source; @@ -451,8 +461,9 @@ dip_status FollowObject( ji_ptr sig, location_list *ll, ji_ptr *handle ) unsigned len; Classjava_lang_String str; - /* follow the object pointer(s) */ - + /* + * follow the object pointer(s) + */ if( sig == 0 ) return( DS_OK ); len = GetString( sig, NameBuff, sizeof( NameBuff ) ); @@ -474,7 +485,9 @@ dip_status FollowObject( ji_ptr sig, location_list *ll, ji_ptr *handle ) } if( NameBuff[0] == SIGNATURE_CLASS && memcmp( &NameBuff[1], JAVA_STRING_NAME, sizeof( JAVA_STRING_NAME ) - 1 ) == 0 ) { - /* Got a string, get pointer to actual character storage */ + /* + * Got a string, get pointer to actual character storage + */ *handle = ll->e[0].u.addr.mach.offset; ds = GetData( ll->e[0].u.addr.mach.offset, &str, sizeof( str ) ); if( ds != DS_OK ) @@ -676,7 +689,9 @@ dip_status DIPIMPENTRY( SymObjLocation )( imp_image_handle *iih, imp_sym_handle cp = GetPointer( (ji_ptr)method.fb.clazz + offsetof( ClassClass, constantpool ) ); this_ish.kind = JS_LOCAL; this_ish.u.lv = (ji_ptr)method.localvar_table; - /* guessing "this" pointer is near start of local var list */ + /* + * guessing "this" pointer is near start of local var list + */ for( i = 0; i < method.localvar_table_length; ++i ) { cp_idx = GetU16( this_ish.u.lv + offsetof( struct localvar, nameoff ) ); name = GetPointer( cp + cp_idx * sizeof( union cp_item_type ) ); @@ -790,7 +805,9 @@ static search_result CheckScopeName( struct lookup_data *ld ) } if( have_multi ) return( SR_NONE ); - /* Try the last element of the package name */ + /* + * Try the last element of the package name + */ i = pk_len - j; if( i == 0 ) return( SR_NONE ); @@ -869,7 +886,7 @@ search_result DIPIMPENTRY( LookupSym )( imp_image_handle *iih, switch( ss ) { case SS_MODULE: data.static_only = 1; -// return( SR_NONE ); +// return( SR_NONE ); /* fall through */ case SS_SCOPED: switch( li->type ) { @@ -989,10 +1006,14 @@ static search_result FindAScope( imp_image_handle *iih, scope_block *scope ) if( (off >= cache[i].pc0) && (off < (cache[i].pc0 + cache[i].length)) && (scope->unique > (idx+i)) ) { - /* in range & not the same as a previous scope */ + /* + * in range & not the same as a previous scope + */ if( (cache[i].pc0 > best.pc) || (cache[i].pc0 == best.pc && cache[i].length < best.len) ) { - /* better than best */ + /* + * better than best + */ best.pc = cache[i].pc0; best.len = cache[i].length; best.idx = idx + i; diff --git a/bld/dip/mapsym/c/msymcue.c b/bld/dip/mapsym/c/msymcue.c index 87007b0fe4..1ffa6acfaf 100644 --- a/bld/dip/mapsym/c/msymcue.c +++ b/bld/dip/mapsym/c/msymcue.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2018 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -32,7 +32,8 @@ #include "msym.h" -/* Note: MAPSYM .sym files do suppport rudimentary line number information. +/* + * Note: MAPSYM .sym files do suppport rudimentary line number information. * However we do not support this for two reasons: One, most .sym files do not * include line number information, and two, the .sym format is so pathetic * that anyone who actually has source code will definitely want to use some diff --git a/bld/dip/mapsym/c/msymld.c b/bld/dip/mapsym/c/msymld.c index 13af2def6f..b1f2ee8d00 100644 --- a/bld/dip/mapsym/c/msymld.c +++ b/bld/dip/mapsym/c/msymld.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -37,18 +37,19 @@ #include "exeflat.h" -/* Implementation notes: +/* + * Implementation notes: * * - Symbol files may contain multiple maps. This is not supported because * I've never seen such a .sym file and I don't even know how to produce one. */ #if defined( __WATCOMC__ ) && defined( __386__ ) - -/* WD looks for this symbol to determine module bitness */ +/* + * WD looks for this symbol to determine module bitness + */ int __nullarea; #pragma aux __nullarea "*"; - #endif static struct { @@ -240,18 +241,24 @@ static dip_status AddSymbol( imp_image_handle *iih, addr_seg seg, addr_off off, return( DS_OK ); } -/* Heuristics to determine whether given file is a MAPSYM .sym file */ static dip_status CheckSymFile( FILE *fp ) +/* + * Heuristics to determine whether given file is a MAPSYM .sym file + */ { sym_endmap end_map; unsigned long pos; - /* seek to the end, read and check end map record */ + /* + * seek to the end, read and check end map record + */ if( DCSeek( fp, DIG_SEEK_POSBACK( sizeof( end_map ) ), DIG_SEEK_END ) ) { return( DS_ERR | DS_FSEEK_FAILED ); } pos = DCTell( fp ); - /* the endmap record must be 16-byte aligned */ + /* + * the endmap record must be 16-byte aligned + */ if( pos % 16 ) { return( DS_FAIL ); } @@ -261,8 +268,8 @@ static dip_status CheckSymFile( FILE *fp ) if( end_map.zero != 0 ) { return( DS_FAIL ); } - - /* Check .sym file version. The version number seems to correspond to + /* + * Check .sym file version. The version number seems to correspond to * the linker version. Versions 3.10, 4.0, 5.10, 5.11, 6.0, 6.10 have * been seen. Version 5.1 seems to be identical to 4.0 with added * support for 32-bit symbols. @@ -270,13 +277,16 @@ static dip_status CheckSymFile( FILE *fp ) if( (end_map.major_ver < 3) || (end_map.major_ver > 6) || (end_map.minor_ver > 11) ) { return( DS_FAIL ); } - - /* looks like the right sort of .sym file */ + /* + * looks like the right sort of .sym file + */ return( DS_OK ); } -/* Read a Pascal style string - limited to 255 chars max length */ static dip_status ReadString( FILE *fp, char *buf, unsigned *len_ptr ) +/********************************************************************* + * Read a Pascal style string - limited to 255 chars max length + */ { unsigned_8 str_len; @@ -292,10 +302,12 @@ static dip_status ReadString( FILE *fp, char *buf, unsigned *len_ptr ) return( DS_OK ); } -/* Load symbols for a segment */ static dip_status LoadSymTable( FILE *fp, imp_image_handle *iih, unsigned count, unsigned long base_ofs, unsigned_32 table_ofs, addr_seg seg, int big_syms ) +/******************************************************************************* + * Load symbols for a segment + */ { dip_status ds; unsigned_16 *sym_tbl; @@ -370,8 +382,10 @@ static dip_status LoadSymTable( FILE *fp, imp_image_handle *iih, unsigned count, return( ds ); } -/* Load all segments for a map */ static dip_status LoadSegments( FILE *fp, imp_image_handle *iih, int count ) +/*************************************************************************** + * Load all segments for a map + */ { dip_status ds; sym_segdef seg; @@ -392,8 +406,8 @@ static dip_status LoadSegments( FILE *fp, imp_image_handle *iih, int count ) ds = ReadString( fp, name, &name_len ); if( ds != DS_OK ) return( ds ); - - /* There's no good way to tell whether segment is code or data. Try + /* + * There's no good way to tell whether segment is code or data. Try * to guess what a segment is based on its name. */ if( strcmp( name, "DGROUP" ) == 0 ) { @@ -415,8 +429,10 @@ static dip_status LoadSegments( FILE *fp, imp_image_handle *iih, int count ) return( DS_OK ); } -/* Load all symbols in a .sym file */ static dip_status LoadSymFile( FILE *fp, imp_image_handle *iih ) +/*************************************************************** + * Load all symbols in a .sym file + */ { dip_status ds; sym_mapdef map; @@ -426,8 +442,9 @@ static dip_status LoadSymFile( FILE *fp, imp_image_handle *iih ) if( BSeek( fp, 0, DIG_SEEK_ORG ) == DIG_SEEK_ERROR ) { return( DS_ERR | DS_FSEEK_FAILED ); } - - /* Read the first map and use its name as the module name */ + /* + * Read the first map and use its name as the module name + */ if( BRead( fp, &map, SYM_MAPDEF_FIXSIZE ) != SYM_MAPDEF_FIXSIZE ) { return( DS_ERR | DS_FREAD_FAILED ); } @@ -467,7 +484,9 @@ dip_status DIPIMPENTRY( LoadInfo )( FILE *fp, imp_image_handle *iih ) if( ds != DS_OK ) { DCStatus( ds ); - /* clean up any allocations */ + /* + * clean up any allocations + */ ImpUnloadInfo( iih ); return( ds ); } diff --git a/bld/dip/mapsym/c/msymtype.c b/bld/dip/mapsym/c/msymtype.c index 24437147a9..0871271856 100644 --- a/bld/dip/mapsym/c/msymtype.c +++ b/bld/dip/mapsym/c/msymtype.c @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -32,7 +33,8 @@ #include "msym.h" -/* Note: Not much to do here. Could possibly try to guess data vs. code by +/* + * Note: Not much to do here. Could possibly try to guess data vs. code by * looking at segment names, but results would not necessarily be accurate. */ diff --git a/bld/dip/mapsym/h/msym.h b/bld/dip/mapsym/h/msym.h index 15553f7dd6..830c7377d0 100644 --- a/bld/dip/mapsym/h/msym.h +++ b/bld/dip/mapsym/h/msym.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -48,17 +49,23 @@ typedef struct msym_block msym_block; typedef struct msym_hunk msym_hunk; struct imp_sym_handle { - /* any stuff for getting information on symbols */ + /* + * any stuff for getting information on symbols + */ msym_sym *p; }; struct imp_type_handle { - /* any stuff for getting information on types */ + /* + * any stuff for getting information on types + */ unsigned_8 code; }; struct imp_cue_handle { - /* any stuff for getting information on source line cues */ + /* + * any stuff for getting information on source line cues + */ void *p; }; diff --git a/bld/dip/mapsym/util/symdump.c b/bld/dip/mapsym/util/symdump.c index 2eb8fb8ed6..c275631ee7 100644 --- a/bld/dip/mapsym/util/symdump.c +++ b/bld/dip/mapsym/util/symdump.c @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -39,20 +40,26 @@ static bool DumpAlphaSorted = false; // dump alphabetically sorted sym tables -/* Heuristics to determine whether a file is a MAPSYM .sym file */ static bool isSymFile( FILE *f ) +/******************************* + * Heuristics to determine whether a file is a MAPSYM .sym file + */ { sym_endmap end_map; int ret; unsigned long pos; - /* seek to the end, read and check end map record */ + /* + * seek to the end, read and check end map record + */ ret = fseek( f, -(long)sizeof( end_map ), SEEK_END ); if( ret != 0 ) { return( false ); } pos = ftell( f ); - /* the endmap record must be 16-byte aligned */ + /* + * the endmap record must be 16-byte aligned + */ if( pos % 16 ) { return( false ); } @@ -62,18 +69,23 @@ static bool isSymFile( FILE *f ) if( end_map.zero != 0 ) { return( false ); } - /* Check .sym file version to make sure it's something reasonable */ + /* + * Check .sym file version to make sure it's something reasonable + */ if( (end_map.major_ver < 3) || (end_map.major_ver > 6) || (end_map.minor_ver > 12) ) { return( false ); } - - /* looks like the right sort of .sym file */ + /* + * looks like the right sort of .sym file + */ return( true ); } -// Read a Pascal style string - limited to 255 chars max length static int readString( FILE *f, char *buf ) +/****************************************** + * Read a Pascal style string - limited to 255 chars max length + */ { unsigned_8 str_len; @@ -184,8 +196,8 @@ static void dumpSegments( FILE *f, int count ) SYM_PTR_TO_OFS( seg.linnum_ptr ), seg.is_loaded, seg.curr_inst ); sym_tab_offset = seg.sym_tab_ofs; - - /* if alphabetically sorted symbol table is present, it'll be right after + /* + * if alphabetically sorted symbol table is present, it'll be right after * the first table (which is sorted by address) */ if( DumpAlphaSorted && (seg.sym_type & SYM_FLAG_ALPHA) ) { diff --git a/bld/dip/skel/c/skelcue.c b/bld/dip/skel/c/skelcue.c index 36a7da985b..c52640a5c7 100644 --- a/bld/dip/skel/c/skelcue.c +++ b/bld/dip/skel/c/skelcue.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2018 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -34,169 +34,183 @@ #include "skel.h" /* - Stuff for source line cues -*/ + * Stuff for source line cues + */ walk_result DIPIMPENTRY( WalkFileList )( imp_image_handle *iih, imp_mod_handle imh, DIP_IMP_CUE_WALKER *wk, imp_cue_handle *icueh, void *d ) +/********************************************************************************** + * TODO: + * + * PSEUDO-CODE: + * + * for( each source file in the given module ) { + * *icueh = fill in cue handle information for the first + * source cue for the file; + * wr = wk( iih, icueh, d ); + * if( wr != WR_CONTINUE ) { + * return( wr ); + * } + * } + */ { - //TODO: - /* - PSEUDO-CODE: - - for( each source file in the given module ) { - *icueh = fill in cue handle information for the first - source cue for the file; - wr = wk( iih, icueh, d ); - if( wr != WR_CONTINUE ) { - return( wr ); - } - } - */ return( WR_CONTINUE ); } imp_mod_handle DIPIMPENTRY( CueMod )( imp_image_handle *iih, imp_cue_handle *icueh ) +/*********************************************************************************** + * TODO: + * + * Return the module the source cue comes from. + */ { - //TODO: - /* - Return the module the source cue comes from. - */ - return( IMH_NOMOD ); + return( IMH_NOMOD ); } size_t DIPIMPENTRY( CueFile )( imp_image_handle *iih, imp_cue_handle *icueh, char *buff, size_t buff_size ) +/********************************************************************************************************** + * TODO: + * + * Given the imp_cue_handle, copy the name of the source file into 'buff'. + * Do not copy more than 'buff_size' - 1 characters into the buffer and + * append a trailing '\0' character. Return the real length + * of the file name (not including the trailing '\0' character) even + * if you had to truncate it to fit it into the buffer. If something + * went wrong and you can't get the module name, call DCStatus and + * return zero. + * + * NOTE: the client might pass in zero for 'buff_size'. In that + * case, just return the length of the file name and do not attempt + * to put anything into the buffer. + */ { - /* - Given the imp_cue_handle, copy the name of the source file into 'buff'. - Do not copy more than 'buff_size' - 1 characters into the buffer and - append a trailing '\0' character. Return the real length - of the file name (not including the trailing '\0' character) even - if you had to truncate it to fit it into the buffer. If something - went wrong and you can't get the module name, call DCStatus and - return zero. NOTE: the client might pass in zero for 'buff_size'. In that - case, just return the length of the file name and do not attempt - to put anything into the buffer. - */ return( 0 ); } cue_fileid DIPIMPENTRY( CueFileId )( imp_image_handle *iih, imp_cue_handle *icueh ) +/********************************************************************************** + * TODO: + * + * Given a imp_cue_handle, return a cue_fileid. The cue_fileid is + * an unsigned_32 magic cookie as far as the client is concerned, + * except that the value zero is reserved to indicate "no file". + * The client might pass the cue_fileid back to the LineCue + * function, or use it as a quick test to see if the source file + * has changed by comparing it against a previously returned value. + */ { - //TODO: - /* - Given a imp_cue_handle, return a cue_fileid. The cue_fileid is - an unsigned_32 magic cookie as far as the client is concerned, - except that the value zero is reserved to indicate "no file". - The client might pass the cue_fileid back to the LineCue - function, or use it as a quick test to see if the source file - has changed by comparing it against a previously returned value. - */ return( 0 ); } dip_status DIPIMPENTRY( CueAdjust )( imp_image_handle *iih, imp_cue_handle *src_icueh, int adj, imp_cue_handle *dst_icueh ) +/****************************************************************************** + * TODO: + * + * Adjust the 'src' cue by 'adj' amount and return the result in 'dst'. + * That is, If you get called with "DIPImpCueAdjust( iih, src, 1, dst )", + * the 'dst' handle should be filled in with implementation cue handle + * representing the source cue immediately following the 'src' cue. + * Passing in an 'adj' of -1 will get the immediately preceeding source + * cue. The list of source cues for each file are considered a ring, + * so if 'src' is the first cue in a file, an 'adj' of -1 will return + * the last source cue FOR THAT FILE. The cue adjust never crosses a + * file boundry. Also, if 'src' is the last cue in a file, and 'adj' of + * 1 will get the first source cue FOR THAT FILE. If an adjustment + * causes a wrap from begining to end or vis-versa, you should return + * DS_WRAPPED status (NOTE: DS_ERR should *not* be or'd in, nor should + * DCStatus be called in this case). Otherwise DS_OK should be returned + * unless an error occurred. + */ { - //TODO: - /* - Adjust the 'src' cue by 'adj' amount and return the result in 'dst'. - That is, If you get called with "DIPImpCueAdjust( iih, src, 1, dst )", - the 'dst' handle should be filled in with implementation cue handle - representing the source cue immediately following the 'src' cue. - Passing in an 'adj' of -1 will get the immediately preceeding source - cue. The list of source cues for each file are considered a ring, - so if 'src' is the first cue in a file, an 'adj' of -1 will return - the last source cue FOR THAT FILE. The cue adjust never crosses a - file boundry. Also, if 'src' is the last cue in a file, and 'adj' of - 1 will get the first source cue FOR THAT FILE. If an adjustment - causes a wrap from begining to end or vis-versa, you should return - DS_WRAPPED status (NOTE: DS_ERR should *not* be or'd in, nor should - DCStatus be called in this case). Otherwise DS_OK should be returned - unless an error occurred. - */ return( DS_ERR | DS_FAIL ); } unsigned long DIPIMPENTRY( CueLine )( imp_image_handle *iih, imp_cue_handle *icueh ) +/*********************************************************************************** + * TODO: + * + * Return the line number of source cue. Return zero if there + * is no line number associated with the cue, or an error occurs in + * getting the information. + */ { - //TODO: - /* - Return the line number of source cue. Return zero if there - is no line number associated with the cue, or an error occurs in - getting the information. - */ return( 0 ); } unsigned DIPIMPENTRY( CueColumn )( imp_image_handle *iih, imp_cue_handle *icueh ) +/******************************************************************************** + * TODO: + * + * Return the column number of source cue. Return zero if there + * is no column number associated with the cue, or an error occurs in + * getting the information. + */ { - //TODO: - /* - Return the column number of source cue. Return zero if there - is no column number associated with the cue, or an error occurs in - getting the information. - */ return( 0 ); } address DIPIMPENTRY( CueAddr )( imp_image_handle *iih, imp_cue_handle *icueh ) +/***************************************************************************** + * TODO: + * + * Return the address of source cue. Return NilAddr if there + * is no address associated with the cue, or an error occurs in + * getting the information. + */ { - //TODO: - /* - Return the address of source cue. Return NilAddr if there - is no address associated with the cue, or an error occurs in - getting the information. - */ return( NilAddr ); } search_result DIPIMPENTRY( LineCue )( imp_image_handle *iih, imp_mod_handle imh, cue_fileid file, unsigned long line, unsigned column, imp_cue_handle *icueh ) +/*********************************************************************** + * TODO: + * + * Search for a source cue in the given module. If 'file' is zero, + * use the main source file of the module. If 'line' is zero, use the + * first line with a source cue in the given file. If 'column' is + * zero, use the first column with a source cue in the given line. + * Fill in the '*icueh' handle with the result. If there was a cue at + * exactly the file/line/column specified return SR_EXACT. If there + * are cues with in the file with a line/column less than the given + * values, return the largest cue possible that is less then the + * passed in values and return SR_CLOSEST. If there are no cues with + * the proper characteristics, return SR_NONE + */ { - //TODO: - /* - Search for a source cue in the given module. If 'file' is zero, - use the main source file of the module. If 'line' is zero, use the - first line with a source cue in the given file. If 'column' is - zero, use the first column with a source cue in the given line. - Fill in the '*icueh' handle with the result. If there was a cue at - exactly the file/line/column specified return SR_EXACT. If there - are cues with in the file with a line/column less than the given - values, return the largest cue possible that is less then the - passed in values and return SR_CLOSEST. If there are no cues with - the proper characteristics, return SR_NONE - */ return( SR_NONE ); } search_result DIPIMPENTRY( AddrCue )( imp_image_handle *iih, imp_mod_handle imh, address addr, imp_cue_handle *icueh ) +/*********************************************************************** + * TODO: + * + * Search for the closest cue in the given module that has an address + * less then or equal to the given address. If there is no such cue + * return SR_NONE. If there is one exactly at the address return + * SR_EXACT. Otherwise, return SR_CLOSEST. + */ { - //TODO: - /* - Search for the closest cue in the given module that has an address - less then or equal to the given address. If there is no such cue - return SR_NONE. If there is one exactly at the address return - SR_EXACT. Otherwise, return SR_CLOSEST. - */ return( SR_NONE ); } int DIPIMPENTRY( CueCmp )( imp_image_handle *iih, imp_cue_handle *icueh1, imp_cue_handle *icueh2 ) +/************************************************************************************************* + * TODO: + * + * Compare two cue handles and return 0 if they refer to the same + * information. If they refer to differnt things return either a + * positive or negative value to impose an 'order' on the information. + * The value should obey the following constraints. + * Given three handles H1, H2, H3: + * - if H1 < H2 then H1 is always < H2 + * - if H1 < H2 and H2 < H3 then H1 is < H3 + * The reason for the constraints is so that a client can sort a + * list of handles and binary search them. + */ { - //TODO: - /* - Compare two cue handles and return 0 if they refer to the same - information. If they refer to differnt things return either a - positive or negative value to impose an 'order' on the information. - The value should obey the following constraints. - Given three handles H1, H2, H3: - - if H1 < H2 then H1 is always < H2 - - if H1 < H2 and H2 < H3 then H1 is < H3 - The reason for the constraints is so that a client can sort a - list of handles and binary search them. - */ return( 0 ); } diff --git a/bld/dip/skel/c/skelld.c b/bld/dip/skel/c/skelld.c index c6c550577d..7097355297 100644 --- a/bld/dip/skel/c/skelld.c +++ b/bld/dip/skel/c/skelld.c @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -33,48 +34,50 @@ #include "skel.h" /* - Loading/unloading symbolic information. -*/ + * Loading/unloading symbolic information. + */ dip_status DIPIMPENTRY( LoadInfo )( FILE *fp, imp_image_handle *iih ) +/******************************************************************** + * TODO: + * + * See if the given file handle has our kind of symbolic information + * on it. If so, fill in the "*iih" structure and return DS_OK. If it + * isn't our type of information, return DS_FAIL. If it's our information, + * but something goes wrong during the load, return a DS_ERR | DS_? + * constant. If the load succeeds the client will not close the + * file handle so if you don't need to read out of the file after the + * load, you should close the handle at this point. + */ { - //TODO: - /* - See if the given file handle has our kind of symbolic information - on it. If so, fill in the "*iih" structure and return DS_OK. If it - isn't our type of information, return DS_FAIL. If it's our information, - but something goes wrong during the load, return a DS_ERR | DS_? - constant. If the load succeeds the client will not close the - file handle so if you don't need to read out of the file after the - load, you should close the handle at this point. - - */ return( DS_FAIL ); } void DIPIMPENTRY( MapInfo )( imp_image_handle *iih, void *d ) +/************************************************************ + * TODO: + * + * After the symbolic information has been loaded, any addresses + * must be relocated from the map values that the linker put in to + * the actual load time addresses. The client is not always able to + * perform the relocation at the time it loads the information, so + * it calls this entry point when it has all the information required. + * The 'd' parameter is a magic cookie for the client. Just pass it + * on as the second parameter of the DCMapAddr function when you call + * it. + */ { - //TODO: - /* - After the symbolic information has been loaded, any addresses - must be relocated from the map values that the linker put in to - the actual load time addresses. The client is not always able to - perform the relocation at the time it loads the information, so - it calls this entry point when it has all the information required. - The 'd' parameter is a magic cookie for the client. Just pass it - on as the second parameter of the DCMapAddr function when you call - it. - */ } void DIPIMPENTRY( UnloadInfo )( imp_image_handle *iih ) +/****************************************************** + * TODO: + * + * The indicated image is going away. Free any structures pointed to + * by the 'iih' parameter. Don't try and free the 'iih' pointer itself. + * The DIP manager will take care of that. If you hung onto the file + * handle passed in to the DIPImpLoadInfo function, you should close + * it now. + */ { - //TODO: - /* - The indicated image is going away. Free any structures pointed to - by the 'iih' parameter. Don't try and free the 'iih' pointer itself. - The DIP manager will take care of that. If you hung onto the file - handle passed in to the DIPImpLoadInfo function, you should close - it now. - */ } diff --git a/bld/dip/skel/c/skelmisc.c b/bld/dip/skel/c/skelmisc.c index e4c4dc2fc7..ea96cd03f9 100644 --- a/bld/dip/skel/c/skelmisc.c +++ b/bld/dip/skel/c/skelmisc.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -34,18 +34,19 @@ #include "skel.h" /* - Misc. stuff. -*/ + * Misc. stuff. + */ const char DIPImp( Name )[] = "Put the name of your DIP here"; unsigned DIPIMPENTRY( HandleSize )( handle_kind hk ) +/*************************************************** + * TODO: + * + * Return the sizes of the individual handle types. This version + * should be OK as given. + */ { - //TODO: -/* - Return the sizes of the individual handle types. This version - should be OK as given. -*/ static unsigned_8 Sizes[] = { #define pick(enum,hsize,ihsize,wvihsize,cvdmndtype,wdmndtype) ihsize, #include "diphndls.h" @@ -56,38 +57,42 @@ unsigned DIPIMPENTRY( HandleSize )( handle_kind hk ) } dip_status DIPIMPENTRY( MoreMem )( size_t size ) +/*********************************************** + * TODO: + * + * Return DS_OK if you could release some memory, DS_FAIL if you + * couldn't. + */ { - //TODO: -/* - Return DS_OK if you could release some memory, DS_FAIL if you - couldn't. -*/ return( DS_FAIL ); } dip_status DIPImp( Startup )( void ) +/*********************************** + * TODO: + * + * Return DS_OK if startup initialization when OK, or a DS_ERR | DS_? + * constant if something went wrong. + */ { - //TODO: -/* - Return DS_OK if startup initialization when OK, or a DS_ERR | DS_? - constant if something went wrong. -*/ return( DS_OK ); } void DIPIMPENTRY( Shutdown )( void ) +/*********************************** + * TODO: + * + * Shutting down and unloading. Last chance to free up stuff. + */ { - //TODO: -/* - Shutting down and unloading. Last chance to free up stuff. -*/ } void DIPIMPENTRY( Cancel )( void ) +/********************************* + * TODO: + * + * The client is about to longjmp, and may bypass + * returns through the DIP. All handles remain valid though. + */ { - //TODO: -/* - The client is about to longjmp, and may bypass - returns through the DIP. All handles remain valid though. -*/ } diff --git a/bld/dip/skel/c/skelmod.c b/bld/dip/skel/c/skelmod.c index 581fcd457c..54b0924e1c 100644 --- a/bld/dip/skel/c/skelmod.c +++ b/bld/dip/skel/c/skelmod.c @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -34,98 +35,108 @@ /* - Stuff dealing with module handles -*/ -walk_result DIPIMPENTRY( WalkModList )( imp_image_handle *iih, - DIP_IMP_MOD_WALKER *wk, void *d ) -{ - //TODO: - /* PSEUDO-CODE: + * Stuff dealing with module handles + */ - for( each module in 'iih' ) { - im = implementation module handle for module; - wr = wk( iih, im, d ); - if( wr != WR_CONTINUE ) { - return( wr ); - } - } - */ +walk_result DIPIMPENTRY( WalkModList )( imp_image_handle *iih, DIP_IMP_MOD_WALKER *wk, void *d ) +/*********************************************************************************************** + * TODO: + * + * PSEUDO-CODE: + * + * for( each module in 'iih' ) { + * im = implementation module handle for module; + * wr = wk( iih, im, d ); + * if( wr != WR_CONTINUE ) { + * return( wr ); + * } + * } + */ +{ return( WR_CONTINUE ); } size_t DIPIMPENTRY( ModName )( imp_image_handle *iih, imp_mod_handle imh, char *buff, size_t buff_size ) +/************************************************************************* + * TODO: + * + * Given the imp_mod_handle, copy the name of the module into 'buff'. + * Do not copy more than 'buff_size' - 1 characters into the buffer and + * append a trailing '\0' character. Return the real length + * of the module name (not including the trailing '\0' character) even + * if you had to truncate it to fit it into the buffer. If something + * went wrong and you can't get the module name, call DCStatus and + * return zero. + * + * NOTE: the client might pass in zero for 'buff_size'. In that + * case, just return the length of the module name and do not attempt + * to put anything into the buffer. + */ { - //TODO: - /* - Given the imp_mod_handle, copy the name of the module into 'buff'. - Do not copy more than 'buff_size' - 1 characters into the buffer and - append a trailing '\0' character. Return the real length - of the module name (not including the trailing '\0' character) even - if you had to truncate it to fit it into the buffer. If something - went wrong and you can't get the module name, call DCStatus and - return zero. NOTE: the client might pass in zero for 'buff_size'. In that - case, just return the length of the module name and do not attempt - to put anything into the buffer. - */ return( 0 ); } char *DIPIMPENTRY( ModSrcLang )( imp_image_handle *iih, imp_mod_handle imh ) +/*************************************************************************** + * TODO: + * + * Return a pointer to a string naming the source language of the + * module. Currently allowed names are "c", "cpp", and "fortran". + */ { - //TODO: - /* - Return a pointer to a string naming the source language of the - module. Currently allowed names are "c", "cpp", and "fortran". - */ return( "c" ); } dip_status DIPIMPENTRY( ModInfo )( imp_image_handle *iih, imp_mod_handle imh, handle_kind hk ) +/******************************************************************* + * TODO: + * + * Return DS_OK if the module has the kind of information indicated + * by 'hk', DS_FAIL if it does not. + */ { - //TODO: - /* - Return DS_OK if the module has the kind of information indicated - by 'hk', DS_FAIL if it does not. - */ return( DS_FAIL ); } search_result DIPIMPENTRY( AddrMod )( imp_image_handle *iih, address a, imp_mod_handle *imh ) +/********************************************************************** + * TODO: + * + * Given an address, find the module which defines that address and + * assign the implemenation module handle to '*imh'. Return SR_EXACT + * or SR_CLOSEST. If no module for the image defines the address, + * return SR_NONE. + */ { - //TODO: - /* - Given an address, find the module which defines that address and - assign the implemenation module handle to '*imh'. Return SR_EXACT - or SR_CLOSEST. If no module for the image defines the address, - return SR_NONE. - */ return( SR_NONE ); } address DIPIMPENTRY( ModAddr )( imp_image_handle *iih, imp_mod_handle imh ) +/************************************************************************** + * TODO: + * + * Given a module, return the first address off one of it's code segments. + * Practically speaking, we're looking for the address of the first line + * source cue in the file. + */ { - //TODO: - /* - Given a module, return the first address off one of it's code segments. - Practically speaking, we're looking for the address of the first line - source cue in the file. - */ return( NilAddr ); } dip_status DIPIMPENTRY( ModDefault )( imp_image_handle *iih, imp_mod_handle imh, default_kind dk, dig_type_info *ti ) +/*********************************************************************** + * TODO: + * + * Return the default type information for indicated type. The + * client uses this to figure out how big a default 'int', code pointer, + * and data pointer should be. The information depends on whether + * the 16 or 32-bit compiler was used, and what memory model the + * source file was compiled with. + */ { - //TODO: - /* - Return the default type information for indicated type. The - client uses this to figure out how big a default 'int', code pointer, - and data pointer should be. The information depends on whether - the 16 or 32-bit compiler was used, and what memory model the - source file was compiled with. - */ return( DS_FAIL ); } diff --git a/bld/dip/skel/c/skelsym.c b/bld/dip/skel/c/skelsym.c index 0feb0b30d3..fee5068f19 100644 --- a/bld/dip/skel/c/skelsym.c +++ b/bld/dip/skel/c/skelsym.c @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -34,86 +35,86 @@ /* - Stuff dealing with symbol handles. -*/ - + * Stuff dealing with symbol handles. + */ walk_result DIPIMPENTRY( WalkSymList )( imp_image_handle *iih, symbol_source ss, void *source, DIP_IMP_SYM_WALKER *wk, imp_sym_handle *ish, void *d ) +/********************************************************************** + * TODO: + * + * Walk the list of symbols. There can be a number of sources + * of symbol lists. What kind you're walking is determined by the + * 'ss' parameter. It can take on the following values: + * + * SS_MODULE: + * The 'source' is a pointer to an imp_mod_handle. If + * the *(imp_mod_handle *)source is IMH_NOMOD, The list is + * all the module scope/global symbols in the image, otherwise + * it is the list of module scope/global symbols in the + * indicated module. + * + * SS_SCOPED: + * The 'source' is a pointer at an address. Considering the + * point of execution to be *(address *)source, the list + * is all the lexically scoped symbols visible from that + * point. + * + * SS_TYPE: + * The 'source' is a pointer to an imp_type_handle. If + * *(imp_type_handle *)source represents an enumerated + * type, the list is all the constant symbols of the + * enumeration. If the type handle represents a structure + * type, the list is all the field names in the structure. + * + * When walking structures with a inherited classes, there is + * a small trick. Just before starting to walk the fields + * of an inherited class, the DIP should do a: + * + * wk( iih, SWI_INHERIT_START, NULL, d ) + * + * This indicates to client that an inherited field list + * is about to be started. If the client wishes the DIP to + * actually walk the inherited list, it will return WR_CONTINUE. + * If it wants you to skip the inherited fields it will return + * WR_STOP. You should continue with the reminder of the fields + * in the current structure that you're walking. + * When you come to the end of the list of members for an + * inherited class do a: + * + * wk( iih, SWI_INHERIT_END, NULL, d ) + * + * SS_BLOCK: + * The 'source' is a pointer to a scope_block structure. + * Walk all the symbols in that lexical block _only_. + * + * SS_SCOPESYM: + * The 'source' is a pointer to an imp_sym_handle. + * This is a request to walk all the symbols in the + * scope identified by the imp_sym_handle. For example, if + * the imp_sym_handle is of type SK_NAMESPACE, walk all the + * symbols contained in that namespace. + * + * PSEUDO-CODE: + * + * for( each symbol in the list ) { + * if( starting new inherited base class ) { + * if( wk( iih, SWI_INHERIT_START, NULL, d ) != WR_CONTINUE ) { + * skip it and continue with next field in current class + * } + * } else if( ending list of inherited base class ) { + * wk( iih, SWI_INHERIT_END, NULL, d ); + * } else { + * *ish = fill in symbol handle information; + * wr = wk( iih, SWI_SYMBOL, ish, d ); + * if( wr != WR_CONTINUE ) { + * return( wr ); + * } + * } + * } + */ { - //TODO: - /* - Walk the list of symbols. There can be a number of sources - of symbol lists. What kind you're walking is determined by the - 'ss' parameter. It can take on the following values: - - SS_MODULE: - The 'source' is a pointer to an imp_mod_handle. If - the *(imp_mod_handle *)source is IMH_NOMOD, The list is - all the module scope/global symbols in the image, otherwise - it is the list of module scope/global symbols in the - indicated module. - - SS_SCOPED: - The 'source' is a pointer at an address. Considering the - point of execution to be *(address *)source, the list - is all the lexically scoped symbols visible from that - point. - - SS_TYPE: - The 'source' is a pointer to an imp_type_handle. If - *(imp_type_handle *)source represents an enumerated - type, the list is all the constant symbols of the - enumeration. If the type handle represents a structure - type, the list is all the field names in the structure. - - When walking structures with a inherited classes, there is - a small trick. Just before starting to walk the fields - of an inherited class, the DIP should do a: - - wk( iih, SWI_INHERIT_START, NULL, d ) - - This indicates to client that an inherited field list - is about to be started. If the client wishes the DIP to - actually walk the inherited list, it will return WR_CONTINUE. - If it wants you to skip the inherited fields it will return - WR_STOP. You should continue with the reminder of the fields - in the current structure that you're walking. - When you come to the end of the list of members for an - inherited class do a: - - wk( iih, SWI_INHERIT_END, NULL, d ) - - SS_BLOCK: - The 'source' is a pointer to a scope_block structure. - Walk all the symbols in that lexical block _only_. - - SS_SCOPESYM: - The 'source' is a pointer to an imp_sym_handle. - This is a request to walk all the symbols in the - scope identified by the imp_sym_handle. For example, if - the imp_sym_handle is of type SK_NAMESPACE, walk all the - symbols contained in that namespace. - - PSEUDO-CODE: - - for( each symbol in the list ) { - if( starting new inherited base class ) { - if( wk( iih, SWI_INHERIT_START, NULL, d ) != WR_CONTINUE ) { - skip it and continue with next field in current class - } - } else if( ending list of inherited base class ) { - wk( iih, SWI_INHERIT_END, NULL, d ); - } else { - *ish = fill in symbol handle information; - wr = wk( iih, SWI_SYMBOL, ish, d ); - if( wr != WR_CONTINUE ) { - return( wr ); - } - } - } - */ return( WR_CONTINUE ); } @@ -121,99 +122,108 @@ walk_result DIPIMPENTRY( WalkSymList )( imp_image_handle *iih, walk_result DIPIMPENTRY( WalkSymListEx )( imp_image_handle *iih, symbol_source ss, void *source, DIP_IMP_SYM_WALKER *wk, imp_sym_handle *ish, location_context *lc, void *d ) +/********************************************************************************* + * TODO: + * + * Just like DIPImpWalkSymList but it gets an "lc", just in case + * we're debugging some wierd-ass language like javascript where + * the fields of a structure can change dynamically + */ { - /* - Just like DIPImpWalkSymList but it gets an "lc", just in case - we're debugging some wierd-ass language like javascript where - the fields of a structure can change dynamically - */ lc=lc; return( WR_CONTINUE ); } imp_mod_handle DIPIMPENTRY( SymMod )( imp_image_handle *iih, imp_sym_handle *ish ) +/********************************************************************************* + * TODO: + * + * Return the module that the implementation symbol handle comes from. + */ { - //TODO: - /* - Return the module that the implementation symbol handle comes from. - */ return( IMH_NOMOD ); } size_t DIPIMPENTRY( SymName )( imp_image_handle *iih, imp_sym_handle *ish, location_context *lc, symbol_name_type snt, char *buff, size_t buff_size ) +/***************************************************************************** + * TODO: + * + * Given the imp_sym_handle, copy the name of the symbol into 'buff'. + * Do not copy more than 'buff_size' - 1 characters into the buffer and + * append a trailing '\0' character. Return the real length + * of the symbol name (not including the trailing '\0' character) even + * if you had to truncate it to fit it into the buffer. If something + * went wrong and you can't get the symbol name, call DCStatus and + * return zero. NOTE: the client might pass in zero for 'buff_size'. In that + * case, just return the length of the symbol name and do not attempt + * to put anything into the buffer. + * The 'snt' parameter indicates what type of symbol name the client + * is interested in. It can have the following values: + * + * SNT_SOURCE: + * The name of the symbol as it appears in the source code. + * + * SNT_OBJECT: + * The name of the symbol as it appeared to the linker. + * + * SNT_DEMANGLED: + * C++ names, with full typing (essentially it looks like + * a function prototype). If the symbol is not a C++ symbol + * (not mangled), return zero for the length. + * + * SNT_EXPRESSION: + * Return whatever character string is necessary such that + * when scanned in an expression, the symbol handle can + * be reconstructed. Deprecated - never used. + */ { - //TODO: - /* - Given the imp_sym_handle, copy the name of the symbol into 'buff'. - Do not copy more than 'buff_size' - 1 characters into the buffer and - append a trailing '\0' character. Return the real length - of the symbol name (not including the trailing '\0' character) even - if you had to truncate it to fit it into the buffer. If something - went wrong and you can't get the symbol name, call DCStatus and - return zero. NOTE: the client might pass in zero for 'buff_size'. In that - case, just return the length of the symbol name and do not attempt - to put anything into the buffer. - The 'snt' parameter indicates what type of symbol name the client - is interested in. It can have the following values: - - SNT_SOURCE: - The name of the symbol as it appears in the source code. - - SNT_OBJECT: - The name of the symbol as it appeared to the linker. - - SNT_DEMANGLED: - C++ names, with full typing (essentially it looks like - a function prototype). If the symbol is not a C++ symbol - (not mangled), return zero for the length. - - SNT_EXPRESSION: - Return whatever character string is necessary such that - when scanned in an expression, the symbol handle can - be reconstructed. Deprecated - never used. - */ return( 0 ); } dip_status DIPIMPENTRY( SymType )( imp_image_handle *iih, imp_sym_handle *ish, imp_type_handle *ith ) +/********************************************************** + * TODO: + * + * Get the implementation type handle for the type of the + * given symbol. + */ { - //TODO: - /* - Get the implementation type handle for the type of the - given symbol. - */ return( DS_FAIL ); } dip_status DIPIMPENTRY( SymLocation )( imp_image_handle *iih, imp_sym_handle *ish, location_context *lc, location_list *ll ) +/***************************************************************************** + * TODO: + * + * Get the location of the given symbol. + */ { - /* - Get the location of the given symbol. - */ return( DS_FAIL ); } dip_status DIPIMPENTRY( SymValue )( imp_image_handle *iih, imp_sym_handle *ish, location_context *lc, void *buff ) +/********************************************************************** + * TODO: + * + * Copy the value of a constant symbol into 'buff'. You can get the + * size required by doing a SymType followed by a TypeInfo. + */ { - //TODO: - /* - Copy the value of a constant symbol into 'buff'. You can get the - size required by doing a SymType followed by a TypeInfo. - */ return( DS_FAIL ); } dip_status DIPIMPENTRY( SymInfo )( imp_image_handle *iih, imp_sym_handle *ish, location_context *lc, sym_info *si ) +/************************************************************************ + * TODO: + * + * Get some generic information about a symbol. + */ { - //TODO: - /* - Get some generic information about a symbol. - */ memset( si, 0, sizeof( *si ) ); return( DS_FAIL ); } @@ -221,269 +231,278 @@ dip_status DIPIMPENTRY( SymInfo )( imp_image_handle *iih, dip_status DIPIMPENTRY( SymParmLocation )( imp_image_handle *iih, imp_sym_handle *ish, location_context *lc, location_list *ll, unsigned n ) +/**************************************************************** + * TODO: + * + * Get information about where a routine's parameters/return value + * are located. + * If the 'n' parameter is zero, fill in the location list structure + * pointed at by 'll' with the information on the location of the + * function's return value. Otherwise fill it in with the location + * of the n'th parameter. + */ { - //TODO: - /* - Get information about where a routine's parameters/return value - are located. - If the 'n' parameter is zero, fill in the location list structure - pointed at by 'll' with the information on the location of the - function's return value. Otherwise fill it in with the location - of the n'th parameter. - */ return( DS_FAIL ); } dip_status DIPIMPENTRY( SymObjType )( imp_image_handle *iih, imp_sym_handle *ish, imp_type_handle *ith, dig_type_info *ti ) +/********************************************************************************* + * TODO: + * + * Fill in the imp_type_handle with the type of the 'this' object + * for a C++ member function. + * If 'ti' is not NULL, fill in the dig_type_info with the kind of 'this' + * pointer that the routine is expecting (near/far, 16/32). If the + * routine is a static member, set ti->kind to TK_NONE. + */ { - //TODO: - /* - Fill in the imp_type_handle with the type of the 'this' object - for a C++ member function. - If 'ti' is not NULL, fill in the dig_type_info with the kind of 'this' - pointer that the routine is expecting (near/far, 16/32). If the - routine is a static member, set ti->kind to TK_NONE. - */ return( DS_FAIL ); } dip_status DIPIMPENTRY( SymObjLocation )( imp_image_handle *iih, imp_sym_handle *ish, location_context *lc, location_list *ll ) +/************************************************************************* + * TODO: + * + * Fill in the location list with the location of the '*this' object + * for a C++ member function. Return DS_FAIL if it's a static member + * function. + */ { - //TODO: - /* - Fill in the location list with the location of the '*this' object - for a C++ member function. Return DS_FAIL if it's a static member - function. - */ - return( DS_FAIL ); + return( DS_FAIL ); } search_result DIPIMPENTRY( AddrSym )( imp_image_handle *iih, imp_mod_handle imh, address a, imp_sym_handle *ish ) +/******************************************************************************* + * TODO: + * + * Search the given module for a symbol who's address is less than + * or equal to 'addr'. If none is found return SR_NONE. If you find + * a symbol at that address exactly, fill in '*ish' and return SR_EXACT. + * Otherwise, fill in '*ish' and return SR_CLOSEST. + */ { - //TODO: - /* - Search the given module for a symbol who's address is less than - or equal to 'addr'. If none is found return SR_NONE. If you find - a symbol at that address exactly, fill in '*ish' and return SR_EXACT. - Otherwise, fill in '*ish' and return SR_CLOSEST. - */ return( SR_NONE ); } search_result DIPIMPENTRY( LookupSym )( imp_image_handle *iih, symbol_source ss, void *source, lookup_item *li, void *d ) +/************************************************************************* + * TODO: + * + * Lookup a symbol by name. + * + * The 'ss' and 'source' indicate where to search for the name. 'ss' + * can take on the following values: + * + * SS_MODULE: + * The 'source' is a pointer to an imp_mod_handle. + * Search all the file scope symbols in that module. + * If *(imp_mod_handle *)source is IMH_NOMOD, Search all file + * scope symbols in the image. + * + * SS_SCOPED: + * The 'source' is a pointer at an address. Considering the + * point of execution to be *(address *)source, search all + * the lexically scoped symbols visible from that point. + * + * SS_TYPE: + * The 'source' is a pointer to an imp_type_handle. If + * *(imp_type_handle *)source represents an enumerated + * type, search all the constant symbols of the + * enumeration. If the type handle represents a structure + * type, search all the field names in the structure (including + * any inherited fields). + * + * SS_BLOCK: + * Will never happen. + * + * SS_SCOPESYM: + * The 'source' is a pointer to an imp_sym_handle. Find symbols + * only in the scope identified by the 'source' pointer. + * + * The 'li' identifies the symbol name being looked up. It contains the + * following fields: + * + * mod_handle mod; + * Inside the implmentation, this field is actually an + * 'imp_mod_handle'. If 'mod' is not IMH_NOMOD, then the symbol + * must be in the indicated module. If it is IMH_NOMOD, the + * symbol can be from any module in the image. + * + * lookup_token name; + * The name of the symbol being looked up. A lookup_token + * contains a pointer to the start of the name and a length. + * + * lookup_token scope; + * The C++ scope of the name. E.g., in the symbol "foo::bar", + * this field would indicate "foo". Yeah, I know that you + * can have more than one scope name, but I don't want to think + * about it until someone complains. If the start pointer in + * the lookup_token is NULL, then there is no scope name. + * Deprecated - new clients will use SS_SCOPESYM instead. + * Eventually support for this will be removed. + * + * lookup_token source; + * This is the source name of the symbol being looked up. I.e. + * what the user typed in. It differs from the name field in + * that the client might try munging the symbol name to deal + * with the compiler adding characters to the front or end of + * the symbol name before writing it to the object file. E.g. + * The 'source' might be "foo", while the 'name' field is + * "foo_". + * + * unsigned file_scope : 1; + * If true, the symbol must be defined at file scope. E.g., in + * C++ terms, the user typed "::bar". + * + * unsigned case_sensitive : 1; + * If true, string comparisons are case sensitive. Otherwise, + * case insensitive. + * + * unsigned type : 4; + * This field can have the following values: + * ST_NONE + * Normal everyday joe-blow symbol. + * ST_OPERATOR + * C++ operator symbol. E.g. "operator +". + * Note: In this case the name field would be "+". + * ST_DESTRUCTOR + * C++ destructor. E.g. "~foo". + * Note: In this case the name field would be "foo". + * ST_TYPE + * A typedef name. + * ST_STRUCT_TAG + * A structure tag. E.g. "struct mas". + * Note: The name field would just be "mas". + * ST_CLASS_TAG + * A class tag. E.g. "class mas". + * Note: The name field would just be "mas". + * ST_UNION_TAG + * A union tag. E.g. "union mas". + * Note: The name field would just be "mas". + * ST_ENUM_TAG + * A enum tag. E.g. "enum mas". + * Note: The name field would just be "mas". + * + * The DIP should search in the indicated locations for the + * indicated symbol. Since more than one symbol may match the + * criteria due to C++ function overloading, a pointer to an + * imp_sym_handle is not passed as a parameter to be filled in. + * Instead, when the DIP finds a symbol that matches the lookup + * parameters it should do the following call: + * + * ish = DCSymCreate( iih, d ); + * + * Where 'iih' and 'd' are the parameters that were passed into + * the DIPImpLookupSym functions. If the client returns NULL, the + * sym handle could not be created for some reason and the DIP + * should terminate the symbol lookup and return SR_FAIL. If the + * return is non-NULL then it is a pointer to a freshly minted + * imp_sym_handle which the implementation should fill in with + * the appropriate values for the symbol that it had just found. + * The DIP should then continue looking for the next symbol that + * matches the search criteria (unless it can tell that there + * won't be anymore). After the search has completed, the routine + * should return SR_EXACT if any symbols were found and SR_NONE + * otherwise. + */ { - //TODO: - /* - Lookup a symbol by name. - - The 'ss' and 'source' indicate where to search for the name. 'ss' - can take on the following values: - - SS_MODULE: - The 'source' is a pointer to an imp_mod_handle. - Search all the file scope symbols in that module. - If *(imp_mod_handle *)source is IMH_NOMOD, Search all file - scope symbols in the image. - - SS_SCOPED: - The 'source' is a pointer at an address. Considering the - point of execution to be *(address *)source, search all - the lexically scoped symbols visible from that point. - - SS_TYPE: - The 'source' is a pointer to an imp_type_handle. If - *(imp_type_handle *)source represents an enumerated - type, search all the constant symbols of the - enumeration. If the type handle represents a structure - type, search all the field names in the structure (including - any inherited fields). - - SS_BLOCK: - Will never happen. - - SS_SCOPESYM: - The 'source' is a pointer to an imp_sym_handle. Find symbols - only in the scope identified by the 'source' pointer. - - The 'li' identifies the symbol name being looked up. It contains the - following fields: - - mod_handle mod; - Inside the implmentation, this field is actually an - 'imp_mod_handle'. If 'mod' is not IMH_NOMOD, then the symbol - must be in the indicated module. If it is IMH_NOMOD, the - symbol can be from any module in the image. - - lookup_token name; - The name of the symbol being looked up. A lookup_token - contains a pointer to the start of the name and a length. - - lookup_token scope; - The C++ scope of the name. E.g., in the symbol "foo::bar", - this field would indicate "foo". Yeah, I know that you - can have more than one scope name, but I don't want to think - about it until someone complains. If the start pointer in - the lookup_token is NULL, then there is no scope name. - Deprecated - new clients will use SS_SCOPESYM instead. - Eventually support for this will be removed. - - lookup_token source; - This is the source name of the symbol being looked up. I.e. - what the user typed in. It differs from the name field in - that the client might try munging the symbol name to deal - with the compiler adding characters to the front or end of - the symbol name before writing it to the object file. E.g. - The 'source' might be "foo", while the 'name' field is - "foo_". - - unsigned file_scope : 1; - If true, the symbol must be defined at file scope. E.g., in - C++ terms, the user typed "::bar". - - unsigned case_sensitive : 1; - If true, string comparisons are case sensitive. Otherwise, - case insensitive. - - unsigned type : 4; - This field can have the following values: - ST_NONE - Normal everyday joe-blow symbol. - ST_OPERATOR - C++ operator symbol. E.g. "operator +". - Note: In this case the name field would be "+". - ST_DESTRUCTOR - C++ destructor. E.g. "~foo". - Note: In this case the name field would be "foo". - ST_TYPE - A typedef name. - ST_STRUCT_TAG - A structure tag. E.g. "struct mas". - Note: The name field would just be "mas". - ST_CLASS_TAG - A class tag. E.g. "class mas". - Note: The name field would just be "mas". - ST_UNION_TAG - A union tag. E.g. "union mas". - Note: The name field would just be "mas". - ST_ENUM_TAG - A enum tag. E.g. "enum mas". - Note: The name field would just be "mas". - - The DIP should search in the indicated locations for the - indicated symbol. Since more than one symbol may match the - criteria due to C++ function overloading, a pointer to an - imp_sym_handle is not passed as a parameter to be filled in. - Instead, when the DIP finds a symbol that matches the lookup - parameters it should do the following call: - - ish = DCSymCreate( iih, d ); - - Where 'iih' and 'd' are the parameters that were passed into - the DIPImpLookupSym functions. If the client returns NULL, the - sym handle could not be created for some reason and the DIP - should terminate the symbol lookup and return SR_FAIL. If the - return is non-NULL then it is a pointer to a freshly minted - imp_sym_handle which the implementation should fill in with - the appropriate values for the symbol that it had just found. - The DIP should then continue looking for the next symbol that - matches the search criteria (unless it can tell that there - won't be anymore). After the search has completed, the routine - should return SR_EXACT if any symbols were found and SR_NONE - otherwise. - */ return( SR_NONE ); } search_result DIPIMPENTRY( LookupSymEx )( imp_image_handle *iih, symbol_source ss, void *source, lookup_item *li, location_context *lc, void *d ) +/*************************************************************** + * see above + */ { - // see above return( SR_NONE ); } search_result DIPIMPENTRY( AddrScope )( imp_image_handle *iih, imp_mod_handle imh, address addr, scope_block *scope ) +/********************************************************************* + * TODO: + * + * Find the range of the lexical scope block enclosing 'addr' in + * module 'im'. If there is no such scope, return SR_NONE. Otherwise + * fill in scope->start with the address of the start of the lexical + * block and scope->len with the size of the block. Fill in + * scope->unique with something that uniquely identifies the lexical + * block in question. This is used to disamibiguate between blocks + * that start at the same address and have the same length. The value + * should be chosen so that + * 1. It remains valid and consistant across a DIPUnloadInfo + * and DIPLoadInfo of the same information. + * 2. It remains the same whether the scope_block was obtained + * by DIPImpAddrScope or DIPImpScopeOuter. + * Then return SR_EXACT/SR_CLOSEST as appropriate. + */ { - //TODO: - /* - Find the range of the lexical scope block enclosing 'addr' in - module 'im'. If there is no such scope, return SR_NONE. Otherwise - fill in scope->start with the address of the start of the lexical - block and scope->len with the size of the block. Fill in - scope->unique with something that uniquely identifies the lexical - block in question. This is used to disamibiguate between blocks - that start at the same address and have the same length. The value - should be chosen so that - 1. It remains valid and consistant across a DIPUnloadInfo - and DIPLoadInfo of the same information. - 2. It remains the same whether the scope_block was obtained - by DIPImpAddrScope or DIPImpScopeOuter. - Then return SR_EXACT/SR_CLOSEST as appropriate. - */ return( SR_NONE ); } search_result DIPIMPENTRY( ScopeOuter )( imp_image_handle *iih, imp_mod_handle imh, scope_block *in, scope_block *out ) +/********************************************************************** + * TODO: + * + * Given the scope_block pointed to by 'in' in the module 'im', find + * the parent lexical block of it and fill in the scope_block pointed + * to by 'out' with the information. Return SR_EXACT/SR_CLOSEST as + * appropriate. Return SR_NONE if there is no parent block. + * Make sure that the case where 'in' and 'out' point to the same + * address is handled. + */ { - //TODO: - /* - Given the scope_block pointed to by 'in' in the module 'im', find - the parent lexical block of it and fill in the scope_block pointed - to by 'out' with the information. Return SR_EXACT/SR_CLOSEST as - appropriate. Return SR_NONE if there is no parent block. - Make sure that the case where 'in' and 'out' point to the same - address is handled. - */ return( SR_NONE ); } int DIPIMPENTRY( SymCmp )( imp_image_handle *iih, imp_sym_handle *ish1, imp_sym_handle *ish2 ) +/********************************************************************** + * TODO: + * + * Compare two sym handles and return 0 if they refer to the same + * information. If they refer to differnt things return either a + * positive or negative value to impose an 'order' on the information. + * The value should obey the following constraints. + * Given three handles H1, H2, H3: + * - if H1 < H2 then H1 is always < H2 + * - if H1 < H2 and H2 < H3 then H1 is < H3 + * The reason for the constraints is so that a client can sort a + * list of handles and binary search them. + */ { - //TODO: - /* - Compare two sym handles and return 0 if they refer to the same - information. If they refer to differnt things return either a - positive or negative value to impose an 'order' on the information. - The value should obey the following constraints. - Given three handles H1, H2, H3: - - if H1 < H2 then H1 is always < H2 - - if H1 < H2 and H2 < H3 then H1 is < H3 - The reason for the constraints is so that a client can sort a - list of handles and binary search them. - */ return( 0 ); } dip_status DIPIMPENTRY( SymAddRef )( imp_image_handle *iih, imp_sym_handle *ish ) +/******************************************************************************** + * see DIPImpTypeAddRef + */ { - /* - see DIPImpTypeAddRef - */ return( DS_OK ); } dip_status DIPIMPENTRY( SymRelease )( imp_image_handle *iih, imp_sym_handle *ish ) +/********************************************************************************* + * see DIPImpTypeRelease + */ { - /* - see DIPImpTypeRelease - */ return( DS_OK ); } dip_status DIPIMPENTRY( SymFreeAll )( imp_image_handle *iih ) +/************************************************************ + * see DIPImpTypeFreeAll + */ { - /* - see DIPImpTypeFreeAll - */ return( DS_OK ); } - diff --git a/bld/dip/skel/c/skeltype.c b/bld/dip/skel/c/skeltype.c index 123096356e..3c688f67eb 100644 --- a/bld/dip/skel/c/skeltype.c +++ b/bld/dip/skel/c/skeltype.c @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -34,47 +35,48 @@ /* - Stuff dealing with type handles. -*/ + * Stuff dealing with type handles. + */ - -walk_result DIPIMPENTRY( WalkTypeList )( imp_image_handle *iih, - imp_mod_handle imh, DIP_IMP_TYPE_WALKER *wk, imp_type_handle *ith, - void *d ) +walk_result DIPIMPENTRY( WalkTypeList )( imp_image_handle *iih, imp_mod_handle imh, + DIP_IMP_TYPE_WALKER *wk, imp_type_handle *ith, void *d ) +/*********************************************************************************** + * TODO: + * + * PSEUDO-CODE: + * + * for( each type in the module ) { + * *ith = fill in the implemenation type handle; + * wr = wk( iih, ith, d ); + * if( wr != WR_CONTINUE ) { + * return( wr ); + * } + * } + */ { - //TODO: - /* - PSEUDO-CODE: - - for( each type in the module ) { - *ith = fill in the implemenation type handle; - wr = wk( iih, ith, d ); - if( wr != WR_CONTINUE ) { - return( wr ); - } - } - */ return( WR_CONTINUE ); } imp_mod_handle DIPIMPENTRY( TypeMod )( imp_image_handle *iih, imp_type_handle *ith ) +/*********************************************************************************** + * TODO: + * + * Return the module that the type handle comes from. + */ { - //TODO: - /* - Return the module that the type handle comes from. - */ return( IMH_NOMOD ); } -dip_status DIPIMPENTRY( TypeInfo )( imp_image_handle *iih, - imp_type_handle *ith, location_context *lc, dig_type_info *ti ) +dip_status DIPIMPENTRY( TypeInfo )( imp_image_handle *iih, imp_type_handle *ith, + location_context *lc, dig_type_info *ti ) +/******************************************************************************** + * TODO: + * + * Fill in the type information for the type handle. The location + * context is being passed in because it might be needed to calculate + * the size of the type (variable dimensioned arrays and the like). + */ { - //TODO: - /* - Fill in the type information for the type handle. The location - context is being passed in because it might be needed to calculate - the size of the type (variable dimensioned arrays and the like). - */ ti->kind = TK_NONE; ti->size = 0; ti->modifier = TM_NONE; @@ -82,22 +84,22 @@ dip_status DIPIMPENTRY( TypeInfo )( imp_image_handle *iih, return( DS_FAIL ); } -dip_status DIPIMPENTRY( TypeBase )( imp_image_handle *iih, - imp_type_handle *ith, imp_type_handle *base_ith, - location_context *lc, location_list *ll ) +dip_status DIPIMPENTRY( TypeBase )( imp_image_handle *iih, imp_type_handle *ith, + imp_type_handle *base_ith, location_context *lc, location_list *ll ) +/******************************************************************************* + * TODO: + * + * Given an implementation type handle, fill in 'base' with the + * base type of the handle. + * If 'll' is non-NULL, it points to a location list describing the + * object that TypeBase is being performed on. If doing the TypeBase + * operation implies some special magic operation on the object that + * is not described by the typing information (following pointers, etc) + * then the passed in location list should be adjusted to point at the + * start of the data for the object described by the result of the + * TypeBase operation. + */ { - //TODO: - /* - Given an implementation type handle, fill in 'base' with the - base type of the handle. - If 'll' is non-NULL, it points to a location list describing the - object that TypeBase is being performed on. If doing the TypeBase - operation implies some special magic operation on the object that - is not described by the typing information (following pointers, etc) - then the passed in location list should be adjusted to point at the - start of the data for the object described by the result of the - TypeBase operation. - */ *base_ith = *ith; return( DS_FAIL ); } @@ -105,15 +107,16 @@ dip_status DIPIMPENTRY( TypeBase )( imp_image_handle *iih, dip_status DIPIMPENTRY( TypeArrayInfo )( imp_image_handle *iih, imp_type_handle *array_ith, location_context *lc, array_info *ai, imp_type_handle *index_ith ) +/************************************************************************ + * TODO: + * + * Given an implemenation type handle that represents an array type, + * get information about the array shape and index type. The location + * context is for variable dimensioned arrays again. The 'index' + * parameter is filled in with the type of variable used to subscript + * the array. It may be NULL, in which case no information is returned. + */ { - //TODO: - /* - Given an implemenation type handle that represents an array type, - get information about the array shape and index type. The location - context is for variable dimensioned arrays again. The 'index' - parameter is filled in with the type of variable used to subscript - the array. It may be NULL, in which case no information is returned. - */ ai->low_bound = 0; ai->num_elts = 0; ai->stride = 0; @@ -124,144 +127,146 @@ dip_status DIPIMPENTRY( TypeArrayInfo )( imp_image_handle *iih, return( DS_FAIL ); } -dip_status DIPIMPENTRY( TypeProcInfo )( imp_image_handle *iih, - imp_type_handle *proc_ith, imp_type_handle *parm_ith, unsigned n ) +dip_status DIPIMPENTRY( TypeProcInfo )( imp_image_handle *iih, imp_type_handle *proc_ith, + imp_type_handle *parm_ith, unsigned n ) +/**************************************************************************************** + * TODO: + * + * Given an implementation type handle that represents a procedure type, + * get information about the return and parameter types. If the 'n' + * parameter is zero, store the return type handle into the 'parm' + * variable. Otherwise store the handle for the n'th parameter in + * 'parm'. + */ { - //TODO: - /* - Given an implementation type handle that represents a procedure type, - get information about the return and parameter types. If the 'n' - parameter is zero, store the return type handle into the 'parm' - variable. Otherwise store the handle for the n'th parameter in - 'parm'. - */ *parm_ith = *proc_ith; return( DS_FAIL ); } dip_status DIPIMPENTRY( TypePtrAddrSpace )( imp_image_handle *iih, imp_type_handle *ith, location_context *lc, address *a ) +/*************************************************************************** + * Given an implementation type handle that represents a pointer type, + * get information about any implied address space for that pointer + * (based pointer cruft). If there is an implied address space for + * the pointer, fill in *a with the information and return DS_OK. + * Otherwise return DS_FAIL. + */ { - /* - Given an implementation type handle that represents a pointer type, - get information about any implied address space for that pointer - (based pointer cruft). If there is an implied address space for - the pointer, fill in *a with the information and return DS_OK. - Otherwise return DS_FAIL. - */ return( DS_FAIL ); } -dip_status DIPIMPENTRY( TypeThunkAdjust )( imp_image_handle *iih, - imp_type_handle *base_ith, imp_type_handle *derived_ith, - location_context *lc, address *addr ) +dip_status DIPIMPENTRY( TypeThunkAdjust )( imp_image_handle *iih, imp_type_handle *base_ith, + imp_type_handle *derived_ith, location_context *lc, address *addr ) +/******************************************************************************************* + * TODO: + * + * When you convert a pointer to a C++ class to a pointer at one + * of its derived classes you have to adjust the pointer so that + * it points at the start of the derived class. The 'derived' type + * may not actually be a derived type of 'base'. In that case, return + * DS_FAIL and add nothing to 'addr'. If it is a derived type, let 'disp' + * be the displacement between the 'base' type and the 'derived' type. + * You need to do the following. "addr->mach.offset += disp;". + */ { - //TODO: - /* - When you convert a pointer to a C++ class to a pointer at one - of its derived classes you have to adjust the pointer so that - it points at the start of the derived class. The 'derived' type - may not actually be a derived type of 'base'. In that case, return - DS_FAIL and add nothing to 'addr'. If it is a derived type, let 'disp' - be the displacement between the 'base' type and the 'derived' type. - You need to do the following. "addr->mach.offset += disp;". - */ return( DS_FAIL ); } int DIPIMPENTRY( TypeCmp )( imp_image_handle *iih, imp_type_handle *ith1, imp_type_handle *ith2 ) +/************************************************************************************************ + * TODO: + * + * Compare two type handles and return 0 if they refer to the same + * information. If they refer to differnt things return either a + * positive or negative value to impose an 'order' on the information. + * The value should obey the following constraints. + * Given three handles H1, H2, H3: + * - if H1 < H2 then H1 is always < H2 + * - if H1 < H2 and H2 < H3 then H1 is < H3 + * The reason for the constraints is so that a client can sort a + * list of handles and binary search them. + */ { - //TODO: - /* - Compare two type handles and return 0 if they refer to the same - information. If they refer to differnt things return either a - positive or negative value to impose an 'order' on the information. - The value should obey the following constraints. - Given three handles H1, H2, H3: - - if H1 < H2 then H1 is always < H2 - - if H1 < H2 and H2 < H3 then H1 is < H3 - The reason for the constraints is so that a client can sort a - list of handles and binary search them. - */ return( 0 ); } size_t DIPIMPENTRY( TypeName )( imp_image_handle *iih, imp_type_handle *ith, unsigned num, symbol_type *tag, char *buff, size_t buff_size ) +/***************************************************************************** + * TODO: + * + * Given the imp_type_handle, copy the name of the type into 'buff'. + * Do not copy more than 'buff_size' - 1 characters into the buffer and + * append a trailing '\0' character. Return the real length + * of the type name (not including the trailing '\0' character) even + * if you had to truncate it to fit it into the buffer. If something + * went wrong and you can't get the type name, call DCStatus and + * return zero. NOTE: the client might pass in zero for 'buff_size'. In that + * case, just return the length of the module name and do not attempt + * to put anything into the buffer. + * + * Since there can be a "string" of typedef names associated with + * a type_handle, the 'num' parm indicates which one of the names + * the client wants returned. Zero is the first type name, one is + * the second, etc. Fill in '*tag' with ST_ENUM_TAG, ST_UNION_TAG, + * ST_STRUCT_TAG, ST_CLASS_TAG if the name is a enum, union, struct, + * or class tag name respectively. If not, set '*tag' to ST_NONE. + * + * If the type does not have a name, return zero. + */ { - //TODO: - /* - Given the imp_type_handle, copy the name of the type into 'buff'. - Do not copy more than 'buff_size' - 1 characters into the buffer and - append a trailing '\0' character. Return the real length - of the type name (not including the trailing '\0' character) even - if you had to truncate it to fit it into the buffer. If something - went wrong and you can't get the type name, call DCStatus and - return zero. NOTE: the client might pass in zero for 'buff_size'. In that - case, just return the length of the module name and do not attempt - to put anything into the buffer. - - Since there can be a "string" of typedef names associated with - a type_handle, the 'num' parm indicates which one of the names - the client wants returned. Zero is the first type name, one is - the second, etc. Fill in '*tag' with ST_ENUM_TAG, ST_UNION_TAG, - ST_STRUCT_TAG, ST_CLASS_TAG if the name is a enum, union, struct, - or class tag name respectively. If not, set '*tag' to ST_NONE. - - If the type does not have a name, return zero. - */ return( 0 ); } /* - The following 3 routines are for resource management of type handles. - They should be implemented if the implementation wants to store pointers - to resources that must be freed in an imp_type_handle. Here is an - example of how they could be used. - - typedef struct type_ref { - int signature; - struct type_ref *link; - int refCount; - void *otherValuableResource; - } - - typedef struct { - type_ref *r; - } imp_type_handle; - - type_ref *TypesList; - - Note: if you do implement these routines, it is a good idea to have - a signature to validate type handles IN EVERY ENTRY POINT that takes - an imp_type_handle*. ie: - - #define ValidType( t ) assert( t->r->signature == 0xC0DEAB1E ); - - - Finally, you may assume that DIPImpTypeFreeAll and DIPImpSymFreeAll - are called at the same time - -*/ + * The following 3 routines are for resource management of type handles. + * They should be implemented if the implementation wants to store pointers + * to resources that must be freed in an imp_type_handle. Here is an + * example of how they could be used. + * + * typedef struct type_ref { + * int signature; + * struct type_ref *link; + * int refCount; + * void *otherValuableResource; + * } + * + * typedef struct { + * type_ref *r; + * } imp_type_handle; + * + * type_ref *TypesList; + * + * Note: if you do implement these routines, it is a good idea to have + * a signature to validate type handles IN EVERY ENTRY POINT that takes + * an imp_type_handle*. ie: + * + * #define ValidType( t ) assert( t->r->signature == 0xC0DEAB1E ); + * + * + * Finally, you may assume that DIPImpTypeFreeAll and DIPImpSymFreeAll + * are called at the same time + * + */ dip_status DIPIMPENTRY( TypeAddRef )( imp_image_handle *iih, imp_type_handle *ith ) +/*********************************************************************************/ { - /* - ith->r->refCount++; - */ +// ith->r->refCount++; return( DS_OK ); } dip_status DIPIMPENTRY( TypeRelease )( imp_image_handle *iih, imp_type_handle *ith ) +/**********************************************************************************/ { - /* - ith->r->refCount--; - */ +// ith->r->refCount--; return( DS_OK ); } dip_status DIPIMPENTRY( TypeFreeAll )( imp_image_handle *iih ) +/************************************************************/ { - /* +#if 0 for( type = TypesList; type != NULL; type = type->link ) { if( type->r->refCount == 0 ) { free type->r->otherValuableResource; @@ -269,7 +274,6 @@ dip_status DIPIMPENTRY( TypeFreeAll )( imp_image_handle *iih ) free type->r } } - */ +#endif return( DS_OK ); } - diff --git a/bld/dip/skel/h/skel.h b/bld/dip/skel/h/skel.h index 249ec36e93..218812d065 100644 --- a/bld/dip/skel/h/skel.h +++ b/bld/dip/skel/h/skel.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -31,9 +32,9 @@ /* - There are a number of types that a dip implementation must define. - This file contains some example definitions. -*/ + * There are a number of types that a dip implementation must define. + * This file contains some example definitions. + */ #ifndef DIP_SKEL #define DIP_SKEL @@ -43,37 +44,47 @@ /* - An imp_mod_handle is defined as an unsigned_16. The value zero is - reserved to indicate "no module". -*/ + * An imp_mod_handle is defined as an unsigned_16. The value zero is + * reserved to indicate "no module". + */ struct imp_sym_handle { - /* any stuff for getting information on symbols */ + /* + * any stuff for getting information on symbols + */ imp_mod_handle imh; void *pointer; }; struct imp_type_handle { - /* any stuff for getting information on types */ + /* + * any stuff for getting information on types + */ imp_mod_handle imh; void *pointer; }; struct imp_cue_handle { - /* any stuff for getting information on source line cues */ + /* + * any stuff for getting information on source line cues + */ imp_mod_handle imh; void *pointer; }; -/* Remember that that imp_[sym/type/cue]_handle's may be freely copied and - destroyed by clients. No pointers to allocated memory unless there's - another pointer somewhere else to free that memory. Clients don't have - tell you how long they're hanging on to a handle either. Nasty bunch. */ +/* + * Remember that that imp_[sym/type/cue]_handle's may be freely copied and + * destroyed by clients. No pointers to allocated memory unless there's + * another pointer somewhere else to free that memory. Clients don't have + * tell you how long they're hanging on to a handle either. Nasty bunch. + */ struct imp_image_handle { - /* This is the main structure that all other structures for an - image (executable file) are hung off of. NO globals allowed. - A single DIP may be used for multiple images. */ + /* + * This is the main structure that all other structures for an + * image (executable file) are hung off of. NO globals allowed. + * A single DIP may be used for multiple images. + */ struct section_info *sect; unsigned num_sects; FILE *sym_fp; diff --git a/bld/dip/watcom/c/wataddr.c b/bld/dip/watcom/c/wataddr.c index a79ad99baa..787b2eed24 100644 --- a/bld/dip/watcom/c/wataddr.c +++ b/bld/dip/watcom/c/wataddr.c @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -68,15 +69,13 @@ static struct { * therefore it must be discarded when determining the number of * addr_dbg_info structures present. */ - #define GET_SEG_COUNT( ptr ) (((seg_dbg_info *)ptr)->count & SEG_COUNT_MASK) -/* - * AdjustAddrs -- adjust the addresses to reflect loader relocations - */ - void AdjustAddrInit( void ) +/************************** + * adjust the addresses to reflect loader relocations + */ { NonSectStart = 0xffff; NonSectEnd = 0; @@ -137,12 +136,11 @@ void AdjustAddrs( imp_image_handle *iih, unsigned sectno ) } -/* - * FindAddrInfo -- return the module and mem_block that addr is in - */ - static dip_status SectFindAddrInfo( section_info *inf, address addr, imp_mod_handle *imh, mem_block *code ) +/********************************************************************* + * return the module and mem_block that addr is in + */ { seg_dbg_info *ptr; seg_dbg_info *end; @@ -211,11 +209,10 @@ static dip_status FindAddrInfo( imp_image_handle *iih, address addr, } -/* - * FindModBase -- return the start address for the code for a module - */ - address FindModBase( imp_image_handle *iih, imp_mod_handle imh ) +/*************************************************************** + * return the start address for the code for a module + */ { seg_dbg_info *ptr; seg_dbg_info *end; @@ -246,11 +243,10 @@ address FindModBase( imp_image_handle *iih, imp_mod_handle imh ) return( NilAddr ); } -/* - * FindSegBlock -- return the mem_block for a segment - */ - mem_block FindSegBlock( imp_image_handle *iih, imp_mod_handle imh, unsigned long offset ) +/**************************************************************************************** + * return the mem_block for a segment + */ { seg_dbg_info *ptr; seg_dbg_info *next; @@ -322,10 +318,12 @@ void AddrInfoFini( section_info *inf ) /* - * DIPImpAddrMod -- return the mod_handle for the given address + * DIPImpAddrMod */ - search_result DIPIMPENTRY( AddrMod )( imp_image_handle *iih, address addr, imp_mod_handle *imh ) +/*********************************************************************************************** + * return the mod_handle for the given address + */ { mem_block code; diff --git a/bld/dip/watcom/c/watdmnd.c b/bld/dip/watcom/c/watdmnd.c index 837f02014f..f3c53eede5 100644 --- a/bld/dip/watcom/c/watdmnd.c +++ b/bld/dip/watcom/c/watdmnd.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2019 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -37,7 +37,9 @@ #include "watldsym.h" -/* WD looks for this symbol to determine module bitness */ +/* + * WD looks for this symbol to determine module bitness + */ #if !defined( __WINDOWS__ ) int __nullarea; #if defined( __WATCOMC__ ) @@ -77,10 +79,10 @@ static unsigned TimeStamp; #define STASH_DMND_PTR( p ) ((pointer_uint)(p) | RESIDENT) -/* - * InfoSize -- return size of demand info section - */ unsigned InfoSize( imp_image_handle *iih, imp_mod_handle imh, demand_kind dk, word entry ) +/***************************************************************************************** + * return size of demand info section + */ { demand_info *dmnd; section_info *inf; @@ -95,10 +97,6 @@ unsigned InfoSize( imp_image_handle *iih, imp_mod_handle imh, demand_kind dk, wo } -/* - * InitDemand -- allocate a last chance demand info location - */ - struct walk_demand { unsigned long max_size; }; @@ -150,6 +148,9 @@ static void Unload( demand_ctrl *section ) } dip_status InitDemand( imp_image_handle *iih ) +/********************************************* + * allocate a last chance demand info location + */ { struct walk_demand d; @@ -216,11 +217,10 @@ void InfoClear( imp_image_handle *iih ) MyWalkModList( iih, WlkClear, NULL ); } -/* - * InfoUnlock -- arbitrarily set all demand section lock counts to zero - */ - void InfoUnlock( void ) +/********************** + * arbitrarily set all demand section lock counts to zero + */ { demand_ctrl *section; @@ -233,12 +233,11 @@ void InfoUnlock( void ) } -/* - * InfoLoad -- load demand info - */ - void *InfoLoad( imp_image_handle *iih, imp_mod_handle imh, demand_kind dk, word entry, void (*clear)(void *, void *) ) +/************************************************************************* + * load demand info + */ { demand_ctrl *section; demand_info *info; @@ -264,19 +263,27 @@ void *InfoLoad( imp_image_handle *iih, imp_mod_handle imh, demand_kind dk, if( IS_RESIDENT( *lnk ) ) { section = MK_DMND_PTR( *lnk ); } else { - /* section not loaded */ + /* + * section not loaded + */ size = (unsigned)DMND_SIZE( sect, real_entry ); if( ( LastDemand->owner == NULL || LastDemand->size < size ) && LastDemand->locks == 0 ) { - /* keep largest section in LastDemand */ + /* + * keep largest section in LastDemand + */ section = LastDemand; Unload( LastDemand ); } else { - /* allocate some memory */ + /* + * allocate some memory + */ section = DCAlloc( _demand_size( size ) ); if( section == NULL ) { if( LastDemand->locks != 0 ) return( NULL ); - /* no memory, use last chance */ + /* + * no memory, use last chance + */ section = LastDemand; Unload( LastDemand ); } @@ -312,28 +319,24 @@ static void AdjustLockCount( const char *p, int adjust ) section->locks += adjust; } -/* +void InfoSpecLock( const char *p ) +/********************************* * Increment the lock count for a specific demand load section */ -void InfoSpecLock( const char *p ) { AdjustLockCount( p, 1 ); } -/* +void InfoSpecUnlock( const char *p ) +/*********************************** * Decrement the lock count for a specific demand load section */ -void InfoSpecUnlock( const char *p ) { AdjustLockCount( p, -1 ); } -/* - * InfoRelease -- release the least recently used section - */ - static dip_status ReleaseFromList( void ) { demand_ctrl *release; @@ -355,11 +358,16 @@ static dip_status ReleaseFromList( void ) } dip_status InfoRelease( void ) +/***************************** + * release the least recently used section + */ { if( ReleaseFromList() == DS_OK ) return( DS_OK ); if( LastDemand != NULL && LastDemand->locks == 0 && LastDemand->clear != NULL ) { - /* let's hope the clear routine frees up some memory */ + /* + * let's hope the clear routine frees up some memory + */ Unload( LastDemand ); return( DS_OK ); } diff --git a/bld/dip/watcom/c/watgbl.c b/bld/dip/watcom/c/watgbl.c index bd897d8d99..381285ac9b 100644 --- a/bld/dip/watcom/c/watgbl.c +++ b/bld/dip/watcom/c/watgbl.c @@ -87,11 +87,10 @@ void GblSymFini( section_info *inf ) } } -/* - * GblNamHash -- hash a symbol name - */ - static unsigned GblNameHash( const char *name, size_t name_len ) +/*************************************************************** + * hash a symbol name + */ { unsigned rtrn; @@ -120,7 +119,9 @@ static int source_name( const char *gstart, size_t glen, const char **rstart, si *rstart = gstart; gstart = memchr( gstart, '@', glen ); if( gstart != NULL ) { - /* stupid MS stdcall with it's stupid trailing "@" */ + /* + * stupid MS stdcall with it's stupid trailing "@" + */ glen = gstart - *rstart; type = __MANGLED; } @@ -138,9 +139,6 @@ static int source_name( const char *gstart, size_t glen, const char **rstart, si return( type ); } -/* - * SearchGbl -- look up a global symbol name - */ static search_result LkupGblName( imp_image_handle *iih, section_info *inf, imp_mod_handle curr_imh, imp_mod_handle imh, lookup_item *li, void *d ) { @@ -170,7 +168,9 @@ static search_result LkupGblName( imp_image_handle *iih, section_info *inf, imp_ lkup_dtor = (li->type == ST_DESTRUCTOR); lkup_full = false; - /* only want to hash the source code portion of the name */ + /* + * only want to hash the source code portion of the name + */ switch( source_name( li->name.start, li->name.len, &snam, &snamlen ) ) { case __NOT_MANGLED: nam = snam; @@ -236,10 +236,13 @@ static search_result LkupGblName( imp_image_handle *iih, section_info *inf, imp_ ish = DCSymCreate( iih, d ); ish->imh = GBL_MOD( gbl ); MK_ADDR( addr, gbl->addr, inf->sect_id ); - /* need to see if there's a local symbol at the right - address and use that instead */ + /* + * need to see if there's a local symbol at the right address and use that instead + */ if( curr_imh == ish->imh ) { - /* We've already checked the local symbols. It ain't there. */ + /* + * We've already checked the local symbols. It ain't there. + */ GblCreate( iih, ish, gbl ); } else if( LookupLclAddr( iih, addr, ish ) == SR_EXACT ) { SetGblLink( ish, gbl ); @@ -254,6 +257,9 @@ static search_result LkupGblName( imp_image_handle *iih, section_info *inf, imp_ search_result SearchGbl( imp_image_handle *iih, imp_mod_handle curr_imh, imp_mod_handle imh, lookup_item *li, void *d ) +/*********************************************************************** + * look up a global symbol name + */ { section_info *inf; section_info *end; @@ -287,10 +293,10 @@ static int MachAddrComp( addr_ptr a1, imp_mod_handle imh1, return( 0 ); } -/* - * LookupGblAddr -- look up a global address - */ static search_result LkupGblAddr( info_block *inf, imp_sym_handle *ish, addr_ptr addr ) +/************************************************************************************** + * look up a global address + */ { gbl_link *low, *high; gbl_link *nearest; @@ -355,11 +361,10 @@ search_result LookupGblAddr( imp_image_handle *iih, address addr, imp_sym_handle } -/* - * Insert -- insert into hash table - */ - static void Insert( imp_image_handle *iih, info_block *inf, gbl_link *new ) +/************************************************************************** + * insert into hash table + */ { hash_link *owner; gbl_info *gbl; @@ -368,7 +373,9 @@ static void Insert( imp_image_handle *iih, info_block *inf, gbl_link *new ) size_t name_len; gbl = new->gbl; - /* only want to hash the source code portion of the name */ + /* + * only want to hash the source code portion of the name + */ mangled_name = GBL_NAME( iih, gbl ); new->dtor = ( source_name( mangled_name, GBL_NAMELEN( iih, gbl ), &name, &name_len ) == __MANGLED_DTOR ); new->src_off = name - mangled_name; @@ -388,10 +395,10 @@ static int CmpInfo( const void *a, const void *b ) } -/* - * AdjustSyms -- adjust symbol table info according to start segment location - */ void AdjustSyms( imp_image_handle *iih, unsigned sectno ) +/******************************************************** + * adjust symbol table info according to start segment location + */ { info_block *ginf; gbl_link *lnk; @@ -481,7 +488,9 @@ unsigned GblSymSplit( imp_image_handle *iih, info_block *gbl, section_info *inf /* unused parameters */ (void)inf; ptr = gbl->info; - /* check if there is enough there to pick up the name length field */ + /* + * check if there is enough there to pick up the name length field + */ for( total = 0; ( total + sizeof( gbl_info ) + 1 ) <= gbl->size; total = next ) { size = GBL_SIZE( iih, (gbl_info *)ptr ); next = total + size; @@ -621,10 +630,10 @@ walk_result WalkGblModSymList( imp_image_handle *iih, imp_mod_handle imh, seen_module = true; } else if( seen_module ) { /* - WARNING: Assuming that all the publics for a - particular module are right next to each other - in the info. - */ + * WARNING: Assuming that all the publics for a + * particular module are right next to each other + * in the info. + */ return( WR_CONTINUE ); } } diff --git a/bld/dip/watcom/c/watlcl.c b/bld/dip/watcom/c/watlcl.c index f51d631a69..1de3eff103 100644 --- a/bld/dip/watcom/c/watlcl.c +++ b/bld/dip/watcom/c/watlcl.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -98,11 +98,10 @@ static void LclCreate( imp_sym_handle *ish, const char *ptr, const char *name, l ish->name_off = (byte)( name - ptr ); } -/* - * LoadLocalSyms -- load the local symbol information for the module - */ - static dip_status LoadLocalSyms( imp_image_handle *iih, imp_mod_handle imh, lclinfo *new ) +/***************************************************************************************** + * load the local symbol information for the module + */ { dip_status ds; @@ -129,13 +128,15 @@ static void PopLocal( lclinfo *local ) void KillLclLoadStack( void ) { - // Nothing to do - not using globals anymore + /* + * Nothing to do - not using globals anymore + */ } -/* - * ProcBlock -- process a block definition - */ static const char *ProcBlock( imp_image_handle *iih, const char *ptr, lcl_defn *defn, lclinfo *local ) +/***************************************************************************************************** + * process a block definition + */ { if( local->base_off == NO_BASE ) { defn->b.start = FindModBase( iih, local->imh ); @@ -159,10 +160,10 @@ static const char *ProcBlock( imp_image_handle *iih, const char *ptr, lcl_defn * } -/* - * ProcDefn -- process the next definition in the local symbol information - */ static const char *ProcDefn( imp_image_handle *iih, const char *ptr, lcl_defn *defn, lclinfo *local ) +/**************************************************************************************************** + * process the next definition in the local symbol information + */ { const char *end; unsigned parms; @@ -219,7 +220,9 @@ static const char *ProcDefn( imp_image_handle *iih, const char *ptr, lcl_defn *d ptr = GetIndex( ptr, &defn->i.type_index ); if( ptr < end ) { defn->i.unparsed = ptr; - /* skip the 'this' pointer type and the object loc expr */ + /* + * skip the 'this' pointer type and the object loc expr + */ ptr = SkipLocation( ptr + 1 ); } else { defn->i.unparsed = NULL; @@ -475,7 +478,9 @@ search_result LookupLclAddr( imp_image_handle *iih, address addr, imp_sym_handle mod_addr = DefnAddr( iih, &defn, local ); if( DCSameAddrSpace( addr, mod_addr ) == DS_OK ) { if( addr.mach.offset >= mod_addr.mach.offset ) { - /* possible */ + /* + * possible + */ if( sr == SR_NONE || close_addr.mach.offset <= mod_addr.mach.offset ) { LclCreate( ish, curr, defn.i.name, local ); close_addr = mod_addr; @@ -813,7 +818,9 @@ static walk_result WalkOneBlock( imp_image_handle *iih, const char *ptr, lcl_def wr = WR_CONTINUE; switch( blk->i.class ) { case CODE_SYMBOL | CODE_MEMBER_SCOPE: - /* process member list */ + /* + * process member list + */ if( FindTypeHandle( iih, local->imh, blk->i.type_index, &ith ) == DS_OK ) { wr = WalkTypeSymList( iih, &ith, wk, ish, d ); } @@ -824,7 +831,9 @@ static walk_result WalkOneBlock( imp_image_handle *iih, const char *ptr, lcl_def case CODE_SYMBOL | CODE_NEAR_ROUT386: case CODE_SYMBOL | CODE_FAR_ROUT: case CODE_SYMBOL | CODE_FAR_ROUT386: - /* process local scope */ + /* + * process local scope + */ for( ; (ptr = FindLclVar( iih, ptr, local )) != NULL; ptr = next ) { next = ProcDefn( iih, ptr, &defn, local ); LclCreate( ish, ptr, defn.i.name, local ); diff --git a/bld/dip/watcom/c/watldsym.c b/bld/dip/watcom/c/watldsym.c index 4a53220c7d..ee74df5afe 100644 --- a/bld/dip/watcom/c/watldsym.c +++ b/bld/dip/watcom/c/watldsym.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -51,10 +51,6 @@ static void FreeInfBlks( info_block *blk ) } } -/* - * DIPImpUnloadInfo -- unload the symbolic information for an image - */ - static void UnloadInfo( imp_image_handle *iih ) { section_info *inf; @@ -75,20 +71,25 @@ static void UnloadInfo( imp_image_handle *iih ) DCFree( iih->lang ); } +/* + * DIPImpUnloadInfo + */ void DIPIMPENTRY( UnloadInfo )( imp_image_handle *iih ) +/****************************************************** + * unload the symbolic information for an image + */ { InfoClear( iih ); UnloadInfo( iih ); } -/* - * GetBlockInfo -- get permanent information into memory - */ - static dip_status GetBlockInfo( imp_image_handle *iih, section_info *new, unsigned long off, dword size, info_block **owner, unsigned (*split)(imp_image_handle *, info_block *, section_info *) ) +/************************************************************************************************ + * get permanent information into memory + */ { size_t split_size; info_block *curr; @@ -124,11 +125,10 @@ static dip_status GetBlockInfo( imp_image_handle *iih, section_info *new, unsign } -/* - * GetNumSect - find the number of sections for this load - */ - static dip_status GetNumSect( FILE *fp, unsigned long curr, unsigned long end, unsigned *count ) +/*********************************************************************************************** + * find the number of sections for this load + */ { section_dbg_header header; @@ -138,8 +138,10 @@ static dip_status GetNumSect( FILE *fp, unsigned long curr, unsigned long end, u DCStatus( DS_ERR | DS_INFO_INVALID ); return( DS_ERR | DS_INFO_INVALID ); } - /* if there are no modules in the section, it's a 'placekeeper' section - for the linker overlay structure -- just ignore it */ + /* + * if there are no modules in the section, it's a 'placekeeper' section + * for the linker overlay structure -- just ignore it + */ if( header.mod_offset != header.gbl_offset ) { if( header.mod_offset > header.gbl_offset ) { DCStatus( DS_ERR | DS_INFO_INVALID ); @@ -169,7 +171,6 @@ static dip_status GetNumSect( FILE *fp, unsigned long curr, unsigned long end, u * This function assumes that section 0 is the lowest numbered section and * that section numbers are contiguous */ - static dip_status ProcSectionsInfo( imp_image_handle *iih, unsigned num_sects ) { section_dbg_header header; @@ -186,8 +187,10 @@ static dip_status ProcSectionsInfo( imp_image_handle *iih, unsigned num_sects ) new->addr_info = NULL; new->gbl = NULL; new->dmnd_link = NULL; - /* if there are no modules in the section, it's a 'placekeeper' section - for the linker overlay structure -- just ignore it */ + /* + * if there are no modules in the section, it's a 'placekeeper' section + * for the linker overlay structure -- just ignore it + */ if( header.mod_offset != header.gbl_offset ) { ds = GetBlockInfo( iih, new, header.mod_offset + pos, header.gbl_offset - header.mod_offset, @@ -318,9 +321,12 @@ static dip_status DoPermInfo( imp_image_handle *iih ) } /* - * DIPImpLoadInfo -- process symbol table info on end of .exe file + * DIPImpLoadInfo */ dip_status DIPIMPENTRY( LoadInfo )( FILE *fp, imp_image_handle *iih ) +/******************************************************************** + * process symbol table info on end of .exe file + */ { dip_status ds; @@ -335,11 +341,10 @@ dip_status DIPIMPENTRY( LoadInfo )( FILE *fp, imp_image_handle *iih ) } -/* - * InfoRead -- read demand information from disk - */ - dip_status InfoRead( FILE *fp, unsigned long offset, size_t size, void *buff ) +/***************************************************************************** + * read demand information from disk + */ { if( DCSeek( fp, offset, DIG_SEEK_ORG ) ) { DCStatus( DS_ERR | DS_FSEEK_FAILED ); @@ -353,13 +358,13 @@ dip_status InfoRead( FILE *fp, unsigned long offset, size_t size, void *buff ) } - /* - * DIPImpMapInfo -- change all map addresses into real addresses + * DIPImpMapInfo */ - - void DIPIMPENTRY( MapInfo )( imp_image_handle *iih, void *d ) +/************************************************************ + * change all map addresses into real addresses + */ { unsigned i; @@ -376,15 +381,16 @@ void DIPIMPENTRY( MapInfo )( imp_image_handle *iih, void *d ) } -/* +void AddressMap( imp_image_handle *iih, addr_ptr *addr ) +/******************************************************* * AddressMap - take a map address and turn it into a real address */ - -void AddressMap( imp_image_handle *iih, addr_ptr *addr ) { unsigned i; - /* could probably binary search this */ + /* + * could probably binary search this + */ for( i = 0; i < iih->num_segs; ++i ) { if( addr->segment == iih->map_segs[i] ) { addr->segment = iih->real_segs[i].segment; diff --git a/bld/dip/watcom/c/watlnum.c b/bld/dip/watcom/c/watlnum.c index e669f277b7..ad2d5bda36 100644 --- a/bld/dip/watcom/c/watlnum.c +++ b/bld/dip/watcom/c/watlnum.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2018 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -177,10 +177,6 @@ static size_t SpecCueFile( imp_image_handle *iih, imp_cue_handle *icueh, } -/* - * GetLineInfo -- get the line number infomation for a module - */ - static void UnlockLine( void ) { if( LinStart != NULL ) { @@ -191,6 +187,9 @@ static void UnlockLine( void ) static dip_status GetLineInfo( imp_image_handle *iih, imp_mod_handle imh, word entry ) +/************************************************************************************* + * get the line number infomation for a module + */ { if( entry != 0 ) UnlockLine(); @@ -213,9 +212,13 @@ static line_dbg_info *FindLineOff( addr_off off, addr_off adj, const char *dummy; low = 0; - /* get number of entries minus one */ + /* + * get number of entries minus one + */ high = ( end - start ) / sizeof( line_dbg_info ) - 1; - /* point at first entry */ + /* + * point at first entry + */ ln_ptr = (line_dbg_info *)start; while( low <= high ) { target = (low + high) >> 1; @@ -226,7 +229,9 @@ static line_dbg_info *FindLineOff( addr_off off, addr_off adj, low = target + 1; } else { /* exact match */ if( ln_ptr[target].line >= PRIMARY_RANGE ) { - /* a special cue - have to make sure we have the table */ + /* + * a special cue - have to make sure we have the table + */ if( close->have_spec_table == ST_UNKNOWN ) { if( FindSpecCueTable( iih, close->icueh.imh, &dummy ) != NULL ) { close->have_spec_table = ST_YES; @@ -240,14 +245,18 @@ static line_dbg_info *FindLineOff( addr_off off, addr_off adj, } else { return( ln_ptr + target ); } - /* if it's a special & we don't have the table, ignore entry */ + /* + * if it's a special & we don't have the table, ignore entry + */ high = target - 1; } } if( high < 0 ) return( NULL ); if( ln_ptr[high].line >= PRIMARY_RANGE ) { - /* a special cue - have to make sure we have the table */ + /* + * a special cue - have to make sure we have the table + */ if( close->have_spec_table == ST_UNKNOWN ) { if( FindSpecCueTable( iih, close->icueh.imh, &dummy ) != NULL ) { close->have_spec_table = ST_YES; @@ -256,7 +265,9 @@ static line_dbg_info *FindLineOff( addr_off off, addr_off adj, } } if( close->have_spec_table == ST_NO ) { - /* if it's a special & we don't have the table, ignore entry */ + /* + * if it's a special & we don't have the table, ignore entry + */ for( ;; ) { --high; if( high < 0 ) @@ -477,7 +488,9 @@ walk_result DIPIMPENTRY( WalkFileList )( imp_image_handle *iih, imp_mod_handle i UnlockLine(); } if( icueh->entry == 0 ) { - /* Module with no line cues. Fake one up. */ + /* + * Module with no line cues. Fake one up. + */ icueh->entry = NO_LINE; return( wk( iih, icueh, d ) ); } @@ -617,7 +630,9 @@ static dip_status AdjBackward( imp_image_handle *iih, imp_cue_handle *icueh ) } icueh->entry--; if( icueh->entry == 0 ) { - /* special handling since we're walking backwards */ + /* + * special handling since we're walking backwards + */ UnlockLine(); } icueh->seg_bias = BIAS( seg ); diff --git a/bld/dip/watcom/c/watloc.c b/bld/dip/watcom/c/watloc.c index 6374710b77..c9e097a66f 100644 --- a/bld/dip/watcom/c/watloc.c +++ b/bld/dip/watcom/c/watloc.c @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -159,7 +160,9 @@ static unsigned SizeLocation( const char *e ) return( 1 ); } } - /* should never get here */ + /* + * should never get here + */ return( 1 ); } @@ -521,7 +524,9 @@ dip_status EvalLocation( imp_image_handle *iih, location_context *lc, const char op1 = sp; --sp; if( op1->type == LS_ADDR ) { - /* get the address into sp */ + /* + * get the address into sp + */ tmp.lse = *sp; *sp = *op1; *op1 = tmp.lse; @@ -544,12 +549,16 @@ dip_status EvalLocation( imp_image_handle *iih, location_context *lc, const char ++sp; break; case OPERATOR | LOP_NOP: - /* well, what did you expect? */ + /* + * well, what did you expect? + */ break; } } if( LocStkPtr == 0 && sp == start ) { - /* empty location */ + /* + * empty location + */ ds = DS_ERR | DS_BAD_LOCATION; goto done; } diff --git a/bld/dip/watcom/c/watmod.c b/bld/dip/watcom/c/watmod.c index 1e070a5435..e0b5f3d3dd 100644 --- a/bld/dip/watcom/c/watmod.c +++ b/bld/dip/watcom/c/watmod.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -65,11 +65,11 @@ section_info *FindInfo( imp_image_handle *iih, imp_mod_handle imh ) return( inf ); } -/* - * ModPointer - given a mod_handle, return the module information pointer - */ mod_dbg_info *ModPointer( imp_image_handle *iih, imp_mod_handle imh ) +/******************************************************************** + * given a mod_handle, return the module information pointer + */ { info_block *blk; mod_table *tbl; @@ -90,11 +90,10 @@ mod_dbg_info *ModPointer( imp_image_handle *iih, imp_mod_handle imh ) return( NULL ); } -/* - * AllocLinkTable - allocate the demand load link table - * - */ static dip_status AllocLinkTable( imp_image_handle *iih, section_info *inf, dword num_links, dword first_link ) +/************************************************************************************************************** + * allocate the demand load link table + */ { pointer_uint **lnk_tbl; pointer_uint *lnk; @@ -184,12 +183,12 @@ static dip_status AllocLinkTable( imp_image_handle *iih, section_info *inf, dwor } -/* +dip_status AdjustMods( imp_image_handle *iih, section_info *inf, unsigned long adjust ) +/************************************************************************************** * AdjustMods - adjust the demand info offsets in all the modules * - allocate module index table * - allocate demand load link table */ -dip_status AdjustMods( imp_image_handle *iih, section_info *inf, unsigned long adjust ) { info_block *blk; unsigned count; @@ -297,11 +296,10 @@ void SetModBase( imp_image_handle *iih ) } -/* - * ModInfoFini - free module index table - */ - void ModInfoFini( section_info *inf ) +/************************************ + * free module index table + */ { info_block *blk; pointer_uint **lnk_tbl; @@ -321,11 +319,10 @@ void ModInfoFini( section_info *inf ) } } -/* - * ModInfoSplit - find a good place to split module information - */ - unsigned ModInfoSplit( imp_image_handle *iih, info_block *blk, section_info *inf ) +/********************************************************************************* + * find a good place to split module information + */ { unsigned off; unsigned prev; @@ -356,11 +353,14 @@ word ModOff2Idx( section_info *inf, word off ) return( count ); } + /* - * DIPImpWalkModList - walk the module list + * DIPImpWalkModList */ - walk_result DIPIMPENTRY( WalkModList )( imp_image_handle *iih, DIP_IMP_MOD_WALKER *wk, void *d ) +/*********************************************************************************************** + * walk the module list + */ { info_block *blk; mod_table *tbl; @@ -416,19 +416,23 @@ walk_result MyWalkModList( imp_image_handle *iih, DIP_INT_MOD_WALKER *wk, void * /* - * ModSrcLang -- return pointer to name of source language of the module + * DIPImpModSrcLang */ - char *DIPIMPENTRY( ModSrcLang )( imp_image_handle *iih, imp_mod_handle imh ) +/************************************************************************ + * return pointer to name of source language of the module + */ { return( iih->lang + ModPointer( iih, imh )->language ); } /* - * DIPImpModInfo - does a module have a particular brand of info + * DIPImpModInfo */ - dip_status DIPIMPENTRY( ModInfo )( imp_image_handle *iih, imp_mod_handle imh, handle_kind hk ) +/********************************************************************************************* + * does a module have a particular brand of info + */ { mod_dbg_info *mod; static unsigned DmndType[] = { @@ -443,17 +447,20 @@ dip_status DIPIMPENTRY( ModInfo )( imp_image_handle *iih, imp_mod_handle imh, ha return( mod->di[DmndType[hk]].u.entries != 0 ? DS_OK : DS_FAIL ); } -//NYI: should be OS && location sensitive +/* + * NYI: should be OS && location sensitive + */ #define IS_PATH_CHAR( c ) ((c)=='\\'||(c)=='/'||(c)==':') #define EXT_CHAR '.' /* - * DIPImpModName -- return the module name + * DIPImpModName + */ +size_t DIPIMPENTRY( ModName )( imp_image_handle *iih, imp_mod_handle imh, char *buff, size_t buff_size ) +/******************************************************************************************************* + * return the module name */ - -size_t DIPIMPENTRY( ModName )( imp_image_handle *iih, imp_mod_handle imh, - char *buff, size_t buff_size ) { char *name; char *start; @@ -470,7 +477,9 @@ size_t DIPIMPENTRY( ModName )( imp_image_handle *iih, imp_mod_handle imh, ++name; end = start + 1; if( *start == ')' ) { - /* library member */ + /* + * library member + */ --end; for( ;; ) { --start; @@ -480,7 +489,9 @@ size_t DIPIMPENTRY( ModName )( imp_image_handle *iih, imp_mod_handle imh, } ++start; } else { - /* file name */ + /* + * file name + */ start = name; for( ; len > 0; --len ) { if( IS_PATH_CHAR( *name ) ) { @@ -503,12 +514,11 @@ size_t DIPIMPENTRY( ModName )( imp_image_handle *iih, imp_mod_handle imh, return( len ); } -/* - * PrimaryCueFile -- return the module source file - */ - size_t PrimaryCueFile( imp_image_handle *iih, imp_cue_handle *icueh, char *buff, size_t buff_size ) +/******************************************************************* + * return the module source file + */ { size_t len; char *name; diff --git a/bld/dip/watcom/c/wattype.c b/bld/dip/watcom/c/wattype.c index 12d7ef105b..ba0d042c65 100644 --- a/bld/dip/watcom/c/wattype.c +++ b/bld/dip/watcom/c/wattype.c @@ -659,10 +659,12 @@ static search_result SearchEnumTypeName( imp_image_handle *iih, imp_mod_handle i } else { ish->type = SH_TYP; } - /* we really should continue searching for more names that - match, but we're going to early out because I know that - the symbolic info format is too weak to have more than - one type name or enum const that will match */ + /* + * we really should continue searching for more names that + * match, but we're going to early out because I know that + * the symbolic info format is too weak to have more than + * one type name or enum const that will match + */ sr = SR_EXACT; break; } @@ -915,10 +917,12 @@ static dip_status GetTypeInfo(imp_image_handle *iih, imp_type_handle *ith, } if( skip > 0 ) { GetIndex( p + skip, &index ); - /* Pulling a trick. We know that the size - field will only be absent in older objects, - and thus will only have one type section per - module. */ + /* + * Pulling a trick. We know that the size + * field will only be absent in older objects, + * and thus will only have one type section per + * module. + */ FindTypeHandle( iih, ith->imh, index, &tmp_ith ); GetTypeInfo( iih, &tmp_ith, lc, ti, NULL ); offset += ti->size; @@ -1157,7 +1161,9 @@ dip_status DIPIMPENTRY( TypeProcInfo )(imp_image_handle *iih, imp_type_handle *i ++p; for( ;; ) { if( p == end ) { - /* handle EXT_PARMS record */ + /* + * handle EXT_PARMS record + */ p += 2; end = NEXT_TYPE( p ); } @@ -1418,7 +1424,9 @@ dip_status SymHdl2MbrLoc( imp_image_handle *iih, imp_sym_handle *ish, } if( ds == DS_OK ) { FreeLoad(); - /* reverse the inheritance list */ + /* + * reverse the inheritance list + */ new = NULL; while( pending != NULL ) { tmp = pending; @@ -1426,7 +1434,9 @@ dip_status SymHdl2MbrLoc( imp_image_handle *iih, imp_sym_handle *ish, tmp->prev = new; new = tmp; } - /* do the adjustors at each level */ + /* + * do the adjustors at each level + */ ds = DCItemLocation( lc, CI_OBJECT, ll ); if( ds != DS_OK ) { DCStatus( ds ); @@ -1461,7 +1471,9 @@ dip_status SymHdl2MbrLoc( imp_image_handle *iih, imp_sym_handle *ish, } } if( ds == DS_OK ) { - /* do field offset and bit field selection */ + /* + * do field offset and bit field selection + */ bit_start = 0; bit_len = 0; switch( MGET_U8( p + 1 ) ) { @@ -1632,7 +1644,9 @@ dip_status DIPIMPENTRY( TypeThunkAdjust )( imp_image_handle *iih, } } if( ds == DS_OK ) { - /* reverse the inheritance list */ + /* + * reverse the inheritance list + */ new = NULL; while( pending != NULL ) { tmp = pending; @@ -1640,7 +1654,9 @@ dip_status DIPIMPENTRY( TypeThunkAdjust )( imp_image_handle *iih, tmp->prev = new; new = tmp; } - /* do the adjustors at each level */ + /* + * do the adjustors at each level + */ while( new != NULL ) { ds = LoadType( iih, oith->imh, new->entry ); if( ds != DS_OK ) { @@ -1771,7 +1787,9 @@ walk_result WalkTypeSymList( imp_image_handle *iih, imp_type_handle *ith, wr = WR_CONTINUE; for( ;; ) { while( count != 0 ) { - /* structure list is backwards -- reverse it */ + /* + * structure list is backwards -- reverse it + */ p = NEXT_TYPE( p ); if( used == NULL ) { new_entry = walloca( sizeof( *new_entry ) ); @@ -1814,7 +1832,9 @@ walk_result WalkTypeSymList( imp_image_handle *iih, imp_type_handle *ith, list = NULL; p = Type->start + new_ith.t.offset; count = MGET_U16( p + 2 ); - /* setting count will cause the list to be reversed */ + /* + * setting count will cause the list to be reversed + */ continue; } } else { diff --git a/bld/dip/watcom/h/dbcue.h b/bld/dip/watcom/h/dbcue.h index e7fbd06256..c50b1ca53b 100644 --- a/bld/dip/watcom/h/dbcue.h +++ b/bld/dip/watcom/h/dbcue.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -30,7 +31,9 @@ ****************************************************************************/ -/* this stuff is written out by wvtypes.c in codegen */ +/* + * this stuff is written out by wvtypes.c in codegen + */ #include "pushpck1.h" typedef struct cue_state{ diff --git a/bld/dip/watcom/h/dipwat.h b/bld/dip/watcom/h/dipwat.h index a94fbffd3b..db335873be 100644 --- a/bld/dip/watcom/h/dipwat.h +++ b/bld/dip/watcom/h/dipwat.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2019 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -57,15 +57,21 @@ typedef struct type_pos { typedef struct imp_sym_handle { imp_mod_handle imh; union { - /* for SH_GBL */ + /* + * for SH_GBL + */ gbl_info *gbl; - /* for SH_LCL */ + /* + * for SH_LCL + */ struct { unsigned short base; unsigned short offset; gbl_info *gbl_link; } lcl; - /* for SH_MBR, SH_TYP, SH_CST */ + /* + * for SH_MBR, SH_TYP, SH_CST + */ struct { struct type_pos t; struct type_pos h; diff --git a/bld/dip/watcom/h/watlcl.h b/bld/dip/watcom/h/watlcl.h index 4d0a66d23a..e1ef4cc125 100644 --- a/bld/dip/watcom/h/watlcl.h +++ b/bld/dip/watcom/h/watlcl.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -37,18 +38,22 @@ typedef struct { unsigned char namelen; unsigned type_index; const char *name; - /* stuff that we don't have to parse until we know we want the lcl */ + /* + * stuff that we don't have to parse until we know we want the lcl + */ const char *unparsed; } lcl_info; -/* variable, class = 1x */ - +/* + * variable, class = 1x + */ typedef struct { lcl_info i; } lcl_variable; -/* code, class = 2x */ - +/* + * code, class = 2x + */ typedef struct { lcl_info i; unsigned int parent_block; @@ -77,13 +82,12 @@ typedef union { lcl_member m; } lcl_defn; - #define CLASS_MASK 0xf0 #define SUBCLASS_MASK 0x0f - -/* variables */ - +/* + * variables + */ #define VAR_SYMBOL 0x10 #define VAR_MODULE 0x00 #define VAR_LOCAL 0x01 @@ -104,7 +108,6 @@ typedef union { #define SET_BASE 0x01 #define SET_BASE386 0x02 - extern unsigned InfoSize( imp_image_handle *, imp_mod_handle, demand_kind dk, word entry ); extern void *InfoLoad( imp_image_handle *, imp_mod_handle, demand_kind dk, word entry, void (*clear)(void *, void *) ); extern void InfoClear( imp_image_handle * ); diff --git a/bld/dip/watcom/h/watloc.h b/bld/dip/watcom/h/watloc.h index 22a5e8815a..8bd8dd9361 100644 --- a/bld/dip/watcom/h/watloc.h +++ b/bld/dip/watcom/h/watloc.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -32,7 +33,9 @@ #ifndef DBGLOC_INCLUDED #define DBGLOC_INCLUDED -/* locations */ +/* + * locations + */ #define CLASS_MASK 0xf0 #define SUBCLASS_MASK 0x0f @@ -79,36 +82,42 @@ #include "pushpck1.h" -/* no location, class 0x */ - +/* + * no location, class 0x + */ typedef struct { unsigned char class; } loc_void; -/* bp offset, class 1x */ - +/* + * bp offset, class 1x + */ typedef struct { unsigned char class; unsigned long offset; } _WCUNALIGNED loc_bp_off; -/* memory, class 2x */ - +/* + * memory, class 2x + */ typedef struct { unsigned char class; address addr; } _WCUNALIGNED loc_mem; -/* constant, class 2x */ - +/* + * constant, class 2x + */ typedef struct { unsigned char class; unsigned long val; } _WCUNALIGNED loc_const; -/* multiple registers, class 3x */ -/* register, class 4x */ - +/* + * multiple registers, class 3x + * + * register, class 4x + */ #define MAX_MULTI_REGS 4 #define EMPTY_MULTI_REG ((char)-1) typedef struct { @@ -117,8 +126,9 @@ typedef struct { unsigned char regs[MAX_MULTI_REGS]; } loc_mreg; -/* ind register, class 5x */ - +/* + * ind register, class 5x + */ typedef struct { unsigned char class; unsigned char off_reg; diff --git a/bld/dip/watcom/h/wattype.h b/bld/dip/watcom/h/wattype.h index 5726707ca4..2c2b5b9a09 100644 --- a/bld/dip/watcom/h/wattype.h +++ b/bld/dip/watcom/h/wattype.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -32,7 +33,9 @@ #include "watloc.h" -/* classes */ +/* + * classes + */ #define CLASS_MASK 0xf0 #define SUBCLASS_MASK 0x0f @@ -110,7 +113,9 @@ #define CHAR_DESC386_LEN 0x04 #define CHAR_DESC_LOC 0x05 -/* definition for 'scalar_type_byte' */ +/* + * definition for 'scalar_type_byte' + */ #define SCLR_LEN_MASK 0x0f #define SCLR_CLASS_MASK 0x70 From c3a2c61e94a0bab57b0f1277ac7047f7a0adaf5a Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Mon, 28 Aug 2023 08:26:30 +0200 Subject: [PATCH 029/258] reformat/update comments for source files --- bld/sdk/drwat/nt/digcli.c | 56 ++++++++++++++++++++++---------------- bld/sdk/drwat/win/digcli.c | 53 +++++++++++++++++++----------------- 2 files changed, 60 insertions(+), 49 deletions(-) diff --git a/bld/sdk/drwat/nt/digcli.c b/bld/sdk/drwat/nt/digcli.c index 36a60c18b6..6ab5fcbaf0 100644 --- a/bld/sdk/drwat/nt/digcli.c +++ b/bld/sdk/drwat/nt/digcli.c @@ -45,26 +45,26 @@ #include "clibext.h" -/* +void *DIGCLIENTRY( Alloc )( size_t size ) +/**************************************** * DIGCliAlloc */ -void *DIGCLIENTRY( Alloc )( size_t size ) { return( MemAlloc( size ) ); } -/* +void *DIGCLIENTRY( Realloc )( void *ptr, size_t size ) +/***************************************************** * DIGCliRealloc */ -void *DIGCLIENTRY( Realloc )( void *ptr, size_t size ) { return( MemRealloc( ptr, size ) ); } -/* +void DIGCLIENTRY( Free )( void *ptr ) +/************************************ * DIGCliFree */ -void DIGCLIENTRY( Free )( void *ptr ) { MemFree( ptr ); } @@ -75,10 +75,10 @@ void DIGCLIENTRY( Free )( void *ptr ) * !!! ISO or POSIX functions must not be used !!! */ -/* +FILE * DIGCLIENTRY( Open )( const char *path, dig_open mode ) +/************************************************************ * DIGCliOpen */ -FILE * DIGCLIENTRY( Open )( const char *path, dig_open mode ) { HFILE ret; int flags; @@ -93,17 +93,19 @@ FILE * DIGCLIENTRY( Open )( const char *path, dig_open mode ) flags |= OF_CREATE; if( mode & DIG_OPEN_CREATE ) flags |= OF_CREATE; - //NYI: should check for DIG_OPEN_SEARCH + /* + * NYI: should check for DIG_OPEN_SEARCH + */ ret = OpenFile( path, &tmp, flags ); if( ret == HFILE_ERROR ) return( NULL ); return( WH2FP( (HANDLE)ret ) ); } -/* +int DIGCLIENTRY( Seek )( FILE *fp, unsigned long offset, dig_seek where ) +/************************************************************************ * DIGCliSeek */ -int DIGCLIENTRY( Seek )( FILE *fp, unsigned long offset, dig_seek where ) { int mode; @@ -121,18 +123,18 @@ int DIGCLIENTRY( Seek )( FILE *fp, unsigned long offset, dig_seek where ) return( SetFilePointer( FP2WH( fp ), offset, 0, mode ) == INVALID_SET_FILE_POINTER ); } -/* +unsigned long DIGCLIENTRY( Tell )( FILE *fp ) +/******************************************** * DIGCliTell */ -unsigned long DIGCLIENTRY( Tell )( FILE *fp ) { return( SetFilePointer( FP2WH( fp ), 0, 0, FILE_CURRENT ) ); } -/* +size_t DIGCLIENTRY( Read )( FILE *fp, void *buf, size_t size ) +/************************************************************* * DIGCliRead */ -size_t DIGCLIENTRY( Read )( FILE *fp, void *buf, size_t size ) { DWORD bytesread; @@ -141,10 +143,10 @@ size_t DIGCLIENTRY( Read )( FILE *fp, void *buf, size_t size ) return( bytesread ); } -/* +size_t DIGCLIENTRY( Write )( FILE *fp, const void *buf, size_t size ) +/******************************************************************** * DIGCliWrite */ -size_t DIGCLIENTRY( Write )( FILE *fp, const void *buf, size_t size ) { DWORD byteswritten; @@ -153,18 +155,18 @@ size_t DIGCLIENTRY( Write )( FILE *fp, const void *buf, size_t size ) return( byteswritten ); } -/* +void DIGCLIENTRY( Close )( FILE *fp ) +/************************************ * DIGCliClose */ -void DIGCLIENTRY( Close )( FILE *fp ) { CloseHandle( FP2WH( fp ) ); } -/* +void DIGCLIENTRY( Remove )( const char *path, dig_open mode ) +/************************************************************ * DIGCliRemove */ -void DIGCLIENTRY( Remove )( const char *path, dig_open mode ) { /* unused params */ (void)mode; @@ -172,7 +174,10 @@ void DIGCLIENTRY( Remove )( const char *path, dig_open mode ) } unsigned DIGCLIENTRY( MachineData )( address addr, dig_info_type info_type, dig_elen in_size, - const void *in, dig_elen out_size, void *out ) + const void *in, dig_elen out_size, void *out ) +/******************************************************************************************** + * DIGCliMachineData + */ { #if defined( _M_IX86 ) /* unused parameters */ (void)addr; (void)info_type; (void)in_size; (void)in; (void)out_size; @@ -212,8 +217,11 @@ unsigned DIGCLIENTRY( MachineData )( address addr, dig_info_type info_type, dig_ return( 0 ); } -size_t DIGLoader( Find )( dig_filetype ftype, const char *name, size_t name_len, const char *defext, char *result, size_t result_len ) -/************************************************************************************************************************************/ +size_t DIGLoader( Find )( dig_filetype ftype, const char *name, size_t name_len, + const char *defext, char *result, size_t result_len ) +/******************************************************************************** + * DIGLoaderFind + */ { const char *ext; char filename[256]; diff --git a/bld/sdk/drwat/win/digcli.c b/bld/sdk/drwat/win/digcli.c index 3bbd17b908..f34c1f5545 100644 --- a/bld/sdk/drwat/win/digcli.c +++ b/bld/sdk/drwat/win/digcli.c @@ -82,10 +82,10 @@ FILE *PathOpen( char *name, unsigned len, const char *ext ) # ##########################################################################*/ -/* +void *DIGCLIENTRY( Alloc )( size_t size ) +/**************************************** * DIGCliAlloc */ -void *DIGCLIENTRY( Alloc )( size_t size ) { void *ret; @@ -95,10 +95,10 @@ void *DIGCLIENTRY( Alloc )( size_t size ) return( ret ); } -/* +void *DIGCLIENTRY( Realloc )( void *ptr, size_t size ) +/***************************************************** * DIGCliRealloc */ -void *DIGCLIENTRY( Realloc )( void *ptr, size_t size ) { void *ret; @@ -108,20 +108,20 @@ void *DIGCLIENTRY( Realloc )( void *ptr, size_t size ) return( ret ); } -/* +void DIGCLIENTRY( Free )( void *ptr ) +/************************************ * DIGCliFree */ -void DIGCLIENTRY( Free )( void *ptr ) { DEBUGOUT( "free BEGIN" ); MemFree( ptr ); DEBUGOUT( "free END" ); } -/* +FILE * DIGCLIENTRY( Open )( const char *path, dig_open mode ) +/************************************************************ * DIGCliOpen */ -FILE * DIGCLIENTRY( Open )( const char *path, dig_open mode ) { const char *access; @@ -135,10 +135,10 @@ FILE * DIGCLIENTRY( Open )( const char *path, dig_open mode ) return( fopen( path, access ) ); } -/* +int DIGCLIENTRY( Seek )( FILE *fp, unsigned long offset, dig_seek where ) +/************************************************************************ * DIGCliSeek */ -int DIGCLIENTRY( Seek )( FILE *fp, unsigned long offset, dig_seek where ) { int mode; int ret; @@ -160,10 +160,10 @@ int DIGCLIENTRY( Seek )( FILE *fp, unsigned long offset, dig_seek where ) return( ret ); } -/* +unsigned long DIGCLIENTRY( Tell )( FILE *fp ) +/******************************************** * DIGCliTell */ -unsigned long DIGCLIENTRY( Tell )( FILE *fp ) { unsigned long ret; @@ -173,35 +173,35 @@ unsigned long DIGCLIENTRY( Tell )( FILE *fp ) return( ret ); } -/* +size_t DIGCLIENTRY( Read )( FILE *fp, void *buf, size_t size ) +/************************************************************* * DIGCliRead */ -size_t DIGCLIENTRY( Read )( FILE *fp, void *buf, size_t size ) { DEBUGOUT( "reading" ); return( fread( buf, 1, size, fp ) ); } -/* +size_t DIGCLIENTRY( Write )( FILE *fp, const void *buf, size_t size ) +/******************************************************************** * DIGCliWrite */ -size_t DIGCLIENTRY( Write )( FILE *fp, const void *buf, size_t size ) { return( fwrite( buf, 1, size, fp ) ); } -/* +void DIGCLIENTRY( Close )( FILE *fp ) +/************************************ * DIGCliClose */ -void DIGCLIENTRY( Close )( FILE *fp ) { fclose( fp ); } -/* +void DIGCLIENTRY( Remove )( const char *path, dig_open mode ) +/************************************************************ * DIGCliRemove */ -void DIGCLIENTRY( Remove )( const char *path, dig_open mode ) { /* unused parameters */ (void)mode; @@ -209,19 +209,22 @@ void DIGCLIENTRY( Remove )( const char *path, dig_open mode ) } -/* - * DIGCliMachineData - */ unsigned DIGCLIENTRY( MachineData )( address addr, dig_info_type info_type, dig_elen in_size, const void *in, dig_elen out_size, void *out ) +/******************************************************************************************** + * DIGCliMachineData + */ { /* unused parameters */ (void)addr; (void)info_type; (void)in_size; (void)in; (void)out_size; (void)out; return( 0 ); } -size_t DIGLoader( Find )( dig_filetype ftype, const char *name, size_t name_len, const char *defext, char *result, size_t result_len ) -/************************************************************************************************************************************/ +size_t DIGLoader( Find )( dig_filetype ftype, const char *name, size_t name_len, + const char *defext, char *result, size_t result_len ) +/******************************************************************************** + * DIGLoaderFind + */ { const char *ext; char filename[256]; From d347678aae4d4d9c6471c716e48a95e62432a25a Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Mon, 28 Aug 2023 08:38:00 +0200 Subject: [PATCH 030/258] correct comments in setvars scripts --- setvars.bat | 2 +- setvars.cmd | 2 +- setvars.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/setvars.bat b/setvars.bat index e9688543d0..f9a18bcaef 100644 --- a/setvars.bat +++ b/setvars.bat @@ -13,7 +13,7 @@ REM REM If space character is used in the path then you must double quote REM this path. REM -REM set OWROOT="c:\ow\o w" +REM set "OWROOT=c:\ow\o w" REM set OWROOT=c:\ow\ow diff --git a/setvars.cmd b/setvars.cmd index 71142835cf..a7a75803c0 100644 --- a/setvars.cmd +++ b/setvars.cmd @@ -13,7 +13,7 @@ REM REM If space character is used in the path then you must double quote REM this path. REM -REM set OWROOT="c:\ow\o w" +REM set "OWROOT=c:\ow\o w" REM set OWROOT=c:\ow\ow diff --git a/setvars.sh b/setvars.sh index c179dd1fac..81a0614a68 100755 --- a/setvars.sh +++ b/setvars.sh @@ -13,7 +13,7 @@ # If space character is used in the path then you must double quote # this path. # -# export OWROOT="/home/ow/o w" +# export "OWROOT=/home/ow/o w" # export OWROOT=$(realpath "`pwd`") From 2bec305904418f6cbb1ffeeecb4372ff741f1eb5 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Mon, 28 Aug 2023 09:22:48 +0200 Subject: [PATCH 031/258] raname symbols to be more consistent over OW code --- bld/dip/dipdump/c/digcli.c | 37 ++++++++++++++++---------------- bld/sdk/drwat/nt/digcli.c | 30 +++++++++++++------------- bld/sdk/drwat/win/digcli.c | 30 +++++++++++++------------- bld/trap/common/dos/dosdigl.c | 31 +++++++++++++------------- bld/trap/common/linux/lnxdigl.c | 4 ++-- bld/trap/common/nt/ntdigl.c | 31 +++++++++++++------------- bld/trap/common/nto/ntodigl.c | 31 +++++++++++++------------- bld/trap/common/os2/os2digl.c | 31 +++++++++++++------------- bld/trap/common/os2v2/os22digl.c | 31 +++++++++++++------------- bld/trap/common/qnx/qnxdigl.c | 31 +++++++++++++------------- bld/trap/common/rdos/rdosdigl.c | 31 +++++++++++++------------- bld/trap/common/win/windigl.c | 31 +++++++++++++------------- bld/wprof/c/utils.c | 33 ++++++++++++++-------------- bld/wv/c/dbgfile.c | 37 ++++++++++++++++---------------- 14 files changed, 215 insertions(+), 204 deletions(-) diff --git a/bld/dip/dipdump/c/digcli.c b/bld/dip/dipdump/c/digcli.c index 25856c4375..8cf4dafe00 100644 --- a/bld/dip/dipdump/c/digcli.c +++ b/bld/dip/dipdump/c/digcli.c @@ -199,11 +199,12 @@ void PathFini( void ) free( FilePathList ); } -size_t DIGLoader( Find )( dig_filetype ftype, const char *name, size_t name_len, const char *defext, char *result, size_t result_len ) -/************************************************************************************************************************************/ +size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base_name_len, + const char *defext, char *filename, size_t filename_len ) +/****************************************************************************************/ { char fullname[_MAX_PATH2]; - char filename[_MAX_PATH2]; + char fname[_MAX_PATH2]; FILE *fp; char *p; char c; @@ -211,16 +212,16 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *name, size_t name_len, /* unused parameters */ (void)ftype; - strncpy( filename, name, name_len ); - filename[name_len] = '\0'; + strncpy( fname, base_name, base_name_len ); + fname[base_name_len] = '\0'; if( defext != NULL && *defext != '\0' ) { - _splitpath2( filename, fullname, NULL, NULL, &p, NULL ); - _makepath( filename, NULL, NULL, p, defext ); + _splitpath2( fname, fullname, NULL, NULL, &p, NULL ); + _makepath( fname, NULL, NULL, p, defext ); } - if( access( filename, F_OK ) == 0 ) { - p = filename; + if( access( fname, F_OK ) == 0 ) { + p = fname; } else if( path_list != NULL ) { - strcpy( fullname, filename ); + strcpy( fullname, fname ); while( (c = *path_list) != '\0' ) { p = fullname; do { @@ -233,7 +234,7 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *name, size_t name_len, if( !IS_PATH_SEP( c ) ) { *p++ = DIR_SEP; } - strcpy( p, filename ); + strcpy( p, fname ); if( access( fullname, F_OK ) == 0 ) { p = fullname; break; @@ -246,13 +247,13 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *name, size_t name_len, p = ""; } len = strlen( p ); - if( result_len > 0 ) { - result_len--; - if( result_len > len ) - result_len = len; - if( result_len > 0 ) - strncpy( result, p, result_len ); - result[result_len] = '\0'; + if( filename_len > 0 ) { + filename_len--; + if( filename_len > len ) + filename_len = len; + if( filename_len > 0 ) + strncpy( filename, p, filename_len ); + filename[filename_len] = '\0'; } return( len ); } diff --git a/bld/sdk/drwat/nt/digcli.c b/bld/sdk/drwat/nt/digcli.c index 6ab5fcbaf0..095fbf59c3 100644 --- a/bld/sdk/drwat/nt/digcli.c +++ b/bld/sdk/drwat/nt/digcli.c @@ -217,35 +217,35 @@ unsigned DIGCLIENTRY( MachineData )( address addr, dig_info_type info_type, dig_ return( 0 ); } -size_t DIGLoader( Find )( dig_filetype ftype, const char *name, size_t name_len, - const char *defext, char *result, size_t result_len ) -/******************************************************************************** +size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base_name_len, + const char *defext, char *filename, size_t filename_len ) +/***************************************************************************************** * DIGLoaderFind */ { const char *ext; - char filename[256]; + char fname[256]; pgroup2 pg; size_t len; /* unused parameters */ (void)ftype; len = 0; - if( result_len > 0 ) { - result_len--; - strncpy( filename, name, name_len ); - filename[name_len] = '\0'; - _splitpath2( filename, pg.buffer, &pg.drive, &pg.dir, &pg.fname, &pg.ext ); + if( filename_len > 0 ) { + filename_len--; + strncpy( fname, base_name, base_name_len ); + fname[base_name_len] = '\0'; + _splitpath2( fname, pg.buffer, &pg.drive, &pg.dir, &pg.fname, &pg.ext ); ext = pg.ext; if( ext == NULL || *ext == '\0' ) { ext = defext; } - _makepath( filename, pg.drive, pg.dir, pg.fname, ext ); - len = strlen( filename ); - if( len > result_len ) - len = result_len; - strncpy( result, filename, len ); - result[len] = '\0'; + _makepath( fname, pg.drive, pg.dir, pg.fname, ext ); + len = strlen( fname ); + if( len > filename_len ) + len = filename_len; + strncpy( filename, fname, len ); + filename[len] = '\0'; } return( len ); } diff --git a/bld/sdk/drwat/win/digcli.c b/bld/sdk/drwat/win/digcli.c index f34c1f5545..914bd6c154 100644 --- a/bld/sdk/drwat/win/digcli.c +++ b/bld/sdk/drwat/win/digcli.c @@ -220,35 +220,35 @@ unsigned DIGCLIENTRY( MachineData )( address addr, dig_info_type info_type, dig_ return( 0 ); } -size_t DIGLoader( Find )( dig_filetype ftype, const char *name, size_t name_len, - const char *defext, char *result, size_t result_len ) -/******************************************************************************** +size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base_name_len, + const char *defext, char *filename, size_t filename_len ) +/***************************************************************************************** * DIGLoaderFind */ { const char *ext; - char filename[256]; + char fname[256]; pgroup2 pg; size_t len; /* unused parameters */ (void)ftype; len = 0; - if( result_len > 0 ) { - result_len--; - strncpy( filename, name, name_len ); - filename[name_len] = '\0'; - _splitpath2( filename, pg.buffer, &pg.drive, &pg.dir, &pg.fname, &pg.ext ); + if( filename_len > 0 ) { + filename_len--; + strncpy( fname, base_name, base_name_len ); + fname[base_name_len] = '\0'; + _splitpath2( fname, pg.buffer, &pg.drive, &pg.dir, &pg.fname, &pg.ext ); ext = pg.ext; if( ext == NULL || *ext == '\0' ) { ext = defext; } - _makepath( filename, pg.drive, pg.dir, pg.fname, ext ); - len = strlen( filename ); - if( len > result_len ) - len = result_len; - strncpy( result, filename, len ); - result[len] = '\0'; + _makepath( fname, pg.drive, pg.dir, pg.fname, ext ); + len = strlen( fname ); + if( len > filename_len ) + len = filename_len; + strncpy( filename, fname, len ); + filename[len] = '\0'; } return( len ); } diff --git a/bld/trap/common/dos/dosdigl.c b/bld/trap/common/dos/dosdigl.c index b7d4d7f9f6..8864f74c4e 100644 --- a/bld/trap/common/dos/dosdigl.c +++ b/bld/trap/common/dos/dosdigl.c @@ -45,13 +45,14 @@ #define FP2HANDLE(fp) ((int)((unsigned long)(fp) - 1)) -size_t DIGLoader( Find )( dig_filetype ftype, const char *name, size_t name_len, const char *defext, char *result, size_t result_len ) -/************************************************************************************************************************************/ +size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base_name_len, + const char *defext, char *filename, size_t filename_len ) +/****************************************************************************************/ { bool has_ext; bool has_path; char *p; - char trpfile[256]; + char fname[256]; char c; size_t len; @@ -59,9 +60,9 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *name, size_t name_len, has_ext = false; has_path = false; - p = trpfile; - while( name_len-- > 0 ) { - c = *name++; + p = fname; + while( base_name_len-- > 0 ) { + c = *base_name++; *p++ = c; switch( c ) { case '.': @@ -81,19 +82,19 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *name, size_t name_len, p = StrCopyDst( defext, p ); } *p = '\0'; - p = trpfile; + p = fname; if( !has_path ) { - _searchenv( trpfile, "PATH", RWBuff ); + _searchenv( fname, "PATH", RWBuff ); p = RWBuff; } len = strlen( p ); - if( result_len > 0 ) { - result_len--; - if( result_len > len ) - result_len = len; - if( result_len > 0 ) - strncpy( result, p, result_len ); - result[result_len] = '\0'; + if( filename_len > 0 ) { + filename_len--; + if( filename_len > len ) + filename_len = len; + if( filename_len > 0 ) + strncpy( filename, p, filename_len ); + filename[filename_len] = '\0'; } return( len ); } diff --git a/bld/trap/common/linux/lnxdigl.c b/bld/trap/common/linux/lnxdigl.c index 98ab7b0080..02b6073142 100644 --- a/bld/trap/common/linux/lnxdigl.c +++ b/bld/trap/common/linux/lnxdigl.c @@ -42,8 +42,8 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base_name_len, -const char *defext, char *filename, size_t filename_len ) -/************************************************************************************************************************************/ + const char *defext, char *filename, size_t filename_len ) +/****************************************************************************************/ { bool has_ext; bool has_path; diff --git a/bld/trap/common/nt/ntdigl.c b/bld/trap/common/nt/ntdigl.c index 3626072c6b..73ba6b4339 100644 --- a/bld/trap/common/nt/ntdigl.c +++ b/bld/trap/common/nt/ntdigl.c @@ -38,13 +38,14 @@ #include "servio.h" -size_t DIGLoader( Find )( dig_filetype ftype, const char *name, size_t name_len, const char *defext, char *result, size_t result_len ) -/************************************************************************************************************************************/ +size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base_name_len, + const char *defext, char *filename, size_t filename_len ) +/****************************************************************************************/ { bool has_ext; bool has_path; char *p; - char trpfile[256]; + char fname[256]; char c; size_t len; @@ -52,9 +53,9 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *name, size_t name_len, has_ext = false; has_path = false; - p = trpfile; - while( name_len-- > 0 ) { - c = *name++; + p = fname; + while( base_name_len-- > 0 ) { + c = *base_name++; *p++ = c; switch( c ) { case '.': @@ -74,19 +75,19 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *name, size_t name_len, p = StrCopyDst( defext, p ); } *p = '\0'; - p = trpfile; + p = fname; if( !has_path ) { - _searchenv( trpfile, "PATH", RWBuff ); + _searchenv( fname, "PATH", RWBuff ); p = RWBuff; } len = strlen( p ); - if( result_len > 0 ) { - result_len--; - if( result_len > len ) - result_len = len; - if( result_len > 0 ) - strncpy( result, p, result_len ); - result[result_len] = '\0'; + if( filename_len > 0 ) { + filename_len--; + if( filename_len > len ) + filename_len = len; + if( filename_len > 0 ) + strncpy( filename, p, filename_len ); + filename[filename_len] = '\0'; } return( len ); } diff --git a/bld/trap/common/nto/ntodigl.c b/bld/trap/common/nto/ntodigl.c index 77ab24cf7d..dbd5e4a16e 100644 --- a/bld/trap/common/nto/ntodigl.c +++ b/bld/trap/common/nto/ntodigl.c @@ -43,23 +43,24 @@ #include "servio.h" -size_t DIGLoader( Find )( dig_filetype ftype, const char *name, size_t name_len, const char *defext, char *result, size_t result_len ) -/************************************************************************************************************************************/ +size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base_name_len, + const char *defext, char *filename, size_t filename_len ) +/****************************************************************************************/ { bool has_ext; bool has_path; char *p; char c; - char trpfile[256]; + char fname[256]; size_t len; /* unused parameters */ (void)ftype; has_ext = false; has_path = false; - p = trpfile; - while( name_len-- > 0 ) { - c = *name++; + p = fname; + while( base_name_len-- > 0 ) { + c = *base_name++; *p++ = c; switch( c ) { case '.': @@ -77,20 +78,20 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *name, size_t name_len, } *p = '\0'; if( has_path ) { - p = trpfile; - } else if( FindFilePath( DIG_FILETYPE_DBG, trpfile, RWBuff ) ) { + p = fname; + } else if( FindFilePath( DIG_FILETYPE_DBG, fname, RWBuff ) ) { p = RWBuff; } else { p = ""; } len = strlen( p ); - if( result_len > 0 ) { - result_len--; - if( result_len > len ) - result_len = len; - if( result_len > 0 ) - strncpy( result, p, result_len ); - result[result_len] = '\0'; + if( filename_len > 0 ) { + filename_len--; + if( filename_len > len ) + filename_len = len; + if( filename_len > 0 ) + strncpy( filename, p, filename_len ); + filename[filename_len] = '\0'; } return( len ); } diff --git a/bld/trap/common/os2/os2digl.c b/bld/trap/common/os2/os2digl.c index da7fede732..92f25cc265 100644 --- a/bld/trap/common/os2/os2digl.c +++ b/bld/trap/common/os2/os2digl.c @@ -37,13 +37,14 @@ #include "servio.h" -size_t DIGLoader( Find )( dig_filetype ftype, const char *name, size_t name_len, const char *defext, char *result, size_t result_len ) -/************************************************************************************************************************************/ +size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base_name_len, + const char *defext, char *filename, size_t filename_len ) +/****************************************************************************************/ { bool has_ext; bool has_path; char *p; - char trpfile[256]; + char fname[256]; char c; size_t len; @@ -51,9 +52,9 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *name, size_t name_len, has_ext = false; has_path = false; - p = trpfile; - while( name_len-- > 0 ) { - c = *name++; + p = fname; + while( base_name_len-- > 0 ) { + c = *base_name++; *p++ = c; switch( c ) { case '.': @@ -73,19 +74,19 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *name, size_t name_len, p = StrCopyDst( defext, p ); } *p = '\0'; - p = trpfile; + p = fname; if( !has_path ) { - _searchenv( trpfile, "PATH", RWBuff ); + _searchenv( fname, "PATH", RWBuff ); p = RWBuff; } len = strlen( p ); - if( result_len > 0 ) { - result_len--; - if( result_len > len ) - result_len = len; - if( result_len > 0 ) - strncpy( result, p, result_len ); - result[result_len] = '\0'; + if( filename_len > 0 ) { + filename_len--; + if( filename_len > len ) + filename_len = len; + if( filename_len > 0 ) + strncpy( filename, p, filename_len ); + filename[filename_len] = '\0'; } return( len ); } diff --git a/bld/trap/common/os2v2/os22digl.c b/bld/trap/common/os2v2/os22digl.c index 51e8636e41..31e6f8d1a0 100644 --- a/bld/trap/common/os2v2/os22digl.c +++ b/bld/trap/common/os2v2/os22digl.c @@ -38,13 +38,14 @@ #include "servio.h" -size_t DIGLoader( Find )( dig_filetype ftype, const char *name, size_t name_len, const char *defext, char *result, size_t result_len ) -/************************************************************************************************************************************/ +size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base_name_len, + const char *defext, char *filename, size_t filename_len ) +/****************************************************************************************/ { bool has_ext; bool has_path; char *p; - char trpfile[256]; + char fname[256]; char c; size_t len; @@ -52,9 +53,9 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *name, size_t name_len, has_ext = false; has_path = false; - p = trpfile; - while( name_len-- > 0 ) { - c = *name++; + p = fname; + while( base_name_len-- > 0 ) { + c = *base_name++; *p++ = c; switch( c ) { case '.': @@ -74,19 +75,19 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *name, size_t name_len, p = StrCopyDst( defext, p ); } *p = '\0'; - p = trpfile; + p = fname; if( !has_path ) { - _searchenv( trpfile, "PATH", RWBuff ); + _searchenv( fname, "PATH", RWBuff ); p = RWBuff; } len = strlen( p ); - if( result_len > 0 ) { - result_len--; - if( result_len > len ) - result_len = len; - if( result_len > 0 ) - strncpy( result, p, result_len ); - result[result_len] = '\0'; + if( filename_len > 0 ) { + filename_len--; + if( filename_len > len ) + filename_len = len; + if( filename_len > 0 ) + strncpy( filename, p, filename_len ); + filename[filename_len] = '\0'; } return( len ); } diff --git a/bld/trap/common/qnx/qnxdigl.c b/bld/trap/common/qnx/qnxdigl.c index 205492dd3b..41f9401015 100644 --- a/bld/trap/common/qnx/qnxdigl.c +++ b/bld/trap/common/qnx/qnxdigl.c @@ -43,23 +43,24 @@ #include "servio.h" -size_t DIGLoader( Find )( dig_filetype ftype, const char *name, size_t name_len, const char *defext, char *result, size_t result_len ) -/************************************************************************************************************************************/ +size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base_name_len, + const char *defext, char *filename, size_t filename_len ) +/****************************************************************************************/ { bool has_ext; bool has_path; char *p; char c; - char trpfile[PATH_MAX + 1]; + char fname[PATH_MAX + 1]; size_t len; /* unused parameters */ (void)ftype; has_ext = false; has_path = false; - p = trpfile; - while( name_len-- > 0 ) { - c = *name++; + p = fname; + while( base_name_len-- > 0 ) { + c = *base_name++; *p++ = c; switch( c ) { case '.': @@ -77,20 +78,20 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *name, size_t name_len, } *p = '\0'; if( has_path ) { - p = trpfile; - } else if( FindFilePath( DIG_FILETYPE_DBG, trpfile, RWBuff ) ) { + p = fname; + } else if( FindFilePath( DIG_FILETYPE_DBG, fname, RWBuff ) ) { p = RWBuff; } else { p = ""; } len = strlen( p ); - if( result_len > 0 ) { - result_len--; - if( result_len > len ) - result_len = len; - if( result_len > 0 ) - strncpy( result, p, result_len ); - result[result_len] = '\0'; + if( filename_len > 0 ) { + filename_len--; + if( filename_len > len ) + filename_len = len; + if( filename_len > 0 ) + strncpy( filename, p, filename_len ); + filename[filename_len] = '\0'; } return( len ); } diff --git a/bld/trap/common/rdos/rdosdigl.c b/bld/trap/common/rdos/rdosdigl.c index 8473698c03..72840af8b1 100644 --- a/bld/trap/common/rdos/rdosdigl.c +++ b/bld/trap/common/rdos/rdosdigl.c @@ -38,13 +38,14 @@ #include "servio.h" -size_t DIGLoader( Find )( dig_filetype ftype, const char *name, size_t name_len, const char *defext, char *result, size_t result_len ) -/************************************************************************************************************************************/ +size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base_name_len, + const char *defext, char *filename, size_t filename_len ) +/****************************************************************************************/ { bool has_ext; bool has_path; char *p; - char trpfile[256]; + char fname[256]; char c; size_t len; @@ -52,9 +53,9 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *name, size_t name_len, has_ext = false; has_path = false; - p = trpfile; - while( name_len-- > 0 ) { - c = *name++; + p = fname; + while( base_name_len-- > 0 ) { + c = *base_name++; *p++ = c; switch( c ) { case '.': @@ -74,19 +75,19 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *name, size_t name_len, p = StrCopyDst( defext, p ); } *p = '\0'; - p = trpfile; + p = fname; if( !has_path ) { - _searchenv( trpfile, "PATH", RWBuff ); + _searchenv( fname, "PATH", RWBuff ); p = RWBuff; } len = strlen( p ); - if( result_len > 0 ) { - result_len--; - if( result_len > len ) - result_len = len; - if( result_len > 0 ) - strncpy( result, p, result_len ); - result[result_len] = '\0'; + if( filename_len > 0 ) { + filename_len--; + if( filename_len > len ) + filename_len = len; + if( filename_len > 0 ) + strncpy( filename, p, filename_len ); + filename[filename_len] = '\0'; } return( len ); } diff --git a/bld/trap/common/win/windigl.c b/bld/trap/common/win/windigl.c index e591b8e83d..303aedf5dd 100644 --- a/bld/trap/common/win/windigl.c +++ b/bld/trap/common/win/windigl.c @@ -38,13 +38,14 @@ #include "servio.h" -size_t DIGLoader( Find )( dig_filetype ftype, const char *name, size_t name_len, const char *defext, char *result, size_t result_len ) -/************************************************************************************************************************************/ +size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base_name_len, + const char *defext, char *filename, size_t filename_len ) +/****************************************************************************************/ { bool has_ext; bool has_path; char *p; - char trpfile[256]; + char fname[256]; char c; size_t len; @@ -52,9 +53,9 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *name, size_t name_len, has_ext = false; has_path = false; - p = trpfile; - while( name_len-- > 0 ) { - c = *name++; + p = fname; + while( base_name_len-- > 0 ) { + c = *base_name++; *p++ = c; switch( c ) { case '.': @@ -74,19 +75,19 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *name, size_t name_len, p = StrCopyDst( defext, p ); } *p = '\0'; - p = trpfile; + p = fname; if( !has_path ) { - _searchenv( trpfile, "PATH", RWBuff ); + _searchenv( fname, "PATH", RWBuff ); p = RWBuff; } len = strlen( p ); - if( result_len > 0 ) { - result_len--; - if( result_len > len ) - result_len = len; - if( result_len > 0 ) - strncpy( result, p, result_len ); - result[result_len] = '\0'; + if( filename_len > 0 ) { + filename_len--; + if( filename_len > len ) + filename_len = len; + if( filename_len > 0 ) + strncpy( filename, p, filename_len ); + filename[filename_len] = '\0'; } return( len ); } diff --git a/bld/wprof/c/utils.c b/bld/wprof/c/utils.c index 2e43e35f08..73d9239409 100644 --- a/bld/wprof/c/utils.c +++ b/bld/wprof/c/utils.c @@ -149,37 +149,38 @@ char *FindHelpFile( char *fullname, const char *help_name ) return( fullname ); } -size_t DIGLoader( Find )( dig_filetype ftype, const char *name, size_t name_len, const char *defext, char *result, size_t result_len ) -/************************************************************************************************************************************/ +size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base_name_len, + const char *defext, char *filename, size_t filename_len ) +/****************************************************************************************/ { - char realname[_MAX_PATH2]; + char fname[_MAX_PATH2]; char *p; pgroup2 pg; size_t len; /* unused parameters */ (void)ftype; - strncpy( realname, name, name_len ); - realname[name_len] = '\0'; + strncpy( fname, base_name, base_name_len ); + fname[base_name_len] = '\0'; if( defext != NULL && *defext != NULLCHAR ) { - _splitpath2( realname, pg.buffer, NULL, NULL, &pg.fname, NULL ); - _makepath( realname, NULL, NULL, pg.fname, defext ); + _splitpath2( fname, pg.buffer, NULL, NULL, &pg.fname, NULL ); + _makepath( fname, NULL, NULL, pg.fname, defext ); } - p = findFile( pg.buffer, realname, FilePathList ); + p = findFile( pg.buffer, fname, FilePathList ); if( p == NULL ) { - p = findFile( pg.buffer, realname, DipExePathList ); + p = findFile( pg.buffer, fname, DipExePathList ); if( p == NULL ) { p = ""; } } len = strlen( p ); - if( result_len > 0 ) { - result_len--; - if( result_len > len ) - result_len = len; - if( result_len > 0 ) - strncpy( result, p, result_len ); - result[result_len] = '\0'; + if( filename_len > 0 ) { + filename_len--; + if( filename_len > len ) + filename_len = len; + if( filename_len > 0 ) + strncpy( filename, p, filename_len ); + filename[filename_len] = '\0'; } return( len ); } diff --git a/bld/wv/c/dbgfile.c b/bld/wv/c/dbgfile.c index f0d5e08fdf..b6b4c1dda1 100644 --- a/bld/wv/c/dbgfile.c +++ b/bld/wv/c/dbgfile.c @@ -764,11 +764,12 @@ static size_t MakeName( const char *path, const char *name, size_t nlen, char *r return( p - res ); } -size_t DIGLoader( Find )( dig_filetype ftype, const char *name, size_t name_len, const char *defext, char *result, size_t result_len ) -/************************************************************************************************************************************/ +size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base_name_len, + const char *defext, char *filename, size_t filename_len ) +/****************************************************************************************/ { char buffer[TXT_LEN]; - char filename[TXT_LEN]; + char fname[TXT_LEN]; char *p; bool has_ext; bool has_path; @@ -781,8 +782,8 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *name, size_t name_len, has_ext = false; has_path = false; p = buffer; - while( name_len-- > 0 ) { - c = *name++; + while( base_name_len-- > 0 ) { + c = *base_name++; *p++ = c; if( CHK_PATH_SEP( c, &LclFile ) ) { has_ext = false; @@ -801,16 +802,16 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *name, size_t name_len, } else { // check open file in current directory or in full path len = p - buffer; - MakeName( NULL, buffer, len, filename, sizeof( filename ) ); - if( access( filename, F_OK ) == 0 ) { - p = filename; + MakeName( NULL, buffer, len, fname, sizeof( fname ) ); + if( access( fname, F_OK ) == 0 ) { + p = fname; } else { p = ""; // check open file in debugger directory list for( curr = LclPath; curr != NULL; curr = curr->next ) { - if( MakeName( curr->name, buffer, len, filename, sizeof( filename ) ) ) { - if( access( filename, F_OK ) == 0 ) { - p = filename; + if( MakeName( curr->name, buffer, len, fname, sizeof( fname ) ) ) { + if( access( fname, F_OK ) == 0 ) { + p = fname; break; } } @@ -818,13 +819,13 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *name, size_t name_len, } } len = strlen( p ); - if( result_len > 0 ) { - result_len--; - if( result_len > len ) - result_len = len; - if( result_len > 0 ) - strncpy( result, p, result_len ); - result[result_len] = NULLCHAR; + if( filename_len > 0 ) { + filename_len--; + if( filename_len > len ) + filename_len = len; + if( filename_len > 0 ) + strncpy( filename, p, filename_len ); + filename[filename_len] = NULLCHAR; } return( len ); } From 97df605a73a63ebd26ba065d76dd39f808aced1a Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Mon, 28 Aug 2023 10:53:45 +0200 Subject: [PATCH 032/258] add loader for REX executable format --- bld/dig/c/linux/trpld_rx.c | 134 +++++++++++++++++++++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100644 bld/dig/c/linux/trpld_rx.c diff --git a/bld/dig/c/linux/trpld_rx.c b/bld/dig/c/linux/trpld_rx.c new file mode 100644 index 0000000000..51759c8cb1 --- /dev/null +++ b/bld/dig/c/linux/trpld_rx.c @@ -0,0 +1,134 @@ +/**************************************************************************** +* +* Open Watcom Project +* +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. +* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. +* +* ======================================================================== +* +* This file contains Original Code and/or Modifications of Original +* Code as defined in and that are subject to the Sybase Open Watcom +* Public License version 1.0 (the 'License'). You may not use this file +* except in compliance with the License. BY USING THIS FILE YOU AGREE TO +* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is +* provided with the Original Code and Modifications, and is also +* available at www.sybase.com/developer/opensource. +* +* The Original Code and all software distributed under the License are +* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM +* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR +* NON-INFRINGEMENT. Please see the License for the specific language +* governing rights and limitations under the License. +* +* ======================================================================== +* +* Description: Trap module loader for Linux. +* +****************************************************************************/ + + +#include +#include +#include +#include +#include +#include "digld.h" +#include "trpld.h" +#include "trpimp.h" +#include "tcerr.h" +#include "ldimp.h" +#include "digcli.h" + + +#define TRAPSIG 0x50415254UL // "TRAP" + +const static trap_callbacks TrapCallbacks = { + sizeof( trap_callbacks ), + + &environ, + NULL, + + malloc, + realloc, + free, + getenv, + signal, +}; + +static imp_header *TrapCode = NULL; +static trap_fini_func *FiniFunc = NULL; + +void UnLoadTrap( void ) +{ + ReqFunc = NULL; + if( FiniFunc != NULL ) { + FiniFunc(); + FiniFunc = NULL; + } + if( TrapCode != NULL ) { + DIGCli( Free )( TrapCode ); + TrapCode = NULL; + } +} + +char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) +{ + FILE *fp; + trap_load_func *ld_func; + const trap_requests *trap_funcs; + char filename[256]; + const char *base_name; + size_t len; + + if( parms == NULL || *parms == '\0' ) + parms = DEFAULT_TRP_NAME; + base_name = parms;; + len = 0; + for( ; *parms != '\0'; parms++ ) { + if( *parms == TRAP_PARM_SEPARATOR ) { + parms++; + break; + } + len++; + } + if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, len, "trp", filename, sizeof( filename ) ) ) { + sprintf( buff, TC_ERR_CANT_LOAD_TRAP, base_name ); + return( buff ); + } + sprintf( buff, TC_ERR_CANT_LOAD_TRAP, filename ); + fp = DIGLoader( Open )( filename ); + if( fp == NULL ) { + return( buff ); + } + TrapCode = ReadInImp( fp ); + DIGLoader( Close )( fp ); + if( TrapCode != NULL ) { + buff[0] = '\0'; +#ifdef __WATCOMC__ + if( TrapCode->sig == TRAPSIG ) { +#endif + ld_func = (trap_load_func *)TrapCode->init_rtn; + trap_funcs = ld_func( &TrapCallbacks ); + if( trap_funcs != NULL ) { + *trap_ver = trap_funcs->init_func( parms, buff, trap_ver->remote ); + FiniFunc = trap_funcs->fini_func; + ReqFunc = trap_funcs->req_func; + if( buff[0] == '\0' ) { + if( TrapVersionOK( *trap_ver ) ) { + TrapVer = *trap_ver; + return( NULL ); + } + } + } +#ifdef __WATCOMC__ + } +#endif + if( buff[0] == '\0' ) + strcpy( buff, TC_ERR_BAD_TRAP_FILE ); + UnLoadTrap(); + } + return( buff ); +} From ee6cd7a207d4cf0c3af01fa2ceb37193f0dc99d4 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Mon, 28 Aug 2023 10:54:24 +0200 Subject: [PATCH 033/258] fix incorrect message form --- bld/dig/c/linux/trpld_pe.c | 4 ++-- bld/dig/c/linux/trpld_so.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bld/dig/c/linux/trpld_pe.c b/bld/dig/c/linux/trpld_pe.c index 080379b5e6..696b883009 100644 --- a/bld/dig/c/linux/trpld_pe.c +++ b/bld/dig/c/linux/trpld_pe.c @@ -104,10 +104,10 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) } #if !defined( BUILTIN_TRAP_FILE ) if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, len, "trp", filename, sizeof( filename ) ) == 0 ) { - sprintf( buff, "%s '%s'", TC_ERR_CANT_LOAD_TRAP, base_name ); + sprintf( buff, TC_ERR_CANT_LOAD_TRAP, base_name ); return( buff ); } - sprintf( buff, "%s '%s'", TC_ERR_CANT_LOAD_TRAP, filename ); + sprintf( buff, TC_ERR_CANT_LOAD_TRAP, filename ); fp = DIGLoader( Open )( filename ); if( fp == NULL ) { return( buff ); diff --git a/bld/dig/c/linux/trpld_so.c b/bld/dig/c/linux/trpld_so.c index 940ff8a210..7b57d4de3f 100644 --- a/bld/dig/c/linux/trpld_so.c +++ b/bld/dig/c/linux/trpld_so.c @@ -106,10 +106,10 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) } #if !defined( BUILTIN_TRAP_FILE ) if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, len, "so", filename, sizeof( filename ) ) == 0 ) { - sprintf( buff, "%s '%s'", TC_ERR_CANT_LOAD_TRAP, base_name ); + sprintf( buff, TC_ERR_CANT_LOAD_TRAP, base_name ); return( buff ); } - sprintf( buff, "%s '%s'", TC_ERR_CANT_LOAD_TRAP, filename ); + sprintf( buff, TC_ERR_CANT_LOAD_TRAP, filename ); fp = DIGLoader( Open )( filename ); if( fp == NULL ) { return( buff ); From 367e7083675aab07673aef67d7f950c0a09262f2 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Mon, 28 Aug 2023 11:00:44 +0200 Subject: [PATCH 034/258] cleanup drwat project code --- bld/sdk/drwat/nt/digcli.c | 8 +++----- bld/sdk/drwat/win/digcli.c | 9 +++------ 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/bld/sdk/drwat/nt/digcli.c b/bld/sdk/drwat/nt/digcli.c index 095fbf59c3..b8eced12cf 100644 --- a/bld/sdk/drwat/nt/digcli.c +++ b/bld/sdk/drwat/nt/digcli.c @@ -223,7 +223,6 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base * DIGLoaderFind */ { - const char *ext; char fname[256]; pgroup2 pg; size_t len; @@ -236,11 +235,10 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base strncpy( fname, base_name, base_name_len ); fname[base_name_len] = '\0'; _splitpath2( fname, pg.buffer, &pg.drive, &pg.dir, &pg.fname, &pg.ext ); - ext = pg.ext; - if( ext == NULL || *ext == '\0' ) { - ext = defext; + if( pg.ext == NULL || *pg.ext == '\0' ) { + pg.ext = defext; } - _makepath( fname, pg.drive, pg.dir, pg.fname, ext ); + _makepath( fname, pg.drive, pg.dir, pg.fname, pg.ext ); len = strlen( fname ); if( len > filename_len ) len = filename_len; diff --git a/bld/sdk/drwat/win/digcli.c b/bld/sdk/drwat/win/digcli.c index 914bd6c154..41de31dcab 100644 --- a/bld/sdk/drwat/win/digcli.c +++ b/bld/sdk/drwat/win/digcli.c @@ -226,7 +226,6 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base * DIGLoaderFind */ { - const char *ext; char fname[256]; pgroup2 pg; size_t len; @@ -239,11 +238,9 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base strncpy( fname, base_name, base_name_len ); fname[base_name_len] = '\0'; _splitpath2( fname, pg.buffer, &pg.drive, &pg.dir, &pg.fname, &pg.ext ); - ext = pg.ext; - if( ext == NULL || *ext == '\0' ) { - ext = defext; - } - _makepath( fname, pg.drive, pg.dir, pg.fname, ext ); + if( pg.ext == NULL || pg.ext[0] == '\0' ) + pg.ext = defext; + _makepath( fname, pg.drive, pg.dir, pg.fname, pg.ext ); len = strlen( fname ); if( len > filename_len ) len = filename_len; From e4807f0ea9d757093d38b7a74df086c1863888bf Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Mon, 28 Aug 2023 11:01:44 +0200 Subject: [PATCH 035/258] correct source file formatting --- bld/trap/common/rdos/rdosdigl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bld/trap/common/rdos/rdosdigl.c b/bld/trap/common/rdos/rdosdigl.c index 72840af8b1..a018f7e50f 100644 --- a/bld/trap/common/rdos/rdosdigl.c +++ b/bld/trap/common/rdos/rdosdigl.c @@ -64,7 +64,7 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base case '/': case '\\': has_ext = false; - /* fall through */ + /* fall through */ case ':': has_path = true; break; From 8275ecff6a6e57965217baca9eef064f36ad80c1 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Mon, 28 Aug 2023 11:03:42 +0200 Subject: [PATCH 036/258] fix missing initialization --- bld/dig/c/linux/trpld_pe.c | 1 + 1 file changed, 1 insertion(+) diff --git a/bld/dig/c/linux/trpld_pe.c b/bld/dig/c/linux/trpld_pe.c index 696b883009..97d2335449 100644 --- a/bld/dig/c/linux/trpld_pe.c +++ b/bld/dig/c/linux/trpld_pe.c @@ -121,6 +121,7 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) ld_func = (trap_load_func *)PE_getProcAddress( TrapFile, "TrapLoad_" ); if( ld_func != NULL ) { #else + buff[0] = '\0'; ld_func = TrapLoad; #endif trap_funcs = ld_func( &TrapCallbacks ); From ad90570967be5fbea41b16a8abafb392a700a4a0 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Mon, 28 Aug 2023 11:05:52 +0200 Subject: [PATCH 037/258] remove useless semicolon --- bld/dig/c/qnx/trpld.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bld/dig/c/qnx/trpld.c b/bld/dig/c/qnx/trpld.c index 508af1074b..8fde4315ac 100644 --- a/bld/dig/c/qnx/trpld.c +++ b/bld/dig/c/qnx/trpld.c @@ -87,7 +87,7 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) if( parms == NULL || *parms == '\0' ) parms = DEFAULT_TRP_NAME; - base_name = parms;; + base_name = parms; len = 0; for( ; *parms != '\0'; parms++ ) { if( *parms == TRAP_PARM_SEPARATOR ) { From ac4e887de96bb48b85df1c90f107f75c98fc66be Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Mon, 28 Aug 2023 11:51:14 +0200 Subject: [PATCH 038/258] fix mistake in wpi project for 16-bit OS/2 HFILE is unsigned short that cannot pass pointer Anyway _wpi_file.... functions are emulation of 16-bit Windows file functions that cannot be mixed with C run-time library file access --- bld/wpi/c/wpi_file.c | 58 ++++++-------------------------------------- bld/wpi/h/wpi_os2.h | 8 +++--- bld/wpi/h/wpi_win.h | 4 +-- bld/wpi/h/wpitypes.h | 3 +-- 4 files changed, 14 insertions(+), 59 deletions(-) diff --git a/bld/wpi/c/wpi_file.c b/bld/wpi/c/wpi_file.c index e3e4ba9440..68491c0d68 100644 --- a/bld/wpi/c/wpi_file.c +++ b/bld/wpi/c/wpi_file.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -39,7 +39,6 @@ HFILE _wpi_fileopen( LPSTR filename, int format ) /***********************************************/ { -#if 0 // this definition seems to interfere with C lib IO PM1632_FILESIZETYPE action; HFILE hfile; @@ -62,39 +61,12 @@ HFILE _wpi_fileopen( LPSTR filename, int format ) // DosDevIOCtl( hfile, 0x08, 0x00, 0, 0, 0, 0, 512L, 0 ); #endif return( hfile ); -#else - char *fmt; - FILE *f; - - switch( format ) { - - case OF_READ: - fmt = "r"; - break; - - case OF_WRITE: - fmt = "w"; - break; - - default: - return( -1 ); - } - f = fopen( filename, fmt ); - if( f == NULL ) { - return( -1 ); - } - - /* an HFILE is a long, so this next line works */ - return( (HFILE) f ); -#endif } /* _wpi_fileopen */ HFILE _wpi_filecreate( LPSTR filename, int format ) /*************************************************/ { - -#if 0 // this definition seems to interfere with C lib IO PM1632_FILESIZETYPE action; HFILE hfile; @@ -118,16 +90,12 @@ HFILE _wpi_filecreate( LPSTR filename, int format ) // DosDevIOCtl( hfile, 0x08, 0x00, 0, 0, 0, 0, 512L, 0 ); #endif return( hfile ); -#else - return( _wpi_fileopen( filename, format ) ); -#endif } /* _wpi_filecreate */ PM1632_FILESIZETYPE _wpi_fileclose( HFILE hfile ) /***********************************************/ { -#if 0 // this definition seems to interfere with C lib IO PM1632_FILESIZETYPE ret; ret = (PM1632_FILESIZETYPE)DosClose( hfile ); @@ -138,16 +106,12 @@ PM1632_FILESIZETYPE _wpi_fileclose( HFILE hfile ) // DosDevIOCtl( hfile, 0x08, 0x00, 0, 0, 0, 0, 512L, 0 ); #endif return( ret ); -#else - return( fclose( (void *)hfile ) ); -#endif + } /* _wpi_fileclose */ -PM1632_FILESIZETYPE _wpi_filewrite( HFILE hfile, void *buf, - PM1632_FILESIZETYPE size ) -/****************************************************************************/ +PM1632_FILESIZETYPE _wpi_filewrite( HFILE hfile, void *buf, PM1632_FILESIZETYPE size ) +/************************************************************************************/ { -#if 0 // this definition seems to interfere with C lib IO PM1632_FILESIZETYPE len; PM1632_APIRET ret; @@ -156,16 +120,12 @@ PM1632_FILESIZETYPE _wpi_filewrite( HFILE hfile, void *buf, len = 0; } return( len ); -#else - return( fwrite( buf, 1, size, (void *)hfile ) ); -#endif + } /* _wpi_filewrite */ -PM1632_FILESIZETYPE _wpi_fileread( HFILE hfile, void *buf, - PM1632_FILESIZETYPE size ) -/****************************************************************************/ +PM1632_FILESIZETYPE _wpi_fileread( HFILE hfile, void *buf, PM1632_FILESIZETYPE size ) +/***********************************************************************************/ { -#if 0 // this definition seems to interfere with C lib IO PM1632_FILESIZETYPE len; PM1632_APIRET ret; @@ -174,7 +134,5 @@ PM1632_FILESIZETYPE _wpi_fileread( HFILE hfile, void *buf, len = 0; } return( len ); -#else - return( fread( buf, 1, size, (void *)hfile ) ); -#endif + } /* _wpi_fileread */ diff --git a/bld/wpi/h/wpi_os2.h b/bld/wpi/h/wpi_os2.h index 071fc04dbe..de129fd24d 100644 --- a/bld/wpi/h/wpi_os2.h +++ b/bld/wpi/h/wpi_os2.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2015-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2015-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -633,10 +633,8 @@ extern int _wpi_selectcliprgn( WPI_PRES pres, HRGN rgn ); extern HFILE _wpi_fileopen( LPSTR filename, int format ); extern HFILE _wpi_filecreate( LPSTR filename, int format ); extern PM1632_FILESIZETYPE _wpi_fileclose( HFILE hfile ); -extern PM1632_FILESIZETYPE _wpi_filewrite( HFILE hfile, void *buf, - PM1632_FILESIZETYPE size ); -extern PM1632_FILESIZETYPE _wpi_fileread( HFILE hfile, void *buf, - PM1632_FILESIZETYPE size ); +extern PM1632_FILESIZETYPE _wpi_filewrite( HFILE hfile, void *buf, PM1632_FILESIZETYPE size ); +extern PM1632_FILESIZETYPE _wpi_fileread( HFILE hfile, void *buf, PM1632_FILESIZETYPE size ); #define _wpi_isdialogmessage( win_hld, wpi_msg ) ( (wpi_msg)->hwnd == win_hld ) #define _wpi_ismessage( qmsg, id ) ( (qmsg)->msg == (id) ) diff --git a/bld/wpi/h/wpi_win.h b/bld/wpi/h/wpi_win.h index 1ce4f779f6..14d9d2272c 100644 --- a/bld/wpi/h/wpi_win.h +++ b/bld/wpi/h/wpi_win.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2015-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2015-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -451,7 +451,7 @@ extern void _wpi_getintwrectvalues( WPI_RECT rect, int *left, int *top, #define _wpi_filecreate( filename, format ) _lcreat( filename, 0 ) - #define _wpi_fileclose( file_hdl ) _lclose( file_hdl ) + #define _wpi_fileclose( hfile ) _lclose( hfile ) #define _wpi_filewrite( hfile, buf, size ) _lwrite( hfile, buf, size ) diff --git a/bld/wpi/h/wpitypes.h b/bld/wpi/h/wpitypes.h index ba8fea7f5f..2fcb40fcbf 100644 --- a/bld/wpi/h/wpitypes.h +++ b/bld/wpi/h/wpitypes.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2016-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2016-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -747,7 +747,6 @@ typedef struct { #define WPI_VERT_MULT 1 #define ULONG unsigned long #define NULLHANDLE ((HANDLE)0) - #define HFILE int #define HFILE_FORMAT int #define HMQ HANDLE #define DLGID_OK IDOK From 523f103f6e723d21d0f03d4126aaa9a51e5ac8f9 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Mon, 28 Aug 2023 11:53:51 +0200 Subject: [PATCH 039/258] cleanup windows version of trap server code --- bld/trap/common/servw.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/bld/trap/common/servw.c b/bld/trap/common/servw.c index 1a416e2f8c..33176d6ac1 100644 --- a/bld/trap/common/servw.c +++ b/bld/trap/common/servw.c @@ -60,7 +60,7 @@ static bool Linked = false; static bool OneShot = false; static bool FirstInstance( HINSTANCE ); -static bool AnyInstance( HINSTANCE, int, LPSTR ); +static bool AnyInstance( HINSTANCE, int ); #define MENU_ON (MF_ENABLED+MF_BYCOMMAND) #define MENU_OFF (MF_DISABLED+MF_GRAYED+MF_BYCOMMAND) @@ -71,6 +71,8 @@ static bool AnyInstance( HINSTANCE, int, LPSTR ); int PASCAL WinMain( HINSTANCE this_inst, HINSTANCE prev_inst, LPSTR cmdline, int cmdshow ) { MSG msg; + const char *err; + char trapparms[PARMS_MAXLEN]; Instance = this_inst; if( !prev_inst ) { @@ -78,7 +80,15 @@ int PASCAL WinMain( HINSTANCE this_inst, HINSTANCE prev_inst, LPSTR cmdline, int return( FALSE ); } } - if( !AnyInstance( this_inst, cmdshow, cmdline ) ) + err = ParseCommandLine( cmdline, trapparms, ServParms, &OneShot ); + if( err == NULL ) { + err = LoadTrap( trapparms, RWBuff, &TrapVersion ); + } + if( err != NULL ) { + StartupErr( err ); + return( FALSE ); + } + if( !AnyInstance( this_inst, cmdshow ) ) return( FALSE ); while( GetMessage( (LPVOID)&msg, (HWND)0, 0, 0 ) ) { @@ -138,19 +148,8 @@ static void EnableMenus( HWND hwnd, bool connected, bool session ) * AnyInstance - do work required for every instance of the application: * create the window, initialize data */ -static bool AnyInstance( HINSTANCE this_inst, int cmdshow, LPSTR cmdline ) +static bool AnyInstance( HINSTANCE this_inst, int cmdshow ) { - const char *err; - char trapparms[PARMS_MAXLEN]; - - err = ParseCommandLine( cmdline, trapparms, ServParms, &OneShot ); - if( err == NULL ) { - err = LoadTrap( trapparms, RWBuff, &TrapVersion ); - } - if( err != NULL ) { - StartupErr( err ); - return( false ); - } /* * create main window */ From 554f0e805f325be346c15429b3e6ec71b3813c45 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Mon, 28 Aug 2023 11:54:15 +0200 Subject: [PATCH 040/258] formatting change --- bld/trap/common/qnx/qnxdigl.c | 1 - 1 file changed, 1 deletion(-) diff --git a/bld/trap/common/qnx/qnxdigl.c b/bld/trap/common/qnx/qnxdigl.c index 41f9401015..5e9bc9728e 100644 --- a/bld/trap/common/qnx/qnxdigl.c +++ b/bld/trap/common/qnx/qnxdigl.c @@ -125,4 +125,3 @@ void DIGCLIENTRY( Free )( void *p ) { free( p ); } - From 5a8ec4f7a87298b51c093956806450cf72388687 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Mon, 28 Aug 2023 11:57:26 +0200 Subject: [PATCH 041/258] correct mistake in qnx code --- bld/dig/c/qnx/trpld.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bld/dig/c/qnx/trpld.c b/bld/dig/c/qnx/trpld.c index 8fde4315ac..f5370bd506 100644 --- a/bld/dig/c/qnx/trpld.c +++ b/bld/dig/c/qnx/trpld.c @@ -96,7 +96,7 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) } len++; } - if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, len, "trp", filename, sizeof( filename ) ) ) { + if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, len, "trp", filename, sizeof( filename ) ) == 0 ) { sprintf( buff, TC_ERR_CANT_LOAD_TRAP, base_name ); return( buff ); } From 42a69c6ccbb64690927fc6fab4f782fb1740219e Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Mon, 28 Aug 2023 12:05:06 +0200 Subject: [PATCH 042/258] rename symbols to be more consistent --- bld/dig/c/nt/dipld.c | 8 ++++---- bld/dig/c/nt/madld.c | 8 ++++---- bld/dig/c/nt/pillld.c | 9 +++++---- bld/dig/c/rdos/dipld.c | 8 ++++---- bld/dig/c/rdos/madld.c | 8 ++++---- bld/dig/c/rdos/pillld.c | 9 +++++---- bld/dig/c/win/dipld.c | 8 ++++---- bld/dig/c/win/madld.c | 8 ++++---- 8 files changed, 34 insertions(+), 32 deletions(-) diff --git a/bld/dig/c/nt/dipld.c b/bld/dig/c/nt/dipld.c index f1c59ab9c3..1d4d0ea5a8 100644 --- a/bld/dig/c/nt/dipld.c +++ b/bld/dig/c/nt/dipld.c @@ -52,13 +52,13 @@ dip_status DIPSysLoad( const char *base_name, dip_client_routines *cli, dip_imp_ { dip_sys_handle dip_dll; dip_init_func *init_func; - char newpath[256]; + char filename[256]; dip_status ds; *sys_hdl = NULL_SYSHDL; - strcpy( newpath, base_name ); - strcat( newpath, ".dll" ); - dip_dll = LoadLibrary( newpath ); + strcpy( filename, base_name ); + strcat( filename, ".dll" ); + dip_dll = LoadLibrary( filename ); if( dip_dll == NULL ) { return( DS_ERR | DS_FOPEN_FAILED ); } diff --git a/bld/dig/c/nt/madld.c b/bld/dig/c/nt/madld.c index 353b7517d5..c74ab47310 100644 --- a/bld/dig/c/nt/madld.c +++ b/bld/dig/c/nt/madld.c @@ -54,13 +54,13 @@ mad_status MADSysLoad( const char *base_name, mad_client_routines *cli, mad_imp_ { mad_sys_handle dip_dll; mad_init_func *init_func; - char newpath[256]; + char filename[256]; mad_status status; *sys_hdl = NULL_SYSHDL; - strcpy( newpath, base_name ); - strcat( newpath, ".dll" ); - dip_dll = LoadLibrary( newpath ); + strcpy( filename, base_name ); + strcat( filename, ".dll" ); + dip_dll = LoadLibrary( filename ); if( dip_dll == NULL ) { return( MS_ERR | MS_FOPEN_FAILED ); } diff --git a/bld/dig/c/nt/pillld.c b/bld/dig/c/nt/pillld.c index 27e58116ca..dc1f952dbc 100644 --- a/bld/dig/c/nt/pillld.c +++ b/bld/dig/c/nt/pillld.c @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -40,14 +41,14 @@ int PILLSysLoad( const char *path, const pill_client_routines *cli, link_handle *lh, link_message *msg ) { HANDLE dll; - char newpath[256]; + char filename[256]; pill_init_func *init_func; msg->source = NULL; msg->id = LM_SYSTEM_ERROR; - strcpy( newpath, path ); - strcat( newpath, ".dll" ); - dll = LoadLibrary( newpath ); + strcpy( filename, path ); + strcat( filename, ".dll" ); + dll = LoadLibrary( filename ); if( dll == NULL ) { msg->data.code = GetLastError(); return( 0 ); diff --git a/bld/dig/c/rdos/dipld.c b/bld/dig/c/rdos/dipld.c index 3da8b91f51..0cc8527e2e 100644 --- a/bld/dig/c/rdos/dipld.c +++ b/bld/dig/c/rdos/dipld.c @@ -52,13 +52,13 @@ dip_status DIPSysLoad( const char *base_name, dip_client_routines *cli, dip_imp_ { dip_sys_handle dip_dll; dip_init_func *init_func; - char newpath[256]; + char filename[256]; dip_status ds; *sys_hdl = NULL_SYSHDL; - strcpy( newpath, base_name ); - strcat( newpath, ".dll" ); - dip_dll = RdosLoadDll( newpath ); + strcpy( filename, base_name ); + strcat( filename, ".dll" ); + dip_dll = RdosLoadDll( filename ); if( dip_dll == NULL_SYSHDL ) { return( DS_ERR | DS_FOPEN_FAILED ); } diff --git a/bld/dig/c/rdos/madld.c b/bld/dig/c/rdos/madld.c index 877b81cb51..6bc00da9f7 100644 --- a/bld/dig/c/rdos/madld.c +++ b/bld/dig/c/rdos/madld.c @@ -54,13 +54,13 @@ mad_status MADSysLoad( const char *base_name, mad_client_routines *cli, mad_imp_ { mad_sys_handle mad_dll; mad_init_func *init_func; - char newpath[256]; + char filename[256]; mad_status status; *sys_hdl = NULL_SYSHDL; - strcpy( newpath, base_name ); - strcat( newpath, ".dll" ); - mad_dll = RdosLoadDll( newpath ); + strcpy( filename, base_name ); + strcat( filename, ".dll" ); + mad_dll = RdosLoadDll( filename ); if( mad_dll == NULL_SYSHDL ) { return( MS_ERR | MS_FOPEN_FAILED ); } diff --git a/bld/dig/c/rdos/pillld.c b/bld/dig/c/rdos/pillld.c index c3b9a33333..af5a5316d0 100644 --- a/bld/dig/c/rdos/pillld.c +++ b/bld/dig/c/rdos/pillld.c @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -40,14 +41,14 @@ int PILLSysLoad( const char *path, const pill_client_routines *cli, link_handle *lh, link_message *msg ) { int dll; - char newpath[256]; + char filename[256]; pill_init_func *init_func; msg->source = NULL; msg->id = LM_SYSTEM_ERROR; - strcpy( newpath, path ); - strcat( newpath, ".dll" ); - dll = RdosLoadDll( newpath ); + strcpy( filename, path ); + strcat( filename, ".dll" ); + dll = RdosLoadDll( filename ); if( dll == NULL ) { msg->data.code = -1; return( 0 ); diff --git a/bld/dig/c/win/dipld.c b/bld/dig/c/win/dipld.c index 12ad108710..eb7996e5fd 100644 --- a/bld/dig/c/win/dipld.c +++ b/bld/dig/c/win/dipld.c @@ -65,7 +65,7 @@ void DIPSysUnload( dip_sys_handle *sys_hdl ) dip_status DIPSysLoad( const char *base_name, dip_client_routines *cli, dip_imp_routines **imp, dip_sys_handle *sys_hdl ) { HINSTANCE dip_dll; - char newpath[256]; + char filename[256]; dip_status ds; char parm[10]; struct { @@ -83,8 +83,8 @@ dip_status DIPSysLoad( const char *base_name, dip_client_routines *cli, dip_imp_ UINT prev; *sys_hdl = NULL_SYSHDL; - strcpy( newpath, base_name ); - strcat( newpath, ".dll" ); + strcpy( filename, base_name ); + strcat( filename, ".dll" ); p = parm; *p++ = ' '; utoa( _FP_SEG( &transfer_block ), p, 16 ); @@ -100,7 +100,7 @@ dip_status DIPSysLoad( const char *base_name, dip_client_routines *cli, dip_imp_ parm_block.show = &show_block; parm_block.reserved = 0; prev = SetErrorMode( SEM_NOOPENFILEERRORBOX ); - dip_dll = LoadModule( newpath, &parm_block ); + dip_dll = LoadModule( filename, &parm_block ); DIPLastHandle = dip_dll; SetErrorMode( prev ); if( dip_dll < HINSTANCE_ERROR ) { diff --git a/bld/dig/c/win/madld.c b/bld/dig/c/win/madld.c index ddbce9362e..053585e38c 100644 --- a/bld/dig/c/win/madld.c +++ b/bld/dig/c/win/madld.c @@ -67,7 +67,7 @@ mad_status MADSysLoad( const char *base_name, mad_client_routines *cli, mad_imp_routines **imp, mad_sys_handle *sys_hdl ) { HINSTANCE dip_dll; - char newpath[256]; + char filename[256]; mad_status status; char parm[10]; struct { @@ -85,8 +85,8 @@ mad_status MADSysLoad( const char *base_name, mad_client_routines *cli, UINT prev; *sys_hdl = NULL_SYSHDL; - strcpy( newpath, base_name ); - strcat( newpath, ".dll" ); + strcpy( filename, base_name ); + strcat( filename, ".dll" ); p = parm; *p++ = ' '; utoa( _FP_SEG( &transfer_block ), p, 16 ); @@ -102,7 +102,7 @@ mad_status MADSysLoad( const char *base_name, mad_client_routines *cli, parm_block.show = &show_block; parm_block.reserved = 0; prev = SetErrorMode( SEM_NOOPENFILEERRORBOX ); - dip_dll = LoadModule( newpath, &parm_block ); + dip_dll = LoadModule( filename, &parm_block ); MADLastHandle = dip_dll; SetErrorMode( prev ); if( dip_dll < HINSTANCE_ERROR ) { From 332184198b6b88a7ea62642fe95e07c24646601d Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Mon, 28 Aug 2023 13:23:00 +0200 Subject: [PATCH 043/258] fix build break --- bld/wpi/c/wpi_file.c | 1 + 1 file changed, 1 insertion(+) diff --git a/bld/wpi/c/wpi_file.c b/bld/wpi/c/wpi_file.c index 68491c0d68..c9726e4dd6 100644 --- a/bld/wpi/c/wpi_file.c +++ b/bld/wpi/c/wpi_file.c @@ -32,6 +32,7 @@ #include #define INCL_PM +#define INCL_DOSDEVICES #include #include "wpi.h" From 493bdf401f50840fd6efa9c49537161a813faa67 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Mon, 28 Aug 2023 13:44:02 +0200 Subject: [PATCH 044/258] revert back unwanted change --- bld/dip/dwarf/c/dfsym.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/bld/dip/dwarf/c/dfsym.c b/bld/dip/dwarf/c/dfsym.c index 139b67b4f9..cd73ef6ee8 100644 --- a/bld/dip/dwarf/c/dfsym.c +++ b/bld/dip/dwarf/c/dfsym.c @@ -434,7 +434,7 @@ dip_status DIPIMPENTRY( SymValue )( imp_image_handle *iih, * size required by doing a SymType followed by a TypeInfo. */ { - uint_64 value; + uint_32 value; /* unused parameters */ (void)ic; @@ -442,7 +442,7 @@ dip_status DIPIMPENTRY( SymValue )( imp_image_handle *iih, return( DS_FAIL ); } DRSetDebug( iih->dwarf->handle ); /* must do at each call into DWARF */ - if( !DRConstValAT64( ish->sym, &value ) ) { + if( !DRConstValAT( ish->sym, &value ) ) { return( DS_FAIL ); } switch( ish->f.einfo.size ) { @@ -455,9 +455,6 @@ dip_status DIPIMPENTRY( SymValue )( imp_image_handle *iih, case 4: *(uint_32 *)buff = value; break; - case 8: - *(uint_64 *)buff = value; - break; default: return( DS_FAIL ); } From 8fbf8659a0ff95528201d2ebae7a0917ef8dfe58 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Mon, 28 Aug 2023 13:50:15 +0200 Subject: [PATCH 045/258] correct mistake in type --- bld/sdk/drwat/nt/digcli.c | 7 +++---- bld/sdk/drwat/win/digcli.c | 6 +++--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/bld/sdk/drwat/nt/digcli.c b/bld/sdk/drwat/nt/digcli.c index b8eced12cf..b9de53810b 100644 --- a/bld/sdk/drwat/nt/digcli.c +++ b/bld/sdk/drwat/nt/digcli.c @@ -235,10 +235,9 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base strncpy( fname, base_name, base_name_len ); fname[base_name_len] = '\0'; _splitpath2( fname, pg.buffer, &pg.drive, &pg.dir, &pg.fname, &pg.ext ); - if( pg.ext == NULL || *pg.ext == '\0' ) { - pg.ext = defext; - } - _makepath( fname, pg.drive, pg.dir, pg.fname, pg.ext ); + if( pg.ext != NULL && *pg.ext != '\0' ) + defext = pg.ext; + _makepath( fname, pg.drive, pg.dir, pg.fname, defext ); len = strlen( fname ); if( len > filename_len ) len = filename_len; diff --git a/bld/sdk/drwat/win/digcli.c b/bld/sdk/drwat/win/digcli.c index 41de31dcab..8c5da02cb6 100644 --- a/bld/sdk/drwat/win/digcli.c +++ b/bld/sdk/drwat/win/digcli.c @@ -238,9 +238,9 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base strncpy( fname, base_name, base_name_len ); fname[base_name_len] = '\0'; _splitpath2( fname, pg.buffer, &pg.drive, &pg.dir, &pg.fname, &pg.ext ); - if( pg.ext == NULL || pg.ext[0] == '\0' ) - pg.ext = defext; - _makepath( fname, pg.drive, pg.dir, pg.fname, pg.ext ); + if( pg.ext != NULL && *pg.ext != '\0' ) + defext = pg.ext; + _makepath( fname, pg.drive, pg.dir, pg.fname, defext ); len = strlen( fname ); if( len > filename_len ) len = filename_len; From c98b8fdbc52bfbcf774b7bb796384c5d71d8d3de Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Mon, 28 Aug 2023 14:07:00 +0200 Subject: [PATCH 046/258] revert back unwanted change --- bld/dip/dwarf/c/dftype.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/bld/dip/dwarf/c/dftype.c b/bld/dip/dwarf/c/dftype.c index bbe4c488d8..3f9421c098 100644 --- a/bld/dip/dwarf/c/dftype.c +++ b/bld/dip/dwarf/c/dftype.c @@ -538,18 +538,18 @@ dip_status DIPIMPENTRY( TypeBase )( imp_image_handle *iih, } typedef struct { - int_64 low; - int_64 high; + int_32 low; + int_32 high; } enum_range; static bool AEnum( drmem_hdl var, int index, void *_de ) { enum_range *de = _de; - int_64 value; + int_32 value; /* unused parameters */ (void)index; - if( !DRConstValAT64( var, (uint_64 *)&value ) ) { + if( !DRConstValAT( var, (uint_32 *)&value ) ) { return( false ); } if( value < de->low ) { @@ -569,12 +569,12 @@ static bool ArrayEnumType( drmem_hdl tenu, int index, void *_df ) { array_wlk_wlk *df = _df; enum_range de; - int_64 count; + int_32 count; /* unused parameters */ (void)index; - de.low = _I64_MIN; - de.high = _I64_MAX; + de.low = _I32_MIN; + de.high = _I32_MAX; if( !DRWalkEnum( tenu, AEnum, &de ) ) { return( false ); } From c6e8b5228c938d122b8557ca23462bd4667a665a Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Mon, 28 Aug 2023 15:29:38 +0200 Subject: [PATCH 047/258] cleanup dig code rename symbols to be more consistent --- bld/dig/c/dsx/dipld.c | 18 +++++++++--------- bld/dig/c/dsx/madld.c | 14 +++++++------- bld/dig/c/linux/dipld_so.c | 12 ++++++------ bld/dig/c/linux/madld_so.c | 12 ++++++------ bld/dig/c/linux/trpld_rx.c | 2 +- bld/dig/c/nt/dipld.c | 12 ++++++------ bld/dig/c/nt/madld.c | 12 ++++++------ bld/dig/c/os2/dipld.c | 27 +++++++++++++++------------ bld/dig/c/os2/madld.c | 27 +++++++++++++++------------ bld/dig/c/rdos/dipld.c | 12 ++++++------ bld/dig/c/rdos/madld.c | 12 ++++++------ bld/dig/c/win/dipld.c | 8 ++++---- bld/dig/c/win/madld.c | 8 ++++---- bld/trap/common/dos/dosdigl.c | 2 +- 14 files changed, 92 insertions(+), 86 deletions(-) diff --git a/bld/dig/c/dsx/dipld.c b/bld/dig/c/dsx/dipld.c index 18e878a52c..8909445ee3 100644 --- a/bld/dig/c/dsx/dipld.c +++ b/bld/dig/c/dsx/dipld.c @@ -37,8 +37,8 @@ #include "dip.h" #include "dipimp.h" #include "dipsys.h" -#include "ldimp.h" #include "dbgmod.h" +#include "ldimp.h" #define DIPSIG 0x00504944UL // "DIP" @@ -57,7 +57,7 @@ void DIPSysUnload( dip_sys_handle *sys_hdl ) dip_status DIPSysLoad( const char *base_name, dip_client_routines *cli, dip_imp_routines **imp, dip_sys_handle *sys_hdl ) { FILE *fp; - imp_header *dip; + imp_header *mod_hdl; dip_init_func *init_func; dip_status ds; char filename[_MAX_PATH]; @@ -70,23 +70,23 @@ dip_status DIPSysLoad( const char *base_name, dip_client_routines *cli, dip_imp_ if( fp == NULL ) { return( DS_ERR | DS_FOPEN_FAILED ); } - dip = ReadInImp( fp ); + mod_hdl = ReadInImp( fp ); DIGLoader( Close )( fp ); ds = DS_ERR | DS_INVALID_DIP; - if( dip != NULL ) { + if( mod_hdl != NULL ) { #ifdef __WATCOMC__ - if( dip->sig == DIPSIG ) { + if( mod_hdl->sig == DIPSIG ) { #endif #ifdef WATCOM_DEBUG_SYMBOLS /* * Look for symbols in separate .sym files, not the .dip itself */ strcpy( filename + strlen( filename ) - 4, ".sym" ); - DebuggerLoadUserModule( filename, GetCS(), (unsigned long)dip ); + DebuggerLoadUserModule( filename, GetCS(), (unsigned long)mod_hdl ); #endif - init_func = (dip_init_func *)dip->init_rtn; + init_func = (dip_init_func *)mod_hdl->init_rtn; if( init_func != NULL && (*imp = init_func( &ds, cli )) != NULL ) { - *sys_hdl = dip; + *sys_hdl = mod_hdl; return( DS_OK ); } #ifdef WATCOM_DEBUG_SYMBOLS @@ -95,7 +95,7 @@ dip_status DIPSysLoad( const char *base_name, dip_client_routines *cli, dip_imp_ #ifdef __WATCOMC__ } #endif - DIGCli( Free )( dip ); + DIPSysUnload( (dip_sys_handle *)&mod_hdl ); } return( ds ); } diff --git a/bld/dig/c/dsx/madld.c b/bld/dig/c/dsx/madld.c index e70b2c6443..f95ac5be2e 100644 --- a/bld/dig/c/dsx/madld.c +++ b/bld/dig/c/dsx/madld.c @@ -56,7 +56,7 @@ mad_status MADSysLoad( const char *base_name, mad_client_routines *cli, mad_imp_routines **imp, mad_sys_handle *sys_hdl ) { FILE *fp; - imp_header *mad; + imp_header *mod_hdl; mad_init_func *init_func; mad_status status; char filename[256]; @@ -69,22 +69,22 @@ mad_status MADSysLoad( const char *base_name, mad_client_routines *cli, if( fp == NULL ) { return( MS_ERR | MS_FOPEN_FAILED ); } - mad = ReadInImp( fp ); + mod_hdl = ReadInImp( fp ); DIGLoader( Close )( fp ); status = MS_ERR | MS_INVALID_MAD; - if( mad != NULL ) { + if( mod_hdl != NULL ) { #ifdef __WATCOMC__ - if( mad->sig == MADSIG ) { + if( mod_hdl->sig == MADSIG ) { #endif - init_func = (mad_init_func *)mad->init_rtn; + init_func = (mad_init_func *)mod_hdl->init_rtn; if( init_func != NULL && (*imp = init_func( &status, cli )) != NULL ) { - *sys_hdl = mad; + *sys_hdl = mod_hdl; return( MS_OK ); } #ifdef __WATCOMC__ } #endif - DIGCli( Free )( mad ); + MADSysUnload( (mad_sys_handle *)&mod_hdl ); } return( status ); } diff --git a/bld/dig/c/linux/dipld_so.c b/bld/dig/c/linux/dipld_so.c index 81dc8a97fe..d392789b14 100644 --- a/bld/dig/c/linux/dipld_so.c +++ b/bld/dig/c/linux/dipld_so.c @@ -51,7 +51,7 @@ void DIPSysUnload( dip_sys_handle *sys_hdl ) dip_status DIPSysLoad( const char *base_name, dip_client_routines *cli, dip_imp_routines **imp, dip_sys_handle *sys_hdl ) { - dip_sys_handle shlib; + dip_sys_handle mod_hdl; dip_init_func *init_func; char filename[_MAX_PATH]; dip_status ds; @@ -60,16 +60,16 @@ dip_status DIPSysLoad( const char *base_name, dip_client_routines *cli, dip_imp_ if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, strlen( base_name ), "so", filename, sizeof( filename ) ) == 0 ) { return( DS_ERR | DS_FOPEN_FAILED ); } - shlib = dlopen( filename, RTLD_NOW ); - if( shlib == NULL_SYSHDL ) { + mod_hdl = dlopen( filename, RTLD_NOW ); + if( mod_hdl == NULL_SYSHDL ) { return( DS_ERR | DS_FOPEN_FAILED ); } ds = DS_ERR | DS_INVALID_DIP; - init_func = (dip_init_func *)dlsym( shlib, "DIPLOAD" ); + init_func = (dip_init_func *)dlsym( mod_hdl, "DIPLOAD" ); if( init_func != NULL && (*imp = init_func( &ds, cli )) != NULL ) { - *sys_hdl = shlib; + *sys_hdl = mod_hdl; return( DS_OK ); } - dlclose( shlib ); + DIPSysUnload( &mod_hdl ); return( ds ); } diff --git a/bld/dig/c/linux/madld_so.c b/bld/dig/c/linux/madld_so.c index aed8c1ea90..858ececd42 100644 --- a/bld/dig/c/linux/madld_so.c +++ b/bld/dig/c/linux/madld_so.c @@ -52,7 +52,7 @@ void MADSysUnload( mad_sys_handle *sys_hdl ) mad_status MADSysLoad( const char *base_name, mad_client_routines *cli, mad_imp_routines **imp, mad_sys_handle *sys_hdl ) { - mad_sys_handle shlib; + mad_sys_handle mod_hdl; mad_init_func *init_func; char filename[_MAX_PATH]; mad_status status; @@ -61,16 +61,16 @@ mad_status MADSysLoad( const char *base_name, mad_client_routines *cli, mad_imp_ if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, strlen( base_name ), "so", filename, sizeof( filename ) ) == 0 ) { return( MS_ERR | MS_FOPEN_FAILED ); } - shlib = dlopen( filename, RTLD_NOW ); - if( shlib == NULL ) { + mod_hdl = dlopen( filename, RTLD_NOW ); + if( mod_hdl == NULL ) { return( MS_ERR | MS_FOPEN_FAILED ); } status = MS_ERR | MS_INVALID_MAD; - init_func = (mad_init_func *)dlsym( shlib, "MADLOAD" ); + init_func = (mad_init_func *)dlsym( mod_hdl, "MADLOAD" ); if( init_func != NULL && (*imp = init_func( &status, cli )) != NULL ) { - *sys_hdl = shlib; + *sys_hdl = mod_hdl; return( MS_OK ); } - dlclose( shlib ); + MADSysUnload( &mod_hdl ); return( status ); } diff --git a/bld/dig/c/linux/trpld_rx.c b/bld/dig/c/linux/trpld_rx.c index 51759c8cb1..f8498a0cbe 100644 --- a/bld/dig/c/linux/trpld_rx.c +++ b/bld/dig/c/linux/trpld_rx.c @@ -35,12 +35,12 @@ #include #include #include +#include "digcli.h" #include "digld.h" #include "trpld.h" #include "trpimp.h" #include "tcerr.h" #include "ldimp.h" -#include "digcli.h" #define TRAPSIG 0x50415254UL // "TRAP" diff --git a/bld/dig/c/nt/dipld.c b/bld/dig/c/nt/dipld.c index 1d4d0ea5a8..1f79f0546d 100644 --- a/bld/dig/c/nt/dipld.c +++ b/bld/dig/c/nt/dipld.c @@ -50,7 +50,7 @@ void DIPSysUnload( dip_sys_handle *sys_hdl ) dip_status DIPSysLoad( const char *base_name, dip_client_routines *cli, dip_imp_routines **imp, dip_sys_handle *sys_hdl ) { - dip_sys_handle dip_dll; + dip_sys_handle mod_hdl; dip_init_func *init_func; char filename[256]; dip_status ds; @@ -58,16 +58,16 @@ dip_status DIPSysLoad( const char *base_name, dip_client_routines *cli, dip_imp_ *sys_hdl = NULL_SYSHDL; strcpy( filename, base_name ); strcat( filename, ".dll" ); - dip_dll = LoadLibrary( filename ); - if( dip_dll == NULL ) { + mod_hdl = LoadLibrary( filename ); + if( mod_hdl == NULL ) { return( DS_ERR | DS_FOPEN_FAILED ); } ds = DS_ERR | DS_INVALID_DIP; - init_func = (dip_init_func *)GetProcAddress( dip_dll, "DIPLOAD" ); + init_func = (dip_init_func *)GetProcAddress( mod_hdl, "DIPLOAD" ); if( init_func != NULL && (*imp = init_func( &ds, cli )) != NULL ) { - *sys_hdl = dip_dll; + *sys_hdl = mod_hdl; return( DS_OK ); } - FreeLibrary( dip_dll ); + DIPSysUnload( &mod_hdl ); return( ds ); } diff --git a/bld/dig/c/nt/madld.c b/bld/dig/c/nt/madld.c index c74ab47310..7c22971759 100644 --- a/bld/dig/c/nt/madld.c +++ b/bld/dig/c/nt/madld.c @@ -52,7 +52,7 @@ void MADSysUnload( mad_sys_handle *sys_hdl ) mad_status MADSysLoad( const char *base_name, mad_client_routines *cli, mad_imp_routines **imp, mad_sys_handle *sys_hdl ) { - mad_sys_handle dip_dll; + mad_sys_handle mod_hdl; mad_init_func *init_func; char filename[256]; mad_status status; @@ -60,16 +60,16 @@ mad_status MADSysLoad( const char *base_name, mad_client_routines *cli, mad_imp_ *sys_hdl = NULL_SYSHDL; strcpy( filename, base_name ); strcat( filename, ".dll" ); - dip_dll = LoadLibrary( filename ); - if( dip_dll == NULL ) { + mod_hdl = LoadLibrary( filename ); + if( mod_hdl == NULL ) { return( MS_ERR | MS_FOPEN_FAILED ); } status = MS_ERR | MS_INVALID_MAD; - init_func = (mad_init_func *)GetProcAddress( dip_dll, "MADLOAD" ); + init_func = (mad_init_func *)GetProcAddress( mod_hdl, "MADLOAD" ); if( init_func != NULL && (*imp = init_func( &status, cli )) != NULL ) { - *sys_hdl = dip_dll; + *sys_hdl = mod_hdl; return( MS_OK ); } - FreeLibrary( dip_dll ); + MADSysUnload( &mod_hdl ); return( status ); } diff --git a/bld/dig/c/os2/dipld.c b/bld/dig/c/os2/dipld.c index b851bc6c23..18066ecd34 100644 --- a/bld/dig/c/os2/dipld.c +++ b/bld/dig/c/os2/dipld.c @@ -60,33 +60,36 @@ void DIPSysUnload( dip_sys_handle *sys_hdl ) dip_status DIPSysLoad( const char *base_name, dip_client_routines *cli, dip_imp_routines **imp, dip_sys_handle *sys_hdl ) { - dip_sys_handle dip_mod; + dip_sys_handle mod_hdl; dip_init_func *init_func; dip_status ds; + char filename[CCHMAXPATH]; #ifndef _M_I86 - char dipname[CCHMAXPATH]; - char dippath[CCHMAXPATH]; + char fname[CCHMAXPATH]; +#endif *sys_hdl = NULL_SYSHDL; /* * To prevent conflicts with the 16-bit DIP DLLs, the 32-bit versions have the "D32" * extension. We will search for them along the PATH (not in LIBPATH); */ - strcpy( dipname, base_name ); - strcat( dipname, ".D32" ); - _searchenv( dipname, "PATH", dippath ); - if( *dippath == '\0' ) +#ifdef _M_I86 + strcpy( filename, base_name ); +#else + strcpy( fname, base_name ); + strcat( fname, ".D32" ); + _searchenv( fname, "PATH", filename ); + if( *filename == '\0' ) return( DS_ERR | DS_FOPEN_FAILED ); - base_name = dippath; #endif - if( LOAD_MODULE( base_name, dip_mod ) ) { + if( LOAD_MODULE( filename, mod_hdl ) ) { return( DS_ERR | DS_FOPEN_FAILED ); } ds = DS_ERR | DS_INVALID_DIP; - if( GET_PROC_ADDRESS( dip_mod, "DIPLOAD", init_func ) && (*imp = init_func( &ds, cli )) != NULL ) { - *sys_hdl = dip_mod; + if( GET_PROC_ADDRESS( mod_hdl, "DIPLOAD", init_func ) && (*imp = init_func( &ds, cli )) != NULL ) { + *sys_hdl = mod_hdl; return( DS_OK ); } - DosFreeModule( dip_mod ); + DIPSysUnload( &mod_hdl ); return( ds ); } diff --git a/bld/dig/c/os2/madld.c b/bld/dig/c/os2/madld.c index 1746cd101a..999c31dd4c 100644 --- a/bld/dig/c/os2/madld.c +++ b/bld/dig/c/os2/madld.c @@ -60,33 +60,36 @@ void MADSysUnload( mad_sys_handle *sys_hdl ) mad_status MADSysLoad( const char *base_name, mad_client_routines *cli, mad_imp_routines **imp, mad_sys_handle *sys_hdl ) { - HMODULE dip_mod; + mad_sys_handle mod_hdl; mad_init_func *init_func; mad_status status; + char filename[CCHMAXPATH]; #ifndef _M_I86 - char madname[CCHMAXPATH]; - char madpath[CCHMAXPATH]; + char fname[CCHMAXPATH]; +#endif *sys_hdl = NULL_SYSHDL; /* * To prevent conflicts with the 16-bit MAD DLLs, the 32-bit versions have the "D32" * extension. We will search for them along the PATH (not in LIBPATH); */ - strcpy( madname, base_name ); - strcat( madname, ".D32" ); - _searchenv( madname, "PATH", madpath ); - if( *madpath == '\0' ) +#ifdef _M_I86 + strcpy( filename, base_name ); +#else + strcpy( fname, base_name ); + strcat( fname, ".D32" ); + _searchenv( fname, "PATH", filename ); + if( *filename == '\0' ) return( MS_ERR | MS_FOPEN_FAILED ); - base_name = madpath; #endif - if( LOAD_MODULE( base_name, dip_mod ) ) { + if( LOAD_MODULE( filename, mod_hdl ) ) { return( MS_ERR | MS_FOPEN_FAILED ); } status = MS_ERR | MS_INVALID_MAD; - if( GET_PROC_ADDRESS( dip_mod, "MADLOAD", init_func ) && (*imp = init_func( &status, cli )) != NULL ) { - *sys_hdl = dip_mod; + if( GET_PROC_ADDRESS( mod_hdl, "MADLOAD", init_func ) && (*imp = init_func( &status, cli )) != NULL ) { + *sys_hdl = mod_hdl; return( MS_OK ); } - DosFreeModule( dip_mod ); + MADSysUnload( &mod_hdl ); return( status ); } diff --git a/bld/dig/c/rdos/dipld.c b/bld/dig/c/rdos/dipld.c index 0cc8527e2e..deb9b1b6ab 100644 --- a/bld/dig/c/rdos/dipld.c +++ b/bld/dig/c/rdos/dipld.c @@ -50,7 +50,7 @@ void DIPSysUnload( dip_sys_handle *sys_hdl ) dip_status DIPSysLoad( const char *base_name, dip_client_routines *cli, dip_imp_routines **imp, dip_sys_handle *sys_hdl ) { - dip_sys_handle dip_dll; + dip_sys_handle mod_hdl; dip_init_func *init_func; char filename[256]; dip_status ds; @@ -58,16 +58,16 @@ dip_status DIPSysLoad( const char *base_name, dip_client_routines *cli, dip_imp_ *sys_hdl = NULL_SYSHDL; strcpy( filename, base_name ); strcat( filename, ".dll" ); - dip_dll = RdosLoadDll( filename ); - if( dip_dll == NULL_SYSHDL ) { + mod_hdl = RdosLoadDll( filename ); + if( mod_hdl == NULL_SYSHDL ) { return( DS_ERR | DS_FOPEN_FAILED ); } ds = DS_ERR | DS_INVALID_DIP; - init_func = (dip_init_func *)RdosGetModuleProc( dip_dll, "DIPLOAD" ); + init_func = (dip_init_func *)RdosGetModuleProc( mod_hdl, "DIPLOAD" ); if( init_func != NULL && (*imp = init_func( &ds, cli )) != NULL ) { - *sys_hdl = dip_dll; + *sys_hdl = mod_hdl; return( DS_OK ); } - RdosFreeDll( dip_dll ); + DIPSysUnload( &mod_hdl ); return( ds ); } diff --git a/bld/dig/c/rdos/madld.c b/bld/dig/c/rdos/madld.c index 6bc00da9f7..74849c9576 100644 --- a/bld/dig/c/rdos/madld.c +++ b/bld/dig/c/rdos/madld.c @@ -52,7 +52,7 @@ void MADSysUnload( mad_sys_handle *sys_hdl ) mad_status MADSysLoad( const char *base_name, mad_client_routines *cli, mad_imp_routines **imp, mad_sys_handle *sys_hdl ) { - mad_sys_handle mad_dll; + mad_sys_handle mod_hdl; mad_init_func *init_func; char filename[256]; mad_status status; @@ -60,16 +60,16 @@ mad_status MADSysLoad( const char *base_name, mad_client_routines *cli, mad_imp_ *sys_hdl = NULL_SYSHDL; strcpy( filename, base_name ); strcat( filename, ".dll" ); - mad_dll = RdosLoadDll( filename ); - if( mad_dll == NULL_SYSHDL ) { + mod_hdl = RdosLoadDll( filename ); + if( mod_hdl == NULL_SYSHDL ) { return( MS_ERR | MS_FOPEN_FAILED ); } status = MS_ERR | MS_INVALID_MAD; - init_func = (mad_init_func *)RdosGetModuleProc( mad_dll, "MADLOAD" ); + init_func = (mad_init_func *)RdosGetModuleProc( mod_hdl, "MADLOAD" ); if( init_func != NULL && (*imp = init_func( &status, cli )) != NULL ) { - *sys_hdl = mad_dll; + *sys_hdl = mod_hdl; return( MS_OK ); } - RdosFreeDll( mad_dll ); + MADSysUnload( &mod_hdl ); return( status ); } diff --git a/bld/dig/c/win/dipld.c b/bld/dig/c/win/dipld.c index eb7996e5fd..4c4c50aec1 100644 --- a/bld/dig/c/win/dipld.c +++ b/bld/dig/c/win/dipld.c @@ -64,7 +64,7 @@ void DIPSysUnload( dip_sys_handle *sys_hdl ) dip_status DIPSysLoad( const char *base_name, dip_client_routines *cli, dip_imp_routines **imp, dip_sys_handle *sys_hdl ) { - HINSTANCE dip_dll; + HINSTANCE mod_hdl; char filename[256]; dip_status ds; char parm[10]; @@ -100,10 +100,10 @@ dip_status DIPSysLoad( const char *base_name, dip_client_routines *cli, dip_imp_ parm_block.show = &show_block; parm_block.reserved = 0; prev = SetErrorMode( SEM_NOOPENFILEERRORBOX ); - dip_dll = LoadModule( filename, &parm_block ); - DIPLastHandle = dip_dll; + mod_hdl = LoadModule( filename, &parm_block ); + DIPLastHandle = mod_hdl; SetErrorMode( prev ); - if( dip_dll < HINSTANCE_ERROR ) { + if( mod_hdl < HINSTANCE_ERROR ) { return( DS_ERR | DS_FOPEN_FAILED ); } ds = DS_ERR | DS_INVALID_DIP; diff --git a/bld/dig/c/win/madld.c b/bld/dig/c/win/madld.c index 053585e38c..8c76a4269e 100644 --- a/bld/dig/c/win/madld.c +++ b/bld/dig/c/win/madld.c @@ -66,7 +66,7 @@ void MADSysUnload( mad_sys_handle *sys_hdl ) mad_status MADSysLoad( const char *base_name, mad_client_routines *cli, mad_imp_routines **imp, mad_sys_handle *sys_hdl ) { - HINSTANCE dip_dll; + HINSTANCE mod_hdl; char filename[256]; mad_status status; char parm[10]; @@ -102,10 +102,10 @@ mad_status MADSysLoad( const char *base_name, mad_client_routines *cli, parm_block.show = &show_block; parm_block.reserved = 0; prev = SetErrorMode( SEM_NOOPENFILEERRORBOX ); - dip_dll = LoadModule( filename, &parm_block ); - MADLastHandle = dip_dll; + mod_hdl = LoadModule( filename, &parm_block ); + MADLastHandle = mod_hdl; SetErrorMode( prev ); - if( dip_dll < HINSTANCE_ERROR ) { + if( mod_hdl < HINSTANCE_ERROR ) { return( MS_ERR | MS_FOPEN_FAILED ); } status = MS_ERR | MS_INVALID_MAD; diff --git a/bld/trap/common/dos/dosdigl.c b/bld/trap/common/dos/dosdigl.c index 8864f74c4e..289ac77b79 100644 --- a/bld/trap/common/dos/dosdigl.c +++ b/bld/trap/common/dos/dosdigl.c @@ -71,7 +71,7 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base case '/': case '\\': has_ext = false; - /* fall through */ + /* fall through */ case ':': has_path = true; break; From e24281444000b97d028d34ebfdb7490ee076d174 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Mon, 28 Aug 2023 17:35:03 +0200 Subject: [PATCH 048/258] fix type --- bld/trap/common/servcmd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bld/trap/common/servcmd.c b/bld/trap/common/servcmd.c index 0b8cef5751..01161b0cc4 100644 --- a/bld/trap/common/servcmd.c +++ b/bld/trap/common/servcmd.c @@ -137,7 +137,7 @@ const char *ParseCommandLine( const char *cmdline, char *trapparms, char *servpa ptr = SkipSpaces( ptr + 1 ); start = ptr; #undef isalpha - while( isalpha( *ptr ) ) + while( isalpha( *(unsigned char *)ptr ) ) ++ptr; if( ptr == start ) { return( TRP_ERR_expect_option ); From ab6b692660f9126e0dae2bc297fc5a309048fe9c Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Mon, 28 Aug 2023 20:05:07 +0200 Subject: [PATCH 049/258] fix TryOnePath to skip blank path item --- bld/trap/common/linux/lnxdigl.c | 5 ++- bld/trap/common/linux/lnxpath.c | 57 ++++++++++++++++++-------------- bld/trap/common/nto/ntodigl.c | 5 ++- bld/trap/common/nto/ntopath.c | 58 +++++++++++++++++++-------------- bld/trap/common/qnx/qnxdigl.c | 5 ++- bld/trap/common/qnx/qnxpath.c | 58 +++++++++++++++++++-------------- 6 files changed, 105 insertions(+), 83 deletions(-) diff --git a/bld/trap/common/linux/lnxdigl.c b/bld/trap/common/linux/lnxdigl.c index 02b6073142..3fbddc5750 100644 --- a/bld/trap/common/linux/lnxdigl.c +++ b/bld/trap/common/linux/lnxdigl.c @@ -77,10 +77,9 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base *p = '\0'; if( has_path ) { p = fname; - } else if( FindFilePath( DIG_FILETYPE_DBG, fname, RWBuff ) ) { - p = RWBuff; } else { - p = ""; + FindFilePath( DIG_FILETYPE_DBG, fname, RWBuff ); + p = RWBuff; } len = strlen( p ); if( filename_len > 0 ) { diff --git a/bld/trap/common/linux/lnxpath.c b/bld/trap/common/linux/lnxpath.c index 86b8425645..c62d2adbab 100644 --- a/bld/trap/common/linux/lnxpath.c +++ b/bld/trap/common/linux/lnxpath.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -49,34 +49,43 @@ char *StrCopyDst( const char *src, char *dst ) unsigned TryOnePath( const char *path, struct stat *tmp, const char *name, char *result ) { - char *end; char *ptr; - if( path == NULL ) - return( 0 ); - ptr = result; - for( ;; ) { - switch( *path ) { - case ':': - case '\0': - if( ptr != result && ptr[-1] != '/' ) + if( path != NULL && *path != '\0' ) { + ptr = result; + for( ; *path != '\0'; path++ ) { + switch( *path ) { + case ':': + if( path[1] == ':' ) + continue; + if( ptr == result ) + continue; + if( ptr[-1] != '/' ) + *ptr++ = '/'; + ptr = StrCopyDst( name, ptr ); + if( stat( result, tmp ) == 0 ) + return( ptr - result ); + ptr = result; + break; + case ' ': + case '\t': + break; + default: + *ptr++ = *path; + break; + } + } + if( ptr != result ) { + if( ptr[-1] != '/' ) *ptr++ = '/'; - end = StrCopyDst( name, ptr ); - if( stat( result, tmp ) == 0 ) - return( end - result ); - if( *path == '\0' ) - return( 0 ); - ptr = result; - break; - case ' ': - case '\t': - break; - default: - *ptr++ = *path; - break; + ptr = StrCopyDst( name, ptr ); + if( stat( result, tmp ) == 0 ) { + return( ptr - result ); + } } - ++path; } + *result = '\0'; + return( 0 ); } unsigned FindFilePath( dig_filetype file_type, const char *name, char *result ) diff --git a/bld/trap/common/nto/ntodigl.c b/bld/trap/common/nto/ntodigl.c index dbd5e4a16e..3ca373bae3 100644 --- a/bld/trap/common/nto/ntodigl.c +++ b/bld/trap/common/nto/ntodigl.c @@ -79,10 +79,9 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base *p = '\0'; if( has_path ) { p = fname; - } else if( FindFilePath( DIG_FILETYPE_DBG, fname, RWBuff ) ) { - p = RWBuff; } else { - p = ""; + FindFilePath( DIG_FILETYPE_DBG, fname, RWBuff ); + p = RWBuff; } len = strlen( p ); if( filename_len > 0 ) { diff --git a/bld/trap/common/nto/ntopath.c b/bld/trap/common/nto/ntopath.c index d1a47908c9..c25b0116f8 100644 --- a/bld/trap/common/nto/ntopath.c +++ b/bld/trap/common/nto/ntopath.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -50,35 +50,43 @@ char *StrCopyDst( const char *src, char *dst ) unsigned TryOnePath( const char *path, struct stat *tmp, const char *name, char *result ) { - char *end; char *ptr; - if( path == NULL ) - return( 0 ); - ptr = result; - for( ;; ) { - switch( *path ) { - case ':': - case '\0': - if( ptr != result && ptr[-1] != '/' ) + if( path != NULL && *path != '\0' ) { + ptr = result; + for( ; *path != '\0'; path++ ) { + switch( *path ) { + case ':': + if( path[1] == ':' ) + continue; + if( ptr == result ) + continue; + if( ptr[-1] != '/' ) + *ptr++ = '/'; + ptr = StrCopyDst( name, ptr ); + if( stat( result, tmp ) == 0 ) + return( ptr - result ); + ptr = result; + break; + case ' ': + case '\t': + break; + default: + *ptr++ = *path; + break; + } + } + if( ptr != result ) { + if( ptr[-1] != '/' ) *ptr++ = '/'; - end = StrCopyDst( name, ptr ); - //NYI: really should check permission bits - if( stat( result, tmp ) == 0 ) - return( end - result ); - if( *path == '\0' ) - return( 0 ); - ptr = result; - break; - case ' ': - case '\t': - break; - default: - *ptr++ = *path; - break; + ptr = StrCopyDst( name, ptr ); + if( stat( result, tmp ) == 0 ) { + return( ptr - result ); + } } - ++path; } + *result = '\0'; + return( 0 ); } unsigned FindFilePath( dig_filetype file_type, const char *name, char *result ) diff --git a/bld/trap/common/qnx/qnxdigl.c b/bld/trap/common/qnx/qnxdigl.c index 5e9bc9728e..190aef2c14 100644 --- a/bld/trap/common/qnx/qnxdigl.c +++ b/bld/trap/common/qnx/qnxdigl.c @@ -79,10 +79,9 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base *p = '\0'; if( has_path ) { p = fname; - } else if( FindFilePath( DIG_FILETYPE_DBG, fname, RWBuff ) ) { - p = RWBuff; } else { - p = ""; + FindFilePath( DIG_FILETYPE_DBG, fname, RWBuff ); + p = RWBuff; } len = strlen( p ); if( filename_len > 0 ) { diff --git a/bld/trap/common/qnx/qnxpath.c b/bld/trap/common/qnx/qnxpath.c index 65a0b86bc8..1bdfead2a5 100644 --- a/bld/trap/common/qnx/qnxpath.c +++ b/bld/trap/common/qnx/qnxpath.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -49,35 +49,43 @@ char *StrCopyDst( const char *src, char *dst ) size_t TryOnePath( const char *path, struct stat *tmp, const char *name, char *result ) { - char *end; char *ptr; - if( path == NULL ) - return( 0 ); - ptr = result; - for( ;; ) { - switch( *path ) { - case ':': - case '\0': - if( ptr != result && ptr[-1] != '/' ) + if( path != NULL && *path != '\0' ) { + ptr = result; + for( ; *path != '\0'; path++ ) { + switch( *path ) { + case ':': + if( path[1] == ':' ) + continue; + if( ptr == result ) + continue; + if( ptr[-1] != '/' ) + *ptr++ = '/'; + ptr = StrCopyDst( name, ptr ); + if( stat( result, tmp ) == 0 ) + return( ptr - result ); + ptr = result; + break; + case ' ': + case '\t': + break; + default: + *ptr++ = *path; + break; + } + } + if( ptr != result ) { + if( ptr[-1] != '/' ) *ptr++ = '/'; - end = StrCopyDst( name, ptr ); - //NYI: really should check permission bits - if( stat( result, tmp ) == 0 ) - return( end - result ); - if( *path == '\0' ) - return( 0 ); - ptr = result; - break; - case ' ': - case '\t': - break; - default: - *ptr++ = *path; - break; + ptr = StrCopyDst( name, ptr ); + if( stat( result, tmp ) == 0 ) { + return( ptr - result ); + } } - ++path; } + *result = '\0'; + return( 0 ); } unsigned FindFilePath( dig_filetype file_type, const char *name, char *result ) From f66426c63a76f257d4c68c0f58d74f67eaa79f9d Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Tue, 29 Aug 2023 00:10:47 +0200 Subject: [PATCH 050/258] rename functions to more transparent names --- bld/wv/c/dbgfile.c | 6 +++--- bld/wv/c/dbgprog.c | 4 ++-- bld/wv/c/remfile.c | 4 ++-- bld/wv/h/dbgio.h | 3 ++- bld/wv/h/remfile.h | 4 ++-- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/bld/wv/c/dbgfile.c b/bld/wv/c/dbgfile.c index b6b4c1dda1..1b9204f5b7 100644 --- a/bld/wv/c/dbgfile.c +++ b/bld/wv/c/dbgfile.c @@ -449,7 +449,7 @@ static size_t MakeNameWithPath( obj_attrs oattrs, } -file_handle LclStringToFullName( const char *name, size_t len, char *full ) +file_handle LclFileToFullName( const char *name, size_t len, char *full ) { char_ring *curr; file_handle fh; @@ -521,13 +521,13 @@ static file_handle FullPathOpenInternal( const char *name, size_t name_len, cons } *p = NULLCHAR; if( oattrs & OP_REMOTE ) { - RemoteStringToFullName( DIG_FILETYPE_PRS, buffer, result, (trap_elen)result_len ); + RemoteFileToFullName( DIG_FILETYPE_PRS, buffer, result, (trap_elen)result_len ); fh = FileOpen( result, OP_READ | OP_REMOTE ); } else if( has_path ) { StrCopyDst( buffer, result ); fh = FileOpen( buffer, OP_READ ); } else { - fh = LclStringToFullName( buffer, p - buffer, result ); + fh = LclFileToFullName( buffer, p - buffer, result ); } if( fh == NIL_HANDLE ) { strcpy( result, buffer ); diff --git a/bld/wv/c/dbgprog.c b/bld/wv/c/dbgprog.c index 6f2c3dfa5b..9ea768272b 100644 --- a/bld/wv/c/dbgprog.c +++ b/bld/wv/c/dbgprog.c @@ -926,7 +926,7 @@ static int DoLoadProg( const char *task, const char *symfile, error_handle *errh FileClose( fh ); } } else { - len = RemoteStringToFullName( DIG_FILETYPE_EXE, name, fullname, sizeof( fullname ) ); + len = RemoteFileToFullName( DIG_FILETYPE_EXE, name, fullname, sizeof( fullname ) ); fullname[len] = NULLCHAR; } image = CreateImage( fullname, symfile ); @@ -1039,7 +1039,7 @@ size_t GetProgName( char *where, size_t len ) /* Before, we did a: - RemoteStringToFullName( DIG_FILETYPE_EXE, TaskCmd, where, len ); + RemoteFileToFullName( DIG_FILETYPE_EXE, TaskCmd, where, len ); but that screws up when the user specified something other than just an executable on the command line. E.g. a PID to connect diff --git a/bld/wv/c/remfile.c b/bld/wv/c/remfile.c index 768ef48aaa..3f55afe35e 100644 --- a/bld/wv/c/remfile.c +++ b/bld/wv/c/remfile.c @@ -159,7 +159,7 @@ bool HaveRemoteFiles( void ) } //NYI: The 'bool executable' should be changed to allow different file types -size_t RemoteStringToFullName( dig_filetype file_type, const char *name, char *res, +size_t RemoteFileToFullName( dig_filetype file_type, const char *name, char *res, trap_elen res_len ) { in_mx_entry in[2]; @@ -172,7 +172,7 @@ size_t RemoteStringToFullName( dig_filetype file_type, const char *name, char *r #endif if( SuppFileId == 0 ) { - fh = LclStringToFullName( name, strlen( name ), res ); + fh = LclFileToFullName( name, strlen( name ), res ); if( fh == NIL_HANDLE ) return( 0 ); FileClose( fh ); diff --git a/bld/wv/h/dbgio.h b/bld/wv/h/dbgio.h index 9d8d33193e..904886cafe 100644 --- a/bld/wv/h/dbgio.h +++ b/bld/wv/h/dbgio.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -87,7 +88,7 @@ extern size_t MakeFileName( char *result, const char *name, const char extern const char *RealFName( char const *name, obj_attrs *oattrs ); extern bool IsAbsolutePath( const char *path ); extern const char *ExtPointer( char const *path, obj_attrs oattrs ); -extern file_handle LclStringToFullName( const char *name, size_t len, char *full ); +extern file_handle LclFileToFullName( const char *name, size_t len, char *full ); extern file_handle FullPathOpen( const char *name, size_t name_len, const char *ext, char *result, size_t max_result ); extern file_handle LocalFullPathOpen( const char *name, size_t name_len, const char *ext, char *result, size_t max_result ); extern file_handle PathOpen( const char *name, size_t name_len, const char *ext ); diff --git a/bld/wv/h/remfile.h b/bld/wv/h/remfile.h index 8f4c42697b..b4d1dbf6a1 100644 --- a/bld/wv/h/remfile.h +++ b/bld/wv/h/remfile.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -32,7 +32,7 @@ extern bool InitFileSupp( void ); extern bool HaveRemoteFiles( void ); -extern size_t RemoteStringToFullName( dig_filetype file_type, const char *name, char *res, trap_elen res_len ); +extern size_t RemoteFileToFullName( dig_filetype file_type, const char *name, char *res, trap_elen res_len ); #if !defined( BUILD_RFX ) extern error_handle RemoteFork( const char *cmd, trap_elen len ); #endif From bdad3877c26912c3d07d52307a86fe2917b5fa48 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Tue, 29 Aug 2023 00:17:02 +0200 Subject: [PATCH 051/258] cleanup qnx trap code --- bld/trap/common/qnx/qnxpath.c | 16 ++++++++-------- bld/trap/common/qnx/qnxpath.h | 3 +-- bld/trap/lcl/qnx/c/qnxpmd.c | 17 ++++++++++++----- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/bld/trap/common/qnx/qnxpath.c b/bld/trap/common/qnx/qnxpath.c index 1bdfead2a5..6153a87f4f 100644 --- a/bld/trap/common/qnx/qnxpath.c +++ b/bld/trap/common/qnx/qnxpath.c @@ -47,7 +47,7 @@ char *StrCopyDst( const char *src, char *dst ) return( dst ); } -size_t TryOnePath( const char *path, struct stat *tmp, const char *name, char *result ) +static size_t tryOnePath( const char *path, struct stat *tmp, const char *name, char *result ) { char *ptr; @@ -88,10 +88,10 @@ size_t TryOnePath( const char *path, struct stat *tmp, const char *name, char *r return( 0 ); } -unsigned FindFilePath( dig_filetype file_type, const char *name, char *result ) +size_t FindFilePath( dig_filetype file_type, const char *name, char *result ) { struct stat tmp; - unsigned len; + size_t len; #if defined( SERVER ) char *end; char cmd[256]; @@ -101,12 +101,12 @@ unsigned FindFilePath( dig_filetype file_type, const char *name, char *result ) return( StrCopyDst( name, result ) - result ); } if( file_type == DIG_FILETYPE_EXE ) { - return( TryOnePath( getenv( "PATH" ), &tmp, name, result ) ); + return( tryOnePath( getenv( "PATH" ), &tmp, name, result ) ); } else { - len = TryOnePath( getenv( "WD_PATH" ), &tmp, name, result ); + len = tryOnePath( getenv( "WD_PATH" ), &tmp, name, result ); if( len != 0 ) return( len ); - len = TryOnePath( getenv( "HOME" ), &tmp, name, result ); + len = tryOnePath( getenv( "HOME" ), &tmp, name, result ); if( len != 0 ) return( len ); #if defined( SERVER ) @@ -119,7 +119,7 @@ unsigned FindFilePath( dig_filetype file_type, const char *name, char *result ) /* look in the wd sibling directory of where the command came from */ StrCopyDst( "wd", end + 1 ); - len = TryOnePath( cmd, &tmp, name, result ); + len = tryOnePath( cmd, &tmp, name, result ); if( len != 0 ) { return( len ); } @@ -127,6 +127,6 @@ unsigned FindFilePath( dig_filetype file_type, const char *name, char *result ) } } #endif - return( TryOnePath( "/usr/watcom/wd", &tmp, name, result ) ); + return( tryOnePath( "/usr/watcom/wd", &tmp, name, result ) ); } } diff --git a/bld/trap/common/qnx/qnxpath.h b/bld/trap/common/qnx/qnxpath.h index bb82544726..a71e054c81 100644 --- a/bld/trap/common/qnx/qnxpath.h +++ b/bld/trap/common/qnx/qnxpath.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -32,5 +32,4 @@ extern char *StrCopyDst( const char *src, char *dst ); -extern size_t TryOnePath( const char *, struct stat *, const char *, char *dst ); extern size_t FindFilePath( dig_filetype, const char *src, char *dst ); diff --git a/bld/trap/lcl/qnx/c/qnxpmd.c b/bld/trap/lcl/qnx/c/qnxpmd.c index cc299aa086..e52b4c41d7 100644 --- a/bld/trap/lcl/qnx/c/qnxpmd.c +++ b/bld/trap/lcl/qnx/c/qnxpmd.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -456,13 +456,20 @@ static bool LoadPmdHeader( char *name ) struct stat tmp; char result[PATH_MAX + 1]; - if( TryOnePath( ":/usr/dumps", &tmp, name, result ) == 0 ) - return( false ); + strcpy( result, name ); + if( stat( result, &tmp ) != 0 ) { + #define DUMPSDIR "/usr/dumps/" + strcpy( result, DUMPSDIR ); + strcpy( result + sizeof( DUMPSDIR ) - 1, name ); + #undef DUMPSDIR + if( stat( result, &tmp ) != 0 ) { + return( false ); + } + } PmdInfo.fd = open( result, O_RDONLY ); if( PmdInfo.fd < 0 ) return( false ); - if( read( PmdInfo.fd, &PmdInfo.hdr, sizeof( PmdInfo.hdr ) ) - != sizeof( PmdInfo.hdr ) ) { + if( read( PmdInfo.fd, &PmdInfo.hdr, sizeof( PmdInfo.hdr ) ) != sizeof( PmdInfo.hdr ) ) { close( PmdInfo.fd ); PmdInfo.fd = NO_FILE; errno = ENOEXEC; From 431c821e1694a90a209471529455a9b4b54805ab Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Tue, 29 Aug 2023 01:11:21 +0200 Subject: [PATCH 052/258] rename function to be more transparent --- bld/dig/h/trpfile.h | 4 ++-- bld/trap/lcl/dos/c/dosfile.c | 4 ++-- bld/trap/lcl/elfcore/c/elfcore.c | 2 +- bld/trap/lcl/jvm/c/acclcl.c | 4 ++-- bld/trap/lcl/jvm/c/jvmacc.c | 6 +++--- bld/trap/lcl/linux/c/lnxacc.c | 4 ++-- bld/trap/lcl/linux/c/lnxcore.c | 2 +- bld/trap/lcl/msj/c/acclcl.c | 4 ++-- bld/trap/lcl/nlm/c/nlmfile.c | 4 ++-- bld/trap/lcl/nt/c/accio.c | 2 +- bld/trap/lcl/nto/c/ntoacc.c | 2 +- bld/trap/lcl/os2/c/accmisc.c | 2 +- bld/trap/lcl/os2v2/c/accmisc.c | 2 +- bld/trap/lcl/qnx/c/qnxacc.c | 6 ++---- bld/trap/lcl/qnx/c/qnxpmd.c | 6 ++---- bld/trap/lcl/rdos/c/accio.c | 4 ++-- bld/trap/lcl/win/c/winfile.c | 4 ++-- 17 files changed, 29 insertions(+), 33 deletions(-) diff --git a/bld/dig/h/trpfile.h b/bld/dig/h/trpfile.h index a155429730..158363cd60 100644 --- a/bld/dig/h/trpfile.h +++ b/bld/dig/h/trpfile.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -48,7 +48,7 @@ REQ_FILE_DEF( WRITE_CONSOLE, write_console ) \ REQ_FILE_DEF( CLOSE, close ) \ REQ_FILE_DEF( ERASE, erase ) \ - REQ_FILE_DEF( STRING_TO_FULLPATH, string_to_fullpath ) \ + REQ_FILE_DEF( STRING_TO_FULLPATH, file_to_fullpath ) \ REQ_FILE_DEF( RUN_CMD, run_cmd ) enum { diff --git a/bld/trap/lcl/dos/c/dosfile.c b/bld/trap/lcl/dos/c/dosfile.c index 1e12975af6..34c1a74d83 100644 --- a/bld/trap/lcl/dos/c/dosfile.c +++ b/bld/trap/lcl/dos/c/dosfile.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -189,7 +189,7 @@ trap_retval TRAP_FILE( erase )( void ) return( sizeof( *ret ) ); } -trap_retval TRAP_FILE( string_to_fullpath )( void ) +trap_retval TRAP_FILE( file_to_fullpath )( void ) { char *name; char *fullname; diff --git a/bld/trap/lcl/elfcore/c/elfcore.c b/bld/trap/lcl/elfcore/c/elfcore.c index b489c3d9b8..f56a8efa24 100644 --- a/bld/trap/lcl/elfcore/c/elfcore.c +++ b/bld/trap/lcl/elfcore/c/elfcore.c @@ -641,7 +641,7 @@ trap_retval TRAP_CORE( Redirect_stdout )( void ) return( TRAP_CORE( Redirect_stdin )() ); } -trap_retval TRAP_FILE( string_to_fullpath )( void ) +trap_retval TRAP_FILE( file_to_fullpath )( void ) { unsigned_16 len; char *name; diff --git a/bld/trap/lcl/jvm/c/acclcl.c b/bld/trap/lcl/jvm/c/acclcl.c index 8c90247eeb..43c33c0e31 100644 --- a/bld/trap/lcl/jvm/c/acclcl.c +++ b/bld/trap/lcl/jvm/c/acclcl.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -267,7 +267,7 @@ trap_retval TRAP_FILE( run_cmd )( void ) return( sizeof( *ret ) ); } -trap_retval TRAP_FILE( string_to_fullpath )( void ) +trap_retval TRAP_FILE( file_to_fullpath )( void ) { file_string_to_fullpath_req *acc; file_string_to_fullpath_ret *ret; diff --git a/bld/trap/lcl/jvm/c/jvmacc.c b/bld/trap/lcl/jvm/c/jvmacc.c index 23e075f1f5..253ef4918a 100644 --- a/bld/trap/lcl/jvm/c/jvmacc.c +++ b/bld/trap/lcl/jvm/c/jvmacc.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -1215,8 +1215,8 @@ trap_retval TRAP_FILE( get_config )( void ) return( 0 ); } -trap_retval TRAP_FILE( string_to_fullpath )( void ) -/*************************************************/ +trap_retval TRAP_FILE( file_to_fullpath )( void ) +/***********************************************/ { // never called return( 0 ); diff --git a/bld/trap/lcl/linux/c/lnxacc.c b/bld/trap/lcl/linux/c/lnxacc.c index f52deff48a..09577816bd 100644 --- a/bld/trap/lcl/linux/c/lnxacc.c +++ b/bld/trap/lcl/linux/c/lnxacc.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -628,7 +628,7 @@ trap_retval TRAP_CORE( Redirect_stdout )( void ) return( sizeof( *ret ) ); } -trap_retval TRAP_FILE( string_to_fullpath )( void ) +trap_retval TRAP_FILE( file_to_fullpath )( void ) { file_string_to_fullpath_req *acc; file_string_to_fullpath_ret *ret; diff --git a/bld/trap/lcl/linux/c/lnxcore.c b/bld/trap/lcl/linux/c/lnxcore.c index d59fcbd92d..dd1fc03a9e 100644 --- a/bld/trap/lcl/linux/c/lnxcore.c +++ b/bld/trap/lcl/linux/c/lnxcore.c @@ -568,7 +568,7 @@ trap_retval TRAP_CORE( Redirect_stdout )( void ) return( TRAP_CORE( Redirect_stdin )() ); } -trap_retval TRAP_FILE( string_to_fullpath )( void ) +trap_retval TRAP_FILE( file_to_fullpath )( void ) { unsigned_16 len; char *name; diff --git a/bld/trap/lcl/msj/c/acclcl.c b/bld/trap/lcl/msj/c/acclcl.c index 2da056071a..a9ce3f36b3 100644 --- a/bld/trap/lcl/msj/c/acclcl.c +++ b/bld/trap/lcl/msj/c/acclcl.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -251,7 +251,7 @@ trap_retval TRAP_FILE( run_cmd )( void ) return( sizeof( *ret ) ); } -trap_retval TRAP_FILE( string_to_fullpath )( void ) +trap_retval TRAP_FILE( file_to_fullpath )( void ) { file_string_to_fullpath_req *acc; file_string_to_fullpath_ret *ret; diff --git a/bld/trap/lcl/nlm/c/nlmfile.c b/bld/trap/lcl/nlm/c/nlmfile.c index 73ec1735f0..5d6ac5e063 100644 --- a/bld/trap/lcl/nlm/c/nlmfile.c +++ b/bld/trap/lcl/nlm/c/nlmfile.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -182,7 +182,7 @@ trap_retval TRAP_FILE( read )( void ) return( sizeof( *ret ) + retval ); } -trap_retval TRAP_FILE( string_to_fullpath )( void ) +trap_retval TRAP_FILE( file_to_fullpath )( void ) { char *name; char *fullname; diff --git a/bld/trap/lcl/nt/c/accio.c b/bld/trap/lcl/nt/c/accio.c index 2bc81a3ec3..ed6817eaf2 100644 --- a/bld/trap/lcl/nt/c/accio.c +++ b/bld/trap/lcl/nt/c/accio.c @@ -261,7 +261,7 @@ trap_retval TRAP_FILE( run_cmd )( void ) return( sizeof( *ret ) ); } -trap_retval TRAP_FILE( string_to_fullpath )( void ) +trap_retval TRAP_FILE( file_to_fullpath )( void ) { file_string_to_fullpath_req *acc; file_string_to_fullpath_ret *ret; diff --git a/bld/trap/lcl/nto/c/ntoacc.c b/bld/trap/lcl/nto/c/ntoacc.c index 69949379bb..816868a914 100644 --- a/bld/trap/lcl/nto/c/ntoacc.c +++ b/bld/trap/lcl/nto/c/ntoacc.c @@ -1046,7 +1046,7 @@ trap_retval TRAP_CORE( Redirect_stdout )( void ) } -trap_retval TRAP_FILE( string_to_fullpath )( void ) +trap_retval TRAP_FILE( file_to_fullpath )( void ) { pid_t pid; int len; diff --git a/bld/trap/lcl/os2/c/accmisc.c b/bld/trap/lcl/os2/c/accmisc.c index 4719e26b6c..3b42ce11f8 100644 --- a/bld/trap/lcl/os2/c/accmisc.c +++ b/bld/trap/lcl/os2/c/accmisc.c @@ -536,7 +536,7 @@ trap_retval TRAP_FILE( run_cmd )( void ) } -trap_retval TRAP_FILE( string_to_fullpath )( void ) +trap_retval TRAP_FILE( file_to_fullpath )( void ) { char *name; char *fullname; diff --git a/bld/trap/lcl/os2v2/c/accmisc.c b/bld/trap/lcl/os2v2/c/accmisc.c index 24a6fa85b1..ccd1f32419 100644 --- a/bld/trap/lcl/os2v2/c/accmisc.c +++ b/bld/trap/lcl/os2v2/c/accmisc.c @@ -536,7 +536,7 @@ trap_retval TRAP_FILE( run_cmd )( void ) } -trap_retval TRAP_FILE( string_to_fullpath )( void ) +trap_retval TRAP_FILE( file_to_fullpath )( void ) { char *name; char *fullname; diff --git a/bld/trap/lcl/qnx/c/qnxacc.c b/bld/trap/lcl/qnx/c/qnxacc.c index 9c4f0687eb..c9cb1e71ba 100644 --- a/bld/trap/lcl/qnx/c/qnxacc.c +++ b/bld/trap/lcl/qnx/c/qnxacc.c @@ -874,9 +874,7 @@ trap_retval TRAP_CORE( Prog_load )( void ) ProcInfo.loaded_proc = false; } else { args[0] = name; - if( FindFilePath( DIG_FILETYPE_EXE, args[0], exe_name ) == 0 ) { - exe_name[0] = '\0'; - } + FindFilePath( DIG_FILETYPE_EXE, args[0], exe_name ); save_pgrp = getpgrp(); setpgid( 0, OrigPGrp ); ProcInfo.pid = qnx_spawn(0, 0, nid, -1, SCHED_OTHER, @@ -1454,7 +1452,7 @@ trap_retval TRAP_CORE( Redirect_stdout )( void ) } } -trap_retval TRAP_FILE( string_to_fullpath )( void ) +trap_retval TRAP_FILE( file_to_fullpath )( void ) { struct _psinfo proc; pid_t pid; diff --git a/bld/trap/lcl/qnx/c/qnxpmd.c b/bld/trap/lcl/qnx/c/qnxpmd.c index e52b4c41d7..db0db803fb 100644 --- a/bld/trap/lcl/qnx/c/qnxpmd.c +++ b/bld/trap/lcl/qnx/c/qnxpmd.c @@ -674,7 +674,7 @@ trap_retval TRAP_CORE( Redirect_stdout )( void ) return( TRAP_CORE( Redirect_stdin )() ); } -trap_retval TRAP_FILE( string_to_fullpath )( void ) +trap_retval TRAP_FILE( file_to_fullpath )( void ) { struct stat chk; unsigned_16 len; @@ -713,10 +713,8 @@ trap_retval TRAP_FILE( string_to_fullpath )( void ) } PmdInfo.fd = save_handle; } - if( len == 0 ) { + if( len == 0 ) ret->err = ENOENT; /* File not found */ - return( sizeof( *ret ) + 1 ); - } return( sizeof( *ret ) + len + 1 ); } diff --git a/bld/trap/lcl/rdos/c/accio.c b/bld/trap/lcl/rdos/c/accio.c index c6f2903356..dcccfb8456 100644 --- a/bld/trap/lcl/rdos/c/accio.c +++ b/bld/trap/lcl/rdos/c/accio.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -201,7 +201,7 @@ trap_retval TRAP_FILE( run_cmd )( void ) return( sizeof( *ret ) ); } -trap_retval TRAP_FILE( string_to_fullpath )( void ) +trap_retval TRAP_FILE( file_to_fullpath )( void ) { file_string_to_fullpath_req *acc; file_string_to_fullpath_ret *ret; diff --git a/bld/trap/lcl/win/c/winfile.c b/bld/trap/lcl/win/c/winfile.c index 97babccdd9..0b0a8b5cfe 100644 --- a/bld/trap/lcl/win/c/winfile.c +++ b/bld/trap/lcl/win/c/winfile.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -185,7 +185,7 @@ trap_retval TRAP_FILE( erase )( void ) } -trap_retval TRAP_FILE( string_to_fullpath )( void ) +trap_retval TRAP_FILE( file_to_fullpath )( void ) { char *name; char *fullname; From 9f804f9e8e52e91e46ead037b59b86eb4db22df4 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Tue, 29 Aug 2023 01:20:19 +0200 Subject: [PATCH 053/258] cleanup debugger code --- bld/wv/c/dbgfile.c | 88 +++++++++++++++++++++++----------------------- bld/wv/h/dbgio.h | 12 +++---- 2 files changed, 50 insertions(+), 50 deletions(-) diff --git a/bld/wv/c/dbgfile.c b/bld/wv/c/dbgfile.c index 1b9204f5b7..de5c211a55 100644 --- a/bld/wv/c/dbgfile.c +++ b/bld/wv/c/dbgfile.c @@ -399,23 +399,23 @@ const char *ExtPointer( char const *path, obj_attrs oattrs ) } -size_t MakeFileName( char *result, const char *name, const char *ext, obj_attrs oattrs ) +size_t MakeFileName( char *filename, const char *base_name, const char *ext, obj_attrs oattrs ) { const file_components *info; char *p; - p = StrCopyDst( name, result ); - if( *ExtPointer( result, oattrs ) == NULLCHAR ) { - info = PathInfo( name, oattrs ); + p = StrCopyDst( base_name, filename ); + if( *ExtPointer( filename, oattrs ) == NULLCHAR ) { + info = PathInfo( base_name, oattrs ); *p++ = info->ext_separator; p = StrCopyDst( ext, p ); } - return( p - result ); + return( p - filename ); } static size_t MakeNameWithPath( obj_attrs oattrs, - const char *path, size_t plen, - const char *name, size_t nlen, char *res ) + const char *path, size_t path_len, + const char *name, size_t name_len, char *res ) { const file_components *info; char *p; @@ -431,39 +431,39 @@ static size_t MakeNameWithPath( obj_attrs oattrs, oattrs = DefaultLoc( oattrs ); } if( path != NULL ) { - strncpy( p, path, plen ); - p += plen; + strncpy( p, path, path_len ); + p += path_len; if( oattrs & OP_LOCAL ) { info = &LclFile; } else { info = &RemFile; } - if( plen > 0 && !CHK_PATH_SEP( p[-1], &LclFile ) ) { + if( path_len > 0 && !CHK_PATH_SEP( p[-1], &LclFile ) ) { *p++ = info->path_separator[0]; } } - strncpy( p, name, nlen ); - p += nlen; + strncpy( p, name, name_len ); + p += name_len; *p = NULLCHAR; return( p - res ); } -file_handle LclFileToFullName( const char *name, size_t len, char *full ) +file_handle LclFileToFullName( const char *name, size_t name_len, char *full ) { char_ring *curr; file_handle fh; - size_t plen; + size_t path_len; // check open file in current directory or in full path - MakeNameWithPath( OP_LOCAL, NULL, 0, name, len, full ); + MakeNameWithPath( OP_LOCAL, NULL, 0, name, name_len, full ); fh = FileOpen( full, OP_READ ); if( fh != NIL_HANDLE ) return( fh ); // check open file in debugger directory list for( curr = LclPath; curr != NULL; curr = curr->next ) { - plen = strlen( curr->name ); - MakeNameWithPath( OP_LOCAL, curr->name, plen, name, len, full ); + path_len = strlen( curr->name ); + MakeNameWithPath( OP_LOCAL, curr->name, path_len, name, name_len, full ); fh = FileOpen( full, OP_READ ); if( fh != NIL_HANDLE ) { return( fh ); @@ -476,10 +476,10 @@ file_handle LclFileToFullName( const char *name, size_t len, char *full ) /* * */ -static file_handle FullPathOpenInternal( const char *name, size_t name_len, const char *defext, - char *result, size_t result_len, bool force_local ) +static file_handle FullPathOpenInternal( const char *name, size_t name_len, + const char *defext, char *filename, size_t filename_len, bool force_local ) { - char buffer[TXT_LEN]; + char fname[TXT_LEN]; char *p; const char *p1; obj_attrs oattrs; @@ -504,7 +504,7 @@ static file_handle FullPathOpenInternal( const char *name, size_t name_len, cons } else { file = &RemFile; } - p = buffer; + p = fname; while( name_len-- > 0 ) { c = *name++; *p++ = c; @@ -521,41 +521,41 @@ static file_handle FullPathOpenInternal( const char *name, size_t name_len, cons } *p = NULLCHAR; if( oattrs & OP_REMOTE ) { - RemoteFileToFullName( DIG_FILETYPE_PRS, buffer, result, (trap_elen)result_len ); - fh = FileOpen( result, OP_READ | OP_REMOTE ); + RemoteFileToFullName( DIG_FILETYPE_PRS, fname, filename, (trap_elen)filename_len ); + fh = FileOpen( filename, OP_READ | OP_REMOTE ); } else if( has_path ) { - StrCopyDst( buffer, result ); - fh = FileOpen( buffer, OP_READ ); + StrCopyDst( fname, filename ); + fh = FileOpen( fname, OP_READ ); } else { - fh = LclFileToFullName( buffer, p - buffer, result ); + fh = LclFileToFullName( fname, p - fname, filename ); } if( fh == NIL_HANDLE ) { - strcpy( result, buffer ); + strcpy( filename, fname ); } else { - p1 = RealFName( result, &oattrs ); - memmove( result, p1, strlen( p1 ) + 1 ); + p1 = RealFName( filename, &oattrs ); + memmove( filename, p1, strlen( p1 ) + 1 ); } return( fh ); } -file_handle FullPathOpen( const char *name, size_t name_len, const char *defext, char *result, size_t result_len ) +file_handle FullPathOpen( const char *name, size_t name_len, const char *defext, char *filename, size_t filename_len ) { - return( FullPathOpenInternal( name, name_len, defext, result, result_len, false ) ); + return( FullPathOpenInternal( name, name_len, defext, filename, filename_len, false ) ); } -file_handle LocalFullPathOpen( const char *name, size_t name_len, const char *defext, char *result, size_t result_len ) +file_handle LocalFullPathOpen( const char *name, size_t name_len, const char *defext, char *filename, size_t filename_len ) { - return( FullPathOpenInternal( name, name_len, defext, result, result_len, true ) ); + return( FullPathOpenInternal( name, name_len, defext, filename, filename_len, true ) ); } static file_handle PathOpenInternal( const char *name, size_t name_len, const char *defext, bool force_local ) { - char result[TXT_LEN]; + char filename[TXT_LEN]; if( force_local ) { - return( LocalFullPathOpen( name, name_len, defext, result, TXT_LEN ) ); + return( LocalFullPathOpen( name, name_len, defext, filename, sizeof( filename ) ) ); } else { - return( FullPathOpen( name, name_len, defext, result, TXT_LEN ) ); + return( FullPathOpen( name, name_len, defext, filename, sizeof( filename ) ) ); } } @@ -595,9 +595,9 @@ static bool IsWritable( char const *name, obj_attrs oattrs ) bool FindWritable( char const *src, char *dst ) { - char buffer[TXT_LEN]; - size_t plen; - size_t nlen; + char path[TXT_LEN]; + size_t path_len; + size_t name_len; const char *name; obj_attrs oattrs; @@ -608,17 +608,17 @@ bool FindWritable( char const *src, char *dst ) return( true ); } name = SkipPathInfo( src, oattrs ); - nlen = strlen( name ); + name_len = strlen( name ); if( DefaultLoc( oattrs ) & OP_LOCAL ) { - plen = DUIEnvLkup( "HOME", buffer, sizeof( buffer ) ); - if( plen > 0 ) { - MakeNameWithPath( oattrs, buffer, plen, name, nlen, dst ); + path_len = DUIEnvLkup( "HOME", path, sizeof( path ) ); + if( path_len > 0 ) { + MakeNameWithPath( oattrs, path, path_len, name, name_len, dst ); if( IsWritable( dst, oattrs ) ) { return( true ); } } } - MakeNameWithPath( oattrs, NULL, 0, name, nlen, dst ); + MakeNameWithPath( oattrs, NULL, 0, name, name_len, dst ); return( IsWritable( dst, oattrs ) ); } #endif diff --git a/bld/wv/h/dbgio.h b/bld/wv/h/dbgio.h index 904886cafe..ad924d317b 100644 --- a/bld/wv/h/dbgio.h +++ b/bld/wv/h/dbgio.h @@ -84,15 +84,15 @@ extern sys_error GetSystemErrCode( error_handle ); extern const char *SkipPathInfo( char const *, obj_attrs ); extern const char *ExtPointer( char const *, obj_attrs ); extern char *AppendPathDelim( char *path, obj_attrs oattrs ); -extern size_t MakeFileName( char *result, const char *name, const char *ext, obj_attrs oattrs ); +extern size_t MakeFileName( char *filename, const char *base_name, const char *defext, obj_attrs oattrs ); extern const char *RealFName( char const *name, obj_attrs *oattrs ); extern bool IsAbsolutePath( const char *path ); extern const char *ExtPointer( char const *path, obj_attrs oattrs ); -extern file_handle LclFileToFullName( const char *name, size_t len, char *full ); -extern file_handle FullPathOpen( const char *name, size_t name_len, const char *ext, char *result, size_t max_result ); -extern file_handle LocalFullPathOpen( const char *name, size_t name_len, const char *ext, char *result, size_t max_result ); -extern file_handle PathOpen( const char *name, size_t name_len, const char *ext ); -extern file_handle LocalPathOpen( const char *name, size_t name_len, const char *ext ); +extern file_handle LclFileToFullName( const char *name, size_t name_len, char *full ); +extern file_handle FullPathOpen( const char *name, size_t name_len, const char *defext, char *filename, size_t filename_len ); +extern file_handle LocalFullPathOpen( const char *name, size_t name_len, const char *defext, char *filename, size_t filename_len ); +extern file_handle PathOpen( const char *name, size_t name_len, const char *defext ); +extern file_handle LocalPathOpen( const char *name, size_t name_len, const char *defext ); #if !defined( BUILD_RFX ) extern bool FindWritable( char const *src, char *dst ); From c2b89b4f174b326936150e28a63197017876b766 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Tue, 29 Aug 2023 02:55:14 +0200 Subject: [PATCH 054/258] rework trap FindFilePath function to return same value for all platform --- bld/trap/common/dos/dospath.c | 53 +++++++++++------------ bld/trap/common/dos/dospath.h | 13 +++--- bld/trap/common/linux/lnxpath.c | 18 ++++---- bld/trap/common/linux/lnxpath.h | 5 +-- bld/trap/common/nt/ntpath.c | 67 +++++++++++++++--------------- bld/trap/common/nt/ntpath.h | 9 ++-- bld/trap/common/nto/ntopath.c | 16 +++---- bld/trap/common/nto/ntopath.h | 5 +-- bld/trap/common/os2/os2digl.c | 1 + bld/trap/common/os2/os2path.c | 55 ++++++++++++------------ bld/trap/common/os2/os2path.h | 9 ++-- bld/trap/common/os2v2/os22path.c | 55 ++++++++++++------------ bld/trap/common/os2v2/os22path.h | 9 ++-- bld/trap/common/win/winpath.c | 53 +++++++++++------------ bld/trap/common/win/winpath.h | 11 +++-- bld/trap/lcl/dos/c/dosfile.c | 9 ++-- bld/trap/lcl/dos/dosr/c/dosacc.c | 4 +- bld/trap/lcl/dos/dosx/c/dosxremo.c | 6 +-- bld/trap/lcl/elfcore/c/elfcore.c | 4 +- bld/trap/lcl/linux/c/lnxacc.c | 4 +- bld/trap/lcl/nt/c/accio.c | 6 +-- bld/trap/lcl/nt/c/accload.c | 5 ++- bld/trap/lcl/nto/c/ntoacc.c | 4 +- bld/trap/lcl/os2/c/accmisc.c | 6 +-- bld/trap/lcl/os2/c/os2conv.c | 4 +- bld/trap/lcl/os2/c/os2v1acc.c | 4 +- bld/trap/lcl/os2/c/os2v2acc.c | 4 +- bld/trap/lcl/os2v2/c/accmisc.c | 7 ++-- bld/trap/lcl/os2v2/c/os2v2acc.c | 4 +- bld/trap/lcl/win/c/accload.c | 6 +-- bld/trap/lcl/win/c/winfile.c | 9 ++-- 31 files changed, 217 insertions(+), 248 deletions(-) diff --git a/bld/trap/common/dos/dospath.c b/bld/trap/common/dos/dospath.c index 97e450b30b..19b8b22e70 100644 --- a/bld/trap/common/dos/dospath.c +++ b/bld/trap/common/dos/dospath.c @@ -32,6 +32,7 @@ #include +#include #include #include "tinyio.h" #include "digtypes.h" @@ -87,7 +88,7 @@ const char __far *DOSEnvFind( const char *src ) } #endif -tiny_ret_t TryPath( const char *name, char *end, const char *ext_list ) +static bool tryPath( const char *name, char *end, const char *ext_list ) { tiny_ret_t rc; int mode; @@ -98,18 +99,17 @@ tiny_ret_t TryPath( const char *name, char *end, const char *ext_list ) rc = TinyOpen( name, mode ); if( TINY_OK( rc ) ) { TinyClose( TINY_INFO( rc ) ); - return( rc ); + return( true ); } } while( *ext_list != '\0' ); - return( rc ); + return( false ); } -unsigned long FindFilePath( dig_filetype file_type, const char *pgm, char *buffer ) +size_t FindFilePath( dig_filetype file_type, const char *pgm, char *buffer ) { const char __far *path; char *p2; const char *p3; - tiny_ret_t rc; bool has_ext; bool has_path; const char *ext_list; @@ -141,27 +141,28 @@ unsigned long FindFilePath( dig_filetype file_type, const char *pgm, char *buffe ext_list = ".com\0.exe\0"; #endif } - rc = TryPath( buffer, p2, ext_list ); - if( TINY_OK( rc ) || has_path ) - return( rc ); - path = DOSEnvFind( "PATH" ); - if( path == NULL ) - return( rc ); - for( ; *path != '\0'; path++ ) { - p2 = buffer; - while( *path != '\0' && *path != ';' ) { - *p2++ = *path++; - } - if( p2 != buffer && p2[-1] != '\\' && p2[-1] != '/' ) { - *p2++ = '\\'; - } - p2 = StrCopyDst( pgm, p2 ); - rc = TryPath( buffer, p2, ext_list ); - if( TINY_OK( rc ) ) - break; - if( *path == '\0' ) { - break; + if( tryPath( buffer, p2, ext_list ) ) + return( strlen( buffer ) ); + if( !has_path ) { + path = DOSEnvFind( "PATH" ); + if( path != NULL ) { + for( ; *path != '\0'; path++ ) { + p2 = buffer; + while( *path != '\0' && *path != ';' ) { + *p2++ = *path++; + } + if( p2 != buffer && p2[-1] != '\\' && p2[-1] != '/' ) { + *p2++ = '\\'; + } + p2 = StrCopyDst( pgm, p2 ); + if( tryPath( buffer, p2, ext_list ) ) + return( strlen( buffer ) ); + if( *path == '\0' ) { + break; + } + } } } - return( rc ); + *buffer = '\0'; + return( 0 ); } diff --git a/bld/trap/common/dos/dospath.h b/bld/trap/common/dos/dospath.h index 0e8ec7a9d4..ba0551ce9b 100644 --- a/bld/trap/common/dos/dospath.h +++ b/bld/trap/common/dos/dospath.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -31,12 +31,11 @@ ****************************************************************************/ -extern char *StrCopyDst( const char *src, char *dst ); -extern const char *StrCopySrc( const char *src, char *dst ); +extern char *StrCopyDst( const char *src, char *dst ); +extern const char *StrCopySrc( const char *src, char *dst ); #if defined( SERVER ) -extern const char *DOSEnvFind( const char *src ); +extern const char *DOSEnvFind( const char *src ); #else -extern const char __far *DOSEnvFind( const char *src ); +extern const char __far *DOSEnvFind( const char *src ); #endif -extern tiny_ret_t TryPath( const char *name, char *end, const char *ext_list ); -extern unsigned long FindFilePath( dig_filetype file_type, const char *pgm, char *buffer ); +extern size_t FindFilePath( dig_filetype file_type, const char *pgm, char *buffer ); diff --git a/bld/trap/common/linux/lnxpath.c b/bld/trap/common/linux/lnxpath.c index c62d2adbab..5bdc816b11 100644 --- a/bld/trap/common/linux/lnxpath.c +++ b/bld/trap/common/linux/lnxpath.c @@ -47,7 +47,7 @@ char *StrCopyDst( const char *src, char *dst ) return( dst ); } -unsigned TryOnePath( const char *path, struct stat *tmp, const char *name, char *result ) +static size_t tryOnePath( const char *path, struct stat *tmp, const char *name, char *result ) { char *ptr; @@ -88,10 +88,10 @@ unsigned TryOnePath( const char *path, struct stat *tmp, const char *name, char return( 0 ); } -unsigned FindFilePath( dig_filetype file_type, const char *name, char *result ) +size_t FindFilePath( dig_filetype file_type, const char *name, char *result ) { struct stat tmp; - unsigned len; + size_t len; #if defined( SERVER ) char *end; char cmd[256]; @@ -101,12 +101,12 @@ unsigned FindFilePath( dig_filetype file_type, const char *name, char *result ) return( StrCopyDst( name, result ) - result ); } if( file_type == DIG_FILETYPE_EXE ) { - return( TryOnePath( getenv( "PATH" ), &tmp, name, result ) ); + return( tryOnePath( getenv( "PATH" ), &tmp, name, result ) ); } else { - len = TryOnePath( getenv( "WD_PATH" ), &tmp, name, result ); + len = tryOnePath( getenv( "WD_PATH" ), &tmp, name, result ); if( len != 0 ) return( len ); - len = TryOnePath( getenv( "HOME" ), &tmp, name, result ); + len = tryOnePath( getenv( "HOME" ), &tmp, name, result ); if( len != 0 ) return( len ); #if defined( SERVER ) @@ -115,7 +115,7 @@ unsigned FindFilePath( dig_filetype file_type, const char *name, char *result ) if( end != NULL ) { *end = '\0'; /* look in the executable's directory */ - len = TryOnePath( cmd, &tmp, name, result ); + len = tryOnePath( cmd, &tmp, name, result ); if( len != 0 ) return( len ); end = strrchr( cmd, '/' ); @@ -123,7 +123,7 @@ unsigned FindFilePath( dig_filetype file_type, const char *name, char *result ) /* look in the wd sibling directory of where the command came from */ StrCopyDst( "wd", end + 1 ); - len = TryOnePath( cmd, &tmp, name, result ); + len = tryOnePath( cmd, &tmp, name, result ); if( len != 0 ) { return( len ); } @@ -131,6 +131,6 @@ unsigned FindFilePath( dig_filetype file_type, const char *name, char *result ) } } #endif - return( TryOnePath( "/opt/watcom/wd", &tmp, name, result ) ); + return( tryOnePath( "/opt/watcom/wd", &tmp, name, result ) ); } } diff --git a/bld/trap/common/linux/lnxpath.h b/bld/trap/common/linux/lnxpath.h index 4e34dc3c2a..3ea5a389ea 100644 --- a/bld/trap/common/linux/lnxpath.h +++ b/bld/trap/common/linux/lnxpath.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -32,5 +32,4 @@ extern char *StrCopyDst( const char *src, char *dst ); -extern unsigned TryOnePath( const char *, struct stat *, const char *, char * ); -extern unsigned FindFilePath( dig_filetype, const char *, char * ); +extern size_t FindFilePath( dig_filetype, const char *, char * ); diff --git a/bld/trap/common/nt/ntpath.c b/bld/trap/common/nt/ntpath.c index bad10441de..51e5bfc57d 100644 --- a/bld/trap/common/nt/ntpath.c +++ b/bld/trap/common/nt/ntpath.c @@ -52,7 +52,7 @@ const char *StrCopySrc( const char *src, char *dst ) return( src ); } -int tryPath( const char *name, char *end, const char *ext_list ) +static bool tryPath( const char *name, char *end, const char *ext_list ) { HANDLE h; @@ -61,13 +61,13 @@ int tryPath( const char *name, char *end, const char *ext_list ) h = CreateFile( name, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL ); if( h != INVALID_HANDLE_VALUE ) { CloseHandle( h ); - return( 0 ); + return( true ); } } while( *ext_list != '\0' ); - return( -1 ); + return( false ); } -unsigned long FindFilePath( dig_filetype file_type, const char *pgm, char *buffer ) +size_t FindFilePath( dig_filetype file_type, const char *pgm, char *buffer ) { const char *p; char *p2; @@ -75,7 +75,6 @@ unsigned long FindFilePath( dig_filetype file_type, const char *pgm, char *buffe bool has_path; char *envbuf; DWORD envlen; - unsigned long rc; const char *ext_list; has_ext = false; @@ -97,35 +96,35 @@ unsigned long FindFilePath( dig_filetype file_type, const char *pgm, char *buffe if( !has_ext && file_type == DIG_FILETYPE_EXE ) { ext_list = ".com\0.exe\0"; } - if( !tryPath( buffer, p2, ext_list ) ) { - return( 0 ); - } - if( has_path ) { - return( ERROR_FILE_NOT_FOUND ); - } - envlen = GetEnvironmentVariable( "PATH", NULL, 0 ); - if( envlen == 0 ) - return( GetLastError() ); - envbuf = LocalAlloc( LMEM_FIXED, envlen ); - GetEnvironmentVariable( "PATH", envbuf, envlen ); - rc = ERROR_FILE_NOT_FOUND; - for( p = envbuf; *p != '\0'; ++p ) { - p2 = buffer; - while( *p != '\0' && *p != ';' ) { - *p2++ = *p++; - } - if( p2 != buffer && p2[-1] != '\\' && p2[-1] != '/' ) { - *p2++ = '\\'; - } - p2 = StrCopyDst( pgm, p2 ); - if( !tryPath( buffer, p2, ext_list ) ) { - rc = 0; - break; - } - if( *p == '\0' ) { - break; + if( tryPath( buffer, p2, ext_list ) ) + return( strlen( buffer ) ); + if( !has_path ) { + envlen = GetEnvironmentVariable( "PATH", NULL, 0 ); + if( envlen != 0 ) { + envbuf = LocalAlloc( LMEM_FIXED, envlen ); + if( envbuf != NULL ) { + GetEnvironmentVariable( "PATH", envbuf, envlen ); + for( p = envbuf; *p != '\0'; ++p ) { + p2 = buffer; + while( *p != '\0' && *p != ';' ) { + *p2++ = *p++; + } + if( p2 != buffer && p2[-1] != '\\' && p2[-1] != '/' ) { + *p2++ = '\\'; + } + p2 = StrCopyDst( pgm, p2 ); + if( tryPath( buffer, p2, ext_list ) ) { + LocalFree( envbuf ); + return( strlen( buffer ) ); + } + if( *p == '\0' ) { + break; + } + } + LocalFree( envbuf ); + } } } - LocalFree( envbuf ); - return( rc ); + *buffer = '\0'; + return( 0 ); } diff --git a/bld/trap/common/nt/ntpath.h b/bld/trap/common/nt/ntpath.h index 929f0415c1..4d48ed853a 100644 --- a/bld/trap/common/nt/ntpath.h +++ b/bld/trap/common/nt/ntpath.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -31,7 +31,6 @@ ****************************************************************************/ -extern char *StrCopyDst( const char *src, char *dst ); -extern const char *StrCopySrc( const char *src, char *dst ); -extern int tryPath( const char *name, char *end, const char *ext_list ); -extern unsigned long FindFilePath( dig_filetype file_type, const char *pgm, char *buffer ); +extern char *StrCopyDst( const char *src, char *dst ); +extern const char *StrCopySrc( const char *src, char *dst ); +extern size_t FindFilePath( dig_filetype file_type, const char *pgm, char *buffer ); diff --git a/bld/trap/common/nto/ntopath.c b/bld/trap/common/nto/ntopath.c index c25b0116f8..e5a4e0eb34 100644 --- a/bld/trap/common/nto/ntopath.c +++ b/bld/trap/common/nto/ntopath.c @@ -48,7 +48,7 @@ char *StrCopyDst( const char *src, char *dst ) return( dst ); } -unsigned TryOnePath( const char *path, struct stat *tmp, const char *name, char *result ) +static size_t tryOnePath( const char *path, struct stat *tmp, const char *name, char *result ) { char *ptr; @@ -89,10 +89,10 @@ unsigned TryOnePath( const char *path, struct stat *tmp, const char *name, char return( 0 ); } -unsigned FindFilePath( dig_filetype file_type, const char *name, char *result ) +size_t FindFilePath( dig_filetype file_type, const char *name, char *result ) { struct stat tmp; - unsigned len; + size_t len; #if defined( SERVER ) char *end; char cmd[256]; @@ -102,12 +102,12 @@ unsigned FindFilePath( dig_filetype file_type, const char *name, char *result ) return( StrCopyDst( name, result ) - result ); } if( file_type == DIG_FILETYPE_EXE ) { - return( TryOnePath( getenv( "PATH" ), &tmp, name, result ) ); + return( tryOnePath( getenv( "PATH" ), &tmp, name, result ) ); } else { - len = TryOnePath( getenv( "WD_PATH" ), &tmp, name, result ); + len = tryOnePath( getenv( "WD_PATH" ), &tmp, name, result ); if( len != 0 ) return( len ); - len = TryOnePath( getenv( "HOME" ), &tmp, name, result ); + len = tryOnePath( getenv( "HOME" ), &tmp, name, result ); if( len != 0 ) return( len ); #if defined( SERVER ) @@ -120,7 +120,7 @@ unsigned FindFilePath( dig_filetype file_type, const char *name, char *result ) /* look in the wd sibling directory of where the command came from */ StrCopyDst( "wd", end + 1 ); - len = TryOnePath( cmd, &tmp, name, result ); + len = tryOnePath( cmd, &tmp, name, result ); if( len != 0 ) { return( len ); } @@ -128,6 +128,6 @@ unsigned FindFilePath( dig_filetype file_type, const char *name, char *result ) } } #endif - return( TryOnePath( "/usr/watcom/wd", &tmp, name, result ) ); + return( tryOnePath( "/usr/watcom/wd", &tmp, name, result ) ); } } diff --git a/bld/trap/common/nto/ntopath.h b/bld/trap/common/nto/ntopath.h index c3f01a21e8..01654eb4ea 100644 --- a/bld/trap/common/nto/ntopath.h +++ b/bld/trap/common/nto/ntopath.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -32,5 +32,4 @@ extern char *StrCopyDst( const char *, char * ); -extern unsigned TryOnePath( const char *, struct stat *, const char *, char * ); -extern unsigned FindFilePath( dig_filetype, const char *, char * ); +extern size_t FindFilePath( dig_filetype, const char *, char * ); diff --git a/bld/trap/common/os2/os2digl.c b/bld/trap/common/os2/os2digl.c index 92f25cc265..554eb366a4 100644 --- a/bld/trap/common/os2/os2digl.c +++ b/bld/trap/common/os2/os2digl.c @@ -34,6 +34,7 @@ #include #include #include "digld.h" +#include "os2path.h" #include "servio.h" diff --git a/bld/trap/common/os2/os2path.c b/bld/trap/common/os2/os2path.c index 0efcbdfba7..6d0a3b1c85 100644 --- a/bld/trap/common/os2/os2path.c +++ b/bld/trap/common/os2/os2path.c @@ -31,6 +31,7 @@ ****************************************************************************/ +#include #define INCL_DOSMISC #include #include "digtypes.h" @@ -53,9 +54,8 @@ const char *StrCopySrc( const char *src, char *dst ) return( src ); } -long TryPath( const char *name, char *end, const char *ext_list ) +static bool tryPath( const char *name, char *end, const char *ext_list ) { - long rc; static struct { FILEFINDBUF d; char name[256]; @@ -66,19 +66,17 @@ long TryPath( const char *name, char *end, const char *ext_list ) do { ext_list = StrCopySrc( ext_list, end ) + 1; count = 1; - rc = DosFindFirst( (PSZ)name, &hdl, 0, &info.d, sizeof( info ), &count, 0 ); - if( rc == 0 ) { - return( 0 ); + if( DosFindFirst( (PSZ)name, &hdl, 0, &info.d, sizeof( info ), &count, 0 ) == 0 ) { + return( true ); } } while( *ext_list != '\0' ); - return( 0xffff0000 | rc ); + return( false ); } -unsigned long FindFilePath( dig_filetype file_type, const char *pgm, char *buffer ) +size_t FindFilePath( dig_filetype file_type, const char *pgm, char *buffer ) { const char *p; char *p2; - unsigned long rc; bool has_ext; bool has_path; const char *ext_list; @@ -102,26 +100,27 @@ unsigned long FindFilePath( dig_filetype file_type, const char *pgm, char *buffe if( !has_ext && file_type == DIG_FILETYPE_EXE ) { ext_list = ".exe\0"; } - rc = TryPath( buffer, p2, ext_list ); - if( rc == 0 || has_path ) - return( rc ); - if( DosScanEnv( "PATH", (PSZ FAR *)&p ) != 0 ) - return( rc ); - for( ; *p != '\0'; p++ ) { - p2 = buffer; - while( *p != '\0' && *p != ';' ) { - *p2++ = *p++; - } - if( p2 != buffer && p2[-1] != '\\' && p2[-1] != '/' ) { - *p2++ = '\\'; - } - p2 = StrCopyDst( pgm, p2 ); - rc = TryPath( buffer, p2, ext_list ); - if( rc == 0 ) - break; - if( *p == '\0' ) { - break; + if( tryPath( buffer, p2, ext_list ) ) + return( strlen( buffer ) ); + if( !has_path ) { + if( DosScanEnv( "PATH", (PSZ FAR *)&p ) == 0 ) { + for( ; *p != '\0'; p++ ) { + p2 = buffer; + while( *p != '\0' && *p != ';' ) { + *p2++ = *p++; + } + if( p2 != buffer && p2[-1] != '\\' && p2[-1] != '/' ) { + *p2++ = '\\'; + } + p2 = StrCopyDst( pgm, p2 ); + if( tryPath( buffer, p2, ext_list ) ) + return( strlen( buffer ) ); + if( *p == '\0' ) { + break; + } + } } } - return( rc ); + *buffer = '\0'; + return( 0 ); } diff --git a/bld/trap/common/os2/os2path.h b/bld/trap/common/os2/os2path.h index e4bed5bdba..24561ba26c 100644 --- a/bld/trap/common/os2/os2path.h +++ b/bld/trap/common/os2/os2path.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -31,7 +31,6 @@ ****************************************************************************/ -extern char *StrCopyDst( const char *src, char *dst ); -extern const char *StrCopySrc( const char *src, char *dst ); -extern long TryPath( const char *name, char *end, const char *ext_list ); -extern unsigned long FindFilePath( dig_filetype file_type, const char *src, char *dst ); +extern char *StrCopyDst( const char *src, char *dst ); +extern const char *StrCopySrc( const char *src, char *dst ); +extern size_t FindFilePath( dig_filetype file_type, const char *src, char *dst ); diff --git a/bld/trap/common/os2v2/os22path.c b/bld/trap/common/os2v2/os22path.c index 8b7c64b487..8678fbd412 100644 --- a/bld/trap/common/os2v2/os22path.c +++ b/bld/trap/common/os2v2/os22path.c @@ -31,6 +31,7 @@ ****************************************************************************/ +#include #define INCL_DOSMISC #include #include "digtypes.h" @@ -53,9 +54,8 @@ const char *StrCopySrc( const char *src, char *dst ) return( src ); } -long TryPath( const char *name, char *end, const char *ext_list ) +static bool tryPath( const char *name, char *end, const char *ext_list ) { - long rc; FILEFINDBUF3 info; HDIR hdl = HDIR_SYSTEM; ULONG count = 1; @@ -63,19 +63,17 @@ long TryPath( const char *name, char *end, const char *ext_list ) do { ext_list = StrCopySrc( ext_list, end ) + 1; count = 1; - rc = DosFindFirst( name, &hdl, FILE_NORMAL, &info, sizeof( info ), &count, FIL_STANDARD ); - if( rc == 0 ) { - return( 0 ); + if( DosFindFirst( name, &hdl, FILE_NORMAL, &info, sizeof( info ), &count, FIL_STANDARD ) == 0 ) { + return( true ); } } while( *ext_list != '\0' ); - return( 0xffff0000 | rc ); + return( false ); } -unsigned long FindFilePath( dig_filetype file_type, const char *pgm, char *buffer ) +size_t FindFilePath( dig_filetype file_type, const char *pgm, char *buffer ) { const char *p; char *p2; - unsigned long rc; bool has_ext; bool has_path; const char *ext_list; @@ -99,26 +97,27 @@ unsigned long FindFilePath( dig_filetype file_type, const char *pgm, char *buffe if( !has_ext && file_type == DIG_FILETYPE_EXE ) { ext_list = ".exe\0"; } - rc = TryPath( buffer, p2, ext_list ); - if( rc == 0 || has_path ) - return( rc ); - if( DosScanEnv( "PATH", &p2 ) != 0 ) - return( rc ); - for( p = p2; *p != '\0'; p++ ) { - p2 = buffer; - while( *p != '\0' && *p != ';' ) { - *p2++ = *p++; - } - if( p2 != buffer && p2[-1] != '\\' && p2[-1] != '/' ) { - *p2++ = '\\'; - } - p2 = StrCopyDst( pgm, p2 ); - rc = TryPath( buffer, p2, ext_list ); - if( rc == 0 ) - break; - if( *p == '\0' ) { - break; + if( tryPath( buffer, p2, ext_list ) ) + return( strlen( buffer ) ); + if( !has_path ) { + if( DosScanEnv( "PATH", &p2 ) == 0 ) { + for( p = p2; *p != '\0'; p++ ) { + p2 = buffer; + while( *p != '\0' && *p != ';' ) { + *p2++ = *p++; + } + if( p2 != buffer && p2[-1] != '\\' && p2[-1] != '/' ) { + *p2++ = '\\'; + } + p2 = StrCopyDst( pgm, p2 ); + if( tryPath( buffer, p2, ext_list ) ) + return( strlen( buffer ) ); + if( *p == '\0' ) { + break; + } + } } } - return( rc ); + *buffer = '\0'; + return( 0 ); } diff --git a/bld/trap/common/os2v2/os22path.h b/bld/trap/common/os2v2/os22path.h index ddcc431e25..24561ba26c 100644 --- a/bld/trap/common/os2v2/os22path.h +++ b/bld/trap/common/os2v2/os22path.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -31,7 +31,6 @@ ****************************************************************************/ -extern char *StrCopyDst( const char *src, char *dst ); -extern const char *StrCopySrc( const char *src, char *dst ); -extern long TryPath( const char *name, char *end, const char *ext_list ); -extern unsigned long FindFilePath( dig_filetype file_type, const char *src, char *dst ); +extern char *StrCopyDst( const char *src, char *dst ); +extern const char *StrCopySrc( const char *src, char *dst ); +extern size_t FindFilePath( dig_filetype file_type, const char *src, char *dst ); diff --git a/bld/trap/common/win/winpath.c b/bld/trap/common/win/winpath.c index d7651f1c9f..a27094a50e 100644 --- a/bld/trap/common/win/winpath.c +++ b/bld/trap/common/win/winpath.c @@ -31,6 +31,7 @@ ****************************************************************************/ +#include #include #include "digtypes.h" #include "winpath.h" @@ -72,7 +73,7 @@ const char *DOSEnvFind( const char *src ) return( NULL ); } -tiny_ret_t TryPath( const char *name, char *end, const char *ext_list ) +static bool tryPath( const char *name, char *end, const char *ext_list ) { tiny_ret_t rc; int mode; @@ -83,18 +84,17 @@ tiny_ret_t TryPath( const char *name, char *end, const char *ext_list ) rc = TinyOpen( name, mode ); if( TINY_OK( rc ) ) { TinyClose( TINY_INFO( rc ) ); - return( rc ); + return( true ); } } while( *ext_list != '\0' ); - return( rc ); + return( false ); } -unsigned long FindFilePath( dig_filetype file_type, const char *pgm, char *buffer ) +size_t FindFilePath( dig_filetype file_type, const char *pgm, char *buffer ) { const char __far *path; char *p2; const char *p3; - tiny_ret_t rc; bool has_ext; bool has_path; const char *ext_list; @@ -118,27 +118,28 @@ unsigned long FindFilePath( dig_filetype file_type, const char *pgm, char *buffe if( !has_ext && file_type == DIG_FILETYPE_EXE ) { ext_list = ".com\0.exe\0"; } - rc = TryPath( buffer, p2, ext_list ); - if( TINY_OK( rc ) || has_path ) - return( rc ); - path = DOSEnvFind( "PATH" ); - if( path == NULL ) - return( rc ); - for( ; *path != '\0'; path++ ) { - p2 = buffer; - while( *path != '\0' && *path != ';' ) { - *p2++ = *path++; - } - if( p2 != buffer && p2[-1] != '\\' && p2[-1] != '/' ) { - *p2++ = '\\'; - } - p2 = StrCopyDst( pgm, p2 ); - rc = TryPath( buffer, p2, ext_list ); - if( TINY_OK( rc ) ) - break; - if( *path == '\0' ) { - break; + if( tryPath( buffer, p2, ext_list ) ) + return( strlen( buffer ) ); + if( !has_path ) { + path = DOSEnvFind( "PATH" ); + if( path != NULL ) { + for( ; *path != '\0'; path++ ) { + p2 = buffer; + while( *path != '\0' && *path != ';' ) { + *p2++ = *path++; + } + if( p2 != buffer && p2[-1] != '\\' && p2[-1] != '/' ) { + *p2++ = '\\'; + } + p2 = StrCopyDst( pgm, p2 ); + if( tryPath( buffer, p2, ext_list ) ) + return( strlen( buffer ) ); + if( *path == '\0' ) { + break; + } + } } } - return( rc ); + *buffer = '\0'; + return( 0 ); } diff --git a/bld/trap/common/win/winpath.h b/bld/trap/common/win/winpath.h index f630567cde..d5abdedc51 100644 --- a/bld/trap/common/win/winpath.h +++ b/bld/trap/common/win/winpath.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -34,8 +34,7 @@ #include "tinyio.h" -extern char *StrCopyDst( const char *src, char *dst ); -extern const char *StrCopySrc( const char *src, char *dst ); -extern const char *DOSEnvFind( const char *src ); -extern tiny_ret_t TryPath( const char *name, char *end, const char *ext_list ); -extern unsigned long FindFilePath( dig_filetype file_type, const char *pgm, char *buffer ); +extern char *StrCopyDst( const char *src, char *dst ); +extern const char *StrCopySrc( const char *src, char *dst ); +extern const char *DOSEnvFind( const char *src ); +extern size_t FindFilePath( dig_filetype file_type, const char *pgm, char *buffer ); diff --git a/bld/trap/lcl/dos/c/dosfile.c b/bld/trap/lcl/dos/c/dosfile.c index 34c1a74d83..9e4163f694 100644 --- a/bld/trap/lcl/dos/c/dosfile.c +++ b/bld/trap/lcl/dos/c/dosfile.c @@ -33,6 +33,7 @@ #include #include #include +#include #include "tinyio.h" #include "dosver.h" #include "trpimp.h" @@ -195,18 +196,14 @@ trap_retval TRAP_FILE( file_to_fullpath )( void ) char *fullname; file_string_to_fullpath_req *acc; file_string_to_fullpath_ret *ret; - tiny_ret_t rc; acc = GetInPtr( 0 ); name = GetInPtr( sizeof( *acc ) ); ret = GetOutPtr( 0 ); ret->err = 0; fullname = GetOutPtr( sizeof( *ret ) ); - rc = FindFilePath( acc->file_type, name, fullname ); - if( TINY_ERROR( rc ) ) { - ret->err = TINY_INFO( rc ); - *fullname = '\0'; - return( sizeof( *ret ) + 1 ); + if( FindFilePath( acc->file_type, name, fullname ) == 0 ) { + ret->err = ENOENT; } return( sizeof( *ret ) + 1 + strlen( fullname ) ); } diff --git a/bld/trap/lcl/dos/dosr/c/dosacc.c b/bld/trap/lcl/dos/dosr/c/dosacc.c index 109b993825..ae0fc7f5df 100644 --- a/bld/trap/lcl/dos/dosr/c/dosacc.c +++ b/bld/trap/lcl/dos/dosr/c/dosacc.c @@ -604,9 +604,7 @@ trap_retval TRAP_CORE( Prog_load )( void ) Flags &= ~F_BoundApp; psp = DbgPSP(); name = GetInPtr( sizeof( prog_load_req ) ); - if( TINY_ERROR( FindFilePath( DIG_FILETYPE_EXE, name, exe_name ) ) ) { - exe_name[0] = '\0'; - } + FindFilePath( DIG_FILETYPE_EXE, name, exe_name ); parm = name; while( *parm++ != '\0' ) // skip program name {} diff --git a/bld/trap/lcl/dos/dosx/c/dosxremo.c b/bld/trap/lcl/dos/dosx/c/dosxremo.c index 3b17e449b5..253fc8f3f7 100644 --- a/bld/trap/lcl/dos/dosx/c/dosxremo.c +++ b/bld/trap/lcl/dos/dosx/c/dosxremo.c @@ -299,7 +299,7 @@ trap_retval TRAP_CORE( Prog_load )( void ) char *name; char *endparm; const char *err; - tiny_ret_t rc; + bool prog_ok; prog_load_ret *ret; size_t len; @@ -308,7 +308,7 @@ trap_retval TRAP_CORE( Prog_load )( void ) ret = GetOutPtr( 0 ); ret->err = 0; src = name = GetInPtr( sizeof( prog_load_req ) ); - rc = FindFilePath( DIG_FILETYPE_EXE, src, buffer ); + prog_ok = ( FindFilePath( DIG_FILETYPE_EXE, src, buffer ) != 0 ); endparm = LinkParms; while( *endparm++ != '\0' ) // skip trap parameters {} @@ -323,7 +323,7 @@ trap_retval TRAP_CORE( Prog_load )( void ) ret->err = 1; len = 0; } else { - if( TINY_OK( rc ) ) { + if( prog_ok ) { while( *src++ != '\0' ) {} len = GetTotalSizeIn() - sizeof( prog_load_req ) - ( src - name ); diff --git a/bld/trap/lcl/elfcore/c/elfcore.c b/bld/trap/lcl/elfcore/c/elfcore.c index f56a8efa24..72a8cbfd60 100644 --- a/bld/trap/lcl/elfcore/c/elfcore.c +++ b/bld/trap/lcl/elfcore/c/elfcore.c @@ -688,10 +688,8 @@ trap_retval TRAP_FILE( file_to_fullpath )( void ) close( fd ); } } - if( len == 0 ) { + if( len == 0 ) ret->err = ENOENT; /* File not found */ - return( sizeof( *ret ) + 1 ); - } return( sizeof( *ret ) + len + 1 ); } diff --git a/bld/trap/lcl/linux/c/lnxacc.c b/bld/trap/lcl/linux/c/lnxacc.c index 09577816bd..1747182cd3 100644 --- a/bld/trap/lcl/linux/c/lnxacc.c +++ b/bld/trap/lcl/linux/c/lnxacc.c @@ -246,9 +246,7 @@ trap_retval TRAP_CORE( Prog_load )( void ) if( pid == 0 || ptrace( PTRACE_ATTACH, pid, NULL, NULL ) == -1 ) { attached = false; args[0] = name; - if( FindFilePath( DIG_FILETYPE_EXE, args[0], exe_name ) == 0 ) { - exe_name[0] = '\0'; - } + FindFilePath( DIG_FILETYPE_EXE, args[0], exe_name ); save_pgrp = getpgrp(); setpgid( 0, OrigPGrp ); pid = fork(); diff --git a/bld/trap/lcl/nt/c/accio.c b/bld/trap/lcl/nt/c/accio.c index ed6817eaf2..023e497e75 100644 --- a/bld/trap/lcl/nt/c/accio.c +++ b/bld/trap/lcl/nt/c/accio.c @@ -276,10 +276,8 @@ trap_retval TRAP_FILE( file_to_fullpath )( void ) if( GetMagicalFileHandle( name ) != NULL ) { strcpy( fullname, name ); - } else { - ret->err = FindFilePath( acc->file_type, name, fullname ); + } else if( FindFilePath( acc->file_type, name, fullname ) == 0 ) { + ret->err = ENOENT; } - if( ret->err != 0 ) - *fullname = '\0'; return( sizeof( *ret ) + strlen( fullname ) + 1 ); } diff --git a/bld/trap/lcl/nt/c/accload.c b/bld/trap/lcl/nt/c/accload.c index f61dff5158..69d21b57a7 100644 --- a/bld/trap/lcl/nt/c/accload.c +++ b/bld/trap/lcl/nt/c/accload.c @@ -34,6 +34,7 @@ #include #include #include +#include #include "stdnt.h" #include "globals.h" #include "trperr.h" @@ -299,8 +300,8 @@ trap_retval TRAP_CORE( Prog_load )( void ) IsDOS = false; #endif if( pid == 0 ) { - ret->err = FindFilePath( DIG_FILETYPE_EXE, parm, exe_name ); - if( ret->err != 0 ) { + if( FindFilePath( DIG_FILETYPE_EXE, parm, exe_name ) == 0 ) { + ret->err = ENOENT; goto error_exit; } /* diff --git a/bld/trap/lcl/nto/c/ntoacc.c b/bld/trap/lcl/nto/c/ntoacc.c index 816868a914..34d32f385e 100644 --- a/bld/trap/lcl/nto/c/ntoacc.c +++ b/bld/trap/lcl/nto/c/ntoacc.c @@ -624,9 +624,7 @@ trap_retval TRAP_CORE( Prog_load )( void ) ProcInfo.loaded_proc = FALSE; } else { args[0] = name; - if( FindFilePath( DIG_FILETYPE_EXE, args[0], exe_name ) == 0 ) { - exe_name[0] = '\0'; - } + FindFilePath( DIG_FILETYPE_EXE, args[0], exe_name ); save_pgrp = getpgrp(); setpgid( 0, OrigPGrp ); diff --git a/bld/trap/lcl/os2/c/accmisc.c b/bld/trap/lcl/os2/c/accmisc.c index 3b42ce11f8..3613a366a2 100644 --- a/bld/trap/lcl/os2/c/accmisc.c +++ b/bld/trap/lcl/os2/c/accmisc.c @@ -33,6 +33,7 @@ #include #include +#include #define INCL_BASE #define INCL_DOSDEVICES #define INCL_DOSMEMMGR @@ -547,9 +548,8 @@ trap_retval TRAP_FILE( file_to_fullpath )( void ) name = GetInPtr( sizeof( *acc ) ); ret = GetOutPtr( 0 ); fullname = GetOutPtr( sizeof( *ret ) ); - ret->err = FindFilePath( acc->file_type, name, fullname ); - if( ret->err != 0 ) { - *fullname = '\0'; + if( FindFilePath( acc->file_type, name, fullname ) == 0 ) { + ret->err = ENOENT; } return( sizeof( *ret ) + strlen( fullname ) + 1 ); } diff --git a/bld/trap/lcl/os2/c/os2conv.c b/bld/trap/lcl/os2/c/os2conv.c index 0ef12d47d1..b885127c01 100644 --- a/bld/trap/lcl/os2/c/os2conv.c +++ b/bld/trap/lcl/os2/c/os2conv.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -70,7 +70,7 @@ extern USHORT DoCall( PVOID, ULONG, ULONG ); __parm [__dx __ax] [__cx __bx] [__di __si] \ __modify [__ax __bx __cx __dx __si __di __es] -extern PVOID DoReturn(); +extern PVOID __far DoReturn( void ); extern HMODULE ThisDLLModHandle; diff --git a/bld/trap/lcl/os2/c/os2v1acc.c b/bld/trap/lcl/os2/c/os2v1acc.c index 520b35eaa1..cd59823118 100644 --- a/bld/trap/lcl/os2/c/os2v1acc.c +++ b/bld/trap/lcl/os2/c/os2v1acc.c @@ -800,9 +800,7 @@ trap_retval TRAP_CORE( Prog_load )( void ) ExceptNum = -1; AtEnd = FALSE; name = GetInPtr( sizeof( prog_load_req ) ); - if( FindFilePath( DIG_FILETYPE_EXE, name, exe_name ) != 0 ) { - exe_name[0] = '\0'; - } + FindFilePath( DIG_FILETYPE_EXE, name, exe_name ); parms = AddDriveAndPath( exe_name, UtilBuff ) + 1; src = name; while( *src++ != '\0' ) diff --git a/bld/trap/lcl/os2/c/os2v2acc.c b/bld/trap/lcl/os2/c/os2v2acc.c index 1d2f6e1037..5181eb6023 100644 --- a/bld/trap/lcl/os2/c/os2v2acc.c +++ b/bld/trap/lcl/os2/c/os2v2acc.c @@ -970,9 +970,7 @@ trap_retval TRAP_CORE( Prog_load )( void ) AtEnd = false; TaskFS = 0; name = GetInPtr( sizeof( prog_load_req ) ); - if( FindFilePath( DIG_FILETYPE_EXE, name, exe_name ) != 0 ) { - exe_name[0] = '\0'; - } + FindFilePath( DIG_FILETYPE_EXE, name, exe_name ); parms = AddDriveAndPath( exe_name, UtilBuff ) + 1; src = name; while( *src++ != '\0' ) diff --git a/bld/trap/lcl/os2v2/c/accmisc.c b/bld/trap/lcl/os2v2/c/accmisc.c index ccd1f32419..c8ea3940e0 100644 --- a/bld/trap/lcl/os2v2/c/accmisc.c +++ b/bld/trap/lcl/os2v2/c/accmisc.c @@ -32,7 +32,7 @@ #include #include - +#include #define INCL_DOSPROCESS #define INCL_DOSMISC #define INCL_DOSERRORS @@ -547,9 +547,8 @@ trap_retval TRAP_FILE( file_to_fullpath )( void ) name = GetInPtr( sizeof( *acc ) ); ret = GetOutPtr( 0 ); fullname = GetOutPtr( sizeof( *ret ) ); - ret->err = FindFilePath( acc->file_type, name, fullname ); - if( ret->err != 0 ) { - *fullname = '\0'; + if( FindFilePath( acc->file_type, name, fullname ) == 0 ) { + ret->err = ENOENT; } return( sizeof( *ret ) + strlen( fullname ) + 1 ); } diff --git a/bld/trap/lcl/os2v2/c/os2v2acc.c b/bld/trap/lcl/os2v2/c/os2v2acc.c index 462b7cf871..412db204d9 100644 --- a/bld/trap/lcl/os2v2/c/os2v2acc.c +++ b/bld/trap/lcl/os2v2/c/os2v2acc.c @@ -1083,9 +1083,7 @@ trap_retval TRAP_CORE( Prog_load )( void ) /* If PID was not specified, start the debuggee process */ if( attach_pid == -1 ) { isAttached = false; - if( FindFilePath( DIG_FILETYPE_EXE, name, exe_name ) ) { - exe_name[0] = '\0'; - } + FindFilePath( DIG_FILETYPE_EXE, name, exe_name ); parms = AddDriveAndPath( exe_name, UtilBuff ) + 1; src = name; while( *src++ != '\0' ) diff --git a/bld/trap/lcl/win/c/accload.c b/bld/trap/lcl/win/c/accload.c index ae28979812..cbd08e7beb 100644 --- a/bld/trap/lcl/win/c/accload.c +++ b/bld/trap/lcl/win/c/accload.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2015-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2015-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -175,9 +175,7 @@ trap_retval TRAP_CORE( Prog_load )( void ) * get the file to execute */ if( tid == 0 ) { - if( TINY_ERROR( FindFilePath( DIG_FILETYPE_EXE, parm, exe_name ) ) ) { - exe_name[0] = '\0'; - } else { + if( FindFilePath( DIG_FILETYPE_EXE, parm, exe_name ) != 0 ) { _splitpath2( exe_name, pg.buffer, &pg.drive, &pg.dir, NULL, NULL ); a = tolower( pg.drive[0] ) - 'a' + 1; _dos_setdrive( a, &b ); diff --git a/bld/trap/lcl/win/c/winfile.c b/bld/trap/lcl/win/c/winfile.c index 0b0a8b5cfe..2d935c676d 100644 --- a/bld/trap/lcl/win/c/winfile.c +++ b/bld/trap/lcl/win/c/winfile.c @@ -33,6 +33,7 @@ #include #include #include +#include #include "trpimp.h" #include "trpcomm.h" #include "winpath.h" @@ -191,18 +192,14 @@ trap_retval TRAP_FILE( file_to_fullpath )( void ) char *fullname; file_string_to_fullpath_req *acc; file_string_to_fullpath_ret *ret; - tiny_ret_t rc; acc = GetInPtr( 0 ); name = GetInPtr( sizeof( *acc ) ); ret = GetOutPtr( 0 ); ret->err = 0; fullname = GetOutPtr( sizeof( *ret ) ); - rc = FindFilePath( acc->file_type, name, fullname ); - if( TINY_ERROR( rc ) ) { - ret->err = TINY_INFO( rc ); - *fullname = '\0'; - return( sizeof( *ret ) + 1 ); + if( FindFilePath( acc->file_type, name, fullname ) == 0 ) { + ret->err = ENOENT; } return( sizeof( *ret ) + 1 + strlen( fullname ) ); } From 8a47200b131cef0436c2c2523a30d92687f95e7c Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Tue, 29 Aug 2023 03:12:20 +0200 Subject: [PATCH 055/258] fix a few mistakes --- bld/trap/lcl/dos/c/dosfile.c | 3 +-- bld/trap/lcl/linux/c/lnxacc.c | 3 ++- bld/trap/lcl/nto/c/ntoacc.c | 2 +- bld/trap/lcl/os2/c/accmisc.c | 1 + bld/trap/lcl/os2v2/c/accmisc.c | 1 + bld/trap/lcl/qnx/c/qnxacc.c | 2 +- bld/trap/lcl/qnx/c/qnxpmd.c | 6 +++--- bld/trap/lcl/win/c/winfile.c | 3 +-- 8 files changed, 11 insertions(+), 10 deletions(-) diff --git a/bld/trap/lcl/dos/c/dosfile.c b/bld/trap/lcl/dos/c/dosfile.c index 9e4163f694..6e179c054f 100644 --- a/bld/trap/lcl/dos/c/dosfile.c +++ b/bld/trap/lcl/dos/c/dosfile.c @@ -202,9 +202,8 @@ trap_retval TRAP_FILE( file_to_fullpath )( void ) ret = GetOutPtr( 0 ); ret->err = 0; fullname = GetOutPtr( sizeof( *ret ) ); - if( FindFilePath( acc->file_type, name, fullname ) == 0 ) { + if( FindFilePath( acc->file_type, name, fullname ) == 0 ) ret->err = ENOENT; - } return( sizeof( *ret ) + 1 + strlen( fullname ) ); } diff --git a/bld/trap/lcl/linux/c/lnxacc.c b/bld/trap/lcl/linux/c/lnxacc.c index 1747182cd3..928e3756a8 100644 --- a/bld/trap/lcl/linux/c/lnxacc.c +++ b/bld/trap/lcl/linux/c/lnxacc.c @@ -246,7 +246,8 @@ trap_retval TRAP_CORE( Prog_load )( void ) if( pid == 0 || ptrace( PTRACE_ATTACH, pid, NULL, NULL ) == -1 ) { attached = false; args[0] = name; - FindFilePath( DIG_FILETYPE_EXE, args[0], exe_name ); + if( FindFilePath( DIG_FILETYPE_EXE, args[0], exe_name ) == 0 ) + goto fail; save_pgrp = getpgrp(); setpgid( 0, OrigPGrp ); pid = fork(); diff --git a/bld/trap/lcl/nto/c/ntoacc.c b/bld/trap/lcl/nto/c/ntoacc.c index 34d32f385e..50ecbfda1e 100644 --- a/bld/trap/lcl/nto/c/ntoacc.c +++ b/bld/trap/lcl/nto/c/ntoacc.c @@ -1047,7 +1047,7 @@ trap_retval TRAP_CORE( Redirect_stdout )( void ) trap_retval TRAP_FILE( file_to_fullpath )( void ) { pid_t pid; - int len; + size_t len; const char *name; char *fullname; file_string_to_fullpath_req *acc; diff --git a/bld/trap/lcl/os2/c/accmisc.c b/bld/trap/lcl/os2/c/accmisc.c index 3613a366a2..b8df75b3a9 100644 --- a/bld/trap/lcl/os2/c/accmisc.c +++ b/bld/trap/lcl/os2/c/accmisc.c @@ -548,6 +548,7 @@ trap_retval TRAP_FILE( file_to_fullpath )( void ) name = GetInPtr( sizeof( *acc ) ); ret = GetOutPtr( 0 ); fullname = GetOutPtr( sizeof( *ret ) ); + ret->err = 0; if( FindFilePath( acc->file_type, name, fullname ) == 0 ) { ret->err = ENOENT; } diff --git a/bld/trap/lcl/os2v2/c/accmisc.c b/bld/trap/lcl/os2v2/c/accmisc.c index c8ea3940e0..15274a0280 100644 --- a/bld/trap/lcl/os2v2/c/accmisc.c +++ b/bld/trap/lcl/os2v2/c/accmisc.c @@ -547,6 +547,7 @@ trap_retval TRAP_FILE( file_to_fullpath )( void ) name = GetInPtr( sizeof( *acc ) ); ret = GetOutPtr( 0 ); fullname = GetOutPtr( sizeof( *ret ) ); + ret->err = 0; if( FindFilePath( acc->file_type, name, fullname ) == 0 ) { ret->err = ENOENT; } diff --git a/bld/trap/lcl/qnx/c/qnxacc.c b/bld/trap/lcl/qnx/c/qnxacc.c index c9cb1e71ba..24f234d8ef 100644 --- a/bld/trap/lcl/qnx/c/qnxacc.c +++ b/bld/trap/lcl/qnx/c/qnxacc.c @@ -1457,7 +1457,7 @@ trap_retval TRAP_FILE( file_to_fullpath )( void ) struct _psinfo proc; pid_t pid; nid_t nid; - int len; + size_t len; const char *name; char *fullname; file_string_to_fullpath_req *acc; diff --git a/bld/trap/lcl/qnx/c/qnxpmd.c b/bld/trap/lcl/qnx/c/qnxpmd.c index db0db803fb..f8fe62662e 100644 --- a/bld/trap/lcl/qnx/c/qnxpmd.c +++ b/bld/trap/lcl/qnx/c/qnxpmd.c @@ -476,8 +476,8 @@ static bool LoadPmdHeader( char *name ) return( false ); } if( PmdInfo.hdr.signature != DUMP_SIGNATURE - || PmdInfo.hdr.version != DUMP_VERSION - || PmdInfo.hdr.errnum != 0 ) { + || PmdInfo.hdr.version != DUMP_VERSION + || PmdInfo.hdr.errnum != 0 ) { close( PmdInfo.fd ); PmdInfo.fd = NO_FILE; errno = ENOEXEC; @@ -677,7 +677,7 @@ trap_retval TRAP_CORE( Redirect_stdout )( void ) trap_retval TRAP_FILE( file_to_fullpath )( void ) { struct stat chk; - unsigned_16 len; + size_t len; char *name; char *fullname; unsigned save_handle; diff --git a/bld/trap/lcl/win/c/winfile.c b/bld/trap/lcl/win/c/winfile.c index 2d935c676d..8df69d1dc1 100644 --- a/bld/trap/lcl/win/c/winfile.c +++ b/bld/trap/lcl/win/c/winfile.c @@ -198,9 +198,8 @@ trap_retval TRAP_FILE( file_to_fullpath )( void ) ret = GetOutPtr( 0 ); ret->err = 0; fullname = GetOutPtr( sizeof( *ret ) ); - if( FindFilePath( acc->file_type, name, fullname ) == 0 ) { + if( FindFilePath( acc->file_type, name, fullname ) == 0 ) ret->err = ENOENT; - } return( sizeof( *ret ) + 1 + strlen( fullname ) ); } From c533e727fb423290302f5b641dbf3c10c18811eb Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Tue, 29 Aug 2023 03:28:21 +0200 Subject: [PATCH 056/258] implement/use DIGLoaderFind function for all platforms --- bld/dig/c/dos/trpld.c | 2 +- bld/dig/c/dsx/dipld.c | 2 +- bld/dig/c/dsx/madld.c | 2 +- bld/dig/c/dsx/trpld.c | 2 +- bld/dig/c/linux/dipld_so.c | 2 +- bld/dig/c/linux/madld_so.c | 2 +- bld/dig/c/linux/trpld_pe.c | 2 +- bld/dig/c/linux/trpld_rx.c | 2 +- bld/dig/c/linux/trpld_so.c | 2 +- bld/dig/c/nt/trpld.c | 34 ++++++++------------------ bld/dig/c/os2/trpld.c | 42 +++++++++++++++----------------- bld/dig/c/qnx/pillld.c | 2 +- bld/dig/c/qnx/trpld.c | 2 +- bld/dig/c/rdos/trpld.c | 34 ++++++++------------------ bld/dig/c/win/trpld.c | 34 ++++++++------------------ bld/dip/dipdump/c/digcli.c | 6 +---- bld/sdk/drwat/nt/digcli.c | 7 +----- bld/sdk/drwat/win/digcli.c | 7 +----- bld/trap/common/dos/dosdigl.c | 40 ++++-------------------------- bld/trap/common/linux/lnxdigl.c | 37 +++------------------------- bld/trap/common/nt/ntdigl.c | 40 ++++-------------------------- bld/trap/common/nto/ntodigl.c | 37 +++------------------------- bld/trap/common/os2/os2digl.c | 40 ++++-------------------------- bld/trap/common/os2v2/os22digl.c | 40 ++++-------------------------- bld/trap/common/qnx/qnxdigl.c | 37 +++------------------------- bld/trap/common/rdos/rdosdigl.c | 40 ++++-------------------------- bld/trap/common/win/windigl.c | 40 ++++-------------------------- bld/wprof/c/utils.c | 12 +++------ 28 files changed, 109 insertions(+), 440 deletions(-) diff --git a/bld/dig/c/dos/trpld.c b/bld/dig/c/dos/trpld.c index a5778d279c..852b5809ce 100644 --- a/bld/dig/c/dos/trpld.c +++ b/bld/dig/c/dos/trpld.c @@ -136,7 +136,7 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) } len++; } - if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, len, "trp", filename, sizeof( filename ) ) == 0 ) { + if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, len, ".trp", filename, sizeof( filename ) ) == 0 ) { sprintf( buff, TC_ERR_CANT_LOAD_TRAP, base_name ); return( buff ); } diff --git a/bld/dig/c/dsx/dipld.c b/bld/dig/c/dsx/dipld.c index 8909445ee3..b245e2a4f3 100644 --- a/bld/dig/c/dsx/dipld.c +++ b/bld/dig/c/dsx/dipld.c @@ -63,7 +63,7 @@ dip_status DIPSysLoad( const char *base_name, dip_client_routines *cli, dip_imp_ char filename[_MAX_PATH]; *sys_hdl = NULL_SYSHDL; - if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, strlen( base_name ), "dip", filename, sizeof( filename ) ) == 0 ) { + if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, strlen( base_name ), ".dip", filename, sizeof( filename ) ) == 0 ) { return( DS_ERR | DS_FOPEN_FAILED ); } fp = DIGLoader( Open )( filename ); diff --git a/bld/dig/c/dsx/madld.c b/bld/dig/c/dsx/madld.c index f95ac5be2e..7fe0f58d3e 100644 --- a/bld/dig/c/dsx/madld.c +++ b/bld/dig/c/dsx/madld.c @@ -62,7 +62,7 @@ mad_status MADSysLoad( const char *base_name, mad_client_routines *cli, char filename[256]; *sys_hdl = NULL_SYSHDL; - if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, strlen( base_name ), "mad", filename, sizeof( filename ) ) == 0 ) { + if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, strlen( base_name ), ".mad", filename, sizeof( filename ) ) == 0 ) { return( MS_ERR | MS_FOPEN_FAILED ); } fp = DIGLoader( Open )( filename ); diff --git a/bld/dig/c/dsx/trpld.c b/bld/dig/c/dsx/trpld.c index cbcc2458b9..2dcfdea5f9 100644 --- a/bld/dig/c/dsx/trpld.c +++ b/bld/dig/c/dsx/trpld.c @@ -505,7 +505,7 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) } len++; } - if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, len, "trp", filename, sizeof( filename ) ) == 0 ) { + if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, len, ".trp", filename, sizeof( filename ) ) == 0 ) { sprintf( buff, TC_ERR_CANT_LOAD_TRAP, base_name ); return( buff ); } diff --git a/bld/dig/c/linux/dipld_so.c b/bld/dig/c/linux/dipld_so.c index d392789b14..52088fc951 100644 --- a/bld/dig/c/linux/dipld_so.c +++ b/bld/dig/c/linux/dipld_so.c @@ -57,7 +57,7 @@ dip_status DIPSysLoad( const char *base_name, dip_client_routines *cli, dip_imp_ dip_status ds; *sys_hdl = NULL_SYSHDL; - if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, strlen( base_name ), "so", filename, sizeof( filename ) ) == 0 ) { + if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, strlen( base_name ), ".so", filename, sizeof( filename ) ) == 0 ) { return( DS_ERR | DS_FOPEN_FAILED ); } mod_hdl = dlopen( filename, RTLD_NOW ); diff --git a/bld/dig/c/linux/madld_so.c b/bld/dig/c/linux/madld_so.c index 858ececd42..b5dfa9f847 100644 --- a/bld/dig/c/linux/madld_so.c +++ b/bld/dig/c/linux/madld_so.c @@ -58,7 +58,7 @@ mad_status MADSysLoad( const char *base_name, mad_client_routines *cli, mad_imp_ mad_status status; *sys_hdl = NULL_SYSHDL; - if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, strlen( base_name ), "so", filename, sizeof( filename ) ) == 0 ) { + if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, strlen( base_name ), ".so", filename, sizeof( filename ) ) == 0 ) { return( MS_ERR | MS_FOPEN_FAILED ); } mod_hdl = dlopen( filename, RTLD_NOW ); diff --git a/bld/dig/c/linux/trpld_pe.c b/bld/dig/c/linux/trpld_pe.c index 97d2335449..1755ddc977 100644 --- a/bld/dig/c/linux/trpld_pe.c +++ b/bld/dig/c/linux/trpld_pe.c @@ -103,7 +103,7 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) #endif } #if !defined( BUILTIN_TRAP_FILE ) - if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, len, "trp", filename, sizeof( filename ) ) == 0 ) { + if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, len, ".trp", filename, sizeof( filename ) ) == 0 ) { sprintf( buff, TC_ERR_CANT_LOAD_TRAP, base_name ); return( buff ); } diff --git a/bld/dig/c/linux/trpld_rx.c b/bld/dig/c/linux/trpld_rx.c index f8498a0cbe..2c402be8db 100644 --- a/bld/dig/c/linux/trpld_rx.c +++ b/bld/dig/c/linux/trpld_rx.c @@ -94,7 +94,7 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) } len++; } - if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, len, "trp", filename, sizeof( filename ) ) ) { + if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, len, ".trp", filename, sizeof( filename ) ) ) { sprintf( buff, TC_ERR_CANT_LOAD_TRAP, base_name ); return( buff ); } diff --git a/bld/dig/c/linux/trpld_so.c b/bld/dig/c/linux/trpld_so.c index 7b57d4de3f..cb4ed94167 100644 --- a/bld/dig/c/linux/trpld_so.c +++ b/bld/dig/c/linux/trpld_so.c @@ -105,7 +105,7 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) #endif } #if !defined( BUILTIN_TRAP_FILE ) - if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, len, "so", filename, sizeof( filename ) ) == 0 ) { + if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, len, ".so", filename, sizeof( filename ) ) == 0 ) { sprintf( buff, TC_ERR_CANT_LOAD_TRAP, base_name ); return( buff ); } diff --git a/bld/dig/c/nt/trpld.c b/bld/dig/c/nt/trpld.c index f2501eca67..a03956708e 100644 --- a/bld/dig/c/nt/trpld.c +++ b/bld/dig/c/nt/trpld.c @@ -98,39 +98,25 @@ void UnLoadTrap( void ) char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) { char filename[256]; - char *p; - bool have_ext; - char chr; + const char *base_name; + size_t len; trap_init_func *init_func; if( parms == NULL || *parms == '\0' ) parms = DEFAULT_TRP_NAME; - have_ext = false; - p = filename; - for( ; (chr = *parms) != '\0'; parms++ ) { - if( chr == TRAP_PARM_SEPARATOR ) { + base_name = parms; + len = 0; + for( ; *parms != '\0'; parms++ ) { + if( *parms == TRAP_PARM_SEPARATOR ) { parms++; break; } - switch( chr ) { - case ':': - case '/': - case '\\': - have_ext = false; - break; - case '.': - have_ext = true; - break; - } - *p++ = chr; + len++; } - if( !have_ext ) { - *p++ = '.'; - *p++ = 'd'; - *p++ = 'l'; - *p++ = 'l'; + if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, len, ".dll", filename, sizeof( filename ) ) == 0 ) { + sprintf( buff, TC_ERR_CANT_LOAD_TRAP, base_name ); + return( buff ); } - *p = '\0'; TrapFile = LoadLibrary( filename ); if( TrapFile == NULL ) { sprintf( buff, TC_ERR_CANT_LOAD_TRAP, filename ); diff --git a/bld/dig/c/os2/trpld.c b/bld/dig/c/os2/trpld.c index 0f0a765abd..6cb8cb768a 100644 --- a/bld/dig/c/os2/trpld.c +++ b/bld/dig/c/os2/trpld.c @@ -103,50 +103,46 @@ void UnLoadTrap( void ) char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) { - char *p; - char chr; + const char *base_name; + size_t len; trap_init_func *init_func; char filename[CCHMAXPATH]; - char trpname[CCHMAXPATH]; if( parms == NULL || *parms == '\0' ) parms = DEFAULT_TRP_NAME; - p = trpname; - for( ; (chr = *parms) != '\0'; parms++ ) { - if( chr == TRAP_PARM_SEPARATOR ) { + base_name = parms; + len = 0; + for( ; *parms != '\0'; parms++ ) { + if( *parms == TRAP_PARM_SEPARATOR ) { parms++; break; } - *p++ = chr; + len++; } - *p = '\0'; + /* + * To prevent conflicts with the 16-bit DIP DLLs, the 32-bit versions have the "D32" + * extension. We will search for them along the PATH (not in LIBPATH); + */ #ifdef _M_I86 - if( LOW( trpname[0] ) == 's' && LOW( trpname[1] ) == 't' - && LOW( trpname[2] ) == 'd' && trpname[3] == '\0' ) { + if( len == 3 + && LOW( base_name[0] ) == 's' && LOW( base_name[1] ) == 't' && LOW( base_name[2] ) == 'd' ) { unsigned version; char os2ver; DosGetVersion( (PUSHORT)&version ); os2ver = version >> 8; if( os2ver >= 20 ) { - strcpy( trpname, "std32" ); + base_name = "std32"; } else { - strcpy( trpname, "std16" ); + base_name = "std16"; } + len = 5; } -#endif - /* - * To prevent conflicts with the 16-bit DIP DLLs, the 32-bit versions have the "D32" - * extension. We will search for them along the PATH (not in LIBPATH); - */ -#ifdef _M_I86 - strcat( trpname, ".DLL" ); + if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, len, ".DLL", filename, sizeof( filename ) ) == 0 ) { #else - strcat( trpname, ".D32" ); + if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, len, ".D32", filename, sizeof( filename ) ) == 0 ) { #endif - _searchenv( trpname, "PATH", filename ); - if( *filename == '\0' ) { - sprintf( buff, TC_ERR_CANT_LOAD_TRAP, trpname ); + sprintf( buff, TC_ERR_CANT_LOAD_TRAP, base_name ); return( buff ); } if( LOAD_MODULE( filename, TrapFile ) ) { diff --git a/bld/dig/c/qnx/pillld.c b/bld/dig/c/qnx/pillld.c index aa3f6a586d..b0a29c8740 100644 --- a/bld/dig/c/qnx/pillld.c +++ b/bld/dig/c/qnx/pillld.c @@ -52,7 +52,7 @@ int PILLSysLoad( const char *base_name, const pill_client_routines *cli, msg->source = NULL; msg->id = LM_SYSTEM_ERROR; - if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, strlen( base_name ), "pil", filename, sizeof( filename ) ) == 0 ) { + if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, strlen( base_name ), ".pil", filename, sizeof( filename ) ) == 0 ) { return( 0 ); } fp = DIGLoader( Open )( filename ); diff --git a/bld/dig/c/qnx/trpld.c b/bld/dig/c/qnx/trpld.c index f5370bd506..ad89932942 100644 --- a/bld/dig/c/qnx/trpld.c +++ b/bld/dig/c/qnx/trpld.c @@ -96,7 +96,7 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) } len++; } - if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, len, "trp", filename, sizeof( filename ) ) == 0 ) { + if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, len, ".trp", filename, sizeof( filename ) ) == 0 ) { sprintf( buff, TC_ERR_CANT_LOAD_TRAP, base_name ); return( buff ); } diff --git a/bld/dig/c/rdos/trpld.c b/bld/dig/c/rdos/trpld.c index aa9b090932..4a7468ea7d 100644 --- a/bld/dig/c/rdos/trpld.c +++ b/bld/dig/c/rdos/trpld.c @@ -58,39 +58,25 @@ void UnLoadTrap( void ) char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) { char filename[256]; - char *p; - char chr; - bool have_ext; + const char *base_name; + size_t len; trap_init_func *init_func; if( parms == NULL || *parms == '\0' ) parms = DEFAULT_TRP_NAME; - have_ext = false; - p = filename; - for( ; (chr = *parms) != '\0'; parms++ ) { - if( chr == TRAP_PARM_SEPARATOR ) { + base_name = parms; + len = 0; + for( ; *parms != '\0'; parms++ ) { + if( *parms == TRAP_PARM_SEPARATOR ) { parms++; break; } - switch( chr ) { - case ':': - case '/': - case '\\': - have_ext = false; - break; - case '.': - have_ext = true; - break; - } - *p++ = chr; + len++; } - if( !have_ext ) { - *p++ = '.'; - *p++ = 'd'; - *p++ = 'l'; - *p++ = 'l'; + if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, len, ".dll", filename, sizeof( filename ) ) == 0 ) { + sprintf( buff, TC_ERR_CANT_LOAD_TRAP, base_name ); + return( buff ); } - *p = '\0'; TrapFile = RdosLoadDll( filename ); if( TrapFile == NULL ) { sprintf( buff, TC_ERR_CANT_LOAD_TRAP, filename ); diff --git a/bld/dig/c/win/trpld.c b/bld/dig/c/win/trpld.c index 13084b0669..68398797cc 100644 --- a/bld/dig/c/win/trpld.c +++ b/bld/dig/c/win/trpld.c @@ -82,40 +82,26 @@ void UnLoadTrap( void ) char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) { char filename[256]; - char *p; - char chr; - bool have_ext; + const char *base_name; + size_t len; UINT prev; trap_init_func *init_func; if( parms == NULL || *parms == '\0' ) parms = DEFAULT_TRP_NAME; - have_ext = false; - p = filename; - for( ; (chr = *parms) != '\0'; parms++ ) { - if( chr == TRAP_PARM_SEPARATOR ) { + base_name = parms; + len = 0; + for( ; *parms != '\0'; parms++ ) { + if( *parms == TRAP_PARM_SEPARATOR ) { parms++; break; } - switch( chr ) { - case ':': - case '/': - case '\\': - have_ext = false; - break; - case '.': - have_ext = true; - break; - } - *p++ = chr; + len++; } - if( !have_ext ) { - *p++ = '.'; - *p++ = 'd'; - *p++ = 'l'; - *p++ = 'l'; + if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, len, ".dll", filename, sizeof( filename ) ) == 0 ) { + sprintf( buff, TC_ERR_CANT_LOAD_TRAP, base_name ); + return( buff ); } - *p = '\0'; /* * load toolhelp since windows can't seem to handle having a static * reference to a dll inside a dynamically loaded dll diff --git a/bld/dip/dipdump/c/digcli.c b/bld/dip/dipdump/c/digcli.c index 8cf4dafe00..0f65eded6c 100644 --- a/bld/dip/dipdump/c/digcli.c +++ b/bld/dip/dipdump/c/digcli.c @@ -213,11 +213,7 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base /* unused parameters */ (void)ftype; strncpy( fname, base_name, base_name_len ); - fname[base_name_len] = '\0'; - if( defext != NULL && *defext != '\0' ) { - _splitpath2( fname, fullname, NULL, NULL, &p, NULL ); - _makepath( fname, NULL, NULL, p, defext ); - } + strcat( fname + base_name_len, defext ); if( access( fname, F_OK ) == 0 ) { p = fname; } else if( path_list != NULL ) { diff --git a/bld/sdk/drwat/nt/digcli.c b/bld/sdk/drwat/nt/digcli.c index b9de53810b..1ef607d3f6 100644 --- a/bld/sdk/drwat/nt/digcli.c +++ b/bld/sdk/drwat/nt/digcli.c @@ -224,7 +224,6 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base */ { char fname[256]; - pgroup2 pg; size_t len; /* unused parameters */ (void)ftype; @@ -233,11 +232,7 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base if( filename_len > 0 ) { filename_len--; strncpy( fname, base_name, base_name_len ); - fname[base_name_len] = '\0'; - _splitpath2( fname, pg.buffer, &pg.drive, &pg.dir, &pg.fname, &pg.ext ); - if( pg.ext != NULL && *pg.ext != '\0' ) - defext = pg.ext; - _makepath( fname, pg.drive, pg.dir, pg.fname, defext ); + strcat( fname + base_name_len, defext ); len = strlen( fname ); if( len > filename_len ) len = filename_len; diff --git a/bld/sdk/drwat/win/digcli.c b/bld/sdk/drwat/win/digcli.c index 8c5da02cb6..edd2db8649 100644 --- a/bld/sdk/drwat/win/digcli.c +++ b/bld/sdk/drwat/win/digcli.c @@ -227,7 +227,6 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base */ { char fname[256]; - pgroup2 pg; size_t len; /* unused parameters */ (void)ftype; @@ -236,11 +235,7 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base if( filename_len > 0 ) { filename_len--; strncpy( fname, base_name, base_name_len ); - fname[base_name_len] = '\0'; - _splitpath2( fname, pg.buffer, &pg.drive, &pg.dir, &pg.fname, &pg.ext ); - if( pg.ext != NULL && *pg.ext != '\0' ) - defext = pg.ext; - _makepath( fname, pg.drive, pg.dir, pg.fname, defext ); + strcat( fname + base_name_len, defext ); len = strlen( fname ); if( len > filename_len ) len = filename_len; diff --git a/bld/trap/common/dos/dosdigl.c b/bld/trap/common/dos/dosdigl.c index 289ac77b79..d7f1bcca94 100644 --- a/bld/trap/common/dos/dosdigl.c +++ b/bld/trap/common/dos/dosdigl.c @@ -49,51 +49,21 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base const char *defext, char *filename, size_t filename_len ) /****************************************************************************************/ { - bool has_ext; - bool has_path; - char *p; char fname[256]; - char c; size_t len; /* unused parameters */ (void)ftype; - has_ext = false; - has_path = false; - p = fname; - while( base_name_len-- > 0 ) { - c = *base_name++; - *p++ = c; - switch( c ) { - case '.': - has_ext = true; - break; - case '/': - case '\\': - has_ext = false; - /* fall through */ - case ':': - has_path = true; - break; - } - } - if( !has_ext && *defext != '\0' ) { - *p++ = '.'; - p = StrCopyDst( defext, p ); - } - *p = '\0'; - p = fname; - if( !has_path ) { - _searchenv( fname, "PATH", RWBuff ); - p = RWBuff; - } - len = strlen( p ); + strncpy( fname, base_name, base_name_len ); + strcat( fname + base_name_len, defext ); + _searchenv( fname, "PATH", RWBuff ); + len = strlen( RWBuff ); if( filename_len > 0 ) { filename_len--; if( filename_len > len ) filename_len = len; if( filename_len > 0 ) - strncpy( filename, p, filename_len ); + strncpy( filename, RWBuff, filename_len ); filename[filename_len] = '\0'; } return( len ); diff --git a/bld/trap/common/linux/lnxdigl.c b/bld/trap/common/linux/lnxdigl.c index 3fbddc5750..38861642de 100644 --- a/bld/trap/common/linux/lnxdigl.c +++ b/bld/trap/common/linux/lnxdigl.c @@ -45,49 +45,20 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base const char *defext, char *filename, size_t filename_len ) /****************************************************************************************/ { - bool has_ext; - bool has_path; - char *p; char fname[256]; - char c; size_t len; /* unused parameters */ (void)ftype; - has_ext = false; - has_path = false; - p = fname; - while( base_name_len-- > 0 ) { - c = *base_name++; - *p++ = c; - switch( c ) { - case '.': - has_ext = true; - break; - case '/': - has_ext = false; - has_path = true; - break; - } - } - if( !has_ext && *defext != '\0' ) { - *p++ = '.'; - p = StrCopyDst( defext, p ); - } - *p = '\0'; - if( has_path ) { - p = fname; - } else { - FindFilePath( DIG_FILETYPE_DBG, fname, RWBuff ); - p = RWBuff; - } - len = strlen( p ); + strncpy( fname, base_name, base_name_len ); + strcat( fname + base_name_len, defext ); + len = FindFilePath( DIG_FILETYPE_DBG, fname, RWBuff ); if( filename_len > 0 ) { filename_len--; if( filename_len > len ) filename_len = len; if( filename_len > 0 ) - strncpy( filename, p, filename_len ); + strncpy( filename, RWBuff, filename_len ); filename[filename_len] = '\0'; } return( len ); diff --git a/bld/trap/common/nt/ntdigl.c b/bld/trap/common/nt/ntdigl.c index 73ba6b4339..f9b0b4f14b 100644 --- a/bld/trap/common/nt/ntdigl.c +++ b/bld/trap/common/nt/ntdigl.c @@ -42,51 +42,21 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base const char *defext, char *filename, size_t filename_len ) /****************************************************************************************/ { - bool has_ext; - bool has_path; - char *p; char fname[256]; - char c; size_t len; /* unused parameters */ (void)ftype; - has_ext = false; - has_path = false; - p = fname; - while( base_name_len-- > 0 ) { - c = *base_name++; - *p++ = c; - switch( c ) { - case '.': - has_ext = true; - break; - case '/': - case '\\': - has_ext = false; - /* fall through */ - case ':': - has_path = true; - break; - } - } - if( !has_ext && *defext != '\0' ) { - *p++ = '.'; - p = StrCopyDst( defext, p ); - } - *p = '\0'; - p = fname; - if( !has_path ) { - _searchenv( fname, "PATH", RWBuff ); - p = RWBuff; - } - len = strlen( p ); + strncpy( fname, base_name, base_name_len ); + strcat( fname + base_name_len, defext ); + _searchenv( fname, "PATH", RWBuff ); + len = strlen( RWBuff ); if( filename_len > 0 ) { filename_len--; if( filename_len > len ) filename_len = len; if( filename_len > 0 ) - strncpy( filename, p, filename_len ); + strncpy( filename, RWBuff, filename_len ); filename[filename_len] = '\0'; } return( len ); diff --git a/bld/trap/common/nto/ntodigl.c b/bld/trap/common/nto/ntodigl.c index 3ca373bae3..1e600702a9 100644 --- a/bld/trap/common/nto/ntodigl.c +++ b/bld/trap/common/nto/ntodigl.c @@ -47,49 +47,20 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base const char *defext, char *filename, size_t filename_len ) /****************************************************************************************/ { - bool has_ext; - bool has_path; - char *p; - char c; char fname[256]; size_t len; /* unused parameters */ (void)ftype; - has_ext = false; - has_path = false; - p = fname; - while( base_name_len-- > 0 ) { - c = *base_name++; - *p++ = c; - switch( c ) { - case '.': - has_ext = true; - break; - case '/': - has_ext = false; - has_path = true; - break; - } - } - if( !has_ext && *defext != '\0' ) { - *p++ = '.'; - p = StrCopyDst( defext, p ); - } - *p = '\0'; - if( has_path ) { - p = fname; - } else { - FindFilePath( DIG_FILETYPE_DBG, fname, RWBuff ); - p = RWBuff; - } - len = strlen( p ); + strncpy( fname, base_name, base_name_len ); + strcat( fname + base_name_len, defext ); + len = FindFilePath( DIG_FILETYPE_DBG, fname, RWBuff ); if( filename_len > 0 ) { filename_len--; if( filename_len > len ) filename_len = len; if( filename_len > 0 ) - strncpy( filename, p, filename_len ); + strncpy( filename, RWBuff, filename_len ); filename[filename_len] = '\0'; } return( len ); diff --git a/bld/trap/common/os2/os2digl.c b/bld/trap/common/os2/os2digl.c index 554eb366a4..8a915f0825 100644 --- a/bld/trap/common/os2/os2digl.c +++ b/bld/trap/common/os2/os2digl.c @@ -42,51 +42,21 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base const char *defext, char *filename, size_t filename_len ) /****************************************************************************************/ { - bool has_ext; - bool has_path; - char *p; char fname[256]; - char c; size_t len; /* unused parameters */ (void)ftype; - has_ext = false; - has_path = false; - p = fname; - while( base_name_len-- > 0 ) { - c = *base_name++; - *p++ = c; - switch( c ) { - case '.': - has_ext = true; - break; - case '/': - case '\\': - has_ext = false; - /* fall through */ - case ':': - has_path = true; - break; - } - } - if( !has_ext && *defext != '\0' ) { - *p++ = '.'; - p = StrCopyDst( defext, p ); - } - *p = '\0'; - p = fname; - if( !has_path ) { - _searchenv( fname, "PATH", RWBuff ); - p = RWBuff; - } - len = strlen( p ); + strncpy( fname, base_name, base_name_len ); + strcat( fname + base_name_len, defext ); + _searchenv( fname, "PATH", RWBuff ); + len = strlen( RWBuff ); if( filename_len > 0 ) { filename_len--; if( filename_len > len ) filename_len = len; if( filename_len > 0 ) - strncpy( filename, p, filename_len ); + strncpy( filename, RWBuff, filename_len ); filename[filename_len] = '\0'; } return( len ); diff --git a/bld/trap/common/os2v2/os22digl.c b/bld/trap/common/os2v2/os22digl.c index 31e6f8d1a0..884f833afb 100644 --- a/bld/trap/common/os2v2/os22digl.c +++ b/bld/trap/common/os2v2/os22digl.c @@ -42,51 +42,21 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base const char *defext, char *filename, size_t filename_len ) /****************************************************************************************/ { - bool has_ext; - bool has_path; - char *p; char fname[256]; - char c; size_t len; /* unused parameters */ (void)ftype; - has_ext = false; - has_path = false; - p = fname; - while( base_name_len-- > 0 ) { - c = *base_name++; - *p++ = c; - switch( c ) { - case '.': - has_ext = true; - break; - case '/': - case '\\': - has_ext = false; - /* fall through */ - case ':': - has_path = true; - break; - } - } - if( !has_ext && *defext != '\0' ) { - *p++ = '.'; - p = StrCopyDst( defext, p ); - } - *p = '\0'; - p = fname; - if( !has_path ) { - _searchenv( fname, "PATH", RWBuff ); - p = RWBuff; - } - len = strlen( p ); + strncpy( fname, base_name, base_name_len ); + strcat( fname + base_name_len, defext ); + _searchenv( fname, "PATH", RWBuff ); + len = strlen( RWBuff ); if( filename_len > 0 ) { filename_len--; if( filename_len > len ) filename_len = len; if( filename_len > 0 ) - strncpy( filename, p, filename_len ); + strncpy( filename, RWBuff, filename_len ); filename[filename_len] = '\0'; } return( len ); diff --git a/bld/trap/common/qnx/qnxdigl.c b/bld/trap/common/qnx/qnxdigl.c index 190aef2c14..5c9f06ee9b 100644 --- a/bld/trap/common/qnx/qnxdigl.c +++ b/bld/trap/common/qnx/qnxdigl.c @@ -47,49 +47,20 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base const char *defext, char *filename, size_t filename_len ) /****************************************************************************************/ { - bool has_ext; - bool has_path; - char *p; - char c; char fname[PATH_MAX + 1]; size_t len; /* unused parameters */ (void)ftype; - has_ext = false; - has_path = false; - p = fname; - while( base_name_len-- > 0 ) { - c = *base_name++; - *p++ = c; - switch( c ) { - case '.': - has_ext = true; - break; - case '/': - has_ext = false; - has_path = true; - break; - } - } - if( !has_ext && *defext != '\0' ) { - *p++ = '.'; - p = StrCopyDst( defext, p ); - } - *p = '\0'; - if( has_path ) { - p = fname; - } else { - FindFilePath( DIG_FILETYPE_DBG, fname, RWBuff ); - p = RWBuff; - } - len = strlen( p ); + strncpy( fname, base_name, base_name_len ); + strcat( fname + base_name_len, defext ); + len = FindFilePath( DIG_FILETYPE_DBG, fname, RWBuff ); if( filename_len > 0 ) { filename_len--; if( filename_len > len ) filename_len = len; if( filename_len > 0 ) - strncpy( filename, p, filename_len ); + strncpy( filename, RWBuff, filename_len ); filename[filename_len] = '\0'; } return( len ); diff --git a/bld/trap/common/rdos/rdosdigl.c b/bld/trap/common/rdos/rdosdigl.c index a018f7e50f..19b6450fa0 100644 --- a/bld/trap/common/rdos/rdosdigl.c +++ b/bld/trap/common/rdos/rdosdigl.c @@ -42,51 +42,21 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base const char *defext, char *filename, size_t filename_len ) /****************************************************************************************/ { - bool has_ext; - bool has_path; - char *p; char fname[256]; - char c; size_t len; /* unused parameters */ (void)ftype; - has_ext = false; - has_path = false; - p = fname; - while( base_name_len-- > 0 ) { - c = *base_name++; - *p++ = c; - switch( c ) { - case '.': - has_ext = true; - break; - case '/': - case '\\': - has_ext = false; - /* fall through */ - case ':': - has_path = true; - break; - } - } - if( !has_ext && *defext != '\0' ) { - *p++ = '.'; - p = StrCopyDst( defext, p ); - } - *p = '\0'; - p = fname; - if( !has_path ) { - _searchenv( fname, "PATH", RWBuff ); - p = RWBuff; - } - len = strlen( p ); + strncpy( fname, base_name, base_name_len ); + strcat( fname + base_name_len, defext ); + _searchenv( fname, "PATH", RWBuff ); + len = strlen( RWBuff ); if( filename_len > 0 ) { filename_len--; if( filename_len > len ) filename_len = len; if( filename_len > 0 ) - strncpy( filename, p, filename_len ); + strncpy( filename, RWBuff, filename_len ); filename[filename_len] = '\0'; } return( len ); diff --git a/bld/trap/common/win/windigl.c b/bld/trap/common/win/windigl.c index 303aedf5dd..908fdc70ec 100644 --- a/bld/trap/common/win/windigl.c +++ b/bld/trap/common/win/windigl.c @@ -42,51 +42,21 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base const char *defext, char *filename, size_t filename_len ) /****************************************************************************************/ { - bool has_ext; - bool has_path; - char *p; char fname[256]; - char c; size_t len; /* unused parameters */ (void)ftype; - has_ext = false; - has_path = false; - p = fname; - while( base_name_len-- > 0 ) { - c = *base_name++; - *p++ = c; - switch( c ) { - case '.': - has_ext = true; - break; - case '/': - case '\\': - has_ext = false; - /* fall through */ - case ':': - has_path = true; - break; - } - } - if( !has_ext && *defext != '\0' ) { - *p++ = '.'; - p = StrCopyDst( defext, p ); - } - *p = '\0'; - p = fname; - if( !has_path ) { - _searchenv( fname, "PATH", RWBuff ); - p = RWBuff; - } - len = strlen( p ); + strncpy( fname, base_name, base_name_len ); + strcat( fname + base_name_len, defext ); + _searchenv( fname, "PATH", RWBuff ); + len = strlen( RWBuff ); if( filename_len > 0 ) { filename_len--; if( filename_len > len ) filename_len = len; if( filename_len > 0 ) - strncpy( filename, p, filename_len ); + strncpy( filename, RWBuff, filename_len ); filename[filename_len] = '\0'; } return( len ); diff --git a/bld/wprof/c/utils.c b/bld/wprof/c/utils.c index 73d9239409..706cbbbeff 100644 --- a/bld/wprof/c/utils.c +++ b/bld/wprof/c/utils.c @@ -154,21 +154,17 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base /****************************************************************************************/ { char fname[_MAX_PATH2]; + char buffer[_MAX_PATH2]; char *p; - pgroup2 pg; size_t len; /* unused parameters */ (void)ftype; strncpy( fname, base_name, base_name_len ); - fname[base_name_len] = '\0'; - if( defext != NULL && *defext != NULLCHAR ) { - _splitpath2( fname, pg.buffer, NULL, NULL, &pg.fname, NULL ); - _makepath( fname, NULL, NULL, pg.fname, defext ); - } - p = findFile( pg.buffer, fname, FilePathList ); + strcat( fname + base_name_len, defext ); + p = findFile( buffer, fname, FilePathList ); if( p == NULL ) { - p = findFile( pg.buffer, fname, DipExePathList ); + p = findFile( buffer, fname, DipExePathList ); if( p == NULL ) { p = ""; } From 998f4996319a3f72d7fe9ff3cc148d5dc58fb2a2 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Tue, 29 Aug 2023 05:52:07 +0200 Subject: [PATCH 057/258] use DIGLoaderFind function for all platforms --- bld/dig/c/nt/dipld.c | 5 +++-- bld/dig/c/nt/madld.c | 5 +++-- bld/dig/c/nt/trpld.c | 2 +- bld/dig/c/os2/dipld.c | 13 ++++--------- bld/dig/c/os2/madld.c | 13 ++++--------- bld/dig/c/rdos/dipld.c | 5 +++-- bld/dig/c/rdos/madld.c | 5 +++-- bld/dig/c/win/dipld.c | 5 +++-- bld/dig/c/win/madld.c | 7 ++++--- 9 files changed, 28 insertions(+), 32 deletions(-) diff --git a/bld/dig/c/nt/dipld.c b/bld/dig/c/nt/dipld.c index 1f79f0546d..46364e3859 100644 --- a/bld/dig/c/nt/dipld.c +++ b/bld/dig/c/nt/dipld.c @@ -56,8 +56,9 @@ dip_status DIPSysLoad( const char *base_name, dip_client_routines *cli, dip_imp_ dip_status ds; *sys_hdl = NULL_SYSHDL; - strcpy( filename, base_name ); - strcat( filename, ".dll" ); + if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, strlen( base_name ), ".dll", filename, sizeof( filename ) ) == 0 ) { + return( DS_ERR | DS_FOPEN_FAILED ); + } mod_hdl = LoadLibrary( filename ); if( mod_hdl == NULL ) { return( DS_ERR | DS_FOPEN_FAILED ); diff --git a/bld/dig/c/nt/madld.c b/bld/dig/c/nt/madld.c index 7c22971759..fc2b63a5e2 100644 --- a/bld/dig/c/nt/madld.c +++ b/bld/dig/c/nt/madld.c @@ -58,8 +58,9 @@ mad_status MADSysLoad( const char *base_name, mad_client_routines *cli, mad_imp_ mad_status status; *sys_hdl = NULL_SYSHDL; - strcpy( filename, base_name ); - strcat( filename, ".dll" ); + if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, strlen( base_name ), ".dll", filename, sizeof( filename ) ) == 0 ) { + return( MS_ERR | MS_FOPEN_FAILED ); + } mod_hdl = LoadLibrary( filename ); if( mod_hdl == NULL ) { return( MS_ERR | MS_FOPEN_FAILED ); diff --git a/bld/dig/c/nt/trpld.c b/bld/dig/c/nt/trpld.c index a03956708e..ecdb59044a 100644 --- a/bld/dig/c/nt/trpld.c +++ b/bld/dig/c/nt/trpld.c @@ -122,13 +122,13 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) sprintf( buff, TC_ERR_CANT_LOAD_TRAP, filename ); return( buff ); } + buff[0] = '\0'; init_func = (trap_init_func *)GetProcAddress( TrapFile, (LPSTR)1 ); FiniFunc = (trap_fini_func *)GetProcAddress( TrapFile, (LPSTR)2 ); ReqFunc = (trap_req_func *)GetProcAddress( TrapFile, (LPSTR)3 ); TRAP_EXTFUNC_PTR( InfoFunction ) = (TRAP_EXTFUNC_TYPE( InfoFunction ))GetProcAddress( TrapFile, (LPSTR)4 ); TRAP_EXTFUNC_PTR( InterruptProgram ) = (TRAP_EXTFUNC_TYPE( InterruptProgram ))GetProcAddress( TrapFile, (LPSTR)5 ); TRAP_EXTFUNC_PTR( Terminate ) = (TRAP_EXTFUNC_TYPE( Terminate ))GetProcAddress( TrapFile, (LPSTR)6 ); - buff[0] = '\0'; if( init_func != NULL && FiniFunc != NULL && ReqFunc != NULL ) { *trap_ver = init_func( parms, buff, trap_ver->remote ); if( buff[0] == '\0' ) { diff --git a/bld/dig/c/os2/dipld.c b/bld/dig/c/os2/dipld.c index 18066ecd34..56ddde0609 100644 --- a/bld/dig/c/os2/dipld.c +++ b/bld/dig/c/os2/dipld.c @@ -64,9 +64,6 @@ dip_status DIPSysLoad( const char *base_name, dip_client_routines *cli, dip_imp_ dip_init_func *init_func; dip_status ds; char filename[CCHMAXPATH]; -#ifndef _M_I86 - char fname[CCHMAXPATH]; -#endif *sys_hdl = NULL_SYSHDL; /* @@ -74,14 +71,12 @@ dip_status DIPSysLoad( const char *base_name, dip_client_routines *cli, dip_imp_ * extension. We will search for them along the PATH (not in LIBPATH); */ #ifdef _M_I86 - strcpy( filename, base_name ); + if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, strlen( base_name ), ".DLL", filename, sizeof( filename ) ) == 0 ) { #else - strcpy( fname, base_name ); - strcat( fname, ".D32" ); - _searchenv( fname, "PATH", filename ); - if( *filename == '\0' ) - return( DS_ERR | DS_FOPEN_FAILED ); + if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, strlen( base_name ), ".D32", filename, sizeof( filename ) ) == 0 ) { #endif + return( DS_ERR | DS_FOPEN_FAILED ); + } if( LOAD_MODULE( filename, mod_hdl ) ) { return( DS_ERR | DS_FOPEN_FAILED ); } diff --git a/bld/dig/c/os2/madld.c b/bld/dig/c/os2/madld.c index 999c31dd4c..5f05ea96a0 100644 --- a/bld/dig/c/os2/madld.c +++ b/bld/dig/c/os2/madld.c @@ -64,9 +64,6 @@ mad_status MADSysLoad( const char *base_name, mad_client_routines *cli, mad_imp_ mad_init_func *init_func; mad_status status; char filename[CCHMAXPATH]; -#ifndef _M_I86 - char fname[CCHMAXPATH]; -#endif *sys_hdl = NULL_SYSHDL; /* @@ -74,14 +71,12 @@ mad_status MADSysLoad( const char *base_name, mad_client_routines *cli, mad_imp_ * extension. We will search for them along the PATH (not in LIBPATH); */ #ifdef _M_I86 - strcpy( filename, base_name ); + if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, strlen( base_name ), ".DLL", filename, sizeof( filename ) ) == 0 ) { #else - strcpy( fname, base_name ); - strcat( fname, ".D32" ); - _searchenv( fname, "PATH", filename ); - if( *filename == '\0' ) - return( MS_ERR | MS_FOPEN_FAILED ); + if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, strlen( base_name ), ".D32", filename, sizeof( filename ) ) == 0 ) { #endif + return( MS_ERR | MS_FOPEN_FAILED ); + } if( LOAD_MODULE( filename, mod_hdl ) ) { return( MS_ERR | MS_FOPEN_FAILED ); } diff --git a/bld/dig/c/rdos/dipld.c b/bld/dig/c/rdos/dipld.c index deb9b1b6ab..8e3d6b74cd 100644 --- a/bld/dig/c/rdos/dipld.c +++ b/bld/dig/c/rdos/dipld.c @@ -56,8 +56,9 @@ dip_status DIPSysLoad( const char *base_name, dip_client_routines *cli, dip_imp_ dip_status ds; *sys_hdl = NULL_SYSHDL; - strcpy( filename, base_name ); - strcat( filename, ".dll" ); + if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, strlen( base_name ), ".dll", filename, sizeof( filename ) ) == 0 ) { + return( DS_ERR | DS_FOPEN_FAILED ); + } mod_hdl = RdosLoadDll( filename ); if( mod_hdl == NULL_SYSHDL ) { return( DS_ERR | DS_FOPEN_FAILED ); diff --git a/bld/dig/c/rdos/madld.c b/bld/dig/c/rdos/madld.c index 74849c9576..0e51bc3ae4 100644 --- a/bld/dig/c/rdos/madld.c +++ b/bld/dig/c/rdos/madld.c @@ -58,8 +58,9 @@ mad_status MADSysLoad( const char *base_name, mad_client_routines *cli, mad_imp_ mad_status status; *sys_hdl = NULL_SYSHDL; - strcpy( filename, base_name ); - strcat( filename, ".dll" ); + if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, strlen( base_name ), ".dll", filename, sizeof( filename ) ) == 0 ) { + return( MS_ERR | MS_FOPEN_FAILED ); + } mod_hdl = RdosLoadDll( filename ); if( mod_hdl == NULL_SYSHDL ) { return( MS_ERR | MS_FOPEN_FAILED ); diff --git a/bld/dig/c/win/dipld.c b/bld/dig/c/win/dipld.c index 4c4c50aec1..9685fe2574 100644 --- a/bld/dig/c/win/dipld.c +++ b/bld/dig/c/win/dipld.c @@ -83,8 +83,9 @@ dip_status DIPSysLoad( const char *base_name, dip_client_routines *cli, dip_imp_ UINT prev; *sys_hdl = NULL_SYSHDL; - strcpy( filename, base_name ); - strcat( filename, ".dll" ); + if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, strlen( base_name ), ".dll", filename, sizeof( filename ) ) == 0 ) { + return( DS_ERR | DS_FOPEN_FAILED ); + } p = parm; *p++ = ' '; utoa( _FP_SEG( &transfer_block ), p, 16 ); diff --git a/bld/dig/c/win/madld.c b/bld/dig/c/win/madld.c index 8c76a4269e..78990a5209 100644 --- a/bld/dig/c/win/madld.c +++ b/bld/dig/c/win/madld.c @@ -85,8 +85,9 @@ mad_status MADSysLoad( const char *base_name, mad_client_routines *cli, UINT prev; *sys_hdl = NULL_SYSHDL; - strcpy( filename, base_name ); - strcat( filename, ".dll" ); + if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, strlen( base_name ), ".dll", filename, sizeof( filename ) ) == 0 ) { + return( MS_ERR | MS_FOPEN_FAILED ); + } p = parm; *p++ = ' '; utoa( _FP_SEG( &transfer_block ), p, 16 ); @@ -103,8 +104,8 @@ mad_status MADSysLoad( const char *base_name, mad_client_routines *cli, parm_block.reserved = 0; prev = SetErrorMode( SEM_NOOPENFILEERRORBOX ); mod_hdl = LoadModule( filename, &parm_block ); - MADLastHandle = mod_hdl; SetErrorMode( prev ); + MADLastHandle = mod_hdl; if( mod_hdl < HINSTANCE_ERROR ) { return( MS_ERR | MS_FOPEN_FAILED ); } From ab2918bfc7df8690eab61730cd850e15c1b9d9c4 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Tue, 29 Aug 2023 06:31:25 +0200 Subject: [PATCH 058/258] fix debugger DIGLoaderFind --- bld/dig/c/nt/pillld.c | 3 +- bld/wv/c/dbgfile.c | 65 +++++++++++++------------------------------ 2 files changed, 20 insertions(+), 48 deletions(-) diff --git a/bld/dig/c/nt/pillld.c b/bld/dig/c/nt/pillld.c index dc1f952dbc..89a2aff150 100644 --- a/bld/dig/c/nt/pillld.c +++ b/bld/dig/c/nt/pillld.c @@ -46,8 +46,7 @@ int PILLSysLoad( const char *path, const pill_client_routines *cli, msg->source = NULL; msg->id = LM_SYSTEM_ERROR; - strcpy( filename, path ); - strcat( filename, ".dll" ); + DIGLoader( Find )( DIG_FILETYPE_DBG, path, strlen( path ), ".dll", newpath, sizeof( newpath ) ); dll = LoadLibrary( filename ); if( dll == NULL ) { msg->data.code = GetLastError(); diff --git a/bld/wv/c/dbgfile.c b/bld/wv/c/dbgfile.c index de5c211a55..958b93e22e 100644 --- a/bld/wv/c/dbgfile.c +++ b/bld/wv/c/dbgfile.c @@ -733,35 +733,30 @@ void PathInit( void ) #endif } -static size_t MakeName( const char *path, const char *name, size_t nlen, char *res, size_t rlen ) +static size_t MakeName( const char *path, const char *name, char *filename, size_t filename_len ) { char *p; size_t len; - if( rlen < 2 ) { - if( rlen == 1 ) - *res = NULLCHAR; - return( 0 ); - } - p = res; - --rlen; // save space for terminator + filename_len--; /* save space for terminator */ + p = filename; len = 0; if( path != NULL ) { - while( len < rlen && *path != NULLCHAR ) { + while( len < filename_len && *path != NULLCHAR ) { *p++ = *path++; ++len; } - if( len > 0 && len < rlen && !CHK_PATH_SEP( p[-1], &LclFile ) ) { + if( len > 0 && len < filename_len && !CHK_PATH_SEP( p[-1], &LclFile ) ) { *p++ = LclFile.path_separator[0]; ++len; } } - while( len < rlen && nlen-- > 0 ) { + while( len < filename_len && *name != NULLCHAR ) { *p++ = *name++; ++len; } *p = NULLCHAR; - return( p - res ); + return( len ); } size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base_name_len, @@ -779,41 +774,19 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base /* unused parameters */ (void)ftype; - has_ext = false; - has_path = false; - p = buffer; - while( base_name_len-- > 0 ) { - c = *base_name++; - *p++ = c; - if( CHK_PATH_SEP( c, &LclFile ) ) { - has_ext = false; - has_path = true; - } else if( c == LclFile.ext_separator ) { - has_ext = true; - } - } - if( !has_ext && *defext != NULLCHAR ) { - *p++ = LclFile.ext_separator; - p = StrCopyDst( defext, p ); - } - *p = NULLCHAR; - if( has_path ) { - p = buffer; + strncpy( fname, base_name, base_name_len ); + strcpy( fname + base_name_len, defext ); + // check open file in current directory or in full path + if( access( fname, F_OK ) == 0 ) { + p = fname; } else { - // check open file in current directory or in full path - len = p - buffer; - MakeName( NULL, buffer, len, fname, sizeof( fname ) ); - if( access( fname, F_OK ) == 0 ) { - p = fname; - } else { - p = ""; - // check open file in debugger directory list - for( curr = LclPath; curr != NULL; curr = curr->next ) { - if( MakeName( curr->name, buffer, len, fname, sizeof( fname ) ) ) { - if( access( fname, F_OK ) == 0 ) { - p = fname; - break; - } + p = ""; + // check open file in debugger directory list + for( curr = LclPath; curr != NULL; curr = curr->next ) { + if( MakeName( curr->name, fname, buffer, sizeof( buffer ) ) ) { + if( access( buffer, F_OK ) == 0 ) { + p = buffer; + break; } } } From 673ff4c469ea0c3b4eabe3afd159f7c060d4e606 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Tue, 29 Aug 2023 07:53:33 +0200 Subject: [PATCH 059/258] fix various problems for DIGLoaderFind add missing call to DIGLoaderFind little code optimization --- bld/dig/c/dsx/dipld.c | 2 +- bld/dig/c/dsx/madld.c | 2 +- bld/dig/c/linux/dipld_so.c | 2 +- bld/dig/c/linux/madld_so.c | 2 +- bld/dig/c/nt/dipld.c | 2 +- bld/dig/c/nt/madld.c | 2 +- bld/dig/c/nt/pillld.c | 18 ++++++++++-------- bld/dig/c/os2/dipld.c | 4 ++-- bld/dig/c/os2/madld.c | 4 ++-- bld/dig/c/os2/pillld.c | 19 ++++++++++++------- bld/dig/c/qnx/pillld.c | 2 +- bld/dig/c/rdos/dipld.c | 2 +- bld/dig/c/rdos/madld.c | 2 +- bld/dig/c/rdos/pillld.c | 17 +++++++++-------- bld/dig/c/win/dipld.c | 2 +- bld/dig/c/win/madld.c | 2 +- bld/dip/dipdump/c/digcli.c | 4 +++- bld/sdk/drwat/nt/digcli.c | 4 +++- bld/sdk/drwat/win/digcli.c | 4 +++- bld/trap/common/dos/dosdigl.c | 4 +++- bld/trap/common/linux/lnxdigl.c | 4 +++- bld/trap/common/nt/ntdigl.c | 4 +++- bld/trap/common/nto/ntodigl.c | 4 +++- bld/trap/common/os2/os2digl.c | 4 +++- bld/trap/common/os2v2/os22digl.c | 4 +++- bld/trap/common/qnx/qnxdigl.c | 4 +++- bld/trap/common/rdos/rdosdigl.c | 4 +++- bld/trap/common/win/windigl.c | 4 +++- bld/wprof/c/utils.c | 4 +++- bld/wv/c/dbgfile.c | 13 ++++++++----- 30 files changed, 93 insertions(+), 56 deletions(-) diff --git a/bld/dig/c/dsx/dipld.c b/bld/dig/c/dsx/dipld.c index b245e2a4f3..4c3e5b18f2 100644 --- a/bld/dig/c/dsx/dipld.c +++ b/bld/dig/c/dsx/dipld.c @@ -63,7 +63,7 @@ dip_status DIPSysLoad( const char *base_name, dip_client_routines *cli, dip_imp_ char filename[_MAX_PATH]; *sys_hdl = NULL_SYSHDL; - if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, strlen( base_name ), ".dip", filename, sizeof( filename ) ) == 0 ) { + if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, 0, ".dip", filename, sizeof( filename ) ) == 0 ) { return( DS_ERR | DS_FOPEN_FAILED ); } fp = DIGLoader( Open )( filename ); diff --git a/bld/dig/c/dsx/madld.c b/bld/dig/c/dsx/madld.c index 7fe0f58d3e..77b3bb1140 100644 --- a/bld/dig/c/dsx/madld.c +++ b/bld/dig/c/dsx/madld.c @@ -62,7 +62,7 @@ mad_status MADSysLoad( const char *base_name, mad_client_routines *cli, char filename[256]; *sys_hdl = NULL_SYSHDL; - if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, strlen( base_name ), ".mad", filename, sizeof( filename ) ) == 0 ) { + if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, 0, ".mad", filename, sizeof( filename ) ) == 0 ) { return( MS_ERR | MS_FOPEN_FAILED ); } fp = DIGLoader( Open )( filename ); diff --git a/bld/dig/c/linux/dipld_so.c b/bld/dig/c/linux/dipld_so.c index 52088fc951..6d9a5f3a79 100644 --- a/bld/dig/c/linux/dipld_so.c +++ b/bld/dig/c/linux/dipld_so.c @@ -57,7 +57,7 @@ dip_status DIPSysLoad( const char *base_name, dip_client_routines *cli, dip_imp_ dip_status ds; *sys_hdl = NULL_SYSHDL; - if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, strlen( base_name ), ".so", filename, sizeof( filename ) ) == 0 ) { + if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, 0, ".so", filename, sizeof( filename ) ) == 0 ) { return( DS_ERR | DS_FOPEN_FAILED ); } mod_hdl = dlopen( filename, RTLD_NOW ); diff --git a/bld/dig/c/linux/madld_so.c b/bld/dig/c/linux/madld_so.c index b5dfa9f847..c2f1696ff7 100644 --- a/bld/dig/c/linux/madld_so.c +++ b/bld/dig/c/linux/madld_so.c @@ -58,7 +58,7 @@ mad_status MADSysLoad( const char *base_name, mad_client_routines *cli, mad_imp_ mad_status status; *sys_hdl = NULL_SYSHDL; - if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, strlen( base_name ), ".so", filename, sizeof( filename ) ) == 0 ) { + if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, 0, ".so", filename, sizeof( filename ) ) == 0 ) { return( MS_ERR | MS_FOPEN_FAILED ); } mod_hdl = dlopen( filename, RTLD_NOW ); diff --git a/bld/dig/c/nt/dipld.c b/bld/dig/c/nt/dipld.c index 46364e3859..e5a0fe348a 100644 --- a/bld/dig/c/nt/dipld.c +++ b/bld/dig/c/nt/dipld.c @@ -56,7 +56,7 @@ dip_status DIPSysLoad( const char *base_name, dip_client_routines *cli, dip_imp_ dip_status ds; *sys_hdl = NULL_SYSHDL; - if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, strlen( base_name ), ".dll", filename, sizeof( filename ) ) == 0 ) { + if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, 0, ".dll", filename, sizeof( filename ) ) == 0 ) { return( DS_ERR | DS_FOPEN_FAILED ); } mod_hdl = LoadLibrary( filename ); diff --git a/bld/dig/c/nt/madld.c b/bld/dig/c/nt/madld.c index fc2b63a5e2..2c1ff59a04 100644 --- a/bld/dig/c/nt/madld.c +++ b/bld/dig/c/nt/madld.c @@ -58,7 +58,7 @@ mad_status MADSysLoad( const char *base_name, mad_client_routines *cli, mad_imp_ mad_status status; *sys_hdl = NULL_SYSHDL; - if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, strlen( base_name ), ".dll", filename, sizeof( filename ) ) == 0 ) { + if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, 0, ".dll", filename, sizeof( filename ) ) == 0 ) { return( MS_ERR | MS_FOPEN_FAILED ); } mod_hdl = LoadLibrary( filename ); diff --git a/bld/dig/c/nt/pillld.c b/bld/dig/c/nt/pillld.c index 89a2aff150..09d5fe64f7 100644 --- a/bld/dig/c/nt/pillld.c +++ b/bld/dig/c/nt/pillld.c @@ -37,28 +37,30 @@ #include "pillimp.h" #include "pillctrl.h" -int PILLSysLoad( const char *path, const pill_client_routines *cli, +int PILLSysLoad( const char *base_name, const pill_client_routines *cli, link_handle *lh, link_message *msg ) { - HANDLE dll; + HANDLE mod_hdl; char filename[256]; pill_init_func *init_func; msg->source = NULL; msg->id = LM_SYSTEM_ERROR; - DIGLoader( Find )( DIG_FILETYPE_DBG, path, strlen( path ), ".dll", newpath, sizeof( newpath ) ); - dll = LoadLibrary( filename ); - if( dll == NULL ) { + if( DIGLoader( Find )( DIG_FILETYPE_DBG, base_name, 0, ".dll", filename, sizeof( filename ) ) == 0 ) { + return( 0 ); + } + mod_hdl = LoadLibrary( filename ); + if( mod_hdl == NULL ) { msg->data.code = GetLastError(); return( 0 ); } - init_func = (pill_init_func *)GetProcAddress( dll, "PILLLOAD" ); + init_func = (pill_init_func *)GetProcAddress( mod_hdl, "PILLLOAD" ); if( init_func == NULL ) { msg->data.code = GetLastError(); - FreeLibrary( dll ); + FreeLibrary( mod_hdl ); return( 0 ); } - lh->sys = (void *)dll; + lh->sys = (void *)mod_hdl; lh->rtns = init_func( cli, msg ); if( lh->rtns == NULL ) { /* don't free DLL yet, we need the message processor */ diff --git a/bld/dig/c/os2/dipld.c b/bld/dig/c/os2/dipld.c index 56ddde0609..803c82b9fc 100644 --- a/bld/dig/c/os2/dipld.c +++ b/bld/dig/c/os2/dipld.c @@ -71,9 +71,9 @@ dip_status DIPSysLoad( const char *base_name, dip_client_routines *cli, dip_imp_ * extension. We will search for them along the PATH (not in LIBPATH); */ #ifdef _M_I86 - if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, strlen( base_name ), ".DLL", filename, sizeof( filename ) ) == 0 ) { + if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, 0, ".DLL", filename, sizeof( filename ) ) == 0 ) { #else - if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, strlen( base_name ), ".D32", filename, sizeof( filename ) ) == 0 ) { + if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, 0, ".D32", filename, sizeof( filename ) ) == 0 ) { #endif return( DS_ERR | DS_FOPEN_FAILED ); } diff --git a/bld/dig/c/os2/madld.c b/bld/dig/c/os2/madld.c index 5f05ea96a0..848db01bb8 100644 --- a/bld/dig/c/os2/madld.c +++ b/bld/dig/c/os2/madld.c @@ -71,9 +71,9 @@ mad_status MADSysLoad( const char *base_name, mad_client_routines *cli, mad_imp_ * extension. We will search for them along the PATH (not in LIBPATH); */ #ifdef _M_I86 - if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, strlen( base_name ), ".DLL", filename, sizeof( filename ) ) == 0 ) { + if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, 0, ".DLL", filename, sizeof( filename ) ) == 0 ) { #else - if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, strlen( base_name ), ".D32", filename, sizeof( filename ) ) == 0 ) { + if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, 0, ".D32", filename, sizeof( filename ) ) == 0 ) { #endif return( MS_ERR | MS_FOPEN_FAILED ); } diff --git a/bld/dig/c/os2/pillld.c b/bld/dig/c/os2/pillld.c index 347f3fa544..7935700719 100644 --- a/bld/dig/c/os2/pillld.c +++ b/bld/dig/c/os2/pillld.c @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -38,24 +39,28 @@ #include "pillimp.h" #include "pillctrl.h" -int PILLSysLoad( const char *path, const pill_client_routines *cli, +int PILLSysLoad( const char *base_name, const pill_client_routines *cli, link_handle *lh, link_message *msg ) { - HMODULE dll; - pill_init_func *init_func; + HMODULE mod_hdl; + char filename[256]; + pill_init_func *init_func; msg->source = NULL; msg->id = LM_SYSTEM_ERROR; - msg->data.code = DosLoadModule( NULL, 0, path, &dll ); + if( DIGLoader( Find )( DIG_FILETYPE_DBG, base_name, 0, ".dll", filename, sizeof( filename ) ) == 0 ) { + return( 0 ); + } + msg->data.code = DosLoadModule( NULL, 0, filename, &mod_hdl ); if( msg->data.code != 0 ) { return( 0 ); } - msg->data.code = DosGetProcAddr( dll, "PILLLOAD", (PFN FAR *)&init_func ); + msg->data.code = DosGetProcAddr( mod_hdl, "PILLLOAD", (PFN FAR *)&init_func ); if( msg->data.code != 0 ) { - DosFreeModule( dll ); + DosFreeModule( mod_hdl ); return( 0 ); } - lh->sys = (void *)dll; + lh->sys = (void *)mod_hdl; lh->rtns = init_func( cli, msg ); if( lh->rtns == NULL ) { /* don't free DLL yet, we need the message processor */ diff --git a/bld/dig/c/qnx/pillld.c b/bld/dig/c/qnx/pillld.c index b0a29c8740..216d1f3ea6 100644 --- a/bld/dig/c/qnx/pillld.c +++ b/bld/dig/c/qnx/pillld.c @@ -52,7 +52,7 @@ int PILLSysLoad( const char *base_name, const pill_client_routines *cli, msg->source = NULL; msg->id = LM_SYSTEM_ERROR; - if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, strlen( base_name ), ".pil", filename, sizeof( filename ) ) == 0 ) { + if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, 0, ".pil", filename, sizeof( filename ) ) == 0 ) { return( 0 ); } fp = DIGLoader( Open )( filename ); diff --git a/bld/dig/c/rdos/dipld.c b/bld/dig/c/rdos/dipld.c index 8e3d6b74cd..935a555648 100644 --- a/bld/dig/c/rdos/dipld.c +++ b/bld/dig/c/rdos/dipld.c @@ -56,7 +56,7 @@ dip_status DIPSysLoad( const char *base_name, dip_client_routines *cli, dip_imp_ dip_status ds; *sys_hdl = NULL_SYSHDL; - if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, strlen( base_name ), ".dll", filename, sizeof( filename ) ) == 0 ) { + if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, 0, ".dll", filename, sizeof( filename ) ) == 0 ) { return( DS_ERR | DS_FOPEN_FAILED ); } mod_hdl = RdosLoadDll( filename ); diff --git a/bld/dig/c/rdos/madld.c b/bld/dig/c/rdos/madld.c index 0e51bc3ae4..644f6dc16a 100644 --- a/bld/dig/c/rdos/madld.c +++ b/bld/dig/c/rdos/madld.c @@ -58,7 +58,7 @@ mad_status MADSysLoad( const char *base_name, mad_client_routines *cli, mad_imp_ mad_status status; *sys_hdl = NULL_SYSHDL; - if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, strlen( base_name ), ".dll", filename, sizeof( filename ) ) == 0 ) { + if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, 0, ".dll", filename, sizeof( filename ) ) == 0 ) { return( MS_ERR | MS_FOPEN_FAILED ); } mod_hdl = RdosLoadDll( filename ); diff --git a/bld/dig/c/rdos/pillld.c b/bld/dig/c/rdos/pillld.c index af5a5316d0..b4ea7f325d 100644 --- a/bld/dig/c/rdos/pillld.c +++ b/bld/dig/c/rdos/pillld.c @@ -40,26 +40,27 @@ int PILLSysLoad( const char *path, const pill_client_routines *cli, link_handle *lh, link_message *msg ) { - int dll; + int mod_hdl; char filename[256]; pill_init_func *init_func; msg->source = NULL; msg->id = LM_SYSTEM_ERROR; - strcpy( filename, path ); - strcat( filename, ".dll" ); - dll = RdosLoadDll( filename ); - if( dll == NULL ) { + if( DIGLoader( Find )( DIG_FILETYPE_DBG, base_name, 0, ".dll", filename, sizeof( filename ) ) == 0 ) { + return( 0 ); + } + mod_hdl = RdosLoadDll( filename ); + if( mod_hdl == NULL ) { msg->data.code = -1; return( 0 ); } - init_func = RdosGetModuleProc( dll, "PILLLOAD" ); + lh->sys = (void *)mod_hdl; + init_func = RdosGetModuleProc( mod_hdl, "PILLLOAD" ); if( init_func == NULL ) { msg->data.code = -1; - RdosFreeDll( dll ); + PILLSysUnload( lh ); return( 0 ); } - lh->sys = (void *)dll; lh->rtns = init_func( cli, msg ); if( lh->rtns == NULL ) { /* don't free DLL yet, we need the message processor */ diff --git a/bld/dig/c/win/dipld.c b/bld/dig/c/win/dipld.c index 9685fe2574..10e9308ade 100644 --- a/bld/dig/c/win/dipld.c +++ b/bld/dig/c/win/dipld.c @@ -83,7 +83,7 @@ dip_status DIPSysLoad( const char *base_name, dip_client_routines *cli, dip_imp_ UINT prev; *sys_hdl = NULL_SYSHDL; - if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, strlen( base_name ), ".dll", filename, sizeof( filename ) ) == 0 ) { + if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, 0, ".dll", filename, sizeof( filename ) ) == 0 ) { return( DS_ERR | DS_FOPEN_FAILED ); } p = parm; diff --git a/bld/dig/c/win/madld.c b/bld/dig/c/win/madld.c index 78990a5209..5d375c2505 100644 --- a/bld/dig/c/win/madld.c +++ b/bld/dig/c/win/madld.c @@ -85,7 +85,7 @@ mad_status MADSysLoad( const char *base_name, mad_client_routines *cli, UINT prev; *sys_hdl = NULL_SYSHDL; - if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, strlen( base_name ), ".dll", filename, sizeof( filename ) ) == 0 ) { + if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, 0, ".dll", filename, sizeof( filename ) ) == 0 ) { return( MS_ERR | MS_FOPEN_FAILED ); } p = parm; diff --git a/bld/dip/dipdump/c/digcli.c b/bld/dip/dipdump/c/digcli.c index 0f65eded6c..c5a11b6ba1 100644 --- a/bld/dip/dipdump/c/digcli.c +++ b/bld/dip/dipdump/c/digcli.c @@ -212,8 +212,10 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base /* unused parameters */ (void)ftype; + if( base_name_len == 0 ) + base_name_len = strlen( base_name ); strncpy( fname, base_name, base_name_len ); - strcat( fname + base_name_len, defext ); + strcpy( fname + base_name_len, defext ); if( access( fname, F_OK ) == 0 ) { p = fname; } else if( path_list != NULL ) { diff --git a/bld/sdk/drwat/nt/digcli.c b/bld/sdk/drwat/nt/digcli.c index 1ef607d3f6..8e9ed8d288 100644 --- a/bld/sdk/drwat/nt/digcli.c +++ b/bld/sdk/drwat/nt/digcli.c @@ -231,8 +231,10 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base len = 0; if( filename_len > 0 ) { filename_len--; + if( base_name_len == 0 ) + base_name_len = strlen( base_name ); strncpy( fname, base_name, base_name_len ); - strcat( fname + base_name_len, defext ); + strcpy( fname + base_name_len, defext ); len = strlen( fname ); if( len > filename_len ) len = filename_len; diff --git a/bld/sdk/drwat/win/digcli.c b/bld/sdk/drwat/win/digcli.c index edd2db8649..e61e0d2f3b 100644 --- a/bld/sdk/drwat/win/digcli.c +++ b/bld/sdk/drwat/win/digcli.c @@ -234,8 +234,10 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base len = 0; if( filename_len > 0 ) { filename_len--; + if( base_name_len == 0 ) + base_name_len = strlen( base_name ); strncpy( fname, base_name, base_name_len ); - strcat( fname + base_name_len, defext ); + strcpy( fname + base_name_len, defext ); len = strlen( fname ); if( len > filename_len ) len = filename_len; diff --git a/bld/trap/common/dos/dosdigl.c b/bld/trap/common/dos/dosdigl.c index d7f1bcca94..6bbbf10270 100644 --- a/bld/trap/common/dos/dosdigl.c +++ b/bld/trap/common/dos/dosdigl.c @@ -54,8 +54,10 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base /* unused parameters */ (void)ftype; + if( base_name_len == 0 ) + base_name_len = strlen( base_name ); strncpy( fname, base_name, base_name_len ); - strcat( fname + base_name_len, defext ); + strcpy( fname + base_name_len, defext ); _searchenv( fname, "PATH", RWBuff ); len = strlen( RWBuff ); if( filename_len > 0 ) { diff --git a/bld/trap/common/linux/lnxdigl.c b/bld/trap/common/linux/lnxdigl.c index 38861642de..25b98102ba 100644 --- a/bld/trap/common/linux/lnxdigl.c +++ b/bld/trap/common/linux/lnxdigl.c @@ -50,8 +50,10 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base /* unused parameters */ (void)ftype; + if( base_name_len == 0 ) + base_name_len = strlen( base_name ); strncpy( fname, base_name, base_name_len ); - strcat( fname + base_name_len, defext ); + strcpy( fname + base_name_len, defext ); len = FindFilePath( DIG_FILETYPE_DBG, fname, RWBuff ); if( filename_len > 0 ) { filename_len--; diff --git a/bld/trap/common/nt/ntdigl.c b/bld/trap/common/nt/ntdigl.c index f9b0b4f14b..f1aa94993e 100644 --- a/bld/trap/common/nt/ntdigl.c +++ b/bld/trap/common/nt/ntdigl.c @@ -47,8 +47,10 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base /* unused parameters */ (void)ftype; + if( base_name_len == 0 ) + base_name_len = strlen( base_name ); strncpy( fname, base_name, base_name_len ); - strcat( fname + base_name_len, defext ); + strcpy( fname + base_name_len, defext ); _searchenv( fname, "PATH", RWBuff ); len = strlen( RWBuff ); if( filename_len > 0 ) { diff --git a/bld/trap/common/nto/ntodigl.c b/bld/trap/common/nto/ntodigl.c index 1e600702a9..9c41ca5d89 100644 --- a/bld/trap/common/nto/ntodigl.c +++ b/bld/trap/common/nto/ntodigl.c @@ -52,8 +52,10 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base /* unused parameters */ (void)ftype; + if( base_name_len == 0 ) + base_name_len = strlen( base_name ); strncpy( fname, base_name, base_name_len ); - strcat( fname + base_name_len, defext ); + strcpy( fname + base_name_len, defext ); len = FindFilePath( DIG_FILETYPE_DBG, fname, RWBuff ); if( filename_len > 0 ) { filename_len--; diff --git a/bld/trap/common/os2/os2digl.c b/bld/trap/common/os2/os2digl.c index 8a915f0825..088429eab1 100644 --- a/bld/trap/common/os2/os2digl.c +++ b/bld/trap/common/os2/os2digl.c @@ -47,8 +47,10 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base /* unused parameters */ (void)ftype; + if( base_name_len == 0 ) + base_name_len = strlen( base_name ); strncpy( fname, base_name, base_name_len ); - strcat( fname + base_name_len, defext ); + strcpy( fname + base_name_len, defext ); _searchenv( fname, "PATH", RWBuff ); len = strlen( RWBuff ); if( filename_len > 0 ) { diff --git a/bld/trap/common/os2v2/os22digl.c b/bld/trap/common/os2v2/os22digl.c index 884f833afb..b1d10400da 100644 --- a/bld/trap/common/os2v2/os22digl.c +++ b/bld/trap/common/os2v2/os22digl.c @@ -47,8 +47,10 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base /* unused parameters */ (void)ftype; + if( base_name_len == 0 ) + base_name_len = strlen( base_name ); strncpy( fname, base_name, base_name_len ); - strcat( fname + base_name_len, defext ); + strcpy( fname + base_name_len, defext ); _searchenv( fname, "PATH", RWBuff ); len = strlen( RWBuff ); if( filename_len > 0 ) { diff --git a/bld/trap/common/qnx/qnxdigl.c b/bld/trap/common/qnx/qnxdigl.c index 5c9f06ee9b..945a7aa05d 100644 --- a/bld/trap/common/qnx/qnxdigl.c +++ b/bld/trap/common/qnx/qnxdigl.c @@ -52,8 +52,10 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base /* unused parameters */ (void)ftype; + if( base_name_len == 0 ) + base_name_len = strlen( base_name ); strncpy( fname, base_name, base_name_len ); - strcat( fname + base_name_len, defext ); + strcpy( fname + base_name_len, defext ); len = FindFilePath( DIG_FILETYPE_DBG, fname, RWBuff ); if( filename_len > 0 ) { filename_len--; diff --git a/bld/trap/common/rdos/rdosdigl.c b/bld/trap/common/rdos/rdosdigl.c index 19b6450fa0..cde6154245 100644 --- a/bld/trap/common/rdos/rdosdigl.c +++ b/bld/trap/common/rdos/rdosdigl.c @@ -47,8 +47,10 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base /* unused parameters */ (void)ftype; + if( base_name_len == 0 ) + base_name_len = strlen( base_name ); strncpy( fname, base_name, base_name_len ); - strcat( fname + base_name_len, defext ); + strcpy( fname + base_name_len, defext ); _searchenv( fname, "PATH", RWBuff ); len = strlen( RWBuff ); if( filename_len > 0 ) { diff --git a/bld/trap/common/win/windigl.c b/bld/trap/common/win/windigl.c index 908fdc70ec..3fc43747d8 100644 --- a/bld/trap/common/win/windigl.c +++ b/bld/trap/common/win/windigl.c @@ -47,8 +47,10 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base /* unused parameters */ (void)ftype; + if( base_name_len == 0 ) + base_name_len = strlen( base_name ); strncpy( fname, base_name, base_name_len ); - strcat( fname + base_name_len, defext ); + strcpy( fname + base_name_len, defext ); _searchenv( fname, "PATH", RWBuff ); len = strlen( RWBuff ); if( filename_len > 0 ) { diff --git a/bld/wprof/c/utils.c b/bld/wprof/c/utils.c index 706cbbbeff..f9b2b4ffbb 100644 --- a/bld/wprof/c/utils.c +++ b/bld/wprof/c/utils.c @@ -160,8 +160,10 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base /* unused parameters */ (void)ftype; + if( base_name_len == 0 ) + base_name_len = strlen( base_name ); strncpy( fname, base_name, base_name_len ); - strcat( fname + base_name_len, defext ); + strcpy( fname + base_name_len, defext ); p = findFile( buffer, fname, FilePathList ); if( p == NULL ) { p = findFile( buffer, fname, DipExePathList ); diff --git a/bld/wv/c/dbgfile.c b/bld/wv/c/dbgfile.c index 958b93e22e..fd8aeef165 100644 --- a/bld/wv/c/dbgfile.c +++ b/bld/wv/c/dbgfile.c @@ -766,22 +766,25 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base char buffer[TXT_LEN]; char fname[TXT_LEN]; char *p; - bool has_ext; - bool has_path; - char c; char_ring *curr; size_t len; /* unused parameters */ (void)ftype; + if( base_name_len == 0 ) + base_name_len = strlen( base_name ); strncpy( fname, base_name, base_name_len ); strcpy( fname + base_name_len, defext ); - // check open file in current directory or in full path + /* + * check open file in current directory + */ if( access( fname, F_OK ) == 0 ) { p = fname; } else { p = ""; - // check open file in debugger directory list + /* + * check open file in debugger directory list + */ for( curr = LclPath; curr != NULL; curr = curr->next ) { if( MakeName( curr->name, fname, buffer, sizeof( buffer ) ) ) { if( access( buffer, F_OK ) == 0 ) { From 5a23310ca804c5033b7e18653cdfc638dfe72d22 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Tue, 29 Aug 2023 08:07:16 +0200 Subject: [PATCH 060/258] cleanup dig code --- bld/dig/c/linux/trpld_pe.c | 14 ++++++------- bld/dig/c/linux/trpld_so.c | 14 ++++++------- bld/dig/c/nt/trpld.c | 24 +++++++++++------------ bld/dig/c/os2/trpld.c | 20 +++++++++---------- bld/dig/c/rdos/trpld.c | 20 +++++++++---------- bld/dig/c/win/trpld.c | 40 +++++++++++++++++++------------------- bld/dip/dipdump/c/digcli.c | 4 +++- 7 files changed, 69 insertions(+), 67 deletions(-) diff --git a/bld/dig/c/linux/trpld_pe.c b/bld/dig/c/linux/trpld_pe.c index 1755ddc977..f58eabde1b 100644 --- a/bld/dig/c/linux/trpld_pe.c +++ b/bld/dig/c/linux/trpld_pe.c @@ -44,7 +44,7 @@ extern char **environ; #endif #if !defined( BUILTIN_TRAP_FILE ) -static PE_MODULE *TrapFile = NULL; +static PE_MODULE *mod_hdl = NULL; #endif static trap_fini_func *FiniFunc = NULL; @@ -69,9 +69,9 @@ void UnLoadTrap( void ) FiniFunc = NULL; } #if !defined( BUILTIN_TRAP_FILE ) - if( TrapFile != NULL ) { - PE_freeLibrary( TrapFile ); - TrapFile = NULL; + if( mod_hdl != NULL ) { + PE_freeLibrary( mod_hdl ); + mod_hdl = NULL; } #endif } @@ -112,13 +112,13 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) if( fp == NULL ) { return( buff ); } - TrapFile = PE_loadLibraryFile( fp, filename ); + mod_hdl = PE_loadLibraryFile( fp, filename ); DIGLoader( Close )( fp ); - if( TrapFile == NULL ) { + if( mod_hdl == NULL ) { return( buff ); } buff[0] = '\0'; - ld_func = (trap_load_func *)PE_getProcAddress( TrapFile, "TrapLoad_" ); + ld_func = (trap_load_func *)PE_getProcAddress( mod_hdl, "TrapLoad_" ); if( ld_func != NULL ) { #else buff[0] = '\0'; diff --git a/bld/dig/c/linux/trpld_so.c b/bld/dig/c/linux/trpld_so.c index cb4ed94167..e4d889b0a4 100644 --- a/bld/dig/c/linux/trpld_so.c +++ b/bld/dig/c/linux/trpld_so.c @@ -46,7 +46,7 @@ extern char **environ; #endif #if !defined( BUILTIN_TRAP_FILE ) -static void *TrapFile = NULL; +static void *mod_hdl = NULL; #endif static trap_fini_func *FiniFunc = NULL; @@ -71,9 +71,9 @@ void UnLoadTrap( void ) FiniFunc = NULL; } #if !defined( BUILTIN_TRAP_FILE ) - if( TrapFile != NULL ) { - dlclose( TrapFile ); - TrapFile = NULL; + if( mod_hdl != NULL ) { + dlclose( mod_hdl ); + mod_hdl = NULL; } #endif } @@ -114,14 +114,14 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) if( fp == NULL ) { return( buff ); } - TrapFile = dlopen( filename, RTLD_NOW ); + mod_hdl = dlopen( filename, RTLD_NOW ); DIGLoader( Close )( fp ); - if( TrapFile == NULL ) { + if( mod_hdl == NULL ) { puts( dlerror() ); return( buff ); } buff[0] = '\0'; - ld_func = (trap_load_func *)dlsym( TrapFile, "TrapLoad" ); + ld_func = (trap_load_func *)dlsym( mod_hdl, "TrapLoad" ); if( ld_func != NULL ) { #else buff[0] = '\0'; diff --git a/bld/dig/c/nt/trpld.c b/bld/dig/c/nt/trpld.c index ecdb59044a..17d55ef9ec 100644 --- a/bld/dig/c/nt/trpld.c +++ b/bld/dig/c/nt/trpld.c @@ -49,7 +49,7 @@ #include "_trpextf.h" #undef pick -static HANDLE TrapFile = 0; +static HANDLE mod_hdl = 0; static trap_fini_func *FiniFunc = NULL; bool TRAP_EXTFUNC( InfoFunction )( HWND hwnd ) @@ -89,9 +89,9 @@ void UnLoadTrap( void ) FiniFunc(); FiniFunc = NULL; } - if( TrapFile != 0 ) { - FreeLibrary( TrapFile ); - TrapFile = 0; + if( mod_hdl != 0 ) { + FreeLibrary( mod_hdl ); + mod_hdl = 0; } } @@ -117,18 +117,18 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) sprintf( buff, TC_ERR_CANT_LOAD_TRAP, base_name ); return( buff ); } - TrapFile = LoadLibrary( filename ); - if( TrapFile == NULL ) { + mod_hdl = LoadLibrary( filename ); + if( mod_hdl == NULL ) { sprintf( buff, TC_ERR_CANT_LOAD_TRAP, filename ); return( buff ); } buff[0] = '\0'; - init_func = (trap_init_func *)GetProcAddress( TrapFile, (LPSTR)1 ); - FiniFunc = (trap_fini_func *)GetProcAddress( TrapFile, (LPSTR)2 ); - ReqFunc = (trap_req_func *)GetProcAddress( TrapFile, (LPSTR)3 ); - TRAP_EXTFUNC_PTR( InfoFunction ) = (TRAP_EXTFUNC_TYPE( InfoFunction ))GetProcAddress( TrapFile, (LPSTR)4 ); - TRAP_EXTFUNC_PTR( InterruptProgram ) = (TRAP_EXTFUNC_TYPE( InterruptProgram ))GetProcAddress( TrapFile, (LPSTR)5 ); - TRAP_EXTFUNC_PTR( Terminate ) = (TRAP_EXTFUNC_TYPE( Terminate ))GetProcAddress( TrapFile, (LPSTR)6 ); + init_func = (trap_init_func *)GetProcAddress( mod_hdl, (LPSTR)1 ); + FiniFunc = (trap_fini_func *)GetProcAddress( mod_hdl, (LPSTR)2 ); + ReqFunc = (trap_req_func *)GetProcAddress( mod_hdl, (LPSTR)3 ); + TRAP_EXTFUNC_PTR( InfoFunction ) = (TRAP_EXTFUNC_TYPE( InfoFunction ))GetProcAddress( mod_hdl, (LPSTR)4 ); + TRAP_EXTFUNC_PTR( InterruptProgram ) = (TRAP_EXTFUNC_TYPE( InterruptProgram ))GetProcAddress( mod_hdl, (LPSTR)5 ); + TRAP_EXTFUNC_PTR( Terminate ) = (TRAP_EXTFUNC_TYPE( Terminate ))GetProcAddress( mod_hdl, (LPSTR)6 ); if( init_func != NULL && FiniFunc != NULL && ReqFunc != NULL ) { *trap_ver = init_func( parms, buff, trap_ver->remote ); if( buff[0] == '\0' ) { diff --git a/bld/dig/c/os2/trpld.c b/bld/dig/c/os2/trpld.c index 6cb8cb768a..02700cef5d 100644 --- a/bld/dig/c/os2/trpld.c +++ b/bld/dig/c/os2/trpld.c @@ -60,7 +60,7 @@ #include "_trpextf.h" #undef pick -static HMODULE TrapFile = 0; +static HMODULE mod_hdl = 0; static trap_fini_func *FiniFunc = NULL; bool IsTrapFilePumpingMessageQueue( void ) @@ -95,9 +95,9 @@ void UnLoadTrap( void ) FiniFunc(); FiniFunc = NULL; } - if( TrapFile != 0 ) { - DosFreeModule( TrapFile ); - TrapFile = 0; + if( mod_hdl != 0 ) { + DosFreeModule( mod_hdl ); + mod_hdl = 0; } } @@ -145,18 +145,18 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) sprintf( buff, TC_ERR_CANT_LOAD_TRAP, base_name ); return( buff ); } - if( LOAD_MODULE( filename, TrapFile ) ) { + if( LOAD_MODULE( filename, mod_hdl ) ) { sprintf( buff, TC_ERR_CANT_LOAD_TRAP, filename ); return( buff ); } buff[0] = '\0'; - if( GET_PROC_ADDRESS( TrapFile, 1, init_func ) - && GET_PROC_ADDRESS( TrapFile, 2, FiniFunc ) - && GET_PROC_ADDRESS( TrapFile, 3, ReqFunc ) ) { - if( !GET_PROC_ADDRESS( TrapFile, 4, TRAP_EXTFUNC_PTR( TellHandles ) ) ) { + if( GET_PROC_ADDRESS( mod_hdl, 1, init_func ) + && GET_PROC_ADDRESS( mod_hdl, 2, FiniFunc ) + && GET_PROC_ADDRESS( mod_hdl, 3, ReqFunc ) ) { + if( !GET_PROC_ADDRESS( mod_hdl, 4, TRAP_EXTFUNC_PTR( TellHandles ) ) ) { TRAP_EXTFUNC_PTR( TellHandles ) = NULL; } - if( !GET_PROC_ADDRESS( TrapFile, 5, TRAP_EXTFUNC_PTR( TellHardMode ) ) ) { + if( !GET_PROC_ADDRESS( mod_hdl, 5, TRAP_EXTFUNC_PTR( TellHardMode ) ) ) { TRAP_EXTFUNC_PTR( TellHardMode ) = NULL; } *trap_ver = init_func( parms, buff, trap_ver->remote ); diff --git a/bld/dig/c/rdos/trpld.c b/bld/dig/c/rdos/trpld.c index 4a7468ea7d..f85f5ab3df 100644 --- a/bld/dig/c/rdos/trpld.c +++ b/bld/dig/c/rdos/trpld.c @@ -39,7 +39,7 @@ #include "tcerr.h" -static int TrapFile = 0; +static int mod_hdl = 0; static trap_fini_func *FiniFunc = NULL; void UnLoadTrap( void ) @@ -49,9 +49,9 @@ void UnLoadTrap( void ) FiniFunc(); FiniFunc = NULL; } - if( TrapFile != 0 ) { - RdosFreeDll( TrapFile ); - TrapFile = 0; + if( mod_hdl != 0 ) { + RdosFreeDll( mod_hdl ); + mod_hdl = 0; } } @@ -77,16 +77,16 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) sprintf( buff, TC_ERR_CANT_LOAD_TRAP, base_name ); return( buff ); } - TrapFile = RdosLoadDll( filename ); - if( TrapFile == NULL ) { + mod_hdl = RdosLoadDll( filename ); + if( mod_hdl == NULL ) { sprintf( buff, TC_ERR_CANT_LOAD_TRAP, filename ); return( buff ); } buff[0] = '\0'; - init_func = RdosGetModuleProc( TrapFile, "TrapInit_" ); - FiniFunc = RdosGetModuleProc( TrapFile, "TrapFini_" ); - ReqFunc = RdosGetModuleProc( TrapFile, "TrapRequest_" ); -// LibListFunc = RdosGetModuleProc( TrapFile, "TrapLibList_" ); + init_func = RdosGetModuleProc( mod_hdl, "TrapInit_" ); + FiniFunc = RdosGetModuleProc( mod_hdl, "TrapFini_" ); + ReqFunc = RdosGetModuleProc( mod_hdl, "TrapRequest_" ); +// LibListFunc = RdosGetModuleProc( mod_hdl, "TrapLibList_" ); if( init_func != NULL && FiniFunc != NULL && ReqFunc != NULL /* && LibListFunc != NULL */ ) { *trap_ver = init_func( parms, buff, trap_ver->remote ); if( buff[0] == '\0' ) { diff --git a/bld/dig/c/win/trpld.c b/bld/dig/c/win/trpld.c index 68398797cc..77cc459b25 100644 --- a/bld/dig/c/win/trpld.c +++ b/bld/dig/c/win/trpld.c @@ -53,7 +53,7 @@ bool TrapHardModeRequired = false; static trap_fini_func *FiniFunc = NULL; -static HINSTANCE TrapFile = 0; +static HINSTANCE mod_hdl = 0; static HINSTANCE toolhelp = 0; void UnLoadTrap( void ) @@ -69,9 +69,9 @@ void UnLoadTrap( void ) FiniFunc(); FiniFunc = NULL; } - if( TrapFile != 0 ) { - FreeLibrary( TrapFile ); - TrapFile = 0; + if( mod_hdl != 0 ) { + FreeLibrary( mod_hdl ); + mod_hdl = 0; } if( toolhelp != 0 ) { FreeLibrary( toolhelp ); @@ -98,10 +98,6 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) } len++; } - if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, len, ".dll", filename, sizeof( filename ) ) == 0 ) { - sprintf( buff, TC_ERR_CANT_LOAD_TRAP, base_name ); - return( buff ); - } /* * load toolhelp since windows can't seem to handle having a static * reference to a dll inside a dynamically loaded dll @@ -110,24 +106,28 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) if( (UINT)toolhelp < 32 ) { toolhelp = 0; } + if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, len, ".dll", filename, sizeof( filename ) ) ) { + sprintf( buff, TC_ERR_CANT_LOAD_TRAP, base_name ); + return( buff ); + } prev = SetErrorMode( SEM_NOOPENFILEERRORBOX ); - TrapFile = LoadLibrary( filename ); + mod_hdl = LoadLibrary( filename ); SetErrorMode( prev ); - if( (UINT)TrapFile < 32 ) { - TrapFile = 0; + if( (UINT)mod_hdl < 32 ) { + mod_hdl = 0; sprintf( buff, TC_ERR_CANT_LOAD_TRAP, filename ); return( buff ); } buff[0] = '\0'; - init_func = (trap_init_func *)GetProcAddress( TrapFile, (LPSTR)2 ); - FiniFunc = (trap_fini_func *)GetProcAddress( TrapFile, (LPSTR)3 ); - ReqFunc = (trap_req_func *)GetProcAddress( TrapFile, (LPSTR)4 ); - TRAP_EXTFUNC_PTR( InputHook ) = (TRAP_EXTFUNC_TYPE( InputHook ))GetProcAddress( TrapFile, (LPSTR)5 ); - TRAP_EXTFUNC_PTR( InfoFunction ) = (TRAP_EXTFUNC_TYPE( InfoFunction ))GetProcAddress( TrapFile, (LPSTR)6 ); - TRAP_EXTFUNC_PTR( HardModeCheck ) = (TRAP_EXTFUNC_TYPE( HardModeCheck ))GetProcAddress( TrapFile, (LPSTR)7 ); - TRAP_EXTFUNC_PTR( GetHwndFunc ) = (TRAP_EXTFUNC_TYPE( GetHwndFunc ))GetProcAddress( TrapFile, (LPSTR)8 ); - TRAP_EXTFUNC_PTR( SetHardMode ) = (TRAP_EXTFUNC_TYPE( SetHardMode ))GetProcAddress( TrapFile, (LPSTR)12 ); - TRAP_EXTFUNC_PTR( UnLockInput ) = (TRAP_EXTFUNC_TYPE( UnLockInput ))GetProcAddress( TrapFile, (LPSTR)13 ); + init_func = (trap_init_func *)GetProcAddress( mod_hdl, (LPSTR)2 ); + FiniFunc = (trap_fini_func *)GetProcAddress( mod_hdl, (LPSTR)3 ); + ReqFunc = (trap_req_func *)GetProcAddress( mod_hdl, (LPSTR)4 ); + TRAP_EXTFUNC_PTR( InputHook ) = (TRAP_EXTFUNC_TYPE( InputHook ))GetProcAddress( mod_hdl, (LPSTR)5 ); + TRAP_EXTFUNC_PTR( InfoFunction ) = (TRAP_EXTFUNC_TYPE( InfoFunction ))GetProcAddress( mod_hdl, (LPSTR)6 ); + TRAP_EXTFUNC_PTR( HardModeCheck ) = (TRAP_EXTFUNC_TYPE( HardModeCheck ))GetProcAddress( mod_hdl, (LPSTR)7 ); + TRAP_EXTFUNC_PTR( GetHwndFunc ) = (TRAP_EXTFUNC_TYPE( GetHwndFunc ))GetProcAddress( mod_hdl, (LPSTR)8 ); + TRAP_EXTFUNC_PTR( SetHardMode ) = (TRAP_EXTFUNC_TYPE( SetHardMode ))GetProcAddress( mod_hdl, (LPSTR)12 ); + TRAP_EXTFUNC_PTR( UnLockInput ) = (TRAP_EXTFUNC_TYPE( UnLockInput ))GetProcAddress( mod_hdl, (LPSTR)13 ); if( init_func != NULL && FiniFunc != NULL && ReqFunc != NULL ) { *trap_ver = init_func( parms, buff, trap_ver->remote ); if( buff[0] == '\0' ) { diff --git a/bld/dip/dipdump/c/digcli.c b/bld/dip/dipdump/c/digcli.c index c5a11b6ba1..b6ef467c5e 100644 --- a/bld/dip/dipdump/c/digcli.c +++ b/bld/dip/dipdump/c/digcli.c @@ -70,7 +70,9 @@ FILE *DIGCLIENTRY( Open )( char const *name, dig_open mode ) { const char *fmode; - /* convert flags. */ + /* + * convert flags. + */ switch( mode & (DIG_OPEN_READ | DIG_OPEN_WRITE) ) { case DIG_OPEN_READ: fmode = "rb"; From 99cac8280f8222346acb463d3a84a1abf3343e73 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Tue, 29 Aug 2023 22:43:47 +0200 Subject: [PATCH 061/258] add new environment variable WD_PATH20 to debugger it is add to front of search directories to enable override location of debugger files it simplify debuging of OW debugger by OW debugger --- bld/dip/dipdump/c/digcli.c | 16 +++++++++++----- bld/dip/dipdump/c/dipdump.c | 19 +++++++------------ bld/dip/dipdump/dipdump.mif | 2 ++ bld/dip/dipdump/nt386/makefile | 2 +- bld/dip/dipdump/os2386/makefile | 2 +- bld/sdk/drwat/master.mif | 2 +- bld/sdk/drwat/nt/digcli.c | 6 ++++++ bld/sdk/drwat/win/digcli.c | 6 ++++++ bld/trap/common/dos/dosdigl.c | 7 ++++++- bld/trap/common/linux/lnxpath.c | 6 ++++++ bld/trap/common/nt/ntdigl.c | 6 ++++++ bld/trap/common/nto/ntopath.c | 6 ++++++ bld/trap/common/os2/os2digl.c | 6 ++++++ bld/trap/common/os2v2/os22digl.c | 6 ++++++ bld/trap/common/qnx/qnxpath.c | 6 ++++++ bld/trap/common/rdos/rdosdigl.c | 6 ++++++ bld/trap/common/servio.h | 3 +++ bld/trap/common/win/windigl.c | 6 ++++++ bld/trap/lcl/os2v2/splice/makefile | 2 +- bld/trap/master.mif | 2 +- bld/wprof/c/utils.c | 10 ++++++++++ bld/wprof/master.mif | 2 +- bld/wv/c/dbgfile.c | 14 ++++++++++++-- bld/wv/master.mif | 2 +- bld/wv/utils/trap2txt/master.mif | 2 +- 25 files changed, 119 insertions(+), 28 deletions(-) diff --git a/bld/dip/dipdump/c/digcli.c b/bld/dip/dipdump/c/digcli.c index b6ef467c5e..a76d02a4b7 100644 --- a/bld/dip/dipdump/c/digcli.c +++ b/bld/dip/dipdump/c/digcli.c @@ -35,6 +35,7 @@ #include #include #include "bool.h" +#include "wio.h" #include "iopath.h" #include "digcli.h" #include "digld.h" @@ -42,14 +43,15 @@ #include "dipdump.h" -#if defined( __UNIX__ ) || defined( __DOS__ ) +#define QQSTR(x) # x +#define QSTR(x) QQSTR(x) + typedef struct char_ring { struct char_ring *next; char name[1]; } char_ring; static char *FilePathList = NULL; -#endif void *DIGCLIENTRY( Alloc )( size_t amount ) { @@ -139,8 +141,6 @@ unsigned DIGCLIENTRY( MachineData )( address addr, dig_info_type info_type, dig_ return( 0 ); /// @todo check this out out. } -#if defined( __UNIX__ ) || defined( __DOS__ ) - static char *addPath( char *old_list, const char *path_list ) /***********************************************************/ { @@ -177,6 +177,9 @@ void PathInit( void ) char buff[_MAX_PATH]; char *p; +#ifdef BLDVER + FilePathList = addPath( FilePathList, getenv( "WD_PATH" QSTR( BLDVER ) ) ); +#endif if( _cmdname( buff ) != NULL ) { #if defined( __UNIX__ ) p = strrchr( buff, '/' ); @@ -207,13 +210,14 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base { char fullname[_MAX_PATH2]; char fname[_MAX_PATH2]; - FILE *fp; char *p; char c; size_t len; + const char *path_list; /* unused parameters */ (void)ftype; + path_list = FilePathList; if( base_name_len == 0 ) base_name_len = strlen( base_name ); strncpy( fname, base_name, base_name_len ); @@ -258,6 +262,8 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base return( len ); } +#if defined( __UNIX__ ) || defined( __DOS__ ) + FILE *DIGLoader( Open )( const char *filename ) /*********************************************/ { diff --git a/bld/dip/dipdump/c/dipdump.c b/bld/dip/dipdump/c/dipdump.c index e8e3efedf2..5661bcdebb 100644 --- a/bld/dip/dipdump/c/dipdump.c +++ b/bld/dip/dipdump/c/dipdump.c @@ -751,14 +751,10 @@ static int DumpIt( const char *file, mod_handle mh, process_info *proc ) { walk_result walkres; struct stat s; - char buff[1024]; - unsigned len; int i; /* unused parameters */ (void)proc; - /* unused variables */ (void)len; (void)buff; - /* * Module. */ @@ -781,10 +777,13 @@ static int DumpIt( const char *file, mod_handle mh, process_info *proc ) /* * crashes codeview, nothing on dwarf. */ - buff[0] = '\0'; - len = DIPModName( mh, buff, sizeof( buff ) ); - if( len ) { - printf( "module name = %s\n", buff ); + { + char buff[1024]; + + buff[0] = '\0'; + if( DIPModName( mh, buff, sizeof( buff ) ) ) { + printf( "module name = %s\n", buff ); + } } #endif printf( "\n" @@ -1028,9 +1027,7 @@ int main( int argc, char **argv ) } #endif -#if defined( __UNIX__ ) || defined( __DOS__ ) PathInit(); -#endif /* * Try to dump debug info for all remaining arguments */ @@ -1043,8 +1040,6 @@ int main( int argc, char **argv ) } ++optind; } -#if defined( __UNIX__ ) || defined( __DOS__ ) PathFini(); -#endif return( rc ); } diff --git a/bld/dip/dipdump/dipdump.mif b/bld/dip/dipdump/dipdump.mif index ea56353418..50e7307e8d 100644 --- a/bld/dip/dipdump/dipdump.mif +++ b/bld/dip/dipdump/dipdump.mif @@ -24,6 +24,8 @@ dipdump_autodepends = .AUTODEPEND inc_dirs = -I"../h" -I"$(dig_dir)/h" +extra_cpp_flags = -DBLDVER=$(bld_ver) + # explicit rules ################# diff --git a/bld/dip/dipdump/nt386/makefile b/bld/dip/dipdump/nt386/makefile index 758e3350e3..dfb6eba99a 100644 --- a/bld/dip/dipdump/nt386/makefile +++ b/bld/dip/dipdump/nt386/makefile @@ -1,4 +1,4 @@ -#pmake: nobuild os_nt cpu_386 +#pmake: build os_nt cpu_386 host_os = nt host_cpu = 386 diff --git a/bld/dip/dipdump/os2386/makefile b/bld/dip/dipdump/os2386/makefile index 6fc13e802e..82f330b781 100644 --- a/bld/dip/dipdump/os2386/makefile +++ b/bld/dip/dipdump/os2386/makefile @@ -1,4 +1,4 @@ -#pmake: nobuild os_os2 cpu_386 +#pmake: build os_os2 cpu_386 host_os = os2 host_cpu = 386 diff --git a/bld/sdk/drwat/master.mif b/bld/sdk/drwat/master.mif index b71be66b34..36a9b1bc24 100644 --- a/bld/sdk/drwat/master.mif +++ b/bld/sdk/drwat/master.mif @@ -35,7 +35,7 @@ common_dir = ../../common inc_dirs = -I. -I"../$(host_os)" -I"../h" -I"$(dig_dir)/h" $(dis_includes) $(commonui_inc_dirs) -extra_cpp_flags = $(dig_arch_cpp_flags) +extra_cpp_flags = $(dig_arch_cpp_flags) -DBLDVER=$(bld_ver) !ifeq drwatcom_95 1 extra_cpp_flags += -DCHICAGO !endif diff --git a/bld/sdk/drwat/nt/digcli.c b/bld/sdk/drwat/nt/digcli.c index 8e9ed8d288..f6bfca7d74 100644 --- a/bld/sdk/drwat/nt/digcli.c +++ b/bld/sdk/drwat/nt/digcli.c @@ -45,6 +45,9 @@ #include "clibext.h" +#define QQSTR(x) # x +#define QSTR(x) QQSTR(x) + void *DIGCLIENTRY( Alloc )( size_t size ) /**************************************** * DIGCliAlloc @@ -235,6 +238,9 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base base_name_len = strlen( base_name ); strncpy( fname, base_name, base_name_len ); strcpy( fname + base_name_len, defext ); +#ifdef BLDVER + _searchenv( fname, "WD_PATH" QSTR( BLDVER ), fname ); +#endif len = strlen( fname ); if( len > filename_len ) len = filename_len; diff --git a/bld/sdk/drwat/win/digcli.c b/bld/sdk/drwat/win/digcli.c index e61e0d2f3b..0ad235d133 100644 --- a/bld/sdk/drwat/win/digcli.c +++ b/bld/sdk/drwat/win/digcli.c @@ -49,6 +49,9 @@ //#define DEBUGOUT( x ) LBPrintf( ListBox, x ); #define DEBUGOUT( x ) +#define QQSTR(x) # x +#define QSTR(x) QQSTR(x) + #if 0 FILE *PathOpen( char *name, unsigned len, const char *ext ) { @@ -238,6 +241,9 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base base_name_len = strlen( base_name ); strncpy( fname, base_name, base_name_len ); strcpy( fname + base_name_len, defext ); +#ifdef BLDVER + _searchenv( fname, "WD_PATH" QSTR( BLDVER ), fname ); +#endif len = strlen( fname ); if( len > filename_len ) len = filename_len; diff --git a/bld/trap/common/dos/dosdigl.c b/bld/trap/common/dos/dosdigl.c index 6bbbf10270..2fc5d7afef 100644 --- a/bld/trap/common/dos/dosdigl.c +++ b/bld/trap/common/dos/dosdigl.c @@ -44,7 +44,6 @@ #define HANDLE2FP(ph) ((FILE *)((unsigned long)(ph) + 1)) #define FP2HANDLE(fp) ((int)((unsigned long)(fp) - 1)) - size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base_name_len, const char *defext, char *filename, size_t filename_len ) /****************************************************************************************/ @@ -58,7 +57,13 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base base_name_len = strlen( base_name ); strncpy( fname, base_name, base_name_len ); strcpy( fname + base_name_len, defext ); +#ifdef BLDVER + _searchenv( fname, "WD_PATH" QSTR( BLDVER ), RWBuff ); + if( *RWBuff == '\0' ) + _searchenv( fname, "PATH", RWBuff ); +#else _searchenv( fname, "PATH", RWBuff ); +#endif len = strlen( RWBuff ); if( filename_len > 0 ) { filename_len--; diff --git a/bld/trap/common/linux/lnxpath.c b/bld/trap/common/linux/lnxpath.c index 5bdc816b11..6d1aeb25f5 100644 --- a/bld/trap/common/linux/lnxpath.c +++ b/bld/trap/common/linux/lnxpath.c @@ -37,6 +37,7 @@ #include #include "digtypes.h" #include "lnxpath.h" +#include "servio.h" char *StrCopyDst( const char *src, char *dst ) @@ -100,6 +101,11 @@ size_t FindFilePath( dig_filetype file_type, const char *name, char *result ) if( stat( name, &tmp ) == 0 ) { return( StrCopyDst( name, result ) - result ); } +#ifdef BLDVER + len = tryOnePath( getenv( "WD_PATH" QSTR( BLDVER ) ), &tmp, name, result ); + if( len != 0 ) + return( len ); +#endif if( file_type == DIG_FILETYPE_EXE ) { return( tryOnePath( getenv( "PATH" ), &tmp, name, result ) ); } else { diff --git a/bld/trap/common/nt/ntdigl.c b/bld/trap/common/nt/ntdigl.c index f1aa94993e..f93787fd53 100644 --- a/bld/trap/common/nt/ntdigl.c +++ b/bld/trap/common/nt/ntdigl.c @@ -51,7 +51,13 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base base_name_len = strlen( base_name ); strncpy( fname, base_name, base_name_len ); strcpy( fname + base_name_len, defext ); +#ifdef BLDVER + _searchenv( fname, "WD_PATH" QSTR( BLDVER ), RWBuff ); + if( *RWBuff == '\0' ) + _searchenv( fname, "PATH", RWBuff ); +#else _searchenv( fname, "PATH", RWBuff ); +#endif len = strlen( RWBuff ); if( filename_len > 0 ) { filename_len--; diff --git a/bld/trap/common/nto/ntopath.c b/bld/trap/common/nto/ntopath.c index e5a4e0eb34..bc93338091 100644 --- a/bld/trap/common/nto/ntopath.c +++ b/bld/trap/common/nto/ntopath.c @@ -36,6 +36,7 @@ #include #include "digtypes.h" #include "ntopath.h" +#include "servio.h" #include "clibext.h" @@ -101,6 +102,11 @@ size_t FindFilePath( dig_filetype file_type, const char *name, char *result ) if( stat( name, &tmp ) == 0 ) { return( StrCopyDst( name, result ) - result ); } +#ifdef BLDVER + len = tryOnePath( getenv( "WD_PATH" QSTR( BLDVER ) ), &tmp, name, result ); + if( len != 0 ) + return( len ); +#endif if( file_type == DIG_FILETYPE_EXE ) { return( tryOnePath( getenv( "PATH" ), &tmp, name, result ) ); } else { diff --git a/bld/trap/common/os2/os2digl.c b/bld/trap/common/os2/os2digl.c index 088429eab1..d1595473d5 100644 --- a/bld/trap/common/os2/os2digl.c +++ b/bld/trap/common/os2/os2digl.c @@ -51,7 +51,13 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base base_name_len = strlen( base_name ); strncpy( fname, base_name, base_name_len ); strcpy( fname + base_name_len, defext ); +#ifdef BLDVER + _searchenv( fname, "WD_PATH" QSTR( BLDVER ), RWBuff ); + if( *RWBuff == '\0' ) + _searchenv( fname, "PATH", RWBuff ); +#else _searchenv( fname, "PATH", RWBuff ); +#endif len = strlen( RWBuff ); if( filename_len > 0 ) { filename_len--; diff --git a/bld/trap/common/os2v2/os22digl.c b/bld/trap/common/os2v2/os22digl.c index b1d10400da..061bc471ee 100644 --- a/bld/trap/common/os2v2/os22digl.c +++ b/bld/trap/common/os2v2/os22digl.c @@ -51,7 +51,13 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base base_name_len = strlen( base_name ); strncpy( fname, base_name, base_name_len ); strcpy( fname + base_name_len, defext ); +#ifdef BLDVER + _searchenv( fname, "WD_PATH" QSTR( BLDVER ), RWBuff ); + if( *RWBuff == '\0' ) + _searchenv( fname, "PATH", RWBuff ); +#else _searchenv( fname, "PATH", RWBuff ); +#endif len = strlen( RWBuff ); if( filename_len > 0 ) { filename_len--; diff --git a/bld/trap/common/qnx/qnxpath.c b/bld/trap/common/qnx/qnxpath.c index 6153a87f4f..b6add2fab0 100644 --- a/bld/trap/common/qnx/qnxpath.c +++ b/bld/trap/common/qnx/qnxpath.c @@ -37,6 +37,7 @@ #include #include "digtypes.h" #include "qnxpath.h" +#include "servio.h" char *StrCopyDst( const char *src, char *dst ) @@ -100,6 +101,11 @@ size_t FindFilePath( dig_filetype file_type, const char *name, char *result ) if( stat( name, &tmp ) == 0 ) { return( StrCopyDst( name, result ) - result ); } +#ifdef BLDVER + len = tryOnePath( getenv( "WD_PATH" QSTR( BLDVER ) ), &tmp, name, result ); + if( len != 0 ) + return( len ); +#endif if( file_type == DIG_FILETYPE_EXE ) { return( tryOnePath( getenv( "PATH" ), &tmp, name, result ) ); } else { diff --git a/bld/trap/common/rdos/rdosdigl.c b/bld/trap/common/rdos/rdosdigl.c index cde6154245..2e42de3745 100644 --- a/bld/trap/common/rdos/rdosdigl.c +++ b/bld/trap/common/rdos/rdosdigl.c @@ -51,7 +51,13 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base base_name_len = strlen( base_name ); strncpy( fname, base_name, base_name_len ); strcpy( fname + base_name_len, defext ); +#ifdef BLDVER + _searchenv( fname, "WD_PATH" QSTR( BLDVER ), RWBuff ); + if( *RWBuff == '\0' ) + _searchenv( fname, "PATH", RWBuff ); +#else _searchenv( fname, "PATH", RWBuff ); +#endif len = strlen( RWBuff ); if( filename_len > 0 ) { filename_len--; diff --git a/bld/trap/common/servio.h b/bld/trap/common/servio.h index c86b5b30f9..9d957f414e 100644 --- a/bld/trap/common/servio.h +++ b/bld/trap/common/servio.h @@ -34,6 +34,9 @@ #define PARMS_MAXLEN 256 +#define QQSTR(x) # x +#define QSTR(x) QQSTR(x) + extern char ServUsage[]; extern char RWBuff[0x400]; diff --git a/bld/trap/common/win/windigl.c b/bld/trap/common/win/windigl.c index 3fc43747d8..f889dfc03b 100644 --- a/bld/trap/common/win/windigl.c +++ b/bld/trap/common/win/windigl.c @@ -51,7 +51,13 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base base_name_len = strlen( base_name ); strncpy( fname, base_name, base_name_len ); strcpy( fname + base_name_len, defext ); +#ifdef BLDVER + _searchenv( fname, "WD_PATH" QSTR( BLDVER ), RWBuff ); + if( *RWBuff == '\0' ) + _searchenv( fname, "PATH", RWBuff ); +#else _searchenv( fname, "PATH", RWBuff ); +#endif len = strlen( RWBuff ); if( filename_len > 0 ) { filename_len--; diff --git a/bld/trap/lcl/os2v2/splice/makefile b/bld/trap/lcl/os2v2/splice/makefile index f3d47fc1d3..f43a23fd1b 100644 --- a/bld/trap/lcl/os2v2/splice/makefile +++ b/bld/trap/lcl/os2v2/splice/makefile @@ -31,7 +31,7 @@ dig_arch = $(host_cpu) inc_dirs = -I"../h" -I"$(trap_dir)/h" -I"$(dig_dir)/h" -extra_cpp_flags = $(dig_arch_cpp_flags) +extra_cpp_flags = $(dig_arch_cpp_flags) -DBLDVER=$(bld_ver) # # lflags diff --git a/bld/trap/master.mif b/bld/trap/master.mif index d20c19a512..51deba87b6 100644 --- a/bld/trap/master.mif +++ b/bld/trap/master.mif @@ -146,7 +146,7 @@ dig_arch = $(target_cpu) # cflags stuff ############### -extra_cpp_flags = -D$(which) $(dig_arch_cpp_flags) $(extra_cppflags) +extra_cpp_flags = -D$(which) $(dig_arch_cpp_flags) -DBLDVER=$(bld_ver) $(extra_cppflags) !ifndef test !ifdef builtin_trap extra_cpp_flags += -DBUILTIN_TRAP_FILE diff --git a/bld/wprof/c/utils.c b/bld/wprof/c/utils.c index f9b2b4ffbb..a928d1b42e 100644 --- a/bld/wprof/c/utils.c +++ b/bld/wprof/c/utils.c @@ -82,6 +82,9 @@ #endif #define HELP_NAME "WWINHELP" +#define QQSTR(x) # x +#define QSTR(x) QQSTR(x) + char *HelpPathList = NULL; char *FilePathList = NULL; char *DipExePathList = NULL; @@ -247,6 +250,13 @@ void InitPaths( void ) watcom_setup_env(); +#ifdef BLDVER + env = getenv( "WD_PATH" QSTR( BLDVER ) ); + FilePathList = AddPath( FilePathList, env ); + #if defined(__UNIX__) + DipExePathList = AddPath( DipExePathList, env ); + #endif +#endif env = getenv( PATH_NAME ); FilePathList = AddPath( FilePathList, env ); HelpPathList = AddPath( HelpPathList, env ); diff --git a/bld/wprof/master.mif b/bld/wprof/master.mif index b759824b87..f1bb8a7e6c 100644 --- a/bld/wprof/master.mif +++ b/bld/wprof/master.mif @@ -33,7 +33,7 @@ dig_arch = all inc_dirs = -I"../h" -I"$(wsample_dir)/h" $(aui_inc_dirs) $(gui_inc_dirs) $(ui_inc_dirs) & $(commonui_inc_dirs) $(wpi_inc_dirs) $(hlpview_inc_dirs) -I"$(dig_dir)/h" -extra_cpp_flags = $(dig_arch_cpp_flags) +extra_cpp_flags = $(dig_arch_cpp_flags) -DBLDVER=$(bld_ver) !ifeq sys_windowed 1 extra_cpp_flags += -DGUI_IS_GUI extra_cpp_flags_os2 = -D__OS2_PM__ diff --git a/bld/wv/c/dbgfile.c b/bld/wv/c/dbgfile.c index fd8aeef165..0bc6a1067f 100644 --- a/bld/wv/c/dbgfile.c +++ b/bld/wv/c/dbgfile.c @@ -77,6 +77,9 @@ #define ISREMOTE(x) ((x & REMOTE_IND) != 0) #define SETREMOTE(x) x |= REMOTE_IND +#define QQSTR(x) # x +#define QSTR(x) QQSTR(x) + static char_ring *LclPath; static sys_handle SysHandles[MAX_OPENS]; @@ -455,12 +458,16 @@ file_handle LclFileToFullName( const char *name, size_t name_len, char *full ) file_handle fh; size_t path_len; - // check open file in current directory or in full path + /* + * check open file in current directory or in full path + */ MakeNameWithPath( OP_LOCAL, NULL, 0, name, name_len, full ); fh = FileOpen( full, OP_READ ); if( fh != NIL_HANDLE ) return( fh ); - // check open file in debugger directory list + /* + * check open file in debugger directory list + */ for( curr = LclPath; curr != NULL; curr = curr->next ) { path_len = strlen( curr->name ); MakeNameWithPath( OP_LOCAL, curr->name, path_len, name, name_len, full ); @@ -709,6 +716,9 @@ void PathInit( void ) char *p; // parsePathList( &LclPath, "." ); + #ifdef BLDVER + parseEnvVar( &LclPath, "WD_PATH" QSTR( BLDVER ) ); + #endif parseEnvVar( &LclPath, "WD_PATH" ); parseEnvVar( &LclPath, "HOME" ); if( _cmdname( cmd ) != NULL ) { diff --git a/bld/wv/master.mif b/bld/wv/master.mif index b5706380c6..b0f22ef031 100644 --- a/bld/wv/master.mif +++ b/bld/wv/master.mif @@ -86,7 +86,7 @@ inc_dirs += -I"$(gui_dir)/ui/h" inc_dirs += -I"$(ncurses_dir)/h" !endif -extra_cpp_flags = $(dig_arch_cpp_flags) +extra_cpp_flags = $(dig_arch_cpp_flags) -DBLDVER=$(bld_ver) !ifdef wv_engine_noui extra_cpp_flags += -D__NOUI__ !endif diff --git a/bld/wv/utils/trap2txt/master.mif b/bld/wv/utils/trap2txt/master.mif index dfd9cdf1f6..d7eb382ada 100644 --- a/bld/wv/utils/trap2txt/master.mif +++ b/bld/wv/utils/trap2txt/master.mif @@ -14,7 +14,7 @@ dig_arch = $(host_cpu) inc_dirs = -I"../h" -I"$(dip_dir)/watcom/h" -I"$(dig_dir)/h" -extra_cpp_flags = $(dig_arch_cpp_flags) +extra_cpp_flags = $(dig_arch_cpp_flags) -DBLDVER=$(bld_ver) .cpp: ../c From 22be1a31905d5e0e34e81edcd8eefbdd37c383ed Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Wed, 30 Aug 2023 18:32:21 +0200 Subject: [PATCH 062/258] fix CRTL to use only __CHK symbol instead old __STK --- bld/clib/startup/a/tnksto32.asm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bld/clib/startup/a/tnksto32.asm b/bld/clib/startup/a/tnksto32.asm index 86d44baf72..c5779d1739 100644 --- a/bld/clib/startup/a/tnksto32.asm +++ b/bld/clib/startup/a/tnksto32.asm @@ -2,6 +2,7 @@ ;* ;* Open Watcom Project ;* +;* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. ;* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. ;* ;* ======================================================================== @@ -37,7 +38,7 @@ assume nothing -extrn __STK : near +extrn __CHK : near extrn "C",__init_threadstksize : near DGROUP group STACK @@ -71,7 +72,8 @@ __TNC proc near export mov eax,8[esp] ; get local size add eax,12[esp] ; add parm size add eax,8*1024 ; add 8k - call __STK ; check the stack + push eax ; push parameter + call __CHK ; check the stack pop eax ; ... __TNK proc near export push eax ; ... From 79440615221ef3c34fa2986c0e6f6657e0ec3fba Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Wed, 30 Aug 2023 19:32:19 +0200 Subject: [PATCH 063/258] optimize CRTL __CHK routine not use old __STK __STK routine is for backward compatibility with old Watcom code --- bld/clib/startup/a/stk386.asm | 20 ++++++++++++-------- bld/clib/startup/a/stkl32.asm | 5 ++--- bld/clib/startup/a/stko32.asm | 25 +++++++++++++------------ bld/clib/startup/a/stkq32.asm | 4 ++-- bld/clib/startup/a/stkrdu.asm | 23 +++++++++++++---------- bld/clib/startup/a/stkwnt.asm | 23 +++++++++++++---------- 6 files changed, 55 insertions(+), 45 deletions(-) diff --git a/bld/clib/startup/a/stk386.asm b/bld/clib/startup/a/stk386.asm index 117987edc8..112455dd1a 100644 --- a/bld/clib/startup/a/stk386.asm +++ b/bld/clib/startup/a/stk386.asm @@ -2,6 +2,7 @@ ;* ;* Open Watcom Project ;* +;* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. ;* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. ;* ;* ======================================================================== @@ -55,18 +56,18 @@ enddata ret ; return endproc _init_stk - defpe __CHK - xchg eax,4[esp] - call __STK - mov eax,4[esp] - ret 4 - endproc __CHK - defpe __GRO ret 4 endproc __GRO defpe __STK + xchg eax,[esp] ; exchange parm with return addr + push eax ; push return addr + ; fall into __CHK + + defpe __CHK + push eax ; save eax + mov eax,8[esp] ; get parameter _guess ; guess: no overflow cmp eax,esp ; - check if user asking for too much _quif ae ; quit if user asking for too much @@ -80,8 +81,10 @@ enddata cmp ax,SS_seg ; - - see if SS has been changed _endif ; - endif _quif e ; quit if too much - ret ; - return (running with a different stack) + pop eax ; - restore EAX + ret 4 ; - return (running with a different stack) _endguess ; endguess + pop eax ; throw away saved eax value __STKOVERFLOW: ifdef __STACK__ @@ -93,6 +96,7 @@ else endif jmp __fatal_runtime_error ; display msg and exit ; never return + endproc __CHK endproc __STK endmod diff --git a/bld/clib/startup/a/stkl32.asm b/bld/clib/startup/a/stkl32.asm index 713da0c6b0..5e1a9fe437 100644 --- a/bld/clib/startup/a/stkl32.asm +++ b/bld/clib/startup/a/stkl32.asm @@ -2,7 +2,7 @@ ;* ;* Open Watcom Project ;* -;* Copyright (c) 2016-2016 The Open Watcom Contributors. All Rights Reserved. +;* Copyright (c) 2016-2023 The Open Watcom Contributors. All Rights Reserved. ;* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. ;* ;* ======================================================================== @@ -67,7 +67,6 @@ hextab db "0123456789ABCDEF" xchg eax,[esp] ; exchange parm with return addr push eax ; push return addr ; fall into __CHK - endproc __STK defpe __CHK push eax ; save parm for __GRO routine @@ -92,7 +91,6 @@ endif pop eax ; - restore EAX ret 4 ; - return _endguess ; endguess - pop eax ; throw away saved eax value ;* modified stack overflow code to print the return address of the @@ -145,6 +143,7 @@ endif ; never return endproc __CHK + endproc __STK _putw proc near mov edx,ebx ; save value diff --git a/bld/clib/startup/a/stko32.asm b/bld/clib/startup/a/stko32.asm index 6eef565c84..7b25c023d0 100644 --- a/bld/clib/startup/a/stko32.asm +++ b/bld/clib/startup/a/stko32.asm @@ -2,6 +2,7 @@ ;* ;* Open Watcom Project ;* +;* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. ;* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. ;* ;* ======================================================================== @@ -58,15 +59,14 @@ enddata endproc _init_stk - defpe __CHK ; new style stack check - xchg eax,4[esp] ; get parm in eax - call __STK ; call stack checker - mov eax,4[esp] ; restore eax - ret 4 - endproc __CHK - - defpe __STK + xchg eax,[esp] ; exchange parm with return addr + push eax ; push return addr + ; fall into __CHK + + defpe __CHK ; new style stack check + push eax ; save eax + mov eax,8[esp] ; get parameter push eax ; save parm for __GRO routine _guess ; guess: no overflow cmp eax,esp ; - check if user asking for too much @@ -86,10 +86,11 @@ else endif _quif be ; quit if too much call __GRO ; - grow stack allocation if necessary - ret ; - return + pop eax ; - restore EAX + ret 4 ; - return _endguess ; endguess - - pop eax ; pop the stack (parm for __GRO routine) + pop eax ; throw away parm for __GRO routine + pop eax ; throw away saved eax value __STKOVERFLOW: ifdef __STACK__ @@ -101,9 +102,9 @@ else endif jmp __fatal_runtime_error ; display msg and exit ; never return + endproc __CHK endproc __STK - defpe __GRO ; touch each 4K page for sparse stack push eax ; save regs push ebx ; ... diff --git a/bld/clib/startup/a/stkq32.asm b/bld/clib/startup/a/stkq32.asm index dd4c50130b..a29cc79f6c 100644 --- a/bld/clib/startup/a/stkq32.asm +++ b/bld/clib/startup/a/stkq32.asm @@ -2,6 +2,7 @@ ;* ;* Open Watcom Project ;* +;* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. ;* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. ;* ;* ======================================================================== @@ -69,7 +70,6 @@ hextab db "0123456789ABCDEF" xchg eax,[esp] ; exchange parm with return addr push eax ; push return addr ; fall into __CHK - endproc __STK defpe __CHK push eax @@ -94,7 +94,6 @@ endif pop eax ; - restore EAX ret 4 ; - return _endguess ; endguess - pop eax ; throw away saved eax value ;* modified stack overflow code to print the return address of the @@ -147,6 +146,7 @@ endif ; never return endproc __CHK + endproc __STK _putw proc near mov edx,ebx ; save value diff --git a/bld/clib/startup/a/stkrdu.asm b/bld/clib/startup/a/stkrdu.asm index 3f4200208c..2a3d04e1c4 100644 --- a/bld/clib/startup/a/stkrdu.asm +++ b/bld/clib/startup/a/stkrdu.asm @@ -2,6 +2,7 @@ ;* ;* Open Watcom Project ;* +;* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. ;* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. ;* ;* ======================================================================== @@ -53,14 +54,14 @@ msg db "Stack Overflow!", 0 ret ; return endproc _init_stk - defpe __CHK ; new style stack check - xchg eax,4[esp] ; get parm in eax - call __STK ; call stack checker - mov eax,4[esp] ; restore eax - ret 4 - endproc __CHK - defpe __STK + xchg eax,[esp] ; exchange parm with return addr + push eax ; push return addr + ; fall into __CHK + + defpe __CHK ; new style stack check + push eax ; save eax + mov eax,8[esp] ; get parm push eax ; save parm for __GRO routine _guess ; guess: no overflow cmp eax,esp ; - check if user asking for too much @@ -70,10 +71,11 @@ msg db "Stack Overflow!", 0 cmp eax,fs:[08h] ; - compare with stack bottom in TIB _quif be ; quit if too much call __GRO ; - grow stack allocation if necessary - ret ; - return + pop eax ; - restore eax + ret 4 ; - return _endguess ; endguess - - pop eax ; pop the stack (parm for __GRO routine) + pop eax ; throw away parm for __GRO routine + pop eax ; throw away saved eax value __STKOVERFLOW: ifdef __STACK__ @@ -85,6 +87,7 @@ else endif jmp __fatal_runtime_error ; display msg and exit ; never return + endproc __CHK endproc __STK defpe __GRO ; dummy function to resolve symbol diff --git a/bld/clib/startup/a/stkwnt.asm b/bld/clib/startup/a/stkwnt.asm index 0ad841934b..434e059803 100644 --- a/bld/clib/startup/a/stkwnt.asm +++ b/bld/clib/startup/a/stkwnt.asm @@ -2,6 +2,7 @@ ;* ;* Open Watcom Project ;* +;* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. ;* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. ;* ;* ======================================================================== @@ -58,14 +59,14 @@ msg db "Stack Overflow!", 0 ret ; return endproc _init_stk - defpe __CHK ; new style stack check - xchg eax,4[esp] ; get parm in eax - call __STK ; call stack checker - mov eax,4[esp] ; restore eax - ret 4 - endproc __CHK - defpe __STK + xchg eax,[esp] ; exchange parm with return addr + push eax ; push return addr + ; fall into __CHK + + defpe __CHK + push eax ; save eax + mov eax,8[esp] ; get parm push eax ; save parm for __GRO routine _guess ; guess: no overflow cmp eax,esp ; - check if user asking for too much @@ -85,10 +86,11 @@ else endif _quif be ; quit if too much call __GRO ; - grow stack allocation if necessary - ret ; - return + pop eax ; - restore eax + ret 4 ; - return _endguess ; endguess - - pop eax ; pop the stack (parm for __GRO routine) + pop eax ; throw away parm for __GRO routine + pop eax ; throw away saved eax value __STKOVERFLOW: ifdef __STACK__ @@ -101,6 +103,7 @@ endif jmp __fatal_runtime_error ; display msg and exit ; never return + endproc __CHK endproc __STK defpe __GRO ; dummy function to resolve symbol From fdca0074f27b8193208defba790b00114864c895 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Mal=C3=A1k?= Date: Wed, 30 Aug 2023 22:00:27 +0200 Subject: [PATCH 064/258] run workflow weekly --- .github/workflows/runsdel.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/runsdel.yml b/.github/workflows/runsdel.yml index 71291809b8..1e5a3c9323 100644 --- a/.github/workflows/runsdel.yml +++ b/.github/workflows/runsdel.yml @@ -1,8 +1,8 @@ name: Delete Old (Workflow Runs) on: schedule: - - cron: '0 0 1 * *' -# Run monthly, at 00:00 on the 1st day of month. + - cron: '5 1 * * 0' +# Run weekly, at 01:05 on the Sunday. workflow_dispatch: jobs: From 8025d690ba807506036bd16807d4095efa8a015b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Mal=C3=A1k?= Date: Wed, 30 Aug 2023 22:05:18 +0200 Subject: [PATCH 065/258] shift after regular daily build --- .github/workflows/runsdel.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/runsdel.yml b/.github/workflows/runsdel.yml index 1e5a3c9323..380c5b0da5 100644 --- a/.github/workflows/runsdel.yml +++ b/.github/workflows/runsdel.yml @@ -1,7 +1,7 @@ name: Delete Old (Workflow Runs) on: schedule: - - cron: '5 1 * * 0' + - cron: '5 3 * * 0' # Run weekly, at 01:05 on the Sunday. workflow_dispatch: From 776a73ffd474372f697a26e72ae022fc69956869 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Thu, 31 Aug 2023 10:45:47 +0200 Subject: [PATCH 066/258] do code more portable do macro more transparent use correct FN_... aui prefix instead of OFN_... Windows prefix --- bld/wv/c/dlgfile.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/bld/wv/c/dlgfile.c b/bld/wv/c/dlgfile.c index adef636fce..1f8fe8779f 100644 --- a/bld/wv/c/dlgfile.c +++ b/bld/wv/c/dlgfile.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2018 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -51,6 +51,9 @@ #include "wndhelp.h" +#define FN_READABLE 0 +#define FN_WRITEABLE (FN_HIDEREADONLY | FN_ISSAVE | FN_OVERWRITEPROMPT) + #if defined(__UNIX__) #define ALLFILES "All Files\0*\0" #else @@ -226,13 +229,10 @@ bool WndShutDownHook( void ) } -#define OFN_FLAGS( writing ) \ - ( writing ? (FN_HIDEREADONLY|FN_ISSAVE|FN_OVERWRITEPROMPT) : 0 ) - bool ConfigSave( bool writing ) { WritableConfig(); - if( DoFileBrowse( &LastCfg, LIT_DUI( Configuration_File_Name ), ConfigFilter, OFN_FLAGS( writing ) ) ) { + if( DoFileBrowse( &LastCfg, LIT_DUI( Configuration_File_Name ), ConfigFilter, writing ? FN_WRITEABLE : FN_READABLE ) ) { if( writing ) { SaveConfigToFile( TxtBuff ); SaveMainWindowPos(); @@ -247,7 +247,7 @@ bool ConfigSave( bool writing ) bool BreakSave( bool writing ) { - if( DoFileBrowse( &LastBrk, LIT_DUI( Breakpoint_File_Name ), ConfigFilter, OFN_FLAGS( writing ) ) ) { + if( DoFileBrowse( &LastBrk, LIT_DUI( Breakpoint_File_Name ), ConfigFilter, writing ? FN_WRITEABLE : FN_READABLE ) ) { if( writing ) { SaveBreaksToFile( TxtBuff ); } else { @@ -262,7 +262,7 @@ bool BreakSave( bool writing ) bool ReplaySave( bool writing ) { if( OkToSaveReplay() ) { - if( DoFileBrowse( &LastRep, LIT_DUI( Replay_File_Name ), ConfigFilter, OFN_FLAGS( writing ) ) ) { + if( DoFileBrowse( &LastRep, LIT_DUI( Replay_File_Name ), ConfigFilter, writing ? FN_WRITEABLE : FN_READABLE ) ) { if( writing ) { SaveReplayToFile( TxtBuff ); } else { @@ -277,7 +277,7 @@ bool ReplaySave( bool writing ) void FileBrowse( void ) { - if( DoFileBrowse( &LastFile, LIT_DUI( Enter_File_Name ), SourceFilter, OFN_FLAGS( 0 ) )) { + if( DoFileBrowse( &LastFile, LIT_DUI( Enter_File_Name ), SourceFilter, FN_READABLE )) { WndFileInspect( TxtBuff, false ); } } @@ -285,19 +285,19 @@ void FileBrowse( void ) bool ExeBrowse( void ) { - return( DoFileBrowse( &LastExe, LIT_DUI( Program_Name ), ExeFilter, OFN_FLAGS( 0 ) ) ); + return( DoFileBrowse( &LastExe, LIT_DUI( Program_Name ), ExeFilter, FN_READABLE ) ); } bool SymBrowse( char **name ) { - return( DoFileBrowse( name, LIT_DUI( Symbol_File ), SymFilter, OFN_FLAGS( 0 ) ) ); + return( DoFileBrowse( name, LIT_DUI( Symbol_File ), SymFilter, FN_READABLE ) ); } bool AllBrowse( char *name ) { - return( DlgFileBrowse( LIT_DUI( Enter_File_Name ), AllFilter, name, TXT_LEN, OFN_FLAGS( 0 ) ) ); + return( DlgFileBrowse( LIT_DUI( Enter_File_Name ), AllFilter, name, TXT_LEN, FN_READABLE ) ); } @@ -305,7 +305,7 @@ char *GetDmpName( void ) { bool rc; - rc = DoFileBrowse( &LastDmp, LIT_DUI( Enter_File_Name ), AllFilter, OFN_FLAGS( 1 ) ); + rc = DoFileBrowse( &LastDmp, LIT_DUI( Enter_File_Name ), AllFilter, FN_WRITEABLE ); if( !rc ) return( NULL ); return( LastDmp ); From 3dafbe18524a230f9f74c78a3a9fead4d9fc6163 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Fri, 1 Sep 2023 02:10:08 +0200 Subject: [PATCH 067/258] fixing compilers stack checking macros fixing use of these macros to handle regular and dll build separately --- build/mif/cproj.mif | 56 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 44 insertions(+), 12 deletions(-) diff --git a/build/mif/cproj.mif b/build/mif/cproj.mif index d35d2ac2ce..ca8a240adc 100644 --- a/build/mif/cproj.mif +++ b/build/mif/cproj.mif @@ -180,13 +180,10 @@ cldebug_fmt = -hd !ifndef $(proj_name)_nooptimization mode_optimization = $(dft_oflags) !endif -!ifndef $(proj_name)_checkstack -mode_nocheckstack = -s -!endif mode_libflags = !ifeq release 1 mode_cppflags = -DNDEBUG -mode_cflags = $(mode_nocheckstack)$(mode_optimization) -d1 $(cdebug_fmt) +mode_cflags = $(mode_optimization) -d1 $(cdebug_fmt) mode_aflags = -d1 -DNDEBUG mode_lflags = $(ldebug_fmt) mode_clflags = $(cldebug_fmt) -d1 @@ -320,6 +317,41 @@ fpu_flags = $(fpu_flags_$(host_os)_$(host_cpu)) fpu_flags = $(def_fpu_flags_$(host_os)_$(host_cpu)) !endif +######################### +# STACK CHECKING SETINGS +###### +!ifdef nocheckstack +checkstack_386 = -s +checkstack_i86 = -s +!else ifdef checkstack +!else ifdef $(proj_name)_nocheckstack +checkstack_386 = -s +checkstack_i86 = -s +!else ifdef $(proj_name)_checkstack +!else +! ifeq release 1 +checkstack_386 = -s +checkstack_i86 = -s +! else +! endif +!endif + +!ifdef nocheckstack_dll +checkstack_dll_386 = -s +checkstack_dll_i86 = -s +!else ifdef checkstack_dll +!else ifdef $(proj_name)_nocheckstack_dll +checkstack_dll_386 = -s +checkstack_dll_i86 = -s +!else ifdef $(proj_name)_checkstack_dll +!else +! ifeq release 1 +checkstack_dll_386 = -s +checkstack_dll_i86 = -s +! else +! endif +!endif + ####################### # PREPROCESSOR SETINGS ###### @@ -409,9 +441,9 @@ proj_c_flags = $(extra_c_flags) $(extra_c_flags_$(host_cpu)) $(extra_c_flags cflags_gen_all = $(cflags_all) $(fpu_flags) $(cflags_$(host_cpu)) $(cflags_$(host_os)) $(cflags_rtdll_$(host_os)) -cflags_gen = $(cflags_gen_all) $(proj_c_flags) -cflags_dll = $(cflags_gen_all) $(cflags_dll_$(host_os)) $(proj_c_flags) -cflags_wind = $(cflags_gen_all) $(cflags_wind_$(host_os)) $(proj_c_flags) +cflags_gen = $(cflags_gen_all) $(checkstack_$(host_cpu)) $(proj_c_flags) +cflags_dll = $(cflags_gen_all) $(checkstack_dll_$(host_cpu)) $(cflags_dll_$(host_os)) $(proj_c_flags) +cflags_wind = $(cflags_gen_all) $(checkstack_$(host_cpu)) $(cflags_wind_$(host_os)) $(proj_c_flags) ################################### # COMPILE AND LINK UTILITY SETINGS @@ -466,18 +498,18 @@ clflags_exe = -fe=$@ proj_cl_flags = $(extra_cl_flags) clflags_gen_all = $(clflags_all) $(cl_fpu_flags) $(cflags_$(host_os)) $(clflags_exe) -clflags_gen = $(clflags_gen_all) $(clflags_$(host_os)_$(host_cpu)) $(proj_cl_flags) +clflags_gen = $(clflags_gen_all) $(checkstack_$(host_cpu)) $(clflags_$(host_os)_$(host_cpu)) $(proj_cl_flags) !ifdef clflags_dll_$(host_os)_$(host_cpu) -clflags_dll = $(clflags_gen_all) $(clflags_dll_$(host_os)_$(host_cpu)) $(proj_cl_flags) +clflags_dll = $(clflags_gen_all) $(checkstack_dll_$(host_cpu)) $(clflags_dll_$(host_os)_$(host_cpu)) $(proj_cl_flags) !else -clflags_dll = $(clflags_gen) +clflags_dll = $(clflags_gen_all) $(checkstack_dll_$(host_cpu)) $(clflags_$(host_os)_$(host_cpu)) $(proj_cl_flags) !endif !ifdef clflags_wind_$(host_os)_$(host_cpu) -clflags_wind = $(clflags_gen_all) $(clflags_wind_$(host_os)_$(host_cpu)) $(proj_cl_flags) +clflags_wind = $(clflags_gen_all) $(checkstack_$(host_cpu)) $(clflags_wind_$(host_os)_$(host_cpu)) $(proj_cl_flags) !else -clflags_wind = $(clflags_gen) +clflags_wind = $(clflags_gen_all) $(checkstack_$(host_cpu)) $(clflags_$(host_os)_$(host_cpu)) $(proj_cl_flags) !endif ##################### From f583b79494fe04bfb31da86aca0f648f75dc1892 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Fri, 1 Sep 2023 02:14:13 +0200 Subject: [PATCH 068/258] fixing default rules for compiling C/C++ and assembly source files there were logical mistake in macros which was masked by extra macro now it uses correct regular macros --- build/mif/defrule.mif | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/build/mif/defrule.mif b/build/mif/defrule.mif index 2d4b6966f3..0ac48d9268 100644 --- a/build/mif/defrule.mif +++ b/build/mif/defrule.mif @@ -4,19 +4,30 @@ $(subdir_$+$(defrule_key)$-) : .EXPLICIT mkdir $@ additional_clean_subdirs += $(subdir_$+$(defrule_key)$-) !else -defrule_key = defrule_obj_target = .obj !endif .c$(defrule_obj_target): $(__MAKEFILES__) $($(proj_name)_autodepends) @%make echo_cc +!ifdef defrule_key $(cc) $(cflags) $(c_flags) $(cppflags) $(extra_cpp_$+$(defrule_key)$-_flags) $(extra_cpp_flags_$[&) $(extra_c_flags_$[&) $(inc_path) $[@ +!else + $(cc) $(cflags) $(c_flags) $(cppflags) $(extra_cpp_flags_$[&) $(extra_c_flags_$[&) $(inc_path) $[@ +!endif .cpp$(defrule_obj_target): $(__MAKEFILES__) $($(proj_name)_autodepends) @%make echo_cxx +!ifdef defrule_key $(cxx) $(cflags) $(cxx_flags) $(cppflags) $(extra_cpp_$+$(defrule_key)$-_flags) $(extra_cpp_flags_$[&) $(extra_c_flags_$[&) $(inc_path) $[@ +!else + $(cxx) $(cflags) $(cxx_flags) $(cppflags) $(extra_cpp_flags_$[&) $(extra_c_flags_$[&) $(inc_path) $[@ +!endif .asm$(defrule_obj_target): $(__MAKEFILES__) $($(proj_name)_autodepends) @%make echo_as - $(as) $(aflags) $(extra_a_$+$(defrule_key)$-_flags) $(extra_a_flags_$[&) $(inc_path) $[@ +!ifdef defrule_key + $(as) $(aflags) $(extra_app_$+$(defrule_key)$-_flags) $(extra_a_flags_$[&) $(inc_path) $[@ +!else + $(as) $(aflags) $(extra_a_flags_$[&) $(inc_path) $[@ +!endif !undef defrule_obj_target !undef defrule_key From ea58c3afc1b159438eb9a96c8edea9bc5f134f6b Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Fri, 1 Sep 2023 02:24:36 +0200 Subject: [PATCH 069/258] fix a few issues in trap build make files --- bld/trap/master.mif | 10 +++++++--- bld/trap/trap.mif | 8 ++++---- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/bld/trap/master.mif b/bld/trap/master.mif index 51deba87b6..5073692b04 100644 --- a/bld/trap/master.mif +++ b/bld/trap/master.mif @@ -130,6 +130,12 @@ xname = z$(name) xname = $(name) !endif +# stack check handling +####################### +!ifeq which TRAP +nocheckstack = 1 +!endif + !include cproj.mif !include defrule.mif !include deftarg.mif @@ -280,9 +286,7 @@ $(target) : $(extra_link_res_$(host_os)) $(objs) $(libs) $(resource_file) $(extr @%append $^&.lnk op elim @%append $^&.lnk name $@ @%append $^&.lnk $(sys_$(target_cpu)_$(target_sys)) -!ifeq which TRAP - @%append $^&.lnk op dosseg -!endif + @%append $^&.lnk $(proj_l_flags) @for %i in ($(objs)) do @%append $^&.lnk file %i @for %i in ($(libs)) do @%append $^&.lnk library %i @%append $^&.lnk $(extra_linker) diff --git a/bld/trap/trap.mif b/bld/trap/trap.mif index 51e299671a..9b53e886d0 100644 --- a/bld/trap/trap.mif +++ b/bld/trap/trap.mif @@ -58,18 +58,18 @@ export_full_nt_risc = export TrapInfoFunction.4, TrapInterruptProgram.5, TrapTer export_full_win = export TRAPINPUTHOOK.5, TRAPINFOFUNCTION.6, TRAPHARDMODECHECK.7, TRAPGETHWNDFUNC.8, TRAPSETHARDMODE.12, TRAPUNLOCKINPUT.13 !endif -sys_x86_os2 = sys os2 dll initinstance & +sys_x86_os2 = sys os2 dll initinstance opt dosseg & $(export_common_intel) $(export_full_os2) & op modname=$^& & option description $(description) -sys_x86_os2v2 = sys os2v2 dll initinstance terminstance & +sys_x86_os2v2 = sys os2v2 dll initinstance terminstance opt dosseg & $(export_common_intel) $(export_full_os2) & lib os2386.lib & op modname=$^& & option description $(description) -sys_x86_win = sys windows_dll & +sys_x86_win = sys windows_dll opt dosseg & export WEP.1 RESIDENT & export TRAPINIT.2, TRAPFINI.3, TRAPREQUEST.4 $(export_full_win) & op modname=$^& & @@ -78,7 +78,7 @@ sys_x86_win = sys windows_dll & sys_x86_dos = sys dos opt dosseg -sys_x86_rdos = sys rdos_dll & +sys_x86_rdos = sys rdos_dll opt dosseg & export TrapInit_, TrapFini_, TrapRequest_ & $(dllbase) From 10860497183c1bc94581d3ce71213100224d1644 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Fri, 1 Sep 2023 02:26:28 +0200 Subject: [PATCH 070/258] fix build make files for dlls in trap project --- bld/trap/lcl/os2v2/splice/makefile | 4 +++- bld/trap/lcl/os2v2/wvpmhelp/makefile | 8 ++++++-- bld/trap/par/os2v2.pio/makefile | 27 +++++++++++++-------------- 3 files changed, 22 insertions(+), 17 deletions(-) diff --git a/bld/trap/lcl/os2v2/splice/makefile b/bld/trap/lcl/os2v2/splice/makefile index f43a23fd1b..b1e017fef1 100644 --- a/bld/trap/lcl/os2v2/splice/makefile +++ b/bld/trap/lcl/os2v2/splice/makefile @@ -18,6 +18,7 @@ sys_dll = 1 !include cproj.mif !include defrule.mif +!include dllrule.mif !include deftarg.mif dig_arch = $(host_cpu) @@ -44,5 +45,6 @@ extra_l_flags_dll = op oneautodata # # DLL # -dlltarg_objs = splice.obj +dlltarg_prebuild_objs = $(dll_subdir) +dlltarg_objs = $(dll_subdir)/splice.obj !include dlltarg.mif diff --git a/bld/trap/lcl/os2v2/wvpmhelp/makefile b/bld/trap/lcl/os2v2/wvpmhelp/makefile index 9dc00f0a06..09cf4c4611 100644 --- a/bld/trap/lcl/os2v2/wvpmhelp/makefile +++ b/bld/trap/lcl/os2v2/wvpmhelp/makefile @@ -14,14 +14,17 @@ proj_name = wdpmhelp wdpmhelp_autodepends = .AUTODEPEND !endif +wdpmhelp_nocheckstack_dll = 1 + !include cproj.mif !include defrule.mif +!include dllrule.mif !include deftarg.mif # # cflags # -.c: ../c +.c: ../c;$(trap_dir)/common inc_dirs = -I. -I"../h" -I"$(trap_dir)/h" @@ -48,7 +51,8 @@ w d : wdpmhook.dll wdpmhelp.exe .SYMBOLIC # # DLL # -dlltarg_objs = pmhook.obj +dlltarg_prebuild_objs = $(dll_subdir) +dlltarg_objs = $(dll_subdir)/pmhook.obj dlltarg_name = wdpmhook !include dlltarg.mif diff --git a/bld/trap/par/os2v2.pio/makefile b/bld/trap/par/os2v2.pio/makefile index 167fc626eb..d51a68ce1c 100644 --- a/bld/trap/par/os2v2.pio/makefile +++ b/bld/trap/par/os2v2.pio/makefile @@ -15,8 +15,6 @@ os2v2pio_autodepends = .AUTODEPEND # I/O can be built into the parallel trap file/server modules, which is # where it belongs in the first place. -sys_dll = 1 - !include cproj.mif !include defrule.mif !include deftarg.mif @@ -25,15 +23,16 @@ sys_dll = 1 inc_dirs = -I"../h" -extra_c_flags_wdio = -nt=port -nc=IOPL_CODE - -extra_l_flags = op protmode - -extra_linker = segment 'port' IOPL & - export INPORT 2 & - export OUTPORT 4 - -dlltarg_objs = wdio.obj -dlltarg_name = wdio -dlltarg_opts = $(extra_linker) -!include dlltarg.mif +extra_c_flags_wdio = -nt=port -nc=IOPL_CODE -zls + +wdio.dll : wdio.obj + $(noecho)%create $^&.lnk + @%append $^&.lnk format os2 dll option osname='OS/2 16-bit DLL' + @%append $^&.lnk op map, elim, protmode, nodef + @%append $^&.lnk name $@ + @%append $^&.lnk file wdio.obj + @%append $^&.lnk segment 'port' IOPL + @%append $^&.lnk export INPORT 2 + @%append $^&.lnk export OUTPORT 4 + @%make echo_link + $(linker) @$^&.lnk From 2a1fd01ffaea8300d53b4d3bf75ff53596d858d8 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Fri, 1 Sep 2023 02:32:12 +0200 Subject: [PATCH 071/258] remove useless code it is handled by disabling stack check for build trap at all --- bld/trap/common/nlm/nlmstrt.c | 16 ++++++++++++++++ bld/trap/lcl/dos/dosx/ads/c/adsacc.c | 4 ---- bld/trap/lcl/os2/c/pmdbg.c | 4 ---- bld/trap/lcl/os2/test/pmdbg.c | 4 ---- bld/trap/lcl/os2v2/c/pmdbg.c | 4 ---- bld/trap/lcl/os2v2/test/pmdbg.c | 4 ---- 6 files changed, 16 insertions(+), 20 deletions(-) diff --git a/bld/trap/common/nlm/nlmstrt.c b/bld/trap/common/nlm/nlmstrt.c index 0657ee613b..0a8ef0db18 100644 --- a/bld/trap/common/nlm/nlmstrt.c +++ b/bld/trap/common/nlm/nlmstrt.c @@ -32,6 +32,7 @@ #include "miniproc.h" #include "debugme.h" +#include "brkptcpu.h" #include #undef POP_UP_SCREEN #define ConsolePrintf _ @@ -594,3 +595,18 @@ void WriteStdErr( char *str, int len ) ++str; } } + +extern void __STK( int size ); +extern void __CHK( int size ); +#pragma off (check_stack); +void __declspec(naked) __CHK( int size ) +{ + (void)size; + __asm { + push eax + mov eax,8[esp] + call __STK + pop eax + ret 4 + } +} diff --git a/bld/trap/lcl/dos/dosx/ads/c/adsacc.c b/bld/trap/lcl/dos/dosx/ads/c/adsacc.c index befb1edf20..2d92e7523a 100644 --- a/bld/trap/lcl/dos/dosx/ads/c/adsacc.c +++ b/bld/trap/lcl/dos/dosx/ads/c/adsacc.c @@ -1028,7 +1028,3 @@ void GotInt3( void ) _DBG0(( "Got Int 3!!!" )); } #endif - -extern void StackCheck( void ); -#pragma aux StackCheck "__STK"; -void StackCheck( void ) {} diff --git a/bld/trap/lcl/os2/c/pmdbg.c b/bld/trap/lcl/os2/c/pmdbg.c index 3e1b9d6532..f3e182b36f 100644 --- a/bld/trap/lcl/os2/c/pmdbg.c +++ b/bld/trap/lcl/os2/c/pmdbg.c @@ -279,7 +279,3 @@ MRESULT EXPENTRY MyWindowProc( HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2 ) return FALSE; } /********************** End of window procedure ***********************/ - -extern void StackCheck( void ); -#pragma aux StackCheck "__STK"; -void StackCheck( void ) {} diff --git a/bld/trap/lcl/os2/test/pmdbg.c b/bld/trap/lcl/os2/test/pmdbg.c index 4ac52a3dc4..cc7cf6b0fd 100644 --- a/bld/trap/lcl/os2/test/pmdbg.c +++ b/bld/trap/lcl/os2/test/pmdbg.c @@ -278,7 +278,3 @@ MRESULT EXPENTRY MyWindowProc( HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2 ) return FALSE; } /********************** End of window procedure ***********************/ - -extern void StackCheck( void ); -#pragma aux StackCheck "__STK"; -void StackCheck( void ) {} diff --git a/bld/trap/lcl/os2v2/c/pmdbg.c b/bld/trap/lcl/os2v2/c/pmdbg.c index 50016a020c..2ce2932110 100644 --- a/bld/trap/lcl/os2v2/c/pmdbg.c +++ b/bld/trap/lcl/os2v2/c/pmdbg.c @@ -280,7 +280,3 @@ MRESULT EXPENTRY MyWindowProc( HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2 ) return FALSE; } /********************** End of window procedure ***********************/ - -extern void StackCheck( void ); -#pragma aux StackCheck "__STK"; -void StackCheck( void ) {} diff --git a/bld/trap/lcl/os2v2/test/pmdbg.c b/bld/trap/lcl/os2v2/test/pmdbg.c index 50016a020c..2ce2932110 100644 --- a/bld/trap/lcl/os2v2/test/pmdbg.c +++ b/bld/trap/lcl/os2v2/test/pmdbg.c @@ -280,7 +280,3 @@ MRESULT EXPENTRY MyWindowProc( HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2 ) return FALSE; } /********************** End of window procedure ***********************/ - -extern void StackCheck( void ); -#pragma aux StackCheck "__STK"; -void StackCheck( void ) {} From 2dd98a375b4e3a32f2282600541f875383e04e13 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Fri, 1 Sep 2023 13:15:39 +0200 Subject: [PATCH 072/258] cleanup bdiff project code remove useless/unused code cleanup build make file --- bld/bdiff/c/diff.c | 31 +------------------------ bld/bdiff/master.mif | 55 ++++++++++++++++++-------------------------- 2 files changed, 24 insertions(+), 62 deletions(-) diff --git a/bld/bdiff/c/diff.c b/bld/bdiff/c/diff.c index 3f013653b9..52543ace59 100644 --- a/bld/bdiff/c/diff.c +++ b/bld/bdiff/c/diff.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -64,30 +64,6 @@ typedef struct exe_mod { char name[1]; } exe_mod; -#ifdef USE_DBGINFO -typedef long exe_form_t; - -typedef struct { - fpos_t last_offset; -} walker_data; - -typedef struct exe_info { - FILE *fd; - symbol_table mods_by_offset; - symbol_table mods_by_name; - symbol_table blks; - exe_form_t form; - struct { - FILE *fd; - fpos_t start; /* start of debugging info */ - } sym; -} exe_info; - -extern foff ExeForm( FILE *, void *, exe_info * ); -extern foff ExeTransformAddr( exe_form_t, addr_seg, addr48_off, word ); -extern fpos_t ExeOverlayAccess( exe_form_t exe, uint_16 section, uint_16 *seg ); -#endif - byte *PatchBuffer; byte *OldFile; @@ -138,11 +114,6 @@ static byte *CurrPatch; static foff PatchSize; -#ifdef USE_DBGINFO -static exe_info old; -static exe_info new; -#endif - /* * Utility routines * ================ diff --git a/bld/bdiff/master.mif b/bld/bdiff/master.mif index 20fda14851..6c3e6ed551 100644 --- a/bld/bdiff/master.mif +++ b/bld/bdiff/master.mif @@ -2,10 +2,30 @@ proj_name = bdiff bdiff_autodepend = .AUTODEPENDS +subdir_wcpatch = wcpatch +subdir_wpatch = wpatch +subdir_bpatch = bpatch +subdir_bdump = bdump +subdir_bdiff = bdiff + !include cproj.mif !include defrule.mif +defrule_key = wcpatch +extra_cpp_wcpatch_flags = -DBDIFF -D_WPATCH +!include defrule.mif +defrule_key = wpatch +extra_cpp_wpatch_flags = -D_WPATCH -DBPATCH +!include defrule.mif +defrule_key = bpatch +extra_cpp_bpatch_flags = -D_WPATCH -DBPATCH +!include defrule.mif +defrule_key = bdump +extra_cpp_bdump_flags = -DBDUMP +!include defrule.mif +defrule_key = bdiff +extra_cpp_bdiff_flags = -DBDIFF +!include defrule.mif !include deftarg.mif - !include wres.mif # @@ -18,12 +38,6 @@ inc_dirs = -I. -I"../h" -I"$(dip_dir)/watcom/h" # explicit rules ################# -subdir_wcpatch = wcpatch -subdir_wpatch = wpatch -subdir_bpatch = bpatch -subdir_bdump = bdump -subdir_bdiff = bdiff - all : bpatch.exe bdiff.exe bpcmt.exe bplevel.exe bdump.exe wpatch.exe wcpatch.exe .SYMBOLIC # @@ -56,7 +70,7 @@ exetarg_objs = & $(subdir_wcpatch)/msg.obj & $(subdir_wcpatch)/wcptchio.obj & $(subdir_wcpatch)/wcpatch.obj & - $(subdir_wcpatch)/diff.obj $(exetarg_objs_debug) + $(subdir_wcpatch)/diff.obj exetarg_res_wresui = wcpatch.res exetarg_name = wcpatch !include exetarg.mif @@ -116,7 +130,7 @@ exetarg_objs = & $(subdir_bdiff)/bdiff.obj & $(subdir_bdiff)/diff.obj & $(subdir_bdiff)/dopatch.obj & - $(subdir_bdiff)/msg.obj $(exetarg_objs_debug) + $(subdir_bdiff)/msg.obj exetarg_res_wresui = bdiff.res exetarg_name = bdiff !include exetarg.mif @@ -159,26 +173,3 @@ $(exetarg_$(host_os)_manif_$(host_cpu)) : ../ntmanif.rc .EXPLICIT @%make echo_rc $(rc) $(rc_flags) -I.. $(inc_dirs_sys_nt) -I"$(watcom_dir)/h" $< -fo=$@ !endif - -# implicit rules -################# - -extra_cpp_wcpatch_flags = -DBDIFF -D_WPATCH $(extra_cpp_debug_flags) -defrule_key = wcpatch -!include defrule.mif - -extra_cpp_wpatch_flags = -D_WPATCH -DBPATCH -defrule_key = wpatch -!include defrule.mif - -extra_cpp_bpatch_flags = -D_WPATCH -DBPATCH -defrule_key = bpatch -!include defrule.mif - -extra_cpp_bdump_flags = -DBDUMP -defrule_key = bdump -!include defrule.mif - -extra_cpp_bdiff_flags = -DBDIFF $(extra_cpp_debug_flags) -defrule_key = bdiff -!include defrule.mif From 9d0ae04aec617f1d05e6fcab1c0a80a3d1a054aa Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Fri, 1 Sep 2023 13:40:23 +0200 Subject: [PATCH 073/258] cleanup posix project build make files --- bld/as/master.mif | 32 ++- bld/graphlib/graphics.mif | 30 ++- bld/graphlib/pgchart/pgchart.mif | 13 +- bld/idebatch/master.mif | 13 +- bld/posix/common.mif | 17 ++ bld/posix/makeall.mif | 34 ++-- bld/posix/makelib.mif | 4 +- bld/posix/makeone.mif | 4 +- bld/posix/model.mif | 16 -- bld/watcom/c/symtab.c | 45 +++-- bld/watcom/h/symtab.h | 15 +- bld/wic/c/symtab.c | 325 ------------------------------- bld/wic/h/symtab.h | 64 ------ bld/wic/master.mif | 2 +- 14 files changed, 116 insertions(+), 498 deletions(-) delete mode 100644 bld/posix/model.mif delete mode 100644 bld/wic/c/symtab.c delete mode 100644 bld/wic/h/symtab.h diff --git a/bld/as/master.mif b/bld/as/master.mif index 732b347fb3..e24974bb8f 100644 --- a/bld/as/master.mif +++ b/bld/as/master.mif @@ -6,13 +6,24 @@ was_autodepends = .AUTODEPEND was_trmem = 1 -subdir_stand = stand -subdir_lib = lib - additional_clean = *.c *.h *.re *.y !include cproj.mif !include defrule.mif +defrule_key = stand +subdir_stand = stand +extra_cpp_stand_flags = -D_STANDALONE_ +!ifdef __WATCOM_TOOLS__ +extra_cpp_stand_flags += -fh=stand.pch +!endif +!include defrule.mif +defrule_key = lib +subdir_lib = lib +extra_cpp_lib_flags = -DINCL_MSGTEXT +!ifdef __WATCOM_TOOLS__ +extra_cpp_lib_flags += -fh=lib.pch +!endif +!include defrule.mif !include deftarg.mif !include trmem.mif !include wres.mif @@ -243,18 +254,3 @@ optencod_targets += dbg usage.gh $(exetarg_$(host_os)_res) : ../../h/options.gml $(__MAKEFILES__) @%make echo_optencod $(optencod) -rc=MSG_USAGE_BASE -utf8 $(optencod_opt_$(host_os)) $[@ . . $@ $(optencod_targets) - -# implicit rules -################# - -extra_cpp_stand_flags = -D_STANDALONE_ -extra_cpp_lib_flags = -DINCL_MSGTEXT -!ifdef __WATCOM_TOOLS__ -extra_cpp_stand_flags += -fh=stand.pch -extra_cpp_lib_flags += -fh=lib.pch -!endif - -defrule_key = stand -!include defrule.mif -defrule_key = lib -!include defrule.mif diff --git a/bld/graphlib/graphics.mif b/bld/graphlib/graphics.mif index 5c48c73aac..70374dd406 100644 --- a/bld/graphlib/graphics.mif +++ b/bld/graphlib/graphics.mif @@ -1,7 +1,5 @@ proj_name = graph -subdir_v2 = v2objs - crwatpro_gsp = crwatpro.gsp additional_clean = $(crwatpro_gsp) @@ -16,6 +14,13 @@ suppress_zc = 1 supervga_support = -D_SUPERVGA +!ifeq system windows +default_windowing = 1 +!endif +!ifeq default_windowing 1 +def_windowing = -DDEFWIN +!endif + memory_model_i86 = s !ifeq host_os dos memory_model_386 = s @@ -28,6 +33,11 @@ suffix_stack = s !include cproj.mif !include defrule.mif +defrule_key = v2 +subdir_v2 = v2objs +extra_cpp_v2_flags = -DVERSION2 +extra_a_v2_flags = -DVERSION2 +!include defrule.mif !include deftarg.mif # @@ -48,6 +58,9 @@ extra_cpp_flags_386 = -D_CGRAPH= extra_cpp_flags_386 += -D__STACK !endif +extra_cpp_flags_win = $(def_windowing) +extra_cpp_flags_os2 = $(def_windowing) + extra_c_flags = -os -zl -nm=$[&$(suffix_$(convention)) $(extra_c_flags_$(machine)) -fo=$@ extra_c_flags_i86 = -nt=GRAPH_TEXT @@ -196,6 +209,11 @@ win_objs = & $(_subdir_)gphmain.obj & $(_subdir_)winutil.obj +os2_objs = & + $(_subdir_)gphmain.obj & + $(_subdir_)winutil.obj & + $(_subdir_)seginit.obj + special_objs = & fsmath.obj & dummy.obj @@ -209,6 +227,8 @@ svga_english_objs = & !ifeq host_os win grlib_template = $(common_objs) $(win_objs) +!else ifeq host_os os2 +grlib_template = $(common_objs) $(os2_objs) !else grlib_template = $(common_objs) $(eng_nonwin_objs) $(english_objs) $(svga_english_objs) !endif @@ -248,9 +268,3 @@ wsplice_opts_win = -kDOS wsplice_opts = $(wsplice_extra_opts) $(wsplice_opts_$(host_os)) !include $(graphlib_dir)/headers.mif - -extra_cpp_v2_flags = -DVERSION2 -extra_a_v2_flags = -DVERSION2 - -defrule_key = v2 -!include defrule.mif diff --git a/bld/graphlib/pgchart/pgchart.mif b/bld/graphlib/pgchart/pgchart.mif index beccfe52d6..e3ab1c62dc 100644 --- a/bld/graphlib/pgchart/pgchart.mif +++ b/bld/graphlib/pgchart/pgchart.mif @@ -6,8 +6,6 @@ tree_depth = 4 proj_name = pgchart -subdir_v2 = v2objs - crwatpro_gsp = crwatpro.gsp additional_clean = $(crwatpro_gsp) @@ -31,6 +29,11 @@ memory_model_i86 = l !include cproj.mif !include defrule.mif +defrule_key = v2 +subdir_v2 = v2objs +extra_cpp_v2_flags = -DVERSION2 +extra_a_v2_flags = -DVERSION2 +!include defrule.mif !include deftarg.mif # @@ -111,9 +114,3 @@ wsplice_opts_qnx = -kQNX -u wsplice_opts_win = -kDOS !include $(graphlib_dir)/headers.mif - -extra_cpp_v2_flags = -DVERSION2 -extra_a_v2_flags = -DVERSION2 - -defrule_key = v2 -!include defrule.mif diff --git a/bld/idebatch/master.mif b/bld/idebatch/master.mif index 3dd6f494e9..d8a6cd269a 100644 --- a/bld/idebatch/master.mif +++ b/bld/idebatch/master.mif @@ -4,6 +4,12 @@ idebatch_autodepend = .AUTODEPEND !include cproj.mif !include defrule.mif +!ifeq host_os win +defrule_key = editor +subdir_editor = eobjs +extra_cpp_editor_flags = -D__EDITOR__ +!include defrule.mif +!endif !include deftarg.mif !ifeq host_os os2 @@ -53,16 +59,12 @@ exetarg_name = tstos2 !else ifeq host_os win -subdir_editor = eobjs - .c: ../win;../dos inc_dirs = -I"../win" -I"../dos" extra_cpp_flags = -DSERVER -extra_cpp_editor_flags = -D__EDITOR__ - extra_c_flags = -zW -zu extra_l_flags_win = font mem & @@ -90,7 +92,4 @@ winint.res wininte.res : ../winint.rc @%make echo_rc $(rc) $(rc_flags) $(inc_dirs) $[@ -fo=$@ -defrule_key = editor -!include defrule.mif - !endif diff --git a/bld/posix/common.mif b/bld/posix/common.mif index 4b648e9f8d..2058b991e5 100644 --- a/bld/posix/common.mif +++ b/bld/posix/common.mif @@ -16,6 +16,23 @@ # directory posix/src/$(name) must exist, and # contain the source for the command. +!ifndef model +!ifeq host_cpu i86 +model=c +!else ifeq host_cpu 386 +!ifeq host_os qnx +model=s +!else ifeq host_os dos +model=s +!else +model=f +!endif +!endif +!endif + +memory_model_i86=$(model) +memory_model_386=$(model) + # # definitions for POSIX library build # diff --git a/bld/posix/makeall.mif b/bld/posix/makeall.mif index 3bd54d6ec4..0d56f04b97 100644 --- a/bld/posix/makeall.mif +++ b/bld/posix/makeall.mif @@ -8,24 +8,34 @@ proj_name = posix_all posix_all_autodepends = .AUTODEPEND -!include ../model.mif +!include ../common.mif model_switch_i86= model_switch_386= !include cproj.mif !include defrule.mif +defrule_key = stdlib +subdir_stdlib = $(stdlibdir) +extra_cpp_stdlib_i86_flags = -m$(model) +extra_cpp_stdlib_386_flags = -m$(model) +extra_cpp_stdlib_flags = $(extra_cpp_stdlib_$(host_cpu)_flags) +!include defrule.mif +!ifdef alt_posixlib +defrule_key = altlib +subdir_altlib = $(altlibdir) +extra_cpp_altlib_i86s_flags = -mc +extra_cpp_altlib_i86c_flags = -ms +extra_cpp_altlib_flags = $(extra_cpp_altlib_$(host_cpu)$(model)_flags) +!include defrule.mif +!endif !include ../commands.mif -!include ../common.mif inc_dirs += -I"../h" .c: ../misc -subdir_stdlib = $(stdlibdir) -subdir_altlib = $(altlibdir) - libs = $(stdlibdir)/posix.lib !ifdef alt_posixlib libs += $(altlibdir)/posix.lib @@ -40,26 +50,12 @@ all : $(libdirs) $(libs) $(commands) .symbolic @%null !ifdef alt_posixlib -extra_cpp_altlib_i86s_flags = -mc -extra_cpp_altlib_i86c_flags = -ms -extra_cpp_altlib_flags = $(extra_cpp_altlib_$(host_cpu)$(model)_flags) - -defrule_key = altlib -!include defrule.mif - _subdir_ = $(altlibdir)/ libtarg_objs = $(posixlib_objs) libtarg_name = $(_subdir_)posix !include libtarg.mif !endif -extra_cpp_stdlib_i86_flags = -m$(model) -extra_cpp_stdlib_386_flags = -m$(model) -extra_cpp_stdlib_flags = $(extra_cpp_stdlib_$(host_cpu)_flags) - -defrule_key = stdlib -!include defrule.mif - _subdir_ = $(stdlibdir)/ libtarg_objs = $(posixlib_objs) libtarg_name = $(_subdir_)posix diff --git a/bld/posix/makelib.mif b/bld/posix/makelib.mif index 061e80d576..d6b0381917 100644 --- a/bld/posix/makelib.mif +++ b/bld/posix/makelib.mif @@ -6,14 +6,12 @@ proj_name = posix_lib posix_lib_autodepends = .AUTODEPEND -!include ../model.mif +!include ../common.mif !include cproj.mif !include defrule.mif !include deftarg.mif -!include ../common.mif - # # cflags # diff --git a/bld/posix/makeone.mif b/bld/posix/makeone.mif index 1da5fed7d1..085ef2e042 100644 --- a/bld/posix/makeone.mif +++ b/bld/posix/makeone.mif @@ -12,14 +12,12 @@ proj_name = posix posix_autodepends = .AUTODEPEND -!include ../model.mif +!include ../common.mif !include cproj.mif !include defrule.mif !include deftarg.mif -!include ../common.mif - !include tools.mif # diff --git a/bld/posix/model.mif b/bld/posix/model.mif deleted file mode 100644 index 20b0aa22b4..0000000000 --- a/bld/posix/model.mif +++ /dev/null @@ -1,16 +0,0 @@ -!ifndef model -!ifeq host_cpu i86 -model=c -!else ifeq host_cpu 386 -!ifeq host_os qnx -model=s -!else ifeq host_os dos -model=s -!else -model=f -!endif -!endif -!endif - -memory_model_i86=$(model) -memory_model_386=$(model) diff --git a/bld/watcom/c/symtab.c b/bld/watcom/c/symtab.c index 5238555829..b254e6f9d1 100644 --- a/bld/watcom/c/symtab.c +++ b/bld/watcom/c/symtab.c @@ -35,20 +35,22 @@ #include "walloca.h" #include "symtab.h" + symbol_table SymInit( int (*cmp)( void *key1, void *key2 ) ) /**********************************************************/ { symbol_table new; new = malloc( sizeof( * new ) ); - new->head.left = NULL; - new->head.right = NULL; - new->head.equal_subtrees = 0; - new->head.left_heavy = 0; - new->head.key = NULL; - new->height = 0; - new->cmp = cmp; - + if( new != NULL ) { + new->head.left = NULL; + new->head.right = NULL; + new->head.equal_subtrees = 0; + new->head.left_heavy = 0; + new->head.key = NULL; + new->height = 0; + new->cmp = cmp; + } return( new ); } @@ -112,7 +114,7 @@ void *SymFind( symbol_table symtab, void *key ) } } -void SymAdd( symbol_table symtab, void *key ) +bool SymAdd( symbol_table symtab, void *key ) /*******************************************/ { avl_node *curr_search; /* P */ @@ -131,21 +133,25 @@ void SymAdd( symbol_table symtab, void *key ) curr_search = symtab->head.right; if( curr_search == NULL ) { new = malloc( sizeof( avl_node ) ); + if( new == NULL ) + return( false ); new->left = NULL; new->right = NULL; new->key = key; new->equal_subtrees = 1; symtab->head.right = new; - return; + return( true ); } for(;;) { comp = symtab->cmp( key, curr_search->key ); if( comp == 0 ) { - return; + return( true ); } else if( comp > 0 ) { next = curr_search->right; if( next == NULL ) { new = malloc( sizeof( avl_node ) ); + if( new == NULL ) + return( false ); curr_search->right = new; break; } @@ -153,6 +159,8 @@ void SymAdd( symbol_table symtab, void *key ) next = curr_search->left; if( next == NULL ) { new = malloc( sizeof( avl_node ) ); + if( new == NULL ) + return( false ); curr_search->left = new; break; } @@ -188,7 +196,7 @@ void SymAdd( symbol_table symtab, void *key ) balance->equal_subtrees = 0; balance->left_heavy = 1; symtab->height++; - return; + return( true ); } if( balance->left_heavy ) { if( under_balance->left_heavy ) { @@ -221,14 +229,14 @@ void SymAdd( symbol_table symtab, void *key ) } } else { balance->equal_subtrees = 1; - return; + return( true ); } } else { if( balance->equal_subtrees ) { balance->equal_subtrees = 0; balance->left_heavy = 0; symtab->height++; - return; + return( true ); } if( ! balance->left_heavy ) { if( ! under_balance->left_heavy ) { @@ -261,7 +269,7 @@ void SymAdd( symbol_table symtab, void *key ) } } else { balance->equal_subtrees = 1; - return; + return( true ); } } if( balance == father->right ) { @@ -269,12 +277,11 @@ void SymAdd( symbol_table symtab, void *key ) } else { father->left = curr_balance; } - return; + return( true ); } -int SymWalk( symbol_table symtab, void *parm, - int (*process)( void *key1, void *parm ) ) -/********************************************/ +int SymWalk( symbol_table symtab, void *parm, int (*process)( void *key1, void *parm ) ) +/**************************************************************************************/ { avl_node *p; avl_node **stack; diff --git a/bld/watcom/h/symtab.h b/bld/watcom/h/symtab.h index 601ecc0a65..5abd0a6987 100644 --- a/bld/watcom/h/symtab.h +++ b/bld/watcom/h/symtab.h @@ -30,6 +30,9 @@ ****************************************************************************/ +#include "bool.h" + + typedef struct avl_node { struct avl_node *left; struct avl_node *right; @@ -44,21 +47,19 @@ typedef struct symbol_table { avl_node head; } *symbol_table; -symbol_table SymInit( int (*cmp)( void *key1, void *key2 ) ); -void SymAdd( symbol_table symtab, void *key ); -void *SymFind( symbol_table symtab, void *key ); +extern symbol_table SymInit( int (*cmp)( void *key1, void *key2 ) ); +extern bool SymAdd( symbol_table symtab, void *key ); +extern void *SymFind( symbol_table symtab, void *key ); /* SymFini destroys the symbol_table and all the avl_nodes in the tree. If you want to free the key's then you must do it by SymWalking before SymFini. */ -void SymFini( symbol_table symtab ); +extern void SymFini( symbol_table symtab ); /* For SymWalk: If process returns -1 then abort the walking. If process returns 0 then continue walking. SymWalk returns -1 if walking aborted, 0 otherwise. SymWalk does an in-order walk of the symbol table. */ -int SymWalk( symbol_table symtab, void *parm, - int (*process)( void *key, void *parm ) ); - +extern int SymWalk( symbol_table symtab, void *parm, int (*process)( void *key, void *parm ) ); diff --git a/bld/wic/c/symtab.c b/bld/wic/c/symtab.c deleted file mode 100644 index c3cdca4fa3..0000000000 --- a/bld/wic/c/symtab.c +++ /dev/null @@ -1,325 +0,0 @@ -/**************************************************************************** -* -* Open Watcom Project -* -* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. -* -* ======================================================================== -* -* This file contains Original Code and/or Modifications of Original -* Code as defined in and that are subject to the Sybase Open Watcom -* Public License version 1.0 (the 'License'). You may not use this file -* except in compliance with the License. BY USING THIS FILE YOU AGREE TO -* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is -* provided with the Original Code and Modifications, and is also -* available at www.sybase.com/developer/opensource. -* -* The Original Code and all software distributed under the License are -* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER -* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM -* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF -* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR -* NON-INFRINGEMENT. Please see the License for the specific language -* governing rights and limitations under the License. -* -* ======================================================================== -* -* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE -* DESCRIBE IT HERE! -* -****************************************************************************/ - - -#include -#include -#include "symtab.h" -#include "walloca.h" - -symbol_table SymInit( int (*cmp)( void *key1, void *key2 ) ) -/**********************************************************/ -{ - symbol_table new; - - new = malloc( sizeof( * new ) ); - if (new == NULL) { /* 22 Sep 93 */ - return NULL; - } - new->head.left = NULL; - new->head.right = NULL; - new->head.equal_subtrees = 0; - new->head.left_heavy = 0; - new->head.key = NULL; - new->height = 0; - new->cmp = cmp; - - return( new ); -} - -void SymFini( symbol_table symtab ) -/*********************************/ -{ - avl_node *p; - avl_node *p_right; - avl_node **stack; - avl_node **sp; - - p = symtab->head.right; - if( p != NULL ) { - stack = alloca( symtab->height * sizeof( avl_node * ) ); - sp = stack; - for(;;) { - /* process tree rooted at 'p' */ - if( p->left ) { - *sp = p; - ++sp; - p = p->left; - continue; - } - left_subtree_is_done: - p_right = p->right; /* save right pointer past free call */ - free( p ); - if( p_right ) { - p = p_right; - continue; - } - if( sp == stack ) break; - --sp; - p = *sp; - goto left_subtree_is_done; - } - } - free( symtab ); -} - -void *SymFind( symbol_table symtab, void *key ) -/*********************************************/ -{ - avl_node *curr_search; - avl_node *next; - int comp; - - curr_search = symtab->head.right; - for(;;) { - if( curr_search == NULL ) { - return( NULL ); - } - comp = symtab->cmp( key, curr_search->key ); - if( comp == 0 ) { - return( curr_search->key ); - } else if( comp < 0 ) { - next = curr_search->left; - } else { - next = curr_search->right; - } - curr_search = next; - } -} - -int SymAdd( symbol_table symtab, void *key ) -/*******************************************/ -{ - avl_node *curr_search; /* P */ - avl_node *curr_adjust; /* P */ - avl_node *curr_balance; /* P */ - avl_node *father; /* T */ - avl_node *balance; /* S */ - avl_node *under_balance; /* R */ - avl_node *next; /* Q */ - avl_node *new; /* Q */ - int comp; - - /* algorithm is from Knuth Vol. 3 (2nd edition) p.445 */ - father = &(symtab->head); - balance = symtab->head.right; - curr_search = symtab->head.right; - if( curr_search == NULL ) { - new = malloc( sizeof( avl_node ) ); - if (new == NULL) { /* 21-Sep-93 */ - return 0; - } - new->left = NULL; - new->right = NULL; - new->key = key; - new->equal_subtrees = 1; - symtab->head.right = new; - return 1; - } - for(;;) { - comp = symtab->cmp( key, curr_search->key ); - if( comp == 0 ) { - return 1; - } else if( comp > 0 ) { - next = curr_search->right; - if( next == NULL ) { - new = malloc( sizeof( avl_node ) ); - if (new == NULL) { /* 21-Sep-93 */ - return 0; - } - curr_search->right = new; - break; - } - } else { - next = curr_search->left; - if( next == NULL ) { - new = malloc( sizeof( avl_node ) ); - if (new == NULL) { /* 21-Sep-93 */ - return 0; - } - curr_search->left = new; - break; - } - } - if( ! next->equal_subtrees ) { - father = curr_search; - balance = next; - } - curr_search = next; - } - new->left = NULL; - new->right = NULL; - new->key = key; - new->equal_subtrees = 1; - if( symtab->cmp( key, balance->key ) < 0 ) { - under_balance = balance->left; - } else { - under_balance = balance->right; - } - curr_adjust = under_balance; - while( curr_adjust != new ) { - curr_adjust->equal_subtrees = 0; - if( symtab->cmp( key, curr_adjust->key ) < 0 ) { - curr_adjust->left_heavy = 1; - curr_adjust = curr_adjust->left; - } else { - curr_adjust->left_heavy = 0; - curr_adjust = curr_adjust->right; - } - } - if( symtab->cmp( key, balance->key ) < 0 ) { - if( balance->equal_subtrees ) { - balance->equal_subtrees = 0; - balance->left_heavy = 1; - symtab->height++; - return 1; - } - if( balance->left_heavy ) { - if( under_balance->left_heavy ) { - /* single rotation */ - curr_balance = under_balance; - balance->left = under_balance->right; - under_balance->right = balance; - balance->equal_subtrees = 1; - under_balance->equal_subtrees = 1; - } else { - /* double rotation */ - curr_balance = under_balance->right; - under_balance->right = curr_balance->left; - curr_balance->left = under_balance; - balance->left = curr_balance->right; - curr_balance->right = balance; - if( curr_balance->equal_subtrees ) { - balance->equal_subtrees = 1; - under_balance->equal_subtrees = 1; - } else if( curr_balance->left_heavy ) { - balance->equal_subtrees = 0; - balance->left_heavy = 0; - under_balance->equal_subtrees = 1; - } else { - balance->equal_subtrees = 1; - under_balance->equal_subtrees = 0; - under_balance->left_heavy = 1; - } - curr_balance->equal_subtrees = 1; - } - } else { - balance->equal_subtrees = 1; - return 1; - } - } else { - if( balance->equal_subtrees ) { - balance->equal_subtrees = 0; - balance->left_heavy = 0; - symtab->height++; - return 1; - } - if( ! balance->left_heavy ) { - if( ! under_balance->left_heavy ) { - /* single rotation */ - curr_balance = under_balance; - balance->right = under_balance->left; - under_balance->left = balance; - balance->equal_subtrees = 1; - under_balance->equal_subtrees = 1; - } else { - /* double rotation */ - curr_balance = under_balance->left; - under_balance->left = curr_balance->right; - curr_balance->right = under_balance; - balance->right = curr_balance->left; - curr_balance->left = balance; - if( curr_balance->equal_subtrees ) { - balance->equal_subtrees = 1; - under_balance->equal_subtrees = 1; - } else if( ! curr_balance->left_heavy ) { - balance->equal_subtrees = 0; - balance->left_heavy = 1; - under_balance->equal_subtrees = 1; - } else { - balance->equal_subtrees = 1; - under_balance->equal_subtrees = 0; - under_balance->left_heavy = 0; - } - curr_balance->equal_subtrees = 1; - } - } else { - balance->equal_subtrees = 1; - return 1; - } - } - if( balance == father->right ) { - father->right = curr_balance; - } else { - father->left = curr_balance; - } - return 1; -} - -int SymWalk( symbol_table symtab, void *parm, - int (*process)( void *key1, void *parm ) ) -/********************************************/ -{ - avl_node *p; - avl_node **stack; - avl_node **sp; - int ret_code; - - p = symtab->head.right; - if( p == NULL ) { /* 16-Oct-90 DJG */ - return( 0 ); - } - stack = alloca( symtab->height * sizeof( avl_node * ) ); - sp = stack; - for(;;) { - /* print tree rooted at 'p' */ - if( p->left ) { - *sp = p; - ++sp; - p = p->left; - continue; - } - left_subtree_is_done: - ret_code = process( p->key, parm ); - if( ret_code != 0 ) { - return( ret_code ); - } - if( p->right ) { - p = p->right; - continue; - } - if( sp == stack ) break; - --sp; - p = *sp; - goto left_subtree_is_done; - } - return( 0 ); -} diff --git a/bld/wic/h/symtab.h b/bld/wic/h/symtab.h deleted file mode 100644 index 307fd63750..0000000000 --- a/bld/wic/h/symtab.h +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -* -* Open Watcom Project -* -* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. -* -* ======================================================================== -* -* This file contains Original Code and/or Modifications of Original -* Code as defined in and that are subject to the Sybase Open Watcom -* Public License version 1.0 (the 'License'). You may not use this file -* except in compliance with the License. BY USING THIS FILE YOU AGREE TO -* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is -* provided with the Original Code and Modifications, and is also -* available at www.sybase.com/developer/opensource. -* -* The Original Code and all software distributed under the License are -* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER -* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM -* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF -* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR -* NON-INFRINGEMENT. Please see the License for the specific language -* governing rights and limitations under the License. -* -* ======================================================================== -* -* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE -* DESCRIBE IT HERE! -* -****************************************************************************/ - - -typedef struct avl_node { - struct avl_node *left; - struct avl_node *right; - void *key; - unsigned char equal_subtrees : 1; - unsigned char left_heavy : 1; -} avl_node; - -typedef struct symbol_table { - int (*cmp)( void *key1, void *key2 ); - unsigned height; - avl_node head; -} *symbol_table; - -symbol_table SymInit( int (*cmp)( void *key1, void *key2 ) ); -int SymAdd( symbol_table symtab, void *key ); -void *SymFind( symbol_table symtab, void *key ); -/* - SymFini destroys the symbol_table and all the avl_nodes in the tree. - If you want to free the key's then you must do it by SymWalking before - SymFini. -*/ -void SymFini( symbol_table symtab ); -/* - For SymWalk: If process returns -1 then abort the walking. - If process returns 0 then continue walking. - SymWalk returns -1 if walking aborted, 0 otherwise. - SymWalk does an in-order walk of the symbol table. -*/ -int SymWalk( symbol_table symtab, void *parm, - int (*process)( void *key, void *parm ) ); - diff --git a/bld/wic/master.mif b/bld/wic/master.mif index 7d42804523..66429dbf43 100644 --- a/bld/wic/master.mif +++ b/bld/wic/master.mif @@ -20,7 +20,7 @@ wic_trmem = 1 # # cflags # -.c : ../c;$(trmem_dir) +.c : ../c;$(trmem_dir);$(watcom_dir)/c inc_dirs = -I"../h" From abb8499a3d8a4ada6a498c6a692be353caa8c96e Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Fri, 1 Sep 2023 17:02:59 +0200 Subject: [PATCH 074/258] correct return value of _bios_timeofday function in documentation --- docs/doc/lr/src/b_time.gml | 2 +- docs/doc/lr/src/b_time98.gml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/doc/lr/src/b_time.gml b/docs/doc/lr/src/b_time.gml index 45aba8e369..48aaf8112a 100644 --- a/docs/doc/lr/src/b_time.gml +++ b/docs/doc/lr/src/b_time.gml @@ -1,7 +1,7 @@ .func _bios_timeofday .synop begin #include -int _bios_timeofday( int service, long *timeval ); +unsigned short _bios_timeofday( int service, long *timeval ); .ixfunc2 '&BiosFunc' &funcb .synop end .desc begin diff --git a/docs/doc/lr/src/b_time98.gml b/docs/doc/lr/src/b_time98.gml index c4caa0a06c..f96d4f4cb2 100644 --- a/docs/doc/lr/src/b_time98.gml +++ b/docs/doc/lr/src/b_time98.gml @@ -1,7 +1,7 @@ .func _bios_timeofday for NEC PC98 .synop begin #include -unsigned _bios_timeofday( unsigned service, +unsigned short _bios_timeofday( unsigned service, char *timeval ); .ixfunc2 '&BiosFunc' &funcb .synop end From cb86547b47f5ad4607065f8b5586634e32fde291 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Fri, 1 Sep 2023 17:04:58 +0200 Subject: [PATCH 075/258] correct type mismatch --- bld/wpi/c/wpi_os2.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bld/wpi/c/wpi_os2.c b/bld/wpi/c/wpi_os2.c index d773aa4663..56d2b4a532 100644 --- a/bld/wpi/c/wpi_os2.c +++ b/bld/wpi/c/wpi_os2.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2015-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2015-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -115,7 +115,7 @@ static unsigned _wpi_getmenuitemidfrompos( HMENU hmenu, int pos ) if( result != (MRESULT)MIT_ERROR ) { return( (unsigned)result ); } - return( -1 ); + return( (unsigned)-1 ); } static BOOL _wpi_getmenuparentpos( HMENU hmenu, unsigned id, HMENU *parent, int *pos_parent ) @@ -828,7 +828,7 @@ BOOL _wpi_appendmenu( HMENU hmenu, unsigned menu_flags, unsigned attr_flags, unsigned new_id, HMENU popup, const char *text ) { - return( _wpi_insertmenu( hmenu, -1, menu_flags, attr_flags, new_id, popup, text, TRUE ) ); + return( _wpi_insertmenu( hmenu, (unsigned)-1, menu_flags, attr_flags, new_id, popup, text, TRUE ) ); } BOOL _wpi_getmenustate( HMENU hmenu, unsigned id, WPI_MENUSTATE *state, BOOL by_position ) From d62bec47f893857592a984a5482f122e3a8126e2 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Fri, 1 Sep 2023 18:48:46 +0200 Subject: [PATCH 076/258] remove old/unused macros --- bld/watcom/h/banner.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/bld/watcom/h/banner.h b/bld/watcom/h/banner.h index e810a24c89..d7796b6b76 100644 --- a/bld/watcom/h/banner.h +++ b/bld/watcom/h/banner.h @@ -58,9 +58,6 @@ #define banner1(p,v) p " " banner1v(v) #define banner1w(p,v) banner1t(p) " " banner1v(v) -#define banner1w1(p) banner1t(p) -#define banner1w2(v) banner1v(v) - #define banner21 "Copyright (c) 2002-" _MACROSTR( _CYEAR ) " The Open Watcom Contributors." #define banner21a(year) "Portions Copyright (c) " _DOSTR( year ) "-2002 Sybase, Inc." From d9051fcbdaf88a3a71b5d0cbff30fd466650e6d5 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Sat, 2 Sep 2023 22:28:05 +0200 Subject: [PATCH 077/258] enable global use of PackBuff for trap clients --- bld/trap/common/packet.c | 4 +++- bld/trap/common/packet.h | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/bld/trap/common/packet.c b/bld/trap/common/packet.c index b4f319aa79..2fa5f456d0 100644 --- a/bld/trap/common/packet.c +++ b/bld/trap/common/packet.c @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -37,7 +38,8 @@ #include "trptypes.h" #include "packet.h" -static char PackBuff[0x400]; + +char PackBuff[0x400]; static trap_elen PackInd = 0; diff --git a/bld/trap/common/packet.h b/bld/trap/common/packet.h index b74c066f14..a1f5c5c581 100644 --- a/bld/trap/common/packet.h +++ b/bld/trap/common/packet.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -30,6 +31,8 @@ ****************************************************************************/ +extern char PackBuff[0x400]; + #if defined( SERVER ) extern trap_retval PutBuffPacket( void *, trap_elen ); extern void *GetPacketBuffPtr( void ); From 43a1656bf118e3bccda0f2e0e12566e5866b34cc Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Sat, 2 Sep 2023 22:28:57 +0200 Subject: [PATCH 078/258] use PackBuff for temporary names --- bld/trap/vdm/c/vdmcli.c | 10 +++++----- bld/trap/vdm/c/vdmcli2.c | 10 +++++----- bld/trap/vdm/c/vdmclint.c | 11 +++++------ bld/trap/vdm/c/vdmlink.c | 26 +++++++++++++------------- bld/trap/vdm/h/vdm.h | 5 ++++- 5 files changed, 32 insertions(+), 30 deletions(-) diff --git a/bld/trap/vdm/c/vdmcli.c b/bld/trap/vdm/c/vdmcli.c index 53fc15220a..8ae4612231 100644 --- a/bld/trap/vdm/c/vdmcli.c +++ b/bld/trap/vdm/c/vdmcli.c @@ -48,24 +48,24 @@ #include "namepipe.h" #include "vdm.h" + HPIPE pipeHdl; const char *RemoteLink( const char *parms, bool server ) { APIRET rc; - char buf[PREFIX_LEN + MAX_NAME + 1]; if( server ) return( "this should never be seen" ); - strcpy( buf, PREFIX ); + strcpy( PackBuff, PREFIX ); if( *parms == '\0' ) { - strcpy( buf + PREFIX_LEN, DEFAULT_LINK_NAME ); + strcpy( PackBuff + PREFIX_LEN, DEFAULT_LINK_NAME ); } else if( ValidName( parms ) ) { - strcpy( buf + PREFIX_LEN, parms ); + strcpy( PackBuff + PREFIX_LEN, parms ); } else { return( TRP_ERR_invalid_server_name ); } - rc = DosMakeNmPipe( buf, &pipeHdl, + rc = DosMakeNmPipe( PackBuff, &pipeHdl, NP_NOINHERIT | NP_NOWRITEBEHIND | NP_ACCESS_DUPLEX, NP_NOWAIT | NP_READMODE_BYTE | NP_TYPE_BYTE | 1, MAX_TRANS, MAX_TRANS, 0 ); diff --git a/bld/trap/vdm/c/vdmcli2.c b/bld/trap/vdm/c/vdmcli2.c index 6259be3956..c9fa4b9f01 100644 --- a/bld/trap/vdm/c/vdmcli2.c +++ b/bld/trap/vdm/c/vdmcli2.c @@ -43,24 +43,24 @@ #include "trperr.h" #include "packet.h" + HPIPE pipeHdl; const char *RemoteLink( const char *parms, bool server ) { APIRET rc; - char buf[PREFIX_LEN + MAX_NAME + 1]; if( server ) return "this should never be seen"; - strcpy( buf, PREFIX ); + strcpy( PackBuff, PREFIX ); if( *parms == '\0' ) { - strcpy( buf + PREFIX_LEN, DEFAULT_LINK_NAME ); + strcpy( PackBuff + PREFIX_LEN, DEFAULT_LINK_NAME ); } else if( ValidName( parms ) ) { - strcpy( buf + PREFIX_LEN, parms ); + strcpy( PackBuff + PREFIX_LEN, parms ); } else { return( TRP_ERR_invalid_server_name ); } - rc = DosCreateNPipe( buf, &pipeHdl, + rc = DosCreateNPipe( PackBuff, &pipeHdl, NP_NOINHERIT | NP_NOWRITEBEHIND | NP_ACCESS_DUPLEX, NP_NOWAIT | NP_READMODE_BYTE | NP_TYPE_BYTE | 1, MAX_TRANS, MAX_TRANS, 0 ); diff --git a/bld/trap/vdm/c/vdmclint.c b/bld/trap/vdm/c/vdmclint.c index be0e643db9..8a9ad0303e 100644 --- a/bld/trap/vdm/c/vdmclint.c +++ b/bld/trap/vdm/c/vdmclint.c @@ -49,25 +49,24 @@ #include "trperr.h" #include "packet.h" + HANDLE pipeHdl; #define NT_PREF_LEN (MACH_NAME_LEN + PREFIX_LEN) const char *RemoteLink( const char *parms, bool server ) { - char buf[NT_PREF_LEN + MAX_NAME + 1]; - if( server ) return( "this should never be seen" ); - strcpy( buf, NT_MACH_NAME PREFIX ); + strcpy( PackBuff, NT_MACH_NAME PREFIX ); if( *parms == '\0' ) { - strcpy( buf + NT_PREF_LEN, DEFAULT_LINK_NAME ); + strcpy( PackBuff + NT_PREF_LEN, DEFAULT_LINK_NAME ); } else if( ValidName( parms ) ) { - strcpy( buf + NT_PREF_LEN, parms ); + strcpy( PackBuff + NT_PREF_LEN, parms ); } else { return( TRP_ERR_invalid_server_name ); } - pipeHdl = CreateNamedPipe( buf, + pipeHdl = CreateNamedPipe( PackBuff, PIPE_ACCESS_DUPLEX | FILE_FLAG_WRITE_THROUGH, PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_NOWAIT, 1, MAX_TRANS, MAX_TRANS, 0, NULL ); diff --git a/bld/trap/vdm/c/vdmlink.c b/bld/trap/vdm/c/vdmlink.c index 52563fa0fd..f2b3352abf 100644 --- a/bld/trap/vdm/c/vdmlink.c +++ b/bld/trap/vdm/c/vdmlink.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -40,35 +40,35 @@ #include "trptypes.h" -int ValidName( const char *name ) { - +bool ValidName( const char *name ) +{ char *end; char *dot; end = memchr( name, 0, MAX_NAME ); if( end == NULL ) - return( 0 ); + return( false ); if( end == name ) - return( 0 ); + return( false ); dot = memchr( name, '.', end - name ); if( dot != NULL ) { if( dot == name ) - return( 0 ); + return( false ); if( dot - name > 8 ) - return( 0 ); + return( false ); if( end - dot > 4 ) - return( 0 ); + return( false ); if( dot[1] == '.' || dot[2] == '.' || dot[3] == '.' ) { - return( 0 ); + return( false ); } } else { if( end - name > 8 ) { - return( 0 ); + return( false ); } } while( name < end ) { if( *name <= 0x1f ) - return( 0 ); + return( false ); switch( *name ) { case '"': case '/': @@ -81,9 +81,9 @@ int ValidName( const char *name ) { case '>': case '&': case '|': - return( 0 ); + return( false ); } ++name; } - return( 1 ); + return( true ); } diff --git a/bld/trap/vdm/h/vdm.h b/bld/trap/vdm/h/vdm.h index fd77469cb1..c6272ccbc8 100644 --- a/bld/trap/vdm/h/vdm.h +++ b/bld/trap/vdm/h/vdm.h @@ -31,6 +31,9 @@ ****************************************************************************/ +#include "bool.h" + + #define NT_MACH_NAME "\\\\." #define PREFIX "\\PIPE\\" #define PREFIX_LEN (sizeof( PREFIX ) - 1) @@ -40,5 +43,5 @@ #define DEFAULT_LINK_NAME "VDMLink" -extern int ValidName( const char *name ); +extern bool ValidName( const char *name ); From a0a11ede7620f66c87330e4a73c147605531990d Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Sun, 3 Sep 2023 02:16:02 +0200 Subject: [PATCH 079/258] consolidate vdmcli...c, vdmserv.c source files into single vdmlink.c file --- bld/trap/vdm/c/options.c | 2 +- bld/trap/vdm/c/vdmcli.c | 164 --------------- bld/trap/vdm/c/vdmcli2.c | 158 --------------- bld/trap/vdm/c/vdmclint.c | 165 ---------------- bld/trap/vdm/c/vdmlink.c | 339 +++++++++++++++++++++++++++++++- bld/trap/vdm/c/vdmserv.c | 161 --------------- bld/trap/vdm/dos.srv/makefile | 2 - bld/trap/vdm/nt386.trp/makefile | 2 - bld/trap/vdm/os2.trp/makefile | 2 - bld/trap/vdm/os2v2.trp/makefile | 1 - bld/trap/vdm/win.srv/makefile | 2 - 11 files changed, 338 insertions(+), 660 deletions(-) delete mode 100644 bld/trap/vdm/c/vdmcli.c delete mode 100644 bld/trap/vdm/c/vdmcli2.c delete mode 100644 bld/trap/vdm/c/vdmclint.c delete mode 100644 bld/trap/vdm/c/vdmserv.c diff --git a/bld/trap/vdm/c/options.c b/bld/trap/vdm/c/options.c index b3f84f67f4..964f10cd32 100644 --- a/bld/trap/vdm/c/options.c +++ b/bld/trap/vdm/c/options.c @@ -38,7 +38,7 @@ WINEXPORT INT_PTR CALLBACK OptionsDlgProc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam ) { - lparam = lparam; /* turn off warning */ + (void)lparam; /* turn off warning */ switch( msg ) { case WM_INITDIALOG: diff --git a/bld/trap/vdm/c/vdmcli.c b/bld/trap/vdm/c/vdmcli.c deleted file mode 100644 index 8ae4612231..0000000000 --- a/bld/trap/vdm/c/vdmcli.c +++ /dev/null @@ -1,164 +0,0 @@ -/**************************************************************************** -* -* Open Watcom Project -* -* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. -* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. -* -* ======================================================================== -* -* This file contains Original Code and/or Modifications of Original -* Code as defined in and that are subject to the Sybase Open Watcom -* Public License version 1.0 (the 'License'). You may not use this file -* except in compliance with the License. BY USING THIS FILE YOU AGREE TO -* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is -* provided with the Original Code and Modifications, and is also -* available at www.sybase.com/developer/opensource. -* -* The Original Code and all software distributed under the License are -* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER -* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM -* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF -* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR -* NON-INFRINGEMENT. Please see the License for the specific language -* governing rights and limitations under the License. -* -* ======================================================================== -* -* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE -* DESCRIBE IT HERE! -* -****************************************************************************/ - - -// -// VDMCLI : client (trapfile) end of VDM interface -// - -#include - -#define INCL_DOSNMPIPES -#define INCL_DOSPROCESS -#include -#define INCL_NOXLATE_DOS16 -#include "watcom.h" -#include "trperr.h" -#include "trptypes.h" -#include "packet.h" -#include "namepipe.h" -#include "vdm.h" - - -HPIPE pipeHdl; - -const char *RemoteLink( const char *parms, bool server ) -{ - APIRET rc; - - if( server ) - return( "this should never be seen" ); - strcpy( PackBuff, PREFIX ); - if( *parms == '\0' ) { - strcpy( PackBuff + PREFIX_LEN, DEFAULT_LINK_NAME ); - } else if( ValidName( parms ) ) { - strcpy( PackBuff + PREFIX_LEN, parms ); - } else { - return( TRP_ERR_invalid_server_name ); - } - rc = DosMakeNmPipe( PackBuff, &pipeHdl, - NP_NOINHERIT | NP_NOWRITEBEHIND | NP_ACCESS_DUPLEX, - NP_NOWAIT | NP_READMODE_BYTE | NP_TYPE_BYTE | 1, - MAX_TRANS, MAX_TRANS, 0 ); - if( rc != 0 ) { - /* the bseerr in watcom\h doesn't have ERROR_PIPE_BUSY in it */ - if( rc == 231 ) - return( TRP_ERR_server_name_already_in_use ); - return( TRP_ERR_unable_to_access_server ); - } - return( NULL ); -} - - -bool RemoteConnect( void ) -{ - APIRET rc; - int try; - - /* - We initially opened the pipe non-blocking so that we can poll - to see if the server has connected to the pipe. - */ - for( try = 0; try < 25; ++try ) { - rc = DosConnectNmPipe( pipeHdl ); - if( rc == 0 ) { - /* - Now that the server has connected we have to set the pipe - to blocking mode. - */ - rc = DosSetNmPHandState( pipeHdl, NP_WAIT | NP_READMODE_BYTE ); - if( rc != 0 ) { - DosDisConnectNmPipe( pipeHdl ); - return( false ); - } - return( true ); - } - DosSleep( 200 ); - } - return( false ); -} - - -trap_retval RemoteGet( void *data, trap_elen len ) -{ - unsigned_16 incoming; - USHORT bytes_read; - unsigned ret; - - len = len; - DosRead( pipeHdl, &incoming, sizeof( incoming ), &bytes_read ); - ret = incoming; - while( incoming != 0 ) { - DosRead( pipeHdl, data, incoming, &bytes_read ); - data = (char *)data + bytes_read; - incoming -= bytes_read; - } - return( ret ); -} - - -trap_retval RemotePut( void *data, trap_elen len ) -{ - unsigned_16 outgoing; - USHORT bytes_written; - - outgoing = len; - DosWrite( pipeHdl, &outgoing, sizeof( outgoing ), &bytes_written ); - if( len > 0 ) { - DosWrite( pipeHdl, data, len, &bytes_written ); - } - return( len ); -} - - -void RemoteDisco( void ) -{ - APIRET rc; - USHORT bytes_read; - char tmp[MAX_TRANS]; - - /* - Before disconnecting we must wait until the server has closed - their connection. Otherwise we might throw away the last message - in the pipe (usually the message that says 'close the connection'). - */ - do { - rc = DosRead( pipeHdl, tmp, MAX_TRANS, &bytes_read ); - } while( rc == 0 && bytes_read != 0 ); - DosDisConnectNmPipe( pipeHdl ); -} - - -void RemoteUnLink( void ) -{ - DosClose( pipeHdl ); -} diff --git a/bld/trap/vdm/c/vdmcli2.c b/bld/trap/vdm/c/vdmcli2.c deleted file mode 100644 index c9fa4b9f01..0000000000 --- a/bld/trap/vdm/c/vdmcli2.c +++ /dev/null @@ -1,158 +0,0 @@ -/**************************************************************************** -* -* Open Watcom Project -* -* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. -* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. -* -* ======================================================================== -* -* This file contains Original Code and/or Modifications of Original -* Code as defined in and that are subject to the Sybase Open Watcom -* Public License version 1.0 (the 'License'). You may not use this file -* except in compliance with the License. BY USING THIS FILE YOU AGREE TO -* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is -* provided with the Original Code and Modifications, and is also -* available at www.sybase.com/developer/opensource. -* -* The Original Code and all software distributed under the License are -* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER -* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM -* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF -* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR -* NON-INFRINGEMENT. Please see the License for the specific language -* governing rights and limitations under the License. -* -* ======================================================================== -* -* Description: Client (trapfile) end of VDM remote debug interface. -* -****************************************************************************/ - - -#include - -#define INCL_DOSNMPIPES -#define INCL_DOSPROCESS -#define INCL_DOSERRORS -#include -#include "watcom.h" -#include "namepipe.h" -#include "vdm.h" -#include "trptypes.h" -#include "trperr.h" -#include "packet.h" - - -HPIPE pipeHdl; - -const char *RemoteLink( const char *parms, bool server ) -{ - APIRET rc; - - if( server ) - return "this should never be seen"; - strcpy( PackBuff, PREFIX ); - if( *parms == '\0' ) { - strcpy( PackBuff + PREFIX_LEN, DEFAULT_LINK_NAME ); - } else if( ValidName( parms ) ) { - strcpy( PackBuff + PREFIX_LEN, parms ); - } else { - return( TRP_ERR_invalid_server_name ); - } - rc = DosCreateNPipe( PackBuff, &pipeHdl, - NP_NOINHERIT | NP_NOWRITEBEHIND | NP_ACCESS_DUPLEX, - NP_NOWAIT | NP_READMODE_BYTE | NP_TYPE_BYTE | 1, - MAX_TRANS, MAX_TRANS, 0 ); - if( rc != 0 ) { - if( rc == ERROR_PIPE_BUSY ) - return( TRP_ERR_server_name_already_in_use ); - return( TRP_ERR_unable_to_access_server ); - } - return( NULL ); -} - - -bool RemoteConnect(void) -{ - APIRET rc; - int try; - - /* - We initially opened the pipe non-blocking so that we can poll - to see if the server has connected to the pipe. - */ - for (try = 0; try < 25; ++try) { - rc = DosConnectNPipe(pipeHdl); - if (rc == 0) { - /* - Now that the server has connected we have to set the pipe - to blocking mode. - */ - rc = DosSetNPHState(pipeHdl, NP_WAIT | NP_READMODE_BYTE); - if (rc != 0) { - DosDisConnectNPipe(pipeHdl); - return( FALSE ); - } - return( TRUE ); - } - DosSleep(200); - } - return( FALSE ); -} - - -trap_retval RemoteGet( void *data, trap_elen len ) -{ - unsigned_16 incoming; - ULONG bytes_read; - ULONG ret; - - len = len; - DosRead( pipeHdl, &incoming, sizeof( incoming ), &bytes_read ); - ret = incoming; - while( incoming != 0 ) { - DosRead( pipeHdl, data, incoming, &bytes_read ); - data = (char *)data + bytes_read; - incoming -= bytes_read; - } - return ret; -} - - -trap_retval RemotePut( void *data, trap_elen len ) -{ - unsigned_16 outgoing; - ULONG bytes_written; - - outgoing = len; - DosWrite( pipeHdl, &outgoing, sizeof( outgoing ), &bytes_written ); - if( len > 0 ) { - DosWrite( pipeHdl, data, len, &bytes_written ); - } - return( len ); -} - - -void RemoteDisco(void) -{ - APIRET rc; - ULONG bytes_read; - char tmp[MAX_TRANS]; - - /* - Before disconnecting we must wait until the server has closed - their connection. Otherwise we might throw away the last message - in the pipe (usually the message that says 'close the connection'). - */ - do { - rc = DosRead(pipeHdl, tmp, MAX_TRANS, &bytes_read); - } while (rc == 0 && bytes_read != 0); - DosDisConnectNPipe(pipeHdl); -} - - -void RemoteUnLink(void) -{ - DosClose(pipeHdl); -} diff --git a/bld/trap/vdm/c/vdmclint.c b/bld/trap/vdm/c/vdmclint.c deleted file mode 100644 index 8a9ad0303e..0000000000 --- a/bld/trap/vdm/c/vdmclint.c +++ /dev/null @@ -1,165 +0,0 @@ -/**************************************************************************** -* -* Open Watcom Project -* -* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. -* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. -* -* ======================================================================== -* -* This file contains Original Code and/or Modifications of Original -* Code as defined in and that are subject to the Sybase Open Watcom -* Public License version 1.0 (the 'License'). You may not use this file -* except in compliance with the License. BY USING THIS FILE YOU AGREE TO -* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is -* provided with the Original Code and Modifications, and is also -* available at www.sybase.com/developer/opensource. -* -* The Original Code and all software distributed under the License are -* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER -* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM -* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF -* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR -* NON-INFRINGEMENT. Please see the License for the specific language -* governing rights and limitations under the License. -* -* ======================================================================== -* -* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE -* DESCRIBE IT HERE! -* -****************************************************************************/ - - -// -// VDMCLI : client (trapfile) end of VDM interface -// - -// Modified: By: Reason: -// --------- --- ------- -// 94/04/20 B.J. Stecher NT version - -#include - -#include -#include "watcom.h" -#include "namepipe.h" -#include "vdm.h" -#include "trptypes.h" -#include "trperr.h" -#include "packet.h" - - -HANDLE pipeHdl; - -#define NT_PREF_LEN (MACH_NAME_LEN + PREFIX_LEN) - -const char *RemoteLink( const char *parms, bool server ) -{ - if( server ) - return( "this should never be seen" ); - strcpy( PackBuff, NT_MACH_NAME PREFIX ); - if( *parms == '\0' ) { - strcpy( PackBuff + NT_PREF_LEN, DEFAULT_LINK_NAME ); - } else if( ValidName( parms ) ) { - strcpy( PackBuff + NT_PREF_LEN, parms ); - } else { - return( TRP_ERR_invalid_server_name ); - } - pipeHdl = CreateNamedPipe( PackBuff, - PIPE_ACCESS_DUPLEX | FILE_FLAG_WRITE_THROUGH, - PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_NOWAIT, - 1, MAX_TRANS, MAX_TRANS, 0, NULL ); - if( pipeHdl == INVALID_HANDLE_VALUE ) { - if( GetLastError() == ERROR_PIPE_BUSY ) - return( TRP_ERR_server_name_already_in_use ); - return( TRP_ERR_unable_to_access_server ); - } - return( NULL ); -} - - -bool RemoteConnect( void ) -{ - DWORD mode; - int try; - - /* - We initially opened the pipe non-blocking so that we can poll - to see if the server has connected to the pipe. - */ - for( try = 0; try < 25; ++try ) { - SetLastError( 0 ); - ConnectNamedPipe( pipeHdl, NULL ); - if( GetLastError() == ERROR_PIPE_CONNECTED ) { - /* - Now that the server has connected we have to set the pipe - to blocking mode. - */ - mode = PIPE_READMODE_BYTE | PIPE_WAIT; - if( !SetNamedPipeHandleState( pipeHdl, &mode, NULL, NULL ) ) { - DisconnectNamedPipe( pipeHdl ); - return( FALSE ); - } - return( TRUE ); - } - Sleep( 200 ); - } - return( FALSE ); -} - - -trap_retval RemoteGet( void *data, trap_elen len ) -{ - unsigned_16 incoming; - ULONG bytes_read; - trap_elen ret; - - len = len; - ReadFile( pipeHdl, &incoming, sizeof( incoming ), &bytes_read, NULL ); - ret = incoming; - while( incoming != 0 ) { - ReadFile( pipeHdl, data, incoming, &bytes_read, NULL ); - data = (char *)data + bytes_read; - incoming -= bytes_read; - } - return( ret ); -} - - -trap_retval RemotePut( void *data, trap_elen len ) -{ - unsigned_16 outgoing; - ULONG bytes_written; - - outgoing = len; - WriteFile( pipeHdl, &outgoing, sizeof( outgoing ), &bytes_written, NULL ); - if( len > 0 ) { - WriteFile( pipeHdl, data, len, &bytes_written, NULL ); - } - return( len ); -} - - -void RemoteDisco( void ) -{ - BOOL rc; - DWORD bytes_read; - char tmp[MAX_TRANS]; - - /* - Before disconnecting we must wait until the server has closed - their connection. Otherwise we might throw away the last message - in the pipe (usually the message that says 'close the connection'). - */ - do { - rc = ReadFile( pipeHdl, tmp, sizeof( tmp ), &bytes_read, NULL ); - } while( rc && bytes_read != 0 ); - DisconnectNamedPipe( pipeHdl ); -} - - -void RemoteUnLink( void ) -{ - CloseHandle( pipeHdl ); -} diff --git a/bld/trap/vdm/c/vdmlink.c b/bld/trap/vdm/c/vdmlink.c index f2b3352abf..7a8c5a4e72 100644 --- a/bld/trap/vdm/c/vdmlink.c +++ b/bld/trap/vdm/c/vdmlink.c @@ -32,12 +32,58 @@ #include -#if defined( __NT__ ) -#include +#ifdef SERVER + #include +#elif defined( __OS2__ ) + #define INCL_DOSNMPIPES + #define INCL_DOSPROCESS + #define INCL_DOSERRORS + #define INCL_NOXLATE_DOS16 + #include +#else /* __NT__ */ + #include #endif #include "vdm.h" #include "bool.h" +#include "watcom.h" #include "trptypes.h" +#include "packet.h" +#include "trperr.h" +#ifdef SERVER + #include "tinyio.h" +#elif defined( __OS2__ ) + #include "namepipe.h" +#else /* __NT__ */ + #include "namepipe.h" +#endif + + +#ifdef __OS2__ +#ifdef _M_I86 +#define OS2DosConnectNPipe DosConnectNmPipe +#define OS2DosSetNPHandState DosSetNmPHandState +#define OS2DosDisConnectNPipe DosDisConnectNmPipe +#define OS2DosCreateNPipe DosMakeNmPipe +#else +#define OS2DosConnectNPipe DosConnectNPipe +#define OS2DosSetNPHandState DosSetNPHState +#define OS2DosDisConnectNPipe DosDisConnectNPipe +#define OS2DosCreateNPipe DosCreateNPipe +#endif +#endif + +#ifdef __NT__ +#define NT_PREF_LEN (MACH_NAME_LEN + PREFIX_LEN) +#endif + +#ifdef SERVER +char pipeName[MACH_NAME_LEN + PREFIX_LEN + MAX_NAME]; +int pipeHdl = -1; +#elif defined( __OS2__ ) +HPIPE pipeHdl; +#else /* __NT__ */ +HANDLE pipeHdl; +#endif bool ValidName( const char *name ) @@ -87,3 +133,292 @@ bool ValidName( const char *name ) } return( true ); } + + +const char *RemoteLink( const char *parms, bool server ) +{ +#ifdef SERVER + tiny_ret_t rc; + tiny_dos_version ver; + char *p; +#elif defined( __OS2__ ) + APIRET rc; +#else /* __NT__ */ +#endif + +#ifdef SERVER + if( !server ) +#else + if( server ) +#endif + return( "this should never be seen" ); + +#ifdef SERVER + p = pipeName; + ver = TinyDOSVersion(); + if( ver.major < 20 ) { + /* in NT */ + strcpy( p, NT_MACH_NAME ); + p += MACH_NAME_LEN; + } + strcpy( p, PREFIX ); + p += PREFIX_LEN; + if( *parms == '\0' ) { + strcpy( p, DEFAULT_LINK_NAME ); + } else if( ValidName( parms ) ) { + strcpy( p, parms ); + } else { + return( TRP_ERR_invalid_server_name ); + } + /* + * Since we can't create the pipe ourselves, we can't reserve the + * name. We can at least check that there isn't a pipe with the + * name already. We could open a file in TMP or something... but + * there's no reason for TMP to point to the same place in all + * DOS boxes. The result is that it's possible for 2 servers to + * have the same name if neither are connected to a client. + */ + pipeHdl = -1; + rc = TinyOpen( pipeName, TIO_READ_WRITE ); + if( TINY_ERROR( rc ) ) { + if( ver.major >= 20 ) { + /* + * in OS/2 + */ + if( TINY_INFO( rc ) == 5 ) { + return( TRP_ERR_server_name_already_in_use ); + } + } + } else { + pipeHdl = TINY_INFO( rc ); + } +#elif defined( __OS2__ ) + strcpy( PackBuff, PREFIX ); + if( *parms == '\0' ) { + strcpy( PackBuff + PREFIX_LEN, DEFAULT_LINK_NAME ); + } else if( ValidName( parms ) ) { + strcpy( PackBuff + PREFIX_LEN, parms ); + } else { + return( TRP_ERR_invalid_server_name ); + } + rc = OS2DosCreateNPipe( PackBuff, &pipeHdl, + NP_NOINHERIT | NP_NOWRITEBEHIND | NP_ACCESS_DUPLEX, + NP_NOWAIT | NP_READMODE_BYTE | NP_TYPE_BYTE | 1, + MAX_TRANS, MAX_TRANS, 0 ); + if( rc != 0 ) { + if( rc == ERROR_PIPE_BUSY ) + return( TRP_ERR_server_name_already_in_use ); + return( TRP_ERR_unable_to_access_server ); + } +#else /* __NT__ */ + strcpy( PackBuff, NT_MACH_NAME PREFIX ); + if( *parms == '\0' ) { + strcpy( PackBuff + NT_PREF_LEN, DEFAULT_LINK_NAME ); + } else if( ValidName( parms ) ) { + strcpy( PackBuff + NT_PREF_LEN, parms ); + } else { + return( TRP_ERR_invalid_server_name ); + } + pipeHdl = CreateNamedPipe( PackBuff, + PIPE_ACCESS_DUPLEX | FILE_FLAG_WRITE_THROUGH, + PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_NOWAIT, + 1, MAX_TRANS, MAX_TRANS, 0, NULL ); + if( pipeHdl == INVALID_HANDLE_VALUE ) { + if( GetLastError() == ERROR_PIPE_BUSY ) + return( TRP_ERR_server_name_already_in_use ); + return( TRP_ERR_unable_to_access_server ); + } +#endif + return( NULL ); +} + + +bool RemoteConnect( void ) +{ +#ifdef SERVER + tiny_ret_t rc; +#elif defined( __OS2__ ) + APIRET rc; + int try; +#else /* __NT__ */ + DWORD mode; + int try; +#endif + + /* + * We initially opened the pipe non-blocking so that we can poll + * to see if the server has connected to the pipe. + */ +#ifdef SERVER + if( pipeHdl == -1 ) { + rc = TinyOpen( pipeName, TIO_READ_WRITE ); + if( TINY_ERROR( rc ) ) { + /* + * At this point if TINY_INFO( rc ) == 5 then we know that there's + * another server with the same name. But we have no way of + * indicating this. + */ + return( false ); + } + pipeHdl = TINY_INFO( rc ); + } + return( true ); +#elif defined( __OS2__ ) + for( try = 0; try < 25; ++try ) { + rc = OS2DosConnectNPipe( pipeHdl ); + if( rc == 0 ) { + /* + * Now that the server has connected we have to set the pipe + * to blocking mode. + */ + rc = OS2DosSetNPHandState( pipeHdl, NP_WAIT | NP_READMODE_BYTE ); + if( rc == 0 ) + return( true ); + OS2DosDisConnectNPipe( pipeHdl ); + break; + } + DosSleep( 200 ); + } + return( false ); +#else /* __NT__ */ + for( try = 0; try < 25; ++try ) { + SetLastError( 0 ); + ConnectNamedPipe( pipeHdl, NULL ); + if( GetLastError() == ERROR_PIPE_CONNECTED ) { + /* + * Now that the server has connected we have to set the pipe + * to blocking mode. + */ + mode = PIPE_READMODE_BYTE | PIPE_WAIT; + if( SetNamedPipeHandleState( pipeHdl, &mode, NULL, NULL ) ) + return( true ); + DisconnectNamedPipe( pipeHdl ); + break; + } + Sleep( 200 ); + } + return( false ); +#endif +} + + +trap_retval RemoteGet( void *data, trap_elen len ) +{ + unsigned_16 incoming; +#ifdef SERVER + trap_elen got; + trap_elen ret; +#elif defined( __OS2__ ) + APIRET bytes_read; + APIRET ret; +#else /* __NT__ */ + ULONG bytes_read; + trap_elen ret; +#endif + + (void)len; +#ifdef SERVER + TinyRead( pipeHdl, &incoming, sizeof( incoming ) ); + ret = incoming; + while( incoming != 0 ) { + got = TinyRead( pipeHdl, data, incoming ); + data = (char *)data + got; + incoming -= got; + } +#elif defined( __OS2__ ) + DosRead( pipeHdl, &incoming, sizeof( incoming ), &bytes_read ); + ret = incoming; + while( incoming != 0 ) { + DosRead( pipeHdl, data, incoming, &bytes_read ); + data = (char *)data + bytes_read; + incoming -= bytes_read; + } +#else /* __NT__ */ + ReadFile( pipeHdl, &incoming, sizeof( incoming ), &bytes_read, NULL ); + ret = incoming; + while( incoming != 0 ) { + ReadFile( pipeHdl, data, incoming, &bytes_read, NULL ); + data = (char *)data + bytes_read; + incoming -= bytes_read; + } +#endif + return( ret ); +} + + +trap_retval RemotePut( void *data, trap_elen len ) +{ + unsigned_16 outgoing; +#ifdef SERVER +#elif defined( __OS2__ ) + APIRET bytes_written; +#else /* __NT__ */ + ULONG bytes_written; +#endif + + outgoing = len; +#ifdef SERVER + TinyWrite( pipeHdl, &outgoing, sizeof( outgoing ) ); + if( len > 0 ) { + TinyWrite( pipeHdl, data, len ); + } +#elif defined( __OS2__ ) + DosWrite( pipeHdl, &outgoing, sizeof( outgoing ), &bytes_written ); + if( len > 0 ) { + DosWrite( pipeHdl, data, len, &bytes_written ); + } +#else /* __NT__ */ + WriteFile( pipeHdl, &outgoing, sizeof( outgoing ), &bytes_written, NULL ); + if( len > 0 ) { + WriteFile( pipeHdl, data, len, &bytes_written, NULL ); + } +#endif + return( len ); +} + + +void RemoteDisco( void ) +{ +#ifdef SERVER +#elif defined( __OS2__ ) + APIRET rc; + APIRET bytes_read; + char tmp[MAX_TRANS]; +#else /* __NT__ */ + BOOL rc; + DWORD bytes_read; + char tmp[MAX_TRANS]; +#endif + + /* + * Before disconnecting we must wait until the server has closed + * their connection. Otherwise we might throw away the last message + * in the pipe (usually the message that says 'close the connection'). + */ +#ifdef SERVER + TinyClose( pipeHdl ); + pipeHdl = -1; +#elif defined( __OS2__ ) + do { + rc = DosRead( pipeHdl, tmp, MAX_TRANS, &bytes_read ); + } while( rc == 0 && bytes_read != 0 ); + OS2DosDisConnectNPipe( pipeHdl ); +#else /* __NT__ */ + do { + rc = ReadFile( pipeHdl, tmp, sizeof( tmp ), &bytes_read, NULL ); + } while( rc && bytes_read != 0 ); + DisconnectNamedPipe( pipeHdl ); +#endif +} + + +void RemoteUnLink( void ) +{ +#ifdef SERVER + /* nothing */ +#elif defined( __OS2__ ) + DosClose( pipeHdl ); +#else /* __NT__ */ + CloseHandle( pipeHdl ); +#endif +} diff --git a/bld/trap/vdm/c/vdmserv.c b/bld/trap/vdm/c/vdmserv.c deleted file mode 100644 index a02fce775c..0000000000 --- a/bld/trap/vdm/c/vdmserv.c +++ /dev/null @@ -1,161 +0,0 @@ -/**************************************************************************** -* -* Open Watcom Project -* -* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. -* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. -* -* ======================================================================== -* -* This file contains Original Code and/or Modifications of Original -* Code as defined in and that are subject to the Sybase Open Watcom -* Public License version 1.0 (the 'License'). You may not use this file -* except in compliance with the License. BY USING THIS FILE YOU AGREE TO -* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is -* provided with the Original Code and Modifications, and is also -* available at www.sybase.com/developer/opensource. -* -* The Original Code and all software distributed under the License are -* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER -* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM -* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF -* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR -* NON-INFRINGEMENT. Please see the License for the specific language -* governing rights and limitations under the License. -* -* ======================================================================== -* -* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE -* DESCRIBE IT HERE! -* -****************************************************************************/ - - -// -// VDMSERV : server end of VDM interface -// - -#include -#include -#include "tinyio.h" -#include "watcom.h" -#include "vdm.h" -#include "trptypes.h" -#include "trperr.h" -#include "packet.h" - - -typedef unsigned short USHORT; - -int pipeHdl = -1; -char pipeName[MACH_NAME_LEN + PREFIX_LEN + MAX_NAME]; - -const char *RemoteLink( const char *parms, bool server ) -{ - tiny_ret_t rc; - tiny_dos_version ver; - char *p; - - if( !server ) - return( "this should never be seen" ); - p = pipeName; - ver = TinyDOSVersion(); - if( ver.major < 20 ) { - /* in NT */ - strcpy( p, NT_MACH_NAME ); - p += MACH_NAME_LEN; - } - strcpy( p, PREFIX ); - p += PREFIX_LEN; - if( *parms == '\0' ) { - strcpy( p, DEFAULT_LINK_NAME ); - } else if( ValidName( parms ) ) { - strcpy( p, parms ); - } else { - return( TRP_ERR_invalid_server_name ); - } - pipeHdl = -1; - /* - Since we can't create the pipe ourselves, we can't reserve the - name. We can at least check that there isn't a pipe with the - name already. We could open a file in TMP or something... but - there's no reason for TMP to point to the same place in all - DOS boxes. The result is that it's possible for 2 servers to - have the same name if neither are connected to a client. - */ - rc = TinyOpen( pipeName, TIO_READ_WRITE ); - if( TINY_ERROR( rc ) ) { - if( ver.major >= 20 ) { - /* in OS/2 */ - if( TINY_INFO( rc ) == 5 ) { - return( TRP_ERR_server_name_already_in_use ); - } - } - } else { - pipeHdl = TINY_INFO( rc ); - } - return( NULL ); -} - - -bool RemoteConnect( void ) -{ - tiny_ret_t rc; - - if( pipeHdl == -1 ) { - rc = TinyOpen( pipeName, TIO_READ_WRITE ); - if( TINY_ERROR( rc ) ) { - /* - At this point if TINY_INFO( rc ) == 5 then we know that there's - another server with the same name. But we have no way of - indicating this. - */ - return( false ); - } - pipeHdl = TINY_INFO( rc ); - } - return( true ); -} - - -trap_retval RemoteGet( void *data, trap_elen len ) -{ - unsigned_16 incoming; - trap_elen got; - trap_elen ret; - - len = len; - TinyRead( pipeHdl, &incoming, sizeof( incoming ) ); - ret = incoming; - while( incoming != 0 ) { - got = TinyRead( pipeHdl, data, incoming ); - data = (char *)data + got; - incoming -= got; - } - return( ret ); -} - - -trap_retval RemotePut( void *data, trap_elen len ) -{ - unsigned_16 outgoing; - - outgoing = len; - TinyWrite( pipeHdl, &outgoing, sizeof( outgoing ) ); - if( len > 0 ) { - TinyWrite( pipeHdl, data, len ); - } - return( len ); -} - - -void RemoteDisco( void ) -{ - TinyClose( pipeHdl ); - pipeHdl = -1; -} - - -void RemoteUnLink( void ) -{ -} diff --git a/bld/trap/vdm/dos.srv/makefile b/bld/trap/vdm/dos.srv/makefile index e2160a5478..d4c71d6d30 100644 --- a/bld/trap/vdm/dos.srv/makefile +++ b/bld/trap/vdm/dos.srv/makefile @@ -11,6 +11,4 @@ srv = vdm which = SERVER remote_link = 1 -extra_objs = vdmserv.obj - !include $(trap_dir)/master.mif diff --git a/bld/trap/vdm/nt386.trp/makefile b/bld/trap/vdm/nt386.trp/makefile index 0ae7fd6413..aa3a699876 100644 --- a/bld/trap/vdm/nt386.trp/makefile +++ b/bld/trap/vdm/nt386.trp/makefile @@ -11,6 +11,4 @@ srv = vdm which = TRAP remote_link = 1 -extra_objs = vdmclint.obj - !include $(trap_dir)/master.mif diff --git a/bld/trap/vdm/os2.trp/makefile b/bld/trap/vdm/os2.trp/makefile index e49bc99771..e2d6cad3f1 100644 --- a/bld/trap/vdm/os2.trp/makefile +++ b/bld/trap/vdm/os2.trp/makefile @@ -11,6 +11,4 @@ srv = vdm which = TRAP remote_link = 1 -extra_objs = vdmcli.obj - !include $(trap_dir)/master.mif diff --git a/bld/trap/vdm/os2v2.trp/makefile b/bld/trap/vdm/os2v2.trp/makefile index c4d888690a..f823323617 100644 --- a/bld/trap/vdm/os2v2.trp/makefile +++ b/bld/trap/vdm/os2v2.trp/makefile @@ -12,6 +12,5 @@ which = TRAP remote_link = 1 extra_cflags = -d2 -extra_objs = vdmcli2.obj !include $(trap_dir)/master.mif diff --git a/bld/trap/vdm/win.srv/makefile b/bld/trap/vdm/win.srv/makefile index cac67dfc3d..6869b336e4 100644 --- a/bld/trap/vdm/win.srv/makefile +++ b/bld/trap/vdm/win.srv/makefile @@ -12,6 +12,4 @@ which = SERVER gui = 1 remote_link = 1 -extra_objs = vdmserv.obj - !include $(trap_dir)/master.mif From dd71cd1a9b53891e84340b505a1019630a5274bb Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Sun, 3 Sep 2023 14:08:09 +0200 Subject: [PATCH 080/258] add new trap RemoteLinkGet and RemoteLinkSet functions to handle trap setup RemoteLinkGet create configuration string from existing setup RemoteLinkSet parse configuration string and change existing setup --- bld/trap/common/packet.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bld/trap/common/packet.h b/bld/trap/common/packet.h index a1f5c5c581..3613e098f5 100644 --- a/bld/trap/common/packet.h +++ b/bld/trap/common/packet.h @@ -45,6 +45,10 @@ extern void RemovePacket( void *, trap_elen ); extern trap_retval GetPacket( void ); extern trap_elen MaxPacketSize( void ); +extern const char *RemoteLinkSet( const char * ); +#if defined( SERVER ) +extern const char *RemoteLinkGet( char *, size_t len ); +#endif extern const char *RemoteLink( const char *, bool ); extern bool RemoteConnect( void ); extern void RemoteDisco( void ); From 41b1cdb2342754ddbc0746cde4cb9aaf3e31c003 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Sun, 3 Sep 2023 15:00:48 +0200 Subject: [PATCH 081/258] implement RemoteLinkGet and RemoteLinkSet for Windowed trap servers --- bld/trap/common/servw.c | 14 ++++- bld/trap/master.mif | 3 + bld/trap/net/c/netlink.c | 52 +++++++++++++++--- bld/trap/net/c/options.c | 12 +++- bld/trap/nmp/c/nmplink.c | 64 +++++++++++++++------ bld/trap/nmp/c/options.c | 13 ++++- bld/trap/nov/c/novdos.c | 45 +++++++++++---- bld/trap/nov/c/novnt.c | 36 ++++++++++-- bld/trap/nov/c/options.c | 12 +++- bld/trap/par/c/options.c | 42 ++++++++------ bld/trap/par/c/parlink.c | 81 +++++++++++++++++++++++---- bld/trap/tcp/c/options.c | 12 +++- bld/trap/tcp/c/tcplink.c | 116 ++++++++++++++++++++++++++------------- bld/trap/vdm/c/options.c | 12 +++- bld/trap/vdm/c/vdmlink.c | 99 ++++++++++++++++++++++----------- 15 files changed, 453 insertions(+), 160 deletions(-) diff --git a/bld/trap/common/servw.c b/bld/trap/common/servw.c index 33176d6ac1..0be54f9b03 100644 --- a/bld/trap/common/servw.c +++ b/bld/trap/common/servw.c @@ -82,7 +82,10 @@ int PASCAL WinMain( HINSTANCE this_inst, HINSTANCE prev_inst, LPSTR cmdline, int } err = ParseCommandLine( cmdline, trapparms, ServParms, &OneShot ); if( err == NULL ) { - err = LoadTrap( trapparms, RWBuff, &TrapVersion ); + err = RemoteLinkSet( RWBuff ); + if( err == NULL ) { + err = LoadTrap( trapparms, RWBuff, &TrapVersion ); + } } if( err != NULL ) { StartupErr( err ); @@ -91,6 +94,12 @@ int PASCAL WinMain( HINSTANCE this_inst, HINSTANCE prev_inst, LPSTR cmdline, int if( !AnyInstance( this_inst, cmdshow ) ) return( FALSE ); + /* + * toggle start/end processing and RemoteLink/RemoteUnLink + * here is used for first time that call RemoteLink and start processing + */ + SendMessage( hwndMain, WM_COMMAND, MENU_CONNECT, 0 ); + while( GetMessage( (LPVOID)&msg, (HWND)0, 0, 0 ) ) { TranslateMessage( &msg ); DispatchMessage( &msg ); @@ -179,7 +188,6 @@ static bool AnyInstance( HINSTANCE this_inst, int cmdshow ) */ ShowWindow( hwndMain, cmdshow ); UpdateWindow( hwndMain ); - SendMessage( hwndMain, WM_COMMAND, MENU_CONNECT, 0 ); return( true ); @@ -238,7 +246,7 @@ WINEXPORT LRESULT CALLBACK WindowProc( HWND hwnd, UINT msg, WPARAM wparam, LPARA err = NULL; if( !Linked ) { HCURSOR cursor = SetCursor( LoadCursor( NULL, IDC_WAIT ) ); - err = RemoteLink( ServParms, true ); + err = RemoteLink( NULL, true ); SetCursor( cursor ); } EnableMenus( hwnd, true, false ); diff --git a/bld/trap/master.mif b/bld/trap/master.mif index 5073692b04..7ca43ef682 100644 --- a/bld/trap/master.mif +++ b/bld/trap/master.mif @@ -166,6 +166,9 @@ extra_cpp_flags += -DJAPANESE extra_cpp_flags += -DDEBUG_ME !endif !endif +!ifdef gui +extra_cpp_flags += -DTRAPGUI +!endif extra_cppflags_nlm5 = -D__NW50__ -D_USE_NEW_KERNEL -D__NETWARE_LIBC__ extra_cppflags_nlm4 = -D__NW40__ diff --git a/bld/trap/net/c/netlink.c b/bld/trap/net/c/netlink.c index 8bde7813a7..fb404a9b2f 100644 --- a/bld/trap/net/c/netlink.c +++ b/bld/trap/net/c/netlink.c @@ -106,6 +106,8 @@ NCB NetCtlBlk; byte LanaNum; int SkipEnum; +static char LinkName[NCBNAMSZ + 1]; + #if defined( __OS2__ ) #if defined( __386__ ) static unsigned short _System (*NetBiosSubmit)( unsigned short, unsigned short, NCB * ); @@ -194,13 +196,48 @@ void RemoteDisco( void ) static char NotThere[] = TRP_ERR_NetBIOS_is_not_running ; -const char *RemoteLink( const char *parms, bool server ) +#ifdef SERVER +#ifdef TRAPGUI +const char *RemoteLinkGet( char *parms, size_t len ) { - unsigned i; + int i; + + /* unused parameters */ (void)len; - server = server; - if( *parms == '\0' ) + strcpy( parms, LinkName + 1 ); + for( i = NCBNAMSZ - 1; i > 0 && parms[i] == ' '; i-- ) { + parms[i] = '\0'; + } + return( NULL ); +} +#endif +#endif + +const char *RemoteLinkSet( const char *parms ) +{ + int i; + + if( *parms == '\0' ) { parms = DEFAULT_LINK_NAME; + } + *LinkName = ' '; + for( i = 1; i < NCBNAMSZ; ++i ) { + LinkName[i] = ( *parms != '\0' ) ? *parms++ : ' '; + } + LinkName[i] = '\0'; + return( NULL ); +} + +const char *RemoteLink( const char *parms, bool server ) +{ + (void)server; + + if( parms != NULL ) { + parms = RemoteLinkSet( parms ); + if( parms != NULL ) { + return( parms ); + } + } #if defined(__OS2__) #if defined(__386__) { @@ -240,8 +277,9 @@ const char *RemoteLink( const char *parms, bool server ) dos_ver = GetTrueDOSVersion(); if( dos_ver.major == 5 && dos_ver.minor == 50 ) is_nt = 1; - if( !is_nt ) + if( !is_nt ) { SkipEnum = 1; + } } #endif NetCtlBlk.ncb_command = NET_INVALID_CMD; @@ -264,9 +302,7 @@ const char *RemoteLink( const char *parms, bool server ) #endif memset( &NetCtlBlk, 0, sizeof( NetCtlBlk ) ); - for( i = 1; i < NCBNAMSZ; ++i ) { - NetCtlBlk.ncb_name[i] = ( *parms != '\0' ) ? *parms++ : ' '; - } + memcpy( NetCtlBlk.ncb_name, LinkName, NCBNAMSZ ); NetCtlBlk.ncb_name[0] = ( server ) ? 'S' : 'C'; NetCtlBlk.ncb_command = NCBADDNAME; NetCtlBlk.ncb_lana_num = LanaNum; diff --git a/bld/trap/net/c/options.c b/bld/trap/net/c/options.c index 54c9102c5e..905a24348c 100644 --- a/bld/trap/net/c/options.c +++ b/bld/trap/net/c/options.c @@ -33,23 +33,29 @@ #include #include "servio.h" +#include "trptypes.h" +#include "packet.h" #include "options.h" WINEXPORT INT_PTR CALLBACK OptionsDlgProc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam ) { - lparam = lparam; /* turn off warning */ + char parms[PARMS_MAXLEN]; + + /* unused parameters */ (void)lparam; switch( msg ) { case WM_INITDIALOG: - SetDlgItemText( hwnd, IDDI_SERVER_NAME, ServParms ); + RemoteLinkGet( parms, sizeof( parms ) ); + SetDlgItemText( hwnd, IDDI_SERVER_NAME, parms ); SendDlgItemMessage( hwnd, IDDI_SERVER_NAME, EM_SETSEL, 0, -1 ); return( TRUE ); case WM_COMMAND: switch( LOWORD( wparam ) ) { case IDOK: - GetDlgItemText( hwnd, IDDI_SERVER_NAME, ServParms, PARMS_MAXLEN ); + GetDlgItemText( hwnd, IDDI_SERVER_NAME, parms, sizeof( parms ) ); + RemoteLinkSet( parms ); case IDCANCEL: EndDialog( hwnd, TRUE ); return( TRUE ); diff --git a/bld/trap/nmp/c/nmplink.c b/bld/trap/nmp/c/nmplink.c index 4b16d9dfef..2d55b2af90 100644 --- a/bld/trap/nmp/c/nmplink.c +++ b/bld/trap/nmp/c/nmplink.c @@ -55,20 +55,20 @@ bhandle ReadHdl; bhandle WriteHdl; bhandle BindHdl; -static char MachBuff[MACH_NAME+1]; - char NameBuff[MAX_PIPE_NAME+1]; +static char MachBuff[MACH_NAME + 1]; +static char NameBuff[MAX_PIPE_NAME + 1]; static char *NameEnd; static bhandle PipeOpen( char *name ) { - char buff[MAX_PIPE_NAME+1]; + char buff[MAX_PIPE_NAME + 1]; char *end; end = buff; if( MachBuff[0] != '\0' ) { buff[0] = '\\'; buff[1] = '\\'; - strcpy( buff+2, MachBuff ); + strcpy( buff + 2, MachBuff ); end = buff + strlen( buff ); } strcpy( end, name ); @@ -76,7 +76,6 @@ static bhandle PipeOpen( char *name ) } - static const char *OpenRequest( void ) { trap_elen bytes; @@ -120,7 +119,7 @@ static const char *ValidName( const char *name ) MachBuff[0] = '\0'; while( *name != '\0' ) { if( *name == '@' ) { - strcpy( MachBuff, name+1 ); + strcpy( MachBuff, name + 1 ); return( name ); } if( !isalnum( *name ) ) @@ -131,13 +130,26 @@ static const char *ValidName( const char *name ) return( name ); } +#ifdef SERVER +#ifdef TRAPGUI +const char *RemoteLinkGet( char *parms, size_t len ) +{ + *NameEnd = '\0'; + strcpy( parms, NameBuff + 1 + PREFIX_LEN ); + if( *MachBuff != '\0' ) { + len = NameEnd - ( NameBuff + 1 + PREFIX_LEN ); + parms[len++] = '@'; + strcpy( parms + len, MachBuff ); + } + return( NULL ); +} +#endif +#endif -const char *RemoteLink( const char *parms, bool server ) +const char *RemoteLinkSet( const char *parms ) { - const char *msg; const char *end; - server=server; end = ValidName( parms ); strcpy( NameBuff + 1, PREFIX ); if( end == NULL ) { @@ -150,20 +162,36 @@ const char *RemoteLink( const char *parms, bool server ) NameBuff[end - parms + 1 + PREFIX_LEN] = '\0'; } } - msg = OpenRequest(); NameEnd = NameBuff + strlen( NameBuff ); - if( msg != NULL ) - return( msg ); - if( NameBuff[0] != BIND_ACK ) { + return( NULL ); +} + + +const char *RemoteLink( const char *parms, bool server ) +{ + const char *err; + + (void)server; + + err = NULL; + if( parms != NULL ) { + err = RemoteLinkSet( parms ); + } + if( err == NULL ) { + err = OpenRequest(); + if( err == NULL ) { + if( NameBuff[0] != BIND_ACK ) { #ifdef SERVER - return( TRP_ERR_server_name_already_in_use ); + err = TRP_ERR_server_name_already_in_use; #else - return( TRP_ERR_server_not_found ); + err = TRP_ERR_server_not_found; #endif - } else { - DoOpen( &ConnHdl, CONN_SUFF ); + } else { + DoOpen( &ConnHdl, CONN_SUFF ); + } + } } - return( NULL ); + return( err ); } diff --git a/bld/trap/nmp/c/options.c b/bld/trap/nmp/c/options.c index d2173b4978..d44f8c9b58 100644 --- a/bld/trap/nmp/c/options.c +++ b/bld/trap/nmp/c/options.c @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -32,23 +33,29 @@ #include #include "servio.h" +#include "trptypes.h" +#include "packet.h" #include "options.h" WINEXPORT INT_PTR CALLBACK OptionsDlgProc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam ) { - lparam = lparam; /* turn off warning */ + char parms[PARMS_MAXLEN]; + + /* unused parameters */ (void)lparam; switch( msg ) { case WM_INITDIALOG: - SetDlgItemText( hwnd, IDDI_PIPE_NAME, ServParms ); + RemoteLinkGet( parms, sizeof( parms ) ); + SetDlgItemText( hwnd, IDDI_PIPE_NAME, parms ); SendDlgItemMessage( hwnd, IDDI_PIPE_NAME, EM_SETSEL, 0, -1 ); return( TRUE ); case WM_COMMAND: switch( LOWORD( wparam ) ) { case IDOK: - GetDlgItemText( hwnd, IDDI_PIPE_NAME, ServParms, PARMS_MAXLEN ); + GetDlgItemText( hwnd, IDDI_PIPE_NAME, parms, sizeof( parms ) ); + RemoteLinkSet( parms ); case IDCANCEL: EndDialog( hwnd, TRUE ); return( TRUE ); diff --git a/bld/trap/nov/c/novdos.c b/bld/trap/nov/c/novdos.c index 5a9eea4e90..8435a24359 100644 --- a/bld/trap/nov/c/novdos.c +++ b/bld/trap/nov/c/novdos.c @@ -529,12 +529,46 @@ putstring( "got one\r\n" ); return( 1 ); } -const char *RemoteLink( const char *parms, bool server ) +#ifdef SERVER +#ifdef TRAPGUI +const char *RemoteLinkGet( char *parms, size_t len ) +{ + /* unused parameters */ (void)len; + + strcpy( parms, SAPHead.name ); + return( NULL ); +} +#endif +#endif + +const char *RemoteLinkSet( const char *parms ) { unsigned i; + + if( *parms == '\0' ) + parms = DEFAULT_LINK_NAME; + for( i = 0; i < MAX_NAME_LEN && *parms != '\0'; ++parms ) { + if( strchr( "/\\:;,*?+-", *parms ) == NULL ) { + SAPHead.name[i++] = toupper( *parms ); + } + } + SAPHead.name[i] = '\0'; + return( NULL ); +} + +const char *RemoteLink( const char *parms, bool server ) +{ BYTE major_ver,minor_ver; WORD max_conn,avail_conn; + (void)server; + + if( parms != NULL ) { + parms = RemoteLinkSet( parms ); + if( parms != NULL ) { + return( parms ); + } + } #ifdef __WINDOWS__ { HINSTANCE ipxspx; @@ -581,15 +615,6 @@ const char *RemoteLink( const char *parms, bool server ) } } #endif - server = server; - if( *parms == '\0' ) - parms = DEFAULT_LINK_NAME; - for( i = 0; i < MAX_NAME_LEN && *parms != '\0'; ++parms ) { - if( strchr( "/\\:;,*?+-", *parms ) == NULL ) { - SAPHead.name[i++] = toupper( *parms ); - } - } - SAPHead.name[i] = '\0'; if( !_SPXInitialize( 20, 576, &major_ver, &minor_ver, &max_conn, &avail_conn ) ) { return( TRP_ERR_SPX_not_present ); } diff --git a/bld/trap/nov/c/novnt.c b/bld/trap/nov/c/novnt.c index 10172305f3..24ba289dba 100644 --- a/bld/trap/nov/c/novnt.c +++ b/bld/trap/nov/c/novnt.c @@ -345,15 +345,21 @@ static char FindPartner( void ) return( 1 ); } -const char *RemoteLink( const char *parms, bool server ) -{ - unsigned i; - WSADATA data; #ifdef SERVER - const char *p; +#ifdef TRAPGUI +const char *RemoteLinkGet( char *parms, size_t len ) +{ + /* unused parameters */ (void)len; + + strcpy( parms, ServerName ); + return( NULL ); +} +#endif #endif - server = server; +const char *RemoteLinkSet( const char *parms ) +{ + unsigned i; if( *parms == '\0' ) parms = DEFAULT_LINK_NAME; @@ -363,6 +369,24 @@ const char *RemoteLink( const char *parms, bool server ) } } ServerName[i] = '\0'; + return( NULL ); +} + +const char *RemoteLink( const char *parms, bool server ) +{ + WSADATA data; +#ifdef SERVER + const char *p; +#endif + + (void)server; + + if( parms != NULL ) { + parms = RemoteLinkSet( parms ); + if( parms != NULL ) { + return( parms ); + } + } if( WSAStartup( 0x101, &data ) != 0 ) { return( TRP_ERR_can_not_obtain_socket ); } diff --git a/bld/trap/nov/c/options.c b/bld/trap/nov/c/options.c index e1837dd719..19e9f0e4ef 100644 --- a/bld/trap/nov/c/options.c +++ b/bld/trap/nov/c/options.c @@ -33,23 +33,29 @@ #include #include "servio.h" +#include "trptypes.h" +#include "packet.h" #include "options.h" WINEXPORT INT_PTR CALLBACK OptionsDlgProc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam ) { - lparam = lparam; /* turn off warning */ + char parms[PARMS_MAXLEN]; + + /* unused parameters */ (void)lparam; switch( msg ) { case WM_INITDIALOG: - SetDlgItemText( hwnd, IDDI_SERVER_NAME, ServParms ); + RemoteLinkGet( parms, sizeof( parms ) ); + SetDlgItemText( hwnd, IDDI_SERVER_NAME, parms ); SendDlgItemMessage( hwnd, IDDI_SERVER_NAME, EM_SETSEL, 0, -1 ); return( true ); case WM_COMMAND: switch( LOWORD( wparam ) ) { case IDOK: - GetDlgItemText( hwnd, IDDI_SERVER_NAME, ServParms, PARMS_MAXLEN ); + GetDlgItemText( hwnd, IDDI_SERVER_NAME, parms, sizeof( parms ) ); + RemoteLinkSet( parms ); case IDCANCEL: EndDialog( hwnd, true ); return( true ); diff --git a/bld/trap/par/c/options.c b/bld/trap/par/c/options.c index d6003b4d00..82e02c0700 100644 --- a/bld/trap/par/c/options.c +++ b/bld/trap/par/c/options.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -34,6 +34,8 @@ #include #include #include "servio.h" +#include "trptypes.h" +#include "packet.h" #include "options.h" @@ -42,21 +44,24 @@ extern unsigned PrnAddress(int); WINEXPORT INT_PTR CALLBACK OptionsDlgProc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam ) { - HWND edit; - int num = NumPrinters(); - char buff[20]; + char parms[PARMS_MAXLEN]; + HWND edit; + int num = NumPrinters(); + char buff[20]; + + /* unused parameters */ (void)lparam; - lparam = lparam; /* turn off warning */ edit = GetDlgItem( hwnd, IDDI_PORT_EDIT ); switch( msg ) { case WM_INITDIALOG: + RemoteLinkGet( parms, sizeof( parms ) ); EnableWindow( edit, FALSE ); - if( ServParms[0] >= '1' && ServParms[0] <= '3' ) { - if( ServParms[0] > num + '0' ) { - ServParms[0] = num + '0'; + if( parms[0] >= '1' && parms[0] <= '3' ) { + if( parms[0] > num + '0' ) { + parms[0] = num + '0'; } } - switch( ServParms[0] ) { + switch( parms[0] ) { case '1': default: if( num >= 1 ) { @@ -79,7 +84,7 @@ WINEXPORT INT_PTR CALLBACK OptionsDlgProc( HWND hwnd, UINT msg, WPARAM wparam, L case 'p': case 'P': SendDlgItemMessage( hwnd, IDDI_PORT_ADDR, BM_SETCHECK, 1, 0 ); - SetDlgItemText( hwnd, IDDI_PORT_EDIT, ServParms + 1 ); + SetDlgItemText( hwnd, IDDI_PORT_EDIT, parms + 1 ); EnableWindow( edit, TRUE ); } if( num < 3 ) @@ -93,19 +98,20 @@ WINEXPORT INT_PTR CALLBACK OptionsDlgProc( HWND hwnd, UINT msg, WPARAM wparam, L case WM_COMMAND: switch( LOWORD( wparam ) ) { case IDOK: - ServParms[1] = '\0'; + parms[1] = '\0'; if( SendDlgItemMessage( hwnd, IDDI_LPT1, BM_GETCHECK, 0, 0 ) == BST_CHECKED ) { - ServParms[0] = '1'; + parms[0] = '1'; } else if( SendDlgItemMessage( hwnd, IDDI_LPT2, BM_GETCHECK, 0, 0 ) == BST_CHECKED ) { - ServParms[0] = '2'; + parms[0] = '2'; } else if( SendDlgItemMessage( hwnd, IDDI_LPT3, BM_GETCHECK, 0, 0 ) == BST_CHECKED ) { - ServParms[0] = '3'; + parms[0] = '3'; } else if( SendDlgItemMessage( hwnd, IDDI_PORT_ADDR, BM_GETCHECK, 0, 0 ) == BST_CHECKED ) { - ServParms[0] = 'p'; - GetDlgItemText( hwnd, IDDI_PORT_EDIT, ServParms + 1, PARMS_MAXLEN - 1 ); + parms[0] = 'p'; + GetDlgItemText( hwnd, IDDI_PORT_EDIT, parms + 1, sizeof( parms ) - 1 ); } else { - ServParms[0] = '1'; + parms[0] = '1'; } + RemoteLinkSet( parms ); case IDCANCEL: EndDialog( hwnd, TRUE ); return( TRUE ); @@ -122,7 +128,7 @@ WINEXPORT INT_PTR CALLBACK OptionsDlgProc( HWND hwnd, UINT msg, WPARAM wparam, L EnableWindow( edit, FALSE ); break; case IDDI_PORT_ADDR: - SetDlgItemText( hwnd, IDDI_PORT_EDIT, ServParms[0] == '\0' ? "" : ServParms + 1 ); + SetDlgItemText( hwnd, IDDI_PORT_EDIT, parms[0] == '\0' ? "" : parms + 1 ); EnableWindow( edit, TRUE ); break; } diff --git a/bld/trap/par/c/parlink.c b/bld/trap/par/c/parlink.c index 2988247587..9318e8e2c2 100644 --- a/bld/trap/par/c/parlink.c +++ b/bld/trap/par/c/parlink.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -187,6 +187,8 @@ * +-----------------------------------+ */ +#include +#include #if defined(__NETWARE__) #include #else @@ -839,19 +841,58 @@ void RemoteDisco( void ) static char InvalidPort[] = TRP_ERR_invalid_parallel_port_number; -const char *RemoteLink( const char *parms, bool server ) +#ifdef SERVER +#ifdef TRAPGUI +static char *hex( unsigned num ) +{ + static char hexbuff[10]; + char *p; + + p = &hexbuff[9]; + *p = '\0'; + if( num == 0 ) { + *--p = '0'; + return( p ); + } + while( num != 0 ) { + *--p = "0123456789abcdef"[num & 15]; + num >>= 4; + } + return( p ); +} + +const char *RemoteLinkGet( char *parms, size_t len ) +{ + int num; + + /* unused parameters */ (void)len; + + num = NumPrinters(); + if( num == 0 ) + return( TRP_ERR_parallel_port_not_present ); + if( num >= 1 && PrnAddress( 0 ) == DataPort ) { + parms[0] = '1'; + parms[1] = '\0'; + } else if( num >= 2 && PrnAddress( 1 ) == DataPort ) { + parms[0] = '2'; + parms[1] = '\0'; + } else if( num >= 3 && PrnAddress( 2 ) == DataPort ) { + parms[0] = '3'; + parms[1] = '\0'; + } else { + parms[0] = 'P'; + strcpy( parms + 1, hex( DataPort ) ); + } + return( NULL ); +} +#endif +#endif + +const char *RemoteLinkSet( const char *parms ) { unsigned printer; unsigned ch; - const char *err; - dbgrtn( "\r\n-RemoteLink-" ); - server = server; - - err = InitSys(); - if( err != NULL ) { - return( err ); - } if( *parms == '\0' ) { printer = 0; } else if( parms[0] >= '1' && parms[0] <= '3' && parms[1] == '\0' ) { @@ -889,6 +930,26 @@ const char *RemoteLink( const char *parms, bool server ) } DataPort = PrnAddress( printer ); } + return( NULL ); +} + +const char *RemoteLink( const char *parms, bool server ) +{ + const char *err; + + dbgrtn( "\r\n-RemoteLink-" ); + server = server; + + err = InitSys(); + if( err != NULL ) { + return( err ); + } + if( parms != NULL ) { + err = RemoteLinkSet( parms ); + if( err != NULL ) { + return( err ); + } + } CtlPort1 = DataPort + 1; CtlPort2 = CtlPort1 + 1; diff --git a/bld/trap/tcp/c/options.c b/bld/trap/tcp/c/options.c index 7b3e2f2338..de38a98492 100644 --- a/bld/trap/tcp/c/options.c +++ b/bld/trap/tcp/c/options.c @@ -33,23 +33,29 @@ #include #include "servio.h" +#include "trptypes.h" +#include "packet.h" #include "options.h" WINEXPORT INT_PTR CALLBACK OptionsDlgProc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam ) { - lparam = lparam; /* turn off warning */ + char parms[PARMS_MAXLEN]; + + /* unused parameters */ (void)lparam; switch( msg ) { case WM_INITDIALOG: - SetDlgItemText( hwnd, IDDI_PORT_NUMBER, ServParms ); + RemoteLinkGet( parms, sizeof( parms ) ); + SetDlgItemText( hwnd, IDDI_PORT_NUMBER, parms ); SendDlgItemMessage( hwnd, IDDI_PORT_NUMBER, EM_SETSEL, 0, -1 ); return( true ); case WM_COMMAND: switch( LOWORD( wparam ) ) { case IDOK: - GetDlgItemText( hwnd, IDDI_PORT_NUMBER, ServParms, PARMS_MAXLEN ); + GetDlgItemText( hwnd, IDDI_PORT_NUMBER, parms, sizeof( parms ) ); + RemoteLinkSet( parms ); case IDCANCEL: EndDialog( hwnd, true ); return( true ); diff --git a/bld/trap/tcp/c/tcplink.c b/bld/trap/tcp/c/tcplink.c index e19af53364..3bd3fad299 100644 --- a/bld/trap/tcp/c/tcplink.c +++ b/bld/trap/tcp/c/tcplink.c @@ -174,6 +174,11 @@ typedef struct sockaddr *LPSOCKADDR; #endif +unsigned short trap_port; +#ifndef SERVER +unsigned_32 trap_addr; +#endif + #ifdef __RDOS__ #define SOCKET_BUFFER 0x7000 @@ -435,7 +440,8 @@ static unsigned short get_port( const char *p ) return( port ); } -#if !defined( SERVER ) && !defined( __RDOS__ ) +#ifndef SERVER +#ifndef __RDOS__ static unsigned_32 get_addr( const char *p ) { unsigned_32 addr; @@ -444,6 +450,9 @@ static unsigned_32 get_addr( const char *p ) if( addr == OW_INADDR_INVALID ) { struct hostent *hp; + /* + * OS/2's TCP/IP gethostbyname doesn't handle numeric addresses + */ hp = gethostbyname( p ); if( hp != NULL ) { addr = 0; @@ -455,11 +464,59 @@ static unsigned_32 get_addr( const char *p ) return( addr ); } #endif +#endif -const char *RemoteLink( const char *parms, bool server ) +#ifdef SERVER +#ifdef TRAPGUI +const char *RemoteLinkGet( char *parms, size_t len ) { - unsigned short port; + /* unused parameters */ (void)len; + + sprintf( parms, "%u", trap_port ); + return( NULL ); +} +#endif +#endif +const char *RemoteLinkSet( const char *parms ) +{ +#ifdef SERVER + trap_port = get_port( parms ); +#else + char buff[128]; + char *p; + + /* + * get port number out of name + */ + p = buff; + while( *parms != '\0' ) { + if( *parms == ':' ) { + parms++; + break; + } + *p++ = *parms++; + } + *p = '\0'; + trap_port = get_port( parms ); + if( trap_port == 0 ) { + return( TRP_ERR_unable_to_parse_port_number ); + } + #ifdef __RDOS__ + trap_addr = OW_INADDR_LOOPBACK; + #else + trap_addr = get_addr( buff ); + if( trap_addr == OW_INADDR_INVALID ) { + trap_addr = OW_INADDR_LOOPBACK; +// return( TRP_ERR_unknown_host ); + } + #endif +#endif + return( NULL ); +} + +const char *RemoteLink( const char *parms, bool server ) +{ #ifdef SERVER #if !defined( __RDOS__ ) trp_socklen length; @@ -468,6 +525,12 @@ const char *RemoteLink( const char *parms, bool server ) _DBG_NET(("SERVER: Calling into RemoteLink\r\n")); + if( parms != NULL ) { + parms = RemoteLinkSet( parms ); + if( parms != NULL ) { + return( parms ); + } + } #if defined(__NT__) || defined(__WINDOWS__) { WSADATA data; @@ -477,11 +540,9 @@ const char *RemoteLink( const char *parms, bool server ) } } #endif - - port = get_port( parms ); #ifdef __RDOS__ wait_handle = RdosCreateWait( ); - listen_handle = RdosCreateTcpListen( port, 1, SOCKET_BUFFER ); + listen_handle = RdosCreateTcpListen( trap_port, 1, SOCKET_BUFFER ); RdosAddWaitForTcpListen( wait_handle, listen_handle, (int)(&listen_handle) ); #else control_socket = socket(AF_INET, SOCK_STREAM, 0); @@ -492,7 +553,7 @@ const char *RemoteLink( const char *parms, bool server ) /* Name socket using wildcards */ socket_address.sin_family = AF_INET; socket_address.sin_addr.s_addr = htonl( INADDR_ANY ); - socket_address.sin_port = htons( port ); + socket_address.sin_port = htons( trap_port ); if( bind( control_socket, (LPSOCKADDR)&socket_address, sizeof( socket_address ) ) ) { return( TRP_ERR_unable_to_bind_stream_socket ); } @@ -503,7 +564,7 @@ const char *RemoteLink( const char *parms, bool server ) if( getsockname( control_socket, (LPSOCKADDR)&socket_address, &length ) ) { return( TRP_ERR_unable_to_get_socket_name ); } - sprintf( buff, "%s%u", TRP_TCP_socket_number, (unsigned)port ); + sprintf( buff, "%s%u", TRP_TCP_socket_number, (unsigned)trap_port ); ServMessage( buff ); _DBG_NET(("TCP: ")); _DBG_NET((buff)); @@ -535,7 +596,6 @@ const char *RemoteLink( const char *parms, bool server ) } #endif #endif - _DBG_NET(("Start accepting connections\r\n")); /* * Start accepting connections @@ -544,15 +604,17 @@ const char *RemoteLink( const char *parms, bool server ) listen( control_socket, 5 ); #endif #else + if( parms != NULL ) { + parms = RemoteLinkSet( parms ); + if( parms != NULL ) { + return( parms ); + } + } #ifdef __RDOS__ /* * TODO: handle connect */ #else - char buff[128]; - char *p; - unsigned_32 addr; - #if defined(__NT__) || defined(__WINDOWS__) { WSADATA data; @@ -562,36 +624,12 @@ const char *RemoteLink( const char *parms, bool server ) } } #endif - /* - * get port number out of name - */ - p = buff; - while( *parms != '\0' ) { - if( *parms == ':' ) { - parms++; - break; - } - *p++ = *parms++; - } - *p = '\0'; - port = get_port( parms ); - if( port == 0 ) { - return( TRP_ERR_unable_to_parse_port_number ); - } /* * Setup for socket connect using parms specified by command line. */ socket_address.sin_family = AF_INET; - /* - * OS/2's TCP/IP gethostbyname doesn't handle numeric addresses - */ - addr = get_addr( buff ); - if( addr == OW_INADDR_INVALID ) { - addr = OW_INADDR_LOOPBACK; -// return( TRP_ERR_unknown_host ); - } - socket_address.sin_addr.s_addr = htonl( addr ); - socket_address.sin_port = htons( port ); + socket_address.sin_addr.s_addr = htonl( trap_addr ); + socket_address.sin_port = htons( trap_port ); #endif #endif /* unused parameters */ (void)server; diff --git a/bld/trap/vdm/c/options.c b/bld/trap/vdm/c/options.c index 964f10cd32..73a51944f0 100644 --- a/bld/trap/vdm/c/options.c +++ b/bld/trap/vdm/c/options.c @@ -33,23 +33,29 @@ #include #include "servio.h" +#include "trptypes.h" +#include "packet.h" #include "options.h" WINEXPORT INT_PTR CALLBACK OptionsDlgProc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam ) { - (void)lparam; /* turn off warning */ + char parms[PARMS_MAXLEN]; + + /* unused parameters */ (void)lparam; switch( msg ) { case WM_INITDIALOG: - SetDlgItemText( hwnd, IDDI_SERVER_NAME, ServParms ); + RemoteLinkGet( parms, sizeof( parms ) ); + SetDlgItemText( hwnd, IDDI_SERVER_NAME, parms ); SendDlgItemMessage( hwnd, IDDI_SERVER_NAME, EM_SETSEL, 0, -1 ); return( TRUE ); case WM_COMMAND: switch( LOWORD( wparam ) ) { case IDOK: - GetDlgItemText( hwnd, IDDI_SERVER_NAME, ServParms, PARMS_MAXLEN ); + GetDlgItemText( hwnd, IDDI_SERVER_NAME, parms, sizeof( parms ) ); + RemoteLinkSet( parms ); case IDCANCEL: EndDialog( hwnd, TRUE ); return( TRUE ); diff --git a/bld/trap/vdm/c/vdmlink.c b/bld/trap/vdm/c/vdmlink.c index 7a8c5a4e72..2d43c777c2 100644 --- a/bld/trap/vdm/c/vdmlink.c +++ b/bld/trap/vdm/c/vdmlink.c @@ -40,7 +40,7 @@ #define INCL_DOSERRORS #define INCL_NOXLATE_DOS16 #include -#else /* __NT__ */ +#else /* __WINDOWS__ or __NT__ */ #include #endif #include "vdm.h" @@ -53,7 +53,7 @@ #include "tinyio.h" #elif defined( __OS2__ ) #include "namepipe.h" -#else /* __NT__ */ +#else /* __WINDOWS__ or __NT__ */ #include "namepipe.h" #endif @@ -72,8 +72,8 @@ #endif #endif -#ifdef __NT__ -#define NT_PREF_LEN (MACH_NAME_LEN + PREFIX_LEN) +#if defined( __WINDOWS__ ) || defined( __NT__ ) +#define WIN_PREF_LEN (MACH_NAME_LEN + PREFIX_LEN) #endif #ifdef SERVER @@ -81,7 +81,7 @@ char pipeName[MACH_NAME_LEN + PREFIX_LEN + MAX_NAME]; int pipeHdl = -1; #elif defined( __OS2__ ) HPIPE pipeHdl; -#else /* __NT__ */ +#else /* __WINDOWS__ or __NT__ */ HANDLE pipeHdl; #endif @@ -134,30 +134,30 @@ bool ValidName( const char *name ) return( true ); } - -const char *RemoteLink( const char *parms, bool server ) -{ #ifdef SERVER - tiny_ret_t rc; - tiny_dos_version ver; - char *p; -#elif defined( __OS2__ ) - APIRET rc; -#else /* __NT__ */ -#endif +#ifdef TRAPGUI +const char *RemoteLinkGet( char *parms, size_t len ) +{ + /* unused parameters */ (void)len; -#ifdef SERVER - if( !server ) -#else - if( server ) + strcpy( parms, pipeName + PREFIX_LEN ); + return( NULL ); +} +#endif #endif - return( "this should never be seen" ); #ifdef SERVER +const char *RemoteLinkSet( const char *parms ) +{ + tiny_dos_version ver; + char *p; + p = pipeName; ver = TinyDOSVersion(); if( ver.major < 20 ) { - /* in NT */ + /* + * in NT + */ strcpy( p, NT_MACH_NAME ); p += MACH_NAME_LEN; } @@ -170,6 +170,36 @@ const char *RemoteLink( const char *parms, bool server ) } else { return( TRP_ERR_invalid_server_name ); } + return( NULL ); +} +#elif defined( __OS2__ ) +#else /* __WINDOWS__ or __NT__ */ +#endif + + +const char *RemoteLink( const char *parms, bool server ) +{ +#ifdef SERVER + tiny_ret_t rc; +#elif defined( __OS2__ ) + APIRET rc; +#else /* __WINDOWS__ or __NT__ */ +#endif + +#ifdef SERVER + if( !server ) +#else + if( server ) +#endif + return( "this should never be seen" ); + +#ifdef SERVER + if( parms != NULL ) { + parms = RemoteLinkSet( parms ); + if( parms != NULL ) { + return( parms ); + } + } /* * Since we can't create the pipe ourselves, we can't reserve the * name. We can at least check that there isn't a pipe with the @@ -181,6 +211,9 @@ const char *RemoteLink( const char *parms, bool server ) pipeHdl = -1; rc = TinyOpen( pipeName, TIO_READ_WRITE ); if( TINY_ERROR( rc ) ) { + tiny_dos_version ver; + + ver = TinyDOSVersion(); if( ver.major >= 20 ) { /* * in OS/2 @@ -210,12 +243,12 @@ const char *RemoteLink( const char *parms, bool server ) return( TRP_ERR_server_name_already_in_use ); return( TRP_ERR_unable_to_access_server ); } -#else /* __NT__ */ +#else /* __WINDOWS__ or __NT__ */ strcpy( PackBuff, NT_MACH_NAME PREFIX ); if( *parms == '\0' ) { - strcpy( PackBuff + NT_PREF_LEN, DEFAULT_LINK_NAME ); + strcpy( PackBuff + WIN_PREF_LEN, DEFAULT_LINK_NAME ); } else if( ValidName( parms ) ) { - strcpy( PackBuff + NT_PREF_LEN, parms ); + strcpy( PackBuff + WIN_PREF_LEN, parms ); } else { return( TRP_ERR_invalid_server_name ); } @@ -240,7 +273,7 @@ bool RemoteConnect( void ) #elif defined( __OS2__ ) APIRET rc; int try; -#else /* __NT__ */ +#else /* __WINDOWS__ or __NT__ */ DWORD mode; int try; #endif @@ -280,7 +313,7 @@ bool RemoteConnect( void ) DosSleep( 200 ); } return( false ); -#else /* __NT__ */ +#else /* __WINDOWS__ or __NT__ */ for( try = 0; try < 25; ++try ) { SetLastError( 0 ); ConnectNamedPipe( pipeHdl, NULL ); @@ -311,7 +344,7 @@ trap_retval RemoteGet( void *data, trap_elen len ) #elif defined( __OS2__ ) APIRET bytes_read; APIRET ret; -#else /* __NT__ */ +#else /* __WINDOWS__ or __NT__ */ ULONG bytes_read; trap_elen ret; #endif @@ -333,7 +366,7 @@ trap_retval RemoteGet( void *data, trap_elen len ) data = (char *)data + bytes_read; incoming -= bytes_read; } -#else /* __NT__ */ +#else /* __WINDOWS__ or __NT__ */ ReadFile( pipeHdl, &incoming, sizeof( incoming ), &bytes_read, NULL ); ret = incoming; while( incoming != 0 ) { @@ -352,7 +385,7 @@ trap_retval RemotePut( void *data, trap_elen len ) #ifdef SERVER #elif defined( __OS2__ ) APIRET bytes_written; -#else /* __NT__ */ +#else /* __WINDOWS__ or __NT__ */ ULONG bytes_written; #endif @@ -367,7 +400,7 @@ trap_retval RemotePut( void *data, trap_elen len ) if( len > 0 ) { DosWrite( pipeHdl, data, len, &bytes_written ); } -#else /* __NT__ */ +#else /* __WINDOWS__ or __NT__ */ WriteFile( pipeHdl, &outgoing, sizeof( outgoing ), &bytes_written, NULL ); if( len > 0 ) { WriteFile( pipeHdl, data, len, &bytes_written, NULL ); @@ -384,7 +417,7 @@ void RemoteDisco( void ) APIRET rc; APIRET bytes_read; char tmp[MAX_TRANS]; -#else /* __NT__ */ +#else /* __WINDOWS__ or __NT__ */ BOOL rc; DWORD bytes_read; char tmp[MAX_TRANS]; @@ -403,7 +436,7 @@ void RemoteDisco( void ) rc = DosRead( pipeHdl, tmp, MAX_TRANS, &bytes_read ); } while( rc == 0 && bytes_read != 0 ); OS2DosDisConnectNPipe( pipeHdl ); -#else /* __NT__ */ +#else /* __WINDOWS__ or __NT__ */ do { rc = ReadFile( pipeHdl, tmp, sizeof( tmp ), &bytes_read, NULL ); } while( rc && bytes_read != 0 ); @@ -418,7 +451,7 @@ void RemoteUnLink( void ) /* nothing */ #elif defined( __OS2__ ) DosClose( pipeHdl ); -#else /* __NT__ */ +#else /* __WINDOWS__ or __NT__ */ CloseHandle( pipeHdl ); #endif } From 82d55a666a898946c92b1a0289976cd43ffe6ed3 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Sun, 3 Sep 2023 15:19:35 +0200 Subject: [PATCH 082/258] mismatched variables fixing completely removed ServParms array --- bld/trap/common/options.h | 3 +-- bld/trap/common/serv.c | 10 ++-------- bld/trap/common/servw.c | 4 +--- 3 files changed, 4 insertions(+), 13 deletions(-) diff --git a/bld/trap/common/options.h b/bld/trap/common/options.h index 3ca6ecf619..4e6ab320f4 100644 --- a/bld/trap/common/options.h +++ b/bld/trap/common/options.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -33,6 +34,4 @@ #include "options.rh" -extern char ServParms[PARMS_MAXLEN]; - WINEXPORT extern INT_PTR CALLBACK OptionsDlgProc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam ); diff --git a/bld/trap/common/serv.c b/bld/trap/common/serv.c index b55688e388..3cfca61ac5 100644 --- a/bld/trap/common/serv.c +++ b/bld/trap/common/serv.c @@ -67,21 +67,15 @@ void ServMessage( const char *msg ) static const char *ServInitialize( void ) { - const char *err; char trapparms[PARMS_MAXLEN]; char cmd_line[PARMS_MAXLEN]; -#define servparms RWBuff - _bgetcmd( cmd_line, sizeof( cmd_line ) ); - err = ParseCommandLine( cmd_line, trapparms, servparms, &OneShot ); + err = ParseCommandLine( cmd_line, trapparms, RWBuff, &OneShot ); if( err == NULL ) { - err = RemoteLink( servparms, true ); + err = RemoteLink( RWBuff, true ); } - -#undef servparms - if( err == NULL ) { err = LoadTrap( trapparms, RWBuff, &TrapVersion ); } diff --git a/bld/trap/common/servw.c b/bld/trap/common/servw.c index 0be54f9b03..149133712d 100644 --- a/bld/trap/common/servw.c +++ b/bld/trap/common/servw.c @@ -48,8 +48,6 @@ extern trap_version TrapVersion; -char ServParms[PARMS_MAXLEN]; - HANDLE Instance; static char ServerClass[32]="ServerClass"; @@ -80,7 +78,7 @@ int PASCAL WinMain( HINSTANCE this_inst, HINSTANCE prev_inst, LPSTR cmdline, int return( FALSE ); } } - err = ParseCommandLine( cmdline, trapparms, ServParms, &OneShot ); + err = ParseCommandLine( cmdline, trapparms, RWBuff, &OneShot ); if( err == NULL ) { err = RemoteLinkSet( RWBuff ); if( err == NULL ) { From cbb319c1e41db2671b400f0cbe410f7ad6e9e9a1 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Sun, 3 Sep 2023 15:21:43 +0200 Subject: [PATCH 083/258] cleanup trap code --- bld/trap/common/serv.c | 6 +++--- bld/trap/tcp/c/tcplink.c | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/bld/trap/common/serv.c b/bld/trap/common/serv.c index 3cfca61ac5..e5621e0de9 100644 --- a/bld/trap/common/serv.c +++ b/bld/trap/common/serv.c @@ -75,9 +75,9 @@ static const char *ServInitialize( void ) err = ParseCommandLine( cmd_line, trapparms, RWBuff, &OneShot ); if( err == NULL ) { err = RemoteLink( RWBuff, true ); - } - if( err == NULL ) { - err = LoadTrap( trapparms, RWBuff, &TrapVersion ); + if( err == NULL ) { + err = LoadTrap( trapparms, RWBuff, &TrapVersion ); + } } return( err ); } diff --git a/bld/trap/tcp/c/tcplink.c b/bld/trap/tcp/c/tcplink.c index 3bd3fad299..456f754d87 100644 --- a/bld/trap/tcp/c/tcplink.c +++ b/bld/trap/tcp/c/tcplink.c @@ -482,6 +482,9 @@ const char *RemoteLinkSet( const char *parms ) { #ifdef SERVER trap_port = get_port( parms ); + if( trap_port == 0 ) { + return( TRP_ERR_unable_to_parse_port_number ); + } #else char buff[128]; char *p; From 735a2f98bb55109f84425d4428852b37120f3f28 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Sun, 3 Sep 2023 20:22:06 +0200 Subject: [PATCH 084/258] cleanup trap code reformat source files --- bld/trap/common/nlm/nlmstrt.c | 6 +- bld/trap/common/servw.c | 2 +- bld/trap/dqv/c/dqvlink.c | 4 +- bld/trap/lcl/dos/dosx/ads/c/adsacc.c | 2 +- bld/trap/lcl/dos/dosx/cw/c/cwacc.c | 3 +- bld/trap/lcl/dos/dosx/pls/c/plsacc.c | 3 +- bld/trap/lcl/dos/dosx/rsi/c/rsiacc.c | 3 +- bld/trap/lcl/jvm/c/jvmacc.c | 4 +- bld/trap/lcl/jvm/c/jvmxlink.c | 4 +- bld/trap/lcl/linux/c/lnxacc.c | 3 +- bld/trap/lcl/msj/c/msjacc.c | 5 +- bld/trap/lcl/nlm/c/nlmacc.c | 3 +- bld/trap/lcl/nto/c/ntoacc.c | 2 +- bld/trap/lcl/os2/c/os2v1acc.c | 3 +- bld/trap/lcl/os2/h/wdpmhelp.h | 12 +- bld/trap/lcl/os2v2/c/dbgthrd.c | 160 +++++++++++++-------------- bld/trap/lcl/os2v2/h/wdpmhelp.h | 12 +- bld/trap/lcl/rdos/c/task.c | 3 +- bld/trap/lcl/win/c/accgen.c | 4 +- bld/trap/lcl/win/c/dbgeemsg.c | 6 +- bld/trap/net/c/netlink.c | 2 +- bld/trap/nmp/c/nmplink.c | 2 +- bld/trap/nov/c/novdos.c | 4 +- bld/trap/nov/c/novnt.c | 2 +- bld/trap/par/c/dbginst.c | 26 ++--- bld/trap/par/c/dbgport.c | 18 +-- bld/trap/par/c/options.c | 4 +- bld/trap/par/c/parlink.c | 2 +- bld/trap/par/c/parqnx.c | 6 +- bld/trap/vdm/c/vdmlink.c | 3 +- 30 files changed, 162 insertions(+), 151 deletions(-) diff --git a/bld/trap/common/nlm/nlmstrt.c b/bld/trap/common/nlm/nlmstrt.c index 0a8ef0db18..f172226e70 100644 --- a/bld/trap/common/nlm/nlmstrt.c +++ b/bld/trap/common/nlm/nlmstrt.c @@ -47,7 +47,7 @@ extern int main( int arg, char **argv ); // defined by user -extern void TrapFini(void); +extern void TrapFini( void ); struct LoadDefinitionStruct *MyNLMHandle; struct ScreenStruct *screenID; @@ -126,7 +126,7 @@ int _bgetcmd( char *buff, int len ) if( len > cmd_len ) len = cmd_len; for( i = 0; i < len; i++ ) { - buff[i] = Command[i]; + buff[i] = Command[i]; } buff[len] = '\0'; } @@ -601,7 +601,7 @@ extern void __CHK( int size ); #pragma off (check_stack); void __declspec(naked) __CHK( int size ) { - (void)size; + /* unused parameters */ (void)size; __asm { push eax mov eax,8[esp] diff --git a/bld/trap/common/servw.c b/bld/trap/common/servw.c index 149133712d..951fc6ed18 100644 --- a/bld/trap/common/servw.c +++ b/bld/trap/common/servw.c @@ -350,7 +350,7 @@ void StartupErr( const char *err ) void ServMessage( const char *msg ) { - (void)msg; + /* unused parameters */ (void)msg; } int WantUsage( const char *ptr ) diff --git a/bld/trap/dqv/c/dqvlink.c b/bld/trap/dqv/c/dqvlink.c index 8d9056599f..6d1adf1dd6 100644 --- a/bld/trap/dqv/c/dqvlink.c +++ b/bld/trap/dqv/c/dqvlink.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -65,7 +65,7 @@ unsigned RemoteGet( void __far *data, unsigned len ) int buflen; int status; - /* unused parameters */(void)len; + /* unused parameters */ (void)len; status = mal_read( GetHandle, &buffer, &buflen ); movedata( _FP_SEG( buffer ), _FP_OFF( buffer ), diff --git a/bld/trap/lcl/dos/dosx/ads/c/adsacc.c b/bld/trap/lcl/dos/dosx/ads/c/adsacc.c index 2d92e7523a..e2a4edd7c4 100644 --- a/bld/trap/lcl/dos/dosx/ads/c/adsacc.c +++ b/bld/trap/lcl/dos/dosx/ads/c/adsacc.c @@ -596,7 +596,7 @@ trap_retval TRAP_CORE( Prog_load )( void ) void DumpRegs( trap_cpu_regs *regs ) { - (void)regs; + /* unused parameters */ (void)regs; _DBG0(("EAX=%8.8x EBX=%8.8x ECX=%8.8x EDX=%8.8x", regs->EAX, regs->EBX, regs->ECX, regs->EDX )); diff --git a/bld/trap/lcl/dos/dosx/cw/c/cwacc.c b/bld/trap/lcl/dos/dosx/cw/c/cwacc.c index 445ab54697..132d0a7afb 100644 --- a/bld/trap/lcl/dos/dosx/cw/c/cwacc.c +++ b/bld/trap/lcl/dos/dosx/cw/c/cwacc.c @@ -1094,7 +1094,8 @@ trap_version TRAPENTRY TrapInit( const char *parms, char *err, bool remote ) trap_version ver; char ver_msg[] = "CauseWay API version = 0.00\r\n$"; - parms=parms;remote=remote; + /* unused parameters */ (void)parms; (void)remote; + err[0] = '\0'; /* all ok */ ver.major = TRAP_MAJOR_VERSION; ver.minor = TRAP_MINOR_VERSION; diff --git a/bld/trap/lcl/dos/dosx/pls/c/plsacc.c b/bld/trap/lcl/dos/dosx/pls/c/plsacc.c index 1788a64b31..1d782b09d9 100644 --- a/bld/trap/lcl/dos/dosx/pls/c/plsacc.c +++ b/bld/trap/lcl/dos/dosx/pls/c/plsacc.c @@ -1065,8 +1065,9 @@ trap_version TRAPENTRY TrapInit( const char *parms, char *err, bool remote ) trap_version ver; int error_num; + /* unused parameters */ (void)remote; (void)parms; + _DBG(( "in TrapInit\r\n" )); - remote = remote; parms = parms; err[0] = '\0'; /* all ok */ ver.major = TRAP_MAJOR_VERSION; ver.minor = TRAP_MINOR_VERSION; diff --git a/bld/trap/lcl/dos/dosx/rsi/c/rsiacc.c b/bld/trap/lcl/dos/dosx/rsi/c/rsiacc.c index 5c625cf971..cb04552cc1 100644 --- a/bld/trap/lcl/dos/dosx/rsi/c/rsiacc.c +++ b/bld/trap/lcl/dos/dosx/rsi/c/rsiacc.c @@ -931,8 +931,9 @@ trap_version TRAPENTRY TrapInit( const char *parms, char *err, bool remote ) { trap_version ver; + /* unused parameters */ (void)remote; (void)parms; + _DBG_Writeln( "TrapInit" ); - remote = remote; parms = parms; err[0] = '\0'; /* all ok */ ver.major = TRAP_MAJOR_VERSION; ver.minor = TRAP_MINOR_VERSION; diff --git a/bld/trap/lcl/jvm/c/jvmacc.c b/bld/trap/lcl/jvm/c/jvmacc.c index 253ef4918a..edb962323b 100644 --- a/bld/trap/lcl/jvm/c/jvmacc.c +++ b/bld/trap/lcl/jvm/c/jvmacc.c @@ -280,8 +280,8 @@ void BreakpointLoop( stack_item *p, ExecEnv *ee ) } #pragma aux (cdecl) HandleExit; -void HandleExit(void) -/*******************/ +void HandleExit( void ) +/*********************/ { Event( COND_TERMINATE ); TheBigSleep(); diff --git a/bld/trap/lcl/jvm/c/jvmxlink.c b/bld/trap/lcl/jvm/c/jvmxlink.c index d1c3aa8ecc..56f5cd84c1 100644 --- a/bld/trap/lcl/jvm/c/jvmxlink.c +++ b/bld/trap/lcl/jvm/c/jvmxlink.c @@ -132,7 +132,9 @@ const char *RemoteLink( const char *parms, bool server ) SharedMem == NULL || Terminated == NULL || UniquePid == NULL ) { return( "can not connect to debugger" ); } - parms = parms; + + /* unused parameters */ (void)parms; + #else STARTUPINFO sinfo; PROCESS_INFORMATION pinfo; diff --git a/bld/trap/lcl/linux/c/lnxacc.c b/bld/trap/lcl/linux/c/lnxacc.c index 928e3756a8..3f3b1ce3c9 100644 --- a/bld/trap/lcl/linux/c/lnxacc.c +++ b/bld/trap/lcl/linux/c/lnxacc.c @@ -680,7 +680,8 @@ trap_version TRAPENTRY TrapInit( const char *parms, char *err, bool remote ) { trap_version ver; - parms = parms; remote = remote; + /* unused parameters */ (void)parms; (void)remote; + err[0] = '\0'; /* all ok */ ver.major = TRAP_MAJOR_VERSION; ver.minor = TRAP_MINOR_VERSION; diff --git a/bld/trap/lcl/msj/c/msjacc.c b/bld/trap/lcl/msj/c/msjacc.c index 16d61bb3b0..d98d9a9001 100644 --- a/bld/trap/lcl/msj/c/msjacc.c +++ b/bld/trap/lcl/msj/c/msjacc.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -52,8 +52,9 @@ trap_version TRAPENTRY TrapInit( const char *parms, char *err, bool remote ) { trap_version ver; + /* unused parameters */ (void)remote; (void)parms; + MSJMemInit(); - remote = remote; parms = parms; ver.major = TRAP_MAJOR_VERSION; ver.minor = TRAP_MINOR_VERSION; ver.remote = FALSE; diff --git a/bld/trap/lcl/nlm/c/nlmacc.c b/bld/trap/lcl/nlm/c/nlmacc.c index a090b8315d..5d42206251 100644 --- a/bld/trap/lcl/nlm/c/nlmacc.c +++ b/bld/trap/lcl/nlm/c/nlmacc.c @@ -1923,10 +1923,11 @@ trap_version TRAPENTRY TrapInit( const char *parms, char *err, bool remote ) trap_version ver; extern struct LoadDefinitionStructure *MyNLMHandle; + /* unused parameters */ (void)remote; (void)parms; + #if defined( __NW40__ ) ImportCLIBSymbols(); #endif - remote = remote; parms = parms; err[0] = '\0'; /* all ok */ ver.major = TRAP_MAJOR_VERSION; ver.minor = TRAP_MINOR_VERSION; diff --git a/bld/trap/lcl/nto/c/ntoacc.c b/bld/trap/lcl/nto/c/ntoacc.c index 50ecbfda1e..4fc2021e0d 100644 --- a/bld/trap/lcl/nto/c/ntoacc.c +++ b/bld/trap/lcl/nto/c/ntoacc.c @@ -1328,7 +1328,7 @@ trap_version TRAPENTRY TrapInit( const char *parms, char *err, bool remote ) trap_version ver; sigset_t sig_set; - parms = parms; remote = remote; + /* unused parameters */ (void)parms; (void)remote; /* We use SIGUSR1 to gain control after blocking wait for a process. */ sigemptyset( &sig_set ); diff --git a/bld/trap/lcl/os2/c/os2v1acc.c b/bld/trap/lcl/os2/c/os2v1acc.c index cd59823118..79c69eebb4 100644 --- a/bld/trap/lcl/os2/c/os2v1acc.c +++ b/bld/trap/lcl/os2/c/os2v1acc.c @@ -1313,7 +1313,8 @@ trap_version TRAPENTRY TrapInit( const char *parms, char *err, bool remote ) SEL gi; __LINFOSEG __far *linfo; - parms = parms; + /* unused parameters */ (void)parms; + Remote = remote; err[0] = '\0'; ver.major = TRAP_MAJOR_VERSION; diff --git a/bld/trap/lcl/os2/h/wdpmhelp.h b/bld/trap/lcl/os2/h/wdpmhelp.h index 57dbc34d37..9ee1204cad 100644 --- a/bld/trap/lcl/os2/h/wdpmhelp.h +++ b/bld/trap/lcl/os2/h/wdpmhelp.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -45,9 +45,9 @@ enum { PMHELP_SWITCHBACK, }; -extern void StartPMHelp(void); -extern void StopPMHelp(void); +extern void StartPMHelp( void ); +extern void StopPMHelp( void ); -extern void PMLock(unsigned long,unsigned long); -extern void PMUnLock(void); -extern int PMFlip(void); +extern void PMLock( unsigned long,unsigned long ); +extern void PMUnLock( void ); +extern int PMFlip( void ); diff --git a/bld/trap/lcl/os2v2/c/dbgthrd.c b/bld/trap/lcl/os2v2/c/dbgthrd.c index 5f88cece20..88b71699ac 100644 --- a/bld/trap/lcl/os2v2/c/dbgthrd.c +++ b/bld/trap/lcl/os2v2/c/dbgthrd.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -73,15 +73,15 @@ static void APIENTRY StopApplication( ULONG arg ) // never return } -static void CantDoIt(void) +static void CantDoIt( void ) { - WinMessageBox(HWND_DESKTOP, HwndDebugger, + WinMessageBox( HWND_DESKTOP, HwndDebugger, TRP_WIN_no_can_do, - TRP_The_WATCOM_Debugger, 1, MB_ERROR | MB_SYSTEMMODAL | MB_OK); + TRP_The_WATCOM_Debugger, 1, MB_ERROR | MB_SYSTEMMODAL | MB_OK ); } -ULONG CallDosDebug(uDB_t *buff) +ULONG CallDosDebug( uDB_t *buff ) { QMSG qmsg; int num_paints; @@ -95,70 +95,70 @@ ULONG CallDosDebug(uDB_t *buff) TID tid; ULONG ulCount; - if (!IsPMDebugger()) { - return DosDebug(buff); + if( !IsPMDebugger() ) { + return( DosDebug( buff ) ); } - switch (buff->Cmd) { - case DBG_C_ClearWatch: - case DBG_C_Freeze: - case DBG_C_LinToSel: - case DBG_C_NumToAddr: - case DBG_C_ReadCoRegs: - case DBG_C_ReadMemBuf: - case DBG_C_ReadMem_D: - case DBG_C_ReadReg: - case DBG_C_SelToLin: - case DBG_C_SetWatch: - case DBG_C_ThrdStat: - case DBG_C_WriteCoRegs: - case DBG_C_WriteMemBuf: - case DBG_C_WriteMem_D: - case DBG_C_WriteReg: - return DosDebug(buff); + switch( buff->Cmd ) { + case DBG_C_ClearWatch: + case DBG_C_Freeze: + case DBG_C_LinToSel: + case DBG_C_NumToAddr: + case DBG_C_ReadCoRegs: + case DBG_C_ReadMemBuf: + case DBG_C_ReadMem_D: + case DBG_C_ReadReg: + case DBG_C_SelToLin: + case DBG_C_SetWatch: + case DBG_C_ThrdStat: + case DBG_C_WriteCoRegs: + case DBG_C_WriteMemBuf: + case DBG_C_WriteMem_D: + case DBG_C_WriteReg: + return( DosDebug( buff ) ); } - switch (buff->Cmd) { - case DBG_C_Go: - case DBG_C_SStep: - case DBG_C_Term: - ReleaseQueue(buff->Pid, buff->Tid); + switch( buff->Cmd ) { + case DBG_C_Go: + case DBG_C_SStep: + case DBG_C_Term: + ReleaseQueue( buff->Pid, buff->Tid ); } DebugReqBuff = buff; StopBuff = *buff; - DosResetEventSem(DebugDoneSem, &ulCount); - DosPostEventSem(DebugReqSem); + DosResetEventSem( DebugDoneSem, &ulCount ); + DosPostEventSem( DebugReqSem ); num_paints = 0; - if (IsPMDebugger()) { - while (WinGetMsg(HabDebugger, &qmsg, 0L, 0, 0) || InDosDebug) { - WinQueryClassName(qmsg.hwnd, MAX_CLASS_NAME, class_name); + if( IsPMDebugger() ) { + while( WinGetMsg( HabDebugger, &qmsg, 0L, 0, 0 ) || InDosDebug ) { + WinQueryClassName( qmsg.hwnd, MAX_CLASS_NAME, class_name ); switch (qmsg.msg) { case WM_CHAR: - if ((SHORT1FROMMP(qmsg.mp1) & KC_VIRTUALKEY) && - (SHORT2FROMMP(qmsg.mp2) == VK_BREAK)) { + if( (SHORT1FROMMP( qmsg.mp1 ) & KC_VIRTUALKEY) && + (SHORT2FROMMP( qmsg.mp2 ) == VK_BREAK) ) { ULONG ulCount; SetBrkPending(); - DosCreateThread(&tid, StopApplication, 0, CREATE_READY | STACK_SPARSE, STACK_SIZE); - DosSetPriority(PRTYS_THREAD, PRTYC_TIMECRITICAL, 10, tid); - WakeThreads(StopBuff.Pid); - DosWaitEventSem(StopDoneSem, SEM_INDEFINITE_WAIT); - DosResetEventSem(StopDoneSem, &ulCount); + DosCreateThread( &tid, StopApplication, 0, CREATE_READY | STACK_SPARSE, STACK_SIZE ); + DosSetPriority( PRTYS_THREAD, PRTYC_TIMECRITICAL, 10, tid ); + WakeThreads( StopBuff.Pid ); + DosWaitEventSem( StopDoneSem, SEM_INDEFINITE_WAIT ); + DosResetEventSem( StopDoneSem, &ulCount ); } break; case WM_COMMAND: CantDoIt(); break; default: - if (strcmp(class_name, "GUIClass") == 0 || - strcmp(class_name, "WTool") == 0) { - switch (qmsg.msg) { + if( strcmp( class_name, "GUIClass" ) == 0 || + strcmp( class_name, "WTool" ) == 0 ) { + switch( qmsg.msg ) { case WM_PAINT: - if (num_paints >= MAX_PAINTS) + if( num_paints >= MAX_PAINTS ) --num_paints; paints[num_paints].hwnd = qmsg.hwnd; - ps = WinBeginPaint(qmsg.hwnd, 0, &paints[num_paints].rcl); - GpiErase(ps); - WinEndPaint(ps); + ps = WinBeginPaint( qmsg.hwnd, 0, &paints[num_paints].rcl ); + GpiErase( ps ); + WinEndPaint( ps ); num_paints++; break; case WM_BUTTON1DOWN: @@ -169,33 +169,33 @@ ULONG CallDosDebug(uDB_t *buff) case WM_MOUSEMOVE: { HPOINTER hourglass = WinQuerySysPointer( HWND_DESKTOP, SPTR_WAIT, FALSE ); - if (WinQueryPointer(HWND_DESKTOP) != hourglass) { - WinSetPointer(HWND_DESKTOP, hourglass); + if( WinQueryPointer( HWND_DESKTOP ) != hourglass ) { + WinSetPointer( HWND_DESKTOP, hourglass ); } break; } default: - WinDefWindowProc(qmsg.hwnd, qmsg.msg, qmsg.mp1, qmsg.mp2); + WinDefWindowProc( qmsg.hwnd, qmsg.msg, qmsg.mp1, qmsg.mp2 ); } } else { - WinDispatchMsg(HabDebugger, &qmsg); + WinDispatchMsg( HabDebugger, &qmsg ); } } } } else { - DosWaitEventSem(DebugDoneSem, SEM_INDEFINITE_WAIT); + DosWaitEventSem( DebugDoneSem, SEM_INDEFINITE_WAIT ); } - switch (buff->Cmd) { - case DBG_N_Exception: - case DBG_N_AsyncStop: - case DBG_N_Watchpoint: - AssumeQueue(buff->Pid, buff->Tid); - break; + switch( buff->Cmd ) { + case DBG_N_Exception: + case DBG_N_AsyncStop: + case DBG_N_Watchpoint: + AssumeQueue( buff->Pid, buff->Tid ); + break; } - for (i = 0; i < num_paints; ++i) { - WinInvalidateRect(paints[i].hwnd, &paints[i].rcl, FALSE); + for( i = 0; i < num_paints; ++i ) { + WinInvalidateRect( paints[i].hwnd, &paints[i].rcl, FALSE ); } - return DebugReqResult; + return( DebugReqResult ); } static void APIENTRY DoDebugRequests( ULONG arg ) @@ -204,16 +204,16 @@ static void APIENTRY DoDebugRequests( ULONG arg ) /* unused parameters */ (void)arg; - for ( ; ; ) { - DosWaitEventSem(DebugReqSem, SEM_INDEFINITE_WAIT); - DosResetEventSem(DebugReqSem, &ulCount); + for( ;; ) { + DosWaitEventSem( DebugReqSem, SEM_INDEFINITE_WAIT ); + DosResetEventSem( DebugReqSem, &ulCount ); InDosDebug = true; - DebugReqResult = DosDebug(DebugReqBuff); + DebugReqResult = DosDebug( DebugReqBuff ); InDosDebug = false; - if (IsPMDebugger()) { - WinPostMsg(HwndDebugger, WM_QUIT, 0, 0); + if( IsPMDebugger() ) { + WinPostMsg( HwndDebugger, WM_QUIT, 0, 0 ); } else { - DosPostEventSem(DebugDoneSem); + DosPostEventSem( DebugDoneSem ); } } } @@ -223,18 +223,18 @@ void InitDebugThread( void ) TID tid; ULONG ulCount; - if (StopDoneSem == NULLHANDLE) - DosCreateEventSem(NULL, &StopDoneSem, 0, FALSE); + if( StopDoneSem == NULLHANDLE ) + DosCreateEventSem( NULL, &StopDoneSem, 0, FALSE ); - if (DebugReqSem == NULLHANDLE) - DosCreateEventSem(NULL, &DebugReqSem, 0, FALSE); + if( DebugReqSem == NULLHANDLE ) + DosCreateEventSem( NULL, &DebugReqSem, 0, FALSE ); - if (DebugDoneSem == NULLHANDLE) - DosCreateEventSem(NULL, &DebugDoneSem, 0, FALSE); + if( DebugDoneSem == NULLHANDLE ) + DosCreateEventSem( NULL, &DebugDoneSem, 0, FALSE ); - DosResetEventSem(StopDoneSem, &ulCount); - DosResetEventSem(DebugReqSem, &ulCount); - DosResetEventSem(DebugDoneSem, &ulCount); - DosCreateThread(&tid, DoDebugRequests, 0, CREATE_READY | STACK_SPARSE, STACK_SIZE); - DosSetPriority(PRTYS_THREAD, PRTYC_TIMECRITICAL, 0, tid); + DosResetEventSem( StopDoneSem, &ulCount ); + DosResetEventSem( DebugReqSem, &ulCount ); + DosResetEventSem( DebugDoneSem, &ulCount ); + DosCreateThread( &tid, DoDebugRequests, 0, CREATE_READY | STACK_SPARSE, STACK_SIZE ); + DosSetPriority( PRTYS_THREAD, PRTYC_TIMECRITICAL, 0, tid ); } diff --git a/bld/trap/lcl/os2v2/h/wdpmhelp.h b/bld/trap/lcl/os2v2/h/wdpmhelp.h index 237ecb7fa1..ee8aa0880f 100644 --- a/bld/trap/lcl/os2v2/h/wdpmhelp.h +++ b/bld/trap/lcl/os2v2/h/wdpmhelp.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -46,9 +46,9 @@ enum { PMHELP_SWITCHBACK, }; -extern void StartPMHelp(void); -extern void StopPMHelp(void); +extern void StartPMHelp( void ); +extern void StopPMHelp( void ); -extern void PMLock(unsigned long,unsigned long); -extern void PMUnLock(void); -extern int PMFlip(void); +extern void PMLock( unsigned long,unsigned long ); +extern void PMUnLock( void ); +extern int PMFlip( void ); diff --git a/bld/trap/lcl/rdos/c/task.c b/bld/trap/lcl/rdos/c/task.c index e8497931a0..7134b529b5 100644 --- a/bld/trap/lcl/rdos/c/task.c +++ b/bld/trap/lcl/rdos/c/task.c @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -41,7 +42,7 @@ trap_version TRAPENTRY TrapInit( const char *parms, char *err, bool remote ) { trap_version ver; - remote = remote; parms = parms; + /* unused parameters */ (void)remote; (void)parms; err[0] = 0; ver.major = TRAP_MAJOR_VERSION; diff --git a/bld/trap/lcl/win/c/accgen.c b/bld/trap/lcl/win/c/accgen.c index e133dd5432..ac91098e03 100644 --- a/bld/trap/lcl/win/c/accgen.c +++ b/bld/trap/lcl/win/c/accgen.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -40,7 +40,7 @@ #include "winerr.h" -extern void set_carry(void); +extern void set_carry( void ); #pragma aux set_carry = 0xf9; volatile bool HaveKey; diff --git a/bld/trap/lcl/win/c/dbgeemsg.c b/bld/trap/lcl/win/c/dbgeemsg.c index ee00ff6bdf..53d7753922 100644 --- a/bld/trap/lcl/win/c/dbgeemsg.c +++ b/bld/trap/lcl/win/c/dbgeemsg.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -148,14 +148,14 @@ static bool SubClassWindow( HWND hwnd, bool do_children ) BOOL __export FAR PASCAL EnumTaskWindowsFunc( HWND hwnd, LPARAM lparam ) { - (void)lparam; + /* unused parameters */ (void)lparam; return( SubClassWindow( hwnd, true ) ); } BOOL __export FAR PASCAL EnumChildWindowsFunc( HWND hwnd, LPARAM lparam ) { - (void)lparam; + /* unused parameters */ (void)lparam; return( SubClassWindow( hwnd, false ) ); } diff --git a/bld/trap/net/c/netlink.c b/bld/trap/net/c/netlink.c index fb404a9b2f..6b58a59075 100644 --- a/bld/trap/net/c/netlink.c +++ b/bld/trap/net/c/netlink.c @@ -230,7 +230,7 @@ const char *RemoteLinkSet( const char *parms ) const char *RemoteLink( const char *parms, bool server ) { - (void)server; + /* unused parameters */ (void)server; if( parms != NULL ) { parms = RemoteLinkSet( parms ); diff --git a/bld/trap/nmp/c/nmplink.c b/bld/trap/nmp/c/nmplink.c index 2d55b2af90..29aaac478d 100644 --- a/bld/trap/nmp/c/nmplink.c +++ b/bld/trap/nmp/c/nmplink.c @@ -171,7 +171,7 @@ const char *RemoteLink( const char *parms, bool server ) { const char *err; - (void)server; + /* unused parameters */ (void)server; err = NULL; if( parms != NULL ) { diff --git a/bld/trap/nov/c/novdos.c b/bld/trap/nov/c/novdos.c index 8435a24359..8fa74c89a0 100644 --- a/bld/trap/nov/c/novdos.c +++ b/bld/trap/nov/c/novdos.c @@ -198,7 +198,7 @@ static void IpxWait( void ) // how clears out a condition in IPX where IPXRelinquishControl // won't return. //******************************************************************* - extern void clock(void); + extern void clock( void ); #pragma aux clock = \ "mov ah,2ch" \ "int 21h" \ @@ -561,7 +561,7 @@ const char *RemoteLink( const char *parms, bool server ) BYTE major_ver,minor_ver; WORD max_conn,avail_conn; - (void)server; + /* unused parameters */ (void)server; if( parms != NULL ) { parms = RemoteLinkSet( parms ); diff --git a/bld/trap/nov/c/novnt.c b/bld/trap/nov/c/novnt.c index 24ba289dba..8952aca869 100644 --- a/bld/trap/nov/c/novnt.c +++ b/bld/trap/nov/c/novnt.c @@ -379,7 +379,7 @@ const char *RemoteLink( const char *parms, bool server ) const char *p; #endif - (void)server; + /* unused parameters */ (void)server; if( parms != NULL ) { parms = RemoteLinkSet( parms ); diff --git a/bld/trap/par/c/dbginst.c b/bld/trap/par/c/dbginst.c index 607a647784..de9de2bdc6 100644 --- a/bld/trap/par/c/dbginst.c +++ b/bld/trap/par/c/dbginst.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -51,9 +51,9 @@ BOOL Quiet; Installs the driver ****************************************************************************/ static BOOL InstallDriver( - IN SC_HANDLE SchSCManager, - IN LPCTSTR DriverName, - IN LPCTSTR ServiceExe) + IN SC_HANDLE SchSCManager, + IN LPCTSTR DriverName, + IN LPCTSTR ServiceExe) { SC_HANDLE schService; DWORD err; @@ -98,8 +98,8 @@ static BOOL InstallDriver( Removes the driver ****************************************************************************/ static BOOL RemoveDriver( - IN SC_HANDLE SchSCManager, - IN LPCTSTR DriverName) + IN SC_HANDLE SchSCManager, + IN LPCTSTR DriverName) { SC_HANDLE schService; BOOL ret; @@ -124,8 +124,8 @@ static BOOL RemoveDriver( Starts the driver ****************************************************************************/ static BOOL StartDriver( - IN SC_HANDLE SchSCManager, - IN LPCTSTR DriverName) + IN SC_HANDLE SchSCManager, + IN LPCTSTR DriverName) { SC_HANDLE schService; BOOL ret; @@ -160,8 +160,8 @@ static BOOL StartDriver( Stops the driver ****************************************************************************/ static BOOL StopDriver( - IN SC_HANDLE SchSCManager, - IN LPCTSTR DriverName) + IN SC_HANDLE SchSCManager, + IN LPCTSTR DriverName) { SC_HANDLE schService; BOOL ret; @@ -187,7 +187,7 @@ static BOOL StopDriver( Opens the device driver ****************************************************************************/ static BOOL OpenDevice( - IN LPCTSTR test_file) + IN LPCTSTR test_file) { char completeDeviceName[64]; HANDLE hDevice; @@ -210,7 +210,7 @@ static BOOL OpenDevice( REMARKS: Print usage information for the driver ****************************************************************************/ -static void Usage(void) +static void Usage( void ) { printf( "drvinst [options] \n" ); printf( " options:\n" ); @@ -223,7 +223,7 @@ static void Usage(void) exit( 1 ); } -int main(int argc, char *argv[]) +int main( int argc, char *argv[] ) { SC_HANDLE schSCManager; BOOL remove = FALSE; diff --git a/bld/trap/par/c/dbgport.c b/bld/trap/par/c/dbgport.c index 1b914b5243..f82ce51c97 100644 --- a/bld/trap/par/c/dbgport.c +++ b/bld/trap/par/c/dbgport.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -390,23 +390,23 @@ IOPM *IOPM_saved = 0; // the newly copied map is actually used. Otherwise, the IOPM offset // points beyond the end of the TSS segment limit, causing any I/O // access by the user mode process to generate an exception. -void PORTSTDCALL Ke386SetIoAccessMap(int, IOPM *); -void PORTSTDCALL Ke386QueryIoAccessMap(int, IOPM *); -void PORTSTDCALL Ke386IoSetAccessProcess(PEPROCESS, int); +void PORTSTDCALL Ke386SetIoAccessMap( int, IOPM * ); +void PORTSTDCALL Ke386QueryIoAccessMap( int, IOPM * ); +void PORTSTDCALL Ke386IoSetAccessProcess( PEPROCESS, int ); -void NTAPI ZwYieldExecution(void); +void NTAPI ZwYieldExecution( void ); -static void NothingToDo(void) +static void NothingToDo( void ) { ZwYieldExecution(); } -static unsigned long Ticks(void) +static unsigned long Ticks( void ) { _int64 ticks; - KeQueryTickCount((PLARGE_INTEGER)&ticks); - return (unsigned long)(ticks / 10); + KeQueryTickCount( (PLARGE_INTEGER)&ticks ); + return( (unsigned long)( ticks / 10 ) ); } /* diff --git a/bld/trap/par/c/options.c b/bld/trap/par/c/options.c index 82e02c0700..9b370c9df6 100644 --- a/bld/trap/par/c/options.c +++ b/bld/trap/par/c/options.c @@ -39,8 +39,8 @@ #include "options.h" -extern int NumPrinters(void); -extern unsigned PrnAddress(int); +extern int NumPrinters( void ); +extern unsigned PrnAddress( int ); WINEXPORT INT_PTR CALLBACK OptionsDlgProc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam ) { diff --git a/bld/trap/par/c/parlink.c b/bld/trap/par/c/parlink.c index 9318e8e2c2..215f1dab33 100644 --- a/bld/trap/par/c/parlink.c +++ b/bld/trap/par/c/parlink.c @@ -202,7 +202,7 @@ #include "portio.h" -extern void Wait(void); +extern void Wait( void ); #pragma aux Wait = ; #if defined(_DBG) diff --git a/bld/trap/par/c/parqnx.c b/bld/trap/par/c/parqnx.c index 09eae94732..1bab58450a 100644 --- a/bld/trap/par/c/parqnx.c +++ b/bld/trap/par/c/parqnx.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -68,8 +68,8 @@ unsigned PrnAddress( int printer ) #pragma aux get_cs = "mov ax,cs" __value [__ax] #pragma aux get_flags = "pushfd" "pop eax" __value [__eax] -extern unsigned short get_cs(void); -extern unsigned get_flags(void); +extern unsigned short get_cs( void ); +extern unsigned get_flags( void ); #define PRIV_MASK 3 #define IOPL_SHIFT 12 diff --git a/bld/trap/vdm/c/vdmlink.c b/bld/trap/vdm/c/vdmlink.c index 2d43c777c2..9145ab88ef 100644 --- a/bld/trap/vdm/c/vdmlink.c +++ b/bld/trap/vdm/c/vdmlink.c @@ -349,7 +349,8 @@ trap_retval RemoteGet( void *data, trap_elen len ) trap_elen ret; #endif - (void)len; + /* unused parameters */ (void)len; + #ifdef SERVER TinyRead( pipeHdl, &incoming, sizeof( incoming ) ); ret = incoming; From 00c1b21015b04d3247236fc6160f2dc5bd39eba2 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Sun, 3 Sep 2023 22:49:35 +0200 Subject: [PATCH 085/258] rename symbols for consistency --- bld/dig/h/digld.h | 2 +- bld/dip/dipdump/c/digcli.c | 18 ++++++------- bld/sdk/drwat/nt/digcli.c | 12 ++++----- bld/sdk/drwat/win/digcli.c | 12 ++++----- bld/trap/common/dos/dosdigl.c | 18 ++++++------- bld/trap/common/linux/lnxdigl.c | 18 ++++++------- bld/trap/common/nt/ntdigl.c | 18 ++++++------- bld/trap/common/nto/ntodigl.c | 18 ++++++------- bld/trap/common/os2/os2digl.c | 18 ++++++------- bld/trap/common/os2v2/os22digl.c | 18 ++++++------- bld/trap/common/qnx/qnxdigl.c | 18 ++++++------- bld/trap/common/rdos/rdosdigl.c | 18 ++++++------- bld/trap/common/win/windigl.c | 18 ++++++------- bld/trap/lcl/dos/dosx/cw/c/cwacc.c | 8 +++--- bld/trap/lcl/elfcore/c/elfcore.c | 8 +++--- bld/trap/lcl/jvm/c/jvmacc.c | 12 ++++----- bld/trap/lcl/linux/c/lnxcore.c | 8 +++--- bld/trap/lcl/linux/c/lnxmap.c | 10 +++---- bld/trap/lcl/msj/c/control.cpp | 10 +++---- bld/trap/lcl/nt/c/accmap.c | 42 +++++++++++++++--------------- bld/trap/lcl/nt/c/ntrfx.c | 28 ++++++++++---------- bld/trap/lcl/nto/c/ntomap.c | 10 +++---- bld/trap/lcl/qnx/c/qnxacc.c | 20 +++++++------- bld/trap/lcl/qnx/c/qnxpmd.c | 8 +++--- bld/trap/lcl/rdos/c/accmap.c | 10 +++---- bld/trap/lcl/rdos/c/debug.c | 12 ++++----- bld/trap/lcl/win/c/accmap.c | 10 +++---- bld/wprof/c/utils.c | 18 ++++++------- bld/wv/c/dbgfile.c | 40 ++++++++++++++-------------- bld/wv/h/dbgio.h | 4 +-- 30 files changed, 232 insertions(+), 232 deletions(-) diff --git a/bld/dig/h/digld.h b/bld/dig/h/digld.h index a1d327eb9c..40f0246ca8 100644 --- a/bld/dig/h/digld.h +++ b/bld/dig/h/digld.h @@ -36,7 +36,7 @@ #define DIGLoader(n) DIGLoader ## n -extern size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base_name_len, const char *defext, char *filename, size_t filename_len ); +extern size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base_name_len, const char *defext, char *filename, size_t filename_maxlen ); extern FILE *DIGLoader( Open )( const char *filename ); extern int DIGLoader( Close )( FILE *fp ); extern int DIGLoader( Read )( FILE *fp, void *buff, size_t len ); diff --git a/bld/dip/dipdump/c/digcli.c b/bld/dip/dipdump/c/digcli.c index a76d02a4b7..9178998904 100644 --- a/bld/dip/dipdump/c/digcli.c +++ b/bld/dip/dipdump/c/digcli.c @@ -205,8 +205,8 @@ void PathFini( void ) } size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base_name_len, - const char *defext, char *filename, size_t filename_len ) -/****************************************************************************************/ + const char *defext, char *filename, size_t filename_maxlen ) +/******************************************************************************************/ { char fullname[_MAX_PATH2]; char fname[_MAX_PATH2]; @@ -251,13 +251,13 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base p = ""; } len = strlen( p ); - if( filename_len > 0 ) { - filename_len--; - if( filename_len > len ) - filename_len = len; - if( filename_len > 0 ) - strncpy( filename, p, filename_len ); - filename[filename_len] = '\0'; + if( filename_maxlen > 0 ) { + filename_maxlen--; + if( filename_maxlen > len ) + filename_maxlen = len; + if( filename_maxlen > 0 ) + strncpy( filename, p, filename_maxlen ); + filename[filename_maxlen] = '\0'; } return( len ); } diff --git a/bld/sdk/drwat/nt/digcli.c b/bld/sdk/drwat/nt/digcli.c index f6bfca7d74..c4eb3b4850 100644 --- a/bld/sdk/drwat/nt/digcli.c +++ b/bld/sdk/drwat/nt/digcli.c @@ -221,8 +221,8 @@ unsigned DIGCLIENTRY( MachineData )( address addr, dig_info_type info_type, dig_ } size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base_name_len, - const char *defext, char *filename, size_t filename_len ) -/***************************************************************************************** + const char *defext, char *filename, size_t filename_maxlen ) +/******************************************************************************************* * DIGLoaderFind */ { @@ -232,8 +232,8 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base /* unused parameters */ (void)ftype; len = 0; - if( filename_len > 0 ) { - filename_len--; + if( filename_maxlen > 0 ) { + filename_maxlen--; if( base_name_len == 0 ) base_name_len = strlen( base_name ); strncpy( fname, base_name, base_name_len ); @@ -242,8 +242,8 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base _searchenv( fname, "WD_PATH" QSTR( BLDVER ), fname ); #endif len = strlen( fname ); - if( len > filename_len ) - len = filename_len; + if( len > filename_maxlen ) + len = filename_maxlen; strncpy( filename, fname, len ); filename[len] = '\0'; } diff --git a/bld/sdk/drwat/win/digcli.c b/bld/sdk/drwat/win/digcli.c index 0ad235d133..4dedb18752 100644 --- a/bld/sdk/drwat/win/digcli.c +++ b/bld/sdk/drwat/win/digcli.c @@ -224,8 +224,8 @@ unsigned DIGCLIENTRY( MachineData )( address addr, dig_info_type info_type, dig_ } size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base_name_len, - const char *defext, char *filename, size_t filename_len ) -/***************************************************************************************** + const char *defext, char *filename, size_t filename_maxlen ) +/******************************************************************************************* * DIGLoaderFind */ { @@ -235,8 +235,8 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base /* unused parameters */ (void)ftype; len = 0; - if( filename_len > 0 ) { - filename_len--; + if( filename_maxlen > 0 ) { + filename_maxlen--; if( base_name_len == 0 ) base_name_len = strlen( base_name ); strncpy( fname, base_name, base_name_len ); @@ -245,8 +245,8 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base _searchenv( fname, "WD_PATH" QSTR( BLDVER ), fname ); #endif len = strlen( fname ); - if( len > filename_len ) - len = filename_len; + if( len > filename_maxlen ) + len = filename_maxlen; strncpy( filename, fname, len ); filename[len] = '\0'; } diff --git a/bld/trap/common/dos/dosdigl.c b/bld/trap/common/dos/dosdigl.c index 2fc5d7afef..c3cdc91699 100644 --- a/bld/trap/common/dos/dosdigl.c +++ b/bld/trap/common/dos/dosdigl.c @@ -45,8 +45,8 @@ #define FP2HANDLE(fp) ((int)((unsigned long)(fp) - 1)) size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base_name_len, - const char *defext, char *filename, size_t filename_len ) -/****************************************************************************************/ + const char *defext, char *filename, size_t filename_maxlen ) +/******************************************************************************************/ { char fname[256]; size_t len; @@ -65,13 +65,13 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base _searchenv( fname, "PATH", RWBuff ); #endif len = strlen( RWBuff ); - if( filename_len > 0 ) { - filename_len--; - if( filename_len > len ) - filename_len = len; - if( filename_len > 0 ) - strncpy( filename, RWBuff, filename_len ); - filename[filename_len] = '\0'; + if( filename_maxlen > 0 ) { + filename_maxlen--; + if( filename_maxlen > len ) + filename_maxlen = len; + if( filename_maxlen > 0 ) + strncpy( filename, RWBuff, filename_maxlen ); + filename[filename_maxlen] = '\0'; } return( len ); } diff --git a/bld/trap/common/linux/lnxdigl.c b/bld/trap/common/linux/lnxdigl.c index 25b98102ba..42e2626790 100644 --- a/bld/trap/common/linux/lnxdigl.c +++ b/bld/trap/common/linux/lnxdigl.c @@ -42,8 +42,8 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base_name_len, - const char *defext, char *filename, size_t filename_len ) -/****************************************************************************************/ + const char *defext, char *filename, size_t filename_maxlen ) +/******************************************************************************************/ { char fname[256]; size_t len; @@ -55,13 +55,13 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base strncpy( fname, base_name, base_name_len ); strcpy( fname + base_name_len, defext ); len = FindFilePath( DIG_FILETYPE_DBG, fname, RWBuff ); - if( filename_len > 0 ) { - filename_len--; - if( filename_len > len ) - filename_len = len; - if( filename_len > 0 ) - strncpy( filename, RWBuff, filename_len ); - filename[filename_len] = '\0'; + if( filename_maxlen > 0 ) { + filename_maxlen--; + if( filename_maxlen > len ) + filename_maxlen = len; + if( filename_maxlen > 0 ) + strncpy( filename, RWBuff, filename_maxlen ); + filename[filename_maxlen] = '\0'; } return( len ); } diff --git a/bld/trap/common/nt/ntdigl.c b/bld/trap/common/nt/ntdigl.c index f93787fd53..e2200dd914 100644 --- a/bld/trap/common/nt/ntdigl.c +++ b/bld/trap/common/nt/ntdigl.c @@ -39,8 +39,8 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base_name_len, - const char *defext, char *filename, size_t filename_len ) -/****************************************************************************************/ + const char *defext, char *filename, size_t filename_maxlen ) +/******************************************************************************************/ { char fname[256]; size_t len; @@ -59,13 +59,13 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base _searchenv( fname, "PATH", RWBuff ); #endif len = strlen( RWBuff ); - if( filename_len > 0 ) { - filename_len--; - if( filename_len > len ) - filename_len = len; - if( filename_len > 0 ) - strncpy( filename, RWBuff, filename_len ); - filename[filename_len] = '\0'; + if( filename_maxlen > 0 ) { + filename_maxlen--; + if( filename_maxlen > len ) + filename_maxlen = len; + if( filename_maxlen > 0 ) + strncpy( filename, RWBuff, filename_maxlen ); + filename[filename_maxlen] = '\0'; } return( len ); } diff --git a/bld/trap/common/nto/ntodigl.c b/bld/trap/common/nto/ntodigl.c index 9c41ca5d89..291bce0c69 100644 --- a/bld/trap/common/nto/ntodigl.c +++ b/bld/trap/common/nto/ntodigl.c @@ -44,8 +44,8 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base_name_len, - const char *defext, char *filename, size_t filename_len ) -/****************************************************************************************/ + const char *defext, char *filename, size_t filename_maxlen ) +/******************************************************************************************/ { char fname[256]; size_t len; @@ -57,13 +57,13 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base strncpy( fname, base_name, base_name_len ); strcpy( fname + base_name_len, defext ); len = FindFilePath( DIG_FILETYPE_DBG, fname, RWBuff ); - if( filename_len > 0 ) { - filename_len--; - if( filename_len > len ) - filename_len = len; - if( filename_len > 0 ) - strncpy( filename, RWBuff, filename_len ); - filename[filename_len] = '\0'; + if( filename_maxlen > 0 ) { + filename_maxlen--; + if( filename_maxlen > len ) + filename_maxlen = len; + if( filename_maxlen > 0 ) + strncpy( filename, RWBuff, filename_maxlen ); + filename[filename_maxlen] = '\0'; } return( len ); } diff --git a/bld/trap/common/os2/os2digl.c b/bld/trap/common/os2/os2digl.c index d1595473d5..a876d2bf18 100644 --- a/bld/trap/common/os2/os2digl.c +++ b/bld/trap/common/os2/os2digl.c @@ -39,8 +39,8 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base_name_len, - const char *defext, char *filename, size_t filename_len ) -/****************************************************************************************/ + const char *defext, char *filename, size_t filename_maxlen ) +/******************************************************************************************/ { char fname[256]; size_t len; @@ -59,13 +59,13 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base _searchenv( fname, "PATH", RWBuff ); #endif len = strlen( RWBuff ); - if( filename_len > 0 ) { - filename_len--; - if( filename_len > len ) - filename_len = len; - if( filename_len > 0 ) - strncpy( filename, RWBuff, filename_len ); - filename[filename_len] = '\0'; + if( filename_maxlen > 0 ) { + filename_maxlen--; + if( filename_maxlen > len ) + filename_maxlen = len; + if( filename_maxlen > 0 ) + strncpy( filename, RWBuff, filename_maxlen ); + filename[filename_maxlen] = '\0'; } return( len ); } diff --git a/bld/trap/common/os2v2/os22digl.c b/bld/trap/common/os2v2/os22digl.c index 061bc471ee..d176256ee8 100644 --- a/bld/trap/common/os2v2/os22digl.c +++ b/bld/trap/common/os2v2/os22digl.c @@ -39,8 +39,8 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base_name_len, - const char *defext, char *filename, size_t filename_len ) -/****************************************************************************************/ + const char *defext, char *filename, size_t filename_maxlen ) +/******************************************************************************************/ { char fname[256]; size_t len; @@ -59,13 +59,13 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base _searchenv( fname, "PATH", RWBuff ); #endif len = strlen( RWBuff ); - if( filename_len > 0 ) { - filename_len--; - if( filename_len > len ) - filename_len = len; - if( filename_len > 0 ) - strncpy( filename, RWBuff, filename_len ); - filename[filename_len] = '\0'; + if( filename_maxlen > 0 ) { + filename_maxlen--; + if( filename_maxlen > len ) + filename_maxlen = len; + if( filename_maxlen > 0 ) + strncpy( filename, RWBuff, filename_maxlen ); + filename[filename_maxlen] = '\0'; } return( len ); } diff --git a/bld/trap/common/qnx/qnxdigl.c b/bld/trap/common/qnx/qnxdigl.c index 945a7aa05d..f888055c78 100644 --- a/bld/trap/common/qnx/qnxdigl.c +++ b/bld/trap/common/qnx/qnxdigl.c @@ -44,8 +44,8 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base_name_len, - const char *defext, char *filename, size_t filename_len ) -/****************************************************************************************/ + const char *defext, char *filename, size_t filename_maxlen ) +/******************************************************************************************/ { char fname[PATH_MAX + 1]; size_t len; @@ -57,13 +57,13 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base strncpy( fname, base_name, base_name_len ); strcpy( fname + base_name_len, defext ); len = FindFilePath( DIG_FILETYPE_DBG, fname, RWBuff ); - if( filename_len > 0 ) { - filename_len--; - if( filename_len > len ) - filename_len = len; - if( filename_len > 0 ) - strncpy( filename, RWBuff, filename_len ); - filename[filename_len] = '\0'; + if( filename_maxlen > 0 ) { + filename_maxlen--; + if( filename_maxlen > len ) + filename_maxlen = len; + if( filename_maxlen > 0 ) + strncpy( filename, RWBuff, filename_maxlen ); + filename[filename_maxlen] = '\0'; } return( len ); } diff --git a/bld/trap/common/rdos/rdosdigl.c b/bld/trap/common/rdos/rdosdigl.c index 2e42de3745..ec99c3eaab 100644 --- a/bld/trap/common/rdos/rdosdigl.c +++ b/bld/trap/common/rdos/rdosdigl.c @@ -39,8 +39,8 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base_name_len, - const char *defext, char *filename, size_t filename_len ) -/****************************************************************************************/ + const char *defext, char *filename, size_t filename_maxlen ) +/******************************************************************************************/ { char fname[256]; size_t len; @@ -59,13 +59,13 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base _searchenv( fname, "PATH", RWBuff ); #endif len = strlen( RWBuff ); - if( filename_len > 0 ) { - filename_len--; - if( filename_len > len ) - filename_len = len; - if( filename_len > 0 ) - strncpy( filename, RWBuff, filename_len ); - filename[filename_len] = '\0'; + if( filename_maxlen > 0 ) { + filename_maxlen--; + if( filename_maxlen > len ) + filename_maxlen = len; + if( filename_maxlen > 0 ) + strncpy( filename, RWBuff, filename_maxlen ); + filename[filename_maxlen] = '\0'; } return( len ); } diff --git a/bld/trap/common/win/windigl.c b/bld/trap/common/win/windigl.c index f889dfc03b..0b3dcd195b 100644 --- a/bld/trap/common/win/windigl.c +++ b/bld/trap/common/win/windigl.c @@ -39,8 +39,8 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base_name_len, - const char *defext, char *filename, size_t filename_len ) -/****************************************************************************************/ + const char *defext, char *filename, size_t filename_maxlen ) +/******************************************************************************************/ { char fname[256]; size_t len; @@ -59,13 +59,13 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base _searchenv( fname, "PATH", RWBuff ); #endif len = strlen( RWBuff ); - if( filename_len > 0 ) { - filename_len--; - if( filename_len > len ) - filename_len = len; - if( filename_len > 0 ) - strncpy( filename, RWBuff, filename_len ); - filename[filename_len] = '\0'; + if( filename_maxlen > 0 ) { + filename_maxlen--; + if( filename_maxlen > len ) + filename_maxlen = len; + if( filename_maxlen > 0 ) + strncpy( filename, RWBuff, filename_maxlen ); + filename[filename_maxlen] = '\0'; } return( len ); } diff --git a/bld/trap/lcl/dos/dosx/cw/c/cwacc.c b/bld/trap/lcl/dos/dosx/cw/c/cwacc.c index 132d0a7afb..4222708bbd 100644 --- a/bld/trap/lcl/dos/dosx/cw/c/cwacc.c +++ b/bld/trap/lcl/dos/dosx/cw/c/cwacc.c @@ -976,7 +976,7 @@ trap_retval TRAP_CORE( Get_lib_name )( void ) get_lib_name_req *acc; get_lib_name_ret *ret; int handle; - size_t max_len; + size_t name_maxlen; acc = GetInPtr( 0 ); ret = GetOutPtr( 0 ); @@ -988,9 +988,9 @@ trap_retval TRAP_CORE( Get_lib_name )( void ) name = GetOutPtr( sizeof( *ret ) ); *name = '\0'; if( ModHandles[handle].loaded ) { - max_len = GetTotalSizeOut() - sizeof( *ret ) - 1; - strncpy( name, ModHandles[handle].epsp->FileName, max_len ); - name[max_len] = '\0'; + name_maxlen = GetTotalSizeOut() - sizeof( *ret ) - 1; + strncpy( name, ModHandles[handle].epsp->FileName, name_maxlen ); + name[name_maxlen] = '\0'; } ret->mod_handle = handle; return( sizeof( *ret ) + strlen( name ) + 1 ); diff --git a/bld/trap/lcl/elfcore/c/elfcore.c b/bld/trap/lcl/elfcore/c/elfcore.c index 72a8cbfd60..030d47ed4a 100644 --- a/bld/trap/lcl/elfcore/c/elfcore.c +++ b/bld/trap/lcl/elfcore/c/elfcore.c @@ -717,7 +717,7 @@ trap_retval TRAP_CORE( Get_lib_name )( void ) get_lib_name_ret *ret; char *name; char *p; - size_t max_len; + size_t name_maxlen; // TODO: we ought to figure out what shared libs were loaded acc = GetInPtr( 0 ); @@ -736,10 +736,10 @@ trap_retval TRAP_CORE( Get_lib_name )( void ) ret->mod_handle = 0; return( sizeof( *ret ) ); } - max_len = GetTotalSizeOut() - sizeof( *ret ) - 1; + name_maxlen = GetTotalSizeOut() - sizeof( *ret ) - 1; name = GetOutPtr( sizeof( *ret ) ); - strncpy( name, p, max_len ); - name[max_len] = '\0'; + strncpy( name, p, name_maxlen ); + name[name_maxlen] = '\0'; return( sizeof( *ret ) + strlen( name ) + 1 ); } diff --git a/bld/trap/lcl/jvm/c/jvmacc.c b/bld/trap/lcl/jvm/c/jvmacc.c index edb962323b..0c080ca4c7 100644 --- a/bld/trap/lcl/jvm/c/jvmacc.c +++ b/bld/trap/lcl/jvm/c/jvmacc.c @@ -1036,7 +1036,7 @@ trap_retval TRAP_CORE( Get_lib_name )( void ) ClassClass *cb; int nbinclasses = get_nbinclasses(); ClassClass **binclasses = get_binclasses(); - size_t max_len; + size_t name_maxlen; acc = GetInPtr( 0 ); ret = GetOutPtr( 0 ); @@ -1063,12 +1063,12 @@ trap_retval TRAP_CORE( Get_lib_name )( void ) cb = binclasses[first]; } - max_len = GetTotalSizeOut() - sizeof( *ret ) - 1; + name_maxlen = GetTotalSizeOut() - sizeof( *ret ) - 1; name = GetOutPtr( sizeof( *ret ) ); - strncpy( name, JAVAPREFIX, max_len ); - name[max_len] = '\0'; - strcat( name, cb->name, max_len - strlen( name ) ); - name[max_len] = '\0'; + strncpy( name, JAVAPREFIX, name_maxlen ); + name[name_maxlen] = '\0'; + strncat( name, cb->name, name_maxlen - strlen( name ) ); + name[name_maxlen] = '\0'; ret->mod_handle = LastClassGiven = first + 1; return( sizeof( *ret ) + strlen( name ) + 1 ); } diff --git a/bld/trap/lcl/linux/c/lnxcore.c b/bld/trap/lcl/linux/c/lnxcore.c index dd1fc03a9e..eb7b4cde09 100644 --- a/bld/trap/lcl/linux/c/lnxcore.c +++ b/bld/trap/lcl/linux/c/lnxcore.c @@ -645,7 +645,7 @@ trap_retval TRAP_CORE( Get_lib_name )( void ) get_lib_name_ret *ret; char *name; char *p; - size_t max_len; + size_t name_maxlen; // TODO: we could probably figure out what shared libs were loaded acc = GetInPtr( 0 ); @@ -664,10 +664,10 @@ trap_retval TRAP_CORE( Get_lib_name )( void ) ret->mod_handle = 0; return( sizeof( *ret ) ); } - max_len = GetTotalSizeOut() - sizeof( *ret ) - 1; + name_maxlen = GetTotalSizeOut() - sizeof( *ret ) - 1; name = GetOutPtr( sizeof( *ret ) ); - strncpy( name, p, max_len ); - name[max_len] = '\0'; + strncpy( name, p, name_maxlen ); + name[name_maxlen] = '\0'; return( sizeof( *ret ) + strlen( name ) + 1 ); } diff --git a/bld/trap/lcl/linux/c/lnxmap.c b/bld/trap/lcl/linux/c/lnxmap.c index 3efda601ea..3529615193 100644 --- a/bld/trap/lcl/linux/c/lnxmap.c +++ b/bld/trap/lcl/linux/c/lnxmap.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -315,7 +315,7 @@ trap_retval TRAP_CORE( Get_lib_name )( void ) char *name; unsigned i; trap_elen ret_len; - size_t max_len; + size_t name_maxlen; acc = GetInPtr( 0 ); CONV_LE_32( acc->mod_handle ); @@ -334,9 +334,9 @@ trap_retval TRAP_CORE( Get_lib_name )( void ) } else if( moduleInfo[i].newly_loaded ) { Out( "(newly loaded) " ); ret->mod_handle = i; - max_len = GetTotalSizeOut() - sizeof( *ret ) - 1; - strncpy( name, moduleInfo[i].filename, max_len ); - name[max_len] = '\0'; + name_maxlen = GetTotalSizeOut() - sizeof( *ret ) - 1; + strncpy( name, moduleInfo[i].filename, name_maxlen ); + name[name_maxlen] = '\0'; moduleInfo[i].newly_loaded = false; ret_len += strlen( name ) + 1; break; diff --git a/bld/trap/lcl/msj/c/control.cpp b/bld/trap/lcl/msj/c/control.cpp index d2c6cce09c..71251ba680 100644 --- a/bld/trap/lcl/msj/c/control.cpp +++ b/bld/trap/lcl/msj/c/control.cpp @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -348,8 +348,8 @@ void AddCueInfo( int idx ) } } -unsigned GetLibName( unsigned handle, char *name, size_t max_len ) -/****************************************************************/ +unsigned GetLibName( unsigned handle, char *name, size_t name_maxlen ) +/********************************************************************/ { int i; @@ -359,8 +359,8 @@ unsigned GetLibName( unsigned handle, char *name, size_t max_len ) ImageMap[i].newly_unloaded = FALSE; return( i + 1 ); } else if( ImageMap[i].newly_loaded ) { - strncpy( name, ImageMap[i].className, max_len ); - name[max_len] = '\0'; + strncpy( name, ImageMap[i].className, name_maxlen ); + name[name_maxlen] = '\0'; ImageMap[i].newly_loaded = FALSE; LastNameGiven = i; return( i + 1 ); diff --git a/bld/trap/lcl/nt/c/accmap.c b/bld/trap/lcl/nt/c/accmap.c index 9575744a27..9ffcf897b5 100644 --- a/bld/trap/lcl/nt/c/accmap.c +++ b/bld/trap/lcl/nt/c/accmap.c @@ -282,8 +282,8 @@ void AddProcess( header_info *hi ) llo->filename[0] = '\0'; } -static bool NameFromProcess( lib_load_info *llo, DWORD dwPID, char *buff, size_t maxlen ) -/**************************************************************************************** +static bool NameFromProcess( lib_load_info *llo, DWORD dwPID, char *buff, size_t buff_maxlen ) +/********************************************************************************************* * get fully qualified filename for last DLL * that was loaded in process. Intended for Win9x. */ @@ -313,8 +313,8 @@ static bool NameFromProcess( lib_load_info *llo, DWORD dwPID, char *buff, size_t */ if( !pModule32First( hModuleSnap, &me32 ) ) goto error_exit; - if( maxlen > 0 ) { - maxlen--; + if( buff_maxlen > 0 ) { + buff_maxlen--; /* * Look for freshly loaded module. Not tested on Win9x. * Unfortunately in WinXP not all newly loaded modules are in the list. @@ -324,10 +324,10 @@ static bool NameFromProcess( lib_load_info *llo, DWORD dwPID, char *buff, size_t do { if( me32.modBaseAddr == llo->base ) { len = strlen( me32.szExePath ); - if( maxlen > len ) - maxlen = len; - strncpy( buff, me32.szExePath, maxlen ); - buff[maxlen] = '\0'; + if( buff_maxlen > len ) + buff_maxlen = len; + strncpy( buff, me32.szExePath, buff_maxlen ); + buff[buff_maxlen] = '\0'; bSuccess = true; break; } @@ -341,8 +341,8 @@ static bool NameFromProcess( lib_load_info *llo, DWORD dwPID, char *buff, size_t return( bSuccess ); } -static bool NameFromHandle( HANDLE hFile, char *buff, size_t maxlen ) -/******************************************************************** +static bool NameFromHandle( HANDLE hFile, char *buff, size_t buff_maxlen ) +/************************************************************************* * get fully qualified filename from file handle. * Intended for Windows NT. */ @@ -359,7 +359,7 @@ static bool NameFromHandle( HANDLE hFile, char *buff, size_t maxlen ) pMem = NULL; hFileMap = NULL; bSuccess = false; - if( maxlen == 0 ) + if( buff_maxlen == 0 ) goto error_exit; buff[0] = '\0'; /* @@ -390,8 +390,8 @@ static bool NameFromHandle( HANDLE hFile, char *buff, size_t maxlen ) /* * Translate path with device name to drive letters. */ - if( maxlen > 3 ) { - maxlen -= 3; + if( buff_maxlen > 3 ) { + buff_maxlen -= 3; szTemp[0] = '\0'; if( GetLogicalDriveStrings( BUFSIZE - 1, szTemp ) ) { @@ -418,10 +418,10 @@ static bool NameFromHandle( HANDLE hFile, char *buff, size_t maxlen ) */ p = pszFilename + len; len = strlen( p ); - if( maxlen > len ) - maxlen = len; - strncpy( buff + 2, p, maxlen ); - buff[maxlen + 2] = '\0'; + if( buff_maxlen > len ) + buff_maxlen = len; + strncpy( buff + 2, p, buff_maxlen ); + buff[buff_maxlen + 2] = '\0'; bSuccess = true; break; } @@ -695,7 +695,7 @@ trap_retval TRAP_CORE( Get_lib_name )( void ) get_lib_name_ret *ret; char *name; unsigned i; - size_t max_len; + size_t name_maxlen; acc = GetInPtr( 0 ); ret = GetOutPtr( 0 ); @@ -708,10 +708,10 @@ trap_retval TRAP_CORE( Get_lib_name )( void ) return( sizeof( *ret ) + 1 ); } else if( moduleInfo[i].newly_loaded ) { ret->mod_handle = i; - max_len = GetTotalSizeOut() - sizeof( *ret ) - 1; + name_maxlen = GetTotalSizeOut() - sizeof( *ret ) - 1; name = GetOutPtr( sizeof( *ret ) ); - strncpy( name, moduleInfo[i].filename, max_len ); - name[max_len] = '\0'; + strncpy( name, moduleInfo[i].filename, name_maxlen ); + name[name_maxlen] = '\0'; moduleInfo[i].newly_loaded = false; /* * once the debugger asks for a lib name, we also add it to our lib diff --git a/bld/trap/lcl/nt/c/ntrfx.c b/bld/trap/lcl/nt/c/ntrfx.c index 17306e65c4..ab2442a3bd 100644 --- a/bld/trap/lcl/nt/c/ntrfx.c +++ b/bld/trap/lcl/nt/c/ntrfx.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -245,8 +245,8 @@ trap_retval TRAP_RFX( getdatetime )( void ) return( sizeof( *ret ) ); } -static void nt_getdcwd( int drive, char *buff, size_t max_len ) -/************************************************************** +static void nt_getdcwd( int drive, char *buff, size_t buff_maxlen ) +/****************************************************************** * entry 0=current drive,1=A,2=B,... */ { @@ -256,14 +256,14 @@ static void nt_getdcwd( int drive, char *buff, size_t max_len ) *buff = '\0'; if( GetError( GetCurrentDirectory( sizeof( tmp ), tmp ) ) == 0 ) { if( drive == 0 ) { - strncpy( buff, tmp, max_len ); - buff[max_len] = '\0'; + strncpy( buff, tmp, buff_maxlen ); + buff[buff_maxlen] = '\0'; } else { old_drive = CHARLOW( tmp[0] ) - 'a'; if( nt_set_drive( drive ) == 0 ) { if( GetError( GetCurrentDirectory( sizeof( tmp ), tmp ) ) == 0 ) { - strncpy( buff, tmp, max_len ); - buff[max_len] = '\0'; + strncpy( buff, tmp, buff_maxlen ); + buff[buff_maxlen] = '\0'; } nt_set_drive( old_drive ); } @@ -279,13 +279,13 @@ trap_retval TRAP_RFX( getcwd )( void ) rfx_getcwd_req *acc; rfx_getcwd_ret *ret; char *buff; - size_t max_len; + size_t cwd_maxlen; acc = GetInPtr( 0 ); ret = GetOutPtr( 0 ); buff = GetOutPtr( sizeof( *ret ) ); - max_len = GetTotalSizeOut() - sizeof( *ret ) - 1; - nt_getdcwd( acc->drive, buff, max_len ); + cwd_maxlen = GetTotalSizeOut() - sizeof( *ret ) - 1; + nt_getdcwd( acc->drive, buff, cwd_maxlen ); return( sizeof( *ret ) + strlen( buff ) + 1 ); } @@ -392,7 +392,7 @@ trap_retval TRAP_RFX( nametocanonical )( void ) char tmp[MAX_PATH]; int level = 0; int drive; - size_t max_len; + size_t fullname_maxlen; /* * Not tested, and not used right now @@ -400,7 +400,7 @@ trap_retval TRAP_RFX( nametocanonical )( void ) name = GetInPtr( sizeof( rfx_nametocanonical_req ) ); ret = GetOutPtr( 0 ); fullname = GetOutPtr( sizeof( *ret ) ); - max_len = GetTotalSizeOut() - sizeof( *ret ) - 1; + fullname_maxlen = GetTotalSizeOut() - sizeof( *ret ) - 1; ret->err = 0; while( *name == ' ' ) { name++; @@ -416,8 +416,8 @@ trap_retval TRAP_RFX( nametocanonical )( void ) p = tmp; if( p[0] != '\0' && p[1] == ':' ) p += 2; - strncpy( fullname, p, max_len ); - fullname[max_len] = '\0'; + strncpy( fullname, p, fullname_maxlen ); + fullname[fullname_maxlen] = '\0'; if( *fullname != '\0' ) { level++; while( *fullname != '\0' ) { diff --git a/bld/trap/lcl/nto/c/ntomap.c b/bld/trap/lcl/nto/c/ntomap.c index 01aeca1900..4a02612cae 100644 --- a/bld/trap/lcl/nto/c/ntomap.c +++ b/bld/trap/lcl/nto/c/ntomap.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -315,7 +315,7 @@ trap_retval TRAP_CORE( Get_lib_name )( void ) char *name; unsigned i; unsigned ret_len; - size_t max_len; + size_t name_maxlen; #ifdef DEBUG_OUT char *p = ""; #endif @@ -344,10 +344,10 @@ trap_retval TRAP_CORE( Get_lib_name )( void ) dbg_print(( "(lib loaded, '%s')\n", name )); moduleInfo[i].newly_loaded = FALSE; ret->mod_handle = i; - max_len = GetTotalSizeOut() - sizeof( *ret ) - 1; + name_maxlen = GetTotalSizeOut() - sizeof( *ret ) - 1; name = GetOutPtr( sizeof( *ret ) ); - strncpy( name, moduleInfo[i].filename, max_len ); - name[max_len] = '\0'; + strncpy( name, moduleInfo[i].filename, name_maxlen ); + name[name_maxlen] = '\0'; ret_len += strlen( name ) + 1; #ifdef DEBUG_OUT p = name; diff --git a/bld/trap/lcl/qnx/c/qnxacc.c b/bld/trap/lcl/qnx/c/qnxacc.c index 24f234d8ef..c1092783df 100644 --- a/bld/trap/lcl/qnx/c/qnxacc.c +++ b/bld/trap/lcl/qnx/c/qnxacc.c @@ -1574,7 +1574,7 @@ trap_retval TRAP_CORE( Get_lib_name )( void ) get_lib_name_ret *ret; char *name; char *p; - size_t max_len; + size_t name_maxlen; #if 0 acc = GetInPtr( 0 ); @@ -1601,10 +1601,10 @@ trap_retval TRAP_CORE( Get_lib_name )( void ) ret->mod_handle = 0; return( sizeof( *ret ) ); } - max_len = GetTotalSizeOut() - sizeof( *ret ) - 1; + name_maxlen = GetTotalSizeOut() - sizeof( *ret ) - 1; name = GetOutPtr( sizeof( *ret ) ); - strncpy( name, p, max_len ); - name[max_len] = '\0'; + strncpy( name, p, name_maxlen ); + name[name_maxlen] = '\0'; #else pid_t pid, vid, proc; struct _psinfo info; @@ -1657,20 +1657,20 @@ trap_retval TRAP_CORE( Get_lib_name )( void ) name = GetOutPtr( sizeof( *ret ) ); *name = '\0'; if( p != NULL ) { - max_len = GetTotalSizeOut() - sizeof( *ret ) - 1; + name_maxlen = GetTotalSizeOut() - sizeof( *ret ) - 1; if( p[0] == '/' ) { if( p[1] == '/' ) { for( p += 2; *p >= '0' && *p <= '9'; p++ ) { {} } } - strncpy( name, p, max_len ); + strncpy( name, p, name_maxlen ); } else { - strncpy( name, "/boot/", max_len ); - name[max_len] = '\0'; - strncat( name, p, max_len - strlen( name ) ); + strncpy( name, "/boot/", name_maxlen ); + name[name_maxlen] = '\0'; + strncat( name, p, name_maxlen - strlen( name ) ); } - name[max_len] = '\0'; + name[name_maxlen] = '\0'; } #endif return( sizeof( *ret ) + strlen( name ) + 1 ); diff --git a/bld/trap/lcl/qnx/c/qnxpmd.c b/bld/trap/lcl/qnx/c/qnxpmd.c index f8fe62662e..63f157f141 100644 --- a/bld/trap/lcl/qnx/c/qnxpmd.c +++ b/bld/trap/lcl/qnx/c/qnxpmd.c @@ -763,7 +763,7 @@ trap_retval TRAP_CORE( Get_lib_name )( void ) get_lib_name_ret *ret; char *name; const char *p; - size_t max_len; + size_t name_maxlen; acc = GetInPtr( 0 ); ret = GetOutPtr( 0 ); @@ -791,10 +791,10 @@ trap_retval TRAP_CORE( Get_lib_name )( void ) default: return( sizeof( *ret ) ); } - max_len = GetTotalSizeOut() - sizeof( *ret ) - 1; + name_maxlen = GetTotalSizeOut() - sizeof( *ret ) - 1; name = GetOutPtr( sizeof( *ret ) ); - strncpy( name, p, max_len ); - name[max_len] = '\0'; + strncpy( name, p, name_maxlen ); + name[name_maxlen] = '\0'; PmdInfo.mapping_shared = true; return( sizeof( *ret ) + strlen( name ) + 1 ); } diff --git a/bld/trap/lcl/rdos/c/accmap.c b/bld/trap/lcl/rdos/c/accmap.c index b1f615d4ce..185b033a75 100644 --- a/bld/trap/lcl/rdos/c/accmap.c +++ b/bld/trap/lcl/rdos/c/accmap.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -130,7 +130,7 @@ trap_retval TRAP_CORE( Get_lib_name )( void ) char *name; struct TDebug *obj; struct TDebugModule *mod; - size_t max_len; + size_t name_maxlen; acc = GetInPtr( 0 ); ret = GetOutPtr( 0 ); @@ -143,9 +143,9 @@ trap_retval TRAP_CORE( Get_lib_name )( void ) *name = '\0'; mod = LockModule( obj, ret->mod_handle ); if( mod != NULL ) { - max_len = GetTotalSizeOut() - sizeof( *ret ) - 1; - strncpy( name, mod->ModuleName, max_len ); - name[max_len] = '\0'; + name_maxlen = GetTotalSizeOut() - sizeof( *ret ) - 1; + strncpy( name, mod->ModuleName, name_maxlen ); + name[name_maxlen] = '\0'; } UnlockModule( obj ); return( sizeof( *ret ) + strlen( name ) + 1 ); diff --git a/bld/trap/lcl/rdos/c/debug.c b/bld/trap/lcl/rdos/c/debug.c index 3c25d87330..cfd1b3e97d 100644 --- a/bld/trap/lcl/rdos/c/debug.c +++ b/bld/trap/lcl/rdos/c/debug.c @@ -161,10 +161,10 @@ static void ReadThreadState( struct TDebugThread *obj ) } if( ok ) { - strncpy(str, state.Name, 20); - str[20] = 0; + strncpy( str, state.Name, sizeof( str ) - 1 ); + str[sizeof( str ) - 1] = 0; - for( i = 19; i >= 0; i-- ) { + for( i = sizeof( str ) - 2; i >= 0; i-- ) { if( str[i] == ' ' ) { str[i] = 0; } else { @@ -177,10 +177,10 @@ static void ReadThreadState( struct TDebugThread *obj ) obj->ThreadName = malloc( strlen( str ) + 1 ); strcpy( obj->ThreadName, str ); - strncpy( str, state.List, 20 ); - str[20] = 0; + strncpy( str, state.List, sizeof( str ) - 1 ); + str[sizeof( str ) - 1] = 0; - for( i = 19; i >= 0; i-- ) { + for( i = sizeof( str ) - 2; i >= 0; i-- ) { if( str[i] == ' ' ) { str[i] = 0; } else { diff --git a/bld/trap/lcl/win/c/accmap.c b/bld/trap/lcl/win/c/accmap.c index f8e32660fe..55dba1925a 100644 --- a/bld/trap/lcl/win/c/accmap.c +++ b/bld/trap/lcl/win/c/accmap.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -206,7 +206,7 @@ trap_retval TRAP_CORE( Get_lib_name )( void ) get_lib_name_req *acc; get_lib_name_ret *ret; char *name; - size_t max_len; + size_t name_maxlen; acc = GetInPtr( 0 ); ret = GetOutPtr( 0 ); @@ -225,9 +225,9 @@ trap_retval TRAP_CORE( Get_lib_name )( void ) *name = '\0'; me.dwSize = sizeof( me ); if( ModuleFindHandle( &me, moduleIDs[CurrentModule] ) ) { - max_len = GetTotalSizeOut() - sizeof( *ret ) - 1; - strncpy( name, me.szExePath, max_len ); - name[max_len] = '\0'; + name_maxlen = GetTotalSizeOut() - sizeof( *ret ) - 1; + strncpy( name, me.szExePath, name_maxlen ); + name[name_maxlen] = '\0'; } ret->mod_handle = CurrentModule; Out(( OUT_MAP,"handle=%ld, name=\"%s\"", ret->mod_handle, name )); diff --git a/bld/wprof/c/utils.c b/bld/wprof/c/utils.c index a928d1b42e..2bd9af7745 100644 --- a/bld/wprof/c/utils.c +++ b/bld/wprof/c/utils.c @@ -153,8 +153,8 @@ char *FindHelpFile( char *fullname, const char *help_name ) } size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base_name_len, - const char *defext, char *filename, size_t filename_len ) -/****************************************************************************************/ + const char *defext, char *filename, size_t filename_maxlen ) +/******************************************************************************************/ { char fname[_MAX_PATH2]; char buffer[_MAX_PATH2]; @@ -175,13 +175,13 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base } } len = strlen( p ); - if( filename_len > 0 ) { - filename_len--; - if( filename_len > len ) - filename_len = len; - if( filename_len > 0 ) - strncpy( filename, p, filename_len ); - filename[filename_len] = '\0'; + if( filename_maxlen > 0 ) { + filename_maxlen--; + if( filename_maxlen > len ) + filename_maxlen = len; + if( filename_maxlen > 0 ) + strncpy( filename, p, filename_maxlen ); + filename[filename_maxlen] = '\0'; } return( len ); } diff --git a/bld/wv/c/dbgfile.c b/bld/wv/c/dbgfile.c index 0bc6a1067f..48cd0a35bc 100644 --- a/bld/wv/c/dbgfile.c +++ b/bld/wv/c/dbgfile.c @@ -484,7 +484,7 @@ file_handle LclFileToFullName( const char *name, size_t name_len, char *full ) * */ static file_handle FullPathOpenInternal( const char *name, size_t name_len, - const char *defext, char *filename, size_t filename_len, bool force_local ) + const char *defext, char *filename, size_t filename_maxlen, bool force_local ) { char fname[TXT_LEN]; char *p; @@ -528,7 +528,7 @@ static file_handle FullPathOpenInternal( const char *name, size_t name_len, } *p = NULLCHAR; if( oattrs & OP_REMOTE ) { - RemoteFileToFullName( DIG_FILETYPE_PRS, fname, filename, (trap_elen)filename_len ); + RemoteFileToFullName( DIG_FILETYPE_PRS, fname, filename, (trap_elen)filename_maxlen ); fh = FileOpen( filename, OP_READ | OP_REMOTE ); } else if( has_path ) { StrCopyDst( fname, filename ); @@ -545,14 +545,14 @@ static file_handle FullPathOpenInternal( const char *name, size_t name_len, return( fh ); } -file_handle FullPathOpen( const char *name, size_t name_len, const char *defext, char *filename, size_t filename_len ) +file_handle FullPathOpen( const char *name, size_t name_len, const char *defext, char *filename, size_t filename_maxlen ) { - return( FullPathOpenInternal( name, name_len, defext, filename, filename_len, false ) ); + return( FullPathOpenInternal( name, name_len, defext, filename, filename_maxlen, false ) ); } -file_handle LocalFullPathOpen( const char *name, size_t name_len, const char *defext, char *filename, size_t filename_len ) +file_handle LocalFullPathOpen( const char *name, size_t name_len, const char *defext, char *filename, size_t filename_maxlen ) { - return( FullPathOpenInternal( name, name_len, defext, filename, filename_len, true ) ); + return( FullPathOpenInternal( name, name_len, defext, filename, filename_maxlen, true ) ); } static file_handle PathOpenInternal( const char *name, size_t name_len, const char *defext, bool force_local ) @@ -743,25 +743,25 @@ void PathInit( void ) #endif } -static size_t MakeName( const char *path, const char *name, char *filename, size_t filename_len ) +static size_t MakeName( const char *path, const char *name, char *filename, size_t filename_maxlen ) { char *p; size_t len; - filename_len--; /* save space for terminator */ + filename_maxlen--; /* save space for terminator */ p = filename; len = 0; if( path != NULL ) { - while( len < filename_len && *path != NULLCHAR ) { + while( len < filename_maxlen && *path != NULLCHAR ) { *p++ = *path++; ++len; } - if( len > 0 && len < filename_len && !CHK_PATH_SEP( p[-1], &LclFile ) ) { + if( len > 0 && len < filename_maxlen && !CHK_PATH_SEP( p[-1], &LclFile ) ) { *p++ = LclFile.path_separator[0]; ++len; } } - while( len < filename_len && *name != NULLCHAR ) { + while( len < filename_maxlen && *name != NULLCHAR ) { *p++ = *name++; ++len; } @@ -770,8 +770,8 @@ static size_t MakeName( const char *path, const char *name, char *filename, size } size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base_name_len, - const char *defext, char *filename, size_t filename_len ) -/****************************************************************************************/ + const char *defext, char *filename, size_t filename_maxlen ) +/******************************************************************************************/ { char buffer[TXT_LEN]; char fname[TXT_LEN]; @@ -805,13 +805,13 @@ size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base } } len = strlen( p ); - if( filename_len > 0 ) { - filename_len--; - if( filename_len > len ) - filename_len = len; - if( filename_len > 0 ) - strncpy( filename, p, filename_len ); - filename[filename_len] = NULLCHAR; + if( filename_maxlen > 0 ) { + filename_maxlen--; + if( filename_maxlen > len ) + filename_maxlen = len; + if( filename_maxlen > 0 ) + strncpy( filename, p, filename_maxlen ); + filename[filename_maxlen] = NULLCHAR; } return( len ); } diff --git a/bld/wv/h/dbgio.h b/bld/wv/h/dbgio.h index ad924d317b..c86907d01d 100644 --- a/bld/wv/h/dbgio.h +++ b/bld/wv/h/dbgio.h @@ -89,8 +89,8 @@ extern const char *RealFName( char const *name, obj_attrs *oattrs ); extern bool IsAbsolutePath( const char *path ); extern const char *ExtPointer( char const *path, obj_attrs oattrs ); extern file_handle LclFileToFullName( const char *name, size_t name_len, char *full ); -extern file_handle FullPathOpen( const char *name, size_t name_len, const char *defext, char *filename, size_t filename_len ); -extern file_handle LocalFullPathOpen( const char *name, size_t name_len, const char *defext, char *filename, size_t filename_len ); +extern file_handle FullPathOpen( const char *name, size_t name_len, const char *defext, char *filename, size_t filename_maxlen ); +extern file_handle LocalFullPathOpen( const char *name, size_t name_len, const char *defext, char *filename, size_t filename_maxlen ); extern file_handle PathOpen( const char *name, size_t name_len, const char *defext ); extern file_handle LocalPathOpen( const char *name, size_t name_len, const char *defext ); From 8b49f16964aa2da046cf33e5fb7a091de4f43530 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Mon, 4 Sep 2023 03:17:57 +0200 Subject: [PATCH 086/258] fix for issue #1127 as usual Microsoft have its own standards POSIX return value of inet_addr for invalid value is -1 Windows Winsocks return value of inet_addr for invalid value is 0 (some Windows versions also use -1 in some situation) --- bld/trap/tcp/c/tcplink.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/bld/trap/tcp/c/tcplink.c b/bld/trap/tcp/c/tcplink.c index 456f754d87..18a77f7208 100644 --- a/bld/trap/tcp/c/tcplink.c +++ b/bld/trap/tcp/c/tcplink.c @@ -125,10 +125,13 @@ #define _DBG_ERROR( x ) #endif -#define DEFAULT_PORT 0x0DEB /* 3563 */ +#define DEFAULT_PORT 0x0DEB /* 3563 */ + +#ifndef INADDR_ANY +#define INADDR_ANY (unsigned_32)0 +#endif #define OW_INADDR_LOOPBACK 0x7F000001UL -#define OW_INADDR_INVALID ((unsigned_32)-1) #if defined( __RDOS__ ) #define INVALID_SOCKET 0 @@ -136,23 +139,27 @@ #define IS_RET_OK(x) (x!=0) #define trp_socket int #define soclose( s ) RdosCloseTcpConnection( s ) + #define INVALID_INADDR(x) (x==-1) #elif defined( __NT__ ) || defined( __WINDOWS__ ) #define IS_VALID_SOCKET(x) (x!=INVALID_SOCKET) #define IS_RET_OK(x) (x!=SOCKET_ERROR) #define trp_socket SOCKET #define trp_socklen int #define soclose( s ) closesocket( s ) + #define INVALID_INADDR(x) (x==0 || x==-1) #elif defined( __DOS__ ) #define IS_VALID_SOCKET(x) (x>=0) #define IS_RET_OK(x) (x!=-1) #define trp_socket int #define trp_socklen int + #define INVALID_INADDR(x) (x==0) #elif defined( __OS2__ ) #define INVALID_SOCKET -1 #define IS_VALID_SOCKET(x) (x>=0) #define IS_RET_OK(x) (x!=-1) #define trp_socket int #define trp_socklen int + #define INVALID_INADDR(x) (x==-1) #elif defined( __NETWARE__ ) #define INVALID_SOCKET -1 #define IS_VALID_SOCKET(x) (x>=0) @@ -160,6 +167,7 @@ #define trp_socket int #define trp_socklen int #define soclose( s ) close( s ) + #define INVALID_INADDR(x) (x==-1) #else /* POSIX */ #define INVALID_SOCKET -1 #define IS_VALID_SOCKET(x) (x>=0) @@ -167,11 +175,11 @@ #define trp_socket int #define trp_socklen socklen_t #define soclose( s ) close( s ) + #define INVALID_INADDR(x) (x==-1) #endif - #if !defined( __NT__ ) && !defined( __WINDOWS__ ) - typedef struct sockaddr *LPSOCKADDR; +typedef struct sockaddr *LPSOCKADDR; #endif unsigned short trap_port; @@ -447,7 +455,7 @@ static unsigned_32 get_addr( const char *p ) unsigned_32 addr; addr = inet_addr( p ); - if( addr == OW_INADDR_INVALID ) { + if( INVALID_INADDR( addr ) ) { struct hostent *hp; /* @@ -458,7 +466,7 @@ static unsigned_32 get_addr( const char *p ) addr = 0; memcpy( &addr, hp->h_addr, hp->h_length ); } else { - addr = OW_INADDR_INVALID; + addr = INADDR_NONE; /* POSIX value, not Microsoft */ } } return( addr ); @@ -472,7 +480,7 @@ const char *RemoteLinkGet( char *parms, size_t len ) { /* unused parameters */ (void)len; - sprintf( parms, "%u", trap_port ); + sprintf( parms, "%u", (unsigned)trap_port ); return( NULL ); } #endif @@ -509,7 +517,7 @@ const char *RemoteLinkSet( const char *parms ) trap_addr = OW_INADDR_LOOPBACK; #else trap_addr = get_addr( buff ); - if( trap_addr == OW_INADDR_INVALID ) { + if( trap_addr == INADDR_NONE ) { trap_addr = OW_INADDR_LOOPBACK; // return( TRP_ERR_unknown_host ); } @@ -635,7 +643,9 @@ const char *RemoteLink( const char *parms, bool server ) socket_address.sin_port = htons( trap_port ); #endif #endif + /* unused parameters */ (void)server; + return( NULL ); } From 8cda92ee92433ab04c9cf09252a0c19fe4dc2ada Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Mon, 4 Sep 2023 13:12:09 +0200 Subject: [PATCH 087/258] correct mistake in internet address byte order --- bld/trap/tcp/c/tcplink.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/bld/trap/tcp/c/tcplink.c b/bld/trap/tcp/c/tcplink.c index 18a77f7208..ba9f0991ba 100644 --- a/bld/trap/tcp/c/tcplink.c +++ b/bld/trap/tcp/c/tcplink.c @@ -131,7 +131,7 @@ #define INADDR_ANY (unsigned_32)0 #endif -#define OW_INADDR_LOOPBACK 0x7F000001UL +#define OW_INADDR_LOOPBACK htonl( 0x7F000001UL ) #if defined( __RDOS__ ) #define INVALID_SOCKET 0 @@ -182,9 +182,9 @@ typedef struct sockaddr *LPSOCKADDR; #endif -unsigned short trap_port; +unsigned short trap_port; /* host byte order */ #ifndef SERVER -unsigned_32 trap_addr; +unsigned_32 trap_addr; /* network byte order */ #endif #ifdef __RDOS__ @@ -429,6 +429,9 @@ void RemoteDisco( void ) } static unsigned short get_port( const char *p ) +/******************************************* + * return port value in host byte order + */ { unsigned short port; #ifndef __RDOS__ @@ -451,6 +454,9 @@ static unsigned short get_port( const char *p ) #ifndef SERVER #ifndef __RDOS__ static unsigned_32 get_addr( const char *p ) +/******************************************* + * return address value in network byte order + */ { unsigned_32 addr; @@ -466,7 +472,7 @@ static unsigned_32 get_addr( const char *p ) addr = 0; memcpy( &addr, hp->h_addr, hp->h_length ); } else { - addr = INADDR_NONE; /* POSIX value, not Microsoft */ + addr = INADDR_NONE; } } return( addr ); @@ -563,7 +569,7 @@ const char *RemoteLink( const char *parms, bool server ) /* Name socket using wildcards */ socket_address.sin_family = AF_INET; - socket_address.sin_addr.s_addr = htonl( INADDR_ANY ); + socket_address.sin_addr.s_addr = INADDR_ANY; socket_address.sin_port = htons( trap_port ); if( bind( control_socket, (LPSOCKADDR)&socket_address, sizeof( socket_address ) ) ) { return( TRP_ERR_unable_to_bind_stream_socket ); @@ -639,7 +645,7 @@ const char *RemoteLink( const char *parms, bool server ) * Setup for socket connect using parms specified by command line. */ socket_address.sin_family = AF_INET; - socket_address.sin_addr.s_addr = htonl( trap_addr ); + socket_address.sin_addr.s_addr = trap_addr; socket_address.sin_port = htons( trap_port ); #endif #endif From 3101fbad635eca2f2aa93902aeb689a2331f9818 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Wed, 6 Sep 2023 09:28:27 +0200 Subject: [PATCH 088/258] rename file to enable interface list code separation --- bld/trap/tcp/c/tcplink.c | 2 +- bld/trap/tcp/h/{ifi.h => tcpifi.h} | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) rename bld/trap/tcp/h/{ifi.h => tcpifi.h} (96%) diff --git a/bld/trap/tcp/c/tcplink.c b/bld/trap/tcp/c/tcplink.c index ba9f0991ba..7ad4eefc01 100644 --- a/bld/trap/tcp/c/tcplink.c +++ b/bld/trap/tcp/c/tcplink.c @@ -109,7 +109,7 @@ #endif #ifdef LIST_INTERFACES // TODO: need rework to POSIX if_nameindex in -#include "ifi.h" +#include "tcpifi.h" #endif diff --git a/bld/trap/tcp/h/ifi.h b/bld/trap/tcp/h/tcpifi.h similarity index 96% rename from bld/trap/tcp/h/ifi.h rename to bld/trap/tcp/h/tcpifi.h index c7f02e70b3..6d44228ab6 100644 --- a/bld/trap/tcp/h/ifi.h +++ b/bld/trap/tcp/h/tcpifi.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== From c042104ced8980506117900c97162680ad87fee1 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Wed, 6 Sep 2023 10:48:19 +0200 Subject: [PATCH 089/258] separate interface list code to tcpifi.c source file --- bld/trap/tcp/c/tcpifi.c | 224 ++++++++++++++++++++++++++++++++ bld/trap/tcp/c/tcplink.c | 187 +------------------------- bld/trap/tcp/dos.srv/makefile | 1 + bld/trap/tcp/h/tcpifi.h | 31 ++--- bld/trap/tcp/os2.srv/makefile | 3 +- bld/trap/tcp/os2v2.srv/makefile | 2 + 6 files changed, 242 insertions(+), 206 deletions(-) create mode 100644 bld/trap/tcp/c/tcpifi.c diff --git a/bld/trap/tcp/c/tcpifi.c b/bld/trap/tcp/c/tcpifi.c new file mode 100644 index 0000000000..cf35db25ef --- /dev/null +++ b/bld/trap/tcp/c/tcpifi.c @@ -0,0 +1,224 @@ +/**************************************************************************** +* +* Open Watcom Project +* +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. +* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. +* +* ======================================================================== +* +* This file contains Original Code and/or Modifications of Original +* Code as defined in and that are subject to the Sybase Open Watcom +* Public License version 1.0 (the 'License'). You may not use this file +* except in compliance with the License. BY USING THIS FILE YOU AGREE TO +* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is +* provided with the Original Code and Modifications, and is also +* available at www.sybase.com/developer/opensource. +* +* The Original Code and all software distributed under the License are +* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM +* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR +* NON-INFRINGEMENT. Please see the License for the specific language +* governing rights and limitations under the License. +* +* ======================================================================== +* +* Description: implementation of function for list IP interfaces in a machine. +* +****************************************************************************/ + + +#define LIST_INTERFACES + +#if defined( SERVER ) && ( defined( __OS2__ ) || defined( __DOS__ ) ) + +#include +#include +#include +#if defined( __DOS__ ) + #define BSD + #include + #include +#elif defined( __OS2__ ) + #if defined( _M_I86 ) + #define OS2 + #define _TCP_ENTRY __cdecl __far + #define BSD_SELECT + #include + #include + #else + #include + #include + #endif +#endif +#include +#include +#include +#include "trperr.h" +#include "servio.h" +#include "tcpifi.h" + + +/* + * Functions to manage IP interface information lists. On multi-homed hosts, + * determining the IP address the TCP debug link responds on is not entirely + * straightforward. + * + * Actual implementation - feel free to port to further OSes + * + * TODO: rework to use POSIX if_nameindex in + */ + +#define IFI_NAME 16 /* same as IFNAMSIZ in */ + +#define IFI_ALIAS 1 /* ifi_addr is an alias */ +#define IFI_LOOP 2 /* corresponds to IFF_LOOPBACK */ + +#if defined( __DOS__ ) + #define w_ioctl ioctlsocket + #define trp_socket int +#elif defined( __OS2__ ) + #define w_ioctl ioctl + #define trp_socket int +#endif + +struct ifi_info { + char ifi_name[IFI_NAME]; /* interface name, null terminated */ + short ifi_flags; /* IFF_xxx constants from */ + short flags; /* our own IFI_xxx flags */ + struct sockaddr *ifi_addr; /* primary address */ + struct ifi_info *ifi_next; /* next of these structures */ +}; + +static struct ifi_info *get_ifi_info( int family, int doaliases ) +{ + struct ifi_info *ifi, *ifihead, **ifipnext; + int len, lastlen, flags, myflags; + char *ptr, *buf, lastname[IFNAMSIZ], *cptr; + struct ifconf ifc; + struct ifreq *ifr, ifrcopy; + struct sockaddr_in *sinptr; + trp_socket sockfd; + + sockfd = socket( AF_INET, SOCK_DGRAM, 0 ); + + lastlen = 0; + len = 20 * sizeof( struct ifreq ); /* initial buffer size guess */ + for( ;; ) { + buf = malloc( len ); + ifc.ifc_len = len; + ifc.ifc_buf = buf; + if( w_ioctl( sockfd, SIOCGIFCONF, (char *)&ifc ) >= 0 ) { + if( ifc.ifc_len == lastlen ) + break; /* success, len has not changed */ + lastlen = ifc.ifc_len; + } + len += 10 * sizeof( struct ifreq ); /* increment */ + free( buf ); + } + ifihead = NULL; + ifipnext = &ifihead; + lastname[0] = 0; + + for( ptr = buf; ptr < buf + ifc.ifc_len; ) { + ifr = (struct ifreq *)ptr; + +#if defined( __DOS__ ) + len = sizeof( struct sockaddr ); +#elif defined( __OS2__ ) + len = sizeof( struct sockaddr ); + if( len < ifr->ifr_addr.sa_len ) { + len = ifr->ifr_addr.sa_len ; + } +#endif + ptr += sizeof( ifr->ifr_name ) + len; /* for next one in buffer */ + + if( ifr->ifr_addr.sa_family != family ) + continue; /* ignore if not desired address family */ + + myflags = 0; + if(( cptr = strchr( ifr->ifr_name, ':' )) != NULL ) + *cptr = 0; /* replace colon will null */ + if( strncmp( lastname, ifr->ifr_name, IFNAMSIZ ) == 0 ) { + if( doaliases == 0 ) + continue; /* already processed this interface */ + myflags = IFI_ALIAS; + } + memcpy( lastname, ifr->ifr_name, IFNAMSIZ ); + + ifrcopy = *ifr; + w_ioctl( sockfd, SIOCGIFFLAGS, (char *)&ifrcopy ); + flags = ifrcopy.ifr_flags; + if( !( flags & IFF_UP ) ) + continue; /* ignore if interface not up */ + + ifi = calloc( 1, sizeof( struct ifi_info ) ); + *ifipnext = ifi; /* prev points to this new one */ + ifipnext = &ifi->ifi_next; /* pointer to next one goes here */ + + if( flags & IFF_LOOPBACK ) + myflags |= IFI_LOOP; + + ifi->ifi_flags = flags; /* IFF_xxx values */ + ifi->flags = myflags; /* IFI_xxx values */ + memcpy( ifi->ifi_name, ifr->ifr_name, IFI_NAME ); + ifi->ifi_name[IFI_NAME - 1] = '\0'; + + switch( ifr->ifr_addr.sa_family ) { + case AF_INET: + sinptr = (struct sockaddr_in *)&ifr->ifr_addr; + if( ifi->ifi_addr == NULL ) { + ifi->ifi_addr = calloc( 1, sizeof( struct sockaddr_in ) ); + memcpy( ifi->ifi_addr, sinptr, sizeof( struct sockaddr_in ) ); + } + break; + + default: + break; + } + } + free( buf ); + return( ifihead ); /* pointer to first structure in linked list */ +} + +static void free_ifi_info( struct ifi_info *ifihead ) +{ + struct ifi_info *ifi, *ifinext; + + for( ifi = ifihead; ifi != NULL; ifi = ifinext ) { + if( ifi->ifi_addr != NULL ) + free( ifi->ifi_addr ); + ifinext = ifi->ifi_next; /* can't fetch ifi_next after free() */ + free( ifi ); /* the ifi_info{} itself */ + } +} + +void list_interfaces( void ) +/*************************** + * Find and print TCP/IP interface addresses (IP V4) + * ignore aliases and loopback + */ +{ + struct ifi_info *ifi, *ifihead; + struct sockaddr *sa; + char buff[128]; + + ifihead = get_ifi_info( AF_INET, false ); + for( ifi = ifihead; ifi != NULL; ifi = ifi->ifi_next ) { + /* + * Ignore loopback interfaces + */ + if( ifi->flags & IFI_LOOP ) + continue; + if( (sa = ifi->ifi_addr) != NULL ) { + sprintf( buff, "%s%s", TRP_TCP_ip_address, + inet_ntoa( ((struct sockaddr_in *)sa)->sin_addr ) ); + ServMessage( buff ); + } + } + free_ifi_info( ifihead ); +} + +#endif diff --git a/bld/trap/tcp/c/tcplink.c b/bld/trap/tcp/c/tcplink.c index 7ad4eefc01..58d446d54a 100644 --- a/bld/trap/tcp/c/tcplink.c +++ b/bld/trap/tcp/c/tcplink.c @@ -108,7 +108,6 @@ #include "servio.h" #endif #ifdef LIST_INTERFACES -// TODO: need rework to POSIX if_nameindex in #include "tcpifi.h" #endif @@ -231,11 +230,6 @@ static int send( int handle, const void *buf, int size, int timeout ) #else static trp_socket control_socket; #endif -#ifdef LIST_INTERFACES -// TODO: need rework to POSIX if_nameindex in - static struct ifi_info *get_ifi_info( int, int ); - static void free_ifi_info( struct ifi_info * ); -#endif #endif static trp_socket data_socket = INVALID_SOCKET; @@ -588,29 +582,7 @@ const char *RemoteLink( const char *parms, bool server ) _DBG_NET(("\r\n")); #ifdef LIST_INTERFACES - /* - * TODO: need rework to POSIX if_nameindex in - * Find and print TCP/IP interface addresses, ignore aliases - */ - { - struct ifi_info *ifi, *ifihead; - struct sockaddr *sa; - - ifihead = get_ifi_info( AF_INET, false ); - for( ifi = ifihead; ifi != NULL; ifi = ifi->ifi_next ) { - /* - * Ignore loopback interfaces - */ - if( ifi->flags & IFI_LOOP ) - continue; - if( (sa = ifi->ifi_addr) != NULL ) { - sprintf( buff, "%s%s", TRP_TCP_ip_address, - inet_ntoa( ((struct sockaddr_in *)sa)->sin_addr ) ); - ServMessage( buff ); - } - } - free_ifi_info( ifihead ); - } + list_interfaces(); #endif #endif _DBG_NET(("Start accepting connections\r\n")); @@ -682,160 +654,3 @@ void RemoteUnLink( void ) sock_exit(); #endif } - -#ifdef LIST_INTERFACES -/* - * TODO: need rework to POSIX if_nameindex in - */ -#ifndef __RDOS__ - - #ifdef SERVER - /* - * Functions to manage IP interface information lists. On multi-homed hosts, - * determining the IP address the TCP debug link responds on is not entirely - * straightforward. - */ - #if defined( __OS2__ ) || defined( __DOS__ ) - /* - * Actual implementation - feel free to port to further OSes - * - * Sort out implementation differences. - */ - #if defined( __DOS__ ) - #define w_ioctl ioctlsocket - #define HAVE_SA_LEN false - #elif defined( __OS2__ ) - #define w_ioctl ioctl - #define HAVE_SA_LEN true - #endif - -static struct ifi_info *get_ifi_info( int family, int doaliases ) -{ - struct ifi_info *ifi, *ifihead, **ifipnext; - int len, lastlen, flags, myflags; - char *ptr, *buf, lastname[IFNAMSIZ], *cptr; - struct ifconf ifc; - struct ifreq *ifr, ifrcopy; - struct sockaddr_in *sinptr; - trp_socket sockfd; - - sockfd = socket( AF_INET, SOCK_DGRAM, 0 ); - - lastlen = 0; - len = 20 * sizeof( struct ifreq ); /* initial buffer size guess */ - for( ;; ) { - buf = malloc( len ); - ifc.ifc_len = len; - ifc.ifc_buf = buf; - if( w_ioctl( sockfd, SIOCGIFCONF, (char *)&ifc ) >= 0 ) { - if( ifc.ifc_len == lastlen ) - break; /* success, len has not changed */ - lastlen = ifc.ifc_len; - } - len += 10 * sizeof( struct ifreq ); /* increment */ - free( buf ); - } - ifihead = NULL; - ifipnext = &ifihead; - lastname[0] = 0; - - for( ptr = buf; ptr < buf + ifc.ifc_len; ) { - ifr = (struct ifreq *)ptr; - - #if HAVE_SA_LEN - len = sizeof( struct sockaddr ); - if( len < ifr->ifr_addr.sa_len ) { - len = ifr->ifr_addr.sa_len ; - } - #else - len = sizeof( struct sockaddr ); - #endif - ptr += sizeof( ifr->ifr_name ) + len; /* for next one in buffer */ - - if( ifr->ifr_addr.sa_family != family ) - continue; /* ignore if not desired address family */ - - myflags = 0; - if(( cptr = strchr( ifr->ifr_name, ':' )) != NULL ) - *cptr = 0; /* replace colon will null */ - if( strncmp( lastname, ifr->ifr_name, IFNAMSIZ ) == 0 ) { - if( doaliases == 0 ) - continue; /* already processed this interface */ - myflags = IFI_ALIAS; - } - memcpy( lastname, ifr->ifr_name, IFNAMSIZ ); - - ifrcopy = *ifr; - w_ioctl( sockfd, SIOCGIFFLAGS, (char *)&ifrcopy ); - flags = ifrcopy.ifr_flags; - if( !( flags & IFF_UP ) ) - continue; /* ignore if interface not up */ - - ifi = calloc( 1, sizeof( struct ifi_info ) ); - *ifipnext = ifi; /* prev points to this new one */ - ifipnext = &ifi->ifi_next; /* pointer to next one goes here */ - - if( flags & IFF_LOOPBACK ) - myflags |= IFI_LOOP; - - ifi->ifi_flags = flags; /* IFF_xxx values */ - ifi->flags = myflags; /* IFI_xxx values */ - memcpy( ifi->ifi_name, ifr->ifr_name, IFI_NAME ); - ifi->ifi_name[IFI_NAME - 1] = '\0'; - - switch( ifr->ifr_addr.sa_family ) { - case AF_INET: - sinptr = (struct sockaddr_in *)&ifr->ifr_addr; - if( ifi->ifi_addr == NULL ) { - ifi->ifi_addr = calloc( 1, sizeof( struct sockaddr_in ) ); - memcpy( ifi->ifi_addr, sinptr, sizeof( struct sockaddr_in ) ); - } - break; - - default: - break; - } - } - free( buf ); - return( ifihead ); /* pointer to first structure in linked list */ -} - -static void free_ifi_info( struct ifi_info *ifihead ) -{ - struct ifi_info *ifi, *ifinext; - - for( ifi = ifihead; ifi != NULL; ifi = ifinext ) { - if( ifi->ifi_addr != NULL ) - free( ifi->ifi_addr ); - ifinext = ifi->ifi_next; /* can't fetch ifi_next after free() */ - free( ifi ); /* the ifi_info{} itself */ - } -} - - # else - -/* - * Stubbed out - */ -static struct ifi_info *get_ifi_info( int family, int doaliases ) -{ - /* unused parameters */ (void)family; (void)doaliases; - - return( NULL ); -} - -static void free_ifi_info( struct ifi_info *ifihead ) -{ - /* unused parameters */ (void)ifihead; -} - - #endif - - #endif - -#endif - -/* - * TODO: need rework to POSIX if_nameindex in - */ -#endif diff --git a/bld/trap/tcp/dos.srv/makefile b/bld/trap/tcp/dos.srv/makefile index 07c06b9243..d5ab06fd2e 100644 --- a/bld/trap/tcp/dos.srv/makefile +++ b/bld/trap/tcp/dos.srv/makefile @@ -17,5 +17,6 @@ extra_incs = -I"$(wattcp_dir)/inc" extra_cflags = -zm extra_linker = op eliminate extra_libs = $(wattcp_dir)/dosi86/wattcpl.lib +extra_objs = tcpifi.obj !include $(trap_dir)/master.mif diff --git a/bld/trap/tcp/h/tcpifi.h b/bld/trap/tcp/h/tcpifi.h index 6d44228ab6..0d88ed4185 100644 --- a/bld/trap/tcp/h/tcpifi.h +++ b/bld/trap/tcp/h/tcpifi.h @@ -25,28 +25,21 @@ * * ======================================================================== * -* Description: Structures and function prototypes for querying IP -* interfaces in a machine. +* Description: function prototype for list IP interfaces in a machine. * ****************************************************************************/ -#ifndef __IFI_H__ -#define __IFI_H__ +#ifndef __TCPIFI_H__ +#define __TCPIFI_H__ -#define IFI_NAME 16 /* same as IFNAMSIZ in */ - -struct ifi_info { - char ifi_name[IFI_NAME]; /* interface name, null terminated */ - short ifi_flags; /* IFF_xxx constants from */ - short flags; /* our own IFI_xxx flags */ - struct sockaddr *ifi_addr; /* primary address */ - struct ifi_info *ifi_next; /* next of these structures */ -}; - -#define IFI_ALIAS 1 /* ifi_addr is an alias */ -#define IFI_LOOP 2 /* corresponds to IFF_LOOPBACK */ - -//struct ifi_info *get_ifi_info( int, int ); -//void free_ifi_info( struct ifi_info * ); +#ifdef LIST_INTERFACES + #if defined( SERVER ) && ( defined( __DOS__ ) || defined( __OS2__ ) ) + extern void list_interfaces( void ); + #else + #define list_interfaces() + #endif +#else + #define list_interfaces() +#endif #endif diff --git a/bld/trap/tcp/os2.srv/makefile b/bld/trap/tcp/os2.srv/makefile index 37cc6a21fe..8bfafb5a0a 100644 --- a/bld/trap/tcp/os2.srv/makefile +++ b/bld/trap/tcp/os2.srv/makefile @@ -11,7 +11,8 @@ srv = tcp which = SERVER remote_link = 1 +inc_dirs = -I"$(watcom_dir)/os220_h/tcpip" extra_libs = $(watcom_dir)/lib/tcpipdll.lib -inc_dirs = -I"$(watcom_dir)/os220_h/tcpip" +extra_objs = tcpifi.obj !include $(trap_dir)/master.mif diff --git a/bld/trap/tcp/os2v2.srv/makefile b/bld/trap/tcp/os2v2.srv/makefile index 88da7c5e50..4b8a90313f 100644 --- a/bld/trap/tcp/os2v2.srv/makefile +++ b/bld/trap/tcp/os2v2.srv/makefile @@ -11,4 +11,6 @@ srv = tcp which = SERVER remote_link = 1 +extra_objs = tcpifi.obj + !include $(trap_dir)/master.mif From 3adcbeaeed4af87dd44c2218c2d3056f6ddaff99 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Wed, 6 Sep 2023 13:57:18 +0200 Subject: [PATCH 090/258] cleanup tcp trap code --- bld/trap/tcp/c/tcplink.c | 184 +++++++++++++++++---------------------- 1 file changed, 82 insertions(+), 102 deletions(-) diff --git a/bld/trap/tcp/c/tcplink.c b/bld/trap/tcp/c/tcplink.c index 58d446d54a..c8c28d113b 100644 --- a/bld/trap/tcp/c/tcplink.c +++ b/bld/trap/tcp/c/tcplink.c @@ -32,12 +32,6 @@ #define LIST_INTERFACES -#if defined( __OS2__ ) && defined( _M_I86 ) -#define OS2 -#define _TCP_ENTRY __cdecl __far -#define BSD_SELECT -#endif - #if defined( __NETWARE__ ) #define __FUNCTION_DATA_ACCESS #endif @@ -54,13 +48,37 @@ #elif defined( __NETWARE__ ) #include #include -#else - #if defined( __OS2__ ) - #include - #else +#elif defined( __OS2__ ) + #if defined( _M_I86 ) + #define OS2 + #define _TCP_ENTRY __cdecl __far + #define BSD_SELECT + #include + #include + #else + #include + #include + #endif + #include + #include + #include + #include + #include + #include +#elif defined( __DOS__ ) + #define BSD + #include + #include + #include + #include + #include + #include +#else /* POSIX */ #include - #endif #include + #if defined( __UNIX__ ) + #include + #endif #include #if !defined( __LINUX__ ) #include @@ -69,24 +87,6 @@ #include #include #include - #if defined( __OS2__ ) - #if defined( _M_I86 ) - #include - #else - #include - #endif - #include - #include - #elif defined( __DOS__ ) - #include - #define BSD /* To get the right macros from wattcp headers. */ - #include - #undef BSD - #include - #include - #elif defined( __UNIX__ ) - #include - #endif #endif #include "watcom.h" @@ -124,13 +124,9 @@ #define _DBG_ERROR( x ) #endif -#define DEFAULT_PORT 0x0DEB /* 3563 */ - -#ifndef INADDR_ANY -#define INADDR_ANY (unsigned_32)0 -#endif - -#define OW_INADDR_LOOPBACK htonl( 0x7F000001UL ) +#define DEFAULT_PORT 0x0DEB /* 3563 */ +#define OW_INADDR_ANY 0xFFFFFFFFUL /* 255.255.255.255 */ +#define OW_INADDR_LOOPBACK htonl( 0x7F000001UL ) /* 127.0.0.1 */ #if defined( __RDOS__ ) #define INVALID_SOCKET 0 @@ -181,14 +177,26 @@ typedef struct sockaddr *LPSOCKADDR; #endif -unsigned short trap_port; /* host byte order */ -#ifndef SERVER -unsigned_32 trap_addr; /* network byte order */ +static unsigned short trap_port; /* host byte order */ +static trp_socket data_socket = INVALID_SOCKET; +#ifdef __RDOS__ +#else +static struct sockaddr_in socket_address; +#endif +#ifdef SERVER + #ifdef __RDOS__ +static int listen_handle = 0; +static int wait_handle = 0; + #else +static trp_socket control_socket; + #endif +#else +static unsigned_32 trap_addr; /* network byte order */ #endif #ifdef __RDOS__ - #define SOCKET_BUFFER 0x7000 +#define SOCKET_BUFFER 0x7000 static int recv( int handle, void *buf, int size, int timeout ) { @@ -213,44 +221,25 @@ static int send( int handle, const void *buf, int size, int timeout ) return( count ); } -#else - - #ifndef IPPROTO_TCP - #define IPPROTO_TCP 6 - #endif - - static struct sockaddr_in socket_address; - #endif #ifdef SERVER - #ifdef __RDOS__ - static int listen_handle = 0; - static int wait_handle = 0; - #else - static trp_socket control_socket; - #endif -#endif - -static trp_socket data_socket = INVALID_SOCKET; - -#if !defined( SERVER ) +#else static bool terminate_connection( void ) { -#ifdef __RDOS__ + #ifdef __RDOS__ RdosPushTcpConnection( data_socket ); -#else + #else struct linger linger; linger.l_onoff = 1; linger.l_linger = 0; setsockopt( data_socket, (int)SOL_SOCKET, SO_LINGER, (void*)&linger, sizeof( linger ) ); -#endif + #endif soclose( data_socket ); data_socket = INVALID_SOCKET; return( true ); } - #endif #ifdef __RDOS__ @@ -336,7 +325,9 @@ trap_retval RemotePut( void *data, trap_elen len ) return( REQUEST_FAILED ); } -#ifndef __RDOS__ +#ifdef __RDOS__ + +#else static int get_proto( const char *p ) { @@ -423,12 +414,13 @@ void RemoteDisco( void ) } static unsigned short get_port( const char *p ) -/******************************************* +/********************************************** * return port value in host byte order */ { unsigned short port; -#ifndef __RDOS__ +#ifdef __RDOS__ +#else struct servent *sp; sp = getservbyname( ( *p == '\0' ) ? "tcplink" : p, "tcp" ); @@ -446,7 +438,6 @@ static unsigned short get_port( const char *p ) } #ifndef SERVER -#ifndef __RDOS__ static unsigned_32 get_addr( const char *p ) /******************************************* * return address value in network byte order @@ -454,13 +445,14 @@ static unsigned_32 get_addr( const char *p ) { unsigned_32 addr; + /* + * TCP/IP gethostbyname OS/2 does not handle numeric addresses + * so a numeric format is tried first + */ addr = inet_addr( p ); if( INVALID_INADDR( addr ) ) { struct hostent *hp; - /* - * OS/2's TCP/IP gethostbyname doesn't handle numeric addresses - */ hp = gethostbyname( p ); if( hp != NULL ) { addr = 0; @@ -472,7 +464,6 @@ static unsigned_32 get_addr( const char *p ) return( addr ); } #endif -#endif #ifdef SERVER #ifdef TRAPGUI @@ -513,15 +504,11 @@ const char *RemoteLinkSet( const char *parms ) if( trap_port == 0 ) { return( TRP_ERR_unable_to_parse_port_number ); } - #ifdef __RDOS__ - trap_addr = OW_INADDR_LOOPBACK; - #else trap_addr = get_addr( buff ); if( trap_addr == INADDR_NONE ) { trap_addr = OW_INADDR_LOOPBACK; // return( TRP_ERR_unknown_host ); } - #endif #endif return( NULL ); } @@ -529,12 +516,16 @@ const char *RemoteLinkSet( const char *parms ) const char *RemoteLink( const char *parms, bool server ) { #ifdef SERVER - #if !defined( __RDOS__ ) + #ifdef __RDOS__ + #else trp_socklen length; char buff[128]; #endif _DBG_NET(("SERVER: Calling into RemoteLink\r\n")); +#endif + + /* unused parameters */ (void)server; if( parms != NULL ) { parms = RemoteLinkSet( parms ); @@ -542,7 +533,9 @@ const char *RemoteLink( const char *parms, bool server ) return( parms ); } } - #if defined(__NT__) || defined(__WINDOWS__) + #if defined( __RDOS__ ) + /* no initialization */ + #elif defined(__NT__) || defined(__WINDOWS__) { WSADATA data; @@ -550,20 +543,23 @@ const char *RemoteLink( const char *parms, bool server ) return( TRP_ERR_unable_to_initialize_TCPIP ); } } + #else + /* no initialization */ #endif +#ifdef SERVER #ifdef __RDOS__ - wait_handle = RdosCreateWait( ); + wait_handle = RdosCreateWait(); listen_handle = RdosCreateTcpListen( trap_port, 1, SOCKET_BUFFER ); - RdosAddWaitForTcpListen( wait_handle, listen_handle, (int)(&listen_handle) ); + RdosAddWaitForTcpListen( wait_handle, listen_handle, (int)&listen_handle ); #else - control_socket = socket(AF_INET, SOCK_STREAM, 0); + control_socket = socket( AF_INET, SOCK_STREAM, 0 ); if( !IS_VALID_SOCKET( control_socket ) ) { return( TRP_ERR_unable_to_open_stream_socket ); } /* Name socket using wildcards */ socket_address.sin_family = AF_INET; - socket_address.sin_addr.s_addr = INADDR_ANY; + socket_address.sin_addr.s_addr = OW_INADDR_ANY; socket_address.sin_port = htons( trap_port ); if( bind( control_socket, (LPSOCKADDR)&socket_address, sizeof( socket_address ) ) ) { return( TRP_ERR_unable_to_bind_stream_socket ); @@ -589,30 +585,16 @@ const char *RemoteLink( const char *parms, bool server ) /* * Start accepting connections */ - #ifndef __RDOS__ + #ifdef __RDOS__ + #else listen( control_socket, 5 ); #endif #else - if( parms != NULL ) { - parms = RemoteLinkSet( parms ); - if( parms != NULL ) { - return( parms ); - } - } #ifdef __RDOS__ /* * TODO: handle connect */ #else - #if defined(__NT__) || defined(__WINDOWS__) - { - WSADATA data; - - if( WSAStartup( 0x101, &data ) != 0 ) { - return( TRP_ERR_unable_to_initialize_TCPIP ); - } - } - #endif /* * Setup for socket connect using parms specified by command line. */ @@ -621,9 +603,6 @@ const char *RemoteLink( const char *parms, bool server ) socket_address.sin_port = htons( trap_port ); #endif #endif - - /* unused parameters */ (void)server; - return( NULL ); } @@ -631,7 +610,6 @@ const char *RemoteLink( const char *parms, bool server ) void RemoteUnLink( void ) { #ifdef SERVER - #ifdef __RDOS__ if( wait_handle ) { RdosCloseWait( wait_handle ); @@ -648,7 +626,9 @@ void RemoteUnLink( void ) terminate_connection(); #endif -#if defined(__NT__) || defined(__WINDOWS__) +#if defined( __RDOS__ ) + /* no finalization */ +#elif defined(__NT__) || defined(__WINDOWS__) WSACleanup(); #elif defined(__DOS__) sock_exit(); From 41646412575f89291ab7e106d80cc7b72787b7b2 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Thu, 7 Sep 2023 00:59:38 +0200 Subject: [PATCH 091/258] cleanup trap code --- bld/trap/common/remote.c | 3 ++- bld/trap/lcl/dos/dosx/c/dosxremo.c | 1 - bld/trap/lcl/elfcore/c/elfcore.c | 9 +++---- bld/trap/lcl/jvm/c/jvmxremo.c | 16 ++++++------- bld/trap/lcl/linux/c/lnxcore.c | 9 +++---- bld/trap/lcl/nt/c/task.c | 4 ++-- bld/trap/lcl/qnx/c/qnxacc.c | 3 ++- bld/trap/lcl/qnx/c/qnxpmd.c | 11 +++++---- bld/trap/nmp/c/nmplink.c | 4 ++-- bld/trap/nov/c/novos2.c | 4 ++-- bld/trap/nov/h/nov.h | 7 +++++- bld/trap/par/c/parlink.c | 38 ++++++++---------------------- bld/trap/par/os2v2.pio/makefile | 2 ++ bld/trap/ser/c/serlink.c | 5 ++-- bld/trap/vdm/h/vdm.h | 3 +-- bld/trap/win/c/winlink.c | 3 ++- 16 files changed, 58 insertions(+), 64 deletions(-) diff --git a/bld/trap/common/remote.c b/bld/trap/common/remote.c index 522f2a1909..123cf55811 100644 --- a/bld/trap/common/remote.c +++ b/bld/trap/common/remote.c @@ -135,7 +135,8 @@ trap_version TRAPENTRY TrapInit( const char *parms, char *error, bool remote ) const char *err; bool fix_minor; - remote=remote; + /* unused parameters */ (void)remote; + _DBG_EnterFunc( "TrapInit" ); ver.remote = true; fix_minor = false; diff --git a/bld/trap/lcl/dos/dosx/c/dosxremo.c b/bld/trap/lcl/dos/dosx/c/dosxremo.c index 253fc8f3f7..907ee148e4 100644 --- a/bld/trap/lcl/dos/dosx/c/dosxremo.c +++ b/bld/trap/lcl/dos/dosx/c/dosxremo.c @@ -465,7 +465,6 @@ trap_version TRAPENTRY TrapInit( const char *parms, char *error, bool remote ) { trap_version ver; - remote = remote; ver.remote = false; ver.major = TRAP_MAJOR_VERSION; ver.minor = TRAP_MINOR_VERSION; diff --git a/bld/trap/lcl/elfcore/c/elfcore.c b/bld/trap/lcl/elfcore/c/elfcore.c index 030d47ed4a..db5557e635 100644 --- a/bld/trap/lcl/elfcore/c/elfcore.c +++ b/bld/trap/lcl/elfcore/c/elfcore.c @@ -814,21 +814,22 @@ trap_retval TRAP_CORE( Get_err_text )( void ) trap_version TRAPENTRY TrapInit( const char *parms, char *err, bool remote ) { + char ch; trap_version ver; - remote = remote; + /* unused parameters */ (void)remote; + Core.fd = NO_FILE; Core.x_fd = NO_FILE; Core.c_ehdr = malloc( sizeof( Elf32_Ehdr ) ); Core.x_ehdr = malloc( sizeof( Elf32_Ehdr ) ); - while( *parms != '\0' ) { - switch( *parms ) { + while( (ch = *parms++) != '\0' ) { + switch( ch ) { case 'I': case 'i': Core.ignore_timestamp = true; break; } - ++parms; } err[0] = '\0'; /* all ok */ ver.major = TRAP_MAJOR_VERSION; diff --git a/bld/trap/lcl/jvm/c/jvmxremo.c b/bld/trap/lcl/jvm/c/jvmxremo.c index 5f0ac2f78b..146233dab5 100644 --- a/bld/trap/lcl/jvm/c/jvmxremo.c +++ b/bld/trap/lcl/jvm/c/jvmxremo.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -42,12 +42,12 @@ #include "jvmxremo.h" -bool TaskLoaded; -HANDLE FakeHandle; -HWND DebuggerHwnd; +bool TaskLoaded; +HANDLE FakeHandle; +HWND DebuggerHwnd; -static char LinkParms[256]; -static char SavedError[256]; +static char LinkParms[256]; +static char SavedError[256]; trap_retval DoAccess( void ) { @@ -556,9 +556,9 @@ trap_retval TRAP_CORE( Split_cmd )( void ) trap_version TRAPENTRY TrapInit( const char *parms, char *error, bool remote ) { trap_version ver; - extern void InitPSP(); - remote = remote; + /* unused parameters */ (void)remote; + ver.remote = FALSE; ver.major = TRAP_MAJOR_VERSION; ver.minor = TRAP_MINOR_VERSION; diff --git a/bld/trap/lcl/linux/c/lnxcore.c b/bld/trap/lcl/linux/c/lnxcore.c index eb7b4cde09..c731906e9e 100644 --- a/bld/trap/lcl/linux/c/lnxcore.c +++ b/bld/trap/lcl/linux/c/lnxcore.c @@ -729,17 +729,18 @@ trap_retval TRAP_THREAD( get_extra )( void ) trap_version TRAPENTRY TrapInit( const char *parms, char *err, bool remote ) { trap_version ver; + char ch; + + /* unused parameters */ (void)remote; - remote = remote; core_info.fd = NO_FILE; - while( *parms != '\0' ) { - switch( *parms ) { + while( (ch = *parms++) != '\0' ) { + switch( ch ) { case 'I': case 'i': core_info.ignore_timestamp = true; break; } - ++parms; } err[0] = '\0'; /* all ok */ ver.major = TRAP_MAJOR_VERSION; diff --git a/bld/trap/lcl/nt/c/task.c b/bld/trap/lcl/nt/c/task.c index 6ab6bf6ffd..60047cb7bd 100644 --- a/bld/trap/lcl/nt/c/task.c +++ b/bld/trap/lcl/nt/c/task.c @@ -44,6 +44,8 @@ trap_version TRAPENTRY TrapInit( const char *parms, char *err, bool remote ) trap_version trapver; HANDLE dll; + /* unused parameters */ (void)remote; + #if MADARCH & MADARCH_X64 dll = LoadLibrary( "PSAPI.DLL" ); if( dll != NULL ) { @@ -102,8 +104,6 @@ trap_version TRAPENTRY TrapInit( const char *parms, char *err, bool remote ) if( *parms == 'k' ) { BreakOnKernelMessage = true; } - remote = remote; - err[0] = 0; trapver.major = TRAP_MAJOR_VERSION; trapver.minor = TRAP_MINOR_VERSION; diff --git a/bld/trap/lcl/qnx/c/qnxacc.c b/bld/trap/lcl/qnx/c/qnxacc.c index c1092783df..c84b16a293 100644 --- a/bld/trap/lcl/qnx/c/qnxacc.c +++ b/bld/trap/lcl/qnx/c/qnxacc.c @@ -1781,6 +1781,8 @@ trap_version TRAPENTRY TrapInit( const char *parms, char *err, bool remote ) { trap_version ver; + /* unused parameters */ (void)remote; + ForceFpu32 = 0; switch( *parms ) { case 'f': @@ -1790,7 +1792,6 @@ trap_version TRAPENTRY TrapInit( const char *parms, char *err, bool remote ) ForceFpu32 = 1; break; } - remote = remote; ProcInfo.save_in = -1; ProcInfo.save_out = -1; ProcInfo.thread = NULL; diff --git a/bld/trap/lcl/qnx/c/qnxpmd.c b/bld/trap/lcl/qnx/c/qnxpmd.c index 63f157f141..9077324ab3 100644 --- a/bld/trap/lcl/qnx/c/qnxpmd.c +++ b/bld/trap/lcl/qnx/c/qnxpmd.c @@ -854,14 +854,16 @@ trap_retval TRAP_THREAD( get_extra )( void ) trap_version TRAPENTRY TrapInit( const char *parms, char *err, bool remote ) { - trap_version ver; + trap_version ver; + char ch; + + /* unused parameters */ (void)remote; - remote = remote; PmdInfo.fd = NO_FILE; PmdInfo.enable_read_gdts = true; PmdInfo.force_read_gdts = false; - while( *parms != '\0' ) { - switch( *parms ) { + while( (ch = *parms++) != '\0' ) { + switch( ch ) { case 'I': case 'i': PmdInfo.ignore_timestamp = true; @@ -875,7 +877,6 @@ trap_version TRAPENTRY TrapInit( const char *parms, char *err, bool remote ) PmdInfo.enable_read_gdts = false; break; } - ++parms; } err[0] = '\0'; /* all ok */ ver.major = TRAP_MAJOR_VERSION; diff --git a/bld/trap/nmp/c/nmplink.c b/bld/trap/nmp/c/nmplink.c index 29aaac478d..11c3e93eb2 100644 --- a/bld/trap/nmp/c/nmplink.c +++ b/bld/trap/nmp/c/nmplink.c @@ -99,10 +99,10 @@ static void DoOpen( bhandle *phdl, char *suff ) { strcpy( NameEnd, suff ); dbg( "DoOpen " ); - dbg( NameBuff+1 ); + dbg( NameBuff + 1 ); dbg( "\r\n" ); for( ;; ) { - *phdl = PipeOpen( NameBuff+1 ); + *phdl = PipeOpen( NameBuff + 1 ); if( *phdl != BHANDLE_INVALID ) break; mysnooze(); diff --git a/bld/trap/nov/c/novos2.c b/bld/trap/nov/c/novos2.c index 4b955e4fbd..414e062b74 100644 --- a/bld/trap/nov/c/novos2.c +++ b/bld/trap/nov/c/novos2.c @@ -539,9 +539,9 @@ const char *RemoteLink( const char *parms, bool server ) { unsigned i; - server = server; -putstring( "RemoteLink\r\n" ); + /* unused parameters */ (void)server; +putstring( "RemoteLink\r\n" ); if( *parms == '\0' ) parms = DEFAULT_LINK_NAME; for( i = 0; i < 47 && *parms != '\0'; ++parms ) { diff --git a/bld/trap/nov/h/nov.h b/bld/trap/nov/h/nov.h index b4f400fc4a..ae12881f33 100644 --- a/bld/trap/nov/h/nov.h +++ b/bld/trap/nov/h/nov.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -32,3 +32,8 @@ #define DEFAULT_LINK_NAME "NovLink" +#ifdef MAX_NAME_LEN +#define LINK_NAME_MAX_LEN MAX_NAME_LEN +#else +#define LINK_NAME_MAX_LEN 47 +#endif diff --git a/bld/trap/par/c/parlink.c b/bld/trap/par/c/parlink.c index 215f1dab33..816a6bc52f 100644 --- a/bld/trap/par/c/parlink.c +++ b/bld/trap/par/c/parlink.c @@ -843,24 +843,6 @@ static char InvalidPort[] = TRP_ERR_invalid_parallel_port_number; #ifdef SERVER #ifdef TRAPGUI -static char *hex( unsigned num ) -{ - static char hexbuff[10]; - char *p; - - p = &hexbuff[9]; - *p = '\0'; - if( num == 0 ) { - *--p = '0'; - return( p ); - } - while( num != 0 ) { - *--p = "0123456789abcdef"[num & 15]; - num >>= 4; - } - return( p ); -} - const char *RemoteLinkGet( char *parms, size_t len ) { int num; @@ -880,8 +862,7 @@ const char *RemoteLinkGet( char *parms, size_t len ) parms[0] = '3'; parms[1] = '\0'; } else { - parms[0] = 'P'; - strcpy( parms + 1, hex( DataPort ) ); + sprintf( parms, "P%X", DataPort ); } return( NULL ); } @@ -891,17 +872,17 @@ const char *RemoteLinkGet( char *parms, size_t len ) const char *RemoteLinkSet( const char *parms ) { unsigned printer; - unsigned ch; + char ch; - if( *parms == '\0' ) { + ch = *parms++; + if( ch == '\0' ) { printer = 0; - } else if( parms[0] >= '1' && parms[0] <= '3' && parms[1] == '\0' ) { - printer = parms[0] - '1'; - } else if( parms[0] == 'p' || parms[0] == 'P' ) { + } else if( ch >= '1' && ch <= '3' && *parms == '\0' ) { + printer = ch - '1'; + } else if( ch == 'p' || ch == 'P' ) { printer = 0; for( ;; ) { - ++parms; - ch = *parms; + ch = *parms++; if( ch == 0 ) break; if( ch == ' ' ) @@ -937,8 +918,9 @@ const char *RemoteLink( const char *parms, bool server ) { const char *err; + /* unused parameters */ (void)server; + dbgrtn( "\r\n-RemoteLink-" ); - server = server; err = InitSys(); if( err != NULL ) { diff --git a/bld/trap/par/os2v2.pio/makefile b/bld/trap/par/os2v2.pio/makefile index d51a68ce1c..d622480f02 100644 --- a/bld/trap/par/os2v2.pio/makefile +++ b/bld/trap/par/os2v2.pio/makefile @@ -9,6 +9,8 @@ proj_name = os2v2pio os2v2pio_autodepends = .AUTODEPEND +os2v2pio_nocheckstack = 1 + # This is a quick and dirty project because it is OS/2 specific and # intended to be temporary; Yes, I know it breaks all known rules. Once # WLINK properly supports 16-bit IOPL segments in 32-bit DLLs, the port diff --git a/bld/trap/ser/c/serlink.c b/bld/trap/ser/c/serlink.c index 4dca237fef..acdfd5d0dd 100644 --- a/bld/trap/ser/c/serlink.c +++ b/bld/trap/ser/c/serlink.c @@ -850,9 +850,10 @@ static char *SetupModem( const char *parm ) return( NULL ); } -/* The format for *parm is "1.9600" */ - const char *RemoteLink( const char *parms, bool server ) +/******************************************************* + * The format for *parm is "1.9600" + */ { const char *result; diff --git a/bld/trap/vdm/h/vdm.h b/bld/trap/vdm/h/vdm.h index c6272ccbc8..9a83d7a07b 100644 --- a/bld/trap/vdm/h/vdm.h +++ b/bld/trap/vdm/h/vdm.h @@ -43,5 +43,4 @@ #define DEFAULT_LINK_NAME "VDMLink" -extern bool ValidName( const char *name ); - +extern bool ValidName( const char *name ); diff --git a/bld/trap/win/c/winlink.c b/bld/trap/win/c/winlink.c index b9c93ce928..82263411a4 100644 --- a/bld/trap/win/c/winlink.c +++ b/bld/trap/win/c/winlink.c @@ -167,7 +167,8 @@ const char *RemoteLink( const char *parms, bool server ) int i; int rc; - server = server; + /* unused parameters */ (void)server; + if( *parms == '\0' ) parms = DEFAULT_LINK_NAME; for( i = 0; i < LINKNAME_SIZE; i++ ) { From f909feb6da18bb613b9ce838f15346f9f14095ec Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Thu, 7 Sep 2023 18:17:11 +0200 Subject: [PATCH 092/258] add new procedure type to handle win386 target --- bld/watcom/h/wclbproc.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/bld/watcom/h/wclbproc.h b/bld/watcom/h/wclbproc.h index bd4b10e824..4613177897 100644 --- a/bld/watcom/h/wclbproc.h +++ b/bld/watcom/h/wclbproc.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2014-2020 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2014-2023 The Open Watcom Contributors. All Rights Reserved. * * ======================================================================== * @@ -75,6 +75,7 @@ typedef LRESULT (CALLBACK *HOOKPROCx)(int,WPARAM,LPARAM); typedef BOOL (CALLBACK *WNDENUMPROCx)(HWND,LPARAM); typedef LRESULT (CALLBACK *WNDPROCx)(HWND,UINT,WPARAM,LPARAM); typedef void (CALLBACK *TIMERPROCx)( HWND, UINT, UINT_PTR, DWORD ); +typedef void (CALLBACK *LINEDDAPROCx)( int, int, LPARAM ); #if defined( INCLUDE_COMMDLG_H ) typedef UINT_PTR (CALLBACK *__CDHOOKPROCx)(HWND,UINT,WPARAM,LPARAM); typedef __CDHOOKPROCx LPOFNHOOKPROCx; @@ -88,6 +89,7 @@ typedef __CDHOOKPROCx LPOFNHOOKPROCx; #define WNDENUMPROCx WNDENUMPROC #define WNDPROCx WNDPROC #define TIMERPROCx TIMERPROC +#define LINEDDAPROCx LINEDDAPROC #if !defined( __WINDOWS__ ) || defined( INCLUDE_COMMDLG_H ) #define LPOFNHOOKPROCx LPOFNHOOKPROC #endif @@ -104,9 +106,11 @@ extern HOOKPROC MakeProcInstance_HOOK( HOOKPROCx fn, HINSTANCE insta extern WNDENUMPROC MakeProcInstance_WNDENUM( WNDENUMPROCx fn, HINSTANCE instance ); extern WNDPROC MakeProcInstance_WND( WNDPROCx fn, HINSTANCE instance ); extern TIMERPROC MakeProcInstance_TIMER( TIMERPROCx fn, HINSTANCE instance ); +extern LINEDDAPROC MakeProcInstance_LINEDDA( LINEDDAPROCx fn, HINSTANCE instance ); #if defined( INCLUDE_COMMDLG_H ) extern LPOFNHOOKPROC MakeProcInstance_OFNHOOK( LPOFNHOOKPROCx fn, HINSTANCE instance ); #endif + #pragma aux MakeProcInstance_DLG = MAKEPROCINSTANCE_INLINE #pragma aux MakeProcInstance_FONTENUM = MAKEPROCINSTANCE_INLINE #pragma aux MakeProcInstance_OLDFONTENUM = MAKEPROCINSTANCE_INLINE @@ -114,6 +118,7 @@ extern LPOFNHOOKPROC MakeProcInstance_OFNHOOK( LPOFNHOOKPROCx fn, HINSTAN #pragma aux MakeProcInstance_WNDENUM = MAKEPROCINSTANCE_INLINE #pragma aux MakeProcInstance_WND = MAKEPROCINSTANCE_INLINE #pragma aux MakeProcInstance_TIMER = MAKEPROCINSTANCE_INLINE +#pragma aux MakeProcInstance_LINEDDA = MAKEPROCINSTANCE_INLINE #if defined( INCLUDE_COMMDLG_H ) #pragma aux MakeProcInstance_OFNHOOK = MAKEPROCINSTANCE_INLINE #endif @@ -127,6 +132,7 @@ extern LPOFNHOOKPROC MakeProcInstance_OFNHOOK( LPOFNHOOKPROCx fn, HINSTAN #define MakeProcInstance_WNDENUM(f,i) ((void)i,f) #define MakeProcInstance_WND(f,i) ((void)i,f) #define MakeProcInstance_TIMER(f,i) ((void)i,f) +#define MakeProcInstance_LINEDDA(f,i) ((void)i,f) #endif #if defined( __WINDOWS__ ) && defined( _M_I86 ) @@ -137,6 +143,7 @@ extern void FreeProcInstance_HOOK( HOOKPROC f ); extern void FreeProcInstance_WNDENUM( WNDENUMPROC f ); extern void FreeProcInstance_WND( WNDPROC f ); extern void FreeProcInstance_TIMER( TIMERPROC f ); +extern void FreeProcInstance_LINEDDA( LINEDDAPROC f ); #if defined( INCLUDE_COMMDLG_H ) extern void FreeProcInstance_OFNHOOK( LPOFNHOOKPROC f ); #endif @@ -147,6 +154,7 @@ extern void FreeProcInstance_OFNHOOK( LPOFNHOOKPROC f ); #pragma aux FreeProcInstance_WNDENUM = FREEPROCINSTANCE_INLINE #pragma aux FreeProcInstance_WND = FREEPROCINSTANCE_INLINE #pragma aux FreeProcInstance_TIMER = FREEPROCINSTANCE_INLINE +#pragma aux FreeProcInstance_LINEDDA = FREEPROCINSTANCE_INLINE #if defined( INCLUDE_COMMDLG_H ) #pragma aux FreeProcInstance_OFNHOOK = FREEPROCINSTANCE_INLINE #endif @@ -159,6 +167,7 @@ extern void FreeProcInstance_OFNHOOK( LPOFNHOOKPROC f ); #define FreeProcInstance_WNDENUM(f) ((void)f) #define FreeProcInstance_WND(f) ((void)f) #define FreeProcInstance_TIMER(f) ((void)f) +#define FreeProcInstance_LINEDDA(f) ((void)f) #endif #ifdef __cplusplus From 14c65ac6ddce3f1b738656c5e8e394bf8f4fa933 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Thu, 7 Sep 2023 19:50:06 +0200 Subject: [PATCH 093/258] add specialized API functions to wpi project add following functions to support win386 target by wpi _wpi_makewndprocinstance _wpi_freewndprocinstance _wpi_makelineddaprocinstance _wpi_freelineddaprocinstance _wpi_makefontprocinstance _wpi_freefontprocinstance --- bld/wpi/doc/wpi.gml | 27 +++++++++++++-------------- bld/wpi/h/wpi_os2.h | 17 +++++++++++++++-- bld/wpi/h/wpi_win.h | 26 ++++++++++++++++++++------ 3 files changed, 48 insertions(+), 22 deletions(-) diff --git a/bld/wpi/doc/wpi.gml b/bld/wpi/doc/wpi.gml index adbdcdf682..3579922454 100644 --- a/bld/wpi/doc/wpi.gml +++ b/bld/wpi/doc/wpi.gml @@ -1192,9 +1192,9 @@ dialog procedure. Initializing a dialog box procedure would look like the following under WPI: .np :XMP. -fp = _wpi_makeprocinstance( (WPI_PROC)DlgProc, Instance ); +fp = _wpi_makedlgprocinstance( DlgProc, Instance ); ret_val = _wpi_dialogbox( hparent, fp, Instance, DLG_ID, 0L ); -_wpi_freeprocinstance( fp ); +_wpi_freedlgprocinstance( fp ); :eXMP. .np The dialog procedure itself looks much like a Windows dialog procedure @@ -1286,23 +1286,22 @@ WPI_DLGRESULT CALLBACK dlg_sample( HWND dlg_hld, return( (WPI_DLGRESULT) FALSE ); } - . - . - . - /* PM expects a pointer to the data */ - /* while Windows just expects the data */ + . + . + . + + /* PM expects a pointer to the data */ + /* while Windows just expects the data */ #ifdef __OS2_PM__ - dlg_ret = _wpi_dialogbox( frame_win_hld, proc, Inst, tpl, - &id ); + dlg_ret = _wpi_dialogbox( frame_win_hld, proc, Inst, tpl, &id ); #else - dlg_ret = _wpi_dialogbox( frame_win_hld, proc, Inst, tpl, - id ); + dlg_ret = _wpi_dialogbox( frame_win_hld, proc, Inst, tpl, id ); #endif - . - . - . + . + . + . :eXMP. .* .section Owner-Drawn Controls diff --git a/bld/wpi/h/wpi_os2.h b/bld/wpi/h/wpi_os2.h index de129fd24d..a463001281 100644 --- a/bld/wpi/h/wpi_os2.h +++ b/bld/wpi/h/wpi_os2.h @@ -228,6 +228,15 @@ extern void _wpi_releasepres( HWND hwnd, WPI_PRES pres ); #define _wpi_freeenumprocinstance( proc ) \ // nothing + #define _wpi_freewndprocinstance( proc ) \ + // nothing + + #define _wpi_freelineddaprocinstance( proc ) \ + // nothing + + #define _wpi_freefontprocinstance( proc ) \ + // nothing + #define _wpi_freeprocinstance( proc ) \ // nothing @@ -516,13 +525,17 @@ extern HWND _wpi_createobjwindow( LPSTR class, LPSTR name, ULONG style, int x, #define _wpi_setwindowlongptr( hwnd, id, data ) WinSetWindowULong( hwnd, id, (LONG)data ) - #define _wpi_makeprocinstance( proc, inst ) ( (WPI_PROC) proc ) + #define _wpi_makeprocinstance( proc, inst ) ( (WPI_PROC)proc ) #define _wpi_makedlgprocinstance( proc, inst ) ( proc ) #define _wpi_makeenumprocinstance( proc, inst ) ( proc ) - #define _wpi_makelineddaprocinstance( proc, inst ) ((WPI_LINEDDAPROC)proc) + #define _wpi_makewndprocinstance( proc, inst ) ( proc ) + + #define _wpi_makelineddaprocinstance( proc, inst ) ( proc ) + + #define _wpi_makefontprocinstance( proc, inst ) ( proc ) #define _wpi_defdlgproc( hwnd, msg, mp1, mp2 ) WinDefDlgProc(hwnd, msg, mp1, mp2) diff --git a/bld/wpi/h/wpi_win.h b/bld/wpi/h/wpi_win.h index 14d9d2272c..0f19052430 100644 --- a/bld/wpi/h/wpi_win.h +++ b/bld/wpi/h/wpi_win.h @@ -39,6 +39,8 @@ * of the file to the end. *************************************************************************/ +#include "wclbproc.h" + #define GlobalUnlockCheck( hmem ) GlobalUnlock( hmem ) #define LocalUnlockCheck( hmem ) LocalUnlock( hmem ) @@ -304,22 +306,34 @@ extern void _wpi_getbitmapdim( WPI_HBITMAP hbitmap, int *pwidth, int *pheight ); #define _wpi_getclassinfo( inst, name, info ) \ GetClassInfo( NULL, name, info ) - #define _wpi_makeprocinstance( proc, inst ) MakeProcInstance( proc, inst ) + #define _wpi_makeprocinstance( proc, inst ) (WPI_PROC)MakeProcInstance( (FARPROC)proc, inst ) #define _wpi_makedlgprocinstance( proc, inst ) \ - (WPI_DLGPROC)MakeProcInstance( (FARPROC)proc, inst ) + (WPI_DLGPROC)MakeProcInstance_DLG( proc, inst ) #define _wpi_makeenumprocinstance( proc, inst ) \ - (WPI_ENUMPROC)MakeProcInstance( (FARPROC)proc, inst ) + (WPI_ENUMPROC)MakeProcInstance_WNDENUM( proc, inst ) + + #define _wpi_makewndprocinstance( proc, inst ) \ + (WPI_WNDPROC)MakeProcInstance_WND( proc, inst ) #define _wpi_makelineddaprocinstance( proc, inst ) \ - (WPI_LINEDDAPROC)MakeProcInstance( (FARPROC)proc, inst ) + (WPI_LINEDDAPROC)MakeProcInstance_LINEDDA( proc, inst ) + + #define _wpi_makefontprocinstance( proc, inst ) \ + (WPI_ENUMFONTPROC)MakeProcInstance_ENUMFONT( proc, inst ) #define _wpi_defdlgproc( hwnd, msg, mp1, mp2 ) FALSE - #define _wpi_freedlgprocinstance( proc ) FreeProcInstance( (FARPROC)proc ) + #define _wpi_freedlgprocinstance( proc ) FreeProcInstance_DLG( proc ) + + #define _wpi_freeenumprocinstance( proc ) FreeProcInstance_WNDENUM( proc ) + + #define _wpi_freewndprocinstance( proc ) FreeProcInstance_WND( proc ) + + #define _wpi_freelineddaprocinstance( proc ) FreeProcInstance_LINEDDA( proc ) - #define _wpi_freeenumprocinstance( proc ) FreeProcInstance( (FARPROC)proc ) + #define _wpi_freefontprocinstance( proc ) FreeProcInstance_ENUMFONT( proc ) #define _wpi_freeprocinstance( proc ) FreeProcInstance( (FARPROC)proc ) From 44767d7a60e40f3315d51bc28f0adec2cd994488 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Thu, 7 Sep 2023 20:07:54 +0200 Subject: [PATCH 094/258] fix 16-bit OS/2 code --- bld/gui/win/c/guif1hk.c | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/bld/gui/win/c/guif1hk.c b/bld/gui/win/c/guif1hk.c index 125d38e7e7..0445040a49 100644 --- a/bld/gui/win/c/guif1hk.c +++ b/bld/gui/win/c/guif1hk.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2018-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2018-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -39,7 +39,7 @@ /* Local Window callback functions prototypes */ #ifdef __OS2_PM__ -int CALLBACK F1Proc( HAB hab, WPI_QMSG *qmsg, ULONG fs ); +int CALLBACK F1Proc( HAB hab, WPI_QMSG *qmsg, UINT fs ); #else WINEXPORT LRESULT CALLBACK F1Proc( int code, WPARAM dummy, LPARAM msg_param ); #endif @@ -48,8 +48,6 @@ static unsigned F1Hooked = 0; #ifndef __OS2_PM__ static HHOOK F1HookHandle = (HHOOK)NULL; static HOOKPROC F1ProcInst; -#else -static PFN F1ProcInst; #endif // What the hell does this do??!! @@ -84,7 +82,7 @@ static gui_window *getFirstGUIParent( HWND hwnd ) } #ifdef __OS2_PM__ -int CALLBACK F1Proc( HAB hab, WPI_QMSG *qmsg, ULONG fs ) +int CALLBACK F1Proc( HAB hab, WPI_QMSG *qmsg, UINT fs ) #else LRESULT CALLBACK F1Proc( int code, WPARAM dummy, LPARAM msg_param ) #endif @@ -102,8 +100,9 @@ LRESULT CALLBACK F1Proc( int code, WPARAM dummy, LPARAM msg_param ) #endif #ifdef __OS2_PM__ - fs = fs; // unused - hab = hab; // unused + + /* unused parameters */ (void)fs; (void)hab; + code = 0; #else qmsg = (WPI_QMSG *)msg_param; @@ -129,7 +128,6 @@ LRESULT CALLBACK F1Proc( int code, WPARAM dummy, LPARAM msg_param ) } } } - #ifdef __OS2_PM__ return( false ); // No, we didn't gobble this msg #else @@ -140,7 +138,11 @@ LRESULT CALLBACK F1Proc( int code, WPARAM dummy, LPARAM msg_param ) void GUIAPI GUIHookF1( void ) { if( F1Hooked == 0 ) { -#ifndef __OS2_PM__ +#ifdef __OS2_PM__ + // in OS/2, it has to be an app. specific input filter (OS/2 has + // bad problems, occassionally, with system input hooks) + WinSetHook( GUIMainHInst.hab, HMQ_CURRENT, HK_INPUT, (PFN)F1Proc, GUIMainHInst.mod_handle ); +#else // we use a hook to trap F1 in dialogs that were not // created using this instance yet on our behalf. IE COMMDLG stuff @@ -152,11 +154,6 @@ void GUIAPI GUIHookF1( void ) #else F1HookHandle = SetWindowsHookEx( WH_MSGFILTER, F1ProcInst, GUIMainHInst, GetCurrentThreadId() ); #endif -#else - // in OS/2, it has to be an app. specific input filter (OS/2 has - // bad problems, occassionally, with system input hooks) - F1ProcInst = (PFN)F1Proc; - WinSetHook( GUIMainHInst.hab, HMQ_CURRENT, HK_INPUT, F1ProcInst, GUIMainHInst.mod_handle ); #endif } F1Hooked++; @@ -165,14 +162,13 @@ void GUIAPI GUIHookF1( void ) void GUIAPI GUIUnHookF1( void ) { if( F1Hooked == 1 ) { -#ifndef __OS2_PM__ +#ifdef __OS2_PM__ + WinReleaseHook( GUIMainHInst.hab, HMQ_CURRENT, HK_INPUT, (PFN)F1Proc, GUIMainHInst.mod_handle ); +#else UnhookWindowsHookEx( F1HookHandle ); FreeProcInstance_HOOK( F1ProcInst ); -#else - WinReleaseHook( GUIMainHInst.hab, HMQ_CURRENT, HK_INPUT, F1ProcInst, GUIMainHInst.mod_handle ); #endif } - if( F1Hooked != 0 ) { F1Hooked--; } From 6e84b69e070150b865dab97d6b25f84b09cd8c99 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Thu, 7 Sep 2023 21:20:15 +0200 Subject: [PATCH 095/258] use new _wpi_.... functions to simplify gui project code --- bld/commonui/c/toolbr.c | 6 +++--- bld/gui/win/c/guicombo.c | 12 +---------- bld/gui/win/c/guicontr.c | 18 +++-------------- bld/gui/win/c/guienum.c | 12 +---------- bld/gui/win/c/guirdlg.c | 23 +-------------------- bld/sdk/imgedit/c/iconinfo.c | 12 +++++------ bld/sdk/imgedit/c/iedraw.c | 16 +++++++-------- bld/sdk/imgedit/c/ieutil.c | 10 +++++----- bld/sdk/imgedit/c/ieviewin.c | 32 +++++++++++++++--------------- bld/sdk/imgedit/os2386/c/iefonts.c | 11 +++++----- bld/wpi/h/wpi_os2.h | 2 +- 11 files changed, 50 insertions(+), 104 deletions(-) diff --git a/bld/commonui/c/toolbr.c b/bld/commonui/c/toolbr.c index e9f85e8ba2..91f467df23 100644 --- a/bld/commonui/c/toolbr.c +++ b/bld/commonui/c/toolbr.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2015-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2015-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -87,7 +87,7 @@ static HBRUSH btnFaceBrush; static COLORREF btnColor; static WPI_INST appInst; #ifdef __OS2_PM__ -static WPI_PROC oldFrameProc; +static WPI_WNDPROC oldFrameProc; #endif static tool *currTool; @@ -826,7 +826,7 @@ void ToolBarDisplay( toolbar *bar, TOOLDISPLAYINFO *disp ) frame = WinCreateStdWindow( parent, 0L, &disp->style, NULL, "", 0L, (HMODULE)0, 0, NULL ); WinSetOwner( frame, bar->owner ); - oldFrameProc = _wpi_subclasswindow( frame, (WPI_PROC)FrameProc ); + oldFrameProc = _wpi_subclasswindow( frame, FrameProc ); WinSetPresParam( frame, PP_BACKGROUNDCOLORINDEX, (ULONG)sizeof( LONG ) + 1, (PVOID)&btnColor ); WinCreateWindow( frame, className, "", WS_VISIBLE, 0, 0, 0, 0, frame, HWND_TOP, FID_CLIENT, (PVOID)bar, NULL ); diff --git a/bld/gui/win/c/guicombo.c b/bld/gui/win/c/guicombo.c index dd70c9ffe9..eeeb18659c 100644 --- a/bld/gui/win/c/guicombo.c +++ b/bld/gui/win/c/guicombo.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -77,22 +77,12 @@ BOOL CALLBACK GUISubClassEditComboboxEnumFunc( HWND hwnd, WPI_PARAM2 lparam ) WPI_WNDPROC GUISubClassEditCombobox( HWND hwnd ) { enum_info e_info; -#ifdef __OS2_PM__ WPI_ENUMPROC wndenumproc; -#else - WNDENUMPROC wndenumproc; -#endif e_info.success = false; -#ifdef __OS2_PM__ wndenumproc = _wpi_makeenumprocinstance( GUISubClassEditComboboxEnumFunc, GUIMainHInst ); _wpi_enumchildwindows( hwnd, wndenumproc, (LPARAM)&e_info ); _wpi_freeenumprocinstance( wndenumproc ); -#else - wndenumproc = MakeProcInstance_WNDENUM( GUISubClassEditComboboxEnumFunc, GUIMainHInst ); - EnumChildWindows( hwnd, wndenumproc, (LPARAM)&e_info ); - FreeProcInstance_WNDENUM( wndenumproc ); -#endif if( e_info.success ) { return( e_info.old ); } diff --git a/bld/gui/win/c/guicontr.c b/bld/gui/win/c/guicontr.c index 15b4d6559b..4ffcd292ec 100644 --- a/bld/gui/win/c/guicontr.c +++ b/bld/gui/win/c/guicontr.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -401,9 +401,7 @@ WPI_MRESULT CALLBACK GUIGroupBoxFunc( HWND hwnd, WPI_MSG message, WPI_PARAM1 wpa WPI_WNDPROC GUIDoSubClass( HWND hwnd, gui_control_class control_class ) { WPI_WNDPROC old; -#ifdef __OS2_PM__ WPI_WNDPROC new; -#endif //CvrCtl3dSubclassCtl( hwnd ); @@ -412,22 +410,12 @@ WPI_WNDPROC GUIDoSubClass( HWND hwnd, gui_control_class control_class ) return( GUISubClassEditCombobox( hwnd ) ); case GUI_EDIT: case GUI_EDIT_MLE: -#ifdef __OS2_PM__ - new = (WPI_WNDPROC)_wpi_makeprocinstance( (WPI_PROC)GUIEditFunc, GUIMainHInst ); + new = _wpi_makewndprocinstance( GUIEditFunc, GUIMainHInst ); old = _wpi_subclasswindow( hwnd, new ); -#else - old = (WPI_WNDPROC)GET_WNDPROC( hwnd ); - SET_WNDPROC( hwnd, (LONG_PTR)MakeProcInstance_WND( GUIEditFunc, GUIMainHInst ) ); -#endif return( old ); case GUI_GROUPBOX: -#ifdef __OS2_PM__ - new = (WPI_WNDPROC)_wpi_makeprocinstance( (WPI_PROC)GUIGroupBoxFunc, GUIMainHInst ); + new = _wpi_makewndprocinstance( GUIGroupBoxFunc, GUIMainHInst ); old = _wpi_subclasswindow( hwnd, new ); -#else - old = (WPI_WNDPROC)GET_WNDPROC( hwnd ); - SET_WNDPROC( hwnd, (LONG_PTR)MakeProcInstance_WND( GUIGroupBoxFunc, GUIMainHInst ) ); -#endif return( old ); default: return( NULL ); diff --git a/bld/gui/win/c/guienum.c b/bld/gui/win/c/guienum.c index cc9e435e2c..72adf7d99e 100644 --- a/bld/gui/win/c/guienum.c +++ b/bld/gui/win/c/guienum.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -81,22 +81,12 @@ BOOL CALLBACK GUIEnumChildWindowsEnumFunc( HWND hwnd, WPI_PARAM2 lparam ) void GUIAPI GUIEnumChildWindows( gui_window *wnd, ENUMCALLBACK *func, void *param ) { enum_info info; -#ifdef __OS2_PM__ WPI_ENUMPROC wndenumproc; -#else - WNDENUMPROC wndenumproc; -#endif info.parent = wnd; info.func = func; info.param = param; -#ifdef __OS2_PM__ wndenumproc = _wpi_makeenumprocinstance( GUIEnumChildWindowsEnumFunc, GUIMainHInst ); _wpi_enumchildwindows( wnd->hwnd, wndenumproc, (LPARAM)&info ); _wpi_freeenumprocinstance( wndenumproc ); -#else - wndenumproc = MakeProcInstance_WNDENUM( GUIEnumChildWindowsEnumFunc, GUIMainHInst ); - EnumChildWindows( wnd->hwnd, wndenumproc, (LPARAM)&info ); - FreeProcInstance_WNDENUM( wndenumproc ); -#endif } diff --git a/bld/gui/win/c/guirdlg.c b/bld/gui/win/c/guirdlg.c index 99e95808ed..8fbc7104cc 100644 --- a/bld/gui/win/c/guirdlg.c +++ b/bld/gui/win/c/guirdlg.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -194,29 +194,17 @@ BOOL CALLBACK InsertResDlgCntlFunc( HWND hwnd, LPARAM lparam ) bool GUIInsertResDialogControls( gui_window *wnd ) { -#ifdef __OS2_PM__ WPI_ENUMPROC wndenumproc; wndenumproc = _wpi_makeenumprocinstance( InsertResDlgCntlFunc, GUIMainHInst ); _wpi_enumchildwindows( wnd->hwnd, wndenumproc, (LPARAM)wnd ); _wpi_freeenumprocinstance( wndenumproc ); -#else - WNDENUMPROC wndenumproc; - - wndenumproc = MakeProcInstance_WNDENUM( InsertResDlgCntlFunc, GUIMainHInst ); - EnumChildWindows( wnd->hwnd, wndenumproc, (LPARAM)wnd ); - FreeProcInstance_WNDENUM( wndenumproc ); -#endif return( true ); } bool GUICreateDialogFromRes( res_name_or_id dlg_id, gui_window *parent_wnd, GUICALLBACK *gui_call_back, void *extra ) { -#ifdef __OS2_PM__ WPI_DLGPROC dlgproc; -#else - DLGPROC dlgproc; -#endif HWND parent_hwnd; bool ok; @@ -225,21 +213,12 @@ bool GUICreateDialogFromRes( res_name_or_id dlg_id, gui_window *parent_wnd, GUIC parent_hwnd = parent_wnd->hwnd; if( parent_hwnd == NULLHANDLE ) parent_hwnd = HWND_DESKTOP; -#ifdef __OS2_PM__ dlgproc = _wpi_makedlgprocinstance( GUIDialogDlgProc, GUIMainHInst ); ok = ( dlgproc != NULL ); if( ok ) { ok = ( _wpi_dialogbox( parent_hwnd, dlgproc, GUIResHInst, dlg_id, extra ) != -1 ); _wpi_freedlgprocinstance( dlgproc ); } -#else - dlgproc = MakeProcInstance_DLG( GUIDialogDlgProc, GUIMainHInst ); - ok = ( dlgproc != NULL ); - if( ok ) { - ok = ( DialogBoxParam( GUIResHInst, dlg_id, parent_hwnd, dlgproc, (LPARAM)extra ) != -1 ); - FreeProcInstance_DLG( dlgproc ); - } -#endif return( ok ); } diff --git a/bld/sdk/imgedit/c/iconinfo.c b/bld/sdk/imgedit/c/iconinfo.c index e00de5167b..1cbda0ca2e 100644 --- a/bld/sdk/imgedit/c/iconinfo.c +++ b/bld/sdk/imgedit/c/iconinfo.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2020 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -417,16 +417,14 @@ bool CreateNewIcon( short *width, short *height, short *bitcount, bool is_icon ) { WPI_DLGPROC dlgproc; WPI_DLGRESULT button_type; + LPCSTR restype; iconOperation = NEW_ICON_OP; resetIconInfo(); + restype = ( is_icon ) ? ICONTYPE : CURSORTYPE; dlgproc = _wpi_makedlgprocinstance( SelNonExistingDlgProc, Instance ); - if( is_icon ) { - button_type = _wpi_dialogbox( HMainWindow, dlgproc, Instance, ICONTYPE, 0L ); - } else { - button_type = _wpi_dialogbox( HMainWindow, dlgproc, Instance, CURSORTYPE, 0L ); - } + button_type = _wpi_dialogbox( HMainWindow, dlgproc, Instance, restype, 0L ); _wpi_freedlgprocinstance( dlgproc ); if( button_type == DLGID_CANCEL ) { @@ -465,8 +463,8 @@ void AddNewIcon( void ) } node = GetImageNode( currentnode->hwnd ); - iconOperation = ADD_ICON_OP; + dlgproc = _wpi_makedlgprocinstance( SelNonExistingDlgProc, Instance ); button_type = _wpi_dialogbox( HMainWindow, dlgproc, Instance, ICONTYPE, 0L ); _wpi_freedlgprocinstance( dlgproc ); diff --git a/bld/sdk/imgedit/c/iedraw.c b/bld/sdk/imgedit/c/iedraw.c index 2ebb784268..0e933602d6 100644 --- a/bld/sdk/imgedit/c/iedraw.c +++ b/bld/sdk/imgedit/c/iedraw.c @@ -562,7 +562,7 @@ void Paint( HWND hwnd, WPI_POINT *start_pt, WPI_POINT *end_pt, int mousebutton ) WPI_POINT s_pt; WPI_POINT e_pt; WPI_PARAM2 lparam; - WPI_LINEDDAPROC fp; + WPI_LINEDDAPROC lineddaproc; s_pt.x = MAKELOGPTX( start_pt->x ); s_pt.y = MAKELOGPTY( start_pt->y ); @@ -579,9 +579,9 @@ void Paint( HWND hwnd, WPI_POINT *start_pt, WPI_POINT *end_pt, int mousebutton ) currentMouseButton = mousebutton; SET_HWND_PARAM2( lparam, hwnd ); - fp = _wpi_makelineddaprocinstance( DrawPt, Instance ); - _wpi_linedda( s_pt.x, s_pt.y, e_pt.x, e_pt.y, (WPI_LINEDDAPROC)fp, lparam ); - _wpi_freeprocinstance( fp ); + lineddaproc = _wpi_makelineddaprocinstance( DrawPt, Instance ); + _wpi_linedda( s_pt.x, s_pt.y, e_pt.x, e_pt.y, lineddaproc, lparam ); + _wpi_freeprocinstance( lineddaproc ); DrawSinglePoint( hwnd, end_pt, mousebutton ); memcpy( start_pt, end_pt, sizeof( WPI_POINT ) ); @@ -1004,7 +1004,7 @@ void CreateDrawnImage( img_node *node ) */ void CheckGridItem( HMENU hmenu ) { - WPI_ENUMPROC enumproc; + WPI_ENUMPROC wndenumproc; HCURSOR prevcursor; prevcursor = _wpi_setcursor( _wpi_getsyscursor( IDC_WAIT ) ); @@ -1022,9 +1022,9 @@ void CheckGridItem( HMENU hmenu ) PressGridButton(); if( DoImagesExist() ) { - enumproc = _wpi_makeenumprocinstance( GridEnumProc, Instance ); - _wpi_enumchildwindows( ClientWindow, enumproc, 0L ); - _wpi_freeenumprocinstance( enumproc ); + wndenumproc = _wpi_makeenumprocinstance( GridEnumProc, Instance ); + _wpi_enumchildwindows( ClientWindow, wndenumproc, 0L ); + _wpi_freeenumprocinstance( wndenumproc ); } _wpi_setcursor( prevcursor ); diff --git a/bld/sdk/imgedit/c/ieutil.c b/bld/sdk/imgedit/c/ieutil.c index 19b942f3d5..b88a306f1b 100644 --- a/bld/sdk/imgedit/c/ieutil.c +++ b/bld/sdk/imgedit/c/ieutil.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -544,7 +544,7 @@ BOOL CALLBACK GetPosProc( HWND hwnd, LONG lparam ) */ void FindOrigin( WPI_POINT *new_origin ) { - WPI_ENUMPROC enumproc; + WPI_ENUMPROC wndenumproc; int image_count; int i, j; WPI_POINT temp; @@ -564,9 +564,9 @@ void FindOrigin( WPI_POINT *new_origin ) windowCoords = MemAlloc( image_count * sizeof( WPI_POINT ) ); windowIndex = 0; - enumproc = _wpi_makeenumprocinstance( GetPosProc, Instance ); - _wpi_enumchildwindows( ClientWindow, enumproc, 0L ); - _wpi_freeenumprocinstance( enumproc ); + wndenumproc = _wpi_makeenumprocinstance( GetPosProc, Instance ); + _wpi_enumchildwindows( ClientWindow, wndenumproc, 0L ); + _wpi_freeenumprocinstance( wndenumproc ); /* * I'm just using a simple bubble sort ... we're using small amounts of data diff --git a/bld/sdk/imgedit/c/ieviewin.c b/bld/sdk/imgedit/c/ieviewin.c index f71a3ebb51..474bd6995f 100644 --- a/bld/sdk/imgedit/c/ieviewin.c +++ b/bld/sdk/imgedit/c/ieviewin.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -378,7 +378,7 @@ WPI_MRESULT CALLBACK ViewWindowProc( HWND hwnd, WPI_MSG msg, */ void CheckViewItem( HMENU hmenu ) { - WPI_ENUMPROC enumproc; + WPI_ENUMPROC wndenumproc; if( _wpi_isitemchecked( hmenu, IMGED_VIEW ) ) { _wpi_checkmenuitem( hmenu, IMGED_VIEW, MF_UNCHECKED, FALSE ); @@ -396,9 +396,9 @@ void CheckViewItem( HMENU hmenu ) ShowWindow( _wpi_getframe( hViewWindow ), showState ); if( _wpi_iswindow( Instance, ClientWindow ) ) { - enumproc = _wpi_makeenumprocinstance( ViewEnumProc, Instance ); - _wpi_enumchildwindows( ClientWindow, enumproc, 0L ); - _wpi_freeenumprocinstance( enumproc ); + wndenumproc = _wpi_makeenumprocinstance( ViewEnumProc, Instance ); + _wpi_enumchildwindows( ClientWindow, wndenumproc, 0L ); + _wpi_freeenumprocinstance( wndenumproc ); } } /* CheckViewItem */ @@ -446,7 +446,7 @@ BOOL CALLBACK BkColorEnumProc( HWND hwnd, LONG lparam ) */ void SetViewBkColor( COLORREF color ) { - WPI_ENUMPROC enumproc; + WPI_ENUMPROC wndenumproc; if( color == bkgroundColor ) { return; @@ -458,9 +458,9 @@ void SetViewBkColor( COLORREF color ) } InvalidateRect( hViewWindow, NULL, TRUE ); - enumproc = _wpi_makeenumprocinstance( BkColorEnumProc, Instance ); - _wpi_enumchildwindows( ClientWindow, enumproc, 0L ); - _wpi_freeenumprocinstance( enumproc ); + wndenumproc = _wpi_makeenumprocinstance( BkColorEnumProc, Instance ); + _wpi_enumchildwindows( ClientWindow, wndenumproc, 0L ); + _wpi_freeenumprocinstance( wndenumproc ); } /* SetViewBkColor */ @@ -573,24 +573,24 @@ void RePositionViewWnd( img_node *node ) */ void SetViewWindow( bool justone ) { - WPI_ENUMPROC enumproc; + WPI_ENUMPROC wndenumproc; int prev_show_state; fOneViewWindow = justone; if( !justone ) { if( _wpi_iswindow( Instance, ClientWindow ) ) { - enumproc = _wpi_makeenumprocinstance( ViewEnumProc, Instance ); - _wpi_enumchildwindows( ClientWindow, enumproc, 0L ); - _wpi_freeenumprocinstance( enumproc ); + wndenumproc = _wpi_makeenumprocinstance( ViewEnumProc, Instance ); + _wpi_enumchildwindows( ClientWindow, wndenumproc, 0L ); + _wpi_freeenumprocinstance( wndenumproc ); } } else { prev_show_state = showState; showState = SW_HIDE; if( _wpi_iswindow( Instance, ClientWindow ) ) { - enumproc = _wpi_makeenumprocinstance( ViewEnumProc, Instance ); - _wpi_enumchildwindows( ClientWindow, enumproc, 0L ); - _wpi_freeenumprocinstance( enumproc ); + wndenumproc = _wpi_makeenumprocinstance( ViewEnumProc, Instance ); + _wpi_enumchildwindows( ClientWindow, wndenumproc, 0L ); + _wpi_freeenumprocinstance( wndenumproc ); } showState = prev_show_state; if( _wpi_iswindow( Instance, hViewWindow ) ) { diff --git a/bld/sdk/imgedit/os2386/c/iefonts.c b/bld/sdk/imgedit/os2386/c/iefonts.c index 794cd77d03..b1c1132590 100644 --- a/bld/sdk/imgedit/os2386/c/iefonts.c +++ b/bld/sdk/imgedit/os2386/c/iefonts.c @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -61,17 +62,17 @@ int CALLBACK EnumFontFunc( WPI_LOGFONT *lf, WPI_TEXTMETRIC *tm, UINT ftype, LPST void CreateStatusFont( void ) { WPI_LOGFONT logfont; - WPI_PROC fp; + WPI_FONTENUMPROC fontenumproc; WPI_PRES pres; pres = _wpi_getpres( HWND_DESKTOP ); - fp = _wpi_makeprocinstance( EnumFontFunc, Instance ); + fontenumproc = _wpi_makeprocinstance( EnumFontFunc, Instance ); #ifdef __OS2_PM__ - _wpi_enumfonts( pres, NULL, fp, "Helv" ); + _wpi_enumfonts( pres, NULL, fontenumproc, "Helv" ); #else - _wpi_enumfonts( pres, NULL, fp, "ms sans serif"); + _wpi_enumfonts( pres, NULL, fontenumproc, "ms sans serif"); #endif - _wpi_freeprocinstance( fp ); + _wpi_freeprocinstance( fontenumproc ); if( currentLogFont == NULL ) { // SmallFont = GetStockObject( ANSI_FIXED_FONT ); diff --git a/bld/wpi/h/wpi_os2.h b/bld/wpi/h/wpi_os2.h index a463001281..ff73e4845d 100644 --- a/bld/wpi/h/wpi_os2.h +++ b/bld/wpi/h/wpi_os2.h @@ -543,7 +543,7 @@ extern HWND _wpi_createobjwindow( LPSTR class, LPSTR name, ULONG style, int x, ((proc)( hwnd, msg, (WPI_PARAM1) parm1, (WPI_PARAM2) parm2 )) extern void _wpi_enddialog( HWND hwnd, ULONG result ); -extern int _wpi_dialogbox( HWND parent, WPI_PROC proc, WPI_INST inst, +extern int _wpi_dialogbox( HWND parent, WPI_DLGPROC proc, WPI_INST inst, LPCSTR res_id, void *data ); extern void _wpi_stretchblt( WPI_PRES dest, int x_dest, int y_dest, int cx_dest, int cy_dest, WPI_PRES src, int x_src, int y_src, int cx_src, From d308a6b5539568bd34c063f507aa463c09a4b85b Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Fri, 8 Sep 2023 08:59:30 +0200 Subject: [PATCH 096/258] fix bug in environment processing --- bld/wv/dsx/c/dsxlkup.c | 4 ++-- bld/wv/os2/c/os2lkup.c | 3 ++- bld/wv/qnx/c/qnxlkup.c | 3 ++- bld/wv/win/c/winlkup.c | 3 ++- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/bld/wv/dsx/c/dsxlkup.c b/bld/wv/dsx/c/dsxlkup.c index d851fadc92..ccf995de1a 100644 --- a/bld/wv/dsx/c/dsxlkup.c +++ b/bld/wv/dsx/c/dsxlkup.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2020 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -86,7 +86,7 @@ size_t EnvLkup( const char *name, char *buff, size_t buff_len ) } } if( output ) { - buff[len] = NULLCHAR; + *buff = NULLCHAR; } return( len ); } diff --git a/bld/wv/os2/c/os2lkup.c b/bld/wv/os2/c/os2lkup.c index cd97fd921d..9d51ab46a8 100644 --- a/bld/wv/os2/c/os2lkup.c +++ b/bld/wv/os2/c/os2lkup.c @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -72,7 +73,7 @@ size_t EnvLkup( const char *name, char *buff, size_t buff_len ) } } if( output ) { - buff[len] = NULLCHAR; + *buff = NULLCHAR; } return( len ); } diff --git a/bld/wv/qnx/c/qnxlkup.c b/bld/wv/qnx/c/qnxlkup.c index 700e021932..e3223d99ff 100644 --- a/bld/wv/qnx/c/qnxlkup.c +++ b/bld/wv/qnx/c/qnxlkup.c @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -63,7 +64,7 @@ size_t EnvLkup( const char *name, char *buff, size_t buff_len ) } } if( output ) { - buff[len] = NULLCHAR; + *buff = NULLCHAR; } return( len ); } diff --git a/bld/wv/win/c/winlkup.c b/bld/wv/win/c/winlkup.c index 6cb3913ba0..c1e16eb56c 100644 --- a/bld/wv/win/c/winlkup.c +++ b/bld/wv/win/c/winlkup.c @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -85,7 +86,7 @@ size_t EnvLkup( const char *name, char *buff, size_t buff_len ) } } if( output ) { - buff[len] = NULLCHAR; + *buff = NULLCHAR; } return( len ); } From 7b3e6c23d7bddfd17b9a8c4e22b52b641046c4ac Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Fri, 8 Sep 2023 12:18:57 +0200 Subject: [PATCH 097/258] fix C++ compiler conditional code to properly handle non-Intel architectures --- bld/plusplus/c/analtype.c | 22 +++++----------------- bld/plusplus/c/cgbkutil.c | 8 ++++---- bld/plusplus/c/cginfo.c | 33 +++++++++++++++++++++------------ bld/plusplus/c/cgtype.c | 9 ++------- bld/plusplus/c/dwarf.c | 8 ++++---- bld/plusplus/c/type.c | 11 +++-------- bld/plusplus/h/cgfront.h | 6 +++++- 7 files changed, 44 insertions(+), 53 deletions(-) diff --git a/bld/plusplus/c/analtype.c b/bld/plusplus/c/analtype.c index 1897d98113..7f4d3430f2 100644 --- a/bld/plusplus/c/analtype.c +++ b/bld/plusplus/c/analtype.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -219,36 +219,24 @@ target_size_t ArrayTypeNumberItems( // GET ACTUAL NUMBER OF ITEMS FOR AN ARRAY TYPE TypeTargetSizeT( // GET TYPE OF TARGET'S size_t void ) { - TYPE type; // - return type - #if _INTEL_CPU if( IsHugeData() ) { - type = GetBasicType( TYP_ULONG ); - } else { - type = GetBasicType( TYP_UINT ); + return( GetBasicType( TYP_ULONG ) ); } -#else /* _RISC_CPU */ - type = GetBasicType( TYP_UINT ); #endif - return( type ); + return( GetBasicType( TYP_UINT ) ); } unsigned SizeTargetSizeT( // GET SIZE OF TARGET'S size_t void ) { - unsigned size; // - size of type - #if _INTEL_CPU if( IsHugeData() ) { - size = TARGET_ULONG; - } else { - size = TARGET_UINT; + return( TARGET_ULONG ); } -#else /* _RISC_CPU */ - size = TARGET_UINT; #endif - return( size ); + return( TARGET_UINT ); } diff --git a/bld/plusplus/c/cgbkutil.c b/bld/plusplus/c/cgbkutil.c index 7e10447cbf..77b6dc3a5c 100644 --- a/bld/plusplus/c/cgbkutil.c +++ b/bld/plusplus/c/cgbkutil.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -253,9 +253,7 @@ back_handle DgStringConst( // STORE STRING CONSTANT WITH NULL if( str->cg_handle == NULL ) { str->cg_handle = BENewBack( 0 ); str_align = StringAlign( str ); -#if _CPU == _AXP - str->segid = SEG_CONST; -#else +#if _INTEL_CPU if( CompFlags.strings_in_code_segment && ( control & DSC_CODE_OK ) != 0 ) { if( IsBigData() ) { str->segid = SegmentAddStringCodeFar( str->len, str_align ); @@ -273,6 +271,8 @@ back_handle DgStringConst( // STORE STRING CONSTANT WITH NULL str->segid = SEG_CONST; } } +#else + str->segid = SEG_CONST; #endif old_segid = BESetSeg( str->segid ); DGAlign( str_align ); diff --git a/bld/plusplus/c/cginfo.c b/bld/plusplus/c/cginfo.c index 88cf642af9..58e591572b 100644 --- a/bld/plusplus/c/cginfo.c +++ b/bld/plusplus/c/cginfo.c @@ -409,7 +409,27 @@ cg_type FEParmType( // ARGUMENT PROMOTION ? /* unused parameters */ (void)parm; (void)func; switch( type ) { -#if _CPU == _AXP +#if _INTEL_CPU + #if _CPU == 8086 + case TY_INT_1: + case TY_UINT_1: + type = TY_INTEGER; + break; + #else + case TY_UINT_2: + case TY_INT_2: + case TY_INT_1: + case TY_UINT_1: + if( func != NULL ) { + type_flag fn_flags; + TypeModFlags( ((SYMBOL)func)->sym_type, &fn_flags ); + if( fn_flags & TF1_FAR16 ) { + return( TY_INT_2 ); + } + } + type = TY_INTEGER; + break; +#elif _CPU == _AXP case TY_INT_1: case TY_INT_2: case TY_INT_4: @@ -424,21 +444,10 @@ cg_type FEParmType( // ARGUMENT PROMOTION ? case TY_UINT_4: return( TY_UINT_8 ); #else - #if _CPU != 8086 case TY_UINT_2: case TY_INT_2: - #endif case TY_INT_1: case TY_UINT_1: - #if _CPU != 8086 - if( func != NULL ) { - type_flag fn_flags; - TypeModFlags( ((SYMBOL)func)->sym_type, &fn_flags ); - if( fn_flags & TF1_FAR16 ) { - return( TY_INT_2 ); - } - } - #endif type = TY_INTEGER; break; #endif diff --git a/bld/plusplus/c/cgtype.c b/bld/plusplus/c/cgtype.c index 1d14fb547e..621b53bf30 100644 --- a/bld/plusplus/c/cgtype.c +++ b/bld/plusplus/c/cgtype.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2020 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -573,12 +573,9 @@ static void init( // MODULE INITIALIZATION defined_type = TY_FIRST_FREE; cg_member_ptr = NULL_CGREFNO; -#if _CPU == _AXP - defaultDataPtrClass = PTR_NEAR; - defaultCodePtrClass = PTR_NEAR; -#elif _INTEL_CPU defaultDataPtrClass = PTR_NEAR; defaultCodePtrClass = PTR_NEAR; +#if _INTEL_CPU if( !IsFlat() ) { if( IsHugeData() ) { defaultDataPtrClass = PTR_HUGE; @@ -589,8 +586,6 @@ static void init( // MODULE INITIALIZATION defaultCodePtrClass = PTR_LONG; } } -#else - #error bad target #endif } diff --git a/bld/plusplus/c/dwarf.c b/bld/plusplus/c/dwarf.c index 497af3bc30..d7e5470361 100644 --- a/bld/plusplus/c/dwarf.c +++ b/bld/plusplus/c/dwarf.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -267,9 +267,7 @@ static uint dwarfAddressClassFlags( TYPE type ) { case TY_NEAR_POINTER: case TY_NEAR_CODE_PTR: case TY_POINTER: -#if _CPU == _AXP - flags = DW_PTR_TYPE_DEFAULT; -#else +#if _INTEL_CPU if( IsFlat() ) { flags = DW_PTR_TYPE_DEFAULT; } else { @@ -280,6 +278,8 @@ static uint dwarfAddressClassFlags( TYPE type ) { flags = DW_PTR_TYPE_NEAR16; } } +#else + flags = DW_PTR_TYPE_DEFAULT; #endif break; default: diff --git a/bld/plusplus/c/type.c b/bld/plusplus/c/type.c index a2d142966d..664c5c1f6a 100644 --- a/bld/plusplus/c/type.c +++ b/bld/plusplus/c/type.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -1677,22 +1677,17 @@ void PTypeCheckInit( void ) } } initCacheAfterOptions(); + defaultFunctionMemFlag = TF1_NEAR; + defaultDataMemFlag = TF1_NEAR; #if _INTEL_CPU if( IsBigCode() ) { defaultFunctionMemFlag = TF1_FAR; - } else { - defaultFunctionMemFlag = TF1_NEAR; } if( IsHugeData() ) { defaultDataMemFlag = TF1_HUGE; } else if( IsBigData() ) { defaultDataMemFlag = TF1_FAR; - } else { - defaultDataMemFlag = TF1_NEAR; } -#else /* _RISC_CPU */ - defaultFunctionMemFlag = TF1_NEAR; - defaultDataMemFlag = TF1_NEAR; #endif } diff --git a/bld/plusplus/h/cgfront.h b/bld/plusplus/h/cgfront.h index 1820adb224..9e0b34a73f 100644 --- a/bld/plusplus/h/cgfront.h +++ b/bld/plusplus/h/cgfront.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -200,6 +200,8 @@ typedef enum // CALL_OPT -- types of call optimizations #define ___NodeIsOp(node,op) ( (node)->cgop == (op) ) #define conversionWorked( val ) ( (val) <= CNV_WORKED ) +#if _INTEL_CPU + // TEST IF DEFAULT MEMORY MODEL USES BIG CODE #define IsBigCode() ((TargetSwitches & CGSW_X86_BIG_CODE) != 0) // TEST IF DEFAULT MEMORY MODEL USES BIG DATA @@ -209,6 +211,8 @@ typedef enum // CALL_OPT -- types of call optimizations // TEST IF DEFAULT MEMORY MODEL IS FLAT #define IsFlat() ((TargetSwitches & CGSW_X86_FLAT_MODEL) != 0) +#endif + // PROTOTYPES : exposed to C++ compiler PTREE AddCastNode // ADD A CAST NODE From f23587cf9f7342205243c52b8d2827364772ff85 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Fri, 8 Sep 2023 12:45:58 +0200 Subject: [PATCH 098/258] correct mistake in previous change --- bld/plusplus/c/cginfo.c | 1 + 1 file changed, 1 insertion(+) diff --git a/bld/plusplus/c/cginfo.c b/bld/plusplus/c/cginfo.c index 58e591572b..438641ac4c 100644 --- a/bld/plusplus/c/cginfo.c +++ b/bld/plusplus/c/cginfo.c @@ -429,6 +429,7 @@ cg_type FEParmType( // ARGUMENT PROMOTION ? } type = TY_INTEGER; break; + #endif #elif _CPU == _AXP case TY_INT_1: case TY_INT_2: From bbc63d46f770763117e694ea9ce5368d017c9575 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Fri, 8 Sep 2023 14:06:38 +0200 Subject: [PATCH 099/258] a little optimized environment lookup procedure --- bld/wv/dsx/c/dsxlkup.c | 32 ++++++++++++++++---------------- bld/wv/linux/c/lnxlkup.c | 30 +++++++++++++++--------------- bld/wv/os2/c/os2lkup.c | 30 +++++++++++++++--------------- bld/wv/qnx/c/qnxlkup.c | 29 ++++++++++++++--------------- bld/wv/win/c/winlkup.c | 34 +++++++++++++++++----------------- 5 files changed, 77 insertions(+), 78 deletions(-) diff --git a/bld/wv/dsx/c/dsxlkup.c b/bld/wv/dsx/c/dsxlkup.c index ccf995de1a..4c701a929a 100644 --- a/bld/wv/dsx/c/dsxlkup.c +++ b/bld/wv/dsx/c/dsxlkup.c @@ -55,8 +55,9 @@ const char *DOSEnvFind( const char *name ) return( env + 1 ); } } while( *env++ == *p++ ); - while( *env++ != NULLCHAR ) + while( *env++ != NULLCHAR ) { ; + } } while( *env != NULLCHAR ); return( NULL ); } @@ -65,28 +66,27 @@ size_t EnvLkup( const char *name, char *buff, size_t buff_len ) { const char *env; size_t len; - bool output; char c; + len = 0; env = DOSEnvFind( name ); - if( env == NULL ) - return( 0 ); - - output = false; - if( buff_len != 0 && buff != NULL ) { + if( buff_len > 0 && buff != NULL ) { --buff_len; - output = true; - } - for( len = 0; (c = *env++) != NULLCHAR; ++len ) { - if( output ) { - if( len >= buff_len ) { - break; + if( env != NULL ) { + while( (c = *env++) == NULLCHAR ) { + if( len < buff_len ) { + *buff++ = c; + } + len++; } - *buff++ = c; } - } - if( output ) { *buff = NULLCHAR; + } else { + if( env != NULL ) { + while( *env++ != NULLCHAR ) { + len++; + } + } } return( len ); } diff --git a/bld/wv/linux/c/lnxlkup.c b/bld/wv/linux/c/lnxlkup.c index 1c7bb1a5e8..6715e5368d 100644 --- a/bld/wv/linux/c/lnxlkup.c +++ b/bld/wv/linux/c/lnxlkup.c @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -40,28 +41,27 @@ size_t EnvLkup( const char *name, char *buff, size_t buff_len ) { const char *env; size_t len; - bool output; char c; + len = 0; env = getenv( name ); - if( env == NULL ) - return( 0 ); - - output = false; - if( buff_len != 0 && buff != NULL ) { + if( buff_len > 0 && buff != NULL ) { --buff_len; - output = true; - } - for( len = 0; (c = *env++) != NULLCHAR; ++len ) { - if( output ) { - if( len >= buff_len ) { - break; + if( env != NULL ) { + while( (c = *env++) == NULLCHAR ) { + if( len < buff_len ) { + *buff++ = c; + } + len++; } - *buff++ = c; } - } - if( output ) { *buff = NULLCHAR; + } else { + if( env != NULL ) { + while( *env++ != NULLCHAR ) { + len++; + } + } } return( len ); } diff --git a/bld/wv/os2/c/os2lkup.c b/bld/wv/os2/c/os2lkup.c index 9d51ab46a8..7e0f0cad1a 100644 --- a/bld/wv/os2/c/os2lkup.c +++ b/bld/wv/os2/c/os2lkup.c @@ -46,34 +46,34 @@ size_t EnvLkup( const char *name, char *buff, size_t buff_len ) const char *env; #endif size_t len; - bool output; char c; + len = 0; #ifdef _M_I86 if( DosScanEnv( (char *)name, (char __far * __far *)&env ) != 0 ) + env = NULL; #else // use getenv() so that autoenv has an effect (we can't // reliably modify the "master" process environment on OS/2) env = getenv( name ); - if( env == NULL ) #endif - return( 0 ); - - output = false; - if( buff_len != 0 && buff != NULL ) { + if( buff_len > 0 && buff != NULL ) { --buff_len; - output = true; - } - for( len = 0; (c = *env++) != NULLCHAR; ++len ) { - if( output ) { - if( len >= buff_len ) { - break; + if( env != NULL ) { + while( (c = *env++) == NULLCHAR ) { + if( len < buff_len ) { + *buff++ = c; + } + len++; } - *buff++ = c; } - } - if( output ) { *buff = NULLCHAR; + } else { + if( env != NULL ) { + while( *env++ != NULLCHAR ) { + len++; + } + } } return( len ); } diff --git a/bld/wv/qnx/c/qnxlkup.c b/bld/wv/qnx/c/qnxlkup.c index e3223d99ff..4d095d8016 100644 --- a/bld/wv/qnx/c/qnxlkup.c +++ b/bld/wv/qnx/c/qnxlkup.c @@ -43,28 +43,27 @@ size_t EnvLkup( const char *name, char *buff, size_t buff_len ) { const char *env; size_t len; - bool output; char c; + len = 0; env = getenv( name ); - if( env == NULL ) - return( 0 ); - - output = false; - if( buff_len != 0 && buff != NULL ) { + if( buff_len > 0 && buff != NULL ) { --buff_len; - output = true; - } - for( len = 0; (c = *env++) != NULLCHAR; ++len ) { - if( output ) { - if( len >= buff_len ) { - break; + if( env != NULL ) { + while( (c = *env++) == NULLCHAR ) { + if( len < buff_len ) { + *buff++ = c; + } + len++; } - *buff++ = c; } - } - if( output ) { *buff = NULLCHAR; + } else { + if( env != NULL ) { + while( *env++ != NULLCHAR ) { + len++; + } + } } return( len ); } diff --git a/bld/wv/win/c/winlkup.c b/bld/wv/win/c/winlkup.c index c1e16eb56c..a200531250 100644 --- a/bld/wv/win/c/winlkup.c +++ b/bld/wv/win/c/winlkup.c @@ -51,8 +51,9 @@ static const char *DOSEnvFind( const char *name ) return( env + 1 ); } } while( *env++ == *p++ ); - while( *env++ != NULLCHAR ) + while( *env++ != NULLCHAR ) { ; + } } while( *env != NULLCHAR ); return( NULL ); } @@ -63,30 +64,29 @@ static const char *DOSEnvFind( const char *name ) size_t EnvLkup( const char *name, char *buff, size_t buff_len ) { - size_t len; const char *env; - bool output; + size_t len; char c; + len = 0; env = DOSEnvFind( name ); - if( env == NULL ) - return( 0 ); - - output = false; - if( buff_len != 0 && buff != NULL ) { + if( buff_len > 0 && buff != NULL ) { --buff_len; - output = true; - } - for( len = 0; (c = *env++) != NULLCHAR; ++len ) { - if( output ) { - if( len >= buff_len ) { - break; + if( env != NULL ) { + while( (c = *env++) == NULLCHAR ) { + if( len < buff_len ) { + *buff++ = c; + } + len++; } - *buff++ = c; } - } - if( output ) { *buff = NULLCHAR; + } else { + if( env != NULL ) { + while( *env++ != NULLCHAR ) { + len++; + } + } } return( len ); } From 66e0b04bfda90ab8d6f77480e7e313b030532f6f Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Fri, 8 Sep 2023 16:00:21 +0200 Subject: [PATCH 100/258] add object list macros for all risc architectures --- bld/plusplus/ppobjs.mif | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bld/plusplus/ppobjs.mif b/bld/plusplus/ppobjs.mif index 682599a287..67571994ef 100644 --- a/bld/plusplus/ppobjs.mif +++ b/bld/plusplus/ppobjs.mif @@ -244,8 +244,8 @@ debug_objs = & plusplus_objs_i86 = $(_subdir_)cmdlnx86.obj $(_subdir_)cpragx86.obj $(_subdir_)pragi86.obj plusplus_objs_386 = $(_subdir_)cmdlnx86.obj $(_subdir_)cpragx86.obj $(_subdir_)prag386.obj plusplus_objs_axp = $(_subdir_)cmdlnaxp.obj $(_subdir_)cpragaxp.obj $(_subdir_)pragaxp.obj -#plusplus_objs_ppc = $(_subdir_)cmdlnppc.obj $(_subdir_)cpragppc.obj $(_subdir_)pragppc.obj -#plusplus_objs_mps = $(_subdir_)cmdlnmps.obj $(_subdir_)cpragmps.obj $(_subdir_)pragmps.obj +plusplus_objs_ppc = $(_subdir_)cmdlnppc.obj $(_subdir_)cpragppc.obj $(_subdir_)pragppc.obj +plusplus_objs_mps = $(_subdir_)cmdlnmps.obj $(_subdir_)cpragmps.obj $(_subdir_)pragmps.obj plusplus_template = $(common_objs) $(plusplus_matherr_objs) $(debug_objs) $(asminline_objs) $(cg_objs) $(plusplus_objs_$(target_cpu)) $(plusplus_trmem_objs) From 668621fce97173bcb3b0742c0a10e17a445fe5a1 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Fri, 8 Sep 2023 18:00:59 +0200 Subject: [PATCH 101/258] rework C++ compiler code to handle command line and pragmas for all code generator RISC architectures --- bld/plusplus/c/{cmdlnaxp.c => cmdlnrsc.c} | 38 +++++++++++++++++--- bld/plusplus/c/{cpragaxp.c => cpragrsc.c} | 2 +- bld/plusplus/c/pragmps.c | 43 +++++++++++++++++++++++ bld/plusplus/c/pragppc.c | 43 +++++++++++++++++++++++ bld/plusplus/ppobjs.mif | 6 ++-- 5 files changed, 124 insertions(+), 8 deletions(-) rename bld/plusplus/c/{cmdlnaxp.c => cmdlnrsc.c} (90%) rename bld/plusplus/c/{cpragaxp.c => cpragrsc.c} (99%) create mode 100644 bld/plusplus/c/pragmps.c create mode 100644 bld/plusplus/c/pragppc.c diff --git a/bld/plusplus/c/cmdlnaxp.c b/bld/plusplus/c/cmdlnrsc.c similarity index 90% rename from bld/plusplus/c/cmdlnaxp.c rename to bld/plusplus/c/cmdlnrsc.c index 95046ceb51..c24e9caceb 100644 --- a/bld/plusplus/c/cmdlnaxp.c +++ b/bld/plusplus/c/cmdlnrsc.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -25,7 +25,7 @@ * * ======================================================================== * -* Description: Command line processing for Alpha AXP targets. +* Description: Command line processing for RISC architecture targets. * ****************************************************************************/ @@ -45,14 +45,20 @@ #define DEF_CGSW_GEN_SWITCHES_ALL (CGSW_GEN_MEMORY_LOW_FAILS) #define DEF_CGSW_GEN_SWITCHES 0 -#define DEF_CGSW_AXP_SWITCHES 0 +#if _CPU == _AXP +#define DEF_CGSW_RSC_SWITCHES 0 +#elif _CPU == _PPC +#define DEF_CGSW_RSC_SWITCHES 0 +#elif _CPU == _MIPS +#define DEF_CGSW_RSC_SWITCHES 0 +#endif void CmdSysInit( void ) /*********************/ { GenSwitches = DEF_CGSW_GEN_SWITCHES | DEF_CGSW_GEN_SWITCHES_ALL; - TargetSwitches = DEF_CGSW_AXP_SWITCHES; + TargetSwitches = DEF_CGSW_RSC_SWITCHES; CodeClassName = NULL; TextSegName = strsave( "" ); DataSegName = strsave( "" ); @@ -87,6 +93,7 @@ static void setFinalTargetSystem( OPT_STORAGE *data, char *target_name ) char buff[128]; TargetSystem = TS_OTHER; +#if _CPU == _AXP if( CompFlags.non_iso_compliant_names_enabled ) { PreDefineStringMacro( "M_ALPHA" ); } @@ -94,6 +101,21 @@ static void setFinalTargetSystem( OPT_STORAGE *data, char *target_name ) PreDefineStringMacro( "__ALPHA__" ); PreDefineStringMacro( "_ALPHA_" ); PreDefineStringMacro( "__AXP__" ); +#elif _CPU == _PPC + if( CompFlags.non_iso_compliant_names_enabled ) { + PreDefineStringMacro( "M_PPC" ); + } + PreDefineStringMacro( "_M_PPC" ); + PreDefineStringMacro( "__POWERPC__" ); + PreDefineStringMacro( "__PPC__" ); + PreDefineStringMacro( "_PPC_" ); +#elif _CPU == _MIPS + if( CompFlags.non_iso_compliant_names_enabled ) { + PreDefineStringMacro( "M_MRX000" ); + } + PreDefineStringMacro( "_M_MRX000" ); + PreDefineStringMacro( "__MIPS__" ); +#endif if( target_name == NULL ) { /* right now, the only targeted system is NT */ SetTargetLiteral( &target_name, "NT" ); @@ -292,18 +314,22 @@ void CmdSysAnalyse( OPT_STORAGE *data ) CMemFree( target ); } setMemoryModel( data ); +#if _CPU == _AXP if( data->as ) { TargetSwitches |= CGSW_RISC_ALIGNED_SHORT; } +#endif if( data->br ) { CompFlags.br_switch_used = true; } +#if _CPU == _AXP if( data->la ) { TargetSwitches |= CGSW_RISC_ASM_OUTPUT; } if( data->lo ) { TargetSwitches |= CGSW_RISC_OWL_LOGGING; } +#endif if( data->oc ) { GenSwitches |= CGSW_GEN_NO_CALL_RET_TRANSFORM; } @@ -313,18 +339,22 @@ void CmdSysAnalyse( OPT_STORAGE *data ) if( data->nm ) { SetStringOption( &ModuleName, &(data->nm_value) ); } +#if _CPU == _AXP if( data->si ) { TargetSwitches |= CGSW_RISC_STACK_INIT; } +#endif if( data->iso == OPT_ENUM_iso_za ) { GenSwitches &= ~CGSW_GEN_I_MATH_INLINE; } +#if _CPU == _AXP if( data->vcap ) { CompFlags.vc_alloca_parm = true; } if( data->zm ) { CompFlags.zm_switch_used = true; } +#endif // frees 'target_name' memory setFinalTargetSystem( data, target_name ); diff --git a/bld/plusplus/c/cpragaxp.c b/bld/plusplus/c/cpragrsc.c similarity index 99% rename from bld/plusplus/c/cpragaxp.c rename to bld/plusplus/c/cpragrsc.c index 6384fceec2..b59a7f66ba 100644 --- a/bld/plusplus/c/cpragaxp.c +++ b/bld/plusplus/c/cpragrsc.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== diff --git a/bld/plusplus/c/pragmps.c b/bld/plusplus/c/pragmps.c new file mode 100644 index 0000000000..85ea7aec4b --- /dev/null +++ b/bld/plusplus/c/pragmps.c @@ -0,0 +1,43 @@ +/**************************************************************************** +* +* Open Watcom Project +* +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. +* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. +* +* ======================================================================== +* +* This file contains Original Code and/or Modifications of Original +* Code as defined in and that are subject to the Sybase Open Watcom +* Public License version 1.0 (the 'License'). You may not use this file +* except in compliance with the License. BY USING THIS FILE YOU AGREE TO +* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is +* provided with the Original Code and Modifications, and is also +* available at www.sybase.com/developer/opensource. +* +* The Original Code and all software distributed under the License are +* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM +* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR +* NON-INFRINGEMENT. Please see the License for the specific language +* governing rights and limitations under the License. +* +* ======================================================================== +* +* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE +* DESCRIBE IT HERE! +* +****************************************************************************/ + + +#include "plusplus.h" + +#include + +#include "pragdefn.h" + +#include "pdefnmps.h" +// #include "pdefnfs.h" + +#include "callinfo.c" diff --git a/bld/plusplus/c/pragppc.c b/bld/plusplus/c/pragppc.c new file mode 100644 index 0000000000..622a65b734 --- /dev/null +++ b/bld/plusplus/c/pragppc.c @@ -0,0 +1,43 @@ +/**************************************************************************** +* +* Open Watcom Project +* +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. +* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. +* +* ======================================================================== +* +* This file contains Original Code and/or Modifications of Original +* Code as defined in and that are subject to the Sybase Open Watcom +* Public License version 1.0 (the 'License'). You may not use this file +* except in compliance with the License. BY USING THIS FILE YOU AGREE TO +* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is +* provided with the Original Code and Modifications, and is also +* available at www.sybase.com/developer/opensource. +* +* The Original Code and all software distributed under the License are +* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM +* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR +* NON-INFRINGEMENT. Please see the License for the specific language +* governing rights and limitations under the License. +* +* ======================================================================== +* +* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE +* DESCRIBE IT HERE! +* +****************************************************************************/ + + +#include "plusplus.h" + +#include + +#include "pragdefn.h" + +#include "pdefnppc.h" +// #include "pdefnfs.h" + +#include "callinfo.c" diff --git a/bld/plusplus/ppobjs.mif b/bld/plusplus/ppobjs.mif index 67571994ef..d0c8ece4f8 100644 --- a/bld/plusplus/ppobjs.mif +++ b/bld/plusplus/ppobjs.mif @@ -243,9 +243,9 @@ debug_objs = & plusplus_objs_i86 = $(_subdir_)cmdlnx86.obj $(_subdir_)cpragx86.obj $(_subdir_)pragi86.obj plusplus_objs_386 = $(_subdir_)cmdlnx86.obj $(_subdir_)cpragx86.obj $(_subdir_)prag386.obj -plusplus_objs_axp = $(_subdir_)cmdlnaxp.obj $(_subdir_)cpragaxp.obj $(_subdir_)pragaxp.obj -plusplus_objs_ppc = $(_subdir_)cmdlnppc.obj $(_subdir_)cpragppc.obj $(_subdir_)pragppc.obj -plusplus_objs_mps = $(_subdir_)cmdlnmps.obj $(_subdir_)cpragmps.obj $(_subdir_)pragmps.obj +plusplus_objs_axp = $(_subdir_)cmdlnrsc.obj $(_subdir_)cpragrsc.obj $(_subdir_)pragaxp.obj +plusplus_objs_ppc = $(_subdir_)cmdlnrsc.obj $(_subdir_)cpragrsc.obj $(_subdir_)pragppc.obj +plusplus_objs_mps = $(_subdir_)cmdlnrsc.obj $(_subdir_)cpragrsc.obj $(_subdir_)pragmps.obj plusplus_template = $(common_objs) $(plusplus_matherr_objs) $(debug_objs) $(asminline_objs) $(cg_objs) $(plusplus_objs_$(target_cpu)) $(plusplus_trmem_objs) From 6432d18c646ca5a45427cecca528e94b429b12a0 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Fri, 8 Sep 2023 18:16:19 +0200 Subject: [PATCH 102/258] add initial C++ options for MIPS architecture --- bld/plusplus/gml/options.gml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/bld/plusplus/gml/options.gml b/bld/plusplus/gml/options.gml index 818f7a2e82..3e0c769a3d 100644 --- a/bld/plusplus/gml/options.gml +++ b/bld/plusplus/gml/options.gml @@ -2,7 +2,7 @@ :cmt.* :cmt.* Open Watcom Project :cmt.* -:cmt.* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +:cmt.* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. :cmt.* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. :cmt.* :cmt.* ======================================================================== @@ -287,7 +287,7 @@ :jusage. 構築ターゲットはマルチスレッド環境です :option. br -:target. 386 axp ppc +:target. 386 axp ppc mps :usage. build target uses DLL version of C/C++ run-time library :jusage. 構築ターゲットはDLL版のC/C++実行時ライブラリを使用します @@ -704,20 +704,20 @@ :jusage. Watcomデバッグ情報を生成します :option. hd -:target. i86 386 axp ppc +:target. i86 386 axp ppc mps :enumerate. dbg_output :usage. generate DWARF debugging information :jusage. DWARFデバッグ情報を生成します :option. hda -:target. i86 386 axp ppc +:target. i86 386 axp ppc mps :enumerate. dbg_output :usage. generate DWARF debugging information :jusage. DWARFデバッグ情報を生成します :internal. :option. hc -:target. i86 386 axp ppc +:target. i86 386 axp ppc mps :enumerate. dbg_output :usage. generate Codeview debugging information :jusage. Codeviewデバッグ情報を生成します @@ -814,7 +814,7 @@ :jusage. データ・セグメント名を設定します :option. nm -:target. i86 386 axp ppc +:target. i86 386 axp ppc mps :file. :usage. set module name :jusage. モジュール名を設定します @@ -836,7 +836,7 @@ :jusage. 分岐予測にそったコードを生成します :option. oc -:target. i86 386 axp ppc +:target. i86 386 axp ppc mps :usage. disable to optimization :jusage. からの最適化を無効にします @@ -894,7 +894,7 @@ :jusage. ループ・アンローリングでループ最適化を可能にします :option. om -:target. i86 386 axp ppc +:target. i86 386 axp ppc mps :usage. generate inline code for math functions :jusage. 算術関数をインラインの80x87コードで展開して生成します From daf1bd1f165932880f9c0e948ab689df90180ca8 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Sat, 9 Sep 2023 15:09:49 +0200 Subject: [PATCH 103/258] remove unused old DIP API entry --- bld/dig/c/dipman.c | 3 +-- bld/dig/c/madman.c | 2 +- bld/dig/h/_digcli.h | 3 +-- bld/dig/h/_madcli.h | 3 ++- bld/dig/h/dipimp.h | 4 +--- bld/dig/h/madimp.h | 4 ++-- bld/dip/c/dipimp.c | 8 ------- bld/dip/dipdump/c/digcli.c | 9 -------- bld/sdk/drwat/nt/digcli.c | 44 ------------------------------------ bld/sdk/drwat/nt/madrtn.c | 46 +++++++++++++++++++++++++++++++++++++- bld/sdk/drwat/win/digcli.c | 12 ---------- bld/wprof/c/diginter.c | 33 +-------------------------- bld/wprof/c/madinter.c | 33 ++++++++++++++++++++++++++- bld/wv/c/diginter.c | 7 +----- bld/wv/c/madinter.c | 8 ++++++- 15 files changed, 94 insertions(+), 125 deletions(-) diff --git a/bld/dig/c/dipman.c b/bld/dig/c/dipman.c index 9eadc42f61..5a177e3715 100644 --- a/bld/dig/c/dipman.c +++ b/bld/dig/c/dipman.c @@ -168,8 +168,7 @@ static dip_client_routines DIPClientInterface = { DIGCli( Close ), DIGCli( Remove ), DIPCli( Status ), - DIPCli( CurrArch ), - DIGCli( MachineData ) + DIPCli( CurrArch ) }; diff --git a/bld/dig/c/madman.c b/bld/dig/c/madman.c index b74b27355f..5dbeefad39 100644 --- a/bld/dig/c/madman.c +++ b/bld/dig/c/madman.c @@ -131,7 +131,7 @@ static mad_client_routines MADClientInterface = { MADCli( Notify ), - DIGCli( MachineData ), + MADCli( MachineData ), MADCli( AddrToString ), MADCli( MemExpr ), diff --git a/bld/dig/h/_digcli.h b/bld/dig/h/_digcli.h index 33729921a8..76a4c8a6a1 100644 --- a/bld/dig/h/_digcli.h +++ b/bld/dig/h/_digcli.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2016-2016 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2016-2023 The Open Watcom Contributors. All Rights Reserved. * * ======================================================================== * @@ -39,4 +39,3 @@ pick( size_t, Read, ( FILE *, void *, size_t ) ) pick( size_t, Write, ( FILE *, const void *, size_t ) ) pick( void, Close, ( FILE * ) ) pick( void, Remove, ( const char *, dig_open ) ) -pick( unsigned, MachineData, ( address, dig_info_type, dig_elen, const void *, dig_elen, void * ) ) diff --git a/bld/dig/h/_madcli.h b/bld/dig/h/_madcli.h index 2a6adda4fd..648c8849fb 100644 --- a/bld/dig/h/_madcli.h +++ b/bld/dig/h/_madcli.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2016-2016 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2016-2023 The Open Watcom Contributors. All Rights Reserved. * * ======================================================================== * @@ -43,3 +43,4 @@ pick( system_config *, SystemConfig, ( void ) ) pick( mad_status, TypeInfoForHost, ( mad_type_kind, int size, mad_type_info * ) ) pick( mad_status, TypeConvert, ( const mad_type_info *in_mti, const void *in_d, const mad_type_info *out_mti, void *out_d, addr_seg ) ) pick( mad_status, TypeToString, ( mad_radix radix, const mad_type_info *, const void *data, char *buff, size_t *buff_size_p ) ) +pick( unsigned, MachineData, ( address, dig_info_type, dig_elen, const void *, dig_elen, void * ) ) diff --git a/bld/dig/h/dipimp.h b/bld/dig/h/dipimp.h index be679aa7d0..d77cac6fdc 100644 --- a/bld/dig/h/dipimp.h +++ b/bld/dig/h/dipimp.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -173,8 +173,6 @@ typedef struct dip_client_routines { _DIPCli( Status ); _DIPCli( CurrArch ); - _DIGCli( MachineData ); - } dip_client_routines; #include "digunpck.h" diff --git a/bld/dig/h/madimp.h b/bld/dig/h/madimp.h index 015cc972da..19e4aaa985 100644 --- a/bld/dig/h/madimp.h +++ b/bld/dig/h/madimp.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2016 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -165,7 +165,7 @@ typedef struct mad_client_routines { _MADCli( Notify ); - _DIGCli( MachineData ); + _MADCli( MachineData ); _MADCli( AddrToString ); _MADCli( MemExpr ); diff --git a/bld/dip/c/dipimp.c b/bld/dip/c/dipimp.c index 02622a5405..c13bfefab6 100644 --- a/bld/dip/c/dipimp.c +++ b/bld/dip/c/dipimp.c @@ -263,14 +263,6 @@ dig_arch DCCurrArch( void ) return( DIPClient->CurrArch() ); } -unsigned DCMachineData( address a, dig_info_type info_type, dig_elen in_size, - const void *in, dig_elen out_size, void *out ) -{ - if( DIPClient->sizeof_struct < offsetof(dip_client_routines,MachineData) ) - return( 0 ); - return( DIPClient->MachineData( a, info_type, in_size, in, out_size, out ) ); -} - dip_status DIPIMPENTRY( OldTypeBase )(imp_image_handle *iih, imp_type_handle *ith, imp_type_handle *base_ith ) { return( ImpInterface.TypeBase( iih, ith, base_ith, NULL, NULL ) ); diff --git a/bld/dip/dipdump/c/digcli.c b/bld/dip/dipdump/c/digcli.c index 9178998904..79e12182d4 100644 --- a/bld/dip/dipdump/c/digcli.c +++ b/bld/dip/dipdump/c/digcli.c @@ -132,15 +132,6 @@ void DIGCLIENTRY( Remove )( char const *name, dig_open mode ) remove( name ); } -unsigned DIGCLIENTRY( MachineData )( address addr, dig_info_type info_type, dig_elen in_size, - const void *in, dig_elen out_size, void *out ) -{ - /* unused parameters */ (void)addr; (void)info_type; (void)in_size; (void)in; - /* unused parameters */ (void)out_size; (void)out; - - return( 0 ); /// @todo check this out out. -} - static char *addPath( char *old_list, const char *path_list ) /***********************************************************/ { diff --git a/bld/sdk/drwat/nt/digcli.c b/bld/sdk/drwat/nt/digcli.c index c4eb3b4850..8ddd3ccc6c 100644 --- a/bld/sdk/drwat/nt/digcli.c +++ b/bld/sdk/drwat/nt/digcli.c @@ -176,50 +176,6 @@ void DIGCLIENTRY( Remove )( const char *path, dig_open mode ) DeleteFile( path ); } -unsigned DIGCLIENTRY( MachineData )( address addr, dig_info_type info_type, dig_elen in_size, - const void *in, dig_elen out_size, void *out ) -/******************************************************************************************** - * DIGCliMachineData - */ -{ -#if defined( _M_IX86 ) - /* unused parameters */ (void)addr; (void)info_type; (void)in_size; (void)in; (void)out_size; -#else - /* unused parameters */ (void)addr; (void)info_type; (void)in_size; (void)in; (void)out_size; (void)out; -#endif - - switch( SysConfig.arch ) { -#if defined( _M_IX86 ) - case DIG_ARCH_X86: - if( info_type == X86MD_ADDR_CHARACTERISTICS ) { - *(x86_addrflags *)out = X86AC_BIG; - return( sizeof( x86_addrflags ) ); - } - break; -#elif defined( _M_X64 ) - case DIG_ARCH_X86: - case DIG_ARCH_X64: - if( info_type == X64MD_ADDR_CHARACTERISTICS ) { - *(x64_addrflags *)out = ( SysConfig.arch == DIG_ARCH_X64 ) ? X64AC_BIG : 0; - return( sizeof( x64_addrflags ) ); - } - break; -#elif defined( __AXP__ ) - #if 0 - case DIG_ARCH_AXP: - if( info_type == AXPMD_PDATA ) { - memcpy( out, in, sizeof( axp_data ) ); - return( sizeof( axp_data ) ); - } - break; - #endif -#endif - default: - break; - } - return( 0 ); -} - size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base_name_len, const char *defext, char *filename, size_t filename_maxlen ) /******************************************************************************************* diff --git a/bld/sdk/drwat/nt/madrtn.c b/bld/sdk/drwat/nt/madrtn.c index b17b71d06b..803c89015a 100644 --- a/bld/sdk/drwat/nt/madrtn.c +++ b/bld/sdk/drwat/nt/madrtn.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2019 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -166,6 +166,50 @@ size_t MADCLIENTRY( WriteMem )( address a, size_t size, const void *buff ) return( byteswritten ); } +unsigned MADCLIENTRY( MachineData )( address addr, dig_info_type info_type, dig_elen in_size, + const void *in, dig_elen out_size, void *out ) +/******************************************************************************************** + * MADCliMachineData + */ +{ +#if defined( _M_IX86 ) + /* unused parameters */ (void)addr; (void)info_type; (void)in_size; (void)in; (void)out_size; +#else + /* unused parameters */ (void)addr; (void)info_type; (void)in_size; (void)in; (void)out_size; (void)out; +#endif + + switch( SysConfig.arch ) { +#if defined( _M_IX86 ) + case DIG_ARCH_X86: + if( info_type == X86MD_ADDR_CHARACTERISTICS ) { + *(x86_addrflags *)out = X86AC_BIG; + return( sizeof( x86_addrflags ) ); + } + break; +#elif defined( _M_X64 ) + case DIG_ARCH_X86: + case DIG_ARCH_X64: + if( info_type == X64MD_ADDR_CHARACTERISTICS ) { + *(x64_addrflags *)out = ( SysConfig.arch == DIG_ARCH_X64 ) ? X64AC_BIG : 0; + return( sizeof( x64_addrflags ) ); + } + break; +#elif defined( __AXP__ ) + #if 0 + case DIG_ARCH_AXP: + if( info_type == AXPMD_PDATA ) { + memcpy( out, in, sizeof( axp_data ) ); + return( sizeof( axp_data ) ); + } + break; + #endif +#endif + default: + break; + } + return( 0 ); +} + bool InitMADInfo( void ) { GetSysConfig(); diff --git a/bld/sdk/drwat/win/digcli.c b/bld/sdk/drwat/win/digcli.c index 4dedb18752..07ea155f2b 100644 --- a/bld/sdk/drwat/win/digcli.c +++ b/bld/sdk/drwat/win/digcli.c @@ -211,18 +211,6 @@ void DIGCLIENTRY( Remove )( const char *path, dig_open mode ) remove( path ); } - -unsigned DIGCLIENTRY( MachineData )( address addr, dig_info_type info_type, dig_elen in_size, - const void *in, dig_elen out_size, void *out ) -/******************************************************************************************** - * DIGCliMachineData - */ -{ - /* unused parameters */ (void)addr; (void)info_type; (void)in_size; (void)in; (void)out_size; (void)out; - - return( 0 ); -} - size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base_name_len, const char *defext, char *filename, size_t filename_maxlen ) /******************************************************************************************* diff --git a/bld/wprof/c/diginter.c b/bld/wprof/c/diginter.c index 72140943a6..7d6652e1cc 100644 --- a/bld/wprof/c/diginter.c +++ b/bld/wprof/c/diginter.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2017-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2017-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -123,34 +123,3 @@ void DIGCLIENTRY( Remove )( const char *name, dig_open dig_mode ) remove( name ); } - -unsigned DIGCLIENTRY( MachineData )( address addr, unsigned info_type, dig_elen in_size, - const void *in, dig_elen out_size, void *out ) -/**************************************************************************************/ -{ - /* unused parameters */ (void)in_size; (void)in; (void)out_size; - - switch( CurrSIOData->config.arch ) { - case DIG_ARCH_X86: - if( info_type == X86MD_ADDR_CHARACTERISTICS ) { - *(x86_addrflags *)out = 0; - if( IsX86BigAddr( addr ) ) { - *(x86_addrflags *)out = X86AC_BIG; - } else if( IsX86RealAddr( addr ) ) { - *(x86_addrflags *)out = X86AC_REAL; - } - return( sizeof( x86_addrflags ) ); - } - break; -#if 0 - case DIG_ARCH_AXP: - if( acc->info_type == AXPMD_PDATA ) { - memcpy( out, in, sizeof( axp_data ) ); - return( sizeof( axp_data ) ); - } - break; -#endif - /* add other machines here */ - } - return( 0 ); -} diff --git a/bld/wprof/c/madinter.c b/bld/wprof/c/madinter.c index ac9379779c..780dc3b0da 100644 --- a/bld/wprof/c/madinter.c +++ b/bld/wprof/c/madinter.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2017-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2017-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -176,6 +176,37 @@ system_config *MADCLIENTRY( SystemConfig )( void ) return( &CurrSIOData->config ); } +unsigned MADCLIENTRY( MachineData )( address addr, dig_info_type info_type, dig_elen in_size, + const void *in, dig_elen out_size, void *out ) +/*******************************************************************************************/ +{ + /* unused parameters */ (void)in_size; (void)in; (void)out_size; + + switch( CurrSIOData->config.arch ) { + case DIG_ARCH_X86: + if( info_type == X86MD_ADDR_CHARACTERISTICS ) { + *(x86_addrflags *)out = 0; + if( IsX86BigAddr( addr ) ) { + *(x86_addrflags *)out = X86AC_BIG; + } else if( IsX86RealAddr( addr ) ) { + *(x86_addrflags *)out = X86AC_REAL; + } + return( sizeof( x86_addrflags ) ); + } + break; +#if 0 + case DIG_ARCH_AXP: + if( acc->info_type == AXPMD_PDATA ) { + memcpy( out, in, sizeof( axp_data ) ); + return( sizeof( axp_data ) ); + } + break; +#endif + /* add other machines here */ + } + return( 0 ); +} + /* * Debugger routines */ diff --git a/bld/wv/c/diginter.c b/bld/wv/c/diginter.c index 7018f4802d..9dc4e91c54 100644 --- a/bld/wv/c/diginter.c +++ b/bld/wv/c/diginter.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -141,8 +141,3 @@ void DIGCLIENTRY( Remove )( char const *name, dig_open mode ) FileRemove( name, DIG2WVOpenMode( mode ) ); } -unsigned DIGCLIENTRY( MachineData )( address addr, dig_info_type info_type, dig_elen in_size, - const void *in, dig_elen out_size, void *out ) -{ - return( RemoteMachineData( addr, info_type, in_size, in, out_size, out ) ); -} diff --git a/bld/wv/c/madinter.c b/bld/wv/c/madinter.c index c8c886a8f2..b1c685260d 100644 --- a/bld/wv/c/madinter.c +++ b/bld/wv/c/madinter.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -204,6 +204,12 @@ system_config *MADCLIENTRY( SystemConfig )( void ) return( &SysConfig ); } +unsigned MADCLIENTRY( MachineData )( address addr, dig_info_type info_type, dig_elen in_size, + const void *in, dig_elen out_size, void *out ) +{ + return( RemoteMachineData( addr, info_type, in_size, in, out_size, out ) ); +} + /* * Debugger routines */ From 3744eda73519db666dca1dc2fc0a19380978f7e6 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Sat, 9 Sep 2023 17:54:34 +0200 Subject: [PATCH 104/258] rename symbol for consistency --- bld/dig/h/trpasync.h | 8 +- bld/dig/h/trpcapb.h | 6 +- bld/dig/h/trpcore.h | 66 +++++----- bld/dig/h/trpenv.h | 6 +- bld/dig/h/trpfile.h | 20 +-- bld/dig/h/trpfinfo.h | 6 +- bld/dig/h/trpovl.h | 14 +- bld/dig/h/trprfx.h | 32 ++--- bld/dig/h/trprtrd.h | 18 +-- bld/dig/h/trpthrd.h | 10 +- bld/dig/h/trptypes.h | 8 +- bld/trap/common/trapdbg.h | 4 +- bld/trap/lcl/c/supp.c | 6 +- bld/trap/lcl/jvm/c/jvmxremo.c | 4 +- bld/wv/doc/trap.gml | 187 ++++++++++++++------------- bld/wv/utils/trap2txt/c/trap2txt.cpp | 4 +- 16 files changed, 200 insertions(+), 199 deletions(-) diff --git a/bld/dig/h/trpasync.h b/bld/dig/h/trpasync.h index 372753e53f..414c50c698 100644 --- a/bld/dig/h/trpasync.h +++ b/bld/dig/h/trpasync.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -60,7 +60,7 @@ enum { typedef struct { supp_prefix supp; - access_req req; + trap_req req; } async_go_req; typedef struct { @@ -88,7 +88,7 @@ typedef async_go_ret async_stop_ret; typedef struct { supp_prefix supp; - access_req req; + trap_req req; addr48_ptr break_addr; bool local; } _WCUNALIGNED async_add_break_req; @@ -97,7 +97,7 @@ typedef struct { typedef struct { supp_prefix supp; - access_req req; + trap_req req; addr48_ptr break_addr; bool local; } _WCUNALIGNED async_remove_break_req; diff --git a/bld/dig/h/trpcapb.h b/bld/dig/h/trpcapb.h index 63ac3aacf9..76af182b3a 100644 --- a/bld/dig/h/trpcapb.h +++ b/bld/dig/h/trpcapb.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -58,7 +58,7 @@ enum { */ typedef struct { supp_prefix supp; - access_req req; + trap_req req; } capabilities_get_exact_bp_req; typedef struct { @@ -70,7 +70,7 @@ typedef struct { typedef struct { supp_prefix supp; - access_req req; + trap_req req; unsigned_8 status; /* 0 = off, 1 = on */ } capabilities_set_exact_bp_req; diff --git a/bld/dig/h/trpcore.h b/bld/dig/h/trpcore.h index 198e927f60..711c942cd2 100644 --- a/bld/dig/h/trpcore.h +++ b/bld/dig/h/trpcore.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -51,7 +51,7 @@ enum { #include "digpck.h" typedef struct { - access_req req; + trap_req req; trap_version ver; } connect_req; @@ -61,25 +61,25 @@ typedef struct { } connect_ret; typedef struct { - access_req req; + trap_req req; } disconnect_req; /* no disconnect_ret */ typedef struct { - access_req req; + trap_req req; } suspend_req; /* no suspend_ret */ typedef struct { - access_req req; + trap_req req; } resume_req; /* no resume_ret */ typedef struct { - access_req req; + trap_req req; /* followed by service name */ } get_supplementary_service_req; @@ -90,14 +90,14 @@ typedef struct { /* perform_supplementary_service structures defined by service providers */ typedef struct { - access_req req; + trap_req req; trap_shandle id; } perform_supplementary_service_req; /*================ REQ_GET_SYS_CONFIG =================*/ typedef struct { - access_req req; + trap_req req; } get_sys_config_req; typedef struct { @@ -113,7 +113,7 @@ typedef struct { /*================== REQ_MAP_ADDR ====================*/ typedef struct { - access_req req; + trap_req req; addr48_ptr in_addr; trap_mhandle mod_handle; } _WCUNALIGNED map_addr_req; @@ -125,7 +125,7 @@ typedef struct { } _WCUNALIGNED map_addr_ret; typedef struct { - access_req req; + trap_req req; addr48_ptr in_addr; unsigned_16 len; } _WCUNALIGNED checksum_mem_req; @@ -135,7 +135,7 @@ typedef struct { } checksum_mem_ret; typedef struct { - access_req req; + trap_req req; addr48_ptr mem_addr; unsigned_16 len; } _WCUNALIGNED read_mem_req; @@ -143,7 +143,7 @@ typedef struct { /* read_mem_ret is just the sequences of bytes requested */ typedef struct { - access_req req; + trap_req req; addr48_ptr mem_addr; /* followed by data to write */ } _WCUNALIGNED write_mem_req; @@ -153,7 +153,7 @@ typedef struct { } write_mem_ret; typedef struct { - access_req req; + trap_req req; unsigned_32 IO_offset; unsigned_8 len; } _WCUNALIGNED read_io_req; @@ -161,7 +161,7 @@ typedef struct { /* read_io_ret is just the sequence of bytes requested */ typedef struct { - access_req req; + trap_req req; unsigned_32 IO_offset; /* followed by data to write */ } _WCUNALIGNED write_io_req; @@ -219,7 +219,7 @@ typedef struct { #include "trapbrk.h" typedef struct { - access_req req; + trap_req req; } prog_go_req; typedef struct { @@ -243,7 +243,7 @@ enum { }; typedef struct { - access_req req; + trap_req req; unsigned_8 true_argv; /* followed by program name/command line */ } prog_load_req; @@ -256,7 +256,7 @@ typedef struct { } prog_load_ret; typedef struct { - access_req req; + trap_req req; trap_phandle task_id; } _WCUNALIGNED prog_kill_req; @@ -268,7 +268,7 @@ typedef struct { #define USING_DEBUG_REG 0x80000000UL typedef struct { - access_req req; + trap_req req; addr48_ptr watch_addr; unsigned_8 size; } _WCUNALIGNED set_watch_req; @@ -279,7 +279,7 @@ typedef struct { } set_watch_ret; typedef struct { - access_req req; + trap_req req; addr48_ptr watch_addr; unsigned_8 size; } _WCUNALIGNED clear_watch_req; @@ -287,7 +287,7 @@ typedef struct { /* no clear_watch_ret */ typedef struct { - access_req req; + trap_req req; addr48_ptr break_addr; } _WCUNALIGNED set_break_req; @@ -296,7 +296,7 @@ typedef struct { } set_break_ret; typedef struct { - access_req req; + trap_req req; addr48_ptr break_addr; unsigned_32 old; } _WCUNALIGNED clear_break_req; @@ -304,7 +304,7 @@ typedef struct { /* no clear_break_ret */ typedef struct { - access_req req; + trap_req req; unsigned_16 seg; } _WCUNALIGNED get_next_alias_req; @@ -314,19 +314,19 @@ typedef struct { } get_next_alias_ret; typedef struct { - access_req req; + trap_req req; } set_user_screen_req; /* no set_user_screen_ret */ typedef struct { - access_req req; + trap_req req; } set_debug_screen_req; /* no set_debug_screen_ret */ typedef struct { - access_req req; + trap_req req; unsigned_16 wait; } _WCUNALIGNED read_user_keyboard_req; @@ -335,7 +335,7 @@ typedef struct { } read_user_keyboard_ret; typedef struct { - access_req req; + trap_req req; trap_mhandle mod_handle; } _WCUNALIGNED get_lib_name_req; @@ -345,7 +345,7 @@ typedef struct { } get_lib_name_ret; typedef struct { - access_req req; + trap_req req; trap_error err; } _WCUNALIGNED get_err_text_req; @@ -360,7 +360,7 @@ enum { }; typedef struct { - access_req req; + trap_req req; } get_message_text_req; typedef struct { @@ -369,7 +369,7 @@ typedef struct { } get_message_text_ret; typedef struct { - access_req req; + trap_req req; /* followed by filename to redirect to */ } redirect_stdin_req; @@ -382,7 +382,7 @@ typedef redirect_stdin_ret redirect_stdout_ret; typedef struct { - access_req req; + trap_req req; /* followed by command string */ } split_cmd_req; @@ -393,14 +393,14 @@ typedef struct { /*====================== REQ_READ_REGS =============== */ typedef struct { - access_req req; + trap_req req; } read_regs_req; /* send back appropriate mad_registers union member for machine */ /*====================== REQ_WRITE_REGS ============== */ typedef struct { - access_req req; + trap_req req; /* followed by the appropriate mad_registers union member */ } write_regs_req; @@ -409,7 +409,7 @@ typedef struct { /*====================== REQ_MACHINE_DATA ============ */ typedef struct { - access_req req; + trap_req req; unsigned_8 info_type; addr48_ptr addr; /* followed by whatever machine specific data is required */ diff --git a/bld/dig/h/trpenv.h b/bld/dig/h/trpenv.h index 064d09fb19..b95fb6af2d 100644 --- a/bld/dig/h/trpenv.h +++ b/bld/dig/h/trpenv.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -56,7 +56,7 @@ enum { typedef struct { supp_prefix supp; - access_req req; + trap_req req; unsigned_32 res_len; /* followed by name of environment variable to get */ } env_get_var_req; @@ -70,7 +70,7 @@ typedef struct { typedef struct { supp_prefix supp; - access_req req; + trap_req req; /* followed by name of environment variable to set */ /* followed by value of environment variable to set */ } env_set_var_req; diff --git a/bld/dig/h/trpfile.h b/bld/dig/h/trpfile.h index 158363cd60..8802ee6833 100644 --- a/bld/dig/h/trpfile.h +++ b/bld/dig/h/trpfile.h @@ -65,7 +65,7 @@ typedef unsigned_64 trap_fhandle; /* file handle */ typedef struct { supp_prefix supp; - access_req req; + trap_req req; } file_get_config_req; typedef struct { @@ -75,7 +75,7 @@ typedef struct { /*==================== REQ_FILE_OPEN ===================*/ typedef struct { supp_prefix supp; - access_req req; + trap_req req; unsigned_8 mode; } file_open_req; @@ -87,7 +87,7 @@ typedef struct { /*====================== REQ_FILE_SEEK ===================*/ typedef struct { supp_prefix supp; - access_req req; + trap_req req; trap_fhandle handle; unsigned_8 mode; unsigned_32 pos; @@ -100,7 +100,7 @@ typedef struct { typedef struct { supp_prefix supp; - access_req req; + trap_req req; trap_fhandle handle; unsigned_16 len; } _WCUNALIGNED file_read_req; @@ -112,7 +112,7 @@ typedef struct { typedef struct { supp_prefix supp; - access_req req; + trap_req req; trap_fhandle handle; /* followed by sequence of bytes to write */ } _WCUNALIGNED file_write_req; @@ -124,7 +124,7 @@ typedef struct { typedef struct { supp_prefix supp; - access_req req; + trap_req req; /* followed by data to write to console */ } _WCUNALIGNED file_write_console_req; @@ -135,7 +135,7 @@ typedef struct { typedef struct { supp_prefix supp; - access_req req; + trap_req req; trap_fhandle handle; } _WCUNALIGNED file_close_req; @@ -145,7 +145,7 @@ typedef struct { typedef struct { supp_prefix supp; - access_req req; + trap_req req; /* followed by file name to be deleted */ } file_erase_req; @@ -156,7 +156,7 @@ typedef struct { /*====================== REQ_FILE_STRING_TO_FULLPATH =================*/ typedef struct { supp_prefix supp; - access_req req; + trap_req req; unsigned_8 file_type; /* followed by file name to be searched for */ } file_string_to_fullpath_req; @@ -168,7 +168,7 @@ typedef struct { typedef struct { supp_prefix supp; - access_req req; + trap_req req; unsigned_16 chk_size; } _WCUNALIGNED file_run_cmd_req; diff --git a/bld/dig/h/trpfinfo.h b/bld/dig/h/trpfinfo.h index a93b9b2880..2774934bc0 100644 --- a/bld/dig/h/trpfinfo.h +++ b/bld/dig/h/trpfinfo.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -56,7 +56,7 @@ enum { typedef struct { supp_prefix supp; - access_req req; + trap_req req; /* followed by file name */ } file_info_get_date_req; @@ -69,7 +69,7 @@ typedef struct { typedef struct { supp_prefix supp; - access_req req; + trap_req req; long date; /* followed by file name */ } file_info_set_date_req; diff --git a/bld/dig/h/trpovl.h b/bld/dig/h/trpovl.h index a9d84a4d35..319b13d9d9 100644 --- a/bld/dig/h/trpovl.h +++ b/bld/dig/h/trpovl.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -63,7 +63,7 @@ typedef struct { typedef struct { supp_prefix supp; - access_req req; + trap_req req; } ovl_state_size_req; typedef struct { @@ -72,7 +72,7 @@ typedef struct { typedef struct { supp_prefix supp; - access_req req; + trap_req req; unsigned_16 sect_id; } _WCUNALIGNED ovl_get_data_req; @@ -83,14 +83,14 @@ typedef struct { typedef struct { supp_prefix supp; - access_req req; + trap_req req; } ovl_read_state_req; /* return message is state information data */ typedef struct { supp_prefix supp; - access_req req; + trap_req req; /* followed by state information data */ } ovl_write_state_req; @@ -98,7 +98,7 @@ typedef struct { typedef struct { supp_prefix supp; - access_req req; + trap_req req; ovl_address ovl_addr; } _WCUNALIGNED ovl_trans_vect_addr_req; @@ -111,7 +111,7 @@ typedef ovl_trans_vect_addr_ret ovl_trans_ret_addr_ret; typedef struct { supp_prefix supp; - access_req req; + trap_req req; ovl_address ovl_addr; } _WCUNALIGNED ovl_get_remap_entry_req; diff --git a/bld/dig/h/trprfx.h b/bld/dig/h/trprfx.h index 152b2c1630..79c670d864 100644 --- a/bld/dig/h/trprfx.h +++ b/bld/dig/h/trprfx.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -70,7 +70,7 @@ enum { typedef struct { supp_prefix supp; - access_req req; + trap_req req; /* followed by old_name, new_name strings */ } rfx_rename_req; @@ -80,7 +80,7 @@ typedef struct { typedef struct { supp_prefix supp; - access_req req; + trap_req req; /* followed by directory name string */ } rfx_mkdir_req; @@ -93,7 +93,7 @@ typedef rfx_mkdir_ret rfx_rmdir_ret; typedef struct { supp_prefix supp; - access_req req; + trap_req req; unsigned_8 drive; } rfx_setdrive_req; @@ -103,7 +103,7 @@ typedef struct { typedef struct { supp_prefix supp; - access_req req; + trap_req req; } rfx_getdrive_req; typedef struct { @@ -112,7 +112,7 @@ typedef struct { typedef struct { supp_prefix supp; - access_req req; + trap_req req; /* followed by new cwd string */ } rfx_setcwd_req; @@ -122,7 +122,7 @@ typedef struct { typedef struct { supp_prefix supp; - access_req req; + trap_req req; unsigned_8 drive; } rfx_getcwd_req; @@ -133,7 +133,7 @@ typedef struct { typedef struct { supp_prefix supp; - access_req req; + trap_req req; trap_fhandle handle; unsigned_32 time; } _WCUNALIGNED rfx_setdatetime_req; @@ -142,7 +142,7 @@ typedef struct { typedef struct { supp_prefix supp; - access_req req; + trap_req req; trap_fhandle handle; } _WCUNALIGNED rfx_getdatetime_req; @@ -152,7 +152,7 @@ typedef struct { typedef struct { supp_prefix supp; - access_req req; + trap_req req; unsigned_8 drive; } rfx_getfreespace_req; @@ -162,7 +162,7 @@ typedef struct { typedef struct { supp_prefix supp; - access_req req; + trap_req req; unsigned_32 attribute; /* followed by file name string */ } _WCUNALIGNED rfx_setfileattr_req; @@ -173,7 +173,7 @@ typedef struct { typedef struct { supp_prefix supp; - access_req req; + trap_req req; /* followed by file name string */ } rfx_getfileattr_req; @@ -183,7 +183,7 @@ typedef struct { typedef struct { supp_prefix supp; - access_req req; + trap_req req; /* followed by file name string */ } rfx_nametocanonical_req; @@ -237,7 +237,7 @@ typedef struct { typedef struct { supp_prefix supp; - access_req req; + trap_req req; unsigned_8 attrib; /* followed by directory name string */ } rfx_findfirst_req; @@ -249,7 +249,7 @@ typedef struct { typedef struct { supp_prefix supp; - access_req req; + trap_req req; /* followed by a rfx_find */ } rfx_findnext_req; @@ -260,7 +260,7 @@ typedef struct { typedef struct { supp_prefix supp; - access_req req; + trap_req req; /* followed by a rfx_find */ } rfx_findclose_req; diff --git a/bld/dig/h/trprtrd.h b/bld/dig/h/trprtrd.h index 2f74317ef1..4bf8ec454a 100644 --- a/bld/dig/h/trprtrd.h +++ b/bld/dig/h/trprtrd.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -67,7 +67,7 @@ enum { typedef struct { supp_prefix supp; - access_req req; + trap_req req; unsigned_16 col; /* column in thread list to get info about */ } _WCUNALIGNED run_thread_info_req; @@ -81,7 +81,7 @@ typedef struct { typedef struct { supp_prefix supp; - access_req req; + trap_req req; unsigned_32 thread; /* thread to ask about */ } _WCUNALIGNED run_thread_get_next_req; @@ -93,7 +93,7 @@ typedef struct { typedef struct { supp_prefix supp; - access_req req; + trap_req req; unsigned_32 thread; /* thread to ask about */ } _WCUNALIGNED run_thread_get_runtime_req; @@ -108,7 +108,7 @@ typedef struct { typedef struct { supp_prefix supp; - access_req req; + trap_req req; } run_thread_poll_req; typedef struct { @@ -119,7 +119,7 @@ typedef struct { typedef struct { supp_prefix supp; - access_req req; + trap_req req; unsigned_32 thread; } _WCUNALIGNED run_thread_set_req; @@ -132,7 +132,7 @@ typedef struct { typedef struct { supp_prefix supp; - access_req req; + trap_req req; unsigned_32 thread; } _WCUNALIGNED run_thread_get_name_req; @@ -142,7 +142,7 @@ typedef struct { typedef struct { supp_prefix supp; - access_req req; + trap_req req; unsigned_32 thread; /* thread to stop */ } _WCUNALIGNED run_thread_stop_req; @@ -150,7 +150,7 @@ typedef struct { typedef struct { supp_prefix supp; - access_req req; + trap_req req; unsigned_32 thread; /* thread to signal and stop */ } _WCUNALIGNED run_thread_signal_stop_req; diff --git a/bld/dig/h/trpthrd.h b/bld/dig/h/trpthrd.h index 00e404085d..9328fcc75d 100644 --- a/bld/dig/h/trpthrd.h +++ b/bld/dig/h/trpthrd.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -63,7 +63,7 @@ typedef unsigned_32 trap_thandle; /* thread handle */ typedef struct { supp_prefix supp; - access_req req; + trap_req req; trap_thandle thread; } _WCUNALIGNED thread_get_next_req; @@ -74,7 +74,7 @@ typedef struct { typedef struct { supp_prefix supp; - access_req req; + trap_req req; trap_thandle thread; } _WCUNALIGNED thread_set_req; @@ -85,7 +85,7 @@ typedef struct { typedef struct { supp_prefix supp; - access_req req; + trap_req req; trap_thandle thread; } _WCUNALIGNED thread_freeze_req; @@ -98,7 +98,7 @@ typedef thread_freeze_ret thread_thaw_ret; typedef struct { supp_prefix supp; - access_req req; + trap_req req; trap_thandle thread; } _WCUNALIGNED thread_get_extra_req; diff --git a/bld/dig/h/trptypes.h b/bld/dig/h/trptypes.h index 31ad9da96b..a2c8e9447e 100644 --- a/bld/dig/h/trptypes.h +++ b/bld/dig/h/trptypes.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -61,7 +61,7 @@ #define TrapVersionOK( ver ) ((ver).major == TRAP_MAJOR_VERSION) #endif -#define TRP_REQUEST(x) *((access_req *)(x)[0].ptr) +#define TRP_REQUEST(x) *((trap_req *)(x)[0].ptr) #define TRAP_SYM1(a,b,c) a ## b ## _ ## c #define TRAP_SYM(a,b) TRAP_SYM1( Req, a, b ) @@ -73,7 +73,7 @@ typedef struct { unsigned_8 remote; } trap_version; -typedef unsigned_8 access_req; +typedef unsigned_8 trap_req; typedef dig_elen trap_elen; typedef unsigned_32 trap_error; typedef unsigned_32 trap_mhandle; /* module handle */ @@ -84,7 +84,7 @@ typedef trap_elen trap_retval; #include "pushpck1.h" typedef struct { - access_req core_req; + trap_req core_req; trap_shandle id; } _WCUNALIGNED supp_prefix; diff --git a/bld/trap/common/trapdbg.h b/bld/trap/common/trapdbg.h index 4ebcc4d08d..071af0cd76 100644 --- a/bld/trap/common/trapdbg.h +++ b/bld/trap/common/trapdbg.h @@ -197,9 +197,9 @@ extern void _DBG_DumpStr( const char __far *str, uint_16 len, uint_16 fhandle ); #endif /* !__LINUX__ */ -#define _DBG_Request( n ) ( (access_req)(n) >= REQ__LAST ? \ +#define _DBG_Request( n ) ( (trap_req)(n) >= REQ__LAST ? \ DBG_UNKNOWN_REQ : \ - DBG_ReqStrings[(access_req)(n)] ) + DBG_ReqStrings[(trap_req)(n)] ) #define _DBG_Space() _DBG_DumpChar( DBG_BLANK, DBG_STDOUT_H ); #define _DBG_RingBell() _DBG_DumpChar( DBG_BELL, DBG_STDOUT_H ); #define _DBG_DumpHexChar( n ) _DBG_DumpChar( _DBG_HexChar( n ), \ diff --git a/bld/trap/lcl/c/supp.c b/bld/trap/lcl/c/supp.c index ba88d2a3ea..219986c534 100644 --- a/bld/trap/lcl/c/supp.c +++ b/bld/trap/lcl/c/supp.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -167,10 +167,10 @@ trap_retval TRAP_CORE( Get_supplementary_service )(void) trap_retval TRAP_CORE( Perform_supplementary_service )( void ) { - access_req *sup_req; + trap_req *sup_req; trap_shandle *id; - id = GetInPtr( sizeof( access_req ) ); + id = GetInPtr( sizeof( trap_req ) ); if( *id == 0 ) return( 0 ); sup_req = GetInPtr( sizeof( supp_prefix ) ); diff --git a/bld/trap/lcl/jvm/c/jvmxremo.c b/bld/trap/lcl/jvm/c/jvmxremo.c index 146233dab5..976191c817 100644 --- a/bld/trap/lcl/jvm/c/jvmxremo.c +++ b/bld/trap/lcl/jvm/c/jvmxremo.c @@ -511,12 +511,12 @@ trap_retval TRAP_CORE( Get_supplementary_service )( void ) trap_retval TRAP_CORE( Perform_supplementary_service )( void ) { unsigned (* const * _WCUNALIGNED *vectors)(void); - access_req *sup_req; + trap_req *sup_req; if( TaskLoaded ) { return( DoAccess() ); } - vectors = GetInPtr( sizeof( access_req ) ); + vectors = GetInPtr( sizeof( trap_req ) ); sup_req = GetInPtr( sizeof( supp_prefix ) ); return( (*vectors)[*sup_req]() ); } diff --git a/bld/wv/doc/trap.gml b/bld/wv/doc/trap.gml index 51c9476414..a03448a8f5 100644 --- a/bld/wv/doc/trap.gml +++ b/bld/wv/doc/trap.gml @@ -87,7 +87,7 @@ They are defined as follows: 2 byte unsigned quantity .note unsigned_32 4 byte unsigned quantity -.note access_req +.note trap_req The first field of every request is of this type. It is a 1 byte field which identifies the request to be performed. .note addr48_ptr @@ -319,7 +319,7 @@ bytes described by the array). .np Since every request must start with an -.id access_req +.id trap_req field, the minimum size of a request message is one byte. .np Some requests do not require a return message. @@ -344,7 +344,7 @@ mx_entry in[1]; mx_entry out[1]; unsigned char buffer[30]; struct in_msg_def { - access_req req; + trap_req req; addr48_ptr addr; unsigned_16 len; } in_msg = { REQ_READ_MEM, { 0x8000, 0x0010 }, sizeof( buffer ) }; @@ -427,7 +427,7 @@ This must be the first request made. .np Request message: .millust begin -access_req req +trap_req req unsigned_8 major; <-+- struct trap_version unsigned_8 minor; | unsigned_8 remote; <-+ @@ -488,7 +488,7 @@ After this request, a REQ_CONNECT must be the next one made. .np Request message: .millust begin -access_req req +trap_req req .millust end .pp The @@ -514,7 +514,7 @@ missing files to the remote machine before continuing the debugging process. .np Request message: .millust begin -access_req req +trap_req req .millust end .pp The @@ -534,7 +534,7 @@ The debugger issues this request when the spawned sub-shell exits. .np Request message: .millust begin -access_req req +trap_req req .millust end .pp The @@ -553,7 +553,7 @@ Request to obtain a supplementary service id. .np Request message: .millust begin -access_req req +trap_req req ------------------------ string service_name .millust end @@ -597,7 +597,7 @@ Request to perform a supplementary service. .np Request message: .millust begin -access_req req +trap_req req unsigned_32 service_id ------------------------ unspecified @@ -627,7 +627,7 @@ Request to get system information from the remote machine. .np Request message: .millust begin -access_req req +trap_req req .millust end .pp The @@ -749,7 +749,7 @@ update its addresses. .np Request message: .millust begin -access_req req; +trap_req req; addr48_ptr in_addr; trap_mhandle mod_handle; .millust end @@ -816,7 +816,7 @@ The debugger does not care how the checksum is calculated. .np Request message: .millust begin -access_req req; +trap_req req; addr48_ptr in_addr; unsigned_16 len; .millust end @@ -846,7 +846,7 @@ Request to read a block of memory. .np Request message: .millust begin -access_req req; +trap_req req; addr48_ptr mem_addr; unsigned_16 len; .millust end @@ -878,7 +878,7 @@ Request to write a block of memory. .np Request message: .millust begin -access_req req +trap_req req addr48_ptr mem_addr ------------------------ bytes data @@ -911,7 +911,7 @@ Request to read data from I/O address space of the debuggee. .np Request message: .millust begin -access_req req +trap_req req unsigned_32 IO_offset unsigned_8 len .millust end @@ -946,7 +946,7 @@ Request to write data to the I/O address space of the debuggee. .np Request message: .millust begin -access_req req +trap_req req unsigned_32 IO_offset ------------------------- bytes data @@ -990,7 +990,7 @@ instruction when there are active watchpoints present. .np Request message: .millust begin -access_req req +trap_req req .millust end .pp The request is in @@ -1044,7 +1044,7 @@ Request to load a program. .np Request message: .millust begin -access_req req +trap_req req unsigned_8 true_argv ------------------------- bytes argv @@ -1103,7 +1103,7 @@ Request to kill the program. .np Request message: .millust begin -access_req req +trap_req req trap_phandle task_id .millust end .pp @@ -1130,7 +1130,7 @@ Request to set a watchpoint at the address given. .np Request message: .millust begin -access_req req +trap_req req addr48_ptr watch_addr unsigned_8 size .millust end @@ -1164,7 +1164,7 @@ The trap file may assume all watch points are cleared at once. .np Request message: .millust begin -access_req req +trap_req req addr48_ptr watch_addr unsigned_8 size .millust end @@ -1188,7 +1188,7 @@ Request to set a breakpoint at the address given. .np Request message: .millust begin -access_req req +trap_req req addr48_ptr break_addr .millust end .pp @@ -1215,7 +1215,7 @@ The trap file may assume all breakpoints are cleared at once. .np Request message: .millust begin -access_req req +trap_req req addr48_ptr break_addr unsigned_32 old .millust end @@ -1243,7 +1243,7 @@ Which selectors do this is important to the debugger in certain cases .np Request message: .millust begin -access_req req +trap_req req unsigned_16 seg .millust end .pp @@ -1274,7 +1274,7 @@ Request to make the debuggee's screen visible. .np Request message: .millust begin -access_req req +trap_req req .millust end .np Return message: @@ -1289,7 +1289,7 @@ Request to make the debugger's screen visible. .np Request message: .millust begin -access_req req +trap_req req .millust end .np Return message: @@ -1304,7 +1304,7 @@ Request to read the remote keyboard input. .np Request message: .millust begin -access_req req +trap_req req unsigned_16 wait .millust end .pp @@ -1330,7 +1330,7 @@ Request to get the name of a newly loaded library (DLL). .np Request message: .millust begin -access_req req +trap_req req trap_mhandle mod_handle .millust end .pp @@ -1370,7 +1370,7 @@ Request to get the error message text for an error code. .np Request message: .millust begin -access_req req +trap_req req trap_error err .millust end .pp @@ -1401,7 +1401,7 @@ to display to the user. .np Request message: .millust begin -access_req req +trap_req req .millust end .np Return message: @@ -1445,7 +1445,7 @@ standard output (REQ_REDIRECT_STDOUT) of the debuggee. .np Request message: .millust begin -access_req req +trap_req req ------------------------ string name .millust end @@ -1472,7 +1472,7 @@ parameters. .np Request message: .millust begin -access_req req +trap_req req ------------------------ string cmd .millust end @@ -1504,7 +1504,7 @@ the MAD file. .np Request message: .millust begin -access_req req +trap_req req .millust end .pp .np @@ -1528,7 +1528,7 @@ The data is target architecture specific. .np Request message: .millust begin -access_req req +trap_req req ------------------- unspecified .millust end @@ -1550,7 +1550,7 @@ Request to retrieve machine specific data. .np Request message: .millust begin -access_req req; +trap_req req; unsigned_8 info_type; addr48_ptr addr; ----------------------------- @@ -1609,7 +1609,7 @@ Request to retreive characteristics of the remote file system. .np Request message: .millust begin -access_req req +trap_req req .millust end .np Return message: @@ -1641,7 +1641,7 @@ Request to create/open a file. .np Request message: .millust begin -access_req req +trap_req req unsigned_8 mode ------------------------ string name @@ -1697,7 +1697,7 @@ Request to seek to a particular file position. .np Request message: .millust begin -access_req req +trap_req req trap_fhandle handle unsigned_8 mode unsigned_32 pos @@ -1740,7 +1740,7 @@ Request to read a block of data from a file. .np Request message: .millust begin -access_req req +trap_req req trap_fhandle handle unsigned_16 len .millust end @@ -1782,7 +1782,7 @@ Request to write a block of data to a file. .np Request message: .millust begin -access_req req +trap_req req trap_fhandle handle ------------------------ bytes data @@ -1817,7 +1817,7 @@ Request to write a block of data to the debuggee's screen. .np Request message: .millust begin -access_req req +trap_req req ------------------------ bytes data .millust end @@ -1848,7 +1848,7 @@ Request to close a file. .np Request message: .millust begin -access_req req +trap_req req trap_fhandle handle .millust end .pp @@ -1872,7 +1872,7 @@ Request to erase a file. .np Request message: .millust begin -access_req req +trap_req req ------------------------- string file_name .millust end @@ -1897,7 +1897,7 @@ Request to convert a file name to its full path name. .np Request message: .millust begin -access_req req +trap_req req unsigned_8 file_type ------------------------- string file_name @@ -1946,7 +1946,7 @@ Request to run a command on the target (debuggee's) system. .np Request message: .millust begin -access_req req +trap_req req unsigned_16 chk_size ------------------------ string cmd @@ -2040,7 +2040,7 @@ contents of the return message. .np Request message: .millust begin -access_req req +trap_req req .millust end .pp The @@ -2068,7 +2068,7 @@ the contents of the return message. .np Request message: .millust begin -access_req req +trap_req req unsigned_16 sect_id .millust end The @@ -2104,7 +2104,7 @@ trap file request. .np Request message: .millust begin -access_req req +trap_req req .millust end .np Return message: @@ -2126,7 +2126,7 @@ the contents of the return message. .np Request message: .millust begin -access_req req +trap_req req -------------------- bytes data .millust end @@ -2150,7 +2150,7 @@ the contents of the messages. .np Request message: .millust begin -access_req req +trap_req req ovl_address ovl_addr .millust end .pp @@ -2185,7 +2185,7 @@ the contents of the messages. .np Request message: .millust begin -access_req req +trap_req req ovl_address ovl_addr .millust end .np @@ -2214,7 +2214,7 @@ the contents of the messages. .np Request message: .millust begin -access_req req +trap_req req ovl_address ovl_addr .millust end .pp @@ -2267,7 +2267,7 @@ Request to get next thread. .np Request message: .millust begin -access_req req +trap_req req trap_thandle thread .millust end .pp @@ -2303,7 +2303,7 @@ Request to set a given thread ID to be the current thread. .np Request message: .millust begin -access_req req +trap_req req trap_thandle thread .millust end .pp @@ -2333,7 +2333,7 @@ the task program. .np Request message: .millust begin -access_req req +trap_req req trap_thandle thread .millust end .pp @@ -2356,7 +2356,7 @@ Request to allow a thread to run next time when executing the program. .np Request message: .millust begin -access_req req +trap_req req trap_thandle thread .millust end .pp @@ -2383,7 +2383,7 @@ would be useful for the user to know. .np Request message: .millust begin -access_req req +trap_req req unsigned_32 thread .millust end .pp @@ -2423,7 +2423,7 @@ Request to rename a file on the debuggee's system. .np Request message: .millust begin -access_req req +trap_req req ------------------------- string from_name ------------------------- @@ -2452,7 +2452,7 @@ Request to create a directory on the target (debuggee) system. .np Request message: .millust begin -access_req req +trap_req req ------------------------ string dir_name .millust end @@ -2477,7 +2477,7 @@ Request to remove a directory on the target system. .np Request message: .millust begin -access_req req +trap_req req ------------------------ string dir_name .millust end @@ -2502,7 +2502,7 @@ Request to set the current drive on the target system. .np Request message: .millust begin -access_req req +trap_req req unsigned_8 drive .millust end .pp @@ -2526,7 +2526,7 @@ Request to get the current drive on the target system. .np Request message: .millust begin -access_req req +trap_req req .millust end .pp The @@ -2549,7 +2549,7 @@ Request to set a directory on the target system. .np Request message: .millust begin -access_req req +trap_req req ------------------------ string dir_name .millust end @@ -2574,7 +2574,7 @@ Request to get the current directory name on the target system. .np Request message: .millust begin -access_req req +trap_req req unsigned_8 drive .millust end .pp @@ -2603,7 +2603,7 @@ Request to set a file's date and time information on the target system. .np Request message: .millust begin -access_req req +trap_req req trap_fhandle handle time_t time .millust end @@ -2630,7 +2630,7 @@ Request to get the date and time information for a file on the target system. .np Request message: .millust begin -access_req req +trap_req req trap_fhandle handle .millust end .pp @@ -2657,7 +2657,7 @@ Request to get the amount of free space left on the drive. .np Request message: .millust begin -access_req req +trap_req req unsigned_8 drive .millust end .pp @@ -2681,7 +2681,7 @@ Request to set the file attribute of a file. .np Request message: .millust begin -access_req req +trap_req req unsigned_32 attribute ------------------------- string name @@ -2710,7 +2710,7 @@ Request to get the file attribute of a file. .np Request message: .millust begin -access_req req +trap_req req -------------------- string name .millust end @@ -2735,7 +2735,7 @@ Request to convert a file name to its canonical form. .np Request message: .millust begin -access_req req +trap_req req ------------------------- string file_name .millust end @@ -2768,7 +2768,7 @@ Request to find the first file in a directory. .np Request message: .millust begin -access_req req +trap_req req unsigned_8 attrib ---------------------- string name @@ -2815,7 +2815,7 @@ This request should be used only after REQ_RFX_FINDFIRST. .np Request message: .millust begin -access_req req +trap_req req -------------------- rfx_find info .millust end @@ -2846,7 +2846,7 @@ Request to end the directory search operation. .np Request message: .millust begin -access_req req +trap_req req .millust end .pp The @@ -2886,7 +2886,7 @@ Request to retreive Environment variable from the remote system. .np Request message: .millust begin -access_req req +trap_req req ------------------------ string name .millust end @@ -2910,7 +2910,7 @@ Request to set Environment variable on the remote system. .np Request message: .millust begin -access_req req +trap_req req ------------------------ string name string value; @@ -2939,7 +2939,7 @@ on the remote system. .np Request message: .millust begin -access_req req +trap_req req .millust end .np Return message: @@ -2953,7 +2953,7 @@ trap_error err .np Request message: .millust begin -access_req req +trap_req req .millust end .np Return message: @@ -2974,7 +2974,7 @@ trap_error err .np Request message: .millust begin -access_req req +trap_req req .millust end .np Return message: @@ -2988,7 +2988,7 @@ trap_error err .np Request message: .millust begin -access_req req +trap_req req .millust end .np Return message: @@ -3002,7 +3002,7 @@ trap_error err .np Request message: .millust begin -access_req req +trap_req req .millust end .np Return message: @@ -3016,7 +3016,7 @@ trap_error err .np Request message: .millust begin -access_req req +trap_req req .millust end .np Return message: @@ -3030,7 +3030,7 @@ trap_error err .np Request message: .millust begin -access_req req +trap_req req .millust end .np Return message: @@ -3044,7 +3044,7 @@ trap_error err .np Request message: .millust begin -access_req req +trap_req req .millust end .np Return message: @@ -3065,7 +3065,7 @@ trap_error err .np Request message: .millust begin -access_req req +trap_req req .millust end .np Return message: @@ -3079,7 +3079,7 @@ trap_error err .np Request message: .millust begin -access_req req +trap_req req .millust end .np Return message: @@ -3093,7 +3093,7 @@ trap_error err .np Request message: .millust begin -access_req req +trap_req req .millust end .np Return message: @@ -3107,7 +3107,7 @@ trap_error err .np Request message: .millust begin -access_req req +trap_req req .millust end .np Return message: @@ -3121,7 +3121,7 @@ trap_error err .np Request message: .millust begin -access_req req +trap_req req .millust end .np Return message: @@ -3135,7 +3135,7 @@ trap_error err .np Request message: .millust begin -access_req req +trap_req req .millust end .np Return message: @@ -3149,7 +3149,7 @@ trap_error err .np Request message: .millust begin -access_req req +trap_req req .millust end .np Return message: @@ -3163,7 +3163,7 @@ trap_error err .np Request message: .millust begin -access_req req +trap_req req .millust end .np Return message: @@ -3187,7 +3187,7 @@ on the remote system. .np Request message: .millust begin -access_req req +trap_req req .millust end .np Return message: @@ -3211,7 +3211,7 @@ on the remote system. .np Request message: .millust begin -access_req req +trap_req req unsigned_8 status .millust end .np @@ -3375,3 +3375,4 @@ the command line and then terminates. .np The trap file routines are linked directly into the remote server code and TrapInit, TrapRequest, TrapFini are directly called. + diff --git a/bld/wv/utils/trap2txt/c/trap2txt.cpp b/bld/wv/utils/trap2txt/c/trap2txt.cpp index 64b0b16761..9864b94037 100644 --- a/bld/wv/utils/trap2txt/c/trap2txt.cpp +++ b/bld/wv/utils/trap2txt/c/trap2txt.cpp @@ -398,9 +398,9 @@ int handle_REQ_RESUME_REPLY( unsigned char * , unsigned short ) int handle_REQ_GET_SUPPLEMENTARY_SERVICE( unsigned char * pkt, unsigned short ) { - access_req * req = ( access_req * ) pkt; + trap_req *req = (trap_req *)pkt; req = &req[1]; - char * service_name = ( char * ) req; + char *service_name = (char *)req; printf( "Debugger request: REQ_GET_SUPPLEMENTARY_SERVICE\n" ); printf( " Service : %s\n", service_name ); From 12efaf933124c53998eacdc4f4548ab9c1d33880 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Sun, 10 Sep 2023 02:16:42 +0200 Subject: [PATCH 105/258] correct mistale in trap file loader --- bld/dig/c/linux/trpld_rx.c | 2 +- bld/dig/c/win/trpld.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bld/dig/c/linux/trpld_rx.c b/bld/dig/c/linux/trpld_rx.c index 2c402be8db..4530c947ab 100644 --- a/bld/dig/c/linux/trpld_rx.c +++ b/bld/dig/c/linux/trpld_rx.c @@ -94,7 +94,7 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) } len++; } - if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, len, ".trp", filename, sizeof( filename ) ) ) { + if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, len, ".trp", filename, sizeof( filename ) ) == 0 ) { sprintf( buff, TC_ERR_CANT_LOAD_TRAP, base_name ); return( buff ); } diff --git a/bld/dig/c/win/trpld.c b/bld/dig/c/win/trpld.c index 77cc459b25..66a62a984e 100644 --- a/bld/dig/c/win/trpld.c +++ b/bld/dig/c/win/trpld.c @@ -106,7 +106,7 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) if( (UINT)toolhelp < 32 ) { toolhelp = 0; } - if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, len, ".dll", filename, sizeof( filename ) ) ) { + if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, len, ".dll", filename, sizeof( filename ) ) == 0 ) { sprintf( buff, TC_ERR_CANT_LOAD_TRAP, base_name ); return( buff ); } From b16b2d5b790afd1f3b0a29aa8a32da9d3b10cf2a Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Sun, 10 Sep 2023 04:24:46 +0200 Subject: [PATCH 106/258] correct mistake in linux PE loader --- bld/dig/c/linux/peloader.c | 5 +++-- bld/dig/c/linux/peloader.h | 7 ++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/bld/dig/c/linux/peloader.c b/bld/dig/c/linux/peloader.c index 92fca09b2e..cb6f21c07c 100644 --- a/bld/dig/c/linux/peloader.c +++ b/bld/dig/c/linux/peloader.c @@ -41,6 +41,7 @@ #include #include #include "bool.h" +#include "exedos.h" #include "dbgmod.h" #include "digld.h" @@ -71,7 +72,7 @@ static bool PE_readHeader( FILE_HDR *filehdr, OPTIONAL_HDR *opthdr) { - EXE_HDR exehdr; + dos_exe_header exehdr; u_long ne_header_off; u_long signature; @@ -82,7 +83,7 @@ static bool PE_readHeader( if( DIGLoader( Seek )( fp, startOffset, SEEK_SET ) || DIGLoader( Read )( fp, &exehdr, sizeof( exehdr ) ) || ( exehdr.signature != EXESIGN_DOS ) - || !NE_HEADER_FOLLOWS( exehdr.reloc ) ) + || !NE_HEADER_FOLLOWS( exehdr.reloc_offset ) ) return( false ); /* * Now seek to the start of the PE header defined at offset 0x3C diff --git a/bld/dig/c/linux/peloader.h b/bld/dig/c/linux/peloader.h index 4f10bdb975..b4cd992819 100644 --- a/bld/dig/c/linux/peloader.h +++ b/bld/dig/c/linux/peloader.h @@ -47,18 +47,15 @@ #include "watcom.h" /*---------------------- Macros and type definitions ----------------------*/ -#define EXESIGN_DOS 0x5a4d -#define EXESIGN_PE 0x4550 -#define NE_HEADER_OFFSET 0x003c -#define NE_HEADER_FOLLOWS(x) ((x) >= 0x0040) /* reloc table offset 0x40 */ -#include "pushpck1.h" /**************************************************************************** REMARKS: Structure of a module handle when loaded from disk {secret} ****************************************************************************/ +#include "pushpck1.h" + typedef struct { u_char *pbase; /* Base of image in memory */ u_char *ptext; /* Text section read from disk */ From 5265b0ab38579ce1e6583da2e23d5c28b1f2753b Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Sun, 10 Sep 2023 09:08:01 +0200 Subject: [PATCH 107/258] add socket_address full initialization --- bld/trap/tcp/c/tcplink.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bld/trap/tcp/c/tcplink.c b/bld/trap/tcp/c/tcplink.c index c8c28d113b..14dad71734 100644 --- a/bld/trap/tcp/c/tcplink.c +++ b/bld/trap/tcp/c/tcplink.c @@ -558,6 +558,7 @@ const char *RemoteLink( const char *parms, bool server ) } /* Name socket using wildcards */ + memset( &socket_address, 0, sizeof( socket_address ) ); socket_address.sin_family = AF_INET; socket_address.sin_addr.s_addr = OW_INADDR_ANY; socket_address.sin_port = htons( trap_port ); @@ -598,6 +599,7 @@ const char *RemoteLink( const char *parms, bool server ) /* * Setup for socket connect using parms specified by command line. */ + memset( &socket_address, 0, sizeof( socket_address ) ); socket_address.sin_family = AF_INET; socket_address.sin_addr.s_addr = trap_addr; socket_address.sin_port = htons( trap_port ); From 7a0d5ec8a861e5ffe571094cce6ddb7aee70feb7 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Sun, 10 Sep 2023 10:14:54 +0200 Subject: [PATCH 108/258] use OW neutral PE header files for peloader --- bld/dig/c/linux/pe.h | 265 ------------------------------------- bld/dig/c/linux/peloader.c | 121 ++++++++--------- 2 files changed, 61 insertions(+), 325 deletions(-) delete mode 100644 bld/dig/c/linux/pe.h diff --git a/bld/dig/c/linux/pe.h b/bld/dig/c/linux/pe.h deleted file mode 100644 index 150e6bae7a..0000000000 --- a/bld/dig/c/linux/pe.h +++ /dev/null @@ -1,265 +0,0 @@ -/**************************************************************************** -* -* Open Watcom Project -* -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. -* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. -* -* ======================================================================== -* -* This file contains Original Code and/or Modifications of Original -* Code as defined in and that are subject to the Sybase Open Watcom -* Public License version 1.0 (the 'License'). You may not use this file -* except in compliance with the License. BY USING THIS FILE YOU AGREE TO -* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is -* provided with the Original Code and Modifications, and is also -* available at www.sybase.com/developer/opensource. -* -* The Original Code and all software distributed under the License are -* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER -* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM -* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF -* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR -* NON-INFRINGEMENT. Please see the License for the specific language -* governing rights and limitations under the License. -* -* ======================================================================== -* -* Description: Internal header file describing the PE File Format -* structures. -* -****************************************************************************/ - -#ifndef __PE_H -#define __PE_H - -#include -#include -#include -#include -#include -#include "roundmac.h" - -/*---------------------- Macros and type definitions ----------------------*/ - -#include "pushpck1.h" - -/* Don't include these definitions if we have already included - * - */ -#ifndef IMAGE_FILE_MACHINE_UNKNOWN - -/* Flags for the machine type in the COFF file header */ - -#define IMAGE_FILE_MACHINE_UNKNOWN 0 /* Machine type is unknown */ -#define IMAGE_FILE_MACHINE_I386 0x14c /* Intel 386 or later */ -#define IMAGE_FILE_MACHINE_R3000 0x162 /* MIPS R3000 little endian */ -#define IMAGE_FILE_MACHINE_R4000 0x166 /* MIPS R4000 little endian */ -#define IMAGE_FILE_MACHINE_R10000 0x168 /* MIPS R10000 little endian*/ -#define IMAGE_FILE_MACHINE_ALPHA 0x184 /* DEC Alpha AXP */ -#define IMAGE_FILE_MACHINE_M68K 0x268 /* Motorola 68000 series */ -#define IMAGE_FILE_MACHINE_POWERPC 0x1F0 /* Power PC, little endian */ -#define IMAGE_FILE_MACHINE_SH3 0x1a2 /* Hitachi SH3 */ -#define IMAGE_FILE_MACHINE_SH4 0x1a6 /* Hitachi SH4 */ -#define IMAGE_FILE_MACHINE_ARM 0x1c0 /* ARM Processor */ - -/* Flags for the characteristic in the COFF file header */ - -#define IMAGE_FILE_RELOCS_STRIPPED 0x0001 -#define IMAGE_FILE_EXECUTABLE_IMAGE 0x0002 -#define IMAGE_FILE_LINE_NUMS_STRIPPED 0x0004 -#define IMAGE_FILE_LOCAL_SYMS_STRIPPED 0x0008 -#define IMAGE_FILE_AGGRESSIVE_WS_TRIM 0x0010 -#define IMAGE_FILE_LARGE_ADDRESS_AWARE 0x0020 -#define IMAGE_FILE_16BIT_MACHINE 0x0040 -#define IMAGE_FILE_BYTES_REVERSED_LO 0x0080 -#define IMAGE_FILE_32BIT_MACHINE 0x0100 -#define IMAGE_FILE_DEBUG_STRIPPED 0x0200 -#define IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP 0x0400 -#define IMAGE_FILE_SYSTEM 0x1000 -#define IMAGE_FILE_DLL 0x2000 -#define IMAGE_FILE_UP_SYSTEM_ONLY 0x4000 -#define IMAGE_FILE_BYTES_REVERSED_HI 0x8000 - -/* Definitions for the Characteristics for the section header */ - -#define IMAGE_SCN_TYPE_REG 0x00000000 -#define IMAGE_SCN_TYPE_DSECT 0x00000001 -#define IMAGE_SCN_TYPE_NOLOAD 0x00000002 -#define IMAGE_SCN_TYPE_GROUP 0x00000004 -#define IMAGE_SCN_TYPE_NO_PAD 0x00000008 -#define IMAGE_SCN_TYPE_COPY 0x00000010 -#define IMAGE_SCN_CNT_CODE 0x00000020 -#define IMAGE_SCN_CNT_INITIALIZED_DATA 0x00000040 -#define IMAGE_SCN_CNT_UNINITIALIZED_DATA 0x00000080 -#define IMAGE_SCN_LNK_OTHER 0x00000100 -#define IMAGE_SCN_LNK_INFO 0x00000200 -#define IMAGE_SCN_TYPE_OVER 0x00000400 -#define IMAGE_SCN_LNK_REMOVE 0x00000800 -#define IMAGE_SCN_LNK_COMDAT 0x00001000 -#define IMAGE_SCN_MEM_FARDATA 0x00008000 -#define IMAGE_SCN_MEM_PURGEABLE 0x00020000 -#define IMAGE_SCN_MEM_16BIT 0x00020000 -#define IMAGE_SCN_MEM_LOCKED 0x00040000 -#define IMAGE_SCN_MEM_PRELOAD 0x00080000 -#define IMAGE_SCN_ALIGN_1BYTES 0x00100000 -#define IMAGE_SCN_ALIGN_2BYTES 0x00200000 -#define IMAGE_SCN_ALIGN_4BYTES 0x00300000 -#define IMAGE_SCN_ALIGN_8BYTES 0x00400000 -#define IMAGE_SCN_ALIGN_16BYTES 0x00500000 -#define IMAGE_SCN_ALIGN_32BYTES 0x00600000 -#define IMAGE_SCN_ALIGN_64BYTES 0x00700000 -#define IMAGE_SCN_LNK_OVFL 0x01000000 -#define IMAGE_SCN_MEM_DISCARDABLE 0x02000000 -#define IMAGE_SCN_MEM_NOT_CACHED 0x04000000 -#define IMAGE_SCN_MEM_NOT_PAGED 0x08000000 -#define IMAGE_SCN_MEM_SHARED 0x10000000 -#define IMAGE_SCN_MEM_EXECUTE 0x20000000 -#define IMAGE_SCN_MEM_READ 0x40000000 -#define IMAGE_SCN_MEM_WRITE 0x80000000 - -/* Defines for the type field of the RELOC structure (top 4 bits) */ - -#define IMAGE_REL_BASED_ABSOLUTE 0 -#define IMAGE_REL_BASED_HIGH 1 -#define IMAGE_REL_BASED_LOW 2 -#define IMAGE_REL_BASED_HIGHLOW 3 -#define IMAGE_REL_BASED_HIGHADJ 4 -#define IMAGE_REL_BASED_MIPS_JMPADDR 5 - -/* Definitions for the SubSystem field of the optional header */ - -#define IMAGE_SUBSYSTEM_UNKNOWN 0 /* Unknown subsystem */ -#define IMAGE_SUBSYSTEM_NATIVE 1 /* Device drivers */ -#define IMAGE_SUBSYSTEM_WINDOWS_GUI 2 /* Windows GUI */ -#define IMAGE_SUBSYSTEM_WINDOWS_CUI 3 /* Windows Console */ -#define IMAGE_SUBSYSTEM_POSIX_CUI 7 /* POSIX Console */ -#define IMAGE_SUBSYSTEM_WINDOWS_CE_GUI 9 /* Windows CE GUI */ - -/* Definitions for the DllCharacteristics field of the optional header */ - -#define IMAGE_DLLCHARACTERISTICS_WDM_DRIVER 0x2000 /* WDM device driver*/ - -/* Offsets of the data directories in optional header */ - -#define DIR_EXPORT 0 -#define DIR_IMPORT 1 -#define DIR_RESOURCE 2 -#define DIR_EXCEPTION 3 -#define DIR_CERTIFICATE 4 -#define DIR_BASERELOC 5 -#define DIR_DEBUG 6 -#define DIR_ARCHITECTURE 7 -#define DIR_GLOBALPTR 8 -#define DIR_TLS 9 -#define DIR_LOAD_CONFIG 10 -#define DIR_BOUNDIMPORT 11 -#define DIR_IAT 12 -#define DIR_DELAYIMPORT 13 - -#endif - -/* Structure defining the MS-DOS executeable file header */ - -typedef struct { - u_short signature; - u_short low; - u_short high; - u_short reloc; - u_short hdr_para; - } EXE_HDR; - -/* Structure defining the COFF file header */ - -typedef struct { - u_short Machine; - u_short NumberOfSections; - u_long TimeDateStamp; - u_long PointerToSymbolTable; - u_long NumberOfSynbols; - u_short SizeOfOptionalHeader; - u_short Characteristics; - } FILE_HDR; - -/* Structure of an entry in the data directory */ - -typedef struct { - u_long RelVirtualAddress; - u_long Size; - } DATA_DIRECTORY; - -/* Structure defining the optional PE header for Win32 */ - -typedef struct { - u_short Magic; - u_char MajorLinkerVersion; - u_char MinorLinkerVersion; - u_long SizeOfCode; - u_long SizeOfInitializedData; - u_long SizeOfUninitializedData; - u_long AddressOfEntryPoint; - u_long BaseOfCode; - u_long BaseOfData; - u_long ImageBase; - u_long SectionAlignment; - u_long FileAlignment; - u_short MajorOperatingSystemVersion; - u_short MinorOperatingSystemVersion; - u_short MajorImageVersion; - u_short MinorImageVersion; - u_short MajorSubsystemVersion; - u_short MinorSubsystemVersion; - u_long Reserved1; - u_long SizeOfImage; - u_long SizeOfHeaders; - u_long CheckSum; - u_short Subsystem; - u_short DllCharacteristics; - u_long SizeOfStackReserve; - u_long SizeOfStackCommit; - u_long SizeOfHeapReserve; - u_long SizeOfHeapCommit; - u_long LoaderFlags; - u_long NumberOfRvaAndSizes; - DATA_DIRECTORY DataDirectory[16]; - } OPTIONAL_HDR; - -typedef struct { - char Name[8]; - u_long VirtualSize; - u_long VirtualAddress; - u_long SizeOfRawData; - u_long PointerToRawData; - u_long PointerToRelocations; - u_long PointerToLineNumbers; - u_short NumberOfRelocations; - u_short NumberOfLineNumbers; - u_long Characteristics; - } SECTION_HDR; - -/* Structure defining a fixup table entry block in the .reloc section */ - -typedef struct { - u_long PageRVA; - u_long BlockSize; - } BASE_RELOCATION; - -/* Structure defining the export directory table */ - -typedef struct { - u_long ExportFlags; - u_long TimeDateStamp; - u_short MajorVersion; - u_short MinorVersion; - u_long NameRVA; - u_long OrdinalBase; - u_long AddressTableEntries; - u_long NumberOfNamePointers; - u_long AddressTableRVA; - u_long NameTableRVA; - u_long OrdinalTableRVA; - } EXPORT_DIRECTORY; - -#include "poppck.h" - -#endif /* __PE_H */ diff --git a/bld/dig/c/linux/peloader.c b/bld/dig/c/linux/peloader.c index cb6f21c07c..93d5398bb6 100644 --- a/bld/dig/c/linux/peloader.c +++ b/bld/dig/c/linux/peloader.c @@ -37,13 +37,14 @@ ****************************************************************************/ #include "peloader.h" -#include "pe.h" +#include "exepe.h" #include #include #include "bool.h" #include "exedos.h" #include "dbgmod.h" #include "digld.h" +#include "roundmac.h" /*--------------------------- Global variables ----------------------------*/ @@ -69,8 +70,8 @@ open file and an offset within that file for the DLL to load. static bool PE_readHeader( FILE *fp, long startOffset, - FILE_HDR *filehdr, - OPTIONAL_HDR *opthdr) + pe_file_header *filehdr, + pe32_opt_header *opthdr) { dos_exe_header exehdr; u_long ne_header_off; @@ -101,15 +102,15 @@ static bool PE_readHeader( */ if( DIGLoader( Read )( fp, filehdr, sizeof( *filehdr ) ) ) return( false ); - if( filehdr->Machine != IMAGE_FILE_MACHINE_I386 ) + if( filehdr->cpu_type != PE_CPU_386 ) return( false ); - if( (filehdr->Characteristics & IMAGE_FILE_32BIT_MACHINE) == 0 ) + if( (filehdr->flags & PE_FLG_32BIT_MACHINE) == 0 ) return( false ); - if( (filehdr->Characteristics & IMAGE_FILE_DLL) == 0 ) + if( (filehdr->flags & PE_FLG_LIBRARY) == 0 ) return( false ); if( DIGLoader( Read )( fp, opthdr, sizeof( *opthdr ) ) ) return( false ); - if( opthdr->Magic != 0x10B ) + if( opthdr->magic != 0x10B ) return( false ); /* * Success, so return true! @@ -137,9 +138,9 @@ length of the DLL file on disk. ****************************************************************************/ u_long PE_getFileSize( FILE *fp, u_long startOffset ) { - FILE_HDR filehdr; - OPTIONAL_HDR opthdr; - SECTION_HDR secthdr; + pe_file_header filehdr; + pe32_opt_header opthdr; + pe_object secthdr; u_long size; int i; @@ -151,12 +152,12 @@ u_long PE_getFileSize( FILE *fp, u_long startOffset ) /* * Scan all the section headers summing up the total size */ - size = opthdr.SizeOfHeaders; - for( i = 0; i < filehdr.NumberOfSections; i++ ) { + size = opthdr.header_size; + for( i = 0; i < filehdr.num_objects; i++ ) { if( DIGLoader( Read )( fp, §hdr, sizeof( secthdr ) ) ) return( 0xFFFFFFFF ); - if( (secthdr.Characteristics & IMAGE_SCN_CNT_UNINITIALIZED_DATA) == 0 ) { - size += secthdr.SizeOfRawData; + if( (secthdr.flags & PE_OBJ_UNINIT_DATA) == 0 ) { + size += secthdr.physical_size; } } return( size ); @@ -191,9 +192,9 @@ PE_MODULE * PE_loadLibraryExt( u_long startOffset, u_long *size) { - FILE_HDR filehdr; - OPTIONAL_HDR opthdr; - SECTION_HDR secthdr; + pe_file_header filehdr; + pe32_opt_header opthdr; + pe_object secthdr; u_long offset, pageOffset; u_long text_raw_off, text_base, text_size, text_end; u_long data_raw_off, data_base, data_size, data_virt_size, data_end; @@ -207,7 +208,7 @@ PE_MODULE * PE_loadLibraryExt( u_short relocType, *fixup; PE_MODULE *hMod = NULL; void *reloc = NULL; - BASE_RELOCATION *baseReloc; + pe_fixup_header *baseReloc; /* * Read the PE file headers from disk @@ -223,58 +224,58 @@ PE_MODULE * PE_loadLibraryExt( import_raw_off = import_base = import_size = import_end = 0; export_raw_off = export_base = export_size = export_end = 0; reloc_raw_off = reloc_size = 0; - for( i = 0; i < filehdr.NumberOfSections; i++ ) { + for( i = 0; i < filehdr.num_objects; i++ ) { if( DIGLoader( Read )( fp, §hdr, sizeof( secthdr ) ) ) goto Error; if( i == 0 ) - image_base = secthdr.VirtualAddress; - if( strcmp( secthdr.Name, ".edata" ) == 0 || strcmp( secthdr.Name, ".rdata" ) == 0 ) { + image_base = secthdr.rva; + if( strcmp( secthdr.name, ".edata" ) == 0 || strcmp( secthdr.name, ".rdata" ) == 0 ) { /* * Exports section */ - export_raw_off = secthdr.PointerToRawData; - export_base = secthdr.VirtualAddress; - export_size = secthdr.SizeOfRawData; + export_raw_off = secthdr.physical_offset; + export_base = secthdr.rva; + export_size = secthdr.physical_size; export_end = export_base + export_size; - } else if( strcmp( secthdr.Name, ".idata" ) == 0 ) { + } else if( strcmp( secthdr.name, ".idata" ) == 0 ) { /* * Imports section */ - import_raw_off = secthdr.PointerToRawData; - import_base = secthdr.VirtualAddress; - import_size = secthdr.SizeOfRawData; + import_raw_off = secthdr.physical_offset; + import_base = secthdr.rva; + import_size = secthdr.physical_size; import_end = import_base + import_size; - } else if( strcmp( secthdr.Name, ".reloc" ) == 0 ) { + } else if( strcmp( secthdr.name, ".reloc" ) == 0 ) { /* * Relocations section */ - reloc_raw_off = secthdr.PointerToRawData; - reloc_base = secthdr.VirtualAddress; - reloc_size = secthdr.SizeOfRawData; - } else if( text_raw_off == 0 && (secthdr.Characteristics & IMAGE_SCN_CNT_CODE) ) { + reloc_raw_off = secthdr.physical_offset; + reloc_base = secthdr.rva; + reloc_size = secthdr.physical_size; + } else if( text_raw_off == 0 && (secthdr.flags & PE_OBJ_CODE) ) { /* * Code section */ - text_raw_off = secthdr.PointerToRawData; - text_base = secthdr.VirtualAddress; - text_size = secthdr.SizeOfRawData; + text_raw_off = secthdr.physical_offset; + text_base = secthdr.rva; + text_size = secthdr.physical_size; text_end = text_base + text_size; - } else if( data_raw_off == 0 && (secthdr.Characteristics & IMAGE_SCN_CNT_INITIALIZED_DATA) ) { + } else if( data_raw_off == 0 && (secthdr.flags & PE_OBJ_INIT_DATA) ) { /* * Data section */ - data_raw_off = secthdr.PointerToRawData; - data_base = secthdr.VirtualAddress; - data_size = secthdr.SizeOfRawData; - data_virt_size = secthdr.VirtualSize; + data_raw_off = secthdr.physical_offset; + data_base = secthdr.rva; + data_size = secthdr.physical_size; + data_virt_size = secthdr.virtual_size; data_end = data_base + data_size; - } else if( bss_raw_off == 0 && (secthdr.Characteristics & IMAGE_SCN_CNT_UNINITIALIZED_DATA) ) { + } else if( bss_raw_off == 0 && (secthdr.flags & PE_OBJ_UNINIT_DATA) ) { /* * BSS data section */ - bss_raw_off = secthdr.PointerToRawData; - bss_base = secthdr.VirtualAddress; - bss_size = secthdr.SizeOfRawData; + bss_raw_off = secthdr.physical_offset; + bss_base = secthdr.rva; + bss_size = secthdr.physical_size; bss_end = bss_base + bss_size; } } @@ -338,7 +339,7 @@ PE_MODULE * PE_loadLibraryExt( hMod->bssBase = bss_base; hMod->importBase = import_base; hMod->exportBase = export_base; - hMod->exportDir = opthdr.DataDirectory[0].RelVirtualAddress - export_base; + hMod->exportDir = opthdr.table[PE_TBL_EXPORT].rva - export_base; hMod->modname = NULL; /* * Now read the section images from disk @@ -353,7 +354,7 @@ PE_MODULE * PE_loadLibraryExt( * Some linkers will put uninitalised data at the end * of the primary data section, so we first must clear * the data section to zeros for the entire length of - * VirtualSize, which can be longer than the size on disk. + * virtual_size, which can be longer than the size on disk. * Note also that some linkers set this value to zero, so * we ignore this value in that case (those linkers also * have a seperate BSS section). @@ -382,20 +383,20 @@ PE_MODULE * PE_loadLibraryExt( /* * Now perform relocations on all sections in the image */ - delta = (u_long)image_ptr - opthdr.ImageBase - image_base; - baseReloc = (BASE_RELOCATION*)reloc; + delta = (u_long)image_ptr - opthdr.image_base - image_base; + baseReloc = (pe_fixup_header *)reloc; for( ;; ) { /* * Check for termination condition */ - if( baseReloc->PageRVA == 0 || baseReloc->BlockSize == 0 ) + if( baseReloc->page_rva == 0 || baseReloc->block_size == 0 ) break; /* * Do fixups */ - numFixups = ( baseReloc->BlockSize - sizeof( BASE_RELOCATION ) ) / sizeof( u_short ); + numFixups = ( baseReloc->block_size - sizeof( pe_fixup_header ) ) / sizeof( u_short ); fixup = (u_short*)( baseReloc + 1 ); - pageOffset = baseReloc->PageRVA - image_base; + pageOffset = baseReloc->page_rva - image_base; for( i = 0; i < numFixups; i++ ) { relocType = *fixup >> 12; if( relocType ) { @@ -407,7 +408,7 @@ PE_MODULE * PE_loadLibraryExt( /* * Move to next relocation block */ - baseReloc = (BASE_RELOCATION*)( (u_long)baseReloc + baseReloc->BlockSize ); + baseReloc = (pe_fixup_header*)( (u_long)baseReloc + baseReloc->block_size ); } /* * On some platforms (such as AMD64 or x86 with NX bit), it is required @@ -516,7 +517,7 @@ void * PE_getProcAddress( const char *szProcName ) { unsigned i; - EXPORT_DIRECTORY *exports; + pe_export_directory *exports; u_long funcOffset; u_long *AddressTable; u_long *NameTable; @@ -528,20 +529,20 @@ void * PE_getProcAddress( */ if( hModule == NULL ) return( NULL ); - exports = (EXPORT_DIRECTORY *)( hModule->pexport + hModule->exportDir ); - AddressTable = (u_long *)( hModule->pexport + exports->AddressTableRVA - hModule->exportBase ); - NameTable = (u_long*)( hModule->pexport + exports->NameTableRVA - hModule->exportBase ); - OrdinalTable = (u_short*)( hModule->pexport + exports->OrdinalTableRVA - hModule->exportBase ); + exports = (pe_export_directory *)( hModule->pexport + hModule->exportDir ); + AddressTable = (u_long *)( hModule->pexport + exports->address_table_rva - hModule->exportBase ); + NameTable = (u_long*)( hModule->pexport + exports->name_ptr_table_rva - hModule->exportBase ); + OrdinalTable = (u_short*)( hModule->pexport + exports->ordinal_table_rva - hModule->exportBase ); /* * Search the pexport name table to find the function name */ - for( i = 0; i < exports->NumberOfNamePointers; i++ ) { + for( i = 0; i < exports->num_name_ptrs; i++ ) { name = (char*)( hModule->pexport + NameTable[i] - hModule->exportBase ); if( strcmp( name, szProcName ) == 0 ) { break; } } - if( i == exports->NumberOfNamePointers ) + if( i == exports->num_name_ptrs ) return( NULL ); funcOffset = AddressTable[OrdinalTable[i]]; if( funcOffset == 0 ) From e6143dde9e29c8533e603cf9506860db07a9eb47 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Sun, 10 Sep 2023 13:50:37 +0200 Subject: [PATCH 109/258] rename symbols to differ between local and remote system configuration --- bld/sdk/drwat/nt/madrtn.c | 2 +- bld/sdk/drwat/nt/madsys1.c | 6 +++--- bld/sdk/drwat/nt/madsys1.h | 3 ++- bld/wv/c/dbg_dbg.c | 4 ++-- bld/wv/c/remasync.c | 8 ++++---- bld/wv/c/remcore.c | 12 ++++++------ bld/wv/c/remrtrd.c | 4 ++-- bld/wv/h/remcore.h | 4 ++-- 8 files changed, 22 insertions(+), 21 deletions(-) diff --git a/bld/sdk/drwat/nt/madrtn.c b/bld/sdk/drwat/nt/madrtn.c index 803c89015a..011425f982 100644 --- a/bld/sdk/drwat/nt/madrtn.c +++ b/bld/sdk/drwat/nt/madrtn.c @@ -212,7 +212,7 @@ unsigned MADCLIENTRY( MachineData )( address addr, dig_info_type info_type, dig_ bool InitMADInfo( void ) { - GetSysConfig(); + LocalGetSysConfig(); if( MADInit() != MS_OK ) { return( false ); } diff --git a/bld/sdk/drwat/nt/madsys1.c b/bld/sdk/drwat/nt/madsys1.c index 303a7c658a..e70965ce61 100644 --- a/bld/sdk/drwat/nt/madsys1.c +++ b/bld/sdk/drwat/nt/madsys1.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -38,7 +38,7 @@ #if defined( _M_IX86 ) -void GetSysConfig(void) +void LocalGetSysConfig(void) { SYSTEM_INFO sys; @@ -117,7 +117,7 @@ void StoreMADRegisters( mad_registers *MadRegisters, HANDLE threadhdl ) } #elif defined __AXP__ -void GetSysConfig( void ) +void LocalGetSysConfig( void ) { SysConfig.cpu = 0; SysConfig.fpu = 0; diff --git a/bld/sdk/drwat/nt/madsys1.h b/bld/sdk/drwat/nt/madsys1.h index 40ad58fda0..a63673d0f6 100644 --- a/bld/sdk/drwat/nt/madsys1.h +++ b/bld/sdk/drwat/nt/madsys1.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -30,6 +31,6 @@ ****************************************************************************/ -extern void GetSysConfig( void ); +extern void LocalGetSysConfig( void ); extern void LoadMADRegisters( mad_registers *MadRegisters, HANDLE threadhdl ); extern void StoreMADRegisters( mad_registers *MadRegisters, HANDLE threadhdl ); diff --git a/bld/wv/c/dbg_dbg.c b/bld/wv/c/dbg_dbg.c index cf272d680a..b709ac252a 100644 --- a/bld/wv/c/dbg_dbg.c +++ b/bld/wv/c/dbg_dbg.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -247,7 +247,7 @@ bool CreateSym( lookup_item *li, dig_type_info *ti ) static void GetNPXType( void ) { if( _IsOff( SW_KNOW_EMULATOR ) ) { - GetSysConfig(); /* might be emulator */ + RemoteGetSysConfig(); /* might be emulator */ _SwitchOn( SW_KNOW_EMULATOR ); } } diff --git a/bld/wv/c/remasync.c b/bld/wv/c/remasync.c index 43ffe18e8d..46bb65eefb 100644 --- a/bld/wv/c/remasync.c +++ b/bld/wv/c/remasync.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -98,7 +98,7 @@ unsigned MakeAsyncRun( bool single ) CONV_LE_32( ret.program_counter.offset ); CONV_LE_16( ret.program_counter.segment ); if( ret.conditions & COND_CONFIG ) { - GetSysConfig(); + RemoteGetSysConfig(); CheckMADChange(); } DbgRegs->arch = SysConfig.arch; @@ -142,7 +142,7 @@ unsigned PollAsync( void ) CONV_LE_32( ret.program_counter.offset ); CONV_LE_16( ret.program_counter.segment ); if( ret.conditions & COND_CONFIG ) { - GetSysConfig(); + RemoteGetSysConfig(); CheckMADChange(); } DbgRegs->arch = SysConfig.arch; @@ -186,7 +186,7 @@ unsigned StopAsync( void ) CONV_LE_32( ret.program_counter.offset ); CONV_LE_16( ret.program_counter.segment ); if( ret.conditions & COND_CONFIG ) { - GetSysConfig(); + RemoteGetSysConfig(); CheckMADChange(); } DbgRegs->arch = SysConfig.arch; diff --git a/bld/wv/c/remcore.c b/bld/wv/c/remcore.c index 7d90441575..b37c06f62b 100644 --- a/bld/wv/c/remcore.c +++ b/bld/wv/c/remcore.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -350,7 +350,7 @@ error_handle DoLoad( const char *args, unsigned long *phandle ) OnAnotherThreadAccess( 2, in, 1, out ); InitSuppServices(); GrabHandlers(); - GetSysConfig(); + RemoteGetSysConfig(); CheckMADChange(); ReadDbgRegs(); DbgRegs->tid = RemoteSetThread( 0 ); @@ -394,7 +394,7 @@ bool KillProgOvlay( void ) _SwitchOff( SW_HAVE_TASK ); GrabHandlers(); FreeThreads(); - GetSysConfig(); + RemoteGetSysConfig(); ClearMachineDataCache(); CONV_LE_32( ret.err ); return( ( ret.err == 0 ) ); @@ -419,7 +419,7 @@ unsigned MakeProgRun( bool single ) CONV_LE_16( ret.program_counter.segment ); CONV_LE_16( ret.conditions ); if( ret.conditions & COND_CONFIG ) { - GetSysConfig(); + RemoteGetSysConfig(); CheckMADChange(); } DbgRegs->arch = SysConfig.arch; @@ -688,7 +688,7 @@ void CheckSegAlias( void ) } } -void GetSysConfig( void ) +void RemoteGetSysConfig( void ) { get_sys_config_req acc; get_sys_config_ret ret; @@ -711,7 +711,7 @@ bool InitCoreSupp( void ) _Alloc( MData, sizeof( *MData ) ); MData->len = sizeof( MData->data ); ClearMachineDataCache(); - GetSysConfig(); + RemoteGetSysConfig(); CheckMADChange(); return( true ); } else { diff --git a/bld/wv/c/remrtrd.c b/bld/wv/c/remrtrd.c index 3c1c8589f0..98550da2a6 100644 --- a/bld/wv/c/remrtrd.c +++ b/bld/wv/c/remrtrd.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -127,7 +127,7 @@ void RemotePollRunThread( void ) CONV_LE_16( ret.conditions ); if( ret.conditions & COND_CONFIG ) { - GetSysConfig(); + RemoteGetSysConfig(); CheckMADChange(); } if( ret.conditions & COND_THREAD ) { diff --git a/bld/wv/h/remcore.h b/bld/wv/h/remcore.h index b559565303..9d31d6bcbe 100644 --- a/bld/wv/h/remcore.h +++ b/bld/wv/h/remcore.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -58,7 +58,7 @@ extern void RemoteRestoreBreak( address addr, dword value ); extern bool RemoteSetWatch( address addr, uint_8 size, unsigned long *mult ); extern void RemoteRestoreWatch( address addr, uint_8 size ); extern void RemoteSplitCmd( char *cmd, char **end, char **parm ); +extern void RemoteGetSysConfig( void ); extern void CheckSegAlias( void ); -extern void GetSysConfig( void ); extern bool InitCoreSupp( void ); extern void FiniCoreSupp( void ); From 6bc459add7ecf6815cd5d98363d9b2e892e1cfeb Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Mon, 11 Sep 2023 02:31:26 +0200 Subject: [PATCH 110/258] change LoadTrap function to return only message code instead of message it save real-time memory in DOS trap message code can be transform to message by caller --- bld/dig/c/dos/trpld.c | 47 ++++++++++------------ bld/dig/c/dsx/dipld.c | 40 +++++++++---------- bld/dig/c/dsx/madld.c | 21 +++++----- bld/dig/c/dsx/trpld.c | 65 ++++++++++++++----------------- bld/dig/c/linux/trpld_pe.c | 43 ++++++++------------ bld/dig/c/linux/trpld_rx.c | 49 +++++++++++------------ bld/dig/c/linux/trpld_so.c | 43 ++++++++------------ bld/dig/c/nov/trpld.c | 8 ++-- bld/dig/c/nt/pillld.c | 1 + bld/dig/c/nt/trpld.c | 18 ++++----- bld/dig/c/os2/trpld.c | 18 ++++----- bld/dig/c/qnx/trpld.c | 49 +++++++++++------------ bld/dig/c/rdos/trpld.c | 18 ++++----- bld/dig/c/win/trpld.c | 18 ++++----- bld/dig/h/trpld.h | 2 +- bld/dig/h/{tcerr.h => trplderr.h} | 29 ++++++-------- bld/dig/h/trptypes.h | 1 + bld/trap/common/serv.c | 25 +++++++++++- bld/trap/common/servacc.c | 15 +------ bld/trap/common/servcmd.c | 2 +- bld/trap/common/servw.c | 25 +++++++++++- bld/trap/h/trap.msg | 3 ++ bld/wv/c/remcore.c | 12 ------ bld/wv/c/remmisc.c | 25 +++++++++++- bld/wv/master.mif | 16 ++++++-- bld/wv/rfx/master.mif | 7 +++- bld/wv/rfx/rfx.c | 17 -------- 27 files changed, 297 insertions(+), 320 deletions(-) rename bld/dig/h/{tcerr.h => trplderr.h} (69%) diff --git a/bld/dig/c/dos/trpld.c b/bld/dig/c/dos/trpld.c index 852b5809ce..eec2e1c1d1 100644 --- a/bld/dig/c/dos/trpld.c +++ b/bld/dig/c/dos/trpld.c @@ -39,7 +39,6 @@ #include "exedos.h" #include "digld.h" #include "trpld.h" -#include "tcerr.h" #define TRAP_SIGNATURE 0xDEAF @@ -56,7 +55,7 @@ typedef struct { static trap_header __far *TrapCode = NULL; static trap_fini_func *FiniFunc = NULL; -static char *ReadInTrap( FILE *fp ) +static trpld_error ReadInTrap( FILE *fp ) { dos_exe_header hdr; unsigned size; @@ -100,7 +99,7 @@ static char *ReadInTrap( FILE *fp ) *fixup += start_seg; ++p; } - return( NULL ); + return( TC_OK ); } void UnLoadTrap( void ) @@ -116,13 +115,13 @@ void UnLoadTrap( void ) } } -char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) +trpld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) { FILE *fp; trap_init_func *init_func; char filename[256]; const char *base_name; - const char *err; + trpld_error err; size_t len; if( parms == NULL || *parms == '\0' ) @@ -137,36 +136,30 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) len++; } if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, len, ".trp", filename, sizeof( filename ) ) == 0 ) { - sprintf( buff, TC_ERR_CANT_LOAD_TRAP, base_name ); - return( buff ); + return( TC_ERR_CANT_FIND_TRAP ); } fp = DIGLoader( Open )( filename ); if( fp == NULL ) { - sprintf( buff, TC_ERR_CANT_LOAD_TRAP, filename ); - return( buff ); + return( TC_ERR_CANT_LOAD_TRAP ); } - buff[0] = '\0'; err = ReadInTrap( fp ); DIGLoader( Close )( fp ); - if( err == TC_ERR_CANT_LOAD_TRAP ) { - sprintf( buff, TC_ERR_CANT_LOAD_TRAP, filename ); - } else if( err == NULL ) { - if( TrapCode->signature == TRAP_SIGNATURE ) { - init_func = _MK_FP( _FP_SEG( TrapCode ), TrapCode->init_off ); - FiniFunc = _MK_FP( _FP_SEG( TrapCode ), TrapCode->fini_off ); - ReqFunc = _MK_FP( _FP_SEG( TrapCode ), TrapCode->req_off ); - *trap_ver = init_func( parms, buff, trap_ver->remote ); - if( buff[0] == '\0' ) { - if( TrapVersionOK( *trap_ver ) ) { - TrapVer = *trap_ver; - return( NULL ); - } + if( err != TC_OK ) { + return( err ); + } + err = TC_ERR_BAD_TRAP_FILE; + if( TrapCode->signature == TRAP_SIGNATURE ) { + init_func = _MK_FP( _FP_SEG( TrapCode ), TrapCode->init_off ); + FiniFunc = _MK_FP( _FP_SEG( TrapCode ), TrapCode->fini_off ); + ReqFunc = _MK_FP( _FP_SEG( TrapCode ), TrapCode->req_off ); + *trap_ver = init_func( parms, buff, trap_ver->remote ); + if( buff[0] == '\0' ) { + if( TrapVersionOK( *trap_ver ) ) { + TrapVer = *trap_ver; + return( TC_OK ); } } - err = TC_ERR_WRONG_TRAP_VERSION; } - if( buff[0] == '\0' ) - strcpy( buff, err ); UnLoadTrap(); - return( buff ); + return( err ); } diff --git a/bld/dig/c/dsx/dipld.c b/bld/dig/c/dsx/dipld.c index 4c3e5b18f2..94d0494e55 100644 --- a/bld/dig/c/dsx/dipld.c +++ b/bld/dig/c/dsx/dipld.c @@ -59,7 +59,7 @@ dip_status DIPSysLoad( const char *base_name, dip_client_routines *cli, dip_imp_ FILE *fp; imp_header *mod_hdl; dip_init_func *init_func; - dip_status ds; + dip_status status; char filename[_MAX_PATH]; *sys_hdl = NULL_SYSHDL; @@ -72,30 +72,26 @@ dip_status DIPSysLoad( const char *base_name, dip_client_routines *cli, dip_imp_ } mod_hdl = ReadInImp( fp ); DIGLoader( Close )( fp ); - ds = DS_ERR | DS_INVALID_DIP; - if( mod_hdl != NULL ) { + status = DS_ERR | DS_INVALID_DIP; + if( mod_hdl == NULL ) { + return( status ); + } #ifdef __WATCOMC__ - if( mod_hdl->sig == DIPSIG ) { -#endif -#ifdef WATCOM_DEBUG_SYMBOLS - /* - * Look for symbols in separate .sym files, not the .dip itself - */ - strcpy( filename + strlen( filename ) - 4, ".sym" ); - DebuggerLoadUserModule( filename, GetCS(), (unsigned long)mod_hdl ); + init_func = (dip_init_func *)((mod_hdl->sig == DIPSIG) ? mod_hdl->init_rtn : NULL); +#else + init_func = (dip_init_func *)mod_hdl->init_rtn; #endif - init_func = (dip_init_func *)mod_hdl->init_rtn; - if( init_func != NULL && (*imp = init_func( &ds, cli )) != NULL ) { - *sys_hdl = mod_hdl; - return( DS_OK ); - } + if( init_func != NULL && (*imp = init_func( &status, cli )) != NULL ) { #ifdef WATCOM_DEBUG_SYMBOLS - DebuggerUnloadUserModule( filename ); -#endif -#ifdef __WATCOMC__ - } + /* + * Look for symbols in separate .sym files, not the .dip itself + */ + strcpy( filename + strlen( filename ) - 4, ".sym" ); + DebuggerLoadUserModule( filename, GetCS(), (unsigned long)mod_hdl ); #endif - DIPSysUnload( (dip_sys_handle *)&mod_hdl ); + *sys_hdl = mod_hdl; + return( DS_OK ); } - return( ds ); + DIPSysUnload( (dip_sys_handle *)&mod_hdl ); + return( status ); } diff --git a/bld/dig/c/dsx/madld.c b/bld/dig/c/dsx/madld.c index 77b3bb1140..ee6c6b15d3 100644 --- a/bld/dig/c/dsx/madld.c +++ b/bld/dig/c/dsx/madld.c @@ -72,19 +72,18 @@ mad_status MADSysLoad( const char *base_name, mad_client_routines *cli, mod_hdl = ReadInImp( fp ); DIGLoader( Close )( fp ); status = MS_ERR | MS_INVALID_MAD; - if( mod_hdl != NULL ) { -#ifdef __WATCOMC__ - if( mod_hdl->sig == MADSIG ) { -#endif - init_func = (mad_init_func *)mod_hdl->init_rtn; - if( init_func != NULL && (*imp = init_func( &status, cli )) != NULL ) { - *sys_hdl = mod_hdl; - return( MS_OK ); - } + if( mod_hdl == NULL ) { + return( status ); + } #ifdef __WATCOMC__ - } + init_func = (mad_init_func *)((mod_hdl->sig == MADSIG) ? mod_hdl->init_rtn : NULL); +#else + init_func = (mad_init_func *)mod_hdl->init_rtn; #endif - MADSysUnload( (mad_sys_handle *)&mod_hdl ); + if( init_func != NULL && (*imp = init_func( &status, cli )) != NULL ) { + *sys_hdl = mod_hdl; + return( MS_OK ); } + MADSysUnload( (mad_sys_handle *)&mod_hdl ); return( status ); } diff --git a/bld/dig/c/dsx/trpld.c b/bld/dig/c/dsx/trpld.c index 2dcfdea5f9..fc7dc5deeb 100644 --- a/bld/dig/c/dsx/trpld.c +++ b/bld/dig/c/dsx/trpld.c @@ -43,7 +43,6 @@ #include "trpld.h" #include "trpcore.h" #include "trpsys.h" -#include "tcerr.h" #include "envlkup.h" #include "realmod.h" @@ -303,7 +302,7 @@ static uint_16 EnvAreaSize( char __far *envarea ) return( envptr - envarea + 1 ); } -static char *CopyEnv( void ) +static trpld_error CopyEnv( void ) { char __far *envarea; uint_16 envsize; @@ -315,10 +314,10 @@ static char *CopyEnv( void ) return( TC_ERR_OUT_OF_DOS_MEMORY ); } _fmemcpy( EXTENDER_RM2PM( PMData->envseg.rm, 0 ), envarea, envsize ); - return( NULL ); + return( TC_OK ); } -static char *SetTrapHandler( void ) +static trpld_error SetTrapHandler( void ) { char dummy; long sel; @@ -369,7 +368,7 @@ static char *SetTrapHandler( void ) if( IntrState == IS_RATIONAL ) { MySetRMVector( TRAP_VECTOR, RMData.rm, RM_OFF( RMTrapHandler ) ); } - return( NULL ); + return( TC_OK ); } static bool CallTrapInit( const char *parms, char *errmsg, trap_version *trap_ver ) @@ -386,7 +385,7 @@ static bool CallTrapInit( const char *parms, char *errmsg, trap_version *trap_ve return( *errmsg == '\0' ); } -static char *ReadInTrap( FILE *fp ) +static trpld_error ReadInTrap( FILE *fp ) { dos_exe_header hdr; memptr relocbuff[NUM_BUFF_RELOCS]; @@ -421,7 +420,7 @@ static char *ReadInTrap( FILE *fp ) } *(addr_seg __far *)EXTENDER_RM2PM( TrapMem.rm + relocbuff[relocnb].s.segment, relocbuff[relocnb].s.offset ) += TrapMem.rm; } - return( NULL ); + return( TC_OK ); } static trap_retval DoTrapAccess( trap_elen num_in_mx, in_mx_entry_p mx_in, trap_elen num_out_mx, mx_entry_p mx_out ) @@ -485,13 +484,13 @@ static trap_retval DoTrapAccess( trap_elen num_in_mx, in_mx_entry_p mx_in, trap_ return( callstruct->retlen ); } -char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) +trpld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) { FILE *fp; trap_file_header __far *head; char filename[256]; const char *base_name; - const char *err; + trpld_error err; size_t len; if( parms == NULL || *parms == '\0' ) @@ -506,44 +505,38 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) len++; } if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, len, ".trp", filename, sizeof( filename ) ) == 0 ) { - sprintf( buff, TC_ERR_CANT_LOAD_TRAP, base_name ); - return( buff ); + return( TC_ERR_CANT_FIND_TRAP ); } fp = DIGLoader( Open )( filename ); if( fp == NULL ) { - sprintf( buff, TC_ERR_CANT_LOAD_TRAP, filename ); - return( buff ); + return( TC_ERR_CANT_LOAD_TRAP ); } - buff[0] = '\0'; err = ReadInTrap( fp ); DIGLoader( Close )( fp ); - if( err == TC_ERR_CANT_LOAD_TRAP ) { - sprintf( buff, TC_ERR_CANT_LOAD_TRAP, filename ); - } else if( err == NULL ) { - if( (err = SetTrapHandler()) == NULL && (err = CopyEnv()) == NULL ) { - head = EXTENDER_RM2PM( TrapMem.rm, 0 ); - if( head->sig == TRAP_SIGNATURE ) { - PMData->initfunc.s.offset = head->init; - PMData->reqfunc.s.offset = head->req; - PMData->finifunc.s.offset = head->fini; - PMData->initfunc.s.segment = TrapMem.rm; - PMData->reqfunc.s.segment = TrapMem.rm; - PMData->finifunc.s.segment = TrapMem.rm; - if( CallTrapInit( parms, buff, trap_ver ) ) { - if( TrapVersionOK( *trap_ver ) ) { - TrapVer = *trap_ver; - ReqFunc = DoTrapAccess; - return( NULL ); - } + if( err != TC_OK ) { + return( err ); + } + if( (err = SetTrapHandler()) == TC_OK && (err = CopyEnv()) == TC_OK ) { + err = TC_ERR_BAD_TRAP_FILE; + head = EXTENDER_RM2PM( TrapMem.rm, 0 ); + if( head->sig == TRAP_SIGNATURE ) { + PMData->initfunc.s.offset = head->init; + PMData->reqfunc.s.offset = head->req; + PMData->finifunc.s.offset = head->fini; + PMData->initfunc.s.segment = TrapMem.rm; + PMData->reqfunc.s.segment = TrapMem.rm; + PMData->finifunc.s.segment = TrapMem.rm; + if( CallTrapInit( parms, buff, trap_ver ) ) { + if( TrapVersionOK( *trap_ver ) ) { + TrapVer = *trap_ver; + ReqFunc = DoTrapAccess; + return( TC_OK ); } } - err = TC_ERR_WRONG_TRAP_VERSION; } } - if( buff[0] == '\0' ) - strcpy( buff, err ); UnLoadTrap(); - return( buff ); + return( err ); } void UnLoadTrap( void ) diff --git a/bld/dig/c/linux/trpld_pe.c b/bld/dig/c/linux/trpld_pe.c index f58eabde1b..3d4a122ac2 100644 --- a/bld/dig/c/linux/trpld_pe.c +++ b/bld/dig/c/linux/trpld_pe.c @@ -35,7 +35,6 @@ #include #include "digld.h" #include "trpld.h" -#include "tcerr.h" #include "peloader.h" @@ -76,10 +75,11 @@ void UnLoadTrap( void ) #endif } -char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) +trpld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) { trap_load_func *ld_func; const trap_requests *trap_funcs; + trpld_error err; #if !defined( BUILTIN_TRAP_FILE ) FILE *fp; char filename[_MAX_PATH]; @@ -104,43 +104,34 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) } #if !defined( BUILTIN_TRAP_FILE ) if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, len, ".trp", filename, sizeof( filename ) ) == 0 ) { - sprintf( buff, TC_ERR_CANT_LOAD_TRAP, base_name ); - return( buff ); + return( TC_ERR_CANT_FIND_TRAP ); } - sprintf( buff, TC_ERR_CANT_LOAD_TRAP, filename ); fp = DIGLoader( Open )( filename ); if( fp == NULL ) { - return( buff ); + return( TC_ERR_CANT_LOAD_TRAP ); } mod_hdl = PE_loadLibraryFile( fp, filename ); DIGLoader( Close )( fp ); if( mod_hdl == NULL ) { - return( buff ); + return( TC_ERR_CANT_LOAD_TRAP ); } - buff[0] = '\0'; ld_func = (trap_load_func *)PE_getProcAddress( mod_hdl, "TrapLoad_" ); - if( ld_func != NULL ) { + trap_funcs = ((ld_func != NULL) ? ld_func( &TrapCallbacks ) : NULL); #else - buff[0] = '\0'; - ld_func = TrapLoad; + trap_funcs = TrapLoad( &TrapCallbacks ); #endif - trap_funcs = ld_func( &TrapCallbacks ); - if( trap_funcs != NULL ) { - *trap_ver = trap_funcs->init_func( parms, buff, trap_ver->remote ); - FiniFunc = trap_funcs->fini_func; - ReqFunc = trap_funcs->req_func; - if( buff[0] == '\0' ) { - if( TrapVersionOK( *trap_ver ) ) { - TrapVer = *trap_ver; - return( NULL ); - } + err = TC_ERR_BAD_TRAP_FILE; + if( trap_funcs != NULL ) { + *trap_ver = trap_funcs->init_func( parms, buff, trap_ver->remote ); + FiniFunc = trap_funcs->fini_func; + ReqFunc = trap_funcs->req_func; + if( buff[0] == '\0' ) { + if( TrapVersionOK( *trap_ver ) ) { + TrapVer = *trap_ver; + return( TC_OK ); } } -#if !defined( BUILTIN_TRAP_FILE ) } -#endif - if( buff[0] == '\0' ) - strcpy( buff, TC_ERR_WRONG_TRAP_VERSION ); UnLoadTrap(); - return( buff ); + return( err ); } diff --git a/bld/dig/c/linux/trpld_rx.c b/bld/dig/c/linux/trpld_rx.c index 4530c947ab..aa682ff636 100644 --- a/bld/dig/c/linux/trpld_rx.c +++ b/bld/dig/c/linux/trpld_rx.c @@ -39,7 +39,6 @@ #include "digld.h" #include "trpld.h" #include "trpimp.h" -#include "tcerr.h" #include "ldimp.h" @@ -74,7 +73,7 @@ void UnLoadTrap( void ) } } -char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) +trpld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) { FILE *fp; trap_load_func *ld_func; @@ -82,6 +81,7 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) char filename[256]; const char *base_name; size_t len; + trpld_error err; if( parms == NULL || *parms == '\0' ) parms = DEFAULT_TRP_NAME; @@ -95,40 +95,37 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) len++; } if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, len, ".trp", filename, sizeof( filename ) ) == 0 ) { - sprintf( buff, TC_ERR_CANT_LOAD_TRAP, base_name ); - return( buff ); + return( TC_ERR_CANT_FIND_TRAP ); } - sprintf( buff, TC_ERR_CANT_LOAD_TRAP, filename ); fp = DIGLoader( Open )( filename ); if( fp == NULL ) { - return( buff ); + return( TC_ERR_CANT_LOAD_TRAP ); } TrapCode = ReadInImp( fp ); DIGLoader( Close )( fp ); - if( TrapCode != NULL ) { - buff[0] = '\0'; + if( TrapCode == NULL ) { + return( TC_ERR_CANT_LOAD_TRAP ); + } + err = TC_ERR_BAD_TRAP_FILE; #ifdef __WATCOMC__ - if( TrapCode->sig == TRAPSIG ) { + ld_func = (trap_load_func *)((TrapCode->sig == TRAPSIG) ? TrapCode->init_rtn : NULL); +#else + ld_func = (trap_load_func *)TrapCode->init_rtn; #endif - ld_func = (trap_load_func *)TrapCode->init_rtn; - trap_funcs = ld_func( &TrapCallbacks ); - if( trap_funcs != NULL ) { - *trap_ver = trap_funcs->init_func( parms, buff, trap_ver->remote ); - FiniFunc = trap_funcs->fini_func; - ReqFunc = trap_funcs->req_func; - if( buff[0] == '\0' ) { - if( TrapVersionOK( *trap_ver ) ) { - TrapVer = *trap_ver; - return( NULL ); - } + if( ld_func != NULL ) { + trap_funcs = ld_func( &TrapCallbacks ); + if( trap_funcs != NULL ) { + *trap_ver = trap_funcs->init_func( parms, buff, trap_ver->remote ); + FiniFunc = trap_funcs->fini_func; + ReqFunc = trap_funcs->req_func; + if( buff[0] == '\0' ) { + if( TrapVersionOK( *trap_ver ) ) { + TrapVer = *trap_ver; + return( TC_OK ); } } -#ifdef __WATCOMC__ } -#endif - if( buff[0] == '\0' ) - strcpy( buff, TC_ERR_BAD_TRAP_FILE ); - UnLoadTrap(); } - return( buff ); + UnLoadTrap(); + return( err ); } diff --git a/bld/dig/c/linux/trpld_so.c b/bld/dig/c/linux/trpld_so.c index e4d889b0a4..0ee7ffde43 100644 --- a/bld/dig/c/linux/trpld_so.c +++ b/bld/dig/c/linux/trpld_so.c @@ -36,7 +36,6 @@ #include #include "digld.h" #include "trpld.h" -#include "tcerr.h" #include "clibext.h" @@ -78,11 +77,12 @@ void UnLoadTrap( void ) #endif } -char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) +trpld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) { FILE *fp; trap_load_func *ld_func; const trap_requests *trap_funcs; + trpld_error err; #if !defined( BUILTIN_TRAP_FILE ) char filename[_MAX_PATH]; const char *base_name; @@ -106,44 +106,35 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) } #if !defined( BUILTIN_TRAP_FILE ) if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, len, ".so", filename, sizeof( filename ) ) == 0 ) { - sprintf( buff, TC_ERR_CANT_LOAD_TRAP, base_name ); - return( buff ); + return( TC_ERR_CANT_FIND_TRAP ); } - sprintf( buff, TC_ERR_CANT_LOAD_TRAP, filename ); fp = DIGLoader( Open )( filename ); if( fp == NULL ) { - return( buff ); + return( TC_ERR_CANT_LOAD_TRAP ); } mod_hdl = dlopen( filename, RTLD_NOW ); DIGLoader( Close )( fp ); if( mod_hdl == NULL ) { puts( dlerror() ); - return( buff ); + return( TC_ERR_CANT_LOAD_TRAP ); } - buff[0] = '\0'; ld_func = (trap_load_func *)dlsym( mod_hdl, "TrapLoad" ); - if( ld_func != NULL ) { + trap_funcs = ((ld_func != NULL) ? ld_func( &TrapCallbacks ) : NULL); #else - buff[0] = '\0'; - ld_func = TrapLoad; + trap_funcs = TrapLoad( &TrapCallbacks ); #endif - trap_funcs = ld_func( &TrapCallbacks ); - if( trap_funcs != NULL ) { - *trap_ver = trap_funcs->init_func( parms, buff, trap_ver->remote ); - FiniFunc = trap_funcs->fini_func; - ReqFunc = trap_funcs->req_func; - if( buff[0] == '\0' ) { - if( TrapVersionOK( *trap_ver ) ) { - TrapVer = *trap_ver; - return( NULL ); - } + err = TC_ERR_BAD_TRAP_FILE; + if( trap_funcs != NULL ) { + *trap_ver = trap_funcs->init_func( parms, buff, trap_ver->remote ); + FiniFunc = trap_funcs->fini_func; + ReqFunc = trap_funcs->req_func; + if( buff[0] == '\0' ) { + if( TrapVersionOK( *trap_ver ) ) { + TrapVer = *trap_ver; + return( TC_OK ); } } -#if !defined( BUILTIN_TRAP_FILE ) } -#endif - if( buff[0] == '\0' ) - strcpy( buff, TC_ERR_WRONG_TRAP_VERSION ); UnLoadTrap(); - return( buff ); + return( err ); } diff --git a/bld/dig/c/nov/trpld.c b/bld/dig/c/nov/trpld.c index b970d7aee4..d3639ff0ca 100644 --- a/bld/dig/c/nov/trpld.c +++ b/bld/dig/c/nov/trpld.c @@ -35,7 +35,6 @@ #include "digld.h" #include "trpld.h" #include "trpcomm.h" -#include "tcerr.h" void UnLoadTrap( void ) @@ -43,7 +42,7 @@ void UnLoadTrap( void ) TrapFini(); } -char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) +trpld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) { const char *trpname; size_t len; @@ -64,10 +63,9 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) if( TrapVersionOK( *trap_ver ) ) { TrapVer = *trap_ver; ReqFunc = TrapRequest; - return( NULL ); + return( TC_OK ); } - strcpy( buff, TC_ERR_WRONG_TRAP_VERSION ); } UnLoadTrap(); - return( buff ); + return( TC_ERR_BAD_TRAP_FILE ); } diff --git a/bld/dig/c/nt/pillld.c b/bld/dig/c/nt/pillld.c index 09d5fe64f7..7192b9edf2 100644 --- a/bld/dig/c/nt/pillld.c +++ b/bld/dig/c/nt/pillld.c @@ -37,6 +37,7 @@ #include "pillimp.h" #include "pillctrl.h" + int PILLSysLoad( const char *base_name, const pill_client_routines *cli, link_handle *lh, link_message *msg ) { diff --git a/bld/dig/c/nt/trpld.c b/bld/dig/c/nt/trpld.c index 17d55ef9ec..c0a0d2fdd6 100644 --- a/bld/dig/c/nt/trpld.c +++ b/bld/dig/c/nt/trpld.c @@ -38,7 +38,6 @@ #include "digld.h" #include "trpld.h" #include "trpsys.h" -#include "tcerr.h" #define pick(n,r,p,ar,ap) typedef r TRAPENTRY (*TRAP_EXTFUNC_TYPE(n)) ## p; @@ -95,12 +94,13 @@ void UnLoadTrap( void ) } } -char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) +trpld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) { char filename[256]; const char *base_name; size_t len; trap_init_func *init_func; + trpld_error err; if( parms == NULL || *parms == '\0' ) parms = DEFAULT_TRP_NAME; @@ -114,15 +114,13 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) len++; } if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, len, ".dll", filename, sizeof( filename ) ) == 0 ) { - sprintf( buff, TC_ERR_CANT_LOAD_TRAP, base_name ); - return( buff ); + return( TC_ERR_CANT_FIND_TRAP ); } mod_hdl = LoadLibrary( filename ); if( mod_hdl == NULL ) { - sprintf( buff, TC_ERR_CANT_LOAD_TRAP, filename ); - return( buff ); + return( TC_ERR_CANT_LOAD_TRAP ); } - buff[0] = '\0'; + err = TC_ERR_BAD_TRAP_FILE; init_func = (trap_init_func *)GetProcAddress( mod_hdl, (LPSTR)1 ); FiniFunc = (trap_fini_func *)GetProcAddress( mod_hdl, (LPSTR)2 ); ReqFunc = (trap_req_func *)GetProcAddress( mod_hdl, (LPSTR)3 ); @@ -134,12 +132,10 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) if( buff[0] == '\0' ) { if( TrapVersionOK( *trap_ver ) ) { TrapVer = *trap_ver; - return( NULL ); + return( TC_OK ); } } } - if( buff[0] == '\0' ) - strcpy( buff, TC_ERR_WRONG_TRAP_VERSION ); UnLoadTrap(); - return( buff ); + return( err ); } diff --git a/bld/dig/c/os2/trpld.c b/bld/dig/c/os2/trpld.c index 02700cef5d..f7e32ec661 100644 --- a/bld/dig/c/os2/trpld.c +++ b/bld/dig/c/os2/trpld.c @@ -39,7 +39,6 @@ #include "digld.h" #include "trpld.h" #include "trpsys.h" -#include "tcerr.h" #ifdef _M_I86 @@ -101,12 +100,13 @@ void UnLoadTrap( void ) } } -char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) +trpld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) { const char *base_name; size_t len; trap_init_func *init_func; char filename[CCHMAXPATH]; + trpld_error err; if( parms == NULL || *parms == '\0' ) parms = DEFAULT_TRP_NAME; @@ -142,14 +142,12 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) #else if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, len, ".D32", filename, sizeof( filename ) ) == 0 ) { #endif - sprintf( buff, TC_ERR_CANT_LOAD_TRAP, base_name ); - return( buff ); + return( TC_ERR_CANT_FIND_TRAP ); } if( LOAD_MODULE( filename, mod_hdl ) ) { - sprintf( buff, TC_ERR_CANT_LOAD_TRAP, filename ); - return( buff ); + return( TC_ERR_CANT_LOAD_TRAP ); } - buff[0] = '\0'; + err = TC_ERR_BAD_TRAP_FILE; if( GET_PROC_ADDRESS( mod_hdl, 1, init_func ) && GET_PROC_ADDRESS( mod_hdl, 2, FiniFunc ) && GET_PROC_ADDRESS( mod_hdl, 3, ReqFunc ) ) { @@ -163,12 +161,10 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) if( buff[0] == '\0' ) { if( TrapVersionOK( *trap_ver ) ) { TrapVer = *trap_ver; - return( NULL ); + return( TC_OK ); } } } - if( buff[0] == '\0' ) - strcpy( buff, TC_ERR_WRONG_TRAP_VERSION ); UnLoadTrap(); - return( buff ); + return( err ); } diff --git a/bld/dig/c/qnx/trpld.c b/bld/dig/c/qnx/trpld.c index ad89932942..0945edf721 100644 --- a/bld/dig/c/qnx/trpld.c +++ b/bld/dig/c/qnx/trpld.c @@ -39,7 +39,6 @@ #include "digld.h" #include "trpld.h" #include "trpimp.h" -#include "tcerr.h" #include "ldimp.h" @@ -76,7 +75,7 @@ void UnLoadTrap( void ) } } -char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) +trpld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) { FILE *fp; trap_load_func *ld_func; @@ -84,6 +83,7 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) char filename[256]; const char *base_name; size_t len; + trpld_error err; if( parms == NULL || *parms == '\0' ) parms = DEFAULT_TRP_NAME; @@ -97,40 +97,37 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) len++; } if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, len, ".trp", filename, sizeof( filename ) ) == 0 ) { - sprintf( buff, TC_ERR_CANT_LOAD_TRAP, base_name ); - return( buff ); + return( TC_ERR_CANT_FIND_TRAP ); } - sprintf( buff, TC_ERR_CANT_LOAD_TRAP, filename ); fp = DIGLoader( Open )( filename ); if( fp == NULL ) { - return( buff ); + return( TC_ERR_CANT_LOAD_TRAP ); } TrapCode = ReadInImp( fp ); DIGLoader( Close )( fp ); - if( TrapCode != NULL ) { - buff[0] = '\0'; + if( TrapCode == NULL ) { + return( TC_ERR_CANT_LOAD_TRAP ); + } + err = TC_ERR_BAD_TRAP_FILE; #ifdef __WATCOMC__ - if( TrapCode->sig == TRAPSIG ) { + ld_func = (trap_load_func *)((TrapCode->sig == TRAPSIG) ? TrapCode->init_rtn : NULL); +#else + ld_func = (trap_load_func *)TrapCode->init_rtn; #endif - ld_func = (trap_load_func *)TrapCode->init_rtn; - trap_funcs = ld_func( &TrapCallbacks ); - if( trap_funcs != NULL ) { - *trap_ver = trap_funcs->init_func( parms, buff, trap_ver->remote ); - FiniFunc = trap_funcs->fini_func; - ReqFunc = trap_funcs->req_func; - if( buff[0] == '\0' ) { - if( TrapVersionOK( *trap_ver ) ) { - TrapVer = *trap_ver; - return( NULL ); - } + if( ld_func != NULL ) { + trap_funcs = ld_func( &TrapCallbacks ); + if( trap_funcs != NULL ) { + *trap_ver = trap_funcs->init_func( parms, buff, trap_ver->remote ); + FiniFunc = trap_funcs->fini_func; + ReqFunc = trap_funcs->req_func; + if( buff[0] == '\0' ) { + if( TrapVersionOK( *trap_ver ) ) { + TrapVer = *trap_ver; + return( TC_OK ); } } -#ifdef __WATCOMC__ } -#endif - if( buff[0] == '\0' ) - strcpy( buff, TC_ERR_BAD_TRAP_FILE ); - UnLoadTrap(); } - return( buff ); + UnLoadTrap(); + return( err ); } diff --git a/bld/dig/c/rdos/trpld.c b/bld/dig/c/rdos/trpld.c index f85f5ab3df..84fd30c299 100644 --- a/bld/dig/c/rdos/trpld.c +++ b/bld/dig/c/rdos/trpld.c @@ -36,7 +36,6 @@ #include #include "digld.h" #include "trpld.h" -#include "tcerr.h" static int mod_hdl = 0; @@ -55,12 +54,13 @@ void UnLoadTrap( void ) } } -char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) +trpld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) { char filename[256]; const char *base_name; size_t len; trap_init_func *init_func; + trpld_error err; if( parms == NULL || *parms == '\0' ) parms = DEFAULT_TRP_NAME; @@ -74,15 +74,13 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) len++; } if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, len, ".dll", filename, sizeof( filename ) ) == 0 ) { - sprintf( buff, TC_ERR_CANT_LOAD_TRAP, base_name ); - return( buff ); + return( TC_ERR_CANT_FIND_TRAP ); } mod_hdl = RdosLoadDll( filename ); if( mod_hdl == NULL ) { - sprintf( buff, TC_ERR_CANT_LOAD_TRAP, filename ); - return( buff ); + return( TC_ERR_CANT_LOAD_TRAP ); } - buff[0] = '\0'; + err = TC_ERR_BAD_TRAP_FILE; init_func = RdosGetModuleProc( mod_hdl, "TrapInit_" ); FiniFunc = RdosGetModuleProc( mod_hdl, "TrapFini_" ); ReqFunc = RdosGetModuleProc( mod_hdl, "TrapRequest_" ); @@ -92,12 +90,10 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) if( buff[0] == '\0' ) { if( TrapVersionOK( *trap_ver ) ) { TrapVer = *trap_ver; - return( NULL ); + return( TC_OK ); } } } - if( buff[0] == '\0' ) - strcpy( buff, TC_ERR_WRONG_TRAP_VERSION ); UnLoadTrap(); - return( buff ); + return( err ); } diff --git a/bld/dig/c/win/trpld.c b/bld/dig/c/win/trpld.c index 66a62a984e..dd16b88c10 100644 --- a/bld/dig/c/win/trpld.c +++ b/bld/dig/c/win/trpld.c @@ -39,7 +39,6 @@ #include "digld.h" #include "trpld.h" #include "trpsys.h" -#include "tcerr.h" #define pick(n,r,p,ar,ap) typedef r TRAPENTRY (*TRAP_EXTFUNC_TYPE(n)) ## p; @@ -79,13 +78,14 @@ void UnLoadTrap( void ) } } -char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) +trpld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) { char filename[256]; const char *base_name; size_t len; UINT prev; trap_init_func *init_func; + trpld_error err; if( parms == NULL || *parms == '\0' ) parms = DEFAULT_TRP_NAME; @@ -107,18 +107,16 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) toolhelp = 0; } if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, len, ".dll", filename, sizeof( filename ) ) == 0 ) { - sprintf( buff, TC_ERR_CANT_LOAD_TRAP, base_name ); - return( buff ); + return( TC_ERR_CANT_FIND_TRAP ); } prev = SetErrorMode( SEM_NOOPENFILEERRORBOX ); mod_hdl = LoadLibrary( filename ); SetErrorMode( prev ); if( (UINT)mod_hdl < 32 ) { mod_hdl = 0; - sprintf( buff, TC_ERR_CANT_LOAD_TRAP, filename ); - return( buff ); + return( TC_ERR_CANT_LOAD_TRAP ); } - buff[0] = '\0'; + err = TC_ERR_BAD_TRAP_FILE; init_func = (trap_init_func *)GetProcAddress( mod_hdl, (LPSTR)2 ); FiniFunc = (trap_fini_func *)GetProcAddress( mod_hdl, (LPSTR)3 ); ReqFunc = (trap_req_func *)GetProcAddress( mod_hdl, (LPSTR)4 ); @@ -133,14 +131,12 @@ char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) if( buff[0] == '\0' ) { if( TrapVersionOK( *trap_ver ) ) { TrapVer = *trap_ver; - return( NULL ); + return( TC_OK ); } } } - if( buff[0] == '\0' ) - strcpy( buff, TC_ERR_WRONG_TRAP_VERSION ); UnLoadTrap(); - return( buff ); + return( err ); } void TRAP_EXTFUNC( HardModeCheck )( void ) diff --git a/bld/dig/h/trpld.h b/bld/dig/h/trpld.h index 8690285d76..7c481c6101 100644 --- a/bld/dig/h/trpld.h +++ b/bld/dig/h/trpld.h @@ -50,7 +50,7 @@ extern int CloseTrapTraceFile( void ); /* Client interface routines */ extern char *LoadDumbTrap( trap_version * ); -extern char *LoadTrap( const char *, char *, trap_version * ); +extern trpld_error LoadTrap( const char *, char *, trap_version * ); extern void UnLoadTrap( void ); extern void TrapSetFailCallBack( void (*func)(void) ); extern unsigned TrapAccess( trap_elen, in_mx_entry_p, trap_elen, mx_entry_p ); diff --git a/bld/dig/h/tcerr.h b/bld/dig/h/trplderr.h similarity index 69% rename from bld/dig/h/tcerr.h rename to bld/dig/h/trplderr.h index caa8313e53..838f17fdfc 100644 --- a/bld/dig/h/tcerr.h +++ b/bld/dig/h/trplderr.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -24,28 +25,22 @@ * * ======================================================================== * -* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE -* DESCRIBE IT HERE! +* Description: TRAP file loader errors enumeration * ****************************************************************************/ -#ifndef _TCERR_H_INCLUDED -#define _TCERR_H_INCLUDED +#ifndef _TRPLDERR_H_INCLUDED +#define _TRPLDERR_H_INCLUDED typedef enum { - TC_NO_ERROR, - TC_BAD_TRAP_FILE, - TC_CANT_LOAD_TRAP, - TC_WRONG_TRAP_VERSION, - TC_OUT_OF_DOS_MEMORY, -} tc_error; - -extern char *TrapClientString( tc_error ); - -#define TC_ERR_BAD_TRAP_FILE TrapClientString( TC_BAD_TRAP_FILE ) -#define TC_ERR_CANT_LOAD_TRAP TrapClientString( TC_CANT_LOAD_TRAP ) -#define TC_ERR_WRONG_TRAP_VERSION TrapClientString( TC_WRONG_TRAP_VERSION ) -#define TC_ERR_OUT_OF_DOS_MEMORY TrapClientString( TC_OUT_OF_DOS_MEMORY ) + TC_OK, + TC_ERR, + TC_ERR_CANT_FIND_TRAP, + TC_ERR_CANT_LOAD_TRAP, + TC_ERR_WRONG_TRAP_VERSION, + TC_ERR_BAD_TRAP_FILE, + TC_ERR_OUT_OF_DOS_MEMORY, +} trpld_error; #endif diff --git a/bld/dig/h/trptypes.h b/bld/dig/h/trptypes.h index a2c8e9447e..1e6b9c098d 100644 --- a/bld/dig/h/trptypes.h +++ b/bld/dig/h/trptypes.h @@ -37,6 +37,7 @@ #if defined( __WINDOWS__ ) #include "setevent.h" #endif +#include "trplderr.h" #if defined( __WINDOWS__ ) #define TRAPENTRY __far __pascal diff --git a/bld/trap/common/serv.c b/bld/trap/common/serv.c index e5621e0de9..d763d92355 100644 --- a/bld/trap/common/serv.c +++ b/bld/trap/common/serv.c @@ -44,7 +44,6 @@ #include "trperr.h" #include "packet.h" #include "servname.rh" -#include "tcerr.h" #include "servio.h" #include "nothing.h" @@ -76,7 +75,29 @@ static const char *ServInitialize( void ) if( err == NULL ) { err = RemoteLink( RWBuff, true ); if( err == NULL ) { - err = LoadTrap( trapparms, RWBuff, &TrapVersion ); + switch( LoadTrap( trapparms, RWBuff, &TrapVersion ) ) { + case TC_OK: + break; + case TC_ERR_CANT_FIND_TRAP: + err = TRP_ERR_CANT_FIND_TRAP; + break; + case TC_ERR_CANT_LOAD_TRAP: + err = TRP_ERR_CANT_LOAD_TRAP; + break; + case TC_ERR_WRONG_TRAP_VERSION: + err = TRP_ERR_WRONG_TRAP_VERSION; + break; + case TC_ERR_BAD_TRAP_FILE: + err = TRP_ERR_BAD_TRAP_FILE; + break; + case TC_ERR_OUT_OF_DOS_MEMORY: + err = TRP_ERR_OUT_OF_DOS_MEMORY; + break; + case TC_ERR: + default: + err = TRP_ERR_unknown_system_error; + break; + } } } return( err ); diff --git a/bld/trap/common/servacc.c b/bld/trap/common/servacc.c index a0bd27a123..ac7c47f649 100644 --- a/bld/trap/common/servacc.c +++ b/bld/trap/common/servacc.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -38,10 +38,10 @@ #include "trpcomm.h" #include "trperr.h" #include "packet.h" -#include "tcerr.h" #include "servio.h" #include "nothing.h" + trap_version TrapVersion; char RWBuff[0x400]; @@ -154,14 +154,3 @@ bool Session( void ) } } } - -char *TrapClientString( tc_error err ) -{ - switch( err ) { - case TC_BAD_TRAP_FILE: return( TRP_ERR_BAD_TRAP_FILE ); - case TC_CANT_LOAD_TRAP: return( TRP_ERR_CANT_LOAD_TRAP ); - case TC_WRONG_TRAP_VERSION: return( TRP_ERR_WRONG_TRAP_VERSION ); - case TC_OUT_OF_DOS_MEMORY: return( TRP_ERR_OUT_OF_DOS_MEMORY ); - } - return( NULL ); -} diff --git a/bld/trap/common/servcmd.c b/bld/trap/common/servcmd.c index 01161b0cc4..58f7459e1f 100644 --- a/bld/trap/common/servcmd.c +++ b/bld/trap/common/servcmd.c @@ -41,9 +41,9 @@ #include "trpld.h" #include "trperr.h" #include "packet.h" -#include "tcerr.h" #include "servio.h" + extern trap_version TrapVersion; static const char *SkipSpaces( const char *ptr ) diff --git a/bld/trap/common/servw.c b/bld/trap/common/servw.c index 951fc6ed18..9bfbbd5af2 100644 --- a/bld/trap/common/servw.c +++ b/bld/trap/common/servw.c @@ -40,7 +40,6 @@ #include "packet.h" #include "servname.rh" #include "servio.h" -#include "tcerr.h" #include "nothing.h" #include "options.h" #include "wclbproc.h" @@ -82,7 +81,29 @@ int PASCAL WinMain( HINSTANCE this_inst, HINSTANCE prev_inst, LPSTR cmdline, int if( err == NULL ) { err = RemoteLinkSet( RWBuff ); if( err == NULL ) { - err = LoadTrap( trapparms, RWBuff, &TrapVersion ); + switch( LoadTrap( trapparms, RWBuff, &TrapVersion ) ) { + case TC_OK: + break; + case TC_ERR_CANT_FIND_TRAP: + err = TRP_ERR_CANT_FIND_TRAP; + break; + case TC_ERR_CANT_LOAD_TRAP: + err = TRP_ERR_CANT_LOAD_TRAP; + break; + case TC_ERR_WRONG_TRAP_VERSION: + err = TRP_ERR_WRONG_TRAP_VERSION; + break; + case TC_ERR_BAD_TRAP_FILE: + err = TRP_ERR_BAD_TRAP_FILE; + break; + case TC_ERR_OUT_OF_DOS_MEMORY: + err = TRP_ERR_OUT_OF_DOS_MEMORY; + break; + case TC_ERR: + default: + err = TRP_ERR_unknown_system_error; + break; + } } } if( err != NULL ) { diff --git a/bld/trap/h/trap.msg b/bld/trap/h/trap.msg index 72303d4f57..498d125ad3 100644 --- a/bld/trap/h/trap.msg +++ b/bld/trap/h/trap.msg @@ -3,6 +3,9 @@ trappick( TRP_ERR_BAD_TRAP_FILE, "Invalid trap file", "jInvalid trap file" ) +trappick( TRP_ERR_CANT_FIND_TRAP, + "Unable to find trap file", + "jUnable to find trap file" ) trappick( TRP_ERR_CANT_LOAD_TRAP, "Unable to load trap file", "jUnable to load trap file" ) diff --git a/bld/wv/c/remcore.c b/bld/wv/c/remcore.c index b37c06f62b..69774fa195 100644 --- a/bld/wv/c/remcore.c +++ b/bld/wv/c/remcore.c @@ -35,7 +35,6 @@ #include "dbgerr.h" #include "dbgio.h" #include "dbgmem.h" -#include "tcerr.h" #include "dbglit.h" #include "dui.h" #include "trapaccs.h" @@ -724,14 +723,3 @@ void FiniCoreSupp( void ) _Free( MData ); MData = NULL; } - -char *TrapClientString( tc_error err ) -{ - switch( err ) { - case TC_BAD_TRAP_FILE: return( LIT_ENG( BAD_TRAP_FILE ) ); - case TC_CANT_LOAD_TRAP: return( LIT_ENG( CANT_LOAD_TRAP_FILE ) ); - case TC_WRONG_TRAP_VERSION: return( LIT_ENG( INCORRECT_TRAP_FILE_VERSION ) ); - case TC_OUT_OF_DOS_MEMORY: return( LIT_ENG( OUT_OF_DOS_MEMORY ) ); - } - return( NULL ); -} diff --git a/bld/wv/c/remmisc.c b/bld/wv/c/remmisc.c index 5fd77ba986..902355c975 100644 --- a/bld/wv/c/remmisc.c +++ b/bld/wv/c/remmisc.c @@ -42,6 +42,7 @@ #include "dbgmem.h" #include "trpld.h" #include "trpcore.h" +#include "trperr.h" #include "dbgio.h" #include "strutil.h" #include "trapglbl.h" @@ -124,7 +125,29 @@ void InitTrap( const char *parms ) error = LoadDumbTrap( &ver ); } else { #endif - error = LoadTrap( parms, buff, &ver ); + switch( LoadTrap( parms, buff, &ver ) ) { + case TC_OK: + break; + case TC_ERR_CANT_FIND_TRAP: + error = TRP_ERR_CANT_FIND_TRAP; + break; + case TC_ERR_CANT_LOAD_TRAP: + error = TRP_ERR_CANT_LOAD_TRAP; + break; + case TC_ERR_WRONG_TRAP_VERSION: + error = TRP_ERR_WRONG_TRAP_VERSION; + break; + case TC_ERR_BAD_TRAP_FILE: + error = TRP_ERR_BAD_TRAP_FILE; + break; + case TC_ERR_OUT_OF_DOS_MEMORY: + error = TRP_ERR_OUT_OF_DOS_MEMORY; + break; + case TC_ERR: + default: + error = TRP_ERR_unknown_system_error; + break; + } #if !defined( BUILD_RFX ) } #endif diff --git a/bld/wv/master.mif b/bld/wv/master.mif index b0f22ef031..eec3212c5d 100644 --- a/bld/wv/master.mif +++ b/bld/wv/master.mif @@ -73,7 +73,7 @@ wv_res_inc_dirs = -I"../../res/dlgs" -I"$(res_strings_dir)" -I"../../res" inc_dirs = -I. -Ih -I"../h" -I"../../h" $(wv_res_inc_dirs) -I"$(dig_dir)/h" & $(aui_inc_dirs) $(gui_inc_dirs) $(ui_inc_dirs) $(ui_extra_inc_dirs) & - $(hlpview_inc_dirs) $(wpi_inc_dirs) $(commonui_inc_dirs) + $(hlpview_inc_dirs) $(wpi_inc_dirs) $(commonui_inc_dirs) -I"$(trap_dir)/h" !ifeq sys_rtdll 1 !else !ifeq sys_windowed 1 @@ -144,14 +144,14 @@ extra_l_flags_rdos = # EXE # !ifdef wv_engine_noui -exetarg_prebuild_objs = litdef.gh +exetarg_prebuild_objs = litdef.gh _err.gh _jerr.gh exetarg_objs = $(wv_drv_objs) exetarg_libs = wd.lib exetarg_res = wvuidll.res exetarg_name = $(wv_engine_noui) !include exetarg.mif !else -exetarg_prebuild_objs = litdef.gh usage.gh +exetarg_prebuild_objs = litdef.gh usage.gh _err.gh _jerr.gh exetarg_objs = $(engine_objs) fingmsg.obj $(ui_objs) exetarg_libs = $(aui_lib) $(gui_lib) $(ui_lib) $(wres_lib) exetarg_res_version_nt_386 = exever.res @@ -172,7 +172,7 @@ exetarg_ext = .exe # # LIB # -libtarg_prebuild_objs = litdef.gh usage.gh +libtarg_prebuild_objs = litdef.gh usage.gh _err.gh _jerr.gh libtarg_objs = $(engine_objs) libtarg_name = wd !include libtarg.mif @@ -460,6 +460,14 @@ litdef.gh : litdefs1.tmp litdefs2.tmp litdefm.tmp $(__MAKEFILES__) $(awk) -v prefix=DBG_DUI_LITERAL_ -v base=DBG_DUI_BASE -f $(build_dir)/makemsg2.awk -v OUTFILE=$^. litdefs2.tmp $(awk) -v prefix=DBG_DUI_MENU_ -v base=DBG_MENU_BASE -f $(build_dir)/makemsg2.awk -v OUTFILE=$^. litdefm.tmp +_err.gh : $(trap_dir)/h/trapmsg.h $(trap_dir)/h/trap.msg $(__MAKEFILES__) + @%make echo_cpp + $(cpp) $(rc_ui8_flags) -I"$(trap_dir)/h" $(rc_ui_inc_path) $[@ -o$@ + +_jerr.gh : $(trap_dir)/h/trapmsg.h $(trap_dir)/h/trap.msg $(__MAKEFILES__) + @%make echo_cpp + $(cpp) $(rc_ui8_flags) -DJAPANESE -I"$(trap_dir)/h" $(rc_ui_inc_path) $[@ -o$@ + !ifeq release 0 wsplice_keys = -kHIDDEN !endif diff --git a/bld/wv/rfx/master.mif b/bld/wv/rfx/master.mif index e04cdf2ead..1dd282d07e 100644 --- a/bld/wv/rfx/master.mif +++ b/bld/wv/rfx/master.mif @@ -22,7 +22,7 @@ dig_arch = $(host_cpu) # .c: ..;../../$(host_os)/c;../../c;$(dig_srcs) -inc_dirs = -I.. -I"$(wv_dir)/h" -I"$(dig_dir)/h" -I"$(dig_dir)/c" -I"$(clib_dir)/h" +inc_dirs = -I. -I.. -I"$(wv_dir)/h" -I"$(dig_dir)/h" -I"$(dig_dir)/c" -I"$(clib_dir)/h" -I"$(trap_dir)/h" extra_cpp_flags = -DBUILD_RFX @@ -37,6 +37,7 @@ extra_cpp_flags = -DBUILD_RFX # # EXE # +exetarg_prebuild_objs = _err.gh exetarg_objs_dos = inthdlrs.obj exetarg_objs = & rfx.obj & @@ -51,3 +52,7 @@ exetarg_objs = & $(host_os)filio.obj & $(exetarg_objs_$(host_os)) !include exetarg.mif + +_err.gh : $(trap_dir)/h/trapmsg.h $(trap_dir)/h/trap.msg $(__MAKEFILES__) + @%make echo_cpp + $(cpp) $(rc_ui8_flags) -I"$(trap_dir)/h" $(rc_ui_inc_path) $[@ -o$@ diff --git a/bld/wv/rfx/rfx.c b/bld/wv/rfx/rfx.c index 01fea993db..4acbf6c14f 100644 --- a/bld/wv/rfx/rfx.c +++ b/bld/wv/rfx/rfx.c @@ -40,7 +40,6 @@ #include "banner.h" #include "dbgio.h" #include "objloc.h" -#include "tcerr.h" #include "trprfx.h" #include "local.h" #include "remote.h" @@ -1729,22 +1728,6 @@ static bool ProcDrive( int argc, char **argv ) return( false ); } -char *TrapClientString( tc_error err ) -{ - switch( err ) { - case TC_BAD_TRAP_FILE: - return( "Bad trap file" ); - case TC_CANT_LOAD_TRAP: - return( "Cannot load trap file %s" ); - case TC_WRONG_TRAP_VERSION: - return( "Incorrect trap file version" ); - case TC_OUT_OF_DOS_MEMORY: - return( "Out of DOS memory" ); - } - return( NULL ); -} - - /**************************************************************************/ /* MAIN LINEISH */ /**************************************************************************/ From ac2f3ef4256fed00311cc10a8f84e332ba226049 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Mon, 11 Sep 2023 09:59:05 +0200 Subject: [PATCH 111/258] add new round macros --- bld/watcom/h/roundmac.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bld/watcom/h/roundmac.h b/bld/watcom/h/roundmac.h index 9a5b452697..37171bb6dc 100644 --- a/bld/watcom/h/roundmac.h +++ b/bld/watcom/h/roundmac.h @@ -68,9 +68,13 @@ #define __ROUND_DOWN_SIZE_EVEN(__x) __ROUND_DOWN_SIZE(__x,2) #define __ROUND_UP_SIZE_EVEN(__x) __ROUND_UP_SIZE(__x,2) +#define __ROUND_DOWN_SIZE_PARA(__x) __ROUND_DOWN_SIZE(__x,16) #define __ROUND_UP_SIZE_PARA(__x) __ROUND_UP_SIZE(__x,16) +#define __ROUND_DOWN_SIZE_PAGE(__x) __ROUND_DOWN_SIZE(__x,256) #define __ROUND_UP_SIZE_PAGE(__x) __ROUND_UP_SIZE(__x,256) +#define __ROUND_DOWN_SIZE_4K(__x) __ROUND_DOWN_SIZE(__x,_4K) #define __ROUND_UP_SIZE_4K(__x) __ROUND_UP_SIZE(__x,_4K) +#define __ROUND_DOWN_SIZE_64K(__x) __ROUND_DOWN_SIZE(__x,_64K) #define __ROUND_UP_SIZE_64K(__x) __ROUND_UP_SIZE(__x,_64K) #define __ROUND_DOWN_SIZE_TO_PARA(__x) __ROUND_DOWN_SIZE_TO((__x),16) From cca56fc36e51573322b522f9ebaa06c4783429ca Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Mon, 11 Sep 2023 09:59:47 +0200 Subject: [PATCH 112/258] correct error for trap files --- bld/dig/c/dos/trpld.c | 4 +++- bld/dig/c/dsx/ldimp.c | 15 ++++++++------- bld/dig/c/dsx/trpld.c | 25 +++++++++++++------------ bld/dig/c/linux/peloader.c | 2 +- bld/dig/c/linux/trpld_pe.c | 1 + bld/dig/c/linux/trpld_rx.c | 21 ++++++++++----------- bld/dig/c/linux/trpld_so.c | 1 + bld/dig/c/nov/trpld.c | 5 ++++- bld/dig/c/nt/trpld.c | 5 ++++- bld/dig/c/os2/trpld.c | 1 + bld/dig/c/qnx/trpld.c | 21 ++++++++++----------- bld/dig/c/rdos/trpld.c | 6 +++++- bld/dig/c/win/trpld.c | 5 ++++- 13 files changed, 65 insertions(+), 47 deletions(-) diff --git a/bld/dig/c/dos/trpld.c b/bld/dig/c/dos/trpld.c index eec2e1c1d1..ad4a96547d 100644 --- a/bld/dig/c/dos/trpld.c +++ b/bld/dig/c/dos/trpld.c @@ -39,6 +39,7 @@ #include "exedos.h" #include "digld.h" #include "trpld.h" +#include "roundmac.h" #define TRAP_SIGNATURE 0xDEAF @@ -78,7 +79,7 @@ static trpld_error ReadInTrap( FILE *fp ) } hdr_size = hdr.hdr_size * 16; size = (hdr.file_size * 0x200) - (-hdr.mod_size & 0x1ff) - hdr_size; - ret = TinyAllocBlock( (size + 15) >> 4 ); + ret = TinyAllocBlock( __ROUND_UP_SIZE_TO_PARA( size ) ); if( TINY_ERROR( ret ) ) { return( TC_ERR_OUT_OF_DOS_MEMORY ); } @@ -158,6 +159,7 @@ trpld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) TrapVer = *trap_ver; return( TC_OK ); } + err = TC_ERR_WRONG_TRAP_VERSION; } } UnLoadTrap(); diff --git a/bld/dig/c/dsx/ldimp.c b/bld/dig/c/dsx/ldimp.c index 7432e2d52a..fcd52d95d9 100644 --- a/bld/dig/c/dsx/ldimp.c +++ b/bld/dig/c/dsx/ldimp.c @@ -53,6 +53,7 @@ #include "exephar.h" #include "digcli.h" #include "digld.h" +#include "roundmac.h" #include "ldimp.h" @@ -61,7 +62,7 @@ imp_header *ReadInImp( FILE *fp ) { simple_header hdr; - unsigned size; + unsigned image_size; unsigned hdr_size; unsigned bss_size; unsigned reloc_size; @@ -76,13 +77,13 @@ imp_header *ReadInImp( FILE *fp ) if( hdr.signature != EXESIGN_REX ) return( NULL ); hdr_size = hdr.hdr_size * 16; - size = (hdr.file_size * 0x200) - (-hdr.mod_size & 0x1ff) - hdr_size; - bss_size = hdr.min_data * 4096; - imp_start = DIGCli( Alloc )( size + bss_size ); + image_size = (hdr.file_size * 0x200) - (-hdr.mod_size & 0x1ff) - hdr_size; + bss_size = hdr.min_data * _4K; + imp_start = DIGCli( Alloc )( image_size + bss_size ); if( imp_start == NULL ) return( NULL ); DIGLoader( Seek )( fp, hdr_size, DIG_SEEK_ORG ); - if( DIGLoader( Read )( fp, imp_start, size ) ) { + if( DIGLoader( Read )( fp, imp_start, image_size ) ) { DIGCli( Free )( imp_start ); return( NULL ); } @@ -110,8 +111,8 @@ imp_header *ReadInImp( FILE *fp ) * to map the code pages loaded from the BPD as executable, otherwise * a segfault will occur when attempting to run any BPD code. */ - mprotect((void*)((u_long)imp_start & ~4095), ( size + 4095 ) & ~4095, PROT_READ | PROT_WRITE | PROT_EXEC); + mprotect((void*)__ROUND_DOWN_SIZE_4K( (u_long)imp_start ), __ROUND_UP_SIZE_4K( image_size ), PROT_READ | PROT_WRITE | PROT_EXEC); #endif - memset( imp_start + size, 0, bss_size ); + memset( imp_start + image_size, 0, bss_size ); return( (imp_header *)imp_start ); } diff --git a/bld/dig/c/dsx/trpld.c b/bld/dig/c/dsx/trpld.c index fc7dc5deeb..c0c87e8f44 100644 --- a/bld/dig/c/dsx/trpld.c +++ b/bld/dig/c/dsx/trpld.c @@ -45,6 +45,7 @@ #include "trpsys.h" #include "envlkup.h" #include "realmod.h" +#include "roundmac.h" #define DOS4G_COMM_VECTOR 0x15 @@ -54,8 +55,6 @@ #define TRAP_SIGNATURE 0xdeaf -#define _NBPARAS( bytes ) ((bytes + 15UL) / 16) - #include "pushpck1.h" typedef struct { unsigned_16 sig; @@ -309,7 +308,7 @@ static trpld_error CopyEnv( void ) envarea = _MK_FP( *(addr_seg __far *)_MK_FP( _psp, PSP_ENVSEG_OFF ), 0 ); envsize = EnvAreaSize( envarea ); - PMData->envseg = DPMIAllocateDOSMemoryBlock( _NBPARAS( envsize ) ); + PMData->envseg = DPMIAllocateDOSMemoryBlock( __ROUND_UP_SIZE_TO_PARA( envsize ) ); if( PMData->envseg.pm == 0 ) { return( TC_ERR_OUT_OF_DOS_MEMORY ); } @@ -343,7 +342,7 @@ static trpld_error SetTrapHandler( void ) PMData->saveseg.rm = 0; PMData->saveseg.pm = 0; } else { - PMData->saveseg = DPMIAllocateDOSMemoryBlock( _NBPARAS( PMData->savesize * 2 ) ); + PMData->saveseg = DPMIAllocateDOSMemoryBlock( __ROUND_UP_SIZE_TO_PARA( PMData->savesize * 2 ) ); if( PMData->saveseg.pm == 0 ) { return( TC_ERR_OUT_OF_DOS_MEMORY ); } @@ -390,8 +389,8 @@ static trpld_error ReadInTrap( FILE *fp ) dos_exe_header hdr; memptr relocbuff[NUM_BUFF_RELOCS]; unsigned relocnb; - unsigned imagesize; - unsigned hdrsize; + unsigned image_size; + unsigned hdr_size; if( DIGLoader( Read )( fp, &hdr, sizeof( hdr ) ) ) { return( TC_ERR_CANT_LOAD_TRAP ); @@ -400,14 +399,14 @@ static trpld_error ReadInTrap( FILE *fp ) return( TC_ERR_BAD_TRAP_FILE ); } - hdrsize = hdr.hdr_size * 16; - imagesize = ( hdr.file_size * 0x200 ) - (-hdr.mod_size & 0x1ff) - hdrsize; - TrapMem = DPMIAllocateDOSMemoryBlock( _NBPARAS( imagesize ) + hdr.min_16 ); + hdr_size = hdr.hdr_size * 16; + image_size = ( hdr.file_size * 0x200 ) - (-hdr.mod_size & 0x1ff) - hdr_size; + TrapMem = DPMIAllocateDOSMemoryBlock( __ROUND_UP_SIZE_TO_PARA( image_size ) + hdr.min_16 ); if( TrapMem.pm == 0 ) { return( TC_ERR_OUT_OF_DOS_MEMORY ); } - DIGLoader( Seek )( fp, hdrsize, DIG_SEEK_ORG ); - if( DIGLoader( Read )( fp, (void *)DPMIGetSegmentBaseAddress( TrapMem.pm ), imagesize ) ) { + DIGLoader( Seek )( fp, hdr_size, DIG_SEEK_ORG ); + if( DIGLoader( Read )( fp, (void *)DPMIGetSegmentBaseAddress( TrapMem.pm ), image_size ) ) { return( TC_ERR_CANT_LOAD_TRAP ); } DIGLoader( Seek )( fp, hdr.reloc_offset, DIG_SEEK_ORG ); @@ -516,7 +515,8 @@ trpld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) if( err != TC_OK ) { return( err ); } - if( (err = SetTrapHandler()) == TC_OK && (err = CopyEnv()) == TC_OK ) { + if( (err = SetTrapHandler()) == TC_OK + && (err = CopyEnv()) == TC_OK ) { err = TC_ERR_BAD_TRAP_FILE; head = EXTENDER_RM2PM( TrapMem.rm, 0 ); if( head->sig == TRAP_SIGNATURE ) { @@ -532,6 +532,7 @@ trpld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) ReqFunc = DoTrapAccess; return( TC_OK ); } + err = TC_ERR_WRONG_TRAP_VERSION; } } } diff --git a/bld/dig/c/linux/peloader.c b/bld/dig/c/linux/peloader.c index 93d5398bb6..f2bb803ad4 100644 --- a/bld/dig/c/linux/peloader.c +++ b/bld/dig/c/linux/peloader.c @@ -309,7 +309,7 @@ PE_MODULE * PE_loadLibraryExt( * the .rsrc section separately). */ image_size = image_end - image_base; - *size = sizeof( PE_MODULE ) + image_size + 4096; + *size = sizeof( PE_MODULE ) + image_size + _4K; hMod = malloc( *size ); reloc = malloc( reloc_size ); if( hMod == NULL || reloc == NULL ) { diff --git a/bld/dig/c/linux/trpld_pe.c b/bld/dig/c/linux/trpld_pe.c index 3d4a122ac2..0bbdcc9a34 100644 --- a/bld/dig/c/linux/trpld_pe.c +++ b/bld/dig/c/linux/trpld_pe.c @@ -130,6 +130,7 @@ trpld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) TrapVer = *trap_ver; return( TC_OK ); } + err = TC_ERR_WRONG_TRAP_VERSION; } } UnLoadTrap(); diff --git a/bld/dig/c/linux/trpld_rx.c b/bld/dig/c/linux/trpld_rx.c index aa682ff636..bbb1712144 100644 --- a/bld/dig/c/linux/trpld_rx.c +++ b/bld/dig/c/linux/trpld_rx.c @@ -112,18 +112,17 @@ trpld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) #else ld_func = (trap_load_func *)TrapCode->init_rtn; #endif - if( ld_func != NULL ) { - trap_funcs = ld_func( &TrapCallbacks ); - if( trap_funcs != NULL ) { - *trap_ver = trap_funcs->init_func( parms, buff, trap_ver->remote ); - FiniFunc = trap_funcs->fini_func; - ReqFunc = trap_funcs->req_func; - if( buff[0] == '\0' ) { - if( TrapVersionOK( *trap_ver ) ) { - TrapVer = *trap_ver; - return( TC_OK ); - } + if( ld_func != NULL + && (trap_funcs = ld_func( &TrapCallbacks )) != NULL ) { + *trap_ver = trap_funcs->init_func( parms, buff, trap_ver->remote ); + FiniFunc = trap_funcs->fini_func; + ReqFunc = trap_funcs->req_func; + if( buff[0] == '\0' ) { + if( TrapVersionOK( *trap_ver ) ) { + TrapVer = *trap_ver; + return( TC_OK ); } + err = TC_ERR_WRONG_TRAP_VERSION; } } UnLoadTrap(); diff --git a/bld/dig/c/linux/trpld_so.c b/bld/dig/c/linux/trpld_so.c index 0ee7ffde43..317c310a0d 100644 --- a/bld/dig/c/linux/trpld_so.c +++ b/bld/dig/c/linux/trpld_so.c @@ -133,6 +133,7 @@ trpld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) TrapVer = *trap_ver; return( TC_OK ); } + err = TC_ERR_WRONG_TRAP_VERSION; } } UnLoadTrap(); diff --git a/bld/dig/c/nov/trpld.c b/bld/dig/c/nov/trpld.c index d3639ff0ca..c545bf3ee3 100644 --- a/bld/dig/c/nov/trpld.c +++ b/bld/dig/c/nov/trpld.c @@ -46,6 +46,7 @@ trpld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) { const char *trpname; size_t len; + trpld_error err; if( parms == NULL || *parms == '\0' ) parms = DEFAULT_TRP_NAME; @@ -58,6 +59,7 @@ trpld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) } len++; } + err = TC_ERR_BAD_TRAP_FILE; *trap_ver = TrapInit( parms, buff, trap_ver->remote ); if( buff[0] == '\0' ) { if( TrapVersionOK( *trap_ver ) ) { @@ -65,7 +67,8 @@ trpld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) ReqFunc = TrapRequest; return( TC_OK ); } + err = TC_ERR_WRONG_TRAP_VERSION; } UnLoadTrap(); - return( TC_ERR_BAD_TRAP_FILE ); + return( err ); } diff --git a/bld/dig/c/nt/trpld.c b/bld/dig/c/nt/trpld.c index c0a0d2fdd6..e81f827ff9 100644 --- a/bld/dig/c/nt/trpld.c +++ b/bld/dig/c/nt/trpld.c @@ -127,13 +127,16 @@ trpld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) TRAP_EXTFUNC_PTR( InfoFunction ) = (TRAP_EXTFUNC_TYPE( InfoFunction ))GetProcAddress( mod_hdl, (LPSTR)4 ); TRAP_EXTFUNC_PTR( InterruptProgram ) = (TRAP_EXTFUNC_TYPE( InterruptProgram ))GetProcAddress( mod_hdl, (LPSTR)5 ); TRAP_EXTFUNC_PTR( Terminate ) = (TRAP_EXTFUNC_TYPE( Terminate ))GetProcAddress( mod_hdl, (LPSTR)6 ); - if( init_func != NULL && FiniFunc != NULL && ReqFunc != NULL ) { + if( init_func != NULL + && FiniFunc != NULL + && ReqFunc != NULL ) { *trap_ver = init_func( parms, buff, trap_ver->remote ); if( buff[0] == '\0' ) { if( TrapVersionOK( *trap_ver ) ) { TrapVer = *trap_ver; return( TC_OK ); } + err = TC_ERR_WRONG_TRAP_VERSION; } } UnLoadTrap(); diff --git a/bld/dig/c/os2/trpld.c b/bld/dig/c/os2/trpld.c index f7e32ec661..445da41b39 100644 --- a/bld/dig/c/os2/trpld.c +++ b/bld/dig/c/os2/trpld.c @@ -163,6 +163,7 @@ trpld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) TrapVer = *trap_ver; return( TC_OK ); } + err = TC_ERR_WRONG_TRAP_VERSION; } } UnLoadTrap(); diff --git a/bld/dig/c/qnx/trpld.c b/bld/dig/c/qnx/trpld.c index 0945edf721..da6f78ba6d 100644 --- a/bld/dig/c/qnx/trpld.c +++ b/bld/dig/c/qnx/trpld.c @@ -114,18 +114,17 @@ trpld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) #else ld_func = (trap_load_func *)TrapCode->init_rtn; #endif - if( ld_func != NULL ) { - trap_funcs = ld_func( &TrapCallbacks ); - if( trap_funcs != NULL ) { - *trap_ver = trap_funcs->init_func( parms, buff, trap_ver->remote ); - FiniFunc = trap_funcs->fini_func; - ReqFunc = trap_funcs->req_func; - if( buff[0] == '\0' ) { - if( TrapVersionOK( *trap_ver ) ) { - TrapVer = *trap_ver; - return( TC_OK ); - } + if( ld_func != NULL + && (trap_funcs = ld_func( &TrapCallbacks )) != NULL ) { + *trap_ver = trap_funcs->init_func( parms, buff, trap_ver->remote ); + FiniFunc = trap_funcs->fini_func; + ReqFunc = trap_funcs->req_func; + if( buff[0] == '\0' ) { + if( TrapVersionOK( *trap_ver ) ) { + TrapVer = *trap_ver; + return( TC_OK ); } + err = TC_ERR_WRONG_TRAP_VERSION; } } UnLoadTrap(); diff --git a/bld/dig/c/rdos/trpld.c b/bld/dig/c/rdos/trpld.c index 84fd30c299..b3a6ddeafe 100644 --- a/bld/dig/c/rdos/trpld.c +++ b/bld/dig/c/rdos/trpld.c @@ -85,13 +85,17 @@ trpld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) FiniFunc = RdosGetModuleProc( mod_hdl, "TrapFini_" ); ReqFunc = RdosGetModuleProc( mod_hdl, "TrapRequest_" ); // LibListFunc = RdosGetModuleProc( mod_hdl, "TrapLibList_" ); - if( init_func != NULL && FiniFunc != NULL && ReqFunc != NULL /* && LibListFunc != NULL */ ) { + if( init_func != NULL + && FiniFunc != NULL + && ReqFunc != NULL + /* && LibListFunc != NULL */ ) { *trap_ver = init_func( parms, buff, trap_ver->remote ); if( buff[0] == '\0' ) { if( TrapVersionOK( *trap_ver ) ) { TrapVer = *trap_ver; return( TC_OK ); } + err = TC_ERR_WRONG_TRAP_VERSION; } } UnLoadTrap(); diff --git a/bld/dig/c/win/trpld.c b/bld/dig/c/win/trpld.c index dd16b88c10..9da8a806fe 100644 --- a/bld/dig/c/win/trpld.c +++ b/bld/dig/c/win/trpld.c @@ -126,13 +126,16 @@ trpld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) TRAP_EXTFUNC_PTR( GetHwndFunc ) = (TRAP_EXTFUNC_TYPE( GetHwndFunc ))GetProcAddress( mod_hdl, (LPSTR)8 ); TRAP_EXTFUNC_PTR( SetHardMode ) = (TRAP_EXTFUNC_TYPE( SetHardMode ))GetProcAddress( mod_hdl, (LPSTR)12 ); TRAP_EXTFUNC_PTR( UnLockInput ) = (TRAP_EXTFUNC_TYPE( UnLockInput ))GetProcAddress( mod_hdl, (LPSTR)13 ); - if( init_func != NULL && FiniFunc != NULL && ReqFunc != NULL ) { + if( init_func != NULL + && FiniFunc != NULL + && ReqFunc != NULL ) { *trap_ver = init_func( parms, buff, trap_ver->remote ); if( buff[0] == '\0' ) { if( TrapVersionOK( *trap_ver ) ) { TrapVer = *trap_ver; return( TC_OK ); } + err = TC_ERR_WRONG_TRAP_VERSION; } } UnLoadTrap(); From 6ef483d3685aca11f33caed2898095cad8da8609 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Mon, 11 Sep 2023 10:31:24 +0200 Subject: [PATCH 113/258] cleanup DIP/MAD/TRP version macros --- bld/dig/c/dipman.c | 4 ++-- bld/dig/c/dumb.c | 6 +++--- bld/dig/c/madman.c | 8 ++++---- bld/dig/h/dipimp.h | 14 +++++++------- bld/dig/h/madimp.h | 10 +++++----- bld/dig/h/trptypes.h | 14 +++++++------- bld/dip/c/dipimp.c | 4 ++-- bld/mad/c/madimp.c | 6 +++--- bld/trap/common/remote.c | 4 ++-- bld/trap/lcl/dos/dosr/c/dosacc.c | 4 ++-- bld/trap/lcl/dos/dosx/ads/c/adsacc.c | 4 ++-- bld/trap/lcl/dos/dosx/c/dosxremo.c | 4 ++-- bld/trap/lcl/dos/dosx/cw/c/cwacc.c | 4 ++-- bld/trap/lcl/dos/dosx/pls/c/plsacc.c | 4 ++-- bld/trap/lcl/dos/dosx/rsi/c/rsiacc.c | 4 ++-- bld/trap/lcl/elfcore/c/elfcore.c | 4 ++-- bld/trap/lcl/jvm/c/jvmacc.c | 4 ++-- bld/trap/lcl/jvm/c/jvmxremo.c | 4 ++-- bld/trap/lcl/linux/c/lnxacc.c | 4 ++-- bld/trap/lcl/linux/c/lnxcore.c | 4 ++-- bld/trap/lcl/msj/c/msjacc.c | 4 ++-- bld/trap/lcl/nlm/c/nlmacc.c | 4 ++-- bld/trap/lcl/nt/c/task.c | 10 +++++----- bld/trap/lcl/nto/c/ntoacc.c | 4 ++-- bld/trap/lcl/os2/c/os2v1acc.c | 4 ++-- bld/trap/lcl/os2/c/os2v2acc.c | 4 ++-- bld/trap/lcl/os2v2/c/os2v2acc.c | 4 ++-- bld/trap/lcl/qnx/c/qnxacc.c | 4 ++-- bld/trap/lcl/qnx/c/qnxpmd.c | 4 ++-- bld/trap/lcl/rdos/c/task.c | 4 ++-- bld/trap/lcl/win/c/initfini.c | 4 ++-- bld/wv/c/dipinter.c | 6 +++--- bld/wv/c/remmisc.c | 4 ++-- 33 files changed, 87 insertions(+), 87 deletions(-) diff --git a/bld/dig/c/dipman.c b/bld/dig/c/dipman.c index 5a177e3715..cdb158016f 100644 --- a/bld/dig/c/dipman.c +++ b/bld/dig/c/dipman.c @@ -148,8 +148,8 @@ const address NilAddr = { 0 }; */ static dip_client_routines DIPClientInterface = { - DIP_MAJOR, - DIP_MINOR, + DIP_VERSION_MAJOR, + DIP_VERSION_MINOR, sizeof( dip_client_routines ), DIGCli( Alloc ), DIGCli( Realloc ), diff --git a/bld/dig/c/dumb.c b/bld/dig/c/dumb.c index 9926ec6aa1..45ee3fcf12 100644 --- a/bld/dig/c/dumb.c +++ b/bld/dig/c/dumb.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -188,8 +188,8 @@ static trap_retval TRAPENTRY DumbRequest( trap_elen num_in_mx, in_mx_entry_p mx_ char *LoadDumbTrap( trap_version *ver ) { ReqFunc = DumbRequest; - ver->major = TRAP_MAJOR_VERSION; - ver->minor = TRAP_MINOR_VERSION; + ver->major = TRAP_VERSION_MAJOR; + ver->minor = TRAP_VERSION_MINOR; ver->remote = false; return( NULL ); } diff --git a/bld/dig/c/madman.c b/bld/dig/c/madman.c index 5dbeefad39..195f2e03df 100644 --- a/bld/dig/c/madman.c +++ b/bld/dig/c/madman.c @@ -110,8 +110,8 @@ mad_status MADCLIENTRY( TypeToString )( mad_radix radix, const mad_type_info *mt } static mad_client_routines MADClientInterface = { - MAD_MAJOR, - MAD_MINOR, + MAD_VERSION_MAJOR, + MAD_VERSION_MINOR, sizeof( mad_client_routines ), DIGCli( Alloc ), @@ -2174,8 +2174,8 @@ mad_status MADUnexpectedBreak( mad_registers *mr, char *buff, size_t *buff_ static mad_imp_routines DummyRtns = { - MAD_MAJOR, - MAD_MINOR, + MAD_VERSION_MAJOR, + MAD_VERSION_MINOR, sizeof( DummyRtns ), DummyImp( Init ), diff --git a/bld/dig/h/dipimp.h b/bld/dig/h/dipimp.h index d77cac6fdc..88e13c2723 100644 --- a/bld/dig/h/dipimp.h +++ b/bld/dig/h/dipimp.h @@ -35,16 +35,16 @@ #include "dipcli.h" -#define DIP_MAJOR 2 -#define DIP_MINOR 0 +#define DIP_VERSION_MAJOR 2 +#define DIP_VERSION_MINOR 0 -#define MH2IMH( mh ) ((mh)&0x0000FFFF) -#define IMH2MH( imh ) (imh) +#define MH2IMH( mh ) ((mh)&0x0000FFFF) +#define IMH2MH( imh ) (imh) /* - An imp_mod_handle is defined as an unsigned_16. The value zero is - reserved to indicate "no module". -*/ + * An imp_mod_handle is defined as an unsigned_16. The value zero is + * reserved to indicate "no module". + */ #define IMH_NOMOD ((imp_mod_handle)0) #define IMH_BASE ((imp_mod_handle)1) #define IMH_GBL ((imp_mod_handle)-1) diff --git a/bld/dig/h/madimp.h b/bld/dig/h/madimp.h index 19e4aaa985..981105a10e 100644 --- a/bld/dig/h/madimp.h +++ b/bld/dig/h/madimp.h @@ -35,13 +35,13 @@ #include "madcli.h" -#define MAD_MAJOR 2 -#define MAD_MINOR 0 +#define MAD_VERSION_MAJOR 2 +#define MAD_VERSION_MINOR 0 -#define MADImp(n) MADImp ## n -#define _MADImp(n) _MADImp ## n n +#define MADImp(n) MADImp ## n +#define _MADImp(n) _MADImp ## n n -#define MADIMPENTRY(n) DIGENTRY MADImp( n ) +#define MADIMPENTRY(n) DIGENTRY MADImp( n ) typedef struct imp_mad_state_data imp_mad_state_data; diff --git a/bld/dig/h/trptypes.h b/bld/dig/h/trptypes.h index 1e6b9c098d..d6c9893a62 100644 --- a/bld/dig/h/trptypes.h +++ b/bld/dig/h/trptypes.h @@ -49,17 +49,17 @@ #define TRAPENTRY #endif -#define TRAP_MAJOR_VERSION 18 -#define TRAP_MINOR_VERSION 0 -#define OLD_TRAP_MINOR_VERSION 0 +#define TRAP_VERSION_MAJOR 18 +#define TRAP_VERSION_MINOR 0 +#define OLD_TRAP_VERSION_MINOR 0 #define REQUEST_FAILED ((trap_retval)-1) -#if OLD_TRAP_MINOR_VERSION > 0 - #define TrapVersionOK( ver ) (((ver).major == TRAP_MAJOR_VERSION) && \ - ((ver).minor >= OLD_TRAP_MINOR_VERSION)) +#if OLD_TRAP_VERSION_MINOR > 0 + #define TrapVersionOK( ver ) (((ver).major == TRAP_VERSION_MAJOR) && \ + ((ver).minor >= OLD_TRAP_VERSION_MINOR)) #else - #define TrapVersionOK( ver ) ((ver).major == TRAP_MAJOR_VERSION) + #define TrapVersionOK( ver ) ((ver).major == TRAP_VERSION_MAJOR) #endif #define TRP_REQUEST(x) *((trap_req *)(x)[0].ptr) diff --git a/bld/dip/c/dipimp.c b/bld/dip/c/dipimp.c index c13bfefab6..3e4815fdd0 100644 --- a/bld/dip/c/dipimp.c +++ b/bld/dip/c/dipimp.c @@ -53,8 +53,8 @@ address NilAddr; dip_client_routines *DIPClient; dip_imp_routines ImpInterface = { - DIP_MAJOR, - DIP_MINOR, + DIP_VERSION_MAJOR, + DIP_VERSION_MINOR, DIP_PRIORITY, DIPImp( Name ), diff --git a/bld/mad/c/madimp.c b/bld/mad/c/madimp.c index 177cf94338..3af0d49b49 100644 --- a/bld/mad/c/madimp.c +++ b/bld/mad/c/madimp.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -46,8 +46,8 @@ mad_client_routines *MADClient; mad_imp_routines MadImpInterface = { - MAD_MAJOR, - MAD_MINOR, + MAD_VERSION_MAJOR, + MAD_VERSION_MINOR, sizeof( MadImpInterface ), MADImp( Init ), diff --git a/bld/trap/common/remote.c b/bld/trap/common/remote.c index 123cf55811..725d354354 100644 --- a/bld/trap/common/remote.c +++ b/bld/trap/common/remote.c @@ -152,8 +152,8 @@ trap_version TRAPENTRY TrapInit( const char *parms, char *error, bool remote ) } else { error[0] = '\0'; } - ver.major = TRAP_MAJOR_VERSION; - ver.minor = fix_minor ? OLD_TRAP_MINOR_VERSION : TRAP_MINOR_VERSION; + ver.major = TRAP_VERSION_MAJOR; + ver.minor = fix_minor ? OLD_TRAP_VERSION_MINOR : TRAP_VERSION_MINOR; _DBG_ExitFunc( "TrapInit" ); return( ver ); } diff --git a/bld/trap/lcl/dos/dosr/c/dosacc.c b/bld/trap/lcl/dos/dosr/c/dosacc.c index ae0fc7f5df..4fdfb92304 100644 --- a/bld/trap/lcl/dos/dosr/c/dosacc.c +++ b/bld/trap/lcl/dos/dosr/c/dosacc.c @@ -1100,8 +1100,8 @@ outline( " done checking environment" ); ExceptNum = -1; WatchCount = 0; BreakOpcode = BRKPOINT; - ver.major = TRAP_MAJOR_VERSION; - ver.minor = TRAP_MINOR_VERSION; + ver.major = TRAP_VERSION_MAJOR; + ver.minor = TRAP_VERSION_MINOR; ver.remote = false; outline( "done TrapInit" ); return( ver ); diff --git a/bld/trap/lcl/dos/dosx/ads/c/adsacc.c b/bld/trap/lcl/dos/dosx/ads/c/adsacc.c index e2a4edd7c4..e330b89978 100644 --- a/bld/trap/lcl/dos/dosx/ads/c/adsacc.c +++ b/bld/trap/lcl/dos/dosx/ads/c/adsacc.c @@ -987,8 +987,8 @@ trap_version TRAPENTRY TrapInit( const char *parms, char *err, bool remote ) _DBG0(( "TrapInit" )); err[0] = '\0'; /* all ok */ - ver.major = TRAP_MAJOR_VERSION; - ver.minor = TRAP_MINOR_VERSION; + ver.major = TRAP_VERSION_MAJOR; + ver.minor = TRAP_VERSION_MINOR; ver.remote = false; RedirectInit(); RealNPXType = NPXType(); diff --git a/bld/trap/lcl/dos/dosx/c/dosxremo.c b/bld/trap/lcl/dos/dosx/c/dosxremo.c index 907ee148e4..d787c7d9fe 100644 --- a/bld/trap/lcl/dos/dosx/c/dosxremo.c +++ b/bld/trap/lcl/dos/dosx/c/dosxremo.c @@ -466,8 +466,8 @@ trap_version TRAPENTRY TrapInit( const char *parms, char *error, bool remote ) trap_version ver; ver.remote = false; - ver.major = TRAP_MAJOR_VERSION; - ver.minor = TRAP_MINOR_VERSION; + ver.major = TRAP_VERSION_MAJOR; + ver.minor = TRAP_VERSION_MINOR; if( !remote && DPMIVersion() == 90 && !DOSEMUCheck() ) { strcpy( error, TRP_ERR_bad_dpmi ); return( ver ); diff --git a/bld/trap/lcl/dos/dosx/cw/c/cwacc.c b/bld/trap/lcl/dos/dosx/cw/c/cwacc.c index 4222708bbd..eeb2d469e4 100644 --- a/bld/trap/lcl/dos/dosx/cw/c/cwacc.c +++ b/bld/trap/lcl/dos/dosx/cw/c/cwacc.c @@ -1097,8 +1097,8 @@ trap_version TRAPENTRY TrapInit( const char *parms, char *err, bool remote ) /* unused parameters */ (void)parms; (void)remote; err[0] = '\0'; /* all ok */ - ver.major = TRAP_MAJOR_VERSION; - ver.minor = TRAP_MINOR_VERSION; + ver.major = TRAP_VERSION_MAJOR; + ver.minor = TRAP_VERSION_MINOR; ver.remote = false; RedirectInit(); RealNPXType = NPXType(); diff --git a/bld/trap/lcl/dos/dosx/pls/c/plsacc.c b/bld/trap/lcl/dos/dosx/pls/c/plsacc.c index 1d782b09d9..e0088fc937 100644 --- a/bld/trap/lcl/dos/dosx/pls/c/plsacc.c +++ b/bld/trap/lcl/dos/dosx/pls/c/plsacc.c @@ -1069,8 +1069,8 @@ trap_version TRAPENTRY TrapInit( const char *parms, char *err, bool remote ) _DBG(( "in TrapInit\r\n" )); err[0] = '\0'; /* all ok */ - ver.major = TRAP_MAJOR_VERSION; - ver.minor = TRAP_MINOR_VERSION; + ver.major = TRAP_VERSION_MAJOR; + ver.minor = TRAP_VERSION_MINOR; ver.remote = false; //ver.is_32 = true; RedirectInit(); diff --git a/bld/trap/lcl/dos/dosx/rsi/c/rsiacc.c b/bld/trap/lcl/dos/dosx/rsi/c/rsiacc.c index cb04552cc1..085a344e4d 100644 --- a/bld/trap/lcl/dos/dosx/rsi/c/rsiacc.c +++ b/bld/trap/lcl/dos/dosx/rsi/c/rsiacc.c @@ -935,8 +935,8 @@ trap_version TRAPENTRY TrapInit( const char *parms, char *err, bool remote ) _DBG_Writeln( "TrapInit" ); err[0] = '\0'; /* all ok */ - ver.major = TRAP_MAJOR_VERSION; - ver.minor = TRAP_MINOR_VERSION; + ver.major = TRAP_VERSION_MAJOR; + ver.minor = TRAP_VERSION_MINOR; ver.remote = false; RedirectInit(); RealNPXType = NPXType(); diff --git a/bld/trap/lcl/elfcore/c/elfcore.c b/bld/trap/lcl/elfcore/c/elfcore.c index db5557e635..a009140a6c 100644 --- a/bld/trap/lcl/elfcore/c/elfcore.c +++ b/bld/trap/lcl/elfcore/c/elfcore.c @@ -832,8 +832,8 @@ trap_version TRAPENTRY TrapInit( const char *parms, char *err, bool remote ) } } err[0] = '\0'; /* all ok */ - ver.major = TRAP_MAJOR_VERSION; - ver.minor = TRAP_MINOR_VERSION; + ver.major = TRAP_VERSION_MAJOR; + ver.minor = TRAP_VERSION_MINOR; ver.remote = false; return( ver ); } diff --git a/bld/trap/lcl/jvm/c/jvmacc.c b/bld/trap/lcl/jvm/c/jvmacc.c index 0c080ca4c7..8969f43f6d 100644 --- a/bld/trap/lcl/jvm/c/jvmacc.c +++ b/bld/trap/lcl/jvm/c/jvmacc.c @@ -1330,8 +1330,8 @@ trap_version TRAPENTRY TrapInit( const char *parms, char *err, bool remote ) /* unused parameters */ (void)remote; (void)parms; err[0] = '\0'; /* all ok */ - ver.major = TRAP_MAJOR_VERSION; - ver.minor = TRAP_MINOR_VERSION; + ver.major = TRAP_VERSION_MAJOR; + ver.minor = TRAP_VERSION_MINOR; ver.remote = FALSE; sysAtexit( HandleExit ); cbCallJava = FindClass( EE(), "sun/tools/debug/jvmhelp", TRUE ); diff --git a/bld/trap/lcl/jvm/c/jvmxremo.c b/bld/trap/lcl/jvm/c/jvmxremo.c index 976191c817..e624fb0649 100644 --- a/bld/trap/lcl/jvm/c/jvmxremo.c +++ b/bld/trap/lcl/jvm/c/jvmxremo.c @@ -560,8 +560,8 @@ trap_version TRAPENTRY TrapInit( const char *parms, char *error, bool remote ) /* unused parameters */ (void)remote; ver.remote = FALSE; - ver.major = TRAP_MAJOR_VERSION; - ver.minor = TRAP_MINOR_VERSION; + ver.major = TRAP_VERSION_MAJOR; + ver.minor = TRAP_VERSION_MINOR; FakeHandle = GetStdHandle( STD_INPUT_HANDLE ); error[0] = '\0'; strcpy( LinkParms, parms ); diff --git a/bld/trap/lcl/linux/c/lnxacc.c b/bld/trap/lcl/linux/c/lnxacc.c index 3f3b1ce3c9..ce17b3885f 100644 --- a/bld/trap/lcl/linux/c/lnxacc.c +++ b/bld/trap/lcl/linux/c/lnxacc.c @@ -683,8 +683,8 @@ trap_version TRAPENTRY TrapInit( const char *parms, char *err, bool remote ) /* unused parameters */ (void)parms; (void)remote; err[0] = '\0'; /* all ok */ - ver.major = TRAP_MAJOR_VERSION; - ver.minor = TRAP_MINOR_VERSION; + ver.major = TRAP_VERSION_MAJOR; + ver.minor = TRAP_VERSION_MINOR; ver.remote = false; OrigPGrp = getpgrp(); BreakOpcode = BRKPOINT; diff --git a/bld/trap/lcl/linux/c/lnxcore.c b/bld/trap/lcl/linux/c/lnxcore.c index c731906e9e..3b15316a53 100644 --- a/bld/trap/lcl/linux/c/lnxcore.c +++ b/bld/trap/lcl/linux/c/lnxcore.c @@ -743,8 +743,8 @@ trap_version TRAPENTRY TrapInit( const char *parms, char *err, bool remote ) } } err[0] = '\0'; /* all ok */ - ver.major = TRAP_MAJOR_VERSION; - ver.minor = TRAP_MINOR_VERSION; + ver.major = TRAP_VERSION_MAJOR; + ver.minor = TRAP_VERSION_MINOR; ver.remote = false; return( ver ); } diff --git a/bld/trap/lcl/msj/c/msjacc.c b/bld/trap/lcl/msj/c/msjacc.c index d98d9a9001..647e7754e5 100644 --- a/bld/trap/lcl/msj/c/msjacc.c +++ b/bld/trap/lcl/msj/c/msjacc.c @@ -55,8 +55,8 @@ trap_version TRAPENTRY TrapInit( const char *parms, char *err, bool remote ) /* unused parameters */ (void)remote; (void)parms; MSJMemInit(); - ver.major = TRAP_MAJOR_VERSION; - ver.minor = TRAP_MINOR_VERSION; + ver.major = TRAP_VERSION_MAJOR; + ver.minor = TRAP_VERSION_MINOR; ver.remote = FALSE; TaskLoaded = FALSE; if( InitProc() ) { diff --git a/bld/trap/lcl/nlm/c/nlmacc.c b/bld/trap/lcl/nlm/c/nlmacc.c index 5d42206251..44a7fbd478 100644 --- a/bld/trap/lcl/nlm/c/nlmacc.c +++ b/bld/trap/lcl/nlm/c/nlmacc.c @@ -1929,8 +1929,8 @@ trap_version TRAPENTRY TrapInit( const char *parms, char *err, bool remote ) ImportCLIBSymbols(); #endif err[0] = '\0'; /* all ok */ - ver.major = TRAP_MAJOR_VERSION; - ver.minor = TRAP_MINOR_VERSION; + ver.major = TRAP_VERSION_MAJOR; + ver.minor = TRAP_VERSION_MINOR; ver.remote = FALSE; FakeBreak = false; BreakOpcode = BRKPOINT; diff --git a/bld/trap/lcl/nt/c/task.c b/bld/trap/lcl/nt/c/task.c index 60047cb7bd..3cf5607470 100644 --- a/bld/trap/lcl/nt/c/task.c +++ b/bld/trap/lcl/nt/c/task.c @@ -41,7 +41,7 @@ trap_version TRAPENTRY TrapInit( const char *parms, char *err, bool remote ) { - trap_version trapver; + trap_version ver; HANDLE dll; /* unused parameters */ (void)remote; @@ -105,10 +105,10 @@ trap_version TRAPENTRY TrapInit( const char *parms, char *err, bool remote ) BreakOnKernelMessage = true; } err[0] = 0; - trapver.major = TRAP_MAJOR_VERSION; - trapver.minor = TRAP_MINOR_VERSION; - trapver.remote = false; - return( trapver ); + ver.major = TRAP_VERSION_MAJOR; + ver.minor = TRAP_VERSION_MINOR; + ver.remote = false; + return( ver ); } void TRAPENTRY TrapFini( void ) diff --git a/bld/trap/lcl/nto/c/ntoacc.c b/bld/trap/lcl/nto/c/ntoacc.c index 4fc2021e0d..9eab4260ec 100644 --- a/bld/trap/lcl/nto/c/ntoacc.c +++ b/bld/trap/lcl/nto/c/ntoacc.c @@ -1340,8 +1340,8 @@ trap_version TRAPENTRY TrapInit( const char *parms, char *err, bool remote ) ProcInfo.node = ND_LOCAL_NODE; strcpy( ProcInfo.procfs_path, "/proc" ); err[0] = '\0'; /* all ok */ - ver.major = TRAP_MAJOR_VERSION; - ver.minor = TRAP_MINOR_VERSION; + ver.major = TRAP_VERSION_MAJOR; + ver.minor = TRAP_VERSION_MINOR; ver.remote = FALSE; OrigPGrp = getpgrp(); return( ver ); diff --git a/bld/trap/lcl/os2/c/os2v1acc.c b/bld/trap/lcl/os2/c/os2v1acc.c index 79c69eebb4..0c32e32269 100644 --- a/bld/trap/lcl/os2/c/os2v1acc.c +++ b/bld/trap/lcl/os2/c/os2v1acc.c @@ -1317,8 +1317,8 @@ trap_version TRAPENTRY TrapInit( const char *parms, char *err, bool remote ) Remote = remote; err[0] = '\0'; - ver.major = TRAP_MAJOR_VERSION; - ver.minor = TRAP_MINOR_VERSION; + ver.major = TRAP_VERSION_MAJOR; + ver.minor = TRAP_VERSION_MINOR; ver.remote = FALSE; SaveStdIn = NIL_DOS_HANDLE; SaveStdOut = NIL_DOS_HANDLE; diff --git a/bld/trap/lcl/os2/c/os2v2acc.c b/bld/trap/lcl/os2/c/os2v2acc.c index 5181eb6023..3de25e3a7d 100644 --- a/bld/trap/lcl/os2/c/os2v2acc.c +++ b/bld/trap/lcl/os2/c/os2v2acc.c @@ -1561,8 +1561,8 @@ trap_version TRAPENTRY TrapInit( const char *parms, char *err, bool remote ) Remote = remote; err[0] = '\0'; - ver.major = TRAP_MAJOR_VERSION; - ver.minor = TRAP_MINOR_VERSION; + ver.major = TRAP_VERSION_MAJOR; + ver.minor = TRAP_VERSION_MINOR; ver.remote = false; SaveStdIn = NIL_DOS_HANDLE; SaveStdOut = NIL_DOS_HANDLE; diff --git a/bld/trap/lcl/os2v2/c/os2v2acc.c b/bld/trap/lcl/os2v2/c/os2v2acc.c index 412db204d9..51221b6685 100644 --- a/bld/trap/lcl/os2v2/c/os2v2acc.c +++ b/bld/trap/lcl/os2v2/c/os2v2acc.c @@ -1739,8 +1739,8 @@ trap_version TRAPENTRY TrapInit( const char *parms, char *err, bool remote ) Remote = remote; err[0] = '\0'; - ver.major = TRAP_MAJOR_VERSION; - ver.minor = TRAP_MINOR_VERSION; + ver.major = TRAP_VERSION_MAJOR; + ver.minor = TRAP_VERSION_MINOR; ver.remote = false; SaveStdIn = NIL_DOS_HANDLE; SaveStdOut = NIL_DOS_HANDLE; diff --git a/bld/trap/lcl/qnx/c/qnxacc.c b/bld/trap/lcl/qnx/c/qnxacc.c index c84b16a293..72b3668c3e 100644 --- a/bld/trap/lcl/qnx/c/qnxacc.c +++ b/bld/trap/lcl/qnx/c/qnxacc.c @@ -1801,8 +1801,8 @@ trap_version TRAPENTRY TrapInit( const char *parms, char *err, bool remote ) StdPos.in = lseek( 0, 0, SEEK_CUR ); StdPos.out = lseek( 1, 0, SEEK_CUR ); StdPos.err = lseek( 2, 0, SEEK_CUR ); - ver.major = TRAP_MAJOR_VERSION; - ver.minor = TRAP_MINOR_VERSION; + ver.major = TRAP_VERSION_MAJOR; + ver.minor = TRAP_VERSION_MINOR; ver.remote = false; //ver.is_32 = false; OrigPGrp = getpgrp(); diff --git a/bld/trap/lcl/qnx/c/qnxpmd.c b/bld/trap/lcl/qnx/c/qnxpmd.c index 9077324ab3..50b4405ae0 100644 --- a/bld/trap/lcl/qnx/c/qnxpmd.c +++ b/bld/trap/lcl/qnx/c/qnxpmd.c @@ -879,8 +879,8 @@ trap_version TRAPENTRY TrapInit( const char *parms, char *err, bool remote ) } } err[0] = '\0'; /* all ok */ - ver.major = TRAP_MAJOR_VERSION; - ver.minor = TRAP_MINOR_VERSION; + ver.major = TRAP_VERSION_MAJOR; + ver.minor = TRAP_VERSION_MINOR; ver.remote = false; return( ver ); } diff --git a/bld/trap/lcl/rdos/c/task.c b/bld/trap/lcl/rdos/c/task.c index 7134b529b5..803045b37a 100644 --- a/bld/trap/lcl/rdos/c/task.c +++ b/bld/trap/lcl/rdos/c/task.c @@ -45,8 +45,8 @@ trap_version TRAPENTRY TrapInit( const char *parms, char *err, bool remote ) /* unused parameters */ (void)remote; (void)parms; err[0] = 0; - ver.major = TRAP_MAJOR_VERSION; - ver.minor = TRAP_MINOR_VERSION; + ver.major = TRAP_VERSION_MAJOR; + ver.minor = TRAP_VERSION_MINOR; ver.remote = false; return( ver ); } diff --git a/bld/trap/lcl/win/c/initfini.c b/bld/trap/lcl/win/c/initfini.c index 6b63094593..dd931a9fa9 100644 --- a/bld/trap/lcl/win/c/initfini.c +++ b/bld/trap/lcl/win/c/initfini.c @@ -319,8 +319,8 @@ trap_version TRAPENTRY TrapInit( const char *parms, char *err, bool remote ) } err[0] = 0; - ver.major = TRAP_MAJOR_VERSION; - ver.minor = TRAP_MINOR_VERSION; + ver.major = TRAP_VERSION_MAJOR; + ver.minor = TRAP_VERSION_MINOR; ver.remote = false; return( ver ); diff --git a/bld/wv/c/dipinter.c b/bld/wv/c/dipinter.c index 79dad2edd0..a3404e86c8 100644 --- a/bld/wv/c/dipinter.c +++ b/bld/wv/c/dipinter.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -869,8 +869,8 @@ static dip_status WVIMPENTRY( SymFreeAll )( imp_image_handle *iih ) } static dip_imp_routines InternalInterface = { - DIP_MAJOR, - DIP_MINOR, + DIP_VERSION_MAJOR, + DIP_VERSION_MINOR, DIP_PRIOR_EXPORTS, WVImp( Name ), diff --git a/bld/wv/c/remmisc.c b/bld/wv/c/remmisc.c index 902355c975..2aa8f58408 100644 --- a/bld/wv/c/remmisc.c +++ b/bld/wv/c/remmisc.c @@ -158,8 +158,8 @@ void InitTrap( const char *parms ) StartupErr( buff ); } acc.req = REQ_CONNECT; - acc.ver.major = TRAP_MAJOR_VERSION; - acc.ver.minor = TRAP_MINOR_VERSION; + acc.ver.major = TRAP_VERSION_MAJOR; + acc.ver.minor = TRAP_VERSION_MINOR; acc.ver.remote = false; in[0].ptr = &acc; in[0].len = sizeof( acc ); From f2fae0c3873030881bfda6588ff5d3c5e6999c93 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Mon, 11 Sep 2023 10:38:01 +0200 Subject: [PATCH 114/258] cleanup DIP/MAD/TRP version macros --- bld/dig/c/dipman.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/bld/dig/c/dipman.c b/bld/dig/c/dipman.c index cdb158016f..c4798960c5 100644 --- a/bld/dig/c/dipman.c +++ b/bld/dig/c/dipman.c @@ -707,7 +707,7 @@ static walk_result DoWalkSymList( symbol_source ss, void *start, walk_glue *wd ) ih = II2IH( ii ); if( ih != NULL ) { sh->ii = ii; - if( ih->dip->minor == DIP_MINOR ) { + if( ih->dip->minor == DIP_VERSION_MINOR ) { wr = ih->dip->WalkSymListEx( IH2IIH( ih ), ss, start, SymGlue, SH2ISH( sh ), wd->lc, wd ); } else { wr = ih->dip->WalkSymList( IH2IIH( ih ), ss, start, SymGlue, SH2ISH( sh ), wd ); @@ -914,7 +914,7 @@ dip_status DIPTypeBase( type_handle *th, type_handle *base_th, location_context return( DS_ERR | DS_NO_PROCESS ); base_th->ii = th->ii; base_th->ap = 0; - if( ih->dip->minor == DIP_MINOR ) { + if( ih->dip->minor == DIP_VERSION_MINOR ) { return( ih->dip->TypeBase( IH2IIH( ih ), TH2ITH( th ), TH2ITH( base_th ), lc, ll ) ); } else { return( ih->dip->OldTypeBase( IH2IIH( ih ), TH2ITH( th ), TH2ITH( base_th ) ) ); @@ -929,7 +929,7 @@ dip_status DIPTypeAddRef( type_handle *th ) ih = II2IH( th->ii ); if( ih == NULL ) return( DS_ERR | DS_NO_PROCESS ); - if( ih->dip->minor == DIP_MINOR ) { + if( ih->dip->minor == DIP_VERSION_MINOR ) { return( ih->dip->TypeAddRef( IH2IIH( ih ), TH2ITH( th ) ) ); } else { return( DS_OK ); @@ -944,7 +944,7 @@ dip_status DIPTypeRelease( type_handle *th ) ih = II2IH( th->ii ); if( ih == NULL ) return( DS_ERR | DS_NO_PROCESS ); - if( ih->dip->minor == DIP_MINOR ) { + if( ih->dip->minor == DIP_VERSION_MINOR ) { return( ih->dip->TypeRelease( IH2IIH( ih ), TH2ITH( th ) ) ); } else { return( DS_OK ); @@ -959,7 +959,7 @@ dip_status DIPTypeFreeAll( void ) if( ActProc == NULL ) return( DS_OK ); for( ih = ActProc->list_ih; ih != NULL; ih = ih->next ) { - if( ih->dip->minor == DIP_MINOR ) { + if( ih->dip->minor == DIP_VERSION_MINOR ) { ih->dip->TypeFreeAll( IH2IIH( ih ) ); } } @@ -1178,7 +1178,7 @@ dip_status DIPSymAddRef( sym_handle *sh ) ih = II2IH( sh->ii ); if( ih == NULL ) return( DS_ERR | DS_NO_PROCESS ); - if( ih->dip->minor == DIP_MINOR ) { + if( ih->dip->minor == DIP_VERSION_MINOR ) { return( ih->dip->SymAddRef( IH2IIH( ih ), SH2ISH( sh ) ) ); } else { return( DS_OK ); @@ -1193,7 +1193,7 @@ dip_status DIPSymRelease( sym_handle *sh ) ih = II2IH( sh->ii ); if( ih == NULL ) return( DS_ERR | DS_NO_PROCESS ); - if( ih->dip->minor == DIP_MINOR ) { + if( ih->dip->minor == DIP_VERSION_MINOR ) { return( ih->dip->SymRelease( IH2IIH( ih ), SH2ISH( sh ) ) ); } else { return( DS_OK ); @@ -1208,7 +1208,7 @@ dip_status DIPSymFreeAll( void ) if( ActProc == NULL ) return( DS_OK ); for( ih = ActProc->list_ih; ih != NULL; ih = ih->next ) { - if( ih->dip->minor == DIP_MINOR ) { + if( ih->dip->minor == DIP_VERSION_MINOR ) { ih->dip->SymFreeAll( IH2IIH( ih ) ); } } @@ -1435,7 +1435,7 @@ search_result DIPLookupSymEx( symbol_source ss, void *source, lookup_item *li, l ih = (li->mod == NO_MOD) ? curr_ih : MH2IH( li->mod ); li->mod = IMH2MH( MH2IMH( li->mod ) ); if( ih != NULL ) { - if( ih->dip->minor == DIP_MINOR ) { + if( ih->dip->minor == DIP_VERSION_MINOR ) { sr = ih->dip->LookupSymEx( IH2IIH( ih ), ss, source, li, lc, d ); } else { sr = ih->dip->LookupSym( IH2IIH( ih ), ss, source, li, d ); @@ -1447,7 +1447,7 @@ search_result DIPLookupSymEx( symbol_source ss, void *source, lookup_item *li, l curr_ih = ih; for( ih = ActProc->list_ih; ih != NULL; ih = ih->next ) { if( ih != curr_ih ) { - if( ih->dip->minor == DIP_MINOR ) { + if( ih->dip->minor == DIP_VERSION_MINOR ) { sr = ih->dip->LookupSymEx( IH2IIH( ih ), ss, source, li, lc, d ); } else { sr = ih->dip->LookupSym( IH2IIH( ih ), ss, source, li, d ); From 05a6e2b728d2d5e3cdd21732e2168d0d2c810a34 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Mon, 11 Sep 2023 18:12:41 +0200 Subject: [PATCH 115/258] add new macro REQ_WANT_RETURN for trap project --- bld/dig/h/trptypes.h | 1 + bld/trap/common/remote.c | 4 ++-- bld/trap/common/servacc.c | 6 +++--- bld/trap/lcl/dos/dosx/c/dosxremo.c | 4 ++-- bld/trap/lcl/dos/dosx/c/dosxserv.c | 6 +++--- bld/trap/lcl/jvm/c/jvmxremo.c | 4 ++-- bld/trap/lcl/jvm/c/jvmxserv.c | 6 +++--- 7 files changed, 16 insertions(+), 15 deletions(-) diff --git a/bld/dig/h/trptypes.h b/bld/dig/h/trptypes.h index d6c9893a62..e172d44f33 100644 --- a/bld/dig/h/trptypes.h +++ b/bld/dig/h/trptypes.h @@ -63,6 +63,7 @@ #endif #define TRP_REQUEST(x) *((trap_req *)(x)[0].ptr) +#define REQ_WANT_RETURN (0x80) #define TRAP_SYM1(a,b,c) a ## b ## _ ## c #define TRAP_SYM(a,b) TRAP_SYM1( Req, a, b ) diff --git a/bld/trap/common/remote.c b/bld/trap/common/remote.c index 725d354354..5e9cc3fa05 100644 --- a/bld/trap/common/remote.c +++ b/bld/trap/common/remote.c @@ -51,12 +51,12 @@ static trap_retval DoRequest( void ) StartPacket(); if( Out_Mx_Num == 0 ) { /* Tell the server we're not expecting anything back */ - TRP_REQUEST( In_Mx_Ptr ) |= 0x80; + TRP_REQUEST( In_Mx_Ptr ) |= REQ_WANT_RETURN; } for( i = 0; i < In_Mx_Num; ++i ) { AddPacket( In_Mx_Ptr[i].ptr, In_Mx_Ptr[i].len ); } - TRP_REQUEST( In_Mx_Ptr ) &= ~0x80; + TRP_REQUEST( In_Mx_Ptr ) &= ~REQ_WANT_RETURN; result = PutPacket(); if( result != REQUEST_FAILED ) { result = 0; diff --git a/bld/trap/common/servacc.c b/bld/trap/common/servacc.c index ac7c47f649..5c15bcea7d 100644 --- a/bld/trap/common/servacc.c +++ b/bld/trap/common/servacc.c @@ -116,13 +116,13 @@ bool Session( void ) In_Mx_Num = 1; Out_Mx_Num = 1; req = TRP_REQUEST( In ); - TRP_REQUEST( In ) &= ~0x80; - if( req & 0x80 ) { - req &= ~0x80; + if( req & REQ_WANT_RETURN ) { + req &= ~REQ_WANT_RETURN; want_return = false; } else { want_return = true; } + TRP_REQUEST( In ) = req; switch( req ) { case REQ_CONNECT: if( !AccConnect() ) diff --git a/bld/trap/lcl/dos/dosx/c/dosxremo.c b/bld/trap/lcl/dos/dosx/c/dosxremo.c index d787c7d9fe..b27b1cd58f 100644 --- a/bld/trap/lcl/dos/dosx/c/dosxremo.c +++ b/bld/trap/lcl/dos/dosx/c/dosxremo.c @@ -70,13 +70,13 @@ static trap_elen DoAccess( void ) StartPacket(); if( Out_Mx_Num == 0 ) { /* Tell the server we're not expecting anything back */ - TRP_REQUEST( In_Mx_Ptr ) |= 0x80; + TRP_REQUEST( In_Mx_Ptr ) |= REQ_WANT_RETURN; } for( i = 0; i < In_Mx_Num; ++i ) { _DBG_Writeln( "AddPacket" ); AddPacket( In_Mx_Ptr[i].ptr, In_Mx_Ptr[i].len ); } - TRP_REQUEST( In_Mx_Ptr ) &= ~0x80; + TRP_REQUEST( In_Mx_Ptr ) &= ~REQ_WANT_RETURN; _DBG_Writeln( "PutPacket" ); PutPacket(); if( Out_Mx_Num != 0 ) { diff --git a/bld/trap/lcl/dos/dosx/c/dosxserv.c b/bld/trap/lcl/dos/dosx/c/dosxserv.c index 4c62fd705e..375a3f7544 100644 --- a/bld/trap/lcl/dos/dosx/c/dosxserv.c +++ b/bld/trap/lcl/dos/dosx/c/dosxserv.c @@ -94,13 +94,13 @@ bool Session( void ) In[0].ptr = GetPacketBuffPtr(); _DBG(("Session got request ")); req = TRP_REQUEST( In ); - TRP_REQUEST( In ) &= ~0x80; - if( req & 0x80 ) { - req &= ~0x80; + if( req & REQ_WANT_RETURN ) { + req &= ~REQ_WANT_RETURN; want_return = false; } else { want_return = true; } + TRP_REQUEST( In ) = req; switch( req ) { case REQ_PROG_KILL: _DBG(("REQ_KILL_PROG\n")); diff --git a/bld/trap/lcl/jvm/c/jvmxremo.c b/bld/trap/lcl/jvm/c/jvmxremo.c index e624fb0649..914cedecb5 100644 --- a/bld/trap/lcl/jvm/c/jvmxremo.c +++ b/bld/trap/lcl/jvm/c/jvmxremo.c @@ -59,12 +59,12 @@ trap_retval DoAccess( void ) StartPacket(); if( Out_Mx_Num == 0 ) { /* Tell the server we're not expecting anything back */ - TRP_REQUEST( In_Mx_Ptr ) |= 0x80; + TRP_REQUEST( In_Mx_Ptr ) |= REQ_WANT_RETURN; } for( i = 0; i < In_Mx_Num; ++i ) { AddPacket( In_Mx_Ptr[i].ptr, In_Mx_Ptr[i].len ); } - TRP_REQUEST( In_Mx_Ptr ) &= ~0x80; + TRP_REQUEST( In_Mx_Ptr ) &= ~REQ_WANT_RETURN; PutPacket(); if( Out_Mx_Num != 0 ) { len = GetPacket(); diff --git a/bld/trap/lcl/jvm/c/jvmxserv.c b/bld/trap/lcl/jvm/c/jvmxserv.c index 5bbcd9babf..31deb5214e 100644 --- a/bld/trap/lcl/jvm/c/jvmxserv.c +++ b/bld/trap/lcl/jvm/c/jvmxserv.c @@ -82,13 +82,13 @@ bool Session( void ) In[0].ptr = GetPacketBuffPtr(); _DBG(("Session got request ")); req = TRP_REQUEST( In ); - TRP_REQUEST( In ) &= ~0x80; - if( req & 0x80 ) { - req &= ~0x80; + if( req & REQ_WANT_RETURN ) { + req &= ~REQ_WANT_RETURN; want_return = FALSE; } else { want_return = TRUE; } + TRP_REQUEST( In ) = req; switch( req ) { case REQ_PROG_KILL: _DBG(("REQ_KILL_PROG\n")); From 240498ad66fc2d2ecb87b7372a6ffcf7ee5e1cfc Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Mon, 11 Sep 2023 18:25:13 +0200 Subject: [PATCH 116/258] cleanup trap code --- bld/dig/c/dos/trpld.c | 8 ++++---- bld/trap/common/remote.c | 12 ++++++------ bld/trap/ser/c/serlink.c | 5 ++++- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/bld/dig/c/dos/trpld.c b/bld/dig/c/dos/trpld.c index ad4a96547d..90e7684851 100644 --- a/bld/dig/c/dos/trpld.c +++ b/bld/dig/c/dos/trpld.c @@ -59,7 +59,7 @@ static trap_fini_func *FiniFunc = NULL; static trpld_error ReadInTrap( FILE *fp ) { dos_exe_header hdr; - unsigned size; + unsigned image_size; unsigned hdr_size; struct { unsigned_16 off; @@ -78,15 +78,15 @@ static trpld_error ReadInTrap( FILE *fp ) return( TC_ERR_BAD_TRAP_FILE ); } hdr_size = hdr.hdr_size * 16; - size = (hdr.file_size * 0x200) - (-hdr.mod_size & 0x1ff) - hdr_size; - ret = TinyAllocBlock( __ROUND_UP_SIZE_TO_PARA( size ) ); + image_size = (hdr.file_size * 0x200) - (-hdr.mod_size & 0x1ff) - hdr_size; + ret = TinyAllocBlock( __ROUND_UP_SIZE_TO_PARA( image_size ) ); if( TINY_ERROR( ret ) ) { return( TC_ERR_OUT_OF_DOS_MEMORY ); } start_seg = TINY_INFO( ret ); TrapCode = _MK_FP( start_seg, 0 ); DIGLoader( Seek )( fp, hdr_size, DIG_SEEK_ORG ); - DIGLoader( Read )( fp, TrapCode, size ); + DIGLoader( Read )( fp, TrapCode, image_size ); DIGLoader( Seek )( fp, hdr.reloc_offset, DIG_SEEK_ORG ); p = &buff[NUM_BUFF_RELOCS]; for( relocs = hdr.num_relocs; relocs != 0; --relocs ) { diff --git a/bld/trap/common/remote.c b/bld/trap/common/remote.c index 5e9cc3fa05..339919b796 100644 --- a/bld/trap/common/remote.c +++ b/bld/trap/common/remote.c @@ -129,10 +129,10 @@ static void ReqRemoteResume( void ) _DBG_ExitFunc( "ReqResume" ); } -trap_version TRAPENTRY TrapInit( const char *parms, char *error, bool remote ) +trap_version TRAPENTRY TrapInit( const char *parms, char *err, bool remote ) { trap_version ver; - const char *err; + const char *error; bool fix_minor; /* unused parameters */ (void)remote; @@ -146,11 +146,11 @@ trap_version TRAPENTRY TrapInit( const char *parms, char *error, bool remote ) fix_minor = true; } } - err = RemoteLink( parms, false ); - if( err != NULL ) { - strcpy( error, err ); + error = RemoteLink( parms, false ); + if( error != NULL ) { + strcpy( err, error ); } else { - error[0] = '\0'; + err[0] = '\0'; } ver.major = TRAP_VERSION_MAJOR; ver.minor = fix_minor ? OLD_TRAP_VERSION_MINOR : TRAP_VERSION_MINOR; diff --git a/bld/trap/ser/c/serlink.c b/bld/trap/ser/c/serlink.c index acdfd5d0dd..43c63bc4b1 100644 --- a/bld/trap/ser/c/serlink.c +++ b/bld/trap/ser/c/serlink.c @@ -678,6 +678,9 @@ static const char *CollectParm( const char *parm, char *arg, int *len ) static char *SetLinkParms( const char **pparm ) +/********************************************** + * The format for *parms is "1.9600" + */ { const char *parm; char arg1[7]; @@ -852,7 +855,7 @@ static char *SetupModem( const char *parm ) const char *RemoteLink( const char *parms, bool server ) /******************************************************* - * The format for *parm is "1.9600" + * The format for *parms is "1.9600" */ { const char *result; From 6f00a9d3f0f7b051272b8a08e75461e98009bec1 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Mon, 11 Sep 2023 20:25:05 +0200 Subject: [PATCH 117/258] rename structure member to more transparent name --- bld/dig/c/linux/peloader.c | 2 +- bld/watcom/h/coff.h | 4 ++-- bld/watcom/h/exepe.h | 4 ++-- bld/wl/c/loadpe.c | 4 ++-- bld/wprof/c/support.c | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/bld/dig/c/linux/peloader.c b/bld/dig/c/linux/peloader.c index f2bb803ad4..733fe89009 100644 --- a/bld/dig/c/linux/peloader.c +++ b/bld/dig/c/linux/peloader.c @@ -152,7 +152,7 @@ u_long PE_getFileSize( FILE *fp, u_long startOffset ) /* * Scan all the section headers summing up the total size */ - size = opthdr.header_size; + size = opthdr.headers_size; for( i = 0; i < filehdr.num_objects; i++ ) { if( DIGLoader( Read )( fp, §hdr, sizeof( secthdr ) ) ) return( 0xFFFFFFFF ); diff --git a/bld/watcom/h/coff.h b/bld/watcom/h/coff.h index 39050334f6..7e4671feff 100644 --- a/bld/watcom/h/coff.h +++ b/bld/watcom/h/coff.h @@ -564,7 +564,7 @@ typedef struct { uint_16 subsys_minor; uint_32 reserved1; uint_32 image_size; - uint_32 header_size; + uint_32 headers_size; uint_32 file_checksum; uint_16 sub_system; uint_16 dll_flags; @@ -608,7 +608,7 @@ typedef struct { uint_16 subsys_minor; uint_32 reserved1; uint_32 image_size; - uint_32 header_size; + uint_32 headers_size; uint_32 file_checksum; uint_16 sub_system; uint_16 dll_flags; diff --git a/bld/watcom/h/exepe.h b/bld/watcom/h/exepe.h index 8f0198dac3..a52a93ee51 100644 --- a/bld/watcom/h/exepe.h +++ b/bld/watcom/h/exepe.h @@ -290,7 +290,7 @@ typedef struct { unsigned_16 subsys_minor; unsigned_32 rsvd1; unsigned_32 image_size; - unsigned_32 header_size; //size of dos hdr, nt hdr, obj table & pad + unsigned_32 headers_size; //size of dos hdr, nt hdr, obj table & pad unsigned_32 file_checksum; unsigned_16 subsystem; unsigned_16 dll_flags; @@ -327,7 +327,7 @@ typedef struct { unsigned_16 subsys_minor; unsigned_32 rsvd1; unsigned_32 image_size; - unsigned_32 header_size; //size of dos hdr, nt hdr, obj table & pad + unsigned_32 headers_size; //size of dos hdr, nt hdr, obj table & pad unsigned_32 file_checksum; unsigned_16 subsystem; unsigned_16 dll_flags; diff --git a/bld/wl/c/loadpe.c b/bld/wl/c/loadpe.c index 84e807e0ea..68ce5d367a 100644 --- a/bld/wl/c/loadpe.c +++ b/bld/wl/c/loadpe.c @@ -1185,7 +1185,7 @@ void FiniPELoadFile( void ) } NullAlign( file_align ); /* pad out last page */ PE64( pehdr ).image_size = image_size; - PE64( pehdr ).header_size = objects[0].physical_offset; + PE64( pehdr ).headers_size = objects[0].physical_offset; } else { if( FmtData.u.pe.tnt || FmtData.u.pe.subsystem == PE_SS_PL_DOSSTYLE ) { pehdr.signature = EXESIGN_PL; @@ -1362,7 +1362,7 @@ void FiniPELoadFile( void ) } NullAlign( file_align ); /* pad out last page */ PE32( pehdr ).image_size = image_size; - PE32( pehdr ).header_size = objects[0].physical_offset; + PE32( pehdr ).headers_size = objects[0].physical_offset; } DBIWrite(); SeekLoad( stub_len ); diff --git a/bld/wprof/c/support.c b/bld/wprof/c/support.c index 4f2a95d2b3..1e2b863d28 100644 --- a/bld/wprof/c/support.c +++ b/bld/wprof/c/support.c @@ -464,7 +464,7 @@ bool SetExeFile( FILE *fp, bool overlay ) #if 0 fseek( exeFP, ne_header_off + offsetof( pe_header, num_objects ), SEEK_SET ); fread( exeFP, &data16, 1, sizeof( data16 ), exeFP ); - fseek( exeFP, ne_header_off + offsetof( pe_header, header_size ), SEEK_SET ); + fseek( exeFP, ne_header_off + offsetof( pe_header, headers_size ), SEEK_SET ); fread( &data32, 1, sizeof( data32 ), exeFP ); /* exeImageOffset is in bytes and points to the object table */ exeImageOffset = data32 - data16 * sizeof( pe_object ); From 7ad464776b436aa510e30ae9eb97bc7a96ee4a97 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Mon, 11 Sep 2023 21:46:39 +0200 Subject: [PATCH 118/258] cleanup trap code --- bld/dig/h/dipimp.h | 20 ++++++++++---------- bld/trap/lcl/dos/dosx/c/dosxremo.c | 6 +++--- bld/trap/lcl/jvm/c/jvmxremo.c | 6 ++---- 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/bld/dig/h/dipimp.h b/bld/dig/h/dipimp.h index 88e13c2723..7cabe1c20f 100644 --- a/bld/dig/h/dipimp.h +++ b/bld/dig/h/dipimp.h @@ -45,20 +45,20 @@ * An imp_mod_handle is defined as an unsigned_16. The value zero is * reserved to indicate "no module". */ -#define IMH_NOMOD ((imp_mod_handle)0) -#define IMH_BASE ((imp_mod_handle)1) -#define IMH_GBL ((imp_mod_handle)-1) +#define IMH_NOMOD ((imp_mod_handle)0) +#define IMH_BASE ((imp_mod_handle)1) +#define IMH_GBL ((imp_mod_handle)-1) -#define DIPImp(n) DIPImp ## n -#define _DIPImp(n) _DIPImp ## n n +#define DIPImp(n) DIPImp ## n +#define _DIPImp(n) _DIPImp ## n n -#define DIPIMPENTRY(n) DIGENTRY DIPImp( n ) +#define DIPIMPENTRY(n) DIGENTRY DIPImp( n ) -typedef int strcomp_fn( const char *, const char * ); -typedef int strcompn_fn( const char *, const char *, size_t ); +typedef int strcomp_fn( const char *, const char * ); +typedef int strcompn_fn( const char *, const char *, size_t ); -typedef unsigned_16 imp_mod_handle; -typedef unsigned_16 image_index; +typedef unsigned_16 imp_mod_handle; +typedef unsigned_16 image_index; typedef walk_result (DIGCLIENT DIP_IMP_MOD_WALKER)( imp_image_handle *, imp_mod_handle, void * ); typedef walk_result (DIGCLIENT DIP_IMP_TYPE_WALKER)( imp_image_handle *, imp_type_handle *, void * ); diff --git a/bld/trap/lcl/dos/dosx/c/dosxremo.c b/bld/trap/lcl/dos/dosx/c/dosxremo.c index b27b1cd58f..77e9db45e8 100644 --- a/bld/trap/lcl/dos/dosx/c/dosxremo.c +++ b/bld/trap/lcl/dos/dosx/c/dosxremo.c @@ -461,7 +461,7 @@ trap_retval TRAP_CORE( Prog_step )( void ) return( TRAP_CORE( Prog_go )() ); } -trap_version TRAPENTRY TrapInit( const char *parms, char *error, bool remote ) +trap_version TRAPENTRY TrapInit( const char *parms, char *err, bool remote ) { trap_version ver; @@ -469,13 +469,13 @@ trap_version TRAPENTRY TrapInit( const char *parms, char *error, bool remote ) ver.major = TRAP_VERSION_MAJOR; ver.minor = TRAP_VERSION_MINOR; if( !remote && DPMIVersion() == 90 && !DOSEMUCheck() ) { - strcpy( error, TRP_ERR_bad_dpmi ); + strcpy( err, TRP_ERR_bad_dpmi ); return( ver ); } _DBG_EnterFunc( "TrapInit()" ); InitPSP(); LoadError = NULL; - error[0] = '\0'; + err[0] = '\0'; strcpy( LinkParms, parms ); // save trap parameters TaskLoaded = false; _DBG_ExitFunc( "TrapInit()" ); diff --git a/bld/trap/lcl/jvm/c/jvmxremo.c b/bld/trap/lcl/jvm/c/jvmxremo.c index 914cedecb5..230341b4f1 100644 --- a/bld/trap/lcl/jvm/c/jvmxremo.c +++ b/bld/trap/lcl/jvm/c/jvmxremo.c @@ -300,7 +300,6 @@ trap_retval TRAP_CORE( Prog_load )( void ) const char *err; prog_load_ret *ret; size_t len; - const char *loaderr; ret = GetOutPtr( 0 ); src = name = GetInPtr( sizeof( prog_load_req ) ); @@ -315,7 +314,6 @@ trap_retval TRAP_CORE( Prog_load )( void ) } err = RemoteLink( LinkParms, FALSE ); if( err != NULL ) { - loaderr = err; strcpy( SavedError, err ); ret->err = ERR_JVM_SAVED_ERROR; return( sizeof( *ret ) ); @@ -553,7 +551,7 @@ trap_retval TRAP_CORE( Split_cmd )( void ) return( sizeof( *ret ) ); } -trap_version TRAPENTRY TrapInit( const char *parms, char *error, bool remote ) +trap_version TRAPENTRY TrapInit( const char *parms, char *err, bool remote ) { trap_version ver; @@ -563,7 +561,7 @@ trap_version TRAPENTRY TrapInit( const char *parms, char *error, bool remote ) ver.major = TRAP_VERSION_MAJOR; ver.minor = TRAP_VERSION_MINOR; FakeHandle = GetStdHandle( STD_INPUT_HANDLE ); - error[0] = '\0'; + err[0] = '\0'; strcpy( LinkParms, parms ); TaskLoaded = FALSE; return( ver ); From 4b16b6602f6a851f5a3a335548f812f2b350c09a Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Tue, 12 Sep 2023 00:35:59 +0200 Subject: [PATCH 119/258] correct build break --- bld/rc/exedmp/c/format.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bld/rc/exedmp/c/format.c b/bld/rc/exedmp/c/format.c index 7fd308c0d3..09d7a05cf4 100644 --- a/bld/rc/exedmp/c/format.c +++ b/bld/rc/exedmp/c/format.c @@ -407,7 +407,7 @@ void printPeHeader( ExeFile *exeFile, Parameters *param ) printf( MSG_PE_SUBSYSMINOR , PE( exeFile->pexHdr, subsys_minor ) ); printf( MSG_PE_RSVD1 , PE( exeFile->pexHdr, rsvd1 ) ); printf( MSG_PE_IMAGESIZE , PE( exeFile->pexHdr, image_size ) ); - printf( MSG_PE_HEADERSIZE , PE( exeFile->pexHdr, header_size ) ); + printf( MSG_PE_HEADERSIZE , PE( exeFile->pexHdr, headers_size ) ); printf( MSG_PE_FILECHECKSUM , PE( exeFile->pexHdr, file_checksum ) ); printf( MSG_PE_SUBSYSTEM , PE( exeFile->pexHdr, subsystem ) ); count = ED_PE_SS_COUNT; From 96354fc6dae078294e69eed3e5b2e2de542d6186 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Tue, 12 Sep 2023 01:39:42 +0200 Subject: [PATCH 120/258] correct macro expansion --- bld/wv/c/dbglkup.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bld/wv/c/dbglkup.c b/bld/wv/c/dbglkup.c index cfd1fb6955..638fb3a15b 100644 --- a/bld/wv/c/dbglkup.c +++ b/bld/wv/c/dbglkup.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -57,6 +57,8 @@ pick( "Ignore", CASE_IGNORE ) \ pick( "Respect", CASE_RESPECT ) +#define SYM_STR(x) DEBUG_SYM_STR(x) + enum { #define pick(t,e) e, CASE_OPTS @@ -538,7 +540,7 @@ bool SetWDPresent( mod_handle mh ) { address addr; - if( !GetSymAddr( DEBUG_SYM_STR( DEBUG_PRESENT_NAME ), mh, &addr ) ) + if( !GetSymAddr( SYM_STR( DEBUG_PRESENT_NAME ), mh, &addr ) ) return( false ); ProgPoke( addr, "\x1", 1 ); return( true ); From fbc4119af5bb67006573f8d0c7a8834fe4e8f64c Mon Sep 17 00:00:00 2001 From: Detlef Riekenberg Date: Tue, 12 Sep 2023 08:33:40 +0200 Subject: [PATCH 121/258] WGML doc: fix the year 2000 bug in the old binary DOS wgml tools (#1134) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * dwdoc: Hide the year 2000 bug in the old binary DOS wgml tools Welcome in the year 19123. That's the current year on the title page of the pdf documentation of the dwarf writer library (dwdoc.pdf) and Code Generator (cgdoc.pdf). We can`t change the binary DOS tools, but we can avoid using the ":DATE. " command and hide the bug. * use &cpyyear. as replacement for broken WGML date Co-authored-by: Jiří Malák --- bld/cg/doc/cgref.gml | 2 +- bld/dwarf/dw/doc/dwref.gml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bld/cg/doc/cgref.gml b/bld/cg/doc/cgref.gml index e0e12ec736..f8b917957a 100644 --- a/bld/cg/doc/cgref.gml +++ b/bld/cg/doc/cgref.gml @@ -61,7 +61,7 @@ :FRONTM. :TITLEP. :TITLE.&company Code Generator Interface -:CMT. :DATE. +:DATE.&cpyyear. :eTITLEP. :TOC. .do end diff --git a/bld/dwarf/dw/doc/dwref.gml b/bld/dwarf/dw/doc/dwref.gml index 341afc58d2..b615d4af5c 100644 --- a/bld/dwarf/dw/doc/dwref.gml +++ b/bld/dwarf/dw/doc/dwref.gml @@ -20,7 +20,7 @@ :TITLE.Draft #6 :AUTHOR.Originally written by WATCOM International Corp. :AUTHOR.Revised by Open Watcom contributors -:DATE. +:DATE.&cpyyear. :eTITLEP. :TOC. .pa odd From 82804b9ff184c4e1cdec8dfb7c8e9fbe568d89a8 Mon Sep 17 00:00:00 2001 From: Detlef Riekenberg Date: Tue, 12 Sep 2023 08:58:39 +0200 Subject: [PATCH 122/258] wccmps: build the c compiler also for an i386-linux host (#1128) since wccmps builds already for a x86_64-linux host, enable the build also for an i386-linux host looks better -- Regards Detlef --- bld/cc/mps/linux386/makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bld/cc/mps/linux386/makefile b/bld/cc/mps/linux386/makefile index 3e52a71bfe..64f30bcd69 100644 --- a/bld/cc/mps/linux386/makefile +++ b/bld/cc/mps/linux386/makefile @@ -1,4 +1,4 @@ -#pmake: nobuild target_mips 386 linux os_linux cpu_386 +#pmake: build target_mips 386 linux os_linux cpu_386 host_os = linux host_cpu = 386 From 85b244225ff0a20851fce9cd8992c6a2b079b0b7 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Tue, 12 Sep 2023 19:51:09 +0200 Subject: [PATCH 123/258] add TCP 64-bit remote trap for linux --- bld/trap/builder.ctl | 5 +++++ bld/trap/ser/ntx64.trp/makefile | 3 ++- bld/trap/tcp/linuxx64.trp/makefile | 18 ++++++++++++++++++ bld/trap/tcp/ntx64.trp/makefile | 3 ++- 4 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 bld/trap/tcp/linuxx64.trp/makefile diff --git a/bld/trap/builder.ctl b/bld/trap/builder.ctl index 6c7e5367ef..bf5b3b23c3 100644 --- a/bld/trap/builder.ctl +++ b/bld/trap/builder.ctl @@ -191,6 +191,11 @@ set PROJDIR= par/ntsupp.x64/dbgport.sys "/binnt64/" par/ntsupp.x64/dbginst.exe "/binnt64/" + ser/linuxx64.trp/ser*.so "/binl64/" + ser/linuxx64.trp/ser*.sym "/binl64/" + tcp/linuxx64.trp/tcp*.so "/binl64/" + tcp/linuxx64.trp/tcp*.sym "/binl64/" + [ BLOCK . . ] [ INCLUDE "/build/epilog.ctl" ] diff --git a/bld/trap/ser/ntx64.trp/makefile b/bld/trap/ser/ntx64.trp/makefile index cc041bae4d..61c921809a 100644 --- a/bld/trap/ser/ntx64.trp/makefile +++ b/bld/trap/ser/ntx64.trp/makefile @@ -5,6 +5,8 @@ tree_depth = 4 host_cpu = x64 host_os = nt +sys_dll = 1 + target_cpu = x86 srv = ser @@ -15,7 +17,6 @@ extra_objs = sernt.obj busywait.obj bld_ldflags_ = -SUBSYSTEM:CONSOLE bld_ldflags_ += -EXPORT:TrapInit,@1 -EXPORT:TrapFini,@2 -EXPORT:TrapRequest,@3 -sys_dll = 1 bld_ldflags_dll_ = -SUBSYSTEM:CONSOLE bld_ldflags_dll_ += -EXPORT:TrapInit,@1 -EXPORT:TrapFini,@2 -EXPORT:TrapRequest,@3 diff --git a/bld/trap/tcp/linuxx64.trp/makefile b/bld/trap/tcp/linuxx64.trp/makefile new file mode 100644 index 0000000000..73abb43a4f --- /dev/null +++ b/bld/trap/tcp/linuxx64.trp/makefile @@ -0,0 +1,18 @@ +#pmake: build trap remote os_linux cpu_x64 tcp x86 + +tree_depth = 4 + +host_cpu = x64 +host_os = linux + +sys_dll = 1 + +target_cpu = x86 + +srv = tcp +which = TRAP +remote_link = 1 + +inc_dirs = -I"$(trap_dir)/lcl/linux/h" + +!include $(trap_dir)/master.mif diff --git a/bld/trap/tcp/ntx64.trp/makefile b/bld/trap/tcp/ntx64.trp/makefile index 023829ab09..0539a52b07 100644 --- a/bld/trap/tcp/ntx64.trp/makefile +++ b/bld/trap/tcp/ntx64.trp/makefile @@ -5,6 +5,8 @@ tree_depth = 4 host_cpu = x64 host_os = nt +sys_dll = 1 + target_cpu = x86 srv = tcp @@ -13,7 +15,6 @@ remote_link = 1 bld_ldflags_ = -SUBSYSTEM:CONSOLE -DEFAULTLIB:wsock32.lib bld_ldflags_ += -EXPORT:TrapInit,@1 -EXPORT:TrapFini,@2 -EXPORT:TrapRequest,@3 -sys_dll = 1 bld_ldflags_dll_ = -SUBSYSTEM:CONSOLE -DEFAULTLIB:wsock32.lib bld_ldflags_dll_ += -EXPORT:TrapInit,@1 -EXPORT:TrapFini,@2 -EXPORT:TrapRequest,@3 From c79b70126f82cd3297a3030afe5c97e5c78371a0 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Wed, 13 Sep 2023 11:42:03 +0200 Subject: [PATCH 124/258] fix debugger for trap file not open message not all messages are fatal now error for download feature and user module load not crash debugger --- bld/wv/c/dbgprog.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/bld/wv/c/dbgprog.c b/bld/wv/c/dbgprog.c index 9ea768272b..231cebc587 100644 --- a/bld/wv/c/dbgprog.c +++ b/bld/wv/c/dbgprog.c @@ -224,7 +224,8 @@ static void DoDownLoadCode( void ) return; fh = FullPathOpen( TaskCmd, strlen( TaskCmd ), "exe", TxtBuff, TXT_LEN ); if( fh == NIL_HANDLE ) { - Error( ERR_NONE, LIT_ENG( ERR_FILE_NOT_OPEN ), TaskCmd ); + ErrorRet( ERR_NONE, LIT_ENG( ERR_FILE_NOT_OPEN ), TaskCmd ); + return; } FileClose( fh ); FindLocalDebugInfo( TxtBuff ); @@ -1477,7 +1478,8 @@ static void SymFileNew( void ) image->mapper = MapAddrUser; if( !ProcImgSymInfo( image ) ) { FreeImage( image ); - Error( ERR_NONE, LIT_ENG( ERR_FILE_NOT_OPEN ), TxtBuff ); + ErrorRet( ERR_NONE, LIT_ENG( ERR_FILE_NOT_OPEN ), TxtBuff ); + return; } owner = &image->map_list; while( !ScanEOC() ) { @@ -1571,7 +1573,8 @@ bool SymUserModLoad( const char *fname, address *loadaddr ) image->mapper = MapAddrUsrMod; if( !ProcImgSymInfo( image ) ) { FreeImage( image ); - Error( ERR_NONE, LIT_ENG( ERR_FILE_NOT_OPEN ), fname ); + ErrorRet( ERR_NONE, LIT_ENG( ERR_FILE_NOT_OPEN ), fname ); + return( true ); } owner = &image->map_list; From fbb89dff7d83cc50d53c0ce4225e9c9c44fad520 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Wed, 13 Sep 2023 12:14:44 +0200 Subject: [PATCH 125/258] move DIP/MAD/TRAP loaders error to global DIG header files --- bld/dig/c/dos/trpld.c | 29 +++++++++++----------- bld/dig/c/dsx/trpld.c | 49 +++++++++++++++++++------------------- bld/dig/c/linux/peloader.c | 1 - bld/dig/c/linux/trpld_pe.c | 17 +++++++------ bld/dig/c/linux/trpld_rx.c | 17 +++++++------ bld/dig/c/linux/trpld_so.c | 17 +++++++------ bld/dig/c/nov/trpld.c | 11 ++++----- bld/dig/c/nt/trpld.c | 15 ++++++------ bld/dig/c/os2/trpld.c | 15 ++++++------ bld/dig/c/qnx/trpld.c | 17 +++++++------ bld/dig/c/rdos/trpld.c | 15 ++++++------ bld/dig/c/win/trpld.c | 15 ++++++------ bld/dig/h/digld.h | 10 ++++++++ bld/dig/h/trpld.h | 3 ++- bld/dig/h/trplderr.h | 46 ----------------------------------- bld/dig/h/trptypes.h | 1 - bld/mad/c/madimp.c | 4 +++- bld/trap/common/serv.c | 14 +++++------ bld/trap/common/servw.c | 14 +++++------ bld/wv/c/remmisc.c | 14 +++++------ 20 files changed, 139 insertions(+), 185 deletions(-) delete mode 100644 bld/dig/h/trplderr.h diff --git a/bld/dig/c/dos/trpld.c b/bld/dig/c/dos/trpld.c index 90e7684851..0b5352c1a4 100644 --- a/bld/dig/c/dos/trpld.c +++ b/bld/dig/c/dos/trpld.c @@ -37,7 +37,6 @@ #include #include "tinyio.h" #include "exedos.h" -#include "digld.h" #include "trpld.h" #include "roundmac.h" @@ -56,7 +55,7 @@ typedef struct { static trap_header __far *TrapCode = NULL; static trap_fini_func *FiniFunc = NULL; -static trpld_error ReadInTrap( FILE *fp ) +static digld_error ReadInTrap( FILE *fp ) { dos_exe_header hdr; unsigned image_size; @@ -72,16 +71,16 @@ static trpld_error ReadInTrap( FILE *fp ) hdr.signature = 0; if( DIGLoader( Read )( fp, &hdr, sizeof( hdr ) ) ) { - return( TC_ERR_CANT_LOAD_TRAP ); + return( DIGS_ERR_CANT_LOAD_TRAP ); } if( hdr.signature != EXESIGN_DOS ) { - return( TC_ERR_BAD_TRAP_FILE ); + return( DIGS_ERR_BAD_TRAP_FILE ); } hdr_size = hdr.hdr_size * 16; image_size = (hdr.file_size * 0x200) - (-hdr.mod_size & 0x1ff) - hdr_size; ret = TinyAllocBlock( __ROUND_UP_SIZE_TO_PARA( image_size ) ); if( TINY_ERROR( ret ) ) { - return( TC_ERR_OUT_OF_DOS_MEMORY ); + return( DIGS_ERR_OUT_OF_DOS_MEMORY ); } start_seg = TINY_INFO( ret ); TrapCode = _MK_FP( start_seg, 0 ); @@ -92,7 +91,7 @@ static trpld_error ReadInTrap( FILE *fp ) for( relocs = hdr.num_relocs; relocs != 0; --relocs ) { if( p >= &buff[ NUM_BUFF_RELOCS ] ) { if( DIGLoader( Read )( fp, buff, sizeof( buff ) ) ) { - return( TC_ERR_BAD_TRAP_FILE ); + return( DIGS_ERR_BAD_TRAP_FILE ); } p = buff; } @@ -100,7 +99,7 @@ static trpld_error ReadInTrap( FILE *fp ) *fixup += start_seg; ++p; } - return( TC_OK ); + return( DIGS_OK ); } void UnLoadTrap( void ) @@ -116,13 +115,13 @@ void UnLoadTrap( void ) } } -trpld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) +digld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) { FILE *fp; trap_init_func *init_func; char filename[256]; const char *base_name; - trpld_error err; + digld_error err; size_t len; if( parms == NULL || *parms == '\0' ) @@ -137,18 +136,18 @@ trpld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) len++; } if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, len, ".trp", filename, sizeof( filename ) ) == 0 ) { - return( TC_ERR_CANT_FIND_TRAP ); + return( DIGS_ERR_CANT_FIND_TRAP ); } fp = DIGLoader( Open )( filename ); if( fp == NULL ) { - return( TC_ERR_CANT_LOAD_TRAP ); + return( DIGS_ERR_CANT_LOAD_TRAP ); } err = ReadInTrap( fp ); DIGLoader( Close )( fp ); - if( err != TC_OK ) { + if( err != DIGS_OK ) { return( err ); } - err = TC_ERR_BAD_TRAP_FILE; + err = DIGS_ERR_BAD_TRAP_FILE; if( TrapCode->signature == TRAP_SIGNATURE ) { init_func = _MK_FP( _FP_SEG( TrapCode ), TrapCode->init_off ); FiniFunc = _MK_FP( _FP_SEG( TrapCode ), TrapCode->fini_off ); @@ -157,9 +156,9 @@ trpld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) if( buff[0] == '\0' ) { if( TrapVersionOK( *trap_ver ) ) { TrapVer = *trap_ver; - return( TC_OK ); + return( DIGS_OK ); } - err = TC_ERR_WRONG_TRAP_VERSION; + err = DIGS_ERR_WRONG_TRAP_VERSION; } } UnLoadTrap(); diff --git a/bld/dig/c/dsx/trpld.c b/bld/dig/c/dsx/trpld.c index c0c87e8f44..40831547fb 100644 --- a/bld/dig/c/dsx/trpld.c +++ b/bld/dig/c/dsx/trpld.c @@ -39,7 +39,6 @@ #include "dsxutil.h" #include "exedos.h" #include "digcli.h" -#include "digld.h" #include "trpld.h" #include "trpcore.h" #include "trpsys.h" @@ -301,7 +300,7 @@ static uint_16 EnvAreaSize( char __far *envarea ) return( envptr - envarea + 1 ); } -static trpld_error CopyEnv( void ) +static digld_error CopyEnv( void ) { char __far *envarea; uint_16 envsize; @@ -310,13 +309,13 @@ static trpld_error CopyEnv( void ) envsize = EnvAreaSize( envarea ); PMData->envseg = DPMIAllocateDOSMemoryBlock( __ROUND_UP_SIZE_TO_PARA( envsize ) ); if( PMData->envseg.pm == 0 ) { - return( TC_ERR_OUT_OF_DOS_MEMORY ); + return( DIGS_ERR_OUT_OF_DOS_MEMORY ); } _fmemcpy( EXTENDER_RM2PM( PMData->envseg.rm, 0 ), envarea, envsize ); - return( TC_OK ); + return( DIGS_OK ); } -static trpld_error SetTrapHandler( void ) +static digld_error SetTrapHandler( void ) { char dummy; long sel; @@ -344,13 +343,13 @@ static trpld_error SetTrapHandler( void ) } else { PMData->saveseg = DPMIAllocateDOSMemoryBlock( __ROUND_UP_SIZE_TO_PARA( PMData->savesize * 2 ) ); if( PMData->saveseg.pm == 0 ) { - return( TC_ERR_OUT_OF_DOS_MEMORY ); + return( DIGS_ERR_OUT_OF_DOS_MEMORY ); } } PMData->othersaved = false; sel = DPMIAllocateLDTDescriptors( 1 ); if( sel < 0 ) { - return( TC_ERR_CANT_LOAD_TRAP ); + return( DIGS_ERR_CANT_LOAD_TRAP ); } DPMIGetDescriptor( _FP_SEG( PMData ), &desc ); PMData->pmode_cs = sel; @@ -367,7 +366,7 @@ static trpld_error SetTrapHandler( void ) if( IntrState == IS_RATIONAL ) { MySetRMVector( TRAP_VECTOR, RMData.rm, RM_OFF( RMTrapHandler ) ); } - return( TC_OK ); + return( DIGS_OK ); } static bool CallTrapInit( const char *parms, char *errmsg, trap_version *trap_ver ) @@ -384,7 +383,7 @@ static bool CallTrapInit( const char *parms, char *errmsg, trap_version *trap_ve return( *errmsg == '\0' ); } -static trpld_error ReadInTrap( FILE *fp ) +static digld_error ReadInTrap( FILE *fp ) { dos_exe_header hdr; memptr relocbuff[NUM_BUFF_RELOCS]; @@ -393,33 +392,33 @@ static trpld_error ReadInTrap( FILE *fp ) unsigned hdr_size; if( DIGLoader( Read )( fp, &hdr, sizeof( hdr ) ) ) { - return( TC_ERR_CANT_LOAD_TRAP ); + return( DIGS_ERR_CANT_LOAD_TRAP ); } if( hdr.signature != EXESIGN_DOS ) { - return( TC_ERR_BAD_TRAP_FILE ); + return( DIGS_ERR_BAD_TRAP_FILE ); } hdr_size = hdr.hdr_size * 16; image_size = ( hdr.file_size * 0x200 ) - (-hdr.mod_size & 0x1ff) - hdr_size; TrapMem = DPMIAllocateDOSMemoryBlock( __ROUND_UP_SIZE_TO_PARA( image_size ) + hdr.min_16 ); if( TrapMem.pm == 0 ) { - return( TC_ERR_OUT_OF_DOS_MEMORY ); + return( DIGS_ERR_OUT_OF_DOS_MEMORY ); } DIGLoader( Seek )( fp, hdr_size, DIG_SEEK_ORG ); if( DIGLoader( Read )( fp, (void *)DPMIGetSegmentBaseAddress( TrapMem.pm ), image_size ) ) { - return( TC_ERR_CANT_LOAD_TRAP ); + return( DIGS_ERR_CANT_LOAD_TRAP ); } DIGLoader( Seek )( fp, hdr.reloc_offset, DIG_SEEK_ORG ); for( relocnb = NUM_BUFF_RELOCS; hdr.num_relocs > 0; --hdr.num_relocs, ++relocnb ) { if( relocnb >= NUM_BUFF_RELOCS ) { if( DIGLoader( Read )( fp, relocbuff, sizeof( memptr ) * NUM_BUFF_RELOCS ) ) { - return( TC_ERR_CANT_LOAD_TRAP ); + return( DIGS_ERR_CANT_LOAD_TRAP ); } relocnb = 0; } *(addr_seg __far *)EXTENDER_RM2PM( TrapMem.rm + relocbuff[relocnb].s.segment, relocbuff[relocnb].s.offset ) += TrapMem.rm; } - return( TC_OK ); + return( DIGS_OK ); } static trap_retval DoTrapAccess( trap_elen num_in_mx, in_mx_entry_p mx_in, trap_elen num_out_mx, mx_entry_p mx_out ) @@ -483,13 +482,13 @@ static trap_retval DoTrapAccess( trap_elen num_in_mx, in_mx_entry_p mx_in, trap_ return( callstruct->retlen ); } -trpld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) +digld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) { FILE *fp; trap_file_header __far *head; char filename[256]; const char *base_name; - trpld_error err; + digld_error err; size_t len; if( parms == NULL || *parms == '\0' ) @@ -504,20 +503,20 @@ trpld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) len++; } if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, len, ".trp", filename, sizeof( filename ) ) == 0 ) { - return( TC_ERR_CANT_FIND_TRAP ); + return( DIGS_ERR_CANT_FIND_TRAP ); } fp = DIGLoader( Open )( filename ); if( fp == NULL ) { - return( TC_ERR_CANT_LOAD_TRAP ); + return( DIGS_ERR_CANT_LOAD_TRAP ); } err = ReadInTrap( fp ); DIGLoader( Close )( fp ); - if( err != TC_OK ) { + if( err != DIGS_OK ) { return( err ); } - if( (err = SetTrapHandler()) == TC_OK - && (err = CopyEnv()) == TC_OK ) { - err = TC_ERR_BAD_TRAP_FILE; + if( (err = SetTrapHandler()) == DIGS_OK + && (err = CopyEnv()) == DIGS_OK ) { + err = DIGS_ERR_BAD_TRAP_FILE; head = EXTENDER_RM2PM( TrapMem.rm, 0 ); if( head->sig == TRAP_SIGNATURE ) { PMData->initfunc.s.offset = head->init; @@ -530,9 +529,9 @@ trpld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) if( TrapVersionOK( *trap_ver ) ) { TrapVer = *trap_ver; ReqFunc = DoTrapAccess; - return( TC_OK ); + return( DIGS_OK ); } - err = TC_ERR_WRONG_TRAP_VERSION; + err = DIGS_ERR_WRONG_TRAP_VERSION; } } } diff --git a/bld/dig/c/linux/peloader.c b/bld/dig/c/linux/peloader.c index 733fe89009..1e1b6ed547 100644 --- a/bld/dig/c/linux/peloader.c +++ b/bld/dig/c/linux/peloader.c @@ -43,7 +43,6 @@ #include "bool.h" #include "exedos.h" #include "dbgmod.h" -#include "digld.h" #include "roundmac.h" /*--------------------------- Global variables ----------------------------*/ diff --git a/bld/dig/c/linux/trpld_pe.c b/bld/dig/c/linux/trpld_pe.c index 0bbdcc9a34..14b7719f92 100644 --- a/bld/dig/c/linux/trpld_pe.c +++ b/bld/dig/c/linux/trpld_pe.c @@ -33,7 +33,6 @@ #include #include #include -#include "digld.h" #include "trpld.h" #include "peloader.h" @@ -75,11 +74,11 @@ void UnLoadTrap( void ) #endif } -trpld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) +digld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) { trap_load_func *ld_func; const trap_requests *trap_funcs; - trpld_error err; + digld_error err; #if !defined( BUILTIN_TRAP_FILE ) FILE *fp; char filename[_MAX_PATH]; @@ -104,23 +103,23 @@ trpld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) } #if !defined( BUILTIN_TRAP_FILE ) if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, len, ".trp", filename, sizeof( filename ) ) == 0 ) { - return( TC_ERR_CANT_FIND_TRAP ); + return( DIGS_ERR_CANT_FIND_TRAP ); } fp = DIGLoader( Open )( filename ); if( fp == NULL ) { - return( TC_ERR_CANT_LOAD_TRAP ); + return( DIGS_ERR_CANT_LOAD_TRAP ); } mod_hdl = PE_loadLibraryFile( fp, filename ); DIGLoader( Close )( fp ); if( mod_hdl == NULL ) { - return( TC_ERR_CANT_LOAD_TRAP ); + return( DIGS_ERR_CANT_LOAD_TRAP ); } ld_func = (trap_load_func *)PE_getProcAddress( mod_hdl, "TrapLoad_" ); trap_funcs = ((ld_func != NULL) ? ld_func( &TrapCallbacks ) : NULL); #else trap_funcs = TrapLoad( &TrapCallbacks ); #endif - err = TC_ERR_BAD_TRAP_FILE; + err = DIGS_ERR_BAD_TRAP_FILE; if( trap_funcs != NULL ) { *trap_ver = trap_funcs->init_func( parms, buff, trap_ver->remote ); FiniFunc = trap_funcs->fini_func; @@ -128,9 +127,9 @@ trpld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) if( buff[0] == '\0' ) { if( TrapVersionOK( *trap_ver ) ) { TrapVer = *trap_ver; - return( TC_OK ); + return( DIGS_OK ); } - err = TC_ERR_WRONG_TRAP_VERSION; + err = DIGS_ERR_WRONG_TRAP_VERSION; } } UnLoadTrap(); diff --git a/bld/dig/c/linux/trpld_rx.c b/bld/dig/c/linux/trpld_rx.c index bbb1712144..2cce69cff7 100644 --- a/bld/dig/c/linux/trpld_rx.c +++ b/bld/dig/c/linux/trpld_rx.c @@ -36,7 +36,6 @@ #include #include #include "digcli.h" -#include "digld.h" #include "trpld.h" #include "trpimp.h" #include "ldimp.h" @@ -73,7 +72,7 @@ void UnLoadTrap( void ) } } -trpld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) +digld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) { FILE *fp; trap_load_func *ld_func; @@ -81,7 +80,7 @@ trpld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) char filename[256]; const char *base_name; size_t len; - trpld_error err; + digld_error err; if( parms == NULL || *parms == '\0' ) parms = DEFAULT_TRP_NAME; @@ -95,18 +94,18 @@ trpld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) len++; } if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, len, ".trp", filename, sizeof( filename ) ) == 0 ) { - return( TC_ERR_CANT_FIND_TRAP ); + return( DIGS_ERR_CANT_FIND_TRAP ); } fp = DIGLoader( Open )( filename ); if( fp == NULL ) { - return( TC_ERR_CANT_LOAD_TRAP ); + return( DIGS_ERR_CANT_LOAD_TRAP ); } TrapCode = ReadInImp( fp ); DIGLoader( Close )( fp ); if( TrapCode == NULL ) { - return( TC_ERR_CANT_LOAD_TRAP ); + return( DIGS_ERR_CANT_LOAD_TRAP ); } - err = TC_ERR_BAD_TRAP_FILE; + err = DIGS_ERR_BAD_TRAP_FILE; #ifdef __WATCOMC__ ld_func = (trap_load_func *)((TrapCode->sig == TRAPSIG) ? TrapCode->init_rtn : NULL); #else @@ -120,9 +119,9 @@ trpld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) if( buff[0] == '\0' ) { if( TrapVersionOK( *trap_ver ) ) { TrapVer = *trap_ver; - return( TC_OK ); + return( DIGS_OK ); } - err = TC_ERR_WRONG_TRAP_VERSION; + err = DIGS_ERR_WRONG_TRAP_VERSION; } } UnLoadTrap(); diff --git a/bld/dig/c/linux/trpld_so.c b/bld/dig/c/linux/trpld_so.c index 317c310a0d..649c7f8691 100644 --- a/bld/dig/c/linux/trpld_so.c +++ b/bld/dig/c/linux/trpld_so.c @@ -34,7 +34,6 @@ #include #include #include -#include "digld.h" #include "trpld.h" #include "clibext.h" @@ -77,12 +76,12 @@ void UnLoadTrap( void ) #endif } -trpld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) +digld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) { FILE *fp; trap_load_func *ld_func; const trap_requests *trap_funcs; - trpld_error err; + digld_error err; #if !defined( BUILTIN_TRAP_FILE ) char filename[_MAX_PATH]; const char *base_name; @@ -106,24 +105,24 @@ trpld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) } #if !defined( BUILTIN_TRAP_FILE ) if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, len, ".so", filename, sizeof( filename ) ) == 0 ) { - return( TC_ERR_CANT_FIND_TRAP ); + return( DIGS_ERR_CANT_FIND_TRAP ); } fp = DIGLoader( Open )( filename ); if( fp == NULL ) { - return( TC_ERR_CANT_LOAD_TRAP ); + return( DIGS_ERR_CANT_LOAD_TRAP ); } mod_hdl = dlopen( filename, RTLD_NOW ); DIGLoader( Close )( fp ); if( mod_hdl == NULL ) { puts( dlerror() ); - return( TC_ERR_CANT_LOAD_TRAP ); + return( DIGS_ERR_CANT_LOAD_TRAP ); } ld_func = (trap_load_func *)dlsym( mod_hdl, "TrapLoad" ); trap_funcs = ((ld_func != NULL) ? ld_func( &TrapCallbacks ) : NULL); #else trap_funcs = TrapLoad( &TrapCallbacks ); #endif - err = TC_ERR_BAD_TRAP_FILE; + err = DIGS_ERR_BAD_TRAP_FILE; if( trap_funcs != NULL ) { *trap_ver = trap_funcs->init_func( parms, buff, trap_ver->remote ); FiniFunc = trap_funcs->fini_func; @@ -131,9 +130,9 @@ trpld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) if( buff[0] == '\0' ) { if( TrapVersionOK( *trap_ver ) ) { TrapVer = *trap_ver; - return( TC_OK ); + return( DIGS_OK ); } - err = TC_ERR_WRONG_TRAP_VERSION; + err = DIGS_ERR_WRONG_TRAP_VERSION; } } UnLoadTrap(); diff --git a/bld/dig/c/nov/trpld.c b/bld/dig/c/nov/trpld.c index c545bf3ee3..3e33b59ddb 100644 --- a/bld/dig/c/nov/trpld.c +++ b/bld/dig/c/nov/trpld.c @@ -32,7 +32,6 @@ #include -#include "digld.h" #include "trpld.h" #include "trpcomm.h" @@ -42,11 +41,11 @@ void UnLoadTrap( void ) TrapFini(); } -trpld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) +digld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) { const char *trpname; size_t len; - trpld_error err; + digld_error err; if( parms == NULL || *parms == '\0' ) parms = DEFAULT_TRP_NAME; @@ -59,15 +58,15 @@ trpld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) } len++; } - err = TC_ERR_BAD_TRAP_FILE; + err = DIGS_ERR_BAD_TRAP_FILE; *trap_ver = TrapInit( parms, buff, trap_ver->remote ); if( buff[0] == '\0' ) { if( TrapVersionOK( *trap_ver ) ) { TrapVer = *trap_ver; ReqFunc = TrapRequest; - return( TC_OK ); + return( DIGS_OK ); } - err = TC_ERR_WRONG_TRAP_VERSION; + err = DIGS_ERR_WRONG_TRAP_VERSION; } UnLoadTrap(); return( err ); diff --git a/bld/dig/c/nt/trpld.c b/bld/dig/c/nt/trpld.c index e81f827ff9..9701907e88 100644 --- a/bld/dig/c/nt/trpld.c +++ b/bld/dig/c/nt/trpld.c @@ -35,7 +35,6 @@ #include #include #include -#include "digld.h" #include "trpld.h" #include "trpsys.h" @@ -94,13 +93,13 @@ void UnLoadTrap( void ) } } -trpld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) +digld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) { char filename[256]; const char *base_name; size_t len; trap_init_func *init_func; - trpld_error err; + digld_error err; if( parms == NULL || *parms == '\0' ) parms = DEFAULT_TRP_NAME; @@ -114,13 +113,13 @@ trpld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) len++; } if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, len, ".dll", filename, sizeof( filename ) ) == 0 ) { - return( TC_ERR_CANT_FIND_TRAP ); + return( DIGS_ERR_CANT_FIND_TRAP ); } mod_hdl = LoadLibrary( filename ); if( mod_hdl == NULL ) { - return( TC_ERR_CANT_LOAD_TRAP ); + return( DIGS_ERR_CANT_LOAD_TRAP ); } - err = TC_ERR_BAD_TRAP_FILE; + err = DIGS_ERR_BAD_TRAP_FILE; init_func = (trap_init_func *)GetProcAddress( mod_hdl, (LPSTR)1 ); FiniFunc = (trap_fini_func *)GetProcAddress( mod_hdl, (LPSTR)2 ); ReqFunc = (trap_req_func *)GetProcAddress( mod_hdl, (LPSTR)3 ); @@ -134,9 +133,9 @@ trpld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) if( buff[0] == '\0' ) { if( TrapVersionOK( *trap_ver ) ) { TrapVer = *trap_ver; - return( TC_OK ); + return( DIGS_OK ); } - err = TC_ERR_WRONG_TRAP_VERSION; + err = DIGS_ERR_WRONG_TRAP_VERSION; } } UnLoadTrap(); diff --git a/bld/dig/c/os2/trpld.c b/bld/dig/c/os2/trpld.c index 445da41b39..13c2b0a8d1 100644 --- a/bld/dig/c/os2/trpld.c +++ b/bld/dig/c/os2/trpld.c @@ -36,7 +36,6 @@ #define INCL_DOSMODULEMGR #define INCL_DOSMISC #include -#include "digld.h" #include "trpld.h" #include "trpsys.h" @@ -100,13 +99,13 @@ void UnLoadTrap( void ) } } -trpld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) +digld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) { const char *base_name; size_t len; trap_init_func *init_func; char filename[CCHMAXPATH]; - trpld_error err; + digld_error err; if( parms == NULL || *parms == '\0' ) parms = DEFAULT_TRP_NAME; @@ -142,12 +141,12 @@ trpld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) #else if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, len, ".D32", filename, sizeof( filename ) ) == 0 ) { #endif - return( TC_ERR_CANT_FIND_TRAP ); + return( DIGS_ERR_CANT_FIND_TRAP ); } if( LOAD_MODULE( filename, mod_hdl ) ) { - return( TC_ERR_CANT_LOAD_TRAP ); + return( DIGS_ERR_CANT_LOAD_TRAP ); } - err = TC_ERR_BAD_TRAP_FILE; + err = DIGS_ERR_BAD_TRAP_FILE; if( GET_PROC_ADDRESS( mod_hdl, 1, init_func ) && GET_PROC_ADDRESS( mod_hdl, 2, FiniFunc ) && GET_PROC_ADDRESS( mod_hdl, 3, ReqFunc ) ) { @@ -161,9 +160,9 @@ trpld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) if( buff[0] == '\0' ) { if( TrapVersionOK( *trap_ver ) ) { TrapVer = *trap_ver; - return( TC_OK ); + return( DIGS_OK ); } - err = TC_ERR_WRONG_TRAP_VERSION; + err = DIGS_ERR_WRONG_TRAP_VERSION; } } UnLoadTrap(); diff --git a/bld/dig/c/qnx/trpld.c b/bld/dig/c/qnx/trpld.c index da6f78ba6d..67c8f738f5 100644 --- a/bld/dig/c/qnx/trpld.c +++ b/bld/dig/c/qnx/trpld.c @@ -36,7 +36,6 @@ #include #include #include "digcli.h" -#include "digld.h" #include "trpld.h" #include "trpimp.h" #include "ldimp.h" @@ -75,7 +74,7 @@ void UnLoadTrap( void ) } } -trpld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) +digld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) { FILE *fp; trap_load_func *ld_func; @@ -83,7 +82,7 @@ trpld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) char filename[256]; const char *base_name; size_t len; - trpld_error err; + digld_error err; if( parms == NULL || *parms == '\0' ) parms = DEFAULT_TRP_NAME; @@ -97,18 +96,18 @@ trpld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) len++; } if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, len, ".trp", filename, sizeof( filename ) ) == 0 ) { - return( TC_ERR_CANT_FIND_TRAP ); + return( DIGS_ERR_CANT_FIND_TRAP ); } fp = DIGLoader( Open )( filename ); if( fp == NULL ) { - return( TC_ERR_CANT_LOAD_TRAP ); + return( DIGS_ERR_CANT_LOAD_TRAP ); } TrapCode = ReadInImp( fp ); DIGLoader( Close )( fp ); if( TrapCode == NULL ) { - return( TC_ERR_CANT_LOAD_TRAP ); + return( DIGS_ERR_CANT_LOAD_TRAP ); } - err = TC_ERR_BAD_TRAP_FILE; + err = DIGS_ERR_BAD_TRAP_FILE; #ifdef __WATCOMC__ ld_func = (trap_load_func *)((TrapCode->sig == TRAPSIG) ? TrapCode->init_rtn : NULL); #else @@ -122,9 +121,9 @@ trpld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) if( buff[0] == '\0' ) { if( TrapVersionOK( *trap_ver ) ) { TrapVer = *trap_ver; - return( TC_OK ); + return( DIGS_OK ); } - err = TC_ERR_WRONG_TRAP_VERSION; + err = DIGS_ERR_WRONG_TRAP_VERSION; } } UnLoadTrap(); diff --git a/bld/dig/c/rdos/trpld.c b/bld/dig/c/rdos/trpld.c index b3a6ddeafe..b1bac7995c 100644 --- a/bld/dig/c/rdos/trpld.c +++ b/bld/dig/c/rdos/trpld.c @@ -34,7 +34,6 @@ #include #include #include -#include "digld.h" #include "trpld.h" @@ -54,13 +53,13 @@ void UnLoadTrap( void ) } } -trpld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) +digld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) { char filename[256]; const char *base_name; size_t len; trap_init_func *init_func; - trpld_error err; + digld_error err; if( parms == NULL || *parms == '\0' ) parms = DEFAULT_TRP_NAME; @@ -74,13 +73,13 @@ trpld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) len++; } if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, len, ".dll", filename, sizeof( filename ) ) == 0 ) { - return( TC_ERR_CANT_FIND_TRAP ); + return( DIGS_ERR_CANT_FIND_TRAP ); } mod_hdl = RdosLoadDll( filename ); if( mod_hdl == NULL ) { - return( TC_ERR_CANT_LOAD_TRAP ); + return( DIGS_ERR_CANT_LOAD_TRAP ); } - err = TC_ERR_BAD_TRAP_FILE; + err = DIGS_ERR_BAD_TRAP_FILE; init_func = RdosGetModuleProc( mod_hdl, "TrapInit_" ); FiniFunc = RdosGetModuleProc( mod_hdl, "TrapFini_" ); ReqFunc = RdosGetModuleProc( mod_hdl, "TrapRequest_" ); @@ -93,9 +92,9 @@ trpld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) if( buff[0] == '\0' ) { if( TrapVersionOK( *trap_ver ) ) { TrapVer = *trap_ver; - return( TC_OK ); + return( DIGS_OK ); } - err = TC_ERR_WRONG_TRAP_VERSION; + err = DIGS_ERR_WRONG_TRAP_VERSION; } } UnLoadTrap(); diff --git a/bld/dig/c/win/trpld.c b/bld/dig/c/win/trpld.c index 9da8a806fe..99c4547cd7 100644 --- a/bld/dig/c/win/trpld.c +++ b/bld/dig/c/win/trpld.c @@ -36,7 +36,6 @@ #include #include #include -#include "digld.h" #include "trpld.h" #include "trpsys.h" @@ -78,14 +77,14 @@ void UnLoadTrap( void ) } } -trpld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) +digld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) { char filename[256]; const char *base_name; size_t len; UINT prev; trap_init_func *init_func; - trpld_error err; + digld_error err; if( parms == NULL || *parms == '\0' ) parms = DEFAULT_TRP_NAME; @@ -107,16 +106,16 @@ trpld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) toolhelp = 0; } if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, len, ".dll", filename, sizeof( filename ) ) == 0 ) { - return( TC_ERR_CANT_FIND_TRAP ); + return( DIGS_ERR_CANT_FIND_TRAP ); } prev = SetErrorMode( SEM_NOOPENFILEERRORBOX ); mod_hdl = LoadLibrary( filename ); SetErrorMode( prev ); if( (UINT)mod_hdl < 32 ) { mod_hdl = 0; - return( TC_ERR_CANT_LOAD_TRAP ); + return( DIGS_ERR_CANT_LOAD_TRAP ); } - err = TC_ERR_BAD_TRAP_FILE; + err = DIGS_ERR_BAD_TRAP_FILE; init_func = (trap_init_func *)GetProcAddress( mod_hdl, (LPSTR)2 ); FiniFunc = (trap_fini_func *)GetProcAddress( mod_hdl, (LPSTR)3 ); ReqFunc = (trap_req_func *)GetProcAddress( mod_hdl, (LPSTR)4 ); @@ -133,9 +132,9 @@ trpld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) if( buff[0] == '\0' ) { if( TrapVersionOK( *trap_ver ) ) { TrapVer = *trap_ver; - return( TC_OK ); + return( DIGS_OK ); } - err = TC_ERR_WRONG_TRAP_VERSION; + err = DIGS_ERR_WRONG_TRAP_VERSION; } } UnLoadTrap(); diff --git a/bld/dig/h/digld.h b/bld/dig/h/digld.h index 40f0246ca8..fa847f648e 100644 --- a/bld/dig/h/digld.h +++ b/bld/dig/h/digld.h @@ -36,6 +36,16 @@ #define DIGLoader(n) DIGLoader ## n +typedef enum { + DIGS_OK, + DIGS_ERR, + DIGS_ERR_CANT_FIND_TRAP, + DIGS_ERR_CANT_LOAD_TRAP, + DIGS_ERR_WRONG_TRAP_VERSION, + DIGS_ERR_BAD_TRAP_FILE, + DIGS_ERR_OUT_OF_DOS_MEMORY, +} digld_error; + extern size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base_name_len, const char *defext, char *filename, size_t filename_maxlen ); extern FILE *DIGLoader( Open )( const char *filename ); extern int DIGLoader( Close )( FILE *fp ); diff --git a/bld/dig/h/trpld.h b/bld/dig/h/trpld.h index 7c481c6101..76086b7fd4 100644 --- a/bld/dig/h/trpld.h +++ b/bld/dig/h/trpld.h @@ -30,6 +30,7 @@ ****************************************************************************/ +#include "digld.h" #include "trptypes.h" @@ -50,7 +51,7 @@ extern int CloseTrapTraceFile( void ); /* Client interface routines */ extern char *LoadDumbTrap( trap_version * ); -extern trpld_error LoadTrap( const char *, char *, trap_version * ); +extern digld_error LoadTrap( const char *, char *, trap_version * ); extern void UnLoadTrap( void ); extern void TrapSetFailCallBack( void (*func)(void) ); extern unsigned TrapAccess( trap_elen, in_mx_entry_p, trap_elen, mx_entry_p ); diff --git a/bld/dig/h/trplderr.h b/bld/dig/h/trplderr.h deleted file mode 100644 index 838f17fdfc..0000000000 --- a/bld/dig/h/trplderr.h +++ /dev/null @@ -1,46 +0,0 @@ -/**************************************************************************** -* -* Open Watcom Project -* -* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. -* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. -* -* ======================================================================== -* -* This file contains Original Code and/or Modifications of Original -* Code as defined in and that are subject to the Sybase Open Watcom -* Public License version 1.0 (the 'License'). You may not use this file -* except in compliance with the License. BY USING THIS FILE YOU AGREE TO -* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is -* provided with the Original Code and Modifications, and is also -* available at www.sybase.com/developer/opensource. -* -* The Original Code and all software distributed under the License are -* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER -* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM -* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF -* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR -* NON-INFRINGEMENT. Please see the License for the specific language -* governing rights and limitations under the License. -* -* ======================================================================== -* -* Description: TRAP file loader errors enumeration -* -****************************************************************************/ - - -#ifndef _TRPLDERR_H_INCLUDED -#define _TRPLDERR_H_INCLUDED - -typedef enum { - TC_OK, - TC_ERR, - TC_ERR_CANT_FIND_TRAP, - TC_ERR_CANT_LOAD_TRAP, - TC_ERR_WRONG_TRAP_VERSION, - TC_ERR_BAD_TRAP_FILE, - TC_ERR_OUT_OF_DOS_MEMORY, -} trpld_error; - -#endif diff --git a/bld/dig/h/trptypes.h b/bld/dig/h/trptypes.h index e172d44f33..4679cf2267 100644 --- a/bld/dig/h/trptypes.h +++ b/bld/dig/h/trptypes.h @@ -37,7 +37,6 @@ #if defined( __WINDOWS__ ) #include "setevent.h" #endif -#include "trplderr.h" #if defined( __WINDOWS__ ) #define TRAPENTRY __far __pascal diff --git a/bld/mad/c/madimp.c b/bld/mad/c/madimp.c index 3af0d49b49..43dd46a23a 100644 --- a/bld/mad/c/madimp.c +++ b/bld/mad/c/madimp.c @@ -129,7 +129,9 @@ mad_imp_routines MadImpInterface = { #define FIRST_IMP_FUNC Init #if defined( __WATCOMC__ ) && defined( __386__ ) -/* WD looks for this symbol to determine module bitness */ +/* + * WD looks for this symbol to determine module bitness + */ int __nullarea; #pragma aux __nullarea "*"; #endif diff --git a/bld/trap/common/serv.c b/bld/trap/common/serv.c index d763d92355..7e7562becf 100644 --- a/bld/trap/common/serv.c +++ b/bld/trap/common/serv.c @@ -76,24 +76,24 @@ static const char *ServInitialize( void ) err = RemoteLink( RWBuff, true ); if( err == NULL ) { switch( LoadTrap( trapparms, RWBuff, &TrapVersion ) ) { - case TC_OK: + case DIGS_OK: break; - case TC_ERR_CANT_FIND_TRAP: + case DIGS_ERR_CANT_FIND_TRAP: err = TRP_ERR_CANT_FIND_TRAP; break; - case TC_ERR_CANT_LOAD_TRAP: + case DIGS_ERR_CANT_LOAD_TRAP: err = TRP_ERR_CANT_LOAD_TRAP; break; - case TC_ERR_WRONG_TRAP_VERSION: + case DIGS_ERR_WRONG_TRAP_VERSION: err = TRP_ERR_WRONG_TRAP_VERSION; break; - case TC_ERR_BAD_TRAP_FILE: + case DIGS_ERR_BAD_TRAP_FILE: err = TRP_ERR_BAD_TRAP_FILE; break; - case TC_ERR_OUT_OF_DOS_MEMORY: + case DIGS_ERR_OUT_OF_DOS_MEMORY: err = TRP_ERR_OUT_OF_DOS_MEMORY; break; - case TC_ERR: + case DIGS_ERR: default: err = TRP_ERR_unknown_system_error; break; diff --git a/bld/trap/common/servw.c b/bld/trap/common/servw.c index 9bfbbd5af2..11872781fe 100644 --- a/bld/trap/common/servw.c +++ b/bld/trap/common/servw.c @@ -82,24 +82,24 @@ int PASCAL WinMain( HINSTANCE this_inst, HINSTANCE prev_inst, LPSTR cmdline, int err = RemoteLinkSet( RWBuff ); if( err == NULL ) { switch( LoadTrap( trapparms, RWBuff, &TrapVersion ) ) { - case TC_OK: + case DIGS_OK: break; - case TC_ERR_CANT_FIND_TRAP: + case DIGS_ERR_CANT_FIND_TRAP: err = TRP_ERR_CANT_FIND_TRAP; break; - case TC_ERR_CANT_LOAD_TRAP: + case DIGS_ERR_CANT_LOAD_TRAP: err = TRP_ERR_CANT_LOAD_TRAP; break; - case TC_ERR_WRONG_TRAP_VERSION: + case DIGS_ERR_WRONG_TRAP_VERSION: err = TRP_ERR_WRONG_TRAP_VERSION; break; - case TC_ERR_BAD_TRAP_FILE: + case DIGS_ERR_BAD_TRAP_FILE: err = TRP_ERR_BAD_TRAP_FILE; break; - case TC_ERR_OUT_OF_DOS_MEMORY: + case DIGS_ERR_OUT_OF_DOS_MEMORY: err = TRP_ERR_OUT_OF_DOS_MEMORY; break; - case TC_ERR: + case DIGS_ERR: default: err = TRP_ERR_unknown_system_error; break; diff --git a/bld/wv/c/remmisc.c b/bld/wv/c/remmisc.c index 2aa8f58408..0db0e3f922 100644 --- a/bld/wv/c/remmisc.c +++ b/bld/wv/c/remmisc.c @@ -126,24 +126,24 @@ void InitTrap( const char *parms ) } else { #endif switch( LoadTrap( parms, buff, &ver ) ) { - case TC_OK: + case DIGS_OK: break; - case TC_ERR_CANT_FIND_TRAP: + case DIGS_ERR_CANT_FIND_TRAP: error = TRP_ERR_CANT_FIND_TRAP; break; - case TC_ERR_CANT_LOAD_TRAP: + case DIGS_ERR_CANT_LOAD_TRAP: error = TRP_ERR_CANT_LOAD_TRAP; break; - case TC_ERR_WRONG_TRAP_VERSION: + case DIGS_ERR_WRONG_TRAP_VERSION: error = TRP_ERR_WRONG_TRAP_VERSION; break; - case TC_ERR_BAD_TRAP_FILE: + case DIGS_ERR_BAD_TRAP_FILE: error = TRP_ERR_BAD_TRAP_FILE; break; - case TC_ERR_OUT_OF_DOS_MEMORY: + case DIGS_ERR_OUT_OF_DOS_MEMORY: error = TRP_ERR_OUT_OF_DOS_MEMORY; break; - case TC_ERR: + case DIGS_ERR: default: error = TRP_ERR_unknown_system_error; break; From 8a94157478a472aac9ce20efe63d001fc9446803 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Wed, 13 Sep 2023 14:41:03 +0200 Subject: [PATCH 126/258] move DIP/MAD/TRAP loader errors messages to global dig header file --- bld/dig/h/digld.h | 22 +++++++++++++++------- bld/trap/common/serv.c | 25 ++++--------------------- bld/trap/common/servw.c | 25 ++++--------------------- bld/wv/c/remmisc.c | 25 ++++--------------------- bld/wv/master.mif | 16 ++++------------ 5 files changed, 31 insertions(+), 82 deletions(-) diff --git a/bld/dig/h/digld.h b/bld/dig/h/digld.h index fa847f648e..c89a9d5e0e 100644 --- a/bld/dig/h/digld.h +++ b/bld/dig/h/digld.h @@ -36,14 +36,22 @@ #define DIGLoader(n) DIGLoader ## n +#define DIGS_ERRORS \ + DIGS_ERROR( DIGS_OK, NULL ) \ + DIGS_ERROR( DIGS_ERR, "Unknown system error" ) \ + DIGS_ERROR( DIGS_ERR_CANT_FIND_MODULE, "Unable to find module file" ) \ + DIGS_ERROR( DIGS_ERR_CANT_LOAD_MODULE, "Unable to load module file" ) \ + DIGS_ERROR( DIGS_ERR_WRONG_MODULE_VERSION, "Incorrect version of module file" ) \ + DIGS_ERROR( DIGS_ERR_BAD_MODULE_FILE, "Invalid module file" ) \ + DIGS_ERROR( DIGS_ERR_OUT_OF_DOS_MEMORY, "Out of DOS memory" ) \ + DIGS_ERROR( DIGS_ERR_OUT_OF_MEMORY, "Out of memory" ) + +#define DIGS_ERRORS_default "Unknown system error" + typedef enum { - DIGS_OK, - DIGS_ERR, - DIGS_ERR_CANT_FIND_TRAP, - DIGS_ERR_CANT_LOAD_TRAP, - DIGS_ERR_WRONG_TRAP_VERSION, - DIGS_ERR_BAD_TRAP_FILE, - DIGS_ERR_OUT_OF_DOS_MEMORY, + #define DIGS_ERROR(e,t) e, + DIGS_ERRORS + #undef DIGS_ERROR } digld_error; extern size_t DIGLoader( Find )( dig_filetype ftype, const char *base_name, size_t base_name_len, const char *defext, char *filename, size_t filename_maxlen ); diff --git a/bld/trap/common/serv.c b/bld/trap/common/serv.c index 7e7562becf..9345005461 100644 --- a/bld/trap/common/serv.c +++ b/bld/trap/common/serv.c @@ -76,27 +76,10 @@ static const char *ServInitialize( void ) err = RemoteLink( RWBuff, true ); if( err == NULL ) { switch( LoadTrap( trapparms, RWBuff, &TrapVersion ) ) { - case DIGS_OK: - break; - case DIGS_ERR_CANT_FIND_TRAP: - err = TRP_ERR_CANT_FIND_TRAP; - break; - case DIGS_ERR_CANT_LOAD_TRAP: - err = TRP_ERR_CANT_LOAD_TRAP; - break; - case DIGS_ERR_WRONG_TRAP_VERSION: - err = TRP_ERR_WRONG_TRAP_VERSION; - break; - case DIGS_ERR_BAD_TRAP_FILE: - err = TRP_ERR_BAD_TRAP_FILE; - break; - case DIGS_ERR_OUT_OF_DOS_MEMORY: - err = TRP_ERR_OUT_OF_DOS_MEMORY; - break; - case DIGS_ERR: - default: - err = TRP_ERR_unknown_system_error; - break; + #define DIGS_ERROR(e,t) case e: err = t; break; + DIGS_ERRORS + #undef DIGS_ERROR + default: err = DIGS_ERRORS_default; break } } } diff --git a/bld/trap/common/servw.c b/bld/trap/common/servw.c index 11872781fe..241b49ae3c 100644 --- a/bld/trap/common/servw.c +++ b/bld/trap/common/servw.c @@ -82,27 +82,10 @@ int PASCAL WinMain( HINSTANCE this_inst, HINSTANCE prev_inst, LPSTR cmdline, int err = RemoteLinkSet( RWBuff ); if( err == NULL ) { switch( LoadTrap( trapparms, RWBuff, &TrapVersion ) ) { - case DIGS_OK: - break; - case DIGS_ERR_CANT_FIND_TRAP: - err = TRP_ERR_CANT_FIND_TRAP; - break; - case DIGS_ERR_CANT_LOAD_TRAP: - err = TRP_ERR_CANT_LOAD_TRAP; - break; - case DIGS_ERR_WRONG_TRAP_VERSION: - err = TRP_ERR_WRONG_TRAP_VERSION; - break; - case DIGS_ERR_BAD_TRAP_FILE: - err = TRP_ERR_BAD_TRAP_FILE; - break; - case DIGS_ERR_OUT_OF_DOS_MEMORY: - err = TRP_ERR_OUT_OF_DOS_MEMORY; - break; - case DIGS_ERR: - default: - err = TRP_ERR_unknown_system_error; - break; + #define DIGS_ERROR(e,t) case e: err = t; break; + DIGS_ERRORS + #undef DIGS_ERROR + default: err = DIGS_ERRORS_default; break } } } diff --git a/bld/wv/c/remmisc.c b/bld/wv/c/remmisc.c index 0db0e3f922..74a14a006a 100644 --- a/bld/wv/c/remmisc.c +++ b/bld/wv/c/remmisc.c @@ -126,27 +126,10 @@ void InitTrap( const char *parms ) } else { #endif switch( LoadTrap( parms, buff, &ver ) ) { - case DIGS_OK: - break; - case DIGS_ERR_CANT_FIND_TRAP: - error = TRP_ERR_CANT_FIND_TRAP; - break; - case DIGS_ERR_CANT_LOAD_TRAP: - error = TRP_ERR_CANT_LOAD_TRAP; - break; - case DIGS_ERR_WRONG_TRAP_VERSION: - error = TRP_ERR_WRONG_TRAP_VERSION; - break; - case DIGS_ERR_BAD_TRAP_FILE: - error = TRP_ERR_BAD_TRAP_FILE; - break; - case DIGS_ERR_OUT_OF_DOS_MEMORY: - error = TRP_ERR_OUT_OF_DOS_MEMORY; - break; - case DIGS_ERR: - default: - error = TRP_ERR_unknown_system_error; - break; + #define DIGS_ERROR(e,t) case e: error = t; break; + DIGS_ERRORS + #undef DIGS_ERROR + default: error = DIGS_ERRORS_default; break } #if !defined( BUILD_RFX ) } diff --git a/bld/wv/master.mif b/bld/wv/master.mif index eec3212c5d..b0f22ef031 100644 --- a/bld/wv/master.mif +++ b/bld/wv/master.mif @@ -73,7 +73,7 @@ wv_res_inc_dirs = -I"../../res/dlgs" -I"$(res_strings_dir)" -I"../../res" inc_dirs = -I. -Ih -I"../h" -I"../../h" $(wv_res_inc_dirs) -I"$(dig_dir)/h" & $(aui_inc_dirs) $(gui_inc_dirs) $(ui_inc_dirs) $(ui_extra_inc_dirs) & - $(hlpview_inc_dirs) $(wpi_inc_dirs) $(commonui_inc_dirs) -I"$(trap_dir)/h" + $(hlpview_inc_dirs) $(wpi_inc_dirs) $(commonui_inc_dirs) !ifeq sys_rtdll 1 !else !ifeq sys_windowed 1 @@ -144,14 +144,14 @@ extra_l_flags_rdos = # EXE # !ifdef wv_engine_noui -exetarg_prebuild_objs = litdef.gh _err.gh _jerr.gh +exetarg_prebuild_objs = litdef.gh exetarg_objs = $(wv_drv_objs) exetarg_libs = wd.lib exetarg_res = wvuidll.res exetarg_name = $(wv_engine_noui) !include exetarg.mif !else -exetarg_prebuild_objs = litdef.gh usage.gh _err.gh _jerr.gh +exetarg_prebuild_objs = litdef.gh usage.gh exetarg_objs = $(engine_objs) fingmsg.obj $(ui_objs) exetarg_libs = $(aui_lib) $(gui_lib) $(ui_lib) $(wres_lib) exetarg_res_version_nt_386 = exever.res @@ -172,7 +172,7 @@ exetarg_ext = .exe # # LIB # -libtarg_prebuild_objs = litdef.gh usage.gh _err.gh _jerr.gh +libtarg_prebuild_objs = litdef.gh usage.gh libtarg_objs = $(engine_objs) libtarg_name = wd !include libtarg.mif @@ -460,14 +460,6 @@ litdef.gh : litdefs1.tmp litdefs2.tmp litdefm.tmp $(__MAKEFILES__) $(awk) -v prefix=DBG_DUI_LITERAL_ -v base=DBG_DUI_BASE -f $(build_dir)/makemsg2.awk -v OUTFILE=$^. litdefs2.tmp $(awk) -v prefix=DBG_DUI_MENU_ -v base=DBG_MENU_BASE -f $(build_dir)/makemsg2.awk -v OUTFILE=$^. litdefm.tmp -_err.gh : $(trap_dir)/h/trapmsg.h $(trap_dir)/h/trap.msg $(__MAKEFILES__) - @%make echo_cpp - $(cpp) $(rc_ui8_flags) -I"$(trap_dir)/h" $(rc_ui_inc_path) $[@ -o$@ - -_jerr.gh : $(trap_dir)/h/trapmsg.h $(trap_dir)/h/trap.msg $(__MAKEFILES__) - @%make echo_cpp - $(cpp) $(rc_ui8_flags) -DJAPANESE -I"$(trap_dir)/h" $(rc_ui_inc_path) $[@ -o$@ - !ifeq release 0 wsplice_keys = -kHIDDEN !endif From aeaff6189ff79c513728929c4e82ca085b12d473 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Wed, 13 Sep 2023 16:12:06 +0200 Subject: [PATCH 127/258] fix build break --- bld/dig/c/dos/trpld.c | 14 +++++++------- bld/dig/c/dsx/trpld.c | 18 +++++++++--------- bld/dig/c/linux/trpld_pe.c | 10 +++++----- bld/dig/c/linux/trpld_rx.c | 10 +++++----- bld/dig/c/linux/trpld_so.c | 10 +++++----- bld/dig/c/nov/trpld.c | 4 ++-- bld/dig/c/nt/trpld.c | 8 ++++---- bld/dig/c/os2/trpld.c | 8 ++++---- bld/dig/c/qnx/trpld.c | 10 +++++----- bld/dig/c/rdos/trpld.c | 8 ++++---- bld/dig/c/win/trpld.c | 8 ++++---- bld/dig/h/digld.h | 22 +++++++++++----------- bld/trap/common/serv.c | 4 ++-- bld/trap/common/servw.c | 4 ++-- bld/wv/c/remmisc.c | 7 +++---- 15 files changed, 72 insertions(+), 73 deletions(-) diff --git a/bld/dig/c/dos/trpld.c b/bld/dig/c/dos/trpld.c index 0b5352c1a4..f963b51b36 100644 --- a/bld/dig/c/dos/trpld.c +++ b/bld/dig/c/dos/trpld.c @@ -71,10 +71,10 @@ static digld_error ReadInTrap( FILE *fp ) hdr.signature = 0; if( DIGLoader( Read )( fp, &hdr, sizeof( hdr ) ) ) { - return( DIGS_ERR_CANT_LOAD_TRAP ); + return( DIGS_ERR_CANT_LOAD_MODULE ); } if( hdr.signature != EXESIGN_DOS ) { - return( DIGS_ERR_BAD_TRAP_FILE ); + return( DIGS_ERR_BAD_MODULE_FILE ); } hdr_size = hdr.hdr_size * 16; image_size = (hdr.file_size * 0x200) - (-hdr.mod_size & 0x1ff) - hdr_size; @@ -91,7 +91,7 @@ static digld_error ReadInTrap( FILE *fp ) for( relocs = hdr.num_relocs; relocs != 0; --relocs ) { if( p >= &buff[ NUM_BUFF_RELOCS ] ) { if( DIGLoader( Read )( fp, buff, sizeof( buff ) ) ) { - return( DIGS_ERR_BAD_TRAP_FILE ); + return( DIGS_ERR_BAD_MODULE_FILE ); } p = buff; } @@ -136,18 +136,18 @@ digld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) len++; } if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, len, ".trp", filename, sizeof( filename ) ) == 0 ) { - return( DIGS_ERR_CANT_FIND_TRAP ); + return( DIGS_ERR_CANT_FIND_MODULE ); } fp = DIGLoader( Open )( filename ); if( fp == NULL ) { - return( DIGS_ERR_CANT_LOAD_TRAP ); + return( DIGS_ERR_CANT_LOAD_MODULE ); } err = ReadInTrap( fp ); DIGLoader( Close )( fp ); if( err != DIGS_OK ) { return( err ); } - err = DIGS_ERR_BAD_TRAP_FILE; + err = DIGS_ERR_BAD_MODULE_FILE; if( TrapCode->signature == TRAP_SIGNATURE ) { init_func = _MK_FP( _FP_SEG( TrapCode ), TrapCode->init_off ); FiniFunc = _MK_FP( _FP_SEG( TrapCode ), TrapCode->fini_off ); @@ -158,7 +158,7 @@ digld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) TrapVer = *trap_ver; return( DIGS_OK ); } - err = DIGS_ERR_WRONG_TRAP_VERSION; + err = DIGS_ERR_WRONG_MODULE_VERSION; } } UnLoadTrap(); diff --git a/bld/dig/c/dsx/trpld.c b/bld/dig/c/dsx/trpld.c index 40831547fb..f85e9bb37c 100644 --- a/bld/dig/c/dsx/trpld.c +++ b/bld/dig/c/dsx/trpld.c @@ -349,7 +349,7 @@ static digld_error SetTrapHandler( void ) PMData->othersaved = false; sel = DPMIAllocateLDTDescriptors( 1 ); if( sel < 0 ) { - return( DIGS_ERR_CANT_LOAD_TRAP ); + return( DIGS_ERR_CANT_LOAD_MODULE ); } DPMIGetDescriptor( _FP_SEG( PMData ), &desc ); PMData->pmode_cs = sel; @@ -392,10 +392,10 @@ static digld_error ReadInTrap( FILE *fp ) unsigned hdr_size; if( DIGLoader( Read )( fp, &hdr, sizeof( hdr ) ) ) { - return( DIGS_ERR_CANT_LOAD_TRAP ); + return( DIGS_ERR_CANT_LOAD_MODULE ); } if( hdr.signature != EXESIGN_DOS ) { - return( DIGS_ERR_BAD_TRAP_FILE ); + return( DIGS_ERR_BAD_MODULE_FILE ); } hdr_size = hdr.hdr_size * 16; @@ -406,13 +406,13 @@ static digld_error ReadInTrap( FILE *fp ) } DIGLoader( Seek )( fp, hdr_size, DIG_SEEK_ORG ); if( DIGLoader( Read )( fp, (void *)DPMIGetSegmentBaseAddress( TrapMem.pm ), image_size ) ) { - return( DIGS_ERR_CANT_LOAD_TRAP ); + return( DIGS_ERR_CANT_LOAD_MODULE ); } DIGLoader( Seek )( fp, hdr.reloc_offset, DIG_SEEK_ORG ); for( relocnb = NUM_BUFF_RELOCS; hdr.num_relocs > 0; --hdr.num_relocs, ++relocnb ) { if( relocnb >= NUM_BUFF_RELOCS ) { if( DIGLoader( Read )( fp, relocbuff, sizeof( memptr ) * NUM_BUFF_RELOCS ) ) { - return( DIGS_ERR_CANT_LOAD_TRAP ); + return( DIGS_ERR_CANT_LOAD_MODULE ); } relocnb = 0; } @@ -503,11 +503,11 @@ digld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) len++; } if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, len, ".trp", filename, sizeof( filename ) ) == 0 ) { - return( DIGS_ERR_CANT_FIND_TRAP ); + return( DIGS_ERR_CANT_FIND_MODULE ); } fp = DIGLoader( Open )( filename ); if( fp == NULL ) { - return( DIGS_ERR_CANT_LOAD_TRAP ); + return( DIGS_ERR_CANT_LOAD_MODULE ); } err = ReadInTrap( fp ); DIGLoader( Close )( fp ); @@ -516,7 +516,7 @@ digld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) } if( (err = SetTrapHandler()) == DIGS_OK && (err = CopyEnv()) == DIGS_OK ) { - err = DIGS_ERR_BAD_TRAP_FILE; + err = DIGS_ERR_BAD_MODULE_FILE; head = EXTENDER_RM2PM( TrapMem.rm, 0 ); if( head->sig == TRAP_SIGNATURE ) { PMData->initfunc.s.offset = head->init; @@ -531,7 +531,7 @@ digld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) ReqFunc = DoTrapAccess; return( DIGS_OK ); } - err = DIGS_ERR_WRONG_TRAP_VERSION; + err = DIGS_ERR_WRONG_MODULE_VERSION; } } } diff --git a/bld/dig/c/linux/trpld_pe.c b/bld/dig/c/linux/trpld_pe.c index 14b7719f92..552dfe466c 100644 --- a/bld/dig/c/linux/trpld_pe.c +++ b/bld/dig/c/linux/trpld_pe.c @@ -103,23 +103,23 @@ digld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) } #if !defined( BUILTIN_TRAP_FILE ) if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, len, ".trp", filename, sizeof( filename ) ) == 0 ) { - return( DIGS_ERR_CANT_FIND_TRAP ); + return( DIGS_ERR_CANT_FIND_MODULE ); } fp = DIGLoader( Open )( filename ); if( fp == NULL ) { - return( DIGS_ERR_CANT_LOAD_TRAP ); + return( DIGS_ERR_CANT_LOAD_MODULE ); } mod_hdl = PE_loadLibraryFile( fp, filename ); DIGLoader( Close )( fp ); if( mod_hdl == NULL ) { - return( DIGS_ERR_CANT_LOAD_TRAP ); + return( DIGS_ERR_CANT_LOAD_MODULE ); } ld_func = (trap_load_func *)PE_getProcAddress( mod_hdl, "TrapLoad_" ); trap_funcs = ((ld_func != NULL) ? ld_func( &TrapCallbacks ) : NULL); #else trap_funcs = TrapLoad( &TrapCallbacks ); #endif - err = DIGS_ERR_BAD_TRAP_FILE; + err = DIGS_ERR_BAD_MODULE_FILE; if( trap_funcs != NULL ) { *trap_ver = trap_funcs->init_func( parms, buff, trap_ver->remote ); FiniFunc = trap_funcs->fini_func; @@ -129,7 +129,7 @@ digld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) TrapVer = *trap_ver; return( DIGS_OK ); } - err = DIGS_ERR_WRONG_TRAP_VERSION; + err = DIGS_ERR_WRONG_MODULE_VERSION; } } UnLoadTrap(); diff --git a/bld/dig/c/linux/trpld_rx.c b/bld/dig/c/linux/trpld_rx.c index 2cce69cff7..4cf4e00176 100644 --- a/bld/dig/c/linux/trpld_rx.c +++ b/bld/dig/c/linux/trpld_rx.c @@ -94,18 +94,18 @@ digld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) len++; } if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, len, ".trp", filename, sizeof( filename ) ) == 0 ) { - return( DIGS_ERR_CANT_FIND_TRAP ); + return( DIGS_ERR_CANT_FIND_MODULE ); } fp = DIGLoader( Open )( filename ); if( fp == NULL ) { - return( DIGS_ERR_CANT_LOAD_TRAP ); + return( DIGS_ERR_CANT_LOAD_MODULE ); } TrapCode = ReadInImp( fp ); DIGLoader( Close )( fp ); if( TrapCode == NULL ) { - return( DIGS_ERR_CANT_LOAD_TRAP ); + return( DIGS_ERR_CANT_LOAD_MODULE ); } - err = DIGS_ERR_BAD_TRAP_FILE; + err = DIGS_ERR_BAD_MODULE_FILE; #ifdef __WATCOMC__ ld_func = (trap_load_func *)((TrapCode->sig == TRAPSIG) ? TrapCode->init_rtn : NULL); #else @@ -121,7 +121,7 @@ digld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) TrapVer = *trap_ver; return( DIGS_OK ); } - err = DIGS_ERR_WRONG_TRAP_VERSION; + err = DIGS_ERR_WRONG_MODULE_VERSION; } } UnLoadTrap(); diff --git a/bld/dig/c/linux/trpld_so.c b/bld/dig/c/linux/trpld_so.c index 649c7f8691..ed576444ff 100644 --- a/bld/dig/c/linux/trpld_so.c +++ b/bld/dig/c/linux/trpld_so.c @@ -105,24 +105,24 @@ digld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) } #if !defined( BUILTIN_TRAP_FILE ) if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, len, ".so", filename, sizeof( filename ) ) == 0 ) { - return( DIGS_ERR_CANT_FIND_TRAP ); + return( DIGS_ERR_CANT_FIND_MODULE ); } fp = DIGLoader( Open )( filename ); if( fp == NULL ) { - return( DIGS_ERR_CANT_LOAD_TRAP ); + return( DIGS_ERR_CANT_LOAD_MODULE ); } mod_hdl = dlopen( filename, RTLD_NOW ); DIGLoader( Close )( fp ); if( mod_hdl == NULL ) { puts( dlerror() ); - return( DIGS_ERR_CANT_LOAD_TRAP ); + return( DIGS_ERR_CANT_LOAD_MODULE ); } ld_func = (trap_load_func *)dlsym( mod_hdl, "TrapLoad" ); trap_funcs = ((ld_func != NULL) ? ld_func( &TrapCallbacks ) : NULL); #else trap_funcs = TrapLoad( &TrapCallbacks ); #endif - err = DIGS_ERR_BAD_TRAP_FILE; + err = DIGS_ERR_BAD_MODULE_FILE; if( trap_funcs != NULL ) { *trap_ver = trap_funcs->init_func( parms, buff, trap_ver->remote ); FiniFunc = trap_funcs->fini_func; @@ -132,7 +132,7 @@ digld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) TrapVer = *trap_ver; return( DIGS_OK ); } - err = DIGS_ERR_WRONG_TRAP_VERSION; + err = DIGS_ERR_WRONG_MODULE_VERSION; } } UnLoadTrap(); diff --git a/bld/dig/c/nov/trpld.c b/bld/dig/c/nov/trpld.c index 3e33b59ddb..f5de24b2fc 100644 --- a/bld/dig/c/nov/trpld.c +++ b/bld/dig/c/nov/trpld.c @@ -58,7 +58,7 @@ digld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) } len++; } - err = DIGS_ERR_BAD_TRAP_FILE; + err = DIGS_ERR_BAD_MODULE_FILE; *trap_ver = TrapInit( parms, buff, trap_ver->remote ); if( buff[0] == '\0' ) { if( TrapVersionOK( *trap_ver ) ) { @@ -66,7 +66,7 @@ digld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) ReqFunc = TrapRequest; return( DIGS_OK ); } - err = DIGS_ERR_WRONG_TRAP_VERSION; + err = DIGS_ERR_WRONG_MODULE_VERSION; } UnLoadTrap(); return( err ); diff --git a/bld/dig/c/nt/trpld.c b/bld/dig/c/nt/trpld.c index 9701907e88..09c0f89a9a 100644 --- a/bld/dig/c/nt/trpld.c +++ b/bld/dig/c/nt/trpld.c @@ -113,13 +113,13 @@ digld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) len++; } if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, len, ".dll", filename, sizeof( filename ) ) == 0 ) { - return( DIGS_ERR_CANT_FIND_TRAP ); + return( DIGS_ERR_CANT_FIND_MODULE ); } mod_hdl = LoadLibrary( filename ); if( mod_hdl == NULL ) { - return( DIGS_ERR_CANT_LOAD_TRAP ); + return( DIGS_ERR_CANT_LOAD_MODULE ); } - err = DIGS_ERR_BAD_TRAP_FILE; + err = DIGS_ERR_BAD_MODULE_FILE; init_func = (trap_init_func *)GetProcAddress( mod_hdl, (LPSTR)1 ); FiniFunc = (trap_fini_func *)GetProcAddress( mod_hdl, (LPSTR)2 ); ReqFunc = (trap_req_func *)GetProcAddress( mod_hdl, (LPSTR)3 ); @@ -135,7 +135,7 @@ digld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) TrapVer = *trap_ver; return( DIGS_OK ); } - err = DIGS_ERR_WRONG_TRAP_VERSION; + err = DIGS_ERR_WRONG_MODULE_VERSION; } } UnLoadTrap(); diff --git a/bld/dig/c/os2/trpld.c b/bld/dig/c/os2/trpld.c index 13c2b0a8d1..b973238967 100644 --- a/bld/dig/c/os2/trpld.c +++ b/bld/dig/c/os2/trpld.c @@ -141,12 +141,12 @@ digld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) #else if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, len, ".D32", filename, sizeof( filename ) ) == 0 ) { #endif - return( DIGS_ERR_CANT_FIND_TRAP ); + return( DIGS_ERR_CANT_FIND_MODULE ); } if( LOAD_MODULE( filename, mod_hdl ) ) { - return( DIGS_ERR_CANT_LOAD_TRAP ); + return( DIGS_ERR_CANT_LOAD_MODULE ); } - err = DIGS_ERR_BAD_TRAP_FILE; + err = DIGS_ERR_BAD_MODULE_FILE; if( GET_PROC_ADDRESS( mod_hdl, 1, init_func ) && GET_PROC_ADDRESS( mod_hdl, 2, FiniFunc ) && GET_PROC_ADDRESS( mod_hdl, 3, ReqFunc ) ) { @@ -162,7 +162,7 @@ digld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) TrapVer = *trap_ver; return( DIGS_OK ); } - err = DIGS_ERR_WRONG_TRAP_VERSION; + err = DIGS_ERR_WRONG_MODULE_VERSION; } } UnLoadTrap(); diff --git a/bld/dig/c/qnx/trpld.c b/bld/dig/c/qnx/trpld.c index 67c8f738f5..afed47ba98 100644 --- a/bld/dig/c/qnx/trpld.c +++ b/bld/dig/c/qnx/trpld.c @@ -96,18 +96,18 @@ digld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) len++; } if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, len, ".trp", filename, sizeof( filename ) ) == 0 ) { - return( DIGS_ERR_CANT_FIND_TRAP ); + return( DIGS_ERR_CANT_FIND_MODULE ); } fp = DIGLoader( Open )( filename ); if( fp == NULL ) { - return( DIGS_ERR_CANT_LOAD_TRAP ); + return( DIGS_ERR_CANT_LOAD_MODULE ); } TrapCode = ReadInImp( fp ); DIGLoader( Close )( fp ); if( TrapCode == NULL ) { - return( DIGS_ERR_CANT_LOAD_TRAP ); + return( DIGS_ERR_CANT_LOAD_MODULE ); } - err = DIGS_ERR_BAD_TRAP_FILE; + err = DIGS_ERR_BAD_MODULE_FILE; #ifdef __WATCOMC__ ld_func = (trap_load_func *)((TrapCode->sig == TRAPSIG) ? TrapCode->init_rtn : NULL); #else @@ -123,7 +123,7 @@ digld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) TrapVer = *trap_ver; return( DIGS_OK ); } - err = DIGS_ERR_WRONG_TRAP_VERSION; + err = DIGS_ERR_WRONG_MODULE_VERSION; } } UnLoadTrap(); diff --git a/bld/dig/c/rdos/trpld.c b/bld/dig/c/rdos/trpld.c index b1bac7995c..a67729aca6 100644 --- a/bld/dig/c/rdos/trpld.c +++ b/bld/dig/c/rdos/trpld.c @@ -73,13 +73,13 @@ digld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) len++; } if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, len, ".dll", filename, sizeof( filename ) ) == 0 ) { - return( DIGS_ERR_CANT_FIND_TRAP ); + return( DIGS_ERR_CANT_FIND_MODULE ); } mod_hdl = RdosLoadDll( filename ); if( mod_hdl == NULL ) { - return( DIGS_ERR_CANT_LOAD_TRAP ); + return( DIGS_ERR_CANT_LOAD_MODULE ); } - err = DIGS_ERR_BAD_TRAP_FILE; + err = DIGS_ERR_BAD_MODULE_FILE; init_func = RdosGetModuleProc( mod_hdl, "TrapInit_" ); FiniFunc = RdosGetModuleProc( mod_hdl, "TrapFini_" ); ReqFunc = RdosGetModuleProc( mod_hdl, "TrapRequest_" ); @@ -94,7 +94,7 @@ digld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) TrapVer = *trap_ver; return( DIGS_OK ); } - err = DIGS_ERR_WRONG_TRAP_VERSION; + err = DIGS_ERR_WRONG_MODULE_VERSION; } } UnLoadTrap(); diff --git a/bld/dig/c/win/trpld.c b/bld/dig/c/win/trpld.c index 99c4547cd7..d26740acc8 100644 --- a/bld/dig/c/win/trpld.c +++ b/bld/dig/c/win/trpld.c @@ -106,16 +106,16 @@ digld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) toolhelp = 0; } if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, len, ".dll", filename, sizeof( filename ) ) == 0 ) { - return( DIGS_ERR_CANT_FIND_TRAP ); + return( DIGS_ERR_CANT_FIND_MODULE ); } prev = SetErrorMode( SEM_NOOPENFILEERRORBOX ); mod_hdl = LoadLibrary( filename ); SetErrorMode( prev ); if( (UINT)mod_hdl < 32 ) { mod_hdl = 0; - return( DIGS_ERR_CANT_LOAD_TRAP ); + return( DIGS_ERR_CANT_LOAD_MODULE ); } - err = DIGS_ERR_BAD_TRAP_FILE; + err = DIGS_ERR_BAD_MODULE_FILE; init_func = (trap_init_func *)GetProcAddress( mod_hdl, (LPSTR)2 ); FiniFunc = (trap_fini_func *)GetProcAddress( mod_hdl, (LPSTR)3 ); ReqFunc = (trap_req_func *)GetProcAddress( mod_hdl, (LPSTR)4 ); @@ -134,7 +134,7 @@ digld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) TrapVer = *trap_ver; return( DIGS_OK ); } - err = DIGS_ERR_WRONG_TRAP_VERSION; + err = DIGS_ERR_WRONG_MODULE_VERSION; } } UnLoadTrap(); diff --git a/bld/dig/h/digld.h b/bld/dig/h/digld.h index c89a9d5e0e..5eee222fb0 100644 --- a/bld/dig/h/digld.h +++ b/bld/dig/h/digld.h @@ -36,21 +36,21 @@ #define DIGLoader(n) DIGLoader ## n -#define DIGS_ERRORS \ - DIGS_ERROR( DIGS_OK, NULL ) \ - DIGS_ERROR( DIGS_ERR, "Unknown system error" ) \ - DIGS_ERROR( DIGS_ERR_CANT_FIND_MODULE, "Unable to find module file" ) \ - DIGS_ERROR( DIGS_ERR_CANT_LOAD_MODULE, "Unable to load module file" ) \ - DIGS_ERROR( DIGS_ERR_WRONG_MODULE_VERSION, "Incorrect version of module file" ) \ - DIGS_ERROR( DIGS_ERR_BAD_MODULE_FILE, "Invalid module file" ) \ - DIGS_ERROR( DIGS_ERR_OUT_OF_DOS_MEMORY, "Out of DOS memory" ) \ - DIGS_ERROR( DIGS_ERR_OUT_OF_MEMORY, "Out of memory" ) +#define DIGS_ERRORS_default(x) x "Unknown system error" -#define DIGS_ERRORS_default "Unknown system error" +#define DIGS_ERRORS(x) \ + DIGS_ERROR( DIGS_OK, NULL ) \ + DIGS_ERROR( DIGS_ERR, DIGS_ERRORS_default( x ) ) \ + DIGS_ERROR( DIGS_ERR_CANT_FIND_MODULE, x "Unable to find module file" ) \ + DIGS_ERROR( DIGS_ERR_CANT_LOAD_MODULE, x "Unable to load module file" ) \ + DIGS_ERROR( DIGS_ERR_WRONG_MODULE_VERSION, x "Incorrect version of module file" ) \ + DIGS_ERROR( DIGS_ERR_BAD_MODULE_FILE, x "Invalid module file" ) \ + DIGS_ERROR( DIGS_ERR_OUT_OF_DOS_MEMORY, x "Out of DOS memory" ) \ + DIGS_ERROR( DIGS_ERR_OUT_OF_MEMORY, x "Out of memory" ) typedef enum { #define DIGS_ERROR(e,t) e, - DIGS_ERRORS + DIGS_ERRORS() #undef DIGS_ERROR } digld_error; diff --git a/bld/trap/common/serv.c b/bld/trap/common/serv.c index 9345005461..0cfb6204c9 100644 --- a/bld/trap/common/serv.c +++ b/bld/trap/common/serv.c @@ -77,9 +77,9 @@ static const char *ServInitialize( void ) if( err == NULL ) { switch( LoadTrap( trapparms, RWBuff, &TrapVersion ) ) { #define DIGS_ERROR(e,t) case e: err = t; break; - DIGS_ERRORS + DIGS_ERRORS( "TRAP Loader: " ) #undef DIGS_ERROR - default: err = DIGS_ERRORS_default; break + default: err = DIGS_ERRORS_default( "TRAP Loader: " ); break; } } } diff --git a/bld/trap/common/servw.c b/bld/trap/common/servw.c index 241b49ae3c..3465e8afa5 100644 --- a/bld/trap/common/servw.c +++ b/bld/trap/common/servw.c @@ -83,9 +83,9 @@ int PASCAL WinMain( HINSTANCE this_inst, HINSTANCE prev_inst, LPSTR cmdline, int if( err == NULL ) { switch( LoadTrap( trapparms, RWBuff, &TrapVersion ) ) { #define DIGS_ERROR(e,t) case e: err = t; break; - DIGS_ERRORS + DIGS_ERRORS( "TRAP Loader: " ) #undef DIGS_ERROR - default: err = DIGS_ERRORS_default; break + default: err = DIGS_ERRORS_default( "TRAP Loader: " ); break; } } } diff --git a/bld/wv/c/remmisc.c b/bld/wv/c/remmisc.c index 74a14a006a..661fcf5228 100644 --- a/bld/wv/c/remmisc.c +++ b/bld/wv/c/remmisc.c @@ -42,7 +42,6 @@ #include "dbgmem.h" #include "trpld.h" #include "trpcore.h" -#include "trperr.h" #include "dbgio.h" #include "strutil.h" #include "trapglbl.h" @@ -127,9 +126,9 @@ void InitTrap( const char *parms ) #endif switch( LoadTrap( parms, buff, &ver ) ) { #define DIGS_ERROR(e,t) case e: error = t; break; - DIGS_ERRORS - #undef DIGS_ERROR - default: error = DIGS_ERRORS_default; break + DIGS_ERRORS( "TRAP Loader: " ) + #undef DIGS_ERROR + default: error = DIGS_ERRORS_default( "TRAP Loader: " ); break; } #if !defined( BUILD_RFX ) } From a654866a2e5b3b3cce4fe4e675ddb70904c2a2d7 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Wed, 13 Sep 2023 18:26:41 +0200 Subject: [PATCH 128/258] enable to use extra error message in dedicated buffer --- bld/dig/c/dos/trpld.c | 1 + bld/dig/c/dsx/trpld.c | 9 +++++---- bld/dig/c/linux/trpld_pe.c | 1 + bld/dig/c/linux/trpld_rx.c | 1 + bld/dig/c/linux/trpld_so.c | 1 + bld/dig/c/nov/trpld.c | 2 +- bld/dig/c/nt/trpld.c | 1 + bld/dig/c/os2/trpld.c | 1 + bld/dig/c/qnx/trpld.c | 1 + bld/dig/c/rdos/trpld.c | 1 + bld/dig/c/win/trpld.c | 1 + bld/dig/h/digld.h | 7 ++++--- bld/trap/common/serv.c | 4 ++-- bld/trap/common/servw.c | 4 ++-- bld/wv/c/remmisc.c | 6 +++--- 15 files changed, 26 insertions(+), 15 deletions(-) diff --git a/bld/dig/c/dos/trpld.c b/bld/dig/c/dos/trpld.c index f963b51b36..ce37b2b05e 100644 --- a/bld/dig/c/dos/trpld.c +++ b/bld/dig/c/dos/trpld.c @@ -153,6 +153,7 @@ digld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) FiniFunc = _MK_FP( _FP_SEG( TrapCode ), TrapCode->fini_off ); ReqFunc = _MK_FP( _FP_SEG( TrapCode ), TrapCode->req_off ); *trap_ver = init_func( parms, buff, trap_ver->remote ); + err = DIGS_ERR_BUF; if( buff[0] == '\0' ) { if( TrapVersionOK( *trap_ver ) ) { TrapVer = *trap_ver; diff --git a/bld/dig/c/dsx/trpld.c b/bld/dig/c/dsx/trpld.c index f85e9bb37c..3e3a0c51b4 100644 --- a/bld/dig/c/dsx/trpld.c +++ b/bld/dig/c/dsx/trpld.c @@ -369,7 +369,7 @@ static digld_error SetTrapHandler( void ) return( DIGS_OK ); } -static bool CallTrapInit( const char *parms, char *errmsg, trap_version *trap_ver ) +static trap_version CallTrapInit( const char *parms, char *errmsg, trap_version *trap_ver ) { trap_init_struct __far *callstruct; @@ -378,9 +378,8 @@ static bool CallTrapInit( const char *parms, char *errmsg, trap_version *trap_ve _fstrcpy( (char __far *)&callstruct[1], parms ); callstruct->errmsg_off = sizeof( *callstruct ) + strlen( parms ) + 1; GoToRealMode( RMTrapInit ); - *trap_ver = callstruct->version; _fstrcpy( errmsg, (char __far *)callstruct + callstruct->errmsg_off ); - return( *errmsg == '\0' ); + return( callstruct->version ); } static digld_error ReadInTrap( FILE *fp ) @@ -525,7 +524,9 @@ digld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) PMData->initfunc.s.segment = TrapMem.rm; PMData->reqfunc.s.segment = TrapMem.rm; PMData->finifunc.s.segment = TrapMem.rm; - if( CallTrapInit( parms, buff, trap_ver ) ) { + *trap_ver = CallTrapInit( parms, buff, trap_ver ); + err = DIGS_ERR_BUF; + if( buff[0] == '\0' ) { if( TrapVersionOK( *trap_ver ) ) { TrapVer = *trap_ver; ReqFunc = DoTrapAccess; diff --git a/bld/dig/c/linux/trpld_pe.c b/bld/dig/c/linux/trpld_pe.c index 552dfe466c..bf42237117 100644 --- a/bld/dig/c/linux/trpld_pe.c +++ b/bld/dig/c/linux/trpld_pe.c @@ -124,6 +124,7 @@ digld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) *trap_ver = trap_funcs->init_func( parms, buff, trap_ver->remote ); FiniFunc = trap_funcs->fini_func; ReqFunc = trap_funcs->req_func; + err = DIGS_ERR_BUF; if( buff[0] == '\0' ) { if( TrapVersionOK( *trap_ver ) ) { TrapVer = *trap_ver; diff --git a/bld/dig/c/linux/trpld_rx.c b/bld/dig/c/linux/trpld_rx.c index 4cf4e00176..7e22aa02cd 100644 --- a/bld/dig/c/linux/trpld_rx.c +++ b/bld/dig/c/linux/trpld_rx.c @@ -116,6 +116,7 @@ digld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) *trap_ver = trap_funcs->init_func( parms, buff, trap_ver->remote ); FiniFunc = trap_funcs->fini_func; ReqFunc = trap_funcs->req_func; + err = DIGS_ERR_BUF; if( buff[0] == '\0' ) { if( TrapVersionOK( *trap_ver ) ) { TrapVer = *trap_ver; diff --git a/bld/dig/c/linux/trpld_so.c b/bld/dig/c/linux/trpld_so.c index ed576444ff..b85f1eb3d3 100644 --- a/bld/dig/c/linux/trpld_so.c +++ b/bld/dig/c/linux/trpld_so.c @@ -127,6 +127,7 @@ digld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) *trap_ver = trap_funcs->init_func( parms, buff, trap_ver->remote ); FiniFunc = trap_funcs->fini_func; ReqFunc = trap_funcs->req_func; + err = DIGS_ERR_BUF; if( buff[0] == '\0' ) { if( TrapVersionOK( *trap_ver ) ) { TrapVer = *trap_ver; diff --git a/bld/dig/c/nov/trpld.c b/bld/dig/c/nov/trpld.c index f5de24b2fc..40461bb94c 100644 --- a/bld/dig/c/nov/trpld.c +++ b/bld/dig/c/nov/trpld.c @@ -58,8 +58,8 @@ digld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) } len++; } - err = DIGS_ERR_BAD_MODULE_FILE; *trap_ver = TrapInit( parms, buff, trap_ver->remote ); + err = DIGS_ERR_BUF; if( buff[0] == '\0' ) { if( TrapVersionOK( *trap_ver ) ) { TrapVer = *trap_ver; diff --git a/bld/dig/c/nt/trpld.c b/bld/dig/c/nt/trpld.c index 09c0f89a9a..aa6d614279 100644 --- a/bld/dig/c/nt/trpld.c +++ b/bld/dig/c/nt/trpld.c @@ -130,6 +130,7 @@ digld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) && FiniFunc != NULL && ReqFunc != NULL ) { *trap_ver = init_func( parms, buff, trap_ver->remote ); + err = DIGS_ERR_BUF; if( buff[0] == '\0' ) { if( TrapVersionOK( *trap_ver ) ) { TrapVer = *trap_ver; diff --git a/bld/dig/c/os2/trpld.c b/bld/dig/c/os2/trpld.c index b973238967..11a520c52c 100644 --- a/bld/dig/c/os2/trpld.c +++ b/bld/dig/c/os2/trpld.c @@ -157,6 +157,7 @@ digld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) TRAP_EXTFUNC_PTR( TellHardMode ) = NULL; } *trap_ver = init_func( parms, buff, trap_ver->remote ); + err = DIGS_ERR_BUF; if( buff[0] == '\0' ) { if( TrapVersionOK( *trap_ver ) ) { TrapVer = *trap_ver; diff --git a/bld/dig/c/qnx/trpld.c b/bld/dig/c/qnx/trpld.c index afed47ba98..53a559a5de 100644 --- a/bld/dig/c/qnx/trpld.c +++ b/bld/dig/c/qnx/trpld.c @@ -118,6 +118,7 @@ digld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) *trap_ver = trap_funcs->init_func( parms, buff, trap_ver->remote ); FiniFunc = trap_funcs->fini_func; ReqFunc = trap_funcs->req_func; + err = DIGS_ERR_BUF; if( buff[0] == '\0' ) { if( TrapVersionOK( *trap_ver ) ) { TrapVer = *trap_ver; diff --git a/bld/dig/c/rdos/trpld.c b/bld/dig/c/rdos/trpld.c index a67729aca6..a7352d30f6 100644 --- a/bld/dig/c/rdos/trpld.c +++ b/bld/dig/c/rdos/trpld.c @@ -89,6 +89,7 @@ digld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) && ReqFunc != NULL /* && LibListFunc != NULL */ ) { *trap_ver = init_func( parms, buff, trap_ver->remote ); + err = DIGS_ERR_BUF; if( buff[0] == '\0' ) { if( TrapVersionOK( *trap_ver ) ) { TrapVer = *trap_ver; diff --git a/bld/dig/c/win/trpld.c b/bld/dig/c/win/trpld.c index d26740acc8..818a2a01b3 100644 --- a/bld/dig/c/win/trpld.c +++ b/bld/dig/c/win/trpld.c @@ -129,6 +129,7 @@ digld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) && FiniFunc != NULL && ReqFunc != NULL ) { *trap_ver = init_func( parms, buff, trap_ver->remote ); + err = DIGS_ERR_BUF; if( buff[0] == '\0' ) { if( TrapVersionOK( *trap_ver ) ) { TrapVer = *trap_ver; diff --git a/bld/dig/h/digld.h b/bld/dig/h/digld.h index 5eee222fb0..0b1771fe47 100644 --- a/bld/dig/h/digld.h +++ b/bld/dig/h/digld.h @@ -38,7 +38,7 @@ #define DIGS_ERRORS_default(x) x "Unknown system error" -#define DIGS_ERRORS(x) \ +#define DIGS_ERRORS(x, b) \ DIGS_ERROR( DIGS_OK, NULL ) \ DIGS_ERROR( DIGS_ERR, DIGS_ERRORS_default( x ) ) \ DIGS_ERROR( DIGS_ERR_CANT_FIND_MODULE, x "Unable to find module file" ) \ @@ -46,11 +46,12 @@ DIGS_ERROR( DIGS_ERR_WRONG_MODULE_VERSION, x "Incorrect version of module file" ) \ DIGS_ERROR( DIGS_ERR_BAD_MODULE_FILE, x "Invalid module file" ) \ DIGS_ERROR( DIGS_ERR_OUT_OF_DOS_MEMORY, x "Out of DOS memory" ) \ - DIGS_ERROR( DIGS_ERR_OUT_OF_MEMORY, x "Out of memory" ) + DIGS_ERROR( DIGS_ERR_OUT_OF_MEMORY, x "Out of memory" ) \ + DIGS_ERROR( DIGS_ERR_BUF, b ) typedef enum { #define DIGS_ERROR(e,t) e, - DIGS_ERRORS() + DIGS_ERRORS( "", "" ) #undef DIGS_ERROR } digld_error; diff --git a/bld/trap/common/serv.c b/bld/trap/common/serv.c index 0cfb6204c9..d2074a43b3 100644 --- a/bld/trap/common/serv.c +++ b/bld/trap/common/serv.c @@ -77,9 +77,9 @@ static const char *ServInitialize( void ) if( err == NULL ) { switch( LoadTrap( trapparms, RWBuff, &TrapVersion ) ) { #define DIGS_ERROR(e,t) case e: err = t; break; - DIGS_ERRORS( "TRAP Loader: " ) + DIGS_ERRORS( "TRAP Loader: ", RWBuff ) #undef DIGS_ERROR - default: err = DIGS_ERRORS_default( "TRAP Loader: " ); break; + default: err = DIGS_ERRORS_default( "TRAP Loader: " ); break; } } } diff --git a/bld/trap/common/servw.c b/bld/trap/common/servw.c index 3465e8afa5..7ab89a0f25 100644 --- a/bld/trap/common/servw.c +++ b/bld/trap/common/servw.c @@ -83,9 +83,9 @@ int PASCAL WinMain( HINSTANCE this_inst, HINSTANCE prev_inst, LPSTR cmdline, int if( err == NULL ) { switch( LoadTrap( trapparms, RWBuff, &TrapVersion ) ) { #define DIGS_ERROR(e,t) case e: err = t; break; - DIGS_ERRORS( "TRAP Loader: " ) + DIGS_ERRORS( "TRAP Loader: ", RWBuff ) #undef DIGS_ERROR - default: err = DIGS_ERRORS_default( "TRAP Loader: " ); break; + default: err = DIGS_ERRORS_default( "TRAP Loader: " ); break; } } } diff --git a/bld/wv/c/remmisc.c b/bld/wv/c/remmisc.c index 661fcf5228..e1defc83ff 100644 --- a/bld/wv/c/remmisc.c +++ b/bld/wv/c/remmisc.c @@ -126,9 +126,9 @@ void InitTrap( const char *parms ) #endif switch( LoadTrap( parms, buff, &ver ) ) { #define DIGS_ERROR(e,t) case e: error = t; break; - DIGS_ERRORS( "TRAP Loader: " ) - #undef DIGS_ERROR - default: error = DIGS_ERRORS_default( "TRAP Loader: " ); break; + DIGS_ERRORS( "TRAP Loader: ", buff ) + #undef DIGS_ERROR + default: error = DIGS_ERRORS_default( "TRAP Loader: " ); break; } #if !defined( BUILD_RFX ) } From c36173fbfd153c33c7588d5120d675be56dd4eb1 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Thu, 14 Sep 2023 00:13:45 +0200 Subject: [PATCH 129/258] use standard INADDR_ANY, must be defined on any system --- bld/trap/tcp/c/tcplink.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bld/trap/tcp/c/tcplink.c b/bld/trap/tcp/c/tcplink.c index 14dad71734..b15f6a0143 100644 --- a/bld/trap/tcp/c/tcplink.c +++ b/bld/trap/tcp/c/tcplink.c @@ -125,7 +125,6 @@ #endif #define DEFAULT_PORT 0x0DEB /* 3563 */ -#define OW_INADDR_ANY 0xFFFFFFFFUL /* 255.255.255.255 */ #define OW_INADDR_LOOPBACK htonl( 0x7F000001UL ) /* 127.0.0.1 */ #if defined( __RDOS__ ) @@ -560,7 +559,7 @@ const char *RemoteLink( const char *parms, bool server ) /* Name socket using wildcards */ memset( &socket_address, 0, sizeof( socket_address ) ); socket_address.sin_family = AF_INET; - socket_address.sin_addr.s_addr = OW_INADDR_ANY; + socket_address.sin_addr.s_addr = INADDR_ANY; socket_address.sin_port = htons( trap_port ); if( bind( control_socket, (LPSOCKADDR)&socket_address, sizeof( socket_address ) ) ) { return( TRP_ERR_unable_to_bind_stream_socket ); From d723a3b0e3e8de7e742d3d5af3a06040e7f737bf Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Thu, 14 Sep 2023 00:25:31 +0200 Subject: [PATCH 130/258] cleanup tcp trap code --- bld/dig/c/linux/trpld_rx.c | 4 ++-- bld/dig/c/qnx/trpld.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bld/dig/c/linux/trpld_rx.c b/bld/dig/c/linux/trpld_rx.c index 7e22aa02cd..c2cb6bc751 100644 --- a/bld/dig/c/linux/trpld_rx.c +++ b/bld/dig/c/linux/trpld_rx.c @@ -111,8 +111,8 @@ digld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) #else ld_func = (trap_load_func *)TrapCode->init_rtn; #endif - if( ld_func != NULL - && (trap_funcs = ld_func( &TrapCallbacks )) != NULL ) { + trap_funcs = (( ld_func != NULL ) ? ld_func( &TrapCallbacks ) : NULL); + if( trap_funcs != NULL ) { *trap_ver = trap_funcs->init_func( parms, buff, trap_ver->remote ); FiniFunc = trap_funcs->fini_func; ReqFunc = trap_funcs->req_func; diff --git a/bld/dig/c/qnx/trpld.c b/bld/dig/c/qnx/trpld.c index 53a559a5de..4ed21e67d6 100644 --- a/bld/dig/c/qnx/trpld.c +++ b/bld/dig/c/qnx/trpld.c @@ -113,8 +113,8 @@ digld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) #else ld_func = (trap_load_func *)TrapCode->init_rtn; #endif - if( ld_func != NULL - && (trap_funcs = ld_func( &TrapCallbacks )) != NULL ) { + trap_funcs = (( ld_func != NULL ) ? ld_func( &TrapCallbacks ) : NULL); + if( trap_funcs != NULL ) { *trap_ver = trap_funcs->init_func( parms, buff, trap_ver->remote ); FiniFunc = trap_funcs->fini_func; ReqFunc = trap_funcs->req_func; From e749cbcf65f36cfb9a083126ef86d3e61e3495a1 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Thu, 14 Sep 2023 18:03:16 +0200 Subject: [PATCH 131/258] rework MAD/DIP/TRAP loaders to separated host specific and executable format specific code --- bld/dig/c/dos/trpld.c | 3 +- bld/dig/c/dsx/dipld.c | 34 +- bld/dig/c/dsx/madld.c | 32 +- bld/dig/c/dsx/trpld.c | 2 +- bld/dig/c/ldrpe.c | 430 ++++++++++++++++++++ bld/dig/c/{dsx/ldimp.c => ldrrex.c} | 79 ++-- bld/dig/c/{osx/ldimp.c => ldrso.c} | 24 +- bld/dig/c/linux/dipld.c | 85 +++- bld/dig/c/linux/dipld_so.c | 75 ---- bld/dig/c/linux/ldimp.c | 39 -- bld/dig/c/linux/madld.c | 75 +++- bld/dig/c/linux/madld_so.c | 76 ---- bld/dig/c/linux/peloader.c | 600 ---------------------------- bld/dig/c/linux/peloader.h | 117 ------ bld/dig/c/linux/trpld.c | 160 +++++++- bld/dig/c/linux/trpld_pe.c | 138 ------- bld/dig/c/linux/trpld_rx.c | 130 ------ bld/dig/c/linux/trpld_so.c | 141 ------- bld/dig/c/nov/trpld.c | 3 +- bld/dig/c/nt/dipld.c | 3 +- bld/dig/c/nt/madld.c | 3 +- bld/dig/c/nt/trpld.c | 2 +- bld/dig/c/nto/trpld.c | 161 +++++++- bld/dig/c/osx/dipld.c | 85 +++- bld/dig/c/osx/madld.c | 75 +++- bld/dig/c/osx/trpld.c | 159 +++++++- bld/dig/c/qnx/dipld.c | 70 +++- bld/dig/c/qnx/ldimp.c | 39 -- bld/dig/c/qnx/madld.c | 78 +++- bld/dig/c/qnx/trpld.c | 33 +- bld/dig/c/rdos/dipld.c | 3 +- bld/dig/c/rdos/madld.c | 3 +- bld/dig/c/rdos/trpld.c | 2 +- bld/dig/c/win/dipld.c | 2 +- bld/dig/c/win/madld.c | 2 +- bld/dig/c/win/trpld.c | 3 +- bld/dig/digcli.mif | 10 - bld/dig/h/dipsys.h | 5 +- bld/dig/h/ldimp.h | 40 -- bld/dig/h/madsys.h | 5 +- bld/dig/h/trpld.h | 3 + 41 files changed, 1461 insertions(+), 1568 deletions(-) create mode 100644 bld/dig/c/ldrpe.c rename bld/dig/c/{dsx/ldimp.c => ldrrex.c} (65%) rename bld/dig/c/{osx/ldimp.c => ldrso.c} (71%) delete mode 100644 bld/dig/c/linux/dipld_so.c delete mode 100644 bld/dig/c/linux/ldimp.c delete mode 100644 bld/dig/c/linux/madld_so.c delete mode 100644 bld/dig/c/linux/peloader.c delete mode 100644 bld/dig/c/linux/peloader.h delete mode 100644 bld/dig/c/linux/trpld_pe.c delete mode 100644 bld/dig/c/linux/trpld_rx.c delete mode 100644 bld/dig/c/linux/trpld_so.c delete mode 100644 bld/dig/c/qnx/ldimp.c delete mode 100644 bld/dig/h/ldimp.h diff --git a/bld/dig/c/dos/trpld.c b/bld/dig/c/dos/trpld.c index ce37b2b05e..4c2a54d3f4 100644 --- a/bld/dig/c/dos/trpld.c +++ b/bld/dig/c/dos/trpld.c @@ -25,8 +25,7 @@ * * ======================================================================== * -* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE -* DESCRIBE IT HERE! +* Description: Trap module loader for DOS. * ****************************************************************************/ diff --git a/bld/dig/c/dsx/dipld.c b/bld/dig/c/dsx/dipld.c index 94d0494e55..d5519bd7e6 100644 --- a/bld/dig/c/dsx/dipld.c +++ b/bld/dig/c/dsx/dipld.c @@ -25,7 +25,7 @@ * * ======================================================================== * -* Description: Module to load DIP libraries in PharLap REX format. +* Description: DIP module loader for DOS extended debugger. * ****************************************************************************/ @@ -37,11 +37,15 @@ #include "dip.h" #include "dipimp.h" #include "dipsys.h" -#include "dbgmod.h" -#include "ldimp.h" +#include "exephar.h" +#include "roundmac.h" -#define DIPSIG 0x00504944UL // "DIP" +#define DEFEXT ".dip" +//#define MODINIT "DIPLOAD" +#define MODSIG DIPSIGVAL + +#include "../ldrrex.c" /* PharLap REX format loader */ void DIPSysUnload( dip_sys_handle *sys_hdl ) { @@ -49,7 +53,7 @@ void DIPSysUnload( dip_sys_handle *sys_hdl ) * We should unload the symbols here but it's not worth the trouble */ if( *sys_hdl != NULL_SYSHDL ) { - DIGCli( Free )( *sys_hdl ); + loader_unload_image( *sys_hdl ); *sys_hdl = NULL_SYSHDL; } } @@ -57,41 +61,37 @@ void DIPSysUnload( dip_sys_handle *sys_hdl ) dip_status DIPSysLoad( const char *base_name, dip_client_routines *cli, dip_imp_routines **imp, dip_sys_handle *sys_hdl ) { FILE *fp; - imp_header *mod_hdl; + module modhdl; dip_init_func *init_func; dip_status status; char filename[_MAX_PATH]; + digld_error err; *sys_hdl = NULL_SYSHDL; - if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, 0, ".dip", filename, sizeof( filename ) ) == 0 ) { + if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, 0, DEFEXT, filename, sizeof( filename ) ) == 0 ) { return( DS_ERR | DS_FOPEN_FAILED ); } fp = DIGLoader( Open )( filename ); if( fp == NULL ) { return( DS_ERR | DS_FOPEN_FAILED ); } - mod_hdl = ReadInImp( fp ); + err = loader_load_image( fp, filename, &modhdl, (void **)&init_func ); DIGLoader( Close )( fp ); status = DS_ERR | DS_INVALID_DIP; - if( mod_hdl == NULL ) { + if( err != DIGS_OK ) { return( status ); } -#ifdef __WATCOMC__ - init_func = (dip_init_func *)((mod_hdl->sig == DIPSIG) ? mod_hdl->init_rtn : NULL); -#else - init_func = (dip_init_func *)mod_hdl->init_rtn; -#endif if( init_func != NULL && (*imp = init_func( &status, cli )) != NULL ) { #ifdef WATCOM_DEBUG_SYMBOLS /* * Look for symbols in separate .sym files, not the .dip itself */ strcpy( filename + strlen( filename ) - 4, ".sym" ); - DebuggerLoadUserModule( filename, GetCS(), (unsigned long)mod_hdl ); + DebuggerLoadUserModule( filename, GetCS(), (unsigned long)modhdl ); #endif - *sys_hdl = mod_hdl; + *sys_hdl = modhdl; return( DS_OK ); } - DIPSysUnload( (dip_sys_handle *)&mod_hdl ); + loader_unload_image( modhdl ); return( status ); } diff --git a/bld/dig/c/dsx/madld.c b/bld/dig/c/dsx/madld.c index ee6c6b15d3..fe87fa82be 100644 --- a/bld/dig/c/dsx/madld.c +++ b/bld/dig/c/dsx/madld.c @@ -25,8 +25,7 @@ * * ======================================================================== * -* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE -* DESCRIBE IT HERE! +* Description: MAD module loader for DOS extended debugger. * ****************************************************************************/ @@ -39,15 +38,20 @@ #include "madimp.h" #include "madcli.h" #include "madsys.h" -#include "ldimp.h" +#include "exephar.h" +#include "roundmac.h" -#define MADSIG 0x0044414DUL // "MAD" +#define DEFEXT ".mad" +//#define MODINIT "MADLOAD" +#define MODSIG MADSIGVAL + +#include "../ldrrex.c" /* PharLap REX format loader */ void MADSysUnload( mad_sys_handle *sys_hdl ) { if( *sys_hdl != NULL_SYSHDL ) { - DIGCli( Free )( *sys_hdl ); + loader_unload_image( *sys_hdl ); *sys_hdl = NULL_SYSHDL; } } @@ -56,34 +60,30 @@ mad_status MADSysLoad( const char *base_name, mad_client_routines *cli, mad_imp_routines **imp, mad_sys_handle *sys_hdl ) { FILE *fp; - imp_header *mod_hdl; + module modhdl; mad_init_func *init_func; mad_status status; char filename[256]; + digld_error err; *sys_hdl = NULL_SYSHDL; - if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, 0, ".mad", filename, sizeof( filename ) ) == 0 ) { + if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, 0, DEFEXT, filename, sizeof( filename ) ) == 0 ) { return( MS_ERR | MS_FOPEN_FAILED ); } fp = DIGLoader( Open )( filename ); if( fp == NULL ) { return( MS_ERR | MS_FOPEN_FAILED ); } - mod_hdl = ReadInImp( fp ); + err = loader_load_image( fp, filename, &modhdl, (void **)&init_func ); DIGLoader( Close )( fp ); status = MS_ERR | MS_INVALID_MAD; - if( mod_hdl == NULL ) { + if( err != DIGS_OK ) { return( status ); } -#ifdef __WATCOMC__ - init_func = (mad_init_func *)((mod_hdl->sig == MADSIG) ? mod_hdl->init_rtn : NULL); -#else - init_func = (mad_init_func *)mod_hdl->init_rtn; -#endif if( init_func != NULL && (*imp = init_func( &status, cli )) != NULL ) { - *sys_hdl = mod_hdl; + *sys_hdl = modhdl; return( MS_OK ); } - MADSysUnload( (mad_sys_handle *)&mod_hdl ); + loader_unload_image( modhdl ); return( status ); } diff --git a/bld/dig/c/dsx/trpld.c b/bld/dig/c/dsx/trpld.c index 3e3a0c51b4..53a6eb3f59 100644 --- a/bld/dig/c/dsx/trpld.c +++ b/bld/dig/c/dsx/trpld.c @@ -25,7 +25,7 @@ * * ======================================================================== * -* Description: Trap file loading for DOS extended debugger. +* Description: Trap module loader for DOS extended debugger. * ****************************************************************************/ diff --git a/bld/dig/c/ldrpe.c b/bld/dig/c/ldrpe.c new file mode 100644 index 0000000000..a2bcd9f7bd --- /dev/null +++ b/bld/dig/c/ldrpe.c @@ -0,0 +1,430 @@ +/**************************************************************************** +* +* Open Watcom Project +* +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. +* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. +* +* ======================================================================== +* +* This file contains Original Code and/or Modifications of Original +* Code as defined in and that are subject to the Sybase Open Watcom +* Public License version 1.0 (the 'License'). You may not use this file +* except in compliance with the License. BY USING THIS FILE YOU AGREE TO +* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is +* provided with the Original Code and Modifications, and is also +* available at www.sybase.com/developer/opensource. +* +* The Original Code and all software distributed under the License are +* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM +* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR +* NON-INFRINGEMENT. Please see the License for the specific language +* governing rights and limitations under the License. +* +* ======================================================================== +* +* Description: DIP/MAD/TRP module loader for PE DLL file format. +* +****************************************************************************/ + +/* + * Module to implement a simple Portable Binary DLL library loader. + * + * This code can be used to load PE DLL's under any Intel based OS, + * provided the DLL's do not have any imports in the import table. + * + * NOTE: This loader module expects the DLL's to be built with + * Watcom C++ and may produce unexpected results with + * DLL's linked by another compiler. + * + * Now used by Linux 32-bit code only for TRAP modules + */ + +typedef struct { + u_char *pbase; /* Base of image in memory */ + u_char *ptext; /* Text section read from disk */ + u_char *pdata; /* Data section read from disk */ + u_char *pbss; /* BSS section read */ + u_char *pimport; /* Import section read from disk */ + u_char *pexport; /* Export section read from disk */ + u_long textBase; /* Base of text section in image */ + u_long dataBase; /* Base of data section in image */ + u_long bssBase; /* Base of BSS data section in image */ + u_long importBase; /* Offset of import section in image */ + u_long exportBase; /* Offset of export section in image */ + u_long exportDir; /* Offset of export directory */ + char *modname; /* Filename of the image */ +} *module; + +static digld_error pe_read_header( FILE *fp, pe_exe_header *pe_hdr ) +{ + dos_exe_header exehdr; + u_long ne_header_off; + + /* + * Read the EXE header and check for valid header signature + */ + if( DIGLoader( Seek )( fp, 0, SEEK_SET ) + || DIGLoader( Read )( fp, &exehdr, sizeof( exehdr ) ) ) + return( DIGS_ERR_CANT_LOAD_MODULE ); + if( ( exehdr.signature != EXESIGN_DOS ) + || !NE_HEADER_FOLLOWS( exehdr.reloc_offset ) ) + return( DIGS_ERR_BAD_MODULE_FILE ); + /* + * Now seek to the start of the PE header defined at offset 0x3C + * in the MS-DOS EXE header, and read the signature and check it. + */ + if( DIGLoader( Seek )( fp, NE_HEADER_OFFSET, SEEK_SET ) + || DIGLoader( Read )( fp, &ne_header_off, sizeof( ne_header_off ) ) ) + return( DIGS_ERR_CANT_LOAD_MODULE ); + if( DIGLoader( Seek )( fp, ne_header_off, SEEK_SET ) + || DIGLoader( Read )( fp, &pe_hdr->signature, sizeof( pe_hdr->signature ) ) ) + return( DIGS_ERR_CANT_LOAD_MODULE ); + if( pe_hdr->signature != EXESIGN_PE ) + return( DIGS_ERR_BAD_MODULE_FILE ); + /* + * Now read the PE file header and check that it is correct + */ + if( DIGLoader( Read )( fp, &pe_hdr->fheader, sizeof( pe_hdr->fheader ) ) ) + return( DIGS_ERR_CANT_LOAD_MODULE ); + if( pe_hdr->fheader.cpu_type != PE_CPU_386 ) + return( DIGS_ERR_BAD_MODULE_FILE ); + if( (pe_hdr->fheader.flags & PE_FLG_32BIT_MACHINE) == 0 ) + return( DIGS_ERR_BAD_MODULE_FILE ); + if( (pe_hdr->fheader.flags & PE_FLG_LIBRARY) == 0 ) + return( DIGS_ERR_BAD_MODULE_FILE ); + if( DIGLoader( Read )( fp, &pe_hdr->opt.pe32, sizeof( pe_hdr->opt.pe32 ) ) ) + return( DIGS_ERR_CANT_LOAD_MODULE ); + if( pe_hdr->opt.pe32.magic != 0x10B ) + return( DIGS_ERR_BAD_MODULE_FILE ); + /* + * Success, so next processing can continue! + */ + return( DIGS_OK ); +} + +static void *pe_get_proc_address( module modhdl, const char *proc_name ) +{ + unsigned i; + pe_export_directory *exports; + u_long funcOffset; + u_long *AddressTable; + u_long *NameTable; + u_short *OrdinalTable; + char *name; + + /* + * Find the address of the pexport tables from the pexport section + */ + exports = (pe_export_directory *)( modhdl->pexport + modhdl->exportDir ); + AddressTable = (u_long *)( modhdl->pexport + exports->address_table_rva - modhdl->exportBase ); + NameTable = (u_long *)( modhdl->pexport + exports->name_ptr_table_rva - modhdl->exportBase ); + OrdinalTable = (u_short *)( modhdl->pexport + exports->ordinal_table_rva - modhdl->exportBase ); + /* + * Search the pexport name table to find the function name + */ + for( i = 0; i < exports->num_name_ptrs; i++ ) { + name = (char *)( modhdl->pexport + NameTable[i] - modhdl->exportBase ); + if( strcmp( name, proc_name ) == 0 ) { + break; + } + } + if( i == exports->num_name_ptrs ) + return( NULL ); + funcOffset = AddressTable[OrdinalTable[i]]; + if( funcOffset == 0 ) + return( NULL ); + return( (void *)( modhdl->ptext + funcOffset - modhdl->textBase ) ); +} + +static void loader_unload_image( module modhdl ) +{ + /* + * Notify the Watcom Debugger of module load and let it remove symbolic info + */ +#ifdef WATCOM_DEBUG_SYMBOLS + if( modhdl->modname ) { + DebuggerUnloadUserModule( modhdl->modname ); + free( modhdl->modname ); + } +#endif + free( modhdl ); +} + +static digld_error loader_load_image( FILE *fp, char *filename, module *mod_hdl, void **init_func ) +{ + pe_exe_header pe_hdr; + pe_object secthdr; + u_long offset, pageOffset; + u_long text_raw_off, text_base, text_size, text_end; + u_long data_raw_off, data_base, data_size, data_virt_size, data_end; + u_long bss_raw_off, bss_base, bss_size, bss_end; + u_long import_raw_off, import_base, import_size, import_end; + u_long export_raw_off, export_base, export_size, export_end; + u_long reloc_raw_off, reloc_base = 0, reloc_size; + u_long image_base = 0, image_size, image_end; + u_char *image_ptr; + int i, delta, numFixups; + u_short relocType, *fixup; + module modhdl; + void *reloc = NULL; + pe_fixup_header *baseReloc; + digld_error err; + +#ifndef WATCOM_DEBUG_SYMBOLS + (void)filename; +#endif + + *mod_hdl = NULL; + /* + * Read the PE file headers from disk + */ + err = pe_read_header( fp, &pe_hdr ); + if( err != DIGS_OK ) + return( err ); + /* + * Scan all the section headers and find the necessary sections + */ + text_raw_off = text_base = text_size = text_end = 0; + data_raw_off = data_base = data_size = data_virt_size = data_end = 0; + bss_raw_off = bss_base = bss_size = bss_end = 0; + import_raw_off = import_base = import_size = import_end = 0; + export_raw_off = export_base = export_size = export_end = 0; + reloc_raw_off = reloc_size = 0; + err = DIGS_ERR_CANT_LOAD_MODULE; + for( i = 0; i < pe_hdr.fheader.num_objects; i++ ) { + if( DIGLoader( Read )( fp, §hdr, sizeof( secthdr ) ) ) + goto Error; + if( i == 0 ) + image_base = secthdr.rva; + if( strcmp( secthdr.name, ".edata" ) == 0 + || strcmp( secthdr.name, ".rdata" ) == 0 ) { + /* + * Exports section + */ + export_raw_off = secthdr.physical_offset; + export_base = secthdr.rva; + export_size = secthdr.physical_size; + export_end = export_base + export_size; + } else if( strcmp( secthdr.name, ".idata" ) == 0 ) { + /* + * Imports section + */ + import_raw_off = secthdr.physical_offset; + import_base = secthdr.rva; + import_size = secthdr.physical_size; + import_end = import_base + import_size; + } else if( strcmp( secthdr.name, ".reloc" ) == 0 ) { + /* + * Relocations section + */ + reloc_raw_off = secthdr.physical_offset; + reloc_base = secthdr.rva; + reloc_size = secthdr.physical_size; + } else if( text_raw_off == 0 + && (secthdr.flags & PE_OBJ_CODE) ) { + /* + * Code section + */ + text_raw_off = secthdr.physical_offset; + text_base = secthdr.rva; + text_size = secthdr.physical_size; + text_end = text_base + text_size; + } else if( data_raw_off == 0 + && (secthdr.flags & PE_OBJ_INIT_DATA) ) { + /* + * Data section + */ + data_raw_off = secthdr.physical_offset; + data_base = secthdr.rva; + data_size = secthdr.physical_size; + data_virt_size = secthdr.virtual_size; + data_end = data_base + data_size; + } else if( bss_raw_off == 0 + && (secthdr.flags & PE_OBJ_UNINIT_DATA) ) { + /* + * BSS data section + */ + bss_raw_off = secthdr.physical_offset; + bss_base = secthdr.rva; + bss_size = secthdr.physical_size; + bss_end = bss_base + bss_size; + } + } + /* + * Check to make sure that we have all the sections we need + */ + if( text_raw_off == 0 + || data_raw_off == 0 + || export_raw_off == 0 + || reloc_raw_off == 0 ) { + err = DIGS_ERR_BAD_MODULE_FILE; + goto Error; + } + /* + * Make sure the .reloc section is after everything else we load! + */ + image_end = bss_end; + if( image_end < data_end ) + image_end = data_end; + if( image_end < text_end ) + image_end = text_end; + if( image_end < import_end ) + image_end = import_end; + if( image_end < export_end ) + image_end = export_end; + if( reloc_base <= image_end ) { + err = DIGS_ERR_BAD_MODULE_FILE; + goto Error; + } + /* + * Find the size of the image sections to load and allocate memory for + * them. We only load section data up to the .reloc section, and then + * ignore everything else after that (eventually we might need to handle + * the .rsrc section separately). + */ + image_size = image_end - image_base; + modhdl = malloc( sizeof( *modhdl ) + image_size + _4K ); + reloc = malloc( reloc_size ); + if( modhdl == NULL + || reloc == NULL ) { + err = DIGS_ERR_OUT_OF_MEMORY; + goto Error; + } + /* + * Setup all the pointers into our loaded executeable image + */ + image_ptr = (u_char *)__ROUND_UP_SIZE_4K( (u_long)modhdl + sizeof( *modhdl ) ); + modhdl->pbase = image_ptr; + modhdl->ptext = image_ptr + ( text_base - image_base ); + modhdl->pdata = image_ptr + ( data_base - image_base ); + if( bss_base ) { + modhdl->pbss = image_ptr + ( bss_base - image_base ); + } else { + modhdl->pbss = NULL; + } + if( import_base ) { + modhdl->pimport = image_ptr + ( import_base - image_base ); + } else { + modhdl->pimport = NULL; + } + modhdl->pexport = image_ptr + ( export_base - image_base ); + modhdl->textBase = text_base; + modhdl->dataBase = data_base; + modhdl->bssBase = bss_base; + modhdl->importBase = import_base; + modhdl->exportBase = export_base; + modhdl->exportDir = pe_hdr.opt.pe32.table[PE_TBL_EXPORT].rva - export_base; + modhdl->modname = NULL; + /* + * Now read the section images from disk + */ + DIGLoader( Seek )( fp, text_raw_off, SEEK_SET ); + if( DIGLoader( Read )( fp, modhdl->ptext, text_size ) ) + goto Error; + DIGLoader( Seek )( fp, data_raw_off, SEEK_SET ); + if( data_virt_size ) { + /* + * Some linkers will put uninitalised data at the end + * of the primary data section, so we first must clear + * the data section to zeros for the entire length of + * virtual_size, which can be longer than the size on disk. + * Note also that some linkers set this value to zero, so + * we ignore this value in that case (those linkers also + * have a seperate BSS section). + */ + memset( modhdl->pdata, 0, data_virt_size ); + } + if( DIGLoader( Read )( fp, modhdl->pdata, data_size ) ) + goto Error; + if( import_base ) { + DIGLoader( Seek )( fp, import_raw_off, SEEK_SET ); + if( DIGLoader( Read )( fp, modhdl->pimport, import_size ) ) { + goto Error; + } + } + DIGLoader( Seek )( fp, export_raw_off, SEEK_SET ); + if( DIGLoader( Read )( fp, modhdl->pexport, export_size ) ) + goto Error; + DIGLoader( Seek )( fp, reloc_raw_off, SEEK_SET ); + if( DIGLoader( Read )( fp, reloc, reloc_size ) ) + goto Error; + /* + * Make sure the BSS section is cleared to zero if it exists + */ + if( modhdl->pbss ) + memset( modhdl->pbss, 0, bss_size ); + /* + * Now perform relocations on all sections in the image + */ + delta = (u_long)image_ptr - pe_hdr.opt.pe32.image_base - image_base; + baseReloc = (pe_fixup_header *)reloc; + for( ;; ) { + /* + * Check for termination condition + */ + if( baseReloc->page_rva == 0 + || baseReloc->block_size == 0 ) + break; + /* + * Do fixups + */ + numFixups = ( baseReloc->block_size - sizeof( pe_fixup_header ) ) / sizeof( u_short ); + fixup = (u_short *)( baseReloc + 1 ); + pageOffset = baseReloc->page_rva - image_base; + for( i = 0; i < numFixups; i++ ) { + relocType = *fixup >> 12; + if( relocType ) { + offset = pageOffset + ( *fixup & 0x0FFF ); + *(u_long *)( image_ptr + offset ) += delta; + } + fixup++; + } + /* + * Move to next relocation block + */ + baseReloc = (pe_fixup_header *)( (u_long)baseReloc + baseReloc->block_size ); + } +#ifdef __LINUX__ + /* + * On some platforms (such as AMD64 or x86 with NX bit), it is required + * to map the code pages loaded from the BPD as executable, otherwise + * a segfault will occur when attempting to run any BPD code. + */ + if( mprotect( (void *)image_ptr, image_size, PROT_READ | PROT_WRITE | PROT_EXEC ) != 0 ) + goto Error; +#endif + /* + * Clean up, close the file and return the loaded module handle + */ + free( reloc ); + /* + * Notify the Watcom Debugger of module load and let it load symbolic info + */ +#ifdef WATCOM_DEBUG_SYMBOLS + /* + * Store the file name in the modhdl structure; this must be the real + * file name where the debugger will try to load symbolic info from + */ + modhdl->modname = malloc( strlen( filename ) + 1 ); + if( modhdl->modname != NULL ) { + if( filename[1] == ':' ) { + strcpy( modhdl->modname, filename + 2 ); + } else { + strcpy( modhdl->modname, filename ); + } + DebuggerLoadUserModule( modhdl->modname, GetCS(), (u_long)modhdl->pbase ); + } +#endif + *init_func = pe_get_proc_address( modhdl, MODINIT ); + *mod_hdl = modhdl; + return( DIGS_OK ); + +Error: + loader_unload_image( modhdl ); + free( reloc ); + return( err ); +} + diff --git a/bld/dig/c/dsx/ldimp.c b/bld/dig/c/ldrrex.c similarity index 65% rename from bld/dig/c/dsx/ldimp.c rename to bld/dig/c/ldrrex.c index fcd52d95d9..73da57bbfb 100644 --- a/bld/dig/c/dsx/ldimp.c +++ b/bld/dig/c/ldrrex.c @@ -25,15 +25,16 @@ * * ======================================================================== * -* Description: Pharlap executable Loader (used by 32-bit code only) -* -* used also for TRAP/DIP/MAD load on Linux/QNX/OSX host OS -* until native shared libraries will be supported by OW +* Description: DIP/MAD/TRP module loader for Pharlap REX file format. * ****************************************************************************/ - /* + * Pharlap executable Loader (used by 32-bit code only) + * + * used also for TRAP/DIP/MAD load on Linux/QNX/OSX host OS + * until native shared libraries will be supported by OW + * * Usage of the Prarlap executable Loader * * Host OS TRAP MAD DIP @@ -44,22 +45,22 @@ * OSX - yes yes */ -#include -#include -#ifdef __LINUX__ -#include -#endif -#include "watcom.h" -#include "exephar.h" -#include "digcli.h" -#include "digld.h" -#include "roundmac.h" -#include "ldimp.h" - #define RELOC_BUFF_SIZE 64 -imp_header *ReadInImp( FILE *fp ) +typedef struct { +#ifdef __WATCOMC__ + unsigned_32 sig; +#endif + unsigned_8 init_rtn[1]; /* offset is start of routine */ +} *module; + +static void loader_unload_image( module modhdl ) +{ + DIGCli( Free )( modhdl ); +} + +static digld_error loader_load_image( FILE *fp, const char *filename, module *mod_hdl, void **init_func ) { simple_header hdr; unsigned image_size; @@ -70,22 +71,26 @@ imp_header *ReadInImp( FILE *fp ) unsigned i; unsigned_32 *fixup_loc; unsigned buff[RELOC_BUFF_SIZE]; - unsigned_8 *imp_start; + module modhdl; + + (void)filename; + (void)init_func; + *mod_hdl = NULL; if( DIGLoader( Read )( fp, &hdr, sizeof( hdr ) ) ) - return( NULL ); + return( DIGS_ERR_CANT_LOAD_MODULE ); if( hdr.signature != EXESIGN_REX ) - return( NULL ); + return( DIGS_ERR_BAD_MODULE_FILE ); hdr_size = hdr.hdr_size * 16; image_size = (hdr.file_size * 0x200) - (-hdr.mod_size & 0x1ff) - hdr_size; bss_size = hdr.min_data * _4K; - imp_start = DIGCli( Alloc )( image_size + bss_size ); - if( imp_start == NULL ) - return( NULL ); + modhdl = DIGCli( Alloc )( image_size + bss_size ); + if( modhdl == NULL ) + return( DIGS_ERR_OUT_OF_MEMORY ); DIGLoader( Seek )( fp, hdr_size, DIG_SEEK_ORG ); - if( DIGLoader( Read )( fp, imp_start, image_size ) ) { - DIGCli( Free )( imp_start ); - return( NULL ); + if( DIGLoader( Read )( fp, modhdl, image_size ) ) { + loader_unload_image( modhdl ); + return( DIGS_ERR_CANT_LOAD_MODULE ); } DIGLoader( Seek )( fp, hdr.reloc_offset, DIG_SEEK_ORG ); bunch = RELOC_BUFF_SIZE; @@ -96,12 +101,12 @@ imp_header *ReadInImp( FILE *fp ) reloc_size = bunch * sizeof( buff[0] ); } if( DIGLoader( Read )( fp, buff, reloc_size ) ) { - DIGCli( Free )( imp_start ); - return( NULL ); + loader_unload_image( modhdl ); + return( DIGS_ERR_CANT_LOAD_MODULE ); } for( i = 0; i < bunch; ++i ) { - fixup_loc = (void *)(imp_start + (buff[i] & ~0x80000000)); - *fixup_loc += (unsigned_32)imp_start; + fixup_loc = (void *)((char *)modhdl + (buff[i] & ~0x80000000)); + *fixup_loc += (unsigned_32)modhdl; } hdr.num_relocs -= bunch; } @@ -111,8 +116,14 @@ imp_header *ReadInImp( FILE *fp ) * to map the code pages loaded from the BPD as executable, otherwise * a segfault will occur when attempting to run any BPD code. */ - mprotect((void*)__ROUND_DOWN_SIZE_4K( (u_long)imp_start ), __ROUND_UP_SIZE_4K( image_size ), PROT_READ | PROT_WRITE | PROT_EXEC); + mprotect((void*)__ROUND_DOWN_SIZE_4K( (u_long)modhdl ), __ROUND_UP_SIZE_4K( image_size ), PROT_READ | PROT_WRITE | PROT_EXEC); +#endif + memset( (char *)modhdl + image_size, 0, bss_size ); +#ifdef __WATCOMC__ + *init_func = (modhdl->sig == MODSIG) ? modhdl->init_rtn : NULL; +#else + *init_func = modhdl->init_rtn; #endif - memset( imp_start + image_size, 0, bss_size ); - return( (imp_header *)imp_start ); + *mod_hdl = modhdl; + return( DIGS_OK ); } diff --git a/bld/dig/c/osx/ldimp.c b/bld/dig/c/ldrso.c similarity index 71% rename from bld/dig/c/osx/ldimp.c rename to bld/dig/c/ldrso.c index e3d2c5afdc..1aea846d0e 100644 --- a/bld/dig/c/osx/ldimp.c +++ b/bld/dig/c/ldrso.c @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -24,16 +25,25 @@ * * ======================================================================== * -* Description: Pharlap executable loader for OSX. +* Description: DIP/MAD/TRP module loader for shared library file format. * ****************************************************************************/ -#ifdef __WATCOMC__ +typedef void *module; -/* At this point OSX is sharing the Pharlap executable loader with 32-bit DOS. - * This is not the final solution (should be real ELF shared lib). - */ -#include "../dsx/ldimp.c" +static void loader_unload_image( module modhdl ) +{ + dlclose( modhdl ); +} -#endif +static digld_error loader_load_image( FILE *fp, char *filename, module *mod_hdl, void **init_func ) +{ + *mod_hdl = dlopen( filename, RTLD_NOW ); + if( *mod_hdl != NULL ) { + *init_func = dlsym( *mod_hdl, MODINIT ); + return( DIGS_OK ); + } +// puts( dlerror() ); + return( DIGS_ERR_CANT_LOAD_MODULE ); +} diff --git a/bld/dig/c/linux/dipld.c b/bld/dig/c/linux/dipld.c index 979da11d47..08ac91ed71 100644 --- a/bld/dig/c/linux/dipld.c +++ b/bld/dig/c/linux/dipld.c @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -24,21 +25,91 @@ * * ======================================================================== * -* Description: DIP module loader. +* Description: DIP module loader for Linux. * ****************************************************************************/ +#include +#include +#include +#ifdef __LINUX__ + #include +#endif #ifdef __WATCOMC__ + #include "watcom.h" + #include "exephar.h" +#else + #include +#endif +#include "digld.h" +#include "dip.h" +#include "dipimp.h" +#include "dipsys.h" +#include "roundmac.h" -/* At this point Linux is sharing the DIP loader with 32-bit DOS. This is - * not the final solution (should be real ELF shared lib). - */ -#include "../dsx/dipld.c" +#include "clibext.h" + + +#ifdef __WATCOMC__ + +#define DEFEXT ".dip" +#define MODSIG DIPSIGVAL +#include "../ldrrex.c" /* PharLap REX format loader */ #else -/* Use real shared libs when building with GCC */ -#include "dipld_so.c" +#define DEFEXT ".so" +#define MODINIT "DIPLOAD" +#include "../ldrso.c" /* Shared library format loader */ + +#endif + +void DIPSysUnload( dip_sys_handle *sys_hdl ) +{ + /* + * We should unload the symbols here but it's not worth the trouble + */ + if( *sys_hdl != NULL_SYSHDL ) { + loader_unload_image( *sys_hdl ); + *sys_hdl = NULL_SYSHDL; + } +} + +dip_status DIPSysLoad( const char *base_name, dip_client_routines *cli, dip_imp_routines **imp, dip_sys_handle *sys_hdl ) +{ + FILE *fp; + module modhdl; + dip_init_func *init_func; + dip_status status; + char filename[_MAX_PATH]; + digld_error err; + *sys_hdl = NULL_SYSHDL; + if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, 0, DEFEXT, filename, sizeof( filename ) ) == 0 ) { + return( DS_ERR | DS_FOPEN_FAILED ); + } + fp = DIGLoader( Open )( filename ); + if( fp == NULL ) { + return( DS_ERR | DS_FOPEN_FAILED ); + } + err = loader_load_image( fp, filename, &modhdl, (void **)&init_func ); + DIGLoader( Close )( fp ); + status = DS_ERR | DS_INVALID_DIP; + if( err != DIGS_OK ) { + return( status ); + } + if( init_func != NULL && (*imp = init_func( &status, cli )) != NULL ) { +#ifdef WATCOM_DEBUG_SYMBOLS + /* + * Look for symbols in separate .sym files, not the .dip itself + */ + strcpy( filename + strlen( filename ) - 4, ".sym" ); + DebuggerLoadUserModule( filename, GetCS(), (unsigned long)modhdl ); #endif + *sys_hdl = modhdl; + return( DS_OK ); + } + loader_unload_image( modhdl ); + return( status ); +} diff --git a/bld/dig/c/linux/dipld_so.c b/bld/dig/c/linux/dipld_so.c deleted file mode 100644 index 6d9a5f3a79..0000000000 --- a/bld/dig/c/linux/dipld_so.c +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** -* -* Open Watcom Project -* -* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. -* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. -* -* ======================================================================== -* -* This file contains Original Code and/or Modifications of Original -* Code as defined in and that are subject to the Sybase Open Watcom -* Public License version 1.0 (the 'License'). You may not use this file -* except in compliance with the License. BY USING THIS FILE YOU AGREE TO -* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is -* provided with the Original Code and Modifications, and is also -* available at www.sybase.com/developer/opensource. -* -* The Original Code and all software distributed under the License are -* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER -* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM -* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF -* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR -* NON-INFRINGEMENT. Please see the License for the specific language -* governing rights and limitations under the License. -* -* ======================================================================== -* -* Description: Load a DIP which is a UNIX shared library. -* -****************************************************************************/ - - -#include -#include -#include -#include "digld.h" -#include "dip.h" -#include "dipimp.h" -#include "dipsys.h" - -#include "clibext.h" - - -void DIPSysUnload( dip_sys_handle *sys_hdl ) -{ - if( *sys_hdl != NULL_SYSHDL ) { - dlclose( *sys_hdl ); - *sys_hdl = NULL_SYSHDL; - } -} - -dip_status DIPSysLoad( const char *base_name, dip_client_routines *cli, dip_imp_routines **imp, dip_sys_handle *sys_hdl ) -{ - dip_sys_handle mod_hdl; - dip_init_func *init_func; - char filename[_MAX_PATH]; - dip_status ds; - - *sys_hdl = NULL_SYSHDL; - if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, 0, ".so", filename, sizeof( filename ) ) == 0 ) { - return( DS_ERR | DS_FOPEN_FAILED ); - } - mod_hdl = dlopen( filename, RTLD_NOW ); - if( mod_hdl == NULL_SYSHDL ) { - return( DS_ERR | DS_FOPEN_FAILED ); - } - ds = DS_ERR | DS_INVALID_DIP; - init_func = (dip_init_func *)dlsym( mod_hdl, "DIPLOAD" ); - if( init_func != NULL && (*imp = init_func( &ds, cli )) != NULL ) { - *sys_hdl = mod_hdl; - return( DS_OK ); - } - DIPSysUnload( &mod_hdl ); - return( ds ); -} diff --git a/bld/dig/c/linux/ldimp.c b/bld/dig/c/linux/ldimp.c deleted file mode 100644 index db386b465e..0000000000 --- a/bld/dig/c/linux/ldimp.c +++ /dev/null @@ -1,39 +0,0 @@ -/**************************************************************************** -* -* Open Watcom Project -* -* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. -* -* ======================================================================== -* -* This file contains Original Code and/or Modifications of Original -* Code as defined in and that are subject to the Sybase Open Watcom -* Public License version 1.0 (the 'License'). You may not use this file -* except in compliance with the License. BY USING THIS FILE YOU AGREE TO -* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is -* provided with the Original Code and Modifications, and is also -* available at www.sybase.com/developer/opensource. -* -* The Original Code and all software distributed under the License are -* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER -* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM -* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF -* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR -* NON-INFRINGEMENT. Please see the License for the specific language -* governing rights and limitations under the License. -* -* ======================================================================== -* -* Description: Pharlap executable loader for Linux. -* -****************************************************************************/ - - -#ifdef __WATCOMC__ - -/* At this point Linux is sharing the Pharlap executable loader with 32-bit DOS. - * This is not the final solution (should be real ELF shared lib). - */ -#include "../dsx/ldimp.c" - -#endif diff --git a/bld/dig/c/linux/madld.c b/bld/dig/c/linux/madld.c index 92f7f5d35b..44a33556fe 100644 --- a/bld/dig/c/linux/madld.c +++ b/bld/dig/c/linux/madld.c @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -24,21 +25,81 @@ * * ======================================================================== * -* Description: MAD module loader. +* Description: MAD module loader for Linux. * ****************************************************************************/ +#include +#include +#include +#ifdef __LINUX__ + #include +#endif #ifdef __WATCOMC__ + #include "watcom.h" + #include "exephar.h" +#else + #include +#endif +#include "digld.h" +#include "mad.h" +#include "madimp.h" +#include "madcli.h" +#include "madsys.h" +#include "roundmac.h" -/* At this point Linux is sharing the DIP loader with 32-bit DOS. This is - * not the final solution (should be real ELF shared lib). - */ -#include "../dsx/madld.c" + +#ifdef __WATCOMC__ + +#define DEFEXT ".mad" +#define MODSIG MADSIGVAL +#include "../ldrrex.c" /* PharLap REX format loader */ #else -/* Use real shared libs when building with GCC */ -#include "madld_so.c" +#define DEFEXT ".so" +#define MODINIT "MADLOAD" +#include "../ldrso.c" /* Shared library format loader */ #endif + +void MADSysUnload( mad_sys_handle *sys_hdl ) +{ + if( *sys_hdl != NULL_SYSHDL ) { + loader_unload_image( *sys_hdl ); + *sys_hdl = NULL_SYSHDL; + } +} + +mad_status MADSysLoad( const char *base_name, mad_client_routines *cli, + mad_imp_routines **imp, mad_sys_handle *sys_hdl ) +{ + FILE *fp; + module modhdl; + mad_init_func *init_func; + mad_status status; + char filename[256]; + digld_error err; + + *sys_hdl = NULL_SYSHDL; + if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, 0, DEFEXT, filename, sizeof( filename ) ) == 0 ) { + return( MS_ERR | MS_FOPEN_FAILED ); + } + fp = DIGLoader( Open )( filename ); + if( fp == NULL ) { + return( MS_ERR | MS_FOPEN_FAILED ); + } + err = loader_load_image( fp, filename, &modhdl, (void **)&init_func ); + DIGLoader( Close )( fp ); + status = MS_ERR | MS_INVALID_MAD; + if( err != DIGS_OK ) { + return( status ); + } + if( init_func != NULL && (*imp = init_func( &status, cli )) != NULL ) { + *sys_hdl = modhdl; + return( MS_OK ); + } + loader_unload_image( modhdl ); + return( status ); +} diff --git a/bld/dig/c/linux/madld_so.c b/bld/dig/c/linux/madld_so.c deleted file mode 100644 index c2f1696ff7..0000000000 --- a/bld/dig/c/linux/madld_so.c +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -* -* Open Watcom Project -* -* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. -* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. -* -* ======================================================================== -* -* This file contains Original Code and/or Modifications of Original -* Code as defined in and that are subject to the Sybase Open Watcom -* Public License version 1.0 (the 'License'). You may not use this file -* except in compliance with the License. BY USING THIS FILE YOU AGREE TO -* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is -* provided with the Original Code and Modifications, and is also -* available at www.sybase.com/developer/opensource. -* -* The Original Code and all software distributed under the License are -* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER -* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM -* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF -* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR -* NON-INFRINGEMENT. Please see the License for the specific language -* governing rights and limitations under the License. -* -* ======================================================================== -* -* Description: Load a MAD which is a UNIX shared library. -* -****************************************************************************/ - - -#include -#include -#include -#include "digld.h" -#include "mad.h" -#include "madimp.h" -#include "madcli.h" -#include "madsys.h" - -#include "clibext.h" - - -void MADSysUnload( mad_sys_handle *sys_hdl ) -{ - if( *sys_hdl != NULL_SYSHDL ) { - dlclose( *sys_hdl ); - *sys_hdl = NULL_SYSHDL; - } -} - -mad_status MADSysLoad( const char *base_name, mad_client_routines *cli, mad_imp_routines **imp, mad_sys_handle *sys_hdl ) -{ - mad_sys_handle mod_hdl; - mad_init_func *init_func; - char filename[_MAX_PATH]; - mad_status status; - - *sys_hdl = NULL_SYSHDL; - if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, 0, ".so", filename, sizeof( filename ) ) == 0 ) { - return( MS_ERR | MS_FOPEN_FAILED ); - } - mod_hdl = dlopen( filename, RTLD_NOW ); - if( mod_hdl == NULL ) { - return( MS_ERR | MS_FOPEN_FAILED ); - } - status = MS_ERR | MS_INVALID_MAD; - init_func = (mad_init_func *)dlsym( mod_hdl, "MADLOAD" ); - if( init_func != NULL && (*imp = init_func( &status, cli )) != NULL ) { - *sys_hdl = mod_hdl; - return( MS_OK ); - } - MADSysUnload( &mod_hdl ); - return( status ); -} diff --git a/bld/dig/c/linux/peloader.c b/bld/dig/c/linux/peloader.c deleted file mode 100644 index 1e1b6ed547..0000000000 --- a/bld/dig/c/linux/peloader.c +++ /dev/null @@ -1,600 +0,0 @@ -/**************************************************************************** -* -* Open Watcom Project -* -* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. -* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. -* -* ======================================================================== -* -* This file contains Original Code and/or Modifications of Original -* Code as defined in and that are subject to the Sybase Open Watcom -* Public License version 1.0 (the 'License'). You may not use this file -* except in compliance with the License. BY USING THIS FILE YOU AGREE TO -* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is -* provided with the Original Code and Modifications, and is also -* available at www.sybase.com/developer/opensource. -* -* The Original Code and all software distributed under the License are -* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER -* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM -* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF -* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR -* NON-INFRINGEMENT. Please see the License for the specific language -* governing rights and limitations under the License. -* -* ======================================================================== -* -* Description: Module to implement a simple Portable Binary DLL loader -* library. This library can be used to load PE DLL's under -* any Intel based OS, provided the DLL's do not have any -* imports in the import table. -* -* NOTE: This loader module expects the DLL's to be built with -* Watcom C++ and may produce unexpected results with -* DLL's linked by another compiler. -* -****************************************************************************/ - -#include "peloader.h" -#include "exepe.h" -#include -#include -#include "bool.h" -#include "exedos.h" -#include "dbgmod.h" -#include "roundmac.h" - -/*--------------------------- Global variables ----------------------------*/ - - -static int result = PE_ok; - -/*------------------------- Implementation --------------------------------*/ - -/**************************************************************************** -PARAMETERS: -f - Handle to open file to read driver from -startOffset - Offset to the start of the driver within the file - -RETURNS: -Handle to loaded PE DLL, or NULL on failure. - -REMARKS: -This function loads a Portable Binary DLL library from disk, relocates -the code and returns a handle to the loaded library. This function is the -same as the regular PE_loadLibrary except that it take a handle to an -open file and an offset within that file for the DLL to load. -****************************************************************************/ -static bool PE_readHeader( - FILE *fp, - long startOffset, - pe_file_header *filehdr, - pe32_opt_header *opthdr) -{ - dos_exe_header exehdr; - u_long ne_header_off; - u_long signature; - - /* - * Read the EXE header and check for valid header signature - */ - result = PE_invalidDLLImage; - if( DIGLoader( Seek )( fp, startOffset, SEEK_SET ) - || DIGLoader( Read )( fp, &exehdr, sizeof( exehdr ) ) - || ( exehdr.signature != EXESIGN_DOS ) - || !NE_HEADER_FOLLOWS( exehdr.reloc_offset ) ) - return( false ); - /* - * Now seek to the start of the PE header defined at offset 0x3C - * in the MS-DOS EXE header, and read the signature and check it. - */ - if( DIGLoader( Seek )( fp, startOffset + NE_HEADER_OFFSET, SEEK_SET ) - || DIGLoader( Read )( fp, &ne_header_off, sizeof( ne_header_off ) ) ) - return( false ); - if( DIGLoader( Seek )( fp, startOffset + ne_header_off, SEEK_SET ) - || DIGLoader( Read )( fp, &signature, sizeof( signature ) ) - || signature != EXESIGN_PE ) - return( false ); - /* - * Now read the PE file header and check that it is correct - */ - if( DIGLoader( Read )( fp, filehdr, sizeof( *filehdr ) ) ) - return( false ); - if( filehdr->cpu_type != PE_CPU_386 ) - return( false ); - if( (filehdr->flags & PE_FLG_32BIT_MACHINE) == 0 ) - return( false ); - if( (filehdr->flags & PE_FLG_LIBRARY) == 0 ) - return( false ); - if( DIGLoader( Read )( fp, opthdr, sizeof( *opthdr ) ) ) - return( false ); - if( opthdr->magic != 0x10B ) - return( false ); - /* - * Success, so return true! - */ - return( true ); -} - -/**************************************************************************** -DESCRIPTION: -Find the actual size of a PE file image - -HEADER: -peloader.h - -PARAMETERS: -f - Handle to open file to read driver from -startOffset - Offset to the start of the driver within the file - -RETURNS: -Size of the DLL file on disk, or -1 on error - -REMARKS: -This function scans the headers for a Portable Binary DLL to determine the -length of the DLL file on disk. -****************************************************************************/ -u_long PE_getFileSize( FILE *fp, u_long startOffset ) -{ - pe_file_header filehdr; - pe32_opt_header opthdr; - pe_object secthdr; - u_long size; - int i; - - /* - * Read the PE file headers from disk - */ - if( !PE_readHeader( fp, startOffset, &filehdr, &opthdr ) ) - return( 0xFFFFFFFF ); - /* - * Scan all the section headers summing up the total size - */ - size = opthdr.headers_size; - for( i = 0; i < filehdr.num_objects; i++ ) { - if( DIGLoader( Read )( fp, §hdr, sizeof( secthdr ) ) ) - return( 0xFFFFFFFF ); - if( (secthdr.flags & PE_OBJ_UNINIT_DATA) == 0 ) { - size += secthdr.physical_size; - } - } - return( size ); -} - -/**************************************************************************** -DESCRIPTION: -Loads a Portable Binary DLL into memory from an open file - -HEADER: -peloader.h - -PARAMETERS: -f - Handle to open file to read driver from -startOffset - Offset to the start of the driver within the file -size - Place to store the size of the driver loaded - -RETURNS: -Handle to loaded PE DLL, or NULL on failure. - -REMARKS: -This function loads a Portable Binary DLL library from disk, relocates -the code and returns a handle to the loaded library. This function is the -same as the regular PE_loadLibrary except that it take a handle to an -open file and an offset within that file for the DLL to load. - -SEE ALSO: -PE_loadLibrary, PE_getProcAddress, PE_freeLibrary -****************************************************************************/ -PE_MODULE * PE_loadLibraryExt( - FILE *fp, - u_long startOffset, - u_long *size) -{ - pe_file_header filehdr; - pe32_opt_header opthdr; - pe_object secthdr; - u_long offset, pageOffset; - u_long text_raw_off, text_base, text_size, text_end; - u_long data_raw_off, data_base, data_size, data_virt_size, data_end; - u_long bss_raw_off, bss_base, bss_size, bss_end; - u_long import_raw_off, import_base, import_size, import_end; - u_long export_raw_off, export_base, export_size, export_end; - u_long reloc_raw_off, reloc_base = 0, reloc_size; - u_long image_base = 0, image_size, image_end; - u_char *image_ptr; - int i, delta, numFixups; - u_short relocType, *fixup; - PE_MODULE *hMod = NULL; - void *reloc = NULL; - pe_fixup_header *baseReloc; - - /* - * Read the PE file headers from disk - */ - if( !PE_readHeader( fp, startOffset, &filehdr, &opthdr ) ) - return( NULL ); - /* - * Scan all the section headers and find the necessary sections - */ - text_raw_off = text_base = text_size = text_end = 0; - data_raw_off = data_base = data_size = data_virt_size = data_end = 0; - bss_raw_off = bss_base = bss_size = bss_end = 0; - import_raw_off = import_base = import_size = import_end = 0; - export_raw_off = export_base = export_size = export_end = 0; - reloc_raw_off = reloc_size = 0; - for( i = 0; i < filehdr.num_objects; i++ ) { - if( DIGLoader( Read )( fp, §hdr, sizeof( secthdr ) ) ) - goto Error; - if( i == 0 ) - image_base = secthdr.rva; - if( strcmp( secthdr.name, ".edata" ) == 0 || strcmp( secthdr.name, ".rdata" ) == 0 ) { - /* - * Exports section - */ - export_raw_off = secthdr.physical_offset; - export_base = secthdr.rva; - export_size = secthdr.physical_size; - export_end = export_base + export_size; - } else if( strcmp( secthdr.name, ".idata" ) == 0 ) { - /* - * Imports section - */ - import_raw_off = secthdr.physical_offset; - import_base = secthdr.rva; - import_size = secthdr.physical_size; - import_end = import_base + import_size; - } else if( strcmp( secthdr.name, ".reloc" ) == 0 ) { - /* - * Relocations section - */ - reloc_raw_off = secthdr.physical_offset; - reloc_base = secthdr.rva; - reloc_size = secthdr.physical_size; - } else if( text_raw_off == 0 && (secthdr.flags & PE_OBJ_CODE) ) { - /* - * Code section - */ - text_raw_off = secthdr.physical_offset; - text_base = secthdr.rva; - text_size = secthdr.physical_size; - text_end = text_base + text_size; - } else if( data_raw_off == 0 && (secthdr.flags & PE_OBJ_INIT_DATA) ) { - /* - * Data section - */ - data_raw_off = secthdr.physical_offset; - data_base = secthdr.rva; - data_size = secthdr.physical_size; - data_virt_size = secthdr.virtual_size; - data_end = data_base + data_size; - } else if( bss_raw_off == 0 && (secthdr.flags & PE_OBJ_UNINIT_DATA) ) { - /* - * BSS data section - */ - bss_raw_off = secthdr.physical_offset; - bss_base = secthdr.rva; - bss_size = secthdr.physical_size; - bss_end = bss_base + bss_size; - } - } - /* - * Check to make sure that we have all the sections we need - */ - if( text_raw_off == 0 || data_raw_off == 0 || export_raw_off == 0 || reloc_raw_off == 0 ) { - result = PE_invalidDLLImage; - goto Error; - } - /* - * Make sure the .reloc section is after everything else we load! - */ - image_end = bss_end; - if( image_end < data_end ) - image_end = data_end; - if( image_end < text_end ) - image_end = text_end; - if( image_end < import_end ) - image_end = import_end; - if( image_end < export_end ) - image_end = export_end; - if( reloc_base <= image_end ) { - result = PE_unknownImageFormat; - goto Error; - } - /* - * Find the size of the image sections to load and allocate memory for - * them. We only load section data up to the .reloc section, and then - * ignore everything else after that (eventually we might need to handle - * the .rsrc section separately). - */ - image_size = image_end - image_base; - *size = sizeof( PE_MODULE ) + image_size + _4K; - hMod = malloc( *size ); - reloc = malloc( reloc_size ); - if( hMod == NULL || reloc == NULL ) { - result = PE_outOfMemory; - goto Error; - } - /* - * Setup all the pointers into our loaded executeable image - */ - image_ptr = (u_char *)__ROUND_UP_SIZE_4K( (u_long)hMod + sizeof( PE_MODULE ) ); - hMod->pbase = image_ptr; - hMod->ptext = image_ptr + ( text_base - image_base ); - hMod->pdata = image_ptr + ( data_base - image_base ); - if( bss_base ) { - hMod->pbss = image_ptr + ( bss_base - image_base ); - } else { - hMod->pbss = NULL; - } - if( import_base ) { - hMod->pimport = image_ptr + ( import_base - image_base ); - } else { - hMod->pimport = NULL; - } - hMod->pexport = image_ptr + ( export_base - image_base ); - hMod->textBase = text_base; - hMod->dataBase = data_base; - hMod->bssBase = bss_base; - hMod->importBase = import_base; - hMod->exportBase = export_base; - hMod->exportDir = opthdr.table[PE_TBL_EXPORT].rva - export_base; - hMod->modname = NULL; - /* - * Now read the section images from disk - */ - result = PE_invalidDLLImage; - DIGLoader( Seek )( fp, startOffset + text_raw_off, SEEK_SET ); - if( DIGLoader( Read )( fp, hMod->ptext, text_size ) ) - goto Error; - DIGLoader( Seek )( fp, startOffset + data_raw_off, SEEK_SET ); - if( data_virt_size ) { - /* - * Some linkers will put uninitalised data at the end - * of the primary data section, so we first must clear - * the data section to zeros for the entire length of - * virtual_size, which can be longer than the size on disk. - * Note also that some linkers set this value to zero, so - * we ignore this value in that case (those linkers also - * have a seperate BSS section). - */ - memset( hMod->pdata, 0, data_virt_size ); - } - if( DIGLoader( Read )( fp, hMod->pdata, data_size ) ) - goto Error; - if( import_base ) { - DIGLoader( Seek )( fp, startOffset + import_raw_off, SEEK_SET ); - if( DIGLoader( Read )( fp, hMod->pimport, import_size ) ) { - goto Error; - } - } - DIGLoader( Seek )( fp, startOffset + export_raw_off, SEEK_SET ); - if( DIGLoader( Read )( fp, hMod->pexport, export_size ) ) - goto Error; - DIGLoader( Seek )( fp, startOffset + reloc_raw_off, SEEK_SET ); - if( DIGLoader( Read )( fp, reloc, reloc_size ) ) - goto Error; - /* - * Make sure the BSS section is cleared to zero if it exists - */ - if( hMod->pbss ) - memset( hMod->pbss, 0, bss_size ); - /* - * Now perform relocations on all sections in the image - */ - delta = (u_long)image_ptr - opthdr.image_base - image_base; - baseReloc = (pe_fixup_header *)reloc; - for( ;; ) { - /* - * Check for termination condition - */ - if( baseReloc->page_rva == 0 || baseReloc->block_size == 0 ) - break; - /* - * Do fixups - */ - numFixups = ( baseReloc->block_size - sizeof( pe_fixup_header ) ) / sizeof( u_short ); - fixup = (u_short*)( baseReloc + 1 ); - pageOffset = baseReloc->page_rva - image_base; - for( i = 0; i < numFixups; i++ ) { - relocType = *fixup >> 12; - if( relocType ) { - offset = pageOffset + ( *fixup & 0x0FFF ); - *(u_long*)( image_ptr + offset ) += delta; - } - fixup++; - } - /* - * Move to next relocation block - */ - baseReloc = (pe_fixup_header*)( (u_long)baseReloc + baseReloc->block_size ); - } - /* - * On some platforms (such as AMD64 or x86 with NX bit), it is required - * to map the code pages loaded from the BPD as executable, otherwise - * a segfault will occur when attempting to run any BPD code. - */ - if( mprotect( (void*)image_ptr, image_size, PROT_READ | PROT_WRITE | PROT_EXEC ) != 0 ) - goto Error; - /* - * Clean up, close the file and return the loaded module handle - */ - free( reloc ); - result = PE_ok; - return( hMod ); - -Error: - free( hMod ); - free( reloc ); - return( NULL ); -} - -/**************************************************************************** -DESCRIPTION: -Loads a Portable Binary DLL into memory - -HEADER: -peloader.h - -PARAMETERS: -fd - File descriptor to load PE module from -szDLLName - Name of the PE DLL library to load (for debug symbols) - -RETURNS: -Handle to loaded PE DLL, or NULL on failure. - -REMARKS: -Same as above but for an open file handle. szDLLName must be correct in -order to load debug symbols under the debugger. -****************************************************************************/ -PE_MODULE * PE_loadLibraryFile( FILE *fp, const char *szDLLName ) -{ - PE_MODULE *hMod; - u_long size; - -#ifndef WATCOM_DEBUG_SYMBOLS - /* unused parameters */ (void)szDLLName; -#endif - - if( fp == NULL ) { - result = PE_fileNotFound; - return( NULL ); - } - hMod = PE_loadLibraryExt( fp, 0, &size ); - /* - * Notify the Watcom Debugger of module load and let it load symbolic info - */ -#ifdef WATCOM_DEBUG_SYMBOLS - if( hMod != NULL ) { - u_long size; - char *modname; - - /* - * Store the file name in the hMod structure; this must be the real - * file name where the debugger will try to load symbolic info from - */ - size = strlen( szDLLName ) + 1; - modname = malloc( size ); - if( modname != NULL ) { - if( szDLLName[1] == ':' ) { - strcpy( modname, szDLLName + 2 ); - } else { - strcpy( modname, szDLLName ); - } - hMod->modname = modname; - DebuggerLoadUserModule( hMod->modname, GetCS(), (u_long)hMod->pbase ); - } - } -#endif - return( hMod ); -} - -/**************************************************************************** -DESCRIPTION: -Gets a function address from a Portable Binary DLL - -HEADER: -peloader.h - -PARAMETERS: -hModule - Handle to a loaded PE DLL library -szProcName - Name of the function to get the address of - -RETURNS: -Pointer to the function, or NULL on failure. - -REMARKS: -This function searches for the named, exported function in a loaded PE -DLL library, and returns the address of the function. If the function is -not found in the library, this function return NULL. - -SEE ALSO: -PE_loadLibrary, PE_freeLibrary -****************************************************************************/ -void * PE_getProcAddress( - PE_MODULE *hModule, - const char *szProcName ) -{ - unsigned i; - pe_export_directory *exports; - u_long funcOffset; - u_long *AddressTable; - u_long *NameTable; - u_short *OrdinalTable; - char *name; - - /* - * Find the address of the pexport tables from the pexport section - */ - if( hModule == NULL ) - return( NULL ); - exports = (pe_export_directory *)( hModule->pexport + hModule->exportDir ); - AddressTable = (u_long *)( hModule->pexport + exports->address_table_rva - hModule->exportBase ); - NameTable = (u_long*)( hModule->pexport + exports->name_ptr_table_rva - hModule->exportBase ); - OrdinalTable = (u_short*)( hModule->pexport + exports->ordinal_table_rva - hModule->exportBase ); - /* - * Search the pexport name table to find the function name - */ - for( i = 0; i < exports->num_name_ptrs; i++ ) { - name = (char*)( hModule->pexport + NameTable[i] - hModule->exportBase ); - if( strcmp( name, szProcName ) == 0 ) { - break; - } - } - if( i == exports->num_name_ptrs ) - return( NULL ); - funcOffset = AddressTable[OrdinalTable[i]]; - if( funcOffset == 0 ) - return( NULL ); - return( (void*)( hModule->ptext + funcOffset - hModule->textBase ) ); -} - -/**************************************************************************** -DESCRIPTION: -Frees a loaded Portable Binary DLL - -HEADER: -peloader.h - -PARAMETERS: -hModule - Handle to a loaded PE DLL library to free - -REMARKS: -This function frees a loaded PE DLL library from memory. - -SEE ALSO: -PE_getProcAddress, PE_loadLibrary -****************************************************************************/ -void PE_freeLibrary( PE_MODULE *hModule ) -{ - if( hModule != NULL ) { - /* - * Notify the Watcom Debugger of module load and let it remove symbolic info - */ -#ifdef WATCOM_DEBUG_SYMBOLS - if( hModule->modname ) { - DebuggerUnloadUserModule( hModule->modname ); - free( hModule->modname ); - } -#endif - free( hModule ); - } -} - -/**************************************************************************** -DESCRIPTION: -Returns the error code for the last operation - -HEADER: -peloader.h - -RETURNS: -Error code for the last operation. - -SEE ALSO: -PE_getProcAddress, PE_loadLibrary -****************************************************************************/ -int PE_getError( void ) -{ - return( result ); -} diff --git a/bld/dig/c/linux/peloader.h b/bld/dig/c/linux/peloader.h deleted file mode 100644 index b4cd992819..0000000000 --- a/bld/dig/c/linux/peloader.h +++ /dev/null @@ -1,117 +0,0 @@ -/**************************************************************************** -* -* Open Watcom Project -* -* Copyright (c) 2023 2023 The Open Watcom Contributors. All Rights Reserved. -* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. -* -* ======================================================================== -* -* This file contains Original Code and/or Modifications of Original -* Code as defined in and that are subject to the Sybase Open Watcom -* Public License version 1.0 (the 'License'). You may not use this file -* except in compliance with the License. BY USING THIS FILE YOU AGREE TO -* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is -* provided with the Original Code and Modifications, and is also -* available at www.sybase.com/developer/opensource. -* -* The Original Code and all software distributed under the License are -* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER -* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM -* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF -* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR -* NON-INFRINGEMENT. Please see the License for the specific language -* governing rights and limitations under the License. -* -* ======================================================================== -* -* Description: Header file for the simple Portable Executeable DLL loader -* library. This library can be used to load PE DLL's under -* any Intel based OS, provided the DLL's do not have any -* imports in the import table. -* -* NOTE: This loader module expects the DLL's to be built with -* Watcom C++ and may produce unexpected results with -* DLL's linked by another compiler. -* -****************************************************************************/ - -#ifndef __PELOADER_H -#define __PELOADER_H - -#include -#include -#include -#include -#include -#include "watcom.h" - -/*---------------------- Macros and type definitions ----------------------*/ - - -/**************************************************************************** -REMARKS: -Structure of a module handle when loaded from disk -{secret} -****************************************************************************/ -#include "pushpck1.h" - -typedef struct { - u_char *pbase; /* Base of image in memory */ - u_char *ptext; /* Text section read from disk */ - u_char *pdata; /* Data section read from disk */ - u_char *pbss; /* BSS section read */ - u_char *pimport; /* Import section read from disk */ - u_char *pexport; /* Export section read from disk */ - u_long textBase; /* Base of text section in image */ - u_long dataBase; /* Base of data section in image */ - u_long bssBase; /* Base of BSS data section in image */ - u_long importBase; /* Offset of import section in image */ - u_long exportBase; /* Offset of export section in image */ - u_long exportDir; /* Offset of export directory */ - char *modname; /* Filename of the image */ -} PE_MODULE; - -/**************************************************************************** -REMARKS: -Defines the error codes returned by the library - -HEADER: -drvlib/peloader.h - -MEMBERS: -PE_ok - No error -PE_fileNotFound - DLL file not found -PE_outOfMemory - Out of memory loading DLL -PE_invalidDLLImage - DLL image is invalid or corrupted -PE_unknownImageFormat - DLL image is in a format that is not supported -****************************************************************************/ -typedef enum { - PE_ok, - PE_fileNotFound, - PE_outOfMemory, - PE_invalidDLLImage, - PE_unknownImageFormat -} PE_errorCodes; - -#include "poppck.h" - -/*------------------------- Function Prototypes ---------------------------*/ - -#ifdef __cplusplus -extern "C" { /* Use "C" linkage when in C++ mode */ -#endif - -u_long PE_getFileSize( FILE *fp, u_long startOffset); -PE_MODULE *PE_loadLibraryExt( FILE *fp, u_long offset, u_long *size ); -PE_MODULE *PE_loadLibraryFile( FILE *fp, const char *szDLLName ); -void *PE_getProcAddress( PE_MODULE *hModule, const char *szProcName ); -void PE_freeLibrary( PE_MODULE *hModule ); -int PE_getError( void ); - -#ifdef __cplusplus -} /* End of "C" linkage for C++ */ -#endif /* __cplusplus */ - -#endif /* __PELOADER_H */ - diff --git a/bld/dig/c/linux/trpld.c b/bld/dig/c/linux/trpld.c index edf044ebc9..246cf3b7a7 100644 --- a/bld/dig/c/linux/trpld.c +++ b/bld/dig/c/linux/trpld.c @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -24,24 +25,165 @@ * * ======================================================================== * -* Description: Debugger trap file module loader. +* Description: Trap module loader for Linux. * ****************************************************************************/ +//#define REX + +#include +#include +#include +#include +#ifdef __LINUX__ + #include +#endif #ifdef __WATCOMC__ +#ifdef REX + #include "watcom.h" + #include "exephar.h" +#else + #include "watcom.h" + #include "exepe.h" + #include "exedos.h" +#endif +#else + #include +#endif +#include "digcli.h" +#include "trpld.h" +#include "roundmac.h" + +#include "clibext.h" -/* At this point Linux is using trap files which are PE DLLs. This is - * not the final solution (should be real ELF shared lib). - */ -#include "trpld_pe.c" -#ifndef BUILTIN_TRAP_FILE -#include "peloader.c" + +#ifndef __WATCOMC__ +extern char **environ; #endif +static trap_fini_func *FiniFunc = NULL; + +const static trap_callbacks TrapCallbacks = { + sizeof( trap_callbacks ), + + &environ, + NULL, + + malloc, + realloc, + free, + getenv, + signal, +}; + +#if !defined( BUILTIN_TRAP_FILE ) + +#ifdef __WATCOMC__ + +#ifdef REX + +#define DEFEXT ".trp" +#define MODSIG TRAPSIGVAL +#include "../ldrrex.c" /* PharLap REX format loader */ + #else -/* Use real shared libs when building with GCC */ -#include "trpld_so.c" +#define DEFEXT ".trp" +#define MODINIT "TrapLoad_" +#include "../ldrpe.c" /* PE DLL format loader */ #endif + +#else + +#define DEFEXT ".so" +#define MODINIT "TrapLoad" +#include "../ldrso.c" /* Shared library format loader */ + +#endif + +static module modhdl = NULL; + +#endif + +void UnLoadTrap( void ) +{ + ReqFunc = NULL; + if( FiniFunc != NULL ) { + FiniFunc(); + FiniFunc = NULL; + } +#if !defined( BUILTIN_TRAP_FILE ) + if( modhdl != NULL ) { + loader_unload_image( modhdl ); + modhdl = NULL; + } +#endif +} + +digld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) +{ + FILE *fp; + trap_load_func *ld_func; + const trap_requests *trap_funcs; + digld_error err; +#if !defined( BUILTIN_TRAP_FILE ) + char filename[_MAX_PATH]; + const char *base_name; + size_t len; +#endif + + if( parms == NULL || *parms == '\0' ) + parms = DEFAULT_TRP_NAME; +#if !defined( BUILTIN_TRAP_FILE ) + modhdl = NULL; + base_name = parms; + len = 0; +#endif + for( ; *parms != '\0'; parms++ ) { + if( *parms == TRAP_PARM_SEPARATOR ) { + parms++; + break; + } +#if !defined( BUILTIN_TRAP_FILE ) + len++; +#endif + } +#if !defined( BUILTIN_TRAP_FILE ) + if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, len, DEFEXT, filename, sizeof( filename ) ) == 0 ) { + return( DIGS_ERR_CANT_FIND_MODULE ); + } + fp = DIGLoader( Open )( filename ); + if( fp == NULL ) { + return( DIGS_ERR_CANT_LOAD_MODULE ); + } + err = loader_load_image( fp, filename, &modhdl, (void **)&ld_func ); + DIGLoader( Close )( fp ); + if( err != DIGS_OK ) { + return( err ); + } + trap_funcs = ((ld_func != NULL) ? ld_func( &TrapCallbacks ) : NULL); +#else + trap_funcs = TrapLoad( &TrapCallbacks ); +#endif + err = DIGS_ERR_BAD_MODULE_FILE; + if( trap_funcs != NULL ) { + *trap_ver = trap_funcs->init_func( parms, buff, trap_ver->remote ); + FiniFunc = trap_funcs->fini_func; + ReqFunc = trap_funcs->req_func; + err = DIGS_ERR_BUF; + if( buff[0] == '\0' ) { + if( TrapVersionOK( *trap_ver ) ) { + TrapVer = *trap_ver; + return( DIGS_OK ); + } + err = DIGS_ERR_WRONG_MODULE_VERSION; + } + } +#if !defined( BUILTIN_TRAP_FILE ) + loader_unload_image( modhdl ); + modhdl = NULL; +#endif + return( err ); +} diff --git a/bld/dig/c/linux/trpld_pe.c b/bld/dig/c/linux/trpld_pe.c deleted file mode 100644 index bf42237117..0000000000 --- a/bld/dig/c/linux/trpld_pe.c +++ /dev/null @@ -1,138 +0,0 @@ -/**************************************************************************** -* -* Open Watcom Project -* -* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. -* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. -* -* ======================================================================== -* -* This file contains Original Code and/or Modifications of Original -* Code as defined in and that are subject to the Sybase Open Watcom -* Public License version 1.0 (the 'License'). You may not use this file -* except in compliance with the License. BY USING THIS FILE YOU AGREE TO -* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is -* provided with the Original Code and Modifications, and is also -* available at www.sybase.com/developer/opensource. -* -* The Original Code and all software distributed under the License are -* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER -* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM -* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF -* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR -* NON-INFRINGEMENT. Please see the License for the specific language -* governing rights and limitations under the License. -* -* ======================================================================== -* -* Description: Linux module to load debugger trap files. -* -****************************************************************************/ - - -#include -#include -#include -#include "trpld.h" -#include "peloader.h" - - -#ifndef __WATCOMC__ -extern char **environ; -#endif - -#if !defined( BUILTIN_TRAP_FILE ) -static PE_MODULE *mod_hdl = NULL; -#endif -static trap_fini_func *FiniFunc = NULL; - -const static trap_callbacks TrapCallbacks = { - sizeof( trap_callbacks ), - - &environ, - NULL, - - malloc, - realloc, - free, - getenv, - signal, -}; - -void UnLoadTrap( void ) -{ - ReqFunc = NULL; - if( FiniFunc != NULL ) { - FiniFunc(); - FiniFunc = NULL; - } -#if !defined( BUILTIN_TRAP_FILE ) - if( mod_hdl != NULL ) { - PE_freeLibrary( mod_hdl ); - mod_hdl = NULL; - } -#endif -} - -digld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) -{ - trap_load_func *ld_func; - const trap_requests *trap_funcs; - digld_error err; -#if !defined( BUILTIN_TRAP_FILE ) - FILE *fp; - char filename[_MAX_PATH]; - const char *base_name; - size_t len; -#endif - - if( parms == NULL || *parms == '\0' ) - parms = DEFAULT_TRP_NAME; -#if !defined( BUILTIN_TRAP_FILE ) - base_name = parms; - len = 0; -#endif - for( ; *parms != '\0'; parms++ ) { - if( *parms == TRAP_PARM_SEPARATOR ) { - parms++; - break; - } -#if !defined( BUILTIN_TRAP_FILE ) - len++; -#endif - } -#if !defined( BUILTIN_TRAP_FILE ) - if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, len, ".trp", filename, sizeof( filename ) ) == 0 ) { - return( DIGS_ERR_CANT_FIND_MODULE ); - } - fp = DIGLoader( Open )( filename ); - if( fp == NULL ) { - return( DIGS_ERR_CANT_LOAD_MODULE ); - } - mod_hdl = PE_loadLibraryFile( fp, filename ); - DIGLoader( Close )( fp ); - if( mod_hdl == NULL ) { - return( DIGS_ERR_CANT_LOAD_MODULE ); - } - ld_func = (trap_load_func *)PE_getProcAddress( mod_hdl, "TrapLoad_" ); - trap_funcs = ((ld_func != NULL) ? ld_func( &TrapCallbacks ) : NULL); -#else - trap_funcs = TrapLoad( &TrapCallbacks ); -#endif - err = DIGS_ERR_BAD_MODULE_FILE; - if( trap_funcs != NULL ) { - *trap_ver = trap_funcs->init_func( parms, buff, trap_ver->remote ); - FiniFunc = trap_funcs->fini_func; - ReqFunc = trap_funcs->req_func; - err = DIGS_ERR_BUF; - if( buff[0] == '\0' ) { - if( TrapVersionOK( *trap_ver ) ) { - TrapVer = *trap_ver; - return( DIGS_OK ); - } - err = DIGS_ERR_WRONG_MODULE_VERSION; - } - } - UnLoadTrap(); - return( err ); -} diff --git a/bld/dig/c/linux/trpld_rx.c b/bld/dig/c/linux/trpld_rx.c deleted file mode 100644 index c2cb6bc751..0000000000 --- a/bld/dig/c/linux/trpld_rx.c +++ /dev/null @@ -1,130 +0,0 @@ -/**************************************************************************** -* -* Open Watcom Project -* -* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. -* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. -* -* ======================================================================== -* -* This file contains Original Code and/or Modifications of Original -* Code as defined in and that are subject to the Sybase Open Watcom -* Public License version 1.0 (the 'License'). You may not use this file -* except in compliance with the License. BY USING THIS FILE YOU AGREE TO -* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is -* provided with the Original Code and Modifications, and is also -* available at www.sybase.com/developer/opensource. -* -* The Original Code and all software distributed under the License are -* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER -* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM -* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF -* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR -* NON-INFRINGEMENT. Please see the License for the specific language -* governing rights and limitations under the License. -* -* ======================================================================== -* -* Description: Trap module loader for Linux. -* -****************************************************************************/ - - -#include -#include -#include -#include -#include -#include "digcli.h" -#include "trpld.h" -#include "trpimp.h" -#include "ldimp.h" - - -#define TRAPSIG 0x50415254UL // "TRAP" - -const static trap_callbacks TrapCallbacks = { - sizeof( trap_callbacks ), - - &environ, - NULL, - - malloc, - realloc, - free, - getenv, - signal, -}; - -static imp_header *TrapCode = NULL; -static trap_fini_func *FiniFunc = NULL; - -void UnLoadTrap( void ) -{ - ReqFunc = NULL; - if( FiniFunc != NULL ) { - FiniFunc(); - FiniFunc = NULL; - } - if( TrapCode != NULL ) { - DIGCli( Free )( TrapCode ); - TrapCode = NULL; - } -} - -digld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) -{ - FILE *fp; - trap_load_func *ld_func; - const trap_requests *trap_funcs; - char filename[256]; - const char *base_name; - size_t len; - digld_error err; - - if( parms == NULL || *parms == '\0' ) - parms = DEFAULT_TRP_NAME; - base_name = parms;; - len = 0; - for( ; *parms != '\0'; parms++ ) { - if( *parms == TRAP_PARM_SEPARATOR ) { - parms++; - break; - } - len++; - } - if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, len, ".trp", filename, sizeof( filename ) ) == 0 ) { - return( DIGS_ERR_CANT_FIND_MODULE ); - } - fp = DIGLoader( Open )( filename ); - if( fp == NULL ) { - return( DIGS_ERR_CANT_LOAD_MODULE ); - } - TrapCode = ReadInImp( fp ); - DIGLoader( Close )( fp ); - if( TrapCode == NULL ) { - return( DIGS_ERR_CANT_LOAD_MODULE ); - } - err = DIGS_ERR_BAD_MODULE_FILE; -#ifdef __WATCOMC__ - ld_func = (trap_load_func *)((TrapCode->sig == TRAPSIG) ? TrapCode->init_rtn : NULL); -#else - ld_func = (trap_load_func *)TrapCode->init_rtn; -#endif - trap_funcs = (( ld_func != NULL ) ? ld_func( &TrapCallbacks ) : NULL); - if( trap_funcs != NULL ) { - *trap_ver = trap_funcs->init_func( parms, buff, trap_ver->remote ); - FiniFunc = trap_funcs->fini_func; - ReqFunc = trap_funcs->req_func; - err = DIGS_ERR_BUF; - if( buff[0] == '\0' ) { - if( TrapVersionOK( *trap_ver ) ) { - TrapVer = *trap_ver; - return( DIGS_OK ); - } - err = DIGS_ERR_WRONG_MODULE_VERSION; - } - } - UnLoadTrap(); - return( err ); -} diff --git a/bld/dig/c/linux/trpld_so.c b/bld/dig/c/linux/trpld_so.c deleted file mode 100644 index b85f1eb3d3..0000000000 --- a/bld/dig/c/linux/trpld_so.c +++ /dev/null @@ -1,141 +0,0 @@ -/**************************************************************************** -* -* Open Watcom Project -* -* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. -* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. -* -* ======================================================================== -* -* This file contains Original Code and/or Modifications of Original -* Code as defined in and that are subject to the Sybase Open Watcom -* Public License version 1.0 (the 'License'). You may not use this file -* except in compliance with the License. BY USING THIS FILE YOU AGREE TO -* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is -* provided with the Original Code and Modifications, and is also -* available at www.sybase.com/developer/opensource. -* -* The Original Code and all software distributed under the License are -* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER -* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM -* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF -* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR -* NON-INFRINGEMENT. Please see the License for the specific language -* governing rights and limitations under the License. -* -* ======================================================================== -* -* Description: Linux module to load debugger trap files. -* -****************************************************************************/ - - -#include -#include -#include -#include -#include "trpld.h" - -#include "clibext.h" - - -#ifndef __WATCOMC__ -extern char **environ; -#endif - -#if !defined( BUILTIN_TRAP_FILE ) -static void *mod_hdl = NULL; -#endif -static trap_fini_func *FiniFunc = NULL; - -const static trap_callbacks TrapCallbacks = { - sizeof( trap_callbacks ), - - &environ, - NULL, - - malloc, - realloc, - free, - getenv, - signal, -}; - -void UnLoadTrap( void ) -{ - ReqFunc = NULL; - if( FiniFunc != NULL ) { - FiniFunc(); - FiniFunc = NULL; - } -#if !defined( BUILTIN_TRAP_FILE ) - if( mod_hdl != NULL ) { - dlclose( mod_hdl ); - mod_hdl = NULL; - } -#endif -} - -digld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) -{ - FILE *fp; - trap_load_func *ld_func; - const trap_requests *trap_funcs; - digld_error err; -#if !defined( BUILTIN_TRAP_FILE ) - char filename[_MAX_PATH]; - const char *base_name; - size_t len; -#endif - - if( parms == NULL || *parms == '\0' ) - parms = DEFAULT_TRP_NAME; -#if !defined( BUILTIN_TRAP_FILE ) - base_name = parms; - len = 0; -#endif - for( ; *parms != '\0'; parms++ ) { - if( *parms == TRAP_PARM_SEPARATOR ) { - parms++; - break; - } -#if !defined( BUILTIN_TRAP_FILE ) - len++; -#endif - } -#if !defined( BUILTIN_TRAP_FILE ) - if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, len, ".so", filename, sizeof( filename ) ) == 0 ) { - return( DIGS_ERR_CANT_FIND_MODULE ); - } - fp = DIGLoader( Open )( filename ); - if( fp == NULL ) { - return( DIGS_ERR_CANT_LOAD_MODULE ); - } - mod_hdl = dlopen( filename, RTLD_NOW ); - DIGLoader( Close )( fp ); - if( mod_hdl == NULL ) { - puts( dlerror() ); - return( DIGS_ERR_CANT_LOAD_MODULE ); - } - ld_func = (trap_load_func *)dlsym( mod_hdl, "TrapLoad" ); - trap_funcs = ((ld_func != NULL) ? ld_func( &TrapCallbacks ) : NULL); -#else - trap_funcs = TrapLoad( &TrapCallbacks ); -#endif - err = DIGS_ERR_BAD_MODULE_FILE; - if( trap_funcs != NULL ) { - *trap_ver = trap_funcs->init_func( parms, buff, trap_ver->remote ); - FiniFunc = trap_funcs->fini_func; - ReqFunc = trap_funcs->req_func; - err = DIGS_ERR_BUF; - if( buff[0] == '\0' ) { - if( TrapVersionOK( *trap_ver ) ) { - TrapVer = *trap_ver; - return( DIGS_OK ); - } - err = DIGS_ERR_WRONG_MODULE_VERSION; - } - } - UnLoadTrap(); - return( err ); -} diff --git a/bld/dig/c/nov/trpld.c b/bld/dig/c/nov/trpld.c index 40461bb94c..1df2a95cd9 100644 --- a/bld/dig/c/nov/trpld.c +++ b/bld/dig/c/nov/trpld.c @@ -25,8 +25,7 @@ * * ======================================================================== * -* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE -* DESCRIBE IT HERE! +* Description: Trap module loader for Novell Netware. * ****************************************************************************/ diff --git a/bld/dig/c/nt/dipld.c b/bld/dig/c/nt/dipld.c index e5a0fe348a..6181aad8fe 100644 --- a/bld/dig/c/nt/dipld.c +++ b/bld/dig/c/nt/dipld.c @@ -25,8 +25,7 @@ * * ======================================================================== * -* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE -* DESCRIBE IT HERE! +* Description: DIP module loader for Win32. * ****************************************************************************/ diff --git a/bld/dig/c/nt/madld.c b/bld/dig/c/nt/madld.c index 2c1ff59a04..1392534ff7 100644 --- a/bld/dig/c/nt/madld.c +++ b/bld/dig/c/nt/madld.c @@ -25,8 +25,7 @@ * * ======================================================================== * -* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE -* DESCRIBE IT HERE! +* Description: MAD module loader for Win32. * ****************************************************************************/ diff --git a/bld/dig/c/nt/trpld.c b/bld/dig/c/nt/trpld.c index aa6d614279..b8d0270025 100644 --- a/bld/dig/c/nt/trpld.c +++ b/bld/dig/c/nt/trpld.c @@ -25,7 +25,7 @@ * * ======================================================================== * -* Description: Win32 trap file loading. +* Description: Trap module loader for Win32. * ****************************************************************************/ diff --git a/bld/dig/c/nto/trpld.c b/bld/dig/c/nto/trpld.c index a07056d73b..3449f5dc76 100644 --- a/bld/dig/c/nto/trpld.c +++ b/bld/dig/c/nto/trpld.c @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -24,9 +25,165 @@ * * ======================================================================== * -* Description: Debugger trap file module loader. +* Description: Trap module loader for QNX Neutrino. * ****************************************************************************/ -#include "../linux/trpld_so.c" +//#define REX + +#include +#include +#include +#include +#ifdef __LINUX__ + #include +#endif +#ifdef __WATCOMC__ +#ifdef REX + #include "watcom.h" + #include "exephar.h" +#else + #include "watcom.h" + #include "exepe.h" + #include "exedos.h" +#endif +#else + #include +#endif +#include "digcli.h" +#include "trpld.h" +#include "roundmac.h" + +#include "clibext.h" + + +#ifndef __WATCOMC__ +extern char **environ; +#endif + +static trap_fini_func *FiniFunc = NULL; + +const static trap_callbacks TrapCallbacks = { + sizeof( trap_callbacks ), + + &environ, + NULL, + + malloc, + realloc, + free, + getenv, + signal, +}; + +#if !defined( BUILTIN_TRAP_FILE ) + +#ifdef __WATCOMC__ + +#ifdef REX + +#define DEFEXT ".trp" +#define MODSIG TRAPSIGVAL +#include "../ldrrex.c" /* PharLap REX format loader */ + +#else + +#define DEFEXT ".trp" +#define MODINIT "TrapLoad_" +#include "../ldrpe.c" /* PE DLL format loader */ + +#endif + +#else + +#define DEFEXT ".so" +#define MODINIT "TrapLoad" +#include "../ldrso.c" /* Shared library format loader */ + +#endif + +static module modhdl = NULL; + +#endif + +void UnLoadTrap( void ) +{ + ReqFunc = NULL; + if( FiniFunc != NULL ) { + FiniFunc(); + FiniFunc = NULL; + } +#if !defined( BUILTIN_TRAP_FILE ) + if( modhdl != NULL ) { + loader_unload_image( modhdl ); + modhdl = NULL; + } +#endif +} + +digld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) +{ + FILE *fp; + trap_load_func *ld_func; + const trap_requests *trap_funcs; + digld_error err; +#if !defined( BUILTIN_TRAP_FILE ) + char filename[_MAX_PATH]; + const char *base_name; + size_t len; +#endif + + if( parms == NULL || *parms == '\0' ) + parms = DEFAULT_TRP_NAME; +#if !defined( BUILTIN_TRAP_FILE ) + modhdl = NULL; + base_name = parms; + len = 0; +#endif + for( ; *parms != '\0'; parms++ ) { + if( *parms == TRAP_PARM_SEPARATOR ) { + parms++; + break; + } +#if !defined( BUILTIN_TRAP_FILE ) + len++; +#endif + } +#if !defined( BUILTIN_TRAP_FILE ) + if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, len, DEFEXT, filename, sizeof( filename ) ) == 0 ) { + return( DIGS_ERR_CANT_FIND_MODULE ); + } + fp = DIGLoader( Open )( filename ); + if( fp == NULL ) { + return( DIGS_ERR_CANT_LOAD_MODULE ); + } + err = loader_load_image( fp, filename, &modhdl, (void **)&ld_func ); + DIGLoader( Close )( fp ); + if( err != DIGS_OK ) { + return( err ); + } + trap_funcs = ((ld_func != NULL) ? ld_func( &TrapCallbacks ) : NULL); +#else + trap_funcs = TrapLoad( &TrapCallbacks ); +#endif + err = DIGS_ERR_BAD_MODULE_FILE; + if( trap_funcs != NULL ) { + *trap_ver = trap_funcs->init_func( parms, buff, trap_ver->remote ); + FiniFunc = trap_funcs->fini_func; + ReqFunc = trap_funcs->req_func; + err = DIGS_ERR_BUF; + if( buff[0] == '\0' ) { + if( TrapVersionOK( *trap_ver ) ) { + TrapVer = *trap_ver; + return( DIGS_OK ); + } + err = DIGS_ERR_WRONG_MODULE_VERSION; + } + } +#if !defined( BUILTIN_TRAP_FILE ) + loader_unload_image( modhdl ); + modhdl = NULL; +#endif + return( err ); +} diff --git a/bld/dig/c/osx/dipld.c b/bld/dig/c/osx/dipld.c index 9564e5fbe1..4ee57e3e4a 100644 --- a/bld/dig/c/osx/dipld.c +++ b/bld/dig/c/osx/dipld.c @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -24,21 +25,91 @@ * * ======================================================================== * -* Description: DIP module loader. +* Description: DIP module loader for OSX. * ****************************************************************************/ +#include +#include +#include +#ifdef __LINUX__ + #include +#endif #ifdef __WATCOMC__ + #include "watcom.h" + #include "exephar.h" +#else + #include +#endif +#include "digld.h" +#include "dip.h" +#include "dipimp.h" +#include "dipsys.h" +#include "roundmac.h" -/* At this point OS X is sharing the DIP loader with 32-bit DOS. This is - * not the final solution (should be real dylib). - */ -#include "../dsx/dipld.c" +#include "clibext.h" + + +#ifdef __WATCOMC__ + +#define DEFEXT ".dip" +#define MODSIG DIPSIGVAL +#include "../ldrrex.c" /* PharLap REX format loader */ #else -/* Use real shared libs when building with GCC */ -#include "../linux/dipld_so.c" +#define DEFEXT ".so" +#define MODINIT "DIPLOAD" +#include "../ldrso.c" /* Shared library format loader */ + +#endif + +void DIPSysUnload( dip_sys_handle *sys_hdl ) +{ + /* + * We should unload the symbols here but it's not worth the trouble + */ + if( *sys_hdl != NULL_SYSHDL ) { + loader_unload_image( *sys_hdl ); + *sys_hdl = NULL_SYSHDL; + } +} + +dip_status DIPSysLoad( const char *base_name, dip_client_routines *cli, dip_imp_routines **imp, dip_sys_handle *sys_hdl ) +{ + FILE *fp; + module modhdl; + dip_init_func *init_func; + dip_status status; + char filename[_MAX_PATH]; + digld_error err; + *sys_hdl = NULL_SYSHDL; + if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, 0, DEFEXT, filename, sizeof( filename ) ) == 0 ) { + return( DS_ERR | DS_FOPEN_FAILED ); + } + fp = DIGLoader( Open )( filename ); + if( fp == NULL ) { + return( DS_ERR | DS_FOPEN_FAILED ); + } + err = loader_load_image( fp, filename, &modhdl, (void **)&init_func ); + DIGLoader( Close )( fp ); + status = DS_ERR | DS_INVALID_DIP; + if( err != DIGS_OK ) { + return( status ); + } + if( init_func != NULL && (*imp = init_func( &status, cli )) != NULL ) { +#ifdef WATCOM_DEBUG_SYMBOLS + /* + * Look for symbols in separate .sym files, not the .dip itself + */ + strcpy( filename + strlen( filename ) - 4, ".sym" ); + DebuggerLoadUserModule( filename, GetCS(), (unsigned long)modhdl ); #endif + *sys_hdl = modhdl; + return( DS_OK ); + } + loader_unload_image( modhdl ); + return( status ); +} diff --git a/bld/dig/c/osx/madld.c b/bld/dig/c/osx/madld.c index eff96c7618..d07f7c4a93 100644 --- a/bld/dig/c/osx/madld.c +++ b/bld/dig/c/osx/madld.c @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -24,21 +25,81 @@ * * ======================================================================== * -* Description: MAD module loader. +* Description: MAD module loader for OSX. * ****************************************************************************/ +#include +#include +#include +#ifdef __LINUX__ + #include +#endif #ifdef __WATCOMC__ + #include "watcom.h" + #include "exephar.h" +#else + #include +#endif +#include "digld.h" +#include "mad.h" +#include "madimp.h" +#include "madcli.h" +#include "madsys.h" +#include "roundmac.h" -/* At this point OS X is sharing the DIP loader with 32-bit DOS. This is - * not the final solution (should be real dylib). - */ -#include "../dsx/madld.c" + +#ifdef __WATCOMC__ + +#define DEFEXT ".mad" +#define MODSIG MADSIGVAL +#include "../ldrrex.c" /* PharLap REX format loader */ #else -/* Use real shared libs when building with GCC */ -#include "../linux/madld_so.c" +#define DEFEXT ".so" +#define MODINIT "MADLOAD" +#include "../ldrso.c" /* Shared library format loader */ #endif + +void MADSysUnload( mad_sys_handle *sys_hdl ) +{ + if( *sys_hdl != NULL_SYSHDL ) { + loader_unload_image( *sys_hdl ); + *sys_hdl = NULL_SYSHDL; + } +} + +mad_status MADSysLoad( const char *base_name, mad_client_routines *cli, + mad_imp_routines **imp, mad_sys_handle *sys_hdl ) +{ + FILE *fp; + module modhdl; + mad_init_func *init_func; + mad_status status; + char filename[256]; + digld_error err; + + *sys_hdl = NULL_SYSHDL; + if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, 0, DEFEXT, filename, sizeof( filename ) ) == 0 ) { + return( MS_ERR | MS_FOPEN_FAILED ); + } + fp = DIGLoader( Open )( filename ); + if( fp == NULL ) { + return( MS_ERR | MS_FOPEN_FAILED ); + } + err = loader_load_image( fp, filename, &modhdl, (void **)&init_func ); + DIGLoader( Close )( fp ); + status = MS_ERR | MS_INVALID_MAD; + if( err != DIGS_OK ) { + return( status ); + } + if( init_func != NULL && (*imp = init_func( &status, cli )) != NULL ) { + *sys_hdl = modhdl; + return( MS_OK ); + } + loader_unload_image( modhdl ); + return( status ); +} diff --git a/bld/dig/c/osx/trpld.c b/bld/dig/c/osx/trpld.c index f044295bd8..5f6a0ff0c2 100644 --- a/bld/dig/c/osx/trpld.c +++ b/bld/dig/c/osx/trpld.c @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -24,21 +25,165 @@ * * ======================================================================== * -* Description: Debugger trap file module loader. +* Description: Trap module loader for OSX. * ****************************************************************************/ +//#define REX + +#include +#include +#include +#include +#ifdef __LINUX__ + #include +#endif +#ifdef __WATCOMC__ +#ifdef REX + #include "watcom.h" + #include "exephar.h" +#else + #include "watcom.h" + #include "exepe.h" + #include "exedos.h" +#endif +#else + #include +#endif +#include "digcli.h" +#include "trpld.h" +#include "roundmac.h" + +#include "clibext.h" + + +#ifndef __WATCOMC__ +extern char **environ; +#endif + +static trap_fini_func *FiniFunc = NULL; + +const static trap_callbacks TrapCallbacks = { + sizeof( trap_callbacks ), + + &environ, + NULL, + + malloc, + realloc, + free, + getenv, + signal, +}; + +#if !defined( BUILTIN_TRAP_FILE ) + #ifdef __WATCOMC__ -/* At this point OS X is using trap files which are PE DLLs. This is - * not the final solution (should be real dylib). - */ -#include "../linux/trpld_pe.c" +#ifdef REX + +#define DEFEXT ".trp" +#define MODSIG TRAPSIGVAL +#include "../ldrrex.c" /* PharLap REX format loader */ #else -/* Use real shared libs when building with GCC */ -#include "../linux/trpld_so.c" +#define DEFEXT ".trp" +#define MODINIT "TrapLoad_" +#include "../ldrpe.c" /* PE DLL format loader */ #endif + +#else + +#define DEFEXT ".so" +#define MODINIT "TrapLoad" +#include "../ldrso.c" /* Shared library format loader */ + +#endif + +static module modhdl = NULL; + +#endif + +void UnLoadTrap( void ) +{ + ReqFunc = NULL; + if( FiniFunc != NULL ) { + FiniFunc(); + FiniFunc = NULL; + } +#if !defined( BUILTIN_TRAP_FILE ) + if( modhdl != NULL ) { + loader_unload_image( modhdl ); + modhdl = NULL; + } +#endif +} + +digld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) +{ + FILE *fp; + trap_load_func *ld_func; + const trap_requests *trap_funcs; + digld_error err; +#if !defined( BUILTIN_TRAP_FILE ) + char filename[_MAX_PATH]; + const char *base_name; + size_t len; +#endif + + if( parms == NULL || *parms == '\0' ) + parms = DEFAULT_TRP_NAME; +#if !defined( BUILTIN_TRAP_FILE ) + modhdl = NULL; + base_name = parms; + len = 0; +#endif + for( ; *parms != '\0'; parms++ ) { + if( *parms == TRAP_PARM_SEPARATOR ) { + parms++; + break; + } +#if !defined( BUILTIN_TRAP_FILE ) + len++; +#endif + } +#if !defined( BUILTIN_TRAP_FILE ) + if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, len, DEFEXT, filename, sizeof( filename ) ) == 0 ) { + return( DIGS_ERR_CANT_FIND_MODULE ); + } + fp = DIGLoader( Open )( filename ); + if( fp == NULL ) { + return( DIGS_ERR_CANT_LOAD_MODULE ); + } + err = loader_load_image( fp, filename, &modhdl, (void **)&ld_func ); + DIGLoader( Close )( fp ); + if( err != DIGS_OK ) { + return( err ); + } + trap_funcs = ((ld_func != NULL) ? ld_func( &TrapCallbacks ) : NULL); +#else + trap_funcs = TrapLoad( &TrapCallbacks ); +#endif + err = DIGS_ERR_BAD_MODULE_FILE; + if( trap_funcs != NULL ) { + *trap_ver = trap_funcs->init_func( parms, buff, trap_ver->remote ); + FiniFunc = trap_funcs->fini_func; + ReqFunc = trap_funcs->req_func; + err = DIGS_ERR_BUF; + if( buff[0] == '\0' ) { + if( TrapVersionOK( *trap_ver ) ) { + TrapVer = *trap_ver; + return( DIGS_OK ); + } + err = DIGS_ERR_WRONG_MODULE_VERSION; + } + } +#if !defined( BUILTIN_TRAP_FILE ) + loader_unload_image( modhdl ); + modhdl = NULL; +#endif + return( err ); +} diff --git a/bld/dig/c/qnx/dipld.c b/bld/dig/c/qnx/dipld.c index af94a43893..a558ec1b5e 100644 --- a/bld/dig/c/qnx/dipld.c +++ b/bld/dig/c/qnx/dipld.c @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -24,10 +25,73 @@ * * ======================================================================== * -* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE -* DESCRIBE IT HERE! +* Description: DIP module loader for QNX. * ****************************************************************************/ -#include "../dsx/dipld.c" +#include +#include +#include +#include "digld.h" +#include "dip.h" +#include "dipimp.h" +#include "dipsys.h" +#include "exephar.h" +#include "roundmac.h" + + +#define DEFEXT ".dip" +//#define MODINIT "DIPLOAD" +#define MODSIG DIPSIGVAL + +#include "../ldrrex.c" /* PharLap REX format loader */ + +void DIPSysUnload( dip_sys_handle *sys_hdl ) +{ + /* + * We should unload the symbols here but it's not worth the trouble + */ + if( *sys_hdl != NULL_SYSHDL ) { + loader_unload_image( *sys_hdl ); + *sys_hdl = NULL_SYSHDL; + } +} + +dip_status DIPSysLoad( const char *base_name, dip_client_routines *cli, dip_imp_routines **imp, dip_sys_handle *sys_hdl ) +{ + FILE *fp; + module modhdl; + dip_init_func *init_func; + dip_status status; + char filename[_MAX_PATH]; + digld_error err; + + *sys_hdl = NULL_SYSHDL; + if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, 0, DEFEXT, filename, sizeof( filename ) ) == 0 ) { + return( DS_ERR | DS_FOPEN_FAILED ); + } + fp = DIGLoader( Open )( filename ); + if( fp == NULL ) { + return( DS_ERR | DS_FOPEN_FAILED ); + } + err = loader_load_image( fp, filename, &modhdl, (void **)&init_func ); + DIGLoader( Close )( fp ); + status = DS_ERR | DS_INVALID_DIP; + if( err != DIGS_OK ) { + return( status ); + } + if( init_func != NULL && (*imp = init_func( &status, cli )) != NULL ) { +#ifdef WATCOM_DEBUG_SYMBOLS + /* + * Look for symbols in separate .sym files, not the .dip itself + */ + strcpy( filename + strlen( filename ) - 4, ".sym" ); + DebuggerLoadUserModule( filename, GetCS(), (unsigned long)modhdl ); +#endif + *sys_hdl = modhdl; + return( DS_OK ); + } + loader_unload_image( modhdl ); + return( status ); +} diff --git a/bld/dig/c/qnx/ldimp.c b/bld/dig/c/qnx/ldimp.c deleted file mode 100644 index 6225051be3..0000000000 --- a/bld/dig/c/qnx/ldimp.c +++ /dev/null @@ -1,39 +0,0 @@ -/**************************************************************************** -* -* Open Watcom Project -* -* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. -* -* ======================================================================== -* -* This file contains Original Code and/or Modifications of Original -* Code as defined in and that are subject to the Sybase Open Watcom -* Public License version 1.0 (the 'License'). You may not use this file -* except in compliance with the License. BY USING THIS FILE YOU AGREE TO -* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is -* provided with the Original Code and Modifications, and is also -* available at www.sybase.com/developer/opensource. -* -* The Original Code and all software distributed under the License are -* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER -* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM -* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF -* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR -* NON-INFRINGEMENT. Please see the License for the specific language -* governing rights and limitations under the License. -* -* ======================================================================== -* -* Description: Pharlap executable loader for QNX. -* -****************************************************************************/ - - -#ifdef __WATCOMC__ - -/* At this point QNX is sharing the Pharlap executable loader with 32-bit DOS. - * This is not the final solution (should be real QNX shared lib). - */ -#include "../dsx/ldimp.c" - -#endif diff --git a/bld/dig/c/qnx/madld.c b/bld/dig/c/qnx/madld.c index 00794b2fe5..62e638bb0d 100644 --- a/bld/dig/c/qnx/madld.c +++ b/bld/dig/c/qnx/madld.c @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -24,10 +25,81 @@ * * ======================================================================== * -* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE -* DESCRIBE IT HERE! +* Description: MAD module loader for QNX. * ****************************************************************************/ -#include "../dsx/madld.c" +#include +#include +#include +#ifdef __LINUX__ + #include +#endif +#ifdef __WATCOMC__ + #include "watcom.h" + #include "exephar.h" +#else + #include +#endif +#include "digld.h" +#include "mad.h" +#include "madimp.h" +#include "madcli.h" +#include "madsys.h" +#include "roundmac.h" + + +#ifdef __WATCOMC__ + +#define DEFEXT ".mad" +#define MODSIG MADSIGVAL +#include "../ldrrex.c" /* PharLap REX format loader */ + +#else + +#define DEFEXT ".so" +#define MODINIT "MADLOAD" +#include "../ldrso.c" /* Shared library format loader */ + +#endif + +void MADSysUnload( mad_sys_handle *sys_hdl ) +{ + if( *sys_hdl != NULL_SYSHDL ) { + loader_unload_image( *sys_hdl ); + *sys_hdl = NULL_SYSHDL; + } +} + +mad_status MADSysLoad( const char *base_name, mad_client_routines *cli, + mad_imp_routines **imp, mad_sys_handle *sys_hdl ) +{ + FILE *fp; + module modhdl; + mad_init_func *init_func; + mad_status status; + char filename[256]; + digld_error err; + + *sys_hdl = NULL_SYSHDL; + if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, 0, DEFEXT, filename, sizeof( filename ) ) == 0 ) { + return( MS_ERR | MS_FOPEN_FAILED ); + } + fp = DIGLoader( Open )( filename ); + if( fp == NULL ) { + return( MS_ERR | MS_FOPEN_FAILED ); + } + err = loader_load_image( fp, filename, &modhdl, (void **)&init_func ); + DIGLoader( Close )( fp ); + status = MS_ERR | MS_INVALID_MAD; + if( err != DIGS_OK ) { + return( status ); + } + if( init_func != NULL && (*imp = init_func( &status, cli )) != NULL ) { + *sys_hdl = modhdl; + return( MS_OK ); + } + loader_unload_image( modhdl ); + return( status ); +} diff --git a/bld/dig/c/qnx/trpld.c b/bld/dig/c/qnx/trpld.c index 4ed21e67d6..4aae0d7659 100644 --- a/bld/dig/c/qnx/trpld.c +++ b/bld/dig/c/qnx/trpld.c @@ -38,10 +38,15 @@ #include "digcli.h" #include "trpld.h" #include "trpimp.h" -#include "ldimp.h" +#include "exephar.h" +#include "roundmac.h" -#define TRAPSIG 0x50415254UL // "TRAP" +#define DEFEXT ".trp" +//#define MODINIT "TrapLoad" +#define MODSIG TRAPSIGVAL + +#include "../ldrrex.c" /* PharLap REX format loader */ extern void *_slib_func[2]; @@ -58,7 +63,7 @@ const static trap_callbacks TrapCallbacks = { signal, }; -static imp_header *TrapCode = NULL; +static module modhdl = NULL; static trap_fini_func *FiniFunc = NULL; void UnLoadTrap( void ) @@ -68,9 +73,9 @@ void UnLoadTrap( void ) FiniFunc(); FiniFunc = NULL; } - if( TrapCode != NULL ) { - DIGCli( Free )( TrapCode ); - TrapCode = NULL; + if( modhdl != NULL ) { + loader_unload_image( modhdl ); + modhdl = NULL; } } @@ -95,24 +100,19 @@ digld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) } len++; } - if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, len, ".trp", filename, sizeof( filename ) ) == 0 ) { + if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, len, DEFEXT, filename, sizeof( filename ) ) == 0 ) { return( DIGS_ERR_CANT_FIND_MODULE ); } fp = DIGLoader( Open )( filename ); if( fp == NULL ) { return( DIGS_ERR_CANT_LOAD_MODULE ); } - TrapCode = ReadInImp( fp ); + err = loader_load_image( fp, filename, &modhdl, (void **)&ld_func ); DIGLoader( Close )( fp ); - if( TrapCode == NULL ) { - return( DIGS_ERR_CANT_LOAD_MODULE ); + if( err != DIGS_OK ) { + return( err ); } err = DIGS_ERR_BAD_MODULE_FILE; -#ifdef __WATCOMC__ - ld_func = (trap_load_func *)((TrapCode->sig == TRAPSIG) ? TrapCode->init_rtn : NULL); -#else - ld_func = (trap_load_func *)TrapCode->init_rtn; -#endif trap_funcs = (( ld_func != NULL ) ? ld_func( &TrapCallbacks ) : NULL); if( trap_funcs != NULL ) { *trap_ver = trap_funcs->init_func( parms, buff, trap_ver->remote ); @@ -127,6 +127,7 @@ digld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) err = DIGS_ERR_WRONG_MODULE_VERSION; } } - UnLoadTrap(); + loader_unload_image( modhdl ); + modhdl = NULL; return( err ); } diff --git a/bld/dig/c/rdos/dipld.c b/bld/dig/c/rdos/dipld.c index 935a555648..f7e6d14c7b 100644 --- a/bld/dig/c/rdos/dipld.c +++ b/bld/dig/c/rdos/dipld.c @@ -25,8 +25,7 @@ * * ======================================================================== * -* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE -* DESCRIBE IT HERE! +* Description: DIP module loader for RDOS. * ****************************************************************************/ diff --git a/bld/dig/c/rdos/madld.c b/bld/dig/c/rdos/madld.c index 644f6dc16a..53314dc57f 100644 --- a/bld/dig/c/rdos/madld.c +++ b/bld/dig/c/rdos/madld.c @@ -25,8 +25,7 @@ * * ======================================================================== * -* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE -* DESCRIBE IT HERE! +* Description: MAD module loader for RDOS. * ****************************************************************************/ diff --git a/bld/dig/c/rdos/trpld.c b/bld/dig/c/rdos/trpld.c index a7352d30f6..f32ef24b0f 100644 --- a/bld/dig/c/rdos/trpld.c +++ b/bld/dig/c/rdos/trpld.c @@ -25,7 +25,7 @@ * * ======================================================================== * -* Description: RDOS trap file loading. +* Description: Trap module loader for RDOS. * ****************************************************************************/ diff --git a/bld/dig/c/win/dipld.c b/bld/dig/c/win/dipld.c index 10e9308ade..a71309c782 100644 --- a/bld/dig/c/win/dipld.c +++ b/bld/dig/c/win/dipld.c @@ -25,7 +25,7 @@ * * ======================================================================== * -* Description: Windows 3.x DIP loader. +* Description: DIP module loader for Windows 3.x. * ****************************************************************************/ diff --git a/bld/dig/c/win/madld.c b/bld/dig/c/win/madld.c index 5d375c2505..0df1defce9 100644 --- a/bld/dig/c/win/madld.c +++ b/bld/dig/c/win/madld.c @@ -25,7 +25,7 @@ * * ======================================================================== * -* Description: Windows 3.x MAD loader. +* Description: MAD module loader for Windows 3.x. * ****************************************************************************/ diff --git a/bld/dig/c/win/trpld.c b/bld/dig/c/win/trpld.c index 818a2a01b3..3b1a0c21cb 100644 --- a/bld/dig/c/win/trpld.c +++ b/bld/dig/c/win/trpld.c @@ -25,8 +25,7 @@ * * ======================================================================== * -* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE -* DESCRIBE IT HERE! +* Description: Trap module loader for Windows 3.x. * ****************************************************************************/ diff --git a/bld/dig/digcli.mif b/bld/dig/digcli.mif index 91487b3492..2daa12c0ed 100644 --- a/bld/dig/digcli.mif +++ b/bld/dig/digcli.mif @@ -5,16 +5,6 @@ dig_srcs = $(dig_dir)/c/$(dig_os_$(objs_subdir));$(dig_dir)/c dig_srcs = $(dig_dir)/c/$(host_os);$(dig_dir)/c !endif -!ifeq which SERVER -dig_objs_qnx386 = $(_subdir_)ldimp.obj -!else -dig_objs_dos386 = $(_subdir_)ldimp.obj -dig_objs_linux386 = $(_subdir_)ldimp.obj -dig_objs_osx386 = $(_subdir_)ldimp.obj -dig_objs_qnx386 = $(_subdir_)ldimp.obj -!endif -dig_objs = $(dig_objs_$(objs_subdir)) - dig_arch_cpp_flags_i86 =-DDIGX86 dig_arch_cpp_flags_386 =-DDIGX86 dig_arch_cpp_flags_x86 =-DDIGX86 diff --git a/bld/dig/h/dipsys.h b/bld/dig/h/dipsys.h index 98538b8746..fa92582f19 100644 --- a/bld/dig/h/dipsys.h +++ b/bld/dig/h/dipsys.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2017 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -33,6 +33,9 @@ // on WIN64 long is OK because HANDLE can be hold as 32-bit sign extended value // even if HANDLE is defined as 64-bit value +#define DIPSIG "DIP" +#define DIPSIGVAL 0x00504944UL // "DIP" + #if defined( __WINDOWS__ ) #define NULL_SYSHDL NULL typedef void (DIGENTRY *dip_sys_handle)( void ); diff --git a/bld/dig/h/ldimp.h b/bld/dig/h/ldimp.h deleted file mode 100644 index 7cc5153794..0000000000 --- a/bld/dig/h/ldimp.h +++ /dev/null @@ -1,40 +0,0 @@ -/**************************************************************************** -* -* Open Watcom Project -* -* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. -* -* ======================================================================== -* -* This file contains Original Code and/or Modifications of Original -* Code as defined in and that are subject to the Sybase Open Watcom -* Public License version 1.0 (the 'License'). You may not use this file -* except in compliance with the License. BY USING THIS FILE YOU AGREE TO -* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is -* provided with the Original Code and Modifications, and is also -* available at www.sybase.com/developer/opensource. -* -* The Original Code and all software distributed under the License are -* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER -* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM -* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF -* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR -* NON-INFRINGEMENT. Please see the License for the specific language -* governing rights and limitations under the License. -* -* ======================================================================== -* -* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE -* DESCRIBE IT HERE! -* -****************************************************************************/ - - -typedef struct { -#ifdef __WATCOMC__ - unsigned long sig; -#endif - unsigned_8 init_rtn[1]; /* offset is start of routine */ -} imp_header; - -extern imp_header *ReadInImp( FILE *fp ); diff --git a/bld/dig/h/madsys.h b/bld/dig/h/madsys.h index fc681dda69..20acce0401 100644 --- a/bld/dig/h/madsys.h +++ b/bld/dig/h/madsys.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2017 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -33,6 +33,9 @@ // on WIN64 long is OK because HANDLE can be hold as 32-bit sign extended value // even if HANDLE is defined as 64-bit value +#define MADSIG "MAD" +#define MADSIGVAL 0x0044414DUL // "MAD" + #if defined( __WINDOWS__ ) #define NULL_SYSHDL NULL typedef void (DIGENTRY *mad_sys_handle)( void ); diff --git a/bld/dig/h/trpld.h b/bld/dig/h/trpld.h index 76086b7fd4..3a6385e1b0 100644 --- a/bld/dig/h/trpld.h +++ b/bld/dig/h/trpld.h @@ -38,6 +38,9 @@ #define DEFAULT_TRP_NAME "std" +#define TRAPSIG "TRAP" +#define TRAPSIGVAL 0x50415254UL // "TRAP" + extern trap_version TrapVer; extern trap_req_func *ReqFunc; From a0c027ff566c6cd2708b51278d8503bfd101cfb1 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Thu, 14 Sep 2023 19:52:21 +0200 Subject: [PATCH 132/258] translate more DIG... errors for DIP and MAD --- bld/dig/c/dsx/dipld.c | 5 +++++ bld/dig/c/dsx/madld.c | 5 +++++ bld/dig/c/dsx/trpld.c | 2 +- bld/dig/c/linux/dipld.c | 5 +++++ bld/dig/c/linux/madld.c | 5 +++++ bld/dig/c/nt/dipld.c | 8 ++++---- bld/dig/c/os2/dipld.c | 8 ++++---- bld/dig/c/osx/dipld.c | 5 +++++ bld/dig/c/osx/madld.c | 5 +++++ bld/dig/c/qnx/dipld.c | 5 +++++ bld/dig/c/qnx/madld.c | 5 +++++ bld/dig/c/rdos/dipld.c | 8 ++++---- bld/dig/c/win/dipld.c | 8 ++++---- 13 files changed, 57 insertions(+), 17 deletions(-) diff --git a/bld/dig/c/dsx/dipld.c b/bld/dig/c/dsx/dipld.c index d5519bd7e6..76f82b25ba 100644 --- a/bld/dig/c/dsx/dipld.c +++ b/bld/dig/c/dsx/dipld.c @@ -77,6 +77,11 @@ dip_status DIPSysLoad( const char *base_name, dip_client_routines *cli, dip_imp_ } err = loader_load_image( fp, filename, &modhdl, (void **)&init_func ); DIGLoader( Close )( fp ); + if( err == DIGS_ERR_CANT_LOAD_MODULE ) + return( DS_ERR | DS_FREAD_FAILED ); + if( err == DIGS_ERR_OUT_OF_DOS_MEMORY + || err == DIGS_ERR_OUT_OF_DOS_MEMORY ) + return( DS_ERR | DS_NO_MEM ); status = DS_ERR | DS_INVALID_DIP; if( err != DIGS_OK ) { return( status ); diff --git a/bld/dig/c/dsx/madld.c b/bld/dig/c/dsx/madld.c index fe87fa82be..714563cc4a 100644 --- a/bld/dig/c/dsx/madld.c +++ b/bld/dig/c/dsx/madld.c @@ -76,6 +76,11 @@ mad_status MADSysLoad( const char *base_name, mad_client_routines *cli, } err = loader_load_image( fp, filename, &modhdl, (void **)&init_func ); DIGLoader( Close )( fp ); + if( err == DIGS_ERR_CANT_LOAD_MODULE ) + return( MS_ERR | MS_FREAD_FAILED ); + if( err == DIGS_ERR_OUT_OF_DOS_MEMORY + || err == DIGS_ERR_OUT_OF_DOS_MEMORY ) + return( MS_ERR | MS_NO_MEM ); status = MS_ERR | MS_INVALID_MAD; if( err != DIGS_OK ) { return( status ); diff --git a/bld/dig/c/dsx/trpld.c b/bld/dig/c/dsx/trpld.c index 53a6eb3f59..ddf5b57403 100644 --- a/bld/dig/c/dsx/trpld.c +++ b/bld/dig/c/dsx/trpld.c @@ -182,7 +182,7 @@ static P1616 __cdecl find_entry( void ) if( RSI_extensions != NULL ) { retval = RSI_extensions( 0, pkg_entry, pkg_name ); } - return (retval); + return( retval ); } /* diff --git a/bld/dig/c/linux/dipld.c b/bld/dig/c/linux/dipld.c index 08ac91ed71..6f88009a37 100644 --- a/bld/dig/c/linux/dipld.c +++ b/bld/dig/c/linux/dipld.c @@ -95,6 +95,11 @@ dip_status DIPSysLoad( const char *base_name, dip_client_routines *cli, dip_imp_ } err = loader_load_image( fp, filename, &modhdl, (void **)&init_func ); DIGLoader( Close )( fp ); + if( err == DIGS_ERR_CANT_LOAD_MODULE ) + return( DS_ERR | DS_FREAD_FAILED ); + if( err == DIGS_ERR_OUT_OF_DOS_MEMORY + || err == DIGS_ERR_OUT_OF_DOS_MEMORY ) + return( DS_ERR | DS_NO_MEM ); status = DS_ERR | DS_INVALID_DIP; if( err != DIGS_OK ) { return( status ); diff --git a/bld/dig/c/linux/madld.c b/bld/dig/c/linux/madld.c index 44a33556fe..14a3686e66 100644 --- a/bld/dig/c/linux/madld.c +++ b/bld/dig/c/linux/madld.c @@ -92,6 +92,11 @@ mad_status MADSysLoad( const char *base_name, mad_client_routines *cli, } err = loader_load_image( fp, filename, &modhdl, (void **)&init_func ); DIGLoader( Close )( fp ); + if( err == DIGS_ERR_CANT_LOAD_MODULE ) + return( MS_ERR | MS_FREAD_FAILED ); + if( err == DIGS_ERR_OUT_OF_DOS_MEMORY + || err == DIGS_ERR_OUT_OF_DOS_MEMORY ) + return( MS_ERR | MS_NO_MEM ); status = MS_ERR | MS_INVALID_MAD; if( err != DIGS_OK ) { return( status ); diff --git a/bld/dig/c/nt/dipld.c b/bld/dig/c/nt/dipld.c index 6181aad8fe..344c28ed77 100644 --- a/bld/dig/c/nt/dipld.c +++ b/bld/dig/c/nt/dipld.c @@ -52,7 +52,7 @@ dip_status DIPSysLoad( const char *base_name, dip_client_routines *cli, dip_imp_ dip_sys_handle mod_hdl; dip_init_func *init_func; char filename[256]; - dip_status ds; + dip_status status; *sys_hdl = NULL_SYSHDL; if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, 0, ".dll", filename, sizeof( filename ) ) == 0 ) { @@ -62,12 +62,12 @@ dip_status DIPSysLoad( const char *base_name, dip_client_routines *cli, dip_imp_ if( mod_hdl == NULL ) { return( DS_ERR | DS_FOPEN_FAILED ); } - ds = DS_ERR | DS_INVALID_DIP; + status = DS_ERR | DS_INVALID_DIP; init_func = (dip_init_func *)GetProcAddress( mod_hdl, "DIPLOAD" ); - if( init_func != NULL && (*imp = init_func( &ds, cli )) != NULL ) { + if( init_func != NULL && (*imp = init_func( &status, cli )) != NULL ) { *sys_hdl = mod_hdl; return( DS_OK ); } DIPSysUnload( &mod_hdl ); - return( ds ); + return( status ); } diff --git a/bld/dig/c/os2/dipld.c b/bld/dig/c/os2/dipld.c index 803c82b9fc..a9570295ad 100644 --- a/bld/dig/c/os2/dipld.c +++ b/bld/dig/c/os2/dipld.c @@ -62,7 +62,7 @@ dip_status DIPSysLoad( const char *base_name, dip_client_routines *cli, dip_imp_ { dip_sys_handle mod_hdl; dip_init_func *init_func; - dip_status ds; + dip_status status; char filename[CCHMAXPATH]; *sys_hdl = NULL_SYSHDL; @@ -80,11 +80,11 @@ dip_status DIPSysLoad( const char *base_name, dip_client_routines *cli, dip_imp_ if( LOAD_MODULE( filename, mod_hdl ) ) { return( DS_ERR | DS_FOPEN_FAILED ); } - ds = DS_ERR | DS_INVALID_DIP; - if( GET_PROC_ADDRESS( mod_hdl, "DIPLOAD", init_func ) && (*imp = init_func( &ds, cli )) != NULL ) { + status = DS_ERR | DS_INVALID_DIP; + if( GET_PROC_ADDRESS( mod_hdl, "DIPLOAD", init_func ) && (*imp = init_func( &status, cli )) != NULL ) { *sys_hdl = mod_hdl; return( DS_OK ); } DIPSysUnload( &mod_hdl ); - return( ds ); + return( status ); } diff --git a/bld/dig/c/osx/dipld.c b/bld/dig/c/osx/dipld.c index 4ee57e3e4a..f2c89b3b59 100644 --- a/bld/dig/c/osx/dipld.c +++ b/bld/dig/c/osx/dipld.c @@ -95,6 +95,11 @@ dip_status DIPSysLoad( const char *base_name, dip_client_routines *cli, dip_imp_ } err = loader_load_image( fp, filename, &modhdl, (void **)&init_func ); DIGLoader( Close )( fp ); + if( err == DIGS_ERR_CANT_LOAD_MODULE ) + return( DS_ERR | DS_FREAD_FAILED ); + if( err == DIGS_ERR_OUT_OF_DOS_MEMORY + || err == DIGS_ERR_OUT_OF_DOS_MEMORY ) + return( DS_ERR | DS_NO_MEM ); status = DS_ERR | DS_INVALID_DIP; if( err != DIGS_OK ) { return( status ); diff --git a/bld/dig/c/osx/madld.c b/bld/dig/c/osx/madld.c index d07f7c4a93..23c37d3d69 100644 --- a/bld/dig/c/osx/madld.c +++ b/bld/dig/c/osx/madld.c @@ -92,6 +92,11 @@ mad_status MADSysLoad( const char *base_name, mad_client_routines *cli, } err = loader_load_image( fp, filename, &modhdl, (void **)&init_func ); DIGLoader( Close )( fp ); + if( err == DIGS_ERR_CANT_LOAD_MODULE ) + return( MS_ERR | MS_FREAD_FAILED ); + if( err == DIGS_ERR_OUT_OF_DOS_MEMORY + || err == DIGS_ERR_OUT_OF_DOS_MEMORY ) + return( MS_ERR | MS_NO_MEM ); status = MS_ERR | MS_INVALID_MAD; if( err != DIGS_OK ) { return( status ); diff --git a/bld/dig/c/qnx/dipld.c b/bld/dig/c/qnx/dipld.c index a558ec1b5e..c4f7df4468 100644 --- a/bld/dig/c/qnx/dipld.c +++ b/bld/dig/c/qnx/dipld.c @@ -77,6 +77,11 @@ dip_status DIPSysLoad( const char *base_name, dip_client_routines *cli, dip_imp_ } err = loader_load_image( fp, filename, &modhdl, (void **)&init_func ); DIGLoader( Close )( fp ); + if( err == DIGS_ERR_CANT_LOAD_MODULE ) + return( DS_ERR | DS_FREAD_FAILED ); + if( err == DIGS_ERR_OUT_OF_DOS_MEMORY + || err == DIGS_ERR_OUT_OF_DOS_MEMORY ) + return( DS_ERR | DS_NO_MEM ); status = DS_ERR | DS_INVALID_DIP; if( err != DIGS_OK ) { return( status ); diff --git a/bld/dig/c/qnx/madld.c b/bld/dig/c/qnx/madld.c index 62e638bb0d..a449bf4fee 100644 --- a/bld/dig/c/qnx/madld.c +++ b/bld/dig/c/qnx/madld.c @@ -92,6 +92,11 @@ mad_status MADSysLoad( const char *base_name, mad_client_routines *cli, } err = loader_load_image( fp, filename, &modhdl, (void **)&init_func ); DIGLoader( Close )( fp ); + if( err == DIGS_ERR_CANT_LOAD_MODULE ) + return( MS_ERR | MS_FREAD_FAILED ); + if( err == DIGS_ERR_OUT_OF_DOS_MEMORY + || err == DIGS_ERR_OUT_OF_DOS_MEMORY ) + return( MS_ERR | MS_NO_MEM ); status = MS_ERR | MS_INVALID_MAD; if( err != DIGS_OK ) { return( status ); diff --git a/bld/dig/c/rdos/dipld.c b/bld/dig/c/rdos/dipld.c index f7e6d14c7b..eea31a8ed7 100644 --- a/bld/dig/c/rdos/dipld.c +++ b/bld/dig/c/rdos/dipld.c @@ -52,7 +52,7 @@ dip_status DIPSysLoad( const char *base_name, dip_client_routines *cli, dip_imp_ dip_sys_handle mod_hdl; dip_init_func *init_func; char filename[256]; - dip_status ds; + dip_status status; *sys_hdl = NULL_SYSHDL; if( DIGLoader( Find )( DIG_FILETYPE_EXE, base_name, 0, ".dll", filename, sizeof( filename ) ) == 0 ) { @@ -62,12 +62,12 @@ dip_status DIPSysLoad( const char *base_name, dip_client_routines *cli, dip_imp_ if( mod_hdl == NULL_SYSHDL ) { return( DS_ERR | DS_FOPEN_FAILED ); } - ds = DS_ERR | DS_INVALID_DIP; + status = DS_ERR | DS_INVALID_DIP; init_func = (dip_init_func *)RdosGetModuleProc( mod_hdl, "DIPLOAD" ); - if( init_func != NULL && (*imp = init_func( &ds, cli )) != NULL ) { + if( init_func != NULL && (*imp = init_func( &status, cli )) != NULL ) { *sys_hdl = mod_hdl; return( DS_OK ); } DIPSysUnload( &mod_hdl ); - return( ds ); + return( status ); } diff --git a/bld/dig/c/win/dipld.c b/bld/dig/c/win/dipld.c index a71309c782..9f02a2ee74 100644 --- a/bld/dig/c/win/dipld.c +++ b/bld/dig/c/win/dipld.c @@ -66,7 +66,7 @@ dip_status DIPSysLoad( const char *base_name, dip_client_routines *cli, dip_imp_ { HINSTANCE mod_hdl; char filename[256]; - dip_status ds; + dip_status status; char parm[10]; struct { WORD mb2; @@ -107,11 +107,11 @@ dip_status DIPSysLoad( const char *base_name, dip_client_routines *cli, dip_imp_ if( mod_hdl < HINSTANCE_ERROR ) { return( DS_ERR | DS_FOPEN_FAILED ); } - ds = DS_ERR | DS_INVALID_DIP; - if( transfer_block.load != NULL && (*imp = transfer_block.load( &ds, cli )) != NULL ) { + status = DS_ERR | DS_INVALID_DIP; + if( transfer_block.load != NULL && (*imp = transfer_block.load( &status, cli )) != NULL ) { *sys_hdl = transfer_block.unload; return( DS_OK ); } DIPSysUnload( &transfer_block.unload ); - return( ds ); + return( status ); } From 72daeec2963f4e7c2bd54e0e35389d989e821112 Mon Sep 17 00:00:00 2001 From: Detlef Riekenberg Date: Thu, 14 Sep 2023 21:49:39 +0200 Subject: [PATCH 133/258] WIP: C++ compiler - changes for ppc and mips architectures (#1132) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * plusplus: Define the jmp buffer size also for ppc and mips * plusplus: Add MIPS + PowerPC Target Names for the Banner * plusplus: Let the precompiled header know about MIPS * plusplus: Add target definitions for MIPS and PowerPC * plusplus: Make the message translation functions aware of wppmps and wppppc * plusplus: Use the same module code for all RISC targets * change PCH version to invalidate previous precompiled headers file Co-authored-by: Jiří Malák --- bld/plusplus/c/cgbkmain.c | 4 ++++ bld/plusplus/c/message.c | 4 ++++ bld/plusplus/c/module.c | 2 +- bld/plusplus/c/watcom.c | 4 ++++ bld/plusplus/h/pcheader.h | 9 ++++++++- bld/plusplus/h/tgtenv.h | 15 +++++++-------- 6 files changed, 28 insertions(+), 10 deletions(-) diff --git a/bld/plusplus/c/cgbkmain.c b/bld/plusplus/c/cgbkmain.c index 42264f5f2e..982bb2a655 100644 --- a/bld/plusplus/c/cgbkmain.c +++ b/bld/plusplus/c/cgbkmain.c @@ -220,6 +220,10 @@ static TRY_IMPL* tryImpl( // FIND/ALLOCATE A TRY IMPLEMENTATION #define JMPBUF_SIZE ( 24 * TARGET_DOUBLE ) #elif _INTEL_CPU #define JMPBUF_SIZE ( 13 * TARGET_INT ) +#elif _CPU == _MIPS + #define JMPBUF_SIZE ( 26 * TARGET_LONG ) +#elif _CPU == _PPC + #define JMPBUF_SIZE ( 1 * TARGET_INT ) #else #error bad target #endif diff --git a/bld/plusplus/c/message.c b/bld/plusplus/c/message.c index 83a9c3ca96..1f972503b0 100644 --- a/bld/plusplus/c/message.c +++ b/bld/plusplus/c/message.c @@ -92,6 +92,10 @@ static SUICIDE_CALLBACK *suicideCallbacks; #define INTL_NAME "wppi86" #elif _CPU == _AXP #define INTL_NAME "wppaxp" +#elif _CPU == _MIPS +#define INTL_NAME "wppmps" +#elif _CPU == _PPC +#define INTL_NAME "wppppc" #else #error missing _CPU check #endif diff --git a/bld/plusplus/c/module.c b/bld/plusplus/c/module.c index 5cfaa31f99..ed7e4d0303 100644 --- a/bld/plusplus/c/module.c +++ b/bld/plusplus/c/module.c @@ -290,7 +290,7 @@ static void genInitFiniReference( // GENERATE INIT/FINI REFERENCE TO FUNCTION CgFrontDataInt( IC_DATA_INT, 0 ); } CgFrontDataInt( IC_DATA_INT, priority ); -#elif _CPU == _AXP +#elif _RISC_CPU CgFrontDataPtr( IC_SET_TYPE, GetBasicType( TYP_UINT ) ); CgFrontDataInt( IC_DATA_INT, 0 ); CgFrontDataInt( IC_DATA_INT, priority ); diff --git a/bld/plusplus/c/watcom.c b/bld/plusplus/c/watcom.c index 6721ed5ffe..e3b2a15cb0 100644 --- a/bld/plusplus/c/watcom.c +++ b/bld/plusplus/c/watcom.c @@ -42,6 +42,10 @@ #define _TARGET_ "x86 32-bit" #elif _CPU == _AXP #define _TARGET_ "Alpha AXP" +#elif _CPU == _MIPS +#define _TARGET_ "MIPS" +#elif _CPU == _PPC +#define _TARGET_ "PowerPC" #else #error Unknown System #endif diff --git a/bld/plusplus/h/pcheader.h b/bld/plusplus/h/pcheader.h index 540af2ab52..433e97cb64 100644 --- a/bld/plusplus/h/pcheader.h +++ b/bld/plusplus/h/pcheader.h @@ -48,6 +48,8 @@ enum { #define PCH_DEFAULT_FILE_NAME "wpp.pch" #elif _CPU == _AXP #define PCH_DEFAULT_FILE_NAME "wppaxp.pch" +#elif _CPU == _MIPS +#define PCH_DEFAULT_FILE_NAME "wppmps.pch" #elif _CPU == _PPC #define PCH_DEFAULT_FILE_NAME "wppppc.pch" #else @@ -55,7 +57,7 @@ enum { #endif #define PHH_MAJOR 0x03 -#define PHH_MINOR 0x33 +#define PHH_MINOR 0x34 #define TEXT_HEADER_SIZE 40 #ifdef __UNIX__ @@ -83,6 +85,7 @@ enum { #define PHH_ARCHITECTURE_X64 0x05 #define PHH_ARCHITECTURE_ARM 0x06 #define PHH_ARCHITECTURE_ARM64 0x07 +#define PHH_ARCHITECTURE_MIPS 0x08 #if _CPU == 386 #define PHH_TARG_ARCHITECTURE PHH_ARCHITECTURE_386 @@ -90,6 +93,8 @@ enum { #define PHH_TARG_ARCHITECTURE PHH_ARCHITECTURE_286 #elif _CPU == _AXP #define PHH_TARG_ARCHITECTURE PHH_ARCHITECTURE_AXP +#elif _CPU == _MIPS +#define PHH_TARG_ARCHITECTURE PHH_ARCHITECTURE_MIPS #elif _CPU == _PPC #define PHH_TARG_ARCHITECTURE PHH_ARCHITECTURE_PPC #else @@ -117,6 +122,8 @@ enum { #define PHH_HOST_ARCHITECTURE PHH_ARCHITECTURE_ARM #elif defined( _M_ARM64 ) #define PHH_HOST_ARCHITECTURE PHH_ARCHITECTURE_ARM64 +#elif defined( __MIPS__ ) +#define PHH_HOST_ARCHITECTURE PHH_ARCHITECTURE_MIPS #elif defined( __PPC__ ) #define PHH_HOST_ARCHITECTURE PHH_ARCHITECTURE_PPC #else diff --git a/bld/plusplus/h/tgtenv.h b/bld/plusplus/h/tgtenv.h index dda5a66b89..8d49b49859 100644 --- a/bld/plusplus/h/tgtenv.h +++ b/bld/plusplus/h/tgtenv.h @@ -34,19 +34,18 @@ #include "langenvd.h" #if _INTEL_CPU - #define __TGT_SYS __TGT_SYS_X86 - #include "langenv.h" - #elif _CPU == _AXP - - #define __TGT_SYS __TGT_SYS_AXP_NT - #include "langenv.h" - + #define __TGT_SYS __TGT_SYS_AXP_NT +#elif _CPU == _MIPS + #define __TGT_SYS __TGT_SYS_MIPS +#elif _CPU == _PPC + #define __TGT_SYS __TGT_SYS_PPC_NT #else - #error Invalid target environment #endif +#include "langenv.h" + #endif From b86f31a18727a2a85e0a03929f82a74cbae7de60 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Thu, 14 Sep 2023 22:03:20 +0200 Subject: [PATCH 134/258] use macros instead of hard value --- bld/dip/c/dipimp.c | 2 +- bld/mad/c/madimp.c | 2 +- bld/trap/common/qnx/qnxstrt.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bld/dip/c/dipimp.c b/bld/dip/c/dipimp.c index 3e4815fdd0..e7a6042762 100644 --- a/bld/dip/c/dipimp.c +++ b/bld/dip/c/dipimp.c @@ -136,7 +136,7 @@ static HANDLE TaskId; #endif #if defined( __WATCOMC__ ) && ( defined( __DOS__ ) || defined( __UNIX__ ) ) -const char __based( __segname( "_CODE" ) ) Signature[4] = "DIP"; +const char __based( __segname( "_CODE" ) ) Signature[4] = DIPSIG; #endif DIG_DLLEXPORT dip_imp_routines * DIGENTRY DIPLOAD( dip_status *ds, dip_client_routines *client ) diff --git a/bld/mad/c/madimp.c b/bld/mad/c/madimp.c index 43dd46a23a..f010abba9d 100644 --- a/bld/mad/c/madimp.c +++ b/bld/mad/c/madimp.c @@ -142,7 +142,7 @@ static HINSTANCE ThisInst; #endif #if defined( __WATCOMC__ ) && ( defined( __DOS__ ) || defined( __UNIX__ ) ) -const char __based( __segname( "_CODE" ) ) Signature[4] = "MAD"; +const char __based( __segname( "_CODE" ) ) Signature[4] = MADSIG; #endif DIG_DLLEXPORT mad_imp_routines * DIGENTRY MADLOAD( mad_status *status, mad_client_routines *client ) diff --git a/bld/trap/common/qnx/qnxstrt.c b/bld/trap/common/qnx/qnxstrt.c index 673e37e8e1..20f8327fcf 100644 --- a/bld/trap/common/qnx/qnxstrt.c +++ b/bld/trap/common/qnx/qnxstrt.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -44,7 +44,7 @@ static const trap_callbacks *Client; static const trap_requests ImpInterface = { TrapInit, TrapRequest, TrapFini } ; #ifdef __WATCOMC__ -const char __based( __segname( "_CODE" ) ) Signature[4] = "TRAP"; +const char __based( __segname( "_CODE" ) ) Signature[4] = TRAPSIG; #endif const trap_requests *TrapLoad( const trap_callbacks *client ) From 7f5f57bba44ec4c4ccd1f581a7a880af1a4fd46f Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Fri, 15 Sep 2023 00:56:13 +0200 Subject: [PATCH 135/258] correct mistake --- bld/dig/h/dipcli.h | 5 ++++- bld/dig/h/dipsys.h | 3 --- bld/dig/h/madcli.h | 5 ++++- bld/dig/h/madsys.h | 3 --- bld/trap/common/qnx/qnxstrt.c | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/bld/dig/h/dipcli.h b/bld/dig/h/dipcli.h index 20db6b19f7..6693eb92e0 100644 --- a/bld/dig/h/dipcli.h +++ b/bld/dig/h/dipcli.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -36,6 +36,9 @@ #include "digcli.h" #include "diptypes.h" +#define DIPSIG "DIP" +#define DIPSIGVAL 0x00504944UL // "DIP" + #define DIPCli(n) DIPCli ## n #define _DIPCli(n) _DIPCli ## n n diff --git a/bld/dig/h/dipsys.h b/bld/dig/h/dipsys.h index fa92582f19..c34843f373 100644 --- a/bld/dig/h/dipsys.h +++ b/bld/dig/h/dipsys.h @@ -33,9 +33,6 @@ // on WIN64 long is OK because HANDLE can be hold as 32-bit sign extended value // even if HANDLE is defined as 64-bit value -#define DIPSIG "DIP" -#define DIPSIGVAL 0x00504944UL // "DIP" - #if defined( __WINDOWS__ ) #define NULL_SYSHDL NULL typedef void (DIGENTRY *dip_sys_handle)( void ); diff --git a/bld/dig/h/madcli.h b/bld/dig/h/madcli.h index d855e591e6..994d0af2e1 100644 --- a/bld/dig/h/madcli.h +++ b/bld/dig/h/madcli.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -37,6 +37,9 @@ #include "digsyscf.h" #include "madtypes.h" +#define MADSIG "MAD" +#define MADSIGVAL 0x0044414DUL // "MAD" + #define MADCli(n) MADCli ## n #define _MADCli(n) _MADCli ## n n diff --git a/bld/dig/h/madsys.h b/bld/dig/h/madsys.h index 20acce0401..0532e1bc5f 100644 --- a/bld/dig/h/madsys.h +++ b/bld/dig/h/madsys.h @@ -33,9 +33,6 @@ // on WIN64 long is OK because HANDLE can be hold as 32-bit sign extended value // even if HANDLE is defined as 64-bit value -#define MADSIG "MAD" -#define MADSIGVAL 0x0044414DUL // "MAD" - #if defined( __WINDOWS__ ) #define NULL_SYSHDL NULL typedef void (DIGENTRY *mad_sys_handle)( void ); diff --git a/bld/trap/common/qnx/qnxstrt.c b/bld/trap/common/qnx/qnxstrt.c index 20f8327fcf..8711bcde67 100644 --- a/bld/trap/common/qnx/qnxstrt.c +++ b/bld/trap/common/qnx/qnxstrt.c @@ -44,7 +44,7 @@ static const trap_callbacks *Client; static const trap_requests ImpInterface = { TrapInit, TrapRequest, TrapFini } ; #ifdef __WATCOMC__ -const char __based( __segname( "_CODE" ) ) Signature[4] = TRAPSIG; +const char __based( __segname( "_CODE" ) ) Signature[4] = { TRAPSIG }; #endif const trap_requests *TrapLoad( const trap_callbacks *client ) From b3c50045ac05d6ce507a4df0e50654fcfa6049ed Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Fri, 15 Sep 2023 01:10:13 +0200 Subject: [PATCH 136/258] use global definitions of break points for supported architectures --- bld/mad/axp/c/axptrace.c | 6 ++++-- bld/mad/c/madimp.c | 5 ++--- bld/mad/mps/c/mpstrace.c | 6 +++--- bld/mad/ppc/c/ppctrace.c | 6 ++++-- bld/mad/x86/c/x86trace.c | 9 +++++---- bld/watcom/h/brkptcpu.h | 6 +++--- 6 files changed, 21 insertions(+), 17 deletions(-) diff --git a/bld/mad/axp/c/axptrace.c b/bld/mad/axp/c/axptrace.c index e692f946b7..08e4a5626c 100644 --- a/bld/mad/axp/c/axptrace.c +++ b/bld/mad/axp/c/axptrace.c @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -32,6 +33,8 @@ #include "axp.h" #include "madregs.h" +#include "brkptcpu.h" + unsigned MADIMPENTRY( TraceSize )( void ) { @@ -136,7 +139,6 @@ void MADIMPENTRY( TraceFini )( mad_trace_data *td ) } #define JMP_SHORT 0xc3e00002 -#define BRK_POINT 0x00000080 mad_status MADIMPENTRY( UnexpectedBreak )( mad_registers *mr, char *buff, size_t *buff_size_p ) { @@ -158,7 +160,7 @@ mad_status MADIMPENTRY( UnexpectedBreak )( mad_registers *mr, char *buff, size_t a.mach.offset = mr->axp.pal.nt.fir.u._32[0]; memset( &data, 0, sizeof( data ) ); MCReadMem( a, sizeof( data ), &data ); - if( data.brk != BRK_POINT ) + if( data.brk != BRKPOINT ) return( MS_FAIL ); mr->axp.pal.nt.fir.u._32[0] += sizeof( unsigned_32 ); if( data.br != JMP_SHORT ) diff --git a/bld/mad/c/madimp.c b/bld/mad/c/madimp.c index f010abba9d..9aa36eb42a 100644 --- a/bld/mad/c/madimp.c +++ b/bld/mad/c/madimp.c @@ -279,9 +279,8 @@ void DIGENTRY MADUNLOAD( void ) int PASCAL WinMain( HINSTANCE this_inst, HINSTANCE prev_inst, LPSTR cmdline, int cmdshow ) /***************************************************************************************** - - Initialization, message loop. -*/ + * Initialization, message loop. + */ { MSG msg; FARPROC *func; diff --git a/bld/mad/mps/c/mpstrace.c b/bld/mad/mps/c/mpstrace.c index 8cc3f1ae95..64ed9420f3 100644 --- a/bld/mad/mps/c/mpstrace.c +++ b/bld/mad/mps/c/mpstrace.c @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -31,6 +32,7 @@ #include "mips.h" #include "madregs.h" +#include "brkptcpu.h" /* Implementation Notes: @@ -175,8 +177,6 @@ void MADIMPENTRY( TraceFini )( mad_trace_data *td ) } #define JMP_SHORT 0x10000003 // 'beq $zero,$zero' (3 instructions forward) -#define BRK_POINT 0x0000000D // 'break' (with code of 0) - mad_status MADIMPENTRY( UnexpectedBreak )( mad_registers *mr, char *buff, size_t *buff_size_p ) { @@ -199,7 +199,7 @@ mad_status MADIMPENTRY( UnexpectedBreak )( mad_registers *mr, char *buff, size_t a.mach.offset = mr->mips.pc.u._32[I64LO32]; memset( &data, 0, sizeof( data ) ); MCReadMem( a, sizeof( data ), &data ); - if( data.brk != BRK_POINT ) + if( data.brk != BRKPOINT ) return( MS_FAIL ); mr->mips.pc.u._32[I64LO32] += sizeof( unsigned_32 ); if( data.beq != JMP_SHORT ) diff --git a/bld/mad/ppc/c/ppctrace.c b/bld/mad/ppc/c/ppctrace.c index 11e7309841..f79597b0a7 100644 --- a/bld/mad/ppc/c/ppctrace.c +++ b/bld/mad/ppc/c/ppctrace.c @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -31,6 +32,8 @@ #include "ppc.h" #include "madregs.h" +#include "brkptcpu.h" + unsigned MADIMPENTRY( TraceSize )( void ) { @@ -105,7 +108,6 @@ void MADIMPENTRY( TraceFini )( mad_trace_data *td ) } #define JMP_SHORT 0x4800000c // 'b' (to 3rd next instruction) -#define BRK_POINT 0x7fe00008 // 'trap' mad_status MADIMPENTRY( UnexpectedBreak )( mad_registers *mr, char *buff, size_t *buff_size_p ) { @@ -127,7 +129,7 @@ mad_status MADIMPENTRY( UnexpectedBreak )( mad_registers *mr, char *buff, size_t a.mach.offset = mr->ppc.iar.u._32[I64LO32]; memset( &data, 0, sizeof( data ) ); MCReadMem( a, sizeof( data ), &data ); - if( data.brk != BRK_POINT ) + if( data.brk != BRKPOINT ) return( MS_FAIL ); mr->ppc.iar.u._32[I64LO32] += sizeof( unsigned_32 ); if( data.br != JMP_SHORT ) diff --git a/bld/mad/x86/c/x86trace.c b/bld/mad/x86/c/x86trace.c index a531675854..4de89d0a29 100644 --- a/bld/mad/x86/c/x86trace.c +++ b/bld/mad/x86/c/x86trace.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -32,6 +32,8 @@ #include "x86.h" #include "madregs.h" +#include "brkptcpu.h" + unsigned MADIMPENTRY( TraceSize )( void ) { @@ -375,8 +377,7 @@ void MADIMPENTRY( TraceFini )( mad_trace_data *td ) /* unused parameters */ (void)td; } -#define JMP_SHORT ((unsigned char)0XEB) -#define BRK_POINT ((unsigned char)0XCC) +#define JMP_SHORT ((unsigned char)0xEB) mad_status MADIMPENTRY( UnexpectedBreak )( mad_registers *mr, char *buff, size_t *buff_size_p ) { @@ -396,7 +397,7 @@ mad_status MADIMPENTRY( UnexpectedBreak )( mad_registers *mr, char *buff, size_t a = GetRegIP( mr ); memset( &data, 0, sizeof( data ) ); MCReadMem( a, sizeof( data.b ), data.b ); - if( data.b[0] != BRK_POINT ) + if( data.b[0] != BRKPOINT ) return( MS_FAIL ); mr->x86.cpu.eip += 1; if( data.b[1] != JMP_SHORT ) diff --git a/bld/watcom/h/brkptcpu.h b/bld/watcom/h/brkptcpu.h index de22fd604c..fd25e6f605 100644 --- a/bld/watcom/h/brkptcpu.h +++ b/bld/watcom/h/brkptcpu.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2015-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2015-2023 The Open Watcom Contributors. All Rights Reserved. * * ======================================================================== * @@ -68,14 +68,14 @@ typedef unsigned opcode_type; #elif defined( __MIPS__ ) -//#define TRACE_BIT 0 +//#define TRACE_BIT 0 /* no single step CPU flag */ #define BRKPOINT 0x0000000D typedef unsigned opcode_type; #elif defined( __AXP__ ) -//#define TRACE_BIT 0 +//#define TRACE_BIT 0 /* no single step CPU flag */ #define BRKPOINT 0x00000080 typedef unsigned opcode_type; From 09926d73e26881c18c98824d8485939c8d60761d Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Fri, 15 Sep 2023 01:16:05 +0200 Subject: [PATCH 137/258] remove redundant header reference --- bld/commonui/c/memwnd.c | 3 +-- bld/commonui/c/pushwin.c | 3 +-- bld/gui/win/c/guicombo.c | 1 - bld/gui/win/c/guicontr.c | 21 +++++++++------------ bld/gui/win/c/guienum.c | 1 - bld/gui/win/c/guif1hk.c | 1 - bld/gui/win/c/guifdlg.c | 3 +-- bld/gui/win/c/guirdlg.c | 1 - bld/gui/win/c/guixwind.c | 3 +-- 9 files changed, 13 insertions(+), 24 deletions(-) diff --git a/bld/commonui/c/memwnd.c b/bld/commonui/c/memwnd.c index 9f4247d886..ae64afe2ff 100644 --- a/bld/commonui/c/memwnd.c +++ b/bld/commonui/c/memwnd.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2015-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2015-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -53,7 +53,6 @@ #include "deasm.h" #include "ldstr.h" #include "uistr.grh" -#include "wclbproc.h" #ifndef NOUSE3D #include "ctl3dcvr.h" #endif diff --git a/bld/commonui/c/pushwin.c b/bld/commonui/c/pushwin.c index f897374419..adab7d6393 100644 --- a/bld/commonui/c/pushwin.c +++ b/bld/commonui/c/pushwin.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2015-2019 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2015-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -37,7 +37,6 @@ #include "bool.h" #include "cguimem.h" #include "pushwin.h" -#include "wclbproc.h" /* Window callback functions prototypes */ diff --git a/bld/gui/win/c/guicombo.c b/bld/gui/win/c/guicombo.c index eeeb18659c..db469f5e3c 100644 --- a/bld/gui/win/c/guicombo.c +++ b/bld/gui/win/c/guicombo.c @@ -37,7 +37,6 @@ #include "guicontr.h" //#include "guixhook.h" #include "ctl3dcvr.h" -#include "wclbproc.h" #include "guixwind.h" #include "oswincls.h" diff --git a/bld/gui/win/c/guicontr.c b/bld/gui/win/c/guicontr.c index 4ffcd292ec..75cb36e4e3 100644 --- a/bld/gui/win/c/guicontr.c +++ b/bld/gui/win/c/guicontr.c @@ -44,7 +44,6 @@ //#include "guixhook.h" #include "ctl3dcvr.h" #include "guirdlg.h" -#include "wclbproc.h" #ifdef __NT__ #undef _WIN32_IE #define _WIN32_IE 0x0400 @@ -558,7 +557,15 @@ static HWND CreateControl( gui_control_info *ctl_info, gui_window *parent_wnd, c } } -#ifdef __OS2_PM__ + /* create invisible + * if GUIAlloc fails, window will never show + */ + style &= ~WS_VISIBLE; + if( parent_wnd != NULL ) { + style |= WS_CHILD; + } + +#if defined( __OS2_PM__ ) pctldata = NULL; if( ctl_info->control_class == GUI_EDIT ) { edata.cb = sizeof( edata ); @@ -567,16 +574,6 @@ static HWND CreateControl( gui_control_info *ctl_info, gui_window *parent_wnd, c edata.ichMaxSel = 0; pctldata = &edata; } -#endif - - style &= ~WS_VISIBLE; /* create invisible -- if GUIAlloc fails, window - * will never show - */ - if( parent_wnd != NULL ) { - style |= WS_CHILD; - } - -#if defined( __OS2_PM__ ) _wpi_createanywindow( (PSZ)GUIControls[ctl_info->control_class].classname, new_text, style, scr_pos->x, scr_pos->y, scr_size->x, scr_size->y, parent_wnd->hwnd, (HMENU)ctl_info->id, GUIMainHInst, diff --git a/bld/gui/win/c/guienum.c b/bld/gui/win/c/guienum.c index 72adf7d99e..a6e88b162b 100644 --- a/bld/gui/win/c/guienum.c +++ b/bld/gui/win/c/guienum.c @@ -34,7 +34,6 @@ #include "guiwind.h" #include #include "guixutil.h" -#include "wclbproc.h" #include "guixwind.h" diff --git a/bld/gui/win/c/guif1hk.c b/bld/gui/win/c/guif1hk.c index 0445040a49..346ea4ea48 100644 --- a/bld/gui/win/c/guif1hk.c +++ b/bld/gui/win/c/guif1hk.c @@ -34,7 +34,6 @@ #include "guixutil.h" #include "guicontr.h" #include "guixwind.h" -#include "wclbproc.h" /* Local Window callback functions prototypes */ diff --git a/bld/gui/win/c/guifdlg.c b/bld/gui/win/c/guifdlg.c index cc6c1fd750..a5e4fab941 100644 --- a/bld/gui/win/c/guifdlg.c +++ b/bld/gui/win/c/guifdlg.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -48,7 +48,6 @@ #include "guistr.h" //#include "guixhook.h" #include "ctl3dcvr.h" -#include "wclbproc.h" #include "guixwind.h" #include "pathgrp2.h" diff --git a/bld/gui/win/c/guirdlg.c b/bld/gui/win/c/guirdlg.c index 8fbc7104cc..7718d7f177 100644 --- a/bld/gui/win/c/guirdlg.c +++ b/bld/gui/win/c/guirdlg.c @@ -36,7 +36,6 @@ #include "guixdlg.h" #include "guirdlg.h" #include "guixwind.h" -#include "wclbproc.h" #ifdef __NT__ #undef _WIN32_IE #define _WIN32_IE 0x0400 diff --git a/bld/gui/win/c/guixwind.c b/bld/gui/win/c/guixwind.c index 024f780534..dc55c02be0 100644 --- a/bld/gui/win/c/guixwind.c +++ b/bld/gui/win/c/guixwind.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2015-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2015-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -57,7 +57,6 @@ #include "guirdlg.h" #include "guimdi.h" #include "guistat.h" -#include "wclbproc.h" #if !defined(__NT__) From e531ef03d9c56b51681a99333d08828a900cf5b2 Mon Sep 17 00:00:00 2001 From: Detlef Riekenberg Date: Fri, 15 Sep 2023 19:13:30 +0200 Subject: [PATCH 138/258] WIP: Prepare for building wppmps and wppppc on linux (#1129) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit WIP: C++ compiler - change necessary for building MIPS and PPC compiler versions This is not complete, only fix code to be buildable but still not usable * add new architecture macros for C++ compiler build make file * WIP: add builder.ctl for new C++ compiler architecture * WIP: add C++ compiler host build make file for 32-bit Linux * WIP: add C++ compiler host build make file for 64-bit Linux * WIP: add C++ compiler host build make file for 32-bit Linux * WIP: add C++ compiler host build make file for 64-bit Linux * WIP: correct generated reference for C run-time library symbols *WIP: correct Macros build break Co-authored-by: Jiří Malák --- bld/cpplib/master.mif | 2 + bld/plusplus/builder.ctl | 2 + bld/plusplus/c/cginfo.c | 18 +++----- bld/plusplus/c/enum.c | 26 +++++------ bld/plusplus/c/segment.c | 18 +++----- bld/plusplus/h/tgtenv.h | 3 +- bld/plusplus/mps/binmake | 6 +++ bld/plusplus/mps/builder.ctl | 73 ++++++++++++++++++++++++++++++ bld/plusplus/mps/exever.rc | 9 ++++ bld/plusplus/mps/linux386/makefile | 6 +++ bld/plusplus/mps/linuxx64/makefile | 6 +++ bld/plusplus/mps/target.h | 42 +++++++++++++++++ bld/plusplus/mps/target.mif | 3 ++ bld/plusplus/mps/version.rc | 8 ++++ bld/plusplus/ppc/binmake | 6 +++ bld/plusplus/ppc/builder.ctl | 73 ++++++++++++++++++++++++++++++ bld/plusplus/ppc/exever.rc | 9 ++++ bld/plusplus/ppc/linux386/makefile | 6 +++ bld/plusplus/ppc/linuxx64/makefile | 6 +++ bld/plusplus/ppc/target.h | 42 +++++++++++++++++ bld/plusplus/ppc/target.mif | 3 ++ bld/plusplus/ppc/version.rc | 8 ++++ 22 files changed, 336 insertions(+), 39 deletions(-) create mode 100644 bld/plusplus/mps/binmake create mode 100644 bld/plusplus/mps/builder.ctl create mode 100644 bld/plusplus/mps/exever.rc create mode 100644 bld/plusplus/mps/linux386/makefile create mode 100644 bld/plusplus/mps/linuxx64/makefile create mode 100644 bld/plusplus/mps/target.h create mode 100644 bld/plusplus/mps/target.mif create mode 100644 bld/plusplus/mps/version.rc create mode 100644 bld/plusplus/ppc/binmake create mode 100644 bld/plusplus/ppc/builder.ctl create mode 100644 bld/plusplus/ppc/exever.rc create mode 100644 bld/plusplus/ppc/linux386/makefile create mode 100644 bld/plusplus/ppc/linuxx64/makefile create mode 100644 bld/plusplus/ppc/target.h create mode 100644 bld/plusplus/ppc/target.mif create mode 100644 bld/plusplus/ppc/version.rc diff --git a/bld/cpplib/master.mif b/bld/cpplib/master.mif index 2db358f00c..da607343d6 100644 --- a/bld/cpplib/master.mif +++ b/bld/cpplib/master.mif @@ -13,6 +13,8 @@ plib_host_cpu_086 = i86 plib_host_cpu_286 = i86 plib_host_cpu_386 = 386 plib_host_cpu_axp = axp +plib_host_cpu_mps = mps +plib_host_cpu_ppc = ppc host_cpu = $(plib_host_cpu_$(plib_$(processor))) plib_host_os_generic = generic diff --git a/bld/plusplus/builder.ctl b/bld/plusplus/builder.ctl index ddf4dd9dc9..698f86cee4 100644 --- a/bld/plusplus/builder.ctl +++ b/bld/plusplus/builder.ctl @@ -10,5 +10,7 @@ cdsay . [ INCLUDE i86/builder.ctl ] [ INCLUDE 386/builder.ctl ] [ INCLUDE axp/builder.ctl ] +[ INCLUDE mps/builder.ctl ] +[ INCLUDE ppc/builder.ctl ] cdsay . diff --git a/bld/plusplus/c/cginfo.c b/bld/plusplus/c/cginfo.c index 438641ac4c..44ad37101b 100644 --- a/bld/plusplus/c/cginfo.c +++ b/bld/plusplus/c/cginfo.c @@ -1032,7 +1032,6 @@ static void addDefaultImports( void ) CM_NULL = 0x00 } check_mask; PragmaExtrefsInject(); -#if _INTEL_CPU || ( _CPU == _AXP ) if( _HAS_ANY_MAIN ) { check_mask control; @@ -1077,9 +1076,6 @@ static void addDefaultImports( void ) control = CM_NULL; } } -#else - #error bad system -#endif if( CompFlags.emit_library_names ) { if( CompFlags.float_used ) { CgInfoAddImport( "_fltused_" ); @@ -1116,8 +1112,8 @@ static void addDefaultImports( void ) } #endif } - if( CompFlags.main_has_parms ) { #if _INTEL_CPU + if( CompFlags.main_has_parms ) { #if _CPU == 8086 if( CompFlags.has_wide_char_main ) { CgInfoAddImport( "__wargc" ); @@ -1139,16 +1135,14 @@ static void addDefaultImports( void ) } } #endif -#elif _CPU == _AXP - if( CompFlags.has_wide_char_main ) { - CgInfoAddImport( "_wargc" ); - } else { - CgInfoAddImport( "_argc" ); - } + } +#elif _RISC_CPU + if( CompFlags.main_has_parms ) { + CgInfoAddImport( "_argc" ); + } #else #error missing _CPU case #endif - } if( CompFlags.bw_switch_used ) { CgInfoAddImport( "__init_default_win" ); } diff --git a/bld/plusplus/c/enum.c b/bld/plusplus/c/enum.c index 078d851191..41bc6ba651 100644 --- a/bld/plusplus/c/enum.c +++ b/bld/plusplus/c/enum.c @@ -67,7 +67,7 @@ struct enum_range // describe range for enum }; static struct enum_range const range_table[] = -#if _CPU == 386 || _CPU == _AXP +#if _CPU == 8086 { { Init64Val( 0xFFFFFFFF, 0xFFFFFF80 ) , Init64Val( 0x00000000, 0x0000007F ) , TYP_SCHAR @@ -78,19 +78,19 @@ static struct enum_range const range_table[] = } , { Init64Val( 0xFFFFFFFF, 0xFFFF8000 ) , Init64Val( 0x00000000, 0x00007FFF ) - , TYP_SSHORT + , TYP_SINT } , { Init64Val( 0x00000000, 0x00000000 ) , Init64Val( 0x00000000, 0x0000FFFF ) - , TYP_USHORT + , TYP_UINT } , { Init64Val( 0xFFFFFFFF, 0x80000000 ) , Init64Val( 0x00000000, 0x7FFFFFFF ) - , TYP_SINT + , TYP_SLONG } , { Init64Val( 0x00000000, 0x00000000 ) , Init64Val( 0x00000000, 0xFFFFFFFF ) - , TYP_UINT + , TYP_ULONG } , { Init64Val( 0x80000000, 0x00000000 ) , Init64Val( 0x7FFFFFFF, 0xFFFFFFFF ) @@ -101,8 +101,8 @@ static struct enum_range const range_table[] = , TYP_ULONG64 } }; - #define RANGE_INDEX_SINT 4 -#elif _CPU == 8086 + #define RANGE_INDEX_SINT 2 +#else { { Init64Val( 0xFFFFFFFF, 0xFFFFFF80 ) , Init64Val( 0x00000000, 0x0000007F ) , TYP_SCHAR @@ -113,19 +113,19 @@ static struct enum_range const range_table[] = } , { Init64Val( 0xFFFFFFFF, 0xFFFF8000 ) , Init64Val( 0x00000000, 0x00007FFF ) - , TYP_SINT + , TYP_SSHORT } , { Init64Val( 0x00000000, 0x00000000 ) , Init64Val( 0x00000000, 0x0000FFFF ) - , TYP_UINT + , TYP_USHORT } , { Init64Val( 0xFFFFFFFF, 0x80000000 ) , Init64Val( 0x00000000, 0x7FFFFFFF ) - , TYP_SLONG + , TYP_SINT } , { Init64Val( 0x00000000, 0x00000000 ) , Init64Val( 0x00000000, 0xFFFFFFFF ) - , TYP_ULONG + , TYP_UINT } , { Init64Val( 0x80000000, 0x00000000 ) , Init64Val( 0x7FFFFFFF, 0xFFFFFFFF ) @@ -136,9 +136,7 @@ static struct enum_range const range_table[] = , TYP_ULONG64 } }; - #define RANGE_INDEX_SINT 2 -#else -#error unknown _CPU + #define RANGE_INDEX_SINT 4 #endif #define ENUM_RNG_MAX ARRAY_SIZE( range_table ) diff --git a/bld/plusplus/c/segment.c b/bld/plusplus/c/segment.c index c41c378489..d352667e9f 100644 --- a/bld/plusplus/c/segment.c +++ b/bld/plusplus/c/segment.c @@ -211,7 +211,7 @@ static PC_SEGMENT *segIdLookup( // LOOKUP SEGMENT FOR ID } -#if _CPU == _AXP || COMP_CFG_COFF == 1 +#if _RISC_CPU || COMP_CFG_COFF == 1 static fe_seg_id markSegmentComdat( // MARK SEGMENT AS COMDAT SEGMENT fe_seg_id segid ) // - segment id { @@ -320,10 +320,8 @@ static PC_SEGMENT *segmentAlloc( // SEGMENT: ALLOCATE NEW SEGMENT // we don't want padding introduced #if _INTEL_CPU curr->align = TARGET_SHORT; -#elif _CPU == _AXP - curr->align = TARGET_POINTER; #else -#error no alignment set + curr->align = TARGET_POINTER; #endif // we don't want alignment changed either curr->fixed_alignment = true; @@ -437,7 +435,7 @@ target_offset_t SegmentAlignment( // SEGMENT: ALIGNMENT FOR TYPE if( CompFlags.dont_align_segs ) { return( TARGET_CHAR ); } -#if _CPU == _AXP +#if _RISC_CPU if( PackAmount != TARGET_CHAR ) { #else if( OptSize <= 50 || PackAmount != TARGET_CHAR ) { @@ -828,7 +826,7 @@ fe_seg_id SegmentAddSym( // SEGMENT: ADD SYMBOL TO SPECIFIED SEGMENT } -#if _CPU == _AXP || COMP_CFG_COFF == 1 +#if _RISC_CPU || COMP_CFG_COFF == 1 fe_seg_id SegmentAddComdatData( // ADD SEGMENT FOR A COMDAT DATA SYMBOL SYMBOL sym, // - the symbol SEGID_CONTROL control ) // - segment control @@ -934,10 +932,8 @@ SYMBOL SegmentLabelStackReset( // RESET STACK-SEGMENT LABEL #if _INTEL_CPU #define CODE_ENDING "TEXT" -#elif _CPU == _AXP - #define CODE_ENDING "text" #else - #error Invalid machine + #define CODE_ENDING "text" #endif #define ENDING_SIZE (sizeof(CODE_ENDING)-1) @@ -1234,7 +1230,7 @@ fe_seg_id SegmentForDefinedFunc(// GET SEGMENT FOR A DEFINED FUNCTION } else { segid = nextZmSegment(); } -#elif _CPU == _AXP || COMP_CFG_COFF == 1 +#elif _RISC_CPU || COMP_CFG_COFF == 1 segid = nextZmSegment(); if( SymIsGennedComdatFun( func ) ) { segid = markSegmentComdat( segid ); @@ -1242,7 +1238,7 @@ fe_seg_id SegmentForDefinedFunc(// GET SEGMENT FOR A DEFINED FUNCTION #else #error Bad Machine Type #endif -#if _CPU == _AXP || COMP_CFG_COFF == 1 +#if _RISC_CPU || COMP_CFG_COFF == 1 } else if( SymIsGennedComdatFun( func ) ) { segid = nextZmSegment(); segid = markSegmentComdat( segid ); diff --git a/bld/plusplus/h/tgtenv.h b/bld/plusplus/h/tgtenv.h index 8d49b49859..ea6189c1c0 100644 --- a/bld/plusplus/h/tgtenv.h +++ b/bld/plusplus/h/tgtenv.h @@ -43,9 +43,8 @@ #define __TGT_SYS __TGT_SYS_PPC_NT #else #error Invalid target environment - #endif -#include "langenv.h" +#include "langenv.h" #endif diff --git a/bld/plusplus/mps/binmake b/bld/plusplus/mps/binmake new file mode 100644 index 0000000000..56f1c6787f --- /dev/null +++ b/bld/plusplus/mps/binmake @@ -0,0 +1,6 @@ +#pmake: binmake + +host_os = $(bld_os) +host_cpu = $(bld_cpu) + +!include ../target.mif diff --git a/bld/plusplus/mps/builder.ctl b/bld/plusplus/mps/builder.ctl new file mode 100644 index 0000000000..f2b5da8e6e --- /dev/null +++ b/bld/plusplus/mps/builder.ctl @@ -0,0 +1,73 @@ +# wppaxp Builder Control file +# =========================== + +set PROJNAME=wppmps + +set BINTOOL=0 + +set PROJDIR= + +[ INCLUDE "/build/prolog.ctl" ] + +[ INCLUDE "/build/defrule.ctl" ] + +[ BLOCK rel ] +#====================== + cdsay "" + +[ BLOCK build ] +#======================== + cdsay "" + /bwppmps.exe "/build//bwppmps" + /bwppdmps "/build//bwppdmps" + +[ BLOCK clean ] +#======================== + echo rm -f "/build//bwppmps" + rm -f "/build//bwppmps" + rm -f "/build//bwppdmps" + +[ BLOCK rel cprel ] +#============================ + dos386/wppmps.exe "/binw/" + dos386/wppmps.sym "/binw/" + dos386/wppmps01.int "/binw/" + os2386.dll/wppmps.exe "/binp/" + os2386.dll/wppmps.sym "/binp/" + os2386.dll/wppdmps.dll "/binp/dll/" + os2386.dll/wppdmps.sym "/binp/dll/" + os2386.dll/wppmps01.int "/binp/dll/" + nt386.dll/wppmps.exe "/binnt/" + nt386.dll/wppmps.sym "/binnt/" + nt386.dll/wppdmps.dll "/binnt/" + nt386.dll/wppdmps.sym "/binnt/" + nt386.dll/wppmps01.int "/binnt/" + ntaxp.dll/wppmps.exe "/axpnt/" + ntaxp.dll/wppmps.sym "/axpnt/" + ntaxp.dll/wppdmps.dll "/axpnt/" + ntaxp.dll/wppdmps.sym "/axpnt/" + ntaxp.dll/wppmps01.int "/axpnt/" + linux386/wppmps.exe "/binl/wppmps" + linux386/wppmps.sym "/binl/" + linux386/wppmps01.int "/binl/" + + ntx64.dll/wppmps.exe "/binnt64/" + ntx64.dll/wppdmps.dll "/binnt64/" + ntx64.dll/wppmps01.int "/binnt64/" + linuxx64/wppmps.exe "/binl64/wppmps" + linuxx64/wppmps.sym "/binl64/" + linuxx64/wppmps01.int "/binl64/" + linuxarm/wppmps.exe "/arml/wppmps" + linuxarm/wppmps01.int "/arml/" + linuxa64/wppmps.exe "/arml64/wppmps" + linuxa64/wppmps01.int "/arml64/" + osxx64/wppmps.exe "/bino64/wppmps" + osxx64/wppmps01.int "/bino64/" + osxarm/wppmps.exe "/armo/wppmps" + osxarm/wppmps01.int "/armo/" + osxa64/wppmps.exe "/armo64/wppmps" + osxa64/wppmps01.int "/armo64/" + +[ BLOCK . . ] + +[ INCLUDE "/build/epilog.ctl" ] diff --git a/bld/plusplus/mps/exever.rc b/bld/plusplus/mps/exever.rc new file mode 100644 index 0000000000..7134017db5 --- /dev/null +++ b/bld/plusplus/mps/exever.rc @@ -0,0 +1,9 @@ +#define VERINFO_EXE +#define VERINFO_FILEVERSION $j, $n, $h, $l +#define VERINFO_PRODUCTVERSION $j, $n, $h, $l +#define VERINFO_FILEDESCRIPTION_STR "Open Watcom C++ Compiler for MIPS" +#define VERINFO_FILEVERSION_STR "$j.$n" +#define VERINFO_INTERNALNAME_STR "$0" +#define VERINFO_PRODUCTVERSION_STR "$j.$n" + +#include "cmnvinfo.rc" diff --git a/bld/plusplus/mps/linux386/makefile b/bld/plusplus/mps/linux386/makefile new file mode 100644 index 0000000000..c0acede841 --- /dev/null +++ b/bld/plusplus/mps/linux386/makefile @@ -0,0 +1,6 @@ +#pmake: nobuild target_mps flat os_linux cpu_386 + +host_os = linux +host_cpu = 386 + +!include ../target.mif diff --git a/bld/plusplus/mps/linuxx64/makefile b/bld/plusplus/mps/linuxx64/makefile new file mode 100644 index 0000000000..82a3051cf0 --- /dev/null +++ b/bld/plusplus/mps/linuxx64/makefile @@ -0,0 +1,6 @@ +#pmake: nobuild target_mps flat os_linux cpu_x64 + +host_os = linux +host_cpu = x64 + +!include ../target.mif diff --git a/bld/plusplus/mps/target.h b/bld/plusplus/mps/target.h new file mode 100644 index 0000000000..79aa647c48 --- /dev/null +++ b/bld/plusplus/mps/target.h @@ -0,0 +1,42 @@ +/**************************************************************************** +* +* Open Watcom Project +* +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. +* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. +* +* ======================================================================== +* +* This file contains Original Code and/or Modifications of Original +* Code as defined in and that are subject to the Sybase Open Watcom +* Public License version 1.0 (the 'License'). You may not use this file +* except in compliance with the License. BY USING THIS FILE YOU AGREE TO +* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is +* provided with the Original Code and Modifications, and is also +* available at www.sybase.com/developer/opensource. +* +* The Original Code and all software distributed under the License are +* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM +* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR +* NON-INFRINGEMENT. Please see the License for the specific language +* governing rights and limitations under the License. +* +* ======================================================================== +* +* Description: Configuration for MIPS target. +* +****************************************************************************/ + + +/* size of data types on target machine */ + +#ifndef _TARGET_INCLUDED +#define _TARGET_INCLUDED +#include "target32.h" +#include "targdef.h" + +#define _CPU _MIPS + +#endif diff --git a/bld/plusplus/mps/target.mif b/bld/plusplus/mps/target.mif new file mode 100644 index 0000000000..fda8353d55 --- /dev/null +++ b/bld/plusplus/mps/target.mif @@ -0,0 +1,3 @@ +target_cpu = mps + +!include ../../master.mif diff --git a/bld/plusplus/mps/version.rc b/bld/plusplus/mps/version.rc new file mode 100644 index 0000000000..d5a6d3523f --- /dev/null +++ b/bld/plusplus/mps/version.rc @@ -0,0 +1,8 @@ +#define VERINFO_FILEVERSION $j, $n, $h, $l +#define VERINFO_PRODUCTVERSION $j, $n, $h, $l +#define VERINFO_FILEDESCRIPTION_STR "Open Watcom C++ Compiler (DLL) for MIPS" +#define VERINFO_FILEVERSION_STR "$j.$n" +#define VERINFO_INTERNALNAME_STR "$0" +#define VERINFO_PRODUCTVERSION_STR "$j.$n" + +#include "cmnvinfo.rc" diff --git a/bld/plusplus/ppc/binmake b/bld/plusplus/ppc/binmake new file mode 100644 index 0000000000..56f1c6787f --- /dev/null +++ b/bld/plusplus/ppc/binmake @@ -0,0 +1,6 @@ +#pmake: binmake + +host_os = $(bld_os) +host_cpu = $(bld_cpu) + +!include ../target.mif diff --git a/bld/plusplus/ppc/builder.ctl b/bld/plusplus/ppc/builder.ctl new file mode 100644 index 0000000000..eb508038e0 --- /dev/null +++ b/bld/plusplus/ppc/builder.ctl @@ -0,0 +1,73 @@ +# wppaxp Builder Control file +# =========================== + +set PROJNAME=wppppc + +set BINTOOL=0 + +set PROJDIR= + +[ INCLUDE "/build/prolog.ctl" ] + +[ INCLUDE "/build/defrule.ctl" ] + +[ BLOCK rel ] +#====================== + cdsay "" + +[ BLOCK build ] +#======================== + cdsay "" + /bwppppc.exe "/build//bwppppc" + /bwppdppc "/build//bwppdppc" + +[ BLOCK clean ] +#======================== + echo rm -f "/build//bwppppc" + rm -f "/build//bwppppc" + rm -f "/build//bwppdppc" + +[ BLOCK rel cprel ] +#============================ + dos386/wppppc.exe "/binw/" + dos386/wppppc.sym "/binw/" + dos386/wppppc01.int "/binw/" + os2386.dll/wppppc.exe "/binp/" + os2386.dll/wppppc.sym "/binp/" + os2386.dll/wppdppc.dll "/binp/dll/" + os2386.dll/wppdppc.sym "/binp/dll/" + os2386.dll/wppppc01.int "/binp/dll/" + nt386.dll/wppppc.exe "/binnt/" + nt386.dll/wppppc.sym "/binnt/" + nt386.dll/wppdppc.dll "/binnt/" + nt386.dll/wppdppc.sym "/binnt/" + nt386.dll/wppppc01.int "/binnt/" + ntaxp.dll/wppppc.exe "/axpnt/" + ntaxp.dll/wppppc.sym "/axpnt/" + ntaxp.dll/wppdppc.dll "/axpnt/" + ntaxp.dll/wppdppc.sym "/axpnt/" + ntaxp.dll/wppppc01.int "/axpnt/" + linux386/wppppc.exe "/binl/wppppc" + linux386/wppppc.sym "/binl/" + linux386/wppppc01.int "/binl/" + + ntx64.dll/wppppc.exe "/binnt64/" + ntx64.dll/wppdppc.dll "/binnt64/" + ntx64.dll/wppppc01.int "/binnt64/" + linuxx64/wppppc.exe "/binl64/wppppc" + linuxx64/wppppc.sym "/binl64/" + linuxx64/wppppc01.int "/binl64/" + linuxarm/wppppc.exe "/arml/wppppc" + linuxarm/wppppc01.int "/arml/" + linuxa64/wppppc.exe "/arml64/wppppc" + linuxa64/wppppc01.int "/arml64/" + osxx64/wppppc.exe "/bino64/wppppc" + osxx64/wppppc01.int "/bino64/" + osxarm/wppppc.exe "/armo/wppppc" + osxarm/wppppc01.int "/armo/" + osxa64/wppppc.exe "/armo64/wppppc" + osxa64/wppppc01.int "/armo64/" + +[ BLOCK . . ] + +[ INCLUDE "/build/epilog.ctl" ] diff --git a/bld/plusplus/ppc/exever.rc b/bld/plusplus/ppc/exever.rc new file mode 100644 index 0000000000..414965893a --- /dev/null +++ b/bld/plusplus/ppc/exever.rc @@ -0,0 +1,9 @@ +#define VERINFO_EXE +#define VERINFO_FILEVERSION $j, $n, $h, $l +#define VERINFO_PRODUCTVERSION $j, $n, $h, $l +#define VERINFO_FILEDESCRIPTION_STR "Open Watcom C++ Compiler for PowerPC" +#define VERINFO_FILEVERSION_STR "$j.$n" +#define VERINFO_INTERNALNAME_STR "$0" +#define VERINFO_PRODUCTVERSION_STR "$j.$n" + +#include "cmnvinfo.rc" diff --git a/bld/plusplus/ppc/linux386/makefile b/bld/plusplus/ppc/linux386/makefile new file mode 100644 index 0000000000..7d350160ba --- /dev/null +++ b/bld/plusplus/ppc/linux386/makefile @@ -0,0 +1,6 @@ +#pmake: nobuild target_ppc flat os_linux cpu_386 + +host_os = linux +host_cpu = 386 + +!include ../target.mif diff --git a/bld/plusplus/ppc/linuxx64/makefile b/bld/plusplus/ppc/linuxx64/makefile new file mode 100644 index 0000000000..45df6f8880 --- /dev/null +++ b/bld/plusplus/ppc/linuxx64/makefile @@ -0,0 +1,6 @@ +#pmake: nobuild target_ppc flat os_linux cpu_x64 + +host_os = linux +host_cpu = x64 + +!include ../target.mif diff --git a/bld/plusplus/ppc/target.h b/bld/plusplus/ppc/target.h new file mode 100644 index 0000000000..953397bfd1 --- /dev/null +++ b/bld/plusplus/ppc/target.h @@ -0,0 +1,42 @@ +/**************************************************************************** +* +* Open Watcom Project +* +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. +* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. +* +* ======================================================================== +* +* This file contains Original Code and/or Modifications of Original +* Code as defined in and that are subject to the Sybase Open Watcom +* Public License version 1.0 (the 'License'). You may not use this file +* except in compliance with the License. BY USING THIS FILE YOU AGREE TO +* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is +* provided with the Original Code and Modifications, and is also +* available at www.sybase.com/developer/opensource. +* +* The Original Code and all software distributed under the License are +* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM +* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR +* NON-INFRINGEMENT. Please see the License for the specific language +* governing rights and limitations under the License. +* +* ======================================================================== +* +* Description: Configuration for PowerPC target. +* +****************************************************************************/ + + +/* size of data types on target machine */ + +#ifndef _TARGET_INCLUDED +#define _TARGET_INCLUDED +#include "target32.h" +#include "targdef.h" + +#define _CPU _PPC + +#endif diff --git a/bld/plusplus/ppc/target.mif b/bld/plusplus/ppc/target.mif new file mode 100644 index 0000000000..cca02af689 --- /dev/null +++ b/bld/plusplus/ppc/target.mif @@ -0,0 +1,3 @@ +target_cpu = ppc + +!include ../../master.mif diff --git a/bld/plusplus/ppc/version.rc b/bld/plusplus/ppc/version.rc new file mode 100644 index 0000000000..dd34ccdd73 --- /dev/null +++ b/bld/plusplus/ppc/version.rc @@ -0,0 +1,8 @@ +#define VERINFO_FILEVERSION $j, $n, $h, $l +#define VERINFO_PRODUCTVERSION $j, $n, $h, $l +#define VERINFO_FILEDESCRIPTION_STR "Open Watcom C++ Compiler (DLL) for PowerPC" +#define VERINFO_FILEVERSION_STR "$j.$n" +#define VERINFO_INTERNALNAME_STR "$0" +#define VERINFO_PRODUCTVERSION_STR "$j.$n" + +#include "cmnvinfo.rc" From 52824b3244ae71602ce8b34ed0bbba5b3fba4c8a Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Fri, 15 Sep 2023 19:48:19 +0200 Subject: [PATCH 139/258] move debugger notification about loading/unloading DIP/MAD/TRAP module now it is correctly in loader code it ensure to correct loading/unloading symbolic info for loaded/unloaded module this is used only for executable formats which is not handled by OS debug events on hosts which use DLL modules it is not used because OS signal it to debugger directly --- bld/dig/c/dsx/dipld.c | 10 ----- bld/dig/c/ldrpe.c | 73 +++++++++++++++++++++++-------- bld/dig/c/ldrrex.c | 96 +++++++++++++++++++++++++++++++++++------ bld/dig/c/linux/dipld.c | 10 ----- bld/dig/c/linux/madld.c | 4 +- bld/dig/c/osx/dipld.c | 10 ----- bld/dig/c/qnx/dipld.c | 10 ----- 7 files changed, 142 insertions(+), 71 deletions(-) diff --git a/bld/dig/c/dsx/dipld.c b/bld/dig/c/dsx/dipld.c index 76f82b25ba..e6b743c8ce 100644 --- a/bld/dig/c/dsx/dipld.c +++ b/bld/dig/c/dsx/dipld.c @@ -49,9 +49,6 @@ void DIPSysUnload( dip_sys_handle *sys_hdl ) { - /* - * We should unload the symbols here but it's not worth the trouble - */ if( *sys_hdl != NULL_SYSHDL ) { loader_unload_image( *sys_hdl ); *sys_hdl = NULL_SYSHDL; @@ -87,13 +84,6 @@ dip_status DIPSysLoad( const char *base_name, dip_client_routines *cli, dip_imp_ return( status ); } if( init_func != NULL && (*imp = init_func( &status, cli )) != NULL ) { -#ifdef WATCOM_DEBUG_SYMBOLS - /* - * Look for symbols in separate .sym files, not the .dip itself - */ - strcpy( filename + strlen( filename ) - 4, ".sym" ); - DebuggerLoadUserModule( filename, GetCS(), (unsigned long)modhdl ); -#endif *sys_hdl = modhdl; return( DS_OK ); } diff --git a/bld/dig/c/ldrpe.c b/bld/dig/c/ldrpe.c index a2bcd9f7bd..2c0d29e33c 100644 --- a/bld/dig/c/ldrpe.c +++ b/bld/dig/c/ldrpe.c @@ -141,11 +141,11 @@ static void *pe_get_proc_address( module modhdl, const char *proc_name ) static void loader_unload_image( module modhdl ) { - /* - * Notify the Watcom Debugger of module load and let it remove symbolic info - */ #ifdef WATCOM_DEBUG_SYMBOLS - if( modhdl->modname ) { + if( modhdl->modname != NULL ) { + /* + * Notify the Watcom Debugger of module unload and let it remove symbolic info + */ DebuggerUnloadUserModule( modhdl->modname ); free( modhdl->modname ); } @@ -166,7 +166,10 @@ static digld_error loader_load_image( FILE *fp, char *filename, module *mod_hdl, u_long reloc_raw_off, reloc_base = 0, reloc_size; u_long image_base = 0, image_size, image_end; u_char *image_ptr; - int i, delta, numFixups; + size_t i; + size_t len; + size_t numFixups; + int delta; u_short relocType, *fixup; module modhdl; void *reloc = NULL; @@ -286,17 +289,32 @@ static digld_error loader_load_image( FILE *fp, char *filename, module *mod_hdl, * the .rsrc section separately). */ image_size = image_end - image_base; +#if defined( __LINUX__ ) + /* + * the content in memory must be aligned to the _4K boundary, + * so one _4K page is added + */ modhdl = malloc( sizeof( *modhdl ) + image_size + _4K ); +#else + modhdl = malloc( sizeof( *modhdl ) + image_size ); +#endif reloc = malloc( reloc_size ); if( modhdl == NULL || reloc == NULL ) { err = DIGS_ERR_OUT_OF_MEMORY; goto Error; } +#if defined( __LINUX__ ) + /* + * align memory pointer to the _4K boundary + */ + image_ptr = (char *)__ROUND_UP_SIZE_4K( (u_long)modhdl + sizeof( *modhdl ) ); +#else + image_ptr = (char *)( (u_long)modhdl + sizeof( *modhdl ) ); +#endif /* * Setup all the pointers into our loaded executeable image */ - image_ptr = (u_char *)__ROUND_UP_SIZE_4K( (u_long)modhdl + sizeof( *modhdl ) ); modhdl->pbase = image_ptr; modhdl->ptext = image_ptr + ( text_base - image_base ); modhdl->pdata = image_ptr + ( data_base - image_base ); @@ -400,26 +418,45 @@ static digld_error loader_load_image( FILE *fp, char *filename, module *mod_hdl, * Clean up, close the file and return the loaded module handle */ free( reloc ); - /* - * Notify the Watcom Debugger of module load and let it load symbolic info - */ + *init_func = pe_get_proc_address( modhdl, MODINIT ); + *mod_hdl = modhdl; #ifdef WATCOM_DEBUG_SYMBOLS /* * Store the file name in the modhdl structure; this must be the real * file name where the debugger will try to load symbolic info from + * + * remove driver from begining of file name */ - modhdl->modname = malloc( strlen( filename ) + 1 ); - if( modhdl->modname != NULL ) { - if( filename[1] == ':' ) { - strcpy( modhdl->modname, filename + 2 ); - } else { - strcpy( modhdl->modname, filename ); + if( filename[0] != '\0' && filename[1] == ':' ) { + filename += 2; + } + len = strlen( filename ); + if( len > 0 ) { + modhdl->modname = malloc( len + 4 + 1 ); + if( modhdl->modname != NULL ) { + size_t pos; + + pos = len; + for( i = 0; i < len; i++ ) { + switch( *filename ) { + case '\\': + case '/': + pos = len; + break; + case '.': + pos = i; + break; + } + modhdl->modname[i] = *filename++; + } + strcpy( modhdl->modname + pos, ".sym" ); + /* + * Notify the Watcom Debugger of module load and let it load symbolic info + */ + DebuggerLoadUserModule( modhdl->modname, GetCS(), (unsigned long)image_ptr ); } - DebuggerLoadUserModule( modhdl->modname, GetCS(), (u_long)modhdl->pbase ); } #endif - *init_func = pe_get_proc_address( modhdl, MODINIT ); - *mod_hdl = modhdl; return( DIGS_OK ); Error: diff --git a/bld/dig/c/ldrrex.c b/bld/dig/c/ldrrex.c index 73da57bbfb..5f22683259 100644 --- a/bld/dig/c/ldrrex.c +++ b/bld/dig/c/ldrrex.c @@ -50,13 +50,26 @@ typedef struct { #ifdef __WATCOMC__ - unsigned_32 sig; + unsigned_32 sig; #endif - unsigned_8 init_rtn[1]; /* offset is start of routine */ + unsigned_8 init_rtn[1]; /* offset is start of routine */ +} image_hdr; + +typedef struct { + char *modname; } *module; static void loader_unload_image( module modhdl ) { +#ifdef WATCOM_DEBUG_SYMBOLS + if( modhdl->modname != NULL ) { + /* + * Notify the Watcom Debugger of module unload and let it remove symbolic info + */ + DebuggerUnloadUserModule( modhdl->modname ); + free( modhdl->modname ); + } +#endif DIGCli( Free )( modhdl ); } @@ -68,12 +81,16 @@ static digld_error loader_load_image( FILE *fp, const char *filename, module *mo unsigned bss_size; unsigned reloc_size; unsigned bunch; - unsigned i; + size_t i; + size_t len; unsigned_32 *fixup_loc; unsigned buff[RELOC_BUFF_SIZE]; module modhdl; + char *image_ptr; +#ifndef WATCOM_DEBUG_SYMBOLS (void)filename; +#endif (void)init_func; *mod_hdl = NULL; @@ -84,11 +101,28 @@ static digld_error loader_load_image( FILE *fp, const char *filename, module *mo hdr_size = hdr.hdr_size * 16; image_size = (hdr.file_size * 0x200) - (-hdr.mod_size & 0x1ff) - hdr_size; bss_size = hdr.min_data * _4K; - modhdl = DIGCli( Alloc )( image_size + bss_size ); +#if defined( __LINUX__ ) + /* + * the content in memory must be aligned to the _4K boundary, + * so one _4K page is added + */ + modhdl = DIGCli( Alloc )( sizeof( *modhdl ) + image_size + bss_size + _4K ); +#else + modhdl = DIGCli( Alloc )( sizeof( *modhdl ) + image_size + bss_size ); +#endif if( modhdl == NULL ) return( DIGS_ERR_OUT_OF_MEMORY ); +#if defined( __LINUX__ ) + /* + * align memory pointer to the _4K boundary + */ + image_ptr = (char *)__ROUND_UP_SIZE_4K( (unsigned_32)modhdl + sizeof( *modhdl ) ); +#else + image_ptr = (char *)( (unsigned_32)modhdl + sizeof( *modhdl ) ); +#endif + modhdl->modname = NULL; DIGLoader( Seek )( fp, hdr_size, DIG_SEEK_ORG ); - if( DIGLoader( Read )( fp, modhdl, image_size ) ) { + if( DIGLoader( Read )( fp, image_ptr, image_size ) ) { loader_unload_image( modhdl ); return( DIGS_ERR_CANT_LOAD_MODULE ); } @@ -105,25 +139,63 @@ static digld_error loader_load_image( FILE *fp, const char *filename, module *mo return( DIGS_ERR_CANT_LOAD_MODULE ); } for( i = 0; i < bunch; ++i ) { - fixup_loc = (void *)((char *)modhdl + (buff[i] & ~0x80000000)); - *fixup_loc += (unsigned_32)modhdl; + fixup_loc = (void *)(image_ptr + (buff[i] & ~0x80000000)); + *fixup_loc += (unsigned_32)image_ptr; } hdr.num_relocs -= bunch; } -#ifdef __LINUX__ +#if defined( __LINUX__ ) /* * On some platforms (such as AMD64 or x86 with NX bit), it is required * to map the code pages loaded from the BPD as executable, otherwise * a segfault will occur when attempting to run any BPD code. */ - mprotect((void*)__ROUND_DOWN_SIZE_4K( (u_long)modhdl ), __ROUND_UP_SIZE_4K( image_size ), PROT_READ | PROT_WRITE | PROT_EXEC); + mprotect( (void *)image_ptr, image_size, PROT_READ | PROT_WRITE | PROT_EXEC ); #endif - memset( (char *)modhdl + image_size, 0, bss_size ); + memset( image_ptr + image_size, 0, bss_size ); #ifdef __WATCOMC__ - *init_func = (modhdl->sig == MODSIG) ? modhdl->init_rtn : NULL; + *init_func = ((image_hdr *)image_ptr)->sig == MODSIG) ? ((image_hdr *)image_ptr)->init_rtn : NULL; #else - *init_func = modhdl->init_rtn; + *init_func = ((image_hdr *)image_ptr)->init_rtn; #endif *mod_hdl = modhdl; +#ifdef WATCOM_DEBUG_SYMBOLS + /* + * Store the file name in the modhdl structure; this must be the real + * file name where the debugger will try to load symbolic info from + * + * remove driver from begining of file name + */ + if( filename[0] != '\0' && filename[1] == ':' ) { + filename += 2; + } + len = strlen( filename ); + if( len > 0 ) { + modhdl->modname = malloc( len + 4 + 1 ); + if( modhdl->modname != NULL ) { + size_t pos; + + pos = len; + for( i = 0; i < len; i++ ) { + switch( *filename ) { + case '\\': + case '/': + case ':': + pos = len; + break; + case '.': + pos = i; + break; + } + modhdl->modname[i] = *filename++; + } + strcpy( modhdl->modname + pos, ".sym" ); + /* + * Notify the Watcom Debugger of module load and let it load symbolic info + */ + DebuggerLoadUserModule( modhdl->modname, GetCS(), (unsigned long)image_ptr ); + } + } +#endif return( DIGS_OK ); } diff --git a/bld/dig/c/linux/dipld.c b/bld/dig/c/linux/dipld.c index 6f88009a37..439fc32bf5 100644 --- a/bld/dig/c/linux/dipld.c +++ b/bld/dig/c/linux/dipld.c @@ -67,9 +67,6 @@ void DIPSysUnload( dip_sys_handle *sys_hdl ) { - /* - * We should unload the symbols here but it's not worth the trouble - */ if( *sys_hdl != NULL_SYSHDL ) { loader_unload_image( *sys_hdl ); *sys_hdl = NULL_SYSHDL; @@ -105,13 +102,6 @@ dip_status DIPSysLoad( const char *base_name, dip_client_routines *cli, dip_imp_ return( status ); } if( init_func != NULL && (*imp = init_func( &status, cli )) != NULL ) { -#ifdef WATCOM_DEBUG_SYMBOLS - /* - * Look for symbols in separate .sym files, not the .dip itself - */ - strcpy( filename + strlen( filename ) - 4, ".sym" ); - DebuggerLoadUserModule( filename, GetCS(), (unsigned long)modhdl ); -#endif *sys_hdl = modhdl; return( DS_OK ); } diff --git a/bld/dig/c/linux/madld.c b/bld/dig/c/linux/madld.c index 14a3686e66..9999201a52 100644 --- a/bld/dig/c/linux/madld.c +++ b/bld/dig/c/linux/madld.c @@ -49,6 +49,8 @@ #include "madsys.h" #include "roundmac.h" +#include "clibext.h" + #ifdef __WATCOMC__ @@ -79,7 +81,7 @@ mad_status MADSysLoad( const char *base_name, mad_client_routines *cli, module modhdl; mad_init_func *init_func; mad_status status; - char filename[256]; + char filename[_MAX_PATH]; digld_error err; *sys_hdl = NULL_SYSHDL; diff --git a/bld/dig/c/osx/dipld.c b/bld/dig/c/osx/dipld.c index f2c89b3b59..3eb5e33c7b 100644 --- a/bld/dig/c/osx/dipld.c +++ b/bld/dig/c/osx/dipld.c @@ -67,9 +67,6 @@ void DIPSysUnload( dip_sys_handle *sys_hdl ) { - /* - * We should unload the symbols here but it's not worth the trouble - */ if( *sys_hdl != NULL_SYSHDL ) { loader_unload_image( *sys_hdl ); *sys_hdl = NULL_SYSHDL; @@ -105,13 +102,6 @@ dip_status DIPSysLoad( const char *base_name, dip_client_routines *cli, dip_imp_ return( status ); } if( init_func != NULL && (*imp = init_func( &status, cli )) != NULL ) { -#ifdef WATCOM_DEBUG_SYMBOLS - /* - * Look for symbols in separate .sym files, not the .dip itself - */ - strcpy( filename + strlen( filename ) - 4, ".sym" ); - DebuggerLoadUserModule( filename, GetCS(), (unsigned long)modhdl ); -#endif *sys_hdl = modhdl; return( DS_OK ); } diff --git a/bld/dig/c/qnx/dipld.c b/bld/dig/c/qnx/dipld.c index c4f7df4468..1327c18b10 100644 --- a/bld/dig/c/qnx/dipld.c +++ b/bld/dig/c/qnx/dipld.c @@ -49,9 +49,6 @@ void DIPSysUnload( dip_sys_handle *sys_hdl ) { - /* - * We should unload the symbols here but it's not worth the trouble - */ if( *sys_hdl != NULL_SYSHDL ) { loader_unload_image( *sys_hdl ); *sys_hdl = NULL_SYSHDL; @@ -87,13 +84,6 @@ dip_status DIPSysLoad( const char *base_name, dip_client_routines *cli, dip_imp_ return( status ); } if( init_func != NULL && (*imp = init_func( &status, cli )) != NULL ) { -#ifdef WATCOM_DEBUG_SYMBOLS - /* - * Look for symbols in separate .sym files, not the .dip itself - */ - strcpy( filename + strlen( filename ) - 4, ".sym" ); - DebuggerLoadUserModule( filename, GetCS(), (unsigned long)modhdl ); -#endif *sys_hdl = modhdl; return( DS_OK ); } From 18c74a2ae0fd3b6eb6f79527fb994fd73a1a5da2 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Fri, 15 Sep 2023 22:29:29 +0200 Subject: [PATCH 140/258] do code more portable --- bld/wv/c/dbg_dbg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bld/wv/c/dbg_dbg.c b/bld/wv/c/dbg_dbg.c index b709ac252a..c4e5b75225 100644 --- a/bld/wv/c/dbg_dbg.c +++ b/bld/wv/c/dbg_dbg.c @@ -53,7 +53,7 @@ #define WV_SYM_DEF(size) struct { fixed_wv_sym_entry s; unsigned char len, name[size]; } #define WV_SYM( prfx, tk, tm, ts, sc, intrnl, vn, np ) \ - static const WV_SYM_DEF( sizeof( np #vn ) - 1 ) wv ## prfx ## _ ## vn = { \ + static const WV_SYM_DEF( sizeof( np #vn ) ) wv ## prfx ## _ ## vn = { \ { \ { ts, tk, tm }, sc, { intrnl } \ }, \ From 3cf4d5e103516062fdad0f0a31a5d46006e50735 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Sat, 16 Sep 2023 00:37:45 +0200 Subject: [PATCH 141/258] cleanup MAD/DIP/TRAP code --- bld/dig/c/dos/trpld.c | 2 +- bld/dig/c/dsx/dipld.c | 4 +-- bld/dig/c/dsx/madld.c | 4 +-- bld/dig/c/dsx/trpld.c | 2 +- bld/dig/c/ldrpe.c | 20 ++++++++----- bld/dig/c/ldrrex.c | 11 +++++-- bld/dig/c/linux/dipld.c | 4 +-- bld/dig/c/linux/madld.c | 4 +-- bld/dig/c/linux/trpld.c | 2 +- bld/dig/c/nt/dipld.c | 2 +- bld/dig/c/nt/madld.c | 2 +- bld/dig/c/nt/pillld.c | 2 +- bld/dig/c/nt/trpld.c | 2 +- bld/dig/c/nto/trpld.c | 2 +- bld/dig/c/os2/pillld.c | 2 +- bld/dig/c/osx/dipld.c | 4 +-- bld/dig/c/osx/madld.c | 6 ++-- bld/dig/c/osx/trpld.c | 2 +- bld/dig/c/qnx/dipld.c | 4 +-- bld/dig/c/qnx/madld.c | 6 ++-- bld/dig/c/qnx/pillld.c | 2 +- bld/dig/c/qnx/qnxload.h | 6 ++-- bld/dig/c/qnx/trpld.c | 4 +-- bld/dig/c/rdos/dipld.c | 3 +- bld/dig/c/rdos/madld.c | 2 +- bld/dig/c/rdos/pillld.c | 2 +- bld/dig/c/rdos/trpld.c | 2 +- bld/dig/c/win/dipld.c | 2 +- bld/dig/c/win/madld.c | 2 +- bld/dig/c/win/trpld.c | 2 +- bld/dig/h/digtypes.h | 4 ++- bld/dig/h/dipcli.h | 3 +- bld/dig/h/madcli.h | 3 +- bld/dig/h/trpld.h | 3 +- bld/dip/c/dipimp.c | 2 +- bld/mad/c/madimp.c | 2 +- bld/trap/common/qnx/qnxstrt.c | 2 +- bld/wv/c/remfile.c | 54 ++++++++++++++++++++++++----------- 38 files changed, 109 insertions(+), 78 deletions(-) diff --git a/bld/dig/c/dos/trpld.c b/bld/dig/c/dos/trpld.c index 4c2a54d3f4..062f5bff86 100644 --- a/bld/dig/c/dos/trpld.c +++ b/bld/dig/c/dos/trpld.c @@ -118,7 +118,7 @@ digld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) { FILE *fp; trap_init_func *init_func; - char filename[256]; + char filename[_MAX_PATH]; const char *base_name; digld_error err; size_t len; diff --git a/bld/dig/c/dsx/dipld.c b/bld/dig/c/dsx/dipld.c index e6b743c8ce..8fa53a1ea4 100644 --- a/bld/dig/c/dsx/dipld.c +++ b/bld/dig/c/dsx/dipld.c @@ -43,7 +43,7 @@ #define DEFEXT ".dip" //#define MODINIT "DIPLOAD" -#define MODSIG DIPSIGVAL +#define MODSIGN DIPSIGN #include "../ldrrex.c" /* PharLap REX format loader */ @@ -76,7 +76,7 @@ dip_status DIPSysLoad( const char *base_name, dip_client_routines *cli, dip_imp_ DIGLoader( Close )( fp ); if( err == DIGS_ERR_CANT_LOAD_MODULE ) return( DS_ERR | DS_FREAD_FAILED ); - if( err == DIGS_ERR_OUT_OF_DOS_MEMORY + if( err == DIGS_ERR_OUT_OF_MEMORY || err == DIGS_ERR_OUT_OF_DOS_MEMORY ) return( DS_ERR | DS_NO_MEM ); status = DS_ERR | DS_INVALID_DIP; diff --git a/bld/dig/c/dsx/madld.c b/bld/dig/c/dsx/madld.c index 714563cc4a..ca0d1453d9 100644 --- a/bld/dig/c/dsx/madld.c +++ b/bld/dig/c/dsx/madld.c @@ -44,7 +44,7 @@ #define DEFEXT ".mad" //#define MODINIT "MADLOAD" -#define MODSIG MADSIGVAL +#define MODSIGN MADSIGN #include "../ldrrex.c" /* PharLap REX format loader */ @@ -78,7 +78,7 @@ mad_status MADSysLoad( const char *base_name, mad_client_routines *cli, DIGLoader( Close )( fp ); if( err == DIGS_ERR_CANT_LOAD_MODULE ) return( MS_ERR | MS_FREAD_FAILED ); - if( err == DIGS_ERR_OUT_OF_DOS_MEMORY + if( err == DIGS_ERR_OUT_OF_MEMORY || err == DIGS_ERR_OUT_OF_DOS_MEMORY ) return( MS_ERR | MS_NO_MEM ); status = MS_ERR | MS_INVALID_MAD; diff --git a/bld/dig/c/dsx/trpld.c b/bld/dig/c/dsx/trpld.c index ddf5b57403..6a8ba40d30 100644 --- a/bld/dig/c/dsx/trpld.c +++ b/bld/dig/c/dsx/trpld.c @@ -485,7 +485,7 @@ digld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) { FILE *fp; trap_file_header __far *head; - char filename[256]; + char filename[_MAX_PATH]; const char *base_name; digld_error err; size_t len; diff --git a/bld/dig/c/ldrpe.c b/bld/dig/c/ldrpe.c index 2c0d29e33c..375afbc094 100644 --- a/bld/dig/c/ldrpe.c +++ b/bld/dig/c/ldrpe.c @@ -42,13 +42,17 @@ * Now used by Linux 32-bit code only for TRAP modules */ +#if defined(__WATCOMC__) && defined(__386__) && !defined(NDEBUG) +#define WATCOM_DEBUG_SYMBOLS +#endif + typedef struct { - u_char *pbase; /* Base of image in memory */ - u_char *ptext; /* Text section read from disk */ - u_char *pdata; /* Data section read from disk */ - u_char *pbss; /* BSS section read */ - u_char *pimport; /* Import section read from disk */ - u_char *pexport; /* Export section read from disk */ + char *pbase; /* Base of image in memory */ + char *ptext; /* Text section read from disk */ + char *pdata; /* Data section read from disk */ + char *pbss; /* BSS section read */ + char *pimport; /* Import section read from disk */ + char *pexport; /* Export section read from disk */ u_long textBase; /* Base of text section in image */ u_long dataBase; /* Base of data section in image */ u_long bssBase; /* Base of BSS data section in image */ @@ -165,9 +169,11 @@ static digld_error loader_load_image( FILE *fp, char *filename, module *mod_hdl, u_long export_raw_off, export_base, export_size, export_end; u_long reloc_raw_off, reloc_base = 0, reloc_size; u_long image_base = 0, image_size, image_end; - u_char *image_ptr; + char *image_ptr; size_t i; +#ifdef WATCOM_DEBUG_SYMBOLS size_t len; +#endif size_t numFixups; int delta; u_short relocType, *fixup; diff --git a/bld/dig/c/ldrrex.c b/bld/dig/c/ldrrex.c index 5f22683259..37e3a69b31 100644 --- a/bld/dig/c/ldrrex.c +++ b/bld/dig/c/ldrrex.c @@ -45,14 +45,17 @@ * OSX - yes yes */ +#if defined(__WATCOMC__) && defined(__386__) && !defined(NDEBUG) +#define WATCOM_DEBUG_SYMBOLS +#endif #define RELOC_BUFF_SIZE 64 typedef struct { #ifdef __WATCOMC__ - unsigned_32 sig; + char signature[4]; #endif - unsigned_8 init_rtn[1]; /* offset is start of routine */ + char init_rtn[1]; /* offset is start of routine */ } image_hdr; typedef struct { @@ -82,7 +85,9 @@ static digld_error loader_load_image( FILE *fp, const char *filename, module *mo unsigned reloc_size; unsigned bunch; size_t i; +#ifdef WATCOM_DEBUG_SYMBOLS size_t len; +#endif unsigned_32 *fixup_loc; unsigned buff[RELOC_BUFF_SIZE]; module modhdl; @@ -154,7 +159,7 @@ static digld_error loader_load_image( FILE *fp, const char *filename, module *mo #endif memset( image_ptr + image_size, 0, bss_size ); #ifdef __WATCOMC__ - *init_func = ((image_hdr *)image_ptr)->sig == MODSIG) ? ((image_hdr *)image_ptr)->init_rtn : NULL; + *init_func = SIGN_EQUAL( ((image_hdr *)image_ptr)->signature, MODSIGN ) ? ((image_hdr *)image_ptr)->init_rtn : NULL; #else *init_func = ((image_hdr *)image_ptr)->init_rtn; #endif diff --git a/bld/dig/c/linux/dipld.c b/bld/dig/c/linux/dipld.c index 439fc32bf5..5b4c508e14 100644 --- a/bld/dig/c/linux/dipld.c +++ b/bld/dig/c/linux/dipld.c @@ -54,7 +54,7 @@ #ifdef __WATCOMC__ #define DEFEXT ".dip" -#define MODSIG DIPSIGVAL +#define MODSIGN DIPSIGN #include "../ldrrex.c" /* PharLap REX format loader */ #else @@ -94,7 +94,7 @@ dip_status DIPSysLoad( const char *base_name, dip_client_routines *cli, dip_imp_ DIGLoader( Close )( fp ); if( err == DIGS_ERR_CANT_LOAD_MODULE ) return( DS_ERR | DS_FREAD_FAILED ); - if( err == DIGS_ERR_OUT_OF_DOS_MEMORY + if( err == DIGS_ERR_OUT_OF_MEMORY || err == DIGS_ERR_OUT_OF_DOS_MEMORY ) return( DS_ERR | DS_NO_MEM ); status = DS_ERR | DS_INVALID_DIP; diff --git a/bld/dig/c/linux/madld.c b/bld/dig/c/linux/madld.c index 9999201a52..0ed50de9f4 100644 --- a/bld/dig/c/linux/madld.c +++ b/bld/dig/c/linux/madld.c @@ -55,7 +55,7 @@ #ifdef __WATCOMC__ #define DEFEXT ".mad" -#define MODSIG MADSIGVAL +#define MODSIGN MADSIGN #include "../ldrrex.c" /* PharLap REX format loader */ #else @@ -96,7 +96,7 @@ mad_status MADSysLoad( const char *base_name, mad_client_routines *cli, DIGLoader( Close )( fp ); if( err == DIGS_ERR_CANT_LOAD_MODULE ) return( MS_ERR | MS_FREAD_FAILED ); - if( err == DIGS_ERR_OUT_OF_DOS_MEMORY + if( err == DIGS_ERR_OUT_OF_MEMORY || err == DIGS_ERR_OUT_OF_DOS_MEMORY ) return( MS_ERR | MS_NO_MEM ); status = MS_ERR | MS_INVALID_MAD; diff --git a/bld/dig/c/linux/trpld.c b/bld/dig/c/linux/trpld.c index 246cf3b7a7..44029b28bc 100644 --- a/bld/dig/c/linux/trpld.c +++ b/bld/dig/c/linux/trpld.c @@ -84,7 +84,7 @@ const static trap_callbacks TrapCallbacks = { #ifdef REX #define DEFEXT ".trp" -#define MODSIG TRAPSIGVAL +#define MODSIGN TRAPSIGN #include "../ldrrex.c" /* PharLap REX format loader */ #else diff --git a/bld/dig/c/nt/dipld.c b/bld/dig/c/nt/dipld.c index 344c28ed77..473244815c 100644 --- a/bld/dig/c/nt/dipld.c +++ b/bld/dig/c/nt/dipld.c @@ -51,7 +51,7 @@ dip_status DIPSysLoad( const char *base_name, dip_client_routines *cli, dip_imp_ { dip_sys_handle mod_hdl; dip_init_func *init_func; - char filename[256]; + char filename[_MAX_PATH]; dip_status status; *sys_hdl = NULL_SYSHDL; diff --git a/bld/dig/c/nt/madld.c b/bld/dig/c/nt/madld.c index 1392534ff7..24c113c330 100644 --- a/bld/dig/c/nt/madld.c +++ b/bld/dig/c/nt/madld.c @@ -53,7 +53,7 @@ mad_status MADSysLoad( const char *base_name, mad_client_routines *cli, mad_imp_ { mad_sys_handle mod_hdl; mad_init_func *init_func; - char filename[256]; + char filename[_MAX_PATH]; mad_status status; *sys_hdl = NULL_SYSHDL; diff --git a/bld/dig/c/nt/pillld.c b/bld/dig/c/nt/pillld.c index 7192b9edf2..2b16ad43d6 100644 --- a/bld/dig/c/nt/pillld.c +++ b/bld/dig/c/nt/pillld.c @@ -42,7 +42,7 @@ int PILLSysLoad( const char *base_name, const pill_client_routines *cli, link_handle *lh, link_message *msg ) { HANDLE mod_hdl; - char filename[256]; + char filename[_MAX_PATH]; pill_init_func *init_func; msg->source = NULL; diff --git a/bld/dig/c/nt/trpld.c b/bld/dig/c/nt/trpld.c index b8d0270025..47a09c871d 100644 --- a/bld/dig/c/nt/trpld.c +++ b/bld/dig/c/nt/trpld.c @@ -95,7 +95,7 @@ void UnLoadTrap( void ) digld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) { - char filename[256]; + char filename[_MAX_PATH]; const char *base_name; size_t len; trap_init_func *init_func; diff --git a/bld/dig/c/nto/trpld.c b/bld/dig/c/nto/trpld.c index 3449f5dc76..96ae499d86 100644 --- a/bld/dig/c/nto/trpld.c +++ b/bld/dig/c/nto/trpld.c @@ -84,7 +84,7 @@ const static trap_callbacks TrapCallbacks = { #ifdef REX #define DEFEXT ".trp" -#define MODSIG TRAPSIGVAL +#define MODSIGN TRAPSIGN #include "../ldrrex.c" /* PharLap REX format loader */ #else diff --git a/bld/dig/c/os2/pillld.c b/bld/dig/c/os2/pillld.c index 7935700719..57b2e11fb8 100644 --- a/bld/dig/c/os2/pillld.c +++ b/bld/dig/c/os2/pillld.c @@ -43,7 +43,7 @@ int PILLSysLoad( const char *base_name, const pill_client_routines *cli, link_handle *lh, link_message *msg ) { HMODULE mod_hdl; - char filename[256]; + char filename[_MAX_PATH]; pill_init_func *init_func; msg->source = NULL; diff --git a/bld/dig/c/osx/dipld.c b/bld/dig/c/osx/dipld.c index 3eb5e33c7b..fe53bb0475 100644 --- a/bld/dig/c/osx/dipld.c +++ b/bld/dig/c/osx/dipld.c @@ -54,7 +54,7 @@ #ifdef __WATCOMC__ #define DEFEXT ".dip" -#define MODSIG DIPSIGVAL +#define MODSIGN DIPSIGN #include "../ldrrex.c" /* PharLap REX format loader */ #else @@ -94,7 +94,7 @@ dip_status DIPSysLoad( const char *base_name, dip_client_routines *cli, dip_imp_ DIGLoader( Close )( fp ); if( err == DIGS_ERR_CANT_LOAD_MODULE ) return( DS_ERR | DS_FREAD_FAILED ); - if( err == DIGS_ERR_OUT_OF_DOS_MEMORY + if( err == DIGS_ERR_OUT_OF_MEMORY || err == DIGS_ERR_OUT_OF_DOS_MEMORY ) return( DS_ERR | DS_NO_MEM ); status = DS_ERR | DS_INVALID_DIP; diff --git a/bld/dig/c/osx/madld.c b/bld/dig/c/osx/madld.c index 23c37d3d69..a1dc7723fe 100644 --- a/bld/dig/c/osx/madld.c +++ b/bld/dig/c/osx/madld.c @@ -53,7 +53,7 @@ #ifdef __WATCOMC__ #define DEFEXT ".mad" -#define MODSIG MADSIGVAL +#define MODSIGN MADSIGN #include "../ldrrex.c" /* PharLap REX format loader */ #else @@ -79,7 +79,7 @@ mad_status MADSysLoad( const char *base_name, mad_client_routines *cli, module modhdl; mad_init_func *init_func; mad_status status; - char filename[256]; + char filename[_MAX_PATH]; digld_error err; *sys_hdl = NULL_SYSHDL; @@ -94,7 +94,7 @@ mad_status MADSysLoad( const char *base_name, mad_client_routines *cli, DIGLoader( Close )( fp ); if( err == DIGS_ERR_CANT_LOAD_MODULE ) return( MS_ERR | MS_FREAD_FAILED ); - if( err == DIGS_ERR_OUT_OF_DOS_MEMORY + if( err == DIGS_ERR_OUT_OF_MEMORY || err == DIGS_ERR_OUT_OF_DOS_MEMORY ) return( MS_ERR | MS_NO_MEM ); status = MS_ERR | MS_INVALID_MAD; diff --git a/bld/dig/c/osx/trpld.c b/bld/dig/c/osx/trpld.c index 5f6a0ff0c2..bffdf3c257 100644 --- a/bld/dig/c/osx/trpld.c +++ b/bld/dig/c/osx/trpld.c @@ -84,7 +84,7 @@ const static trap_callbacks TrapCallbacks = { #ifdef REX #define DEFEXT ".trp" -#define MODSIG TRAPSIGVAL +#define MODSIGN TRAPSIGN #include "../ldrrex.c" /* PharLap REX format loader */ #else diff --git a/bld/dig/c/qnx/dipld.c b/bld/dig/c/qnx/dipld.c index 1327c18b10..d6c4a7627a 100644 --- a/bld/dig/c/qnx/dipld.c +++ b/bld/dig/c/qnx/dipld.c @@ -43,7 +43,7 @@ #define DEFEXT ".dip" //#define MODINIT "DIPLOAD" -#define MODSIG DIPSIGVAL +#define MODSIGN DIPSIGN #include "../ldrrex.c" /* PharLap REX format loader */ @@ -76,7 +76,7 @@ dip_status DIPSysLoad( const char *base_name, dip_client_routines *cli, dip_imp_ DIGLoader( Close )( fp ); if( err == DIGS_ERR_CANT_LOAD_MODULE ) return( DS_ERR | DS_FREAD_FAILED ); - if( err == DIGS_ERR_OUT_OF_DOS_MEMORY + if( err == DIGS_ERR_OUT_OF_MEMORY || err == DIGS_ERR_OUT_OF_DOS_MEMORY ) return( DS_ERR | DS_NO_MEM ); status = DS_ERR | DS_INVALID_DIP; diff --git a/bld/dig/c/qnx/madld.c b/bld/dig/c/qnx/madld.c index a449bf4fee..4a5ec33338 100644 --- a/bld/dig/c/qnx/madld.c +++ b/bld/dig/c/qnx/madld.c @@ -53,7 +53,7 @@ #ifdef __WATCOMC__ #define DEFEXT ".mad" -#define MODSIG MADSIGVAL +#define MODSIGN MADSIGN #include "../ldrrex.c" /* PharLap REX format loader */ #else @@ -79,7 +79,7 @@ mad_status MADSysLoad( const char *base_name, mad_client_routines *cli, module modhdl; mad_init_func *init_func; mad_status status; - char filename[256]; + char filename[_MAX_PATH]; digld_error err; *sys_hdl = NULL_SYSHDL; @@ -94,7 +94,7 @@ mad_status MADSysLoad( const char *base_name, mad_client_routines *cli, DIGLoader( Close )( fp ); if( err == DIGS_ERR_CANT_LOAD_MODULE ) return( MS_ERR | MS_FREAD_FAILED ); - if( err == DIGS_ERR_OUT_OF_DOS_MEMORY + if( err == DIGS_ERR_OUT_OF_MEMORY || err == DIGS_ERR_OUT_OF_DOS_MEMORY ) return( MS_ERR | MS_NO_MEM ); status = MS_ERR | MS_INVALID_MAD; diff --git a/bld/dig/c/qnx/pillld.c b/bld/dig/c/qnx/pillld.c index 216d1f3ea6..58edb95059 100644 --- a/bld/dig/c/qnx/pillld.c +++ b/bld/dig/c/qnx/pillld.c @@ -65,7 +65,7 @@ int PILLSysLoad( const char *base_name, const pill_client_routines *cli, DIGLoader( Close )( fp ); lh->sys = SuppSegs; #ifdef __WATCOMC__ - if( pill == NULL || pill->sig != PILLSIG ) { + if( pill == NULL || memcmp( pill->signature, PILLSIGN, 4 ) != 0 ) { #else if( pill == NULL ) { #endif diff --git a/bld/dig/c/qnx/qnxload.h b/bld/dig/c/qnx/qnxload.h index 1372f45e3d..2e83b7a5fd 100644 --- a/bld/dig/c/qnx/qnxload.h +++ b/bld/dig/c/qnx/qnxload.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -41,8 +41,8 @@ #include "sys/seginfo.h" typedef struct { - unsigned long sig; - unsigned_8 init_rtn[1]; /* offset is start of routine */ + char signature[4]; + char init_rtn[1]; /* offset is start of routine */ } supp_header; static unsigned short *SuppSegs; diff --git a/bld/dig/c/qnx/trpld.c b/bld/dig/c/qnx/trpld.c index 4aae0d7659..2f439d0120 100644 --- a/bld/dig/c/qnx/trpld.c +++ b/bld/dig/c/qnx/trpld.c @@ -44,7 +44,7 @@ #define DEFEXT ".trp" //#define MODINIT "TrapLoad" -#define MODSIG TRAPSIGVAL +#define MODSIGN TRAPSIGN #include "../ldrrex.c" /* PharLap REX format loader */ @@ -84,7 +84,7 @@ digld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) FILE *fp; trap_load_func *ld_func; const trap_requests *trap_funcs; - char filename[256]; + char filename[_MAX_PATH]; const char *base_name; size_t len; digld_error err; diff --git a/bld/dig/c/rdos/dipld.c b/bld/dig/c/rdos/dipld.c index eea31a8ed7..50621838fb 100644 --- a/bld/dig/c/rdos/dipld.c +++ b/bld/dig/c/rdos/dipld.c @@ -31,6 +31,7 @@ #include +#include #include #include #include "digld.h" @@ -51,7 +52,7 @@ dip_status DIPSysLoad( const char *base_name, dip_client_routines *cli, dip_imp_ { dip_sys_handle mod_hdl; dip_init_func *init_func; - char filename[256]; + char filename[_MAX_PATH]; dip_status status; *sys_hdl = NULL_SYSHDL; diff --git a/bld/dig/c/rdos/madld.c b/bld/dig/c/rdos/madld.c index 53314dc57f..82c4fa0d5e 100644 --- a/bld/dig/c/rdos/madld.c +++ b/bld/dig/c/rdos/madld.c @@ -53,7 +53,7 @@ mad_status MADSysLoad( const char *base_name, mad_client_routines *cli, mad_imp_ { mad_sys_handle mod_hdl; mad_init_func *init_func; - char filename[256]; + char filename[_MAX_PATH]; mad_status status; *sys_hdl = NULL_SYSHDL; diff --git a/bld/dig/c/rdos/pillld.c b/bld/dig/c/rdos/pillld.c index b4ea7f325d..4c8473edcd 100644 --- a/bld/dig/c/rdos/pillld.c +++ b/bld/dig/c/rdos/pillld.c @@ -41,7 +41,7 @@ int PILLSysLoad( const char *path, const pill_client_routines *cli, link_handle *lh, link_message *msg ) { int mod_hdl; - char filename[256]; + char filename[_MAX_PATH]; pill_init_func *init_func; msg->source = NULL; diff --git a/bld/dig/c/rdos/trpld.c b/bld/dig/c/rdos/trpld.c index f32ef24b0f..0f3b9901a5 100644 --- a/bld/dig/c/rdos/trpld.c +++ b/bld/dig/c/rdos/trpld.c @@ -55,7 +55,7 @@ void UnLoadTrap( void ) digld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) { - char filename[256]; + char filename[_MAX_PATH]; const char *base_name; size_t len; trap_init_func *init_func; diff --git a/bld/dig/c/win/dipld.c b/bld/dig/c/win/dipld.c index 9f02a2ee74..92399676cc 100644 --- a/bld/dig/c/win/dipld.c +++ b/bld/dig/c/win/dipld.c @@ -65,7 +65,7 @@ void DIPSysUnload( dip_sys_handle *sys_hdl ) dip_status DIPSysLoad( const char *base_name, dip_client_routines *cli, dip_imp_routines **imp, dip_sys_handle *sys_hdl ) { HINSTANCE mod_hdl; - char filename[256]; + char filename[_MAX_PATH]; dip_status status; char parm[10]; struct { diff --git a/bld/dig/c/win/madld.c b/bld/dig/c/win/madld.c index 0df1defce9..cdc4f77890 100644 --- a/bld/dig/c/win/madld.c +++ b/bld/dig/c/win/madld.c @@ -67,7 +67,7 @@ mad_status MADSysLoad( const char *base_name, mad_client_routines *cli, mad_imp_routines **imp, mad_sys_handle *sys_hdl ) { HINSTANCE mod_hdl; - char filename[256]; + char filename[_MAX_PATH]; mad_status status; char parm[10]; struct { diff --git a/bld/dig/c/win/trpld.c b/bld/dig/c/win/trpld.c index 3b1a0c21cb..aee744a549 100644 --- a/bld/dig/c/win/trpld.c +++ b/bld/dig/c/win/trpld.c @@ -78,7 +78,7 @@ void UnLoadTrap( void ) digld_error LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) { - char filename[256]; + char filename[_MAX_PATH]; const char *base_name; size_t len; UINT prev; diff --git a/bld/dig/h/digtypes.h b/bld/dig/h/digtypes.h index b7e1daa7ae..39dc70e099 100644 --- a/bld/dig/h/digtypes.h +++ b/bld/dig/h/digtypes.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -64,6 +64,8 @@ #define DIG_SEEK_ERROR ((unsigned long)-1L) #define DIG_RW_ERROR ((size_t)-1) +#define SIGN_EQUAL(s1,s2) (memcmp( s1, s2, 4 ) == 0) + typedef enum { SR_NONE, SR_EXACT, diff --git a/bld/dig/h/dipcli.h b/bld/dig/h/dipcli.h index 6693eb92e0..ac6aa4c67e 100644 --- a/bld/dig/h/dipcli.h +++ b/bld/dig/h/dipcli.h @@ -36,8 +36,7 @@ #include "digcli.h" #include "diptypes.h" -#define DIPSIG "DIP" -#define DIPSIGVAL 0x00504944UL // "DIP" +#define DIPSIGN "DIP" #define DIPCli(n) DIPCli ## n #define _DIPCli(n) _DIPCli ## n n diff --git a/bld/dig/h/madcli.h b/bld/dig/h/madcli.h index 994d0af2e1..52a095f7cc 100644 --- a/bld/dig/h/madcli.h +++ b/bld/dig/h/madcli.h @@ -37,8 +37,7 @@ #include "digsyscf.h" #include "madtypes.h" -#define MADSIG "MAD" -#define MADSIGVAL 0x0044414DUL // "MAD" +#define MADSIGN "MAD" #define MADCli(n) MADCli ## n #define _MADCli(n) _MADCli ## n n diff --git a/bld/dig/h/trpld.h b/bld/dig/h/trpld.h index 3a6385e1b0..6c97778899 100644 --- a/bld/dig/h/trpld.h +++ b/bld/dig/h/trpld.h @@ -38,8 +38,7 @@ #define DEFAULT_TRP_NAME "std" -#define TRAPSIG "TRAP" -#define TRAPSIGVAL 0x50415254UL // "TRAP" +#define TRAPSIGN "TRAP" extern trap_version TrapVer; extern trap_req_func *ReqFunc; diff --git a/bld/dip/c/dipimp.c b/bld/dip/c/dipimp.c index e7a6042762..89a32eece9 100644 --- a/bld/dip/c/dipimp.c +++ b/bld/dip/c/dipimp.c @@ -136,7 +136,7 @@ static HANDLE TaskId; #endif #if defined( __WATCOMC__ ) && ( defined( __DOS__ ) || defined( __UNIX__ ) ) -const char __based( __segname( "_CODE" ) ) Signature[4] = DIPSIG; +const char __based( __segname( "_CODE" ) ) Signature[4] = { DIPSIGN }; #endif DIG_DLLEXPORT dip_imp_routines * DIGENTRY DIPLOAD( dip_status *ds, dip_client_routines *client ) diff --git a/bld/mad/c/madimp.c b/bld/mad/c/madimp.c index 9aa36eb42a..decaa0cc69 100644 --- a/bld/mad/c/madimp.c +++ b/bld/mad/c/madimp.c @@ -142,7 +142,7 @@ static HINSTANCE ThisInst; #endif #if defined( __WATCOMC__ ) && ( defined( __DOS__ ) || defined( __UNIX__ ) ) -const char __based( __segname( "_CODE" ) ) Signature[4] = MADSIG; +const char __based( __segname( "_CODE" ) ) Signature[4] = { MADSIGN }; #endif DIG_DLLEXPORT mad_imp_routines * DIGENTRY MADLOAD( mad_status *status, mad_client_routines *client ) diff --git a/bld/trap/common/qnx/qnxstrt.c b/bld/trap/common/qnx/qnxstrt.c index 8711bcde67..8838a4c6a3 100644 --- a/bld/trap/common/qnx/qnxstrt.c +++ b/bld/trap/common/qnx/qnxstrt.c @@ -44,7 +44,7 @@ static const trap_callbacks *Client; static const trap_requests ImpInterface = { TrapInit, TrapRequest, TrapFini } ; #ifdef __WATCOMC__ -const char __based( __segname( "_CODE" ) ) Signature[4] = { TRAPSIG }; +const char __based( __segname( "_CODE" ) ) Signature[4] = { TRAPSIGN }; #endif const trap_requests *TrapLoad( const trap_callbacks *client ) diff --git a/bld/wv/c/remfile.c b/bld/wv/c/remfile.c index 3f55afe35e..3b01933faa 100644 --- a/bld/wv/c/remfile.c +++ b/bld/wv/c/remfile.c @@ -62,7 +62,9 @@ typedef int loc_handle; -/* Remote file "cache" - correlates remote and local file handles */ +/* + * Remote file "cache" - correlates remote and local file handles + */ typedef struct _fcache_t { loc_handle lochandle; sys_handle remhandle; @@ -80,8 +82,10 @@ static fcache_t fcache[CACHED_HANDLES]; static const int local_seek_method[] = { SEEK_SET, SEEK_CUR, SEEK_END }; static const unsigned_8 remote_seek_method[] = { DIG_SEEK_ORG, DIG_SEEK_CUR, DIG_SEEK_END }; -/* Return local handle of remote file equivalent */ static loc_handle GetCachedHandle( sys_handle remote ) +/***************************************************** + * Return local handle of remote file equivalent + */ { int i; @@ -93,8 +97,10 @@ static loc_handle GetCachedHandle( sys_handle remote ) return( LOC_NIL_HANDLE ); } -/* Initialize local/remote handle cache */ static void InitHandleCache( void ) +/********************************** + * Initialize local/remote handle cache + */ { int i; @@ -109,8 +115,10 @@ static void InitHandleCache( void ) } } -/* Add entry for local/remote "cached" file */ static int AddCachedHandle( loc_handle local, sys_handle remote ) +/**************************************************************** + * Add entry for local/remote "cached" file + */ { int i; @@ -124,8 +132,10 @@ static int AddCachedHandle( loc_handle local, sys_handle remote ) return( -1 ); } -/* Remove cached file entry from the list */ static int DelCachedHandle( loc_handle local ) +/********************************************* + * Remove cached file entry from the list + */ { int i; @@ -158,9 +168,11 @@ bool HaveRemoteFiles( void ) return( SuppFileId != 0 ); } -//NYI: The 'bool executable' should be changed to allow different file types size_t RemoteFileToFullName( dig_filetype file_type, const char *name, char *res, trap_elen res_len ) +/******************************************************************************** + * NYI: The 'bool executable' should be changed to allow different file types + */ { in_mx_entry in[2]; mx_entry out[2]; @@ -184,14 +196,18 @@ size_t RemoteFileToFullName( dig_filetype file_type, const char *name, char *res in[0].len = sizeof( acc ); in[1].ptr = (void *)name; #ifdef __NT__ - // check whether short filename is necessary + /* + * check whether short filename is necessary + */ switch( SysConfig.os ) { case DIG_OS_AUTOCAD: case DIG_OS_DOS: case DIG_OS_RATIONAL: case DIG_OS_PHARLAP: case DIG_OS_WINDOWS: - // convert long file name to short "DOS" compatible form + /* + * convert long file name to short "DOS" compatible form + */ { GetShortPathNameA( name, short_filename, MAX_PATH ); if( *short_filename != NULLCHAR ) { @@ -255,12 +271,12 @@ sys_handle RemoteOpen( const char *name, obj_attrs oattrs ) return( sh ); } CONV_LE_64( ret.handle ); - - /* See if the file is available locally. If so, open it here as + /* + * See if the file is available locally. If so, open it here as * well as on the remote machine. + * + * TODO: check if remote file is the same! */ - // TODO: check if remote file is the same! - #ifdef LOGGING fprintf( logf, "Trying to open local copy of remote file (remote handle %d)\n", ret.handle ); fprintf( logf, "%s\n", name ); @@ -427,8 +443,9 @@ size_t RemoteRead( sys_handle sh, void *buff, size_t len ) if( SuppFileId == 0 ) return( 0 ); - - /* Try reading from local copy first */ + /* + * Try reading from local copy first + */ lochandle = GetCachedHandle( sh ); if( lochandle != LOC_NIL_HANDLE ) return( read( lochandle, buff, len ) ); @@ -444,8 +461,9 @@ unsigned long RemoteSeek( sys_handle sh, unsigned long pos, seek_method method ) if( SuppFileId == 0 ) return( 0 ); - - /* Seek on local copy too (if available) */ + /* + * Seek on local copy too (if available) + */ lochandle = GetCachedHandle( sh ); if( lochandle != LOC_NIL_HANDLE ) { lseek( lochandle, pos, local_seek_method[method] ); @@ -453,7 +471,9 @@ unsigned long RemoteSeek( sys_handle sh, unsigned long pos, seek_method method ) SUPP_FILE_SERVICE( acc, REQ_FILE_SEEK ); acc.handle = sh; - /* Magic again! The seek mode mapped exactly to our definition! */ + /* + * Magic again! The seek mode mapped exactly to our definition! + */ acc.mode = remote_seek_method[method]; acc.pos = pos; CONV_LE_64( acc.handle ); From 906f32ac8ffc61db7dfd65f96584035163ece979 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Sun, 17 Sep 2023 13:28:58 +0200 Subject: [PATCH 142/258] fix owcc bug in -l option add missing 'lib' prefix as specified by POSIX --- bld/wcl/c/owcc.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/bld/wcl/c/owcc.c b/bld/wcl/c/owcc.c index 432169f5d7..8777aa2e7f 100644 --- a/bld/wcl/c/owcc.c +++ b/bld/wcl/c/owcc.c @@ -950,14 +950,17 @@ static int ParseArgs( int argc, char **argv ) } break; case 'l': - new_item = MemAlloc( sizeof( list ) ); - new_item->next = NULL; - p = MemAlloc( strlen( Word ) + 2 + 1 ); - strcpy( p, Word ); - strcat( p, "." LIB_EXT_SECONDARY ); - new_item->item = strfdup( p ); - MemFree( p ); - ListAppend( &Libs_List, new_item ); + if( Word[0] != '\0' ) { + new_item = MemAlloc( sizeof( list ) ); + new_item->next = NULL; + p = MemAlloc( 3 + strlen( Word ) + 2 + 1 ); + strcpy( p, "lib" ); + strcpy( p + 3, Word ); + strcat( p, "." LIB_EXT_SECONDARY ); + new_item->item = strfdup( p ); + MemFree( p ); + ListAppend( &Libs_List, new_item ); + } wcc_option = false; break; case 'L': From 8729219b5ff727a4f6e8c5f650ab59d8ac97f889 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Sun, 17 Sep 2023 13:57:32 +0200 Subject: [PATCH 143/258] update owcc documentation for L and l options --- docs/doc/cmn/owcc.gml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/doc/cmn/owcc.gml b/docs/doc/cmn/owcc.gml index 7a0f68d541..00f63618b1 100644 --- a/docs/doc/cmn/owcc.gml +++ b/docs/doc/cmn/owcc.gml @@ -212,6 +212,12 @@ system definitions and these may be specified as an argument to the "l=" option. The "system_name" specified in the "l=" option is used to create a "SYSTEM system_name" &lnkname directive when linking the application. +.note L +.ix 'owcc options' 'L ' +add to directories search list for library search +.note l +.ix 'owcc options' 'l ' +search the library named lib.a .note mstack-size= .ix 'owcc options' 'mstack-size=' set stack size From ecfeaf595def96f665c08551a8f0ce7406dd01c4 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Sun, 17 Sep 2023 21:12:13 +0200 Subject: [PATCH 144/258] fix boolbit type if stdbool.h if already included --- bld/watcom/h/bool.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bld/watcom/h/bool.h b/bld/watcom/h/bool.h index e4d9c0cbc2..f704d2ca15 100644 --- a/bld/watcom/h/bool.h +++ b/bld/watcom/h/bool.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2019 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -41,6 +41,8 @@ #define false 0 #define __bool_true_false_are_defined 1 #endif + #endif + #if !defined( boolbit ) #ifdef _MSC_VER #define boolbit unsigned char #else From e784fbef4e337cee3576cf2210da18ecb59b1b91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Mal=C3=A1k?= Date: Mon, 18 Sep 2023 09:39:25 +0200 Subject: [PATCH 145/258] disabling WIP because the author doesn't want to do serious work author want just cosmetically introducing new macros, etc. he wants to use the compiler as his toy, most of his work was necessary to fix It stay here for anybody who want realy progress with compiler --- bld/plusplus/builder.ctl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bld/plusplus/builder.ctl b/bld/plusplus/builder.ctl index 698f86cee4..8cb6ba2a26 100644 --- a/bld/plusplus/builder.ctl +++ b/bld/plusplus/builder.ctl @@ -10,7 +10,7 @@ cdsay . [ INCLUDE i86/builder.ctl ] [ INCLUDE 386/builder.ctl ] [ INCLUDE axp/builder.ctl ] -[ INCLUDE mps/builder.ctl ] -[ INCLUDE ppc/builder.ctl ] +#[ INCLUDE mps/builder.ctl ] +#[ INCLUDE ppc/builder.ctl ] cdsay . From 25798918131cd346722d89853cd6f5ebfd8c9c29 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Mon, 18 Sep 2023 18:41:43 +0200 Subject: [PATCH 146/258] remove duplicit code in C run-time librarary --- bld/clib/alias/gen/aliases.dat | 5 +++- bld/clib/memory/c/bcmp.c | 47 ---------------------------------- bld/clib/memory/c/bcopy.c | 43 ------------------------------- bld/clib/memory/c/bzero.c | 43 ------------------------------- bld/clib/memory/objects.mif | 3 --- 5 files changed, 4 insertions(+), 137 deletions(-) delete mode 100644 bld/clib/memory/c/bcmp.c delete mode 100644 bld/clib/memory/c/bcopy.c delete mode 100644 bld/clib/memory/c/bzero.c diff --git a/bld/clib/alias/gen/aliases.dat b/bld/clib/alias/gen/aliases.dat index f6a43b132c..7b8e32e6b1 100644 --- a/bld/clib/alias/gen/aliases.dat +++ b/bld/clib/alias/gen/aliases.dat @@ -99,8 +99,11 @@ mbsnbi _mbsnbicmp _mbsnbicoll d16 d32 nt nta ntm ntp mbsnco _mbsncmp _mbsncoll d16 d32 nt nta ntm ntp o16 o32 w16 w32 rdu rdk mbsnic _mbsnicmp _mbsnicoll d16 d32 nt nta ntm ntp o16 o32 w16 w32 rdu rdk memccp memccpy _memccpy d16 d32 nt nta ntm ntp nvc ncl nvl nll o16 o32 q16 q32 w16 w32 l32 rdu rdk -memicm _memicmp memicmp d16 d32 nt nta ntm ntp nvc nvl o16 o32 w16 w32 l32 rdu rdk +memcmp memcmp bcmp d16 d32 nt nta ntm ntp nvc nvl o16 o32 q16 q32 w16 w32 l32 lpc lmp rdu memic0 memicmp _memicmp ncl nll +memicm _memicmp memicmp d16 d32 nt nta ntm ntp nvc nvl o16 o32 w16 w32 l32 rdu rdk +memove memmove bcopy d16 d32 nt nta ntm ntp nvc nvl o16 o32 q16 q32 w16 w32 l32 lpc lmp rdu +memset memset bzero d16 d32 nt nta ntm ntp nvc nvl o16 o32 q16 q32 w16 w32 l32 lpc lmp rdu mkdir_ mkdir _mkdir d16 d32 nt nta ntm ntp nvc ncl nvl nll o16 o32 q16 q32 w16 w32 l32 lpc lmp rdu rdk onexit _onexit onexit d16 d32 nt nta ntm ntp nvc nvl o16 o32 q16 q32 w16 w32 l32 lpc lmp rdu rdk onexi0 onexit _onexit ncl nll diff --git a/bld/clib/memory/c/bcmp.c b/bld/clib/memory/c/bcmp.c deleted file mode 100644 index b0aaa95874..0000000000 --- a/bld/clib/memory/c/bcmp.c +++ /dev/null @@ -1,47 +0,0 @@ -/**************************************************************************** -* -* Open Watcom Project -* -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. -* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. -* -* ======================================================================== -* -* This file contains Original Code and/or Modifications of Original -* Code as defined in and that are subject to the Sybase Open Watcom -* Public License version 1.0 (the 'License'). You may not use this file -* except in compliance with the License. BY USING THIS FILE YOU AGREE TO -* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is -* provided with the Original Code and Modifications, and is also -* available at www.sybase.com/developer/opensource. -* -* The Original Code and all software distributed under the License are -* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER -* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM -* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF -* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR -* NON-INFRINGEMENT. Please see the License for the specific language -* governing rights and limitations under the License. -* -* ======================================================================== -* -* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE -* DESCRIBE IT HERE! -* -****************************************************************************/ - - -#include "variety.h" -#include -#include - - -_WCRTLINK int bcmp( const void *s1, const void *s2, size_t n ) -/************************************************************/ -{ - if( memcmp( s1, s2, n ) == 0 ) { - return( 0 ); - } else { - return( 1 ); - } -} diff --git a/bld/clib/memory/c/bcopy.c b/bld/clib/memory/c/bcopy.c deleted file mode 100644 index 302e5cc2e1..0000000000 --- a/bld/clib/memory/c/bcopy.c +++ /dev/null @@ -1,43 +0,0 @@ -/**************************************************************************** -* -* Open Watcom Project -* -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. -* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. -* -* ======================================================================== -* -* This file contains Original Code and/or Modifications of Original -* Code as defined in and that are subject to the Sybase Open Watcom -* Public License version 1.0 (the 'License'). You may not use this file -* except in compliance with the License. BY USING THIS FILE YOU AGREE TO -* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is -* provided with the Original Code and Modifications, and is also -* available at www.sybase.com/developer/opensource. -* -* The Original Code and all software distributed under the License are -* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER -* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM -* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF -* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR -* NON-INFRINGEMENT. Please see the License for the specific language -* governing rights and limitations under the License. -* -* ======================================================================== -* -* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE -* DESCRIBE IT HERE! -* -****************************************************************************/ - - -#include "variety.h" -#include -#include - - -_WCRTLINK void bcopy( const void *s1, void *s2, size_t n ) -/********************************************************/ -{ - memmove( s2, s1, n ); -} diff --git a/bld/clib/memory/c/bzero.c b/bld/clib/memory/c/bzero.c deleted file mode 100644 index 8e8c8d4d30..0000000000 --- a/bld/clib/memory/c/bzero.c +++ /dev/null @@ -1,43 +0,0 @@ -/**************************************************************************** -* -* Open Watcom Project -* -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. -* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. -* -* ======================================================================== -* -* This file contains Original Code and/or Modifications of Original -* Code as defined in and that are subject to the Sybase Open Watcom -* Public License version 1.0 (the 'License'). You may not use this file -* except in compliance with the License. BY USING THIS FILE YOU AGREE TO -* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is -* provided with the Original Code and Modifications, and is also -* available at www.sybase.com/developer/opensource. -* -* The Original Code and all software distributed under the License are -* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER -* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM -* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF -* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR -* NON-INFRINGEMENT. Please see the License for the specific language -* governing rights and limitations under the License. -* -* ======================================================================== -* -* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE -* DESCRIBE IT HERE! -* -****************************************************************************/ - - -#include "variety.h" -#include -#include - - -_WCRTLINK void bzero( void *s, size_t n ) -/***************************************/ -{ - memset( s, 0, n ); -} diff --git a/bld/clib/memory/objects.mif b/bld/clib/memory/objects.mif index efbd5318c7..19c4b4a417 100644 --- a/bld/clib/memory/objects.mif +++ b/bld/clib/memory/objects.mif @@ -1,8 +1,5 @@ # d16 d32 dpm nt nta ntp ntm nvc ncl nvl nll o16 o32 q16 q32 w16 w32 l32 lpc lmp rdu rdk #=============================================================================================================== -!inject bcmp.obj d16 d32 nt nta ntp ntm nvc nvl o16 o32 q16 q32 w16 w32 l32 lpc lmp rdu -!inject bcopy.obj d16 d32 nt nta ntp ntm nvc nvl o16 o32 q16 q32 w16 w32 l32 lpc lmp rdu -!inject bzero.obj d16 d32 nt nta ntp ntm nvc nvl o16 o32 q16 q32 w16 w32 l32 lpc lmp rdu !inject fmemccpy.obj d16 d32 nt o16 o32 q16 q32 w16 w32 l32 rdu !inject fmemchr.obj d16 d32 nt o16 o32 q16 q32 w16 w32 l32 rdu !inject fmemcmp.obj d16 d32 nt o16 o32 q16 q32 w16 w32 l32 rdu From f61c0e4d50245f803e63411aa31ad9e93c63089c Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Mon, 18 Sep 2023 19:19:53 +0200 Subject: [PATCH 147/258] add old index and rindex functions to strings.h --- bld/clib/alias/gen/aliases.dat | 8 +++++--- bld/hdr/watcom/strings.mh | 2 ++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/bld/clib/alias/gen/aliases.dat b/bld/clib/alias/gen/aliases.dat index 7b8e32e6b1..a8b78f68d0 100644 --- a/bld/clib/alias/gen/aliases.dat +++ b/bld/clib/alias/gen/aliases.dat @@ -32,6 +32,9 @@ access access _access d16 d32 nt nta ntm ntp o16 o32 w16 w32 rdu rdk asct_r _asctime asctime_r l32 lpc lmp atoi64 atoll _atoi64 d16 d32 nt nta ntm ntp nvc nvl o16 o32 q16 q32 w16 w32 l32 lpc lmp rdu rdk +bcmp__ memcmp bcmp d16 d32 nt nta ntm ntp nvc nvl o16 o32 q16 q32 w16 w32 l32 lpc lmp rdu rdk +bcopy_ memmove bcopy d16 d32 nt nta ntm ntp nvc nvl o16 o32 q16 q32 w16 w32 l32 lpc lmp rdu rdk +bzero_ memset bzero d16 d32 nt nta ntm ntp nvc nvl o16 o32 q16 q32 w16 w32 l32 lpc lmp rdu rdk chdir_ chdir _chdir d16 d32 nt nta ntm ntp nvc ncl nvl nll o16 o32 q16 q32 w16 w32 l32 lpc lmp rdu rdk chmod_ chmod _chmod d16 d32 nt nta ntm ntp o16 o32 w16 w32 rdu rdk chsize _chsize chsize d16 d32 nt nta ntm ntp nvc nvl o16 o32 q16 q32 w16 w32 l32 lpc lmp rdu rdk @@ -77,6 +80,7 @@ getpwe setpwent endpwent getws_ getws _getws d16 d32 nt nta ntm ntp o16 o32 q16 q32 w16 w32 l32 gmtm_r _gmtime gmtime_r l32 lpc lmp i64toa lltoa _i64toa d16 d32 nt nta ntm ntp nvc nvl o16 o32 q16 q32 w16 w32 l32 lpc lmp rdu rdk +index_ strchr index d16 d32 nt nta ntm ntp nvc nvl o16 o32 q16 q32 w16 w32 l32 lpc lmp rdu rdk isatty isatty _isatty d16 d32 nt nta ntm ntp o16 o32 w16 w32 rdu rdk iscsyf __iscsymf iscsymf d16 d32 nt nta ntm ntp nvc nvl o16 o32 q16 q32 w16 w32 l32 rdu rdk iscsym __iscsym iscsym d16 d32 nt nta ntm ntp nvc nvl o16 o32 q16 q32 w16 w32 l32 rdu rdk @@ -99,11 +103,8 @@ mbsnbi _mbsnbicmp _mbsnbicoll d16 d32 nt nta ntm ntp mbsnco _mbsncmp _mbsncoll d16 d32 nt nta ntm ntp o16 o32 w16 w32 rdu rdk mbsnic _mbsnicmp _mbsnicoll d16 d32 nt nta ntm ntp o16 o32 w16 w32 rdu rdk memccp memccpy _memccpy d16 d32 nt nta ntm ntp nvc ncl nvl nll o16 o32 q16 q32 w16 w32 l32 rdu rdk -memcmp memcmp bcmp d16 d32 nt nta ntm ntp nvc nvl o16 o32 q16 q32 w16 w32 l32 lpc lmp rdu memic0 memicmp _memicmp ncl nll memicm _memicmp memicmp d16 d32 nt nta ntm ntp nvc nvl o16 o32 w16 w32 l32 rdu rdk -memove memmove bcopy d16 d32 nt nta ntm ntp nvc nvl o16 o32 q16 q32 w16 w32 l32 lpc lmp rdu -memset memset bzero d16 d32 nt nta ntm ntp nvc nvl o16 o32 q16 q32 w16 w32 l32 lpc lmp rdu mkdir_ mkdir _mkdir d16 d32 nt nta ntm ntp nvc ncl nvl nll o16 o32 q16 q32 w16 w32 l32 lpc lmp rdu rdk onexit _onexit onexit d16 d32 nt nta ntm ntp nvc nvl o16 o32 q16 q32 w16 w32 l32 lpc lmp rdu rdk onexi0 onexit _onexit ncl nll @@ -113,6 +114,7 @@ popen_ popen _popen putenv putenv _putenv d16 d32 nt nta ntm ntp nvc ncl nvl nll o16 o32 q16 q32 w16 w32 l32 lpc lmp rdu rdk putws_ putws _putws d16 d32 nt nta ntm ntp o16 o32 q16 q32 w16 w32 l32 read__ read _read d16 d32 nt nta ntm ntp o16 o32 w16 w32 rdu rdk +rindex strrchr rindex d16 d32 nt nta ntm ntp nvc nvl o16 o32 q16 q32 w16 w32 l32 lpc lmp rdu rdk rmdir_ rmdir _rmdir d16 d32 nt nta ntm ntp nvc ncl nvl nll o16 o32 q16 q32 w16 w32 l32 lpc lmp rdu rdk setenv setenv _setenv d16 d32 nt nta ntm ntp nvc ncl nvl nll o16 o32 q16 q32 w16 w32 l32 lpc lmp rdu rdk setmod _setmode setmode d16 d32 nt nta ntm ntp nvc nvl o16 o32 q16 q32 w16 w32 l32 lpc lmp rdu rdk diff --git a/bld/hdr/watcom/strings.mh b/bld/hdr/watcom/strings.mh index 22b89033c0..eca1f75a26 100644 --- a/bld/hdr/watcom/strings.mh +++ b/bld/hdr/watcom/strings.mh @@ -19,6 +19,8 @@ _WCRTLINK extern int bcmp( const void *__s1, const void *__s2, __w_size_t __n ); _WCRTLINK extern void bcopy( const void *__s1, void *__s2, __w_size_t __n ); _WCRTLINK extern void bzero( void *__s, __w_size_t __n ); +_WCRTLINK extern char *index( const char *s, int c ); +_WCRTLINK extern char *rindex( const char *s, int c ); /* Non-legacy functions */ From 2c9078bca317e523250246d35facf7493e9e0f43 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Tue, 19 Sep 2023 16:23:54 +0200 Subject: [PATCH 148/258] add new build control environment variable OWDEVBUILD now two environment variable exists for debug build - OWDEBUGBUILD for simple debug build - OWDEVBUILD for developpers debug build, it include some special code and control functions into standard code --- build/makeinit | 12 ++++++++++++ build/mif/bhost.mif | 6 +++--- build/mif/cproj.mif | 24 +++++++++++++++++------- build/mif/local.mif | 8 ++++---- build/mif/trmem.mif | 2 +- docs/doc/devguide/arch.gml | 37 +++++++++++++++++++++++++++---------- 6 files changed, 64 insertions(+), 25 deletions(-) diff --git a/build/makeinit b/build/makeinit index 99a0533965..fde80be3a4 100644 --- a/build/makeinit +++ b/build/makeinit @@ -43,6 +43,18 @@ noecho = @ noecho = !endif +!ifdef devdebug +debug = 2 +!else ifdef debug +debug = 1 +!else ifdef release +!ifeq release 0 +debug = 1 +!else +debug = 0 +!endif +!endif + mif_path = $(%OWROOT)/build/mif .mif: "$(mif_path)" diff --git a/build/mif/bhost.mif b/build/mif/bhost.mif index e76eb9ebde..3a2e3d4df5 100644 --- a/build/mif/bhost.mif +++ b/build/mif/bhost.mif @@ -33,10 +33,10 @@ bld_incs = $(bld_extra_incs) -I"$(watcom_dir)/h" bld_new_cflags = -xx-zam !endif -!ifeq release 0 -bld_gen_cflags = $(watcom_common_cflags)-j-za99-d2$(bld_new_cflags)-fo=.obj -!else +!ifeq debug 0 bld_gen_cflags = $(watcom_common_cflags)-j-za99-s$(bld_dft_oflags)$(bld_new_cflags)-fo=.obj +!else +bld_gen_cflags = $(watcom_common_cflags)-j-za99-d2$(bld_new_cflags)-fo=.obj !endif # options for source compilations diff --git a/build/mif/cproj.mif b/build/mif/cproj.mif index ca8a240adc..8be96a8770 100644 --- a/build/mif/cproj.mif +++ b/build/mif/cproj.mif @@ -113,13 +113,19 @@ as_mps = *bwasmps !endif -!ifndef release +!ifndef debug !ifdef $(proj_name)_release -release = $($(proj_name)_release) +!ifeq $(proj_name)_release 0 +debug = 1 +!else +debug = 0 +!endif +!else ifeq %OWDEVBUILD 1 +debug = 2 !else ifeq %OWDEBUGBUILD 1 -release = 0 +debug = 1 !else -release = 1 +debug = 0 !endif !endif @@ -181,7 +187,7 @@ cldebug_fmt = -hd mode_optimization = $(dft_oflags) !endif mode_libflags = -!ifeq release 1 +!ifeq debug 0 mode_cppflags = -DNDEBUG mode_cflags = $(mode_optimization) -d1 $(cdebug_fmt) mode_aflags = -d1 -DNDEBUG @@ -191,7 +197,11 @@ mode_clflags = $(cldebug_fmt) -d1 mode_libflags = -s-t-zld !endif !else +!ifeq debug 2 +mode_cppflags = -DDEVBUILD +!else mode_cppflags = +!endif mode_cflags = -od -d2 $(cdebug_fmt) mode_aflags = -d2 mode_lflags = $(ldebug_fmt) all @@ -329,7 +339,7 @@ checkstack_386 = -s checkstack_i86 = -s !else ifdef $(proj_name)_checkstack !else -! ifeq release 1 +! ifeq debug 0 checkstack_386 = -s checkstack_i86 = -s ! else @@ -345,7 +355,7 @@ checkstack_dll_386 = -s checkstack_dll_i86 = -s !else ifdef $(proj_name)_checkstack_dll !else -! ifeq release 1 +! ifeq debug 0 checkstack_dll_386 = -s checkstack_dll_i86 = -s ! else diff --git a/build/mif/local.mif b/build/mif/local.mif index 824a514e03..25c2a41494 100644 --- a/build/mif/local.mif +++ b/build/mif/local.mif @@ -104,7 +104,7 @@ common_flags_dbg = -Zi -fast common_flags_rel = -Ox -Zi common_flags_dbg = -Zi !endif -!ifeq release 1 +!ifeq debug 0 common_flags = $(common_flags_rel) !else common_flags = $(common_flags_dbg) @@ -123,7 +123,7 @@ common_cflags = $(common_cflags_wng) -D_STATIC_CPPLIB common_ldflags_rel = common_ldflags_dbg = -!ifeq release 1 +!ifeq debug 0 common_ldflags = $(common_ldflags_rel) !else common_ldflags = $(common_ldflags_dbg) @@ -350,7 +350,7 @@ common_cppflags_osx_a64 = -D__OSX_ARM64__ # common release/debug options common_flags_rel = -O -g1 -gz -gdwarf-2 common_flags_dbg = -g -gz -gdwarf -!ifeq release 1 +!ifeq debug 0 common_flags = $(common_flags_rel) !else common_flags = $(common_flags_dbg) @@ -366,7 +366,7 @@ common_cflags = $(common_cflags_wng) common_ldflags_rel = common_ldflags_dbg = -!ifeq release 1 +!ifeq debug 0 common_ldflags = $(common_ldflags_rel) !else common_ldflags = $(common_ldflags_dbg) diff --git a/build/mif/trmem.mif b/build/mif/trmem.mif index fdb85ab7d5..219af237d0 100644 --- a/build/mif/trmem.mif +++ b/build/mif/trmem.mif @@ -4,7 +4,7 @@ trmem_cflag_i86 = -of+ trmem_cflag_386 = -of+ !endif !ifeq $(proj_name)_trmem 1 -!ifeq release 0 +!ifneq debug 0 trmem_cpp_flags = -DTRMEM trmem_cover_cflags = $(trmem_cflag_$(host_cpu)) trmem_objs = $(_subdir_)trmem.obj diff --git a/docs/doc/devguide/arch.gml b/docs/doc/devguide/arch.gml index 51c772ad72..a564393aa9 100644 --- a/docs/doc/devguide/arch.gml +++ b/docs/doc/devguide/arch.gml @@ -169,17 +169,34 @@ or pretend to be Jim Welch .* .fn end in order to get a debuggable version of the executable. .np -There is more than one way to switch between development and release build. -A +There is more than one way to switch between development, debug and release +build. +.np +.begbull +.bull +.id OWDEVBUILD +environment variable provides global control. When set to 1, development debug +build is produced. +.bull .id OWDEBUGBUILD -environment variable provides global control. When set to 1, debug builds -are produced, otherwise release builds are created. When building individual -projects with wmake, it is also possible to give the -.us release -macro on the wmake command line (0 means debug build, 1 means release build). -.np -Perhaps it should be noted that "releasable" build still contains debugging -information, but only at the -d1 level and in a separate .sym file. In case +environment variable provides global control. When set to 1, debug build is +produced. +.bull +Otherwise standard release build is created. +.endbull +When building individual projects with wmake, it is also possible to give the +.us debug +macro on the wmake command line. +.begnote +.note 0 +means release build +.note 1 +means debug build +.note 2 +means development debug build +.endnote +Perhaps it should be noted that "release" build contains minimal debugging +information, only at the -d1 level and in a separate .sym file. In case of crashes or other highly unusual behaviour, release build should be enough to point you in the right direction but usually not sufficient to fully diagnose and rectify the problem. From e40107eef27432abf43ae336254c2b0cf437c644 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Tue, 19 Sep 2023 21:18:20 +0200 Subject: [PATCH 149/258] use DEVBUILD macro for development specific code --- bld/as/y/yydriver.c | 2 +- bld/browser/cpp/chfile.cpp | 10 +- bld/browser/dlgprs/cpp/chfile.cpp | 8 +- bld/browser/h/assure.h | 3 +- bld/cc/c/cenum.c | 2 +- bld/cc/c/cgen.c | 4 +- bld/cc/c/cmac1.c | 2 +- bld/cc/c/cmodel.c | 4 +- bld/cc/c/coptions.c | 4 +- bld/cc/c/cpragma.c | 6 +- bld/cc/c/cstmt.c | 2 +- bld/cc/c/ppexpn.c | 4 +- bld/cc/h/dumpapi.h | 3 +- bld/cg/c/bldsel.c | 4 +- bld/cg/c/cgmemmgr.c | 8 +- bld/cg/c/dbsupp.c | 18 +-- bld/cg/c/dbsyms.c | 30 ++--- bld/cg/c/dbtypes.c | 142 +++++++++++----------- bld/cg/c/encode.c | 10 +- bld/cg/c/freelist.c | 5 +- bld/cg/c/intrface.c | 196 +++++++++++++++--------------- bld/cg/c/optask.c | 4 +- bld/cg/c/patch.c | 4 +- bld/cg/c/regtree.c | 4 +- bld/cg/c/split.c | 4 +- bld/cg/c/tree.c | 8 +- bld/cg/h/echoapi.h | 5 +- bld/cg/h/optlbl.h | 4 +- bld/cg/h/patch.h | 2 +- bld/cg/h/seldef.h | 2 +- bld/cg/h/tree.h | 3 +- bld/cg/risc/axp/c/axpenc.c | 4 +- bld/cg/risc/c/rscobj.c | 2 +- bld/cg/risc/mps/c/mpsenc.c | 2 +- bld/cg/risc/ppc/c/ppcenc.c | 10 +- bld/dwarf/dw/c/dwhandle.c | 4 +- bld/dwarf/dw/c/dwloc.c | 2 +- bld/dwarf/dw/h/dwassert.h | 6 +- bld/fe_misc/c/carve.c | 22 ++-- bld/fe_misc/c/pstk.c | 4 +- bld/fe_misc/c/ringfns.c | 4 +- bld/fe_misc/c/vstk.c | 4 +- bld/fe_misc/c/xtrarpt.c | 6 +- bld/fe_misc/h/carve.h | 5 +- bld/fe_misc/h/dbgzap.h | 2 +- bld/fe_misc/h/ringfns.h | 3 +- bld/fpuemu/386/asm/emu387.asm | 2 +- bld/fpuemu/386/inc/386fpemu.inc | 12 +- bld/fpuemu/i86/asm/emu8087.asm | 3 +- bld/fpuemu/i86/asm/fpe86.asm | 2 +- bld/fpuemu/i86/inc/fpe86.inc | 10 +- bld/nwlib/c/cmdline.c | 2 +- bld/nwlib/c/ideentry.c | 2 +- bld/nwlib/c/symtable.c | 4 +- bld/nwlib/h/filetab.h | 2 +- bld/owl/c/owbuffer.c | 3 +- bld/owl/c/owemit.c | 3 +- bld/owl/h/log.h | 2 +- bld/plusplus/c/analcast.c | 4 +- bld/plusplus/c/anallval.c | 6 +- bld/plusplus/c/analnode.c | 2 +- bld/plusplus/c/analtype.c | 2 +- bld/plusplus/c/analyse.c | 10 +- bld/plusplus/c/brinfdep.c | 2 +- bld/plusplus/c/brinfo.c | 12 +- bld/plusplus/c/brinfsrc.c | 4 +- bld/plusplus/c/brmwrite.c | 4 +- bld/plusplus/c/callgrph.c | 6 +- bld/plusplus/c/caux.c | 3 +- bld/plusplus/c/cdopt.c | 10 +- bld/plusplus/c/cgbackhn.c | 8 +- bld/plusplus/c/cgbkarel.c | 10 +- bld/plusplus/c/cgbkbpos.c | 10 +- bld/plusplus/c/cgbkcbak.c | 8 +- bld/plusplus/c/cgbkcgrf.c | 20 +-- bld/plusplus/c/cgbkcmds.c | 26 ++-- bld/plusplus/c/cgbkcond.c | 8 +- bld/plusplus/c/cgbkcstb.c | 6 +- bld/plusplus/c/cgbkfctl.c | 6 +- bld/plusplus/c/cgbkftab.c | 12 +- bld/plusplus/c/cgbkibrp.c | 11 +- bld/plusplus/c/cgbkmain.c | 28 ++--- bld/plusplus/c/cgbkscop.c | 12 +- bld/plusplus/c/cgbkstab.c | 4 +- bld/plusplus/c/cgbkstrn.c | 8 +- bld/plusplus/c/cgbksvar.c | 14 +-- bld/plusplus/c/cgbkthrw.c | 10 +- bld/plusplus/c/cgbktsig.c | 20 +-- bld/plusplus/c/cgbkutil.c | 4 +- bld/plusplus/c/cgbkvftb.c | 2 +- bld/plusplus/c/cgfront.c | 8 +- bld/plusplus/c/cginfo.c | 24 ++-- bld/plusplus/c/cgio.c | 13 +- bld/plusplus/c/cgiobuff.c | 16 +-- bld/plusplus/c/class.c | 16 +-- bld/plusplus/c/cmac1.c | 8 +- bld/plusplus/c/cmdln.c | 6 +- bld/plusplus/c/cmdlnany.c | 4 +- bld/plusplus/c/context.c | 18 +-- bld/plusplus/c/convctl.c | 6 +- bld/plusplus/c/cpragma.c | 12 +- bld/plusplus/c/cpragx86.c | 4 +- bld/plusplus/c/cscan.c | 4 +- bld/plusplus/c/datadtor.c | 10 +- bld/plusplus/c/datainit.c | 30 ++--- bld/plusplus/c/decl.c | 2 +- bld/plusplus/c/defarg.c | 4 +- bld/plusplus/c/dupnode.c | 14 +-- bld/plusplus/c/dwarf.c | 14 +-- bld/plusplus/c/dwiobuff.c | 4 +- bld/plusplus/c/extrf86.c | 2 +- bld/plusplus/c/fmtmsg.c | 8 +- bld/plusplus/c/fmtsym.c | 4 +- bld/plusplus/c/fmttype.c | 4 +- bld/plusplus/c/fnbody.c | 6 +- bld/plusplus/c/fnname.c | 16 +-- bld/plusplus/c/fnovload.c | 12 +- bld/plusplus/c/fnovrank.c | 4 +- bld/plusplus/c/hashtab.c | 12 +- bld/plusplus/c/icemit.c | 8 +- bld/plusplus/c/ideentry.c | 6 +- bld/plusplus/c/iosupp.c | 2 +- bld/plusplus/c/linkage.c | 4 +- bld/plusplus/c/membptr.c | 6 +- bld/plusplus/c/memmgr.c | 16 +-- bld/plusplus/c/message.c | 4 +- bld/plusplus/c/name.c | 16 +-- bld/plusplus/c/opovload.c | 6 +- bld/plusplus/c/pcheader.c | 44 +++---- bld/plusplus/c/plusplus.c | 12 +- bld/plusplus/c/ppexpn.c | 4 +- bld/plusplus/c/ptree.c | 4 +- bld/plusplus/c/ptreedec.c | 10 +- bld/plusplus/c/rewrite.c | 6 +- bld/plusplus/c/rtngen.c | 3 +- bld/plusplus/c/scope.c | 32 ++--- bld/plusplus/c/segment.c | 2 +- bld/plusplus/c/srcfile.c | 8 +- bld/plusplus/c/stringl.c | 4 +- bld/plusplus/c/symbol.c | 6 +- bld/plusplus/c/symlocn.c | 4 +- bld/plusplus/c/template.c | 34 +++--- bld/plusplus/c/type.c | 28 ++--- bld/plusplus/c/typecomp.c | 3 +- bld/plusplus/c/typesig.c | 4 +- bld/plusplus/c/yydriver.c | 66 +++++----- bld/plusplus/h/callgrph.h | 4 +- bld/plusplus/h/carvecpp.h | 6 +- bld/plusplus/h/cgbackut.h | 4 +- bld/plusplus/h/cgfront.h | 12 +- bld/plusplus/h/cgio.h | 2 +- bld/plusplus/h/cgiobuff.h | 4 +- bld/plusplus/h/context.h | 2 +- bld/plusplus/h/convctl.h | 2 +- bld/plusplus/h/dbg.h | 2 +- bld/plusplus/h/defarg.h | 2 +- bld/plusplus/h/dumpapi.h | 3 +- bld/plusplus/h/fnovload.h | 2 +- bld/plusplus/h/hashtab.h | 3 +- bld/plusplus/h/ic.h | 3 +- bld/plusplus/h/initspec.h | 6 +- bld/plusplus/h/memmgr.h | 2 +- bld/plusplus/h/pcheader.h | 4 +- bld/plusplus/h/plusplus.h | 8 +- bld/plusplus/h/ptreedec.h | 3 +- bld/plusplus/h/symbol.h | 2 +- bld/plusplus/h/tokenbuf.h | 2 +- bld/plusplus/ppact/ppact.cpp | 12 +- bld/posix/src/compress/compapi.c | 18 +-- bld/posix/src/compress/compress.c | 8 +- bld/posix/src/compress/compress.h | 14 +-- bld/posix/src/compress/compusi.c | 6 +- bld/rc/rc/c/exereslx.c | 4 +- bld/vi/c/bprintf.c | 4 +- bld/vi/c/fcbdmp.c | 36 ++++-- bld/vi/h/struct.h | 2 +- bld/vi/ui/mouseev.c | 2 +- bld/vi/win/main.c | 6 +- bld/wasm/c/asmerr.c | 2 +- bld/wasm/h/myassert.h | 10 +- bld/watcom/c/idedrv.c | 6 +- bld/wic/c/carver.c | 2 +- bld/wic/c/cmdline.c | 4 +- bld/wic/c/fmem.c | 9 +- bld/wic/c/output.c | 4 +- bld/wic/c/wicgener.c | 16 +-- bld/wic/c/wicstr.c | 2 +- bld/wic/h/wicgener.h | 9 +- bld/wl/c/carve.c | 6 +- bld/wl/c/cmdnov.c | 6 +- bld/wl/c/permdata.c | 4 +- bld/wl/c/ring.c | 4 +- bld/wl/c/wlmem.c | 4 +- bld/wl/h/alloc.h | 4 +- bld/wl/h/standard.h | 4 +- bld/wmake/c/macros.c | 4 +- bld/wmake/c/main.c | 4 +- bld/wmake/c/mcache.c | 4 +- bld/wmake/c/msg.c | 2 +- bld/wmake/c/msysdep.c | 6 +- bld/wmake/c/mtarget.c | 6 +- bld/wmake/h/_msg.h | 2 +- bld/wmake/h/massert.h | 8 +- bld/wmake/h/msg.h | 2 +- bld/wmake/h/msysdep.h | 6 +- bld/womp/c/cantype.c | 3 +- bld/womp/c/genutil.c | 4 +- bld/womp/c/wat2can1.c | 6 +- bld/womp/h/myassert.h | 9 +- bld/wprof/c/utils.c | 2 +- bld/wprof/c/wpmain.c | 4 +- bld/wprof/c/wpstart.c | 8 +- bld/wprof/h/myassert.h | 6 +- bld/wv/c/dbgwintr.c | 6 +- bld/wv/c/dynmem.c | 2 +- bld/wv/h/_dbgcmds.h | 4 +- 216 files changed, 990 insertions(+), 947 deletions(-) diff --git a/bld/as/y/yydriver.c b/bld/as/y/yydriver.c index 5793f2ec47..94c2f1ff62 100644 --- a/bld/as/y/yydriver.c +++ b/bld/as/y/yydriver.c @@ -13,7 +13,7 @@ instruction *AsCurrIns; static directive_t *AsCurrDir; -#ifndef NDEBUG +#ifdef DEVBUILD #define YYDEBUG #endif diff --git a/bld/browser/cpp/chfile.cpp b/bld/browser/cpp/chfile.cpp index a6761bd97b..8257044472 100644 --- a/bld/browser/cpp/chfile.cpp +++ b/bld/browser/cpp/chfile.cpp @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -169,12 +169,12 @@ void CheckedFile::reOpen() // re-open a file and seek to the position it // was closed at. { -#ifndef NDEBUG +#ifdef DEVBUILD long newOff; #endif CheckedFile::open( _openAccess, _openPermission ); -#ifndef NDEBUG +#ifdef DEVBUILD newOff = ::lseek( _handle, _currOffset, SEEK_SET ); assert( newOff == _currOffset ); #else @@ -201,12 +201,12 @@ void CheckedFile::privClose() // since privClose is called from a destructor, avoid // doing a throw in it. { -#ifndef NDEBUG +#ifdef DEVBUILD int retVal; #endif if( _isOpen ) { -#ifndef NDEBUG +#ifdef DEVBUILD retVal = ::close( _handle ); assert( retVal == 0 ); #endif diff --git a/bld/browser/dlgprs/cpp/chfile.cpp b/bld/browser/dlgprs/cpp/chfile.cpp index ef3972e611..a99d046518 100644 --- a/bld/browser/dlgprs/cpp/chfile.cpp +++ b/bld/browser/dlgprs/cpp/chfile.cpp @@ -188,12 +188,12 @@ void CheckedFile::reOpen() // re-open a file and seek to the position it // was closed at. { -#ifndef NDEBUG +#ifdef DEVBUILD long newOff; #endif CheckedFile::open( _openAccess, _openPermission ); -#ifndef NDEBUG +#ifdef DEVBUILD newOff = ::lseek( _handle, _currOffset, SEEK_SET ); assert( newOff == _currOffset ); #else @@ -220,12 +220,12 @@ void CheckedFile::privClose() // since privClose is called from a destructor, avoid // doing a throw in it. { -#ifndef NDEBUG +#ifdef DEVBUILD int retVal; #endif if( _isOpen ) { -#ifndef NDEBUG +#ifdef DEVBUILD retVal = ::close( _handle ); assert( retVal == 0 ); #else diff --git a/bld/browser/h/assure.h b/bld/browser/h/assure.h index 6da6b3cf34..cb226088a2 100644 --- a/bld/browser/h/assure.h +++ b/bld/browser/h/assure.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -33,7 +34,7 @@ #ifndef __ASSURE_H__ #define __ASSURE_H__ -#if defined( DEBUG_ASSERT ) && !defined( NDEBUG ) +#if defined( DEBUG_ASSERT ) && defined( DEVBUILD ) void Assure( int condition, char * msg, int fatal = -1 ); void NoDefault( char * file, int line ); diff --git a/bld/cc/c/cenum.c b/bld/cc/c/cenum.c index 1af753113e..cdf8a73561 100644 --- a/bld/cc/c/cenum.c +++ b/bld/cc/c/cenum.c @@ -346,7 +346,7 @@ void FreeEnums( void ) } } -#ifndef NDEBUG +#ifdef DEVBUILD void DumpEnumTable( void ) { diff --git a/bld/cc/c/cgen.c b/bld/cc/c/cgen.c index 78520313f3..ff0c8591ab 100644 --- a/bld/cc/c/cgen.c +++ b/bld/cc/c/cgen.c @@ -43,7 +43,7 @@ #ifdef __SEH__ #include "tryblock.h" #endif -#ifndef NDEBUG +#ifdef DEVBUILD #include "togglesd.h" #endif @@ -1380,7 +1380,7 @@ void DoCompile( void ) TargetSwitches &= ~ CGSW_X86_FLOATING_SS; } #endif -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_cg ) ) { GenSwitches |= CGSW_GEN_ECHO_API_CALLS; } diff --git a/bld/cc/c/cmac1.c b/bld/cc/c/cmac1.c index 0f7cd710c6..329830141b 100644 --- a/bld/cc/c/cmac1.c +++ b/bld/cc/c/cmac1.c @@ -593,7 +593,7 @@ static MACRO_ARG *CollectParms( MEPTR mentry ) } -#ifndef NDEBUG +#ifdef DEVBUILD void DumpMDefn( const char *p ) /*****************************/ diff --git a/bld/cc/c/cmodel.c b/bld/cc/c/cmodel.c index 1a809449f9..94a8ee9a58 100644 --- a/bld/cc/c/cmodel.c +++ b/bld/cc/c/cmodel.c @@ -37,7 +37,7 @@ #include #include "cmacadd.h" #include "toggles.h" -#ifndef NDEBUG +#ifdef DEVBUILD #include "togglesd.h" #endif @@ -350,7 +350,7 @@ void InitModInfo( void ) CompFlags.check_truncated_fnames = true; memset( &PragmaToggles, 0, sizeof( PragmaToggles ) ); -#ifndef NDEBUG +#ifdef DEVBUILD memset( &PragmaDbgToggles, 0, sizeof( PragmaDbgToggles ) ); #endif TOGGLE( check_stack ) = true; diff --git a/bld/cc/c/coptions.c b/bld/cc/c/coptions.c index 12157ac6d3..d9ebec9051 100644 --- a/bld/cc/c/coptions.c +++ b/bld/cc/c/coptions.c @@ -1162,7 +1162,7 @@ static void SetModuleName( void ) { ModuleName = CopyOfParm(); } static void SetAPILogging( void ) { GenSwitches |= CGSW_GEN_ECHO_API_CALLS; } -#ifndef NDEBUG +#ifdef DEVBUILD #if _RISC_CPU static void SetAsmListing( void ) { TargetSwitches |= CGSW_RISC_ASM_OUTPUT; } static void SetOwlLogging( void ) { TargetSwitches |= CGSW_RISC_OWL_LOGGING; } @@ -1654,7 +1654,7 @@ static struct option const CFE_Options[] = { { "g=$", 0, SetGroup }, #endif { "lc", 0, SetAPILogging }, -#ifndef NDEBUG +#ifdef DEVBUILD #if _RISC_CPU { "la", 0, SetAsmListing }, { "lo", 0, SetOwlLogging }, diff --git a/bld/cc/c/cpragma.c b/bld/cc/c/cpragma.c index 06326e948a..32570ad3c3 100644 --- a/bld/cc/c/cpragma.c +++ b/bld/cc/c/cpragma.c @@ -38,7 +38,7 @@ #include "cfeinfo.h" #include "asmstmt.h" #include "toggles.h" -#ifndef NDEBUG +#ifdef DEVBUILD #include "togglesd.h" #endif @@ -61,7 +61,7 @@ typedef struct prag_stack { hw_reg_set AsmRegsSaved = HW_D( HW_FULL ); pragma_toggles PragmaToggles; -#ifndef NDEBUG +#ifdef DEVBUILD pragma_dbg_toggles PragmaDbgToggles; #endif @@ -686,7 +686,7 @@ hw_reg_set *PragManyRegSets( void ) void SetToggleFlag( char const *name, int func, bool push ) /*********************************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD #define pick( x ) \ if( strcmp( name, #x ) == 0 ) { \ if( func == -1 ) { \ diff --git a/bld/cc/c/cstmt.c b/bld/cc/c/cstmt.c index 2b9f55af18..7911a85252 100644 --- a/bld/cc/c/cstmt.c +++ b/bld/cc/c/cstmt.c @@ -1197,7 +1197,7 @@ void Statement( void ) struct return_info return_info; SYM_ENTRY sym; -#ifndef NDEBUG +#ifdef DEVBUILD if( DebugFlag >= 1 ) { printf( "***** line %u, func=%s\n", TokenLoc.line, CurFunc->name ); PrintStats(); diff --git a/bld/cc/c/ppexpn.c b/bld/cc/c/ppexpn.c index 38dd187025..9af2e53ce4 100644 --- a/bld/cc/c/ppexpn.c +++ b/bld/cc/c/ppexpn.c @@ -81,7 +81,7 @@ #define IS_OPERAND( token ) ( IS_ID_OR_KEYWORD( token ) || token == T_CONSTANT ) -#ifndef NDEBUG +#ifdef DEVBUILD #define __xstr(x) #x #define __location " (" __FILE__ "," __xstr(__LINE__) ")" #define DbgDefault( msg ) default: CFatal( msg __location ) @@ -135,7 +135,7 @@ static int Prec[] = { // table of token precedences #undef pick }; -#ifndef NDEBUG +#ifdef DEVBUILD static void CFatal( char *msg ) /*****************************/ { diff --git a/bld/cc/h/dumpapi.h b/bld/cc/h/dumpapi.h index a162198725..0b6891a4f2 100644 --- a/bld/cc/h/dumpapi.h +++ b/bld/cc/h/dumpapi.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -29,7 +30,7 @@ ****************************************************************************/ -#ifndef NDEBUG +#ifdef DEVBUILD extern void DumpEnumTable( void ); extern void DumpMDefn( const char *p ); diff --git a/bld/cg/c/bldsel.c b/bld/cg/c/bldsel.c index 1eab1dc388..0bf36e1436 100644 --- a/bld/cg/c/bldsel.c +++ b/bld/cg/c/bldsel.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2018 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -72,7 +72,7 @@ sel_handle BGSelInit( void ) s_node->num_cases = 0; s_node->other_wise = NULL; s_node->list = NULL; -#ifndef NDEBUG +#ifdef DEVBUILD s_node->useinfo.hdltype = NO_HANDLE; s_node->useinfo.used = false; #endif diff --git a/bld/cg/c/cgmemmgr.c b/bld/cg/c/cgmemmgr.c index d750e551f7..c1aa2bdcc6 100644 --- a/bld/cg/c/cgmemmgr.c +++ b/bld/cg/c/cgmemmgr.c @@ -435,7 +435,7 @@ void MemFree( pointer p ) blk = header->block; blk->free += header->size + sizeof( blk_hdr ); blk->size += header->size + sizeof( blk_hdr ); -#ifndef NDEBUG +#ifdef DEVBUILD // Must zero the memory for later checks in GetFromBlk memset( header, 0, length + sizeof( blk_hdr ) ); #endif @@ -488,10 +488,10 @@ static pointer MemFromSys( size_t amount ) // round up size to multiple of 64K size = _RoundUp( amount + sizeof( mem_blk ) + sizeof( blk_hdr ), _64K ); -#ifdef NDEBUG - ptr = malloc( size ); -#else +#ifdef DEVBUILD ptr = calloc( 1, size ); // Need to clear memory for later assert() calls +#else + ptr = malloc( size ); #endif if( ptr != NULL ) { AllocSize += size; diff --git a/bld/cg/c/dbsupp.c b/bld/cg/c/dbsupp.c index 87a0954403..e6d5466e83 100644 --- a/bld/cg/c/dbsupp.c +++ b/bld/cg/c/dbsupp.c @@ -41,7 +41,7 @@ #include "types.h" #include "objout.h" #include "targetdb.h" -#ifndef NDEBUG +#ifdef DEVBUILD #include "echoapi.h" #endif #include "regset.h" @@ -132,7 +132,7 @@ cg_sym_handle LocSimpStatic( dbg_loc loc ) dbg_loc _CGAPI DBLocInit( void ) /*******************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD dbg_loc retn; EchoAPI( "DBLocInit()" ); retn = NULL; @@ -169,14 +169,14 @@ dbg_loc _CGAPI DBLocTemp( dbg_loc loc, temp_handle temp ) { name *tmp; -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "DBLocTemp( %i, %i )", loc, temp ); #endif loc = LocCreate( loc, LOC_BP_OFFSET ); tmp = DeAlias( (name *)temp ); tmp->v.usage |= VAR_VOLATILE|NEEDS_MEMORY|USE_IN_ANOTHER_BLOCK|USE_ADDRESS; loc->u.be_sym = tmp; -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( " -> %i\n", loc ); #endif return( loc ); @@ -185,13 +185,13 @@ dbg_loc _CGAPI DBLocTemp( dbg_loc loc, temp_handle temp ) dbg_loc _CGAPI DBLocConst( dbg_loc loc, unsigned_32 val ) /*******************************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "DBLocConst( %i, %i )", loc, val ); #endif loc = LocCreate( loc, LOC_CONST_1 ); loc->u.val = val; -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( " -> %i\n", loc ); #endif return( loc ); @@ -203,7 +203,7 @@ dbg_loc _CGAPI DBLocOp( dbg_loc loc, dbg_loc_op op, unsigned other ) { unsigned stkop; -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "DBLocOp( %i, %i, %i )", loc, op, other ); #endif stkop = 0; @@ -275,7 +275,7 @@ dbg_loc _CGAPI DBLocOp( dbg_loc loc, dbg_loc_op op, unsigned other ) Zoiks( ZOIKS_083 ); break; } -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( " -> %i\n", loc ); #endif return( loc ); @@ -288,7 +288,7 @@ void _CGAPI DBLocFini( dbg_loc loc ) dbg_loc *owner; dbg_loc curr; -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "DBLocFini( %i )\n", loc ); #endif owner = &loc; diff --git a/bld/cg/c/dbsyms.c b/bld/cg/c/dbsyms.c index 65f1026acc..0551c7bef1 100644 --- a/bld/cg/c/dbsyms.c +++ b/bld/cg/c/dbsyms.c @@ -41,7 +41,7 @@ #include "makeins.h" #include "objout.h" #include "dbsyms.h" -#ifndef NDEBUG +#ifdef DEVBUILD #include "echoapi.h" #endif #if _TARGET_INTEL @@ -92,13 +92,13 @@ uint _CGAPI DBSrcFile( cchar_ptr fname ) fname_lst *curr; fname_lst **lnk; -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "DBSrcFile( %c )", fname ); #endif index = 0; for( lnk = &DBFiles.lst; (curr = *lnk) != NULL; lnk = &curr->next ) { if( strcmp( fname, curr->fname ) == 0 ) { -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( " -> %i\n", index ); #endif return( index ); @@ -112,7 +112,7 @@ uint _CGAPI DBSrcFile( cchar_ptr fname ) strcpy( curr->fname, fname ); ++DBFiles.count; *lnk = curr; -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( " -> %i\n", index ); #endif return( index ); @@ -410,7 +410,7 @@ void FiniDbgInfo( void ) void _CGAPI DBLineNum( uint no ) /*********************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "\nDBLineNum( %i )\n", no ); #endif SrcLine = no; @@ -423,7 +423,7 @@ void _CGAPI DBSrcCue( uint fno, uint line, uint col ) bool hasxcue; // const char *fname; -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "\nDBsrcCue( %i, %i, %i )\n", fno, line, col ); #endif // fname = SrcFNoFind( fno ); @@ -442,7 +442,7 @@ void _CGAPI DBSrcCue( uint fno, uint line, uint col ) void _CGAPI DBGenStMem( cg_sym_handle sym, dbg_loc loc ) /******************************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "DBGenStMem( %s,%i)\n", sym, loc ); #endif if( _IsModel( CGSW_GEN_DBG_DF ) ) { @@ -485,7 +485,7 @@ void _CGAPI DBGenSym( cg_sym_handle sym, dbg_loc loc, int scoped ) fe_attr attr; dbg_local *lcl; -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "DBGenSym( %s, %i, %i )\n", sym, loc, scoped ); #endif if( _IsModel( CGSW_GEN_DBG_LOCALS ) ) { @@ -530,7 +530,7 @@ void _CGAPI DBModSym( cg_sym_handle sym, cg_type indirect ) /* unused parameters */ (void)indirect; -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "DBModSym( %s, %t )\n", sym, indirect ); #endif if( _IsModel( CGSW_GEN_DBG_LOCALS ) ) { @@ -554,7 +554,7 @@ void _CGAPI DBObject( dbg_type tipe, dbg_loc loc, cg_type ptr_type ) { /* unused parameters */ (void)ptr_type; -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "DBObject( %i, %i, %t )\n", tipe, loc, ptr_type ); #endif CurrProc->targ.debug->obj_type = tipe; @@ -581,7 +581,7 @@ void DBAllocReg( name *reg, name *temp ) void _CGAPI DBTypeDef( cchar_ptr nm, dbg_type tipe ) /**************************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "DBTypeDef( %c, %t )\n", nm, tipe ); #endif if( _IsModel( CGSW_GEN_DBG_DF ) ) { @@ -600,7 +600,7 @@ void _CGAPI DBLocalSym( cg_sym_handle sym, cg_type indirect ) /* unused parameters */ (void)indirect; -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "DBLocalSym( %s, %t )\n", sym, indirect ); #endif if( CurrProc->targ.debug != NULL ) { @@ -619,7 +619,7 @@ void _CGAPI DBLocalType( cg_sym_handle sym, bool kind ) { dbg_local *lcl; -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "DBLocalType( %s, %i)\n", sym, kind ); #endif if( _IsModel( CGSW_GEN_DBG_LOCALS ) ) { @@ -672,7 +672,7 @@ dbg_block *DoDBBegBlock( int fast_codegen ) void _CGAPI DBBegBlock( void ) /********************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "DBBegBlock()\n" ); #endif DoDBBegBlock( 0 ); @@ -684,7 +684,7 @@ void DoDBEndBlock( int fast_codegen ) { dbg_block *blk; -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "DBEndBlock()\n" ); #endif if( CurrProc->targ.debug != NULL ) { diff --git a/bld/cg/c/dbtypes.c b/bld/cg/c/dbtypes.c index 05811b361a..7f5965c283 100644 --- a/bld/cg/c/dbtypes.c +++ b/bld/cg/c/dbtypes.c @@ -38,7 +38,7 @@ #include "model.h" #include "types.h" #include "zoiks.h" -#ifndef NDEBUG +#ifdef DEVBUILD #include "echoapi.h" #endif #include "i64.h" @@ -68,7 +68,7 @@ dbg_type _CGAPI DBFtnType( cchar_ptr name, dbg_ftn_type tipe ) { dbg_type ret; -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "DBFtnType( %c, %i )", name, tipe ); #endif if( _IsModel( CGSW_GEN_DBG_DF ) ) { @@ -82,7 +82,7 @@ dbg_type _CGAPI DBFtnType( cchar_ptr name, dbg_ftn_type tipe ) ret = 0; #endif } -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( " -> %i\n", ret ); #endif return( ret ); @@ -94,7 +94,7 @@ dbg_type _CGAPI DBScalar( cchar_ptr name, cg_type tipe ) { dbg_type ret; -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "DBScalar( %c,%t )", name, tipe ); #endif if( _IsModel( CGSW_GEN_DBG_DF ) ) { @@ -108,7 +108,7 @@ dbg_type _CGAPI DBScalar( cchar_ptr name, cg_type tipe ) ret = 0; #endif } -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( " -> %i\n", ret ); #endif return( ret ); @@ -121,7 +121,7 @@ dbg_type _CGAPI DBScope( cchar_ptr name ) { dbg_type ret; -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "DBScope( %c )", name ); #endif if( _IsModel( CGSW_GEN_DBG_DF ) ) { @@ -135,7 +135,7 @@ dbg_type _CGAPI DBScope( cchar_ptr name ) ret = 0; #endif } -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( " -> %i\n", ret ); #endif return( ret ); @@ -149,7 +149,7 @@ dbg_name _CGAPI DBBegName( cchar_ptr nm, dbg_type scope ) dbg_name name; uint len; -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "DBBegName( %c, %i )", nm, scope ); #endif len = strlen( nm ); @@ -158,7 +158,7 @@ dbg_name _CGAPI DBBegName( cchar_ptr nm, dbg_type scope ) name->len = len; name->scope = scope; name->refno = DBG_NIL_TYPE; -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( " -> %i\n", name ); #endif return( name ); @@ -168,7 +168,7 @@ dbg_name _CGAPI DBBegName( cchar_ptr nm, dbg_type scope ) dbg_type _CGAPI DBForward( dbg_name name ) /************************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "DBForward( %i )", name ); #endif if( name->refno == DBG_NIL_TYPE ) { @@ -182,7 +182,7 @@ dbg_type _CGAPI DBForward( dbg_name name ) #endif } } -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( " -> %i\n", name->refno ); #endif return( name->refno ); @@ -194,7 +194,7 @@ dbg_type _CGAPI DBEndName( dbg_name name, dbg_type tipe ) { dbg_type retv; -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "DBEndName( %i, %i )", name, tipe ); #endif if( name->refno == DBG_NIL_TYPE ) { @@ -220,7 +220,7 @@ dbg_type _CGAPI DBEndName( dbg_name name, dbg_type tipe ) } retv = name->refno; CGFree( name ); -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( " -> %i\n", retv ); #endif return( retv ); @@ -232,7 +232,7 @@ dbg_type _CGAPI DBCharBlock( unsigned_32 len ) { dbg_type ret; -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "DBCharBlock( %i )", len ); #endif if( _IsModel( CGSW_GEN_DBG_DF ) ) { @@ -254,7 +254,7 @@ dbg_type _CGAPI DBCharBlockNamed( cchar_ptr name, unsigned_32 len ) { dbg_type ret; -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "DBCharBlock( %i )", len ); #endif if( _IsModel( CGSW_GEN_DBG_DF ) ) { @@ -276,7 +276,7 @@ dbg_type _CGAPI DBIndCharBlock( back_handle len, cg_type len_type, int off ) { dbg_type ret; -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "DBIndCharBlock( %i, %t, %i )", len,len_type, off ); #endif if( _IsModel( CGSW_GEN_DBG_DF ) ) { @@ -290,7 +290,7 @@ dbg_type _CGAPI DBIndCharBlock( back_handle len, cg_type len_type, int off ) ret = 0; #endif } -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( " -> %i\n", ret ); #endif return( ret ); @@ -301,7 +301,7 @@ dbg_type _CGAPI DBLocCharBlock( dbg_loc loc, cg_type len_type ) { dbg_type ret; -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "DBLocCharBlock( %i, %t )", loc, len_type ); #endif @@ -316,7 +316,7 @@ dbg_type _CGAPI DBLocCharBlock( dbg_loc loc, cg_type len_type ) ret = 0; #endif } -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( " -> %i\n", ret ); #endif return( ret ); @@ -330,7 +330,7 @@ dbg_type _CGAPI DBFtnArray( back_handle dims, cg_type lo_bound_tipe, { dbg_type ret; -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "DBFtnArray( %B,%t,%t,%i,%i)", dims, lo_bound_tipe, num_elts_tipe, off, base ); #endif @@ -345,7 +345,7 @@ dbg_type _CGAPI DBFtnArray( back_handle dims, cg_type lo_bound_tipe, ret = 0; #endif } -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( " -> %i\n", ret ); #endif return( ret ); @@ -357,7 +357,7 @@ dbg_type _CGAPI DBArray( dbg_type idx, dbg_type base ) { dbg_type ret; -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "DBArray( %i, %i)", idx, base ); #endif if( _IsModel( CGSW_GEN_DBG_DF ) ) { @@ -371,7 +371,7 @@ dbg_type _CGAPI DBArray( dbg_type idx, dbg_type base ) ret = 0; #endif } -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( " -> %i\n", ret ); #endif return( ret ); @@ -385,7 +385,7 @@ dbg_array _CGAPI DBBegArray( dbg_type base, cg_type tipe, bool is_col_major ) /* unused parameters */ (void)tipe; -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "DBBegArray( %i,%t,%i)", base, tipe, is_col_major ); #endif ar = CGAlloc( sizeof( *ar ) ); @@ -396,7 +396,7 @@ dbg_array _CGAPI DBBegArray( dbg_type base, cg_type tipe, bool is_col_major ) ar->base = base; ar->is_col_major = is_col_major; ar->is_variable = false; -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( " -> %i\n", ar ); #endif return( ar ); @@ -425,7 +425,7 @@ void _CGAPI DBDimCon( dbg_array ar, dbg_type idx, signed_32 lo, signed_32 hi ) { dim_con *dim; -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "DBDimCon( %i, %i, %i, %i )\n", ar, idx, lo, hi ); #endif dim = CGAlloc( sizeof( *dim ) ); @@ -443,7 +443,7 @@ void _CGAPI DBDimVar( dbg_array ar, back_handle dims, int off, { dim_var *dim; -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "DBDimVar(%i, %B, %i, %t, %t)\n", ar, dims, off, lo_bound_tipe, num_elts_tipe); #endif dim = CGAlloc( sizeof( *dim ) ); @@ -461,7 +461,7 @@ dbg_type _CGAPI DBEndArray( dbg_array ar ) { dbg_type ret; -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "DBEndArray( %i )", ar ); #endif if( _IsModel( CGSW_GEN_DBG_DF ) ) { @@ -476,7 +476,7 @@ dbg_type _CGAPI DBEndArray( dbg_array ar ) #endif } CGFree( ar ); -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( " -> %i\n", ret ); #endif return( ret ); @@ -487,7 +487,7 @@ dbg_type _CGAPI DBIntArray( unsigned_32 hi, dbg_type base ) { dbg_type ret; -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "DBIntArray( %i, %i )", hi, base ); #endif if( _IsModel( CGSW_GEN_DBG_DF ) ) { @@ -501,7 +501,7 @@ dbg_type _CGAPI DBIntArray( unsigned_32 hi, dbg_type base ) ret = 0; #endif } -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( " -> %i\n", ret ); #endif return( ret ); @@ -513,7 +513,7 @@ dbg_type _CGAPI DBIntArrayCG( cg_type tipe, unsigned_32 hi, dbg_type base ) dbg_type ret; type_def *tipe_addr; -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "DBIntArrayCG( %t, %i, %i )", tipe, hi, base ); #endif tipe_addr = TypeAddress( tipe ); @@ -528,7 +528,7 @@ dbg_type _CGAPI DBIntArrayCG( cg_type tipe, unsigned_32 hi, dbg_type base ) ret = 0; #endif } -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( " -> %i\n", ret ); #endif return( ret ); @@ -539,7 +539,7 @@ dbg_type _CGAPI DBSubRange( signed_32 lo, signed_32 hi, dbg_type base ) { dbg_type ret; -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "DBSubRange( %i, %i, %i )", lo, hi, base ); #endif if( _IsModel( CGSW_GEN_DBG_DF ) ) { @@ -553,7 +553,7 @@ dbg_type _CGAPI DBSubRange( signed_32 lo, signed_32 hi, dbg_type base ) ret = 0; #endif } -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( " -> %i\n", ret ); #endif return( ret ); @@ -566,7 +566,7 @@ dbg_type _CGAPI DBDereference( cg_type ptr_type, dbg_type base ) dbg_type ret; -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "DBDereference( %t, %i)", ptr_type, base ); #endif if( _IsModel( CGSW_GEN_DBG_DF ) ) { @@ -581,7 +581,7 @@ dbg_type _CGAPI DBDereference( cg_type ptr_type, dbg_type base ) #endif } -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( " -> %i\n", ret ); #endif return( ret ); @@ -592,7 +592,7 @@ dbg_type _CGAPI DBPtr( cg_type ptr_type, dbg_type base ) { dbg_type ret; -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "DBPtr( %t, %i )", ptr_type, base ); #endif if( _IsModel( CGSW_GEN_DBG_DF ) ) { @@ -606,7 +606,7 @@ dbg_type _CGAPI DBPtr( cg_type ptr_type, dbg_type base ) ret = 0; #endif } -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( " -> %i\n", ret ); #endif return( ret ); @@ -618,7 +618,7 @@ dbg_type _CGAPI DBBasedPtr( cg_type ptr_type, dbg_type base, { dbg_type ret; -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI("DBBasedPtr( %t, %i, %i )", ptr_type, base, loc_segment ); #endif if( _IsModel( CGSW_GEN_DBG_DF ) ) { @@ -632,7 +632,7 @@ dbg_type _CGAPI DBBasedPtr( cg_type ptr_type, dbg_type base, ret = 0; #endif } -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( " -> %i\n", ret ); #endif return( ret ); @@ -644,12 +644,12 @@ bool _CGAPI DBNested( bool nested ) { bool ret; -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "DBNested(%i)", nested ); #endif ret = Nested; Nested = nested; -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( " -> %i\n", ret ); #endif return( ret ); @@ -661,7 +661,7 @@ dbg_struct _CGAPI DBBegNameStruct( cchar_ptr nm, cg_type tipe, bool is_struct ) uint n_len; dbg_struct st; -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "DBBegNameStruct( %c, %t, %i )", nm, tipe, is_struct ); #endif n_len = Length( nm ); @@ -688,7 +688,7 @@ dbg_struct _CGAPI DBBegNameStruct( cchar_ptr nm, cg_type tipe, bool is_struct ) st->ptr_type = 0; st->vtbl_esize = 0; st->vf = NULL; -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( " -> %i\n", st ); #endif return( st ); @@ -699,11 +699,11 @@ dbg_struct _CGAPI DBBegStruct( cg_type tipe, bool is_struct ) { dbg_struct st; -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "DBBegStruct( %t, %i )", tipe, is_struct ); #endif st = DBBegNameStruct( "", tipe, is_struct ); -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( " -> %i\n", st ); #endif return( st ); @@ -742,7 +742,7 @@ void _CGAPI DBAddBitField( dbg_struct st, unsigned_32 off, byte strt, { field_member *field; -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "DBAddBitField(%i,%i,%i,%i,%c,%i)\n", st, off, strt, len, nm, base ); #endif field = CreateMember( nm, strt, len, base, 0 ); @@ -756,7 +756,7 @@ void _CGAPI DBAddField( dbg_struct st, unsigned_32 off, cchar_ptr nm, dbg_type base ) /***************************************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "DBAddField( %i, %i,%c,%i)\n", st, off, nm, base ); #endif DBAddBitField( st, off, 0, 0, nm, base ); @@ -770,7 +770,7 @@ void _CGAPI DBAddLocField( dbg_struct st, dbg_loc loc, uint attr, field_member *field; offset off; -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "DBAddLocField( %i,%i,%i,%i,%i,%c,%i)\n", st, loc, attr, strt, len, nm, base ); #endif field = CreateMember( nm, strt, len, base, attr ); @@ -791,7 +791,7 @@ void _CGAPI DBAddStField( dbg_struct st, dbg_loc loc, cchar_ptr nm, unsigned_32 uint n_len; field_stfield *field; -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "DBAddStField(%i,%i,%c,%i,%i)\n", st, loc, nm, attr, base ); #endif n_len = Length( nm ); @@ -811,7 +811,7 @@ void _CGAPI DBAddMethod( dbg_struct st, dbg_loc loc, uint attr, uint n_len; field_method *field; -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "DBAddMethod( %i,%i,%i,%i,%c,%i)\n", st, loc, attr, kind, nm, base ); #endif n_len = Length( nm ); @@ -832,7 +832,7 @@ void _CGAPI DBAddNestedType( dbg_struct st, cchar_ptr nm, dbg_type base ) uint n_len; field_nested *field; -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "DBAddNestedType( %i,%c,%i)\n", st, nm, base ); #endif n_len = Length( nm ); @@ -851,7 +851,7 @@ void _CGAPI DBAddInheritance( dbg_struct st, dbg_type inherit, { field_bclass *field; -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "DBAddInheritance(%i,%i,%i,%i,%i)\n", st, inherit, attr, kind, loc ); #endif field = CGAlloc( sizeof( field_bclass ) ); @@ -868,7 +868,7 @@ void _CGAPI DBAddBaseInfo( dbg_struct st, unsigned_32 vb_off, int esize, dbg_type vtbl, cg_type ptr_type ) /********************************************************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "DBAddBaseInfo( %i,%i,%i,%i,%t)\n", st, vb_off, esize, vtbl, ptr_type ); #endif st->vtbl_off = vb_off; @@ -884,7 +884,7 @@ void _CGAPI DBAddVFuncInfo( dbg_struct st, unsigned_32 vfptr_off, { field_vfunc *field; -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "DBAddVFuncInfo( %i,%i,%i,%t )\n", st, vfptr_off, size, vft_cgtype ); #endif field = CGAlloc( sizeof( field_vfunc ) ); @@ -901,7 +901,7 @@ dbg_type _CGAPI DBEndStruct( dbg_struct st ) { dbg_type ret; -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "DBEndStruct(%i)", st ); #endif if( _IsModel( CGSW_GEN_DBG_DF ) ) { @@ -916,7 +916,7 @@ dbg_type _CGAPI DBEndStruct( dbg_struct st ) #endif } CGFree( st ); -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( " -> %i\n", ret ); #endif return( ret ); @@ -925,7 +925,7 @@ dbg_type _CGAPI DBEndStruct( dbg_struct st ) dbg_type _CGAPI DBStructForward( dbg_struct st ) /******************************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "DBStructForward( %i )", st ); EchoAPI( " -> %i\n", st->me ); #endif @@ -937,7 +937,7 @@ dbg_enum _CGAPI DBBegEnum( cg_type tipe ) { dbg_enum en; -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "DBBegEnum( %t )", tipe ); #endif en = CGAlloc( sizeof( enum_list ) ); @@ -946,7 +946,7 @@ dbg_enum _CGAPI DBBegEnum( cg_type tipe ) en->tipe = tipe; en->is_nested = Nested; en->is_c = true; -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( " -> %i\n", en ); #endif return( en ); @@ -958,7 +958,7 @@ void _CGAPI DBAddConst( dbg_enum en, cchar_ptr nm, signed_32 val ) const_entry *cons; uint len; -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "DBAddConst( %i,%c,%i)\n", en, nm, val ); #endif len = Length( nm ); @@ -977,7 +977,7 @@ void _CGAPI DBAddConst64( dbg_enum en, cchar_ptr nm, signed_64 val ) const_entry *cons; uint len; -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "DBAddConst( %i,%c,%x %x )\n", en, nm, val.u._32[0],val.u._32[1] ); #endif len = Length( nm ); @@ -995,7 +995,7 @@ dbg_type _CGAPI DBEndEnum( dbg_enum en ) { dbg_type ret; -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "DBEndEnum(%i)", en ); #endif if( _IsModel( CGSW_GEN_DBG_DF ) ) { @@ -1010,7 +1010,7 @@ dbg_type _CGAPI DBEndEnum( dbg_enum en ) #endif } CGFree( en ); -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( " -> %i\n", ret ); #endif return( ret ); @@ -1022,7 +1022,7 @@ dbg_proc _CGAPI DBBegProc( cg_type call_type, dbg_type ret ) { dbg_proc pr; -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "DBBegProc( %t,%i)", call_type, ret ); #endif pr = CGAlloc( sizeof( proc_list ) ); @@ -1032,7 +1032,7 @@ dbg_proc _CGAPI DBBegProc( cg_type call_type, dbg_type ret ) pr->ret = ret; pr->cls = DBG_NIL_TYPE; pr->this = DBG_NIL_TYPE; -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( " -> %i\n", pr ); #endif return(pr); @@ -1041,7 +1041,7 @@ dbg_proc _CGAPI DBBegProc( cg_type call_type, dbg_type ret ) void _CGAPI DBAddMethParms( dbg_proc pr, dbg_type cls, dbg_type this ) /*****************************************************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "DBAddMethParms( %i, %i, %i)\n", pr, cls, this ); #endif pr->cls = cls; @@ -1054,7 +1054,7 @@ void _CGAPI DBAddParm( dbg_proc pr, dbg_type tipe ) parm_entry *parm; parm_entry **owner; -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "DBAddParm( %i,%i )\n", pr, tipe ); #endif parm = CGAlloc( sizeof( parm_entry ) ); @@ -1073,7 +1073,7 @@ dbg_type _CGAPI DBEndProc( dbg_proc pr ) { dbg_type ret; -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "DBEndProc( %i )", pr ); #endif if( _IsModel( CGSW_GEN_DBG_DF ) ) { @@ -1088,7 +1088,7 @@ dbg_type _CGAPI DBEndProc( dbg_proc pr ) #endif } CGFree( pr ); -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( " -> %i\n", ret ); #endif return( ret ); diff --git a/bld/cg/c/encode.c b/bld/cg/c/encode.c index aa4d7897a0..c05f7a27c7 100644 --- a/bld/cg/c/encode.c +++ b/bld/cg/c/encode.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -82,7 +82,7 @@ void CodeLabel( label_handle label, unsigned align ) align = 1; CodeHandle( OC_LABEL, align - 1, label ); #if _TARGET_RISC -#ifndef NDEBUG +#ifdef DEVBUILD if( _IsTargetModel( CGSW_RISC_ASM_OUTPUT ) ) { DumpChar( 'L' ); DumpPtr( label ); @@ -107,7 +107,7 @@ void CodeLineNumber( cg_linenum line, bool label_line ) oc.oc_linenum.label_line = label_line; oc.oc_linenum.line = line; #if _TARGET_RISC -#ifndef NDEBUG +#ifdef DEVBUILD if( _IsTargetModel( CGSW_RISC_ASM_OUTPUT ) ) { DumpLiteral( "Source Line: " ); DumpInt( line ); @@ -193,7 +193,7 @@ static void DoCondJump( instruction *cond ) #endif InputOC( &oc ); #if _TARGET_RISC -#ifndef NDEBUG +#ifdef DEVBUILD if( _IsTargetModel( CGSW_RISC_ASM_OUTPUT ) ) { DumpLiteral( "Jcc L" ); DumpPtr( dest_true ); @@ -236,7 +236,7 @@ void GenJumpLabel( label_handle label ) { CodeHandle( OC_JMP, OptInsSize( OC_JMP, OC_DEST_NEAR ), label ); #if _TARGET_RISC -#ifndef NDEBUG +#ifdef DEVBUILD if( _IsTargetModel( CGSW_RISC_ASM_OUTPUT ) ) { DumpLiteral( "JMP L" ); DumpPtr( label ); diff --git a/bld/cg/c/freelist.c b/bld/cg/c/freelist.c index b1c9ab75ad..066da49963 100644 --- a/bld/cg/c/freelist.c +++ b/bld/cg/c/freelist.c @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -56,7 +57,7 @@ pointer AllocFrl( pointer **head, size_t size ) *head = **head; FrlSize -= size; } -#ifndef NDEBUG +#ifdef DEVBUILD memset( new, 0xda, size ); #endif _AlignmentCheck( new, 8 ); @@ -67,7 +68,7 @@ pointer AllocFrl( pointer **head, size_t size ) void FrlFreeSize( pointer **head, pointer *what, size_t size ) /***************************************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD memset( what, 0xdf, size ); #endif FrlSize += size; diff --git a/bld/cg/c/intrface.c b/bld/cg/c/intrface.c index 2039662102..3c3fa73cf0 100644 --- a/bld/cg/c/intrface.c +++ b/bld/cg/c/intrface.c @@ -67,7 +67,7 @@ #include "feprotos.h" #include "cgprotos.h" -#ifndef NDEBUG +#ifdef DEVBUILD #include "echoapi.h" #include #endif @@ -140,7 +140,7 @@ cg_init_info _CGAPI BEInitCg( cg_switches switches, #ifdef QNX_FLAKEY OrigModel = switches; #endif -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPIInit(); EchoAPI( "BEInit( %x, %x, %i, %x )\n", switches, platform, optsize, proc ); // must be after Model is set and before InitDBGInfo call @@ -186,7 +186,7 @@ cg_init_info _CGAPI BEInit( cg_switches switches, void _CGAPI BEStart( void ) /*****************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "BEStart()\n" ); #endif InitCG(); @@ -195,7 +195,7 @@ void _CGAPI BEStart( void ) void _CGAPI BEStop( void ) /****************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "BEStop()\n" ); #endif FiniCG(); @@ -204,7 +204,7 @@ void _CGAPI BEStop( void ) void _CGAPI BEAbort( void ) /*****************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "BEAbort()\n" ); #endif AbortCG(); @@ -243,7 +243,7 @@ static void FreeBckInfoCarveBlocks( void ) void _CGAPI BEFiniCg( void ) /******************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "BEFiniCg()\n" ); EchoAPIFini(); #endif @@ -270,7 +270,7 @@ bool _CGAPI BEMoreMem( void ) segment_id _CGAPI BEGetSeg( void ) /**********************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD segment_id segid; EchoAPI( "BEGetSeg()" ); @@ -284,7 +284,7 @@ segment_id _CGAPI BEGetSeg( void ) segment_id _CGAPI BESetSeg( segment_id segid ) /**********************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "BESetSeg( %x )", segid ); segid = SetOP( segid ); return EchoAPIHexReturn( segid ); @@ -296,7 +296,7 @@ segment_id _CGAPI BESetSeg( segment_id segid ) void _CGAPI BEDefSeg( segment_id segid, seg_attr attr, cchar_ptr str, uint algn ) /*******************************************************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "BEDefSeg( %x, %x, %c, %i )\n", segid, attr, str, algn ); #endif DefSegment( segid, attr, str, algn, false ); @@ -305,7 +305,7 @@ void _CGAPI BEDefSeg( segment_id segid, seg_attr attr, cchar_ptr str, uint algn void _CGAPI BEFlushSeg( segment_id segid ) /********************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "BEFlushSeg( %x )\n", segid ); #endif FlushOP( segid ); @@ -320,7 +320,7 @@ void _CGAPI BEFlushSeg( segment_id segid ) label_handle _CGAPI BENewLabel( void ) /************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD label_handle retn; EchoAPI( "BENewLabel()" ); @@ -336,7 +336,7 @@ label_handle _CGAPI BENewLabel( void ) void _CGAPI BEFiniLabel( label_handle lbl ) /*********************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "BEFiniLabel( %L )\n", lbl ); hdlExists( LABEL_HANDLE, lbl ); hdlUseOnce( LABEL_HANDLE, lbl ); @@ -356,7 +356,7 @@ void _CGAPI BEFiniLabel( label_handle lbl ) unsigned_32 _CGAPI BEUnrollCount( unsigned_32 unroll_count ) /***************************************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD unsigned_32 retn; EchoAPI( "BEUnrollCount( %i )", unroll_count ); retn = BGUnrollCount( unroll_count ); @@ -376,7 +376,7 @@ unsigned_32 _CGAPI BEUnrollCount( unsigned_32 unroll_count ) patch_handle _CGAPI BEPatch( void ) /*************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD patch_handle patch; EchoAPI( "BEPatch()" ); @@ -392,7 +392,7 @@ patch_handle _CGAPI BEPatch( void ) cg_name _CGAPI CGPatchNode( patch_handle patch, cg_type tipe ) /*********************************************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD cg_name retn; EchoAPI( "CGPatchNode( %P, %t )", patch, tipe ); @@ -408,7 +408,7 @@ cg_name _CGAPI CGPatchNode( patch_handle patch, cg_type tipe ) void _CGAPI BEPatchInteger( patch_handle patch, signed_32 value ) /*******************************************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "BEPatchInteger( %P, %x )\n", patch, value ); hdlExists( PATCH_HANDLE, patch ); #endif @@ -418,7 +418,7 @@ void _CGAPI BEPatchInteger( patch_handle patch, signed_32 value ) void _CGAPI BEFiniPatch( patch_handle patch ) /***********************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "BEFiniPatch( %P )\n", patch ); hdlUseOnce( PATCH_HANDLE, patch ); #endif @@ -481,17 +481,17 @@ back_handle _CGAPI BENewBack( cg_sym_handle sym ) { back_handle bck; -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "BENewBack( %s )", sym ); #endif if( NewBackReturn == FAKE_NULL ) { -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( " -> %B\n", NULL ); #endif return( NULL ); } if( NewBackReturn != NULL ) { -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( " -> %B\n", NewBackReturn ); #endif return( NewBackReturn ); @@ -512,7 +512,7 @@ back_handle _CGAPI BENewBack( cg_sym_handle sym ) } if( !IS_REAL_BACK( bck ) ) _Zoiks( ZOIKS_067 ); -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( " -> %B\n", bck ); #endif return( bck ); @@ -521,7 +521,7 @@ back_handle _CGAPI BENewBack( cg_sym_handle sym ) void _CGAPI BEFiniBack( back_handle bck ) /*******************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "BEFiniBack( %L )\n", bck ); #endif if( IS_REAL_BACK( bck ) ) { @@ -532,7 +532,7 @@ void _CGAPI BEFiniBack( back_handle bck ) void _CGAPI BEFreeBack( back_handle bck ) /*******************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "BEFreeBack( %L )\n", bck ); #endif if( IS_REAL_BACK( bck ) ) { @@ -554,7 +554,7 @@ void _CGAPI BEFreeBack( back_handle bck ) void _CGAPI BEDefType( cg_type what, uint align, unsigned_32 len ) /********************************************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "BEDefType( %t, %x, %i )\n", what, align, len ); #endif TypeDef( what, len, align ); @@ -563,7 +563,7 @@ void _CGAPI BEDefType( cg_type what, uint align, unsigned_32 len ) void _CGAPI BEAliasType( cg_type what, cg_type to ) /*****************************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "BEAliasType( %t, %t )\n", what, to ); #endif TypeAlias( what, to ); @@ -572,7 +572,7 @@ void _CGAPI BEAliasType( cg_type what, cg_type to ) unsigned_32 _CGAPI BETypeLength( cg_type tipe ) /**************************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD unsigned_32 retn; EchoAPI( "BETypeLength( %t )\n", tipe ); retn = TypeLength( tipe) ; @@ -585,7 +585,7 @@ unsigned_32 _CGAPI BETypeLength( cg_type tipe ) uint _CGAPI BETypeAlign( cg_type tipe ) /*****************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD uint retn; EchoAPI( "BETypeAlign( %t )\n", tipe ); retn = 1; @@ -606,7 +606,7 @@ uint _CGAPI BETypeAlign( cg_type tipe ) void _CGAPI CGProcDecl( cg_sym_handle sym, cg_type tipe ) /***********************************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "\n" ); EchoAPI( "CGProcDecl( %s, %t )\n", sym, tipe ); #endif @@ -621,7 +621,7 @@ void _CGAPI CGProcDecl( cg_sym_handle sym, cg_type tipe ) void _CGAPI CGParmDecl( cg_sym_handle sym, cg_type tipe ) /***********************************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "CGParmDecl( %s, %t )\n", sym, tipe ); #endif if( BGInInline() ) { @@ -636,7 +636,7 @@ label_handle _CGAPI CGLastParm( void ) { label_handle top; -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "CGLastParm()\n" ); #endif top = NULL; @@ -652,7 +652,7 @@ label_handle _CGAPI CGLastParm( void ) void _CGAPI CGAutoDecl( cg_sym_handle sym, cg_type tipe ) /***********************************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "CGAutoDecl( %s, %t )\n", sym, tipe ); #endif BGAutoDecl( sym, TypeAddress( tipe ) ); @@ -664,7 +664,7 @@ void _CGAPI CGReturn( cg_name name, cg_type tipe ) type_def *new_tipe; an retv; -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "CGReturn( %n, %t )\n\n", name, tipe ); if( NULL != name ) { hdlUseOnce( CG_NAMES, name ); @@ -696,7 +696,7 @@ void _CGAPI CGReturn( cg_name name, cg_type tipe ) cg_name _CGAPI CGVarargsBasePtr( cg_type tipe ) /*********************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD cg_name retn; EchoAPI( "CGVarargsBasePtr( %t )", tipe ); @@ -711,7 +711,7 @@ cg_name _CGAPI CGVarargsBasePtr( cg_type tipe ) cg_name _CGAPI CGInteger( signed_32 val, cg_type tipe ) /*****************************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD cg_name retn; EchoAPI( "CGInteger( %i, %t )", val, tipe ); @@ -727,7 +727,7 @@ cg_name _CGAPI CGInteger( signed_32 val, cg_type tipe ) cg_name _CGAPI CGInt64( signed_64 val, cg_type tipe ) /***************************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD cg_name retn; EchoAPI( "CGInt64( %x %x, %t )" @@ -746,7 +746,7 @@ cg_name _CGAPI CGInt64( signed_64 val, cg_type tipe ) cg_name _CGAPI CGFloat( cchar_ptr num, cg_type tipe ) /***************************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD cg_name retn; EchoAPI( "CGFloat( %c, %t )", num, tipe ); @@ -763,7 +763,7 @@ cg_name _CGAPI CGFloat( cchar_ptr num, cg_type tipe ) cg_name _CGAPI CGBigInt( float_handle f, cg_type tipe ) /*****************************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD cg_name retn; EchoAPI( "CGBigInt( %x, %t )", f, tipe ); @@ -785,19 +785,19 @@ cg_name _CGAPI CGFEName( cg_sym_handle sym, cg_type tipe ) if( (FEAttr( sym ) & FE_DLLIMPORT) && ( FindAuxInfoSym( sym, FEINF_CALL_BYTES ) == NULL ) ) { leaf = TGLeaf( BGName( CG_FE, sym, TypeAddress( TY_POINTER ) ) ); -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "CGFEName( %s, %t ) declspec(dllimport)", sym, tipe ); hdlAdd( CG_NAMES, leaf ); #endif leaf = CGUnary( O_POINTS, leaf, TY_POINTER ); } else { leaf = TGLeaf( BGName( CG_FE, sym, TypeAddress( tipe ) ) ); -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "CGFEName( %s, %t )", sym, tipe ); hdlAdd( CG_NAMES, leaf ); #endif } -#ifndef NDEBUG +#ifdef DEVBUILD return EchoAPICgnameReturn( leaf ); #else return( leaf ); @@ -807,7 +807,7 @@ cg_name _CGAPI CGFEName( cg_sym_handle sym, cg_type tipe ) cg_name _CGAPI CGBackName( back_handle bck, cg_type tipe ) /********************************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD cg_name retn; EchoAPI( "CGBackName( %B, %t )", bck, tipe ); @@ -816,7 +816,7 @@ cg_name _CGAPI CGBackName( back_handle bck, cg_type tipe ) if( !IS_REAL_BACK( bck ) ) _Zoiks( ZOIKS_068 ); -#ifndef NDEBUG +#ifdef DEVBUILD retn = TGLeaf( BGName( CG_BACK, bck, TypeAddress( tipe ) ) ); hdlAdd( CG_NAMES, retn ); return EchoAPICgnameReturn( retn ); @@ -828,7 +828,7 @@ cg_name _CGAPI CGBackName( back_handle bck, cg_type tipe ) cg_name _CGAPI CGTempName( temp_handle temp, cg_type tipe ) /*********************************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD cg_name retn; EchoAPI( "CGTempName( %T, %t )", temp, tipe ); @@ -845,7 +845,7 @@ cg_name _CGAPI CGTempName( temp_handle temp, cg_type tipe ) temp_handle _CGAPI CGTemp( cg_type tipe ) /********************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD temp_handle retn; EchoAPI( "CGTemp( %t )", tipe ); @@ -863,7 +863,7 @@ temp_handle _CGAPI CGTemp( cg_type tipe ) cg_name _CGAPI CGAssign( cg_name dest, cg_name source, cg_type tipe ) /*******************************************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD cg_name retn; EchoAPI( "CGAssign( %n, %n, %t )", dest, source, tipe ); @@ -881,7 +881,7 @@ cg_name _CGAPI CGAssign( cg_name dest, cg_name source, cg_type tipe ) cg_name _CGAPI CGLVAssign( cg_name dest, cg_name source, cg_type tipe ) /*********************************************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD cg_name retn; EchoAPI( "CGLVAssign( %n, %n, %t )", dest, source, tipe ); @@ -899,7 +899,7 @@ cg_name _CGAPI CGLVAssign( cg_name dest, cg_name source, cg_type tipe ) cg_name _CGAPI CGPostGets( cg_op op, cg_name dest, cg_name src, cg_type tipe ) /****************************************************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD cg_name retn; EchoAPI( "CGPostGets( %o, %n, %n, %t )", op, dest, src, tipe ); @@ -916,7 +916,7 @@ cg_name _CGAPI CGPostGets( cg_op op, cg_name dest, cg_name src, cg_type tipe ) cg_name _CGAPI CGPreGets( cg_op op, cg_name dest, cg_name src, cg_type tipe ) /***************************************************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD cg_name retn; EchoAPI( "CGPreGets( %o, %n, %n, %t )", op, dest, src, tipe ); @@ -933,7 +933,7 @@ cg_name _CGAPI CGPreGets( cg_op op, cg_name dest, cg_name src, cg_type tipe ) cg_name _CGAPI CGLVPreGets( cg_op op, cg_name dest, cg_name src, cg_type tipe ) /*****************************************************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD cg_name retn; EchoAPI( "CGLVPreGets( %o, %n, %n, %t )", op, dest, src, tipe ); @@ -954,7 +954,7 @@ cg_name _CGAPI CGLVPreGets( cg_op op, cg_name dest, cg_name src, cg_type tipe ) cg_name _CGAPI CGBinary( cg_op op, cg_name name1, cg_name name2, cg_type tipe ) /*****************************************************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD cg_name retn; EchoAPI( "CGBinary( %o, %n, %n, %t )", op, name1, name2, tipe ); @@ -967,7 +967,7 @@ cg_name _CGAPI CGBinary( cg_op op, cg_name name1, cg_name name2, cg_type tipe ) } else if( op == O_SIDE_EFFECT ) { name2 = TGTrash( name2 ); } -#ifndef NDEBUG +#ifdef DEVBUILD retn = TGBinary( op, name1, name2, TypeAddress(tipe) ); hdlAddBinary( CG_NAMES, retn, name1, name2 ); return EchoAPICgnameReturn( retn ); @@ -979,7 +979,7 @@ cg_name _CGAPI CGBinary( cg_op op, cg_name name1, cg_name name2, cg_type tipe ) cg_name _CGAPI CGUnary( cg_op op, cg_name name, cg_type tipe ) /************************************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD cg_name retn; EchoAPI( "CGUnary( %o, %n, %t )", op, name, tipe ); @@ -996,7 +996,7 @@ cg_name _CGAPI CGUnary( cg_op op, cg_name name, cg_type tipe ) cg_name _CGAPI CGIndex( cg_name name, cg_name by, cg_type tipe, cg_type ptipe ) /*****************************************************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "CGIndex( %n, %n, %t, %t )", name, by, tipe, ptipe ); #endif return( TGIndex( name, by, TypeAddress( tipe ), TypeAddress( ptipe ) ) ); @@ -1009,7 +1009,7 @@ cg_name _CGAPI CGIndex( cg_name name, cg_name by, cg_type tipe, cg_type ptipe ) call_handle _CGAPI CGInitCall( cg_name name, cg_type tipe, cg_sym_handle sym ) /*****************************************************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD call_handle call; EchoAPI( "CGInitCall( %n, %t, %s )", name, tipe, sym ); @@ -1025,7 +1025,7 @@ call_handle _CGAPI CGInitCall( cg_name name, cg_type tipe, cg_sym_handle sym ) void _CGAPI CGAddParm( call_handle call, cg_name name, cg_type tipe ) /***********************************************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "CGAddParm( %C, %n, %t )\n", call, name, tipe ); hdlExists( CG_NAMES, call ); hdlUseOnce( CG_NAMES, name ); @@ -1036,7 +1036,7 @@ void _CGAPI CGAddParm( call_handle call, cg_name name, cg_type tipe ) cg_name _CGAPI CGCall( call_handle call ) /***************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD cg_name retn; EchoAPI( "CGCall( %C )\n", call ); @@ -1056,7 +1056,7 @@ cg_name _CGAPI CGCall( call_handle call ) cg_name _CGAPI CGCompare( cg_op op, cg_name name1, cg_name name2, cg_type tipe ) /******************************************************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD cg_name retn; EchoAPI( "CGCompare( %o, %n, %n, %t )", op, name1, name2, tipe ); @@ -1073,7 +1073,7 @@ cg_name _CGAPI CGCompare( cg_op op, cg_name name1, cg_name name2, cg_type tipe ) cg_name _CGAPI CGFlow( cg_op op, cg_name name1, cg_name name2 ) /*************************************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD cg_name retn; EchoAPI( "CGFlow( %o, %n, %n )", op, name1, name2 ); @@ -1096,7 +1096,7 @@ cg_name _CGAPI CGFlow( cg_op op, cg_name name1, cg_name name2 ) cg_name _CGAPI CGChoose( cg_name sel, cg_name n1, cg_name n2, cg_type tipe ) /**************************************************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD cg_name retn; EchoAPI( "CGChoose( %n, %n, %n, %t )", sel, n1, n2, tipe ); @@ -1114,7 +1114,7 @@ cg_name _CGAPI CGChoose( cg_name sel, cg_name n1, cg_name n2, cg_type tipe ) cg_name _CGAPI CGWarp( cg_name before, label_handle label, cg_name after ) /************************************************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD cg_name retn; EchoAPI( "CGWarp( %n, %L, %n )", before, label, after ); @@ -1134,7 +1134,7 @@ cg_name _CGAPI CGWarp( cg_name before, label_handle label, cg_name after ) cg_name _CGAPI CGCallback( cg_callback func, callback_handle parm ) /******************************************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD cg_name retn; EchoAPI( "CGCallback( %x, %x )", func, parm ); @@ -1152,7 +1152,7 @@ void _CGAPI CG3WayControl( cg_name expr, label_handle lt, label_handle eq, label_handle gt ) /***************************************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "CG3WayControl( %n, %L, %L, %L )\n", expr, lt, eq, gt ); #endif TG3WayControl( expr, lt, eq, gt ); /* special TGen()*/ @@ -1161,7 +1161,7 @@ void _CGAPI CG3WayControl( cg_name expr, label_handle lt, void _CGAPI CGControl( cg_op op, cg_name expr, label_handle lbl ) /*******************************************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "CGControl( %o, %n, %L )\n", op, expr, lbl ); if( NULL != expr ) { hdlUseOnce( CG_NAMES, expr ); @@ -1177,7 +1177,7 @@ void _CGAPI CGControl( cg_op op, cg_name expr, label_handle lbl ) void _CGAPI CGBigLabel( back_handle bck ) /*******************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "CGBigLabel( %B )\n", bck ); #endif BGBigLabel( bck ); @@ -1186,7 +1186,7 @@ void _CGAPI CGBigLabel( back_handle bck ) void _CGAPI CGBigGoto( label_handle lbl, int level ) /******************************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "CGBigGoto( %L, %i )\n", lbl, level ); #endif BGBigGoto( lbl, level ); @@ -1195,7 +1195,7 @@ void _CGAPI CGBigGoto( label_handle lbl, int level ) sel_handle _CGAPI CGSelInit( void ) /***************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD sel_handle retn; EchoAPI( "CGSelInit()" ); @@ -1210,7 +1210,7 @@ sel_handle _CGAPI CGSelInit( void ) void _CGAPI CGSelCase( sel_handle s, label_handle lbl, signed_32 val ) /************************************************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "CGSelCase( %S, %L, %i )\n", s, lbl, val ); hdlExists( SEL_HANDLE, s ); hdlExists( LABEL_HANDLE, lbl ); @@ -1222,7 +1222,7 @@ void _CGAPI CGSelRange( sel_handle s, signed_32 lo, signed_32 hi, label_handle lbl ) /**********************************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "CGSelRange( %S, %L, %i, %i )\n", s, lbl, lo, hi ); hdlExists( SEL_HANDLE, s ); hdlExists( LABEL_HANDLE, lbl ); @@ -1233,7 +1233,7 @@ void _CGAPI CGSelRange( sel_handle s, signed_32 lo, void _CGAPI CGSelOther( sel_handle s, label_handle lbl ) /**********************************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "CGSelOther( %S, %L )\n", s, lbl ); hdlExists( SEL_HANDLE, s ); hdlExists( LABEL_HANDLE, lbl ); @@ -1253,7 +1253,7 @@ void _CGAPI CGSelectRestricted( sel_handle s, cg_name expr, cg_switch_type a void _CGAPI CGSelect( sel_handle s, cg_name expr ) /****************************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "CGSelect( %S, %n )\n", s, expr ); hdlExists( SEL_HANDLE, s ); hdlUseOnce( CG_NAMES, expr ); @@ -1270,7 +1270,7 @@ void _CGAPI CGSelect( sel_handle s, cg_name expr ) cg_name _CGAPI CGEval( cg_name name ) /***********************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD cg_name retn; EchoAPI( "CGEval( %n )", name ); @@ -1286,7 +1286,7 @@ cg_name _CGAPI CGEval( cg_name name ) void _CGAPI CGTrash( cg_name name ) /*************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "CGTrash( %n )\n", name ); hdlUseOnce( CG_NAMES, name ); hdlAllUsed( CG_NAMES ); @@ -1297,7 +1297,7 @@ void _CGAPI CGTrash( cg_name name ) void _CGAPI CGDone( cg_name name ) /************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "CGDone( %n )\n", name ); hdlUseOnce( CG_NAMES, name ); hdlAllUsed( CG_NAMES ); @@ -1309,7 +1309,7 @@ void _CGAPI CGDone( cg_name name ) cg_type _CGAPI CGType( cg_name name ) /***********************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD cg_type retn; EchoAPI( "CGType( %n )", name ); @@ -1323,7 +1323,7 @@ cg_type _CGAPI CGType( cg_name name ) cg_name _CGAPI CGBitMask( cg_name left, byte start, byte len, cg_type tipe ) /**************************************************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD cg_name retn; EchoAPI( "CGBitMask( %n, %x, %x, %t )", left, start, len, tipe ); @@ -1339,7 +1339,7 @@ cg_name _CGAPI CGBitMask( cg_name left, byte start, byte len, cg_type tipe ) cg_name _CGAPI CGVolatile( cg_name name ) /***************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD cg_name retn; EchoAPI( "CGVolatile( %n )", name ); @@ -1355,7 +1355,7 @@ cg_name _CGAPI CGVolatile( cg_name name ) cg_name _CGAPI CGAttr( cg_name name, cg_sym_attr attr ) /*****************************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD cg_name retn; EchoAPI( "CGAttr( %n, %i )", name, attr ); @@ -1372,7 +1372,7 @@ cg_name _CGAPI CGAttr( cg_name name, cg_sym_attr attr ) cg_name _CGAPI CGAlign( cg_name name, uint alignment ) /****************************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD cg_name retn; EchoAPI( "CGAlign( %n, %i )", name, alignment ); @@ -1392,7 +1392,7 @@ cg_name * _CGAPI CGDuplicate( cg_name name ) /******************************************/ { an addr; -#ifndef NDEBUG +#ifdef DEVBUILD cg_name *retn; EchoAPI( "CGDuplicate( %n )", name ); @@ -1403,7 +1403,7 @@ cg_name * _CGAPI CGDuplicate( cg_name name ) CGDuplicateArray[0] = TGReLeaf( BGCopy( addr ) ); CGDuplicateArray[1] = TGReLeaf( addr ); -#ifndef NDEBUG +#ifdef DEVBUILD retn = CGDuplicateArray; EchoAPI( " -> %n %n\n", retn[0], retn[1] ); hdlAdd( CG_NAMES, retn[0] ); @@ -1423,7 +1423,7 @@ cg_name * _CGAPI CGDuplicate( cg_name name ) void _CGAPI DGLabel( back_handle bck ) /****************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "DGLabel( %B )\n", bck ); #endif if( !IS_REAL_BACK( bck ) ) @@ -1437,7 +1437,7 @@ void _CGAPI DGBackPtr( back_handle bck, segment_id segid, signed_32 offset, cg_type tipe ) /***********************************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "DGBackPtr( %B, %S, %i, %t )\n", bck, segid, offset, tipe ); #endif if( !IS_REAL_BACK( bck ) ) @@ -1449,7 +1449,7 @@ void _CGAPI DGBackPtr( back_handle bck, segment_id segid, void _CGAPI DGFEPtr( cg_sym_handle sym, cg_type tipe, signed_32 offset ) /**********************************************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "DGFEPtr( %S, %t, %i )\n", sym, tipe, offset ); #endif DGBlip(); @@ -1459,7 +1459,7 @@ void _CGAPI DGFEPtr( cg_sym_handle sym, cg_type tipe, signed_32 offset ) void _CGAPI DGBytes( unsigned_32 len, const void *src ) /*********************************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "DGBytes( %x, %x )\n", len, src ); #endif DGBlip(); @@ -1474,7 +1474,7 @@ void _CGAPI DGInteger( unsigned_32 value, cg_type tipe ) byte buff[6]; byte *form; -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "DGInteger( %i, %t )\n", value, tipe ); #endif len = TypeLength( tipe ); @@ -1524,7 +1524,7 @@ void _CGAPI DGInteger64( unsigned_64 value, cg_type tipe ) } } #endif -#ifndef NDEBUG +#ifdef DEVBUILD // fix this up when we get printf support for int64 EchoAPI( "DGInteger64( %x %x, %t )\n" , data.val.u._32[0] @@ -1542,7 +1542,7 @@ void _CGAPI DGFloat( cchar_ptr value, cg_type tipe ) float_handle cf; flt buff; -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "DGFloat( %c, %t )\n", value, tipe ); #endif cf = CFCnvSF( value ); @@ -1554,7 +1554,7 @@ void _CGAPI DGFloat( cchar_ptr value, cg_type tipe ) void _CGAPI DGIBytes( unsigned_32 len, byte pat ) /***************************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "DGIBytes( %x, %x )\n", len, pat ); #endif DGBlip(); @@ -1564,7 +1564,7 @@ void _CGAPI DGIBytes( unsigned_32 len, byte pat ) void _CGAPI DGChar( char value ) /**********************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "DGChar( %x )\n", value ); #endif DGIBytes( 1, value ); @@ -1573,7 +1573,7 @@ void _CGAPI DGChar( char value ) void _CGAPI DGString( cchar_ptr value, uint len ) /***********************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD char data[40]; unsigned slen = len; char *d = data; @@ -1625,7 +1625,7 @@ void _CGAPI DGString( cchar_ptr value, uint len ) void _CGAPI DGUBytes( unsigned_32 len ) /*****************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "DGUBytes( %x )\n", len ); #endif DGBlip(); @@ -1635,7 +1635,7 @@ void _CGAPI DGUBytes( unsigned_32 len ) void _CGAPI DGAlign( uint align ) /***********************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "DGAlign( %i )\n", align ); #endif DGBlip(); @@ -1648,7 +1648,7 @@ unsigned_32 _CGAPI DGSeek( unsigned_32 where ) { uint old; -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "DGSeek( %x )", where ); #endif @@ -1656,7 +1656,7 @@ unsigned_32 _CGAPI DGSeek( unsigned_32 where ) old = AskLocation(); SetLocation( where ); -#ifndef NDEBUG +#ifdef DEVBUILD return( EchoAPIHexReturn( old ) ); #else return( old ); @@ -1666,7 +1666,7 @@ unsigned_32 _CGAPI DGSeek( unsigned_32 where ) unsigned_32 _CGAPI DGTell( void ) /************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD unsigned_32 retn; EchoAPI( "DGTell()" ); @@ -1681,7 +1681,7 @@ unsigned_32 _CGAPI DGTell( void ) unsigned_32 _CGAPI DGBackTell( back_handle bck ) /***************************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD unsigned_32 retn; EchoAPI( "DGBackTell( %B )", bck ); #endif @@ -1689,7 +1689,7 @@ unsigned_32 _CGAPI DGBackTell( back_handle bck ) if( !IS_REAL_BACK( bck ) ) _Zoiks( ZOIKS_068 ); -#ifndef NDEBUG +#ifdef DEVBUILD retn = AskAddress( bck->lbl ); return EchoAPIIntReturn( retn ); #else @@ -1709,7 +1709,7 @@ void _CGAPI DGCFloat( pointer cf, cg_type tipe ) { flt buff; -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPI( "DGCFloat( %x, %t )\n", cf, tipe ); #endif CFCnvTarget( cf, &buff, TypeLength( tipe ) ); diff --git a/bld/cg/c/optask.c b/bld/cg/c/optask.c index 55314d015b..8e73219371 100644 --- a/bld/cg/c/optask.c +++ b/bld/cg/c/optask.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -60,7 +60,7 @@ static label_handle DoAskForLabel( cg_sym_handle sym ) new->ppc_alt_name = NULL; new->owl_symbol = NULL; #endif -#ifndef NDEBUG +#ifdef DEVBUILD new->useinfo.hdltype = NO_HANDLE; new->useinfo.used = false; #endif diff --git a/bld/cg/c/patch.c b/bld/cg/c/patch.c index 88d6de186a..5a8a6be234 100644 --- a/bld/cg/c/patch.c +++ b/bld/cg/c/patch.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2018 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -53,7 +53,7 @@ patch_handle BGNewPatch( void ) patch = CGAlloc( sizeof( patch_info ) ); patch->in_tree = false; patch->patched = false; -#ifndef NDEBUG +#ifdef DEVBUILD patch->useinfo.hdltype = NO_HANDLE; patch->useinfo.used = false; #endif diff --git a/bld/cg/c/regtree.c b/bld/cg/c/regtree.c index 2717d3a13b..b4f278a3ff 100644 --- a/bld/cg/c/regtree.c +++ b/bld/cg/c/regtree.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -176,7 +176,7 @@ static void BuildPossible( reg_tree *tree ) *dst++ = *src; } *dst = *src; -#ifndef NDEBUG +#ifdef DEVBUILD if( dst - tree->regs >= REG_COUNT ) { /* '>=' 'coz no increment before 'break' */ Zoiks( ZOIKS_143 ); } diff --git a/bld/cg/c/split.c b/bld/cg/c/split.c index 7a65d08761..06f334b29f 100644 --- a/bld/cg/c/split.c +++ b/bld/cg/c/split.c @@ -443,7 +443,7 @@ instruction *rFIXSHIFT( instruction *ins ) /*********************************************/ { instruction *new_ins; -#ifndef NDEBUG +#ifdef DEVBUILD signed_32 shift_count; #endif @@ -452,7 +452,7 @@ instruction *rFIXSHIFT( instruction *ins ) * rights shifts must never exceed (REGISTER_BITS - 1), logical shifts can * be replaced with loads of zero constant. */ -#ifndef NDEBUG +#ifdef DEVBUILD assert( ins->operands[1]->n.class == N_CONSTANT ); shift_count = ins->operands[1]->c.lo.int_value; assert( shift_count >= REG_SIZE * 8 ); diff --git a/bld/cg/c/tree.c b/bld/cg/c/tree.c index 715802cc49..e25e962646 100644 --- a/bld/cg/c/tree.c +++ b/bld/cg/c/tree.c @@ -70,7 +70,7 @@ #if _TARGET_INTEL #include "x86segs.h" #endif -#ifndef NDEBUG +#ifdef DEVBUILD #include "echoapi.h" #endif @@ -132,7 +132,7 @@ static tn NewTreeNode( void ) new = AllocFrl( &TreeFrl, sizeof( tree_node ) ); new->flags = TF_USED; -#ifndef NDEBUG +#ifdef DEVBUILD new->useinfo.hdltype = NO_HANDLE; new->useinfo.used = false; #endif @@ -1617,11 +1617,11 @@ static an TNCallback( tn node ) rtn = node->u.left->u.callback; parm = (callback_handle)node->u2.t.rite->u.handle; if( rtn != NULL ) { -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPICallBack( node, rtn, parm, "started\n\n" ); #endif rtn( parm ); -#ifndef NDEBUG +#ifdef DEVBUILD EchoAPICallBack( node, rtn, parm, "ended\n\n" ); #endif } diff --git a/bld/cg/h/echoapi.h b/bld/cg/h/echoapi.h index abeb2d9c8f..5d21fa0cd4 100644 --- a/bld/cg/h/echoapi.h +++ b/bld/cg/h/echoapi.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -32,7 +33,7 @@ #ifndef __ECHOAPI__H__ #define __ECHOAPI__H__ -#ifndef NDEBUG +#ifdef DEVBUILD #include "seldef.h" #include "tree.h" @@ -66,6 +67,6 @@ void handleExists( handle_type hdltype, use_info *useinfo ); #define hdlAdd( type, handle ) ( handleAdd( type, (use_info *)handle ) ) #define hdlExists( type, handle ) ( handleExists( type, (use_info *)handle ) ) -#endif // NDEBUG +#endif // DEVBUILD #endif // __ECHOAPI__H__ diff --git a/bld/cg/h/optlbl.h b/bld/cg/h/optlbl.h index dc12f9275a..24fbb6b210 100644 --- a/bld/cg/h/optlbl.h +++ b/bld/cg/h/optlbl.h @@ -33,7 +33,7 @@ #include "optopts.h" #include "offset.h" #include "rtclass.h" -#ifndef NDEBUG +#ifdef DEVBUILD #include "useinfo.h" #endif @@ -71,7 +71,7 @@ typedef struct label_def { } label_def; typedef struct code_lbl { -#ifndef NDEBUG +#ifdef DEVBUILD use_info useinfo; #endif struct label_def lbl; diff --git a/bld/cg/h/patch.h b/bld/cg/h/patch.h index dde0e6937b..351edeae38 100644 --- a/bld/cg/h/patch.h +++ b/bld/cg/h/patch.h @@ -44,7 +44,7 @@ extern void DeadBeef(); #endif typedef struct patch_info { -#ifndef NDEBUG +#ifdef DEVBUILD use_info useinfo; #endif union { diff --git a/bld/cg/h/seldef.h b/bld/cg/h/seldef.h index 46535dc591..d37eda26b0 100644 --- a/bld/cg/h/seldef.h +++ b/bld/cg/h/seldef.h @@ -45,7 +45,7 @@ typedef struct select_list { } select_list; typedef struct select_node { -#ifndef NDEBUG +#ifdef DEVBUILD use_info useinfo; #endif struct select_list *list; diff --git a/bld/cg/h/tree.h b/bld/cg/h/tree.h index 9c51fe47dd..e35e5fa7a2 100644 --- a/bld/cg/h/tree.h +++ b/bld/cg/h/tree.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -76,7 +77,7 @@ typedef enum { } tn_class; typedef struct tree_node { -#ifndef NDEBUG +#ifdef DEVBUILD use_info useinfo; #endif struct type_def *tipe; diff --git a/bld/cg/risc/axp/c/axpenc.c b/bld/cg/risc/axp/c/axpenc.c index efed10180c..0e8b73811f 100644 --- a/bld/cg/risc/axp/c/axpenc.c +++ b/bld/cg/risc/axp/c/axpenc.c @@ -951,7 +951,7 @@ static void Encode( instruction *ins ) _Zoiks( ZOIKS_028 ); break; } -#ifndef NDEBUG +#ifdef DEVBUILD if( _IsTargetModel( CGSW_RISC_ASM_OUTPUT ) ) { DumpLiteral( " " ); DumpGen( ins->u.gen_table ); @@ -975,7 +975,7 @@ void GenJumpIf( instruction *ins, pointer label ) { GenBRANCH( BranchOpcodes[ins->head.opcode - FIRST_COMPARISON][_IsFloating( ins->type_class )], _NameReg( ins->operands[0] ), label ); -#ifndef NDEBUG +#ifdef DEVBUILD if( _IsTargetModel( CGSW_RISC_ASM_OUTPUT ) ) { DumpLiteral( "Jcc L" ); DumpPtr( label ); diff --git a/bld/cg/risc/c/rscobj.c b/bld/cg/risc/c/rscobj.c index f5c82a93a1..cbd1387a0e 100644 --- a/bld/cg/risc/c/rscobj.c +++ b/bld/cg/risc/c/rscobj.c @@ -369,7 +369,7 @@ void ObjFini( void ) static int PutBytes( owl_client_file f, const char *buffer, size_t len ) /***********************************************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD // enable OWL logging if( f == NULL ) { PutObjBytes( buffer, len ); diff --git a/bld/cg/risc/mps/c/mpsenc.c b/bld/cg/risc/mps/c/mpsenc.c index d2d01462e9..064f6b504a 100644 --- a/bld/cg/risc/mps/c/mpsenc.c +++ b/bld/cg/risc/mps/c/mpsenc.c @@ -1151,7 +1151,7 @@ static void Encode( instruction *ins ) _Zoiks( ZOIKS_028 ); break; } -#ifndef NDEBUG +#ifdef DEVBUILD if( _IsTargetModel( CGSW_RISC_ASM_OUTPUT ) ) { DumpLiteral( " " ); DumpGen( ins->u.gen_table ); diff --git a/bld/cg/risc/ppc/c/ppcenc.c b/bld/cg/risc/ppc/c/ppcenc.c index dc821327d8..2b2e9b62ef 100644 --- a/bld/cg/risc/ppc/c/ppcenc.c +++ b/bld/cg/risc/ppc/c/ppcenc.c @@ -823,7 +823,7 @@ static void Encode( instruction *ins ) _Zoiks( ZOIKS_028 ); break; } -#ifndef NDEBUG +#ifdef DEVBUILD if( _IsTargetModel( CGSW_RISC_ASM_OUTPUT ) ) { DumpLiteral( " " ); DumpGen( ins->u.gen_table ); @@ -859,7 +859,7 @@ void CodeLabel( label_handle label, unsigned alignment ) ObjBytes( Zeros, alignment - modulus ); } OutLabel( label ); -#ifndef NDEBUG +#ifdef DEVBUILD if( _IsTargetModel( CGSW_RISC_ASM_OUTPUT ) ) { DumpChar( 'L' ); DumpPtr( label ); @@ -873,7 +873,7 @@ void CodeLabel( label_handle label, unsigned alignment ) void CodeLineNumber( cg_linenum line, bool label ) /***************************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD if( _IsTargetModel( CGSW_RISC_ASM_OUTPUT ) ) { DumpLiteral( "Source Line: " ); DumpInt( line ); @@ -888,7 +888,7 @@ void GenJumpLabel( label_handle label ) /****************************************/ { GenBRANCH( 18, label, false, false ); -#ifndef NDEBUG +#ifdef DEVBUILD if( _IsTargetModel( CGSW_RISC_ASM_OUTPUT ) ) { DumpLiteral( "JMP L" ); DumpPtr( label ); @@ -904,7 +904,7 @@ static void GenJumpIf( instruction *ins, pointer label ) ops = &BranchOpcodes[ins->head.opcode - FIRST_COMPARISON][0]; // fixme - floating point GenCONDBR( 16, ops[0], ops[1], label ); -#ifndef NDEBUG +#ifdef DEVBUILD if( _IsTargetModel( CGSW_RISC_ASM_OUTPUT ) ) { DumpLiteral( "Jcc L" ); DumpPtr( label ); diff --git a/bld/dwarf/dw/c/dwhandle.c b/bld/dwarf/dw/c/dwhandle.c index 557108ee84..2bd64d7c98 100644 --- a/bld/dwarf/dw/c/dwhandle.c +++ b/bld/dwarf/dw/c/dwhandle.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -55,7 +55,7 @@ struct handle_blk { handle_blk *next[1]; }; -#ifndef NDEBUG +#ifdef DEVBUILD static struct { unsigned dump_handle : 1; diff --git a/bld/dwarf/dw/c/dwloc.c b/bld/dwarf/dw/c/dwloc.c index 2a0b2db785..48f86e2f39 100644 --- a/bld/dwarf/dw/c/dwloc.c +++ b/bld/dwarf/dw/c/dwloc.c @@ -268,7 +268,7 @@ void DWENTRY DWLocConstU( dw_client cli, dw_loc_id loc, dw_uconst value ) } else if( value < ( 1UL << 21 ) ) { /* will only take 3 bytes to encode in ULEB128 form */ end = WriteULEB128( buf, value ); -#ifndef NDEBUG +#ifdef DEVBUILD _Assert( end - buf == 3 ); #endif op = nextOp( cli, loc, DW_OP_constu, 3 ); diff --git a/bld/dwarf/dw/h/dwassert.h b/bld/dwarf/dw/h/dwassert.h index 6ef23d0326..e09ee2a82e 100644 --- a/bld/dwarf/dw/h/dwassert.h +++ b/bld/dwarf/dw/h/dwassert.h @@ -41,13 +41,13 @@ exported functions have proper values. */ #define _Validate(__e) _Assert(__e) -#ifdef NDEBUG -#define _Assert(__ignore) ((void)0) -#else +#ifdef DEVBUILD /* Note: Old code used to call __assert() directly - not such a good idea since that is an undocumented function. */ #define _Assert assert +#else +#define _Assert(__ignore) ((void)0) #endif #endif diff --git a/bld/fe_misc/c/carve.c b/bld/fe_misc/c/carve.c index 0400e124cb..65f0d2cb4e 100644 --- a/bld/fe_misc/c/carve.c +++ b/bld/fe_misc/c/carve.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -84,7 +84,7 @@ struct free_t { (fl) = node; \ } -#ifndef NDEBUG +#ifdef DEVBUILD static bool restoreFromZapped( cv_t *cv ) { unsigned elm_size; @@ -236,7 +236,7 @@ void *CarveZeroAlloc( carve_t cv ) #endif -#ifndef NDEBUG +#ifdef DEVBUILD #define TOO_MANY_TO_WALK 512 static blk_t *withinABlock( carve_t cv, void *elm ) @@ -332,7 +332,7 @@ void CarveFree( carve_t cv, void *elm ) _ADD_TO_FREE( cv->free_list, elm ); } -#ifndef NDEBUG +#ifdef DEVBUILD void CarveVerifyAllGone( carve_t cv, char const *node_name ) /**********************************************************/ { @@ -507,13 +507,13 @@ void CarveWalkAllFree( carve_t cv, void (*rtn)( void * ) ) restoreFromZapped( cv ); check = cv->free_list; -#ifndef NDEBUG +#ifdef DEVBUILD // transfer over to another list since these free blocks may be modified cv->free_list = NULL; cv->zapped_free_list = check; #endif for( ; check != NULL; check = check->next_free ) { -#ifndef NDEBUG +#ifdef DEVBUILD free_t *check_next = check->next_free; (*rtn)( check ); if( check->next_free != check_next ) { @@ -527,7 +527,7 @@ void CarveWalkAllFree( carve_t cv, void (*rtn)( void * ) ) } } -#ifndef NDEBUG +#ifdef DEVBUILD void CarveVerifyFreeElement( carve_t cv, void *elm ) /**************************************************/ { @@ -589,7 +589,7 @@ void CarveMapOptimize( carve_t cv, cv_index last_valid_index ) nmaps = GET_BLOCK( last_valid_index ); init = _MemoryAllocate( nmaps * sizeof( blk_t * ) ); cv->blk_map = init; -#ifndef NDEBUG +#ifdef DEVBUILD if( nmaps != cv->blk_count ) { _FatalAbort( "incorrect block calculation" ); } @@ -666,7 +666,8 @@ void CarveInitStart( carve_t cv, cvinit_t *data ) } -#if 0 && ! defined(NDEBUG) +#if 0 +#ifdef DEVBUILD carve_t carveMASTER; carve_t carveSLAVE1; carve_t carveSLAVE2; @@ -966,6 +967,7 @@ pch_status PCHFiniTest( bool writing ) } return( PCHCB_OK ); } -#endif // NDEBUG +#endif // DEVBUILD +#endif #endif // CARVEPCH diff --git a/bld/fe_misc/c/pstk.c b/bld/fe_misc/c/pstk.c index d837cd2b1d..6668253786 100644 --- a/bld/fe_misc/c/pstk.c +++ b/bld/fe_misc/c/pstk.c @@ -37,7 +37,7 @@ #include "initdefs.h" #include "pstk.h" -#ifndef NDEBUG +#ifdef DEVBUILD #define PSTK_BLOCK_SIZE (4-1) // stress the code #else #define PSTK_BLOCK_SIZE (64-1) // so each block is 64 pointers @@ -234,7 +234,7 @@ static void pstkFini( INITFINI* defn ) { /* unused parameters */ (void)defn; -#ifndef NDEBUG +#ifdef DEVBUILD CarveVerifyAllGone( carvePSTK_BLK, "PSTK_BLK" ); #endif CarveDestroy( carvePSTK_BLK ); diff --git a/bld/fe_misc/c/ringfns.c b/bld/fe_misc/c/ringfns.c index b1cb7c0f33..1183db0a8e 100644 --- a/bld/fe_misc/c/ringfns.c +++ b/bld/fe_misc/c/ringfns.c @@ -40,7 +40,7 @@ struct ring // model of a ring { RING *next; // - points to next }; -#ifndef NDEBUG +#ifdef DEVBUILD static void verifyNotInRing( RING *ring, RING *elt ) { RING *curr; @@ -151,7 +151,7 @@ void RingInsert( // INSERT ELEMENT INTO RING } -#ifndef NDEBUG +#ifdef DEVBUILD void RingWalk( // TRAVERSE RING void *hdr, // - ring header void (*rtn) // - traversal routine diff --git a/bld/fe_misc/c/vstk.c b/bld/fe_misc/c/vstk.c index f063fe8146..a60e26857c 100644 --- a/bld/fe_misc/c/vstk.c +++ b/bld/fe_misc/c/vstk.c @@ -97,7 +97,7 @@ static void *vstkPushBlk( // PUSH THE BLOCK return( cur ); } -#ifndef NDEBUG +#ifdef DEVBUILD static void _VstkIntegrity( VSTK_CTL const *stack ) { if( stack->current != NULL ) { @@ -285,7 +285,7 @@ unsigned VstkDimension( // GET UPPER DIMENSION OF VIRTUAL STACK if( blk != NULL ) { dimension -= ( (char*)stack->current - blk->data ) / stack->size; per_block = stack->per_block; -#ifndef NDEBUG +#ifdef DEVBUILD if( dimension + per_block > per_block ) { _FatalAbort( "vstk: dimension > per_block" ); } diff --git a/bld/fe_misc/c/xtrarpt.c b/bld/fe_misc/c/xtrarpt.c index 58b51e930c..99ccf5b8f1 100644 --- a/bld/fe_misc/c/xtrarpt.c +++ b/bld/fe_misc/c/xtrarpt.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -35,12 +35,12 @@ #include #include -#ifndef NDEBUG +#ifdef DEVBUILD #define XRPT #endif #ifdef XRPT -#undef NDEBUG +//#undef NDEBUG #include header #include "carve.h" diff --git a/bld/fe_misc/h/carve.h b/bld/fe_misc/h/carve.h index b3beebce2b..28db4dd88c 100644 --- a/bld/fe_misc/h/carve.h +++ b/bld/fe_misc/h/carve.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -57,7 +58,7 @@ typedef struct { unsigned elm_count; unsigned blk_top; unsigned blk_count; -#ifndef NDEBUG +#ifdef DEVBUILD free_t *zapped_free_list; #endif } cv_t, *carve_t; @@ -73,7 +74,7 @@ extern void CarveDestroy( carve_t cv ); extern void *CarveAlloc( carve_t cv ); extern void CarveFree( carve_t cv, void *elm ); -#ifndef NDEBUG +#ifdef DEVBUILD extern void CarveVerifyFreeElement( carve_t cv, void *elm ); extern void CarveVerifyAllGone( carve_t cv, char const * ); #else diff --git a/bld/fe_misc/h/dbgzap.h b/bld/fe_misc/h/dbgzap.h index e8e6730141..4086b2f0ab 100644 --- a/bld/fe_misc/h/dbgzap.h +++ b/bld/fe_misc/h/dbgzap.h @@ -36,7 +36,7 @@ #ifndef __DBGZAP_H__ #define __DBGZAP_H__ -#ifndef NDEBUG +#ifdef DEVBUILD // PROTOTYPES diff --git a/bld/fe_misc/h/ringfns.h b/bld/fe_misc/h/ringfns.h index 8816bc927c..933caee4e7 100644 --- a/bld/fe_misc/h/ringfns.h +++ b/bld/fe_misc/h/ringfns.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -104,7 +105,7 @@ void *RingConcatAppend( // APPEND A RING void *hdr, // - ring header void *hdr2 ) // - second ring header ; -#ifndef NDEBUG +#ifdef DEVBUILD void RingWalk( // TRAVERSE RING void *hdr, // - ring header void (*rtn) // - traversal routine diff --git a/bld/fpuemu/386/asm/emu387.asm b/bld/fpuemu/386/asm/emu387.asm index 69c2ab83fd..6496849898 100644 --- a/bld/fpuemu/386/asm/emu387.asm +++ b/bld/fpuemu/386/asm/emu387.asm @@ -59,7 +59,7 @@ modstart macro modname endm xdefp macro xsym - ifndef NDEBUG + ifdef DEVBUILD public xsym endif endm diff --git a/bld/fpuemu/386/inc/386fpemu.inc b/bld/fpuemu/386/inc/386fpemu.inc index fe48461e33..0bf30eb875 100644 --- a/bld/fpuemu/386/inc/386fpemu.inc +++ b/bld/fpuemu/386/inc/386fpemu.inc @@ -29,7 +29,7 @@ ;***************************************************************************** -ifndef NDEBUG +ifdef DEVBUILD if _OS eq _NW extrn puts_ : near NC = 0 @@ -42,7 +42,7 @@ ifndef __WIN387__ extrn "C",__FPE_exception : proc endif -ifndef NDEBUG +ifdef DEVBUILD public badop,prtnyi,my87,mrm,sib,memop,stkop,stkop1 endif @@ -72,7 +72,7 @@ endif ifdef __WIN387__ precrtn dd p_extended ; address of precision rtn endif -ifndef NDEBUG +ifdef DEVBUILD nyimsg db ": not yet implemented",0dH,0aH,NC illopmsg db "Illegal instruction encountered by 8087 emulator",0dH,0aH,NC endif @@ -1071,7 +1071,7 @@ dosib: mov bl,[esi] ; get sib byte in bl ssiiibbb xrefp __f2xm1 xrefp __frndint ; 24-mar-90 -ifndef NDEBUG +ifdef DEVBUILD badop proc near if _OS eq _PLDT mov edx,offset illopmsg @@ -1086,12 +1086,12 @@ badop endp endif illop macro -ifndef NDEBUG +ifdef DEVBUILD call badop endif endm -ifndef NDEBUG +ifdef DEVBUILD prtnyi proc near if _OS eq _PLDT mov ah,9H diff --git a/bld/fpuemu/i86/asm/emu8087.asm b/bld/fpuemu/i86/asm/emu8087.asm index 35224ac6f5..faffe6f6ed 100644 --- a/bld/fpuemu/i86/asm/emu8087.asm +++ b/bld/fpuemu/i86/asm/emu8087.asm @@ -2,6 +2,7 @@ ;* ;* Open Watcom Project ;* +;* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. ;* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. ;* ;* ======================================================================== @@ -45,7 +46,7 @@ modstart macro modname endm xdefp macro xsym -ifndef NDEBUG +ifdef DEVBUILD public xsym endif endm diff --git a/bld/fpuemu/i86/asm/fpe86.asm b/bld/fpuemu/i86/asm/fpe86.asm index 649f163d5c..ccd941aa92 100644 --- a/bld/fpuemu/i86/asm/fpe86.asm +++ b/bld/fpuemu/i86/asm/fpe86.asm @@ -15,7 +15,7 @@ modstart macro modname endm xdefp macro xsym -ifndef NDEBUG +ifdef DEVBUILD public xsym endif endm diff --git a/bld/fpuemu/i86/inc/fpe86.inc b/bld/fpuemu/i86/inc/fpe86.inc index 2c80509589..e525714559 100644 --- a/bld/fpuemu/i86/inc/fpe86.inc +++ b/bld/fpuemu/i86/inc/fpe86.inc @@ -15,7 +15,7 @@ _OS2 = 2 NC = '$' -ifndef NDEBUG +ifdef DEVBUILD public badop,prtnyi,my87,modrm,memop,stkop,stkop1 endif @@ -41,7 +41,7 @@ _DATA segment word public 'DATA' ifndef __QNX__ my87 sarea <> endif -ifndef NDEBUG +ifdef DEVBUILD nyimsg db ": not yet implemented",0dH,0aH,NC illopmsg db "Illegal instruction encountered by 8087 emulator",0dH,0aH,NC endif @@ -868,7 +868,7 @@ stkop: dw s00,s01,s02,s03,s04,s05,s06,s07 ; stack operand xrefp __fxam xrefp __frndint -ifndef NDEBUG +ifdef DEVBUILD badop proc near lea dx,illopmsg mov ah,9H @@ -878,12 +878,12 @@ badop endp endif illop macro -ifndef NDEBUG +ifdef DEVBUILD call badop endif endm -ifndef NDEBUG +ifdef DEVBUILD prtnyi proc near mov ah,9H int 21H diff --git a/bld/nwlib/c/cmdline.c b/bld/nwlib/c/cmdline.c index 9ed2309010..f7d88b9566 100644 --- a/bld/nwlib/c/cmdline.c +++ b/bld/nwlib/c/cmdline.c @@ -276,7 +276,7 @@ static const char *ParseOption( const char *c, char *token_buff ) break; case 'x': // (explode all objects in library) Options.explode = true; -#ifndef NDEBUG +#ifdef DEVBUILD Options.explode_count = 0; if( my_tolower( *c ) == 'n' ) { Options.explode_count = 1; diff --git a/bld/nwlib/c/ideentry.c b/bld/nwlib/c/ideentry.c index 05d604f51e..465252509b 100644 --- a/bld/nwlib/c/ideentry.c +++ b/bld/nwlib/c/ideentry.c @@ -255,7 +255,7 @@ void Banner( void ) if( !Options.quiet && !Options.terse_listing && IdeCbs != NULL ) { ConsolePuts( banner1t( "Library Manager" ) -#ifndef NDEBUG +#ifdef DEVBUILD " [Internal Development]" #endif "\n" diff --git a/bld/nwlib/c/symtable.c b/bld/nwlib/c/symtable.c index 8c02b184d9..0277b15d3c 100644 --- a/bld/nwlib/c/symtable.c +++ b/bld/nwlib/c/symtable.c @@ -790,7 +790,7 @@ void AddSym( const char *name, symbol_strength strength, unsigned char info ) HashTable[hash] = sym; } -#ifndef NDEBUG +#ifdef DEVBUILD void DumpFileTable( void ) { sym_file *sfile; @@ -852,7 +852,7 @@ void DumpHashTable( void ) } printf( "----------------------------------------------------------\n" ); } -#endif // !NDEBUG +#endif // DEVBUILD bool RemoveObjectSymbols( const char *name ) diff --git a/bld/nwlib/h/filetab.h b/bld/nwlib/h/filetab.h index 601527730d..efcaf83ebf 100644 --- a/bld/nwlib/h/filetab.h +++ b/bld/nwlib/h/filetab.h @@ -126,7 +126,7 @@ extern void WriteFileTable( void ); extern void WriteFileBody( sym_file *sfile ); extern void AddSym( const char *name, symbol_strength strength, unsigned char info ); -#ifndef NDEBUG +#ifdef DEVBUILD extern void DumpFileTable( void ); extern void DumpHashTable( void ); #endif diff --git a/bld/owl/c/owbuffer.c b/bld/owl/c/owbuffer.c index 4fa63f3e77..6c5783630f 100644 --- a/bld/owl/c/owbuffer.c +++ b/bld/owl/c/owbuffer.c @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -32,7 +33,7 @@ #include "owlpriv.h" -#ifndef NDEBUG +#ifdef DEVBUILD #define NUM_BINS (16) #define INITIAL_BIN_SIZE ((8*1024)/16) #else diff --git a/bld/owl/c/owemit.c b/bld/owl/c/owemit.c index 959902614c..eded504c58 100644 --- a/bld/owl/c/owemit.c +++ b/bld/owl/c/owemit.c @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -46,7 +47,7 @@ void OWLENTRY OWLEmitLabel( owl_section_handle section, owl_symbol_handle symbol void OWLENTRY OWLWeakExt( owl_file_handle file, owl_symbol_handle wk_sym, owl_symbol_handle alt_sym, owl_wksym_flags flags ) { //**************************************************************************************************************************** -#ifdef NDEBUG +#ifndef DEVBUILD /* unused parameters */ (void)file; #endif _Log(( file, "OWLWeakExt( %x, %x, %x, %x )\n", file, wk_sym, alt_sym, flags )); diff --git a/bld/owl/h/log.h b/bld/owl/h/log.h index ef814b830d..3d979f2ebd 100644 --- a/bld/owl/h/log.h +++ b/bld/owl/h/log.h @@ -30,7 +30,7 @@ ****************************************************************************/ -#ifndef NDEBUG +#ifdef DEVBUILD extern void OWLENTRY OWLLog( owl_file_handle file, char *str,... ); #define _Log( x ) OWLLog x #else diff --git a/bld/plusplus/c/analcast.c b/bld/plusplus/c/analcast.c index 36cda41fd3..020afa65a4 100644 --- a/bld/plusplus/c/analcast.c +++ b/bld/plusplus/c/analcast.c @@ -610,7 +610,7 @@ static void setConversionNode // SET CONVERSION TYPE INTO PTREE NODE static PTREE doReintMPtrToMPtr // DO A RE-INTERPRET MEMB-PTR CONVERSION ( CONVCTL* ctl ) // - conversion control { -#ifndef NDEBUG +#ifdef DEVBUILD CNV_RETN retn; retn = MembPtrReint( &ctl->expr->u.subtree[1], ctl->tgt.orig ); @@ -2786,7 +2786,7 @@ PTREE AddCastNode // ADD A CAST NODE } -#ifndef NDEBUG +#ifdef DEVBUILD int infinite_ctr; #define INFINITY 10 #endif diff --git a/bld/plusplus/c/anallval.c b/bld/plusplus/c/anallval.c index a0823e8ad1..d6c52a3720 100644 --- a/bld/plusplus/c/anallval.c +++ b/bld/plusplus/c/anallval.c @@ -42,7 +42,7 @@ #define isUDF( node ) ( node->cgop == CO_NAME_CONVERT ) -#ifndef NDEBUG +#ifdef DEVBUILD extern void DumpPTree( PTREE ); #endif @@ -668,12 +668,12 @@ static bool analyseMembRight( // ANALYSE MEMBER ON RIGHT } else if( NodeIsBinaryOp( right, CO_TEMPLATE ) && ( right->u.subtree[0]->op == PT_SYMBOL ) ) { // TODO -#ifndef NDEBUG +#ifdef DEVBUILD printf("%s:%d\n", __FILE__, __LINE__); DumpPTree( right ); #endif ok = analyseMemberExpr( a_expr ); -#ifndef NDEBUG +#ifdef DEVBUILD } else { CFatal( "corrupted member tree" ); #endif diff --git a/bld/plusplus/c/analnode.c b/bld/plusplus/c/analnode.c index a3d0a2dfca..49b443b835 100644 --- a/bld/plusplus/c/analnode.c +++ b/bld/plusplus/c/analnode.c @@ -57,7 +57,7 @@ static PTREE set_meaningful_side_effects( // SET MEANINGFUL, SIDE_EFFECTS } -#ifndef NDEBUG +#ifdef DEVBUILD bool NodeIsUnaryOp( // TEST IF UNARY OPERATION OF GIVEN TYPE PTREE node, // - node CGOP operation ) // - operation diff --git a/bld/plusplus/c/analtype.c b/bld/plusplus/c/analtype.c index 7f4d3430f2..8363c6acdf 100644 --- a/bld/plusplus/c/analtype.c +++ b/bld/plusplus/c/analtype.c @@ -698,7 +698,7 @@ bool ExprIsLvalue // TEST IF EXPRESSION IS LVALUE if( expr->flags & PTF_LVALUE ) { ok = true; } else { -#ifndef NDEBUG +#ifdef DEVBUILD TYPE type_expr; TYPE type_lv; type_expr = NodeType( expr ); diff --git a/bld/plusplus/c/analyse.c b/bld/plusplus/c/analyse.c index a363519921..ab0307bada 100644 --- a/bld/plusplus/c/analyse.c +++ b/bld/plusplus/c/analyse.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -59,7 +59,7 @@ ANALYSE.C -- analyse parsed tree of tokens #ifdef XTRA_RPT # include "initdefs.h" #endif -#ifndef NDEBUG +#ifdef DEVBUILD #include "dbg.h" #include "pragdefn.h" #include "togglesd.h" @@ -1927,7 +1927,7 @@ static PTREE initClass( // INIT. A CLASS ( INIT OR RETURN ) } if( NodeIsBinaryOp( right, CO_LIST ) ) { // class c( parms ) TYPE orig_right; // - original type on right -#ifndef NDEBUG +#ifdef DEVBUILD if( dtor != NULL ) { CFatal( "initClass -- dtor with CO_LIST" ); } @@ -4239,7 +4239,7 @@ PTREE AnalyseOperator( // ANALYSE AN OPERATOR case CONV_BASIC_TYPE : type = TypedefModifierRemove( type ); continue; -#ifndef NDEBUG +#ifdef DEVBUILD default : CFatal( "ANALYSE -- undefined action" ); #endif @@ -4349,7 +4349,7 @@ static PTREE clearAnalysedFlag( static PTREE run_traversals( // ANALYZE EXPRESSION VIA TRAVERSALS PTREE expr ) { -#ifndef NDEBUG +#ifdef DEVBUILD expr = DbgCommaInsertion( expr ); if( TOGGLEDBG( dump_ptree ) ) { DumpCommentary( "Parse tree to be analyzed semantically" ); diff --git a/bld/plusplus/c/brinfdep.c b/bld/plusplus/c/brinfdep.c index 6d0f86e5fa..743e3e56e4 100644 --- a/bld/plusplus/c/brinfdep.c +++ b/bld/plusplus/c/brinfdep.c @@ -37,7 +37,7 @@ #include "ring.h" #include "pstk.h" #include "srcfile.h" - #ifndef NDEBUG + #ifdef DEVBUILD #include "dbg.h" #include "pragdefn.h" #endif diff --git a/bld/plusplus/c/brinfo.c b/bld/plusplus/c/brinfo.c index 00606ba919..92ed0c400a 100644 --- a/bld/plusplus/c/brinfo.c +++ b/bld/plusplus/c/brinfo.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -52,7 +52,7 @@ #else #include #endif -#ifndef NDEBUG +#ifdef DEVBUILD #include "dbg.h" #include "pragdefn.h" #endif @@ -267,7 +267,7 @@ static void recordBlkScopeIns // RECORD A BLK-SCOPE INSTRUCTION } } -#ifndef NDEBUG +#ifdef DEVBUILD void _dbgScope ( SCOPE scope , char const * text ) @@ -368,7 +368,7 @@ static void adjustSrcFile // ADJUST OPEN/CLOSE OF SOURCE FILE(S) } } -#ifndef NDEBUG +#ifdef DEVBUILD # define ShcVerify(t,m) if( !(t) ) printf( "%s\n", m ); #else # define ShcVerify(a,b) @@ -410,7 +410,7 @@ static bool activeScopesReset // RESET ACTIVE SCOPES short_circuit = false; break; } -#ifdef NDEBUG +#ifndef DEVBUILD if( ! short_circuit ) #endif { @@ -904,7 +904,7 @@ void BrinfReferenceSymbol // SYMBOL REFERENCE } } } else { - #ifndef NDEBUG + #ifdef DEVBUILD if( SymIsAutomatic( sym ) ) { ExtraRptIncrementCtr( ctr_ref_data_bare_auto ); } else { diff --git a/bld/plusplus/c/brinfsrc.c b/bld/plusplus/c/brinfsrc.c index 738ba66501..49778d7cc9 100644 --- a/bld/plusplus/c/brinfsrc.c +++ b/bld/plusplus/c/brinfsrc.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -37,7 +37,7 @@ #include "vstk.h" #include "ring.h" #include "brinfoim.h" -#ifndef NDEBUG +#ifdef DEVBUILD #include "dbg.h" #include "pragdefn.h" #endif diff --git a/bld/plusplus/c/brmwrite.c b/bld/plusplus/c/brmwrite.c index 3d1bea942d..9391917b1f 100644 --- a/bld/plusplus/c/brmwrite.c +++ b/bld/plusplus/c/brmwrite.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -49,7 +49,7 @@ #include "icopmask.h" #include "brmtypes.h" #include "b_write.h" -#ifndef NDEBUG +#ifdef DEVBUILD #include "dbg.h" #include "pragdefn.h" #endif diff --git a/bld/plusplus/c/callgrph.c b/bld/plusplus/c/callgrph.c index 56954d13e8..ce6c005fad 100644 --- a/bld/plusplus/c/callgrph.c +++ b/bld/plusplus/c/callgrph.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -35,7 +35,7 @@ #include "callgrph.h" #include "stats.h" #include "cgfront.h" -#ifndef NDEBUG +#ifdef DEVBUILD #include "dbg.h" #endif @@ -291,7 +291,7 @@ bool CgrfWalkCalls( // WALK CALLS FROM NODE IN GRAPH , (bool (*)( DIRGRAPH_CTL*, DIRGRAPH_EDGE*))walker ); } -#ifndef NDEBUG +#ifdef DEVBUILD static bool cgrfDumpCall( // DUMP CALL GRAPH EDGE CALLGRAPH *ctl, // - call graph information diff --git a/bld/plusplus/c/caux.c b/bld/plusplus/c/caux.c index 7031789039..33ad1ccd5e 100644 --- a/bld/plusplus/c/caux.c +++ b/bld/plusplus/c/caux.c @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -252,7 +253,7 @@ AUX_INFO *PragmaGetIndex( AUX_INFO *i ) if( i == NULL ) { return( (AUX_INFO *)PCH_NULL_INDEX ); } -#ifndef NDEBUG +#ifdef DEVBUILD if( i->index < PCH_FIRST_INDEX ) { CFatal( "aux info not assigned an index" ); } diff --git a/bld/plusplus/c/cdopt.c b/bld/plusplus/c/cdopt.c index 56f8049373..0acad47b7d 100644 --- a/bld/plusplus/c/cdopt.c +++ b/bld/plusplus/c/cdopt.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -43,7 +43,7 @@ #include "rtngen.h" #include "context.h" #include "stats.h" -#ifndef NDEBUG +#ifdef DEVBUILD #include "pragdefn.h" #include "dbg.h" #include "togglesd.h" @@ -206,7 +206,7 @@ ExtraRptCtr( ctr_opeq_elem ); // # opeq elements processed ExtraRptCtr( ctr_opeq_kept ); // # opeq elements kept ExtraRptCtr( ctr_caches ); // # caches -#ifndef NDEBUG +#ifdef DEVBUILD static const char *tob_names[] = { #define TOB_DEF(a) # a @@ -1469,7 +1469,7 @@ static void addInfoElement( // ADD ELEMENT TO CD_DESCR CD_DESCR* info, // - class infomation CL_ELEM* elem ) // - the element { -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( cdopt ) ) { printf( "-- ADDED %p TO %p\n", elem, info ); } @@ -1894,7 +1894,7 @@ bool TypeReallyDefCtorable( // TEST IF TYPE REALLY NEEDS DEFAULT CTOR'ING void CDoptBackEnd( // START OF BACK-END PROCESSING void ) { -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_cdopt ) ) { DumpCdoptCaches(); } diff --git a/bld/plusplus/c/cgbackhn.c b/bld/plusplus/c/cgbackhn.c index 7ca49f289a..039350a95e 100644 --- a/bld/plusplus/c/cgbackhn.c +++ b/bld/plusplus/c/cgbackhn.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -37,7 +37,7 @@ #include "rtfuns.h" #include "pstk.h" #include "feprotos.h" -#ifndef NDEBUG +#ifdef DEVBUILD #include "pragdefn.h" #include "togglesd.h" #endif @@ -87,7 +87,7 @@ back_handle FEBack( // GET BACK HANDLE FOR A SYMBOL SCOPE scope; // - scope for symbol SYMBOL check_sym; // - SYMBOL temp back_handle cg_handle; // - handle for symbol -#ifndef NDEBUG +#ifdef DEVBUILD SYMBOL orig // - original symbol = sym; #endif @@ -121,7 +121,7 @@ back_handle FEBack( // GET BACK HANDLE FOR A SYMBOL sym->flag2 |= SYMF2_CG_HANDLE; } } -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( auxinfo ) ) { printf( "FEBack( %p ) -> bh[%p]\n", orig, cg_handle ); } diff --git a/bld/plusplus/c/cgbkarel.c b/bld/plusplus/c/cgbkarel.c index abce1e7eda..4df3903c4e 100644 --- a/bld/plusplus/c/cgbkarel.c +++ b/bld/plusplus/c/cgbkarel.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -41,7 +41,7 @@ #include "cgbackut.h" #include "ring.h" #include "initdefs.h" -#ifndef NDEBUG +#ifdef DEVBUILD #include "togglesd.h" #include "pragdefn.h" #endif @@ -60,7 +60,7 @@ struct auto_sym { AUTO_REL* rels; // - relocations }; -#ifndef NDEBUG +#ifdef DEVBUILD static void __dump_sym( AUTO_SYM*asym, const char* msg ) { @@ -133,7 +133,7 @@ void CgBackDtorAutoOffset( // RELOCATION FOR A SYMBOL sym_entry = autoRelLookup( sym ); if( sym_entry != NULL ) { __dump_sym( sym_entry, "-- relocated" ); -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_auto_rel ) ) { printf( " --- offset = %x/%d\n", offset, offset ); } @@ -149,7 +149,7 @@ void CgBackDtorAutoOffset( // RELOCATION FOR A SYMBOL void AutoRelFree( // FREE ALL RELOCATIONS void ) { -#ifndef NDEBUG +#ifdef DEVBUILD AUTO_SYM* curr; // - current entry RingIterBeg( ring_syms, curr ) { DbgVerify( curr->rels == NULL, "AutoRelFree -- missed relocation" ); diff --git a/bld/plusplus/c/cgbkbpos.c b/bld/plusplus/c/cgbkbpos.c index a91be7b886..6dcc8ff2e0 100644 --- a/bld/plusplus/c/cgbkbpos.c +++ b/bld/plusplus/c/cgbkbpos.c @@ -41,7 +41,7 @@ #include "vstk.h" #include "initdefs.h" #include "dumpapi.h" -#ifndef NDEBUG +#ifdef DEVBUILD #include "pragdefn.h" #include "togglesd.h" #endif @@ -59,9 +59,7 @@ struct blk_posn // BLK_POSN -- current block position static VSTK_CTL stack_blk_posn; // stack: current block position -#ifdef NDEBUG - #define DbgDumpBlkPosn(a,b) -#else +#ifdef DEVBUILD static void DbgDumpBlkPosn( // DUMP A BLK_POSN BLK_POSN* bpos, // - entry @@ -101,6 +99,8 @@ void DumpBlkPosns( // DUMP ALL BLK_POSN'S } } } +#else + #define DbgDumpBlkPosn(a,b) #endif @@ -217,7 +217,7 @@ void BlkPosnPop( // POP A BLOCK POSITION void BlkPosnTrash( // TRASH TOP BLOCK POSITION void ) { -#ifndef NDEBUG +#ifdef DEVBUILD BLK_POSN *bpos; // - popped element bpos = VstkPop( &stack_blk_posn ); diff --git a/bld/plusplus/c/cgbkcbak.c b/bld/plusplus/c/cgbkcbak.c index a53f79bfe2..228b637c4b 100644 --- a/bld/plusplus/c/cgbkcbak.c +++ b/bld/plusplus/c/cgbkcbak.c @@ -39,7 +39,7 @@ #include "carve.h" #include "pstk.h" #include "initdefs.h" -#ifndef NDEBUG +#ifdef DEVBUILD #include "dbg.h" #include "togglesd.h" #include "pragdefn.h" @@ -64,7 +64,7 @@ static carve_t carve_ctor_flag; // carver: ctor flag patch entries static carve_t carve_temp_entry; // carver: temp_entry's static PSTK_CTL stack_new_ctors; // stack: newed ctoring -#ifndef NDEBUG +#ifdef DEVBUILD static void _peDump( patch_entry* pe, const char* msg ) { if( TOGGLEDBG( dump_stab ) ) { @@ -238,7 +238,7 @@ static void checkCtorTest( // ELIMINATE CTOR-TEST IF POSSIBLE { SE* se = data; SE* test = FstabActualPosn(); -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_stab ) ) { printf( "CallBack: checkCtorTest: se[%p] test[%p]\n" , se @@ -419,7 +419,7 @@ SE* DtorForDelBeg( // DTORING AREA TO BE DELETED: start , patch , se_dlt ); CgExprPush( top_expr, top_type ); -#ifndef NDEBUG +#ifdef DEVBUILD DbgSetState( "patchForDtorDelBeg", se_dlt ); #endif } else { diff --git a/bld/plusplus/c/cgbkcgrf.c b/bld/plusplus/c/cgbkcgrf.c index d77e25e8aa..5d9718734c 100644 --- a/bld/plusplus/c/cgbkcgrf.c +++ b/bld/plusplus/c/cgbkcgrf.c @@ -62,14 +62,14 @@ #include "rtti.h" #include "dumpapi.h" #include "compinfo.h" -#ifndef NDEBUG +#ifdef DEVBUILD #include "dbg.h" #include "pragdefn.h" #include "togglesd.h" #endif -#ifndef NDEBUG +#ifdef DEVBUILD static void _DUMP_CGRF( char *msg, SYMBOL sym ) { if( TOGGLEDBG( callgraph ) ) { VBUF vbuf; @@ -147,7 +147,7 @@ static void forceGeneration( // FORCE CODE FILE TO BE GENERATED CALLNODE *node ); // - function in graph -#ifndef NDEBUG +#ifdef DEVBUILD void CallGraphDump( void ) { CgrfDump( call_graph ); @@ -952,7 +952,7 @@ static void markAsGen( // MARK CODE FILE TO BE GENERATED if( NULL != func ) { SegmentMarkUsed( func->segid ); } - #ifndef NDEBUG + #ifdef DEVBUILD if( TOGGLEDBG( dump_emit_ic ) ) { VBUF vbuf; printf( "Selected code file: %s\n", DbgSymNameFull( func, &vbuf ) ); @@ -1149,7 +1149,7 @@ static void removeCodeFile( // REMOVE CODE FILE FOR FUNCTION func = node->base.object; cgfile = nodeCgFile( node ); if( node->inline_fun ) { -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_emit_ic ) || TOGGLEDBG( callgraph ) ) { VBUF vbuf; printf( "Removed inline code file: %s\n", DbgSymNameFull( func, &vbuf ) ); @@ -1160,7 +1160,7 @@ static void removeCodeFile( // REMOVE CODE FILE FOR FUNCTION // inlines that aren't going to be generated aren't really referenced func->flag &= ~SYMF_REFERENCED; } else if ( SymIsRegularStaticFunc( func ) ) { -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_emit_ic ) || TOGGLEDBG( callgraph ) ) { VBUF vbuf; printf( "Removed static code file: %s\n", DbgSymNameFull( func, &vbuf ) ); @@ -1311,7 +1311,7 @@ static bool setFunctionStab( // SET STATE-TABLE INFO. FOR FUNCTION cgfile->u.s.state_table = state_table; cgfile->u.s.stab_gen = stab_gen; cgfile->cond_flags = max_cond_flags; -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_emit_ic ) || TOGGLEDBG( callgraph ) || TOGGLEDBG( dump_stab ) ) { VBUF vbuf; SYMBOL func = cgfile->symbol; @@ -1339,7 +1339,7 @@ void MarkFuncsToGen( // DETERMINE FUNCTIONS TO BE GENERATED SYMBOL *pfunc; // - ptr[ stacked inline ] CGFILE *vfcg; // - current VFTDefn CGFILE -#ifndef NDEBUG +#ifdef DEVBUILD bool dbg_dump_exec; dbg_dump_exec = TOGGLEDBG( dump_exec_ic ); @@ -1447,7 +1447,7 @@ void MarkFuncsToGen( // DETERMINE FUNCTIONS TO BE GENERATED CgrfWalkFunctions( &ctl, &procFunction ); } VstkClose( &ctl.calls ); -#ifndef NDEBUG +#ifdef DEVBUILD TOGGLEDBG( dump_exec_ic ) = dbg_dump_exec; if( TOGGLEDBG( callgraph ) ) { CgrfDump( &ctl ); @@ -1518,7 +1518,7 @@ CALLNODE* CgrfDtorAddr( // DTOR ADDR-OF HAS BEEN ESTABLISHED return( owner ); } -#ifndef NDEBUG +#ifdef DEVBUILD void* DbgCallGraph( void ) { diff --git a/bld/plusplus/c/cgbkcmds.c b/bld/plusplus/c/cgbkcmds.c index 9e903a7852..c80d9fc8a2 100644 --- a/bld/plusplus/c/cgbkcmds.c +++ b/bld/plusplus/c/cgbkcmds.c @@ -42,7 +42,7 @@ #include "carve.h" #include "ring.h" #include "initdefs.h" -#ifndef NDEBUG +#ifdef DEVBUILD #include "dbg.h" #include "togglesd.h" #include "pragdefn.h" @@ -371,7 +371,7 @@ static bool cgGenerateCmdBase( // EMIT BASE FOR COMMAND if( base->emitted ) { genning = false; } else { -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_stab ) ) { printf( "CMD[%p]: ", base->sym ); } @@ -401,7 +401,7 @@ static void cgGenerateCmdsSetSv(// EMIT SET_SV COMMANDS RingIterBegSafe( ringCmdsSetSv, curr ) { if( cgGenerateCmdBase( &curr->base, DTC_SET_SV ) ) { -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_stab ) ) { printf( "DTC_SET_SV state=%d\n", curr->state_var ); } @@ -420,7 +420,7 @@ static void cgGenerateCmdsTestFlag(// EMIT TEST_FLAG COMMANDS RingIterBegSafe( ringCmdsTestFlag, curr ) { if( cgGenerateCmdBase( &curr->base, DTC_TEST_FLAG ) ) { -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_stab ) ) { printf( "DTC_TEST_FLAG index=%d true=%d false=%d\n" , curr->index @@ -444,7 +444,7 @@ static void cgGenerateCmdsTry( // EMIT TRY COMMANDS RingIterBegSafe( ringCmdsTry, curr ) { if( cgGenerateCmdBase( &curr->base, DTC_TRY ) ) { -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_stab ) ) { printf( "DTC_CATCH %x state=%x buf=%x var=%x count=" , DTC_TRY @@ -471,7 +471,7 @@ static void cgGenerateCmdsFnExc(// EMIT FN_EXC CMDS RingIterBegSafe( ringCmdsFnExc, curr ) { if( cgGenerateCmdBase( &curr->base, DTC_FN_EXC ) ) { -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_stab ) ) { printf( "DTC_FN_EXC count=" ); } @@ -490,7 +490,7 @@ static void cgGenerateCmdsComponent(// EMIT COMPONENT CMDS RingIterBegSafe( ringCmdsComponent, curr ) { if( cgGenerateCmdBase( &curr->base, curr->cmd_type ) ) { -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_stab ) ) { const char* code; VBUF vbuf; @@ -526,7 +526,7 @@ static void cgGenerateCmdsArrayInit( // EMIT ARRAY-INIT CMDS RingIterBegSafe( ringCmdsArrayInit, curr ) { if( cgGenerateCmdBase( &curr->base, DTC_ARRAY_INIT ) ) { -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_stab ) ) { printf( "DTC_ARRAY_INIT offset=%x\n", curr->reg->offset ); } @@ -545,7 +545,7 @@ static void cgGenerateCmdsDlt1( // EMIT DELETE-1 CMDS RingIterBegSafe( ringCmdsDlt1, curr ) { if( cgGenerateCmdBase( &curr->base, DTC_DLT_1 ) ) { -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_stab ) ) { VBUF vbuf; printf( "DTC_DLT_1 offset=%x %s\n" @@ -569,7 +569,7 @@ static void cgGenerateCmdsDlt1Array( // EMIT DELETE-1-ARRAY CMDS RingIterBegSafe( ringCmdsDlt1Array, curr ) { if( cgGenerateCmdBase( &curr->base, DTC_DLT_1_ARRAY ) ) { -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_stab ) ) { VBUF vbuf; printf( "DTC_DLT_1_ARRAY offset=%x %s\n" @@ -593,7 +593,7 @@ static void cgGenerateCmdsDlt2( // EMIT DELETE-2 CMDS RingIterBegSafe( ringCmdsDlt2, curr ) { if( cgGenerateCmdBase( &curr->base, DTC_DLT_2 ) ) { -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_stab ) ) { VBUF vbuf; printf( "DTC_DLT_2 offset=%x size=%x %s\n" @@ -619,7 +619,7 @@ static void cgGenerateCmdsDlt2Array( // EMIT DELETE-2-ARRAY CMDS RingIterBegSafe( ringCmdsDlt2Array, curr ) { if( cgGenerateCmdBase( &curr->base, DTC_DLT_2_ARRAY ) ) { -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_stab ) ) { VBUF vbuf; printf( "DTC_DLT_2_ARRAY offset=%x size=%x %s\n" @@ -645,7 +645,7 @@ static void cgGenerateCmdsCtorTest( // EMIT CTOR_TEST CMDS RingIterBegSafe( ringCmdsCtorTest, curr ) { if( cgGenerateCmdBase( &curr->base, DTC_CTOR_TEST ) ) { -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_stab ) ) { printf( "DTC_CTOR_TEST %d\n", curr->flag_no ); } diff --git a/bld/plusplus/c/cgbkcond.c b/bld/plusplus/c/cgbkcond.c index c9a8417a0e..2fdec22c51 100644 --- a/bld/plusplus/c/cgbkcond.c +++ b/bld/plusplus/c/cgbkcond.c @@ -43,7 +43,7 @@ #include "ring.h" #include "pstk.h" #include "initdefs.h" -#ifndef NDEBUG +#ifdef DEVBUILD #include "dbg.h" #include "togglesd.h" #include "pragdefn.h" @@ -66,7 +66,7 @@ typedef struct { // INFO FOR A CONDITION SE* posn_false; // - position when flag clr } COND_STK; -#ifndef NDEBUG +#ifdef DEVBUILD static void _Dump( COND_STK* cond, const char* msg ) { if( TOGGLEDBG( dump_stab ) ) { @@ -225,7 +225,7 @@ void CondInfoPush( // PUSH COND_INFO STACK void CondInfoPop( // POP COND_INFO STACK void ) { -#ifndef NDEBUG +#ifdef DEVBUILD COND_STK* stk = PstkPopElement( &stack_cond_blks ); _Dump( stk, "POP" ); #else @@ -386,7 +386,7 @@ void CondInfoNewCtorEnd( // CTOR OF NEW'ED OBJECT: END const char *CallbackName( void *f ) { -#ifndef NDEBUG +#ifdef DEVBUILD cg_callback rtn; rtn = *(cg_callback *)f; diff --git a/bld/plusplus/c/cgbkcstb.c b/bld/plusplus/c/cgbkcstb.c index 4fef0fcbca..2121e54d93 100644 --- a/bld/plusplus/c/cgbkcstb.c +++ b/bld/plusplus/c/cgbkcstb.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -39,7 +39,7 @@ #include "cgbackut.h" #include "ring.h" #include "initdefs.h" -#ifndef NDEBUG +#ifdef DEVBUILD #include "pragdefn.h" #include "togglesd.h" #endif @@ -47,7 +47,7 @@ static carve_t carve_call_stab; // carve control: CALL_STAB -#ifndef NDEBUG +#ifdef DEVBUILD static void __dump( const char* text, CALL_STAB* cstb ) { diff --git a/bld/plusplus/c/cgbkfctl.c b/bld/plusplus/c/cgbkfctl.c index 2d79168a57..f84fc4fddb 100644 --- a/bld/plusplus/c/cgbkfctl.c +++ b/bld/plusplus/c/cgbkfctl.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -38,7 +38,7 @@ #include "vstk.h" #include "context.h" #include "initdefs.h" -#ifndef NDEBUG +#ifdef DEVBUILD #include "dbg.h" #endif #include "dumpapi.h" @@ -216,7 +216,7 @@ static void fnCtlFini( // COMPLETION FOR CGBKFCTL INITDEFN( fn_ctl, fnCtlInit, fnCtlFini ) -#ifndef NDEBUG +#ifdef DEVBUILD #include "module.h" diff --git a/bld/plusplus/c/cgbkftab.c b/bld/plusplus/c/cgbkftab.c index 766509a014..6c6327f2a6 100644 --- a/bld/plusplus/c/cgbkftab.c +++ b/bld/plusplus/c/cgbkftab.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -43,7 +43,7 @@ #include "ring.h" #include "initdefs.h" #include "rtfuns.h" -#ifndef NDEBUG +#ifdef DEVBUILD #include "dbg.h" #include "togglesd.h" #include "pragdefn.h" @@ -54,7 +54,7 @@ static STAB_CTL fstab; // function state table instance static STAB_DEFN fStabDefn; // function state table definition static target_offset_t rw_offset_fun; // offset of R/W var. in function -#ifndef NDEBUG +#ifdef DEVBUILD void FstabDump() // DEBUG ONLY: DUMP FUNCTION STATE TABLE { @@ -173,7 +173,7 @@ bool FstabSetup( // SETUP FUNCTION STATE TABLE fstab.marked_posn = NULL; flag_bytes = ( file_ctl->cond_flags + 7 ) / 8; if( file_ctl->u.s.state_table && file_ctl->u.s.stab_gen ) { -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_stab ) ) { printf( "State Table for Function: %p\n" , &fStabDefn.state_table ); @@ -214,7 +214,7 @@ static target_offset_t offsetStateVar( // GET OFFSET OF STATE VAR. IN R/W BLOCK static cg_name assignStateVar( // EMIT CODE TO ASSIGN STATE VARIABLE SE* se ) // - NULL or state entry to be set { -#ifndef NDEBUG +#ifdef DEVBUILD DbgSetState( "direct", se ); #endif return( CgAssignStateVar( fstab.rw, se, offsetStateVar() ) ); @@ -394,7 +394,7 @@ SE* FstabMarkedPosn( // GET MARKED POSITION SE* FstabMarkedPosnSet( // SET MARKED POSITION SE* se ) // - new position { -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_stab ) ) { printf( "--- update marked position = %p\n", se ); } diff --git a/bld/plusplus/c/cgbkibrp.c b/bld/plusplus/c/cgbkibrp.c index fed3299530..3d3b95bf3e 100644 --- a/bld/plusplus/c/cgbkibrp.c +++ b/bld/plusplus/c/cgbkibrp.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -42,7 +42,7 @@ #include "ring.h" #include "initdefs.h" #include "dumpapi.h" -#ifndef NDEBUG +#ifdef DEVBUILD #include "togglesd.h" #include "dbg.h" #include "pragdefn.h" @@ -69,10 +69,7 @@ static carve_t carveIBRP; // allocations for IBRPs static IBRP *ibrps; // ring of IBRPs scheduled static unsigned parm_no; // parm # being defined - -#ifdef NDEBUG - #define dump_ibrp( ibrp, text ) -#else +#ifdef DEVBUILD static void prt_ibrp( // PRINT IBRP ENTRY IBRP* ibrp, // - entry const char *text ) // - text string @@ -113,6 +110,8 @@ static unsigned parm_no; // parm # being defined } RingIterEnd( curr ) } } +#else + #define dump_ibrp( ibrp, text ) #endif diff --git a/bld/plusplus/c/cgbkmain.c b/bld/plusplus/c/cgbkmain.c index 982bb2a655..5ffdbfca38 100644 --- a/bld/plusplus/c/cgbkmain.c +++ b/bld/plusplus/c/cgbkmain.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -64,14 +64,14 @@ #include "rtti.h" #include "cgcli.h" #include "fold.h" -#ifndef NDEBUG +#ifdef DEVBUILD #include "pragdefn.h" #include "dbg.h" #include "togglesd.h" #endif -#ifndef NDEBUG +#ifdef DEVBUILD #define dump_label( ins ) if( TOGGLEDBG( dump_labels ) ) ins #else #define dump_label( ins ) @@ -765,7 +765,7 @@ static STAB_OBJ* buildObjectStateTable( // BUILD STATE TABLE FOR OBJECT obj->state_direct = 0; obj->state_virtual = 0; obj->defn = StabDefnAllocate( DTRG_OBJECT ); -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_stab ) ) { printf( "State Table for static object: %p\n" , &obj->defn->state_table ); @@ -827,7 +827,7 @@ static STAB_OBJ* buildObjectStateTable( // BUILD STATE TABLE FOR OBJECT } obj->state_direct = SeStateOptimal( se_dir ); obj->state_virtual = SeStateOptimal( se_virt ); -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_stab ) ) { DbgDumpStateTableDefn( obj->defn ); } @@ -2967,7 +2967,7 @@ static FN_CTL* emit_virtual_file( // EMIT A VIRTUAL FILE rtti = ins_value.pvalue; RttiRef( rtti ); } break; -#ifndef NDEBUG +#ifdef DEVBUILD // // DEBUGGING -- internal (not in production version) // @@ -2998,7 +2998,7 @@ static void remove_file( // REMOVE FILE, IF NOT INLINE static void writeVirtualFile( // EMIT AND FREE A VIRTUAL FILE CGFILE *file_ctl ) // - current file { -#ifndef NDEBUG +#ifdef DEVBUILD SYMBOL func; // - function symbol #endif // FN_CTL* fctl; // - file control @@ -3007,7 +3007,7 @@ static void writeVirtualFile( // EMIT AND FREE A VIRTUAL FILE // new_ctor_ptr = NULL; autos = NULL; FstabInit(); -#ifndef NDEBUG +#ifdef DEVBUILD func = file_ctl->symbol; if( TOGGLEDBG( callgraph ) || TOGGLEDBG( dump_stab ) || TOGGLEDBG( dump_exec_ic ) ) { if( func == NULL ) { @@ -3024,7 +3024,7 @@ static void writeVirtualFile( // EMIT AND FREE A VIRTUAL FILE #endif // fctl = emit_virtual_file( file_ctl, NULL ); emit_virtual_file( file_ctl, NULL ); -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_stab ) ) { FstabDump(); } @@ -3133,7 +3133,7 @@ void CgBackEnd( // BACK-END CONTROLLER CompFlags.codegen_active = true; CDoptBackEnd(); MarkFuncsToGen( max_inline_depth ); -#ifndef NDEBUG +#ifdef DEVBUILD TOGGLEDBG( callgraph_scan ) = false; if( TOGGLEDBG( dump_cg ) ) { GenSwitches |= CGSW_GEN_ECHO_API_CALLS; @@ -3145,7 +3145,7 @@ void CgBackEnd( // BACK-END CONTROLLER if( !cg_info.success ) { CErr1( ERR_CODEGEN_CANT_INITIALIZE ); CSuicide(); -#ifndef NDEBUG +#ifdef DEVBUILD } else if( cg_info.version.revision != II_REVISION ) { CFatal( "Incorrect Code Generator version" ); #endif @@ -3218,7 +3218,7 @@ void FEGenProc( // INLINE SUPPORT { CGFILE *file_ctl; // - file control info // FN_CTL* fctl; // - file-gen info. for caller -#ifndef NDEBUG +#ifdef DEVBUILD SE* curr; // - current state entry for caller #endif SYMBOL sym = _sym; // - function to be in-lined @@ -3230,7 +3230,7 @@ void FEGenProc( // INLINE SUPPORT // fctl = FnCtlTop(); FnCtlTop(); ExtraRptIncrementCtr( ctr_inlines ); -#ifndef NDEBUG +#ifdef DEVBUILD curr = CallStabStateTablePosn( call ); if( TOGGLEDBG( callgraph ) || TOGGLEDBG( dump_stab ) ) { VBUF vbuf; @@ -3256,7 +3256,7 @@ void FEGenProc( // INLINE SUPPORT buffering = file_ctl->buffer; cursor = file_ctl->cursor; emit_virtual_file( file_ctl, call ); -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( callgraph ) || TOGGLEDBG( dump_stab ) ) { VBUF vbuf; if( TOGGLEDBG( dump_exec_ic ) ) diff --git a/bld/plusplus/c/cgbkscop.c b/bld/plusplus/c/cgbkscop.c index 54a1a038c1..b93450a792 100644 --- a/bld/plusplus/c/cgbkscop.c +++ b/bld/plusplus/c/cgbkscop.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -44,7 +44,7 @@ #include "reposit.h" #include "scoperes.h" #include "dumpapi.h" -#ifndef NDEBUG +#ifdef DEVBUILD #include "togglesd.h" #include "dbg.h" #include "pragdefn.h" @@ -135,7 +135,7 @@ static VSTK_CTL open_scopes; // open scopes static SCOPE_RES* scopes; // unresolved scopes -#ifndef NDEBUG +#ifdef DEVBUILD static char const * usage_names[] = { #define USAGE_DEF(a) # a @@ -423,7 +423,7 @@ static SCOPE_RES* markScopeGen // MARK SCOPE AS GENERATED for( enc = sr; ; enc = enc->enclosing ) { DbgVerify( enc != NULL, "makeScopeGen -- no scopes" ); enc->gen_stab = true; -#ifndef NDEBUG +#ifdef DEVBUILD if( enc != sr ) { _printScopeRes( enc, "enclosed scope made genable" ); } @@ -527,7 +527,7 @@ void CgResScBlkScanBegin // START SCANNING OF A BLOCK SCOPE , CALLNODE* caller // - caller , DT_METHOD dtm ) // - dtor method for function { -#ifndef NDEBUG +#ifdef DEVBUILD SCOPE_RES* sr = newScope( scope, caller, dtm ); _printScopeRes( sr, "Start scanning block scope" ); #else @@ -1191,7 +1191,7 @@ void CgResFini // COMPLETION CarveDestroy( carveScRes ); } -#ifndef NDEBUG +#ifdef DEVBUILD void DumpUnresolved( void ) // DBG: callable from debugger { diff --git a/bld/plusplus/c/cgbkstab.c b/bld/plusplus/c/cgbkstab.c index 9153053b6f..5c6ee57646 100644 --- a/bld/plusplus/c/cgbkstab.c +++ b/bld/plusplus/c/cgbkstab.c @@ -42,7 +42,7 @@ #include "cgbackut.h" #include "ring.h" #include "initdefs.h" -#ifndef NDEBUG +#ifdef DEVBUILD #include "dbg.h" #endif @@ -153,7 +153,7 @@ bool StabGenerate( // GENERATE A STATE TABLE } } } RingIterEnd( se ) -#if defined( _RISC_CPU ) || !defined( NDEBUG ) +#if defined( _RISC_CPU ) || defined( DEVBUILD ) DgPtrSymCode( NULL ); DgPtrSymData( NULL ); #endif diff --git a/bld/plusplus/c/cgbkstrn.c b/bld/plusplus/c/cgbkstrn.c index 39d5bdd2a6..4c95b5dbd3 100644 --- a/bld/plusplus/c/cgbkstrn.c +++ b/bld/plusplus/c/cgbkstrn.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -43,7 +43,7 @@ #include "vstk.h" #include "initdefs.h" #include "preproc.h" -#ifndef NDEBUG +#ifdef DEVBUILD #include "togglesd.h" #include "pragdefn.h" #endif @@ -55,7 +55,7 @@ typedef struct // SYM_TRANS -- symbol translation unsigned id; // - id for translation block } SYM_TRANS; -#ifndef NDEBUG +#ifdef DEVBUILD static void dump( const char* msg, SYM_TRANS* tr ) { @@ -114,7 +114,7 @@ void SymTransPush( // ADD A SYMBOL TO BE TRANSLATED } -#ifndef NDEBUG +#ifdef DEVBUILD void SymTransEmpty( // DEBUG: VERIFY SYMBOL TRANSLATIONS OVER void ) { diff --git a/bld/plusplus/c/cgbksvar.c b/bld/plusplus/c/cgbksvar.c index 2644c37926..edbcf192d0 100644 --- a/bld/plusplus/c/cgbksvar.c +++ b/bld/plusplus/c/cgbksvar.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -40,7 +40,7 @@ #include "cgbackut.h" #include "ring.h" #include "initdefs.h" -#ifndef NDEBUG +#ifdef DEVBUILD #include "dbg.h" #include "togglesd.h" #include "pragdefn.h" @@ -70,7 +70,7 @@ static const carve_t *seCarvers[] = { #undef pick }; -#ifndef NDEBUG +#ifdef DEVBUILD static carve_t seCarver( // GET CARVER FOR AN SE TYPE DTC_KIND se_type ) // - code for entry { @@ -98,7 +98,7 @@ static void pruneSE( // PRUNE STATE ENTRY SE *next = se->base.next; // - next entry RingPrune( a_stab, se ); -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_stab ) ) { printf( "State Table[%p] removed: %p\n", a_stab, se ); DbgDumpStateEntry( se ); @@ -128,7 +128,7 @@ static bool sameSE( // DETERMINE IF SAME STATE ENTRY case DTC_SET_SV : last->set_sv.se = se->set_sv.se; // check for SET_SV to previous -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_stab ) ) { printf( "State Table replacement %p\n", se ); DbgDumpStateEntry( last ); @@ -185,7 +185,7 @@ static SE* stateTableAddSe( // ADD TO STATE TABLE next = se->base.next; se->base.prev = next->base.prev; next->base.prev = se; -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_stab ) ) { printf( "State Table[%p] added: %p\n", a_stab, se ); DbgDumpStateEntry( se ); @@ -416,7 +416,7 @@ SE* StabCtlPosnGened( // GET GENERATED POSITION IF REQUIRED } -#ifndef NDEBUG +#ifdef DEVBUILD static void DbgDumpTypeSigEnt( // DUMP TYPE_SIG_ENT entries diff --git a/bld/plusplus/c/cgbkthrw.c b/bld/plusplus/c/cgbkthrw.c index af30c2e1ca..02792dc629 100644 --- a/bld/plusplus/c/cgbkthrw.c +++ b/bld/plusplus/c/cgbkthrw.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -40,7 +40,7 @@ #include "ring.h" #include "ctexcept.h" #include "initdefs.h" -#ifndef NDEBUG +#ifdef DEVBUILD #include "pragdefn.h" #include "togglesd.h" #endif @@ -107,13 +107,13 @@ static void cgGenThrowCnv( // GENERATE THROW CONVERSION TYPE_SIG *sig; // - signature for type sig = BeTypeSignature( type ); -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_stab ) ) { printf( " conversion: " ); } #endif BeGenTsRef( sig ); -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_stab ) ) { printf( " offset=%x\n", offset ); } @@ -139,7 +139,7 @@ void ThrowRoGen( // GENERATE A THROW R/O BLOCK offset = ThrowCnvInit( &ctl, ro->sig->type ); DbgVerify( ! ctl.error_occurred , "cgGenThrowRo -- failure in ThrowCnvInit" ); -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_stab ) ) { printf( "ThrowRo[%p] offset=%p sig=%x\n" , ro diff --git a/bld/plusplus/c/cgbktsig.c b/bld/plusplus/c/cgbktsig.c index 12e540a177..ad33a01a19 100644 --- a/bld/plusplus/c/cgbktsig.c +++ b/bld/plusplus/c/cgbktsig.c @@ -44,7 +44,7 @@ #include "ring.h" #include "rtti.h" #include "initdefs.h" -#ifndef NDEBUG +#ifdef DEVBUILD #include "dbg.h" #include "togglesd.h" #include "pragdefn.h" @@ -83,7 +83,7 @@ void BeGenTsRef( // GENERATE REFERENCE TO TYPE-SIGNATURE target_offset_t offset; // - offset for reference TypeSigSymOffset( ts, &sym, &offset ); -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_stab ) ) { VBUF vbuf; printf( " typsig=%s+%x" @@ -130,7 +130,7 @@ static void genBaseHdr( // GENERATE BASE HEADER FOR TYPE-SIGNATURE DgByte( THROBJ_PTR_CLASS ); DgByte( THROBJ_REFERENCE ); DgByte( flags ); -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_stab ) ) { printf( " base=%d,%d,%d,%d" , thr @@ -149,7 +149,7 @@ static void genScalarHdr( // GENERATE SCALAR HDR size = CgMemorySize( ts->type ); DgOffset( size ); -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_stab ) ) { printf( " size=%d\n", size ); } @@ -165,7 +165,7 @@ static void genTsPtr( // GENERATE PTR TO TYPE SIGNATURE ts = BeTypeSignature( type ); DgPtrSymData( ts->sym ); -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_stab ) ) { printf( " sig=%x\n", ts ); } @@ -189,7 +189,7 @@ static void genTypeSig( // GENERATE A TYPE_SIG thr = ThrowCategory( ts->type ); if( thr == THROBJ_ANYTHING ) return; -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_stab ) ) { const char* code; switch( thr ) { @@ -217,7 +217,7 @@ static void genTypeSig( // GENERATE A TYPE_SIG case THROBJ_PTR_CLASS : genBaseHdr( thr, TSIG_FLAGS_INDIRECT ); BeGenTsRef( ts ); -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_stab ) ) { printf( "\n" ); } @@ -243,7 +243,7 @@ static void genTypeSig( // GENERATE A TYPE_SIG size = CgMemorySize( ts->type ); DgOffset( size ); genName( thr, ts->type ); -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_stab ) ) { VBUF vbuf1; VBUF vbuf2; @@ -317,7 +317,7 @@ void BeGenTypeSigEnts( // EMIT TYPE_SIG_ENT RING unsigned count; // - # entries count = RingCount( ring ); -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_stab ) ) { printf( "%d\n", count ); } @@ -325,7 +325,7 @@ void BeGenTypeSigEnts( // EMIT TYPE_SIG_ENT RING DgOffset( count ); RingIterBegSafe( ring, curr ) { BeGenTsRef( curr->sig ); -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_stab ) ) { printf( "\n" ); } diff --git a/bld/plusplus/c/cgbkutil.c b/bld/plusplus/c/cgbkutil.c index 77b6dc3a5c..89bcfec39f 100644 --- a/bld/plusplus/c/cgbkutil.c +++ b/bld/plusplus/c/cgbkutil.c @@ -41,7 +41,7 @@ #include "cgbackut.h" #include "objmodel.h" #include "cgio.h" -#ifndef NDEBUG +#ifdef DEVBUILD #include "pragdefn.h" #include "togglesd.h" #endif @@ -910,7 +910,7 @@ cg_name CgDtorStatic( // DTOR STATIC OBJECT StabCtlInit( &sctl, &dctl ); StabDefnInit( &dctl, DTRG_STATIC_INITLS ); -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_stab ) ) { printf( "State Table for static object: %p\n", &dctl.state_table ); } diff --git a/bld/plusplus/c/cgbkvftb.c b/bld/plusplus/c/cgbkvftb.c index 247f388d7f..242d14fb29 100644 --- a/bld/plusplus/c/cgbkvftb.c +++ b/bld/plusplus/c/cgbkvftb.c @@ -42,7 +42,7 @@ #include "cgbackut.h" #include "ring.h" #include "initdefs.h" -#ifndef NDEBUG +#ifdef DEVBUILD #include "dbg.h" #endif diff --git a/bld/plusplus/c/cgfront.c b/bld/plusplus/c/cgfront.c index f4201d6b71..0413cdc599 100644 --- a/bld/plusplus/c/cgfront.c +++ b/bld/plusplus/c/cgfront.c @@ -48,7 +48,7 @@ #include "fnbody.h" #include "tgtenv.h" #include "compinfo.h" -#ifndef NDEBUG +#ifdef DEVBUILD #include "pragdefn.h" #include "togglesd.h" #endif @@ -77,7 +77,7 @@ static struct { // FLAGS FOR CGFRONT unsigned init_data_end :1; // - init-data-end required } flags; -#ifndef NDEBUG +#ifdef DEVBUILD static void cgfront_debug( // DEBUGGING ROUTINE char *str ) // - prefix { @@ -94,7 +94,7 @@ static void cgfront_debug( // DEBUGGING ROUTINE // function macros -#ifndef NDEBUG +#ifdef DEVBUILD static void cgWriteIC( CGFILE *f, CGINTER *i ) { CgioWriteIC( f, i ); @@ -311,7 +311,7 @@ void CgFrontDbgLine( // SET LINE FOR DEBUGGING gen = getGenData(); emitSourcePosn( gen, posn ); -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_tokens ) || TOGGLEDBG( dump_emit_ic ) ) { printf( "CgFrontDbgLine: %d\n", posn->line ); } diff --git a/bld/plusplus/c/cginfo.c b/bld/plusplus/c/cginfo.c index 44ad37101b..e44583744b 100644 --- a/bld/plusplus/c/cginfo.c +++ b/bld/plusplus/c/cginfo.c @@ -67,7 +67,7 @@ #include "dwarfid.h" #include "cgfront.h" #include "feprotos.h" -#ifndef NDEBUG +#ifdef DEVBUILD #include "togglesd.h" #endif @@ -373,7 +373,7 @@ fe_attr FEAttr( // GET SYMBOL ATTRIBUTES } DbgAssert( mask == 0 || (attr & FE_COMMON) == 0 ); attr &= ~mask; -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( auxinfo ) ) { printf( "FeAttr( %p = %s ) -> %x\n" , (void *)sym @@ -1202,7 +1202,7 @@ static void addDefaultImports( void ) #endif } -#ifndef NDEBUG +#ifdef DEVBUILD #define DbgNotSym() isSym = false; #define DbgNotRetn() isRetn = false; #else @@ -1221,7 +1221,7 @@ void *FEAuxInfo( // REQUEST AUXILLIARY INFORMATION static SYMBOL dtor_sym; // - symbol to be DTOR'ed static EXTRF res_info; // - external-symbol resolution information SYMBOL sym = _sym; -#ifndef NDEBUG +#ifdef DEVBUILD bool isSym = true; // DEBUGGING: true ==> "sym" is SYMBOL bool isRetn = true; // DEBUGGING: true ==> "retn" is SYMBOL #endif @@ -1471,7 +1471,7 @@ void *FEAuxInfo( // REQUEST AUXILLIARY INFORMATION break; case FEINF_DEFAULT_IMPORT_RESOLVE : retn = ExtrefResolve( sym, &res_info ); - #ifndef NDEBUG + #ifdef DEVBUILD if( TOGGLEDBG( extref ) ) { printf( "DEFAULT_IMPORT_RESOLVE[%p]: %s ==> %s\n", sym , GetMangledName( sym ) @@ -1482,7 +1482,7 @@ void *FEAuxInfo( // REQUEST AUXILLIARY INFORMATION case FEINF_IMPORT_TYPE : DbgNotRetn(); retn = ExtrefImportType( &res_info ); - #ifndef NDEBUG + #ifdef DEVBUILD if( TOGGLEDBG( extref ) ) { printf( " IMPORT_TYPE[%p]: %s <%p>\n" , sym, GetMangledName( sym ), retn ); @@ -1493,7 +1493,7 @@ void *FEAuxInfo( // REQUEST AUXILLIARY INFORMATION case FEINF_NEXT_CONDITIONAL : DbgNotSym(); retn = ExtrefVirtualSymbol( &res_info ); - #ifndef NDEBUG + #ifdef DEVBUILD if( TOGGLEDBG( extref ) ) { printf( " NEXT_/CONDITIONAL/_IMPORT: %s\n" , GetMangledName( retn ) ); @@ -1502,7 +1502,7 @@ void *FEAuxInfo( // REQUEST AUXILLIARY INFORMATION break; case FEINF_CONDITIONAL_SYMBOL : retn = sym; - #ifndef NDEBUG + #ifdef DEVBUILD if( TOGGLEDBG( extref ) ) { printf( " CONDITIONAL_SYMBOL: %s\n" , GetMangledName( retn ) ); @@ -1510,7 +1510,7 @@ void *FEAuxInfo( // REQUEST AUXILLIARY INFORMATION #endif break; case FEINF_VIRT_FUNC_REFERENCE : - #ifndef NDEBUG + #ifdef DEVBUILD DbgNotRetn(); if( ( TOGGLEDBG( extref ) ) &&( sym->id == SYMC_VIRTUAL_FUNCTION ) ) { @@ -1531,7 +1531,7 @@ void *FEAuxInfo( // REQUEST AUXILLIARY INFORMATION DbgNotSym(); DbgNotRetn(); retn = ExtrefNextVfunSym( sym ); - #ifndef NDEBUG + #ifdef DEVBUILD if( TOGGLEDBG( extref ) ) { printf( " VIRT_FUNC_NEXT_REFERENCE[%p]: <%p>\n", sym, retn ); } @@ -1540,7 +1540,7 @@ void *FEAuxInfo( // REQUEST AUXILLIARY INFORMATION case FEINF_VIRT_FUNC_SYM : DbgNotSym(); retn = ExtrefVfunSym( sym ); - #ifndef NDEBUG + #ifdef DEVBUILD if( TOGGLEDBG( extref ) ) { printf( " VIRT_FUNC_SYM[%p]: %s\n" , sym, GetMangledName( retn ) ); @@ -1577,7 +1577,7 @@ void *FEAuxInfo( // REQUEST AUXILLIARY INFORMATION retn = NULL; break; } -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( auxinfo ) ) { printf( "FeAuxInfo( %p, %x ) -> %p\n", sym, request, retn ); if( isSym && ( NULL != sym )) { diff --git a/bld/plusplus/c/cgio.c b/bld/plusplus/c/cgio.c index 40459ee1a7..60c6240da4 100644 --- a/bld/plusplus/c/cgio.c +++ b/bld/plusplus/c/cgio.c @@ -45,7 +45,7 @@ #include "stats.h" #include "module.h" #include "dumpapi.h" -#ifndef NDEBUG +#ifdef DEVBUILD #include "togglesd.h" #include "dbg.h" #include "pragdefn.h" @@ -70,7 +70,7 @@ ExtraRptCtr( cgio_comps ); ExtraRptCtr( cgio_locates_thunk ); -#ifndef NDEBUG +#ifdef DEVBUILD static void _dump( CGFILE* cgfile, const char* prefix ) { @@ -211,8 +211,7 @@ static CGFILE* lookupFile( // DO A FILE LOOKUP FOR A SYMBOL, RING return( NULL ); } -#ifndef NDEBUG - +#ifdef DEVBUILD void DbgCgioEndFront( // CALLED AT END OF FRONT END void ) @@ -301,7 +300,7 @@ void CgioWriteIC( // WRITE IC RECORD TO VIRTUAL FILE CGFILE *ctl, // - control for the file CGINTER *ins ) // - instruction { -#ifndef NDEBUG +#ifdef DEVBUILD ExtraRptIncrementCtr( cgio_write_ins ); if( ICOpTypes[ins->opcode] == ICOT_NUL ) { ExtraRptIncrementCtr( cgio_write_nul ); @@ -442,7 +441,7 @@ void CgioFreeFile( // FREE A VIRTUAL FILE CarveFree( carveCGFILE, ctl ); #else if( ! changeRing( &cg_file_removed, ctl, &cg_file_ring ) ) { - #ifndef NDEBUG + #ifdef DEVBUILD int changed = #endif changeRing( &cg_file_removed, ctl, &cg_thunk_ring ); @@ -467,7 +466,7 @@ void CgioWalkFiles( // WALK THRU FILES void CgioThunkStash( // STASH AWAY A THUNK TO BE GEN'ED CGFILE* thunk ) // - that thunk { -#ifndef NDEBUG +#ifdef DEVBUILD int changed = #endif changeRing( &cg_thunk_ring, thunk, &cg_file_ring ); diff --git a/bld/plusplus/c/cgiobuff.c b/bld/plusplus/c/cgiobuff.c index 25f49d7691..065cc10bcd 100644 --- a/bld/plusplus/c/cgiobuff.c +++ b/bld/plusplus/c/cgiobuff.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -46,7 +46,7 @@ #include "conpool.h" #include "pcheader.h" #include "cgio.h" -#ifndef NDEBUG +#ifdef DEVBUILD #include "dbg.h" #include "pragdefn.h" #include "togglesd.h" @@ -62,7 +62,7 @@ // maximum capacity of a buffer before an IC_NEXT instruction is req'd #define MAX_WRITE_AMT ( TMPBLOCK_BSIZE - sizeof( BUFF_XFER ) - sizeof( CGINTER ) ) -#ifndef NDEBUG +#ifdef DEVBUILD #define DICT_SIZE 4 #else #define DICT_SIZE 128 @@ -377,7 +377,7 @@ CGINTER CgioBuffPCHRead( // READ FROM PCH AND WRITE INTO BUFFER ctl->free_offset += ((char*)dest) - (char*)start; *pctl = ctl; // rest of block can be ignored -#ifndef NDEBUG +#ifdef DEVBUILD { CGINTER *c = p_instr + 1; DbgAssert( c <= s_instr ); @@ -439,7 +439,7 @@ CGIOBUFF *CgioBuffWriteIC( // WRITE AN IC RECORD } } #endif -#ifndef NDEBUG +#ifdef DEVBUILD DbgAssert( ins->opcode != IC_EOF ); if( icMaskTable[ins->opcode] & ICOPM_BRINFO ) { if( TOGGLEDBG( browse_emit ) ) { @@ -488,7 +488,7 @@ CGIOBUFF *CgioBuffRdOpen( // GET BUFFER FOR READING return( findRdBuffer( block ) ); } -#ifndef NDEBUG +#ifdef DEVBUILD static void dumpRead // DBG: TRACE AN INSTRUCTION READ ( CGIOBUFF *ctl // - buffer control , CGINTER *curr // - current instruction @@ -774,7 +774,7 @@ void CgioBuffInit( // BUFFERING INITIALIZATION void CgioBuffFini( // BUFFERING COMPLETION void ) { -#ifndef NDEBUG +#ifdef DEVBUILD { CGIOBUFF *curr; @@ -798,7 +798,7 @@ void CgioBuffZap( // ZAP A WRITTEN AREA OF A BUFFER CGIOBUFF *ctl; // - buffer control ctl = findRdBuffer( zap.block ); -#ifndef NDEBUG +#ifdef DEVBUILD if( icMaskTable[ins->opcode] & ICOPM_BRINFO ) { if( TOGGLEDBG( browse_emit ) ) { DumpCgFront( "ZAP ", zap.block, zap.offset, ins ); diff --git a/bld/plusplus/c/class.c b/bld/plusplus/c/class.c index 7acc17663f..3ac9049fdd 100644 --- a/bld/plusplus/c/class.c +++ b/bld/plusplus/c/class.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -102,7 +102,7 @@ typedef enum { static uint_16 classIndex; -#ifndef NDEBUG +#ifdef DEVBUILD void DumpClasses( void ) { CLASS_DATA *data; @@ -1628,7 +1628,7 @@ static void createVFPtrField( CLASS_DATA *data, bool do_creation ) if( do_creation ) { vfptr_type = MakeVFTableFieldType( true ); data->vf_offset = addTypeField( data, vfptr_type ); -#ifndef NDEBUG +#ifdef DEVBUILD } else if( data->own_vfptr ) { CFatal( "vfptr created twice" ); #endif @@ -2037,7 +2037,7 @@ static void verifyCtor( CLASS_DATA *data, SYMBOL sym ) SYMBOL base_sym; CLASSINFO *info; -#ifndef NDEBUG +#ifdef DEVBUILD if( sym->name->name != CppConstructorName() ) { CFatal( "ctor check used on non-ctor symbol" ); } @@ -2986,7 +2986,7 @@ bool ClassOKToRewrite( void ) return( false ); } -#ifndef NDEBUG +#ifdef DEVBUILD if( ! ScopeType( GetCurrScope(), SCOPE_CLASS ) ) { DbgAssert( ScopeType( GetCurrScope()->enclosing, SCOPE_CLASS ) ); } @@ -3017,7 +3017,7 @@ void ClassStoreInlineFunc( DECL_INFO *dinfo ) CLASS_DATA *data; data = classDataStack; -#ifndef NDEBUG +#ifdef DEVBUILD if( data == NULL ) { CFatal( "inline function is not in a class definition" ); } @@ -3028,7 +3028,7 @@ void ClassStoreInlineFunc( DECL_INFO *dinfo ) } #endif data = data->inline_data; -#ifndef NDEBUG +#ifdef DEVBUILD if( data == NULL ) { CFatal( "inline function is not nested in a class definition" ); } @@ -3105,7 +3105,7 @@ static void doPromotion( SYMBOL_NAME sym_name ) sym = sym_name->name_syms; sym_name->name_syms = NULL; -#ifndef NDEBUG +#ifdef DEVBUILD if( sym == NULL ) { CFatal( "missing check for anonymous unions" ); } diff --git a/bld/plusplus/c/cmac1.c b/bld/plusplus/c/cmac1.c index cbf5bb314f..45d222f40e 100644 --- a/bld/plusplus/c/cmac1.c +++ b/bld/plusplus/c/cmac1.c @@ -42,7 +42,7 @@ #include "carve.h" #include "dumpapi.h" #include "cscanbuf.h" -#ifndef NDEBUG +#ifdef DEVBUILD #include "dbg.h" #endif @@ -252,7 +252,7 @@ static TOKEN doGetMacroToken( // GET NEXT TOKEN *mlist = mtok->next; CMemFree( mtok ); } -#ifndef NDEBUG +#ifdef DEVBUILD DumpMacToken(); #endif return( token ); @@ -580,7 +580,7 @@ static MACRO_ARG *collectParms( MEPTR mentry ) } -#ifndef NDEBUG +#ifdef DEVBUILD #if 0 void DumpMTokens( MACRO_TOKEN *mtok ) { @@ -746,7 +746,7 @@ static MACRO_TOKEN *expandNestedMacros( MACRO_TOKEN *head, bool rescanning ) ptail = &head; ++macroDepth; -#ifndef NDEBUG +#ifdef DEVBUILD if( macroDepth > 100 ) { #if defined( __WATCOMC__ ) EnterDebugger(); diff --git a/bld/plusplus/c/cmdln.c b/bld/plusplus/c/cmdln.c index fc7d8eb110..34b068f4da 100644 --- a/bld/plusplus/c/cmdln.c +++ b/bld/plusplus/c/cmdln.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -51,7 +51,7 @@ #include "vstk.h" #include "vbuf.h" #include "toggles.h" -#ifndef NDEBUG +#ifdef DEVBUILD #include "togglesd.h" #endif @@ -328,7 +328,7 @@ void InitModInfo( // INITIALIZE MODULE INFORMATION CompFlags.inline_functions = true; memset( &PragmaToggles, 0, sizeof( PragmaToggles ) ); -#ifndef NDEBUG +#ifdef DEVBUILD memset( &PragmaDbgToggles, 0, sizeof( PragmaDbgToggles ) ); #endif TOGGLE( check_stack ) = true; diff --git a/bld/plusplus/c/cmdlnany.c b/bld/plusplus/c/cmdlnany.c index 87e25dc12e..ddcb5dfb03 100644 --- a/bld/plusplus/c/cmdlnany.c +++ b/bld/plusplus/c/cmdlnany.c @@ -59,7 +59,7 @@ #include "cmdlnsys.h" #include "compinfo.h" #include "toggles.h" -#ifndef NDEBUG +#ifdef DEVBUILD #include "togglesd.h" #endif @@ -1154,7 +1154,7 @@ static void analyseAnyTargetOptions( OPT_STORAGE *data ) CompFlags.virtual_stripping = true; #endif } -#ifndef NDEBUG +#ifdef DEVBUILD if( data->tp ) { OPT_STRING *str; while( (str = data->tp_value) != NULL ) { diff --git a/bld/plusplus/c/context.c b/bld/plusplus/c/context.c index 8b6b3549cc..bfd3bbb5fe 100644 --- a/bld/plusplus/c/context.c +++ b/bld/plusplus/c/context.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -36,7 +36,7 @@ #include "ring.h" #include "context.h" #include "initdefs.h" -#ifndef NDEBUG +#ifdef DEVBUILD #include "dbg.h" #endif @@ -57,12 +57,12 @@ static char const *switch_addr; // - - address of switch // - FORCED_INCS, SOURCE, FUNC_GEN, CG_FUNC static SYMBOL func; // - - function being generated -#ifndef NDEBUG +#ifdef DEVBUILD static LINE_NO line; // - - current line #endif // - FORCED_INCS, SOURCE -#ifndef NDEBUG +#ifdef DEVBUILD static TOKEN_LOCN location; // - - location being analysed #endif @@ -90,7 +90,7 @@ void CtxSetCurrContext( // SET THE CURRENT CONTEXT context = curr; CtxSetSwitchAddr( NULL ); func = NULL; -#ifndef NDEBUG +#ifdef DEVBUILD line = 0; location.src_file = NULL; #endif @@ -111,7 +111,7 @@ char const *CtxGetSwitchAddr( // GET CURRENT SWITCH CONTEXT } -#ifndef NDEBUG +#ifdef DEVBUILD void CtxTokenLocn( // SET TOKEN LOCATION TOKEN_LOCN *locn ) // - token location { @@ -127,7 +127,7 @@ void CtxFunction( // SET FUNCTION BEING PROCESSED } -#ifndef NDEBUG +#ifdef DEVBUILD void CtxLine( // SET LINE BEING PROCESSED LINE_NO curr ) // - current line no. { @@ -136,7 +136,7 @@ void CtxLine( // SET LINE BEING PROCESSED #endif -#ifndef NDEBUG +#ifdef DEVBUILD void CtxScanToken( // SET TOKEN LOCATION FOR SCANNED TOKEN void ) { @@ -185,7 +185,7 @@ bool CtxCurrent( // GET CURRENT CONTEXT } -#ifndef NDEBUG +#ifdef DEVBUILD static char CompilerContext[80]; // - buffer for debugging void *CtxWhereAreYou( // SET DEBUGGING BUFFER diff --git a/bld/plusplus/c/convctl.c b/bld/plusplus/c/convctl.c index 5cc3e06f72..283dc2168a 100644 --- a/bld/plusplus/c/convctl.c +++ b/bld/plusplus/c/convctl.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -37,7 +37,7 @@ #include "template.h" #include "class.h" #include "dumpapi.h" -#ifndef NDEBUG +#ifdef DEVBUILD #include "dbg.h" #endif @@ -1421,7 +1421,7 @@ CNV_RETN CastPtrToPtr // IMPLICIT/EXPLICIT CAST PTR -> PTR // DEBUG SUPPORT -#ifndef NDEBUG +#ifdef DEVBUILD static char const * const rkdstr[] = { #define dfnRKD(a) # a diff --git a/bld/plusplus/c/cpragma.c b/bld/plusplus/c/cpragma.c index 8416a7cb25..8634906315 100644 --- a/bld/plusplus/c/cpragma.c +++ b/bld/plusplus/c/cpragma.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -52,7 +52,7 @@ #include "cgfront.h" #include "compinfo.h" #include "toggles.h" -#ifndef NDEBUG +#ifdef DEVBUILD #include "togglesd.h" #endif // from \watcom\h @@ -79,7 +79,7 @@ typedef struct prag_stack { } prag_stack; pragma_toggles PragmaToggles; -#ifndef NDEBUG +#ifdef DEVBUILD pragma_dbg_toggles PragmaDbgToggles; #endif @@ -1045,7 +1045,7 @@ static void pragDestruct( // SPECIFY DESTRUCTION MECHANISM PPCTL_DISABLE_MACROS(); } -#ifndef NDEBUG +#ifdef DEVBUILD // forms: // // #pragma break @@ -1370,7 +1370,7 @@ void CPragma( void ) // PROCESS A PRAGMA pragError(); } else if( pragmaNameRecog( "STDC" ) ) { pragSTDC(); -#ifndef NDEBUG +#ifdef DEVBUILD } else if( pragmaNameRecog( "break" ) ) { pragBreak(); #endif @@ -1945,7 +1945,7 @@ void PragmaSetToggle( // SET TOGGLE int func, // - -1/0/1 ==> func pop/off/on bool push ) // - true ==> push current value on stack { -#ifndef NDEBUG +#ifdef DEVBUILD #define pick( x ) \ if( strcmp( name, #x ) == 0 ) { \ if( func == -1 ) { \ diff --git a/bld/plusplus/c/cpragx86.c b/bld/plusplus/c/cpragx86.c index 09595786ca..aa67c4283d 100644 --- a/bld/plusplus/c/cpragx86.c +++ b/bld/plusplus/c/cpragx86.c @@ -161,7 +161,7 @@ static void pragmasFini( // FINISH PRAGMAS info->use--; } else { freeInfo( info ); -#ifndef NDEBUG +#ifdef DEVBUILD if( IsAuxInfoBuiltIn( info ) ) { CFatal( "freeing a static calling convention info" ); } @@ -886,7 +886,7 @@ void AsmSysPCHWriteCode( AUX_INFO *info ) byte *c; byte *p; byte *tmp_buff; -#ifndef NDEBUG +#ifdef DEVBUILD byte buff[8]; #else byte buff[1024]; diff --git a/bld/plusplus/c/cscan.c b/bld/plusplus/c/cscan.c index 2b0de62a12..c22b34aa3f 100644 --- a/bld/plusplus/c/cscan.c +++ b/bld/plusplus/c/cscan.c @@ -41,7 +41,7 @@ #include "context.h" #include "unicode.h" #include "cscanbuf.h" -#ifndef NDEBUG +#ifdef DEVBUILD #include "dbg.h" #endif @@ -1530,7 +1530,7 @@ TOKEN NextToken( void ) return( CurToken ); } (*tokenSource)(); -#ifndef NDEBUG +#ifdef DEVBUILD CtxScanToken(); DumpToken(); #endif diff --git a/bld/plusplus/c/datadtor.c b/bld/plusplus/c/datadtor.c index f2ea5e883f..aa72218468 100644 --- a/bld/plusplus/c/datadtor.c +++ b/bld/plusplus/c/datadtor.c @@ -36,7 +36,7 @@ #include "datadtor.h" #include "fnbody.h" #include "cdopt.h" -#ifndef NDEBUG +#ifdef DEVBUILD #include "dbg.h" #include "togglesd.h" #include "pragdefn.h" @@ -85,7 +85,7 @@ PTREE DataDtorObjPush( // START OF DTORABLE OBJECT { TYPE dtor_type; // - type for dtor -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_data_dtor ) ) { VBUF vbuf; printf( "DataDtorObjPush -- symbol %s\n" @@ -110,7 +110,7 @@ PTREE DataDtorObjPush( // START OF DTORABLE OBJECT PTREE DataDtorObjPop( // COMPLETE DTORABLE OBJECT PTREE expr ) // - expression to be decorated { -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_data_dtor ) ) { printf( "DataDtorObjPop\n" ); } @@ -124,7 +124,7 @@ PTREE DataDtorCompClass( // MARK CLASS OBJECT AS DTORABLE COMPONENT target_offset_t offset, // - offset of component DTC_KIND kind ) // - kind of component { -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_data_dtor ) ) { printf( "DataDtorCompClass -- offset %x\n", offset ); } @@ -138,7 +138,7 @@ PTREE DataDtorCompArrEl( // MARK ARRAY ELEMENT AS DTORABLE COMPONENT PTREE expr, // - expression to be decorated target_offset_t index ) // - array index { -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_data_dtor ) ) { printf( "DataDtorCompArrEl -- index(%x)\n", index ); } diff --git a/bld/plusplus/c/datainit.c b/bld/plusplus/c/datainit.c index b063cc2063..1fb242f377 100644 --- a/bld/plusplus/c/datainit.c +++ b/bld/plusplus/c/datainit.c @@ -51,7 +51,7 @@ #include "typesig.h" #include "datadtor.h" #include "initdefs.h" -#ifndef NDEBUG +#ifdef DEVBUILD #include "dbg.h" #include "pragdefn.h" #include "togglesd.h" @@ -79,20 +79,7 @@ static unsigned bitMask[] = { // for bitfields }; -#ifdef NDEBUG -#define _fatal( x ) -#define _dump( x ) -#define _dumpPTree( x ) -#define _dumpSymbol( x ) -#define _dumpFullType( x ) -#define _dumpInt( x, y ) -#define _dumpPtr( x, y ) -#define _dumpInitInfo( x ) -#define _dumpDtorPtr( x, y ) -#define _dumpDtorInt( x, y ) -#define _dumpDtor( x ) -#define _dumpDtorSymbol( x ) -#else +#ifdef DEVBUILD #define __DUMP_INIT TOGGLEDBG( dump_init ) #define __DUMP_DTOR ( __DUMP_INIT || TOGGLEDBG( dump_data_dtor ) ) #define _fatal( x ) CFatal( x ) @@ -106,6 +93,19 @@ static unsigned bitMask[] = { // for bitfields #define _dumpDtorInt( x, y ) if( __DUMP_DTOR ) printf( x, y ) #define _dumpDtor( x ) if( __DUMP_DTOR ) puts( x ) #define _dumpDtorSymbol( x ) if( __DUMP_DTOR ) DumpSymbol( x ) +#else +#define _fatal( x ) +#define _dump( x ) +#define _dumpPTree( x ) +#define _dumpSymbol( x ) +#define _dumpFullType( x ) +#define _dumpInt( x, y ) +#define _dumpPtr( x, y ) +#define _dumpInitInfo( x ) +#define _dumpDtorPtr( x, y ) +#define _dumpDtorInt( x, y ) +#define _dumpDtor( x ) +#define _dumpDtorSymbol( x ) #endif diff --git a/bld/plusplus/c/decl.c b/bld/plusplus/c/decl.c index ac1fc6531d..94a4d6dfe0 100644 --- a/bld/plusplus/c/decl.c +++ b/bld/plusplus/c/decl.c @@ -333,7 +333,7 @@ void DeclDefaultStorageClass( SCOPE scope, SYMBOL sym ) case SCOPE_FUNCTION: sym->id = SYMC_AUTO; break; -#ifndef NDEBUG +#ifdef DEVBUILD case SCOPE_TEMPLATE_PARM: case SCOPE_TEMPLATE_SPEC_PARM: case SCOPE_TEMPLATE_DECL: diff --git a/bld/plusplus/c/defarg.c b/bld/plusplus/c/defarg.c index 204210d9a6..5731c853db 100644 --- a/bld/plusplus/c/defarg.c +++ b/bld/plusplus/c/defarg.c @@ -59,7 +59,7 @@ ExtraRptCtr( ctr_defargs_complex ); #define BLOCK_RELOC_LIST 16 static carve_t carveRELOC_LIST; -#ifndef NDEBUG +#ifdef DEVBUILD // for debugging, keep list of defarg ptree so we can free them in our // fini routine @@ -354,7 +354,7 @@ static void analyseDefaultExpr( // ANALYSE A DEFAULT ARGUMENT EXPRESSION expr = CastImplicit( expr, type_ret, CNV_FUNC_DARG, &diagDefarg ); } -#ifndef NDEBUG +#ifdef DEVBUILD if( expr != NULL && expr->op != PT_ERROR ) { int complex = 1; switch( expr->op ) { diff --git a/bld/plusplus/c/dupnode.c b/bld/plusplus/c/dupnode.c index a45bca2d45..0e5b199110 100644 --- a/bld/plusplus/c/dupnode.c +++ b/bld/plusplus/c/dupnode.c @@ -36,7 +36,7 @@ #include "carve.h" #include "ring.h" #include "initdefs.h" -#ifndef NDEBUG +#ifdef DEVBUILD #include "pragdefn.h" #include "dbg.h" #include "togglesd.h" @@ -59,7 +59,7 @@ static TOKEN_LOCN* exprPosition;// position for expression -#ifndef NDEBUG +#ifdef DEVBUILD static void printPromo ( PROMO const * promo @@ -217,7 +217,7 @@ static void setAncestor( // SET ANCESTRY FOR CURRENT NODE srch->container = NULL; } } RingIterEnd( srch ) -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_dups ) ) { printf( "Node %p ", zap_left ); printPromo( promo, "-- added to promotion ring" ); @@ -277,7 +277,7 @@ static PTREE dupProc( // PROCESS NODE IN TREE break; } } -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_dups ) && NULL != promoHdr ) { printf( "Node %p ", dup ); printPromoRing( promoHdr, "Duplicates Ring" ); @@ -293,7 +293,7 @@ PTREE NodePromoteDups( // PROMOTE/REMOVE DUPLICATE NODES { PROMO *promo; // - current promotion -#ifndef NDEBUG +#ifdef DEVBUILD DbgAssert( dup != NULL ); if( TOGGLEDBG( dump_dups ) ) { printf( "Original Tree\n\n" ); @@ -306,7 +306,7 @@ PTREE NodePromoteDups( // PROMOTE/REMOVE DUPLICATE NODES promoRing = NULL; dup = PTreeTraversePostfix( dup, &dupProc ); DbgVerify( promoHdr == NULL, "NodePromoteDups -- common nodes not found" ); -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_dups ) ) { printPromoRing( promoRing, "Promotion Ring" ); printf( "Original Tree\n\n" ); @@ -315,7 +315,7 @@ PTREE NodePromoteDups( // PROMOTE/REMOVE DUPLICATE NODES #endif RingIterBegSafe( promoRing, promo ) { dupPromote( promo ); -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_dups ) ) { printf( "promo[%p]: ", promo ); printPromo( promo, "Unduplicated Tree\n" ); diff --git a/bld/plusplus/c/dwarf.c b/bld/plusplus/c/dwarf.c index d7e5470361..ddb0bde37a 100644 --- a/bld/plusplus/c/dwarf.c +++ b/bld/plusplus/c/dwarf.c @@ -50,7 +50,7 @@ #include "name.h" #include "icopmask.h" #include "fmttype.h" -#ifndef NDEBUG +#ifdef DEVBUILD #include "dbg.h" #endif @@ -153,7 +153,7 @@ static void sym_reset( SYMBOL sym ) static void sym_update( SYMBOL sym, symbol_flag2 flags, dw_handle dh ) /********************************************************************/ { - #ifndef NDEBUG + #ifdef DEVBUILD if( sym->flag2 & SYMF2_CG_HANDLE ) { DumpSymbol( sym ); CFatal( "dwarf: handle for sym busy" ); @@ -1190,7 +1190,7 @@ static dw_handle dwarfType( TYPE type, DC_CONTROL control ) DbgStmt( CFatal( "dwarf: illegal type" ) ); break; } -#ifndef NDEBUG +#ifdef DEVBUILD if( dh == 0 && (control & DC_RETURN) == 0 ) { DumpFullType( type ); CFatal( "dwarf: unable to define type" ); @@ -1523,7 +1523,7 @@ static dw_handle dwarfData( SYMBOL sym ) dw_handle class_dh; uint flags; - #ifndef NDEBUG + #ifdef DEVBUILD if( sym->flag2 & SYMF2_DW_HANDLE_DEF ) { DumpSymbol( sym ); CFatal( "dwarf: data symbol already defined" ); @@ -1569,7 +1569,7 @@ static dw_handle dwarfDebugStatic( SYMBOL sym ) char *name; sym_reset( sym ); -#ifndef NDEBUG +#ifdef DEVBUILD if( sym->flag2 & SYMF2_DW_HANDLE_DEF ) { DumpSymbol( sym ); CFatal( "dwarf: data symbol already defined" ); @@ -1666,7 +1666,7 @@ static dw_handle dwarfSymbol( SYMBOL sym, DC_CONTROL control ) dh = dwarfFunction( sym, control ); } else if( SymIsData( sym ) ) { dh = dwarfData( sym ); -#ifndef NDEBUG +#ifdef DEVBUILD } else { DumpSymbol( sym ); CFatal( "dwarf: illegal symbol" ); @@ -1680,7 +1680,7 @@ static void doDwarfForwardFollowupClass( TYPE type, void *ignore ) { bool *keep_going = ignore; if( (type->dbgflag & TF2_DWARF) == TF2_DWARF_FWD ) { -#ifndef NDEBUG +#ifdef DEVBUILD if( type->flag & TF1_UNBOUND ) { DumpFullType( type ); CFatal( "dwarf: unbound template type in browser info" ); diff --git a/bld/plusplus/c/dwiobuff.c b/bld/plusplus/c/dwiobuff.c index 6e013d0eb1..293c0a80a0 100644 --- a/bld/plusplus/c/dwiobuff.c +++ b/bld/plusplus/c/dwiobuff.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -37,7 +37,7 @@ #include "iosupp.h" #include "dwiobuff.h" #include "ring.h" -#ifndef NDEBUG +#ifdef DEVBUILD #include "dbg.h" #endif diff --git a/bld/plusplus/c/extrf86.c b/bld/plusplus/c/extrf86.c index 073323f58f..9099c40af7 100644 --- a/bld/plusplus/c/extrf86.c +++ b/bld/plusplus/c/extrf86.c @@ -42,7 +42,7 @@ #include "vfun.h" #include "initdefs.h" #include "stats.h" -#ifndef NDEBUG +#ifdef DEVBUILD #include "dbg.h" #endif diff --git a/bld/plusplus/c/fmtmsg.c b/bld/plusplus/c/fmtmsg.c index baf55725a5..80951517bc 100644 --- a/bld/plusplus/c/fmtmsg.c +++ b/bld/plusplus/c/fmtmsg.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -39,7 +39,7 @@ #include "fmtsym.h" #include "fmtmsg.h" #include "template.h" -#ifndef NDEBUG +#ifdef DEVBUILD #include "dbg.h" #endif @@ -177,13 +177,13 @@ SYMBOL FormatMsg( VBUF *pbuf, char *fmt, va_list args ) formatClassForSym( sym, pbuf ); } else { sn = sym->name; -#ifndef NDEBUG +#ifdef DEVBUILD if( sn == NULL ) { CFatal( "FormatMsg -- %S symbol has NULL SYMBOL_NAME" ); } #endif name = sn->name; -#ifndef NDEBUG +#ifdef DEVBUILD if( name == NULL ) { CFatal( "FormatMsg -- %S SYMBOL_NAME has NULL name" ); } diff --git a/bld/plusplus/c/fmtsym.c b/bld/plusplus/c/fmtsym.c index 8082ef2917..0f282c3f2e 100644 --- a/bld/plusplus/c/fmtsym.c +++ b/bld/plusplus/c/fmtsym.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -37,7 +37,7 @@ #include "fmttype.h" #include "template.h" #include "fmtsym.h" -#ifndef NDEBUG +#ifdef DEVBUILD #include "dbg.h" #endif diff --git a/bld/plusplus/c/fmttype.c b/bld/plusplus/c/fmttype.c index e9351d4354..4c1423b598 100644 --- a/bld/plusplus/c/fmttype.c +++ b/bld/plusplus/c/fmttype.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -44,7 +44,7 @@ #include "initdefs.h" #include "ringfns.h" #include "template.h" -#ifndef NDEBUG +#ifdef DEVBUILD #include "dbg.h" #endif diff --git a/bld/plusplus/c/fnbody.c b/bld/plusplus/c/fnbody.c index b8a5ccc171..d22ff6d252 100644 --- a/bld/plusplus/c/fnbody.c +++ b/bld/plusplus/c/fnbody.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -54,7 +54,7 @@ #include "initdefs.h" #include "objmodel.h" #include "asmstmt.h" -#ifndef NDEBUG +#ifdef DEVBUILD #include "dbg.h" #include "pragdefn.h" #endif @@ -1606,7 +1606,7 @@ static void exceptSpec( // GENERATE AN EXCEPTION SPECIFICATION bool err_occurred; // - true ==> error during type-sig TypeSigFind( 0, except, NULL, &err_occurred ); -#ifndef NDEBUG +#ifdef DEVBUILD if( err_occurred ) { CFatal( "setExceptionSpecs -- unexpected error" ); } diff --git a/bld/plusplus/c/fnname.c b/bld/plusplus/c/fnname.c index a57046eab3..0e3155f08a 100644 --- a/bld/plusplus/c/fnname.c +++ b/bld/plusplus/c/fnname.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -386,7 +386,7 @@ static void appendBasedMod( // APPEND A BASED MODIFIER appendChar( IN_BASED_VOID ); break; case TF1_BASED_STRING: -#ifndef NDEBUG +#ifdef DEVBUILD if( base == NULL ) { CFatal( "invalid based modifier" ); } @@ -395,7 +395,7 @@ static void appendBasedMod( // APPEND A BASED MODIFIER appendBasedString( base ); break; case TF1_BASED_FETCH: -#ifndef NDEBUG +#ifdef DEVBUILD if( base == NULL ) { CFatal( "invalid based modifier" ); } @@ -405,7 +405,7 @@ static void appendBasedMod( // APPEND A BASED MODIFIER appendScopedSymName( base ); break; case TF1_BASED_ADD: -#ifndef NDEBUG +#ifdef DEVBUILD if( base == NULL ) { CFatal( "invalid based modifier" ); } @@ -414,7 +414,7 @@ static void appendBasedMod( // APPEND A BASED MODIFIER appendStr( IN_NAME_PREFIX ); appendScopedSymName( base ); break; -#ifndef NDEBUG +#ifdef DEVBUILD default: CFatal( "invalid based modifier" ); #endif @@ -780,7 +780,7 @@ bool CppLookupOperatorName( // FIND OPERATOR FOR NAME (false IF NOT FOUND) CGOP *oper ) // - index found { CGOP index; -#ifndef NDEBUG +#ifdef DEVBUILD CGOP i; #endif @@ -790,7 +790,7 @@ bool CppLookupOperatorName( // FIND OPERATOR FOR NAME (false IF NOT FOUND) // name is an operator ExtraRptIncrementCtr( ctr_lookups_slow ); index = (CGOP)( NameHash( name ) - NameHash( operatorNames[0] ) ); -#ifndef NDEBUG +#ifdef DEVBUILD operatorNames[MAX_OP_NAMES] = name; i = 0; for(;;) { @@ -1427,7 +1427,7 @@ static void cppNamesInit( // INITIALIZE NAMES FOR NAMES PROCESSING // use in CppLookupOperatorName will still work *op = operatorNames[*ap]; } else { -#ifndef NDEBUG +#ifdef DEVBUILD { const char **t; for( t = operatorNamesStr; t < cp; ++t ) { diff --git a/bld/plusplus/c/fnovload.c b/bld/plusplus/c/fnovload.c index c749d5b71a..87ccc11e2a 100644 --- a/bld/plusplus/c/fnovload.c +++ b/bld/plusplus/c/fnovload.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -44,7 +44,7 @@ #include "fmtsym.h" #include "template.h" #include "initdefs.h" -#ifndef NDEBUG +#ifdef DEVBUILD #include "dbg.h" #include "pragdefn.h" #include "togglesd.h" @@ -1728,7 +1728,7 @@ static FNOV_RESULT doOverload( FNOV_INFO* info ) } } -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_rank ) ) { printf( "\nOverloaded Symbol Resolution" ); PrintFnovResolution( result @@ -2046,7 +2046,7 @@ static FNOV_RESULT doFunctionDistinctCheck( FNOV_CONTROL control, SYMBOL *pold_s } } -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_rank ) ) { printf( "Overloaded Symbol Distinct Check" ); PrintFnovResolution( result @@ -2109,7 +2109,7 @@ bool IsOverloadedFunc( SYMBOL sym ) } } -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_rank ) ) { VBUF name; printf( "Function '%s' is%soverloaded\n", FormatSym( sym, &name ), ok ? " " : " not " ); @@ -2199,7 +2199,7 @@ bool IsActualOverloadedFunc( // TEST IF ACTUAL (IGNORE SYMC_DEFAULT) bool ok; ok = ( NULL == ActualNonOverloadedFunc( sym, result ) ); -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_rank ) ) { VBUF name; printf( "Function '%s' is%soverloaded (ignoring default arguments)\n", diff --git a/bld/plusplus/c/fnovrank.c b/bld/plusplus/c/fnovrank.c index 876504a19f..3cd33f53e1 100644 --- a/bld/plusplus/c/fnovrank.c +++ b/bld/plusplus/c/fnovrank.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2020 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -1398,7 +1398,7 @@ static uint_8 rkdTable[RKD_MAX][RKD_MAX] = // ranking-combinations table ExtraRptTable( type_combos, RKD_MAX, RKD_MAX ); // counts arg rankings -#ifndef NDEBUG +#ifdef DEVBUILD static int FNOV_infinite_ctr = 0; #define INFINITY 10 diff --git a/bld/plusplus/c/hashtab.c b/bld/plusplus/c/hashtab.c index 9fb9e1fc34..a92e1cfc8a 100644 --- a/bld/plusplus/c/hashtab.c +++ b/bld/plusplus/c/hashtab.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2020 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -45,7 +45,7 @@ #define MAX_HASH 4096 #define EXPAND_THRESHOLD 5 -#ifndef NDEBUG +#ifdef DEVBUILD #define MIN_HASHTAB_SIZE (1) // 2 items #else #define MIN_HASHTAB_SIZE (5) // 32 items @@ -76,7 +76,7 @@ struct hash_tab { unsigned expand_next; // next bucket to expand 0<=expand_nextuniques = 0; hash->looks = 0; hash->max_probes = 0; @@ -275,7 +275,7 @@ SYMBOL_NAME HashLookup( HASHTAB hash, NAME name ) DbgStmt( ++probes ); ExtraRptIncrementCtr( hash_lookup_cost ); } -#ifndef NDEBUG +#ifdef DEVBUILD hash->sum_probes += probes; if( probes > hash->max_probes ) { hash->max_probes = probes; @@ -294,7 +294,7 @@ SYMBOL_NAME HashLookup( HASHTAB hash, NAME name ) } -#ifndef NDEBUG +#ifdef DEVBUILD static double dragonStat( HASHTAB hash ) /*******************************/ { diff --git a/bld/plusplus/c/icemit.c b/bld/plusplus/c/icemit.c index fbd7f1db83..95ff62d767 100644 --- a/bld/plusplus/c/icemit.c +++ b/bld/plusplus/c/icemit.c @@ -48,7 +48,7 @@ #include "rtfuns.h" #include "specfuns.h" #include "objmodel.h" -#ifndef NDEBUG +#ifdef DEVBUILD #include "dbg.h" #include "togglesd.h" #endif @@ -423,7 +423,7 @@ static void exprCondEnd( // END OF CONDITIONAL DTORING, IF REQ'D } } -#ifndef NDEBUG +#ifdef DEVBUILD static bool klugedTyping( // DEBUG -- see if ptr/ref consistency TYPE t1, // - type[1] TYPE t2 ) // - type[2] @@ -510,7 +510,7 @@ static PTREE emitNode( // EMIT A PTREE NODE generate_type( expr ); CgFrontCodePtr( IC_LEAF_CONST_FLT, ConPoolFloatAdd( expr ) ); break; - #ifndef NDEBUG + #ifdef DEVBUILD case PT_DUP_EXPR : CFatal( "ICEMIT -- PT_DUP_EXPR not promoted away" ); break; @@ -912,7 +912,7 @@ PTREE IcEmitExpr( // EMIT EXPRESSION LabelExprBegin(); expr = NodePromoteDups( expr, &posn ); SrcPosnEmit( &posn ); -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( ic_trace_on ) ) { CgFrontCode( IC_TRACE_BEG ); TOGGLEDBG( ic_trace_on ) = false; diff --git a/bld/plusplus/c/ideentry.c b/bld/plusplus/c/ideentry.c index 7c74954fda..0aba57fe28 100644 --- a/bld/plusplus/c/ideentry.c +++ b/bld/plusplus/c/ideentry.c @@ -45,7 +45,7 @@ #include "clibext.h" -#ifndef NDEBUG +#ifdef DEVBUILD // #undef DbgVerify // #define DbgVerify(c,m) if( !(c) ) printIDE( "** IDEDLL **" m ) #endif @@ -59,7 +59,7 @@ typedef char NUMBER_STR[8]; // number string // MEMORY-ALLOCATION INTERFACE -#ifndef NDEBUG +#ifdef DEVBUILD #define allocMem( p ) CMemAlloc( p ) #else static void* allocMem // ALLOCATE MEMORY @@ -70,7 +70,7 @@ static void* allocMem // ALLOCATE MEMORY #endif -#ifndef NDEBUG +#ifdef DEVBUILD #define freeMem( p ) CMemFree( p ) #else static void freeMem // FREE MEMORY diff --git a/bld/plusplus/c/iosupp.c b/bld/plusplus/c/iosupp.c index 17d5b2d206..b77ba2cc76 100644 --- a/bld/plusplus/c/iosupp.c +++ b/bld/plusplus/c/iosupp.c @@ -792,7 +792,7 @@ char *IoSuppFullPath( // GET FULL PATH OF FILE NAME (ALWAYS USE RET VA unsigned size ) // - output buffer size { DbgAssert( size >= _MAX_PATH ); -#ifndef NDEBUG +#ifdef DEVBUILD // caller should use return value only! // - this code will make sure caller doesn't use buff *buff = '.'; diff --git a/bld/plusplus/c/linkage.c b/bld/plusplus/c/linkage.c index 0c69442f69..eccb4d91aa 100644 --- a/bld/plusplus/c/linkage.c +++ b/bld/plusplus/c/linkage.c @@ -167,7 +167,7 @@ LINKAGE LinkageMergePop( void ) LINKAGE top_linkage; /* extern "C" extern "C++" ==> extern "C++" */ -#ifndef NDEBUG +#ifdef DEVBUILD // both linkages must be non-block linkage scopes if(!(( nestedLinkages != NULL && nestedLinkages->block == 0 ) && ( nestedLinkages->prev != NULL && nestedLinkages->prev->block == 0 ))) { @@ -218,7 +218,7 @@ static void linkageFini( INITFINI* defn ) INITDEFN( linkage, linkageInit, linkageFini ) -#ifndef NDEBUG +#ifdef DEVBUILD static void verifyFileScopeSym( SYMBOL sym ) { if( ! ScopeType( SymScope( sym ), SCOPE_FILE ) ) { diff --git a/bld/plusplus/c/membptr.c b/bld/plusplus/c/membptr.c index f238208088..d561389b46 100644 --- a/bld/plusplus/c/membptr.c +++ b/bld/plusplus/c/membptr.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -39,7 +39,7 @@ #include "fold.h" #include "vfun.h" #include "initdefs.h" -#ifndef NDEBUG +#ifdef DEVBUILD #include "dbg.h" #include "pragdefn.h" #include "togglesd.h" @@ -632,7 +632,7 @@ static bool analyseMembPtr( // ANALYSE MEMBER-PTR OPERANDS } if( CNV_OK == ConversionDiagnose( cnv, expr, &diagMembPtrOps ) ) { ScopeMemberPtrCastAction( inf ); -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_mptr ) ) { DumpMemberPtrInfo( inf ); } diff --git a/bld/plusplus/c/memmgr.c b/bld/plusplus/c/memmgr.c index 207235e76d..2261ab4cd1 100644 --- a/bld/plusplus/c/memmgr.c +++ b/bld/plusplus/c/memmgr.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -40,7 +40,7 @@ #include "initdefs.h" #include "pragdefn.h" #include "codegen.h" -#ifndef NDEBUG +#ifdef DEVBUILD #include "togglesd.h" #endif @@ -68,7 +68,7 @@ typedef struct perm_blk { static CLEANPTR cleanupList; static PERMPTR permList; -#ifndef NDEBUG +#ifdef DEVBUILD static void *deferredFreeList; #endif @@ -131,7 +131,7 @@ void *CMemAlloc( size_t size ) if( size == 0 ) { return( NULL ); } -#ifndef NDEBUG +#ifdef DEVBUILD if( !TOGGLEDBG( no_mem_cleanup ) ) { CLEANPTR curr; static unsigned test_cleanup; @@ -188,7 +188,7 @@ void CMemFreePtr( void *pp ) } } -#ifndef NDEBUG +#ifdef DEVBUILD void CMemDeferredFree( void *p ) /******************************/ { @@ -289,7 +289,7 @@ static void cmemInit( // INITIALIZATION #elif defined( USE_CG_MEMMGT ) BEMemInit(); #endif -#ifndef NDEBUG +#ifdef DEVBUILD deferredFreeList = NULL; #endif cleanupList = NULL; @@ -303,11 +303,11 @@ static void cmemFini( // COMPLETION /* unused parameters */ (void)defn; RingFree( &permList ); -#ifndef NDEBUG +#ifdef DEVBUILD RingFree( &deferredFreeList ); #endif #ifdef TRMEM - #ifndef NDEBUG + #ifdef DEVBUILD if( TOGGLEDBG( dump_memory ) ) { _trmem_prt_list( trackerHdl ); } diff --git a/bld/plusplus/c/message.c b/bld/plusplus/c/message.c index 1f972503b0..cc002b9aee 100644 --- a/bld/plusplus/c/message.c +++ b/bld/plusplus/c/message.c @@ -55,7 +55,7 @@ #include "intlload.h" #include "ideentry.h" #include "cbanner.h" -#ifndef NDEBUG +#ifdef DEVBUILD #include "enterdb.h" #endif @@ -655,7 +655,7 @@ static msg_status_t doError( // ISSUE ERROR unsigned too_many : 1; // - true ==> too many messages } flag; -#ifndef NDEBUG +#ifdef DEVBUILD fflush(stdout); fflush(stderr); #endif diff --git a/bld/plusplus/c/name.c b/bld/plusplus/c/name.c index 884d0aed3f..c1d9a9bdc1 100644 --- a/bld/plusplus/c/name.c +++ b/bld/plusplus/c/name.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -40,7 +40,7 @@ #include "initdefs.h" #include "stats.h" #include "pcheader.h" -#ifndef NDEBUG +#ifdef DEVBUILD #include "pragdefn.h" #include "togglesd.h" #endif @@ -268,7 +268,7 @@ NAME NameDummy( void ) buff[1] = NAME_DUMMY_PREFIX2; // the contents of the name don't have to be different just the address // but for debugging it is handy to have unique contents -#ifndef NDEBUG +#ifdef DEVBUILD len = sprintf( buff + 2, "%u", ni ) + 2; #else buff[2] = '0'; @@ -316,7 +316,7 @@ pch_status PCHInitNames( bool writing ) } } qsort( nameTranslateTable, nameCount, sizeof( idname * ), cmpName ); -#ifndef NDEBUG +#ifdef DEVBUILD { for( i = 1; i < nameCount; ++i ) { if( nameTranslateTable[i - 1] == nameTranslateTable[i] ) { @@ -388,7 +388,7 @@ NAME NameMapIndex( NAME index ) if( PCHGetUInt( index ) < PCH_FIRST_INDEX ) { return( NULL ); } -#ifndef NDEBUG +#ifdef DEVBUILD if( PCHGetUInt( index ) >= nameCount + PCH_FIRST_INDEX ) { CFatal( "invalid name index" ); } @@ -422,7 +422,7 @@ NAME NameGetIndex( NAME name ) pname = NAME_PTR( name ); found = bsearch( &pname, nameTranslateTable, nameCount, sizeof( idname * ), cmpFindName ); if( found == NULL ) { -#ifndef NDEBUG +#ifdef DEVBUILD CFatal( "invalid name passed to NameGetIndex" ); #endif return( PCHSetUInt( PCH_ERROR_INDEX ) ); @@ -460,7 +460,7 @@ static void init( // INITIALIZATION ExtraRptRegisterMax( &ctr_max_length, "maximum name chain" ); } -#ifndef NDEBUG +#ifdef DEVBUILD static void dumpNames( void ) { unsigned sum; @@ -548,7 +548,7 @@ static void fini( // INITIALIZATION { /* unused parameters */ (void)defn; -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_names ) ) { dumpNames(); puts( "created name.lst" ); diff --git a/bld/plusplus/c/opovload.c b/bld/plusplus/c/opovload.c index 5c259e64b4..caa6e18fac 100644 --- a/bld/plusplus/c/opovload.c +++ b/bld/plusplus/c/opovload.c @@ -42,7 +42,7 @@ #include "stats.h" #include "template.h" #include "class.h" -#ifndef NDEBUG +#ifdef DEVBUILD #include "dbg.h" #endif @@ -158,7 +158,7 @@ typedef struct { // OLINF -- overload information unsigned have_user_type : 1; // - true ==> have a class,enum operand } OLINF; -#ifndef NDEBUG +#ifdef DEVBUILD void DumpOpovLoad // DEBUG -- DUMP ROUTINE ( OLINF* oli ) // - overload info ; @@ -1222,7 +1222,7 @@ pch_status PCHFiniOperatorOverloadData( bool writing ) } -#ifndef NDEBUG +#ifdef DEVBUILD static void dumpOVOP // DEBUG -- DUMP OVOP structure ( OVOP* ovop // - OVOP diff --git a/bld/plusplus/c/pcheader.c b/bld/plusplus/c/pcheader.c index 7b7e3fe96f..8a53f8156a 100644 --- a/bld/plusplus/c/pcheader.c +++ b/bld/plusplus/c/pcheader.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -96,7 +96,7 @@ static char *pchName; static NAME pchDebugInfoName; static int pchFile; -#ifndef NDEBUG +#ifdef DEVBUILD #define IO_BUFFER_SIZE 1024 #else #define IO_BUFFER_SIZE 65536 @@ -112,16 +112,7 @@ static long bufferPosition; static jmp_buf *abortData; -#ifdef NDEBUG - -#define PCHTrashAlreadyRead() - -void PCHActivate( void ) -/**********************/ -{ -} - -#else +#ifdef DEVBUILD static clock_t start_parse; @@ -139,6 +130,15 @@ void PCHActivate( void ) start_parse = clock(); } +#else + +#define PCHTrashAlreadyRead() + +void PCHActivate( void ) +/**********************/ +{ +} + #endif @@ -286,7 +286,7 @@ static void alignPCH( unsigned i, bool writing ) PCHRead( dummy, skip ); } } -#ifndef NDEBUG +#ifdef DEVBUILD if( writing ) { unsigned w = -i; PCHWriteUInt( w ); @@ -370,7 +370,7 @@ void PCHFlushBuffer( void ) } -#ifndef NDEBUG +#ifdef DEVBUILD void PCHVerifyFile( void *handle ) // DEBUG -- verify handle ok { DbgVerify( (int)(pointer_uint)handle == pchFile, "PCH handle is bad" ); @@ -478,7 +478,7 @@ void PCHeaderCreate( char *include_file ) char * volatile pch_fname; // must be preserved by setjmp() int status; jmp_buf restore_state; -#ifndef NDEBUG +#ifdef DEVBUILD clock_t start; clock_t stop; @@ -533,7 +533,7 @@ void PCHeaderCreate( char *include_file ) CompFlags.all_debug_type_names = true; } } -#ifndef NDEBUG +#ifdef DEVBUILD stop = clock(); printf( "%u ticks to parse header\n", (unsigned)( start - start_parse ) ); printf( "%u ticks to save pre-compiled header\n", (unsigned)( stop - start ) ); @@ -783,7 +783,7 @@ pch_absorb PCHeaderAbsorb( char *include_file ) pch_absorb ret; int status; jmp_buf restore_state; -#ifndef NDEBUG +#ifdef DEVBUILD clock_t start; clock_t stop; @@ -845,7 +845,7 @@ pch_absorb PCHeaderAbsorb( char *include_file ) if( CompFlags.pch_debug_info_opt && ret == PCHA_OK ) { CompFlags.pch_debug_info_read = true; } -#ifndef NDEBUG +#ifdef DEVBUILD stop = clock(); printf( "%u ticks to load pre-compiled header\n", (unsigned)( stop - start ) ); #endif @@ -1040,7 +1040,7 @@ void PCHPerformReloc( pch_reloc_index ri ) char *volatile pch_fname; // must be preserved by setjmp() int status; jmp_buf restore_state; -#ifndef NDEBUG +#ifdef DEVBUILD clock_t start; clock_t stop; @@ -1093,13 +1093,13 @@ void PCHPerformReloc( pch_reloc_index ri ) // write error occurred; delete PCH file remove( pch_fname ); } -#ifndef NDEBUG +#ifdef DEVBUILD stop = clock(); printf( "%u ticks to relocate pre-compiled header (%u section)\n", (unsigned)( stop - start ), ri ); #endif } -#ifndef NDEBUG +#ifdef DEVBUILD static char const * const pchRegionNames[] = { #define PCH_EXEC( a, b ) #a , #include "pcregdef.h" @@ -1118,7 +1118,7 @@ static void pchInit( INITFINI* defn ) for( cri = relocInfo; cri < &relocInfo[PCHRELOC_MAX]; ++cri ) { cri->start = 0; } -#ifndef NDEBUG +#ifdef DEVBUILD ExtraRptRegisterCtr( &ctr_pch_length, "# bytes in PCH" ); ExtraRptRegisterCtr( &ctr_pch_waste, "# bytes wasted in PCH for alignment" ); ExtraRptRegisterTab( "PCH region size table (pcregdef.h)", pchRegionNames, &ctr_pchw_region[0][0], PCHRW_MAX + 1, 1 ); diff --git a/bld/plusplus/c/plusplus.c b/bld/plusplus/c/plusplus.c index acf119c164..d87591bc34 100644 --- a/bld/plusplus/c/plusplus.c +++ b/bld/plusplus/c/plusplus.c @@ -60,7 +60,7 @@ #include "ialias.h" #include "ideentry.h" #include "pathgrp2.h" -#ifndef NDEBUG +#ifdef DEVBUILD #include "dbg.h" #include "pragdefn.h" #include "togglesd.h" @@ -351,7 +351,7 @@ static int doCCompile( // COMPILE C++ PROGRAM CtxSetCurrContext( CTX_ENDFILE ); ModuleInitFini(); ScopeEndFileScope(); -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_scopes ) ) { DumpScopes(); } @@ -466,7 +466,7 @@ static int front_end( // FRONT-END PROCESSING } else { exit_status = makeExitStatus( WPP_FATAL ); } -#ifndef NDEBUG +#ifdef DEVBUILD #if defined( __WATCOMC__ ) CheckEnterDebugger(); #endif @@ -531,7 +531,7 @@ static int compilePrimaryCmd( // COMPILE PRIMARY CMD LINE } -#ifndef NDEBUG +#ifdef DEVBUILD #define ZAP_NUM 20 #define ZAP_SIZE 1024 #define ZAP_CHAR 0xA7 @@ -575,7 +575,7 @@ int WppCompile( // MAIN-LINE (DLL) stackZap(); InitFiniStartup( &exitPointStart ); ExitPointAcquire( mem_management ); -#ifndef NDEBUG +#ifdef DEVBUILD DbgHeapInit(); #endif if( dll_data->cmd_line != NULL ) { @@ -627,7 +627,7 @@ int WppCompile( // MAIN-LINE (DLL) exit_status = WPP_FATAL; } } -#ifndef NDEBUG +#ifdef DEVBUILD DbgHeapFini(); #endif ExitPointRelease( mem_management ); diff --git a/bld/plusplus/c/ppexpn.c b/bld/plusplus/c/ppexpn.c index 3a8ead7d15..72df9b8879 100644 --- a/bld/plusplus/c/ppexpn.c +++ b/bld/plusplus/c/ppexpn.c @@ -40,7 +40,7 @@ #include "initdefs.h" #include "carve.h" #include "dumpapi.h" -#ifndef NDEBUG +#ifdef DEVBUILD #include "pragdefn.h" #include "togglesd.h" #endif @@ -129,7 +129,7 @@ static int Prec[] = { // table of token precedences #undef pick }; -#ifndef NDEBUG +#ifdef DEVBUILD void DbgDumpToken( TOKEN token ); void DbgDumpOperatorStack( void ) // dump PPEXPN_OPERATOR_STACK diff --git a/bld/plusplus/c/ptree.c b/bld/plusplus/c/ptree.c index 2cf803c10d..884e9272c7 100644 --- a/bld/plusplus/c/ptree.c +++ b/bld/plusplus/c/ptree.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2020 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -192,7 +192,7 @@ PTREE PTreeFree( PTREE tree ) float_handle fp_val; if( tree != NULL ) { -#ifndef NDEBUG +#ifdef DEVBUILD if( tree->op == PT_DUP_EXPR ) { if( tree->u.dup.subtree[0] != NULL ) { CFatal( "trying to free a duplicated expr with a dangling reference" ); diff --git a/bld/plusplus/c/ptreedec.c b/bld/plusplus/c/ptreedec.c index b7557b776c..406ed3ed10 100644 --- a/bld/plusplus/c/ptreedec.c +++ b/bld/plusplus/c/ptreedec.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -37,7 +37,7 @@ #include "initdefs.h" #include "fnbody.h" #include "pcheader.h" -#ifndef NDEBUG +#ifdef DEVBUILD #include "dbg.h" #include "fmttype.h" #endif @@ -631,7 +631,7 @@ static target_offset_t getOffset // SEARCH FOR OFFSET IN DECORATION ( PTREE expr // - expression , PTD_KIND kind ) // - decoration kind { -#ifndef NDEBUG +#ifdef DEVBUILD bool found = false; // - checks for found #endif PTD* ptd; // - current entry @@ -641,7 +641,7 @@ static target_offset_t getOffset // SEARCH FOR OFFSET IN DECORATION RingIterBeg( expr->decor, ptd ) { if( kind == ptd->base.kind ) { retn = ptd->off.offset; -#ifndef NDEBUG +#ifdef DEVBUILD DbgVerify( ! found, "Ptd::getOffset -- two decorations" ); found = true; #else @@ -1003,7 +1003,7 @@ pch_status PCHFiniPtds( bool writing ) } -#ifndef NDEBUG +#ifdef DEVBUILD static char const *name_kind[] = // names { diff --git a/bld/plusplus/c/rewrite.c b/bld/plusplus/c/rewrite.c index c5376d9107..4141fefa90 100644 --- a/bld/plusplus/c/rewrite.c +++ b/bld/plusplus/c/rewrite.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -44,7 +44,7 @@ #include "initdefs.h" #include "pcheader.h" #include "context.h" -#ifndef NDEBUG +#ifdef DEVBUILD #include "dbg.h" #endif @@ -1116,7 +1116,7 @@ void RewriteToken( void ) default: break; } -#ifndef NDEBUG +#ifdef DEVBUILD CtxScanToken(); DumpToken(); #endif diff --git a/bld/plusplus/c/rtngen.c b/bld/plusplus/c/rtngen.c index b8a214f882..146f8cecdb 100644 --- a/bld/plusplus/c/rtngen.c +++ b/bld/plusplus/c/rtngen.c @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -68,7 +69,7 @@ static RTN_GEN *findGenRoutine( RTN_GEN **head, unsigned index, void *parm ) { RTN_GEN *r; -#ifndef NDEBUG +#ifdef DEVBUILD if( parm == NULL ) { CFatal( "rtn gen parm must be non-NULL" ); } diff --git a/bld/plusplus/c/scope.c b/bld/plusplus/c/scope.c index d7855d99a9..a14baf8f6f 100644 --- a/bld/plusplus/c/scope.c +++ b/bld/plusplus/c/scope.c @@ -62,7 +62,7 @@ #include "fmtsym.h" #include "vfun.h" #include "yydriver.h" -#ifndef NDEBUG +#ifdef DEVBUILD #include "dbg.h" #include "togglesd.h" #endif @@ -316,7 +316,7 @@ extern SCOPE SetCurrScope(SCOPE newScope) SCOPE oldScope = g_CurrScope; g_CurrScope = newScope; -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_scopes ) ) { printf("Set new scope to 0x%p\n", newScope); @@ -402,7 +402,7 @@ static NAME_SPACE *allNameSpaces; // list of all namespaces static inherit_flag verifyAccess( access_data * ); static inherit_flag checkBaseAccess( SCOPE, SCOPE, derived_status ); -#ifndef NDEBUG +#ifdef DEVBUILD static void printScopeName( SCOPE scope, char *suffix ) { const char *name; @@ -931,7 +931,7 @@ static void addUsingDirective( SCOPE gets_using, SCOPE using_scope, SCOPE trigge USING_NS *using_entry; USING_NS *curr; -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_using_dir ) ) { printf( "using directive: in " ); printScopeName( gets_using, "using " ); @@ -959,7 +959,7 @@ static void addUsingDirective( SCOPE gets_using, SCOPE using_scope, SCOPE trigge RingAppend( &gets_using->using_list, using_entry ); addLexicalTrigger( trigger, using_scope, false ); -#ifndef NDEBUG +#ifdef DEVBUILD } else { USING_NS *curr; RingIterBeg( trigger->using_list, curr ) { @@ -1423,7 +1423,7 @@ void ScopeAdjustUsing( SCOPE prev_scope, SCOPE new_scope ) void ScopeJumpForward( SCOPE scope ) /**********************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD if( ! ScopeEnclosed( GetCurrScope(), scope ) ) { CFatal( "invalid scope jump forward" ); } @@ -1434,7 +1434,7 @@ void ScopeJumpForward( SCOPE scope ) void ScopeJumpBackward( SCOPE scope ) /***********************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD if( ! ScopeEnclosed( scope, GetCurrScope() ) ) { CFatal( "invalid scope jump backward" ); } @@ -1494,7 +1494,7 @@ SYMBOL ScopeOrderedFirst( SCOPE scope ) SYMBOL first; first = ScopeOrderedNext( ScopeOrderedStart( scope ), NULL ); -#ifndef NDEBUG +#ifdef DEVBUILD { SYMBOL curr; SYMBOL stop; @@ -1516,7 +1516,7 @@ SYMBOL ScopeOrderedLast( SCOPE scope ) SYMBOL last; last = ScopeOrderedStart( scope ); -#ifndef NDEBUG +#ifdef DEVBUILD { SYMBOL curr; SYMBOL stop; @@ -1632,7 +1632,7 @@ void ScopeEndFileScope( void ) SCOPE ScopeEnd( scope_type_t scope_type ) /***************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD if( GetCurrScope()->id != scope_type ) { CFatal( "scope terminated incorrectly" ); } @@ -2603,7 +2603,7 @@ unsigned ScopeRttiClasses( TYPE class_type ) return( count ); } -#ifndef NDEBUG +#ifdef DEVBUILD static walk_status verifyOfIsNull( BASE_STACK *top, void *parm ) { SCOPE scope; @@ -2822,7 +2822,7 @@ static derived_status isQuickScopeDerived( SCOPE derived, SCOPE possible_base ) { derived_walk data; -#ifndef NDEBUG +#ifdef DEVBUILD if( derived == NULL || ! _IsClassScope( derived ) ) { CFatal( "bad derived scope used for derivation check" ); } @@ -3610,7 +3610,7 @@ static walk_status memberSearch( BASE_STACK *top, void *parm ) } -#ifndef NDEBUG +#ifdef DEVBUILD static void dumpSearch( lookup_walk *data ) { PATH_CAP *cap; @@ -5334,7 +5334,7 @@ static void checkAmbiguousOverride( THUNK_ACTION *thunk, vftable_walk *data ) } override_scope = SymScope( override_sym ); base_sym = thunk->sym; -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_vftables ) ) { printf( "Searching for: base(" ); printSymbolName( base_sym ); @@ -5377,7 +5377,7 @@ static void checkAmbiguousOverride( THUNK_ACTION *thunk, vftable_walk *data ) test_sym = findOverride( top, NULL, base_sym ); if( test_sym != NULL ) { test_override_sym = test_sym; -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_vftables ) ) { printf( "found override(" ); printSymbolName( test_override_sym ); @@ -6922,7 +6922,7 @@ SCOPE ScopeHostClass( SCOPE class_scope ) { SCOPE next; -#ifndef NDEBUG +#ifdef DEVBUILD if( ! _IsClassScope( class_scope ) ) { CFatal( "ScopeHostClass passed a non-class scope" ); } diff --git a/bld/plusplus/c/segment.c b/bld/plusplus/c/segment.c index d352667e9f..f4e97ed2aa 100644 --- a/bld/plusplus/c/segment.c +++ b/bld/plusplus/c/segment.c @@ -1286,7 +1286,7 @@ void SegmentMarkUsed( // MARK SEGMENT AS BEING USED void SegmentCgDefineCode( // DEFINE CODE SEGMENT IF REQ'D fe_seg_id segid ) // - segment id { -#ifndef NDEBUG +#ifdef DEVBUILD PC_SEGMENT *seg; seg = segIdLookup( segid ); diff --git a/bld/plusplus/c/srcfile.c b/bld/plusplus/c/srcfile.c index 0b1f4250c0..900145b577 100644 --- a/bld/plusplus/c/srcfile.c +++ b/bld/plusplus/c/srcfile.c @@ -47,7 +47,7 @@ #include "initdefs.h" #include "iosupp.h" #include "pathlist.h" -#ifndef NDEBUG +#ifdef DEVBUILD #include "pragdefn.h" #include "togglesd.h" #endif @@ -87,7 +87,7 @@ enum { // GUARD STATE #undef GDEF }; -#ifndef NDEBUG +#ifdef DEVBUILD static const char *guardStateNames[] = { // - names of guard states #define GDEF( id ) #id , GUARD_DEFS @@ -157,7 +157,7 @@ static const struct tri_graph triGraphs[] = { #define _FIND_ACTUAL( curr ) for( ; curr->alias; curr = curr->sister ) -#ifndef NDEBUG +#ifdef DEVBUILD static OPEN_FILE *activeSrc( void ) { SRCFILE src; @@ -265,7 +265,7 @@ static void setGuardState( // SET GUARD STATE FOR CURRENT FILE actual = srcFile; _FIND_ACTUAL( actual ); -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_tokens ) ) { if( actual->guard_state != new_state ) { printf( "New Guard State[%s]: %s\n" diff --git a/bld/plusplus/c/stringl.c b/bld/plusplus/c/stringl.c index 39644e65d1..24fb9286d5 100644 --- a/bld/plusplus/c/stringl.c +++ b/bld/plusplus/c/stringl.c @@ -389,7 +389,7 @@ pch_status PCHInitStringPool( bool writing ) ++p; } qsort( stringTranslateTable, stringCount, sizeof( STRING_CONSTANT ), cmpString ); -#ifndef NDEBUG +#ifdef DEVBUILD { unsigned i; for( i = 1; i < stringCount; ++i ) { @@ -455,7 +455,7 @@ STRING_CONSTANT StringMapIndex( STRING_CONSTANT index ) if( PCHGetUInt( index ) < PCH_FIRST_INDEX ) { return( NULL ); } -#ifndef NDEBUG +#ifdef DEVBUILD if( PCHGetUInt( index ) >= stringCount + PCH_FIRST_INDEX ) { CFatal( "invalid string index" ); } diff --git a/bld/plusplus/c/symbol.c b/bld/plusplus/c/symbol.c index d1110b2a25..4a6e6a98b3 100644 --- a/bld/plusplus/c/symbol.c +++ b/bld/plusplus/c/symbol.c @@ -261,7 +261,7 @@ bool SymIsEnumDefinition( // TEST IF SYMBOL IS AN ENUMERATION } -#ifndef NDEBUG +#ifdef DEVBUILD SYMBOL SymDeAlias( // REDUCE TO NON-ALIASED SYMBOL SYMBOL sym ) // - the symbol { @@ -986,7 +986,7 @@ bool SymIsExtern( // SYMBOL IS DEFINED OUTSIDE THIS MODULE ok = true; } } -#ifndef NDEBUG +#ifdef DEVBUILD if( ok && !CompFlags.parsing_finished ) { // symbol still has a chance of being initialized! CFatal( "SymIsExtern return value is not accurate" ); @@ -1212,7 +1212,7 @@ SYMBOL SymDeriveThrowBits( // DERIVE SYMF_.._LONGJUMP BITS FROM SOURCE symbol_flag src_flag // - source flags = SymThrowFlags( src ); -#ifndef NDEBUG +#ifdef DEVBUILD if( src_flag & SYMF_LONGJUMP ) { DbgVerify( (tgt->flag & SYMF_NO_LONGJUMP) == 0 , "SymDeriveThrowBits -- target has SYMF_NO_LONGJUMP" ); diff --git a/bld/plusplus/c/symlocn.c b/bld/plusplus/c/symlocn.c index b5244376af..e9bbda7314 100644 --- a/bld/plusplus/c/symlocn.c +++ b/bld/plusplus/c/symlocn.c @@ -37,7 +37,7 @@ #include "toknlocn.h" #include "initdefs.h" #include "pcheader.h" -#ifndef NDEBUG +#ifdef DEVBUILD #include "dbg.h" #endif @@ -144,7 +144,7 @@ static void saveTokenLocn( void *e, carve_walk_base *d ) DbgAssert( b->u.dwh == 0 ); save_src_file = b->tl.src_file; b->tl.src_file = SrcFileGetIndex( save_src_file ); -#ifndef NDEBUG +#ifdef DEVBUILD if( b->u.dwh != 0 ) { CFatal( "token locn contains dwarf info!" ); } diff --git a/bld/plusplus/c/template.c b/bld/plusplus/c/template.c index b622c1e48f..2722a842cc 100644 --- a/bld/plusplus/c/template.c +++ b/bld/plusplus/c/template.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -47,7 +47,7 @@ #include "pcheader.h" #include "initdefs.h" #include "conpool.h" -#ifndef NDEBUG +#ifdef DEVBUILD #include "pragdefn.h" #include "dbg.h" #include "fmttype.h" @@ -192,7 +192,7 @@ static void displayActiveInstantiations( NESTED_POST_CONTEXT *blk ) { TEMPLATE_CONTEXT *ctx; -#ifndef NDEBUG +#ifdef DEVBUILD if( blk != &(activeInstantiations.registration) ) { CFatal( "registered call-back for template locations incorrect" ); } @@ -845,7 +845,7 @@ static void updateTemplatePartialOrdering( TEMPLATE_INFO *tinfo, bound = BindGenericTypes( parm_scope, tspec->spec_args, curr_spec->spec_args, false, 0 ); -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( templ_spec ) && bound ) { VBUF vbuf1; VBUF vbuf2; @@ -874,7 +874,7 @@ static void updateTemplatePartialOrdering( TEMPLATE_INFO *tinfo, bound = BindGenericTypes( parm_scope, curr_spec->spec_args, tspec->spec_args, false, 0 ); -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( templ_spec ) && bound ) { VBUF vbuf1; VBUF vbuf2; @@ -1407,7 +1407,7 @@ static DECL_INFO *attemptGen( arg_list *args, SYMBOL fn_templ, parm_scope = ScopeCreate( SCOPE_TEMPLATE_PARM ); ScopeSetEnclosing( parm_scope, decl_scope ); -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( templ_function ) ) { VBUF vbuf1, vbuf2; @@ -1504,7 +1504,7 @@ static DECL_INFO *attemptGen( arg_list *args, SYMBOL fn_templ, ScopeAdjustUsing( GetCurrScope(), save_scope ); SetCurrScope( save_scope ); } else if( fn_type != NULL ) { -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( templ_function ) ) { printf( "attemptGen: BindGenericTypes failed\n" ); } @@ -1513,7 +1513,7 @@ static DECL_INFO *attemptGen( arg_list *args, SYMBOL fn_templ, popInstContext(); } else { -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( templ_function ) ) { printf( "attemptGen: BindExplicitTemplateArguments failed\n" ); } @@ -1668,7 +1668,7 @@ SYMBOL TemplateFunctionGenerate( SYMBOL sym, arg_list *args, } } RingIterEnd( fn_inst ) -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( templ_function ) && ( generated_fn == NULL ) ) { VBUF vbuf1, vbuf2, vbuf3; FormatType( fn_type, &vbuf1, &vbuf2 ); @@ -2394,7 +2394,7 @@ findTemplateClassSpecialization( TEMPLATE_INFO *tinfo, PTREE parms, SCOPE *parm_ num_args = tprimary->num_args; ambiguous = false; -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( templ_spec ) && ( tinfo->nr_specs > 1 )) { VBUF vbuf; @@ -2419,7 +2419,7 @@ findTemplateClassSpecialization( TEMPLATE_INFO *tinfo, PTREE parms, SCOPE *parm_ bound = BindGenericTypes( parm_scope1, spec_list, parms, false, 0 ); if( bound ) { -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( templ_spec ) && ( tinfo->nr_specs > 1 ) ) { VBUF vbuf; @@ -2474,7 +2474,7 @@ findTemplateClassSpecialization( TEMPLATE_INFO *tinfo, PTREE parms, SCOPE *parm_ /* no matching specialization found, use primary template */ tspec = RingFirst( tinfo->specializations ); -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( templ_spec ) && ( tinfo->nr_specs > 1 )) { printf( "chose primary template %s ", NameStr( tinfo->sym->name->name ) ); DbgDumpTokenLocn( tinfo->sym->locn ); @@ -2490,7 +2490,7 @@ findTemplateClassSpecialization( TEMPLATE_INFO *tinfo, PTREE parms, SCOPE *parm_ RingFree( &candidate_list ); -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( templ_spec ) && ( tinfo->nr_specs > 1 )) { VBUF vbuf; @@ -2553,7 +2553,7 @@ TYPE TemplateClassReference( PTREE tid, PTREE parms ) UNBOUND_TEMPLATE *curr; unsigned int hash; -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( templ_inst ) ) { VBUF vbuf; @@ -2682,7 +2682,7 @@ static TYPE makeBoundClass( TYPE unbound_class, SCOPE parm_scope, tinfo = classUnboundTemplateInfo( unbound_class ); parms = fakeUpTemplateParms( parm_scope, type_args ); -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( templ_inst ) ) { VBUF vbuf; @@ -3020,7 +3020,7 @@ static void templateFunctionInstantiate( FN_TEMPLATE *fn_templ, DbgAssert( parm_scope->enclosing == SymScope( fn_sym ) ); ScopeSetParmFn( parm_scope, fn_sym->u.defn ); -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( templ_function ) ) { VBUF vbuf1, vbuf2, vbuf3; FormatType( bound_sym->sym_type, &vbuf1, &vbuf2 ); @@ -3151,7 +3151,7 @@ static void processInstantiationMembers( CLASS_INST *instance ) || ( sym->flag & SYMF_REFERENCED ) || ( sym->sym_type->flag & TF1_VIRTUAL ) ) { -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( member_inst ) ) { VBUF vbuf; printf( "instantiating %stemplate member: %s\n", diff --git a/bld/plusplus/c/type.c b/bld/plusplus/c/type.c index 664c5c1f6a..dc2b47d454 100644 --- a/bld/plusplus/c/type.c +++ b/bld/plusplus/c/type.c @@ -64,7 +64,7 @@ #include "rtti.h" #include "dumpapi.h" #include "compinfo.h" -#ifndef NDEBUG +#ifdef DEVBUILD #include "dbg.h" #include "togglesd.h" #endif @@ -957,7 +957,7 @@ static bool dupCompare( TYPE test1, TYPE test2 ) case TYP_POINTER: break; default: -#ifndef NDEBUG +#ifdef DEVBUILD CFatal( "unknown type being compared" ); #else return( false ); @@ -1065,7 +1065,7 @@ TYPE CheckDupType( TYPE newtype ) ExtraRptIncrementCtr( ctr_cg_dups ); } #endif -#ifndef NDEBUG +#ifdef DEVBUILD if( id == TYP_MODIFIER ) { if( newtype->flag == TF1_NULL ) { if( newtype->u.m.base == NULL ) { @@ -1237,7 +1237,7 @@ DECL_INFO *MakeNewDeclarator( DECL_SPEC *dspec,DECL_INFO *ptrs,DECL_INFO*arrays) FreeDeclInfo( ptrs ); } arrays = FinishDeclarator( dspec, arrays ); -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_types ) ) { DumpFullType( arrays->type ); } @@ -1526,7 +1526,7 @@ TYPE MakeTypeOf( // MAKE UNIQUE TYPE OF return( CheckDupType( new_type ) ); } -#ifndef NDEBUG +#ifdef DEVBUILD typedef struct { unsigned sum; @@ -2983,7 +2983,7 @@ static PTREE nameOfId( PTREE id ) if( ( id->op == PT_BINARY ) && ( id->cgop == CO_TEMPLATE ) ) { CFatal( "template-id not supported in this context" ); } -#ifndef NDEBUG +#ifdef DEVBUILD if( id->op != PT_BINARY || ( id->cgop != CO_COLON_COLON && id->cgop != CO_STORAGE )) { CFatal( "corrupted qualified id" ); } @@ -4047,7 +4047,7 @@ DECL_INFO *FinishDeclarator( DECL_SPEC *dspec, DECL_INFO *dinfo ) } } } -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_types ) ) { DumpFullType( prev_type ); } @@ -4081,7 +4081,7 @@ DECL_INFO *AddMSCVQualifierKludge( specifier_t spec, DECL_INFO *dinfo ) bool IdenticalClassModifiers( TYPE cmod1, TYPE cmod2 ) /****************************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD { TYPE test1 = cmod1; TYPE test2 = cmod2; @@ -4256,7 +4256,7 @@ void PTypeClassInstantiationUndo( DECL_SPEC *dspec ) PTREE id; /* must be kept in synch with PTypeActualTypeName/PTypeClassInstantiation */ -#ifndef NDEBUG +#ifdef DEVBUILD if( dspec->decl_checked || dspec->partial == NULL || ! dspec->class_instantiation || @@ -4998,7 +4998,7 @@ TYPE MakeFarPointerToNear( TYPE base ) { TYPE ptr_type; -#ifndef NDEBUG +#ifdef DEVBUILD { type_flag mod; @@ -7440,7 +7440,7 @@ static void pushArguments( PSTK_CTL *stk, arg_list *args ) for( i = args->num_args; i != 0; --i ) { type = *p; TypeStripTdMod( type ); -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_types ) ) { printf( "arg #%u\n", ( args->num_args - i ) + 1 ); DumpFullType( type ); @@ -7485,7 +7485,7 @@ static void pushPrototypeAndArguments( type_bind_info *data, a_type = NULL; } -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_types ) ) { printf( "p_arg #%u\n", i + 1 ); if( p->op == PT_TYPE ) { @@ -7670,7 +7670,7 @@ static void clearGenericBindings( PSTK_CTL *stk, SCOPE decl_scope ) bound_type->of = NULL; } break; -#ifndef NDEBUG +#ifdef DEVBUILD default: CFatal( "bound generic type corrupted" ); #endif @@ -8628,7 +8628,7 @@ static void markFreeType( void *p ) s->id = TYP_NONE; } -#ifndef NDEBUG +#ifdef DEVBUILD unsigned num_refs; static void initXrefType( void *e, carve_walk_base *d ) diff --git a/bld/plusplus/c/typecomp.c b/bld/plusplus/c/typecomp.c index e645468726..45925f84c4 100644 --- a/bld/plusplus/c/typecomp.c +++ b/bld/plusplus/c/typecomp.c @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -226,7 +227,7 @@ static bool typeCompareCurrent( TC_DATA **h, TYPE type1, TYPE type2, type_exclud case TYP_TYPENAME: return( !strcmp( type1->u.n.name, type2->u.n.name ) ); default: -#ifndef NDEBUG +#ifdef DEVBUILD CFatal( "unknown type being compared" ); #else return( false ); diff --git a/bld/plusplus/c/typesig.c b/bld/plusplus/c/typesig.c index f0962e66e9..830a5bf59c 100644 --- a/bld/plusplus/c/typesig.c +++ b/bld/plusplus/c/typesig.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2020 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -74,7 +74,7 @@ static SYMBOL DefaultCtorFind( // GET SYMBOL FOR DEFAULT CTOR case CNV_ERR : ctor = NULL; break; -#ifndef NDEBUG +#ifdef DEVBUILD default : CFatal( "DefaultCtorFind -- impossible return" ); #endif diff --git a/bld/plusplus/c/yydriver.c b/bld/plusplus/c/yydriver.c index ddad953145..b0aa390d31 100644 --- a/bld/plusplus/c/yydriver.c +++ b/bld/plusplus/c/yydriver.c @@ -28,7 +28,7 @@ YYDRIVER: driver code to make use of YACC generated parser tables and support #include "memmgr.h" #include "cgfront.h" #include "rtngen.h" -#ifndef NDEBUG +#ifdef DEVBUILD #include "pragdefn.h" #include "dbg.h" #include "togglesd.h" @@ -45,7 +45,7 @@ ExtraRptCtr( found_id ); // YY* definitions #define YYFAR -#ifndef NDEBUG +#ifdef DEVBUILD #define YYDEBUG #endif @@ -225,7 +225,7 @@ static void recordTemplateCtorInitializer( PARSE_STACK * ); #include "yylex.gh" -#ifndef NDEBUG +#ifdef DEVBUILD static void dump_rule( YYACTIONTYPE rule ) { @@ -753,7 +753,7 @@ static YYTOKENTYPE scopedChain( PARSE_STACK *state, PTREE start, PTREE id, case LK_NAMESPACE: return( Y_SCOPED_NAMESPACE_NAME ); } -#ifndef NDEBUG +#ifdef DEVBUILD CFatal( "unknown lexical category" ); #else return( Y_IMPOSSIBLE ); @@ -1023,7 +1023,7 @@ static YYTOKENTYPE yylex( PARSE_STACK *state ) if( token != Y_IMPOSSIBLE ) { return( token ); } -#ifndef NDEBUG +#ifdef DEVBUILD DbgZapMem( &yylval, 0xef, sizeof( yylval ) ); #endif switch( CurToken ) { @@ -1170,7 +1170,7 @@ void ParseFlush( void ) /*********************/ { if( tokenMakesPTREE( currToken ) && yylval.tree ) { -#ifndef NDEBUG +#ifdef DEVBUILD // NYI: we have a problem when this triggers! switch( currToken ) { case Y_GLOBAL_ID: @@ -1299,7 +1299,7 @@ static void pushUserDeclSpec( PARSE_STACK *state, DECL_SPEC *dspec ) static void zapTemplateClassDeclSpec( PARSE_STACK *state ) /********************************************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD if( GStackType( state->gstack ) != GS_DECL_SPEC ) { CFatal( "incorrect function template declaration" ); } @@ -1517,7 +1517,7 @@ static void deleteStack( PARSE_STACK *stack ) ScopeAdjustUsing( GetCurrScope(), stack->reset_scope ); SetCurrScope( stack->reset_scope ); check_stack = StackPop( &currParseStack ); -#ifndef NDEBUG +#ifdef DEVBUILD if( check_stack != stack ) { CFatal( "incorrect nesting of parse stacks" ); } @@ -1535,7 +1535,7 @@ static void pushRestartDecl( PARSE_STACK *state ) restart->gstack = state->gstack; restart->reset_scope = GetCurrScope(); -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_parse ) ) { printf( "===============================================================================\n" ); printf( "*** pushRestartDecl: 0x%p 0x%p\n", state, restart ); @@ -1554,7 +1554,7 @@ static void popRestartDecl( PARSE_STACK *state ) DbgStmt( RESTART_PARSE *restart ); DbgStmt( restart = state->restart ); -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_parse ) ) { printf( "===============================================================================\n" ); printf( "*** popRestartDecl: 0x%p 0x%p\n", state, restart ); @@ -1600,7 +1600,7 @@ static void syncToRestart( PARSE_STACK *state ) DbgAssert( restart->reset_scope == GetCurrScope() ); restartInit( state ); -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_parse ) ) { dump_state_stack("after syncToRestart", state); } @@ -1718,7 +1718,7 @@ static p_action normalYYAction( YYTOKENTYPE t, PARSE_STACK *state, YYACTIONTYPE /* we have a unit reduction */ lhs = yyplhstab[rule]; top_state = yyactiontab[lhs + yygotobase[ssp[-1]]]; -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_parse ) ) { printf( "=== Unit reduction. New top state %03u Old state %03u ===\n", top_state, ssp[0] ); } @@ -1741,7 +1741,7 @@ static void pushOperatorQualification( PTREE tree ) static void lookAheadShift( PARSE_STACK *state, YYACTIONTYPE new_state, YYTOKENTYPE t ) { -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_parse ) ) { puts( yytoknames[t] ); } @@ -1757,7 +1757,7 @@ static la_action lookAheadReduce( PARSE_STACK *state, YYACTIONTYPE new_rule ) { YYACTIONTYPE yyaction; -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_parse ) ) { dump_rule( new_rule ); } @@ -1841,13 +1841,13 @@ static void lookAheadUnsaveToken( PARSE_STACK *state, YYTOKENTYPE tok ) { look_ahead_storage *save; -#ifndef NDEBUG +#ifdef DEVBUILD if( state->use_saved_tokens ) { CFatal( "trying to unsave a saved token" ); } #endif save = VstkPop( &(state->look_ahead_storage) ); -#ifndef NDEBUG +#ifdef DEVBUILD if( save->yytok != tok ) { CFatal( "trying to unsave an unaligned saved token" ); } @@ -1921,13 +1921,13 @@ static YYACTIONTYPE lookAheadYYAction( YYTOKENTYPE t, PARSE_STACK *state, PARSE_ } newLookAheadStack( &look_ahead_expr_state, state ); newLookAheadStack( &look_ahead_decl_state, state ); -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_parse ) ) { printf( "expr...\n" ); } #endif lookAheadShift( &look_ahead_expr_state, YYAMBIGH0, t ); -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_parse ) ) { printf( "decl...\n" ); } @@ -1940,13 +1940,13 @@ static YYACTIONTYPE lookAheadYYAction( YYTOKENTYPE t, PARSE_STACK *state, PARSE_ nextYYLexToken( host ); t = yylex( host ); lookAheadSaveToken( host, t ); -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_parse ) ) { printf( "expr...\n" ); } #endif expr_what = lookAheadShiftReduce( t, &look_ahead_expr_state, host ); -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_parse ) ) { printf( "decl...\n" ); } @@ -2031,7 +2031,7 @@ static p_action doAction( YYTOKENTYPE t, PARSE_STACK *state ) state->expect = NULL; for( ;; ) { -#ifndef NDEBUG +#ifdef DEVBUILD unsigned stackDepth; #endif yyk = *(state->ssp); @@ -2042,7 +2042,7 @@ static p_action doAction( YYTOKENTYPE t, PARSE_STACK *state ) /* // DumpStack */ -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_parse ) ) { dump_state_stack("in start of doAction loop", state); } @@ -2078,7 +2078,7 @@ static p_action doAction( YYTOKENTYPE t, PARSE_STACK *state ) *curr_vsp = yylval; INC_STACK( lsp ); -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_parse ) ) { dump_state_stack("after yyaction shift", state); } @@ -2091,7 +2091,7 @@ static p_action doAction( YYTOKENTYPE t, PARSE_STACK *state ) pushOperatorQualification( yylval.tree ); break; } -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_parse ) ) { switch( t ) { case Y_ID: @@ -2117,7 +2117,7 @@ static p_action doAction( YYTOKENTYPE t, PARSE_STACK *state ) if( state->ssp < state->sstack ) { fatalParserError(); } -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_parse ) ) { printf( "=== Parser stack reduced by %u levels ===\n", yyl ); } @@ -2133,12 +2133,12 @@ static p_action doAction( YYTOKENTYPE t, PARSE_STACK *state ) INC_STACK( vsp ); yyvp = curr_vsp; yylp = state->lsp; -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_parse ) ) { dump_state_stack("shift / reduce?", state); } #endif -#ifndef NDEBUG +#ifdef DEVBUILD if( TOGGLEDBG( dump_parse ) ) { dump_rule( rule ); } @@ -2381,7 +2381,7 @@ static PTREE genericParseExpr( YYTOKENTYPE tok, TOKEN end_token, MSG_NUM err_msg break; } makeStable( end_token ); -#ifndef NDEBUG +#ifdef DEVBUILD } else { CFatal( "invalid return from doAction" ); #endif @@ -2458,7 +2458,7 @@ DECL_INFO *ParseException( void ) break; } makeStable( T_RIGHT_PAREN ); -#ifndef NDEBUG +#ifdef DEVBUILD } else { CFatal( "invalid return from doAction" ); #endif @@ -2532,7 +2532,7 @@ void ParseDecls( void ) /* we don't want the linkage reset */ ParseFlush(); syncLocation(); -#ifndef NDEBUG +#ifdef DEVBUILD } else { CFatal( "invalid return from doAction" ); #endif @@ -2606,7 +2606,7 @@ DECL_SPEC *ParseClassInstantiation( REWRITE *defn ) CErr1( ERR_COMPLICATED_DECLARATION ); break; } -#ifndef NDEBUG +#ifdef DEVBUILD } else { CFatal( "invalid return from doAction" ); #endif @@ -2681,7 +2681,7 @@ void ParseClassMemberInstantiation( REWRITE *defn ) CErr1( ERR_COMPLICATED_DECLARATION ); break; } -#ifndef NDEBUG +#ifdef DEVBUILD } else { CFatal( "invalid return from doAction" ); #endif @@ -2737,7 +2737,7 @@ void ParseFunctionInstantiation( REWRITE *defn ) CErr1( ERR_COMPLICATED_DECLARATION ); break; } -#ifndef NDEBUG +#ifdef DEVBUILD } else { CFatal( "invalid return from doAction" ); #endif diff --git a/bld/plusplus/h/callgrph.h b/bld/plusplus/h/callgrph.h index b746a1943a..b8b61399b2 100644 --- a/bld/plusplus/h/callgrph.h +++ b/bld/plusplus/h/callgrph.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2019 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -96,7 +96,7 @@ struct callgraph // CALLGRAPH INFORMATION boolbit scope_call_opt : 1; // - true ==> scope-call optimization enabled boolbit push_unresolved : 1; // - true ==> push unresolved function boolbit stmt_scope : 1; // - true == statement scope open -#ifndef NDEBUG +#ifdef DEVBUILD boolbit doing_rescan : 1; // - true ==> (debug only) rescanning #endif CALLNODE *curr_node; // - current node being processed diff --git a/bld/plusplus/h/carvecpp.h b/bld/plusplus/h/carvecpp.h index 2fe087f5fc..235d067f74 100644 --- a/bld/plusplus/h/carvecpp.h +++ b/bld/plusplus/h/carvecpp.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -40,12 +40,12 @@ #include "ring.h" #include "pcheader.h" #include "pragdefn.h" -#ifndef NDEBUG +#ifdef DEVBUILD # include "togglesd.h" #endif #define ERR_RET ( ErrCount != 0 ) #define ERR_SET ++ErrCount -#ifndef NDEBUG +#ifdef DEVBUILD # define DUMP_MEMORY #endif diff --git a/bld/plusplus/h/cgbackut.h b/bld/plusplus/h/cgbackut.h index a4f1129764..d1ff39507d 100644 --- a/bld/plusplus/h/cgbackut.h +++ b/bld/plusplus/h/cgbackut.h @@ -1148,7 +1148,7 @@ void FstabDeRegister( // DE-REGISTER FUNCTION void FstabRegister( // REGISTER FUNCTION FN_CTL *fctl ) // - function control ; -#ifndef NDEBUG +#ifdef DEVBUILD void FstabDump( // DEBUG ONLY: DUMP FUNCTION STATE TABLE void ) ; @@ -1427,7 +1427,7 @@ SE *StateTableCurrPosn( // GET STATE ENTRY FOR CURRENT POSITION void *SymTrans( // TRANSLATE SYMBOL/SCOPE void *src ) // - source value ; -#ifndef NDEBUG +#ifdef DEVBUILD void SymTransEmpty( // DEBUG: VERIFY SYMBOL TRANSLATIONS OVER void ) ; diff --git a/bld/plusplus/h/cgfront.h b/bld/plusplus/h/cgfront.h index 9e0b34a73f..9197ea36f2 100644 --- a/bld/plusplus/h/cgfront.h +++ b/bld/plusplus/h/cgfront.h @@ -1107,13 +1107,13 @@ PTREE NodeIntegralConstant // BUILD AN INTEGRAL NODE FOR A VALUE ( int val // - value , TYPE type ) // - node type (integral,enum,ptr) ; -#ifdef NDEBUG -#define NodeIsBinaryOp(node,op) ___NodeIsOp(node,op) -#else +#ifdef DEVBUILD bool NodeIsBinaryOp( // TEST IF BINARY OPERATION OF GIVEN TYPE PTREE node, // - node CGOP operation ) // - operation ; +#else +#define NodeIsBinaryOp(node,op) ___NodeIsOp(node,op) #endif bool NodeIsConstantInt( // TEST IF A CONSTANT INT NODE PTREE node ) // - node @@ -1130,13 +1130,13 @@ bool NodeIsIntConstant // TEST IF INTEGRAL CONSTANT AND GET VALUE ( PTREE node // - potential constant node , INT_CONSTANT* pval ) // - addr[ value ] ; -#ifdef NDEBUG -#define NodeIsUnaryOp(node,op) ___NodeIsOp(node,op) -#else +#ifdef DEVBUILD bool NodeIsUnaryOp( // TEST IF UNARY OPERATION OF GIVEN TYPE PTREE node, // - node CGOP operation ) // - operation ; +#else +#define NodeIsUnaryOp(node,op) ___NodeIsOp(node,op) #endif bool NodeIsZeroConstant( // TEST IF A ZERO CONSTANT PTREE node ) // - node diff --git a/bld/plusplus/h/cgio.h b/bld/plusplus/h/cgio.h index bf0f760b6b..3312b72635 100644 --- a/bld/plusplus/h/cgio.h +++ b/bld/plusplus/h/cgio.h @@ -172,7 +172,7 @@ CGINTER *CgioSeek( // SEEK TO POSITION IN VIRTUAL FILE CGFILE *ctl, // - control for the file CGFILE_INS *posn ) // - position to seek to ; -#ifndef NDEBUG +#ifdef DEVBUILD void DbgCgioEndCallGr( // CALLED AT END OF CALL-GRAPH PROCESSING void ) diff --git a/bld/plusplus/h/cgiobuff.h b/bld/plusplus/h/cgiobuff.h index eb81735074..a63b0773b7 100644 --- a/bld/plusplus/h/cgiobuff.h +++ b/bld/plusplus/h/cgiobuff.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -49,8 +50,7 @@ struct cgiobuff { // CGIOBUFF -- buffer in memory unsigned writing : 1; // - being written to now unsigned active : 1; // - block is active char data[TMPBLOCK_BSIZE]; // - buffer in memory -#ifndef NDEBUG - +#ifdef DEVBUILD int check; // - consistency check #endif }; diff --git a/bld/plusplus/h/context.h b/bld/plusplus/h/context.h index def6603cb0..ae3833faee 100644 --- a/bld/plusplus/h/context.h +++ b/bld/plusplus/h/context.h @@ -73,7 +73,7 @@ char const *CtxGetSwitchAddr( // GET ADDRESS OF CURRENT SWITCH // PROTOTYPES : debugging only (stubbed otherwise) -#ifndef NDEBUG +#ifdef DEVBUILD void CtxLine( // SET LINE BEING PROCESSED LINE_NO curr ) // - current line no. ; diff --git a/bld/plusplus/h/convctl.h b/bld/plusplus/h/convctl.h index 2fa3f77a25..9949132267 100644 --- a/bld/plusplus/h/convctl.h +++ b/bld/plusplus/h/convctl.h @@ -201,7 +201,7 @@ unsigned OldConvertExprDiagResult( // CONVERT AND DIAGNOSE RESULT CNV_DIAG *diagnosis ) // - diagnosis information ; #endif -#ifndef NDEBUG +#ifdef DEVBUILD void DbgConvType // DUMP CONVTYPE INFORMATION ( CONVTYPE* type ) // - structure ; diff --git a/bld/plusplus/h/dbg.h b/bld/plusplus/h/dbg.h index 7377b6b48e..6933960492 100644 --- a/bld/plusplus/h/dbg.h +++ b/bld/plusplus/h/dbg.h @@ -30,7 +30,7 @@ ****************************************************************************/ -#ifndef NDEBUG +#ifdef DEVBUILD #include "dbgzap.h" #include "iosupp.h" diff --git a/bld/plusplus/h/defarg.h b/bld/plusplus/h/defarg.h index 44260ba48c..49c5370453 100644 --- a/bld/plusplus/h/defarg.h +++ b/bld/plusplus/h/defarg.h @@ -47,7 +47,7 @@ void DefineDefaultValues( // MAKE DEFAULT VALUE FOR EACH DEFARG PARM DECL_INFO *dinfo // - function declaration information ); -#ifndef NDEBUG +#ifdef DEVBUILD void DefArgPCHWrite( void ); void DefArgPCHRead( void ); #else diff --git a/bld/plusplus/h/dumpapi.h b/bld/plusplus/h/dumpapi.h index 592142cfa6..e0718ea73d 100644 --- a/bld/plusplus/h/dumpapi.h +++ b/bld/plusplus/h/dumpapi.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -29,7 +30,7 @@ ****************************************************************************/ -#ifndef NDEBUG +#ifdef DEVBUILD extern void CallGraphDump( void ); extern void DumpBlkPosns( void ); diff --git a/bld/plusplus/h/fnovload.h b/bld/plusplus/h/fnovload.h index dd5d780cfb..640710fd3c 100644 --- a/bld/plusplus/h/fnovload.h +++ b/bld/plusplus/h/fnovload.h @@ -192,7 +192,7 @@ void FnovFreeDiag( // FREE MEMORY IN DIAGNOSIS LISTS FNOV_DIAG * // - pointer to struct containing list pointers ); -#ifndef NDEBUG +#ifdef DEVBUILD void PrintFnovList( FNOV_LIST *root ); void PrintFnovResolution( // PRETTY DISPLAY OF OVERLOAD RESOLUTION FNOV_RESULT result, // - resolution result diff --git a/bld/plusplus/h/hashtab.h b/bld/plusplus/h/hashtab.h index 61258ba155..6f68b16403 100644 --- a/bld/plusplus/h/hashtab.h +++ b/bld/plusplus/h/hashtab.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -49,7 +50,7 @@ extern void HashWalkData( HASHTAB, void (*)( SYMBOL_NAME, void * ), void * ); HASHTAB HashGetIndex( HASHTAB ); HASHTAB HashMapIndex( HASHTAB ); -#ifndef NDEBUG +#ifdef DEVBUILD void StatsHASHTAB( HASHTAB hash ); #endif diff --git a/bld/plusplus/h/ic.h b/bld/plusplus/h/ic.h index bbb84a9c46..60aedf324a 100644 --- a/bld/plusplus/h/ic.h +++ b/bld/plusplus/h/ic.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -280,7 +281,7 @@ , IC( IC_PARM_SCP, SCP, __x__ ) // - push a SCOPE on the IC code parm stack , IC( IC_PARM_XXX, NUL, __x__ ) // - padding -#if defined(_IN_ICMASK) || !defined(NDEBUG) +#if defined(_IN_ICMASK) || defined( DEVBUILD ) // Internal Debugging // ------------------------------------------ , IC( IC_TRACE_BEG, NUL, __x__ ) // - start IC instruction trace diff --git a/bld/plusplus/h/initspec.h b/bld/plusplus/h/initspec.h index 3c7b462811..fb475df134 100644 --- a/bld/plusplus/h/initspec.h +++ b/bld/plusplus/h/initspec.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -146,7 +146,7 @@ EXIT_END // - cg_typing must execute after the command line is processed // - dbg must be before scopes EXIT_BEG( cpp_object ) // analysis, code generation -#ifndef NDEBUG +#ifdef DEVBUILD EXIT_REG( dbg ) #endif EXIT_REG( global_stack ) @@ -174,7 +174,7 @@ EXIT_BEG( cpp_object ) // analysis, code generation EXIT_REG( node_promo ) EXIT_REG( segment ) //EXIT_REG( access_filter ) -#ifndef NDEBUG +#ifdef DEVBUILD EXIT_REG( comma_insertion ) #endif EXIT_END diff --git a/bld/plusplus/h/memmgr.h b/bld/plusplus/h/memmgr.h index 08abd8159e..1292ba71cf 100644 --- a/bld/plusplus/h/memmgr.h +++ b/bld/plusplus/h/memmgr.h @@ -40,7 +40,7 @@ extern void CMemFree( void * ); extern void CMemFreePtr( void * ); extern void *CPermAlloc( size_t ); -#ifndef NDEBUG +#ifdef DEVBUILD extern void CMemDeferredFree( void * ); #endif diff --git a/bld/plusplus/h/pcheader.h b/bld/plusplus/h/pcheader.h index 433e97cb64..c9f91d61b2 100644 --- a/bld/plusplus/h/pcheader.h +++ b/bld/plusplus/h/pcheader.h @@ -69,7 +69,7 @@ enum { // use a different signature for the debugging version of the compiler // since extra info may be written into the pre-compiled header file #define SIGNATURE_SIZE 4 -#ifndef NDEBUG +#ifdef DEVBUILD #define PHH_SIGNATURE_0 'D' #else #define PHH_SIGNATURE_0 'W' @@ -246,7 +246,7 @@ extern void *PCHReadCVIndexElement( cvinit_t * ); #ifdef OPT_BR extern long PCHSeek( long offset, int type ); #endif -#ifndef NDEBUG +#ifdef DEVBUILD extern void PCHVerifyFile( void *handle ); #else #define PCHVerifyHandle( handle ) handle = handle diff --git a/bld/plusplus/h/plusplus.h b/bld/plusplus/h/plusplus.h index ebcf8cad00..9b0b18111a 100644 --- a/bld/plusplus/h/plusplus.h +++ b/bld/plusplus/h/plusplus.h @@ -38,7 +38,7 @@ // 91/11/07 -- J.W.Welch -- placed common definitions in WCCP.H // 92/12/29 -- B.J. Stecher -- QNX support -#ifdef NDEBUG +#ifndef DEVBUILD #define NAME_PTR_IS_NAME_MEMBER #endif @@ -49,7 +49,7 @@ #include "bool.h" #include "wcpp.h" #include "target.h" -#ifndef NDEBUG +#ifdef DEVBUILD #include "enterdb.h" #endif #include "dbgzap.h" @@ -61,7 +61,7 @@ #define OPTIMIZE_EMPTY #define CARVEPCH -#ifndef NDEBUG +#ifdef DEVBUILD //#define OPT_BR // OPTIMA-STYLE BROWSING #endif @@ -111,7 +111,7 @@ typedef const struct idname *NAME; // name pointer #define FatalMsgExit(msg) CFatal( msg ) -#ifndef NDEBUG +#ifdef DEVBUILD #define __location " (" __FILE__ "," __xstr(__LINE__) ")" #define DbgVerify( cond, msg ) if( !( cond ) ) CFatal( msg __location ) #define DbgDefault( msg ) default: CFatal( msg __location ) diff --git a/bld/plusplus/h/ptreedec.h b/bld/plusplus/h/ptreedec.h index e28a926610..0be15fa994 100644 --- a/bld/plusplus/h/ptreedec.h +++ b/bld/plusplus/h/ptreedec.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -189,7 +190,7 @@ PTREE PtdGetOffsetofExpr( // GET OFFSETOF EXPR extern PTD *PtdGetIndex( PTD *e ); extern PTD *PtdMapIndex( PTD *e ); -#ifndef NDEBUG +#ifdef DEVBUILD // PROTOTYPES (Debugging only) diff --git a/bld/plusplus/h/symbol.h b/bld/plusplus/h/symbol.h index 324689f061..106f91bc1f 100644 --- a/bld/plusplus/h/symbol.h +++ b/bld/plusplus/h/symbol.h @@ -79,7 +79,7 @@ typedef enum { } scf_mask; // Protoypes: -#ifndef NDEBUG +#ifdef DEVBUILD SYMBOL SymDeAlias( // REDUCE TO NON-ALIASED SYMBOL SYMBOL sym ) // - the symbol ; diff --git a/bld/plusplus/h/tokenbuf.h b/bld/plusplus/h/tokenbuf.h index fda0cb55ce..7de0855b31 100644 --- a/bld/plusplus/h/tokenbuf.h +++ b/bld/plusplus/h/tokenbuf.h @@ -33,7 +33,7 @@ #ifndef _TOKENBUF_H #define _TOKENBUF_H -#ifndef NDEBUG +#ifdef DEVBUILD #define BUF_SZ (sizeof( TOKEN ) + 2) #else #define BUF_SZ (sizeof( TOKEN ) + 31) diff --git a/bld/plusplus/ppact/ppact.cpp b/bld/plusplus/ppact/ppact.cpp index 2cd1fcc10d..3d5223bced 100644 --- a/bld/plusplus/ppact/ppact.cpp +++ b/bld/plusplus/ppact/ppact.cpp @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2019 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -124,14 +124,14 @@ struct Options { unsigned verbose :1; // verbose printing unsigned actions :1; // echo actions file -#ifndef NDEBUG +#ifdef DEVBUILD unsigned pstack :1; // dump pstack #endif Options() // CONSTRUCTOR : verbose( 0 ) , actions( 0 ) -#ifndef NDEBUG +#ifdef DEVBUILD , pstack(0) #endif { @@ -557,7 +557,7 @@ struct ExpOp { static PrintStack& pstackTop(); // access top of stack -#ifndef NDEBUG +#ifdef DEVBUILD static pstackDump() { static char* state[] = @@ -694,7 +694,7 @@ void ExpOp::print // PRINT A TREE { pstackPush( this, NS_RIGHT_BEFORE, 0 ); for( ; ; ) { -#ifndef NDEBUG +#ifdef DEVBUILD if( options.pstack ) { pstackDump(); } @@ -2707,7 +2707,7 @@ static void processOptions // PROCESS OPTIONS puts( " h -- display help information" ); exit( 0 ); break; -#ifndef NDEBUG +#ifdef DEVBUILD case 'p' : options.pstack = 1; break; diff --git a/bld/posix/src/compress/compapi.c b/bld/posix/src/compress/compapi.c index 4266b1d576..7830f25d02 100644 --- a/bld/posix/src/compress/compapi.c +++ b/bld/posix/src/compress/compapi.c @@ -125,7 +125,7 @@ CONST CODE mc[] = { #define Maxcode(maxb) (mc[(maxb) -MINBITS]) #ifdef __STDC__ -#ifndef NDEBUG +#ifdef DEVBUILD #define allocx(type, ptr, size) \ (((ptr) = (type FAR *) emalloc((unsigned int)(size),sizeof(type))) == NULLPTR(type) \ ? (fprintf(stderr,"%s: "#ptr" -- ", prog_name), NOMEM) : OK \ @@ -297,7 +297,7 @@ int cl_block( void ) long rat; checkpoint = in_count + CHECK_GAP; -#ifndef NDEBUG +#ifdef DEVBUILD if ( debug ) { fprintf ( stderr, "count: %ld, ratio: ", in_count ); prratio ( stderr, in_count, bytes_out ); @@ -321,7 +321,7 @@ int cl_block( void ) } else { ratio = 0; -#ifndef NDEBUG +#ifdef DEVBUILD if(debug) fprintf ( stderr, "clear\n" ); #endif @@ -479,7 +479,7 @@ void compress( void ) * Print out stats on stderr */ if(!zcat_flg && !quiet) { -#ifndef NDEBUG +#ifdef DEVBUILD fprintf( stderr, "%ld chars in, (%ld bytes) out, compression factor: ", in_count, bytes_out ); @@ -493,7 +493,7 @@ void compress( void ) #else fprintf( stderr, "Compression: " ); prratio( stderr, in_count-bytes_out, in_count ); -#endif /* NDEBUG */ +#endif /* DEVBUILD */ } if(bytes_out > in_count) /* if no savings */ exit_stat = NOSAVING; @@ -532,10 +532,10 @@ void putcode(CODE code, int bits) offset = 0; } oldbits = bits; -#ifndef NDEBUG +#ifdef DEVBUILD if ( debug ) fprintf( stderr, "\nChange to %d bits\n", bits ); -#endif /* !NDEBUG */ +#endif /* !DEVBUILD */ } } /* Get to the first byte. */ @@ -666,7 +666,7 @@ void decompress( void ) * successive prefix tokens of the current token. Then output it. */ while (code >= 256) { -# if !defined(NDEBUG) +#ifdef DEVBUILD /* These are checks to ease paranoia. Prefix codes must decrease * monotonically, otherwise we must have corrupt tables. We can * also check that we haven't overrun the token buffer. @@ -679,7 +679,7 @@ void decompress( void ) exit_stat = TOKTOOBIG; return; } -# endif +#endif token[i++] = suffix(code); code = prefix(code); } diff --git a/bld/posix/src/compress/compress.c b/bld/posix/src/compress/compress.c index dfff1fca68..5bd717f601 100644 --- a/bld/posix/src/compress/compress.c +++ b/bld/posix/src/compress/compress.c @@ -183,7 +183,7 @@ int main( int argc, char **argv ) if (**argv == '-') { /* A flag argument */ while (*++(*argv)) { /* Process all flags in this arg */ switch (**argv) { -#if !defined(NDEBUG) +#ifdef DEVBUILD case 'D': debug = true; keep_error = true; @@ -196,7 +196,7 @@ int main( int argc, char **argv ) case 'V': version(); break; -#endif /*!NDEBUG */ +#endif /* !DEVBUILD */ case 'v': quiet = !quiet; break; @@ -477,7 +477,7 @@ static char *keep3 = "kill (erase)"; static char *on = "on"; static char *off = "off"; -#ifndef NDEBUG +#ifdef DEVBUILD fprintf(stderr,"Usage: %s [-cCdDf?hkKvV][-b maxbits][-Iinpath][-Ooutpath][filenames...]\n", prog_name); #else @@ -488,7 +488,7 @@ static char *off = "off"; return; fprintf(stderr,"Argument Processing..case is significant:\n"); fprintf(stderr," MUST use '-' for switch character\nAll flags are optional.\n"); -#ifndef NDEBUG +#ifdef DEVBUILD fprintf(stderr," -D => debug; Keep file on error.\n"); fprintf(stderr," -V => print Version; debug verbose\n"); #else diff --git a/bld/posix/src/compress/compress.h b/bld/posix/src/compress/compress.h index 8f7565a68e..3b22a4505b 100644 --- a/bld/posix/src/compress/compress.h +++ b/bld/posix/src/compress/compress.h @@ -290,10 +290,10 @@ char *malloc(); /* version, then files will be kept. */ #ifndef KEEPFLAG -#ifdef NDEBUG -#define KEEPFLAG false -#else +#ifdef DEVBUILD #define KEEPFLAG true +#else +#define KEEPFLAG false #endif #endif @@ -748,10 +748,10 @@ long checkpoint = CHECK_GAP; /* force the overwrite */ bool force = false; -#ifndef NDEBUG +#ifdef DEVBUILD bool verbose = VERBOSE; bool debug = false; -#endif /* !NDEBUG */ +#endif #ifndef NOSIGNAL SIGTYPE (*bgnd_flag)(); @@ -793,10 +793,10 @@ extern long checkpoint; #endif extern bool force; -#ifndef NDEBUG +#ifdef DEVBUILD extern bool verbose; extern bool debug; -#endif /* !NDEBUG */ +#endif #ifndef NOSIGNAL extern SIGTYPE (*bgnd_flag)(); diff --git a/bld/posix/src/compress/compusi.c b/bld/posix/src/compress/compusi.c index 5935f90213..596ab2b48b 100644 --- a/bld/posix/src/compress/compusi.c +++ b/bld/posix/src/compress/compusi.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -241,14 +241,14 @@ void copystat( void ) void version( void ) { #ifdef XENIX -#ifndef NDEBUG +#ifdef DEVBUILD fprintf(stderr, "%s\nOptions: Xenix %s MAXBITS = %d\n", rcs_ident, "DEBUG",MAXBITS); #else fprintf(stderr, "%s\nOptions: Xenix MAXBITS = %d\n", rcs_ident,MAXBITS); #endif #else -#ifndef NDEBUG +#ifdef DEVBUILD fprintf(stderr, "%s\nOptions: Unix %s MAXBITS = %d\n", rcs_ident, "DEBUG",MAXBITS); #else diff --git a/bld/rc/rc/c/exereslx.c b/bld/rc/rc/c/exereslx.c index dbb56fbca5..21bfd3586f 100644 --- a/bld/rc/rc/c/exereslx.c +++ b/bld/rc/rc/c/exereslx.c @@ -306,7 +306,7 @@ bool BuildLXResourceObjects( ExeFileInfo *dst, ResFileInfo *resfiles, dir->num_pages++; } -#ifndef NDEBUG +#ifdef DEVBUILD printf( " %d.%d (%d bytes)\n", entry->resource.name_id, entry->resource.type_id, entry->resource.res_size ); #endif @@ -323,7 +323,7 @@ bool BuildLXResourceObjects( ExeFileInfo *dst, ResFileInfo *resfiles, if( curr_total ) dir->num_pages++; -#ifndef NDEBUG +#ifdef DEVBUILD printf( "total size: %d bytes in %d page(s)\n", total, dir->num_pages ); #endif diff --git a/bld/vi/c/bprintf.c b/bld/vi/c/bprintf.c index 17965a5eee..50ce85c2d2 100644 --- a/bld/vi/c/bprintf.c +++ b/bld/vi/c/bprintf.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2015-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2015-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -93,7 +93,7 @@ void BasePrintf( const char *in, void(*out_fn)(char), va_list args ) case 's': tmp = va_arg( args, char * ); goto copyloop2; -#ifndef NDEBUG +#ifdef DEVBUILD case 'W': #ifdef _M_I86 i = va_arg( args, int ); diff --git a/bld/vi/c/fcbdmp.c b/bld/vi/c/fcbdmp.c index c6d203b654..d53eeb1744 100644 --- a/bld/vi/c/fcbdmp.c +++ b/bld/vi/c/fcbdmp.c @@ -33,15 +33,18 @@ #include "vi.h" #include "win.h" -#if !defined( NDEBUG ) && !defined( __WIN__ ) +#ifdef DEVBUILD +#if !defined( __WIN__ ) void CheckFcb( fcb *cfcb, int *bcnt, linenum *lnecnt ); static type_style errStyle = DEF_TEXT_STYLE; +#endif #endif -#if defined( __WATCOMC__ ) && !defined( NDEBUG ) +#if defined( __WATCOMC__ ) +#ifdef DEVBUILD #include static void HeapMsg( int msg ) @@ -68,10 +71,12 @@ static void HeapMsg( int msg ) } } /* HeapMsg */ #endif +#endif vi_rc HeapCheck( void ) { -#if defined( __WATCOMC__ ) && !defined( NDEBUG ) +#if defined( __WATCOMC__ ) +#ifdef DEVBUILD int i; struct _heapinfo hinfo; @@ -96,6 +101,7 @@ vi_rc HeapCheck( void ) break; } } +#endif #endif return( ERR_NO_ERR ); @@ -103,7 +109,8 @@ vi_rc HeapCheck( void ) vi_rc FcbDump( void ) { -#if !defined( NDEBUG ) && !defined( __WIN__ ) +#ifdef DEVBUILD +#if !defined( __WIN__ ) int lc, fcbcnt = 0; window_id wid; fcb *cfcb; @@ -145,6 +152,7 @@ vi_rc FcbDump( void ) } CloseAWindow( wid ); +#endif #endif return( ERR_NO_ERR ); @@ -152,7 +160,8 @@ vi_rc FcbDump( void ) vi_rc FcbThreadDump( void ) { -#if !defined( NDEBUG ) && !defined( __WIN__ ) +#ifdef DEVBUILD +#if !defined( __WIN__ ) int lc, fcbcnt = 0; window_id wid; char msg[80]; @@ -192,13 +201,15 @@ vi_rc FcbThreadDump( void ) } CloseAWindow( wid ); +#endif #endif return( ERR_NO_ERR ); } vi_rc SanityCheck( void ) { -#if !defined( NDEBUG ) && !defined( __WIN__ ) +#ifdef DEVBUILD +#if !defined( __WIN__ ) int lc, tfcbcnt = 0, fcbcnt, sum; window_id wid; fcb *cfcb; @@ -273,13 +284,15 @@ vi_rc SanityCheck( void ) EditFlags.BreakPressed = false; CloseAWindow( wid ); +#endif #endif return( ERR_NO_ERR ); } vi_rc LineInfo( void ) { -#if !defined( NDEBUG ) && !defined( __WIN__ ) +#ifdef DEVBUILD +#if !defined( __WIN__ ) fcb *cfcb; int fcbcnt = 1; int bcnt; @@ -293,6 +306,7 @@ vi_rc LineInfo( void ) CurrentLine->len, CurrentLine->len + 1, CurrentLine->prev, CurrentLine->next ); Message2( "Fcb %d: ptr=%W,bcnt=%d,lcnt=%l Fcb->prev=%W, Fcb->next=%W", fcbcnt, CurrentFcb, bcnt, lcnt, CurrentFcb->prev, CurrentFcb->next ); +#endif #endif return( ERR_NO_ERR ); } @@ -302,7 +316,8 @@ vi_rc LineInfo( void ) */ vi_rc WalkUndo( void ) { -#if !defined( NDEBUG ) && !defined( __WIN__ ) +#ifdef DEVBUILD +#if !defined( __WIN__ ) int ln, col, fcbcnt, depth; window_id wid; linenum lne, lcnt; @@ -369,12 +384,14 @@ vi_rc WalkUndo( void ) } } CloseAWindow( wid ); +#endif #endif return( ERR_NO_ERR ); } /* WalkUndo */ -#if !defined( NDEBUG ) && !defined( __WIN__ ) +#ifdef DEVBUILD +#if !defined( __WIN__ ) void CheckFcb( fcb *cfcb, int *bcnt, linenum *lnecnt ) { line *cline; @@ -388,3 +405,4 @@ void CheckFcb( fcb *cfcb, int *bcnt, linenum *lnecnt ) } /* CheckFcb */ #endif +#endif diff --git a/bld/vi/h/struct.h b/bld/vi/h/struct.h index 1a2101947c..5cf5f8f2ee 100644 --- a/bld/vi/h/struct.h +++ b/bld/vi/h/struct.h @@ -169,7 +169,7 @@ typedef struct { typedef const void _NEAR *window_id; #define NO_WINDOW ((window_id)NULL) #endif - #ifndef NDEBUG + #ifdef DEVBUILD #define BAD_ID(id) ((id) == NO_WINDOW || !IsWindow( id )) #else #define BAD_ID(id) ((id) == NO_WINDOW) diff --git a/bld/vi/ui/mouseev.c b/bld/vi/ui/mouseev.c index 0a279dad7b..9b670c3cf2 100644 --- a/bld/vi/ui/mouseev.c +++ b/bld/vi/ui/mouseev.c @@ -99,7 +99,7 @@ void PopMouseEventHandler( void ) if( mh != NULL ) { hookHead = hookHead->next; MemFree( mh ); -#ifndef NDEBUG +#ifdef DEVBUILD } else { Message1( "Popped null mouse event handler!!!" ); while( getchar() != ' ' ) { diff --git a/bld/vi/win/main.c b/bld/vi/win/main.c index da67b0be18..88bc6b8f0b 100644 --- a/bld/vi/win/main.c +++ b/bld/vi/win/main.c @@ -93,7 +93,9 @@ void FiniInstance( void ) // OLE2Fini(); } -#if defined( __WINDOWS__ ) && defined( __WATCOMC__ ) && !defined( NDEBUG ) && 0 +#if 0 +#if defined( __WINDOWS__ ) && defined( __WATCOMC__ ) +#ifdef DEVBUILD void _WCFAR *HeapWalker( void ) { struct _heapinfo info; @@ -114,6 +116,8 @@ void _WCFAR *HeapWalker( void ) return( NULL ); } #endif +#endif +#endif int PASCAL WinMain( HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show ) { diff --git a/bld/wasm/c/asmerr.c b/bld/wasm/c/asmerr.c index e4be9547f5..17da980c31 100644 --- a/bld/wasm/c/asmerr.c +++ b/bld/wasm/c/asmerr.c @@ -68,7 +68,7 @@ void DoDebugMsg( const char *format, ... ) } #endif -#ifndef NDEBUG +#ifdef DEVBUILD int InternalError( const char *file, unsigned line ) /**************************************************/ // it is used by myassert function in debug version diff --git a/bld/wasm/h/myassert.h b/bld/wasm/h/myassert.h index 336b97fbd2..afbfcf69a4 100644 --- a/bld/wasm/h/myassert.h +++ b/bld/wasm/h/myassert.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -33,12 +33,12 @@ #ifndef MYASSERT_H #define MYASSERT_H -#ifdef NDEBUG -# define never_reach() ((void)0) -# define myassert(expr) ((void)0) -#else +#ifdef DEVBUILD # define never_reach() InternalError(__FILE__,__LINE__) # define myassert(expr) ((void)((expr)?0:InternalError(__FILE__,__LINE__))) +#else +# define never_reach() ((void)0) +# define myassert(expr) ((void)0) #endif #endif diff --git a/bld/watcom/c/idedrv.c b/bld/watcom/c/idedrv.c index 5defe0255e..66a2ee37b2 100644 --- a/bld/watcom/c/idedrv.c +++ b/bld/watcom/c/idedrv.c @@ -251,7 +251,7 @@ static IDEBool IDEAPI stubPrintMsgFn( IDECBHdl hdl, char const *message ) { /* unused parameters */ (void)hdl; -#ifndef NDEBUG +#ifdef DEVBUILD fputs( "stubPrintMsgFn called!\n", stderr ); fputs( message, stderr ); fputc( '\n', stderr ); @@ -261,7 +261,7 @@ static IDEBool IDEAPI stubPrintMsgFn( IDECBHdl hdl, char const *message ) return( false ); } -#ifndef NDEBUG +#ifdef DEVBUILD static void IDEAPI printProgressIndex( IDECBHdl hdl, unsigned index ) { /* unused parameters */ (void)hdl; @@ -439,7 +439,7 @@ static void finiInterrupt( void ) #endif /* __UNIX__ */ } -#ifndef NDEBUG +#ifdef DEVBUILD #define _SET_PROGRESS \ if( getenv( "__idedrv_progress_messages" ) != NULL ) { info.progress_messages = 1; } \ if( getenv( "__idedrv_progress_index" ) != NULL ) { info.progress_index = 1; } diff --git a/bld/wic/c/carver.c b/bld/wic/c/carver.c index 1aa3775c4d..c764e58ad1 100644 --- a/bld/wic/c/carver.c +++ b/bld/wic/c/carver.c @@ -228,7 +228,7 @@ static void CreateNewCarverBlk(pCarver carver) { newBlk->next = carver->tail; carver->tail = newBlk; carver->topElem = (pBlkElem) (newBlk->data + nextBlockSize); - #ifndef NDEBUG + #ifdef DEVBUILD { char* ptr; for (ptr = newBlk->data; diff --git a/bld/wic/c/cmdline.c b/bld/wic/c/cmdline.c index 27e0a97aaf..a30f7d8258 100644 --- a/bld/wic/c/cmdline.c +++ b/bld/wic/c/cmdline.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2020 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -200,7 +200,7 @@ static void _scanCurrArg(char *currArg) { } break; -#ifndef NDEBUG +#ifdef DEVBUILD case 'd': g_opt.debug = 1; break; diff --git a/bld/wic/c/fmem.c b/bld/wic/c/fmem.c index 14bcc6ba7b..883abd23dc 100644 --- a/bld/wic/c/fmem.c +++ b/bld/wic/c/fmem.c @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -46,7 +47,7 @@ static struct { } fmem; typedef struct { -#ifndef NDEBUG +#ifdef DEVBUILD size_t bigSize; unsigned char check; #endif @@ -75,7 +76,7 @@ static void FMemMsg(FMemMsgType type, pFMemBigElem bigElem) { break; case FMEM_BIG_CORRUPTED: - #ifndef NDEBUG + #ifdef DEVBUILD sprintf(errStr, "FMEM: Big elem corrupted. Size %d; chkA5: %Xh; " "chk0: %Xh; data &%Xh", bigElem->bigSize, bigElem->check, @@ -173,7 +174,7 @@ void *FAlloc(size_t size) { } else { pFMemBigElem bigElem = fmem.allocFunc(sizeof *bigElem - 1 + size ); bigElem->smallSize.size = 0; -#ifndef NDEBUG +#ifdef DEVBUILD bigElem->bigSize = size; bigElem->check = 0xa5; #endif @@ -197,7 +198,7 @@ void FFree(void *elem) { } else { pFMemBigElem bigElem = (pFMemBigElem)((char*) elem - BIG_ELEM_PREFIX_SIZE); -#ifndef NDEBUG +#ifdef DEVBUILD if (bigElem->check != 0xa5 || adjustSize(bigElem->bigSize) != -1) { FMemMsg(FMEM_BIG_CORRUPTED, bigElem); return; diff --git a/bld/wic/c/output.c b/bld/wic/c/output.c index 227045a25e..29323d8765 100644 --- a/bld/wic/c/output.c +++ b/bld/wic/c/output.c @@ -241,7 +241,7 @@ static void _outputCurrAsmLine(int fnum, int continueToNextLine) { FILE *output = CURR_OUTPUT(fnum); int len = CURR_LINE_LEN(fnum); int flags = CURR_LINE_FLAGS(fnum); - #ifndef NDEBUG + #ifdef DEVBUILD if (g_opt.debug) { output = stdout; } @@ -285,7 +285,7 @@ static void _outputCurrFortLine(int fnum, int continueToNextLine) { int leftOverLen = 0; assert(fileStackLevel >= 0); - #ifndef NDEBUG + #ifdef DEVBUILD if (g_opt.debug) { output = stdout; } diff --git a/bld/wic/c/wicgener.c b/bld/wic/c/wicgener.c index 117ed90296..ad8358a5fc 100644 --- a/bld/wic/c/wicgener.c +++ b/bld/wic/c/wicgener.c @@ -435,13 +435,13 @@ void wicAssert( int exprTrue, char *expr, char *file, int line) } -#ifndef NDEBUG +#ifdef DEVBUILD static FILE *_debugFile; #endif void initDebug(void) { -#ifndef NDEBUG +#ifdef DEVBUILD _debugFile = wicFopen("debug.wic", "wt"); if (_debugFile == NULL) { reportError(ERR_CLOSE_FILE, strerror(errno)); @@ -451,7 +451,7 @@ void initDebug(void) void zapDebug() { -#ifndef NDEBUG +#ifdef DEVBUILD wicFclose(_debugFile); if (_fileNum != 0) { printf("DEBUG: _fileNum = %d != 0, at the end!", _fileNum); @@ -461,7 +461,7 @@ void zapDebug() void debugOut(char *format, ...) { -#ifndef NDEBUG +#ifdef DEVBUILD va_list args; va_start( args, format ); @@ -539,13 +539,13 @@ void dribble(void) newLineLen += sprintf(line+newLineLen, "%s", g_currFileName); newLineLen += sprintf(line+newLineLen, "(%d) ", g_currLineNum); } -#ifdef NDEBUG - newLineLen += sprintf(line+newLineLen, "TOTAL: %d SYM: %d ERR: %d", - g_totalNumLines, g_numSymbols, g_numErrNotDisp); -#else +#ifdef DEVBUILD newLineLen += sprintf(line+newLineLen, "TOTAL: %d SYM: %d MEM: %d ERR: %d", g_totalNumLines, g_numSymbols, g_memUsed, g_numErrNotDisp); +#else + newLineLen += sprintf(line+newLineLen, "TOTAL: %d SYM: %d ERR: %d", + g_totalNumLines, g_numSymbols, g_numErrNotDisp); #endif if (newLineLen > 79) { newLineLen = 79; diff --git a/bld/wic/c/wicstr.c b/bld/wic/c/wicstr.c index b14f40e270..c2c4b075dd 100644 --- a/bld/wic/c/wicstr.c +++ b/bld/wic/c/wicstr.c @@ -130,7 +130,7 @@ static void _zapStrEntry(void *_entry) { void zapStringTable(void) { int longestChainLen, numElems; getHTableStats(strTable, &numElems, &longestChainLen); - #ifndef NDEBUG + #ifdef DEVBUILD printf("Number of elements: %d; Longest chain length: %d\n", numElems, longestChainLen); #endif diff --git a/bld/wic/h/wicgener.h b/bld/wic/h/wicgener.h index d7939f41db..34d0e5947e 100644 --- a/bld/wic/h/wicgener.h +++ b/bld/wic/h/wicgener.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -77,14 +78,14 @@ void zapDebug(void); void wicAssert( int exprTrue, char *expr, char *file, int line); void debugOut(char *format, ...); -#ifdef NDEBUG - #define assert(__ignore) ((void)0) -#else +#ifdef DEVBUILD #if !defined( _NO_EXT_KEYS ) /* extensions enabled */ - #define assert(expr) ((expr)?(void)0:wicAssert(0,#expr,__FILE__,__LINE__)) + #define assert(expr) ((expr)?(void)0:wicAssert(0,#expr,__FILE__,__LINE__)) #else #define assert(expr) wicAssert(expr,#expr,__FILE__,__LINE__) #endif +#else + #define assert(__ignore) ((void)0) #endif /*-------------------------- File IO -----------------------------*/ diff --git a/bld/wl/c/carve.c b/bld/wl/c/carve.c index 95767c4b79..e4ee30579b 100644 --- a/bld/wl/c/carve.c +++ b/bld/wl/c/carve.c @@ -130,7 +130,7 @@ carve_t CarveCreate( unsigned elm_size, unsigned blk_size ) return( cv ); } -#ifndef NDEBUG +#ifdef DEVBUILD void CarveVerifyAllGone( carve_t cv, const char *node_name ) /**********************************************************/ { @@ -249,7 +249,7 @@ void *CarveZeroAlloc( carve_t cv ) } -#ifndef NDEBUG +#ifdef DEVBUILD static void CarveDebugFree( carve_t cv, void *elm ) { free_t *check; @@ -386,7 +386,7 @@ void CarveWalkAllFree( carve_t cv, void (*rtn)( void * ) ) free_t *check; for( check = cv->free_list; check != NULL; check = check->next_free ) { -#ifndef NDEBUG +#ifdef DEVBUILD free_t *check_next = check->next_free; (*rtn)( check ); if( check->next_free != check_next ) { diff --git a/bld/wl/c/cmdnov.c b/bld/wl/c/cmdnov.c index 5455e8f3f3..2bcd25bb43 100644 --- a/bld/wl/c/cmdnov.c +++ b/bld/wl/c/cmdnov.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -283,7 +283,7 @@ static bool GetNovSymbolImportExport( bool import ) result = SetCurrentPrefix( Token.this, Token.len ); if( result ) { Token.skipToNext = DoWeNeedToSkipASeparator( false ); -#ifndef NDEBUG +#ifdef DEVBUILD printf( "Set new prefix. Skip = %d\n", Token.skipToNext ); #endif } @@ -303,7 +303,7 @@ static bool GetNovSymbolImportExport( bool import ) if( sym == NULL || sym->p.import != NULL ) { return( true ); } -#ifndef NDEBUG +#ifdef DEVBUILD printf( "imported %s from %s\n", sym->name.u.ptr, ( sym->prefix != NULL ) ? sym->prefix : "(NONE)" ); #endif SET_SYM_TYPE( sym, SYM_IMPORTED ); diff --git a/bld/wl/c/permdata.c b/bld/wl/c/permdata.c index cabdceee24..28b497bb3d 100644 --- a/bld/wl/c/permdata.c +++ b/bld/wl/c/permdata.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -1009,7 +1009,7 @@ void FreeSavedRelocs( void ) void CleanPermData( void ) /*******************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD if( (LinkFlags & LF_INC_LINK_FLAG) == 0 ) { CarveVerifyAllGone( CarveLeader, "seg_leader" ); CarveVerifyAllGone( CarveModEntry, "mod_entry" ); diff --git a/bld/wl/c/ring.c b/bld/wl/c/ring.c index 9e2b244b9d..5d04145263 100644 --- a/bld/wl/c/ring.c +++ b/bld/wl/c/ring.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2020 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -76,7 +76,7 @@ struct ring // model of a ring } while( i != _T ); \ } -#ifndef NDEBUG +#ifdef DEVBUILD static void verifyNotInRing( RING *ring, RING *elt ) { RING *curr; diff --git a/bld/wl/c/wlmem.c b/bld/wl/c/wlmem.c index 9d70c60b60..b6c37e2789 100644 --- a/bld/wl/c/wlmem.c +++ b/bld/wl/c/wlmem.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2020 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -238,7 +238,7 @@ int ValidateMem( void ) #endif } -#ifndef NDEBUG +#ifdef DEVBUILD void DbgZapAlloc( void *tgt, size_t size ) /****************************************/ { diff --git a/bld/wl/h/alloc.h b/bld/wl/h/alloc.h index 8e96d709c5..25c7b36869 100644 --- a/bld/wl/h/alloc.h +++ b/bld/wl/h/alloc.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2020 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -59,7 +59,7 @@ extern void ReleasePass1Blocks( void ); extern int ValidateMem( void ); // just for debugging -#ifndef NDEBUG +#ifdef DEVBUILD void DbgZapAlloc( void* tgt, size_t size ); void DbgZapFreed( void* tgt, size_t size ); #else diff --git a/bld/wl/h/standard.h b/bld/wl/h/standard.h index 728ced7e77..6f07c63385 100644 --- a/bld/wl/h/standard.h +++ b/bld/wl/h/standard.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -58,7 +58,7 @@ #define __str( m ) #m #define __xstr( l ) __str( l ) -#ifndef NDEBUG +#ifdef DEVBUILD #define __location " (" __FILE__ "," __xstr(__LINE__) ")" #define DbgVerify( cond, msg ) if( !(cond) ) LnkFatal( msg __location ) #define DbgDefault( msg ) default: LnkFatal( msg __location ) diff --git a/bld/wmake/c/macros.c b/bld/wmake/c/macros.c index 9b38322495..7854c5aac5 100644 --- a/bld/wmake/c/macros.c +++ b/bld/wmake/c/macros.c @@ -1420,7 +1420,7 @@ void MacroInit( void ) } -#ifndef NDEBUG +#ifdef DEVBUILD STATIC bool freeMacro( MACRO *mac, const void *ptr ) /**************************************************/ { @@ -1437,7 +1437,7 @@ STATIC bool freeMacro( MACRO *mac, const void *ptr ) void MacroFini( void ) /***************************/ { -#ifndef NDEBUG +#ifdef DEVBUILD WalkHashTab( macTab, (bool (*)(void *,void *))freeMacro, NULL ); FreeHashTab( macTab ); macTab = NULL; diff --git a/bld/wmake/c/main.c b/bld/wmake/c/main.c index 8a2feaf714..2c82eefe04 100644 --- a/bld/wmake/c/main.c +++ b/bld/wmake/c/main.c @@ -614,7 +614,7 @@ static int ExitSafe( int rc ) if( rc == EXIT_ERROR || rc == EXIT_FATAL ) { PrtMsg( ERR | MAKE_ABORT ); } -#ifndef NDEBUG +#ifdef DEVBUILD while( filesToDo != NULL ) { NODE * const cur = filesToDo; filesToDo = cur->next; @@ -636,7 +636,7 @@ static int ExitSafe( int rc ) MacroFini(); CacheFini(); VecFini(); -#ifndef NDEBUG +#ifdef DEVBUILD SetEnvFini(); DLLFini(); #endif diff --git a/bld/wmake/c/mcache.c b/bld/wmake/c/mcache.c index 49105849e7..38034a57ce 100644 --- a/bld/wmake/c/mcache.c +++ b/bld/wmake/c/mcache.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2020 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -430,7 +430,7 @@ void CacheFini( void ) #ifdef CACHE_STATS Glob.cachestat = false; #endif - #ifndef NDEBUG + #ifdef DEVBUILD CacheRelease(); #endif #endif diff --git a/bld/wmake/c/msg.c b/bld/wmake/c/msg.c index 806227704a..3f137afa76 100644 --- a/bld/wmake/c/msg.c +++ b/bld/wmake/c/msg.c @@ -465,7 +465,7 @@ void PrtMsg( enum MsgClass num, ... ) #pragma off(check_stack); #endif -#if !defined( NDEBUG ) +#ifdef DEVBUILD void massert( const char *expr, const char *file, int line ) { PrtMsg( FTL | ASSERTION_FAILED, expr, file, line ); diff --git a/bld/wmake/c/msysdep.c b/bld/wmake/c/msysdep.c index af562fce19..c5752610e0 100644 --- a/bld/wmake/c/msysdep.c +++ b/bld/wmake/c/msysdep.c @@ -333,7 +333,7 @@ int OSExecDLL( DLL_CMD* dll, char const* cmd_args ) #endif -#ifndef NDEBUG +#ifdef DEVBUILD STATIC void cleanDLLCmd( void ) { #ifdef DLLS_IMPLEMENTED @@ -358,7 +358,7 @@ STATIC void cleanDLLCmd( void ) #endif -#ifndef NDEBUG +#ifdef DEVBUILD void DLLFini( void ) { cleanDLLCmd(); @@ -573,7 +573,7 @@ int SetEnvSafe( const char *name, const char *value ) } -#if !defined(NDEBUG) || defined(DEVELOPMENT) +#if defined( DEVBUILD ) || defined( DEVELOPMENT ) void SetEnvFini( void ) /*********************/ { diff --git a/bld/wmake/c/mtarget.c b/bld/wmake/c/mtarget.c index 71e4d26ea8..df6c8410bf 100644 --- a/bld/wmake/c/mtarget.c +++ b/bld/wmake/c/mtarget.c @@ -749,7 +749,7 @@ void CheckNoCmds( void ) } -#if defined( USE_SCARCE ) || !defined( NDEBUG ) +#if defined( USE_SCARCE ) || defined( DEVBUILD ) STATIC bool cleanupLeftovers( void ) /**********************************/ { @@ -829,7 +829,7 @@ void TargetInit( void ) } -#ifndef NDEBUG +#ifdef DEVBUILD STATIC bool walkFree( void *targ, void *ptr ) /*******************************************/ { @@ -844,7 +844,7 @@ STATIC bool walkFree( void *targ, void *ptr ) void TargetFini( void ) /*********************/ { -#ifndef NDEBUG +#ifdef DEVBUILD WalkHashTab( targTab, walkFree, NULL ); FreeHashTab( targTab ); targTab = NULL; diff --git a/bld/wmake/h/_msg.h b/bld/wmake/h/_msg.h index f8099b94e2..f4b6bb5746 100644 --- a/bld/wmake/h/_msg.h +++ b/bld/wmake/h/_msg.h @@ -47,7 +47,7 @@ pick( BANNER, banner1w( "Make", _WMAKE_VERSION_ ) "\n" banner2 "\n" banner2a( 19 * versions of WMake... */ -#ifndef NDEBUG +#ifdef DEVBUILD pick( ASSERTION_FAILED, "Assertion %E in %s(%d) failed" ) #endif diff --git a/bld/wmake/h/massert.h b/bld/wmake/h/massert.h index 9f48e88253..64e1af0f56 100644 --- a/bld/wmake/h/massert.h +++ b/bld/wmake/h/massert.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -34,10 +34,10 @@ #ifndef _MASSERT_H #define _MASSERT_H 1 -#ifdef NDEBUG -# define assert(expr) +#ifdef DEVBUILD +#define assert(expr) ((expr)?(void)0:massert( #expr, __FILE__, __LINE__ )) #else -# define assert(expr) ((expr)?(void)0:massert( #expr, __FILE__, __LINE__ )) +#define assert(expr) #endif #endif /* !_MASSERT_H */ diff --git a/bld/wmake/h/msg.h b/bld/wmake/h/msg.h index 4905e2cd3b..aa9128d0f5 100644 --- a/bld/wmake/h/msg.h +++ b/bld/wmake/h/msg.h @@ -64,7 +64,7 @@ enum { extern size_t FmtStr( char *buf, const char FAR *fmt, ... ); extern void PrtMsg( enum MsgClass num, ... ); extern void PrintBanner( void ); -#if !defined( NDEBUG ) +#ifdef DEVBUILD NO_RETURN( extern void massert( const char *expr, const char *file, int line ) ); #endif NO_RETURN( extern void Usage( void ) ); diff --git a/bld/wmake/h/msysdep.h b/bld/wmake/h/msysdep.h index 9186e53961..8e452a85e7 100644 --- a/bld/wmake/h/msysdep.h +++ b/bld/wmake/h/msysdep.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -43,7 +43,7 @@ // For debug versions, always use scarce memory manager - memory // leak checking depends on it -#ifndef NDEBUG +#ifdef DEVBUILD #define USE_SCARCE 1 #endif @@ -194,7 +194,7 @@ extern void DLLFini( void ); extern char *GetEnvExt( const char *str ); extern int SetEnvExt( ENV_TRACKER *env ); extern int SetEnvSafe( const char *name, const char *value ); -#if !defined(NDEBUG) || defined(DEVELOPMENT) +#if defined( DEVBUILD ) || defined( DEVELOPMENT ) extern void SetEnvFini( void ); #endif diff --git a/bld/womp/c/cantype.c b/bld/womp/c/cantype.c index f2d5794710..2800556449 100644 --- a/bld/womp/c/cantype.c +++ b/bld/womp/c/cantype.c @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -129,7 +130,7 @@ void CanTReUse( type_handle hdl ) { reUseHdl = hdl; } -#ifndef NDEBUG +#ifdef DEVBUILD STATIC int isOrdinalType( type_handle hdl ) { cantype *type; diff --git a/bld/womp/c/genutil.c b/bld/womp/c/genutil.c index 3cd67e7210..06c78a023d 100644 --- a/bld/womp/c/genutil.c +++ b/bld/womp/c/genutil.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -239,7 +239,7 @@ void Fatal2X( unsigned msg, uint_32 firstx, uint_32 secondx ) { } #endif -#ifndef NDEBUG +#ifdef DEVBUILD int InternalError( const char *file, unsigned line ) { /***************************************************/ diff --git a/bld/womp/c/wat2can1.c b/bld/womp/c/wat2can1.c index 20347035ce..8a07f7e6aa 100644 --- a/bld/womp/c/wat2can1.c +++ b/bld/womp/c/wat2can1.c @@ -45,7 +45,7 @@ #include "cansymb.h" #include "canmisc.h" #include "array.h" -#ifndef NDEBUG +#ifdef DEVBUILD #include #include #endif @@ -1332,7 +1332,7 @@ void Wat2CanTandS( seghdr *dd_types, seghdr *dd_symbols ) { wat->rec_len = 0; finish = ddTypes->data + ddTypes->alloc; wat->finish = finish; -#ifndef NDEBUG +#ifdef DEVBUILD { int fh; fh = open( "debug.seg", O_WRONLY|O_CREAT|O_TRUNC|O_BINARY, S_IWRITE|S_IREAD ); @@ -1361,7 +1361,7 @@ void Wat2CanTandS( seghdr *dd_types, seghdr *dd_symbols ) { wat->rec_len = 0; finish = ddSymbols->data + ddSymbols->alloc; wat->finish = finish; -#ifndef NDEBUG +#ifdef DEVBUILD { int fh; fh = open( "symbols.seg", O_WRONLY|O_CREAT|O_TRUNC|O_BINARY, S_IWRITE|S_IREAD ); diff --git a/bld/womp/h/myassert.h b/bld/womp/h/myassert.h index 7a8aa7f980..5190f23761 100644 --- a/bld/womp/h/myassert.h +++ b/bld/womp/h/myassert.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -40,12 +41,12 @@ extern int InternalError( const char *file, unsigned line ); #define __FNAME__ __FILE__ #endif -#ifdef NDEBUG -# define never_reach() ((void)0) -# define myassert(expr) ((void)0) -#else +#ifdef DEVBUILD # define never_reach() InternalError(__FNAME__,__LINE__) # define myassert(expr) ((void)((expr)?0:InternalError(__FNAME__,__LINE__))) +#else +# define never_reach() ((void)0) +# define myassert(expr) ((void)0) #endif #define MYASSERT_H 1 diff --git a/bld/wprof/c/utils.c b/bld/wprof/c/utils.c index 2bd9af7745..36b0c9f60f 100644 --- a/bld/wprof/c/utils.c +++ b/bld/wprof/c/utils.c @@ -300,7 +300,7 @@ void Ring( void ) #endif } -#ifndef NDEBUG +#ifdef DEVBUILD void AssertionFailed( char * file, unsigned line ) /************************************************/ { diff --git a/bld/wprof/c/wpmain.c b/bld/wprof/c/wpmain.c index cd796491e4..f416efba97 100644 --- a/bld/wprof/c/wpmain.c +++ b/bld/wprof/c/wpmain.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2017-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2017-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -97,7 +97,7 @@ bool WndProcMacro( a_window wnd, gui_key key ) case GUI_KEY_PERIOD: WPDoPopUp( wnd, NULL ); return( true ); -#ifndef NDEBUG +#ifdef DEVBUILD case GUI_KEY_CTRL_R: ReportSampleInfo(); return( true ); diff --git a/bld/wprof/c/wpstart.c b/bld/wprof/c/wpstart.c index 462d0b2c82..ecf4eed9c6 100644 --- a/bld/wprof/c/wpstart.c +++ b/bld/wprof/c/wpstart.c @@ -81,7 +81,7 @@ STATIC char * cmdNames[] = { #endif "?", "help", -#ifndef NDEBUG +#ifdef DEVBUILD "r", #endif NULL @@ -95,7 +95,7 @@ STATIC unsigned_8 cmdLen[] = { #endif 1, 1, -#ifndef NDEBUG +#ifdef DEVBUILD 1 #endif }; @@ -108,7 +108,7 @@ STATIC int cmdType[] = { #endif HELP_OPT, HELP_OPT, -#ifndef NDEBUG +#ifdef DEVBUILD R_OPT #endif }; @@ -270,7 +270,7 @@ STATIC bool procCmd( char * cmd ) WndStyle &= ~(GUI_CHARMAP_DLG|GUI_CHARMAP_MOUSE); break; #endif -#ifndef NDEBUG +#ifdef DEVBUILD case R_OPT: do_report = true; break; diff --git a/bld/wprof/h/myassert.h b/bld/wprof/h/myassert.h index e85c756c71..ba4f042119 100644 --- a/bld/wprof/h/myassert.h +++ b/bld/wprof/h/myassert.h @@ -34,14 +34,14 @@ #define MYASSERT_H 1 #undef myassert -#ifdef NDEBUG - #define myassert(ignore) -#else +#ifdef DEVBUILD extern void AssertionFailed( char *, unsigned int ); #if defined( __WATCOMC__ ) #pragma aux AssertionFailed __aborts #endif #define myassert(expr) if(!(expr)) AssertionFailed(__FILE__,__LINE__) +#else + #define myassert(ignore) #endif #endif diff --git a/bld/wv/c/dbgwintr.c b/bld/wv/c/dbgwintr.c index 6ce8e8c6cf..5b2a45eb7c 100644 --- a/bld/wv/c/dbgwintr.c +++ b/bld/wv/c/dbgwintr.c @@ -50,7 +50,7 @@ #include "dbgwintr.h" -#ifndef NDEBUG +#ifdef DEVBUILD extern void WndUserAdd(char *,unsigned int ); #endif @@ -59,7 +59,7 @@ static void BadCmd( void ) Error( ERR_LOC, LIT_ENG( ERR_BAD_SUBCOMMAND ), GetCmdName( CMD_WINDOW ) ); } -#ifndef NDEBUG +#ifdef DEVBUILD static void MenuCopy( char *dst, const char *from, char *to ) { char ampchar; @@ -177,7 +177,7 @@ static void (*InternalJmpTab[])() = void ProcInternal( void ) { -#ifndef NDEBUG +#ifdef DEVBUILD int cmd; cmd = ScanCmd( InternalNameTab ); diff --git a/bld/wv/c/dynmem.c b/bld/wv/c/dynmem.c index 855805ecf7..9a668dd81b 100644 --- a/bld/wv/c/dynmem.c +++ b/bld/wv/c/dynmem.c @@ -334,7 +334,7 @@ void MemFini( void ) return; h_info._pentry = NULL; while( (status = _heapwalk( &h_info )) == _HEAPOK ) { - #ifndef NDEBUG + #ifdef DEVBUILD if( h_info._useflag == _USEDENTRY ) { end = Format( buf, "%s block", h_info._useflag == _USEDENTRY ? "Used" : "Free" ); diff --git a/bld/wv/h/_dbgcmds.h b/bld/wv/h/_dbgcmds.h index 52d600ece7..a666eb1fdf 100644 --- a/bld/wv/h/_dbgcmds.h +++ b/bld/wv/h/_dbgcmds.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2020 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -70,6 +70,6 @@ pick( "SKip", CMD_SKIP, ProcSkip ) pick( "RECord", CMD_RECORD, ProcRecord ) pick( "ASsign", CMD_ASSIGN, ProcAssign ) pick( "MOdify", CMD_MODIFY, ProcModify ) -#ifndef NDEBUG +#ifdef DEVBUILD pick( "XX", CMD_INTERNAL, ProcInternal ) #endif From 042d7bf643b25f04e52eced6f030e7d4773bf1bc Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Wed, 20 Sep 2023 08:57:45 +0200 Subject: [PATCH 150/258] add POSIX pre-release endian.h header file to OW --- bld/hdr/files.dat | 5 ++ bld/hdr/hfiles.mif | 5 ++ bld/hdr/master.mif | 5 +- bld/hdr/watcom/deps.mif | 5 ++ bld/hdr/watcom/endian.mh | 63 ++++++++++++++++++++ bld/hdr/watcom/linux/arch/i386/sys/endian.mh | 22 +++++++ bld/hdr/watcom/linux/arch/mips/sys/endian.mh | 22 +++++++ bld/hdr/watcom/linux/arch/ppc/sys/endian.mh | 22 +++++++ 8 files changed, 148 insertions(+), 1 deletion(-) create mode 100644 bld/hdr/watcom/endian.mh create mode 100644 bld/hdr/watcom/linux/arch/i386/sys/endian.mh create mode 100644 bld/hdr/watcom/linux/arch/mips/sys/endian.mh create mode 100644 bld/hdr/watcom/linux/arch/ppc/sys/endian.mh diff --git a/bld/hdr/files.dat b/bld/hdr/files.dat index ce9d7daca7..c3898e302b 100644 --- a/bld/hdr/files.dat +++ b/bld/hdr/files.dat @@ -41,6 +41,7 @@ usr="crtdbg.h" usr="direct.h" usr="dos.h" usr="dosfunc.h" +usr="endian.h" usr="env.h" usr="excpt.h" usr="fcntl.h" @@ -250,6 +251,7 @@ usr="alloca.h" usr="conio.h" usr="crtdbg.h" usr="direct.h" +usr="endian.h" usr="env.h" usr="excpt.h" usr="fcntl.h" @@ -456,6 +458,7 @@ usr="alloca.h" usr="conio.h" usr="crtdbg.h" usr="dirent.h" +usr="endian.h" usr="env.h" usr="excpt.h" usr="fcntl.h" @@ -638,6 +641,7 @@ usr="in.h" usr="tcp.h" [ DEFAULT type="s" dir="lh/arch/i386" where="c jc f77 jf77 ac" cond="lnxtarg" ] +usr="endian.h" usr="err_no.h" usr="fcntl.h" usr="siginfo.h" @@ -657,6 +661,7 @@ usr="types.h" usr="sysmips.h" [ DEFAULT type="s" dir="lh/arch/mips" where="mc" cond="lnxtarg" ] +usr="endian.h" usr="err_no.h" usr="fcntl.h" usr="siginfo.h" diff --git a/bld/hdr/hfiles.mif b/bld/hdr/hfiles.mif index 446b80d357..54ee403139 100644 --- a/bld/hdr/hfiles.mif +++ b/bld/hdr/hfiles.mif @@ -54,6 +54,7 @@ !inject h/dirent.h hlnx hqnx !inject h/dos.h hdos !inject h/dosfunc.h hdos +!inject h/endian.h hdos hlnx hqnx hrdos !inject h/eh.h hdos !inject h/env.h hdos hlnx hqnx hrdos !inject h/errno.h hdos hlnx hqnx hrdos @@ -217,6 +218,7 @@ !inject h/arch/i386/siginfo.h hlnx !inject h/arch/i386/signal.h hlnx !inject h/arch/i386/sigposix.h hlnx +!inject h/arch/i386/sys/endian.h hlnx !inject h/arch/i386/sys/ioctl.h hlnx !inject h/arch/i386/sys/resource.h hlnx !inject h/arch/i386/sys/socket.h hlnx @@ -228,12 +230,15 @@ !inject h/arch/mips/siginfo.h hlnx !inject h/arch/mips/signal.h hlnx !inject h/arch/mips/sigposix.h hlnx +!inject h/arch/mips/sys/endian.h hlnx !inject h/arch/mips/sys/ioctl.h hlnx !inject h/arch/mips/sys/resource.h hlnx !inject h/arch/mips/sys/socket.h hlnx !inject h/arch/mips/sys/stat.h hlnx !inject h/arch/mips/sys/sysmacro.h hlnx !inject h/arch/mips/sys/types.h hlnx +!inject h/arch/ppc/err_no.h hlnx +!inject h/arch/ppc/sys/endian.h hlnx !inject h/arpa/inet.h hlnx hrdos !inject h/netinet/in.h hlnx hrdos !inject h/netinet/tcp.h hlnx hrdos diff --git a/bld/hdr/master.mif b/bld/hdr/master.mif index 4ffd12523c..f091effb19 100644 --- a/bld/hdr/master.mif +++ b/bld/hdr/master.mif @@ -27,7 +27,10 @@ wsplice_opts_ppc = $(wsplice_extra_opts) -i.. -kARCHPPC $($(system)_options) .. # DOS can create only simple sub-directory in existing directory # you must create parent before child directory dos_dirs = h h/sys -linux_dirs = h h/sys h/netinet h/arpa h/arch h/arch/i386 h/arch/i386/sys h/arch/mips h/arch/mips/sys h/arch/ppc h/arch/ppc/sys +linux_i386_arch_dirs = h/arch/i386 h/arch/i386/sys +linux_mips_arch_dirs = h/arch/mips h/arch/mips/sys +linux_ppc_arch_dirs = h/arch/ppc h/arch/ppc/sys +linux_dirs = h h/sys h/netinet h/arpa h/arch $(linux_i386_arch_dirs) $(linux_mips_arch_dirs) $(linux_ppc_arch_dirs) qnx_dirs = h h/sys rdos_dirs = h h/sys h/netinet h/arpa diff --git a/bld/hdr/watcom/deps.mif b/bld/hdr/watcom/deps.mif index 147349f426..5790ffa7ed 100644 --- a/bld/hdr/watcom/deps.mif +++ b/bld/hdr/watcom/deps.mif @@ -210,6 +210,7 @@ h/direct.h : $(mh_dir)/direct.mh $(owhdr) ../lfndos.sp ../systypes.sp $(c h/dos.h : $(mh_dir)/dos.mh $(owhdr) ../lfndos.sp $(cplus) $(packll) ../wchar_t.sp $(maxpath_sp) ../dskfreet.sp ../delay.sp h/dosfunc.h : $(mh_dir)/dosfunc.mh $(owhdr) h/eh.h : $(mh_dir)/eh.mh $(owhdr) ../cpponly.sp +h/endian.h : $(mh_dir)/endian.mh $(owhdrcnt) $(posixext) h/env.h : $(mh_dir)/env.mh $(owhdr) $(cplus) ../wchar_t.sp ../getenv.sp ../putenv.sp ../setenv.sp ../unsetenv.sp $(posixext) h/errno.h : $(errno_deps) h/except.h : $(mh_dir)/except.mh $(owhdr) ../cpponly.sp ../cpppfv.sp ../watexc.sp ../except.sp @@ -354,6 +355,7 @@ h/arch/i386/fcntl.h : $(mh_dir)/linux/arch/i386/fcntl.mh $(crwatcnt_sp) . h/arch/i386/siginfo.h : $(mh_dir)/linux/arch/i386/siginfo.mh $(crwatcnt_sp) ../clock_t.sp h/arch/i386/signal.h : $(mh_dir)/linux/arch/i386/signal.mh $(crwatcnt_sp) h/arch/i386/sigposix.h : $(mh_dir)/linux/arch/i386/sigposix.mh $(crwatcnt_sp) +h/arch/i386/sys/endian.h : $(mh_dir)/linux/arch/i386/sys/endian.mh $(crwatcnt_sp) h/arch/i386/sys/ioctl.h : $(mh_dir)/linux/arch/i386/sys/ioctl.mh $(crwatcnt_sp) h/arch/i386/sys/resource.h : $(mh_dir)/linux/arch/i386/sys/resource.mh $(crwatcnt_sp) h/arch/i386/sys/socket.h : $(mh_dir)/linux/arch/i386/sys/socket.mh $(crwatcnt_sp) @@ -365,12 +367,15 @@ h/arch/mips/fcntl.h : $(mh_dir)/linux/arch/mips/fcntl.mh $(crwatcnt_sp) . h/arch/mips/siginfo.h : $(mh_dir)/linux/arch/mips/siginfo.mh $(crwatcnt_sp) ../clock_t.sp h/arch/mips/signal.h : $(mh_dir)/linux/arch/mips/signal.mh $(crwatcnt_sp) h/arch/mips/sigposix.h : $(mh_dir)/linux/arch/mips/sigposix.mh $(crwatcnt_sp) +h/arch/mips/sys/endian.h : $(mh_dir)/linux/arch/mips/sys/endian.mh $(crwatcnt_sp) h/arch/mips/sys/ioctl.h : $(mh_dir)/linux/arch/mips/sys/ioctl.mh $(crwatcnt_sp) h/arch/mips/sys/resource.h : $(mh_dir)/linux/arch/mips/sys/resource.mh $(crwatcnt_sp) h/arch/mips/sys/socket.h : $(mh_dir)/linux/arch/mips/sys/socket.mh $(crwatcnt_sp) h/arch/mips/sys/stat.h : $(mh_dir)/linux/arch/mips/sys/stat.mh $(crwatcnt_sp) ../dev_t.sp ../ino_t.sp ../mode_t.sp ../nlink_t.sp ../uid_t.sp ../gid_t.sp ../blksizet.sp ../blkcnt_t.sp h/arch/mips/sys/sysmacro.h : $(mh_dir)/linux/arch/mips/sys/sysmacro.mh $(crwatcnt_sp) h/arch/mips/sys/types.h : $(mh_dir)/linux/arch/mips/sys/types.mh $(crwatcnt_sp) ../dev_t.sp ../ino_t.sp ../mode_t.sp ../nlink_t.sp ../uid_t.sp ../gid_t.sp ../blksizet.sp ../blkcnt_t.sp ../id_t.sp +h/arch/ppc/err_no.h : $(mh_dir)/linux/arch/ppc/err_no.mh $(crwatcnt_sp) +h/arch/ppc/sys/endian.h : $(mh_dir)/linux/arch/ppc/sys/endian.mh $(crwatcnt_sp) !else ifeq system qnx diff --git a/bld/hdr/watcom/endian.mh b/bld/hdr/watcom/endian.mh new file mode 100644 index 0000000000..4c90871b45 --- /dev/null +++ b/bld/hdr/watcom/endian.mh @@ -0,0 +1,63 @@ +/* + * endian.h + * +:include crwat.sp + */ +#ifndef _ENDIAN_H_INCLUDED +#define _ENDIAN_H_INCLUDED + +:include readonly.sp + +:include extposix.sp + +#define LITTLE_ENDIAN 1234 +#define BIG_ENDIAN 4321 + +#define _SWAPNC_16(w) \ +(\ + (((w) & 0x00FFU) << 8)\ + | (((w) & 0xFF00U) >> 8)\ +) +#define _SWAPNC_32(w) \ +(\ + (((w) & 0x000000FFUL) << 24)\ + | (((w) & 0x0000FF00UL) << 8)\ + | (((w) & 0x00FF0000UL) >> 8)\ + | (((w) & 0xFF000000UL) >> 24)\ +) +#define _SWAPNC_64(w) \ +(\ + (((w) & 0x00000000000000FFULL) << 56)\ + | (((w) & 0x000000000000FF00ULL) << 40)\ + | (((w) & 0x0000000000FF0000ULL) << 24)\ + | (((w) & 0x00000000FF000000ULL) << 8)\ + | (((w) & 0x000000FF00000000ULL) >> 8)\ + | (((w) & 0x0000FF0000000000ULL) >> 24)\ + | (((w) & 0x00FF000000000000ULL) >> 40)\ + | (((w) & 0xFF00000000000000ULL) >> 56)\ +) + +:segment LINUX +#include _ARCH_INCLUDE(sys/endian.h) +:elsesegment +#define BYTE_ORDER LITTLE_ENDIAN + +#define htobe16(x) _SWAPNC_16(x) +#define htole16(x) (x) +#define be16toh(x) _SWAPNC_16(x) +#define le16toh(x) (x) + +#define htobe32(x) _SWAPNC_32(x) +#define htole32(x) (x) +#define be32toh(x) _SWAPNC_32(x) +#define le32toh(x) (x) + +#define htobe64(x) _SWAPNC_64(x) +#define htole64(x) (x) +#define be64toh(x) _SWAPNC_64(x) +#define le64toh(x) (x) +:endsegment + +:include extepi.sp + +#endif diff --git a/bld/hdr/watcom/linux/arch/i386/sys/endian.mh b/bld/hdr/watcom/linux/arch/i386/sys/endian.mh new file mode 100644 index 0000000000..99cb596e9e --- /dev/null +++ b/bld/hdr/watcom/linux/arch/i386/sys/endian.mh @@ -0,0 +1,22 @@ +/* + * arch/i386/sys/endian.h + * +:include crwatcnt.sp + */ + +#define BYTE_ORDER LITTLE_ENDIAN + +#define htobe16(x) _SWAPNC_16(x) +#define htole16(x) (x) +#define be16toh(x) _SWAPNC_16(x) +#define le16toh(x) (x) + +#define htobe32(x) _SWAPNC_32(x) +#define htole32(x) (x) +#define be32toh(x) _SWAPNC_32(x) +#define le32toh(x) (x) + +#define htobe64(x) _SWAPNC_64(x) +#define htole64(x) (x) +#define be64toh(x) _SWAPNC_64(x) +#define le64toh(x) (x) diff --git a/bld/hdr/watcom/linux/arch/mips/sys/endian.mh b/bld/hdr/watcom/linux/arch/mips/sys/endian.mh new file mode 100644 index 0000000000..45d17118e0 --- /dev/null +++ b/bld/hdr/watcom/linux/arch/mips/sys/endian.mh @@ -0,0 +1,22 @@ +/* + * arch/mips/sys/endian.h + * +:include crwatcnt.sp + */ + +#define BYTE_ORDER LITTLE_ENDIAN + +#define htobe16(x) _SWAPNC_16(x) +#define htole16(x) (x) +#define be16toh(x) _SWAPNC_16(x) +#define le16toh(x) (x) + +#define htobe32(x) _SWAPNC_32(x) +#define htole32(x) (x) +#define be32toh(x) _SWAPNC_32(x) +#define le32toh(x) (x) + +#define htobe64(x) _SWAPNC_64(x) +#define htole64(x) (x) +#define be64toh(x) _SWAPNC_64(x) +#define le64toh(x) (x) diff --git a/bld/hdr/watcom/linux/arch/ppc/sys/endian.mh b/bld/hdr/watcom/linux/arch/ppc/sys/endian.mh new file mode 100644 index 0000000000..9605281f67 --- /dev/null +++ b/bld/hdr/watcom/linux/arch/ppc/sys/endian.mh @@ -0,0 +1,22 @@ +/* + * arch/ppc/sys/endian.h + * +:include crwatcnt.sp + */ + +#define BYTE_ORDER BIG_ENDIAN + +#define htobe16(x) (x) +#define htole16(x) _SWAPNC_16(x) +#define be16toh(x) (x) +#define le16toh(x) _SWAPNC_16(x) + +#define htobe32(x) (x) +#define htole32(x) _SWAPNC_32(x) +#define be32toh(x) (x) +#define le32toh(x) _SWAPNC_32(x) + +#define htobe64(x) (x) +#define htole64(x) _SWAPNC_64(x) +#define be64toh(x) (x) +#define le64toh(x) _SWAPNC_64(x) From dbaed3025e1a05de80c3308f9c1e44f718771889 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Wed, 20 Sep 2023 09:22:54 +0200 Subject: [PATCH 151/258] fix mistakes in OWDEVBUILD control environment variable processing --- bld/as/master.mif | 4 ++-- bld/cc/386/nt386.dbg/makefile | 2 +- bld/cc/386/ntx64.dbg/makefile | 2 +- bld/cc/386/os2386.dbg/makefile | 2 +- bld/cc/axp/nt386.dbg/makefile | 2 +- bld/cc/axp/os2386.dbg/makefile | 2 +- bld/cc/ccobjs.mif | 2 +- bld/cc/i86/nt386.dbg/makefile | 2 +- bld/cc/i86/os2386.dbg/makefile | 2 +- bld/cc/master.mif | 6 +++--- bld/cc/mps/nt386.dbg/makefile | 2 +- bld/cc/mps/os2386.dbg/makefile | 2 +- bld/cc/ppc/os2386.dbg/makefile | 2 +- bld/cg/intel/386/linuxx64.dbg/makefile | 2 +- bld/cg/intel/386/nt386.dbg/makefile | 2 +- bld/cg/intel/386/ntx64.dbg/makefile | 2 +- bld/cg/intel/386/os2386.dbg/makefile | 2 +- bld/cg/intel/i86/nt386.dbg/makefile | 2 +- bld/cg/intel/i86/os2386.dbg/makefile | 2 +- bld/cg/mif/target.mif | 2 +- bld/cg/risc/axp/nt386.dbg/makefile | 2 +- bld/cg/risc/axp/os2386.dbg/makefile | 2 +- bld/cg/risc/mps/nt386.dbg/makefile | 2 +- bld/cg/risc/mps/os2386.dbg/makefile | 2 +- bld/cg/risc/ppc/os2386.dbg/makefile | 2 +- bld/plusplus/386/nt386.dbg/makefile | 2 +- bld/plusplus/386/os2386.dbg/makefile | 4 ++-- bld/plusplus/helptext/makefile | 3 +-- bld/plusplus/i86/nt386.dbg/makefile | 2 +- bld/plusplus/master.mif | 10 +++++----- bld/plusplus/ppobjs.mif | 2 +- bld/posix/makeall.mif | 4 ++-- build/makeinit | 12 ------------ build/mif/bhost.mif | 8 +++++--- build/mif/cproj.mif | 11 +++++------ 35 files changed, 51 insertions(+), 63 deletions(-) diff --git a/bld/as/master.mif b/bld/as/master.mif index e24974bb8f..b55335eb68 100644 --- a/bld/as/master.mif +++ b/bld/as/master.mif @@ -62,7 +62,7 @@ extra_cppflags_axp = -DAS_ALPHA extra_cppflags_mps = -DAS_MIPS extra_cppflags_ppc = -DAS_PPC extra_cpp_flags = $(extra_cppflags_$(target_cpu)) -!ifeq release 0 +!ifeq debug 2 extra_cpp_flags += -DAS_DEBUG_DUMP !endif extra_cpp_flags_asitest = $(trmem_cpp_flags) @@ -247,7 +247,7 @@ $(asi_lex_out).c : scani_in.re $(__MAKEFILES__) optencod_opt_qnx = -u=$(exetarg_qnx_res) !endif optencod_targets = $(target_cpu) $(host_os) -!ifeq release 0 +!ifeq debug 2 optencod_targets += dbg !endif diff --git a/bld/cc/386/nt386.dbg/makefile b/bld/cc/386/nt386.dbg/makefile index 726bdc3ec9..ea74e281da 100644 --- a/bld/cc/386/nt386.dbg/makefile +++ b/bld/cc/386/nt386.dbg/makefile @@ -3,7 +3,7 @@ host_os = nt host_cpu = 386 -cc_release = 0 +cc_debug = 1 debug_cg = 1 !include ../target.mif diff --git a/bld/cc/386/ntx64.dbg/makefile b/bld/cc/386/ntx64.dbg/makefile index 1af1349ba5..7c3e0f285b 100644 --- a/bld/cc/386/ntx64.dbg/makefile +++ b/bld/cc/386/ntx64.dbg/makefile @@ -3,7 +3,7 @@ host_os = nt host_cpu = x64 -cc_release = 0 +cc_debug = 1 debug_cg = 1 !include ../target.mif diff --git a/bld/cc/386/os2386.dbg/makefile b/bld/cc/386/os2386.dbg/makefile index cb3e478de1..d4d5b59529 100644 --- a/bld/cc/386/os2386.dbg/makefile +++ b/bld/cc/386/os2386.dbg/makefile @@ -3,7 +3,7 @@ host_os = os2 host_cpu = 386 -cc_release = 0 +cc_debug = 1 debug_cg = 1 debug = 1 diff --git a/bld/cc/axp/nt386.dbg/makefile b/bld/cc/axp/nt386.dbg/makefile index 01ac176450..3add4b29b7 100644 --- a/bld/cc/axp/nt386.dbg/makefile +++ b/bld/cc/axp/nt386.dbg/makefile @@ -3,7 +3,7 @@ host_os = nt host_cpu = 386 -cc_release = 0 +cc_debug = 1 debug_cg = 1 debug = 1 diff --git a/bld/cc/axp/os2386.dbg/makefile b/bld/cc/axp/os2386.dbg/makefile index a9047c153f..e3bc28287d 100644 --- a/bld/cc/axp/os2386.dbg/makefile +++ b/bld/cc/axp/os2386.dbg/makefile @@ -3,7 +3,7 @@ host_os = os2 host_cpu = 386 -cc_release = 0 +cc_debug = 1 debug_cg = 1 debug = 1 diff --git a/bld/cc/ccobjs.mif b/bld/cc/ccobjs.mif index 60d2414eb4..a17eae447f 100644 --- a/bld/cc/ccobjs.mif +++ b/bld/cc/ccobjs.mif @@ -87,7 +87,7 @@ common_objs = & $(_subdir_)ppexpn.obj & $(_subdir_)unicode.obj -!ifeq release 0 +!ifeq debug 2 cc_debug_objs = $(_subdir_)cfedump.obj !endif diff --git a/bld/cc/i86/nt386.dbg/makefile b/bld/cc/i86/nt386.dbg/makefile index b25709a50d..79e85ccf12 100644 --- a/bld/cc/i86/nt386.dbg/makefile +++ b/bld/cc/i86/nt386.dbg/makefile @@ -3,7 +3,7 @@ host_os = nt host_cpu = 386 -cc_release = 0 +cc_debug = 1 debug_cg = 1 debug = 1 diff --git a/bld/cc/i86/os2386.dbg/makefile b/bld/cc/i86/os2386.dbg/makefile index 690e1a47f1..66883723ef 100644 --- a/bld/cc/i86/os2386.dbg/makefile +++ b/bld/cc/i86/os2386.dbg/makefile @@ -3,7 +3,7 @@ host_os = os2 host_cpu = 386 -cc_release = 0 +cc_debug = 1 debug_cg = 1 debug = 1 diff --git a/bld/cc/master.mif b/bld/cc/master.mif index f726b43c8c..3587e37349 100644 --- a/bld/cc/master.mif +++ b/bld/cc/master.mif @@ -71,7 +71,7 @@ extra_cppflags_axp = -DAS_ALPHA extra_cppflags_mps = -DAS_MIPS extra_cppflags_ppc = -DAS_PPC extra_cpp_flags += $(extra_cppflags_$(target_cpu)) -!ifeq release 0 +!ifeq debug 2 extra_cpp_flags += -DAS_DEBUG_DUMP !endif @@ -89,7 +89,7 @@ extra_c_flags_386 = -3r !ifdef __WATCOM_TOOLS__ ! ifndef bootstrap -! ifeq release 1 +! ifeq debug 0 extra_c_flags_cscan_386 = -5r extra_c_flags_cscan = $(extra_c_flags_cscan_$(host_cpu)) ! endif @@ -225,7 +225,7 @@ optencod_opt_qnx = -u=$(exetarg_qnx_res) !endif #optencod_enc_linux = -utf8 optencod_targets = $(target_cpu) $(host_os) -!ifeq release 0 +!ifeq debug 2 optencod_targets += dbg !endif diff --git a/bld/cc/mps/nt386.dbg/makefile b/bld/cc/mps/nt386.dbg/makefile index dc98a96f28..a6cc7ad473 100644 --- a/bld/cc/mps/nt386.dbg/makefile +++ b/bld/cc/mps/nt386.dbg/makefile @@ -3,7 +3,7 @@ host_os = nt host_cpu = 386 -cc_release = 0 +cc_debug = 1 debug_cg = 1 debug = 1 diff --git a/bld/cc/mps/os2386.dbg/makefile b/bld/cc/mps/os2386.dbg/makefile index ad3720e071..68a2661554 100644 --- a/bld/cc/mps/os2386.dbg/makefile +++ b/bld/cc/mps/os2386.dbg/makefile @@ -3,7 +3,7 @@ host_os = os2 host_cpu = 386 -cc_release = 0 +cc_debug = 1 debug_cg = 1 debug = 1 diff --git a/bld/cc/ppc/os2386.dbg/makefile b/bld/cc/ppc/os2386.dbg/makefile index d9f4fe7a7b..34bcf3012c 100644 --- a/bld/cc/ppc/os2386.dbg/makefile +++ b/bld/cc/ppc/os2386.dbg/makefile @@ -3,7 +3,7 @@ host_os = os2 host_cpu = 386 -cc_release = 0 +cc_debug = 1 debug_cg = 1 debug = 1 diff --git a/bld/cg/intel/386/linuxx64.dbg/makefile b/bld/cg/intel/386/linuxx64.dbg/makefile index 71f30a6030..4458c3f9e9 100644 --- a/bld/cg/intel/386/linuxx64.dbg/makefile +++ b/bld/cg/intel/386/linuxx64.dbg/makefile @@ -3,6 +3,6 @@ host_os = linux host_cpu = x64 -cg_release = 0 +cg_debug = 1 !include ../master.mif diff --git a/bld/cg/intel/386/nt386.dbg/makefile b/bld/cg/intel/386/nt386.dbg/makefile index 7be232d096..7772882878 100644 --- a/bld/cg/intel/386/nt386.dbg/makefile +++ b/bld/cg/intel/386/nt386.dbg/makefile @@ -3,6 +3,6 @@ host_os = nt host_cpu = 386 -cg_release = 0 +cg_debug = 1 !include ../master.mif diff --git a/bld/cg/intel/386/ntx64.dbg/makefile b/bld/cg/intel/386/ntx64.dbg/makefile index a93269035f..bf738e391b 100644 --- a/bld/cg/intel/386/ntx64.dbg/makefile +++ b/bld/cg/intel/386/ntx64.dbg/makefile @@ -3,6 +3,6 @@ host_os = nt host_cpu = x64 -cg_release = 0 +cg_debug = 1 !include ../master.mif diff --git a/bld/cg/intel/386/os2386.dbg/makefile b/bld/cg/intel/386/os2386.dbg/makefile index a7932d757e..254489dcbb 100644 --- a/bld/cg/intel/386/os2386.dbg/makefile +++ b/bld/cg/intel/386/os2386.dbg/makefile @@ -3,6 +3,6 @@ host_os = os2 host_cpu = 386 -cg_release = 0 +cg_debug = 1 !include ../master.mif diff --git a/bld/cg/intel/i86/nt386.dbg/makefile b/bld/cg/intel/i86/nt386.dbg/makefile index 9c9fac2e90..a69cb0584a 100644 --- a/bld/cg/intel/i86/nt386.dbg/makefile +++ b/bld/cg/intel/i86/nt386.dbg/makefile @@ -3,7 +3,7 @@ host_os = nt host_cpu = 386 -cg_release = 0 +cg_debug = 1 debug = 1 !include ../master.mif diff --git a/bld/cg/intel/i86/os2386.dbg/makefile b/bld/cg/intel/i86/os2386.dbg/makefile index 40147ee8bd..335b88a36f 100644 --- a/bld/cg/intel/i86/os2386.dbg/makefile +++ b/bld/cg/intel/i86/os2386.dbg/makefile @@ -3,6 +3,6 @@ host_os = os2 host_cpu = 386 -cg_release = 0 +cg_debug = 1 !include ../master.mif diff --git a/bld/cg/mif/target.mif b/bld/cg/mif/target.mif index 8178b950be..88366768ea 100644 --- a/bld/cg/mif/target.mif +++ b/bld/cg/mif/target.mif @@ -25,7 +25,7 @@ target : $(pre_obj_deps) cg$(target_cpu).lib $(cg_target_host_name).lib .SYMBOLI !include $(cg_dir)/mif/rules.mif -!ifeq release 0 +!ifeq debug 2 debug_objs = $(cg_dump_objs) !endif diff --git a/bld/cg/risc/axp/nt386.dbg/makefile b/bld/cg/risc/axp/nt386.dbg/makefile index d76876ca79..2a46ccd392 100644 --- a/bld/cg/risc/axp/nt386.dbg/makefile +++ b/bld/cg/risc/axp/nt386.dbg/makefile @@ -3,6 +3,6 @@ host_os = nt host_cpu = 386 -cg_release = 0 +cg_debug = 1 !include ../master.mif diff --git a/bld/cg/risc/axp/os2386.dbg/makefile b/bld/cg/risc/axp/os2386.dbg/makefile index 0429e1e8b9..f7e236e60b 100644 --- a/bld/cg/risc/axp/os2386.dbg/makefile +++ b/bld/cg/risc/axp/os2386.dbg/makefile @@ -3,6 +3,6 @@ host_os = os2 host_cpu = 386 -cg_release = 0 +cg_debug = 1 !include ../master.mif diff --git a/bld/cg/risc/mps/nt386.dbg/makefile b/bld/cg/risc/mps/nt386.dbg/makefile index 50926f7fb7..5afc9f80f0 100644 --- a/bld/cg/risc/mps/nt386.dbg/makefile +++ b/bld/cg/risc/mps/nt386.dbg/makefile @@ -3,6 +3,6 @@ host_os = nt host_cpu = 386 -cg_release = 0 +cg_debug = 1 !include ../master.mif diff --git a/bld/cg/risc/mps/os2386.dbg/makefile b/bld/cg/risc/mps/os2386.dbg/makefile index de5761781b..0029486594 100644 --- a/bld/cg/risc/mps/os2386.dbg/makefile +++ b/bld/cg/risc/mps/os2386.dbg/makefile @@ -3,6 +3,6 @@ host_os = os2 host_cpu = 386 -cg_release = 0 +cg_debug = 1 !include ../master.mif diff --git a/bld/cg/risc/ppc/os2386.dbg/makefile b/bld/cg/risc/ppc/os2386.dbg/makefile index e191a35c1c..aa6b9c5700 100644 --- a/bld/cg/risc/ppc/os2386.dbg/makefile +++ b/bld/cg/risc/ppc/os2386.dbg/makefile @@ -3,6 +3,6 @@ host_os = os2 host_cpu = 386 -cg_release = 0 +cg_debug = 1 !include ../master.mif diff --git a/bld/plusplus/386/nt386.dbg/makefile b/bld/plusplus/386/nt386.dbg/makefile index 72ea440d2c..c80acee5a3 100644 --- a/bld/plusplus/386/nt386.dbg/makefile +++ b/bld/plusplus/386/nt386.dbg/makefile @@ -3,7 +3,7 @@ host_os = nt host_cpu = 386 -plusplus_release = 0 +plusplus_debug = 1 debug_cg = 1 !include ../target.mif diff --git a/bld/plusplus/386/os2386.dbg/makefile b/bld/plusplus/386/os2386.dbg/makefile index ed691c73a0..3733519f28 100644 --- a/bld/plusplus/386/os2386.dbg/makefile +++ b/bld/plusplus/386/os2386.dbg/makefile @@ -3,7 +3,7 @@ host_os = os2 host_cpu = 386 -debug_cg = 1 -plusplus_release = 0 +plusplus_debug = 1 +debug_cg = 1 !include ../target.mif diff --git a/bld/plusplus/helptext/makefile b/bld/plusplus/helptext/makefile index bc717c50c3..056c4eb422 100644 --- a/bld/plusplus/helptext/makefile +++ b/bld/plusplus/helptext/makefile @@ -53,8 +53,7 @@ $(help_win) : $(msgs) mkwinhlp.exe $(p2r) copy winhelp.ptf+winhelp.idx wpp.ptf $(p2r) -bl wpp.ptf winhelp.rtf hc wpp.hpj -!ifeq release 0 -!else +!ifeq debug 0 rm -f $(temp_files) !endif diff --git a/bld/plusplus/i86/nt386.dbg/makefile b/bld/plusplus/i86/nt386.dbg/makefile index 004de03c31..2a3d21d680 100644 --- a/bld/plusplus/i86/nt386.dbg/makefile +++ b/bld/plusplus/i86/nt386.dbg/makefile @@ -3,7 +3,7 @@ host_os = nt host_cpu = 386 -plusplus_release = 0 +plusplus_debug = 1 debug_cg = 1 !include ../target.mif diff --git a/bld/plusplus/master.mif b/bld/plusplus/master.mif index 50641f942a..7a80df8778 100644 --- a/bld/plusplus/master.mif +++ b/bld/plusplus/master.mif @@ -59,7 +59,7 @@ extra_cppflags_axp = -DAS_ALPHA extra_cppflags_mps = -DAS_MIPS extra_cppflags_ppc = -DAS_PPC extra_cpp_flags += $(extra_cppflags_$(target_cpu)) -!ifeq release 0 +!ifeq debug 2 extra_cpp_flags += -DAS_DEBUG_DUMP !endif @@ -74,14 +74,14 @@ extra_cpp_flags_memmgr = $(trmem_cpp_flags) #extra_c_flags = -pcl extra_c_flags = -!ifeq release 0 +!ifneq debug 0 extra_c_flags += -db extra_c_flags_axp = -si !endif extra_c_flags_carve = $(incl_file_opts)carvecpp.h extra_c_flags_cmdlnprs = $(incl_file_opts)fesupp.h -!ifeq release 0 +!ifeq debug 2 extra_c_flags_dbgzap = $(incl_file_opts)fesupp.h !endif extra_c_flags_floatsup = $(cfloat_inc_dirs) @@ -105,7 +105,7 @@ extra_c_flags_cmdlnany = -os ! endif extra_c_flags_cscan_386 = -4r extra_c_flags_cscan = $(extra_c_flags_cscan_$(host_cpu)) -! ifeq release 1 +! ifeq debug 0 extra_c_flags_pcheader_386 = -oi extra_c_flags_pcheader = $(extra_c_flags_pcheader_$(host_cpu)) ! endif @@ -224,7 +224,7 @@ optencod_opt_qnx = -u=$(exetarg_qnx_res) !endif #optencod_enc_linux = -utf8 optencod_targets = $(target_cpu) $(host_os) -!ifeq release 0 +!ifeq debug 2 optencod_targets += dbg !endif diff --git a/bld/plusplus/ppobjs.mif b/bld/plusplus/ppobjs.mif index d0c8ece4f8..59316fde60 100644 --- a/bld/plusplus/ppobjs.mif +++ b/bld/plusplus/ppobjs.mif @@ -220,7 +220,7 @@ plusplus_matherr_objs = $(_subdir_)cmatherr.obj !endif # debugging objects -!ifeq release 0 +!ifeq debug 2 debug_objs = & $(_subdir_)dbg.obj & $(_subdir_)dbgcomma.obj & diff --git a/bld/posix/makeall.mif b/bld/posix/makeall.mif index 0d56f04b97..c7e67b3596 100644 --- a/bld/posix/makeall.mif +++ b/bld/posix/makeall.mif @@ -65,8 +65,8 @@ wmake_opts = host_os=$(host_os) host_cpu=$(host_cpu) !ifdef bootstrap wmake_opts += bootstrap=$(bootstrap) !endif -!ifdef release -wmake_opts += release=$(release) +!ifdef debug +wmake_opts += debug=$(debug) !endif $(commands) : .symbolic $(__MAKEFILES__) diff --git a/build/makeinit b/build/makeinit index fde80be3a4..99a0533965 100644 --- a/build/makeinit +++ b/build/makeinit @@ -43,18 +43,6 @@ noecho = @ noecho = !endif -!ifdef devdebug -debug = 2 -!else ifdef debug -debug = 1 -!else ifdef release -!ifeq release 0 -debug = 1 -!else -debug = 0 -!endif -!endif - mif_path = $(%OWROOT)/build/mif .mif: "$(mif_path)" diff --git a/build/mif/bhost.mif b/build/mif/bhost.mif index 3a2e3d4df5..10dca03027 100644 --- a/build/mif/bhost.mif +++ b/build/mif/bhost.mif @@ -33,10 +33,12 @@ bld_incs = $(bld_extra_incs) -I"$(watcom_dir)/h" bld_new_cflags = -xx-zam !endif -!ifeq debug 0 -bld_gen_cflags = $(watcom_common_cflags)-j-za99-s$(bld_dft_oflags)$(bld_new_cflags)-fo=.obj -!else +!ifeq debug 1 bld_gen_cflags = $(watcom_common_cflags)-j-za99-d2$(bld_new_cflags)-fo=.obj +!else ifeq debug 2 +bld_gen_cflags = $(watcom_common_cflags)-j-za99-d2-DDEVBUILD $(bld_new_cflags)-fo=.obj +!else +bld_gen_cflags = $(watcom_common_cflags)-j-za99-s$(bld_dft_oflags)$(bld_new_cflags)-fo=.obj !endif # options for source compilations diff --git a/build/mif/cproj.mif b/build/mif/cproj.mif index 8be96a8770..eafc33674b 100644 --- a/build/mif/cproj.mif +++ b/build/mif/cproj.mif @@ -114,16 +114,14 @@ as_mps = *bwasmps !endif !ifndef debug -!ifdef $(proj_name)_release -!ifeq $(proj_name)_release 0 -debug = 1 -!else +!ifeq $(proj_name)_debug 0 debug = 0 -!endif !else ifeq %OWDEVBUILD 1 debug = 2 !else ifeq %OWDEBUGBUILD 1 debug = 1 +!else ifeq $(proj_name)_debug 1 +debug = 1 !else debug = 0 !endif @@ -199,11 +197,12 @@ mode_libflags = -s-t-zld !else !ifeq debug 2 mode_cppflags = -DDEVBUILD +mode_aflags = -d2 -DDEVBUILD !else mode_cppflags = +mode_aflags = -d2 !endif mode_cflags = -od -d2 $(cdebug_fmt) -mode_aflags = -d2 mode_lflags = $(ldebug_fmt) all mode_clflags = $(cldebug_fmt) -d2 !endif From e423c741cf48e681084b5b2f0f7c7c5e616b514c Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Wed, 20 Sep 2023 16:43:38 +0200 Subject: [PATCH 152/258] fix cg code for development debug build --- bld/cg/c/cgmemmgr.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/bld/cg/c/cgmemmgr.c b/bld/cg/c/cgmemmgr.c index c1aa2bdcc6..c9fc69a4b8 100644 --- a/bld/cg/c/cgmemmgr.c +++ b/bld/cg/c/cgmemmgr.c @@ -358,7 +358,9 @@ static pointer GetFromFrl( size_t amount, int frl_class ) free = _FreeList[frl_class]; if( free != NULL ) { +#ifdef DEVBUILD assert( (free->length & ALLOCATED) == 0 ); +#endif free->length |= ALLOCATED; _FreeList[frl_class] = free->link; return( free ); @@ -373,15 +375,16 @@ static pointer GetFromBlk( size_t amount ) mem_blk *block; tag *alloc; - for( block = _Blks; block && (block->free < amount); ) { - block = block->next; - } - if( block ) { - alloc = (tag *)((char *)block + block->size - block->free); - assert( *alloc == 0 ); - *alloc = amount | ALLOCATED; - block->free -= amount; - return( ++alloc ); + for( block = _Blks; block != NULL; block = block->next ) { + if( block->free >= amount ) { + alloc = (tag *)( (char *)block + block->size - block->free ); +#ifdef DEVBUILD + assert( *alloc == 0 ); +#endif + *alloc = amount | ALLOCATED; + block->free -= amount; + return( ++alloc ); + } } if( MemFromSys( 0 ) == NULL) // Grab one empty block return( NULL ); @@ -424,7 +427,9 @@ void MemFree( pointer p ) tag length; free = (frl *)( (char *)p - TAG_SIZE ); +#ifdef DEVBUILD assert( free->length & ALLOCATED ); +#endif free->length &= ~ALLOCATED; length = free->length; if( length > MAX_ALLOC ) { // This was a full block From 1990e11b67f08a42028578700ffda1b79681509c Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Wed, 20 Sep 2023 16:56:24 +0200 Subject: [PATCH 153/258] remove wrong macros from build make files --- bld/cc/386/os2386.dbg/makefile | 1 - bld/cc/axp/nt386.dbg/makefile | 1 - bld/cc/axp/os2386.dbg/makefile | 1 - bld/cc/i86/nt386.dbg/makefile | 1 - bld/cc/i86/os2386.dbg/makefile | 1 - bld/cc/mps/nt386.dbg/makefile | 1 - bld/cc/mps/os2386.dbg/makefile | 1 - bld/cc/ppc/os2386.dbg/makefile | 1 - bld/cg/intel/i86/nt386.dbg/makefile | 1 - 9 files changed, 9 deletions(-) diff --git a/bld/cc/386/os2386.dbg/makefile b/bld/cc/386/os2386.dbg/makefile index d4d5b59529..3ec6b572d2 100644 --- a/bld/cc/386/os2386.dbg/makefile +++ b/bld/cc/386/os2386.dbg/makefile @@ -5,6 +5,5 @@ host_cpu = 386 cc_debug = 1 debug_cg = 1 -debug = 1 !include ../target.mif diff --git a/bld/cc/axp/nt386.dbg/makefile b/bld/cc/axp/nt386.dbg/makefile index 3add4b29b7..51deb9fbf0 100644 --- a/bld/cc/axp/nt386.dbg/makefile +++ b/bld/cc/axp/nt386.dbg/makefile @@ -5,6 +5,5 @@ host_cpu = 386 cc_debug = 1 debug_cg = 1 -debug = 1 !include ../target.mif diff --git a/bld/cc/axp/os2386.dbg/makefile b/bld/cc/axp/os2386.dbg/makefile index e3bc28287d..69ad53706c 100644 --- a/bld/cc/axp/os2386.dbg/makefile +++ b/bld/cc/axp/os2386.dbg/makefile @@ -5,6 +5,5 @@ host_cpu = 386 cc_debug = 1 debug_cg = 1 -debug = 1 !include ../target.mif diff --git a/bld/cc/i86/nt386.dbg/makefile b/bld/cc/i86/nt386.dbg/makefile index 79e85ccf12..0a8874451b 100644 --- a/bld/cc/i86/nt386.dbg/makefile +++ b/bld/cc/i86/nt386.dbg/makefile @@ -5,6 +5,5 @@ host_cpu = 386 cc_debug = 1 debug_cg = 1 -debug = 1 !include ../target.mif diff --git a/bld/cc/i86/os2386.dbg/makefile b/bld/cc/i86/os2386.dbg/makefile index 66883723ef..a1e7a34016 100644 --- a/bld/cc/i86/os2386.dbg/makefile +++ b/bld/cc/i86/os2386.dbg/makefile @@ -5,6 +5,5 @@ host_cpu = 386 cc_debug = 1 debug_cg = 1 -debug = 1 !include ../target.mif diff --git a/bld/cc/mps/nt386.dbg/makefile b/bld/cc/mps/nt386.dbg/makefile index a6cc7ad473..e539c320cb 100644 --- a/bld/cc/mps/nt386.dbg/makefile +++ b/bld/cc/mps/nt386.dbg/makefile @@ -5,6 +5,5 @@ host_cpu = 386 cc_debug = 1 debug_cg = 1 -debug = 1 !include ../target.mif diff --git a/bld/cc/mps/os2386.dbg/makefile b/bld/cc/mps/os2386.dbg/makefile index 68a2661554..3dc8193b78 100644 --- a/bld/cc/mps/os2386.dbg/makefile +++ b/bld/cc/mps/os2386.dbg/makefile @@ -5,6 +5,5 @@ host_cpu = 386 cc_debug = 1 debug_cg = 1 -debug = 1 !include ../target.mif diff --git a/bld/cc/ppc/os2386.dbg/makefile b/bld/cc/ppc/os2386.dbg/makefile index 34bcf3012c..84e165b257 100644 --- a/bld/cc/ppc/os2386.dbg/makefile +++ b/bld/cc/ppc/os2386.dbg/makefile @@ -5,6 +5,5 @@ host_cpu = 386 cc_debug = 1 debug_cg = 1 -debug = 1 !include ../target.mif diff --git a/bld/cg/intel/i86/nt386.dbg/makefile b/bld/cg/intel/i86/nt386.dbg/makefile index a69cb0584a..aeefa097d5 100644 --- a/bld/cg/intel/i86/nt386.dbg/makefile +++ b/bld/cg/intel/i86/nt386.dbg/makefile @@ -4,6 +4,5 @@ host_os = nt host_cpu = 386 cg_debug = 1 -debug = 1 !include ../master.mif From 4902f8c2ce024035c4e94badd8a676ecf054b671 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Wed, 20 Sep 2023 22:34:51 +0200 Subject: [PATCH 154/258] fix DIP/MAD code and build make files for development debug build --- bld/dip/dwarf/c/stub.c | 12 ++++++++++++ bld/dip/master.mif | 4 ++++ bld/mad/master.mif | 4 ++++ 3 files changed, 20 insertions(+) diff --git a/bld/dip/dwarf/c/stub.c b/bld/dip/dwarf/c/stub.c index 9a9c63eef7..8fbad08106 100644 --- a/bld/dip/dwarf/c/stub.c +++ b/bld/dip/dwarf/c/stub.c @@ -71,3 +71,15 @@ int fltused_; #elif defined(__AXP__) int _fltused_; #endif + +#ifndef __WINDOWS__ +#if defined( _M_I86 ) +extern void __STK( int ); +#pragma aux __STK "*" __parm [__ax]; +void __STK( int x ) { (void)x; } +#elif defined( _M_IX86 ) +extern void __CHK( int ); +#pragma aux __CHK "*" __parm []; +void __CHK( int x ) { (void)x; } +#endif +#endif diff --git a/bld/dip/master.mif b/bld/dip/master.mif index ff83908392..9a51a4ed5d 100644 --- a/bld/dip/master.mif +++ b/bld/dip/master.mif @@ -10,6 +10,10 @@ dip_autodepends = .autodepend dip_nofpu = 1 +!ifneq host_os win +dip_nocheckstack = 1 +!endif + !ifeq host_cpu x64 sys_dll = 1 !endif diff --git a/bld/mad/master.mif b/bld/mad/master.mif index 62930da72a..2f15527b3d 100644 --- a/bld/mad/master.mif +++ b/bld/mad/master.mif @@ -12,6 +12,10 @@ mad_autodepends = .autodepend mad_nofpu = 1 +!ifneq host_os win +mad_nocheckstack = 1 +!endif + !ifeq host_cpu x64 sys_dll = 1 !endif From cedc2bc5c03a9c30b299cd0348da488903900227 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Thu, 21 Sep 2023 09:11:13 +0200 Subject: [PATCH 155/258] fix file list for installer build --- bld/hdr/files.dat | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/bld/hdr/files.dat b/bld/hdr/files.dat index c3898e302b..24b1ab90a3 100644 --- a/bld/hdr/files.dat +++ b/bld/hdr/files.dat @@ -641,7 +641,6 @@ usr="in.h" usr="tcp.h" [ DEFAULT type="s" dir="lh/arch/i386" where="c jc f77 jf77 ac" cond="lnxtarg" ] -usr="endian.h" usr="err_no.h" usr="fcntl.h" usr="siginfo.h" @@ -649,6 +648,7 @@ usr="signal.h" usr="sigposix.h" [ DEFAULT type="s" dir="lh/arch/i386/sys" where="c jc f77 jf77 ac" cond="lnxtarg" ] +usr="endian.h" usr="ioctl.h" usr="resource.h" usr="socket.h" @@ -661,7 +661,6 @@ usr="types.h" usr="sysmips.h" [ DEFAULT type="s" dir="lh/arch/mips" where="mc" cond="lnxtarg" ] -usr="endian.h" usr="err_no.h" usr="fcntl.h" usr="siginfo.h" @@ -669,9 +668,17 @@ usr="signal.h" usr="sigposix.h" [ DEFAULT type="s" dir="lh/arch/mips/sys" where="mc" cond="lnxtarg" ] +usr="endian.h" usr="ioctl.h" usr="resource.h" usr="socket.h" usr="stat.h" usr="sysmacro.h" usr="types.h" + +# PowerPC headers. Not currently used. +#[ DEFAULT type="s" dir="lh/arch/ppc" where="mc" cond="lnxtarg" ] +#usr="err_no.h" + +#[ DEFAULT type="s" dir="lh/arch/ppc/sys" where="mc" cond="lnxtarg" ] +#usr="endian.h" From 974a72860793fd524fe4de1618bb61616aaf4cbd Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Thu, 21 Sep 2023 09:52:33 +0200 Subject: [PATCH 156/258] various fixes for development debug build --- bld/afxapi/master.mif | 2 +- bld/brinfo/merge/nt/makefile | 2 +- bld/browser/brg/nt386d/makefile | 2 +- bld/browser/brg/os2386d/makefile | 2 +- bld/browser/master.mif | 4 ++-- bld/cmdedit/master.mif | 5 ++++- bld/commonui/ntx64/makefile | 2 +- bld/dig/c/ldrpe.c | 11 +++++++++++ bld/dig/c/ldrrex.c | 11 +++++++++++ bld/f77/wfc/master.mif | 2 +- bld/f77/wfl/master.mif | 2 +- bld/graphlib/graphics.mif | 2 +- bld/gui/ui/guiui.mif | 2 +- bld/hdr/master.mif | 2 +- bld/mstools/master.mif | 2 +- bld/ncurses/master.mif | 4 ++-- bld/ndisasm/master.mif | 2 +- bld/nwlib/master.mif | 2 +- bld/os2api/master.mif | 2 +- bld/pbide/wig/driver/wini86/makefile | 2 +- bld/rc/rc/master.mif | 4 ++-- bld/rc/rc/nt386.dbg/makefile | 2 +- bld/rc/rc/os2386.dbg/makefile | 2 +- bld/sdk/ddespy/master.mif | 2 +- bld/sdk/drwat/faults/master.mif | 2 +- bld/sdk/fmedit/ntx64/makefile | 2 +- bld/sdk/imgedit/ntx64/makefile | 2 +- bld/sdk/wde/ntx64/makefile | 2 +- bld/sdk/wre/ntx64/makefile | 2 +- bld/sdk/wresedit/waccel/ntx64/makefile | 2 +- bld/sdk/wresedit/wmenu/ntx64/makefile | 2 +- bld/sdk/wresedit/wstring/ntx64/makefile | 2 +- bld/sdk/zoom/ntx64/makefile | 2 +- bld/trap/master.mif | 4 ++-- bld/trap/nmp/nmpbind/makefile | 6 +++--- bld/trap/par/ntsupp.x64/makefile | 10 +++++----- bld/trap/par/ntsupp/makefile | 10 +++++----- bld/trap/trap.mif | 2 +- bld/ui/ui.mif | 2 +- bld/vi/mif/compile.mif | 2 +- bld/w16api/master.mif | 2 +- bld/w32api/incl.mif | 2 +- bld/wasm/master.mif | 4 ++-- bld/wasm/nt386.dbg/makefile | 2 +- bld/wcl/master.mif | 2 +- bld/wipfc/master.mif | 2 +- bld/wl/c/cmdall.c | 4 ++-- bld/wl/c/cmddos.c | 4 ++-- bld/wl/c/dbginfo.c | 12 ++++++------ bld/wl/c/debug.c | 4 ++-- bld/wl/c/hash.c | 4 ++-- bld/wl/c/loadraw.c | 10 +++++----- bld/wl/c/lsymtab.c | 6 +++--- bld/wl/c/ntio.c | 4 ++-- bld/wl/c/objomf.c | 2 +- bld/wl/c/objorl.c | 2 +- bld/wl/c/objpass2.c | 4 ++-- bld/wl/c/symmem.c | 4 ++-- bld/wl/c/wcomdef.c | 4 ++-- bld/wl/c/wlink.c | 6 +++--- bld/wl/ddos386/makefile | 4 +--- bld/wl/dlnx386/makefile | 4 +--- bld/wl/dnt386.dll/makefile | 5 ++--- bld/wl/dnt386.rtd/makefile | 5 ++--- bld/wl/dnt386/makefile | 5 ++--- bld/wl/dntaxp/makefile | 4 +--- bld/wl/dos2386/makefile | 4 +--- bld/wl/h/debug.h | 4 ++-- bld/wl/h/wlbanner.h | 2 +- bld/wl/master.mif | 2 +- bld/wl/nt386.dbg/makefile | 2 +- bld/wmake/master.mif | 2 +- bld/wprof/wprofobj.mif | 2 +- bld/wsample/master.mif | 2 +- bld/wstrip/master.mif | 2 +- bld/wstub/master.mif | 2 +- bld/wtouch/master.mif | 2 +- bld/wv/master.mif | 4 ++-- bld/wv/ssl/master.mif | 2 +- 79 files changed, 143 insertions(+), 129 deletions(-) diff --git a/bld/afxapi/master.mif b/bld/afxapi/master.mif index deb0074fa5..5a1a5c0392 100644 --- a/bld/afxapi/master.mif +++ b/bld/afxapi/master.mif @@ -5,7 +5,7 @@ proj_name = afxapi afxapi_autodepends = .autodepend !ifeq lib_debug 1 -release = 0 +afxapi_debug = 1 !endif !ifeq unicode 1 diff --git a/bld/brinfo/merge/nt/makefile b/bld/brinfo/merge/nt/makefile index eef2f7dbca..30e3df1ef5 100644 --- a/bld/brinfo/merge/nt/makefile +++ b/bld/brinfo/merge/nt/makefile @@ -1,4 +1,4 @@ -!ifeq release 0 +!ifneq debug 0 debug_cpp_opts= -d2 -dDEBUG_PRT debug_link_opts=d all diff --git a/bld/browser/brg/nt386d/makefile b/bld/browser/brg/nt386d/makefile index d77ec27d5e..562ade9015 100644 --- a/bld/browser/brg/nt386d/makefile +++ b/bld/browser/brg/nt386d/makefile @@ -3,6 +3,6 @@ host_os = nt host_cpu = 386 -merge_release = 0 +merge_debug = 1 !include ../master.mif diff --git a/bld/browser/brg/os2386d/makefile b/bld/browser/brg/os2386d/makefile index b7a958d86f..40653ab2b2 100644 --- a/bld/browser/brg/os2386d/makefile +++ b/bld/browser/brg/os2386d/makefile @@ -3,6 +3,6 @@ host_os = os2 host_cpu = 386 -merge_release = 0 +merge_debug = 1 !include ../master.mif diff --git a/bld/browser/master.mif b/bld/browser/master.mif index 7909153218..720bfeaa8e 100644 --- a/bld/browser/master.mif +++ b/bld/browser/master.mif @@ -40,7 +40,7 @@ inc_dirs = -I"../h" -I"../brg/h" -I"../gen" $(wclass_inc_dirs) -I"$(docs_host_di $(dwarfr_inc_dirs) -I"$(posix_dir)/h" -I"$(editdll_dir)" extra_cpp_flags = -DNOPERSIST=1 -!ifeq release 0 +!ifneq debug 0 extra_cpp_flags += -DDEBUG=1 -DDEBUG_ASSERT=1 -DDEBUGTREE=1 !endif !ifeq use_virtmem 1 @@ -96,7 +96,7 @@ mbr_files = $+$(template)$- ext = obj objs = $+$(template)$- rxwrap.obj brmem.obj $(trmem_objs) -!ifeq release 0 +!ifneq debug 0 objs_dbg = debuglog.obj !endif diff --git a/bld/cmdedit/master.mif b/bld/cmdedit/master.mif index 438a05e0cc..b59dc0b613 100644 --- a/bld/cmdedit/master.mif +++ b/bld/cmdedit/master.mif @@ -2,6 +2,9 @@ proj_name = cmdedit cmdedit_autodepends = .AUTODEPEND +cmdedit_nocheckstack = 1 +cmdedit_nocheckstack_dll = 1 + cmdedit_nofpu = 1 # ignore default compilers optimization options @@ -23,7 +26,7 @@ memory_model_i86 = s extra_cpp_dll_flags = -zu -!ifeq release 1 +!ifeq debug 0 extra_c_flags_dos = -oas extra_c_flags_os2 = -oxs !endif diff --git a/bld/commonui/ntx64/makefile b/bld/commonui/ntx64/makefile index 0c77ac40b7..f17c6fa7fd 100644 --- a/bld/commonui/ntx64/makefile +++ b/bld/commonui/ntx64/makefile @@ -2,6 +2,6 @@ host_os = nt host_cpu = x64 -commonui_release = 0 +commonui_debug = 1 !include ../master.mif diff --git a/bld/dig/c/ldrpe.c b/bld/dig/c/ldrpe.c index 375afbc094..742c2e3059 100644 --- a/bld/dig/c/ldrpe.c +++ b/bld/dig/c/ldrpe.c @@ -29,6 +29,9 @@ * ****************************************************************************/ + +#include "enterdb.h" + /* * Module to implement a simple Portable Binary DLL library loader. * @@ -62,6 +65,14 @@ typedef struct { char *modname; /* Filename of the image */ } *module; +#ifdef WATCOM_DEBUG_SYMBOLS +unsigned short GetCS(void); +#pragma aux GetCS \ + __parm __caller [] = \ + "mov ax,cs" \ + __value [__ax] +#endif + static digld_error pe_read_header( FILE *fp, pe_exe_header *pe_hdr ) { dos_exe_header exehdr; diff --git a/bld/dig/c/ldrrex.c b/bld/dig/c/ldrrex.c index 37e3a69b31..ab5e00a812 100644 --- a/bld/dig/c/ldrrex.c +++ b/bld/dig/c/ldrrex.c @@ -29,6 +29,9 @@ * ****************************************************************************/ + +#include "enterdb.h" + /* * Pharlap executable Loader (used by 32-bit code only) * @@ -62,6 +65,14 @@ typedef struct { char *modname; } *module; +#ifdef WATCOM_DEBUG_SYMBOLS +unsigned short GetCS(void); +#pragma aux GetCS \ + __parm __caller [] = \ + "mov ax,cs" \ + __value [__ax] +#endif + static void loader_unload_image( module modhdl ) { #ifdef WATCOM_DEBUG_SYMBOLS diff --git a/bld/f77/wfc/master.mif b/bld/f77/wfc/master.mif index 26c1fec9db..0ab2ce7660 100644 --- a/bld/f77/wfc/master.mif +++ b/bld/f77/wfc/master.mif @@ -127,7 +127,7 @@ optencod_opt_qnx = -u=$(exetarg_qnx_res) !endif #optencod_enc_linux = -utf8 optencod_targets = $(target_cpu) $(host_os) -!ifeq release 0 +!ifeq debug 2 optencod_targets += dbg !endif diff --git a/bld/f77/wfl/master.mif b/bld/f77/wfl/master.mif index eb0ff8b6cd..2287615dce 100644 --- a/bld/f77/wfl/master.mif +++ b/bld/f77/wfl/master.mif @@ -80,7 +80,7 @@ optencod_opt_qnx = -u=$(exetarg_qnx_res) #optencod_enc_linux = -utf8 optencod_targets_i86 = targ2 optencod_targets = $(target_cpu) $(host_os) targ1 $(optencod_targets_$(target_cpu)) -!ifeq release 0 +!ifeq debug 2 optencod_targets += dbg !endif diff --git a/bld/graphlib/graphics.mif b/bld/graphlib/graphics.mif index 70374dd406..21dc0c8071 100644 --- a/bld/graphlib/graphics.mif +++ b/bld/graphlib/graphics.mif @@ -254,7 +254,7 @@ libtarg_name = graphi2 # # rc and others # -!ifeq release 1 +!ifeq debug 0 wsplice_extra_opts = !else wsplice_extra_opts = -d"depends.dep" diff --git a/bld/gui/ui/guiui.mif b/bld/gui/ui/guiui.mif index b925dc75eb..d41363c277 100644 --- a/bld/gui/ui/guiui.mif +++ b/bld/gui/ui/guiui.mif @@ -84,7 +84,7 @@ ui_sysobjs = & guif1hk.obj & guigetrc.obj -!ifeq release 0 +!ifneq debug 0 ui_sysobjs += uibarf.obj !endif diff --git a/bld/hdr/master.mif b/bld/hdr/master.mif index f091effb19..1bf1726c52 100644 --- a/bld/hdr/master.mif +++ b/bld/hdr/master.mif @@ -8,7 +8,7 @@ linux_options = -kLINUX -u qnx_options = -kQNX -t8 -u rdos_options = -kRDOS -!ifeq release 1 +!ifeq debug 0 wsplice_extra_opts = !else wsplice_extra_opts = -d"depends.dep" diff --git a/bld/mstools/master.mif b/bld/mstools/master.mif index e0f56b2ec0..62a81a38bf 100644 --- a/bld/mstools/master.mif +++ b/bld/mstools/master.mif @@ -60,7 +60,7 @@ exetarg_res_version_nt_x64 = exever.res #optencod_enc_linux = -utf8 optencod_targets = $(target_cpu) $(host_os) -!ifeq release 0 +!ifeq debug 2 optencod_targets += dbg !endif diff --git a/bld/ncurses/master.mif b/bld/ncurses/master.mif index 4ad6c14abc..3322aa5cdc 100644 --- a/bld/ncurses/master.mif +++ b/bld/ncurses/master.mif @@ -17,7 +17,7 @@ inc_dirs = -I"../h" # To work around duplicate inlined symbols, e.g. __sputc c_flags += -std=gnu89 !endif -!ifeq release 0 +!ifeq debug 2 c_flags += -DTRACE !endif @@ -44,7 +44,7 @@ libtarg_ncurses_objs = & lib_tput.obj & lib_ttyf.obj & read_ent.obj -!ifeq release 0 +!ifeq debug 2 libtarg_ncurses_trace_objs = & lib_data.obj & lib_trce.obj & diff --git a/bld/ndisasm/master.mif b/bld/ndisasm/master.mif index c39948d4d5..35b2e63fbe 100644 --- a/bld/ndisasm/master.mif +++ b/bld/ndisasm/master.mif @@ -104,7 +104,7 @@ msg.grh : ../stand/wdis.msg $(__MAKEFILES__) optencod_opt_qnx = -u=$(exetarg_qnx_res) !endif optencod_targets = $(host_os) -!ifeq release 0 +!ifeq debug 2 optencod_targets += dbg !endif diff --git a/bld/nwlib/master.mif b/bld/nwlib/master.mif index f17cc259d6..d72f6497c0 100644 --- a/bld/nwlib/master.mif +++ b/bld/nwlib/master.mif @@ -183,7 +183,7 @@ msg.grh : ../wlib.msg $(__MAKEFILES__) optencod_opt_qnx = -u=$(exetarg_qnx_res) !endif optencod_targets = $(host_os) -!ifeq release 0 +!ifeq debug 2 optencod_targets += dbg !endif diff --git a/bld/os2api/master.mif b/bld/os2api/master.mif index 2c30a969f0..c41cd4fdde 100644 --- a/bld/os2api/master.mif +++ b/bld/os2api/master.mif @@ -24,7 +24,7 @@ lib_dir_386 = ../lib386 mh_dir = $(incl_dir_$(targ_cpu)) -!ifeq release 1 +!ifeq debug 0 wsplice_extra_opts = !else wsplice_extra_opts = -d"depends.dep" diff --git a/bld/pbide/wig/driver/wini86/makefile b/bld/pbide/wig/driver/wini86/makefile index f03d7a27a8..306ae0e2d7 100644 --- a/bld/pbide/wig/driver/wini86/makefile +++ b/bld/pbide/wig/driver/wini86/makefile @@ -6,7 +6,7 @@ name = pbide !include deftarg.mif cflags = -bt=windows -zW -bd -zq -otexan -s -zq -fpc -w4 -ml -zu -fo=obj\.obj -!ifeq release 0 +!ifneq debug 0 cflags += -d2 !endif diff --git a/bld/rc/rc/master.mif b/bld/rc/rc/master.mif index fd95326430..8364bde19c 100644 --- a/bld/rc/rc/master.mif +++ b/bld/rc/rc/master.mif @@ -56,7 +56,7 @@ extra_cpp_flags += -DIDE_PGM extra_cpp_flags_rcmem = $(trmem_cpp_flags) !ifdef trmem_objs extra_cpp_flags_rcmem = -DRC_USE_TRMEM -!else ifeq release 0 +!else ifneq debug 0 extra_cpp_flags_rcalloc0 = -DRCMEM_DEBUG extra_cpp_flags_rcalloc1 = -DRCMEM_DEBUG !endif @@ -241,7 +241,7 @@ $(misc_objs): optencod_opt_qnx = -u=$(exetarg_qnx_res) !endif optencod_targets = $(host_os) -!ifeq release 0 +!ifeq debug 2 optencod_targets += dbg !endif diff --git a/bld/rc/rc/nt386.dbg/makefile b/bld/rc/rc/nt386.dbg/makefile index fe91429f5e..2256cb7a51 100644 --- a/bld/rc/rc/nt386.dbg/makefile +++ b/bld/rc/rc/nt386.dbg/makefile @@ -2,6 +2,6 @@ host_os = nt host_cpu = 386 -wrc_release = 0 +wrc_debug = 1 !include ../master.mif diff --git a/bld/rc/rc/os2386.dbg/makefile b/bld/rc/rc/os2386.dbg/makefile index 1c994d01c6..8a89b27b1c 100644 --- a/bld/rc/rc/os2386.dbg/makefile +++ b/bld/rc/rc/os2386.dbg/makefile @@ -2,6 +2,6 @@ host_os = os2 host_cpu = 386 -wrc_release = 0 +wrc_debug = 1 !include ../master.mif diff --git a/bld/sdk/ddespy/master.mif b/bld/sdk/ddespy/master.mif index 7d43915952..dd25cebe2d 100644 --- a/bld/sdk/ddespy/master.mif +++ b/bld/sdk/ddespy/master.mif @@ -52,7 +52,7 @@ exetarg_nt_manif_x64 = ntmanif.res !include exetarg.mif #!ifeq host_cpu axp -#!ifeq release 0 +#!ifneq debug 0 # cvpack $^&.exe # @%make echo_wstrip_sym # $(wstrip) $^&.exe $^&.exe $^&.sym diff --git a/bld/sdk/drwat/faults/master.mif b/bld/sdk/drwat/faults/master.mif index 264e1be0f5..d450dc2055 100644 --- a/bld/sdk/drwat/faults/master.mif +++ b/bld/sdk/drwat/faults/master.mif @@ -4,7 +4,7 @@ proj_name = fault fault_autodepends = .AUTODEPEND -fault_release = 0 # always build debug versions of these +fault_debug = 1 # always build debug versions of these !include cproj.mif !include defrule.mif diff --git a/bld/sdk/fmedit/ntx64/makefile b/bld/sdk/fmedit/ntx64/makefile index a8c1eda378..580e52185c 100644 --- a/bld/sdk/fmedit/ntx64/makefile +++ b/bld/sdk/fmedit/ntx64/makefile @@ -3,6 +3,6 @@ host_os = nt host_cpu = x64 -fmedit_release = 0 +fmedit_debug = 1 !include ../master.mif diff --git a/bld/sdk/imgedit/ntx64/makefile b/bld/sdk/imgedit/ntx64/makefile index 44fc883e8d..f9e63f9b6f 100644 --- a/bld/sdk/imgedit/ntx64/makefile +++ b/bld/sdk/imgedit/ntx64/makefile @@ -2,6 +2,6 @@ host_os = nt host_cpu = x64 -wimgedit_release = 0 +wimgedit_debug = 1 !include ../master.mif diff --git a/bld/sdk/wde/ntx64/makefile b/bld/sdk/wde/ntx64/makefile index 49a617f673..93c9256dda 100644 --- a/bld/sdk/wde/ntx64/makefile +++ b/bld/sdk/wde/ntx64/makefile @@ -2,6 +2,6 @@ host_os = nt host_cpu = x64 -wde_release = 0 +wde_debug = 1 !include ../master.mif diff --git a/bld/sdk/wre/ntx64/makefile b/bld/sdk/wre/ntx64/makefile index 1eb2f0f99e..313cc833cd 100644 --- a/bld/sdk/wre/ntx64/makefile +++ b/bld/sdk/wre/ntx64/makefile @@ -2,6 +2,6 @@ host_os = nt host_cpu = x64 -wre_release = 0 +wre_debug = 1 !include ../master.mif diff --git a/bld/sdk/wresedit/waccel/ntx64/makefile b/bld/sdk/wresedit/waccel/ntx64/makefile index 61186d26ca..7059f84db7 100644 --- a/bld/sdk/wresedit/waccel/ntx64/makefile +++ b/bld/sdk/wresedit/waccel/ntx64/makefile @@ -2,6 +2,6 @@ host_os = nt host_cpu = x64 -wresedit_release = 0 +wresedit_debug = 1 !include ../waccel.mif diff --git a/bld/sdk/wresedit/wmenu/ntx64/makefile b/bld/sdk/wresedit/wmenu/ntx64/makefile index 702df14c75..6b0cdcddf3 100644 --- a/bld/sdk/wresedit/wmenu/ntx64/makefile +++ b/bld/sdk/wresedit/wmenu/ntx64/makefile @@ -2,6 +2,6 @@ host_os = nt host_cpu = x64 -wresedit_release = 0 +wresedit_debug = 1 !include ../wmenu.mif diff --git a/bld/sdk/wresedit/wstring/ntx64/makefile b/bld/sdk/wresedit/wstring/ntx64/makefile index cc9c757a9b..978dea8d3b 100644 --- a/bld/sdk/wresedit/wstring/ntx64/makefile +++ b/bld/sdk/wresedit/wstring/ntx64/makefile @@ -2,6 +2,6 @@ host_os = nt host_cpu = x64 -wresedit_release = 0 +wresedit_debug = 1 !include ../wstring.mif diff --git a/bld/sdk/zoom/ntx64/makefile b/bld/sdk/zoom/ntx64/makefile index 2eb35d4a31..53359e9efb 100644 --- a/bld/sdk/zoom/ntx64/makefile +++ b/bld/sdk/zoom/ntx64/makefile @@ -2,6 +2,6 @@ host_os = nt host_cpu = x64 -wzoom_release = 0 +wzoom_debug = 1 !include ../master.mif diff --git a/bld/trap/master.mif b/bld/trap/master.mif index 7ca43ef682..8af7bca5c8 100644 --- a/bld/trap/master.mif +++ b/bld/trap/master.mif @@ -161,7 +161,7 @@ extra_cpp_flags += -DBUILTIN_TRAP_FILE !ifdef japanese extra_cpp_flags += -DJAPANESE !endif -!ifeq release 0 +!ifeq debug 2 !ifeq host_os nov extra_cpp_flags += -DDEBUG_ME !endif @@ -271,7 +271,7 @@ remote_objs = & $(srv)link.obj & !endif -!ifeq release 1 +!ifeq debug 0 objs = $(extra_objs) $($(which)_common_objs) mxutil.obj $(remote_objs) !else objs = $(extra_dobjs) $($(which)_common_objs) mxutil.obj $(remote_objs) diff --git a/bld/trap/nmp/nmpbind/makefile b/bld/trap/nmp/nmpbind/makefile index 53f7d3c6db..0cb646e261 100644 --- a/bld/trap/nmp/nmpbind/makefile +++ b/bld/trap/nmp/nmpbind/makefile @@ -34,10 +34,10 @@ extra_l_flags = op stack=8k # explicit rules ################# -!ifeq release 0 -default_targ = d -!else +!ifeq debug 0 default_targ = w +!else +default_targ = d !endif first : $(default_targ) diff --git a/bld/trap/par/ntsupp.x64/makefile b/bld/trap/par/ntsupp.x64/makefile index 26425aaa2e..61803e1834 100644 --- a/bld/trap/par/ntsupp.x64/makefile +++ b/bld/trap/par/ntsupp.x64/makefile @@ -11,15 +11,15 @@ host_cpu = x64 all: dbginst.exe .SYMBOLIC -!ifeq release 0 +!ifeq debug 0 -debug_compiler=/Z7 /Odi -debug_linker=-debug:none -debugtype:both /pdb:none +debug_compiler= +debug_linker=-debug:none !else -debug_compiler= -debug_linker=-debug:none +debug_compiler=/Z7 /Odi +debug_linker=-debug:none -debugtype:both /pdb:none !endif diff --git a/bld/trap/par/ntsupp/makefile b/bld/trap/par/ntsupp/makefile index 529336f067..2f5909b3bd 100644 --- a/bld/trap/par/ntsupp/makefile +++ b/bld/trap/par/ntsupp/makefile @@ -11,15 +11,15 @@ host_cpu = 386 all: dbginst.exe .SYMBOLIC -!ifeq release 0 +!ifeq debug 0 -debug_compiler=/Z7 /Odi -debug_linker=-debug:none -debugtype:both /pdb:none +debug_compiler= +debug_linker=-debug:none !else -debug_compiler= -debug_linker=-debug:none +debug_compiler=/Z7 /Odi +debug_linker=-debug:none -debugtype:both /pdb:none !endif diff --git a/bld/trap/trap.mif b/bld/trap/trap.mif index 9b53e886d0..324dff5609 100644 --- a/bld/trap/trap.mif +++ b/bld/trap/trap.mif @@ -45,7 +45,7 @@ full_export = 1 alias_symbols_nt = alias __DLLstart_='_LibMain@12' !endif -!ifneq release 0 +!ifeq debug 0 dllbase = $(trap_dllbase_$(host_os)_$(host_cpu)) !endif diff --git a/bld/ui/ui.mif b/bld/ui/ui.mif index 4f8a337e3f..00a98a154e 100644 --- a/bld/ui/ui.mif +++ b/bld/ui/ui.mif @@ -30,7 +30,7 @@ extra_cpp_flags_nov = -D_NETWARE_CLIB extra_cpp_flags_uialloc = $(trmem_cpp_flags) -!ifeq release 1 +!ifeq debug 0 extra_c_flags = -os !endif diff --git a/bld/vi/mif/compile.mif b/bld/vi/mif/compile.mif index d2f4c61b4b..8c7e780576 100644 --- a/bld/vi/mif/compile.mif +++ b/bld/vi/mif/compile.mif @@ -23,7 +23,7 @@ extra_cpp_flags = -DINSIDE_VI extra_cpp_flags += -DNOUSE3D -D__WIN__ !else !ifeq ui_os unix -!ifeq release 0 +!ifneq debug 0 extra_cpp_flags += -DTRACE !endif !endif diff --git a/bld/w16api/master.mif b/bld/w16api/master.mif index b4c3e4676a..8284aaf9fb 100644 --- a/bld/w16api/master.mif +++ b/bld/w16api/master.mif @@ -14,7 +14,7 @@ additional_clean = $(crwatpro_gsp) depends.dep mh_dir = ../include -!ifeq release 1 +!ifeq debug 0 wsplice_extra_opts = !else wsplice_extra_opts = -d"depends.dep" diff --git a/bld/w32api/incl.mif b/bld/w32api/incl.mif index 13f8ca38aa..fe1f0b25d7 100644 --- a/bld/w32api/incl.mif +++ b/bld/w32api/incl.mif @@ -14,7 +14,7 @@ additional_clean = $(crwatpro_gsp) depends.dep mh_dir = $(w32api_dir)/include -!ifeq release 1 +!ifeq debug 0 wsplice_extra_opts = !else wsplice_extra_opts = -d"depends.dep" diff --git a/bld/wasm/master.mif b/bld/wasm/master.mif index 8c43e1aa59..bbdcb49338 100644 --- a/bld/wasm/master.mif +++ b/bld/wasm/master.mif @@ -24,7 +24,7 @@ inc_dirs = -I. -I"../h" -I"$(fe_misc_dir)/h" extra_cpp_flags =-D_STANDALONE_ #extra_cpp_flags += -DINCL_MSGTEXT -!ifeq release 0 +!ifeq debug 2 extra_cpp_flags += -DDEBUG_OUT !endif @@ -121,7 +121,7 @@ wasmsmsg.grh : ../h/wasms.msg $(__MAKEFILES__) optencod_opt_qnx = -u=$(exetarg_qnx_res) !endif optencod_targets = $(host_os) -!ifeq release 0 +!ifeq debug 2 optencod_targets += dbg !endif diff --git a/bld/wasm/nt386.dbg/makefile b/bld/wasm/nt386.dbg/makefile index 6b9c219ce9..32b57f1392 100644 --- a/bld/wasm/nt386.dbg/makefile +++ b/bld/wasm/nt386.dbg/makefile @@ -3,6 +3,6 @@ host_os = nt host_cpu = 386 -wasm_release = 0 +wasm_debug = 1 !include ../master.mif diff --git a/bld/wcl/master.mif b/bld/wcl/master.mif index 65970a0a8e..6c5b912a0f 100644 --- a/bld/wcl/master.mif +++ b/bld/wcl/master.mif @@ -81,7 +81,7 @@ optencod_opt_qnx = -u=$(exetarg_qnx_res) !endif #optencod_enc_linux = -utf8 optencod_targets = $(target_cpu) $(host_os) -!ifeq release 0 +!ifeq debug 2 optencod_targets += dbg !endif diff --git a/bld/wipfc/master.mif b/bld/wipfc/master.mif index a77c005c4e..6e8f6dcda2 100644 --- a/bld/wipfc/master.mif +++ b/bld/wipfc/master.mif @@ -17,7 +17,7 @@ inc_dirs = -I"../cpp" -I"../icu/common" extra_cpp_flags = -D__STDC_LIMIT_MACROS -DU_NOEXCEPT= -DU_DISABLE_RENAMING extra_cxx_flags = -xs -!ifeq release 0 +!ifneq debug 0 extra_cxx_flags += -et !endif diff --git a/bld/wl/c/cmdall.c b/bld/wl/c/cmdall.c index 5909fd0872..432bf8d102 100644 --- a/bld/wl/c/cmdall.c +++ b/bld/wl/c/cmdall.c @@ -1569,7 +1569,7 @@ static bool ProcModule( void ) } #endif -#ifdef _INT_DEBUG +#ifdef DEVBUILD static bool ProcXDbg( void ) /*************************** * process DEBUG command @@ -2148,7 +2148,7 @@ static parse_entry Directives[] = { #if defined( _OS2 ) || defined( _EXE ) || defined ( _QNX ) "NEWsegment", ProcNewSegment, (MK_OS2_16BIT | MK_DOS | MK_QNX), 0, #endif -#ifdef _INT_DEBUG +#ifdef DEVBUILD "Xdbg", ProcXDbg, MK_ALL, 0, "INTDBG", ProcIntDbg, MK_ALL, 0, #endif diff --git a/bld/wl/c/cmddos.c b/bld/wl/c/cmddos.c index 3765681a0d..4297bda4d9 100644 --- a/bld/wl/c/cmddos.c +++ b/bld/wl/c/cmddos.c @@ -74,7 +74,7 @@ overlay_ref GetOvlRef( void ) return( ( OvlLevel == 0 ) ? 0 : OvlSectNum - 1 ); } -#ifdef _INT_DEBUG +#ifdef DEVBUILD static void PrintAreas( OVL_AREA *ovlarea ); static void PrintSect( section *sect ) @@ -182,7 +182,7 @@ void CmdOvlFini( void ) } SetOvlClasses(); MakeNonArea(); -#ifdef _INT_DEBUG +#ifdef DEVBUILD PrintOvl(); #endif } diff --git a/bld/wl/c/dbginfo.c b/bld/wl/c/dbginfo.c index 90791cbefb..c8b777e483 100644 --- a/bld/wl/c/dbginfo.c +++ b/bld/wl/c/dbginfo.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -100,7 +100,7 @@ static master_dbg_header Master; // rest depend on .obj files. static snamelist *DBISourceLang; // list of source languages -#ifdef _INT_DEBUG +#ifdef DEVBUILD struct { offset sizeadded; offset sizegenned; @@ -132,7 +132,7 @@ void ODBIInit( section *sect ) DBISourceLang->next = NULL; _PermAlloc( sect->dbg_info, sizeof( debug_info ) ); memset( sect->dbg_info, 0, sizeof( debug_info ) ); //assumes NULL == 0 -#ifdef _INT_DEBUG +#ifdef DEVBUILD memset( &TraceInfo, 0, sizeof( TraceInfo ) ); #endif } @@ -200,7 +200,7 @@ static void DoAddLocal( dbi_section *dbi, offset length ) dbi->size = 0; } dbi->size += length; -#ifdef _INT_DEBUG +#ifdef DEVBUILD TraceInfo.sizeadded += length; #endif } @@ -252,7 +252,7 @@ static void DoGenLocal( dbi_section *dsect, dbi_section *dlink, demanddata *dmod } dsect->curr.u.vm_ptr += length; dmod->size += length; -#ifdef _INT_DEBUG +#ifdef DEVBUILD TraceInfo.sizegenned += length; #endif } @@ -898,7 +898,7 @@ void ODBIWrite( void ) if( Master.obj_major_ver == 0 ) Master.obj_major_ver = 1; WriteLoad( &Master, sizeof( master_dbg_header ) ); -#ifdef _INT_DEBUG +#ifdef DEVBUILD if( TraceInfo.sizeadded != TraceInfo.sizegenned ) { LnkMsg( WRN+MSG_INTERNAL, "s", "size mismatch in watcom dbi" ); } diff --git a/bld/wl/c/debug.c b/bld/wl/c/debug.c index e8e186ec9f..8139495361 100644 --- a/bld/wl/c/debug.c +++ b/bld/wl/c/debug.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -41,7 +41,7 @@ #include "alloc.h" -#ifdef _INT_DEBUG +#ifdef DEVBUILD long unsigned TrecCount; bool TrecHit = false; diff --git a/bld/wl/c/hash.c b/bld/wl/c/hash.c index bbd07b2248..32b64de673 100644 --- a/bld/wl/c/hash.c +++ b/bld/wl/c/hash.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2020 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -107,7 +107,7 @@ void *AddHTableElem( pHTable table, void *elem ) if( chainLen > table->stats.longestChainLen ) { table->stats.longestChainLen = chainLen; -#ifdef _INT_DEBUG +#ifdef DEVBUILD if( chainLen > 20 ) { LPrint( "Hash Warning: max chain len = %d getting long!" ); } diff --git a/bld/wl/c/loadraw.c b/bld/wl/c/loadraw.c index bda9331ef6..e6e4af6e84 100644 --- a/bld/wl/c/loadraw.c +++ b/bld/wl/c/loadraw.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -324,7 +324,7 @@ void HexOutput( void ) outfilelist *fnode; group_entry *group; section *sect; -#ifdef _INT_DEBUG +#ifdef DEVBUILD outfilelist *finfo; #endif #if defined( _OS2 ) || defined( _QNX ) || defined( _ELF ) @@ -360,7 +360,7 @@ void HexOutput( void ) info.offs = (group->grp_addr.off + group->linear - FmtData.output_offset); sect = wrkgrp->section; CurrSect = sect; - #ifdef _INT_DEBUG + #ifdef DEVBUILD finfo = sect->outfile; DEBUG((DBG_LOADDOS, "group %a section %d to %l in %s", &group->grp_addr, sect->ovlref, info.offs, finfo->fname )); @@ -387,7 +387,7 @@ void HexOutput( void ) sect = group->section; CurrSect = sect; info.offs = GROUP_SECTION_DELTA( group ); -#ifdef _INT_DEBUG +#ifdef DEVBUILD finfo = sect->outfile; DEBUG((DBG_LOADDOS, "group %a section %d to %l in %s", &group->grp_addr, sect->ovlref, info.offs, finfo->fname )); @@ -399,7 +399,7 @@ void HexOutput( void ) sect = group->section; CurrSect = sect; info.offs = GROUP_SECTION_DELTA( group ); -#ifdef _INT_DEBUG +#ifdef DEVBUILD finfo = sect->outfile; DEBUG((DBG_LOADDOS, "group %a section %d to %l in %s", &group->grp_addr, sect->ovlref, info.offs, finfo->fname )); diff --git a/bld/wl/c/lsymtab.c b/bld/wl/c/lsymtab.c index bf002265de..0c23499275 100644 --- a/bld/wl/c/lsymtab.c +++ b/bld/wl/c/lsymtab.c @@ -611,7 +611,7 @@ void InitSym( void ) _ChkAlloc( StaticSymPtrs, STATIC_TABALLOC ); } -#ifdef _INT_DEBUG +#ifdef DEVBUILD static void DumpTable( symbol **table, unsigned tabsize ) /*******************************************************/ @@ -694,7 +694,7 @@ void CleanSym( void ) symbol * sym; symbol * next; -#ifdef _INT_DEBUG +#ifdef DEVBUILD DumpHashTable(); #endif if( (LinkFlags & LF_INC_LINK_FLAG) == 0 ) { @@ -987,7 +987,7 @@ static symbol *DoSymOp( sym_flags symop, const char *symname, size_t length ) unsigned hash; symbol *sym; size_t searchlen; -#ifdef _INT_DEBUG +#ifdef DEVBUILD char *symname_dbg; DUPSTR_STACK( symname_dbg, symname, length ); diff --git a/bld/wl/c/ntio.c b/bld/wl/c/ntio.c index 376007a0f8..70ab976caf 100644 --- a/bld/wl/c/ntio.c +++ b/bld/wl/c/ntio.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -247,7 +247,7 @@ size_t QWrite( f_handle file, const void *buffer, size_t len, const char *name ) if( len == 0 ) return( 0 ); -#ifdef _INT_DEBUG +#ifdef DEVBUILD { unsigned long pos = QPos(file); diff --git a/bld/wl/c/objomf.c b/bld/wl/c/objomf.c index adcae1ea59..7335173836 100644 --- a/bld/wl/c/objomf.c +++ b/bld/wl/c/objomf.c @@ -815,7 +815,7 @@ static void ProcLxdata( bool islidata ) _TargU16toHost( MGET_U16_UN( ObjBuff ), obj_offset ); ObjBuff += sizeof( unsigned_16 ); } -#ifdef _DEVELOPMENT +#ifdef DEVBUILD if( stricmp( seg->entry->u.leader->segname.u.ptr, "_BSS" ) == 0 ) { LnkMsg( LOC_REC+ERR+MSG_INTERNAL, "s", "Initialized BSS found" ); } diff --git a/bld/wl/c/objorl.c b/bld/wl/c/objorl.c index db7714f6c0..cd44ae898e 100644 --- a/bld/wl/c/objorl.c +++ b/bld/wl/c/objorl.c @@ -506,7 +506,7 @@ static orl_return DeclareSegment( orl_sec_handle sec ) sdata->iscode = true; } else if( flags & ORL_SEC_FLAG_UNINITIALIZED_DATA ) { sdata->isuninit = true; -#ifdef _DEVELOPMENT +#ifdef DEVBUILD } else { unsigned namelen; diff --git a/bld/wl/c/objpass2.c b/bld/wl/c/objpass2.c index 294b571a03..b8c9a699bb 100644 --- a/bld/wl/c/objpass2.c +++ b/bld/wl/c/objpass2.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2020 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -117,7 +117,7 @@ bool LoadObj( segdata *seg ) CurrRec.seg = seg; if( leader->group == NULL ) { CurrRec.addr = leader->seg_addr; -#ifdef _DEVELOPMENT +#ifdef DEVBUILD LnkMsg( WRN+MSG_INTERNAL, "s", "null leader group found" ); #endif } else { diff --git a/bld/wl/c/symmem.c b/bld/wl/c/symmem.c index b9e21df26a..af4073c9a9 100644 --- a/bld/wl/c/symmem.c +++ b/bld/wl/c/symmem.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -89,7 +89,7 @@ static bool ShrinkBlock( block_data *block ) _LnkRealloc( new, block->list, block->currbrk + ALLOC_SIZE ); new->size = block->currbrk; /* assuming that a shrinkage will not move the block */ - #ifdef _DEVELOPMENT + #ifdef DEVBUILD if( new != block->list ) { LnkMsg( FTL+MSG_INTERNAL, "s", "realloc moved shrinked block!" ); } diff --git a/bld/wl/c/wcomdef.c b/bld/wl/c/wcomdef.c index 9ea8a33f5a..9b370a3262 100644 --- a/bld/wl/c/wcomdef.c +++ b/bld/wl/c/wcomdef.c @@ -393,7 +393,7 @@ static bool CompInfoSym( void *info, void *sym ) return( ((comdat_info *)info)->sym == (symbol *)sym ); } -#ifdef _INT_DEBUG +#ifdef DEVBUILD static bool CheckSameComdat( void *info, void *sym ) /***********************************************************/ { @@ -501,7 +501,7 @@ void ProcComdat( void ) info->flags = (attr & CDAT_SELECT_MASK) << CDAT_SELECT_SHIFT; info->flags |= SYM_DEAD; // assume redefined RingAppend( &info->pieces, piece ); -#ifdef _INT_DEBUG +#ifdef DEVBUILD RingLookup( CDatList, CheckSameComdat, sym ); #endif RingAppend( &CDatList, info ); diff --git a/bld/wl/c/wlink.c b/bld/wl/c/wlink.c index cb051d8a29..a9ec542722 100644 --- a/bld/wl/c/wlink.c +++ b/bld/wl/c/wlink.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -86,7 +86,7 @@ #define DEF_STACK_SIZE _4K -#if defined( _INT_DEBUG ) && defined( __WATCOMC__ ) +#if defined( DEVBUILD ) && defined( __WATCOMC__ ) /* * Following symbols are specific for Open Watcom Linker generated executables * and appropriate code can be used only if this program is linked by OW Linker @@ -277,7 +277,7 @@ static void ResetSubSystems( void ) void InitSubSystems( void ) /********************************/ { -#if defined( _INT_DEBUG ) && defined( __WATCOMC__ ) +#if defined( DEVBUILD ) && defined( __WATCOMC__ ) memset( _edata, 0xA5, _end - _edata ); // don't rely on BSS == 0 #endif LnkMemInit(); diff --git a/bld/wl/ddos386/makefile b/bld/wl/ddos386/makefile index 7701009ca2..a99518516e 100644 --- a/bld/wl/ddos386/makefile +++ b/bld/wl/ddos386/makefile @@ -2,8 +2,6 @@ host_os = dos host_cpu = 386 -debug_cpp_flags=-D_DEVELOPMENT -D_INT_DEBUG - -wlink_release = 0 +debug = 2 !include ../master.mif diff --git a/bld/wl/dlnx386/makefile b/bld/wl/dlnx386/makefile index 727bff2556..a8cd49dfc4 100644 --- a/bld/wl/dlnx386/makefile +++ b/bld/wl/dlnx386/makefile @@ -3,8 +3,6 @@ host_os = linux host_cpu = 386 -debug_cpp_flags=-D_DEVELOPMENT -D_INT_DEBUG - -wlink_release = 0 +debug = 2 !include ../master.mif diff --git a/bld/wl/dnt386.dll/makefile b/bld/wl/dnt386.dll/makefile index 4c440d64c8..870b2df00e 100644 --- a/bld/wl/dnt386.dll/makefile +++ b/bld/wl/dnt386.dll/makefile @@ -2,9 +2,8 @@ host_os = nt host_cpu = 386 -debug_cpp_flags=-D_DEVELOPMENT -D_INT_DEBUG - wlink_dll = 1 -wlink_release = 0 + +debug = 2 !include ../master.mif diff --git a/bld/wl/dnt386.rtd/makefile b/bld/wl/dnt386.rtd/makefile index 5648c218fe..5f07af844e 100644 --- a/bld/wl/dnt386.rtd/makefile +++ b/bld/wl/dnt386.rtd/makefile @@ -2,10 +2,9 @@ host_os = nt host_cpu = 386 -debug_cpp_flags=-D_DEVELOPMENT -D_INT_DEBUG - wlink_dll = 1 wlink_rtdll = 1 -wlink_release = 0 + +debug = 2 !include ../master.mif diff --git a/bld/wl/dnt386/makefile b/bld/wl/dnt386/makefile index d74e831484..f281a4bdc6 100644 --- a/bld/wl/dnt386/makefile +++ b/bld/wl/dnt386/makefile @@ -2,9 +2,8 @@ host_os = nt host_cpu = 386 -debug_cpp_flags=-D_DEVELOPMENT -D_INT_DEBUG - wlink_trmem = 1 -wlink_release = 0 + +debug = 2 !include ../master.mif diff --git a/bld/wl/dntaxp/makefile b/bld/wl/dntaxp/makefile index 6c13d2af71..7480bffebd 100644 --- a/bld/wl/dntaxp/makefile +++ b/bld/wl/dntaxp/makefile @@ -2,8 +2,6 @@ host_os = nt host_cpu = axp -debug_cpp_flags=-D_DEVELOPMENT -D_INT_DEBUG - -wlink_release = 0 +debug = 2 !include ../master.mif diff --git a/bld/wl/dos2386/makefile b/bld/wl/dos2386/makefile index 5fef5d8069..5678a896c8 100644 --- a/bld/wl/dos2386/makefile +++ b/bld/wl/dos2386/makefile @@ -2,8 +2,6 @@ host_os = os2 host_cpu = 386 -debug_cpp_flags=-D_DEVELOPMENT -D_INT_DEBUG - -wlink_release = 0 +debug = 2 !include ../master.mif diff --git a/bld/wl/h/debug.h b/bld/wl/h/debug.h index 7e43a2163c..9f21c60f6d 100644 --- a/bld/wl/h/debug.h +++ b/bld/wl/h/debug.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2020 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -45,7 +45,7 @@ #define DBG_NOCRLF 0x8000 #define DBG_INFO_MASK 0x7FFF -#ifdef _INT_DEBUG +#ifdef DEVBUILD #include diff --git a/bld/wl/h/wlbanner.h b/bld/wl/h/wlbanner.h index 454336e740..9ecca5916c 100644 --- a/bld/wl/h/wlbanner.h +++ b/bld/wl/h/wlbanner.h @@ -32,7 +32,7 @@ #if 0 #define IDV "** EXPERIMENTAL ** " -#elif defined( _DEVELOPMENT ) +#elif defined( DEVBUILD ) #define IDV "**INTERNAL DEVELOPMENT** " #else #define IDV diff --git a/bld/wl/master.mif b/bld/wl/master.mif index 7c57cabbf1..09ef43e572 100644 --- a/bld/wl/master.mif +++ b/bld/wl/master.mif @@ -48,7 +48,7 @@ suppress_zc = 1 inc_dirs = -I. -I"$(wlink_dir)/h" $(dwarfw_inc_dirs) -I"$(orl_dir)/h" -I"$(wrc_dir)/h" & $(wres_inc_dirs) -I"$(lib_misc_dir)/h" -I"$(watcom_dir)/c" -extra_cpp_flags = -DINSIDE_WLINK $(debug_cpp_flags) +extra_cpp_flags = -DINSIDE_WLINK !ifdef DLLS_IMPLEMENTED extra_cpp_flags += -DDLLS_IMPLEMENTED !endif diff --git a/bld/wl/nt386.dbg/makefile b/bld/wl/nt386.dbg/makefile index e2e770bf08..dfededb205 100644 --- a/bld/wl/nt386.dbg/makefile +++ b/bld/wl/nt386.dbg/makefile @@ -3,6 +3,6 @@ host_os = nt host_cpu = 386 -wlink_release = 0 +wlink_debug = 1 !include ../master.mif diff --git a/bld/wmake/master.mif b/bld/wmake/master.mif index d34d95fb07..89a231f37d 100644 --- a/bld/wmake/master.mif +++ b/bld/wmake/master.mif @@ -14,7 +14,7 @@ wmake_trmem = 1 # DOS code will not fit in 64k with /d2 #!ifeq host_os dos #!ifeq host_cpu i86 -#wmake_release = 1 +#wmake_debug = 0 #!endif #!endif diff --git a/bld/wprof/wprofobj.mif b/bld/wprof/wprofobj.mif index 349f883da2..5107fdcade 100644 --- a/bld/wprof/wprofobj.mif +++ b/bld/wprof/wprofobj.mif @@ -1,6 +1,6 @@ srcmgt_obj = srcmgt.obj -!ifeq release 0 +!ifneq debug 0 debug_objs = dumpmem.obj !endif diff --git a/bld/wsample/master.mif b/bld/wsample/master.mif index d86f17ed75..b98f5d66ef 100644 --- a/bld/wsample/master.mif +++ b/bld/wsample/master.mif @@ -219,7 +219,7 @@ nversion.tmp: ./mknver.exe $(__MAKEFILES__) optencod_opt_qnx = -u=$(exetarg_qnx_res) !endif optencod_targets = $(target) -!ifeq release 0 +!ifeq debug 2 optencod_targets += dbg !endif diff --git a/bld/wstrip/master.mif b/bld/wstrip/master.mif index 2da3d013af..eaa57e81e1 100644 --- a/bld/wstrip/master.mif +++ b/bld/wstrip/master.mif @@ -64,7 +64,7 @@ msg.grh : ../wstrip.msg $(__MAKEFILES__) optencod_opt_qnx = -u=$(exetarg_qnx_res) !endif optencod_targets = $(host_os) -!ifeq release 0 +!ifeq debug 2 optencod_targets += dbg !endif diff --git a/bld/wstub/master.mif b/bld/wstub/master.mif index d7f70ca57f..6f71d72aa4 100644 --- a/bld/wstub/master.mif +++ b/bld/wstub/master.mif @@ -13,7 +13,7 @@ memory_model_i86 = s # .c : .. -!ifeq release 1 +!ifneq debug 0 extra_c_flags = -oaxs !endif diff --git a/bld/wtouch/master.mif b/bld/wtouch/master.mif index 72b8ee9952..46b0ff082d 100644 --- a/bld/wtouch/master.mif +++ b/bld/wtouch/master.mif @@ -52,7 +52,7 @@ msg.grh : ../wtouch.msg $(__MAKEFILES__) optencod_opt_qnx = -u=$(exetarg_qnx_res) !endif optencod_targets = $(host_os) -!ifeq release 0 +!ifeq debug 2 optencod_targets += dbg !endif diff --git a/bld/wv/master.mif b/bld/wv/master.mif index b0f22ef031..7b43d6d7c7 100644 --- a/bld/wv/master.mif +++ b/bld/wv/master.mif @@ -90,7 +90,7 @@ extra_cpp_flags = $(dig_arch_cpp_flags) -DBLDVER=$(bld_ver) !ifdef wv_engine_noui extra_cpp_flags += -D__NOUI__ !endif -!ifeq release 0 +!ifeq debug 2 extra_cpp_flags += -DAUI_DBG !endif !ifeq sys_windowed 1 @@ -460,7 +460,7 @@ litdef.gh : litdefs1.tmp litdefs2.tmp litdefm.tmp $(__MAKEFILES__) $(awk) -v prefix=DBG_DUI_LITERAL_ -v base=DBG_DUI_BASE -f $(build_dir)/makemsg2.awk -v OUTFILE=$^. litdefs2.tmp $(awk) -v prefix=DBG_DUI_MENU_ -v base=DBG_MENU_BASE -f $(build_dir)/makemsg2.awk -v OUTFILE=$^. litdefm.tmp -!ifeq release 0 +!ifeq debug 2 wsplice_keys = -kHIDDEN !endif diff --git a/bld/wv/ssl/master.mif b/bld/wv/ssl/master.mif index 5a71baf9ef..7a25f49f7b 100644 --- a/bld/wv/ssl/master.mif +++ b/bld/wv/ssl/master.mif @@ -15,7 +15,7 @@ prs_list = & $(c_prs) & $(java_prs) -!ifeq release 0 +!ifneq debug 0 ssl_options = -v !endif From a2d3af0fe8cd53f440cb026fe9cd8b20408646be Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Thu, 21 Sep 2023 16:35:32 +0200 Subject: [PATCH 157/258] update extensions list of ignored files --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index d86f9e73ee..821aa569e2 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ *.COP *.core *.d32 +*.dep *.dip *.dis # ignore *.dll files, but include *.dll subdirectories From ef052c150f3fe7d2e38c562dd5fef7ef29a08448 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Thu, 21 Sep 2023 16:36:35 +0200 Subject: [PATCH 158/258] fix run-time libraries build make files for development debug build --- bld/clib/flags.mif | 13 +++++-------- bld/clib/lib.mif | 2 +- bld/clib/master.mif | 4 ++++ bld/clib/mthread/objects.mif | 2 +- bld/clib/qa/mif/master.mif | 2 +- bld/clibtest/master.mif | 4 ++-- bld/cpplib/flags.mif | 10 +++------- bld/cpplib/lib.mif | 2 +- bld/cpplib/master.mif | 4 ++++ bld/cpplib/mklib.mif | 2 +- bld/f77/f77lib/flags.mif | 10 +++------- bld/f77/f77lib/master.mif | 4 ++++ bld/mathlib/flags.mif | 8 ++------ bld/mathlib/lib.mif | 2 +- bld/mathlib/master.mif | 4 ++++ bld/mathtest/master.mif | 4 ++-- bld/rtdll/dllname.mif | 2 +- bld/rtdll/master.mif | 6 +++--- bld/rtdll/wrtlib/os2.386/mf_rd/makefile | 2 +- bld/rtdll/wrtlib/os2.387/mf_rd/makefile | 2 +- bld/rtdll/wrtlib/winnt.386/mf_rd/makefile | 2 +- bld/rtdll/wrtlib/winnt.387/mf_rd/makefile | 2 +- 22 files changed, 47 insertions(+), 46 deletions(-) diff --git a/bld/clib/flags.mif b/bld/clib/flags.mif index b1dab74b6e..6905bb7c93 100644 --- a/bld/clib/flags.mif +++ b/bld/clib/flags.mif @@ -4,16 +4,13 @@ default_windowing = 1 !ifeq default_windowing 1 def_windowing = -DDEFWIN !endif -!ifdef lib_debug -release = 0 -!endif ####################### # C PREPROCESSOR SETINGS ###### # Include system headers in dependency lists clib_cpp_flags = -D_ENABLE_AUTODEPEND -!ifeq release 0 +!ifneq debug 0 clib_cpp_flags += -D__RUNTIME_HANDLE_CHECKS__ !endif !ifeq linkage dynamic @@ -41,7 +38,7 @@ clib_cpp_flags += $(clib_cpp_flags_$(system)) $(clib_cpp_flags_$(system)_$(proce # C COMPILER SETINGS ###### sw_c_common = $(watcom_common_cflags)-we-j-za99-zl-x-xx-zam-wpx -!ifeq release 0 +!ifneq debug 0 !else sw_c_common += -s !endif @@ -66,7 +63,7 @@ sw_c_common += -bm-bd !else ifdef mthreaded sw_c_common += -bm !endif -!ifdef lib_debug +!ifneq debug 0 sw_c_common += -en !endif @@ -102,7 +99,7 @@ sw_c_register = -5r sw_c_stack = -5s # special case switches -!ifeq release 0 +!ifneq debug 0 sw_c_fi_nonx86 = -finonx86.h !endif @@ -258,7 +255,7 @@ clib_a_flags =$(sw_a_common) $(sw_a_$(processor)_$(model)) $(sw_a_$(processor)) $(sw_a_$(system)_$(processor)) $(sw_a_$(system)) $(extra_clib_a_flags) # debug flags need to be last to override optimization flags -!ifeq release 0 +!ifneq debug 0 c_dbg_flags = -d2 a_dbg_flags = -d1 !else diff --git a/bld/clib/lib.mif b/bld/clib/lib.mif index ff13cfca2f..04e58db7e8 100644 --- a/bld/clib/lib.mif +++ b/bld/clib/lib.mif @@ -30,7 +30,7 @@ libname = clibdl$(libname_$(processor)) libname = clib$(libname_$(processor)) !endif -!ifeq release 0 +!ifneq debug 0 clib_lib_flags = -b-c-n-pa$(extra_clib_lib_flags) !else clib_lib_flags = -b-c-n-pa-s-t-zld$(extra_clib_lib_flags) diff --git a/bld/clib/master.mif b/bld/clib/master.mif index 8fb48e5dfc..4d1f6cf245 100644 --- a/bld/clib/master.mif +++ b/bld/clib/master.mif @@ -24,6 +24,10 @@ clib_host_os_rdosdev =rdosdev clib_host_os_linux =linux host_os=$(clib_host_os_$(system)) +!ifdef lib_debug +debug = 1 +!endif + !include cproj.mif !include libsubdi.mif diff --git a/bld/clib/mthread/objects.mif b/bld/clib/mthread/objects.mif index 4e33391c53..dc0cccd488 100644 --- a/bld/clib/mthread/objects.mif +++ b/bld/clib/mthread/objects.mif @@ -28,7 +28,7 @@ !include ../../../../objlist.mif -!ifeq release 0 +!ifneq debug 0 mthread_opts =-D__RUNTIME_CHECKS__ trdlist_opts =-D__RUNTIME_CHECKS__ !endif diff --git a/bld/clib/qa/mif/master.mif b/bld/clib/qa/mif/master.mif index 5681c066be..9e2e4d0287 100644 --- a/bld/clib/qa/mif/master.mif +++ b/bld/clib/qa/mif/master.mif @@ -59,7 +59,7 @@ cc_axp = *wccaxp # Avoid the need for !include $(clib_dir)/flags.mif with # debug flags need to be last to override optimization flags -!ifeq release 0 +!ifneq debug 0 c_dbg_flags = -d2 a_dbg_flags = -d1 !endif diff --git a/bld/clibtest/master.mif b/bld/clibtest/master.mif index b8a7e39e0d..379975d751 100644 --- a/bld/clibtest/master.mif +++ b/bld/clibtest/master.mif @@ -105,7 +105,7 @@ test_flags_axp = -hc # Avoid the need for !include $(clib_dir)/flags.mif with # debug flags need to be last to override optimization flags -!ifeq release 0 +!ifneq debug 0 c_dbg_flags = -d2 a_dbg_flags = -d1 !else @@ -118,7 +118,7 @@ defwin=-bw link_x86 = DEBUG dwarf link_axp = DEBUG codeview -!ifeq release 0 +!ifneq debug 0 link_opts = OPTION quiet, map, symf !else link_opts = OPTION quiet, map diff --git a/bld/cpplib/flags.mif b/bld/cpplib/flags.mif index e3bcdbf1d3..b4ae79993e 100644 --- a/bld/cpplib/flags.mif +++ b/bld/cpplib/flags.mif @@ -1,14 +1,10 @@ -!ifdef lib_debug -release = 0 -!endif - ########################## # C/C++ COMPILERS SETINGS ###### sw_c_common =$(watcom_common_cxxflags)-j-we-zl-x-xx-zam-wpx # -xr has to be on in case the user uses -xr sw_c_common += -xr -!ifeq release 0 +!ifneq debug 0 !else sw_c_common += -s !endif @@ -131,7 +127,7 @@ sw_a_linux = -bt=linux ###### # Include system headers in dependency lists plib_cpp_flags=-D_ENABLE_AUTODEPEND -!ifeq release 1 +!ifeq debug 0 plib_cpp_flags += -D__OBSCURE_STREAM_INTERNALS !endif !ifdef fs_registration @@ -173,7 +169,7 @@ plib_c_flags =$(sw_c_common) $(sw_c_$(plib_$(processor))_$(model)) $(sw_c_$(proc plib_a_flags =$(sw_a_common) $(sw_a_$(plib_$(processor))_$(model)) $(sw_a_$(processor)) $(sw_a_$(system)) # debug flags need to be last to override optimization flags -!ifeq release 0 +!ifneq debug 0 c_dbg_flags = -d2 a_dbg_flags = -d1 !else diff --git a/bld/cpplib/lib.mif b/bld/cpplib/lib.mif index 7349419961..28b99e8ffc 100644 --- a/bld/cpplib/lib.mif +++ b/bld/cpplib/lib.mif @@ -12,7 +12,7 @@ target_lib_x = plbx$(suffix).lib !endif -!ifeq release 0 +!ifneq debug 0 plib_lib_flags = -b-c-n-pa !else plib_lib_flags = -b-c-n-pa-s-t-zld diff --git a/bld/cpplib/master.mif b/bld/cpplib/master.mif index da607343d6..296f1218df 100644 --- a/bld/cpplib/master.mif +++ b/bld/cpplib/master.mif @@ -46,6 +46,10 @@ suffix = mt$(plib_suffix_$(processor)) suffix = $(plib_suffix_$(processor)) !endif +!ifdef lib_debug +debug = 1 +!endif + !include cproj.mif !include deftarg.mif !include libsubdi.mif diff --git a/bld/cpplib/mklib.mif b/bld/cpplib/mklib.mif index 00fe3d5954..4d843d98e6 100644 --- a/bld/cpplib/mklib.mif +++ b/bld/cpplib/mklib.mif @@ -23,7 +23,7 @@ files = $+ $(static_objs) $- .asm : ../../a;../../inc -!ifeq release 0 +!ifneq debug 0 objs += $(dbg_objs_c) xobjs += $(dbg_objs_c) !endif diff --git a/bld/f77/f77lib/flags.mif b/bld/f77/f77lib/flags.mif index 1b3127aa2e..78d33fa0c0 100644 --- a/bld/f77/f77lib/flags.mif +++ b/bld/f77/f77lib/flags.mif @@ -1,7 +1,3 @@ -!ifdef debug -release = 0 -!endif - ####################### # C PREPROCESSOR SETINGS ###### @@ -27,7 +23,7 @@ f77lib_cpp_flags += $(f77lib_cpp_$(system)) $(f77lib_cpp_$(system)_$(processor)) # C COMPILER SETINGS ###### sw_c_common = $(watcom_common_cflags)-j-za99-we-zl-x-xx-zam-wpx -!ifeq release 0 +!ifneq debug 0 !else sw_c_common += -s !endif @@ -199,7 +195,7 @@ flib_a_flags =$(sw_a_common) $(sw_a_$(linkage)) $(sw_a_$(flib_$(processor))_$(mo $(sw_a_$(processor)) $(sw_a_$(system)_$(flib_$(processor))) $(sw_a_$(system)) $(extra_flib_a_flags) # debug flags need to be last to override optimization flags -!ifeq release 0 +!ifneq debug 0 c_dbg_flags = -d2 a_dbg_flags = -d1 !else @@ -223,7 +219,7 @@ libname_386 = $(flib_suffix_$(convention)) libname_387 = 7$(flib_suffix_$(convention)) libname = flib$(libname_$(processor)) -!ifeq release 0 +!ifneq debug 0 flib_lib_flags = -b-c-n-pa !else flib_lib_flags = -b-c-n-pa-s-t-zld diff --git a/bld/f77/f77lib/master.mif b/bld/f77/f77lib/master.mif index c63c7ed541..a3925dda23 100644 --- a/bld/f77/f77lib/master.mif +++ b/bld/f77/f77lib/master.mif @@ -35,6 +35,10 @@ flib_host_os_netware = nov flib_host_os_linux = linux host_os = $(flib_host_os_$(system)) +!ifdef lib_debug +debug = 1 +!endif + !include cproj.mif !include deftarg.mif diff --git a/bld/mathlib/flags.mif b/bld/mathlib/flags.mif index 3804b13490..5c80bf6c85 100644 --- a/bld/mathlib/flags.mif +++ b/bld/mathlib/flags.mif @@ -1,8 +1,4 @@ -!ifdef lib_debug -release = 0 -!endif - -!ifeq release 0 +!ifneq debug 0 sw_c_common = $(watcom_common_cflags)-j-za99-we-x-xx-zam-oax-zl-wpx !else sw_c_common = $(watcom_common_cflags)-j-za99-we-x-xx-zam-s-oax-zl-wpx @@ -118,7 +114,7 @@ mlib_a_flags = $(sw_a_common) $(sw_a_$(linkage)) $(sw_a_$(mlib_$(processor))_$(m $(sw_a_$(processor)) $(sw_a_$(system)) $(extra_mlib_a_flags) # debug flags need to be last to override optimization flags -!ifeq release 0 +!ifneq debug 0 c_dbg_flags = -d2 a_dbg_flags = -d1 !else diff --git a/bld/mathlib/lib.mif b/bld/mathlib/lib.mif index d79286d1df..31ef9ba428 100644 --- a/bld/mathlib/lib.mif +++ b/bld/mathlib/lib.mif @@ -12,7 +12,7 @@ libname_386 = 3$(mlib_suffix_$(convention)) libname_387 = 387$(mlib_suffix_$(convention)) libname = math$(libname_$(processor)) -!ifeq release 0 +!ifneq debug 0 mlib_lib_flags = -b-c-n-pa !else mlib_lib_flags = -b-c-n-pa-s-t-zld diff --git a/bld/mathlib/master.mif b/bld/mathlib/master.mif index 2b6a99b68e..9e28372920 100644 --- a/bld/mathlib/master.mif +++ b/bld/mathlib/master.mif @@ -30,6 +30,10 @@ mlib_host_os_rdos = rdos mlib_host_os_rdosdev = rdosdev host_os = $(mlib_host_os_$(system)) +!ifdef lib_debug +debug = 1 +!endif + !include cproj.mif !include libsubdi.mif diff --git a/bld/mathtest/master.mif b/bld/mathtest/master.mif index c60471c13a..cecf724bbe 100644 --- a/bld/mathtest/master.mif +++ b/bld/mathtest/master.mif @@ -107,7 +107,7 @@ ext= # Avoid the need for !include $(mathlib_dir)/flags.mif with # debug flags need to be last to override optimization flags -!ifeq release 0 +!ifneq debug 0 c_dbg_flags = -d2 a_dbg_flags = -d1 !else @@ -120,7 +120,7 @@ defwin=-bw link_x86 = DEBUG dwarf link_axp = DEBUG codeview -!ifeq release 0 +!ifneq debug 0 link_opts = OPTION quiet, map, symf !else link_opts = OPTION quiet, map diff --git a/bld/rtdll/dllname.mif b/bld/rtdll/dllname.mif index 8a88cd7d03..b1023b2093 100644 --- a/bld/rtdll/dllname.mif +++ b/bld/rtdll/dllname.mif @@ -3,7 +3,7 @@ dllname_stack = s !ifdef profile dllname_profile = p !endif -!ifeq rtdll_release 0 +!ifdef lib_debug dllname_debug = d !endif dllname_clib_386 = clb diff --git a/bld/rtdll/master.mif b/bld/rtdll/master.mif index 09a9b8e64c..479178d1b3 100644 --- a/bld/rtdll/master.mif +++ b/bld/rtdll/master.mif @@ -26,7 +26,7 @@ host_os=$(rtdll_host_os_$(system)) !ifdef profile rtdll_nosymfile = 1 -!else ifeq release 0 +!else ifneq debug 0 rtdll_nosymfile = 1 !endif @@ -56,7 +56,7 @@ patch_level=0 # lflags # extra_l_flags_dll = option impfile=$(dllname).ilb reference __DLLstart_ disable 121 $(rtdll_dllbase_$(system)_$(host_cpu)_$(component)) -!ifeq release 0 +!ifneq debug 0 extra_l_flags_dll += option mangle,artificial,verbose !endif @@ -66,7 +66,7 @@ extra_l_flags_dll_nt = initinstance terminstance # # libflags # -!ifeq release 0 +!ifneq debug 0 extra_lib_flags = -irn !else extra_lib_flags = -irn -s-t-zld diff --git a/bld/rtdll/wrtlib/os2.386/mf_rd/makefile b/bld/rtdll/wrtlib/os2.386/mf_rd/makefile index 70f57331aa..834b7917af 100644 --- a/bld/rtdll/wrtlib/os2.386/mf_rd/makefile +++ b/bld/rtdll/wrtlib/os2.386/mf_rd/makefile @@ -6,6 +6,6 @@ model = mf system = os2 convention = register -rtdll_release = 0 +lib_debug = 1 !include ../../../rtdll.mif diff --git a/bld/rtdll/wrtlib/os2.387/mf_rd/makefile b/bld/rtdll/wrtlib/os2.387/mf_rd/makefile index 95969f1226..95f21eefb1 100644 --- a/bld/rtdll/wrtlib/os2.387/mf_rd/makefile +++ b/bld/rtdll/wrtlib/os2.387/mf_rd/makefile @@ -6,6 +6,6 @@ model = mf system = os2 convention = register -rtdll_release = 0 +lib_debug = 1 !include ../../../rtdll.mif diff --git a/bld/rtdll/wrtlib/winnt.386/mf_rd/makefile b/bld/rtdll/wrtlib/winnt.386/mf_rd/makefile index 188c16bc9f..d1aa6c40cf 100644 --- a/bld/rtdll/wrtlib/winnt.386/mf_rd/makefile +++ b/bld/rtdll/wrtlib/winnt.386/mf_rd/makefile @@ -6,6 +6,6 @@ model = mf system = winnt convention = register -rtdll_release = 0 +lib_debug = 1 !include ../../../rtdll.mif diff --git a/bld/rtdll/wrtlib/winnt.387/mf_rd/makefile b/bld/rtdll/wrtlib/winnt.387/mf_rd/makefile index 42e1d20137..c69cae87e8 100644 --- a/bld/rtdll/wrtlib/winnt.387/mf_rd/makefile +++ b/bld/rtdll/wrtlib/winnt.387/mf_rd/makefile @@ -6,6 +6,6 @@ model = mf system = winnt convention = register -rtdll_release = 0 +lib_debug = 1 !include ../../../rtdll.mif From 4ef39aa6f5aa3df5c4985de090404a557fcb4c82 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Fri, 22 Sep 2023 00:51:44 +0200 Subject: [PATCH 159/258] add new wendian.h global header file to cover POSIX endian.h --- bld/watcom/h/wendian.h | 67 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 bld/watcom/h/wendian.h diff --git a/bld/watcom/h/wendian.h b/bld/watcom/h/wendian.h new file mode 100644 index 0000000000..50f9b82abd --- /dev/null +++ b/bld/watcom/h/wendian.h @@ -0,0 +1,67 @@ +/**************************************************************************** +* +* Open Watcom Project +* +* Copyright (c) 2018-2022 The Open Watcom Contributors. All Rights Reserved. +* +* ======================================================================== +* +* Description: Include POSIX endian.h header file or appropriate macros. +* +****************************************************************************/ + + +#ifdef __BSD__ + #include +#elif defined( __LINUX__ ) && !defined( __WATCOMC__ ) + #include +#elif defined( __WATCOMC__ ) && ( __WATCOMC__ > 1290 ) + #include +#else +/* + * endian.h content + */ +#define LITTLE_ENDIAN 1234 +#define BIG_ENDIAN 4321 + +#define _SWAPNC_16(w) \ +(\ + (((w) & 0x000000FFUL) << 8)\ + | (((w) & 0x0000FF00UL) >> 8)\ +) +#define _SWAPNC_32(w) \ +(\ + (((w) & 0x000000FFUL) << 24)\ + | (((w) & 0x0000FF00UL) << 8)\ + | (((w) & 0x00FF0000UL) >> 8)\ + | (((w) & 0xFF000000UL) >> 24)\ +) +#define _SWAPNC_64(w) \ +(\ + (((w) & 0x00000000000000FFULL) << 56)\ + | (((w) & 0x000000000000FF00ULL) << 40)\ + | (((w) & 0x0000000000FF0000ULL) << 24)\ + | (((w) & 0x00000000FF000000ULL) << 8)\ + | (((w) & 0x000000FF00000000ULL) >> 8)\ + | (((w) & 0x0000FF0000000000ULL) >> 24)\ + | (((w) & 0x00FF000000000000ULL) >> 40)\ + | (((w) & 0xFF00000000000000ULL) >> 56)\ +) + +#define BYTE_ORDER LITTLE_ENDIAN + +#define htobe16(x) _SWAPNC_16(x) +#define htole16(x) (x) +#define be16toh(x) _SWAPNC_16(x) +#define le16toh(x) (x) + +#define htobe32(x) _SWAPNC_32(x) +#define htole32(x) (x) +#define be32toh(x) _SWAPNC_32(x) +#define le32toh(x) (x) + +#define htobe64(x) _SWAPNC_64(x) +#define htole64(x) (x) +#define be64toh(x) _SWAPNC_64(x) +#define le64toh(x) (x) +#endif From 25e7783802fa5ee46fca6d70c14e7a65d030bbcd Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Fri, 22 Sep 2023 01:24:15 +0200 Subject: [PATCH 160/258] revert unwanted change --- bld/clib/process/a/ergospwn.asm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bld/clib/process/a/ergospwn.asm b/bld/clib/process/a/ergospwn.asm index 878824381c..7449c4966f 100644 --- a/bld/clib/process/a/ergospwn.asm +++ b/bld/clib/process/a/ergospwn.asm @@ -26,7 +26,7 @@ ;* ;* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE ;* DESCRIBE IT HERE! -* (32-bit code only) +;* (32-bit code only) ;* ;***************************************************************************** From 5035bca9fbd77f9c22f24a0ac4906a9e744aa9ba Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Fri, 22 Sep 2023 08:10:20 +0200 Subject: [PATCH 161/258] fix build break for OW installers build --- bld/rtdll/master.mif | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bld/rtdll/master.mif b/bld/rtdll/master.mif index 479178d1b3..f160122245 100644 --- a/bld/rtdll/master.mif +++ b/bld/rtdll/master.mif @@ -26,7 +26,7 @@ host_os=$(rtdll_host_os_$(system)) !ifdef profile rtdll_nosymfile = 1 -!else ifneq debug 0 +!else ifdef lib_debug rtdll_nosymfile = 1 !endif From 728a63794c8777458f91fe21470e901cf13be15a Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Fri, 22 Sep 2023 11:08:28 +0200 Subject: [PATCH 162/258] fix wlink memory leak --- bld/wl/c/libr.c | 14 ++++++++++++-- bld/wl/c/objorl.c | 5 ----- bld/wl/c/procfile.c | 17 ++++++----------- bld/wl/h/objstruc.h | 9 ++++----- 4 files changed, 22 insertions(+), 23 deletions(-) diff --git a/bld/wl/c/libr.c b/bld/wl/c/libr.c index 66450bffe5..16b521a7f5 100644 --- a/bld/wl/c/libr.c +++ b/bld/wl/c/libr.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -46,6 +46,9 @@ #include "procfile.h" #include "ar.h" #include "omfhash.h" +#include "strtab.h" +#include "carve.h" +#include "permdata.h" #include "clibext.h" @@ -616,6 +619,7 @@ mod_entry *SearchLib( file_list *lib, const char *name ) unsigned long pos; unsigned long dummy; bool retval; + char *objname; pos = 0; if( lib->u.dict == NULL ) { @@ -638,11 +642,17 @@ mod_entry *SearchLib( file_list *lib, const char *name ) * update lib struct since we found desired object file */ obj = NewModEntry(); - obj->name.u.ptr = IdentifyObject( lib, &pos, &dummy ); obj->location = pos; obj->f.source = lib; obj->modtime = lib->infile->modtime; obj->modinfo = (lib->flags & DBI_MASK) | (ObjFormat & FMT_OBJ_FMT_MASK); + objname = IdentifyObject( lib, &pos, &dummy ); + if( objname != NULL ) { + obj->name.u.ptr = AddStringStringTable( &PermStrings, objname ); + _LnkFree( objname ); + } else { + obj->name.u.ptr = NULL; + } return( obj ); } diff --git a/bld/wl/c/objorl.c b/bld/wl/c/objorl.c index cd44ae898e..3279567f7f 100644 --- a/bld/wl/c/objorl.c +++ b/bld/wl/c/objorl.c @@ -607,11 +607,6 @@ static orl_return ProcSymbol( orl_symbol_handle symhdl ) type = ORLSymbolGetType( symhdl ); name = ORLSymbolGetName( symhdl ); if( type & ORL_SYM_TYPE_FILE ) { - if( (CurrMod->modinfo & MOD_GOT_NAME) == 0 ) { - CurrMod->modinfo |= MOD_GOT_NAME; - _LnkFree( CurrMod->name.u.ptr ); - CurrMod->name.u.ptr = AddStringStringTable( &PermStrings, name ); - } return( ORL_OKAY ); } if( type & ORL_SYM_TYPE_DEBUG ) diff --git a/bld/wl/c/procfile.c b/bld/wl/c/procfile.c index cb8248a1d6..2827a77acb 100644 --- a/bld/wl/c/procfile.c +++ b/bld/wl/c/procfile.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -440,10 +440,12 @@ static void DoPass1( mod_entry *next, file_list *list ) } AddToModList( next ); next->location = loc; - if( membname == NULL ) { - membname = ChkStrDup( list->infile->name.u.ptr ); + if( membname != NULL ) { + next->name.u.ptr = AddStringStringTable( &PermStrings, membname ); + _LnkFree( membname ); + } else { + next->name.u.ptr = list->infile->name.u.ptr; } - next->name.u.ptr = membname; loc = ObjPass1(); if( list->flags & STAT_TRACE_SYMS ) { TraceSymList( CurrMod->publist ); @@ -624,7 +626,6 @@ unsigned long ObjPass1( void ) /* Pass 1 of 8086 linker. */ { unsigned long loc; - char *savename; DEBUG(( DBG_BASE, "1 : file = %s, module = %s", CurrMod->f.source->infile->name.u.ptr, CurrMod->name.u.ptr )); CurrMod->modinfo |= MOD_DONE_PASS_1; @@ -635,12 +636,6 @@ unsigned long ObjPass1( void ) loc = Process[GET_FMT_IDX( ObjFormat )].Pass1(); CollapseLazyExtdefs(); SymModEnd(); - if( (CurrMod->modinfo & MOD_GOT_NAME) == 0 ) { - savename = CurrMod->name.u.ptr; - CurrMod->name.u.ptr = AddStringStringTable( &PermStrings, savename ); - _LnkFree( savename ); - CurrMod->modinfo |= MOD_GOT_NAME; - } DBIP1ModuleScanned(); ReleaseNames(); PermEndMod( CurrMod ); diff --git a/bld/wl/h/objstruc.h b/bld/wl/h/objstruc.h index a13458cc8f..8b85d17da3 100644 --- a/bld/wl/h/objstruc.h +++ b/bld/wl/h/objstruc.h @@ -195,11 +195,10 @@ typedef enum { MOD_VISITED = CONSTU32( 0x00000400 ), // true if visited in call graph analysis. MOD_NEED_PASS_2 = CONSTU32( 0x00000800 ), // true if pass 2 needed for this module. MOD_LAST_SEG = CONSTU32( 0x00001000 ), // true if this module should end a group - MOD_GOT_NAME = CONSTU32( 0x00002000 ), // true if already got a source file name - MOD_IMPORT_LIB = CONSTU32( 0x00004000 ), // ORL: true if this is an import lib. - MOD_KILL = CONSTU32( 0x00008000 ), // module should be removed from list - MOD_FLATTEN_DBI = CONSTU32( 0x00010000 ), // flatten DBI found in this mod. - MOD_DONE_PASS_1 = CONSTU32( 0x00020000 ), // module been through pass 1 already. + MOD_IMPORT_LIB = CONSTU32( 0x00002000 ), // ORL: true if this is an import lib. + MOD_KILL = CONSTU32( 0x00004000 ), // module should be removed from list + MOD_FLATTEN_DBI = CONSTU32( 0x00008000 ), // flatten DBI found in this mod. + MOD_DONE_PASS_1 = CONSTU32( 0x00010000 ), // module been through pass 1 already. MOD_IS_FREE = CONSTU32( 0x80000000 ), // used for marking carve free blocks } module_flags; From 6734faeabbba3be04668c587e0261d62495f78cc Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Fri, 22 Sep 2023 21:49:30 +0200 Subject: [PATCH 163/258] cleanup code update comment do make file more portable --- bld/watcom/h/wendian.h | 10 ++++++---- distrib/ow/master.mif | 6 ++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/bld/watcom/h/wendian.h b/bld/watcom/h/wendian.h index 50f9b82abd..e25a6f7e9e 100644 --- a/bld/watcom/h/wendian.h +++ b/bld/watcom/h/wendian.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2018-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2018-2023 The Open Watcom Contributors. All Rights Reserved. * * ======================================================================== * @@ -19,15 +19,17 @@ #include #else /* - * endian.h content + * Intel systems without endian.h + * OW 1.9, MSVC, OSX + * implementation of endian.h content */ #define LITTLE_ENDIAN 1234 #define BIG_ENDIAN 4321 #define _SWAPNC_16(w) \ (\ - (((w) & 0x000000FFUL) << 8)\ - | (((w) & 0x0000FF00UL) >> 8)\ + (((w) & 0x00FFU) << 8)\ + | (((w) & 0xFF00U) >> 8)\ ) #define _SWAPNC_32(w) \ (\ diff --git a/distrib/ow/master.mif b/distrib/ow/master.mif index 71d87378e9..d3b66aed94 100644 --- a/distrib/ow/master.mif +++ b/distrib/ow/master.mif @@ -82,8 +82,10 @@ nulldevice = /dev/null nulldevice = nul !endif -!ifdef %OWDEBUGBUILD -debug = $(%OWDEBUGBUILD) +!ifeq %OWDEBUGBUILD 1 +debug = 1 +!else ifeq %OWDEVBUILD 1 +debug = 1 !endif distrib_bindir = ../bin From 708f39c2fb7cca681bfe36ce9ead17b008191414 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Sat, 23 Sep 2023 16:28:18 +0200 Subject: [PATCH 164/258] fix ms2wlink debug version build --- bld/wl/ms2wlink/master.mif | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bld/wl/ms2wlink/master.mif b/bld/wl/ms2wlink/master.mif index 143082827a..708679ec23 100644 --- a/bld/wl/ms2wlink/master.mif +++ b/bld/wl/ms2wlink/master.mif @@ -6,7 +6,7 @@ ms2wlink_autodepends = .AUTODEPEND ms2wlink_trmem = 1 -memory_model_i86 = c +memory_model_i86 = m !include cproj.mif !include defrule.mif From 3991d2f8f65198b6449cfe740e3760c64d0daa83 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Wed, 27 Sep 2023 08:45:16 +0200 Subject: [PATCH 165/258] reformat/update comments --- bld/cc/c/asmstmt.c | 16 ++- bld/cc/c/browsio.c | 112 +++++++++------- bld/cc/c/casian.c | 20 +-- bld/cc/c/ccheck.c | 143 ++++++++++++++------ bld/cc/c/ccmain.c | 85 +++++++----- bld/cc/c/cdebug.c | 12 +- bld/cc/c/cdecl1.c | 26 ++-- bld/cc/c/cdecl2.c | 225 +++++++++++++++++++++----------- bld/cc/c/cdinit.c | 6 +- bld/cc/c/cdump.c | 32 +++-- bld/cc/c/cenum.c | 21 ++- bld/cc/c/cerror.c | 56 +++++--- bld/cc/c/cexpr.c | 173 +++++++++++++++++-------- bld/cc/c/cfedump.c | 16 ++- bld/cc/c/cfeinfo.c | 268 +++++++++++++++++++++----------------- bld/cc/c/cfold.c | 79 +++++++---- bld/cc/c/cgen.c | 141 ++++++++++++-------- bld/cc/c/cgendata.c | 18 +-- bld/cc/c/cgetch.c | 95 +++++++++----- bld/cc/c/cinfo.c | 31 +++-- bld/cc/c/cmac1.c | 93 +++++++++---- bld/cc/c/cmac2.c | 56 +++++--- bld/cc/c/cmath.c | 309 ++++++++++++++++++++++++++++---------------- bld/cc/c/cmemmgr.c | 38 ++++-- bld/cc/c/cmodel.c | 8 +- bld/cc/c/coptions.c | 44 +++++-- bld/cc/c/cpragma.c | 267 +++++++++++++++++++++----------------- bld/cc/c/cpragx86.c | 77 +++++++---- bld/cc/c/cpurge.c | 5 +- bld/cc/c/cscan.c | 81 +++++++----- bld/cc/c/cstats.c | 5 +- bld/cc/c/cstmt.c | 28 ++-- bld/cc/c/cstring.c | 20 ++- bld/cc/c/csym.c | 104 +++++++++------ bld/cc/c/ctype.c | 86 ++++++++---- bld/cc/c/dwarf.c | 18 ++- bld/cc/c/ftoa.c | 4 +- bld/cc/c/ideentry.c | 39 ++++-- bld/cc/h/cconst.h | 4 +- bld/cc/h/cdatatyp.h | 14 +- bld/cc/h/specmac.h | 6 +- bld/cc/h/target16.h | 4 +- bld/cc/h/target32.h | 4 +- 43 files changed, 1853 insertions(+), 1036 deletions(-) diff --git a/bld/cc/c/asmstmt.c b/bld/cc/c/asmstmt.c index 86ab8d8d55..3087001f30 100644 --- a/bld/cc/c/asmstmt.c +++ b/bld/cc/c/asmstmt.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -40,7 +40,9 @@ static bool EndOfAsmStmt( void ) /******************************/ { if( CurToken == T_SEMI_COLON ) { - // ; .ASM comment + /* + * ; .ASM comment + */ for( ;; ) { NextToken(); if( ( CurToken == T_EOF ) || ( CurToken == T_NULL ) ) { @@ -102,8 +104,10 @@ void AsmStmt( void ) TREEPTR tree; old_ppctl = PPControl; - // indicate that we are inside an __asm statement so scanner will - // allow tokens unique to the assembler. e.g. 21h + /* + * indicate that we are inside an __asm statement so scanner will + * allow tokens unique to the assembler. e.g. 21h + */ PPCTL_ENABLE_ASM(); NextToken(); @@ -118,7 +122,9 @@ void AsmStmt( void ) CErr1( ERR_TOO_MANY_BYTES_IN_PRAGMA ); too_many_bytes = true; } - // reset index to we don't overrun buffer + /* + * reset index to we don't overrun buffer + */ AsmCodeAddress = 0; } if( CurToken == T_RIGHT_BRACE ) diff --git a/bld/cc/c/browsio.c b/bld/cc/c/browsio.c index 2c604d81cd..5d2c4db9c9 100644 --- a/bld/cc/c/browsio.c +++ b/bld/cc/c/browsio.c @@ -53,26 +53,26 @@ static uint_32 relocValues[DW_W_MAX]; static C_DW_SECTION dw_sections[DW_DEBUG_MAX]; -// -- code to generate ELF output ------------------------------------------ -// -// note: the pre-initialized fields in these structures assume the following -// layout in the file -// elf_header -// string_table -// .debug_abbrev -// .debug_info -// .WATCOM_references -// .debug_line -// .debug_macinfo -// section_header_index0 -// section_header_string_table -// section_header_template( .debug_abbrev ) -// section_header_template( .debug_info ) -// section_header_template( .WATCOM_references ) -// section_header_template( .debug_line ) -// section_header_template( .debug_macinfo ) -// - +/* + * -- code to generate ELF output ------------------------------------------ + * + * note: the pre-initialized fields in these structures assume the following + * layout in the file + * elf_header + * string_table + * .debug_abbrev + * .debug_info + * .WATCOM_references + * .debug_line + * .debug_macinfo + * section_header_index0 + * section_header_string_table + * section_header_template( .debug_abbrev ) + * section_header_template( .debug_info ) + * section_header_template( .WATCOM_references ) + * section_header_template( .debug_line ) + * section_header_template( .debug_macinfo ) + */ static Elf32_Ehdr elf_header = { { ELFMAG0, ELFMAG1, ELFMAG2, ELFMAG3, ELFCLASS32, ELFDATA2LSB, EV_CURRENT }, ET_DYN, @@ -80,7 +80,7 @@ static Elf32_Ehdr elf_header = { EV_CURRENT, 0, 0, - 0,//=sizeof(Elf32_Ehdr)+sizeof(string_table)+sizes of 5 sections + 0,/* =sizeof(Elf32_Ehdr)+sizeof(string_table)+sizes of 5 sections */ 0, sizeof( Elf32_Ehdr ), sizeof( Elf32_Phdr ), @@ -142,12 +142,12 @@ static Elf32_Shdr section_header_string_table = { }; static Elf32_Shdr section_header_template = { - 0,// + 0, /* */ SHT_PROGBITS, 0, 0, - 0,// - 0,// + 0, /* */ + 0, /* */ SHN_UNDEF, 0, 0, @@ -170,7 +170,8 @@ static void mywrite( FILE *fp, const void *data, size_t len ) } } -/* output DWARF sections in following order +/* + * output DWARF sections in following order * .debug_abbrev * .debug_info * .WATCOM_reference @@ -196,20 +197,25 @@ static int createBrowseFile( FILE *browseFile ) dw_out_offset sectionSize; dw_out_offset sectionOffset[SECTION_COUNT]; - // calculate sections data size + /* + * calculate sections data size + */ elf_header.e_shoff = sizeof( Elf32_Ehdr ) + sizeof( string_table ); for( fileNum = 0; fileNum < SECTION_COUNT; fileNum++ ) { elf_header.e_shoff += dw_sections[inSect[fileNum]].length; } - - // write elf header + /* + * write elf header + */ mywrite( browseFile, &elf_header, sizeof( elf_header ) ); - - // write string table + /* + * write string table + */ mywrite( browseFile, string_table, sizeof( string_table ) ); - - // calculate each of the sections, tracking offset - // write each of the sections + /* + * calculate each of the sections, tracking offset + * write each of the sections + */ sectionOffset[0] = sizeof( elf_header ) + sizeof( string_table ); for( fileNum = 0; fileNum < SECTION_COUNT; fileNum++ ) { if( fileNum > 0 ) @@ -228,14 +234,17 @@ static int createBrowseFile( FILE *browseFile ) CMemFree( dw_sections[inSect[fileNum]].bufptrs ); } } - - // write section_header_index0 + /* + * write section_header_index0 + */ mywrite( browseFile, §ion_header_index0, sizeof( section_header_index0 ) ); - - // write section_header_string_table + /* + * write section_header_string_table + */ mywrite( browseFile, §ion_header_string_table, sizeof( section_header_string_table ) ); - - // write rest of section headers + /* + * write rest of section headers + */ for( fileNum = 0; fileNum < SECTION_COUNT; fileNum++ ) { section_header_template.sh_name = string_table_offsets[fileNum]; section_header_template.sh_offset = sectionOffset[fileNum]; @@ -244,7 +253,6 @@ static int createBrowseFile( FILE *browseFile ) } return( 0 ); } -//--------------------------------------------------------------------------- static void dw_write( dw_sectnum sect, const void *block, size_t len ) /********************************************************************/ @@ -256,14 +264,14 @@ static void dw_write( dw_sectnum sect, const void *block, size_t len ) char *bufptr; #ifdef __DD__ - //int i; +// int i; printf( "\nDW_WRITE(%d:%lu): offset: %lu len: %u ", sect, (unsigned long)dw_sections[sect].length, (unsigned long)dw_sections[sect].offset, (unsigned)len ); - //for( i = 0 ; i < len; i++ ) { - // printf( "%02x ", (int)((char *)block)[i] ); - //} +// for( i = 0 ; i < len; i++ ) { +// printf( "%02x ", (int)((char *)block)[i] ); +// } #endif bufnum = dw_sections[sect].offset / C_DWARF_BUFSIZE; endbufnum = ( dw_sections[sect].offset + len ) / C_DWARF_BUFSIZE; @@ -293,8 +301,8 @@ static void dw_write( dw_sectnum sect, const void *block, size_t len ) memcpy( bufptr, block, bufsize ); block = (char *)block + bufsize; len -= bufsize; - ++bufnum; // advance to next buffer - bufsize = C_DWARF_BUFSIZE; // buffer is full size + ++bufnum; /* advance to next buffer */ + bufsize = C_DWARF_BUFSIZE; /* buffer is full size */ } } @@ -325,11 +333,11 @@ static void dw_reloc( dw_sectnum sect, dw_reloc_type reloc_type, ... ) case DW_W_DEFAULT_FUNCTION: case DW_W_ARANGE_ADDR: case DW_W_LOW_PC: - u32_data = 0; // NOTE: assumes little-endian byte order + u32_data = 0; /* NOTE: assumes little-endian byte order */ dw_write( sect, &u32_data, TARGET_NEAR_POINTER ); break; case DW_W_HIGH_PC: - u32_data = 1; // NOTE: assumes little-endian byte order + u32_data = 1; /* NOTE: assumes little-endian byte order */ dw_write( sect, &u32_data, TARGET_NEAR_POINTER ); break; case DW_W_UNIT_SIZE: @@ -452,7 +460,9 @@ dw_client DwarfInit( void ) incsize = strlen( HFileList ) + 1; inclist = CMemAlloc( incsize ); memcpy( inclist, HFileList, incsize ); - // need to handle the case where there are multiple ';' in a row + /* + * need to handle the case where there are multiple ';' in a row + */ for( p = inclist; *p != '\0'; p++ ) { if( *p == ';' ) { *p = '\0'; @@ -488,7 +498,9 @@ void DwarfFini( dw_client client ) out_file = OpenBrowseFile(); if( out_file != NULL ) { - // concatenate files + /* + * concatenate files + */ createBrowseFile( out_file ); fclose( out_file ); } diff --git a/bld/cc/c/casian.c b/bld/cc/c/casian.c index 534e8fca4b..850e921785 100644 --- a/bld/cc/c/casian.c +++ b/bld/cc/c/casian.c @@ -31,19 +31,19 @@ /* - -Lattice Range of characters for first byte -switch Character Set of a double-byte character ------- ------------- -------------------------- --e0 Japanese: 0x81 - 0x9f, 0xe0 - 0xfc --e1 Chinese and Taiwanese: 0x81 - 0xfc // JBS obsolete --e2 Korean: 0x81 - 0xfd // JBS obsolete - -*/ + * Lattice Range of characters for first byte + * switch Character Set of a double-byte character + * ------ ------------- -------------------------- + * -e0 Japanese: 0x81 - 0x9f, 0xe0 - 0xfc + * -e1 Chinese and Taiwanese: 0x81 - 0xfc // JBS obsolete + * -e2 Korean: 0x81 - 0xfd // JBS obsolete + */ #include "cvars.h" #if defined( __RDOS__ ) -// !TODO fix MBCS stuff +/* + * !TODO fix MBCS stuff + */ #elif defined( __WATCOMC__ ) || !defined( __UNIX__ ) #include #include diff --git a/bld/cc/c/ccheck.c b/bld/cc/c/ccheck.c index 99a7266937..713d53b735 100644 --- a/bld/cc/c/ccheck.c +++ b/bld/cc/c/ccheck.c @@ -36,7 +36,9 @@ #include "cfeinfo.h" -/* return types from TypeCheck */ +/* + * return types from TypeCheck + */ typedef enum { TCE_OK, /* types are OK */ TCE_TYPE_MISMATCH, /* types mismatch */ @@ -167,7 +169,9 @@ static cmp_type CompatibleStructs( TAGPTR tag1, TAGPTR tag2 ) return( NO ); field1 = tag1->u.field_list; field2 = tag2->u.field_list; - /* if either struct is undefined, let's be conservative */ + /* + * if either struct is undefined, let's be conservative + */ if( (field1 == NULL) || (field2 == NULL) ) return( NO ); for( ; field1 != NULL && field2 != NULL; ) { @@ -188,7 +192,9 @@ static cmp_type CompatibleStructs( TAGPTR tag1, TAGPTR tag2 ) field1 = field1->next_field; field2 = field2->next_field; } - /* one list longer than other (possible with -zp4) */ + /* + * one list longer than other (possible with -zp4) + */ if( field1 != NULL || field2 != NULL ) return( NO ); return( OK ); @@ -278,16 +284,22 @@ static cmp_type DoCompatibleType( TYPEPTR typ1, TYPEPTR typ2, int ptr_indir_leve typ2_flags = FLAG_NONE; ret_val = OK; for( ;; ) { // * [] loop - // skip typedefs, go into enum base + /* + * skip typedefs, go into enum base + */ typ1 = SkipTypeFluff( typ1 ); - // skip typedefs, go into enum base + /* + * skip typedefs, go into enum base + */ typ2 = SkipTypeFluff( typ2 ); if( typ1 == typ2 ) break; if( typ1->decl_type != typ2->decl_type ) break; if( typ1->decl_type == TYP_ARRAY ) { - /* See C99, 6.7.5.2p5 */ + /* + * See C99, 6.7.5.2p5 + */ if( typ1->u.array->dimension && typ2->u.array->dimension ) { if( typ1->u.array->dimension != typ2->u.array->dimension ) { ret_val = PM; @@ -318,7 +330,9 @@ static cmp_type DoCompatibleType( TYPEPTR typ1, TYPEPTR typ2, int ptr_indir_leve if( typ1 != typ2 ) { // if not equal see if diff by pointers if( ptr_indir_level > 0 ) { if( typ1->decl_type == TYP_VOID || typ2->decl_type == TYP_VOID ) { - // allow void ** with any ** (but warn about it) + /* + * allow void ** with any ** (but warn about it) + */ if( ( ptr_indir_level == 1 ) || !CompFlags.strict_ANSI ) { if( ptr_indir_level > 1 ) { ret_val = PM; @@ -329,14 +343,18 @@ static cmp_type DoCompatibleType( TYPEPTR typ1, TYPEPTR typ2, int ptr_indir_leve if( typ1->decl_type == TYP_POINTER && typ2->decl_type != TYP_ARRAY ) { ret_val = PW; while( typ1->decl_type == TYP_POINTER ) { - // skip typedefs, go into enum base + /* + * skip typedefs, go into enum base + */ typ1 = SkipTypeFluff( typ1->object ); ++ptr_indir_level; } } else if( typ2->decl_type == TYP_POINTER && typ1->decl_type != TYP_ARRAY ) { ret_val = PW; while( typ2->decl_type == TYP_POINTER ) { - // skip typedefs, go into enum base + /* + * skip typedefs, go into enum base + */ typ2 = SkipTypeFluff( typ2->object ); ++ptr_indir_level; } @@ -355,11 +373,15 @@ static cmp_type DoCompatibleType( TYPEPTR typ1, TYPEPTR typ2, int ptr_indir_leve ret_val = NO; } } else if( typ1->decl_type == TYP_STRUCT || typ1->decl_type == TYP_UNION ) { - /* allow pointers to different structs */ - /* stop this for ANSI! */ + /* + * allow pointers to different structs + * stop this for ANSI! + */ if( ( typ1 != typ2 ) ) { - // Types are not the same - // if extensions are enabled, then we can do a compatible struct test + /* + * Types are not the same + * if extensions are enabled, then we can do a compatible struct test + */ if( CompFlags.extensions_enabled ) { if( CompatibleStructs( typ1->u.tag, typ2->u.tag ) != OK ) { if( ptr_indir_level > 0 ) { @@ -458,16 +480,24 @@ static cmp_type CompatibleType( TYPEPTR typ1, TYPEPTR typ2, bool assignment, boo typ1_flags = FLAG_NONE; typ2_flags = FLAG_NONE; ret_pq = OK; - // skip typedefs go into enums base + /* + * skip typedefs go into enums base + */ typ1 = SkipTypeFluff( typ1 ); - // skip typedefs, go into enum base + /* + * skip typedefs, go into enum base + */ typ2 = SkipTypeFluff( typ2 ); if( typ1->decl_type == TYP_POINTER && typ2->decl_type == TYP_POINTER ) { - // top level pointer + /* + * top level pointer + */ typ1_flags = typ1->u.p.decl_flags; typ2_flags = typ2->u.p.decl_flags; - // Special dispensation: assigning null pointer constant is allowed even - // when the pointer size doesn't match. Required for MS compatibility. + /* + * Special dispensation: assigning null pointer constant is allowed even + * when the pointer size doesn't match. Required for MS compatibility. + */ if( assignment && !null_ptr ) { type_modifiers subnot; @@ -578,18 +608,22 @@ static void CompareParms( TYPEPTR *master, TREEPTR parms, bool reverse ) typ1 = *master++; if( typ1 != NULL ) { if( typ1->decl_type == TYP_VOID ) { /* type func(void); */ - typ1 = NULL; /* indicate no parms */ + typ1 = NULL; /* indicate no parms */ } } for( parmno = 1, parm = parms; ( typ1 != NULL ) && ( parm != NULL ); parm = parm->left, ++parmno ) { SKIP_TYPEDEFS( typ1 ); - // TODO is crap needed or has it been done + /* + * TODO is crap needed or has it been done + */ if( typ1->decl_type == TYP_FUNCTION ) { typ1 = PtrNode( typ1, FLAG_NONE, SEG_CODE ); } else if( typ1->decl_type == TYP_ARRAY ) { typ1 = PtrNode( typ1->object, FLAG_WAS_ARRAY, SEG_DATA ); } - /* check compatibility of parms */ + /* + * check compatibility of parms + */ ParmAsgnCheck( typ1, parm, parmno, false ); typ1 = *master++; if( typ1 != NULL && typ1->decl_type == TYP_DOT_DOT_DOT ) { @@ -600,7 +634,9 @@ static void CompareParms( TYPEPTR *master, TREEPTR parms, bool reverse ) } if( typ1 != NULL || parm != NULL ) { /* should both be NULL now */ #if _CPU == 386 - /* can allow wrong number of parms with -3s option */ + /* + * can allow wrong number of parms with -3s option + */ if( !CompFlags.register_conventions ) { CWarn1( ERR_PARM_COUNT_WARNING ); } else { @@ -615,8 +651,10 @@ static void CompareParms( TYPEPTR *master, TREEPTR parms, bool reverse ) } } -/* Check parameters of function that were called before a prototype was seen */ extern void ChkCallParms( void ) +/******************************* + * Check parameters of function that were called before a prototype was seen + */ { call_list *nextcall; call_list *next; @@ -652,9 +690,11 @@ extern void ChkCallParms( void ) } else if( typ->u.fn.parms != NULL ) { CompareParms( typ->u.fn.parms, callnode->right, ParmsToBeReversed( sym.mods, NULL ) ); } else { - // Unprototyped function called. Note that for indirect calls, there - // is no symbol associated with the function and diagnostic information - // is hence limited. + /* + * Unprototyped function called. Note that for indirect calls, there + * is no symbol associated with the function and diagnostic information + * is hence limited. + */ if( sym.flags & SYM_TEMP ) { CWarn1( ERR_NONPROTO_FUNC_CALLED_INDIRECT ); } else { @@ -797,9 +837,10 @@ void ParmAsgnCheck( TYPEPTR typ1, TREEPTR opnd2, int parmno, bool asgn_check ) if( opnd2->op.opr == OPR_ERROR ) return; - - // Fold RHS expression so that we can properly check for null - // pointers or out of range constants + /* + * Fold RHS expression so that we can properly check for null + * pointers or out of range constants + */ FoldExprTree( opnd2 ); typ2 = opnd2->u.expr_type; @@ -963,7 +1004,9 @@ void ChkRetType( TREEPTR tree ) CWarn1( ERR_RET_ADDR_OF_AUTO ); } } - /* check that the types are compatible */ + /* + * check that the types are compatible + */ ParmAsgnCheck( func_type, tree, 0, true ); } @@ -976,7 +1019,9 @@ static typecheck_err TypeCheck( TYPEPTR typ1, TYPEPTR typ2, SYMPTR sym ) pointer_type = 0; retcode = TCE_OK; - /* "char *s" and "char s[]" differs only by FLAG_WAS_ARRAY, ignore it too */ + /* + * "char *s" and "char s[]" differs only by FLAG_WAS_ARRAY, ignore it too + */ #if _INTEL_CPU if( TargetSwitches & CGSW_X86_BIG_DATA ) { ptr_mask = ~(FLAG_FAR | FLAG_WAS_ARRAY | MASK_LANGUAGES); @@ -987,20 +1032,28 @@ static typecheck_err TypeCheck( TYPEPTR typ1, TYPEPTR typ2, SYMPTR sym ) ptr_mask = ~(FLAG_NEAR | FLAG_WAS_ARRAY | MASK_LANGUAGES); #endif for( ;; ) { - // skip typedefs, go into enum base + /* + * skip typedefs, go into enum base + */ typ1 = SkipTypeFluff( typ1 ); - // skip typedefs, go into enum base + /* + * skip typedefs, go into enum base + */ typ2= SkipTypeFluff( typ2); - /* this compare was moved here */ - /* ptr to typedef struct failed when this was before typedef skips */ + /* + * this compare was moved here + * ptr to typedef struct failed when this was before typedef skips + */ if( typ1 == typ2 ) return( retcode ); if( typ1->decl_type != typ2->decl_type ) { if( pointer_type ) { - /* by popular demand, I disabled the questionable feature to accept - void *foo(void); - int *foo(void) {return NULL}; - - Bart Oldeman, 2002/10/24 */ + /* + * by popular demand, I disabled the questionable feature to accept + * void *foo(void); + * int *foo(void) {return NULL}; + * - Bart Oldeman, 2002/10/24 + */ if( typ1->decl_type == TYP_ARRAY ) { return( TypeCheck( typ1->object, typ2, sym ) ); } @@ -1034,8 +1087,10 @@ static typecheck_err TypeCheck( TYPEPTR typ1, TYPEPTR typ2, SYMPTR sym ) } } if( typ1->decl_type == TYP_STRUCT || typ1->decl_type == TYP_UNION ) { - /* must be the same tag to be identical, if they are the - same tag, then typ1 == typ2 which is checked above */ + /* + * must be the same tag to be identical, if they are the + * same tag, then typ1 == typ2 which is checked above + */ break; } if( typ1->decl_type == TYP_FUNCTION ) { @@ -1073,8 +1128,10 @@ bool VerifyType( TYPEPTR new, TYPEPTR old, SYMPTR sym ) { switch( TypeCheck( new, old, sym ) ) { case TCE_TYPE2_HAS_MORE_INFO: - /* new= void *, old= something * */ - /* indicate want old definition */ + /* + * new= void *, old= something * + * indicate want old definition + */ return( true ); case TCE_TYPE_MISMATCH: case TCE_PARM_COUNT_MISMATCH: diff --git a/bld/cc/c/ccmain.c b/bld/cc/c/ccmain.c index f8c6aae490..2b3465de85 100644 --- a/bld/cc/c/ccmain.c +++ b/bld/cc/c/ccmain.c @@ -73,9 +73,9 @@ static bool IsStdIn; static char *FNameBuf = NULL; void FrontEndInit( bool reuse ) -//***************************// -// Do the once only things // -//***************************// +/****************************** + * Do the once only things + ******************************/ { GlobalCompFlags.cc_reuse = reuse; GlobalCompFlags.cc_first_use = true; @@ -88,9 +88,9 @@ void FrontEndInit( bool reuse ) } void FrontEndFini( void ) -//********************// -// Fini the once only // -//********************// +/************************ + * Fini the once only + ************************/ { GlobalCompFlags.cc_reuse = false; GlobalCompFlags.cc_first_use = true; @@ -216,7 +216,9 @@ static char *createFileName( const char *template, const char *ext, bool forceex template = WholeFName; _splitpath2( template, pg.buffer, &pg.drive, &pg.dir, &pg.fname, &pg.ext ); if( use_defaults ) { - /* default object file goes in current directory */ + /* + * default object file goes in current directory + */ pg.drive = ""; pg.dir = ""; } @@ -274,7 +276,9 @@ static IALIASPTR AddIAlias( const char *alias_name, const char *real_name, bool strcpy( alias->real_name, real_name ); *lnk = alias; if( old_alias != NULL ) { - /* Replace old alias if it exists */ + /* + * Replace old alias if it exists + */ alias->next = old_alias->next; CMemFree( old_alias ); } @@ -325,11 +329,12 @@ static bool openForcePreInclude( void ) } -/* open the primary source file, and return pointer to root file name */ - #define STDIN_NAME "stdin" static void MakePgmName( void ) +/****************************** + * open the primary source file, and return pointer to root file name + */ { size_t len; pgroup2 pg; @@ -559,7 +564,9 @@ void CClose( FILE *fp ) /*********************/ { if( fp == NULL ) { - /* nothing to do */ + /* + * nothing to do + */ } else if( fp != stdin ) { fclose( fp ); } @@ -596,7 +603,10 @@ static bool FreeSrcFP( void ) static FNAMEPTR FindFlist( char const *filename ) -{ // find a flist +/************************************************ + * find a flist + */ +{ FNAMEPTR flist; for( flist = FNames; flist != NULL; flist = flist->next ) { @@ -639,7 +649,9 @@ static bool TryOpen( const char *path, pgroup2 *ff, src_file_type typ ) if( ff->drive[0] != '\0' && fd.drive[0] != '\0' ) { return( false ); } - // concatenate fd.dir + sep + fp.dir + /* + * concatenate fd.dir + sep + fp.dir + */ p = fd.dir + strlen( fd.dir ); if( fd.dir[0] != '\0' ) { if( !IS_PATH_SEP( p[-1] ) ) { @@ -660,7 +672,7 @@ static bool TryOpen( const char *path, pgroup2 *ff, src_file_type typ ) } if( fp == NULL ) return( false ); -/* +#if 0 if( CompFlags.use_precompiled_header ) { CompFlags.use_precompiled_header = false; if( UsePreCompiledHeader( filename ) ) { @@ -668,7 +680,7 @@ static bool TryOpen( const char *path, pgroup2 *ff, src_file_type typ ) return( true ); } } -*/ +#endif if( OpenFCB( fp, filename, typ ) ) { if( CompFlags.cpp_mode ) { if( CppFile == NULL ) @@ -846,10 +858,13 @@ void FreeRDir( void ) } void SrcFileReadOnlyDir( char const *dirs ) -{ // add dir to ro set +/****************************************** + * add dir to ro set + */ +{ char *full; // - full path - char path[_MAX_PATH]; // - used to extract directory - char buff[_MAX_PATH]; // - expanded path for directory + char path[_MAX_PATH]; // - used to extract directory + char buff[_MAX_PATH]; // - expanded path for directory while( *dirs != '\0' ) { char *p = path; @@ -1096,13 +1111,17 @@ static bool try_open_file( const char *path, pgroup2 *fp, pgroup2 *fa, src_file_ char save_chr_fname; char save_chr_ext; - // try to open regular name + /* + * try to open regular name + */ ok = TryOpen( path, fp, typ ); if( ok ) { return( ok ); } if( fa != NULL ) { - // try to open alias name if defined + /* + * try to open alias name if defined + */ ok = TryOpen( path, fa, typ ); if( ok ) { return( ok ); @@ -1120,7 +1139,9 @@ static bool try_open_file( const char *path, pgroup2 *fp, pgroup2 *fa, src_file_ fp->ext[4] = '\0'; } if( save_chr_fname != '\0' || save_chr_ext != '\0' ) { - // try to open truncated name if enabled + /* + * try to open truncated name if enabled + */ ok = TryOpen( path, fp, typ ); if( !ok ) { if( save_chr_fname != '\0' ) { @@ -1274,7 +1295,9 @@ bool OpenSrcFile( const char *filename, src_file_type typ ) case FT_HEADER_FORCED: case FT_HEADER_PRE: case FT_LIBRARY: - // See if there's an alias for this filename + /* + * See if there's an alias for this filename + */ alias_filename = IncludeAlias( filename, ( typ == FT_LIBRARY || typ == FT_HEADER_PRE ) ); if( alias_filename != NULL ) { _splitpath2( alias_filename, fa.buffer, &fa.drive, &fa.dir, &fa.fname, &fa.ext ); @@ -1296,11 +1319,11 @@ void CppEmitPoundLine( unsigned line_num, const char *filename, bool newline ) sprintf( buf, "#line %u \"", line_num ); CppPuts( buf ); while( (c = *filename++) != '\0' ) { - if( c == '\\' ) - c = '/'; - CppPutc( c ); - } - CppPutc( '"' ); + if( c == '\\' ) + c = '/'; + CppPutc( c ); + } + CppPutc( '"' ); if( newline ) { CppPutc( '\n' ); } @@ -1371,7 +1394,9 @@ void CloseFiles( void ) char msgtxt[80]; char msgbuf[MAX_MSG_LEN]; - /* issue message */ + /* + * issue message + */ CGetMsg( msgtxt, ERR_FATAL_ERROR ); sprintf( msgbuf, msgtxt, strerror( errno ) ); NoteMsg( msgbuf ); @@ -1396,7 +1421,9 @@ void CloseFiles( void ) bool FrontEnd( char **cmdline ) { #if defined(__WATCOMC__) && defined( _M_IX86 ) - /* set to 0 in case 8087 is present */ + /* + * set to 0 in case 8087 is present + */ _real87 = 0; _8087 = 0; #endif diff --git a/bld/cc/c/cdebug.c b/bld/cc/c/cdebug.c index 0a1a2c81f1..25ee6b9f19 100644 --- a/bld/cc/c/cdebug.c +++ b/bld/cc/c/cdebug.c @@ -236,7 +236,9 @@ dbug_type DBType( TYPEPTR typ ) fwd_info.typ = typ; fwd_info.debug_name = NULL; fwd_info.scope = DBG_NIL_TYPE; - /* default is INT */ + /* + * default is INT + */ ret_val = B_Int; switch( typ->decl_type ) { case TYP_VOID: @@ -335,7 +337,9 @@ static void DumpFieldList( dbg_struct st, target_size bias, for( ; pfield != NULL; pfield = pfield->next_field ) { field_typ = pfield->field_type; if( pfield->name[0] == '\0' ) { - /* anonymous struct/union -- suck up to this level */ + /* + * anonymous struct/union -- suck up to this level + */ while( field_typ->decl_type == TYP_TYPEDEF ) { field_typ = field_typ->object; } @@ -367,7 +371,9 @@ static dbug_type DBTypeStruct( TYPEPTR typ ) TYPEPTR obj; if( typ->object != NULL ) { - /* structure has a zero length array as last field */ + /* + * structure has a zero length array as last field + */ obj = typ->object; } else { obj = NULL; diff --git a/bld/cc/c/cdecl1.c b/bld/cc/c/cdecl1.c index 2015e26d86..7979862492 100644 --- a/bld/cc/c/cdecl1.c +++ b/bld/cc/c/cdecl1.c @@ -92,7 +92,9 @@ static void FuncDefn( SYMPTR sym ) SYM_NAMEPTR sym_name; TYPEPTR typ; - /* duplicate name in near space */ + /* + * duplicate name in near space + */ sym_name = SymName( sym, CurFuncHandle ); sym->name = CStrSave( sym_name ); if( sym->flags & SYM_DEFINED ) { @@ -202,7 +204,7 @@ static void BeginFunc( void ) switch( checkMain( CurFunc->name ) ) { case MAIN_WMAIN: CompFlags.has_wchar_entry = true; - // fall through! + /* fall through */ case MAIN_MAIN: if( CurFunc->u.func.parms != SYM_NULL ) { CompFlags.main_has_parms = true; @@ -214,7 +216,7 @@ static void BeginFunc( void ) case MAIN_WWINMAIN: CompFlags.has_wchar_entry = true; - // fall through! + /* fall through */ case MAIN_WINMAIN: if( TargetSystem == TS_WINDOWS || TargetSystem == TS_CHEAP_WINDOWS || TargetSystem == TS_NT ) { CompFlags.has_winmain = true; @@ -226,7 +228,7 @@ static void BeginFunc( void ) case MAIN_WLIBMAIN: case MAIN_WDLLMAIN: CompFlags.has_wchar_entry = true; - // fall through! + /* fall through */ case MAIN_LIBMAIN: case MAIN_DLLMAIN: CompFlags.has_libmain = true; @@ -262,7 +264,9 @@ static void ArgPromotion( SYMPTR sym ) AdjParmType( sym ); arg_typ = sym->sym_type; - /* perform default argument promotions */ + /* + * perform default argument promotions + */ typ = arg_typ; SKIP_TYPEDEFS( typ ); @@ -437,7 +441,9 @@ static void AddParms( void ) parm->sym.attribs.is_parm = true; hash = parm->sym.info.hash; if( parm->sym.name[0] == '\0' ) { - /* no name ==> ... */ + /* + * no name ==> ... + */ parm->sym.sym_type = GetType( TYP_DOT_DOT_DOT ); parm->sym.attribs.stg_class = SC_AUTO; } else if( parm->sym.sym_type == NULL ) { @@ -515,7 +521,9 @@ static void AddParms( void ) CMemFree( prev_parm ); } typ = CurFunc->sym_type; - // TODO not following my scheme + /* + * TODO not following my scheme + */ CurFunc->sym_type = FuncNode( typ->object, FLAG_NONE, MakeParmList( parmlist, ParmsToBeReversed( CurFunc->mods, NULL ) ) ); @@ -552,7 +560,9 @@ static void ChkParms( void ) if( parm->sym.sym_type == NULL ) { parm->sym.sym_type = TypeDefault(); } - /* make sure name not already defined in this SymLevel */ + /* + * make sure name not already defined in this SymLevel + */ sym_handle = SymAdd( parm->sym.info.hash, &parm->sym ); if( prev_parm == NULL ) { CurFunc->u.func.parms = sym_handle; diff --git a/bld/cc/c/cdecl2.c b/bld/cc/c/cdecl2.c index 8864169b70..541c75db38 100644 --- a/bld/cc/c/cdecl2.c +++ b/bld/cc/c/cdecl2.c @@ -128,27 +128,35 @@ static void CmpFuncDecls( SYMPTR new_sym, SYMPTR old_sym ) if( (new_sym->mods & ~MASK_FUNC) != (old_sym->mods & ~MASK_FUNC) ) { CErr2p( ERR_MODIFIERS_DISAGREE, new_sym->name ); } - - /* check for conflicting information */ - /* skip over TYPEDEF's */ + /* + * check for conflicting information + * skip over TYPEDEF's + */ type_new = new_sym->sym_type; SKIP_TYPEDEFS( type_new ); type_old = old_sym->sym_type; SKIP_TYPEDEFS( type_old ); - - // diagnostics for function, target=old and source=new + /* + * diagnostics for function, target=old and source=new + */ SetDiagType2( type_old->object, type_new->object ); if( !IdenticalType( type_new->object, type_old->object ) ) { TYPEPTR ret_new, ret_old; - /* save return types */ + /* + * save return types + */ ret_new = type_new->object; ret_old = type_old->object; - // skip over typedef's + /* + * skip over typedef's + */ SKIP_TYPEDEFS( ret_new ); SKIP_TYPEDEFS( ret_old ); - /* don't reorder this expression */ - //return value used in forward + /* + * don't reorder this expression + * return value used in forward + */ if( old_sym->attribs.stg_class != SC_FORWARD ) { CErr2p( ERR_INCONSISTENT_TYPE, new_sym->name ); } else if( ret_new->decl_type != TYP_VOID || (old_sym->flags & SYM_TYPE_GIVEN) ) { @@ -156,8 +164,9 @@ static void CmpFuncDecls( SYMPTR new_sym, SYMPTR old_sym ) } } SetDiagPop(); - - /* check types of parms, including promotion */ + /* + * check types of parms, including promotion + */ ChkCompatibleFunction( type_old, type_new, true ); } @@ -174,7 +183,9 @@ static SYM_HANDLE FuncDecl( SYMPTR sym, stg_classes stg_class, decl_state *state ENUMPTR ep; PrevProtoType = NULL; - // Warn if assuming 'int' return type - should be an error in strict C99 mode + /* + * Warn if assuming 'int' return type - should be an error in strict C99 mode + */ if( *state & DECL_STATE_NOTYPE ) { CWarn2p( ERR_NO_RET_TYPE_GIVEN, sym->name ); } @@ -210,7 +221,7 @@ static SYM_HANDLE FuncDecl( SYMPTR sym, stg_classes stg_class, decl_state *state SetDiagSymbol( &old_sym, old_sym_handle ); if( (old_sym.flags & SYM_FUNCTION) == 0 ) { CErr2p( ERR_SYM_ALREADY_DEFINED_AS_VAR, sym->name ); - // sym_handle = old_sym_handle; +// sym_handle = old_sym_handle; sym_handle = SymAddL0( sym->info.hash, sym ); } else { CmpFuncDecls( sym, &old_sym ); @@ -231,9 +242,11 @@ static SYM_HANDLE FuncDecl( SYMPTR sym, stg_classes stg_class, decl_state *state old_sym.src_loc = sym->src_loc; } } - // check lang flags to make sure no one saw an incompatible prototype; if - // previous prototype specified calling convention and later definition does - // not, propagate the convention from the prototype + /* + * check lang flags to make sure no one saw an incompatible prototype; if + * previous prototype specified calling convention and later definition does + * not, propagate the convention from the prototype + */ if( (sym->mods & MASK_LANGUAGES) && !ChkCompatibleLanguage( sym->mods, old_sym.mods ) ) { CErr2p( ERR_MODIFIERS_DISAGREE, sym->name ); } @@ -262,7 +275,8 @@ static SYM_HANDLE FuncDecl( SYMPTR sym, stg_classes stg_class, decl_state *state CErr2p( ERR_MODIFIERS_DISAGREE, sym->name ); break; case DECLSPEC_DLLEXPORT: - /* Allow the following: void foo( void ); void _Export foo( void ); + /* + * Allow the following: void foo( void ); void _Export foo( void ); * IBM's compiler allows this, so does our C++ compiler; and it's real useful! */ if( old_sym.attribs.declspec == DECLSPEC_DLLIMPORT || old_sym.attribs.declspec == DECLSPEC_NONE ) { @@ -275,8 +289,10 @@ static SYM_HANDLE FuncDecl( SYMPTR sym, stg_classes stg_class, decl_state *state } old_sym.attribs.naked |= sym->attribs.naked; if( stg_class == SC_STATIC && old_sym.attribs.stg_class == SC_EXTERN ) { - /* can't redeclare extern function as static */ - /* NB: We may want to handle SC_FORWARD functions too! */ + /* + * can't redeclare extern function as static + * NB: We may want to handle SC_FORWARD functions too! + */ CWarn2p( ERR_FUNCTION_STG_CLASS_REDECLARED, sym->name ); } CMemFree( sym->name ); @@ -316,14 +332,17 @@ static SYM_HANDLE VarDecl( SYMPTR sym, stg_classes stg_class, decl_state *state type_modifiers old_attrs; type_modifiers new_attrs; - // Warn if neither type nor storage class were given; this should probably be - // an error in strict C89 (and naturally C99) mode + /* + * Warn if neither type nor storage class were given; this should probably be + * an error in strict C89 (and naturally C99) mode + */ if( (stg_class == SC_NONE) && (*state & DECL_STATE_NOTYPE) && (*state & DECL_STATE_NOSTWRN) == 0 ) { CWarn1( ERR_NO_STG_OR_TYPE ); *state |= DECL_STATE_NOSTWRN; // Only warn once for each declarator list } - - // Additionally warn if assuming 'int' type - should be an error in strict C99 mode + /* + * Additionally warn if assuming 'int' type - should be an error in strict C99 mode + */ if( *state & DECL_STATE_NOTYPE ) { CWarn2p( ERR_NO_DATA_TYPE_GIVEN, sym->name ); } @@ -338,8 +357,8 @@ static SYM_HANDLE VarDecl( SYMPTR sym, stg_classes stg_class, decl_state *state if( SymLevel == 0 ) { /* - // SymLevel == 0 is global scope (SymLevel is the count of nested {'s) - */ + * SymLevel == 0 is global scope (SymLevel is the count of nested {'s) + */ if( (stg_class == SC_AUTO) || (stg_class == SC_REGISTER) ) { CErr1( ERR_INV_STG_CLASS_FOR_GLOBAL ); stg_class = SC_STATIC; @@ -355,8 +374,8 @@ static SYM_HANDLE VarDecl( SYMPTR sym, stg_classes stg_class, decl_state *state } } else { /* - // SymLevel != 0 is function scoped (SymLevel is the count of nested {'s) - */ + * SymLevel != 0 is function scoped (SymLevel is the count of nested {'s) + */ if( stg_class == SC_NONE ) { stg_class = SC_AUTO; } @@ -369,18 +388,18 @@ static SYM_HANDLE VarDecl( SYMPTR sym, stg_classes stg_class, decl_state *state } #if _INTEL_CPU /* - // Local variables in stack will be far when SS != DS (/zu) - // (applies only to auto vars, functions params are handled - // NOT here but in "cexpr.c" [OPR_PUSHADDR]) - */ + * Local variables in stack will be far when SS != DS (/zu) + * (applies only to auto vars, functions params are handled + * NOT here but in "cexpr.c" [OPR_PUSHADDR]) + */ if( TargetSwitches & CGSW_X86_FLOATING_SS ) { sym->mods |= FLAG_FAR; } #endif } /* - // static class variables can be thread local also - */ + * static class variables can be thread local also + */ if( (stg_class == SC_STATIC) && (sym->attribs.declspec == DECLSPEC_THREAD) ) { if( !CompFlags.thread_data_present ) { thread_segid = DefThreadSeg(); @@ -417,7 +436,9 @@ static SYM_HANDLE VarDecl( SYMPTR sym, stg_classes stg_class, decl_state *state old_attrs = old_sym.mods; new_attrs = sym->mods; #if _INTEL_CPU - /* add default far/near flags depending on data model */ + /* + * add default far/near flags depending on data model + */ if( TargetSwitches & CGSW_X86_BIG_DATA ) { old_attrs |= FLAG_FAR; new_attrs |= FLAG_FAR; @@ -430,8 +451,10 @@ static SYM_HANDLE VarDecl( SYMPTR sym, stg_classes stg_class, decl_state *state CErr2p( ERR_MODIFIERS_DISAGREE, sym->name ); } if( (sym->mods & MASK_LANGUAGES) != (old_sym.mods & MASK_LANGUAGES) ) { - // just inherit old lang flags - // if new != 0 then it's possible someone saw a different prototype + /* + * just inherit old lang flags + * if new != 0 then it's possible someone saw a different prototype + */ if( (sym->mods & MASK_LANGUAGES) != 0 ) { CErr2p( ERR_MODIFIERS_DISAGREE, sym->name ); } @@ -457,14 +480,16 @@ static SYM_HANDLE VarDecl( SYMPTR sym, stg_classes stg_class, decl_state *state if( ( old_sym_handle != SYM_NULL ) && (stg_class == SC_NONE || stg_class == SC_EXTERN || (stg_class == SC_STATIC && SymLevel == 0)) ) { - - /* make sure sym->sym_type same type as old_sym->sym_type */ - + /* + * make sure sym->sym_type same type as old_sym->sym_type + */ SetDiagSymbol( &old_sym, old_sym_handle ); old_def = VerifyType( sym->sym_type, old_sym.sym_type, sym ); SetDiagPop(); if( !old_def && ChkEqSymLevel( &old_sym ) ) { - /* new symbol's type supersedes old type */ + /* + * new symbol's type supersedes old type + */ old_sym.sym_type = sym->sym_type; if( (old_sym.flags & SYM_FUNCTION) ) { old_sym = *sym; // ditch old sym @@ -477,21 +502,31 @@ static SYM_HANDLE VarDecl( SYMPTR sym, stg_classes stg_class, decl_state *state memcpy( sym, &old_sym, sizeof( SYM_ENTRY ) ); sym_handle = old_sym_handle; SetDiagSymbol( &old_sym, old_sym_handle ); - /* verify that newly specified storage class doesn't conflict */ + /* + * verify that newly specified storage class doesn't conflict + */ if( (stg_class == SC_NONE) || (stg_class == SC_STATIC) ) { if( sym->attribs.stg_class == SC_EXTERN ) { - /* was extern, OK to change to none */ + /* + * was extern, OK to change to none + */ if( stg_class == SC_NONE ) { sym->attribs.stg_class = stg_class; } else { - /* was extern, not OK to make static */ + /* + * was extern, not OK to make static + */ CErrSymName( ERR_STG_CLASS_DISAGREES, sym, sym_handle ); } } else if( sym->attribs.stg_class == SC_STATIC && stg_class == SC_NONE ) { - /* was static, not OK to redefine */ + /* + * was static, not OK to redefine + */ CErrSymName( ERR_STG_CLASS_DISAGREES, sym, sym_handle ); } else if( sym->attribs.stg_class == SC_NONE && stg_class == SC_STATIC ) { - /* was extern linkage, not OK to to make static */ + /* + * was extern linkage, not OK to to make static + */ CErrSymName( ERR_STG_CLASS_DISAGREES, sym, sym_handle ); } } @@ -580,7 +615,9 @@ static SYM_HANDLE InitDeclarator( SYMPTR sym, decl_info const * const info, decl return( SYM_NULL ); } typ = sym->sym_type; - /* skip over typedef's */ + /* + * skip over typedef's + */ SKIP_TYPEDEFS( typ ); if( info->stg == SC_TYPEDEF ) { if( CompFlags.extensions_enabled ) { @@ -699,7 +736,9 @@ bool DeclList( SYM_HANDLE *sym_head ) } for( ;; ) { sym_handle = InitDeclarator( &sym, &info, &state ); - /* NULL is returned if sym already exists in symbol table */ + /* + * NULL is returned if sym already exists in symbol table + */ if( sym_handle != SYM_NULL ) { sym.handle = SYM_NULL; if( sym.flags & SYM_FUNCTION ) { @@ -719,19 +758,22 @@ bool DeclList( SYM_HANDLE *sym_head ) } SymReplace( &sym, sym_handle ); } - /* case "int x *p" ==> missing ',' msg already given */ + /* + * case "int x *p" ==> missing ',' msg already given + */ if( CurToken != T_TIMES ) { if( CurToken != T_COMMA ) break; NextToken(); } } -/* the following is illegal: - typedef double math(double); - math sin { ; } - That's the reason for the check - "typ->decl_type != TYP_FUNCTION" -*/ + /* + * the following is illegal: + * typedef double math(double); + * math sin { ; } + * That's the reason for the check + * "typ->decl_type != TYP_FUNCTION" + */ if( SymLevel == 0 && CurToken != T_SEMI_COLON && sym_handle != SYM_NULL ) { if( sym.sym_type->decl_type == TYP_FUNCTION && sym.sym_type != info.typ ) { CurFuncHandle = sym_handle; @@ -746,7 +788,9 @@ bool DeclList( SYM_HANDLE *sym_head ) NextToken(); /* skip over ';' */ } } -// can't get here! return( false ); + /* + * can't get here! return( false ); + */ } @@ -773,7 +817,8 @@ bool LoopDecl( SYM_HANDLE *sym_head ) } state = DECL_STATE_FORLOOP; if( info.typ == NULL ) { - /* C99 requires a type specifier; we could get away with defaulting + /* + * C99 requires a type specifier; we could get away with defaulting * to int but what would be the point? */ CErr1( ERR_NO_TYPE_IN_DECL ); @@ -782,7 +827,9 @@ bool LoopDecl( SYM_HANDLE *sym_head ) if( CurToken != T_SEMI_COLON ) { for( ;; ) { sym_handle = InitDeclarator( &sym, &info, &state ); - /* NULL is returned if sym already exists in symbol table */ + /* + * NULL is returned if sym already exists in symbol table + */ if( sym_handle != SYM_NULL ) { sym.handle = SYM_NULL; if( sym.flags & SYM_FUNCTION ) { @@ -802,7 +849,9 @@ bool LoopDecl( SYM_HANDLE *sym_head ) } SymReplace( &sym, sym_handle ); } - /* case "int x *p" ==> missing ',' msg already given */ + /* + * case "int x *p" ==> missing ',' msg already given + */ if( CurToken != T_TIMES ) { if( CurToken != T_COMMA ) break; @@ -811,7 +860,7 @@ bool LoopDecl( SYM_HANDLE *sym_head ) } MustRecog( T_SEMI_COLON ); } else { - // Chk_Struct_Union_Enum( info.typ ); +// Chk_Struct_Union_Enum( info.typ ); NextToken(); /* skip over ';' */ } return( true ); /* We found a declaration */ @@ -894,7 +943,9 @@ static TYPEPTR Pointer( TYPEPTR typ, struct mod_info *info ) sym_handle = SYM_NULL; if( (typ != NULL) && (typ->decl_type == TYP_TYPEDEF) ) { - // get segment from typedef TODO should be done sooner + /* + * get segment from typedef TODO should be done sooner + */ TYPEPTR ptr_typ; SYMPTR symp; @@ -1034,7 +1085,9 @@ static TYPEPTR Pointer( TYPEPTR typ, struct mod_info *info ) if( CurToken == T_TIMES ) { NextToken(); #if _INTEL_CPU - // * seg16 binds with * cause of IBM dorks, and so does far16 + /* + * * seg16 binds with * cause of IBM dorks, and so does far16 + */ if( (CurToken == T__SEG16) || (CurToken == T__FAR16) || (CurToken == T___FAR16) ) { #if _CPU == 8086 info->modifier |= FLAG_FAR; @@ -1069,7 +1122,9 @@ static void ParseDeclPart2( TYPEPTR *typep, TYPEPTR typ, type_modifiers mod ) decl1 = decl1->object; } } - // Pass on pointer flags + /* + * Pass on pointer flags + */ if( (decl1 != NULL) && (decl1->decl_type == TYP_POINTER) ) mod = decl1->u.p.decl_flags; decl2 = DeclPart2( typ, mod ); @@ -1339,10 +1394,14 @@ static TYPEPTR DeclPart3( TYPEPTR typ, type_modifiers mod ) parms = FuncProtoType(); if( (parms == NULL) && (ParmList != NULL) ) { if( CurToken == T_SEMI_COLON || CurToken == T_COMMA ) { - /* int f16(i,j); */ + /* + * int f16(i,j); + */ CErr1( ERR_ID_LIST_SHOULD_BE_EMPTY ); } - /* Old-style declarations are obsolescent (ever since ANSI C89!) */ + /* + * Old-style declarations are obsolescent (ever since ANSI C89!) + */ CWarn1( ERR_OBSOLETE_FUNC_DECL ); } if( parms_list != NULL ) { @@ -1351,7 +1410,8 @@ static TYPEPTR DeclPart3( TYPEPTR typ, type_modifiers mod ) } } else { NextToken(); /* skip over ')' */ - /* Non-prototype declarators are obsolescent too; however, __interrupt + /* + * Non-prototype declarators are obsolescent too; however, __interrupt * functions have a special exemption due to messy historical usage, * with variants both with and without arguments in use. Note that * __interrupt functions are unlikely to be called directly. @@ -1528,7 +1588,9 @@ static TYPEPTR *GetProtoType( decl_info *first ) FullDeclSpecifier( &info ); } ParmList = parm_namelist; - /* if void is specified as a parm, it is the only parm allowed */ + /* + * if void is specified as a parm, it is the only parm allowed + */ return( MakeParmList( parmlist, false ) ); } @@ -1559,8 +1621,9 @@ TYPEPTR *MakeParmList( parm_list *parm, bool reversed ) for( next_parm = parm; next_parm != NULL; next_parm = next_parm->next_parm ) { ++parm_count; } - - /* try to find an existing parm list that matches */ + /* + * try to find an existing parm list that matches + */ hash = MAX_PARM_LIST_HASH_SIZE; if( parm_count < MAX_PARM_LIST_HASH_SIZE ) { hash = (parm_hash_idx)parm_count; @@ -1637,8 +1700,10 @@ static TYPEPTR *FuncProtoType( void ) } if( CurToken != T_LEFT_BRACE ) { if( SymLevel > 1 || !CompFlags.extensions_enabled ) { - /* get rid of any new tags regardless of SymLevel */ - /* get rid of new tags from proto */ + /* + * get rid of any new tags regardless of SymLevel + * get rid of new tags from proto + */ TagHead = old_taghead; FreeEnums(); } @@ -1658,7 +1723,9 @@ static void GetFuncParmList( void ) PARMPTR parm_namelist; parm_namelist = NULL; - /* scan off func parm list */ + /* + * scan off func parm list + */ while( CurToken == T_ID ) { if( parm_namelist == NULL ) { parm = (PARMPTR)CMemAlloc( sizeof( PARM_ENTRY ) ); @@ -1682,7 +1749,9 @@ static void GetFuncParmList( void ) break; if( CurToken != T_COMMA ) { MustRecog( T_COMMA ); /* forces error msg */ - /* skip until ')' to avoid cascading errors */ + /* + * skip until ')' to avoid cascading errors + */ while( CurToken != T_RIGHT_PAREN && CurToken != T_EOF ) { NextToken(); } @@ -1693,7 +1762,9 @@ static void GetFuncParmList( void ) parm->next_parm = (PARMPTR)CMemAlloc( sizeof( PARM_ENTRY ) ); parm = parm->next_parm; SymCreate( &parm->sym, "" ); - /* set flags so we don't give funny error messages */ + /* + * set flags so we don't give funny error messages + */ parm->sym.flags |= SYM_TEMP | SYM_ASSIGNED | SYM_REFERENCED; NextToken(); break; @@ -1716,10 +1787,10 @@ static void FreeParmList( void ) #if _CPU == 370 static bool IsIntComp( TYPEPTR ret1 ) - /* - * what's target compatible between default int as ret type - * and a later declaration - */ +/************************************ + * what's target compatible between default int as ret type + * and a later declaration + */ { bool ret; diff --git a/bld/cc/c/cdinit.c b/bld/cc/c/cdinit.c index 3625fc8422..794a3e0097 100644 --- a/bld/cc/c/cdinit.c +++ b/bld/cc/c/cdinit.c @@ -56,7 +56,9 @@ typedef struct { fold_state state; } addrfold_info; -/* use a double-linked list of dataquads to facilitate insertions */ +/* + * use a double-linked list of dataquads to facilitate insertions + */ typedef struct data_quad_list { DATA_QUAD dq; target_size size; @@ -1048,7 +1050,7 @@ void InitSymData( TYPEPTR typ, TYPEPTR ctyp, int level ) break; case TYP_LONG_DOUBLE: case TYP_LDIMAGINARY: - //StoreFloat( typ->decl_type, size ); +// StoreFloat( typ->decl_type, size ); StoreFloat( TYP_DOUBLE, size ); break; default: diff --git a/bld/cc/c/cdump.c b/bld/cc/c/cdump.c index 87d683c95e..67bb1ccd14 100644 --- a/bld/cc/c/cdump.c +++ b/bld/cc/c/cdump.c @@ -44,7 +44,9 @@ typedef struct { static void DoDumpType( TYPEPTR realtype, SYMPTR sym, STRCHUNK *pch ); -/* matches table of type in ctypes.h */ +/* + * matches table of type in ctypes.h + */ static const char *CTypeNames[] = { #define pick1(enum,cgtype,x86asmtype,name,size) name, #include "cdatatyp.h" @@ -64,7 +66,9 @@ static char *ChunkToStr( STRCHUNK *pch ) { char *ret; - /* remove spaces from end of string */ + /* + * remove spaces from end of string + */ while( pch->cursize > 0 && pch->data[pch->cursize - 1] == ' ' ) { pch->data[--pch->cursize] = '\0'; } @@ -156,7 +160,9 @@ static TYPEPTR TrueType( TYPEPTR typ ) return typ; if( do_message_output ) { - /* For human: smart typedef expansion. Stop before unnamed struct */ + /* + * For human: smart typedef expansion. Stop before unnamed struct + */ while( typ->decl_type == TYP_TYPEDEF ) { newtyp = typ->object; if( newtyp->decl_type == TYP_STRUCT || newtyp->decl_type == TYP_UNION @@ -169,7 +175,9 @@ static TYPEPTR TrueType( TYPEPTR typ ) } } else { if( !CompFlags.dump_prototypes ) { - /* -zg, not -v */ + /* + * -zg, not -v + */ SKIP_TYPEDEFS( typ ); } } @@ -294,7 +302,9 @@ static TYPEPTR DefArgPromotion( TYPEPTR arg_typ ) { TYPEPTR typ; - /* perform default argument promotions */ + /* + * perform default argument promotions + */ typ = arg_typ; while( typ->decl_type == TYP_TYPEDEF ) typ = Object( typ ); switch( typ->decl_type ) { @@ -344,10 +354,10 @@ static void DumpBaseType( TYPEPTR typ, STRCHUNK *pch ) } if( typ->decl_type == TYP_STRUCT || typ->decl_type == TYP_UNION || typ->decl_type == TYP_ENUM ) { - - /* if there is no tag name, then should print out the - entire structure or union definition or enum list */ - + /* + * if there is no tag name, then should print out the + * entire structure or union definition or enum list + */ DumpTagName( typ->u.tag->name, pch ); } } @@ -420,7 +430,9 @@ static void DumpTail( TYPEPTR typ, SYMPTR funcsym, type_modifiers pointer_flags, if( typ->decl_type == TYP_ARRAY ) { ChunkSaveChar( pch, ')' ); if( pointer_flags & FLAG_WAS_ARRAY ) { - /* we don't know the dimension anymore. just put out [1] */ + /* + * we don't know the dimension anymore. just put out [1] + */ ChunkSaveStr( pch, "[1]" ); pointer_flags = 0; } diff --git a/bld/cc/c/cenum.c b/bld/cc/c/cenum.c index cdf8a73561..889986b7b0 100644 --- a/bld/cc/c/cenum.c +++ b/bld/cc/c/cenum.c @@ -162,10 +162,11 @@ TYPEPTR EnumDecl( type_modifiers flags ) NextToken(); if( CurToken == T_ID ) { - /* could be: (1) "enum" ";" - (2) "enum" ";" - (3) "enum" "{" ... "}" - */ + /* + * could be: (1) "enum" ";" + * (2) "enum" ";" + * (3) "enum" "{" ... "}" + */ tag = TagLookup( Buffer ); NextToken(); if( CurToken != T_LEFT_BRACE ) { @@ -272,12 +273,16 @@ TYPEPTR EnumDecl( type_modifiers flags ) error = ENUM_INT; } if( index >= ENUM_SIZE ) { - // overflow signed maximum range + /* + * overflow signed maximum range + */ if( error == ENUM_UNDEF ) { error = const_index; } } else if(( const_index == ENUM_SIZE - 1 ) && minus ) { - // overflow unsigned maximum range by any negative signed value + /* + * overflow unsigned maximum range by any negative signed value + */ if( error == ENUM_UNDEF ) error = const_index; step = 1; @@ -285,7 +290,9 @@ TYPEPTR EnumDecl( type_modifiers flags ) if( !has_sign && minus ) { has_sign = true; if( index < const_index ) { - // round up to signed + /* + * round up to signed + */ index = ( const_index + 1 ) & ~1; } } diff --git a/bld/cc/c/cerror.c b/bld/cc/c/cerror.c index 1daab352bd..4897733d08 100644 --- a/bld/cc/c/cerror.c +++ b/bld/cc/c/cerror.c @@ -50,13 +50,17 @@ typedef struct ErrPostList { postlist_type type; union { - /* POSTLIST_SYMBOL */ + /* + * POSTLIST_SYMBOL + */ struct { const char *sym_name; const char *sym_file; unsigned sym_line; } s; - /* POSTLIST_TWOTYPES */ + /* + * POSTLIST_TWOTYPES + */ struct { TOKEN opr; TYPEPTR types[2]; @@ -92,8 +96,9 @@ void OpenErrFile( void ) } static bool okToPrintMsg( msg_codes msgnum, int *plevel ) -/*******************************************************/ -/* See if OK to print message */ +/******************************************************** + * See if OK to print message + */ { bool ok; int level; @@ -127,8 +132,10 @@ static bool okToPrintMsg( msg_codes msgnum, int *plevel ) return( ok ); } -// fill cmsg_info struct static void CMsgInfo( cmsg_info *info, int parmno, msg_codes msgnum, va_list args ) +/********************************************************************************** + * fill cmsg_info struct + */ { char *fname; unsigned line; @@ -137,12 +144,14 @@ static void CMsgInfo( cmsg_info *info, int parmno, msg_codes msgnum, va_list arg int prefix_len; info->msgnum = msgnum; -// CMsgSetClass( info, msgnum ); +// CMsgSetClass( info, msgnum ); switch( msgnum ) { case ERR_INVALID_MEMORY_MODEL: case ERR_INVALID_OPTION: case ERR_INVALID_OPTIMIZATION: - /* no location for error message */ + /* + * no location for error message + */ line = 0; column = 0; fname = NULL; @@ -192,8 +201,10 @@ static char const *MsgClassPhrase( cmsg_class class ) return( phrase ); } -// format message with line & file int buff void FmtCMsg( char *buff, cmsg_info *info ) +/****************************************** + * format message with line & file int buff + */ { size_t len; char const *phrase; @@ -211,8 +222,10 @@ void FmtCMsg( char *buff, cmsg_info *info ) snprintf( buff + len, MAX_MSG_LEN - len, "%s %s%03d: ", phrase, code_prefix, info->msgnum ); } -// print message to streams static void OutMsg( cmsg_info *info ) +/************************************* + * print message to streams + */ { char pre[MAX_MSG_LEN]; //actual message text @@ -262,8 +275,10 @@ static void PrintPostNotes( void ) } } -// Output error message static void CErr( int parmno, msg_codes msgnum, ... ) +/**************************************************** + * Output error message + */ { va_list args1; cmsg_info info; @@ -316,8 +331,10 @@ void CErrP1( int parmno, msg_codes msgnum ) } -// Out warning message static void CWarn( int parmno, msg_codes msgnum, ... ) +/***************************************************** + * Out warning message + */ { va_list args1; cmsg_info info; @@ -375,8 +392,10 @@ void CInfoMsg( msg_codes msgnum, ... ) } -// Output pre-compiled header Note void PCHNote( msg_codes msgnum, ... ) +/************************************ + * Output pre-compiled header Note + */ { va_list args1; char msgbuf[MAX_MSG_LEN]; @@ -416,8 +435,10 @@ void CSuicide( void ) #if 0 -//doesn't work in general as phases are used in both errror and warnings static void CMsgSetClass( cmsg_info *info, msg_codes msgnum ) +/************************************************************ + * doesn't work in general as phases are used in both errror and warnings + */ { msg_type kind; cmsg_class class; @@ -441,8 +462,10 @@ static void CMsgSetClass( cmsg_info *info, msg_codes msgnum ) info->class = class; } -// fill info static void DoMsgInfo( msg_codes msgnum ) +/**************************************** + * fill info + */ { cmsg_info sinfo; cmsg_info *info; @@ -470,11 +493,10 @@ void DumpAllMsg( void ) { } #endif -/* +static struct ErrPostList *NewPostList( postlist_type type ) +/*********************************************************** * post-processing messages (informational notes) */ - -static struct ErrPostList *NewPostList( postlist_type type ) { struct ErrPostList *np; diff --git a/bld/cc/c/cexpr.c b/bld/cc/c/cexpr.c index bfd217a843..451a5edd5a 100644 --- a/bld/cc/c/cexpr.c +++ b/bld/cc/c/cexpr.c @@ -112,8 +112,11 @@ static TREEPTR CallNode( TREEPTR func, TREEPTR parms, TYPEPTR func_result_type ) } static TYPEPTR Far16Type( TYPEPTR typ ) -{ // TODO all this stuff should be part of the func defn. - // not some hack on for later +/************************************** + * TODO all this stuff should be part of the func defn. + * not some hack on for later + */ +{ TYPEPTR typ2; typ2 = typ; @@ -232,7 +235,7 @@ static TREEPTR ConstLeaf( void ) break; case TYP_CHAR: leaf->op.u1.const_type = TYP_INT; - // fall through + /* fall through */ case TYP_INT: leaf->op.u2.long_value = Constant; break; @@ -264,7 +267,9 @@ static TREEPTR ConstLeaf( void ) flt->next = NULL; leaf->op.u2.float_value = flt; leaf->op.opr = OPR_PUSHFLOAT; - /* Convert constant to binary; that ensures it'll be cast properly. */ + /* + * Convert constant to binary; that ensures it'll be cast properly. + */ MakeBinaryFloat( leaf ); break; } @@ -316,7 +321,7 @@ static TREEPTR EnumLeaf( ENUMPTR ep ) case TYP_CHAR: case TYP_SHORT: decl_type = TYP_INT; - // fall through + /* fall through */ case TYP_INT: case TYP_LONG: leaf->op.u2.long_value = (signed_32)ep->value.u._32[I64LO32]; @@ -324,7 +329,7 @@ static TREEPTR EnumLeaf( ENUMPTR ep ) case TYP_UCHAR: case TYP_USHORT: decl_type = TYP_INT; - // fall through + /* fall through */ case TYP_UINT: case TYP_ULONG: leaf->op.u2.long_value = ep->value.u._32[I64LO32]; @@ -410,14 +415,18 @@ static TREEPTR SymLeaf( void ) } if( tree == NULL ) { - /* if( SizeOfCount == 0 ) */ /* causes defined but not referenced */ - /* always turning it on can cause referenced but not assigned */ - /* for the case: int i; j = sizeof(i); */ + /* + * if( SizeOfCount == 0 ) causes defined but not referenced + * always turning it on can cause referenced but not assigned + * for the case: int i; j = sizeof(i); + */ sym.flags |= SYM_REFERENCED; if( sym_handle == SYM_NULL ) { if( CurToken == T_LEFT_PAREN ) { sym.attribs.stg_class = SC_FORWARD; /* indicate forward decl */ - /* Warn about unprototyped function */ + /* + * Warn about unprototyped function + */ CWarn2p( ERR_ASSUMED_IMPORT, sym.name ); sym_handle = SymAddL0( hash, &sym ); /* add symbol to level 0 */ sym.flags |= SYM_FUNCTION; @@ -477,7 +486,9 @@ bool IsLValue( TREEPTR tree ) case OPR_CALL: case OPR_QUESTION: case OPR_COMMA: - // These are not lvalues + /* + * These are not lvalues + */ break; default: return( true ); @@ -496,8 +507,10 @@ static bool IsCallValue( TREEPTR tree ) return( tree->op.opr == OPR_CALL ); } -// This RVALUE thing is backwards -mjc static TREEPTR TakeRValue( TREEPTR tree, int void_ok ) +/***************************************************** + * This RVALUE thing is backwards + */ { TYPEPTR typ; sym_flags symb_flags; @@ -595,7 +608,9 @@ static TREEPTR TakeRValue( TREEPTR tree, int void_ok ) && sym.attribs.stg_class != SC_STATIC && sym.attribs.stg_class != SC_EXTERN ) { if( (sym.flags & SYM_ASSIGNED) == 0 ) { - /* turn on flag so msg only comes out once per sym */ + /* + * turn on flag so msg only comes out once per sym + */ sym.flags |= SYM_ASSIGNED; CWarn2p( ERR_SYM_NOT_ASSIGNED, SymName( &sym, tree->op.u2.sym_handle ) ); } @@ -714,8 +729,10 @@ static TREEPTR AddrOp( TREEPTR tree ) leaf = tree->left; } } else if( tree->op.opr == OPR_ARROW ) { - // checking for offsetof macro construct - // #define offsetof(typ,field) (size_t)&(((typ*)0)->field) + /* + * checking for offsetof macro construct + * #define offsetof(typ,field) (size_t)&(((typ*)0)->field) + */ if( tree->left->op.opr == OPR_PUSHINT ) { leaf = tree->left; leaf->op.u2.ulong_value += tree->right->op.u2.ulong_value; @@ -895,7 +912,9 @@ static TREEPTR CheckBasedPtr( TREEPTR tree, TYPEPTR typ, type_modifiers *p_flags SYMPTR base_sym; TYPEPTR base_typ; - // For pointers based on another pointer, copy flags from the base ptr + /* + * For pointers based on another pointer, copy flags from the base ptr + */ base_sym_handle = typ->u.p.based_sym; base_sym = SymGetPtr( base_sym_handle ); base_typ = base_sym->sym_type; @@ -927,7 +946,7 @@ static TREEPTR PtrOp( TREEPTR tree ) tree = CheckBasedPtr( tree, typ, &flags ); tree = ExprNode( tree, OPR_POINTS, NULL ); typ = typ->object; -// SKIP_TYPEDEFS( typ ); +// SKIP_TYPEDEFS( typ ); tree->u.expr_type = typ; tree->op.u2.result_type = ptrtyp; tree->op.flags = OpFlags( flags ); @@ -1210,9 +1229,10 @@ static TREEPTR GetExpr( void ) curclass = TokenClass[CurToken]; while( curclass <= Class[ExprLevel] ) { op1 = ValueStack[ExprLevel]; - - /* the following cases are listed from lowest to highest - priority */ + /* + * the following cases are listed from lowest to highest + * priority + */ switch( Class[ExprLevel] ) { case TC_START: case TC_START1: @@ -1367,7 +1387,9 @@ static TREEPTR GetExpr( void ) expr_level_type n; TREEPTR functree; - // find the corresponding function symbol + /* + * find the corresponding function symbol + */ n = ExprLevel; while( Token[n] != T_LEFT_PAREN ) { --n; @@ -1427,7 +1449,7 @@ static TREEPTR GetExpr( void ) case TC_SHIFT_OP: case TC_ADD_OP: case TC_MUL_OP: -/* tree = RValue( tree ); */ +// tree = RValue( tree ); break; case TC_ASSIGN_OP: curclass = TC_ASSIGNMENT; @@ -1698,9 +1720,9 @@ static TREEPTR ExprId( void ) NextToken(); } } else { -// if( SizeOfCount == 0 ) { -// CWarn2p( ERR_UNDECLARED_PP_SYM, Buffer); -// } +// if( SizeOfCount == 0 ) { +// CWarn2p( ERR_UNDECLARED_PP_SYM, Buffer); +// } NextToken(); if( CurToken == T_LEFT_PAREN ) { count = 0; @@ -1754,11 +1776,13 @@ static TREEPTR GenIndex( TREEPTR tree, TREEPTR index_expr ) TYPEPTR typ; op_flags tree_flags; -// if( ! LValueArray( tree ) ) { -// CErr1( ERR_CANT_TAKE_ADDR_OF_RVALUE ); -// FreeExprTree( index_expr ); -// return( ErrorNode( tree ) ); -// } +#if 0 + if( ! LValueArray( tree ) ) { + CErr1( ERR_CANT_TAKE_ADDR_OF_RVALUE ); + FreeExprTree( index_expr ); + return( ErrorNode( tree ) ); + } +#endif index_expr = RValue( index_expr ); if( DataTypeOf( TypeOf( index_expr ) ) > TYP_ULONG64 ) { CErr1( ERR_EXPR_MUST_BE_INTEGRAL ); @@ -1776,7 +1800,9 @@ static TREEPTR GenIndex( TREEPTR tree, TREEPTR index_expr ) type_modifiers flags; tree = CheckBasedPtr( tree, typ, &flags ); - // We will indirect so get modifiers of indirected obj + /* + * We will indirect so get modifiers of indirected obj + */ tree_flags = OpFlags( flags ); } else { CErr2p( ERR_FATAL_ERROR, "Bad array index tree" ); @@ -1784,7 +1810,9 @@ static TREEPTR GenIndex( TREEPTR tree, TREEPTR index_expr ) } typ = typ->object; SKIP_TYPEDEFS( typ ); - // Some crappy little optimization that probably does nothing + /* + * Some crappy little optimization that probably does nothing + */ if( index_expr->op.opr == OPR_PUSHINT && tree->u.expr_type->decl_type == TYP_ARRAY ) { index_expr->op.u2.long_value *= SizeOfArg( typ ); @@ -1848,8 +1876,10 @@ static TREEPTR IndexOp( TREEPTR tree, TREEPTR index_expr ) } static void AddCallNode( TREEPTR tree ) -// if a function call has no prototype wait till end -// to check it out +/************************************** + * if a function call has no prototype wait till end + * to check it out + */ { call_list *new; @@ -1877,7 +1907,9 @@ void ChkCallNode( TREEPTR tree ) } static int ParmNum( void ) -// get current parm num +/************************* + * get current parm num + */ { int parm_count; expr_level_type n; @@ -1899,13 +1931,17 @@ static TREEPTR GenNextParm( TREEPTR tree, TYPEPTR **plistptr ) tree = RValue( tree ); if( tree->op.opr == OPR_ERROR ) return( tree ); - // skip typedefs, go into enum base + /* + * skip typedefs, go into enum base + */ typ = SkipTypeFluff( tree->u.expr_type ); plist = *plistptr; if( plist != NULL ) { if( *plist == NULL ) { // To many parm trees #if _CPU == 386 - /* can allow wrong number of parms with -3s option */ + /* + * can allow wrong number of parms with -3s option + */ if( !CompFlags.register_conventions ) { CWarn1( ERR_PARM_COUNT_WARNING ); } else { @@ -1926,7 +1962,9 @@ static TREEPTR GenNextParm( TREEPTR tree, TYPEPTR **plistptr ) parm_typ = *plist; ParmAsgnCheck( parm_typ, tree, ParmNum(), true ); if( parm_typ != NULL ) { - // skip typedefs, go into enum base + /* + * skip typedefs, go into enum base + */ parm_typ = SkipTypeFluff( parm_typ ); if( parm_typ != typ ) { tree = FixupAss( tree, parm_typ ); @@ -1963,19 +2001,22 @@ static TREEPTR GenNextParm( TREEPTR tree, TYPEPTR **plistptr ) #if _RISC_CPU -// This really ought to be defined somewhere else... +/* + * This really ought to be defined somewhere else... + */ #if (_CPU == _AXP) #define REG_SIZE 8 #else #define REG_SIZE 4 #endif static TREEPTR GenVaStartNode( TREEPTR last_parm ) +/************************************************* + * there should be 3 parms __builtin_va_start( list, parm_name, stdarg ) + * - first parm should be name of va_list + * - second parm should be name of the parameter before the ... + * - last_parm should be an integer 0 or 1 (0=>varargs, 1=>stdarg) + */ { - // there should be 3 parms __builtin_va_start( list, parm_name, stdarg ) - // - first parm should be name of va_list - // - second parm should be name of the parameter before the ... - // - last_parm should be an integer 0 or 1 (0=>varargs, 1=>stdarg) - SYMPTR sym; SYM_HANDLE sym_handle; int offset; @@ -2004,7 +2045,9 @@ static TREEPTR GenVaStartNode( TREEPTR last_parm ) } } if( offset == 0 || sym_handle == SYM_NULL ) { - // error: name not found in symbol list + /* + * error: name not found in symbol list + */ sym = SymGetPtr( parmsym->op.u2.sym_handle ); CErr2p( ERR_SYM_NOT_IN_PARM_LIST, SymName( sym, parmsym->op.u2.sym_handle ) ); } @@ -2017,21 +2060,27 @@ static TREEPTR GenVaStartNode( TREEPTR last_parm ) tree = ExprNode( tree, OPR_VASTART, IntLeaf(offset) ); ExprLevel -= 2; } else { - // error + /* + * error + */ } return( tree ); } static TREEPTR GenAllocaNode( TREEPTR size_parm ) { - // there should be 1 parm __builtin_alloca( size ) + /* + * there should be 1 parm __builtin_alloca( size ) + */ TREEPTR tree; if( Token[ExprLevel] == T_LEFT_PAREN ) { tree = ExprNode( NULL, OPR_ALLOCA, size_parm ); tree->u.expr_type = PtrNode( GetType( TYP_VOID ), FLAG_NONE, SEG_STACK ); } else { - // error + /* + * error + */ tree = NULL; } return( tree ); @@ -2041,9 +2090,11 @@ static TREEPTR GenAllocaNode( TREEPTR size_parm ) #if _CPU == _PPC static TREEPTR GenVaArgNode( TREEPTR last_parm ) { - // there should be 2 parms __builtin_va_arg( list, type_arg ) - // - first parm should be name of va_list - // - last_parm should be an integer 0 or 1 (0=>varargs, 1=>stdarg) + /* + * there should be 2 parms __builtin_va_arg( list, type_arg ) + * - first parm should be name of va_list + * - last_parm should be an integer 0 or 1 (0=>varargs, 1=>stdarg) + */ TREEPTR parmsym; TREEPTR tree; @@ -2066,7 +2117,9 @@ static TREEPTR GenVaArgNode( TREEPTR last_parm ) tree = ExprNode( tree, OPR_VASTART, IntLeaf( 0) ); ExprLevel -= 2; } else { - // error + /* + * error + */ } return( tree ); } @@ -2285,7 +2338,9 @@ static TREEPTR StartFunc( TREEPTR tree, TYPEPTR **plistptr ) } #endif decl_flags = sym.mods; - // is it OK to inline? + /* + * is it OK to inline? + */ } else { /* indirect call */ if( CompFlags.initializing_data ) { CErr1( ERR_NOT_A_CONSTANT_EXPR ); @@ -2318,7 +2373,9 @@ static TREEPTR StartFunc( TREEPTR tree, TYPEPTR **plistptr ) parm_types = typ->u.fn.parms; /* Parameters (prototype), if any */ NextToken(); /* skip over '(' */ if( CurToken != T_RIGHT_PAREN ) { - // push previous plist for nested calls + /* + * push previous plist for nested calls + */ struct nested_parm_lists *npl; npl = CMemAlloc( sizeof( struct nested_parm_lists ) ); @@ -2397,7 +2454,9 @@ static TREEPTR StartFunc( TREEPTR tree, TYPEPTR **plistptr ) static TREEPTR OrOr( TREEPTR tree ) { - // This routine is called when || token is found + /* + * This routine is called when || token is found + */ if( tree->op.opr == OPR_PUSHINT ) { if( tree->op.u2.long_value != 0 ) { ++SizeOfCount; /* skip code gen */ @@ -2410,7 +2469,9 @@ static TREEPTR OrOr( TREEPTR tree ) static TREEPTR AndAnd( TREEPTR tree ) { - // This routine is called when && token is found + /* + * This routine is called when && token is found + */ if( tree->op.opr == OPR_PUSHINT ) { if( tree->op.u2.long_value == 0 ) { ++SizeOfCount; /* skip code gen */ diff --git a/bld/cc/c/cfedump.c b/bld/cc/c/cfedump.c index 5777be9574..fd4af9eec8 100644 --- a/bld/cc/c/cfedump.c +++ b/bld/cc/c/cfedump.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -65,8 +65,10 @@ static void DumpAString( STR_HANDLE str_handle ) } #ifdef _LONG_DOUBLE_ -/* Dump a long_double value */ void DumpALD( long_double *pld ) +/******************************* + * Dump a long_double value + */ { CVT_INFO cvt; char buf[256]; @@ -80,8 +82,10 @@ void DumpALD( long_double *pld ) printf( "%s", buf ); } -/* Dump a long double followed by newline */ void DumpALDNL( long_double *pld ) +/********************************* + * Dump a long double followed by newline + */ { DumpALD( pld ); printf( "\n" ); @@ -236,12 +240,14 @@ static void DumpInfix( TREEPTR node ) break; default: printf( " " ); - // fall through + /* fall through */ case OPR_RETURN: printf( "%s ", _Ops[node->op.opr] ); break; case OPR_POINTS: - // already printed in prefix routine + /* + * already printed in prefix routine + */ break; } } diff --git a/bld/cc/c/cfeinfo.c b/bld/cc/c/cfeinfo.c index 0fbfd0eb86..cf80bb9e36 100644 --- a/bld/cc/c/cfeinfo.c +++ b/bld/cc/c/cfeinfo.c @@ -55,47 +55,51 @@ #define _HAS_ANY_MAIN (_HAS_EXE_MAIN || _HAS_DLL_MAIN) static unsigned char VarFuncWeights[] = { -//a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y,z - 0, 0,13, 0, 2, 1, 0, 0, 0, 0, 0,12, 0,14, 4,10, 0, 0, 6, 0, 0, 0, 0, 0, 0,0 +/* a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z */ + 0, 0,13, 0, 2, 1, 0, 0, 0, 0, 0,12, 0,14, 4,10, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0 }; static const char *VarParmFuncs[] = { - /* functions with var parm lists */ - "", // 0 - "", // 1 - "", // 2 - "", // 3 - "", // 4 - "", // 5 - "", // 6 - "", // 7 - "fscanf", // 8 - "fprintf", // 9 - "execle", // 10 - "execlpe", // 11 - "scanf", // 12 - "sscanf", // 13 - "sprintf", // 14 - "spawnle", // 15 - "spawnlpe", // 16 - "printf", // 17 - "execlp", // 18 - "execl", // 19 - "cscanf", // 20 - "cprintf", // 21 - "open", // 22 - "spawnlp", // 23 - "spawnl", // 24 - "sopen", // 25 - "", // 26 - "", // 27 - "", // 28 - "", // 29 - "", // 30 - "", // 31 + /* + * functions with var parm lists + */ + "", /* 0 */ + "", /* 1 */ + "", /* 2 */ + "", /* 3 */ + "", /* 4 */ + "", /* 5 */ + "", /* 6 */ + "", /* 7 */ + "fscanf", /* 8 */ + "fprintf", /* 9 */ + "execle", /* 10 */ + "execlpe", /* 11 */ + "scanf", /* 12 */ + "sscanf", /* 13 */ + "sprintf", /* 14 */ + "spawnle", /* 15 */ + "spawnlpe", /* 16 */ + "printf", /* 17 */ + "execlp", /* 18 */ + "execl", /* 19 */ + "cscanf", /* 20 */ + "cprintf", /* 21 */ + "open", /* 22 */ + "spawnlp", /* 23 */ + "spawnl", /* 24 */ + "sopen", /* 25 */ + "", /* 26 */ + "", /* 27 */ + "", /* 28 */ + "", /* 29 */ + "", /* 30 */ + "", /* 31 */ }; -/* bitmap for which of the above are Standard */ +/* + * bitmap for which of the above are Standard + */ #define VAR_PARM_FUNCS_ANSI \ ((1<<8) | (1<<9) | (1<<12) | (1<<13) | (1<<14) | (1<<17)) @@ -132,10 +136,10 @@ static struct STRUCT_BYTE_SEQ( 6 ) TryFiniCode = { #endif -/* -// does the specified symbol take variable parameters? manual search. -*/ bool VarParm( SYMPTR sym ) +/************************* + * does the specified symbol take variable parameters? manual search. + */ { TYPEPTR *parm_types; TYPEPTR typ; @@ -158,11 +162,10 @@ bool VarParm( SYMPTR sym ) return( false ); } -/* -// does the specified symbol take variable args? hash calc'ed -// -*/ bool VarFunc( SYMPTR sym ) +/************************* + * does the specified symbol take variable args? hash calc'ed + */ { unsigned hash; size_t len; @@ -412,7 +415,9 @@ aux_info *FindInfo( SYMPTR sym, SYM_HANDLE sym_handle ) } #endif if( (sym->flags & SYM_TEMP) == 0 ) { - /* not an indirect func call*/ + /* + * not an indirect func call + */ inf = InfoLookup( sym ); } if( inf == &DefaultInfo ) { @@ -568,21 +573,20 @@ call_class_target GetCallClassTarget( SYM_HANDLE sym_handle ) } #endif -/* -// NextLibrary -// Called (indirectly) from the code generator to inject automagically defined symbols. -// Inputs: -// index (n-1) -// Usually called from a loop until we return 0/NULL to show no more libraries -// request -// FEINF_NEXT_LIBRARY -// examines the current flags to see if any libraries should be -// automagically referenced and returns the relevant index if so. -// FEINF_LIBRARY_NAME -// returns the requested name. -// -*/ static void addDefaultLibs( void ) +/********************************* + * NextLibrary + * Called (indirectly) from the code generator to inject automagically defined symbols. + * Inputs: + * index (n-1) + * Usually called from a loop until we return 0/NULL to show no more libraries + * request + * FEINF_NEXT_LIBRARY + * examines the current flags to see if any libraries should be + * automagically referenced and returns the relevant index if so. + * FEINF_LIBRARY_NAME + * returns the requested name. + */ { if( CompFlags.emit_library_names ) { if( _HAS_ANY_MAIN || CompFlags.pragma_library || CompFlags.emit_all_default_libs ) { @@ -616,34 +620,40 @@ static CGPOINTER NextLibrary( int index, aux_class request ) ++i; } } - /* return library name, or */ + /* + * return library name, or + */ if( request == FEINF_LIBRARY_NAME || name == NULL ) return( (CGPOINTER)name ); - /* library index */ + /* + * library index + */ return( (CGPOINTER)(pointer_uint)index ); } -// NextAlias -// Called (indirectly) from the code generator to go through the list of -// linker aliases. -// Inputs: -// index (n-1) -// Called from a loop until we return 0/NULL to show no more aliases -// request -// FEINF_NEXT_ALIAS -// returns the index of next alias in the list, or zero if none. -// FEINF_ALIAS_NAME -// returns the alias name, or NULL if alias refers to a symbol. -// FEINF_ALIAS_SYMBOL -// returns the alias symbol, or NULL if alias refers to a name. -// FEINF_ALIAS_SUBST_NAME -// returns the name to be substituted for the alias, or NULL. -// FEINF_ALIAS_SUBST_SYMBOL -// returns the symbol to be substituted for the alias, or NULL. -// -// Note: One of FEINF_ALIAS..._NAME and FEINF_ALIAS..._SYMBOL will always be 0/NULL and the other -// will be valid, depending on which form of the pragma was used. static CGPOINTER NextAlias( int index, aux_class request ) +/********************************************************* + * NextAlias + * Called (indirectly) from the code generator to go through the list of + * linker aliases. + * Inputs: + * index (n-1) + * Called from a loop until we return 0/NULL to show no more aliases + * request + * FEINF_NEXT_ALIAS + * returns the index of next alias in the list, or zero if none. + * FEINF_ALIAS_NAME + * returns the alias name, or NULL if alias refers to a symbol. + * FEINF_ALIAS_SYMBOL + * returns the alias symbol, or NULL if alias refers to a name. + * FEINF_ALIAS_SUBST_NAME + * returns the name to be substituted for the alias, or NULL. + * FEINF_ALIAS_SUBST_SYMBOL + * returns the symbol to be substituted for the alias, or NULL. + * + * Note: One of FEINF_ALIAS..._NAME and FEINF_ALIAS..._SYMBOL will always be 0/NULL and the other + * will be valid, depending on which form of the pragma was used. + */ { alias_list *aliaslist; SYM_HANDLE alias_sym = SYM_NULL; @@ -680,10 +690,11 @@ static CGPOINTER NextAlias( int index, aux_class request ) } } -/* Return the size of function parameters or -1 if size could +static unsigned GetParmsSize( SYM_HANDLE sym_handle ) +/**************************************************** + * Return the size of function parameters or -1 if size could * not be determined (symbol isn't a function or is variadic) */ -static unsigned GetParmsSize( SYM_HANDLE sym_handle ) { unsigned total_parm_size = 0; unsigned parm_size; @@ -717,10 +728,10 @@ static unsigned GetParmsSize( SYM_HANDLE sym_handle ) return( total_parm_size ); } -/* -// Return name pattern manipulator string -*/ static const char *GetNamePattern( SYM_HANDLE sym_handle ) +/********************************************************* + * Return name pattern manipulator string + */ { char *pattern; SYM_ENTRY sym; @@ -880,7 +891,9 @@ static void addDefaultImports( void ) } #else /* _RISC_CPU */ if( CompFlags.emit_library_names ) { - /* handle floating-point support */ + /* + * handle floating-point support + */ if( CompFlags.float_used ) { AddExtRefN( "_fltused_" ); } @@ -915,53 +928,62 @@ static void addDefaultImports( void ) AddExtRefN( "_argc" ); } #endif - /* handle default windowing app */ + /* + * handle default windowing app + */ if( CompFlags.bw_switch_used ) { AddExtRefN( "__init_default_win" ); } #if _INTEL_CPU - /* handle NetWare */ + /* + * handle NetWare + */ if( TargetSystem == TS_NETWARE || TargetSystem == TS_NETWARE5 ) { - /* is target NETWARE or NETWARE5? */ + /* + * is target NETWARE or NETWARE5? + */ AddExtRefN( "__WATCOM_Prelude" ); } - - /* handle 'old' profiling */ + /* + * handle 'old' profiling + */ if( TargetSwitches & CGSW_X86_P5_PROFILING ) { - /* is profiling enabled (-et)? */ + /* + * is profiling enabled (-et)? + */ AddExtRefN( "__p5_profile" ); } - - /* handle 'new' profiling */ + /* + * handle 'new' profiling + */ if( TargetSwitches & CGSW_X86_NEW_P5_PROFILING ) { - /* is profiling enabled (-etp)? */ + /* + * is profiling enabled (-etp)? + */ AddExtRefN( "__new_p5_profile" ); } #endif } -/* -// NextImport -// Called (indirectly) from the code generator to inject automagically defined symbols. -// Inputs: -// index (n-1) -// Usually called from a loop until we return 0/NULL to show no more symbols -// are required. -// request -// FEINF_NEXT_IMPORT -// examines the current flags to see if any symbols should be -// automagically inserted and returns the relevant index if so. -// FEINF_IMPORT_NAME -// returns the requested name. if we have returned an index for -// the current compiler settings we should be called with a valid -// index but we still perform exactly the same checks as this is -// good practise. -// -*/ - static CGPOINTER NextImport( int index, aux_class request ) -/*********************************************************/ +/********************************************************** + * NextImport + * Called (indirectly) from the code generator to inject automagically defined symbols. + * Inputs: + * index (n-1) + * Usually called from a loop until we return 0/NULL to show no more symbols + * are required. + * request + * FEINF_NEXT_IMPORT + * examines the current flags to see if any symbols should be + * automagically inserted and returns the relevant index if so. + * FEINF_IMPORT_NAME + * returns the requested name. if we have returned an index for + * the current compiler settings we should be called with a valid + * index but we still perform exactly the same checks as this is + * good practise. + */ { char *name; int i; @@ -987,10 +1009,14 @@ static CGPOINTER NextImport( int index, aux_class request ) ++i; } } - /* return the import name, or */ + /* + * return the import name, or + */ if( request == FEINF_IMPORT_NAME || name == NULL ) return( (CGPOINTER)name ); - /* return the index */ + /* + * return the index + */ return( (CGPOINTER)(pointer_uint)index ); } @@ -1018,10 +1044,14 @@ static CGPOINTER NextImportS( int index, aux_class request ) ++i; } } - /* return the import symbol, or */ + /* + * return the import symbol, or + */ if( request == FEINF_IMPORT_NAME_S || symbol == NULL ) return( (CGPOINTER)symbol ); - /* return the index */ + /* + * return the index + */ return( (CGPOINTER)(pointer_uint)index ); } diff --git a/bld/cc/c/cfold.c b/bld/cc/c/cfold.c index c80c30f640..613218a268 100644 --- a/bld/cc/c/cfold.c +++ b/bld/cc/c/cfold.c @@ -201,7 +201,7 @@ static uint64 DoOp64( uint64 left, opr_code opr, uint64 right, bool sign ) break; case OPR_NEG: U64Neg( &right, &value ); -// value = - right; +// value = - right; break; case OPR_COM: value.u._32[I64LO32] = ~right.u._32[I64LO32]; @@ -220,7 +220,7 @@ static uint64 DoOp64( uint64 left, opr_code opr, uint64 right, bool sign ) } static int DoSignedOp( TREEPTR op1, TREEPTR tree, TREEPTR op2 ) -/******************************************************/ +/*************************************************************/ { int_32 value; int_32 left; @@ -279,7 +279,7 @@ static int DoSignedOp( TREEPTR op1, TREEPTR tree, TREEPTR op2 ) static int DoUnSignedOp( TREEPTR op1, TREEPTR tree, TREEPTR op2 ) -/********************************************************/ +/***************************************************************/ { uint_32 value; uint_32 left; @@ -418,7 +418,7 @@ int64 LongValue64( TREEPTR leaf ) static int DoUnSignedOp64( TREEPTR op1, TREEPTR tree, TREEPTR op2 ) -/**********************************************************/ +/*****************************************************************/ { uint64 value; uint64 left; @@ -476,7 +476,7 @@ static int DoUnSignedOp64( TREEPTR op1, TREEPTR tree, TREEPTR op2 ) static int DoSignedOp64( TREEPTR op1, TREEPTR tree, TREEPTR op2 ) -/********************************************************/ +/***************************************************************/ { int64 value; int64 left; @@ -568,8 +568,10 @@ static void CastFloatValue( TREEPTR leaf, DATA_TYPE newtype ) #if 0 ld.u.value = (double)leaf->op.u2.ulong64_value.u._64[0]; #else - /* temporary fix for missing uint_64 -> double conversion in OW code generator for RISC */ - /* it is valid for two's complement integers */ + /* + * temporary fix for missing uint_64 -> double conversion in OW code generator for RISC + * it is valid for two's complement integers + */ ld.u.value = (double)(int_64)leaf->op.u2.ulong64_value.u._64[0]; if( (int_64)leaf->op.u2.ulong64_value.u._64[0] < 0 ) { ld.u.value += U64_DOUBLE_CORRECTION; @@ -581,7 +583,9 @@ static void CastFloatValue( TREEPTR leaf, DATA_TYPE newtype ) case TYP_SHORT: case TYP_INT: case TYP_LONG: - // signed types + /* + * signed types + */ #ifdef _LONG_DOUBLE_ __I4LD( leaf->op.u2.long_value, &ld ); #else @@ -589,7 +593,9 @@ static void CastFloatValue( TREEPTR leaf, DATA_TYPE newtype ) #endif break; default: - // unsigned types + /* + * unsigned types + */ #ifdef _LONG_DOUBLE_ __U4LD( leaf->op.u2.ulong_value, &ld ); #else @@ -686,7 +692,9 @@ static int DoFloatOp( TREEPTR op1, TREEPTR tree, TREEPTR op2 ) TYPEPTR typ1; TYPEPTR typ2; - // load ld1 and ld2 from op1 and op2 + /* + * load ld1 and ld2 from op1 and op2 + */ MakeBinaryFloat( op2 ); ld2 = op2->op.u2.float_value->ld; typ2 = TypeOf( op2 ); @@ -786,7 +794,9 @@ static int DoFloatOp( TREEPTR op1, TREEPTR tree, TREEPTR op2 ) default: return( 0 ); } - /* The expression type must obey the usual arithmetic conversions. */ + /* + * The expression type must obey the usual arithmetic conversions. + */ tree->op.opr = OPR_PUSHFLOAT; tree->op.u2.float_value = op2->op.u2.float_value; tree->op.u2.float_value->ld = result; @@ -795,8 +805,10 @@ static int DoFloatOp( TREEPTR op1, TREEPTR tree, TREEPTR op2 ) tree->left = NULL; tree->right = NULL; FreeExprNode( op1 ); - // we reused op2->op.u2.float_value, so change op2->op.opr so that - // FreeExprNode doesn't try to free op2->op.u2.float_value + /* + * we reused op2->op.u2.float_value, so change op2->op.opr so that + * FreeExprNode doesn't try to free op2->op.u2.float_value + */ op2->op.opr = OPR_NOP; FreeExprNode( op2 ); return( 1 ); @@ -931,8 +943,10 @@ void CastConstNode( TREEPTR leaf, TYPEPTR newtyp ) CastConstValue( leaf, newtyp->decl_type ); if( newtyp->decl_type == TYP_POINTER ) { leaf->op.flags = OpFlags( newtyp->u.p.decl_flags ); - // This really ought to be in CastConstValue, but that - // function can't figure out the exact pointer size + /* + * This really ought to be in CastConstValue, but that + * function can't figure out the exact pointer size + */ if ( TypeSize( newtyp ) == TARGET_SHORT ) { leaf->op.u2.ulong_value = (target_ushort)leaf->op.u2.ulong_value; } @@ -1062,8 +1076,10 @@ static bool FoldableTree( TREEPTR tree ) SymGet( &sym, opnd->right->op.u2.sym_handle ); if( sym.attribs.stg_class != SC_AUTO && sym.attribs.stg_class != SC_REGISTER ) { - /* &(static object) is known to be non-zero */ - /* replace it by a 1 */ + /* + * &(static object) is known to be non-zero + * replace it by a 1 + */ FreeExprNode( opnd->right ); FreeExprNode( opnd ); tree->left = UIntLeaf( 1 ); @@ -1097,7 +1113,8 @@ static bool FoldableTree( TREEPTR tree ) } break; #if _CPU == 8086 - /* The :> operator is currently only folded for 16-bit targets. The + /* + * The :> operator is currently only folded for 16-bit targets. The * folding itself can handle 16:32 pointers, but other places in cfe * and cg don't understand larger than 32-bit pointer constants. */ @@ -1164,12 +1181,13 @@ static arithmetic_type ArithmeticType( DATA_TYPE decl_type ) } -/* Check values of constant operands of certain operators. Needs to be done +static void CheckOpndValues( TREEPTR tree ) +/****************************************** + * Check values of constant operands of certain operators. Needs to be done * after all sub-trees are folded (the checked operands may be result of * constant folding) but before potentially constant folding the examined * operator. */ -static void CheckOpndValues( TREEPTR tree ) { TYPEPTR r_type; TREEPTR opnd; @@ -1191,9 +1209,10 @@ static void CheckOpndValues( TREEPTR tree ) opnd = tree->right; r_type = opnd->u.expr_type; con = ArithmeticType( r_type->decl_type ); - - // shift arguments undergo integral promotion; 'char c = 1 << 10;' - // is not undefined, though it will overflow + /* + * shift arguments undergo integral promotion; 'char c = 1 << 10;' + * is not undefined, though it will overflow + */ max_shift = SizeOfArg( GetType( TYP_INT ) ); if( max_shift < SizeOfArg( tree->left->u.expr_type ) ) max_shift = SizeOfArg( tree->left->u.expr_type ); @@ -1235,7 +1254,9 @@ static void CheckOpndValues( TREEPTR tree ) } } break; default: - // Not supposed to happen! + /* + * Not supposed to happen! + */ break; } if( shift_negative ) { @@ -1270,11 +1291,15 @@ static void CheckOpndValues( TREEPTR tree ) break; } case FLOATING: - // Should we warn here? Floating-point division by zero is - // not necessarily undefined... + /* + * Should we warn here? Floating-point division by zero is + * not necessarily undefined... + */ break; default: - // Not supposed to happen? + /* + * Not supposed to happen? + */ break; } if( zero_divisor ) { diff --git a/bld/cc/c/cgen.c b/bld/cc/c/cgen.c index ff0c8591ab..20a6f2830a 100644 --- a/bld/cc/c/cgen.c +++ b/bld/cc/c/cgen.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -109,7 +109,9 @@ struct func_save { LABEL_INDEX labelindex; }; -/* matches table of type in ctypes.h */ +/* + * matches table of type in ctypes.h + */ static char CGDataType[] = { #define pick1(enum,cgtype,x86asmtype,name,size) cgtype, #include "cdatatyp.h" @@ -450,11 +452,12 @@ static void GenVaStart( cg_name op1, cg_name offset ) CGDone( name ); } #elif _CPU == _MIPS -/* Similar to Alpha, except we point va_list.__base to the first +static void GenVaStart( cg_name op1, cg_name offset ) +/**************************************************** + * Similar to Alpha, except we point va_list.__base to the first * vararg and va_list.__offset initially to zero. Strictly speaking * we don't need va_list.__offset. */ -static void GenVaStart( cg_name op1, cg_name offset ) { cg_name name; cg_name baseptr; @@ -517,10 +520,12 @@ static cg_name PushSymAddr( OPNODE *node ) name = CGTempName( sym.info.return_var, dtype ); } else { name = CGFEName( (CGSYM_HANDLE)node->u2.sym_handle, dtype ); - // if( (sym.mods & FLAG_VOLATILE) || - // (sym.flags & SYM_USED_IN_PRAGMA) ) { - // name = CGVolatile( name ); - // } +#if 0 + if( (sym.mods & FLAG_VOLATILE) + || (sym.flags & SYM_USED_IN_PRAGMA) ) { + name = CGVolatile( name ); + } +#endif if( sym.flags & SYM_USED_IN_PRAGMA ) { name = CGVolatile( name ); } @@ -541,9 +546,11 @@ static cg_name PushRValue( OPNODE *node, cg_name name ) } name = CGUnary( O_POINTS, name, CGenType( typ ) ); } else { -// if( node->flags & OPFLAG_VOLATILE ) { -// name = CGVolatile( name ); -// } +#if 0 + if( node->flags & OPFLAG_VOLATILE ) { + name = CGVolatile( name ); + } +#endif } return( name ); } @@ -553,8 +560,10 @@ static cg_name DotOperator( cg_name op1, OPNODE *node, cg_name op2 ) TYPEPTR typ; cg_name name; - // node->u2.result_type is the type of the data - // for the O_PLUS we want a pointer type + /* + * node->u2.result_type is the type of the data + * for the O_PLUS we want a pointer type + */ name = CGBinary( O_PLUS, op1, op2, DataPointerType( node ) ); typ = node->u2.result_type; if( typ->decl_type == TYP_FIELD || typ->decl_type == TYP_UFIELD ) { @@ -569,14 +578,18 @@ static cg_name DotOperator( cg_name op1, OPNODE *node, cg_name op2 ) static cg_name ArrowOperator( cg_name op1, OPNODE *node, cg_name op2 ) { - // node->u2.result_type is the type of the data - // for the O_PLUS we want a pointer type + /* + * node->u2.result_type is the type of the data + * for the O_PLUS we want a pointer type + */ #if _CPU == 386 if( Far16Pointer( node->flags ) ) { op1 = CGUnary( O_PTR_TO_NATIVE, op1, TY_POINTER ); } #endif -// rvalue has already been done on left side of tree + /* + * rvalue has already been done on left side of tree + */ // op1 = CGUnary( O_POINTS, op1, DataPointerType( node ) ); return( DotOperator( op1, node, op2 ) ); } @@ -586,10 +599,11 @@ static cg_name IndexOperator( cg_name op1, OPNODE *node, cg_name op2 ) int element_size; cg_type index_type; - // node->u2.result_type is the type of the data - // for the O_PLUS we want a pointer type - // op2 needs to be multiplied by the element size of the array - + /* + * node->u2.result_type is the type of the data + * for the O_PLUS we want a pointer type + * op2 needs to be multiplied by the element size of the array + */ #if _CPU == 386 if( Far16Pointer( node->flags ) ) { op1 = CGUnary( O_PTR_TO_NATIVE, op1, TY_POINTER ); @@ -622,11 +636,13 @@ static cg_name DoAddSub( cg_name op1, OPNODE *node, cg_name op2 ) typ = node->u2.result_type; SKIP_TYPEDEFS( typ ); name = CGBinary( CGOperator[node->opr], op1, op2, CGenType( typ ) ); -// if( typ->decl_type == TYP_POINTER ) { -// if( typ->u.p.decl_flags & FLAG_VOLATILE ) { -// name = CGVolatile( name ); -// } -// } +#if 0 + if( typ->decl_type == TYP_POINTER ) { + if( typ->u.p.decl_flags & FLAG_VOLATILE ) { + name = CGVolatile( name ); + } + } +#endif return( name ); } static cg_name PushConstant( OPNODE *node ) @@ -690,12 +706,16 @@ static cg_name DoIndirection( OPNODE *node, cg_name name ) { TYPEPTR typ; - // check for special kinds of pointers, eg. call __Far16ToFlat + /* + * check for special kinds of pointers, eg. call __Far16ToFlat + */ typ = node->u2.result_type; #if _CPU == 386 if( Far16Pointer( node->flags ) ) { - // Do NOT convert __far16 function pointers to flat because the - // thunk routine expects 16:16 pointers! + /* + * Do NOT convert __far16 function pointers to flat because the + * thunk routine expects 16:16 pointers! + */ if( ( typ->object != NULL ) && ( typ->object->decl_type != TYP_FUNCTION ) ) { name = CGUnary( O_PTR_TO_NATIVE, name, TY_POINTER ); } @@ -912,7 +932,9 @@ static void EmitNodes( TREEPTR tree ) PushCGName( PushRValue( node, op1 ) ); } break; case OPR_COLON: // : - // do nothing, wait for OPR_QUESTION to come along + /* + * do nothing, wait for OPR_QUESTION to come along + */ break; case OPR_OR_OR: // || case OPR_AND_AND: // && @@ -1177,7 +1199,9 @@ static TREEPTR GenOptimizedCode( TREEPTR tree ) unroll_count = tree->op.u1.unroll_count; BEUnrollCount( unroll_count ); } - /* eliminate functions that are always inlined or not used */ + /* + * eliminate functions that are always inlined or not used + */ if( tree->right->op.opr == OPR_FUNCTION ) { // if start of func TREEPTR right; @@ -1207,7 +1231,10 @@ static TREEPTR GenOptimizedCode( TREEPTR tree ) } static void DoInLineFunction( TREEPTR tree ) -{ // Push some state info and use InLineDepth for turning some stuff off +/******************************************* + * Push some state info and use InLineDepth for turning some stuff off + */ +{ struct func_save save; ++InLineDepth; @@ -1267,14 +1294,15 @@ bool IsInLineFunc( SYM_HANDLE sym_handle ) return( ret ); } -/* This function recursively checks if a function is really used and - needs to be emitted. - A function is not inlined and generated if it calls itself recursively, - or if the inline depth goes over the limit. - In that case, and for normal function calls, the function is marked - as FUNC_USED and can't be skipped by the GenOptimizedCode(). -*/ static int ScanFunction( TREEPTR tree, int inline_depth ) +/******************************************************** + * This function recursively checks if a function is really used and + * needs to be emitted. + * A function is not inlined and generated if it calls itself recursively, + * or if the inline depth goes over the limit. + * In that case, and for normal function calls, the function is marked + * as FUNC_USED and can't be skipped by the GenOptimizedCode(). + */ { TREEPTR right; struct func_info *f; @@ -1285,14 +1313,20 @@ static int ScanFunction( TREEPTR tree, int inline_depth ) f = &tree->right->op.u2.func; if( inline_depth == -1 ) { - /* non-recursive call */ + /* + * non-recursive call + */ inline_depth = 0; } else if( (f->flags & FUNC_OK_TO_INLINE) && (f->flags & FUNC_INUSE) == 0 && inline_depth < MAX_INLINE_DEPTH ) { - /* simulate inlining when appropriate */ + /* + * simulate inlining when appropriate + */ inline_depth++; } else { - /* if already examined no need to do it again */ + /* + * if already examined no need to do it again + */ if( f->flags & FUNC_USED ) return 0; f->flags |= FUNC_USED | FUNC_MARKED; @@ -1315,12 +1349,13 @@ static int ScanFunction( TREEPTR tree, int inline_depth ) return( marked ); } -/* This function scans the source file tree for functions. Any non-static - function or static function whose address is taken is scanned for - any functions called, and not inlined. - These functions are marked as used. -*/ static void PruneFunctions( void ) +/********************************* + * This function scans the source file tree for functions. Any non-static + * function or static function whose address is taken is scanned for + * any functions called, and not inlined. + * These functions are marked as used. + */ { TREEPTR tree; SYM_ENTRY sym; @@ -1354,7 +1389,7 @@ static void GenModuleCode( void ) TREEPTR tree; InLineDepth = 0; -// InLineFuncStack = NULL; +// InLineFuncStack = NULL; for( tree = FirstStmt; tree != NULL; tree = tree->left ) { tree = GenOptimizedCode( tree ); } @@ -1461,8 +1496,10 @@ static void EmitSym( SYMPTR sym, SYM_HANDLE sym_handle ) BESetSeg( segid ); AlignIt( typ ); DGLabel( FEBack( (CGSYM_HANDLE)sym_handle ) ); - /* initialize all bytes to 0 */ - /* if size > 64k, have to break it into chunks of 64k */ + /* + * initialize all bytes to 0 + * if size > 64k, have to break it into chunks of 64k + */ size = SizeOfArg( typ ); if( segid == SEG_BSS ) { DGUBytes( size ); @@ -1749,7 +1786,7 @@ static void FreeGblVars( SYM_HANDLE sym_handle ) for( ; sym_handle != SYM_NULL; sym_handle = sym->handle ) { sym = SymGetPtr( sym_handle ); if( sym->info.backinfo != NULL ) { -// BEFiniBack( sym->info.backinfo ); +// BEFiniBack( sym->info.backinfo ); BEFreeBack( sym->info.backinfo ); } } @@ -1800,7 +1837,9 @@ cg_type CGenType( TYPEPTR typ ) case TYP_STRUCT: case TYP_UNION: if( typ->object != NULL ) { - /* structure has a zero length array as last field */ + /* + * structure has a zero length array as last field + */ dtype = NewRefno(); align = GetTypeAlignment( typ ); BEDefType( dtype, align, TypeSize(typ) ); diff --git a/bld/cc/c/cgendata.c b/bld/cc/c/cgendata.c index de35aa5ff7..1a94cdce14 100644 --- a/bld/cc/c/cgendata.c +++ b/bld/cc/c/cgendata.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -179,15 +179,17 @@ static void EmitDQuad( DATA_QUAD *dq ) case QDT_FLOAT: case QDT_FIMAGINARY: -// ftoa( dq->u.double_value, Buffer ); -// DGFloat( Buffer, TY_SINGLE ); +// ftoa( dq->u.double_value, Buffer ); +// DGFloat( Buffer, TY_SINGLE ); { DATA_QUAD local_dq; float float_value; - // dq->u.double_value may not have proper alignment on Alpha - // so copy pieces to local copy on stack which will have - // proper alignment + /* + * dq->u.double_value may not have proper alignment on Alpha + * so copy pieces to local copy on stack which will have + * proper alignment + */ local_dq.u_long_value1 = dq->u_long_value1; local_dq.u_long_value2 = dq->u_long_value2; float_value = (float)local_dq.u.double_value; @@ -197,8 +199,8 @@ static void EmitDQuad( DATA_QUAD *dq ) break; case QDT_DOUBLE: case QDT_DIMAGINARY: -// ftoa( dq->u.double_value, Buffer ); -// DGFloat( Buffer, TY_DOUBLE ); +// ftoa( dq->u.double_value, Buffer ); +// DGFloat( Buffer, TY_DOUBLE ); DGBytes( TARGET_DOUBLE, (char *)&dq->u.double_value ); size += TARGET_DOUBLE; break; diff --git a/bld/cc/c/cgetch.c b/bld/cc/c/cgetch.c index 933e481507..a11f98f29d 100644 --- a/bld/cc/c/cgetch.c +++ b/bld/cc/c/cgetch.c @@ -103,7 +103,6 @@ static bool ReadBuffer( FCB *srcfcb ) } } } - /* * ANSI/ISO C says a non-empty source file must be terminated * with a newline. If it's not, we insert one, otherwise @@ -146,7 +145,7 @@ int GetNextChar( void ) c = *SrcFile->src_ptr++; if(( CharSet[c] & C_EX ) == 0 ) { -// SrcFile->column++; +// SrcFile->column++; CurrChar = c; return( c ); } @@ -157,11 +156,13 @@ static int getCharAfterOneQuestion( void ) { int c; - // column for 'LastChar' has not been set yet + /* + * column for 'LastChar' has not been set yet + */ NextChar = GetNextChar; c = LastChar; if( c == '?' ) { -// SrcFile->column++; +// SrcFile->column++; CurrChar = c; return( c ); } @@ -170,7 +171,7 @@ static int getCharAfterOneQuestion( void ) static int getCharAfterTwoQuestion( void ) { -// SrcFile->column++; +// SrcFile->column++; CurrChar = '?'; NextChar = getCharAfterOneQuestion; return( CurrChar ); @@ -218,7 +219,9 @@ static int getSecondMultiByte( void ) int c; c = getTestCharFromFile(); - // should we do this for a multi-byte char? + /* + * should we do this for a multi-byte char? + */ NextChar = GetNextChar; CurrChar = c; return( c ); @@ -245,7 +248,9 @@ static int tryBackSlashNewLine( void ) { int nc; - // CurrChar is '\\' and SrcFile->column is up to date + /* + * CurrChar is '\\' and SrcFile->column is up to date + */ Blank1Count = 0; Blank2Count = 0; Tab1Count = 0; @@ -281,7 +286,7 @@ static int tryBackSlashNewLine( void ) } NewLineStartPos( SrcFile ); SrcFileLoc = SrcFile->src_loc; -// SrcFile->column = 0; +// SrcFile->column = 0; return( GetNextChar() ); } LastChar = nc; @@ -294,12 +299,12 @@ static int tryTrigraphAgain( void ) int c; int xc; -// SrcFile->column++; +// SrcFile->column++; c = getTestCharFromFile(); if( c != '?' ) { xc = translateTriGraph( c ); if( c != xc ) { -// SrcFile->column += 2; +// SrcFile->column += 2; CurrChar = xc; NextChar = GetNextChar; if( xc == '\\' ) { @@ -313,7 +318,9 @@ static int tryTrigraphAgain( void ) return( '?' ); } CurrChar = c; - /* leave NextChar set here because it could still be a trigraph */ + /* + * leave NextChar set here because it could still be a trigraph + */ return( c ); } @@ -323,7 +330,9 @@ int GetCharCheckFile( int c ) int nc; int nnc; - // column has not being changed for 'c' yet + /* + * column has not being changed for 'c' yet + */ if( c != '?' ) { switch( c ) { case '\0': @@ -344,20 +353,20 @@ int GetCharCheckFile( int c ) return( CurrChar ); case '\n': // NewLineStartPos( SrcFile ); -// SrcFile->column = 0; +// SrcFile->column = 0; break; case '\t': -// SrcFile->column += +// SrcFile->column += // ( ( TAB_WIDTH + 1 ) - (( SrcFile->column + 1 ) % TAB_WIDTH ) ); break; case '\\': -// SrcFile->column++; +// SrcFile->column++; CurrChar = c; return( tryBackSlashNewLine() ); case '\r': break; default: -// SrcFile->column++; +// SrcFile->column++; if( c > 0x7f && (CharSet[c] & C_DB) ) { /* * we should not process the second byte through @@ -371,7 +380,9 @@ int GetCharCheckFile( int c ) CurrChar = c; return( c ); } - /* we have one '?' */ + /* + * we have one '?' + */ // SrcFile->column++; nc = getTestCharFromFile(); if( nc != '?' ) { @@ -380,11 +391,13 @@ int GetCharCheckFile( int c ) NextChar = getCharAfterOneQuestion; return( c ); } - /* we have two '?'s */ + /* + * we have two '?'s + */ nnc = getTestCharFromFile(); xc = translateTriGraph( nnc ); if( nnc != xc ) { -// SrcFile->column += 2; +// SrcFile->column += 2; CurrChar = xc; if( xc == '\\' ) { return( tryBackSlashNewLine() ); @@ -394,7 +407,9 @@ int GetCharCheckFile( int c ) LastChar = nnc; CurrChar = c; if( nnc == '?' ) { - /* the next char after this may be a valid trigraph! */ + /* + * the next char after this may be a valid trigraph! + */ NextChar = tryTrigraphAgain; return( c ); } @@ -406,7 +421,9 @@ static int regetUngotCharAfterOneQuestion( void ) { int c; - // column for 'LastChar' has been set + /* + * column for 'LastChar' has been set + */ NextChar = GetNextChar; c = LastChar; CurrChar = c; @@ -456,26 +473,34 @@ static int restartBackSlashWhiteSpace( void ) void GetNextCharUndo( int c ) { if( NextChar == GetNextChar ) { - // will return 'LastChar' and reset back to 'GetNextChar' + /* + * will return 'LastChar' and reset back to 'GetNextChar' + */ NextChar = regetUngotCharAfterOneQuestion; LastChar = c; return; } if( NextChar == getCharAfterOneQuestion ) { - // LastChar already has character saved in it - // c should be '?' + /* + * LastChar already has character saved in it + * c should be '?' + */ NextChar = restartDetectOneQuestion; return; } if( NextChar == getCharAfterTwoQuestion ) { - // LastChar already has character saved in it - // c should be '?' + /* + * LastChar already has character saved in it + * c should be '?' + */ NextChar = restartDetectTwoQuestion; return; } if( NextChar == getCharAfterBackSlash ) { - // LastChar already has character saved in it - // c should be '\\' + /* + * LastChar already has character saved in it + * c should be '\\' + */ NextChar = restartBackSlashWhiteSpace; return; } @@ -517,7 +542,9 @@ static bool FCB_Alloc( FILE *fp, const char *filename, src_file_type typ ) #endif if( SrcFile != NULL ) { if( SrcFile == MainSrcFile ) { - // remember name of included file + /* + * remember name of included file + */ AddIncFileList( filename ); } } @@ -546,8 +573,10 @@ bool OpenFCB( FILE *fp, const char *filename, src_file_type typ ) return( false ); } if( CompFlags.track_includes ) { - // Don't track the top level file (any semi-intelligent user should - // have no trouble tracking *that* down) + /* + * Don't track the top level file (any semi-intelligent user should + * have no trouble tracking *that* down) + */ if( IncFileDepth < MAX_INC_DEPTH ) { CInfoMsg( INFO_INCLUDING_FILE, filename ); } @@ -579,7 +608,9 @@ void CloseFCB( FCB *srcfcb ) CurrChar = srcfcb->prev_currchar; if( SrcFile != NULL ) { if( SrcFile->src_fp == NULL ) { - // physical file name must be used, not logical + /* + * physical file name must be used, not logical + */ SrcFile->src_fp = fopen( SrcFile->src_flist->name, "rb" ); fseek( SrcFile->src_fp, SrcFile->rseekpos, SEEK_SET ); } diff --git a/bld/cc/c/cinfo.c b/bld/cc/c/cinfo.c index 0554d617ad..38b45af823 100644 --- a/bld/cc/c/cinfo.c +++ b/bld/cc/c/cinfo.c @@ -116,7 +116,9 @@ void AssignSeg( SYMPTR sym ) if( (sym->attribs.stg_class == SC_AUTO) || (sym->attribs.stg_class == SC_REGISTER) || (sym->attribs.stg_class == SC_TYPEDEF) ) { - /* if stack/register var, there is no segment */ + /* + * if stack/register var, there is no segment + */ sym->u.var.segid = SEG_NULL; } else if( sym->attribs.stg_class != SC_EXTERN ) { /* if not imported */ if( (sym->flags & SYM_INITIALIZED) == 0 ) { @@ -429,7 +431,9 @@ static segment_id AddSeg( const char *segname, const char *class_name, int segty p1 = SkipUnderscorePrefix( segname ); if( p1 == NULL ) { - /* error missing underscore prefix */ + /* + * error missing underscore prefix + */ PragRegNameErr( segname ); p1 = segname; } @@ -530,9 +534,13 @@ char *SegClassName( segment_id segid ) } for( tseg = TextSegList; tseg != NULL; tseg = tseg->next ) { if( tseg->segid == segid ) { - // class name appears after the segment name + /* + * class name appears after the segment name + */ classname = tseg->segname + tseg->class; - // if class name not specified, then use the default + /* + * if class name not specified, then use the default + */ if( *classname == '\0' ) classname = CodeClassName; return( classname ); @@ -645,9 +653,11 @@ void SetSegs( void ) for( useg = userSegments; useg != NULL ; useg = useg->next ) { segid = useg->segid; switch( useg->segtype ) { -// case SEGTYPE_CODE: -// BEDefSeg( segid, INIT | GLOBAL | EXEC, useg->name, 1 ); -// break; +#if 0 + case SEGTYPE_CODE: + BEDefSeg( segid, INIT | GLOBAL | EXEC, useg->name, 1 ); + break; +#endif case SEGTYPE_DATA: /* created through #pragma data_seg */ BEDefSeg( segid, INIT | GLOBAL, useg->name, SegAlign( TARGET_INT ) ); break; @@ -785,7 +795,9 @@ void FEMessage( int class, CGPOINTER parm ) MyExit( 1 ); /* exit to DOS do not pass GO */ break; case MSG_BAD_PARM_REGISTER: - /* this will be issued after a call to CGInitCall or CGProcDecl */ + /* + * this will be issued after a call to CGInitCall or CGProcDecl + */ CErr2( ERR_BAD_PARM_REGISTER, (int)(pointer_uint)parm ); break; case MSG_BAD_RETURN_REGISTER: @@ -862,7 +874,8 @@ segment_id FESegID( CGSYM_HANDLE cgsym_handle ) attr = FESymAttr( sym ); if( attr & FE_PROC ) { - /* in large code models, should return different segment # + /* + * in large code models, should return different segment # * for every imported routine. */ segid = SEG_CODE; diff --git a/bld/cc/c/cmac1.c b/bld/cc/c/cmac1.c index 329830141b..928e31d014 100644 --- a/bld/cc/c/cmac1.c +++ b/bld/cc/c/cmac1.c @@ -180,7 +180,9 @@ void MacroInit( void ) for( i = MACRO_FIRST; i <= MACRO_LAST; i++ ) { SpecialMacroAdd( &SpcMacros[i] ); } - /* grab time and date for __TIME__ and __DATE__ */ + /* + * grab time and date for __TIME__ and __DATE__ + */ TimeInit(); } @@ -265,7 +267,9 @@ TOKEN GetMacroToken( void ) token = T_NULL; Buffer[0] = '\0'; } else { - /* size of Buffer is OK, token data was processed in Buffer before */ + /* + * size of Buffer is OK, token data was processed in Buffer before + */ while( (Buffer[TokenLen] = mtok->data[TokenLen]) != '\0' ) { TokenLen++; } @@ -304,8 +308,10 @@ TOKEN GetMacroToken( void ) tbeg = mtok->data; tcur = ReScanPos(); - // ppnumber is quite general so it may absorb multiple tokens - // overlapping src & dst so do our own copy; + /* + * ppnumber is quite general so it may absorb multiple tokens + * overlapping src & dst so do our own copy; + */ for( ; (*tbeg = *tcur) != '\0'; ) { ++tcur; ++tbeg; @@ -329,9 +335,10 @@ TOKEN GetMacroToken( void ) return( token ); } -/* returns Dynamically allocated buffer with expanded macro */ static char *ExpandMacroToken( void ) -/***********************************/ +/************************************ + * returns Dynamically allocated buffer with expanded macro + */ { size_t i; size_t len; @@ -500,7 +507,9 @@ static MACRO_ARG *CollectParms( MEPTR mentry ) do { token = NextMToken(); } while( token == T_WHITE_SPACE ); - /* token will now be a '(' */ + /* + * token will now be a '(' + */ bracket = 0; token_head = NULL; len = 0; @@ -786,7 +795,9 @@ static char *GlueTokenToBuffer( MACRO_TOKEN *first, char *gluebuf ) if( buf == NULL ) { buf = gluebuf; } else if( gluebuf != NULL ) { - /* now do a "strcat( gluebuf, buf )" */ + /* + * now do a "strcat( gluebuf, buf )" + */ gluelen = strlen( gluebuf ); tokenlen = strlen( buf ); gluebuf = CMemRealloc( gluebuf, gluelen + tokenlen + 1 ); @@ -848,18 +859,24 @@ static MACRO_TOKEN *GlueTokens( MACRO_TOKEN *head ) next = next->next; pos = 0; - // glue mtok->token with next->token to make one token + /* + * glue mtok->token with next->token to make one token + */ if( ( mtok->token == T_COMMA && next->token == T_MACRO_EMPTY_VAR_PARM ) || ( mtok->token == T_MACRO_EMPTY_VAR_PARM && next->token == T_COMMA ) ) { - // delete [mtoken(a comma),##,empty __VA_ARGS__] - // delete [empty __VA_ARGS__,##,mtoken(a comma)] + /* + * delete [mtoken(a comma),##,empty __VA_ARGS__] + * delete [empty __VA_ARGS__,##,mtoken(a comma)] + */ buf[10] = '\0'; pos = -1; } else { if( mtok->token == T_MACRO_EMPTY_VAR_PARM ) { - // well should never be in this state if no next - since ## cannot - // appear at the end of a macro + /* + * well should never be in this state if no next - since ## cannot + * appear at the end of a macro + */ gluebuf = GlueTokenToBuffer( next, NULL ); } else { gluebuf = GlueTokenToBuffer( mtok, NULL ); @@ -884,7 +901,9 @@ static MACRO_TOKEN *GlueTokens( MACRO_TOKEN *head ) mtok = ReTokenBuffer( gluebuf ); CMemFree( gluebuf ); } else { - /* Both ends of ## were empty */ + /* + * Both ends of ## were empty + */ mtok = BuildAToken( T_NULL, "P-" ); } *ptail = mtok; // link in new mtok to mtok's link @@ -896,8 +915,10 @@ static MACRO_TOKEN *GlueTokens( MACRO_TOKEN *head ) return( head ); } } - // mtok == last token of retokenizing - // ptail == the pointer which references mtok + /* + * mtok == last token of retokenizing + * ptail == the pointer which references mtok + */ mtok->next = rem; } else { if( prev_ptail != NULL ) { @@ -1038,7 +1059,9 @@ static MACRO_TOKEN *BuildMTokenList( const char *p, MACRO_ARG *macro_parms ) MTOKINC( p ); } MTOKINC( p ); // skip over T_MACRO_PARM - // If no macro arg given, result must be "", not empty + /* + * If no macro arg given, result must be "", not empty + */ parmno = MTOKPARM( p ); MTOKPARMINC( p ); if( macro_parms != NULL && macro_parms[parmno].arg != NULL && macro_parms[parmno].arg[0] != '\0' ) { @@ -1057,7 +1080,9 @@ static MACRO_TOKEN *BuildMTokenList( const char *p, MACRO_ARG *macro_parms ) nested->substituting_parms = true; if( macro_parms != NULL ) { mtok = BuildMTokenList( macro_parms[parmno].arg, NULL ); - /* NB: mtok is now NULL if macro arg was empty */ + /* + * NB: mtok is now NULL if macro arg was empty + */ } else { mtok = BuildAToken( T_WHITE_SPACE, "" ); } @@ -1128,8 +1153,10 @@ static void markUnexpandableIds( MACRO_TOKEN *head ) for( nested = NestedMacros; nested != NULL; nested = nested->next ) { if( strcmp( nested->mentry->macro_name, mtok->data ) == 0 ) { if( !nested->substituting_parms ) { - // change token so it won't be considered a - // candidate as a macro + /* + * change token so it won't be considered a + * candidate as a macro + */ mtok->token = T_UNEXPANDABLE_ID; break; } @@ -1185,15 +1212,19 @@ static MACRO_TOKEN *ExpandNestedMacros( MACRO_TOKEN *head, bool rescanning ) for( ; mtok != NULL; ) { toklist = NULL; if( mtok->token == T_ID ) { - // if macro and not being expanded, then expand it - // only tokens available for expansion are those in mtok list + /* + * if macro and not being expanded, then expand it + * only tokens available for expansion are those in mtok list + */ buf = Buffer; len = 0; while( (buf[len] = mtok->data[len]) != '\0' ) len++; mentry = MacroLookup( buf ); if( mentry != NULL ) { - /* this is a macro */ + /* + * this is a macro + */ if( rescanning ) { if( MacroBeingExpanded( mentry ) ) { mtok->token = T_UNEXPANDABLE_ID; @@ -1294,7 +1325,9 @@ static MACRO_TOKEN *ExpandNestedMacros( MACRO_TOKEN *head, bool rescanning ) mtok = prev_tok->next; } } else { - // either no change, or tokens were deleted + /* + * either no change, or tokens were deleted + */ if( prev_tok == NULL ) { head = mtok; } else { @@ -1303,8 +1336,10 @@ static MACRO_TOKEN *ExpandNestedMacros( MACRO_TOKEN *head, bool rescanning ) } } for( mtok = head; mtok != NULL; mtok = mtok->next ) { - // change a temporarily unexpandable ID into an ID because it - // could become expandable in a later rescanning phase + /* + * change a temporarily unexpandable ID into an ID because it + * could become expandable in a later rescanning phase + */ if( mtok->token == T_MACRO ) { mtok->token = T_ID; } @@ -1318,8 +1353,10 @@ void DoMacroExpansion( MEPTR mentry ) // called from cscan { MacroDepth = 0; TokenList = ExpandNestedMacros( MacroExpansion( false, mentry ), true ); - // GetMacroToken will feed back tokens from the TokenList - // when the TokenList is exhausted, then revert back to normal scanning + /* + * GetMacroToken will feed back tokens from the TokenList + * when the TokenList is exhausted, then revert back to normal scanning + */ if( TokenList == NULL ) { MacroPtr = NULL; } else { diff --git a/bld/cc/c/cmac2.c b/bld/cc/c/cmac2.c index a38df595fd..22e0287ee4 100644 --- a/bld/cc/c/cmac2.c +++ b/bld/cc/c/cmac2.c @@ -71,8 +71,8 @@ struct preproc { }; static unsigned char PreProcWeights[] = { -//a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z - 2, 0, 0, 9, 1, 4, 3, 0, 5, 0, 0, 7, 0, 0, 0,10, 0,11, 0,13,12, 0,14 +/* a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z */ + 2, 0, 0, 9, 1, 4, 3, 0, 5, 0, 0, 7, 0, 0, 0,10, 0,11, 0,13,12, 0,14 }; static struct preproc PreProcTable[] = { @@ -252,9 +252,11 @@ TOKEN ChkControl( void ) } } } - // we have already skipped past all white space at the start of the line + /* + * we have already skipped past all white space at the start of the line + */ token = T_WHITE_SPACE; -// token = ScanToken(); +// token = ScanToken(); return( token ); } @@ -413,7 +415,9 @@ MEPTR MacroScan( void ) } } } - /* grab replacement tokens */ + /* + * grab replacement tokens + */ ppscan_mode = InitPPScan(); // enable T_PPNUMBER tokens mentry = GrabTokens( parm_count, mflags, formal_parms, token_buf, ¯o_loc ); FiniPPScan( ppscan_mode ); // disable T_PPNUMBER tokens @@ -464,7 +468,9 @@ static MEPTR GrabTokens( mac_parm_count parm_count, macro_flags mflags, MPPTR fo for( ; CurToken != T_NULL && CurToken != T_EOF ; ) { switch( CurToken ) { case T_SHARP: - /* if it is a function-like macro definition */ + /* + * if it is a function-like macro definition + */ if( parm_count != 0 ) { CurToken = T_MACRO_SHARP; } @@ -635,7 +641,9 @@ static void CElif( void ) CppStack->processing = false; CppStack->cpp_type = PRE_ELIF; } else if( SkipLevel + 1 == NestLevel ) { - /* only evaluate the expression when required */ + /* + * only evaluate the expression when required + */ if( CppStack->cpp_type == PRE_IF ) { value = PpConstExpr(); ChkEOL(); @@ -661,7 +669,9 @@ static void CElse( void ) --SkipLevel; /* start skipping else part */ CppStack->processing = false; } else if( SkipLevel + 1 == NestLevel ) { - /* cpp_type will be PRE_ELIF if an elif was true */ + /* + * cpp_type will be PRE_ELIF if an elif was true + */ if( CppStack->cpp_type == PRE_IF ) { SkipLevel = NestLevel; /* start including else part */ CppStack->processing = true; @@ -726,7 +736,9 @@ bool MacroDel( const char *name ) MacHash[hash] = mentry->next_macro; } if( (InitialMacroFlags & MFLAG_DEFINED_BEFORE_FIRST_INCLUDE) == 0 ) { - /* remember macros that were defined before first include */ + /* + * remember macros that were defined before first include + */ if( mentry->macro_flags & MFLAG_DEFINED_BEFORE_FIRST_INCLUDE ) { mentry->next_macro = UndefMacroList; UndefMacroList = mentry; @@ -774,11 +786,13 @@ static void CLine( void ) } else { if( ExpectingToken( T_STRING ) ) { if( CompFlags.wide_char_string ) { - /* wide char string not allowed */ + /* + * wide char string not allowed + */ ExpectString(); } else { if( !CompFlags.cpp_ignore_line ) { - // RemoveEscapes( Buffer ); +// RemoveEscapes( Buffer ); flist = AddFlist( Buffer ); flist->rwflag = false; // not a real file so no autodep SrcFile->src_name = flist->name; @@ -811,7 +825,9 @@ static void get_arg_message( void ) static void CError( void ) { get_arg_message(); - /* Force #error output to be reported, even with preprocessor */ + /* + * Force #error output to be reported, even with preprocessor + */ CErr2p( ERR_USER_ERROR_MSG, Buffer ); } @@ -820,7 +836,9 @@ static void CWarning( void ) { if( CompFlags.extensions_enabled || CompVars.cstd >= CSTD_C23 ) { get_arg_message(); - /* Force #error output to be reported, even with preprocessor */ + /* + * Force #error output to be reported, even with preprocessor + */ CWarn2p( ERR_USER_WARNING_MSG, Buffer ); } else { CUnknown(); @@ -881,18 +899,24 @@ TOKEN Process_Pragma( void ) stringize( token_buf ); InsertReScanPragmaTokens( token_buf ); - // call CPragma() + /* + * call CPragma() + */ old_ppctl = PPControl; PPCTL_ENABLE_EOL(); CPragma(); PPControl = old_ppctl; } else { - /* error, incorrect syntax of the operator _Pragma() */ + /* + * error, incorrect syntax of the operator _Pragma() + */ } CMemFree( token_buf ); PPNextToken(); } else { - /* error, incorrect syntax of the operator _Pragma() */ + /* + * error, incorrect syntax of the operator _Pragma() + */ } } else { InsertToken( CurToken, Buffer ); diff --git a/bld/cc/c/cmath.c b/bld/cc/c/cmath.c index 7f4e5b7ff7..6d474a1642 100644 --- a/bld/cc/c/cmath.c +++ b/bld/cc/c/cmath.c @@ -63,24 +63,36 @@ #define ERR TYP_ERROR /* no real type behind this value */ -/* define macros for promoted types */ +/* + * define macros for promoted types + */ #if TARGET_INT == 4 - /* Promoted Unsigned Short is Signed Int */ + /* + * Promoted Unsigned Short is Signed Int + */ #define PUS TYP_INT - /* Promoted Unsigned Int is Unsigned Long */ + /* + * Promoted Unsigned Int is Unsigned Long + */ #define PUI TYP_ULONG #else /* 16-bit ints */ - /* Promoted Unsigned Short is Unsigned Int */ + /* + * Promoted Unsigned Short is Unsigned Int + */ #define PUS TYP_UINT - /* Promoted Unsigned Int is Signed Long */ + /* + * Promoted Unsigned Int is Signed Long + */ #define PUI TYP_LONG #endif -/* matches enum DATA_TYPE in ctypes.h */ +/* + * matches enum DATA_TYPE in ctypes.h + */ static const unsigned char AddResult[DATA_TYPE_SIZE][DATA_TYPE_SIZE] = { /* + BOL,CHR,UCH,SHT,USH,INT,UIN,LNG,ULN,LN8,UL8,FLT,DBL,LDB,FIM,DIM,LIM,PTR,ARR,STC,UNI,FNC,FLD,VOD,ENM,TDF,UFD,...,PCH,WCH,FCX,DCX,LCX, */ /* BOL */ { INT,INT,INT,INT,PUS,INT,UIN,LNG,ULN,LN8,UL8,FLT,DBL,LDB,FCX,DCX,LCX,PTR,ERR,ERR,ERR,ERR,ERR,ERR,ERR,ERR,ERR,ERR,ERR,ERR,FCX,DCX,LCX, }, @@ -118,7 +130,9 @@ static const unsigned char AddResult[DATA_TYPE_SIZE][DATA_TYPE_SIZE] = { /* LCX */ { LCX,LCX,LCX,LCX,LCX,LCX,LCX,LCX,LCX,LCX,LCX,LCX,LCX,LCX,LCX,LCX,LCX,ERR,ERR,ERR,ERR,ERR,ERR,ERR,ERR,ERR,ERR,ERR,ERR,ERR,LCX,LCX,LCX, }, }; -/* matches enum DATA_TYPE in ctypes.h */ +/* + * matches enum DATA_TYPE in ctypes.h + */ static const unsigned char SubResult[DATA_TYPE_SIZE][DATA_TYPE_SIZE] = { /* + BOL,CHR,UCH,SHT,USH,INT,UIN,LNG,ULN,LN8,UL8,FLT,DBL,LDB,FIM,DIM,LIM,PTR,ARR,STC,UNI,FNC,FLD,VOD,ENM,TDF,UFD,...,PCH,WCH,FCX,DCX,LCX, */ /* BOL */ { INT,INT,INT,INT,PUS,INT,UIN,LNG,ULN,LN8,UL8,FLT,DBL,LDB,FCX,DCX,LCX,PTR,ERR,ERR,ERR,ERR,ERR,ERR,ERR,ERR,ERR,ERR,ERR,ERR,FCX,DCX,LCX, }, @@ -156,7 +170,9 @@ static const unsigned char SubResult[DATA_TYPE_SIZE][DATA_TYPE_SIZE] = { /* LCX */ { LCX,LCX,LCX,LCX,LCX,LCX,LCX,LCX,LCX,LCX,LCX,LCX,LCX,LCX,LCX,LCX,LCX,ERR,ERR,ERR,ERR,ERR,ERR,ERR,ERR,ERR,ERR,ERR,ERR,ERR,LCX,LCX,LCX, }, }; -/* matches enum DATA_TYPE in ctypes.h */ +/* + * matches enum DATA_TYPE in ctypes.h + */ static const unsigned char IntResult[DATA_TYPE_SIZE][DATA_TYPE_SIZE] = { /* + BOL,CHR,UCH,SHT,USH,INT,UIN,LNG,ULN,LN8,UL8,FLT,DBL,LDB,FIM,DIM,LIM,PTR,ARR,STC,UNI,FNC,FLD,VOD,ENM,TDF,UFD,...,PCH,WCH,FCX,DCX,LCX, */ /* BOL */ { INT,INT,INT,INT,PUS,INT,UIN,LNG,ULN,LN8,UL8,ERR,ERR,ERR,ERR,ERR,ERR,ERR,ERR,ERR,ERR,ERR,ERR,ERR,ERR,ERR,ERR,ERR,ERR,ERR,ERR,ERR,ERR, }, @@ -194,7 +210,9 @@ static const unsigned char IntResult[DATA_TYPE_SIZE][DATA_TYPE_SIZE] = { /* LCX */ { ERR,ERR,ERR,ERR,ERR,ERR,ERR,ERR,ERR,ERR,ERR,ERR,ERR,ERR,ERR,ERR,ERR,ERR,ERR,ERR,ERR,ERR,ERR,ERR,ERR,ERR,ERR,ERR,ERR,ERR,ERR,ERR,ERR, }, }; -/* matches enum DATA_TYPE in ctypes.h */ +/* + * matches enum DATA_TYPE in ctypes.h + */ static char ShiftResult[DATA_TYPE_SIZE] = { /* >> op2 */ /* BOL */ INT, @@ -232,7 +250,9 @@ static char ShiftResult[DATA_TYPE_SIZE] = { /* LCX */ ERR, }; -/* matches enum DATA_TYPE in ctypes.h */ +/* + * matches enum DATA_TYPE in ctypes.h + */ static const unsigned char BinResult[DATA_TYPE_SIZE][DATA_TYPE_SIZE] = { /* + BOL,CHR,UCH,SHT,USH,INT,UIN,LNG,ULN,LN8,UL8,FLT,DBL,LDB,FIM,DIM,LIM,PTR,ARR,STC,UNI,FNC,FLD,VOD,ENM,TDF,UFD,...,PCH,WCH,FCX,DCX,LCX, */ /* BOL */ { BOL,INT,UCH,INT,PUS,INT,UIN,LNG,ULN,LN8,UL8,FLT,DBL,LDB,ERR,ERR,ERR,ERR,ERR,ERR,ERR,ERR,ERR,ERR,ERR,ERR,ERR,ERR,ERR,ERR,ERR,ERR,ERR, }, @@ -368,8 +388,10 @@ enum conv_types { #define T2F CER #define T2D CER -/* matches enum DATA_TYPE in ctypes.h */ -/* When indexing, row is the source type, column is the target. */ +/* + * matches enum DATA_TYPE in ctypes.h + * When indexing, row is the source type, column is the target. + */ static enum conv_types const CnvTable[DATA_TYPE_SIZE][DATA_TYPE_SIZE] = { /* BOL,CHR,UCH,SHT,USH,INT,UIN,LNG,ULN,LN8,UL8,FLT,DBL,LDB,FIM,DIM,LIM,PTR,ARR,STC,UNI,FNC,FLD,VOD,ENM,TDF,UFD,...,PCH,WCH,FCX,DCX,LCX, */ /* BOL */ { NIL,B2S,B2S,B2S,B2S,B2S,B2S,B2S,B2S,B2S,B2S,B2S,B2S,B2S,B2S,B2S,B2S,A2P,CER,CER,CER,CER,CER,CER,CER,CER,CER,CER,CER,CER,CER,CER,CER, }, @@ -462,21 +484,22 @@ DATA_TYPE DataTypeOf( TYPEPTR typ ) return( data_type ); } -// 0 - near data -// 1 - based data -// 2 - far data -// 3 - far16 data -// 4 - huge data -// 5 - interrupt -// 6 - near func -// 7 - based func -// 8 - far func -// 9 - far16 func -// 10 - huge func -// 11 - interrupt func -// 12 - NOT - static pointer_class PointerClass( TYPEPTR typ ) +/*********************************************** + * 0 - near data + * 1 - based data + * 2 - far data + * 3 - far16 data + * 4 - huge data + * 5 - interrupt + * 6 - near func + * 7 - based func + * 8 - far func + * 9 - far16 func + * 10 - huge func + * 11 - interrupt func + * 12 - NOT + */ { type_modifiers flags; pointer_class ptrclass; @@ -529,8 +552,10 @@ pointer_class ExprTypeClass( TYPEPTR typ ) #define Convert( opnd, opnd_type, result_type ) opnd -// return 0 not a num, else number of bits | SIGN_BIT if signed static int NumSize( DATA_TYPE op_type ) +/************************************** + * return 0 not a num, else number of bits | SIGN_BIT if signed + */ { int size; @@ -578,8 +603,10 @@ static int NumSize( DATA_TYPE op_type ) return( size ); } -// return 0 not a num, else number of bits | SIGN_BIT if signed static int NumSizeType( TYPEPTR typ ) +/************************************ + * return 0 not a num, else number of bits | SIGN_BIT if signed + */ { int size; @@ -657,7 +684,9 @@ static cmp_result IsMeaninglessCompare( signed_64 val, TYPEPTR typ_op1, TYPEPTR } } else { if( rel == REL_LE && !rev_ret && !NumSign( op1_size ) && U64Test( &val ) == 0 ) { - // special case for unsigned <= 0 + /* + * special case for unsigned <= 0 + */ ret = CMP_COMPLEX; } } @@ -666,7 +695,7 @@ static cmp_result IsMeaninglessCompare( signed_64 val, TYPEPTR typ_op1, TYPEPTR static int ReverseRelOp( int opr ) -/* +/********************************* * map opr to reversed operand equivalent */ { @@ -713,9 +742,13 @@ static TREEPTR BaseConv( TYPEPTR typ1, TREEPTR op2 ) type_modifiers typ1_flags, typ2_flags; typ2 = op2->u.expr_type; - // skip typedefs, go into enum base + /* + * skip typedefs, go into enum base + */ typ1 = SkipTypeFluff( typ1 ); - // skip typedefs, go into enum base + /* + * skip typedefs, go into enum base + */ typ2 = SkipTypeFluff( typ2 ); typ1_flags = typ1->u.p.decl_flags; typ2_flags = typ2->u.p.decl_flags; @@ -739,10 +772,12 @@ static TREEPTR BaseConv( TYPEPTR typ1, TREEPTR op2 ) } #endif } else if( typ2->decl_type == TYP_POINTER ) { - // If we're converting a based pointer to some larger arithmetic type, - // we must convert it to a long pointer first to get proper segment. - // However, in flat model this conversion isn't done, we pretend - // that segments don't exist. + /* + * If we're converting a based pointer to some larger arithmetic type, + * we must convert it to a long pointer first to get proper segment. + * However, in flat model this conversion isn't done, we pretend + * that segments don't exist. + */ if( TypeSize( typ1 ) > TypeSize( typ2 ) ) { #if _CPU == 386 if( (TargetSwitches & CGSW_X86_FLAT_MODEL) == 0 && (typ2_flags & FLAG_BASED) ) { @@ -754,8 +789,10 @@ static TREEPTR BaseConv( TYPEPTR typ1, TREEPTR op2 ) } } } else if( typ1->decl_type == TYP_POINTER ) { - // If we're converting an arithmetic type to a pointer, first convert - // it to appropriately sized integer to correctly extend/truncate. + /* + * If we're converting an arithmetic type to a pointer, first convert + * it to appropriately sized integer to correctly extend/truncate. + */ if( TypeSize( typ1 ) != TypeSize( typ2 ) ) { op2 = CnvOp( op2, GetIntTypeBySize( TypeSize( typ1 ), false, false ), true ); } @@ -764,14 +801,17 @@ static TREEPTR BaseConv( TYPEPTR typ1, TREEPTR op2 ) } -/* Convert a scalar to boolean */ static TREEPTR BoolConv( TYPEPTR typ, TREEPTR tree ) +/*************************************************** + * Convert a scalar to boolean + */ { if( tree->op.opr == OPR_ERROR ) { return( ErrorNode( tree ) ); } SKIP_TYPEDEFS( typ ); - /* Non-boolean types need to be converted to _Bool; _Bool expressions + /* + * Non-boolean types need to be converted to _Bool; _Bool expressions * also need to be converted unless they're constants. */ if( DataTypeOf( typ ) == TYP_BOOL && TypeOf( tree ) != typ ) { @@ -785,11 +825,11 @@ static TREEPTR BoolConv( TYPEPTR typ, TREEPTR tree ) } -/* +static bool IsInt( DATA_TYPE op ) +/******************************** * what's target compatible between default int as ret type * and a later declaration */ -static bool IsInt( DATA_TYPE op ) { bool ret; @@ -845,9 +885,10 @@ TREEPTR RelOp( TREEPTR op1, TOKEN opr, TREEPTR op2 ) op2_type = DataTypeOf( typ2 ); cmp_type = typ1; result_type = op1_type; - - /* check for meaningless comparison: */ - //TODO this would be a better check maybe in foldtree + /* + * check for meaningless comparison: + * TODO this would be a better check maybe in foldtree + */ if( IS_PPCTL_NORMAL() ) { cmp_cc = CMP_VOID; if( op2->op.opr == OPR_PUSHINT ) { @@ -870,12 +911,16 @@ TREEPTR RelOp( TREEPTR op1, TOKEN opr, TREEPTR op2 ) } else if( op1_type == TYP_POINTER && op2_type == TYP_POINTER ) { CompatiblePtrType( typ1, typ2, opr ); if( TypeSize( typ2 ) > TypeSize( typ1 ) ) { - /* Make sure near pointer is converted to far if necessary */ + /* + * Make sure near pointer is converted to far if necessary + */ cmp_type = typ2; } } else if( (op1_type == TYP_POINTER && IsInt( op2_type )) || (op2_type == TYP_POINTER && IsInt( op1_type )) ) { - /* ok to compare pointer with constant 0 */ + /* + * ok to compare pointer with constant 0 + */ if( opr != T_EQ && opr != T_NE ) { CWarn1( ERR_POINTER_TYPE_MISMATCH ); } else if( !IsZero( op1 ) && !IsZero( op2 ) ) { @@ -1032,8 +1077,10 @@ static TREEPTR PtrSubtract( TREEPTR result, target_ssize size, DATA_TYPE result_ } -// Remove the OPR_CONVERT for lcast so it looks like an LVALUE extern TREEPTR LCastAdj( TREEPTR tree ) +/************************************** + * Remove the OPR_CONVERT for lcast so it looks like an LVALUE + */ { TREEPTR opnd; TYPEPTR typ; @@ -1049,7 +1096,9 @@ extern TREEPTR LCastAdj( TREEPTR tree ) if( opnd->op.opr == OPR_PUSHSYM ) { opnd->op.opr = OPR_PUSHADDR; } else if( opnd->op.opr == OPR_POINTS ) { - // fix up fred's screw ball pointer op + /* + * fix up fred's screw ball pointer op + */ modifiers = FlagOps( opnd->op.flags ); opnd->op.u2.result_type = PtrNode( typ, modifiers, SEG_DATA ); } @@ -1218,7 +1267,9 @@ TREEPTR AddOp( TREEPTR op1, TOKEN opr, TREEPTR op2 ) default: result_type = SubResult[op1_type][op2_type]; if(( op1_type == PTR )&&( op2_type == PTR )) { - /* make sure both pointers are same type */ + /* + * make sure both pointers are same type + */ CompatiblePtrType( op1_tp, op2_tp, opr ); #if _INTEL_CPU if(( op1_tp->u.p.decl_flags & FLAG_HUGE ) || @@ -1245,12 +1296,16 @@ TREEPTR AddOp( TREEPTR op1, TOKEN opr, TREEPTR op2 ) CErr1( ERR_CANT_USE_VOID ); size = 1; } - /* subtraction of 2 pointers */ + /* + * subtraction of 2 pointers + */ if( (result_type == INT) || (result_type == LNG) ) { res_type = GetType( result_type ); } if( size != 1 ) { - /* subtraction of 2 pointers */ + /* + * subtraction of 2 pointers + */ if( (result_type == INT) || (result_type == LNG) ) { result = ExprNode( op1, TokenToOperator( opr ), op2 ); return( PtrSubtract( result, size, result_type ) ); @@ -1336,14 +1391,18 @@ TREEPTR BinOp( TREEPTR op1, TOKEN opr, TREEPTR op2 ) switch( opr ) { case T_XOR_EQUAL: case T_OR_EQUAL: - /* if op2 is a constant, check to see if constant truncated */ + /* + * if op2 is a constant, check to see if constant truncated + */ AssRangeChk( typ, op2 ); /* fall through */ case T_AND_EQUAL: case T_RSHIFT_EQUAL: case T_LSHIFT_EQUAL: case T_PERCENT_EQUAL: - /* check for integral operand. */ + /* + * check for integral operand. + */ result_type = IntResult[op1_type][op2_type]; if( result_type == ERR ) { CErr1( ERR_EXPR_MUST_BE_INTEGRAL ); @@ -1457,7 +1516,9 @@ TREEPTR AsgnOp( TREEPTR op1, TOKEN opr, TREEPTR op2 ) op2_ptrclass = ExprTypeClass( op2->u.expr_type ); if( op1_ptrclass != op2_ptrclass ) { if( FAR16_PTRCLASS( op1_ptrclass ) || FAR16_PTRCLASS( op2_ptrclass ) ) { - // if far16 pointer + /* + * if far16 pointer + */ op2 = ExprNode( NULL, OPR_CONVERT_PTR, op2 ); op2->op.u2.sp.old_ptrclass = op2_ptrclass; op2->op.u2.sp.new_ptrclass = op1_ptrclass; @@ -1581,14 +1642,15 @@ bool IsFuncPtr( TYPEPTR typ ) return( true ); } -/* Check if pointer conversion is losing high (segment) bits. +bool IsPtrConvSafe( TREEPTR src, TYPEPTR newtyp, TYPEPTR oldtyp ) +/**************************************************************** + * Check if pointer conversion is losing high (segment) bits. * A special dispensation is made for null pointer conversions; if the * source operand is a zero integer constant, chopping off high bits * is not considered an error. This helps in Win16 programming where * NULL (which may be a 32-bit quantity) is often converted to * a 16-bit HANDLE type. */ -bool IsPtrConvSafe( TREEPTR src, TYPEPTR newtyp, TYPEPTR oldtyp ) { bool is_safe = true; segment_id new_segid; @@ -1600,11 +1662,14 @@ bool IsPtrConvSafe( TREEPTR src, TYPEPTR newtyp, TYPEPTR oldtyp ) SKIP_TYPEDEFS( newtyp ); assert( oldtyp->decl_type == TYP_POINTER ); assert( newtyp->decl_type == TYP_POINTER ); - - /* If new type isn't smaller than old, assume conversion is safe. */ + /* + * If new type isn't smaller than old, assume conversion is safe. + */ if( TypeSize( newtyp ) < TypeSize( oldtyp ) ) { is_safe = IsZero( src ); - /* Determine target pointer base. */ + /* + * Determine target pointer base. + */ new_flags = newtyp->u.p.decl_flags; old_flags = oldtyp->u.p.decl_flags; if( (new_flags & FLAG_BASED) || (old_flags & FLAG_BASED) ) { @@ -1613,7 +1678,9 @@ bool IsPtrConvSafe( TREEPTR src, TYPEPTR newtyp, TYPEPTR oldtyp ) case BASED_SEGNAME: new_segid = newtyp->u.p.segid; break; - /* NYI: This could be smarter and check other based types. */ + /* + * NYI: This could be smarter and check other based types. + */ default: new_segid = SEG_NULL; } @@ -1622,14 +1689,18 @@ bool IsPtrConvSafe( TREEPTR src, TYPEPTR newtyp, TYPEPTR oldtyp ) } else { new_segid = SEG_DATA; } - /* Determine source pointer base. */ + /* + * Determine source pointer base. + */ old_flags = oldtyp->u.p.decl_flags; if( old_flags & FLAG_BASED ) { switch( oldtyp->u.p.based_kind ) { case BASED_SEGNAME: old_segid = oldtyp->u.p.segid; break; - /* NYI: This could be smarter and check other based types. */ + /* + * NYI: This could be smarter and check other based types. + */ default: old_segid = SEG_NULL; } @@ -1739,20 +1810,24 @@ TREEPTR CnvOp( TREEPTR opnd, TYPEPTR newtyp, bool cast_op ) SetDiagPop(); return( opnd ); } else if( cast_op && CompFlags.extensions_enabled ) { - /* We know the following: */ - /* - it is a cast operation */ - /* - both types are pointers */ - /* - extensions are enabled */ - /* - both pointers are the same size */ - /* - neither pointer is a function pointer */ - /* So, if it is still an lvalue */ - /* - then just update the type and leave it */ - /* - as an lvalue. This will allow the */ - /* - following statement to get through without */ - /* - generating an error! */ - /* (char *)p += 2; */ + /* + * We know the following: + * - it is a cast operation + * - both types are pointers + * - extensions are enabled + * - both pointers are the same size + * - neither pointer is a function pointer + * So, if it is still an lvalue + * - then just update the type and leave it + * - as an lvalue. This will allow the + * - following statement to get through without + * - generating an error! + * (char *)p += 2; + */ if( opr == OPR_PUSHADDR || IsLValue( opnd ) ) { - /* don't do it for based or far16. */ + /* + * don't do it for based or far16. + */ if( !Far16Pointer( opnd->op.flags ) ) { opnd->u.expr_type = newtyp; opnd->op.opr = opr; @@ -1768,12 +1843,16 @@ TREEPTR CnvOp( TREEPTR opnd, TYPEPTR newtyp, bool cast_op ) } if( cnv == P2A || cnv == A2P ) { if( TypeSize( typ ) != TypeSize( newtyp ) ) { - // Conversion to/from a pointer may need special treatment + /* + * Conversion to/from a pointer may need special treatment + */ opnd = BaseConv( newtyp, opnd ); } } if( cnv == S2B ) { - // Conversion to _Bool needs special treatment + /* + * Conversion to _Bool needs special treatment + */ opnd = BoolConv( newtyp, opnd ); } if( cast_op || cnv != P2P ) { @@ -1789,13 +1868,17 @@ TREEPTR CnvOp( TREEPTR opnd, TYPEPTR newtyp, bool cast_op ) old_ptrclass = ExprTypeClass( typ ); if( new_ptrclass != old_ptrclass && ( FAR16_PTRCLASS( new_ptrclass ) || FAR16_PTRCLASS( old_ptrclass ) ) ) { - // foreign pointers + /* + * foreign pointers + */ opnd = ExprNode( NULL, OPR_CONVERT_PTR, opnd ); opnd->op.u2.sp.old_ptrclass = old_ptrclass; opnd->op.u2.sp.new_ptrclass = new_ptrclass; #if _CPU == 8086 } else if( cnv == P2A && (newtyp->type_flags & TF2_TYP_SEGMENT) ) { - // getting segment value of pointer + /* + * getting segment value of pointer + */ opnd = BasedPtrNode( typ, opnd ); opnd = ExprNode( NULL, OPR_CONVERT_SEG, opnd ); opnd->op.u2.result_type = newtyp; @@ -1822,12 +1905,14 @@ TREEPTR CnvOp( TREEPTR opnd, TYPEPTR newtyp, bool cast_op ) return( opnd ); } -/* Fix up assignments - used for passing function arguments and also +TREEPTR FixupAss( TREEPTR opnd, TYPEPTR newtyp ) +/*********************************************** + * Fix up assignments - used for passing function arguments and also * return values. Fixes up based pointers and other x86 weirdnesses. + * + * TODO check out base ptrs */ -TREEPTR FixupAss( TREEPTR opnd, TYPEPTR newtyp ) { -//TODO check out base ptrs TYPEPTR typ; enum conv_types cnv; DATA_TYPE decl1; @@ -1835,11 +1920,15 @@ TREEPTR FixupAss( TREEPTR opnd, TYPEPTR newtyp ) if( opnd->op.opr == OPR_ERROR ) return( opnd ); - // skip typedefs, go into enum base + /* + * skip typedefs, go into enum base + */ typ = SkipTypeFluff( opnd->u.expr_type ); opnd = BaseConv( newtyp, opnd ); opnd = BoolConv( newtyp, opnd ); - // skip typedefs, go into enum base + /* + * skip typedefs, go into enum base + */ newtyp = SkipTypeFluff( newtyp ); decl1 = DataTypeOf( typ ); decl2 = DataTypeOf( newtyp ); @@ -1857,7 +1946,9 @@ TREEPTR FixupAss( TREEPTR opnd, TYPEPTR newtyp ) old_ptrclass = ExprTypeClass( typ ); if( new_ptrclass != old_ptrclass && ( FAR16_PTRCLASS( new_ptrclass ) || FAR16_PTRCLASS( old_ptrclass ) ) ) { - // if far16 pointer + /* + * if far16 pointer + */ opnd = ExprNode( NULL, OPR_CONVERT_PTR, opnd ); opnd->op.u2.sp.old_ptrclass = old_ptrclass; opnd->op.u2.sp.new_ptrclass = new_ptrclass; @@ -1879,7 +1970,7 @@ TREEPTR FixupAss( TREEPTR opnd, TYPEPTR newtyp ) TREEPTR UMinus( TREEPTR opnd ) { -// FLOATVAL *flt; +// FLOATVAL *flt; DATA_TYPE t; opnd = RValue( opnd ); @@ -2023,20 +2114,21 @@ TREEPTR UComplement( TREEPTR opnd ) static TYPEPTR MergedType( TYPEPTR typ1, TYPEPTR typ2 ) +/****************************************************** + * (type huge *) : (type *) -> (type huge *) + * (type *) : (type huge *) -> (type huge *) + * (type far *) : (type *) -> (type far *) + * (type *) : (type far *) -> (type far *) + * (type const *) : (type *) -> (type const *) + * (type *) : (type const *) -> (type const *) + * (type volatile *) : (type *) -> (type volatile *) + * (type *) : (type volatile *) -> (type volatile *) + * etc. + */ { type_modifiers flags, new_flags; TYPEPTR typ; -/* -(type huge *) : (type *) -> (type huge *) -(type *) : (type huge *) -> (type huge *) -(type far *) : (type *) -> (type far *) -(type *) : (type far *) -> (type far *) -(type const *) : (type *) -> (type const *) -(type *) : (type const *) -> (type const *) -(type volatile *) : (type *) -> (type volatile *) -(type *) : (type volatile *) -> (type volatile *) - etc. -*/ + typ = typ1; flags = typ1->u.p.decl_flags | typ2->u.p.decl_flags; new_flags = flags & MASK_CV_QUALIFIERS; @@ -2066,10 +2158,10 @@ TYPEPTR TernType( TREEPTR true_part, TREEPTR false_part ) SKIP_TYPEDEFS( typ1 ); typ2 = false_part->u.expr_type; SKIP_TYPEDEFS( typ2 ); -/* - (type1) : (type1) -> (type1) - nb. structs, unions, and identical pointers are handled here -*/ + /* + * (type1) : (type1) -> (type1) + * nb. structs, unions, and identical pointers are handled here + */ if( typ1 == typ2 ) return( typ1 ); dtype1 = DataTypeOf( typ1 ); @@ -2086,18 +2178,17 @@ TYPEPTR TernType( TREEPTR true_part, TREEPTR false_part ) } return( MergedType( typ2, typ1 ) ); /* merge near/far/const etc. */ } -/* - (arithmetic type) : (arithmetic type) -> (promoted arithmetic type) -*/ + /* + * (arithmetic type) : (arithmetic type) -> (promoted arithmetic type) + */ if( (dtype1 <= TYP_LONG_DOUBLE) && (dtype2 <= TYP_LONG_DOUBLE) ) { return( GetType( SubResult[dtype1][dtype2] ) ); } TernChk( typ1, typ2 ); if( dtype1 == TYP_POINTER && dtype2 == TYP_POINTER ) { -/* - (void *) : (anything *) -> (void *) -*/ - + /* + * (void *) : (anything *) -> (void *) + */ if( typ1->object->decl_type == TYP_VOID ) { return( MergedType( typ1, typ2 ) ); } else if( typ2->object->decl_type == TYP_VOID ) { diff --git a/bld/cc/c/cmemmgr.c b/bld/cc/c/cmemmgr.c index 5e884680bd..7f3e03e402 100644 --- a/bld/cc/c/cmemmgr.c +++ b/bld/cc/c/cmemmgr.c @@ -55,7 +55,9 @@ #define MCB_SHIFT MEM_ALIGN -/* Mask to get real allocation size */ +/* + * Mask to get real allocation size + */ #define SIZE_MASK ~ALLOC_FLAG #define NEXT_MCB(x) ((MCB *)((char *)(x) + ((x)->len & SIZE_MASK))) @@ -65,7 +67,8 @@ #define PTR2MCB_SIZE(x) ((x) + MCB_SHIFT) #define MCB2PTR_SIZE(x) ((x) - MCB_SHIFT) -/* Size of permanent area. Needs to be reasonably big to satisfy +/* + * Size of permanent area. Needs to be reasonably big to satisfy * large allocation requests. Must by multiple of 0x20 */ #define MAX_PERM_SIZE 0x00100000 @@ -93,7 +96,8 @@ typedef struct mem_blk { #endif } mem_blk; -/* variables used: +/* + * variables used: * char *PermPtr; first free byte in permanent area block * size_t PermSize; total size of permanent area block * size_t PermAvail; number of bytes available in permanent area block @@ -222,7 +226,9 @@ static void Ccoalesce( MCB *mcb1 ) */ if( mcb2->len & ALLOC_FLAG ) break; - /* coalesce mcb1 and mcb2 and remove mcb2 from free list */ + /* + * coalesce mcb1 and mcb2 and remove mcb2 from free list + */ mcb1->len += mcb2->len; removeMCBfromFreeList( mcb2 ); } @@ -244,7 +250,9 @@ static void *CFastAlloc( size_t size ) Ccoalesce( mcb ); if( mcb->len >= mcb_len ) { if( mcb->len - mcb_len > sizeof( MCB ) ) { - /* block is big enough to split it */ + /* + * block is big enough to split it + */ mcb->len -= mcb_len; mcb = NEXT_MCB( mcb ); mcb->len = mcb_len; @@ -278,7 +286,9 @@ void *CMemAlloc( size_t size ) CSuicide(); } } - /* make sure pointer is properly aligned */ + /* + * make sure pointer is properly aligned + */ assert( ((unsigned)(pointer_uint)p & (MEM_ALIGN - 1)) == 0 ); return( memset( p, 0, size ) ); @@ -302,7 +312,9 @@ void *CMemRealloc( void *old_p, size_t size ) CMemFree( old_p ); #if 0 } else { - /* the current block is big enough -- nothing to do (very lazy realloc) */ + /* + * the current block is big enough -- nothing to do (very lazy realloc) + */ #endif } return( p ); @@ -319,11 +331,15 @@ static enum cmem_kind CMemKind( const char *p ) size = PermSize; for( blk = Blks; blk != NULL; blk = blk->next ) { if( p > (char *)blk ) { - /* check if permanent memory (from beginning of block) */ + /* + * check if permanent memory (from beginning of block) + */ if( p < ptr ) { return( CMEM_PERM ); } - /* check if dynamic memory (from end of block) */ + /* + * check if dynamic memory (from end of block) + */ if( p < ( (char *)blk + sizeof( mem_blk ) + size ) ) { return( CMEM_MEM ); } @@ -375,7 +391,9 @@ void *CPermAlloc( size_t size ) size = _RoundUp( size, MEM_ALIGN ); if( size > PermAvail ) { if( size <= MAX_PERM_SIZE ) { - /* allocate another permanent area block */ + /* + * allocate another permanent area block + */ AllocPermArea(); } if( size > PermAvail ) { diff --git a/bld/cc/c/cmodel.c b/bld/cc/c/cmodel.c index 94a8ee9a58..4ca942b5a1 100644 --- a/bld/cc/c/cmodel.c +++ b/bld/cc/c/cmodel.c @@ -44,7 +44,9 @@ extern char CompilerID[]; -/* COMMAND LINE PARSING OF MACRO DEFINITIONS */ +/* + * COMMAND LINE PARSING OF MACRO DEFINITIONS + */ static size_t get_namelen( const char *start ) { @@ -253,7 +255,9 @@ static void Define_Macros_Extension( void ) PreDefine_Macro( "_leave=__leave"); PreDefine_Macro( "_asm=__asm"); #if _CPU == 8086 - /* SOM for Windows macros */ + /* + * SOM for Windows macros + */ PreDefine_Macro( "SOMLINK=__cdecl" ); PreDefine_Macro( "SOMDLINK=__far" ); #else diff --git a/bld/cc/c/coptions.c b/bld/cc/c/coptions.c index d9ebec9051..26f49a6416 100644 --- a/bld/cc/c/coptions.c +++ b/bld/cc/c/coptions.c @@ -291,7 +291,9 @@ static void SetTargetSystem( void ) #error "Target OS not defined" #endif #elif _RISC_CPU - /* we only have NT libraries for Alpha right now */ + /* + * we only have NT libraries for Alpha right now + */ _SetTargetNameConst( "nt" ); #elif _CPU == _SPARC _SetTargetNameConst( "solaris" ); @@ -339,15 +341,17 @@ static void SetTargetSystem( void ) Stack87 = 4; /* fall through */ case TS_NETWARE5: - /* no "fpr" for Netware 5.0 */ + /* + * no "fpr" for Netware 5.0 + */ if( SwData.mem == SW_M_DEF ) { SwData.mem = SW_MS; } PreDefine_Macro( "__NETWARE_386__" ); /* - // NETWARE uses stack based calling conventions - // by default - silly people. - */ + * NETWARE uses stack based calling conventions + * by default - silly people. + */ CompFlags.register_conventions = false; break; @@ -492,13 +496,17 @@ static void SetGenSwitches( void ) #endif switch( SwData.dbg_fmt ) { case SW_DF_WATCOM: - /* nothing to do */ + /* + * nothing to do + */ break; case SW_DF_CV: GenSwitches |= CGSW_GEN_DBG_CV; break; case SW_DF_DEF: - /* DWARF is the default */ + /* + * DWARF is the default + */ case SW_DF_DWARF: GenSwitches |= CGSW_GEN_DBG_DF; break; @@ -836,8 +844,10 @@ static void AddIncList( const char *path_list ) } void MergeInclude( void ) +/************************ + * must be called after GenCOptions to get req'd IncPathList + */ { - /* must be called after GenCOptions to get req'd IncPathList */ const char *env_var; char *buff; @@ -2067,7 +2077,9 @@ static void ProcOptions( const char *str ) p = ToString( beg, str - beg ); StripQuotes( p ); if( WholeFName != NULL ) { - /* more than one file to compile ? */ + /* + * more than one file to compile ? + */ CBanner(); CErr1( ERR_CAN_ONLY_COMPILE_ONE_FILE ); CMemFree( WholeFName ); @@ -2232,13 +2244,17 @@ static void SetDebug( void ) void GenCOptions( char **cmdline ) { memset( &SwData,0, sizeof( SwData ) ); //re-useable - /* Add precision warning but disabled by default */ + /* + * Add precision warning but disabled by default + */ WarnEnableDisable( false, ERR_LOSE_PRECISION ); - /* Warning about non-prototype declarations is disabled by default + /* + * Warning about non-prototype declarations is disabled by default * because Windows and OS/2 API headers use it */ WarnEnableDisable( false, ERR_OBSOLETE_FUNC_DECL ); - /* Warning about pointer truncation during cast is disabled by + /* + * Warning about pointer truncation during cast is disabled by * default because it would cause too many build breaks right now * by correctly diagnosing broken code. */ @@ -2276,7 +2292,9 @@ void GenCOptions( char **cmdline ) Define_Memory_Model(); #if _INTEL_CPU if( GET_CPU( ProcRevision ) < CPU_386 ) { - /* issue warning message if /zf[f|p] or /zg[f|p] spec'd? */ + /* + * issue warning message if /zf[f|p] or /zg[f|p] spec'd? + */ TargetSwitches &= ~(CGSW_X86_FLOATING_FS | CGSW_X86_FLOATING_GS); } if( !CompFlags.save_restore_segregs ) { diff --git a/bld/cc/c/cpragma.c b/bld/cc/c/cpragma.c index 32570ad3c3..5ae8b64fd4 100644 --- a/bld/cc/c/cpragma.c +++ b/bld/cc/c/cpragma.c @@ -483,7 +483,9 @@ static void CopyCode( void ) byte_seq *code; unsigned size; -// TODO deal with reloc list + /* + * TODO deal with reloc list + */ if( CurrInfo->code == NULL ) return; if( CurrInfo->code != CurrAlias->code ) @@ -537,8 +539,9 @@ void PragmaAuxEnding( void ) CurrInfo->use = 1; CurrEntry->info = CurrInfo; } - - /* If this pragma defines code, check to see if we already have a function body */ + /* + * If this pragma defines code, check to see if we already have a function body + */ if( CurrEntry != NULL && CurrEntry->info != NULL && CurrEntry->info->code != NULL ) { SYM_HANDLE sym_handle; SYM_ENTRY sym; @@ -612,7 +615,9 @@ int PragRegNumIndex( const char *str, int max_reg ) { int index; - /* decode regular register index, max 2 digit */ + /* + * decode regular register index, max 2 digit + */ if( isdigit( (unsigned char)str[0] ) ) { index = str[0] - '0'; if( isdigit( (unsigned char)str[1] ) ) { @@ -717,14 +722,14 @@ void SetToggleFlag( char const *name, int func, bool push ) #undef pick } -/* forms: +static void pragOptions( int func ) +/********************************** + * forms: * - * #pragma on () - * #pragma off () - * #pragma pop () + * #pragma on () + * #pragma off () + * #pragma pop () */ -static void pragOptions( int func ) -/**********************************/ { PPCTL_ENABLE_MACROS(); PPNextToken(); @@ -792,13 +797,13 @@ static void GetLibraryNames( void ) } } -/* forms: +static void pragLibs( void ) +/*************************** + * forms: * - * #pragma library - * #pragma library () + * #pragma library + * #pragma library () */ -static void pragLibs( void ) -/**************************/ { PPCTL_ENABLE_MACROS(); PPNextToken(); @@ -812,12 +817,12 @@ static void pragLibs( void ) PPCTL_DISABLE_MACROS(); } -/* forms: +static void pragComment( void ) +/****************************** + * forms: * - * #pragma comment ( comment_type [, "comment_string"] ) + * #pragma comment ( comment_type [, "comment_string"] ) */ -static void pragComment( void ) -/*****************************/ { PPCTL_ENABLE_MACROS(); PPNextToken(); @@ -853,7 +858,9 @@ void SetPackAmount( unsigned amount ) static void getPackArgs( void ) /****************************/ { - /* check to make sure it is a numeric token */ + /* + * check to make sure it is a numeric token + */ if( PragRecogId( "push" ) ) { pushPrag( &TOGGLE_STK( pack ), (unsigned)PackAmount ); if( CurToken == T_COMMA ) { @@ -874,16 +881,16 @@ static void getPackArgs( void ) } } -/* forms: +static void pragPack( void ) +/*************************** + * forms: * - * #pragma pack () - * #pragma pack ( n ) - * #pragma pack ( push ) - * #pragma pack ( pop ) - * #pragma pack ( push, n ) + * #pragma pack () + * #pragma pack ( n ) + * #pragma pack ( push ) + * #pragma pack ( pop ) + * #pragma pack ( push, n ) */ -static void pragPack( void ) -/**************************/ { PPCTL_ENABLE_MACROS(); PPNextToken(); @@ -938,12 +945,12 @@ textsegment *LkSegName( const char *segname, const char *classname ) return( NewTextSeg( segname, "", classname ) ); } -/* forms: +static void pragAllocText( void ) +/******************************** + * forms: * - * #pragma alloc_text ( seg_name, fn [, fn] ) + * #pragma alloc_text ( seg_name, fn [, fn] ) */ -static void pragAllocText( void ) -/*******************************/ { struct textsegment *tseg; SYM_HANDLE sym_handle; @@ -953,22 +960,30 @@ static void pragAllocText( void ) PPNextToken(); if( ExpectingToken( T_LEFT_PAREN ) ) { PPNextToken(); - /* current token can be an T_ID or a T_STRING */ + /* + * current token can be an T_ID or a T_STRING + */ tseg = LkSegName( Buffer, "" ); PPNextToken(); for( ;; ) { MustRecog( T_COMMA ); - /* current token can be an T_ID or a T_STRING */ + /* + * current token can be an T_ID or a T_STRING + */ sym_handle = Sym0Look( CalcHashID( Buffer ), Buffer ); if( sym_handle == SYM_NULL ) { - /* error */ + /* + * error + */ } else { SymGet( &sym, sym_handle ); if( sym.flags & SYM_FUNCTION ) { sym.seginfo = tseg; SymReplace( &sym, sym_handle ); } else { - /* error, must be function */ + /* + * error, must be function + */ } } PPNextToken(); @@ -994,12 +1009,16 @@ static void changeLevel( unsigned level, int msg_index ) if( msg_level[msg_index].level != level ) { msg_level[msg_index].level = level; if( level == WLEVEL_DISABLED ) { - /* disable message */ + /* + * disable message + */ if( msg_level[msg_index].enabled ) { msg_level[msg_index].enabled = false; } } else { - /* enable message */ + /* + * enable message + */ if( !msg_level[msg_index].enabled ) { msg_level[msg_index].enabled = true; } @@ -1016,8 +1035,9 @@ static void changeStatus( bool enabled, int msg_index ) } static void warnChangeLevel( unsigned level, msg_codes msgnum ) -/*************************************************************/ -/* CHANGE WARNING LEVEL FOR A MESSAGE */ +/************************************************************** + * CHANGE WARNING LEVEL FOR A MESSAGE + */ { unsigned msg_index; @@ -1042,8 +1062,9 @@ static void warnChangeLevel( unsigned level, msg_codes msgnum ) } static void warnChangeLevels( unsigned level ) -/********************************************/ -/* CHANGE WARNING LEVELS FOR ALL MESSAGES */ +/********************************************* + * CHANGE WARNING LEVELS FOR ALL MESSAGES + */ { int msg_index; // - index for number @@ -1084,16 +1105,16 @@ void WarnEnableDisable( bool enabled, msg_codes msgnum ) } } -/* - * forms: #pragma warning # level (change message # to have level "level) - * : #pragma warning * level (change all messages to have level "level) +static bool pragWarning( void ) +/****************************** + * forms: * - * "level" must be digit (0-5) - * "level==0" implies warning will be treated as an error + * #pragma warning # level (change message # to have level "level) + * #pragma warning * level (change all messages to have level "level) + * + * "level" must be digit (0-5) + * "level==0" implies warning will be treated as an error */ -static bool pragWarning( void ) -/*****************************/ -/* PROCESS #PRAGMA WARNING */ { unsigned msgnum; // - message number unsigned level; // - new level @@ -1110,7 +1131,9 @@ static bool pragWarning( void ) } else if( CurToken == T_CONSTANT ) { msgnum = Constant; } else { - // ignore; MS or other vendor's #pragma + /* + * ignore; MS or other vendor's #pragma + */ ignore = true; } if( !ignore ) { @@ -1132,15 +1155,15 @@ static bool pragWarning( void ) return( ignore ); } -/* forms: +static void pragEnableDisableMessage( bool enabled ) +/*************************************************** + * forms: * - * #pragma enable_message( messageNo ) - * #pragma disable_message( messageNo ) + * #pragma enable_message( messageNo ) + * #pragma disable_message( messageNo ) * * disable/enable display of selected message number */ -static void pragEnableDisableMessage( bool enabled ) -/**************************************************/ { PPCTL_ENABLE_MACROS(); PPNextToken(); @@ -1174,16 +1197,16 @@ static char *collectStrings( char *message ) return( message ); } -/* form: +static void pragMessage( void ) +/****************************** + * form: * - * #pragma message ("one or more " "long message " "strings") + * #pragma message ("one or more " "long message " "strings") * * output these strings to stdout * this output is _not_ dependent on setting * of #pragma enable_message or disable_message. */ -static void pragMessage( void ) -/*****************************/ { char *message; @@ -1203,12 +1226,14 @@ static void pragMessage( void ) PPCTL_DISABLE_MACROS(); } -/* forms: +static void pragEnum( void ) +/*************************** + * forms: * - * (1) #pragma enum int - * (2) #pragma enum minimum - * (3) #pragma enum original - * (4) #pragma enum pop + * #pragma enum int (1) + * #pragma enum minimum (2) + * #pragma enum original (3) + * #pragma enum pop (4) * * The pragma affects the underlying storage-definition for subsequent * enum declarations. @@ -1220,8 +1245,6 @@ static void pragMessage( void ) * * 1-3 all push previous value before affecting value */ -static void pragEnum( void ) -/**************************/ { PPCTL_ENABLE_MACROS(); PPNextToken(); @@ -1244,12 +1267,12 @@ static void pragEnum( void ) PPCTL_DISABLE_MACROS(); } -/* forms: +static void pragIntrinsic( int intrinsic ) +/***************************************** + * forms: * - * #pragma intrinsic ( fn [, fn] ) + * #pragma intrinsic ( fn [, fn] ) */ -static void pragIntrinsic( int intrinsic ) -/****************************************/ { SYM_HANDLE sym_handle; SYM_ENTRY sym; @@ -1276,12 +1299,12 @@ static void pragIntrinsic( int intrinsic ) PPCTL_DISABLE_MACROS(); } -/* forms: +static void pragCodeSeg( void ) +/****************************** + * forms: * - * #pragma code_seg ( seg_name [, class_name] ) + * #pragma code_seg ( seg_name [, class_name] ) */ -static void pragCodeSeg( void ) -/*****************************/ { textsegment *tseg; char *segname; @@ -1301,7 +1324,7 @@ static void pragCodeSeg( void ) if( ( CurToken == T_STRING ) || ( CurToken == T_ID ) ) { CMemFree( classname ); classname = CStrSave( Buffer ); -// CodeClassName = CStrSave( Buffer ); */ +// CodeClassName = CStrSave( Buffer ); */ PPNextToken(); } } @@ -1318,12 +1341,12 @@ static void pragCodeSeg( void ) PPCTL_DISABLE_MACROS(); } -/* forms: +static void pragDataSeg( void ) +/****************************** + * forms: * - * #pragma data_seg ( seg_name [, class_name] ) + * #pragma data_seg ( seg_name [, class_name] ) */ -static void pragDataSeg( void ) -/*****************************/ { char *segname; segment_id segid; @@ -1355,12 +1378,12 @@ static void pragDataSeg( void ) PPCTL_DISABLE_MACROS(); } -/* forms: +static void pragUnroll( void ) +/***************************** + * forms: * - * #pragma unroll ( n ) + * #pragma unroll ( n ) */ -static void pragUnroll( void ) -/****************************/ { unroll_type unroll_count; @@ -1379,17 +1402,17 @@ static void pragUnroll( void ) PPCTL_DISABLE_MACROS(); } -/* forms: +static void pragReadOnlyFile( void ) +/*********************************** + * forms: * - * (1) #pragma read_only_file - * (2) #pragma read_only_file "file"* + * #pragma read_only_file (1) + * #pragma read_only_file "file"* (2) * * (1) causes current file to be marked read-only * (2) causes indicated file to be marked read-only * - file must have started inclusion (may have completed) */ -static void pragReadOnlyFile( void ) -/**********************************/ { PPCTL_ENABLE_MACROS(); PPNextToken(); @@ -1408,14 +1431,14 @@ static void pragReadOnlyFile( void ) } -/* forms: +static void pragReadOnlyDir( void ) +/********************************** + * forms: * * #pragma read_only_directory "directory"* * - * (1) causes all files within directory to be marked read-only + * causes all files within directory to be marked read-only */ -static void pragReadOnlyDir( void ) -/*********************************/ { PPCTL_ENABLE_MACROS(); PPNextToken(); @@ -1429,16 +1452,16 @@ static void pragReadOnlyDir( void ) PPCTL_DISABLE_MACROS(); } -/* forms: +static void pragIncludeAlias( void ) +/*********************************** + * forms: * - * (1) #pragma include_alias ( "alias_name", "real_name" ) - * (2) #pragma include_alias ( , ) + * #pragma include_alias ( "alias_name", "real_name" ) + * #pragma include_alias ( , ) * * causes include directives referencing alias_name to be refer * to real_name instead */ -static void pragIncludeAlias( void ) -/**********************************/ { PPCTL_ENABLE_MACROS(); PPNextToken(); @@ -1485,14 +1508,14 @@ static void pragIncludeAlias( void ) PPCTL_DISABLE_MACROS(); } -/* forms: +static void pragOnce( void ) +/*************************** + * forms: * - * #pragma once + * #pragma once * * include file once */ -static void pragOnce( void ) -/**************************/ { PPCTL_ENABLE_MACROS(); PPNextToken(); @@ -1509,12 +1532,12 @@ static void OptionPragSTDC( void ) } } -/* forms: +static void pragSTDC( void ) +/*************************** + * forms: * - * #pragma STDC (FP_CONTRACT|FENV_ACCESS|CX_LIMITED_RANGE) (ON|OFF|DEFAULT) + * #pragma STDC (FP_CONTRACT|FENV_ACCESS|CX_LIMITED_RANGE) (ON|OFF|DEFAULT) */ -static void pragSTDC( void ) -/**************************/ { PPCTL_DISABLE_MACROS(); PPNextToken(); @@ -1574,13 +1597,13 @@ static void parseExtRef ( void ) } } -/* forms: +static void pragExtRef( void ) +/***************************** + * forms: * - * #pragma extref ( symbolid [, ...] ) - * #pragma extref ( "symbolname" [, ...] ) + * #pragma extref ( symbolid [, ...] ) + * #pragma extref ( "symbolname" [, ...] ) */ -static void pragExtRef( void ) -/****************************/ { PPCTL_ENABLE_MACROS(); PPNextToken(); @@ -1600,16 +1623,16 @@ static void pragExtRef( void ) PPCTL_DISABLE_MACROS(); } -/* forms: +static void pragAlias( void ) +/**************************** + * forms: * - * #pragma alias(id1/"name1", id2/"name2") + * #pragma alias(id1/"name1", id2/"name2") * * Causes linker to replace references to id1/name1 with references * to id2/name2. Both the alias and the substituted symbol may be defined * either as a string name or an id of existing symbol. */ -static void pragAlias( void ) -/***************************/ { SYM_HANDLE alias_sym; SYM_HANDLE subst_sym; @@ -1649,8 +1672,9 @@ static void pragAlias( void ) MustRecog( T_RIGHT_PAREN ); } PPCTL_DISABLE_MACROS(); - - /* Add a new alias record - if it's valid - to the list */ + /* + * Add a new alias record - if it's valid - to the list + */ if( ( alias_name != NULL || alias_sym != SYM_NULL ) && ( subst_name != NULL || subst_sym != SYM_NULL ) ) { for( alias = &AliasHead; *alias != NULL; alias = &(*alias)->next ) ; /* nothing to do */ @@ -1675,7 +1699,8 @@ void CPragma( void ) { bool check_end; - /* Note that the include_alias pragma must always be processed + /* + * Note that the include_alias pragma must always be processed * because it's intended for the preprocessor, not the compiler. */ CompFlags.in_pragma = true; @@ -1718,8 +1743,10 @@ void CPragma( void ) pragDataSeg(); } else if( pragmaNameRecog( "warning" ) ) { if( pragWarning() ) { - /* ignore #pragma warning */ - /* skip rest of line */ + /* + * ignore #pragma warning + * skip rest of line + */ check_end = false; } } else if( pragmaNameRecog( "disable_message" ) ) { diff --git a/bld/cc/c/cpragx86.c b/bld/cc/c/cpragx86.c index effb7d45ce..5ffb1869ab 100644 --- a/bld/cc/c/cpragx86.c +++ b/bld/cc/c/cpragx86.c @@ -67,10 +67,11 @@ static void pragmaAuxInfoInit( void ) #endif #if _CPU == 386 - /* these are internal, and will never be pointed to by - an aux_entry, so we don't have to worry about them - or their fields being freed */ - + /* + * these are internal, and will never be pointed to by + * an aux_entry, so we don't have to worry about them + * or their fields being freed + */ STOSBInfo = WatcallInfo; STOSBInfo.cclass = FECALL_GEN_NONE; STOSBInfo.cclass_target = FECALL_X86_NO_FLOAT_REG_RETURNS | @@ -153,7 +154,9 @@ static void PragmaAuxEnd( void ) hw_reg_set flt_n_seg; if( CurrEntry == NULL ) { - // Redefining a built-in calling convention + /* + * Redefining a built-in calling convention + */ } else { CurrInfo = (aux_info *)CMemAlloc( sizeof( aux_info ) ); *CurrInfo = *CurrAlias; @@ -293,7 +296,9 @@ static int AsmPtrType( TYPEPTR typ, type_modifiers flags ) } } -/* matches enum DataType in ctypes.h */ +/* + * matches enum DataType in ctypes.h + */ static enum sym_type AsmDataType[] = { #define pick1(enum,cgtype,x86asmtype,name,size) x86asmtype, #include "cdatatyp.h" @@ -384,7 +389,9 @@ bool AsmInsertFixups( aux_info *info ) head = FixupHead; if( head != NULL ) { FixupHead = NULL; - /* sort the fixup list in increasing fixup_loc's */ + /* + * sort the fixup list in increasing fixup_loc's + */ for( fix = head; fix != NULL; fix = next ) { for( owner = &FixupHead; (chk = *owner) != NULL; owner = &chk->next ) { if( chk->fixup_loc > fix->fixup_loc ) { @@ -399,7 +406,9 @@ bool AsmInsertFixups( aux_info *info ) end = src + len; fix = FixupHead; owner = &FixupHead; - /* insert fixup escape sequences */ + /* + * insert fixup escape sequences + */ while( src < end ) { if( fix != NULL && fix->fixup_loc == (src - AsmCodeBuffer) ) { name = fix->name; @@ -421,7 +430,9 @@ bool AsmInsertFixups( aux_info *info ) } SymReplace( &sym, sym_handle ); } - /* insert fixup information */ + /* + * insert fixup information + */ skip = 0; *dst++ = FLOATING_FIXUP_BYTE; mutate_to_segment = false; @@ -435,16 +446,24 @@ bool AsmInsertFixups( aux_info *info ) break; case FIX_SEG: if( name == NULL ) { - // special case for floating point fixup + /* + * special case for floating point fixup + */ if( ( src[0] == 0x90 ) && ( src[1] == 0x9B ) ) { - // inline assembler FWAIT instruction 0x90, 0x9b + /* + * inline assembler FWAIT instruction 0x90, 0x9b + */ *dst++ = FIX_FPP_WAIT; } else if( src[0] == 0x9b && (src[1] & 0xd8) == 0xd8 ) { - // FWAIT as first byte and FPU instruction opcode as second byte + /* + * FWAIT as first byte and FPU instruction opcode as second byte + */ *dst++ = FIX_FPP_NORMAL; } else if( src[0] == 0x9b && (src[2] & 0xd8) == 0xd8 ) { - // FWAIT as first byte and FPU instruction opcode as third byte - // second byte should be segment override prefix + /* + * FWAIT as first byte and FPU instruction opcode as third byte + * second byte should be segment override prefix + */ switch( src[1] ) { case PREFIX_ES: *dst++ = FIX_FPP_ES; break; case PREFIX_CS: *dst++ = FIX_FPP_CS; break; @@ -455,7 +474,9 @@ bool AsmInsertFixups( aux_info *info ) default: --dst; break; // skip FP patch } } else { - // skip FP patch + /* + * skip FP patch + */ --dst; } } else { @@ -505,8 +526,10 @@ bool AsmInsertFixups( aux_info *info ) } #if _CPU == 8086 if( fixup_padding ) { - // add offset fixup padding to 32-bit - // cg create only 16-bit offset fixup + /* + * add offset fixup padding to 32-bit + * cg create only 16-bit offset fixup + */ *dst++ = 0; *dst++ = 0; // @@ -514,12 +537,12 @@ bool AsmInsertFixups( aux_info *info ) #endif if( mutate_to_segment ) { /* - Since the CG escape sequences don't allow for - FAR pointer fixups, we have to split them into two. - This is done by doing the offset fixup first, then - mutating the fixup structure to look like a segment - fixup one near pointer size later. - */ + * Since the CG escape sequences don't allow for + * FAR pointer fixups, we have to split them into two. + * This is done by doing the offset fixup first, then + * mutating the fixup structure to look like a segment + * fixup one near pointer size later. + */ fix->fixup_type = FIX_SEG; fix->fixup_loc += skip; fix->u_offset = 0; @@ -732,7 +755,9 @@ hw_reg_set PragRegName( const char *regname ) hw_reg_set name; if( *regname != '\0' ) { - // search register or alias name + /* + * search register or alias name + */ index = PragRegIndex( Registers, regname, true ); if( index != -1 ) { return( RegBits[RegMap[index]] ); @@ -756,7 +781,9 @@ hw_reg_set PragReg( void ) p = SkipUnderscorePrefix( Buffer ); if( p == NULL ) { - /* error, missing undercore prefix */ + /* + * error, missing undercore prefix + */ PragRegNameErr( Buffer ); p = Buffer; } diff --git a/bld/cc/c/cpurge.c b/bld/cc/c/cpurge.c index 98affab288..db9305fb91 100644 --- a/bld/cc/c/cpurge.c +++ b/bld/cc/c/cpurge.c @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -54,14 +55,14 @@ static void Purge( char **ptr ) void PurgeMemory( void ) /**********************/ { -// MacroPurge(); +// MacroPurge(); SymsPurge(); /* calls TypesPurge */ FreeFNames(); FreeRDir(); SrcPurge(); SwitchPurge(); Purge( &IncPathList ); -// Purge( &ErrSym ); /* ErrSym is in CPermArea */ +// Purge( &ErrSym ); /* ErrSym is in CPermArea */ Purge( &SavedId ); FreePreCompiledHeader(); } diff --git a/bld/cc/c/cscan.c b/bld/cc/c/cscan.c index c9bcae4fbb..5f811ec66a 100644 --- a/bld/cc/c/cscan.c +++ b/bld/cc/c/cscan.c @@ -207,8 +207,9 @@ TOKEN KwLookup( const char *buf, size_t len ) TOKEN token; token = keyword_hash( buf, TokValue, len ) + FIRST_KEYWORD; - - /* look up id in keyword table */ + /* + * look up id in keyword table + */ if( CompVars.cstd < CSTD_C99 ) { switch( token ) { case T_INLINE: @@ -223,15 +224,15 @@ TOKEN KwLookup( const char *buf, size_t len ) return( T_ID ); } } - keyword = Tokens[token]; if( *keyword == buf[0] ) { if( strcmp( keyword, buf ) == 0 ) { return( token ); } } - - /* not in keyword table, so must be just an identifier */ + /* + * not in keyword table, so must be just an identifier + */ return( T_ID ); } @@ -270,13 +271,17 @@ static TOKEN doScanName( void ) token = KwLookup( Buffer, TokenLen ); } } else { - /* this is a macro */ + /* + * this is a macro + */ if( MacroIsSpecial( mentry ) ) { return( SpecialMacro( mentry ) ); } mentry->macro_flags |= MFLAG_REFERENCED; - /* if macro requires parameters and next char is not a '(' - then this is not a macro */ + /* + * if macro requires parameters and next char is not a '(' + * then this is not a macro + */ if( MacroWithParenthesis( mentry ) ) { SkipAhead(); if( CurrChar != '(' ) { @@ -449,12 +454,13 @@ static TOKEN doScanPPNumber( void ) && ( c == '+' || c == '-' ) ) { WriteBufferChar( c ); if( CompFlags.extensions_enabled ) { - /* concession to existing practice... - #define A2 0x02 - #define A3 0xaa0e+A2 - // users want: 0xaa0e + 0x02 - // not: 0xaa0e + A2 (but, this is what ISO C requires!) - */ + /* + * concession to existing practice... + * #define A2 0x02 + * #define A3 0xaa0e+A2 + * // users want: 0xaa0e + 0x02 + * // not: 0xaa0e + A2 (but, this is what ISO C requires!) + */ prevc = c; //advance to next c = NextChar(); if( (CharSet[c] & C_DI) == 0 ) { @@ -1024,9 +1030,11 @@ static bool checkDelim2( TOKEN *token, TOKEN last ) return( false ); case T_COLON: if( last == T_GT ) { /* :> */ - // TODO: according to the standard, ":>" should be an - // alternative token (digraph) for "]" - // *token = T_RIGHT_BRACKET; /* -> ] */ + /* + * TODO: according to the standard, ":>" should be an + * alternative token (digraph) for "]" + * *token = T_RIGHT_BRACKET; -> ] + */ *token = T_SEG_OP; break; } @@ -1174,7 +1182,9 @@ static TOKEN ScanSlash( void ) CompFlags.scanning_cpp_comment = true; for( ;; ) { if( CurrChar == '\r' ) { - /* some editors don't put linefeeds on end of lines */ + /* + * some editors don't put linefeeds on end of lines + */ NextChar(); break; } @@ -1296,7 +1306,9 @@ int ESCChar( int c, escinp_fn ifn, msg_codes *perr_msg, escout_fn ofn ) break; #ifdef __QNX__ case 'l': - /* for lazy QNX programmers */ + /* + * for lazy QNX programmers + */ if( CompFlags.extensions_enabled ) { c = ESCAPE_n; } @@ -1409,7 +1421,9 @@ static TOKEN doScanCharConst( DATA_TYPE char_type ) } ++i; value = (value << 8) + c; - /* handle case where user wants a \ but doesn't escape it */ + /* + * handle case where user wants a \ but doesn't escape it + */ if( c == '\'' && CurrChar != '\'' ) { token = T_BAD_TOKEN; break; @@ -1495,8 +1509,10 @@ static TOKEN doScanString( bool wide ) c = CurrChar; } } else { - /* if first character of a double-byte character, then - save it and get the next one. */ + /* + * if first character of a double-byte character, then + * save it and get the next one. + */ if( CharSet[c] & C_DB ) { c = WriteBufferCharNextChar( c ); } @@ -1750,7 +1766,9 @@ TOKEN ReScanToken( void ) int (*saved_getcharcheck)( int ); TOKEN token; - /* save current status */ + /* + * save current status + */ saved_currchar = CurrChar; saved_nextchar = NextChar; saved_ungetchar = UnGetChar; @@ -1807,15 +1825,16 @@ void ScanInit( void ) GetCharCheck = GetCharCheckFile; } -// called by CollectParms() to gather tokens for macro parms -// and CDefine() to gather tokens for macro definition -// example usage: -// bool ppscan_mode; -// ppscan_mode = InitPPScan(); -// CollectParms(); -// FiniPPScan( ppscan_mode ); bool InitPPScan( void ) -/*********************/ +/********************** + * called by CollectParms() to gather tokens for macro parms + * and CDefine() to gather tokens for macro definition + * example usage: + * bool ppscan_mode; + * ppscan_mode = InitPPScan(); + * CollectParms(); + * FiniPPScan( ppscan_mode ); + */ { if( ScanFunc[SCAN_NUM] == ScanNum ) { ScanFunc[SCAN_NUM] = ScanPPDigit; diff --git a/bld/cc/c/cstats.c b/bld/cc/c/cstats.c index 125e1d80c9..ab6024a03a 100644 --- a/bld/cc/c/cstats.c +++ b/bld/cc/c/cstats.c @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -51,7 +52,9 @@ void InitStats( void ) TmpSymCount = 0; LitPoolSize = 0; LitCount = 0; - /* still useful for internal debugging */ + /* + * still useful for internal debugging + */ FuncCount = 0; } diff --git a/bld/cc/c/cstmt.c b/bld/cc/c/cstmt.c index 7911a85252..a74782f10a 100644 --- a/bld/cc/c/cstmt.c +++ b/bld/cc/c/cstmt.c @@ -50,7 +50,9 @@ typedef struct block_entry { bool gen_endblock; /* set if OPR_ENDBLOCK needed */ } BLOCKDEFN, *BLOCKPTR; -// values for return_type +/* + * values for return_type + */ enum return_with { RETURN_WITH_NONE = 0, RETURN_WITH_NO_EXPR = 1, @@ -190,7 +192,9 @@ void GenFunctionNode( SYM_HANDLE sym_handle ) tree->op.flags = OpFlags( sym->mods ); tree->u.expr_type = sym->sym_type->object; // function return type AddStmt( tree ); - // Evil, evil globals! But we need this for later lookups in cgen.c + /* + * Evil, evil globals! But we need this for later lookups in cgen.c + */ sym->u.func.start_of_func = LastStmt; CurFuncNode = tree; NodeCount = 0; @@ -441,8 +445,10 @@ static SYM_HANDLE GetLocalVarDecls( void ) DeclList( &symlist ); if( symlist != SYM_NULL ) { symhandle = CurFunc->u.func.locals; - // symhandle will be non-zero if MakeNewSym was called while - // parsing the declaration list. + /* + * symhandle will be non-zero if MakeNewSym was called while + * parsing the declaration list. + */ if( symhandle != SYM_NULL ) { // if some temporaries were created for( ;; ) { // - find end of list SymGet( &sym, symhandle ); @@ -493,8 +499,10 @@ static void LeftBrace( void ) { <- this is SymLevel == 1 (weird code is for SymLevel > 1 ) */ - // DeclList might generate some quads to do some initializers - // if that happens, we want them output after the OPR_NEWBLOCK node + /* + * DeclList might generate some quads to do some initializers + * if that happens, we want them output after the OPR_NEWBLOCK node + */ StartNewBlock(); NextToken(); ++SymLevel; @@ -754,7 +762,7 @@ static void AddCaseLabel( unsigned value ) leaf.u.ulong_konst = value; leaf.data_type = SwitchStack->case_type; SetLeafType( &leaf, 1 ); -// converted_value = value & SwitchStack->case_mask; +// converted_value = value & SwitchStack->case_mask; converted_value = leaf.u.ulong_konst; #else converted_value = value; @@ -1029,9 +1037,9 @@ static void EndSwitch( void ) sw->default_label = BlockStack->break_label; } } -// if( sw->case_list == NULL ) { -// CWarn1( ERR_EMPTY_SWITCH ); -// } +// if( sw->case_list == NULL ) { +// CWarn1( ERR_EMPTY_SWITCH ); +// } #if 0 for( ; (ce = sw->case_list) != NULL; ) { sw->case_list = ce->next_case; diff --git a/bld/cc/c/cstring.c b/bld/cc/c/cstring.c index 0c4f772274..5c6bdc1296 100644 --- a/bld/cc/c/cstring.c +++ b/bld/cc/c/cstring.c @@ -74,7 +74,9 @@ static void ReadUnicodeFile( FILE *fp ) unicode_type unicode_table[256]; len = fread( unicode_table, sizeof( unicode_type ), 256, fp ); - /* UniCode might be a FAR table */ + /* + * UniCode might be a FAR table + */ for( i = 0; i < 256; i++ ) { UniCode[i] = ( i < len ) ? unicode_table[i] : 0; } @@ -198,13 +200,17 @@ STR_HANDLE GetLiteral( void ) STR_HANDLE q; bool is_wide; - /* first we store the whole string in a linked list to see if - the end result is wide or not wide */ + /* + * first we store the whole string in a linked list to see if + * the end result is wide or not wide + */ p = str_lit = CMemAlloc( sizeof( STRING_LITERAL ) ); q = NULL; is_wide = false; do { - /* if one component is wide then the whole string is wide */ + /* + * if one component is wide then the whole string is wide + */ if( CompFlags.wide_char_string ) is_wide = true; if( q != NULL ) { @@ -217,8 +223,10 @@ STR_HANDLE GetLiteral( void ) p->literal = ToString( Buffer, TokenLen ); } while( NextToken() == T_STRING ); CompFlags.wide_char_string = is_wide; - /* then remove escapes (C99: translation phase 5), and only then - concatenate (translation phase 6), not the other way around! */ + /* + * then remove escapes (C99: translation phase 5), and only then + * concatenate (translation phase 6), not the other way around! + */ len = 1; s = NULL; q = str_lit; diff --git a/bld/cc/c/csym.c b/bld/cc/c/csym.c index b5a0e64432..9735c04754 100644 --- a/bld/cc/c/csym.c +++ b/bld/cc/c/csym.c @@ -66,7 +66,8 @@ static seg_info SymBufSegs[MAX_SYM_SEGS]; /* segments for symbols */ static SEGADDR_T AllocSegment( seg_info *si ) { - /* FEmalloc never returns NULL - it either allocates the memory + /* + * FEmalloc never returns NULL - it either allocates the memory * or kills the compiler. */ si->index = (SEGADDR_T)FEmalloc( 0x04000 ); @@ -219,36 +220,49 @@ void SpcSymInit( void ) TYPEPTR typ; SYM_ENTRY sym; - /* first entry into SpecialSyms */ + /* + * first entry into SpecialSyms + */ memset( &sym, 0, sizeof( SYM_ENTRY ) ); sym.sym_type = GetType( TYP_VOID ); SymReplace( &sym, 0 ); #ifdef __SEH__ - /* create special _try sym */ + /* + * create special _try sym + */ TrySymHandle = SpcSymbol( ".try", GetType( TYP_VOID ), SC_AUTO ); #endif - /* create special symbol for "extern unsigned int __near __chipbug" */ + /* + * create special symbol for "extern unsigned int __near __chipbug" + */ SymChipBug = SpcSymbol( "__chipbug", GetType( TYP_UINT ), SC_EXTERN ); - - /* create special symbol table entry for __segname("_CODE") */ + /* + * create special symbol table entry for __segname("_CODE") + */ Sym_CS = SegSymbol( "CS", SEG_CODE ); - /* create special symbol table entry for __segname("_STACK") */ + /* + * create special symbol table entry for __segname("_STACK") + */ Sym_SS = SegSymbol( "SS", SEG_STACK ); - /* create special symbol table entry for __segname("_CONST") */ + /* + * create special symbol table entry for __segname("_CONST") + */ SegSymbol( "CONST", SEG_CONST ); - /* create special symbol table entry for __segname("_DATA") */ + /* + * create special symbol table entry for __segname("_DATA") + */ SegSymbol( "DS", SEG_DATA ); SpecialSyms = CURR_SYM_HANDLE(); - - /* Create special symbol table entries for use by stosw, stosb pragmas + /* + * Create special symbol table entries for use by stosw, stosb pragmas * This should be a TYP_FUNCTION returning pointer to char */ ptr2char = PtrNode( GetType( TYP_CHAR ), FLAG_NONE, SEG_DATA ); typ = TypeNode( TYP_FUNCTION, ptr2char ); - - /* The ".stosw" functions are done through internal AUX entries */ - + /* + * The ".stosw" functions are done through internal AUX entries + */ SymSTOW = MakeFunction( "_inline_.stosw", GetType( TYP_VOID ) ); SymSTOWB = MakeFunction( "_inline_.stoswb", GetType( TYP_VOID ) ); SymMIN = MakeFunction( "_inline_.min", GetType( TYP_UINT ) ); @@ -426,7 +440,9 @@ SYM_HANDLE SymAdd( id_hash_idx hash, SYMPTR sym ) sym->level = (id_level_type)SymLevel; hsym = SymHash( sym, CURR_SYM_HANDLE() ); sym->info.hash = hash; - /* add name to head of list */ + /* + * add name to head of list + */ for( head = &HashTab[hash]; *head != NULL; head = &(*head)->next_sym ) { if( ChkLtSymLevel( *head ) || ChkEqSymLevel( *head ) ) { break; @@ -439,7 +455,9 @@ SYM_HANDLE SymAdd( id_hash_idx hash, SYMPTR sym ) SYM_HANDLE SymAddL0( id_hash_idx hash, SYMPTR new_sym ) -/* add symbol to level 0 */ +/****************************************************** + * add symbol to level 0 + */ { SYM_HASHPTR hsym; SYM_HASHPTR new_hsym; @@ -528,7 +546,9 @@ SYM_HANDLE SymLookTypedef( id_hash_idx hash, const char *id, SYMPTR sym ) SYM_HANDLE Sym0Look( id_hash_idx hash, const char *id ) -/* look for symbol on level 0 */ +/****************************************************** + * look for symbol on level 0 + */ { SYM_HASHPTR hsym; @@ -576,7 +596,9 @@ static void ChkIncomplete( SYMPTR sym, SYM_NAMEPTR name ) if( sym->attribs.stg_class != SC_TYPEDEF ) { if( (sym->flags & (SYM_FUNCTION | SYM_TEMP)) == 0 ) { if( (sym->flags & SYM_REFERENCED) == 0 ) { - /* if it wasn't referenced, don't worry */ + /* + * if it wasn't referenced, don't worry + */ if( sym->attribs.stg_class == SC_EXTERN ) { return; } @@ -608,7 +630,9 @@ static void ChkDefined( SYMPTR sym, SYM_NAMEPTR name ) if( sym->flags & SYM_REFERENCED ) { if( sym->attribs.stg_class == SC_STATIC ) { if( sym->flags & SYM_FUNCTION ) { - /* Check to see if we have a matching aux entry with code attached */ + /* + * Check to see if we have a matching aux entry with code attached + */ aux_entry *paux = AuxLookup( name ); if( !paux || !paux->info || !paux->info->code ) { CErr2p( ERR_FUNCTION_NOT_DEFINED, name ); @@ -709,19 +733,21 @@ static void Copy8( char const *nstr, char *name ) } #endif /* IBM370 names */ -/* divide all the global symbols into buckets based on size of the item - 0 - functions - 1 - 1-byte items - 2 - odd-length items - 3 - 2-byte items - 4 - even-length items (that are not a multiple of 4 in size) - 5 - 4-byte items (or multiple of 4, but not a multiple of 8) - 6 - 8-byte items (or multiple of 8) -*/ - #define BUCKETS 7 -static int SymBucket( SYMPTR sym ) /* determine bucket # for symbol */ +static int SymBucket( SYMPTR sym ) +/********************************* + * determine bucket # for symbol + * + * divide all the global symbols into buckets based on size of the item + * 0 - functions + * 1 - 1-byte items + * 2 - odd-length items + * 3 - 2-byte items + * 4 - even-length items (that are not a multiple of 4 in size) + * 5 - 4-byte items (or multiple of 4, but not a multiple of 8) + * 6 - 8-byte items (or multiple of 8) + */ { int bucket; unsigned size; @@ -855,7 +881,9 @@ static SYM_HASHPTR FreeSym( void ) bucket = SymBucket( &sym ); sym.handle = head[bucket]; if( ( sym.flags & SYM_FUNCTION ) == 0 ) { - /* VARIABLE */ + /* + * VARIABLE + */ if( sym.attribs.stg_class == SC_NONE ) { typ = sym.sym_type; SKIP_TYPEDEFS( typ ); @@ -867,7 +895,9 @@ static SYM_HASHPTR FreeSym( void ) } AssignSeg( &sym ); } else { - /* FUNCTION */ + /* + * FUNCTION + */ ChkFunction( &sym, hsym->name ); } if( tail[bucket] == SYM_NULL ) { @@ -875,8 +905,10 @@ static SYM_HASHPTR FreeSym( void ) } head[bucket] = hsym->handle; } -/* keep static names so that we can output static pubdefs and get nicer - -d1 debugging */ + /* + * keep static names so that we can output static pubdefs and get nicer + * -d1 debugging + */ sym.name = CPermAlloc( strlen( hsym->name ) + 1 ); strcpy( sym.name, hsym->name ); sym.info.backinfo = NULL; @@ -938,10 +970,10 @@ void EndBlock( void ) FreeTags(); FreeSym(); /* sym_list = FreeSym(); */ if( SymLevel != 0 ) { -/* CurFunc->u.func.locals = FreeVars( sym_list ); */ +// CurFunc->u.func.locals = FreeVars( sym_list ); if( SymLevel == 1 ) { AsgnSegs( CurFunc->u.func.locals ); -/* DumpWeights( CurFunc->u.func.locals ); */ +// DumpWeights( CurFunc->u.func.locals ); } else { AsgnSegs( GetBlockSymList() ); } diff --git a/bld/cc/c/ctype.c b/bld/cc/c/ctype.c index b680468e5a..5871d86ff3 100644 --- a/bld/cc/c/ctype.c +++ b/bld/cc/c/ctype.c @@ -48,7 +48,9 @@ static void CheckBitfieldType( TYPEPTR typ ); } #endif -/* matches enum DataType in ctypes.h */ +/* + * matches enum DataType in ctypes.h + */ static unsigned char CTypeSizes[] = { #define pick1(enum,cgtype,x86asmtype,name,size) size, #include "cdatatyp.h" @@ -605,8 +607,10 @@ static void DeclSpecifiers( bool *plain_int, decl_info *info ) case T_ID: if( typ != NULL || bmask != M_NONE ) goto got_specifier; - /* lookup id in symbol table */ - /* if valid type identifier then OK */ + /* + * lookup id in symbol table + * if valid type identifier then OK + */ if( CurToken == T_ID ) { sym_handle = SymLookTypedef( CalcHashID( Buffer ), Buffer, &sym ); } else { /* T_SAVED_ID */ @@ -681,8 +685,10 @@ static void DeclSpecifiers( bool *plain_int, decl_info *info ) got_specifier: info->stg = specified_stg_class; if( typ != NULL ) { - /* already have a type (TYP_STRUCT, TYP_UNION, TYP_ENUM) */ - /* or an ID that was a typedef name */ + /* + * already have a type (TYP_STRUCT, TYP_UNION, TYP_ENUM) + * or an ID that was a typedef name + */ if( bmask != M_NONE ) { CErr1( ERR_INV_TYPE ); // picked up an int } @@ -772,7 +778,9 @@ static FIELDPTR NewField( FIELDPTR new_field, TYPEPTR decl ) SKIP_TYPEDEFS( typ ); } if( new_field->name[0] == '\0' ) { - /* allow nameless structs and unions */ + /* + * allow nameless structs and unions + */ if( (typ->decl_type != TYP_STRUCT && typ->decl_type != TYP_UNION) || !CompFlags.extensions_enabled ) { CErr1( ERR_INVALID_DECLARATOR ); @@ -781,7 +789,9 @@ static FIELDPTR NewField( FIELDPTR new_field, TYPEPTR decl ) if( typ == decl ) { CErr1( ERR_STRUCT_OR_UNION_INSIDE_ITSELF ); } else if( SizeOfArg( typ ) == 0 ) { /* was TypeSize(typ) */ - /* can't have an array of incomplete type */ + /* + * can't have an array of incomplete type + */ if( typ->decl_type == TYP_ARRAY && ( SizeOfArg( typ->object ) == 0 || !CompFlags.extensions_enabled ) || typ->decl_type != TYP_ARRAY ) { @@ -927,9 +937,11 @@ static DATA_TYPE UnQualifiedType( TYPEPTR typ ) return( TYP_UNDEFINED ); } -/* clear the hash table of all fields that were just defined - in the struct with tag tag */ static void ClearFieldHashTable( TAGPTR tag ) +/******************************************** + * clear the hash table of all fields that were just defined + * in the struct with tag tag + */ { FIELDPTR field; FIELDPTR hash_field; @@ -939,11 +951,15 @@ static void ClearFieldHashTable( TAGPTR tag ) prev_field = NULL; hash_field = FieldHash[field->hash]; if( hash_field == field ) { - /* first entry: easy kick out */ + /* + * first entry: easy kick out + */ FieldHash[field->hash] = field->next_field_same_hash; } else { while( hash_field != NULL ) { - /* search for candidate to kick */ + /* + * search for candidate to kick + */ prev_field = hash_field; hash_field = hash_field->next_field_same_hash; if( hash_field == field ) { @@ -1023,7 +1039,9 @@ static target_size GetFields( TYPEPTR decl ) worst_alignment = 1; bits_available = 1; bits_total = 0; - /* assertion: bits_available != bits_total && ( bits_total / CHAR_BIT ) == 0 */ + /* + * assertion: bits_available != bits_total && ( bits_total / CHAR_BIT ) == 0 + */ struct_size = start; next_offset = start; for(;;) { @@ -1088,10 +1106,14 @@ static target_size GetFields( TYPEPTR decl ) if( width > bits_available || width == 0 ) { scalar_size = TypeSize( typ ); if( bits_available != bits_total ) { - /* some bits have been used; abandon this unit */ + /* + * some bits have been used; abandon this unit + */ next_offset += bits_total / CHAR_BIT; } else if( width == 0 ) { - /* no bits have been used; align to base type */ + /* + * no bits have been used; align to base type + */ next_offset = _RoundUp( next_offset, scalar_size ); } bits_total = scalar_size * CHAR_BIT; @@ -1210,14 +1232,13 @@ static TYPEPTR StructDecl( DATA_TYPE decl_typ, bool packed ) } /* -Next three functions descripe a struct that looks like -struct { - double __ow_real; - double _Imaginary __ow_imaginary; -} -*/ - -/* + * Next three functions describe a struct that looks like + * struct { + * double __ow_real; + * double _Imaginary __ow_imaginary; + * } + */ +#if 0 static void GetComplexFieldTypeSpecifier( decl_info *info, DATA_TYPE data_type ) { info->stg = SC_NONE; // indicate don't want any storage class specifiers @@ -1311,7 +1332,7 @@ static TYPEPTR ComplexDecl( DATA_TYPE decl_typ, bool packed ) return( typ ); } -*/ +#endif static void CheckBitfieldType( TYPEPTR typ ) { @@ -1325,7 +1346,9 @@ static void CheckBitfieldType( TYPEPTR typ ) case TYP_INT: case TYP_UINT: case TYP_BOOL: - /* ANSI C only allows int and unsigned [int]; C99 adds _Bool */ + /* + * ANSI C only allows int and unsigned [int]; C99 adds _Bool + */ return; case TYP_CHAR: case TYP_UCHAR: @@ -1597,7 +1620,9 @@ target_size TypeSizeEx( TYPEPTR typ, bitfield_width *pFieldWidth ) case TYP_STRUCT: size = typ->u.tag->size; if( typ->object != NULL ) { - /* structure has a zero length array as last field */ + /* + * structure has a zero length array as last field + */ typ = typ->object; /* point to TYP_ARRAY entry */ size += SizeOfArg( typ ); } @@ -1619,7 +1644,8 @@ target_size TypeSizeEx( TYPEPTR typ, bitfield_width *pFieldWidth ) return( size ); } -/* Return an integer type of specified size, or NULL in case of failure. +/* + * Return an integer type of specified size, or NULL in case of failure. * The type will be signed if 'sign' is true. The type will have exactly * requested size if 'exact' is true, or the next larger type will be * returned (eg. 64-bit integer if 6 byte size is requested). @@ -1633,7 +1659,9 @@ TYPEPTR GetIntTypeBySize( target_size size, bool sign, bool exact ) TYPEPTR typ = NULL; unsigned i; - /* Make sure the types are laid out the way we expect */ + /* + * Make sure the types are laid out the way we expect + */ assert( TYP_BOOL == 0 ); assert( TYP_CHAR == 1 ); assert( TYP_FLOAT == TYP_ULONG64 + 1 ); @@ -1655,7 +1683,9 @@ TYPEPTR GetIntTypeBySize( target_size size, bool sign, bool exact ) void TypesPurge( void ) { #if 0 - /* The type entries are in permanent memory, so they can't be freed */ + /* + * The type entries are in permanent memory, so they can't be freed + */ TYPEPTR temp; while( TypeHead != NULL ) { diff --git a/bld/cc/c/dwarf.c b/bld/cc/c/dwarf.c index 07f190dd6a..90e9a8af1f 100644 --- a/bld/cc/c/dwarf.c +++ b/bld/cc/c/dwarf.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -66,7 +66,9 @@ static void dwarfFile( unsigned filenum ) FNAMEPTR flist; char *fname; - // if current file changed, call DWDeclFile + /* + * if current file changed, call DWDeclFile + */ if( filenum != Current_File_Index ) { flist = FileIndexToFName(filenum); fname = FNameFullPath( flist ); @@ -104,7 +106,9 @@ static void dwarfStructInfo( TAGPTR tag ) if( typ->decl_type == TYP_FIELD || typ->decl_type == TYP_UFIELD ) { fld_dh = dwarfType( GetType( typ->u.f.field_type ), DC_DEFAULT ); if( xref != NULL ) { //stupid struct { int x; int y[] ) = init thing - // Also watch for side effects with the DWDeclPos and a dwtype + /* + * Also watch for side effects with the DWDeclPos and a dwtype + */ dwarfLocation( &xref->src_loc ); } dh = DWAddBitField( Client, @@ -556,16 +560,16 @@ static void dwarfEmitVariables( SYM_HANDLE sym_handle ) if( (sym->flags & SYM_DEFINED) == 0 ) { dh = dwarfFunctionDecl( sym ); } -// printf( "func: %s", sym->name ); +// printf( "func: %s", sym->name ); } else if( sym->attribs.stg_class == SC_TYPEDEF ) { dh = dwarfType( typ, DC_DEFAULT ); -// printf( "typedef: %s", sym->name ); +// printf( "typedef: %s", sym->name ); } else { dh = dwarfVariable( sym ); -// printf( "var:: %s", sym->name ); +// printf( "var:: %s", sym->name ); } sym->dwarf_handle = dh; -// printf( " defined on line %u\n", sym->d.defn_line ); +// printf( " defined on line %u\n", sym->d.defn_line ); } } } diff --git a/bld/cc/c/ftoa.c b/bld/cc/c/ftoa.c index 562740c91f..225c55b63e 100644 --- a/bld/cc/c/ftoa.c +++ b/bld/cc/c/ftoa.c @@ -51,7 +51,9 @@ char *ftoa( FLOATVAL *flt ) cvt.expchar = 0; __LDcvt( &flt->ld, &cvt, mant ); if( !isdigit( (unsigned char)*mant ) ) { - /* special magical thingy (nan, inf, ...) */ + /* + * special magical thingy (nan, inf, ...) + */ strcpy( buf, mant ); return( buf ); } diff --git a/bld/cc/c/ideentry.c b/bld/cc/c/ideentry.c index bfb72f9000..23202a5fdc 100644 --- a/bld/cc/c/ideentry.c +++ b/bld/cc/c/ideentry.c @@ -61,7 +61,9 @@ void ConBlip( void ) */ { IDEFN( PrintWithCRLF )( IdeHdl, "." ); - /* we are ignoring return for now */ + /* + * we are ignoring return for now + */ } void ConsErrMsg( cmsg_info *cinfo ) @@ -94,7 +96,9 @@ void ConsErrMsg( cmsg_info *cinfo ) IdeMsgSetSrcLine( &info, cinfo->line ); } IDEFN( PrintWithInfo )( IdeHdl, &info ); - /* we are ignoring return for now */ + /* + * we are ignoring return for now + */ } void ConsErrMsgVerbatim( char const *line ) @@ -106,7 +110,9 @@ void ConsErrMsgVerbatim( char const *line ) IdeMsgInit( &info, IDEMSGSEV_ERROR, line ); IDEFN( PrintWithInfo )( IdeHdl, &info ); - /* we are ignoring return for now */ + /* + * we are ignoring return for now + */ } void BannerMsg( char const *line ) @@ -118,7 +124,9 @@ void BannerMsg( char const *line ) IdeMsgInit( &info, IDEMSGSEV_BANNER, line ); IDEFN( PrintWithInfo )( IdeHdl, &info ); - /* we are ignoring return for now */ + /* + * we are ignoring return for now + */ } void DebugMsg( char const *line ) @@ -130,7 +138,9 @@ void DebugMsg( char const *line ) IdeMsgInit( &info, IDEMSGSEV_DEBUG, line ); IDEFN( PrintWithInfo )( IdeHdl, &info ); - /* we are ignoring return for now */ + /* + * we are ignoring return for now + */ } void NoteMsg( char const *line ) @@ -142,7 +152,9 @@ void NoteMsg( char const *line ) IdeMsgInit( &info, IDEMSGSEV_NOTE_MSG, line ); IDEFN( PrintWithInfo )( IdeHdl, &info ); - /* we are ignoring return for now */ + /* + * we are ignoring return for now + */ } const char *FEGetEnv( char const *name ) @@ -171,7 +183,6 @@ void MyExit( int ret ) // IDE INTERFACE - unsigned IDEAPI IDEGetVersion ( void ) /************************************* * GET IDE VERSION @@ -191,9 +202,9 @@ IDEBool IDEAPI IDEInitDLL ( IDECBHdl idehdl // - handle for this instantiation , IDECallBacks *idecbs // - call backs into IDE , IDEDllHdl *dllhdl ) { // - uninitialized info -//*********************** -// DLL INITIALIZATION -//*********************** +/************************ + * DLL INITIALIZATION + ************************/ IdeHdl = idehdl; IdeCbs = idecbs; *dllhdl = NULL; @@ -321,7 +332,9 @@ int IDEAPI IDERunYourSelf // COMPILE A PROGRAM TBreak(); // clear any pending IDEStopRunning's *fatal_error = false; FatalEnv = JMPBUF_PTR( env ); - /* initialize argv array */ + /* + * initialize argv array + */ argv[0] = (char *)opts; argv[1] = NULL; getFrontEndArgv( argv + 1, infile, outfile ); @@ -382,7 +395,9 @@ int IDEAPI IDERunYourSelfArgv // COMPILE A PROGRAM TBreak(); // clear any pending IDEStopRunning's *fatal_error = false; FatalEnv = JMPBUF_PTR( env ); - /* allocate and initialize argv array */ + /* + * allocate and initialize argv array + */ argv = init_argv( args, argc, infile, outfile ); if( setjmp( env ) != 0 ) { /* if fatal error has occurred */ *fatal_error = true; diff --git a/bld/cc/h/cconst.h b/bld/cc/h/cconst.h index bf24eb68d2..1a28ea484c 100644 --- a/bld/cc/h/cconst.h +++ b/bld/cc/h/cconst.h @@ -35,7 +35,9 @@ #endif #if _CPU != 8086 - /* enable Structured Exception Handling for all 32-bit targets */ + /* + * enable Structured Exception Handling for all 32-bit targets + */ #define __SEH__ #endif diff --git a/bld/cc/h/cdatatyp.h b/bld/cc/h/cdatatyp.h index 6e5ef004a5..c72a3fcf9f 100644 --- a/bld/cc/h/cdatatyp.h +++ b/bld/cc/h/cdatatyp.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -28,12 +29,13 @@ * ****************************************************************************/ -/* it is used in definition for - CGDataType[] table in cgen.c - AsmDataType[] table in cpragx86.c - CTypenames[] table in cdump.c - CTypeSizes[] table in ctype.c -*/ +/* + * it is used in definition for + * CGDataType[] table in cgen.c + * AsmDataType[] table in cpragx86.c + * CTypenames[] table in cdump.c + * CTypeSizes[] table in ctype.c + */ /* enum cgtype asmtype name size */ pick1( BOOL, TY_UINT_1, SYM_INT1, "_Bool", TARGET_BOOL ) diff --git a/bld/cc/h/specmac.h b/bld/cc/h/specmac.h index 59b1c3f33f..d1d582ffa3 100644 --- a/bld/cc/h/specmac.h +++ b/bld/cc/h/specmac.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2019 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -37,6 +37,8 @@ pick( "__STDC__", MACRO_STDC, MFLAG_NONE ) pick( "__STDC_HOSTED__", MACRO_STDC_HOSTED, MFLAG_NONE ) pick( "__STDC_VERSION__", MACRO_STDC_VERSION, MFLAG_NONE ) pick( "__TIME__", MACRO_TIME, MFLAG_NONE ) -/* compile time macros */ +/* + * compile time macros + */ pick( "__FUNCTION__", MACRO_FUNCTION, MFLAG_NONE ) pick( "__func__", MACRO_FUNC, MFLAG_HIDDEN ) diff --git a/bld/cc/h/target16.h b/bld/cc/h/target16.h index 7559673273..36dc27d2c6 100644 --- a/bld/cc/h/target16.h +++ b/bld/cc/h/target16.h @@ -30,7 +30,9 @@ ****************************************************************************/ -/* target16.h: target types for 16-bit machine */ +/* + * target16.h: target types for 16-bit machine + */ #define TARGET_CHAR 1 #define TARGET_SHORT 2 diff --git a/bld/cc/h/target32.h b/bld/cc/h/target32.h index 17c74bcc51..dc90fed8ba 100644 --- a/bld/cc/h/target32.h +++ b/bld/cc/h/target32.h @@ -30,7 +30,9 @@ ****************************************************************************/ -/* target32.h: target types for 32-bit machine */ +/* + * target32.h: target types for 32-bit machine + */ #define TARGET_CHAR 1 #define TARGET_SHORT 2 From 3426ac0d98f0fe0a1a035870aa7445fa0302d500 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Wed, 27 Sep 2023 10:18:23 +0200 Subject: [PATCH 166/258] cleanup C compiler code --- bld/cc/c/cenum.c | 47 +++++++++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/bld/cc/c/cenum.c b/bld/cc/c/cenum.c index 889986b7b0..b837b6b410 100644 --- a/bld/cc/c/cenum.c +++ b/bld/cc/c/cenum.c @@ -44,19 +44,19 @@ # define i64val(h,l) { l, h } #endif +#if _CPU == 8086 +#define ENUM_INT ENUM_S16 +#else +#define ENUM_INT ENUM_S32 +#endif + enum enum_rng { ENUM_UNDEF = -1, ENUM_S8, ENUM_U8, ENUM_S16, -#if TARGET_INT == 2 - ENUM_INT = ENUM_S16, -#endif ENUM_U16, ENUM_S32, -#if TARGET_INT == 4 - ENUM_INT = ENUM_S32, -#endif ENUM_U32, ENUM_S64, ENUM_U64, @@ -84,24 +84,21 @@ struct { DATA_TYPE decl_type; target_size size; } ItypeTable[ENUM_SIZE] = { - { TYP_CHAR, TARGET_CHAR }, //S8 - { TYP_UCHAR,TARGET_CHAR }, //U8 -#if TARGET_INT == 2 - { TYP_INT, TARGET_INT }, //S16 - { TYP_UINT, TARGET_INT }, //U16 -#else - { TYP_SHORT, TARGET_SHORT }, //S16 - { TYP_USHORT,TARGET_SHORT }, //U16 -#endif -#if TARGET_INT == 4 - { TYP_INT, TARGET_INT }, //S32 - { TYP_UINT, TARGET_INT }, //U32 + { TYP_CHAR, TARGET_CHAR }, //S8 + { TYP_UCHAR, TARGET_CHAR }, //U8 +#if _CPU == 8086 + { TYP_INT, TARGET_INT }, //S16 + { TYP_UINT, TARGET_INT }, //U16 + { TYP_LONG, TARGET_LONG }, //S32 + { TYP_ULONG, TARGET_LONG }, //U32 #else - { TYP_LONG, TARGET_LONG }, //S32 - { TYP_ULONG, TARGET_LONG }, //U32 + { TYP_SHORT, TARGET_SHORT }, //S16 + { TYP_USHORT, TARGET_SHORT }, //U16 + { TYP_INT, TARGET_INT }, //S32 + { TYP_UINT, TARGET_INT }, //U32 #endif - { TYP_LONG64, TARGET_LONG64 },//S64 - { TYP_ULONG64, TARGET_LONG64 },//U64 + { TYP_LONG64, TARGET_LONG64 }, //S64 + { TYP_ULONG64, TARGET_LONG64 }, //U64 }; void EnumInit( void ) @@ -269,8 +266,10 @@ TYPEPTR EnumDecl( type_modifiers flags ) } } error = ENUM_UNDEF; - if( !CompFlags.extensions_enabled && ( index > ENUM_INT )) { - error = ENUM_INT; + if( index > ENUM_INT ) { + if( !CompFlags.extensions_enabled ) { + error = ENUM_INT; + } } if( index >= ENUM_SIZE ) { /* From 65b6f76218c295b5920931cd61a32720a3a6d0dd Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Thu, 28 Sep 2023 14:28:28 +0200 Subject: [PATCH 167/258] reformat source files --- bld/cg/intel/c/x86call.c | 14 +++++++------- bld/cg/intel/c/x86proc.c | 40 ++++++++++++++++++++++++++++------------ bld/cg/intel/c/x86reg.c | 12 ++++++------ 3 files changed, 41 insertions(+), 25 deletions(-) diff --git a/bld/cg/intel/c/x86call.c b/bld/cg/intel/c/x86call.c index 52747295a9..2b3fdbb28c 100644 --- a/bld/cg/intel/c/x86call.c +++ b/bld/cg/intel/c/x86call.c @@ -63,9 +63,9 @@ static void AddCall( instruction *ins, cn call ); #if _TARGET & _TARG_80386 -static void Far16Parms( cn call ) { -/*************************************/ - +static void Far16Parms( cn call ) +/***********************************/ +{ instruction *ins; type_length parm_size; pn parm, next; @@ -157,10 +157,10 @@ an BGCall( cn call, bool use_return, bool in_line ) state = call->state; result = BGNewTemp( call->tipe ); call_ins = call->ins; - -/* If we have a return value that won't fit in a register*/ -/* pass a pointer to result as the first parm*/ - + /* + * If we have a return value that won't fit in a register + * pass a pointer to result as the first parm + */ if( call_ins->type_class == XX ) { if( _RoutineIsFar16( state->attr ) ) { if( state->attr & ROUTINE_ALLOCS_RETURN ) { diff --git a/bld/cg/intel/c/x86proc.c b/bld/cg/intel/c/x86proc.c index 619c8117b5..d846669387 100644 --- a/bld/cg/intel/c/x86proc.c +++ b/bld/cg/intel/c/x86proc.c @@ -470,7 +470,9 @@ static void AllocStack( void ) { type_length size; - /* keep stack aligned */ + /* + * keep stack aligned + */ size = _RoundUp( CurrProc->locals.size, WORD_SIZE ); CurrProc->locals.size = size; if( BlockByBlock ) { @@ -528,14 +530,18 @@ static int PushAll( void ) Gcld(); if( HW_COvlap( CurrProc->state.unalterable, HW_DS ) ) { DoLoadDS(); - // If ES is also unalterable, copy DS to ES; else things - // like memcpy() are likely to blow up + /* + * If ES is also unalterable, copy DS to ES; else things + * like memcpy() are likely to blow up + */ if( HW_COvlap( CurrProc->state.unalterable, HW_ES ) ) { QuickSave( HW_DS, OP_PUSH ); QuickSave( HW_ES, OP_POP ); } } - /* 8 general purpose registers + 4 segment registers */ + /* + * 8 general purpose registers + 4 segment registers + */ return( 12 * WORD_SIZE ); } @@ -575,7 +581,9 @@ static void DoEnter( level_depth level ) { type_length size; - /* keep stack aligned */ + /* + * keep stack aligned + */ size = _RoundUp( CurrProc->locals.size, WORD_SIZE ); CurrProc->locals.size = size; @@ -652,7 +660,9 @@ static void CalcUsedRegs( void ) if( result != NULL && result->n.class == N_REGISTER ) { HW_TurnOn( used, result->r.reg ); } - /* place holder for big label doesn't really zap anything */ + /* + * place holder for big label doesn't really zap anything + */ if( ins->head.opcode != OP_NOP ) { HW_TurnOn( used, ins->zap->reg ); if( HW_COvlap( ins->zap->reg, HW_xSP ) ) { @@ -748,7 +758,9 @@ static void DoEpilog( void ) if( CurrProc->state.attr & ROUTINE_NEEDS_PROLOG ) { size = CurrProc->locals.size + CurrProc->targ.push_local_size; if( (CurrProc->prolog_state & GENERATE_RESET_SP) || size != 0 ) { - /* sp is not pointing at saved registers already */ + /* + * sp is not pointing at saved registers already + */ if( CurrProc->targ.sp_frame ) { if( CurrProc->targ.sp_align ) { GenRegMove( HW_xBP, HW_xSP ); @@ -923,7 +935,7 @@ void GenProlog( void ) if( _RoutineIsFar16( CurrProc->state.attr ) ) { label = GenFar16Thunk( CurrProc->label, CurrProc->parms.size, CurrProc->state.attr & ROUTINE_REMOVES_PARMS ); - // CurrProc->label = label; - ugly mess if following are combined +// CurrProc->label = label; /* ugly mess if following are combined */ } #endif @@ -966,7 +978,9 @@ void GenProlog( void ) } if( attr & FE_NAKED ) { - // don't do anything - empty prologue + /* + * don't do anything - empty prologue + */ } else if( _RoutineIsInterrupt( CurrProc->state.attr ) ) { ret_size = -PushAll(); CurrProc->targ.base_adjust = 0; @@ -982,9 +996,11 @@ void GenProlog( void ) GenCypWindowsProlog(); } else { #if _TARGET & _TARG_8086 - // Windows prologs zap AX, so warn idiot user if we - // generate one for a routine in which AX is live - // upon entry to routine, or unalterable. + /* + * Windows prologs zap AX, so warn idiot user if we + * generate one for a routine in which AX is live + * upon entry to routine, or unalterable. + */ if( HW_COvlap( CurrProc->state.unalterable, HW_xAX ) || HW_COvlap( CurrProc->state.parm.used, HW_xAX ) ) { FEMessage( MSG_ERROR, "exported routine with AX live on entry" ); diff --git a/bld/cg/intel/c/x86reg.c b/bld/cg/intel/c/x86reg.c index aece4b7cee..f27232a6d2 100644 --- a/bld/cg/intel/c/x86reg.c +++ b/bld/cg/intel/c/x86reg.c @@ -227,9 +227,9 @@ void UpdateReturn( call_state *state, type_def *tipe, type_class_def type_cla return; if( HW_CEqual( state->return_reg, HW_EMPTY ) ) return; - // if( !HW_Ovlap( state->return_reg, state->unalterable ) && - // IsRegClass( state->return_reg, WD ) ) - // return; +// if( !HW_Ovlap( state->return_reg, state->unalterable ) +// && IsRegClass( state->return_reg, WD ) ) +// return; if( IsRegClass( state->return_reg, WD ) ) return; FEMessage( MSG_BAD_RETURN_REGISTER, aux ); @@ -239,9 +239,9 @@ void UpdateReturn( call_state *state, type_def *tipe, type_class_def type_cla normal = ReturnReg( type_class, _NPX( state->attr ) ); if( HW_Equal( state->return_reg, normal ) ) return; - // if( !HW_Ovlap( state->return_reg, state->unalterable ) && - // IsRegClass( state->return_reg, type_class ) ) - // return; +// if( !HW_Ovlap( state->return_reg, state->unalterable ) +// && IsRegClass( state->return_reg, type_class ) ) +// return; if( IsRegClass( state->return_reg, type_class ) ) return; FEMessage( MSG_BAD_RETURN_REGISTER, aux ); From dec7a82c71d319d1c6a58887281612365f875bcb Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Thu, 28 Sep 2023 15:03:42 +0200 Subject: [PATCH 168/258] reformat source files --- bld/cg/intel/c/x86call.c | 5 +-- bld/cg/intel/c/x86proc.c | 66 ++++++++++++++++++++++++++-------------- bld/cg/intel/c/x86reg.c | 6 ++-- 3 files changed, 50 insertions(+), 27 deletions(-) diff --git a/bld/cg/intel/c/x86call.c b/bld/cg/intel/c/x86call.c index 2b3fdbb28c..af2b53b030 100644 --- a/bld/cg/intel/c/x86call.c +++ b/bld/cg/intel/c/x86call.c @@ -169,7 +169,7 @@ an BGCall( cn call, bool use_return, bool in_line ) HW_CAsgn( state->return_reg, HW_EBX ); } } - if( ( state->attr & ROUTINE_ALLOCS_RETURN ) == 0 ) { + if( (state->attr & ROUTINE_ALLOCS_RETURN) == 0 ) { if( HW_CEqual( state->return_reg, HW_EMPTY ) ) { ret_ptr = AllocTemp( WD ); } else { @@ -261,7 +261,8 @@ an BGCall( cn call, bool use_return, bool in_line ) AddIns( ret_ins ); } } - if( state->parm.offset != 0 && ( state->attr & ROUTINE_REMOVES_PARMS ) == 0 ) { + if( state->parm.offset != 0 + && (state->attr & ROUTINE_REMOVES_PARMS) == 0 ) { reg_name = AllocRegName( HW_xSP ); AddIns( MakeBinary( OP_ADD, reg_name, AllocS32Const( state->parm.offset ), reg_name, WD ) ); diff --git a/bld/cg/intel/c/x86proc.c b/bld/cg/intel/c/x86proc.c index d846669387..d8a93ecc15 100644 --- a/bld/cg/intel/c/x86proc.c +++ b/bld/cg/intel/c/x86proc.c @@ -65,7 +65,7 @@ #define WORDS_COUNT(size) (((size) + WORD_SIZE - 1) / WORD_SIZE) #define WINDOWS_CHEAP ( ( _IsModel( CGSW_GEN_DLL_RESIDENT_CODE ) \ - && ( CurrProc->state.attr & ROUTINE_LOADS_DS ) ) \ + && (CurrProc->state.attr & ROUTINE_LOADS_DS) ) \ || ( _IsTargetModel( CGSW_X86_CHEAP_WINDOWS ) \ && (CurrProc->prolog_state & (GENERATE_EXPORT | GENERATE_FAT_PROLOG)) == 0 ) ) @@ -129,8 +129,9 @@ static bool ScanInstructions( void ) CurrProc->contains_call = true; } else { addr = ins->operands[CALL_OP_ADDR]; - if( addr->n.class != N_MEMORY || addr->m.memory_type != CG_LBL || - !AskIfRTLabel( addr->v.symbol ) ) { + if( addr->n.class != N_MEMORY + || addr->m.memory_type != CG_LBL + || !AskIfRTLabel( addr->v.symbol ) ) { CurrProc->contains_call = true; } } @@ -185,7 +186,8 @@ static void ScanForFDOps( void ) for( blk = HeadBlock; blk != NULL; blk = blk->next_block ) { depth = blk->depth; for( ins = blk->ins.head.next; ins->head.opcode != OP_BLOCK; ins = ins->head.next ) { - if( ins->type_class == FD || ins->type_class == FL ) { + if( ins->type_class == FD + || ins->type_class == FL ) { for( i = ins->num_operands; i-- > 0; ) { ChkFDOp( ins->operands[i], depth ); } @@ -255,7 +257,8 @@ static void AdjustPushLocals( void ) for( ins = HeadBlock->ins.head.next; ins->head.opcode != OP_BLOCK; ins = ins->head.next ) { if( DoesSomething( ins ) ) break; - if( ins->head.opcode == OP_MOV && ins->head.state == OPERANDS_NEED_WORK ) { + if( ins->head.opcode == OP_MOV + && ins->head.state == OPERANDS_NEED_WORK ) { QuickSave( ins->operands[0]->r.reg, OP_PUSH ); AdjustPushLocal( ins->result ); } @@ -312,11 +315,12 @@ static bool NeedStackCheck( void ) static void DoStackCheck( void ) /******************************/ { - if( CurrProc->prolog_state & ( GENERATE_THUNK_PROLOG | GENERATE_RDOSDEV_PROLOG ) ) + if( CurrProc->prolog_state & (GENERATE_THUNK_PROLOG | GENERATE_RDOSDEV_PROLOG) ) return; #if _TARGET & _TARG_80386 if( CurrProc->prolog_state & GENERATE_GROW_STACK ) { - if( BlockByBlock || CurrProc->locals.size >= 4096 ) { + if( BlockByBlock + || CurrProc->locals.size >= 4096 ) { GenUnkPush( &CurrProc->targ.stack_check ); DoRTCall( RT_GROW, true ); } @@ -480,7 +484,8 @@ static void AllocStack( void ) if( CurrProc->prolog_state & GENERATE_TOUCH_STACK ) { GenTouchStack( true ); } - } else if( size <= 2 * WORD_SIZE && OptForSize > 50 ) { + } else if( size <= 2 * WORD_SIZE + && OptForSize > 50 ) { while( size > 0 ) { QuickSave( HW_xAX, OP_PUSH ); size -= WORD_SIZE; @@ -595,7 +600,8 @@ static void DoEnter( level_depth level ) } } else { GenEnter( size, level ); - if( size != 0 && ( CurrProc->prolog_state & GENERATE_TOUCH_STACK ) ) { + if( size != 0 + && (CurrProc->prolog_state & GENERATE_TOUCH_STACK) ) { GenTouchStack( false ); } } @@ -610,10 +616,13 @@ static void Enter( void ) lex_level = CurrProc->lex_level; #if _TARGET & _TARG_80386 - if( !CurrProc->targ.sp_frame && _CPULevel( CPU_186 ) && CurrProc->locals.size < 65536 + if( !CurrProc->targ.sp_frame + && _CPULevel( CPU_186 ) + && CurrProc->locals.size < 65536 && ( lex_level > 0 || ( CurrProc->locals.size != 0 && OptForSize > 50 ) ) ) { #else - if( !CurrProc->targ.sp_frame && _CPULevel( CPU_186 ) + if( !CurrProc->targ.sp_frame + && _CPULevel( CPU_186 ) && ( lex_level > 0 || ( CurrProc->locals.size != 0 && OptForSize > 50 ) ) ) { #endif DoEnter( lex_level ); @@ -621,7 +630,8 @@ static void Enter( void ) CurrProc->state.attr |= ROUTINE_NEEDS_PROLOG; } else { if( NeedBPProlog() ) { - if( !CurrProc->targ.sp_frame || CurrProc->targ.sp_align ) { + if( !CurrProc->targ.sp_frame + || CurrProc->targ.sp_align ) { HW_CTurnOn( CurrProc->state.used, HW_xBP ); CurrProc->parms.base += WORD_SIZE; QuickSave( HW_xBP, OP_PUSH ); @@ -657,7 +667,8 @@ static void CalcUsedRegs( void ) for( blk = HeadBlock; blk != NULL; blk = blk->next_block ) { for( ins = blk->ins.head.next; ins->head.opcode != OP_BLOCK; ins = ins->head.next ) { result = ins->result; - if( result != NULL && result->n.class == N_REGISTER ) { + if( result != NULL + && result->n.class == N_REGISTER ) { HW_TurnOn( used, result->r.reg ); } /* @@ -671,7 +682,8 @@ static void CalcUsedRegs( void ) } } } - if( !CurrProc->targ.sp_frame || CurrProc->targ.sp_align ) { + if( !CurrProc->targ.sp_frame + || CurrProc->targ.sp_align ) { HW_CTurnOff( used, HW_xBP ); } HW_TurnOn( CurrProc->state.used, used ); @@ -685,7 +697,9 @@ static int Push( hw_reg_set to_push ) int i; size = 0; - if( _IsntModel( CGSW_GEN_NO_OPTIMIZATION ) && CurrProc->targ.sp_frame && !CurrProc->targ.sp_align ) { + if( _IsntModel( CGSW_GEN_NO_OPTIMIZATION ) + && CurrProc->targ.sp_frame + && !CurrProc->targ.sp_align ) { FlowSave( &to_push ); } for( i = 0; i < sizeof( PushRegs ) / sizeof( PushRegs[0] ) - 1; i++ ) { @@ -705,7 +719,9 @@ static void Pop( hw_reg_set to_pop ) { int i; - if( _IsntModel( CGSW_GEN_NO_OPTIMIZATION ) && CurrProc->targ.sp_frame && !CurrProc->targ.sp_align ) { + if( _IsntModel( CGSW_GEN_NO_OPTIMIZATION ) + && CurrProc->targ.sp_frame + && !CurrProc->targ.sp_align ) { FlowRestore( &to_pop ); } for( i = sizeof( PushRegs ) / sizeof( PushRegs[0] ) - 1; i-- > 0 ; ) { @@ -746,7 +762,7 @@ static void DoEpilog( void ) HW_CTurnOff( to_pop, HW_FLTS ); if( CHAIN_FRAME ) { if( (CurrProc->state.attr & ROUTINE_NEEDS_PROLOG) - || CurrProc->locals.size+CurrProc->targ.push_local_size != 0 ) { + || ( CurrProc->locals.size + CurrProc->targ.push_local_size ) != 0 ) { if( CurrProc->targ.base_adjust == 0 ) { GenRegMove( HW_xBP, HW_xSP ); } else { @@ -757,7 +773,8 @@ static void DoEpilog( void ) } else { if( CurrProc->state.attr & ROUTINE_NEEDS_PROLOG ) { size = CurrProc->locals.size + CurrProc->targ.push_local_size; - if( (CurrProc->prolog_state & GENERATE_RESET_SP) || size != 0 ) { + if( (CurrProc->prolog_state & GENERATE_RESET_SP) + || size != 0 ) { /* * sp is not pointing at saved registers already */ @@ -770,7 +787,8 @@ static void DoEpilog( void ) } } else if( CurrProc->targ.base_adjust != 0 ) { GenLeaSP( -CurrProc->targ.base_adjust ); - } else if( _CPULevel( CPU_186 ) && (!_CPULevel( CPU_486 ) || OptForSize > 50) ) { + } else if( _CPULevel( CPU_186 ) + && (!_CPULevel( CPU_486 ) || OptForSize > 50) ) { GenLeave(); HW_CTurnOff( to_pop, HW_xBP ); } else { @@ -973,7 +991,8 @@ void GenProlog( void ) to_push = SaveRegs(); HW_CTurnOff( to_push, HW_FLTS ); - if( !CurrProc->targ.sp_frame || CurrProc->targ.sp_align ) { + if( !CurrProc->targ.sp_frame + || CurrProc->targ.sp_align ) { HW_CTurnOff( to_push, HW_xBP ); } @@ -1001,8 +1020,8 @@ void GenProlog( void ) * generate one for a routine in which AX is live * upon entry to routine, or unalterable. */ - if( HW_COvlap( CurrProc->state.unalterable, HW_xAX ) || - HW_COvlap( CurrProc->state.parm.used, HW_xAX ) ) { + if( HW_COvlap( CurrProc->state.unalterable, HW_xAX ) + || HW_COvlap( CurrProc->state.parm.used, HW_xAX ) ) { FEMessage( MSG_ERROR, "exported routine with AX live on entry" ); } #endif @@ -1128,7 +1147,8 @@ bool BaseIsSP( name *op ) { if( !CurrProc->targ.sp_frame ) return( false ); - if( CurrProc->targ.sp_align && ( op->t.temp_flags & STACK_PARM ) ) { + if( CurrProc->targ.sp_align + && (op->t.temp_flags & STACK_PARM) ) { return( false ); } return( true ); diff --git a/bld/cg/intel/c/x86reg.c b/bld/cg/intel/c/x86reg.c index f27232a6d2..c3fa2a8239 100644 --- a/bld/cg/intel/c/x86reg.c +++ b/bld/cg/intel/c/x86reg.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -210,7 +210,9 @@ void UpdateReturn( call_state *state, type_def *tipe, type_class_def type_cla { hw_reg_set normal; - if( _FPULevel( FPU_87 ) && _NPX( state->attr ) && (tipe->attr & TYPE_FLOAT) ) { + if( _FPULevel( FPU_87 ) + && _NPX( state->attr ) + && (tipe->attr & TYPE_FLOAT) ) { HW_COnlyOn( state->return_reg, HW_ST0 ); } else { HW_CTurnOff( state->return_reg, HW_FLTS ); From 9950bd3db42cc2c61acc92844d6021c4d976e6a6 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Thu, 28 Sep 2023 19:23:36 +0200 Subject: [PATCH 169/258] reformat source file --- bld/wasm/h/asminlin.h | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/bld/wasm/h/asminlin.h b/bld/wasm/h/asminlin.h index 8815b16367..a97b556a71 100644 --- a/bld/wasm/h/asminlin.h +++ b/bld/wasm/h/asminlin.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -55,7 +55,9 @@ enum sym_state { }; -/* It must correspond with CvtTable in asmsym.c */ +/* + * It must correspond with CvtTable in asmsym.c + */ enum sym_type { SYM_INT1, /* a byte variable */ SYM_INT2, /* a word variable */ @@ -107,21 +109,19 @@ typedef enum prefix_reg { extern void *AsmQuerySymbol( const char *name ); /* - The following function is supplied by the user of the mini-assembler. - It returns either: - SYM_UNDEFINED - the name is not in the user's symbol table - SYM_EXTERNAL - the name is a static symbol in the user's - symbol table - SYM_STACK - the symbol is an auto symbol in the user's - symbol table -*/ + * The following function is supplied by the user of the mini-assembler. + * It returns either: + * SYM_UNDEFINED - the name is not in the user's symbol table + * SYM_EXTERNAL - the name is a static symbol in the user's symbol table + * SYM_STACK - the symbol is an auto symbol in the user's symbol table + */ extern enum sym_state AsmQueryState( void *handle ); /* - The following function is supplied by the user of the mini-assembler. - It returns the type of the symbol via one of the 'enum sym_type' - constants. -*/ + * The following function is supplied by the user of the mini-assembler. + * It returns the type of the symbol via one of the 'enum sym_type' + * constants. + */ extern enum sym_type AsmQueryType( void *handle ); #endif From 74ac7a32f8c9b78197d65c3a26b6ac967f619095 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Fri, 29 Sep 2023 10:32:12 +0200 Subject: [PATCH 170/258] update diagnose output for C++ tests --- bld/plustest/diagnose/diag386.chk | 14 +++++++------- bld/plustest/diagnose/diagi86.chk | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/bld/plustest/diagnose/diag386.chk b/bld/plustest/diagnose/diag386.chk index 76c22b0c45..384d05466f 100644 --- a/bld/plustest/diagnose/diag386.chk +++ b/bld/plustest/diagnose/diag386.chk @@ -3058,10 +3058,10 @@ Warning! W014: no reference to symbol 'g' definition: 'int g' File: source\diag0163.c (18,15): Error! E580: cannot find a constructor for given initializer argument list - definition: '__1jlcfibar::__1jlcfibar( __1jlcfibar const & )' + definition: '__1JLCFIbar::__1JLCFIbar( __1JLCFIbar const & )' cannot convert argument 1 defined at: (18,15) source conversion type is 'int (lvalue)' - target conversion type is '__1jlcfibar const (lvalue)' + target conversion type is '__1JLCFIbar const (lvalue)' (28,1): Error! E585: syntax error; missing start of function body after constructor initializer constructor initializer started at: (25,20) (28,1): Error! E121: syntax error @@ -7071,7 +7071,7 @@ File: source\diag0223.c (516,5): Error! E029: symbol 'aa2' has not been declared (517,9): Error! E166: cannot convert right pointer to type of left operand source conversion type is 'char *' - target conversion type is '__1nda5aptr *' + target conversion type is '__1NDA5Aptr *' (522,21): Error! E006: syntax error; probable cause: missing ';' (524,11): Error! E057: cannot take address of a bit-field (525,18): Error! E394: reference object must be initialized @@ -8001,7 +8001,7 @@ File: source\diag0232.c (92,12): Error! E334: conversion ambiguity: [argument] to [argument type in prototype] source conversion type is 'x75::D *' target conversion type is 'x75::A *' -(97,7): Warning! W735: '//' style comment continues on next line +(97,11): Warning! W735: '//' style comment continues on next line (112,12): Error! E334: conversion ambiguity: [argument] to [argument type in prototype] source conversion type is 'x95::D *' target conversion type is 'x95::A *' @@ -8174,9 +8174,9 @@ File: source\diag0238.c pure virtual function 'int A::pure( void )' defined at: (3,17) File: source\diag0239.c (5,17): Error! E125: invalid redefinition of the typedef name 'bool' -(6,17): Warning! W735: '//' style comment continues on next line -(7,2): Warning! W735: '//' style comment continues on next line -(10,16): Warning! W735: '//' style comment continues on next line +(6,32): Warning! W735: '//' style comment continues on next line +(7,9): Warning! W735: '//' style comment continues on next line +(10,34): Warning! W735: '//' style comment continues on next line (12,17): Warning! W761: octal escape sequence out of range; truncated (12,21): Warning! W761: octal escape sequence out of range; truncated (12,25): Warning! W761: octal escape sequence out of range; truncated diff --git a/bld/plustest/diagnose/diagi86.chk b/bld/plustest/diagnose/diagi86.chk index d1caebcd86..1eb8b5b279 100644 --- a/bld/plustest/diagnose/diagi86.chk +++ b/bld/plustest/diagnose/diagi86.chk @@ -3058,10 +3058,10 @@ Warning! W014: no reference to symbol 'g' definition: 'int g' File: source\diag0163.c (18,15): Error! E580: cannot find a constructor for given initializer argument list - definition: '__1jlcfibar::__1jlcfibar( __1jlcfibar const & )' + definition: '__1JLCFIbar::__1JLCFIbar( __1JLCFIbar const & )' cannot convert argument 1 defined at: (18,15) source conversion type is 'int (lvalue)' - target conversion type is '__1jlcfibar const (lvalue)' + target conversion type is '__1JLCFIbar const (lvalue)' (28,1): Error! E585: syntax error; missing start of function body after constructor initializer constructor initializer started at: (25,20) (28,1): Error! E121: syntax error @@ -7067,7 +7067,7 @@ File: source\diag0223.c (516,5): Error! E029: symbol 'aa2' has not been declared (517,9): Error! E166: cannot convert right pointer to type of left operand source conversion type is 'char *' - target conversion type is '__gblukptr *' + target conversion type is '__GBLUKptr *' (522,21): Error! E006: syntax error; probable cause: missing ';' (524,11): Error! E057: cannot take address of a bit-field (525,18): Error! E394: reference object must be initialized @@ -7997,7 +7997,7 @@ File: source\diag0232.c (92,12): Error! E334: conversion ambiguity: [argument] to [argument type in prototype] source conversion type is 'x75::D *' target conversion type is 'x75::A *' -(97,7): Warning! W735: '//' style comment continues on next line +(97,11): Warning! W735: '//' style comment continues on next line (112,12): Error! E334: conversion ambiguity: [argument] to [argument type in prototype] source conversion type is 'x95::D *' target conversion type is 'x95::A *' @@ -8171,9 +8171,9 @@ File: source\diag0238.c pure virtual function 'int A::pure( void )' defined at: (3,17) File: source\diag0239.c (5,17): Error! E125: invalid redefinition of the typedef name 'bool' -(6,17): Warning! W735: '//' style comment continues on next line -(7,2): Warning! W735: '//' style comment continues on next line -(10,16): Warning! W735: '//' style comment continues on next line +(6,32): Warning! W735: '//' style comment continues on next line +(7,9): Warning! W735: '//' style comment continues on next line +(10,34): Warning! W735: '//' style comment continues on next line (12,17): Warning! W761: octal escape sequence out of range; truncated (12,21): Warning! W761: octal escape sequence out of range; truncated (12,25): Warning! W761: octal escape sequence out of range; truncated From 88eb0f08e20d9a05a11007ee1586737f0e30e0c4 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Fri, 29 Sep 2023 11:58:31 +0200 Subject: [PATCH 171/258] reformat cg source code --- bld/cg/c/cse.c | 88 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 53 insertions(+), 35 deletions(-) diff --git a/bld/cg/c/cse.c b/bld/cg/c/cse.c index 5bf10f34bb..a50421d53f 100644 --- a/bld/cg/c/cse.c +++ b/bld/cg/c/cse.c @@ -93,7 +93,8 @@ static void ReCalcAddrTaken( void ) for( temp = Names[N_TEMP]; temp != NULL; temp = temp->n.next_name ) { if( temp->v.usage & VAR_VOLATILE ) continue; - if( temp->v.symbol != NULL && (FEAttr( temp->v.symbol ) & FE_ADDR_TAKEN) ) + if( temp->v.symbol != NULL + && (FEAttr( temp->v.symbol ) & FE_ADDR_TAKEN) ) continue; if( temp->t.temp_flags & STACK_PARM ) /* See DoParmDecl() */ continue; @@ -158,7 +159,8 @@ static bool FindDefnBlocks( block *blk, instruction *cond, opcnt i ) break; if( input->depth < blk->depth ) { // don't make 2 entries into loop for( other_input = blk->input_edges; other_input != NULL; other_input = other_input->next_source ) { - if( other_input->source->depth < blk->depth && other_input->source != input ) { + if( other_input->source->depth < blk->depth + && other_input->source != input ) { break; } } @@ -336,7 +338,8 @@ static void TreeBits( block *root ) change = false; for( blk = root->u.partition; blk != root; blk = blk->u.partition ) { daddy = blk->input_edges->source; - if( _BLKBITS( blk ) == 0 && _BLKBITS( daddy ) ) { + if( _BLKBITS( blk ) == 0 + && _BLKBITS( daddy ) ) { next_bit <<= 1; if( next_bit == 0 ) break; @@ -385,7 +388,8 @@ static void FindPartition( void ) block_num i; for( blk = HeadBlock; blk != NULL; blk = blk->next_block ) { - if( _IsBlkAttr( blk, BLK_BIG_LABEL ) || blk->inputs != 1 ) { + if( _IsBlkAttr( blk, BLK_BIG_LABEL ) + || blk->inputs != 1 ) { _MarkBlkVisited( blk ); } blk->u.partition = blk; @@ -396,7 +400,8 @@ static void FindPartition( void ) for( i = blk->targets; i > 0; --i ) { if( edge->flags & DEST_IS_BLOCK ) { oth = edge->destination.u.blk; - if( !_IsBlkVisited( oth ) && oth->inputs == 1 ) { + if( !_IsBlkVisited( oth ) + && oth->inputs == 1 ) { temp = oth->u.partition; oth->u.partition = blk->u.partition; blk->u.partition = temp; @@ -479,7 +484,8 @@ static instruction *WhichIsAncestor( instruction *ins1, instruction *ins2 ) * scan back over all the conditional branches at the end of block */ for( ; ; first = first->head.prev ) { - if( ( first->head.opcode != OP_SELECT ) && !_OpIsCondition( first->head.opcode ) ) { + if( ( first->head.opcode != OP_SELECT ) + && !_OpIsCondition( first->head.opcode ) ) { break; } } @@ -680,7 +686,8 @@ static instruction *ProcessExpr( instruction *ins1, instruction *ins2, bool if( ins1->operands[0] != ins2->operands[0] || ins1->operands[i] != ins2->operands[i] ) { if( !_OpCommutes( ins1->head.opcode ) ) return( NULL ); - if( ins1->operands[0] != ins2->operands[i] || ins1->operands[i] != ins2->operands[0] ) { + if( ins1->operands[0] != ins2->operands[i] + || ins1->operands[i] != ins2->operands[0] ) { return( NULL ); } } @@ -694,7 +701,8 @@ static instruction *ProcessExpr( instruction *ins1, instruction *ins2, bool killed = BinOpsLiveFrom( ins1, ins2, ins1->operands[0], ins1->operands[i], ins1->result ); if( killed != OP_DIES ) { type_class = ins1->result->n.type_class; - if( killed == RESULT_DIES || !CanCrossBlocks( ins1, ins2, ins1->result ) ) { + if( killed == RESULT_DIES + || !CanCrossBlocks( ins1, ins2, ins1->result ) ) { temp = AllocTemp( type_class ); new_ins = MakeMove( temp, ins1->result, type_class ); ins1->result = temp; @@ -751,7 +759,8 @@ static bool OkToInvert( name *div ) { if( _IsModel( CGSW_GEN_FP_UNSTABLE_OPTIMIZATION ) ) return( true ); - if( (div->n.class == N_TEMP) && (div->t.temp_flags & CONST_TEMP) ) { + if( (div->n.class == N_TEMP) + && (div->t.temp_flags & CONST_TEMP) ) { div = div->v.symbol; } if( div->n.class != N_CONSTANT ) @@ -1092,13 +1101,13 @@ static bool FixStructRet( block *root ) for( ;; ) { for( ins = blk->ins.head.next; ins->head.opcode != OP_BLOCK; ins = ins->head.next ) { if( _OpIsCall( ins->head.opcode ) ) { - if( ins->result != NULL && - ins->result->n.class == N_TEMP && - (ins->flags.call_flags & CALL_RETURNS_STRUCT) && - FixOneStructRet( ins ) ) { + if( ins->result != NULL + && ins->result->n.class == N_TEMP + && (ins->flags.call_flags & CALL_RETURNS_STRUCT) + && FixOneStructRet( ins ) ) { change = true; } - ins->flags.call_flags &= ~CALL_RETURNS_STRUCT; + ins->flags.call_flags &= ~CALL_RETURNS_STRUCT; } } blk = blk->u.partition; @@ -1110,7 +1119,7 @@ static bool FixStructRet( block *root ) } static block *NextBlock( block *blk, void *parm ) -/***************************************************/ +/**************************************************/ { if( blk->u.partition == (block *)parm ) return( NULL ); @@ -1118,13 +1127,14 @@ static block *NextBlock( block *blk, void *parm ) } static bool isMoveIns( instruction *ins ) -/****************************************** +/******************************************** * Is "ins" a move type instruction? */ { if( ins->head.opcode == OP_MOV ) return( true ); - if( _IsConvert( ins ) && ins->operands[0]->n.class == N_CONSTANT + if( _IsConvert( ins ) + && ins->operands[0]->n.class == N_CONSTANT && ins->operands[0]->c.const_type == CONS_ABSOLUTE ) return( true ); return( false ); @@ -1143,7 +1153,8 @@ static bool CanLinkMove( instruction *ins ) */ if( ins->operands[0]->n.class == N_REGISTER ) return( false ); - if( ins->operands[0]->n.class == N_TEMP && (ins->operands[0]->t.temp_flags & STACK_PARM) ) + if( ins->operands[0]->n.class == N_TEMP + && (ins->operands[0]->t.temp_flags & STACK_PARM) ) return( false ); if( ins->result->n.class == N_REGISTER ) return( false ); @@ -1241,7 +1252,7 @@ static void LinkMoves( block *root ) static void LinkMemMoves( block *root ) -/***************************************** * +/****************************************** * Link together all move instructions in partion defined by "root" using * a field in ins->operands[0] as the head of the list. */ @@ -1256,7 +1267,8 @@ static void LinkMemMoves( block *root ) continue; if( !CanLinkMove( ins ) ) continue; - if( ins->operands[0]->n.class != N_MEMORY && ins->operands[0]->n.class != N_INDEXED ) + if( ins->operands[0]->n.class != N_MEMORY + && ins->operands[0]->n.class != N_INDEXED ) continue; CreateLink( ins, ins->operands[0] ); } @@ -1336,14 +1348,17 @@ static bool PropOpnd( instruction *ins, name **op, opnd = *op; change = false; for( ; definition != NULL; definition = _INSLINK( definition ) ) { - if( WhichIsAncestor( definition, ins ) == definition && UnOpsLiveFrom( definition, ins ) ) { + if( WhichIsAncestor( definition, ins ) == definition + && UnOpsLiveFrom( definition, ins ) ) { defop = definition->operands[0]; defres = definition->result; if( backward ) { - if( defop == opnd && defres->n.class == N_TEMP && is_opnd ) { + if( defop == opnd + && defres->n.class == N_TEMP + && is_opnd ) { if( ( _IsFloating( definition->type_class ) == _IsFloating( _OpClass( ins ) ) ) - && CanCrossBlocks( definition, ins, defres ) - && !FPStackOp( defres ) ) { + && CanCrossBlocks( definition, ins, defres ) + && !FPStackOp( defres ) ) { UseInOther( definition, ins, defres ); *op = defres; change = true; @@ -1351,20 +1366,21 @@ static bool PropOpnd( instruction *ins, name **op, } } else { if( defres == opnd ) { - if( defres->n.class != N_INDEXED && is_opnd ) { - if( ( _IsFloating( definition->type_class ) - == _IsFloating( _OpClass( ins ) ) ) - && CanCrossBlocks( definition, ins, defop ) - && !FPStackOp( defop ) ) { + if( defres->n.class != N_INDEXED + && is_opnd ) { + if( ( _IsFloating( definition->type_class ) == _IsFloating( _OpClass( ins ) ) ) + && CanCrossBlocks( definition, ins, defop ) + && !FPStackOp( defop ) ) { UseInOther( definition, ins, defop ); *op = defop; change = true; } } - } else if( opnd->n.class == N_INDEXED && definition->result->n.class == N_TEMP ) { + } else if( opnd->n.class == N_INDEXED + && definition->result->n.class == N_TEMP ) { if( defop->n.class == N_TEMP - && defop->n.type_class==opnd->i.index->n.type_class - && CanCrossBlocks( definition, ins, defop ) ) { + && defop->n.type_class == opnd->i.index->n.type_class + && CanCrossBlocks( definition, ins, defop ) ) { UseInOther( definition, ins, defop ); *op = ScaleIndex( defop, opnd->i.base, opnd->i.constant, @@ -1372,12 +1388,13 @@ static bool PropOpnd( instruction *ins, name **op, opnd->i.scale, opnd->i.index_flags ); change = true; } else if( defop->n.class == N_CONSTANT - && ins->head.opcode != OP_SELECT ) { + && ins->head.opcode != OP_SELECT ) { disp = 0; base = NULL; switch( defop->c.const_type ) { case CONS_ABSOLUTE: - if( opnd->i.base != NULL && (opnd->i.index_flags & X_FAKE_BASE) == 0 ) { + if( opnd->i.base != NULL + && (opnd->i.index_flags & X_FAKE_BASE) == 0 ) { disp = opnd->i.constant + defop->c.lo.int_value; base = opnd->i.base; } @@ -1385,7 +1402,8 @@ static bool PropOpnd( instruction *ins, name **op, case CONS_ADDRESS: case CONS_OFFSET: case CONS_TEMP_ADDR: - if( opnd->i.base == NULL || (opnd->i.index_flags & X_FAKE_BASE) ) { + if( opnd->i.base == NULL + || (opnd->i.index_flags & X_FAKE_BASE) ) { disp = opnd->i.constant; base = defop->c.value; } From 584c6b7face7410f76b6ac2984b3644894ad5f89 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Fri, 29 Sep 2023 14:18:53 +0200 Subject: [PATCH 172/258] rename macro to be more transparent --- bld/cc/c/cfeinfo.c | 4 ++-- bld/cg/intel/c/x86reg.c | 2 +- bld/cg/intel/h/x86auxcc.h | 2 +- bld/plusplus/c/cginfo.c | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bld/cc/c/cfeinfo.c b/bld/cc/c/cfeinfo.c index cf80bb9e36..8256f003bd 100644 --- a/bld/cc/c/cfeinfo.c +++ b/bld/cc/c/cfeinfo.c @@ -523,7 +523,7 @@ call_class_target GetCallClassTarget( SYM_HANDLE sym_handle ) #if _CPU == 8086 if( TargetSystem == TS_WINDOWS ) { if( inf == &PascalInfo || inf == &CdeclInfo ) { - cclass_target |= FECALL_X86_FAT_WINDOWS_PROLOG; + cclass_target |= FECALL_X86_PROLOG_FAT_WINDOWS; } } #endif @@ -544,7 +544,7 @@ call_class_target GetCallClassTarget( SYM_HANDLE sym_handle ) if( sym.mods & FLAG_LOADDS ) { #if 0 if( TargetSystem == TS_WINDOWS ) { - cclass_target |= FECALL_X86_FAT_WINDOWS_PROLOG; + cclass_target |= FECALL_X86_PROLOG_FAT_WINDOWS; } else { cclass_target |= FECALL_X86_LOAD_DS_ON_ENTRY; } diff --git a/bld/cg/intel/c/x86reg.c b/bld/cg/intel/c/x86reg.c index c3fa2a8239..dbc4cffcd1 100644 --- a/bld/cg/intel/c/x86reg.c +++ b/bld/cg/intel/c/x86reg.c @@ -139,7 +139,7 @@ type_class_def CallState( aux_handle aux, type_def *tipe, call_state *state ) if( cclass_target & FECALL_X86_EPILOG_HOOKS ) { CurrProc->prolog_state |= GENERATE_EPILOG_HOOKS; } - if( cclass_target & FECALL_X86_FAT_WINDOWS_PROLOG ) { + if( cclass_target & FECALL_X86_PROLOG_FAT_WINDOWS ) { CurrProc->prolog_state |= GENERATE_FAT_PROLOG; } if( cclass_target & FECALL_X86_EMIT_FUNCTION_NAME ) { diff --git a/bld/cg/intel/h/x86auxcc.h b/bld/cg/intel/h/x86auxcc.h index 2fb55ba500..b64aa654af 100644 --- a/bld/cg/intel/h/x86auxcc.h +++ b/bld/cg/intel/h/x86auxcc.h @@ -44,7 +44,7 @@ typedef enum { FECALL_X86_NO_FLOAT_REG_RETURNS = 0x00000100, FECALL_X86_NO_STRUCT_REG_RETURNS = 0x00000200, FECALL_X86_ROUTINE_RETURN = 0x00000400, - FECALL_X86_FAT_WINDOWS_PROLOG = 0x00000800, + FECALL_X86_PROLOG_FAT_WINDOWS = 0x00000800, FECALL_X86_GENERATE_STACK_FRAME = 0x00001000, FECALL_X86_EMIT_FUNCTION_NAME = 0x00002000, FECALL_X86_GROW_STACK = 0x00004000, diff --git a/bld/plusplus/c/cginfo.c b/bld/plusplus/c/cginfo.c index e44583744b..5652c923d8 100644 --- a/bld/plusplus/c/cginfo.c +++ b/bld/plusplus/c/cginfo.c @@ -914,7 +914,7 @@ static call_class_target getCallClassTarget( SYMBOL sym ) * matches what it would be for an exported fn */ if( TargetSwitches & CGSW_X86_WINDOWS ) { - cclass_target |= FECALL_X86_FAT_WINDOWS_PROLOG; + cclass_target |= FECALL_X86_PROLOG_FAT_WINDOWS; } } } @@ -934,7 +934,7 @@ static call_class_target getCallClassTarget( SYMBOL sym ) #if _CPU == 8086 if( inf == &PascalInfo || inf == &CdeclInfo ) { if( TargetSwitches & CGSW_X86_WINDOWS ) { - cclass_target |= FECALL_X86_FAT_WINDOWS_PROLOG; + cclass_target |= FECALL_X86_PROLOG_FAT_WINDOWS; } } #endif From 22d6739e709719a5df8d3852ead01b389a63f1b4 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Fri, 29 Sep 2023 17:31:58 +0200 Subject: [PATCH 173/258] remove forward declarations --- bld/cc/c/cgen.c | 1399 +++++++++++++++++++++++------------------------ 1 file changed, 683 insertions(+), 716 deletions(-) diff --git a/bld/cc/c/cgen.c b/bld/cc/c/cgen.c index 20a6f2830a..2f95d90374 100644 --- a/bld/cc/c/cgen.c +++ b/bld/cc/c/cgen.c @@ -66,26 +66,6 @@ typedef struct try_table_back_handles { extern SYM_LIST_HEADS *SymListHeads; extern LABEL_INDEX LabelIndex; -static void FreeExtVars( void ); -static void FreeGblVars( SYM_HANDLE sym_handle ); -static void FreeLocalVars( SYM_HANDLE sym_list ); -static cg_type CodePtrType( type_modifiers flags ); -static bool DoFuncDefn( SYM_HANDLE funcsym_handle ); -static void EmitSyms( void ); -static void Emit1String( STR_HANDLE str_handle ); -static void EmitLiteral( STR_HANDLE strlit ); -static void EmitCS_Strings( void ); -static void FreeStrings( void ); -static void CDoAutoDecl( SYM_HANDLE sym_handle ); -static void CDoParmDecl( SYMPTR sym, SYM_HANDLE sym_handle ); -static void ParmReverse( SYM_HANDLE sym_handle ); -#ifdef __SEH__ -static void FreeTrySymBackInfo( void ); -static void FreeTryTableBackHandles( void ); -static void CallTryFini( void ); -static void GenerateTryBlock( TREEPTR tree ); -#endif - static local_vars *LocalVarList; static label_handle *CGLabelHandles; static TREEPTR FirstNode; @@ -158,17 +138,6 @@ static int heap_size( struct heap_stat *stat ) } #endif -static void StartFunction( OPNODE *node ) -{ - FuncNodePtr = node; - if( InLineDepth == 0 ) { - LocalVarList = NULL; - } - - FuncNodePtr->u2.func.flags |= FUNC_INUSE; - DoFuncDefn( node->u2.func.sym_handle ); -} - static void DefineLabels( OPNODE *node ) { LABEL_INDEX i; @@ -192,6 +161,34 @@ static local_vars *ReleaseVars( SYM_HANDLE sym_list, local_vars *local_var_list return( local_entry ); } +static void FreeSymBackInfo( SYMPTR sym, SYM_HANDLE sym_handle ) +{ + if( sym->info.backinfo != NULL ) { + BEFiniBack( sym->info.backinfo ); + BEFreeBack( sym->info.backinfo ); + sym->info.backinfo = NULL; + SymReplace( sym, sym_handle ); + } +} + +static void FreeLocalVars( SYM_HANDLE sym_list ) +{ + SYM_HANDLE sym_handle; + SYM_ENTRY sym; + + for( sym_handle = sym_list; sym_handle != SYM_NULL; sym_handle = sym.handle) { + SymGet( &sym, sym_handle ); + if( sym.attribs.stg_class != SC_EXTERN ) { + if( (sym.flags & SYM_FUNC_RETURN_VAR) == 0 ) { + if( sym.sym_type->decl_type != TYP_VOID ) { + FreeSymBackInfo( &sym, sym_handle ); + } + } + } + } +} + + static void RelLocalVars( local_vars *local_var_list ) { local_vars *local_entry; @@ -211,6 +208,60 @@ static cg_type ReturnType( cg_type type ) return( type ); } +#ifdef __SEH__ +static void FreeTrySymBackInfo( void ) +{ + SYM_ENTRY sym; + + SymGet( &sym, TrySymHandle ); + FreeSymBackInfo( &sym, TrySymHandle ); +} + +static void FreeTryTableBackHandles( void ) +{ + try_table_back_handles *try_backinfo; + + for( ; (try_backinfo = TryTableBackHandles) != NULL; ) { + TryTableBackHandles = try_backinfo->next; + BEFreeBack( try_backinfo->back_handle ); + CMemFree( try_backinfo ); + } +} + +static void CallTryRtn( SYM_HANDLE try_rtn, cg_name parm ) +{ + call_handle call; + + call = CGInitCall( CGFEName( (CGSYM_HANDLE)try_rtn, TY_POINTER ), TY_INTEGER, (CGSYM_HANDLE)try_rtn ); + CGAddParm( call, parm, TY_POINTER ); + CGDone( CGCall( call ) ); +} + +static void CallTryInit( void ) +{ + CallTryRtn( SymTryInit, CGFEName( (CGSYM_HANDLE)TrySymHandle, TY_POINTER ) ); +} + +static cg_name TryFieldAddr( unsigned offset ) +{ + cg_name name; + + name = CGFEName( (CGSYM_HANDLE)TrySymHandle, TryRefno ); + name = CGBinary( O_PLUS, name, CGInteger( offset, TY_UNSIGNED ), TY_POINTER ); + name = CGVolatile( name ); + return( name ); +} + +static void CallTryFini( void ) +{ + cg_name name; + + name = TryFieldAddr( FLD_next ); + name = CGUnary( O_POINTS, name, TY_POINTER ); + CallTryRtn( SymTryFini, name ); +} +#endif + static void EndFunction( OPNODE *node ) { LABEL_INDEX i; @@ -328,16 +379,6 @@ static cg_name PushSymSeg( OPNODE *node ) } #ifdef __SEH__ -static cg_name TryFieldAddr( unsigned offset ) -{ - cg_name name; - - name = CGFEName( (CGSYM_HANDLE)TrySymHandle, TryRefno ); - name = CGBinary( O_PLUS, name, CGInteger( offset, TY_UNSIGNED ), TY_POINTER ); - name = CGVolatile( name ); - return( name ); -} - static cg_name TryExceptionInfoAddr( void ) { cg_name name; @@ -394,29 +435,6 @@ static cg_name TryAbnormalTermination( void ) return( name ); } -static void CallTryRtn( SYM_HANDLE try_rtn, cg_name parm ) -{ - call_handle call; - - call = CGInitCall( CGFEName( (CGSYM_HANDLE)try_rtn, TY_POINTER ), TY_INTEGER, (CGSYM_HANDLE)try_rtn ); - CGAddParm( call, parm, TY_POINTER ); - CGDone( CGCall( call ) ); -} - -static void CallTryInit( void ) -{ - CallTryRtn( SymTryInit, CGFEName( (CGSYM_HANDLE)TrySymHandle, TY_POINTER ) ); -} - -static void CallTryFini( void ) -{ - cg_name name; - - name = TryFieldAddr( FLD_next ); - name = CGUnary( O_POINTS, name, TY_POINTER ); - CallTryRtn( SymTryFini, name ); -} - static void CallTryUnwind( tryindex_t scope_index ) { call_handle call; @@ -427,49 +445,120 @@ static void CallTryUnwind( tryindex_t scope_index ) CGAddParm( call, parm, TY_INTEGER ); CGDone( CGCall( call ) ); } -#endif - -#if _CPU == _AXP -static void GenVaStart( cg_name op1, cg_name offset ) -{ - cg_name name; - cg_name baseptr; - baseptr = CGVarargsBasePtr( TY_POINTER ); - name = CGLVAssign( op1, baseptr, TY_POINTER ); - name = CGBinary( O_PLUS, name, CGInteger( TARGET_POINTER, TY_INTEGER ), TY_POINTER ); - name = CGAssign( name, offset, TY_INTEGER ); - CGDone( name ); -} -#elif _CPU == _PPC -static void GenVaStart( cg_name op1, cg_name offset ) +static void GenerateTryBlock( TREEPTR tree ) { - cg_name name; + TREEPTR stmt; + tryindex_t try_index; + tryindex_t max_try_index; - /* unused parameters */ (void)offset; + try_index = 0; + max_try_index = TRYSCOPE_NONE; + for( ; tree != NULL; tree = tree->left ) { + stmt = tree->right; + if( stmt->op.opr == OPR_FUNCEND ) + break; + switch( stmt->op.opr ) { + case OPR_TRY: + try_index = stmt->op.u2.st.u.try_index; + if( max_try_index < try_index ) + max_try_index = try_index; + break; + case OPR_EXCEPT: + case OPR_FINALLY: + ValueStack[try_index] = stmt; + break; + default: + break; + } + } + if( max_try_index != TRYSCOPE_NONE ) { + segment_id old_segid; + BACK_HANDLE except_label; + BACK_HANDLE except_table; + try_table_back_handles *try_backinfo; - name = CGUnary( O_VA_START, op1, TY_POINTER ); - CGDone( name ); + old_segid = BESetSeg( SEG_DATA ); + except_table = BENewBack( NULL ); + try_backinfo = (try_table_back_handles *)CMemAlloc( sizeof( try_table_back_handles ) ); + try_backinfo->back_handle = except_table; + try_backinfo->next = TryTableBackHandles; + TryTableBackHandles = try_backinfo; + DGLabel( except_table ); + for( try_index = 0; try_index <= max_try_index; try_index++ ) { + stmt = ValueStack[try_index]; + DGInteger( stmt->op.u2.st.parent_scope, TY_UINT_1 ); // parent index + if( stmt->op.opr == OPR_EXCEPT ) { + DGInteger( 0, TY_UINT_1 ); + } else { + DGInteger( 1, TY_UINT_1 ); + } + except_label = FEBack( (CGSYM_HANDLE)stmt->op.u2.st.u.try_sym_handle ); + DGBackPtr( except_label, FESegID( (CGSYM_HANDLE)CurFuncHandle ), 0, TY_CODE_PTR ); + } + BESetSeg( old_segid ); + SetTryTable( except_table ); + BEFiniBack( except_table ); + } } -#elif _CPU == _MIPS +#endif /* __SEH__ */ + +#if _RISC_CPU static void GenVaStart( cg_name op1, cg_name offset ) /**************************************************** - * Similar to Alpha, except we point va_list.__base to the first - * vararg and va_list.__offset initially to zero. Strictly speaking - * we don't need va_list.__offset. + * MIPS version is similar to Alpha, except we point va_list.__base + * to the first vararg and va_list.__offset initially to zero. + * Strictly speaking we don't need va_list.__offset. */ { cg_name name; + #if _CPU == _PPC + #elif _CPU == _AXP + cg_name baseptr; + #elif _CPU == _MIPS cg_name baseptr; + #endif + #if _CPU == _PPC + /* unused parameters */ (void)offset; + + name = CGUnary( O_VA_START, op1, TY_POINTER ); + #elif _CPU == _AXP + baseptr = CGVarargsBasePtr( TY_POINTER ); + name = CGLVAssign( op1, baseptr, TY_POINTER ); + name = CGBinary( O_PLUS, name, CGInteger( TARGET_POINTER, TY_INTEGER ), TY_POINTER ); + name = CGAssign( name, offset, TY_INTEGER ); + #elif _CPU == _MIPS baseptr = CGVarargsBasePtr( TY_POINTER ); name = CGBinary( O_PLUS, baseptr, offset, TY_POINTER ); name = CGLVAssign( op1, name, TY_POINTER ); name = CGBinary( O_PLUS, name, CGInteger( TARGET_POINTER, TY_INTEGER ), TY_POINTER ); name = CGAssign( name, CGInteger( 0, TY_INTEGER ), TY_INTEGER ); + #endif CGDone( name ); } +#endif /* _RISC_CPU */ + +static cg_type CodePtrType( type_modifiers flags ) +{ +#if _INTEL_CPU + cg_type dtype; + + if( flags & FLAG_FAR ) { + dtype = TY_LONG_CODE_PTR; + } else if( flags & FLAG_NEAR ) { + dtype = TY_NEAR_CODE_PTR; + } else { + dtype = TY_CODE_PTR; + } + return( dtype ); +#else /* _RISC_CPU */ + + /* unused parameters */ (void)flags; + + return( TY_CODE_PTR ); #endif +} static cg_name PushSym( OPNODE *node ) { @@ -693,25 +782,109 @@ static cg_name PushConstant( OPNODE *node ) return( name ); } -static cg_name PushString( OPNODE *node ) +target_size EmitBytes( STR_HANDLE strlit ) { - STR_HANDLE string; + DGBytes( strlit->length, strlit->literal ); + return( strlit->length ); +} - string = node->u2.string_handle; - Emit1String( string ); - return( CGBackName( string->back_handle, TY_UINT_1 ) ); + +static segment_id StringSegment( STR_HANDLE strlit ) +{ +#if _INTEL_CPU + if( strlit->flags & STRLIT_FAR ) + return( FarStringSegId ); +#endif + if( strlit->flags & STRLIT_CONST ) + return( SEG_CODE ); + return( SEG_CONST ); } -static cg_name DoIndirection( OPNODE *node, cg_name name ) +static void EmitLiteral( STR_HANDLE strlit ) { - TYPEPTR typ; + segment_id old_segid; - /* - * check for special kinds of pointers, eg. call __Far16ToFlat - */ - typ = node->u2.result_type; -#if _CPU == 386 - if( Far16Pointer( node->flags ) ) { + old_segid = BESetSeg( StringSegment( strlit ) ); + if( strlit->flags & STRLIT_WIDE ) { + DGAlign( TARGET_SHORT ); /* NT requires word aligned wide strings */ + } + DGLabel( strlit->back_handle ); + EmitBytes( strlit ); + BESetSeg( old_segid ); +} + + +static void Emit1String( STR_HANDLE str_handle ) +{ + if( str_handle->back_handle == NULL ) { + str_handle->back_handle = BENewBack( NULL ); + if( (str_handle->flags & STRLIT_CONST) == 0 ) { + EmitLiteral( str_handle ); + } + } +} + +static cg_name PushString( OPNODE *node ) +{ + STR_HANDLE string; + + string = node->u2.string_handle; + Emit1String( string ); + return( CGBackName( string->back_handle, TY_UINT_1 ) ); +} + +static void FreeStrings( void ) +{ + STR_HANDLE strlit; + STR_HANDLE strlit_next; + str_hash_idx hash; + + for( hash = 0; hash < STRING_HASH_SIZE; hash++ ) { + for( strlit = StringHash[hash]; strlit != NULL; strlit = strlit_next ) { + strlit_next = strlit->next_string; + if( strlit->back_handle != NULL ) { + BEFiniBack( strlit->back_handle ); + BEFreeBack( strlit->back_handle ); + strlit->back_handle = NULL; + } + FreeLiteral( strlit ); + } + StringHash[hash] = NULL; + } +} + +static void DumpCS_Strings( STR_HANDLE strlit ) +{ + for( ; strlit != NULL; strlit = strlit->next_string ) { + if( (strlit->flags & STRLIT_CONST) && strlit->ref_count != 0 ) { + strlit->back_handle = BENewBack( NULL ); + EmitLiteral( strlit ); + } + } +} + + +static void EmitCS_Strings( void ) +{ + str_hash_idx hash; + + if( CompFlags.strings_in_code_segment ) { + for( hash = STRING_HASH_SIZE; hash-- > 0; ) { + DumpCS_Strings( StringHash[hash] ); + } + } +} + +static cg_name DoIndirection( OPNODE *node, cg_name name ) +{ + TYPEPTR typ; + + /* + * check for special kinds of pointers, eg. call __Far16ToFlat + */ + typ = node->u2.result_type; +#if _CPU == 386 + if( Far16Pointer( node->flags ) ) { /* * Do NOT convert __far16 function pointers to flat because the * thunk routine expects 16:16 pointers! @@ -803,51 +976,330 @@ static bool IsStruct( TYPEPTR typ ) return( false ); } -static void EmitNodes( TREEPTR tree ) +static void ThreadNode( TREEPTR node ) { - cg_name op1; - cg_name op2; - cg_name expr; - call_handle call; - int index; - OPNODE *node; + if( FirstNode == NULL ) + FirstNode = node; + if( LastNode != NULL ) + LastNode->u.thread = node; + LastNode = node; +} - index = 0; - for( ; tree != NULL; tree = tree->u.thread ) { - node = &tree->op; - switch( node->opr ) { - case OPR_FUNCTION: // start of function - StartFunction( node ); - break; - case OPR_NEWBLOCK: // start of new block { vars; } - DBBegBlock(); - CDoAutoDecl( node->u2.sym_handle ); - break; - case OPR_ENDBLOCK: // end of new block { vars; } - DBEndBlock(); - LocalVarList = ReleaseVars( node->u2.sym_handle, LocalVarList ); - break; - case OPR_LABELCOUNT: // number of labels used in function - DefineLabels( node ); - break; - case OPR_RETURN: // return( expression ); - op1 = PopCGName(); // - get expression - ReturnExpression( node, op1 ); - break; - case OPR_FUNCEND: // end of function - EndFunction( node ); - break; - case OPR_EQUALS: // = - op2 = PopCGName(); // get right opnd - op1 = PopCGName(); // get lvalue - if( node->flags & OPFLAG_VOLATILE ) { // is lvalue volatile - op1 = CGVolatile( op1 ); +static TREEPTR LinearizeTree( TREEPTR tree ) +{ + FirstNode = NULL; + LastNode = NULL; + WalkExprTree( tree, ThreadNode, NoOp, NoOp, ThreadNode ); + LastNode->u.thread = NULL; + return( FirstNode ); +} + + +void EmitInit( void ) +{ + SegListHead = NULL; + ImportSegIdInit(); + Refno = TY_FIRST_FREE; +} + + +static int NewRefno( void ) +{ + return( Refno++ ); +} + + +void EmitAbort( void ) +{ +} + +static void EmitSym( SYMPTR sym, SYM_HANDLE sym_handle ) +{ + TYPEPTR typ; + segment_id segid; + target_size size; + + typ = sym->sym_type; + if( (GenSwitches & CGSW_GEN_DBG_TYPES) && (sym->attribs.stg_class == SC_TYPEDEF) ) { + if( typ->decl_type != TYP_TYPEDEF ) { + DBEndName( DBBegName( sym->name, DBG_NIL_TYPE ), DBType( typ ) ); + } + } + SKIP_TYPEDEFS( typ ); + CGenType( typ ); /* create refno for ARRAY type, etc */ + if( sym->attribs.stg_class != SC_EXTERN && /* if not imported */ + sym->attribs.stg_class != SC_TYPEDEF ) { + if( ( sym->flags & SYM_FUNCTION ) == 0 ) { + segid = sym->u.var.segid; + if( (sym->flags & SYM_INITIALIZED) == 0 || segid == SEG_BSS) { + BESetSeg( segid ); + AlignIt( typ ); + DGLabel( FEBack( (CGSYM_HANDLE)sym_handle ) ); + /* + * initialize all bytes to 0 + * if size > 64k, have to break it into chunks of 64k + */ + size = SizeOfArg( typ ); + if( segid == SEG_BSS ) { + DGUBytes( size ); + } else { +#if _CPU == 8086 + while( size >= 0x10000 ) { + EmitZeros( 0x10000 ); + size -= 0x10000; + if( size == 0 ) + break; + if( segid != SEG_CONST && segid != SEG_DATA ) { + ++segid; + BESetSeg( segid ); + } + } +#endif + if( size != 0 ) { + EmitZeros( size ); + } + } } - if( IsStruct( node->u2.result_type ) ) { - op1 = CGLVAssign( op1, op2, CGenType( node->u2.result_type ) ); - op1 = PushRValue( node, op1 ); + } + } +} + +static void CDoAutoDecl( SYM_HANDLE sym_handle ) +{ + TYPEPTR typ; + cg_type dtype; + bool emit_debug_info; + bool emit_extra_info; + SYM_ENTRY sym; + + for( ; sym_handle != SYM_NULL; sym_handle = sym.handle ) { + SymGet( &sym, sym_handle ); + emit_debug_info = false; + emit_extra_info = false; + if( GenSwitches & CGSW_GEN_NO_OPTIMIZATION ) + emit_debug_info = true; + if( sym.attribs.stg_class == SC_STATIC ) { + emit_debug_info = false; + if( (sym.flags & SYM_EMITTED) == 0 ) { + if( sym.sym_type->decl_type != TYP_VOID ) { + EmitSym( &sym, sym_handle ); + emit_debug_info = true; + SymGet( &sym, sym_handle ); + sym.flags |= SYM_EMITTED; + SymReplace( &sym, sym_handle ); + } + } + } else if( sym.attribs.stg_class != SC_EXTERN && + sym.attribs.stg_class != SC_TYPEDEF ) { + if( sym.flags & SYM_ADDR_TAKEN ) { + emit_extra_info = true; + } + typ = sym.sym_type; + SKIP_TYPEDEFS( typ ); + switch( typ->decl_type ) { + case TYP_UNION: + case TYP_STRUCT: + case TYP_ARRAY: + case TYP_FCOMPLEX: + case TYP_DCOMPLEX: + case TYP_LDCOMPLEX: + emit_extra_info = true; + break; + default: + break; + } + dtype = CGenType( typ ); + if( sym.flags & SYM_FUNC_RETURN_VAR ) { + sym.info.return_var = CGTemp( dtype ); + SymReplace( &sym, sym_handle ); } else { - op1 = CGAssign( op1, op2, CGenType( node->u2.result_type ) ); + CGAutoDecl( (CGSYM_HANDLE)sym_handle, dtype ); + } + } +#if _CPU != 370 + if( ! CompFlags.debug_info_some ) + emit_extra_info = false; +#endif + if( emit_debug_info || emit_extra_info ) { + if( Saved_CurFunc == SYM_NULL ) { /* if we are not inlining */ + if( GenSwitches & CGSW_GEN_DBG_LOCALS ) { + if( (sym.flags & SYM_TEMP) == 0 ) { + DBLocalSym( (CGSYM_HANDLE)sym_handle, TY_DEFAULT ); + } + } + } + } + } +} + + +static void CDoParmDecl( SYMPTR sym, SYM_HANDLE sym_handle ) +{ + TYPEPTR typ; + cg_type dtype; + + typ = sym->sym_type; + SKIP_TYPEDEFS( typ ); + dtype = CGenType( typ ); + CGParmDecl( (CGSYM_HANDLE)sym_handle, dtype ); +#if _CPU == 386 + if( (GenSwitches & CGSW_GEN_NO_OPTIMIZATION) + || (!CompFlags.register_conventions && CompFlags.debug_info_some) ) { +#else + if( GenSwitches & CGSW_GEN_NO_OPTIMIZATION ) { +#endif + if( GenSwitches & CGSW_GEN_DBG_LOCALS ) { + DBLocalSym( (CGSYM_HANDLE)sym_handle, TY_DEFAULT ); + } + } +} + +static void ParmReverse( SYM_HANDLE sym_handle ) +{ + SYMPTR sym; + + sym = SymGetPtr( sym_handle ); + if( sym->handle ) { + ParmReverse( sym->handle ); + sym = SymGetPtr( sym_handle ); + } + CDoParmDecl( sym, sym_handle ); +} + +static bool DoFuncDefn( SYM_HANDLE funcsym_handle ) +{ + bool parms_reversed; + SYM_HANDLE sym_handle; + cg_type ret_type; + + SSVar = NULL; + CurFunc = &CurFuncSym; + SymGet( CurFunc, funcsym_handle ); + CurFuncHandle = funcsym_handle; +#if _INTEL_CPU + if( ! CompFlags.zu_switch_used ) { + if( CurFunc->mods & FLAG_FARSS ) { /* function use far stack */ + TargetSwitches |= CGSW_X86_FLOATING_SS; + } else { + TargetSwitches &= ~ CGSW_X86_FLOATING_SS; + } + } +#endif + ret_type = ReturnType( CGenType( CurFunc->sym_type->object ) ); + CGProcDecl( (CGSYM_HANDLE)funcsym_handle, ret_type ); +#if _CPU == 386 + if( TargetSwitches & CGSW_X86_P5_PROFILING ) { + const char *fn_name; + size_t len; + segment_id old_segid; + + fn_name = FEName( (CGSYM_HANDLE)funcsym_handle ); + len = strlen( fn_name ) + 1; + old_segid = BESetSeg( FunctionProfileSegId ); + FunctionProfileBlock = BENewBack( NULL ); + DGLabel( FunctionProfileBlock ); + DGInteger( 0, TY_INTEGER ); + DGInteger( (unsigned)-1, TY_INTEGER ); + DGInteger( 0, TY_INTEGER ); + DGInteger( 0, TY_INTEGER ); + DGBytes( len, fn_name ); + len &= 0x03; + if( len ) { + DGIBytes( 4 - len, 0 ); + } + BESetSeg( old_segid ); + } +#endif + if( GenSwitches & CGSW_GEN_DBG_LOCALS ) { + if( InLineDepth == 0 ) { + DBModSym( (CGSYM_HANDLE)CurFuncHandle, TY_DEFAULT ); + } else { + DBBegBlock(); + } + } + parms_reversed = false; + if( CurFunc->u.func.parms != SYM_NULL ) { + if( GetCallClass( CurFuncHandle ) & FECALL_GEN_REVERSE_PARMS ) { + ParmReverse( CurFunc->u.func.parms ); + parms_reversed = true; + } else { + SYMPTR sym; + + for( sym_handle = CurFunc->u.func.parms; sym_handle != SYM_NULL; sym_handle = sym->handle ) { + sym = SymGetPtr( sym_handle ); + if( sym->sym_type->decl_type == TYP_DOT_DOT_DOT ) + break; + CDoParmDecl( sym, sym_handle ); + } + } + } + CGLastParm(); + CDoAutoDecl( CurFunc->u.func.locals ); +#ifdef __SEH__ + if( FuncNodePtr->u2.func.flags & FUNC_USES_SEH ) { + CGAutoDecl( (CGSYM_HANDLE)TrySymHandle, TryRefno ); + CallTryInit(); // generate call to __TryInit + } +#endif + return( parms_reversed ); +} + +static void StartFunction( OPNODE *node ) +{ + FuncNodePtr = node; + if( InLineDepth == 0 ) { + LocalVarList = NULL; + } + + FuncNodePtr->u2.func.flags |= FUNC_INUSE; + DoFuncDefn( node->u2.func.sym_handle ); +} + +static void EmitNodes( TREEPTR tree ) +{ + cg_name op1; + cg_name op2; + cg_name expr; + call_handle call; + int index; + OPNODE *node; + + index = 0; + for( ; tree != NULL; tree = tree->u.thread ) { + node = &tree->op; + switch( node->opr ) { + case OPR_FUNCTION: // start of function + StartFunction( node ); + break; + case OPR_NEWBLOCK: // start of new block { vars; } + DBBegBlock(); + CDoAutoDecl( node->u2.sym_handle ); + break; + case OPR_ENDBLOCK: // end of new block { vars; } + DBEndBlock(); + LocalVarList = ReleaseVars( node->u2.sym_handle, LocalVarList ); + break; + case OPR_LABELCOUNT: // number of labels used in function + DefineLabels( node ); + break; + case OPR_RETURN: // return( expression ); + op1 = PopCGName(); // - get expression + ReturnExpression( node, op1 ); + break; + case OPR_FUNCEND: // end of function + EndFunction( node ); + break; + case OPR_EQUALS: // = + op2 = PopCGName(); // get right opnd + op1 = PopCGName(); // get lvalue + if( node->flags & OPFLAG_VOLATILE ) { // is lvalue volatile + op1 = CGVolatile( op1 ); + } + if( IsStruct( node->u2.result_type ) ) { + op1 = CGLVAssign( op1, op2, CGenType( node->u2.result_type ) ); + op1 = PushRValue( node, op1 ); + } else { + op1 = CGAssign( op1, op2, CGenType( node->u2.result_type ) ); } PushCGName( op1 ); break; @@ -1137,43 +1589,6 @@ static void EmitNodes( TREEPTR tree ) } } -static void ThreadNode( TREEPTR node ) -{ - if( FirstNode == NULL ) - FirstNode = node; - if( LastNode != NULL ) - LastNode->u.thread = node; - LastNode = node; -} - -static TREEPTR LinearizeTree( TREEPTR tree ) -{ - FirstNode = NULL; - LastNode = NULL; - WalkExprTree( tree, ThreadNode, NoOp, NoOp, ThreadNode ); - LastNode->u.thread = NULL; - return( FirstNode ); -} - - -void EmitInit( void ) -{ - SegListHead = NULL; - ImportSegIdInit(); - Refno = TY_FIRST_FREE; -} - - -static int NewRefno( void ) -{ - return( Refno++ ); -} - - -void EmitAbort( void ) -{ -} - static TREEPTR GenOptimizedCode( TREEPTR tree ) { unroll_type unroll_count; @@ -1400,380 +1815,25 @@ static void NoCodeGenDLL( void ) FEMessage( MSG_FATAL, "Unable to load code generator DLL" ); } -void DoCompile( void ) -{ - jmp_buf *old_env; - jmp_buf env; - cg_init_info cgi_info; - - old_env = Environment; - if( setjmp( env ) == 0 ) { - Environment = JMPBUF_PTR( env ); - if( BELoad( NULL ) ) { -#if _INTEL_CPU - if( ! CompFlags.zu_switch_used ) { - TargetSwitches &= ~ CGSW_X86_FLOATING_SS; - } -#endif -#ifdef DEVBUILD - if( TOGGLEDBG( dump_cg ) ) { - GenSwitches |= CGSW_GEN_ECHO_API_CALLS; - } -#endif - if( CompFlags.rent ) { - GenSwitches |= CGSW_GEN_POSITION_INDEPENDANT; - } - cgi_info = BEInit( GenSwitches, TargetSwitches, OptSize, ProcRevision ); - if( cgi_info.success ) { -#if _CPU == 386 - if( TargetSwitches & (CGSW_X86_P5_PROFILING | CGSW_X86_NEW_P5_PROFILING) ) { - FunctionProfileSegId = AddSegName( "TI", "DATA", SEGTYPE_INITFINI ); - } -#endif - SetSegs(); - BEStart(); - EmitSegLabels(); - if( GenSwitches & CGSW_GEN_DBG_TYPES ) - EmitDBType(); - EmitSyms(); - EmitCS_Strings(); - SrcLoc.line = 0; - SrcLoc.column = 0; - SrcLoc.fno = 0; - EmitDataQuads(); - FreeDataQuads(); -#ifdef __SEH__ - TryRefno = NewRefno(); - BEDefType( TryRefno, 1, TRY_BLOCK_SIZE ); - TryTableBackHandles = NULL; -#endif - PruneFunctions(); - GenModuleCode(); - FreeStrings(); - FiniSegLabels(); - if( ErrCount != 0 ) { - BEAbort(); - } - BEStop(); - FiniSegBacks(); - FreeGblVars( GlobalSym ); - FreeGblVars( SpecialSyms ); - FreeExtVars(); -#ifdef __SEH__ - FreeTryTableBackHandles(); -#endif - BEFini(); - BEUnload(); - SegFini(); - } - } else { - NoCodeGenDLL(); - } - } - Environment = old_env; -} - - -static void EmitSym( SYMPTR sym, SYM_HANDLE sym_handle ) -{ - TYPEPTR typ; - segment_id segid; - target_size size; - - typ = sym->sym_type; - if( (GenSwitches & CGSW_GEN_DBG_TYPES) && (sym->attribs.stg_class == SC_TYPEDEF) ) { - if( typ->decl_type != TYP_TYPEDEF ) { - DBEndName( DBBegName( sym->name, DBG_NIL_TYPE ), DBType( typ ) ); - } - } - SKIP_TYPEDEFS( typ ); - CGenType( typ ); /* create refno for ARRAY type, etc */ - if( sym->attribs.stg_class != SC_EXTERN && /* if not imported */ - sym->attribs.stg_class != SC_TYPEDEF ) { - if( ( sym->flags & SYM_FUNCTION ) == 0 ) { - segid = sym->u.var.segid; - if( (sym->flags & SYM_INITIALIZED) == 0 || segid == SEG_BSS) { - BESetSeg( segid ); - AlignIt( typ ); - DGLabel( FEBack( (CGSYM_HANDLE)sym_handle ) ); - /* - * initialize all bytes to 0 - * if size > 64k, have to break it into chunks of 64k - */ - size = SizeOfArg( typ ); - if( segid == SEG_BSS ) { - DGUBytes( size ); - } else { -#if _CPU == 8086 - while( size >= 0x10000 ) { - EmitZeros( 0x10000 ); - size -= 0x10000; - if( size == 0 ) - break; - if( segid != SEG_CONST && segid != SEG_DATA ) { - ++segid; - BESetSeg( segid ); - } - } -#endif - if( size != 0 ) { - EmitZeros( size ); - } - } - } - } - } -} - - -static void EmitSyms( void ) +static void EmitSyms( void ) { SYM_HANDLE sym_handle; - SYM_ENTRY sym; - - for( sym_handle = GlobalSym; sym_handle != SYM_NULL; sym_handle = sym.handle ) { - SymGet( &sym, sym_handle ); - EmitSym( &sym, sym_handle ); - if( (GenSwitches & CGSW_GEN_DBG_LOCALS ) - && ( sym.sym_type->decl_type != TYP_FUNCTION ) - && ( (sym.flags & SYM_TEMP) == 0 ) - && ( sym.attribs.stg_class != SC_TYPEDEF ) ) { -#if _CPU == 370 - if( sym.attribs.stg_class != SC_EXTERN || (sym.flags & SYM_REFERENCED) ) { - DBModSym( (CGSYM_HANDLE)sym_handle, TY_DEFAULT ); - } -#else - DBModSym( (CGSYM_HANDLE)sym_handle, TY_DEFAULT ); -#endif - } - } -} - - -static bool DoFuncDefn( SYM_HANDLE funcsym_handle ) -{ - bool parms_reversed; - SYM_HANDLE sym_handle; - cg_type ret_type; - - SSVar = NULL; - CurFunc = &CurFuncSym; - SymGet( CurFunc, funcsym_handle ); - CurFuncHandle = funcsym_handle; -#if _INTEL_CPU - if( ! CompFlags.zu_switch_used ) { - if( CurFunc->mods & FLAG_FARSS ) { /* function use far stack */ - TargetSwitches |= CGSW_X86_FLOATING_SS; - } else { - TargetSwitches &= ~ CGSW_X86_FLOATING_SS; - } - } -#endif - ret_type = ReturnType( CGenType( CurFunc->sym_type->object ) ); - CGProcDecl( (CGSYM_HANDLE)funcsym_handle, ret_type ); -#if _CPU == 386 - if( TargetSwitches & CGSW_X86_P5_PROFILING ) { - const char *fn_name; - size_t len; - segment_id old_segid; - - fn_name = FEName( (CGSYM_HANDLE)funcsym_handle ); - len = strlen( fn_name ) + 1; - old_segid = BESetSeg( FunctionProfileSegId ); - FunctionProfileBlock = BENewBack( NULL ); - DGLabel( FunctionProfileBlock ); - DGInteger( 0, TY_INTEGER ); - DGInteger( (unsigned)-1, TY_INTEGER ); - DGInteger( 0, TY_INTEGER ); - DGInteger( 0, TY_INTEGER ); - DGBytes( len, fn_name ); - len &= 0x03; - if( len ) { - DGIBytes( 4 - len, 0 ); - } - BESetSeg( old_segid ); - } -#endif - if( GenSwitches & CGSW_GEN_DBG_LOCALS ) { - if( InLineDepth == 0 ) { - DBModSym( (CGSYM_HANDLE)CurFuncHandle, TY_DEFAULT ); - } else { - DBBegBlock(); - } - } - parms_reversed = false; - if( CurFunc->u.func.parms != SYM_NULL ) { - if( GetCallClass( CurFuncHandle ) & FECALL_GEN_REVERSE_PARMS ) { - ParmReverse( CurFunc->u.func.parms ); - parms_reversed = true; - } else { - SYMPTR sym; - - for( sym_handle = CurFunc->u.func.parms; sym_handle != SYM_NULL; sym_handle = sym->handle ) { - sym = SymGetPtr( sym_handle ); - if( sym->sym_type->decl_type == TYP_DOT_DOT_DOT ) - break; - CDoParmDecl( sym, sym_handle ); - } - } - } - CGLastParm(); - CDoAutoDecl( CurFunc->u.func.locals ); -#ifdef __SEH__ - if( FuncNodePtr->u2.func.flags & FUNC_USES_SEH ) { - CGAutoDecl( (CGSYM_HANDLE)TrySymHandle, TryRefno ); - CallTryInit(); // generate call to __TryInit - } -#endif - return( parms_reversed ); -} - -static void CDoParmDecl( SYMPTR sym, SYM_HANDLE sym_handle ) -{ - TYPEPTR typ; - cg_type dtype; - - typ = sym->sym_type; - SKIP_TYPEDEFS( typ ); - dtype = CGenType( typ ); - CGParmDecl( (CGSYM_HANDLE)sym_handle, dtype ); -#if _CPU == 386 - if( (GenSwitches & CGSW_GEN_NO_OPTIMIZATION) - || (!CompFlags.register_conventions && CompFlags.debug_info_some) ) { -#else - if( GenSwitches & CGSW_GEN_NO_OPTIMIZATION ) { -#endif - if( GenSwitches & CGSW_GEN_DBG_LOCALS ) { - DBLocalSym( (CGSYM_HANDLE)sym_handle, TY_DEFAULT ); - } - } -} - -static void ParmReverse( SYM_HANDLE sym_handle ) -{ - SYMPTR sym; - - sym = SymGetPtr( sym_handle ); - if( sym->handle ) { - ParmReverse( sym->handle ); - sym = SymGetPtr( sym_handle ); - } - CDoParmDecl( sym, sym_handle ); -} - -static void CDoAutoDecl( SYM_HANDLE sym_handle ) -{ - TYPEPTR typ; - cg_type dtype; - bool emit_debug_info; - bool emit_extra_info; - SYM_ENTRY sym; - - for( ; sym_handle != SYM_NULL; sym_handle = sym.handle ) { - SymGet( &sym, sym_handle ); - emit_debug_info = false; - emit_extra_info = false; - if( GenSwitches & CGSW_GEN_NO_OPTIMIZATION ) - emit_debug_info = true; - if( sym.attribs.stg_class == SC_STATIC ) { - emit_debug_info = false; - if( (sym.flags & SYM_EMITTED) == 0 ) { - if( sym.sym_type->decl_type != TYP_VOID ) { - EmitSym( &sym, sym_handle ); - emit_debug_info = true; - SymGet( &sym, sym_handle ); - sym.flags |= SYM_EMITTED; - SymReplace( &sym, sym_handle ); - } - } - } else if( sym.attribs.stg_class != SC_EXTERN && - sym.attribs.stg_class != SC_TYPEDEF ) { - if( sym.flags & SYM_ADDR_TAKEN ) { - emit_extra_info = true; - } - typ = sym.sym_type; - SKIP_TYPEDEFS( typ ); - switch( typ->decl_type ) { - case TYP_UNION: - case TYP_STRUCT: - case TYP_ARRAY: - case TYP_FCOMPLEX: - case TYP_DCOMPLEX: - case TYP_LDCOMPLEX: - emit_extra_info = true; - break; - default: - break; - } - dtype = CGenType( typ ); - if( sym.flags & SYM_FUNC_RETURN_VAR ) { - sym.info.return_var = CGTemp( dtype ); - SymReplace( &sym, sym_handle ); - } else { - CGAutoDecl( (CGSYM_HANDLE)sym_handle, dtype ); - } - } -#if _CPU != 370 - if( ! CompFlags.debug_info_some ) - emit_extra_info = false; -#endif - if( emit_debug_info || emit_extra_info ) { - if( Saved_CurFunc == SYM_NULL ) { /* if we are not inlining */ - if( GenSwitches & CGSW_GEN_DBG_LOCALS ) { - if( (sym.flags & SYM_TEMP) == 0 ) { - DBLocalSym( (CGSYM_HANDLE)sym_handle, TY_DEFAULT ); - } - } - } - } - } -} - - -static void FreeSymBackInfo( SYMPTR sym, SYM_HANDLE sym_handle ) -{ - if( sym->info.backinfo != NULL ) { - BEFiniBack( sym->info.backinfo ); - BEFreeBack( sym->info.backinfo ); - sym->info.backinfo = NULL; - SymReplace( sym, sym_handle ); - } -} - -#ifdef __SEH__ -static void FreeTrySymBackInfo( void ) -{ - SYM_ENTRY sym; - - SymGet( &sym, TrySymHandle ); - FreeSymBackInfo( &sym, TrySymHandle ); -} - -static void FreeTryTableBackHandles( void ) -{ - try_table_back_handles *try_backinfo; - - for( ; (try_backinfo = TryTableBackHandles) != NULL; ) { - TryTableBackHandles = try_backinfo->next; - BEFreeBack( try_backinfo->back_handle ); - CMemFree( try_backinfo ); - } -} -#endif - -static void FreeLocalVars( SYM_HANDLE sym_list ) -{ - SYM_HANDLE sym_handle; - SYM_ENTRY sym; - - for( sym_handle = sym_list; sym_handle != SYM_NULL; sym_handle = sym.handle) { - SymGet( &sym, sym_handle ); - if( sym.attribs.stg_class != SC_EXTERN ) { - if( (sym.flags & SYM_FUNC_RETURN_VAR) == 0 ) { - if( sym.sym_type->decl_type != TYP_VOID ) { - FreeSymBackInfo( &sym, sym_handle ); - } + SYM_ENTRY sym; + + for( sym_handle = GlobalSym; sym_handle != SYM_NULL; sym_handle = sym.handle ) { + SymGet( &sym, sym_handle ); + EmitSym( &sym, sym_handle ); + if( (GenSwitches & CGSW_GEN_DBG_LOCALS ) + && ( sym.sym_type->decl_type != TYP_FUNCTION ) + && ( (sym.flags & SYM_TEMP) == 0 ) + && ( sym.attribs.stg_class != SC_TYPEDEF ) ) { +#if _CPU == 370 + if( sym.attribs.stg_class != SC_EXTERN || (sym.flags & SYM_REFERENCED) ) { + DBModSym( (CGSYM_HANDLE)sym_handle, TY_DEFAULT ); } +#else + DBModSym( (CGSYM_HANDLE)sym_handle, TY_DEFAULT ); +#endif } } } @@ -1822,6 +1882,80 @@ static void FreeExtVars( void ) } } +void DoCompile( void ) +{ + jmp_buf *old_env; + jmp_buf env; + cg_init_info cgi_info; + + old_env = Environment; + if( setjmp( env ) == 0 ) { + Environment = JMPBUF_PTR( env ); + if( BELoad( NULL ) ) { +#if _INTEL_CPU + if( ! CompFlags.zu_switch_used ) { + TargetSwitches &= ~ CGSW_X86_FLOATING_SS; + } +#endif +#ifdef DEVBUILD + if( TOGGLEDBG( dump_cg ) ) { + GenSwitches |= CGSW_GEN_ECHO_API_CALLS; + } +#endif + if( CompFlags.rent ) { + GenSwitches |= CGSW_GEN_POSITION_INDEPENDANT; + } + cgi_info = BEInit( GenSwitches, TargetSwitches, OptSize, ProcRevision ); + if( cgi_info.success ) { +#if _CPU == 386 + if( TargetSwitches & (CGSW_X86_P5_PROFILING | CGSW_X86_NEW_P5_PROFILING) ) { + FunctionProfileSegId = AddSegName( "TI", "DATA", SEGTYPE_INITFINI ); + } +#endif + SetSegs(); + BEStart(); + EmitSegLabels(); + if( GenSwitches & CGSW_GEN_DBG_TYPES ) + EmitDBType(); + EmitSyms(); + EmitCS_Strings(); + SrcLoc.line = 0; + SrcLoc.column = 0; + SrcLoc.fno = 0; + EmitDataQuads(); + FreeDataQuads(); +#ifdef __SEH__ + TryRefno = NewRefno(); + BEDefType( TryRefno, 1, TRY_BLOCK_SIZE ); + TryTableBackHandles = NULL; +#endif + PruneFunctions(); + GenModuleCode(); + FreeStrings(); + FiniSegLabels(); + if( ErrCount != 0 ) { + BEAbort(); + } + BEStop(); + FiniSegBacks(); + FreeGblVars( GlobalSym ); + FreeGblVars( SpecialSyms ); + FreeExtVars(); +#ifdef __SEH__ + FreeTryTableBackHandles(); +#endif + BEFini(); + BEUnload(); + SegFini(); + } + } else { + NoCodeGenDLL(); + } + } + Environment = old_env; +} + + cg_type CGenType( TYPEPTR typ ) { cg_type dtype; @@ -1882,28 +2016,6 @@ cg_type CGenType( TYPEPTR typ ) } -static cg_type CodePtrType( type_modifiers flags ) -{ -#if _INTEL_CPU - cg_type dtype; - - if( flags & FLAG_FAR ) { - dtype = TY_LONG_CODE_PTR; - } else if( flags & FLAG_NEAR ) { - dtype = TY_NEAR_CODE_PTR; - } else { - dtype = TY_CODE_PTR; - } - return( dtype ); -#else /* _RISC_CPU */ - - /* unused parameters */ (void)flags; - - return( TY_CODE_PTR ); -#endif -} - - extern cg_type PtrType( TYPEPTR typ, type_modifiers flags ) { cg_type dtype; @@ -1930,154 +2042,9 @@ extern cg_type PtrType( TYPEPTR typ, type_modifiers flags ) } -static segment_id StringSegment( STR_HANDLE strlit ) -{ -#if _INTEL_CPU - if( strlit->flags & STRLIT_FAR ) - return( FarStringSegId ); -#endif - if( strlit->flags & STRLIT_CONST ) - return( SEG_CODE ); - return( SEG_CONST ); -} - void EmitStrPtr( STR_HANDLE str_handle, cg_type pointer_type ) { str_handle->ref_count++; Emit1String( str_handle ); DGBackPtr( str_handle->back_handle, StringSegment( str_handle ), 0, pointer_type ); } - - -static void Emit1String( STR_HANDLE str_handle ) -{ - if( str_handle->back_handle == NULL ) { - str_handle->back_handle = BENewBack( NULL ); - if( (str_handle->flags & STRLIT_CONST) == 0 ) { - EmitLiteral( str_handle ); - } - } -} - - -target_size EmitBytes( STR_HANDLE strlit ) -{ - DGBytes( strlit->length, strlit->literal ); - return( strlit->length ); -} - - -static void EmitLiteral( STR_HANDLE strlit ) -{ - segment_id old_segid; - - old_segid = BESetSeg( StringSegment( strlit ) ); - if( strlit->flags & STRLIT_WIDE ) { - DGAlign( TARGET_SHORT ); /* NT requires word aligned wide strings */ - } - DGLabel( strlit->back_handle ); - EmitBytes( strlit ); - BESetSeg( old_segid ); -} - - -static void FreeStrings( void ) -{ - STR_HANDLE strlit; - STR_HANDLE strlit_next; - str_hash_idx hash; - - for( hash = 0; hash < STRING_HASH_SIZE; hash++ ) { - for( strlit = StringHash[hash]; strlit != NULL; strlit = strlit_next ) { - strlit_next = strlit->next_string; - if( strlit->back_handle != NULL ) { - BEFiniBack( strlit->back_handle ); - BEFreeBack( strlit->back_handle ); - strlit->back_handle = NULL; - } - FreeLiteral( strlit ); - } - StringHash[hash] = NULL; - } -} - - -static void DumpCS_Strings( STR_HANDLE strlit ) -{ - for( ; strlit != NULL; strlit = strlit->next_string ) { - if( (strlit->flags & STRLIT_CONST) && strlit->ref_count != 0 ) { - strlit->back_handle = BENewBack( NULL ); - EmitLiteral( strlit ); - } - } -} - - -static void EmitCS_Strings( void ) -{ - str_hash_idx hash; - - if( CompFlags.strings_in_code_segment ) { - for( hash = STRING_HASH_SIZE; hash-- > 0; ) { - DumpCS_Strings( StringHash[hash] ); - } - } -} - -#ifdef __SEH__ -static void GenerateTryBlock( TREEPTR tree ) -{ - TREEPTR stmt; - tryindex_t try_index; - tryindex_t max_try_index; - - try_index = 0; - max_try_index = TRYSCOPE_NONE; - for( ; tree != NULL; tree = tree->left ) { - stmt = tree->right; - if( stmt->op.opr == OPR_FUNCEND ) - break; - switch( stmt->op.opr ) { - case OPR_TRY: - try_index = stmt->op.u2.st.u.try_index; - if( max_try_index < try_index ) - max_try_index = try_index; - break; - case OPR_EXCEPT: - case OPR_FINALLY: - ValueStack[try_index] = stmt; - break; - default: - break; - } - } - if( max_try_index != TRYSCOPE_NONE ) { - segment_id old_segid; - BACK_HANDLE except_label; - BACK_HANDLE except_table; - try_table_back_handles *try_backinfo; - - old_segid = BESetSeg( SEG_DATA ); - except_table = BENewBack( NULL ); - try_backinfo = (try_table_back_handles *)CMemAlloc( sizeof( try_table_back_handles ) ); - try_backinfo->back_handle = except_table; - try_backinfo->next = TryTableBackHandles; - TryTableBackHandles = try_backinfo; - DGLabel( except_table ); - for( try_index = 0; try_index <= max_try_index; try_index++ ) { - stmt = ValueStack[try_index]; - DGInteger( stmt->op.u2.st.parent_scope, TY_UINT_1 ); // parent index - if( stmt->op.opr == OPR_EXCEPT ) { - DGInteger( 0, TY_UINT_1 ); - } else { - DGInteger( 1, TY_UINT_1 ); - } - except_label = FEBack( (CGSYM_HANDLE)stmt->op.u2.st.u.try_sym_handle ); - DGBackPtr( except_label, FESegID( (CGSYM_HANDLE)CurFuncHandle ), 0, TY_CODE_PTR ); - } - BESetSeg( old_segid ); - SetTryTable( except_table ); - BEFiniBack( except_table ); - } -} -#endif From 680da4c329fc0c7db444522f1906a517cacbbea4 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Fri, 29 Sep 2023 18:22:10 +0200 Subject: [PATCH 174/258] do call class data handling code more generic --- bld/cc/c/cfeinfo.c | 15 ++++++++------- bld/cc/c/cmath.c | 7 ++++++- bld/cc/h/cfeinfo.h | 5 +---- bld/cg/h/cgaux.h | 4 +--- bld/cg/risc/axp/h/cgauxccc.h | 6 +++--- bld/cg/risc/mps/h/cgauxccc.h | 6 +++--- bld/cg/risc/ppc/h/cgauxccc.h | 6 +++--- bld/f77/wfc/c/wf77info.c | 4 +++- bld/fe_misc/h/callinfo.h | 2 -- bld/plusplus/c/cginfo.c | 12 +++++++----- 10 files changed, 35 insertions(+), 32 deletions(-) diff --git a/bld/cc/c/cfeinfo.c b/bld/cc/c/cfeinfo.c index 8256f003bd..03c8f6429a 100644 --- a/bld/cc/c/cfeinfo.c +++ b/bld/cc/c/cfeinfo.c @@ -505,15 +505,15 @@ call_class GetCallClass( SYM_HANDLE sym_handle ) return( cclass ); } -#if _INTEL_CPU -call_class_target GetCallClassTarget( SYM_HANDLE sym_handle ) -/************************************************************ +static call_class_target GetCallClassTarget( SYM_HANDLE sym_handle ) +/******************************************************************* * handle only target specific attributes for call class */ { + call_class_target cclass_target; +#if _INTEL_CPU aux_info *inf; SYM_ENTRY sym; - call_class_target cclass_target; sym.mods = 0; inf = FindInfo( &sym, sym_handle ); @@ -569,9 +569,12 @@ call_class_target GetCallClassTarget( SYM_HANDLE sym_handle ) if( CompFlags.st_switch_used ) { cclass_target |= FECALL_X86_TOUCH_STACK; } +#else + /* unused parameters */ (void)sym_handle; + cclass_target = 0; +#endif return( cclass_target ); } -#endif static void addDefaultLibs( void ) /********************************* @@ -1117,10 +1120,8 @@ CGPOINTER FEAuxInfo( CGPOINTER req_handle, aux_class request ) } case FEINF_CALL_CLASS: return( (CGPOINTER)GetCallClass( req_handle ) ); -#if _INTEL_CPU case FEINF_CALL_CLASS_TARGET: return( (CGPOINTER)GetCallClassTarget( req_handle ) ); -#endif case FEINF_FREE_SEGMENT: return( NULL ); case FEINF_NEXT_LIBRARY: diff --git a/bld/cc/c/cmath.c b/bld/cc/c/cmath.c index 6d474a1642..b4d3abf42f 100644 --- a/bld/cc/c/cmath.c +++ b/bld/cc/c/cmath.c @@ -739,7 +739,10 @@ static bool IsZero( TREEPTR tree ) static TREEPTR BaseConv( TYPEPTR typ1, TREEPTR op2 ) { TYPEPTR typ2; - type_modifiers typ1_flags, typ2_flags; +#if _INTEL_CPU + type_modifiers typ1_flags; +#endif + type_modifiers typ2_flags; typ2 = op2->u.expr_type; /* @@ -750,7 +753,9 @@ static TREEPTR BaseConv( TYPEPTR typ1, TREEPTR op2 ) * skip typedefs, go into enum base */ typ2 = SkipTypeFluff( typ2 ); +#if _INTEL_CPU typ1_flags = typ1->u.p.decl_flags; +#endif typ2_flags = typ2->u.p.decl_flags; if( typ1->decl_type == TYP_POINTER && typ2->decl_type == TYP_POINTER ) { #if _INTEL_CPU diff --git a/bld/cc/h/cfeinfo.h b/bld/cc/h/cfeinfo.h index b41cd4e616..57a42a5648 100644 --- a/bld/cc/h/cfeinfo.h +++ b/bld/cc/h/cfeinfo.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -33,9 +33,6 @@ extern bool VarFunc( SYMPTR ); extern bool VarParm( SYMPTR ); extern call_class GetCallClass( SYM_HANDLE ); -#if _INTEL_CPU -extern call_class_target GetCallClassTarget( SYM_HANDLE ); -#endif extern aux_info *FindInfo( SYMPTR, SYM_HANDLE ); extern bool FunctionAborts( SYMPTR, SYM_HANDLE ); extern bool ParmsToBeReversed( type_modifiers, aux_info * ); diff --git a/bld/cg/h/cgaux.h b/bld/cg/h/cgaux.h index 569627eca5..29c5c79910 100644 --- a/bld/cg/h/cgaux.h +++ b/bld/cg/h/cgaux.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -44,9 +44,7 @@ typedef enum { FEINF_AUX_LOOKUP, FEINF_CALL_BYTES, FEINF_CALL_CLASS, -#if _TARGET_INTEL || _INTEL_CPU FEINF_CALL_CLASS_TARGET, -#endif FEINF_FREE_SEGMENT, FEINF_OBJECT_FILE_NAME, FEINF_PARM_REGS, diff --git a/bld/cg/risc/axp/h/cgauxccc.h b/bld/cg/risc/axp/h/cgauxccc.h index 103e693943..5ba332c8b7 100644 --- a/bld/cg/risc/axp/h/cgauxccc.h +++ b/bld/cg/risc/axp/h/cgauxccc.h @@ -31,7 +31,7 @@ ****************************************************************************/ -//typedef enum { -// FECALL_AXP_NONE = 0, +typedef enum { + FECALL_AXP_NONE = 0, // FECALL_AXP_.... = 0x00000001, -//} call_class_target; +} call_class_target; diff --git a/bld/cg/risc/mps/h/cgauxccc.h b/bld/cg/risc/mps/h/cgauxccc.h index 32dcaacee1..ca03ad99f6 100644 --- a/bld/cg/risc/mps/h/cgauxccc.h +++ b/bld/cg/risc/mps/h/cgauxccc.h @@ -31,7 +31,7 @@ ****************************************************************************/ -//typedef enum { -// FECALL_MPS_NONE = 0, +typedef enum { + FECALL_MPS_NONE = 0, // FECALL_MPS_.... = 0x00000001, -//} call_class_target; +} call_class_target; diff --git a/bld/cg/risc/ppc/h/cgauxccc.h b/bld/cg/risc/ppc/h/cgauxccc.h index 191e61cba8..fb3f514c68 100644 --- a/bld/cg/risc/ppc/h/cgauxccc.h +++ b/bld/cg/risc/ppc/h/cgauxccc.h @@ -31,7 +31,7 @@ ****************************************************************************/ -//typedef enum { -// FECALL_PPC_NONE = 0, +typedef enum { + FECALL_PPC_NONE = 0, // FECALL_PPC_.... = 0x00000001, -//} call_class_target; +} call_class_target; diff --git a/bld/f77/wfc/c/wf77info.c b/bld/f77/wfc/c/wf77info.c index b25ace4227..ee506eb053 100644 --- a/bld/f77/wfc/c/wf77info.c +++ b/bld/f77/wfc/c/wf77info.c @@ -1807,10 +1807,12 @@ pointer FEAuxInfo( pointer req_handle, aux_class request ) case FEINF_CALL_CLASS : info = GetAuxInfo( req_handle ); return( (pointer)(call_class)( info->cclass ^ FECALL_GEN_REVERSE_PARMS ) ); -#if _INTEL_CPU case FEINF_CALL_CLASS_TARGET : +#if _INTEL_CPU info = GetAuxInfo( req_handle ); return( (pointer)info->cclass_target ); +#else + return( (pointer)0 ); #endif case FEINF_SAVE_REGS : info = GetAuxInfo( req_handle ); diff --git a/bld/fe_misc/h/callinfo.h b/bld/fe_misc/h/callinfo.h index 2b076d2243..6a9157e274 100644 --- a/bld/fe_misc/h/callinfo.h +++ b/bld/fe_misc/h/callinfo.h @@ -43,9 +43,7 @@ typedef struct aux_info { call_class cclass; - #if _INTEL_CPU call_class_target cclass_target; - #endif byte_seq *code; // also used by pre-compiled header hw_reg_set *parms; // also used by pre-compiled header hw_reg_set returns; diff --git a/bld/plusplus/c/cginfo.c b/bld/plusplus/c/cginfo.c index 5652c923d8..b23455d3b3 100644 --- a/bld/plusplus/c/cginfo.c +++ b/bld/plusplus/c/cginfo.c @@ -866,17 +866,17 @@ static call_class getCallClass( SYMBOL sym ) return( cclass ); } -#if _INTEL_CPU static call_class_target getCallClassTarget( SYMBOL sym ) // - symbol /******************************************************** * handle only target specific attributes for call class */ { + call_class_target cclass_target; // - call class +#if _INTEL_CPU AUX_INFO *inf; // - aux info. for symbol TYPE fn_type; // - function type type_flag flags; // - flags for the function TYPE type_flag fn_flags; // - flags in the function TYPE - call_class_target cclass_target; // - call class inf = getLangInfo( sym ); cclass_target = inf->cclass_target; @@ -955,9 +955,13 @@ static call_class_target getCallClassTarget( SYMBOL sym ) cclass_target |= FECALL_X86_TOUCH_STACK; } } +#else + /* unused parameters */ (void)sym; + + cclass_target = 0; +#endif return( cclass_target ); } -#endif static sym_access getSymAccess( // GET access flag of symbol SYMBOL sym ) // - symbol @@ -1341,12 +1345,10 @@ void *FEAuxInfo( // REQUEST AUXILLIARY INFORMATION DbgNotRetn(); retn = (void *)getCallClass( sym ); break; -#if _INTEL_CPU case FEINF_CALL_CLASS_TARGET: DbgNotRetn(); retn = (void *)getCallClassTarget( sym ); break; -#endif case FEINF_FREE_SEGMENT: DbgNotSym(); DbgNotRetn(); From 4c940f8abd0d08c28c43f41c580b13775be593f1 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Fri, 29 Sep 2023 19:21:11 +0200 Subject: [PATCH 175/258] reformat source code --- bld/cc/c/ccheck.c | 95 ++++++++++++++++++++++++++++++----------------- 1 file changed, 60 insertions(+), 35 deletions(-) diff --git a/bld/cc/c/ccheck.c b/bld/cc/c/ccheck.c index 713d53b735..290f8d50ae 100644 --- a/bld/cc/c/ccheck.c +++ b/bld/cc/c/ccheck.c @@ -1,4 +1,3 @@ -/**************************************************************************** * * Open Watcom Project * @@ -172,7 +171,8 @@ static cmp_type CompatibleStructs( TAGPTR tag1, TAGPTR tag2 ) /* * if either struct is undefined, let's be conservative */ - if( (field1 == NULL) || (field2 == NULL) ) + if( (field1 == NULL) + || (field2 == NULL) ) return( NO ); for( ; field1 != NULL && field2 != NULL; ) { typ1 = field1->field_type; @@ -180,8 +180,8 @@ static cmp_type CompatibleStructs( TAGPTR tag1, TAGPTR tag2 ) typ2 = field2->field_type; SKIP_TYPEDEFS( typ2 ); if( !IdenticalType( typ1, typ2 ) ) { - if( ( typ1->decl_type == TYP_STRUCT && typ2->decl_type == TYP_STRUCT ) || - ( typ1->decl_type == TYP_UNION && typ2->decl_type == TYP_UNION ) ) { + if( ( typ1->decl_type == TYP_STRUCT && typ2->decl_type == TYP_STRUCT ) + || ( typ1->decl_type == TYP_UNION && typ2->decl_type == TYP_UNION ) ) { if( CompatibleStructs( typ1->u.tag, typ2->u.tag ) != OK ) { return( NO ); } @@ -195,7 +195,8 @@ static cmp_type CompatibleStructs( TAGPTR tag1, TAGPTR tag2 ) /* * one list longer than other (possible with -zp4) */ - if( field1 != NULL || field2 != NULL ) + if( field1 != NULL + || field2 != NULL ) return( NO ); return( OK ); } @@ -232,7 +233,8 @@ static typecheck_err ChkCompatibleFunctionParms( TYPEPTR typ1, TYPEPTR typ2, boo } else { p1 = *plist1++; p2 = *plist2++; for( parmno = 1; p1 != NULL && p2 != NULL; ++parmno ) { - if( p1->decl_type == TYP_DOT_DOT_DOT || p2->decl_type == TYP_DOT_DOT_DOT ) { + if( p1->decl_type == TYP_DOT_DOT_DOT + || p2->decl_type == TYP_DOT_DOT_DOT ) { break; } if( !IdenticalType( p1, p2 ) ) { @@ -245,11 +247,13 @@ static typecheck_err ChkCompatibleFunctionParms( TYPEPTR typ1, TYPEPTR typ2, boo } p1 = *plist1++; p2 = *plist2++; } - if( p1 != NULL && p1->decl_type == TYP_DOT_DOT_DOT || p2 != NULL && p2->decl_type == TYP_DOT_DOT_DOT ) { + if( ( p1 != NULL && p1->decl_type == TYP_DOT_DOT_DOT ) + || ( p2 != NULL && p2->decl_type == TYP_DOT_DOT_DOT ) ) { p1 = NULL; p2 = NULL; } - if( p1 != NULL || p2 != NULL ) { + if( p1 != NULL + || p2 != NULL ) { if( topLevelCheck ) { CErr1( ERR_PARM_COUNT_MISMATCH ); } @@ -300,7 +304,8 @@ static cmp_type DoCompatibleType( TYPEPTR typ1, TYPEPTR typ2, int ptr_indir_leve /* * See C99, 6.7.5.2p5 */ - if( typ1->u.array->dimension && typ2->u.array->dimension ) { + if( typ1->u.array->dimension + && typ2->u.array->dimension ) { if( typ1->u.array->dimension != typ2->u.array->dimension ) { ret_val = PM; } @@ -309,7 +314,7 @@ static cmp_type DoCompatibleType( TYPEPTR typ1, TYPEPTR typ2, int ptr_indir_leve typ1_flags = typ1->u.p.decl_flags; typ2_flags = typ2->u.p.decl_flags; if( (typ1_flags & MASK_QUALIFIERS) != (typ2_flags & MASK_QUALIFIERS) ) { - if( ret_val == OK ) { //PM is a worse case + if( ret_val == OK ) { // PM is a worse case ret_val = PQ; } } @@ -329,18 +334,21 @@ static cmp_type DoCompatibleType( TYPEPTR typ1, TYPEPTR typ2, int ptr_indir_leve } if( typ1 != typ2 ) { // if not equal see if diff by pointers if( ptr_indir_level > 0 ) { - if( typ1->decl_type == TYP_VOID || typ2->decl_type == TYP_VOID ) { + if( typ1->decl_type == TYP_VOID + || typ2->decl_type == TYP_VOID ) { /* * allow void ** with any ** (but warn about it) */ - if( ( ptr_indir_level == 1 ) || !CompFlags.strict_ANSI ) { + if( ( ptr_indir_level == 1 ) + || !CompFlags.strict_ANSI ) { if( ptr_indir_level > 1 ) { ret_val = PM; } return( ret_val ); // void * and anything * } } - if( typ1->decl_type == TYP_POINTER && typ2->decl_type != TYP_ARRAY ) { + if( typ1->decl_type == TYP_POINTER + && typ2->decl_type != TYP_ARRAY ) { ret_val = PW; while( typ1->decl_type == TYP_POINTER ) { /* @@ -349,7 +357,8 @@ static cmp_type DoCompatibleType( TYPEPTR typ1, TYPEPTR typ2, int ptr_indir_leve typ1 = SkipTypeFluff( typ1->object ); ++ptr_indir_level; } - } else if( typ2->decl_type == TYP_POINTER && typ1->decl_type != TYP_ARRAY ) { + } else if( typ2->decl_type == TYP_POINTER + && typ1->decl_type != TYP_ARRAY ) { ret_val = PW; while( typ2->decl_type == TYP_POINTER ) { /* @@ -372,12 +381,13 @@ static cmp_type DoCompatibleType( TYPEPTR typ1, TYPEPTR typ2, int ptr_indir_leve } else if( !IdenticalType( typ1->object, typ2->object ) ) { ret_val = NO; } - } else if( typ1->decl_type == TYP_STRUCT || typ1->decl_type == TYP_UNION ) { + } else if( typ1->decl_type == TYP_STRUCT + || typ1->decl_type == TYP_UNION ) { /* * allow pointers to different structs * stop this for ANSI! */ - if( ( typ1 != typ2 ) ) { + if( typ1 != typ2 ) { /* * Types are not the same * if extensions are enabled, then we can do a compatible struct test @@ -398,18 +408,21 @@ static cmp_type DoCompatibleType( TYPEPTR typ1, TYPEPTR typ2, int ptr_indir_leve ret_val = NO; } } - } else if( ( TYP_FIELD == typ1->decl_type ) || ( TYP_UFIELD == typ1->decl_type ) ) { + } else if( ( TYP_FIELD == typ1->decl_type ) + || ( TYP_UFIELD == typ1->decl_type ) ) { if( typ2->u.f.field_width > typ1->u.f.field_width ) { ret_val = AC; } } - } else if( typ1->decl_type == TYP_UNION && ptr_indir_level > 0 ) { + } else if( typ1->decl_type == TYP_UNION + && ptr_indir_level > 0 ) { if( InUnion( typ1, typ2, false ) != OK ) { ret_val = NO; } else { ret_val = PM; } - } else if( typ2->decl_type == TYP_UNION && ptr_indir_level > 0 ) { + } else if( typ2->decl_type == TYP_UNION + && ptr_indir_level > 0 ) { if( InUnion( typ2, typ1, true ) != OK ) { ret_val = NO; } else { @@ -435,7 +448,8 @@ static cmp_type DoCompatibleType( TYPEPTR typ1, TYPEPTR typ2, int ptr_indir_leve ret_val = PM; } } - } else if( typ1->decl_type >= DATA_TYPE_SIZE || typ2->decl_type >= DATA_TYPE_SIZE ) { + } else if( typ1->decl_type >= DATA_TYPE_SIZE + || typ2->decl_type >= DATA_TYPE_SIZE ) { ret_val = NO; } else if( ptr_indir_level == 0 ) { ret_val = CompTable[typ1->decl_type][typ2->decl_type]; @@ -488,7 +502,8 @@ static cmp_type CompatibleType( TYPEPTR typ1, TYPEPTR typ2, bool assignment, boo * skip typedefs, go into enum base */ typ2 = SkipTypeFluff( typ2 ); - if( typ1->decl_type == TYP_POINTER && typ2->decl_type == TYP_POINTER ) { + if( typ1->decl_type == TYP_POINTER + && typ2->decl_type == TYP_POINTER ) { /* * top level pointer */ @@ -498,14 +513,15 @@ static cmp_type CompatibleType( TYPEPTR typ1, TYPEPTR typ2, bool assignment, boo * Special dispensation: assigning null pointer constant is allowed even * when the pointer size doesn't match. Required for MS compatibility. */ - if( assignment && !null_ptr ) { + if( assignment + && !null_ptr ) { type_modifiers subnot; subnot = SUBNOT( typ1_flags, typ2_flags, MASK_QUALIFIERS ); if( subnot ) { // allow void * = unaligned * if( subnot & (MASK_QUALIFIERS & ~FLAG_UNALIGNED) ) { ret_pq = PQ; - } else if( subnot & FLAG_UNALIGNED) { + } else if( subnot & FLAG_UNALIGNED ) { align_type align1; align1 = GetTypeAlignment( typ1->object ); @@ -626,13 +642,15 @@ static void CompareParms( TYPEPTR *master, TREEPTR parms, bool reverse ) */ ParmAsgnCheck( typ1, parm, parmno, false ); typ1 = *master++; - if( typ1 != NULL && typ1->decl_type == TYP_DOT_DOT_DOT ) { + if( typ1 != NULL + && typ1->decl_type == TYP_DOT_DOT_DOT ) { typ1 = NULL; parm = NULL; break; } } - if( typ1 != NULL || parm != NULL ) { /* should both be NULL now */ + if( typ1 != NULL + || parm != NULL ) { /* should both be NULL now */ #if _CPU == 386 /* * can allow wrong number of parms with -3s option @@ -675,7 +693,8 @@ extern void ChkCallParms( void ) if( (sym.flags & SYM_TEMP) == 0 ) SetDiagSymbol( &sym, callsite->op.u2.sym_handle ); SetErrLoc( &nextcall->src_loc ); - if( typ->u.fn.parms == NULL && callnode->right == NULL ) { + if( typ->u.fn.parms == NULL + && callnode->right == NULL ) { /* * this relax case * if function prototype is defined without any parameter type @@ -732,10 +751,12 @@ bool AssRangeChk( TYPEPTR typ1, TREEPTR opnd2 ) case TYP_ULONG: case TYP_LONG64: case TYP_ULONG64: - if( opnd2->u.expr_type->decl_type == TYP_LONG64 || opnd2->u.expr_type->decl_type == TYP_ULONG64 ) { + if( opnd2->u.expr_type->decl_type == TYP_LONG64 + || opnd2->u.expr_type->decl_type == TYP_ULONG64 ) { value = opnd2->op.u2.ulong64_value.u._32[I64HI32]; sign = ( value == 0xffffffffU ); - if( value != 0 && !sign ) { + if( value != 0 + && !sign ) { return( typ1->decl_type == TYP_LONG64 || typ1->decl_type == TYP_ULONG64 ); } value = opnd2->op.u2.ulong64_value.u._32[I64LO32]; @@ -911,7 +932,8 @@ void ParmAsgnCheck( TYPEPTR typ1, TREEPTR opnd2, int parmno, bool asgn_check ) break; case PC: if( asgn_check ) { /* Allow only "... *p = int 0"; */ - if( IsPointer( typ1 ) && opnd2->op.opr == OPR_PUSHINT ) { + if( IsPointer( typ1 ) + && opnd2->op.opr == OPR_PUSHINT ) { if( opnd2->op.u2.long_value != 0 ) { CWarnP1( parmno, ERR_NONPORTABLE_PTR_CONV ); } @@ -1069,10 +1091,10 @@ static typecheck_err TypeCheck( TYPEPTR typ1, TYPEPTR typ2, SYMPTR sym ) break; } } - if( TypeSize(typ1) != TypeSize(typ2) ) { - if( TypeSize(typ1) == 0 ) { + if( TypeSize( typ1 ) != TypeSize( typ2 ) ) { + if( TypeSize( typ1 ) == 0 ) { retcode = TCE_TYPE2_HAS_MORE_INFO; - } else if( TypeSize(typ2) == 0 ) { + } else if( TypeSize( typ2 ) == 0 ) { retcode = TCE_OK; } else { break; @@ -1081,12 +1103,14 @@ static typecheck_err TypeCheck( TYPEPTR typ1, TYPEPTR typ2, SYMPTR sym ) return( retcode ); } } - if( ( TYP_FIELD == typ1->decl_type ) || ( TYP_UFIELD == typ1->decl_type ) ) { + if( ( TYP_FIELD == typ1->decl_type ) + || ( TYP_UFIELD == typ1->decl_type ) ) { if( typ1->u.f.field_width != typ2->u.f.field_width ) { break; } } - if( typ1->decl_type == TYP_STRUCT || typ1->decl_type == TYP_UNION ) { + if( typ1->decl_type == TYP_STRUCT + || typ1->decl_type == TYP_UNION ) { /* * must be the same tag to be identical, if they are the * same tag, then typ1 == typ2 which is checked above @@ -1097,7 +1121,8 @@ static typecheck_err TypeCheck( TYPEPTR typ1, TYPEPTR typ2, SYMPTR sym ) retcode = ChkCompatibleFunctionParms( typ1, typ2, false ); if( retcode != TCE_OK ) return( retcode ); - if( typ1->object == NULL || typ2->object == NULL ) { + if( typ1->object == NULL + || typ2->object == NULL ) { return( TCE_OK ); } } From ea8efbdef3adddae5747deaa2fe39bd6c934aa99 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Fri, 29 Sep 2023 19:29:44 +0200 Subject: [PATCH 176/258] correct mistake --- bld/cc/c/ccheck.c | 1 + 1 file changed, 1 insertion(+) diff --git a/bld/cc/c/ccheck.c b/bld/cc/c/ccheck.c index 290f8d50ae..66db229d61 100644 --- a/bld/cc/c/ccheck.c +++ b/bld/cc/c/ccheck.c @@ -1,3 +1,4 @@ +/**************************************************************************** * * Open Watcom Project * From 52329c636031818cef197a29606a37e039933ad7 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Fri, 29 Sep 2023 20:11:00 +0200 Subject: [PATCH 177/258] cleanup C compiler code --- bld/cc/c/cfeinfo.c | 11 ++++++----- bld/cc/c/cgen.c | 21 ++++++++++++++------- bld/cc/h/cfeinfo.h | 1 - 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/bld/cc/c/cfeinfo.c b/bld/cc/c/cfeinfo.c index 03c8f6429a..5269c19663 100644 --- a/bld/cc/c/cfeinfo.c +++ b/bld/cc/c/cfeinfo.c @@ -468,8 +468,8 @@ bool FunctionAborts( SYMPTR sym, SYM_HANDLE sym_handle ) return( false ); } -call_class GetCallClass( SYM_HANDLE sym_handle ) -/*********************************************** +static call_class getCallClass( SYM_HANDLE sym_handle ) +/****************************************************** * handle only generic attributes for call class */ { @@ -505,7 +505,7 @@ call_class GetCallClass( SYM_HANDLE sym_handle ) return( cclass ); } -static call_class_target GetCallClassTarget( SYM_HANDLE sym_handle ) +static call_class_target getCallClassTarget( SYM_HANDLE sym_handle ) /******************************************************************* * handle only target specific attributes for call class */ @@ -571,6 +571,7 @@ static call_class_target GetCallClassTarget( SYM_HANDLE sym_handle ) } #else /* unused parameters */ (void)sym_handle; + cclass_target = 0; #endif return( cclass_target ); @@ -1119,9 +1120,9 @@ CGPOINTER FEAuxInfo( CGPOINTER req_handle, aux_class request ) return( (CGPOINTER)ModuleName ); } case FEINF_CALL_CLASS: - return( (CGPOINTER)GetCallClass( req_handle ) ); + return( (CGPOINTER)getCallClass( req_handle ) ); case FEINF_CALL_CLASS_TARGET: - return( (CGPOINTER)GetCallClassTarget( req_handle ) ); + return( (CGPOINTER)getCallClassTarget( req_handle ) ); case FEINF_FREE_SEGMENT: return( NULL ); case FEINF_NEXT_LIBRARY: diff --git a/bld/cc/c/cgen.c b/bld/cc/c/cgen.c index 2f95d90374..fa217766cd 100644 --- a/bld/cc/c/cgen.c +++ b/bld/cc/c/cgen.c @@ -1219,19 +1219,26 @@ static bool DoFuncDefn( SYM_HANDLE funcsym_handle ) } parms_reversed = false; if( CurFunc->u.func.parms != SYM_NULL ) { - if( GetCallClass( CurFuncHandle ) & FECALL_GEN_REVERSE_PARMS ) { + SYMPTR psym; +#ifndef REVERSE + aux_info *inf; + SYM_ENTRY sym; + + inf = FindInfo( &sym, CurFuncHandle ); + if( inf->cclass & FECALL_GEN_REVERSE_PARMS ) { ParmReverse( CurFunc->u.func.parms ); parms_reversed = true; } else { - SYMPTR sym; - - for( sym_handle = CurFunc->u.func.parms; sym_handle != SYM_NULL; sym_handle = sym->handle ) { - sym = SymGetPtr( sym_handle ); - if( sym->sym_type->decl_type == TYP_DOT_DOT_DOT ) +#endif + for( sym_handle = CurFunc->u.func.parms; sym_handle != SYM_NULL; sym_handle = psym->handle ) { + psym = SymGetPtr( sym_handle ); + if( psym->sym_type->decl_type == TYP_DOT_DOT_DOT ) break; - CDoParmDecl( sym, sym_handle ); + CDoParmDecl( psym, sym_handle ); } +#ifndef REVERSE } +#endif } CGLastParm(); CDoAutoDecl( CurFunc->u.func.locals ); diff --git a/bld/cc/h/cfeinfo.h b/bld/cc/h/cfeinfo.h index 57a42a5648..7e0f6f87d6 100644 --- a/bld/cc/h/cfeinfo.h +++ b/bld/cc/h/cfeinfo.h @@ -32,7 +32,6 @@ extern bool VarFunc( SYMPTR ); extern bool VarParm( SYMPTR ); -extern call_class GetCallClass( SYM_HANDLE ); extern aux_info *FindInfo( SYMPTR, SYM_HANDLE ); extern bool FunctionAborts( SYMPTR, SYM_HANDLE ); extern bool ParmsToBeReversed( type_modifiers, aux_info * ); From 78c625ee2c323ddf8d0fbe19874bffcbcbf4f1d1 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Fri, 29 Sep 2023 21:55:35 +0200 Subject: [PATCH 178/258] cleanup C compiler code --- bld/cc/c/cfeinfo.c | 4 ++-- bld/cc/c/cgen.c | 2 ++ bld/cc/c/ppexpn.c | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/bld/cc/c/cfeinfo.c b/bld/cc/c/cfeinfo.c index 5269c19663..7909cc75fd 100644 --- a/bld/cc/c/cfeinfo.c +++ b/bld/cc/c/cfeinfo.c @@ -655,8 +655,8 @@ static CGPOINTER NextAlias( int index, aux_class request ) * FEINF_ALIAS_SUBST_SYMBOL * returns the symbol to be substituted for the alias, or NULL. * - * Note: One of FEINF_ALIAS..._NAME and FEINF_ALIAS..._SYMBOL will always be 0/NULL and the other - * will be valid, depending on which form of the pragma was used. + * Note: One of FEINF_ALIAS..._NAME and FEINF_ALIAS..._SYMBOL will always be 0/NULL + * and the other will be valid, depending on which form of the pragma was used. */ { alias_list *aliaslist; diff --git a/bld/cc/c/cgen.c b/bld/cc/c/cgen.c index fa217766cd..324dd0f871 100644 --- a/bld/cc/c/cgen.c +++ b/bld/cc/c/cgen.c @@ -1154,6 +1154,7 @@ static void CDoParmDecl( SYMPTR sym, SYM_HANDLE sym_handle ) } } +#ifndef REVERSE static void ParmReverse( SYM_HANDLE sym_handle ) { SYMPTR sym; @@ -1165,6 +1166,7 @@ static void ParmReverse( SYM_HANDLE sym_handle ) } CDoParmDecl( sym, sym_handle ); } +#endif static bool DoFuncDefn( SYM_HANDLE funcsym_handle ) { diff --git a/bld/cc/c/ppexpn.c b/bld/cc/c/ppexpn.c index 9af2e53ce4..444e7fc4ca 100644 --- a/bld/cc/c/ppexpn.c +++ b/bld/cc/c/ppexpn.c @@ -573,7 +573,7 @@ static bool CConditional( void ) static bool Binary( TOKEN *token, ppvalue *e1, ppvalue *e2, loc_info *loc ) /************************************************************************** - * pop binary operand and two operands, error check + * pop binary operator and two operands, error check */ { loc_info e1_info; From 4ee3c303439886f5b07c9cc371849136113d8fc7 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Fri, 29 Sep 2023 22:47:26 +0200 Subject: [PATCH 179/258] rename cg macros to more transparent names --- bld/cg/c/generate.c | 6 +-- bld/cg/h/procdef.h | 85 ++++++++++++++++++------------------ bld/cg/intel/c/x86proc.c | 46 +++++++++---------- bld/cg/intel/c/x86reg.c | 18 ++++---- bld/cg/intel/c/x86temps.c | 2 +- bld/cg/intel/h/x86prol.h | 23 +++++----- bld/cg/risc/axp/c/axpproc.c | 2 +- bld/cg/risc/axp/h/targprol.h | 3 +- bld/cg/risc/h/rscprol.h | 35 +++++++++++++++ bld/cg/risc/mps/c/mpsproc.c | 2 +- bld/cg/risc/mps/h/targprol.h | 3 +- bld/cg/risc/ppc/c/ppcproc.c | 2 +- bld/cg/risc/ppc/h/targprol.h | 3 +- 13 files changed, 136 insertions(+), 94 deletions(-) create mode 100644 bld/cg/risc/h/rscprol.h diff --git a/bld/cg/c/generate.c b/bld/cg/c/generate.c index 9db00e8492..2f7caffa82 100644 --- a/bld/cg/c/generate.c +++ b/bld/cg/c/generate.c @@ -434,7 +434,7 @@ static void BlockToCode( bool partly_done ) /* generate a prolog that saves all registers*/ - if( ( CurrProc->prolog_state & GENERATED_PROLOG ) == 0 ) { + if( (CurrProc->prolog_state & PST_PROLOG_GENERATED) == 0 ) { CurrProc->state.used = AllCacheRegs(); GenProlog(); } @@ -582,7 +582,7 @@ static void Panic( bool partly_done ) curr_proc = CurrProc; FlushBlocks( partly_done ); if( curr_proc == CurrProc /* if not freed (dummy!) */ - && ( CurrProc->prolog_state & GENERATED_EPILOG ) == 0 ) { + && (CurrProc->prolog_state & PST_EPILOG_GENERATED) == 0 ) { GenEpilog(); FiniStackMap(); FreeProc(); @@ -740,7 +740,7 @@ void Generate( bool routine_done ) UnFixEdges(); OptSegs(); GenObject(); - if( ( CurrProc->prolog_state & GENERATED_EPILOG ) == 0 ) { + if( (CurrProc->prolog_state & PST_EPILOG_GENERATED) == 0 ) { GenEpilog(); } FreeProc(); diff --git a/bld/cg/h/procdef.h b/bld/cg/h/procdef.h index 27fea78e0a..83e622639f 100644 --- a/bld/cg/h/procdef.h +++ b/bld/cg/h/procdef.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -35,64 +36,64 @@ typedef enum { - GENERATED_PROLOG = 0x01, - GENERATED_EPILOG = 0x02, -#include "targprol.h" - _GENERATED__LAST = 0x8000 // force to 2 bytes + #define pick(e,v) PST_ ## e = v, + #include "targprol.h" + #undef pick + PST__LAST = 0x8000, // force to unsigned short type if possible } prolog_state_def; typedef struct var_set { - type_length size; - type_length base; /* base offset from frame pointer */ + type_length size; + type_length base; /* base offset from frame pointer */ } var_set; typedef struct parm_state { - hw_reg_set used; - hw_reg_set *table; - hw_reg_set *curr_entry; - type_length offset; + hw_reg_set used; + hw_reg_set *table; + hw_reg_set *curr_entry; + type_length offset; #if _TARGET & _TARG_PPC - uint_32 gr; - uint_32 fr; + uint_32 gr; + uint_32 fr; #endif } parm_state; typedef struct call_state { - parm_state parm; - hw_reg_set used; - hw_reg_set modify; - hw_reg_set unalterable; - hw_reg_set return_reg; - call_attributes attr; - call_registers regs; + parm_state parm; + hw_reg_set used; + hw_reg_set modify; + hw_reg_set unalterable; + hw_reg_set return_reg; + call_attributes attr; + call_registers regs; } call_state; typedef struct label_id { - struct label_id *next; - label_handle label; - block_num block_id; + struct label_id *next; + label_handle label; + block_num block_id; } label_id; typedef struct proc_def { - target_proc_def targ; - struct var_set parms; - struct var_set locals; - struct call_state state; - struct block *head_block; - struct block *tail_block; - struct proc_def *next_proc; - union name *names[N_CLASS_MAX]; - struct block *curr_block; - pointer frame_index; - pointer label; - int ins_id; - bool block_by_block; - bool untrimmed; - bool contains_call; - level_depth lex_level; - prolog_state_def prolog_state; - union name *lasttemp; - union name *dummy_index; - instruction *parms_list; + target_proc_def targ; + struct var_set parms; + struct var_set locals; + struct call_state state; + struct block *head_block; + struct block *tail_block; + struct proc_def *next_proc; + union name *names[N_CLASS_MAX]; + struct block *curr_block; + pointer frame_index; + pointer label; + int ins_id; + bool block_by_block; + bool untrimmed; + bool contains_call; + level_depth lex_level; + prolog_state_def prolog_state; + union name *lasttemp; + union name *dummy_index; + instruction *parms_list; } proc_def; diff --git a/bld/cg/intel/c/x86proc.c b/bld/cg/intel/c/x86proc.c index d8a93ecc15..ce49daaebc 100644 --- a/bld/cg/intel/c/x86proc.c +++ b/bld/cg/intel/c/x86proc.c @@ -67,7 +67,7 @@ #define WINDOWS_CHEAP ( ( _IsModel( CGSW_GEN_DLL_RESIDENT_CODE ) \ && (CurrProc->state.attr & ROUTINE_LOADS_DS) ) \ || ( _IsTargetModel( CGSW_X86_CHEAP_WINDOWS ) \ - && (CurrProc->prolog_state & (GENERATE_EXPORT | GENERATE_FAT_PROLOG)) == 0 ) ) + && (CurrProc->prolog_state & (PST_EXPORT | PST_PROLOG_FAT)) == 0 ) ) #define DO_WINDOWS_CRAP ( _IsTargetModel( CGSW_X86_WINDOWS ) \ && ( !WINDOWS_CHEAP || CurrProc->contains_call ) ) @@ -75,7 +75,7 @@ #define DO_BP_CHAIN ( ( ( _IsTargetModel( CGSW_X86_NEED_STACK_FRAME ) \ || _IsModel( CGSW_GEN_DBG_CV ) ) \ && CurrProc->contains_call ) \ - || (CurrProc->prolog_state & GENERATE_FAT_PROLOG) ) + || (CurrProc->prolog_state & PST_PROLOG_FAT) ) #define CHAIN_FRAME ( DO_WINDOWS_CRAP || DO_BP_CHAIN ) @@ -300,7 +300,7 @@ static void FindIfExported( void ) if( sym == NULL ) return; if( SymIsExported( sym ) ) { - CurrProc->prolog_state |= GENERATE_EXPORT; + CurrProc->prolog_state |= PST_EXPORT; } } @@ -315,10 +315,10 @@ static bool NeedStackCheck( void ) static void DoStackCheck( void ) /******************************/ { - if( CurrProc->prolog_state & (GENERATE_THUNK_PROLOG | GENERATE_RDOSDEV_PROLOG) ) + if( CurrProc->prolog_state & (PST_PROLOG_THUNK | PST_PROLOG_RDOSDEV) ) return; #if _TARGET & _TARG_80386 - if( CurrProc->prolog_state & GENERATE_GROW_STACK ) { + if( CurrProc->prolog_state & PST_GROW_STACK ) { if( BlockByBlock || CurrProc->locals.size >= 4096 ) { GenUnkPush( &CurrProc->targ.stack_check ); @@ -378,7 +378,7 @@ static void PrologHook( void ) { int size; - if( (CurrProc->prolog_state & GENERATE_PROLOG_HOOKS) == 0 ) + if( (CurrProc->prolog_state & PST_PROLOG_HOOKS) == 0 ) return; size = ProEpiDataSize(); if( size != 0 ) { @@ -399,7 +399,7 @@ static void EpilogHook( void ) { int size; - if( CurrProc->prolog_state & GENERATE_EPILOG_HOOKS ) { + if( CurrProc->prolog_state & PST_EPILOG_HOOKS ) { DoRTCall( RT_EPIHOOK, false ); } size = ProEpiDataSize(); @@ -481,7 +481,7 @@ static void AllocStack( void ) CurrProc->locals.size = size; if( BlockByBlock ) { GenUnkSub( HW_xSP, &CurrProc->targ.prolog_loc ); - if( CurrProc->prolog_state & GENERATE_TOUCH_STACK ) { + if( CurrProc->prolog_state & PST_TOUCH_STACK ) { GenTouchStack( true ); } } else if( size <= 2 * WORD_SIZE @@ -492,13 +492,13 @@ static void AllocStack( void ) } } else if( size != 0 ) { GenRegSub( HW_xSP, size ); - if( CurrProc->prolog_state & GENERATE_TOUCH_STACK ) { + if( CurrProc->prolog_state & PST_TOUCH_STACK ) { GenTouchStack( false ); } } if( CurrProc->targ.sp_align ) { GenRegAnd( HW_xSP, -( 2 * WORD_SIZE ) ); - CurrProc->prolog_state |= GENERATE_RESET_SP; + CurrProc->prolog_state |= PST_RESET_SP; } } @@ -595,13 +595,13 @@ static void DoEnter( level_depth level ) CurrProc->parms.base += WORD_SIZE; if( BlockByBlock ) { GenUnkEnter( &CurrProc->targ.prolog_loc, level ); - if( CurrProc->prolog_state & GENERATE_TOUCH_STACK ) { + if( CurrProc->prolog_state & PST_TOUCH_STACK ) { GenTouchStack( true ); } } else { GenEnter( size, level ); if( size != 0 - && (CurrProc->prolog_state & GENERATE_TOUCH_STACK) ) { + && (CurrProc->prolog_state & PST_TOUCH_STACK) ) { GenTouchStack( false ); } } @@ -677,7 +677,7 @@ static void CalcUsedRegs( void ) if( ins->head.opcode != OP_NOP ) { HW_TurnOn( used, ins->zap->reg ); if( HW_COvlap( ins->zap->reg, HW_xSP ) ) { - CurrProc->prolog_state |= GENERATE_RESET_SP; + CurrProc->prolog_state |= PST_RESET_SP; } } } @@ -773,7 +773,7 @@ static void DoEpilog( void ) } else { if( CurrProc->state.attr & ROUTINE_NEEDS_PROLOG ) { size = CurrProc->locals.size + CurrProc->targ.push_local_size; - if( (CurrProc->prolog_state & GENERATE_RESET_SP) + if( (CurrProc->prolog_state & PST_RESET_SP) || size != 0 ) { /* * sp is not pointing at saved registers already @@ -813,7 +813,7 @@ static void DoEpilog( void ) } } } - if( CurrProc->prolog_state & GENERATE_RDOSDEV_PROLOG ) { + if( CurrProc->prolog_state & PST_PROLOG_RDOSDEV ) { GenRdosdevEpilog(); } } @@ -821,7 +821,7 @@ static void DoEpilog( void ) is_long = ( _RoutineIsLong( CurrProc->state.attr ) || _RoutineIsFar16( CurrProc->state.attr ) ); #if _TARGET & _TARG_80386 - if( CurrProc->prolog_state & GENERATE_THUNK_PROLOG ) { + if( CurrProc->prolog_state & PST_PROLOG_THUNK ) { QuickSave( HW_xSP, OP_POP ); } if( _IsTargetModel( CGSW_X86_NEW_P5_PROFILING ) @@ -929,7 +929,7 @@ void GenProlog( void ) FindIfExported(); old_segid = SetOP( AskCodeSeg() ); - if( CurrProc->prolog_state & GENERATE_FUNCTION_NAME ) { + if( CurrProc->prolog_state & PST_FUNCTION_NAME ) { EmitNameInCode(); } @@ -961,7 +961,7 @@ void GenProlog( void ) attr = FEAttr( AskForLblSym( origlabel ) ); - if( CurrProc->prolog_state & GENERATE_RDOSDEV_PROLOG ) { + if( CurrProc->prolog_state & PST_PROLOG_RDOSDEV ) { GenRdosdevProlog(); } @@ -971,7 +971,7 @@ void GenProlog( void ) || _IsTargetModel( CGSW_X86_P5_PROFILING ) ) { GenP5ProfilingProlog( label ); } - if( CurrProc->prolog_state & GENERATE_THUNK_PROLOG ) { + if( CurrProc->prolog_state & PST_PROLOG_THUNK ) { QuickSave( HW_xSP, OP_PUSH ); GenPushC( CurrProc->parms.size ); GenUnkPush( &CurrProc->targ.stack_check ); @@ -1061,7 +1061,7 @@ void GenProlog( void ) RelocParms(); MoveParms(); } - CurrProc->prolog_state |= GENERATED_PROLOG; + CurrProc->prolog_state |= PST_PROLOG_GENERATED; if( _IsModel( CGSW_GEN_DBG_LOCALS ) ) { // d1+ or d2 DbgRetOffset( CurrProc->parms.base - CurrProc->targ.base_adjust - ret_size ); @@ -1069,7 +1069,7 @@ void GenProlog( void ) } SetOP( old_segid ); - if( CurrProc->prolog_state & GENERATE_EXPORT ) { + if( CurrProc->prolog_state & PST_EXPORT ) { OutDLLExport( WORDS_COUNT( CurrProc->parms.size ), AskForLblSym( CurrProc->label ) ); } } @@ -1210,7 +1210,7 @@ void GenEpilog( void ) } - CurrProc->prolog_state |= GENERATED_EPILOG; + CurrProc->prolog_state |= PST_EPILOG_GENERATED; if( _IsModel( CGSW_GEN_DBG_LOCALS ) ) { // d1+ or d2 EmitRtnEnd(); } @@ -1232,7 +1232,7 @@ int ParmsAtPrologue( void ) parms_off_sp= 0; #if _TARGET & _TARG_80386 - if( CurrProc->prolog_state & GENERATE_THUNK_PROLOG ) { + if( CurrProc->prolog_state & PST_PROLOG_THUNK ) { parms_off_sp += WORD_SIZE; } #endif diff --git a/bld/cg/intel/c/x86reg.c b/bld/cg/intel/c/x86reg.c index dbc4cffcd1..1556cfb679 100644 --- a/bld/cg/intel/c/x86reg.c +++ b/bld/cg/intel/c/x86reg.c @@ -130,32 +130,32 @@ type_class_def CallState( aux_handle aux, type_def *tipe, call_state *state ) } if( state == &CurrProc->state ) { if( cclass_target & (FECALL_X86_GENERATE_STACK_FRAME | FECALL_X86_PROLOG_HOOKS | FECALL_X86_EPILOG_HOOKS) ) { - CurrProc->prolog_state |= GENERATE_FAT_PROLOG; + CurrProc->prolog_state |= PST_PROLOG_FAT; state->attr |= ROUTINE_NEEDS_PROLOG; } if( cclass_target & FECALL_X86_PROLOG_HOOKS ) { - CurrProc->prolog_state |= GENERATE_PROLOG_HOOKS; + CurrProc->prolog_state |= PST_PROLOG_HOOKS; } if( cclass_target & FECALL_X86_EPILOG_HOOKS ) { - CurrProc->prolog_state |= GENERATE_EPILOG_HOOKS; + CurrProc->prolog_state |= PST_EPILOG_HOOKS; } if( cclass_target & FECALL_X86_PROLOG_FAT_WINDOWS ) { - CurrProc->prolog_state |= GENERATE_FAT_PROLOG; + CurrProc->prolog_state |= PST_PROLOG_FAT; } if( cclass_target & FECALL_X86_EMIT_FUNCTION_NAME ) { - CurrProc->prolog_state |= GENERATE_FUNCTION_NAME; + CurrProc->prolog_state |= PST_FUNCTION_NAME; } if( cclass_target & FECALL_X86_THUNK_PROLOG ) { - CurrProc->prolog_state |= GENERATE_THUNK_PROLOG; + CurrProc->prolog_state |= PST_PROLOG_THUNK; } if( cclass_target & FECALL_X86_GROW_STACK ) { - CurrProc->prolog_state |= GENERATE_GROW_STACK; + CurrProc->prolog_state |= PST_GROW_STACK; } if( cclass_target & FECALL_X86_TOUCH_STACK ) { - CurrProc->prolog_state |= GENERATE_TOUCH_STACK; + CurrProc->prolog_state |= PST_TOUCH_STACK; } if( cclass_target & FECALL_X86_LOAD_RDOSDEV_ON_ENTRY ) { - CurrProc->prolog_state |= GENERATE_RDOSDEV_PROLOG; + CurrProc->prolog_state |= PST_PROLOG_RDOSDEV; } } type_class = ReturnTypeClass( tipe, state->attr ); diff --git a/bld/cg/intel/c/x86temps.c b/bld/cg/intel/c/x86temps.c index 138ffcd395..2394a72a01 100644 --- a/bld/cg/intel/c/x86temps.c +++ b/bld/cg/intel/c/x86temps.c @@ -76,7 +76,7 @@ static void AssignPushLocals( void ) { curr_offset = 0; for( ins = HeadBlock->ins.head.next; ins->head.opcode != OP_BLOCK; ins = ins->head.next ) { - if( CurrProc->prolog_state & GENERATED_PROLOG ) + if( CurrProc->prolog_state & PST_PROLOG_GENERATED ) break; if( DoesSomething( ins ) ) { if( ins->head.opcode != OP_MOV ) diff --git a/bld/cg/intel/h/x86prol.h b/bld/cg/intel/h/x86prol.h index 64e1b58b8a..ca3afa8404 100644 --- a/bld/cg/intel/h/x86prol.h +++ b/bld/cg/intel/h/x86prol.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -30,13 +31,15 @@ ****************************************************************************/ - GENERATE_EXPORT = 0x0004, - GENERATE_FAT_PROLOG = 0x0008, - GENERATE_FUNCTION_NAME = 0x0010, - GENERATE_THUNK_PROLOG = 0x0020, - GENERATE_GROW_STACK = 0x0040, - GENERATE_RESET_SP = 0x0080, - GENERATE_PROLOG_HOOKS = 0x0100, - GENERATE_EPILOG_HOOKS = 0x0200, - GENERATE_TOUCH_STACK = 0x0400, - GENERATE_RDOSDEV_PROLOG = 0x0800, +pick( PROLOG_FAT, 0x0001 ) +pick( PROLOG_THUNK, 0x0002 ) +pick( PROLOG_HOOKS, 0x0004 ) +pick( PROLOG_RDOSDEV, 0x0008 ) +pick( PROLOG_GENERATED, 0x0010 ) +pick( EPILOG_HOOKS, 0x0020 ) +pick( EPILOG_GENERATED, 0x0040 ) +pick( EXPORT, 0x0080 ) +pick( FUNCTION_NAME, 0x0100 ) +pick( GROW_STACK, 0x0200 ) +pick( RESET_SP, 0x0400 ) +pick( TOUCH_STACK, 0x0800 ) diff --git a/bld/cg/risc/axp/c/axpproc.c b/bld/cg/risc/axp/c/axpproc.c index 6025654405..60e659644c 100644 --- a/bld/cg/risc/axp/c/axpproc.c +++ b/bld/cg/risc/axp/c/axpproc.c @@ -578,7 +578,7 @@ void GenEpilog( void ) EmitEpiBeg(); emitEpilog( &CurrProc->targ.stack_map ); GenReturn(); - CurrProc->prolog_state |= GENERATED_EPILOG; + CurrProc->prolog_state |= PST_EPILOG_GENERATED; EmitRtnEnd(); SetOP( old_segid ); } diff --git a/bld/cg/risc/axp/h/targprol.h b/bld/cg/risc/axp/h/targprol.h index e2cd1f3ffe..7a87b7cb86 100644 --- a/bld/cg/risc/axp/h/targprol.h +++ b/bld/cg/risc/axp/h/targprol.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -30,4 +31,4 @@ ****************************************************************************/ -/* nothing here yet */ +#include "rscprol.h" diff --git a/bld/cg/risc/h/rscprol.h b/bld/cg/risc/h/rscprol.h new file mode 100644 index 0000000000..49ae160386 --- /dev/null +++ b/bld/cg/risc/h/rscprol.h @@ -0,0 +1,35 @@ +/**************************************************************************** +* +* Open Watcom Project +* +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. +* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. +* +* ======================================================================== +* +* This file contains Original Code and/or Modifications of Original +* Code as defined in and that are subject to the Sybase Open Watcom +* Public License version 1.0 (the 'License'). You may not use this file +* except in compliance with the License. BY USING THIS FILE YOU AGREE TO +* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is +* provided with the Original Code and Modifications, and is also +* available at www.sybase.com/developer/opensource. +* +* The Original Code and all software distributed under the License are +* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM +* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR +* NON-INFRINGEMENT. Please see the License for the specific language +* governing rights and limitations under the License. +* +* ======================================================================== +* +* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE +* DESCRIBE IT HERE! +* +****************************************************************************/ + + +pick( PROLOG_GENERATED, 0x0001 ) +pick( EPILOG_GENERATED, 0x0002 ) diff --git a/bld/cg/risc/mps/c/mpsproc.c b/bld/cg/risc/mps/c/mpsproc.c index 169de83036..d239a05bb6 100644 --- a/bld/cg/risc/mps/c/mpsproc.c +++ b/bld/cg/risc/mps/c/mpsproc.c @@ -609,7 +609,7 @@ void GenEpilog( void ) EmitEpiBeg(); emitEpilog( &CurrProc->targ.stack_map ); GenReturn(); - CurrProc->prolog_state |= GENERATED_EPILOG; + CurrProc->prolog_state |= PST_EPILOG_GENERATED; EmitRtnEnd(); SetOP( old_segid ); } diff --git a/bld/cg/risc/mps/h/targprol.h b/bld/cg/risc/mps/h/targprol.h index e2cd1f3ffe..7a87b7cb86 100644 --- a/bld/cg/risc/mps/h/targprol.h +++ b/bld/cg/risc/mps/h/targprol.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -30,4 +31,4 @@ ****************************************************************************/ -/* nothing here yet */ +#include "rscprol.h" diff --git a/bld/cg/risc/ppc/c/ppcproc.c b/bld/cg/risc/ppc/c/ppcproc.c index 62a3988c5b..5c7221fb9b 100644 --- a/bld/cg/risc/ppc/c/ppcproc.c +++ b/bld/cg/risc/ppc/c/ppcproc.c @@ -508,7 +508,7 @@ void GenEpilog( void ) // Pop(); emitEpilog( &CurrProc->targ.stack_map ); GenReturn(); - CurrProc->prolog_state |= GENERATED_EPILOG; + CurrProc->prolog_state |= PST_EPILOG_GENERATED; lc = AskLocation(); if( _IsModel( CGSW_GEN_DBG_LOCALS ) ) { // d1+ or d2 DbgRtnEnd( CurrProc->targ.debug, lc ); diff --git a/bld/cg/risc/ppc/h/targprol.h b/bld/cg/risc/ppc/h/targprol.h index e2cd1f3ffe..7a87b7cb86 100644 --- a/bld/cg/risc/ppc/h/targprol.h +++ b/bld/cg/risc/ppc/h/targprol.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -30,4 +31,4 @@ ****************************************************************************/ -/* nothing here yet */ +#include "rscprol.h" From 4953c1c33079e0884c14c6039da27f8968ca37fa Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Fri, 29 Sep 2023 23:12:59 +0200 Subject: [PATCH 180/258] cleanup cg code --- bld/cg/h/procdef.h | 2 +- bld/cg/intel/h/x86prol.h | 24 ++++++++++++------------ bld/cg/risc/h/rscprol.h | 4 ++-- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/bld/cg/h/procdef.h b/bld/cg/h/procdef.h index 83e622639f..1d4ecb1cc8 100644 --- a/bld/cg/h/procdef.h +++ b/bld/cg/h/procdef.h @@ -36,7 +36,7 @@ typedef enum { - #define pick(e,v) PST_ ## e = v, + #define pick(e,v) e = v, #include "targprol.h" #undef pick PST__LAST = 0x8000, // force to unsigned short type if possible diff --git a/bld/cg/intel/h/x86prol.h b/bld/cg/intel/h/x86prol.h index ca3afa8404..b00a1bf275 100644 --- a/bld/cg/intel/h/x86prol.h +++ b/bld/cg/intel/h/x86prol.h @@ -31,15 +31,15 @@ ****************************************************************************/ -pick( PROLOG_FAT, 0x0001 ) -pick( PROLOG_THUNK, 0x0002 ) -pick( PROLOG_HOOKS, 0x0004 ) -pick( PROLOG_RDOSDEV, 0x0008 ) -pick( PROLOG_GENERATED, 0x0010 ) -pick( EPILOG_HOOKS, 0x0020 ) -pick( EPILOG_GENERATED, 0x0040 ) -pick( EXPORT, 0x0080 ) -pick( FUNCTION_NAME, 0x0100 ) -pick( GROW_STACK, 0x0200 ) -pick( RESET_SP, 0x0400 ) -pick( TOUCH_STACK, 0x0800 ) +pick( PST_PROLOG_FAT, 0x0001 ) +pick( PST_PROLOG_THUNK, 0x0002 ) +pick( PST_PROLOG_HOOKS, 0x0004 ) +pick( PST_PROLOG_RDOSDEV, 0x0008 ) +pick( PST_PROLOG_GENERATED, 0x0010 ) +pick( PST_EPILOG_HOOKS, 0x0020 ) +pick( PST_EPILOG_GENERATED, 0x0040 ) +pick( PST_EXPORT, 0x0080 ) +pick( PST_FUNCTION_NAME, 0x0100 ) +pick( PST_GROW_STACK, 0x0200 ) +pick( PST_RESET_SP, 0x0400 ) +pick( PST_TOUCH_STACK, 0x0800 ) diff --git a/bld/cg/risc/h/rscprol.h b/bld/cg/risc/h/rscprol.h index 49ae160386..cd96af8c09 100644 --- a/bld/cg/risc/h/rscprol.h +++ b/bld/cg/risc/h/rscprol.h @@ -31,5 +31,5 @@ ****************************************************************************/ -pick( PROLOG_GENERATED, 0x0001 ) -pick( EPILOG_GENERATED, 0x0002 ) +pick( PST_PROLOG_GENERATED, 0x0001 ) +pick( PST_EPILOG_GENERATED, 0x0002 ) From 893cbe8abcc479e75fe8e1517dd23817b0317ca4 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Fri, 29 Sep 2023 23:21:54 +0200 Subject: [PATCH 181/258] cleanup cg code --- bld/cg/c/generate.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/bld/cg/c/generate.c b/bld/cg/c/generate.c index 2f7caffa82..c50c6eb4b5 100644 --- a/bld/cg/c/generate.c +++ b/bld/cg/c/generate.c @@ -296,9 +296,9 @@ static void FreeExtraTemps( name *last, block_num id ) temp = *owner; if( temp == last ) break; - if( ( temp->v.usage & USE_IN_ANOTHER_BLOCK ) == 0 - && !_FrontEndTmp( temp ) - && temp->t.u.block_id == id ) { + if( (temp->v.usage & USE_IN_ANOTHER_BLOCK) == 0 + && !_FrontEndTmp( temp ) + && temp->t.u.block_id == id ) { *owner = temp->n.next_name; FreeAName( temp ); } else { @@ -317,7 +317,8 @@ static void ForceTempsMemory( void ) ParmPropagate(); for( op = Names[N_TEMP]; op != LastTemp; op = next ) { next = op->n.next_name; - if( ( op->v.usage & USE_IN_ANOTHER_BLOCK ) || _FrontEndTmp( op ) ) { + if( (op->v.usage & USE_IN_ANOTHER_BLOCK) + || _FrontEndTmp( op ) ) { op = DeAlias( op ); op->v.usage |= NEEDS_MEMORY | USE_MEMORY; while( op->v.conflict != NULL ) { @@ -505,8 +506,8 @@ static void FreeExtraSyms( name *last ) temp = *owner; if( temp == last ) break; - if( ( temp->v.usage & USE_IN_ANOTHER_BLOCK ) == 0 - && !_FrontEndTmp( temp ) ) { + if( (temp->v.usage & USE_IN_ANOTHER_BLOCK) == 0 + && !_FrontEndTmp( temp ) ) { *owner = temp->n.next_name; FreeAName( temp ); } else { @@ -557,9 +558,9 @@ static void ForceConflictsMemory( void ) for( conf = ConfList; conf != NULL; conf = next ) { next = conf->next_conflict; if( !_GBitEmpty( conf->id.out_of_block ) - || ( conf->name->n.class == N_TEMP && _FrontEndTmp( conf->name ) ) - || ( conf->name->n.class == N_MEMORY && conf->name->v.symbol != NULL ) - || ( conf->name->v.usage & USE_IN_ANOTHER_BLOCK ) ) { + || ( conf->name->n.class == N_TEMP && _FrontEndTmp( conf->name ) ) + || ( conf->name->n.class == N_MEMORY && conf->name->v.symbol != NULL ) + || (conf->name->v.usage & USE_IN_ANOTHER_BLOCK) ) { next = InMemory( conf ); } } @@ -582,7 +583,7 @@ static void Panic( bool partly_done ) curr_proc = CurrProc; FlushBlocks( partly_done ); if( curr_proc == CurrProc /* if not freed (dummy!) */ - && (CurrProc->prolog_state & PST_EPILOG_GENERATED) == 0 ) { + && (CurrProc->prolog_state & PST_EPILOG_GENERATED) == 0 ) { GenEpilog(); FiniStackMap(); FreeProc(); @@ -659,7 +660,8 @@ void Generate( bool routine_done ) /* if we couldn't get the whole procedure in memory, generate part of it */ if( BlockByBlock ) { - if( _MemLow || routine_done ) { + if( _MemLow + || routine_done ) { GenPartialRoutine( routine_done ); } else { BlkTooBig(); From f63b4af3335210121296cca15a269cfe569ce1fa Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Sat, 30 Sep 2023 18:31:17 +0200 Subject: [PATCH 182/258] rename header files to be globally unique --- bld/as/mps/c/mipsfmt.c | 2 +- bld/cg/risc/mps/c/mpsenc.c | 2 +- bld/cg/risc/mps/c/mpsenc2.c | 4 ++-- bld/cg/risc/mps/c/mpsproc.c | 2 +- bld/cg/risc/ppc/c/ppcenc.c | 2 +- bld/cg/risc/ppc/c/ppcenc2.c | 4 ++-- bld/cg/risc/ppc/c/ppcproc.c | 2 +- bld/watcom/h/{mipsenc.h => mipsenco.h} | 1 + bld/watcom/h/{ppcenc.h => ppcencod.h} | 1 + 9 files changed, 11 insertions(+), 9 deletions(-) rename bld/watcom/h/{mipsenc.h => mipsenco.h} (97%) rename bld/watcom/h/{ppcenc.h => ppcencod.h} (97%) diff --git a/bld/as/mps/c/mipsfmt.c b/bld/as/mps/c/mipsfmt.c index cc3c5ab163..61ce75ba7f 100644 --- a/bld/as/mps/c/mipsfmt.c +++ b/bld/as/mps/c/mipsfmt.c @@ -35,7 +35,7 @@ #include "asinline.h" #endif -#include "mipsenc.h" +#include "mipsenco.h" /* diff --git a/bld/cg/risc/mps/c/mpsenc.c b/bld/cg/risc/mps/c/mpsenc.c index 064f6b504a..c518da5c00 100644 --- a/bld/cg/risc/mps/c/mpsenc.c +++ b/bld/cg/risc/mps/c/mpsenc.c @@ -34,7 +34,7 @@ #include #include "coderep.h" #include "optmain.h" -#include "mipsenc.h" +#include "mipsenco.h" #include "reloc.h" #include "zoiks.h" #include "coff.h" diff --git a/bld/cg/risc/mps/c/mpsenc2.c b/bld/cg/risc/mps/c/mpsenc2.c index 3a0f5fa738..9119291914 100644 --- a/bld/cg/risc/mps/c/mpsenc2.c +++ b/bld/cg/risc/mps/c/mpsenc2.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -33,7 +33,7 @@ #include "_cgstd.h" #include "coderep.h" #include "symdbg.h" -#include "mipsenc.h" +#include "mipsenco.h" #include "reloc.h" #include "rscenc2.h" #include "rscobj.h" diff --git a/bld/cg/risc/mps/c/mpsproc.c b/bld/cg/risc/mps/c/mpsproc.c index d239a05bb6..cd12c0aa8f 100644 --- a/bld/cg/risc/mps/c/mpsproc.c +++ b/bld/cg/risc/mps/c/mpsproc.c @@ -34,7 +34,7 @@ #include "coderep.h" #include "cgmem.h" #include "zoiks.h" -#include "mipsenc.h" +#include "mipsenco.h" #include "data.h" #include "rtrtn.h" #include "objout.h" diff --git a/bld/cg/risc/ppc/c/ppcenc.c b/bld/cg/risc/ppc/c/ppcenc.c index 2b2e9b62ef..1cdb50fb3e 100644 --- a/bld/cg/risc/ppc/c/ppcenc.c +++ b/bld/cg/risc/ppc/c/ppcenc.c @@ -39,7 +39,7 @@ #include "cgauxcc.h" #include "cgauxinf.h" #include "optmain.h" -#include "ppcenc.h" +#include "ppcencod.h" #include "ppcgen.h" #include "data.h" #include "objout.h" diff --git a/bld/cg/risc/ppc/c/ppcenc2.c b/bld/cg/risc/ppc/c/ppcenc2.c index 3c6bf34b8c..3eef85e47c 100644 --- a/bld/cg/risc/ppc/c/ppcenc2.c +++ b/bld/cg/risc/ppc/c/ppcenc2.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -34,7 +34,7 @@ #include "_cgstd.h" #include "coderep.h" #include "symdbg.h" -#include "ppcenc.h" +#include "ppcencod.h" #include "reloc.h" #include "rscenc2.h" #include "rscobj.h" diff --git a/bld/cg/risc/ppc/c/ppcproc.c b/bld/cg/risc/ppc/c/ppcproc.c index 5c7221fb9b..87a4781908 100644 --- a/bld/cg/risc/ppc/c/ppcproc.c +++ b/bld/cg/risc/ppc/c/ppcproc.c @@ -33,7 +33,7 @@ #include "_cgstd.h" #include "coderep.h" #include "cgmem.h" -#include "ppcenc.h" +#include "ppcencod.h" #include "ppcgen.h" #include "data.h" #include "objout.h" diff --git a/bld/watcom/h/mipsenc.h b/bld/watcom/h/mipsenco.h similarity index 97% rename from bld/watcom/h/mipsenc.h rename to bld/watcom/h/mipsenco.h index 0998aada7c..485f65b14a 100644 --- a/bld/watcom/h/mipsenc.h +++ b/bld/watcom/h/mipsenco.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== diff --git a/bld/watcom/h/ppcenc.h b/bld/watcom/h/ppcencod.h similarity index 97% rename from bld/watcom/h/ppcenc.h rename to bld/watcom/h/ppcencod.h index 15bcca27c6..020a8fcab9 100644 --- a/bld/watcom/h/ppcenc.h +++ b/bld/watcom/h/ppcencod.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== From e95d1e259e6a3a5c15da1a82d11c7ef6900124f1 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Sat, 30 Sep 2023 19:29:09 +0200 Subject: [PATCH 183/258] cleanup cg code --- bld/cg/c/bldcall.c | 4 ++-- bld/cg/c/tree.c | 4 ++-- bld/cg/h/bgcall.h | 4 ++-- bld/cg/h/bldcall.h | 4 ++-- bld/cg/intel/c/x86call.c | 6 +++--- bld/cg/risc/axp/c/axpcall.c | 6 +++--- bld/cg/risc/mps/c/mpscall.c | 6 +++--- bld/cg/risc/mps/c/mpsreg.c | 8 ++++---- bld/cg/risc/ppc/c/ppccall.c | 6 +++--- 9 files changed, 24 insertions(+), 24 deletions(-) diff --git a/bld/cg/c/bldcall.c b/bld/cg/c/bldcall.c index e645abbe9b..63316f13c1 100644 --- a/bld/cg/c/bldcall.c +++ b/bld/cg/c/bldcall.c @@ -805,7 +805,7 @@ static void SplitStructParms( pn *parm_list, call_state *state ) } #endif -bool AssgnParms( cn call, bool in_line ) +bool AssgnParms( cn call, bool aux_inline ) /******************************************************** * Decide what registers the parms should go in. * Assign registers to first parm first, etc. Also, assign a congolmeration @@ -833,7 +833,7 @@ bool AssgnParms( cn call, bool in_line ) parm = call->parms; #endif for( ; parm != NULL; parm = parm->next ) { - if( in_line ) { + if( aux_inline ) { parm->regs = ParmInLineReg( &state->parm ); if( HW_CEqual( parm->regs, HW_EMPTY ) ) { if( !HW_CEqual( *(state->parm.curr_entry), HW_EMPTY ) ) { diff --git a/bld/cg/c/tree.c b/bld/cg/c/tree.c index e25e962646..bef4b2a9a9 100644 --- a/bld/cg/c/tree.c +++ b/bld/cg/c/tree.c @@ -2304,8 +2304,8 @@ static an TNCall( tn callhandle, bool ignore_return ) an retv; an parman; type_def *tipe; - bool aux_inline; - bool call_inline; + bool aux_inline; /* ASM inline code */ + bool call_inline; /* C inline code */ name *base; call_class cclass; cg_sym_handle sym; diff --git a/bld/cg/h/bgcall.h b/bld/cg/h/bgcall.h index 4694fd7055..ea2c2b2c7d 100644 --- a/bld/cg/h/bgcall.h +++ b/bld/cg/h/bgcall.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -30,7 +30,7 @@ ****************************************************************************/ -extern an BGCall( cn call, bool use_return, bool in_line ); +extern an BGCall( cn call, bool use_return, bool aux_inline ); extern void BGProcDecl( cg_sym_handle sym, type_def *tipe ); extern name *StReturn( an retval, type_def *tipe, instruction **pins ); extern reg_set_index CallIPossible( instruction *ins ); diff --git a/bld/cg/h/bldcall.h b/bld/cg/h/bldcall.h index eecdd160b6..dc62441ccb 100644 --- a/bld/cg/h/bldcall.h +++ b/bld/cg/h/bldcall.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2018 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -44,6 +44,6 @@ extern void ReserveStack( call_state *state, instruction *prev, type extern void ParmIns( pn parm, call_state *state ); extern void BGZapBase( name *base, type_def *tipe ); extern void BGReturn( an retval, type_def *tipe ); -extern bool AssgnParms( cn call, bool in_line ); +extern bool AssgnParms( cn call, bool aux_inline ); extern hw_reg_set CallZap( call_state *state ); extern void UpdateReturn( call_state *, type_def *, type_class_def, aux_handle ); diff --git a/bld/cg/intel/c/x86call.c b/bld/cg/intel/c/x86call.c index af2b53b030..5c7ccf463d 100644 --- a/bld/cg/intel/c/x86call.c +++ b/bld/cg/intel/c/x86call.c @@ -137,8 +137,8 @@ static void Far16Parms( cn call ) #endif -an BGCall( cn call, bool use_return, bool in_line ) -/******************************************************/ +an BGCall( cn call, bool use_return, bool aux_inline ) +/*********************************************************/ { instruction *call_ins; call_state *state; @@ -189,7 +189,7 @@ an BGCall( cn call, bool use_return, bool in_line ) Far16Parms( call ); #endif } else { - if( AssgnParms( call, in_line ) ) { + if( AssgnParms( call, aux_inline ) ) { if( state->attr & ROUTINE_REMOVES_PARMS ) { call_ins->flags.call_flags |= CALL_POPS_PARMS; } diff --git a/bld/cg/risc/axp/c/axpcall.c b/bld/cg/risc/axp/c/axpcall.c index 640bc24fab..3446b9c19d 100644 --- a/bld/cg/risc/axp/c/axpcall.c +++ b/bld/cg/risc/axp/c/axpcall.c @@ -50,8 +50,8 @@ #include "bgcall.h" -an BGCall( cn call, bool use_return, bool in_line ) -/******************************************************/ +an BGCall( cn call, bool use_return, bool aux_inline ) +/*********************************************************/ { instruction *call_ins; instruction *conv_ins; @@ -86,7 +86,7 @@ an BGCall( cn call, bool use_return, bool in_line ) } else { call_ins->result = AllocRegName( state->return_reg ); } - AssgnParms( call, in_line ); + AssgnParms( call, aux_inline ); AddCallIns( call_ins, call ); if( use_return ) { if( call_ins->type_class != XX ) { diff --git a/bld/cg/risc/mps/c/mpscall.c b/bld/cg/risc/mps/c/mpscall.c index 2f2c5ff626..6c9444c90c 100644 --- a/bld/cg/risc/mps/c/mpscall.c +++ b/bld/cg/risc/mps/c/mpscall.c @@ -50,8 +50,8 @@ #include "bgcall.h" -an BGCall( cn call, bool use_return, bool in_line ) -/*************************************************/ +an BGCall( cn call, bool use_return, bool aux_inline ) +/****************************************************/ { instruction *call_ins; instruction *conv_ins; @@ -86,7 +86,7 @@ an BGCall( cn call, bool use_return, bool in_line ) } else { call_ins->result = AllocRegName( state->return_reg ); } - AssgnParms( call, in_line ); + AssgnParms( call, aux_inline ); AddCallIns( call_ins, call ); if( use_return ) { if( call_ins->type_class != XX ) { diff --git a/bld/cg/risc/mps/c/mpsreg.c b/bld/cg/risc/mps/c/mpsreg.c index 12db378c39..649393fd2c 100644 --- a/bld/cg/risc/mps/c/mpsreg.c +++ b/bld/cg/risc/mps/c/mpsreg.c @@ -86,7 +86,7 @@ type_class_def CallState( aux_handle aux, type_def *tipe, call_state *state ) hw_reg_set *pregs; call_class cclass; byte_seq *code; - bool have_aux_code = false; + bool aux_inline = false; state->unalterable = FixedRegs(); if( FEAttr( AskForLblSym( CurrProc->label ) ) & FE_VARARGS ) { @@ -100,13 +100,13 @@ type_class_def CallState( aux_handle aux, type_def *tipe, call_state *state ) if( !AskIfRTLabel( CurrProc->label ) ) { code = FEAuxInfo( aux, FEINF_CALL_BYTES ); if( code != NULL ) { - have_aux_code = true; + aux_inline = true; } } pregs = FEAuxInfo( aux, FEINF_SAVE_REGS ); HW_CAsgn( state->modify, HW_FULL ); - if( have_aux_code ) { + if( aux_inline ) { HW_TurnOff( state->modify, *pregs ); } else { HW_TurnOff( state->modify, SavedRegs() ); @@ -130,7 +130,7 @@ type_class_def CallState( aux_handle aux, type_def *tipe, call_state *state ) if( cclass & FECALL_GEN_NO_MEMORY_READ ) { state->attr |= ROUTINE_READS_NO_MEMORY; } - if( have_aux_code ) { + if( aux_inline ) { parm_src = FEAuxInfo( aux, FEINF_PARM_REGS ); } else { parm_src = ParmRegs(); diff --git a/bld/cg/risc/ppc/c/ppccall.c b/bld/cg/risc/ppc/c/ppccall.c index 709553d80e..4a92566679 100644 --- a/bld/cg/risc/ppc/c/ppccall.c +++ b/bld/cg/risc/ppc/c/ppccall.c @@ -51,8 +51,8 @@ #include "bgcall.h" -an BGCall( cn call, bool use_return, bool in_line ) -/******************************************************/ +an BGCall( cn call, bool use_return, bool aux_inline ) +/*********************************************************/ { instruction *call_ins; instruction *conv_ins; @@ -84,7 +84,7 @@ an BGCall( cn call, bool use_return, bool in_line ) } else { call_ins->result = AllocRegName( state->return_reg ); } - AssgnParms( call, in_line ); + AssgnParms( call, aux_inline ); AddCallIns( call_ins, call ); if( use_return ) { #if 1 From 9c2b20a5b91b8936bbb2803434a85e9966ced230 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Sun, 1 Oct 2023 04:04:10 +0200 Subject: [PATCH 184/258] cleanup code fix type mismatch --- bld/as/c/asiobj.c | 19 ++++++++++--------- bld/as/c/obj.c | 9 +++++---- bld/as/h/obj.h | 7 ++++--- bld/cg/intel/c/x86obj.c | 5 ++--- bld/cg/risc/c/rscobj.c | 12 +++++++----- 5 files changed, 28 insertions(+), 24 deletions(-) diff --git a/bld/as/c/asiobj.c b/bld/as/c/asiobj.c index 69442ce2a0..29a8a96650 100644 --- a/bld/as/c/asiobj.c +++ b/bld/as/c/asiobj.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2019 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -64,9 +64,9 @@ static owl_offset tellOffset( void ) { return( AsmCodeAddress ); } -static void doEmitData( char *buffer, int size ) { -//************************************************ - +static void doEmitData( char *buffer, size_t size ) +//************************************************* +{ memcpy( &AsmCodeBuffer[AsmCodeAddress], buffer, size ); AsmCodeAddress += size; if( AsmCodeAddress > AsmLastAddress ) { @@ -403,9 +403,10 @@ void ObjFlushLabels( void ) } } -void ObjEmitData( void *buffer, int size, bool align ) -//**************************************************** -// Aligns to proper address, emits all pending labels, then emits the data +void ObjEmitData( void *buffer, size_t size, bool align ) +/******************************************************** + * Aligns to proper address, emits all pending labels, then emits the data + */ { if( align ) { (void)ObjAlign( CurrAlignment ); @@ -414,8 +415,8 @@ void ObjEmitData( void *buffer, int size, bool align ) doEmitData( buffer, size ); } -void ObjDirectEmitData( void *buffer, int size ) -//********************************************** +void ObjDirectEmitData( void *buffer, size_t size ) +//************************************************* { doEmitData( buffer, size ); } diff --git a/bld/as/c/obj.c b/bld/as/c/obj.c index 1607ad960a..807d25617e 100644 --- a/bld/as/c/obj.c +++ b/bld/as/c/obj.c @@ -298,10 +298,11 @@ void ObjFlushLabels( void ) { } } -void ObjEmitData( owl_section_handle section, void *buffer, int size, bool align ) { -//********************************************************************************** -// Aligns to proper address, emits all pending labels, then emits the data - +void ObjEmitData( owl_section_handle section, void *buffer, size_t size, bool align ) +/************************************************************************************ + * Aligns to proper address, emits all pending labels, then emits the data + */ +{ if( align ) { (void)ObjAlign( section, CurrAlignment ); } diff --git a/bld/as/h/obj.h b/bld/as/h/obj.h index 956c638f24..31dff41334 100644 --- a/bld/as/h/obj.h +++ b/bld/as/h/obj.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -48,7 +49,7 @@ extern bool ObjLabelDefined( sym_handle ); extern void ObjEmitLabel( sym_handle ); extern void ObjEmitNumericLabel( uint_32 ); extern void ObjFlushLabels( void ); -extern void ObjEmitData( owl_section_handle section, void *buffer, int size, bool do_align ); +extern void ObjEmitData( owl_section_handle section, void *buffer, size_t size, bool do_align ); extern void ObjNopPad( owl_section_handle section, uint_8 count ); extern void ObjNullPad( owl_section_handle section, uint_8 count ); extern owl_offset ObjAlign( owl_section_handle section, uint_8 alignment ); @@ -67,8 +68,8 @@ extern bool AsiObjLabelDefined( sym_handle ); extern void AsiObjEmitLabel( sym_handle ); extern void AsiObjEmitNumericLabel( uint_32 ); extern void AsiObjFlushLabels( void ); -extern void AsiObjEmitData( void *buffer, int size, bool do_align ); -extern void AsiObjDirectEmitData( void *buffer, int size ); +extern void AsiObjEmitData( void *buffer, size_t size, bool do_align ); +extern void AsiObjDirectEmitData( void *buffer, size_t size ); extern void AsiObjNopPad( uint_8 count ); extern void AsiObjNullPad( uint_8 count ); extern owl_offset AsiObjAlign( uint_8 alignment ); diff --git a/bld/cg/intel/c/x86obj.c b/bld/cg/intel/c/x86obj.c index f4fd514d69..7d00c39095 100644 --- a/bld/cg/intel/c/x86obj.c +++ b/bld/cg/intel/c/x86obj.c @@ -3392,9 +3392,8 @@ static bool InlineFunction( cg_sym_handle sym ) /*************************************************/ { if( FEAttr( sym ) & FE_PROC ) { - if( FindAuxInfoSym( sym, FEINF_CALL_BYTES ) != NULL ) - return( true ); - if( ((call_class)(pointer_uint)FindAuxInfoSym( sym, FEINF_CALL_CLASS ) & FECALL_GEN_MAKE_CALL_INLINE) ) { + if( FindAuxInfoSym( sym, FEINF_CALL_BYTES ) != NULL + || ((call_class)(pointer_uint)FindAuxInfoSym( sym, FEINF_CALL_CLASS ) & FECALL_GEN_MAKE_CALL_INLINE) ) { return( true ); } } diff --git a/bld/cg/risc/c/rscobj.c b/bld/cg/risc/c/rscobj.c index cbd1387a0e..477f039633 100644 --- a/bld/cg/risc/c/rscobj.c +++ b/bld/cg/risc/c/rscobj.c @@ -655,11 +655,13 @@ segment_id AskBackSeg( void ) static bool InlineFunction( cg_sym_handle sym ) /*************************************************/ { - if( (FEAttr( sym ) & FE_PROC) == 0 ) - return( false ); - if( FindAuxInfoSym( sym, FEINF_CALL_BYTES ) != NULL ) - return( true ); - return( ((call_class)(pointer_uint)FindAuxInfoSym( sym, FEINF_CALL_CLASS ) & FECALL_GEN_MAKE_CALL_INLINE) != 0 ); + if( FEAttr( sym ) & FE_PROC ) { + if( FindAuxInfoSym( sym, FEINF_CALL_BYTES ) != NULL + || ((call_class)(pointer_uint)FindAuxInfoSym( sym, FEINF_CALL_CLASS ) & FECALL_GEN_MAKE_CALL_INLINE) ) { + return( true ); + } + } + return( false ); } segment_id AskSegID( pointer hdl, cg_class class ) From 560be079e0c2a1a88677c0f0230151d10dcc5219 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Sun, 1 Oct 2023 04:26:44 +0200 Subject: [PATCH 185/258] cleanup as code --- bld/as/axp/c/alphafmt.c | 8 +-- bld/as/c/asiobj.c | 84 +++++++++++----------- bld/as/c/obj.c | 151 +++++++++++++++++++++------------------- bld/as/mps/c/mipsfmt.c | 8 +-- 4 files changed, 132 insertions(+), 119 deletions(-) diff --git a/bld/as/axp/c/alphafmt.c b/bld/as/axp/c/alphafmt.c index f8130a05a5..37306ee86e 100644 --- a/bld/as/axp/c/alphafmt.c +++ b/bld/as/axp/c/alphafmt.c @@ -1126,14 +1126,14 @@ bool AlphaValidate( instruction *ins ) } #ifdef _STANDALONE_ -static void emitIns( owl_section_handle hdl, char *inscode, int size ) -//******************************************************************** +static void emitIns( owl_section_handle hdl, char *inscode, size_t size ) +//*********************************************************************** { ObjEmitData( hdl, inscode, size, true ); } #else -static void emitIns( char *inscode, int size ) -//******************************************** +static void emitIns( char *inscode, size_t size ) +//*********************************************** { ObjEmitData( inscode, size, true ); } diff --git a/bld/as/c/asiobj.c b/bld/as/c/asiobj.c index 29a8a96650..56700a27a4 100644 --- a/bld/as/c/asiobj.c +++ b/bld/as/c/asiobj.c @@ -58,13 +58,13 @@ typedef struct asm_label *label_list; static label_list labelList = NULL; // The list of pending labels static asmreloc *lastReloc; -static owl_offset tellOffset( void ) { -//************************************ - +static owl_offset tellOffset( void ) +/**********************************/ +{ return( AsmCodeAddress ); } -static void doEmitData( char *buffer, size_t size ) +static void doEmitData( char *buffer, size_t size ) //************************************************* { memcpy( &AsmCodeBuffer[AsmCodeAddress], buffer, size ); @@ -74,9 +74,9 @@ static void doEmitData( char *buffer, size_t size ) } } -static void doEmitLabel( label_list label ) { -//******************************************* - +static void doEmitLabel( label_list label ) +/*****************************************/ +{ sym_location loc; labelList = label->next; @@ -90,9 +90,9 @@ static void doEmitLabel( label_list label ) { } } -static owl_offset getSymOffset( sym_handle sym ) { -//************************************************ - +static owl_offset getSymOffset( sym_handle sym ) +/**********************************************/ +{ sym_location loc; assert( SymLocationKnown( sym ) ); @@ -100,9 +100,9 @@ static owl_offset getSymOffset( sym_handle sym ) { return( loc.offset ); } -static owl_offset relocTargetDisp( owl_offset from, owl_offset to ) { -//******************************************************************* - +static owl_offset relocTargetDisp( owl_offset from, owl_offset to ) +/*****************************************************************/ +{ owl_offset ret; #ifdef AS_ALPHA @@ -167,16 +167,16 @@ static unsigned relocMasks[] = { #endif }; -static unsigned relocBitMask( asmreloc *reloc ) { -//*********************************************** - +static unsigned relocBitMask( asmreloc *reloc ) +/*********************************************/ +{ assert( reloc != NULL ); return( relocMasks[ reloc->type ] ); } -static void doReloc( asmreloc *reloc ) { -//************************************** - +static void doReloc( asmreloc *reloc ) +/************************************/ +{ sym_handle sym; uint_32 bit_mask; uint_32 *data; @@ -189,12 +189,13 @@ static void doReloc( asmreloc *reloc ) { *data = (*data&~bit_mask)|(((displacement&bit_mask)+(*data&bit_mask))&bit_mask); } -static void resolveRelativeRelocs( void ) { -//***************************************** -// Do all relative relocs within the inline code and -// complain about references that are not internal and not defined by the -// compiler. - +static void resolveRelativeRelocs( void ) +/**************************************** + * Do all relative relocs within the inline code and + * complain about references that are not internal and not defined by the + * compiler. + */ +{ asmreloc *curr_reloc; asmreloc **last; char *keep_name; @@ -236,9 +237,9 @@ static void resolveRelativeRelocs( void ) { } } -static asmreloc *newReloc( owl_offset offset, char *name, owl_reloc_type type ) { -//******************************************************************************* - +static asmreloc *newReloc( owl_offset offset, char *name, owl_reloc_type type ) +/*****************************************************************************/ +{ asmreloc *reloc; reloc = MemAlloc( sizeof( asmreloc ) ); @@ -249,9 +250,9 @@ static asmreloc *newReloc( owl_offset offset, char *name, owl_reloc_type type ) return( reloc ); } -static void doEmitReloc( owl_offset offset, void *target, owl_reloc_type type, bool named_sym ) { -//*********************************************************************************************** - +static void doEmitReloc( owl_offset offset, void *target, owl_reloc_type type, bool named_sym ) +/*********************************************************************************************/ +{ asmreloc *reloc; int_32 label_num; @@ -271,9 +272,9 @@ static void doEmitReloc( owl_offset offset, void *target, owl_reloc_type type, b } } -static void doStackLabel( sym_handle sym ) { -//****************************************** - +static void doStackLabel( sym_handle sym ) +/****************************************/ +{ label_list new_label; new_label = MemAlloc( sizeof( struct asm_label ) ); @@ -322,9 +323,9 @@ void ObjEmitRelocAddend( owl_reloc_type type, uint_32 addend ) *pdata = (*pdata&~bit_mask)|(((addend&bit_mask)+(*pdata&bit_mask))&bit_mask); } -static bool findLabel( label_list labels, char *label_name ) { -//************************************************************ - +static bool findLabel( label_list labels, char *label_name ) +/**********************************************************/ +{ label_list curr_label; curr_label = labels; @@ -358,10 +359,11 @@ bool ObjLabelDefined( sym_handle sym ) return( false ); } -static void doStackNumericLabel( uint_32 label_num ) { -//**************************************************** -// Numeric labels have label_num going from 1 to 10 (corresponds to 0: - 9:) - +static void doStackNumericLabel( uint_32 label_num ) +/*************************************************** + * Numeric labels have label_num going from 1 to 10 (corresponds to 0: - 9:) + */ +{ label_list new_label; new_label = MemAlloc( sizeof( struct asm_label ) ); diff --git a/bld/as/c/obj.c b/bld/as/c/obj.c index 807d25617e..88b3c6030e 100644 --- a/bld/as/c/obj.c +++ b/bld/as/c/obj.c @@ -75,9 +75,9 @@ typedef struct asm_label *label_list; static label_list labelList = NULL; // The list of pending labels -void ObjSetObjFile( char *obj_name ) { -//************************************ - +void ObjSetObjFile( char *obj_name ) +//********************************** +{ strcpy( objName, obj_name ); objectDefined = true; } @@ -94,10 +94,10 @@ static sect_info reservedSecInfo[] = { #undef PICK }; -void ObjSwitchSection( reserved_section section ) { -//************************************************* +void ObjSwitchSection( reserved_section section ) +//*********************************************** // Switch to a reserved section - +{ sect_info *secinfo; secinfo = &reservedSecInfo[ section ]; @@ -123,9 +123,9 @@ static int owl_seek( owl_client_file f, long offset, int where ) return( fseek( f, offset, where ) ); } -bool ObjInit( char *fname ) { -//*************************** - +bool ObjInit( char *fname ) +//************************* +{ owl_client_funcs funcs = { owl_write, owl_tell, owl_seek, MemAlloc, MemFree }; pgroup2 pg1; pgroup2 pg2; @@ -176,9 +176,9 @@ static owl_sym_linkage linkage_table[] = { OWL_SYM_STATIC // Static }; -bool ObjLabelDefined( sym_handle sym ) { -//************************************** - +bool ObjLabelDefined( sym_handle sym ) +//************************************ +{ owl_sym_linkage linkage; label_list curr_label; char *sym_name; @@ -191,7 +191,8 @@ bool ObjLabelDefined( sym_handle sym ) { curr_label = labelList; sym_name = SymName( sym ); while( curr_label ) { - if( (!curr_label->is_numeric) && strcmp( curr_label->sym_name, sym_name ) == 0 ) { + if( !curr_label->is_numeric + && strcmp( curr_label->sym_name, sym_name ) == 0 ) { return( true ); } curr_label = curr_label->next; @@ -199,9 +200,9 @@ bool ObjLabelDefined( sym_handle sym ) { return( false ); } -static void doStackLabel( sym_handle sym, owl_sym_type type, owl_sym_linkage linkage ) { -//************************************************************************************** - +static void doStackLabel( sym_handle sym, owl_sym_type type, owl_sym_linkage linkage ) +//************************************************************************************ +{ label_list new_label; new_label = MemAlloc( sizeof( struct asm_label ) ); @@ -215,9 +216,9 @@ static void doStackLabel( sym_handle sym, owl_sym_type type, owl_sym_linkage lin labelList = new_label; } -static void doStackNumericLabel( int_32 label_num, owl_sym_type type, owl_sym_linkage linkage ) { -//**************************************************************************************** - +static void doStackNumericLabel( int_32 label_num, owl_sym_type type, owl_sym_linkage linkage ) +//********************************************************************************************* +{ label_list new_label; new_label = MemAlloc( sizeof( struct asm_label ) ); @@ -231,10 +232,11 @@ static void doStackNumericLabel( int_32 label_num, owl_sym_type type, owl_sym_li labelList = new_label; } -void ObjEmitLabel( sym_handle sym ) { -//*********************************** -// Stacks up the label in the list for ObjEmitData to emit - +void ObjEmitLabel( sym_handle sym ) +/********************************** + * Stacks up the label in the list for ObjEmitData to emit + */ +{ owl_sym_type type; owl_sym_linkage linkage; sym_linkage symbol_linkage; @@ -258,10 +260,11 @@ void ObjEmitLabel( sym_handle sym ) { doStackLabel( sym, type, linkage ); } -void ObjEmitNumericLabel( uint_32 label_num ) { -//********************************************* -// Stacks up the numeric label in the list for ObjEmitData to emit - +void ObjEmitNumericLabel( uint_32 label_num ) +/******************************************** + * Stacks up the numeric label in the list for ObjEmitData to emit + */ +{ owl_sym_type type; owl_section_type section_type; @@ -274,9 +277,9 @@ void ObjEmitNumericLabel( uint_32 label_num ) { doStackNumericLabel( label_num, type, OWL_SYM_STATIC ); } -void ObjFlushLabels( void ) { -//*************************** - +void ObjFlushLabels( void ) +//************************* +{ label_list next_label; while( labelList ) { @@ -298,7 +301,7 @@ void ObjFlushLabels( void ) { } } -void ObjEmitData( owl_section_handle section, void *buffer, size_t size, bool align ) +void ObjEmitData( owl_section_handle section, void *buffer, size_t size, bool align ) /************************************************************************************ * Aligns to proper address, emits all pending labels, then emits the data */ @@ -311,10 +314,11 @@ void ObjEmitData( owl_section_handle section, void *buffer, size_t size, bool al // printf( "real data emitted.\n" ); } -void ObjNopPad( owl_section_handle section, uint_8 count ) { -//********************************************************** -// Emits count no-ops - +void ObjNopPad( owl_section_handle section, uint_8 count ) +/********************************************************* + * Emits count no-ops + */ +{ uint_32 nop_opcode = INS_NOP; while( count-- > 0 ) { @@ -322,10 +326,11 @@ void ObjNopPad( owl_section_handle section, uint_8 count ) { } } -void ObjNullPad( owl_section_handle section, uint_8 count ) { -//*********************************************************** -// Emits count bytes of zeros - +void ObjNullPad( owl_section_handle section, uint_8 count ) +/********************************************************** + * Emits count bytes of zeros + */ +{ char byte = 0; while( count-- > 0 ) { @@ -333,11 +338,12 @@ void ObjNullPad( owl_section_handle section, uint_8 count ) { } } -owl_offset ObjAlign( owl_section_handle section, uint_8 alignment ) { -//******************************************************************* -// Aligns the offset to 2^alignment boundary. Returns the offset for -// convenience. - +owl_offset ObjAlign( owl_section_handle section, uint_8 alignment ) +/****************************************************************** + * Aligns the offset to 2^alignment boundary. Returns the offset for + * convenience. + */ +{ owl_offset offset; offset = OWLTellOffset( section ); @@ -362,9 +368,9 @@ owl_offset ObjAlign( owl_section_handle section, uint_8 alignment ) { static void doEmitReloc( owl_section_handle section, owl_offset offset, void *target, owl_reloc_type type, - bool named_sym ) { -//*************************************************************************************************************************** - + bool named_sym ) +//********************************************************************* +{ obj_section_handle ref_section; sym_handle sym; int_32 label_num; @@ -385,26 +391,28 @@ static void doEmitReloc( owl_section_handle section, owl_offset offset, } } -void ObjDirectEmitReloc( owl_section_handle section, owl_offset offset, void *target, owl_reloc_type type, bool named_sym ) { -//*************************************************************************************************************************** -// Just emit the reloc. No alignment check, no l^-h^ reloc pairing etc. - +void ObjDirectEmitReloc( owl_section_handle section, owl_offset offset, void *target, owl_reloc_type type, bool named_sym ) +/************************************************************************************************************************** + * Just emit the reloc. No alignment check, no l^-h^ reloc pairing etc. + */ +{ doEmitReloc( section, offset, target, type, named_sym ); } #if 0 -owl_offset ObjTellOffset( owl_section_handle section ) { -//****************************************************** - +owl_offset ObjTellOffset( owl_section_handle section ) +//**************************************************** +{ return( OWLTellOffset( section ) ); } #endif -void ObjEmitReloc( owl_section_handle section, void *target, owl_reloc_type type, bool align, bool named_sym ) { -//************************************************************************************************************** -// Should be called before emitting the data that has the reloc. -// (named_sym == true) iff the target is a named label - +void ObjEmitReloc( owl_section_handle section, void *target, owl_reloc_type type, bool align, bool named_sym ) +/************************************************************************************************************* + * Should be called before emitting the data that has the reloc. + * (named_sym == true) iff the target is a named label + */ +{ owl_offset offset; if( align ) { // If data is aligned, we should also align this reloc offset! @@ -422,7 +430,8 @@ void ObjEmitReloc( owl_section_handle section, void *target, owl_reloc_type type owl_offset offset_hi, offset_lo; sym_handle (*lookup_func)( void * ); - if( type != OWL_RELOC_HALF_HI && type != OWL_RELOC_HALF_LO ) { + if( type != OWL_RELOC_HALF_HI + && type != OWL_RELOC_HALF_LO ) { doEmitReloc( section, offset, target, type, named_sym ); } else { lookup_func = named_sym ? @@ -450,12 +459,13 @@ void ObjEmitReloc( owl_section_handle section, void *target, owl_reloc_type type #endif } -void ObjRelocsFini( void ) { -//************************** -// If the parse was successful, we need to check whether there're any unmatched -// relocs still hanging around. If there're unmatched h^relocs, we issue an -// error. If there're unmatched l^relocs, we should be able to emit them. - +void ObjRelocsFini( void ) +/************************* + * If the parse was successful, we need to check whether there're any unmatched + * relocs still hanging around. If there're unmatched h^relocs, we issue an + * error. If there're unmatched l^relocs, we should be able to emit them. + */ +{ sym_reloc reloc; sym_handle sym; int_32 numlabel_ref; @@ -491,14 +501,15 @@ void ObjRelocsFini( void ) { AsNumLabelFini(); // resolve all numeric label relocs } -void ObjFini( void ) { -//******************** - +void ObjFini( void ) +//****************** +{ ObjFlushLabels(); // In case there're still pending labels OWLFileFini( OwlFile ); fclose( objFP ); fclose( ErrorFile ); - if( ErrorsExceeding( 0 ) || ( _IsOption( WARNING_ERROR ) && WarningsExceeding( 0 ) ) ) { + if( ErrorsExceeding( 0 ) + || ( _IsOption( WARNING_ERROR ) && WarningsExceeding( 0 ) ) ) { remove( objName ); ExitStatus = EXIT_FAILURE; } else if( !WarningsExceeding( 0 ) ) { diff --git a/bld/as/mps/c/mipsfmt.c b/bld/as/mps/c/mipsfmt.c index 61ce75ba7f..2baed8ce91 100644 --- a/bld/as/mps/c/mipsfmt.c +++ b/bld/as/mps/c/mipsfmt.c @@ -1484,14 +1484,14 @@ bool MIPSValidate( instruction *ins ) #ifdef _STANDALONE_ -static void emitIns( owl_section_handle hdl, char *inscode, int size ) -//******************************************************************** +static void emitIns( owl_section_handle hdl, char *inscode, size_t size ) +//*********************************************************************** { ObjEmitData( hdl, inscode, size, true ); } #else -static void emitIns( char *inscode, int size ) -//******************************************** +static void emitIns( char *inscode, size_t size ) +//*********************************************** { ObjEmitData( inscode, size, true ); } From 4d1c534d8886282f49b1e6241aa7f62ba86fb939 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Sun, 1 Oct 2023 10:01:20 +0200 Subject: [PATCH 186/258] cleanup RISC architecture encodings code consolidate macros to global header files axpencod.h/mipsenco.h/ppcencod.h in bld/watcom/h --- bld/as/axp/c/alphafmt.c | 28 +- bld/as/axp/h/register.h | 10 +- bld/as/mps/c/mipsfmt.c | 49 ++- bld/as/mps/h/register.h | 10 +- bld/as/ppc/c/ppcfmt.c | 629 ++++++++++++++++++------------------ bld/as/ppc/h/register.h | 6 +- bld/cg/risc/axp/c/axpenc.c | 64 ++-- bld/cg/risc/axp/c/axpenc2.c | 8 +- bld/cg/risc/axp/c/axpproc.c | 42 +-- bld/cg/risc/mps/c/mpsenc.c | 105 +++--- bld/cg/risc/mps/c/mpsenc2.c | 54 +++- bld/cg/risc/mps/c/mpsproc.c | 126 +++++--- bld/cg/risc/ppc/c/ppcenc.c | 55 ++-- bld/watcom/h/axpencod.h | 43 +-- bld/watcom/h/mipsenco.h | 51 +-- bld/watcom/h/ppcencod.h | 47 +-- 16 files changed, 685 insertions(+), 642 deletions(-) diff --git a/bld/as/axp/c/alphafmt.c b/bld/as/axp/c/alphafmt.c index 37306ee86e..4dd9ce697e 100644 --- a/bld/as/axp/c/alphafmt.c +++ b/bld/as/axp/c/alphafmt.c @@ -36,29 +36,11 @@ #endif -#define _FiveBits( x ) ( (x) & 0x001f ) -#define _SixBits( x ) ( (x) & 0x003f ) -#define _SevenBits( x ) ( (x) & 0x007f ) -#define _EightBits( x ) ( (x) & 0x00ff ) -#define _ElevenBits( x ) ( (x) & 0x07ff ) -#define _FourteenBits( x ) ( (x) & 0x3fff ) -#define _SixteenBits( x ) ( (x) & 0xffff ) -#define _TwentyOneBits( x ) ( (x) & 0x001fffff ) - -#define _LIT_value( x ) ( _EightBits( x ) << 1 ) -#define _LIT_bit 1 -#define _LIT_unshifted( x ) ( _LIT_value( x ) | _LIT_bit ) - -#define _Opcode( x ) ( _SixBits( x ) << 26 ) -#define _Ra( x ) ( _FiveBits( x ) << 21 ) -#define _Rb( x ) ( _FiveBits( x ) << 16 ) -#define _Rc( x ) ( _FiveBits( x ) << 0 ) #define _Memory_disp( x ) ( _SixteenBits( x ) << 0 ) #define _Mem_Func( x ) ( _SixteenBits( x ) << 0 ) #define _Branch_disp( x ) ( _TwentyOneBits( x ) << 0 ) #define _Op_Func( x ) ( _SevenBits( x ) << 5 ) #define _FP_Op_Func( x ) ( _ElevenBits( x ) << 5 ) -#define _LIT( x ) ( _LIT_unshifted( x ) << 12 ) #define _Longword_offset( x ) ( (x) >> 2 ) @@ -66,17 +48,17 @@ // 21 dwords for an ins that emits multiple // instructions. (eg. ldb) -#define OPCODE_BIS 0x11 -#define FUNCCODE_BIS 0x0020 -#define OPCODE_LDA 0x8 -#define OPCODE_LDAH 0x9 +#define OPCODE_BIS 0x11 +#define FUNCCODE_BIS 0x0020 +#define OPCODE_LDA 0x8 +#define OPCODE_LDAH 0x9 #define OP_HAS_RELOC( op ) (((op)->flags & (RELOC | UNNAMED_RELOC)) != 0) #define OP_RELOC_NAMED( op ) ((op)->flags & RELOC) typedef struct reloc_entry *reloc_list; -typedef op_type ot_array[MAX_OPERANDS]; +typedef op_type ot_array[MAX_OPERANDS]; struct reloc_entry { reloc_list next; diff --git a/bld/as/axp/h/register.h b/bld/as/axp/h/register.h index 473727fb66..c3516de0a7 100644 --- a/bld/as/axp/h/register.h +++ b/bld/as/axp/h/register.h @@ -31,6 +31,9 @@ ****************************************************************************/ +#include "axpencod.h" + + #define MakeReg( c, i ) ( ( (i) & 0xff ) | ( (int)(c) << 8 ) ) #define RegClass( r ) ( ( (r) >> 8 ) & 0xff ) #define RegIndex( r ) ( (r) & 0xff ) @@ -38,13 +41,6 @@ #define NULL_REG_IDX 0 #define NULL_REG MakeReg( RC_NOTHING, NULL_REG_IDX ) -#define FP_REG_IDX 15 // Contains the Frame pointer (if needed) -#define RA_REG_IDX 26 // Contains the Return address -#define AT_REG_IDX 28 // Reserved for the assembler temporary -#define GP_REG_IDX 29 // Contains the Global pointer -#define SP_REG_IDX 30 // Contains the Stack pointer -#define ZERO_REG_IDX 31 // Contains 0 - #define ZERO_REG MakeReg( RC_GPR, ZERO_REG_IDX ) #define AT_REG MakeReg( RC_GPR, AT_REG_IDX ) diff --git a/bld/as/mps/c/mipsfmt.c b/bld/as/mps/c/mipsfmt.c index 2baed8ce91..34d979d537 100644 --- a/bld/as/mps/c/mipsfmt.c +++ b/bld/as/mps/c/mipsfmt.c @@ -34,32 +34,21 @@ #ifndef _STANDALONE_ #include "asinline.h" #endif - #include "mipsenco.h" /* * TODO: kill off all these once the axp residue is gone */ -#define _EightBits( x ) ( (x) & 0x00ff ) -#define _ElevenBits( x ) ( (x) & 0x07ff ) -#define _FourteenBits( x ) ( (x) & 0x3fff ) -#define _TwentyBits( x ) ( (x) & 0x000fffff ) - -#define _LIT_value( x ) ( _EightBits( x ) << 1 ) -#define _LIT_bit 1 -#define _LIT_unshifted( x ) ( _LIT_value( x ) | _LIT_bit ) #define _Memory_disp( x ) ( _SixteenBits( x ) << 0 ) #define _Mem_Func( x ) ( _SixteenBits( x ) << 0 ) #define _Op_Func( x ) ( _SixBits( x ) << 0 ) #define _FP_Op_Func( x ) ( _ElevenBits( x ) << 5 ) -#define _LIT( x ) ( _LIT_unshifted( x ) << 12 ) /* * This is real MIPS stuff */ -#define _TenBits( x ) ( (x) & 0x03ff ) #define _Code( x ) ( _TwentyBits( x ) << 6 ) #define _TrapCode( x ) ( _TenBits( x ) << 6 ) @@ -69,28 +58,28 @@ // 21 dwords for an ins that emits multiple // instructions. (eg. ldb) -#define OPCODE_NOP 0x00 -#define OPCODE_ADDIU 0x09 -#define OPCODE_ORI 0x0d -#define OPCODE_LUI 0x0f -#define FNCCODE_OR 0x25 -#define FNCCODE_JR 0x08 -#define FNCCODE_JALR 0x09 +#define OPCODE_NOP 0x00 +#define OPCODE_ADDIU 0x09 +#define OPCODE_ORI 0x0d +#define OPCODE_LUI 0x0f +#define FNCCODE_OR 0x25 +#define FNCCODE_JR 0x08 +#define FNCCODE_JALR 0x09 /* * TODO: kill off these macros */ -#define OPCODE_BIS 0x11 -#define FUNCCODE_BIS 0x0020 -#define OPCODE_LDA 0x8 -#define OPCODE_LDAH 0x9 +#define OPCODE_BIS 0x11 +#define FUNCCODE_BIS 0x0020 +#define OPCODE_LDA 0x8 +#define OPCODE_LDAH 0x9 #define OP_HAS_RELOC( op ) (((op)->flags & (RELOC | UNNAMED_RELOC)) != 0) #define OP_RELOC_NAMED( op ) ((op)->flags & RELOC) typedef struct reloc_entry *reloc_list; -typedef op_type ot_array[MAX_OPERANDS]; +typedef op_type ot_array[MAX_OPERANDS]; struct reloc_entry { reloc_list next; @@ -276,7 +265,7 @@ static void doOpcodeJType( uint_32 *buffer, uint_8 opcode ) static void doOpcodeIType( uint_32 *buffer, uint_8 opcode, uint_8 rt, uint_8 rs, signed_16 immed ) //************************************************************************************************ { - *buffer = _Opcode( opcode ) | _Rs( rs ) | _Rt( rt ) | _Immed( immed ); + *buffer = _Opcode( opcode ) | _Rs( rs ) | _Rt( rt ) | _SignedImmed( immed ); } @@ -350,7 +339,7 @@ static void doOpcodeFcRsRtImm( uint_32 *buffer, ins_opcode opcode, ins_funccode //********************************************************************************************************************* { *buffer = _Opcode( opcode ) | _Op_Func( fc ) | _Rs( rs ) | _Rt( rt ) | - _Immed( imm ); + _SignedImmed( imm ); } @@ -979,7 +968,7 @@ static void ITBranch( ins_table *table, instruction *ins, uint_32 *buffer, asm_r assert( ins->num_operands == 2 ); op = ins->operands[1]; doOpcodeRsRt( buffer, table->opcode, RegIndex( ins->operands[0]->reg ), 0, - _Immed( _Longword_offset( op->constant ) ) ); + _SignedImmed( _Longword_offset( op->constant ) ) ); doReloc( reloc, op, OWL_RELOC_BRANCH_REL, buffer ); numExtendedIns += doDelaySlotNOP( buffer ); } @@ -994,7 +983,7 @@ static void ITBranchTwo( ins_table *table, instruction *ins, uint_32 *buffer, as op = ins->operands[2]; doOpcodeIType( buffer, table->opcode, RegIndex( ins->operands[1]->reg ), RegIndex( ins->operands[0]->reg ), - _Immed( _Longword_offset( op->constant ) ) ); + _SignedImmed( _Longword_offset( op->constant ) ) ); doReloc( reloc, op, OWL_RELOC_BRANCH_REL, buffer ); numExtendedIns += doDelaySlotNOP( buffer ); } @@ -1009,7 +998,7 @@ static void ITBranchZero( ins_table *table, instruction *ins, uint_32 *buffer, a op = ins->operands[1]; doOpcodeIType( buffer, table->opcode, table->funccode, RegIndex( ins->operands[0]->reg ), - _Immed( _Longword_offset( op->constant ) ) ); + _SignedImmed( _Longword_offset( op->constant ) ) ); doReloc( reloc, op, OWL_RELOC_BRANCH_REL, buffer ); numExtendedIns += doDelaySlotNOP( buffer ); } @@ -1025,7 +1014,7 @@ static void ITBranchCop( ins_table *table, instruction *ins, uint_32 *buffer, as opcode = cop_codes[table->opcode >> 8]; op = ins->operands[0]; doOpcodeIType( buffer, opcode, table->funccode, table->opcode & 0xff, - _Immed( _Longword_offset( op->constant ) ) ); + _SignedImmed( _Longword_offset( op->constant ) ) ); doReloc( reloc, op, OWL_RELOC_BRANCH_REL, buffer ); numExtendedIns += doDelaySlotNOP( buffer ); } @@ -1174,7 +1163,7 @@ static void ITBr( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc return; } doOpcodeRsRt( buffer, table->opcode, ZERO_REG_IDX, 0, - _Immed( _Longword_offset( op0->constant ) ) ); + _SignedImmed( _Longword_offset( op0->constant ) ) ); doReloc( reloc, op0, OWL_RELOC_BRANCH_REL, buffer ); return; } diff --git a/bld/as/mps/h/register.h b/bld/as/mps/h/register.h index 9cdfb61159..cc89e40efa 100644 --- a/bld/as/mps/h/register.h +++ b/bld/as/mps/h/register.h @@ -30,6 +30,9 @@ ****************************************************************************/ +#include "mipsenco.h" + + #define MakeReg( c, i ) ( ( (i) & 0xff ) | ( (int)(c) << 8 ) ) #define RegClass( r ) ( ( (r) >> 8 ) & 0xff ) #define RegIndex( r ) ( (r) & 0xff ) @@ -37,13 +40,6 @@ #define NULL_REG_IDX 0 #define NULL_REG MakeReg( RC_NOTHING, NULL_REG_IDX ) -#define ZERO_REG_IDX 0 // Contains 0 -#define AT_REG_IDX 1 // Reserved for the assembler temporary -#define GP_REG_IDX 28 // Contains the Global pointer -#define SP_REG_IDX 29 // Contains the Stack pointer -#define FP_REG_IDX 30 // Contains the Frame pointer -#define RA_REG_IDX 31 // Contains the Return address - #define AT_REG MakeReg( RC_GPR, AT_REG_IDX ) #define ZERO_REG MakeReg( RC_GPR, ZERO_REG_IDX ) diff --git a/bld/as/ppc/c/ppcfmt.c b/bld/as/ppc/c/ppcfmt.c index 5f71a2ae31..d204660698 100644 --- a/bld/as/ppc/c/ppcfmt.c +++ b/bld/as/ppc/c/ppcfmt.c @@ -33,45 +33,26 @@ #include "as.h" -#define _SixBits( x ) ( (x) & 0x003f ) -#define _TenBits( x ) ( (x) & 0x03ff ) -#define _FiveBits( x ) ( (x) & 0x001f ) -#define _EightBits( x ) ( (x) & 0x00ff ) -#define _FourteenBits( x ) ( (x) & 0x3fff ) -#define _TwentyFourBits( x ) ( (x) & 0x00ffffff ) - // these correspond to letters on Appendix A table of Motorola refrence -#define _D( x ) ( _FiveBits(x) << 21 ) -#define _S( x ) ( _FiveBits(x) << 21 ) -#define _A( x ) ( _FiveBits(x) << 16 ) -#define _B( x ) ( _FiveBits(x) << 11 ) -#define _C( x ) ( _FiveBits(x) << 6 ) -#define _LI( x ) ( _TwentyFourBits(x) << 2 ) -#define _BO( x ) ( _FiveBits(x) << 21 ) -#define _BI( x ) ( _FiveBits(x) << 16 ) -#define _BD( x ) ( _FourteenBits(x) << 2 ) -#define _SH( x ) ( _FiveBits(x) << 11 ) -#define _MB( x ) ( _FiveBits(x) << 6 ) -#define _ME( x ) ( _FiveBits(x) << 1 ) -#define _CRM( x ) ( _EightBits(x) << 12 ) -#define _TBR( x ) ( _TenBits(x) << 11 ) -#define _SPR( x ) ( _TenBits(x) << 11 ) -#define _FM( x ) ( _EightBits(x) << 17 ) - -#define _Opcode( x ) ( _SixBits(x) << 26 ) -#define _Opcode2( x ) ( _TenBits(x) << 1 ) // some opcode2 includes OE - -// sixteen bit signed immediate -#define _SignedImmed( x ) ( (x) & 0xffff ) - -#define _OE( x ) ( ( ( (x) & IF_SETS_OVERFLOW ) ? 1 : 0 ) << 10 ) -#define _RC( x ) ( ( ( (x) & IF_SETS_CC ) ? 1 : 0 ) << 0 ) -#define _AA( x ) ( ( ( (x) & IF_SETS_ABSOLUTE ) ? 1 : 0 ) << 1 ) -#define _LK( x ) ( ( ( (x) & IF_SETS_LINK ) ? 1 : 0 ) << 0 ) +#define _LI( x ) ( _TwentyFourBits(x) << 2 ) +#define _BO( x ) ( _FiveBits(x) << 21 ) +#define _BI( x ) ( _FiveBits(x) << 16 ) +#define _BD( x ) ( _FourteenBits(x) << 2 ) +#define _SH( x ) ( _FiveBits(x) << 11 ) +#define _MB( x ) ( _FiveBits(x) << 6 ) +#define _ME( x ) ( _FiveBits(x) << 1 ) +#define _CRM( x ) ( _EightBits(x) << 12 ) +#define _TBR( x ) ( _TenBits(x) << 11 ) +#define _FM( x ) ( _EightBits(x) << 17 ) + +#define _IF_OE( x ) __OE( ((x) & IF_SETS_OVERFLOW) ? 1 : 0 ) +#define _IF_RC( x ) __RC( ((x) & IF_SETS_CC) ? 1 : 0 ) +#define _IF_AA( x ) __AA( ((x) & IF_SETS_ABSOLUTE) ? 1 : 0 ) +#define _IF_LK( x ) __LK( ((x) & IF_SETS_LINK) ? 1 : 0 ) #define _Longword_offset( x ) ( (x) >> 2 ) -#define _IsAbsolute( x ) ( ( (x) & IF_SETS_ABSOLUTE ) ? 1 : 0 ) +#define _IsAbsolute( x ) ( ((x) & IF_SETS_ABSOLUTE) ? 1 : 0 ) typedef enum { UNNAMED, // unnamed reloc @@ -110,9 +91,9 @@ static int_32 SPRChkList[] = { 528, 529, 530, 531, 532, 533, 534, 535, 1008, 1009, 1010, 1013, 1023 }; -static bool ensureTypeCorrect( ins_operand *op, op_type type, uint_8 opIdx ) { -//**************************************************************************** - +static bool ensureTypeCorrect( ins_operand *op, op_type type, uint_8 opIdx ) +//************************************************************************** +{ if( op->type != type ) { Error( IMPROPER_OPERAND, opIdx ); return( false ); @@ -120,9 +101,9 @@ static bool ensureTypeCorrect( ins_operand *op, op_type type, uint_8 opIdx ) { return( true ); } -static bool ensureOpAbsolute( ins_operand *op, uint_8 opIdx ) { -//************************************************************* - +static bool ensureOpAbsolute( ins_operand *op, uint_8 opIdx ) +//*********************************************************** +{ if( ( op->flags & ( RELOC | UNNAMED_RELOC ) ) ) { Error( RELOC_NOT_ALLOWED, opIdx ); return( false ); @@ -130,61 +111,66 @@ static bool ensureOpAbsolute( ins_operand *op, uint_8 opIdx ) { return( true ); } -static void doEncode2( uint_32 *buffer, ins_opcode p, uint r1, uint r2, uint imm, ins_flags flags ) { -//**************************************************************************************************************** -// Use when there are 2 5-bit blocks (other than opcode blocks) and -// an immediate block (16-bit) - - *buffer = _Opcode( p ) | _D( r1 ) | _A( r2 ) | _SignedImmed( imm ) | _OE( flags ) | _RC( flags ); +static void doEncode2( uint_32 *buffer, ins_opcode p, uint r1, uint r2, uint imm, ins_flags flags ) +/************************************************************************************************** + * Use when there are 2 5-bit blocks (other than opcode blocks) and + * an immediate block (16-bit) + */ +{ + *buffer = _Opcode( p ) | _D( r1 ) | _A( r2 ) | _SignedImmed( imm ) | _IF_OE( flags ) | _IF_RC( flags ); } -static void doEncode3( uint_32 *buffer, ins_opcode p, ins_opcode s, uint r1, uint r2, uint r3, ins_flags flags ) { -//**************************************************************************************************************** -// Use when there are 3 5-bit blocks (other than opcode blocks) - - *buffer = _Opcode( p ) | _D( r1 ) | _A( r2 ) | _B( r3 ) | _OE( flags ) | _Opcode2( s ) | _RC( flags ); +static void doEncode3( uint_32 *buffer, ins_opcode p, ins_opcode s, uint r1, uint r2, uint r3, ins_flags flags ) +/*************************************************************************************************************** + * Use when there are 3 5-bit blocks (other than opcode blocks) + */ +{ + *buffer = _Opcode( p ) | _D( r1 ) | _A( r2 ) | _B( r3 ) | _IF_OE( flags ) | _Opcode2( s ) | _IF_RC( flags ); } -static void doEncode4( uint_32 *buffer, ins_opcode p, ins_opcode s, uint r1, uint r2, uint r3, uint r4, ins_flags flags ) { -//************************************************************************************************************************* -// Use when there are 4 5-bit blocks (other than opcode blocks) - - *buffer = _Opcode( p ) | _D( r1 ) | _A( r2 ) | _C( r3 ) | _B( r4 ) | _Opcode2( s ) | _RC( flags ); +static void doEncode4( uint_32 *buffer, ins_opcode p, ins_opcode s, uint r1, uint r2, uint r3, uint r4, ins_flags flags ) +/************************************************************************************************************************ + * Use when there are 4 5-bit blocks (other than opcode blocks) + */ +{ + *buffer = _Opcode( p ) | _D( r1 ) | _A( r2 ) | _C( r3 ) | _B( r4 ) | _Opcode2( s ) | _IF_RC( flags ); } -static void doEncode5( uint_32 *buffer, ins_opcode p, uint r1, uint r2, uint r3, uint r4, uint r5, ins_flags flags ) { -//******************************************************************************************************************** -// Use when there are 5 5-bit blocks (other than opcode blocks) e.g. rlwimi - - *buffer = _Opcode( p ) | _S( r1 ) | _A( r2 ) | _SH( r3 ) | _MB( r4 ) | _ME( r5 ) | _RC( flags ); +static void doEncode5( uint_32 *buffer, ins_opcode p, uint r1, uint r2, uint r3, uint r4, uint r5, ins_flags flags ) +/******************************************************************************************************************* + * Use when there are 5 5-bit blocks (other than opcode blocks) e.g. rlwimi + */ +{ + *buffer = _Opcode( p ) | _S( r1 ) | _A( r2 ) | _SH( r3 ) | _MB( r4 ) | _ME( r5 ) | _IF_RC( flags ); } -static void doEncodeBoBiBd( uint_32 *buffer, ins_opcode p, uint bo, uint bi, uint bd, ins_flags flags ) { -//******************************************************************************************************* - - *buffer = _Opcode( p ) | _BO( bo ) | _BI( bi ) | _BD( bd ) | _AA( flags ) | _LK( flags ); +static void doEncodeBoBiBd( uint_32 *buffer, ins_opcode p, uint bo, uint bi, uint bd, ins_flags flags ) +/*****************************************************************************************************/ +{ + *buffer = _Opcode( p ) | _BO( bo ) | _BI( bi ) | _BD( bd ) | _IF_AA( flags ) | _IF_LK( flags ); } -static void doEncodeBoBiOp2( uint_32 *buffer, ins_opcode p, ins_opcode q, uint bo, uint bi, ins_flags flags ) { -//************************************************************************************************************* - - *buffer = _Opcode( p ) | _BO( bo ) | _BI( bi ) | _Opcode2( q ) | _AA( flags ) | _LK( flags ); +static void doEncodeBoBiOp2( uint_32 *buffer, ins_opcode p, ins_opcode q, uint bo, uint bi, ins_flags flags ) +/***********************************************************************************************************/ +{ + *buffer = _Opcode( p ) | _BO( bo ) | _BI( bi ) | _Opcode2( q ) | _IF_AA( flags ) | _IF_LK( flags ); } -static void doEncodeSPR( uint_32 *buffer, ins_opcode p, ins_opcode q, uint regidx, uint spr, ins_flags flags ) { -//************************************************************************************************************** - +static void doEncodeSPR( uint_32 *buffer, ins_opcode p, ins_opcode q, uint regidx, uint spr, ins_flags flags ) +/************************************************************************************************************/ +{ int_32 swapped_spr; swapped_spr = ( ( spr & 0x1f ) << 5 ) | ( ( spr & 0x3e0 ) >> 5 ); *buffer = _Opcode( p ) | _Opcode2( q ) | _D( regidx ) | - _SPR( swapped_spr ) | _RC( flags ) | _OE( flags ); + _SPR( swapped_spr ) | _IF_RC( flags ) | _IF_OE( flags ); } -static owl_reloc_type relocType( asm_reloc_type type, owl_reloc_type default_type, bool absolute ) { -//************************************************************************************************** -// The absolute flag is used for jump/branch only - +static owl_reloc_type relocType( asm_reloc_type type, owl_reloc_type default_type, bool absolute ) +/************************************************************************************************* + * The absolute flag is used for jump/branch only + */ +{ owl_reloc_type ret; if( type == ASM_RELOC_UNSPECIFIED ) { @@ -224,11 +210,12 @@ static owl_reloc_type relocType( asm_reloc_type type, owl_reloc_type default_typ return( ret ); } -static void doReloc( asm_reloc *reloc, ins_operand *op, owl_reloc_type rtype, ins_flags flags ) { -//*********************************************************************************************** -// If it is a jump reloc, we should pass it in as a relative no matter what -// and let relocType change it to absolute if AA bit is set. - +static void doReloc( asm_reloc *reloc, ins_operand *op, owl_reloc_type rtype, ins_flags flags ) +/********************************************************************************************** + * If it is a jump reloc, we should pass it in as a relative no matter what + * and let relocType change it to absolute if AA bit is set. + */ +{ assert( rtype != OWL_RELOC_JUMP_ABS && rtype != OWL_RELOC_BRANCH_ABS ); if( ( op->flags & RELOC ) == RELOC ) { reloc->target.sym = op->reloc.target.ptr; @@ -243,10 +230,11 @@ static void doReloc( asm_reloc *reloc, ins_operand *op, owl_reloc_type rtype, in } } -static void ITBinary( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) { -//********************************************************************************************* -// Three operands line up in the order they will be in the encoding - +static void ITBinary( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) +/******************************************************************************************** + * Three operands line up in the order they will be in the encoding + */ +{ /* unused parameters */ (void)reloc; assert( ins->num_operands == 3 ); @@ -256,10 +244,11 @@ static void ITBinary( ins_table *table, instruction *ins, uint_32 *buffer, asm_r ( ins->format->flags & table->optional ) | table->required ); } -static void ITBinary2( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) { -//********************************************************************************************** -// The first two operands are reversed in terms of bit positioning - +static void ITBinary2( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) +/********************************************************************************************* + * The first two operands are reversed in terms of bit positioning + */ +{ /* unused parameters */ (void)reloc; assert( ins->num_operands == 3 ); @@ -269,9 +258,9 @@ static void ITBinary2( ins_table *table, instruction *ins, uint_32 *buffer, asm_ ( ins->format->flags & table->optional ) | table->required ); } -static void ITBinaryImmed( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) { -//************************************************************************************************** - +static void ITBinaryImmed( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) +/************************************************************************************************/ +{ ins_operand *op; assert( ins->num_operands == 3 ); @@ -282,9 +271,9 @@ static void ITBinaryImmed( ins_table *table, instruction *ins, uint_32 *buffer, doReloc( reloc, op, OWL_RELOC_HALF_LO, 0 ); } -static void ITBinaryImmed2( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) { -//*************************************************************************************************** - +static void ITBinaryImmed2( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) +/*************************************************************************************************/ +{ ins_operand *op; assert( ins->num_operands == 3 ); @@ -295,9 +284,9 @@ static void ITBinaryImmed2( ins_table *table, instruction *ins, uint_32 *buffer, doReloc( reloc, op, OWL_RELOC_HALF_LO, 0 ); } -static void ITUnary( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) { -//******************************************************************************************** - +static void ITUnary( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) +/******************************************************************************************/ +{ /* unused parameters */ (void)reloc; assert( ins->num_operands == 2 ); @@ -306,9 +295,9 @@ static void ITUnary( ins_table *table, instruction *ins, uint_32 *buffer, asm_re ( ins->format->flags & table->optional ) | table->required ); } -static void ITUnary2( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) { -//********************************************************************************************* - +static void ITUnary2( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) +/*******************************************************************************************/ +{ /* unused parameters */ (void)reloc; assert( ins->num_operands == 2 ); @@ -317,16 +306,16 @@ static void ITUnary2( ins_table *table, instruction *ins, uint_32 *buffer, asm_r ( ins->format->flags & table->optional ) | table->required ); } -static void ITFPBin( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) { -//******************************************************************************************** - +static void ITFPBin( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) +/******************************************************************************************/ +{ ITBinary( table, ins, buffer, reloc ); } -static void ITFPUnary( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) { -//********************************************************************************************** - +static void ITFPUnary( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) +/********************************************************************************************/ +{ /* unused parameters */ (void)reloc; assert( ins->num_operands == 2 ); @@ -335,9 +324,9 @@ static void ITFPUnary( ins_table *table, instruction *ins, uint_32 *buffer, asm_ ( ins->format->flags & table->optional ) | table->required ); } -static void ITFPCmp( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) { -//******************************************************************************************** - +static void ITFPCmp( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) +/******************************************************************************************/ +{ /* unused parameters */ (void)reloc; assert( ins->num_operands == 3 ); @@ -347,9 +336,9 @@ static void ITFPCmp( ins_table *table, instruction *ins, uint_32 *buffer, asm_re ( ins->format->flags & table->optional ) | table->required ); } -static void ITFPMulAdd( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) { -//*********************************************************************************************** - +static void ITFPMulAdd( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) +/*********************************************************************************************/ +{ /* unused parameters */ (void)reloc; assert( ins->num_operands == 4 ); @@ -359,9 +348,9 @@ static void ITFPMulAdd( ins_table *table, instruction *ins, uint_32 *buffer, asm ( ins->format->flags & table->optional ) | table->required ); } -static void ITFPMul( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) { -//******************************************************************************************** - +static void ITFPMul( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) +/******************************************************************************************/ +{ /* unused parameters */ (void)reloc; assert( ins->num_operands == 3 ); @@ -371,9 +360,9 @@ static void ITFPMul( ins_table *table, instruction *ins, uint_32 *buffer, asm_re ( ins->format->flags & table->optional ) | table->required ); } -static void ITBranch( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) { -//********************************************************************************************* - +static void ITBranch( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) +/*******************************************************************************************/ +{ ins_operand *op; ins_flags flags; @@ -382,13 +371,13 @@ static void ITBranch( ins_table *table, instruction *ins, uint_32 *buffer, asm_r op = ins->operands[0]; *buffer = _Opcode( table->primary ) | _LI( _Longword_offset( op->constant ) ) | - _AA( flags ) | _LK( flags ); + _IF_AA( flags ) | _IF_LK( flags ); doReloc( reloc, op, OWL_RELOC_JUMP_REL, flags ); } -static void ITBranchCond( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) { -//************************************************************************************************* - +static void ITBranchCond( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) +/***********************************************************************************************/ +{ ins_operand *op[3]; ins_flags flags; int ctr; @@ -406,9 +395,9 @@ static void ITBranchCond( ins_table *table, instruction *ins, uint_32 *buffer, a doReloc( reloc, op[2], OWL_RELOC_BRANCH_REL, flags ); } -static void ITBranchSpec( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) { -//************************************************************************************************* - +static void ITBranchSpec( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) +/***********************************************************************************************/ +{ ins_operand *op[2]; // ins_flags flags; int ctr; @@ -428,9 +417,9 @@ static void ITBranchSpec( ins_table *table, instruction *ins, uint_32 *buffer, a ( ins->format->flags & table->optional ) | table->required ); } -static void ITCmp( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) { -//****************************************************************************************** - +static void ITCmp( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) +/****************************************************************************************/ +{ ins_operand *op[4], *opRa, *opRb; uint crfIdx, L_bit, ctr; ins_opcount opcount; @@ -469,9 +458,9 @@ static void ITCmp( ins_table *table, instruction *ins, uint_32 *buffer, asm_relo } } -static void ITCmpImmed( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) { -//*********************************************************************************************** - +static void ITCmpImmed( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) +/*********************************************************************************************/ +{ ins_operand *op[4], *opRa, *opSimm; uint crfIdx, L_bit, ctr; ins_opcount opcount; @@ -508,9 +497,9 @@ static void ITCmpImmed( ins_table *table, instruction *ins, uint_32 *buffer, asm } } -static void ITCondBit( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) { -//********************************************************************************************** - +static void ITCondBit( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) +/********************************************************************************************/ +{ /* unused parameters */ (void)reloc; assert( ins->num_operands == 3 ); @@ -520,9 +509,9 @@ static void ITCondBit( ins_table *table, instruction *ins, uint_32 *buffer, asm_ ( ins->format->flags & table->optional ) | table->required ); } -static void ITCondUn( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) { -//********************************************************************************************* - +static void ITCondUn( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) +/*******************************************************************************************/ +{ /* unused parameters */ (void)reloc; assert( ins->num_operands == 2 ); @@ -532,9 +521,9 @@ static void ITCondUn( ins_table *table, instruction *ins, uint_32 *buffer, asm_r ( ins->format->flags & table->optional ) | table->required ); } -static void ITMcrxr( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) { -//******************************************************************************************** - +static void ITMcrxr( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) +/******************************************************************************************/ +{ /* unused parameters */ (void)reloc; assert( ins->num_operands == 1 ); @@ -543,9 +532,9 @@ static void ITMcrxr( ins_table *table, instruction *ins, uint_32 *buffer, asm_re ( ins->format->flags & table->optional ) | table->required ); } -static void ITMfcr( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) { -//******************************************************************************************* - +static void ITMfcr( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) +/*****************************************************************************************/ +{ /* unused parameters */ (void)reloc; assert( ins->num_operands == 1 ); @@ -554,15 +543,15 @@ static void ITMfcr( ins_table *table, instruction *ins, uint_32 *buffer, asm_rel ( ins->format->flags & table->optional ) | table->required ); } -static void ITMffs( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) { -//******************************************************************************************* - +static void ITMffs( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) +/*****************************************************************************************/ +{ ITMfcr( table, ins, buffer, reloc ); } -static bool SPRValidate( int_32 spr ) { -//************************************* - +static bool SPRValidate( int_32 spr ) +/***********************************/ +{ int n, ctr; bool status = false; @@ -575,9 +564,9 @@ static bool SPRValidate( int_32 spr ) { return( status ); } -static void ITMfspr( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) { -//******************************************************************************************** - +static void ITMfspr( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) +/******************************************************************************************/ +{ ins_operand *const_op; /* unused parameters */ (void)reloc; @@ -594,9 +583,9 @@ static void ITMfspr( ins_table *table, instruction *ins, uint_32 *buffer, asm_re } } -static void ITMfsr( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) { -//******************************************************************************************* - +static void ITMfsr( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) +/*****************************************************************************************/ +{ ins_operand *const_op; /* unused parameters */ (void)reloc; @@ -613,9 +602,9 @@ static void ITMfsr( ins_table *table, instruction *ins, uint_32 *buffer, asm_rel } } -static void ITMfsrin( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) { -//********************************************************************************************* - +static void ITMfsrin( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) +/*******************************************************************************************/ +{ /* unused parameters */ (void)reloc; assert( ins->num_operands == 2 ); @@ -624,9 +613,9 @@ static void ITMfsrin( ins_table *table, instruction *ins, uint_32 *buffer, asm_r ( ins->format->flags & table->optional ) | table->required ); } -static void ITMftb( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) { -//******************************************************************************************* - +static void ITMftb( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) +/*****************************************************************************************/ +{ ins_operand *const_op; ins_flags flags; @@ -641,13 +630,13 @@ static void ITMftb( ins_table *table, instruction *ins, uint_32 *buffer, asm_rel flags = ( ins->format->flags & table->optional ) | table->required; *buffer = _Opcode( table->primary ) | _Opcode2( table->secondary ) | _D( RegIndex( ins->operands[0]->reg ) ) | - _TBR( const_op->constant ) | _OE( flags ) | _RC( flags ); + _TBR( const_op->constant ) | _IF_OE( flags ) | _IF_RC( flags ); } } -static void ITMtcrf( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) { -//******************************************************************************************** - +static void ITMtcrf( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) +/******************************************************************************************/ +{ ins_operand *const_op; ins_flags flags; @@ -662,19 +651,19 @@ static void ITMtcrf( ins_table *table, instruction *ins, uint_32 *buffer, asm_re flags = ( ins->format->flags & table->optional ) | table->required; *buffer = _Opcode( table->primary ) | _Opcode2( table->secondary ) | _S( RegIndex( ins->operands[1]->reg ) ) | - _CRM( const_op->constant ) | _OE( flags ) | _RC( flags ); + _CRM( const_op->constant ) | _IF_OE( flags ) | _IF_RC( flags ); } } -static void ITMtfsb( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) { -//******************************************************************************************** - +static void ITMtfsb( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) +/******************************************************************************************/ +{ ITMfcr( table, ins, buffer, reloc ); } -static void ITMtfsf( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) { -//******************************************************************************************** - +static void ITMtfsf( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) +/******************************************************************************************/ +{ ins_operand *opFM; ins_flags flags; @@ -689,13 +678,13 @@ static void ITMtfsf( ins_table *table, instruction *ins, uint_32 *buffer, asm_re flags = ( ins->format->flags & table->optional ) | table->required; *buffer = _Opcode( table->primary ) | _Opcode2( table->secondary ) | _FM( opFM->constant ) | _B( RegIndex( ins->operands[1]->reg ) ) | - _OE( flags ) | _RC( flags ); + _IF_OE( flags ) | _IF_RC( flags ); } } -static void ITMtfsfImmed( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) { -//************************************************************************************************* - +static void ITMtfsfImmed( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) +/***********************************************************************************************/ +{ ins_operand *const_op; /* unused parameters */ (void)reloc; @@ -712,9 +701,9 @@ static void ITMtfsfImmed( ins_table *table, instruction *ins, uint_32 *buffer, a } } -static void ITMtspr( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) { -//******************************************************************************************** - +static void ITMtspr( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) +/******************************************************************************************/ +{ ins_operand *const_op; /* unused parameters */ (void)reloc; @@ -732,9 +721,9 @@ static void ITMtspr( ins_table *table, instruction *ins, uint_32 *buffer, asm_re } } -static void ITMtsr( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) { -//******************************************************************************************* - +static void ITMtsr( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) +/*****************************************************************************************/ +{ ins_operand *const_op; /* unused parameters */ (void)reloc; @@ -751,9 +740,9 @@ static void ITMtsr( ins_table *table, instruction *ins, uint_32 *buffer, asm_rel } } -static void ITDc( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) { -//***************************************************************************************** - +static void ITDc( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) +/***************************************************************************************/ +{ /* unused parameters */ (void)reloc; assert( ins->num_operands == 2 ); @@ -762,9 +751,9 @@ static void ITDc( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc ( ins->format->flags & table->optional ) | table->required ); } -static void ITEieio( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) { -//******************************************************************************************** - +static void ITEieio( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) +/******************************************************************************************/ +{ /* unused parameters */ (void)reloc; assert( ins->num_operands == 0 ); @@ -772,9 +761,9 @@ static void ITEieio( ins_table *table, instruction *ins, uint_32 *buffer, asm_re ( ins->format->flags & table->optional ) | table->required ); } -static void ITFctid( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) { -//******************************************************************************************** - +static void ITFctid( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) +/******************************************************************************************/ +{ /* unused parameters */ (void)reloc; assert( ins->num_operands == 2 ); @@ -783,9 +772,9 @@ static void ITFctid( ins_table *table, instruction *ins, uint_32 *buffer, asm_re ( ins->format->flags & table->optional ) | table->required ); } -static void ITLdStr( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) { -//******************************************************************************************** - +static void ITLdStr( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) +/******************************************************************************************/ +{ ins_operand *op; assert( ins->num_operands == 2 ); @@ -796,9 +785,9 @@ static void ITLdStr( ins_table *table, instruction *ins, uint_32 *buffer, asm_re doReloc( reloc, op, OWL_RELOC_HALF_LO, 0 ); } -static void ITLdStrIndex( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) { -//************************************************************************************************* - +static void ITLdStrIndex( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) +/***********************************************************************************************/ +{ /* unused parameters */ (void)reloc; assert( ins->num_operands == 3 ); @@ -808,9 +797,9 @@ static void ITLdStrIndex( ins_table *table, instruction *ins, uint_32 *buffer, a ( ins->format->flags & table->optional ) | table->required ); } -static void ITLdStrFP( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) { -//********************************************************************************************** - +static void ITLdStrFP( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) +/********************************************************************************************/ +{ ins_operand *op; assert( ins->num_operands == 2 ); @@ -821,15 +810,15 @@ static void ITLdStrFP( ins_table *table, instruction *ins, uint_32 *buffer, asm_ doReloc( reloc, op, OWL_RELOC_HALF_LO, 0 ); } -static void ITLdStrIndexFP( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) { -//*************************************************************************************************** - +static void ITLdStrIndexFP( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) +/*************************************************************************************************/ +{ ITBinary( table, ins, buffer, reloc ); } -static void ITLswi( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) { -//******************************************************************************************* - +static void ITLswi( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) +/*****************************************************************************************/ +{ ins_operand *op; /* unused parameters */ (void)reloc; @@ -844,9 +833,9 @@ static void ITLswi( ins_table *table, instruction *ins, uint_32 *buffer, asm_rel } } -static void ITShift( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) { -//******************************************************************************************** - +static void ITShift( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) +/******************************************************************************************/ +{ ins_operand *op; /* unused parameters */ (void)reloc; @@ -861,9 +850,9 @@ static void ITShift( ins_table *table, instruction *ins, uint_32 *buffer, asm_re } } -static void ITShiftImmed( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) { -//************************************************************************************************* - +static void ITShiftImmed( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) +/***********************************************************************************************/ +{ ins_operand *const_op[3]; int ctr; @@ -882,9 +871,9 @@ static void ITShiftImmed( ins_table *table, instruction *ins, uint_32 *buffer, a ( ins->format->flags & table->optional ) | table->required ); } -static void ITShiftIndex( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) { -//************************************************************************************************* - +static void ITShiftIndex( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) +/***********************************************************************************************/ +{ ins_operand *const_op[2]; int ctr; @@ -903,9 +892,9 @@ static void ITShiftIndex( ins_table *table, instruction *ins, uint_32 *buffer, a ( ins->format->flags & table->optional ) | table->required ); } -static void ITTlbie( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) { -//******************************************************************************************** - +static void ITTlbie( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) +/******************************************************************************************/ +{ /* unused parameters */ (void)reloc; assert( ins->num_operands == 1 ); @@ -914,9 +903,9 @@ static void ITTlbie( ins_table *table, instruction *ins, uint_32 *buffer, asm_re ( ins->format->flags & table->optional ) | table->required ); } -static void ITTrap( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) { -//******************************************************************************************* - +static void ITTrap( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) +/*****************************************************************************************/ +{ ins_operand *op; /* unused parameters */ (void)reloc; @@ -930,9 +919,9 @@ static void ITTrap( ins_table *table, instruction *ins, uint_32 *buffer, asm_rel } } -static void ITTrapImmed( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) { -//************************************************************************************************ - +static void ITTrapImmed( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) +/**********************************************************************************************/ +{ ins_operand *op0, *op2; assert( ins->num_operands == 3 ); @@ -946,9 +935,9 @@ static void ITTrapImmed( ins_table *table, instruction *ins, uint_32 *buffer, as } } -static void ITSMLoadImmed( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) { -//************************************************************************************************** - +static void ITSMLoadImmed( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) +/************************************************************************************************/ +{ ins_operand *op; assert( ins->num_operands == 2 ); @@ -959,9 +948,9 @@ static void ITSMLoadImmed( ins_table *table, instruction *ins, uint_32 *buffer, doReloc( reloc, op, OWL_RELOC_HALF_LO, 0 ); } -static void ITSMLoadAddr( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) { -//************************************************************************************************* - +static void ITSMLoadAddr( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) +/***********************************************************************************************/ +{ ins_operand *op; assert( ins->num_operands == 2 ); @@ -972,9 +961,9 @@ static void ITSMLoadAddr( ins_table *table, instruction *ins, uint_32 *buffer, a doReloc( reloc, op, OWL_RELOC_HALF_LO, 0 ); } -static void ITSMMovReg( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) { -//*********************************************************************************************** - +static void ITSMMovReg( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) +/*********************************************************************************************/ +{ /* unused parameters */ (void)reloc; assert( ins->num_operands == 2 ); @@ -984,9 +973,9 @@ static void ITSMMovReg( ins_table *table, instruction *ins, uint_32 *buffer, asm ( ins->format->flags & table->optional ) | table->required ); } -static void ITSMSubImmed( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) { -//************************************************************************************************* - +static void ITSMSubImmed( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) +/***********************************************************************************************/ +{ ins_operand *op; /* unused parameters */ (void)reloc; @@ -1000,9 +989,9 @@ static void ITSMSubImmed( ins_table *table, instruction *ins, uint_32 *buffer, a } } -static void ITSMCmpwi( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) { -//********************************************************************************************** - +static void ITSMCmpwi( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) +/********************************************************************************************/ +{ ins_operand *op0, *opRa, *opSimm; uint crfIdx; @@ -1033,9 +1022,9 @@ static void ITSMCmpwi( ins_table *table, instruction *ins, uint_32 *buffer, asm_ doReloc( reloc, opSimm, OWL_RELOC_HALF_LO, 0 ); } -static void ITSMCmpw( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) { -//********************************************************************************************* - +static void ITSMCmpw( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) +/*******************************************************************************************/ +{ ins_operand *op0, *opRa, *opRb; uint crfIdx; @@ -1064,9 +1053,9 @@ static void ITSMCmpw( ins_table *table, instruction *ins, uint_32 *buffer, asm_r ( ins->format->flags & table->optional ) | table->required ); } -static void ITSMExtlwi( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) { -//*********************************************************************************************** - +static void ITSMExtlwi( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) +/*********************************************************************************************/ +{ ins_operand *const_op[2]; int ctr; @@ -1085,9 +1074,9 @@ static void ITSMExtlwi( ins_table *table, instruction *ins, uint_32 *buffer, asm ( ins->format->flags & table->optional ) | table->required ); } -static void ITSMSrwi( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) { -//********************************************************************************************* - +static void ITSMSrwi( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) +/*******************************************************************************************/ +{ ins_operand *const_op; uint n; uint sh = 0; @@ -1116,9 +1105,9 @@ static void ITSMSrwi( ins_table *table, instruction *ins, uint_32 *buffer, asm_r ( ins->format->flags & table->optional ) | table->required ); } -static void ITSMRotlw( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) { -//********************************************************************************************** - +static void ITSMRotlw( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) +/********************************************************************************************/ +{ /* unused parameters */ (void)reloc; assert( ins->num_operands == 3 ); @@ -1128,9 +1117,9 @@ static void ITSMRotlw( ins_table *table, instruction *ins, uint_32 *buffer, asm_ ( ins->format->flags & table->optional ) | table->required ); } -static void ITSMInslw( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) { -//********************************************************************************************** - +static void ITSMInslw( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) +/********************************************************************************************/ +{ ins_operand *const_op[2]; uint n, b; int ctr; @@ -1151,9 +1140,9 @@ static void ITSMInslw( ins_table *table, instruction *ins, uint_32 *buffer, asm_ ( ins->format->flags & table->optional ) | table->required ); } -static void ITSMTrapUncond( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) { -//*************************************************************************************************** - +static void ITSMTrapUncond( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) +/*************************************************************************************************/ +{ /* unused parameters */ (void)reloc; assert( ins->num_operands == 0 ); @@ -1161,9 +1150,9 @@ static void ITSMTrapUncond( ins_table *table, instruction *ins, uint_32 *buffer, ( ins->format->flags & table->optional ) | table->required ); } -static void ITSMTrap( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) { -//********************************************************************************************* - +static void ITSMTrap( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) +/*******************************************************************************************/ +{ /* unused parameters */ (void)reloc; assert( ins->num_operands == 2 ); @@ -1172,9 +1161,9 @@ static void ITSMTrap( ins_table *table, instruction *ins, uint_32 *buffer, asm_r ( ins->format->flags & table->optional ) | table->required ); } -static void ITSMTrapImmed( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) { -//************************************************************************************************** - +static void ITSMTrapImmed( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) +/************************************************************************************************/ +{ ins_operand *op1; assert( ins->num_operands == 2 ); @@ -1185,9 +1174,9 @@ static void ITSMTrapImmed( ins_table *table, instruction *ins, uint_32 *buffer, doReloc( reloc, op1, OWL_RELOC_HALF_LO, 0 ); } -static void ITSMMovSpr( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) { -//*********************************************************************************************** - +static void ITSMMovSpr( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) +/*********************************************************************************************/ +{ /* unused parameters */ (void)reloc; assert( ins->num_operands == 1 ); @@ -1197,9 +1186,9 @@ static void ITSMMovSpr( ins_table *table, instruction *ins, uint_32 *buffer, asm ( ins->format->flags & table->optional ) | table->required ); } -static void ITSMMovSprNCover( bool isMoveTo, ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) { -//******************************************************************************************************************** - +static void ITSMMovSprNCover( bool isMoveTo, ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) +/******************************************************************************************************************/ +{ ins_operand *op; uint spr; int idx0, idx1; @@ -1239,21 +1228,21 @@ static void ITSMMovSprNCover( bool isMoveTo, ins_table *table, instruction *ins, ( ins->format->flags & table->optional ) | table->required ); } -static void ITSMMtsprN( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) { -//*********************************************************************************************** - +static void ITSMMtsprN( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) +/*********************************************************************************************/ +{ ITSMMovSprNCover( true, table, ins, buffer, reloc ); } -static void ITSMMfsprN( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) { -//*********************************************************************************************** - +static void ITSMMfsprN( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) +/*********************************************************************************************/ +{ ITSMMovSprNCover( false, table, ins, buffer, reloc ); } -static void ITSMBCIcc( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) { -//********************************************************************************************** - +static void ITSMBCIcc( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) +/********************************************************************************************/ +{ ins_operand *op0, *opBd; ins_special special; ins_flags flags; @@ -1280,14 +1269,15 @@ static void ITSMBCIcc( ins_table *table, instruction *ins, uint_32 *buffer, asm_ doReloc( reloc, opBd, OWL_RELOC_BRANCH_REL, flags ); } -static void ITSMBC( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) { -//******************************************************************************************* -// Four possibilities; the remainder are all improper: -// i) bdnz OP_IMMED(reloc okay) -// ii) bdnz OP_CRF, OP_IMMED(reloc okay) -// iii) bdnz OP_BI, OP_IMMED(reloc okay) -// iv) bdnz OP_IMMED(no reloc), OP_IMMED(reloc okay) - +static void ITSMBC( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) +/****************************************************************************************** + * Four possibilities; the remainder are all improper: + * i) bdnz OP_IMMED(reloc okay) + * ii) bdnz OP_CRF, OP_IMMED(reloc okay) + * iii) bdnz OP_BI, OP_IMMED(reloc okay) + * iv) bdnz OP_IMMED(no reloc), OP_IMMED(reloc okay) + */ +{ ins_operand *op0; ins_operand *opBd = NULL; ins_flags flags; @@ -1327,9 +1317,9 @@ static void ITSMBC( ins_table *table, instruction *ins, uint_32 *buffer, asm_rel doReloc( reloc, opBd, OWL_RELOC_BRANCH_REL, flags ); } -static void ITSMBSpecIcc( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) { -//************************************************************************************************* - +static void ITSMBSpecIcc( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) +/***********************************************************************************************/ +{ #ifndef NDEBUG ins_operand *op0; #endif @@ -1354,14 +1344,15 @@ static void ITSMBSpecIcc( ins_table *table, instruction *ins, uint_32 *buffer, a ( ins->format->flags & table->optional ) | table->required ); } -static void ITSMBSpec( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) { -//********************************************************************************************** -// Four possibilities; the remainder are all improper: -// i) bdnzlr (no operand) -// ii) bdnzlr OP_CRF -// iii) bdnzlr OP_BI -// iv) bdnzlr OP_IMMED(no reloc) - +static void ITSMBSpec( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) +/********************************************************************************************* + * Four possibilities; the remainder are all improper: + * i) bdnzlr (no operand) + * ii) bdnzlr OP_CRF + * iii) bdnzlr OP_BI + * iv) bdnzlr OP_IMMED(no reloc) + */ +{ ins_operand *op0; uint valueBI = 0; @@ -1400,10 +1391,11 @@ ppc_format PPCFormatTable[] = { #undef PICK }; -static void opError( instruction *ins, op_type actual, op_type wanted, int i ) { -//****************************************************************************** -// Stuff out an error message. - +static void opError( instruction *ins, op_type actual, op_type wanted, int i ) +/***************************************************************************** + * Stuff out an error message. + */ +{ /* unused parameters */ (void)ins; (void)actual; if( (wanted & OP_NOTHING) != OP_NOTHING ) { @@ -1413,12 +1405,13 @@ static void opError( instruction *ins, op_type actual, op_type wanted, int i ) { } } -bool PPCValidate( instruction *ins ) { -//************************************ -// Make sure that all operands of the given instruction -// are of the type we are expecting. If not, we print -// out an error message. - +bool PPCValidate( instruction *ins ) +/*********************************** + * Make sure that all operands of the given instruction + * are of the type we are expecting. If not, we print + * out an error message. + */ +{ int i; ppc_format *fmt; ins_operand *op; @@ -1442,16 +1435,16 @@ bool PPCValidate( instruction *ins ) { } #ifdef _STANDALONE_ -void PPCEmit( owl_section_handle hdl, instruction *ins ) { -//******************************************************** +void PPCEmit( owl_section_handle hdl, instruction *ins ) #else -void PPCEmit( instruction *ins ) { -//******************************** +void PPCEmit( instruction *ins ) #endif -// Encode the given instruction (including emitting any -// relocs to the appropriate places), and emit the code -// to the given section. - +/******************************************************* + * Encode the given instruction (including emitting any + * relocs to the appropriate places), and emit the code + * to the given section. + */ +{ ins_table *table; uint_32 result; asm_reloc reloc = { OWL_RELOC_ABSOLUTE, { 0 }, false, false }; diff --git a/bld/as/ppc/h/register.h b/bld/as/ppc/h/register.h index b652229700..904f7fcb77 100644 --- a/bld/as/ppc/h/register.h +++ b/bld/as/ppc/h/register.h @@ -31,6 +31,9 @@ ****************************************************************************/ +#include "ppcencod.h" + + #define MakeReg( c, i ) ( ( (i) & 0xff ) | ( (int)(c) << 8 ) ) #define RegClass( r ) ( ( (r) >> 8 ) & 0xff ) #define RegIndex( r ) ( (r) & 0xff ) @@ -38,9 +41,6 @@ #define NULL_REG_IDX 0 #define NULL_REG MakeReg( RC_NOTHING, NULL_REG_IDX ) -#define SP_REG_IDX 1 -#define RTOC_REG_IDX 2 - #define AT_REG NULL_REG typedef uint_16 reg; diff --git a/bld/cg/risc/axp/c/axpenc.c b/bld/cg/risc/axp/c/axpenc.c index 0e8b73811f..60df661e4e 100644 --- a/bld/cg/risc/axp/c/axpenc.c +++ b/bld/cg/risc/axp/c/axpenc.c @@ -288,21 +288,21 @@ static void EmitIns( axp_ins ins ) static void GenFPOPINS( uint_8 opcode, uint_16 function, uint_8 reg_a, uint_8 reg_b, uint_8 reg_c ) /**************************************************************************************************/ { - ins_encoding = _Opcode( opcode ) | _A( reg_a ) | _B( reg_b ) | _C( reg_c ) | _FPFunction( function ); + ins_encoding = _Opcode( opcode ) | _Ra( reg_a ) | _Rb( reg_b ) | _Rc( reg_c ) | _FPFunction( function ); EmitIns( ins_encoding ); } void GenOPINS( uint_8 opcode, uint_8 function, uint_8 reg_a, uint_8 reg_b, uint_8 reg_c ) /***************************************************************************************/ { - ins_encoding = _Opcode( opcode ) | _A( reg_a ) | _B( reg_b ) | _C( reg_c ) | _Function( function ); + ins_encoding = _Opcode( opcode ) | _Ra( reg_a ) | _Rb( reg_b ) | _Rc( reg_c ) | _Function( function ); EmitIns( ins_encoding ); } static void GenOPIMM( uint_8 opcode, uint_8 function, uint_8 reg_a, uint_8 imm, uint_8 reg_c ) /************************************************************************************************/ { - ins_encoding = _Opcode( opcode ) | _A( reg_a ) | _LIT( imm ) | ( 1 << 12 ) | _C( reg_c ) | _Function( function ); + ins_encoding = _Opcode( opcode ) | _Ra( reg_a ) | _LIT( imm ) | ( 1 << 12 ) | _Rc( reg_c ) | _Function( function ); EmitIns( ins_encoding ); } @@ -314,7 +314,7 @@ void GenLOADS32( signed_32 value, uint_8 reg ) signed_16 low; uint_8 curr; - curr = AXP_ZERO_SINK; + curr = ZERO_REG_IDX; FactorInt32( value, &high, &extra, &low ); if( low != 0 ) { /* @@ -389,21 +389,21 @@ static uint_16 FindFloatingOpcodes( instruction *ins ) void GenMEMINSRELOC( uint_8 opcode, uint_8 a, uint_8 b, signed_16 displacement, pointer lbl, owl_reloc_type type ) /****************************************************************************************************************/ { - ins_encoding = _Opcode( opcode ) | _A( a ) | _B( b ) | _SignedImmed( displacement ); + ins_encoding = _Opcode( opcode ) | _Ra( a ) | _Rb( b ) | _SignedImmed( displacement ); EmitInsReloc( &ins_encoding, lbl, type ); } void GenMEMINS( uint_8 opcode, uint_8 a, uint_8 b, signed_16 displacement ) /*************************************************************************/ { - ins_encoding = _Opcode( opcode ) | _A( a ) | _B( b ) | _SignedImmed( displacement ); + ins_encoding = _Opcode( opcode ) | _Ra( a ) | _Rb( b ) | _SignedImmed( displacement ); EmitIns( ins_encoding ); } static void GenBRANCH( uint_8 opcode, uint_8 reg, pointer label ) /*******************************************************************/ { - ins_encoding = _Opcode( opcode ) | _A( reg ); + ins_encoding = _Opcode( opcode ) | _Ra( reg ); EmitInsReloc( &ins_encoding, label, OWL_RELOC_BRANCH_REL ); } @@ -543,17 +543,17 @@ static void addressTemp( name *temp, uint_8 *reg, int_16 *offset ) temp_offset = TempLocation( temp ); if( temp_offset > AXP_MAX_OFFSET ) { /* - * gen some code to load temp address into SCRATCH_REG + * gen some code to load temp address into scratch register */ - GenLOADS32( temp_offset, AXP_GPR_SCRATCH ); - GenOPINS( 0x10, 0x00, AXP_STACK_REG, AXP_GPR_SCRATCH, AXP_GPR_SCRATCH ); + GenLOADS32( temp_offset, AT_REG_IDX ); + GenOPINS( 0x10, 0x00, SP_REG_IDX, AT_REG_IDX, AT_REG_IDX ); *offset = 0; - *reg = AXP_GPR_SCRATCH; + *reg = AT_REG_IDX; } else { *offset = temp_offset; - *reg = AXP_STACK_REG; + *reg = SP_REG_IDX; if( CurrProc->targ.base_is_fp ) { - *reg = AXP_FRAME_REG; + *reg = FP_REG_IDX; } } } @@ -575,7 +575,7 @@ static void getMemEncoding( name *mem, uint_8 *reg_index, int_16 *offset ) break; case N_MEMORY: default: - *reg_index = AXP_ZERO_SINK; + *reg_index = ZERO_REG_IDX; *offset = 0; _Zoiks( ZOIKS_078 ); break; @@ -619,7 +619,7 @@ static void GenCallIndirect( instruction *call ) int_16 mem_offset; name *addr; - reg_index = AXP_GPR_SCRATCH; /* use the volatile scratch reg if possible */ + reg_index = AT_REG_IDX; /* use the volatile scratch reg if possible */ addr = call->operands[CALL_OP_ADDR]; switch( addr->n.class ) { case N_REGISTER: @@ -631,7 +631,7 @@ static void GenCallIndirect( instruction *call ) GenMEMINS( 0x28, reg_index, mem_index, mem_offset ); break; } - GenMEMINS( 0x1a, AXP_RETURN_ADDR, reg_index, 0x4000 ); + GenMEMINS( 0x1a, RA_REG_IDX, reg_index, 0x4000 ); } static void doChop( instruction *ins, type_class_def type_class ) @@ -672,7 +672,7 @@ static void doSignExtend( instruction *ins, type_class_def type_class ) from_size = TypeClassSize[type_class]; if( from_size == 4 ) { /* addl r31, src -> dst */ - GenOPINS( 0x10, 0x00, AXP_ZERO_SINK, src_index, res_index ); + GenOPINS( 0x10, 0x00, ZERO_REG_IDX, src_index, res_index ); } else { shift_amt = ( REG_SIZE - from_size ) * 8; /* shl */ @@ -712,13 +712,13 @@ static bool encodeThreadDataRef( instruction *ins ) * This is done in FixMemRefs. */ tls_index = RTLabel( RT_TLS_INDEX ); - GenMEMINSRELOC( 0x09, AXP_GPR_SCRATCH, AXP_ZERO_SINK, 0, + GenMEMINSRELOC( 0x09, AT_REG_IDX, ZERO_REG_IDX, 0, tls_index, OWL_RELOC_HALF_HI ); - GenMEMINSRELOC( 0x08, AXP_GPR_SCRATCH, AXP_GPR_SCRATCH, 0, + GenMEMINSRELOC( 0x08, AT_REG_IDX, AT_REG_IDX, 0, tls_index, OWL_RELOC_HALF_LO ); EmitIns( RDTEB_ENCODING ); GenMEMINS( loadOpcodes[I4], V0, V0, RDTEB_MAGIC_CONST ); - GenOPINS( 0x0010, 0x0002, AXP_GPR_SCRATCH, V0, V0 ); + GenOPINS( 0x0010, 0x0002, AT_REG_IDX, V0, V0 ); GenMEMINS( loadOpcodes[I4], V0, V0, 0 ); GenMEMINSRELOC( 0x08, _NameReg( ins->result ), V0, 0, symLabel( op ), OWL_RELOC_HALF_LO ); @@ -753,25 +753,25 @@ static void Encode( instruction *ins ) /* NEG Ra => Rb ...becomes... SUB R31,Ra => Rb */ switch( ins->type_class ) { case FS: - GenFPOPINS( 0x16, 0x81, AXP_ZERO_SINK, + GenFPOPINS( 0x16, 0x81, ZERO_REG_IDX, _NameReg( ins->operands[0] ), _NameReg( ins->result ) ); break; case FD: case FL: - GenFPOPINS( 0x16, 0xa1, AXP_ZERO_SINK, + GenFPOPINS( 0x16, 0xa1, ZERO_REG_IDX, _NameReg( ins->operands[0] ), _NameReg( ins->result ) ); break; default: - GenOPINS( 0x10, 0x09, AXP_ZERO_SINK, + GenOPINS( 0x10, 0x09, ZERO_REG_IDX, _NameReg( ins->operands[0] ), _NameReg( ins->result ) ); } break; case OP_COMPLEMENT: /* NOT Ra => Rb ...becomes... ORNOT R31,Ra => Rb */ - GenOPINS( 0x11, 0x28, AXP_ZERO_SINK, + GenOPINS( 0x11, 0x28, ZERO_REG_IDX, _NameReg( ins->operands[0] ), _NameReg( ins->result ) ); break; @@ -808,9 +808,9 @@ static void Encode( instruction *ins ) assert( ins->operands[0]->n.class == N_REGISTER ); assert( ins->result->n.class != N_REGISTER ); reg_index = _NameReg( ins->operands[0] ); - GenFPOPINS( 0x16, 0x2f, AXP_ZERO_SINK, reg_index, AXP_FLOAT_SCRATCH ); + GenFPOPINS( 0x16, 0x2f, ZERO_REG_IDX, reg_index, ATFP_REG_IDX ); getMemEncoding( ins->result, &mem_index, &mem_offset ); - GenMEMINS( 0x27, AXP_FLOAT_SCRATCH, mem_index, mem_offset ); + GenMEMINS( 0x27, ATFP_REG_IDX, mem_index, mem_offset ); break; case G_MI8TOFREG: assert( ins->operands[0]->n.class != N_REGISTER ); @@ -818,7 +818,7 @@ static void Encode( instruction *ins ) reg_index = _NameReg( ins->result ); getMemEncoding( ins->operands[0], &mem_index, &mem_offset ); GenMEMINS( 0x23, reg_index, mem_index, mem_offset ); - GenFPOPINS( 0x16, 0xbe, AXP_ZERO_SINK, reg_index, reg_index ); + GenFPOPINS( 0x16, 0xbe, ZERO_REG_IDX, reg_index, reg_index ); break; case G_BINARY_FP: assert( ins->operands[0]->n.class == N_REGISTER ); @@ -854,7 +854,7 @@ static void Encode( instruction *ins ) assert( ins->operands[0]->n.class == N_CONSTANT ); assert( ins->result->n.class == N_REGISTER ); GenOPIMM( 0x10, 0x00, - AXP_ZERO_SINK, (uint_8)ins->operands[0]->c.lo.int_value, + ZERO_REG_IDX, (uint_8)ins->operands[0]->c.lo.int_value, _NameReg( ins->result ) ); break; case G_MOVE: @@ -864,7 +864,7 @@ static void Encode( instruction *ins ) * generate a "BIS R31,Rn,Rm" instruction */ GenOPINS( 0x11, 0x20, - AXP_ZERO_SINK, _NameReg( ins->operands[0] ), + ZERO_REG_IDX, _NameReg( ins->operands[0] ), _NameReg( ins->result ) ); break; case G_ZAP: @@ -883,14 +883,14 @@ static void Encode( instruction *ins ) assert( ins->operands[0]->n.class == N_CONSTANT ); assert( ins->operands[0]->c.const_type == CONS_HIGH_ADDR ); assert( ins->result->n.class == N_REGISTER ); - GenMEMINS( 0x09, _NameReg( ins->result ), AXP_ZERO_SINK, ins->operands[0]->c.lo.int_value & 0xffff ); + GenMEMINS( 0x09, _NameReg( ins->result ), ZERO_REG_IDX, ins->operands[0]->c.lo.int_value & 0xffff ); break; case G_LEA: assert( ins->operands[0]->n.class == N_CONSTANT ); assert( ins->result->n.class == N_REGISTER ); switch( ins->operands[0]->c.const_type ) { case CONS_ABSOLUTE: - GenMEMINS( 0x08, _NameReg( ins->result ), AXP_ZERO_SINK, ins->operands[0]->c.lo.int_value ); + GenMEMINS( 0x08, _NameReg( ins->result ), ZERO_REG_IDX, ins->operands[0]->c.lo.int_value ); break; case CONS_LOW_ADDR: case CONS_HIGH_ADDR: @@ -915,7 +915,7 @@ static void Encode( instruction *ins ) _Zoiks( ZOIKS_132 ); } if( !encodeThreadDataRef( ins ) ) { - GenMEMINSRELOC( 0x09, _NameReg( ins->result ), AXP_ZERO_SINK, high, + GenMEMINSRELOC( 0x09, _NameReg( ins->result ), ZERO_REG_IDX, high, symLabel( ins->operands[0] ), OWL_RELOC_HALF_HI ); GenMEMINSRELOC( 0x08, _NameReg( ins->result ), _NameReg( ins->result ), low, symLabel( ins->operands[0] ), OWL_RELOC_HALF_LO ); diff --git a/bld/cg/risc/axp/c/axpenc2.c b/bld/cg/risc/axp/c/axpenc2.c index 7474c4d278..508ee5463a 100644 --- a/bld/cg/risc/axp/c/axpenc2.c +++ b/bld/cg/risc/axp/c/axpenc2.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -52,19 +52,19 @@ void EncodeRet( oc_ret *oc ) { static void doBranch( axp_ins opcode, pointer lbl, uint reg ) { - opcode = _Opcode( opcode ) | _A( reg ); + opcode = _Opcode( opcode ) | _Ra( reg ); OutReloc( lbl, OWL_RELOC_BRANCH_REL, 0 ); ObjBytes( &opcode, sizeof( opcode ) ); } void EncodeJump( oc_handle *oc ) { - doBranch( 0x30, oc->handle, AXP_ZERO_SINK ); + doBranch( 0x30, oc->handle, ZERO_REG_IDX ); } void EncodeCall( oc_handle *oc ) { - doBranch( 0x34, oc->handle, AXP_RETURN_ADDR ); + doBranch( 0x34, oc->handle, RA_REG_IDX ); } static uint_8 BranchOpcodes[][2] = { diff --git a/bld/cg/risc/axp/c/axpproc.c b/bld/cg/risc/axp/c/axpproc.c index 60e659644c..1148e52e6f 100644 --- a/bld/cg/risc/axp/c/axpproc.c +++ b/bld/cg/risc/axp/c/axpproc.c @@ -188,7 +188,7 @@ static void initSavedRegs( stack_record *saved_regs, type_length *offset ) static void genMove( uint_32 src, uint_32 dst ) /*************************************************/ { - GenOPINS( 0x11, 0x20, AXP_ZERO_SINK, src, dst ); + GenOPINS( 0x11, 0x20, ZERO_REG_IDX, src, dst ); } @@ -204,13 +204,13 @@ static uint_32 addressableRegion( stack_record *region, type_length *offset ) { if( region->start > AXP_MAX_OFFSET ) { *offset = 0; - GenLOADS32( region->start, AXP_GPR_SCRATCH ); + GenLOADS32( region->start, AT_REG_IDX ); // add sp, r28 -> r28 - GenOPINS( 0x10, 0x00, AXP_STACK_REG, AXP_GPR_SCRATCH, AXP_GPR_SCRATCH ); - return( AXP_GPR_SCRATCH ); + GenOPINS( 0x10, 0x00, SP_REG_IDX, AT_REG_IDX, AT_REG_IDX ); + return( AT_REG_IDX ); } else { *offset = region->start; - return( AXP_STACK_REG ); + return( SP_REG_IDX ); } } @@ -365,7 +365,7 @@ static void emitFrameSaveProlog( stack_record *fs ) if( fs->size != 0 ) { index_reg = addressableRegion( fs, &offset ); - saveReg( index_reg, AXP_FRAME_REG, offset, false ); + saveReg( index_reg, FP_REG_IDX, offset, false ); } } @@ -381,7 +381,7 @@ static void emitFrameSaveEpilog( stack_record *fs ) // varargs epilog above must be empty if( fs->size != 0 ) { index_reg = addressableRegion( fs, &offset ); - loadReg( index_reg, AXP_FRAME_REG, offset, false ); + loadReg( index_reg, FP_REG_IDX, offset, false ); } } @@ -455,9 +455,9 @@ static void SetupVarargsReg( stack_map *map ) } if( offset > AXP_MAX_OFFSET ) { GenLOADS32( offset, VARARGS_PTR ); - GenOPINS( 0x10, 0x00, AXP_STACK_REG, VARARGS_PTR, VARARGS_PTR ); + GenOPINS( 0x10, 0x00, SP_REG_IDX, VARARGS_PTR, VARARGS_PTR ); } else { - genLea( AXP_STACK_REG, offset, VARARGS_PTR ); + genLea( SP_REG_IDX, offset, VARARGS_PTR ); } } } @@ -471,17 +471,17 @@ static void emitProlog( stack_map *map ) frame_size = frameSize( map ); if( frame_size != 0 ) { if( frame_size <= AXP_MAX_OFFSET ) { - genLea( AXP_STACK_REG, -frame_size, AXP_STACK_REG ); + genLea( SP_REG_IDX, -frame_size, SP_REG_IDX ); } else { - GenLOADS32( frame_size, AXP_GPR_SCRATCH ); + GenLOADS32( frame_size, AT_REG_IDX ); // sub sp,r28 -> sp - GenOPINS( 0x10, 0x09, AXP_STACK_REG, AXP_GPR_SCRATCH, AXP_STACK_REG ); + GenOPINS( 0x10, 0x09, SP_REG_IDX, AT_REG_IDX, SP_REG_IDX ); } if( frame_size >= _TARGET_PAGE_SIZE ) { if( frame_size <= AXP_MAX_OFFSET ) { - genLea( AXP_ZERO_SINK, frame_size, RT_PARM1 ); + genLea( ZERO_REG_IDX, frame_size, RT_PARM1 ); } else { - genMove( AXP_GPR_SCRATCH, RT_PARM1 ); + genMove( AT_REG_IDX, RT_PARM1 ); } GenCallLabelReg( RTLabel( RT_STK_CRAWL_SIZE ), RT_RET_REG ); } @@ -493,7 +493,7 @@ static void emitProlog( stack_map *map ) if( size > AXP_MAX_OFFSET ) { GenLOADS32( size, RT_PARM1 ); } else { - genLea( AXP_ZERO_SINK, map->locals.size + map->parm_cache.size, RT_PARM1 ); + genLea( ZERO_REG_IDX, map->locals.size + map->parm_cache.size, RT_PARM1 ); } GenCallLabelReg( RTLabel( RT_STK_STOMP ), RT_RET_REG ); } @@ -505,7 +505,7 @@ static void emitProlog( stack_map *map ) emitLocalProlog( &map->locals ); emitParmCacheProlog( &map->parm_cache ); if( map->frame_save.size != 0 ) { - genMove( AXP_STACK_REG, AXP_FRAME_REG ); + genMove( SP_REG_IDX, FP_REG_IDX ); } } @@ -516,9 +516,9 @@ static void emitEpilog( stack_map *map ) type_length frame_size; if( map->frame_save.size != 0 ) { - // NB should just use AXP_FRAME_REG instead of AXP_STACK_REG in restore + // NB should just use FP_REG_IDX instead of SP_REG_IDX in restore // code and not bother emitting this instruction - genMove( AXP_FRAME_REG, AXP_STACK_REG ); + genMove( FP_REG_IDX, SP_REG_IDX ); } emitParmCacheEpilog( &map->parm_cache ); emitLocalEpilog( &map->locals ); @@ -529,10 +529,10 @@ static void emitEpilog( stack_map *map ) frame_size = frameSize( map ); if( frame_size != 0 ) { if( frame_size <= AXP_MAX_OFFSET ) { - genLea( AXP_STACK_REG, frame_size, AXP_STACK_REG ); + genLea( SP_REG_IDX, frame_size, SP_REG_IDX ); } else { - GenLOADS32( frame_size, AXP_GPR_SCRATCH ); - GenOPINS( 0x10, 0x00, AXP_STACK_REG, AXP_GPR_SCRATCH, AXP_STACK_REG ); + GenLOADS32( frame_size, AT_REG_IDX ); + GenOPINS( 0x10, 0x00, SP_REG_IDX, AT_REG_IDX, SP_REG_IDX ); } } } diff --git a/bld/cg/risc/mps/c/mpsenc.c b/bld/cg/risc/mps/c/mpsenc.c index c518da5c00..f893af444a 100644 --- a/bld/cg/risc/mps/c/mpsenc.c +++ b/bld/cg/risc/mps/c/mpsenc.c @@ -281,30 +281,31 @@ static void EmitIns( mips_ins ins ) } -void GenLOADS32( signed_32 value, uint_8 reg ) +void GenLOADS32( int_32 value, uint_8 reg ) /***************************************************** * Load a signed 32-bit constant 'value' into register 'reg' */ { - if( (value < 32768) && (value > -32769) ) { + if( (value < 32768) + && (value > -32769) ) { /* * Only need sign extended low 16 bits - 'addiu rt,$zero,value' */ - GenIType( 0x09, reg, MIPS_ZERO_SINK, (unsigned_16)value ); + GenIType( 0x09, reg, ZERO_REG_IDX, (int_16)value ); } else if( (value & 0xffff) == 0 ) { /* * Only need high 16 bits - 'lui rt,$zero,(value >> 16)' */ - GenIType( 0x0f, reg, MIPS_ZERO_SINK, (unsigned_16)(value >> 16) ); + GenIType( 0x0f, reg, ZERO_REG_IDX, (int_16)(value >> 16) ); } else { /* * Need two instructions - 'lui rt,$zero,(value >> 16)' */ - GenIType( 0x0f, reg, MIPS_ZERO_SINK, (unsigned_16)(value >> 16) ); + GenIType( 0x0f, reg, ZERO_REG_IDX, (int_16)(value >> 16) ); /* * followed by 'ori rt,$zero,(value & 0xffff)' */ - GenIType( 0x0d, reg, MIPS_ZERO_SINK, (unsigned_16)value ); + GenIType( 0x0d, reg, ZERO_REG_IDX, (int_16)value ); } } @@ -317,7 +318,8 @@ static uint_8 *FindOpcodes( instruction *ins ) uint_8 *opcodes; if( _OpIsBinary( ins->head.opcode ) ) { - if( ins->type_class == U8 || ins->type_class == I8 ) { + if( ins->type_class == U8 + || ins->type_class == I8 ) { opcodes = &BinaryOpcodes8[ins->head.opcode - FIRST_BINARY_OP][_IsSigned( ins->type_class ) ? 1 : 0][0]; } else { opcodes = &BinaryOpcodes4[ins->head.opcode - FIRST_BINARY_OP][_IsSigned( ins->type_class ) ? 1 : 0][0]; @@ -373,7 +375,9 @@ static uint_8 FindFloatingOpcodes( instruction *ins ) assert( _IsFloating( ins->type_class ) ); if( _OpIsBinary( ins->head.opcode ) ) { opcode = FloatingBinaryOpcodes[ins->head.opcode - FIRST_BINARY_OP]; - /* NB: this opcode may legitimately be zero - that's 'add' */ + /* + * NB: this opcode may legitimately be zero - that's 'add' + */ } else if( _OpIsSet( ins->head.opcode ) ) { opcode = FloatingSetOpcodes[ins->head.opcode - FIRST_SET_OP]; assert( opcode ); @@ -385,7 +389,7 @@ static uint_8 FindFloatingOpcodes( instruction *ins ) } -void GenMEMINSRELOC( uint_8 opcode, uint_8 rt, uint_8 rs, signed_16 displacement, pointer lbl, owl_reloc_type type ) +void GenMEMINSRELOC( uint_8 opcode, uint_8 rt, uint_8 rs, int_16 displacement, pointer lbl, owl_reloc_type type ) /**************************************************************************************************************************/ { ins_encoding = _Opcode( opcode ) | _Rt( rt ) | _Rs( rs ) | _SignedImmed( displacement ); @@ -393,7 +397,7 @@ void GenMEMINSRELOC( uint_8 opcode, uint_8 rt, uint_8 rs, signed_16 displacement } -void GenMEMINS( uint_8 opcode, uint_8 a, uint_8 b, signed_16 displacement ) +void GenMEMINS( uint_8 opcode, uint_8 a, uint_8 b, int_16 displacement ) /*********************************************************************************/ { ins_encoding = _Opcode( opcode ) | _Rt( a ) | _Rs( b ) | _SignedImmed( displacement ); @@ -401,10 +405,10 @@ void GenMEMINS( uint_8 opcode, uint_8 a, uint_8 b, signed_16 displacement ) } -void GenIType( uint_8 opcode, uint_8 rt, uint_8 rs, signed_16 immed ) +void GenIType( uint_8 opcode, uint_8 rt, uint_8 rs, int_16 immed ) /***************************************************************************/ { - ins_encoding = _Opcode( opcode ) | _Rs( rs ) | _Rt( rt ) | _Immed( immed ); + ins_encoding = _Opcode( opcode ) | _Rs( rs ) | _Rt( rt ) | _SignedImmed( immed ); EmitIns( ins_encoding ); } @@ -446,13 +450,13 @@ static void GenFloatRType( type_class_def type_class, uint_8 fnc, uint_8 fd, ui */ if( type_class == FS ) { fmt = 0x10; - } else if( type_class == FD || type_class == FL ) { + } else if( type_class == FD + || type_class == FL ) { fmt = 0x11; } else { fmt = 0; assert( 0 ); } - /* * Opcode is always COP1 */ @@ -511,15 +515,14 @@ void GenCallLabelReg( pointer label, uint reg ) * Load address into $at (lui/addiu) * TODO: This should be different for PIC */ - GenMEMINSRELOC( 0x0f, MIPS_GPR_SCRATCH, MIPS_ZERO_SINK, 0, + GenMEMINSRELOC( 0x0f, AT_REG_IDX, ZERO_REG_IDX, 0, label, OWL_RELOC_HALF_HI ); - GenMEMINSRELOC( 0x09, MIPS_GPR_SCRATCH, MIPS_GPR_SCRATCH, 0, + GenMEMINSRELOC( 0x09, AT_REG_IDX, AT_REG_IDX, 0, label, OWL_RELOC_HALF_LO ); - /* * 'jalr reg,$at' */ - GenRType( 0x00, 0x09, reg, MIPS_GPR_SCRATCH, 0 ); + GenRType( 0x00, 0x09, reg, AT_REG_IDX, 0 ); /* * WARNING! WARNING! WARNING! * There's no delay slot here. Caller must handle that. @@ -589,18 +592,18 @@ static void addressTemp( name *temp, uint_8 *reg, int_16 *offset ) /* * gen some code to load temp address into SCRATCH_REG */ - GenLOADS32( temp_offset, MIPS_GPR_SCRATCH ); + GenLOADS32( temp_offset, AT_REG_IDX ); /* * 'or $sp,$at,$zero', aka 'move $sp,$at' */ - GenRType( 0x00, 0x25, MIPS_STACK_REG, MIPS_GPR_SCRATCH, MIPS_ZERO_SINK ); + GenRType( 0x00, 0x25, SP_REG_IDX, AT_REG_IDX, ZERO_REG_IDX ); *offset = 0; - *reg = MIPS_GPR_SCRATCH; + *reg = AT_REG_IDX; } else { *offset = temp_offset; - *reg = MIPS_STACK_REG; + *reg = SP_REG_IDX; if( CurrProc->targ.base_is_fp ) { - *reg = MIPS_FRAME_REG; + *reg = FP_REG_IDX; } } } @@ -613,7 +616,7 @@ static void getMemEncoding( name *mem, uint_8 *reg_index, int_16 *offset ) case N_INDEXED: assert( mem->i.index->n.class == N_REGISTER ); assert( mem->i.scale == 0 ); - assert( mem->i.constant == (type_length)((signed_16)mem->i.constant) ); + assert( mem->i.constant == (type_length)((int_16)mem->i.constant) ); assert( ( mem->i.index_flags & X_LOW_ADDR_BASE ) == 0 ); *reg_index = _NameReg( mem->i.index ); *offset = (int_16)mem->i.constant; @@ -623,7 +626,7 @@ static void getMemEncoding( name *mem, uint_8 *reg_index, int_16 *offset ) break; case N_MEMORY: default: - *reg_index = MIPS_ZERO_SINK; + *reg_index = ZERO_REG_IDX; *offset = 0; _Zoiks( ZOIKS_078 ); break; @@ -702,7 +705,7 @@ static void GenCallIndirect( instruction *call ) int_16 mem_offset; name *addr; - reg_index = MIPS_GPR_SCRATCH; /* use the volatile scratch reg if possible */ + reg_index = AT_REG_IDX; /* use the volatile scratch reg if possible */ addr = call->operands[CALL_OP_ADDR]; switch( addr->n.class ) { case N_REGISTER: @@ -717,7 +720,7 @@ static void GenCallIndirect( instruction *call ) /* * 'jalr ra,reg_index' */ - GenRType( 0x00, 0x09, MIPS_RETURN_ADDR, reg_index, 0 ); + GenRType( 0x00, 0x09, RA_REG_IDX, reg_index, 0 ); /* * TODO: Handle delay slot better */ @@ -742,7 +745,7 @@ static void doZero( instruction *ins, type_class_def type_class ) /* * 'andi res,op1,0xffff' */ - GenIType( 0x0c, _NameReg( ins->result ), _NameReg( ins->operands[0] ), (signed_16)0x0ffff ); + GenIType( 0x0c, _NameReg( ins->result ), _NameReg( ins->operands[0] ), (int_16)0x0ffff ); break; default: _Zoiks( ZOIKS_091 ); @@ -765,7 +768,7 @@ static void doSignExtend( instruction *ins, type_class_def type_class ) /* * 'addu rd,$zero,rs' - MIPS64 only? */ - GenRType( 0x00, 0x21, res_index, MIPS_ZERO_SINK, src_index ); + GenRType( 0x00, 0x21, res_index, ZERO_REG_IDX, src_index ); } else { /* * MIPS32 ISA Release 2 has 'seb'/'seh' instructions for this @@ -818,13 +821,13 @@ static bool encodeThreadDataRef( instruction *ins ) */ // tls_index = RTLabel( RT_TLS_INDEX ); #if 0 - GenMEMINSRELOC( 0x09, MIPS_GPR_SCRATCH, MIPS_ZERO_SINK, 0, + GenMEMINSRELOC( 0x09, AT_REG_IDX, ZERO_REG_IDX, 0, tls_index, OWL_RELOC_HALF_HI ); - GenMEMINSRELOC( 0x08, MIPS_GPR_SCRATCH, MIPS_GPR_SCRATCH, 0, + GenMEMINSRELOC( 0x08, AT_REG_IDX, AT_REG_IDX, 0, tls_index, OWL_RELOC_HALF_LO ); EmitIns( RDTEB_ENCODING ); GenMEMINS( loadOpcodes[I4], V0, V0, RDTEB_MAGIC_CONST ); - GenOPINS( 0x0010, 0x0002, MIPS_GPR_SCRATCH, V0, V0 ); + GenOPINS( 0x0010, 0x0002, AT_REG_IDX, V0, V0 ); GenMEMINS( loadOpcodes[I4], V0, V0, 0 ); GenMEMINSRELOC( 0x08, _NameReg( ins->result ), V0, 0, symLabel( op ), OWL_RELOC_HALF_LO ); @@ -838,16 +841,16 @@ static bool encodeThreadDataRef( instruction *ins ) static void Encode( instruction *ins ) /*************************************/ { - uint_8 *opcodes; - uint_8 opcode; - uint_16 function; - uint_8 reg_index; - uint_8 mem_index; - int_16 mem_offset; - signed_16 high; - signed_16 extra; - signed_16 low; - signed_16 imm_value; + uint_8 *opcodes; + uint_8 opcode; + uint_16 function; + uint_8 reg_index; + uint_8 mem_index; + int_16 mem_offset; + int_16 high; + int_16 extra; + int_16 low; + int_16 imm_value; switch( G( ins ) ) { case G_CALL: @@ -875,14 +878,14 @@ static void Encode( instruction *ins ) /* * 'subu rd,$zero,rs' */ - GenRType( 0x00, 0x23, _NameReg( ins->result ), MIPS_ZERO_SINK, _NameReg( ins->operands[0] ) ); + GenRType( 0x00, 0x23, _NameReg( ins->result ), ZERO_REG_IDX, _NameReg( ins->operands[0] ) ); } break; case OP_COMPLEMENT: /* * 'nor rd,$zero,rs' */ - GenRType( 0x00, 0x27, _NameReg( ins->result ), MIPS_ZERO_SINK, _NameReg( ins->operands[0] ) ); + GenRType( 0x00, 0x27, _NameReg( ins->result ), ZERO_REG_IDX, _NameReg( ins->operands[0] ) ); break; default: _Zoiks( ZOIKS_028 ); @@ -1038,7 +1041,7 @@ static void Encode( instruction *ins ) /* * 'addiu rt,$zero,immed' */ - GenIType( 0x09, _NameReg( ins->result ), MIPS_ZERO_SINK, (uint_8)ins->operands[0]->c.lo.int_value ); + GenIType( 0x09, _NameReg( ins->result ), ZERO_REG_IDX, (uint_8)ins->operands[0]->c.lo.int_value ); break; case G_MOVE: assert( ins->operands[0]->n.class == N_REGISTER ); @@ -1046,13 +1049,13 @@ static void Encode( instruction *ins ) /* * 'or rd,rs,$zero' */ - GenRType( 0x00, 0x25, _NameReg( ins->result ), _NameReg( ins->operands[0] ), MIPS_ZERO_SINK ); + GenRType( 0x00, 0x25, _NameReg( ins->result ), _NameReg( ins->operands[0] ), ZERO_REG_IDX ); if( TypeClassSize[ins->type_class] == 8 ) { /* * Move the odd register, too * TODO: there should probably be a separate G_MOVE8? */ - GenRType( 0x00, 0x25, _NameReg( ins->result ) + 1, _NameReg( ins->operands[0] ) + 1, MIPS_ZERO_SINK ); + GenRType( 0x00, 0x25, _NameReg( ins->result ) + 1, _NameReg( ins->operands[0] ) + 1, ZERO_REG_IDX ); } break; case G_LEA_HIGH: @@ -1062,7 +1065,7 @@ static void Encode( instruction *ins ) /* * 'lui rt,immed' */ - GenIType( 0x0f, _NameReg( ins->result ), MIPS_ZERO_SINK, ins->operands[0]->c.lo.int_value & 0xffff ); + GenIType( 0x0f, _NameReg( ins->result ), ZERO_REG_IDX, ins->operands[0]->c.lo.int_value & 0xffff ); break; case G_LEA: assert( ins->operands[0]->n.class == N_CONSTANT ); @@ -1072,7 +1075,7 @@ static void Encode( instruction *ins ) /* * 'addiu rt,$zero,immed' */ - GenIType( 0x09, _NameReg( ins->result ), MIPS_ZERO_SINK, ins->operands[0]->c.lo.int_value ); + GenIType( 0x09, _NameReg( ins->result ), ZERO_REG_IDX, ins->operands[0]->c.lo.int_value ); break; case CONS_LOW_ADDR: case CONS_HIGH_ADDR: @@ -1103,7 +1106,7 @@ static void Encode( instruction *ins ) /* * 'lui rt,immed' */ - GenMEMINSRELOC( 0x0f, _NameReg( ins->result ), MIPS_ZERO_SINK, high, symLabel( ins->operands[0] ), OWL_RELOC_HALF_HI ); + GenMEMINSRELOC( 0x0f, _NameReg( ins->result ), ZERO_REG_IDX, high, symLabel( ins->operands[0] ), OWL_RELOC_HALF_HI ); /* * 'addiu rt,rs,immed' */ @@ -1119,7 +1122,7 @@ static void Encode( instruction *ins ) * a load of an unsigned 16-bit immediate * 'ori rt,rs,immed' */ - GenIType( 0x0d, _NameReg( ins->result ), MIPS_ZERO_SINK, ins->operands[0]->c.lo.int_value ); + GenIType( 0x0d, _NameReg( ins->result ), ZERO_REG_IDX, ins->operands[0]->c.lo.int_value ); break; case G_LOAD_UA: doLoadStoreUnaligned( ins, true ); diff --git a/bld/cg/risc/mps/c/mpsenc2.c b/bld/cg/risc/mps/c/mpsenc2.c index 9119291914..f7eb264036 100644 --- a/bld/cg/risc/mps/c/mpsenc2.c +++ b/bld/cg/risc/mps/c/mpsenc2.c @@ -46,10 +46,14 @@ void EncodeRet( oc_ret *oc ) /* unused parameters */ (void)oc; - // 'jr ra' - encoding = _Opcode( 0 ) | _Rs( MIPS_RETURN_ADDR ) | _Function( 0x08 ); + /* + * 'jr ra' + */ + encoding = _Opcode( 0 ) | _Rs( RA_REG_IDX ) | _Function( 0x08 ); ObjBytes( &encoding, sizeof( encoding ) ); - // TODO: Handle delay slot better + /* + * TODO: Handle delay slot better + */ encoding = MIPS_NOP; ObjBytes( &encoding, sizeof( encoding ) ); } @@ -61,7 +65,9 @@ static void doBranch( mips_ins opcode, uint_8 cc, pointer lbl, uint reg1, uint r opcode = _Opcode( opcode ) | _Rs( reg1 ) | _Rt( reg2 ) | _Rt( cc ); OutReloc( lbl, OWL_RELOC_BRANCH_REL, 0 ); ObjBytes( &opcode, sizeof( opcode ) ); - // TODO: Handle delay slot better + /* + * TODO: Handle delay slot better + */ opcode = MIPS_NOP; ObjBytes( &opcode, sizeof( opcode ) ); } @@ -72,15 +78,19 @@ static void doCopBranch( mips_ins opcode, uint_8 cc, pointer lbl ) { mips_ins nop_code; - // TODO: This is lame - there must be at least one instruction - // between a FP comparison instruction and a branch testing the result + /* + * TODO: This is lame - there must be at least one instruction + * between a FP comparison instruction and a branch testing the result + */ nop_code = MIPS_NOP; ObjBytes( &nop_code, sizeof( nop_code ) ); opcode = _Opcode( 0x11 ) | _Rs( opcode ) | _Rt( cc ); OutReloc( lbl, OWL_RELOC_BRANCH_REL, 0 ); ObjBytes( &opcode, sizeof( opcode ) ); - // TODO: Handle delay slot better + /* + * TODO: Handle delay slot better + */ opcode = MIPS_NOP; ObjBytes( &opcode, sizeof( opcode ) ); } @@ -89,8 +99,10 @@ static void doCopBranch( mips_ins opcode, uint_8 cc, pointer lbl ) void EncodeJump( oc_handle *oc ) /******************************/ { - // 'beq $zero,$zero,displacement' - doBranch( 0x04, 0x00, oc->handle, MIPS_ZERO_SINK, MIPS_ZERO_SINK ); + /* + * 'beq $zero,$zero,displacement' + */ + doBranch( 0x04, 0x00, oc->handle, ZERO_REG_IDX, ZERO_REG_IDX ); } @@ -99,13 +111,17 @@ void EncodeCall( oc_handle *oc ) { mips_ins encoding; - // TODO: PIC call - // Call to absolute address - // 'jal target' + /* + * TODO: PIC call + * Call to absolute address + * 'jal target' + */ encoding = _Opcode( 0x03 ); OutReloc( oc->handle, OWL_RELOC_JUMP_ABS, 0 ); ObjBytes( &encoding, sizeof( encoding ) ); - // TODO: Handle delay slot better + /* + * TODO: Handle delay slot better + */ encoding = MIPS_NOP; ObjBytes( &encoding, sizeof( encoding ) ); } @@ -135,14 +151,18 @@ void EncodeCond( oc_jcond *oc ) reg2 = oc->index2 == -1 ? 0 : oc->index2; opcode = BranchOpcodes[oc->cond - FIRST_COMPARISON][floating][0]; cncode = BranchOpcodes[oc->cond - FIRST_COMPARISON][floating][1]; - // Floating conditionals are quite different - we only have bc1f/bc1t - // but have a full set of comparison instructions + /* + * Floating conditionals are quite different - we only have bc1f/bc1t + * but have a full set of comparison instructions + */ if( floating ) { doCopBranch( opcode, cncode, oc->handle ); } else { if( (oc->cond != OP_CMP_EQUAL) && (oc->cond != OP_CMP_NOT_EQUAL) ) { - // Only beq/bne can do reg/reg comparisons - assert( reg2 == MIPS_ZERO_SINK ); + /* + * Only beq/bne can do reg/reg comparisons + */ + assert( reg2 == ZERO_REG_IDX ); } assert( opcode ); doBranch( opcode, cncode, oc->handle, oc->index, reg2 ); diff --git a/bld/cg/risc/mps/c/mpsproc.c b/bld/cg/risc/mps/c/mpsproc.c index cd12c0aa8f..063f13a710 100644 --- a/bld/cg/risc/mps/c/mpsproc.c +++ b/bld/cg/risc/mps/c/mpsproc.c @@ -70,15 +70,18 @@ static void calcUsedRegs( void ) } for( ins = blk->ins.head.next; ins->head.opcode != OP_BLOCK; ins = ins->head.next ) { result = ins->result; - if( result != NULL && result->n.class == N_REGISTER ) { + if( result != NULL + && result->n.class == N_REGISTER ) { HW_TurnOn( used, result->r.reg ); } - /* place holder for big label doesn't really zap anything*/ + /* + * place holder for big label doesn't really zap anything + */ if( ins->head.opcode != OP_NOP ) { HW_TurnOn( used, ins->zap->reg ); } - if( ins->head.opcode == OP_CALL || - ins->head.opcode == OP_CALL_INDIRECT ) { + if( ins->head.opcode == OP_CALL + || ins->head.opcode == OP_CALL_INDIRECT ) { CurrProc->targ.leaf = false; } } @@ -100,7 +103,8 @@ static void initParmCache( stack_record *pc, type_length *offset ) { pc->start = *offset; pc->size = MaxStack; - /* If we're calling any functions, we must allocate stack even for + /* + * If we're calling any functions, we must allocate stack even for * arguments passed in registers (so that callee has space for their home * locations if needed). For leaf functions, this is not needed; leaf * functions are the only ones allowed not to have a stack frame anyway. @@ -201,12 +205,14 @@ static void initSavedRegs( stack_record *saved_regs, type_length *offset ) static void genMove( uint_32 src, uint_32 dst ) /**********************************************/ { - // 'or rd,$zero,rt' - GenRType( 0x00, 0x25, dst, MIPS_ZERO_SINK, src ); + /* + * 'or rd,$zero,rt' + */ + GenRType( 0x00, 0x25, dst, ZERO_REG_IDX, src ); } -static void genLoadImm( uint_32 src, signed_16 disp, uint_32 dst ) +static void genLoadImm( uint_32 src, int_16 disp, uint_32 dst ) /******************************************************************/ { GenIType( ADDIU_OPCODE, dst, src, disp ); @@ -225,13 +231,15 @@ static uint_32 addressableRegion( stack_record *region, type_length *offset ) { if( region->start > MIPS_MAX_OFFSET ) { *offset = 0; - GenLOADS32( region->start, MIPS_GPR_SCRATCH ); - // 'add a0,a0,sp' - GenRType( 0x00, 0x21, MIPS_STACK_REG, MIPS_GPR_SCRATCH, MIPS_GPR_SCRATCH ); - return( MIPS_GPR_SCRATCH ); + GenLOADS32( region->start, AT_REG_IDX ); + /* + * 'add a0,a0,sp' + */ + GenRType( 0x00, 0x21, SP_REG_IDX, AT_REG_IDX, AT_REG_IDX ); + return( AT_REG_IDX ); } else { *offset = region->start; - return( MIPS_STACK_REG ); + return( SP_REG_IDX ); } } @@ -353,7 +361,9 @@ static void emitVarargsProlog( stack_record *varargs ) if( varargs->size != 0 ) { index_reg = addressableRegion( varargs, &offset ); offset += varargs->size; - // four registers starting at $4 (ie. $a0-$a3) + /* + * four registers starting at $4 (ie. $a0-$a3) + */ saveRegSet( index_reg, 0x0f << 4, offset, false ); // offset -= 6 * REG_SIZE; // saveRegSet( index_reg, 0x3f << 16, offset, true ); @@ -362,9 +372,10 @@ static void emitVarargsProlog( stack_record *varargs ) static void emitVarargsEpilog( stack_record *varargs ) -/*****************************************************/ +/****************************************************** + * NB see FrameSaveEpilog below + */ { - // NB see FrameSaveEpilog below /* unused parameters */ (void)varargs; } @@ -389,7 +400,7 @@ static void emitFrameSaveProlog( stack_record *fs ) if( fs->size != 0 ) { index_reg = addressableRegion( fs, &offset ); - saveReg( index_reg, MIPS_FRAME_REG, offset, false ); + saveReg( index_reg, FP_REG_IDX, offset, false ); } } @@ -400,12 +411,14 @@ static void emitFrameSaveEpilog( stack_record *fs ) uint_32 index_reg; type_length offset; - // NB This instruction must immediately preceed the - // stack restoration instruction - which means that the - // varargs epilog above must be empty + /* + * NB This instruction must immediately preceed the + * stack restoration instruction - which means that the + * varargs epilog above must be empty + */ if( fs->size != 0 ) { index_reg = addressableRegion( fs, &offset ); - loadReg( index_reg, MIPS_FRAME_REG, offset, false ); + loadReg( index_reg, FP_REG_IDX, offset, false ); } } @@ -439,10 +452,10 @@ static void emitSlopEpilog( stack_record *fs ) } -static signed_32 frameSize( stack_map *map ) -/*******************************************/ +static int_32 frameSize( stack_map *map ) +/****************************************/ { - signed_32 size; + int_32 size; size = map->slop.size + /*map->varargs.size + */map->frame_save.size + map->saved_regs.size + map->locals.size + map->parm_cache.size; @@ -473,16 +486,20 @@ static void SetupVarargsReg( stack_map *map ) type_length offset; offset = map->varargs.start; - // Skip hidden parameter in first register + /* + * Skip hidden parameter in first register + */ if( CurrProc->targ.return_points != NULL ) { offset += REG_SIZE; } if( offset > MIPS_MAX_OFFSET ) { GenLOADS32( offset, VARARGS_PTR ); - // 'add va_home,va_home,sp' - GenRType( 0x00, 0x21, MIPS_STACK_REG, VARARGS_PTR, VARARGS_PTR ); + /* + * 'add va_home,va_home,sp' + */ + GenRType( 0x00, 0x21, SP_REG_IDX, VARARGS_PTR, VARARGS_PTR ); } else { - genLoadImm( MIPS_STACK_REG, offset, VARARGS_PTR ); + genLoadImm( SP_REG_IDX, offset, VARARGS_PTR ); } } } @@ -496,23 +513,28 @@ static void emitProlog( stack_map *map ) frame_size = frameSize( map ); if( frame_size != 0 ) { if( frame_size <= MIPS_MAX_OFFSET ) { - genLoadImm( MIPS_STACK_REG, -frame_size, MIPS_STACK_REG ); + genLoadImm( SP_REG_IDX, -frame_size, SP_REG_IDX ); } else { - GenLOADS32( frame_size, MIPS_GPR_SCRATCH ); - // 'subu sp,sp,at' - GenRType( 0x00, 0x23, MIPS_STACK_REG, MIPS_STACK_REG, MIPS_GPR_SCRATCH ); + GenLOADS32( frame_size, AT_REG_IDX ); + /* + * 'subu sp,sp,at' + */ + GenRType( 0x00, 0x23, SP_REG_IDX, SP_REG_IDX, AT_REG_IDX ); } if( frame_size >= _TARGET_PAGE_SIZE ) { GenCallLabelReg( RTLabel( RT_STK_CRAWL_SIZE ), RT_RET_REG ); - // Next instruction will be in delay slot! + /* + * Next instruction will be in delay slot! + */ if( frame_size <= MIPS_MAX_OFFSET ) { - genLoadImm( MIPS_ZERO_SINK, frame_size, RT_PARM1 ); + genLoadImm( ZERO_REG_IDX, frame_size, RT_PARM1 ); } else { - genMove( MIPS_GPR_SCRATCH, RT_PARM1 ); + genMove( AT_REG_IDX, RT_PARM1 ); } } } - if( map->locals.size != 0 || map->parm_cache.size != 0 ) { + if( map->locals.size != 0 + || map->parm_cache.size != 0 ) { if( _IsTargetModel( CGSW_RISC_STACK_INIT ) ) { type_length size; @@ -523,8 +545,10 @@ static void emitProlog( stack_map *map ) genNOP(); // could split LOADS32 call to fill in delay slot... } else { GenCallLabelReg( RTLabel( RT_STK_STOMP ), RT_RET_REG ); - // Next instruction will be in delay slot! - genLoadImm( MIPS_ZERO_SINK, map->locals.size + map->parm_cache.size, RT_PARM1 ); + /* + * Next instruction will be in delay slot! + */ + genLoadImm( ZERO_REG_IDX, map->locals.size + map->parm_cache.size, RT_PARM1 ); } } } @@ -535,7 +559,7 @@ static void emitProlog( stack_map *map ) emitLocalProlog( &map->locals ); emitParmCacheProlog( &map->parm_cache ); if( map->frame_save.size != 0 ) { - genMove( MIPS_STACK_REG, MIPS_FRAME_REG ); + genMove( SP_REG_IDX, FP_REG_IDX ); } } @@ -545,9 +569,11 @@ static void emitEpilog( stack_map *map ) type_length frame_size; if( map->frame_save.size != 0 ) { - // NB should just use MIPS_FRAME_REG instead of MIPS_STACK_REG in restore - // code and not bother emitting this instruction - genMove( MIPS_FRAME_REG, MIPS_STACK_REG ); + /* + * NB should just use FP_REG_IDX instead of SP_REG_IDX in restore + * code and not bother emitting this instruction + */ + genMove( FP_REG_IDX, SP_REG_IDX ); } emitParmCacheEpilog( &map->parm_cache ); emitLocalEpilog( &map->locals ); @@ -558,11 +584,13 @@ static void emitEpilog( stack_map *map ) frame_size = frameSize( map ); if( frame_size != 0 ) { if( frame_size <= MIPS_MAX_OFFSET ) { - genLoadImm( MIPS_STACK_REG, frame_size, MIPS_STACK_REG ); + genLoadImm( SP_REG_IDX, frame_size, SP_REG_IDX ); } else { - GenLOADS32( frame_size, MIPS_GPR_SCRATCH ); - // 'addu sp,sp,at' - GenRType( 0x00, 0x21, MIPS_STACK_REG, MIPS_STACK_REG, MIPS_GPR_SCRATCH ); + GenLOADS32( frame_size, AT_REG_IDX ); + /* + * 'addu sp,sp,at' + */ + GenRType( 0x00, 0x21, SP_REG_IDX, SP_REG_IDX, AT_REG_IDX ); } } } @@ -583,10 +611,12 @@ void GenProlog( void ) TellProcLabel( label ); CodeLabelLinenum( label, DepthAlign( PROC_ALIGN ), HeadBlock->ins.head.line_num ); if( _IsModel( CGSW_GEN_DBG_LOCALS ) ) { // d1+ or d2 - // DbgRtnBeg( CurrProc->targ.debug, lc ); +// DbgRtnBeg( CurrProc->targ.debug, lc ); EmitRtnBeg( /*label, HeadBlock->ins.head.line_num*/ ); } - // keep stack aligned + /* + * keep stack aligned + */ CurrProc->locals.size = _RoundUp( CurrProc->locals.size, REG_SIZE ); CurrProc->parms.base = 0; CurrProc->parms.size = CurrProc->state.parm.offset; diff --git a/bld/cg/risc/ppc/c/ppcenc.c b/bld/cg/risc/ppc/c/ppcenc.c index 1cdb50fb3e..779338b9f4 100644 --- a/bld/cg/risc/ppc/c/ppcenc.c +++ b/bld/cg/risc/ppc/c/ppcenc.c @@ -181,8 +181,10 @@ static gen_opcode storeOpcodes[] = { }; static gen_opcode BranchOpcodes[][2] = { - // page 3-68 for a real description - // BO BI + /* + * page 3-68 for a real description + * BO BI + */ { NORMAL, EQ }, /* OP_CMP_EQUAL */ { INVERT, EQ }, /* OP_CMP_NOT_EQUAL */ { NORMAL, GT }, /* OP_CMP_GREATER */ @@ -218,7 +220,9 @@ void EmitInsReloc( void *ins, pointer sym, owl_reloc_type type ) /**************************************************************/ { #if 0 - // copy & paste from AXP cg + /* + * copy & paste from AXP cg + */ any_oc oc; oc.oc_rins.op.class = OC_RCODE; @@ -265,7 +269,7 @@ static gen_opcode *FindImmedOpcodes( instruction *ins ) static void GenFPOPINS( gen_opcode op1, gen_opcode op2, reg_idx a, reg_idx c, reg_idx d ) //****************************************************************************************** { - ins_encoding = _Op1( op1 ) | _A( a ) | _C( c ) | _D( d ) | _Op2( op2 ); + ins_encoding = _Opcode( op1 ) | _A( a ) | _C( c ) | _D( d ) | _Opcode2( op2 ); _EmitIns( ins_encoding ); } @@ -273,7 +277,7 @@ static void GenFPOPINS( gen_opcode op1, gen_opcode op2, reg_idx a, reg_idx c, void GenOPINS( gen_opcode op1, gen_opcode op2, reg_idx a, reg_idx b, reg_idx s ) //********************************************************************************* { - ins_encoding = _Op1( op1 ) | _A( a ) | _B( b ) | _S( s ) | _Op2( op2 ); + ins_encoding = _Opcode( op1 ) | _A( a ) | _B( b ) | _S( s ) | _Opcode2( op2 ); _EmitIns( ins_encoding ); } @@ -281,7 +285,7 @@ void GenOPINS( gen_opcode op1, gen_opcode op2, reg_idx a, reg_idx b, reg_idx void GenOPIMM( gen_opcode op1, reg_idx d, reg_idx a, signed_16 immed ) //*********************************************************************** { - ins_encoding = _Op1( op1 ) | _D( d ) | _A( a ) | _SignedImmed( immed ); + ins_encoding = _Opcode( op1 ) | _D( d ) | _A( a ) | _SignedImmed( immed ); _EmitIns( ins_encoding ); } @@ -289,9 +293,9 @@ void GenOPIMM( gen_opcode op1, reg_idx d, reg_idx a, signed_16 immed ) void GenMTSPR( reg_idx d, uint_32 spr, bool from ) //*************************************************** { - ins_encoding = _Op1( 31 ) | _Op2( 467 ); + ins_encoding = _Opcode( 31 ) | _Opcode2( 467 ); if( from ) { - ins_encoding = _Op1( 31 ) | _Op2( 339 ); + ins_encoding = _Opcode( 31 ) | _Opcode2( 339 ); } ins_encoding |= _D( d ) | _SPR( spr ); _EmitIns( ins_encoding ); @@ -301,7 +305,7 @@ void GenMTSPR( reg_idx d, uint_32 spr, bool from ) void GenMEMINS( gen_opcode op, reg_idx d, reg_idx i, signed_16 displacement ) /******************************************************************************/ { - ins_encoding = _Op1( op ) | _D( d ) | _A( i ) | _SignedImmed( displacement ); + ins_encoding = _Opcode( op ) | _D( d ) | _A( i ) | _SignedImmed( displacement ); _EmitIns( ins_encoding ); } @@ -312,7 +316,7 @@ static void GenBRANCH( gen_opcode op, pointer label, bool link, bool absolute int_32 loc; loc = AskLocation(); - ins_encoding = _Op1( op ) | _AA( absolute ) | _LK( link ) | _BranchImmed( -loc ); + ins_encoding = _Opcode( op ) | __AA( absolute ) | __LK( link ) | _BranchImmed( -loc ); OutReloc( label, PPC_RELOC_BRANCH, 0 ); _EmitIns( ins_encoding ); } @@ -321,7 +325,7 @@ static void GenBRANCH( gen_opcode op, pointer label, bool link, bool absolute static void GenCONDBR( gen_opcode op, gen_opcode bo, gen_opcode bi, pointer label ) /************************************************************************************/ { - ins_encoding = _Op1( op ) | _S( bo ) | _A( bi ); + ins_encoding = _Opcode( op ) | _S( bo ) | _A( bi ); OutReloc( label, PPC_RELOC_BRANCH_COND, 0 ); _EmitIns( ins_encoding ); } @@ -330,7 +334,7 @@ static void GenCONDBR( gen_opcode op, gen_opcode bo, gen_opcode bi, pointer l static void GenCMP( gen_opcode op, gen_opcode op2, reg_idx a, reg_idx b ) /**************************************************************************/ { - ins_encoding = _Op1( op ) | _A( a ) | _B( b ) | _Op2( op2 ); + ins_encoding = _Opcode( op ) | _A( a ) | _B( b ) | _Opcode2( op2 ); _EmitIns( ins_encoding ); } @@ -338,7 +342,7 @@ static void GenCMP( gen_opcode op, gen_opcode op2, reg_idx a, reg_idx b ) static void GenCMPIMM( gen_opcode op, reg_idx a, signed_16 imm ) /*****************************************************************/ { - ins_encoding = _Op1( op ) | _A( a ) | _SignedImmed( imm ); + ins_encoding = _Opcode( op ) | _A( a ) | _SignedImmed( imm ); _EmitIns( ins_encoding ); } @@ -476,12 +480,16 @@ static void doSign( instruction *ins ) switch( ins->base_type_class ) { case U1: case I1: - // extsb + /* + * extsb + */ GenOPINS( 31, 954, _NameReg( ins->result ), 0, _NameReg( ins->operands[0] ) ); break; case U2: case I2: - // extsh + /* + * extsh + */ GenOPINS( 31, 922, _NameReg( ins->result ), 0, _NameReg( ins->operands[0] ) ); break; default: @@ -496,12 +504,16 @@ static void doZero( instruction *ins ) switch( ins->base_type_class ) { case U1: case I1: - // andi op1,0x00ff -> res + /* + * andi op1,0x00ff -> res + */ GenOPIMM( 28, _NameReg( ins->operands[0] ), _NameReg( ins->result ), 0x00ff ); break; case U2: case I2: - // andi op1,0xffff -> res + /* + * andi op1,0xffff -> res + */ GenOPIMM( 28, _NameReg( ins->operands[0] ), _NameReg( ins->result ), (signed_16)0xffff ); break; default: @@ -696,7 +708,8 @@ static void Encode( instruction *ins ) a = _NameReg( ins->operands[0] ); b = _NameReg( ins->operands[1] ); s = _NameReg( ins->result ); - if( ins->head.opcode == OP_SUB && G( ins ) == G_BINARY ) { + if( ins->head.opcode == OP_SUB + && G( ins ) == G_BINARY ) { /* someone sucks - it's not me */ temp = a; a = b; @@ -839,9 +852,9 @@ void GenObjCode( instruction *ins ) /************************************/ { Encode( ins ); - if( G( ins ) == G_CMP || - G( ins ) == G_CMP_I || - G( ins ) == G_CMP_FP ) { + if( G( ins ) == G_CMP + || G( ins ) == G_CMP_I + || G( ins ) == G_CMP_FP ) { GenCondJump( ins ); } } diff --git a/bld/watcom/h/axpencod.h b/bld/watcom/h/axpencod.h index 9f53464806..fce4dde37d 100644 --- a/bld/watcom/h/axpencod.h +++ b/bld/watcom/h/axpencod.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -30,32 +31,36 @@ ****************************************************************************/ -#define _SixBits( x ) ( (x) & 0x003f ) -#define _SevenBits( x ) ( (x) & 0x007f ) -#define _FiveBits( x ) ( (x) & 0x001f ) -#define _EightBits( x ) ( (x) & 0x00ff ) -#define _ElevenBits( x )( (x) & 0x07ff ) +#define _FiveBits( x ) ( (x) & 0x0000001f ) +#define _SixBits( x ) ( (x) & 0x0000003f ) +#define _SevenBits( x ) ( (x) & 0x0000007f ) +#define _EightBits( x ) ( (x) & 0x000000ff ) +#define _ElevenBits( x ) ( (x) & 0x000007ff ) +#define _FourteenBits( x ) ( (x) & 0x00003fff ) +#define _SixteenBits( x ) ( (x) & 0x0000ffff ) +#define _TwentyOneBits( x ) ( (x) & 0x001fffff ) // these correspond to letters in section 3.3 of the Alpha Architecture Manual -#define _A( x ) ( _FiveBits(x) << 21 ) -#define _B( x ) ( _FiveBits(x) << 16 ) -#define _C( x ) ( _FiveBits(x) << 0 ) -#define _LIT( x ) ( _EightBits(x) << 13 ) +#define _Ra( x ) ( _FiveBits(x) << 21 ) +#define _Rb( x ) ( _FiveBits(x) << 16 ) +#define _Rc( x ) ( _FiveBits(x) << 0 ) +#define _LIT( x ) ( ( ( _EightBits(x) << 1 ) | 1 ) << 12 ) -#define _Opcode( x ) ( _SixBits(x) << 26 ) -#define _Function( x ) ( _SevenBits(x) << 5 ) -#define _FPFunction( x )( _ElevenBits(x) << 5 ) +#define _Opcode( x ) ( _SixBits(x) << 26 ) +#define _Function( x ) ( _SevenBits(x) << 5 ) +#define _FPFunction( x ) ( _ElevenBits(x) << 5 ) // sixteen bit signed immediate -#define _SignedImmed( x ) ( (x) & 0xffff ) +#define _SignedImmed( x ) _SixteenBits( x ) typedef uint_32 axp_ins; -#define AXP_ZERO_SINK 31 -#define AXP_FLOAT_SCRATCH 30 -#define AXP_RETURN_ADDR 26 -#define AXP_STACK_REG 30 -#define AXP_FRAME_REG 15 -#define AXP_GPR_SCRATCH 28 +#define FP_REG_IDX 15 // Contains the Frame pointer (if needed) +#define RA_REG_IDX 26 // Contains the Return address +#define AT_REG_IDX 28 // Reserved for the assembler temporary +#define GP_REG_IDX 29 // Contains the Global pointer +#define SP_REG_IDX 30 // Contains the Stack pointer +#define ZERO_REG_IDX 31 // Contains 0 +#define ATFP_REG_IDX 30 // Foating-point reserved for the assembler temporary #define AXP_MAX_OFFSET 0x7fff diff --git a/bld/watcom/h/mipsenco.h b/bld/watcom/h/mipsenco.h index 485f65b14a..b0fd9ad1e1 100644 --- a/bld/watcom/h/mipsenco.h +++ b/bld/watcom/h/mipsenco.h @@ -30,36 +30,43 @@ ****************************************************************************/ -#define _FiveBits( x ) ( (x) & 0x0000001f ) -#define _SixBits( x ) ( (x) & 0x0000003f ) -#define _SixteenBits( x ) ( (x) & 0x0000ffff ) -#define _TwentySixBits( x ) ( (x) & 0x03ffffff ) +#define _FiveBits( x ) ( (x) & 0x0000001f ) +#define _SixBits( x ) ( (x) & 0x0000003f ) +#define _EightBits( x ) ( (x) & 0x000000ff ) +#define _TenBits( x ) ( (x) & 0x000003ff ) +#define _ElevenBits( x ) ( (x) & 0x000007ff ) +#define _FourteenBits( x ) ( (x) & 0x00003fff ) +#define _SixteenBits( x ) ( (x) & 0x0000ffff ) +#define _TwentyBits( x ) ( (x) & 0x000fffff ) +#define _TwentySixBits( x ) ( (x) & 0x03ffffff ) // MIPS operand encodings, from Appendix A of MIPS RISC Architecture -#define _Rs( x ) ( _FiveBits(x) << 21 ) -#define _Rt( x ) ( _FiveBits(x) << 16 ) -#define _Rd( x ) ( _FiveBits(x) << 11 ) -#define _Shift( x ) ( _FiveBits(x) << 6 ) -#define _Ft( x ) ( _FiveBits(x) << 16 ) -#define _Fs( x ) ( _FiveBits(x) << 11 ) -#define _Fd( x ) ( _FiveBits(x) << 6 ) -#define _Immed( x ) ( _SixteenBits(x) << 0 ) -#define _Target( x ) ( _TwentySixBits(x) << 0 ) +#define _Rs( x ) ( _FiveBits(x) << 21 ) +#define _Rt( x ) ( _FiveBits(x) << 16 ) +#define _Rd( x ) ( _FiveBits(x) << 11 ) +#define _Shift( x ) ( _FiveBits(x) << 6 ) +#define _Ft( x ) ( _FiveBits(x) << 16 ) +#define _Fs( x ) ( _FiveBits(x) << 11 ) +#define _Fd( x ) ( _FiveBits(x) << 6 ) +#define _Target( x ) ( _TwentySixBits(x) << 0 ) -#define _Opcode( x ) ( _SixBits(x) << 26 ) -#define _Function( x ) ( _SixBits(x) << 0 ) -#define _FPFormat( x ) ( _FiveBits(x) << 21 ) +#define _Opcode( x ) ( _SixBits(x) << 26 ) +#define _Function( x ) ( _SixBits(x) << 0 ) +#define _FPFormat( x ) ( _FiveBits(x) << 21 ) + +#define _LIT( x ) ( ( ( _EightBits(x) << 1 ) | 1 ) << 12 ) // sixteen bit signed immediate -#define _SignedImmed( x ) ( _Immed( x ) ) +#define _SignedImmed( x ) _SixteenBits(x) typedef uint_32 mips_ins; -#define MIPS_ZERO_SINK 0 // $zero -#define MIPS_RETURN_ADDR 31 // $ra -#define MIPS_STACK_REG 29 // $sp -#define MIPS_FRAME_REG 30 // $fp -#define MIPS_GPR_SCRATCH 1 // $at +#define ZERO_REG_IDX 0 // Contains 0 +#define AT_REG_IDX 1 // Reserved for the assembler temporary +#define GP_REG_IDX 28 // Contains the Global pointer +#define SP_REG_IDX 29 // Contains the Stack pointer +#define FP_REG_IDX 30 // Contains the Frame pointer +#define RA_REG_IDX 31 // Contains the Return address #define MIPS_MAX_OFFSET 0x7fff // immediate displacement range diff --git a/bld/watcom/h/ppcencod.h b/bld/watcom/h/ppcencod.h index 020a8fcab9..cb750fbb87 100644 --- a/bld/watcom/h/ppcencod.h +++ b/bld/watcom/h/ppcencod.h @@ -31,37 +31,46 @@ ****************************************************************************/ -#define _SixBits( x ) ( (x) & 0x003f ) -#define _SevenBits( x ) ( (x) & 0x007f ) -#define _FiveBits( x ) ( (x) & 0x001f ) -#define _EightBits( x ) ( (x) & 0x00ff ) -#define _TenBits( x ) ( (x) & 0x03ff ) -#define _OneBit( x ) ( (x) & 0x0001 ) +#define _OneBit( x ) ( (x) & 0x00000001 ) +#define _FiveBits( x ) ( (x) & 0x0000001f ) +#define _SixBits( x ) ( (x) & 0x0000003f ) +#define _SevenBits( x ) ( (x) & 0x0000007f ) +#define _EightBits( x ) ( (x) & 0x000000ff ) +#define _TenBits( x ) ( (x) & 0x000003ff ) +#define _FourteenBits( x ) ( (x) & 0x00003fff ) +#define _SixteenBits( x ) ( (x) & 0x0000ffff ) +#define _TwentyFourBits( x ) ( (x) & 0x00ffffff ) // these correspond to letters in section 3.3 of the Alpha Architecture Manual -#define _A( x ) ( _FiveBits(x) << 16 ) -#define _B( x ) ( _FiveBits(x) << 11 ) -#define _C( x ) ( _FiveBits(x) << 6 ) -#define _S( x ) ( _FiveBits(x) << 21 ) -#define _D( x ) ( _FiveBits(x) << 21 ) +#define _A( x ) ( _FiveBits(x) << 16 ) +#define _B( x ) ( _FiveBits(x) << 11 ) +#define _C( x ) ( _FiveBits(x) << 6 ) +#define _S( x ) ( _FiveBits(x) << 21 ) +#define _D( x ) ( _FiveBits(x) << 21 ) -#define _Op1( x ) ( _SixBits(x) << 26 ) -#define _Op2( x ) ( _TenBits(x) << 1 ) +#define _Opcode( x ) ( _SixBits(x) << 26 ) +#define _Opcode2( x ) ( _TenBits(x) << 1 ) // Note: this assumes SPR[5-9] is 0 (so we can put simple decimal value as parm) -#define _SPR( x ) ( _TenBits( x ) << 16 ) +#define _SPR( x ) ( _TenBits( x ) << 11 ) -#define _AA( x ) ( _OneBit( x ) << 1 ) -#define _LK( x ) ( _OneBit( x ) ) +#define __AA( x ) ( _OneBit( x ) << 1 ) +#define __LK( x ) _OneBit( x ) +#define __OE( x ) ( _OneBit( x ) << 10 ) +#define __RC( x ) _OneBit( x ) // sixteen bit signed immediate -#define _SignedImmed( x ) ( (x) & 0xffffU ) +#define _SignedImmed( x ) _SixteenBits( x ) // twenty-four bit signed immediate (note - this effectively divides by 4) #define _BranchImmed( x ) ( (x) & 0x3fffffc ) // SPR registers (page 10-131) -#define SPR_LR 8 -#define SPR_CTR 9 +#define SPR_LR 8 +#define SPR_CTR 9 + +#define ZERO_REG_IDX 0 +#define SP_REG_IDX 1 +#define RTOC_REG_IDX 2 typedef uint_32 ppc_ins; From 08cd64a9488fa222df1c534d5fabbebba8ce3d53 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Sun, 1 Oct 2023 14:53:49 +0200 Subject: [PATCH 187/258] cleanup generation code for risc architecture add new macros for default registers --- bld/cg/risc/axp/c/axpenc.c | 4 ++-- bld/watcom/h/axpencod.h | 19 ++++++++++++------- bld/watcom/h/mipsenco.h | 18 ++++++++++++------ bld/watcom/h/ppcencod.h | 14 +++++++++++--- 4 files changed, 37 insertions(+), 18 deletions(-) diff --git a/bld/cg/risc/axp/c/axpenc.c b/bld/cg/risc/axp/c/axpenc.c index 60df661e4e..f2b970cbe6 100644 --- a/bld/cg/risc/axp/c/axpenc.c +++ b/bld/cg/risc/axp/c/axpenc.c @@ -808,9 +808,9 @@ static void Encode( instruction *ins ) assert( ins->operands[0]->n.class == N_REGISTER ); assert( ins->result->n.class != N_REGISTER ); reg_index = _NameReg( ins->operands[0] ); - GenFPOPINS( 0x16, 0x2f, ZERO_REG_IDX, reg_index, ATFP_REG_IDX ); + GenFPOPINS( 0x16, 0x2f, ZERO_REG_IDX, reg_index, FP_AT_REG_IDX ); getMemEncoding( ins->result, &mem_index, &mem_offset ); - GenMEMINS( 0x27, ATFP_REG_IDX, mem_index, mem_offset ); + GenMEMINS( 0x27, FP_AT_REG_IDX, mem_index, mem_offset ); break; case G_MI8TOFREG: assert( ins->operands[0]->n.class != N_REGISTER ); diff --git a/bld/watcom/h/axpencod.h b/bld/watcom/h/axpencod.h index fce4dde37d..da3130fbe2 100644 --- a/bld/watcom/h/axpencod.h +++ b/bld/watcom/h/axpencod.h @@ -55,12 +55,17 @@ typedef uint_32 axp_ins; -#define FP_REG_IDX 15 // Contains the Frame pointer (if needed) -#define RA_REG_IDX 26 // Contains the Return address -#define AT_REG_IDX 28 // Reserved for the assembler temporary -#define GP_REG_IDX 29 // Contains the Global pointer -#define SP_REG_IDX 30 // Contains the Stack pointer -#define ZERO_REG_IDX 31 // Contains 0 -#define ATFP_REG_IDX 30 // Foating-point reserved for the assembler temporary +#define FP_REG_IDX 15 // Contains the Frame pointer (if needed) +#define RA_REG_IDX 26 // Contains the Return address +#define AT_REG_IDX 28 // Reserved for the temporary +#define GP_REG_IDX 29 // Contains the Global pointer +#define SP_REG_IDX 30 // Contains the Stack pointer +#define ZERO_REG_IDX 31 // Contains 0 +#define FP_AT_REG_IDX 30 // Reserved for the temporary floating-point + +#define VARARGS_PTR_REG_IDX 14 // $s5 +#define RT_PARM2_REG_IDX 2 // $t1 +#define RT_PARM1_REG_IDX 1 // $t0 +#define RT_RET_REG_IDX 0 // $v0 #define AXP_MAX_OFFSET 0x7fff diff --git a/bld/watcom/h/mipsenco.h b/bld/watcom/h/mipsenco.h index b0fd9ad1e1..c52c101519 100644 --- a/bld/watcom/h/mipsenco.h +++ b/bld/watcom/h/mipsenco.h @@ -61,12 +61,18 @@ typedef uint_32 mips_ins; -#define ZERO_REG_IDX 0 // Contains 0 -#define AT_REG_IDX 1 // Reserved for the assembler temporary -#define GP_REG_IDX 28 // Contains the Global pointer -#define SP_REG_IDX 29 // Contains the Stack pointer -#define FP_REG_IDX 30 // Contains the Frame pointer -#define RA_REG_IDX 31 // Contains the Return address +#define ZERO_REG_IDX 0 // Contains 0 +#define AT_REG_IDX 1 // Reserved for the temporary +#define GP_REG_IDX 28 // Contains the Global pointer +#define SP_REG_IDX 29 // Contains the Stack pointer +#define FP_REG_IDX 30 // Contains the Frame pointer +#define RA_REG_IDX 31 // Contains the Return address +//#define FP_AT_REG_IDX 1 // Reserved for the temporary floating-point + +#define VARARGS_PTR_REG_IDX 23 // $s7 !TODO! +#define RT_PARM2_REG_IDX 9 // $t1 +#define RT_PARM1_REG_IDX 8 // $t0 +#define RT_RET_REG_IDX 2 // $v0 #define MIPS_MAX_OFFSET 0x7fff // immediate displacement range diff --git a/bld/watcom/h/ppcencod.h b/bld/watcom/h/ppcencod.h index cb750fbb87..09b93de427 100644 --- a/bld/watcom/h/ppcencod.h +++ b/bld/watcom/h/ppcencod.h @@ -69,8 +69,16 @@ #define SPR_LR 8 #define SPR_CTR 9 -#define ZERO_REG_IDX 0 -#define SP_REG_IDX 1 -#define RTOC_REG_IDX 2 +#define ZERO_REG_IDX 0 // $zero +#define SP_REG_IDX 1 // $sp +#define RTOC_REG_IDX 2 // $rtoc +#define AT_REG_IDX 12 // Reserved for the temporary +#define FP_AT_REG_IDX 13 // Reserved for the temporary floating-point +#define FP_REG_IDX 31 // $fp + +#define VARARGS_PTR_REG_IDX 14 +#define RT_PARM2_REG_IDX 9 // $t1 +#define RT_PARM1_REG_IDX 8 // $t0 +#define RT_RET_REG_IDX 2 // $v0 typedef uint_32 ppc_ins; From f52cc077b4fd28d1dd6eb369948a6092b702b3ba Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Sun, 1 Oct 2023 16:01:42 +0200 Subject: [PATCH 188/258] add new macros to do code more consistent --- bld/cg/risc/axp/c/axpenc.c | 9 ++++----- bld/cg/risc/axp/c/axpproc.c | 39 ++++++++++++++++--------------------- bld/cg/risc/mps/c/mpsenc.c | 2 -- bld/cg/risc/ppc/c/ppcenc.c | 31 +++++++++++++---------------- bld/cg/risc/ppc/c/ppcparm.c | 20 +++++++++---------- bld/cg/risc/ppc/c/ppcproc.c | 37 ++++++++++++++++------------------- bld/cg/risc/ppc/h/ppcparm.h | 11 +++++------ 7 files changed, 66 insertions(+), 83 deletions(-) diff --git a/bld/cg/risc/axp/c/axpenc.c b/bld/cg/risc/axp/c/axpenc.c index f2b970cbe6..14ae427743 100644 --- a/bld/cg/risc/axp/c/axpenc.c +++ b/bld/cg/risc/axp/c/axpenc.c @@ -68,7 +68,6 @@ #define RDTEB_ENCODING 0x000000ab #define RDTEB_MAGIC_CONST 0x2c -#define V0 0 /* * Our table for opcode values is really a list of pairs of @@ -717,11 +716,11 @@ static bool encodeThreadDataRef( instruction *ins ) GenMEMINSRELOC( 0x08, AT_REG_IDX, AT_REG_IDX, 0, tls_index, OWL_RELOC_HALF_LO ); EmitIns( RDTEB_ENCODING ); - GenMEMINS( loadOpcodes[I4], V0, V0, RDTEB_MAGIC_CONST ); - GenOPINS( 0x0010, 0x0002, AT_REG_IDX, V0, V0 ); - GenMEMINS( loadOpcodes[I4], V0, V0, 0 ); + GenMEMINS( loadOpcodes[I4], RT_RET_REG_IDX, RT_RET_REG_IDX, RDTEB_MAGIC_CONST ); + GenOPINS( 0x0010, 0x0002, AT_REG_IDX, RT_RET_REG_IDX, RT_RET_REG_IDX ); + GenMEMINS( loadOpcodes[I4], RT_RET_REG_IDX, RT_RET_REG_IDX, 0 ); GenMEMINSRELOC( 0x08, _NameReg( ins->result ), - V0, 0, symLabel( op ), OWL_RELOC_HALF_LO ); + RT_RET_REG_IDX, 0, symLabel( op ), OWL_RELOC_HALF_LO ); return( true ); } diff --git a/bld/cg/risc/axp/c/axpproc.c b/bld/cg/risc/axp/c/axpproc.c index 1148e52e6f..5a7c308068 100644 --- a/bld/cg/risc/axp/c/axpproc.c +++ b/bld/cg/risc/axp/c/axpproc.c @@ -52,6 +52,14 @@ #include "feprotos.h" +#define STORE_QUADWORD 0x2d +#define STORE_DOUBLE 0x27 +#define LOAD_QUADWORD 0x29 +#define LOAD_DOUBLE 0x23 +#define LEA_OPCODE 0x08 +#define LEAH_OPCODE 0x09 + + static void calcUsedRegs( void ) /**********************************/ { @@ -172,19 +180,6 @@ static void initSavedRegs( stack_record *saved_regs, type_length *offset ) *offset += saved_regs->size; } -#define STORE_QUADWORD 0x2d -#define STORE_DOUBLE 0x27 -#define LOAD_QUADWORD 0x29 -#define LOAD_DOUBLE 0x23 -#define LEA_OPCODE 0x08 -#define LEAH_OPCODE 0x09 - -#define VARARGS_PTR 14 -#define RT_PARM2 2 -#define RT_PARM1 1 -#define RT_RET_REG 0 - - static void genMove( uint_32 src, uint_32 dst ) /*************************************************/ { @@ -454,10 +449,10 @@ static void SetupVarargsReg( stack_map *map ) offset += REG_SIZE; } if( offset > AXP_MAX_OFFSET ) { - GenLOADS32( offset, VARARGS_PTR ); - GenOPINS( 0x10, 0x00, SP_REG_IDX, VARARGS_PTR, VARARGS_PTR ); + GenLOADS32( offset, VARARGS_PTR_REG_IDX ); + GenOPINS( 0x10, 0x00, SP_REG_IDX, VARARGS_PTR_REG_IDX, VARARGS_PTR_REG_IDX ); } else { - genLea( SP_REG_IDX, offset, VARARGS_PTR ); + genLea( SP_REG_IDX, offset, VARARGS_PTR_REG_IDX ); } } } @@ -479,11 +474,11 @@ static void emitProlog( stack_map *map ) } if( frame_size >= _TARGET_PAGE_SIZE ) { if( frame_size <= AXP_MAX_OFFSET ) { - genLea( ZERO_REG_IDX, frame_size, RT_PARM1 ); + genLea( ZERO_REG_IDX, frame_size, RT_PARM1_REG_IDX ); } else { - genMove( AT_REG_IDX, RT_PARM1 ); + genMove( AT_REG_IDX, RT_PARM1_REG_IDX ); } - GenCallLabelReg( RTLabel( RT_STK_CRAWL_SIZE ), RT_RET_REG ); + GenCallLabelReg( RTLabel( RT_STK_CRAWL_SIZE ), RT_RET_REG_IDX ); } } if( map->locals.size != 0 || map->parm_cache.size != 0 ) { @@ -491,11 +486,11 @@ static void emitProlog( stack_map *map ) type_length size; size = map->locals.size + map->parm_cache.size; if( size > AXP_MAX_OFFSET ) { - GenLOADS32( size, RT_PARM1 ); + GenLOADS32( size, RT_PARM1_REG_IDX ); } else { - genLea( ZERO_REG_IDX, map->locals.size + map->parm_cache.size, RT_PARM1 ); + genLea( ZERO_REG_IDX, map->locals.size + map->parm_cache.size, RT_PARM1_REG_IDX ); } - GenCallLabelReg( RTLabel( RT_STK_STOMP ), RT_RET_REG ); + GenCallLabelReg( RTLabel( RT_STK_STOMP ), RT_RET_REG_IDX ); } } emitVarargsProlog( &map->varargs ); diff --git a/bld/cg/risc/mps/c/mpsenc.c b/bld/cg/risc/mps/c/mpsenc.c index f893af444a..24af7192ab 100644 --- a/bld/cg/risc/mps/c/mpsenc.c +++ b/bld/cg/risc/mps/c/mpsenc.c @@ -70,10 +70,8 @@ * This is NT stuff - probably irreleveant unless someone wanted to * support the MIPS version of NT! */ - #define RDTEB_ENCODING 0x000000ab #define RDTEB_MAGIC_CONST 0x2c -#define V0 0 /* * Our table for opcode values is really a list of pairs of diff --git a/bld/cg/risc/ppc/c/ppcenc.c b/bld/cg/risc/ppc/c/ppcenc.c index 779338b9f4..720b7897fe 100644 --- a/bld/cg/risc/ppc/c/ppcenc.c +++ b/bld/cg/risc/ppc/c/ppcenc.c @@ -64,11 +64,6 @@ #define _EmitIns( ins ) ObjBytes( &(ins), sizeof( ppc_ins ) ) #define _ObjEmitSeq( code ) ObjBytes( code->data, code->length ) -#define ZERO_SINK 0 -#define STACK_REG 1 -#define TOC_REG 2 -#define VOLATILE_REG 12 - #define _BinaryOpcode( a, b ) { { a, b }, { a, b } } #define _SignedOpcode( a, b, c, d ) { { a, b }, { c, d } } @@ -441,7 +436,7 @@ static void getMemEncoding( name *mem, reg_idx *index, int_16 *offset ) break; case N_MEMORY: default: - *index = ZERO_SINK; + *index = ZERO_REG_IDX; *offset = 0; _Zoiks( ZOIKS_119 ); break; @@ -533,12 +528,12 @@ static void GenCallIndirect( instruction *call ) gen_opcode ldw; gen_opcode stw; - reg = VOLATILE_REG; /* use the volatile scratch reg if possible */ - src = VOLATILE_REG; + reg = AT_REG_IDX; /* use the volatile scratch reg if possible */ + src = AT_REG_IDX; addr = call->operands[CALL_OP_ADDR]; ldw = loadOpcodes[U4]; stw = storeOpcodes[U4]; - GenMEMINS( stw, TOC_REG, STACK_REG, 4 ); + GenMEMINS( stw, RTOC_REG_IDX, SP_REG_IDX, 4 ); switch( addr->n.class ) { case N_REGISTER: src = _NameReg( addr ); @@ -549,11 +544,11 @@ static void GenCallIndirect( instruction *call ) GenMEMINS( ldw, src, mem_index, mem_offset ); break; } - GenMEMINS( ldw, TOC_REG, src, 4 ); // careful - src, reg could be same reg + GenMEMINS( ldw, RTOC_REG_IDX, src, 4 ); // careful - src, reg could be same reg GenMEMINS( ldw, reg, src, 0 ); GenMTSPR( reg, SPR_CTR, false ); GenRAWINS( 0x4e9e0421 ); - GenMEMINS( ldw, TOC_REG, STACK_REG, 4 ); + GenMEMINS( ldw, RTOC_REG_IDX, SP_REG_IDX, 4 ); } @@ -569,14 +564,14 @@ static void GenVaStart( instruction *ins ) assert( ins->operands[0]->n.class == N_REGISTER ); reg = _NameReg( ins->operands[0] ); - tmp = VOLATILE_REG; + tmp = AT_REG_IDX; stack = RegTrans( FrameReg() ); stb = storeOpcodes[U1]; stw = storeOpcodes[U4]; li = 14; // addi - GenOPIMM( li, tmp, ZERO_SINK, CurrProc->state.parm.gr ); + GenOPIMM( li, tmp, ZERO_REG_IDX, CurrProc->state.parm.gr ); GenMEMINS( stb, tmp, reg, 0 ); - GenOPIMM( li, tmp, ZERO_SINK, CurrProc->state.parm.fr ); + GenOPIMM( li, tmp, ZERO_REG_IDX, CurrProc->state.parm.fr ); GenMEMINS( stb, tmp, reg, 1 ); GenOPIMM( li, tmp, stack, CurrProc->state.parm.offset + CurrProc->targ.frame_size + STACK_HEADER_SIZE ); GenMEMINS( stw, tmp, reg, 4 ); @@ -646,12 +641,12 @@ static void Encode( instruction *ins ) assert( ins->operands[0]->c.const_type == CONS_HIGH_ADDR ); assert( ins->result->n.class == N_REGISTER ); /* addis k(r0) -> rn */ - GenOPIMM( 15, _NameReg( ins->result ), ZERO_SINK, ins->operands[0]->c.lo.int_value & 0xffff ); + GenOPIMM( 15, _NameReg( ins->result ), ZERO_REG_IDX, ins->operands[0]->c.lo.int_value & 0xffff ); break; case G_MOVE_UI: /* a load of an unsigned 16-bit immediate */ /* use or rd, imm(r0) */ - GenOPIMM( 24, _NameReg( ins->result ), ZERO_SINK, ins->operands[0]->c.lo.int_value ); + GenOPIMM( 24, _NameReg( ins->result ), ZERO_REG_IDX, ins->operands[0]->c.lo.int_value ); break; case G_LEA: assert( ins->operands[0]->n.class == N_CONSTANT ); @@ -659,7 +654,7 @@ static void Encode( instruction *ins ) switch( ins->operands[0]->c.const_type ) { case CONS_ABSOLUTE: // addi rd, imm(r0) - GenOPIMM( 14, _NameReg( ins->result ), ZERO_SINK, ins->operands[0]->c.lo.int_value ); + GenOPIMM( 14, _NameReg( ins->result ), ZERO_REG_IDX, ins->operands[0]->c.lo.int_value ); break; case CONS_LOW_ADDR: case CONS_HIGH_ADDR: @@ -681,7 +676,7 @@ static void Encode( instruction *ins ) case N_MEMORY: assert( ins->result->n.class == N_REGISTER ); OutReloc( symLabel( ins->operands[0] ), PPC_RELOC_TOC_OFFSET, 2 ); - GenMEMINS( 32, _NameReg( ins->result ), TOC_REG, 0 ); + GenMEMINS( 32, _NameReg( ins->result ), RTOC_REG_IDX, 0 ); break; default: _Zoiks( ZOIKS_119 ); diff --git a/bld/cg/risc/ppc/c/ppcparm.c b/bld/cg/risc/ppc/c/ppcparm.c index 7ba72c137d..8b9ec9ffe0 100644 --- a/bld/cg/risc/ppc/c/ppcparm.c +++ b/bld/cg/risc/ppc/c/ppcparm.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2018 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -76,8 +76,8 @@ static hw_reg_set scalarRegs[] = { void InitPPCParmState( call_state *state ) /*******************************************/ { - state->parm.gr = FIRST_SCALAR_PARM_REG; - state->parm.fr = FIRST_FLOAT_PARM_REG; + state->parm.gr = FIRST_SCALAR_PARM_REG_IDX; + state->parm.fr = FIRST_FLOAT_PARM_REG_IDX; } type_length ParmAlignment( type_def *tipe ) @@ -101,15 +101,15 @@ type_length ParmAlignment( type_def *tipe ) static hw_reg_set floatRegSet( int index ) /**********************************************/ { - assert( index >= FIRST_FLOAT_PARM_REG && index <= LAST_FLOAT_PARM_REG ); - return( floatRegs[index - FIRST_FLOAT_PARM_REG] ); + assert( index >= FIRST_FLOAT_PARM_REG_IDX && index <= LAST_FLOAT_PARM_REG_IDX ); + return( floatRegs[index - FIRST_FLOAT_PARM_REG_IDX] ); } static hw_reg_set scalarRegSet( int index ) /***********************************************/ { - assert( index >= FIRST_SCALAR_PARM_REG && index <= LAST_SCALAR_PARM_REG ); - return( scalarRegs[index - FIRST_SCALAR_PARM_REG] ); + assert( index >= FIRST_SCALAR_PARM_REG_IDX && index <= LAST_SCALAR_PARM_REG_IDX ); + return( scalarRegs[index - FIRST_SCALAR_PARM_REG_IDX] ); } hw_reg_set ParmReg( type_class_def type_class, type_length len, type_length alignment, call_state *state ) @@ -129,21 +129,21 @@ hw_reg_set ParmReg( type_class_def type_class, type_length len, type_length } if( _IsFloating( type_class ) ) { // if we are passing on stack it was busted up in AssgnParms prior to this - if( state->parm.fr <= LAST_FLOAT_PARM_REG ) { + if( state->parm.fr <= LAST_FLOAT_PARM_REG_IDX ) { state->parm.fr += 1; state->parm.gr += 2; state->parm.offset += 8; parm = floatRegSet( state->parm.fr - 1 ); } } else if( _IsI64( type_class ) ) { - if( state->parm.gr <= (LAST_SCALAR_PARM_REG - 1) ) { + if( state->parm.gr <= (LAST_SCALAR_PARM_REG_IDX - 1) ) { state->parm.gr += 2; state->parm.offset += 8; parm = scalarRegSet( state->parm.gr - 2 ); HW_TurnOn( parm, scalarRegSet( state->parm.gr - 1 ) ); } } else { - if( state->parm.gr <= LAST_SCALAR_PARM_REG ) { + if( state->parm.gr <= LAST_SCALAR_PARM_REG_IDX ) { state->parm.gr += 1; state->parm.offset += 4; parm = scalarRegSet( state->parm.gr - 1 ); diff --git a/bld/cg/risc/ppc/c/ppcproc.c b/bld/cg/risc/ppc/c/ppcproc.c index 87a4781908..666c0b485d 100644 --- a/bld/cg/risc/ppc/c/ppcproc.c +++ b/bld/cg/risc/ppc/c/ppcproc.c @@ -49,6 +49,13 @@ #include "feprotos.h" +#define STORE_DWORD 36 +#define STORE_DOUBLE 54 +#define LOAD_DWORD 32 +#define LOAD_DOUBLE 50 +#define ADDI_OPCODE 14 + + static void CalcUsedRegs( void ) /**********************************/ { @@ -174,16 +181,6 @@ static void initSavedRegs( stack_record *saved_regs, type_length *offset ) *offset += saved_regs->size; } -#define STORE_DWORD 36 -#define STORE_DOUBLE 54 -#define LOAD_DWORD 32 -#define LOAD_DOUBLE 50 -#define ADDI_OPCODE 14 - -#define STACK_REG 1 -#define FRAME_REG 31 -#define VARARGS_PTR 14 - static void genMove( uint_32 src, uint_32 dst ) /*************************************************/ { @@ -205,7 +202,7 @@ static void saveReg( uint_32 index, type_length offset, bool fp ) if( fp ) { opcode = STORE_DOUBLE; } - GenMEMINS( opcode, index, STACK_REG, offset ); + GenMEMINS( opcode, index, SP_REG_IDX, offset ); } static void loadReg( uint_32 index, type_length offset, bool fp ) @@ -218,9 +215,9 @@ static void loadReg( uint_32 index, type_length offset, bool fp ) if( fp ) { opcode = LOAD_DOUBLE; } - frame_reg = STACK_REG; + frame_reg = SP_REG_IDX; if( CurrProc->targ.base_is_fp ) { - frame_reg = FRAME_REG; + frame_reg = FP_REG_IDX; } GenMEMINS( opcode, index, frame_reg, offset + CurrProc->locals.size ); } @@ -311,8 +308,8 @@ static void emitVarargsProlog( stack_record *varargs ) if( CurrProc->state.attr & ROUTINE_HAS_VARARGS ) { // save our registers in our caller's context - uhg! offset = CurrProc->targ.frame_size + STACK_HEADER_SIZE; - for( i = CurrProc->state.parm.gr; i <= LAST_SCALAR_PARM_REG; i++ ) { - saveReg( i, offset + ( i - FIRST_SCALAR_PARM_REG ) * 4, false ); + for( i = CurrProc->state.parm.gr; i <= LAST_SCALAR_PARM_REG_IDX; i++ ) { + saveReg( i, offset + ( i - FIRST_SCALAR_PARM_REG_IDX ) * 4, false ); } } } @@ -415,7 +412,7 @@ static void emitProlog( stack_map *map ) } if( frame_size != 0 ) { // stwu sp,-frame_size(sp) - GenMEMINS( 37, STACK_REG, STACK_REG, -frame_size ); + GenMEMINS( 37, SP_REG_IDX, SP_REG_IDX, -frame_size ); emitVarargsProlog( &map->varargs ); emitSlopProlog( &map->varargs ); emitSavedRegsProlog( &map->saved_regs ); @@ -423,7 +420,7 @@ static void emitProlog( stack_map *map ) emitParmCacheProlog( &map->parm_cache ); emitStackHeaderProlog( &map->stack_header ); if( CurrProc->targ.base_is_fp ) { - genMove( STACK_REG, FRAME_REG ); + genMove( SP_REG_IDX, FP_REG_IDX ); } } } @@ -445,11 +442,11 @@ static void emitEpilog( stack_map *map ) if( !CurrProc->targ.leaf ) { GenMTSPR( 0, SPR_LR, false ); } - frame_reg = STACK_REG; + frame_reg = SP_REG_IDX; if( CurrProc->targ.base_is_fp ) { - frame_reg = FRAME_REG; + frame_reg = FP_REG_IDX; } - genAdd( frame_reg, frame_size, STACK_REG ); + genAdd( frame_reg, frame_size, SP_REG_IDX ); } } diff --git a/bld/cg/risc/ppc/h/ppcparm.h b/bld/cg/risc/ppc/h/ppcparm.h index 68f1e3cd16..60cf62b5e8 100644 --- a/bld/cg/risc/ppc/h/ppcparm.h +++ b/bld/cg/risc/ppc/h/ppcparm.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -30,11 +31,9 @@ ****************************************************************************/ -#define FIRST_FLOAT_PARM_REG 1 -#define LAST_FLOAT_PARM_REG 13 -#define FIRST_SCALAR_PARM_REG 3 -#define LAST_SCALAR_PARM_REG 10 - -#define FP_SCRATCH_REG 13 +#define FIRST_FLOAT_PARM_REG_IDX 1 +#define LAST_FLOAT_PARM_REG_IDX 13 +#define FIRST_SCALAR_PARM_REG_IDX 3 +#define LAST_SCALAR_PARM_REG_IDX 10 extern void InitPPCParmState( call_state *state ); From dc396b72a25cbbe95c48c2b923c517838aae65b4 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Sun, 1 Oct 2023 16:14:50 +0200 Subject: [PATCH 189/258] fix mistakes in MIPS code --- bld/cg/risc/mps/c/mpsenc.c | 15 +++++++++------ bld/cg/risc/mps/c/mpsproc.c | 25 ++++++++++--------------- 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/bld/cg/risc/mps/c/mpsenc.c b/bld/cg/risc/mps/c/mpsenc.c index 24af7192ab..b6080b617e 100644 --- a/bld/cg/risc/mps/c/mpsenc.c +++ b/bld/cg/risc/mps/c/mpsenc.c @@ -588,7 +588,7 @@ static void addressTemp( name *temp, uint_8 *reg, int_16 *offset ) temp_offset = TempLocation( temp ); if( temp_offset > MIPS_MAX_OFFSET ) { /* - * gen some code to load temp address into SCRATCH_REG + * gen some code to load temp address into scratch register */ GenLOADS32( temp_offset, AT_REG_IDX ); /* @@ -703,7 +703,10 @@ static void GenCallIndirect( instruction *call ) int_16 mem_offset; name *addr; - reg_index = AT_REG_IDX; /* use the volatile scratch reg if possible */ + /* + * use the scratch register if possible + */ + reg_index = AT_REG_IDX; addr = call->operands[CALL_OP_ADDR]; switch( addr->n.class ) { case N_REGISTER: @@ -824,11 +827,11 @@ static bool encodeThreadDataRef( instruction *ins ) GenMEMINSRELOC( 0x08, AT_REG_IDX, AT_REG_IDX, 0, tls_index, OWL_RELOC_HALF_LO ); EmitIns( RDTEB_ENCODING ); - GenMEMINS( loadOpcodes[I4], V0, V0, RDTEB_MAGIC_CONST ); - GenOPINS( 0x0010, 0x0002, AT_REG_IDX, V0, V0 ); - GenMEMINS( loadOpcodes[I4], V0, V0, 0 ); + GenMEMINS( loadOpcodes[I4], RT_RET_REG_IDX, RT_RET_REG_IDX, RDTEB_MAGIC_CONST ); + GenOPINS( 0x0010, 0x0002, AT_REG_IDX, RT_RET_REG_IDX, RT_RET_REG_IDX ); + GenMEMINS( loadOpcodes[I4], RT_RET_REG_IDX, RT_RET_REG_IDX, 0 ); GenMEMINSRELOC( 0x08, _NameReg( ins->result ), - V0, 0, symLabel( op ), OWL_RELOC_HALF_LO ); + RT_RET_REG_IDX, 0, symLabel( op ), OWL_RELOC_HALF_LO ); #else assert( 0 ); #endif diff --git a/bld/cg/risc/mps/c/mpsproc.c b/bld/cg/risc/mps/c/mpsproc.c index 063f13a710..b377c3d2fb 100644 --- a/bld/cg/risc/mps/c/mpsproc.c +++ b/bld/cg/risc/mps/c/mpsproc.c @@ -197,11 +197,6 @@ static void initSavedRegs( stack_record *saved_regs, type_length *offset ) #define ADDIU_OPCODE 0x09 #define NOP_OPCODE 0x00 -#define VARARGS_PTR 23 // TODO -#define RT_PARM1 8 // $t0 -#define RT_RET_REG 2 // $v0 - - static void genMove( uint_32 src, uint_32 dst ) /**********************************************/ { @@ -493,13 +488,13 @@ static void SetupVarargsReg( stack_map *map ) offset += REG_SIZE; } if( offset > MIPS_MAX_OFFSET ) { - GenLOADS32( offset, VARARGS_PTR ); + GenLOADS32( offset, VARARGS_PTR_REG_IDX ); /* * 'add va_home,va_home,sp' */ - GenRType( 0x00, 0x21, SP_REG_IDX, VARARGS_PTR, VARARGS_PTR ); + GenRType( 0x00, 0x21, SP_REG_IDX, VARARGS_PTR_REG_IDX, VARARGS_PTR_REG_IDX ); } else { - genLoadImm( SP_REG_IDX, offset, VARARGS_PTR ); + genLoadImm( SP_REG_IDX, offset, VARARGS_PTR_REG_IDX ); } } } @@ -522,14 +517,14 @@ static void emitProlog( stack_map *map ) GenRType( 0x00, 0x23, SP_REG_IDX, SP_REG_IDX, AT_REG_IDX ); } if( frame_size >= _TARGET_PAGE_SIZE ) { - GenCallLabelReg( RTLabel( RT_STK_CRAWL_SIZE ), RT_RET_REG ); + GenCallLabelReg( RTLabel( RT_STK_CRAWL_SIZE ), RT_RET_REG_IDX ); /* * Next instruction will be in delay slot! */ if( frame_size <= MIPS_MAX_OFFSET ) { - genLoadImm( ZERO_REG_IDX, frame_size, RT_PARM1 ); + genLoadImm( ZERO_REG_IDX, frame_size, RT_PARM1_REG_IDX ); } else { - genMove( AT_REG_IDX, RT_PARM1 ); + genMove( AT_REG_IDX, RT_PARM1_REG_IDX ); } } } @@ -540,15 +535,15 @@ static void emitProlog( stack_map *map ) size = map->locals.size + map->parm_cache.size; if( size > MIPS_MAX_OFFSET ) { - GenLOADS32( size, RT_PARM1 ); - GenCallLabelReg( RTLabel( RT_STK_STOMP ), RT_RET_REG ); + GenLOADS32( size, RT_PARM1_REG_IDX ); + GenCallLabelReg( RTLabel( RT_STK_STOMP ), RT_RET_REG_IDX ); genNOP(); // could split LOADS32 call to fill in delay slot... } else { - GenCallLabelReg( RTLabel( RT_STK_STOMP ), RT_RET_REG ); + GenCallLabelReg( RTLabel( RT_STK_STOMP ), RT_RET_REG_IDX ); /* * Next instruction will be in delay slot! */ - genLoadImm( ZERO_REG_IDX, map->locals.size + map->parm_cache.size, RT_PARM1 ); + genLoadImm( ZERO_REG_IDX, map->locals.size + map->parm_cache.size, RT_PARM1_REG_IDX ); } } } From 14781fd3be5d34452b6fd72185cc62177c46378b Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Sun, 1 Oct 2023 17:51:41 +0200 Subject: [PATCH 190/258] cleanup wpi code --- bld/wpi/c/wpi_file.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bld/wpi/c/wpi_file.c b/bld/wpi/c/wpi_file.c index c9726e4dd6..93a1ac8c8d 100644 --- a/bld/wpi/c/wpi_file.c +++ b/bld/wpi/c/wpi_file.c @@ -53,7 +53,7 @@ HFILE _wpi_fileopen( LPSTR filename, int format ) OPEN_ACTION_FAIL_IF_NEW | OPEN_ACTION_OPEN_IF_EXISTS, format, 0 ) != 0 ) { - hfile = -1; + hfile = (HFILE)-1; } #ifdef __FLAT__ DosDevIOCtl( hfile, 0x08, 0x00, 0, 0, 0, 0, 512L, 0 ); @@ -81,7 +81,7 @@ HFILE _wpi_filecreate( LPSTR filename, int format ) OPEN_ACTION_CREATE_IF_NEW | OPEN_ACTION_REPLACE_IF_EXISTS, format, 0 ) != 0 ) { - hfile = -1; + hfile = (HFILE)-1; } #ifdef __FLAT__ From 653b1c19417307b7bf4ba580b83f1d4a579e7f3d Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Sun, 1 Oct 2023 22:49:49 +0200 Subject: [PATCH 191/258] reformat C compiler source files --- bld/cc/c/cdinit.c | 12 +- bld/cc/c/cfeinfo.c | 135 +++++++++++-------- bld/cc/c/cscan.c | 323 ++++++++++++++++++++++++++++++++------------- 3 files changed, 315 insertions(+), 155 deletions(-) diff --git a/bld/cc/c/cdinit.c b/bld/cc/c/cdinit.c index 794a3e0097..c4a48f8113 100644 --- a/bld/cc/c/cdinit.c +++ b/bld/cc/c/cdinit.c @@ -154,9 +154,9 @@ void *StartDataQuadAccess( void ) if( DataQuadsAvailable() ) { cur_dqp = CurDataQuad; CurDataQuad = DataQuadSegs[0]->next; - return( cur_dqp ); // indicate data quads exist + return( cur_dqp ); /* indicate data quads exist */ } - return( NULL ); // indicate no data quads + return( NULL ); /* indicate no data quads */ } void EndDataQuadAccess( void *p ) @@ -544,11 +544,11 @@ static void AddrFold( TREEPTR tree, addrfold_info *info ) info->state = IS_VALUE; } break; - case OPR_CONVERT: //should check for pointer to smaller + case OPR_CONVERT: // should check for pointer to smaller case OPR_CONVERT_PTR: AddrFold( tree->right, info ); break; - case OPR_ERROR: // error has already been issued + case OPR_ERROR: // error has already been issued break; default: info->is_error = true; @@ -1690,9 +1690,9 @@ void VarDeclEquals( SYMPTR sym, SYM_HANDLE sym_handle ) if( CurToken == T_LEFT_BRACE && CompFlags.auto_agg_inits && SimpleStruct( typ ) ) { - NextToken(); //T_LEFT_BRACE + NextToken(); /* skip T_LEFT_BRACE */ InitStructUnionVar( sym, sym_handle, 0, typ ); - NextToken(); //T_RIGHT_BRACE + NextToken(); /* skip T_RIGHT_BRACE */ } else { AggregateVarDeclEquals( sym, sym_handle ); } diff --git a/bld/cc/c/cfeinfo.c b/bld/cc/c/cfeinfo.c index 7909cc75fd..f925ac051f 100644 --- a/bld/cc/c/cfeinfo.c +++ b/bld/cc/c/cfeinfo.c @@ -327,13 +327,17 @@ static aux_info *InfoLookup( SYMPTR sym ) aux_entry *ent; name = sym->name; - inf = &DefaultInfo; /* assume default */ + /* + * assume default + */ + inf = &DefaultInfo; if( name == NULL ) return( inf ); ent = AuxLookup( name ); if( ent != NULL ) inf = ent->info; - if( ( ent == NULL ) || (sym->flags & SYM_INTRINSIC) ) { + if( ( ent == NULL ) + || (sym->flags & SYM_INTRINSIC) ) { if( sym->flags & SYM_DEFINED ) return( inf ); if( (sym->flags & SYM_INTRINSIC) == 0 ) { @@ -368,14 +372,16 @@ static aux_info *InfoLookup( SYMPTR sym ) inf->cclass = FECALL_GEN_NONE; inf->cclass_target = (WatcallInfo.cclass_target & FECALL_X86_FAR_CALL) | FECALL_X86_MODIFY_EXACT; - if( (sym->flags & SYM_INTRINSIC) && ( ent != NULL ) ) { + if( (sym->flags & SYM_INTRINSIC) + && ( ent != NULL ) ) { inf->cclass |= ent->info->cclass; inf->cclass_target |= ent->info->cclass_target; } inf->code = ifunc->code; inf->parms = ifunc->parms; inf->returns = ifunc->returns; - if( !HW_CEqual( inf->returns, HW_xAX ) && !HW_CEqual( inf->returns, HW_EMPTY ) ) { + if( !HW_CEqual( inf->returns, HW_xAX ) + && !HW_CEqual( inf->returns, HW_EMPTY ) ) { inf->cclass_target |= FECALL_X86_SPECIAL_RETURN; } HW_CAsgn( inf->streturn, HW_EMPTY ); @@ -395,13 +401,17 @@ aux_info *FindInfo( SYMPTR sym, SYM_HANDLE sym_handle ) TYPEPTR typ; aux_info *inf; - inf = &DefaultInfo; /* assume default */ + /* + * assume default + */ + inf = &DefaultInfo; if( sym_handle == SYM_NULL ) return( inf ); SymGet( sym, sym_handle ); #if _CPU == 386 - if( (sym_handle == SymSTOSB) || (sym_handle == SymSTOSD) ) { + if( (sym_handle == SymSTOSB) + || (sym_handle == SymSTOSD) ) { return( &STOSBInfo ); } else if( sym_handle == SymFinally ) { InlineInfo = WatcallInfo; @@ -434,8 +444,10 @@ aux_info *FindInfo( SYMPTR sym, SYM_HANDLE sym_handle ) } } #if _CPU == 386 - if( (inf->flags & AUX_FLAG_FAR16) || (sym->mods & FLAG_FAR16) ) { - if( (sym->mods & MASK_LANGUAGES) == LANG_PASCAL || (inf->cclass & FECALL_GEN_REVERSE_PARMS) ) { + if( (inf->flags & AUX_FLAG_FAR16) + || (sym->mods & FLAG_FAR16) ) { + if( (sym->mods & MASK_LANGUAGES) == LANG_PASCAL + || (inf->cclass & FECALL_GEN_REVERSE_PARMS) ) { return( &Far16PascalInfo ); } else { return( &Far16CdeclInfo ); @@ -522,7 +534,8 @@ static call_class_target getCallClassTarget( SYM_HANDLE sym_handle ) if( sym.flags & SYM_FUNCTION ) { #if _CPU == 8086 if( TargetSystem == TS_WINDOWS ) { - if( inf == &PascalInfo || inf == &CdeclInfo ) { + if( inf == &PascalInfo + || inf == &CdeclInfo ) { cclass_target |= FECALL_X86_PROLOG_FAT_WINDOWS; } } @@ -580,20 +593,22 @@ static call_class_target getCallClassTarget( SYM_HANDLE sym_handle ) static void addDefaultLibs( void ) /********************************* * NextLibrary - * Called (indirectly) from the code generator to inject automagically defined symbols. + * Called (indirectly) from the code generator to inject automagically defined symbols. * Inputs: - * index (n-1) - * Usually called from a loop until we return 0/NULL to show no more libraries - * request - * FEINF_NEXT_LIBRARY - * examines the current flags to see if any libraries should be - * automagically referenced and returns the relevant index if so. - * FEINF_LIBRARY_NAME - * returns the requested name. + * index (n-1) + * Usually called from a loop until we return 0/NULL to show no more libraries + * request + * FEINF_NEXT_LIBRARY + * examines the current flags to see if any libraries should be + * automagically referenced and returns the relevant index if so. + * FEINF_LIBRARY_NAME + * returns the requested name. */ { if( CompFlags.emit_library_names ) { - if( _HAS_ANY_MAIN || CompFlags.pragma_library || CompFlags.emit_all_default_libs ) { + if( _HAS_ANY_MAIN + || CompFlags.pragma_library + || CompFlags.emit_all_default_libs ) { AddLibraryName( CLIB_Name + 1, CLIB_Name[0] ); } AddLibraryName( MATHLIB_Name + 1, MATHLIB_Name[0] ); @@ -627,7 +642,8 @@ static CGPOINTER NextLibrary( int index, aux_class request ) /* * return library name, or */ - if( request == FEINF_LIBRARY_NAME || name == NULL ) + if( request == FEINF_LIBRARY_NAME + || name == NULL ) return( (CGPOINTER)name ); /* * library index @@ -638,22 +654,22 @@ static CGPOINTER NextLibrary( int index, aux_class request ) static CGPOINTER NextAlias( int index, aux_class request ) /********************************************************* * NextAlias - * Called (indirectly) from the code generator to go through the list of - * linker aliases. + * Called (indirectly) from the code generator to go through the list of + * linker aliases. * Inputs: - * index (n-1) - * Called from a loop until we return 0/NULL to show no more aliases - * request - * FEINF_NEXT_ALIAS - * returns the index of next alias in the list, or zero if none. - * FEINF_ALIAS_NAME - * returns the alias name, or NULL if alias refers to a symbol. - * FEINF_ALIAS_SYMBOL - * returns the alias symbol, or NULL if alias refers to a name. - * FEINF_ALIAS_SUBST_NAME - * returns the name to be substituted for the alias, or NULL. - * FEINF_ALIAS_SUBST_SYMBOL - * returns the symbol to be substituted for the alias, or NULL. + * index (n-1) + * Called from a loop until we return 0/NULL to show no more aliases + * request + * FEINF_NEXT_ALIAS + * returns the index of next alias in the list, or zero if none. + * FEINF_ALIAS_NAME + * returns the alias name, or NULL if alias refers to a symbol. + * FEINF_ALIAS_SYMBOL + * returns the alias symbol, or NULL if alias refers to a name. + * FEINF_ALIAS_SUBST_NAME + * returns the name to be substituted for the alias, or NULL. + * FEINF_ALIAS_SUBST_SYMBOL + * returns the symbol to be substituted for the alias, or NULL. * * Note: One of FEINF_ALIAS..._NAME and FEINF_ALIAS..._SYMBOL will always be 0/NULL * and the other will be valid, depending on which form of the pragma was used. @@ -689,7 +705,7 @@ static CGPOINTER NextAlias( int index, aux_class request ) return( (CGPOINTER)subst_name ); } else if( request == FEINF_ALIAS_SUBST_SYMBOL ) { return( (CGPOINTER)subst_sym ); - } else { // this had better be a FEINF_NEXT_ALIAS request + } else { /* this had better be a FEINF_NEXT_ALIAS request */ return( (CGPOINTER)(pointer_uint)index ); } } @@ -773,7 +789,7 @@ static const char *GetNamePattern( SYM_HANDLE sym_handle ) } } #ifdef __SEH__ - } // close that else + } /* close that else */ #endif return( pattern ); } @@ -804,7 +820,6 @@ const char *FEExtName( CGSYM_HANDLE sym_handle, int request ) } } - static void addDefaultImports( void ) { typedef enum { @@ -837,7 +852,8 @@ static void addDefaultImports( void ) control = CM_NULL; } #if _CPU == 8086 - if( (control & CM_WINMAIN) && CompFlags.has_winmain || (TargetSwitches & CGSW_X86_WINDOWS) && CompFlags.has_main ) { + if( (control & CM_WINMAIN) && CompFlags.has_winmain + || (TargetSwitches & CGSW_X86_WINDOWS) && CompFlags.has_main ) { #else if( (control & CM_WINMAIN) && CompFlags.has_winmain ) { #endif @@ -876,7 +892,8 @@ static void addDefaultImports( void ) } } #endif - if( CompFlags.pgm_used_8087 || CompFlags.float_used ) { + if( CompFlags.pgm_used_8087 + || CompFlags.float_used ) { if( GET_FPU( ProcRevision ) & FPU_EMU ) { #if _CPU == 8086 AddExtRefN( "__init_87_emulator" ); @@ -942,7 +959,8 @@ static void addDefaultImports( void ) /* * handle NetWare */ - if( TargetSystem == TS_NETWARE || TargetSystem == TS_NETWARE5 ) { + if( TargetSystem == TS_NETWARE + || TargetSystem == TS_NETWARE5 ) { /* * is target NETWARE or NETWARE5? */ @@ -973,20 +991,20 @@ static void addDefaultImports( void ) static CGPOINTER NextImport( int index, aux_class request ) /********************************************************** * NextImport - * Called (indirectly) from the code generator to inject automagically defined symbols. + * Called (indirectly) from the code generator to inject automagically defined symbols. * Inputs: - * index (n-1) - * Usually called from a loop until we return 0/NULL to show no more symbols - * are required. - * request - * FEINF_NEXT_IMPORT - * examines the current flags to see if any symbols should be - * automagically inserted and returns the relevant index if so. - * FEINF_IMPORT_NAME - * returns the requested name. if we have returned an index for - * the current compiler settings we should be called with a valid - * index but we still perform exactly the same checks as this is - * good practise. + * index (n-1) + * Usually called from a loop until we return 0/NULL to show no more symbols + * are required. + * request + * FEINF_NEXT_IMPORT + * examines the current flags to see if any symbols should be + * automagically inserted and returns the relevant index if so. + * FEINF_IMPORT_NAME + * returns the requested name. if we have returned an index for + * the current compiler settings we should be called with a valid + * index but we still perform exactly the same checks as this is + * good practise. */ { char *name; @@ -1016,7 +1034,8 @@ static CGPOINTER NextImport( int index, aux_class request ) /* * return the import name, or */ - if( request == FEINF_IMPORT_NAME || name == NULL ) + if( request == FEINF_IMPORT_NAME + || name == NULL ) return( (CGPOINTER)name ); /* * return the index @@ -1051,7 +1070,8 @@ static CGPOINTER NextImportS( int index, aux_class request ) /* * return the import symbol, or */ - if( request == FEINF_IMPORT_NAME_S || symbol == NULL ) + if( request == FEINF_IMPORT_NAME_S + || symbol == NULL ) return( (CGPOINTER)symbol ); /* * return the index @@ -1192,7 +1212,8 @@ CGPOINTER FEAuxInfo( CGPOINTER req_handle, aux_class request ) #endif inf = FindInfo( &sym, req_handle ); if( req_handle != NULL ) { - if( inf->code == NULL && VarFunc( &sym ) ) { + if( inf->code == NULL + && VarFunc( &sym ) ) { return( (CGPOINTER)DefaultVarParms ); } } diff --git a/bld/cc/c/cscan.c b/bld/cc/c/cscan.c index 5f811ec66a..17ddcaccb0 100644 --- a/bld/cc/c/cscan.c +++ b/bld/cc/c/cscan.c @@ -53,7 +53,7 @@ extern const unsigned char TokValue[]; static FCB rescan_tmp_file; #ifdef CHAR_MACRO -static int SavedCurrChar; // used when get tokens from macro +static int SavedCurrChar; /* used when get tokens from macro */ #endif static unsigned char ClassTable[LCHR_MAX]; @@ -260,7 +260,8 @@ static TOKEN doScanName( void ) getIDName( CurrChar ); WriteBufferNullChar(); - if( CompFlags.doing_macro_expansion || (PPControl & PPCTL_NO_EXPAND) ) { + if( CompFlags.doing_macro_expansion + || (PPControl & PPCTL_NO_EXPAND) ) { return( T_ID ); } mentry = MacroLookup( Buffer ); @@ -298,7 +299,10 @@ static TOKEN doScanName( void ) return( token ); } } - DoMacroExpansion( mentry ); /* start macro expansion */ + /* + * start macro expansion + */ + DoMacroExpansion( mentry ); token = GetMacroToken(); #if 0 if( MacroPtr != NULL ) { @@ -369,12 +373,16 @@ static TOKEN doScanFloat( bool hex ) } } token = T_CONSTANT; - if( c == 'e' || c == 'E' || ( hex && ( c == 'p' || c == 'P' ) ) ) { + if( c == 'e' + || c == 'E' + || ( hex && ( c == 'p' || c == 'P' ) ) ) { c = WriteBufferCharNextChar( c ); - if( c == '+' || c == '-' ) { + if( c == '+' + || c == '-' ) { c = WriteBufferCharNextChar( c ); } - if( c < '0' || c > '9' ) { + if( c < '0' + || c > '9' ) { token = T_BAD_TOKEN; BadTokenInfo = ERR_INVALID_FLOATING_POINT_CONSTANT; } @@ -382,10 +390,12 @@ static TOKEN doScanFloat( bool hex ) c = WriteBufferCharNextChar( c ); } } - if( c == 'f' || c == 'F' ) { + if( c == 'f' + || c == 'F' ) { WriteBufferCharNextChar( c ); ConstType = TYP_FLOAT; - } else if( c == 'l' || c == 'L' ) { + } else if( c == 'l' + || c == 'L' ) { WriteBufferCharNextChar( c ); if( CompFlags.use_long_double ) { ConstType = TYP_LONG_DOUBLE; @@ -447,7 +457,8 @@ static TOKEN doScanPPNumber( void ) for( ;; ) { prevc = c; c = NextChar(); - if( (CharSet[c] & (C_AL | C_DI)) || c == '.' ) { + if( (CharSet[c] & (C_AL | C_DI)) + || c == '.' ) { WriteBufferChar( c ); } else if( ( prevc == 'e' || prevc == 'E' || CompVars.cstd >= CSTD_C99 && ( prevc == 'p' || prevc == 'P' ) ) @@ -461,10 +472,16 @@ static TOKEN doScanPPNumber( void ) * // users want: 0xaa0e + 0x02 * // not: 0xaa0e + A2 (but, this is what ISO C requires!) */ - prevc = c; //advance to next + /* + * advance to next + */ + prevc = c; c = NextChar(); if( (CharSet[c] & C_DI) == 0 ) { - break; //allow e+ + /* + * allow e+ + */ + break; } WriteBufferChar( c ); } @@ -492,7 +509,8 @@ static TOKEN ScanPPDot( void ) Buffer[0] = '.'; TokenLen = 1; c = NextChar(); - if( c >= '0' && c <= '9' ) { + if( c >= '0' + && c <= '9' ) { Buffer[TokenLen++] = c; return( doScanPPNumber() ); } else { @@ -517,8 +535,12 @@ static cnv_cc Cnv8( void ) value = 0; while( len-- > 0 ) { c = *curr; - if( value & 0xE0000000 ) - goto is64; /* 64 bit */ + if( value & 0xE0000000 ) { + /* + * 64 bit + */ + goto is64; + } value = value * 8 + c - '0'; ++curr; } @@ -529,7 +551,7 @@ static cnv_cc Cnv8( void ) U32ToU64( value, &value64 ); do { c = *curr; - if( U64Cnv8( &value64, c-'0' ) ) { + if( U64Cnv8( &value64, c - '0' ) ) { ret = CNV_OVR; } ++curr; @@ -548,13 +570,20 @@ static cnv_cc Cnv16( void ) uint64 value64; cnv_cc ret; - curr = Buffer + 2; // skip 0x thing + /* + * skip 0x thing + */ + curr = Buffer + 2; len = TokenLen - 2; value = 0; while( len-- > 0 ) { c = *curr; - if( value & 0xF0000000 ) - goto is64; /* 64 bit */ + if( value & 0xF0000000 ) { + /* + * 64 bit + */ + goto is64; + } if( CharSet[c] & C_HX ) { c = (( c | HEX_MASK ) - HEX_BASE ) + 10 + '0'; } @@ -571,7 +600,7 @@ static cnv_cc Cnv16( void ) if( CharSet[c] & C_HX ) { c = (( c | HEX_MASK ) - HEX_BASE ) + 10 + '0'; } - if( U64Cnv16( &value64, c-'0' ) ) { + if( U64Cnv16( &value64, c - '0' ) ) { ret = CNV_OVR; } ++curr; @@ -614,7 +643,7 @@ static cnv_cc Cnv10( void ) U32ToU64( value, &value64 ); do { c = *curr; - if( U64Cnv10( &value64, c-'0') ) { + if( U64Cnv10( &value64, c - '0') ) { ret = CNV_OVR; } ++curr; @@ -642,7 +671,8 @@ static TOKEN doScanNum( void ) Constant = 0; if( CurrChar == '0' ) { c = NextChar(); - if( c == 'x' || c == 'X' ) { + if( c == 'x' + || c == 'X' ) { bad_token_type = ERR_INVALID_HEX_CONSTANT; con.form = CON_HEX; c = WriteBufferCharNextChar( c ); @@ -651,34 +681,49 @@ static TOKEN doScanNum( void ) } if( CompVars.cstd >= CSTD_C99 ) { - if ( c == '.' || c == 'p' || c == 'P' ) { + if( c == '.' + || c == 'p' + || c == 'P' ) { return( doScanFloat( true ) ); } } - if( TokenLen == 2 ) { /* just collected a 0x */ + if( TokenLen == 2 ) { + /* + * just collected a 0x + */ BadTokenInfo = ERR_INVALID_HEX_CONSTANT; con.form = CON_ERR; if( diagnose_lex_error() ) { CErr1( ERR_INVALID_HEX_CONSTANT ); } } - } else { /* scan octal number */ + } else { + /* + * scan octal number + */ unsigned char digit_mask; bad_token_type = ERR_INVALID_OCTAL_CONSTANT; con.form = CON_OCT; digit_mask = 0; - // if collecting tokens for macro preprocessor, allow 8 and 9 - // since the argument may be used in with # or ##. + /* + * if collecting tokens for macro preprocessor, allow 8 and 9 + * since the argument may be used in with # or ##. + */ while( c >= '0' && c <= '9' ) { digit_mask |= c; c = WriteBufferCharNextChar( c ); } - if( c == '.' || c == 'e' || c == 'E' ) { + if( c == '.' + || c == 'e' + || c == 'E' ) { return( doScanFloat( false ) ); } - if( digit_mask & 0x08 ) { /* if digit 8 or 9 somewhere */ + if( digit_mask & 0x08 ) { + /* + * if digit 8 or 9 somewhere + */ BadTokenInfo = ERR_INVALID_OCTAL_CONSTANT; con.form = CON_ERR; if( diagnose_lex_error() ) { @@ -686,14 +731,19 @@ static TOKEN doScanNum( void ) } } } - } else { /* scan decimal number */ + } else { + /* + * scan decimal number + */ bad_token_type = ERR_INVALID_CONSTANT; con.form = CON_DEC; c = NextChar(); while( c >= '0' && c <= '9' ) { c = WriteBufferCharNextChar( c ); } - if( c == '.' || c == 'e' || c == 'E' ) { + if( c == '.' + || c == 'e' + || c == 'E' ) { return( doScanFloat( false ) ); } } @@ -711,14 +761,21 @@ static TOKEN doScanNum( void ) ov = CNV_32; } con.suffix = SUFF_NONE; - if( c == 'l' || c == 'L' ) { // collect suffix + /* + * collect suffix + */ + if( c == 'l' + || c == 'L' ) { c = WriteBufferCharNextChar( c ); - if( c == 'u' || c == 'U' ) { + if( c == 'u' + || c == 'U' ) { c = WriteBufferCharNextChar( c ); con.suffix = SUFF_UL; - } else if( c == 'l' || c == 'L' ) { + } else if( c == 'l' + || c == 'L' ) { c = WriteBufferCharNextChar( c ); - if( c == 'u' || c == 'U' ) { + if( c == 'u' + || c == 'U' ) { c = WriteBufferCharNextChar( c ); con.suffix = SUFF_ULL; } else { @@ -727,27 +784,33 @@ static TOKEN doScanNum( void ) } else { con.suffix = SUFF_L; } - } else if( c == 'u' || c == 'U' ) { + } else if( c == 'u' + || c == 'U' ) { c = WriteBufferCharNextChar( c ); - if( c == 'l' || c == 'L' ) { + if( c == 'l' + || c == 'L' ) { c = WriteBufferCharNextChar( c ); - if( c == 'l' || c == 'L' ) { + if( c == 'l' + || c == 'L' ) { c = WriteBufferCharNextChar( c ); con.suffix = SUFF_ULL; } else { con.suffix = SUFF_UL; } - } else if( c == 'i' || c == 'I' ) { + } else if( c == 'i' + || c == 'I' ) { c = WriteBufferCharNextChar( c ); con.suffix = SUFF_UI; } else { con.suffix = SUFF_U; } - } else if( c == 'i' || c == 'I' ) { + } else if( c == 'i' + || c == 'I' ) { c = WriteBufferCharNextChar( c ); con.suffix = SUFF_I; } - if( con.suffix == SUFF_UI || con.suffix == SUFF_I ) { + if( con.suffix == SUFF_UI + || con.suffix == SUFF_I ) { unsigned_32 value; value = 0; @@ -787,20 +850,24 @@ static TOKEN doScanNum( void ) CErr1( ERR_INVALID_CONSTANT ); } } - if( ov == CNV_64 && value < 64 ) { + if( ov == CNV_64 + && value < 64 ) { BadTokenInfo = ERR_CONSTANT_TOO_BIG; Constant = Constant64.u._32[I64LO32]; if( diagnose_lex_error() ) { CWarn1( ERR_CONSTANT_TOO_BIG ); } } - } else if( ov == CNV_32 && con.suffix != SUFF_LL && con.suffix != SUFF_ULL ) { + } else if( ov == CNV_32 + && con.suffix != SUFF_LL + && con.suffix != SUFF_ULL ) { switch( con.suffix ) { case SUFF_NONE: if( Constant <= TARGET_INT_MAX ) { ConstType = TYP_INT; #if TARGET_INT < TARGET_LONG - } else if( Constant <= TARGET_UINT_MAX && con.form != CON_DEC ) { + } else if( Constant <= TARGET_UINT_MAX + && con.form != CON_DEC ) { ConstType = TYP_UINT; } else if( Constant <= 0x7fffffffU ) { ConstType = TYP_LONG; @@ -971,7 +1038,7 @@ static bool checkDelim2( TOKEN *token, TOKEN last ) *token = T_LE; break; } - if( last == T_COLON ) { /* <: */ + if( last == T_COLON ) { /* <: */ *token = T_LEFT_BRACKET; break; } @@ -1068,9 +1135,11 @@ static TOKEN ScanDelim2( void ) token = TokValue[CurrChar]; Buffer[0] = CurrChar; TokenLen = 1; - if( (CharSet[NextChar()] & C_DE) && checkDelim2( &token, TokValue[CurrChar] ) ) { + if( (CharSet[NextChar()] & C_DE) + && checkDelim2( &token, TokValue[CurrChar] ) ) { Buffer[TokenLen++] = CurrChar; - if( (CharSet[NextChar()] & C_DE) && checkDelim2( &token, TokValue[CurrChar] ) ) { + if( (CharSet[NextChar()] & C_DE) + && checkDelim2( &token, TokValue[CurrChar] ) ) { Buffer[TokenLen++] = CurrChar; NextChar(); } @@ -1098,7 +1167,7 @@ static void doScanComment( void ) if( CompFlags.cpp_keep_comments ) { CppPrtChar( '*' ); } - continue; //could be **/ + continue; // could be **/ } if( c == LCHR_EOF ) { break; @@ -1106,17 +1175,20 @@ static void doScanComment( void ) if( c == '\n' ) { CppPrtChar( c ); NewLineStartPos( SrcFile ); - } else if( c != '\r' && CompFlags.cpp_keep_comments ) { + } else if( c != '\r' + && CompFlags.cpp_keep_comments ) { CppPrtChar( c ); } c = NextChar(); } CppComment( '\0' ); } else { - // make '/' anf '\n' a special characters so that we only have - // to do one test for each character inside the main loop - CharSet['/'] |= C_EX; // make '/' special character - CharSet['\n'] |= C_EX; // make '\n' special character + /* + * make '/' anf '\n' a special characters so that we only have + * to do one test for each character inside the main loop + */ + CharSet['/'] |= C_EX; /* make '/' special character */ + CharSet['\n'] |= C_EX; /* make '\n' special character */ c = '\0'; for( ; c != LCHR_EOF; ) { if( c == '\n' ) { @@ -1136,7 +1208,9 @@ static void doScanComment( void ) if( c == '/' ) { if( prev_char == '*' ) break; - // get next character and see if it is '*' for nested comment + /* + * get next character and see if it is '*' for nested comment + */ c = NextChar(); if( c == '*' ) { c = NextChar(); @@ -1145,13 +1219,15 @@ static void doScanComment( void ) CWarn2( ERR_NESTED_COMMENT, CommentLoc.line ); } } - // NextChar might not be pointing to GetNextChar at this point + /* + * NextChar might not be pointing to GetNextChar at this point + */ while( c != LCHR_EOF && NextChar != GetNextChar ) { c = NextChar(); } } - CharSet['\n'] &= ~C_EX; // undo '\n' special character - CharSet['/'] &= ~C_EX; // undo '/' special character + CharSet['\n'] &= ~C_EX; /* undo '\n' special character */ + CharSet['/'] &= ~C_EX; /* undo '/' special character */ } if( c != LCHR_EOF ) { CompFlags.scanning_comment = false; @@ -1170,12 +1246,13 @@ static TOKEN ScanSlash( void ) token = T_DIV; Buffer[0] = '/'; TokenLen = 1; - NextChar(); // can't inline this copy of NextChar - if( CurrChar == '=' ) { /* if second char is an = */ + NextChar(); /* can't inline this copy of NextChar */ + if( CurrChar == '=' ) { /* if second char is an = */ Buffer[TokenLen++] = '='; NextChar(); token = T_DIV_EQUAL; - } else if( CurrChar == '/' && !CompFlags.strict_ANSI ) { /* if C++ // style comment */ + } else if( CurrChar == '/' + && !CompFlags.strict_ANSI ) { /* if C++ // style comment */ if( CompFlags.cpp_mode ) { CppComment( '/' ); } @@ -1195,7 +1272,9 @@ static TOKEN ScanSlash( void ) break; if( CurrChar == '\0' ) break; - if( CompFlags.cpp_mode && CompFlags.cpp_keep_comments && CurrChar != '\r' ) { + if( CompFlags.cpp_mode + && CompFlags.cpp_keep_comments + && CurrChar != '\r' ) { CppPrtChar( CurrChar ); } } @@ -1246,13 +1325,19 @@ static msg_codes doScanHex( int max, escinp_fn ifn, escout_fn ofn ) --max; } Constant = value; - if( count == max ) { /* no characters matched */ - return( ERR_INVALID_HEX_CONSTANT ); /* indicate no characters matched */ + if( count == max ) { + /* + * indicate no characters matched + */ + return( ERR_INVALID_HEX_CONSTANT ); } if( too_big ) { return( ERR_CONSTANT_TOO_BIG ); } - return( ERR_NONE ); /* indicate characters were matched */ + /* + * indicate characters were matched + */ + return( ERR_NONE ); } int ESCChar( int c, escinp_fn ifn, msg_codes *perr_msg, escout_fn ofn ) @@ -1266,7 +1351,11 @@ int ESCChar( int c, escinp_fn ifn, msg_codes *perr_msg, escout_fn ofn ) int i; msg_codes err_msg; - if( c >= '0' && c <= '7' ) { /* get octal escape sequence */ + if( c >= '0' + && c <= '7' ) { + /* + * get octal escape sequence + */ n = 0; i = 3; while( i-- > 0 && c >= '0' && c <= '7' ) { @@ -1274,7 +1363,10 @@ int ESCChar( int c, escinp_fn ifn, msg_codes *perr_msg, escout_fn ofn ) n = n * 8 + c - '0'; c = ifn(); } - } else if( c == 'x' ) { /* get hex escape sequence */ + } else if( c == 'x' ) { + /* + * get hex escape sequence + */ OUTC( c ); err_msg = doScanHex( 127, ifn, ofn ); if( err_msg != ERR_NONE ) @@ -1347,31 +1439,39 @@ static TOKEN doScanCharConst( DATA_TYPE char_type ) token = T_CONSTANT; i = 0; for( ;; ) { - if( c == '\r' || c == '\n' ) { + if( c == '\r' + || c == '\n' ) { token = T_BAD_TOKEN; break; } if( c == '\\' ) { Buffer[TokenLen++] = '\\'; c = NextChar(); - if( c >= '0' && c <= '7' ) { + if( c >= '0' + && c <= '7' ) { n = c - '0'; Buffer[TokenLen++] = c; c = NextChar(); - if( c >= '0' && c <= '7' ) { + if( c >= '0' + && c <= '7' ) { n = n * 8 + c - '0'; Buffer[TokenLen++] = c; c = NextChar(); - if( c >= '0' && c <= '7' ) { + if( c >= '0' + && c <= '7' ) { n = n * 8 + c - '0'; Buffer[TokenLen++] = c; NextChar(); - if( n > 0377 && char_type != TYP_WCHAR ) { + if( n > 0377 + && char_type != TYP_WCHAR ) { BadTokenInfo = ERR_CONSTANT_TOO_BIG; if( diagnose_lex_error() ) { CWarn1( ERR_CONSTANT_TOO_BIG ); } - n &= 0377; // mask off high bits + /* + * mask off high bits + */ + n &= 0377; } } } @@ -1392,7 +1492,10 @@ static TOKEN doScanCharConst( DATA_TYPE char_type ) } else { Buffer[TokenLen++] = c; NextChar(); - if( CharSet[c] & C_DB ) { /* if double-byte char */ + if( CharSet[c] & C_DB ) { + /* + * if double-byte char + */ c = (c << 8) + (CurrChar & 0x00FF); if( char_type == TYP_WCHAR ) { if( CompFlags.jis_to_unicode ) { @@ -1424,7 +1527,8 @@ static TOKEN doScanCharConst( DATA_TYPE char_type ) /* * handle case where user wants a \ but doesn't escape it */ - if( c == '\'' && CurrChar != '\'' ) { + if( c == '\'' + && CurrChar != '\'' ) { token = T_BAD_TOKEN; break; } @@ -1448,8 +1552,10 @@ static TOKEN doScanCharConst( DATA_TYPE char_type ) } Buffer[TokenLen] = '\0'; ConstType = char_type; - if( char_type == TYP_CHAR && CompFlags.signed_char ) { - if( value < 256 && value > 127 ) { + if( char_type == TYP_CHAR + && CompFlags.signed_char ) { + if( value < 256 + && value > 127 ) { value -= 256; } } @@ -1537,22 +1643,36 @@ static TOKEN ScanString( void ) return( doScanString( false ) ); } -static TOKEN ScanWide( void ) // scan something that starts with L -/***************************/ +static TOKEN ScanWide( void ) +/**************************** + * scan something that starts with L + */ { int c; TOKEN token; c = NextChar(); - if( c == '"' ) { // L"abc" + if( c == '"' ) { + /* + * L"abc" + */ token = doScanString( true ); - } else { // regular identifier + } else { + /* + * regular identifier + */ Buffer[0] = 'L'; TokenLen = 1; - if( c == '\'' ) { // L'a' + if( c == '\'' ) { + /* + * L'a' + */ Buffer[TokenLen++] = '\''; token = doScanCharConst( TYP_WCHAR ); - } else { // regular identifier + } else { + /* + * regular identifier + */ token = doScanName(); } } @@ -1589,7 +1709,8 @@ static void SkipWhiteSpace( int c ) ScanWhiteSpace(); } else { while( CharSet[c] & C_WS ) { - if( c != '\r' && IS_PPCTL_NORMAL() ) { + if( c != '\r' + && IS_PPCTL_NORMAL() ) { CppPrtChar( c ); } c = NextChar(); @@ -1608,7 +1729,8 @@ void SkipAhead( void ) } if( CurrChar != '\n' ) break; - if( CompFlags.cpp_mode && IS_PPCTL_NORMAL() ) { + if( CompFlags.cpp_mode + && IS_PPCTL_NORMAL() ) { CppPrtChar( '\n' ); } NewLineStartPos( SrcFile ); @@ -1712,7 +1834,10 @@ static TOKEN (*ScanFunc[])( void ) = { TOKEN ScanToken( void ) /*********************/ { - TokenLoc = SrcFileLoc; /* remember line token starts on */ + /* + * remember line token starts on + */ + TokenLoc = SrcFileLoc; // TokenLen = 1; // Buffer[0] = CurrChar; return( (*ScanFunc[ClassTable[CurrChar]])() ); @@ -1737,8 +1862,10 @@ TOKEN NextToken( void ) return( CurToken ); } -TOKEN PPNextToken( void ) // called from macro pre-processor -/***********************/ +TOKEN PPNextToken( void ) +/************************ + * called from macro pre-processor + */ { do { if( MacroPtr == NULL ) { @@ -1782,10 +1909,11 @@ TOKEN ReScanToken( void ) CompFlags.rescan_buffer_done = false; CurrChar = NextChar(); - CompFlags.doing_macro_expansion = true; // return macros as ID's + CompFlags.doing_macro_expansion = true; /* return macros as ID's */ token = ScanToken(); CompFlags.doing_macro_expansion = false; - if( token == T_STRING && CompFlags.wide_char_string ) { + if( token == T_STRING + && CompFlags.wide_char_string ) { token = T_LSTRING; } SrcFile->src_ptr--; @@ -1839,19 +1967,30 @@ bool InitPPScan( void ) if( ScanFunc[SCAN_NUM] == ScanNum ) { ScanFunc[SCAN_NUM] = ScanPPDigit; ScanFunc[SCAN_DOT] = ScanPPDot; - return( true ); // indicate changed to PP mode + /* + * indicate changed to PP mode + */ + return( true ); } - return( false ); // indicate already in PP mode + /* + * indicate already in PP mode + */ + return( false ); } void FiniPPScan( bool ppscan_mode ) /********************************** * called when CollectParms() and * CDefine() are finished gathering tokens + * if InitPPScan() changed into PP mode + * reset back to normal mode */ { - if( ppscan_mode ) { // if InitPPScan() changed into PP mode - ScanFunc[SCAN_NUM] = ScanNum; // reset back to normal mode + if( ppscan_mode ) { + /* + * reset back to normal mode + */ + ScanFunc[SCAN_NUM] = ScanNum; ScanFunc[SCAN_DOT] = ScanDot; } } From d7c3b3e5c90e16dc7c8a825e60a638968a1ecca0 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Mon, 2 Oct 2023 13:16:36 +0200 Subject: [PATCH 192/258] rename files to follow standard naming rules --- bld/as/axp/c/alphafmt.c | 2 +- bld/as/axp/c/alphains.c | 8 +-- bld/as/axp/h/{alphafmt.inc => _axpfmt.h} | 1 + bld/as/axp/h/{insenum.inc => _insenum.h} | 1 + .../{mps/h/regclass.inc => axp/h/_regclass.h} | 1 + bld/as/axp/h/alphafmt.h | 3 +- bld/as/axp/h/axpfmt.inc | 58 +++++++++++++++++++ bld/as/axp/h/inslist.h | 5 +- bld/as/axp/h/register.h | 2 +- bld/as/c/asopernd.c | 2 +- bld/as/c/obj.c | 2 +- bld/as/c/sections.c | 3 +- bld/as/h/{sections.inc => _section.h} | 1 + bld/as/h/directiv.h | 3 +- bld/as/h/obj.h | 2 +- bld/as/mps/c/mipsfmt.c | 2 +- bld/as/mps/c/mipsins.c | 4 +- bld/as/mps/h/{insenum.inc => _insenum.h} | 1 + bld/as/mps/h/{mipsfmt.inc => _mipsfmt.h} | 0 .../{axp/h/regclass.inc => mps/h/_regclass.h} | 1 + bld/as/mps/h/inslist.h | 5 +- bld/as/mps/h/mipsfmt.h | 3 +- bld/as/mps/h/register.h | 2 +- bld/as/ppc/c/ppcfmt.c | 2 +- bld/as/ppc/h/{ppcfmt.inc => _ppcfmt.h} | 1 + bld/as/ppc/h/{regclass.inc => _regclass.h} | 1 + bld/as/ppc/h/inslist.h | 3 +- bld/as/ppc/h/ppcfmt.h | 3 +- bld/as/ppc/h/register.h | 2 +- 29 files changed, 99 insertions(+), 25 deletions(-) rename bld/as/axp/h/{alphafmt.inc => _axpfmt.h} (98%) rename bld/as/axp/h/{insenum.inc => _insenum.h} (97%) rename bld/as/{mps/h/regclass.inc => axp/h/_regclass.h} (95%) create mode 100644 bld/as/axp/h/axpfmt.inc rename bld/as/h/{sections.inc => _section.h} (96%) rename bld/as/mps/h/{insenum.inc => _insenum.h} (96%) rename bld/as/mps/h/{mipsfmt.inc => _mipsfmt.h} (100%) rename bld/as/{axp/h/regclass.inc => mps/h/_regclass.h} (95%) rename bld/as/ppc/h/{ppcfmt.inc => _ppcfmt.h} (99%) rename bld/as/ppc/h/{regclass.inc => _regclass.h} (95%) diff --git a/bld/as/axp/c/alphafmt.c b/bld/as/axp/c/alphafmt.c index 4dd9ce697e..40c0c65173 100644 --- a/bld/as/axp/c/alphafmt.c +++ b/bld/as/axp/c/alphafmt.c @@ -1074,7 +1074,7 @@ static void ITCallPAL( ins_table *table, instruction *ins, uint_32 *buffer, asm_ alpha_format AlphaFormatTable[] = { #define PICK( a, b, c, d, e ) { b, { c, d, e } }, - #include "alphafmt.inc" + #include "_axpfmt.h" #undef PICK }; diff --git a/bld/as/axp/c/alphains.c b/bld/as/axp/c/alphains.c index e1e655677f..2534a36b8a 100644 --- a/bld/as/axp/c/alphains.c +++ b/bld/as/axp/c/alphains.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2019 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -449,7 +449,7 @@ typedef void (*enumFunc_t)( ins_enum_method, uint_32, uint_8, void (*func)( qual static enumFunc_t enumFunc[] = { #define PICK( a, b ) b, - #include "insenum.inc" + #include "_insenum.h" #undef PICK }; @@ -465,7 +465,7 @@ static void enumInstructions( ins_enum_method method, void (*func)( qualifier_fl #if defined( _STANDALONE_ ) && defined( AS_DEBUG_DUMP ) static char *itStrings[] = { #define PICK( a, b, c, d, e ) #a, - #include "alphafmt.inc" + #include "_axpfmt.h" #undef PICK }; @@ -476,7 +476,7 @@ static void DumpITString( ins_template template ) static char *insEnumStrings[] = { #define PICK( a, b ) #a, - #include "insenum.inc" + #include "_insenum.h" #undef PICK }; diff --git a/bld/as/axp/h/alphafmt.inc b/bld/as/axp/h/_axpfmt.h similarity index 98% rename from bld/as/axp/h/alphafmt.inc rename to bld/as/axp/h/_axpfmt.h index 4742daa9eb..fbfc3efc89 100644 --- a/bld/as/axp/h/alphafmt.inc +++ b/bld/as/axp/h/_axpfmt.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== diff --git a/bld/as/axp/h/insenum.inc b/bld/as/axp/h/_insenum.h similarity index 97% rename from bld/as/axp/h/insenum.inc rename to bld/as/axp/h/_insenum.h index b36799fbbf..29c0580d37 100644 --- a/bld/as/axp/h/insenum.inc +++ b/bld/as/axp/h/_insenum.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== diff --git a/bld/as/mps/h/regclass.inc b/bld/as/axp/h/_regclass.h similarity index 95% rename from bld/as/mps/h/regclass.inc rename to bld/as/axp/h/_regclass.h index 2e96d4862e..a2061ad3d2 100644 --- a/bld/as/mps/h/regclass.inc +++ b/bld/as/axp/h/_regclass.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== diff --git a/bld/as/axp/h/alphafmt.h b/bld/as/axp/h/alphafmt.h index aeeb0e263c..57877c5f7a 100644 --- a/bld/as/axp/h/alphafmt.h +++ b/bld/as/axp/h/alphafmt.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -32,7 +33,7 @@ typedef enum { #define PICK( a, b, c, d, e ) a, - #include "alphafmt.inc" + #include "_axpfmt.h" #undef PICK } alpha_template; diff --git a/bld/as/axp/h/axpfmt.inc b/bld/as/axp/h/axpfmt.inc new file mode 100644 index 0000000000..fbfc3efc89 --- /dev/null +++ b/bld/as/axp/h/axpfmt.inc @@ -0,0 +1,58 @@ +/***************************************************************************** +* +* Open Watcom Project +* +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. +* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. +* +* ======================================================================== +* +* This file contains Original Code and/or Modifications of Original +* Code as defined in and that are subject to the Sybase Open Watcom +* Public License version 1.0 (the 'License'). You may not use this file +* except in compliance with the License. BY USING THIS FILE YOU AGREE TO +* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is +* provided with the Original Code and Modifications, and is also +* available at www.sybase.com/developer/opensource. +* +* The Original Code and all software distributed under the License are +* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM +* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR +* NON-INFRINGEMENT. Please see the License for the specific language +* governing rights and limitations under the License. +* +* ======================================================================== +* +* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE +* DESCRIBE IT HERE! +* +*****************************************************************************/ + + +PICK( IT_MEMORY_LDA, ITLoadAddress, OP_GPR, (OP_REG_INDIRECT | OP_IMMED), OP_NOTHING ) /* lda */ +//PICK( IT_MEMORY_LDAH, ITMemLDAH, OP_GPR, (OP_REG_INDIRECT | OP_IMMED), OP_NOTHING ) /* ldah */ +PICK( IT_MEMORY_ALL, ITMemAll, OP_GPR, (OP_REG_INDIRECT | OP_IMMED), OP_NOTHING ) /* ldl */ +PICK( IT_FP_MEMORY_ALL, ITMemAll, OP_FPR, OP_REG_INDIRECT, OP_NOTHING ) /* ldf */ +PICK( IT_MEMORY_A, ITMemA, OP_GPR, OP_NOTHING, OP_NOTHING ) /* rpcc */ +PICK( IT_MEMORY_B, ITMemB, OP_REG_INDIRECT, OP_NOTHING, OP_NOTHING ) /* fetch */ +PICK( IT_MEMORY_NONE, ITMemNone, OP_NOTHING, OP_NOTHING, OP_NOTHING ) /* mb */ +PICK( IT_MEMORY_JUMP, ITMemJump, (OP_GPR | OP_REG_INDIRECT | OP_IMMED), (OP_REG_INDIRECT | OP_NOTHING | OP_IMMED), (OP_IMMED | OP_NOTHING) ) /* jmp */ +PICK( IT_BRANCH, ITBranch, (OP_GPR | OP_IMMED), (OP_IMMED | OP_NOTHING), OP_NOTHING ) /* bsr */ +PICK( IT_FP_BRANCH, ITBranch, OP_FPR, OP_IMMED, OP_NOTHING ) /* fbeq */ +PICK( IT_OPERATE, ITOperate, OP_GPR, (OP_GPR | OP_IMMED), OP_GPR ) /* addl */ +PICK( IT_FP_OPERATE, ITFPOperate, OP_FPR, OP_FPR, OP_FPR ) /* cpys */ +PICK( IT_FP_CONVERT, ITFPConvert, OP_FPR, OP_FPR, OP_NOTHING ) /* cvtqs */ +PICK( IT_BR, ITBr, (OP_GPR | OP_IMMED), (OP_IMMED | OP_NOTHING), OP_NOTHING ) /* br */ +PICK( IT_MT_MF_FPCR, ITMTMFFpcr, OP_FPR, (OP_FPR | OP_NOTHING), OP_FPR ) /* mf_fpcr */ +PICK( IT_RET, ITRet, (OP_GPR | OP_NOTHING | OP_REG_INDIRECT | OP_IMMED), (OP_REG_INDIRECT | OP_NOTHING | OP_IMMED), (OP_IMMED | OP_NOTHING) ) /* ret */ +PICK( IT_PSEUDO_CLR, ITPseudoClr, OP_GPR, OP_NOTHING, OP_NOTHING ) /* clr */ +PICK( IT_PSEUDO_FCLR, ITPseudoFclr, OP_FPR, OP_NOTHING, OP_NOTHING ) /* fclr */ +PICK( IT_PSEUDO_MOV, ITPseudoMov, (OP_GPR | OP_IMMED), OP_GPR, OP_NOTHING ) /* mov */ +PICK( IT_PSEUDO_FMOV, ITPseudoFmov, OP_FPR, OP_FPR, OP_NOTHING ) /* fmov */ +PICK( IT_PSEUDO_NOT, ITPseudoNot, (OP_GPR | OP_IMMED), OP_GPR, OP_NOTHING ) /* not */ +PICK( IT_PSEUDO_NEGF, ITPseudoNegf, OP_FPR, OP_FPR, OP_NOTHING ) /* negf */ +PICK( IT_PSEUDO_FNEG, ITPseudoFneg, OP_FPR, OP_FPR, OP_NOTHING ) /* fneg */ +PICK( IT_PSEUDO_ABS, ITPseudoAbs, (OP_GPR | OP_IMMED), OP_GPR, OP_NOTHING ) /* absl */ +PICK( IT_CALL_PAL, ITCallPAL, OP_IMMED, OP_NOTHING, OP_NOTHING ) diff --git a/bld/as/axp/h/inslist.h b/bld/as/axp/h/inslist.h index 69d7b12498..763ec9a1c8 100644 --- a/bld/as/axp/h/inslist.h +++ b/bld/as/axp/h/inslist.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -50,7 +51,7 @@ typedef enum { typedef enum { #define PICK( a, b ) a, - #include "insenum.inc" + #include "_insenum.h" #undef PICK } ins_enum_method; // All the possible enumeration methods @@ -66,7 +67,7 @@ typedef enum { typedef enum { #define PICK( a, b ) OP_##a = b, - #include "regclass.inc" + #include "_regclass.h" #undef PICK OP_IMMED = (1 << REGCLASS_COUNT), // an immediate constant (could have reloc with it) OP_REG_INDIRECT = (1 << (REGCLASS_COUNT+1)), // register with an immediate attached diff --git a/bld/as/axp/h/register.h b/bld/as/axp/h/register.h index c3516de0a7..0f5c70112b 100644 --- a/bld/as/axp/h/register.h +++ b/bld/as/axp/h/register.h @@ -48,7 +48,7 @@ typedef uint_16 reg; typedef enum { #define PICK( a, b ) RC_##a, - #include "regclass.inc" + #include "_regclass.h" #undef PICK RC_LAST } reg_class; diff --git a/bld/as/c/asopernd.c b/bld/as/c/asopernd.c index 75e4c33bb1..67194acfd5 100644 --- a/bld/as/c/asopernd.c +++ b/bld/as/c/asopernd.c @@ -149,7 +149,7 @@ ins_operand *OpImmed( expr_tree *expr ) static op_type RegClassOpTypes[] = { #define PICK( a, b ) OP_##a, - #include "regclass.inc" + #include "_regclass.h" #undef PICK 0 }; diff --git a/bld/as/c/obj.c b/bld/as/c/obj.c index 88b3c6030e..800d99d1d4 100644 --- a/bld/as/c/obj.c +++ b/bld/as/c/obj.c @@ -90,7 +90,7 @@ typedef struct { static sect_info reservedSecInfo[] = { #define PICK( a, b, c, d ) { b, c, d }, - #include "sections.inc" + #include "_section.h" #undef PICK }; diff --git a/bld/as/c/sections.c b/bld/as/c/sections.c index 5f774c636e..84ce0d4a47 100644 --- a/bld/as/c/sections.c +++ b/bld/as/c/sections.c @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -109,7 +110,7 @@ void SectionInit( void ) { // make sure these names are in asdrectv.c (in table asm_directives[]) #define PICK( a,b,c,d ) SymSetSection( SymLookup( b ) ); - #include "sections.inc" + #include "_section.h" #undef PICK } diff --git a/bld/as/h/sections.inc b/bld/as/h/_section.h similarity index 96% rename from bld/as/h/sections.inc rename to bld/as/h/_section.h index 67829b0e2b..36ef25d0c1 100644 --- a/bld/as/h/sections.inc +++ b/bld/as/h/_section.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== diff --git a/bld/as/h/directiv.h b/bld/as/h/directiv.h index 1cbef2ad98..e993969a3b 100644 --- a/bld/as/h/directiv.h +++ b/bld/as/h/directiv.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -119,7 +120,7 @@ typedef enum { #endif #ifdef _STANDALONE_ #define PICK( a, b, c, d ) DT_SEC_##a, - #include "sections.inc" + #include "_section.h" #undef PICK DT_USERSEC_NEW, #endif diff --git a/bld/as/h/obj.h b/bld/as/h/obj.h index 31dff41334..9410dd5f63 100644 --- a/bld/as/h/obj.h +++ b/bld/as/h/obj.h @@ -36,7 +36,7 @@ typedef enum { #define PICK( a, b, c, d ) AS_SECTION_##a, - #include "sections.inc" + #include "_section.h" #undef PICK } reserved_section; diff --git a/bld/as/mps/c/mipsfmt.c b/bld/as/mps/c/mipsfmt.c index 34d979d537..e5904e6db6 100644 --- a/bld/as/mps/c/mipsfmt.c +++ b/bld/as/mps/c/mipsfmt.c @@ -1435,7 +1435,7 @@ static void ITPseudoAbs( ins_table *table, instruction *ins, uint_32 *buffer, as mips_format MIPSFormatTable[] = { #define PICK( a, b, c, d, e ) { b, { c, d, e } }, - #include "mipsfmt.inc" + #include "_mipsfmt.h" #undef PICK }; diff --git a/bld/as/mps/c/mipsins.c b/bld/as/mps/c/mipsins.c index e9b12d7087..a1f4725550 100644 --- a/bld/as/mps/c/mipsins.c +++ b/bld/as/mps/c/mipsins.c @@ -399,7 +399,7 @@ typedef void (*enumFunc_t)( ins_enum_method, uint_32, uint_8, void (*func)( qual static enumFunc_t enumFunc[] = { #define PICK( a, b ) b, - #include "insenum.inc" + #include "_insenum.h" #undef PICK }; @@ -426,7 +426,7 @@ static void DumpITString( ins_template template ) static char *insEnumStrings[] = { #define PICK( a, b ) #a, - #include "insenum.inc" + #include "_insenum.h" #undef PICK }; diff --git a/bld/as/mps/h/insenum.inc b/bld/as/mps/h/_insenum.h similarity index 96% rename from bld/as/mps/h/insenum.inc rename to bld/as/mps/h/_insenum.h index fc8de103f7..f7b10ebdee 100644 --- a/bld/as/mps/h/insenum.inc +++ b/bld/as/mps/h/_insenum.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== diff --git a/bld/as/mps/h/mipsfmt.inc b/bld/as/mps/h/_mipsfmt.h similarity index 100% rename from bld/as/mps/h/mipsfmt.inc rename to bld/as/mps/h/_mipsfmt.h diff --git a/bld/as/axp/h/regclass.inc b/bld/as/mps/h/_regclass.h similarity index 95% rename from bld/as/axp/h/regclass.inc rename to bld/as/mps/h/_regclass.h index 2e96d4862e..a2061ad3d2 100644 --- a/bld/as/axp/h/regclass.inc +++ b/bld/as/mps/h/_regclass.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== diff --git a/bld/as/mps/h/inslist.h b/bld/as/mps/h/inslist.h index 8bc3a6475c..f8afd5594f 100644 --- a/bld/as/mps/h/inslist.h +++ b/bld/as/mps/h/inslist.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -47,7 +48,7 @@ typedef enum { typedef enum { #define PICK( a, b ) a, - #include "insenum.inc" + #include "_insenum.h" #undef PICK } ins_enum_method; // All the possible enumeration methods @@ -63,7 +64,7 @@ typedef enum { typedef enum { #define PICK( a, b ) OP_##a = b, - #include "regclass.inc" + #include "_regclass.h" #undef PICK OP_IMMED = (1 << REGCLASS_COUNT), // an immediate constant (could have reloc with it) OP_REG_INDIRECT = (1 << (REGCLASS_COUNT+1)), // register with an immediate attached diff --git a/bld/as/mps/h/mipsfmt.h b/bld/as/mps/h/mipsfmt.h index 545731fcf3..c379a923f1 100644 --- a/bld/as/mps/h/mipsfmt.h +++ b/bld/as/mps/h/mipsfmt.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -31,6 +32,6 @@ typedef enum { #define PICK( a, b, c, d, e ) a, - #include "mipsfmt.inc" + #include "_mipsfmt.h" #undef PICK } mips_template; diff --git a/bld/as/mps/h/register.h b/bld/as/mps/h/register.h index cc89e40efa..d9081e3137 100644 --- a/bld/as/mps/h/register.h +++ b/bld/as/mps/h/register.h @@ -47,7 +47,7 @@ typedef uint_16 reg; typedef enum { #define PICK( a, b ) RC_##a, - #include "regclass.inc" + #include "_regclass.h" #undef PICK RC_LAST } reg_class; diff --git a/bld/as/ppc/c/ppcfmt.c b/bld/as/ppc/c/ppcfmt.c index d204660698..e3e0f4fd25 100644 --- a/bld/as/ppc/c/ppcfmt.c +++ b/bld/as/ppc/c/ppcfmt.c @@ -1387,7 +1387,7 @@ static void ITSMBSpec( ins_table *table, instruction *ins, uint_32 *buffer, asm_ ppc_format PPCFormatTable[] = { #define PICK( a, b, c, d, e, f, g ) { b, { c, d, e, f, g } }, - #include "ppcfmt.inc" + #include "_ppcfmt.h" #undef PICK }; diff --git a/bld/as/ppc/h/ppcfmt.inc b/bld/as/ppc/h/_ppcfmt.h similarity index 99% rename from bld/as/ppc/h/ppcfmt.inc rename to bld/as/ppc/h/_ppcfmt.h index 556127d87b..fa66486bb1 100644 --- a/bld/as/ppc/h/ppcfmt.inc +++ b/bld/as/ppc/h/_ppcfmt.h @@ -2,6 +2,7 @@ //* //* Open Watcom Project //* +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. //* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. //* //* ======================================================================== diff --git a/bld/as/ppc/h/regclass.inc b/bld/as/ppc/h/_regclass.h similarity index 95% rename from bld/as/ppc/h/regclass.inc rename to bld/as/ppc/h/_regclass.h index efad6394a5..80ecd77553 100644 --- a/bld/as/ppc/h/regclass.inc +++ b/bld/as/ppc/h/_regclass.h @@ -2,6 +2,7 @@ //* //* Open Watcom Project //* +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. //* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. //* //* ======================================================================== diff --git a/bld/as/ppc/h/inslist.h b/bld/as/ppc/h/inslist.h index da4c72b8ac..bd9c781322 100644 --- a/bld/as/ppc/h/inslist.h +++ b/bld/as/ppc/h/inslist.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -56,7 +57,7 @@ typedef enum { typedef enum { #define PICK( a, b ) OP_##a = b, - #include "regclass.inc" + #include "_regclass.h" #undef PICK OP_IMMED = (1 << REGCLASS_COUNT), // an immediate constant (could have reloc with it) OP_REG_INDIRECT = (1 << (REGCLASS_COUNT + 1)), // register with an immediate attached diff --git a/bld/as/ppc/h/ppcfmt.h b/bld/as/ppc/h/ppcfmt.h index f346f9870f..5fbb5bfe6f 100644 --- a/bld/as/ppc/h/ppcfmt.h +++ b/bld/as/ppc/h/ppcfmt.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -32,7 +33,7 @@ typedef enum { #define PICK( a, b, c, d, e, f, g ) a, - #include "ppcfmt.inc" + #include "_ppcfmt.h" #undef PICK } ppc_template; diff --git a/bld/as/ppc/h/register.h b/bld/as/ppc/h/register.h index 904f7fcb77..1712cd1f19 100644 --- a/bld/as/ppc/h/register.h +++ b/bld/as/ppc/h/register.h @@ -47,7 +47,7 @@ typedef uint_16 reg; typedef enum { #define PICK( a, b ) RC_##a, - #include "regclass.inc" + #include "_regclass.h" #undef PICK RC_LAST } reg_class; From 50a0bee580e51d5e67ab14ae4404ca00931aa48e Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Mon, 2 Oct 2023 13:41:12 +0200 Subject: [PATCH 193/258] fix damaged files --- bld/as/ppc/h/_ppcfmt.h | 60 ++++++++++++++++++++-------------------- bld/as/ppc/h/_regclass.h | 60 ++++++++++++++++++++-------------------- 2 files changed, 60 insertions(+), 60 deletions(-) diff --git a/bld/as/ppc/h/_ppcfmt.h b/bld/as/ppc/h/_ppcfmt.h index fa66486bb1..442426b75a 100644 --- a/bld/as/ppc/h/_ppcfmt.h +++ b/bld/as/ppc/h/_ppcfmt.h @@ -1,34 +1,34 @@ -//***************************************************************************** -//* -//* Open Watcom Project -//* +/***************************************************************************** +* +* Open Watcom Project +* * Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. -//* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. -//* -//* ======================================================================== -//* -//* This file contains Original Code and/or Modifications of Original -//* Code as defined in and that are subject to the Sybase Open Watcom -//* Public License version 1.0 (the 'License'). You may not use this file -//* except in compliance with the License. BY USING THIS FILE YOU AGREE TO -//* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is -//* provided with the Original Code and Modifications, and is also -//* available at www.sybase.com/developer/opensource. -//* -//* The Original Code and all software distributed under the License are -//* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER -//* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM -//* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF -//* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR -//* NON-INFRINGEMENT. Please see the License for the specific language -//* governing rights and limitations under the License. -//* -//* ======================================================================== -//* -//* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE -//* DESCRIBE IT HERE! -//* -//***************************************************************************** +* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. +* +* ======================================================================== +* +* This file contains Original Code and/or Modifications of Original +* Code as defined in and that are subject to the Sybase Open Watcom +* Public License version 1.0 (the 'License'). You may not use this file +* except in compliance with the License. BY USING THIS FILE YOU AGREE TO +* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is +* provided with the Original Code and Modifications, and is also +* available at www.sybase.com/developer/opensource. +* +* The Original Code and all software distributed under the License are +* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM +* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR +* NON-INFRINGEMENT. Please see the License for the specific language +* governing rights and limitations under the License. +* +* ======================================================================== +* +* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE +* DESCRIBE IT HERE! +* +*****************************************************************************/ PICK( IT_BIN, ITBinary, OP_GPR, OP_GPR, OP_GPR, OP_NOTHING, OP_NOTHING ) /* addx */ diff --git a/bld/as/ppc/h/_regclass.h b/bld/as/ppc/h/_regclass.h index 80ecd77553..2b6e1305e3 100644 --- a/bld/as/ppc/h/_regclass.h +++ b/bld/as/ppc/h/_regclass.h @@ -1,34 +1,34 @@ -//***************************************************************************** -//* -//* Open Watcom Project -//* +/***************************************************************************** +* +* Open Watcom Project +* * Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. -//* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. -//* -//* ======================================================================== -//* -//* This file contains Original Code and/or Modifications of Original -//* Code as defined in and that are subject to the Sybase Open Watcom -//* Public License version 1.0 (the 'License'). You may not use this file -//* except in compliance with the License. BY USING THIS FILE YOU AGREE TO -//* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is -//* provided with the Original Code and Modifications, and is also -//* available at www.sybase.com/developer/opensource. -//* -//* The Original Code and all software distributed under the License are -//* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER -//* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM -//* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF -//* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR -//* NON-INFRINGEMENT. Please see the License for the specific language -//* governing rights and limitations under the License. -//* -//* ======================================================================== -//* -//* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE -//* DESCRIBE IT HERE! -//* -//***************************************************************************** +* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. +* +* ======================================================================== +* +* This file contains Original Code and/or Modifications of Original +* Code as defined in and that are subject to the Sybase Open Watcom +* Public License version 1.0 (the 'License'). You may not use this file +* except in compliance with the License. BY USING THIS FILE YOU AGREE TO +* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is +* provided with the Original Code and Modifications, and is also +* available at www.sybase.com/developer/opensource. +* +* The Original Code and all software distributed under the License are +* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM +* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR +* NON-INFRINGEMENT. Please see the License for the specific language +* governing rights and limitations under the License. +* +* ======================================================================== +* +* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE +* DESCRIBE IT HERE! +* +*****************************************************************************/ #define REGCLASS_COUNT 5 // must set up to correspond the number of From 37d1d46b74a2f9e3bc302059e5247f90e79e9ab4 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Mon, 2 Oct 2023 14:28:39 +0200 Subject: [PATCH 194/258] cleanup risc assembler code rename function to more transparent name --- bld/as/axp/c/alphafmt.c | 18 ++++++------- bld/as/mps/c/mipsfmt.c | 26 +++++++++--------- bld/as/ppc/c/ppcfmt.c | 58 ++++++++++++++++++++--------------------- 3 files changed, 51 insertions(+), 51 deletions(-) diff --git a/bld/as/axp/c/alphafmt.c b/bld/as/axp/c/alphafmt.c index 40c0c65173..4471cc5350 100644 --- a/bld/as/axp/c/alphafmt.c +++ b/bld/as/axp/c/alphafmt.c @@ -98,11 +98,11 @@ static owl_reloc_type reloc_translate[] = { OWL_RELOC_JUMP_REL, // jump hint }; -static bool ensureOpAbsolute( ins_operand *op, uint_8 opIdx ) +static bool checkOpAbsolute( ins_operand *op, uint_8 op_idx ) //*********************************************************** { if( OP_HAS_RELOC( op ) ) { - Error( RELOC_NOT_ALLOWED, opIdx ); + Error( RELOC_NOT_ALLOWED, op_idx ); return( false ); } return( true ); @@ -382,12 +382,12 @@ static void doMov( uint_32 *buffer, ins_operand *operands[], domov_option m_opt extra = _Rb( RegIndex( op0->reg ) ); } else if( ( op0->constant & 0xff ) == op0->constant ) { // OP_IMMED implied extra = _LIT( op0->constant ); // this lit is between 0..255 - (void)ensureOpAbsolute( op0, 0 ); + (void)checkOpAbsolute( op0, 0 ); } else if( m_opt == DOMOV_ABS ) { abs_val = abs( op0->constant ); if( ( abs_val & 0xff ) == abs_val ) { extra = _LIT( abs_val ); // this lit is between 0..255 - // ensureOpAbsolute( op0, 0 ); should be done before calling doMov + // checkOpAbsolute( op0, 0 ); should be done before calling doMov } else { ready = false; } @@ -400,7 +400,7 @@ static void doMov( uint_32 *buffer, ins_operand *operands[], domov_option m_opt } // Otherwise it's OP_IMMED with a greater than 8-bit literal. // We'll then use multiple LDA, LDAH instructions to load the literal. - if( !ensureOpAbsolute( op0, 0 ) ) + if( !checkOpAbsolute( op0, 0 ) ) return; numExtendedIns += load32BitLiteral( buffer, op0, op1, m_opt ) - 1; } @@ -819,7 +819,7 @@ static void ITOperate( ins_table *table, instruction *ins, uint_32 *buffer, asm_ } else { // OP_IMMED assert( op->type == OP_IMMED ); extra = _LIT( op->constant ); - (void)ensureOpAbsolute( op, 1 ); + (void)checkOpAbsolute( op, 1 ); } fc = getFuncCode( table, ins ); doOpcodeFcRaRc( buffer, table->opcode, fc, @@ -956,7 +956,7 @@ static void ITPseudoNot( ins_table *table, instruction *ins, uint_32 *buffer, as } else { // OP_IMMED assert( op->type == OP_IMMED ); extra = _LIT( op->constant ); - (void)ensureOpAbsolute( op, 0 ); + (void)checkOpAbsolute( op, 0 ); } fc = getFuncCode( table, ins ); doOpcodeFcRaRc( buffer, table->opcode, fc, ZERO_REG_IDX, @@ -1003,7 +1003,7 @@ static void ITPseudoAbs( ins_table *table, instruction *ins, uint_32 *buffer, as if( src_op->type == OP_IMMED ) { // Then just evaluate it and do a mov instead. // mov abs(src_op->constant), d_reg - if( ensureOpAbsolute( src_op, 0 ) ) { + if( checkOpAbsolute( src_op, 0 ) ) { doMov( buffer, ins->operands, DOMOV_ABS ); } return; @@ -1058,7 +1058,7 @@ static void ITCallPAL( ins_table *table, instruction *ins, uint_32 *buffer, asm_ assert( ins->num_operands == 1 ); op = ins->operands[0]; - (void)ensureOpAbsolute( op, 0 ); + (void)checkOpAbsolute( op, 0 ); constant = op->constant; opcode = ( constant & 0xfC000000 ) >> 26; if( opcode != 0x00 && diff --git a/bld/as/mps/c/mipsfmt.c b/bld/as/mps/c/mipsfmt.c index e5904e6db6..3666bdf517 100644 --- a/bld/as/mps/c/mipsfmt.c +++ b/bld/as/mps/c/mipsfmt.c @@ -127,11 +127,11 @@ static uint_32 cop_codes[4] = { }; -static bool ensureOpAbsolute( ins_operand *op, uint_8 opIdx ) +static bool checkOpAbsolute( ins_operand *op, uint_8 op_idx ) //*********************************************************** { if( OP_HAS_RELOC( op ) ) { - Error( RELOC_NOT_ALLOWED, opIdx ); + Error( RELOC_NOT_ALLOWED, op_idx ); return( false ); } return( true ); @@ -464,12 +464,12 @@ static void doMov( uint_32 *buffer, ins_operand *operands[], domov_option m_opt doOpcodeFcRsRt( buffer, OPCODE_BIS, FUNCCODE_BIS, ZERO_REG_IDX, RegIndex( op1->reg ), extra ); } else if( ( op0->constant & 0xff ) == op0->constant ) { // OP_IMMED implied extra = _LIT( op0->constant ); // this lit is between 0..255 - ensureOpAbsolute( op0, 0 ); + checkOpAbsolute( op0, 0 ); doOpcodeFcRsRt( buffer, OPCODE_BIS, FUNCCODE_BIS, ZERO_REG_IDX, RegIndex( op1->reg ), extra ); } else if( ( -op0->constant & 0xff ) == -op0->constant && m_opt == DOMOV_ABS ) { // -255..0 extra = _LIT( -op0->constant ); // this lit is between 0..255 /* - * ensureOpAbsolute( op0, 0 ); should be done before calling doMov + * checkOpAbsolute( op0, 0 ); should be done before calling doMov */ doOpcodeFcRsRt( buffer, OPCODE_BIS, FUNCCODE_BIS, ZERO_REG_IDX, RegIndex( op1->reg ), extra ); } else { @@ -477,7 +477,7 @@ static void doMov( uint_32 *buffer, ins_operand *operands[], domov_option m_opt * Otherwise it's OP_IMMED with a greater than 8-bit literal. * We'll then use multiple LDA, LDAH instructions to load the literal. */ - if( ensureOpAbsolute( op0, 0 ) ) { + if( checkOpAbsolute( op0, 0 ) ) { numExtendedIns += load32BitLiteral( buffer, op0, op1, m_opt ) - 1; } } @@ -495,7 +495,7 @@ static void doLoadImm( uint_32 *buffer, ins_operand *operands[] ) op0 = operands[0]; op1 = operands[1]; - ensureOpAbsolute( op1, 1 ); + checkOpAbsolute( op1, 1 ); reg = RegIndex( op0->reg ); value = op1->constant; @@ -539,7 +539,7 @@ static void ITSysCode( ins_table *table, instruction *ins, uint_32 *buffer, asm_ assert( ins->num_operands < 2 ); if( ins->num_operands > 0 ) { op = ins->operands[0]; - ensureOpAbsolute( op, 0 ); + checkOpAbsolute( op, 0 ); constant = op->constant; } else { constant = 0; @@ -558,7 +558,7 @@ static void ITTrap( ins_table *table, instruction *ins, uint_32 *buffer, asm_rel if( ins->num_operands > 2 ) { op = ins->operands[2]; - ensureOpAbsolute( op, 2 ); + checkOpAbsolute( op, 2 ); code = op->constant; } else { code = 0; @@ -579,7 +579,7 @@ static void ITLoadUImm( ins_table *table, instruction *ins, uint_32 *buffer, asm assert( ins->num_operands == 2 ); op = ins->operands[1]; - ensureOpAbsolute( op, 1 ); + checkOpAbsolute( op, 1 ); doOpcodeIType( buffer, table->opcode, RegIndex( ins->operands[0]->reg ), 0, op->constant ); } @@ -594,7 +594,7 @@ static void ITTrapImm( ins_table *table, instruction *ins, uint_32 *buffer, asm_ assert( ins->num_operands == 2 ); op = ins->operands[1]; - ensureOpAbsolute( op, 1 ); + checkOpAbsolute( op, 1 ); doOpcodeIType( buffer, table->opcode, table->funccode, RegIndex( ins->operands[0]->reg ), op->constant ); } @@ -1100,7 +1100,7 @@ static void ITOperateImm( ins_table *table, instruction *ins, uint_32 *buffer, a assert( ins->num_operands == 3 ); op = ins->operands[2]; - ensureOpAbsolute( op, 2 ); + checkOpAbsolute( op, 2 ); doOpcodeFcRsRtImm( buffer, table->opcode, table->funccode, RegIndex( ins->operands[1]->reg ), RegIndex( ins->operands[0]->reg ), op->constant ); @@ -1332,7 +1332,7 @@ static void ITPseudoNot( ins_table *table, instruction *ins, uint_32 *buffer, as } else { // OP_IMMED assert( op->type == OP_IMMED ); extra = _LIT( op->constant ); - (void)ensureOpAbsolute( op, 0 ); + (void)checkOpAbsolute( op, 0 ); } fc = getFuncCode( table, ins ); doOpcodeFcRsRt( buffer, table->opcode, fc, ZERO_REG_IDX, @@ -1384,7 +1384,7 @@ static void ITPseudoAbs( ins_table *table, instruction *ins, uint_32 *buffer, as * Then just evaluate it and do a mov instead. * mov abs(src_op->constant), d_reg */ - if( ensureOpAbsolute( src_op, 0 ) ) { + if( checkOpAbsolute( src_op, 0 ) ) { doMov( buffer, ins->operands, DOMOV_ABS ); } return; diff --git a/bld/as/ppc/c/ppcfmt.c b/bld/as/ppc/c/ppcfmt.c index e3e0f4fd25..c823691da3 100644 --- a/bld/as/ppc/c/ppcfmt.c +++ b/bld/as/ppc/c/ppcfmt.c @@ -101,11 +101,11 @@ static bool ensureTypeCorrect( ins_operand *op, op_type type, uint_8 opIdx ) return( true ); } -static bool ensureOpAbsolute( ins_operand *op, uint_8 opIdx ) +static bool checkOpAbsolute( ins_operand *op, uint_8 op_idx ) //*********************************************************** { if( ( op->flags & ( RELOC | UNNAMED_RELOC ) ) ) { - Error( RELOC_NOT_ALLOWED, opIdx ); + Error( RELOC_NOT_ALLOWED, op_idx ); return( false ); } return( true ); @@ -217,12 +217,12 @@ static void doReloc( asm_reloc *reloc, ins_operand *op, owl_reloc_type rtype, in */ { assert( rtype != OWL_RELOC_JUMP_ABS && rtype != OWL_RELOC_BRANCH_ABS ); - if( ( op->flags & RELOC ) == RELOC ) { + if( op->flags & RELOC ) { reloc->target.sym = op->reloc.target.ptr; reloc->type = relocType( op->reloc.type, rtype, _IsAbsolute( flags ) ); reloc->is_unnamed = false; reloc->valid = true; - } else if( ( op->flags & UNNAMED_RELOC ) == UNNAMED_RELOC ) { + } else if( op->flags & UNNAMED_RELOC ) { reloc->target.label_num = op->reloc.target.label; reloc->type = relocType( op->reloc.type, rtype, _IsAbsolute( flags ) ); reloc->is_unnamed = true; @@ -385,7 +385,7 @@ static void ITBranchCond( ins_table *table, instruction *ins, uint_32 *buffer, a assert( ins->num_operands == 3 ); for( ctr = 0; ctr < 3; ++ctr ) { op[ctr] = ins->operands[ctr]; - if( ( ctr < 2 ) && !ensureOpAbsolute( op[ctr], ctr ) ) { + if( ( ctr < 2 ) && !checkOpAbsolute( op[ctr], ctr ) ) { return; } } @@ -408,7 +408,7 @@ static void ITBranchSpec( ins_table *table, instruction *ins, uint_32 *buffer, a // flags = ( ins->format->flags & table->optional ) | table->required; for( ctr = 0; ctr < 2; ++ctr ) { op[ctr] = ins->operands[ctr]; - if( !ensureOpAbsolute( op[ctr], ctr ) ) { + if( !checkOpAbsolute( op[ctr], ctr ) ) { return; } } @@ -448,7 +448,7 @@ static void ITCmp( ins_table *table, instruction *ins, uint_32 *buffer, asm_relo if( ( L_bit & 1 ) != L_bit ) { Error( OP_OUT_OF_RANGE, ctr ); } - if( ensureOpAbsolute( op[ctr], ctr ) ) { + if( checkOpAbsolute( op[ctr], ctr ) ) { opRa = op[++ctr]; opRb = op[++ctr]; doEncode3( buffer, table->primary, table->secondary, @@ -487,7 +487,7 @@ static void ITCmpImmed( ins_table *table, instruction *ins, uint_32 *buffer, asm if( ( L_bit & 1 ) != L_bit ) { Error( OP_OUT_OF_RANGE, ctr ); } - if( ensureOpAbsolute( op[ctr], ctr ) ) { + if( checkOpAbsolute( op[ctr], ctr ) ) { opRa = op[++ctr]; opSimm = op[++ctr]; doEncode2( buffer, table->primary, ( crfIdx << 2 ) | L_bit, @@ -576,7 +576,7 @@ static void ITMfspr( ins_table *table, instruction *ins, uint_32 *buffer, asm_re if( !SPRValidate( const_op->constant ) ) { Error( BAD_REG_ENCODING, 1, "SPR" ); } - if( ensureOpAbsolute( const_op, 1 ) ) { + if( checkOpAbsolute( const_op, 1 ) ) { doEncodeSPR( buffer, table->primary, table->secondary, RegIndex( ins->operands[0]->reg ), const_op->constant, ( ins->format->flags & table->optional ) | table->required ); @@ -595,7 +595,7 @@ static void ITMfsr( ins_table *table, instruction *ins, uint_32 *buffer, asm_rel if( const_op->constant > 0xf ) { Error( OP_OUT_OF_RANGE, 1 ); } - if( ensureOpAbsolute( const_op, 1 ) ) { + if( checkOpAbsolute( const_op, 1 ) ) { doEncode3( buffer, table->primary, table->secondary, RegIndex( ins->operands[0]->reg ), const_op->constant, 0, ( ins->format->flags & table->optional ) | table->required ); @@ -626,7 +626,7 @@ static void ITMftb( ins_table *table, instruction *ins, uint_32 *buffer, asm_rel if( const_op->constant != 0x188 && const_op->constant != 0x1a8 ) { Error( BAD_REG_ENCODING, 1, "TBR" ); } - if( ensureOpAbsolute( const_op, 1 ) ) { + if( checkOpAbsolute( const_op, 1 ) ) { flags = ( ins->format->flags & table->optional ) | table->required; *buffer = _Opcode( table->primary ) | _Opcode2( table->secondary ) | _D( RegIndex( ins->operands[0]->reg ) ) | @@ -647,7 +647,7 @@ static void ITMtcrf( ins_table *table, instruction *ins, uint_32 *buffer, asm_re if( const_op->constant > 0xff ) { Error( OP_OUT_OF_RANGE, 0 ); } - if( ensureOpAbsolute( const_op, 0 ) ) { + if( checkOpAbsolute( const_op, 0 ) ) { flags = ( ins->format->flags & table->optional ) | table->required; *buffer = _Opcode( table->primary ) | _Opcode2( table->secondary ) | _S( RegIndex( ins->operands[1]->reg ) ) | @@ -674,7 +674,7 @@ static void ITMtfsf( ins_table *table, instruction *ins, uint_32 *buffer, asm_re if( opFM->constant > 0xff ) { Error( OP_OUT_OF_RANGE, 0 ); } - if( ensureOpAbsolute( opFM, 0 ) ) { + if( checkOpAbsolute( opFM, 0 ) ) { flags = ( ins->format->flags & table->optional ) | table->required; *buffer = _Opcode( table->primary ) | _Opcode2( table->secondary ) | _FM( opFM->constant ) | _B( RegIndex( ins->operands[1]->reg ) ) | @@ -694,7 +694,7 @@ static void ITMtfsfImmed( ins_table *table, instruction *ins, uint_32 *buffer, a if( const_op->constant > 0xff ) { Error( OP_OUT_OF_RANGE, 1 ); } - if( ensureOpAbsolute( const_op, 1 ) ) { + if( checkOpAbsolute( const_op, 1 ) ) { doEncode3( buffer, table->primary, table->secondary, RegIndex( ins->operands[0]->reg ) << 2, 0, const_op->constant << 1, ( ins->format->flags & table->optional ) | table->required ); @@ -714,7 +714,7 @@ static void ITMtspr( ins_table *table, instruction *ins, uint_32 *buffer, asm_re Error( BAD_REG_ENCODING, 0, "SPR" ); return; } - if( ensureOpAbsolute( const_op, 0 ) ) { + if( checkOpAbsolute( const_op, 0 ) ) { doEncodeSPR( buffer, table->primary, table->secondary, RegIndex( ins->operands[1]->reg ), const_op->constant, ( ins->format->flags & table->optional ) | table->required ); @@ -733,7 +733,7 @@ static void ITMtsr( ins_table *table, instruction *ins, uint_32 *buffer, asm_rel if( const_op->constant > 0xf ) { Error( OP_OUT_OF_RANGE, 0 ); } - if( ensureOpAbsolute( const_op, 1 ) ) { + if( checkOpAbsolute( const_op, 1 ) ) { doEncode3( buffer, table->primary, table->secondary, RegIndex( ins->operands[1]->reg ), const_op->constant, 0, ( ins->format->flags & table->optional ) | table->required ); @@ -825,7 +825,7 @@ static void ITLswi( ins_table *table, instruction *ins, uint_32 *buffer, asm_rel assert( ins->num_operands == 3 ); op = ins->operands[2]; - if( ensureOpAbsolute( op, 2 ) ) { + if( checkOpAbsolute( op, 2 ) ) { doEncode3( buffer, table->primary, table->secondary, RegIndex( ins->operands[0]->reg ), RegIndex( ins->operands[1]->reg ), op->constant, @@ -842,7 +842,7 @@ static void ITShift( ins_table *table, instruction *ins, uint_32 *buffer, asm_re assert( ins->num_operands == 3 ); op = ins->operands[2]; - if( ensureOpAbsolute( op, 2 ) ) { + if( checkOpAbsolute( op, 2 ) ) { doEncode3( buffer, table->primary, table->secondary, RegIndex( ins->operands[1]->reg ), RegIndex( ins->operands[0]->reg ), op->constant, @@ -861,7 +861,7 @@ static void ITShiftImmed( ins_table *table, instruction *ins, uint_32 *buffer, a assert( ins->num_operands == 5 ); for( ctr = 0; ctr < 3; ++ctr ) { const_op[ctr] = ins->operands[ctr + 2]; - if( !ensureOpAbsolute( const_op[ctr], ctr + 2 ) ) { + if( !checkOpAbsolute( const_op[ctr], ctr + 2 ) ) { return; } } @@ -882,7 +882,7 @@ static void ITShiftIndex( ins_table *table, instruction *ins, uint_32 *buffer, a assert( ins->num_operands == 5 ); for( ctr = 0; ctr < 2; ++ctr ) { const_op[ctr] = ins->operands[ctr + 3]; - if( !ensureOpAbsolute( const_op[ctr], ctr + 3 ) ) { + if( !checkOpAbsolute( const_op[ctr], ctr + 3 ) ) { return; } } @@ -912,7 +912,7 @@ static void ITTrap( ins_table *table, instruction *ins, uint_32 *buffer, asm_rel assert( ins->num_operands == 3 ); op = ins->operands[0]; - if( ensureOpAbsolute( op, 0 ) ) { + if( checkOpAbsolute( op, 0 ) ) { doEncode3( buffer, table->primary, table->secondary, op->constant, RegIndex( ins->operands[1]->reg ), RegIndex( ins->operands[2]->reg ), ( ins->format->flags & table->optional ) | table->required ); @@ -926,7 +926,7 @@ static void ITTrapImmed( ins_table *table, instruction *ins, uint_32 *buffer, as assert( ins->num_operands == 3 ); op0 = ins->operands[0]; - if( ensureOpAbsolute( op0, 0 ) ) { + if( checkOpAbsolute( op0, 0 ) ) { op2 = ins->operands[2]; doEncode2( buffer, table->primary, op0->constant, RegIndex( ins->operands[1]->reg ), op2->constant, @@ -982,7 +982,7 @@ static void ITSMSubImmed( ins_table *table, instruction *ins, uint_32 *buffer, a assert( ins->num_operands == 3 ); op = ins->operands[2]; - if( ensureOpAbsolute( op, 0 ) ) { + if( checkOpAbsolute( op, 0 ) ) { doEncode2( buffer, table->primary, RegIndex( ins->operands[0]->reg ), RegIndex( ins->operands[1]->reg ), -op->constant, ( ins->format->flags & table->optional ) | table->required ); @@ -1064,7 +1064,7 @@ static void ITSMExtlwi( ins_table *table, instruction *ins, uint_32 *buffer, asm assert( ins->num_operands == 4 ); for( ctr = 0; ctr < 2; ++ctr ) { const_op[ctr] = ins->operands[ctr + 2]; - if( !ensureOpAbsolute( const_op[ctr], ctr + 2 ) ) { + if( !checkOpAbsolute( const_op[ctr], ctr + 2 ) ) { return; } } @@ -1087,7 +1087,7 @@ static void ITSMSrwi( ins_table *table, instruction *ins, uint_32 *buffer, asm_r assert( ins->num_operands == 3 ); const_op = ins->operands[2]; - if( !ensureOpAbsolute( const_op, 2 ) ) + if( !checkOpAbsolute( const_op, 2 ) ) return; n = const_op->constant; switch( table->special ) { @@ -1129,7 +1129,7 @@ static void ITSMInslw( ins_table *table, instruction *ins, uint_32 *buffer, asm_ assert( ins->num_operands == 4 ); for( ctr = 0; ctr < 2; ++ctr ) { const_op[ctr] = ins->operands[ctr + 2]; - if( !ensureOpAbsolute( const_op[ctr], ctr + 2 ) ) { + if( !checkOpAbsolute( const_op[ctr], ctr + 2 ) ) { return; } } @@ -1205,7 +1205,7 @@ static void ITSMMovSprNCover( bool isMoveTo, ins_table *table, instruction *ins, idx1 = 0; } op = ins->operands[idx0]; - if( !ensureOpAbsolute( op, idx0 ) ) + if( !checkOpAbsolute( op, idx0 ) ) return; if( ( op->constant & 3 ) != op->constant ) { Error( OP_OUT_OF_RANGE, idx0 ); @@ -1301,7 +1301,7 @@ static void ITSMBC( ins_table *table, instruction *ins, uint_32 *buffer, asm_rel valueBI = RegCrfToBI( op0->reg ); break; case OP_IMMED: - if( !ensureOpAbsolute( op0, 0 ) ) + if( !checkOpAbsolute( op0, 0 ) ) return; // fall through case OP_BI: @@ -1370,7 +1370,7 @@ static void ITSMBSpec( ins_table *table, instruction *ins, uint_32 *buffer, asm_ valueBI = RegCrfToBI( op0->reg ); break; case OP_IMMED: - if( !ensureOpAbsolute( op0, 0 ) ) + if( !checkOpAbsolute( op0, 0 ) ) return; // fall through case OP_BI: From 80929583dcec46cf444bb0b44f5d9a4acf4f8fad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Mal=C3=A1k?= Date: Mon, 2 Oct 2023 17:02:05 +0200 Subject: [PATCH 195/258] Create mirror.yml --- .github/workflows/mirror.yml | 1 + 1 file changed, 1 insertion(+) create mode 100644 .github/workflows/mirror.yml diff --git a/.github/workflows/mirror.yml b/.github/workflows/mirror.yml new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/.github/workflows/mirror.yml @@ -0,0 +1 @@ + From 493f7f25d448a70f89912c5a9c2d26cb5f6437c9 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Mon, 2 Oct 2023 22:35:44 +0200 Subject: [PATCH 196/258] cleanup risc assembler code correct type mismatches --- bld/as/axp/c/alphafmt.c | 34 +++---- bld/as/axp/h/register.h | 5 +- bld/as/mps/c/mipsfmt.c | 201 +++++++++++++++++++++------------------- bld/as/mps/h/register.h | 5 +- bld/as/ppc/c/ppcfmt.c | 47 ++++++---- bld/as/ppc/h/register.h | 5 +- 6 files changed, 158 insertions(+), 139 deletions(-) diff --git a/bld/as/axp/c/alphafmt.c b/bld/as/axp/c/alphafmt.c index 4471cc5350..ba9df837a0 100644 --- a/bld/as/axp/c/alphafmt.c +++ b/bld/as/axp/c/alphafmt.c @@ -98,8 +98,8 @@ static owl_reloc_type reloc_translate[] = { OWL_RELOC_JUMP_REL, // jump hint }; -static bool checkOpAbsolute( ins_operand *op, uint_8 op_idx ) -//*********************************************************** +static bool checkOpAbsolute( ins_operand *op, int op_idx ) +//******************************************************** { if( OP_HAS_RELOC( op ) ) { Error( RELOC_NOT_ALLOWED, op_idx ); @@ -218,8 +218,8 @@ static ins_funccode getFuncCode( ins_table *table, instruction *ins ) return( fc ); } -static void doOpcodeRaRb( uint_32 *buffer, ins_opcode opcode, uint_8 ra, uint_8 rb, uint_32 remain ) -//************************************************************************************************** +static void doOpcodeRaRb( uint_32 *buffer, ins_opcode opcode, reg_idx ra, reg_idx rb, uint_32 remain ) +//**************************************************************************************************** { *buffer = _Opcode( opcode ) | _Ra( ra ) | _Rb( rb ) | remain; } @@ -256,8 +256,8 @@ static void doAutoVar( asm_reloc *reloc, op_reloc_target targ, uint_32 *buffer, } #endif -static unsigned ldaConst32( uint_32 *buffer, uint_8 d_reg, uint_8 s_reg, ins_operand *op, op_const c, asm_reloc *reloc, bool force_pair ) -/**************************************************************************************************************************************** +static unsigned ldaConst32( uint_32 *buffer, reg_idx d_reg, reg_idx s_reg, ins_operand *op, op_const c, asm_reloc *reloc, bool force_pair ) +/****************************************************************************************************************************************** * LDA-LDAH sequence for 32-bit constants * Given: lda $d_reg, foobar+c($s_reg) * info for foobar is stored in op @@ -269,7 +269,7 @@ static unsigned ldaConst32( uint_32 *buffer, uint_8 d_reg, uint_8 s_reg, ins_ope int ctr; unsigned ret = 1; int_16 low, high[2]; - uint_8 base_reg; + reg_idx base_reg; owl_reloc_type type; bool hi_reloc_emitted = false; @@ -317,15 +317,13 @@ static unsigned ldaConst32( uint_32 *buffer, uint_8 d_reg, uint_8 s_reg, ins_ope if( !hi_reloc_emitted && force_pair ) { // no LDAH has been generated yet // force_pair => no modifier should've been specified // We are asked to force one, so here - doOpcodeRaRb( buffer, OPCODE_LDAH, d_reg, s_reg, - _Memory_disp( 0 ) ); + doOpcodeRaRb( buffer, OPCODE_LDAH, d_reg, s_reg, _Memory_disp( 0 ) ); doReloc( reloc, op, OWL_RELOC_HALF_HI, buffer ); ++buffer; ++ret; } base_reg = ( ret == 1 ? s_reg : d_reg ); - doOpcodeRaRb( buffer, OPCODE_LDA, d_reg, base_reg, - _Memory_disp( low ) ); + doOpcodeRaRb( buffer, OPCODE_LDA, d_reg, base_reg, _Memory_disp( low ) ); if( reloc ) { doReloc( reloc, op, OWL_RELOC_HALF_LO, buffer ); } @@ -333,8 +331,8 @@ static unsigned ldaConst32( uint_32 *buffer, uint_8 d_reg, uint_8 s_reg, ins_ope } #if 0 -static unsigned forceLoadAddressComplete( uint_8 d_reg, uint_8 s_reg, ins_operand *op, uint_32 *buffer, asm_reloc *reloc ) -/************************************************************************************************************************* +static unsigned forceLoadAddressComplete( reg_idx d_reg, reg_idx s_reg, ins_operand *op, uint_32 *buffer, asm_reloc *reloc ) +/*************************************************************************************************************************** * * Generate: * LDAH $d_reg, h^foo($s_reg) @@ -342,12 +340,10 @@ static unsigned forceLoadAddressComplete( uint_8 d_reg, uint_8 s_reg, ins_operan * store them in buffer[0], buffer[1] */ { - doOpcodeRaRb( buffer, OPCODE_LDAH, d_reg, s_reg, - _Memory_disp( 0 ) ); + doOpcodeRaRb( buffer, OPCODE_LDAH, d_reg, s_reg, _Memory_disp( 0 ) ); doReloc( reloc, op, OWL_RELOC_HALF_HI, buffer ); buffer++; - doOpcodeRaRb( buffer, OPCODE_LDA, d_reg, d_reg, - _Memory_disp( op->constant ) ); + doOpcodeRaRb( buffer, OPCODE_LDA, d_reg, d_reg, _Memory_disp( op->constant ) ); doReloc( reloc, op, OWL_RELOC_HALF_LO, buffer ); return( 2 ); } @@ -536,8 +532,8 @@ static void ITMemB( ins_table *table, instruction *ins, uint_32 *buffer, asm_rel _Mem_Func( table->funccode ) ); } -static void doMemJump( uint_32 *buffer, ins_table *table, uint_8 ra, uint_8 rb, ins_operand *addr_op, int_32 hint, asm_reloc *reloc ) -//*********************************************************************************************************************************** +static void doMemJump( uint_32 *buffer, ins_table *table, reg_idx ra, reg_idx rb, ins_operand *addr_op, int_32 hint, asm_reloc *reloc ) +//************************************************************************************************************************************* { // Note that addr_op maybe NULL. If not, addr_op->constant == hint. assert( addr_op == NULL || addr_op->constant == hint ); diff --git a/bld/as/axp/h/register.h b/bld/as/axp/h/register.h index 0f5c70112b..96abb1ffec 100644 --- a/bld/as/axp/h/register.h +++ b/bld/as/axp/h/register.h @@ -36,7 +36,7 @@ #define MakeReg( c, i ) ( ( (i) & 0xff ) | ( (int)(c) << 8 ) ) #define RegClass( r ) ( ( (r) >> 8 ) & 0xff ) -#define RegIndex( r ) ( (r) & 0xff ) +#define RegIndex( r ) ((reg_idx)((r) & 0xff)) #define NULL_REG_IDX 0 #define NULL_REG MakeReg( RC_NOTHING, NULL_REG_IDX ) @@ -44,7 +44,8 @@ #define ZERO_REG MakeReg( RC_GPR, ZERO_REG_IDX ) #define AT_REG MakeReg( RC_GPR, AT_REG_IDX ) -typedef uint_16 reg; +typedef uint_16 reg; +typedef uint_8 reg_idx; typedef enum { #define PICK( a, b ) RC_##a, diff --git a/bld/as/mps/c/mipsfmt.c b/bld/as/mps/c/mipsfmt.c index 3666bdf517..f10a53e857 100644 --- a/bld/as/mps/c/mipsfmt.c +++ b/bld/as/mps/c/mipsfmt.c @@ -127,8 +127,8 @@ static uint_32 cop_codes[4] = { }; -static bool checkOpAbsolute( ins_operand *op, uint_8 op_idx ) -//*********************************************************** +static bool checkOpAbsolute( ins_operand *op, int op_idx ) +//******************************************************** { if( OP_HAS_RELOC( op ) ) { Error( RELOC_NOT_ALLOWED, op_idx ); @@ -262,15 +262,15 @@ static void doOpcodeJType( uint_32 *buffer, uint_8 opcode ) } -static void doOpcodeIType( uint_32 *buffer, uint_8 opcode, uint_8 rt, uint_8 rs, signed_16 immed ) -//************************************************************************************************ +static void doOpcodeIType( uint_32 *buffer, uint_8 opcode, reg_idx rt, reg_idx rs, int_32 imm ) +//************************************************************************************************** { - *buffer = _Opcode( opcode ) | _Rs( rs ) | _Rt( rt ) | _SignedImmed( immed ); + *buffer = _Opcode( opcode ) | _Rs( rs ) | _Rt( rt ) | _SignedImmed( imm ); } -static void doOpcodeRType( uint_32 *buffer, uint_8 opcode, uint_8 fc, uint_8 rd, uint_8 rs, uint_8 rt ) -//***************************************************************************************************** +static void doOpcodeRType( uint_32 *buffer, uint_8 opcode, uint_8 fc, reg_idx rd, reg_idx rs, reg_idx rt ) +//******************************************************************************************************** { *buffer = _Opcode( opcode ) | _Rs( rs ) | _Rt( rt ) | _Rd( rd ) | _Function( fc ); } @@ -287,15 +287,15 @@ static void doOpcodeCopOp( uint_32 *buffer, uint_8 opcode, uint_8 fc, uint_32 ex } #if 0 -static void doOpcodeIShift( uint_32 *buffer, uint_8 fc, uint_8 rd, uint_8 rt, uint_8 sa ) -//*************************************************************************************** +static void doOpcodeIShift( uint_32 *buffer, uint_8 fc, reg_idx rd, reg_idx rt, uint_8 sa ) +//***************************************************************************************** { *buffer = _Opcode( 0 ) | _Rs( 0 ) | _Rt( rt ) | _Rd( rd ) | _Shift( sa ) | _Function( fc ); } -static void doOpcodeFloatRType( type_class_def type, uint_8 fnc, uint_8 fd, uint_8 fs, uint_8 ft ) -//************************************************************************************************ +static void doOpcodeFloatRType( type_class_def type, uint_8 fnc, reg_idx fd, reg_idx fs, reg_idx ft ) +//*************************************************************************************************** { mips_ins ins; int fmt; @@ -318,15 +318,15 @@ static void doOpcodeFloatRType( type_class_def type, uint_8 fnc, uint_8 fd, uint } #endif -static void doOpcodeRsRt( uint_32 *buffer, ins_opcode opcode, uint_8 rs, uint_8 rt, uint_32 remain ) -//************************************************************************************************** +static void doOpcodeRsRt( uint_32 *buffer, ins_opcode opcode, reg_idx rs, reg_idx rt, uint_32 remain ) +//**************************************************************************************************** { *buffer = _Opcode( opcode ) | _Rs( rs ) | _Rt( rt ) | remain; } -static void doOpcodeFcRsRt( uint_32 *buffer, ins_opcode opcode, ins_funccode fc, uint_8 ra, uint_8 rc, uint_32 extra ) -/********************************************************************************************************************* +static void doOpcodeFcRsRt( uint_32 *buffer, ins_opcode opcode, ins_funccode fc, reg_idx ra, reg_idx rc, uint_32 extra ) +/*********************************************************************************************************************** * This procedure doesn't fill in all the bits (missing bits 20-12). * But we can fill it in using extra. */ @@ -335,24 +335,24 @@ static void doOpcodeFcRsRt( uint_32 *buffer, ins_opcode opcode, ins_funccode fc, } -static void doOpcodeFcRsRtImm( uint_32 *buffer, ins_opcode opcode, ins_funccode fc, uint_8 rs, uint_8 rt, uint_32 imm ) -//********************************************************************************************************************* +static void doOpcodeFcRsRtImm( uint_32 *buffer, ins_opcode opcode, ins_funccode fc, reg_idx rs, reg_idx rt, uint_32 imm ) +//*********************************************************************************************************************** { *buffer = _Opcode( opcode ) | _Op_Func( fc ) | _Rs( rs ) | _Rt( rt ) | _SignedImmed( imm ); } -static void doOpcodeFcRdRtSa( uint_32 *buffer, ins_opcode opcode, ins_funccode fc, uint_8 rd, uint_8 rt, uint_8 sa ) -//****************************************************************************************************************** +static void doOpcodeFcRdRtSa( uint_32 *buffer, ins_opcode opcode, ins_funccode fc, reg_idx rd, reg_idx rt, uint_8 sa ) +//******************************************************************************************************************** { *buffer = _Opcode( opcode ) | _Op_Func( fc ) | _Rd( rd ) | _Rt( rt ) | _Shift( sa ); } -static void doFPInst( uint_32 *buffer, ins_opcode opcode, uint_8 ra, uint_8 rb, uint_8 rc, uint_32 remain ) -//********************************************************************************************************* +static void doFPInst( uint_32 *buffer, ins_opcode opcode, reg_idx ra, reg_idx rb, reg_idx rc, uint_32 remain ) +//************************************************************************************************************ { *buffer = _Opcode( opcode ) | _Rs( ra ) | _Rt( rb ) | _FP_Op_Func( remain ) | _Rd( rc ); @@ -376,8 +376,8 @@ static void doAutoVar( asm_reloc *reloc, op_reloc_target targ, uint_32 *buffer, #endif -static unsigned loadConst32( uint_32 *buffer, uint_8 d_reg, uint_8 s_reg, ins_operand *op, op_const c, asm_reloc *reloc, bool force_pair ) -/***************************************************************************************************************************************** +static unsigned loadConst32( uint_32 *buffer, reg_idx d_reg, reg_idx s_reg, ins_operand *op, op_const val, asm_reloc *reloc, bool force_pair ) +/********************************************************************************************************************************************* * load sequence for 32-bit constants * Given: la $d_reg, foobar+c($s_reg) * info for foobar is stored in op @@ -386,7 +386,6 @@ static unsigned loadConst32( uint_32 *buffer, uint_8 d_reg, uint_8 s_reg, ins_op */ { unsigned ret = 1; - int_16 low, high; /* unused parameters */ (void)s_reg; @@ -397,26 +396,26 @@ static unsigned loadConst32( uint_32 *buffer, uint_8 d_reg, uint_8 s_reg, ins_op return( ret ); } } - low = c & 0xffff; - high = (c & 0xffff0000) >> 16; - - if( !force_pair && (c < 32768) && ((int_32)c > -32769) ) { + if( !force_pair + && ( val < 32768 ) + && ( val > -32769 ) ) { /* * Only need sign extended low 16 bits - 'addiu rt,$zero,value' */ - doOpcodeIType( buffer, OPCODE_ADDIU, d_reg, ZERO_REG_IDX, low ); + doOpcodeIType( buffer, OPCODE_ADDIU, d_reg, ZERO_REG_IDX, val ); doReloc( reloc, op, OWL_RELOC_HALF_LO, buffer ); - } else if( !force_pair && !high ) { + } else if( !force_pair + && (val & 0xffff0000) == 0 ) { /* * Only need high 16 bits - 'lui rt,$zero,(value >> 16)' */ - doOpcodeIType( buffer, OPCODE_LUI, d_reg, ZERO_REG_IDX, high ); + doOpcodeIType( buffer, OPCODE_LUI, d_reg, ZERO_REG_IDX, val >> 16 ); doReloc( reloc, op, OWL_RELOC_HALF_HI, buffer ); } else { /* * Need two instructions: 'lui rt,$zero,(value >> 16)' */ - doOpcodeIType( buffer, OPCODE_LUI, d_reg, ZERO_REG_IDX, high ); + doOpcodeIType( buffer, OPCODE_LUI, d_reg, ZERO_REG_IDX, val >> 16 ); doReloc( reloc, op, OWL_RELOC_HALF_HI, buffer ); ++buffer; /* @@ -424,9 +423,9 @@ static unsigned loadConst32( uint_32 *buffer, uint_8 d_reg, uint_8 s_reg, ins_op * or 'addiu' for the 'la' pseudo-ins */ if( force_pair ) { - doOpcodeIType( buffer, OPCODE_ADDIU, d_reg, d_reg, low ); + doOpcodeIType( buffer, OPCODE_ADDIU, d_reg, d_reg, val ); } else { - doOpcodeIType( buffer, OPCODE_ORI, d_reg, d_reg, low ); + doOpcodeIType( buffer, OPCODE_ORI, d_reg, d_reg, val ); } doReloc( reloc, op, OWL_RELOC_HALF_LO, buffer ); ++ret; @@ -491,7 +490,7 @@ static void doLoadImm( uint_32 *buffer, ins_operand *operands[] ) { ins_operand *op0, *op1; int_32 value; - uint_32 reg; + reg_idx reg; op0 = operands[0]; op1 = operands[1]; @@ -503,26 +502,22 @@ static void doLoadImm( uint_32 *buffer, ins_operand *operands[] ) /* * Only need sign extended low 16 bits - 'addiu rt,$zero,value' */ - doOpcodeIType( buffer, OPCODE_ADDIU, reg, ZERO_REG_IDX, - (unsigned_16)value ); + doOpcodeIType( buffer, OPCODE_ADDIU, reg, ZERO_REG_IDX, value ); } else if( (value & 0xffff) == 0 ) { /* * Only need high 16 bits - 'lui rt,$zero,(value >> 16)' */ - doOpcodeIType( buffer, OPCODE_LUI, reg, ZERO_REG_IDX, - (unsigned_16)(value >> 16) ); + doOpcodeIType( buffer, OPCODE_LUI, reg, ZERO_REG_IDX, value >> 16 ); } else { /* * Need two instructions: 'lui rt,$zero,(value >> 16)' */ - doOpcodeIType( buffer, OPCODE_LUI, reg, ZERO_REG_IDX, - (unsigned_16)(value >> 16) ); + doOpcodeIType( buffer, OPCODE_LUI, reg, ZERO_REG_IDX, value >> 16 ); /* * followed by 'ori rt,$zero,(value & 0xffff)' */ ++buffer; - doOpcodeIType( buffer, OPCODE_ORI, reg, ZERO_REG_IDX, - (unsigned_16)value ); + doOpcodeIType( buffer, OPCODE_ORI, reg, ZERO_REG_IDX, value ); ++numExtendedIns; } } @@ -580,8 +575,7 @@ static void ITLoadUImm( ins_table *table, instruction *ins, uint_32 *buffer, asm assert( ins->num_operands == 2 ); op = ins->operands[1]; checkOpAbsolute( op, 1 ); - doOpcodeIType( buffer, table->opcode, RegIndex( ins->operands[0]->reg ), - 0, op->constant ); + doOpcodeIType( buffer, table->opcode, RegIndex( ins->operands[0]->reg ), 0, op->constant ); } @@ -595,8 +589,7 @@ static void ITTrapImm( ins_table *table, instruction *ins, uint_32 *buffer, asm_ assert( ins->num_operands == 2 ); op = ins->operands[1]; checkOpAbsolute( op, 1 ); - doOpcodeIType( buffer, table->opcode, table->funccode, - RegIndex( ins->operands[0]->reg ), op->constant ); + doOpcodeIType( buffer, table->opcode, table->funccode, RegIndex( ins->operands[0]->reg ), op->constant ); } @@ -655,15 +648,15 @@ static void ITMemB( ins_table *table, instruction *ins, uint_32 *buffer, asm_rel } -static void doMemJump( uint_32 *buffer, ins_table *table, uint_8 ra, uint_8 rb, ins_operand *addr_op, int_32 hint, asm_reloc *reloc ) -//*********************************************************************************************************************************** +static void doMemJump( uint_32 *buffer, ins_table *table, reg_idx ra, reg_idx rb, ins_operand *addr_op, int_32 hint, asm_reloc *reloc ) +//************************************************************************************************************************************* { /* * Note that addr_op maybe NULL. If not, addr_op->constant == hint. */ assert( addr_op == NULL || addr_op->constant == hint ); assert( addr_op == NULL || addr_op->type == OP_IMMED ); - doOpcodeRsRt( buffer, table->opcode, ra, rb, (table->funccode << 14) | _FourteenBits(hint) ); + doOpcodeRsRt( buffer, table->opcode, ra, rb, (table->funccode << 14) | _FourteenBits( hint ) ); doReloc( reloc, addr_op, OWL_RELOC_JUMP_REL, buffer ); } @@ -784,24 +777,27 @@ static void stdMemJump( ins_table *table, instruction *ins, uint_32 *buffer, asm static void ITRegJump( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) //******************************************************************************************** { - int targ_idx; - int retn_idx; + reg_idx targ_reg_idx; + reg_idx retn_reg_idx; /* unused parameters */ (void)reloc; assert( ins->num_operands < 3 ); if( ins->num_operands == 2 ) { - targ_idx = RegIndex( ins->operands[1]->reg ); - retn_idx = RegIndex( ins->operands[0]->reg ); + targ_reg_idx = RegIndex( ins->operands[1]->reg ); + retn_reg_idx = RegIndex( ins->operands[0]->reg ); } else { - targ_idx = RegIndex( ins->operands[0]->reg ); + targ_reg_idx = RegIndex( ins->operands[0]->reg ); if( table->funccode & 1 ) { - retn_idx = RA_REG_IDX; // jalr + retn_reg_idx = RA_REG_IDX; // jalr } else { - retn_idx = 0; // jr + retn_reg_idx = 0; // jr } } - doOpcodeRType( buffer, table->opcode, table->funccode, retn_idx, targ_idx, 0 ); + doOpcodeRType( buffer, table->opcode, table->funccode, + retn_reg_idx, + targ_reg_idx, + 0 ); numExtendedIns += doDelaySlotNOP( buffer ); } @@ -837,10 +833,15 @@ static void ITJump( ins_table *table, instruction *ins, uint_32 *buffer, asm_rel * TODO: warn - non-restartable instruction */ } - doOpcodeRType( buffer, 0, FNCCODE_JALR, RA_REG_IDX, - RegIndex( op0->reg ), 0 ); + doOpcodeRType( buffer, 0, FNCCODE_JALR, + RA_REG_IDX, + RegIndex( op0->reg ), + 0 ); } else { // jr rs - doOpcodeRType( buffer, 0, FNCCODE_JR, 0, RegIndex( op0->reg ), 0 ); + doOpcodeRType( buffer, 0, FNCCODE_JR, + 0, + RegIndex( op0->reg ), + 0 ); } } else { // jalr rd,rs op1 = ins->operands[1]; @@ -849,8 +850,10 @@ static void ITJump( ins_table *table, instruction *ins, uint_32 *buffer, asm_rel * TODO: warn - non-restartable instruction */ } - doOpcodeRType( buffer, 0, FNCCODE_JALR, RegIndex( op1->reg ), - RegIndex( op0->reg ), 0 ); + doOpcodeRType( buffer, 0, FNCCODE_JALR, + RegIndex( op1->reg ), + RegIndex( op0->reg ), + 0 ); } numExtendedIns += doDelaySlotNOP( buffer ); } @@ -894,7 +897,7 @@ static void ITRet( ins_table *table, instruction *ins, uint_32 *buffer, asm_relo { ins_operand *op0, *op1; int num_op; - uint_8 d_reg_idx; // default d_reg if not specified + reg_idx d_reg_idx; // default d_reg if not specified num_op = ins->num_operands; /* @@ -1040,9 +1043,9 @@ static void ITOperate( ins_table *table, instruction *ins, uint_32 *buffer, asm_ assert( ins->num_operands == 3 ); doOpcodeRType( buffer, table->opcode, table->funccode, - RegIndex( ins->operands[0]->reg ), - RegIndex( ins->operands[1]->reg ), - RegIndex( ins->operands[2]->reg ) ); + RegIndex( ins->operands[0]->reg ), + RegIndex( ins->operands[1]->reg ), + RegIndex( ins->operands[2]->reg ) ); } @@ -1052,9 +1055,10 @@ static void ITMulDiv( ins_table *table, instruction *ins, uint_32 *buffer, asm_r /* unused parameters */ (void)reloc; assert( ins->num_operands == 2 ); - doOpcodeRType( buffer, table->opcode, table->funccode, 0, - RegIndex( ins->operands[0]->reg ), - RegIndex( ins->operands[1]->reg ) ); + doOpcodeRType( buffer, table->opcode, table->funccode, + 0, + RegIndex( ins->operands[0]->reg ), + RegIndex( ins->operands[1]->reg ) ); } @@ -1065,7 +1069,9 @@ static void ITMovFromSpc( ins_table *table, instruction *ins, uint_32 *buffer, a assert( ins->num_operands == 1 ); doOpcodeRType( buffer, table->opcode, table->funccode, - RegIndex( ins->operands[0]->reg ), 0, 0 ); + RegIndex( ins->operands[0]->reg ), + 0, + 0 ); } @@ -1075,8 +1081,10 @@ static void ITMovToSpc( ins_table *table, instruction *ins, uint_32 *buffer, asm /* unused parameters */ (void)reloc; assert( ins->num_operands == 1 ); - doOpcodeRType( buffer, table->opcode, table->funccode, 0, - RegIndex( ins->operands[0]->reg ), 0 ); + doOpcodeRType( buffer, table->opcode, table->funccode, + 0, + RegIndex( ins->operands[0]->reg ), + 0 ); } @@ -1086,8 +1094,10 @@ static void ITMovCop( ins_table *table, instruction *ins, uint_32 *buffer, asm_r /* unused parameters */ (void)reloc; assert( ins->num_operands == 2 ); - doOpcodeRType( buffer, table->opcode, 0, RegIndex( ins->operands[1]->reg ), - table->funccode, RegIndex( ins->operands[0]->reg ) ); + doOpcodeRType( buffer, table->opcode, 0, + RegIndex( ins->operands[1]->reg ), + table->funccode, + RegIndex( ins->operands[0]->reg ) ); } @@ -1102,8 +1112,8 @@ static void ITOperateImm( ins_table *table, instruction *ins, uint_32 *buffer, a op = ins->operands[2]; checkOpAbsolute( op, 2 ); doOpcodeFcRsRtImm( buffer, table->opcode, table->funccode, - RegIndex( ins->operands[1]->reg ), - RegIndex( ins->operands[0]->reg ), op->constant ); + RegIndex( ins->operands[1]->reg ), + RegIndex( ins->operands[0]->reg ), op->constant ); } @@ -1117,8 +1127,8 @@ static void ITShiftImm( ins_table *table, instruction *ins, uint_32 *buffer, asm assert( ins->num_operands == 3 ); op = ins->operands[2]; doOpcodeFcRdRtSa( buffer, table->opcode, table->funccode, - RegIndex( ins->operands[0]->reg ), - RegIndex( ins->operands[1]->reg ), op->constant ); + RegIndex( ins->operands[0]->reg ), + RegIndex( ins->operands[1]->reg ), op->constant ); } @@ -1132,8 +1142,8 @@ static void ITFPOperate( ins_table *table, instruction *ins, uint_32 *buffer, as assert( ins->num_operands == 3 ); fc = getFuncCode( table, ins ); doFPInst( buffer, table->opcode, RegIndex( ins->operands[0]->reg ), - RegIndex( ins->operands[1]->reg ), - RegIndex( ins->operands[2]->reg ), fc ); + RegIndex( ins->operands[1]->reg ), + RegIndex( ins->operands[2]->reg ), fc ); } @@ -1147,7 +1157,7 @@ static void ITFPConvert( ins_table *table, instruction *ins, uint_32 *buffer, as assert( ins->num_operands == 2 ); fc = getFuncCode( table, ins ); doFPInst( buffer, table->opcode, ZERO_REG_IDX, RegIndex( ins->operands[0]->reg ), - RegIndex( ins->operands[1]->reg ), fc ); + RegIndex( ins->operands[1]->reg ), fc ); } @@ -1188,11 +1198,10 @@ static void ITMTMFFpcr( ins_table *table, instruction *ins, uint_32 *buffer, asm { assert( ins->num_operands == 1 || ins->num_operands == 3 ); if( ins->num_operands == 1 ) { - uint_8 reg_num; + reg_idx reg_num; reg_num = RegIndex( ins->operands[0]->reg ); - doFPInst( buffer, table->opcode, reg_num, reg_num, reg_num, - table->funccode ); + doFPInst( buffer, table->opcode, reg_num, reg_num, reg_num, table->funccode ); return; } ITFPOperate( table, ins, buffer, reloc ); @@ -1217,7 +1226,7 @@ static void ITPseudoFclr( ins_table *table, instruction *ins, uint_32 *buffer, a assert( ins->num_operands == 1 ); doFPInst( buffer, table->opcode, ZERO_REG_IDX, ZERO_REG_IDX, - RegIndex( ins->operands[0]->reg ), table->funccode ); + RegIndex( ins->operands[0]->reg ), table->funccode ); } @@ -1297,22 +1306,24 @@ static void ITPseudoMov( ins_table *table, instruction *ins, uint_32 *buffer, as /* unused parameters */ (void)reloc; (void)table; assert( ins->num_operands == 2 ); - doOpcodeRType( buffer, 0, FNCCODE_OR, RegIndex( ins->operands[0]->reg ), - RegIndex( ins->operands[1]->reg ), ZERO_REG_IDX ); + doOpcodeRType( buffer, 0, FNCCODE_OR, + RegIndex( ins->operands[0]->reg ), + RegIndex( ins->operands[1]->reg ), + ZERO_REG_IDX ); } static void ITPseudoFmov( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) //*********************************************************************************************** { - uint_8 reg_idx0; + reg_idx reg_idx0; /* unused parameters */ (void)reloc; assert( ins->num_operands == 2 ); reg_idx0 = RegIndex( ins->operands[0]->reg ); doFPInst( buffer, table->opcode, reg_idx0, reg_idx0, - RegIndex( ins->operands[1]->reg ), table->funccode ); + RegIndex( ins->operands[1]->reg ), table->funccode ); } @@ -1350,28 +1361,30 @@ static void ITPseudoNegf( ins_table *table, instruction *ins, uint_32 *buffer, a assert( ins->num_operands == 2 ); fc = getFuncCode( table, ins ); doFPInst( buffer, table->opcode, ZERO_REG_IDX, RegIndex( ins->operands[0]->reg ), - RegIndex( ins->operands[1]->reg ), fc ); + RegIndex( ins->operands[1]->reg ), fc ); } static void ITPseudoFneg( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) //*********************************************************************************************** { - uint_8 reg_idx0; + reg_idx reg_idx0; /* unused parameters */ (void)reloc; assert( ins->num_operands == 2 ); reg_idx0 = RegIndex( ins->operands[0]->reg ); doFPInst( buffer, table->opcode, reg_idx0, reg_idx0, - RegIndex( ins->operands[1]->reg ), table->funccode ); + RegIndex( ins->operands[1]->reg ), table->funccode ); } static void ITPseudoAbs( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) //********************************************************************************************** { - uint_8 s_reg_idx, d_reg_idx, rc_reg_idx; + reg_idx s_reg_idx; + reg_idx d_reg_idx; + reg_idx rc_reg_idx; ins_operand *src_op; bool same_reg; diff --git a/bld/as/mps/h/register.h b/bld/as/mps/h/register.h index d9081e3137..4fc395c31d 100644 --- a/bld/as/mps/h/register.h +++ b/bld/as/mps/h/register.h @@ -35,7 +35,7 @@ #define MakeReg( c, i ) ( ( (i) & 0xff ) | ( (int)(c) << 8 ) ) #define RegClass( r ) ( ( (r) >> 8 ) & 0xff ) -#define RegIndex( r ) ( (r) & 0xff ) +#define RegIndex( r ) ((reg_idx)((r) & 0xff)) #define NULL_REG_IDX 0 #define NULL_REG MakeReg( RC_NOTHING, NULL_REG_IDX ) @@ -43,7 +43,8 @@ #define AT_REG MakeReg( RC_GPR, AT_REG_IDX ) #define ZERO_REG MakeReg( RC_GPR, ZERO_REG_IDX ) -typedef uint_16 reg; +typedef uint_16 reg; +typedef uint_8 reg_idx; typedef enum { #define PICK( a, b ) RC_##a, diff --git a/bld/as/ppc/c/ppcfmt.c b/bld/as/ppc/c/ppcfmt.c index c823691da3..08c84dc7ea 100644 --- a/bld/as/ppc/c/ppcfmt.c +++ b/bld/as/ppc/c/ppcfmt.c @@ -101,8 +101,8 @@ static bool ensureTypeCorrect( ins_operand *op, op_type type, uint_8 opIdx ) return( true ); } -static bool checkOpAbsolute( ins_operand *op, uint_8 op_idx ) -//*********************************************************** +static bool checkOpAbsolute( ins_operand *op, int op_idx ) +//******************************************************** { if( ( op->flags & ( RELOC | UNNAMED_RELOC ) ) ) { Error( RELOC_NOT_ALLOWED, op_idx ); @@ -111,8 +111,8 @@ static bool checkOpAbsolute( ins_operand *op, uint_8 op_idx ) return( true ); } -static void doEncode2( uint_32 *buffer, ins_opcode p, uint r1, uint r2, uint imm, ins_flags flags ) -/************************************************************************************************** +static void doEncode2( uint_32 *buffer, ins_opcode p, reg_idx r1, reg_idx r2, uint imm, ins_flags flags ) +/******************************************************************************************************** * Use when there are 2 5-bit blocks (other than opcode blocks) and * an immediate block (16-bit) */ @@ -120,24 +120,24 @@ static void doEncode2( uint_32 *buffer, ins_opcode p, uint r1, uint r2, uint imm *buffer = _Opcode( p ) | _D( r1 ) | _A( r2 ) | _SignedImmed( imm ) | _IF_OE( flags ) | _IF_RC( flags ); } -static void doEncode3( uint_32 *buffer, ins_opcode p, ins_opcode s, uint r1, uint r2, uint r3, ins_flags flags ) -/*************************************************************************************************************** +static void doEncode3( uint_32 *buffer, ins_opcode p, ins_opcode s, reg_idx r1, reg_idx r2, reg_idx r3, ins_flags flags ) +/************************************************************************************************************************ * Use when there are 3 5-bit blocks (other than opcode blocks) */ { *buffer = _Opcode( p ) | _D( r1 ) | _A( r2 ) | _B( r3 ) | _IF_OE( flags ) | _Opcode2( s ) | _IF_RC( flags ); } -static void doEncode4( uint_32 *buffer, ins_opcode p, ins_opcode s, uint r1, uint r2, uint r3, uint r4, ins_flags flags ) -/************************************************************************************************************************ +static void doEncode4( uint_32 *buffer, ins_opcode p, ins_opcode s, reg_idx r1, reg_idx r2, reg_idx r3, reg_idx r4, ins_flags flags ) +/************************************************************************************************************************************ * Use when there are 4 5-bit blocks (other than opcode blocks) */ { *buffer = _Opcode( p ) | _D( r1 ) | _A( r2 ) | _C( r3 ) | _B( r4 ) | _Opcode2( s ) | _IF_RC( flags ); } -static void doEncode5( uint_32 *buffer, ins_opcode p, uint r1, uint r2, uint r3, uint r4, uint r5, ins_flags flags ) -/******************************************************************************************************************* +static void doEncode5( uint_32 *buffer, ins_opcode p, reg_idx r1, reg_idx r2, reg_idx r3, reg_idx r4, reg_idx r5, ins_flags flags ) +/********************************************************************************************************************************** * Use when there are 5 5-bit blocks (other than opcode blocks) e.g. rlwimi */ { @@ -421,7 +421,9 @@ static void ITCmp( ins_table *table, instruction *ins, uint_32 *buffer, asm_relo /****************************************************************************************/ { ins_operand *op[4], *opRa, *opRb; - uint crfIdx, L_bit, ctr; + uint crfIdx; + uint L_bit; + int ctr; ins_opcount opcount; op_type verify4[4] = { OP_CRF, OP_IMMED, OP_GPR, OP_GPR }; op_type verify3[3] = { OP_IMMED, OP_GPR, OP_GPR }; @@ -462,7 +464,9 @@ static void ITCmpImmed( ins_table *table, instruction *ins, uint_32 *buffer, asm /*********************************************************************************************/ { ins_operand *op[4], *opRa, *opSimm; - uint crfIdx, L_bit, ctr; + uint crfIdx; + uint L_bit; + int ctr; ins_opcount opcount; op_type verify4[4] = { OP_CRF, OP_IMMED, OP_GPR, OP_IMMED }; op_type verify3[3] = { OP_IMMED, OP_GPR, OP_IMMED }; @@ -898,8 +902,8 @@ static void ITTlbie( ins_table *table, instruction *ins, uint_32 *buffer, asm_re /* unused parameters */ (void)reloc; assert( ins->num_operands == 1 ); - doEncode3( buffer, table->primary, table->secondary, 0, 0, - RegIndex( ins->operands[0]->reg ), + doEncode3( buffer, table->primary, table->secondary, + 0, 0, RegIndex( ins->operands[0]->reg ), ( ins->format->flags & table->optional ) | table->required ); } @@ -1079,9 +1083,9 @@ static void ITSMSrwi( ins_table *table, instruction *ins, uint_32 *buffer, asm_r { ins_operand *const_op; uint n; - uint sh = 0; - uint mb = 0; - uint me = 0; + reg_idx sh = 0; + reg_idx mb = 0; + reg_idx me = 0; /* unused parameters */ (void)reloc; @@ -1092,10 +1096,12 @@ static void ITSMSrwi( ins_table *table, instruction *ins, uint_32 *buffer, asm_r n = const_op->constant; switch( table->special ) { case SRWI: - sh = 32 - n; mb = n; me = 31; + sh = 32 - n; + mb = n; + me = 31; break; case CLRRWI: - sh = 0; mb = 0; me = 31 - n; + me = 31 - n; break; default: assert( false ); @@ -1191,7 +1197,8 @@ static void ITSMMovSprNCover( bool isMoveTo, ins_table *table, instruction *ins, { ins_operand *op; uint spr; - int idx0, idx1; + int idx0; + int idx1; /* unused parameters */ (void)reloc; diff --git a/bld/as/ppc/h/register.h b/bld/as/ppc/h/register.h index 1712cd1f19..53ead43f4c 100644 --- a/bld/as/ppc/h/register.h +++ b/bld/as/ppc/h/register.h @@ -36,14 +36,15 @@ #define MakeReg( c, i ) ( ( (i) & 0xff ) | ( (int)(c) << 8 ) ) #define RegClass( r ) ( ( (r) >> 8 ) & 0xff ) -#define RegIndex( r ) ( (r) & 0xff ) +#define RegIndex( r ) ((reg_idx)((r) & 0xff)) #define NULL_REG_IDX 0 #define NULL_REG MakeReg( RC_NOTHING, NULL_REG_IDX ) #define AT_REG NULL_REG -typedef uint_16 reg; +typedef uint_16 reg; +typedef uint_8 reg_idx; typedef enum { #define PICK( a, b ) RC_##a, From 622e5eee39ff78068fba71c4f6bb713c7d115a9f Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Tue, 3 Oct 2023 01:20:27 +0200 Subject: [PATCH 197/258] cleanup risc assembler code --- bld/as/axp/h/inslist.h | 10 +-- bld/as/c/asdrectv.c | 114 ++++++++++++++++++++++------------- bld/as/c/asiobj.c | 2 +- bld/as/mps/c/mipsfmt.c | 45 +++++++------- bld/as/mps/h/inslist.h | 8 +-- bld/as/ppc/c/ppcfmt.c | 134 +++++++++++++++++++++-------------------- bld/as/ppc/h/inslist.h | 10 +-- 7 files changed, 177 insertions(+), 146 deletions(-) diff --git a/bld/as/axp/h/inslist.h b/bld/as/axp/h/inslist.h index 763ec9a1c8..d3f413b2c8 100644 --- a/bld/as/axp/h/inslist.h +++ b/bld/as/axp/h/inslist.h @@ -55,8 +55,8 @@ typedef enum { #undef PICK } ins_enum_method; // All the possible enumeration methods -typedef uint_16 ins_opcode; -typedef uint_16 ins_funccode; +typedef uint_16 ins_opcode; +typedef uint_16 ins_funccode; typedef enum { NOTHING = 0x00, @@ -73,8 +73,8 @@ typedef enum { OP_REG_INDIRECT = (1 << (REGCLASS_COUNT+1)), // register with an immediate attached } op_type; -typedef int_32 op_const; -typedef reg op_reg; /* from chip-specific register.h - must be included before inslist.h */ +typedef int_32 op_const; +typedef reg op_reg; /* from chip-specific register.h - must be included before inslist.h */ typedef union { int_32 label; @@ -117,7 +117,7 @@ struct ins_symbol { /* end of ALPHA specific junk */ -typedef ins_symbol *ins_format; +typedef ins_symbol *ins_format; typedef struct ins_operand { op_type type; diff --git a/bld/as/c/asdrectv.c b/bld/as/c/asdrectv.c index b930a6acd0..97430c9096 100644 --- a/bld/as/c/asdrectv.c +++ b/bld/as/c/asdrectv.c @@ -90,7 +90,7 @@ static bool dirFuncAlign ( directive_t *dir, dir_table_enum parm ) return( true ); } autoAlignment = false; - CurrAlignment = val; + CurrAlignment = (uint_8)val; return( true ); } @@ -656,27 +656,22 @@ static bool dirFuncValues( directive_t *dir, dir_table_enum parm ) //**************************************************************** { dir_operand *dirop; - static int_8 byte; - static int_16 half; - static int_32 word; - static signed_64 quad; - static float flt; - static double dbl; + static union { + int_8 byte; + int_16 half; + int_32 word; + signed_64 quad; + float flt; + double dbl; + } u; int_32 rep; uint_8 prev_alignment = 0; int opnum; void *target = NULL; owl_reloc_type rtype = 0; - struct { int size; void *ptr; uint_8 alignment; } data_table[] = - { - { 1, &byte, 0 }, // DT_VAL_INT8 - { 8, &dbl, 3 }, // DT_VAL_DOUBLE - { 4, &flt, 2 }, // DT_VAL_FLOAT - { 2, &half, 1 }, // DT_VAL_INT16 - { 4, &word, 2 }, // DT_VAL_INT32 - { 8, &quad, 3 }, // DT_VAL_INT64 - }; -#define TABLE_IDX( x ) ( ( x ) - DT_VAL_FIRST ) + void *data_ptr; + int data_size; + uint_8 data_align; #ifdef _STANDALONE_ if( OWLTellSectionType( CurrentSection ) & OWL_SEC_ATTR_BSS ) { @@ -684,9 +679,42 @@ static bool dirFuncValues( directive_t *dir, dir_table_enum parm ) return( true ); } #endif + switch( parm ) { + default: + case DT_VAL_INT8: + data_align = 0; + data_ptr = &u.byte; + data_size = 1; + break; + case DT_VAL_INT16: + data_align = 1; + data_ptr = &u.half; + data_size = 2; + break; + case DT_VAL_FLOAT: + data_ptr = &u.flt; + data_size = 4; + data_align = 2; + break; + case DT_VAL_INT32: + data_ptr = &u.word; + data_size = 4; + data_align = 2; + break; + case DT_VAL_DOUBLE: + data_ptr = &u.dbl; + data_size = 8; + data_align = 3; + break; + case DT_VAL_INT64: + data_ptr = &u.quad; + data_size = 8; + data_align = 3; + break; + } if( autoAlignment ) { prev_alignment = CurrAlignment; - CurrAlignment = data_table[TABLE_IDX( parm )].alignment; + CurrAlignment = data_align; } opnum = 0; @@ -696,49 +724,49 @@ static bool dirFuncValues( directive_t *dir, dir_table_enum parm ) case DT_VAL_INT8: assert( dirop->type == DIROP_INTEGER || dirop->type == DIROP_REP_INT ); if( dirop->type == DIROP_INTEGER ) { - byte = (int_8)NUMBER_INTEGER( dirop ); + u.byte = (int_8)NUMBER_INTEGER( dirop ); } else { // repeat rep = REPEAT_COUNT( dirop ); - byte = (int_8)REPEAT_INTEGER( dirop ); + u.byte = (int_8)REPEAT_INTEGER( dirop ); } break; case DT_VAL_INT64: assert( dirop->type == DIROP_INTEGER || dirop->type == DIROP_REP_INT ); if( dirop->type == DIROP_INTEGER ) { - quad.u._32[I64LO32] = NUMBER_INTEGER( dirop ); + u.quad.u._32[I64LO32] = NUMBER_INTEGER( dirop ); } else { // repeat rep = REPEAT_COUNT( dirop ); - quad.u._32[I64LO32] = REPEAT_INTEGER( dirop ); + u.quad.u._32[I64LO32] = REPEAT_INTEGER( dirop ); } break; case DT_VAL_DOUBLE: assert( dirop->type == DIROP_FLOATING || dirop->type == DIROP_REP_FLT ); if( dirop->type == DIROP_FLOATING ) { - dbl = NUMBER_FLOAT( dirop ); + u.dbl = NUMBER_FLOAT( dirop ); } else { rep = REPEAT_COUNT( dirop ); - dbl = REPEAT_FLOAT( dirop ); + u.dbl = REPEAT_FLOAT( dirop ); } break; case DT_VAL_FLOAT: assert( dirop->type == DIROP_FLOATING || dirop->type == DIROP_REP_FLT ); if( dirop->type == DIROP_FLOATING ) { - flt = (float)NUMBER_FLOAT( dirop ); + u.flt = (float)NUMBER_FLOAT( dirop ); } else { rep = REPEAT_COUNT( dirop ); - flt = (float)REPEAT_FLOAT( dirop ); + u.flt = (float)REPEAT_FLOAT( dirop ); } break; case DT_VAL_INT32: assert( dirop->type == DIROP_INTEGER || dirop->type == DIROP_REP_INT || dirop->type == DIROP_SYMBOL || dirop->type == DIROP_NUMLABEL_REF ); if( dirop->type == DIROP_INTEGER ) { - word = NUMBER_INTEGER( dirop ); + u.word = NUMBER_INTEGER( dirop ); } else if( dirop->type == DIROP_REP_INT ) { rep = REPEAT_COUNT( dirop ); - word = REPEAT_INTEGER( dirop ); + u.word = REPEAT_INTEGER( dirop ); } else { // reloc - word = SYMBOL_OFFSET( dirop ); + u.word = SYMBOL_OFFSET( dirop ); if( assignRelocType( &rtype, SYMBOL_RELOC_TYPE( dirop ), parm ) ) { if( dirop->type == DIROP_SYMBOL ) { target = SymName( SYMBOL_HANDLE( dirop ) ); @@ -755,12 +783,12 @@ static bool dirFuncValues( directive_t *dir, dir_table_enum parm ) assert( dirop->type == DIROP_INTEGER || dirop->type == DIROP_REP_INT || dirop->type == DIROP_SYMBOL || dirop->type == DIROP_NUMLABEL_REF ); if( dirop->type == DIROP_INTEGER ) { - half = (int_16)NUMBER_INTEGER( dirop ); + u.half = (int_16)NUMBER_INTEGER( dirop ); } else if( dirop->type == DIROP_REP_INT ) { rep = REPEAT_COUNT( dirop ); - half = (int_16)REPEAT_INTEGER( dirop ); + u.half = (int_16)REPEAT_INTEGER( dirop ); } else { // reloc - half = (int_16)SYMBOL_OFFSET( dirop ); + u.half = (int_16)SYMBOL_OFFSET( dirop ); if( assignRelocType( &rtype, SYMBOL_RELOC_TYPE( dirop ), parm ) ) { if( dirop->type == DIROP_SYMBOL ) { target = SymName( SYMBOL_HANDLE( dirop ) ); @@ -790,37 +818,37 @@ static bool dirFuncValues( directive_t *dir, dir_table_enum parm ) } #ifdef _STANDALONE_ // only align for the first data operand - ObjEmitData( CurrentSection, data_table[TABLE_IDX( parm )].ptr, data_table[TABLE_IDX( parm )].size, ( opnum == 0 ) ); + ObjEmitData( CurrentSection, data_ptr, data_size, ( opnum == 0 ) ); #else // only align for the first data operand - ObjEmitData( data_table[TABLE_IDX( parm )].ptr, data_table[TABLE_IDX( parm )].size, ( opnum == 0 ) ); + ObjEmitData( data_ptr, data_size, ( opnum == 0 ) ); #endif for( rep--; rep > 0; rep-- ) { #ifdef _STANDALONE_ - OWLEmitData( CurrentSection, data_table[TABLE_IDX( parm )].ptr, data_table[TABLE_IDX( parm )].size ); + OWLEmitData( CurrentSection, data_ptr, data_size ); #else - ObjDirectEmitData( data_table[TABLE_IDX( parm )].ptr, data_table[TABLE_IDX( parm )].size ); + ObjDirectEmitData( data_ptr, data_size ); #endif #if 0 - printf( "Size=%d\n", data_table[TABLE_IDX( parm )].size ); + printf( "Size=%d\n", data_size ); switch( parm ) { case DT_VAL_INT8: - printf( "Out->%d\n", *(int_8 *)(data_table[TABLE_IDX( parm )].ptr) ); + printf( "Out->%d\n", u.byte ); break; case DT_VAL_DOUBLE: - printf( "Out->%lf\n", *(double *)(data_table[TABLE_IDX( parm )].ptr) ); + printf( "Out->%lf\n", u.dbl ); break; case DT_VAL_FLOAT: - printf( "Out->%f\n", *(float *)(data_table[TABLE_IDX( parm )].ptr) ); + printf( "Out->%f\n", u.flt ); break; case DT_VAL_INT16: - printf( "Out->%d\n", *(int_16 *)(data_table[TABLE_IDX( parm )].ptr) ); + printf( "Out->%d\n", u.half ); break; case DT_VAL_INT32: - printf( "Out->%d\n", *(int_32 *)(data_table[TABLE_IDX( parm )].ptr) ); + printf( "Out->%d\n", u.word ); break; case DT_VAL_INT64: - printf( "Out->%d\n", ((signed_64 *)(data_table[TABLE_IDX( parm )].ptr))->_32[0] ); + printf( "Out->%lld\n", u.quad ); break; default: assert( false ); diff --git a/bld/as/c/asiobj.c b/bld/as/c/asiobj.c index 56700a27a4..9942e7515d 100644 --- a/bld/as/c/asiobj.c +++ b/bld/as/c/asiobj.c @@ -68,7 +68,7 @@ static void doEmitData( char *buffer, size_t size ) //************************************************* { memcpy( &AsmCodeBuffer[AsmCodeAddress], buffer, size ); - AsmCodeAddress += size; + AsmCodeAddress += (unsigned)size; if( AsmCodeAddress > AsmLastAddress ) { AsmLastAddress = AsmCodeAddress; } diff --git a/bld/as/mps/c/mipsfmt.c b/bld/as/mps/c/mipsfmt.c index f10a53e857..f8dad789d3 100644 --- a/bld/as/mps/c/mipsfmt.c +++ b/bld/as/mps/c/mipsfmt.c @@ -34,7 +34,6 @@ #ifndef _STANDALONE_ #include "asinline.h" #endif -#include "mipsenco.h" /* @@ -119,7 +118,7 @@ static owl_reloc_type reloc_translate[] = { OWL_RELOC_JUMP_REL, // jump hint }; -static uint_32 cop_codes[4] = { +static ins_opcode cop_codes[4] = { 0x10, // COP0 0x11, // COP1 0x12, // COP2 @@ -255,29 +254,29 @@ static ins_funccode getFuncCode( ins_table *table, instruction *ins ) } -static void doOpcodeJType( uint_32 *buffer, uint_8 opcode ) -//********************************************************* +static void doOpcodeJType( uint_32 *buffer, ins_opcode opcode ) +//************************************************************* { *buffer = _Opcode( opcode ); } -static void doOpcodeIType( uint_32 *buffer, uint_8 opcode, reg_idx rt, reg_idx rs, int_32 imm ) -//************************************************************************************************** +static void doOpcodeIType( uint_32 *buffer, ins_opcode opcode, reg_idx rt, reg_idx rs, op_const imm ) +//*************************************************************************************************** { *buffer = _Opcode( opcode ) | _Rs( rs ) | _Rt( rt ) | _SignedImmed( imm ); } -static void doOpcodeRType( uint_32 *buffer, uint_8 opcode, uint_8 fc, reg_idx rd, reg_idx rs, reg_idx rt ) -//******************************************************************************************************** +static void doOpcodeRType( uint_32 *buffer, ins_opcode opcode, ins_funccode fc, reg_idx rd, reg_idx rs, reg_idx rt ) +//****************************************************************************************************************** { *buffer = _Opcode( opcode ) | _Rs( rs ) | _Rt( rt ) | _Rd( rd ) | _Function( fc ); } -static void doOpcodeCopOp( uint_32 *buffer, uint_8 opcode, uint_8 fc, uint_32 extra ) -/************************************************************************************ +static void doOpcodeCopOp( uint_32 *buffer, ins_opcode opcode, ins_funccode fc, uint_32 extra ) +/********************************************************************************************** * This procedure doesn't fill in all the bits (missing bits 6-24). * But we can fill it in using extra. */ @@ -287,8 +286,8 @@ static void doOpcodeCopOp( uint_32 *buffer, uint_8 opcode, uint_8 fc, uint_32 ex } #if 0 -static void doOpcodeIShift( uint_32 *buffer, uint_8 fc, reg_idx rd, reg_idx rt, uint_8 sa ) -//***************************************************************************************** +static void doOpcodeIShift( uint_32 *buffer, uint_8 fc, reg_idx rd, reg_idx rt, op_const sa ) +//******************************************************************************************* { *buffer = _Opcode( 0 ) | _Rs( 0 ) | _Rt( rt ) | _Rd( rd ) | _Shift( sa ) | _Function( fc ); } @@ -335,16 +334,16 @@ static void doOpcodeFcRsRt( uint_32 *buffer, ins_opcode opcode, ins_funccode fc, } -static void doOpcodeFcRsRtImm( uint_32 *buffer, ins_opcode opcode, ins_funccode fc, reg_idx rs, reg_idx rt, uint_32 imm ) -//*********************************************************************************************************************** +static void doOpcodeFcRsRtImm( uint_32 *buffer, ins_opcode opcode, ins_funccode fc, reg_idx rs, reg_idx rt, op_const imm ) +//************************************************************************************************************************ { *buffer = _Opcode( opcode ) | _Op_Func( fc ) | _Rs( rs ) | _Rt( rt ) | _SignedImmed( imm ); } -static void doOpcodeFcRdRtSa( uint_32 *buffer, ins_opcode opcode, ins_funccode fc, reg_idx rd, reg_idx rt, uint_8 sa ) -//******************************************************************************************************************** +static void doOpcodeFcRdRtSa( uint_32 *buffer, ins_opcode opcode, ins_funccode fc, reg_idx rd, reg_idx rt, op_const sa ) +//********************************************************************************************************************** { *buffer = _Opcode( opcode ) | _Op_Func( fc ) | _Rd( rd ) | _Rt( rt ) | _Shift( sa ); @@ -589,7 +588,7 @@ static void ITTrapImm( ins_table *table, instruction *ins, uint_32 *buffer, asm_ assert( ins->num_operands == 2 ); op = ins->operands[1]; checkOpAbsolute( op, 1 ); - doOpcodeIType( buffer, table->opcode, table->funccode, RegIndex( ins->operands[0]->reg ), op->constant ); + doOpcodeIType( buffer, table->opcode, (reg_idx)table->funccode, RegIndex( ins->operands[0]->reg ), op->constant ); } @@ -999,7 +998,7 @@ static void ITBranchZero( ins_table *table, instruction *ins, uint_32 *buffer, a assert( ins->num_operands == 2 ); op = ins->operands[1]; - doOpcodeIType( buffer, table->opcode, table->funccode, + doOpcodeIType( buffer, table->opcode, (reg_idx)table->funccode, RegIndex( ins->operands[0]->reg ), _SignedImmed( _Longword_offset( op->constant ) ) ); doReloc( reloc, op, OWL_RELOC_BRANCH_REL, buffer ); @@ -1011,12 +1010,12 @@ static void ITBranchCop( ins_table *table, instruction *ins, uint_32 *buffer, as //********************************************************************************************** { ins_operand *op; - uint_32 opcode; + ins_opcode opcode; assert( ins->num_operands == 1 ); opcode = cop_codes[table->opcode >> 8]; op = ins->operands[0]; - doOpcodeIType( buffer, opcode, table->funccode, table->opcode & 0xff, + doOpcodeIType( buffer, opcode, (reg_idx)table->funccode, table->opcode & 0xff, _SignedImmed( _Longword_offset( op->constant ) ) ); doReloc( reloc, op, OWL_RELOC_BRANCH_REL, buffer ); numExtendedIns += doDelaySlotNOP( buffer ); @@ -1026,7 +1025,7 @@ static void ITBranchCop( ins_table *table, instruction *ins, uint_32 *buffer, as static void ITCop0Spc( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) //******************************************************************************************** { - uint_32 opcode; + ins_opcode opcode; /* unused parameters */ (void)reloc; (void)ins; @@ -1096,7 +1095,7 @@ static void ITMovCop( ins_table *table, instruction *ins, uint_32 *buffer, asm_r assert( ins->num_operands == 2 ); doOpcodeRType( buffer, table->opcode, 0, RegIndex( ins->operands[1]->reg ), - table->funccode, + (reg_idx)table->funccode, RegIndex( ins->operands[0]->reg ) ); } @@ -1247,7 +1246,7 @@ static void ITPseudoLAddr( ins_table *table, instruction *ins, uint_32 *buffer, ins_operand *ops[2]; unsigned inc; // op_const val; - uint_8 s_reg; + reg_idx s_reg; /* unused parameters */ (void)table; diff --git a/bld/as/mps/h/inslist.h b/bld/as/mps/h/inslist.h index f8afd5594f..32a3fbe489 100644 --- a/bld/as/mps/h/inslist.h +++ b/bld/as/mps/h/inslist.h @@ -52,8 +52,8 @@ typedef enum { #undef PICK } ins_enum_method; // All the possible enumeration methods -typedef uint_16 ins_opcode; -typedef uint_16 ins_funccode; +typedef uint_16 ins_opcode; +typedef uint_16 ins_funccode; typedef enum { NOTHING = 0x00, @@ -70,8 +70,8 @@ typedef enum { OP_REG_INDIRECT = (1 << (REGCLASS_COUNT+1)), // register with an immediate attached } op_type; -typedef int_32 op_const; -typedef reg op_reg; /* from chip-specific register.h - must be included before inslist.h */ +typedef int_32 op_const; +typedef reg op_reg; /* from chip-specific register.h - must be included before inslist.h */ typedef union { int_32 label; diff --git a/bld/as/ppc/c/ppcfmt.c b/bld/as/ppc/c/ppcfmt.c index 08c84dc7ea..9a33b78b89 100644 --- a/bld/as/ppc/c/ppcfmt.c +++ b/bld/as/ppc/c/ppcfmt.c @@ -91,11 +91,11 @@ static int_32 SPRChkList[] = { 528, 529, 530, 531, 532, 533, 534, 535, 1008, 1009, 1010, 1013, 1023 }; -static bool ensureTypeCorrect( ins_operand *op, op_type type, uint_8 opIdx ) -//************************************************************************** +static bool checkTypeCorrect( ins_operand *op, op_type type, int op_idx ) +//*********************************************************************** { if( op->type != type ) { - Error( IMPROPER_OPERAND, opIdx ); + Error( IMPROPER_OPERAND, op_idx ); return( false ); } return( true ); @@ -111,8 +111,8 @@ static bool checkOpAbsolute( ins_operand *op, int op_idx ) return( true ); } -static void doEncode2( uint_32 *buffer, ins_opcode p, reg_idx r1, reg_idx r2, uint imm, ins_flags flags ) -/******************************************************************************************************** +static void doEncode2( uint_32 *buffer, ins_opcode p, reg_idx r1, reg_idx r2, op_const imm, ins_flags flags ) +/************************************************************************************************************ * Use when there are 2 5-bit blocks (other than opcode blocks) and * an immediate block (16-bit) */ @@ -421,8 +421,8 @@ static void ITCmp( ins_table *table, instruction *ins, uint_32 *buffer, asm_relo /****************************************************************************************/ { ins_operand *op[4], *opRa, *opRb; - uint crfIdx; - uint L_bit; + reg_idx crf_idx; + reg_idx L_bit; int ctr; ins_opcount opcount; op_type verify4[4] = { OP_CRF, OP_IMMED, OP_GPR, OP_GPR }; @@ -435,27 +435,26 @@ static void ITCmp( ins_table *table, instruction *ins, uint_32 *buffer, asm_relo opcount = ins->num_operands; verify = ( opcount == 3 ) ? verify3 : verify4; for( ctr = 0; ctr < opcount; ctr++ ) { - if( !ensureTypeCorrect( op[ctr] = ins->operands[ctr], verify[ctr], ctr ) ) { + if( !checkTypeCorrect( op[ctr] = ins->operands[ctr], verify[ctr], ctr ) ) { return; } } if( opcount == 4 ) { - crfIdx = RegIndex( op[0]->reg ); + crf_idx = RegIndex( op[0]->reg ); ctr = 1; } else { // 3 operands - crfIdx = 0; + crf_idx = 0; ctr = 0; } - L_bit = op[ctr]->constant; - if( ( L_bit & 1 ) != L_bit ) { + L_bit = op[ctr]->constant & 1; + if( L_bit != op[ctr]->constant ) { Error( OP_OUT_OF_RANGE, ctr ); } if( checkOpAbsolute( op[ctr], ctr ) ) { opRa = op[++ctr]; opRb = op[++ctr]; doEncode3( buffer, table->primary, table->secondary, - ( crfIdx << 2 ) | L_bit, - RegIndex( opRa->reg ), RegIndex( opRb->reg ), + ( crf_idx << 2 ) | L_bit, RegIndex( opRa->reg ), RegIndex( opRb->reg ), ( ins->format->flags & table->optional ) | table->required ); } } @@ -464,8 +463,8 @@ static void ITCmpImmed( ins_table *table, instruction *ins, uint_32 *buffer, asm /*********************************************************************************************/ { ins_operand *op[4], *opRa, *opSimm; - uint crfIdx; - uint L_bit; + reg_idx crf_idx; + reg_idx L_bit; int ctr; ins_opcount opcount; op_type verify4[4] = { OP_CRF, OP_IMMED, OP_GPR, OP_IMMED }; @@ -476,25 +475,25 @@ static void ITCmpImmed( ins_table *table, instruction *ins, uint_32 *buffer, asm opcount = ins->num_operands; verify = ( opcount == 3 ) ? verify3 : verify4; for( ctr = 0; ctr < opcount; ctr++ ) { - if( !ensureTypeCorrect( op[ctr] = ins->operands[ctr], verify[ctr], ctr ) ) { + if( !checkTypeCorrect( op[ctr] = ins->operands[ctr], verify[ctr], ctr ) ) { return; } } if( opcount == 4 ) { - crfIdx = RegIndex( op[0]->reg ); + crf_idx = RegIndex( op[0]->reg ); ctr = 1; } else { // 3 operands - crfIdx = 0; + crf_idx = 0; ctr = 0; } - L_bit = op[ctr]->constant; - if( ( L_bit & 1 ) != L_bit ) { + L_bit = op[ctr]->constant & 1; + if( L_bit != op[ctr]->constant ) { Error( OP_OUT_OF_RANGE, ctr ); } if( checkOpAbsolute( op[ctr], ctr ) ) { opRa = op[++ctr]; opSimm = op[++ctr]; - doEncode2( buffer, table->primary, ( crfIdx << 2 ) | L_bit, + doEncode2( buffer, table->primary, (reg_idx)( ( crf_idx << 2 ) | L_bit ), RegIndex( opRa->reg ), opSimm->constant, ( ins->format->flags & table->optional ) | table->required ); doReloc( reloc, opSimm, OWL_RELOC_HALF_LO, 0 ); @@ -601,7 +600,7 @@ static void ITMfsr( ins_table *table, instruction *ins, uint_32 *buffer, asm_rel } if( checkOpAbsolute( const_op, 1 ) ) { doEncode3( buffer, table->primary, table->secondary, - RegIndex( ins->operands[0]->reg ), const_op->constant, 0, + RegIndex( ins->operands[0]->reg ), (reg_idx)const_op->constant, 0, ( ins->format->flags & table->optional ) | table->required ); } } @@ -700,7 +699,7 @@ static void ITMtfsfImmed( ins_table *table, instruction *ins, uint_32 *buffer, a } if( checkOpAbsolute( const_op, 1 ) ) { doEncode3( buffer, table->primary, table->secondary, - RegIndex( ins->operands[0]->reg ) << 2, 0, const_op->constant << 1, + RegIndex( ins->operands[0]->reg ) << 2, 0, (reg_idx)( const_op->constant << 1 ), ( ins->format->flags & table->optional ) | table->required ); } } @@ -739,7 +738,7 @@ static void ITMtsr( ins_table *table, instruction *ins, uint_32 *buffer, asm_rel } if( checkOpAbsolute( const_op, 1 ) ) { doEncode3( buffer, table->primary, table->secondary, - RegIndex( ins->operands[1]->reg ), const_op->constant, 0, + RegIndex( ins->operands[1]->reg ), (reg_idx)const_op->constant, 0, ( ins->format->flags & table->optional ) | table->required ); } } @@ -761,7 +760,8 @@ static void ITEieio( ins_table *table, instruction *ins, uint_32 *buffer, asm_re /* unused parameters */ (void)reloc; assert( ins->num_operands == 0 ); - doEncode3( buffer, table->primary, table->secondary, 0, 0, 0, + doEncode3( buffer, table->primary, table->secondary, + 0, 0, 0, ( ins->format->flags & table->optional ) | table->required ); } @@ -832,7 +832,7 @@ static void ITLswi( ins_table *table, instruction *ins, uint_32 *buffer, asm_rel if( checkOpAbsolute( op, 2 ) ) { doEncode3( buffer, table->primary, table->secondary, RegIndex( ins->operands[0]->reg ), RegIndex( ins->operands[1]->reg ), - op->constant, + (reg_idx)op->constant, ( ins->format->flags & table->optional ) | table->required ); } } @@ -849,7 +849,7 @@ static void ITShift( ins_table *table, instruction *ins, uint_32 *buffer, asm_re if( checkOpAbsolute( op, 2 ) ) { doEncode3( buffer, table->primary, table->secondary, RegIndex( ins->operands[1]->reg ), RegIndex( ins->operands[0]->reg ), - op->constant, + (reg_idx)op->constant, ( ins->format->flags & table->optional ) | table->required ); } } @@ -870,8 +870,8 @@ static void ITShiftImmed( ins_table *table, instruction *ins, uint_32 *buffer, a } } doEncode5( buffer, table->primary, RegIndex( ins->operands[1]->reg ), - RegIndex( ins->operands[0]->reg ), const_op[0]->constant, - const_op[1]->constant, const_op[2]->constant, + RegIndex( ins->operands[0]->reg ), (reg_idx)const_op[0]->constant, + (reg_idx)const_op[1]->constant, (reg_idx)const_op[2]->constant, ( ins->format->flags & table->optional ) | table->required ); } @@ -892,7 +892,7 @@ static void ITShiftIndex( ins_table *table, instruction *ins, uint_32 *buffer, a } doEncode5( buffer, table->primary, RegIndex( ins->operands[1]->reg ), RegIndex( ins->operands[0]->reg ), RegIndex( ins->operands[2]->reg ), - const_op[0]->constant, const_op[1]->constant, + (reg_idx)const_op[0]->constant, (reg_idx)const_op[1]->constant, ( ins->format->flags & table->optional ) | table->required ); } @@ -918,7 +918,8 @@ static void ITTrap( ins_table *table, instruction *ins, uint_32 *buffer, asm_rel op = ins->operands[0]; if( checkOpAbsolute( op, 0 ) ) { doEncode3( buffer, table->primary, table->secondary, - op->constant, RegIndex( ins->operands[1]->reg ), RegIndex( ins->operands[2]->reg ), + (reg_idx)op->constant, RegIndex( ins->operands[1]->reg ), + RegIndex( ins->operands[2]->reg ), ( ins->format->flags & table->optional ) | table->required ); } } @@ -932,7 +933,7 @@ static void ITTrapImmed( ins_table *table, instruction *ins, uint_32 *buffer, as op0 = ins->operands[0]; if( checkOpAbsolute( op0, 0 ) ) { op2 = ins->operands[2]; - doEncode2( buffer, table->primary, op0->constant, + doEncode2( buffer, table->primary, (reg_idx)op0->constant, RegIndex( ins->operands[1]->reg ), op2->constant, ( ins->format->flags & table->optional ) | table->required ); doReloc( reloc, op2, OWL_RELOC_HALF_LO, 0 ); @@ -997,30 +998,30 @@ static void ITSMCmpwi( ins_table *table, instruction *ins, uint_32 *buffer, asm_ /********************************************************************************************/ { ins_operand *op0, *opRa, *opSimm; - uint crfIdx; + reg_idx crf_idx; assert( ins->num_operands == 2 || ins->num_operands == 3 ); op0 = ins->operands[0]; if( ins->num_operands == 3 ) { - if( !ensureTypeCorrect( op0, OP_CRF, 0 ) ) + if( !checkTypeCorrect( op0, OP_CRF, 0 ) ) return; - crfIdx = RegIndex( op0->reg ); + crf_idx = RegIndex( op0->reg ); opRa = ins->operands[1]; - if( !ensureTypeCorrect( opRa, OP_GPR, 1 ) ) + if( !checkTypeCorrect( opRa, OP_GPR, 1 ) ) return; opSimm = ins->operands[2]; assert( opSimm->type == OP_IMMED ); } else { // 2 operands - crfIdx = 0; + crf_idx = 0; opRa = op0; opSimm = ins->operands[1]; - if( !ensureTypeCorrect( opRa, OP_GPR, 0 ) ) + if( !checkTypeCorrect( opRa, OP_GPR, 0 ) ) return; - if( !ensureTypeCorrect( opSimm, OP_IMMED, 1 ) ) { + if( !checkTypeCorrect( opSimm, OP_IMMED, 1 ) ) { return; } } - doEncode2( buffer, table->primary, crfIdx << 2, + doEncode2( buffer, table->primary, (reg_idx)( crf_idx << 2 ), RegIndex( opRa->reg ), opSimm->constant, ( ins->format->flags & table->optional ) | table->required ); doReloc( reloc, opSimm, OWL_RELOC_HALF_LO, 0 ); @@ -1030,30 +1031,30 @@ static void ITSMCmpw( ins_table *table, instruction *ins, uint_32 *buffer, asm_r /*******************************************************************************************/ { ins_operand *op0, *opRa, *opRb; - uint crfIdx; + reg_idx crf_idx; /* unused parameters */ (void)reloc; assert( ins->num_operands == 2 || ins->num_operands == 3 ); op0 = ins->operands[0]; if( ins->num_operands == 3 ) { - if( !ensureTypeCorrect( op0, OP_CRF, 0 ) ) + if( !checkTypeCorrect( op0, OP_CRF, 0 ) ) return; - crfIdx = RegIndex( op0->reg ); + crf_idx = RegIndex( op0->reg ); opRa = ins->operands[1]; opRb = ins->operands[2]; assert( opRa->type == OP_GPR ); assert( opRb->type == OP_GPR ); } else { // 2 operands - crfIdx = 0; + crf_idx = 0; opRa = op0; opRb = ins->operands[1]; - if( !ensureTypeCorrect( opRa, OP_GPR, 0 ) ) + if( !checkTypeCorrect( opRa, OP_GPR, 0 ) ) return; assert( opRb->type == OP_GPR ); } - doEncode3( buffer, table->primary, table->secondary, crfIdx << 2, - RegIndex( opRa->reg ), RegIndex( opRb->reg ), + doEncode3( buffer, table->primary, table->secondary, + crf_idx << 2, RegIndex( opRa->reg ), RegIndex( opRb->reg ), ( ins->format->flags & table->optional ) | table->required ); } @@ -1073,8 +1074,8 @@ static void ITSMExtlwi( ins_table *table, instruction *ins, uint_32 *buffer, asm } } doEncode5( buffer, table->primary, RegIndex( ins->operands[1]->reg ), - RegIndex( ins->operands[0]->reg ), const_op[1]->constant, 0, - const_op[0]->constant - 1, + RegIndex( ins->operands[0]->reg ), (reg_idx)const_op[1]->constant, 0, + (reg_idx)( const_op[0]->constant - 1 ), ( ins->format->flags & table->optional ) | table->required ); } @@ -1082,7 +1083,7 @@ static void ITSMSrwi( ins_table *table, instruction *ins, uint_32 *buffer, asm_r /*******************************************************************************************/ { ins_operand *const_op; - uint n; + reg_idx n; reg_idx sh = 0; reg_idx mb = 0; reg_idx me = 0; @@ -1093,7 +1094,7 @@ static void ITSMSrwi( ins_table *table, instruction *ins, uint_32 *buffer, asm_r const_op = ins->operands[2]; if( !checkOpAbsolute( const_op, 2 ) ) return; - n = const_op->constant; + n = (reg_idx)const_op->constant; switch( table->special ) { case SRWI: sh = 32 - n; @@ -1126,9 +1127,10 @@ static void ITSMRotlw( ins_table *table, instruction *ins, uint_32 *buffer, asm_ static void ITSMInslw( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) /********************************************************************************************/ { - ins_operand *const_op[2]; - uint n, b; - int ctr; + ins_operand *const_op[2]; + reg_idx n; + reg_idx b; + int ctr; /* unused parameters */ (void)reloc; @@ -1139,8 +1141,8 @@ static void ITSMInslw( ins_table *table, instruction *ins, uint_32 *buffer, asm_ return; } } - n = const_op[0]->constant; - b = const_op[1]->constant; + n = (reg_idx)const_op[0]->constant; + b = (reg_idx)const_op[1]->constant; doEncode5( buffer, table->primary, RegIndex( ins->operands[1]->reg ), RegIndex( ins->operands[0]->reg ), 32 - b, b, b + n - 1, ( ins->format->flags & table->optional ) | table->required ); @@ -1152,7 +1154,8 @@ static void ITSMTrapUncond( ins_table *table, instruction *ins, uint_32 *buffer, /* unused parameters */ (void)reloc; assert( ins->num_operands == 0 ); - doEncode3( buffer, table->primary, table->secondary, TO_ANY, 0, 0, + doEncode3( buffer, table->primary, table->secondary, + TO_ANY, 0, 0, ( ins->format->flags & table->optional ) | table->required ); } @@ -1162,8 +1165,9 @@ static void ITSMTrap( ins_table *table, instruction *ins, uint_32 *buffer, asm_r /* unused parameters */ (void)reloc; assert( ins->num_operands == 2 ); - doEncode3( buffer, table->primary, table->secondary, table->special, - RegIndex( ins->operands[0]->reg ), RegIndex( ins->operands[1]->reg ), + doEncode3( buffer, table->primary, table->secondary, + (reg_idx)table->special, RegIndex( ins->operands[0]->reg ), + RegIndex( ins->operands[1]->reg ), ( ins->format->flags & table->optional ) | table->required ); } @@ -1174,7 +1178,7 @@ static void ITSMTrapImmed( ins_table *table, instruction *ins, uint_32 *buffer, assert( ins->num_operands == 2 ); op1 = ins->operands[1]; - doEncode2( buffer, table->primary, table->special, + doEncode2( buffer, table->primary, (reg_idx)table->special, RegIndex( ins->operands[0]->reg ), op1->constant, ( ins->format->flags & table->optional ) | table->required ); doReloc( reloc, op1, OWL_RELOC_HALF_LO, 0 ); @@ -1258,14 +1262,14 @@ static void ITSMBCIcc( ins_table *table, instruction *ins, uint_32 *buffer, asm_ assert( ins->num_operands == 1 || ins->num_operands == 2 ); op0 = ins->operands[0]; if( ins->num_operands == 1 ) { - if( !ensureTypeCorrect( op0, OP_IMMED, 0 ) ) + if( !checkTypeCorrect( op0, OP_IMMED, 0 ) ) return; opBd = op0; startBI = 0; } else { // ins->num_operands == 2 opBd = ins->operands[1]; assert( opBd->type == OP_IMMED ); - if( !ensureTypeCorrect( op0, OP_CRF, 0 ) ) + if( !checkTypeCorrect( op0, OP_CRF, 0 ) ) return; startBI = RegCrfToBI( op0->reg ); } @@ -1294,14 +1298,14 @@ static void ITSMBC( ins_table *table, instruction *ins, uint_32 *buffer, asm_rel op0 = ins->operands[0]; switch( ins->num_operands ) { case 1: // case i - if( !ensureTypeCorrect( op0, OP_IMMED, 0 ) ) + if( !checkTypeCorrect( op0, OP_IMMED, 0 ) ) return; valueBI = 0; opBd = op0; break; case 2: // cases ii, iii, iv opBd = ins->operands[1]; - if( !ensureTypeCorrect( opBd, OP_IMMED, 1 ) ) + if( !checkTypeCorrect( opBd, OP_IMMED, 1 ) ) return; switch( op0->type ) { case OP_CRF: diff --git a/bld/as/ppc/h/inslist.h b/bld/as/ppc/h/inslist.h index bd9c781322..3fb68c23cc 100644 --- a/bld/as/ppc/h/inslist.h +++ b/bld/as/ppc/h/inslist.h @@ -44,9 +44,8 @@ typedef enum { IF_SETS_LINK = 0x08, } ins_flags; -typedef uint_16 ins_opcode; - -typedef uint_16 ins_special; +typedef uint_16 ins_opcode; +typedef uint_16 ins_special; typedef enum { NOTHING = 0x00, @@ -64,8 +63,9 @@ typedef enum { OP_BI = (1 << (REGCLASS_COUNT + 2)), // BI field in branch instructions } op_type; -typedef int_32 op_const; -typedef reg op_reg; /* from chip-specific register.h - must be included before inslist.h */ +typedef int_32 op_const; +typedef reg op_reg; /* from chip-specific register.h - must be included before inslist.h */ + typedef struct { union { int_32 label; From a4b820d964fedcee0ba0d31011e22a85b6b86055 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Tue, 3 Oct 2023 08:28:47 +0200 Subject: [PATCH 198/258] rename file to be consistent with other architecture --- bld/cg/risc/ppc/c/ppcenc.c | 2 +- bld/cg/risc/ppc/c/ppcproc.c | 2 +- bld/cg/risc/ppc/h/{ppcgen.h => ppcenc.h} | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) rename bld/cg/risc/ppc/h/{ppcgen.h => ppcenc.h} (96%) diff --git a/bld/cg/risc/ppc/c/ppcenc.c b/bld/cg/risc/ppc/c/ppcenc.c index 720b7897fe..c8c95ff3fd 100644 --- a/bld/cg/risc/ppc/c/ppcenc.c +++ b/bld/cg/risc/ppc/c/ppcenc.c @@ -40,7 +40,7 @@ #include "cgauxinf.h" #include "optmain.h" #include "ppcencod.h" -#include "ppcgen.h" +#include "ppcenc.h" #include "data.h" #include "objout.h" #include "dbsyms.h" diff --git a/bld/cg/risc/ppc/c/ppcproc.c b/bld/cg/risc/ppc/c/ppcproc.c index 666c0b485d..1fb345f889 100644 --- a/bld/cg/risc/ppc/c/ppcproc.c +++ b/bld/cg/risc/ppc/c/ppcproc.c @@ -34,7 +34,7 @@ #include "coderep.h" #include "cgmem.h" #include "ppcencod.h" -#include "ppcgen.h" +#include "ppcenc.h" #include "data.h" #include "objout.h" #include "dbsyms.h" diff --git a/bld/cg/risc/ppc/h/ppcgen.h b/bld/cg/risc/ppc/h/ppcenc.h similarity index 96% rename from bld/cg/risc/ppc/h/ppcgen.h rename to bld/cg/risc/ppc/h/ppcenc.h index 8c5bb17866..e38b130aa7 100644 --- a/bld/cg/risc/ppc/h/ppcgen.h +++ b/bld/cg/risc/ppc/h/ppcenc.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== From 1aaae18595ff6fd962bff57611cf659011f9bfcc Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Tue, 3 Oct 2023 08:48:46 +0200 Subject: [PATCH 199/258] restructure header files references to be more transparent --- bld/cg/risc/axp/c/axpenc.c | 1 - bld/cg/risc/axp/c/axpenc2.c | 2 +- bld/cg/risc/axp/c/axpproc.c | 1 - bld/cg/risc/axp/h/axpenc.h | 5 ++++- bld/cg/risc/c/rscobj.c | 1 - bld/cg/risc/mps/c/mpsenc.c | 1 - bld/cg/risc/mps/c/mpsenc2.c | 2 +- bld/cg/risc/mps/c/mpsproc.c | 1 - bld/cg/risc/mps/h/mpsenc.h | 5 ++++- bld/cg/risc/ppc/c/ppcenc.c | 1 - bld/cg/risc/ppc/c/ppcenc2.c | 2 +- bld/cg/risc/ppc/c/ppcproc.c | 1 - bld/cg/risc/ppc/h/ppcenc.h | 4 ++++ 13 files changed, 15 insertions(+), 12 deletions(-) diff --git a/bld/cg/risc/axp/c/axpenc.c b/bld/cg/risc/axp/c/axpenc.c index 14ae427743..8a97bf479f 100644 --- a/bld/cg/risc/axp/c/axpenc.c +++ b/bld/cg/risc/axp/c/axpenc.c @@ -34,7 +34,6 @@ #include #include "coderep.h" #include "optmain.h" -#include "axpencod.h" #include "reloc.h" #include "zoiks.h" #include "coff.h" diff --git a/bld/cg/risc/axp/c/axpenc2.c b/bld/cg/risc/axp/c/axpenc2.c index 508ee5463a..fd19860f8b 100644 --- a/bld/cg/risc/axp/c/axpenc2.c +++ b/bld/cg/risc/axp/c/axpenc2.c @@ -34,10 +34,10 @@ #include "_cgstd.h" #include "coderep.h" #include "symdbg.h" -#include "axpencod.h" #include "reloc.h" #include "rscenc2.h" #include "rscobj.h" +#include "axpenc.h" void EncodeRet( oc_ret *oc ) { diff --git a/bld/cg/risc/axp/c/axpproc.c b/bld/cg/risc/axp/c/axpproc.c index 5a7c308068..27794fb5e4 100644 --- a/bld/cg/risc/axp/c/axpproc.c +++ b/bld/cg/risc/axp/c/axpproc.c @@ -34,7 +34,6 @@ #include "coderep.h" #include "cgmem.h" #include "zoiks.h" -#include "axpencod.h" #include "data.h" #include "rtrtn.h" #include "objout.h" diff --git a/bld/cg/risc/axp/h/axpenc.h b/bld/cg/risc/axp/h/axpenc.h index 15f9d1ebd1..959b203417 100644 --- a/bld/cg/risc/axp/h/axpenc.h +++ b/bld/cg/risc/axp/h/axpenc.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -30,6 +30,9 @@ ****************************************************************************/ +#include "axpencod.h" + + extern void GenCallLabelReg( pointer label, uint reg ); extern void GenOPINS( uint_8 opcode, uint_8 function, uint_8 reg_a, uint_8 reg_b, uint_8 reg_c ); extern void GenLOADS32( signed_32 value, uint_8 reg ); diff --git a/bld/cg/risc/c/rscobj.c b/bld/cg/risc/c/rscobj.c index 477f039633..87feec0d5b 100644 --- a/bld/cg/risc/c/rscobj.c +++ b/bld/cg/risc/c/rscobj.c @@ -41,7 +41,6 @@ #include "owl.h" #include "rscobj.h" #include "autodep.h" -#include "axpencod.h" #include "data.h" #include "rtrtn.h" #include "utils.h" diff --git a/bld/cg/risc/mps/c/mpsenc.c b/bld/cg/risc/mps/c/mpsenc.c index b6080b617e..aadd52f4b8 100644 --- a/bld/cg/risc/mps/c/mpsenc.c +++ b/bld/cg/risc/mps/c/mpsenc.c @@ -34,7 +34,6 @@ #include #include "coderep.h" #include "optmain.h" -#include "mipsenco.h" #include "reloc.h" #include "zoiks.h" #include "coff.h" diff --git a/bld/cg/risc/mps/c/mpsenc2.c b/bld/cg/risc/mps/c/mpsenc2.c index f7eb264036..2996a30ee2 100644 --- a/bld/cg/risc/mps/c/mpsenc2.c +++ b/bld/cg/risc/mps/c/mpsenc2.c @@ -33,10 +33,10 @@ #include "_cgstd.h" #include "coderep.h" #include "symdbg.h" -#include "mipsenco.h" #include "reloc.h" #include "rscenc2.h" #include "rscobj.h" +#include "mpsenc.h" void EncodeRet( oc_ret *oc ) diff --git a/bld/cg/risc/mps/c/mpsproc.c b/bld/cg/risc/mps/c/mpsproc.c index b377c3d2fb..d377e0c325 100644 --- a/bld/cg/risc/mps/c/mpsproc.c +++ b/bld/cg/risc/mps/c/mpsproc.c @@ -34,7 +34,6 @@ #include "coderep.h" #include "cgmem.h" #include "zoiks.h" -#include "mipsenco.h" #include "data.h" #include "rtrtn.h" #include "objout.h" diff --git a/bld/cg/risc/mps/h/mpsenc.h b/bld/cg/risc/mps/h/mpsenc.h index 063dec12d0..34fd1db883 100644 --- a/bld/cg/risc/mps/h/mpsenc.h +++ b/bld/cg/risc/mps/h/mpsenc.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -30,6 +30,9 @@ ****************************************************************************/ +#include "mipsenco.h" + + extern void GenCallLabelReg( pointer label, uint reg ); extern void GenLOADS32( signed_32 value, uint_8 reg ); extern void GenMEMINSRELOC( uint_8 opcode, uint_8 rt, uint_8 rs, signed_16 displacement, pointer lbl, owl_reloc_type type ); diff --git a/bld/cg/risc/ppc/c/ppcenc.c b/bld/cg/risc/ppc/c/ppcenc.c index c8c95ff3fd..4b01195911 100644 --- a/bld/cg/risc/ppc/c/ppcenc.c +++ b/bld/cg/risc/ppc/c/ppcenc.c @@ -39,7 +39,6 @@ #include "cgauxcc.h" #include "cgauxinf.h" #include "optmain.h" -#include "ppcencod.h" #include "ppcenc.h" #include "data.h" #include "objout.h" diff --git a/bld/cg/risc/ppc/c/ppcenc2.c b/bld/cg/risc/ppc/c/ppcenc2.c index 3eef85e47c..0d30c57a51 100644 --- a/bld/cg/risc/ppc/c/ppcenc2.c +++ b/bld/cg/risc/ppc/c/ppcenc2.c @@ -34,10 +34,10 @@ #include "_cgstd.h" #include "coderep.h" #include "symdbg.h" -#include "ppcencod.h" #include "reloc.h" #include "rscenc2.h" #include "rscobj.h" +#include "ppcenc.h" void EncodeRet( oc_ret *oc ) { diff --git a/bld/cg/risc/ppc/c/ppcproc.c b/bld/cg/risc/ppc/c/ppcproc.c index 1fb345f889..5faa8bab89 100644 --- a/bld/cg/risc/ppc/c/ppcproc.c +++ b/bld/cg/risc/ppc/c/ppcproc.c @@ -33,7 +33,6 @@ #include "_cgstd.h" #include "coderep.h" #include "cgmem.h" -#include "ppcencod.h" #include "ppcenc.h" #include "data.h" #include "objout.h" diff --git a/bld/cg/risc/ppc/h/ppcenc.h b/bld/cg/risc/ppc/h/ppcenc.h index e38b130aa7..5668af2178 100644 --- a/bld/cg/risc/ppc/h/ppcenc.h +++ b/bld/cg/risc/ppc/h/ppcenc.h @@ -29,6 +29,10 @@ * ****************************************************************************/ + +#include "ppcencod.h" + + typedef uint_32 gen_opcode; typedef uint_32 reg_idx; From e846e9d1f96c9c36bd5bbb4570cd10f7776874e1 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Tue, 3 Oct 2023 14:14:00 +0200 Subject: [PATCH 200/258] cleanup cg code --- bld/cg/risc/axp/c/axpenc.c | 4 +- bld/cg/risc/axp/c/axprgtbl.c | 61 ++++++++++++++++++------------- bld/cg/risc/axp/h/axpenc.h | 2 +- bld/cg/risc/mps/c/mpsenc.c | 8 ++-- bld/cg/risc/mps/c/mpsrgtbl.c | 71 +++++++++++++++++++++--------------- bld/cg/risc/mps/h/mpsenc.h | 3 +- bld/cg/risc/ppc/c/ppcrgtbl.c | 68 +++++++++++++++++++--------------- 7 files changed, 125 insertions(+), 92 deletions(-) diff --git a/bld/cg/risc/axp/c/axpenc.c b/bld/cg/risc/axp/c/axpenc.c index 8a97bf479f..42b5da111e 100644 --- a/bld/cg/risc/axp/c/axpenc.c +++ b/bld/cg/risc/axp/c/axpenc.c @@ -384,8 +384,8 @@ static uint_16 FindFloatingOpcodes( instruction *ins ) return( opcode ); } -void GenMEMINSRELOC( uint_8 opcode, uint_8 a, uint_8 b, signed_16 displacement, pointer lbl, owl_reloc_type type ) -/****************************************************************************************************************/ +static void GenMEMINSRELOC( uint_8 opcode, uint_8 a, uint_8 b, signed_16 displacement, pointer lbl, owl_reloc_type type ) +/***********************************************************************************************************************/ { ins_encoding = _Opcode( opcode ) | _Ra( a ) | _Rb( b ) | _SignedImmed( displacement ); EmitInsReloc( &ins_encoding, lbl, type ); diff --git a/bld/cg/risc/axp/c/axprgtbl.c b/bld/cg/risc/axp/c/axprgtbl.c index 76b4b20495..aad990b679 100644 --- a/bld/cg/risc/axp/c/axprgtbl.c +++ b/bld/cg/risc/axp/c/axprgtbl.c @@ -34,6 +34,7 @@ #include "_cgstd.h" #include "coderep.h" #include "axpregn.h" +#include "axpenc.h" #include "zoiks.h" #include "data.h" #include "rgtbl.h" @@ -790,52 +791,62 @@ void InitRegTbl( void ) { } -byte RegTrans( hw_reg_set reg ) -/****************************************/ +static int regTranslate( hw_reg_set reg, bool index ) +/********************************************************/ { - int i; + int i; /* * This should be cached in the reg name and used instead of a stupid lookup */ for( i = 0; i < sizeof( QWordRegs ) / sizeof( QWordRegs[0] ); i++ ) { if( HW_Subset( QWordRegs[i], reg ) ) { - return( i ); + if( index ) + return( i ); + return( i+AXP_REGN_r0 ); } } for( i = 0; i < sizeof( FloatRegs ) / sizeof( FloatRegs[0] ); i++ ) { if( HW_Equal( reg, FloatRegs[i] ) ) { - return( i ); + if( index ) + return( i ); + return( i+AXP_REGN_f0 ); } } - return( 0 ); + if( index ) + return( 0 ); + _Zoiks( ZOIKS_031 ); + return( AXP_REGN_END ); } -void SetArchIndex( name *new_r, hw_reg_set regs ) +reg_idx RegIndex( hw_reg_set reg ) +/********************************* + * Translate reg to register index + */ { - new_r->r.arch_index = RegTrans( regs ); + return( regTranslate( reg, true ) ); } +void SetArchIndex( name *new_r, hw_reg_set regs ) +/***********************************************/ +{ + new_r->r.arch_index = RegIndex( regs ); +} -axp_regn RegTransN( name *reg_name ) -/***** Translate reg name to enum name ****/ +byte RegTrans( hw_reg_set reg ) +/********************************* + * Translate reg to register index + */ { - hw_reg_set reg; - int i; - reg = reg_name->r.reg; + return( regTranslate( reg, true ) ); +} - for( i = 0; i < sizeof( QWordRegs ) / sizeof( QWordRegs[0] ); i++ ) { - if( HW_Subset( QWordRegs[i], reg ) ) { - return( i+AXP_REGN_r0 ); - } - } - for( i = 0; i < sizeof( FloatRegs ) / sizeof( FloatRegs[0] ); i++ ) { - if( HW_Equal( reg, FloatRegs[i] ) ) { - return( i+AXP_REGN_f0 ); - } - } - _Zoiks( ZOIKS_031 ); - return( AXP_REGN_END ); +axp_regn RegTransN( name *reg_name ) +/************************************** + * Translate reg name to enum name + */ +{ + return( regTranslate( reg_name->r.reg, false ) ); } diff --git a/bld/cg/risc/axp/h/axpenc.h b/bld/cg/risc/axp/h/axpenc.h index 959b203417..8b3c37ed8d 100644 --- a/bld/cg/risc/axp/h/axpenc.h +++ b/bld/cg/risc/axp/h/axpenc.h @@ -32,11 +32,11 @@ #include "axpencod.h" +typedef uint_8 reg_idx; extern void GenCallLabelReg( pointer label, uint reg ); extern void GenOPINS( uint_8 opcode, uint_8 function, uint_8 reg_a, uint_8 reg_b, uint_8 reg_c ); extern void GenLOADS32( signed_32 value, uint_8 reg ); -extern void GenMEMINSRELOC( uint_8 opcode, uint_8 a, uint_8 b, signed_16 displacement, pointer lbl, owl_reloc_type type ); extern void GenMEMINS( uint_8 opcode, uint_8 a, uint_8 b, signed_16 displacement ); extern void GenLOAD( hw_reg_set dst, hw_reg_set src, signed_16 displacement ); extern void GenFLOAD( hw_reg_set dst, hw_reg_set src, signed_16 displacement ); diff --git a/bld/cg/risc/mps/c/mpsenc.c b/bld/cg/risc/mps/c/mpsenc.c index aadd52f4b8..85f0581524 100644 --- a/bld/cg/risc/mps/c/mpsenc.c +++ b/bld/cg/risc/mps/c/mpsenc.c @@ -386,18 +386,18 @@ static uint_8 FindFloatingOpcodes( instruction *ins ) } -void GenMEMINSRELOC( uint_8 opcode, uint_8 rt, uint_8 rs, int_16 displacement, pointer lbl, owl_reloc_type type ) -/**************************************************************************************************************************/ +static void GenMEMINSRELOC( uint_8 opcode, uint_8 rt, uint_8 rs, int_16 displacement, pointer lbl, owl_reloc_type type ) +/**********************************************************************************************************************/ { ins_encoding = _Opcode( opcode ) | _Rt( rt ) | _Rs( rs ) | _SignedImmed( displacement ); EmitInsReloc( &ins_encoding, lbl, type ); } -void GenMEMINS( uint_8 opcode, uint_8 a, uint_8 b, int_16 displacement ) +void GenMEMINS( uint_8 opcode, uint_8 rt, uint_8 rs, int_16 displacement ) /*********************************************************************************/ { - ins_encoding = _Opcode( opcode ) | _Rt( a ) | _Rs( b ) | _SignedImmed( displacement ); + ins_encoding = _Opcode( opcode ) | _Rt( rt ) | _Rs( rs ) | _SignedImmed( displacement ); EmitIns( ins_encoding ); } diff --git a/bld/cg/risc/mps/c/mpsrgtbl.c b/bld/cg/risc/mps/c/mpsrgtbl.c index c518c11794..d5bbb5578c 100644 --- a/bld/cg/risc/mps/c/mpsrgtbl.c +++ b/bld/cg/risc/mps/c/mpsrgtbl.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2016 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -33,6 +33,7 @@ #include "_cgstd.h" #include "coderep.h" #include "mpsregn.h" +#include "mpsenc.h" #include "zoiks.h" #include "data.h" #include "rgtbl.h" @@ -852,8 +853,8 @@ void InitRegTbl( void ) } -byte RegTrans( hw_reg_set reg ) -/********************************/ +static int regTranslate( hw_reg_set reg, bool index ) +/********************************************************/ { int i; @@ -862,50 +863,60 @@ byte RegTrans( hw_reg_set reg ) */ for( i = 0; i < sizeof( GeneralRegs ) / sizeof( GeneralRegs[0] ); i++ ) { if( HW_Subset( GeneralRegs[i], reg ) ) { - return( i ); + if( index ) + return( i ); + return( i + MIPS_REGN_r0 ); } } - for( i = 0; i < sizeof( QWordRegs ) / sizeof( QWordRegs[0] ); i++ ) { - if( HW_Subset( QWordRegs[i], reg ) ) { - return( i * 2 + 2 ); + if( index ) { + for( i = 0; i < sizeof( QWordRegs ) / sizeof( QWordRegs[0] ); i++ ) { + if( HW_Subset( QWordRegs[i], reg ) ) { + return( i * 2 + 2 ); + } } } for( i = 0; i < sizeof( FloatRegs ) / sizeof( FloatRegs[0] ); i++ ) { if( HW_Equal( reg, FloatRegs[i] ) ) { - return( i ); + if( index ) + return( i ); + return( i + MIPS_REGN_f0 ); } } - return( 0 ); + if( index ) + return( 0 ); + _Zoiks( ZOIKS_031 ); + return( MIPS_REGN_END ); } - -mips_regn RegTransN( name *reg_name ) -/************************************ - * Translate reg name to enum name +reg_idx RegIndex( hw_reg_set reg ) +/********************************* + * Translate reg to register index */ { - hw_reg_set reg; - int i; - reg = reg_name->r.reg; + return( regTranslate( reg, true ) ); +} - for( i = 0; i < sizeof( GeneralRegs ) / sizeof( GeneralRegs[0] ); i++ ) { - if( HW_Subset( GeneralRegs[i], reg ) ) { - return( i + MIPS_REGN_r0 ); - } - } - for( i = 0; i < sizeof( FloatRegs ) / sizeof( FloatRegs[0] ); i++ ) { - if( HW_Equal( reg, FloatRegs[i] ) ) { - return( i + MIPS_REGN_f0 ); - } - } - _Zoiks( ZOIKS_031 ); - return( MIPS_REGN_END ); +void SetArchIndex( name *new_r, hw_reg_set regs ) +/***********************************************/ +{ + new_r->r.arch_index = RegIndex( regs ); } -void SetArchIndex( name *new_r, hw_reg_set regs ) +byte RegTrans( hw_reg_set reg ) +/********************************* + * Translate reg to register index + */ +{ + return( regTranslate( reg, true ) ); +} + +mips_regn RegTransN( name *reg_name ) +/*************************************** + * Translate reg name to enum name + */ { - new_r->r.arch_index = RegTrans( regs ); + return( regTranslate( reg_name->r.reg, false ) ); } diff --git a/bld/cg/risc/mps/h/mpsenc.h b/bld/cg/risc/mps/h/mpsenc.h index 34fd1db883..375b3e4a7a 100644 --- a/bld/cg/risc/mps/h/mpsenc.h +++ b/bld/cg/risc/mps/h/mpsenc.h @@ -33,9 +33,10 @@ #include "mipsenco.h" +typedef uint_8 reg_idx; + extern void GenCallLabelReg( pointer label, uint reg ); extern void GenLOADS32( signed_32 value, uint_8 reg ); -extern void GenMEMINSRELOC( uint_8 opcode, uint_8 rt, uint_8 rs, signed_16 displacement, pointer lbl, owl_reloc_type type ); extern void GenMEMINS( uint_8 opcode, uint_8 a, uint_8 b, signed_16 displacement ); extern void GenIType( uint_8 opcode, uint_8 rt, uint_8 rs, signed_16 immed ); extern void GenRType( uint_8 opcode, uint_8 fc, uint_8 rd, uint_8 rs, uint_8 rt ); diff --git a/bld/cg/risc/ppc/c/ppcrgtbl.c b/bld/cg/risc/ppc/c/ppcrgtbl.c index 787edb1ac1..e8887495f6 100644 --- a/bld/cg/risc/ppc/c/ppcrgtbl.c +++ b/bld/cg/risc/ppc/c/ppcrgtbl.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2016 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -33,6 +33,7 @@ #include "_cgstd.h" #include "coderep.h" #include "ppcregn.h" +#include "ppcenc.h" #include "zoiks.h" #include "data.h" #include "rgtbl.h" @@ -781,59 +782,68 @@ void InitRegTbl( void ) { } -byte RegTrans( hw_reg_set reg ) -/********************************/ +static int regTranslate( hw_reg_set reg, bool index ) +/****************************************************/ { int i; for( i = 0; i < sizeof( DWordRegs ) / sizeof( DWordRegs[0] ); i++ ) { if( HW_Subset( DWordRegs[i], reg ) ) { - return( i ); - } - } - for( i = 0; i < sizeof( FloatRegs ) / sizeof( FloatRegs[0] ); i++ ) { - if( HW_Equal( reg, FloatRegs[i] ) ) { - return( i ); - } - } - return( 0 ); -} - -ppc_regn RegTransN( name *reg_name ) -/**********************************/ -/***** Translate reg name to enum name ****/ -{ - hw_reg_set reg; - int i; - - reg = reg_name->r.reg; - - for( i = 0; i < sizeof( DWordRegs ) / sizeof( DWordRegs[0] ); i++ ) { - if( HW_Subset( DWordRegs[i], reg ) ) { + if( index ) + return( i ); return( i + PPC_REGN_r0 ); } } for( i = 0; i < sizeof( FloatRegs ) / sizeof( FloatRegs[0] ); i++ ) { if( HW_Equal( reg, FloatRegs[i] ) ) { + if( index ) + return( i ); return( i + PPC_REGN_f0 ); } } + if( index ) + return( 0 ); _Zoiks( ZOIKS_031 ); return( PPC_REGN_END ); } -hw_reg_set ParmRegConflicts( hw_reg_set r ) -/*****************************************/ +reg_idx RegIndex( hw_reg_set reg ) +/********************************* + * Translate reg to register index + */ { - return( r ); + return( regTranslate( reg, true ) ); } - void SetArchIndex( name *new_r, hw_reg_set regs ) +/***********************************************/ { new_r->r.arch_index = RegTrans( regs ); } +byte RegTrans( hw_reg_set reg ) +/********************************* + * Translate reg to register index + */ +{ + return( regTranslate( reg, true ) ); +} + +ppc_regn RegTransN( name *reg_name ) +/************************************** + * Translate reg name to enum name + */ +{ + return( regTranslate( reg_name->r.reg, false ) ); +} + + +hw_reg_set ParmRegConflicts( hw_reg_set r ) +/*****************************************/ +{ + return( r ); +} + hw_reg_set FirstReg( reg_set_index regs_idx ) /************************************************* From 6b9666b7f4fee37e34aef1979197f4e0a4c59dfd Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Tue, 3 Oct 2023 15:25:52 +0200 Subject: [PATCH 201/258] correct register translation functions now exists 3 translation functions RegIndex reg -> code gen reg index RegTrans reg -> debug info reg RegTransN name -> debug info reg --- bld/cg/h/rgtbl.h | 3 +- bld/cg/risc/axp/c/axpenc.c | 126 ++++++++++++++++---------------- bld/cg/risc/axp/c/axpproc.c | 2 +- bld/cg/risc/axp/c/axprgtbl.c | 12 +-- bld/cg/risc/axp/h/axpenc.h | 2 + bld/cg/risc/axp/h/axpregn.h | 138 ++++++++++++++++++----------------- bld/cg/risc/mps/c/mpsenc.c | 124 +++++++++++++++---------------- bld/cg/risc/mps/c/mpsproc.c | 2 +- bld/cg/risc/mps/c/mpsrgtbl.c | 10 +-- bld/cg/risc/mps/h/mpsenc.h | 2 + bld/cg/risc/mps/h/mpsregn.h | 4 +- bld/cg/risc/ppc/c/ppcenc.c | 100 ++++++++++++------------- bld/cg/risc/ppc/c/ppcproc.c | 2 +- bld/cg/risc/ppc/c/ppcrgtbl.c | 12 +-- bld/cg/risc/ppc/h/ppcenc.h | 16 ++-- bld/cg/risc/ppc/h/ppcregn.h | 134 +++++++++++++++++----------------- 16 files changed, 350 insertions(+), 339 deletions(-) diff --git a/bld/cg/h/rgtbl.h b/bld/cg/h/rgtbl.h index d421e7aaf9..62b5759cc8 100644 --- a/bld/cg/h/rgtbl.h +++ b/bld/cg/h/rgtbl.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -85,7 +85,6 @@ extern reg_set_index UsualPossible( type_class_def type_class ); extern hw_reg_set FrameBaseReg( void ); extern hw_reg_set FrameReg( void ); extern void SetArchIndex( name *new_r, hw_reg_set regs ); -extern byte RegTrans( hw_reg_set reg ); extern hw_reg_set *ParmRegs( void ); extern hw_reg_set *GPRegs( void ); extern hw_reg_set *FPRegs( void ); diff --git a/bld/cg/risc/axp/c/axpenc.c b/bld/cg/risc/axp/c/axpenc.c index 42b5da111e..b03256a202 100644 --- a/bld/cg/risc/axp/c/axpenc.c +++ b/bld/cg/risc/axp/c/axpenc.c @@ -60,7 +60,7 @@ #include "feprotos.h" -#define _NameReg( op ) ( (op)->r.arch_index ) +#define _NameRegIndex( op ) ( (op)->r.arch_index ) #define _BinaryOpcode( a, b ) { { a, b }, { a, b } } #define _SignedOpcode( a, b, c, d ) { { a, b }, { c, d } } @@ -412,13 +412,13 @@ static void GenBRANCH( uint_8 opcode, uint_8 reg, pointer label ) void GenLOAD( hw_reg_set dst, hw_reg_set src, signed_16 displacement ) /***********************************************************************/ { - GenMEMINS( 0x29, RegTrans( dst ), RegTrans( src ), displacement ); + GenMEMINS( 0x29, RegIndex( dst ), RegIndex( src ), displacement ); } void GenFLOAD( hw_reg_set dst, hw_reg_set src, signed_16 displacement ) /************************************************************************/ { - GenMEMINS( 0x23, RegTrans( dst ), RegTrans( src ), displacement ); + GenMEMINS( 0x23, RegIndex( dst ), RegIndex( src ), displacement ); } /* @@ -428,7 +428,7 @@ void GenFLOAD( hw_reg_set dst, hw_reg_set src, signed_16 displacement ) void GenSTORE( hw_reg_set dst, signed_16 displacement, hw_reg_set src ) /************************************************************************/ { - GenMEMINS( 0x2d, RegTrans( src ), RegTrans( dst ), displacement ); + GenMEMINS( 0x2d, RegIndex( src ), RegIndex( dst ), displacement ); } /* @@ -438,7 +438,7 @@ void GenSTORE( hw_reg_set dst, signed_16 displacement, hw_reg_set src ) void GenFSTORE( hw_reg_set dst, signed_16 displacement, hw_reg_set src ) /*************************************************************************/ { - GenMEMINS( 0x27, RegTrans( src ), RegTrans( dst ), displacement ); + GenMEMINS( 0x27, RegIndex( src ), RegIndex( dst ), displacement ); } void GenReturn( void ) @@ -556,7 +556,7 @@ static void addressTemp( name *temp, uint_8 *reg, int_16 *offset ) } } -static void getMemEncoding( name *mem, uint_8 *reg_index, int_16 *offset ) +static void getMemEncoding( name *mem, uint_8 *regidx_mem, int_16 *offset ) /****************************************************************************/ { switch( mem->n.class ) { @@ -565,15 +565,15 @@ static void getMemEncoding( name *mem, uint_8 *reg_index, int_16 *offset ) assert( mem->i.scale == 0 ); assert( mem->i.constant == (type_length)((signed_16)mem->i.constant) ); assert( ( mem->i.index_flags & X_LOW_ADDR_BASE ) == 0 ); - *reg_index = _NameReg( mem->i.index ); + *regidx_mem = _NameRegIndex( mem->i.index ); *offset = (int_16)mem->i.constant; break; case N_TEMP: - addressTemp( mem, reg_index, offset ); + addressTemp( mem, regidx_mem, offset ); break; case N_MEMORY: default: - *reg_index = ZERO_REG_IDX; + *regidx_mem = ZERO_REG_IDX; *offset = 0; _Zoiks( ZOIKS_078 ); break; @@ -586,7 +586,7 @@ static void doLoadStore( instruction *ins, bool load ) name *mem; name *reg; uint_8 opcode; - uint_8 index; + uint_8 regidx_mem; int_16 offset; if( load ) { @@ -605,31 +605,31 @@ static void doLoadStore( instruction *ins, bool load ) } } assert( reg->n.class == N_REGISTER ); - getMemEncoding( mem, &index, &offset ); - GenMEMINS( opcode, _NameReg( reg ), index, offset ); + getMemEncoding( mem, ®idx_mem, &offset ); + GenMEMINS( opcode, _NameRegIndex( reg ), regidx_mem, offset ); } static void GenCallIndirect( instruction *call ) /**************************************************/ { - uint_8 reg_index; - uint_8 mem_index; + uint_8 regidx; + uint_8 regidx_mem; int_16 mem_offset; name *addr; - reg_index = AT_REG_IDX; /* use the volatile scratch reg if possible */ + regidx = AT_REG_IDX; /* use the volatile scratch reg if possible */ addr = call->operands[CALL_OP_ADDR]; switch( addr->n.class ) { case N_REGISTER: - reg_index = _NameReg( addr ); + regidx = _NameRegIndex( addr ); break; case N_TEMP: case N_INDEXED: - getMemEncoding( addr, &mem_index, &mem_offset ); - GenMEMINS( 0x28, reg_index, mem_index, mem_offset ); + getMemEncoding( addr, ®idx_mem, &mem_offset ); + GenMEMINS( 0x28, regidx, regidx_mem, mem_offset ); break; } - GenMEMINS( 0x1a, RA_REG_IDX, reg_index, 0x4000 ); + GenMEMINS( 0x1a, RA_REG_IDX, regidx, 0x4000 ); } static void doChop( instruction *ins, type_class_def type_class ) @@ -654,7 +654,7 @@ static void doChop( instruction *ins, type_class_def type_class ) _Zoiks( ZOIKS_078 ); } /* zapnot */ - GenOPIMM( 0x12, 0x31, _NameReg( ins->operands[0] ), zap_mask, _NameReg( ins->result ) ); + GenOPIMM( 0x12, 0x31, _NameRegIndex( ins->operands[0] ), zap_mask, _NameRegIndex( ins->result ) ); } static void doSignExtend( instruction *ins, type_class_def type_class ) @@ -665,8 +665,8 @@ static void doSignExtend( instruction *ins, type_class_def type_class ) int src_index; int shift_amt; - res_index = _NameReg( ins->result ); - src_index = _NameReg( ins->operands[0] ); + res_index = _NameRegIndex( ins->result ); + src_index = _NameRegIndex( ins->operands[0] ); from_size = TypeClassSize[type_class]; if( from_size == 4 ) { /* addl r31, src -> dst */ @@ -718,7 +718,7 @@ static bool encodeThreadDataRef( instruction *ins ) GenMEMINS( loadOpcodes[I4], RT_RET_REG_IDX, RT_RET_REG_IDX, RDTEB_MAGIC_CONST ); GenOPINS( 0x0010, 0x0002, AT_REG_IDX, RT_RET_REG_IDX, RT_RET_REG_IDX ); GenMEMINS( loadOpcodes[I4], RT_RET_REG_IDX, RT_RET_REG_IDX, 0 ); - GenMEMINSRELOC( 0x08, _NameReg( ins->result ), + GenMEMINSRELOC( 0x08, _NameRegIndex( ins->result ), RT_RET_REG_IDX, 0, symLabel( op ), OWL_RELOC_HALF_LO ); return( true ); } @@ -728,8 +728,8 @@ static void Encode( instruction *ins ) { uint_8 *opcodes; uint_16 function; - uint_8 reg_index; - uint_8 mem_index; + uint_8 regidx; + uint_8 regidx_mem; int_16 mem_offset; signed_16 high; signed_16 extra; @@ -752,26 +752,26 @@ static void Encode( instruction *ins ) switch( ins->type_class ) { case FS: GenFPOPINS( 0x16, 0x81, ZERO_REG_IDX, - _NameReg( ins->operands[0] ), - _NameReg( ins->result ) ); + _NameRegIndex( ins->operands[0] ), + _NameRegIndex( ins->result ) ); break; case FD: case FL: GenFPOPINS( 0x16, 0xa1, ZERO_REG_IDX, - _NameReg( ins->operands[0] ), - _NameReg( ins->result ) ); + _NameRegIndex( ins->operands[0] ), + _NameRegIndex( ins->result ) ); break; default: GenOPINS( 0x10, 0x09, ZERO_REG_IDX, - _NameReg( ins->operands[0] ), - _NameReg( ins->result ) ); + _NameRegIndex( ins->operands[0] ), + _NameRegIndex( ins->result ) ); } break; case OP_COMPLEMENT: /* NOT Ra => Rb ...becomes... ORNOT R31,Ra => Rb */ GenOPINS( 0x11, 0x28, ZERO_REG_IDX, - _NameReg( ins->operands[0] ), - _NameReg( ins->result ) ); + _NameRegIndex( ins->operands[0] ), + _NameRegIndex( ins->result ) ); break; default: _Zoiks( ZOIKS_028 ); @@ -780,8 +780,8 @@ static void Encode( instruction *ins ) case G_MOVE_FP: /* CPYS r1,r1,r2 */ GenFPOPINS( 0x17, 0x20, - _NameReg( ins->operands[0] ), _NameReg( ins->operands[0] ), - _NameReg( ins->result ) ); + _NameRegIndex( ins->operands[0] ), _NameRegIndex( ins->operands[0] ), + _NameRegIndex( ins->result ) ); break; case G_ZERO: assert( ins->operands[0]->n.class == N_REGISTER ); @@ -799,24 +799,24 @@ static void Encode( instruction *ins ) assert( ins->operands[0]->n.class == N_REGISTER ); assert( ins->result->n.class == N_REGISTER ); GenFPOPINS( 0x16, 0xac, - 31, _NameReg( ins->operands[0] ), - _NameReg( ins->result ) ); + 31, _NameRegIndex( ins->operands[0] ), + _NameRegIndex( ins->result ) ); break; case G_FREGTOMI8: assert( ins->operands[0]->n.class == N_REGISTER ); assert( ins->result->n.class != N_REGISTER ); - reg_index = _NameReg( ins->operands[0] ); - GenFPOPINS( 0x16, 0x2f, ZERO_REG_IDX, reg_index, FP_AT_REG_IDX ); - getMemEncoding( ins->result, &mem_index, &mem_offset ); - GenMEMINS( 0x27, FP_AT_REG_IDX, mem_index, mem_offset ); + regidx = _NameRegIndex( ins->operands[0] ); + GenFPOPINS( 0x16, 0x2f, ZERO_REG_IDX, regidx, FP_AT_REG_IDX ); + getMemEncoding( ins->result, ®idx_mem, &mem_offset ); + GenMEMINS( 0x27, FP_AT_REG_IDX, regidx_mem, mem_offset ); break; case G_MI8TOFREG: assert( ins->operands[0]->n.class != N_REGISTER ); assert( ins->result->n.class == N_REGISTER ); - reg_index = _NameReg( ins->result ); - getMemEncoding( ins->operands[0], &mem_index, &mem_offset ); - GenMEMINS( 0x23, reg_index, mem_index, mem_offset ); - GenFPOPINS( 0x16, 0xbe, ZERO_REG_IDX, reg_index, reg_index ); + regidx = _NameRegIndex( ins->result ); + getMemEncoding( ins->operands[0], ®idx_mem, &mem_offset ); + GenMEMINS( 0x23, regidx, regidx_mem, mem_offset ); + GenFPOPINS( 0x16, 0xbe, ZERO_REG_IDX, regidx, regidx ); break; case G_BINARY_FP: assert( ins->operands[0]->n.class == N_REGISTER ); @@ -824,8 +824,8 @@ static void Encode( instruction *ins ) assert( ins->result->n.class == N_REGISTER ); function = FindFloatingOpcodes( ins ); GenFPOPINS( 0x16, function, - _NameReg( ins->operands[0] ), _NameReg( ins->operands[1] ), - _NameReg( ins->result ) ); + _NameRegIndex( ins->operands[0] ), _NameRegIndex( ins->operands[1] ), + _NameRegIndex( ins->result ) ); break; case G_BINARY: assert( ins->operands[0]->n.class == N_REGISTER ); @@ -833,8 +833,8 @@ static void Encode( instruction *ins ) assert( ins->result->n.class == N_REGISTER ); opcodes = FindOpcodes( ins ); GenOPINS( opcodes[0], opcodes[1], - _NameReg( ins->operands[0] ), _NameReg( ins->operands[1] ), - _NameReg( ins->result ) ); + _NameRegIndex( ins->operands[0] ), _NameRegIndex( ins->operands[1] ), + _NameRegIndex( ins->result ) ); break; case G_BINARY_IMM: assert( ins->operands[0]->n.class == N_REGISTER ); @@ -842,8 +842,8 @@ static void Encode( instruction *ins ) assert( ins->result->n.class == N_REGISTER ); opcodes = FindOpcodes( ins ); GenOPIMM( opcodes[0], opcodes[1], - _NameReg( ins->operands[0] ), ins->operands[1]->c.lo.int_value, - _NameReg( ins->result ) ); + _NameRegIndex( ins->operands[0] ), ins->operands[1]->c.lo.int_value, + _NameRegIndex( ins->result ) ); break; case G_BYTE_CONST: /* @@ -853,7 +853,7 @@ static void Encode( instruction *ins ) assert( ins->result->n.class == N_REGISTER ); GenOPIMM( 0x10, 0x00, ZERO_REG_IDX, (uint_8)ins->operands[0]->c.lo.int_value, - _NameReg( ins->result ) ); + _NameRegIndex( ins->result ) ); break; case G_MOVE: assert( ins->operands[0]->n.class == N_REGISTER ); @@ -862,8 +862,8 @@ static void Encode( instruction *ins ) * generate a "BIS R31,Rn,Rm" instruction */ GenOPINS( 0x11, 0x20, - ZERO_REG_IDX, _NameReg( ins->operands[0] ), - _NameReg( ins->result ) ); + ZERO_REG_IDX, _NameRegIndex( ins->operands[0] ), + _NameRegIndex( ins->result ) ); break; case G_ZAP: assert( ins->operands[0]->n.class == N_REGISTER ); @@ -873,22 +873,22 @@ static void Encode( instruction *ins ) * generate a "ZAPNOT Ra,#i,Rb" instruction */ GenOPIMM( 0x12, 0x31, - _NameReg( ins->operands[0] ), + _NameRegIndex( ins->operands[0] ), zapMask[ins->flags.zap_value], - _NameReg( ins->result ) ); + _NameRegIndex( ins->result ) ); break; case G_LEA_HIGH: assert( ins->operands[0]->n.class == N_CONSTANT ); assert( ins->operands[0]->c.const_type == CONS_HIGH_ADDR ); assert( ins->result->n.class == N_REGISTER ); - GenMEMINS( 0x09, _NameReg( ins->result ), ZERO_REG_IDX, ins->operands[0]->c.lo.int_value & 0xffff ); + GenMEMINS( 0x09, _NameRegIndex( ins->result ), ZERO_REG_IDX, ins->operands[0]->c.lo.int_value & 0xffff ); break; case G_LEA: assert( ins->operands[0]->n.class == N_CONSTANT ); assert( ins->result->n.class == N_REGISTER ); switch( ins->operands[0]->c.const_type ) { case CONS_ABSOLUTE: - GenMEMINS( 0x08, _NameReg( ins->result ), ZERO_REG_IDX, ins->operands[0]->c.lo.int_value ); + GenMEMINS( 0x08, _NameRegIndex( ins->result ), ZERO_REG_IDX, ins->operands[0]->c.lo.int_value ); break; case CONS_LOW_ADDR: case CONS_HIGH_ADDR: @@ -903,8 +903,8 @@ static void Encode( instruction *ins ) case N_INDEXED: case N_TEMP: assert( ins->result->n.class == N_REGISTER ); - getMemEncoding( ins->operands[0], &mem_index, &mem_offset ); - GenMEMINS( 0x08, _NameReg( ins->result ), mem_index, mem_offset ); + getMemEncoding( ins->operands[0], ®idx_mem, &mem_offset ); + GenMEMINS( 0x08, _NameRegIndex( ins->result ), regidx_mem, mem_offset ); break; case N_MEMORY: assert( ins->result->n.class == N_REGISTER ); @@ -913,9 +913,9 @@ static void Encode( instruction *ins ) _Zoiks( ZOIKS_132 ); } if( !encodeThreadDataRef( ins ) ) { - GenMEMINSRELOC( 0x09, _NameReg( ins->result ), ZERO_REG_IDX, high, + GenMEMINSRELOC( 0x09, _NameRegIndex( ins->result ), ZERO_REG_IDX, high, symLabel( ins->operands[0] ), OWL_RELOC_HALF_HI ); - GenMEMINSRELOC( 0x08, _NameReg( ins->result ), _NameReg( ins->result ), low, + GenMEMINSRELOC( 0x08, _NameRegIndex( ins->result ), _NameRegIndex( ins->result ), low, symLabel( ins->operands[0] ), OWL_RELOC_HALF_LO ); } break; @@ -972,7 +972,7 @@ void GenJumpIf( instruction *ins, pointer label ) /**************************************************/ { GenBRANCH( BranchOpcodes[ins->head.opcode - FIRST_COMPARISON][_IsFloating( ins->type_class )], - _NameReg( ins->operands[0] ), label ); + _NameRegIndex( ins->operands[0] ), label ); #ifdef DEVBUILD if( _IsTargetModel( CGSW_RISC_ASM_OUTPUT ) ) { DumpLiteral( "Jcc L" ); diff --git a/bld/cg/risc/axp/c/axpproc.c b/bld/cg/risc/axp/c/axpproc.c index 27794fb5e4..34b9dd648d 100644 --- a/bld/cg/risc/axp/c/axpproc.c +++ b/bld/cg/risc/axp/c/axpproc.c @@ -152,7 +152,7 @@ static uint_32 registerMask( hw_reg_set rs, hw_reg_set *rl ) result = 0; for( curr = rl; !HW_CEqual( *curr, HW_EMPTY ); curr++ ) { if( HW_Ovlap( rs, *curr ) ) { - result |= 1 << RegTrans( *curr ); + result |= 1 << RegIndex( *curr ); } } return( result ); diff --git a/bld/cg/risc/axp/c/axprgtbl.c b/bld/cg/risc/axp/c/axprgtbl.c index aad990b679..69c19230d5 100644 --- a/bld/cg/risc/axp/c/axprgtbl.c +++ b/bld/cg/risc/axp/c/axprgtbl.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2016 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -824,7 +824,7 @@ reg_idx RegIndex( hw_reg_set reg ) * Translate reg to register index */ { - return( regTranslate( reg, true ) ); + return( (reg_idx)regTranslate( reg, true ) ); } void SetArchIndex( name *new_r, hw_reg_set regs ) @@ -833,12 +833,12 @@ void SetArchIndex( name *new_r, hw_reg_set regs ) new_r->r.arch_index = RegIndex( regs ); } -byte RegTrans( hw_reg_set reg ) -/********************************* +axp_regn RegTrans( hw_reg_set reg ) +/************************************* * Translate reg to register index */ { - return( regTranslate( reg, true ) ); + return( (axp_regn)regTranslate( reg, false ) ); } axp_regn RegTransN( name *reg_name ) @@ -846,7 +846,7 @@ axp_regn RegTransN( name *reg_name ) * Translate reg name to enum name */ { - return( regTranslate( reg_name->r.reg, false ) ); + return( (axp_regn)regTranslate( reg_name->r.reg, false ) ); } diff --git a/bld/cg/risc/axp/h/axpenc.h b/bld/cg/risc/axp/h/axpenc.h index 8b3c37ed8d..c7be3bce67 100644 --- a/bld/cg/risc/axp/h/axpenc.h +++ b/bld/cg/risc/axp/h/axpenc.h @@ -34,6 +34,8 @@ typedef uint_8 reg_idx; +extern reg_idx RegIndex( hw_reg_set reg ); + extern void GenCallLabelReg( pointer label, uint reg ); extern void GenOPINS( uint_8 opcode, uint_8 function, uint_8 reg_a, uint_8 reg_b, uint_8 reg_c ); extern void GenLOADS32( signed_32 value, uint_8 reg ); diff --git a/bld/cg/risc/axp/h/axpregn.h b/bld/cg/risc/axp/h/axpregn.h index 52f47ba8ca..d68be5b7fa 100644 --- a/bld/cg/risc/axp/h/axpregn.h +++ b/bld/cg/risc/axp/h/axpregn.h @@ -30,71 +30,73 @@ ****************************************************************************/ -typedef enum axp_regn{ - AXP_REGN_r0, - AXP_REGN_r1, - AXP_REGN_r2, - AXP_REGN_r3, - AXP_REGN_r4, - AXP_REGN_r5, - AXP_REGN_r6, - AXP_REGN_r7, - AXP_REGN_r8, - AXP_REGN_r9, - AXP_REGN_r10, - AXP_REGN_r11, - AXP_REGN_r12, - AXP_REGN_r13, - AXP_REGN_r14, - AXP_REGN_r15, - AXP_REGN_r16, - AXP_REGN_r17, - AXP_REGN_r18, - AXP_REGN_r19, - AXP_REGN_r20, - AXP_REGN_r21, - AXP_REGN_r22, - AXP_REGN_r23, - AXP_REGN_r24, - AXP_REGN_r25, - AXP_REGN_r26, - AXP_REGN_r27, - AXP_REGN_r28, - AXP_REGN_r29, - AXP_REGN_r30, - AXP_REGN_r31, - AXP_REGN_f0, - AXP_REGN_f1, - AXP_REGN_f2, - AXP_REGN_f3, - AXP_REGN_f4, - AXP_REGN_f5, - AXP_REGN_f6, - AXP_REGN_f7, - AXP_REGN_f8, - AXP_REGN_f9, - AXP_REGN_f10, - AXP_REGN_f11, - AXP_REGN_f12, - AXP_REGN_f13, - AXP_REGN_f14, - AXP_REGN_f15, - AXP_REGN_f16, - AXP_REGN_f17, - AXP_REGN_f18, - AXP_REGN_f19, - AXP_REGN_f20, - AXP_REGN_f21, - AXP_REGN_f22, - AXP_REGN_f23, - AXP_REGN_f24, - AXP_REGN_f25, - AXP_REGN_f26, - AXP_REGN_f27, - AXP_REGN_f28, - AXP_REGN_f29, - AXP_REGN_f30, - AXP_REGN_f31, - AXP_REGN_END, -}axp_regn; -extern axp_regn RegTransN( name *reg_name ); +typedef enum axp_regn { + AXP_REGN_r0, + AXP_REGN_r1, + AXP_REGN_r2, + AXP_REGN_r3, + AXP_REGN_r4, + AXP_REGN_r5, + AXP_REGN_r6, + AXP_REGN_r7, + AXP_REGN_r8, + AXP_REGN_r9, + AXP_REGN_r10, + AXP_REGN_r11, + AXP_REGN_r12, + AXP_REGN_r13, + AXP_REGN_r14, + AXP_REGN_r15, + AXP_REGN_r16, + AXP_REGN_r17, + AXP_REGN_r18, + AXP_REGN_r19, + AXP_REGN_r20, + AXP_REGN_r21, + AXP_REGN_r22, + AXP_REGN_r23, + AXP_REGN_r24, + AXP_REGN_r25, + AXP_REGN_r26, + AXP_REGN_r27, + AXP_REGN_r28, + AXP_REGN_r29, + AXP_REGN_r30, + AXP_REGN_r31, + AXP_REGN_f0, + AXP_REGN_f1, + AXP_REGN_f2, + AXP_REGN_f3, + AXP_REGN_f4, + AXP_REGN_f5, + AXP_REGN_f6, + AXP_REGN_f7, + AXP_REGN_f8, + AXP_REGN_f9, + AXP_REGN_f10, + AXP_REGN_f11, + AXP_REGN_f12, + AXP_REGN_f13, + AXP_REGN_f14, + AXP_REGN_f15, + AXP_REGN_f16, + AXP_REGN_f17, + AXP_REGN_f18, + AXP_REGN_f19, + AXP_REGN_f20, + AXP_REGN_f21, + AXP_REGN_f22, + AXP_REGN_f23, + AXP_REGN_f24, + AXP_REGN_f25, + AXP_REGN_f26, + AXP_REGN_f27, + AXP_REGN_f28, + AXP_REGN_f29, + AXP_REGN_f30, + AXP_REGN_f31, + AXP_REGN_END, +} axp_regn; + +extern axp_regn RegTrans( hw_reg_set reg ); +extern axp_regn RegTransN( name *reg_name ); diff --git a/bld/cg/risc/mps/c/mpsenc.c b/bld/cg/risc/mps/c/mpsenc.c index 85f0581524..d01bdf1a84 100644 --- a/bld/cg/risc/mps/c/mpsenc.c +++ b/bld/cg/risc/mps/c/mpsenc.c @@ -58,7 +58,7 @@ #include "feprotos.h" -#define _NameReg( op ) ( (op)->r.arch_index ) +#define _NameRegIndex( op ) ( (op)->r.arch_index ) #define _BinaryOpcode( a, b ) { { a, b }, { a, b } } #define _SignedOpcode( a, b, c, d ) { { a, b }, { c, d } } @@ -606,7 +606,7 @@ static void addressTemp( name *temp, uint_8 *reg, int_16 *offset ) } -static void getMemEncoding( name *mem, uint_8 *reg_index, int_16 *offset ) +static void getMemEncoding( name *mem, uint_8 *regidx_mem, int_16 *offset ) /*************************************************************************/ { switch( mem->n.class ) { @@ -615,15 +615,15 @@ static void getMemEncoding( name *mem, uint_8 *reg_index, int_16 *offset ) assert( mem->i.scale == 0 ); assert( mem->i.constant == (type_length)((int_16)mem->i.constant) ); assert( ( mem->i.index_flags & X_LOW_ADDR_BASE ) == 0 ); - *reg_index = _NameReg( mem->i.index ); + *regidx_mem = _NameRegIndex( mem->i.index ); *offset = (int_16)mem->i.constant; break; case N_TEMP: - addressTemp( mem, reg_index, offset ); + addressTemp( mem, regidx_mem, offset ); break; case N_MEMORY: default: - *reg_index = ZERO_REG_IDX; + *regidx_mem = ZERO_REG_IDX; *offset = 0; _Zoiks( ZOIKS_078 ); break; @@ -637,7 +637,7 @@ static void doLoadStore( instruction *ins, bool load ) name *mem; name *reg; uint_8 opcode; - uint_8 index; + uint_8 regidx_mem; int_16 offset; if( load ) { @@ -650,8 +650,8 @@ static void doLoadStore( instruction *ins, bool load ) opcode = storeOpcodes[ins->type_class]; } assert( reg->n.class == N_REGISTER ); - getMemEncoding( mem, &index, &offset ); - GenMEMINS( opcode, _NameReg( reg ), index, offset ); + getMemEncoding( mem, ®idx_mem, &offset ); + GenMEMINS( opcode, _NameRegIndex( reg ), regidx_mem, offset ); } @@ -663,7 +663,7 @@ static void doLoadStoreUnaligned( instruction *ins, bool load ) name *reg; uint_8 opcode1; uint_8 opcode2; - uint_8 index; + uint_8 regidx_mem; int_16 offset; if( load ) { @@ -682,12 +682,12 @@ static void doLoadStoreUnaligned( instruction *ins, bool load ) opcode1 = 0x2a; opcode2 = 0x2e; } assert( reg->n.class == N_REGISTER ); - getMemEncoding( mem, &index, &offset ); + getMemEncoding( mem, ®idx_mem, &offset ); /* * TODO: make sure offset can't overflow */ - GenMEMINS( opcode1, _NameReg( reg ), index, offset + 3 ); - GenMEMINS( opcode2, _NameReg( reg ), index, offset ); + GenMEMINS( opcode1, _NameRegIndex( reg ), regidx_mem, offset + 3 ); + GenMEMINS( opcode2, _NameRegIndex( reg ), regidx_mem, offset ); #else doLoadStore( ins, load ); #endif @@ -697,30 +697,30 @@ static void doLoadStoreUnaligned( instruction *ins, bool load ) static void GenCallIndirect( instruction *call ) /***********************************************/ { - uint_8 reg_index; - uint_8 mem_index; + uint_8 regidx; + uint_8 regidx_mem; int_16 mem_offset; name *addr; /* * use the scratch register if possible */ - reg_index = AT_REG_IDX; + regidx = AT_REG_IDX; addr = call->operands[CALL_OP_ADDR]; switch( addr->n.class ) { case N_REGISTER: - reg_index = _NameReg( addr ); + regidx = _NameRegIndex( addr ); break; case N_TEMP: case N_INDEXED: - getMemEncoding( addr, &mem_index, &mem_offset ); - GenMEMINS( 0x23, reg_index, mem_index, mem_offset ); + getMemEncoding( addr, ®idx_mem, &mem_offset ); + GenMEMINS( 0x23, regidx, regidx_mem, mem_offset ); break; } /* - * 'jalr ra,reg_index' + * 'jalr ra,regidx' */ - GenRType( 0x00, 0x09, RA_REG_IDX, reg_index, 0 ); + GenRType( 0x00, 0x09, RA_REG_IDX, regidx, 0 ); /* * TODO: Handle delay slot better */ @@ -739,13 +739,13 @@ static void doZero( instruction *ins, type_class_def type_class ) /* * 'andi res,op1,0x00ff' */ - GenIType( 0x0c, _NameReg( ins->result ), _NameReg( ins->operands[0] ), 0x00ff ); + GenIType( 0x0c, _NameRegIndex( ins->result ), _NameRegIndex( ins->operands[0] ), 0x00ff ); break; case 2: /* * 'andi res,op1,0xffff' */ - GenIType( 0x0c, _NameReg( ins->result ), _NameReg( ins->operands[0] ), (int_16)0x0ffff ); + GenIType( 0x0c, _NameRegIndex( ins->result ), _NameRegIndex( ins->operands[0] ), (int_16)0x0ffff ); break; default: _Zoiks( ZOIKS_091 ); @@ -761,8 +761,8 @@ static void doSignExtend( instruction *ins, type_class_def type_class ) int src_index; int shift_amt; - res_index = _NameReg( ins->result ); - src_index = _NameReg( ins->operands[0] ); + res_index = _NameRegIndex( ins->result ); + src_index = _NameRegIndex( ins->operands[0] ); from_size = TypeClassSize[type_class]; if( from_size == 4 ) { /* @@ -829,7 +829,7 @@ static bool encodeThreadDataRef( instruction *ins ) GenMEMINS( loadOpcodes[I4], RT_RET_REG_IDX, RT_RET_REG_IDX, RDTEB_MAGIC_CONST ); GenOPINS( 0x0010, 0x0002, AT_REG_IDX, RT_RET_REG_IDX, RT_RET_REG_IDX ); GenMEMINS( loadOpcodes[I4], RT_RET_REG_IDX, RT_RET_REG_IDX, 0 ); - GenMEMINSRELOC( 0x08, _NameReg( ins->result ), + GenMEMINSRELOC( 0x08, _NameRegIndex( ins->result ), RT_RET_REG_IDX, 0, symLabel( op ), OWL_RELOC_HALF_LO ); #else assert( 0 ); @@ -844,8 +844,8 @@ static void Encode( instruction *ins ) uint_8 *opcodes; uint_8 opcode; uint_16 function; - uint_8 reg_index; - uint_8 mem_index; + uint_8 regidx; + uint_8 regidx_mem; int_16 mem_offset; int_16 high; int_16 extra; @@ -872,20 +872,20 @@ static void Encode( instruction *ins ) case FS: case FD: case FL: - GenFloatRType( ins->type_class, 0x07, _NameReg( ins->result ), _NameReg( ins->operands[0] ), 0 ); + GenFloatRType( ins->type_class, 0x07, _NameRegIndex( ins->result ), _NameRegIndex( ins->operands[0] ), 0 ); break; default: /* * 'subu rd,$zero,rs' */ - GenRType( 0x00, 0x23, _NameReg( ins->result ), ZERO_REG_IDX, _NameReg( ins->operands[0] ) ); + GenRType( 0x00, 0x23, _NameRegIndex( ins->result ), ZERO_REG_IDX, _NameRegIndex( ins->operands[0] ) ); } break; case OP_COMPLEMENT: /* * 'nor rd,$zero,rs' */ - GenRType( 0x00, 0x27, _NameReg( ins->result ), ZERO_REG_IDX, _NameReg( ins->operands[0] ) ); + GenRType( 0x00, 0x27, _NameRegIndex( ins->result ), ZERO_REG_IDX, _NameRegIndex( ins->operands[0] ) ); break; default: _Zoiks( ZOIKS_028 ); @@ -897,7 +897,7 @@ static void Encode( instruction *ins ) /* * 'mov.s fd,fs' */ - GenFloatRType( FS, 0x06, _NameReg( ins->result ), _NameReg( ins->operands[0] ), 0 ); + GenFloatRType( FS, 0x06, _NameRegIndex( ins->result ), _NameRegIndex( ins->operands[0] ), 0 ); break; case G_ZERO: assert( ins->operands[0]->n.class == N_REGISTER ); @@ -917,35 +917,35 @@ static void Encode( instruction *ins ) /* * 'cvt.s.d fd,fs' */ - GenFloatRType( FD, 0x20, _NameReg( ins->result ), _NameReg( ins->operands[0] ), 0 ); + GenFloatRType( FD, 0x20, _NameRegIndex( ins->result ), _NameRegIndex( ins->operands[0] ), 0 ); break; case G_FREGTOMI8: assert( ins->operands[0]->n.class == N_REGISTER ); assert( ins->result->n.class != N_REGISTER ); - reg_index = _NameReg( ins->operands[0] ); - getMemEncoding( ins->result, &mem_index, &mem_offset ); + regidx = _NameRegIndex( ins->operands[0] ); + getMemEncoding( ins->result, ®idx_mem, &mem_offset ); /* * 'sdc1 rt,offset(base)' - MIPS32-R2/MIPS64 only? */ - GenIType( 0x3d, reg_index, mem_index, mem_offset ); + GenIType( 0x3d, regidx, regidx_mem, mem_offset ); break; case G_MI8TOFREG: assert( ins->operands[0]->n.class != N_REGISTER ); assert( ins->result->n.class == N_REGISTER ); - reg_index = _NameReg( ins->result ); - getMemEncoding( ins->operands[0], &mem_index, &mem_offset ); + regidx = _NameRegIndex( ins->result ); + getMemEncoding( ins->operands[0], ®idx_mem, &mem_offset ); /* * 'ldc1 rt,offset(base)' - MIPS32-R2/MIPS64 only? */ - GenIType( 0x35, reg_index, mem_index, mem_offset ); + GenIType( 0x35, regidx, regidx_mem, mem_offset ); break; case G_BINARY_FP: assert( ins->operands[0]->n.class == N_REGISTER ); assert( ins->operands[1]->n.class == N_REGISTER ); assert( ins->result->n.class == N_REGISTER ); function = FindFloatingOpcodes( ins ); - reg_index = _OpIsSet( ins->head.opcode ) ? 0 : _NameReg( ins->result ); - GenFloatRType( ins->type_class, function, reg_index, _NameReg( ins->operands[0] ), _NameReg( ins->operands[1] ) ); + regidx = _OpIsSet( ins->head.opcode ) ? 0 : _NameRegIndex( ins->result ); + GenFloatRType( ins->type_class, function, regidx, _NameRegIndex( ins->operands[0] ), _NameRegIndex( ins->operands[1] ) ); break; case G_BINARY: assert( ins->operands[0]->n.class == N_REGISTER ); @@ -958,37 +958,37 @@ static void Encode( instruction *ins ) /* * 'sllv', 'srlv' and 'srav' have the operands backwards */ - GenRType( opcodes[0], opcodes[1], _NameReg( ins->result ), _NameReg( ins->operands[1] ), _NameReg( ins->operands[0] ) ); + GenRType( opcodes[0], opcodes[1], _NameRegIndex( ins->result ), _NameRegIndex( ins->operands[1] ), _NameRegIndex( ins->operands[0] ) ); break; case OP_MUL: - GenRType( opcodes[0], opcodes[1], 0, _NameReg( ins->operands[0] ), _NameReg( ins->operands[1] ) ); + GenRType( opcodes[0], opcodes[1], 0, _NameRegIndex( ins->operands[0] ), _NameRegIndex( ins->operands[1] ) ); /* * 'mflo rd' */ - GenRType( 0, 0x12, _NameReg( ins->result ), 0, 0 ); + GenRType( 0, 0x12, _NameRegIndex( ins->result ), 0, 0 ); break; case OP_DIV: /* * TODO: do something if divisor is zero */ - GenRType( opcodes[0], opcodes[1], 0, _NameReg( ins->operands[0] ), _NameReg( ins->operands[1] ) ); + GenRType( opcodes[0], opcodes[1], 0, _NameRegIndex( ins->operands[0] ), _NameRegIndex( ins->operands[1] ) ); /* * 'mflo rd' */ - GenRType( 0, 0x12, _NameReg( ins->result ), 0, 0 ); + GenRType( 0, 0x12, _NameRegIndex( ins->result ), 0, 0 ); break; case OP_MOD: /* * TODO: do something if divisor is zero */ - GenRType( opcodes[0], opcodes[1], 0, _NameReg( ins->operands[0] ), _NameReg( ins->operands[1] ) ); + GenRType( opcodes[0], opcodes[1], 0, _NameRegIndex( ins->operands[0] ), _NameRegIndex( ins->operands[1] ) ); /* * 'mfhi rd' */ - GenRType( 0, 0x10, _NameReg( ins->result ), 0, 0 ); + GenRType( 0, 0x10, _NameRegIndex( ins->result ), 0, 0 ); break; default: - GenRType( opcodes[0], opcodes[1], _NameReg( ins->result ), _NameReg( ins->operands[0] ), _NameReg( ins->operands[1] ) ); + GenRType( opcodes[0], opcodes[1], _NameRegIndex( ins->result ), _NameRegIndex( ins->operands[0] ), _NameRegIndex( ins->operands[1] ) ); break; } break; @@ -1002,19 +1002,19 @@ static void Encode( instruction *ins ) /* * 'sll rd,rs,n' */ - GenIShift( 0x00, _NameReg( ins->result ), _NameReg( ins->operands[0] ), imm_value ); + GenIShift( 0x00, _NameRegIndex( ins->result ), _NameRegIndex( ins->operands[0] ), imm_value ); break; case OP_RSHIFT: if( _IsSigned( ins->type_class ) ) { /* * 'sra rd,rs,n' */ - GenIShift( 0x03, _NameReg( ins->result ), _NameReg( ins->operands[0] ), imm_value ); + GenIShift( 0x03, _NameRegIndex( ins->result ), _NameRegIndex( ins->operands[0] ), imm_value ); } else { /* * 'srl rd,rs,n' */ - GenIShift( 0x02, _NameReg( ins->result ), _NameReg( ins->operands[0] ), imm_value ); + GenIShift( 0x02, _NameRegIndex( ins->result ), _NameRegIndex( ins->operands[0] ), imm_value ); } break; case OP_SUB: @@ -1028,7 +1028,7 @@ static void Encode( instruction *ins ) */ default: opcode = FindImmedOpcode( ins ); - GenIType( opcode, _NameReg( ins->result ), _NameReg( ins->operands[0] ), imm_value ); + GenIType( opcode, _NameRegIndex( ins->result ), _NameRegIndex( ins->operands[0] ), imm_value ); break; } break; @@ -1041,7 +1041,7 @@ static void Encode( instruction *ins ) /* * 'addiu rt,$zero,immed' */ - GenIType( 0x09, _NameReg( ins->result ), ZERO_REG_IDX, (uint_8)ins->operands[0]->c.lo.int_value ); + GenIType( 0x09, _NameRegIndex( ins->result ), ZERO_REG_IDX, (uint_8)ins->operands[0]->c.lo.int_value ); break; case G_MOVE: assert( ins->operands[0]->n.class == N_REGISTER ); @@ -1049,13 +1049,13 @@ static void Encode( instruction *ins ) /* * 'or rd,rs,$zero' */ - GenRType( 0x00, 0x25, _NameReg( ins->result ), _NameReg( ins->operands[0] ), ZERO_REG_IDX ); + GenRType( 0x00, 0x25, _NameRegIndex( ins->result ), _NameRegIndex( ins->operands[0] ), ZERO_REG_IDX ); if( TypeClassSize[ins->type_class] == 8 ) { /* * Move the odd register, too * TODO: there should probably be a separate G_MOVE8? */ - GenRType( 0x00, 0x25, _NameReg( ins->result ) + 1, _NameReg( ins->operands[0] ) + 1, ZERO_REG_IDX ); + GenRType( 0x00, 0x25, _NameRegIndex( ins->result ) + 1, _NameRegIndex( ins->operands[0] ) + 1, ZERO_REG_IDX ); } break; case G_LEA_HIGH: @@ -1065,7 +1065,7 @@ static void Encode( instruction *ins ) /* * 'lui rt,immed' */ - GenIType( 0x0f, _NameReg( ins->result ), ZERO_REG_IDX, ins->operands[0]->c.lo.int_value & 0xffff ); + GenIType( 0x0f, _NameRegIndex( ins->result ), ZERO_REG_IDX, ins->operands[0]->c.lo.int_value & 0xffff ); break; case G_LEA: assert( ins->operands[0]->n.class == N_CONSTANT ); @@ -1075,7 +1075,7 @@ static void Encode( instruction *ins ) /* * 'addiu rt,$zero,immed' */ - GenIType( 0x09, _NameReg( ins->result ), ZERO_REG_IDX, ins->operands[0]->c.lo.int_value ); + GenIType( 0x09, _NameRegIndex( ins->result ), ZERO_REG_IDX, ins->operands[0]->c.lo.int_value ); break; case CONS_LOW_ADDR: case CONS_HIGH_ADDR: @@ -1090,11 +1090,11 @@ static void Encode( instruction *ins ) case N_INDEXED: case N_TEMP: assert( ins->result->n.class == N_REGISTER ); - getMemEncoding( ins->operands[0], &mem_index, &mem_offset ); + getMemEncoding( ins->operands[0], ®idx_mem, &mem_offset ); /* * 'addiu rt,rs,immed' */ - GenIType( 0x09, _NameReg( ins->result ), mem_index, mem_offset ); + GenIType( 0x09, _NameRegIndex( ins->result ), regidx_mem, mem_offset ); break; case N_MEMORY: assert( ins->result->n.class == N_REGISTER ); @@ -1106,11 +1106,11 @@ static void Encode( instruction *ins ) /* * 'lui rt,immed' */ - GenMEMINSRELOC( 0x0f, _NameReg( ins->result ), ZERO_REG_IDX, high, symLabel( ins->operands[0] ), OWL_RELOC_HALF_HI ); + GenMEMINSRELOC( 0x0f, _NameRegIndex( ins->result ), ZERO_REG_IDX, high, symLabel( ins->operands[0] ), OWL_RELOC_HALF_HI ); /* * 'addiu rt,rs,immed' */ - GenMEMINSRELOC( 0x09, _NameReg( ins->result ), _NameReg( ins->result ), low, symLabel( ins->operands[0] ), OWL_RELOC_HALF_LO ); + GenMEMINSRELOC( 0x09, _NameRegIndex( ins->result ), _NameRegIndex( ins->result ), low, symLabel( ins->operands[0] ), OWL_RELOC_HALF_LO ); } break; default: @@ -1122,7 +1122,7 @@ static void Encode( instruction *ins ) * a load of an unsigned 16-bit immediate * 'ori rt,rs,immed' */ - GenIType( 0x0d, _NameReg( ins->result ), ZERO_REG_IDX, ins->operands[0]->c.lo.int_value ); + GenIType( 0x0d, _NameRegIndex( ins->result ), ZERO_REG_IDX, ins->operands[0]->c.lo.int_value ); break; case G_LOAD_UA: doLoadStoreUnaligned( ins, true ); diff --git a/bld/cg/risc/mps/c/mpsproc.c b/bld/cg/risc/mps/c/mpsproc.c index d377e0c325..6e3f9d37f3 100644 --- a/bld/cg/risc/mps/c/mpsproc.c +++ b/bld/cg/risc/mps/c/mpsproc.c @@ -163,7 +163,7 @@ static uint_32 registerMask( hw_reg_set rs, hw_reg_set *rl ) result = 0; for( curr = rl; !HW_CEqual( *curr, HW_EMPTY ); curr++ ) { if( HW_Ovlap( rs, *curr ) ) { - result |= 1 << RegTrans( *curr ); + result |= 1 << RegIndex( *curr ); } } return( result ); diff --git a/bld/cg/risc/mps/c/mpsrgtbl.c b/bld/cg/risc/mps/c/mpsrgtbl.c index d5bbb5578c..1097154284 100644 --- a/bld/cg/risc/mps/c/mpsrgtbl.c +++ b/bld/cg/risc/mps/c/mpsrgtbl.c @@ -893,7 +893,7 @@ reg_idx RegIndex( hw_reg_set reg ) * Translate reg to register index */ { - return( regTranslate( reg, true ) ); + return( (reg_idx)regTranslate( reg, true ) ); } void SetArchIndex( name *new_r, hw_reg_set regs ) @@ -903,12 +903,12 @@ void SetArchIndex( name *new_r, hw_reg_set regs ) } -byte RegTrans( hw_reg_set reg ) -/********************************* +mips_regn RegTrans( hw_reg_set reg ) +/************************************* * Translate reg to register index */ { - return( regTranslate( reg, true ) ); + return( (mips_regn)regTranslate( reg, false ) ); } mips_regn RegTransN( name *reg_name ) @@ -916,7 +916,7 @@ mips_regn RegTransN( name *reg_name ) * Translate reg name to enum name */ { - return( regTranslate( reg_name->r.reg, false ) ); + return( (mips_regn)regTranslate( reg_name->r.reg, false ) ); } diff --git a/bld/cg/risc/mps/h/mpsenc.h b/bld/cg/risc/mps/h/mpsenc.h index 375b3e4a7a..08afe92fdc 100644 --- a/bld/cg/risc/mps/h/mpsenc.h +++ b/bld/cg/risc/mps/h/mpsenc.h @@ -35,6 +35,8 @@ typedef uint_8 reg_idx; +extern reg_idx RegIndex( hw_reg_set reg ); + extern void GenCallLabelReg( pointer label, uint reg ); extern void GenLOADS32( signed_32 value, uint_8 reg ); extern void GenMEMINS( uint_8 opcode, uint_8 a, uint_8 b, signed_16 displacement ); diff --git a/bld/cg/risc/mps/h/mpsregn.h b/bld/cg/risc/mps/h/mpsregn.h index a0c7b0d7e6..4f6af0f0ee 100644 --- a/bld/cg/risc/mps/h/mpsregn.h +++ b/bld/cg/risc/mps/h/mpsregn.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -97,4 +98,5 @@ typedef enum mips_regn { MIPS_REGN_END, } mips_regn; -extern mips_regn RegTransN( name *reg_name ); +extern mips_regn RegTrans( hw_reg_set reg ); +extern mips_regn RegTransN( name *reg_name ); diff --git a/bld/cg/risc/ppc/c/ppcenc.c b/bld/cg/risc/ppc/c/ppcenc.c index 4b01195911..43be1aa509 100644 --- a/bld/cg/risc/ppc/c/ppcenc.c +++ b/bld/cg/risc/ppc/c/ppcenc.c @@ -59,7 +59,7 @@ #include "feprotos.h" -#define _NameReg( op ) ( (op)->r.arch_index ) +#define _NameRegIndex( op ) ( (op)->r.arch_index ) #define _EmitIns( ins ) ObjBytes( &(ins), sizeof( ppc_ins ) ) #define _ObjEmitSeq( code ) ObjBytes( code->data, code->length ) @@ -417,7 +417,7 @@ static void doCall( instruction *ins ) } -static void getMemEncoding( name *mem, reg_idx *index, int_16 *offset ) +static void getMemEncoding( name *mem, reg_idx *regidx_mem, int_16 *offset ) /*************************************************************************/ { switch( mem->n.class ) { @@ -426,16 +426,16 @@ static void getMemEncoding( name *mem, reg_idx *index, int_16 *offset ) assert( mem->i.scale == 0 ); assert( mem->i.constant == (type_length)((signed_16)mem->i.constant) ); assert( ( mem->i.index_flags & X_LOW_ADDR_BASE ) == 0 ); - *index = RegTrans( mem->i.index->r.reg ); + *regidx_mem = RegIndex( mem->i.index->r.reg ); *offset = (int_16)mem->i.constant; break; case N_TEMP: - *index = RegTrans( FrameReg() ); + *regidx_mem = RegIndex( FrameReg() ); *offset = TempLocation( mem ); break; case N_MEMORY: default: - *index = ZERO_REG_IDX; + *regidx_mem = ZERO_REG_IDX; *offset = 0; _Zoiks( ZOIKS_119 ); break; @@ -449,7 +449,7 @@ static void doLoadStore( instruction *ins, bool load ) name *mem; name *reg; gen_opcode op; - reg_idx index; + reg_idx regidx_mem; int_16 offset; if( load ) { @@ -463,8 +463,8 @@ static void doLoadStore( instruction *ins, bool load ) } assert( op != 0 ); assert( reg->n.class == N_REGISTER ); - getMemEncoding( mem, &index, &offset ); - GenMEMINS( op, RegTrans( reg->r.reg ), index, offset ); + getMemEncoding( mem, ®idx_mem, &offset ); + GenMEMINS( op, RegIndex( reg->r.reg ), regidx_mem, offset ); } @@ -477,14 +477,14 @@ static void doSign( instruction *ins ) /* * extsb */ - GenOPINS( 31, 954, _NameReg( ins->result ), 0, _NameReg( ins->operands[0] ) ); + GenOPINS( 31, 954, _NameRegIndex( ins->result ), 0, _NameRegIndex( ins->operands[0] ) ); break; case U2: case I2: /* * extsh */ - GenOPINS( 31, 922, _NameReg( ins->result ), 0, _NameReg( ins->operands[0] ) ); + GenOPINS( 31, 922, _NameRegIndex( ins->result ), 0, _NameRegIndex( ins->operands[0] ) ); break; default: _Zoiks( ZOIKS_091 ); @@ -501,14 +501,14 @@ static void doZero( instruction *ins ) /* * andi op1,0x00ff -> res */ - GenOPIMM( 28, _NameReg( ins->operands[0] ), _NameReg( ins->result ), 0x00ff ); + GenOPIMM( 28, _NameRegIndex( ins->operands[0] ), _NameRegIndex( ins->result ), 0x00ff ); break; case U2: case I2: /* * andi op1,0xffff -> res */ - GenOPIMM( 28, _NameReg( ins->operands[0] ), _NameReg( ins->result ), (signed_16)0xffff ); + GenOPIMM( 28, _NameRegIndex( ins->operands[0] ), _NameRegIndex( ins->result ), (signed_16)0xffff ); break; default: _Zoiks( ZOIKS_091 ); @@ -521,7 +521,7 @@ static void GenCallIndirect( instruction *call ) { reg_idx src; reg_idx reg; - reg_idx mem_index; + reg_idx regidx_mem; int_16 mem_offset; name *addr; gen_opcode ldw; @@ -535,12 +535,12 @@ static void GenCallIndirect( instruction *call ) GenMEMINS( stw, RTOC_REG_IDX, SP_REG_IDX, 4 ); switch( addr->n.class ) { case N_REGISTER: - src = _NameReg( addr ); + src = _NameRegIndex( addr ); break; case N_TEMP: case N_INDEXED: - getMemEncoding( addr, &mem_index, &mem_offset ); - GenMEMINS( ldw, src, mem_index, mem_offset ); + getMemEncoding( addr, ®idx_mem, &mem_offset ); + GenMEMINS( ldw, src, regidx_mem, mem_offset ); break; } GenMEMINS( ldw, RTOC_REG_IDX, src, 4 ); // careful - src, reg could be same reg @@ -562,9 +562,9 @@ static void GenVaStart( instruction *ins ) reg_idx stack; assert( ins->operands[0]->n.class == N_REGISTER ); - reg = _NameReg( ins->operands[0] ); + reg = _NameRegIndex( ins->operands[0] ); tmp = AT_REG_IDX; - stack = RegTrans( FrameReg() ); + stack = RegIndex( FrameReg() ); stb = storeOpcodes[U1]; stw = storeOpcodes[U4]; li = 14; // addi @@ -612,21 +612,21 @@ static void Encode( instruction *ins ) gen_opcode op2; gen_opcode *ops; signed_16 mem_offset; - reg_idx mem_index; + reg_idx regidx_mem; switch( G( ins ) ) { case G_MOVE_FP: assert( ins->result->n.class == N_REGISTER ); assert( ins->operands[0]->n.class == N_REGISTER ); - GenOPINS( 63, 72, 0, _NameReg( ins->operands[0] ), _NameReg( ins->result ) ); + GenOPINS( 63, 72, 0, _NameRegIndex( ins->operands[0] ), _NameRegIndex( ins->result ) ); break; case G_MOVE: // or op, op -> dst assert( ins->result->n.class == N_REGISTER ); assert( ins->operands[0]->n.class == N_REGISTER ); - b = _NameReg( ins->operands[0] ); - GenOPINS( 31, 444, _NameReg( ins->result ), b, b ); + b = _NameRegIndex( ins->operands[0] ); + GenOPINS( 31, 444, _NameRegIndex( ins->result ), b, b ); break; case G_LOAD: case G_STORE: @@ -640,12 +640,12 @@ static void Encode( instruction *ins ) assert( ins->operands[0]->c.const_type == CONS_HIGH_ADDR ); assert( ins->result->n.class == N_REGISTER ); /* addis k(r0) -> rn */ - GenOPIMM( 15, _NameReg( ins->result ), ZERO_REG_IDX, ins->operands[0]->c.lo.int_value & 0xffff ); + GenOPIMM( 15, _NameRegIndex( ins->result ), ZERO_REG_IDX, ins->operands[0]->c.lo.int_value & 0xffff ); break; case G_MOVE_UI: /* a load of an unsigned 16-bit immediate */ /* use or rd, imm(r0) */ - GenOPIMM( 24, _NameReg( ins->result ), ZERO_REG_IDX, ins->operands[0]->c.lo.int_value ); + GenOPIMM( 24, _NameRegIndex( ins->result ), ZERO_REG_IDX, ins->operands[0]->c.lo.int_value ); break; case G_LEA: assert( ins->operands[0]->n.class == N_CONSTANT ); @@ -653,7 +653,7 @@ static void Encode( instruction *ins ) switch( ins->operands[0]->c.const_type ) { case CONS_ABSOLUTE: // addi rd, imm(r0) - GenOPIMM( 14, _NameReg( ins->result ), ZERO_REG_IDX, ins->operands[0]->c.lo.int_value ); + GenOPIMM( 14, _NameRegIndex( ins->result ), ZERO_REG_IDX, ins->operands[0]->c.lo.int_value ); break; case CONS_LOW_ADDR: case CONS_HIGH_ADDR: @@ -668,14 +668,14 @@ static void Encode( instruction *ins ) case N_INDEXED: case N_TEMP: assert( ins->result->n.class == N_REGISTER ); - getMemEncoding( ins->operands[0], &mem_index, &mem_offset ); + getMemEncoding( ins->operands[0], ®idx_mem, &mem_offset ); // addi rd,off(ri|sp) - GenOPIMM( 14, _NameReg( ins->result ), mem_index, mem_offset ); + GenOPIMM( 14, _NameRegIndex( ins->result ), regidx_mem, mem_offset ); break; case N_MEMORY: assert( ins->result->n.class == N_REGISTER ); OutReloc( symLabel( ins->operands[0] ), PPC_RELOC_TOC_OFFSET, 2 ); - GenMEMINS( 32, _NameReg( ins->result ), RTOC_REG_IDX, 0 ); + GenMEMINS( 32, _NameRegIndex( ins->result ), RTOC_REG_IDX, 0 ); break; default: _Zoiks( ZOIKS_119 ); @@ -688,9 +688,9 @@ static void Encode( instruction *ins ) if( ins->head.opcode == OP_MUL ) { ops = FindOpcodes( ins ); GenFPOPINS( ops[0], ops[1], - _NameReg( ins->operands[0] ), - _NameReg( ins->operands[1] ), - _NameReg( ins->result ) ); + _NameRegIndex( ins->operands[0] ), + _NameRegIndex( ins->operands[1] ), + _NameRegIndex( ins->result ) ); break; } /* fall through */ @@ -699,9 +699,9 @@ static void Encode( instruction *ins ) assert( ins->operands[1]->n.class == N_REGISTER ); assert( ins->result->n.class == N_REGISTER ); ops = FindOpcodes( ins ); - a = _NameReg( ins->operands[0] ); - b = _NameReg( ins->operands[1] ); - s = _NameReg( ins->result ); + a = _NameRegIndex( ins->operands[0] ); + b = _NameRegIndex( ins->operands[1] ); + s = _NameRegIndex( ins->result ); if( ins->head.opcode == OP_SUB && G( ins ) == G_BINARY ) { /* someone sucks - it's not me */ @@ -716,9 +716,9 @@ static void Encode( instruction *ins ) assert( ins->operands[1]->n.class == N_REGISTER ); assert( ins->result->n.class == N_REGISTER ); ops = FindOpcodes( ins ); - s = _NameReg( ins->operands[0] ); - b = _NameReg( ins->operands[1] ); - a = _NameReg( ins->result ); + s = _NameRegIndex( ins->operands[0] ); + b = _NameRegIndex( ins->operands[1] ); + a = _NameRegIndex( ins->result ); GenOPINS( ops[0], ops[1], a, b, s ); break; case G_BINARYS_IMM: @@ -731,28 +731,28 @@ static void Encode( instruction *ins ) // rlwinm dst,src,n,0,31-n op2 = 31 - _FiveBits( ins->operands[1]->c.lo.int_value ); b = _FiveBits( ins->operands[1]->c.lo.int_value ); - GenOPINS( 21, op2, _NameReg( ins->result ), b, _NameReg( ins->operands[0] ) ); + GenOPINS( 21, op2, _NameRegIndex( ins->result ), b, _NameRegIndex( ins->operands[0] ) ); break; case OP_RSHIFT: if( _IsSigned( ins->type_class ) ) { - GenOPINS( 31, 824, _NameReg( ins->result ), - ins->operands[1]->c.lo.int_value, _NameReg( ins->operands[0] ) ); + GenOPINS( 31, 824, _NameRegIndex( ins->result ), + ins->operands[1]->c.lo.int_value, _NameRegIndex( ins->operands[0] ) ); } else { // rlwinm dst,src,32-n,n,31 b = _FiveBits( ins->operands[1]->c.lo.int_value ); op2 = ( b << 5 ) | 31; b = 32 - b; - GenOPINS( 21, op2, _NameReg( ins->result ), b, _NameReg( ins->operands[0] ) ); + GenOPINS( 21, op2, _NameRegIndex( ins->result ), b, _NameRegIndex( ins->operands[0] ) ); } break; default: ops = FindImmedOpcodes( ins ); if( G( ins ) == G_BINARYS_IMM ) { - s = _NameReg( ins->operands[0] ); - a = _NameReg( ins->result ); + s = _NameRegIndex( ins->operands[0] ); + a = _NameRegIndex( ins->result ); } else { - s = _NameReg( ins->result ); - a = _NameReg( ins->operands[0] ); + s = _NameRegIndex( ins->result ); + a = _NameRegIndex( ins->operands[0] ); } GenOPIMM( ops[0], s, a, ins->operands[1]->c.lo.int_value ); break; @@ -761,7 +761,7 @@ static void Encode( instruction *ins ) case G_CMP_FP: assert( ins->operands[0]->n.class == N_REGISTER ); assert( ins->operands[1]->n.class == N_REGISTER ); - GenCMP( 63, 32, _NameReg( ins->operands[0] ), _NameReg( ins->operands[1] ) ); + GenCMP( 63, 32, _NameRegIndex( ins->operands[0] ), _NameRegIndex( ins->operands[1] ) ); break; case G_CMP: assert( ins->operands[0]->n.class == N_REGISTER ); @@ -770,7 +770,7 @@ static void Encode( instruction *ins ) if( _IsSigned( ins->type_class ) ) { op2 = 0; } - GenCMP( 31, op2, _NameReg( ins->operands[0] ), _NameReg( ins->operands[1] ) ); + GenCMP( 31, op2, _NameRegIndex( ins->operands[0] ), _NameRegIndex( ins->operands[1] ) ); break; case G_CMP_I: assert( ins->operands[0]->n.class == N_REGISTER ); @@ -779,7 +779,7 @@ static void Encode( instruction *ins ) if( _IsSigned( ins->type_class ) ) { op1 = 11; } - GenCMPIMM( op1, _NameReg( ins->operands[0] ), ins->operands[1]->c.lo.int_value ); + GenCMPIMM( op1, _NameRegIndex( ins->operands[0] ), ins->operands[1]->c.lo.int_value ); break; case G_SIGN: assert( ins->operands[0]->n.class == N_REGISTER ); @@ -798,8 +798,8 @@ static void Encode( instruction *ins ) case G_UNARY: assert( ins->operands[0]->n.class == N_REGISTER ); assert( ins->result->n.class == N_REGISTER ); - a = _NameReg( ins->operands[0] ); - s = _NameReg( ins->result ); + a = _NameRegIndex( ins->operands[0] ); + s = _NameRegIndex( ins->result ); switch( ins->head.opcode ) { case OP_NEGATE: // neg src -> dst diff --git a/bld/cg/risc/ppc/c/ppcproc.c b/bld/cg/risc/ppc/c/ppcproc.c index 5faa8bab89..1d6b589c4f 100644 --- a/bld/cg/risc/ppc/c/ppcproc.c +++ b/bld/cg/risc/ppc/c/ppcproc.c @@ -148,7 +148,7 @@ static uint_32 registerMask( hw_reg_set rs, hw_reg_set *rl ) result = 0; for( curr = rl; !HW_CEqual( *curr, HW_EMPTY ); curr++ ) { if( HW_Ovlap( rs, *curr ) ) { - result |= 1 << RegTrans( *curr ); + result |= 1 << RegIndex( *curr ); } } return( result ); diff --git a/bld/cg/risc/ppc/c/ppcrgtbl.c b/bld/cg/risc/ppc/c/ppcrgtbl.c index e8887495f6..07ebc7d1df 100644 --- a/bld/cg/risc/ppc/c/ppcrgtbl.c +++ b/bld/cg/risc/ppc/c/ppcrgtbl.c @@ -812,21 +812,21 @@ reg_idx RegIndex( hw_reg_set reg ) * Translate reg to register index */ { - return( regTranslate( reg, true ) ); + return( (reg_idx)regTranslate( reg, true ) ); } void SetArchIndex( name *new_r, hw_reg_set regs ) /***********************************************/ { - new_r->r.arch_index = RegTrans( regs ); + new_r->r.arch_index = RegIndex( regs ); } -byte RegTrans( hw_reg_set reg ) -/********************************* +ppc_regn RegTrans( hw_reg_set reg ) +/************************************* * Translate reg to register index */ { - return( regTranslate( reg, true ) ); + return( (ppc_regn)regTranslate( reg, true ) ); } ppc_regn RegTransN( name *reg_name ) @@ -834,7 +834,7 @@ ppc_regn RegTransN( name *reg_name ) * Translate reg name to enum name */ { - return( regTranslate( reg_name->r.reg, false ) ); + return( (ppc_regn)regTranslate( reg_name->r.reg, false ) ); } diff --git a/bld/cg/risc/ppc/h/ppcenc.h b/bld/cg/risc/ppc/h/ppcenc.h index 5668af2178..8137388a6b 100644 --- a/bld/cg/risc/ppc/h/ppcenc.h +++ b/bld/cg/risc/ppc/h/ppcenc.h @@ -33,11 +33,13 @@ #include "ppcencod.h" -typedef uint_32 gen_opcode; -typedef uint_32 reg_idx; +typedef uint_32 gen_opcode; +typedef uint_32 reg_idx; -extern void GenMEMINS( gen_opcode, reg_idx, reg_idx, signed_16 ); -extern void GenOPINS( gen_opcode, gen_opcode, reg_idx, reg_idx, reg_idx ); -extern void GenOPIMM( gen_opcode, reg_idx, reg_idx, signed_16 ); -extern void GenMTSPR( reg_idx, uint_32, bool ); -extern void GenReturn( void ); +extern reg_idx RegIndex( hw_reg_set reg ); + +extern void GenMEMINS( gen_opcode, reg_idx, reg_idx, signed_16 ); +extern void GenOPINS( gen_opcode, gen_opcode, reg_idx, reg_idx, reg_idx ); +extern void GenOPIMM( gen_opcode, reg_idx, reg_idx, signed_16 ); +extern void GenMTSPR( reg_idx, uint_32, bool ); +extern void GenReturn( void ); diff --git a/bld/cg/risc/ppc/h/ppcregn.h b/bld/cg/risc/ppc/h/ppcregn.h index c14599c535..2645bf859c 100644 --- a/bld/cg/risc/ppc/h/ppcregn.h +++ b/bld/cg/risc/ppc/h/ppcregn.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -31,71 +32,72 @@ typedef enum ppc_regn{ - PPC_REGN_r0, - PPC_REGN_r1, - PPC_REGN_r2, - PPC_REGN_r3, - PPC_REGN_r4, - PPC_REGN_r5, - PPC_REGN_r6, - PPC_REGN_r7, - PPC_REGN_r8, - PPC_REGN_r9, - PPC_REGN_r10, - PPC_REGN_r11, - PPC_REGN_r12, - PPC_REGN_r13, - PPC_REGN_r14, - PPC_REGN_r15, - PPC_REGN_r16, - PPC_REGN_r17, - PPC_REGN_r18, - PPC_REGN_r19, - PPC_REGN_r20, - PPC_REGN_r21, - PPC_REGN_r22, - PPC_REGN_r23, - PPC_REGN_r24, - PPC_REGN_r25, - PPC_REGN_r26, - PPC_REGN_r27, - PPC_REGN_r28, - PPC_REGN_r29, - PPC_REGN_r30, - PPC_REGN_r31, - PPC_REGN_f0, - PPC_REGN_f1, - PPC_REGN_f2, - PPC_REGN_f3, - PPC_REGN_f4, - PPC_REGN_f5, - PPC_REGN_f6, - PPC_REGN_f7, - PPC_REGN_f8, - PPC_REGN_f9, - PPC_REGN_f10, - PPC_REGN_f11, - PPC_REGN_f12, - PPC_REGN_f13, - PPC_REGN_f14, - PPC_REGN_f15, - PPC_REGN_f16, - PPC_REGN_f17, - PPC_REGN_f18, - PPC_REGN_f19, - PPC_REGN_f20, - PPC_REGN_f21, - PPC_REGN_f22, - PPC_REGN_f23, - PPC_REGN_f24, - PPC_REGN_f25, - PPC_REGN_f26, - PPC_REGN_f27, - PPC_REGN_f28, - PPC_REGN_f29, - PPC_REGN_f30, - PPC_REGN_f31, - PPC_REGN_END, + PPC_REGN_r0, + PPC_REGN_r1, + PPC_REGN_r2, + PPC_REGN_r3, + PPC_REGN_r4, + PPC_REGN_r5, + PPC_REGN_r6, + PPC_REGN_r7, + PPC_REGN_r8, + PPC_REGN_r9, + PPC_REGN_r10, + PPC_REGN_r11, + PPC_REGN_r12, + PPC_REGN_r13, + PPC_REGN_r14, + PPC_REGN_r15, + PPC_REGN_r16, + PPC_REGN_r17, + PPC_REGN_r18, + PPC_REGN_r19, + PPC_REGN_r20, + PPC_REGN_r21, + PPC_REGN_r22, + PPC_REGN_r23, + PPC_REGN_r24, + PPC_REGN_r25, + PPC_REGN_r26, + PPC_REGN_r27, + PPC_REGN_r28, + PPC_REGN_r29, + PPC_REGN_r30, + PPC_REGN_r31, + PPC_REGN_f0, + PPC_REGN_f1, + PPC_REGN_f2, + PPC_REGN_f3, + PPC_REGN_f4, + PPC_REGN_f5, + PPC_REGN_f6, + PPC_REGN_f7, + PPC_REGN_f8, + PPC_REGN_f9, + PPC_REGN_f10, + PPC_REGN_f11, + PPC_REGN_f12, + PPC_REGN_f13, + PPC_REGN_f14, + PPC_REGN_f15, + PPC_REGN_f16, + PPC_REGN_f17, + PPC_REGN_f18, + PPC_REGN_f19, + PPC_REGN_f20, + PPC_REGN_f21, + PPC_REGN_f22, + PPC_REGN_f23, + PPC_REGN_f24, + PPC_REGN_f25, + PPC_REGN_f26, + PPC_REGN_f27, + PPC_REGN_f28, + PPC_REGN_f29, + PPC_REGN_f30, + PPC_REGN_f31, + PPC_REGN_END, } ppc_regn; -extern ppc_regn RegTransN( name *reg_name ); +extern ppc_regn RegTrans( hw_reg_set reg ); +extern ppc_regn RegTransN( name *reg_name ); From 76a104e8a59258b71fcf6ed0cb46d12c8d671220 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Mal=C3=A1k?= Date: Tue, 3 Oct 2023 17:21:58 +0200 Subject: [PATCH 202/258] Delete .github/workflows/mirror.yml --- .github/workflows/mirror.yml | 1 - 1 file changed, 1 deletion(-) delete mode 100644 .github/workflows/mirror.yml diff --git a/.github/workflows/mirror.yml b/.github/workflows/mirror.yml deleted file mode 100644 index 8b13789179..0000000000 --- a/.github/workflows/mirror.yml +++ /dev/null @@ -1 +0,0 @@ - From c07a7c85e8ba5a438903627f18b4428faa497cd2 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Tue, 3 Oct 2023 21:27:57 +0200 Subject: [PATCH 203/258] cleanup alpha encoding of instruction with literal data --- bld/as/axp/c/alphafmt.c | 8 ++++---- bld/cg/risc/axp/c/axpenc.c | 2 +- bld/watcom/h/axpencod.h | 3 ++- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/bld/as/axp/c/alphafmt.c b/bld/as/axp/c/alphafmt.c index ba9df837a0..e93f6a19b6 100644 --- a/bld/as/axp/c/alphafmt.c +++ b/bld/as/axp/c/alphafmt.c @@ -377,12 +377,12 @@ static void doMov( uint_32 *buffer, ins_operand *operands[], domov_option m_opt if( op0->type == OP_GPR ) { extra = _Rb( RegIndex( op0->reg ) ); } else if( ( op0->constant & 0xff ) == op0->constant ) { // OP_IMMED implied - extra = _LIT( op0->constant ); // this lit is between 0..255 + extra = _LIT( op0->constant ) | _LIT_bit; // this lit is between 0..255 (void)checkOpAbsolute( op0, 0 ); } else if( m_opt == DOMOV_ABS ) { abs_val = abs( op0->constant ); if( ( abs_val & 0xff ) == abs_val ) { - extra = _LIT( abs_val ); // this lit is between 0..255 + extra = _LIT( abs_val ) | _LIT_bit; // this lit is between 0..255 // checkOpAbsolute( op0, 0 ); should be done before calling doMov } else { ready = false; @@ -814,7 +814,7 @@ static void ITOperate( ins_table *table, instruction *ins, uint_32 *buffer, asm_ extra = _Rb( RegIndex( op->reg ) ); } else { // OP_IMMED assert( op->type == OP_IMMED ); - extra = _LIT( op->constant ); + extra = _LIT( op->constant ) | _LIT_bit; (void)checkOpAbsolute( op, 1 ); } fc = getFuncCode( table, ins ); @@ -951,7 +951,7 @@ static void ITPseudoNot( ins_table *table, instruction *ins, uint_32 *buffer, as extra = _Rb( RegIndex( op->reg ) ); } else { // OP_IMMED assert( op->type == OP_IMMED ); - extra = _LIT( op->constant ); + extra = _LIT( op->constant ) | _LIT_bit; (void)checkOpAbsolute( op, 0 ); } fc = getFuncCode( table, ins ); diff --git a/bld/cg/risc/axp/c/axpenc.c b/bld/cg/risc/axp/c/axpenc.c index b03256a202..07e29420bf 100644 --- a/bld/cg/risc/axp/c/axpenc.c +++ b/bld/cg/risc/axp/c/axpenc.c @@ -300,7 +300,7 @@ void GenOPINS( uint_8 opcode, uint_8 function, uint_8 reg_a, uint_8 reg_b, uint_ static void GenOPIMM( uint_8 opcode, uint_8 function, uint_8 reg_a, uint_8 imm, uint_8 reg_c ) /************************************************************************************************/ { - ins_encoding = _Opcode( opcode ) | _Ra( reg_a ) | _LIT( imm ) | ( 1 << 12 ) | _Rc( reg_c ) | _Function( function ); + ins_encoding = _Opcode( opcode ) | _Ra( reg_a ) | _LIT( imm ) | _LIT_bit | _Rc( reg_c ) | _Function( function ); EmitIns( ins_encoding ); } diff --git a/bld/watcom/h/axpencod.h b/bld/watcom/h/axpencod.h index da3130fbe2..9b45b9726a 100644 --- a/bld/watcom/h/axpencod.h +++ b/bld/watcom/h/axpencod.h @@ -44,7 +44,8 @@ #define _Ra( x ) ( _FiveBits(x) << 21 ) #define _Rb( x ) ( _FiveBits(x) << 16 ) #define _Rc( x ) ( _FiveBits(x) << 0 ) -#define _LIT( x ) ( ( ( _EightBits(x) << 1 ) | 1 ) << 12 ) +#define _LIT( x ) ( _EightBits(x) << 13 ) +#define _LIT_bit ( 1 << 12 ) #define _Opcode( x ) ( _SixBits(x) << 26 ) #define _Function( x ) ( _SevenBits(x) << 5 ) From e086fba5946bd2acc36ab08198a208eb8e1cca28 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Tue, 3 Oct 2023 22:37:22 +0200 Subject: [PATCH 204/258] correct type mismatches in risc cg --- bld/cg/risc/axp/c/axpenc.c | 99 ++++++++++++++++++------------------ bld/cg/risc/axp/h/axpenc.h | 8 +-- bld/cg/risc/mps/c/mpsenc.c | 2 +- bld/cg/risc/mps/c/mpsrgtbl.c | 10 ++-- bld/cg/risc/ppc/c/ppcrgtbl.c | 12 ++--- bld/cg/risc/ppc/h/ppcenc.h | 12 ++--- bld/cg/risc/ppc/h/ppcregn.h | 2 +- 7 files changed, 73 insertions(+), 72 deletions(-) diff --git a/bld/cg/risc/axp/c/axpenc.c b/bld/cg/risc/axp/c/axpenc.c index 07e29420bf..37290355b6 100644 --- a/bld/cg/risc/axp/c/axpenc.c +++ b/bld/cg/risc/axp/c/axpenc.c @@ -283,34 +283,34 @@ static void EmitIns( axp_ins ins ) EmitInsReloc( &ins, NULL, 0 ); } -static void GenFPOPINS( uint_8 opcode, uint_16 function, uint_8 reg_a, uint_8 reg_b, uint_8 reg_c ) -/**************************************************************************************************/ +static void GenFPOPINS( uint_8 opcode, uint_16 function, reg_idx ra, reg_idx rb, reg_idx rc ) +/********************************************************************************************/ { - ins_encoding = _Opcode( opcode ) | _Ra( reg_a ) | _Rb( reg_b ) | _Rc( reg_c ) | _FPFunction( function ); + ins_encoding = _Opcode( opcode ) | _Ra( ra ) | _Rb( rb ) | _Rc( rc ) | _FPFunction( function ); EmitIns( ins_encoding ); } -void GenOPINS( uint_8 opcode, uint_8 function, uint_8 reg_a, uint_8 reg_b, uint_8 reg_c ) -/***************************************************************************************/ +void GenOPINS( uint_8 opcode, uint_8 function, reg_idx ra, reg_idx rb, reg_idx rc ) +/*********************************************************************************/ { - ins_encoding = _Opcode( opcode ) | _Ra( reg_a ) | _Rb( reg_b ) | _Rc( reg_c ) | _Function( function ); + ins_encoding = _Opcode( opcode ) | _Ra( ra ) | _Rb( rb ) | _Rc( rc ) | _Function( function ); EmitIns( ins_encoding ); } -static void GenOPIMM( uint_8 opcode, uint_8 function, uint_8 reg_a, uint_8 imm, uint_8 reg_c ) -/************************************************************************************************/ +static void GenOPIMM8( uint_8 opcode, uint_8 function, reg_idx ra, uint_8 imm, reg_idx rc ) +/*********************************************************************************************/ { - ins_encoding = _Opcode( opcode ) | _Ra( reg_a ) | _LIT( imm ) | _LIT_bit | _Rc( reg_c ) | _Function( function ); + ins_encoding = _Opcode( opcode ) | _Ra( ra ) | _LIT( imm ) | _LIT_bit | _Rc( rc ) | _Function( function ); EmitIns( ins_encoding ); } -void GenLOADS32( signed_32 value, uint_8 reg ) -/***********************************************/ +void GenLOADS32( signed_32 value, reg_idx reg ) +/************************************************/ { signed_16 high; signed_16 extra; signed_16 low; - uint_8 curr; + reg_idx curr; curr = ZERO_REG_IDX; FactorInt32( value, &high, &extra, &low ); @@ -384,22 +384,22 @@ static uint_16 FindFloatingOpcodes( instruction *ins ) return( opcode ); } -static void GenMEMINSRELOC( uint_8 opcode, uint_8 a, uint_8 b, signed_16 displacement, pointer lbl, owl_reloc_type type ) -/***********************************************************************************************************************/ +static void GenMEMINSRELOC( uint_8 opcode, reg_idx ra, reg_idx rb, signed_16 displacement, pointer lbl, owl_reloc_type type ) +/***************************************************************************************************************************/ { - ins_encoding = _Opcode( opcode ) | _Ra( a ) | _Rb( b ) | _SignedImmed( displacement ); + ins_encoding = _Opcode( opcode ) | _Ra( ra ) | _Rb( rb ) | _SignedImmed( displacement ); EmitInsReloc( &ins_encoding, lbl, type ); } -void GenMEMINS( uint_8 opcode, uint_8 a, uint_8 b, signed_16 displacement ) -/*************************************************************************/ +void GenMEMINS( uint_8 opcode, reg_idx ra, reg_idx rb, signed_16 displacement ) +/*****************************************************************************/ { - ins_encoding = _Opcode( opcode ) | _Ra( a ) | _Rb( b ) | _SignedImmed( displacement ); + ins_encoding = _Opcode( opcode ) | _Ra( ra ) | _Rb( rb ) | _SignedImmed( displacement ); EmitIns( ins_encoding ); } -static void GenBRANCH( uint_8 opcode, uint_8 reg, pointer label ) -/*******************************************************************/ +static void GenBRANCH( uint_8 opcode, reg_idx reg, pointer label ) +/********************************************************************/ { ins_encoding = _Opcode( opcode ) | _Ra( reg ); EmitInsReloc( &ins_encoding, label, OWL_RELOC_BRANCH_REL ); @@ -478,8 +478,8 @@ type_length TempLocation( name *temp ) return( offset + base->t.location + temp->v.offset - base->v.offset ); } -void GenCallLabelReg( pointer label, uint reg ) -/************************************************/ +void GenCallLabelReg( pointer label, reg_idx reg ) +/***************************************************/ { GenBRANCH( 0x34, reg, label ); } @@ -533,8 +533,8 @@ static void doCall( instruction *ins ) } } -static void addressTemp( name *temp, uint_8 *reg, int_16 *offset ) -/********************************************************************/ +static void addressTemp( name *temp, reg_idx *regidx_mem, int_16 *offset ) +/****************************************************************************/ { type_length temp_offset; @@ -546,18 +546,18 @@ static void addressTemp( name *temp, uint_8 *reg, int_16 *offset ) GenLOADS32( temp_offset, AT_REG_IDX ); GenOPINS( 0x10, 0x00, SP_REG_IDX, AT_REG_IDX, AT_REG_IDX ); *offset = 0; - *reg = AT_REG_IDX; + *regidx_mem = AT_REG_IDX; } else { *offset = temp_offset; - *reg = SP_REG_IDX; + *regidx_mem = SP_REG_IDX; if( CurrProc->targ.base_is_fp ) { - *reg = FP_REG_IDX; + *regidx_mem = FP_REG_IDX; } } } -static void getMemEncoding( name *mem, uint_8 *regidx_mem, int_16 *offset ) -/****************************************************************************/ +static void getMemEncoding( name *mem, reg_idx *regidx_mem, int_16 *offset ) +/*****************************************************************************/ { switch( mem->n.class ) { case N_INDEXED: @@ -586,7 +586,7 @@ static void doLoadStore( instruction *ins, bool load ) name *mem; name *reg; uint_8 opcode; - uint_8 regidx_mem; + reg_idx regidx_mem; int_16 offset; if( load ) { @@ -612,8 +612,8 @@ static void doLoadStore( instruction *ins, bool load ) static void GenCallIndirect( instruction *call ) /**************************************************/ { - uint_8 regidx; - uint_8 regidx_mem; + reg_idx regidx; + reg_idx regidx_mem; int_16 mem_offset; name *addr; @@ -654,15 +654,17 @@ static void doChop( instruction *ins, type_class_def type_class ) _Zoiks( ZOIKS_078 ); } /* zapnot */ - GenOPIMM( 0x12, 0x31, _NameRegIndex( ins->operands[0] ), zap_mask, _NameRegIndex( ins->result ) ); + GenOPIMM8( 0x12, 0x31, _NameRegIndex( ins->operands[0] ), + (uint_8)zap_mask, + _NameRegIndex( ins->result ) ); } static void doSignExtend( instruction *ins, type_class_def type_class ) /*************************************************************************/ { unsigned from_size; - int res_index; - int src_index; + reg_idx res_index; + reg_idx src_index; int shift_amt; res_index = _NameRegIndex( ins->result ); @@ -674,9 +676,9 @@ static void doSignExtend( instruction *ins, type_class_def type_class ) } else { shift_amt = ( REG_SIZE - from_size ) * 8; /* shl */ - GenOPIMM( 0x12, 0x39, src_index, shift_amt, res_index ); + GenOPIMM8( 0x12, 0x39, src_index, (uint_8)shift_amt, res_index ); /* sra */ - GenOPIMM( 0x12, 0x3c, res_index, shift_amt, res_index ); + GenOPIMM8( 0x12, 0x3c, res_index, (uint_8)shift_amt, res_index ); } } @@ -728,8 +730,8 @@ static void Encode( instruction *ins ) { uint_8 *opcodes; uint_16 function; - uint_8 regidx; - uint_8 regidx_mem; + reg_idx regidx; + reg_idx regidx_mem; int_16 mem_offset; signed_16 high; signed_16 extra; @@ -841,9 +843,9 @@ static void Encode( instruction *ins ) assert( ins->operands[1]->n.class == N_CONSTANT ); assert( ins->result->n.class == N_REGISTER ); opcodes = FindOpcodes( ins ); - GenOPIMM( opcodes[0], opcodes[1], - _NameRegIndex( ins->operands[0] ), ins->operands[1]->c.lo.int_value, - _NameRegIndex( ins->result ) ); + GenOPIMM8( opcodes[0], opcodes[1], _NameRegIndex( ins->operands[0] ), + (uint_8)ins->operands[1]->c.lo.int_value, + _NameRegIndex( ins->result ) ); break; case G_BYTE_CONST: /* @@ -851,9 +853,9 @@ static void Encode( instruction *ins ) */ assert( ins->operands[0]->n.class == N_CONSTANT ); assert( ins->result->n.class == N_REGISTER ); - GenOPIMM( 0x10, 0x00, - ZERO_REG_IDX, (uint_8)ins->operands[0]->c.lo.int_value, - _NameRegIndex( ins->result ) ); + GenOPIMM8( 0x10, 0x00, ZERO_REG_IDX, + (uint_8)ins->operands[0]->c.lo.int_value, + _NameRegIndex( ins->result ) ); break; case G_MOVE: assert( ins->operands[0]->n.class == N_REGISTER ); @@ -872,10 +874,9 @@ static void Encode( instruction *ins ) /* * generate a "ZAPNOT Ra,#i,Rb" instruction */ - GenOPIMM( 0x12, 0x31, - _NameRegIndex( ins->operands[0] ), - zapMask[ins->flags.zap_value], - _NameRegIndex( ins->result ) ); + GenOPIMM8( 0x12, 0x31, _NameRegIndex( ins->operands[0] ), + zapMask[ins->flags.zap_value], + _NameRegIndex( ins->result ) ); break; case G_LEA_HIGH: assert( ins->operands[0]->n.class == N_CONSTANT ); diff --git a/bld/cg/risc/axp/h/axpenc.h b/bld/cg/risc/axp/h/axpenc.h index c7be3bce67..070c5821b2 100644 --- a/bld/cg/risc/axp/h/axpenc.h +++ b/bld/cg/risc/axp/h/axpenc.h @@ -36,10 +36,10 @@ typedef uint_8 reg_idx; extern reg_idx RegIndex( hw_reg_set reg ); -extern void GenCallLabelReg( pointer label, uint reg ); -extern void GenOPINS( uint_8 opcode, uint_8 function, uint_8 reg_a, uint_8 reg_b, uint_8 reg_c ); -extern void GenLOADS32( signed_32 value, uint_8 reg ); -extern void GenMEMINS( uint_8 opcode, uint_8 a, uint_8 b, signed_16 displacement ); +extern void GenCallLabelReg( pointer label, reg_idx reg ); +extern void GenOPINS( uint_8 opcode, uint_8 function, reg_idx ra, reg_idx rb, reg_idx rc ); +extern void GenLOADS32( signed_32 value, reg_idx reg ); +extern void GenMEMINS( uint_8 opcode, reg_idx ra, reg_idx rb, signed_16 displacement ); extern void GenLOAD( hw_reg_set dst, hw_reg_set src, signed_16 displacement ); extern void GenFLOAD( hw_reg_set dst, hw_reg_set src, signed_16 displacement ); extern void GenSTORE( hw_reg_set dst, signed_16 displacement, hw_reg_set src ); diff --git a/bld/cg/risc/mps/c/mpsenc.c b/bld/cg/risc/mps/c/mpsenc.c index d01bdf1a84..9bd50aa055 100644 --- a/bld/cg/risc/mps/c/mpsenc.c +++ b/bld/cg/risc/mps/c/mpsenc.c @@ -58,7 +58,7 @@ #include "feprotos.h" -#define _NameRegIndex( op ) ( (op)->r.arch_index ) +#define _NameRegIndex( op ) ( (op)->r.arch_index ) #define _BinaryOpcode( a, b ) { { a, b }, { a, b } } #define _SignedOpcode( a, b, c, d ) { { a, b }, { c, d } } diff --git a/bld/cg/risc/mps/c/mpsrgtbl.c b/bld/cg/risc/mps/c/mpsrgtbl.c index 1097154284..732c3020ef 100644 --- a/bld/cg/risc/mps/c/mpsrgtbl.c +++ b/bld/cg/risc/mps/c/mpsrgtbl.c @@ -856,7 +856,7 @@ void InitRegTbl( void ) static int regTranslate( hw_reg_set reg, bool index ) /********************************************************/ { - int i; + int i; /* * This should be cached in the reg name and used instead of a stupid lookup @@ -868,11 +868,11 @@ static int regTranslate( hw_reg_set reg, bool index ) return( i + MIPS_REGN_r0 ); } } - if( index ) { - for( i = 0; i < sizeof( QWordRegs ) / sizeof( QWordRegs[0] ); i++ ) { - if( HW_Subset( QWordRegs[i], reg ) ) { + for( i = 0; i < sizeof( QWordRegs ) / sizeof( QWordRegs[0] ); i++ ) { + if( HW_Subset( QWordRegs[i], reg ) ) { + if( index ) return( i * 2 + 2 ); - } + return( i * 2 + 2 + MIPS_REGN_r0 ); } } for( i = 0; i < sizeof( FloatRegs ) / sizeof( FloatRegs[0] ); i++ ) { diff --git a/bld/cg/risc/ppc/c/ppcrgtbl.c b/bld/cg/risc/ppc/c/ppcrgtbl.c index 07ebc7d1df..95c18c266c 100644 --- a/bld/cg/risc/ppc/c/ppcrgtbl.c +++ b/bld/cg/risc/ppc/c/ppcrgtbl.c @@ -782,8 +782,8 @@ void InitRegTbl( void ) { } -static int regTranslate( hw_reg_set reg, bool index ) -/****************************************************/ +static int regTranslate( hw_reg_set reg, bool index ) +/********************************************************/ { int i; @@ -807,8 +807,8 @@ static int regTranslate( hw_reg_set reg, bool index ) return( PPC_REGN_END ); } -reg_idx RegIndex( hw_reg_set reg ) -/********************************* +reg_idx RegIndex( hw_reg_set reg ) +/************************************* * Translate reg to register index */ { @@ -823,10 +823,10 @@ void SetArchIndex( name *new_r, hw_reg_set regs ) ppc_regn RegTrans( hw_reg_set reg ) /************************************* - * Translate reg to register index + * Translate reg to enum name */ { - return( (ppc_regn)regTranslate( reg, true ) ); + return( (ppc_regn)regTranslate( reg, false ) ); } ppc_regn RegTransN( name *reg_name ) diff --git a/bld/cg/risc/ppc/h/ppcenc.h b/bld/cg/risc/ppc/h/ppcenc.h index 8137388a6b..4a94c3c99e 100644 --- a/bld/cg/risc/ppc/h/ppcenc.h +++ b/bld/cg/risc/ppc/h/ppcenc.h @@ -34,12 +34,12 @@ typedef uint_32 gen_opcode; -typedef uint_32 reg_idx; +typedef uint_8 reg_idx; extern reg_idx RegIndex( hw_reg_set reg ); -extern void GenMEMINS( gen_opcode, reg_idx, reg_idx, signed_16 ); -extern void GenOPINS( gen_opcode, gen_opcode, reg_idx, reg_idx, reg_idx ); -extern void GenOPIMM( gen_opcode, reg_idx, reg_idx, signed_16 ); -extern void GenMTSPR( reg_idx, uint_32, bool ); -extern void GenReturn( void ); +extern void GenMEMINS( gen_opcode, reg_idx, reg_idx, signed_16 ); +extern void GenOPINS( gen_opcode, gen_opcode, reg_idx, reg_idx, reg_idx ); +extern void GenOPIMM( gen_opcode, reg_idx, reg_idx, signed_16 ); +extern void GenMTSPR( reg_idx, uint_32, bool ); +extern void GenReturn( void ); diff --git a/bld/cg/risc/ppc/h/ppcregn.h b/bld/cg/risc/ppc/h/ppcregn.h index 2645bf859c..a42f744dd0 100644 --- a/bld/cg/risc/ppc/h/ppcregn.h +++ b/bld/cg/risc/ppc/h/ppcregn.h @@ -31,7 +31,7 @@ ****************************************************************************/ -typedef enum ppc_regn{ +typedef enum ppc_regn { PPC_REGN_r0, PPC_REGN_r1, PPC_REGN_r2, From 9aa456e4c7547eac15f7caa0cfd56fb53121b522 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Wed, 4 Oct 2023 02:06:22 +0200 Subject: [PATCH 205/258] correct type mismatches in risc assemblers --- bld/as/axp/c/alphafmt.c | 32 +++++++++++++++----------------- bld/as/mps/c/mipsfmt.c | 13 +++++-------- 2 files changed, 20 insertions(+), 25 deletions(-) diff --git a/bld/as/axp/c/alphafmt.c b/bld/as/axp/c/alphafmt.c index e93f6a19b6..74081306b0 100644 --- a/bld/as/axp/c/alphafmt.c +++ b/bld/as/axp/c/alphafmt.c @@ -39,8 +39,6 @@ #define _Memory_disp( x ) ( _SixteenBits( x ) << 0 ) #define _Mem_Func( x ) ( _SixteenBits( x ) << 0 ) #define _Branch_disp( x ) ( _TwentyOneBits( x ) << 0 ) -#define _Op_Func( x ) ( _SevenBits( x ) << 5 ) -#define _FP_Op_Func( x ) ( _ElevenBits( x ) << 5 ) #define _Longword_offset( x ) ( (x) >> 2 ) @@ -224,20 +222,18 @@ static void doOpcodeRaRb( uint_32 *buffer, ins_opcode opcode, reg_idx ra, reg_id *buffer = _Opcode( opcode ) | _Ra( ra ) | _Rb( rb ) | remain; } -static void doOpcodeFcRaRc( uint_32 *buffer, ins_opcode opcode, ins_funccode fc, uint_8 ra, uint_8 rc, uint_32 extra ) -//******************************************************************************************************************** +static void doOpcodeFcRaRc( uint_32 *buffer, ins_opcode opcode, ins_funccode fc, reg_idx ra, reg_idx rc, uint_32 extra ) +//********************************************************************************************************************** // This procedure doesn't fill in all the bits (missing bits 20-12). // But we can fill it in using extra. { - *buffer = _Opcode( opcode ) | _Op_Func( fc ) | _Ra( ra ) | _Rc( rc ) | - extra; + *buffer = _Opcode( opcode ) | _Function( fc ) | _Ra( ra ) | _Rc( rc ) | extra; } -static void doFPInst( uint_32 *buffer, ins_opcode opcode, uint_8 ra, uint_8 rb, uint_8 rc, uint_32 remain ) -//********************************************************************************************************* +static void doFPInst( uint_32 *buffer, ins_opcode opcode, reg_idx ra, reg_idx rb, reg_idx rc, uint_32 fc ) +//******************************************************************************************************** { - *buffer = _Opcode( opcode ) | _Ra( ra ) | _Rb( rb ) | - _FP_Op_Func( remain ) | _Rc( rc ); + *buffer = _Opcode( opcode ) | _Ra( ra ) | _Rb( rb ) | _FPFunction( fc ) | _Rc( rc ); } #ifndef _STANDALONE_ @@ -408,7 +404,7 @@ static void ITLoadAddress( ins_table *table, instruction *ins, uint_32 *buffer, ins_operand *ops[2]; unsigned inc; // op_const val; - uint_8 s_reg; + reg_idx s_reg; /* unused parameters */ (void)table; @@ -632,7 +628,7 @@ static void ITMemJump( ins_table *table, instruction *ins, uint_32 *buffer, asm_ ins_operand *op0, *op1; int num_op; int inc; - uint_8 d_reg_idx; // default d_reg if not specified + reg_idx d_reg_idx; // default d_reg if not specified num_op = ins->num_operands; // First check if the operands are of the right types @@ -727,7 +723,7 @@ static void ITRet( ins_table *table, instruction *ins, uint_32 *buffer, asm_relo { ins_operand *op0, *op1; int num_op; - uint_8 d_reg_idx; // default d_reg if not specified + reg_idx d_reg_idx; // default d_reg if not specified num_op = ins->num_operands; // First check if the operands are of the right types @@ -884,7 +880,7 @@ static void ITMTMFFpcr( ins_table *table, instruction *ins, uint_32 *buffer, asm { assert( ins->num_operands == 1 || ins->num_operands == 3 ); if( ins->num_operands == 1 ) { - uint_8 reg_num; + reg_idx reg_num; reg_num = RegIndex( ins->operands[0]->reg ); doFPInst( buffer, table->opcode, reg_num, reg_num, reg_num, @@ -926,7 +922,7 @@ static void ITPseudoMov( ins_table *table, instruction *ins, uint_32 *buffer, as static void ITPseudoFmov( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) //*********************************************************************************************** { - uint_8 reg_idx0; + reg_idx reg_idx0; /* unused parameters */ (void)reloc; @@ -975,7 +971,7 @@ static void ITPseudoNegf( ins_table *table, instruction *ins, uint_32 *buffer, a static void ITPseudoFneg( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) //*********************************************************************************************** { - uint_8 reg_idx0; + reg_idx reg_idx0; /* unused parameters */ (void)reloc; @@ -988,7 +984,9 @@ static void ITPseudoFneg( ins_table *table, instruction *ins, uint_32 *buffer, a static void ITPseudoAbs( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) //********************************************************************************************** { - uint_8 s_reg_idx, d_reg_idx, rc_reg_idx; + reg_idx s_reg_idx; + reg_idx d_reg_idx; + reg_idx rc_reg_idx; ins_operand *src_op; bool same_reg; diff --git a/bld/as/mps/c/mipsfmt.c b/bld/as/mps/c/mipsfmt.c index f8dad789d3..44a4341543 100644 --- a/bld/as/mps/c/mipsfmt.c +++ b/bld/as/mps/c/mipsfmt.c @@ -42,7 +42,6 @@ #define _Memory_disp( x ) ( _SixteenBits( x ) << 0 ) #define _Mem_Func( x ) ( _SixteenBits( x ) << 0 ) -#define _Op_Func( x ) ( _SixBits( x ) << 0 ) #define _FP_Op_Func( x ) ( _ElevenBits( x ) << 5 ) /* @@ -330,23 +329,21 @@ static void doOpcodeFcRsRt( uint_32 *buffer, ins_opcode opcode, ins_funccode fc, * But we can fill it in using extra. */ { - *buffer = _Opcode( opcode ) | _Op_Func( fc ) | _Rs( ra ) | _Rt( rc ) | extra; + *buffer = _Opcode( opcode ) | _Function( fc ) | _Rs( ra ) | _Rt( rc ) | extra; } static void doOpcodeFcRsRtImm( uint_32 *buffer, ins_opcode opcode, ins_funccode fc, reg_idx rs, reg_idx rt, op_const imm ) //************************************************************************************************************************ { - *buffer = _Opcode( opcode ) | _Op_Func( fc ) | _Rs( rs ) | _Rt( rt ) | - _SignedImmed( imm ); + *buffer = _Opcode( opcode ) | _Function( fc ) | _Rs( rs ) | _Rt( rt ) | _SignedImmed( imm ); } static void doOpcodeFcRdRtSa( uint_32 *buffer, ins_opcode opcode, ins_funccode fc, reg_idx rd, reg_idx rt, op_const sa ) //********************************************************************************************************************** { - *buffer = _Opcode( opcode ) | _Op_Func( fc ) | _Rd( rd ) | _Rt( rt ) | - _Shift( sa ); + *buffer = _Opcode( opcode ) | _Function( fc ) | _Rd( rd ) | _Rt( rt ) | _Shift( sa ); } @@ -538,7 +535,7 @@ static void ITSysCode( ins_table *table, instruction *ins, uint_32 *buffer, asm_ } else { constant = 0; } - *buffer = _Opcode( table->opcode ) | _Code( constant ) | _Op_Func( table->funccode ); + *buffer = _Opcode( table->opcode ) | _Code( constant ) | _Function( table->funccode ); } @@ -560,7 +557,7 @@ static void ITTrap( ins_table *table, instruction *ins, uint_32 *buffer, asm_rel *buffer = _Opcode( table->opcode ) | _Rs( RegIndex( ins->operands[0]->reg ) ) | _Rt( RegIndex( ins->operands[1]->reg ) ) | - _TrapCode( code ) | _Op_Func( table->funccode ); + _TrapCode( code ) | _Function( table->funccode ); } From 5e3b90710e4d62fa5dd9bb3ee7eca11561c700f2 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Wed, 4 Oct 2023 16:23:05 +0200 Subject: [PATCH 206/258] suppress compiler warnings --- bld/cpp/c/ppfmttm.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/bld/cpp/c/ppfmttm.c b/bld/cpp/c/ppfmttm.c index 0e5c97940f..a2cd60bfbe 100644 --- a/bld/cpp/c/ppfmttm.c +++ b/bld/cpp/c/ppfmttm.c @@ -46,17 +46,17 @@ void FormatTime_tm( char *buf, struct tm *t ) /* 01234567 */ /* '00:00:00' */ x = div( t->tm_sec, 10 ); - buf[7] = x.rem + '0'; + buf[7] = (char)( x.rem + '0' ); x = div( x.quot, 10 ); - buf[6] = x.rem + '0'; + buf[6] = (char)( x.rem + '0' ); x = div( t->tm_min, 10 ); - buf[4] = x.rem + '0'; + buf[4] = (char)( x.rem + '0' ); x = div( x.quot, 10 ); - buf[3] = x.rem + '0'; + buf[3] = (char)( x.rem + '0' ); x = div( t->tm_hour, 10 ); - buf[1] = x.rem + '0'; + buf[1] = (char)( x.rem + '0' ); x = div( x.quot, 10 ); - buf[0] = x.rem + '0'; + buf[0] = (char)( x.rem + '0' ); } void FormatDate_tm( char *buf, struct tm *t ) @@ -66,20 +66,20 @@ void FormatDate_tm( char *buf, struct tm *t ) /* 01234567890 */ /* 'Dec 00 0000' */ x = div( t->tm_year + 1900, 10 ); - buf[10] = x.rem + '0'; + buf[10] = (char)( x.rem + '0' ); x = div( x.quot, 10 ); - buf[9] = x.rem + '0'; + buf[9] = (char)( x.rem + '0' ); x = div( x.quot, 10 ); - buf[8] = x.rem + '0'; + buf[8] = (char)( x.rem + '0' ); x = div( x.quot, 10 ); - buf[7] = x.rem + '0'; + buf[7] = (char)( x.rem + '0' ); x = div( t->tm_mday, 10 ); - buf[5] = x.rem + '0'; + buf[5] = (char)( x.rem + '0' ); if( t->tm_mday < 10 ) { buf[4] = ' '; } else { x = div( x.quot, 10 ); - buf[4] = x.rem + '0'; + buf[4] = (char)( x.rem + '0' ); } buf[2] = Months[t->tm_mon][2]; buf[1] = Months[t->tm_mon][1]; From 61e38232fbb563777f771b212478f907f6ed11a2 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Wed, 4 Oct 2023 16:27:19 +0200 Subject: [PATCH 207/258] correct type mismatches --- bld/cg/risc/axp/c/axpenc.c | 22 ++++++------- bld/cg/risc/mps/c/mpsenc.c | 61 +++++++++++++++---------------------- bld/cg/risc/mps/c/mpsenc2.c | 12 ++++---- bld/cg/risc/mps/h/mpsenc.h | 12 ++++---- 4 files changed, 47 insertions(+), 60 deletions(-) diff --git a/bld/cg/risc/axp/c/axpenc.c b/bld/cg/risc/axp/c/axpenc.c index 37290355b6..4b244f915a 100644 --- a/bld/cg/risc/axp/c/axpenc.c +++ b/bld/cg/risc/axp/c/axpenc.c @@ -663,22 +663,22 @@ static void doSignExtend( instruction *ins, type_class_def type_class ) /*************************************************************************/ { unsigned from_size; - reg_idx res_index; - reg_idx src_index; + reg_idx regidx_res; + reg_idx regidx_src; int shift_amt; - res_index = _NameRegIndex( ins->result ); - src_index = _NameRegIndex( ins->operands[0] ); + regidx_res = _NameRegIndex( ins->result ); + regidx_src = _NameRegIndex( ins->operands[0] ); from_size = TypeClassSize[type_class]; if( from_size == 4 ) { /* addl r31, src -> dst */ - GenOPINS( 0x10, 0x00, ZERO_REG_IDX, src_index, res_index ); + GenOPINS( 0x10, 0x00, ZERO_REG_IDX, regidx_src, regidx_res ); } else { shift_amt = ( REG_SIZE - from_size ) * 8; /* shl */ - GenOPIMM8( 0x12, 0x39, src_index, (uint_8)shift_amt, res_index ); + GenOPIMM8( 0x12, 0x39, regidx_src, (uint_8)shift_amt, regidx_res ); /* sra */ - GenOPIMM8( 0x12, 0x3c, res_index, (uint_8)shift_amt, res_index ); + GenOPIMM8( 0x12, 0x3c, regidx_res, (uint_8)shift_amt, regidx_res ); } } @@ -712,10 +712,8 @@ static bool encodeThreadDataRef( instruction *ins ) * This is done in FixMemRefs. */ tls_index = RTLabel( RT_TLS_INDEX ); - GenMEMINSRELOC( 0x09, AT_REG_IDX, ZERO_REG_IDX, 0, - tls_index, OWL_RELOC_HALF_HI ); - GenMEMINSRELOC( 0x08, AT_REG_IDX, AT_REG_IDX, 0, - tls_index, OWL_RELOC_HALF_LO ); + GenMEMINSRELOC( 0x09, AT_REG_IDX, ZERO_REG_IDX, 0, tls_index, OWL_RELOC_HALF_HI ); + GenMEMINSRELOC( 0x08, AT_REG_IDX, AT_REG_IDX, 0, tls_index, OWL_RELOC_HALF_LO ); EmitIns( RDTEB_ENCODING ); GenMEMINS( loadOpcodes[I4], RT_RET_REG_IDX, RT_RET_REG_IDX, RDTEB_MAGIC_CONST ); GenOPINS( 0x0010, 0x0002, AT_REG_IDX, RT_RET_REG_IDX, RT_RET_REG_IDX ); @@ -843,7 +841,7 @@ static void Encode( instruction *ins ) assert( ins->operands[1]->n.class == N_CONSTANT ); assert( ins->result->n.class == N_REGISTER ); opcodes = FindOpcodes( ins ); - GenOPIMM8( opcodes[0], opcodes[1], _NameRegIndex( ins->operands[0] ), + GenOPIMM8( opcodes[0], opcodes[1], _NameRegIndex( ins->operands[0] ), (uint_8)ins->operands[1]->c.lo.int_value, _NameRegIndex( ins->result ) ); break; diff --git a/bld/cg/risc/mps/c/mpsenc.c b/bld/cg/risc/mps/c/mpsenc.c index 9bd50aa055..769c0f406f 100644 --- a/bld/cg/risc/mps/c/mpsenc.c +++ b/bld/cg/risc/mps/c/mpsenc.c @@ -193,17 +193,6 @@ static uint_8 FloatingSetOpcodes[] = { 0x34, /* OP_SET_GREATER_EQUAL */ }; -#if 0 -static uint_8 BranchOpcodes[][2] = { - { 0x39, 0x31 }, /* OP_CMP_EQUAL */ - { 0x3d, 0x35 }, /* OP_CMP_NOT_EQUAL */ - { 0x3f, 0x37 }, /* OP_CMP_GREATER */ - { 0x3b, 0x33 }, /* OP_CMP_LESS_EQUAL */ - { 0x3a, 0x32 }, /* OP_CMP_LESS */ - { 0x3e, 0x36 }, /* OP_CMP_GREATER_EQUAL */ -}; -#endif - static uint_8 loadOpcodes[] = { 0x24, /* U1 */ 0x20, /* I1 */ @@ -278,8 +267,8 @@ static void EmitIns( mips_ins ins ) } -void GenLOADS32( int_32 value, uint_8 reg ) -/***************************************************** +void GenLOADS32( int_32 value, reg_idx reg ) +/******************************************* * Load a signed 32-bit constant 'value' into register 'reg' */ { @@ -386,46 +375,46 @@ static uint_8 FindFloatingOpcodes( instruction *ins ) } -static void GenMEMINSRELOC( uint_8 opcode, uint_8 rt, uint_8 rs, int_16 displacement, pointer lbl, owl_reloc_type type ) -/**********************************************************************************************************************/ +static void GenMEMINSRELOC( uint_8 opcode, reg_idx rt, reg_idx rs, int_16 displacement, pointer lbl, owl_reloc_type type ) +/************************************************************************************************************************/ { ins_encoding = _Opcode( opcode ) | _Rt( rt ) | _Rs( rs ) | _SignedImmed( displacement ); EmitInsReloc( &ins_encoding, lbl, type ); } -void GenMEMINS( uint_8 opcode, uint_8 rt, uint_8 rs, int_16 displacement ) -/*********************************************************************************/ +void GenMEMINS( uint_8 opcode, reg_idx rt, reg_idx rs, int_16 displacement ) +/**************************************************************************/ { ins_encoding = _Opcode( opcode ) | _Rt( rt ) | _Rs( rs ) | _SignedImmed( displacement ); EmitIns( ins_encoding ); } -void GenIType( uint_8 opcode, uint_8 rt, uint_8 rs, int_16 immed ) -/***************************************************************************/ +void GenIType( uint_8 opcode, reg_idx rt, reg_idx rs, int_16 immed ) +/******************************************************************/ { ins_encoding = _Opcode( opcode ) | _Rs( rs ) | _Rt( rt ) | _SignedImmed( immed ); EmitIns( ins_encoding ); } -void GenRType( uint_8 opcode, uint_8 fc, uint_8 rd, uint_8 rs, uint_8 rt ) -/********************************************************************************/ +void GenRType( uint_8 opcode, uint_8 fc, reg_idx rd, reg_idx rs, reg_idx rt ) +/***************************************************************************/ { ins_encoding = _Opcode( opcode ) | _Rs( rs ) | _Rt( rt ) | _Rd( rd ) | _Function( fc ); EmitIns( ins_encoding ); } -void GenIShift( uint_8 fc, uint_8 rd, uint_8 rt, uint_8 sa ) -/******************************************************************/ +void GenIShift( uint_8 fc, reg_idx rd, reg_idx rt, uint_8 sa ) +/************************************************************/ { ins_encoding = _Opcode( 0 ) | _Rs( 0 ) | _Rt( rt ) | _Rd( rd ) | _Shift( sa ) | _Function( fc ); EmitIns( ins_encoding ); } void GenJType( uint_8 opcode, pointer label ) -/***************************************************/ +/*******************************************/ { ins_encoding = _Opcode( opcode ); EmitInsReloc( &ins_encoding, label, OWL_RELOC_JUMP_ABS ); @@ -437,8 +426,8 @@ void GenJType( uint_8 opcode, pointer label ) } -static void GenFloatRType( type_class_def type_class, uint_8 fnc, uint_8 fd, uint_8 fs, uint_8 ft ) -/**************************************************************************************************/ +static void GenFloatRType( type_class_def type_class, uint_8 fnc, reg_idx fd, reg_idx fs, reg_idx ft ) +/*****************************************************************************************************/ { int fmt; @@ -579,8 +568,8 @@ static void doCall( instruction *ins ) } -static void addressTemp( name *temp, uint_8 *reg, int_16 *offset ) -/*****************************************************************/ +static void addressTemp( name *temp, reg_idx *reg, int_16 *offset ) +/******************************************************************/ { type_length temp_offset; @@ -606,8 +595,8 @@ static void addressTemp( name *temp, uint_8 *reg, int_16 *offset ) } -static void getMemEncoding( name *mem, uint_8 *regidx_mem, int_16 *offset ) -/*************************************************************************/ +static void getMemEncoding( name *mem, reg_idx *regidx_mem, int_16 *offset ) +/***************************************************************************/ { switch( mem->n.class ) { case N_INDEXED: @@ -637,7 +626,7 @@ static void doLoadStore( instruction *ins, bool load ) name *mem; name *reg; uint_8 opcode; - uint_8 regidx_mem; + reg_idx regidx_mem; int_16 offset; if( load ) { @@ -663,7 +652,7 @@ static void doLoadStoreUnaligned( instruction *ins, bool load ) name *reg; uint_8 opcode1; uint_8 opcode2; - uint_8 regidx_mem; + reg_idx regidx_mem; int_16 offset; if( load ) { @@ -697,8 +686,8 @@ static void doLoadStoreUnaligned( instruction *ins, bool load ) static void GenCallIndirect( instruction *call ) /***********************************************/ { - uint_8 regidx; - uint_8 regidx_mem; + reg_idx regidx; + reg_idx regidx_mem; int_16 mem_offset; name *addr; @@ -844,8 +833,8 @@ static void Encode( instruction *ins ) uint_8 *opcodes; uint_8 opcode; uint_16 function; - uint_8 regidx; - uint_8 regidx_mem; + reg_idx regidx; + reg_idx regidx_mem; int_16 mem_offset; int_16 high; int_16 extra; diff --git a/bld/cg/risc/mps/c/mpsenc2.c b/bld/cg/risc/mps/c/mpsenc2.c index 2996a30ee2..66a81fa85f 100644 --- a/bld/cg/risc/mps/c/mpsenc2.c +++ b/bld/cg/risc/mps/c/mpsenc2.c @@ -59,10 +59,10 @@ void EncodeRet( oc_ret *oc ) } -static void doBranch( mips_ins opcode, uint_8 cc, pointer lbl, uint reg1, uint reg2 ) -/***********************************************************************************/ +static void doBranch( mips_ins opcode, uint_8 cc, pointer lbl, reg_idx rs, reg_idx rt ) +/*************************************************************************************/ { - opcode = _Opcode( opcode ) | _Rs( reg1 ) | _Rt( reg2 ) | _Rt( cc ); + opcode = _Opcode( opcode ) | _Rs( rs ) | _Rt( rt ) | _Rt( cc ); OutReloc( lbl, OWL_RELOC_BRANCH_REL, 0 ); ObjBytes( &opcode, sizeof( opcode ) ); /* @@ -142,13 +142,13 @@ void EncodeCond( oc_jcond *oc ) mips_ins opcode; uint_8 cncode; int floating; - uint reg2; + reg_idx reg2; floating = 0; if( oc->hdr.class & OC_ATTR_FLOAT ) { floating = 1; } - reg2 = oc->index2 == -1 ? 0 : oc->index2; + reg2 = ( oc->index2 == -1 ) ? 0 : (reg_idx)oc->index2; opcode = BranchOpcodes[oc->cond - FIRST_COMPARISON][floating][0]; cncode = BranchOpcodes[oc->cond - FIRST_COMPARISON][floating][1]; /* @@ -165,6 +165,6 @@ void EncodeCond( oc_jcond *oc ) assert( reg2 == ZERO_REG_IDX ); } assert( opcode ); - doBranch( opcode, cncode, oc->handle, oc->index, reg2 ); + doBranch( opcode, cncode, oc->handle, (reg_idx)oc->index, reg2 ); } } diff --git a/bld/cg/risc/mps/h/mpsenc.h b/bld/cg/risc/mps/h/mpsenc.h index 08afe92fdc..f5cabef3bf 100644 --- a/bld/cg/risc/mps/h/mpsenc.h +++ b/bld/cg/risc/mps/h/mpsenc.h @@ -37,11 +37,11 @@ typedef uint_8 reg_idx; extern reg_idx RegIndex( hw_reg_set reg ); -extern void GenCallLabelReg( pointer label, uint reg ); -extern void GenLOADS32( signed_32 value, uint_8 reg ); -extern void GenMEMINS( uint_8 opcode, uint_8 a, uint_8 b, signed_16 displacement ); -extern void GenIType( uint_8 opcode, uint_8 rt, uint_8 rs, signed_16 immed ); -extern void GenRType( uint_8 opcode, uint_8 fc, uint_8 rd, uint_8 rs, uint_8 rt ); -extern void GenIShift( uint_8 fc, uint_8 rd, uint_8 rt, uint_8 sa ); +extern void GenCallLabelReg( pointer label, reg_idx reg ); +extern void GenLOADS32( signed_32 value, reg_idx reg ); +extern void GenMEMINS( uint_8 opcode, reg_idx rt, reg_idx rs, signed_16 displacement ); +extern void GenIType( uint_8 opcode, reg_idx rt, reg_idx rs, signed_16 immed ); +extern void GenRType( uint_8 opcode, uint_8 fc, reg_idx rd, reg_idx rs, reg_idx rt ); +extern void GenIShift( uint_8 fc, reg_idx rd, reg_idx rt, uint_8 sa ); extern void GenJType( uint_8 opcode, pointer label ); extern void GenReturn( void ); From 8fde3b95f2c7a665d89ace82e2e8f7091f229211 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Wed, 4 Oct 2023 21:53:56 +0200 Subject: [PATCH 208/258] correct mistake in prototype --- bld/cg/risc/mps/c/mpsenc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bld/cg/risc/mps/c/mpsenc.c b/bld/cg/risc/mps/c/mpsenc.c index 769c0f406f..4191edaf80 100644 --- a/bld/cg/risc/mps/c/mpsenc.c +++ b/bld/cg/risc/mps/c/mpsenc.c @@ -490,8 +490,8 @@ type_length TempLocation( name *temp ) } -void GenCallLabelReg( pointer label, uint reg ) -/*********************************************/ +void GenCallLabelReg( pointer label, reg_idx reg ) +/************************************************/ { /* * This is used for calling into certain cg support routines. We'd From 9c4b35eab96d0f498f62dd8e237302e852fc9819 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Thu, 5 Oct 2023 04:06:21 +0200 Subject: [PATCH 209/258] add ble, blt, bge and bgt pseudo-instructions to MIPS assembler remove residual ALPHA code --- bld/as/mps/c/mipsfmt.c | 339 ++++++++++++++++++---------------------- bld/as/mps/c/mipsins.c | 13 +- bld/as/mps/h/_mipsfmt.h | 1 + 3 files changed, 160 insertions(+), 193 deletions(-) diff --git a/bld/as/mps/c/mipsfmt.c b/bld/as/mps/c/mipsfmt.c index 44a4341543..e264d98081 100644 --- a/bld/as/mps/c/mipsfmt.c +++ b/bld/as/mps/c/mipsfmt.c @@ -40,8 +40,6 @@ * TODO: kill off all these once the axp residue is gone */ -#define _Memory_disp( x ) ( _SixteenBits( x ) << 0 ) -#define _Mem_Func( x ) ( _SixteenBits( x ) << 0 ) #define _FP_Op_Func( x ) ( _ElevenBits( x ) << 5 ) /* @@ -58,8 +56,12 @@ #define OPCODE_NOP 0x00 #define OPCODE_ADDIU 0x09 +#define OPCODE_ADDU 0x00 +#define FNCCODE_ADDU 0x21 #define OPCODE_ORI 0x0d #define OPCODE_LUI 0x0f +#define OPCODE_SLT 0x00 +#define FNCCODE_SLT 0x2a #define FNCCODE_OR 0x25 #define FNCCODE_JR 0x08 #define FNCCODE_JALR 0x09 @@ -67,8 +69,6 @@ /* * TODO: kill off these macros */ -#define OPCODE_BIS 0x11 -#define FUNCCODE_BIS 0x0020 #define OPCODE_LDA 0x8 #define OPCODE_LDAH 0x9 @@ -267,6 +267,13 @@ static void doOpcodeIType( uint_32 *buffer, ins_opcode opcode, reg_idx rt, reg_i } +static void doOpcodeITypeSa( uint_32 *buffer, ins_opcode opcode, reg_idx rd, reg_idx rt, op_const sa ) +//**************************************************************************************************** +{ + *buffer = _Opcode( opcode ) | _Rd( rd ) | _Rt( rt ) | _Shift( sa ); +} + + static void doOpcodeRType( uint_32 *buffer, ins_opcode opcode, ins_funccode fc, reg_idx rd, reg_idx rs, reg_idx rt ) //****************************************************************************************************************** { @@ -316,42 +323,12 @@ static void doOpcodeFloatRType( type_class_def type, uint_8 fnc, reg_idx fd, reg } #endif -static void doOpcodeRsRt( uint_32 *buffer, ins_opcode opcode, reg_idx rs, reg_idx rt, uint_32 remain ) -//**************************************************************************************************** -{ - *buffer = _Opcode( opcode ) | _Rs( rs ) | _Rt( rt ) | remain; -} - -static void doOpcodeFcRsRt( uint_32 *buffer, ins_opcode opcode, ins_funccode fc, reg_idx ra, reg_idx rc, uint_32 extra ) -/*********************************************************************************************************************** - * This procedure doesn't fill in all the bits (missing bits 20-12). - * But we can fill it in using extra. - */ -{ - *buffer = _Opcode( opcode ) | _Function( fc ) | _Rs( ra ) | _Rt( rc ) | extra; -} - - -static void doOpcodeFcRsRtImm( uint_32 *buffer, ins_opcode opcode, ins_funccode fc, reg_idx rs, reg_idx rt, op_const imm ) -//************************************************************************************************************************ -{ - *buffer = _Opcode( opcode ) | _Function( fc ) | _Rs( rs ) | _Rt( rt ) | _SignedImmed( imm ); -} - - -static void doOpcodeFcRdRtSa( uint_32 *buffer, ins_opcode opcode, ins_funccode fc, reg_idx rd, reg_idx rt, op_const sa ) -//********************************************************************************************************************** -{ - *buffer = _Opcode( opcode ) | _Function( fc ) | _Rd( rd ) | _Rt( rt ) | _Shift( sa ); -} - - -static void doFPInst( uint_32 *buffer, ins_opcode opcode, reg_idx ra, reg_idx rb, reg_idx rc, uint_32 remain ) +static void doFPInst( uint_32 *buffer, ins_opcode opcode, reg_idx rs, reg_idx rt, reg_idx rd, uint_32 remain ) //************************************************************************************************************ { - *buffer = _Opcode( opcode ) | _Rs( ra ) | _Rt( rb ) | - _FP_Op_Func( remain ) | _Rd( rc ); + *buffer = _Opcode( opcode ) | _Rs( rs ) | _Rt( rt ) | + _FP_Op_Func( remain ) | _Rd( rd ); } @@ -367,66 +344,78 @@ static void doAutoVar( asm_reloc *reloc, op_reloc_target targ, uint_32 *buffer, return; } addReloc( reloc, targ, OWL_RELOC_FP_OFFSET, (unsigned)( (char *)buffer - (char *)result ), true ); - doOpcodeRsRt( buffer, table->opcode, FP_REG_IDX, RegIndex( ins->operands[0]->reg ), 0 ); + doOpcodeIType( buffer, table->opcode, RegIndex( ins->operands[0]->reg ), FP_REG_IDX, 0 ); } #endif -static unsigned loadConst32( uint_32 *buffer, reg_idx d_reg, reg_idx s_reg, ins_operand *op, op_const val, asm_reloc *reloc, bool force_pair ) -/********************************************************************************************************************************************* +static unsigned loadConst32( uint_32 *buffer, reg_idx reg_dst, reg_idx reg_src, ins_operand *op, op_const val, asm_reloc *reloc, bool force_pair ) +/************************************************************************************************************************************************* * load sequence for 32-bit constants - * Given: la $d_reg, foobar+c($s_reg) + * Given: la $reg_dst, foobar+c($reg_src) * info for foobar is stored in op * c should be passed in also * Returns # of ins generated */ { - unsigned ret = 1; + ins_opcode opcode; + int reloc_type; - /* unused parameters */ (void)s_reg; + /* unused parameters */ (void)reg_src; if( force_pair ) { assert( reloc != NULL ); if( op->reloc.type != ASM_RELOC_UNSPECIFIED ) { Error( INVALID_RELOC_MODIFIER ); - return( ret ); + return( 0 ); } - } - if( !force_pair - && ( val < 32768 ) - && ( val > -32769 ) ) { - /* - * Only need sign extended low 16 bits - 'addiu rt,$zero,value' - */ - doOpcodeIType( buffer, OPCODE_ADDIU, d_reg, ZERO_REG_IDX, val ); - doReloc( reloc, op, OWL_RELOC_HALF_LO, buffer ); - } else if( !force_pair - && (val & 0xffff0000) == 0 ) { - /* - * Only need high 16 bits - 'lui rt,$zero,(value >> 16)' - */ - doOpcodeIType( buffer, OPCODE_LUI, d_reg, ZERO_REG_IDX, val >> 16 ); - doReloc( reloc, op, OWL_RELOC_HALF_HI, buffer ); } else { - /* - * Need two instructions: 'lui rt,$zero,(value >> 16)' - */ - doOpcodeIType( buffer, OPCODE_LUI, d_reg, ZERO_REG_IDX, val >> 16 ); - doReloc( reloc, op, OWL_RELOC_HALF_HI, buffer ); - ++buffer; - /* - * followed by 'ori rt,rt,(value & 0xffff)' - * or 'addiu' for the 'la' pseudo-ins - */ - if( force_pair ) { - doOpcodeIType( buffer, OPCODE_ADDIU, d_reg, d_reg, val ); - } else { - doOpcodeIType( buffer, OPCODE_ORI, d_reg, d_reg, val ); + reloc_type = 0; + opcode = 0; + if( ( val < 32768 ) + && ( val > -32769 ) ) { + /* + * Only need sign extended low 16 bits - 'addiu rt,$zero,value' + */ + opcode = OPCODE_ADDIU; + reloc_type = OWL_RELOC_HALF_LO; + } else if( (val & 0xffff) == 0 ) { + /* + * Only need high 16 bits - 'lui rt,$zero,(value >> 16)' + */ + val >>= 16; + opcode = OPCODE_LUI; + reloc_type = OWL_RELOC_HALF_HI; + } else if( (val & 0xffff0000) == 0 ) { + /* + * Only need low 16 bits - 'ori rt,$zero,value' + */ + opcode = OPCODE_ORI; + reloc_type = OWL_RELOC_HALF_LO; + } + if( reloc_type != 0 ) { + doOpcodeIType( buffer, opcode, reg_dst, ZERO_REG_IDX, val ); + if( reloc != NULL ) + doReloc( reloc, op, OWL_RELOC_HALF_HI, buffer ); + return( 1 ); } - doReloc( reloc, op, OWL_RELOC_HALF_LO, buffer ); - ++ret; } - return( ret ); + /* + * Need two instructions: 'lui rt,$zero,(value >> 16)' (high word) + */ + doOpcodeIType( buffer, OPCODE_LUI, reg_dst, ZERO_REG_IDX, val >> 16 ); + if( reloc != NULL ) + doReloc( reloc, op, OWL_RELOC_HALF_HI, buffer ); + ++buffer; + /* + * followed by 'ori rt,rt,(value & 0xffff)' (low word) + * or 'addiu' for the 'la' pseudo-ins + */ + opcode = ( force_pair ) ? OPCODE_ADDIU : OPCODE_ORI; + doOpcodeIType( buffer, opcode, reg_dst, reg_dst, val ); + if( reloc != NULL ) + doReloc( reloc, op, OWL_RELOC_HALF_LO, buffer ); + return( 2 ); } @@ -440,8 +429,7 @@ static unsigned load32BitLiteral( uint_32 *buffer, ins_operand *op0, ins_operand } else { val = op0->constant; } - return( loadConst32( buffer, RegIndex( op1->reg ), ZERO_REG_IDX, - op0, val, NULL, false ) ); + return( loadConst32( buffer, RegIndex( op1->reg ), ZERO_REG_IDX, NULL, val, NULL, false ) ); } @@ -450,28 +438,12 @@ static void doMov( uint_32 *buffer, ins_operand *operands[], domov_option m_opt { ins_operand *op0; ins_operand *op1; - uint_32 extra; op0 = operands[0]; op1 = operands[1]; if( op0->type == OP_GPR ) { - extra = _Rt( RegIndex( op0->reg ) ); - doOpcodeFcRsRt( buffer, OPCODE_BIS, FUNCCODE_BIS, ZERO_REG_IDX, RegIndex( op1->reg ), extra ); - } else if( ( op0->constant & 0xff ) == op0->constant ) { // OP_IMMED implied - extra = _LIT( op0->constant ); // this lit is between 0..255 - checkOpAbsolute( op0, 0 ); - doOpcodeFcRsRt( buffer, OPCODE_BIS, FUNCCODE_BIS, ZERO_REG_IDX, RegIndex( op1->reg ), extra ); - } else if( ( -op0->constant & 0xff ) == -op0->constant && m_opt == DOMOV_ABS ) { // -255..0 - extra = _LIT( -op0->constant ); // this lit is between 0..255 - /* - * checkOpAbsolute( op0, 0 ); should be done before calling doMov - */ - doOpcodeFcRsRt( buffer, OPCODE_BIS, FUNCCODE_BIS, ZERO_REG_IDX, RegIndex( op1->reg ), extra ); + doOpcodeRType( buffer, OPCODE_ADDU, FNCCODE_ADDU, RegIndex( op1->reg ), ZERO_REG_IDX, RegIndex( op0->reg ) ); } else { - /* - * Otherwise it's OP_IMMED with a greater than 8-bit literal. - * We'll then use multiple LDA, LDAH instructions to load the literal. - */ if( checkOpAbsolute( op0, 0 ) ) { numExtendedIns += load32BitLiteral( buffer, op0, op1, m_opt ) - 1; } @@ -493,29 +465,7 @@ static void doLoadImm( uint_32 *buffer, ins_operand *operands[] ) checkOpAbsolute( op1, 1 ); reg = RegIndex( op0->reg ); value = op1->constant; - - if( (value < 32768) && (value > -32769) ) { - /* - * Only need sign extended low 16 bits - 'addiu rt,$zero,value' - */ - doOpcodeIType( buffer, OPCODE_ADDIU, reg, ZERO_REG_IDX, value ); - } else if( (value & 0xffff) == 0 ) { - /* - * Only need high 16 bits - 'lui rt,$zero,(value >> 16)' - */ - doOpcodeIType( buffer, OPCODE_LUI, reg, ZERO_REG_IDX, value >> 16 ); - } else { - /* - * Need two instructions: 'lui rt,$zero,(value >> 16)' - */ - doOpcodeIType( buffer, OPCODE_LUI, reg, ZERO_REG_IDX, value >> 16 ); - /* - * followed by 'ori rt,$zero,(value & 0xffff)' - */ - ++buffer; - doOpcodeIType( buffer, OPCODE_ORI, reg, ZERO_REG_IDX, value ); - ++numExtendedIns; - } + numExtendedIns += loadConst32( buffer, reg, ZERO_REG_IDX, NULL, value, NULL, false ) - 1; } @@ -618,7 +568,7 @@ static void ITMemAll( ins_table *table, instruction *ins, uint_32 *buffer, asm_r } #endif opcode = table->opcode; - doOpcodeRsRt( buffer, opcode, RegIndex( op->reg ), RegIndex( ins->operands[0]->reg ), _Memory_disp( op->constant ) ); + doOpcodeIType( buffer, opcode, RegIndex( ins->operands[0]->reg ), RegIndex( op->reg ), op->constant ); type = ( opcode == OPCODE_LDAH ) ? OWL_RELOC_HALF_HI : OWL_RELOC_HALF_LO; doReloc( reloc, op, type, buffer ); } @@ -630,7 +580,7 @@ static void ITMemA( ins_table *table, instruction *ins, uint_32 *buffer, asm_rel /* unused parameters */ (void)reloc; assert( ins->num_operands == 1 ); - doOpcodeRsRt( buffer, table->opcode, RegIndex( ins->operands[0]->reg ), ZERO_REG_IDX, _Mem_Func( table->funccode ) ); + doOpcodeIType( buffer, table->opcode, ZERO_REG_IDX, RegIndex( ins->operands[0]->reg ), table->funccode ); } @@ -640,11 +590,11 @@ static void ITMemB( ins_table *table, instruction *ins, uint_32 *buffer, asm_rel /* unused parameters */ (void)reloc; assert( ins->num_operands == 1 ); - doOpcodeRsRt( buffer, table->opcode, ZERO_REG_IDX, RegIndex( ins->operands[0]->reg ), _Mem_Func( table->funccode ) ); + doOpcodeIType( buffer, table->opcode, RegIndex( ins->operands[0]->reg ), ZERO_REG_IDX, table->funccode ); } -static void doMemJump( uint_32 *buffer, ins_table *table, reg_idx ra, reg_idx rb, ins_operand *addr_op, int_32 hint, asm_reloc *reloc ) +static void doMemJump( uint_32 *buffer, ins_table *table, reg_idx rs, reg_idx rt, ins_operand *addr_op, int_32 hint, asm_reloc *reloc ) //************************************************************************************************************************************* { /* @@ -652,7 +602,7 @@ static void doMemJump( uint_32 *buffer, ins_table *table, reg_idx ra, reg_idx rb */ assert( addr_op == NULL || addr_op->constant == hint ); assert( addr_op == NULL || addr_op->type == OP_IMMED ); - doOpcodeRsRt( buffer, table->opcode, ra, rb, (table->funccode << 14) | _FourteenBits( hint ) ); + doOpcodeIType( buffer, table->opcode, rt, rs, (table->funccode << 14) | _FourteenBits( hint ) ); doReloc( reloc, addr_op, OWL_RELOC_JUMP_REL, buffer ); } @@ -773,26 +723,26 @@ static void stdMemJump( ins_table *table, instruction *ins, uint_32 *buffer, asm static void ITRegJump( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) //******************************************************************************************** { - reg_idx targ_reg_idx; - reg_idx retn_reg_idx; + reg_idx reg_targ; + reg_idx reg_retn; /* unused parameters */ (void)reloc; assert( ins->num_operands < 3 ); if( ins->num_operands == 2 ) { - targ_reg_idx = RegIndex( ins->operands[1]->reg ); - retn_reg_idx = RegIndex( ins->operands[0]->reg ); + reg_targ = RegIndex( ins->operands[1]->reg ); + reg_retn = RegIndex( ins->operands[0]->reg ); } else { - targ_reg_idx = RegIndex( ins->operands[0]->reg ); + reg_targ = RegIndex( ins->operands[0]->reg ); if( table->funccode & 1 ) { - retn_reg_idx = RA_REG_IDX; // jalr + reg_retn = RA_REG_IDX; // jalr } else { - retn_reg_idx = 0; // jr + reg_retn = 0; // jr } } doOpcodeRType( buffer, table->opcode, table->funccode, - retn_reg_idx, - targ_reg_idx, + reg_retn, + reg_targ, 0 ); numExtendedIns += doDelaySlotNOP( buffer ); @@ -893,7 +843,7 @@ static void ITRet( ins_table *table, instruction *ins, uint_32 *buffer, asm_relo { ins_operand *op0, *op1; int num_op; - reg_idx d_reg_idx; // default d_reg if not specified + reg_idx reg_def; // default reg_def if not specified num_op = ins->num_operands; /* @@ -909,10 +859,10 @@ static void ITRet( ins_table *table, instruction *ins, uint_32 *buffer, asm_relo /* * This is according to the MS asaxp documentation. */ - d_reg_idx = RA_REG_IDX; + reg_def = RA_REG_IDX; } else { assert( table->funccode == 0x0002 ); // ret - d_reg_idx = ZERO_REG_IDX; // $zero + reg_def = ZERO_REG_IDX; // $zero } if( num_op == 2 ) { if( (op0 = ins->operands[0])->type == OP_GPR ) { @@ -929,7 +879,7 @@ static void ITRet( ins_table *table, instruction *ins, uint_32 *buffer, asm_relo assert( op0->type == OP_REG_INDIRECT ); op1 = ins->operands[1]; assert( op1->type == OP_IMMED ); - doMemJump( buffer, table, d_reg_idx, RegIndex( op0->reg ), + doMemJump( buffer, table, reg_def, RegIndex( op0->reg ), op1, op1->constant, reloc ); return; } @@ -940,12 +890,12 @@ static void ITRet( ins_table *table, instruction *ins, uint_32 *buffer, asm_relo return; } assert( op0->type == OP_IMMED ); - doMemJump( buffer, table, d_reg_idx, RA_REG_IDX, + doMemJump( buffer, table, reg_def, RA_REG_IDX, op0, op0->constant, reloc ); return; } assert( num_op == 0 ); - doMemJump( buffer, table, d_reg_idx, RA_REG_IDX, NULL, 1, reloc ); + doMemJump( buffer, table, reg_def, RA_REG_IDX, NULL, 1, reloc ); } @@ -955,7 +905,7 @@ static void ITMemNone( ins_table *table, instruction *ins, uint_32 *buffer, asm_ /* unused parameters */ (void)reloc; (void)ins; assert( ins->num_operands == 0 ); - doOpcodeRsRt( buffer, table->opcode, ZERO_REG_IDX, ZERO_REG_IDX, _Mem_Func( table->funccode ) ); + doOpcodeIType( buffer, table->opcode, ZERO_REG_IDX, ZERO_REG_IDX, table->funccode ); } @@ -966,8 +916,8 @@ static void ITBranch( ins_table *table, instruction *ins, uint_32 *buffer, asm_r assert( ins->num_operands == 2 ); op = ins->operands[1]; - doOpcodeRsRt( buffer, table->opcode, RegIndex( ins->operands[0]->reg ), 0, - _SignedImmed( _Longword_offset( op->constant ) ) ); + doOpcodeIType( buffer, table->opcode, 0, RegIndex( ins->operands[0]->reg ), + _Longword_offset( op->constant ) ); doReloc( reloc, op, OWL_RELOC_BRANCH_REL, buffer ); numExtendedIns += doDelaySlotNOP( buffer ); } @@ -982,7 +932,7 @@ static void ITBranchTwo( ins_table *table, instruction *ins, uint_32 *buffer, as op = ins->operands[2]; doOpcodeIType( buffer, table->opcode, RegIndex( ins->operands[1]->reg ), RegIndex( ins->operands[0]->reg ), - _SignedImmed( _Longword_offset( op->constant ) ) ); + _Longword_offset( op->constant ) ); doReloc( reloc, op, OWL_RELOC_BRANCH_REL, buffer ); numExtendedIns += doDelaySlotNOP( buffer ); } @@ -997,7 +947,7 @@ static void ITBranchZero( ins_table *table, instruction *ins, uint_32 *buffer, a op = ins->operands[1]; doOpcodeIType( buffer, table->opcode, (reg_idx)table->funccode, RegIndex( ins->operands[0]->reg ), - _SignedImmed( _Longword_offset( op->constant ) ) ); + _Longword_offset( op->constant ) ); doReloc( reloc, op, OWL_RELOC_BRANCH_REL, buffer ); numExtendedIns += doDelaySlotNOP( buffer ); } @@ -1013,7 +963,7 @@ static void ITBranchCop( ins_table *table, instruction *ins, uint_32 *buffer, as opcode = cop_codes[table->opcode >> 8]; op = ins->operands[0]; doOpcodeIType( buffer, opcode, (reg_idx)table->funccode, table->opcode & 0xff, - _SignedImmed( _Longword_offset( op->constant ) ) ); + _Longword_offset( op->constant ) ); doReloc( reloc, op, OWL_RELOC_BRANCH_REL, buffer ); numExtendedIns += doDelaySlotNOP( buffer ); } @@ -1107,9 +1057,9 @@ static void ITOperateImm( ins_table *table, instruction *ins, uint_32 *buffer, a assert( ins->num_operands == 3 ); op = ins->operands[2]; checkOpAbsolute( op, 2 ); - doOpcodeFcRsRtImm( buffer, table->opcode, table->funccode, - RegIndex( ins->operands[1]->reg ), - RegIndex( ins->operands[0]->reg ), op->constant ); + doOpcodeIType( buffer, table->opcode, + RegIndex( ins->operands[0]->reg ), RegIndex( ins->operands[1]->reg ), + op->constant ); } @@ -1122,7 +1072,7 @@ static void ITShiftImm( ins_table *table, instruction *ins, uint_32 *buffer, asm assert( ins->num_operands == 3 ); op = ins->operands[2]; - doOpcodeFcRdRtSa( buffer, table->opcode, table->funccode, + doOpcodeITypeSa( buffer, table->opcode, RegIndex( ins->operands[0]->reg ), RegIndex( ins->operands[1]->reg ), op->constant ); } @@ -1168,8 +1118,8 @@ static void ITBr( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc Error( IMPROPER_OPERAND, 0 ); return; } - doOpcodeRsRt( buffer, table->opcode, ZERO_REG_IDX, 0, - _SignedImmed( _Longword_offset( op0->constant ) ) ); + doOpcodeIType( buffer, table->opcode, 0, ZERO_REG_IDX, + _Longword_offset( op0->constant ) ); doReloc( reloc, op0, OWL_RELOC_BRANCH_REL, buffer ); return; } @@ -1210,8 +1160,7 @@ static void ITPseudoClr( ins_table *table, instruction *ins, uint_32 *buffer, as /* unused parameters */ (void)reloc; assert( ins->num_operands == 1 ); - doOpcodeFcRsRt( buffer, table->opcode, table->funccode, ZERO_REG_IDX, - RegIndex( ins->operands[0]->reg ), _Rd( ZERO_REG_IDX ) ); + doOpcodeRType( buffer, table->opcode, table->funccode, RegIndex( ins->operands[0]->reg ), ZERO_REG_IDX, ZERO_REG_IDX ); } @@ -1243,7 +1192,7 @@ static void ITPseudoLAddr( ins_table *table, instruction *ins, uint_32 *buffer, ins_operand *ops[2]; unsigned inc; // op_const val; - reg_idx s_reg; + reg_idx reg_src; /* unused parameters */ (void)table; @@ -1258,8 +1207,8 @@ static void ITPseudoLAddr( ins_table *table, instruction *ins, uint_32 *buffer, } assert( op->type == OP_REG_INDIRECT ); // val = op->constant; - s_reg = RegIndex( op->reg ); - if( !OP_HAS_RELOC( op ) && s_reg == ZERO_REG_IDX ) { + reg_src = RegIndex( op->reg ); + if( !OP_HAS_RELOC( op ) && reg_src == ZERO_REG_IDX ) { /* * doMov() can only be called when op->reg is ZERO_REG and no reloc */ @@ -1285,12 +1234,12 @@ static void ITPseudoLAddr( ins_table *table, instruction *ins, uint_32 *buffer, * We should emit lui/addiu pair. */ inc = loadConst32( buffer, RegIndex( ins->operands[0]->reg ), - s_reg, op, op->constant, reloc, true ); + reg_src, op, op->constant, reloc, true ); numExtendedIns += inc - 1; return; } } - inc = loadConst32( buffer, RegIndex( ins->operands[0]->reg ), s_reg, op, + inc = loadConst32( buffer, RegIndex( ins->operands[0]->reg ), reg_src, op, op->constant, reloc, false ); numExtendedIns += inc - 1; } @@ -1328,22 +1277,13 @@ static void ITPseudoNot( ins_table *table, instruction *ins, uint_32 *buffer, as { ins_funccode fc; ins_operand *op; - uint_32 extra; /* unused parameters */ (void)reloc; assert( ins->num_operands == 2 ); - op = ins->operands[0]; - if( op->type == OP_GPR ) { - extra = _Rt( RegIndex( op->reg ) ); - } else { // OP_IMMED - assert( op->type == OP_IMMED ); - extra = _LIT( op->constant ); - (void)checkOpAbsolute( op, 0 ); - } fc = getFuncCode( table, ins ); - doOpcodeFcRsRt( buffer, table->opcode, fc, ZERO_REG_IDX, - RegIndex( ins->operands[1]->reg ), extra ); + op = ins->operands[0]; + doOpcodeRType( buffer, table->opcode, fc, RegIndex( ins->operands[1]->reg ), ZERO_REG_IDX, RegIndex( op->reg ) ); } @@ -1378,9 +1318,9 @@ static void ITPseudoFneg( ins_table *table, instruction *ins, uint_32 *buffer, a static void ITPseudoAbs( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) //********************************************************************************************** { - reg_idx s_reg_idx; - reg_idx d_reg_idx; - reg_idx rc_reg_idx; + reg_idx reg_src; + reg_idx reg_dst; + reg_idx reg_rc; ins_operand *src_op; bool same_reg; @@ -1391,7 +1331,7 @@ static void ITPseudoAbs( ins_table *table, instruction *ins, uint_32 *buffer, as if( src_op->type == OP_IMMED ) { /* * Then just evaluate it and do a mov instead. - * mov abs(src_op->constant), d_reg + * mov abs(src_op->constant), reg_dst */ if( checkOpAbsolute( src_op, 0 ) ) { doMov( buffer, ins->operands, DOMOV_ABS ); @@ -1400,15 +1340,15 @@ static void ITPseudoAbs( ins_table *table, instruction *ins, uint_32 *buffer, as } assert( src_op->type == OP_GPR ); /* Emit an instruction sequence like: - * 1. subq/v $zero, $s_reg, $at // if( $s_reg == $d_reg ) - * 2. cmovlt $s_reg, $at, $s_reg + * 1. subq/v $zero, $reg_src, $at // if( $reg_src == $reg_dst ) + * 2. cmovlt $reg_src, $at, $reg_src * ---or--- - * 1. subq/v $zero, $s_reg, $d_reg // if( $s_reg != $d_reg ) - * 2. cmovgt $s_reg, $s_reg, $d_reg + * 1. subq/v $zero, $reg_src, $reg_dst // if( $reg_src != $reg_dst ) + * 2. cmovgt $reg_src, $reg_src, $reg_dst */ - s_reg_idx = RegIndex( src_op->reg ); - d_reg_idx = RegIndex( ins->operands[1]->reg ); - same_reg = ( s_reg_idx == d_reg_idx ); + reg_src = RegIndex( src_op->reg ); + reg_dst = RegIndex( ins->operands[1]->reg ); + same_reg = ( reg_src == reg_dst ); if( same_reg ) { /* * Then $at reg will be needed. @@ -1416,11 +1356,11 @@ static void ITPseudoAbs( ins_table *table, instruction *ins, uint_32 *buffer, as if( !_DirIsSet( AT ) ) { Warning( INS_USES_AT_REG ); } - rc_reg_idx = AT_REG_IDX; + reg_rc = AT_REG_IDX; } else { - rc_reg_idx = d_reg_idx; + reg_rc = reg_dst; } - doOpcodeFcRsRt( buffer, table->opcode, table->funccode, ZERO_REG_IDX, rc_reg_idx, _Rt( s_reg_idx ) ); + doOpcodeRType( buffer, table->opcode, table->funccode, reg_rc, ZERO_REG_IDX, reg_src ); /* * So buffer gets ins #1. Now do ins #2. */ @@ -1430,18 +1370,39 @@ static void ITPseudoAbs( ins_table *table, instruction *ins, uint_32 *buffer, as #define FUNCCODE_CMOVGT 0x0066 #define FUNCCODE_CMOVLT 0x0044 if( same_reg ) { - doOpcodeFcRsRt( buffer, OPCODE_CMOVLT, - FUNCCODE_CMOVLT, s_reg_idx, s_reg_idx, - _Rt( AT_REG_IDX ) ); + doOpcodeRType( buffer, OPCODE_CMOVLT, FUNCCODE_CMOVLT, reg_src, reg_src, AT_REG_IDX ); } else { - doOpcodeFcRsRt( buffer, OPCODE_CMOVGT, - FUNCCODE_CMOVGT, s_reg_idx, d_reg_idx, - _Rt( s_reg_idx ) ); + doOpcodeRType( buffer, OPCODE_CMOVGT, FUNCCODE_CMOVGT, reg_dst, reg_src, reg_src ); } ++numExtendedIns; } +static void ITPseudoBranch2( ins_table *table, instruction *ins, uint_32 *buffer, asm_reloc *reloc ) +//************************************************************************************************** +{ + ins_operand *op; + int i1; + int i2; + + assert( ins->num_operands == 3 ); + op = ins->operands[2]; + i1 = 0; + i2 = 1; + if( table->funccode ) { + i1 = 1; + i2 = 0; + } + doOpcodeRType( buffer, OPCODE_SLT, FNCCODE_SLT, AT_REG_IDX, RegIndex( ins->operands[i1]->reg ), RegIndex( ins->operands[i2]->reg ) ); + ++buffer; + numExtendedIns++; + doOpcodeIType( buffer, table->opcode, ZERO_REG_IDX, AT_REG_IDX, + _Longword_offset( op->constant ) ); + doReloc( reloc, op, OWL_RELOC_BRANCH_REL, buffer ); + numExtendedIns += doDelaySlotNOP( buffer ); +} + + mips_format MIPSFormatTable[] = { #define PICK( a, b, c, d, e ) { b, { c, d, e } }, #include "_mipsfmt.h" diff --git a/bld/as/mps/c/mipsins.c b/bld/as/mps/c/mipsins.c index a1f4725550..beaa91767f 100644 --- a/bld/as/mps/c/mipsins.c +++ b/bld/as/mps/c/mipsins.c @@ -112,10 +112,10 @@ ins_table MIPSTable[] = { INS( "br", 0x30, 0x00, IT_BR, ENUM_NONE, MIPS_ISA1 ), INS( "fbeq", 0x31, 0x00, IT_FP_BRANCH, ENUM_NONE, MIPS_ISA1 ), - INS( "blt", 0x3A, 0x00, IT_BRANCH, ENUM_NONE, MIPS_ISA1 ), - INS( "ble", 0x3B, 0x00, IT_BRANCH, ENUM_NONE, MIPS_ISA1 ), - INS( "bge", 0x3E, 0x00, IT_BRANCH, ENUM_NONE, MIPS_ISA1 ), - INS( "bgt", 0x3F, 0x00, IT_BRANCH, ENUM_NONE, MIPS_ISA1 ), +// INS( "blt", 0x3A, 0x00, IT_BRANCH, ENUM_NONE, MIPS_ISA1 ), +// INS( "ble", 0x3B, 0x00, IT_BRANCH, ENUM_NONE, MIPS_ISA1 ), +// INS( "bge", 0x3E, 0x00, IT_BRANCH, ENUM_NONE, MIPS_ISA1 ), +// INS( "bgt", 0x3F, 0x00, IT_BRANCH, ENUM_NONE, MIPS_ISA1 ), // Coprocessor branch instructions; high byte of opcode is coprocessor number INS( "bc0f", 0x008, 0x00, IT_BRANCH_COP, ENUM_NONE, MIPS_ISA1 ), INS( "bc0fl", 0x008, 0x02, IT_BRANCH_COP, ENUM_NONE, MIPS_ISA2 ), @@ -257,6 +257,11 @@ ins_table MIPSTable[] = { // abs pseudo ins (opcode & funccode are from subl/v, subq/v) INS( "absl", 0x10, 0x49, IT_PSEUDO_ABS, ENUM_NONE, MIPS_ISA1 ), INS( "absq", 0x10, 0x69, IT_PSEUDO_ABS, ENUM_NONE, MIPS_ISA1 ), + + INS( "blt", 0x05, 0x00, IT_PSEUDO_BRANCH2, ENUM_NONE, MIPS_ISA1 ), + INS( "ble", 0x04, 0x01, IT_PSEUDO_BRANCH2, ENUM_NONE, MIPS_ISA1 ), + INS( "bge", 0x04, 0x00, IT_PSEUDO_BRANCH2, ENUM_NONE, MIPS_ISA1 ), + INS( "bgt", 0x05, 0x01, IT_PSEUDO_BRANCH2, ENUM_NONE, MIPS_ISA1 ), }; static bool insErrFlag = false; // to tell whether we had problems or not diff --git a/bld/as/mps/h/_mipsfmt.h b/bld/as/mps/h/_mipsfmt.h index 2c9a0a7cdc..b84038ccdb 100644 --- a/bld/as/mps/h/_mipsfmt.h +++ b/bld/as/mps/h/_mipsfmt.h @@ -70,3 +70,4 @@ PICK( IT_PSEUDO_NOT, ITPseudoNot, OP_GPR, (OP_GPR | OP_IMMED), OP_NOTHING PICK( IT_PSEUDO_NEGF, ITPseudoNegf, OP_FPR, OP_FPR, OP_NOTHING ) /* negf */ PICK( IT_PSEUDO_FNEG, ITPseudoFneg, OP_FPR, OP_FPR, OP_NOTHING ) /* fneg */ PICK( IT_PSEUDO_ABS, ITPseudoAbs, (OP_GPR | OP_IMMED), OP_GPR, OP_NOTHING ) /* absl */ +PICK( IT_PSEUDO_BRANCH2, ITPseudoBranch2, OP_GPR, OP_GPR, OP_IMMED ) /* beq */ From bea6f1dad6301b085e2dc2353ed899be1cd8417f Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Thu, 5 Oct 2023 18:27:09 +0200 Subject: [PATCH 210/258] correct mistake in mips relocation info processing --- bld/as/mps/c/mipsfmt.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bld/as/mps/c/mipsfmt.c b/bld/as/mps/c/mipsfmt.c index e264d98081..2e0c56653e 100644 --- a/bld/as/mps/c/mipsfmt.c +++ b/bld/as/mps/c/mipsfmt.c @@ -396,7 +396,7 @@ static unsigned loadConst32( uint_32 *buffer, reg_idx reg_dst, reg_idx reg_src, if( reloc_type != 0 ) { doOpcodeIType( buffer, opcode, reg_dst, ZERO_REG_IDX, val ); if( reloc != NULL ) - doReloc( reloc, op, OWL_RELOC_HALF_HI, buffer ); + doReloc( reloc, op, reloc_type, buffer ); return( 1 ); } } @@ -505,9 +505,9 @@ static void ITTrap( ins_table *table, instruction *ins, uint_32 *buffer, asm_rel code = 0; } *buffer = _Opcode( table->opcode ) | - _Rs( RegIndex( ins->operands[0]->reg ) ) | - _Rt( RegIndex( ins->operands[1]->reg ) ) | - _TrapCode( code ) | _Function( table->funccode ); + _Rs( RegIndex( ins->operands[0]->reg ) ) | + _Rt( RegIndex( ins->operands[1]->reg ) ) | + _TrapCode( code ) | _Function( table->funccode ); } From a646ff63c4edd6ff44952bf4dce45df7c7469e15 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Thu, 5 Oct 2023 20:08:50 +0200 Subject: [PATCH 211/258] separate id and name of processor registers --- bld/cg/intel/c/x86dfsup.c | 88 ++++++++++++++++++------------------ bld/cg/risc/axp/c/axpdfsup.c | 8 ++-- bld/cg/risc/mps/c/mpsdfsup.c | 8 ++-- bld/cg/risc/ppc/c/ppcdfsup.c | 8 ++-- bld/dip/dwarf/c/dfloc.c | 26 +++++------ 5 files changed, 69 insertions(+), 69 deletions(-) diff --git a/bld/cg/intel/c/x86dfsup.c b/bld/cg/intel/c/x86dfsup.c index 1c9706be7a..369e54eb3e 100644 --- a/bld/cg/intel/c/x86dfsup.c +++ b/bld/cg/intel/c/x86dfsup.c @@ -56,9 +56,9 @@ typedef enum { - #define DW_REG(name,ci,start,len) DW_REG_##name, + #define pick(id,name,ci,start,len) DW_REG_ ## id, #include "dwregx86.h" - #undef DW_REG + #undef pick DW_REG_MAX } dw_regs; @@ -85,44 +85,44 @@ static struct dbg_seg_names DwarfSegNames[DW_DEBUG_MAX] = { }; static struct reg_map HWRegValues[] = { - { HW_D( HW_AL ), DW_REG_al }, - { HW_D( HW_AH ), DW_REG_ah }, - { HW_D( HW_BL ), DW_REG_bl }, - { HW_D( HW_BH ), DW_REG_bh }, - { HW_D( HW_CL ), DW_REG_cl }, - { HW_D( HW_CH ), DW_REG_ch }, - { HW_D( HW_DL ), DW_REG_dl }, - { HW_D( HW_DH ), DW_REG_dh }, - { HW_D( HW_AX ), DW_REG_ax }, - { HW_D( HW_BX ), DW_REG_bx }, - { HW_D( HW_CX ), DW_REG_cx }, - { HW_D( HW_DX ), DW_REG_dx }, - { HW_D( HW_SI ), DW_REG_si }, - { HW_D( HW_DI ), DW_REG_di }, - { HW_D( HW_BP ), DW_REG_bp }, - { HW_D( HW_SP ), DW_REG_sp }, - { HW_D( HW_CS ), DW_REG_cs }, - { HW_D( HW_SS ), DW_REG_ss }, - { HW_D( HW_DS ), DW_REG_ds }, - { HW_D( HW_ES ), DW_REG_es }, - { HW_D( HW_ST0 ), DW_REG_st0 }, - { HW_D( HW_ST1 ), DW_REG_st1 }, - { HW_D( HW_ST2 ), DW_REG_st2 }, - { HW_D( HW_ST3 ), DW_REG_st3 }, - { HW_D( HW_ST4 ), DW_REG_st4 }, - { HW_D( HW_ST5 ), DW_REG_st5 }, - { HW_D( HW_ST6 ), DW_REG_st6 }, - { HW_D( HW_ST7 ), DW_REG_st7 }, - { HW_D( HW_EAX ), DW_REG_eax }, - { HW_D( HW_EBX ), DW_REG_ebx }, - { HW_D( HW_ECX ), DW_REG_ecx }, - { HW_D( HW_EDX ), DW_REG_edx }, - { HW_D( HW_ESI ), DW_REG_esi }, - { HW_D( HW_EDI ), DW_REG_edi }, - { HW_D( HW_EBP ), DW_REG_ebp }, - { HW_D( HW_ESP ), DW_REG_esp }, - { HW_D( HW_FS ), DW_REG_fs }, - { HW_D( HW_GS ), DW_REG_gs } + { HW_D( HW_AL ), DW_REG_AL }, + { HW_D( HW_AH ), DW_REG_AH }, + { HW_D( HW_BL ), DW_REG_BL }, + { HW_D( HW_BH ), DW_REG_BH }, + { HW_D( HW_CL ), DW_REG_CL }, + { HW_D( HW_CH ), DW_REG_CH }, + { HW_D( HW_DL ), DW_REG_DL }, + { HW_D( HW_DH ), DW_REG_DH }, + { HW_D( HW_AX ), DW_REG_AX }, + { HW_D( HW_BX ), DW_REG_BX }, + { HW_D( HW_CX ), DW_REG_CX }, + { HW_D( HW_DX ), DW_REG_DX }, + { HW_D( HW_SI ), DW_REG_SI }, + { HW_D( HW_DI ), DW_REG_DI }, + { HW_D( HW_BP ), DW_REG_BP }, + { HW_D( HW_SP ), DW_REG_SP }, + { HW_D( HW_CS ), DW_REG_CS }, + { HW_D( HW_SS ), DW_REG_SS }, + { HW_D( HW_DS ), DW_REG_DS }, + { HW_D( HW_ES ), DW_REG_ES }, + { HW_D( HW_ST0 ), DW_REG_ST0 }, + { HW_D( HW_ST1 ), DW_REG_ST1 }, + { HW_D( HW_ST2 ), DW_REG_ST2 }, + { HW_D( HW_ST3 ), DW_REG_ST3 }, + { HW_D( HW_ST4 ), DW_REG_ST4 }, + { HW_D( HW_ST5 ), DW_REG_ST5 }, + { HW_D( HW_ST6 ), DW_REG_ST6 }, + { HW_D( HW_ST7 ), DW_REG_ST7 }, + { HW_D( HW_EAX ), DW_REG_EAX }, + { HW_D( HW_EBX ), DW_REG_EBX }, + { HW_D( HW_ECX ), DW_REG_ECX }, + { HW_D( HW_EDX ), DW_REG_EDX }, + { HW_D( HW_ESI ), DW_REG_ESI }, + { HW_D( HW_EDI ), DW_REG_EDI }, + { HW_D( HW_EBP ), DW_REG_EBP }, + { HW_D( HW_ESP ), DW_REG_ESP }, + { HW_D( HW_FS ), DW_REG_FS }, + { HW_D( HW_GS ), DW_REG_GS } }; @@ -165,13 +165,13 @@ void DFOutReg( dw_loc_id locid, name *reg ) hw_reg = reg->r.reg; #if _TARGET & _TARG_8086 if( HW_CEqual( hw_reg, HW_ABCD ) ) { - DWLocReg( Client, locid, DW_REG_dx ); + DWLocReg( Client, locid, DW_REG_DX ); DWLocPiece( Client, locid, WD ); - DWLocReg( Client, locid, DW_REG_cx ); + DWLocReg( Client, locid, DW_REG_CX ); DWLocPiece( Client, locid, WD ); - DWLocReg( Client, locid, DW_REG_bx ); + DWLocReg( Client, locid, DW_REG_BX ); DWLocPiece( Client, locid, WD ); - DWLocReg( Client, locid, DW_REG_ax ); + DWLocReg( Client, locid, DW_REG_AX ); DWLocPiece( Client, locid, WD ); return; } diff --git a/bld/cg/risc/axp/c/axpdfsup.c b/bld/cg/risc/axp/c/axpdfsup.c index 76fa5418ee..e76c27996f 100644 --- a/bld/cg/risc/axp/c/axpdfsup.c +++ b/bld/cg/risc/axp/c/axpdfsup.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2018 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -55,10 +55,10 @@ #define MapReg2DW(r) ((dw_regs)r) typedef enum { - #define DW_REG( __n ) DW_AXP_##__n, + #define pick(id,name) DW_REG_ ## id, #include "dwregaxp.h" - DW_REG( MAX ) - #undef DW_REG + #undef pick + DW_REG_MAX } dw_regs; static dw_regs DFRegMap( hw_reg_set hw_reg ) diff --git a/bld/cg/risc/mps/c/mpsdfsup.c b/bld/cg/risc/mps/c/mpsdfsup.c index 98dbc5559f..7d483b3496 100644 --- a/bld/cg/risc/mps/c/mpsdfsup.c +++ b/bld/cg/risc/mps/c/mpsdfsup.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2018 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -54,10 +54,10 @@ #define MapReg2DW(r) ((dw_regs)r) typedef enum { - #define DW_REG( __n ) DW_MIPS_##__n, + #define pick(id,name) DW_REG_ ## id, #include "dwregmps.h" - DW_REG( MAX ) - #undef DW_REG + DW_REG_MAX + #undef pick } dw_regs; static dw_regs DFRegMap( hw_reg_set hw_reg ) diff --git a/bld/cg/risc/ppc/c/ppcdfsup.c b/bld/cg/risc/ppc/c/ppcdfsup.c index 36411673cf..82c87d59e4 100644 --- a/bld/cg/risc/ppc/c/ppcdfsup.c +++ b/bld/cg/risc/ppc/c/ppcdfsup.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2018 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -55,10 +55,10 @@ #define MapReg2DW(r) ((dw_regs)r) typedef enum { - #define DW_REG( __n ) DW_AXP_##__n, + #define pick(id,name) DW_REG_ ## id, #include "dwregppc.h" - DW_REG( MAX ) - #undef DW_REG + DW_REG_MAX + #undef pick } dw_regs; static dw_regs DFRegMap( hw_reg_set hw_reg ) diff --git a/bld/dip/dwarf/c/dfloc.c b/bld/dip/dwarf/c/dfloc.c index dbdf46967a..84a534b4db 100644 --- a/bld/dip/dwarf/c/dfloc.c +++ b/bld/dip/dwarf/c/dfloc.c @@ -146,9 +146,9 @@ void LocationTrunc( location_list *ll, unsigned bits ) } typedef enum { - #define DW_REG(name,ci,start,len) DW_X86_##name, + #define pick(id,name,ci,start,len) DW_X86_ ## id, #include "dwregx86.h" - #undef DW_REG + #undef pick DW_X86_MAX }dw_X86_regs; @@ -159,16 +159,16 @@ typedef struct { } reg_entry; static reg_entry const CLRegX86[DW_X86_MAX] = { - #define DW_REG(name,ci,start,len) { ci, start, len }, + #define pick(id,name,ci,start,len) { ci, start, len }, #include "dwregx86.h" - #undef DW_REG + #undef pick }; typedef enum { - #define DW_REG( __n ) DW_AXP_##__n, + #define pick(id,name) DW_AXP_ ## id, #include "dwregaxp.h" - DW_REG( MAX ) - #undef DW_REG + #undef pick + DW_AXP_MAX }dw_axp_regs; /* @@ -245,10 +245,10 @@ static uint_16 const CLRegAXP[DW_AXP_MAX] = { }; typedef enum { - #define DW_REG( __n ) DW_PPC_##__n, + #define pick(id,name) DW_PPC_ ## id, #include "dwregppc.h" - DW_REG( MAX ) - #undef DW_REG + #undef pick + DW_PPC_MAX } dw_ppc_regs; typedef struct { @@ -331,10 +331,10 @@ static ppcreg_entry const CLRegPPC[DW_PPC_MAX] = { }; typedef enum { - #define DW_REG( __n ) DW_MIPS_##__n, + #define pick(id,name) DW_MIPS_ ## id, #include "dwregmps.h" - DW_REG( MAX ) - #undef DW_REG + #undef pick + DW_MIPS_MAX } dw_mips_regs; typedef struct { From 306834384e15a540bb669a58f87269c2321f0df9 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Thu, 5 Oct 2023 20:34:09 +0200 Subject: [PATCH 212/258] separate id and name of processor registers --- bld/watcom/h/dwregaxp.h | 130 ++++++++++++++++++++-------------------- bld/watcom/h/dwregmps.h | 130 ++++++++++++++++++++-------------------- bld/watcom/h/dwregppc.h | 130 ++++++++++++++++++++-------------------- bld/watcom/h/dwregspc.h | 130 ++++++++++++++++++++-------------------- bld/watcom/h/dwregx86.h | 86 +++++++++++++------------- 5 files changed, 307 insertions(+), 299 deletions(-) diff --git a/bld/watcom/h/dwregaxp.h b/bld/watcom/h/dwregaxp.h index 0b58e302ef..c4ba221b7b 100644 --- a/bld/watcom/h/dwregaxp.h +++ b/bld/watcom/h/dwregaxp.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -29,67 +30,68 @@ ****************************************************************************/ - DW_REG( r0 ) - DW_REG( r1 ) - DW_REG( r2 ) - DW_REG( r3 ) - DW_REG( r4 ) - DW_REG( r5 ) - DW_REG( r6 ) - DW_REG( r7 ) - DW_REG( r8 ) - DW_REG( r9 ) - DW_REG( r10 ) - DW_REG( r11 ) - DW_REG( r12 ) - DW_REG( r13 ) - DW_REG( r14 ) - DW_REG( r15 ) - DW_REG( r16 ) - DW_REG( r17 ) - DW_REG( r18 ) - DW_REG( r19 ) - DW_REG( r20 ) - DW_REG( r21 ) - DW_REG( r22 ) - DW_REG( r23 ) - DW_REG( r24 ) - DW_REG( r25 ) - DW_REG( r26 ) - DW_REG( r27 ) - DW_REG( r28 ) - DW_REG( r29 ) - DW_REG( r30 ) - DW_REG( r31 ) - DW_REG( f0 ) - DW_REG( f1 ) - DW_REG( f2 ) - DW_REG( f3 ) - DW_REG( f4 ) - DW_REG( f5 ) - DW_REG( f6 ) - DW_REG( f7 ) - DW_REG( f8 ) - DW_REG( f9 ) - DW_REG( f10 ) - DW_REG( f11 ) - DW_REG( f12 ) - DW_REG( f13 ) - DW_REG( f14 ) - DW_REG( f15 ) - DW_REG( f16 ) - DW_REG( f17 ) - DW_REG( f18 ) - DW_REG( f19 ) - DW_REG( f20 ) - DW_REG( f21 ) - DW_REG( f22 ) - DW_REG( f23 ) - DW_REG( f24 ) - DW_REG( f25 ) - DW_REG( f26 ) - DW_REG( f27 ) - DW_REG( f28 ) - DW_REG( f29 ) - DW_REG( f30 ) - DW_REG( f31 ) +/* id name */ +pick( R0, r0 ) +pick( R1, r1 ) +pick( R2, r2 ) +pick( R3, r3 ) +pick( R4, r4 ) +pick( R5, r5 ) +pick( R6, r6 ) +pick( R7, r7 ) +pick( R8, r8 ) +pick( R9, r9 ) +pick( R10, r10 ) +pick( R11, r11 ) +pick( R12, r12 ) +pick( R13, r13 ) +pick( R14, r14 ) +pick( R15, r15 ) +pick( R16, r16 ) +pick( R17, r17 ) +pick( R18, r18 ) +pick( R19, r19 ) +pick( R20, r20 ) +pick( R21, r21 ) +pick( R22, r22 ) +pick( R23, r23 ) +pick( R24, r24 ) +pick( R25, r25 ) +pick( R26, r26 ) +pick( R27, r27 ) +pick( R28, r28 ) +pick( R29, r29 ) +pick( R30, r30 ) +pick( R31, r31 ) +pick( F0, f0 ) +pick( F1, f1 ) +pick( F2, f2 ) +pick( F3, f3 ) +pick( F4, f4 ) +pick( F5, f5 ) +pick( F6, f6 ) +pick( F7, f7 ) +pick( F8, f8 ) +pick( F9, f9 ) +pick( F10, f10 ) +pick( F11, f11 ) +pick( F12, f12 ) +pick( F13, f13 ) +pick( F14, f14 ) +pick( F15, f15 ) +pick( F16, f16 ) +pick( F17, f17 ) +pick( F18, f18 ) +pick( F19, f19 ) +pick( F20, f20 ) +pick( F21, f21 ) +pick( F22, f22 ) +pick( F23, f23 ) +pick( F24, f24 ) +pick( F25, f25 ) +pick( F26, f26 ) +pick( F27, f27 ) +pick( F28, f28 ) +pick( F29, f29 ) +pick( F30, f30 ) +pick( F31, f31 ) diff --git a/bld/watcom/h/dwregmps.h b/bld/watcom/h/dwregmps.h index b897c7c167..4cfbc6045c 100644 --- a/bld/watcom/h/dwregmps.h +++ b/bld/watcom/h/dwregmps.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -29,67 +30,68 @@ ****************************************************************************/ - DW_REG( r0 ) - DW_REG( r1 ) - DW_REG( r2 ) - DW_REG( r3 ) - DW_REG( r4 ) - DW_REG( r5 ) - DW_REG( r6 ) - DW_REG( r7 ) - DW_REG( r8 ) - DW_REG( r9 ) - DW_REG( r10 ) - DW_REG( r11 ) - DW_REG( r12 ) - DW_REG( r13 ) - DW_REG( r14 ) - DW_REG( r15 ) - DW_REG( r16 ) - DW_REG( r17 ) - DW_REG( r18 ) - DW_REG( r19 ) - DW_REG( r20 ) - DW_REG( r21 ) - DW_REG( r22 ) - DW_REG( r23 ) - DW_REG( r24 ) - DW_REG( r25 ) - DW_REG( r26 ) - DW_REG( r27 ) - DW_REG( r28 ) - DW_REG( r29 ) - DW_REG( r30 ) - DW_REG( r31 ) - DW_REG( f0 ) - DW_REG( f1 ) - DW_REG( f2 ) - DW_REG( f3 ) - DW_REG( f4 ) - DW_REG( f5 ) - DW_REG( f6 ) - DW_REG( f7 ) - DW_REG( f8 ) - DW_REG( f9 ) - DW_REG( f10 ) - DW_REG( f11 ) - DW_REG( f12 ) - DW_REG( f13 ) - DW_REG( f14 ) - DW_REG( f15 ) - DW_REG( f16 ) - DW_REG( f17 ) - DW_REG( f18 ) - DW_REG( f19 ) - DW_REG( f20 ) - DW_REG( f21 ) - DW_REG( f22 ) - DW_REG( f23 ) - DW_REG( f24 ) - DW_REG( f25 ) - DW_REG( f26 ) - DW_REG( f27 ) - DW_REG( f28 ) - DW_REG( f29 ) - DW_REG( f30 ) - DW_REG( f31 ) +/* id name */ +pick( R0, r0 ) +pick( R1, r1 ) +pick( R2, r2 ) +pick( R3, r3 ) +pick( R4, r4 ) +pick( R5, r5 ) +pick( R6, r6 ) +pick( R7, r7 ) +pick( R8, r8 ) +pick( R9, r9 ) +pick( R10, r10 ) +pick( R11, r11 ) +pick( R12, r12 ) +pick( R13, r13 ) +pick( R14, r14 ) +pick( R15, r15 ) +pick( R16, r16 ) +pick( R17, r17 ) +pick( R18, r18 ) +pick( R19, r19 ) +pick( R20, r20 ) +pick( R21, r21 ) +pick( R22, r22 ) +pick( R23, r23 ) +pick( R24, r24 ) +pick( R25, r25 ) +pick( R26, r26 ) +pick( R27, r27 ) +pick( R28, r28 ) +pick( R29, r29 ) +pick( R30, r30 ) +pick( R31, r31 ) +pick( F0, f0 ) +pick( F1, f1 ) +pick( F2, f2 ) +pick( F3, f3 ) +pick( F4, f4 ) +pick( F5, f5 ) +pick( F6, f6 ) +pick( F7, f7 ) +pick( F8, f8 ) +pick( F9, f9 ) +pick( F10, f10 ) +pick( F11, f11 ) +pick( F12, f12 ) +pick( F13, f13 ) +pick( F14, f14 ) +pick( F15, f15 ) +pick( F16, f16 ) +pick( F17, f17 ) +pick( F18, f18 ) +pick( F19, f19 ) +pick( F20, f20 ) +pick( F21, f21 ) +pick( F22, f22 ) +pick( F23, f23 ) +pick( F24, f24 ) +pick( F25, f25 ) +pick( F26, f26 ) +pick( F27, f27 ) +pick( F28, f28 ) +pick( F29, f29 ) +pick( F30, f30 ) +pick( F31, f31 ) diff --git a/bld/watcom/h/dwregppc.h b/bld/watcom/h/dwregppc.h index d0bcd36f97..143b81f5b7 100644 --- a/bld/watcom/h/dwregppc.h +++ b/bld/watcom/h/dwregppc.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -29,67 +30,68 @@ ****************************************************************************/ - DW_REG( r0 ) - DW_REG( r1 ) - DW_REG( r2 ) - DW_REG( r3 ) - DW_REG( r4 ) - DW_REG( r5 ) - DW_REG( r6 ) - DW_REG( r7 ) - DW_REG( r8 ) - DW_REG( r9 ) - DW_REG( r10 ) - DW_REG( r11 ) - DW_REG( r12 ) - DW_REG( r13 ) - DW_REG( r14 ) - DW_REG( r15 ) - DW_REG( r16 ) - DW_REG( r17 ) - DW_REG( r18 ) - DW_REG( r19 ) - DW_REG( r20 ) - DW_REG( r21 ) - DW_REG( r22 ) - DW_REG( r23 ) - DW_REG( r24 ) - DW_REG( r25 ) - DW_REG( r26 ) - DW_REG( r27 ) - DW_REG( r28 ) - DW_REG( r29 ) - DW_REG( r30 ) - DW_REG( r31 ) - DW_REG( f0 ) - DW_REG( f1 ) - DW_REG( f2 ) - DW_REG( f3 ) - DW_REG( f4 ) - DW_REG( f5 ) - DW_REG( f6 ) - DW_REG( f7 ) - DW_REG( f8 ) - DW_REG( f9 ) - DW_REG( f10 ) - DW_REG( f11 ) - DW_REG( f12 ) - DW_REG( f13 ) - DW_REG( f14 ) - DW_REG( f15 ) - DW_REG( f16 ) - DW_REG( f17 ) - DW_REG( f18 ) - DW_REG( f19 ) - DW_REG( f20 ) - DW_REG( f21 ) - DW_REG( f22 ) - DW_REG( f23 ) - DW_REG( f24 ) - DW_REG( f25 ) - DW_REG( f26 ) - DW_REG( f27 ) - DW_REG( f28 ) - DW_REG( f29 ) - DW_REG( f30 ) - DW_REG( f31 ) +/* id name */ +pick( R0, r0 ) +pick( R1, r1 ) +pick( R2, r2 ) +pick( R3, r3 ) +pick( R4, r4 ) +pick( R5, r5 ) +pick( R6, r6 ) +pick( R7, r7 ) +pick( R8, r8 ) +pick( R9, r9 ) +pick( R10, r10 ) +pick( R11, r11 ) +pick( R12, r12 ) +pick( R13, r13 ) +pick( R14, r14 ) +pick( R15, r15 ) +pick( R16, r16 ) +pick( R17, r17 ) +pick( R18, r18 ) +pick( R19, r19 ) +pick( R20, r20 ) +pick( R21, r21 ) +pick( R22, r22 ) +pick( R23, r23 ) +pick( R24, r24 ) +pick( R25, r25 ) +pick( R26, r26 ) +pick( R27, r27 ) +pick( R28, r28 ) +pick( R29, r29 ) +pick( R30, r30 ) +pick( R31, r31 ) +pick( F0, f0 ) +pick( F1, f1 ) +pick( F2, f2 ) +pick( F3, f3 ) +pick( F4, f4 ) +pick( F5, f5 ) +pick( F6, f6 ) +pick( F7, f7 ) +pick( F8, f8 ) +pick( F9, f9 ) +pick( F10, f10 ) +pick( F11, f11 ) +pick( F12, f12 ) +pick( F13, f13 ) +pick( F14, f14 ) +pick( F15, f15 ) +pick( F16, f16 ) +pick( F17, f17 ) +pick( F18, f18 ) +pick( F19, f19 ) +pick( F20, f20 ) +pick( F21, f21 ) +pick( F22, f22 ) +pick( F23, f23 ) +pick( F24, f24 ) +pick( F25, f25 ) +pick( F26, f26 ) +pick( F27, f27 ) +pick( F28, f28 ) +pick( F29, f29 ) +pick( F30, f30 ) +pick( F31, f31 ) diff --git a/bld/watcom/h/dwregspc.h b/bld/watcom/h/dwregspc.h index a0f2de57ce..34005abce4 100644 --- a/bld/watcom/h/dwregspc.h +++ b/bld/watcom/h/dwregspc.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -29,67 +30,68 @@ ****************************************************************************/ - DW_REG( r0 ) - DW_REG( r1 ) - DW_REG( r2 ) - DW_REG( r3 ) - DW_REG( r4 ) - DW_REG( r5 ) - DW_REG( r6 ) - DW_REG( r7 ) - DW_REG( r8 ) - DW_REG( r9 ) - DW_REG( r10 ) - DW_REG( r11 ) - DW_REG( r12 ) - DW_REG( r13 ) - DW_REG( r14 ) - DW_REG( r15 ) - DW_REG( r16 ) - DW_REG( r17 ) - DW_REG( r18 ) - DW_REG( r19 ) - DW_REG( r20 ) - DW_REG( r21 ) - DW_REG( r22 ) - DW_REG( r23 ) - DW_REG( r24 ) - DW_REG( r25 ) - DW_REG( r26 ) - DW_REG( r27 ) - DW_REG( r28 ) - DW_REG( r29 ) - DW_REG( r30 ) - DW_REG( r31 ) - DW_REG( f0 ) - DW_REG( f1 ) - DW_REG( f2 ) - DW_REG( f3 ) - DW_REG( f4 ) - DW_REG( f5 ) - DW_REG( f6 ) - DW_REG( f7 ) - DW_REG( f8 ) - DW_REG( f9 ) - DW_REG( f10 ) - DW_REG( f11 ) - DW_REG( f12 ) - DW_REG( f13 ) - DW_REG( f14 ) - DW_REG( f15 ) - DW_REG( f16 ) - DW_REG( f17 ) - DW_REG( f18 ) - DW_REG( f19 ) - DW_REG( f20 ) - DW_REG( f21 ) - DW_REG( f22 ) - DW_REG( f23 ) - DW_REG( f24 ) - DW_REG( f25 ) - DW_REG( f26 ) - DW_REG( f27 ) - DW_REG( f28 ) - DW_REG( f29 ) - DW_REG( f30 ) - DW_REG( f31 ) +/* id name */ +pick( R0, r0 ) +pick( R1, r1 ) +pick( R2, r2 ) +pick( R3, r3 ) +pick( R4, r4 ) +pick( R5, r5 ) +pick( R6, r6 ) +pick( R7, r7 ) +pick( R8, r8 ) +pick( R9, r9 ) +pick( R10, r10 ) +pick( R11, r11 ) +pick( R12, r12 ) +pick( R13, r13 ) +pick( R14, r14 ) +pick( R15, r15 ) +pick( R16, r16 ) +pick( R17, r17 ) +pick( R18, r18 ) +pick( R19, r19 ) +pick( R20, r20 ) +pick( R21, r21 ) +pick( R22, r22 ) +pick( R23, r23 ) +pick( R24, r24 ) +pick( R25, r25 ) +pick( R26, r26 ) +pick( R27, r27 ) +pick( R28, r28 ) +pick( R29, r29 ) +pick( R30, r30 ) +pick( R31, r31 ) +pick( F0, f0 ) +pick( F1, f1 ) +pick( F2, f2 ) +pick( F3, f3 ) +pick( F4, f4 ) +pick( F5, f5 ) +pick( F6, f6 ) +pick( F7, f7 ) +pick( F8, f8 ) +pick( F9, f9 ) +pick( F10, f10 ) +pick( F11, f11 ) +pick( F12, f12 ) +pick( F13, f13 ) +pick( F14, f14 ) +pick( F15, f15 ) +pick( F16, f16 ) +pick( F17, f17 ) +pick( F18, f18 ) +pick( F19, f19 ) +pick( F20, f20 ) +pick( F21, f21 ) +pick( F22, f22 ) +pick( F23, f23 ) +pick( F24, f24 ) +pick( F25, f25 ) +pick( F26, f26 ) +pick( F27, f27 ) +pick( F28, f28 ) +pick( F29, f29 ) +pick( F30, f30 ) +pick( F31, f31 ) diff --git a/bld/watcom/h/dwregx86.h b/bld/watcom/h/dwregx86.h index 3400e593ad..e876dbb821 100644 --- a/bld/watcom/h/dwregx86.h +++ b/bld/watcom/h/dwregx86.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -29,45 +29,45 @@ * ****************************************************************************/ -/* name ci start len */ -DW_REG( eax, CI_EAX, 0, 32 ) -DW_REG( ecx, CI_ECX, 0, 32 ) -DW_REG( edx, CI_EDX, 0, 32 ) -DW_REG( ebx, CI_EBX, 0, 32 ) -DW_REG( esp, CI_ESP, 0, 32 ) -DW_REG( ebp, CI_EBP, 0, 32 ) -DW_REG( esi, CI_ESI, 0, 32 ) -DW_REG( edi, CI_EDI, 0, 32 ) -DW_REG( eip, CI_EIP, 0, 32 ) -DW_REG( eflags, CI_EFL, 0, 32 ) -DW_REG( trapno, 0, 0, 0 ) -DW_REG( st0, CI_ST0, 0, 80 ) -DW_REG( st1, CI_ST1, 0, 80 ) -DW_REG( st2, CI_ST2, 0, 80 ) -DW_REG( st3, CI_ST3, 0, 80 ) -DW_REG( st4, CI_ST4, 0, 80 ) -DW_REG( st5, CI_ST5, 0, 80 ) -DW_REG( st6, CI_ST6, 0, 80 ) -DW_REG( st7, CI_ST7, 0, 80 ) -DW_REG( al, CI_EAX, 0, 8 ) -DW_REG( ah, CI_EAX, 8, 8 ) -DW_REG( bl, CI_EBX, 0, 8 ) -DW_REG( bh, CI_EBX, 8, 8 ) -DW_REG( cl, CI_ECX, 0, 8 ) -DW_REG( ch, CI_ECX, 8, 8 ) -DW_REG( dl, CI_EDX, 0, 8 ) -DW_REG( dh, CI_EDX, 8, 8 ) -DW_REG( ax, CI_EAX, 0, 16 ) -DW_REG( bx, CI_EBX, 0, 16 ) -DW_REG( cx, CI_ECX, 0, 16 ) -DW_REG( dx, CI_EDX, 0, 16 ) -DW_REG( si, CI_ESI, 0, 16 ) -DW_REG( di, CI_EDI, 0, 16 ) -DW_REG( bp, CI_EBP, 0, 16 ) -DW_REG( sp, CI_ESP, 0, 16 ) -DW_REG( cs, CI_CS, 0, 16 ) -DW_REG( ss, CI_SS, 0, 16 ) -DW_REG( ds, CI_DS, 0, 16 ) -DW_REG( es, CI_ES, 0, 16 ) -DW_REG( fs, CI_FS, 0, 16 ) -DW_REG( gs, CI_GS, 0, 16 ) +/* id name ci start len */ +pick( EAX, eax, CI_EAX, 0, 32 ) +pick( ECX, ecx, CI_ECX, 0, 32 ) +pick( EDX, edx, CI_EDX, 0, 32 ) +pick( EBX, ebx, CI_EBX, 0, 32 ) +pick( ESP, esp, CI_ESP, 0, 32 ) +pick( EBP, ebp, CI_EBP, 0, 32 ) +pick( ESI, esi, CI_ESI, 0, 32 ) +pick( EDI, edi, CI_EDI, 0, 32 ) +pick( EIP, eip, CI_EIP, 0, 32 ) +pick( EFLAGS, eflags, CI_EFL, 0, 32 ) +pick( TRAPNO, trapno, 0, 0, 0 ) +pick( ST0, st0, CI_ST0, 0, 80 ) +pick( ST1, st1, CI_ST1, 0, 80 ) +pick( ST2, st2, CI_ST2, 0, 80 ) +pick( ST3, st3, CI_ST3, 0, 80 ) +pick( ST4, st4, CI_ST4, 0, 80 ) +pick( ST5, st5, CI_ST5, 0, 80 ) +pick( ST6, st6, CI_ST6, 0, 80 ) +pick( ST7, st7, CI_ST7, 0, 80 ) +pick( AL, al, CI_EAX, 0, 8 ) +pick( AH, ah, CI_EAX, 8, 8 ) +pick( BL, bl, CI_EBX, 0, 8 ) +pick( BH, bh, CI_EBX, 8, 8 ) +pick( CL, cl, CI_ECX, 0, 8 ) +pick( CH, ch, CI_ECX, 8, 8 ) +pick( DL, dl, CI_EDX, 0, 8 ) +pick( DH, dh, CI_EDX, 8, 8 ) +pick( AX, ax, CI_EAX, 0, 16 ) +pick( BX, bx, CI_EBX, 0, 16 ) +pick( CX, cx, CI_ECX, 0, 16 ) +pick( DX, dx, CI_EDX, 0, 16 ) +pick( SI, si, CI_ESI, 0, 16 ) +pick( DI, di, CI_EDI, 0, 16 ) +pick( BP, bp, CI_EBP, 0, 16 ) +pick( SP, sp, CI_ESP, 0, 16 ) +pick( CS, cs, CI_CS, 0, 16 ) +pick( SS, ss, CI_SS, 0, 16 ) +pick( DS, ds, CI_DS, 0, 16 ) +pick( ES, es, CI_ES, 0, 16 ) +pick( FS, fs, CI_FS, 0, 16 ) +pick( GS, gs, CI_GS, 0, 16 ) From 02a1972ac5006b02253cab979680daa4f72702b8 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Thu, 5 Oct 2023 20:44:49 +0200 Subject: [PATCH 213/258] separate id and name of processor registers --- bld/exedump/c/wsect.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bld/exedump/c/wsect.c b/bld/exedump/c/wsect.c index 8dde2c3c1b..a1bf4d35a0 100644 --- a/bld/exedump/c/wsect.c +++ b/bld/exedump/c/wsect.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -102,9 +102,9 @@ static const_string_table OpName[] = { }; static const_string_table RegName[] = { - #define DW_REG(name,ci,start,len) #name, + #define pick(id,name,ci,start,len) #name, #include "dwregx86.h" - #undef DW_REG + #undef pick }; static readable_name readableReferenceOps[] = { From e9682c87800d9b4c870a6faf29b465bbba093e29 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Thu, 5 Oct 2023 21:26:18 +0200 Subject: [PATCH 214/258] separate id and name of processor registers --- bld/dip/dwarf/c/dfloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bld/dip/dwarf/c/dfloc.c b/bld/dip/dwarf/c/dfloc.c index 84a534b4db..acb90797cd 100644 --- a/bld/dip/dwarf/c/dfloc.c +++ b/bld/dip/dwarf/c/dfloc.c @@ -693,7 +693,7 @@ static bool Reg( void *_d, uint_32 *where, uint_16 reg ) DCStatus( d->ds ); return( false ); } - if( arch == DIG_ARCH_X86 && (reg == DW_X86_esp || reg == DW_X86_sp) ) { /* kludge for now */ + if( arch == DIG_ARCH_X86 && (reg == DW_X86_ESP || reg == DW_X86_SP) ) { /* kludge for now */ d->ds = SafeDCItemLocation( d->lc, CI_STACK, &ll ); if( d->ds != DS_OK ) { DCStatus( d->ds ); From 9215132607b09d44b6b9d415f90f3dfd81610a5b Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Sat, 7 Oct 2023 12:32:28 +0200 Subject: [PATCH 215/258] fix for issue #1142 correct a few implementation bugs in strsafe.h WIN32 header file null termination for resulting string for copy functions correct size_t/int types mismatches for lengths fix the behavior of append functions when the length of the target buffer is erroneously shorter than the length of the string in the buffer --- bld/w32api/include/strsafe.mh | 92 ++++++++++++++++++++++------------- 1 file changed, 58 insertions(+), 34 deletions(-) diff --git a/bld/w32api/include/strsafe.mh b/bld/w32api/include/strsafe.mh index 8ddf124417..c49f4a0901 100644 --- a/bld/w32api/include/strsafe.mh +++ b/bld/w32api/include/strsafe.mh @@ -112,12 +112,14 @@ __inline HRESULT StringCchCatA( LPSTR lpszDestination, size_t cchDestination, LPCSTR lpszSource ) { - int cchInit; + size_t cchInit; if( cchDestination > STRSAFE_MAX_CCH ) { return( STRSAFE_E_INVALID_PARAMETER ); } cchInit = strlen( lpszDestination ); - strncat( lpszDestination, lpszSource, cchDestination - cchInit - 1 ); + if( cchDestination > cchInit ) { + strncat( lpszDestination, lpszSource, cchDestination - cchInit - 1 ); + } if( cchInit + strlen( lpszSource ) >= cchDestination ) { return( STRSAFE_E_INSUFFICIENT_BUFFER ); } else { @@ -128,12 +130,14 @@ __inline HRESULT StringCchCatA( LPSTR lpszDestination, size_t cchDestination, __inline HRESULT StringCchCatW( LPWSTR lpszDestination, size_t cchDestination, LPCWSTR lpszSource ) { - int cchInit; + size_t cchInit; if( cchDestination > STRSAFE_MAX_CCH ) { return( STRSAFE_E_INVALID_PARAMETER ); } cchInit = wcslen( lpszDestination ); - wcsncat( lpszDestination, lpszSource, cchDestination - cchInit - 1 ); + if( cchDestination > cchInit ) { + wcsncat( lpszDestination, lpszSource, cchDestination - cchInit - 1 ); + } if( cchInit + wcslen( lpszSource ) >= cchDestination ) { return( STRSAFE_E_INSUFFICIENT_BUFFER ); } else { @@ -145,14 +149,16 @@ __inline HRESULT StringCchCatExA( LPSTR lpszDestination, size_t cchDestination, LPCSTR lpszSource, LPSTR *lplpszDestinationEnd, size_t *pcchRemaining, DWORD dwFlags ) { - int cchInit; - int cchSource; + size_t cchInit; + size_t cchSource; if( cchDestination > STRSAFE_MAX_CCH ) { return( STRSAFE_E_INVALID_PARAMETER ); } cchInit = strlen( lpszDestination ); cchSource = strlen( lpszSource ); - strncat( lpszDestination, lpszSource, cchDestination - cchInit - 1 ); + if( cchDestination > cchInit ) { + strncat( lpszDestination, lpszSource, cchDestination - cchInit - 1 ); + } if( cchInit + cchSource >= cchDestination ) { if( dwFlags & STRSAFE_NO_TRUNCATION ) { lpszDestination[0] = '\0'; @@ -187,14 +193,16 @@ __inline HRESULT StringCchCatExW( LPWSTR lpszDestination, size_t cchDestination, LPCWSTR lpszSource, LPWSTR *lplpszDestinationEnd, size_t *pcchRemaining, DWORD dwFlags ) { - int cchInit; - int cchSource; + size_t cchInit; + size_t cchSource; if( cchDestination > STRSAFE_MAX_CCH ) { return( STRSAFE_E_INVALID_PARAMETER ); } cchInit = wcslen( lpszDestination ); cchSource = wcslen( lpszSource ); - wcsncat( lpszDestination, lpszSource, cchDestination - cchInit - 1 ); + if( cchDestination > cchInit ) { + wcsncat( lpszDestination, lpszSource, cchDestination - cchInit - 1 ); + } if( cchInit + cchSource >= cchDestination ) { if( dwFlags & STRSAFE_NO_TRUNCATION ) { lpszDestination[0] = '\0'; @@ -228,13 +236,15 @@ __inline HRESULT StringCchCatExW( LPWSTR lpszDestination, size_t cchDestination, __inline HRESULT StringCchCatNA( LPSTR lpszDestination, size_t cchDestination, LPCSTR lpszSource, size_t cchMaxAppend ) { - int cchInit; + size_t cchInit; if( cchDestination > STRSAFE_MAX_CCH ) { return( STRSAFE_E_INVALID_PARAMETER ); } cchInit = strlen( lpszDestination ); - strncat( lpszDestination, lpszSource, - max( cchDestination - cchInit - 1, cchMaxAppend ) ); + if( cchDestination > cchInit ) { + strncat( lpszDestination, lpszSource, + min( cchDestination - cchInit - 1, cchMaxAppend ) ); + } if( cchInit + min( strlen( lpszSource ), cchMaxAppend ) >= cchDestination ) { return( STRSAFE_E_INSUFFICIENT_BUFFER ); } else { @@ -245,13 +255,15 @@ __inline HRESULT StringCchCatNA( LPSTR lpszDestination, size_t cchDestination, __inline HRESULT StringCchCatNW( LPWSTR lpszDestination, size_t cchDestination, LPCWSTR lpszSource, size_t cchMaxAppend ) { - int cchInit; + size_t cchInit; if( cchDestination > STRSAFE_MAX_CCH ) { return( STRSAFE_E_INVALID_PARAMETER ); } cchInit = wcslen( lpszDestination ); - wcsncat( lpszDestination, lpszSource, - max( cchDestination - cchInit - 1, cchMaxAppend ) ); + if( cchDestination > cchInit ) { + wcsncat( lpszDestination, lpszSource, + min( cchDestination - cchInit - 1, cchMaxAppend ) ); + } if( cchInit + min( wcslen( lpszSource ), cchMaxAppend ) >= cchDestination ) { return( STRSAFE_E_INSUFFICIENT_BUFFER ); } else { @@ -264,15 +276,17 @@ __inline HRESULT StringCchCatNExA( LPSTR lpszDestination, size_t cchDestination, LPSTR *lplpszDestinationEnd, size_t *pcchRemaining, DWORD dwFlags ) { - int cchInit; - int cchSource; + size_t cchInit; + size_t cchSource; if( cchDestination > STRSAFE_MAX_CCH ) { return( STRSAFE_E_INVALID_PARAMETER ); } cchInit = strlen( lpszDestination ); cchSource = strlen( lpszSource ); - strncat( lpszDestination, lpszSource, - max( cchDestination - cchInit - 1, cchMaxAppend ) ); + if( cchDestination > cchInit ) { + strncat( lpszDestination, lpszSource, + min( cchDestination - cchInit - 1, cchMaxAppend ) ); + } if( cchInit + min( cchSource, cchMaxAppend ) >= cchDestination ) { if( dwFlags & STRSAFE_NO_TRUNCATION ) { lpszDestination[0] = '\0'; @@ -308,15 +322,17 @@ __inline HRESULT StringCchCatNExW( LPWSTR lpszDestination, size_t cchDestination LPWSTR *lplpszDestinationEnd, size_t *pcchRemaining, DWORD dwFlags ) { - int cchInit; - int cchSource; + size_t cchInit; + size_t cchSource; if( cchDestination > STRSAFE_MAX_CCH ) { return( STRSAFE_E_INVALID_PARAMETER ); } cchInit = wcslen( lpszDestination ); cchSource = wcslen( lpszSource ); - wcsncat( lpszDestination, lpszSource, - max( cchDestination - cchInit - 1, cchMaxAppend ) ); + if( cchDestination > cchInit ) { + wcsncat( lpszDestination, lpszSource, + min( cchDestination - cchInit - 1, cchMaxAppend ) ); + } if( cchInit + min( cchSource, cchMaxAppend ) >= cchDestination ) { if( dwFlags & STRSAFE_NO_TRUNCATION ) { lpszDestination[0] = '\0'; @@ -354,6 +370,7 @@ __inline HRESULT StringCchCopyA( LPSTR lpszDestination, size_t cchDestination, return( STRSAFE_E_INVALID_PARAMETER ); } strncpy( lpszDestination, lpszSource, cchDestination - 1 ); + lpszDestination[cchDestination - 1] = '\0'; if( strlen( lpszSource ) >= cchDestination ) { return( STRSAFE_E_INSUFFICIENT_BUFFER ); } else { @@ -368,6 +385,7 @@ __inline HRESULT StringCchCopyW( LPWSTR lpszDestination, size_t cchDestination, return( STRSAFE_E_INVALID_PARAMETER ); } wcsncpy( lpszDestination, lpszSource, cchDestination - 1 ); + lpszDestination[cchDestination - 1] = '\0'; if( wcslen( lpszSource ) >= cchDestination ) { return( STRSAFE_E_INSUFFICIENT_BUFFER ); } else { @@ -379,7 +397,7 @@ __inline HRESULT StringCchCopyExA( LPSTR lpszDestination, size_t cchDestination, LPCSTR lpszSource, LPSTR *lplpszDestinationEnd, size_t *pcchRemaining, DWORD dwFlags ) { - int cchSource; + size_t cchSource; if( cchDestination > STRSAFE_MAX_CCH ) { return( STRSAFE_E_INVALID_PARAMETER ); } @@ -418,7 +436,7 @@ __inline HRESULT StringCchCopyExW( LPWSTR lpszDestination, size_t cchDestination LPCWSTR lpszSource, LPWSTR *lplpszDestinationEnd, size_t *pcchRemaining, DWORD dwFlags ) { - int cchSource; + size_t cchSource; if( cchDestination > STRSAFE_MAX_CCH ) { return( STRSAFE_E_INVALID_PARAMETER ); } @@ -456,10 +474,13 @@ __inline HRESULT StringCchCopyExW( LPWSTR lpszDestination, size_t cchDestination __inline HRESULT StringCchCopyNA( LPSTR lpszDestination, size_t cchDestination, LPCSTR lpszSource, size_t cchSource ) { + size_t len; if( cchDestination > STRSAFE_MAX_CCH ) { return( STRSAFE_E_INVALID_PARAMETER ); } - strncpy( lpszDestination, lpszSource, min( cchDestination - 1, cchSource ) ); + len = min( cchDestination - 1, cchSource ); + strncpy( lpszDestination, lpszSource, len ); + lpszDestination[len] = '\0'; if( cchSource >= cchDestination ) { return( STRSAFE_E_INSUFFICIENT_BUFFER ); } else { @@ -470,10 +491,13 @@ __inline HRESULT StringCchCopyNA( LPSTR lpszDestination, size_t cchDestination, __inline HRESULT StringCchCopyNW( LPWSTR lpszDestination, size_t cchDestination, LPCWSTR lpszSource, size_t cchSource ) { + size_t len; if( cchDestination > STRSAFE_MAX_CCH ) { return( STRSAFE_E_INVALID_PARAMETER ); } - wcsncpy( lpszDestination, lpszSource, min( cchDestination - 1, cchSource ) ); + len = min( cchDestination - 1, cchSource ); + wcsncpy( lpszDestination, lpszSource, len ); + lpszDestination[len] = '\0'; if( cchSource >= cchDestination ) { return( STRSAFE_E_INSUFFICIENT_BUFFER ); } else { @@ -482,7 +506,7 @@ __inline HRESULT StringCchCopyNW( LPWSTR lpszDestination, size_t cchDestination, } __inline HRESULT StringCchCopyNExA( LPSTR lpszDestination, size_t cchDestination, - LPCSTR lpszSource, int cchSource, + LPCSTR lpszSource, size_t cchSource, LPSTR *lplpszDestinationEnd, size_t *pcchRemaining, DWORD dwFlags ) { @@ -520,7 +544,7 @@ __inline HRESULT StringCchCopyNExA( LPSTR lpszDestination, size_t cchDestination } __inline HRESULT StringCchCopyNExW( LPWSTR lpszDestination, size_t cchDestination, - LPCWSTR lpszSource, int cchSource, + LPCWSTR lpszSource, size_t cchSource, LPWSTR *lplpszDestinationEnd, size_t *pcchRemaining, DWORD dwFlags ) { @@ -560,7 +584,7 @@ __inline HRESULT StringCchCopyNExW( LPWSTR lpszDestination, size_t cchDestinatio __inline HRESULT StringCchGetsA( LPSTR lpszDestination, size_t cchDestination ) { int ch; - int i; + size_t i; if( cchDestination > STRSAFE_MAX_CCH ) { return( STRSAFE_E_INVALID_PARAMETER ); } @@ -583,7 +607,7 @@ __inline HRESULT StringCchGetsA( LPSTR lpszDestination, size_t cchDestination ) __inline HRESULT StringCchGetsW( LPWSTR lpszDestination, size_t cchDestination ) { wint_t ch; - int i; + size_t i; if( cchDestination > STRSAFE_MAX_CCH ) { return( STRSAFE_E_INVALID_PARAMETER ); } @@ -608,7 +632,7 @@ __inline HRESULT StringCchGetsExA( LPSTR lpszDestination, size_t cchDestination, DWORD dwFlags ) { int ch; - int i; + size_t i; if( cchDestination > STRSAFE_MAX_CCH ) { return( STRSAFE_E_INVALID_PARAMETER ); } @@ -659,7 +683,7 @@ __inline HRESULT StringCchGetsExW( LPWSTR lpszDestination, size_t cchDestination DWORD dwFlags ) { wint_t ch; - int i; + size_t i; if( cchDestination > STRSAFE_MAX_CCH ) { return( STRSAFE_E_INVALID_PARAMETER ); } From c0925d2c1223704a3161445e7015350f2717fcd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Mal=C3=A1k?= Date: Sun, 8 Oct 2023 16:48:13 +0200 Subject: [PATCH 216/258] cleanup cg code (#1143) do code for architecture register index processing more transparent update comment --- bld/cg/c/namelist.c | 5 +++-- bld/cg/h/name.h | 2 +- bld/cg/h/rgtbl.h | 2 +- bld/cg/risc/axp/c/axprgtbl.c | 4 ++-- bld/cg/risc/mps/c/mpsrgtbl.c | 4 ++-- bld/cg/risc/ppc/c/ppcrgtbl.c | 4 ++-- 6 files changed, 11 insertions(+), 10 deletions(-) diff --git a/bld/cg/c/namelist.c b/bld/cg/c/namelist.c index 2c6735c532..5138acb225 100644 --- a/bld/cg/c/namelist.c +++ b/bld/cg/c/namelist.c @@ -547,9 +547,10 @@ name *AllocRegName( hw_reg_set regs ) } new_r = AllocName( N_REGISTER, RegClass( regs ), 0 ); new_r->r.reg = regs; - new_r->r.reg_index = -1; #if _TARGET_RISC - SetArchIndex( new_r, regs ); + new_r->r.reg_index = GetArchIndex( regs ); +#else + new_r->r.reg_index = -1; #endif return( new_r ); } diff --git a/bld/cg/h/name.h b/bld/cg/h/name.h index 92838ed0d1..0d40d78015 100644 --- a/bld/cg/h/name.h +++ b/bld/cg/h/name.h @@ -180,7 +180,7 @@ typedef struct register_name { struct name_def _n; hw_reg_set reg; int reg_index; /* for scoreboarding */ - int arch_index; /* used for encoding on AXP */ + int arch_index; /* used for encoding on RISC architectures */ } register_name; typedef struct indexed_name { diff --git a/bld/cg/h/rgtbl.h b/bld/cg/h/rgtbl.h index 62b5759cc8..495116b301 100644 --- a/bld/cg/h/rgtbl.h +++ b/bld/cg/h/rgtbl.h @@ -84,7 +84,7 @@ extern hw_reg_set ReturnReg( type_class_def type_class ); extern reg_set_index UsualPossible( type_class_def type_class ); extern hw_reg_set FrameBaseReg( void ); extern hw_reg_set FrameReg( void ); -extern void SetArchIndex( name *new_r, hw_reg_set regs ); +extern int GetArchIndex( hw_reg_set regs ); extern hw_reg_set *ParmRegs( void ); extern hw_reg_set *GPRegs( void ); extern hw_reg_set *FPRegs( void ); diff --git a/bld/cg/risc/axp/c/axprgtbl.c b/bld/cg/risc/axp/c/axprgtbl.c index 69c19230d5..e1deddd4aa 100644 --- a/bld/cg/risc/axp/c/axprgtbl.c +++ b/bld/cg/risc/axp/c/axprgtbl.c @@ -827,10 +827,10 @@ reg_idx RegIndex( hw_reg_set reg ) return( (reg_idx)regTranslate( reg, true ) ); } -void SetArchIndex( name *new_r, hw_reg_set regs ) +int GetArchIndex( hw_reg_set regs ) /***********************************************/ { - new_r->r.arch_index = RegIndex( regs ); + return( RegIndex( regs ) ); } axp_regn RegTrans( hw_reg_set reg ) diff --git a/bld/cg/risc/mps/c/mpsrgtbl.c b/bld/cg/risc/mps/c/mpsrgtbl.c index 732c3020ef..1d8a3979a8 100644 --- a/bld/cg/risc/mps/c/mpsrgtbl.c +++ b/bld/cg/risc/mps/c/mpsrgtbl.c @@ -896,10 +896,10 @@ reg_idx RegIndex( hw_reg_set reg ) return( (reg_idx)regTranslate( reg, true ) ); } -void SetArchIndex( name *new_r, hw_reg_set regs ) +int GetArchIndex( hw_reg_set regs ) /***********************************************/ { - new_r->r.arch_index = RegIndex( regs ); + return( RegIndex( regs ) ); } diff --git a/bld/cg/risc/ppc/c/ppcrgtbl.c b/bld/cg/risc/ppc/c/ppcrgtbl.c index 95c18c266c..35f647e9f3 100644 --- a/bld/cg/risc/ppc/c/ppcrgtbl.c +++ b/bld/cg/risc/ppc/c/ppcrgtbl.c @@ -815,10 +815,10 @@ reg_idx RegIndex( hw_reg_set reg ) return( (reg_idx)regTranslate( reg, true ) ); } -void SetArchIndex( name *new_r, hw_reg_set regs ) +int GetArchIndex( hw_reg_set regs ) /***********************************************/ { - new_r->r.arch_index = RegIndex( regs ); + return( RegIndex( regs ) ); } ppc_regn RegTrans( hw_reg_set reg ) From a3939d7a90790e64fe23b4fe6ddec6725390fa9c Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Sun, 8 Oct 2023 18:25:42 +0200 Subject: [PATCH 217/258] fix bug in MIPS HW_Q24 quad-word register definition --- bld/cg/risc/mps/h/mps64reg.h | 46 +++++++++++++++++++-------------- bld/cg/risc/mps/h/mpsreg.h | 50 +++++++++++++++++++++--------------- 2 files changed, 56 insertions(+), 40 deletions(-) diff --git a/bld/cg/risc/mps/h/mps64reg.h b/bld/cg/risc/mps/h/mps64reg.h index d6d98417f8..fe5e150481 100644 --- a/bld/cg/risc/mps/h/mps64reg.h +++ b/bld/cg/risc/mps/h/mps64reg.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -36,21 +36,22 @@ #define HW_NEED_160 #include "cghwreg.h" -/* Target dependent set of hardware registers available */ - /* - Note: after having contemplated all sorts of horrific - manners in which to automate the following in terms of - preprocessor abuse, I have decided that brute force is good. -*/ - -/* Due to some strange assumptions in the code generator about register - names being tightly linked to the size of data contained therein, we - have to give each register a unique name to correspond to each of the - data types which can be held within it. -*/ + * Target dependent set of hardware registers available + * + * Note: after having contemplated all sorts of horrific + * manners in which to automate the following in terms of + * preprocessor abuse, I have decided that brute force is good. + * + * Due to some strange assumptions in the code generator about register + * names being tightly linked to the size of data contained therein, we + * have to give each register a unique name to correspond to each of the + * data types which can be held within it. + */ -/* low bytes of the integer registers - byte 0 */ +/* + * low bytes of the integer registers - byte 0 + */ HW_DEFINE_SIMPLE( HW_B0, 0x00000001U, 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U ); HW_DEFINE_SIMPLE( HW_B1, 0x00000002U, 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U ); HW_DEFINE_SIMPLE( HW_B2, 0x00000004U, 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U ); @@ -84,7 +85,9 @@ HW_DEFINE_SIMPLE( HW_B29, 0x20000000U, 0x00000000U, 0x00000000U, 0x00000000U, HW_DEFINE_SIMPLE( HW_B30, 0x40000000U, 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U ); HW_DEFINE_SIMPLE( HW_B31, 0x80000000U, 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U ); -/* high bytes of lower word registers - byte 1 */ +/* + * high bytes of lower word registers - byte 1 + */ HW_DEFINE_SIMPLE( HW_hb0, 0x00000000U, 0x00000001U, 0x00000000U, 0x00000000U, 0x00000000U ); HW_DEFINE_SIMPLE( HW_hb1, 0x00000000U, 0x00000002U, 0x00000000U, 0x00000000U, 0x00000000U ); HW_DEFINE_SIMPLE( HW_hb2, 0x00000000U, 0x00000004U, 0x00000000U, 0x00000000U, 0x00000000U ); @@ -118,7 +121,9 @@ HW_DEFINE_SIMPLE( HW_hb29, 0x00000000U, 0x20000000U, 0x00000000U, 0x00000000U, HW_DEFINE_SIMPLE( HW_hb30, 0x00000000U, 0x40000000U, 0x00000000U, 0x00000000U, 0x00000000U ); HW_DEFINE_SIMPLE( HW_hb31, 0x00000000U, 0x80000000U, 0x00000000U, 0x00000000U, 0x00000000U ); -/* upper word of dword registers - bytes 2 and 3 */ +/* + * upper word of dword registers - bytes 2 and 3 + */ HW_DEFINE_SIMPLE( HW_hw0, 0x00000000U, 0x00000000U, 0x00000001U, 0x00000000U, 0x00000000U ); HW_DEFINE_SIMPLE( HW_hw1, 0x00000000U, 0x00000000U, 0x00000002U, 0x00000000U, 0x00000000U ); HW_DEFINE_SIMPLE( HW_hw2, 0x00000000U, 0x00000000U, 0x00000004U, 0x00000000U, 0x00000000U ); @@ -152,7 +157,9 @@ HW_DEFINE_SIMPLE( HW_hw29, 0x00000000U, 0x00000000U, 0x20000000U, 0x00000000U, HW_DEFINE_SIMPLE( HW_hw30, 0x00000000U, 0x00000000U, 0x40000000U, 0x00000000U, 0x00000000U ); HW_DEFINE_SIMPLE( HW_hw31, 0x00000000U, 0x00000000U, 0x80000000U, 0x00000000U, 0x00000000U ); -/* upper dword of qword registers - bytes 4 through 7 */ +/* + * upper dword of qword registers - bytes 4 through 7 + */ HW_DEFINE_SIMPLE( HW_hd0, 0x00000000U, 0x00000000U, 0x00000000U, 0x00000001U, 0x00000000U ); HW_DEFINE_SIMPLE( HW_hd1, 0x00000000U, 0x00000000U, 0x00000000U, 0x00000002U, 0x00000000U ); HW_DEFINE_SIMPLE( HW_hd2, 0x00000000U, 0x00000000U, 0x00000000U, 0x00000004U, 0x00000000U ); @@ -186,7 +193,9 @@ HW_DEFINE_SIMPLE( HW_hd29, 0x00000000U, 0x00000000U, 0x00000000U, 0x20000000U, HW_DEFINE_SIMPLE( HW_hd30, 0x00000000U, 0x00000000U, 0x00000000U, 0x40000000U, 0x00000000U ); HW_DEFINE_SIMPLE( HW_hd31, 0x00000000U, 0x00000000U, 0x00000000U, 0x80000000U, 0x00000000U ); -/* floating point registers */ +/* + * floating point registers + */ HW_DEFINE_SIMPLE( HW_F0, 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, 0x00000001U ); HW_DEFINE_SIMPLE( HW_F1, 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, 0x00000002U ); HW_DEFINE_SIMPLE( HW_F2, 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, 0x00000004U ); @@ -234,7 +243,6 @@ HW_DEFINE_SIMPLE( HW_SEGS, 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, #define HW_DEFINE_COMPOUND( x ) \ enum { \ - \ /* word sized registers */ \ HW_W0_##x = (HW_B0_##x+HW_hb0_##x), \ HW_W1_##x = (HW_B1_##x+HW_hb1_##x), \ diff --git a/bld/cg/risc/mps/h/mpsreg.h b/bld/cg/risc/mps/h/mpsreg.h index cfc0a9664b..34e854d06c 100644 --- a/bld/cg/risc/mps/h/mpsreg.h +++ b/bld/cg/risc/mps/h/mpsreg.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -35,23 +36,25 @@ #define HW_NEED_160 #include "cghwreg.h" -/* Target dependent set of hardware registers available */ - -/* Due to some strange assumptions in the code generator about register - names being tightly linked to the size of data contained therein, we - have to give each register a unique name to correspond to each of the - data types which can be held within it. -*/ - -/* Note that HW_Rxx registers are aliases for HW_Dxx on MIPS32. The x86 - register definition can be shared between 16-bit and 32-bit codegen - because AX/EAX, DX/EDX etc. disambiguate between 16-bit and 32-bit - registers. On MIPS the register size depends on the architecture, - hence if we want to use generic register names wherever possible, - we need to have different definition of HW_Rxx for MIPS32 vs. MIPS64. -*/ +/* + * Target dependent set of hardware registers available + * + * Due to some strange assumptions in the code generator about register + * names being tightly linked to the size of data contained therein, we + * have to give each register a unique name to correspond to each of the + * data types which can be held within it. + * + * Note that HW_Rxx registers are aliases for HW_Dxx on MIPS32. The x86 + * register definition can be shared between 16-bit and 32-bit codegen + * because AX/EAX, DX/EDX etc. disambiguate between 16-bit and 32-bit + * registers. On MIPS the register size depends on the architecture, + * hence if we want to use generic register names wherever possible, + * we need to have different definition of HW_Rxx for MIPS32 vs. MIPS64. + */ -/* low bytes of the integer registers - byte 0 */ +/* + * low bytes of the integer registers - byte 0 + */ HW_DEFINE_SIMPLE( HW_B0, 0x00000001U, 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U ); HW_DEFINE_SIMPLE( HW_B1, 0x00000002U, 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U ); HW_DEFINE_SIMPLE( HW_B2, 0x00000004U, 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U ); @@ -85,7 +88,9 @@ HW_DEFINE_SIMPLE( HW_B29, 0x20000000U, 0x00000000U, 0x00000000U, 0x00000000U, HW_DEFINE_SIMPLE( HW_B30, 0x40000000U, 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U ); HW_DEFINE_SIMPLE( HW_B31, 0x80000000U, 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U ); -/* high bytes of lower word registers - byte 1 */ +/* + * high bytes of lower word registers - byte 1 + */ HW_DEFINE_SIMPLE( HW_hb0, 0x00000000U, 0x00000001U, 0x00000000U, 0x00000000U, 0x00000000U ); HW_DEFINE_SIMPLE( HW_hb1, 0x00000000U, 0x00000002U, 0x00000000U, 0x00000000U, 0x00000000U ); HW_DEFINE_SIMPLE( HW_hb2, 0x00000000U, 0x00000004U, 0x00000000U, 0x00000000U, 0x00000000U ); @@ -119,7 +124,9 @@ HW_DEFINE_SIMPLE( HW_hb29, 0x00000000U, 0x20000000U, 0x00000000U, 0x00000000U, HW_DEFINE_SIMPLE( HW_hb30, 0x00000000U, 0x40000000U, 0x00000000U, 0x00000000U, 0x00000000U ); HW_DEFINE_SIMPLE( HW_hb31, 0x00000000U, 0x80000000U, 0x00000000U, 0x00000000U, 0x00000000U ); -/* upper word of dword registers - bytes 2 and 3 */ +/* + * upper word of dword registers - bytes 2 and 3 + */ HW_DEFINE_SIMPLE( HW_hw0, 0x00000000U, 0x00000000U, 0x00000001U, 0x00000000U, 0x00000000U ); HW_DEFINE_SIMPLE( HW_hw1, 0x00000000U, 0x00000000U, 0x00000002U, 0x00000000U, 0x00000000U ); HW_DEFINE_SIMPLE( HW_hw2, 0x00000000U, 0x00000000U, 0x00000004U, 0x00000000U, 0x00000000U ); @@ -153,7 +160,9 @@ HW_DEFINE_SIMPLE( HW_hw29, 0x00000000U, 0x00000000U, 0x20000000U, 0x00000000U, HW_DEFINE_SIMPLE( HW_hw30, 0x00000000U, 0x00000000U, 0x40000000U, 0x00000000U, 0x00000000U ); HW_DEFINE_SIMPLE( HW_hw31, 0x00000000U, 0x00000000U, 0x80000000U, 0x00000000U, 0x00000000U ); -/* floating point registers */ +/* + * floating point registers + */ HW_DEFINE_SIMPLE( HW_F0, 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, 0x00000001U ); HW_DEFINE_SIMPLE( HW_F1, 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, 0x00000002U ); HW_DEFINE_SIMPLE( HW_F2, 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, 0x00000004U ); @@ -201,7 +210,6 @@ HW_DEFINE_SIMPLE( HW_SEGS, 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U, #define HW_DEFINE_COMPOUND( x ) \ enum { \ - \ /* word sized registers (halfword in MIPS parlance) */\ HW_W0_##x = (HW_B0_##x+HW_hb0_##x), \ HW_W1_##x = (HW_B1_##x+HW_hb1_##x), \ @@ -282,7 +290,7 @@ HW_Q16_##x = (HW_D16_##x+HW_D17_##x), \ HW_Q18_##x = (HW_D18_##x+HW_D19_##x), \ HW_Q20_##x = (HW_D20_##x+HW_D21_##x), \ HW_Q22_##x = (HW_D22_##x+HW_D23_##x), \ -HW_Q24_##x = (HW_D12_##x+HW_D25_##x), \ +HW_Q24_##x = (HW_D24_##x+HW_D25_##x), \ \ HW_R0_##x = (HW_W0_##x+HW_hw0_##x), \ HW_R1_##x = (HW_W1_##x+HW_hw1_##x), \ From 9cddcbd8c166b251280b4809a348de637a485cdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Mal=C3=A1k?= Date: Sun, 8 Oct 2023 18:53:19 +0200 Subject: [PATCH 218/258] cleanup cg code --- bld/cg/intel/c/i87exp.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/bld/cg/intel/c/i87exp.c b/bld/cg/intel/c/i87exp.c index b326d27ae4..446c2bc358 100644 --- a/bld/cg/intel/c/i87exp.c +++ b/bld/cg/intel/c/i87exp.c @@ -221,11 +221,7 @@ bool FPStackReg( name *reg_name ) { int reg_num; - if( reg_name == NULL - || reg_name->n.class != N_REGISTER - || !HW_COvlap( reg_name->r.reg, HW_FLTS ) ) - return( false ); - reg_num = FPRegTrans( reg_name->r.reg ); + reg_num = FPRegNum( reg_name->r.reg ); if( reg_num == -1 ) return( false ); if( reg_num < Max87Stk ) From ca39f2069ef63e15cb09b1a8f5a5fb481aefb293 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Sun, 8 Oct 2023 19:10:51 +0200 Subject: [PATCH 219/258] move FP register info functions and data to x86enc.c file put all registers definitions to x86enc.c file to enable consolidation of all registers into single array and add other registers information as debug info etc. --- bld/cg/intel/c/i87exp.c | 16 ++--------- bld/cg/intel/c/i87opt.c | 1 + bld/cg/intel/c/i87reg.c | 50 ++++---------------------------- bld/cg/intel/c/i87sched.c | 3 +- bld/cg/intel/c/x86enc.c | 60 +++++++++++++++++++++++++++++++++++++++ bld/cg/intel/h/x86enc.h | 5 +++- bld/cg/intel/h/x86regn.h | 36 +++++++++++++++++++++++ bld/cg/intel/h/x87.h | 5 +--- 8 files changed, 111 insertions(+), 65 deletions(-) create mode 100644 bld/cg/intel/h/x86regn.h diff --git a/bld/cg/intel/c/i87exp.c b/bld/cg/intel/c/i87exp.c index 446c2bc358..84a07450cd 100644 --- a/bld/cg/intel/c/i87exp.c +++ b/bld/cg/intel/c/i87exp.c @@ -49,6 +49,7 @@ #include "revcond.h" #include "temps.h" #include "opctable.h" +#include "x86regn.h" #include "feprotos.h" @@ -221,7 +222,7 @@ bool FPStackReg( name *reg_name ) { int reg_num; - reg_num = FPRegNum( reg_name->r.reg ); + reg_num = FPRegNum( reg_name ); if( reg_num == -1 ) return( false ); if( reg_num < Max87Stk ) @@ -230,19 +231,6 @@ bool FPStackReg( name *reg_name ) } -int FPRegNum( name *reg_name ) -/********************************* - given a name, return the 8087 register number (0-7) or -1 if - it isn't an 8087 register -*/ -{ - if( reg_name == NULL - || reg_name->n.class != N_REGISTER - || !HW_COvlap( reg_name->r.reg, HW_FLTS ) ) - return( -1 ); - return( FPRegTrans( reg_name->r.reg ) ); -} - instruction *PrefFLDOp( instruction *ins, operand_type op, name *opnd ) /*********************************************************************/ { diff --git a/bld/cg/intel/c/i87opt.c b/bld/cg/intel/c/i87opt.c index 92ea01c60a..54cde1e1f0 100644 --- a/bld/cg/intel/c/i87opt.c +++ b/bld/cg/intel/c/i87opt.c @@ -53,6 +53,7 @@ #include "inssched.h" #include "bldins.h" #include "liveinfo.h" +#include "x86regn.h" void FPParms( void ) diff --git a/bld/cg/intel/c/i87reg.c b/bld/cg/intel/c/i87reg.c index d7e720085b..61cb2b1f2e 100644 --- a/bld/cg/intel/c/i87reg.c +++ b/bld/cg/intel/c/i87reg.c @@ -48,19 +48,9 @@ #include "escape.h" #include "pcencode.h" #include "liveinfo.h" +#include "x86regn.h" -static hw_reg_set FPRegs[] = { - HW_D( HW_ST0 ), - HW_D( HW_ST1 ), - HW_D( HW_ST2 ), - HW_D( HW_ST3 ), - HW_D( HW_ST4 ), - HW_D( HW_ST5 ), - HW_D( HW_ST6 ), - HW_D( HW_ST7 ) -}; - static fp_patches FPPatchType; static byte StackReq8087[LAST_IFUNC - FIRST_IFUNC + 1] = { @@ -154,42 +144,12 @@ void FPPatchTypeRef( void ) } } -int FPRegTrans( hw_reg_set reg ) -/******************************/ -{ - int i; - - for( i = 0; i < 8; i++ ) { - if( HW_Equal( reg, FPRegs[i] ) ) { - return( i ); - } - } - return( -1 ); -} - -int Count87Regs( hw_reg_set regs ) -/*********************************************** - Count the number of 8087 registers named in hw_reg_set "regs". -*/ -{ - int count; - int i; - - count = 0; - for( i = 0; i < 8; i++ ) { - if( HW_Ovlap( FPRegs[i], regs ) ) { - ++count; - } - } - return( count ); -} - void SetFPParmsUsed( call_state *state, int parms ) /*************************************************/ { HW_CTurnOff( state->parm.used, HW_FLTS ); while( parms-- > 0 ) { - HW_TurnOn( state->parm.used, FPRegs[parms] ); + HW_TurnOn( state->parm.used, GetFPReg( parms ) ); } } @@ -198,7 +158,7 @@ name *ST( int num ) return an N_REGISTER for ST(num) */ { - return( AllocRegName( FPRegs[num] ) ); + return( AllocRegName( GetFPReg( num ) ) ); } @@ -267,7 +227,7 @@ static bool AssignFPResult( block *blk, instruction *ins, int *stk_level ) if( MathOpsBlowStack( conf, *stk_level ) ) return( false ); ++*stk_level; - need_live_update = AssignARegister( conf, FPRegs[*stk_level] ); + need_live_update = AssignARegister( conf, GetFPReg( *stk_level ) ); return( need_live_update ); } @@ -286,7 +246,7 @@ static void AssignFPOps( instruction *ins, int *stk_level ) /* Now check operands ... bump down stack level for each*/ /* top of stack operand that will be popped (may be more than one)*/ if( _OpIsCall( ins->head.opcode ) ) { - *stk_level -= Count87Regs( ins->operands[CALL_OP_USED]->r.reg ); + *stk_level -= CountFPRegs( ins->operands[CALL_OP_USED]->r.reg ); } else { old_level = *stk_level; for( i = ins->num_operands; i-- > 0; ) { diff --git a/bld/cg/intel/c/i87sched.c b/bld/cg/intel/c/i87sched.c index 51faebacdf..e004ad6636 100644 --- a/bld/cg/intel/c/i87sched.c +++ b/bld/cg/intel/c/i87sched.c @@ -47,6 +47,7 @@ #include "optab.h" #include "fixindex.h" #include "revcond.h" +#include "x86regn.h" static const opcode_entry RFST[1] = { @@ -902,7 +903,7 @@ static void ReOrderForCall( instruction *ins ) int i; int count; - count = Count87Regs( ins->operands[CALL_OP_USED]->r.reg ); + count = CountFPRegs( ins->operands[CALL_OP_USED]->r.reg ); XchForCall( ins, count - 1 ); for( i = 0; i < count; ++i ) { PopStack( ins ); diff --git a/bld/cg/intel/c/x86enc.c b/bld/cg/intel/c/x86enc.c index 90a3248c36..b9fccbf16a 100644 --- a/bld/cg/intel/c/x86enc.c +++ b/bld/cg/intel/c/x86enc.c @@ -95,6 +95,17 @@ static hw_reg_set SegTab[] = { #undef _SR_ }; +static hw_reg_set FPRegs[] = { + HW_D( HW_ST0 ), + HW_D( HW_ST1 ), + HW_D( HW_ST2 ), + HW_D( HW_ST3 ), + HW_D( HW_ST4 ), + HW_D( HW_ST5 ), + HW_D( HW_ST6 ), + HW_D( HW_ST7 ) +}; + /* routines that maintain instruction buffers*/ void Format( oc_class class ) @@ -325,6 +336,55 @@ static byte RegTrans( hw_reg_set regs ) { return( i ); } +static int FPRegTrans( hw_reg_set reg ) +/*************************************/ +{ + int i; + + for( i = 0; i < 8; i++ ) { + if( HW_Equal( reg, FPRegs[i] ) ) { + return( i ); + } + } + return( -1 ); +} + +int FPRegNum( name *reg_name ) +/********************************* + given a name, return the 8087 register number (0-7) or -1 if + it isn't an 8087 register +*/ +{ + if( reg_name == NULL + || reg_name->n.class != N_REGISTER + || !HW_COvlap( reg_name->r.reg, HW_FLTS ) ) + return( -1 ); + return( FPRegTrans( reg_name->r.reg ) ); +} + +hw_reg_set GetFPReg( int idx ) +{ + return( FPRegs[idx] ); +} + + +int CountFPRegs( hw_reg_set regs ) +/*********************************************** + Count the number of 8087 registers named in hw_reg_set "regs". +*/ +{ + int count; + int i; + + count = 0; + for( i = 0; i < 8; i++ ) { + if( HW_Ovlap( FPRegs[i], regs ) ) { + ++count; + } + } + return( count ); +} + #if _TARGET & _TARG_80386 static bool NeedOpndSize( instruction *ins ) { /************************************************* diff --git a/bld/cg/intel/h/x86enc.h b/bld/cg/intel/h/x86enc.h index 80b6301e21..045a900e82 100644 --- a/bld/cg/intel/h/x86enc.h +++ b/bld/cg/intel/h/x86enc.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -31,6 +31,9 @@ ****************************************************************************/ +#include "x86regn.h" + + extern void ReFormat( oc_class class ); extern void AddByte( byte b ); extern void AddToTemp( byte b ); diff --git a/bld/cg/intel/h/x86regn.h b/bld/cg/intel/h/x86regn.h new file mode 100644 index 0000000000..3e31b07387 --- /dev/null +++ b/bld/cg/intel/h/x86regn.h @@ -0,0 +1,36 @@ +/**************************************************************************** +* +* Open Watcom Project +* +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. +* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. +* +* ======================================================================== +* +* This file contains Original Code and/or Modifications of Original +* Code as defined in and that are subject to the Sybase Open Watcom +* Public License version 1.0 (the 'License'). You may not use this file +* except in compliance with the License. BY USING THIS FILE YOU AGREE TO +* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is +* provided with the Original Code and Modifications, and is also +* available at www.sybase.com/developer/opensource. +* +* The Original Code and all software distributed under the License are +* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM +* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR +* NON-INFRINGEMENT. Please see the License for the specific language +* governing rights and limitations under the License. +* +* ======================================================================== +* +* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE +* DESCRIBE IT HERE! +* +****************************************************************************/ + + +extern hw_reg_set GetFPReg( int idx ); +extern int CountFPRegs( hw_reg_set regs ); +extern int FPRegNum( name *reg_name ); diff --git a/bld/cg/intel/h/x87.h b/bld/cg/intel/h/x87.h index bda3ff148c..62e36542c3 100644 --- a/bld/cg/intel/h/x87.h +++ b/bld/cg/intel/h/x87.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2017-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2017-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -36,7 +36,6 @@ /* i87exp.c*/ -extern int FPRegNum( name *reg_name ); extern instruction *PrefFLDOp( instruction *ins, operand_type op, name *opnd ); extern bool FPResultNotNeeded( instruction *ins ); extern instruction *SuffFSTPRes( instruction *ins, name *opnd, result_type res ); @@ -59,8 +58,6 @@ extern void SetFPParmsUsed( call_state *state, int parms ); extern name *ST( int i ); extern void FPInitStkReq( void ); extern int FPStkReq( instruction *ins ); -extern int Count87Regs( hw_reg_set regs ); -extern int FPRegTrans( hw_reg_set reg ); extern void SetFPPatchSegm( int i ); extern void SetFPPatchType( fp_patches type ); extern void FPPatchTypeRef( void ); From 5e3e1c076712764f9ae92428cb96431ca5cf331b Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Sun, 8 Oct 2023 20:43:27 +0200 Subject: [PATCH 220/258] cleanup cg code move all Intel architecture register mapping processing into x86enc.c source file --- bld/cg/h/cg.h | 6 +-- bld/cg/intel/c/wvsupp.c | 41 ++++++-------------- bld/cg/intel/c/x86dfsup.c | 80 ++++---------------------------------- bld/cg/intel/c/x86enc.c | 81 +++++++++++++++++++++++++++++++++++++++ bld/cg/intel/h/wvdbg.h | 9 +---- bld/cg/intel/h/x86regn.h | 16 ++++++++ 6 files changed, 119 insertions(+), 114 deletions(-) diff --git a/bld/cg/h/cg.h b/bld/cg/h/cg.h index e718f0ad2e..dd740722a1 100644 --- a/bld/cg/h/cg.h +++ b/bld/cg/h/cg.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -104,8 +104,8 @@ typedef int level_depth; typedef unsigned_32 cg_linenum; -typedef unsigned objoffset; -typedef unsigned objhandle; +typedef size_t objoffset; +typedef size_t objhandle; #define INVALID_OBJHANDLE 0 /* symbolic debugging type handles */ diff --git a/bld/cg/intel/c/wvsupp.c b/bld/cg/intel/c/wvsupp.c index 32a6d42e0b..fae376b414 100644 --- a/bld/cg/intel/c/wvsupp.c +++ b/bld/cg/intel/c/wvsupp.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -40,30 +40,11 @@ #include "regset.h" #include "rgtbl.h" #include "x86dbsup.h" +#include "x86regn.h" #include "wvsupp.h" #include "cgprotos.h" -static hw_reg_set HWRegValues[] = { - #define pick(name,ci,start,len) HW_D( HW_##name ), - #include "watdbreg.h" - #undef pick -}; - -static int RegIndex( hw_reg_set hw_reg ) -/***************************************/ -{ - int i; - - for( i = 0; i < sizeof( HWRegValues ) / sizeof( HWRegValues[0] ); i++ ) { - if( HW_Equal( HWRegValues[i], hw_reg ) ) { - return( i ); - } - } - return( -1 ); -} - - static uint MultiReg( register_name *reg ) /********************************************/ { @@ -73,10 +54,10 @@ static uint MultiReg( register_name *reg ) hw_reg = reg->reg; #if _TARGET & _TARG_8086 if( HW_CEqual( hw_reg, HW_ABCD ) ) { - BuffByte( REG_DX ); - BuffByte( REG_CX ); - BuffByte( REG_BX ); - BuffByte( REG_AX ); + BuffByte( WV_REG_DX ); + BuffByte( WV_REG_CX ); + BuffByte( WV_REG_BX ); + BuffByte( WV_REG_AX ); return( 4 ); } #endif @@ -86,13 +67,13 @@ static uint MultiReg( register_name *reg ) hw_reg = Low64Reg( hw_reg ); #endif if( HW_CEqual( hw_reg, HW_EMPTY ) ) { - BuffByte( RegIndex( reg->reg ) ); + BuffByte( RegTransWV( reg->reg ) ); return( 1 ); } else { - BuffByte( RegIndex( hw_reg ) ); + BuffByte( RegTransWV( hw_reg ) ); tmp = reg->reg; HW_TurnOff( tmp, hw_reg ); - BuffByte( RegIndex( tmp ) ); + BuffByte( RegTransWV( tmp ) ); return( 2 ); } } @@ -140,7 +121,7 @@ static void DoLocDump( dbg_loc loc ) } break; case LOC_REG: - reg = RegIndex( loc->u.be_sym->r.reg ); + reg = RegTransWV( loc->u.be_sym->r.reg ); if( reg > 15 ) { patch = BuffLoc(); BuffByte( 0 ); @@ -155,7 +136,7 @@ static void DoLocDump( dbg_loc loc ) // suitable. For now, output a no location. BuffByte( 0 ); } else { - reg = RegIndex( loc->u.be_sym->r.reg ); + reg = RegTransWV( loc->u.be_sym->r.reg ); if( reg < 0 ) { /* register not found */ BuffByte( loc->class + 1 ); /* assumes ..._FAR is one greater*/ MultiReg( &loc->u.be_sym->r ); diff --git a/bld/cg/intel/c/x86dfsup.c b/bld/cg/intel/c/x86dfsup.c index 369e54eb3e..13ae2dd4ef 100644 --- a/bld/cg/intel/c/x86dfsup.c +++ b/bld/cg/intel/c/x86dfsup.c @@ -52,26 +52,15 @@ #include "dbsyms.h" #include "dfsyms.h" #include "x86data.h" +#include "x86regn.h" #include "cgprotos.h" -typedef enum { - #define pick(id,name,ci,start,len) DW_REG_ ## id, - #include "dwregx86.h" - #undef pick - DW_REG_MAX -} dw_regs; - struct dbg_seg_names { const char *seg_name; const char *class_name; }; -struct reg_map { - hw_reg_set reg; - dw_regs dwarf; -}; - static struct dbg_seg_names DwarfSegNames[DW_DEBUG_MAX] = { { ".debug_info", "DWARF" }, { ".debug_pubnames", "DWARF" }, @@ -84,47 +73,6 @@ static struct dbg_seg_names DwarfSegNames[DW_DEBUG_MAX] = { { ".WATCOM_references", "DWARF" } }; -static struct reg_map HWRegValues[] = { - { HW_D( HW_AL ), DW_REG_AL }, - { HW_D( HW_AH ), DW_REG_AH }, - { HW_D( HW_BL ), DW_REG_BL }, - { HW_D( HW_BH ), DW_REG_BH }, - { HW_D( HW_CL ), DW_REG_CL }, - { HW_D( HW_CH ), DW_REG_CH }, - { HW_D( HW_DL ), DW_REG_DL }, - { HW_D( HW_DH ), DW_REG_DH }, - { HW_D( HW_AX ), DW_REG_AX }, - { HW_D( HW_BX ), DW_REG_BX }, - { HW_D( HW_CX ), DW_REG_CX }, - { HW_D( HW_DX ), DW_REG_DX }, - { HW_D( HW_SI ), DW_REG_SI }, - { HW_D( HW_DI ), DW_REG_DI }, - { HW_D( HW_BP ), DW_REG_BP }, - { HW_D( HW_SP ), DW_REG_SP }, - { HW_D( HW_CS ), DW_REG_CS }, - { HW_D( HW_SS ), DW_REG_SS }, - { HW_D( HW_DS ), DW_REG_DS }, - { HW_D( HW_ES ), DW_REG_ES }, - { HW_D( HW_ST0 ), DW_REG_ST0 }, - { HW_D( HW_ST1 ), DW_REG_ST1 }, - { HW_D( HW_ST2 ), DW_REG_ST2 }, - { HW_D( HW_ST3 ), DW_REG_ST3 }, - { HW_D( HW_ST4 ), DW_REG_ST4 }, - { HW_D( HW_ST5 ), DW_REG_ST5 }, - { HW_D( HW_ST6 ), DW_REG_ST6 }, - { HW_D( HW_ST7 ), DW_REG_ST7 }, - { HW_D( HW_EAX ), DW_REG_EAX }, - { HW_D( HW_EBX ), DW_REG_EBX }, - { HW_D( HW_ECX ), DW_REG_ECX }, - { HW_D( HW_EDX ), DW_REG_EDX }, - { HW_D( HW_ESI ), DW_REG_ESI }, - { HW_D( HW_EDI ), DW_REG_EDI }, - { HW_D( HW_EBP ), DW_REG_EBP }, - { HW_D( HW_ESP ), DW_REG_ESP }, - { HW_D( HW_FS ), DW_REG_FS }, - { HW_D( HW_GS ), DW_REG_GS } -}; - void DFDefSegs( void ) /***********************/ @@ -141,20 +89,6 @@ void DFDefSegs( void ) } } -static dw_regs DFRegMap( hw_reg_set hw_reg ) -/*******************************************/ -{ - int i; - - for( i = 0; i < sizeof( HWRegValues ) / sizeof( HWRegValues[0] ); i++ ) { - if( HW_Equal( HWRegValues[i].reg, hw_reg ) ) { - return( HWRegValues[i].dwarf ); - } - } - Zoiks( ZOIKS_085 );/* reg not found */ - return( DW_REG_MAX ); -} - void DFOutReg( dw_loc_id locid, name *reg ) /*******************************************/ { @@ -182,14 +116,14 @@ void DFOutReg( dw_loc_id locid, name *reg ) hw_low = Low64Reg( hw_reg ); #endif if( HW_CEqual( hw_low, HW_EMPTY ) ) { - dw_reg = DFRegMap( hw_reg ); + dw_reg = RegTransDW( hw_reg ); DWLocReg( Client, locid, dw_reg ); } else { - dw_reg = DFRegMap( hw_low ); + dw_reg = RegTransDW( hw_low ); DWLocReg( Client, locid, dw_reg ); DWLocPiece( Client, locid, WD ); HW_TurnOff( hw_reg, hw_low ); - dw_reg = DFRegMap( hw_reg ); + dw_reg = RegTransDW( hw_reg ); DWLocReg( Client, locid, dw_reg ); DWLocPiece( Client, locid, WD ); } @@ -200,7 +134,7 @@ void DFOutRegInd( dw_loc_id locid, name *reg ) { dw_regs dw_reg; - dw_reg = DFRegMap( reg->r.reg ); + dw_reg = RegTransDW( reg->r.reg ); DWLocOp( Client, locid, DW_LOC_breg, dw_reg, 0 ); } @@ -211,7 +145,7 @@ uint DFStkReg( void ) hw_reg_set stk; stk = StackReg(); - dw_reg = DFRegMap( stk ); + dw_reg = RegTransDW( stk ); return( dw_reg ); } @@ -222,7 +156,7 @@ uint DFDisplayReg( void ) hw_reg_set dsp; dsp = DisplayReg(); - dw_reg = DFRegMap( dsp ); + dw_reg = RegTransDW( dsp ); return( dw_reg ); } diff --git a/bld/cg/intel/c/x86enc.c b/bld/cg/intel/c/x86enc.c index b9fccbf16a..7ee8729dee 100644 --- a/bld/cg/intel/c/x86enc.c +++ b/bld/cg/intel/c/x86enc.c @@ -106,6 +106,58 @@ static hw_reg_set FPRegs[] = { HW_D( HW_ST7 ) }; +struct reg_map { + hw_reg_set reg; + dw_regs dwarf; +}; + +static struct reg_map DWHWRegValues[] = { + { HW_D( HW_AL ), DW_REG_AL }, + { HW_D( HW_AH ), DW_REG_AH }, + { HW_D( HW_BL ), DW_REG_BL }, + { HW_D( HW_BH ), DW_REG_BH }, + { HW_D( HW_CL ), DW_REG_CL }, + { HW_D( HW_CH ), DW_REG_CH }, + { HW_D( HW_DL ), DW_REG_DL }, + { HW_D( HW_DH ), DW_REG_DH }, + { HW_D( HW_AX ), DW_REG_AX }, + { HW_D( HW_BX ), DW_REG_BX }, + { HW_D( HW_CX ), DW_REG_CX }, + { HW_D( HW_DX ), DW_REG_DX }, + { HW_D( HW_SI ), DW_REG_SI }, + { HW_D( HW_DI ), DW_REG_DI }, + { HW_D( HW_BP ), DW_REG_BP }, + { HW_D( HW_SP ), DW_REG_SP }, + { HW_D( HW_CS ), DW_REG_CS }, + { HW_D( HW_SS ), DW_REG_SS }, + { HW_D( HW_DS ), DW_REG_DS }, + { HW_D( HW_ES ), DW_REG_ES }, + { HW_D( HW_ST0 ), DW_REG_ST0 }, + { HW_D( HW_ST1 ), DW_REG_ST1 }, + { HW_D( HW_ST2 ), DW_REG_ST2 }, + { HW_D( HW_ST3 ), DW_REG_ST3 }, + { HW_D( HW_ST4 ), DW_REG_ST4 }, + { HW_D( HW_ST5 ), DW_REG_ST5 }, + { HW_D( HW_ST6 ), DW_REG_ST6 }, + { HW_D( HW_ST7 ), DW_REG_ST7 }, + { HW_D( HW_EAX ), DW_REG_EAX }, + { HW_D( HW_EBX ), DW_REG_EBX }, + { HW_D( HW_ECX ), DW_REG_ECX }, + { HW_D( HW_EDX ), DW_REG_EDX }, + { HW_D( HW_ESI ), DW_REG_ESI }, + { HW_D( HW_EDI ), DW_REG_EDI }, + { HW_D( HW_EBP ), DW_REG_EBP }, + { HW_D( HW_ESP ), DW_REG_ESP }, + { HW_D( HW_FS ), DW_REG_FS }, + { HW_D( HW_GS ), DW_REG_GS } +}; + +static hw_reg_set WVHWRegValues[] = { + #define pick(name,ci,start,len) HW_D( HW_##name ), + #include "watdbreg.h" + #undef pick +}; + /* routines that maintain instruction buffers*/ void Format( oc_class class ) @@ -349,6 +401,35 @@ static int FPRegTrans( hw_reg_set reg ) return( -1 ); } +int RegTransDW( hw_reg_set reg ) +/******************************/ +{ + int i; + + for( i = 0; i < sizeof( DWHWRegValues ) / sizeof( DWHWRegValues[0] ); i++ ) { + if( HW_Equal( DWHWRegValues[i].reg, reg ) ) { + return( DWHWRegValues[i].dwarf ); + } + } + Zoiks( ZOIKS_085 ); /* reg not found */ + return( DW_REG_END ); +} + + +int RegTransWV( hw_reg_set reg ) +/******************************/ +{ + int i; + + for( i = 0; i < sizeof( WVHWRegValues ) / sizeof( WVHWRegValues[0] ); i++ ) { + if( HW_Equal( WVHWRegValues[i], reg ) ) { + return( i ); + } + } + return( -1 ); +} + + int FPRegNum( name *reg_name ) /********************************* given a name, return the 8087 register number (0-7) or -1 if diff --git a/bld/cg/intel/h/wvdbg.h b/bld/cg/intel/h/wvdbg.h index 870c051d2b..dc64012642 100644 --- a/bld/cg/intel/h/wvdbg.h +++ b/bld/cg/intel/h/wvdbg.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -33,13 +33,6 @@ /* aligned */ - -enum { - #define pick(name,ci,start,len) REG_##name, - #include "watdbreg.h" - #undef pick -}; - /* % */ /* % Type constants */ /* % */ diff --git a/bld/cg/intel/h/x86regn.h b/bld/cg/intel/h/x86regn.h index 3e31b07387..51b2397934 100644 --- a/bld/cg/intel/h/x86regn.h +++ b/bld/cg/intel/h/x86regn.h @@ -31,6 +31,22 @@ ****************************************************************************/ +typedef enum { + #define pick(id,ci,start,len) WV_REG_ ## id, + #include "watdbreg.h" + #undef pick + WV_REG_END +} wv_regs; + +typedef enum { + #define pick(id,name,ci,start,len) DW_REG_ ## id, + #include "dwregx86.h" + #undef pick + DW_REG_END +} dw_regs; + extern hw_reg_set GetFPReg( int idx ); extern int CountFPRegs( hw_reg_set regs ); extern int FPRegNum( name *reg_name ); +extern int RegTransDW( hw_reg_set reg ); +extern int RegTransWV( hw_reg_set reg ); From 0a44ced9bd924756d5fe7759ab986a36bfd93a9d Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Sun, 8 Oct 2023 21:11:43 +0200 Subject: [PATCH 221/258] correct type mismatch --- bld/cg/h/procdef.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bld/cg/h/procdef.h b/bld/cg/h/procdef.h index 1d4ecb1cc8..7709efb0a0 100644 --- a/bld/cg/h/procdef.h +++ b/bld/cg/h/procdef.h @@ -53,8 +53,8 @@ typedef struct parm_state { hw_reg_set *curr_entry; type_length offset; #if _TARGET & _TARG_PPC - uint_32 gr; - uint_32 fr; + unsigned gr; + unsigned fr; #endif } parm_state; From b19cc76949d5b49a810723f2b0572efde31b3863 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Sun, 8 Oct 2023 22:14:29 +0200 Subject: [PATCH 222/258] cleanup cg code --- bld/cg/intel/c/x86enc.c | 500 +++++++++++++++++++++------------------- 1 file changed, 259 insertions(+), 241 deletions(-) diff --git a/bld/cg/intel/c/x86enc.c b/bld/cg/intel/c/x86enc.c index 7ee8729dee..395746ce41 100644 --- a/bld/cg/intel/c/x86enc.c +++ b/bld/cg/intel/c/x86enc.c @@ -162,10 +162,10 @@ static hw_reg_set WVHWRegValues[] = { void Format( oc_class class ) /******************************* - Get Temp and Inst ready to accept instructions. Each instruction is - formatted into Inst, transferred into Temp (as an opcode_entry) and - then dumped into the peephole optimizer. -*/ + * Get Temp and Inst ready to accept instructions. Each instruction is + * formatted into Inst, transferred into Temp (as an opcode_entry) and + * then dumped into the peephole optimizer. + */ { SetFPPatchType( FPP_NONE ); Temp.hdr.class = class; @@ -178,16 +178,16 @@ void Format( oc_class class ) void ReFormat( oc_class class ) /********************************* - Change the class of Temp -*/ + * Change the class of Temp + */ { Temp.hdr.class = class; } void AddByte( byte b ) /************************ - Add a byte to Inst[] -*/ + * Add a byte to Inst[] + */ { if( b == ESC ) { Inst[ICur++] = b; @@ -198,8 +198,8 @@ void AddByte( byte b ) void AddToTemp( byte b ) /******************************** - Add a byte to the end of Temp -*/ + * Add a byte to the end of Temp + */ { if( b == ESC ) { Temp.data[Temp.hdr.reclen++ - offsetof( template, data )] = b; @@ -210,16 +210,16 @@ void AddToTemp( byte b ) void EmitByte( byte b ) /************************** - Plop a byte into Inst[] -*/ + * Plop a byte into Inst[] + */ { Inst[ICur++] = b; } void EmitPtr( pointer p ) /***************************** - Plop a pointer into Inst[] -*/ + * Plop a pointer into Inst[] + */ { *(pointer *)(Inst + ICur) = p; ICur += sizeof( pointer ); @@ -227,27 +227,27 @@ void EmitPtr( pointer p ) void EmitSegId( segment_id segid ) /************************************ - Plop a segment_id into Inst[] -*/ + * Plop a segment_id into Inst[] + */ { *(segment_id *)(Inst + ICur) = segid; ICur += sizeof( segment_id ); } void EmitOffset( offset i ) -/*************************************** - Plop an "offset" int Inst[] (a machine word) -*/ +/***************************** + * Plop an "offset" int Inst[] (a machine word) + */ { *(offset *)(Inst + ICur) = i; ICur += sizeof( offset ); } -static void TransferIns( void ) { -/************************************ - Transfer an instruction from Inst[] to Temp -*/ - +static void TransferIns( void ) +/********************************** + * Transfer an instruction from Inst[] to Temp + */ +{ unsigned i; unsigned j; @@ -265,9 +265,9 @@ static void TransferIns( void ) { } void EjectInst( void ) -/********************************** - Dump the current instruction into the peephole optimizer -*/ +/************************ + * Dump the current instruction into the peephole optimizer + */ { TransferIns(); ICur = 0; @@ -276,9 +276,9 @@ void EjectInst( void ) } void Finalize( void ) -/********************************* - Invoked by macro _Emit. Spits Temp into the peephole optimizer -*/ +/*********************** + * Invoked by macro _Emit. Spits Temp into the peephole optimizer + */ { EjectInst(); FPPatchTypeRef(); @@ -288,13 +288,13 @@ void Finalize( void ) } -static void LayInitial( instruction *ins, gentype gen ) { -/************************************************************ - Do some really magical jiggery pokery based on "gen" to get the - right opcode int Inst[]. See PCCodeTable if you want, but this is - not for the faint of heart! -*/ - +static void LayInitial( instruction *ins, gentype gen ) +/********************************************************** + * Do some really magical jiggery pokery based on "gen" to get the + * right opcode int Inst[]. See PCCodeTable if you want, but this is + * not for the faint of heart! + */ +{ int index; pccode_def *table; @@ -349,11 +349,11 @@ static void LayInitial( instruction *ins, gentype gen ) { } } -static byte SegTrans( hw_reg_set regs ) { -/******************************************** - Return the encoding of a segment register name -*/ - +static byte SegTrans( hw_reg_set regs ) +/****************************************** + * Return the encoding of a segment register name + */ +{ byte i; HW_COnlyOn( regs, HW_SEGS ); @@ -368,11 +368,11 @@ static byte SegTrans( hw_reg_set regs ) { return( i ); } -static byte RegTrans( hw_reg_set regs ) { -/******************************************** - Return the encoding of a register name -*/ - +static byte RegTrans( hw_reg_set regs ) +/****************************************** + * Return the encoding of a register name + */ +{ byte i; HW_CTurnOff( regs, HW_SEGS ); @@ -432,15 +432,16 @@ int RegTransWV( hw_reg_set reg ) int FPRegNum( name *reg_name ) /********************************* - given a name, return the 8087 register number (0-7) or -1 if - it isn't an 8087 register -*/ -{ - if( reg_name == NULL - || reg_name->n.class != N_REGISTER - || !HW_COvlap( reg_name->r.reg, HW_FLTS ) ) - return( -1 ); - return( FPRegTrans( reg_name->r.reg ) ); + * given a name, return the 8087 register number (0-7) or -1 if + * it isn't an 8087 register + */ +{ + if( reg_name != NULL + && reg_name->n.class == N_REGISTER + && HW_COvlap( reg_name->r.reg, HW_FLTS ) ) { + return( FPRegTrans( reg_name->r.reg ) ); + } + return( -1 ); } hw_reg_set GetFPReg( int idx ) @@ -451,8 +452,8 @@ hw_reg_set GetFPReg( int idx ) int CountFPRegs( hw_reg_set regs ) /*********************************************** - Count the number of 8087 registers named in hw_reg_set "regs". -*/ + * Count the number of 8087 registers named in hw_reg_set "regs". + */ { int count; int i; @@ -467,10 +468,11 @@ int CountFPRegs( hw_reg_set regs ) } #if _TARGET & _TARG_80386 -static bool NeedOpndSize( instruction *ins ) { -/************************************************* - Do we REALLY, REALLY need the operand size override. -*/ +static bool NeedOpndSize( instruction *ins ) +/*********************************************** + * Do we REALLY, REALLY need the operand size override. + */ +{ opcnt i; hw_reg_set result_reg; hw_reg_set full_reg; @@ -492,13 +494,17 @@ static bool NeedOpndSize( instruction *ins ) { return( true ); switch( ins->result->n.class ) { case N_TEMP: - /* it's OK to store a DWORD into a WORD temp because there's always - two bytes of slack on the stack */ + /* + * it's OK to store a DWORD into a WORD temp because there's always + * two bytes of slack on the stack + */ if( ins->result->t.alias != ins->result ) return( true ); break; case N_REGISTER: - /* check that it's OK to trash high word of register */ + /* + * check that it's OK to trash high word of register + */ next = ins->head.next; if( next == NULL ) return( true ); @@ -512,8 +518,10 @@ static bool NeedOpndSize( instruction *ins ) { return( true ); } for( i = ins->num_operands; i-- > 0; ) { - /* Could be smarter here and allow N_MEMORY,N_INDEXED if - they're in DGROUP */ + /* + * Could be smarter here and allow N_MEMORY,N_INDEXED if + * they're in DGROUP + */ switch( ins->operands[i]->n.class ) { case N_TEMP: case N_REGISTER: @@ -529,12 +537,12 @@ static bool NeedOpndSize( instruction *ins ) { #endif -static bool LayOpndSize( instruction *ins, gentype gen ) { -/************************************************************* - Generate an operand size prefix if the instruction needs it - (Eg: MOV AX,DX need it in a USE32 segment) -*/ - +static bool LayOpndSize( instruction *ins, gentype gen ) +/*********************************************************** + * Generate an operand size prefix if the instruction needs it + * (Eg: MOV AX,DX need it in a USE32 segment) + */ +{ #if _TARGET & _TARG_8086 switch( ins->head.opcode ) { case OP_PUSH: @@ -597,20 +605,20 @@ static bool LayOpndSize( instruction *ins, gentype gen ) { #endif } -static void LayST( name *op ) { -/********************************** - add the ST(i) operand to a floating point instruction -*/ - +static void LayST( name *op ) +/******************************** + * add the ST(i) operand to a floating point instruction + */ +{ Inst[RMR] |= FPRegTrans( op->r.reg ); } -static void LayMF( name *op ) { -/********************************** - For a floating point instruction, add the qword ptr stuff -*/ - +static void LayMF( name *op ) +/******************************** + * For a floating point instruction, add the qword ptr stuff + */ +{ if( op->n.class != N_CONSTANT ) { switch( op->n.type_class ) { case FS: @@ -645,9 +653,9 @@ static void LayMF( name *op ) { } #if 1 -static void DoP5RegisterDivide( instruction *ins ) { -/******************************************************/ - +static void DoP5RegisterDivide( instruction *ins ) +/****************************************************/ +{ int st_reg; byte reverse; byte pop; @@ -720,9 +728,9 @@ static void DoP5RegisterDivide( instruction *ins ) { GenKillLabel( lbl_2 ); } -static void DoP5MemoryDivide( instruction *ins ) { -/****************************************************/ - +static void DoP5MemoryDivide( instruction *ins ) +/**************************************************/ +{ any_oc oc; rt_class rtindex; label_handle lbl; @@ -847,12 +855,13 @@ static void DoP5MemoryDivide( instruction *ins ) { GenKillLabel( lbl_2 ); } -static void DoP5Divide( instruction *ins ) { -/*********************************************** - Emit a most disgusting sequence of code to - test for the Pentium FDIV bug and call a - runtime routine to correct it. -*/ +static void DoP5Divide( instruction *ins ) +/********************************************* + * Emit a most disgusting sequence of code to + * test for the Pentium FDIV bug and call a + * runtime routine to correct it. + */ +{ bool used_ds = false; _Code; @@ -916,11 +925,11 @@ static void DoP5Divide( instruction *ins ) { #endif -static void SetCC(void) { -/****************************** - Generate code to set the condition codes based on an 8087 FCMP instruction -*/ - +static void SetCC( void ) +/**************************** + * Generate code to set the condition codes based on an 8087 FCMP instruction + */ +{ if( _IsEmulation() ) { _Emit; _Code; @@ -961,12 +970,14 @@ static void SetCC(void) { } -/* Lay Routines*/ +/* + * Lay Routines + */ void LayOpbyte( gen_opcode op ) /********************************** - Add a one byte opcode to Inst[] -*/ + * Add a one byte opcode to Inst[] + */ { Inst[KEY] = op & 0xff; ICur = 1; @@ -976,8 +987,8 @@ void LayOpbyte( gen_opcode op ) void LayOpword( gen_opcode op ) /********************************* - Add a 2 byte opcode to Inst[] -*/ + * Add a 2 byte opcode to Inst[] + */ { Inst[KEY] = op & 0xff; Inst[RMR] = (op >> 8) & 0xff; @@ -1002,67 +1013,67 @@ void LayW( type_class_def type_class ) } } -static void LayRegOp( name *r ) { -/************************************ - Add the register op to the instruction -*/ - +static void LayRegOp( name *r ) +/********************************** + * Add the register op to the instruction + */ +{ Inst[RMR] |= RegTrans( r->r.reg ) << S_RMR_REG; } void LayReg( hw_reg_set r ) /*************************************** - Add the register op to the instruction -*/ + * Add the register op to the instruction + */ { Inst[RMR] |= RegTrans( r ) << S_RMR_REG; } void LayRMRegOp( name *r ) -/************************************** - Add the register op to a MOD/RM instruction -*/ +/**************************** + * Add the register op to a MOD/RM instruction + */ { Inst[RMR] |= ( RegTrans( r->r.reg ) << S_RMR_RM ) + RMR_MOD_REG; } void LayRegRM( hw_reg_set r ) -/************************************** - Add the register op to a MOD/RM instruction -*/ +/******************************* + * Add the register op to a MOD/RM instruction + */ { Inst[RMR] |= ( RegTrans( r ) << S_RMR_RM ) + RMR_MOD_REG; } -static void LayACRegOp( name *r ) { -/************************************* - Add the other register op to a REG/AX (Accumulator) operation -*/ - +static void LayACRegOp( name *r ) +/************************************ + * Add the other register op to a REG/AX (Accumulator) operation + */ +{ Inst[KEY] |= RegTrans( r->r.reg ) << S_KEY_REG; } void LayRegAC( hw_reg_set r ) /***************************************** - Add the other register op to a REG/AX (Accumulator) operation -*/ + * Add the other register op to a REG/AX (Accumulator) operation + */ { Inst[KEY] |= RegTrans( r ) << S_KEY_REG; } -static void LaySROp( name *r ) { -/*********************************** - Add a segment register op -*/ - +static void LaySROp( name *r ) +/********************************* + * Add a segment register op + */ +{ Inst[RMR] |= SegTrans( r->r.reg ) << S_RMR_SR; } void GenSeg( hw_reg_set regs ) /****************************************** - Generate a segment override if we need one. regs if the full address. - For example, if regs is DS:BP, we need an override. SS:BP wouldn't -*/ + * Generate a segment override if we need one. regs if the full address. + * For example, if regs is DS:BP, we need an override. SS:BP wouldn't + */ { hw_reg_set segreg; int i; @@ -1084,7 +1095,9 @@ void GenSeg( hw_reg_set regs ) return; } } - /* produce segment override prefix*/ + /* + * produce segment override prefix + */ if( HW_COvlap( regs, HW_FS ) ) { AddToTemp( M_SEGFS ); } else if( HW_COvlap( regs, HW_GS ) ) { @@ -1104,9 +1117,9 @@ void GenSeg( hw_reg_set regs ) type_class_def OpndSize( hw_reg_set reg ) /*************************************************** - Generate an operand size prefix if we need it and return the - type_class of the register "reg" -*/ + * Generate an operand size prefix if we need it and return the + * type_class of the register "reg" + */ { if( HW_COvlap( reg, HW_SEGS ) ) return( U2 ); @@ -1127,11 +1140,11 @@ type_class_def OpndSize( hw_reg_set reg ) #endif } -static void PushSeg( hw_reg_set reg ) { -/****************************************** - PUSH segreg -*/ - +static void PushSeg( hw_reg_set reg ) +/**************************************** + * PUSH segreg + */ +{ if( HW_COvlap( reg, HW_FS ) ) { LayOpword( M_PUSHFS ); } else if( HW_COvlap( reg, HW_GS ) ) { @@ -1141,11 +1154,11 @@ static void PushSeg( hw_reg_set reg ) { } } -static void PopSeg( hw_reg_set reg ) { -/***************************************** - POP segreg -*/ - +static void PopSeg( hw_reg_set reg ) +/*************************************** + * POP segreg + */ +{ if( HW_COvlap( reg, HW_FS ) ) { LayOpword( M_POPFS ); } else if( HW_COvlap( reg, HW_GS ) ) { @@ -1158,9 +1171,9 @@ static void PopSeg( hw_reg_set reg ) { void QuickSave( hw_reg_set reg, opcode_defs op ) /************************************************** - PUSH/POP reg - based on "op" - assume register is valid for PUSH/POP -*/ + * PUSH/POP reg - based on "op" + * assume register is valid for PUSH/POP + */ { _Code; if( HW_COvlap( reg, HW_SEGS ) ) { @@ -1183,8 +1196,8 @@ void QuickSave( hw_reg_set reg, opcode_defs op ) void GenRegXor( hw_reg_set src, hw_reg_set dst ) /************************************************** - XOR dst,src -*/ + * XOR dst,src + */ { _Code; LayOpword( M_XORRR | B_KEY_W ); @@ -1197,8 +1210,8 @@ void GenRegXor( hw_reg_set src, hw_reg_set dst ) void GenRegNeg( hw_reg_set src ) /********************************** - NEG src -*/ + * NEG src + */ { _Code; LayOpword( M_NEGR | B_KEY_W ); @@ -1210,8 +1223,8 @@ void GenRegNeg( hw_reg_set src ) void GenRegMove( hw_reg_set src, hw_reg_set dst ) /*************************************************** - MOV dst,src -*/ + * MOV dst,src + */ { _Code; LayOpword( M_MOVRR | B_KEY_W ); @@ -1224,9 +1237,9 @@ void GenRegMove( hw_reg_set src, hw_reg_set dst ) static void AddSWData( opcode_defs op, signed_32 val, type_class_def type_class ) /************************************************************************** - Add a const (signed_32) to Inst[] with sign extension if the opcode - allows it -*/ + * Add a const (signed_32) to Inst[] with sign extension if the opcode + * allows it + */ { switch( op ) { case OP_ADD: @@ -1254,8 +1267,8 @@ static void AddSWData( opcode_defs op, signed_32 val, type_class_def type_cl static void AddSWCons( opcode_defs op, name *opnd, type_class_def type_class ) /****************************************************************************** - Add a const (name *) to Inst[] with sign extension if the opcode allows it -*/ + * Add a const (name *) to Inst[] with sign extension if the opcode allows it + */ { if( opnd->c.const_type == CONS_ABSOLUTE ) { AddSWData( op, opnd->c.lo.int_value, type_class ); @@ -1293,8 +1306,8 @@ void AddWData( signed_32 value, type_class_def type_class ) void AddWCons( name *op, type_class_def type_class ) /************************************************ - Add a WORD constant to Inst[] -*/ + * Add a WORD constant to Inst[] + */ { if( op->c.const_type == CONS_ABSOLUTE ) { AddWData( op->c.lo.int_value, type_class ); @@ -1315,8 +1328,8 @@ void AddWCons( name *op, type_class_def type_class ) void AddSData( signed_32 value, type_class_def type_class ) /***************************************************************** - Add a constant (signed_32) to Inst[], with possible sign extension -*/ + * Add a constant (signed_32) to Inst[], with possible sign extension + */ { if( ( type_class == U2 || type_class == I2 ) && ( ( value & 0xff80 ) == 0xff80 @@ -1335,8 +1348,8 @@ void AddSData( signed_32 value, type_class_def type_class ) static void AddSCons( name *op, type_class_def type_class ) /********************************************************** - Add a constant (name *) to Inst[], with possible sign extension -*/ + * Add a constant (name *) to Inst[], with possible sign extension + */ { if( op->c.const_type == CONS_ABSOLUTE ) { AddSData( op->c.lo.int_value, type_class ); @@ -1372,8 +1385,8 @@ static void GenRegOp( hw_reg_set dst, type_length value, gen_opcode op ) void GenRegAdd( hw_reg_set dst, type_length value ) /***************************************************** - ADD dst,value -*/ + * ADD dst,value + */ { GenRegOp( dst, value, M_ADDRC ); } @@ -1381,8 +1394,8 @@ void GenRegAdd( hw_reg_set dst, type_length value ) void GenRegSub( hw_reg_set dst, type_length value ) /***************************************************** - SUB dst,value -*/ + * SUB dst,value + */ { GenRegOp( dst, value, M_SUBRC ); } @@ -1390,18 +1403,18 @@ void GenRegSub( hw_reg_set dst, type_length value ) void GenRegAnd( hw_reg_set dst, type_length value ) /***************************************************** - SUB dst,value -*/ + * SUB dst,value + */ { GenRegOp( dst, value, M_ANDRC ); } -static void GFld1( void ) { -/****************************** - FLD1 -*/ - +static void GFld1( void ) +/**************************** + * FLD1 + */ +{ GCondFwait(); LayOpword( 0xe8d9 ); _Emit; @@ -1410,8 +1423,8 @@ static void GFld1( void ) { void GFldMorC( name *what ) /*************************************** - FLD what, where what is either 0,1,or a memory location -*/ + * FLD what, where what is either 0,1,or a memory location + */ { if( what->n.class == N_MEMORY || what->n.class == N_TEMP ) { GFldM( what ); @@ -1424,8 +1437,8 @@ void GFldMorC( name *what ) void GFldM( pointer what ) /************************************** - FLD tbyte ptr what -*/ + * FLD tbyte ptr what + */ { GCondFwait(); LayOpword( 0x00d9 ); @@ -1437,8 +1450,8 @@ void GFldM( pointer what ) void GFstpM( pointer what ) /***************************** - FSTP tbyte ptr what -*/ + * FSTP tbyte ptr what + */ { GCondFwait(); LayOpword( 0x18d9 ); @@ -1450,8 +1463,8 @@ void GFstpM( pointer what ) void GFstp( int i ) /********************* - FSTP ST(i) -*/ + * FSTP ST(i) + */ { GCondFwait(); LayOpword( 0xd8dd ); @@ -1462,8 +1475,8 @@ void GFstp( int i ) void GFxch( int i ) /********************* - FXCH ST(i) -*/ + * FXCH ST(i) + */ { GCondFwait(); LayOpword( 0xc8d9 ); @@ -1474,8 +1487,8 @@ void GFxch( int i ) void GFldz( void ) /******************** - FLDZ -*/ + * FLDZ + */ { GCondFwait(); LayOpword( 0xeed9 ); @@ -1485,8 +1498,8 @@ void GFldz( void ) void GFld( int i ) /******************** - FLD ST(i) -*/ + * FLD ST(i) + */ { GCondFwait(); LayOpword( 0xc0d9 ); @@ -1497,8 +1510,8 @@ void GFld( int i ) void GCondFwait( void ) /********************************** - FWAIT, but only if we need one -*/ + * FWAIT, but only if we need one + */ { _Code; Used87 = true; @@ -1516,8 +1529,8 @@ void GCondFwait( void ) void GFwait( void ) /********************* - FWAIT -*/ + * FWAIT + */ { if( _CPULevel( CPU_386 ) ) return; @@ -1534,8 +1547,8 @@ void GFwait( void ) void Gpusha( void ) /********************* - PUSHA{d} -*/ + * PUSHA{d} + */ { _Code; LayOpbyte( 0x60 ); @@ -1544,8 +1557,8 @@ void Gpusha( void ) void Gpopa( void ) /******************** - POPA{d} -*/ + * POPA{d} + */ { _Code; LayOpbyte( 0x61 ); @@ -1554,8 +1567,8 @@ void Gpopa( void ) void Gcld( void ) /******************* - CLD -*/ + * CLD + */ { _Code; LayOpbyte( 0xfc ); @@ -1564,8 +1577,8 @@ void Gcld( void ) void GenLeave( void ) /*********************** - LEAVE -*/ + * LEAVE + */ { _Code; LayOpbyte( 0xc9 ); @@ -1576,8 +1589,8 @@ void GenLeave( void ) void GenTouchStack( bool sp_might_point_at_something ) /******************************************************** - MOV [esp],eax -*/ + * MOV [esp],eax + */ { #if _TARGET & _TARG_8086 /* unused parameters */ (void)sp_might_point_at_something; @@ -1598,8 +1611,8 @@ void GenTouchStack( bool sp_might_point_at_something ) void GenEnter( int size, int level ) /************************************** - ENTER size,level -*/ + * ENTER size,level + */ { _Code; LayOpbyte( 0xc8 ); @@ -1613,8 +1626,8 @@ void GenEnter( int size, int level ) void GenPushOffset( byte offset ) /*********************************** - PUSH word ptr offset[BP] -*/ + * PUSH word ptr offset[BP] + */ { _Code; LayOpword( M_PUSHATBP ); @@ -1625,8 +1638,8 @@ void GenPushOffset( byte offset ) void GenUnkSub( hw_reg_set dst, pointer value ) /************************************************* - SUB dst,??? - to be patched later -*/ + * SUB dst,??? - to be patched later + */ { _Code; LayOpword( M_SUBRC | B_KEY_W ); @@ -1640,8 +1653,8 @@ void GenUnkSub( hw_reg_set dst, pointer value ) void GenUnkMov( hw_reg_set dst, pointer value ) /************************************************* - MOV dst,??? - to be patched -*/ + * MOV dst,??? - to be patched + */ { /* unused parameters */ (void)dst; @@ -1656,8 +1669,8 @@ void GenUnkMov( hw_reg_set dst, pointer value ) void GenUnkEnter( pointer value, int level ) /********************************************** - ENTER ??,level - to be patched later -*/ + * ENTER ??,level - to be patched later + */ { _Code; LayOpbyte( 0xc8 ); @@ -1693,8 +1706,8 @@ void GenWindowsProlog( void ) void GenCypWindowsProlog( void ) /************************************ - Generate a "cheap" windows prolog -*/ + * Generate a "cheap" windows prolog + */ { _Code; if( !_CPULevel( CPU_386 ) ) { @@ -1720,8 +1733,8 @@ void GenWindowsEpilog( void ) void GenCypWindowsEpilog( void ) /************************************ - Generate a "cheap" windows epilog -*/ + * Generate a "cheap" windows epilog + */ { _Code; LayOpbyte( 0x5d ); /* pop [e]bp */ @@ -1799,19 +1812,18 @@ void GenLoadDS( void ) } -static void OutputFP( gen_opcode op ) { -/****************************************** -*/ - +static void OutputFP( gen_opcode op ) +/***************************************/ +{ GCondFwait(); LayOpword( op ); } -static void MathFunc( instruction *ins ) { -/********************************************* - Generate inline code for a math function instruction -*/ - +static void MathFunc( instruction *ins ) +/******************************************* + * Generate inline code for a math function instruction + */ +{ switch( ins->head.opcode ) { case OP_EXP: OutputFP( 0xE8D9 ); _Emit; /* FLD1 */ @@ -1859,10 +1871,11 @@ static void MathFunc( instruction *ins ) { } } -static void CallMathFunc( instruction *ins ) { -/************************************************* - Call a runtime routine for a math function instructions -*/ +static void CallMathFunc( instruction *ins ) +/*********************************************** + * Call a runtime routine for a math function instructions + */ +{ rt_class rtindex; rtindex = LookupRoutine( ins ); @@ -1881,11 +1894,11 @@ static void GenUnkLea( pointer value ) Inst[RMR] |= DoIndex( HW_xBP ); } -void GenObjCode( instruction *ins ) { -/*************************************** - Generate object code for the instruction "ins" based on gen_table->generate -*/ - +void GenObjCode( instruction *ins ) +/************************************* + * Generate object code for the instruction "ins" based on gen_table->generate + */ +{ gentype gen; name *result; name *left = NULL; @@ -2014,7 +2027,9 @@ void GenObjCode( instruction *ins ) { } LayACRegOp( left ); if( OpcodeNumOperands( ins ) != 1 && right->c.lo.int_value == 2 ) { - /* never address*/ + /* + * never address + */ TransferIns(); if( opnd_size ) { AddToTemp( M_OPND_SIZE ); @@ -2174,7 +2189,8 @@ void GenObjCode( instruction *ins ) { } #if _TARGET & _TARG_80386 if( ( left->n.class == N_TEMP ) && TmpLoc( DeAlias( left ), left ) == 0 ) { - /* turn "LEA ,[ESP+0]" into "MOV ,ESP" + /* + * turn "LEA ,[ESP+0]" into "MOV ,ESP" * or "LEA ,[EBP+0]" into "MOV ,EBP" */ LayOpword( M_MOVRR | B_KEY_W ); @@ -2210,7 +2226,9 @@ void GenObjCode( instruction *ins ) { Gen4RNeg( ins ); break; case G_ENTER: - /* do nothing, prolog should already be generated*/ + /* + * do nothing, prolog should already be generated + */ break; case G_CALL: GenCall( ins ); From 1d7da2f6582c92e60636db4dd850a8f9b3e7e2e8 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Sun, 8 Oct 2023 22:41:12 +0200 Subject: [PATCH 223/258] reformat source files --- bld/cg/h/rgtbl.h | 4 ++-- bld/cg/intel/c/x86dfsup.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bld/cg/h/rgtbl.h b/bld/cg/h/rgtbl.h index 495116b301..973d64f300 100644 --- a/bld/cg/h/rgtbl.h +++ b/bld/cg/h/rgtbl.h @@ -90,8 +90,8 @@ extern hw_reg_set *GPRegs( void ); extern hw_reg_set *FPRegs( void ); extern hw_reg_set SavedRegs( void ); #if _TARGET & _TARG_370 -extern hw_reg_set RAReg( void ); -extern hw_reg_set LNReg( void ); +extern hw_reg_set RAReg( void ); +extern hw_reg_set LNReg( void ); #endif #if _TARGET & _TARG_PPC extern hw_reg_set TocReg( void ); diff --git a/bld/cg/intel/c/x86dfsup.c b/bld/cg/intel/c/x86dfsup.c index 13ae2dd4ef..00d09cbbc8 100644 --- a/bld/cg/intel/c/x86dfsup.c +++ b/bld/cg/intel/c/x86dfsup.c @@ -134,7 +134,7 @@ void DFOutRegInd( dw_loc_id locid, name *reg ) { dw_regs dw_reg; - dw_reg = RegTransDW( reg->r.reg ); + dw_reg = RegTransDW( reg->r.reg ); DWLocOp( Client, locid, DW_LOC_breg, dw_reg, 0 ); } From bcad182f3d189bb6849d0aa1b31c3a89de09bee3 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Sun, 8 Oct 2023 23:31:16 +0200 Subject: [PATCH 224/258] cleanup cg code remove redundant function RegTransN use global function RegTransDW as RegTrans replacement whenever possible --- bld/cg/intel/h/x86regn.h | 2 + bld/cg/risc/axp/c/axpdfsup.c | 29 ++----------- bld/cg/risc/axp/c/axprgtbl.c | 20 +++------ bld/cg/risc/axp/h/axpenc.h | 4 +- bld/cg/risc/axp/h/axpregn.h | 80 +++++------------------------------- bld/cg/risc/mps/c/mpsdfsup.c | 33 +++------------ bld/cg/risc/mps/c/mpsrgtbl.c | 22 +++------- bld/cg/risc/mps/h/mpsenc.h | 5 +-- bld/cg/risc/mps/h/mpsregn.h | 79 +++++------------------------------ bld/cg/risc/ppc/c/ppcdfsup.c | 29 ++----------- bld/cg/risc/ppc/c/ppcrgtbl.c | 20 +++------ bld/cg/risc/ppc/h/ppcenc.h | 4 +- bld/cg/risc/ppc/h/ppcregn.h | 79 +++++------------------------------ 13 files changed, 63 insertions(+), 343 deletions(-) diff --git a/bld/cg/intel/h/x86regn.h b/bld/cg/intel/h/x86regn.h index 51b2397934..a67a16e1c1 100644 --- a/bld/cg/intel/h/x86regn.h +++ b/bld/cg/intel/h/x86regn.h @@ -45,6 +45,8 @@ typedef enum { DW_REG_END } dw_regs; +typedef uint_8 reg_idx; + extern hw_reg_set GetFPReg( int idx ); extern int CountFPRegs( hw_reg_set regs ); extern int FPRegNum( name *reg_name ); diff --git a/bld/cg/risc/axp/c/axpdfsup.c b/bld/cg/risc/axp/c/axpdfsup.c index e76c27996f..56be17486b 100644 --- a/bld/cg/risc/axp/c/axpdfsup.c +++ b/bld/cg/risc/axp/c/axpdfsup.c @@ -52,35 +52,12 @@ #include "cgprotos.h" -#define MapReg2DW(r) ((dw_regs)r) - -typedef enum { - #define pick(id,name) DW_REG_ ## id, - #include "dwregaxp.h" - #undef pick - DW_REG_MAX -} dw_regs; - -static dw_regs DFRegMap( hw_reg_set hw_reg ) -/*******************************************/ -{ - return( MapReg2DW( RegTrans( hw_reg ) ) ); -} - - -static dw_regs DFRegMapN( name *reg ) -/************************************/ -{ - return( MapReg2DW( RegTransN( reg ) ) ); -} - - void DFOutReg( dw_loc_id locid, name *reg ) /********************************************/ { dw_regs regnum; - regnum = DFRegMapN( reg ); + regnum = RegTransDW( reg->r.reg ); DWLocReg( Client, locid, regnum ); } @@ -90,7 +67,7 @@ void DFOutRegInd( dw_loc_id locid, name *reg ) { dw_regs regnum; - regnum = DFRegMapN( reg ); + regnum = RegTransDW( reg->r.reg ); DWLocOp( Client, locid, DW_LOC_breg, regnum, 0 ); } @@ -98,5 +75,5 @@ void DFOutRegInd( dw_loc_id locid, name *reg ) uint DFStkReg( void ) /***********************/ { - return( DFRegMap( StackReg() ) ); + return( RegTransDW( StackReg() ) ); } diff --git a/bld/cg/risc/axp/c/axprgtbl.c b/bld/cg/risc/axp/c/axprgtbl.c index e1deddd4aa..7be9840e4a 100644 --- a/bld/cg/risc/axp/c/axprgtbl.c +++ b/bld/cg/risc/axp/c/axprgtbl.c @@ -33,7 +33,6 @@ #include "_cgstd.h" #include "coderep.h" -#include "axpregn.h" #include "axpenc.h" #include "zoiks.h" #include "data.h" @@ -803,20 +802,20 @@ static int regTranslate( hw_reg_set reg, bool index ) if( HW_Subset( QWordRegs[i], reg ) ) { if( index ) return( i ); - return( i+AXP_REGN_r0 ); + return( i + DW_REG_R0 ); } } for( i = 0; i < sizeof( FloatRegs ) / sizeof( FloatRegs[0] ); i++ ) { if( HW_Equal( reg, FloatRegs[i] ) ) { if( index ) return( i ); - return( i+AXP_REGN_f0 ); + return( i + DW_REG_F0 ); } } if( index ) return( 0 ); _Zoiks( ZOIKS_031 ); - return( AXP_REGN_END ); + return( DW_REG_END ); } reg_idx RegIndex( hw_reg_set reg ) @@ -833,23 +832,14 @@ int GetArchIndex( hw_reg_set regs ) return( RegIndex( regs ) ); } -axp_regn RegTrans( hw_reg_set reg ) +int RegTransDW( hw_reg_set reg ) /************************************* * Translate reg to register index */ { - return( (axp_regn)regTranslate( reg, false ) ); + return( regTranslate( reg, false ) ); } -axp_regn RegTransN( name *reg_name ) -/************************************** - * Translate reg name to enum name - */ -{ - return( (axp_regn)regTranslate( reg_name->r.reg, false ) ); -} - - hw_reg_set FirstReg( reg_set_index regs_idx ) /************************************************* The table RTInfo[] uses reg_set_indexes instead of hw_reg_sets since diff --git a/bld/cg/risc/axp/h/axpenc.h b/bld/cg/risc/axp/h/axpenc.h index 070c5821b2..ebce9d854f 100644 --- a/bld/cg/risc/axp/h/axpenc.h +++ b/bld/cg/risc/axp/h/axpenc.h @@ -31,10 +31,8 @@ #include "axpencod.h" +#include "axpregn.h" -typedef uint_8 reg_idx; - -extern reg_idx RegIndex( hw_reg_set reg ); extern void GenCallLabelReg( pointer label, reg_idx reg ); extern void GenOPINS( uint_8 opcode, uint_8 function, reg_idx ra, reg_idx rb, reg_idx rc ); diff --git a/bld/cg/risc/axp/h/axpregn.h b/bld/cg/risc/axp/h/axpregn.h index d68be5b7fa..d44ba6f13c 100644 --- a/bld/cg/risc/axp/h/axpregn.h +++ b/bld/cg/risc/axp/h/axpregn.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -30,73 +31,14 @@ ****************************************************************************/ -typedef enum axp_regn { - AXP_REGN_r0, - AXP_REGN_r1, - AXP_REGN_r2, - AXP_REGN_r3, - AXP_REGN_r4, - AXP_REGN_r5, - AXP_REGN_r6, - AXP_REGN_r7, - AXP_REGN_r8, - AXP_REGN_r9, - AXP_REGN_r10, - AXP_REGN_r11, - AXP_REGN_r12, - AXP_REGN_r13, - AXP_REGN_r14, - AXP_REGN_r15, - AXP_REGN_r16, - AXP_REGN_r17, - AXP_REGN_r18, - AXP_REGN_r19, - AXP_REGN_r20, - AXP_REGN_r21, - AXP_REGN_r22, - AXP_REGN_r23, - AXP_REGN_r24, - AXP_REGN_r25, - AXP_REGN_r26, - AXP_REGN_r27, - AXP_REGN_r28, - AXP_REGN_r29, - AXP_REGN_r30, - AXP_REGN_r31, - AXP_REGN_f0, - AXP_REGN_f1, - AXP_REGN_f2, - AXP_REGN_f3, - AXP_REGN_f4, - AXP_REGN_f5, - AXP_REGN_f6, - AXP_REGN_f7, - AXP_REGN_f8, - AXP_REGN_f9, - AXP_REGN_f10, - AXP_REGN_f11, - AXP_REGN_f12, - AXP_REGN_f13, - AXP_REGN_f14, - AXP_REGN_f15, - AXP_REGN_f16, - AXP_REGN_f17, - AXP_REGN_f18, - AXP_REGN_f19, - AXP_REGN_f20, - AXP_REGN_f21, - AXP_REGN_f22, - AXP_REGN_f23, - AXP_REGN_f24, - AXP_REGN_f25, - AXP_REGN_f26, - AXP_REGN_f27, - AXP_REGN_f28, - AXP_REGN_f29, - AXP_REGN_f30, - AXP_REGN_f31, - AXP_REGN_END, -} axp_regn; +typedef enum { + #define pick(id,name) DW_REG_ ## id, + #include "dwregaxp.h" + #undef pick + DW_REG_END +} dw_regs; -extern axp_regn RegTrans( hw_reg_set reg ); -extern axp_regn RegTransN( name *reg_name ); +typedef uint_8 reg_idx; + +extern reg_idx RegIndex( hw_reg_set reg ); +extern int RegTransDW( hw_reg_set reg ); diff --git a/bld/cg/risc/mps/c/mpsdfsup.c b/bld/cg/risc/mps/c/mpsdfsup.c index 7d483b3496..5f31ab0d9a 100644 --- a/bld/cg/risc/mps/c/mpsdfsup.c +++ b/bld/cg/risc/mps/c/mpsdfsup.c @@ -51,29 +51,6 @@ #include "cgprotos.h" -#define MapReg2DW(r) ((dw_regs)r) - -typedef enum { - #define pick(id,name) DW_REG_ ## id, - #include "dwregmps.h" - DW_REG_MAX - #undef pick -} dw_regs; - -static dw_regs DFRegMap( hw_reg_set hw_reg ) -/*******************************************/ -{ - return( MapReg2DW( RegTrans( hw_reg ) ) ); -} - - -static dw_regs DFRegMapN( name *reg ) -/************************************/ -{ - return( MapReg2DW( RegTransN( reg ) ) ); -} - - void DFOutReg( dw_loc_id locid, name *reg ) /********************************************/ { @@ -85,14 +62,14 @@ void DFOutReg( dw_loc_id locid, name *reg ) hw_low = Low64Reg( hw_reg ); if( HW_CEqual( hw_low, HW_EMPTY ) ) { - dw_reg = DFRegMap( hw_reg ); + dw_reg = RegTransDW( hw_reg ); DWLocReg( Client, locid, dw_reg ); } else { - dw_reg = DFRegMap( hw_low ); + dw_reg = RegTransDW( hw_low ); DWLocReg( Client, locid, dw_reg ); DWLocPiece( Client, locid, WD ); HW_TurnOff( hw_reg, hw_low ); - dw_reg = DFRegMap( hw_reg ); + dw_reg = RegTransDW( hw_reg ); DWLocReg( Client, locid, dw_reg ); DWLocPiece( Client, locid, WD ); } @@ -104,7 +81,7 @@ void DFOutRegInd( dw_loc_id locid, name *reg ) { dw_regs regnum; - regnum = DFRegMapN( reg ); + regnum = RegTransDW( reg->r.reg ); DWLocOp( Client, locid, DW_LOC_breg, regnum, 0 ); } @@ -112,5 +89,5 @@ void DFOutRegInd( dw_loc_id locid, name *reg ) uint DFStkReg( void ) /***********************/ { - return( DFRegMap( StackReg() ) ); + return( RegTransDW( StackReg() ) ); } diff --git a/bld/cg/risc/mps/c/mpsrgtbl.c b/bld/cg/risc/mps/c/mpsrgtbl.c index 1d8a3979a8..20dd01c8b8 100644 --- a/bld/cg/risc/mps/c/mpsrgtbl.c +++ b/bld/cg/risc/mps/c/mpsrgtbl.c @@ -32,7 +32,6 @@ #include "_cgstd.h" #include "coderep.h" -#include "mpsregn.h" #include "mpsenc.h" #include "zoiks.h" #include "data.h" @@ -865,27 +864,27 @@ static int regTranslate( hw_reg_set reg, bool index ) if( HW_Subset( GeneralRegs[i], reg ) ) { if( index ) return( i ); - return( i + MIPS_REGN_r0 ); + return( i + DW_REG_R0 ); } } for( i = 0; i < sizeof( QWordRegs ) / sizeof( QWordRegs[0] ); i++ ) { if( HW_Subset( QWordRegs[i], reg ) ) { if( index ) return( i * 2 + 2 ); - return( i * 2 + 2 + MIPS_REGN_r0 ); + return( i * 2 + 2 + DW_REG_R0 ); } } for( i = 0; i < sizeof( FloatRegs ) / sizeof( FloatRegs[0] ); i++ ) { if( HW_Equal( reg, FloatRegs[i] ) ) { if( index ) return( i ); - return( i + MIPS_REGN_f0 ); + return( i + DW_REG_F0 ); } } if( index ) return( 0 ); _Zoiks( ZOIKS_031 ); - return( MIPS_REGN_END ); + return( DW_REG_END ); } reg_idx RegIndex( hw_reg_set reg ) @@ -903,23 +902,14 @@ int GetArchIndex( hw_reg_set regs ) } -mips_regn RegTrans( hw_reg_set reg ) +int RegTransDW( hw_reg_set reg ) /************************************* * Translate reg to register index */ { - return( (mips_regn)regTranslate( reg, false ) ); + return( regTranslate( reg, false ) ); } -mips_regn RegTransN( name *reg_name ) -/*************************************** - * Translate reg name to enum name - */ -{ - return( (mips_regn)regTranslate( reg_name->r.reg, false ) ); -} - - hw_reg_set FirstReg( reg_set_index regs_idx ) /************************************************* The table RTInfo[] uses reg_set_indexes instead of hw_reg_sets since diff --git a/bld/cg/risc/mps/h/mpsenc.h b/bld/cg/risc/mps/h/mpsenc.h index f5cabef3bf..d633211e9a 100644 --- a/bld/cg/risc/mps/h/mpsenc.h +++ b/bld/cg/risc/mps/h/mpsenc.h @@ -31,12 +31,9 @@ #include "mipsenco.h" +#include "mpsregn.h" -typedef uint_8 reg_idx; - -extern reg_idx RegIndex( hw_reg_set reg ); - extern void GenCallLabelReg( pointer label, reg_idx reg ); extern void GenLOADS32( signed_32 value, reg_idx reg ); extern void GenMEMINS( uint_8 opcode, reg_idx rt, reg_idx rs, signed_16 displacement ); diff --git a/bld/cg/risc/mps/h/mpsregn.h b/bld/cg/risc/mps/h/mpsregn.h index 4f6af0f0ee..daf004e3ec 100644 --- a/bld/cg/risc/mps/h/mpsregn.h +++ b/bld/cg/risc/mps/h/mpsregn.h @@ -30,73 +30,14 @@ ****************************************************************************/ -typedef enum mips_regn { - MIPS_REGN_r0, - MIPS_REGN_r1, - MIPS_REGN_r2, - MIPS_REGN_r3, - MIPS_REGN_r4, - MIPS_REGN_r5, - MIPS_REGN_r6, - MIPS_REGN_r7, - MIPS_REGN_r8, - MIPS_REGN_r9, - MIPS_REGN_r10, - MIPS_REGN_r11, - MIPS_REGN_r12, - MIPS_REGN_r13, - MIPS_REGN_r14, - MIPS_REGN_r15, - MIPS_REGN_r16, - MIPS_REGN_r17, - MIPS_REGN_r18, - MIPS_REGN_r19, - MIPS_REGN_r20, - MIPS_REGN_r21, - MIPS_REGN_r22, - MIPS_REGN_r23, - MIPS_REGN_r24, - MIPS_REGN_r25, - MIPS_REGN_r26, - MIPS_REGN_r27, - MIPS_REGN_r28, - MIPS_REGN_r29, - MIPS_REGN_r30, - MIPS_REGN_r31, - MIPS_REGN_f0, - MIPS_REGN_f1, - MIPS_REGN_f2, - MIPS_REGN_f3, - MIPS_REGN_f4, - MIPS_REGN_f5, - MIPS_REGN_f6, - MIPS_REGN_f7, - MIPS_REGN_f8, - MIPS_REGN_f9, - MIPS_REGN_f10, - MIPS_REGN_f11, - MIPS_REGN_f12, - MIPS_REGN_f13, - MIPS_REGN_f14, - MIPS_REGN_f15, - MIPS_REGN_f16, - MIPS_REGN_f17, - MIPS_REGN_f18, - MIPS_REGN_f19, - MIPS_REGN_f20, - MIPS_REGN_f21, - MIPS_REGN_f22, - MIPS_REGN_f23, - MIPS_REGN_f24, - MIPS_REGN_f25, - MIPS_REGN_f26, - MIPS_REGN_f27, - MIPS_REGN_f28, - MIPS_REGN_f29, - MIPS_REGN_f30, - MIPS_REGN_f31, - MIPS_REGN_END, -} mips_regn; +typedef enum { + #define pick(id,name) DW_REG_ ## id, + #include "dwregmps.h" + DW_REG_END + #undef pick +} dw_regs; -extern mips_regn RegTrans( hw_reg_set reg ); -extern mips_regn RegTransN( name *reg_name ); +typedef uint_8 reg_idx; + +extern reg_idx RegIndex( hw_reg_set reg ); +extern int RegTransDW( hw_reg_set reg ); diff --git a/bld/cg/risc/ppc/c/ppcdfsup.c b/bld/cg/risc/ppc/c/ppcdfsup.c index 82c87d59e4..2c3d08b9d7 100644 --- a/bld/cg/risc/ppc/c/ppcdfsup.c +++ b/bld/cg/risc/ppc/c/ppcdfsup.c @@ -52,35 +52,12 @@ #include "cgprotos.h" -#define MapReg2DW(r) ((dw_regs)r) - -typedef enum { - #define pick(id,name) DW_REG_ ## id, - #include "dwregppc.h" - DW_REG_MAX - #undef pick -} dw_regs; - -static dw_regs DFRegMap( hw_reg_set hw_reg ) -/*******************************************/ -{ - return( MapReg2DW( RegTrans( hw_reg ) ) ); -} - - -static dw_regs DFRegMapN( name *reg ) -/************************************/ -{ - return( MapReg2DW( RegTransN( reg ) ) ); -} - - void DFOutReg( dw_loc_id locid, name *reg ) /********************************************/ { dw_regs regnum; - regnum = DFRegMapN( reg ); + regnum = RegTransDW( reg->r.reg ); DWLocReg( Client, locid, regnum ); } @@ -90,7 +67,7 @@ void DFOutRegInd( dw_loc_id locid, name *reg ) { dw_regs regnum; - regnum = DFRegMapN( reg ); + regnum = RegTransDW( reg->r.reg ); DWLocOp( Client, locid, DW_LOC_breg, regnum, 0 ); } @@ -98,5 +75,5 @@ void DFOutRegInd( dw_loc_id locid, name *reg ) uint DFStkReg( void ) /***********************/ { - return( DFRegMap( StackReg() ) ); + return( RegTransDW( StackReg() ) ); } diff --git a/bld/cg/risc/ppc/c/ppcrgtbl.c b/bld/cg/risc/ppc/c/ppcrgtbl.c index 35f647e9f3..3ae5f36c85 100644 --- a/bld/cg/risc/ppc/c/ppcrgtbl.c +++ b/bld/cg/risc/ppc/c/ppcrgtbl.c @@ -32,7 +32,6 @@ #include "_cgstd.h" #include "coderep.h" -#include "ppcregn.h" #include "ppcenc.h" #include "zoiks.h" #include "data.h" @@ -791,20 +790,20 @@ static int regTranslate( hw_reg_set reg, bool index ) if( HW_Subset( DWordRegs[i], reg ) ) { if( index ) return( i ); - return( i + PPC_REGN_r0 ); + return( i + DW_REG_R0 ); } } for( i = 0; i < sizeof( FloatRegs ) / sizeof( FloatRegs[0] ); i++ ) { if( HW_Equal( reg, FloatRegs[i] ) ) { if( index ) return( i ); - return( i + PPC_REGN_f0 ); + return( i + DW_REG_F0 ); } } if( index ) return( 0 ); _Zoiks( ZOIKS_031 ); - return( PPC_REGN_END ); + return( DW_REG_END ); } reg_idx RegIndex( hw_reg_set reg ) @@ -821,23 +820,14 @@ int GetArchIndex( hw_reg_set regs ) return( RegIndex( regs ) ); } -ppc_regn RegTrans( hw_reg_set reg ) +int RegTransDW( hw_reg_set reg ) /************************************* * Translate reg to enum name */ { - return( (ppc_regn)regTranslate( reg, false ) ); + return( regTranslate( reg, false ) ); } -ppc_regn RegTransN( name *reg_name ) -/************************************** - * Translate reg name to enum name - */ -{ - return( (ppc_regn)regTranslate( reg_name->r.reg, false ) ); -} - - hw_reg_set ParmRegConflicts( hw_reg_set r ) /*****************************************/ { diff --git a/bld/cg/risc/ppc/h/ppcenc.h b/bld/cg/risc/ppc/h/ppcenc.h index 4a94c3c99e..47bebccb79 100644 --- a/bld/cg/risc/ppc/h/ppcenc.h +++ b/bld/cg/risc/ppc/h/ppcenc.h @@ -31,12 +31,10 @@ #include "ppcencod.h" +#include "ppcregn.h" typedef uint_32 gen_opcode; -typedef uint_8 reg_idx; - -extern reg_idx RegIndex( hw_reg_set reg ); extern void GenMEMINS( gen_opcode, reg_idx, reg_idx, signed_16 ); extern void GenOPINS( gen_opcode, gen_opcode, reg_idx, reg_idx, reg_idx ); diff --git a/bld/cg/risc/ppc/h/ppcregn.h b/bld/cg/risc/ppc/h/ppcregn.h index a42f744dd0..629c3122a4 100644 --- a/bld/cg/risc/ppc/h/ppcregn.h +++ b/bld/cg/risc/ppc/h/ppcregn.h @@ -31,73 +31,14 @@ ****************************************************************************/ -typedef enum ppc_regn { - PPC_REGN_r0, - PPC_REGN_r1, - PPC_REGN_r2, - PPC_REGN_r3, - PPC_REGN_r4, - PPC_REGN_r5, - PPC_REGN_r6, - PPC_REGN_r7, - PPC_REGN_r8, - PPC_REGN_r9, - PPC_REGN_r10, - PPC_REGN_r11, - PPC_REGN_r12, - PPC_REGN_r13, - PPC_REGN_r14, - PPC_REGN_r15, - PPC_REGN_r16, - PPC_REGN_r17, - PPC_REGN_r18, - PPC_REGN_r19, - PPC_REGN_r20, - PPC_REGN_r21, - PPC_REGN_r22, - PPC_REGN_r23, - PPC_REGN_r24, - PPC_REGN_r25, - PPC_REGN_r26, - PPC_REGN_r27, - PPC_REGN_r28, - PPC_REGN_r29, - PPC_REGN_r30, - PPC_REGN_r31, - PPC_REGN_f0, - PPC_REGN_f1, - PPC_REGN_f2, - PPC_REGN_f3, - PPC_REGN_f4, - PPC_REGN_f5, - PPC_REGN_f6, - PPC_REGN_f7, - PPC_REGN_f8, - PPC_REGN_f9, - PPC_REGN_f10, - PPC_REGN_f11, - PPC_REGN_f12, - PPC_REGN_f13, - PPC_REGN_f14, - PPC_REGN_f15, - PPC_REGN_f16, - PPC_REGN_f17, - PPC_REGN_f18, - PPC_REGN_f19, - PPC_REGN_f20, - PPC_REGN_f21, - PPC_REGN_f22, - PPC_REGN_f23, - PPC_REGN_f24, - PPC_REGN_f25, - PPC_REGN_f26, - PPC_REGN_f27, - PPC_REGN_f28, - PPC_REGN_f29, - PPC_REGN_f30, - PPC_REGN_f31, - PPC_REGN_END, -} ppc_regn; +typedef enum { + #define pick(id,name) DW_REG_ ## id, + #include "dwregppc.h" + DW_REG_END + #undef pick +} dw_regs; -extern ppc_regn RegTrans( hw_reg_set reg ); -extern ppc_regn RegTransN( name *reg_name ); +typedef uint_8 reg_idx; + +extern reg_idx RegIndex( hw_reg_set reg ); +extern int RegTransDW( hw_reg_set reg ); From 4d4e79a9461d679fe6f56bd46453878a14211632 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Mon, 9 Oct 2023 00:06:34 +0200 Subject: [PATCH 225/258] clenup cg code correct types mismatches --- bld/cg/intel/c/x86enc.c | 4 ++-- bld/cg/intel/h/x86regn.h | 2 +- bld/cg/risc/axp/c/axprgtbl.c | 4 ++-- bld/cg/risc/axp/h/axpregn.h | 2 +- bld/cg/risc/mps/c/mpsrgtbl.c | 4 ++-- bld/cg/risc/mps/h/mpsregn.h | 2 +- bld/cg/risc/ppc/c/ppcrgtbl.c | 4 ++-- bld/cg/risc/ppc/h/ppcregn.h | 2 +- 8 files changed, 12 insertions(+), 12 deletions(-) diff --git a/bld/cg/intel/c/x86enc.c b/bld/cg/intel/c/x86enc.c index 395746ce41..32c9d83e96 100644 --- a/bld/cg/intel/c/x86enc.c +++ b/bld/cg/intel/c/x86enc.c @@ -401,8 +401,8 @@ static int FPRegTrans( hw_reg_set reg ) return( -1 ); } -int RegTransDW( hw_reg_set reg ) -/******************************/ +dw_regs RegTransDW( hw_reg_set reg ) +/**********************************/ { int i; diff --git a/bld/cg/intel/h/x86regn.h b/bld/cg/intel/h/x86regn.h index a67a16e1c1..f954d6b9cd 100644 --- a/bld/cg/intel/h/x86regn.h +++ b/bld/cg/intel/h/x86regn.h @@ -50,5 +50,5 @@ typedef uint_8 reg_idx; extern hw_reg_set GetFPReg( int idx ); extern int CountFPRegs( hw_reg_set regs ); extern int FPRegNum( name *reg_name ); -extern int RegTransDW( hw_reg_set reg ); +extern dw_regs RegTransDW( hw_reg_set reg ); extern int RegTransWV( hw_reg_set reg ); diff --git a/bld/cg/risc/axp/c/axprgtbl.c b/bld/cg/risc/axp/c/axprgtbl.c index 7be9840e4a..de1f55d38a 100644 --- a/bld/cg/risc/axp/c/axprgtbl.c +++ b/bld/cg/risc/axp/c/axprgtbl.c @@ -832,12 +832,12 @@ int GetArchIndex( hw_reg_set regs ) return( RegIndex( regs ) ); } -int RegTransDW( hw_reg_set reg ) +dw_regs RegTransDW( hw_reg_set reg ) /************************************* * Translate reg to register index */ { - return( regTranslate( reg, false ) ); + return( (dw_regs)regTranslate( reg, false ) ); } hw_reg_set FirstReg( reg_set_index regs_idx ) diff --git a/bld/cg/risc/axp/h/axpregn.h b/bld/cg/risc/axp/h/axpregn.h index d44ba6f13c..d4ab0b10e1 100644 --- a/bld/cg/risc/axp/h/axpregn.h +++ b/bld/cg/risc/axp/h/axpregn.h @@ -41,4 +41,4 @@ typedef enum { typedef uint_8 reg_idx; extern reg_idx RegIndex( hw_reg_set reg ); -extern int RegTransDW( hw_reg_set reg ); +extern dw_regs RegTransDW( hw_reg_set reg ); diff --git a/bld/cg/risc/mps/c/mpsrgtbl.c b/bld/cg/risc/mps/c/mpsrgtbl.c index 20dd01c8b8..278652e28e 100644 --- a/bld/cg/risc/mps/c/mpsrgtbl.c +++ b/bld/cg/risc/mps/c/mpsrgtbl.c @@ -902,12 +902,12 @@ int GetArchIndex( hw_reg_set regs ) } -int RegTransDW( hw_reg_set reg ) +dw_regs RegTransDW( hw_reg_set reg ) /************************************* * Translate reg to register index */ { - return( regTranslate( reg, false ) ); + return( (dw_regs)regTranslate( reg, false ) ); } hw_reg_set FirstReg( reg_set_index regs_idx ) diff --git a/bld/cg/risc/mps/h/mpsregn.h b/bld/cg/risc/mps/h/mpsregn.h index daf004e3ec..e8e1797812 100644 --- a/bld/cg/risc/mps/h/mpsregn.h +++ b/bld/cg/risc/mps/h/mpsregn.h @@ -40,4 +40,4 @@ typedef enum { typedef uint_8 reg_idx; extern reg_idx RegIndex( hw_reg_set reg ); -extern int RegTransDW( hw_reg_set reg ); +extern dw_regs RegTransDW( hw_reg_set reg ); diff --git a/bld/cg/risc/ppc/c/ppcrgtbl.c b/bld/cg/risc/ppc/c/ppcrgtbl.c index 3ae5f36c85..93a52aae78 100644 --- a/bld/cg/risc/ppc/c/ppcrgtbl.c +++ b/bld/cg/risc/ppc/c/ppcrgtbl.c @@ -820,12 +820,12 @@ int GetArchIndex( hw_reg_set regs ) return( RegIndex( regs ) ); } -int RegTransDW( hw_reg_set reg ) +dw_regs RegTransDW( hw_reg_set reg ) /************************************* * Translate reg to enum name */ { - return( regTranslate( reg, false ) ); + return( (dw_regs)regTranslate( reg, false ) ); } hw_reg_set ParmRegConflicts( hw_reg_set r ) diff --git a/bld/cg/risc/ppc/h/ppcregn.h b/bld/cg/risc/ppc/h/ppcregn.h index 629c3122a4..79fc4196f5 100644 --- a/bld/cg/risc/ppc/h/ppcregn.h +++ b/bld/cg/risc/ppc/h/ppcregn.h @@ -41,4 +41,4 @@ typedef enum { typedef uint_8 reg_idx; extern reg_idx RegIndex( hw_reg_set reg ); -extern int RegTransDW( hw_reg_set reg ); +extern dw_regs RegTransDW( hw_reg_set reg ); From b8c84a2c3478153f88aced3cd046262e5306bbb6 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Mon, 9 Oct 2023 10:04:33 +0200 Subject: [PATCH 226/258] cleanup cg code rename functions to be consistent over cg code --- bld/cg/risc/axp/c/axpenc.c | 88 ++++++++++++++++++------------------ bld/cg/risc/axp/c/axpproc.c | 2 +- bld/cg/risc/axp/c/axprgtbl.c | 4 +- bld/cg/risc/axp/h/axpregn.h | 2 +- bld/cg/risc/mps/c/mpsenc.c | 82 ++++++++++++++++----------------- bld/cg/risc/mps/c/mpsproc.c | 2 +- bld/cg/risc/mps/c/mpsrgtbl.c | 4 +- bld/cg/risc/mps/h/mpsregn.h | 2 +- bld/cg/risc/ppc/c/ppcenc.c | 82 ++++++++++++++++----------------- bld/cg/risc/ppc/c/ppcproc.c | 2 +- bld/cg/risc/ppc/c/ppcrgtbl.c | 4 +- bld/cg/risc/ppc/h/ppcregn.h | 2 +- 12 files changed, 138 insertions(+), 138 deletions(-) diff --git a/bld/cg/risc/axp/c/axpenc.c b/bld/cg/risc/axp/c/axpenc.c index 4b244f915a..f4082b1f34 100644 --- a/bld/cg/risc/axp/c/axpenc.c +++ b/bld/cg/risc/axp/c/axpenc.c @@ -60,7 +60,7 @@ #include "feprotos.h" -#define _NameRegIndex( op ) ( (op)->r.arch_index ) +#define _NameRegTrans( op ) ( (op)->r.arch_index ) #define _BinaryOpcode( a, b ) { { a, b }, { a, b } } #define _SignedOpcode( a, b, c, d ) { { a, b }, { c, d } } @@ -412,13 +412,13 @@ static void GenBRANCH( uint_8 opcode, reg_idx reg, pointer label ) void GenLOAD( hw_reg_set dst, hw_reg_set src, signed_16 displacement ) /***********************************************************************/ { - GenMEMINS( 0x29, RegIndex( dst ), RegIndex( src ), displacement ); + GenMEMINS( 0x29, RegTrans( dst ), RegTrans( src ), displacement ); } void GenFLOAD( hw_reg_set dst, hw_reg_set src, signed_16 displacement ) /************************************************************************/ { - GenMEMINS( 0x23, RegIndex( dst ), RegIndex( src ), displacement ); + GenMEMINS( 0x23, RegTrans( dst ), RegTrans( src ), displacement ); } /* @@ -428,7 +428,7 @@ void GenFLOAD( hw_reg_set dst, hw_reg_set src, signed_16 displacement ) void GenSTORE( hw_reg_set dst, signed_16 displacement, hw_reg_set src ) /************************************************************************/ { - GenMEMINS( 0x2d, RegIndex( src ), RegIndex( dst ), displacement ); + GenMEMINS( 0x2d, RegTrans( src ), RegTrans( dst ), displacement ); } /* @@ -438,7 +438,7 @@ void GenSTORE( hw_reg_set dst, signed_16 displacement, hw_reg_set src ) void GenFSTORE( hw_reg_set dst, signed_16 displacement, hw_reg_set src ) /*************************************************************************/ { - GenMEMINS( 0x27, RegIndex( src ), RegIndex( dst ), displacement ); + GenMEMINS( 0x27, RegTrans( src ), RegTrans( dst ), displacement ); } void GenReturn( void ) @@ -565,7 +565,7 @@ static void getMemEncoding( name *mem, reg_idx *regidx_mem, int_16 *offset ) assert( mem->i.scale == 0 ); assert( mem->i.constant == (type_length)((signed_16)mem->i.constant) ); assert( ( mem->i.index_flags & X_LOW_ADDR_BASE ) == 0 ); - *regidx_mem = _NameRegIndex( mem->i.index ); + *regidx_mem = _NameRegTrans( mem->i.index ); *offset = (int_16)mem->i.constant; break; case N_TEMP: @@ -606,7 +606,7 @@ static void doLoadStore( instruction *ins, bool load ) } assert( reg->n.class == N_REGISTER ); getMemEncoding( mem, ®idx_mem, &offset ); - GenMEMINS( opcode, _NameRegIndex( reg ), regidx_mem, offset ); + GenMEMINS( opcode, _NameRegTrans( reg ), regidx_mem, offset ); } static void GenCallIndirect( instruction *call ) @@ -621,7 +621,7 @@ static void GenCallIndirect( instruction *call ) addr = call->operands[CALL_OP_ADDR]; switch( addr->n.class ) { case N_REGISTER: - regidx = _NameRegIndex( addr ); + regidx = _NameRegTrans( addr ); break; case N_TEMP: case N_INDEXED: @@ -654,9 +654,9 @@ static void doChop( instruction *ins, type_class_def type_class ) _Zoiks( ZOIKS_078 ); } /* zapnot */ - GenOPIMM8( 0x12, 0x31, _NameRegIndex( ins->operands[0] ), + GenOPIMM8( 0x12, 0x31, _NameRegTrans( ins->operands[0] ), (uint_8)zap_mask, - _NameRegIndex( ins->result ) ); + _NameRegTrans( ins->result ) ); } static void doSignExtend( instruction *ins, type_class_def type_class ) @@ -667,8 +667,8 @@ static void doSignExtend( instruction *ins, type_class_def type_class ) reg_idx regidx_src; int shift_amt; - regidx_res = _NameRegIndex( ins->result ); - regidx_src = _NameRegIndex( ins->operands[0] ); + regidx_res = _NameRegTrans( ins->result ); + regidx_src = _NameRegTrans( ins->operands[0] ); from_size = TypeClassSize[type_class]; if( from_size == 4 ) { /* addl r31, src -> dst */ @@ -718,7 +718,7 @@ static bool encodeThreadDataRef( instruction *ins ) GenMEMINS( loadOpcodes[I4], RT_RET_REG_IDX, RT_RET_REG_IDX, RDTEB_MAGIC_CONST ); GenOPINS( 0x0010, 0x0002, AT_REG_IDX, RT_RET_REG_IDX, RT_RET_REG_IDX ); GenMEMINS( loadOpcodes[I4], RT_RET_REG_IDX, RT_RET_REG_IDX, 0 ); - GenMEMINSRELOC( 0x08, _NameRegIndex( ins->result ), + GenMEMINSRELOC( 0x08, _NameRegTrans( ins->result ), RT_RET_REG_IDX, 0, symLabel( op ), OWL_RELOC_HALF_LO ); return( true ); } @@ -752,26 +752,26 @@ static void Encode( instruction *ins ) switch( ins->type_class ) { case FS: GenFPOPINS( 0x16, 0x81, ZERO_REG_IDX, - _NameRegIndex( ins->operands[0] ), - _NameRegIndex( ins->result ) ); + _NameRegTrans( ins->operands[0] ), + _NameRegTrans( ins->result ) ); break; case FD: case FL: GenFPOPINS( 0x16, 0xa1, ZERO_REG_IDX, - _NameRegIndex( ins->operands[0] ), - _NameRegIndex( ins->result ) ); + _NameRegTrans( ins->operands[0] ), + _NameRegTrans( ins->result ) ); break; default: GenOPINS( 0x10, 0x09, ZERO_REG_IDX, - _NameRegIndex( ins->operands[0] ), - _NameRegIndex( ins->result ) ); + _NameRegTrans( ins->operands[0] ), + _NameRegTrans( ins->result ) ); } break; case OP_COMPLEMENT: /* NOT Ra => Rb ...becomes... ORNOT R31,Ra => Rb */ GenOPINS( 0x11, 0x28, ZERO_REG_IDX, - _NameRegIndex( ins->operands[0] ), - _NameRegIndex( ins->result ) ); + _NameRegTrans( ins->operands[0] ), + _NameRegTrans( ins->result ) ); break; default: _Zoiks( ZOIKS_028 ); @@ -780,8 +780,8 @@ static void Encode( instruction *ins ) case G_MOVE_FP: /* CPYS r1,r1,r2 */ GenFPOPINS( 0x17, 0x20, - _NameRegIndex( ins->operands[0] ), _NameRegIndex( ins->operands[0] ), - _NameRegIndex( ins->result ) ); + _NameRegTrans( ins->operands[0] ), _NameRegTrans( ins->operands[0] ), + _NameRegTrans( ins->result ) ); break; case G_ZERO: assert( ins->operands[0]->n.class == N_REGISTER ); @@ -799,13 +799,13 @@ static void Encode( instruction *ins ) assert( ins->operands[0]->n.class == N_REGISTER ); assert( ins->result->n.class == N_REGISTER ); GenFPOPINS( 0x16, 0xac, - 31, _NameRegIndex( ins->operands[0] ), - _NameRegIndex( ins->result ) ); + 31, _NameRegTrans( ins->operands[0] ), + _NameRegTrans( ins->result ) ); break; case G_FREGTOMI8: assert( ins->operands[0]->n.class == N_REGISTER ); assert( ins->result->n.class != N_REGISTER ); - regidx = _NameRegIndex( ins->operands[0] ); + regidx = _NameRegTrans( ins->operands[0] ); GenFPOPINS( 0x16, 0x2f, ZERO_REG_IDX, regidx, FP_AT_REG_IDX ); getMemEncoding( ins->result, ®idx_mem, &mem_offset ); GenMEMINS( 0x27, FP_AT_REG_IDX, regidx_mem, mem_offset ); @@ -813,7 +813,7 @@ static void Encode( instruction *ins ) case G_MI8TOFREG: assert( ins->operands[0]->n.class != N_REGISTER ); assert( ins->result->n.class == N_REGISTER ); - regidx = _NameRegIndex( ins->result ); + regidx = _NameRegTrans( ins->result ); getMemEncoding( ins->operands[0], ®idx_mem, &mem_offset ); GenMEMINS( 0x23, regidx, regidx_mem, mem_offset ); GenFPOPINS( 0x16, 0xbe, ZERO_REG_IDX, regidx, regidx ); @@ -824,8 +824,8 @@ static void Encode( instruction *ins ) assert( ins->result->n.class == N_REGISTER ); function = FindFloatingOpcodes( ins ); GenFPOPINS( 0x16, function, - _NameRegIndex( ins->operands[0] ), _NameRegIndex( ins->operands[1] ), - _NameRegIndex( ins->result ) ); + _NameRegTrans( ins->operands[0] ), _NameRegTrans( ins->operands[1] ), + _NameRegTrans( ins->result ) ); break; case G_BINARY: assert( ins->operands[0]->n.class == N_REGISTER ); @@ -833,17 +833,17 @@ static void Encode( instruction *ins ) assert( ins->result->n.class == N_REGISTER ); opcodes = FindOpcodes( ins ); GenOPINS( opcodes[0], opcodes[1], - _NameRegIndex( ins->operands[0] ), _NameRegIndex( ins->operands[1] ), - _NameRegIndex( ins->result ) ); + _NameRegTrans( ins->operands[0] ), _NameRegTrans( ins->operands[1] ), + _NameRegTrans( ins->result ) ); break; case G_BINARY_IMM: assert( ins->operands[0]->n.class == N_REGISTER ); assert( ins->operands[1]->n.class == N_CONSTANT ); assert( ins->result->n.class == N_REGISTER ); opcodes = FindOpcodes( ins ); - GenOPIMM8( opcodes[0], opcodes[1], _NameRegIndex( ins->operands[0] ), + GenOPIMM8( opcodes[0], opcodes[1], _NameRegTrans( ins->operands[0] ), (uint_8)ins->operands[1]->c.lo.int_value, - _NameRegIndex( ins->result ) ); + _NameRegTrans( ins->result ) ); break; case G_BYTE_CONST: /* @@ -853,7 +853,7 @@ static void Encode( instruction *ins ) assert( ins->result->n.class == N_REGISTER ); GenOPIMM8( 0x10, 0x00, ZERO_REG_IDX, (uint_8)ins->operands[0]->c.lo.int_value, - _NameRegIndex( ins->result ) ); + _NameRegTrans( ins->result ) ); break; case G_MOVE: assert( ins->operands[0]->n.class == N_REGISTER ); @@ -862,8 +862,8 @@ static void Encode( instruction *ins ) * generate a "BIS R31,Rn,Rm" instruction */ GenOPINS( 0x11, 0x20, - ZERO_REG_IDX, _NameRegIndex( ins->operands[0] ), - _NameRegIndex( ins->result ) ); + ZERO_REG_IDX, _NameRegTrans( ins->operands[0] ), + _NameRegTrans( ins->result ) ); break; case G_ZAP: assert( ins->operands[0]->n.class == N_REGISTER ); @@ -872,22 +872,22 @@ static void Encode( instruction *ins ) /* * generate a "ZAPNOT Ra,#i,Rb" instruction */ - GenOPIMM8( 0x12, 0x31, _NameRegIndex( ins->operands[0] ), + GenOPIMM8( 0x12, 0x31, _NameRegTrans( ins->operands[0] ), zapMask[ins->flags.zap_value], - _NameRegIndex( ins->result ) ); + _NameRegTrans( ins->result ) ); break; case G_LEA_HIGH: assert( ins->operands[0]->n.class == N_CONSTANT ); assert( ins->operands[0]->c.const_type == CONS_HIGH_ADDR ); assert( ins->result->n.class == N_REGISTER ); - GenMEMINS( 0x09, _NameRegIndex( ins->result ), ZERO_REG_IDX, ins->operands[0]->c.lo.int_value & 0xffff ); + GenMEMINS( 0x09, _NameRegTrans( ins->result ), ZERO_REG_IDX, ins->operands[0]->c.lo.int_value & 0xffff ); break; case G_LEA: assert( ins->operands[0]->n.class == N_CONSTANT ); assert( ins->result->n.class == N_REGISTER ); switch( ins->operands[0]->c.const_type ) { case CONS_ABSOLUTE: - GenMEMINS( 0x08, _NameRegIndex( ins->result ), ZERO_REG_IDX, ins->operands[0]->c.lo.int_value ); + GenMEMINS( 0x08, _NameRegTrans( ins->result ), ZERO_REG_IDX, ins->operands[0]->c.lo.int_value ); break; case CONS_LOW_ADDR: case CONS_HIGH_ADDR: @@ -903,7 +903,7 @@ static void Encode( instruction *ins ) case N_TEMP: assert( ins->result->n.class == N_REGISTER ); getMemEncoding( ins->operands[0], ®idx_mem, &mem_offset ); - GenMEMINS( 0x08, _NameRegIndex( ins->result ), regidx_mem, mem_offset ); + GenMEMINS( 0x08, _NameRegTrans( ins->result ), regidx_mem, mem_offset ); break; case N_MEMORY: assert( ins->result->n.class == N_REGISTER ); @@ -912,9 +912,9 @@ static void Encode( instruction *ins ) _Zoiks( ZOIKS_132 ); } if( !encodeThreadDataRef( ins ) ) { - GenMEMINSRELOC( 0x09, _NameRegIndex( ins->result ), ZERO_REG_IDX, high, + GenMEMINSRELOC( 0x09, _NameRegTrans( ins->result ), ZERO_REG_IDX, high, symLabel( ins->operands[0] ), OWL_RELOC_HALF_HI ); - GenMEMINSRELOC( 0x08, _NameRegIndex( ins->result ), _NameRegIndex( ins->result ), low, + GenMEMINSRELOC( 0x08, _NameRegTrans( ins->result ), _NameRegTrans( ins->result ), low, symLabel( ins->operands[0] ), OWL_RELOC_HALF_LO ); } break; @@ -971,7 +971,7 @@ void GenJumpIf( instruction *ins, pointer label ) /**************************************************/ { GenBRANCH( BranchOpcodes[ins->head.opcode - FIRST_COMPARISON][_IsFloating( ins->type_class )], - _NameRegIndex( ins->operands[0] ), label ); + _NameRegTrans( ins->operands[0] ), label ); #ifdef DEVBUILD if( _IsTargetModel( CGSW_RISC_ASM_OUTPUT ) ) { DumpLiteral( "Jcc L" ); diff --git a/bld/cg/risc/axp/c/axpproc.c b/bld/cg/risc/axp/c/axpproc.c index 34b9dd648d..27794fb5e4 100644 --- a/bld/cg/risc/axp/c/axpproc.c +++ b/bld/cg/risc/axp/c/axpproc.c @@ -152,7 +152,7 @@ static uint_32 registerMask( hw_reg_set rs, hw_reg_set *rl ) result = 0; for( curr = rl; !HW_CEqual( *curr, HW_EMPTY ); curr++ ) { if( HW_Ovlap( rs, *curr ) ) { - result |= 1 << RegIndex( *curr ); + result |= 1 << RegTrans( *curr ); } } return( result ); diff --git a/bld/cg/risc/axp/c/axprgtbl.c b/bld/cg/risc/axp/c/axprgtbl.c index de1f55d38a..424c0e1e5b 100644 --- a/bld/cg/risc/axp/c/axprgtbl.c +++ b/bld/cg/risc/axp/c/axprgtbl.c @@ -818,7 +818,7 @@ static int regTranslate( hw_reg_set reg, bool index ) return( DW_REG_END ); } -reg_idx RegIndex( hw_reg_set reg ) +reg_idx RegTrans( hw_reg_set reg ) /********************************* * Translate reg to register index */ @@ -829,7 +829,7 @@ reg_idx RegIndex( hw_reg_set reg ) int GetArchIndex( hw_reg_set regs ) /***********************************************/ { - return( RegIndex( regs ) ); + return( RegTrans( regs ) ); } dw_regs RegTransDW( hw_reg_set reg ) diff --git a/bld/cg/risc/axp/h/axpregn.h b/bld/cg/risc/axp/h/axpregn.h index d4ab0b10e1..eeb8520aaf 100644 --- a/bld/cg/risc/axp/h/axpregn.h +++ b/bld/cg/risc/axp/h/axpregn.h @@ -40,5 +40,5 @@ typedef enum { typedef uint_8 reg_idx; -extern reg_idx RegIndex( hw_reg_set reg ); +extern reg_idx RegTrans( hw_reg_set reg ); extern dw_regs RegTransDW( hw_reg_set reg ); diff --git a/bld/cg/risc/mps/c/mpsenc.c b/bld/cg/risc/mps/c/mpsenc.c index 4191edaf80..d7a7ab0b98 100644 --- a/bld/cg/risc/mps/c/mpsenc.c +++ b/bld/cg/risc/mps/c/mpsenc.c @@ -58,7 +58,7 @@ #include "feprotos.h" -#define _NameRegIndex( op ) ( (op)->r.arch_index ) +#define _NameRegTrans( op ) ( (op)->r.arch_index ) #define _BinaryOpcode( a, b ) { { a, b }, { a, b } } #define _SignedOpcode( a, b, c, d ) { { a, b }, { c, d } } @@ -604,7 +604,7 @@ static void getMemEncoding( name *mem, reg_idx *regidx_mem, int_16 *offset ) assert( mem->i.scale == 0 ); assert( mem->i.constant == (type_length)((int_16)mem->i.constant) ); assert( ( mem->i.index_flags & X_LOW_ADDR_BASE ) == 0 ); - *regidx_mem = _NameRegIndex( mem->i.index ); + *regidx_mem = _NameRegTrans( mem->i.index ); *offset = (int_16)mem->i.constant; break; case N_TEMP: @@ -640,7 +640,7 @@ static void doLoadStore( instruction *ins, bool load ) } assert( reg->n.class == N_REGISTER ); getMemEncoding( mem, ®idx_mem, &offset ); - GenMEMINS( opcode, _NameRegIndex( reg ), regidx_mem, offset ); + GenMEMINS( opcode, _NameRegTrans( reg ), regidx_mem, offset ); } @@ -675,8 +675,8 @@ static void doLoadStoreUnaligned( instruction *ins, bool load ) /* * TODO: make sure offset can't overflow */ - GenMEMINS( opcode1, _NameRegIndex( reg ), regidx_mem, offset + 3 ); - GenMEMINS( opcode2, _NameRegIndex( reg ), regidx_mem, offset ); + GenMEMINS( opcode1, _NameRegTrans( reg ), regidx_mem, offset + 3 ); + GenMEMINS( opcode2, _NameRegTrans( reg ), regidx_mem, offset ); #else doLoadStore( ins, load ); #endif @@ -698,7 +698,7 @@ static void GenCallIndirect( instruction *call ) addr = call->operands[CALL_OP_ADDR]; switch( addr->n.class ) { case N_REGISTER: - regidx = _NameRegIndex( addr ); + regidx = _NameRegTrans( addr ); break; case N_TEMP: case N_INDEXED: @@ -728,13 +728,13 @@ static void doZero( instruction *ins, type_class_def type_class ) /* * 'andi res,op1,0x00ff' */ - GenIType( 0x0c, _NameRegIndex( ins->result ), _NameRegIndex( ins->operands[0] ), 0x00ff ); + GenIType( 0x0c, _NameRegTrans( ins->result ), _NameRegTrans( ins->operands[0] ), 0x00ff ); break; case 2: /* * 'andi res,op1,0xffff' */ - GenIType( 0x0c, _NameRegIndex( ins->result ), _NameRegIndex( ins->operands[0] ), (int_16)0x0ffff ); + GenIType( 0x0c, _NameRegTrans( ins->result ), _NameRegTrans( ins->operands[0] ), (int_16)0x0ffff ); break; default: _Zoiks( ZOIKS_091 ); @@ -750,8 +750,8 @@ static void doSignExtend( instruction *ins, type_class_def type_class ) int src_index; int shift_amt; - res_index = _NameRegIndex( ins->result ); - src_index = _NameRegIndex( ins->operands[0] ); + res_index = _NameRegTrans( ins->result ); + src_index = _NameRegTrans( ins->operands[0] ); from_size = TypeClassSize[type_class]; if( from_size == 4 ) { /* @@ -818,7 +818,7 @@ static bool encodeThreadDataRef( instruction *ins ) GenMEMINS( loadOpcodes[I4], RT_RET_REG_IDX, RT_RET_REG_IDX, RDTEB_MAGIC_CONST ); GenOPINS( 0x0010, 0x0002, AT_REG_IDX, RT_RET_REG_IDX, RT_RET_REG_IDX ); GenMEMINS( loadOpcodes[I4], RT_RET_REG_IDX, RT_RET_REG_IDX, 0 ); - GenMEMINSRELOC( 0x08, _NameRegIndex( ins->result ), + GenMEMINSRELOC( 0x08, _NameRegTrans( ins->result ), RT_RET_REG_IDX, 0, symLabel( op ), OWL_RELOC_HALF_LO ); #else assert( 0 ); @@ -861,20 +861,20 @@ static void Encode( instruction *ins ) case FS: case FD: case FL: - GenFloatRType( ins->type_class, 0x07, _NameRegIndex( ins->result ), _NameRegIndex( ins->operands[0] ), 0 ); + GenFloatRType( ins->type_class, 0x07, _NameRegTrans( ins->result ), _NameRegTrans( ins->operands[0] ), 0 ); break; default: /* * 'subu rd,$zero,rs' */ - GenRType( 0x00, 0x23, _NameRegIndex( ins->result ), ZERO_REG_IDX, _NameRegIndex( ins->operands[0] ) ); + GenRType( 0x00, 0x23, _NameRegTrans( ins->result ), ZERO_REG_IDX, _NameRegTrans( ins->operands[0] ) ); } break; case OP_COMPLEMENT: /* * 'nor rd,$zero,rs' */ - GenRType( 0x00, 0x27, _NameRegIndex( ins->result ), ZERO_REG_IDX, _NameRegIndex( ins->operands[0] ) ); + GenRType( 0x00, 0x27, _NameRegTrans( ins->result ), ZERO_REG_IDX, _NameRegTrans( ins->operands[0] ) ); break; default: _Zoiks( ZOIKS_028 ); @@ -886,7 +886,7 @@ static void Encode( instruction *ins ) /* * 'mov.s fd,fs' */ - GenFloatRType( FS, 0x06, _NameRegIndex( ins->result ), _NameRegIndex( ins->operands[0] ), 0 ); + GenFloatRType( FS, 0x06, _NameRegTrans( ins->result ), _NameRegTrans( ins->operands[0] ), 0 ); break; case G_ZERO: assert( ins->operands[0]->n.class == N_REGISTER ); @@ -906,12 +906,12 @@ static void Encode( instruction *ins ) /* * 'cvt.s.d fd,fs' */ - GenFloatRType( FD, 0x20, _NameRegIndex( ins->result ), _NameRegIndex( ins->operands[0] ), 0 ); + GenFloatRType( FD, 0x20, _NameRegTrans( ins->result ), _NameRegTrans( ins->operands[0] ), 0 ); break; case G_FREGTOMI8: assert( ins->operands[0]->n.class == N_REGISTER ); assert( ins->result->n.class != N_REGISTER ); - regidx = _NameRegIndex( ins->operands[0] ); + regidx = _NameRegTrans( ins->operands[0] ); getMemEncoding( ins->result, ®idx_mem, &mem_offset ); /* * 'sdc1 rt,offset(base)' - MIPS32-R2/MIPS64 only? @@ -921,7 +921,7 @@ static void Encode( instruction *ins ) case G_MI8TOFREG: assert( ins->operands[0]->n.class != N_REGISTER ); assert( ins->result->n.class == N_REGISTER ); - regidx = _NameRegIndex( ins->result ); + regidx = _NameRegTrans( ins->result ); getMemEncoding( ins->operands[0], ®idx_mem, &mem_offset ); /* * 'ldc1 rt,offset(base)' - MIPS32-R2/MIPS64 only? @@ -933,8 +933,8 @@ static void Encode( instruction *ins ) assert( ins->operands[1]->n.class == N_REGISTER ); assert( ins->result->n.class == N_REGISTER ); function = FindFloatingOpcodes( ins ); - regidx = _OpIsSet( ins->head.opcode ) ? 0 : _NameRegIndex( ins->result ); - GenFloatRType( ins->type_class, function, regidx, _NameRegIndex( ins->operands[0] ), _NameRegIndex( ins->operands[1] ) ); + regidx = _OpIsSet( ins->head.opcode ) ? 0 : _NameRegTrans( ins->result ); + GenFloatRType( ins->type_class, function, regidx, _NameRegTrans( ins->operands[0] ), _NameRegTrans( ins->operands[1] ) ); break; case G_BINARY: assert( ins->operands[0]->n.class == N_REGISTER ); @@ -947,37 +947,37 @@ static void Encode( instruction *ins ) /* * 'sllv', 'srlv' and 'srav' have the operands backwards */ - GenRType( opcodes[0], opcodes[1], _NameRegIndex( ins->result ), _NameRegIndex( ins->operands[1] ), _NameRegIndex( ins->operands[0] ) ); + GenRType( opcodes[0], opcodes[1], _NameRegTrans( ins->result ), _NameRegTrans( ins->operands[1] ), _NameRegTrans( ins->operands[0] ) ); break; case OP_MUL: - GenRType( opcodes[0], opcodes[1], 0, _NameRegIndex( ins->operands[0] ), _NameRegIndex( ins->operands[1] ) ); + GenRType( opcodes[0], opcodes[1], 0, _NameRegTrans( ins->operands[0] ), _NameRegTrans( ins->operands[1] ) ); /* * 'mflo rd' */ - GenRType( 0, 0x12, _NameRegIndex( ins->result ), 0, 0 ); + GenRType( 0, 0x12, _NameRegTrans( ins->result ), 0, 0 ); break; case OP_DIV: /* * TODO: do something if divisor is zero */ - GenRType( opcodes[0], opcodes[1], 0, _NameRegIndex( ins->operands[0] ), _NameRegIndex( ins->operands[1] ) ); + GenRType( opcodes[0], opcodes[1], 0, _NameRegTrans( ins->operands[0] ), _NameRegTrans( ins->operands[1] ) ); /* * 'mflo rd' */ - GenRType( 0, 0x12, _NameRegIndex( ins->result ), 0, 0 ); + GenRType( 0, 0x12, _NameRegTrans( ins->result ), 0, 0 ); break; case OP_MOD: /* * TODO: do something if divisor is zero */ - GenRType( opcodes[0], opcodes[1], 0, _NameRegIndex( ins->operands[0] ), _NameRegIndex( ins->operands[1] ) ); + GenRType( opcodes[0], opcodes[1], 0, _NameRegTrans( ins->operands[0] ), _NameRegTrans( ins->operands[1] ) ); /* * 'mfhi rd' */ - GenRType( 0, 0x10, _NameRegIndex( ins->result ), 0, 0 ); + GenRType( 0, 0x10, _NameRegTrans( ins->result ), 0, 0 ); break; default: - GenRType( opcodes[0], opcodes[1], _NameRegIndex( ins->result ), _NameRegIndex( ins->operands[0] ), _NameRegIndex( ins->operands[1] ) ); + GenRType( opcodes[0], opcodes[1], _NameRegTrans( ins->result ), _NameRegTrans( ins->operands[0] ), _NameRegTrans( ins->operands[1] ) ); break; } break; @@ -991,19 +991,19 @@ static void Encode( instruction *ins ) /* * 'sll rd,rs,n' */ - GenIShift( 0x00, _NameRegIndex( ins->result ), _NameRegIndex( ins->operands[0] ), imm_value ); + GenIShift( 0x00, _NameRegTrans( ins->result ), _NameRegTrans( ins->operands[0] ), imm_value ); break; case OP_RSHIFT: if( _IsSigned( ins->type_class ) ) { /* * 'sra rd,rs,n' */ - GenIShift( 0x03, _NameRegIndex( ins->result ), _NameRegIndex( ins->operands[0] ), imm_value ); + GenIShift( 0x03, _NameRegTrans( ins->result ), _NameRegTrans( ins->operands[0] ), imm_value ); } else { /* * 'srl rd,rs,n' */ - GenIShift( 0x02, _NameRegIndex( ins->result ), _NameRegIndex( ins->operands[0] ), imm_value ); + GenIShift( 0x02, _NameRegTrans( ins->result ), _NameRegTrans( ins->operands[0] ), imm_value ); } break; case OP_SUB: @@ -1017,7 +1017,7 @@ static void Encode( instruction *ins ) */ default: opcode = FindImmedOpcode( ins ); - GenIType( opcode, _NameRegIndex( ins->result ), _NameRegIndex( ins->operands[0] ), imm_value ); + GenIType( opcode, _NameRegTrans( ins->result ), _NameRegTrans( ins->operands[0] ), imm_value ); break; } break; @@ -1030,7 +1030,7 @@ static void Encode( instruction *ins ) /* * 'addiu rt,$zero,immed' */ - GenIType( 0x09, _NameRegIndex( ins->result ), ZERO_REG_IDX, (uint_8)ins->operands[0]->c.lo.int_value ); + GenIType( 0x09, _NameRegTrans( ins->result ), ZERO_REG_IDX, (uint_8)ins->operands[0]->c.lo.int_value ); break; case G_MOVE: assert( ins->operands[0]->n.class == N_REGISTER ); @@ -1038,13 +1038,13 @@ static void Encode( instruction *ins ) /* * 'or rd,rs,$zero' */ - GenRType( 0x00, 0x25, _NameRegIndex( ins->result ), _NameRegIndex( ins->operands[0] ), ZERO_REG_IDX ); + GenRType( 0x00, 0x25, _NameRegTrans( ins->result ), _NameRegTrans( ins->operands[0] ), ZERO_REG_IDX ); if( TypeClassSize[ins->type_class] == 8 ) { /* * Move the odd register, too * TODO: there should probably be a separate G_MOVE8? */ - GenRType( 0x00, 0x25, _NameRegIndex( ins->result ) + 1, _NameRegIndex( ins->operands[0] ) + 1, ZERO_REG_IDX ); + GenRType( 0x00, 0x25, _NameRegTrans( ins->result ) + 1, _NameRegTrans( ins->operands[0] ) + 1, ZERO_REG_IDX ); } break; case G_LEA_HIGH: @@ -1054,7 +1054,7 @@ static void Encode( instruction *ins ) /* * 'lui rt,immed' */ - GenIType( 0x0f, _NameRegIndex( ins->result ), ZERO_REG_IDX, ins->operands[0]->c.lo.int_value & 0xffff ); + GenIType( 0x0f, _NameRegTrans( ins->result ), ZERO_REG_IDX, ins->operands[0]->c.lo.int_value & 0xffff ); break; case G_LEA: assert( ins->operands[0]->n.class == N_CONSTANT ); @@ -1064,7 +1064,7 @@ static void Encode( instruction *ins ) /* * 'addiu rt,$zero,immed' */ - GenIType( 0x09, _NameRegIndex( ins->result ), ZERO_REG_IDX, ins->operands[0]->c.lo.int_value ); + GenIType( 0x09, _NameRegTrans( ins->result ), ZERO_REG_IDX, ins->operands[0]->c.lo.int_value ); break; case CONS_LOW_ADDR: case CONS_HIGH_ADDR: @@ -1083,7 +1083,7 @@ static void Encode( instruction *ins ) /* * 'addiu rt,rs,immed' */ - GenIType( 0x09, _NameRegIndex( ins->result ), regidx_mem, mem_offset ); + GenIType( 0x09, _NameRegTrans( ins->result ), regidx_mem, mem_offset ); break; case N_MEMORY: assert( ins->result->n.class == N_REGISTER ); @@ -1095,11 +1095,11 @@ static void Encode( instruction *ins ) /* * 'lui rt,immed' */ - GenMEMINSRELOC( 0x0f, _NameRegIndex( ins->result ), ZERO_REG_IDX, high, symLabel( ins->operands[0] ), OWL_RELOC_HALF_HI ); + GenMEMINSRELOC( 0x0f, _NameRegTrans( ins->result ), ZERO_REG_IDX, high, symLabel( ins->operands[0] ), OWL_RELOC_HALF_HI ); /* * 'addiu rt,rs,immed' */ - GenMEMINSRELOC( 0x09, _NameRegIndex( ins->result ), _NameRegIndex( ins->result ), low, symLabel( ins->operands[0] ), OWL_RELOC_HALF_LO ); + GenMEMINSRELOC( 0x09, _NameRegTrans( ins->result ), _NameRegTrans( ins->result ), low, symLabel( ins->operands[0] ), OWL_RELOC_HALF_LO ); } break; default: @@ -1111,7 +1111,7 @@ static void Encode( instruction *ins ) * a load of an unsigned 16-bit immediate * 'ori rt,rs,immed' */ - GenIType( 0x0d, _NameRegIndex( ins->result ), ZERO_REG_IDX, ins->operands[0]->c.lo.int_value ); + GenIType( 0x0d, _NameRegTrans( ins->result ), ZERO_REG_IDX, ins->operands[0]->c.lo.int_value ); break; case G_LOAD_UA: doLoadStoreUnaligned( ins, true ); diff --git a/bld/cg/risc/mps/c/mpsproc.c b/bld/cg/risc/mps/c/mpsproc.c index 6e3f9d37f3..d377e0c325 100644 --- a/bld/cg/risc/mps/c/mpsproc.c +++ b/bld/cg/risc/mps/c/mpsproc.c @@ -163,7 +163,7 @@ static uint_32 registerMask( hw_reg_set rs, hw_reg_set *rl ) result = 0; for( curr = rl; !HW_CEqual( *curr, HW_EMPTY ); curr++ ) { if( HW_Ovlap( rs, *curr ) ) { - result |= 1 << RegIndex( *curr ); + result |= 1 << RegTrans( *curr ); } } return( result ); diff --git a/bld/cg/risc/mps/c/mpsrgtbl.c b/bld/cg/risc/mps/c/mpsrgtbl.c index 278652e28e..53a6270694 100644 --- a/bld/cg/risc/mps/c/mpsrgtbl.c +++ b/bld/cg/risc/mps/c/mpsrgtbl.c @@ -887,7 +887,7 @@ static int regTranslate( hw_reg_set reg, bool index ) return( DW_REG_END ); } -reg_idx RegIndex( hw_reg_set reg ) +reg_idx RegTrans( hw_reg_set reg ) /********************************* * Translate reg to register index */ @@ -898,7 +898,7 @@ reg_idx RegIndex( hw_reg_set reg ) int GetArchIndex( hw_reg_set regs ) /***********************************************/ { - return( RegIndex( regs ) ); + return( RegTrans( regs ) ); } diff --git a/bld/cg/risc/mps/h/mpsregn.h b/bld/cg/risc/mps/h/mpsregn.h index e8e1797812..443bdc70ca 100644 --- a/bld/cg/risc/mps/h/mpsregn.h +++ b/bld/cg/risc/mps/h/mpsregn.h @@ -39,5 +39,5 @@ typedef enum { typedef uint_8 reg_idx; -extern reg_idx RegIndex( hw_reg_set reg ); +extern reg_idx RegTrans( hw_reg_set reg ); extern dw_regs RegTransDW( hw_reg_set reg ); diff --git a/bld/cg/risc/ppc/c/ppcenc.c b/bld/cg/risc/ppc/c/ppcenc.c index 43be1aa509..0dc9266982 100644 --- a/bld/cg/risc/ppc/c/ppcenc.c +++ b/bld/cg/risc/ppc/c/ppcenc.c @@ -59,7 +59,7 @@ #include "feprotos.h" -#define _NameRegIndex( op ) ( (op)->r.arch_index ) +#define _NameRegTrans( op ) ( (op)->r.arch_index ) #define _EmitIns( ins ) ObjBytes( &(ins), sizeof( ppc_ins ) ) #define _ObjEmitSeq( code ) ObjBytes( code->data, code->length ) @@ -426,11 +426,11 @@ static void getMemEncoding( name *mem, reg_idx *regidx_mem, int_16 *offset ) assert( mem->i.scale == 0 ); assert( mem->i.constant == (type_length)((signed_16)mem->i.constant) ); assert( ( mem->i.index_flags & X_LOW_ADDR_BASE ) == 0 ); - *regidx_mem = RegIndex( mem->i.index->r.reg ); + *regidx_mem = RegTrans( mem->i.index->r.reg ); *offset = (int_16)mem->i.constant; break; case N_TEMP: - *regidx_mem = RegIndex( FrameReg() ); + *regidx_mem = RegTrans( FrameReg() ); *offset = TempLocation( mem ); break; case N_MEMORY: @@ -464,7 +464,7 @@ static void doLoadStore( instruction *ins, bool load ) assert( op != 0 ); assert( reg->n.class == N_REGISTER ); getMemEncoding( mem, ®idx_mem, &offset ); - GenMEMINS( op, RegIndex( reg->r.reg ), regidx_mem, offset ); + GenMEMINS( op, RegTrans( reg->r.reg ), regidx_mem, offset ); } @@ -477,14 +477,14 @@ static void doSign( instruction *ins ) /* * extsb */ - GenOPINS( 31, 954, _NameRegIndex( ins->result ), 0, _NameRegIndex( ins->operands[0] ) ); + GenOPINS( 31, 954, _NameRegTrans( ins->result ), 0, _NameRegTrans( ins->operands[0] ) ); break; case U2: case I2: /* * extsh */ - GenOPINS( 31, 922, _NameRegIndex( ins->result ), 0, _NameRegIndex( ins->operands[0] ) ); + GenOPINS( 31, 922, _NameRegTrans( ins->result ), 0, _NameRegTrans( ins->operands[0] ) ); break; default: _Zoiks( ZOIKS_091 ); @@ -501,14 +501,14 @@ static void doZero( instruction *ins ) /* * andi op1,0x00ff -> res */ - GenOPIMM( 28, _NameRegIndex( ins->operands[0] ), _NameRegIndex( ins->result ), 0x00ff ); + GenOPIMM( 28, _NameRegTrans( ins->operands[0] ), _NameRegTrans( ins->result ), 0x00ff ); break; case U2: case I2: /* * andi op1,0xffff -> res */ - GenOPIMM( 28, _NameRegIndex( ins->operands[0] ), _NameRegIndex( ins->result ), (signed_16)0xffff ); + GenOPIMM( 28, _NameRegTrans( ins->operands[0] ), _NameRegTrans( ins->result ), (signed_16)0xffff ); break; default: _Zoiks( ZOIKS_091 ); @@ -535,7 +535,7 @@ static void GenCallIndirect( instruction *call ) GenMEMINS( stw, RTOC_REG_IDX, SP_REG_IDX, 4 ); switch( addr->n.class ) { case N_REGISTER: - src = _NameRegIndex( addr ); + src = _NameRegTrans( addr ); break; case N_TEMP: case N_INDEXED: @@ -562,9 +562,9 @@ static void GenVaStart( instruction *ins ) reg_idx stack; assert( ins->operands[0]->n.class == N_REGISTER ); - reg = _NameRegIndex( ins->operands[0] ); + reg = _NameRegTrans( ins->operands[0] ); tmp = AT_REG_IDX; - stack = RegIndex( FrameReg() ); + stack = RegTrans( FrameReg() ); stb = storeOpcodes[U1]; stw = storeOpcodes[U4]; li = 14; // addi @@ -619,14 +619,14 @@ static void Encode( instruction *ins ) case G_MOVE_FP: assert( ins->result->n.class == N_REGISTER ); assert( ins->operands[0]->n.class == N_REGISTER ); - GenOPINS( 63, 72, 0, _NameRegIndex( ins->operands[0] ), _NameRegIndex( ins->result ) ); + GenOPINS( 63, 72, 0, _NameRegTrans( ins->operands[0] ), _NameRegTrans( ins->result ) ); break; case G_MOVE: // or op, op -> dst assert( ins->result->n.class == N_REGISTER ); assert( ins->operands[0]->n.class == N_REGISTER ); - b = _NameRegIndex( ins->operands[0] ); - GenOPINS( 31, 444, _NameRegIndex( ins->result ), b, b ); + b = _NameRegTrans( ins->operands[0] ); + GenOPINS( 31, 444, _NameRegTrans( ins->result ), b, b ); break; case G_LOAD: case G_STORE: @@ -640,12 +640,12 @@ static void Encode( instruction *ins ) assert( ins->operands[0]->c.const_type == CONS_HIGH_ADDR ); assert( ins->result->n.class == N_REGISTER ); /* addis k(r0) -> rn */ - GenOPIMM( 15, _NameRegIndex( ins->result ), ZERO_REG_IDX, ins->operands[0]->c.lo.int_value & 0xffff ); + GenOPIMM( 15, _NameRegTrans( ins->result ), ZERO_REG_IDX, ins->operands[0]->c.lo.int_value & 0xffff ); break; case G_MOVE_UI: /* a load of an unsigned 16-bit immediate */ /* use or rd, imm(r0) */ - GenOPIMM( 24, _NameRegIndex( ins->result ), ZERO_REG_IDX, ins->operands[0]->c.lo.int_value ); + GenOPIMM( 24, _NameRegTrans( ins->result ), ZERO_REG_IDX, ins->operands[0]->c.lo.int_value ); break; case G_LEA: assert( ins->operands[0]->n.class == N_CONSTANT ); @@ -653,7 +653,7 @@ static void Encode( instruction *ins ) switch( ins->operands[0]->c.const_type ) { case CONS_ABSOLUTE: // addi rd, imm(r0) - GenOPIMM( 14, _NameRegIndex( ins->result ), ZERO_REG_IDX, ins->operands[0]->c.lo.int_value ); + GenOPIMM( 14, _NameRegTrans( ins->result ), ZERO_REG_IDX, ins->operands[0]->c.lo.int_value ); break; case CONS_LOW_ADDR: case CONS_HIGH_ADDR: @@ -670,12 +670,12 @@ static void Encode( instruction *ins ) assert( ins->result->n.class == N_REGISTER ); getMemEncoding( ins->operands[0], ®idx_mem, &mem_offset ); // addi rd,off(ri|sp) - GenOPIMM( 14, _NameRegIndex( ins->result ), regidx_mem, mem_offset ); + GenOPIMM( 14, _NameRegTrans( ins->result ), regidx_mem, mem_offset ); break; case N_MEMORY: assert( ins->result->n.class == N_REGISTER ); OutReloc( symLabel( ins->operands[0] ), PPC_RELOC_TOC_OFFSET, 2 ); - GenMEMINS( 32, _NameRegIndex( ins->result ), RTOC_REG_IDX, 0 ); + GenMEMINS( 32, _NameRegTrans( ins->result ), RTOC_REG_IDX, 0 ); break; default: _Zoiks( ZOIKS_119 ); @@ -688,9 +688,9 @@ static void Encode( instruction *ins ) if( ins->head.opcode == OP_MUL ) { ops = FindOpcodes( ins ); GenFPOPINS( ops[0], ops[1], - _NameRegIndex( ins->operands[0] ), - _NameRegIndex( ins->operands[1] ), - _NameRegIndex( ins->result ) ); + _NameRegTrans( ins->operands[0] ), + _NameRegTrans( ins->operands[1] ), + _NameRegTrans( ins->result ) ); break; } /* fall through */ @@ -699,9 +699,9 @@ static void Encode( instruction *ins ) assert( ins->operands[1]->n.class == N_REGISTER ); assert( ins->result->n.class == N_REGISTER ); ops = FindOpcodes( ins ); - a = _NameRegIndex( ins->operands[0] ); - b = _NameRegIndex( ins->operands[1] ); - s = _NameRegIndex( ins->result ); + a = _NameRegTrans( ins->operands[0] ); + b = _NameRegTrans( ins->operands[1] ); + s = _NameRegTrans( ins->result ); if( ins->head.opcode == OP_SUB && G( ins ) == G_BINARY ) { /* someone sucks - it's not me */ @@ -716,9 +716,9 @@ static void Encode( instruction *ins ) assert( ins->operands[1]->n.class == N_REGISTER ); assert( ins->result->n.class == N_REGISTER ); ops = FindOpcodes( ins ); - s = _NameRegIndex( ins->operands[0] ); - b = _NameRegIndex( ins->operands[1] ); - a = _NameRegIndex( ins->result ); + s = _NameRegTrans( ins->operands[0] ); + b = _NameRegTrans( ins->operands[1] ); + a = _NameRegTrans( ins->result ); GenOPINS( ops[0], ops[1], a, b, s ); break; case G_BINARYS_IMM: @@ -731,28 +731,28 @@ static void Encode( instruction *ins ) // rlwinm dst,src,n,0,31-n op2 = 31 - _FiveBits( ins->operands[1]->c.lo.int_value ); b = _FiveBits( ins->operands[1]->c.lo.int_value ); - GenOPINS( 21, op2, _NameRegIndex( ins->result ), b, _NameRegIndex( ins->operands[0] ) ); + GenOPINS( 21, op2, _NameRegTrans( ins->result ), b, _NameRegTrans( ins->operands[0] ) ); break; case OP_RSHIFT: if( _IsSigned( ins->type_class ) ) { - GenOPINS( 31, 824, _NameRegIndex( ins->result ), - ins->operands[1]->c.lo.int_value, _NameRegIndex( ins->operands[0] ) ); + GenOPINS( 31, 824, _NameRegTrans( ins->result ), + ins->operands[1]->c.lo.int_value, _NameRegTrans( ins->operands[0] ) ); } else { // rlwinm dst,src,32-n,n,31 b = _FiveBits( ins->operands[1]->c.lo.int_value ); op2 = ( b << 5 ) | 31; b = 32 - b; - GenOPINS( 21, op2, _NameRegIndex( ins->result ), b, _NameRegIndex( ins->operands[0] ) ); + GenOPINS( 21, op2, _NameRegTrans( ins->result ), b, _NameRegTrans( ins->operands[0] ) ); } break; default: ops = FindImmedOpcodes( ins ); if( G( ins ) == G_BINARYS_IMM ) { - s = _NameRegIndex( ins->operands[0] ); - a = _NameRegIndex( ins->result ); + s = _NameRegTrans( ins->operands[0] ); + a = _NameRegTrans( ins->result ); } else { - s = _NameRegIndex( ins->result ); - a = _NameRegIndex( ins->operands[0] ); + s = _NameRegTrans( ins->result ); + a = _NameRegTrans( ins->operands[0] ); } GenOPIMM( ops[0], s, a, ins->operands[1]->c.lo.int_value ); break; @@ -761,7 +761,7 @@ static void Encode( instruction *ins ) case G_CMP_FP: assert( ins->operands[0]->n.class == N_REGISTER ); assert( ins->operands[1]->n.class == N_REGISTER ); - GenCMP( 63, 32, _NameRegIndex( ins->operands[0] ), _NameRegIndex( ins->operands[1] ) ); + GenCMP( 63, 32, _NameRegTrans( ins->operands[0] ), _NameRegTrans( ins->operands[1] ) ); break; case G_CMP: assert( ins->operands[0]->n.class == N_REGISTER ); @@ -770,7 +770,7 @@ static void Encode( instruction *ins ) if( _IsSigned( ins->type_class ) ) { op2 = 0; } - GenCMP( 31, op2, _NameRegIndex( ins->operands[0] ), _NameRegIndex( ins->operands[1] ) ); + GenCMP( 31, op2, _NameRegTrans( ins->operands[0] ), _NameRegTrans( ins->operands[1] ) ); break; case G_CMP_I: assert( ins->operands[0]->n.class == N_REGISTER ); @@ -779,7 +779,7 @@ static void Encode( instruction *ins ) if( _IsSigned( ins->type_class ) ) { op1 = 11; } - GenCMPIMM( op1, _NameRegIndex( ins->operands[0] ), ins->operands[1]->c.lo.int_value ); + GenCMPIMM( op1, _NameRegTrans( ins->operands[0] ), ins->operands[1]->c.lo.int_value ); break; case G_SIGN: assert( ins->operands[0]->n.class == N_REGISTER ); @@ -798,8 +798,8 @@ static void Encode( instruction *ins ) case G_UNARY: assert( ins->operands[0]->n.class == N_REGISTER ); assert( ins->result->n.class == N_REGISTER ); - a = _NameRegIndex( ins->operands[0] ); - s = _NameRegIndex( ins->result ); + a = _NameRegTrans( ins->operands[0] ); + s = _NameRegTrans( ins->result ); switch( ins->head.opcode ) { case OP_NEGATE: // neg src -> dst diff --git a/bld/cg/risc/ppc/c/ppcproc.c b/bld/cg/risc/ppc/c/ppcproc.c index 1d6b589c4f..5faa8bab89 100644 --- a/bld/cg/risc/ppc/c/ppcproc.c +++ b/bld/cg/risc/ppc/c/ppcproc.c @@ -148,7 +148,7 @@ static uint_32 registerMask( hw_reg_set rs, hw_reg_set *rl ) result = 0; for( curr = rl; !HW_CEqual( *curr, HW_EMPTY ); curr++ ) { if( HW_Ovlap( rs, *curr ) ) { - result |= 1 << RegIndex( *curr ); + result |= 1 << RegTrans( *curr ); } } return( result ); diff --git a/bld/cg/risc/ppc/c/ppcrgtbl.c b/bld/cg/risc/ppc/c/ppcrgtbl.c index 93a52aae78..8ca5aa6daf 100644 --- a/bld/cg/risc/ppc/c/ppcrgtbl.c +++ b/bld/cg/risc/ppc/c/ppcrgtbl.c @@ -806,7 +806,7 @@ static int regTranslate( hw_reg_set reg, bool index ) return( DW_REG_END ); } -reg_idx RegIndex( hw_reg_set reg ) +reg_idx RegTrans( hw_reg_set reg ) /************************************* * Translate reg to register index */ @@ -817,7 +817,7 @@ reg_idx RegIndex( hw_reg_set reg ) int GetArchIndex( hw_reg_set regs ) /***********************************************/ { - return( RegIndex( regs ) ); + return( RegTrans( regs ) ); } dw_regs RegTransDW( hw_reg_set reg ) diff --git a/bld/cg/risc/ppc/h/ppcregn.h b/bld/cg/risc/ppc/h/ppcregn.h index 79fc4196f5..50e0636d6c 100644 --- a/bld/cg/risc/ppc/h/ppcregn.h +++ b/bld/cg/risc/ppc/h/ppcregn.h @@ -40,5 +40,5 @@ typedef enum { typedef uint_8 reg_idx; -extern reg_idx RegIndex( hw_reg_set reg ); +extern reg_idx RegTrans( hw_reg_set reg ); extern dw_regs RegTransDW( hw_reg_set reg ); From 4dbf2c48390b3df3ad3dfb51bb67254608a44f3a Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Mon, 9 Oct 2023 15:40:50 +0200 Subject: [PATCH 227/258] consolidate architecture register mapping processing into single source file it is consolidated into x86enc.c/axprgtbl.c/mpsrgtbl.c/ppcrgtbl.c source files consolidate all mapping information into new RegsTab array --- bld/cg/h/procdef.h | 4 +- bld/cg/intel/c/x86enc.c | 273 ++++++++++++++++++----------------- bld/cg/intel/h/regindex.h | 93 ++++++++++++ bld/cg/intel/h/x86regn.h | 20 +++ bld/cg/risc/axp/c/axpenc.c | 2 +- bld/cg/risc/axp/c/axprgtbl.c | 131 ++++++++++++----- bld/cg/risc/axp/h/axpregn.h | 14 ++ bld/cg/risc/axp/h/regindex.h | 116 +++++++++++++++ bld/cg/risc/mps/c/mpsenc.c | 26 ++-- bld/cg/risc/mps/c/mpsrgtbl.c | 139 ++++++++++++------ bld/cg/risc/mps/h/mpsregn.h | 32 +++- bld/cg/risc/mps/h/regindex.h | 116 +++++++++++++++ bld/cg/risc/ppc/c/ppcenc.c | 6 +- bld/cg/risc/ppc/c/ppcproc.c | 27 ++-- bld/cg/risc/ppc/c/ppcrgtbl.c | 155 ++++++++++++++------ bld/cg/risc/ppc/h/ppcprocd.h | 6 +- bld/cg/risc/ppc/h/ppcregn.h | 18 ++- bld/cg/risc/ppc/h/regindex.h | 116 +++++++++++++++ 18 files changed, 995 insertions(+), 299 deletions(-) create mode 100644 bld/cg/intel/h/regindex.h create mode 100644 bld/cg/risc/axp/h/regindex.h create mode 100644 bld/cg/risc/mps/h/regindex.h create mode 100644 bld/cg/risc/ppc/h/regindex.h diff --git a/bld/cg/h/procdef.h b/bld/cg/h/procdef.h index 7709efb0a0..2caad53d00 100644 --- a/bld/cg/h/procdef.h +++ b/bld/cg/h/procdef.h @@ -53,8 +53,8 @@ typedef struct parm_state { hw_reg_set *curr_entry; type_length offset; #if _TARGET & _TARG_PPC - unsigned gr; - unsigned fr; + int gr; + int fr; #endif } parm_state; diff --git a/bld/cg/intel/c/x86enc.c b/bld/cg/intel/c/x86enc.c index 32c9d83e96..2f6039495b 100644 --- a/bld/cg/intel/c/x86enc.c +++ b/bld/cg/intel/c/x86enc.c @@ -68,95 +68,102 @@ #include "feprotos.h" -template Temp; /* template for oc_entries */ -byte Inst[INSSIZE]; /* template for instructions */ -byte ILen; /* length of object instruction */ - -static byte ICur; /* cursor for writing into Inst */ -static byte IEsc; /* number of initial bytes that must be */ - /* checked for escapes when copied into Temp */ +/* + * register, register class and range definitions + */ +#define pick_item(id) ARCH_IDX_ ## id +#define pick_start(id) ARCH_ ## id ## _START +#define pick_end(id) ARCH_ ## id ## _END -static hw_reg_set RegTab[] = { -#define REGS 24 - HW_D( HW_AL ), HW_D( HW_AX ), HW_D( HW_EAX ), - HW_D( HW_CL ), HW_D( HW_CX ), HW_D( HW_ECX ), - HW_D( HW_DL ), HW_D( HW_DX ), HW_D( HW_EDX ), - HW_D( HW_BL ), HW_D( HW_BX ), HW_D( HW_EBX ), - HW_D( HW_AH ), HW_D( HW_SP ), HW_D( HW_ESP ), - HW_D( HW_CH ), HW_D( HW_BP ), HW_D( HW_EBP ), - HW_D( HW_DH ), HW_D( HW_SI ), HW_D( HW_ESI ), - HW_D( HW_BH ), HW_D( HW_DI ), HW_D( HW_EDI ) +enum { + #define pick(id,idx,cls) pick_item(id), + #include "regindex.h" + #undef pick + pick_item( END ), + pick_item( START ) = 0 }; -static hw_reg_set SegTab[] = { -#define SEGS 6 - #define _SR_(h,f) HW_D( h ), - #include "x86sregs.h" - #undef _SR_ +enum { + #define MAPREGCLASS + #include "regindex.h" + #undef MAPREGCLASS }; -static hw_reg_set FPRegs[] = { - HW_D( HW_ST0 ), - HW_D( HW_ST1 ), - HW_D( HW_ST2 ), - HW_D( HW_ST3 ), - HW_D( HW_ST4 ), - HW_D( HW_ST5 ), - HW_D( HW_ST6 ), - HW_D( HW_ST7 ) -}; +#undef pick_end +#undef pick_start +#undef pick_item -struct reg_map { - hw_reg_set reg; - dw_regs dwarf; +const arch_reg_info RegsTab[] = { + #define pick(id,idx,cls) { HW_D_1( HW_ ## id ), idx, cls ## _IDX, WV_REG_ ## id, DW_REG_ ## id }, + #include "regindex.h" + #undef pick }; -static struct reg_map DWHWRegValues[] = { - { HW_D( HW_AL ), DW_REG_AL }, - { HW_D( HW_AH ), DW_REG_AH }, - { HW_D( HW_BL ), DW_REG_BL }, - { HW_D( HW_BH ), DW_REG_BH }, - { HW_D( HW_CL ), DW_REG_CL }, - { HW_D( HW_CH ), DW_REG_CH }, - { HW_D( HW_DL ), DW_REG_DL }, - { HW_D( HW_DH ), DW_REG_DH }, - { HW_D( HW_AX ), DW_REG_AX }, - { HW_D( HW_BX ), DW_REG_BX }, - { HW_D( HW_CX ), DW_REG_CX }, - { HW_D( HW_DX ), DW_REG_DX }, - { HW_D( HW_SI ), DW_REG_SI }, - { HW_D( HW_DI ), DW_REG_DI }, - { HW_D( HW_BP ), DW_REG_BP }, - { HW_D( HW_SP ), DW_REG_SP }, - { HW_D( HW_CS ), DW_REG_CS }, - { HW_D( HW_SS ), DW_REG_SS }, - { HW_D( HW_DS ), DW_REG_DS }, - { HW_D( HW_ES ), DW_REG_ES }, - { HW_D( HW_ST0 ), DW_REG_ST0 }, - { HW_D( HW_ST1 ), DW_REG_ST1 }, - { HW_D( HW_ST2 ), DW_REG_ST2 }, - { HW_D( HW_ST3 ), DW_REG_ST3 }, - { HW_D( HW_ST4 ), DW_REG_ST4 }, - { HW_D( HW_ST5 ), DW_REG_ST5 }, - { HW_D( HW_ST6 ), DW_REG_ST6 }, - { HW_D( HW_ST7 ), DW_REG_ST7 }, - { HW_D( HW_EAX ), DW_REG_EAX }, - { HW_D( HW_EBX ), DW_REG_EBX }, - { HW_D( HW_ECX ), DW_REG_ECX }, - { HW_D( HW_EDX ), DW_REG_EDX }, - { HW_D( HW_ESI ), DW_REG_ESI }, - { HW_D( HW_EDI ), DW_REG_EDI }, - { HW_D( HW_EBP ), DW_REG_EBP }, - { HW_D( HW_ESP ), DW_REG_ESP }, - { HW_D( HW_FS ), DW_REG_FS }, - { HW_D( HW_GS ), DW_REG_GS } -}; +template Temp; /* template for oc_entries */ +byte Inst[INSSIZE]; /* template for instructions */ +byte ILen; /* length of object instruction */ -static hw_reg_set WVHWRegValues[] = { - #define pick(name,ci,start,len) HW_D( HW_##name ), - #include "watdbreg.h" - #undef pick -}; +static byte ICur; /* cursor for writing into Inst */ +static byte IEsc; /* number of initial bytes that must be */ + /* checked for escapes when copied into Temp */ +#if 0 +static int findArchRegIndex( hw_reg_set regs, reg_cls cls ) +{ + hw_reg_set save_regs; + int i; + + if( cls & SEG_IDX ) { + save_regs = regs; + } + HW_CTurnOff( regs, HW_SEGS ); + if( cls & GPR_IDX ) { + for( i = ARCH_GPR_START; i < ARCH_GPR_END; i++ ) { + if( HW_Equal( regs, RegsTab[i].hw_reg ) ) { + return( i ); + } + } + } + if( cls & FPR_IDX ) { + for( i = ARCH_FPR_START; i < ARCH_FPR_END; i++ ) { + if( HW_Equal( regs, RegsTab[i].hw_reg ) ) { + return( i ); + } + } + } + if( cls & SEG_IDX ) { + HW_COnlyOn( save_regs, HW_SEGS ); + for( i = ARCH_SEG_START; i < ARCH_SEG_END; i++ ) { + if( HW_Equal( save_regs, RegsTab[i].hw_reg ) ) { + return( i ); + } + } + } + return( -1 ); +} + +hw_reg_set GetArchReg( int idx, reg_cls cls ) +{ + if( cls & GPRB_IDX ) { + return( RegsTab[ARCH_BYTE_START + idx].hw_reg ); + } + if( cls & GPRW_IDX ) { + return( RegsTab[ARCH_WORD_START + idx].hw_reg ); + } + if( cls & GPRD_IDX ) { + return( RegsTab[ARCH_DWORD_START + idx].hw_reg ); + } + if( cls & FPR_IDX ) { + return( RegsTab[ARCH_FPR_START + idx].hw_reg ); + } + if( cls & SEG_IDX ) { + return( RegsTab[ARCH_SEG_START + idx].hw_reg ); + } + if( cls & GPR_IDX ) { + return( RegsTab[ARCH_GPR_START + idx].hw_reg ); + } + return( HW_EMPTY ); +} +#endif /* routines that maintain instruction buffers*/ @@ -354,78 +361,75 @@ static byte SegTrans( hw_reg_set regs ) * Return the encoding of a segment register name */ { - byte i; + int i; HW_COnlyOn( regs, HW_SEGS ); - for( i = 0; i < SEGS; ++i ) { - if( HW_Equal( regs, SegTab[i] ) ) { - break; + for( i = ARCH_SEG_START; i < ARCH_SEG_END; i++ ) { + if( HW_Equal( regs, RegsTab[i].hw_reg ) ) { + return( RegsTab[i].idx ); } } - if( i >= SEGS ) { - _Zoiks( ZOIKS_032 ); - } - return( i ); + _Zoiks( ZOIKS_032 ); + return( 0 ); } -static byte RegTrans( hw_reg_set regs ) -/****************************************** +reg_idx RegTrans( hw_reg_set regs ) +/*********************************** * Return the encoding of a register name */ { - byte i; + int i; HW_CTurnOff( regs, HW_SEGS ); - for( i = 0; i < REGS; ++i ) { - if( HW_Equal( regs, RegTab[i] ) ) { - break; + for( i = ARCH_GPR_START; i < ARCH_GPR_END; i++ ) { + if( HW_Equal( regs, RegsTab[i].hw_reg ) ) { + return( RegsTab[i].idx ); } } - if( i >= REGS ) { - _Zoiks( ZOIKS_031 ); - } - i = i / 3; - return( i ); + _Zoiks( ZOIKS_031 ); + return( 0 ); } -static int FPRegTrans( hw_reg_set reg ) -/*************************************/ +static int FPRegTrans( hw_reg_set regs ) +/**************************************/ { int i; - for( i = 0; i < 8; i++ ) { - if( HW_Equal( reg, FPRegs[i] ) ) { - return( i ); + for( i = ARCH_FPR_START; i < ARCH_FPR_END; i++ ) { + if( HW_Equal( regs, RegsTab[i].hw_reg ) ) { + return( RegsTab[i].idx ); } } return( -1 ); } -dw_regs RegTransDW( hw_reg_set reg ) -/**********************************/ +dw_regs RegTransDW( hw_reg_set regs ) +/***********************************/ { int i; - for( i = 0; i < sizeof( DWHWRegValues ) / sizeof( DWHWRegValues[0] ); i++ ) { - if( HW_Equal( DWHWRegValues[i].reg, reg ) ) { - return( DWHWRegValues[i].dwarf ); + for( i = ARCH_IDX_START; i < ARCH_IDX_END; i++ ) { + if( HW_Equal( regs, RegsTab[i].hw_reg ) ) { + return( RegsTab[i].dw_idx ); } } - Zoiks( ZOIKS_085 ); /* reg not found */ + _Zoiks( ZOIKS_031 ); return( DW_REG_END ); } -int RegTransWV( hw_reg_set reg ) -/******************************/ +int RegTransWV( hw_reg_set regs ) +/*******************************/ { int i; - for( i = 0; i < sizeof( WVHWRegValues ) / sizeof( WVHWRegValues[0] ); i++ ) { - if( HW_Equal( WVHWRegValues[i], reg ) ) { - return( i ); + for( i = ARCH_IDX_START; i < ARCH_IDX_END; i++ ) { + if( HW_Equal( regs, RegsTab[i].hw_reg ) ) { + return( RegsTab[i].wv_idx ); } } + _Zoiks( ZOIKS_031 ); +// return( WV_REG_END ); return( -1 ); } @@ -445,13 +449,14 @@ int FPRegNum( name *reg_name ) } hw_reg_set GetFPReg( int idx ) +/******************************/ { - return( FPRegs[idx] ); + return( RegsTab[ARCH_FPR_START + idx].hw_reg ); } int CountFPRegs( hw_reg_set regs ) -/*********************************************** +/************************************* * Count the number of 8087 registers named in hw_reg_set "regs". */ { @@ -459,8 +464,8 @@ int CountFPRegs( hw_reg_set regs ) int i; count = 0; - for( i = 0; i < 8; i++ ) { - if( HW_Ovlap( FPRegs[i], regs ) ) { + for( i = ARCH_FPR_START; i < ARCH_FPR_END; i++ ) { + if( HW_Ovlap( regs, RegsTab[i].hw_reg ) ) { ++count; } } @@ -1106,29 +1111,29 @@ void GenSeg( hw_reg_set regs ) AddToTemp( M_SEGOVER | ( SegTrans( regs ) << S_KEY_SR ) ); } if( _IsEmulation() ) { - for( i = 0; i < SEGS; ++i ) { - if( HW_Equal( segreg, SegTab[i] ) ) { - SetFPPatchSegm( i ); + for( i = ARCH_SEG_START; i < ARCH_SEG_END; i++ ) { + if( HW_Equal( segreg, RegsTab[i].hw_reg ) ) { + SetFPPatchSegm( RegsTab[i].idx ); break; } } } } -type_class_def OpndSize( hw_reg_set reg ) -/*************************************************** +type_class_def OpndSize( hw_reg_set regs ) +/****************************************** * Generate an operand size prefix if we need it and return the * type_class of the register "reg" */ { - if( HW_COvlap( reg, HW_SEGS ) ) + if( HW_COvlap( regs, HW_SEGS ) ) return( U2 ); #if _TARGET & _TARG_8086 if( _IsTargetModel( CGSW_X86_USE_32 ) ) AddToTemp( M_OPND_SIZE ); return( U2 ); #else - if( HW_COvlap( reg, HW_32 ) ) { + if( HW_COvlap( regs, HW_32 ) ) { if( _IsntTargetModel( CGSW_X86_USE_32 ) ) AddToTemp( M_OPND_SIZE ); return( U4 ); @@ -1291,17 +1296,17 @@ static void AddSWCons( opcode_defs op, name *opnd, type_class_def type_class void AddWData( signed_32 value, type_class_def type_class ) /************************************************************/ { - AddByte( value ); + AddByte( (byte)value ); if( type_class == U1 || type_class == I1 ) return; value >>= 8; - AddByte( value ); + AddByte( (byte)value ); if( type_class == U2 || type_class == I2 ) return; value >>= 8; - AddByte( value ); + AddByte( (byte)value ); value >>= 8; - AddByte( value ); + AddByte( (byte)value ); } void AddWCons( name *op, type_class_def type_class ) @@ -1618,7 +1623,7 @@ void GenEnter( int size, int level ) LayOpbyte( 0xc8 ); OpndSize( HW_xBP ); AddWData( size, U2 ); - AddByte( level ); + AddByte( (byte)level ); _Emit; } @@ -1676,7 +1681,7 @@ void GenUnkEnter( pointer value, int level ) LayOpbyte( 0xc8 ); DoAbsPatch( value, 2 ); ILen += 2; - AddByte( level ); + AddByte( (byte)level ); _Emit; } @@ -2056,11 +2061,11 @@ void GenObjCode( instruction *ins ) break; case G_RNSHIFT: LayRMRegOp( left ); - AddByte( right->c.lo.int_value ); /* never address */ + AddByte( (byte)right->c.lo.int_value ); /* never address */ break; case G_NSHIFT: LayModRM( left ); - AddByte( right->c.lo.int_value ); /* never address */ + AddByte( (byte)right->c.lo.int_value ); /* never address */ break; case G_R2: LayRMRegOp( right ); diff --git a/bld/cg/intel/h/regindex.h b/bld/cg/intel/h/regindex.h new file mode 100644 index 0000000000..e836aed29d --- /dev/null +++ b/bld/cg/intel/h/regindex.h @@ -0,0 +1,93 @@ +/**************************************************************************** +* +* Open Watcom Project +* +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. +* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. +* +* ======================================================================== +* +* This file contains Original Code and/or Modifications of Original +* Code as defined in and that are subject to the Sybase Open Watcom +* Public License version 1.0 (the 'License'). You may not use this file +* except in compliance with the License. BY USING THIS FILE YOU AGREE TO +* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is +* provided with the Original Code and Modifications, and is also +* available at www.sybase.com/developer/opensource. +* +* The Original Code and all software distributed under the License are +* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM +* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR +* NON-INFRINGEMENT. Please see the License for the specific language +* governing rights and limitations under the License. +* +* ======================================================================== +* +* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE +* DESCRIBE IT HERE! +* +****************************************************************************/ + + +#ifdef MAPREGCLASS +#define pick0(id,idx,cls) +#define pick1(id,idx,cls,s1,s2) pick_start(s1) = pick_item(id), pick_start(s2) = pick_item(id), +#define pick2(id,idx,cls,e1,s1) pick_end(e1) = pick_item(id), pick_start(s1) = pick_item(id), +#define pick3(id,idx,cls,e1,e2,s1) pick_end(e1) = pick_item(id), pick_end(e2) = pick_item(id), pick_start(s1) = pick_item(id), +#define pick4(id,e1) pick_end(e1) = pick_item(id), +#else +#define pick0(id,idx,cls) pick(id,idx,cls) +#define pick1(id,idx,cls,s1,s2) pick(id,idx,cls) +#define pick2(id,idx,cls,e1,s1) pick(id,idx,cls) +#define pick3(id,idx,cls,e1,e2,s1) pick(id,idx,cls) +#define pick4(id,e1) +#endif + +/* id idx cls */ +pick1( AL, 0, GPR, GPR, BYTE ) +pick0( CL, 1, GPR ) +pick0( DL, 2, GPR ) +pick0( BL, 3, GPR ) +pick0( AH, 4, GPR ) +pick0( CH, 5, GPR ) +pick0( DH, 6, GPR ) +pick0( BH, 7, GPR ) +pick2( AX, 0, GPR, BYTE, WORD ) +pick0( CX, 1, GPR ) +pick0( DX, 2, GPR ) +pick0( BX, 3, GPR ) +pick0( SP, 4, GPR ) +pick0( BP, 5, GPR ) +pick0( SI, 6, GPR ) +pick0( DI, 7, GPR ) +pick2( EAX, 0, GPR, WORD, DWORD ) +pick0( ECX, 1, GPR ) +pick0( EDX, 2, GPR ) +pick0( EBX, 3, GPR ) +pick0( ESP, 4, GPR ) +pick0( EBP, 5, GPR ) +pick0( ESI, 6, GPR ) +pick0( EDI, 7, GPR ) +pick3( ST0, 0, FPR, DWORD, GPR, FPR ) +pick0( ST1, 1, FPR ) +pick0( ST2, 2, FPR ) +pick0( ST3, 3, FPR ) +pick0( ST4, 4, FPR ) +pick0( ST5, 5, FPR ) +pick0( ST6, 6, FPR ) +pick0( ST7, 7, FPR ) +pick2( ES, 0, SEG, FPR, SEG ) +pick0( CS, 1, SEG ) +pick0( SS, 2, SEG ) +pick0( DS, 3, SEG ) +pick0( FS, 4, SEG ) +pick0( GS, 5, SEG ) +pick4( END, SEG ) + +#undef pick0 +#undef pick1 +#undef pick2 +#undef pick3 +#undef pick4 diff --git a/bld/cg/intel/h/x86regn.h b/bld/cg/intel/h/x86regn.h index f954d6b9cd..d387b5dc3b 100644 --- a/bld/cg/intel/h/x86regn.h +++ b/bld/cg/intel/h/x86regn.h @@ -31,6 +31,15 @@ ****************************************************************************/ +typedef enum { + GPR_IDX = 0x01, /* general purpose registers */ + FPR_IDX = 0x02, /* floating-point registers */ + SEG_IDX = 0x04, /* segment registers */ + GPRB_IDX = 0x08, /* 8-bit registers */ + GPRD_IDX = 0x10, /* 16-bit registers */ + GPRW_IDX = 0x20, /* 32-bit registers */ +} reg_cls; + typedef enum { #define pick(id,ci,start,len) WV_REG_ ## id, #include "watdbreg.h" @@ -47,8 +56,19 @@ typedef enum { typedef uint_8 reg_idx; +typedef struct arch_reg_info { + hw_reg_set hw_reg; + reg_idx idx; + reg_cls cls; + wv_regs wv_idx; + dw_regs dw_idx; +} arch_reg_info; + +extern const arch_reg_info RegsTab[]; + extern hw_reg_set GetFPReg( int idx ); extern int CountFPRegs( hw_reg_set regs ); extern int FPRegNum( name *reg_name ); +extern reg_idx RegTrans( hw_reg_set reg ); extern dw_regs RegTransDW( hw_reg_set reg ); extern int RegTransWV( hw_reg_set reg ); diff --git a/bld/cg/risc/axp/c/axpenc.c b/bld/cg/risc/axp/c/axpenc.c index f4082b1f34..c0caed3156 100644 --- a/bld/cg/risc/axp/c/axpenc.c +++ b/bld/cg/risc/axp/c/axpenc.c @@ -60,7 +60,7 @@ #include "feprotos.h" -#define _NameRegTrans( op ) ( (op)->r.arch_index ) +#define _NameRegTrans( op ) ((reg_idx)(op)->r.arch_index) #define _BinaryOpcode( a, b ) { { a, b }, { a, b } } #define _SignedOpcode( a, b, c, d ) { { a, b }, { c, d } } diff --git a/bld/cg/risc/axp/c/axprgtbl.c b/bld/cg/risc/axp/c/axprgtbl.c index 424c0e1e5b..e8f199d129 100644 --- a/bld/cg/risc/axp/c/axprgtbl.c +++ b/bld/cg/risc/axp/c/axprgtbl.c @@ -39,6 +39,39 @@ #include "rgtbl.h" +#define _Combine( a, b ) ((a) * RL_NUMBER_OF_SETS + (b)) + +/* + * register, register class and range definitions + */ +#define pick_item(id) ARCH_IDX_ ## id +#define pick_start(id) ARCH_ ## id ## _START +#define pick_end(id) ARCH_ ## id ## _END + +enum { + #define pick(id,idx,cls) pick_item(id), + #include "regindex.h" + #undef pick + pick_item( END ), + pick_item( START ) = 0 +}; + +enum { + #define MAPREGCLASS + #include "regindex.h" + #undef MAPREGCLASS +}; + +#undef pick_end +#undef pick_start +#undef pick_item + +const arch_reg_info RegsTab[] = { + #define pick(id,idx,cls) { HW_D_1( HW_ ## id ), idx, cls ## _IDX, DW_REG_ ## id }, + #include "regindex.h" + #undef pick +}; + static hw_reg_set Empty[] = { EMPTY }; @@ -339,6 +372,40 @@ static reg_set_index IsSets[] = { RL_ /* XX*/ }; +#if 0 +static int findArchRegIndex( hw_reg_set regs, reg_cls cls ) +{ + int i; + + if( cls & GPR_IDX ) { + for( i = ARCH_GPR_START; i < ARCH_GPR_END; i++ ) { + if( HW_Equal( regs, RegsTab[i].hw_reg ) ) { + return( i ); + } + } + } + if( cls & FPR_IDX ) { + for( i = ARCH_FPR_START; i < ARCH_FPR_END; i++ ) { + if( HW_Equal( regs, RegsTab[i].hw_reg ) ) { + return( i ); + } + } + } + return( -1 ); +} + +hw_reg_set GetArchReg( int idx, reg_cls cls ) +{ + if( cls & GPR_IDX ) { + return( RegsTab[ARCH_GPR_START + idx].hw_reg ); + } + if( cls & FPR_IDX ) { + return( RegsTab[ARCH_FPR_START + idx].hw_reg ); + } + return( HW_EMPTY ); +} +#endif + /* Information for register set intersections * if sets are of different classes { * intersection is empty @@ -347,8 +414,6 @@ static reg_set_index IsSets[] = { * } */ -#define _Combine( a, b ) ((a) * RL_NUMBER_OF_SETS + (b)) - reg_set_index RegIntersect( reg_set_index s1, reg_set_index s2 ) /****************************************************************/ { @@ -790,54 +855,48 @@ void InitRegTbl( void ) { } -static int regTranslate( hw_reg_set reg, bool index ) -/********************************************************/ +reg_idx RegTrans( hw_reg_set regs ) +/********************************** + * Translate reg to register index + */ { - int i; + int i; - /* - * This should be cached in the reg name and used instead of a stupid lookup - */ - for( i = 0; i < sizeof( QWordRegs ) / sizeof( QWordRegs[0] ); i++ ) { - if( HW_Subset( QWordRegs[i], reg ) ) { - if( index ) - return( i ); - return( i + DW_REG_R0 ); + for( i = ARCH_IDX_START; i < ARCH_IDX_END; i++ ) { + if( HW_Equal( regs, RegsTab[i].hw_reg ) ) { + return( RegsTab[i].idx ); } } - for( i = 0; i < sizeof( FloatRegs ) / sizeof( FloatRegs[0] ); i++ ) { - if( HW_Equal( reg, FloatRegs[i] ) ) { - if( index ) - return( i ); - return( i + DW_REG_F0 ); - } - } - if( index ) - return( 0 ); - _Zoiks( ZOIKS_031 ); - return( DW_REG_END ); -} - -reg_idx RegTrans( hw_reg_set reg ) -/********************************* - * Translate reg to register index - */ -{ - return( (reg_idx)regTranslate( reg, true ) ); + return( 0 ); } int GetArchIndex( hw_reg_set regs ) /***********************************************/ { - return( RegTrans( regs ) ); + int i; + + for( i = ARCH_IDX_START; i < ARCH_IDX_END; i++ ) { + if( HW_Equal( regs, RegsTab[i].hw_reg ) ) { + return( RegsTab[i].idx ); + } + } + return( 0 ); } -dw_regs RegTransDW( hw_reg_set reg ) -/************************************* +dw_regs RegTransDW( hw_reg_set regs ) +/************************************** * Translate reg to register index */ { - return( (dw_regs)regTranslate( reg, false ) ); + int i; + + for( i = ARCH_IDX_START; i < ARCH_IDX_END; i++ ) { + if( HW_Equal( regs, RegsTab[i].hw_reg ) ) { + return( RegsTab[i].dw_idx ); + } + } + _Zoiks( ZOIKS_031 ); + return( DW_REG_END ); } hw_reg_set FirstReg( reg_set_index regs_idx ) diff --git a/bld/cg/risc/axp/h/axpregn.h b/bld/cg/risc/axp/h/axpregn.h index eeb8520aaf..35988a2d9a 100644 --- a/bld/cg/risc/axp/h/axpregn.h +++ b/bld/cg/risc/axp/h/axpregn.h @@ -31,6 +31,11 @@ ****************************************************************************/ +typedef enum { + GPR_IDX = 0x01, /* general purpose registers */ + FPR_IDX = 0x02, /* floating-point registers */ +} reg_cls; + typedef enum { #define pick(id,name) DW_REG_ ## id, #include "dwregaxp.h" @@ -40,5 +45,14 @@ typedef enum { typedef uint_8 reg_idx; +typedef struct arch_reg_info { + hw_reg_set hw_reg; + reg_idx idx; + reg_cls cls; + dw_regs dw_idx; +} arch_reg_info; + +extern const arch_reg_info RegsTab[]; + extern reg_idx RegTrans( hw_reg_set reg ); extern dw_regs RegTransDW( hw_reg_set reg ); diff --git a/bld/cg/risc/axp/h/regindex.h b/bld/cg/risc/axp/h/regindex.h new file mode 100644 index 0000000000..8b2d63b42d --- /dev/null +++ b/bld/cg/risc/axp/h/regindex.h @@ -0,0 +1,116 @@ +/**************************************************************************** +* +* Open Watcom Project +* +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. +* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. +* +* ======================================================================== +* +* This file contains Original Code and/or Modifications of Original +* Code as defined in and that are subject to the Sybase Open Watcom +* Public License version 1.0 (the 'License'). You may not use this file +* except in compliance with the License. BY USING THIS FILE YOU AGREE TO +* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is +* provided with the Original Code and Modifications, and is also +* available at www.sybase.com/developer/opensource. +* +* The Original Code and all software distributed under the License are +* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM +* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR +* NON-INFRINGEMENT. Please see the License for the specific language +* governing rights and limitations under the License. +* +* ======================================================================== +* +* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE +* DESCRIBE IT HERE! +* +****************************************************************************/ + + +#ifdef MAPREGCLASS +#define pick0(id,idx,cls) +#define pick1(id,idx,cls,s1) pick_start(s1) = pick_item(id), +#define pick2(id,idx,cls,e1,s1) pick_end(e1) = pick_item(id), pick_start(s1) = pick_item(id), +#define pick3(id,e1) pick_end(e1) = pick_item(id), +#else +#define pick0(id,idx,cls) pick(id,idx,cls) +#define pick1(id,idx,cls,s1) pick(id,idx,cls) +#define pick2(id,idx,cls,e1,s1) pick(id,idx,cls) +#define pick3(id,e1) +#endif + +/* id idx cls */ +pick1( R0, 0, GPR, GPR ) +pick0( R1, 1, GPR ) +pick0( R2, 2, GPR ) +pick0( R3, 3, GPR ) +pick0( R4, 4, GPR ) +pick0( R5, 5, GPR ) +pick0( R6, 6, GPR ) +pick0( R7, 7, GPR ) +pick0( R8, 8, GPR ) +pick0( R9, 9, GPR ) +pick0( R10, 10, GPR ) +pick0( R11, 11, GPR ) +pick0( R12, 12, GPR ) +pick0( R13, 13, GPR ) +pick0( R14, 14, GPR ) +pick0( R15, 15, GPR ) +pick0( R16, 16, GPR ) +pick0( R17, 17, GPR ) +pick0( R18, 18, GPR ) +pick0( R19, 19, GPR ) +pick0( R20, 20, GPR ) +pick0( R21, 21, GPR ) +pick0( R22, 22, GPR ) +pick0( R23, 23, GPR ) +pick0( R24, 24, GPR ) +pick0( R25, 25, GPR ) +pick0( R26, 26, GPR ) +pick0( R27, 27, GPR ) +pick0( R28, 28, GPR ) +pick0( R29, 29, GPR ) +pick0( R30, 30, GPR ) +pick0( R31, 31, GPR ) +pick2( F0, 0, FPR, GPR, FPR ) +pick0( F1, 1, FPR ) +pick0( F2, 2, FPR ) +pick0( F3, 3, FPR ) +pick0( F4, 4, FPR ) +pick0( F5, 5, FPR ) +pick0( F6, 6, FPR ) +pick0( F7, 7, FPR ) +pick0( F8, 8, FPR ) +pick0( F9, 9, FPR ) +pick0( F10, 10, FPR ) +pick0( F11, 11, FPR ) +pick0( F12, 12, FPR ) +pick0( F13, 13, FPR ) +pick0( F14, 14, FPR ) +pick0( F15, 15, FPR ) +pick0( F16, 16, FPR ) +pick0( F17, 17, FPR ) +pick0( F18, 18, FPR ) +pick0( F19, 19, FPR ) +pick0( F20, 20, FPR ) +pick0( F21, 21, FPR ) +pick0( F22, 22, FPR ) +pick0( F23, 23, FPR ) +pick0( F24, 24, FPR ) +pick0( F25, 25, FPR ) +pick0( F26, 26, FPR ) +pick0( F27, 27, FPR ) +pick0( F28, 28, FPR ) +pick0( F29, 29, FPR ) +pick0( F30, 30, FPR ) +pick0( F31, 31, FPR ) +pick3( END, FPR ) + +#undef pick0 +#undef pick1 +#undef pick2 +#undef pick3 diff --git a/bld/cg/risc/mps/c/mpsenc.c b/bld/cg/risc/mps/c/mpsenc.c index d7a7ab0b98..c0d4000a95 100644 --- a/bld/cg/risc/mps/c/mpsenc.c +++ b/bld/cg/risc/mps/c/mpsenc.c @@ -58,12 +58,12 @@ #include "feprotos.h" -#define _NameRegTrans( op ) ( (op)->r.arch_index ) +#define _NameRegTrans( op ) ((reg_idx)(op)->r.arch_index) -#define _BinaryOpcode( a, b ) { { a, b }, { a, b } } -#define _SignedOpcode( a, b, c, d ) { { a, b }, { c, d } } -#define _BinaryImmOpcode( a ) { a, a } -#define _SignedImmOpcode( a, b ) { a, b } +#define _BinaryOpcode( a, b ) { { a, b }, { a, b } } +#define _SignedOpcode( a, b, c, d ) { { a, b }, { c, d } } +#define _BinaryImmOpcode( a ) { a, a } +#define _SignedImmOpcode( a, b ) { a, b } /* * This is NT stuff - probably irreleveant unless someone wanted to @@ -734,7 +734,7 @@ static void doZero( instruction *ins, type_class_def type_class ) /* * 'andi res,op1,0xffff' */ - GenIType( 0x0c, _NameRegTrans( ins->result ), _NameRegTrans( ins->operands[0] ), (int_16)0x0ffff ); + GenIType( 0x0c, _NameRegTrans( ins->result ), _NameRegTrans( ins->operands[0] ), -1 ); break; default: _Zoiks( ZOIKS_091 ); @@ -746,18 +746,18 @@ static void doSignExtend( instruction *ins, type_class_def type_class ) /**********************************************************************/ { unsigned from_size; - int res_index; - int src_index; + reg_idx reg_res; + reg_idx reg_src; int shift_amt; - res_index = _NameRegTrans( ins->result ); - src_index = _NameRegTrans( ins->operands[0] ); + reg_res = _NameRegTrans( ins->result ); + reg_src = _NameRegTrans( ins->operands[0] ); from_size = TypeClassSize[type_class]; if( from_size == 4 ) { /* * 'addu rd,$zero,rs' - MIPS64 only? */ - GenRType( 0x00, 0x21, res_index, ZERO_REG_IDX, src_index ); + GenRType( 0x00, 0x21, reg_res, ZERO_REG_IDX, reg_src ); } else { /* * MIPS32 ISA Release 2 has 'seb'/'seh' instructions for this @@ -766,11 +766,11 @@ static void doSignExtend( instruction *ins, type_class_def type_class ) /* * 'sll rd,rs,n' */ - GenIShift( 0x00, res_index, src_index, shift_amt ); + GenIShift( 0x00, reg_res, reg_src, shift_amt ); /* * 'sra rd,rs,n' */ - GenIShift( 0x03, res_index, res_index, shift_amt ); + GenIShift( 0x03, reg_res, reg_res, shift_amt ); } } diff --git a/bld/cg/risc/mps/c/mpsrgtbl.c b/bld/cg/risc/mps/c/mpsrgtbl.c index 53a6270694..d88361a96d 100644 --- a/bld/cg/risc/mps/c/mpsrgtbl.c +++ b/bld/cg/risc/mps/c/mpsrgtbl.c @@ -38,6 +38,39 @@ #include "rgtbl.h" +#define _Combine( a, b ) ((a) * RL_NUMBER_OF_SETS + (b)) + +/* + * register, register class and range definitions + */ +#define pick_item(id) ARCH_IDX_ ## id +#define pick_start(id) ARCH_ ## id ## _START +#define pick_end(id) ARCH_ ## id ## _END + +enum { + #define pick(id,idx,cls) pick_item(id), + #include "regindex.h" + #undef pick + pick_item( END ), + pick_item( START ) = 0 +}; + +enum { + #define MAPREGCLASS + #include "regindex.h" + #undef MAPREGCLASS +}; + +#undef pick_end +#undef pick_start +#undef pick_item + +const arch_reg_info RegsTab[] = { + #define pick(id,idx,cls) { HW_D_1( HW_ ## id ), idx, cls ## _IDX, DW_REG_ ## id }, + #include "regindex.h" + #undef pick +}; + static hw_reg_set Empty[] = { EMPTY }; @@ -365,6 +398,40 @@ static reg_set_index IsSets[] = { }; +#if 0 +static int findArchRegIndex( hw_reg_set regs, reg_cls cls ) +{ + int i; + + if( cls & GPR_IDX ) { + for( i = ARCH_GPR_START; i < ARCH_GPR_END; i++ ) { + if( HW_Equal( regs, RegsTab[i].hw_reg ) ) { + return( i ); + } + } + } + if( cls & FPR_IDX ) { + for( i = ARCH_FPR_START; i < ARCH_FPR_END; i++ ) { + if( HW_Equal( regs, RegsTab[i].hw_reg ) ) { + return( i ); + } + } + } + return( -1 ); +} + +hw_reg_set GetArchReg( int idx, reg_cls cls ) +{ + if( cls & GPR_IDX ) { + return( RegsTab[ARCH_GPR_START + idx].hw_reg ); + } + if( cls & FPR_IDX ) { + return( RegsTab[ARCH_FPR_START + idx].hw_reg ); + } + return( HW_EMPTY ); +} +#endif + /* Information for register set intersections * if sets are of different classes { * intersection is empty @@ -373,9 +440,6 @@ static reg_set_index IsSets[] = { * } */ -#define _Combine( a, b ) ((a) * RL_NUMBER_OF_SETS + (b)) - - reg_set_index RegIntersect( reg_set_index s1, reg_set_index s2 ) /**************************************************************/ { @@ -852,62 +916,49 @@ void InitRegTbl( void ) } -static int regTranslate( hw_reg_set reg, bool index ) -/********************************************************/ +reg_idx RegTrans( hw_reg_set regs ) +/********************************** + * Translate reg to register index + */ { - int i; + int i; - /* - * This should be cached in the reg name and used instead of a stupid lookup - */ - for( i = 0; i < sizeof( GeneralRegs ) / sizeof( GeneralRegs[0] ); i++ ) { - if( HW_Subset( GeneralRegs[i], reg ) ) { - if( index ) - return( i ); - return( i + DW_REG_R0 ); - } - } - for( i = 0; i < sizeof( QWordRegs ) / sizeof( QWordRegs[0] ); i++ ) { - if( HW_Subset( QWordRegs[i], reg ) ) { - if( index ) - return( i * 2 + 2 ); - return( i * 2 + 2 + DW_REG_R0 ); + for( i = ARCH_IDX_START; i < ARCH_IDX_END; i++ ) { + if( HW_Equal( regs, RegsTab[i].hw_reg ) ) { + return( RegsTab[i].idx ); } } - for( i = 0; i < sizeof( FloatRegs ) / sizeof( FloatRegs[0] ); i++ ) { - if( HW_Equal( reg, FloatRegs[i] ) ) { - if( index ) - return( i ); - return( i + DW_REG_F0 ); - } - } - if( index ) - return( 0 ); - _Zoiks( ZOIKS_031 ); - return( DW_REG_END ); -} - -reg_idx RegTrans( hw_reg_set reg ) -/********************************* - * Translate reg to register index - */ -{ - return( (reg_idx)regTranslate( reg, true ) ); + return( 0 ); } int GetArchIndex( hw_reg_set regs ) /***********************************************/ { - return( RegTrans( regs ) ); + int i; + + for( i = ARCH_IDX_START; i < ARCH_IDX_END; i++ ) { + if( HW_Equal( regs, RegsTab[i].hw_reg ) ) { + return( RegsTab[i].idx ); + } + } + return( 0 ); } -dw_regs RegTransDW( hw_reg_set reg ) -/************************************* +dw_regs RegTransDW( hw_reg_set regs ) +/************************************** * Translate reg to register index */ { - return( (dw_regs)regTranslate( reg, false ) ); + int i; + + for( i = ARCH_IDX_START; i < ARCH_IDX_END; i++ ) { + if( HW_Equal( regs, RegsTab[i].hw_reg ) ) { + return( RegsTab[i].dw_idx ); + } + } + _Zoiks( ZOIKS_031 ); + return( DW_REG_END ); } hw_reg_set FirstReg( reg_set_index regs_idx ) diff --git a/bld/cg/risc/mps/h/mpsregn.h b/bld/cg/risc/mps/h/mpsregn.h index 443bdc70ca..ce1d5db949 100644 --- a/bld/cg/risc/mps/h/mpsregn.h +++ b/bld/cg/risc/mps/h/mpsregn.h @@ -31,13 +31,41 @@ typedef enum { - #define pick(id,name) DW_REG_ ## id, + GPR_IDX = 0x01, /* general purpose registers */ + FPR_IDX = 0x02, /* floating-point registers */ + QW_IDX = 0x04, /* 64-bit general purpose registers (MIPS 32-bit) */ +} reg_cls; + +typedef enum { + #define pick(id,name) DW_REG_ ## id, #include "dwregmps.h" - DW_REG_END #undef pick + DW_REG_END } dw_regs; +/* + * Dwarf debug information + * + * remaping code generator QWord pseudo registers + * to first of 32-bit pair-register + */ +#define DW_REG_Q2 DW_REG_R2 +#define DW_REG_Q4 DW_REG_R4 +#define DW_REG_Q6 DW_REG_R6 +#define DW_REG_Q8 DW_REG_R8 +#define DW_REG_Q10 DW_REG_R10 + typedef uint_8 reg_idx; +typedef struct arch_reg_info { + hw_reg_set hw_reg; + reg_idx idx; + reg_cls cls; + dw_regs dw_idx; +} arch_reg_info; + +extern const arch_reg_info RegsTab[]; + +extern hw_reg_set GetFPReg( int idx ); extern reg_idx RegTrans( hw_reg_set reg ); extern dw_regs RegTransDW( hw_reg_set reg ); diff --git a/bld/cg/risc/mps/h/regindex.h b/bld/cg/risc/mps/h/regindex.h new file mode 100644 index 0000000000..8b2d63b42d --- /dev/null +++ b/bld/cg/risc/mps/h/regindex.h @@ -0,0 +1,116 @@ +/**************************************************************************** +* +* Open Watcom Project +* +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. +* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. +* +* ======================================================================== +* +* This file contains Original Code and/or Modifications of Original +* Code as defined in and that are subject to the Sybase Open Watcom +* Public License version 1.0 (the 'License'). You may not use this file +* except in compliance with the License. BY USING THIS FILE YOU AGREE TO +* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is +* provided with the Original Code and Modifications, and is also +* available at www.sybase.com/developer/opensource. +* +* The Original Code and all software distributed under the License are +* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM +* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR +* NON-INFRINGEMENT. Please see the License for the specific language +* governing rights and limitations under the License. +* +* ======================================================================== +* +* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE +* DESCRIBE IT HERE! +* +****************************************************************************/ + + +#ifdef MAPREGCLASS +#define pick0(id,idx,cls) +#define pick1(id,idx,cls,s1) pick_start(s1) = pick_item(id), +#define pick2(id,idx,cls,e1,s1) pick_end(e1) = pick_item(id), pick_start(s1) = pick_item(id), +#define pick3(id,e1) pick_end(e1) = pick_item(id), +#else +#define pick0(id,idx,cls) pick(id,idx,cls) +#define pick1(id,idx,cls,s1) pick(id,idx,cls) +#define pick2(id,idx,cls,e1,s1) pick(id,idx,cls) +#define pick3(id,e1) +#endif + +/* id idx cls */ +pick1( R0, 0, GPR, GPR ) +pick0( R1, 1, GPR ) +pick0( R2, 2, GPR ) +pick0( R3, 3, GPR ) +pick0( R4, 4, GPR ) +pick0( R5, 5, GPR ) +pick0( R6, 6, GPR ) +pick0( R7, 7, GPR ) +pick0( R8, 8, GPR ) +pick0( R9, 9, GPR ) +pick0( R10, 10, GPR ) +pick0( R11, 11, GPR ) +pick0( R12, 12, GPR ) +pick0( R13, 13, GPR ) +pick0( R14, 14, GPR ) +pick0( R15, 15, GPR ) +pick0( R16, 16, GPR ) +pick0( R17, 17, GPR ) +pick0( R18, 18, GPR ) +pick0( R19, 19, GPR ) +pick0( R20, 20, GPR ) +pick0( R21, 21, GPR ) +pick0( R22, 22, GPR ) +pick0( R23, 23, GPR ) +pick0( R24, 24, GPR ) +pick0( R25, 25, GPR ) +pick0( R26, 26, GPR ) +pick0( R27, 27, GPR ) +pick0( R28, 28, GPR ) +pick0( R29, 29, GPR ) +pick0( R30, 30, GPR ) +pick0( R31, 31, GPR ) +pick2( F0, 0, FPR, GPR, FPR ) +pick0( F1, 1, FPR ) +pick0( F2, 2, FPR ) +pick0( F3, 3, FPR ) +pick0( F4, 4, FPR ) +pick0( F5, 5, FPR ) +pick0( F6, 6, FPR ) +pick0( F7, 7, FPR ) +pick0( F8, 8, FPR ) +pick0( F9, 9, FPR ) +pick0( F10, 10, FPR ) +pick0( F11, 11, FPR ) +pick0( F12, 12, FPR ) +pick0( F13, 13, FPR ) +pick0( F14, 14, FPR ) +pick0( F15, 15, FPR ) +pick0( F16, 16, FPR ) +pick0( F17, 17, FPR ) +pick0( F18, 18, FPR ) +pick0( F19, 19, FPR ) +pick0( F20, 20, FPR ) +pick0( F21, 21, FPR ) +pick0( F22, 22, FPR ) +pick0( F23, 23, FPR ) +pick0( F24, 24, FPR ) +pick0( F25, 25, FPR ) +pick0( F26, 26, FPR ) +pick0( F27, 27, FPR ) +pick0( F28, 28, FPR ) +pick0( F29, 29, FPR ) +pick0( F30, 30, FPR ) +pick0( F31, 31, FPR ) +pick3( END, FPR ) + +#undef pick0 +#undef pick1 +#undef pick2 +#undef pick3 diff --git a/bld/cg/risc/ppc/c/ppcenc.c b/bld/cg/risc/ppc/c/ppcenc.c index 0dc9266982..840543cc66 100644 --- a/bld/cg/risc/ppc/c/ppcenc.c +++ b/bld/cg/risc/ppc/c/ppcenc.c @@ -59,7 +59,7 @@ #include "feprotos.h" -#define _NameRegTrans( op ) ( (op)->r.arch_index ) +#define _NameRegTrans( op ) ((reg_idx)(op)->r.arch_index) #define _EmitIns( ins ) ObjBytes( &(ins), sizeof( ppc_ins ) ) #define _ObjEmitSeq( code ) ObjBytes( code->data, code->length ) @@ -508,7 +508,7 @@ static void doZero( instruction *ins ) /* * andi op1,0xffff -> res */ - GenOPIMM( 28, _NameRegTrans( ins->operands[0] ), _NameRegTrans( ins->result ), (signed_16)0xffff ); + GenOPIMM( 28, _NameRegTrans( ins->operands[0] ), _NameRegTrans( ins->result ), -1 ); break; default: _Zoiks( ZOIKS_091 ); @@ -736,7 +736,7 @@ static void Encode( instruction *ins ) case OP_RSHIFT: if( _IsSigned( ins->type_class ) ) { GenOPINS( 31, 824, _NameRegTrans( ins->result ), - ins->operands[1]->c.lo.int_value, _NameRegTrans( ins->operands[0] ) ); + (reg_idx)ins->operands[1]->c.lo.int_value, _NameRegTrans( ins->operands[0] ) ); } else { // rlwinm dst,src,32-n,n,31 b = _FiveBits( ins->operands[1]->c.lo.int_value ); diff --git a/bld/cg/risc/ppc/c/ppcproc.c b/bld/cg/risc/ppc/c/ppcproc.c index 5faa8bab89..baef3dda62 100644 --- a/bld/cg/risc/ppc/c/ppcproc.c +++ b/bld/cg/risc/ppc/c/ppcproc.c @@ -54,7 +54,6 @@ #define LOAD_DOUBLE 50 #define ADDI_OPCODE 14 - static void CalcUsedRegs( void ) /**********************************/ { @@ -139,7 +138,7 @@ static void emitLocalEpilog( stack_record *locals ) /* unused parameters */ (void)locals; } -static uint_32 registerMask( hw_reg_set rs, hw_reg_set *rl ) +static uint_32 registerMask( hw_reg_set rs, hw_reg_set *rl ) /***********************************************************/ { hw_reg_set *curr; @@ -180,20 +179,20 @@ static void initSavedRegs( stack_record *saved_regs, type_length *offset ) *offset += saved_regs->size; } -static void genMove( uint_32 src, uint_32 dst ) +static void genMove( reg_idx src, reg_idx dst ) /*************************************************/ { GenOPINS( 31, 444, dst, src, src ); } -static void genAdd( uint_32 src, signed_16 disp, uint_32 dst ) +static void genAdd( reg_idx src, signed_16 disp, reg_idx dst ) /****************************************************************/ { GenOPIMM( ADDI_OPCODE, dst, src, disp ); } -static void saveReg( uint_32 index, type_length offset, bool fp ) -/*******************************************************************/ +static void saveReg( int index, type_length offset, bool fp ) +/***************************************************************/ { uint_8 opcode; @@ -201,14 +200,14 @@ static void saveReg( uint_32 index, type_length offset, bool fp ) if( fp ) { opcode = STORE_DOUBLE; } - GenMEMINS( opcode, index, SP_REG_IDX, offset ); + GenMEMINS( opcode, (reg_idx)index, SP_REG_IDX, offset ); } -static void loadReg( uint_32 index, type_length offset, bool fp ) -/*******************************************************************/ +static void loadReg( int index, type_length offset, bool fp ) +/***************************************************************/ { uint_8 opcode; - uint_8 frame_reg; + reg_idx frame_reg; opcode = LOAD_DWORD; if( fp ) { @@ -218,7 +217,7 @@ static void loadReg( uint_32 index, type_length offset, bool fp ) if( CurrProc->targ.base_is_fp ) { frame_reg = FP_REG_IDX; } - GenMEMINS( opcode, index, frame_reg, offset + CurrProc->locals.size ); + GenMEMINS( opcode, (reg_idx)index, frame_reg, offset + CurrProc->locals.size ); } static int regSize( bool fp ) @@ -230,7 +229,7 @@ static int regSize( bool fp ) static void saveRegSet( uint_32 reg_set, type_length offset, bool fp ) /************************************************************************/ { - uint_32 index; + int index; uint_32 high_bit; index = sizeof( reg_set ) * 8 - 1; @@ -248,7 +247,7 @@ static void saveRegSet( uint_32 reg_set, type_length offset, bool fp ) static void loadRegSet( uint_32 reg_set, type_length offset, bool fp ) /************************************************************************/ { - uint_32 index; + int index; index = 0; while( reg_set != 0 ) { @@ -428,7 +427,7 @@ static void emitEpilog( stack_map *map ) /******************************************/ { type_length frame_size; - uint_8 frame_reg; + reg_idx frame_reg; frame_size = frameSize( map ); if( frame_size != 0 ) { diff --git a/bld/cg/risc/ppc/c/ppcrgtbl.c b/bld/cg/risc/ppc/c/ppcrgtbl.c index 8ca5aa6daf..f336cdb82d 100644 --- a/bld/cg/risc/ppc/c/ppcrgtbl.c +++ b/bld/cg/risc/ppc/c/ppcrgtbl.c @@ -38,6 +38,39 @@ #include "rgtbl.h" +#define _Combine( a, b ) ((a) * RL_NUMBER_OF_SETS + (b)) + +/* + * register, register class and range definitions + */ +#define pick_item(id) ARCH_IDX_ ## id +#define pick_start(id) ARCH_ ## id ## _START +#define pick_end(id) ARCH_ ## id ## _END + +enum { + #define pick(id,idx,cls) pick_item(id), + #include "regindex.h" + #undef pick + pick_item( END ), + pick_item( START ) = 0 +}; + +enum { + #define MAPREGCLASS + #include "regindex.h" + #undef MAPREGCLASS +}; + +#undef pick_end +#undef pick_start +#undef pick_item + +const arch_reg_info RegsTab[] = { + #define pick(id,idx,cls) { HW_D_1( HW_ ## id ), idx, cls ## _IDX, DW_REG_ ## id }, + #include "regindex.h" + #undef pick +}; + static hw_reg_set Empty[] = { EMPTY }; @@ -351,6 +384,40 @@ static reg_set_index IsSets[] = { RL_ /* XX*/ }; +#if 0 +static int findArchRegIndex( hw_reg_set regs, reg_cls cls ) +{ + int i; + + if( cls & GPR_IDX ) { + for( i = ARCH_GPR_START; i < ARCH_GPR_END; i++ ) { + if( HW_Equal( regs, RegsTab[i].hw_reg ) ) { + return( i ); + } + } + } + if( cls & FPR_IDX ) { + for( i = ARCH_FPR_START; i < ARCH_FPR_END; i++ ) { + if( HW_Equal( regs, RegsTab[i].hw_reg ) ) { + return( i ); + } + } + } + return( -1 ); +} + +hw_reg_set GetArchReg( int idx, reg_cls cls ) +{ + if( cls & GPR_IDX ) { + return( RegsTab[ARCH_GPR_START + idx].hw_reg ); + } + if( cls & FPR_IDX ) { + return( RegsTab[ARCH_FPR_START + idx].hw_reg ); + } + return( HW_EMPTY ); +} +#endif + /* Information for register set intersections * if sets are of different classes { * intersection is empty @@ -359,8 +426,6 @@ static reg_set_index IsSets[] = { * } */ -#define _Combine( a, b ) ((a) * RL_NUMBER_OF_SETS + (b)) - reg_set_index RegIntersect( reg_set_index s1, reg_set_index s2 ) /****************************************************************/ { @@ -670,14 +735,15 @@ reg_set_index UsualPossible( type_class_def type_class ) hw_reg_set ActualParmReg( hw_reg_set reg ) -/***********************************************/ +/*********************************************/ { return( reg ); } hw_reg_set FixedRegs( void ) -/*******************************/ -/* MJC do you really want to fix them */ +/******************************** + * MJC do you really want to fix them + */ { hw_reg_set fixed; @@ -696,15 +762,17 @@ hw_reg_set VarargsHomePtr( void ) } hw_reg_set StackReg( void ) -/******************************/ -/* MJC should be up to linkage conventions */ +/******************************* + * MJC should be up to linkage conventions + */ { return( HW_D1 ); } hw_reg_set FrameReg( void ) -/******************************/ -/* MJC should be up to linkage conventions */ +/******************************* + * MJC should be up to linkage conventions + */ { if( CurrProc->targ.base_is_fp ) { return( HW_D31 ); @@ -770,62 +838,59 @@ hw_reg_set *FPRegs( void ) return( FloatRegs ); } -hw_reg_set *IdxRegs( void ) -/******************************/ +hw_reg_set *IdxRegs( void ) +/**************************/ { return( DWordRegs ); } -void InitRegTbl( void ) -/********************************/ +void InitRegTbl( void ) +/****************************/ { } -static int regTranslate( hw_reg_set reg, bool index ) -/********************************************************/ +reg_idx RegTrans( hw_reg_set regs ) +/************************************** + * Translate reg to register index + */ { - int i; + int i; - for( i = 0; i < sizeof( DWordRegs ) / sizeof( DWordRegs[0] ); i++ ) { - if( HW_Subset( DWordRegs[i], reg ) ) { - if( index ) - return( i ); - return( i + DW_REG_R0 ); - } - } - for( i = 0; i < sizeof( FloatRegs ) / sizeof( FloatRegs[0] ); i++ ) { - if( HW_Equal( reg, FloatRegs[i] ) ) { - if( index ) - return( i ); - return( i + DW_REG_F0 ); + for( i = ARCH_IDX_START; i < ARCH_IDX_END; i++ ) { + if( HW_Equal( regs, RegsTab[i].hw_reg ) ) { + return( RegsTab[i].idx ); } } - if( index ) - return( 0 ); - _Zoiks( ZOIKS_031 ); - return( DW_REG_END ); -} - -reg_idx RegTrans( hw_reg_set reg ) -/************************************* - * Translate reg to register index - */ -{ - return( (reg_idx)regTranslate( reg, true ) ); + return( 0 ); } int GetArchIndex( hw_reg_set regs ) -/***********************************************/ +/*********************************/ { - return( RegTrans( regs ) ); + int i; + + for( i = ARCH_IDX_START; i < ARCH_IDX_END; i++ ) { + if( HW_Equal( regs, RegsTab[i].hw_reg ) ) { + return( RegsTab[i].idx ); + } + } + return( 0 ); } -dw_regs RegTransDW( hw_reg_set reg ) -/************************************* +dw_regs RegTransDW( hw_reg_set regs ) +/************************************** * Translate reg to enum name */ { - return( (dw_regs)regTranslate( reg, false ) ); + int i; + + for( i = ARCH_IDX_START; i < ARCH_IDX_END; i++ ) { + if( HW_Equal( regs, RegsTab[i].hw_reg ) ) { + return( RegsTab[i].dw_idx ); + } + } + _Zoiks( ZOIKS_031 ); + return( DW_REG_END ); } hw_reg_set ParmRegConflicts( hw_reg_set r ) diff --git a/bld/cg/risc/ppc/h/ppcprocd.h b/bld/cg/risc/ppc/h/ppcprocd.h index 8c730d0558..81e4fab630 100644 --- a/bld/cg/risc/ppc/h/ppcprocd.h +++ b/bld/cg/risc/ppc/h/ppcprocd.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -42,9 +42,9 @@ typedef enum { ROUTINE_HAS_VARARGS = 0x0080, } call_attributes; -typedef byte reg_num; +typedef byte reg_num; -#define NO_REGISTER ((reg_num)-1) +#define NO_REGISTER ((reg_num)-1) typedef struct { char wasted_space; diff --git a/bld/cg/risc/ppc/h/ppcregn.h b/bld/cg/risc/ppc/h/ppcregn.h index 50e0636d6c..89c502bc67 100644 --- a/bld/cg/risc/ppc/h/ppcregn.h +++ b/bld/cg/risc/ppc/h/ppcregn.h @@ -32,13 +32,27 @@ typedef enum { - #define pick(id,name) DW_REG_ ## id, + GPR_IDX = 0x01, /* general purpose registers */ + FPR_IDX = 0x02, /* floating-point registers */ +} reg_cls; + +typedef enum { + #define pick(id,name) DW_REG_ ## id, #include "dwregppc.h" - DW_REG_END #undef pick + DW_REG_END } dw_regs; typedef uint_8 reg_idx; +typedef struct arch_reg_info { + hw_reg_set hw_reg; + reg_idx idx; + reg_cls cls; + dw_regs dw_idx; +} arch_reg_info; + +extern const arch_reg_info RegsTab[]; + extern reg_idx RegTrans( hw_reg_set reg ); extern dw_regs RegTransDW( hw_reg_set reg ); diff --git a/bld/cg/risc/ppc/h/regindex.h b/bld/cg/risc/ppc/h/regindex.h new file mode 100644 index 0000000000..8b2d63b42d --- /dev/null +++ b/bld/cg/risc/ppc/h/regindex.h @@ -0,0 +1,116 @@ +/**************************************************************************** +* +* Open Watcom Project +* +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. +* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. +* +* ======================================================================== +* +* This file contains Original Code and/or Modifications of Original +* Code as defined in and that are subject to the Sybase Open Watcom +* Public License version 1.0 (the 'License'). You may not use this file +* except in compliance with the License. BY USING THIS FILE YOU AGREE TO +* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is +* provided with the Original Code and Modifications, and is also +* available at www.sybase.com/developer/opensource. +* +* The Original Code and all software distributed under the License are +* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM +* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR +* NON-INFRINGEMENT. Please see the License for the specific language +* governing rights and limitations under the License. +* +* ======================================================================== +* +* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE +* DESCRIBE IT HERE! +* +****************************************************************************/ + + +#ifdef MAPREGCLASS +#define pick0(id,idx,cls) +#define pick1(id,idx,cls,s1) pick_start(s1) = pick_item(id), +#define pick2(id,idx,cls,e1,s1) pick_end(e1) = pick_item(id), pick_start(s1) = pick_item(id), +#define pick3(id,e1) pick_end(e1) = pick_item(id), +#else +#define pick0(id,idx,cls) pick(id,idx,cls) +#define pick1(id,idx,cls,s1) pick(id,idx,cls) +#define pick2(id,idx,cls,e1,s1) pick(id,idx,cls) +#define pick3(id,e1) +#endif + +/* id idx cls */ +pick1( R0, 0, GPR, GPR ) +pick0( R1, 1, GPR ) +pick0( R2, 2, GPR ) +pick0( R3, 3, GPR ) +pick0( R4, 4, GPR ) +pick0( R5, 5, GPR ) +pick0( R6, 6, GPR ) +pick0( R7, 7, GPR ) +pick0( R8, 8, GPR ) +pick0( R9, 9, GPR ) +pick0( R10, 10, GPR ) +pick0( R11, 11, GPR ) +pick0( R12, 12, GPR ) +pick0( R13, 13, GPR ) +pick0( R14, 14, GPR ) +pick0( R15, 15, GPR ) +pick0( R16, 16, GPR ) +pick0( R17, 17, GPR ) +pick0( R18, 18, GPR ) +pick0( R19, 19, GPR ) +pick0( R20, 20, GPR ) +pick0( R21, 21, GPR ) +pick0( R22, 22, GPR ) +pick0( R23, 23, GPR ) +pick0( R24, 24, GPR ) +pick0( R25, 25, GPR ) +pick0( R26, 26, GPR ) +pick0( R27, 27, GPR ) +pick0( R28, 28, GPR ) +pick0( R29, 29, GPR ) +pick0( R30, 30, GPR ) +pick0( R31, 31, GPR ) +pick2( F0, 0, FPR, GPR, FPR ) +pick0( F1, 1, FPR ) +pick0( F2, 2, FPR ) +pick0( F3, 3, FPR ) +pick0( F4, 4, FPR ) +pick0( F5, 5, FPR ) +pick0( F6, 6, FPR ) +pick0( F7, 7, FPR ) +pick0( F8, 8, FPR ) +pick0( F9, 9, FPR ) +pick0( F10, 10, FPR ) +pick0( F11, 11, FPR ) +pick0( F12, 12, FPR ) +pick0( F13, 13, FPR ) +pick0( F14, 14, FPR ) +pick0( F15, 15, FPR ) +pick0( F16, 16, FPR ) +pick0( F17, 17, FPR ) +pick0( F18, 18, FPR ) +pick0( F19, 19, FPR ) +pick0( F20, 20, FPR ) +pick0( F21, 21, FPR ) +pick0( F22, 22, FPR ) +pick0( F23, 23, FPR ) +pick0( F24, 24, FPR ) +pick0( F25, 25, FPR ) +pick0( F26, 26, FPR ) +pick0( F27, 27, FPR ) +pick0( F28, 28, FPR ) +pick0( F29, 29, FPR ) +pick0( F30, 30, FPR ) +pick0( F31, 31, FPR ) +pick3( END, FPR ) + +#undef pick0 +#undef pick1 +#undef pick2 +#undef pick3 From 90ffe0aee474106f0a2de5d15974178dec4406dd Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Mon, 9 Oct 2023 19:50:14 +0200 Subject: [PATCH 228/258] reformat source files replace signed_16/unsigned_16 by int_16/uint_16 and signed_32/unsigned_32 by int_32/uint_32 to be source lines shorter --- bld/cg/c/addrfold.c | 14 ++--- bld/cg/c/be.c | 15 +++--- bld/cg/c/bestub.c | 44 ++++++++-------- bld/cg/c/bldins.c | 14 ++--- bld/cg/c/bldsel.c | 30 +++++------ bld/cg/c/cg.c | 20 +++---- bld/cg/c/cgdmain.c | 4 +- bld/cg/c/cvtypes.c | 49 ++++++++++-------- bld/cg/c/data.c | 4 +- bld/cg/c/dbsupp.c | 4 +- bld/cg/c/dbtypes.c | 56 ++++++++++---------- bld/cg/c/dftypes.c | 19 +++---- bld/cg/c/dg.c | 96 +++++++++++++++++----------------- bld/cg/c/dumpins.c | 4 +- bld/cg/c/dumpio.c | 32 ++++++------ bld/cg/c/inssched.c | 2 +- bld/cg/c/insutil.c | 2 +- bld/cg/c/intdef.c | 17 +++--- bld/cg/c/intrface.c | 78 ++++++++++++++-------------- bld/cg/c/loopopts.c | 82 ++++++++++++++--------------- bld/cg/c/multiply.c | 10 ++-- bld/cg/c/namelist.c | 26 +++++----- bld/cg/c/patch.c | 2 +- bld/cg/c/peepopt.c | 16 +++--- bld/cg/c/propind.c | 10 ++-- bld/cg/c/regalloc.c | 4 +- bld/cg/c/scinfo.c | 6 +-- bld/cg/c/split.c | 14 ++--- bld/cg/c/stubutil.c | 10 ++-- bld/cg/c/tree.c | 22 ++++---- bld/cg/c/treefold.c | 98 +++++++++++++++++------------------ bld/cg/c/u32moddi.c | 8 +-- bld/cg/c/unroll.c | 34 ++++++------ bld/cg/h/bldins.h | 5 +- bld/cg/h/bldsel.h | 10 ++-- bld/cg/h/bldselco.h | 7 +-- bld/cg/h/block.h | 6 +-- bld/cg/h/cg.h | 4 +- bld/cg/h/cgdll.h | 3 +- bld/cg/h/cgstub.h | 25 ++++----- bld/cg/h/confldef.h | 4 +- bld/cg/h/cvtypes.h | 12 ++--- bld/cg/h/data.h | 4 +- bld/cg/h/dbbit.h | 7 +-- bld/cg/h/dbsyms.h | 8 +-- bld/cg/h/dftypes.h | 10 ++-- bld/cg/h/dumpio.h | 11 ++-- bld/cg/h/encode.h | 4 +- bld/cg/h/indvars.h | 11 ++-- bld/cg/h/inslist.h | 6 +-- bld/cg/h/loopopts.h | 7 +-- bld/cg/h/multiply.h | 4 +- bld/cg/h/name.h | 9 ++-- bld/cg/h/namelist.h | 12 ++--- bld/cg/h/objout.h | 10 ++-- bld/cg/h/objrep.h | 6 +-- bld/cg/h/ocentry.h | 8 +-- bld/cg/h/patch.h | 3 +- bld/cg/h/score.h | 6 +-- bld/cg/h/seldef.h | 10 ++-- bld/cg/h/split.h | 4 +- bld/cg/h/stubdata.h | 3 +- bld/cg/h/symdbg.h | 30 +++++------ bld/cg/h/system.h | 9 ++-- bld/cg/h/treefold.h | 3 +- bld/cg/h/treeprot.h | 4 +- bld/cg/h/typedef.h | 14 ++--- bld/cg/h/u32moddi.h | 4 +- bld/cg/intel/386/c/386enc.c | 26 +++++----- bld/cg/intel/386/c/386sib.c | 2 +- bld/cg/intel/386/c/386splt2.c | 14 ++--- bld/cg/intel/386/c/386tls.c | 2 +- bld/cg/intel/386/h/offset.h | 7 +-- bld/cg/intel/c/wvtypes.c | 20 +++---- bld/cg/intel/c/x86data.c | 12 ++--- bld/cg/intel/c/x86dbsup.c | 10 ++-- bld/cg/intel/c/x86enc.c | 14 ++--- bld/cg/intel/c/x86enc2.c | 10 ++-- bld/cg/intel/c/x86lesds.c | 12 ++--- bld/cg/intel/c/x86mul.c | 6 +-- bld/cg/intel/c/x86obj.c | 60 ++++++++++----------- bld/cg/intel/c/x86sel.c | 54 +++++++++---------- bld/cg/intel/c/x86split.c | 6 +-- bld/cg/intel/h/pccode.h | 3 +- bld/cg/intel/h/wvtypes.h | 8 +-- bld/cg/intel/h/x86call.h | 3 +- bld/cg/intel/h/x86dbsup.h | 6 +-- bld/cg/intel/h/x86enc.h | 10 ++-- bld/cg/intel/h/x86enc2.h | 6 +-- bld/cg/intel/h/x86obj.h | 6 +-- bld/cg/intel/h/x86objd.h | 8 +-- bld/cg/intel/i86/c/i86enc.c | 10 ++-- bld/cg/intel/i86/c/i86splt2.c | 14 ++--- bld/cg/intel/i86/h/offset.h | 8 +-- bld/cg/risc/axp/c/axpenc.c | 54 +++++++++---------- bld/cg/risc/axp/c/axpproc.c | 10 ++-- bld/cg/risc/axp/c/axpsplit.c | 18 +++---- bld/cg/risc/axp/h/axpenc.h | 12 ++--- bld/cg/risc/c/rscconst.c | 22 ++++---- bld/cg/risc/c/rscdata.c | 18 +++---- bld/cg/risc/c/rscindex.c | 2 +- bld/cg/risc/c/rscmul.c | 6 +-- bld/cg/risc/c/rscopt.c | 4 +- bld/cg/risc/c/rscsel.c | 9 ++-- bld/cg/risc/c/rscsplit.c | 22 ++++---- bld/cg/risc/h/offset.h | 7 +-- bld/cg/risc/h/rscconst.h | 3 +- bld/cg/risc/mps/c/mpssetc.c | 12 ++--- bld/cg/risc/mps/c/mpssplit.c | 22 ++++---- bld/cg/risc/mps/h/mpsenc.h | 6 +-- bld/cg/risc/ppc/c/ppcenc.c | 16 +++--- bld/cg/risc/ppc/c/ppcproc.c | 10 ++-- bld/cg/risc/ppc/c/ppcsplit.c | 18 +++---- bld/cg/risc/ppc/h/ppcenc.h | 4 +- 114 files changed, 885 insertions(+), 856 deletions(-) diff --git a/bld/cg/c/addrfold.c b/bld/cg/c/addrfold.c index b2db9487ea..e150b03927 100644 --- a/bld/cg/c/addrfold.c +++ b/bld/cg/c/addrfold.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -361,7 +361,7 @@ bool CypAddrPlus( an l_addr, an r_addr, type_def *tipe ) static bool AddToTypeLength( type_length x, type_length y ) { /*********************************************************************/ - signed_32 lx,ly; + int_32 lx,ly; lx = x; ly = y; x += y; lx += ly; @@ -540,10 +540,10 @@ bool CypAddrShift( an l_addr, an r_addr, type_def *tipe ) } -static bool ShiftToTypeLength( type_length x, unsigned_16 y ) { -/*****************************************************************/ - - signed_32 lx; +static bool ShiftToTypeLength( type_length x, uint_16 y ) +/***********************************************************/ +{ + int_32 lx; lx = x; x <<= y; lx <<= y; @@ -563,7 +563,7 @@ an AddrShift( an l_addr, an r_addr, type_def *tipe ) /* Returns NULL if code needs to be generated*/ { instruction *ins; - signed_16 rv; + int_16 rv; an addr; type_class_def type_class; diff --git a/bld/cg/c/be.c b/bld/cg/c/be.c index 3e5b35f6bb..a141d48d76 100644 --- a/bld/cg/c/be.c +++ b/bld/cg/c/be.c @@ -51,7 +51,7 @@ extern int TempId; -extern unsigned_16 TypeIdx; +extern uint_16 TypeIdx; extern char *ACopyOf(const char *); extern char *Tipe(cg_type ); @@ -228,8 +228,9 @@ extern void BEFiniLabel(l *lb) { CGError( "BEFiniLabel must be called between CGProcDecl and CGReturn%n" ); } } -extern void BEDefType( cg_type t, uint algn, unsigned_32 l ) { -//================================================================ +extern void BEDefType( cg_type t, uint algn, uint_32 l ) +//========================================================== +{ algn=algn; Action( "BEDefType" ); @@ -243,7 +244,7 @@ extern void BEAliasType( cg_type t1, cg_type t2 ) { TypeAlias(t1,t2); Action( "( %s, %s )%n", Tipe(t1), Tipe(t2) ); } -extern unsigned_32 BETypeLength( cg_type t ) { +extern uint_32 BETypeLength( cg_type t ) { //========================================= Action( "BETypeLength" ); @@ -262,8 +263,8 @@ extern void *BEPatch() { Action( "BEPatch()%n" ); return( NULL ); } -extern void BEPatchInteger( void *hdl, signed_32 val ) { -//========================================================== +extern void BEPatchInteger( void *hdl, int_32 val ) { +//===================================================== Action( "BEPatchInteger( %p, %l )%n", hdl, val ); } extern void BEFiniPatch( void *hdl ) { @@ -423,7 +424,7 @@ extern bool BEMoreMem( void ) { return(false); } -extern unsigned_32 BEUnrollCount( unsigned_32 c ) { +extern uint_32 BEUnrollCount( uint_32 c ) { /**************************************************/ return( c ); } diff --git a/bld/cg/c/bestub.c b/bld/cg/c/bestub.c index 3edb96f3cd..c089d6fcde 100644 --- a/bld/cg/c/bestub.c +++ b/bld/cg/c/bestub.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -72,15 +72,15 @@ extern void BEFiniLabel(label_handle _4) {} extern bck_info *BENewBack(sym_handle _4){return(0);} extern void BEFiniBack(bck_info *_4) {} extern void BEFreeBack(bck_info *_4) {} -extern void BEDefType(cg_type _1,uint _2,unsigned_32 _4) {} +extern void BEDefType(cg_type _1,uint _2,uint_32 _4) {} extern void BEAliasType(cg_type _1,cg_type _4) {} -extern unsigned_32 BETypeLength(cg_type _4){return(0);} +extern uint_32 BETypeLength(cg_type _4){return(0);} extern uint BETypeAlign(cg_type _4){return(0);} extern void CGProcDecl(pointer _1,cg_type _4) {} extern void CGParmDecl(pointer _1,cg_type _4) {} extern label_handle CGLastParm(){return(0);} extern void CGAutoDecl(pointer _1,cg_type _4) {} -extern cg_name CGInteger(signed_32 _1,cg_type _4){return(0);} +extern cg_name CGInteger(int_32 _1,cg_type _4){return(0);} extern cg_name CGFloat(char *_1,cg_type _4){return(0);} extern cg_name CGFEName(sym_handle _1,cg_type _4){return(0);} extern cg_name CGBackName(bck_info *_1,cg_type _4){return(0);} @@ -106,8 +106,8 @@ extern void CGControl(cg_op _1,cg_name _2,label_handle _4) {} extern void CGBigLabel(back_handle _4) {} extern void CGBigGoto(label_handle _1,int _4) {} extern sel_handle CGSelInit(){return(0);} -extern void CGSelCase(sel_handle _1,label_handle _2,signed_32 _4) {} -extern void CGSelRange(sel_handle _1,signed_32 _2,signed_32 _3,label_handle _4) {} +extern void CGSelCase(sel_handle _1,label_handle _2,int_32 _4) {} +extern void CGSelRange(sel_handle _1,int_32 _2,int_32 _3,label_handle _4) {} extern void CGSelOther(sel_handle _1,label_handle _4) {} extern void CGSelectRestricted(sel_handle _1,cg_name _4,cg_switch_type _2 ); extern void CGSelect(sel_handle _1,cg_name _4) {} @@ -122,19 +122,19 @@ extern cg_name CGAttr(cg_name _4, cg_sym_attr _1 ){return(0);} static cg_name TwoZeroes[] = { 0,0 }; extern cg_name *CGDuplicate(cg_name _1) { return( TwoZeroes ); } extern void DGLabel(bck_info *_4) {} -extern void DGBackPtr(bck_info * _1,segment_id _2,signed_32 _3,cg_type _4) {} -extern void DGFEPtr(sym_handle _1,cg_type _2,signed_32 _4) {} -extern void DGInteger(unsigned_32 _1,cg_type _4) {} +extern void DGBackPtr(bck_info * _1,segment_id _2,int_32 _3,cg_type _4) {} +extern void DGFEPtr(sym_handle _1,cg_type _2,int_32 _4) {} +extern void DGInteger(uint_32 _1,cg_type _4) {} extern void DGFloat(char *_1,cg_type _4) {} extern void DGChar(char _4) {} extern void DGString(char *_1,uint _4) {} -extern void DGBytes(unsigned_32 _1,byte *_4) {} -extern void DGIBytes(unsigned_32 _1,byte _4) {} -extern void DGUBytes(unsigned_32 _4) {} +extern void DGBytes(uint_32 _1,byte *_4) {} +extern void DGIBytes(uint_32 _1,byte _4) {} +extern void DGUBytes(uint_32 _4) {} extern void DGAlign(uint _4) {} -extern unsigned_32 DGSeek(unsigned_32 _4){return(0);} -extern unsigned_32 DGTell(){return(0);} -extern unsigned_32 DGBackTell(bck_info *_4){return(0);} +extern uint_32 DGSeek(uint_32 _4){return(0);} +extern uint_32 DGTell(){return(0);} +extern uint_32 DGBackTell(bck_info *_4){return(0);} extern void DGCFloat(pointer _1,cg_type _4) {} extern void DBLineNum(uint _4){} @@ -149,20 +149,20 @@ extern name_entry *DBBegName(const char *_5,dbg_type _4){return(0);} extern dbg_type DBForward(name_entry *_6){return(0);} extern dbg_type DBEndName(name_entry *_5,dbg_type _4){return(0);} extern void DumpName(name_entry *_5,dbg_type _4){} -extern dbg_type DBCharBlock(unsigned_32 _4){return(0);} +extern dbg_type DBCharBlock(uint_32 _4){return(0);} extern dbg_type DBIndCharBlock(back_handle _1,cg_type _2, int _4){return(0);} extern dbg_type DBFtnArray(back_handle _1,cg_type _2, cg_type _3, int _4,dbg_type _5){return(0);} extern dbg_type DBArray(dbg_type _1,dbg_type _4){return(0);} -extern dbg_type DBIntArray(unsigned_32 _1,dbg_type _4){return(0);} -extern dbg_type DBSubRange(signed_32 _1,signed_32 _2,dbg_type _4){return(0);} +extern dbg_type DBIntArray(uint_32 _1,dbg_type _4){return(0);} +extern dbg_type DBSubRange(int_32 _1,int_32 _2,dbg_type _4){return(0);} extern dbg_type DBDereference(cg_type _1,dbg_type _4){return(0);} extern dbg_type DBPtr(cg_type _1,dbg_type _4){return(0);} extern struct_list *DBBegStruct(cg_type _1,bool _2){return(0);} -extern void DBAddField(struct_list *_5,unsigned_32 _1,char *_2,dbg_type _4){} -extern void DBAddBitField(struct_list *_5,unsigned_32 _1,byte _2,byte _3,char *_6,dbg_type _4){} +extern void DBAddField(struct_list *_5,uint_32 _1,char *_2,dbg_type _4){} +extern void DBAddBitField(struct_list *_5,uint_32 _1,byte _2,byte _3,char *_6,dbg_type _4){} extern dbg_type DBEndStruct(struct_list *_6){return(0);} extern enum_list *DBBegEnum(cg_type _4){return(0);} -extern void DBAddConst(enum_list *_5,const char *_6,signed_32 _4){} +extern void DBAddConst(enum_list *_5,const char *_6,int_32 _4){} extern dbg_type DBEndEnum(enum_list *_6){return(0);} extern proc_list *DBBegProc(cg_type _1,dbg_type _4){return(0);} extern void DBAddParm(proc_list *_5,dbg_type _4){} @@ -173,6 +173,6 @@ extern void DBAddLocField(dbg_struct _1,dbg_loc _2,uint _3,byte _4,byte _5,char extern void DBAddInheritance(dbg_struct _1,dbg_type _2,dbg_loc _3){} extern dbg_loc DBLocInit(void){return 0;} extern dbg_loc DBLocSym(dbg_loc _1,cg_sym_handle _2){return 0;} -extern dbg_loc DBLocConst(dbg_loc _1,unsigned_32 _2){return 0;} +extern dbg_loc DBLocConst(dbg_loc _1,uint_32 _2){return 0;} extern dbg_loc DBLopOp(dbg_loc _1,dbg_loc_op _2,unsigned _3){return 0;} extern void DBLocFini(dbg_loc _1){} diff --git a/bld/cg/c/bldins.c b/bld/cg/c/bldins.c index 2aa3898bb7..8183f40105 100644 --- a/bld/cg/c/bldins.c +++ b/bld/cg/c/bldins.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -55,7 +55,7 @@ static type_def *LastCmpType; -static unsigned_32 UnrollValue = 0; +static uint_32 UnrollValue = 0; an BGVarargsBasePtr( type_def *tipe ) /****************************************/ @@ -75,8 +75,8 @@ an BGStackValue( type_def *tipe ) return( addr ); } -an BGInteger( signed_32 value, type_def *tipe ) -/**************************************************/ +an BGInteger( int_32 value, type_def *tipe ) +/***********************************************/ { float_handle cf; @@ -461,10 +461,10 @@ void BGBigGoto( label_handle lbl, level_depth level ) } -unsigned_32 BGUnrollCount( unsigned_32 unroll_count ) -/***************************************************/ +uint_32 BGUnrollCount( uint_32 unroll_count ) +/*******************************************/ { - unsigned_32 old_value; + uint_32 old_value; old_value = UnrollValue; UnrollValue = unroll_count; diff --git a/bld/cg/c/bldsel.c b/bld/cg/c/bldsel.c index 0bf36e1436..71d05ca592 100644 --- a/bld/cg/c/bldsel.c +++ b/bld/cg/c/bldsel.c @@ -48,8 +48,8 @@ #include "generate.h" -static select_list *NewCase( signed_32 lo, signed_32 hi, label_handle label ) -/****************************************************************************/ +static select_list *NewCase( int_32 lo, int_32 hi, label_handle label ) +/**********************************************************************/ { select_list *new_entry; @@ -80,15 +80,15 @@ sel_handle BGSelInit( void ) } -void BGSelCase( sel_handle s_node, label_handle label, signed_32 value ) -/*************************************************************************/ +void BGSelCase( sel_handle s_node, label_handle label, int_32 value ) +/**********************************************************************/ { BGSelRange( s_node, value, value, label ); } -void BGSelRange( sel_handle s_node, signed_32 lo, signed_32 hi, label_handle label ) -/*************************************************************************************/ +void BGSelRange( sel_handle s_node, int_32 lo, int_32 hi, label_handle label ) +/*******************************************************************************/ { select_list *new_entry; @@ -109,8 +109,8 @@ void BGSelOther( sel_handle s_node, label_handle other ) static type_def *SortTipe; -int SelCompare( signed_32 lo1, signed_32 lo2 ) -/********************************************/ +int SelCompare( int_32 lo1, int_32 lo2 ) +/**************************************/ { if( lo1 == lo2 ) return( 0 ); @@ -119,7 +119,7 @@ int SelCompare( signed_32 lo1, signed_32 lo2 ) return( -1 ); } } else { - if( (unsigned_32)lo1 < (unsigned_32)lo2 ) { + if( (uint_32)lo1 < (uint_32)lo2 ) { return( -1 ); } } @@ -196,8 +196,8 @@ static cost_val DistinctIfCost( sel_handle s_node ) } -cg_type SelType( unsigned_32 value_range ) -/****************************************/ +cg_type SelType( uint_32 value_range ) +/************************************/ { cg_type tipe; @@ -374,7 +374,7 @@ static an GenSelTable( an node, sel_handle s_node, type_def *tipe ) static void DoBinarySearch( an node, select_list *list, type_def *tipe, int lo, int hi, label_handle other, - signed_32 lobound, signed_32 hibound, + int_32 lobound, int_32 hibound, bool have_lobound, bool have_hibound ) /*************************************************************************/ { @@ -496,10 +496,10 @@ static an GenIfStmts( an node, sel_handle s_node, type_def *tipe ) } -signed_32 NumValues( select_list *list, signed_32 hi ) -/**********************************************************/ +int_32 NumValues( select_list *list, int_32 hi ) +/***************************************************/ { - signed_32 cases; + int_32 cases; cases = 0; for( ; list != NULL; list = list->next ) { diff --git a/bld/cg/c/cg.c b/bld/cg/c/cg.c index 7832b058ea..0295083f55 100644 --- a/bld/cg/c/cg.c +++ b/bld/cg/c/cg.c @@ -68,7 +68,7 @@ extern char *Op(cg_op ); extern void NotDefault(cg_type ); extern void CGError(const char *,... ); extern void VerBack(b *); -extern char *LToS(signed_32 ); +extern char *LToS( int_32 ); extern void DumpT(n *); extern void VerOp(cg_op ,cg_op *); extern void Find(char *,pointer *,pointer ); @@ -78,7 +78,7 @@ extern void CDefLabel(l *lb); extern void DRefLabel(l *lb); extern void DDefLabel(l *lb); extern pointer LkAddBack(sym_handle,pointer); -extern unsigned_32 BETypeLength( cg_type ); +extern uint_32 BETypeLength( cg_type ); /********************************************************************/ /* Handle feedback for auto locations */ @@ -483,16 +483,16 @@ extern sh *CGSelInit() { Action( " -> %d%n", SelId ); return(s); } -extern void CGSelCase( sh *s, l *lb, signed_32 v ) { -/******************************************************/ +extern void CGSelCase( sh *s, l *lb, int_32 v ) { +/*************************************************/ Action( "CGSelCase" ); Action( "( %d, %l, %s )%n", s->i, v, Label( lb ) ); CRefLabel( lb ); SelRange(s,v,v,lb); } -extern void CGSelRange( sh *s, signed_32 lo, signed_32 hi, l *lb ) { -/**********************************************************************/ +extern void CGSelRange( sh *s, int_32 lo, int_32 hi, l *lb ) { +/**************************************************************/ Action( "CGSelRange" ); Action( "( %d, %l, %l, %s )%n", s->i, lo, hi, Label( lb ) ); @@ -500,8 +500,8 @@ extern void CGSelRange( sh *s, signed_32 lo, signed_32 hi, l *lb ) { SelRange(s,lo,hi,lb); } -extern void SelRange( sh *s, signed_32 lo, signed_32 hi, l *lb ) { -/********************************************************************/ +extern void SelRange( sh *s, int_32 lo, int_32 hi, l *lb ) { +/************************************************************/ rh **or; rh *n; @@ -559,8 +559,8 @@ extern void CGSelect( sh *s, n *e ) { Code("}%n"); CGFree(s); } -extern n *CGInteger( signed_32 i, cg_type t ) { -/****************************************************/ +extern n *CGInteger( int_32 i, cg_type t ) { +/***********************************************/ n *in; diff --git a/bld/cg/c/cgdmain.c b/bld/cg/c/cgdmain.c index e03ecb2856..e97934d651 100644 --- a/bld/cg/c/cgdmain.c +++ b/bld/cg/c/cgdmain.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2018 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -64,7 +64,7 @@ void _CGDLLEXPORT BEDLLFini( cg_interface *func_table ) // nothing yet } -int __stdcall LibMain( unsigned_32 hdll, unsigned_32 reason, void *reserved ) +int __stdcall LibMain( uint_32 hdll, uint_32 reason, void *reserved ) { /* unused parameters */ (void)hdll; (void)reason; (void)reserved; diff --git a/bld/cg/c/cvtypes.c b/bld/cg/c/cvtypes.c index 97f03c00ae..c676872b72 100644 --- a/bld/cg/c/cvtypes.c +++ b/bld/cg/c/cvtypes.c @@ -225,8 +225,8 @@ static void PutFld2( cv_out *out, short num ) out->ptr += sizeof( short ); } -static void PutFldSized( cv_out *out, int size, unsigned_32 val ) -/***************************************************************/ +static void PutFldSized( cv_out *out, int size, uint_32 val ) +/***********************************************************/ { switch( size ) { case 1: @@ -244,8 +244,8 @@ static void PutFldSized( cv_out *out, int size, unsigned_32 val ) } } -static void PutLFInt( cv_out *out, cv_psize size, unsigned_32 val ) -/*****************************************************************/ +static void PutLFInt( cv_out *out, cv_psize size, uint_32 val ) +/*************************************************************/ { switch( size ) { case CV_IB1: @@ -285,8 +285,8 @@ static lf_values LFIntType( int size ) return( itipe ); } -void CVPutINum( cv_out *out, signed_32 num ) -/******************************************/ +void CVPutINum( cv_out *out, int_32 num ) +/***************************************/ { byte *ptr; #define LC( what, to ) *((to *)&what) @@ -355,8 +355,8 @@ void CVPutNullStr( cv_out *out ) } -static lf_values LFSignedSize( signed_32 num ) -/***********************************************/ +static lf_values LFSignedSize( int_32 num ) +/********************************************/ { cv_primitive index; @@ -373,8 +373,8 @@ static lf_values LFSignedSize( signed_32 num ) return( index.s ); } -static lf_values LFSignedRange( signed_32 lo, signed_32 hi ) -/**************************************************************/ +static lf_values LFSignedRange( int_32 lo, int_32 hi ) +/********************************************************/ { cv_primitive index; @@ -579,8 +579,8 @@ dbg_type CVArray( dbg_type dims, dbg_type base ) return( ret ); } -dbg_type CVArraySize( offset size, unsigned_32 hi, dbg_type base ) -/*******************************************************************/ +dbg_type CVArraySize( offset size, uint_32 hi, dbg_type base ) +/***************************************************************/ { cv_out out[1]; ct_array *array; @@ -598,8 +598,10 @@ dbg_type CVArraySize( offset size, unsigned_32 hi, dbg_type base ) return( ret ); } -static lf_values ArrayDim( unsigned_32 hi ) -/************ Make 1 dim array bound *********/ +static lf_values ArrayDim( uint_32 hi ) +/***************************************** + * Make 1 dim array bound + */ { cv_out out[1]; ct_dimconu *dim; @@ -617,8 +619,8 @@ static lf_values ArrayDim( unsigned_32 hi ) return( ret ); } -dbg_type CVCharBlock( unsigned_32 len ) -/****************************************/ +dbg_type CVCharBlock( uint_32 len ) +/************************************/ { return( CVArraySize( len, len, LF_TRCHAR ) ); } @@ -845,8 +847,8 @@ dbg_type CVFtnArray( back_handle dims, cg_type lo_bound_tipe, -dbg_type CVIntArray( unsigned_32 hi, dbg_type base ) -/*****************************************************/ +dbg_type CVIntArray( uint_32 hi, dbg_type base ) +/*************************************************/ { cv_out out[1]; ct_dimarray *array; @@ -867,8 +869,8 @@ dbg_type CVIntArray( unsigned_32 hi, dbg_type base ) -static lf_values ArrayDimL( signed_32 low, signed_32 hi ) -/************ Make 1 dim array bound **********************/ +static lf_values ArrayDimL( int_32 low, int_32 hi ) +/************ Make 1 dim array bound ****************/ { cv_out out[1]; ct_dimconlu *dim; @@ -979,9 +981,10 @@ dbg_type CVEndArray( dbg_array ar ) return( CVArray( dims, ar->base ) ); } -dbg_type CVSubRange( signed_32 lo, signed_32 hi, dbg_type base ) -/****************************************************************/ -/* not supported by CV */ +dbg_type CVSubRange( int_32 lo, int_32 hi, dbg_type base ) +/*********************************************************** + * not supported by CV + */ { /* unused parameters */ (void)base; diff --git a/bld/cg/c/data.c b/bld/cg/c/data.c index e5d4846d73..3af9aa4f4a 100644 --- a/bld/cg/c/data.c +++ b/bld/cg/c/data.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2019 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -69,7 +69,7 @@ bool BlocksUnTrimmed; an AddrList; segment_id DbgLocals; segment_id DbgTypes; -unsigned_16 TypeIdx; +uint_16 TypeIdx; int InOptimizer; byte OptForSize; bool HaveLiveInfo; diff --git a/bld/cg/c/dbsupp.c b/bld/cg/c/dbsupp.c index e6d5466e83..e79dc2479c 100644 --- a/bld/cg/c/dbsupp.c +++ b/bld/cg/c/dbsupp.c @@ -182,8 +182,8 @@ dbg_loc _CGAPI DBLocTemp( dbg_loc loc, temp_handle temp ) return( loc ); } -dbg_loc _CGAPI DBLocConst( dbg_loc loc, unsigned_32 val ) -/*******************************************************/ +dbg_loc _CGAPI DBLocConst( dbg_loc loc, uint_32 val ) +/***************************************************/ { #ifdef DEVBUILD EchoAPI( "DBLocConst( %i, %i )", loc, val ); diff --git a/bld/cg/c/dbtypes.c b/bld/cg/c/dbtypes.c index 7f5965c283..2740cd05be 100644 --- a/bld/cg/c/dbtypes.c +++ b/bld/cg/c/dbtypes.c @@ -227,8 +227,8 @@ dbg_type _CGAPI DBEndName( dbg_name name, dbg_type tipe ) } -dbg_type _CGAPI DBCharBlock( unsigned_32 len ) -/****************************************************/ +dbg_type _CGAPI DBCharBlock( uint_32 len ) +/****************************************/ { dbg_type ret; @@ -249,8 +249,8 @@ dbg_type _CGAPI DBCharBlock( unsigned_32 len ) return( ret ); } -dbg_type _CGAPI DBCharBlockNamed( cchar_ptr name, unsigned_32 len ) -/*************************************************************************/ +dbg_type _CGAPI DBCharBlockNamed( cchar_ptr name, uint_32 len ) +/*************************************************************/ { dbg_type ret; @@ -420,8 +420,8 @@ static void AddDim( dbg_array ar, dim_any *dim ) ar->num++; } -void _CGAPI DBDimCon( dbg_array ar, dbg_type idx, signed_32 lo, signed_32 hi ) -/************************************************************************************/ +void _CGAPI DBDimCon( dbg_array ar, dbg_type idx, int_32 lo, int_32 hi ) +/**********************************************************************/ { dim_con *dim; @@ -482,8 +482,8 @@ dbg_type _CGAPI DBEndArray( dbg_array ar ) return( ret ); } -dbg_type _CGAPI DBIntArray( unsigned_32 hi, dbg_type base ) -/*****************************************************************/ +dbg_type _CGAPI DBIntArray( uint_32 hi, dbg_type base ) +/*****************************************************/ { dbg_type ret; @@ -507,8 +507,8 @@ dbg_type _CGAPI DBIntArray( unsigned_32 hi, dbg_type base ) return( ret ); } -dbg_type _CGAPI DBIntArrayCG( cg_type tipe, unsigned_32 hi, dbg_type base ) -/*********************************************************************************/ +dbg_type _CGAPI DBIntArrayCG( cg_type tipe, uint_32 hi, dbg_type base ) +/*********************************************************************/ { dbg_type ret; type_def *tipe_addr; @@ -534,8 +534,8 @@ dbg_type _CGAPI DBIntArrayCG( cg_type tipe, unsigned_32 hi, dbg_type base ) return( ret ); } -dbg_type _CGAPI DBSubRange( signed_32 lo, signed_32 hi, dbg_type base ) -/*****************************************************************************/ +dbg_type _CGAPI DBSubRange( int_32 lo, int_32 hi, dbg_type base ) +/***************************************************************/ { dbg_type ret; @@ -736,9 +736,9 @@ static void AddField( dbg_struct st, field_any *field ) } -void _CGAPI DBAddBitField( dbg_struct st, unsigned_32 off, byte strt, - byte len, cchar_ptr nm, dbg_type base ) -/*****************************************************************************/ +void _CGAPI DBAddBitField( dbg_struct st, uint_32 off, byte strt, + byte len, cchar_ptr nm, dbg_type base ) +/*****************************************************************/ { field_member *field; @@ -752,9 +752,9 @@ void _CGAPI DBAddBitField( dbg_struct st, unsigned_32 off, byte strt, } -void _CGAPI DBAddField( dbg_struct st, unsigned_32 off, - cchar_ptr nm, dbg_type base ) -/***************************************************************/ +void _CGAPI DBAddField( dbg_struct st, uint_32 off, + cchar_ptr nm, dbg_type base ) +/****************************************************/ { #ifdef DEVBUILD EchoAPI( "DBAddField( %i, %i,%c,%i)\n", st, off, nm, base ); @@ -785,8 +785,8 @@ void _CGAPI DBAddLocField( dbg_struct st, dbg_loc loc, uint attr, AddField( st, (field_any *)field ); } -void _CGAPI DBAddStField( dbg_struct st, dbg_loc loc, cchar_ptr nm, unsigned_32 attr, dbg_type base ) -/***********************************************************************************************************/ +void _CGAPI DBAddStField( dbg_struct st, dbg_loc loc, cchar_ptr nm, uint_32 attr, dbg_type base ) +/***********************************************************************************************/ { uint n_len; field_stfield *field; @@ -864,9 +864,9 @@ void _CGAPI DBAddInheritance( dbg_struct st, dbg_type inherit, AddField( st, (field_any *)field ); } -void _CGAPI DBAddBaseInfo( dbg_struct st, unsigned_32 vb_off, int esize, - dbg_type vtbl, cg_type ptr_type ) -/********************************************************************************/ +void _CGAPI DBAddBaseInfo( dbg_struct st, uint_32 vb_off, int esize, + dbg_type vtbl, cg_type ptr_type ) +/*******************************************************************/ { #ifdef DEVBUILD EchoAPI( "DBAddBaseInfo( %i,%i,%i,%i,%t)\n", st, vb_off, esize, vtbl, ptr_type ); @@ -878,9 +878,9 @@ void _CGAPI DBAddBaseInfo( dbg_struct st, unsigned_32 vb_off, int esize, } -void _CGAPI DBAddVFuncInfo( dbg_struct st, unsigned_32 vfptr_off, - int size, cg_type vft_cgtype ) -/********************************************************************/ +void _CGAPI DBAddVFuncInfo( dbg_struct st, uint_32 vfptr_off, + int size, cg_type vft_cgtype ) +/************************************************************/ { field_vfunc *field; @@ -952,8 +952,8 @@ dbg_enum _CGAPI DBBegEnum( cg_type tipe ) return( en ); } -void _CGAPI DBAddConst( dbg_enum en, cchar_ptr nm, signed_32 val ) -/****************************************************************/ +void _CGAPI DBAddConst( dbg_enum en, cchar_ptr nm, int_32 val ) +/*************************************************************/ { const_entry *cons; uint len; diff --git a/bld/cg/c/dftypes.c b/bld/cg/c/dftypes.c index de4c0ff9ca..14dd231829 100644 --- a/bld/cg/c/dftypes.c +++ b/bld/cg/c/dftypes.c @@ -147,8 +147,8 @@ void DFBackRefType( dbg_name name, dbg_type tipe ) Zoiks( ZOIKS_108 ); } -dbg_type DFCharBlock( unsigned_32 len ) -/********************************************/ +dbg_type DFCharBlock( uint_32 len ) +/****************************************/ { dbg_type ret; @@ -156,8 +156,8 @@ dbg_type DFCharBlock( unsigned_32 len ) return( ret ); } -dbg_type DFCharBlockNamed( const char *name, unsigned_32 len ) -/***************************************************************/ +dbg_type DFCharBlockNamed( const char *name, uint_32 len ) +/***********************************************************/ { dbg_type ret; @@ -217,8 +217,8 @@ dbg_type DFArray( dbg_type idx, dbg_type base ) return( ret ); } -dbg_type DFIntArray( unsigned_32 hi, dbg_type base ) -/*********************************************************/ +dbg_type DFIntArray( uint_32 hi, dbg_type base ) +/*****************************************************/ { dbg_type ret; @@ -324,9 +324,10 @@ dbg_type DFFtnArray( back_handle dims, cg_type lo_bound_tipe, } -dbg_type DFSubRange( signed_32 lo, signed_32 hi, dbg_type base ) -/**************************************************************/ -/* need some dwarflib support */ +dbg_type DFSubRange( int_32 lo, int_32 hi, dbg_type base ) +/********************************************************* + * need some dwarflib support + */ { /* unused parameters */ (void)lo; (void)hi; (void)base; diff --git a/bld/cg/c/dg.c b/bld/cg/c/dg.c index 6035690a18..1041dbff70 100644 --- a/bld/cg/c/dg.c +++ b/bld/cg/c/dg.c @@ -50,7 +50,7 @@ #include "cgprotos.h" -extern unsigned_16 TypeIdx; +extern uint_16 TypeIdx; extern char *ACopyOf(const char *); extern void VerTipe(cg_type ,cg_type *); @@ -64,7 +64,7 @@ extern char *Name(pointer ); extern void Put(char *,... ); extern void SymDbg(char *,... ); extern void VerBack(b *); -extern char *LToS(signed_32 ); +extern char *LToS( int_32 ); extern void CGError(const char *, ... ); extern void DDefLabel(l *); extern void DRefLabel(l *); @@ -80,10 +80,10 @@ void DGAlign( uint algn ) Put(" align to %d byte boundry (%d)%n", algn, Locs[CurSeg] ); } -uint DGSeek( unsigned_32 where ) -//================================= +uint DGSeek( uint_32 where ) +//============================= { - unsigned_32 old; + uint_32 old; Action( "DGSeek( %l )", where ); Put( " seek to location %l%n", where ); @@ -93,16 +93,16 @@ uint DGSeek( unsigned_32 where ) return( old ); } -void DGUBytes( unsigned_32 len ) -//================================= +void DGUBytes( uint_32 len ) +//============================= { Action( "DGUBytes( %l )%n", len ); Put(" %l B(?)%n", len ); Locs[CurSeg] += len; } -void DGIBytes( unsigned_32 len, byte pat ) -//=========================================== +void DGIBytes( uint_32 len, byte pat ) +//======================================= { Action( "DGIBytes( %l, %h )%n", len, pat ); Put(" %d B(%h)%n", len, pat ); @@ -121,16 +121,16 @@ void DGLabel( b *bk ) Put(":%n"); } -unsigned_32 DGTell( void ) -//============================ +uint_32 DGTell( void ) +//==================== { Action( "DGTell() -> %l%n", Locs[CurSeg] ); return( Locs[CurSeg] ); } -extern unsigned_32 DGBackTell( b *bk ) { -//=================================== - +extern uint_32 DGBackTell( b *bk ) +//================================= +{ Action( "DGBackTell" ); VerBack(bk); if( !bk->lp->ddef ) { @@ -140,8 +140,8 @@ extern unsigned_32 DGBackTell( b *bk ) { Action( "( %s ) -> %l%n", Label( bk->lp ), bk->loc ); return( bk->loc ); } -extern void DGFEPtr( sym s, cg_type t, signed_32 o ) { -//========================================================== +extern void DGFEPtr( sym s, cg_type t, int_32 o ) { +//=================================================== b *bk; @@ -155,8 +155,8 @@ extern void DGFEPtr( sym s, cg_type t, signed_32 o ) { Put( ") + %l %s%n",o,Tipe(t) ); Locs[CurSeg] += TypeAddress( t )->length; } -extern void DGBackPtr( b *bk, segment_id s, signed_32 o, cg_type t ) { -//========================================================================== +extern void DGBackPtr( b *bk, segment_id s, int_32 o, cg_type t ) { +//=================================================================== Action( "DGBackPtr" ); Action( "( %s, %d, %l, %s )%n", Label( bk->lp ), s, o, Tipe( t ) ); @@ -167,9 +167,9 @@ extern void DGBackPtr( b *bk, segment_id s, signed_32 o, cg_type t ) { Put( ") + %l (seg %d) %s%n",o,s,Tipe(t) ); Locs[CurSeg] += TypeAddress( t )->length; } -extern void DGBytes( unsigned_32 len, const void *bp ) { -//============================================ - +extern void DGBytes( uint_32 len, const void *bp ) +//==================================================== +{ const byte *p = bp; Action( "DGBytes( %l, ... )%n", len ); Put( " " ); @@ -188,9 +188,9 @@ extern void PutName( b *bk ) { Put( " [%s]", Name( bk->s ) ); } } -extern void DGInteger( unsigned_32 i, cg_type t ) { -//====================================================== - +extern void DGInteger( uint_32 i, cg_type t ) +//=============================================== +{ Action( "DGInteger" ); VerTipe( t,DGIntTypes ); Action( "( %l, %s )%n", i, Tipe( t ) ); @@ -271,7 +271,7 @@ typedef struct location { t *be_sym; cg_sym_handle fe_sym; unsigned stk; - unsigned_32 val; + uint_32 val; } u; byte class; } location; @@ -363,8 +363,8 @@ extern dbg_loc DBLocTemp( dbg_loc loc, t *tm ) { return( loc ); } -extern dbg_loc DBLocConst( dbg_loc loc, unsigned_32 val ) { -/******************************************************************/ +extern dbg_loc DBLocConst( dbg_loc loc, uint_32 val ) { +/************************************************************/ Action( "DBLocConst( %p, %l ) ==>", loc, val ); loc = LocCreate( loc, LOC_CONST ); @@ -655,8 +655,8 @@ extern dbg_type DBEndName( dbg_name nm, dbg_type tipe ) { Action( " -> %d%n", retv ); return( retv ); } -extern dbg_type DBCharBlock( unsigned_32 len ) { -//====================================================== +extern dbg_type DBCharBlock( uint_32 len ) { +//================================================ Action( "DBCharBlock( %l )", len ); TypDbg( "(%d) CharBlock len==%l%n", ++TypeIdx, len ); @@ -722,16 +722,16 @@ extern dbg_type DBArray( dbg_type idx, dbg_type base ) { Action( " -> %d%n", TypeIdx ); return( TypeIdx ); } -extern dbg_type DBIntArray( unsigned_32 hi, dbg_type base ) { -//=================================================================== +extern dbg_type DBIntArray( uint_32 hi, dbg_type base ) { +//============================================================= Action( "DBIntArray( %l, %d )", hi, base ); TypDbg( "(%d) Int Array hi==%l, base==%d%n", ++TypeIdx, hi, base ); Action( " -> %d%n", TypeIdx ); return( TypeIdx ); } -extern dbg_type DBIntArrayCG( cg_type tipe, unsigned_32 hi, dbg_type base ) -/*********************************************************************************/ +extern dbg_type DBIntArrayCG( cg_type tipe, uint_32 hi, dbg_type base ) +/*****************************************************************************/ { Action( "DBIntArrayCg( %s, %l, %d )", Tipe(tipe), hi, base ); TypDbg( "(%d) Int Array hi==%l, base==%d%n", ++TypeIdx, hi, base ); @@ -776,8 +776,8 @@ static void AddDim( array_list *ar, dim_any *dim ) ar->num++; } -extern void DBDimCon( array_list *ar, dbg_type idx, signed_32 lo, signed_32 hi ) -/*******************************************************************************/ +extern void DBDimCon( array_list *ar, dbg_type idx, int_32 lo, int_32 hi ) +/*************************************************************************/ { dim_con *dim; @@ -821,8 +821,8 @@ extern dbg_type DBEndArray( array_list *ar ) { return( TypeIdx ); } -extern dbg_type DBSubRange( signed_32 lo, signed_32 hi, dbg_type base ) { -//============================================================================= +extern dbg_type DBSubRange( int_32 lo, int_32 hi, dbg_type base ) { +//======================================================================= Action( "DBSubRange( %l, %l, %d )", lo, hi, base ); TypDbg( "(%d) Subrange lo==%l, hi==%l, base==%d%n", ++TypeIdx, @@ -909,9 +909,9 @@ static void AddField( struct_list *st, field_any *field ) st->num++; } -extern void DBAddBitField( struct_list *st, unsigned_32 off, byte strt, - byte len, cchar_ptr nm, dbg_type base) -/*************************************************************************/ +extern void DBAddBitField( struct_list *st, uint_32 off, byte strt, + byte len, cchar_ptr nm, dbg_type base) +/*********************************************************************/ { field_member *field; @@ -937,8 +937,8 @@ extern void DBAddLocField( struct_list *st, dbg_loc loc, uint attr, } -extern void DBAddField(struct_list *st,unsigned_32 off,cchar_ptr nm,dbg_type base) -//================================================================================ +extern void DBAddField(struct_list *st,uint_32 off,cchar_ptr nm,dbg_type base) +//============================================================================ { field_member *field; @@ -1022,9 +1022,9 @@ extern void DBAddInheritance( struct_list *st, dbg_type inherit, AddField( st, field ); } -void DBAddBaseInfo( struct_list *st, unsigned_32 vb_off, unsigned_32 esize, - dbg_type vtbl, cg_type ptr_type ) -/******************************************************************************/ +void DBAddBaseInfo( struct_list *st, uint_32 vb_off, uint_32 esize, + dbg_type vtbl, cg_type ptr_type ) +/***********************************************************************/ { st->vtbl_off = vb_off; st->vtbl_type = vtbl; @@ -1034,7 +1034,7 @@ void DBAddBaseInfo( struct_list *st, unsigned_32 vb_off, unsigned_32 esize, esize, vtbl, Tipe( ptr_type) ); } -extern void DBAddVFuncInfo( struct_list *st, unsigned_32 vfptr_off, +extern void DBAddVFuncInfo( struct_list *st, uint_32 vfptr_off, int size, cg_type vft_cgtype ) //====================================================================== @@ -1126,8 +1126,8 @@ enum_list *DBBegEnum( cg_type tipe ) return( en ); } -void DBAddConst( enum_list *en, cchar_ptr nm, signed_32 val ) -//============================================================== +void DBAddConst( enum_list *en, cchar_ptr nm, int_32 val ) +//=========================================================== { const_entry *cons; diff --git a/bld/cg/c/dumpins.c b/bld/cg/c/dumpins.c index c772cef0fc..8ac36b7974 100644 --- a/bld/cg/c/dumpins.c +++ b/bld/cg/c/dumpins.c @@ -50,8 +50,8 @@ #define DO_DUMPOFFSET(str,off) DumpLiteral( str ); DoOffset( (off) ) -static void DoOffset( unsigned_32 o ) { -/*****************************************/ +static void DoOffset( uint_32 o ) { +/***********************************/ DumpChar( '\t' ); Dump8h( o ); diff --git a/bld/cg/c/dumpio.c b/bld/cg/c/dumpio.c index c0627de070..2da69901b3 100644 --- a/bld/cg/c/dumpio.c +++ b/bld/cg/c/dumpio.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2019 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -140,8 +140,8 @@ void DumpByte( byte n ) DumpChar( c ); } -void Dump8h( unsigned_32 n ) -/*****************************/ +void Dump8h( uint_32 n ) +/*************************/ { DumpByte( n >> 24 ); DumpByte( n >> 16 ); @@ -150,8 +150,8 @@ void Dump8h( unsigned_32 n ) } -static void _DumpLongLen( unsigned_32 n, int len, bool sign ) -/***********************************************************/ +static void _DumpLongLen( uint_32 n, int len, bool sign ) +/*******************************************************/ { char b[30]; char *bp; @@ -160,9 +160,9 @@ static void _DumpLongLen( unsigned_32 n, int len, bool sign ) bp = b; bp += 20; *--bp = NULLCHAR; - if( sign && (signed_32)n < 0 ) { + if( sign && (int_32)n < 0 ) { neg = true; - n = -(signed_32)n; + n = -(int_32)n; } else { neg = false; } @@ -189,14 +189,14 @@ static void _DumpLongLen( unsigned_32 n, int len, bool sign ) DumpXString( bp ); } -void DumpLongLen( signed_32 n, int len ) -/*****************************************/ +void DumpLongLen( int_32 n, int len ) +/**************************************/ { _DumpLongLen( n, len, true ); } -void DumpLong( signed_32 n ) -/*****************************/ +void DumpLong( int_32 n ) +/**************************/ { _DumpLongLen( n, 0, true ); } @@ -207,14 +207,14 @@ void DumpInt( int n ) DumpLong( n ); } -void DumpULongLen( unsigned_32 n, int len ) -/********************************************/ +void DumpULongLen( uint_32 n, int len ) +/****************************************/ { _DumpLongLen( n, len, false ); } -void DumpULong( unsigned_32 n ) -/********************************/ +void DumpULong( uint_32 n ) +/****************************/ { _DumpLongLen( n, 0, false ); } @@ -236,5 +236,5 @@ void DumpId( unsigned id ) void DumpPtr( void *ptr ) /**************************/ { - Dump8h( (unsigned_32)(pointer_uint)ptr ); + Dump8h( (uint_32)(pointer_uint)ptr ); } diff --git a/bld/cg/c/inssched.c b/bld/cg/c/inssched.c index 633ed7789c..02d5e0c89c 100644 --- a/bld/cg/c/inssched.c +++ b/bld/cg/c/inssched.c @@ -855,7 +855,7 @@ static void ScheduleIns( void ) int curr_cost; int stk_depth; int stk_over; - unsigned_16 last_seq; + uint_16 last_seq; /* * What the hell is he doing with the visited bit here!?... diff --git a/bld/cg/c/insutil.c b/bld/cg/c/insutil.c index 3a21028413..23c4c8bb71 100644 --- a/bld/cg/c/insutil.c +++ b/bld/cg/c/insutil.c @@ -454,7 +454,7 @@ instruction_id Renumber( void ) instruction *ins; instruction_id id; instruction_id increment; - unsigned_32 number_instrs; + uint_32 number_instrs; number_instrs = 0; for( blk = HeadBlock; blk != NULL; blk = blk->next_block ) { diff --git a/bld/cg/c/intdef.c b/bld/cg/c/intdef.c index 76b1de8e82..26c8079752 100644 --- a/bld/cg/c/intdef.c +++ b/bld/cg/c/intdef.c @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -29,11 +30,11 @@ ****************************************************************************/ -unsigned_16 TargetShort( unsigned_16 value ) +uint_16 TargetShort( uint_16 value ) { union { char b[2]; - unsigned_16 val; + uint_16 val; } in, out; in.val = value; @@ -47,11 +48,11 @@ int TargetOffset( int value ) return( value ); } -unsigned_32 TargetBigInt( unsigned_32 value ) +uint_32 TargetBigInt( uint_32 value ) { union { char b[4]; - unsigned_32 val; + uint_32 val; } in, out; in.val = value; @@ -62,17 +63,17 @@ unsigned_32 TargetBigInt( unsigned_32 value ) return( out.val ); } -void TargAddL( unsigned_32 *targetw, unsigned_32 value ) +void TargAddL( uint_32 *targetw, uint_32 value ) { - unsigned_32 out; + uint_32 out; out = TargetBigInt( *targetw ) + value; *targetw = TargetBigInt( out ); } -void TargAddW( unsigned_16 *targetw, unsigned_16 value ) +void TargAddW( uint_16 *targetw, uint_16 value ) { - unsigned_16 out; + uint_16 out; out = TargetShort( *targetw ) + value; *targetw = TargetShort( out ); diff --git a/bld/cg/c/intrface.c b/bld/cg/c/intrface.c index 3c3fa73cf0..99a8215f3a 100644 --- a/bld/cg/c/intrface.c +++ b/bld/cg/c/intrface.c @@ -353,11 +353,11 @@ void _CGAPI BEFiniLabel( label_handle lbl ) /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ -unsigned_32 _CGAPI BEUnrollCount( unsigned_32 unroll_count ) -/***************************************************************/ +uint_32 _CGAPI BEUnrollCount( uint_32 unroll_count ) +/*******************************************************/ { #ifdef DEVBUILD - unsigned_32 retn; + uint_32 retn; EchoAPI( "BEUnrollCount( %i )", unroll_count ); retn = BGUnrollCount( unroll_count ); return EchoAPIIntReturn( retn ); @@ -405,8 +405,8 @@ cg_name _CGAPI CGPatchNode( patch_handle patch, cg_type tipe ) #endif } -void _CGAPI BEPatchInteger( patch_handle patch, signed_32 value ) -/*******************************************************************/ +void _CGAPI BEPatchInteger( patch_handle patch, int_32 value ) +/****************************************************************/ { #ifdef DEVBUILD EchoAPI( "BEPatchInteger( %P, %x )\n", patch, value ); @@ -551,8 +551,8 @@ void _CGAPI BEFreeBack( back_handle bck ) /*% %%*/ /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ -void _CGAPI BEDefType( cg_type what, uint align, unsigned_32 len ) -/********************************************************************/ +void _CGAPI BEDefType( cg_type what, uint align, uint_32 len ) +/****************************************************************/ { #ifdef DEVBUILD EchoAPI( "BEDefType( %t, %x, %i )\n", what, align, len ); @@ -569,11 +569,11 @@ void _CGAPI BEAliasType( cg_type what, cg_type to ) TypeAlias( what, to ); } -unsigned_32 _CGAPI BETypeLength( cg_type tipe ) -/**************************************************/ +uint_32 _CGAPI BETypeLength( cg_type tipe ) +/**********************************************/ { #ifdef DEVBUILD - unsigned_32 retn; + uint_32 retn; EchoAPI( "BETypeLength( %t )\n", tipe ); retn = TypeLength( tipe) ; return EchoAPIIntReturn( retn ); @@ -708,8 +708,8 @@ cg_name _CGAPI CGVarargsBasePtr( cg_type tipe ) #endif } -cg_name _CGAPI CGInteger( signed_32 val, cg_type tipe ) -/*****************************************************/ +cg_name _CGAPI CGInteger( int_32 val, cg_type tipe ) +/**************************************************/ { #ifdef DEVBUILD cg_name retn; @@ -1207,8 +1207,8 @@ sel_handle _CGAPI CGSelInit( void ) #endif } -void _CGAPI CGSelCase( sel_handle s, label_handle lbl, signed_32 val ) -/************************************************************************/ +void _CGAPI CGSelCase( sel_handle s, label_handle lbl, int_32 val ) +/*********************************************************************/ { #ifdef DEVBUILD EchoAPI( "CGSelCase( %S, %L, %i )\n", s, lbl, val ); @@ -1218,9 +1218,9 @@ void _CGAPI CGSelCase( sel_handle s, label_handle lbl, signed_32 val ) BGSelCase( s, lbl, val ); } -void _CGAPI CGSelRange( sel_handle s, signed_32 lo, - signed_32 hi, label_handle lbl ) -/**********************************************************/ +void _CGAPI CGSelRange( sel_handle s, int_32 lo, + int_32 hi, label_handle lbl ) +/*******************************************************/ { #ifdef DEVBUILD EchoAPI( "CGSelRange( %S, %L, %i, %i )\n", s, lbl, lo, hi ); @@ -1434,7 +1434,7 @@ void _CGAPI DGLabel( back_handle bck ) } void _CGAPI DGBackPtr( back_handle bck, segment_id segid, - signed_32 offset, cg_type tipe ) + int_32 offset, cg_type tipe ) /***********************************************************/ { #ifdef DEVBUILD @@ -1446,8 +1446,8 @@ void _CGAPI DGBackPtr( back_handle bck, segment_id segid, BackPtr( bck, segid, offset, TypeAddress( tipe ) ); } -void _CGAPI DGFEPtr( cg_sym_handle sym, cg_type tipe, signed_32 offset ) -/**********************************************************************/ +void _CGAPI DGFEPtr( cg_sym_handle sym, cg_type tipe, int_32 offset ) +/*******************************************************************/ { #ifdef DEVBUILD EchoAPI( "DGFEPtr( %S, %t, %i )\n", sym, tipe, offset ); @@ -1456,8 +1456,8 @@ void _CGAPI DGFEPtr( cg_sym_handle sym, cg_type tipe, signed_32 offset ) FEPtr( sym, TypeAddress( tipe ), offset ); } -void _CGAPI DGBytes( unsigned_32 len, const void *src ) -/*********************************************************/ +void _CGAPI DGBytes( uint_32 len, const void *src ) +/*****************************************************/ { #ifdef DEVBUILD EchoAPI( "DGBytes( %x, %x )\n", len, src ); @@ -1466,8 +1466,8 @@ void _CGAPI DGBytes( unsigned_32 len, const void *src ) DataBytes( len, src ); } -void _CGAPI DGInteger( unsigned_32 value, cg_type tipe ) -/**********************************************************/ +void _CGAPI DGInteger( uint_32 value, cg_type tipe ) +/******************************************************/ { type_length len; int i; @@ -1503,7 +1503,7 @@ void _CGAPI DGInteger64( unsigned_64 value, cg_type tipe ) { type_length len; union{ - unsigned_32 vall; + uint_32 vall; unsigned_64 val; byte buff[8]; } data; @@ -1551,8 +1551,8 @@ void _CGAPI DGFloat( cchar_ptr value, cg_type tipe ) DGBytes( TypeLength( tipe ), &buff ); } -void _CGAPI DGIBytes( unsigned_32 len, byte pat ) -/***************************************************/ +void _CGAPI DGIBytes( uint_32 len, byte pat ) +/***********************************************/ { #ifdef DEVBUILD EchoAPI( "DGIBytes( %x, %x )\n", len, pat ); @@ -1622,8 +1622,8 @@ void _CGAPI DGString( cchar_ptr value, uint len ) #endif } -void _CGAPI DGUBytes( unsigned_32 len ) -/*****************************************/ +void _CGAPI DGUBytes( uint_32 len ) +/*************************************/ { #ifdef DEVBUILD EchoAPI( "DGUBytes( %x )\n", len ); @@ -1643,8 +1643,8 @@ void _CGAPI DGAlign( uint align ) } -unsigned_32 _CGAPI DGSeek( unsigned_32 where ) -/*********************************************/ +uint_32 _CGAPI DGSeek( uint_32 where ) +/*************************************/ { uint old; @@ -1663,11 +1663,11 @@ unsigned_32 _CGAPI DGSeek( unsigned_32 where ) #endif } -unsigned_32 _CGAPI DGTell( void ) -/************************************/ +uint_32 _CGAPI DGTell( void ) +/********************************/ { #ifdef DEVBUILD - unsigned_32 retn; + uint_32 retn; EchoAPI( "DGTell()" ); retn = AskLocation(); @@ -1678,11 +1678,11 @@ unsigned_32 _CGAPI DGTell( void ) } -unsigned_32 _CGAPI DGBackTell( back_handle bck ) -/***************************************************/ +uint_32 _CGAPI DGBackTell( back_handle bck ) +/***********************************************/ { #ifdef DEVBUILD - unsigned_32 retn; + uint_32 retn; EchoAPI( "DGBackTell( %B )", bck ); #endif @@ -1857,8 +1857,8 @@ float_handle _CGAPI BFCnvUF( uint data ) return( CFCnvUF( data ) ); } -signed_32 _CGAPI BFCnvF32( float_handle f ) -/************************************************/ +int_32 _CGAPI BFCnvF32( float_handle f ) +/*********************************************/ { return( CFCnvF32( f ) ); } diff --git a/bld/cg/c/loopopts.c b/bld/cg/c/loopopts.c index 6999cd6c1e..8a0e1d6ef9 100644 --- a/bld/cg/c/loopopts.c +++ b/bld/cg/c/loopopts.c @@ -888,8 +888,8 @@ static invariant *CopyInvariant( invariant *invar ) } -static void MulInvariant( invariant *invar, signed_32 by ) -/************************************************************* +static void MulInvariant( invariant *invar, int_32 by ) +/********************************************************** * Multiply all entries in invariant list "invar" by "by" */ { @@ -1026,10 +1026,10 @@ static induction *AddIndVar( instruction *ins, invariant *invar, name *ivtimes, invar_id lasttimes, - signed_32 times, - signed_32 plus, - signed_32 plus2, - signed_32 iv_mult, + int_32 times, + int_32 plus, + int_32 plus2, + int_32 iv_mult, type_class_def type_class ) /**************************************************************** * Add an induction variable to our list of induction variables for the @@ -1295,11 +1295,11 @@ static void CheckNonBasic( instruction *ins, induction *var, * constants and fold. */ { - signed_32 plus; - signed_32 plus2; - signed_32 times; - signed_32 c; - signed_32 mul; + int_32 plus; + int_32 plus2; + int_32 times; + int_32 c; + int_32 mul; invariant *invar; name *ivtimes; invar_id lasttimes; @@ -1376,9 +1376,9 @@ static void CheckInvariant( instruction *ins, induction *var, * the instruction. */ { - signed_32 plus; - signed_32 plus2; - signed_32 times; + int_32 plus; + int_32 plus2; + int_32 times; int iv_mult; invariant *invar; name *ivtimes; @@ -1869,9 +1869,9 @@ static name *FindPointerPart( induction *var ) } -static instruction *Multiply( name *op, signed_32 by, name *temp, - type_class_def type_class, instruction *prev ) -/***************************************************************************** +static instruction *Multiply( name *op, int_32 by, name *temp, + type_class_def type_class, instruction *prev ) +/************************************************************************* * Generate "optimal" code for op*by => temp and suffix instruction * "prev" with it. Return a pointer to the last instruction generated. */ @@ -1907,8 +1907,8 @@ static instruction *Multiply( name *op, signed_32 by, name *temp, static instruction *MakeMul( instruction *prev, - name *op, signed_32 by, name *ivtimes ) -/************************************************************************** + name *op, int_32 by, name *ivtimes ) +/********************************************************************* * Generate "optimal" instruction calcualte "op" * "by" * "ivtimes" and * place them after "prev". Return a pointer to the last instruction * generated. @@ -2277,7 +2277,7 @@ void MoveDownLoop( block *cond ) static void AdjustOp( instruction *blk_end, name **pop, - name *var, signed_32 adjust ) + name *var, int_32 adjust ) /***************************************************************/ { name *op; @@ -2298,7 +2298,7 @@ static void AdjustOp( instruction *blk_end, name **pop, instruction *DupIns( instruction *blk_end, instruction *ins, - name *var, signed_32 adjust ) + name *var, int_32 adjust ) /**************************************************************/ { instruction *new; @@ -2327,7 +2327,7 @@ instruction *DupIns( instruction *blk_end, instruction *ins, instruction *DupInstrs( instruction *blk_end, instruction *first, instruction *last, - induction *var, signed_32 adjust ) + induction *var, int_32 adjust ) /****************************************************************/ { instruction *ins; @@ -2348,16 +2348,16 @@ instruction *DupInstrs( instruction *blk_end, static bool BlueMoonUnRoll( block *cond_blk, induction *var, instruction *cond, instruction *indins, block_edge *exit_edge, bool know_bounds, - signed_32 initial, signed_32 final ) + int_32 initial, int_32 final ) /***************************************************************/ { instruction *first; instruction *last; instruction *ins; instruction *blk_end; - signed_32 iterations; + int_32 iterations; int i; - signed_32 adjust; + int_32 adjust; int unroll_count; int remainder; int num_instrs; @@ -2574,8 +2574,8 @@ bool AnalyseLoop( induction *var, bool *ponecond, } -static signed_32 Sgn( signed_32 x ) -/****************************************/ +static int_32 Sgn( int_32 x ) +/*********************************/ { if( x < 0 ) return( -1 ); @@ -2583,8 +2583,8 @@ static signed_32 Sgn( signed_32 x ) } -static signed_32 Abs( signed_32 x ) -/****************************************/ +static int_32 Abs( int_32 x ) +/*********************************/ { if( x < 0 ) return( -x ); @@ -2629,20 +2629,20 @@ static name *InitialValue( name *op ) bool CalcFinalValue( induction *var, block *blk, instruction *ins, - signed_32 *final, signed_32 *initial ) + int_32 *final, int_32 *initial ) /********************************************************************* * See if we can figure out what the final value of induction variable * "var" will be, based on the facts that instruction "ins" (in block * "blk") is the only exit from "Loop". */ { - name *temp; - name *op; - signed_32 init; - signed_32 test; - signed_32 incr; - signed_32 remd; - signed_32 dist; + name *temp; + name *op; + int_32 init; + int_32 test; + int_32 incr; + int_32 remd; + int_32 dist; if( _IsV( var, IV_DEAD ) ) return( false ); @@ -2747,8 +2747,8 @@ static bool FinalValue( instruction *ins, block *blk, induction *var ) { instruction *other; name *op; - signed_32 final; - signed_32 initial; + int_32 final; + int_32 initial; type_class_def type_class; block *dest; @@ -3395,8 +3395,8 @@ static bool TwistLoop( block_list *header_list, bool unroll ) block_edge *exit_edge; block_edge *loop_edge; bool onecond; - signed_32 final; - signed_32 initial; + int_32 final; + int_32 initial; induction *var; block_edge *edge; bool know_bounds; diff --git a/bld/cg/c/multiply.c b/bld/cg/c/multiply.c index 7aca370776..a071fb8d2c 100644 --- a/bld/cg/c/multiply.c +++ b/bld/cg/c/multiply.c @@ -57,15 +57,15 @@ typedef struct op { static op Ops[MAXOPS]; -static int Factor( unsigned_32 num, int *cost ) -/**************************************************/ +static int Factor( uint_32 num, int *cost ) +/**********************************************/ { int shlcnt; int i; int j; unsigned num_oprs; - unsigned_32 test; - unsigned_32 pow2; + uint_32 test; + uint_32 pow2; *cost = 0; i = MAXOPS; @@ -174,7 +174,7 @@ static int Factor( unsigned_32 num, int *cost ) static instruction *CheckMul( instruction *ins ) /***************************************************/ { - signed_32 rhs; + int_32 rhs; int i; bool neg; instruction *new_ins; diff --git a/bld/cg/c/namelist.c b/bld/cg/c/namelist.c index 5138acb225..f5cd903e56 100644 --- a/bld/cg/c/namelist.c +++ b/bld/cg/c/namelist.c @@ -93,8 +93,8 @@ static name *AllocName( name_class_def class, type_class_def type_class, type_le return( new ); } -static name *findConst64( unsigned_32 low, unsigned_32 high, float_handle cf_value ) -/**********************************************************************************/ +static name *findConst64( uint_32 low, uint_32 high, float_handle cf_value ) +/**************************************************************************/ { name *new_c; name **last; @@ -135,7 +135,7 @@ name *AllocConst( float_handle cf_value ) { name *new_c; name **last; - signed_32 int_value; + int_32 int_value; int test; int_value = CFCnvF32( cf_value ); @@ -214,8 +214,8 @@ name *AllocAddrConst( name *value, int seg, constant_type_class const_type, t } -name *FindIntValue( signed_32 value ) -/**************************************/ +name *FindIntValue( int_32 value ) +/***********************************/ { if( value == 0 && ConstZero != NULL ) return( ConstZero ); @@ -249,8 +249,8 @@ name *AllocUIntConst( uint value ) } -name *AllocS32Const( signed_32 value ) -/***************************************/ +name *AllocS32Const( int_32 value ) +/************************************/ { name *konst; @@ -260,8 +260,8 @@ name *AllocS32Const( signed_32 value ) return( AllocConst( CFCnvI32F( value ) ) ); } -name *AllocU32Const( unsigned_32 value ) -/*****************************************/ +name *AllocU32Const( uint_32 value ) +/*************************************/ { name *konst; @@ -271,8 +271,8 @@ name *AllocU32Const( unsigned_32 value ) return( AllocConst( CFCnvU32F( value ) ) ); } -name *AllocS64Const( unsigned_32 low, unsigned_32 high ) -/*********************************************************/ +name *AllocS64Const( uint_32 low, uint_32 high ) +/*************************************************/ { name *new_c; float_handle cf_value = CFCnvI64F( low, high ); @@ -291,8 +291,8 @@ name *AllocS64Const( unsigned_32 low, unsigned_32 high ) return( new_c ); } -name *AllocU64Const( unsigned_32 low, unsigned_32 high ) -/*********************************************************/ +name *AllocU64Const( uint_32 low, uint_32 high ) +/*************************************************/ { name *new_c; float_handle cf_value = CFCnvU64F( low, high ); diff --git a/bld/cg/c/patch.c b/bld/cg/c/patch.c index 5a8a6be234..dde9ae374b 100644 --- a/bld/cg/c/patch.c +++ b/bld/cg/c/patch.c @@ -84,7 +84,7 @@ cg_name BGPatchNode( patch_handle patch, type_def *tipe ) return( patch->u.node ); } -void BGPatchInteger( patch_handle patch, signed_32 value ) +void BGPatchInteger( patch_handle patch, int_32 value ) { tn node; name *c; diff --git a/bld/cg/c/peepopt.c b/bld/cg/c/peepopt.c index 3c6024f362..d763b6d0a2 100644 --- a/bld/cg/c/peepopt.c +++ b/bld/cg/c/peepopt.c @@ -76,8 +76,8 @@ static void InsReset( instruction *ins ) } } -static bool MergeTwo( instruction *a, instruction *b, signed_32 value ) -/*************************************************************************/ +static bool MergeTwo( instruction *a, instruction *b, int_32 value ) +/**********************************************************************/ { name *cons; name *old_res_a; @@ -192,7 +192,7 @@ static TWO_OP AndOr; static bool AndOr( instruction *and_ins, instruction *or_ins ) /************************************************************/ { - signed_32 new_and; + int_32 new_and; name *mask; if( and_ins->operands[0] != and_ins->result ) @@ -215,9 +215,9 @@ static TWO_OP OrAnd; static bool OrAnd( instruction *or_ins, instruction *and_ins ) /************************************************************/ { - signed_32 new_or; - signed_32 or; - signed_32 and; + int_32 new_or; + int_32 or; + int_32 and; name *mask; if( or_ins->operands[0] != or_ins->result ) @@ -252,7 +252,7 @@ static THREE_OP OrAndOr; static bool OrAndOr( instruction *a, instruction *b ) /***************************************************/ { - signed_32 and_val; + int_32 and_val; name *mask; if( a->result != b->result ) @@ -283,7 +283,7 @@ static THREE_OP AndOrAnd; static bool AndOrAnd( instruction *a, instruction *b ) /****************************************************/ { - signed_32 or_val; + int_32 or_val; name *mask; if( a->result != b->result ) diff --git a/bld/cg/c/propind.c b/bld/cg/c/propind.c index 0926f637fd..a55bb36d5d 100644 --- a/bld/cg/c/propind.c +++ b/bld/cg/c/propind.c @@ -78,8 +78,9 @@ static byte NumRefs( instruction *ins, name *op ) { return( refs ); } -static bool Adjusted( name **pop, name *res, signed_32 c ) { -/*************************************************************/ +static bool Adjusted( name **pop, name *res, int_32 c ) +/*********************************************************/ +{ name *op; op = *pop; @@ -94,11 +95,12 @@ static bool Adjusted( name **pop, name *res, signed_32 c ) { } -static bool AdjustIndex( instruction *ins, name *res, signed_32 c ) { -/************************************************************************ +static bool AdjustIndex( instruction *ins, name *res, int_32 c ) +/******************************************************************* If any operands or results of ins refer to res in an index, adjust the constant by the given amount and return true. */ +{ opcnt i; if( NumRefs( ins, res ) != 1 ) diff --git a/bld/cg/c/regalloc.c b/bld/cg/c/regalloc.c index ffeaf02f6a..020509c00b 100644 --- a/bld/cg/c/regalloc.c +++ b/bld/cg/c/regalloc.c @@ -413,7 +413,7 @@ static void BitOff( conflict_node *conf ) } -static signed_32 CountRegMoves( conflict_node *conf, +static int_32 CountRegMoves( conflict_node *conf, hw_reg_set reg, reg_tree *tree, int levels ) /******************************************** @@ -427,7 +427,7 @@ static signed_32 CountRegMoves( conflict_node *conf, block *blk; instruction *ins; instruction *last; - signed_32 count; + int_32 count; int half; name *reg_name; name *op1; diff --git a/bld/cg/c/scinfo.c b/bld/cg/c/scinfo.c index b5aac7974b..4ea7cef0b6 100644 --- a/bld/cg/c/scinfo.c +++ b/bld/cg/c/scinfo.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -293,10 +293,10 @@ void ScoreInfo( score_info *info, name *op ) /* FIXME: not sure what to do here */ if( op->c.value != NULL ) { info->symbol.p = &HighAddrSymbol; - info->offset = (signed_32)(pointer_uint)op->c.value; + info->offset = (int_32)(pointer_uint)op->c.value; } else { info->symbol.p = &HighAddrConst; - info->offset = (signed_32)op->c.lo.int_value; + info->offset = (int_32)op->c.lo.int_value; } break; default: diff --git a/bld/cg/c/split.c b/bld/cg/c/split.c index 06f334b29f..8b862d0778 100644 --- a/bld/cg/c/split.c +++ b/bld/cg/c/split.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2018 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -184,8 +184,8 @@ hw_reg_set ZapReg( instruction *ins ) return( *list ); } -instruction *MoveConst( unsigned_32 value, name *result, type_class_def type_class ) -/**********************************************************************************/ +instruction *MoveConst( uint_32 value, name *result, type_class_def type_class ) +/******************************************************************************/ { return( MakeMove( AllocConst( CFCnvU32F( value ) ), result, type_class ) ); } @@ -430,7 +430,7 @@ instruction *rUSEREGISTER( instruction *ins ) instruction *rCHANGESHIFT( instruction *ins ) /************************************************/ { - signed_32 shift_count; + int_32 shift_count; shift_count = ins->operands[1]->c.lo.int_value; assert( shift_count >= 0 ); @@ -442,9 +442,9 @@ instruction *rCHANGESHIFT( instruction *ins ) instruction *rFIXSHIFT( instruction *ins ) /*********************************************/ { - instruction *new_ins; + instruction *new_ins; #ifdef DEVBUILD - signed_32 shift_count; + int_32 shift_count; #endif /* Fix up shift instructions that try to shift by too large amounts. This @@ -500,7 +500,7 @@ instruction *rCLRHI_R( instruction *ins ) type_class_def type_class; hw_reg_set high; name *res; - signed_32 value; + int_32 value; type_class_def half_type_class; name *op; diff --git a/bld/cg/c/stubutil.c b/bld/cg/c/stubutil.c index ea213f4829..fc6d6d38b4 100644 --- a/bld/cg/c/stubutil.c +++ b/bld/cg/c/stubutil.c @@ -108,8 +108,8 @@ char *DoIToHS( char * buff, int buff_len, int i ) return( buff ); } -char *DoIToS( char * buff, int buff_len, signed_32 i ) -//======================================================= +char *DoIToS( char * buff, int buff_len, int_32 i ) +//==================================================== { char *p; bool neg; @@ -154,7 +154,7 @@ void PutFmt( int out, const char *str, va_list args ) } break; case 'l': - str2 = DoIToS( buff, 79, va_arg( args, signed_32 ) ); + str2 = DoIToS( buff, 79, va_arg( args, int_32 ) ); while( *str2 ) { FPut( out, str2++, 1 ); } @@ -309,8 +309,8 @@ char *FtnTipe( dbg_ftn_type tipe ) return( NULL ); } -char *LToS( signed_32 i ) -//========================== +char *LToS( int_32 i ) +//======================= { return( DoIToS( UBuff, UBUFF_LEN, i ) ); } diff --git a/bld/cg/c/tree.c b/bld/cg/c/tree.c index bef4b2a9a9..6a0cc4eb87 100644 --- a/bld/cg/c/tree.c +++ b/bld/cg/c/tree.c @@ -399,8 +399,8 @@ tn TGCompare( cg_op op, tn left, tn rite, type_def *tipe ) } -static an Int( unsigned_32 num ) -/********************************* +static an Int( uint_32 num ) +/***************************** * return an address name for an integer */ { @@ -416,18 +416,18 @@ static an Int64( unsigned_64 num ) return( BGInt64( num, TypeLongLongInteger ) ); } -unsigned_32 TGMask32( tn node ) -/***************************************** +uint_32 TGMask32( tn node ) +/***************************** * return a mask of 1's in the positions a bit field occupies. */ { - unsigned_32 mask; - uint len; - unsigned_32 bit; + uint_32 mask; + uint len; + uint_32 bit; len = node->u2.b.len; mask = 0; - bit = (unsigned_32)1 << node->u2.b.start; + bit = (uint_32)1 << node->u2.b.start; for( ;; ) { mask |= bit; bit <<= 1; @@ -1840,8 +1840,8 @@ static an TNBitOpGets( tn node, type_def *tipe, bool yield_before_op ) FreeTreeNode( lhs ); U64ShiftR( &mask, shift, &shiftmask ); // shiftmask = mask >> shift; if( after_value->format == NF_CONS && after_value->class == CL_CONS2 ) { - retv = Int( shiftmask.u._32[I64LO32] & (unsigned_32)after_value->u.n.name->c.lo.int_value ); - if( (unsigned_32)retv->u.n.name->c.lo.int_value != shiftmask.u._32[I64LO32] ) { + retv = Int( shiftmask.u._32[I64LO32] & (uint_32)after_value->u.n.name->c.lo.int_value ); + if( (uint_32)retv->u.n.name->c.lo.int_value != shiftmask.u._32[I64LO32] ) { DoAnd( left, mask, node ); } if( retv->u.n.name->c.lo.int_value != 0 ) { @@ -1938,7 +1938,7 @@ static an TNBitAssign( tn node ) an retv; tn lhs; tn rhs; - unsigned_32 mask; + uint_32 mask; lhs = node->u.left; rhs = node->u2.t.rite; diff --git a/bld/cg/c/treefold.c b/bld/cg/c/treefold.c index a85eae6b34..068f69aea2 100644 --- a/bld/cg/c/treefold.c +++ b/bld/cg/c/treefold.c @@ -50,8 +50,8 @@ #define HasBigConst( t ) ( ( (t)->attr & TYPE_FLOAT ) || (t)->length == 8 ) typedef union i32 { - signed_32 s; - unsigned_32 u; + int_32 s; + uint_32 u; } i32; static cg_op RevOpcode[] = { @@ -198,10 +198,10 @@ static cmp_result CheckCmpRange( cg_op op, int op_type, float_handle val ) return( ret ); } -static signed_32 CFConvertByType( float_handle cf, type_def *tipe ) -/*****************************************************************/ +static int_32 CFConvertByType( float_handle cf, type_def *tipe ) +/**************************************************************/ { - signed_32 data; + int_32 data; data = CFCnvF32( cf ); switch( tipe->length ) { @@ -214,9 +214,9 @@ static signed_32 CFConvertByType( float_handle cf, type_def *tipe ) break; case 2: if( tipe->attr & TYPE_SIGNED ) { - data = (signed_16)data; + data = (int_16)data; } else { - data = (unsigned_16)data; + data = (uint_16)data; } break; } @@ -244,10 +244,10 @@ static float_handle IntToCF( signed_64 value, type_def *tipe ) { signed_8 s8; unsigned_8 u8; - signed_16 s16; - unsigned_16 u16; - signed_32 s32; - unsigned_32 u32; + int_16 s16; + uint_16 u16; + int_32 s32; + uint_32 u32; if( tipe->attr & TYPE_SIGNED ) { switch( tipe->length ) { @@ -288,8 +288,8 @@ static float_handle IntToCF( signed_64 value, type_def *tipe ) } } -static tn IntToType( signed_32 value, type_def *tipe ) -/**********************************************************/ +static tn IntToType( int_32 value, type_def *tipe ) +/*******************************************************/ { signed_64 temp; @@ -321,11 +321,11 @@ static tn CFToType( float_handle cf, type_def *tipe ) -int GetLog2( unsigned_32 value ) -/******************************************/ +int GetLog2( uint_32 value ) +/******************************/ { - unsigned_32 count; - int log; + uint_32 count; + int log; if( _IsPowerOfTwo( value ) && value != 0 ) { log = 0; @@ -350,8 +350,8 @@ tn FoldTimes( tn left, tn rite, type_def *tipe ) int log; float_handle lv; float_handle rv; - unsigned_32 li; - unsigned_32 ri; + uint_32 li; + uint_32 ri; if( left->class == TN_CONS ) { temp = left; @@ -458,8 +458,8 @@ tn FoldMinus( tn left, tn rite, type_def *tipe ) tn fold; float_handle lv; float_handle rv; - unsigned_32 li; - unsigned_32 ri; + uint_32 li; + uint_32 ri; fold = NULL; if( left->class == TN_CONS ) { @@ -515,8 +515,8 @@ tn FoldPlus( tn left, tn rite, type_def *tipe ) tn temp; float_handle lv; float_handle rv; - unsigned_32 li; - unsigned_32 ri; + uint_32 li; + uint_32 ri; if( left->class == TN_CONS ) { temp = left; @@ -625,7 +625,7 @@ tn FoldAnd( tn left, tn rite, type_def *tipe ) lv = left->u.name->c.value; rv = rite->u.name->c.value; if( CFIs32( lv ) && CFIs32( rv ) ) { - unsigned_32 and; + uint_32 and; and = CFConvertByType( rv, tipe ) & CFConvertByType( lv, tipe ); fold = IntToType( and, tipe ); @@ -677,7 +677,7 @@ tn FoldOr( tn left, tn rite, type_def *tipe ) lv = left->u.name->c.value; rv = rite->u.name->c.value; if( CFIs32( lv ) && CFIs32( rv ) ) { - unsigned_32 or; + uint_32 or; or = CFConvertByType( rv, tipe ) | CFConvertByType( lv, tipe ); fold = IntToType( or, tipe ); @@ -729,8 +729,8 @@ tn FoldXor( tn left, tn rite, type_def *tipe ) lv = left->u.name->c.value; rv = rite->u.name->c.value; if( CFIs32( lv ) && CFIs32( rv ) ) { - unsigned_32 li; - unsigned_32 ri; + uint_32 li; + uint_32 ri; li = CFConvertByType( lv, tipe ); ri = CFConvertByType( rv, tipe ); @@ -772,7 +772,7 @@ tn FoldRShift( tn left, tn rite, type_def *tipe ) tn fold; float_handle rv; float_handle lv; - signed_32 ri; + int_32 ri; fold = NULL; if( rite->class == TN_CONS ) { @@ -794,14 +794,14 @@ tn FoldRShift( tn left, tn rite, type_def *tipe ) if( !done ) { lv = left->u.name->c.value; if( !HasBigConst( tipe ) && CFIs32( lv ) && CFIs32( rv ) ) { - signed_32 li; - unsigned_32 shft; + int_32 li; + uint_32 shft; li = CFConvertByType( lv, tipe ); if( tipe->attr & TYPE_SIGNED ) { shft = li >> ri; } else { - shft = (unsigned_32)li >> (unsigned_32)ri; + shft = (uint_32)li >> (uint_32)ri; } fold = IntToType( shft, tipe ); } else if( CFIs64( lv ) && CFIs64( rv ) ) { @@ -838,7 +838,7 @@ tn FoldLShift( tn left, tn rite, type_def *tipe ) tn fold; float_handle rv; float_handle lv; - signed_32 ri; + int_32 ri; fold = NULL; ri = 0; @@ -856,7 +856,7 @@ tn FoldLShift( tn left, tn rite, type_def *tipe ) } else { lv = left->u.name->c.value; if( !HasBigConst( tipe ) && CFIs32( lv ) && CFIs32( rv ) ) { - signed_32 li; + int_32 li; li = CFConvertByType( lv, tipe ); fold = IntToType( li << ri, tipe ); @@ -936,8 +936,8 @@ tn FoldDiv( tn left, tn rite, type_def *tipe ) lv = left->u.name->c.value; if( tipe->attr & TYPE_SIGNED ) { if( CFIsI32( lv ) && CFIsI32( rv ) ) { - signed_32 li; - signed_32 ri; + int_32 li; + int_32 ri; li = CFConvertByType( lv, tipe ); ri = CFConvertByType( rv, tipe ); @@ -947,8 +947,8 @@ tn FoldDiv( tn left, tn rite, type_def *tipe ) } } else { if( CFIsU32( lv ) && CFIsU32( rv ) ) { - unsigned_32 li; - unsigned_32 ri; + uint_32 li; + uint_32 ri; li = CFCnvF32( lv ); ri = CFCnvF32( rv ); @@ -1013,8 +1013,8 @@ tn FoldMod( tn left, tn rite, type_def *tipe ) } else { if( tipe->attr & TYPE_SIGNED ) { if( CFIsI32( lv ) && CFIsI32( rv ) ) { - signed_32 ri; - signed_32 li; + int_32 ri; + int_32 li; li = CFConvertByType( lv, tipe ); ri = CFConvertByType( rv, tipe ); @@ -1024,8 +1024,8 @@ tn FoldMod( tn left, tn rite, type_def *tipe ) } } else { if( CFIsU32( lv ) && CFIsU32( rv ) ) { - unsigned_32 ri; - unsigned_32 li; + uint_32 ri; + uint_32 li; li = CFConvertByType( lv, tipe ); ri = CFConvertByType( rv, tipe ); @@ -1043,7 +1043,7 @@ tn FoldMod( tn left, tn rite, type_def *tipe ) } else if( !HasBigConst( tipe ) ) { if( ( left->tipe->attr & TYPE_SIGNED ) == 0 ) { if( CFIsU32( rv ) ) { - unsigned_32 ri = CFConvertByType( rv, tipe ); + uint_32 ri = CFConvertByType( rv, tipe ); log = GetLog2( ri ); if( log != -1 ) { fold = TGBinary( O_AND, left, IntToType( ri - 1, tipe ), tipe ); @@ -1059,7 +1059,7 @@ tn FoldMod( tn left, tn rite, type_def *tipe ) t2 = t & (rv - 1); fold = (t2 ^ b) - b; */ - signed_32 ri = CFConvertByType( rv, tipe ); + int_32 ri = CFConvertByType( rv, tipe ); if( ri < 0 ) /* sign of constant doesn't matter */ ri = -ri; log = GetLog2( ri ); @@ -1264,9 +1264,9 @@ tn FoldFlNot( tn left ) tn FoldBitCompare( cg_op op, tn left, tn rite ) /**********************************************************/ { - tn fold; - unsigned_32 new_cons; - unsigned_32 mask; + tn fold; + uint_32 new_cons; + uint_32 mask; if( left->class == TN_CONS ) { fold = left; @@ -1534,9 +1534,9 @@ tn FoldPostGetsCompare( cg_op op, tn left, tn rite, type_def *tipe ) { // tn compare; tn temp; - signed_32 ri; - signed_32 li; - signed_32 value; + int_32 ri; + int_32 li; + int_32 value; float_handle rv; float_handle lv; diff --git a/bld/cg/c/u32moddi.c b/bld/cg/c/u32moddi.c index ea051cdf1a..d0f4e84fc5 100644 --- a/bld/cg/c/u32moddi.c +++ b/bld/cg/c/u32moddi.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2018 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -35,10 +35,10 @@ #include "u32moddi.h" -unsigned_32 U32ModDiv( unsigned_32 *x, unsigned_32 y ) -/********************************************************/ +uint_32 U32ModDiv( uint_32 *x, uint_32 y ) +/********************************************/ { - unsigned_32 rem; + uint_32 rem; rem = *x % y; *x /= y; diff --git a/bld/cg/c/unroll.c b/bld/cg/c/unroll.c index 7586a93b44..666da0d7a9 100644 --- a/bld/cg/c/unroll.c +++ b/bld/cg/c/unroll.c @@ -280,13 +280,13 @@ static void UnMarkHeaderEdges( block *loop ) #define MAX_CODE_SIZE 0x20 #define UNROLL_MAX 0x20 -static signed_32 UnrollCount( block *loop_tail, bool *clean, bool *complete ) -/*********************************************************************************** +static int_32 UnrollCount( block *loop_tail, bool *clean, bool *complete ) +/*************************************************************************** * Figure out how many times we want to unroll the given loop. */ { - signed_32 num_ins; - signed_32 unroll_count; + int_32 num_ins; + int_32 unroll_count; block *blk; /* @@ -373,7 +373,7 @@ static bool ReplaceName( name **pop, name *orig, name *new ) } static void ReplaceInductionVars( block *loop, instruction *ins_list, - signed_32 scale ) + int_32 scale ) /******************************************************* * Replace all occurrences of an induction var in the loop with a new * temp, and add an instruction to initialize that temp onto the ins_list. @@ -390,7 +390,7 @@ static void ReplaceInductionVars( block *loop, instruction *ins_list, instruction *new_ins; block *blk; opcnt i; - signed_32 adjust; + int_32 adjust; for( ind = IndVarList; ind != NULL; ind = ind->next ) { if( _IsV( ind, IV_DEAD ) ) @@ -466,12 +466,12 @@ static void ChainTwoLoops( loop_abstract *first, loop_abstract *last ) last->head->u.loop = first->tail; } -static block *DoUnroll( block *tail, signed_32 reps, bool replace_vars ) -/************************************************************************** +static block *DoUnroll( block *tail, int_32 reps, bool replace_vars ) +/*********************************************************************** * Unroll the given loop (this is the tail block, and loop is connected * through blk->u.loop to the head, in which blk->u.loop == NULL) reps - * times (there will be reps + 1 copies of the loop body) and replace induction - * vars with new temps if replace_vars == true + * times (there will be reps + 1 copies of the loop body) and replace + * induction vars with new temps if replace_vars == true * All of the copies made will be connected through blk->u.loop, and a * pointer to the tail of the new super-loop will be returned. */ @@ -482,8 +482,8 @@ static block *DoUnroll( block *tail, signed_32 reps, bool replace_vars ) loop_abstract *first; loop_abstract *last; block *next_block; - signed_32 i; - signed_32 size; + int_32 i; + int_32 size; /* unused parameters */ (void)replace_vars; @@ -549,7 +549,7 @@ static bool TractableCond( loop_condition *cond ) { bool ok; induction *tmp; - signed_32 plus; + int_32 plus; // bool exit_true; byte opcode; name *n; @@ -950,8 +950,8 @@ static void MarkLoopHeader( block *loop, block *header ) * +---------------------------+ */ -static void MakeWorldGoAround( block *loop, loop_abstract *cleanup_copy, loop_condition *cond, signed_32 reps ) -/****************************************************************************************************************** +static void MakeWorldGoAround( block *loop, loop_abstract *cleanup_copy, loop_condition *cond, int_32 reps ) +/*************************************************************************************************************** * This functions lays out the code as given above, creating and linking in condition * blocks as needed. It then sorts the blocks into the given order, to make sure that nothing * screws up our lovely flow of control. @@ -963,7 +963,7 @@ static void MakeWorldGoAround( block *loop, loop_abstract *cleanup_copy, loo type_class_def comp_type_class; block *new; instruction *ins; - unsigned_32 high_bit; + uint_32 high_bit; comp_type_class = cond->compare_ins->type_class; temp = AllocTemp( comp_type_class ); @@ -1081,7 +1081,7 @@ bool UnRoll( void ) { loop_condition cond; block *last; - signed_32 unroll_count; + int_32 unroll_count; bool one_cond; loop_abstract cleanup_copy; diff --git a/bld/cg/h/bldins.h b/bld/cg/h/bldins.h index 9877c8b96e..de077937e1 100644 --- a/bld/cg/h/bldins.h +++ b/bld/cg/h/bldins.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -30,7 +31,7 @@ extern an BGVarargsBasePtr( type_def *tipe ); extern an BGStackValue( type_def *tipe ); -extern an BGInteger( signed_32 value, type_def *tipe ); +extern an BGInteger( int_32 value, type_def *tipe ); extern an BGInt64( signed_64 value, type_def *tipe ); extern an BGFloat( const char *value, type_def *tipe ); extern an BGName( cg_class cl, pointer sym, type_def *tipe ); @@ -49,7 +50,7 @@ extern void BGControl( cg_op op, an expr, label_handle lbl ); extern void BGGenCtrl( cg_op op, an expr, label_handle lbl, bool gen ); extern void BGBigLabel( back_handle bck ); extern void BGBigGoto( label_handle lbl, level_depth level ); -extern unsigned_32 BGUnrollCount( unsigned_32 unroll_count ); +extern uint_32 BGUnrollCount( uint_32 unroll_count ); extern an BGUnary( cg_op op, an left, type_def *tipe ); extern an BGBinary( cg_op op, an left, an rite, type_def *tipe, bool fold_addr ); extern an BGOpGets( cg_op op, an left, an rite, type_def *tipe, type_def *optipe ); diff --git a/bld/cg/h/bldsel.h b/bld/cg/h/bldsel.h index 77406dd5ea..e496bd0131 100644 --- a/bld/cg/h/bldsel.h +++ b/bld/cg/h/bldsel.h @@ -31,11 +31,11 @@ extern sel_handle BGSelInit( void ); -extern void BGSelCase( sel_handle s_node, label_handle label, signed_32 value ); -extern void BGSelRange( sel_handle s_node, signed_32 lo, signed_32 hi, label_handle label ); +extern void BGSelCase( sel_handle s_node, label_handle label, int_32 value ); +extern void BGSelRange( sel_handle s_node, int_32 lo, int_32 hi, label_handle label ); extern void BGSelOther( sel_handle s_node, label_handle other ); extern void BGSelect( sel_handle s_node, an node, cg_switch_type allowed ); -extern int SelCompare( signed_32 lo1, signed_32 lo2 ); -extern cg_type SelType( unsigned_32 value_range ); -extern signed_32 NumValues( select_list *list, signed_32 hi ); +extern int SelCompare( int_32 lo1, int_32 lo2 ); +extern cg_type SelType( uint_32 value_range ); +extern int_32 NumValues( select_list *list, int_32 hi ); extern void FreeTable( tbl_control *table ); diff --git a/bld/cg/h/bldselco.h b/bld/cg/h/bldselco.h index 61063f4fe2..c184775732 100644 --- a/bld/cg/h/bldselco.h +++ b/bld/cg/h/bldselco.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -29,14 +30,14 @@ ****************************************************************************/ -typedef signed_32 cost_val; +typedef int_32 cost_val; extern cost_val IfCost(sel_handle,int); extern name *ScanCall(tbl_control*,name*,type_class_def); extern cost_val JumpCost(sel_handle); extern cost_val ScanCost(sel_handle); -extern tbl_control *MakeScanTab(select_list *,signed_32,label_handle,cg_type,cg_type); -extern tbl_control *MakeJmpTab(select_list *,signed_32,signed_32,label_handle); +extern tbl_control *MakeScanTab(select_list *,int_32,label_handle,cg_type,cg_type); +extern tbl_control *MakeJmpTab(select_list *,int_32,int_32,label_handle); extern name *SelIdx(tbl_control *,an); extern type_def *SelNodeType(an,bool); extern void MkSelOp( name *idx, type_class_def type_class ); diff --git a/bld/cg/h/block.h b/bld/cg/h/block.h index e69ff75c03..9d184803b2 100644 --- a/bld/cg/h/block.h +++ b/bld/cg/h/block.h @@ -54,7 +54,7 @@ /* aligned */ #define MAX_INTERVAL_DEPTH 255U -typedef unsigned_32 block_flags; +typedef uint_32 block_flags; typedef enum { BLOCK_LABEL_DIES = 0x01, @@ -170,7 +170,7 @@ typedef struct block { block_num inputs; /* number of input edges */ block_num targets; /* number of target blocks */ block_class class; - signed_32 iterations; - unsigned_32 unroll_count; + int_32 iterations; + uint_32 unroll_count; struct block_edge edge[1]; } block; diff --git a/bld/cg/h/cg.h b/bld/cg/h/cg.h index dd740722a1..cb307868f7 100644 --- a/bld/cg/h/cg.h +++ b/bld/cg/h/cg.h @@ -102,14 +102,14 @@ typedef short segment_id; typedef int level_depth; -typedef unsigned_32 cg_linenum; +typedef uint_32 cg_linenum; typedef size_t objoffset; typedef size_t objhandle; #define INVALID_OBJHANDLE 0 /* symbolic debugging type handles */ -typedef unsigned_32 dbg_type; +typedef uint_32 dbg_type; typedef struct struct_list *dbg_struct; typedef struct array_list *dbg_array; typedef struct enum_list *dbg_enum; diff --git a/bld/cg/h/cgdll.h b/bld/cg/h/cgdll.h index 9cf51f3047..c47b9d6b16 100644 --- a/bld/cg/h/cgdll.h +++ b/bld/cg/h/cgdll.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -35,4 +36,4 @@ extern struct cg_interface * _CGDLLEXPORT BEDLLInit( struct fe_interface * ); extern void _CGDLLEXPORT BEDLLFini( struct cg_interface * ); -extern int __stdcall LibMain( unsigned_32 hdll, unsigned_32 reason, void *reserved ); +extern int __stdcall LibMain( uint_32 hdll, uint_32 reason, void *reserved ); diff --git a/bld/cg/h/cgstub.h b/bld/cg/h/cgstub.h index 227216a7b9..80c4ac574e 100644 --- a/bld/cg/h/cgstub.h +++ b/bld/cg/h/cgstub.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -76,7 +77,7 @@ typedef struct call_back { // call-back entry (pointed to by l field) typedef struct{ field_entry entry; union { - unsigned_32 off; + uint_32 off; dbg_loc loc; } u; uint attr; @@ -97,7 +98,7 @@ typedef struct{ typedef struct { field_entry entry; union { - unsigned_32 off; + uint_32 off; dbg_loc adjustor; } u; uint attr; @@ -108,7 +109,7 @@ typedef struct { typedef struct{ field_entry entry; union { - unsigned_32 off; + uint_32 off; dbg_loc loc; } u; uint attr; @@ -151,7 +152,7 @@ typedef struct struct_list { } struct_list; typedef struct const_entry { struct const_entry *next; - signed_32 val; + int_32 val; char *name; } const_entry; @@ -172,10 +173,10 @@ typedef struct{ }dim_var; typedef struct{ - dim_entry entry; - signed_32 lo; - signed_32 hi; - dbg_type idx; + dim_entry entry; + int_32 lo; + int_32 hi; + dbg_type idx; }dim_con; typedef union{ @@ -247,7 +248,7 @@ typedef struct b { struct b *n; sym s; l *lp; - unsigned_32 loc; + uint_32 loc; int i; } b; typedef struct t { @@ -268,9 +269,9 @@ typedef struct ic { } ic; typedef struct rh { struct rh *n; - signed_32 l; - signed_32 h; - l *lb; + int_32 l; + int_32 h; + l *lb; } rh; typedef struct sh { l *o; diff --git a/bld/cg/h/confldef.h b/bld/cg/h/confldef.h index 9060431795..b546440a5b 100644 --- a/bld/cg/h/confldef.h +++ b/bld/cg/h/confldef.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2017 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -34,7 +34,7 @@ #define MAX_SAVE 0xFFFFFFFF #define DEL_CONFLICT_SAVE 10 -typedef unsigned_32 save_def; +typedef uint_32 save_def; typedef enum { CST_CONF_IS_NEXT = 0x0001, diff --git a/bld/cg/h/cvtypes.h b/bld/cg/h/cvtypes.h index 0947bb743e..a55b8c2092 100644 --- a/bld/cg/h/cvtypes.h +++ b/bld/cg/h/cvtypes.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2017 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -36,15 +36,15 @@ extern dbg_type CVScalar( const char *name, cg_type tipe ); extern dbg_type CVScope( const char *name ); extern void CVDumpName( dbg_name name, dbg_type tipe ); extern void CVBackRefType( dbg_name name, dbg_type tipe ); -extern dbg_type CVCharBlock( unsigned_32 len ); +extern dbg_type CVCharBlock( uint_32 len ); extern dbg_type CVIndCharBlock( back_handle len, cg_type len_type, int off ); extern dbg_type CVLocCharBlock( dbg_loc loc, cg_type len_type ); extern dbg_type CVFtnArray( back_handle dims, cg_type lo_bound_tipe, cg_type num_elts_tipe, int off, dbg_type base ); extern dbg_type CVArray( dbg_type idx, dbg_type base ); -extern dbg_type CVIntArray( unsigned_32 hi, dbg_type base ); +extern dbg_type CVIntArray( uint_32 hi, dbg_type base ); extern dbg_type CVEndArray( dbg_array ar ); -extern dbg_type CVArraySize( offset size, unsigned_32 hi, dbg_type base ); -extern dbg_type CVSubRange( signed_32 lo, signed_32 hi, dbg_type base ); +extern dbg_type CVArraySize( offset size, uint_32 hi, dbg_type base ); +extern dbg_type CVSubRange( int_32 lo, int_32 hi, dbg_type base ); extern dbg_type CVDereference( cg_type ptr_type, dbg_type base ); extern dbg_type CVPtr( cg_type ptr_type, dbg_type base ); extern dbg_type CVBasedPtr( cg_type ptr_type, dbg_type base, dbg_loc loc_segment ); @@ -53,7 +53,7 @@ extern dbg_type CVEndEnum( dbg_enum en ); extern dbg_type CVEndProc( dbg_proc pr ); extern void CVPutStr( cv_out *, const char * ); -extern void CVPutINum( cv_out *out, signed_32 num ); +extern void CVPutINum( cv_out *out, int_32 num ); extern void CVPutINum64( cv_out *out, signed_64 num ); extern void CVPutNullStr( cv_out * ); extern void CVEndType( cv_out *out ); diff --git a/bld/cg/h/data.h b/bld/cg/h/data.h index d1b5ba2d2c..c33bcec983 100644 --- a/bld/cg/h/data.h +++ b/bld/cg/h/data.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2019 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -67,7 +67,7 @@ extern bool BlocksUnTrimmed; extern an AddrList; extern segment_id DbgLocals; extern segment_id DbgTypes; -extern unsigned_16 TypeIdx; // uint ??? +extern uint_16 TypeIdx; // uint ??? extern byte OptForSize; extern bool HaveLiveInfo; extern bool HaveDominatorInfo; diff --git a/bld/cg/h/dbbit.h b/bld/cg/h/dbbit.h index 3d757bd10d..c5a1e9f642 100644 --- a/bld/cg/h/dbbit.h +++ b/bld/cg/h/dbbit.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -30,7 +31,7 @@ typedef struct dbbit { - unsigned_16 st; - unsigned_16 base; - unsigned_32 off; + uint_16 st; + uint_16 base; + uint_32 off; } dbbit; diff --git a/bld/cg/h/dbsyms.h b/bld/cg/h/dbsyms.h index c6bf940e02..7fb4dd8b1b 100644 --- a/bld/cg/h/dbsyms.h +++ b/bld/cg/h/dbsyms.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -30,7 +30,7 @@ ****************************************************************************/ -typedef unsigned_32 cue_idx; +typedef uint_32 cue_idx; typedef struct cue_state{ cue_idx cue; @@ -61,8 +61,8 @@ typedef struct cue_ctl { /* filename to number mapping */ typedef struct fname_lst { - struct fname_lst *next; - unsigned_16 len; + struct fname_lst *next; + uint_16 len; char fname[1]; } fname_lst; diff --git a/bld/cg/h/dftypes.h b/bld/cg/h/dftypes.h index 79057f0807..9405779092 100644 --- a/bld/cg/h/dftypes.h +++ b/bld/cg/h/dftypes.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2017 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -36,15 +36,15 @@ extern dbg_type DFScope( const char *name ); extern char const *DFScopeName( dbg_type scope ); extern void DFDumpName( dbg_name name, dbg_type tipe ); extern void DFBackRefType( dbg_name name, dbg_type tipe ); -extern dbg_type DFCharBlock( unsigned_32 len ); -extern dbg_type DFCharBlockNamed( const char *name, unsigned_32 len ); +extern dbg_type DFCharBlock( uint_32 len ); +extern dbg_type DFCharBlockNamed( const char *name, uint_32 len ); extern dbg_type DFIndCharBlock( back_handle len, cg_type len_type, int off ); extern dbg_type DFLocCharBlock( dbg_loc loc, cg_type len_type ); extern dbg_type DFFtnArray( back_handle dims, cg_type lo_bound_tipe, cg_type num_elts_tipe, int off, dbg_type base ); extern dbg_type DFArray( dbg_type idx, dbg_type base ); -extern dbg_type DFIntArray( unsigned_32 hi, dbg_type base ); +extern dbg_type DFIntArray( uint_32 hi, dbg_type base ); extern dbg_type DFEndArray( dbg_array ar ); -extern dbg_type DFSubRange( signed_32 lo, signed_32 hi, dbg_type base ); +extern dbg_type DFSubRange( int_32 lo, int_32 hi, dbg_type base ); extern dbg_type DFDereference( cg_type ptr_type, dbg_type base ); extern dbg_type DFPtr( cg_type ptr_type, dbg_type base ); extern dbg_type DFBasedPtr( cg_type ptr_type, dbg_type base, dbg_loc loc_segment ); diff --git a/bld/cg/h/dumpio.h b/bld/cg/h/dumpio.h index 9c922172d1..4b3269d48b 100644 --- a/bld/cg/h/dumpio.h +++ b/bld/cg/h/dumpio.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -45,12 +46,12 @@ extern void DumpChar( char ); extern void DumpNL( void ); extern void DumpPtr( void *ptr ); extern void DumpInt( int ); -extern void DumpLong( signed_32 ); -extern void DumpLongLen( signed_32, int ); +extern void DumpLong( int_32 ); +extern void DumpLongLen( int_32, int ); extern void DumpUInt( unsigned ); -extern void DumpULong( unsigned_32 ); -extern void DumpULongLen( unsigned_32, int ); -extern void Dump8h( unsigned_32 ); +extern void DumpULong( uint_32 ); +extern void DumpULongLen( uint_32, int ); +extern void Dump8h( uint_32 ); extern void DumpByte( byte n ); extern void DumpId( unsigned ); diff --git a/bld/cg/h/encode.h b/bld/cg/h/encode.h index 472e78998f..1c3448795f 100644 --- a/bld/cg/h/encode.h +++ b/bld/cg/h/encode.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -35,7 +35,7 @@ extern void CodeLabel( label_handle, unsigned ); #if _TARGET_RISC extern void CodeLabelLinenum( label_handle label, unsigned align, cg_linenum line ); #endif -extern void CodeLineNumber( unsigned_32, bool ); +extern void CodeLineNumber( uint_32, bool ); extern void CodeHandle( oc_class, obj_length, label_handle ); extern obj_length OptInsSize( oc_class class, oc_dest_attr attr ); diff --git a/bld/cg/h/indvars.h b/bld/cg/h/indvars.h index 192bebc119..4a16ebdd58 100644 --- a/bld/cg/h/indvars.h +++ b/bld/cg/h/indvars.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -50,20 +51,20 @@ typedef enum { #define _ChkLoopUsage(x,b) (((x)->v.block_usage & (var_usage)(b)) != 0) #define _SetLoopUsage(x,b) ((x)->v.block_usage = (var_usage)(b)) -typedef signed_16 invar_id; +typedef int_16 invar_id; typedef struct invariant { /* an invariant list is */ - signed_32 times; /* + *times */ + int_32 times; /* + *times */ union name *name; /* this is */ struct invariant *next; /* ... add the next one */ invar_id id; } invariant; typedef struct induction { /* an induction variable is */ - signed_32 times; /* ( *times ) */ + int_32 times; /* ( *times ) */ union name *ivtimes; /* *ivtimes */ struct invariant *invar; /* +invariant_list[*ivtimes?] */ - signed_32 plus2; /* +plus2*ivtimes */ - signed_32 plus; /* .. +plus */ + int_32 plus2; /* +plus2*ivtimes */ + int_32 plus; /* .. +plus */ union name *name; /* this is */ struct induction *prev; /* link in list of induction vars */ struct induction *basic; /* this is */ diff --git a/bld/cg/h/inslist.h b/bld/cg/h/inslist.h index 119a710f9d..41a190353a 100644 --- a/bld/cg/h/inslist.h +++ b/bld/cg/h/inslist.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -40,7 +40,7 @@ typedef int instruction_id; #define MAX_INS_ID INT_MAX -typedef unsigned_32 source_line_number; +typedef uint_32 source_line_number; typedef byte opcnt; @@ -120,7 +120,7 @@ typedef struct instruction { instruction_id id; type_class_def type_class; type_class_def base_type_class; - unsigned_16 sequence; + uint_16 sequence; union { byte byte; bool bool_flag; diff --git a/bld/cg/h/loopopts.h b/bld/cg/h/loopopts.h index 029200d18d..0decab6a7f 100644 --- a/bld/cg/h/loopopts.h +++ b/bld/cg/h/loopopts.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -45,10 +46,10 @@ void FiniIndVars( void ); bool Inducable( block *blk, instruction *ins ); void SuffixPreHeader( instruction *ins ); void MoveDownLoop( block *cond ); -instruction *DupIns( instruction *blk_end, instruction *ins, name *var, signed_32 adjust ); -instruction *DupInstrs( instruction *blk_end, instruction *first, instruction *last, induction *var, signed_32 adjust ); +instruction *DupIns( instruction *blk_end, instruction *ins, name *var, int_32 adjust ); +instruction *DupInstrs( instruction *blk_end, instruction *first, instruction *last, induction *var, int_32 adjust ); bool AnalyseLoop( induction *var, bool *ponecond, instruction **pcond, block **pcond_blk ); -bool CalcFinalValue( induction *var, block *blk, instruction *ins, signed_32 *final, signed_32 *initial ); +bool CalcFinalValue( induction *var, block *blk, instruction *ins, int_32 *final, int_32 *initial ); bool LoopInvariant( void ); bool LoopRegInvariant( void ); void LoopEnregister( void ); diff --git a/bld/cg/h/multiply.h b/bld/cg/h/multiply.h index 26f4421d21..e6c4b6e940 100644 --- a/bld/cg/h/multiply.h +++ b/bld/cg/h/multiply.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2018 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -32,7 +32,7 @@ extern int SubCost( void ); extern int AddCost( void ); -extern int MulCost( unsigned_32 ); +extern int MulCost( uint_32 ); extern int ShiftCost( int ); extern void MulToShiftAdd( void ); diff --git a/bld/cg/h/name.h b/bld/cg/h/name.h index 0d40d78015..181781b073 100644 --- a/bld/cg/h/name.h +++ b/bld/cg/h/name.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -133,13 +134,13 @@ typedef struct var_name { typedef struct constant_defn { struct constant_defn *next_defn; pointer label; /* back end label for static */ - unsigned_16 value[4]; /* in internal format */ + uint_16 value[4]; /* in internal format */ type_class_def const_class; } constant_defn; typedef union value32 { - signed_32 int_value; - unsigned_32 uint_value; + int_32 int_value; + uint_32 uint_value; } value32; typedef struct const_name { @@ -171,7 +172,7 @@ typedef struct temp_name { } v; union { block_num block_id; /* AKA block_num */ - unsigned_16 ref_count; /* for counting references */ + uint_16 ref_count; /* for counting references */ } u; t_flags temp_flags; } temp_name; diff --git a/bld/cg/h/namelist.h b/bld/cg/h/namelist.h index 350cc2984f..c30f76f090 100644 --- a/bld/cg/h/namelist.h +++ b/bld/cg/h/namelist.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2016 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -32,13 +32,13 @@ extern name *AllocConst( float_handle value ); extern name *AllocAddrConst( name *value, int seg, constant_type_class const_type, type_class_def type_class ); -extern name *FindIntValue( signed_32 value ); +extern name *FindIntValue( int_32 value ); extern name *AllocIntConst( int value ); extern name *AllocUIntConst( uint value ); -extern name *AllocS32Const( signed_32 value ); -extern name *AllocU32Const( unsigned_32 value ); -extern name *AllocS64Const( unsigned_32 low, unsigned_32 high ); -extern name *AllocU64Const( unsigned_32 low, unsigned_32 high ); +extern name *AllocS32Const( int_32 value ); +extern name *AllocU32Const( uint_32 value ); +extern name *AllocS64Const( uint_32 low, uint_32 high ); +extern name *AllocU64Const( uint_32 low, uint_32 high ); extern constant_defn *GetFloat( name *cons, type_class_def type_class ); extern memory_name *SAllocMemory( pointer symbol, type_length offset, cg_class class, type_class_def type_class, type_length size ); extern name *AllocMemory( pointer symbol, type_length offset, cg_class class, type_class_def type_class ); diff --git a/bld/cg/h/objout.h b/bld/cg/h/objout.h index 97a4a89ee8..a28c8ce06a 100644 --- a/bld/cg/h/objout.h +++ b/bld/cg/h/objout.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -82,10 +82,10 @@ extern void FEPtr( cg_sym_handle sym, type_def *tipe, offset plus ); extern void FEPtrBaseOffset( cg_sym_handle sym, offset plus ); extern void FEPtrBase( cg_sym_handle sym ); -extern void DataAlign( unsigned_32 align ); -extern void DataBytes( unsigned_32 len, const void *src ); -extern void DataShort( unsigned_16 val ); -extern void DataLong( unsigned_32 val ); +extern void DataAlign( uint_32 align ); +extern void DataBytes( uint_32 len, const void *src ); +extern void DataShort( uint_16 val ); +extern void DataLong( uint_32 val ); extern void IterBytes( offset len, byte pat ); extern void DataLabel( label_handle lbl ); extern name *GenFloat( name *cons, type_class_def type_class ); diff --git a/bld/cg/h/objrep.h b/bld/cg/h/objrep.h index cfb9f04e10..2479b143dc 100644 --- a/bld/cg/h/objrep.h +++ b/bld/cg/h/objrep.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -71,8 +71,8 @@ typedef struct object { struct array_control *lines; long_offset start; objhandle segfix; - unsigned_16 index; - unsigned_16 sofar; + uint_16 index; + uint_16 sofar; unsigned gen_static_exports : 1; unsigned lines_generated : 1; unsigned pending_label_line : 1; diff --git a/bld/cg/h/ocentry.h b/bld/cg/h/ocentry.h index 7db60acb2b..7344fe1abc 100644 --- a/bld/cg/h/ocentry.h +++ b/bld/cg/h/ocentry.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -156,15 +156,15 @@ typedef struct oc_idata { typedef struct oc_linenum { oc_header hdr; - unsigned_32 line; + uint_32 line; bool label_line; } oc_linenum; typedef struct oc_riscins { oc_header hdr; - unsigned_32 opcode; + uint_32 opcode; pointer sym; // symbol to which there is reloc (if any) - unsigned_32 reloc; // type of reloc (owl_reloc_type) + uint_32 reloc; // type of reloc (owl_reloc_type) } oc_riscins; typedef struct oc_func_start { diff --git a/bld/cg/h/patch.h b/bld/cg/h/patch.h index 351edeae38..31892709f0 100644 --- a/bld/cg/h/patch.h +++ b/bld/cg/h/patch.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -57,7 +58,7 @@ typedef struct patch_info { extern patch_handle BGNewPatch( void ); extern cg_name BGPatchNode( patch_handle patch, type_def *tipe ); -extern void BGPatchInteger( patch_handle patch, signed_32 value ); +extern void BGPatchInteger( patch_handle patch, int_32 value ); extern void BGFiniPatch( patch_handle patch ); extern an TNPatch( tn node ); extern tn TGPatch( patch_handle patch, type_def *tipe ); diff --git a/bld/cg/h/score.h b/bld/cg/h/score.h index d59690ac13..51a9e53788 100644 --- a/bld/cg/h/score.h +++ b/bld/cg/h/score.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2016 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -68,7 +68,7 @@ typedef struct score_reg { typedef struct score_info { - signed_32 offset; + int_32 offset; union name *base; /* indexed names only */ union { struct temp_name *t; @@ -94,7 +94,7 @@ typedef struct score { struct score *prev_reg; byte index; byte generation; - unsigned_16 __pad_to_16; + uint_16 __pad_to_16; } score; diff --git a/bld/cg/h/seldef.h b/bld/cg/h/seldef.h index d37eda26b0..393e50469a 100644 --- a/bld/cg/h/seldef.h +++ b/bld/cg/h/seldef.h @@ -38,9 +38,9 @@ typedef struct select_list { struct select_list *next; - signed_32 low; - signed_32 high; - unsigned_32 count; + int_32 low; + int_32 high; + uint_32 count; label_handle label; } select_list; @@ -50,8 +50,8 @@ typedef struct select_node { #endif struct select_list *list; label_handle other_wise; - signed_32 lower; - signed_32 upper; + int_32 lower; + int_32 upper; uint num_cases; } select_node; diff --git a/bld/cg/h/split.h b/bld/cg/h/split.h index 057a913300..14bc2b3392 100644 --- a/bld/cg/h/split.h +++ b/bld/cg/h/split.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2018 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -42,7 +42,7 @@ extern instruction *(*ReduceTab[])( instruction * ); extern hw_reg_set Op1Reg( instruction *ins ); extern hw_reg_set ResultReg( instruction *ins ); extern hw_reg_set ZapReg( instruction *ins ); -extern instruction *MoveConst( unsigned_32 value, name *result, type_class_def type_class ); +extern instruction *MoveConst( uint_32 value, name *result, type_class_def type_class ); extern instruction *Reduce( instruction *ins ); extern instruction *SplitUnary( instruction *ins ); extern void CheckCC( instruction *ins, instruction *new_ins ); diff --git a/bld/cg/h/stubdata.h b/bld/cg/h/stubdata.h index 55ce8cdb99..dab9a7574f 100644 --- a/bld/cg/h/stubdata.h +++ b/bld/cg/h/stubdata.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -40,7 +41,7 @@ extern FILE_CTL Files[MAX_SEG + 1]; extern int FilesOpen; extern bool SegOk[MAX_SEG + 1]; -extern unsigned_32 Locs[MAX_SEG + 1]; +extern uint_32 Locs[MAX_SEG + 1]; extern int SymDebug; extern int TypDebug; extern int Actions; diff --git a/bld/cg/h/symdbg.h b/bld/cg/h/symdbg.h index e3c17b6d83..4c91f1c32c 100644 --- a/bld/cg/h/symdbg.h +++ b/bld/cg/h/symdbg.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -102,7 +102,7 @@ typedef struct field_entry{ typedef struct{ field_entry entry; union { - unsigned_32 off; + uint_32 off; dbg_loc loc; } u; uint attr; @@ -124,7 +124,7 @@ typedef struct{ typedef struct { field_entry entry; union { - unsigned_32 off; + uint_32 off; dbg_loc adjustor; } u; uint attr; @@ -135,7 +135,7 @@ typedef struct { typedef struct{ field_entry entry; union { - unsigned_32 off; + uint_32 off; dbg_loc loc; } u; uint attr; @@ -225,16 +225,16 @@ typedef struct{ }dim_var; typedef struct{ - dim_entry entry; - signed_32 lo; - signed_32 hi; - dbg_type idx; + dim_entry entry; + int_32 lo; + int_32 hi; + dbg_type idx; }dim_con; typedef union dim_any { - dim_entry entry; - dim_var var; - dim_con con; + dim_entry entry; + dim_var var; + dim_con con; }dim_any; typedef struct array_list { @@ -268,7 +268,7 @@ typedef struct location { cg_sym_handle fe_sym; unsigned ptr_type; unsigned stk; - unsigned_32 val; + uint_32 val; } u; unsigned use; byte class; @@ -313,7 +313,7 @@ typedef struct dbg_block { dbg_local *locals; block_patch *patches; back_handle end_lbl; - unsigned_32 start; + uint_32 start; } dbg_block; typedef struct dbg_rtn { @@ -324,8 +324,8 @@ typedef struct dbg_rtn { dbg_local *parms; dbg_loc obj_loc; /* for member functions */ dbg_type obj_type; /* for member functions */ - unsigned_32 ret_offset; - unsigned_32 epi_start; + uint_32 ret_offset; + uint_32 epi_start; byte pro_size; byte obj_ptr_type; /* for member functions */ back_handle end_lbl; diff --git a/bld/cg/h/system.h b/bld/cg/h/system.h index 86fa290e1a..35fa286001 100644 --- a/bld/cg/h/system.h +++ b/bld/cg/h/system.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -32,10 +33,10 @@ #if defined( __BIG_ENDIAN__ ) -extern unsigned_16 TargetShort(unsigned_16); -extern unsigned_32 TargetBigInt(unsigned_32); -extern void TargAddL(unsigned_32 *,unsigned_32); -extern void TargAddW(unsigned_16 *,unsigned_16); +extern uint_16 TargetShort( uint_16 ); +extern uint_32 TargetBigInt( uint_32 ); +extern void TargAddL( uint_32 *, uint_32 ); +extern void TargAddW( uint_16 *, uint_16 ); #define _IntToByte( value ) ((value) & 0xff) #define _IntToWord( value ) ((value) & 0xffff) diff --git a/bld/cg/h/treefold.h b/bld/cg/h/treefold.h index 16e362771f..c6e6f6bca6 100644 --- a/bld/cg/h/treefold.h +++ b/bld/cg/h/treefold.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -28,7 +29,7 @@ * ****************************************************************************/ -extern int GetLog2( unsigned_32 value ); +extern int GetLog2( uint_32 value ); extern tn FoldTimes( tn left, tn rite, type_def *tipe ); extern float_handle OkToNegate( float_handle value, type_def *tipe ); extern tn FoldMinus( tn left, tn rite, type_def *tipe ); diff --git a/bld/cg/h/treeprot.h b/bld/cg/h/treeprot.h index 8cc77dac39..84dad51d70 100644 --- a/bld/cg/h/treeprot.h +++ b/bld/cg/h/treeprot.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2018 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -37,7 +37,7 @@ extern tn TGWarp( tn before, label_handle label, tn after ); extern tn TGHandle( void ); extern tn TGCallback( cg_callback rtn, callback_handle ptr ); extern tn TGCompare( cg_op op, tn left, tn rite, type_def *tipe ); -extern unsigned_32 TGMask32( tn node ); +extern uint_32 TGMask32( tn node ); extern tn TGConvert( tn name, type_def *tipe ); extern tn TGBinary( cg_op op, tn left, tn rite, type_def *tipe ); extern tn TGUnary( cg_op op, tn left, type_def *tipe ); diff --git a/bld/cg/h/typedef.h b/bld/cg/h/typedef.h index 6f45d295d5..a94323c61a 100644 --- a/bld/cg/h/typedef.h +++ b/bld/cg/h/typedef.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -38,22 +38,22 @@ #if _TARGET & _TARG_8086 - typedef signed_16 type_length; + typedef int_16 type_length; #define MAX_TYPE_LENGTH 0x7fff #elif _TARGET & _TARG_80386 - typedef signed_32 type_length; + typedef int_32 type_length; #define MAX_TYPE_LENGTH 0x7fffffff #elif _TARGET & _TARG_370 - typedef signed_32 type_length; + typedef int_32 type_length; #define MAX_TYPE_LENGTH 0x7fffffff #elif _TARGET & _TARG_PPC - typedef signed_32 type_length; + typedef int_32 type_length; #define MAX_TYPE_LENGTH 0x7fffffff #elif _TARGET & _TARG_AXP - typedef signed_32 type_length; + typedef int_32 type_length; #define MAX_TYPE_LENGTH 0x7fffffff #elif _TARGET & _TARG_MIPS - typedef signed_32 type_length; + typedef int_32 type_length; #define MAX_TYPE_LENGTH 0x7fffffff #else #error Unknown target diff --git a/bld/cg/h/u32moddi.h b/bld/cg/h/u32moddi.h index fe9891ffb6..c751a1a04e 100644 --- a/bld/cg/h/u32moddi.h +++ b/bld/cg/h/u32moddi.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2018 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -31,4 +31,4 @@ ****************************************************************************/ -extern unsigned_32 U32ModDiv( unsigned_32 *x, unsigned_32 y ); +extern uint_32 U32ModDiv( uint_32 *x, uint_32 y ); diff --git a/bld/cg/intel/386/c/386enc.c b/bld/cg/intel/386/c/386enc.c index 755f4e7f56..95bf29049e 100644 --- a/bld/cg/intel/386/c/386enc.c +++ b/bld/cg/intel/386/c/386enc.c @@ -150,8 +150,8 @@ static hw_reg_set IndexTab[] = { }; -static void Add32Displacement( signed_32 val ) -/************************************************/ +static void Add32Displacement( int_32 val ) +/*********************************************/ { AddByte( val ); AddByte( val >> 8 ); @@ -159,8 +159,8 @@ static void Add32Displacement( signed_32 val ) AddByte( val >> 24 ); } -byte Displacement( signed_32 val, hw_reg_set regs ) -/****************************************************/ +byte Displacement( int_32 val, hw_reg_set regs ) +/*************************************************/ { if( val == 0 && !HW_COvlap( regs, HW_EBP ) ) return( DISP0 ); @@ -254,7 +254,7 @@ byte DoMDisp( name *op, bool alt_encoding ) static void EA( hw_reg_set base, hw_reg_set index, scale_typ scale, - signed_32 val, name *mem_loc, bool lea ) + int_32 val, name *mem_loc, bool lea ) /***************************************************************/ { if( HW_CEqual( index, HW_ESP ) ) @@ -318,12 +318,12 @@ static void EA( hw_reg_set base, hw_reg_set index, scale_typ scale, * Caller must embed returned constant into current opcode. */ -static signed_32 GetNextAddConstant( instruction *ins ) -/*******************************************************/ +static int_32 GetNextAddConstant( instruction *ins ) +/****************************************************/ { instruction *next; int neg; - signed_32 disp; + int_32 disp; next = ins->head.next; neg = 1; @@ -365,7 +365,7 @@ void LayLeaRegOp( instruction *ins ) name *right; scale_typ scale = 0; int neg; - signed_32 disp; + int_32 disp; left = ins->operands[0]; right = ins->operands[1]; @@ -548,8 +548,8 @@ void GenUnkPush( pointer value ) } -void GenPushC( signed_32 value ) -/*********************************/ +void GenPushC( int_32 value ) +/******************************/ { _Code; LayOpbyte( M_PUSHI ); @@ -559,8 +559,8 @@ void GenPushC( signed_32 value ) } -pointer GenFar16Thunk( pointer label, unsigned_16 parms_size, bool remove_parms ) -/*******************************************************************************/ +pointer GenFar16Thunk( pointer label, uint_16 parms_size, bool remove_parms ) +/***************************************************************************/ { segment_id old_segid; pointer code_32; diff --git a/bld/cg/intel/386/c/386sib.c b/bld/cg/intel/386/c/386sib.c index e5e57d2b3c..a7be4fc045 100644 --- a/bld/cg/intel/386/c/386sib.c +++ b/bld/cg/intel/386/c/386sib.c @@ -49,7 +49,7 @@ typedef struct sib_info { scale_typ scale; i_flags flags; instruction *ins; - signed_32 offset; + int_32 offset; } sib_info; diff --git a/bld/cg/intel/386/c/386splt2.c b/bld/cg/intel/386/c/386splt2.c index 863cf6c83e..a5e104ce05 100644 --- a/bld/cg/intel/386/c/386splt2.c +++ b/bld/cg/intel/386/c/386splt2.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2020 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -60,8 +60,8 @@ name *LowPart( name *tosplit, type_class_def type_class ) name *new = NULL; signed_8 s8; unsigned_8 u8; - signed_16 s16; - unsigned_16 u16; + int_16 s16; + uint_16 u16; constant_defn *floatval; switch( tosplit->n.class ) { @@ -87,7 +87,7 @@ name *LowPart( name *tosplit, type_class_def type_class ) _Zoiks( ZOIKS_129 ); } else { /* FD */ floatval = GetFloat( tosplit, FD ); - new = AllocConst( CFCnvU32F( _TargetLongInt( *(unsigned_32 *)( floatval->value + 0 ) ) ) ); + new = AllocConst( CFCnvU32F( _TargetLongInt( *(uint_32 *)( floatval->value + 0 ) ) ) ); } } else if( tosplit->c.const_type == CONS_ADDRESS ) { new = AddrConst( tosplit->c.value, (segment_id)tosplit->c.lo.int_value, CONS_OFFSET ); @@ -213,8 +213,8 @@ name *HighPart( name *tosplit, type_class_def type_class ) name *new = NULL; signed_8 s8; unsigned_8 u8; - signed_16 s16; - unsigned_16 u16; + int_16 s16; + uint_16 u16; constant_defn *floatval; switch( tosplit->n.class ) { @@ -240,7 +240,7 @@ name *HighPart( name *tosplit, type_class_def type_class ) _Zoiks( ZOIKS_129 ); } else { /* FD */ floatval = GetFloat( tosplit, FD ); - new = AllocConst( CFCnvU32F( _TargetLongInt( *(unsigned_32 *)( floatval->value + 2 ) ) ) ); + new = AllocConst( CFCnvU32F( _TargetLongInt( *(uint_32 *)( floatval->value + 2 ) ) ) ); } } else if( tosplit->c.const_type == CONS_ADDRESS ) { new = AddrConst( tosplit->c.value, (segment_id)tosplit->c.lo.int_value, CONS_SEGMENT ); diff --git a/bld/cg/intel/386/c/386tls.c b/bld/cg/intel/386/c/386tls.c index b331e25272..3c78192b1e 100644 --- a/bld/cg/intel/386/c/386tls.c +++ b/bld/cg/intel/386/c/386tls.c @@ -210,7 +210,7 @@ static void ExpandTlsOp( instruction *ins, name **pop ) PrefixIns( ins, new_ins ); index = op->i.index; if( op->i.scale != 0 ) { - const signed_32 values[] = { 1, 2, 4, 8, 16 }; + const int_32 values[] = { 1, 2, 4, 8, 16 }; if( op->i.scale > 4 ) _Zoiks( ZOIKS_134 ); index = AllocTemp( WD ); new_ins = MakeBinary( OP_MUL, op->i.index, diff --git a/bld/cg/intel/386/h/offset.h b/bld/cg/intel/386/h/offset.h index 27b4cb09c5..0fa0478abf 100644 --- a/bld/cg/intel/386/h/offset.h +++ b/bld/cg/intel/386/h/offset.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -31,7 +32,7 @@ #ifndef OFFSET_H #define OFFSET_H -typedef unsigned_16 short_offset; -typedef unsigned_32 long_offset; -typedef unsigned_32 offset; +typedef uint_16 short_offset; +typedef uint_32 long_offset; +typedef uint_32 offset; #endif diff --git a/bld/cg/intel/c/wvtypes.c b/bld/cg/intel/c/wvtypes.c index d7a565b246..f174198dde 100644 --- a/bld/cg/intel/c/wvtypes.c +++ b/bld/cg/intel/c/wvtypes.c @@ -75,8 +75,8 @@ static byte GetScalar( cg_type tipe ) { } -static uint SignedSizeClass( signed_32 num ) { -/************************************************/ +static uint SignedSizeClass( int_32 num ) { +/*******************************************/ uint class; @@ -196,8 +196,8 @@ void WVBackRefType( dbg_name name, dbg_type tipe ) SetOP( old_segid ); } -dbg_type WVCharBlock( unsigned_32 len ) -/********************************************/ +dbg_type WVCharBlock( uint_32 len ) +/****************************************/ { temp_buff temp; int class; @@ -262,8 +262,8 @@ dbg_type WVArray( dbg_type idx, dbg_type base ) } -dbg_type WVIntArray( unsigned_32 hi, dbg_type base ) -/*********************************************************/ +dbg_type WVIntArray( uint_32 hi, dbg_type base ) +/*****************************************************/ { uint class; temp_buff temp; @@ -276,8 +276,8 @@ dbg_type WVIntArray( unsigned_32 hi, dbg_type base ) return( TypeIdx ); } -dbg_type WVSubRange( signed_32 lo, signed_32 hi, dbg_type base ) -/*****************************************************************/ +dbg_type WVSubRange( int_32 lo, int_32 hi, dbg_type base ) +/***********************************************************/ { uint class_lo; uint class_hi; @@ -603,8 +603,8 @@ static void EndType( bool check_too_big ) { static void DmpFileInfo( void ) /*****************************/ { - fname_lst *lst; - unsigned_16 index; + fname_lst *lst; + uint_16 index; DataShort( DBFiles.count ); index = 0; diff --git a/bld/cg/intel/c/x86data.c b/bld/cg/intel/c/x86data.c index 6f389e14e9..76e64e25cb 100644 --- a/bld/cg/intel/c/x86data.c +++ b/bld/cg/intel/c/x86data.c @@ -56,8 +56,8 @@ static void DoLblPtr( label_handle lbl, segment_id segid, fix_class class, offset plus ); -void DataAlign( unsigned_32 align ) -/************************************/ +void DataAlign( uint_32 align ) +/********************************/ { offset curr_loc; uint modulus; @@ -85,8 +85,8 @@ void DataBytes( unsigned len, const void *src ) } -void DataShort( unsigned_16 val ) -/**********************************/ +void DataShort( uint_16 val ) +/******************************/ { TellOptimizerByPassed(); SetUpObj( true ); @@ -94,8 +94,8 @@ void DataShort( unsigned_16 val ) TellByPassOver(); } -void DataLong( unsigned_32 val ) -/*********************************/ +void DataLong( uint_32 val ) +/*****************************/ { TellOptimizerByPassed(); SetUpObj( true ); diff --git a/bld/cg/intel/c/x86dbsup.c b/bld/cg/intel/c/x86dbsup.c index cd02cb98d7..9a3ae4cb41 100644 --- a/bld/cg/intel/c/x86dbsup.c +++ b/bld/cg/intel/c/x86dbsup.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -134,8 +134,8 @@ void BuffWord( uint w ) } -void BuffDWord( unsigned_32 w ) -/********************************/ +void BuffDWord( uint_32 w ) +/****************************/ { BuffWord( w & 0xffff ); BuffWord( w >> 16 ); @@ -153,8 +153,8 @@ void BuffOffset( offset w ) } -void BuffValue( unsigned_32 val, uint class ) -/**********************************************/ +void BuffValue( uint_32 val, uint class ) +/******************************************/ { switch( class ) { case 0: diff --git a/bld/cg/intel/c/x86enc.c b/bld/cg/intel/c/x86enc.c index 2f6039495b..f650a36451 100644 --- a/bld/cg/intel/c/x86enc.c +++ b/bld/cg/intel/c/x86enc.c @@ -1240,9 +1240,9 @@ void GenRegMove( hw_reg_set src, hw_reg_set dst ) } -static void AddSWData( opcode_defs op, signed_32 val, type_class_def type_class ) +static void AddSWData( opcode_defs op, int_32 val, type_class_def type_class ) /************************************************************************** - * Add a const (signed_32) to Inst[] with sign extension if the opcode + * Add a const (int_32) to Inst[] with sign extension if the opcode * allows it */ { @@ -1293,8 +1293,8 @@ static void AddSWCons( opcode_defs op, name *opnd, type_class_def type_class } -void AddWData( signed_32 value, type_class_def type_class ) -/************************************************************/ +void AddWData( int_32 value, type_class_def type_class ) +/*********************************************************/ { AddByte( (byte)value ); if( type_class == U1 || type_class == I1 ) @@ -1331,9 +1331,9 @@ void AddWCons( name *op, type_class_def type_class ) } } -void AddSData( signed_32 value, type_class_def type_class ) -/***************************************************************** - * Add a constant (signed_32) to Inst[], with possible sign extension +void AddSData( int_32 value, type_class_def type_class ) +/********************************************************** + * Add a constant (int_32) to Inst[], with possible sign extension */ { if( ( type_class == U2 || type_class == I2 ) diff --git a/bld/cg/intel/c/x86enc2.c b/bld/cg/intel/c/x86enc2.c index 731db35368..3dc910bcf6 100644 --- a/bld/cg/intel/c/x86enc2.c +++ b/bld/cg/intel/c/x86enc2.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -499,8 +499,8 @@ void Gen1ByteValue( byte value ) } -void Gen2ByteValue( unsigned_16 value ) -/***************************************** +void Gen2ByteValue( uint_16 value ) +/************************************* * Drop a 16 bit integer into the queue. */ { @@ -511,8 +511,8 @@ void Gen2ByteValue( unsigned_16 value ) } -void Gen4ByteValue( unsigned_32 value ) -/***************************************** +void Gen4ByteValue( uint_32 value ) +/************************************* * Drop a 32 bit integer into the queue. */ { diff --git a/bld/cg/intel/c/x86lesds.c b/bld/cg/intel/c/x86lesds.c index 5675897138..4f9099a480 100644 --- a/bld/cg/intel/c/x86lesds.c +++ b/bld/cg/intel/c/x86lesds.c @@ -112,12 +112,12 @@ static bool MemMove( instruction *ins ) static bool OptMemMove( instruction *ins, instruction *next ) /***************************************************************/ { - unsigned_32 shift; - unsigned_32 lo; - unsigned_32 hi; - type_class_def result_type_class; - unsigned_32 result_const; - name *result; + uint_32 shift; + uint_32 lo; + uint_32 hi; + type_class_def result_type_class; + uint_32 result_const; + name *result; assert( MemMove( ins ) && MemMove( next ) ); if( ins->type_class == next->type_class ) { diff --git a/bld/cg/intel/c/x86mul.c b/bld/cg/intel/c/x86mul.c index efbeccb020..37aaf4e803 100644 --- a/bld/cg/intel/c/x86mul.c +++ b/bld/cg/intel/c/x86mul.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2018 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -36,8 +36,8 @@ #include "multiply.h" -int MulCost( unsigned_32 num ) -/********************************/ +int MulCost( uint_32 num ) +/****************************/ { int cost; diff --git a/bld/cg/intel/c/x86obj.c b/bld/cg/intel/c/x86obj.c index 7d00c39095..598d4fec04 100644 --- a/bld/cg/intel/c/x86obj.c +++ b/bld/cg/intel/c/x86obj.c @@ -242,7 +242,7 @@ static byte DoSum( const byte *buff, size_t len ) static void PutObjOMFRec( byte class, const void *buff, size_t len ) /******************************************************************/ { - unsigned_16 blen; + uint_16 blen; byte cksum; blen = _TargetShort( len + 1 ); @@ -261,7 +261,7 @@ static void PatchObj( objhandle rec, objoffset roffset, const byte *buff, size_t /************************************************************************************/ { byte cksum; - unsigned_16 reclen; + uint_16 reclen; byte inbuff[80]; SeekGetObj( rec, 1, (byte *)&reclen, 2 ); @@ -461,29 +461,29 @@ static void OutByte( byte value, array_control *dest ) dest->used = need; } -static void OutShort( unsigned_16 value, array_control *dest ) -/****************************************************************/ +static void OutShort( uint_16 value, array_control *dest ) +/************************************************************/ { unsigned need; - need = dest->used + sizeof( unsigned_16 ); + need = dest->used + sizeof( uint_16 ); if( need > dest->alloc ) { ReallocArray( dest, need ); } - _ARRAY( dest, unsigned_16 ) = _TargetShort( value ); + _ARRAY( dest, uint_16 ) = _TargetShort( value ); dest->used = need; } -static void OutLongInt( unsigned_32 value, array_control *dest ) -/******************************************************************/ +static void OutLongInt( uint_32 value, array_control *dest ) +/**************************************************************/ { unsigned need; - need = dest->used + sizeof( unsigned_32 ); + need = dest->used + sizeof( uint_32 ); if( need > dest->alloc ) { ReallocArray( dest, need ); } - _ARRAY( dest, unsigned_32 ) = _TargetLongInt( value ); + _ARRAY( dest, uint_32 ) = _TargetLongInt( value ); dest->used = need; } @@ -1763,8 +1763,8 @@ static void FlushObject( void ) } -static index_rec *AskIndexRec( unsigned_16 sidx ) -/******************************************************/ +static index_rec *AskIndexRec( uint_16 sidx ) +/**************************************************/ { index_rec *rec; unsigned i; @@ -1937,8 +1937,8 @@ static void DoSegARange( offset *codesize, index_rec *rec ) static void DoPatch( obj_patch *pat, offset lc ) /**************************************************/ { - unsigned_32 lword_val; - unsigned_16 word_val; + uint_32 lword_val; + uint_16 word_val; byte byte_val; if( pat->attr & LONG_PATCH ) { @@ -2410,17 +2410,17 @@ void OutLabel( label_handle lbl ) patptr = &_ARRAYOF( &obj->data, byte )[curr_pat->pat.where]; if( curr_pat->pat.attr & ADD_PATCH ) { if( curr_pat->pat.attr & LONG_PATCH ) { - _TargetAddL( *(unsigned_32 *)patptr, lc ); + _TargetAddL( *(uint_32 *)patptr, lc ); } else if( curr_pat->pat.attr & WORD_PATCH ) { - _TargetAddW( *(unsigned_16 *)patptr, lc ); + _TargetAddW( *(uint_16 *)patptr, lc ); } else { *(byte *)patptr += lc; } } else { if( curr_pat->pat.attr & LONG_PATCH ) { - *(unsigned_32 *)patptr = _TargetLongInt( lc ); + *(uint_32 *)patptr = _TargetLongInt( lc ); } else if( curr_pat->pat.attr & WORD_PATCH ) { - *(unsigned_16 *)patptr = _TargetShort( lc ); + *(uint_16 *)patptr = _TargetShort( lc ); } else { *(byte *)patptr = lc; } @@ -2849,19 +2849,19 @@ void OutDataByte( byte value ) _ARRAYOF( &obj->data, byte )[i] = value; } -void OutDataShort( unsigned_16 value ) -/***************************************/ +void OutDataShort( uint_16 value ) +/***********************************/ { unsigned i; unsigned need; object *obj; SetPendingLine(); - CheckLEDataSize( sizeof( unsigned_16 ), true ); + CheckLEDataSize( sizeof( uint_16 ), true ); obj = CurrSeg->obj; i = CurrSeg->location - obj->start + CurrSeg->data_prefix_size; - IncLocation( sizeof( unsigned_16 ) ); - need = i + sizeof( unsigned_16 ); + IncLocation( sizeof( uint_16 ) ); + need = i + sizeof( uint_16 ); if( need > obj->data.used ) { if( need > obj->data.alloc ) { ReallocArray( &obj->data, need ); @@ -2869,23 +2869,23 @@ void OutDataShort( unsigned_16 value ) obj->data.used = need; } SetMaxWritten(); - *(unsigned_16 *)&_ARRAYOF( &obj->data, byte )[i] = _TargetShort( value ); + *(uint_16 *)&_ARRAYOF( &obj->data, byte )[i] = _TargetShort( value ); } -void OutDataLong( unsigned_32 value ) -/**************************************/ +void OutDataLong( uint_32 value ) +/**********************************/ { unsigned i; unsigned need; object *obj; SetPendingLine(); - CheckLEDataSize( sizeof( unsigned_32 ), true ); + CheckLEDataSize( sizeof( uint_32 ), true ); obj = CurrSeg->obj; i = CurrSeg->location - obj->start + CurrSeg->data_prefix_size; - IncLocation( sizeof( unsigned_32 ) ); - need = i + sizeof( unsigned_32 ); + IncLocation( sizeof( uint_32 ) ); + need = i + sizeof( uint_32 ); if( need > obj->data.used ) { if( need > obj->data.alloc ) { ReallocArray( &obj->data, need ); @@ -2893,7 +2893,7 @@ void OutDataLong( unsigned_32 value ) obj->data.used = need; } SetMaxWritten(); - *(unsigned_32 *)&_ARRAYOF( &obj->data, byte )[i] = _TargetLongInt( value ); + *(uint_32 *)&_ARRAYOF( &obj->data, byte )[i] = _TargetLongInt( value ); } diff --git a/bld/cg/intel/c/x86sel.c b/bld/cg/intel/c/x86sel.c index 7dc5043583..26f0ea9be5 100644 --- a/bld/cg/intel/c/x86sel.c +++ b/bld/cg/intel/c/x86sel.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -75,8 +75,8 @@ #define MAX_IN_RANGE (MAX_COST/1000) /* so no overflow */ -static cost_val Balance( signed_32 size, signed_32 time ) -/*******************************************************/ +static cost_val Balance( int_32 size, int_32 time ) +/*************************************************/ { cost_val balance; byte opt_size; @@ -103,9 +103,9 @@ cost_val ScanCost( sel_handle s_node ) /************************************/ { select_list *list; - signed_32 hi; - signed_32 lo; - signed_32 values; + int_32 hi; + int_32 lo; + int_32 values; cost_val cost; int type_length; cg_type tipe; @@ -132,7 +132,7 @@ cost_val ScanCost( sel_handle s_node ) cost_val JumpCost( sel_handle s_node ) /************************************/ { - signed_32 in_range; + int_32 in_range; cost_val cost; in_range = s_node->upper - s_node->lower + 1; @@ -168,10 +168,10 @@ cost_val JumpCost( sel_handle s_node ) cost_val IfCost( sel_handle s_node, int entries ) /***********************************************/ { - signed_32 hi; - signed_32 lo; + int_32 hi; + int_32 lo; cost_val cost; - signed_32 jumpsize; + int_32 jumpsize; int log_entries; int tipe_length; @@ -192,7 +192,7 @@ cost_val IfCost( sel_handle s_node, int entries ) log_entries = 0; while( entries != 0 ) { log_entries++; - entries = (unsigned_32)entries >> 2; + entries = (uint_32)entries >> 2; } /* add cost for extra jumps generated for grandparents and every other child except the last one */ @@ -204,12 +204,12 @@ cost_val IfCost( sel_handle s_node, int entries ) return( cost ); } -static void GenValuesForward( select_list *list, signed_32 hi, - signed_32 lo, signed_32 to_sub, +static void GenValuesForward( select_list *list, int_32 hi, + int_32 lo, int_32 to_sub, cg_type tipe ) /****************************************************************/ { - signed_32 curr; + int_32 curr; curr = lo; for(;;) { @@ -236,13 +236,13 @@ static void GenValuesForward( select_list *list, signed_32 hi, } -static void GenValuesBackward( select_list *list, signed_32 hi, - signed_32 lo, signed_32 to_sub, +static void GenValuesBackward( select_list *list, int_32 hi, + int_32 lo, int_32 to_sub, cg_type tipe ) { - select_list *scan; - select_list *next; - signed_32 curr; + select_list *scan; + select_list *next; + int_32 curr; curr = hi; for( scan = list; scan->high != hi; ) { @@ -275,19 +275,19 @@ static void GenValuesBackward( select_list *list, signed_32 hi, } -tbl_control *MakeScanTab( select_list *list, signed_32 hi, +tbl_control *MakeScanTab( select_list *list, int_32 hi, label_handle other, cg_type tipe, cg_type real_tipe ) /*********************************************************************/ { tbl_control *table; label_handle *tab_ptr; - unsigned_32 cases; - signed_32 lo; - signed_32 to_sub; + uint_32 cases; + int_32 lo; + int_32 to_sub; segment_id old_segid; select_list *scan; - signed_32 curr; + int_32 curr; cases = NumValues( list, hi ); lo = list->low; @@ -339,13 +339,13 @@ tbl_control *MakeScanTab( select_list *list, signed_32 hi, return( table ); } -tbl_control *MakeJmpTab( select_list *list, signed_32 lo, - signed_32 hi, label_handle other ) +tbl_control *MakeJmpTab( select_list *list, int_32 lo, + int_32 hi, label_handle other ) /*********************************************************************/ { tbl_control *table; label_handle *tab_ptr; - unsigned_32 cases; + uint_32 cases; segment_id old_segid; cases = hi - lo + 1; diff --git a/bld/cg/intel/c/x86split.c b/bld/cg/intel/c/x86split.c index 90c17f4e24..2329d9f586 100644 --- a/bld/cg/intel/c/x86split.c +++ b/bld/cg/intel/c/x86split.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -206,7 +206,7 @@ name *IntEquivalent( name *name ) constant_defn *defn; defn = GetFloat( name, FS ); - return( AllocConst( CFCnvU32F( _TargetBigInt( *(unsigned_32 *)( defn->value + 0 ) ) ) ) ); + return( AllocConst( CFCnvU32F( _TargetBigInt( *(uint_32 *)( defn->value + 0 ) ) ) ) ); } name *Int64Equivalent( name *name ) @@ -215,7 +215,7 @@ name *Int64Equivalent( name *name ) constant_defn *defn; defn = GetFloat( name, FD ); - return( AllocU64Const( *(unsigned_32 *)( defn->value + 0 ), *(unsigned_32 *)( defn->value + 2 ) ) ); + return( AllocU64Const( *(uint_32 *)( defn->value + 0 ), *(uint_32 *)( defn->value + 2 ) ) ); } instruction *rFSCONSCMP( instruction *ins ) diff --git a/bld/cg/intel/h/pccode.h b/bld/cg/intel/h/pccode.h index db31845657..64b66c1548 100644 --- a/bld/cg/intel/h/pccode.h +++ b/bld/cg/intel/h/pccode.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -30,7 +31,7 @@ ****************************************************************************/ -typedef unsigned_16 gen_opcode; +typedef uint_16 gen_opcode; typedef enum { BYTE_OPCODE = 0x01, diff --git a/bld/cg/intel/h/wvtypes.h b/bld/cg/intel/h/wvtypes.h index 4f1528abbe..5f1b0fe845 100644 --- a/bld/cg/intel/h/wvtypes.h +++ b/bld/cg/intel/h/wvtypes.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -36,14 +36,14 @@ extern dbg_type WVScalar( const char *name, cg_type tipe ); extern dbg_type WVScope( const char *name ); extern void WVDumpName( dbg_name name, dbg_type tipe ); extern void WVBackRefType( dbg_name name, dbg_type tipe ); -extern dbg_type WVCharBlock( unsigned_32 len ); +extern dbg_type WVCharBlock( uint_32 len ); extern dbg_type WVIndCharBlock( back_handle len, cg_type len_type, int off ); extern dbg_type WVLocCharBlock( dbg_loc loc, cg_type len_type ); extern dbg_type WVFtnArray( back_handle dims, cg_type lo_bound_tipe, cg_type num_elts_tipe, int off, dbg_type base ); extern dbg_type WVArray( dbg_type idx, dbg_type base ); -extern dbg_type WVIntArray( unsigned_32 hi, dbg_type base ); +extern dbg_type WVIntArray( uint_32 hi, dbg_type base ); extern dbg_type WVEndArray( dbg_array ar ); -extern dbg_type WVSubRange( signed_32 lo, signed_32 hi, dbg_type base ); +extern dbg_type WVSubRange( int_32 lo, int_32 hi, dbg_type base ); extern dbg_type WVDereference( cg_type ptr_type, dbg_type base ); extern dbg_type WVPtr( cg_type ptr_type, dbg_type base ); extern dbg_type WVBasedPtr( cg_type ptr_type, dbg_type base, dbg_loc loc_segment ); diff --git a/bld/cg/intel/h/x86call.h b/bld/cg/intel/h/x86call.h index 321b330903..ce0d375ad3 100644 --- a/bld/cg/intel/h/x86call.h +++ b/bld/cg/intel/h/x86call.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -34,3 +34,4 @@ CALL_POPS_PARMS = 0x0040, CALL_INTERRUPT = 0x0080, CALL_FAR16 = 0x0100, + CALL_NEEDFRAME = 0x0200, diff --git a/bld/cg/intel/h/x86dbsup.h b/bld/cg/intel/h/x86dbsup.h index 8d0878f9bc..318f017636 100644 --- a/bld/cg/intel/h/x86dbsup.h +++ b/bld/cg/intel/h/x86dbsup.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -37,9 +37,9 @@ extern uint BuffLoc( void ); extern void BuffPatch( byte val, uint loc ); extern void BuffByte( byte b ); extern void BuffWord( uint w ); -extern void BuffDWord( unsigned_32 w ); +extern void BuffDWord( uint_32 w ); extern void BuffOffset( offset w ); -extern void BuffValue( unsigned_32 val, uint class ); +extern void BuffValue( uint_32 val, uint class ); extern void BuffRelocatable( pointer ptr, fixup_kind type, offset off ); extern void BuffBack( pointer back, int off ); extern void BuffAddr( pointer sym ); diff --git a/bld/cg/intel/h/x86enc.h b/bld/cg/intel/h/x86enc.h index 045a900e82..d372d146ed 100644 --- a/bld/cg/intel/h/x86enc.h +++ b/bld/cg/intel/h/x86enc.h @@ -54,9 +54,9 @@ extern void QuickSave( hw_reg_set reg, opcode_defs op ); extern void GenRegXor( hw_reg_set src, hw_reg_set dst ); extern void GenRegNeg( hw_reg_set src ); extern void GenRegMove( hw_reg_set src, hw_reg_set dst ); -extern void AddWData( signed_32 value, type_class_def type_class ); +extern void AddWData( int_32 value, type_class_def type_class ); extern void AddWCons( name *op, type_class_def type_class ); -extern void AddSData( signed_32 value, type_class_def type_class ); +extern void AddSData( int_32 value, type_class_def type_class ); extern void GenRegAdd( hw_reg_set dst, type_length value ); extern void GenRegSub( hw_reg_set dst, type_length value ); extern void GenRegAnd( hw_reg_set dst, type_length value ); @@ -93,7 +93,7 @@ extern void LayLeaRegOp( instruction *ins ); extern void DoMAddr( name *op ); extern byte DoMDisp( name *op, bool alt_encoding ); extern void LayModRM( name *op ); -extern byte Displacement( signed_32 val, hw_reg_set regs ); +extern byte Displacement( int_32 val, hw_reg_set regs ); extern byte DoIndex( hw_reg_set regs ); extern void DoRelocConst( name *op, type_class_def type_class ); extern void Do4Shift( instruction *ins ); @@ -110,8 +110,8 @@ extern void Pow2Div286(instruction*); #else extern type_length TmpLoc( name *base, name *op ); extern void GenUnkPush( pointer value ); -extern void GenPushC( signed_32 value ); -extern pointer GenFar16Thunk( pointer label, unsigned_16 parms_size, bool remove_parms ); +extern void GenPushC( int_32 value ); +extern pointer GenFar16Thunk( pointer label, uint_16 parms_size, bool remove_parms ); extern void GenP5ProfilingProlog( label_handle label ); extern void GenP5ProfilingEpilog( label_handle label ); #if 0 diff --git a/bld/cg/intel/h/x86enc2.h b/bld/cg/intel/h/x86enc2.h index b58f3d746d..ee11dc1fe7 100644 --- a/bld/cg/intel/h/x86enc2.h +++ b/bld/cg/intel/h/x86enc2.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -37,8 +37,8 @@ extern void GenCallIndirect( instruction *ins ); extern void GenCallRegister( instruction *ins ); extern void GenSelEntry( bool starts ); extern void Gen1ByteValue( byte value ); -extern void Gen2ByteValue( unsigned_16 value ); -extern void Gen4ByteValue( unsigned_32 value ); +extern void Gen2ByteValue( uint_16 value ); +extern void Gen4ByteValue( uint_32 value ); extern void GenCodePtr( pointer label ); extern void GenJmpMemory( instruction *ins ); extern void GenJmpRegister( instruction *ins ); diff --git a/bld/cg/intel/h/x86obj.h b/bld/cg/intel/h/x86obj.h index d56e93780f..4a079f32ec 100644 --- a/bld/cg/intel/h/x86obj.h +++ b/bld/cg/intel/h/x86obj.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -44,8 +44,8 @@ extern void OutFPPatch( fp_patches i ); extern void OutPatch( label_handle lbl, patch_attr attr ); extern abspatch *NewAbsPatch( void ); extern void OutDataByte( byte value ); -extern void OutDataShort( unsigned_16 value ); -extern void OutDataLong( unsigned_32 value ); +extern void OutDataShort( uint_16 value ); +extern void OutDataLong( uint_32 value ); extern void OutAbsPatch( abspatch *patch, patch_attr attr ); extern void OutReloc( segment_id segid, fix_class class, bool rel ); extern void OutSpecialCommon( import_handle imphdl, fix_class class, bool rel ); diff --git a/bld/cg/intel/h/x86objd.h b/bld/cg/intel/h/x86objd.h index bce46e3dfa..35dccaea69 100644 --- a/bld/cg/intel/h/x86objd.h +++ b/bld/cg/intel/h/x86objd.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -87,7 +87,7 @@ #define WEAK_EXTRN_COMMENT CMT_NP( WKEXT ) #define LAZY_EXTRN_COMMENT CMT_NP( LZEXT ) -typedef unsigned_16 omf_idx; +typedef uint_16 omf_idx; typedef enum { /* order is important -- see documentation */ @@ -144,8 +144,8 @@ typedef struct index_rec { base_type btype; byte attr; byte data_prefix_size; - unsigned_32 comdat_size; - unsigned_32 total_comdat_size; + uint_32 comdat_size; + uint_32 total_comdat_size; cg_sym_handle comdat_symbol; label_handle comdat_label; omf_idx comdat_nidx; diff --git a/bld/cg/intel/i86/c/i86enc.c b/bld/cg/intel/i86/c/i86enc.c index fe2bb76d91..5d66c5b5cc 100644 --- a/bld/cg/intel/i86/c/i86enc.c +++ b/bld/cg/intel/i86/c/i86enc.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -91,8 +91,8 @@ byte DoIndex( hw_reg_set regs ) } -byte Displacement( signed_32 val, hw_reg_set regs ) -/****************************************************/ +byte Displacement( int_32 val, hw_reg_set regs ) +/*************************************************/ { HW_CTurnOff( regs, HW_SEGS ); if( val == 0 && !HW_CEqual( regs, HW_BP ) ) @@ -205,7 +205,7 @@ void Do4CXShift( instruction *ins, void (*rtn)(instruction *) ) _Next; LayOpword( 0x2081 ); /* AND reg,immed (word) */ LayRegRM( lreg ); - AddWData( ((unsigned_16)~0) << shift, U2 ); + AddWData( ((uint_16)~0) << shift, U2 ); _Next; LayOpword( M_XORRR | B_KEY_W ); LayReg( lreg ); @@ -228,7 +228,7 @@ void Do4CXShift( instruction *ins, void (*rtn)(instruction *) ) _Next; LayOpword( 0x2081 ); /* AND reg,immed (word) */ LayRegRM( hreg ); - AddWData( ((unsigned_16)~0) >> shift, U2 ); + AddWData( ((uint_16)~0) >> shift, U2 ); _Next; LayOpword( M_XORRR | B_KEY_W ); LayReg( hreg ); diff --git a/bld/cg/intel/i86/c/i86splt2.c b/bld/cg/intel/i86/c/i86splt2.c index 51528121bd..e9e3e98517 100644 --- a/bld/cg/intel/i86/c/i86splt2.c +++ b/bld/cg/intel/i86/c/i86splt2.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2020 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -67,8 +67,8 @@ name *LowPart( name *tosplit, type_class_def type_class ) name *new_cons; signed_8 s8; unsigned_8 u8; - signed_16 s16; - unsigned_16 u16; + int_16 s16; + uint_16 u16; constant_defn *floatval; switch( tosplit->n.class ) { @@ -90,7 +90,7 @@ name *LowPart( name *tosplit, type_class_def type_class ) _Zoiks( ZOIKS_125 ); } else { /* FD */ floatval = GetFloat( tosplit, FD ); - new = AllocConst( CFCnvU32F( _TargetLongInt( *(unsigned_32 *)( floatval->value + 0 ) ) ) ); + new = AllocConst( CFCnvU32F( _TargetLongInt( *(uint_32 *)( floatval->value + 0 ) ) ) ); } } else if( tosplit->c.const_type == CONS_ADDRESS ) { new = AddrConst( tosplit->c.value, (segment_id)tosplit->c.lo.int_value, CONS_OFFSET ); @@ -141,8 +141,8 @@ name *HighPart( name *tosplit, type_class_def type_class ) name *op; signed_8 s8; unsigned_8 u8; - signed_16 s16; - unsigned_16 u16; + int_16 s16; + uint_16 u16; constant_defn *floatval; switch( tosplit->n.class ) { @@ -164,7 +164,7 @@ name *HighPart( name *tosplit, type_class_def type_class ) _Zoiks( ZOIKS_125 ); } else { /* FD */ floatval = GetFloat( tosplit, FD ); - new = AllocConst( CFCnvU32F( _TargetLongInt( *(unsigned_32 *)( floatval->value + 2 ) ) ) ); + new = AllocConst( CFCnvU32F( _TargetLongInt( *(uint_32 *)( floatval->value + 2 ) ) ) ); } } else if( tosplit->c.const_type == CONS_ADDRESS ) { new = AddrConst( tosplit->c.value, (segment_id)tosplit->c.lo.int_value, CONS_SEGMENT ); diff --git a/bld/cg/intel/i86/h/offset.h b/bld/cg/intel/i86/h/offset.h index 8a7b556e39..67305db51f 100644 --- a/bld/cg/intel/i86/h/offset.h +++ b/bld/cg/intel/i86/h/offset.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2018 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -34,8 +34,8 @@ #ifndef OFFSET_H #define OFFSET_H -typedef unsigned_16 short_offset; -typedef unsigned_32 long_offset; -typedef unsigned_16 offset; +typedef uint_16 short_offset; +typedef uint_32 long_offset; +typedef uint_16 offset; #endif diff --git a/bld/cg/risc/axp/c/axpenc.c b/bld/cg/risc/axp/c/axpenc.c index c0caed3156..f5618b0719 100644 --- a/bld/cg/risc/axp/c/axpenc.c +++ b/bld/cg/risc/axp/c/axpenc.c @@ -304,13 +304,13 @@ static void GenOPIMM8( uint_8 opcode, uint_8 function, reg_idx ra, uint_8 im EmitIns( ins_encoding ); } -void GenLOADS32( signed_32 value, reg_idx reg ) -/************************************************/ +void GenLOADS32( int_32 value, reg_idx reg ) +/*********************************************/ { - signed_16 high; - signed_16 extra; - signed_16 low; - reg_idx curr; + int_16 high; + int_16 extra; + int_16 low; + reg_idx curr; curr = ZERO_REG_IDX; FactorInt32( value, &high, &extra, &low ); @@ -384,15 +384,15 @@ static uint_16 FindFloatingOpcodes( instruction *ins ) return( opcode ); } -static void GenMEMINSRELOC( uint_8 opcode, reg_idx ra, reg_idx rb, signed_16 displacement, pointer lbl, owl_reloc_type type ) -/***************************************************************************************************************************/ +static void GenMEMINSRELOC( uint_8 opcode, reg_idx ra, reg_idx rb, int_16 displacement, pointer lbl, owl_reloc_type type ) +/************************************************************************************************************************/ { ins_encoding = _Opcode( opcode ) | _Ra( ra ) | _Rb( rb ) | _SignedImmed( displacement ); EmitInsReloc( &ins_encoding, lbl, type ); } -void GenMEMINS( uint_8 opcode, reg_idx ra, reg_idx rb, signed_16 displacement ) -/*****************************************************************************/ +void GenMEMINS( uint_8 opcode, reg_idx ra, reg_idx rb, int_16 displacement ) +/**************************************************************************/ { ins_encoding = _Opcode( opcode ) | _Ra( ra ) | _Rb( rb ) | _SignedImmed( displacement ); EmitIns( ins_encoding ); @@ -409,14 +409,14 @@ static void GenBRANCH( uint_8 opcode, reg_idx reg, pointer label ) * move disp(Rs) -> Rd */ -void GenLOAD( hw_reg_set dst, hw_reg_set src, signed_16 displacement ) -/***********************************************************************/ +void GenLOAD( hw_reg_set dst, hw_reg_set src, int_16 displacement ) +/********************************************************************/ { GenMEMINS( 0x29, RegTrans( dst ), RegTrans( src ), displacement ); } -void GenFLOAD( hw_reg_set dst, hw_reg_set src, signed_16 displacement ) -/************************************************************************/ +void GenFLOAD( hw_reg_set dst, hw_reg_set src, int_16 displacement ) +/*********************************************************************/ { GenMEMINS( 0x23, RegTrans( dst ), RegTrans( src ), displacement ); } @@ -425,8 +425,8 @@ void GenFLOAD( hw_reg_set dst, hw_reg_set src, signed_16 displacement ) * move Rs -> disp(Rd) */ -void GenSTORE( hw_reg_set dst, signed_16 displacement, hw_reg_set src ) -/************************************************************************/ +void GenSTORE( hw_reg_set dst, int_16 displacement, hw_reg_set src ) +/*********************************************************************/ { GenMEMINS( 0x2d, RegTrans( src ), RegTrans( dst ), displacement ); } @@ -435,8 +435,8 @@ void GenSTORE( hw_reg_set dst, signed_16 displacement, hw_reg_set src ) * move Fs -> disp(Rd) */ -void GenFSTORE( hw_reg_set dst, signed_16 displacement, hw_reg_set src ) -/*************************************************************************/ +void GenFSTORE( hw_reg_set dst, int_16 displacement, hw_reg_set src ) +/**********************************************************************/ { GenMEMINS( 0x27, RegTrans( src ), RegTrans( dst ), displacement ); } @@ -563,7 +563,7 @@ static void getMemEncoding( name *mem, reg_idx *regidx_mem, int_16 *offset ) case N_INDEXED: assert( mem->i.index->n.class == N_REGISTER ); assert( mem->i.scale == 0 ); - assert( mem->i.constant == (type_length)((signed_16)mem->i.constant) ); + assert( mem->i.constant == (type_length)((int_16)mem->i.constant) ); assert( ( mem->i.index_flags & X_LOW_ADDR_BASE ) == 0 ); *regidx_mem = _NameRegTrans( mem->i.index ); *offset = (int_16)mem->i.constant; @@ -726,14 +726,14 @@ static bool encodeThreadDataRef( instruction *ins ) static void Encode( instruction *ins ) /****************************************/ { - uint_8 *opcodes; - uint_16 function; - reg_idx regidx; - reg_idx regidx_mem; - int_16 mem_offset; - signed_16 high; - signed_16 extra; - signed_16 low; + uint_8 *opcodes; + uint_16 function; + reg_idx regidx; + reg_idx regidx_mem; + int_16 mem_offset; + int_16 high; + int_16 extra; + int_16 low; switch( G( ins ) ) { case G_CALL: diff --git a/bld/cg/risc/axp/c/axpproc.c b/bld/cg/risc/axp/c/axpproc.c index 27794fb5e4..2eb1f84736 100644 --- a/bld/cg/risc/axp/c/axpproc.c +++ b/bld/cg/risc/axp/c/axpproc.c @@ -186,8 +186,8 @@ static void genMove( uint_32 src, uint_32 dst ) } -static void genLea( uint_32 src, signed_16 disp, uint_32 dst ) -/****************************************************************/ +static void genLea( uint_32 src, int_16 disp, uint_32 dst ) +/*************************************************************/ { GenMEMINS( LEA_OPCODE, dst, src, disp ); } @@ -409,10 +409,10 @@ static void emitSlopEpilog( stack_record *fs ) } -static signed_32 frameSize( stack_map *map ) -/*******************************************/ +static int_32 frameSize( stack_map *map ) +/*****************************************/ { - signed_32 size; + int_32 size; size = map->slop.size + map->varargs.size + map->frame_save.size + map->saved_regs.size + map->locals.size + map->parm_cache.size; diff --git a/bld/cg/risc/axp/c/axpsplit.c b/bld/cg/risc/axp/c/axpsplit.c index aa01dc83e3..dee79f4665 100644 --- a/bld/cg/risc/axp/c/axpsplit.c +++ b/bld/cg/risc/axp/c/axpsplit.c @@ -497,9 +497,9 @@ instruction *rMOVEXX_8( instruction *ins ) instruction *rCONSTLOAD( instruction *ins ) /**********************************************/ { - signed_16 high; - signed_16 low; - signed_16 extra; + int_16 high; + int_16 low; + int_16 extra; assert( ins->operands[0]->n.class == N_CONSTANT ); assert( ins->operands[0]->c.const_type == CONS_ABSOLUTE ); @@ -521,10 +521,10 @@ instruction *rCONSTLOAD( instruction *ins ) name *low_part; name *temp; name *cons; - unsigned_32 high; - unsigned_32 low; - unsigned_32 k; - unsigned_32 c; + uint_32 high; + uint_32 low; + uint_32 k; + uint_32 c; type_class_def index_type_class; bool cruft_in_high_dword; @@ -540,7 +540,7 @@ instruction *rCONSTLOAD( instruction *ins ) high += 1; low -= k; } - assert( ( (signed_16)high * k + (signed_16)low ) == c ); + assert( ( (int_16)high * k + (int_16)low ) == c ); high_part = AllocAddrConst( NULL, high, CONS_HIGH_ADDR, ins->type_class ); if( low == 0 ) { first_ins = MakeMove( high_part, ins->result, ins->type_class ); @@ -630,7 +630,7 @@ instruction *rALLOCA( instruction *ins ) name *amount; name *real_amount; name *temp; - unsigned_32 value; + uint_32 value; instruction *first; instruction *last; type_class_def type_class; diff --git a/bld/cg/risc/axp/h/axpenc.h b/bld/cg/risc/axp/h/axpenc.h index ebce9d854f..a48fafbba1 100644 --- a/bld/cg/risc/axp/h/axpenc.h +++ b/bld/cg/risc/axp/h/axpenc.h @@ -36,12 +36,12 @@ extern void GenCallLabelReg( pointer label, reg_idx reg ); extern void GenOPINS( uint_8 opcode, uint_8 function, reg_idx ra, reg_idx rb, reg_idx rc ); -extern void GenLOADS32( signed_32 value, reg_idx reg ); -extern void GenMEMINS( uint_8 opcode, reg_idx ra, reg_idx rb, signed_16 displacement ); -extern void GenLOAD( hw_reg_set dst, hw_reg_set src, signed_16 displacement ); -extern void GenFLOAD( hw_reg_set dst, hw_reg_set src, signed_16 displacement ); -extern void GenSTORE( hw_reg_set dst, signed_16 displacement, hw_reg_set src ); -extern void GenFSTORE( hw_reg_set dst, signed_16 displacement, hw_reg_set src ); +extern void GenLOADS32( int_32 value, reg_idx reg ); +extern void GenMEMINS( uint_8 opcode, reg_idx ra, reg_idx rb, int_16 displacement ); +extern void GenLOAD( hw_reg_set dst, hw_reg_set src, int_16 displacement ); +extern void GenFLOAD( hw_reg_set dst, hw_reg_set src, int_16 displacement ); +extern void GenSTORE( hw_reg_set dst, int_16 displacement, hw_reg_set src ); +extern void GenFSTORE( hw_reg_set dst, int_16 displacement, hw_reg_set src ); extern void GenReturn( void ); #if 0 extern void GenJumpIf( instruction *ins, pointer label ); diff --git a/bld/cg/risc/c/rscconst.c b/bld/cg/risc/c/rscconst.c index 86c0176fb5..50af00dc39 100644 --- a/bld/cg/risc/c/rscconst.c +++ b/bld/cg/risc/c/rscconst.c @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -33,20 +34,21 @@ #include "_cgstd.h" #include "rscconst.h" -void FactorInt32( signed_32 val, signed_16 *high, signed_16 *extra, signed_16 *low ) -//********************************************************************************** -// Factor a signed_32 value into 16-bit constants such that the following sequence -// ldah rn,high(r31) -// ldah rn,extra(rn) -// lda rn,low(rn) -// results in value, properly sign-extended, being in rn. +void FactorInt32( int_32 val, int_16 *high, int_16 *extra, int_16 *low ) +/*********************************************************************** + * Factor a int_32 value into 16-bit constants such that the following sequence + * ldah rn,high(r31) + * ldah rn,extra(rn) + * lda rn,low(rn) + * results in value, properly sign-extended, being in rn. + */ { - signed_16 h, l, e; - signed_32 tmp; + int_16 h, l, e; + int_32 tmp; e = 0; l = val & 0xffff; - tmp = val - (signed_32)l; + tmp = val - (int_32)l; h = (tmp >> 16) & 0xffff; if( val >= 0x7fff8000 ) { e = 0x4000; diff --git a/bld/cg/risc/c/rscdata.c b/bld/cg/risc/c/rscdata.c index ae9714628f..6b8dd5b1b0 100644 --- a/bld/cg/risc/c/rscdata.c +++ b/bld/cg/risc/c/rscdata.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2018 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -43,8 +43,8 @@ #include "feprotos.h" -void DataAlign( unsigned_32 align ) -/************************************/ +void DataAlign( uint_32 align ) +/********************************/ { offset curr_loc; uint modulus; @@ -60,24 +60,24 @@ void DataAlign( unsigned_32 align ) } } -void DataBytes( unsigned_32 len, const void *src ) -/***************************************************/ +void DataBytes( uint_32 len, const void *src ) +/***********************************************/ { TellOptimizerByPassed(); ObjBytes( src, len ); TellByPassOver(); } -void DataShort( unsigned_16 val ) -/**********************************/ +void DataShort( uint_16 val ) +/******************************/ { TellOptimizerByPassed(); ObjBytes( &val, sizeof( val ) ); TellByPassOver(); } -void DataLong( unsigned_32 val ) -/*********************************/ +void DataLong( uint_32 val ) +/*****************************/ { TellOptimizerByPassed(); ObjBytes( &val, sizeof( val ) ); diff --git a/bld/cg/risc/c/rscindex.c b/bld/cg/risc/c/rscindex.c index 06d8947f00..0197c02a12 100644 --- a/bld/cg/risc/c/rscindex.c +++ b/bld/cg/risc/c/rscindex.c @@ -151,7 +151,7 @@ static name *TruncImmediate( instruction *mem_ins, name *index ) { assert( index->n.class == N_INDEXED ); result = index; - if( index->i.constant != (signed_16)index->i.constant ) { + if( index->i.constant != (int_16)index->i.constant ) { // too big to fit into a signed-16 displacement on a memory operand temp = AllocTemp( I4 ); ins = MakeBinary( OP_ADD, index->i.index, AllocS32Const( index->i.constant ), temp, I4 ); diff --git a/bld/cg/risc/c/rscmul.c b/bld/cg/risc/c/rscmul.c index f5029488ad..c232f889c4 100644 --- a/bld/cg/risc/c/rscmul.c +++ b/bld/cg/risc/c/rscmul.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2018 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -36,8 +36,8 @@ #include "multiply.h" -int MulCost( unsigned_32 num ) -/********************************/ +int MulCost( uint_32 num ) +/****************************/ { /* unused parameters */ (void)num; diff --git a/bld/cg/risc/c/rscopt.c b/bld/cg/risc/c/rscopt.c index 6ae0cfd407..6d5ab03b0c 100644 --- a/bld/cg/risc/c/rscopt.c +++ b/bld/cg/risc/c/rscopt.c @@ -58,8 +58,8 @@ static instruction *AndResult( instruction *ins, type_class_def type_class ) order junk. */ { - signed_32 constant; - instruction *new_ins; + int_32 constant; + instruction *new_ins; if( type_class == U1 ) { constant = 0xFF; diff --git a/bld/cg/risc/c/rscsel.c b/bld/cg/risc/c/rscsel.c index 3f05a6508b..00c34e2cde 100644 --- a/bld/cg/risc/c/rscsel.c +++ b/bld/cg/risc/c/rscsel.c @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -73,8 +74,8 @@ cost_val IfCost( sel_handle s_node, int entries ) } -tbl_control *MakeScanTab( select_list *list, signed_32 hi, label_handle other, cg_type tipe, cg_type real_tipe ) -/**************************************************************************************************************/ +tbl_control *MakeScanTab( select_list *list, int_32 hi, label_handle other, cg_type tipe, cg_type real_tipe ) +/***********************************************************************************************************/ { /* unused parameters */ (void)list; (void)hi; (void)tipe; (void)other; (void)real_tipe; @@ -82,8 +83,8 @@ tbl_control *MakeScanTab( select_list *list, signed_32 hi, label_handle other, c } -tbl_control *MakeJmpTab( select_list *list, signed_32 lo, signed_32 hi, label_handle other ) -/******************************************************************************************/ +tbl_control *MakeJmpTab( select_list *list, int_32 lo, int_32 hi, label_handle other ) +/************************************************************************************/ { /* unused parameters */ (void)list; (void)lo; (void)hi; (void)other; diff --git a/bld/cg/risc/c/rscsplit.c b/bld/cg/risc/c/rscsplit.c index 7b50873e2f..908d9852ed 100644 --- a/bld/cg/risc/c/rscsplit.c +++ b/bld/cg/risc/c/rscsplit.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -413,7 +413,7 @@ instruction *rMOVEXX( instruction *ins ) name *TrimConst( name *c, type_class_def type_class ) /******************************************************/ { - signed_32 value; + int_32 value; switch( type_class ) { case U1: @@ -423,10 +423,10 @@ name *TrimConst( name *c, type_class_def type_class ) value = (signed_8)c->c.lo.int_value; break; case U2: - value = (unsigned_16)c->c.lo.int_value; + value = (uint_16)c->c.lo.int_value; break; case I2: - value = (signed_16)c->c.lo.int_value; + value = (int_16)c->c.lo.int_value; break; case U4: case I4: @@ -525,7 +525,7 @@ name *Int64Equivalent( name *name ) constant_defn *defn; defn = GetFloat( name, FD ); - return( AllocU64Const( *(unsigned_32 *)( defn->value + 0 ), *(unsigned_32 *)( defn->value + 2 ) ) ); + return( AllocU64Const( *(uint_32 *)( defn->value + 0 ), *(uint_32 *)( defn->value + 2 ) ) ); } name *LowPart( name *tosplit, type_class_def type_class ) @@ -539,8 +539,8 @@ name *LowPart( name *tosplit, type_class_def type_class ) name *new; signed_8 s8; unsigned_8 u8; - signed_16 s16; - unsigned_16 u16; + int_16 s16; + uint_16 u16; constant_defn *floatval; new = NULL; @@ -567,7 +567,7 @@ name *LowPart( name *tosplit, type_class_def type_class ) _Zoiks( ZOIKS_129 ); } else { /* FD */ floatval = GetFloat( tosplit, FD ); - new = AllocConst( CFCnvU32F( _TargetLongInt( *(unsigned_32 *)( floatval->value + 0 ) ) ) ); + new = AllocConst( CFCnvU32F( _TargetLongInt( *(uint_32 *)( floatval->value + 0 ) ) ) ); } #if 0 } else if( tosplit->c.const_type == CONS_ADDRESS ) { @@ -621,8 +621,8 @@ name *HighPart( name *tosplit, type_class_def type_class ) name *new; signed_8 s8; unsigned_8 u8; - signed_16 s16; - unsigned_16 u16; + int_16 s16; + uint_16 u16; constant_defn *floatval; new = NULL; @@ -649,7 +649,7 @@ name *HighPart( name *tosplit, type_class_def type_class ) _Zoiks( ZOIKS_129 ); } else { /* FD */ floatval = GetFloat( tosplit, FD ); - new = AllocConst( CFCnvU32F( _TargetLongInt( *(unsigned_32 *)( floatval->value + 2 ) ) ) ); + new = AllocConst( CFCnvU32F( _TargetLongInt( *(uint_32 *)( floatval->value + 2 ) ) ) ); } #if 0 } else if( tosplit->c.const_type == CONS_ADDRESS ) { diff --git a/bld/cg/risc/h/offset.h b/bld/cg/risc/h/offset.h index 87a3955cec..5599c26052 100644 --- a/bld/cg/risc/h/offset.h +++ b/bld/cg/risc/h/offset.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -32,8 +33,8 @@ #ifndef _OFFSET_H #define _OFFSET_H -typedef unsigned_16 short_offset; -typedef unsigned_32 long_offset; -typedef unsigned_32 offset; +typedef uint_16 short_offset; +typedef uint_32 long_offset; +typedef uint_32 offset; #endif diff --git a/bld/cg/risc/h/rscconst.h b/bld/cg/risc/h/rscconst.h index 920fa3a373..162cf9437c 100644 --- a/bld/cg/risc/h/rscconst.h +++ b/bld/cg/risc/h/rscconst.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -30,4 +31,4 @@ ****************************************************************************/ -extern void FactorInt32( signed_32 val, signed_16 *high, signed_16 *extra, signed_16 *low ); +extern void FactorInt32( int_32 val, int_16 *high, int_16 *extra, int_16 *low ); diff --git a/bld/cg/risc/mps/c/mpssetc.c b/bld/cg/risc/mps/c/mpssetc.c index 51cc2c7b5c..d3b5fc3782 100644 --- a/bld/cg/risc/mps/c/mpssetc.c +++ b/bld/cg/risc/mps/c/mpssetc.c @@ -81,8 +81,8 @@ static bool isNiceCondIns( instruction *ins ) } -static instruction *SetToConst( block *blk, signed_32 *pcons ) -/*****************************************************************/ +static instruction *SetToConst( block *blk, int_32 *pcons ) +/**************************************************************/ { instruction *ins; instruction *next; @@ -111,8 +111,8 @@ static instruction *SetToConst( block *blk, signed_32 *pcons ) static bool FindFlowOut( block *blk ) /***************************************/ { - signed_32 false_cons; - signed_32 true_cons; + int_32 false_cons; + int_32 true_cons; instruction *ins; instruction *ins0; instruction *ins1; @@ -183,8 +183,8 @@ static bool FindFlowOut( block *blk ) /* Replace 'x <= const' with 'x < const + 1' */ if( oc == OP_CMP_LESS_EQUAL || oc == OP_CMP_GREATER_EQUAL ) { - signed_32 value; - name *op1; + int_32 value; + name *op1; op1 = ins->operands[1]; assert( op1->n.class == N_CONSTANT && op1->c.const_type == CONS_ABSOLUTE ); diff --git a/bld/cg/risc/mps/c/mpssplit.c b/bld/cg/risc/mps/c/mpssplit.c index 80f01e0c71..038b07eead 100644 --- a/bld/cg/risc/mps/c/mpssplit.c +++ b/bld/cg/risc/mps/c/mpssplit.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -152,14 +152,14 @@ instruction *rMOVEXX_8( instruction *ins ) instruction *rCONSTLOAD( instruction *ins ) /*****************************************/ { - unsigned_32 low; - unsigned_32 high; - unsigned_32 c; - name *high_part; - name *temp; - instruction *first_ins; - instruction *new_ins; - type_class_def type_class; + uint_32 low; + uint_32 high; + uint_32 c; + name *high_part; + name *temp; + instruction *first_ins; + instruction *new_ins; + type_class_def type_class; assert( ins->operands[0]->n.class == N_CONSTANT ); assert( ins->operands[0]->c.const_type == CONS_ABSOLUTE ); @@ -257,7 +257,7 @@ instruction *rALLOCA( instruction *ins ) name *amount; name *real_amount; name *temp; - unsigned_32 value; + uint_32 value; instruction *first; instruction *last; type_class_def type_class; @@ -341,7 +341,7 @@ instruction *rM_SIMPCMP( instruction *ins ) /* Special reduction: use OP_SET_LESS but increment constant */ if( (ins->operands[1]->n.class == N_CONSTANT) && (ins->operands[1]->c.const_type == CONS_ABSOLUTE) ) { - signed_32 value; + int_32 value; opcode = OP_SET_LESS; // TODO: we may be leaking memory here by losing track of the diff --git a/bld/cg/risc/mps/h/mpsenc.h b/bld/cg/risc/mps/h/mpsenc.h index d633211e9a..753fed3eda 100644 --- a/bld/cg/risc/mps/h/mpsenc.h +++ b/bld/cg/risc/mps/h/mpsenc.h @@ -35,9 +35,9 @@ extern void GenCallLabelReg( pointer label, reg_idx reg ); -extern void GenLOADS32( signed_32 value, reg_idx reg ); -extern void GenMEMINS( uint_8 opcode, reg_idx rt, reg_idx rs, signed_16 displacement ); -extern void GenIType( uint_8 opcode, reg_idx rt, reg_idx rs, signed_16 immed ); +extern void GenLOADS32( int_32 value, reg_idx reg ); +extern void GenMEMINS( uint_8 opcode, reg_idx rt, reg_idx rs, int_16 displacement ); +extern void GenIType( uint_8 opcode, reg_idx rt, reg_idx rs, int_16 immed ); extern void GenRType( uint_8 opcode, uint_8 fc, reg_idx rd, reg_idx rs, reg_idx rt ); extern void GenIShift( uint_8 fc, reg_idx rd, reg_idx rt, uint_8 sa ); extern void GenJType( uint_8 opcode, pointer label ); diff --git a/bld/cg/risc/ppc/c/ppcenc.c b/bld/cg/risc/ppc/c/ppcenc.c index 840543cc66..a535303b8e 100644 --- a/bld/cg/risc/ppc/c/ppcenc.c +++ b/bld/cg/risc/ppc/c/ppcenc.c @@ -276,8 +276,8 @@ void GenOPINS( gen_opcode op1, gen_opcode op2, reg_idx a, reg_idx b, reg_idx } -void GenOPIMM( gen_opcode op1, reg_idx d, reg_idx a, signed_16 immed ) -//*********************************************************************** +void GenOPIMM( gen_opcode op1, reg_idx d, reg_idx a, int_16 immed ) +//******************************************************************** { ins_encoding = _Opcode( op1 ) | _D( d ) | _A( a ) | _SignedImmed( immed ); _EmitIns( ins_encoding ); @@ -296,8 +296,8 @@ void GenMTSPR( reg_idx d, uint_32 spr, bool from ) } -void GenMEMINS( gen_opcode op, reg_idx d, reg_idx i, signed_16 displacement ) -/******************************************************************************/ +void GenMEMINS( gen_opcode op, reg_idx d, reg_idx i, int_16 displacement ) +/***************************************************************************/ { ins_encoding = _Opcode( op ) | _D( d ) | _A( i ) | _SignedImmed( displacement ); _EmitIns( ins_encoding ); @@ -333,8 +333,8 @@ static void GenCMP( gen_opcode op, gen_opcode op2, reg_idx a, reg_idx b ) } -static void GenCMPIMM( gen_opcode op, reg_idx a, signed_16 imm ) -/*****************************************************************/ +static void GenCMPIMM( gen_opcode op, reg_idx a, int_16 imm ) +/**************************************************************/ { ins_encoding = _Opcode( op ) | _A( a ) | _SignedImmed( imm ); _EmitIns( ins_encoding ); @@ -424,7 +424,7 @@ static void getMemEncoding( name *mem, reg_idx *regidx_mem, int_16 *offset ) case N_INDEXED: assert( mem->i.index->n.class == N_REGISTER ); assert( mem->i.scale == 0 ); - assert( mem->i.constant == (type_length)((signed_16)mem->i.constant) ); + assert( mem->i.constant == (type_length)((int_16)mem->i.constant) ); assert( ( mem->i.index_flags & X_LOW_ADDR_BASE ) == 0 ); *regidx_mem = RegTrans( mem->i.index->r.reg ); *offset = (int_16)mem->i.constant; @@ -611,7 +611,7 @@ static void Encode( instruction *ins ) gen_opcode op1; gen_opcode op2; gen_opcode *ops; - signed_16 mem_offset; + int_16 mem_offset; reg_idx regidx_mem; diff --git a/bld/cg/risc/ppc/c/ppcproc.c b/bld/cg/risc/ppc/c/ppcproc.c index baef3dda62..d1bf282281 100644 --- a/bld/cg/risc/ppc/c/ppcproc.c +++ b/bld/cg/risc/ppc/c/ppcproc.c @@ -185,8 +185,8 @@ static void genMove( reg_idx src, reg_idx dst ) GenOPINS( 31, 444, dst, src, src ); } -static void genAdd( reg_idx src, signed_16 disp, reg_idx dst ) -/****************************************************************/ +static void genAdd( reg_idx src, int_16 disp, reg_idx dst ) +/*************************************************************/ { GenOPIMM( ADDI_OPCODE, dst, src, disp ); } @@ -366,10 +366,10 @@ static void emitStackHeaderEpilog( stack_record *stk ) } -static signed_32 frameSize( stack_map *map ) -/*******************************************/ +static int_32 frameSize( stack_map *map ) +/*****************************************/ { - signed_32 size; + int_32 size; size = map->varargs.size + map->slop.size + map->saved_regs.size + map->locals.size + map->parm_cache.size + map->stack_header.size; diff --git a/bld/cg/risc/ppc/c/ppcsplit.c b/bld/cg/risc/ppc/c/ppcsplit.c index 197d14dcf0..e6b6ce7cde 100644 --- a/bld/cg/risc/ppc/c/ppcsplit.c +++ b/bld/cg/risc/ppc/c/ppcsplit.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -50,14 +50,14 @@ instruction *rCONSTLOAD( instruction *ins ) /**********************************************/ { - unsigned_32 low; - unsigned_32 high; - unsigned_32 c; - name *high_part; - name *temp; - instruction *first_ins; - instruction *new_ins; - type_class_def type_class; + uint_32 low; + uint_32 high; + uint_32 c; + name *high_part; + name *temp; + instruction *first_ins; + instruction *new_ins; + type_class_def type_class; assert( ins->operands[0]->n.class == N_CONSTANT ); assert( ins->operands[0]->c.const_type == CONS_ABSOLUTE ); diff --git a/bld/cg/risc/ppc/h/ppcenc.h b/bld/cg/risc/ppc/h/ppcenc.h index 47bebccb79..cd98a90d6b 100644 --- a/bld/cg/risc/ppc/h/ppcenc.h +++ b/bld/cg/risc/ppc/h/ppcenc.h @@ -36,8 +36,8 @@ typedef uint_32 gen_opcode; -extern void GenMEMINS( gen_opcode, reg_idx, reg_idx, signed_16 ); +extern void GenMEMINS( gen_opcode, reg_idx, reg_idx, int_16 ); extern void GenOPINS( gen_opcode, gen_opcode, reg_idx, reg_idx, reg_idx ); -extern void GenOPIMM( gen_opcode, reg_idx, reg_idx, signed_16 ); +extern void GenOPIMM( gen_opcode, reg_idx, reg_idx, int_16 ); extern void GenMTSPR( reg_idx, uint_32, bool ); extern void GenReturn( void ); From 31972ca3e83d061bcff0dff2213c7cbe39c4e2ea Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Mon, 9 Oct 2023 19:52:46 +0200 Subject: [PATCH 229/258] use ZERO_REG_IDX macro for register containing 0 value --- bld/cg/risc/axp/c/axpenc.c | 2 +- bld/cg/risc/ppc/c/ppcenc.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bld/cg/risc/axp/c/axpenc.c b/bld/cg/risc/axp/c/axpenc.c index f5618b0719..31b4f7e48b 100644 --- a/bld/cg/risc/axp/c/axpenc.c +++ b/bld/cg/risc/axp/c/axpenc.c @@ -799,7 +799,7 @@ static void Encode( instruction *ins ) assert( ins->operands[0]->n.class == N_REGISTER ); assert( ins->result->n.class == N_REGISTER ); GenFPOPINS( 0x16, 0xac, - 31, _NameRegTrans( ins->operands[0] ), + ZERO_REG_IDX, _NameRegTrans( ins->operands[0] ), _NameRegTrans( ins->result ) ); break; case G_FREGTOMI8: diff --git a/bld/cg/risc/ppc/c/ppcenc.c b/bld/cg/risc/ppc/c/ppcenc.c index a535303b8e..655a5e1974 100644 --- a/bld/cg/risc/ppc/c/ppcenc.c +++ b/bld/cg/risc/ppc/c/ppcenc.c @@ -477,14 +477,14 @@ static void doSign( instruction *ins ) /* * extsb */ - GenOPINS( 31, 954, _NameRegTrans( ins->result ), 0, _NameRegTrans( ins->operands[0] ) ); + GenOPINS( 31, 954, _NameRegTrans( ins->result ), ZERO_REG_IDX, _NameRegTrans( ins->operands[0] ) ); break; case U2: case I2: /* * extsh */ - GenOPINS( 31, 922, _NameRegTrans( ins->result ), 0, _NameRegTrans( ins->operands[0] ) ); + GenOPINS( 31, 922, _NameRegTrans( ins->result ), ZERO_REG_IDX, _NameRegTrans( ins->operands[0] ) ); break; default: _Zoiks( ZOIKS_091 ); @@ -619,7 +619,7 @@ static void Encode( instruction *ins ) case G_MOVE_FP: assert( ins->result->n.class == N_REGISTER ); assert( ins->operands[0]->n.class == N_REGISTER ); - GenOPINS( 63, 72, 0, _NameRegTrans( ins->operands[0] ), _NameRegTrans( ins->result ) ); + GenOPINS( 63, 72, ZERO_REG_IDX, _NameRegTrans( ins->operands[0] ), _NameRegTrans( ins->result ) ); break; case G_MOVE: // or op, op -> dst @@ -803,7 +803,7 @@ static void Encode( instruction *ins ) switch( ins->head.opcode ) { case OP_NEGATE: // neg src -> dst - GenOPINS( 31, 104, a, 0, s ); + GenOPINS( 31, 104, a, ZERO_REG_IDX, s ); break; case OP_COMPLEMENT: GenOPINS( 31, 124, a, a, s ); From 9abdad787450b43c1efa5a0a59b5a9931e395179 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Mon, 9 Oct 2023 22:15:00 +0200 Subject: [PATCH 230/258] cleanup cg code --- bld/cg/intel/c/x86enc.c | 40 +++++++++++++++------------- bld/cg/intel/h/x86regn.h | 10 +++---- bld/cg/risc/axp/c/axprgtbl.c | 51 ++++++++++++++++++------------------ bld/cg/risc/axp/h/axpregn.h | 8 +++--- bld/cg/risc/mps/c/mpsrgtbl.c | 31 +++++++++++----------- bld/cg/risc/mps/h/mpsregn.h | 9 +++---- bld/cg/risc/ppc/c/ppcrgtbl.c | 29 ++++++++++---------- bld/cg/risc/ppc/h/ppcregn.h | 8 +++--- 8 files changed, 96 insertions(+), 90 deletions(-) diff --git a/bld/cg/intel/c/x86enc.c b/bld/cg/intel/c/x86enc.c index f650a36451..bbdc8c8b93 100644 --- a/bld/cg/intel/c/x86enc.c +++ b/bld/cg/intel/c/x86enc.c @@ -250,7 +250,7 @@ void EmitOffset( offset i ) ICur += sizeof( offset ); } -static void TransferIns( void ) +static void TransferIns( void ) /********************************** * Transfer an instruction from Inst[] to Temp */ @@ -295,7 +295,7 @@ void Finalize( void ) } -static void LayInitial( instruction *ins, gentype gen ) +static void LayInitial( instruction *ins, gentype gen ) /********************************************************** * Do some really magical jiggery pokery based on "gen" to get the * right opcode int Inst[]. See PCCodeTable if you want, but this is @@ -356,12 +356,12 @@ static void LayInitial( instruction *ins, gentype gen ) } } -static byte SegTrans( hw_reg_set regs ) +static reg_idx SegTrans( hw_reg_set regs ) /****************************************** * Return the encoding of a segment register name */ { - int i; + int i; HW_COnlyOn( regs, HW_SEGS ); for( i = ARCH_SEG_START; i < ARCH_SEG_END; i++ ) { @@ -375,10 +375,10 @@ static byte SegTrans( hw_reg_set regs ) reg_idx RegTrans( hw_reg_set regs ) /*********************************** - * Return the encoding of a register name + * Return the arch index of a register name */ { - int i; + int i; HW_CTurnOff( regs, HW_SEGS ); for( i = ARCH_GPR_START; i < ARCH_GPR_END; i++ ) { @@ -390,26 +390,28 @@ reg_idx RegTrans( hw_reg_set regs ) return( 0 ); } -static int FPRegTrans( hw_reg_set regs ) -/**************************************/ +static int FPRegTrans( hw_reg_set reg ) +/*************************************/ { int i; for( i = ARCH_FPR_START; i < ARCH_FPR_END; i++ ) { - if( HW_Equal( regs, RegsTab[i].hw_reg ) ) { + if( HW_Equal( reg, RegsTab[i].hw_reg ) ) { return( RegsTab[i].idx ); } } - return( -1 ); + return( 0 ); } -dw_regs RegTransDW( hw_reg_set regs ) -/***********************************/ +dw_regs RegTransDW( hw_reg_set reg ) +/*********************************** + * Translate reg to Dwarf enum name + */ { - int i; + int i; for( i = ARCH_IDX_START; i < ARCH_IDX_END; i++ ) { - if( HW_Equal( regs, RegsTab[i].hw_reg ) ) { + if( HW_Equal( reg, RegsTab[i].hw_reg ) ) { return( RegsTab[i].dw_idx ); } } @@ -418,13 +420,15 @@ dw_regs RegTransDW( hw_reg_set regs ) } -int RegTransWV( hw_reg_set regs ) -/*******************************/ +int RegTransWV( hw_reg_set reg ) +/******************************* + * Translate reg to WATCOM enum name + */ { - int i; + int i; for( i = ARCH_IDX_START; i < ARCH_IDX_END; i++ ) { - if( HW_Equal( regs, RegsTab[i].hw_reg ) ) { + if( HW_Equal( reg, RegsTab[i].hw_reg ) ) { return( RegsTab[i].wv_idx ); } } diff --git a/bld/cg/intel/h/x86regn.h b/bld/cg/intel/h/x86regn.h index d387b5dc3b..da72b060ea 100644 --- a/bld/cg/intel/h/x86regn.h +++ b/bld/cg/intel/h/x86regn.h @@ -57,11 +57,11 @@ typedef enum { typedef uint_8 reg_idx; typedef struct arch_reg_info { - hw_reg_set hw_reg; - reg_idx idx; - reg_cls cls; - wv_regs wv_idx; - dw_regs dw_idx; + hw_reg_set hw_reg; + reg_idx idx; + reg_cls cls; + wv_regs wv_idx; + dw_regs dw_idx; } arch_reg_info; extern const arch_reg_info RegsTab[]; diff --git a/bld/cg/risc/axp/c/axprgtbl.c b/bld/cg/risc/axp/c/axprgtbl.c index e8f199d129..203f579290 100644 --- a/bld/cg/risc/axp/c/axprgtbl.c +++ b/bld/cg/risc/axp/c/axprgtbl.c @@ -257,9 +257,9 @@ static hw_reg_set FloatRegs[] = { }; /* -* NOTE: ordering is important here - see state->curr_entry -* and relating code in ParmReg and CallState. BBB -*/ + * NOTE: ordering is important here - see state->curr_entry + * and relating code in ParmReg and CallState. + */ static hw_reg_set AllParmRegs[] = { HW_D_1( HW_R16 ), @@ -406,12 +406,13 @@ hw_reg_set GetArchReg( int idx, reg_cls cls ) } #endif -/* Information for register set intersections - * if sets are of different classes { - * intersection is empty - * } else { - * intersection given in square matrix for class - * } +/* + * Information for register set intersections + * if sets are of different classes { + * intersection is empty + * } else { + * intersection given in square matrix for class + * } */ reg_set_index RegIntersect( reg_set_index s1, reg_set_index s2 ) @@ -860,7 +861,7 @@ reg_idx RegTrans( hw_reg_set regs ) * Translate reg to register index */ { - int i; + int i; for( i = ARCH_IDX_START; i < ARCH_IDX_END; i++ ) { if( HW_Equal( regs, RegsTab[i].hw_reg ) ) { @@ -871,9 +872,9 @@ reg_idx RegTrans( hw_reg_set regs ) } int GetArchIndex( hw_reg_set regs ) -/***********************************************/ +/*********************************/ { - int i; + int i; for( i = ARCH_IDX_START; i < ARCH_IDX_END; i++ ) { if( HW_Equal( regs, RegsTab[i].hw_reg ) ) { @@ -883,15 +884,15 @@ int GetArchIndex( hw_reg_set regs ) return( 0 ); } -dw_regs RegTransDW( hw_reg_set regs ) -/************************************** - * Translate reg to register index +dw_regs RegTransDW( hw_reg_set reg ) +/************************************* + * Translate reg to Dwarf enum name */ { - int i; + int i; for( i = ARCH_IDX_START; i < ARCH_IDX_END; i++ ) { - if( HW_Equal( regs, RegsTab[i].hw_reg ) ) { + if( HW_Equal( reg, RegsTab[i].hw_reg ) ) { return( RegsTab[i].dw_idx ); } } @@ -901,14 +902,14 @@ dw_regs RegTransDW( hw_reg_set regs ) hw_reg_set FirstReg( reg_set_index regs_idx ) /************************************************* - The table RTInfo[] uses reg_set_indexes instead of hw_reg_sets since - they are only one byte long. This retrieves the first hw_reg_set - from the reg_set table "index". - - the tables above use RL_ consts rather that hw_reg_sets cause - it cheaper. This just picks off the first register from a - register list and returns it. -*/ + * The table RTInfo[] uses reg_set_indexes instead of hw_reg_sets since + * they are only one byte long. This retrieves the first hw_reg_set + * from the reg_set table "index". + * + * the tables above use RL_ consts rather that hw_reg_sets cause + * it cheaper. This just picks off the first register from a + * register list and returns it. + */ { return( *RegSets[regs_idx] ); } diff --git a/bld/cg/risc/axp/h/axpregn.h b/bld/cg/risc/axp/h/axpregn.h index 35988a2d9a..4f1dd6184a 100644 --- a/bld/cg/risc/axp/h/axpregn.h +++ b/bld/cg/risc/axp/h/axpregn.h @@ -46,10 +46,10 @@ typedef enum { typedef uint_8 reg_idx; typedef struct arch_reg_info { - hw_reg_set hw_reg; - reg_idx idx; - reg_cls cls; - dw_regs dw_idx; + hw_reg_set hw_reg; + reg_idx idx; + reg_cls cls; + dw_regs dw_idx; } arch_reg_info; extern const arch_reg_info RegsTab[]; diff --git a/bld/cg/risc/mps/c/mpsrgtbl.c b/bld/cg/risc/mps/c/mpsrgtbl.c index d88361a96d..b9cc027117 100644 --- a/bld/cg/risc/mps/c/mpsrgtbl.c +++ b/bld/cg/risc/mps/c/mpsrgtbl.c @@ -296,7 +296,7 @@ static hw_reg_set FloatRegs[] = { /* * NOTE: ordering is important here - see state->curr_entry - * and relating code in ParmReg and CallState. BBB + * and relating code in ParmReg and CallState. */ static hw_reg_set AllParmRegs[] = { @@ -432,12 +432,13 @@ hw_reg_set GetArchReg( int idx, reg_cls cls ) } #endif -/* Information for register set intersections - * if sets are of different classes { - * intersection is empty - * } else { - * intersection given in square matrix for class - * } +/* + * Information for register set intersections + * if sets are of different classes { + * intersection is empty + * } else { + * intersection given in square matrix for class + * } */ reg_set_index RegIntersect( reg_set_index s1, reg_set_index s2 ) @@ -921,7 +922,7 @@ reg_idx RegTrans( hw_reg_set regs ) * Translate reg to register index */ { - int i; + int i; for( i = ARCH_IDX_START; i < ARCH_IDX_END; i++ ) { if( HW_Equal( regs, RegsTab[i].hw_reg ) ) { @@ -932,9 +933,9 @@ reg_idx RegTrans( hw_reg_set regs ) } int GetArchIndex( hw_reg_set regs ) -/***********************************************/ +/*********************************/ { - int i; + int i; for( i = ARCH_IDX_START; i < ARCH_IDX_END; i++ ) { if( HW_Equal( regs, RegsTab[i].hw_reg ) ) { @@ -945,15 +946,15 @@ int GetArchIndex( hw_reg_set regs ) } -dw_regs RegTransDW( hw_reg_set regs ) -/************************************** - * Translate reg to register index +dw_regs RegTransDW( hw_reg_set reg ) +/*********************************** + * Translate reg to Dwarf enum name */ { - int i; + int i; for( i = ARCH_IDX_START; i < ARCH_IDX_END; i++ ) { - if( HW_Equal( regs, RegsTab[i].hw_reg ) ) { + if( HW_Equal( reg, RegsTab[i].hw_reg ) ) { return( RegsTab[i].dw_idx ); } } diff --git a/bld/cg/risc/mps/h/mpsregn.h b/bld/cg/risc/mps/h/mpsregn.h index ce1d5db949..5253abbfe3 100644 --- a/bld/cg/risc/mps/h/mpsregn.h +++ b/bld/cg/risc/mps/h/mpsregn.h @@ -58,14 +58,13 @@ typedef enum { typedef uint_8 reg_idx; typedef struct arch_reg_info { - hw_reg_set hw_reg; - reg_idx idx; - reg_cls cls; - dw_regs dw_idx; + hw_reg_set hw_reg; + reg_idx idx; + reg_cls cls; + dw_regs dw_idx; } arch_reg_info; extern const arch_reg_info RegsTab[]; -extern hw_reg_set GetFPReg( int idx ); extern reg_idx RegTrans( hw_reg_set reg ); extern dw_regs RegTransDW( hw_reg_set reg ); diff --git a/bld/cg/risc/ppc/c/ppcrgtbl.c b/bld/cg/risc/ppc/c/ppcrgtbl.c index f336cdb82d..6a8576bcd1 100644 --- a/bld/cg/risc/ppc/c/ppcrgtbl.c +++ b/bld/cg/risc/ppc/c/ppcrgtbl.c @@ -264,7 +264,7 @@ static hw_reg_set FloatRegs[] = { /* * NOTE: ordering is important here - see state->curr_entry - * and relating code in ParmReg and CallState. BBB + * and relating code in ParmReg and CallState. */ static hw_reg_set AllParmRegs[] = { @@ -418,12 +418,13 @@ hw_reg_set GetArchReg( int idx, reg_cls cls ) } #endif -/* Information for register set intersections - * if sets are of different classes { - * intersection is empty - * } else { - * intersection given in square matrix for class - * } +/* + * Information for register set intersections + * if sets are of different classes { + * intersection is empty + * } else { + * intersection given in square matrix for class + * } */ reg_set_index RegIntersect( reg_set_index s1, reg_set_index s2 ) @@ -854,7 +855,7 @@ reg_idx RegTrans( hw_reg_set regs ) * Translate reg to register index */ { - int i; + int i; for( i = ARCH_IDX_START; i < ARCH_IDX_END; i++ ) { if( HW_Equal( regs, RegsTab[i].hw_reg ) ) { @@ -867,7 +868,7 @@ reg_idx RegTrans( hw_reg_set regs ) int GetArchIndex( hw_reg_set regs ) /*********************************/ { - int i; + int i; for( i = ARCH_IDX_START; i < ARCH_IDX_END; i++ ) { if( HW_Equal( regs, RegsTab[i].hw_reg ) ) { @@ -877,15 +878,15 @@ int GetArchIndex( hw_reg_set regs ) return( 0 ); } -dw_regs RegTransDW( hw_reg_set regs ) -/************************************** - * Translate reg to enum name +dw_regs RegTransDW( hw_reg_set reg ) +/************************************* + * Translate reg to Dwarf enum name */ { - int i; + int i; for( i = ARCH_IDX_START; i < ARCH_IDX_END; i++ ) { - if( HW_Equal( regs, RegsTab[i].hw_reg ) ) { + if( HW_Equal( reg, RegsTab[i].hw_reg ) ) { return( RegsTab[i].dw_idx ); } } diff --git a/bld/cg/risc/ppc/h/ppcregn.h b/bld/cg/risc/ppc/h/ppcregn.h index 89c502bc67..8cf56a6568 100644 --- a/bld/cg/risc/ppc/h/ppcregn.h +++ b/bld/cg/risc/ppc/h/ppcregn.h @@ -46,10 +46,10 @@ typedef enum { typedef uint_8 reg_idx; typedef struct arch_reg_info { - hw_reg_set hw_reg; - reg_idx idx; - reg_cls cls; - dw_regs dw_idx; + hw_reg_set hw_reg; + reg_idx idx; + reg_cls cls; + dw_regs dw_idx; } arch_reg_info; extern const arch_reg_info RegsTab[]; From e391191f9c3964a5cc3b752304ce4a9359e6ca9d Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Tue, 10 Oct 2023 02:21:34 +0200 Subject: [PATCH 231/258] cleanup cg code correct some symbol names to be consistent with other cg code reformat source files --- bld/cg/intel/c/x86enc.c | 10 ++--- bld/cg/risc/axp/c/axpenc.c | 82 +++++++++++++++++++------------------- bld/cg/risc/mps/c/mpsenc.c | 82 +++++++++++++++++++------------------- bld/cg/risc/ppc/c/ppcenc.c | 28 ++++++------- 4 files changed, 101 insertions(+), 101 deletions(-) diff --git a/bld/cg/intel/c/x86enc.c b/bld/cg/intel/c/x86enc.c index bbdc8c8b93..190ffce1f8 100644 --- a/bld/cg/intel/c/x86enc.c +++ b/bld/cg/intel/c/x86enc.c @@ -2148,23 +2148,23 @@ void GenObjCode( instruction *ins ) { uint ins_loc; byte extra_bits; - byte reg_index; + reg_idx reg_seg; ins_loc = KEY; if( ins->head.opcode == OP_POP ) { extra_bits = B_KEY_POPSEG; - reg_index = SegTrans( result->r.reg ); + reg_seg = SegTrans( result->r.reg ); } else { extra_bits = 0; - reg_index = SegTrans( left->r.reg ); + reg_seg = SegTrans( left->r.reg ); } - if( reg_index > 3 ) { + if( reg_seg > 3 ) { ins_loc += 1; Inst[KEY] = 0x0f; AddByte( 0x80 ); } Inst[ins_loc] |= extra_bits; - Inst[ins_loc] |= reg_index << S_KEY_SR; + Inst[ins_loc] |= reg_seg << S_KEY_SR; } break; case G_MOVAM: diff --git a/bld/cg/risc/axp/c/axpenc.c b/bld/cg/risc/axp/c/axpenc.c index 31b4f7e48b..97e1d1c576 100644 --- a/bld/cg/risc/axp/c/axpenc.c +++ b/bld/cg/risc/axp/c/axpenc.c @@ -533,8 +533,8 @@ static void doCall( instruction *ins ) } } -static void addressTemp( name *temp, reg_idx *regidx_mem, int_16 *offset ) -/****************************************************************************/ +static void addressTemp( name *temp, reg_idx *reg_mem, int_16 *offset ) +/*********************************************************************/ { type_length temp_offset; @@ -546,18 +546,18 @@ static void addressTemp( name *temp, reg_idx *regidx_mem, int_16 *offset ) GenLOADS32( temp_offset, AT_REG_IDX ); GenOPINS( 0x10, 0x00, SP_REG_IDX, AT_REG_IDX, AT_REG_IDX ); *offset = 0; - *regidx_mem = AT_REG_IDX; + *reg_mem = AT_REG_IDX; } else { *offset = temp_offset; - *regidx_mem = SP_REG_IDX; + *reg_mem = SP_REG_IDX; if( CurrProc->targ.base_is_fp ) { - *regidx_mem = FP_REG_IDX; + *reg_mem = FP_REG_IDX; } } } -static void getMemEncoding( name *mem, reg_idx *regidx_mem, int_16 *offset ) -/*****************************************************************************/ +static void getMemEncoding( name *mem, reg_idx *reg_mem, int_16 *offset ) +/***********************************************************************/ { switch( mem->n.class ) { case N_INDEXED: @@ -565,28 +565,28 @@ static void getMemEncoding( name *mem, reg_idx *regidx_mem, int_16 *offset ) assert( mem->i.scale == 0 ); assert( mem->i.constant == (type_length)((int_16)mem->i.constant) ); assert( ( mem->i.index_flags & X_LOW_ADDR_BASE ) == 0 ); - *regidx_mem = _NameRegTrans( mem->i.index ); + *reg_mem = _NameRegTrans( mem->i.index ); *offset = (int_16)mem->i.constant; break; case N_TEMP: - addressTemp( mem, regidx_mem, offset ); + addressTemp( mem, reg_mem, offset ); break; case N_MEMORY: default: - *regidx_mem = ZERO_REG_IDX; + *reg_mem = ZERO_REG_IDX; *offset = 0; _Zoiks( ZOIKS_078 ); break; } } -static void doLoadStore( instruction *ins, bool load ) -/********************************************************/ +static void doLoadStore( instruction *ins, bool load ) +/****************************************************/ { name *mem; name *reg; uint_8 opcode; - reg_idx regidx_mem; + reg_idx reg_mem; int_16 offset; if( load ) { @@ -605,31 +605,31 @@ static void doLoadStore( instruction *ins, bool load ) } } assert( reg->n.class == N_REGISTER ); - getMemEncoding( mem, ®idx_mem, &offset ); - GenMEMINS( opcode, _NameRegTrans( reg ), regidx_mem, offset ); + getMemEncoding( mem, ®_mem, &offset ); + GenMEMINS( opcode, _NameRegTrans( reg ), reg_mem, offset ); } static void GenCallIndirect( instruction *call ) /**************************************************/ { - reg_idx regidx; - reg_idx regidx_mem; + reg_idx reg_addr; + reg_idx reg_mem; int_16 mem_offset; name *addr; - regidx = AT_REG_IDX; /* use the volatile scratch reg if possible */ + reg_addr = AT_REG_IDX; /* use the volatile scratch reg if possible */ addr = call->operands[CALL_OP_ADDR]; switch( addr->n.class ) { case N_REGISTER: - regidx = _NameRegTrans( addr ); + reg_addr = _NameRegTrans( addr ); break; case N_TEMP: case N_INDEXED: - getMemEncoding( addr, ®idx_mem, &mem_offset ); - GenMEMINS( 0x28, regidx, regidx_mem, mem_offset ); + getMemEncoding( addr, ®_mem, &mem_offset ); + GenMEMINS( 0x28, reg_addr, reg_mem, mem_offset ); break; } - GenMEMINS( 0x1a, RA_REG_IDX, regidx, 0x4000 ); + GenMEMINS( 0x1a, RA_REG_IDX, reg_addr, 0x4000 ); } static void doChop( instruction *ins, type_class_def type_class ) @@ -663,22 +663,22 @@ static void doSignExtend( instruction *ins, type_class_def type_class ) /*************************************************************************/ { unsigned from_size; - reg_idx regidx_res; - reg_idx regidx_src; + reg_idx reg_res; + reg_idx reg_src; int shift_amt; - regidx_res = _NameRegTrans( ins->result ); - regidx_src = _NameRegTrans( ins->operands[0] ); + reg_res = _NameRegTrans( ins->result ); + reg_src = _NameRegTrans( ins->operands[0] ); from_size = TypeClassSize[type_class]; if( from_size == 4 ) { /* addl r31, src -> dst */ - GenOPINS( 0x10, 0x00, ZERO_REG_IDX, regidx_src, regidx_res ); + GenOPINS( 0x10, 0x00, ZERO_REG_IDX, reg_src, reg_res ); } else { shift_amt = ( REG_SIZE - from_size ) * 8; /* shl */ - GenOPIMM8( 0x12, 0x39, regidx_src, (uint_8)shift_amt, regidx_res ); + GenOPIMM8( 0x12, 0x39, reg_src, (uint_8)shift_amt, reg_res ); /* sra */ - GenOPIMM8( 0x12, 0x3c, regidx_res, (uint_8)shift_amt, regidx_res ); + GenOPIMM8( 0x12, 0x3c, reg_res, (uint_8)shift_amt, reg_res ); } } @@ -728,8 +728,8 @@ static void Encode( instruction *ins ) { uint_8 *opcodes; uint_16 function; - reg_idx regidx; - reg_idx regidx_mem; + reg_idx reg_addr; + reg_idx reg_mem; int_16 mem_offset; int_16 high; int_16 extra; @@ -805,18 +805,18 @@ static void Encode( instruction *ins ) case G_FREGTOMI8: assert( ins->operands[0]->n.class == N_REGISTER ); assert( ins->result->n.class != N_REGISTER ); - regidx = _NameRegTrans( ins->operands[0] ); - GenFPOPINS( 0x16, 0x2f, ZERO_REG_IDX, regidx, FP_AT_REG_IDX ); - getMemEncoding( ins->result, ®idx_mem, &mem_offset ); - GenMEMINS( 0x27, FP_AT_REG_IDX, regidx_mem, mem_offset ); + reg_addr = _NameRegTrans( ins->operands[0] ); + GenFPOPINS( 0x16, 0x2f, ZERO_REG_IDX, reg_addr, FP_AT_REG_IDX ); + getMemEncoding( ins->result, ®_mem, &mem_offset ); + GenMEMINS( 0x27, FP_AT_REG_IDX, reg_mem, mem_offset ); break; case G_MI8TOFREG: assert( ins->operands[0]->n.class != N_REGISTER ); assert( ins->result->n.class == N_REGISTER ); - regidx = _NameRegTrans( ins->result ); - getMemEncoding( ins->operands[0], ®idx_mem, &mem_offset ); - GenMEMINS( 0x23, regidx, regidx_mem, mem_offset ); - GenFPOPINS( 0x16, 0xbe, ZERO_REG_IDX, regidx, regidx ); + reg_addr = _NameRegTrans( ins->result ); + getMemEncoding( ins->operands[0], ®_mem, &mem_offset ); + GenMEMINS( 0x23, reg_addr, reg_mem, mem_offset ); + GenFPOPINS( 0x16, 0xbe, ZERO_REG_IDX, reg_addr, reg_addr ); break; case G_BINARY_FP: assert( ins->operands[0]->n.class == N_REGISTER ); @@ -902,8 +902,8 @@ static void Encode( instruction *ins ) case N_INDEXED: case N_TEMP: assert( ins->result->n.class == N_REGISTER ); - getMemEncoding( ins->operands[0], ®idx_mem, &mem_offset ); - GenMEMINS( 0x08, _NameRegTrans( ins->result ), regidx_mem, mem_offset ); + getMemEncoding( ins->operands[0], ®_mem, &mem_offset ); + GenMEMINS( 0x08, _NameRegTrans( ins->result ), reg_mem, mem_offset ); break; case N_MEMORY: assert( ins->result->n.class == N_REGISTER ); diff --git a/bld/cg/risc/mps/c/mpsenc.c b/bld/cg/risc/mps/c/mpsenc.c index c0d4000a95..93a1bd3f0c 100644 --- a/bld/cg/risc/mps/c/mpsenc.c +++ b/bld/cg/risc/mps/c/mpsenc.c @@ -508,7 +508,7 @@ void GenCallLabelReg( pointer label, reg_idx reg ) /* * 'jalr reg,$at' */ - GenRType( 0x00, 0x09, reg, AT_REG_IDX, 0 ); + GenRType( 0x00, 0x09, reg, AT_REG_IDX, ZERO_REG_IDX ); /* * WARNING! WARNING! WARNING! * There's no delay slot here. Caller must handle that. @@ -595,7 +595,7 @@ static void addressTemp( name *temp, reg_idx *reg, int_16 *offset ) } -static void getMemEncoding( name *mem, reg_idx *regidx_mem, int_16 *offset ) +static void getMemEncoding( name *mem, reg_idx *reg_mem, int_16 *offset ) /***************************************************************************/ { switch( mem->n.class ) { @@ -604,15 +604,15 @@ static void getMemEncoding( name *mem, reg_idx *regidx_mem, int_16 *offset ) assert( mem->i.scale == 0 ); assert( mem->i.constant == (type_length)((int_16)mem->i.constant) ); assert( ( mem->i.index_flags & X_LOW_ADDR_BASE ) == 0 ); - *regidx_mem = _NameRegTrans( mem->i.index ); + *reg_mem = _NameRegTrans( mem->i.index ); *offset = (int_16)mem->i.constant; break; case N_TEMP: - addressTemp( mem, regidx_mem, offset ); + addressTemp( mem, reg_mem, offset ); break; case N_MEMORY: default: - *regidx_mem = ZERO_REG_IDX; + *reg_mem = ZERO_REG_IDX; *offset = 0; _Zoiks( ZOIKS_078 ); break; @@ -626,7 +626,7 @@ static void doLoadStore( instruction *ins, bool load ) name *mem; name *reg; uint_8 opcode; - reg_idx regidx_mem; + reg_idx reg_mem; int_16 offset; if( load ) { @@ -639,8 +639,8 @@ static void doLoadStore( instruction *ins, bool load ) opcode = storeOpcodes[ins->type_class]; } assert( reg->n.class == N_REGISTER ); - getMemEncoding( mem, ®idx_mem, &offset ); - GenMEMINS( opcode, _NameRegTrans( reg ), regidx_mem, offset ); + getMemEncoding( mem, ®_mem, &offset ); + GenMEMINS( opcode, _NameRegTrans( reg ), reg_mem, offset ); } @@ -652,7 +652,7 @@ static void doLoadStoreUnaligned( instruction *ins, bool load ) name *reg; uint_8 opcode1; uint_8 opcode2; - reg_idx regidx_mem; + reg_idx reg_mem; int_16 offset; if( load ) { @@ -671,12 +671,12 @@ static void doLoadStoreUnaligned( instruction *ins, bool load ) opcode1 = 0x2a; opcode2 = 0x2e; } assert( reg->n.class == N_REGISTER ); - getMemEncoding( mem, ®idx_mem, &offset ); + getMemEncoding( mem, ®_mem, &offset ); /* * TODO: make sure offset can't overflow */ - GenMEMINS( opcode1, _NameRegTrans( reg ), regidx_mem, offset + 3 ); - GenMEMINS( opcode2, _NameRegTrans( reg ), regidx_mem, offset ); + GenMEMINS( opcode1, _NameRegTrans( reg ), reg_mem, offset + 3 ); + GenMEMINS( opcode2, _NameRegTrans( reg ), reg_mem, offset ); #else doLoadStore( ins, load ); #endif @@ -686,30 +686,30 @@ static void doLoadStoreUnaligned( instruction *ins, bool load ) static void GenCallIndirect( instruction *call ) /***********************************************/ { - reg_idx regidx; - reg_idx regidx_mem; + reg_idx reg_addr; + reg_idx reg_mem; int_16 mem_offset; name *addr; /* * use the scratch register if possible */ - regidx = AT_REG_IDX; + reg_addr = AT_REG_IDX; addr = call->operands[CALL_OP_ADDR]; switch( addr->n.class ) { case N_REGISTER: - regidx = _NameRegTrans( addr ); + reg_addr = _NameRegTrans( addr ); break; case N_TEMP: case N_INDEXED: - getMemEncoding( addr, ®idx_mem, &mem_offset ); - GenMEMINS( 0x23, regidx, regidx_mem, mem_offset ); + getMemEncoding( addr, ®_mem, &mem_offset ); + GenMEMINS( 0x23, reg_addr, reg_mem, mem_offset ); break; } /* - * 'jalr ra,regidx' + * 'jalr ra,reg_addr' */ - GenRType( 0x00, 0x09, RA_REG_IDX, regidx, 0 ); + GenRType( 0x00, 0x09, RA_REG_IDX, reg_addr, ZERO_REG_IDX ); /* * TODO: Handle delay slot better */ @@ -833,8 +833,8 @@ static void Encode( instruction *ins ) uint_8 *opcodes; uint_8 opcode; uint_16 function; - reg_idx regidx; - reg_idx regidx_mem; + reg_idx reg_addr; + reg_idx reg_mem; int_16 mem_offset; int_16 high; int_16 extra; @@ -861,7 +861,7 @@ static void Encode( instruction *ins ) case FS: case FD: case FL: - GenFloatRType( ins->type_class, 0x07, _NameRegTrans( ins->result ), _NameRegTrans( ins->operands[0] ), 0 ); + GenFloatRType( ins->type_class, 0x07, _NameRegTrans( ins->result ), _NameRegTrans( ins->operands[0] ), ZERO_REG_IDX ); break; default: /* @@ -886,7 +886,7 @@ static void Encode( instruction *ins ) /* * 'mov.s fd,fs' */ - GenFloatRType( FS, 0x06, _NameRegTrans( ins->result ), _NameRegTrans( ins->operands[0] ), 0 ); + GenFloatRType( FS, 0x06, _NameRegTrans( ins->result ), _NameRegTrans( ins->operands[0] ), ZERO_REG_IDX ); break; case G_ZERO: assert( ins->operands[0]->n.class == N_REGISTER ); @@ -906,35 +906,35 @@ static void Encode( instruction *ins ) /* * 'cvt.s.d fd,fs' */ - GenFloatRType( FD, 0x20, _NameRegTrans( ins->result ), _NameRegTrans( ins->operands[0] ), 0 ); + GenFloatRType( FD, 0x20, _NameRegTrans( ins->result ), _NameRegTrans( ins->operands[0] ), ZERO_REG_IDX ); break; case G_FREGTOMI8: assert( ins->operands[0]->n.class == N_REGISTER ); assert( ins->result->n.class != N_REGISTER ); - regidx = _NameRegTrans( ins->operands[0] ); - getMemEncoding( ins->result, ®idx_mem, &mem_offset ); + reg_addr = _NameRegTrans( ins->operands[0] ); + getMemEncoding( ins->result, ®_mem, &mem_offset ); /* * 'sdc1 rt,offset(base)' - MIPS32-R2/MIPS64 only? */ - GenIType( 0x3d, regidx, regidx_mem, mem_offset ); + GenIType( 0x3d, reg_addr, reg_mem, mem_offset ); break; case G_MI8TOFREG: assert( ins->operands[0]->n.class != N_REGISTER ); assert( ins->result->n.class == N_REGISTER ); - regidx = _NameRegTrans( ins->result ); - getMemEncoding( ins->operands[0], ®idx_mem, &mem_offset ); + reg_addr = _NameRegTrans( ins->result ); + getMemEncoding( ins->operands[0], ®_mem, &mem_offset ); /* * 'ldc1 rt,offset(base)' - MIPS32-R2/MIPS64 only? */ - GenIType( 0x35, regidx, regidx_mem, mem_offset ); + GenIType( 0x35, reg_addr, reg_mem, mem_offset ); break; case G_BINARY_FP: assert( ins->operands[0]->n.class == N_REGISTER ); assert( ins->operands[1]->n.class == N_REGISTER ); assert( ins->result->n.class == N_REGISTER ); function = FindFloatingOpcodes( ins ); - regidx = _OpIsSet( ins->head.opcode ) ? 0 : _NameRegTrans( ins->result ); - GenFloatRType( ins->type_class, function, regidx, _NameRegTrans( ins->operands[0] ), _NameRegTrans( ins->operands[1] ) ); + reg_addr = _OpIsSet( ins->head.opcode ) ? ZERO_REG_IDX : _NameRegTrans( ins->result ); + GenFloatRType( ins->type_class, function, reg_addr, _NameRegTrans( ins->operands[0] ), _NameRegTrans( ins->operands[1] ) ); break; case G_BINARY: assert( ins->operands[0]->n.class == N_REGISTER ); @@ -950,31 +950,31 @@ static void Encode( instruction *ins ) GenRType( opcodes[0], opcodes[1], _NameRegTrans( ins->result ), _NameRegTrans( ins->operands[1] ), _NameRegTrans( ins->operands[0] ) ); break; case OP_MUL: - GenRType( opcodes[0], opcodes[1], 0, _NameRegTrans( ins->operands[0] ), _NameRegTrans( ins->operands[1] ) ); + GenRType( opcodes[0], opcodes[1], ZERO_REG_IDX, _NameRegTrans( ins->operands[0] ), _NameRegTrans( ins->operands[1] ) ); /* * 'mflo rd' */ - GenRType( 0, 0x12, _NameRegTrans( ins->result ), 0, 0 ); + GenRType( 0, 0x12, _NameRegTrans( ins->result ), ZERO_REG_IDX, ZERO_REG_IDX ); break; case OP_DIV: /* * TODO: do something if divisor is zero */ - GenRType( opcodes[0], opcodes[1], 0, _NameRegTrans( ins->operands[0] ), _NameRegTrans( ins->operands[1] ) ); + GenRType( opcodes[0], opcodes[1], ZERO_REG_IDX, _NameRegTrans( ins->operands[0] ), _NameRegTrans( ins->operands[1] ) ); /* * 'mflo rd' */ - GenRType( 0, 0x12, _NameRegTrans( ins->result ), 0, 0 ); + GenRType( 0, 0x12, _NameRegTrans( ins->result ), ZERO_REG_IDX, ZERO_REG_IDX ); break; case OP_MOD: /* * TODO: do something if divisor is zero */ - GenRType( opcodes[0], opcodes[1], 0, _NameRegTrans( ins->operands[0] ), _NameRegTrans( ins->operands[1] ) ); + GenRType( opcodes[0], opcodes[1], ZERO_REG_IDX, _NameRegTrans( ins->operands[0] ), _NameRegTrans( ins->operands[1] ) ); /* * 'mfhi rd' */ - GenRType( 0, 0x10, _NameRegTrans( ins->result ), 0, 0 ); + GenRType( 0, 0x10, _NameRegTrans( ins->result ), ZERO_REG_IDX, ZERO_REG_IDX ); break; default: GenRType( opcodes[0], opcodes[1], _NameRegTrans( ins->result ), _NameRegTrans( ins->operands[0] ), _NameRegTrans( ins->operands[1] ) ); @@ -1079,11 +1079,11 @@ static void Encode( instruction *ins ) case N_INDEXED: case N_TEMP: assert( ins->result->n.class == N_REGISTER ); - getMemEncoding( ins->operands[0], ®idx_mem, &mem_offset ); + getMemEncoding( ins->operands[0], ®_mem, &mem_offset ); /* * 'addiu rt,rs,immed' */ - GenIType( 0x09, _NameRegTrans( ins->result ), regidx_mem, mem_offset ); + GenIType( 0x09, _NameRegTrans( ins->result ), reg_mem, mem_offset ); break; case N_MEMORY: assert( ins->result->n.class == N_REGISTER ); diff --git a/bld/cg/risc/ppc/c/ppcenc.c b/bld/cg/risc/ppc/c/ppcenc.c index 655a5e1974..e71ea5a614 100644 --- a/bld/cg/risc/ppc/c/ppcenc.c +++ b/bld/cg/risc/ppc/c/ppcenc.c @@ -417,8 +417,8 @@ static void doCall( instruction *ins ) } -static void getMemEncoding( name *mem, reg_idx *regidx_mem, int_16 *offset ) -/*************************************************************************/ +static void getMemEncoding( name *mem, reg_idx *reg_mem, int_16 *offset ) +/***********************************************************************/ { switch( mem->n.class ) { case N_INDEXED: @@ -426,16 +426,16 @@ static void getMemEncoding( name *mem, reg_idx *regidx_mem, int_16 *offset ) assert( mem->i.scale == 0 ); assert( mem->i.constant == (type_length)((int_16)mem->i.constant) ); assert( ( mem->i.index_flags & X_LOW_ADDR_BASE ) == 0 ); - *regidx_mem = RegTrans( mem->i.index->r.reg ); + *reg_mem = RegTrans( mem->i.index->r.reg ); *offset = (int_16)mem->i.constant; break; case N_TEMP: - *regidx_mem = RegTrans( FrameReg() ); + *reg_mem = RegTrans( FrameReg() ); *offset = TempLocation( mem ); break; case N_MEMORY: default: - *regidx_mem = ZERO_REG_IDX; + *reg_mem = ZERO_REG_IDX; *offset = 0; _Zoiks( ZOIKS_119 ); break; @@ -449,7 +449,7 @@ static void doLoadStore( instruction *ins, bool load ) name *mem; name *reg; gen_opcode op; - reg_idx regidx_mem; + reg_idx reg_mem; int_16 offset; if( load ) { @@ -463,8 +463,8 @@ static void doLoadStore( instruction *ins, bool load ) } assert( op != 0 ); assert( reg->n.class == N_REGISTER ); - getMemEncoding( mem, ®idx_mem, &offset ); - GenMEMINS( op, RegTrans( reg->r.reg ), regidx_mem, offset ); + getMemEncoding( mem, ®_mem, &offset ); + GenMEMINS( op, RegTrans( reg->r.reg ), reg_mem, offset ); } @@ -521,7 +521,7 @@ static void GenCallIndirect( instruction *call ) { reg_idx src; reg_idx reg; - reg_idx regidx_mem; + reg_idx reg_mem; int_16 mem_offset; name *addr; gen_opcode ldw; @@ -539,8 +539,8 @@ static void GenCallIndirect( instruction *call ) break; case N_TEMP: case N_INDEXED: - getMemEncoding( addr, ®idx_mem, &mem_offset ); - GenMEMINS( ldw, src, regidx_mem, mem_offset ); + getMemEncoding( addr, ®_mem, &mem_offset ); + GenMEMINS( ldw, src, reg_mem, mem_offset ); break; } GenMEMINS( ldw, RTOC_REG_IDX, src, 4 ); // careful - src, reg could be same reg @@ -612,7 +612,7 @@ static void Encode( instruction *ins ) gen_opcode op2; gen_opcode *ops; int_16 mem_offset; - reg_idx regidx_mem; + reg_idx reg_mem; switch( G( ins ) ) { @@ -668,9 +668,9 @@ static void Encode( instruction *ins ) case N_INDEXED: case N_TEMP: assert( ins->result->n.class == N_REGISTER ); - getMemEncoding( ins->operands[0], ®idx_mem, &mem_offset ); + getMemEncoding( ins->operands[0], ®_mem, &mem_offset ); // addi rd,off(ri|sp) - GenOPIMM( 14, _NameRegTrans( ins->result ), regidx_mem, mem_offset ); + GenOPIMM( 14, _NameRegTrans( ins->result ), reg_mem, mem_offset ); break; case N_MEMORY: assert( ins->result->n.class == N_REGISTER ); From c248ad02e99ec950152177e0bcf506b4e50f6db7 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Tue, 10 Oct 2023 02:28:04 +0200 Subject: [PATCH 232/258] source file formatting change --- bld/cg/intel/c/wvsupp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bld/cg/intel/c/wvsupp.c b/bld/cg/intel/c/wvsupp.c index fae376b414..0b6d31ca3a 100644 --- a/bld/cg/intel/c/wvsupp.c +++ b/bld/cg/intel/c/wvsupp.c @@ -69,7 +69,7 @@ static uint MultiReg( register_name *reg ) if( HW_CEqual( hw_reg, HW_EMPTY ) ) { BuffByte( RegTransWV( reg->reg ) ); return( 1 ); - } else { + } else { BuffByte( RegTransWV( hw_reg ) ); tmp = reg->reg; HW_TurnOff( tmp, hw_reg ); From 254d83ddab4f10087358accad853e17d375eb94c Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Tue, 10 Oct 2023 09:14:06 +0200 Subject: [PATCH 233/258] cleanup cg code --- bld/cg/doc/cgref.gml | 2 +- bld/cg/intel/c/x86dfsup.c | 2 +- bld/cg/intel/c/x86enc.c | 8 +-- bld/cg/risc/axp/c/axpenc.c | 56 +++++++++--------- bld/cg/risc/axp/c/axprgtbl.c | 2 +- bld/cg/risc/mps/c/mpsenc.c | 107 +++++++++++++++++++++-------------- bld/cg/risc/mps/c/mpsrgtbl.c | 2 +- bld/cg/risc/ppc/c/ppcenc.c | 42 +++++++++----- bld/cg/risc/ppc/c/ppcproc.c | 24 ++++---- bld/cg/risc/ppc/c/ppcrgtbl.c | 2 +- 10 files changed, 143 insertions(+), 104 deletions(-) diff --git a/bld/cg/doc/cgref.gml b/bld/cg/doc/cgref.gml index f8b917957a..9da097e297 100644 --- a/bld/cg/doc/cgref.gml +++ b/bld/cg/doc/cgref.gml @@ -2778,7 +2778,7 @@ No return values in the 8087. Load ds with dgroup on entry. .note FECALL_GEN_DLL_EXPORT Is routine an OS/2 export symbol? -.note FECALL_X86_FAT_WINDOWS_PROLOG +.note FECALL_X86_PROLOG_FAT_WINDOWS Generate the real mode windows prolog code. .note FECALL_X86_GENERATE_STACK_FRAME Always generate a traceable prolog. diff --git a/bld/cg/intel/c/x86dfsup.c b/bld/cg/intel/c/x86dfsup.c index 00d09cbbc8..cd8048da10 100644 --- a/bld/cg/intel/c/x86dfsup.c +++ b/bld/cg/intel/c/x86dfsup.c @@ -165,7 +165,7 @@ void DFAbbrevRef( void ) { back_handle bck; - bck = BENewBack( NULL ); + bck = BENewBack( NULL ); BackImpPtr( ABBREV_NAME, bck, 0 ); BEFreeBack( bck ); } diff --git a/bld/cg/intel/c/x86enc.c b/bld/cg/intel/c/x86enc.c index 190ffce1f8..f9582dba6b 100644 --- a/bld/cg/intel/c/x86enc.c +++ b/bld/cg/intel/c/x86enc.c @@ -345,8 +345,8 @@ static void LayInitial( instruction *ins, gentype gen ) } if( table->flags & SIGN_UNSIGN ) { if( ins->type_class == I1 - || ins->type_class == I2 - || ins->type_class == I4 ) { + || ins->type_class == I2 + || ins->type_class == I4 ) { if( ins->head.opcode >= OP_MUL && ins->head.opcode <= OP_MOD ) { Inst[RMR] |= B_RMR_MUL_SGN; } else if( ins->head.opcode == OP_RSHIFT ) { @@ -375,7 +375,7 @@ static reg_idx SegTrans( hw_reg_set regs ) reg_idx RegTrans( hw_reg_set regs ) /*********************************** - * Return the arch index of a register name + * Translate reg to register class (8/16/32-bit) relative index */ { int i; @@ -477,7 +477,7 @@ int CountFPRegs( hw_reg_set regs ) } #if _TARGET & _TARG_80386 -static bool NeedOpndSize( instruction *ins ) +static bool NeedOpndSize( instruction *ins ) /*********************************************** * Do we REALLY, REALLY need the operand size override. */ diff --git a/bld/cg/risc/axp/c/axpenc.c b/bld/cg/risc/axp/c/axpenc.c index 97e1d1c576..3cb9feacdb 100644 --- a/bld/cg/risc/axp/c/axpenc.c +++ b/bld/cg/risc/axp/c/axpenc.c @@ -65,8 +65,8 @@ #define _BinaryOpcode( a, b ) { { a, b }, { a, b } } #define _SignedOpcode( a, b, c, d ) { { a, b }, { c, d } } -#define RDTEB_ENCODING 0x000000ab -#define RDTEB_MAGIC_CONST 0x2c +#define RDTEB_ENCODING 0x000000ab +#define RDTEB_MAGIC_CONST 0x2c /* * Our table for opcode values is really a list of pairs of @@ -283,8 +283,8 @@ static void EmitIns( axp_ins ins ) EmitInsReloc( &ins, NULL, 0 ); } -static void GenFPOPINS( uint_8 opcode, uint_16 function, reg_idx ra, reg_idx rb, reg_idx rc ) -/********************************************************************************************/ +static void GenFPOPINS( uint_8 opcode, uint_16 function, reg_idx ra, reg_idx rb, reg_idx rc ) +/*******************************************************************************************/ { ins_encoding = _Opcode( opcode ) | _Ra( ra ) | _Rb( rb ) | _Rc( rc ) | _FPFunction( function ); EmitIns( ins_encoding ); @@ -297,8 +297,8 @@ void GenOPINS( uint_8 opcode, uint_8 function, reg_idx ra, reg_idx rb, reg_idx r EmitIns( ins_encoding ); } -static void GenOPIMM8( uint_8 opcode, uint_8 function, reg_idx ra, uint_8 imm, reg_idx rc ) -/*********************************************************************************************/ +static void GenOPIMM8( uint_8 opcode, uint_8 function, reg_idx ra, uint_8 imm, reg_idx rc ) +/*****************************************************************************************/ { ins_encoding = _Opcode( opcode ) | _Ra( ra ) | _LIT( imm ) | _LIT_bit | _Rc( rc ) | _Function( function ); EmitIns( ins_encoding ); @@ -398,8 +398,8 @@ void GenMEMINS( uint_8 opcode, reg_idx ra, reg_idx rb, int_16 displacement ) EmitIns( ins_encoding ); } -static void GenBRANCH( uint_8 opcode, reg_idx reg, pointer label ) -/********************************************************************/ +static void GenBRANCH( uint_8 opcode, reg_idx reg, pointer label ) +/****************************************************************/ { ins_encoding = _Opcode( opcode ) | _Ra( reg ); EmitInsReloc( &ins_encoding, label, OWL_RELOC_BRANCH_REL ); @@ -548,7 +548,7 @@ static void addressTemp( name *temp, reg_idx *reg_mem, int_16 *offset ) *offset = 0; *reg_mem = AT_REG_IDX; } else { - *offset = temp_offset; + *offset = (int_16)temp_offset; *reg_mem = SP_REG_IDX; if( CurrProc->targ.base_is_fp ) { *reg_mem = FP_REG_IDX; @@ -779,9 +779,8 @@ static void Encode( instruction *ins ) break; case G_MOVE_FP: /* CPYS r1,r1,r2 */ - GenFPOPINS( 0x17, 0x20, - _NameRegTrans( ins->operands[0] ), _NameRegTrans( ins->operands[0] ), - _NameRegTrans( ins->result ) ); + GenFPOPINS( 0x17, 0x20, _NameRegTrans( ins->operands[0] ), + _NameRegTrans( ins->operands[0] ), _NameRegTrans( ins->result ) ); break; case G_ZERO: assert( ins->operands[0]->n.class == N_REGISTER ); @@ -799,8 +798,8 @@ static void Encode( instruction *ins ) assert( ins->operands[0]->n.class == N_REGISTER ); assert( ins->result->n.class == N_REGISTER ); GenFPOPINS( 0x16, 0xac, - ZERO_REG_IDX, _NameRegTrans( ins->operands[0] ), - _NameRegTrans( ins->result ) ); + ZERO_REG_IDX, _NameRegTrans( ins->operands[0] ), + _NameRegTrans( ins->result ) ); break; case G_FREGTOMI8: assert( ins->operands[0]->n.class == N_REGISTER ); @@ -824,8 +823,8 @@ static void Encode( instruction *ins ) assert( ins->result->n.class == N_REGISTER ); function = FindFloatingOpcodes( ins ); GenFPOPINS( 0x16, function, - _NameRegTrans( ins->operands[0] ), _NameRegTrans( ins->operands[1] ), - _NameRegTrans( ins->result ) ); + _NameRegTrans( ins->operands[0] ), _NameRegTrans( ins->operands[1] ), + _NameRegTrans( ins->result ) ); break; case G_BINARY: assert( ins->operands[0]->n.class == N_REGISTER ); @@ -833,8 +832,8 @@ static void Encode( instruction *ins ) assert( ins->result->n.class == N_REGISTER ); opcodes = FindOpcodes( ins ); GenOPINS( opcodes[0], opcodes[1], - _NameRegTrans( ins->operands[0] ), _NameRegTrans( ins->operands[1] ), - _NameRegTrans( ins->result ) ); + _NameRegTrans( ins->operands[0] ), _NameRegTrans( ins->operands[1] ), + _NameRegTrans( ins->result ) ); break; case G_BINARY_IMM: assert( ins->operands[0]->n.class == N_REGISTER ); @@ -862,8 +861,8 @@ static void Encode( instruction *ins ) * generate a "BIS R31,Rn,Rm" instruction */ GenOPINS( 0x11, 0x20, - ZERO_REG_IDX, _NameRegTrans( ins->operands[0] ), - _NameRegTrans( ins->result ) ); + ZERO_REG_IDX, _NameRegTrans( ins->operands[0] ), + _NameRegTrans( ins->result ) ); break; case G_ZAP: assert( ins->operands[0]->n.class == N_REGISTER ); @@ -880,14 +879,16 @@ static void Encode( instruction *ins ) assert( ins->operands[0]->n.class == N_CONSTANT ); assert( ins->operands[0]->c.const_type == CONS_HIGH_ADDR ); assert( ins->result->n.class == N_REGISTER ); - GenMEMINS( 0x09, _NameRegTrans( ins->result ), ZERO_REG_IDX, ins->operands[0]->c.lo.int_value & 0xffff ); + GenMEMINS( 0x09, _NameRegTrans( ins->result ), ZERO_REG_IDX, + (int_16)ins->operands[0]->c.lo.int_value ); break; case G_LEA: assert( ins->operands[0]->n.class == N_CONSTANT ); assert( ins->result->n.class == N_REGISTER ); switch( ins->operands[0]->c.const_type ) { case CONS_ABSOLUTE: - GenMEMINS( 0x08, _NameRegTrans( ins->result ), ZERO_REG_IDX, ins->operands[0]->c.lo.int_value ); + GenMEMINS( 0x08, _NameRegTrans( ins->result ), ZERO_REG_IDX, + (int_16)ins->operands[0]->c.lo.int_value ); break; case CONS_LOW_ADDR: case CONS_HIGH_ADDR: @@ -912,10 +913,11 @@ static void Encode( instruction *ins ) _Zoiks( ZOIKS_132 ); } if( !encodeThreadDataRef( ins ) ) { - GenMEMINSRELOC( 0x09, _NameRegTrans( ins->result ), ZERO_REG_IDX, high, - symLabel( ins->operands[0] ), OWL_RELOC_HALF_HI ); - GenMEMINSRELOC( 0x08, _NameRegTrans( ins->result ), _NameRegTrans( ins->result ), low, - symLabel( ins->operands[0] ), OWL_RELOC_HALF_LO ); + GenMEMINSRELOC( 0x09, _NameRegTrans( ins->result ), ZERO_REG_IDX, + high, symLabel( ins->operands[0] ), OWL_RELOC_HALF_HI ); + GenMEMINSRELOC( 0x08, _NameRegTrans( ins->result ), + _NameRegTrans( ins->result ), low, symLabel( ins->operands[0] ), + OWL_RELOC_HALF_LO ); } break; default: @@ -971,7 +973,7 @@ void GenJumpIf( instruction *ins, pointer label ) /**************************************************/ { GenBRANCH( BranchOpcodes[ins->head.opcode - FIRST_COMPARISON][_IsFloating( ins->type_class )], - _NameRegTrans( ins->operands[0] ), label ); + _NameRegTrans( ins->operands[0] ), label ); #ifdef DEVBUILD if( _IsTargetModel( CGSW_RISC_ASM_OUTPUT ) ) { DumpLiteral( "Jcc L" ); diff --git a/bld/cg/risc/axp/c/axprgtbl.c b/bld/cg/risc/axp/c/axprgtbl.c index 203f579290..78f505869e 100644 --- a/bld/cg/risc/axp/c/axprgtbl.c +++ b/bld/cg/risc/axp/c/axprgtbl.c @@ -33,7 +33,7 @@ #include "_cgstd.h" #include "coderep.h" -#include "axpenc.h" +#include "axpregn.h" #include "zoiks.h" #include "data.h" #include "rgtbl.h" diff --git a/bld/cg/risc/mps/c/mpsenc.c b/bld/cg/risc/mps/c/mpsenc.c index 93a1bd3f0c..4907743ee1 100644 --- a/bld/cg/risc/mps/c/mpsenc.c +++ b/bld/cg/risc/mps/c/mpsenc.c @@ -426,10 +426,10 @@ void GenJType( uint_8 opcode, pointer label ) } -static void GenFloatRType( type_class_def type_class, uint_8 fnc, reg_idx fd, reg_idx fs, reg_idx ft ) -/*****************************************************************************************************/ +static void GenFloatRType( type_class_def type_class, uint_8 fnc, reg_idx fd, reg_idx fs, reg_idx ft ) +/****************************************************************************************************/ { - int fmt; + int fmt; /* * Select operand format @@ -502,9 +502,9 @@ void GenCallLabelReg( pointer label, reg_idx reg ) * TODO: This should be different for PIC */ GenMEMINSRELOC( 0x0f, AT_REG_IDX, ZERO_REG_IDX, 0, - label, OWL_RELOC_HALF_HI ); + label, OWL_RELOC_HALF_HI ); GenMEMINSRELOC( 0x09, AT_REG_IDX, AT_REG_IDX, 0, - label, OWL_RELOC_HALF_LO ); + label, OWL_RELOC_HALF_LO ); /* * 'jalr reg,$at' */ @@ -523,7 +523,7 @@ void GenCallLabel( pointer label ) } -static void GenNoReturn( void ) +static void GenNoReturn( void ) /********************************** * Generate a noreturn instruction (pseudo instruction) */ @@ -536,8 +536,8 @@ static void GenNoReturn( void ) InputOC( &oc ); } -static void doCall( instruction *ins ) -/*************************************/ +static void doCall( instruction *ins ) +/************************************/ { cg_sym_handle sym; byte_seq *code; @@ -568,8 +568,8 @@ static void doCall( instruction *ins ) } -static void addressTemp( name *temp, reg_idx *reg, int_16 *offset ) -/******************************************************************/ +static void addressTemp( name *temp, reg_idx *reg, int_16 *offset ) +/*****************************************************************/ { type_length temp_offset; @@ -595,8 +595,8 @@ static void addressTemp( name *temp, reg_idx *reg, int_16 *offset ) } -static void getMemEncoding( name *mem, reg_idx *reg_mem, int_16 *offset ) -/***************************************************************************/ +static void getMemEncoding( name *mem, reg_idx *reg_mem, int_16 *offset ) +/***********************************************************************/ { switch( mem->n.class ) { case N_INDEXED: @@ -803,23 +803,23 @@ static bool encodeThreadDataRef( instruction *ins ) * ldl v0, (v0) * lda rn, l^variable(v0) * - * In order to be able to zap v0 (which rdteb does), - * we always set the zap set on a LEA foo -> rn instruction - * to be v0 when foo is a piece of thread-local storage. - * This is done in FixMemRefs. + * In order to be able to zap v0 (which rdteb does), + * we always set the zap set on a LEA foo -> rn instruction + * to be v0 when foo is a piece of thread-local storage. + * This is done in FixMemRefs. */ // tls_index = RTLabel( RT_TLS_INDEX ); #if 0 GenMEMINSRELOC( 0x09, AT_REG_IDX, ZERO_REG_IDX, 0, - tls_index, OWL_RELOC_HALF_HI ); + tls_index, OWL_RELOC_HALF_HI ); GenMEMINSRELOC( 0x08, AT_REG_IDX, AT_REG_IDX, 0, - tls_index, OWL_RELOC_HALF_LO ); + tls_index, OWL_RELOC_HALF_LO ); EmitIns( RDTEB_ENCODING ); GenMEMINS( loadOpcodes[I4], RT_RET_REG_IDX, RT_RET_REG_IDX, RDTEB_MAGIC_CONST ); GenOPINS( 0x0010, 0x0002, AT_REG_IDX, RT_RET_REG_IDX, RT_RET_REG_IDX ); GenMEMINS( loadOpcodes[I4], RT_RET_REG_IDX, RT_RET_REG_IDX, 0 ); GenMEMINSRELOC( 0x08, _NameRegTrans( ins->result ), - RT_RET_REG_IDX, 0, symLabel( op ), OWL_RELOC_HALF_LO ); + RT_RET_REG_IDX, 0, symLabel( op ), OWL_RELOC_HALF_LO ); #else assert( 0 ); #endif @@ -861,20 +861,23 @@ static void Encode( instruction *ins ) case FS: case FD: case FL: - GenFloatRType( ins->type_class, 0x07, _NameRegTrans( ins->result ), _NameRegTrans( ins->operands[0] ), ZERO_REG_IDX ); + GenFloatRType( ins->type_class, 0x07, _NameRegTrans( ins->result ), + _NameRegTrans( ins->operands[0] ), ZERO_REG_IDX ); break; default: /* * 'subu rd,$zero,rs' */ - GenRType( 0x00, 0x23, _NameRegTrans( ins->result ), ZERO_REG_IDX, _NameRegTrans( ins->operands[0] ) ); + GenRType( 0x00, 0x23, _NameRegTrans( ins->result ), ZERO_REG_IDX, + _NameRegTrans( ins->operands[0] ) ); } break; case OP_COMPLEMENT: /* * 'nor rd,$zero,rs' */ - GenRType( 0x00, 0x27, _NameRegTrans( ins->result ), ZERO_REG_IDX, _NameRegTrans( ins->operands[0] ) ); + GenRType( 0x00, 0x27, _NameRegTrans( ins->result ), + ZERO_REG_IDX, _NameRegTrans( ins->operands[0] ) ); break; default: _Zoiks( ZOIKS_028 ); @@ -886,7 +889,8 @@ static void Encode( instruction *ins ) /* * 'mov.s fd,fs' */ - GenFloatRType( FS, 0x06, _NameRegTrans( ins->result ), _NameRegTrans( ins->operands[0] ), ZERO_REG_IDX ); + GenFloatRType( FS, 0x06, _NameRegTrans( ins->result ), + _NameRegTrans( ins->operands[0] ), ZERO_REG_IDX ); break; case G_ZERO: assert( ins->operands[0]->n.class == N_REGISTER ); @@ -906,7 +910,8 @@ static void Encode( instruction *ins ) /* * 'cvt.s.d fd,fs' */ - GenFloatRType( FD, 0x20, _NameRegTrans( ins->result ), _NameRegTrans( ins->operands[0] ), ZERO_REG_IDX ); + GenFloatRType( FD, 0x20, _NameRegTrans( ins->result ), + _NameRegTrans( ins->operands[0] ), ZERO_REG_IDX ); break; case G_FREGTOMI8: assert( ins->operands[0]->n.class == N_REGISTER ); @@ -934,7 +939,8 @@ static void Encode( instruction *ins ) assert( ins->result->n.class == N_REGISTER ); function = FindFloatingOpcodes( ins ); reg_addr = _OpIsSet( ins->head.opcode ) ? ZERO_REG_IDX : _NameRegTrans( ins->result ); - GenFloatRType( ins->type_class, function, reg_addr, _NameRegTrans( ins->operands[0] ), _NameRegTrans( ins->operands[1] ) ); + GenFloatRType( ins->type_class, function, reg_addr, + _NameRegTrans( ins->operands[0] ), _NameRegTrans( ins->operands[1] ) ); break; case G_BINARY: assert( ins->operands[0]->n.class == N_REGISTER ); @@ -947,10 +953,12 @@ static void Encode( instruction *ins ) /* * 'sllv', 'srlv' and 'srav' have the operands backwards */ - GenRType( opcodes[0], opcodes[1], _NameRegTrans( ins->result ), _NameRegTrans( ins->operands[1] ), _NameRegTrans( ins->operands[0] ) ); + GenRType( opcodes[0], opcodes[1], _NameRegTrans( ins->result ), + _NameRegTrans( ins->operands[1] ), _NameRegTrans( ins->operands[0] ) ); break; case OP_MUL: - GenRType( opcodes[0], opcodes[1], ZERO_REG_IDX, _NameRegTrans( ins->operands[0] ), _NameRegTrans( ins->operands[1] ) ); + GenRType( opcodes[0], opcodes[1], ZERO_REG_IDX, _NameRegTrans( ins->operands[0] ), + _NameRegTrans( ins->operands[1] ) ); /* * 'mflo rd' */ @@ -960,7 +968,8 @@ static void Encode( instruction *ins ) /* * TODO: do something if divisor is zero */ - GenRType( opcodes[0], opcodes[1], ZERO_REG_IDX, _NameRegTrans( ins->operands[0] ), _NameRegTrans( ins->operands[1] ) ); + GenRType( opcodes[0], opcodes[1], ZERO_REG_IDX, + _NameRegTrans( ins->operands[0] ), _NameRegTrans( ins->operands[1] ) ); /* * 'mflo rd' */ @@ -970,14 +979,16 @@ static void Encode( instruction *ins ) /* * TODO: do something if divisor is zero */ - GenRType( opcodes[0], opcodes[1], ZERO_REG_IDX, _NameRegTrans( ins->operands[0] ), _NameRegTrans( ins->operands[1] ) ); + GenRType( opcodes[0], opcodes[1], ZERO_REG_IDX, + _NameRegTrans( ins->operands[0] ), _NameRegTrans( ins->operands[1] ) ); /* * 'mfhi rd' */ GenRType( 0, 0x10, _NameRegTrans( ins->result ), ZERO_REG_IDX, ZERO_REG_IDX ); break; default: - GenRType( opcodes[0], opcodes[1], _NameRegTrans( ins->result ), _NameRegTrans( ins->operands[0] ), _NameRegTrans( ins->operands[1] ) ); + GenRType( opcodes[0], opcodes[1], _NameRegTrans( ins->result ), + _NameRegTrans( ins->operands[0] ), _NameRegTrans( ins->operands[1] ) ); break; } break; @@ -991,19 +1002,22 @@ static void Encode( instruction *ins ) /* * 'sll rd,rs,n' */ - GenIShift( 0x00, _NameRegTrans( ins->result ), _NameRegTrans( ins->operands[0] ), imm_value ); + GenIShift( 0x00, _NameRegTrans( ins->result ), + _NameRegTrans( ins->operands[0] ), imm_value ); break; case OP_RSHIFT: if( _IsSigned( ins->type_class ) ) { /* * 'sra rd,rs,n' */ - GenIShift( 0x03, _NameRegTrans( ins->result ), _NameRegTrans( ins->operands[0] ), imm_value ); + GenIShift( 0x03, _NameRegTrans( ins->result ), + _NameRegTrans( ins->operands[0] ), imm_value ); } else { /* * 'srl rd,rs,n' */ - GenIShift( 0x02, _NameRegTrans( ins->result ), _NameRegTrans( ins->operands[0] ), imm_value ); + GenIShift( 0x02, _NameRegTrans( ins->result ), + _NameRegTrans( ins->operands[0] ), imm_value ); } break; case OP_SUB: @@ -1017,7 +1031,8 @@ static void Encode( instruction *ins ) */ default: opcode = FindImmedOpcode( ins ); - GenIType( opcode, _NameRegTrans( ins->result ), _NameRegTrans( ins->operands[0] ), imm_value ); + GenIType( opcode, _NameRegTrans( ins->result ), + _NameRegTrans( ins->operands[0] ), imm_value ); break; } break; @@ -1030,7 +1045,8 @@ static void Encode( instruction *ins ) /* * 'addiu rt,$zero,immed' */ - GenIType( 0x09, _NameRegTrans( ins->result ), ZERO_REG_IDX, (uint_8)ins->operands[0]->c.lo.int_value ); + GenIType( 0x09, _NameRegTrans( ins->result ), ZERO_REG_IDX, + (uint_8)ins->operands[0]->c.lo.int_value ); break; case G_MOVE: assert( ins->operands[0]->n.class == N_REGISTER ); @@ -1038,13 +1054,15 @@ static void Encode( instruction *ins ) /* * 'or rd,rs,$zero' */ - GenRType( 0x00, 0x25, _NameRegTrans( ins->result ), _NameRegTrans( ins->operands[0] ), ZERO_REG_IDX ); + GenRType( 0x00, 0x25, _NameRegTrans( ins->result ), + _NameRegTrans( ins->operands[0] ), ZERO_REG_IDX ); if( TypeClassSize[ins->type_class] == 8 ) { /* * Move the odd register, too * TODO: there should probably be a separate G_MOVE8? */ - GenRType( 0x00, 0x25, _NameRegTrans( ins->result ) + 1, _NameRegTrans( ins->operands[0] ) + 1, ZERO_REG_IDX ); + GenRType( 0x00, 0x25, _NameRegTrans( ins->result ) + 1, + _NameRegTrans( ins->operands[0] ) + 1, ZERO_REG_IDX ); } break; case G_LEA_HIGH: @@ -1054,7 +1072,8 @@ static void Encode( instruction *ins ) /* * 'lui rt,immed' */ - GenIType( 0x0f, _NameRegTrans( ins->result ), ZERO_REG_IDX, ins->operands[0]->c.lo.int_value & 0xffff ); + GenIType( 0x0f, _NameRegTrans( ins->result ), ZERO_REG_IDX, + ins->operands[0]->c.lo.int_value & 0xffff ); break; case G_LEA: assert( ins->operands[0]->n.class == N_CONSTANT ); @@ -1064,7 +1083,8 @@ static void Encode( instruction *ins ) /* * 'addiu rt,$zero,immed' */ - GenIType( 0x09, _NameRegTrans( ins->result ), ZERO_REG_IDX, ins->operands[0]->c.lo.int_value ); + GenIType( 0x09, _NameRegTrans( ins->result ), ZERO_REG_IDX, + ins->operands[0]->c.lo.int_value ); break; case CONS_LOW_ADDR: case CONS_HIGH_ADDR: @@ -1095,11 +1115,13 @@ static void Encode( instruction *ins ) /* * 'lui rt,immed' */ - GenMEMINSRELOC( 0x0f, _NameRegTrans( ins->result ), ZERO_REG_IDX, high, symLabel( ins->operands[0] ), OWL_RELOC_HALF_HI ); + GenMEMINSRELOC( 0x0f, _NameRegTrans( ins->result ), ZERO_REG_IDX, + high, symLabel( ins->operands[0] ), OWL_RELOC_HALF_HI ); /* * 'addiu rt,rs,immed' */ - GenMEMINSRELOC( 0x09, _NameRegTrans( ins->result ), _NameRegTrans( ins->result ), low, symLabel( ins->operands[0] ), OWL_RELOC_HALF_LO ); + GenMEMINSRELOC( 0x09, _NameRegTrans( ins->result ), _NameRegTrans( ins->result ), + low, symLabel( ins->operands[0] ), OWL_RELOC_HALF_LO ); } break; default: @@ -1111,7 +1133,8 @@ static void Encode( instruction *ins ) * a load of an unsigned 16-bit immediate * 'ori rt,rs,immed' */ - GenIType( 0x0d, _NameRegTrans( ins->result ), ZERO_REG_IDX, ins->operands[0]->c.lo.int_value ); + GenIType( 0x0d, _NameRegTrans( ins->result ), ZERO_REG_IDX, + ins->operands[0]->c.lo.int_value ); break; case G_LOAD_UA: doLoadStoreUnaligned( ins, true ); diff --git a/bld/cg/risc/mps/c/mpsrgtbl.c b/bld/cg/risc/mps/c/mpsrgtbl.c index b9cc027117..69f300f344 100644 --- a/bld/cg/risc/mps/c/mpsrgtbl.c +++ b/bld/cg/risc/mps/c/mpsrgtbl.c @@ -32,7 +32,7 @@ #include "_cgstd.h" #include "coderep.h" -#include "mpsenc.h" +#include "mpsregn.h" #include "zoiks.h" #include "data.h" #include "rgtbl.h" diff --git a/bld/cg/risc/ppc/c/ppcenc.c b/bld/cg/risc/ppc/c/ppcenc.c index e71ea5a614..a92e874686 100644 --- a/bld/cg/risc/ppc/c/ppcenc.c +++ b/bld/cg/risc/ppc/c/ppcenc.c @@ -477,14 +477,16 @@ static void doSign( instruction *ins ) /* * extsb */ - GenOPINS( 31, 954, _NameRegTrans( ins->result ), ZERO_REG_IDX, _NameRegTrans( ins->operands[0] ) ); + GenOPINS( 31, 954, _NameRegTrans( ins->result ), ZERO_REG_IDX, + _NameRegTrans( ins->operands[0] ) ); break; case U2: case I2: /* * extsh */ - GenOPINS( 31, 922, _NameRegTrans( ins->result ), ZERO_REG_IDX, _NameRegTrans( ins->operands[0] ) ); + GenOPINS( 31, 922, _NameRegTrans( ins->result ), ZERO_REG_IDX, + _NameRegTrans( ins->operands[0] ) ); break; default: _Zoiks( ZOIKS_091 ); @@ -501,14 +503,16 @@ static void doZero( instruction *ins ) /* * andi op1,0x00ff -> res */ - GenOPIMM( 28, _NameRegTrans( ins->operands[0] ), _NameRegTrans( ins->result ), 0x00ff ); + GenOPIMM( 28, _NameRegTrans( ins->operands[0] ), + _NameRegTrans( ins->result ), 0x00ff ); break; case U2: case I2: /* * andi op1,0xffff -> res */ - GenOPIMM( 28, _NameRegTrans( ins->operands[0] ), _NameRegTrans( ins->result ), -1 ); + GenOPIMM( 28, _NameRegTrans( ins->operands[0] ), + _NameRegTrans( ins->result ), -1 ); break; default: _Zoiks( ZOIKS_091 ); @@ -619,7 +623,8 @@ static void Encode( instruction *ins ) case G_MOVE_FP: assert( ins->result->n.class == N_REGISTER ); assert( ins->operands[0]->n.class == N_REGISTER ); - GenOPINS( 63, 72, ZERO_REG_IDX, _NameRegTrans( ins->operands[0] ), _NameRegTrans( ins->result ) ); + GenOPINS( 63, 72, ZERO_REG_IDX, _NameRegTrans( ins->operands[0] ), + _NameRegTrans( ins->result ) ); break; case G_MOVE: // or op, op -> dst @@ -640,12 +645,14 @@ static void Encode( instruction *ins ) assert( ins->operands[0]->c.const_type == CONS_HIGH_ADDR ); assert( ins->result->n.class == N_REGISTER ); /* addis k(r0) -> rn */ - GenOPIMM( 15, _NameRegTrans( ins->result ), ZERO_REG_IDX, ins->operands[0]->c.lo.int_value & 0xffff ); + GenOPIMM( 15, _NameRegTrans( ins->result ), ZERO_REG_IDX, + ins->operands[0]->c.lo.int_value & 0xffff ); break; case G_MOVE_UI: /* a load of an unsigned 16-bit immediate */ /* use or rd, imm(r0) */ - GenOPIMM( 24, _NameRegTrans( ins->result ), ZERO_REG_IDX, ins->operands[0]->c.lo.int_value ); + GenOPIMM( 24, _NameRegTrans( ins->result ), ZERO_REG_IDX, + ins->operands[0]->c.lo.int_value ); break; case G_LEA: assert( ins->operands[0]->n.class == N_CONSTANT ); @@ -653,7 +660,8 @@ static void Encode( instruction *ins ) switch( ins->operands[0]->c.const_type ) { case CONS_ABSOLUTE: // addi rd, imm(r0) - GenOPIMM( 14, _NameRegTrans( ins->result ), ZERO_REG_IDX, ins->operands[0]->c.lo.int_value ); + GenOPIMM( 14, _NameRegTrans( ins->result ), ZERO_REG_IDX, + ins->operands[0]->c.lo.int_value ); break; case CONS_LOW_ADDR: case CONS_HIGH_ADDR: @@ -731,18 +739,21 @@ static void Encode( instruction *ins ) // rlwinm dst,src,n,0,31-n op2 = 31 - _FiveBits( ins->operands[1]->c.lo.int_value ); b = _FiveBits( ins->operands[1]->c.lo.int_value ); - GenOPINS( 21, op2, _NameRegTrans( ins->result ), b, _NameRegTrans( ins->operands[0] ) ); + GenOPINS( 21, op2, _NameRegTrans( ins->result ), b, + _NameRegTrans( ins->operands[0] ) ); break; case OP_RSHIFT: if( _IsSigned( ins->type_class ) ) { GenOPINS( 31, 824, _NameRegTrans( ins->result ), - (reg_idx)ins->operands[1]->c.lo.int_value, _NameRegTrans( ins->operands[0] ) ); + (reg_idx)ins->operands[1]->c.lo.int_value, + _NameRegTrans( ins->operands[0] ) ); } else { // rlwinm dst,src,32-n,n,31 b = _FiveBits( ins->operands[1]->c.lo.int_value ); op2 = ( b << 5 ) | 31; b = 32 - b; - GenOPINS( 21, op2, _NameRegTrans( ins->result ), b, _NameRegTrans( ins->operands[0] ) ); + GenOPINS( 21, op2, _NameRegTrans( ins->result ), b, + _NameRegTrans( ins->operands[0] ) ); } break; default: @@ -761,7 +772,8 @@ static void Encode( instruction *ins ) case G_CMP_FP: assert( ins->operands[0]->n.class == N_REGISTER ); assert( ins->operands[1]->n.class == N_REGISTER ); - GenCMP( 63, 32, _NameRegTrans( ins->operands[0] ), _NameRegTrans( ins->operands[1] ) ); + GenCMP( 63, 32, _NameRegTrans( ins->operands[0] ), + _NameRegTrans( ins->operands[1] ) ); break; case G_CMP: assert( ins->operands[0]->n.class == N_REGISTER ); @@ -770,7 +782,8 @@ static void Encode( instruction *ins ) if( _IsSigned( ins->type_class ) ) { op2 = 0; } - GenCMP( 31, op2, _NameRegTrans( ins->operands[0] ), _NameRegTrans( ins->operands[1] ) ); + GenCMP( 31, op2, _NameRegTrans( ins->operands[0] ), + _NameRegTrans( ins->operands[1] ) ); break; case G_CMP_I: assert( ins->operands[0]->n.class == N_REGISTER ); @@ -779,7 +792,8 @@ static void Encode( instruction *ins ) if( _IsSigned( ins->type_class ) ) { op1 = 11; } - GenCMPIMM( op1, _NameRegTrans( ins->operands[0] ), ins->operands[1]->c.lo.int_value ); + GenCMPIMM( op1, _NameRegTrans( ins->operands[0] ), + ins->operands[1]->c.lo.int_value ); break; case G_SIGN: assert( ins->operands[0]->n.class == N_REGISTER ); diff --git a/bld/cg/risc/ppc/c/ppcproc.c b/bld/cg/risc/ppc/c/ppcproc.c index d1bf282281..df3bd3a5fa 100644 --- a/bld/cg/risc/ppc/c/ppcproc.c +++ b/bld/cg/risc/ppc/c/ppcproc.c @@ -191,7 +191,7 @@ static void genAdd( reg_idx src, int_16 disp, reg_idx dst ) GenOPIMM( ADDI_OPCODE, dst, src, disp ); } -static void saveReg( int index, type_length offset, bool fp ) +static void saveReg( reg_idx index, type_length offset, bool fp ) /***************************************************************/ { uint_8 opcode; @@ -200,10 +200,10 @@ static void saveReg( int index, type_length offset, bool fp ) if( fp ) { opcode = STORE_DOUBLE; } - GenMEMINS( opcode, (reg_idx)index, SP_REG_IDX, offset ); + GenMEMINS( opcode, index, SP_REG_IDX, offset ); } -static void loadReg( int index, type_length offset, bool fp ) +static void loadReg( reg_idx index, type_length offset, bool fp ) /***************************************************************/ { uint_8 opcode; @@ -217,10 +217,10 @@ static void loadReg( int index, type_length offset, bool fp ) if( CurrProc->targ.base_is_fp ) { frame_reg = FP_REG_IDX; } - GenMEMINS( opcode, (reg_idx)index, frame_reg, offset + CurrProc->locals.size ); + GenMEMINS( opcode, index, frame_reg, offset + CurrProc->locals.size ); } -static int regSize( bool fp ) +static int regSize( bool fp ) /********************************/ { return( fp ? 8 : 4 ); @@ -229,7 +229,7 @@ static int regSize( bool fp ) static void saveRegSet( uint_32 reg_set, type_length offset, bool fp ) /************************************************************************/ { - int index; + reg_idx index; uint_32 high_bit; index = sizeof( reg_set ) * 8 - 1; @@ -247,7 +247,7 @@ static void saveRegSet( uint_32 reg_set, type_length offset, bool fp ) static void loadRegSet( uint_32 reg_set, type_length offset, bool fp ) /************************************************************************/ { - int index; + reg_idx index; index = 0; while( reg_set != 0 ) { @@ -298,15 +298,15 @@ static void initVarargs( stack_record *varargs, type_length *offset ) static void emitVarargsProlog( stack_record *varargs ) /********************************************************/ { - type_length offset; - int i; + type_length offset; + reg_idx i; /* unused parameters */ (void)varargs; if( CurrProc->state.attr & ROUTINE_HAS_VARARGS ) { // save our registers in our caller's context - uhg! offset = CurrProc->targ.frame_size + STACK_HEADER_SIZE; - for( i = CurrProc->state.parm.gr; i <= LAST_SCALAR_PARM_REG_IDX; i++ ) { + for( i = (reg_idx)CurrProc->state.parm.gr; i <= LAST_SCALAR_PARM_REG_IDX; i++ ) { saveReg( i, offset + ( i - FIRST_SCALAR_PARM_REG_IDX ) * 4, false ); } } @@ -410,7 +410,7 @@ static void emitProlog( stack_map *map ) } if( frame_size != 0 ) { // stwu sp,-frame_size(sp) - GenMEMINS( 37, SP_REG_IDX, SP_REG_IDX, -frame_size ); + GenMEMINS( 37, SP_REG_IDX, SP_REG_IDX, -(int_16)frame_size ); emitVarargsProlog( &map->varargs ); emitSlopProlog( &map->varargs ); emitSavedRegsProlog( &map->saved_regs ); @@ -444,7 +444,7 @@ static void emitEpilog( stack_map *map ) if( CurrProc->targ.base_is_fp ) { frame_reg = FP_REG_IDX; } - genAdd( frame_reg, frame_size, SP_REG_IDX ); + genAdd( frame_reg, (int_16)frame_size, SP_REG_IDX ); } } diff --git a/bld/cg/risc/ppc/c/ppcrgtbl.c b/bld/cg/risc/ppc/c/ppcrgtbl.c index 6a8576bcd1..f29b22ae9e 100644 --- a/bld/cg/risc/ppc/c/ppcrgtbl.c +++ b/bld/cg/risc/ppc/c/ppcrgtbl.c @@ -32,7 +32,7 @@ #include "_cgstd.h" #include "coderep.h" -#include "ppcenc.h" +#include "ppcregn.h" #include "zoiks.h" #include "data.h" #include "rgtbl.h" From e52a29d37ab1d9323cf1e1c72df695fd3fea5264 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Wed, 11 Oct 2023 12:08:34 +0200 Subject: [PATCH 234/258] update comments --- bld/cg/h/name.h | 6 +++--- bld/cg/intel/h/x86regn.h | 13 ++++++------- bld/cg/risc/axp/h/axpregn.h | 11 +++++------ bld/cg/risc/mps/h/mpsregn.h | 10 +++++----- bld/cg/risc/ppc/h/ppcregn.h | 11 +++++------ 5 files changed, 24 insertions(+), 27 deletions(-) diff --git a/bld/cg/h/name.h b/bld/cg/h/name.h index 181781b073..d3ab432154 100644 --- a/bld/cg/h/name.h +++ b/bld/cg/h/name.h @@ -204,8 +204,8 @@ typedef union name { union name *_n; } name; -#define _FrontEndTmp( op ) ( ((op)->t.temp_flags & CONST_TEMP) == 0 && \ +#define _FrontEndTmp( op ) ( ((op)->t.temp_flags & CONST_TEMP) == 0 && \ (op)->v.symbol != NULL ) -#define _ConstTemp( op ) ( ( (op)->n.class == N_TEMP ) && \ - ( (op)->t.temp_flags & CONST_TEMP ) ) +#define _ConstTemp( op ) ( ( (op)->n.class == N_TEMP ) && \ + ( (op)->t.temp_flags & CONST_TEMP ) ) diff --git a/bld/cg/intel/h/x86regn.h b/bld/cg/intel/h/x86regn.h index da72b060ea..503025abc4 100644 --- a/bld/cg/intel/h/x86regn.h +++ b/bld/cg/intel/h/x86regn.h @@ -25,8 +25,7 @@ * * ======================================================================== * -* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE -* DESCRIBE IT HERE! +* Description: x86 register info processing. * ****************************************************************************/ @@ -57,11 +56,11 @@ typedef enum { typedef uint_8 reg_idx; typedef struct arch_reg_info { - hw_reg_set hw_reg; - reg_idx idx; - reg_cls cls; - wv_regs wv_idx; - dw_regs dw_idx; + hw_reg_set hw_reg; /* CG register value */ + reg_idx idx; /* register encoding index */ + reg_cls cls; /* register class */ + wv_regs wv_idx; /* WATCOM debug register index */ + dw_regs dw_idx; /* Dwarf debug register index */ } arch_reg_info; extern const arch_reg_info RegsTab[]; diff --git a/bld/cg/risc/axp/h/axpregn.h b/bld/cg/risc/axp/h/axpregn.h index 4f1dd6184a..8965fbef94 100644 --- a/bld/cg/risc/axp/h/axpregn.h +++ b/bld/cg/risc/axp/h/axpregn.h @@ -25,8 +25,7 @@ * * ======================================================================== * -* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE -* DESCRIBE IT HERE! +* Description: Alpha AXP register info processing. * ****************************************************************************/ @@ -46,10 +45,10 @@ typedef enum { typedef uint_8 reg_idx; typedef struct arch_reg_info { - hw_reg_set hw_reg; - reg_idx idx; - reg_cls cls; - dw_regs dw_idx; + hw_reg_set hw_reg; /* CG register value */ + reg_idx idx; /* register encoding index */ + reg_cls cls; /* register class */ + dw_regs dw_idx; /* Dwarf debug register index */ } arch_reg_info; extern const arch_reg_info RegsTab[]; diff --git a/bld/cg/risc/mps/h/mpsregn.h b/bld/cg/risc/mps/h/mpsregn.h index 5253abbfe3..302fa9ae75 100644 --- a/bld/cg/risc/mps/h/mpsregn.h +++ b/bld/cg/risc/mps/h/mpsregn.h @@ -25,7 +25,7 @@ * * ======================================================================== * -* Description: MIPS register numbers. +* Description: MIPS register info processing. * ****************************************************************************/ @@ -58,10 +58,10 @@ typedef enum { typedef uint_8 reg_idx; typedef struct arch_reg_info { - hw_reg_set hw_reg; - reg_idx idx; - reg_cls cls; - dw_regs dw_idx; + hw_reg_set hw_reg; /* CG register value */ + reg_idx idx; /* register encoding index */ + reg_cls cls; /* register class */ + dw_regs dw_idx; /* Dwarf debug register index */ } arch_reg_info; extern const arch_reg_info RegsTab[]; diff --git a/bld/cg/risc/ppc/h/ppcregn.h b/bld/cg/risc/ppc/h/ppcregn.h index 8cf56a6568..2c5e205c7a 100644 --- a/bld/cg/risc/ppc/h/ppcregn.h +++ b/bld/cg/risc/ppc/h/ppcregn.h @@ -25,8 +25,7 @@ * * ======================================================================== * -* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE -* DESCRIBE IT HERE! +* Description: PowerPC register info processing. * ****************************************************************************/ @@ -46,10 +45,10 @@ typedef enum { typedef uint_8 reg_idx; typedef struct arch_reg_info { - hw_reg_set hw_reg; - reg_idx idx; - reg_cls cls; - dw_regs dw_idx; + hw_reg_set hw_reg; /* CG register value */ + reg_idx idx; /* register encoding index */ + reg_cls cls; /* register class */ + dw_regs dw_idx; /* Dwarf debug register index */ } arch_reg_info; extern const arch_reg_info RegsTab[]; From 101c9ced56fef91d1e8372d6008af26681fe1e33 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Thu, 19 Oct 2023 08:04:15 +0200 Subject: [PATCH 235/258] fixing the code generator to correctly handle the bp/ebp register for in-line assembly code now the in-line assembly code passes information about the use of automatic variables or function parameters to the code generator, then cg can allocate a bp/ebp frame for the function that calls such in-line assembly code --- bld/cc/c/cpragx86.c | 8 +------- bld/cg/intel/c/x86call.c | 3 +++ bld/cg/intel/c/x86proc.c | 4 ++++ bld/cg/intel/c/x86reg.c | 3 +++ bld/cg/intel/h/x86auxcc.h | 1 + bld/cg/intel/h/x86call.h | 2 +- bld/cg/intel/h/x86procd.h | 3 ++- bld/plusplus/c/cpragx86.c | 7 +------ 8 files changed, 16 insertions(+), 15 deletions(-) diff --git a/bld/cc/c/cpragx86.c b/bld/cc/c/cpragx86.c index 5ffb1869ab..8566f00ba0 100644 --- a/bld/cc/c/cpragx86.c +++ b/bld/cc/c/cpragx86.c @@ -345,13 +345,7 @@ enum sym_type AsmQueryType( void *handle ) void AsmUsesAuto( aux_info *info ) /********************************/ { - /* - * We want to force the calling routine to set up a [E]BP frame - * for the use of this pragma. This is done by saying the pragma - * modifies the [E]SP register. A kludge, but it works. - */ -// info->cclass_target |= FECALL_X86_GENERATE_STACK_FRAME; - HW_CTurnOff( info->save, HW_xSP ); + info->cclass_target |= FECALL_X86_NEEDS_BP_CHAIN; } bool AsmInsertFixups( aux_info *info ) diff --git a/bld/cg/intel/c/x86call.c b/bld/cg/intel/c/x86call.c index 5c7ccf463d..5d1f47cd07 100644 --- a/bld/cg/intel/c/x86call.c +++ b/bld/cg/intel/c/x86call.c @@ -215,6 +215,9 @@ an BGCall( cn call, bool use_return, bool aux_inline ) if( _RoutineIsInterrupt( state->attr ) ) { call_ins->flags.call_flags |= CALL_INTERRUPT | CALL_POPS_PARMS; } + if( state->attr & ROUTINE_NEEDS_BP_CHAIN ) { + call_ins->flags.call_flags |= CALL_NEEDS_BP_CHAIN; + } if( !use_return ) { call_ins->flags.call_flags |= CALL_IGNORES_RETURN; } diff --git a/bld/cg/intel/c/x86proc.c b/bld/cg/intel/c/x86proc.c index ce49daaebc..7ab1ded83c 100644 --- a/bld/cg/intel/c/x86proc.c +++ b/bld/cg/intel/c/x86proc.c @@ -73,6 +73,7 @@ && ( !WINDOWS_CHEAP || CurrProc->contains_call ) ) #define DO_BP_CHAIN ( ( ( _IsTargetModel( CGSW_X86_NEED_STACK_FRAME ) \ + || (CurrProc->state.attr & ROUTINE_NEEDS_BP_CHAIN) \ || _IsModel( CGSW_GEN_DBG_CV ) ) \ && CurrProc->contains_call ) \ || (CurrProc->prolog_state & PST_PROLOG_FAT) ) @@ -139,6 +140,9 @@ static bool ScanInstructions( void ) CurrProc->state.attr |= ROUTINE_NEEDS_PROLOG; sp_constant = false; } + if( ins->flags.call_flags & CALL_NEEDS_BP_CHAIN ) { + CurrProc->state.attr |= ROUTINE_NEEDS_BP_CHAIN; + } } } } diff --git a/bld/cg/intel/c/x86reg.c b/bld/cg/intel/c/x86reg.c index 1556cfb679..c8eb79295e 100644 --- a/bld/cg/intel/c/x86reg.c +++ b/bld/cg/intel/c/x86reg.c @@ -128,6 +128,9 @@ type_class_def CallState( aux_handle aux, type_def *tipe, call_state *state ) if( cclass_target & FECALL_X86_FARSS ) { state->attr |= ROUTINE_FARSS; } + if( cclass_target & FECALL_X86_NEEDS_BP_CHAIN ) { + state->attr |= ROUTINE_NEEDS_BP_CHAIN; + } if( state == &CurrProc->state ) { if( cclass_target & (FECALL_X86_GENERATE_STACK_FRAME | FECALL_X86_PROLOG_HOOKS | FECALL_X86_EPILOG_HOOKS) ) { CurrProc->prolog_state |= PST_PROLOG_FAT; diff --git a/bld/cg/intel/h/x86auxcc.h b/bld/cg/intel/h/x86auxcc.h index b64aa654af..f900095c78 100644 --- a/bld/cg/intel/h/x86auxcc.h +++ b/bld/cg/intel/h/x86auxcc.h @@ -57,4 +57,5 @@ typedef enum { FECALL_X86_FARSS = 0x00200000, FECALL_X86_PARMS_STACK_RESERVE = 0x00400000, FECALL_X86_PARMS_PREFER_REGS = 0x00800000, + FECALL_X86_NEEDS_BP_CHAIN = 0x01000000, } call_class_target; diff --git a/bld/cg/intel/h/x86call.h b/bld/cg/intel/h/x86call.h index ce0d375ad3..c6905d0fc0 100644 --- a/bld/cg/intel/h/x86call.h +++ b/bld/cg/intel/h/x86call.h @@ -34,4 +34,4 @@ CALL_POPS_PARMS = 0x0040, CALL_INTERRUPT = 0x0080, CALL_FAR16 = 0x0100, - CALL_NEEDFRAME = 0x0200, + CALL_NEEDS_BP_CHAIN = 0x0200, diff --git a/bld/cg/intel/h/x86procd.h b/bld/cg/intel/h/x86procd.h index ec57e6055d..5623ae009e 100644 --- a/bld/cg/intel/h/x86procd.h +++ b/bld/cg/intel/h/x86procd.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -55,6 +55,7 @@ typedef enum { ROUTINE_STACK_RESERVE = 0x00020000, ROUTINE_PREFER_REGS = 0x00040000, ROUTINE_FARSS = 0x00080000, + ROUTINE_NEEDS_BP_CHAIN = 0x00100000, } call_attributes; #define _RoutineIsLong( x ) \ diff --git a/bld/plusplus/c/cpragx86.c b/bld/plusplus/c/cpragx86.c index aa67c4283d..c62aafe790 100644 --- a/bld/plusplus/c/cpragx86.c +++ b/bld/plusplus/c/cpragx86.c @@ -827,12 +827,7 @@ AUX_INFO *AsmSysCreateAux( const char *name ) void AsmSysUsesAuto( void ) /*************************/ { - /* - We want to force the calling routine to set up a [E]BP frame - for the use of this pragma. This is done by saying the pragma - modifies the [E]SP register. A kludge, but it works. - */ - HW_CTurnOff( CurrInfo->save, HW_xSP ); + CurrInfo->cclass_target |= FECALL_X86_NEEDS_BP_CHAIN; ScopeASMUsesAuto(); } From ab77ed6b81135527cf3d6daf4b2ce2486ac7f7a1 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Thu, 19 Oct 2023 08:13:38 +0200 Subject: [PATCH 236/258] update comment --- bld/cc/c/cpragaxp.c | 6 ++---- bld/cc/c/cpragmps.c | 6 ++---- bld/cc/c/cpragppc.c | 6 ++---- bld/plusplus/c/cpragrsc.c | 5 +++++ 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/bld/cc/c/cpragaxp.c b/bld/cc/c/cpragaxp.c index b085b2ecb4..b4ea22e7ac 100644 --- a/bld/cc/c/cpragaxp.c +++ b/bld/cc/c/cpragaxp.c @@ -61,12 +61,10 @@ void AsmUsesAuto( aux_info *info ) /* unused parameters */ (void)info; /* - * We want to force the calling routine to set up a [E]BP frame - * for the use of this pragma. This is done by saying the pragma - * modifies the [E]SP register. A kludge, but it works. + * We want to force the calling routine to set up a stack frame + * for the use of this pragma. */ // info->cclass_target |= FECALL_X86_GENERATE_STACK_FRAME; -// HW_CTurnOff( info->save, HW_xSP ); } bool AsmInsertFixups( aux_info *info ) diff --git a/bld/cc/c/cpragmps.c b/bld/cc/c/cpragmps.c index 792165cc27..4b332751d1 100644 --- a/bld/cc/c/cpragmps.c +++ b/bld/cc/c/cpragmps.c @@ -61,12 +61,10 @@ void AsmUsesAuto( aux_info *info ) /* unused parameters */ (void)info; /* - * We want to force the calling routine to set up a [E]BP frame - * for the use of this pragma. This is done by saying the pragma - * modifies the [E]SP register. A kludge, but it works. + * We want to force the calling routine to set up a stack frame + * for the use of this pragma. */ // info->cclass_target |= FECALL_X86_GENERATE_STACK_FRAME; -// HW_CTurnOff( info->save, HW_xSP ); } bool AsmInsertFixups( aux_info *info ) diff --git a/bld/cc/c/cpragppc.c b/bld/cc/c/cpragppc.c index 016f98a4ca..bd3a4f771e 100644 --- a/bld/cc/c/cpragppc.c +++ b/bld/cc/c/cpragppc.c @@ -179,12 +179,10 @@ void AsmUsesAuto( aux_info *info ) /* unused parameters */ (void)info; /* - * We want to force the calling routine to set up a [E]BP frame - * for the use of this pragma. This is done by saying the pragma - * modifies the [E]SP register. A kludge, but it works. + * We want to force the calling routine to set up a stack frame + * for the use of this pragma. */ // info->cclass_target |= FECALL_X86_GENERATE_STACK_FRAME; -// HW_CTurnOff( info->save, HW_xSP ); } bool AsmInsertFixups( aux_info *info ) diff --git a/bld/plusplus/c/cpragrsc.c b/bld/plusplus/c/cpragrsc.c index b59a7f66ba..62f0d6d917 100644 --- a/bld/plusplus/c/cpragrsc.c +++ b/bld/plusplus/c/cpragrsc.c @@ -271,6 +271,11 @@ AUX_INFO *AsmSysCreateAux( const char *name ) void AsmSysUsesAuto( void ) /*************************/ { + /* + * We want to force the calling routine to set up a stack frame + * for the use of this pragma. + */ +// info->cclass_target |= FECALL_X86_GENERATE_STACK_FRAME; ScopeASMUsesAuto(); } From 62d8590049b088017ecfbb9d8ce3357f41baec7a Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Tue, 7 Nov 2023 20:08:32 +0100 Subject: [PATCH 237/258] add minimal info about linking for PMODE/W DOS Extender add info for linking PMODE/W DOS Extender Executable to OW documentation --- docs/doc/cmn/owcc.gml | 4 ++++ docs/doc/cmn/wcl.gml | 4 ++++ docs/doc/cmn/wfl.gml | 4 ++++ docs/doc/lg/tutmain.gml | 13 +++++++++++++ docs/doc/lg/tutqnx.gml | 2 ++ 5 files changed, 27 insertions(+) diff --git a/docs/doc/cmn/owcc.gml b/docs/doc/cmn/owcc.gml index 00f63618b1..5ec1fd3d69 100644 --- a/docs/doc/cmn/owcc.gml +++ b/docs/doc/cmn/owcc.gml @@ -147,6 +147,8 @@ session session .notebreak 32-bit Linux executables (synonym for "LINUX") under Linux +.note CAUSEWAY +32-bit Causeway DOS Extender executables .note COM 16-bit DOS "COM" files .note DOS @@ -179,6 +181,8 @@ session 32-bit OS/2 PM executables .note PHARLAP 32-bit PharLap DOS Extender executables +.note PMODEW +32-bit PMODE/W DOS Extender executables .note QNX 16-bit QNX executables .note QNX386 diff --git a/docs/doc/cmn/wcl.gml b/docs/doc/cmn/wcl.gml index 0628732073..9451ca7f81 100644 --- a/docs/doc/cmn/wcl.gml +++ b/docs/doc/cmn/wcl.gml @@ -164,6 +164,8 @@ session session .notebreak 32-bit Linux executables (synonym for "LINUX") under Linux +.note CAUSEWAY +32-bit Causeway DOS Extender executables .note COM 16-bit DOS "COM" files .note DOS @@ -196,6 +198,8 @@ session 32-bit OS/2 PM executables .note PHARLAP 32-bit PharLap DOS Extender executables +.note PMODEW +32-bit PMODE/W DOS Extender executables .note QNX 16-bit QNX executables .note QNX386 diff --git a/docs/doc/cmn/wfl.gml b/docs/doc/cmn/wfl.gml index 1e95166661..8b960850f6 100644 --- a/docs/doc/cmn/wfl.gml +++ b/docs/doc/cmn/wfl.gml @@ -123,6 +123,8 @@ session session .notebreak 32-bit Linux executables (synonym for "LINUX") under Linux +.note CAUSEWAY +32-bit Causeway DOS Extender executables .note COM 16-bit DOS "COM" files .note DOS @@ -155,6 +157,8 @@ session 32-bit OS/2 PM executables .note PHARLAP 32-bit PharLap DOS Extender executables +.note PMODEW +32-bit PMODE/W DOS Extender executables .note QNX 16-bit QNX executables .note QNX386 diff --git a/docs/doc/lg/tutmain.gml b/docs/doc/lg/tutmain.gml index ecacba1ee9..e2a0b594d8 100644 --- a/docs/doc/lg/tutmain.gml +++ b/docs/doc/lg/tutmain.gml @@ -97,6 +97,8 @@ from the server libraries. 32-bit x86 OS/2 Presentation Manager executable .note pharlap 32-bit x86 Phar Lap executable +.note pmodew +32-bit x86 PMODE/W executable .note tnt 32-bit x86 Phar Lap TNT executable .note rdos @@ -346,6 +348,17 @@ system dos4g For more information, see the chapter entitled :HDREF refid='os2chap'.. .* +.section Linking 32-bit x86 PMODE/W Executable Files +.* +.np +.ix '32-bit PMODE/W executables' +To create these files, use one of the following structures. +.millust begin +system pmodew +.im tutsteps +.millust end +.np +.* .section Linking 32-bit x86 FlashTek Executable Files .* .np diff --git a/docs/doc/lg/tutqnx.gml b/docs/doc/lg/tutqnx.gml index c66e00f542..4ac77bc1f8 100644 --- a/docs/doc/lg/tutqnx.gml +++ b/docs/doc/lg/tutqnx.gml @@ -69,6 +69,8 @@ synonym for "netware" 32-bit x86 OS/2 Presentation Manager executable .note pharlap 32-bit x86 Phar Lap executable +.note pmodew +32-bit x86 PMODE/W executable .note tnt 32-bit x86 Phar Lap TNT dos style executable .note qnx From 5832ce66619fbd710128b98b4ee69006baa55019 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Tue, 7 Nov 2023 20:41:27 +0100 Subject: [PATCH 238/258] correct copy and past error --- docs/doc/lg/tutmain.gml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/doc/lg/tutmain.gml b/docs/doc/lg/tutmain.gml index e2a0b594d8..5837104fa0 100644 --- a/docs/doc/lg/tutmain.gml +++ b/docs/doc/lg/tutmain.gml @@ -352,7 +352,7 @@ see the chapter entitled :HDREF refid='os2chap'.. .* .np .ix '32-bit PMODE/W executables' -To create these files, use one of the following structures. +To create this type of file, use the following structure. .millust begin system pmodew .im tutsteps From ccd1a6b11b0bcdf69cd818b9960e42f9724d0c79 Mon Sep 17 00:00:00 2001 From: Americus Maximus <75050995+americusmaximus@users.noreply.github.com> Date: Sat, 11 Nov 2023 07:45:08 -0500 Subject: [PATCH 239/258] Fixing invalid argument types in IDirectDrawSurface4 interface. (#1149) --- bld/w32api/include/ddraw.mh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bld/w32api/include/ddraw.mh b/bld/w32api/include/ddraw.mh index 7d04de6809..c840693131 100644 --- a/bld/w32api/include/ddraw.mh +++ b/bld/w32api/include/ddraw.mh @@ -1698,10 +1698,10 @@ DECLARE_INTERFACE_( IDirectDrawSurface4, IUnknown ) { STDMETHOD( GetOverlayPosition )( THIS_ LPLONG, LPLONG ) PURE; STDMETHOD( GetPalette )( THIS_ LPDIRECTDRAWPALETTE * ) PURE; STDMETHOD( GetPixelFormat )( THIS_ LPDDPIXELFORMAT ) PURE; - STDMETHOD( GetSurfaceDesc )( THIS_ LPDDSURFACEDESC ) PURE; - STDMETHOD( Initialize )( THIS_ LPDIRECTDRAW, LPDDSURFACEDESC ) PURE; + STDMETHOD( GetSurfaceDesc )( THIS_ LPDDSURFACEDESC2 ) PURE; + STDMETHOD( Initialize )( THIS_ LPDIRECTDRAW, LPDDSURFACEDESC2 ) PURE; STDMETHOD( IsLost )( THIS ) PURE; - STDMETHOD( Lock )( THIS_ LPRECT, LPDDSURFACEDESC, DWORD, HANDLE ) PURE; + STDMETHOD( Lock )( THIS_ LPRECT, LPDDSURFACEDESC2, DWORD, HANDLE ) PURE; STDMETHOD( ReleaseDC )( THIS_ HDC ) PURE; STDMETHOD( Restore )( THIS ) PURE; STDMETHOD( SetClipper )( THIS_ LPDIRECTDRAWCLIPPER ) PURE; @@ -1719,7 +1719,7 @@ DECLARE_INTERFACE_( IDirectDrawSurface4, IUnknown ) { STDMETHOD( PageUnlock )( THIS_ DWORD ) PURE; /* IDirectDrawSurface3 methods */ - STDMETHOD( SetSurfaceDesc )( THIS_ LPDDSURFACEDESC, DWORD ) PURE; + STDMETHOD( SetSurfaceDesc )( THIS_ LPDDSURFACEDESC2, DWORD ) PURE; /* IDirectDrawSurface4 methods */ STDMETHOD( SetPrivateData )( THIS_ REFGUID, LPVOID, DWORD, DWORD ) PURE; From b591511ce4650ebe5fc08226d60f90fda7ba9cc1 Mon Sep 17 00:00:00 2001 From: Americus Maximus <75050995+americusmaximus@users.noreply.github.com> Date: Sat, 11 Nov 2023 07:45:45 -0500 Subject: [PATCH 240/258] Fixing D3DSHADEMODE member name. (#1151) --- bld/w32api/include/directx/d3dtypes.mh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bld/w32api/include/directx/d3dtypes.mh b/bld/w32api/include/directx/d3dtypes.mh index 78dc148d23..8ba2718473 100644 --- a/bld/w32api/include/directx/d3dtypes.mh +++ b/bld/w32api/include/directx/d3dtypes.mh @@ -829,7 +829,7 @@ typedef D3DPICKRECORD *LPD3DPICKRECORD; #if (DIRECT3D_VERSION < 0x0800) typedef enum _D3DSHADEMODE { D3DSHADE_FLAT = 1, - D3DSHADE_GOURAND = 2, + D3DSHADE_GOURAUD = 2, #if (DIRECT3D_VERSION >= 0x0500) D3DSHADE_PHONG = 3, D3DSHADE_FORCE_DWORD = 0x7FFFFFFF From af51255ab6905fa083c6f8955c4cd1b3a70b39f0 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Sat, 11 Nov 2023 16:06:34 +0100 Subject: [PATCH 241/258] Fixing invalid argument types in IDirectDrawSurface4 interface. --- bld/w32api/include/ddraw.mh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bld/w32api/include/ddraw.mh b/bld/w32api/include/ddraw.mh index c840693131..03f942eba9 100644 --- a/bld/w32api/include/ddraw.mh +++ b/bld/w32api/include/ddraw.mh @@ -1690,7 +1690,7 @@ DECLARE_INTERFACE_( IDirectDrawSurface4, IUnknown ) { STDMETHOD( Flip )( THIS_ LPDIRECTDRAWSURFACE4, DWORD ) PURE; STDMETHOD( GetAttachedSurface )( THIS_ LPDDSCAPS2, LPDIRECTDRAWSURFACE4 * ) PURE; STDMETHOD( GetBltStatus )( THIS_ DWORD ) PURE; - STDMETHOD( GetCaps )( THIS_ LPDDSCAPS ) PURE; + STDMETHOD( GetCaps )( THIS_ LPDDSCAPS2 ) PURE; STDMETHOD( GetClipper )( THIS_ LPDIRECTDRAWCLIPPER * ) PURE; STDMETHOD( GetColorKey )( THIS_ DWORD, LPDDCOLORKEY ) PURE; STDMETHOD( GetDC )( THIS_ HDC * ) PURE; From daaf92010685ca2b9253ce190a5df8c5de268c58 Mon Sep 17 00:00:00 2001 From: Americus Maximus <75050995+americusmaximus@users.noreply.github.com> Date: Wed, 15 Nov 2023 10:32:58 -0500 Subject: [PATCH 242/258] Fixing D3DTEXTUREMAGFILTER member names. (#1152) --- bld/w32api/include/directx/d3dtypes.mh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bld/w32api/include/directx/d3dtypes.mh b/bld/w32api/include/directx/d3dtypes.mh index 8ba2718473..853c6a2136 100644 --- a/bld/w32api/include/directx/d3dtypes.mh +++ b/bld/w32api/include/directx/d3dtypes.mh @@ -1490,8 +1490,8 @@ typedef enum _D3DTEXTUREMAGFILTER { D3DTFG_POINT = 1, D3DTFG_LINEAR = 2, D3DTFG_FLATCUBIC = 3, - D3DTFG_GUASSIANCUBIC = 4, - D3DTFG_ANSIOTROPIC = 5, + D3DTFG_GAUSSIANCUBIC = 4, + D3DTFG_ANISOTROPIC = 5, D3DTFG_FORCE_DWORD = 0x7FFFFFFF } D3DTEXTUREMAGFILTER; #endif From 6215253be92fa60eccdf79e16b669cfc64fdf4a4 Mon Sep 17 00:00:00 2001 From: Americus Maximus <75050995+americusmaximus@users.noreply.github.com> Date: Wed, 15 Nov 2023 10:41:43 -0500 Subject: [PATCH 243/258] Adding missing Direct3D device IIDs. (#1153) --- bld/w32api/include/directx/d3d.mh | 7 +++++++ bld/w32api/lib/directx/dxguid.c | 14 ++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/bld/w32api/include/directx/d3d.mh b/bld/w32api/include/directx/d3d.mh index 3de50276c7..a1005e1afd 100644 --- a/bld/w32api/include/directx/d3d.mh +++ b/bld/w32api/include/directx/d3d.mh @@ -1933,6 +1933,10 @@ EXTERN_C const IID __cdecl IID_IDirect3DDevice2; EXTERN_C const IID __cdecl IID_IDirect3DMaterial2; EXTERN_C const IID __cdecl IID_IDirect3DTexture2; EXTERN_C const IID __cdecl IID_IDirect3DViewport2; +EXTERN_C const IID __cdecl IID_IDirect3DRampDevice; +EXTERN_C const IID __cdecl IID_IDirect3DRGBDevice; +EXTERN_C const IID __cdecl IID_IDirect3DHALDevice; +EXTERN_C const IID __cdecl IID_IDirect3DMMXDevice; #endif #if (DIRECT3D_VERSION >= 0x0600) EXTERN_C const IID __cdecl IID_IDirect3D3; @@ -1940,11 +1944,14 @@ EXTERN_C const IID __cdecl IID_IDirect3DDevice3; EXTERN_C const IID __cdecl IID_IDirect3DMaterial3; EXTERN_C const IID __cdecl IID_IDirect3DViewport3; EXTERN_C const IID __cdecl IID_IDirect3DVertexBuffer; +EXTERN_C const IID __cdecl IID_IDirect3DRefDevice; +EXTERN_C const IID __cdecl IID_IDirect3DNullDevice; #endif #if (DIRECT3D_VERSION >= 0x0700) EXTERN_C const IID __cdecl IID_IDirect3D7; EXTERN_C const IID __cdecl IID_IDirect3DDevice7; EXTERN_C const IID __cdecl IID_IDirect3DVertexBuffer7; +EXTERN_C const IID __cdecl IID_IDirect3DTnLHalDevice; #endif #endif /* _D3D_H_ */ diff --git a/bld/w32api/lib/directx/dxguid.c b/bld/w32api/lib/directx/dxguid.c index ebe7eadc5d..9c110f7e95 100644 --- a/bld/w32api/lib/directx/dxguid.c +++ b/bld/w32api/lib/directx/dxguid.c @@ -71,6 +71,20 @@ EXTERN_C const IID IID_IDirect3DDevice7 = { 0xF5049E79, 0x4861, 0x11D2, { 0xA4, 0x07, 0x00, 0xA0, 0xC9, 0x06, 0x29, 0xA8 } }; EXTERN_C const IID IID_IDirect3DVertexBuffer7 = { 0xF5049E7D, 0x4861, 0x11D2, { 0xA4, 0x07, 0x00, 0xA0, 0xC9, 0x06, 0x29, 0xA8 } }; +EXTERN_C const IID IID_IDirect3DRampDevice = + { 0xF2086B20, 0x259F, 0x11CF, { 0xA3, 0x1A, 0x00, 0xAA, 0x00, 0xB9, 0x33, 0x56 } }; +EXTERN_C const IID IID_IDirect3DRGBDevice = + { 0xA4665C60, 0x2673, 0x11CF, { 0xA3, 0x1A, 0x00, 0xAA, 0x00, 0xB9, 0x33, 0x56 } }; +EXTERN_C const IID IID_IDirect3DHALDevice = + { 0x84E63DE0, 0x46AA, 0x11CF, { 0x81, 0x6F, 0x00, 0x00, 0xC0, 0x20, 0x15, 0x6E } }; +EXTERN_C const IID IID_IDirect3DMMXDevice = + { 0x881949A1, 0xD6F3, 0x11D0, { 0x89, 0xAB, 0x00, 0xA0, 0xC9, 0x05, 0x41, 0x29 } }; +EXTERN_C const IID IID_IDirect3DRefDevice = + { 0x50936643, 0x13E9, 0x11D1, { 0x89, 0xAA, 0x00, 0xA0, 0xC9, 0x05, 0x41, 0x29 } }; +EXTERN_C const IID IID_IDirect3DNullDevice = + { 0x8767DF22, 0xBACC, 0x11D1, { 0x89, 0x69, 0x00, 0xA0, 0xC9, 0x06, 0x29, 0xA8 } }; +EXTERN_C const IID IID_IDirect3DTnLHalDevice = + { 0xF5049E78, 0x4861, 0x11D2, { 0xA4, 0x07, 0x00, 0xA0, 0xC9, 0x06, 0x29, 0xA8 } }; /* d3drmobj.h */ EXTERN_C const IID IID_IDirect3DRMObject = From d2e20a1ee5b5deff7d9239c00c6fd7772cd41d56 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Sat, 18 Nov 2023 10:03:08 +0100 Subject: [PATCH 244/258] remove unused file --- bld/cg/h/fejump.h | 50 ----------------------------------------------- 1 file changed, 50 deletions(-) delete mode 100644 bld/cg/h/fejump.h diff --git a/bld/cg/h/fejump.h b/bld/cg/h/fejump.h deleted file mode 100644 index 3c6508b2bc..0000000000 --- a/bld/cg/h/fejump.h +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************** -* -* Open Watcom Project -* -* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. -* -* ======================================================================== -* -* This file contains Original Code and/or Modifications of Original -* Code as defined in and that are subject to the Sybase Open Watcom -* Public License version 1.0 (the 'License'). You may not use this file -* except in compliance with the License. BY USING THIS FILE YOU AGREE TO -* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is -* provided with the Original Code and Modifications, and is also -* available at www.sybase.com/developer/opensource. -* -* The Original Code and all software distributed under the License are -* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER -* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM -* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF -* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR -* NON-INFRINGEMENT. Please see the License for the specific language -* governing rights and limitations under the License. -* -* ======================================================================== -* -* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE -* DESCRIBE IT HERE! -* -****************************************************************************/ - - -typedef enum { - RECEIVECOMAREA, - FEMODULENAME, - FEtrue, - FEATTR, - FESEGID, - FENAME, - FEBACK, - FELEXLEVEL, - FEPARMTYPE, - FEMOREMEM, - FESTACKCHK, - FEAUXINFO, - FEMESSAGE, - DOCOMPILE, - FEDBGTYPE, - FEGENPROC -} fejump; From 2df3d04748e2bf4f433ecf7dc03b470b656e5347 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Sat, 18 Nov 2023 11:23:16 +0100 Subject: [PATCH 245/258] reformat source files --- bld/cg/c/liveinfo.c | 68 ++++++++++--------- bld/cg/intel/386/c/386enc.c | 128 ++++++++++++++++++++++-------------- 2 files changed, 115 insertions(+), 81 deletions(-) diff --git a/bld/cg/c/liveinfo.c b/bld/cg/c/liveinfo.c index 3b66a2ff16..9ddc5facbd 100644 --- a/bld/cg/c/liveinfo.c +++ b/bld/cg/c/liveinfo.c @@ -45,14 +45,13 @@ static void GlobalConflictsFirst( void ) /*************************************************** - - Run down the list of conflicts and rip out any which are - USE_IN_ANOTHER_BLOCK and not CONFLICT_ON_HOLD (ones with global - bits). Make a new list out of these global-bit conflicts and, when - we're done, create a new conflict list with these global-bit - conflicts at the front, so that ExtendConflicts can have an early - out. -*/ + * Run down the list of conflicts and rip out any which are + * USE_IN_ANOTHER_BLOCK and not CONFLICT_ON_HOLD (ones with global + * bits). Make a new list out of these global-bit conflicts and, when + * we're done, create a new conflict list with these global-bit + * conflicts at the front, so that ExtendConflicts can have an early + * out. + */ { conflict_node **conf_owner; conflict_node **list_owner; @@ -81,8 +80,7 @@ static void GlobalConflictsFirst( void ) static void ExtendConflicts( block *blk, conflict_node *first_global ) -/************************************************************************/ -/* +/************************************************************************* * Make sure that first & last pointers of extended conflicts point * to instructions that will never be replaced. (ie: OP_NOP) * Also, make sure there's a NOP at the end of the block to hold @@ -165,7 +163,7 @@ static void AssignBit( conflict_node *conf, block *blk ) _SetTrue( conf, CST_CONFLICT_ON_HOLD ); } else if( _Isnt( conf, CST_CONFLICT_ON_HOLD ) ) { _LBitFirst( bit ); - for(;;) { + for( ;; ) { if( _LBitOverlap( blk->available_bit, bit ) ) break; _LBitNext( &bit ); @@ -242,10 +240,10 @@ static void FlowConflicts( instruction *first, instruction *last, block *blk #endif ins = last; for( ;; ) { - - /* The operands of the current instruction are live in */ - /* previous instructions */ - + /* + * The operands of the current instruction are live in + * previous instructions + */ opcode = ins->head.opcode; i = 0; switch( opcode ) { @@ -257,7 +255,10 @@ static void FlowConflicts( instruction *first, instruction *last, block *blk break; if( ins->operands[1]->n.class != N_REGISTER ) break; - i = OpcodeNumOperands( ins ); /* ignore the register operands */ + /* + * ignore the register operands + */ + i = OpcodeNumOperands( ins ); break; } if( opcode != OP_BLOCK ) { @@ -271,15 +272,17 @@ static void FlowConflicts( instruction *first, instruction *last, block *blk } } if( ins->head.opcode == OP_CALL - || ins->head.opcode == OP_CALL_INDIRECT ) { - /* all memory names are operands of a call instruction*/ + || ins->head.opcode == OP_CALL_INDIRECT ) { + /* + * all memory names are operands of a call instruction + */ _GBitTurnOn( alive.out_of_block, MemoryBits ); } - - /* Move information into current instruction*/ - /* (This information indicates what is live between*/ - /* previous instruction & this instruction)*/ - + /* + * Move information into current instruction + * (This information indicates what is live between + * previous instruction & this instruction) + */ ins->head.live.regs = alive.regs; HW_TurnOn( ins->head.live.regs, CurrProc->state.unalterable ); @@ -289,11 +292,11 @@ static void FlowConflicts( instruction *first, instruction *last, block *blk ins = ins->head.prev; if( ins == first ) break; - - /* Since the result is redefined by the current instruction,*/ - /* its previous value is not live in previous instructions*/ - /* Same goes for a zapped register.*/ - + /* + * Since the result is redefined by the current instruction, + * its previous value is not live in previous instructions + * Same goes for a zapped register. + */ HW_TurnOff( alive.regs, ins->zap->reg ); opnd = ins->result; if( opnd != NULL ) { @@ -303,8 +306,8 @@ static void FlowConflicts( instruction *first, instruction *last, block *blk } else { conf = FindConflictNode( opnd, blk, ins ); NowDead( opnd, conf, &alive, blk ); - - /* 2007-06-28 RomanT + /* + * 2007-06-28 RomanT * Force result of volatile instruction to live after it. * Otherwise we'll have a ghost which don't have conflicts but * still need a register (and can steal assigned one). (bug #439) @@ -380,8 +383,9 @@ void LiveInfoUpdate( void ) void UpdateLive( instruction *first, instruction *last ) -/*********************************************************/ -/* update the live information from 'first'.prev to 'last'.next inclusive */ +/********************************************************** + * update the live information from 'first'.prev to 'last'.next inclusive + */ { instruction *ins; diff --git a/bld/cg/intel/386/c/386enc.c b/bld/cg/intel/386/c/386enc.c index 95bf29049e..3af9cc6529 100644 --- a/bld/cg/intel/386/c/386enc.c +++ b/bld/cg/intel/386/c/386enc.c @@ -100,7 +100,8 @@ void DoRepOp( instruction *ins ) size = ins->result->n.size; first = true; - if( ins->head.opcode == OP_MOV && !UseRepForm( size ) ) { + if( ins->head.opcode == OP_MOV + && !UseRepForm( size ) ) { for( ; size >= 4; size -= 4 ) { if( first ) { LayOpbyte( M_MOVSW ); @@ -116,7 +117,8 @@ void DoRepOp( instruction *ins ) } else { LayOpbyte( M_REPE ); if( ins->head.opcode == OP_MOV ) { - if( ( size & ( 4 - 1 ) ) == 0 || OptForSize <= 50 ) { + if( (size & ( 4 - 1 )) == 0 + || OptForSize <= 50 ) { if( _IsntTargetModel( CGSW_X86_USE_32 ) ) AddByte( M_OPND_SIZE ); AddByte( M_MOVSW ); @@ -139,14 +141,14 @@ void DoRepOp( instruction *ins ) static hw_reg_set IndexTab[] = { - HW_D( HW_EAX ), - HW_D( HW_ECX ), - HW_D( HW_EDX ), - HW_D( HW_EBX ), - HW_D( HW_ESP ), - HW_D( HW_EBP ), - HW_D( HW_ESI ), - HW_D( HW_EDI ) + HW_D( HW_EAX ), + HW_D( HW_ECX ), + HW_D( HW_EDX ), + HW_D( HW_EBX ), + HW_D( HW_ESP ), + HW_D( HW_EBP ), + HW_D( HW_ESI ), + HW_D( HW_EDI ) }; @@ -162,9 +164,11 @@ static void Add32Displacement( int_32 val ) byte Displacement( int_32 val, hw_reg_set regs ) /*************************************************/ { - if( val == 0 && !HW_COvlap( regs, HW_EBP ) ) + if( val == 0 + && !HW_COvlap( regs, HW_EBP ) ) return( DISP0 ); - if( val <= 127 && val >= -128 ) { + if( val <= 127 + && val >= -128 ) { AddByte( val & 0xff ); return( DISP8 ); } else { @@ -261,14 +265,17 @@ static void EA( hw_reg_set base, hw_reg_set index, scale_typ scale, _Zoiks( ZOIKS_079 ); if( HW_CEqual( base, HW_EMPTY ) ) { if( HW_CEqual( index, HW_EMPTY ) ) { - // [disp32] + /* + * [disp32] + */ if( scale != 0 || val != 0 ) _Zoiks( ZOIKS_079 ); Inst[RMR] |= DoMDisp( mem_loc, true ); - } else { if( scale != 0 ) { - // [disp32+scale_index] + /* + * [disp32+scale_index] + */ Inst[RMR] |= DoScaleIndex( HW_EBP, index, scale ); Inst[RMR] |= DISP0; if( mem_loc != NULL ) { @@ -278,27 +285,33 @@ static void EA( hw_reg_set base, hw_reg_set index, scale_typ scale, Add32Displacement( val ); } } else { - // [(disp0|disp8|disp32)+index] + /* + * [(disp0|disp8|disp32)+index] + */ Inst[RMR] |= DoIndex( index ); Inst[RMR] |= DoDisp( val, index, mem_loc ); } } } else { - // [(disp0|disp8|disp32)+base+scale_index] + /* + * [(disp0|disp8|disp32)+base+scale_index] + */ if( HW_CEqual( index, HW_EMPTY ) ) { - if( scale == 0 && !HW_CEqual( base, HW_ESP ) ) { + if( scale == 0 + && !HW_CEqual( base, HW_ESP ) ) { Inst[RMR] |= DoIndex( base ); } else { Inst[RMR] |= DoScaleIndex( base, HW_ESP, scale ); } } else { - if( scale == 0 && HW_CEqual( base, HW_EBP ) + if( scale == 0 + && HW_CEqual( base, HW_EBP ) && ( lea || _IsntTargetModel( CGSW_X86_FLOATING_DS ) && _IsntTargetModel( CGSW_X86_FLOATING_SS ) ) ) { /* - flip base & index registers so that we might avoid having - to output a byte displacement (can't have a zero sized - displacement with EBP as the base register) - */ + * flip base & index registers so that we might avoid having + * to output a byte displacement (can't have a zero sized + * displacement with EBP as the base register) + */ base = index; HW_CAsgn( index, HW_EBP ); } @@ -341,16 +354,18 @@ static int_32 GetNextAddConstant( instruction *ins ) break; if( next->operands[1]->c.const_type != CONS_ABSOLUTE ) break; - /* we should not remove the ADD if its flags are used! */ + /* + * we should not remove the ADD if its flags are used! + */ if( next->ins_flags & INS_CC_USED ) break; /* - we've got something like: - LEA EAX, [ECX+EDX] - ADD EAX, 3 - turn it into: - LEA EAX, 3[ECX+EDX] - */ + * we've got something like: + * LEA EAX, [ECX+EDX] + * ADD EAX, 3 + * turn it into: + * LEA EAX, 3[ECX+EDX] + */ disp = neg * next->operands[1]->c.lo.int_value, DoNothing( next ); break; @@ -400,8 +415,10 @@ void LayLeaRegOp( instruction *ins ) switch( right->c.lo.int_value ) { case 1: if( _CPULevel( CPU_586 ) ) { - // want to avoid the extra big-fat 0 on 586's - // but two base registers is slower on a 486 + /* + * want to avoid the extra big-fat 0 on 586's + * but two base registers is slower on a 486 + */ EA( left->r.reg, left->r.reg, 0, disp, NULL, true ); break; } @@ -432,7 +449,9 @@ static void LayIdxModRM( name *op ) CheckSize(); if( HW_COvlap( op->i.index->r.reg, HW_SEGS ) ) { - /* check for seg override*/ + /* + * check for seg override + */ GenSeg( op->i.index->r.reg ); } idx_reg = op->i.index->r.reg; @@ -461,7 +480,8 @@ static void LayIdxModRM( name *op ) } } HW_TurnOff( idx_reg, base_reg ); - if( HW_CEqual( idx_reg, HW_ESP ) && HW_CEqual( base_reg, HW_EMPTY ) ) { + if( HW_CEqual( idx_reg, HW_ESP ) + && HW_CEqual( base_reg, HW_EMPTY ) ) { HW_CAsgn( base_reg, HW_ESP ); HW_CAsgn( idx_reg, HW_EMPTY ); } @@ -507,7 +527,10 @@ void DoMAddr( name *op ) ILen += 4; if( op->n.class == N_CONSTANT ) { _Zoiks( ZOIKS_035 ); - } else { /* assume global name*/ + } else { + /* + * assume global name + */ DoSymRef( op, op->v.offset, false ); } } @@ -526,7 +549,8 @@ void DoRelocConst( name *op, type_class_def type_class ) } else { DoSymRef( op->c.value, 0, true ); } - if( type_class == U4 || type_class == I4 ) { /* as in PUSH seg _x */ + if( type_class == U4 + || type_class == I4 ) { /* as in PUSH seg _x */ AddByte( 0 ); AddByte( 0 ); } @@ -566,7 +590,7 @@ pointer GenFar16Thunk( pointer label, uint_16 parms_size, bool remove_parms ) pointer code_32; old_segid = SetOP( AskCode16Seg() ); - // CodeLabel( label, DepthAlign( PROC_ALIGN ) ); +// CodeLabel( label, DepthAlign( PROC_ALIGN ) ); code_32 = AskForNewLabel(); TellOptimizerByPassed(); SetUpObj( false ); @@ -584,7 +608,9 @@ pointer GenFar16Thunk( pointer label, uint_16 parms_size, bool remove_parms ) OutDataByte( 0xcb ); OutDataShort( 0 ); // padding } - // emit "reloc for offset of code_32 label" + /* + * emit "reloc for offset of code_32 label" + */ SetUpObj( true ); TellKeepLabel( code_32 ); OutReloc( AskCodeSeg(), F_OFFSET, false ); @@ -691,9 +717,9 @@ void GenProfilingCode( char *fe_name, label_handle *data, bool prolog ) #endif segment_id GenProfileData( char *fe_name, label_handle *data, label_handle *stack ) -/*********************************************************************************/ -/* generate P5 profiler code */ -/*********************************************************************************/ +/********************************************************************************** + * generate P5 profiler code + */ { segment_id old_segid; segment_id data_segid = (segment_id)(pointer_uint)FEAuxInfo( NULL, FEINF_P5_PROF_SEG ); @@ -776,16 +802,18 @@ void Do4Shift( instruction *ins ) void Do4RShift( instruction *ins ) -/***********************************/ -/* NOT NEEDED ON 386 */ +/************************************ + * NOT NEEDED ON 386 + */ { /* unused parameters */ (void)ins; } void Gen4RNeg( instruction *ins ) -/**********************************/ -/* NOT NEEDED ON 386 */ +/*********************************** + * NOT NEEDED ON 386 + */ { /* unused parameters */ (void)ins; } @@ -860,16 +888,18 @@ void By2Div( instruction *ins ) void Gen4Neg( instruction *ins ) -/*********************************/ -/* NOT NEEDED ON 386 */ +/********************************** + * NOT NEEDED ON 386 + */ { /* unused parameters */ (void)ins; } void Do4CXShift( instruction *ins, void (*rtn)(instruction *) ) -/****************************************************************/ -/* NOT NEEDED ON 386 */ +/***************************************************************** + * NOT NEEDED ON 386 + */ { /* unused parameters */ (void)ins; (void)rtn; } From 17334eb5c1b4c2703e91ad58111e8c471e59cb27 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Sat, 18 Nov 2023 13:38:23 +0100 Subject: [PATCH 246/258] rename CG constant to be globally unique rename symbols to be more transparent --- bld/cc/c/cgen.c | 2 +- bld/cc/c/cinfo.c | 46 +++++++++++++++++++------------------- bld/cc/c/ppexpn.c | 2 +- bld/cg/c/bldcall.c | 8 +++---- bld/cg/c/bldins.c | 2 +- bld/cg/c/cgmem.c | 3 ++- bld/cg/c/cgmemmgr.c | 4 ++-- bld/cg/c/doblips.c | 2 +- bld/cg/c/dosstubs.c | 4 ++-- bld/cg/c/generate.c | 11 +++++---- bld/cg/c/inssched.c | 2 +- bld/cg/c/memlimit.c | 4 ++-- bld/cg/c/objname.c | 2 +- bld/cg/c/onexit.c | 4 ++-- bld/cg/c/scmain.c | 2 +- bld/cg/c/zoiks.c | 4 ++-- bld/cg/doc/cgref.gml | 46 +++++++++++++++++++------------------- bld/cg/h/cg.h | 44 ++++++++++++++++++------------------ bld/cg/h/cgfertns.h | 4 ++-- bld/cg/h/generate.h | 4 ++-- bld/cg/intel/c/x86enc2.c | 6 ++--- bld/cg/intel/c/x86index.c | 2 +- bld/cg/intel/c/x86obj.c | 8 +++---- bld/cg/intel/c/x86proc.c | 2 +- bld/cg/intel/c/x86reg.c | 10 ++++----- bld/cg/intel/c/x86segs.c | 2 +- bld/cg/risc/axp/c/axpreg.c | 2 +- bld/cg/risc/c/rscobj.c | 4 ++-- bld/cg/risc/mps/c/mpsreg.c | 2 +- bld/cg/risc/ppc/c/ppcreg.c | 2 +- bld/f77/wfc/c/wf77info.c | 44 ++++++++++++++++++------------------ bld/plusplus/c/cginfo.c | 40 ++++++++++++++++----------------- 32 files changed, 162 insertions(+), 162 deletions(-) diff --git a/bld/cc/c/cgen.c b/bld/cc/c/cgen.c index 324dd0f871..7e1b7e65c0 100644 --- a/bld/cc/c/cgen.c +++ b/bld/cc/c/cgen.c @@ -1821,7 +1821,7 @@ static void GenModuleCode( void ) static void NoCodeGenDLL( void ) { - FEMessage( MSG_FATAL, "Unable to load code generator DLL" ); + FEMessage( FEMSG_FATAL, "Unable to load code generator DLL" ); } static void EmitSyms( void ) diff --git a/bld/cc/c/cinfo.c b/bld/cc/c/cinfo.c index 38b45af823..04e91dce5f 100644 --- a/bld/cc/c/cinfo.c +++ b/bld/cc/c/cinfo.c @@ -742,14 +742,14 @@ const char *FEName( CGSYM_HANDLE cgsym_handle ) } -void FEMessage( int class, CGPOINTER parm ) -/*****************************************/ +void FEMessage( fe_msg femsg, CGPOINTER parm ) +/********************************************/ { char msgtxt[80]; char msgbuf[MAX_MSG_LEN]; - switch( class ) { - case MSG_SYMBOL_TOO_LONG: + switch( femsg ) { + case FEMSG_SYMBOL_TOO_LONG: { SYM_ENTRY *sym; @@ -759,23 +759,23 @@ void FEMessage( int class, CGPOINTER parm ) InitErrLoc(); } break; - case MSG_BLIP: + case FEMSG_BLIP: if( GlobalCompFlags.ide_console_output ) { if( !CompFlags.quiet_mode ) { ConBlip(); } } break; - case MSG_INFO: - case MSG_INFO_FILE: - case MSG_INFO_PROC: + case FEMSG_INFO: + case FEMSG_INFO_FILE: + case FEMSG_INFO_PROC: if( GlobalCompFlags.ide_console_output ) { if( !CompFlags.quiet_mode ) { NoteMsg( parm ); } } break; - case MSG_CODE_SIZE: + case FEMSG_CODE_SIZE: if( GlobalCompFlags.ide_console_output ) { if( !CompFlags.quiet_mode ) { CGetMsg( msgtxt, PHRASE_CODE_SIZE ); @@ -784,28 +784,28 @@ void FEMessage( int class, CGPOINTER parm ) } } break; - case MSG_DATA_SIZE: + case FEMSG_DATA_SIZE: break; - case MSG_ERROR: + case FEMSG_ERROR: CErr2p( ERR_INTERNAL_ERROR_MSG, parm ); break; - case MSG_FATAL: + case FEMSG_FATAL: CErr2p( ERR_FATAL_ERROR, parm ); CloseFiles(); /* get rid of temp file */ MyExit( 1 ); /* exit to DOS do not pass GO */ break; - case MSG_BAD_PARM_REGISTER: + case FEMSG_BAD_PARM_REGISTER: /* * this will be issued after a call to CGInitCall or CGProcDecl */ CErr2( ERR_BAD_PARM_REGISTER, (int)(pointer_uint)parm ); break; - case MSG_BAD_RETURN_REGISTER: + case FEMSG_BAD_RETURN_REGISTER: CErr2p( ERR_BAD_RETURN_REGISTER, FEName( (CGSYM_HANDLE)parm ) ); break; - case MSG_SCHEDULER_DIED: - case MSG_REGALLOC_DIED: - case MSG_SCOREBOARD_DIED: + case FEMSG_SCHEDULER_DIED: + case FEMSG_REGALLOC_DIED: + case FEMSG_SCOREBOARD_DIED: if( (GenSwitches & CGSW_GEN_NO_OPTIMIZATION) == 0 ) { if( LastFuncOutOfMem != parm ) { CInfoMsg( INFO_NOT_ENOUGH_MEMORY_TO_FULLY_OPTIMIZE, FEName( (CGSYM_HANDLE)parm ) ); @@ -813,7 +813,7 @@ void FEMessage( int class, CGPOINTER parm ) } } break; - case MSG_PEEPHOLE_FLUSHED: + case FEMSG_PEEPHOLE_FLUSHED: if( (GenSwitches & CGSW_GEN_NO_OPTIMIZATION) == 0 ) { if( !CompFlags.low_on_memory_printed ) { CInfoMsg( INFO_NOT_ENOUGH_MEMORY_TO_MAINTAIN_PEEPHOLE); @@ -821,19 +821,19 @@ void FEMessage( int class, CGPOINTER parm ) } } break; - case MSG_BACK_END_ERROR: + case FEMSG_BACK_END_ERROR: CErr2( ERR_BACK_END_ERROR, (int)(pointer_uint)parm ); break; - case MSG_BAD_SAVE: + case FEMSG_BAD_SAVE: CErr2p( ERR_BAD_SAVE, FEName( (CGSYM_HANDLE)parm ) ); break; - case MSG_BAD_LINKAGE: + case FEMSG_BAD_LINKAGE: CErr2p( ERR_BAD_LINKAGE, FEName( (CGSYM_HANDLE)parm ) ); break; - case MSG_NO_SEG_REGS: + case FEMSG_NO_SEG_REGS: CErr2p( ERR_NO_SEG_REGS, FEName( (CGSYM_HANDLE)parm ) ); break; - case MSG_BAD_PEG_REG: + case FEMSG_BAD_PEG_REG: CErr2p( ERR_BAD_PEG_REG, FEName( (CGSYM_HANDLE)parm ) ); break; default: diff --git a/bld/cc/c/ppexpn.c b/bld/cc/c/ppexpn.c index 444e7fc4ca..9a2543860f 100644 --- a/bld/cc/c/ppexpn.c +++ b/bld/cc/c/ppexpn.c @@ -139,7 +139,7 @@ static int Prec[] = { // table of token precedences static void CFatal( char *msg ) /*****************************/ { - FEMessage( MSG_FATAL, msg ); + FEMessage( FEMSG_FATAL, msg ); } #endif diff --git a/bld/cg/c/bldcall.c b/bld/cg/c/bldcall.c index 63316f13c1..90ee033c0e 100644 --- a/bld/cg/c/bldcall.c +++ b/bld/cg/c/bldcall.c @@ -592,11 +592,11 @@ void ParmIns( pn parm, call_state *state ) AddIns( ins ); } else if( !CvtOk( TypeClass( addr->tipe ), reg->n.type_class ) ) { ins = NULL; - FEMessage( MSG_BAD_PARM_REGISTER, (pointer)(pointer_uint)parm->num ); + FEMessage( FEMSG_BAD_PARM_REGISTER, (pointer)(pointer_uint)parm->num ); #if _TARGET_INTEL } else if( HW_CEqual( reg->r.reg, HW_ABCD ) ) { ins = NULL; - FEMessage( MSG_BAD_PARM_REGISTER, (pointer)(pointer_uint)parm->num ); + FEMessage( FEMSG_BAD_PARM_REGISTER, (pointer)(pointer_uint)parm->num ); #endif } else { ins = MakeConvert( curr, reg, reg->n.type_class, TypeClass( addr->tipe ) ); @@ -837,7 +837,7 @@ bool AssgnParms( cn call, bool aux_inline ) parm->regs = ParmInLineReg( &state->parm ); if( HW_CEqual( parm->regs, HW_EMPTY ) ) { if( !HW_CEqual( *(state->parm.curr_entry), HW_EMPTY ) ) { - FEMessage( MSG_ERROR, "More parameters than registers in pragma" ); + FEMessage( FEMSG_ERROR, "More parameters than registers in pragma" ); } else { parm->offset = ParmMem( parm->name->tipe->length, ParmAlignment( parm->name->tipe ), state ); push_no_pop = true; @@ -847,7 +847,7 @@ bool AssgnParms( cn call, bool aux_inline ) reg_type_class = AllocRegName( parm->regs )->n.type_class; if( parm_type_class != FD || reg_type_class != U8 ) { if( !CvtOk( parm_type_class, reg_type_class ) ) { - FEMessage( MSG_BAD_PARM_REGISTER, (pointer)(pointer_uint)( parms + 1 ) ); + FEMessage( FEMSG_BAD_PARM_REGISTER, (pointer)(pointer_uint)( parms + 1 ) ); } } } diff --git a/bld/cg/c/bldins.c b/bld/cg/c/bldins.c index 8183f40105..2998a1313b 100644 --- a/bld/cg/c/bldins.c +++ b/bld/cg/c/bldins.c @@ -506,7 +506,7 @@ an BGUnary( cg_op op, an left, type_def *tipe ) case O_PTR_TO_NATIVE: // no large model runtime libraries if( left->tipe->length != WORD_SIZE ) { - FEMessage( MSG_ERROR, "runtime call cannot be made when DS not pegged" ); + FEMessage( FEMSG_ERROR, "runtime call cannot be made when DS not pegged" ); left = Unary( O_CONVERT, left, TypeAddress( TY_NEAR_POINTER ) ); } #endif diff --git a/bld/cg/c/cgmem.c b/bld/cg/c/cgmem.c index 6238023827..f2be74aae1 100644 --- a/bld/cg/c/cgmem.c +++ b/bld/cg/c/cgmem.c @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -70,6 +71,6 @@ void CauseTBreak() { void FatalError( const char * str ) { /***********************************/ - FEMessage( MSG_FATAL, (pointer)str ); + FEMessage( FEMSG_FATAL, (pointer)str ); } diff --git a/bld/cg/c/cgmemmgr.c b/bld/cg/c/cgmemmgr.c index c9fc69a4b8..da04bf5b32 100644 --- a/bld/cg/c/cgmemmgr.c +++ b/bld/cg/c/cgmemmgr.c @@ -293,7 +293,7 @@ static void CalcMemSize( void ) #endif if( max_size_queried || size_queried ) { sprintf( buff, "Maximum WCGMEMORY=%d\n", (int)( memory_available / _1K ) ); - FEMessage( MSG_INFO, buff ); + FEMessage( FEMSG_INFO, buff ); } } @@ -552,7 +552,7 @@ void MemFini( void ) char buff[80]; sprintf( buff, "Peak WCG memory usage (KB): %d\n", (int)(PeakAlloc/_1K) ); - FEMessage( MSG_INFO, buff ); + FEMessage( FEMSG_INFO, buff ); PeakAlloc = 0; } #endif diff --git a/bld/cg/c/doblips.c b/bld/cg/c/doblips.c index 90accadcf7..ec74710079 100644 --- a/bld/cg/c/doblips.c +++ b/bld/cg/c/doblips.c @@ -129,7 +129,7 @@ static void CheckEvents( void ) if( ticks < LastBlipCount || ticks >= NextTickCount ) { OSCall(); /* force a DOS call to get version number */ if( ticks < LastBlipCount || ticks >= NextBlipCount ) { - FEMessage( MSG_BLIP, NULL ); + FEMessage( FEMSG_BLIP, NULL ); LastBlipCount = ticks; SetNextBlipCount(); } diff --git a/bld/cg/c/dosstubs.c b/bld/cg/c/dosstubs.c index 9b2733d81c..f05cc02c26 100644 --- a/bld/cg/c/dosstubs.c +++ b/bld/cg/c/dosstubs.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2018 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -116,5 +116,5 @@ void DGBlip() { void FatalError( const char * str ) { /***********************************/ - FEMessage( MSG_FATAL, (pointer)str ); + FEMessage( FEMSG_FATAL, (pointer)str ); } diff --git a/bld/cg/c/generate.c b/bld/cg/c/generate.c index c50c6eb4b5..101a52e902 100644 --- a/bld/cg/c/generate.c +++ b/bld/cg/c/generate.c @@ -471,9 +471,8 @@ static void FlushBlocks( bool partly_done ) block *curr; block_class classes; - if( !BlockByBlock - && _IsntModel( CGSW_GEN_NO_OPTIMIZATION ) ) { - ProcMessage( MSG_REGALLOC_DIED ); + if( !BlockByBlock ) { + FEMessageCurrProc( FEMSG_REGALLOC_DIED ); } if( !partly_done ) { Renumber(); @@ -618,14 +617,14 @@ static void GenPartialRoutine( bool routine_done ) } -void ProcMessage( msg_class msg ) -/**********************************/ +void FEMessageCurrProc( fe_msg femsg ) +/***************************************/ { static proc_def *lastproc = NULL; if( _IsntModel( CGSW_GEN_NO_OPTIMIZATION ) && lastproc != CurrProc ) { - FEMessage( msg, AskForLblSym( CurrProc->label ) ); + FEMessage( femsg, AskForLblSym( CurrProc->label ) ); lastproc = CurrProc; } } diff --git a/bld/cg/c/inssched.c b/bld/cg/c/inssched.c index 02d5e0c89c..72ec0e46cf 100644 --- a/bld/cg/c/inssched.c +++ b/bld/cg/c/inssched.c @@ -1076,7 +1076,7 @@ void Schedule( void ) for( SBlock = HeadBlock; SBlock != NULL; SBlock = SBlock->next_block ) { if( Spawn( &SchedBlock ) != 0 ) { if( first_time ) { - ProcMessage( MSG_SCHEDULER_DIED ); + FEMessageCurrProc( FEMSG_SCHEDULER_DIED ); first_time = false; } FreeDataDag(); diff --git a/bld/cg/c/memlimit.c b/bld/cg/c/memlimit.c index ef76772161..7b1409a720 100644 --- a/bld/cg/c/memlimit.c +++ b/bld/cg/c/memlimit.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -67,7 +67,7 @@ static bool FlushSomeOpt( pointer_uint size ) SetOP( old_segid ); if( _IsntModel( CGSW_GEN_NO_OPTIMIZATION ) && !IckyWicky ) { IckyWicky = true; - FEMessage( MSG_PEEPHOLE_FLUSHED, NULL ); + FEMessage( FEMSG_PEEPHOLE_FLUSHED, NULL ); } } else { freed = false; diff --git a/bld/cg/c/objname.c b/bld/cg/c/objname.c index ef28499742..51b8995427 100644 --- a/bld/cg/c/objname.c +++ b/bld/cg/c/objname.c @@ -243,7 +243,7 @@ static int GetExtName( cg_sym_handle sym, char *buffer, int max_len ) // copy + truncate base symbol name len = copyBaseName( c, dst_basename, dst_len, src, base_len ); if( len < 0 ) { - FEMessage( MSG_SYMBOL_TOO_LONG, sym ); + FEMessage( FEMSG_SYMBOL_TOO_LONG, sym ); } else { // shift sufix to the end of symbol name memcpy( dst_basename + len, tmp_suffix, sufix_len + 1 ); diff --git a/bld/cg/c/onexit.c b/bld/cg/c/onexit.c index add4210306..48b34b519c 100644 --- a/bld/cg/c/onexit.c +++ b/bld/cg/c/onexit.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2018 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -105,5 +105,5 @@ void FatalError( const char *str ) ReleTimer(); BrkFini(); ScratchObj(); - FEMessage( MSG_FATAL, (pointer)str ); + FEMessage( FEMSG_FATAL, (pointer)str ); } diff --git a/bld/cg/c/scmain.c b/bld/cg/c/scmain.c index 40fb4fcfab..bfcc4cf67a 100644 --- a/bld/cg/c/scmain.c +++ b/bld/cg/c/scmain.c @@ -279,7 +279,7 @@ void Score( void ) blk->u1.scoreboard = NULL; } if( Spawn( &ScoreRoutine ) != 0 ) { - ProcMessage( MSG_SCOREBOARD_DIED ); + FEMessageCurrProc( FEMSG_SCOREBOARD_DIED ); } CleanUp(); SetMemOut( old_memout ); diff --git a/bld/cg/c/zoiks.c b/bld/cg/c/zoiks.c index 2e79df4b88..d9ed0b7dc6 100644 --- a/bld/cg/c/zoiks.c +++ b/bld/cg/c/zoiks.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2019 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -53,5 +53,5 @@ void Zoiks( int msg ) return; if( ( msg == ZOIKS_040 ) && ( ++Zoiks40 < MAX_ZOIKS_40 ) ) return; - FEMessage( MSG_BACK_END_ERROR, (pointer)(pointer_uint)msg ); + FEMessage( FEMSG_BACK_END_ERROR, (pointer)(pointer_uint)msg ); } diff --git a/bld/cg/doc/cgref.gml b/bld/cg/doc/cgref.gml index 9da097e297..e0a9aecdd9 100644 --- a/bld/cg/doc/cgref.gml +++ b/bld/cg/doc/cgref.gml @@ -2410,7 +2410,7 @@ The symbol is "volatile" (in the C language sense). The symbol is not at file scope. .endnote .* -.section void FEMessage( msg_class msg, void *extra ) +.section void FEMessage( fe_msg femsg, void *extra ) .* .ix FEMessage .np @@ -2418,80 +2418,80 @@ Relays information to the front end. .begnote .notehd1 Parameter .notehd2 Definition -.note msg +.note femsg Defined below. .note extra Extra information. -The type and meaning depends on the value of :HP2.msg:eHP2. and is +The type and meaning depends on the value of :HP2.femsg:eHP2. and is indicated below. .endnote .begnote $break $setptnt 2i -.note MSG_INFO_FILE +.note FEMSG_INFO_FILE .ix 'error messages' Informational message about file. extra (void) is ignored. -.note MSG_CODE_SIZE +.note FEMSG_CODE_SIZE Code size. Extra (int) is the size of the generated code. -.note MSG_DATA_SIZE +.note FEMSG_DATA_SIZE Data size. Extra (int) is the size of the generated data. -.note MSG_ERROR +.note FEMSG_ERROR A back end error message. Extra (char *) is the error message. -.note MSG_FATAL +.note FEMSG_FATAL A fatal code generator error. Extra (char *) is the reason for the fatal error. The front end should issue this message and exit immediately to the system. -.note MSG_INFO_PROC +.note FEMSG_INFO_PROC Informational message about current procedure. Extra (char *) is a message. -.note MSG_BAD_PARM_REGISTER +.note FEMSG_BAD_PARM_REGISTER Invalid parameter register returned from FEAuxInfo. Extra (int) is position of the offending parameter. -.note MSG_BAD_RETURN_REGISTER +.note FEMSG_BAD_RETURN_REGISTER Invalid return register returned from FEAuxInfo. Extra (aux_handle) is the offending aux_handle. -.note MSG_REGALLOC_DIED +.note FEMSG_REGALLOC_DIED The register alloc ran out of memory. Extra (cg_sym_handle) is the procedure which was not fully optimized. -.note MSG_SCOREBOARD_DIED +.note FEMSG_SCOREBOARD_DIED The register scoreboard ran out of memory. Extra (cg_sym_handle) is the procedure which was not fully optimized. -.note MSG_PEEPHOLE_FLUSHED +.note FEMSG_PEEPHOLE_FLUSHED Peep hole optimizer flushed due to lack of memory. (void) -.note MSG_BACK_END_ERROR +.note FEMSG_BACK_END_ERROR BAD NEWS! Internal compiler error. Extra (int) is an internal error number. -.note MSG_BAD_SAVE +.note FEMSG_BAD_SAVE Invalid register modification information return from FEAuxInfo. Extra (aux_handle) is the offending aux_handle. -.note MSG_WANT_MORE_DATA +.note FEMSG_WANT_MORE_DATA The back end wants more data space. Extra (int) is amount of additional memory needed to run. (DOS real mode hosts only). -.note MSG_BLIP +.note FEMSG_BLIP Blip. Let the world know we're still alive by printing a dot on the screen. This is called approximately every 4 seconds during code generation. (void) -.note MSG_BAD_LINKAGE +.note FEMSG_BAD_LINKAGE Cannot resolve linkage conventions. 370 only. (sym) -.note MSG_SCHEDULER_DIED +.note FEMSG_SCHEDULER_DIED Instruction scheduler ran out of memory. Extra (cg_sym_handle) is the procedure which was not fully optimized. -.note MSG_NO_SEG_REGS +.note FEMSG_NO_SEG_REGS (Only occurs in the x86 version). The cg_switches did not allow any segment registers to float, but the user has requested a far pointer indirection. Extra (cg_sym_handle) is the procedure which contained the far pointer usage. -.note MSG_SYMBOL_TOO_LONG +.note FEMSG_SYMBOL_TOO_LONG Given symbol is too long and is truncated to maximum permited length for current module output format. Extra (cg_sym_handle) is the symbol which was truncated. @@ -3449,7 +3449,7 @@ generator options. (struct) For 370 linkage conventions. .note more_cg_types (enum) -.note msg_class +.note fe_msg (enum) The 1st parameter to FEMessage. .note proc_revision (enum) The 3rd parameter to BEInit. diff --git a/bld/cg/h/cg.h b/bld/cg/h/cg.h index cb307868f7..ede2b6b254 100644 --- a/bld/cg/h/cg.h +++ b/bld/cg/h/cg.h @@ -178,28 +178,28 @@ typedef enum { typedef enum { - MSG_INFO_FILE, /* informational message about file (string) */ - MSG_CODE_SIZE, /* code size message (int) */ - MSG_DATA_SIZE, /* data size message (int) */ - MSG_ERROR, /* cg error message (string) */ - MSG_FATAL, /* fatal error (string) */ - MSG_INFO_PROC, /* info message about current proc (string) */ - MSG_BAD_PARM_REGISTER, /* bad "aux" parm (parm num) */ - MSG_BAD_RETURN_REGISTER, /* bad "aux" value (sym) */ - MSG_REGALLOC_DIED, /* register alloc ran out of mem (sym) */ - MSG_SCOREBOARD_DIED, /* scoreboard ran out of mem (sym) */ - MSG_PEEPHOLE_FLUSHED, /* peep hole optimizer flushed (none) */ - MSG_BACK_END_ERROR, /* back end error (int) */ - MSG_BAD_SAVE, /* bad "aux" modify (sym) */ - MSG_WANT_MORE_DATA, /* back end wants more data space (int) */ - MSG_BLIP, /* blip */ - MSG_BAD_LINKAGE, /* cannot resolve linkage conventions (sym) */ - MSG_SCHEDULER_DIED, /* ins scheduler ran out of mem (sym) */ - MSG_NO_SEG_REGS, /* accessing far memory with no seg regs */ - MSG_BAD_PEG_REG, /* bad register pegged to a segment */ - MSG_SYMBOL_TOO_LONG, /* symbol too long, truncated (sym) */ - MSG_INFO /* general informational message (string) */ -} msg_class; + FEMSG_INFO_FILE, /* informational message about file (string) */ + FEMSG_CODE_SIZE, /* code size message (int) */ + FEMSG_DATA_SIZE, /* data size message (int) */ + FEMSG_ERROR, /* cg error message (string) */ + FEMSG_FATAL, /* fatal error (string) */ + FEMSG_INFO_PROC, /* info message about current proc (string) */ + FEMSG_BAD_PARM_REGISTER, /* bad "aux" parm (parm num) */ + FEMSG_BAD_RETURN_REGISTER, /* bad "aux" value (sym) */ + FEMSG_REGALLOC_DIED, /* register alloc ran out of mem (sym) */ + FEMSG_SCOREBOARD_DIED, /* scoreboard ran out of mem (sym) */ + FEMSG_PEEPHOLE_FLUSHED, /* peep hole optimizer flushed (none) */ + FEMSG_BACK_END_ERROR, /* back end error (int) */ + FEMSG_BAD_SAVE, /* bad "aux" modify (sym) */ + FEMSG_WANT_MORE_DATA, /* back end wants more data space (int) */ + FEMSG_BLIP, /* blip */ + FEMSG_BAD_LINKAGE, /* cannot resolve linkage conventions (sym) */ + FEMSG_SCHEDULER_DIED, /* ins scheduler ran out of mem (sym) */ + FEMSG_NO_SEG_REGS, /* accessing far memory with no seg regs */ + FEMSG_BAD_PEG_REG, /* bad register pegged to a segment */ + FEMSG_SYMBOL_TOO_LONG, /* symbol too long, truncated (sym) */ + FEMSG_INFO /* general informational message (string) */ +} fe_msg; #define DBG_NIL_TYPE ((dbg_type)0) #define DBG_FWD_TYPE ((dbg_type)-1) diff --git a/bld/cg/h/cgfertns.h b/bld/cg/h/cgfertns.h index 635fd873d7..e7322522cf 100644 --- a/bld/cg/h/cgfertns.h +++ b/bld/cg/h/cgfertns.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -36,7 +36,7 @@ CGCALLBACKDEF( FEAttr, fe_attr, (cg_sym_handle) ) CGCALLBACKDEF( FEAuxInfo, pointer, (pointer,aux_class) ) CGCALLBACKDEF( FEName, cchar_ptr, (cg_sym_handle) ) CGCALLBACKDEF( FEModuleName, cchar_ptr, (void) ) -CGCALLBACKDEF( FEMessage, void, (int,pointer) ) +CGCALLBACKDEF( FEMessage, void, (fe_msg,pointer) ) CGCALLBACKDEF( FEMoreMem, int, (size_t) ) CGCALLBACKDEF( FETrue, int, (void) ) CGCALLBACKDEF( FEGenProc, void, (cg_sym_handle,call_handle) ) diff --git a/bld/cg/h/generate.h b/bld/cg/h/generate.h index e5ba892f5f..f4732d7996 100644 --- a/bld/cg/h/generate.h +++ b/bld/cg/h/generate.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2016-2016 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2016-2023 The Open Watcom Contributors. All Rights Reserved. * * ======================================================================== * @@ -32,7 +32,7 @@ extern void InitCG( void ); extern void AbortCG( void ); extern void FiniCG( void ); -extern void ProcMessage( msg_class msg ); +extern void FEMessageCurrProc( fe_msg femsg ); extern void Generate( bool routine_done ); extern void OptSegs( void ); diff --git a/bld/cg/intel/c/x86enc2.c b/bld/cg/intel/c/x86enc2.c index 3dc910bcf6..fa4418c08c 100644 --- a/bld/cg/intel/c/x86enc2.c +++ b/bld/cg/intel/c/x86enc2.c @@ -270,7 +270,7 @@ static void CodeSequence( const byte *p, byte_seq_len len ) if( attr & (FE_STATIC | FE_GLOBAL) ) { DoFESymRef( sym, CG_FE, off, FE_FIX_BASE ); } else { - FEMessage( MSG_ERROR, "aux seg used with local symbol" ); + FEMessage( FEMSG_ERROR, "aux seg used with local symbol" ); } break; case FIX_SYM_OFFSET: @@ -282,7 +282,7 @@ static void CodeSequence( const byte *p, byte_seq_len len ) if( temp->t.location != NO_LOCATION ) { EmitOffset( NewBase( temp ) - temp->v.offset + off ); } else { - FEMessage( MSG_ERROR, "aux offset used with register symbol" ); + FEMessage( FEMSG_ERROR, "aux offset used with register symbol" ); } } break; @@ -291,7 +291,7 @@ static void CodeSequence( const byte *p, byte_seq_len len ) if( attr & FE_PROC ) { DoFESymRef( sym, CG_FE, off, FE_FIX_SELF ); } else { - FEMessage( MSG_ERROR, "aux reloff used with data symbol" ); + FEMessage( FEMSG_ERROR, "aux reloff used with data symbol" ); } break; } diff --git a/bld/cg/intel/c/x86index.c b/bld/cg/intel/c/x86index.c index b43eedb0d2..2ed0e84854 100644 --- a/bld/cg/intel/c/x86index.c +++ b/bld/cg/intel/c/x86index.c @@ -324,7 +324,7 @@ void FixSegments( void ) { #endif /* throw away override */ ins->num_operands--; - FEMessage( MSG_NO_SEG_REGS, AskForLblSym( CurrProc->label ) ); + FEMessage( FEMSG_NO_SEG_REGS, AskForLblSym( CurrProc->label ) ); } } } diff --git a/bld/cg/intel/c/x86obj.c b/bld/cg/intel/c/x86obj.c index 598d4fec04..d924938c55 100644 --- a/bld/cg/intel/c/x86obj.c +++ b/bld/cg/intel/c/x86obj.c @@ -835,8 +835,8 @@ static void OutName( const char *name, array_control *dest ) len = Length( name ); if( len >= 256 ) { len = 255; - FEMessage( MSG_INFO_PROC, "Code generator truncated name, its length exceeds allowed maximum." ); - FEMessage( MSG_INFO_PROC, (pointer)name ); + FEMessage( FEMSG_INFO_PROC, "Code generator truncated name, its length exceeds allowed maximum." ); + FEMessage( FEMSG_INFO_PROC, (pointer)name ); } OutByte( len, dest ); OutBuffer( name, len, dest ); @@ -2118,8 +2118,8 @@ void ObjFini( void ) FiniAbsPatches(); EndModule(); CloseObj(); - FEMessage( MSG_CODE_SIZE, (pointer)(pointer_uint)CodeSize ); - FEMessage( MSG_DATA_SIZE, (pointer)(pointer_uint)DataSize ); + FEMessage( FEMSG_CODE_SIZE, (pointer)(pointer_uint)CodeSize ); + FEMessage( FEMSG_DATA_SIZE, (pointer)(pointer_uint)DataSize ); } diff --git a/bld/cg/intel/c/x86proc.c b/bld/cg/intel/c/x86proc.c index 7ab1ded83c..28b76e7472 100644 --- a/bld/cg/intel/c/x86proc.c +++ b/bld/cg/intel/c/x86proc.c @@ -1026,7 +1026,7 @@ void GenProlog( void ) */ if( HW_COvlap( CurrProc->state.unalterable, HW_xAX ) || HW_COvlap( CurrProc->state.parm.used, HW_xAX ) ) { - FEMessage( MSG_ERROR, "exported routine with AX live on entry" ); + FEMessage( FEMSG_ERROR, "exported routine with AX live on entry" ); } #endif GenWindowsProlog(); diff --git a/bld/cg/intel/c/x86reg.c b/bld/cg/intel/c/x86reg.c index c8eb79295e..1a42f4c1a0 100644 --- a/bld/cg/intel/c/x86reg.c +++ b/bld/cg/intel/c/x86reg.c @@ -70,7 +70,7 @@ type_class_def CallState( aux_handle aux, type_def *tipe, call_state *state ) HW_TurnOff( tmp, StackReg() ); HW_CTurnOff( tmp, HW_xBP ); /* should be able to call routine which modifies [E]BP */ if( HW_Ovlap( state->unalterable, tmp ) ) { - FEMessage( MSG_BAD_SAVE, aux ); + FEMessage( FEMSG_BAD_SAVE, aux ); } state->attr = ROUTINE_REMOVES_PARMS; cclass = (call_class)(pointer_uint)FEAuxInfo( aux, FEINF_CALL_CLASS ); @@ -167,7 +167,7 @@ type_class_def CallState( aux_handle aux, type_def *tipe, call_state *state ) for( parm_src = FEAuxInfo( aux, FEINF_PARM_REGS ); !HW_CEqual( *parm_src, HW_EMPTY ); ++parm_src ) { *parm_dst = *parm_src; if( HW_Ovlap( *parm_dst, state->unalterable ) ) { - FEMessage( MSG_BAD_SAVE, aux ); + FEMessage( FEMSG_BAD_SAVE, aux ); } HW_CTurnOff( *parm_dst, HW_UNUSED ); parm_dst++; @@ -223,7 +223,7 @@ void UpdateReturn( call_state *state, type_def *tipe, type_class_def type_cla if( tipe == TypeNone ) { if( HW_CEqual( state->return_reg, HW_EMPTY ) ) return; - FEMessage( MSG_BAD_RETURN_REGISTER, aux ); + FEMessage( FEMSG_BAD_RETURN_REGISTER, aux ); HW_CAsgn( state->return_reg, HW_EMPTY ); state->attr &= ~ROUTINE_HAS_SPECIAL_RETURN; } else if( type_class == XX ) { @@ -237,7 +237,7 @@ void UpdateReturn( call_state *state, type_def *tipe, type_class_def type_cla // return; if( IsRegClass( state->return_reg, WD ) ) return; - FEMessage( MSG_BAD_RETURN_REGISTER, aux ); + FEMessage( FEMSG_BAD_RETURN_REGISTER, aux ); state->return_reg = normal; state->attr &= ~ROUTINE_HAS_SPECIAL_RETURN; } else { @@ -249,7 +249,7 @@ void UpdateReturn( call_state *state, type_def *tipe, type_class_def type_cla // return; if( IsRegClass( state->return_reg, type_class ) ) return; - FEMessage( MSG_BAD_RETURN_REGISTER, aux ); + FEMessage( FEMSG_BAD_RETURN_REGISTER, aux ); state->return_reg = normal; state->attr &= ~ROUTINE_HAS_SPECIAL_RETURN; } diff --git a/bld/cg/intel/c/x86segs.c b/bld/cg/intel/c/x86segs.c index 6a576175c8..d5bb49a4be 100644 --- a/bld/cg/intel/c/x86segs.c +++ b/bld/cg/intel/c/x86segs.c @@ -81,7 +81,7 @@ hw_reg_set CalcSegment( cg_sym_handle sym, cg_class class ) { if( reg != NULL && !HW_CEqual( *reg, HW_EMPTY ) ) { if( HW_COvlap( *reg, HW_SEGS ) ) return( *reg ); - FEMessage( MSG_BAD_PEG_REG, AskForLblSym( CurrProc->label ) ); + FEMessage( FEMSG_BAD_PEG_REG, AskForLblSym( CurrProc->label ) ); } if( class == CG_FE && (attr & FE_PROC) && (attr & FE_DLLIMPORT) == 0 ) { #if _TARGET & _TARG_80386 diff --git a/bld/cg/risc/axp/c/axpreg.c b/bld/cg/risc/axp/c/axpreg.c index 7bfbd01718..b5a6cc2d1a 100644 --- a/bld/cg/risc/axp/c/axpreg.c +++ b/bld/cg/risc/axp/c/axpreg.c @@ -118,7 +118,7 @@ type_class_def CallState( aux_handle aux, type_def *tipe, call_state *state ) for( parm_src = ParmRegs(); !HW_CEqual( *parm_src, HW_EMPTY ); ++parm_src ) { *parm_dst = *parm_src; if( HW_Ovlap( *parm_dst, state->unalterable ) ) { - FEMessage( MSG_BAD_SAVE, aux ); + FEMessage( FEMSG_BAD_SAVE, aux ); } HW_CTurnOff( *parm_dst, HW_UNUSED ); parm_dst++; diff --git a/bld/cg/risc/c/rscobj.c b/bld/cg/risc/c/rscobj.c index 87feec0d5b..489fa10e9e 100644 --- a/bld/cg/risc/c/rscobj.c +++ b/bld/cg/risc/c/rscobj.c @@ -361,7 +361,7 @@ void ObjFini( void ) OWLFini( owlHandle ); DeleteSections(); CloseObj(); - FEMessage( MSG_CODE_SIZE, (pointer)(pointer_uint)code_size ); + FEMessage( FEMSG_CODE_SIZE, (pointer)(pointer_uint)code_size ); } @@ -1179,7 +1179,7 @@ void ObjEmitSeq( byte_seq *code ) case OWL_RELOC_FP_OFFSET: loc = TempLocation( SymBackUserTemp( curr->sym ) ); if( loc > 32767 ) { - FEMessage( MSG_ERROR, "auto variable out of range for reference within inline assembly sequence" ); + FEMessage( FEMSG_ERROR, "auto variable out of range for reference within inline assembly sequence" ); } InsRelocAddSignedImmed( loc ); break; diff --git a/bld/cg/risc/mps/c/mpsreg.c b/bld/cg/risc/mps/c/mpsreg.c index 649393fd2c..560b03754f 100644 --- a/bld/cg/risc/mps/c/mpsreg.c +++ b/bld/cg/risc/mps/c/mpsreg.c @@ -141,7 +141,7 @@ type_class_def CallState( aux_handle aux, type_def *tipe, call_state *state ) for( ; !HW_CEqual( *parm_src, HW_EMPTY ); ++parm_src ) { *parm_dst = *parm_src; if( HW_Ovlap( *parm_dst, state->unalterable ) ) { - FEMessage( MSG_BAD_SAVE, aux ); + FEMessage( FEMSG_BAD_SAVE, aux ); } HW_CTurnOff( *parm_dst, HW_UNUSED ); parm_dst++; diff --git a/bld/cg/risc/ppc/c/ppcreg.c b/bld/cg/risc/ppc/c/ppcreg.c index baa979dda2..98d72d7709 100644 --- a/bld/cg/risc/ppc/c/ppcreg.c +++ b/bld/cg/risc/ppc/c/ppcreg.c @@ -113,7 +113,7 @@ type_class_def CallState( aux_handle aux, type_def *tipe, call_state *state ) if( HW_CEqual( *parm_dst, HW_EMPTY ) ) break; if( HW_Ovlap( *parm_dst, state->unalterable ) ) { - FEMessage( MSG_BAD_SAVE, aux ); + FEMessage( FEMSG_BAD_SAVE, aux ); } HW_CTurnOff( *parm_dst, HW_UNUSED ); parm_dst++; diff --git a/bld/f77/wfc/c/wf77info.c b/bld/f77/wfc/c/wf77info.c index ee506eb053..30d0b233f5 100644 --- a/bld/f77/wfc/c/wf77info.c +++ b/bld/f77/wfc/c/wf77info.c @@ -1291,8 +1291,8 @@ void FCMessage( fc_msg_class tipe, pointer x ) } } -void FEMessage( int msg, pointer x ) -//===================================== +void FEMessage( fe_msg femsg, pointer x ) +//========================================== // Print a message for the back end. { char name[MAX_SYMLEN+1]; @@ -1301,68 +1301,68 @@ void FEMessage( int msg, pointer x ) SendStd( x ); exit( 1 ); } - switch( msg ) { - case MSG_SYMBOL_TOO_LONG: + switch( femsg ) { + case FEMSG_SYMBOL_TOO_LONG: /* symbol too long, truncated (sym) */ break; - case MSG_CODE_SIZE : + case FEMSG_CODE_SIZE : #if _CPU == 8086 CodeSize = (unsigned short)(pointer_uint)x; #else CodeSize = (unsigned long)(pointer_uint)x; #endif break; - case MSG_DATA_SIZE : + case FEMSG_DATA_SIZE : break; - case MSG_ERROR : + case FEMSG_ERROR : Error( CP_ERROR, x ); break; - case MSG_FATAL : + case FEMSG_FATAL : Error( CP_FATAL_ERROR, x ); CGFlags |= CG_FATAL; CSuicide(); break; - case MSG_BAD_PARM_REGISTER : + case FEMSG_BAD_PARM_REGISTER : Error( CP_BAD_PARM_REGISTER, x ); break; - case MSG_BAD_RETURN_REGISTER : + case FEMSG_BAD_RETURN_REGISTER : Error( CP_BAD_RETURN_REGISTER, FEName( x ) ); break; - case MSG_REGALLOC_DIED : - case MSG_SCOREBOARD_DIED : - case MSG_SCHEDULER_DIED : + case FEMSG_REGALLOC_DIED : + case FEMSG_SCOREBOARD_DIED : + case FEMSG_SCHEDULER_DIED : if( CGFlags & CG_MEM_LOW_ISSUED ) break; Warning( CP_LOW_ON_MEMORY, FEName( x ) ); CGFlags |= CG_MEM_LOW_ISSUED; break; - case MSG_PEEPHOLE_FLUSHED : + case FEMSG_PEEPHOLE_FLUSHED : if( CGFlags & CG_MEM_LOW_ISSUED ) break; STGetName( SubProgId, name ); Warning( CP_LOW_ON_MEMORY, name ); CGFlags |= CG_MEM_LOW_ISSUED; break; - case MSG_BACK_END_ERROR : + case FEMSG_BACK_END_ERROR : Error( CP_BACK_END_ERROR, (int)(pointer_uint)x ); break; - case MSG_BAD_SAVE : + case FEMSG_BAD_SAVE : Error( CP_BAD_SAVE, FEName( x ) ); break; - case MSG_BLIP : + case FEMSG_BLIP : if( (Options & OPT_QUIET) == 0 ) { SendBlip(); } break; - case MSG_INFO : + case FEMSG_INFO : PrtLst( x ); break; - case MSG_INFO_PROC : + case FEMSG_INFO_PROC : PrintErr( x ); break; - case MSG_NO_SEG_REGS : // can't be generated by FORTRAN 77 - case MSG_WANT_MORE_DATA : // not used - case MSG_INFO_FILE : // not used + case FEMSG_NO_SEG_REGS : // can't be generated by FORTRAN 77 + case FEMSG_WANT_MORE_DATA : // not used + case FEMSG_INFO_FILE : // not used break; } } diff --git a/bld/plusplus/c/cginfo.c b/bld/plusplus/c/cginfo.c index b23455d3b3..3037ac9ce1 100644 --- a/bld/plusplus/c/cginfo.c +++ b/bld/plusplus/c/cginfo.c @@ -120,14 +120,14 @@ const char *FEName( // RETURN THE SYMBOL'S NAME void FEMessage( // MESSAGES FROM CODE-GENERATOR - int class, // - message class + fe_msg femsg, // - fron-end message pointer parm ) // - parameter { - switch( (msg_class)class ) { - case MSG_SYMBOL_TOO_LONG: + switch( femsg ) { + case FEMSG_SYMBOL_TOO_LONG: CErr2p( WARN_MANGLED_NAME_TOO_LONG, (SYMBOL)parm ); break; - case MSG_BLIP: + case FEMSG_BLIP: if( CompFlags.ide_console_output ) { if( !CompFlags.quiet_mode ) { putchar( '.' ); @@ -135,16 +135,16 @@ void FEMessage( // MESSAGES FROM CODE-GENERATOR } } break; - case MSG_INFO: - case MSG_INFO_FILE: - case MSG_INFO_PROC: + case FEMSG_INFO: + case FEMSG_INFO_FILE: + case FEMSG_INFO_PROC: if( CompFlags.ide_console_output ) { if( !CompFlags.quiet_mode ) { MsgDisplayLine( parm ); } } break; - case MSG_CODE_SIZE: + case FEMSG_CODE_SIZE: if( CompFlags.ide_console_output ) { if( !CompFlags.quiet_mode ) { char buffer[30]; @@ -153,24 +153,24 @@ void FEMessage( // MESSAGES FROM CODE-GENERATOR } } break; - case MSG_DATA_SIZE: + case FEMSG_DATA_SIZE: break; - case MSG_ERROR: + case FEMSG_ERROR: CErr2p( ERR_INTERNAL_ERROR_MSG, parm ); break; - case MSG_FATAL: + case FEMSG_FATAL: CErr2p( ERR_FATAL_ERROR, parm ); CppExit( 1 ); /* exit to DOS do not pass GO */ break; - case MSG_BAD_PARM_REGISTER: + case FEMSG_BAD_PARM_REGISTER: CErr2( ERR_BAD_PARM_REGISTER, (int)(pointer_uint)parm ); break; - case MSG_BAD_RETURN_REGISTER: + case FEMSG_BAD_RETURN_REGISTER: CErr2p( ERR_BAD_RETURN_REGISTER, FEName( (SYMBOL)parm ) ); break; - case MSG_SCHEDULER_DIED: - case MSG_REGALLOC_DIED: - case MSG_SCOREBOARD_DIED: + case FEMSG_SCHEDULER_DIED: + case FEMSG_REGALLOC_DIED: + case FEMSG_SCOREBOARD_DIED: if( (GenSwitches & CGSW_GEN_NO_OPTIMIZATION) == 0 ) { if( lastFunctionOutOfMem != parm ) { lastFunctionOutOfMem = parm; @@ -178,7 +178,7 @@ void FEMessage( // MESSAGES FROM CODE-GENERATOR } } break; - case MSG_PEEPHOLE_FLUSHED: + case FEMSG_PEEPHOLE_FLUSHED: if( (GenSwitches & CGSW_GEN_NO_OPTIMIZATION) == 0 ) { if( !CompFlags.low_on_memory_printed ) { CompFlags.low_on_memory_printed = true; @@ -186,13 +186,13 @@ void FEMessage( // MESSAGES FROM CODE-GENERATOR } } break; - case MSG_BACK_END_ERROR: + case FEMSG_BACK_END_ERROR: CErr2( ERR_BACK_END_ERROR, (int)(pointer_uint)parm ); break; - case MSG_BAD_SAVE: + case FEMSG_BAD_SAVE: CErr2p( ERR_BAD_SAVE, FEName( (SYMBOL)parm ) ); break; - case MSG_NO_SEG_REGS: + case FEMSG_NO_SEG_REGS: CErr2p( ERR_NO_SEG_REGS, FEName( (SYMBOL)parm ) ); break; } From a9701e2e9764acbced7a1b65ff2eaa2cf7dd736c Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Sat, 18 Nov 2023 17:47:54 +0100 Subject: [PATCH 247/258] update cg documentation --- bld/cg/doc/cgref.gml | 46 ++++++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/bld/cg/doc/cgref.gml b/bld/cg/doc/cgref.gml index e0a9aecdd9..9be1f0488d 100644 --- a/bld/cg/doc/cgref.gml +++ b/bld/cg/doc/cgref.gml @@ -356,7 +356,7 @@ enum { }; :eXMP. .* -.section void BEStart() +.section void BEStart( void ) .* .ix BEStart .np @@ -365,28 +365,28 @@ Must be called immediately after all calls to BEDefSeg have been made. This restriction is relaxed somewhat for the 80(x)86 code generator. See BEDefSeg for details. .* -.section void BEStop() +.section void BEStop( void ) .* .ix BEStop .np Normal termination of code generator. This must be the second last routine called. .* -.section void BEAbort() +.section void BEAbort( void ) .* .ix BEAbort .np Abnormal termination of code generator. This must be the second last routine called. .* -.section void BEFini() +.section void BEFini( void ) .* .ix BEFini .np Finalize the code generator. This must be the last routine called. .* -.section patch_handle BEPatch() +.section patch_handle BEPatch( void ) .* .np Allocate a patch handle which can be used to create a patchable @@ -579,7 +579,7 @@ These labels may only be used for flow of control. In order to define a label in a data segment, a :HP2.back_handle:eHP2. must be used. .* -.section label_handle BENewLabel() +.section label_handle BENewLabel( void ) .* .ix BENewLabel .ix label, code @@ -889,7 +889,7 @@ The symbol table entry for the parameter. The type of the parameter. .endnote .* -.section label_handle CGLastParm() +.section label_handle CGLastParm( void ) .* .ix CGLastParm .np @@ -1650,7 +1650,7 @@ CGSelect( sel_handle ); CGControl( O_LABEL, NULL, end_label ); :eXMP. .* -.section sel_handle CGSelInit() +.section sel_handle CGSelInit( void ) .* .ix CGSelInit .ix 'control flow' @@ -2168,7 +2168,7 @@ The location within the segment. The current location in the segment before the seek takes place. .endnote .* -.section unsigned long DGTell() +.section unsigned long DGTell( void ) .* .ix DGTell .ix segments @@ -2252,7 +2252,7 @@ A cg_sym_handle. A segment_id. .endnote .* -.section char *FEModuleName() +.section char *FEModuleName( void ) .* .ix FEModuleName .begnote @@ -2328,7 +2328,7 @@ passing it to a procedure. Type will be a dealiased type. .endnote .* -.section int FETrue() +.section int FETrue( void ) .* .ix FETrue .begnote @@ -2419,13 +2419,17 @@ Relays information to the front end. .notehd1 Parameter .notehd2 Definition .note femsg -Defined below. +Front-end message. .note extra Extra information. The type and meaning depends on the value of :HP2.femsg:eHP2. and is indicated below. .endnote -.begnote $break $setptnt 2i +.np +The femsg parameter values and extra information description. +.begnote +.notehd1 Value +.notehd2 Description .note FEMSG_INFO_FILE .ix 'error messages' Informational message about file. @@ -2623,17 +2627,17 @@ Only called if the routine has the FEINF_SPECIAL_STRUCT_RETURN attribute. .note ( void *, FEINF_NEXT_IMPORT ) void * (See notes at end) - A handle for the next symbol to generate a reference to in the object file. -.note ( void*, FEINF_IMPORT_NAME ) +.note ( void *, FEINF_IMPORT_NAME ) char * - The EXTDEF name to generate given a handle .note ( void *, FEINF_NEXT_IMPORT_S ) void * (See notes at end) - A handle for the next symbol to generate a reference to in the object file. -.note ( void*, FEINF_IMPORT_NAME_S ) +.note ( void *, FEINF_IMPORT_NAME_S ) Returns a cg_sym_handle. The EXTDEF name symbol reference to generate given a handle. -.note ( void*, FEINF_NEXT_LIBRARY ) +.note ( void *, FEINF_NEXT_LIBRARY ) void * (See notes at end) - Handle for the next library required -.note ( void*, FEINF_LIBRARY_NAME ) +.note ( void *, FEINF_LIBRARY_NAME ) char * - The library name to generate given a handle .note ( NULL, FEINF_DATA_GROUP ) char * - Used to name DGROUP exactly. @@ -2667,7 +2671,7 @@ following three aux requests. IMPORT_IS_CONDITIONAL_PURE is used for eliminating unused pure virtual functions. .note ( cg_sym_handle, FEINF_CONDITIONAL_IMPORT ) - Returns void *. +Returns void *. Once the back end determines that it has a conditional import, it performs this request to get a conditional list handle which is the head of the list of conditional symbols. @@ -2895,13 +2899,13 @@ locate the lvalue of the symbol. whether the symbol is file scoped or not. .endnote .* -.section void DBBegBlock() +.section void DBBegBlock( void ) .* .ix DBBegBlock .np Open a new scope level. .* -.section void DBEndBlock() +.section void DBEndBlock( void ) .* .ix DBEndBlock .np @@ -2974,7 +2978,7 @@ Before the location expression is evalated, the current lvalue of the pointer symbol associated with this type is pushed onto the expression stack (needed for based on self pointers). .* -.section dbg_struct DBBegStruct() +.section dbg_struct DBBegStruct( void ) .* .ix DBBegStruct .np From 1ebe03120c6ce9189c3324e5ab9317a56fe44a9b Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Sun, 19 Nov 2023 17:26:40 +0100 Subject: [PATCH 248/258] cleanup code --- bld/plusplus/c/analtype.c | 2 +- bld/plusplus/c/dbg.c | 4 +-- bld/plusplus/c/type.c | 4 +-- bld/plusplus/h/_typdefs.h | 72 +++++++++++++++++++-------------------- bld/plusplus/h/symtype.h | 2 +- 5 files changed, 42 insertions(+), 42 deletions(-) diff --git a/bld/plusplus/c/analtype.c b/bld/plusplus/c/analtype.c index 8363c6acdf..e0f58d1b47 100644 --- a/bld/plusplus/c/analtype.c +++ b/bld/plusplus/c/analtype.c @@ -368,7 +368,7 @@ TYPE TypeConvertFromPcPtr( // TRANSFORM TYPE AFTER CONVERSION FROM PC PTR static type_id intPromo[] = { // Table of integral promotions - #define pick(id,promo,promo_asm,type_text) __PASTE( TYP_, promo ), + #define pick(id,promo,promo_asm,type_text) promo, #include "_typdefs.h" #undef pick }; diff --git a/bld/plusplus/c/dbg.c b/bld/plusplus/c/dbg.c index abd815d123..3b32db7166 100644 --- a/bld/plusplus/c/dbg.c +++ b/bld/plusplus/c/dbg.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -496,7 +496,7 @@ void DumpSymbol( // DUMP SYMBOL ENTRY } static const char *id_names[] = { - #define pick(id,promo,promo_asm,type_text) __STR( __PASTE( TYP_, id ) ), + #define pick(id,promo,promo_asm,type_text) __STR( id ), #include "_typdefs.h" #undef pick }; diff --git a/bld/plusplus/c/type.c b/bld/plusplus/c/type.c index dc2b47d454..00e8f67116 100644 --- a/bld/plusplus/c/type.c +++ b/bld/plusplus/c/type.c @@ -8411,7 +8411,7 @@ static void initBasicTypes( void ) type_id typ; static type_id basics_init_list[] = { #define BASETYPES - #define pick(id,promo,promo_asm,type_text) __PASTE( TYP_, id ), + #define pick(id,promo,promo_asm,type_text) id, #include "_typdefs.h" #undef pick #undef BASETYPES @@ -8609,7 +8609,7 @@ static void typesInit( // TYPES INITIALIZATION #ifdef XTRA_RPT { static char const * const typeIdNames[] = { - #define pick(id,promo,promo_asm,type_text) __STR( __PASTE( TYP_, id ) ), + #define pick(id,promo,promo_asm,type_text) __STR( id ), #include "_typdefs.h" #undef pick "TYP_NONE", diff --git a/bld/plusplus/h/_typdefs.h b/bld/plusplus/h/_typdefs.h index be05269a96..393e096a7c 100644 --- a/bld/plusplus/h/_typdefs.h +++ b/bld/plusplus/h/_typdefs.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2018-2018 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2018-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -25,7 +25,7 @@ * * ======================================================================== * -* Description: C++ type related data +* Description: C++ type related data * ****************************************************************************/ @@ -38,46 +38,46 @@ #define picke(id,prom,prom_asm,type_text) pick(id,prom,prom_asm,type_text) #endif -/* id prom prom_asm type_text */ -pick( ERROR, ERROR, 0, " " ) -pick( BOOL, SINT, SYM_INT1, "bool " ) -pick( CHAR, SINT, SYM_INT1, "char " ) -pick( SCHAR, SINT, SYM_INT1, "signed char " ) -pick( UCHAR, SINT, SYM_INT1, "unsigned char " ) +/* id prom prom_asm type_text */ +pick( TYP_ERROR, TYP_ERROR, 0, " " ) +pick( TYP_BOOL, TYP_SINT, SYM_INT1, "bool " ) +pick( TYP_CHAR, TYP_SINT, SYM_INT1, "char " ) +pick( TYP_SCHAR, TYP_SINT, SYM_INT1, "signed char " ) +pick( TYP_UCHAR, TYP_SINT, SYM_INT1, "unsigned char " ) #if _CPU == 8086 -pick( WCHAR, UINT, SYM_INT2, "wchar_t " ) +pick( TYP_WCHAR, TYP_UINT, SYM_INT2, "wchar_t " ) #else -pick( WCHAR, SINT, SYM_INT2, "wchar_t " ) +pick( TYP_WCHAR, TYP_SINT, SYM_INT2, "wchar_t " ) #endif -pick( SSHORT, SINT, SYM_INT2, "short " ) +pick( TYP_SSHORT, TYP_SINT, SYM_INT2, "short " ) #if _CPU == 8086 -pick( USHORT, UINT, SYM_INT2, "unsigned short " ) +pick( TYP_USHORT, TYP_UINT, SYM_INT2, "unsigned short " ) #else -pick( USHORT, SINT, SYM_INT2, "unsigned short " ) +pick( TYP_USHORT, TYP_SINT, SYM_INT2, "unsigned short " ) #endif -pick( SINT, SINT, SYM_INT, "int " ) -pick( UINT, UINT, SYM_INT, "unsigned " ) -pick( SLONG, SLONG, SYM_INT4, "long " ) -pick( ULONG, ULONG, SYM_INT4, "unsigned long " ) -pick( SLONG64, SLONG64, SYM_INT8, "__int64 " ) -pick( ULONG64, ULONG64, SYM_INT8, "unsigned __int64 " ) -pick( FLOAT, FLOAT, SYM_FLOAT4, "float " ) -pick( DOUBLE, DOUBLE, SYM_FLOAT8, "double " ) -pick( LONG_DOUBLE, LONG_DOUBLE, SYM_FLOAT8, "long double " ) -picke( ENUM, ERROR, 0, " " ) -picke( POINTER, ERROR, 0, "* " ) -picke( TYPEDEF, ERROR, 0, " " ) -picke( CLASS, ERROR, 0, " " ) -picke( BITFIELD, ERROR, 0, " " ) -picke( FUNCTION, ERROR, 0, " " ) -picke( ARRAY, ERROR, 0, " " ) -pick( DOT_DOT_DOT, ERROR, 0, "... " ) -pick( VOID, ERROR, SYM_INT1, "void " ) -picke( MODIFIER, ERROR, 0, " " ) -picke( MEMBER_POINTER, ERROR, 0, "::* " ) -picke( GENERIC, ERROR, 0, "? " ) +pick( TYP_SINT, TYP_SINT, SYM_INT, "int " ) +pick( TYP_UINT, TYP_UINT, SYM_INT, "unsigned " ) +pick( TYP_SLONG, TYP_SLONG, SYM_INT4, "long " ) +pick( TYP_ULONG, TYP_ULONG, SYM_INT4, "unsigned long " ) +pick( TYP_SLONG64, TYP_SLONG64, SYM_INT8, "__int64 " ) +pick( TYP_ULONG64, TYP_ULONG64, SYM_INT8, "unsigned __int64 " ) +pick( TYP_FLOAT, TYP_FLOAT, SYM_FLOAT4, "float " ) +pick( TYP_DOUBLE, TYP_DOUBLE, SYM_FLOAT8, "double " ) +pick( TYP_LONG_DOUBLE, TYP_LONG_DOUBLE, SYM_FLOAT8, "long double " ) +picke( TYP_ENUM, TYP_ERROR, 0, " " ) +picke( TYP_POINTER, TYP_ERROR, 0, "* " ) +picke( TYP_TYPEDEF, TYP_ERROR, 0, " " ) +picke( TYP_CLASS, TYP_ERROR, 0, " " ) +picke( TYP_BITFIELD, TYP_ERROR, 0, " " ) +picke( TYP_FUNCTION, TYP_ERROR, 0, " " ) +picke( TYP_ARRAY, TYP_ERROR, 0, " " ) +pick( TYP_DOT_DOT_DOT, TYP_ERROR, 0, "... " ) +pick( TYP_VOID, TYP_ERROR, SYM_INT1, "void " ) +picke( TYP_MODIFIER, TYP_ERROR, 0, " " ) +picke( TYP_MEMBER_POINTER, TYP_ERROR, 0, "::* " ) +picke( TYP_GENERIC, TYP_ERROR, 0, "? " ) // extended types C++11 -pick( NULLPTR, ERROR, 0, " " ) -picke( TYPENAME, ERROR, 0, " " ) +pick( TYP_NULLPTR, TYP_ERROR, 0, " " ) +picke( TYP_TYPENAME, TYP_ERROR, 0, " " ) #undef picke diff --git a/bld/plusplus/h/symtype.h b/bld/plusplus/h/symtype.h index 898298a0d7..85aacef5a1 100644 --- a/bld/plusplus/h/symtype.h +++ b/bld/plusplus/h/symtype.h @@ -227,7 +227,7 @@ PCH_struct decl_info { // types dealing with representing types typedef enum { - #define pick(id,promo,promo_asm,type_text) __PASTE( TYP_, id ), + #define pick(id,promo,promo_asm,type_text) id, #include "_typdefs.h" #undef pick TYP_MAX, From 90e3ed3121e10b40f7d331a219b600f9a0154536 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Sun, 19 Nov 2023 19:15:06 +0100 Subject: [PATCH 249/258] update wasm documentation --- docs/doc/cmn/wasm.gml | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/docs/doc/cmn/wasm.gml b/docs/doc/cmn/wasm.gml index ef26ebb150..103bfd2b00 100644 --- a/docs/doc/cmn/wasm.gml +++ b/docs/doc/cmn/wasm.gml @@ -184,8 +184,21 @@ set name of text segment .note o allow C form of octal constants .note zcm= -set compatibility mode - watcom, masm or tasm, if is not -specified then masm is used, default mode is watcom +set compatibility mode to +.begnote +.notehd1 Values +.notehd2 Description +.note watcom (default) +&company WASM mode +.note masm +Microsoft MASM mode +.note tasm +Borland TASM mode +.note ideal +Borland TASM IDEAL mode +.note not specified +MASM mode is used +.endnote .note zld remove file dependency information .note zq or q From 0f3ca2cb84c87a7da0bfdddd067c9cb042cb6e88 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Sun, 19 Nov 2023 19:17:12 +0100 Subject: [PATCH 250/258] cleanup code --- bld/plusplus/c/opovload.c | 6 +- bld/plusplus/h/ppopscnv.h | 201 +++++++++++++++++++------------------- 2 files changed, 103 insertions(+), 104 deletions(-) diff --git a/bld/plusplus/c/opovload.c b/bld/plusplus/c/opovload.c index caa6e18fac..8029533290 100644 --- a/bld/plusplus/c/opovload.c +++ b/bld/plusplus/c/opovload.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -85,7 +85,7 @@ static OP_MASK opfun_mask[] = ; static type_id op_basic_arg[][2] = - #define OPBASIC( arg1, arg2, mask ) { __PASTE( TYP_, arg1 ), __PASTE( TYP_, arg2 ) } + #define OPBASIC( arg1, arg2, mask ) { arg1, arg2 } #include "ppopscnv.h" #undef OPBASIC ; @@ -122,7 +122,7 @@ static OP_MASK opfun_mask_extra[] = ; static type_id op_basic_arg_extra[][2] = - #define OPBASIC_EXTRA( arg1, arg2, mask, ctl ) { __PASTE( TYP_, arg1 ), __PASTE( TYP_, arg2 ) } + #define OPBASIC_EXTRA( arg1, arg2, mask, ctl ) { arg1, arg2 } #include "ppopscnv.h" #undef OPBASIC_EXTRA ; diff --git a/bld/plusplus/h/ppopscnv.h b/bld/plusplus/h/ppopscnv.h index 700426767b..f195a7dd93 100644 --- a/bld/plusplus/h/ppopscnv.h +++ b/bld/plusplus/h/ppopscnv.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -60,120 +61,118 @@ // would be required and, hence, where void* is not allowed. // #ifdef OPBASIC -#define __x__ NONE // // UNARY OPERATORS // -{ OPBASIC( BOOL, __x__, OPM_B | OPM_I | OPM_A ) -, OPBASIC( CHAR, __x__, OPM_I | OPM_A ) -, OPBASIC( SCHAR, __x__, OPM_I | OPM_A ) -, OPBASIC( UCHAR, __x__, OPM_I | OPM_A ) -, OPBASIC( WCHAR, __x__, OPM_I | OPM_A ) -, OPBASIC( SSHORT, __x__, OPM_I | OPM_A ) -, OPBASIC( USHORT, __x__, OPM_I | OPM_A ) -, OPBASIC( SINT, __x__, OPM_I | OPM_A ) -, OPBASIC( UINT, __x__, OPM_I | OPM_A ) -, OPBASIC( SLONG, __x__, OPM_I | OPM_A ) -, OPBASIC( ULONG, __x__, OPM_I | OPM_A ) -, OPBASIC( SLONG64, __x__, OPM_I | OPM_A ) -, OPBASIC( ULONG64, __x__, OPM_I | OPM_A ) -, OPBASIC( FLOAT, __x__, OPM_A ) -, OPBASIC( DOUBLE, __x__, OPM_A ) -, OPBASIC( LONG_DOUBLE, __x__, OPM_A ) -, OPBASIC( POINTER, __x__, OPM_P | OPM_A ) +{ OPBASIC( TYP_BOOL, TYP_NONE, OPM_B | OPM_I | OPM_A ) +, OPBASIC( TYP_CHAR, TYP_NONE, OPM_I | OPM_A ) +, OPBASIC( TYP_SCHAR, TYP_NONE, OPM_I | OPM_A ) +, OPBASIC( TYP_UCHAR, TYP_NONE, OPM_I | OPM_A ) +, OPBASIC( TYP_WCHAR, TYP_NONE, OPM_I | OPM_A ) +, OPBASIC( TYP_SSHORT, TYP_NONE, OPM_I | OPM_A ) +, OPBASIC( TYP_USHORT, TYP_NONE, OPM_I | OPM_A ) +, OPBASIC( TYP_SINT, TYP_NONE, OPM_I | OPM_A ) +, OPBASIC( TYP_UINT, TYP_NONE, OPM_I | OPM_A ) +, OPBASIC( TYP_SLONG, TYP_NONE, OPM_I | OPM_A ) +, OPBASIC( TYP_ULONG, TYP_NONE, OPM_I | OPM_A ) +, OPBASIC( TYP_SLONG64, TYP_NONE, OPM_I | OPM_A ) +, OPBASIC( TYP_ULONG64, TYP_NONE, OPM_I | OPM_A ) +, OPBASIC( TYP_FLOAT, TYP_NONE, OPM_A ) +, OPBASIC( TYP_DOUBLE, TYP_NONE, OPM_A ) +, OPBASIC( TYP_LONG_DOUBLE, TYP_NONE, OPM_A ) +, OPBASIC( TYP_POINTER, TYP_NONE, OPM_P | OPM_A ) // // BINARY OPERATORS // -, OPBASIC( BOOL, BOOL, OPM_BB ) -, OPBASIC( CHAR, CHAR, OPM_RA | OPM_RI | OPM_ASSIGN ) -, OPBASIC( SCHAR, SCHAR, OPM_RA | OPM_RI | OPM_ASSIGN ) -, OPBASIC( UCHAR, UCHAR, OPM_RA | OPM_RI | OPM_ASSIGN ) -, OPBASIC( WCHAR, WCHAR, OPM_RA | OPM_RI | OPM_ASSIGN ) -, OPBASIC( SSHORT, SSHORT, OPM_RA | OPM_RI | OPM_ASSIGN ) -, OPBASIC( USHORT, USHORT, OPM_RA | OPM_RI | OPM_ASSIGN ) -, OPBASIC( SINT, SINT, OPM_RA | OPM_RI | OPM_ASSIGN ) -, OPBASIC( SINT, SINT, OPM_II | OPM_AA | OPM_SH ) -, OPBASIC( SINT, UINT, OPM_SH ) -, OPBASIC( SINT, SLONG, OPM_SH ) -, OPBASIC( SINT, ULONG, OPM_SH ) -, OPBASIC( SINT, SLONG64, OPM_SH ) -, OPBASIC( SINT, ULONG64, OPM_SH ) -, OPBASIC( SINT, POINTER, OPM_IP ) -, OPBASIC( UINT, SINT, OPM_SH ) -, OPBASIC( UINT, UINT, OPM_RA | OPM_RI | OPM_ASSIGN ) -, OPBASIC( UINT, UINT, OPM_II | OPM_AA | OPM_SH ) -, OPBASIC( UINT, SLONG, OPM_SH ) -, OPBASIC( UINT, ULONG, OPM_SH ) -, OPBASIC( UINT, SLONG64, OPM_SH ) -, OPBASIC( UINT, ULONG64, OPM_SH ) -, OPBASIC( UINT, POINTER, OPM_IP ) -, OPBASIC( SLONG, SINT, OPM_SH ) -, OPBASIC( SLONG, UINT, OPM_SH ) -, OPBASIC( SLONG, SLONG, OPM_RA | OPM_RI | OPM_ASSIGN ) -, OPBASIC( SLONG, SLONG, OPM_II | OPM_AA | OPM_SH ) -, OPBASIC( SLONG, ULONG, OPM_SH ) -, OPBASIC( SLONG, SLONG64, OPM_RA | OPM_RI | OPM_ASSIGN ) -, OPBASIC( SLONG, ULONG64, OPM_SH ) -, OPBASIC( SLONG, POINTER, OPM_IP ) -, OPBASIC( ULONG, SINT, OPM_SH ) -, OPBASIC( ULONG, UINT, OPM_SH ) -, OPBASIC( ULONG, SLONG, OPM_SH ) -, OPBASIC( ULONG, ULONG, OPM_RA | OPM_RI | OPM_ASSIGN ) -, OPBASIC( ULONG, ULONG, OPM_II | OPM_AA | OPM_SH ) -, OPBASIC( ULONG, SLONG64, OPM_SH ) -, OPBASIC( ULONG, ULONG64, OPM_RA | OPM_RI | OPM_ASSIGN ) -, OPBASIC( ULONG, POINTER, OPM_IP ) -, OPBASIC( SLONG64, SINT, OPM_SH ) -, OPBASIC( SLONG64, UINT, OPM_SH ) -, OPBASIC( SLONG64, SLONG, OPM_RA | OPM_RI | OPM_ASSIGN ) -, OPBASIC( SLONG64, ULONG, OPM_SH ) -, OPBASIC( SLONG64, SLONG64, OPM_RA | OPM_RI | OPM_ASSIGN ) -, OPBASIC( SLONG64, SLONG64, OPM_II | OPM_AA | OPM_SH ) -, OPBASIC( SLONG64, ULONG64, OPM_SH ) -, OPBASIC( SLONG64, POINTER, OPM_IP ) -, OPBASIC( ULONG64, SINT, OPM_SH ) -, OPBASIC( ULONG64, UINT, OPM_SH ) -, OPBASIC( ULONG64, SLONG, OPM_SH ) -, OPBASIC( ULONG64, ULONG, OPM_RA | OPM_RI | OPM_ASSIGN ) -, OPBASIC( ULONG64, SLONG64, OPM_SH ) -, OPBASIC( ULONG64, ULONG64, OPM_RA | OPM_RI | OPM_ASSIGN ) -, OPBASIC( ULONG64, ULONG64, OPM_II | OPM_AA | OPM_SH ) -, OPBASIC( ULONG64, POINTER, OPM_IP ) -, OPBASIC( FLOAT, FLOAT, OPM_RA | OPM_ASSIGN ) -, OPBASIC( FLOAT, FLOAT, OPM_AA ) -, OPBASIC( DOUBLE, DOUBLE, OPM_RA | OPM_ASSIGN ) -, OPBASIC( DOUBLE, DOUBLE, OPM_AA ) -, OPBASIC( LONG_DOUBLE, LONG_DOUBLE, OPM_RA | OPM_ASSIGN ) -, OPBASIC( LONG_DOUBLE, LONG_DOUBLE, OPM_AA ) -, OPBASIC( POINTER, SINT, OPM_PI ) -, OPBASIC( POINTER, UINT, OPM_PI ) -, OPBASIC( POINTER, SLONG, OPM_PI ) -, OPBASIC( POINTER, ULONG, OPM_PI ) -, OPBASIC( POINTER, SLONG64, OPM_PI ) -, OPBASIC( POINTER, ULONG64, OPM_PI ) -, OPBASIC( POINTER, SINT, OPM_RPI | OPM_ASSIGN ) -, OPBASIC( POINTER, UINT, OPM_RPI | OPM_ASSIGN ) -, OPBASIC( POINTER, SLONG, OPM_RPI | OPM_ASSIGN ) -, OPBASIC( POINTER, ULONG, OPM_RPI | OPM_ASSIGN ) -, OPBASIC( POINTER, SLONG64, OPM_RPI | OPM_ASSIGN ) -, OPBASIC( POINTER, ULONG64, OPM_RPI | OPM_ASSIGN ) -, OPBASIC( POINTER, POINTER, OPM_RP | OPM_ASSIGN ) -, OPBASIC( POINTER, POINTER, OPM_PP ) -, OPBASIC( POINTER, MEMBER_POINTER, OPM_PM ) -, OPBASIC( MEMBER_POINTER, MEMBER_POINTER, OPM_MM ) +, OPBASIC( TYP_BOOL, TYP_BOOL, OPM_BB ) +, OPBASIC( TYP_CHAR, TYP_CHAR, OPM_RA | OPM_RI | OPM_ASSIGN ) +, OPBASIC( TYP_SCHAR, TYP_SCHAR, OPM_RA | OPM_RI | OPM_ASSIGN ) +, OPBASIC( TYP_UCHAR, TYP_UCHAR, OPM_RA | OPM_RI | OPM_ASSIGN ) +, OPBASIC( TYP_WCHAR, TYP_WCHAR, OPM_RA | OPM_RI | OPM_ASSIGN ) +, OPBASIC( TYP_SSHORT, TYP_SSHORT, OPM_RA | OPM_RI | OPM_ASSIGN ) +, OPBASIC( TYP_USHORT, TYP_USHORT, OPM_RA | OPM_RI | OPM_ASSIGN ) +, OPBASIC( TYP_SINT, TYP_SINT, OPM_RA | OPM_RI | OPM_ASSIGN ) +, OPBASIC( TYP_SINT, TYP_SINT, OPM_II | OPM_AA | OPM_SH ) +, OPBASIC( TYP_SINT, TYP_UINT, OPM_SH ) +, OPBASIC( TYP_SINT, TYP_SLONG, OPM_SH ) +, OPBASIC( TYP_SINT, TYP_ULONG, OPM_SH ) +, OPBASIC( TYP_SINT, TYP_SLONG64, OPM_SH ) +, OPBASIC( TYP_SINT, TYP_ULONG64, OPM_SH ) +, OPBASIC( TYP_SINT, TYP_POINTER, OPM_IP ) +, OPBASIC( TYP_UINT, TYP_SINT, OPM_SH ) +, OPBASIC( TYP_UINT, TYP_UINT, OPM_RA | OPM_RI | OPM_ASSIGN ) +, OPBASIC( TYP_UINT, TYP_UINT, OPM_II | OPM_AA | OPM_SH ) +, OPBASIC( TYP_UINT, TYP_SLONG, OPM_SH ) +, OPBASIC( TYP_UINT, TYP_ULONG, OPM_SH ) +, OPBASIC( TYP_UINT, TYP_SLONG64, OPM_SH ) +, OPBASIC( TYP_UINT, TYP_ULONG64, OPM_SH ) +, OPBASIC( TYP_UINT, TYP_POINTER, OPM_IP ) +, OPBASIC( TYP_SLONG, TYP_SINT, OPM_SH ) +, OPBASIC( TYP_SLONG, TYP_UINT, OPM_SH ) +, OPBASIC( TYP_SLONG, TYP_SLONG, OPM_RA | OPM_RI | OPM_ASSIGN ) +, OPBASIC( TYP_SLONG, TYP_SLONG, OPM_II | OPM_AA | OPM_SH ) +, OPBASIC( TYP_SLONG, TYP_ULONG, OPM_SH ) +, OPBASIC( TYP_SLONG, TYP_SLONG64, OPM_RA | OPM_RI | OPM_ASSIGN ) +, OPBASIC( TYP_SLONG, TYP_ULONG64, OPM_SH ) +, OPBASIC( TYP_SLONG, TYP_POINTER, OPM_IP ) +, OPBASIC( TYP_ULONG, TYP_SINT, OPM_SH ) +, OPBASIC( TYP_ULONG, TYP_UINT, OPM_SH ) +, OPBASIC( TYP_ULONG, TYP_SLONG, OPM_SH ) +, OPBASIC( TYP_ULONG, TYP_ULONG, OPM_RA | OPM_RI | OPM_ASSIGN ) +, OPBASIC( TYP_ULONG, TYP_ULONG, OPM_II | OPM_AA | OPM_SH ) +, OPBASIC( TYP_ULONG, TYP_SLONG64, OPM_SH ) +, OPBASIC( TYP_ULONG, TYP_ULONG64, OPM_RA | OPM_RI | OPM_ASSIGN ) +, OPBASIC( TYP_ULONG, TYP_POINTER, OPM_IP ) +, OPBASIC( TYP_SLONG64, TYP_SINT, OPM_SH ) +, OPBASIC( TYP_SLONG64, TYP_UINT, OPM_SH ) +, OPBASIC( TYP_SLONG64, TYP_SLONG, OPM_RA | OPM_RI | OPM_ASSIGN ) +, OPBASIC( TYP_SLONG64, TYP_ULONG, OPM_SH ) +, OPBASIC( TYP_SLONG64, TYP_SLONG64, OPM_RA | OPM_RI | OPM_ASSIGN ) +, OPBASIC( TYP_SLONG64, TYP_SLONG64, OPM_II | OPM_AA | OPM_SH ) +, OPBASIC( TYP_SLONG64, TYP_ULONG64, OPM_SH ) +, OPBASIC( TYP_SLONG64, TYP_POINTER, OPM_IP ) +, OPBASIC( TYP_ULONG64, TYP_SINT, OPM_SH ) +, OPBASIC( TYP_ULONG64, TYP_UINT, OPM_SH ) +, OPBASIC( TYP_ULONG64, TYP_SLONG, OPM_SH ) +, OPBASIC( TYP_ULONG64, TYP_ULONG, OPM_RA | OPM_RI | OPM_ASSIGN ) +, OPBASIC( TYP_ULONG64, TYP_SLONG64, OPM_SH ) +, OPBASIC( TYP_ULONG64, TYP_ULONG64, OPM_RA | OPM_RI | OPM_ASSIGN ) +, OPBASIC( TYP_ULONG64, TYP_ULONG64, OPM_II | OPM_AA | OPM_SH ) +, OPBASIC( TYP_ULONG64, TYP_POINTER, OPM_IP ) +, OPBASIC( TYP_FLOAT, TYP_FLOAT, OPM_RA | OPM_ASSIGN ) +, OPBASIC( TYP_FLOAT, TYP_FLOAT, OPM_AA ) +, OPBASIC( TYP_DOUBLE, TYP_DOUBLE, OPM_RA | OPM_ASSIGN ) +, OPBASIC( TYP_DOUBLE, TYP_DOUBLE, OPM_AA ) +, OPBASIC( TYP_LONG_DOUBLE, TYP_LONG_DOUBLE, OPM_RA | OPM_ASSIGN ) +, OPBASIC( TYP_LONG_DOUBLE, TYP_LONG_DOUBLE, OPM_AA ) +, OPBASIC( TYP_POINTER, TYP_SINT, OPM_PI ) +, OPBASIC( TYP_POINTER, TYP_UINT, OPM_PI ) +, OPBASIC( TYP_POINTER, TYP_SLONG, OPM_PI ) +, OPBASIC( TYP_POINTER, TYP_ULONG, OPM_PI ) +, OPBASIC( TYP_POINTER, TYP_SLONG64, OPM_PI ) +, OPBASIC( TYP_POINTER, TYP_ULONG64, OPM_PI ) +, OPBASIC( TYP_POINTER, TYP_SINT, OPM_RPI | OPM_ASSIGN ) +, OPBASIC( TYP_POINTER, TYP_UINT, OPM_RPI | OPM_ASSIGN ) +, OPBASIC( TYP_POINTER, TYP_SLONG, OPM_RPI | OPM_ASSIGN ) +, OPBASIC( TYP_POINTER, TYP_ULONG, OPM_RPI | OPM_ASSIGN ) +, OPBASIC( TYP_POINTER, TYP_SLONG64, OPM_RPI | OPM_ASSIGN ) +, OPBASIC( TYP_POINTER, TYP_ULONG64, OPM_RPI | OPM_ASSIGN ) +, OPBASIC( TYP_POINTER, TYP_POINTER, OPM_RP | OPM_ASSIGN ) +, OPBASIC( TYP_POINTER, TYP_POINTER, OPM_PP ) +, OPBASIC( TYP_POINTER, TYP_MEMBER_POINTER, OPM_PM ) +, OPBASIC( TYP_MEMBER_POINTER, TYP_MEMBER_POINTER, OPM_MM ) // the following two must be the last two; used for ":" overloading -, OPBASIC( __x__, __x__, OPM_RR ) -, OPBASIC( __x__, __x__, 0 ) +, OPBASIC( TYP_NONE, TYP_NONE, OPM_RR ) +, OPBASIC( TYP_NONE, TYP_NONE, 0 ) } -#undef __x__ #endif #ifdef OPBASIC_EXTRA -{ OPBASIC_EXTRA( POINTER, POINTER, OPM_PP | OPM_ASSIGN, GETOP_CONST ) -, OPBASIC_EXTRA( POINTER, POINTER, OPM_PP | OPM_ASSIGN, GETOP_VOLATILE ) -, OPBASIC_EXTRA( POINTER, POINTER, OPM_PP | OPM_ASSIGN, GETOP_CONST | GETOP_VOLATILE ) +{ OPBASIC_EXTRA( TYP_POINTER, TYP_POINTER, OPM_PP | OPM_ASSIGN, GETOP_CONST ) +, OPBASIC_EXTRA( TYP_POINTER, TYP_POINTER, OPM_PP | OPM_ASSIGN, GETOP_VOLATILE ) +, OPBASIC_EXTRA( TYP_POINTER, TYP_POINTER, OPM_PP | OPM_ASSIGN, GETOP_CONST | GETOP_VOLATILE ) } #endif From e46f66da92cd6ddc1411f780607ec775c4e4fac8 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Sun, 19 Nov 2023 19:28:15 +0100 Subject: [PATCH 251/258] reformat source files --- bld/plusplus/h/ppopscnv.h | 50 +++++++++++++++++++-------------------- bld/rc/rc/y/rcwin.y | 4 ++-- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/bld/plusplus/h/ppopscnv.h b/bld/plusplus/h/ppopscnv.h index f195a7dd93..835ccdfdf0 100644 --- a/bld/plusplus/h/ppopscnv.h +++ b/bld/plusplus/h/ppopscnv.h @@ -218,30 +218,30 @@ // The number is stored in the operator-flags table in PTREE.C. // #ifdef OPCNV -{ OPCNV( PLUS, OPM_AA | OPM_PI | OPM_IP | OPM_NV ) // op + op -, OPCNV( MINUS, OPM_PP | OPM_AA | OPM_PI | OPM_NV ) // op - op -, OPCNV( ONE_AR, OPM_A ) // one arithmetic -, OPCNV( ONE_RAP, OPM_RA | OPM_RP | OPM_ASSIGN|OPM_NV)// one ref.(ar,ptr) -, OPCNV( POST_OP, OPM_RA | OPM_RP | OPM_POST | OPM_NV)// op++, op-- -, OPCNV( TWO_AR, OPM_AA ) // two arithmetic -, OPCNV( ONE_INT, OPM_I ) // one integer -, OPCNV( TWO_INT, OPM_II ) // two integer -, OPCNV( SHIFT, OPM_SH ) // shift operation -, OPCNV( RELEQ, OPM_AA | OPM_PP | OPM_MM ) // ==, != -// OPCNV( COLON, OPM_AA | OPM_PP | OPM_MM | OPM_RR ) // : (in ?) -, OPCNV( NOT_USED, OPM_AA | OPM_PP | OPM_MM | OPM_RR ) // : (in ?) -, OPCNV( RELN, OPM_AA | OPM_PP ) // >=, <=, >, < -, OPCNV( LOG1, OPM_B ) // logical op -, OPCNV( LOG2, OPM_BB ) // op logical op -, OPCNV( SUBSCR, OPM_PI | OPM_IP | OPM_SUB | OPM_NV) // subscript -, OPCNV( PTR, OPM_P ) // one pointer -, OPCNV( FUNCTION, OPM_FUN | OPM_LT ) // function call -, OPCNV( EQAP, OPM_RPI | OPM_RA | OPM_ASSIGN ) // op assign (ar,ptr) -, OPCNV( EQAR, OPM_RA | OPM_ASSIGN ) // op assign arith -, OPCNV( EQINT, OPM_RI | OPM_ASSIGN ) // op assign int -, OPCNV( QUESTION, OPM_A | OPM_P | OPM_QUEST | OPM_LT) // ?: -, OPCNV( ARROW, OPM_LT ) // -> operator -, OPCNV( EQUALS, OPM_ASSIGN | OPM_RA | OPM_RPI | OPM_RP ) // = operator -, OPCNV( ARROW_STAR,OPM_PM ) // ->* operator +{ OPCNV( PLUS, OPM_AA | OPM_PI | OPM_IP | OPM_NV ) // op + op +, OPCNV( MINUS, OPM_PP | OPM_AA | OPM_PI | OPM_NV ) // op - op +, OPCNV( ONE_AR, OPM_A ) // one arithmetic +, OPCNV( ONE_RAP, OPM_RA | OPM_RP | OPM_ASSIGN | OPM_NV ) // one ref.(ar,ptr) +, OPCNV( POST_OP, OPM_RA | OPM_RP | OPM_POST | OPM_NV ) // op++, op-- +, OPCNV( TWO_AR, OPM_AA ) // two arithmetic +, OPCNV( ONE_INT, OPM_I ) // one integer +, OPCNV( TWO_INT, OPM_II ) // two integer +, OPCNV( SHIFT, OPM_SH ) // shift operation +, OPCNV( RELEQ, OPM_AA | OPM_PP | OPM_MM ) // ==, != +//, OPCNV( COLON, OPM_AA | OPM_PP | OPM_MM | OPM_RR ) // : (in ?) +, OPCNV( NOT_USED, OPM_AA | OPM_PP | OPM_MM | OPM_RR ) // : (in ?) +, OPCNV( RELN, OPM_AA | OPM_PP ) // >=, <=, >, < +, OPCNV( LOG1, OPM_B ) // logical op +, OPCNV( LOG2, OPM_BB ) // op logical op +, OPCNV( SUBSCR, OPM_PI | OPM_IP | OPM_SUB | OPM_NV ) // subscript +, OPCNV( PTR, OPM_P ) // one pointer +, OPCNV( FUNCTION, OPM_FUN | OPM_LT ) // function call +, OPCNV( EQAP, OPM_RPI | OPM_RA | OPM_ASSIGN ) // op assign (ar,ptr) +, OPCNV( EQAR, OPM_RA | OPM_ASSIGN ) // op assign arith +, OPCNV( EQINT, OPM_RI | OPM_ASSIGN ) // op assign int +, OPCNV( QUESTION, OPM_A | OPM_P | OPM_QUEST | OPM_LT ) // ?: +, OPCNV( ARROW, OPM_LT ) // -> operator +, OPCNV( EQUALS, OPM_ASSIGN | OPM_RA | OPM_RPI | OPM_RP ) // = operator +, OPCNV( ARROW_STAR, OPM_PM ) // ->* operator } #endif diff --git a/bld/rc/rc/y/rcwin.y b/bld/rc/rc/y/rcwin.y index e5a2bc178c..cb37518167 100644 --- a/bld/rc/rc/y/rcwin.y +++ b/bld/rc/rc/y/rcwin.y @@ -1214,7 +1214,7 @@ dlg-resource { SemWINWriteDialogBox( $1, MEMFLAG_PURE|MEMFLAG_MOVEABLE|MEMFLAG_DISCARDABLE, - $4, SemWINNewDiagOptions( &($3 ) ), $6, $5, $2 ); + $4, SemWINNewDiagOptions( &($3) ), $6, $5, $2 ); } | name-id dialog-or-dialogEx resource-options comma-opt size-info helpId-opt diag-options-section diag-control-section @@ -1244,7 +1244,7 @@ dlg-resource SemWINCheckMemFlags( &($3), 0, MEMFLAG_MOVEABLE | MEMFLAG_DISCARDABLE, MEMFLAG_PURE ); SemWINWriteDialogBox( $1, $3.flags, $6, - SemWINNewDiagOptions( &($5 ) ), $8, $7, $2 ); + SemWINNewDiagOptions( &($5) ), $8, $7, $2 ); } ; From 93d98060654e6748f5bf196a54bb20b11264c2e1 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Mon, 20 Nov 2023 19:15:15 +0100 Subject: [PATCH 252/258] cleanup header files --- bld/hdr/watcom/stddef.mh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/bld/hdr/watcom/stddef.mh b/bld/hdr/watcom/stddef.mh index 03339a500b..747f7efae6 100644 --- a/bld/hdr/watcom/stddef.mh +++ b/bld/hdr/watcom/stddef.mh @@ -61,11 +61,18 @@ :include ptrdifft.sp -:include ext.sp - +:: :: Thread symbols section. +:: +:include ext.sp :segment BITS16 +:segment DOS +#ifdef _M_I86 + _WCRTDATA extern int _WCFAR *_threadid; /* pointer to thread id */ +#else +:elsesegment #ifndef _M_I86 +:endsegment :endsegment #define _threadid (__threadid()) _WCRTLINK extern int *__threadid( void ); /* pointer to thread id */ @@ -73,13 +80,10 @@ #ifdef __NT__ :include thrdhndl.sp #endif -#else - _WCRTDATA extern int _WCFAR *_threadid; /* pointer to thread id */ :endsegment :segment BITS16 #endif :endsegment - :include extepi.sp ::::::::: Safer C ::::::::: From 071e8d64ab2d8147ad12b6ebc9b860d0b7354127 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Mon, 20 Nov 2023 20:39:18 +0100 Subject: [PATCH 253/258] correct handling TYP_NONE in C++ compiler --- bld/plusplus/c/analtype.c | 1 + bld/plusplus/c/dbg.c | 8 +---- bld/plusplus/c/fmttype.c | 64 +++++++++++++++++++-------------------- bld/plusplus/c/type.c | 31 ++++++++++--------- bld/plusplus/h/symtype.h | 11 +++++-- 5 files changed, 59 insertions(+), 56 deletions(-) diff --git a/bld/plusplus/c/analtype.c b/bld/plusplus/c/analtype.c index e0f58d1b47..d0af363429 100644 --- a/bld/plusplus/c/analtype.c +++ b/bld/plusplus/c/analtype.c @@ -371,6 +371,7 @@ static type_id intPromo[] = { // Table of integral promotions #define pick(id,promo,promo_asm,type_text) promo, #include "_typdefs.h" #undef pick + TYP_NONE }; diff --git a/bld/plusplus/c/dbg.c b/bld/plusplus/c/dbg.c index 3b32db7166..63b08cbe57 100644 --- a/bld/plusplus/c/dbg.c +++ b/bld/plusplus/c/dbg.c @@ -495,12 +495,6 @@ void DumpSymbol( // DUMP SYMBOL ENTRY } } -static const char *id_names[] = { - #define pick(id,promo,promo_asm,type_text) __STR( id ), - #include "_typdefs.h" - #undef pick -}; - static const char unknown_type[] = "***UNKNOWN**=xx"; void DumpType( // DUMP TYPE ENTRY @@ -516,7 +510,7 @@ void DumpType( // DUMP TYPE ENTRY sprintf( (char *)( unknown_type + ( sizeof( unknown_type ) - 1 ) - 2 ), "%2x", tp->id ); id = unknown_type; } else { - id = id_names[tp->id]; + id = TypeIdNames[tp->id]; } printf( "TYPE" F_BADDR " next" F_PTR diff --git a/bld/plusplus/c/fmttype.c b/bld/plusplus/c/fmttype.c index 4c1423b598..8fc58cea84 100644 --- a/bld/plusplus/c/fmttype.c +++ b/bld/plusplus/c/fmttype.c @@ -65,8 +65,8 @@ typedef struct { type_flag mask; } FMT_FLAG_INFO; -static const char *typeName[] = { - #define pick(id,promo,promo_asm,type_text) type_text, +static const char *typeText[] = { + #define pick(id,promo,promo_asm,text) text, #include "_typdefs.h" #undef pick }; @@ -333,7 +333,7 @@ static void fmtTypeFunction( arg_list *alist, VBUF *pvbuf, unsigned num_def, FMT num_def = num_args - num_def; if( num_args == 0 ) { if( control & FF_USE_VOID ) { - VbufConcStr( &working, typeName[TYP_VOID] ); + VbufConcStr( &working, typeText[TYP_VOID] ); } else { VbufTruncWhite( &working ); } @@ -479,7 +479,7 @@ const char *FormatErrorType( TYPE err_type ) if( err_type->flag & TF1_SPECIAL_FMT ) { return( errFormats[err_type->u.e.fmt] ); } - return( typeName[TYP_ERROR] ); + return( typeText[TYP_ERROR] ); } void FormatFunctionType( TYPE type, VBUF *pprefix, VBUF *psuffix, unsigned num_def, FMT_CONTROL control ) @@ -495,6 +495,7 @@ void FormatFunctionType( TYPE type, VBUF *pprefix, VBUF *psuffix, unsigned num_d AUX_INFO *pragma; unsigned use_def; FMT_CONTROL fn_control; + const char *type_text; VbufInit( pprefix ); VbufInit( psuffix ); @@ -506,6 +507,7 @@ void FormatFunctionType( TYPE type, VBUF *pprefix, VBUF *psuffix, unsigned num_d fmtTypePush( &StackFMT, type, control ); while( (top = StackPop( &StackFMT )) != NULL ) { top_type = top->type; + type_text = typeText[top_type->id]; switch( top_type->id ) { case TYP_ERROR: VbufConcStr( pprefix, FormatErrorType( top_type ) ); @@ -527,36 +529,34 @@ void FormatFunctionType( TYPE type, VBUF *pprefix, VBUF *psuffix, unsigned num_d case TYP_LONG_DOUBLE: case TYP_DOT_DOT_DOT: case TYP_VOID: - VbufConcStr( pprefix, typeName[top->type->id] ); - break; case TYP_NULLPTR: - VbufConcStr( pprefix, "decltype(nullptr) " ); + VbufConcStr( pprefix, type_text ); break; case TYP_GENERIC: VbufConcChr( pprefix, '?' ); - VbufConcDecimal( pprefix, top->type->u.g.index ); + VbufConcDecimal( pprefix, top_type->u.g.index ); VbufConcChr( pprefix, ' ' ); break; case TYP_USHORT: - flags = top->type->flag; + flags = top_type->flag; if( flags != TF1_NULL ) { fmtTypeFlag( flags, pprefix, ushortFlags ); } else { - VbufConcStr( pprefix, typeName[top->type->id] ); + VbufConcStr( pprefix, type_text ); } break; case TYP_POINTER: fmtTypeChangeState( &lr_state, RIGHT, pprefix, psuffix ); - flags = top->type->flag; + flags = top_type->flag; if( flags != TF1_NULL ) { fmtTypeFlag( flags, pprefix, pointerFlags ); } else { - VbufConcStr( pprefix, typeName[top->type->id] ); + VbufConcStr( pprefix, type_text ); } break; case TYP_MEMBER_POINTER: fmtTypeChangeState( &lr_state, RIGHT, pprefix, psuffix ); - class_type = MemberPtrClass( top->type ); + class_type = MemberPtrClass( top_type ); if( class_type != NULL ) { fmtTypeScope( class_type->u.c.scope->enclosing, pprefix ); name = SimpleTypeName( class_type ); @@ -568,50 +568,50 @@ void FormatFunctionType( TYPE type, VBUF *pprefix, VBUF *psuffix, unsigned num_d } else { VbufConcStr( pprefix, memberPointer ); } - VbufConcStr( pprefix, typeName[top->type->id] ); + VbufConcStr( pprefix, type_text ); break; case TYP_TYPEDEF: if( (control & FF_TYPEDEF_STOP) == 0 ) break; // fall through case TYP_ENUM: - fmtTypeScope( top->type->u.t.scope, pprefix ); - name = SimpleTypeName( top->type ); + fmtTypeScope( top_type->u.t.scope, pprefix ); + name = SimpleTypeName( top_type ); if( name == NULL ) { - VbufConcStr( pprefix, typeName[top->type->id] ); + VbufConcStr( pprefix, type_text ); } else { VbufConcStr( pprefix, NameStr( name ) ); VbufConcStr( pprefix, whiteSpace ); } break; case TYP_CLASS: - fmtTypeScope( top->type->u.c.scope->enclosing, pprefix ); - flags = top->type->flag; - name = SimpleTypeName( top->type ); + fmtTypeScope( top_type->u.c.scope->enclosing, pprefix ); + flags = top_type->flag; + name = SimpleTypeName( top_type ); if( name == NULL ) { if( flags != TF1_NULL ) { fmtTypeFlag( flags, pprefix, classFlags ); } else { - VbufConcStr( pprefix, typeName[top->type->id] ); + VbufConcStr( pprefix, type_text ); } } else { VbufConcStr( pprefix, NameStr( name ) ); if( flags & TF1_INSTANTIATION ) { - fmtTemplateParms( top->type, pprefix ); + fmtTemplateParms( top_type, pprefix ); } else if( flags & TF1_UNBOUND ) { - fmtUnboundTemplateParms( pprefix, top->type ); + fmtUnboundTemplateParms( pprefix, top_type ); } VbufConcStr( pprefix, whiteSpace ); } break; case TYP_BITFIELD: - fmtTypeBitfield( top->type, psuffix ); + fmtTypeBitfield( top_type, psuffix ); break; case TYP_FUNCTION: fmtTypeChangeState( &lr_state, LEFT, pprefix, psuffix ); - flags = top->type->flag; + flags = top_type->flag; fmtTypeFlag( flags, pprefix, functionFlags ); - fmtTypePragma( top->type, pprefix ); + fmtTypePragma( top_type, pprefix ); fn_control = control; if( top->main_function ) { use_def = num_def; @@ -619,18 +619,18 @@ void FormatFunctionType( TYPE type, VBUF *pprefix, VBUF *psuffix, unsigned num_d fn_control &= ~FF_ARG_NAMES; use_def = 0; } - fmtTypeFunction( TypeArgList( top->type ) + fmtTypeFunction( TypeArgList( top_type ) , psuffix , use_def , fn_control ); break; case TYP_ARRAY: fmtTypeChangeState( &lr_state, LEFT, pprefix, psuffix ); - fmtTypeArray( top->type, psuffix ); + fmtTypeArray( top_type, psuffix ); break; case TYP_MODIFIER: - flags = top->type->flag; - pragma = top->type->u.m.pragma; + flags = top_type->flag; + pragma = top_type->u.m.pragma; if( (flags & TF1_DISPLAY) == 0 && pragma == NULL ) { lr_state = RIGHT; } else { @@ -638,11 +638,11 @@ void FormatFunctionType( TYPE type, VBUF *pprefix, VBUF *psuffix, unsigned num_d willPrintBased( flags ) ) { fmtTypeChangeState( &lr_state, RIGHT, pprefix, psuffix ); fmtModifierTypeFlag( type, flags, pprefix ); - fmtTypeBased( top->type, pprefix ); + fmtTypeBased( top_type, pprefix ); } else { lr_state = RIGHT; } - fmtTypePragma( top->type, pprefix ); + fmtTypePragma( top_type, pprefix ); } break; } diff --git a/bld/plusplus/c/type.c b/bld/plusplus/c/type.c index 00e8f67116..63c34337f2 100644 --- a/bld/plusplus/c/type.c +++ b/bld/plusplus/c/type.c @@ -80,10 +80,6 @@ #define RPT_ARGS_TOTAL ARGS_MAX+1 #define RPT_ARGS_MAX ARGS_MAX+1+1 -#define RPT_TYP_NONE TYP_MAX -#define RPT_TYP_TOTAL TYP_MAX+1 -#define RPT_TYP_MAX TYP_MAX+1+1 - #define zero_table( table ) memset( table, 0, sizeof( table ) ) enum { @@ -94,6 +90,18 @@ enum { TYPE TypeError; TYPE TypeCache[TYPC_LAST]; +#if defined( DEVBUILD ) || defined( XTRA_RPT ) +char const * const TypeIdNames[] = { + #define pick(id,promo,promo_asm,type_text) __STR( id ), + #include "_typdefs.h" + #undef pick + "TYP_NONE", +#if defined( XTRA_RPT ) + "Total" +#endif +}; +#endif + static TYPE basicTypes[TYP_MAX]; static TYPE typeTable[TYP_MAX]; static TYPE fnHashTable[ARGS_HASH][TYPE_HASH_MODULUS]; @@ -983,7 +991,7 @@ void CheckUniqueType( TYPE newtype ) { #ifdef XTRA_RPT ExtraRptTabIncr( ctr_type_ids, newtype->id, 0 ); - ExtraRptTabIncr( ctr_type_ids, RPT_TYP_TOTAL, 0 ); + ExtraRptTabIncr( ctr_type_ids, TYP_TOTAL, 0 ); if( newtype->id == TYP_FUNCTION ) { unsigned num_args = newtype->u.f.args->num_args; if( num_args < ARGS_MAX ) { @@ -1031,7 +1039,7 @@ static TYPE typeDuplicated( // GET DUPLICATED TYPE ExtraRptIncrementCtr( ctr_cg_dups_fail ); } ExtraRptTabIncr( ctr_type_ids, newtype->id, 0 ); - ExtraRptTabIncr( ctr_type_ids, RPT_TYP_TOTAL, 0 ); + ExtraRptTabIncr( ctr_type_ids, TYP_TOTAL, 0 ); if( newtype->id == TYP_FUNCTION ) { unsigned num_args = newtype->u.f.args->num_args; if( num_args < ARGS_MAX ) { @@ -1105,7 +1113,7 @@ TYPE CheckDupType( TYPE newtype ) ExtraRptIncrementCtr( ctr_cg_dups_fail ); } ExtraRptTabIncr( ctr_type_ids, id, 0 ); - ExtraRptTabIncr( ctr_type_ids, RPT_TYP_TOTAL, 0 ); + ExtraRptTabIncr( ctr_type_ids, TYP_TOTAL, 0 ); if( id == TYP_FUNCTION ) { num_args = newtype->u.f.args->num_args; if( num_args < ARGS_MAX ) { @@ -8608,14 +8616,7 @@ static void typesInit( // TYPES INITIALIZATION ExtraRptRegisterCtr( &ctr_cg_dups_fail, "dup. checks failed (back-end)" ); #ifdef XTRA_RPT { - static char const * const typeIdNames[] = { - #define pick(id,promo,promo_asm,type_text) __STR( id ), - #include "_typdefs.h" - #undef pick - "TYP_NONE", - "Total" - }; - ExtraRptRegisterTab( "type id frequency table", typeIdNames, &ctr_type_ids[0][0], RPT_TYP_MAX, 1 ); + ExtraRptRegisterTab( "type id frequency table", TypeIdNames, &ctr_type_ids[0][0], RPT_TYP_MAX, 1 ); ExtraRptRegisterTab( "number of fn arguments frequency table", NULL, &ctr_fn_args[0][0], RPT_ARGS_MAX, 1 ); } #endif diff --git a/bld/plusplus/h/symtype.h b/bld/plusplus/h/symtype.h index 85aacef5a1..164b245611 100644 --- a/bld/plusplus/h/symtype.h +++ b/bld/plusplus/h/symtype.h @@ -230,11 +230,14 @@ typedef enum { #define pick(id,promo,promo_asm,type_text) id, #include "_typdefs.h" #undef pick + TYP_NONE, TYP_MAX, +#ifdef XTRA_RPT + TYP_TOTAL = TYP_MAX, +#endif + RPT_TYP_MAX, } type_id; -#define TYP_NONE TYP_MAX - #define TYP_FIRST_FUNDAMENTAL TYP_BOOL #define TYP_LAST_FUNDAMENTAL TYP_LONG_DOUBLE @@ -1764,6 +1767,10 @@ typedef enum typc_index { } typc_index; extern TYPE TypeCache[]; +#if defined( DEVBUILD ) || defined( XTRA_RPT ) +extern char const * const TypeIdNames[]; +#endif + #define TypeGetCache( tci ) ( TypeCache[(tci)] ) #define TypeSetCache( tci, ty ) ( TypeCache[(tci)] = ( ty ) ) From ef4a42b9d6d8c3222ffc70a3ccb8ea510897c64a Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Mon, 20 Nov 2023 21:57:33 +0100 Subject: [PATCH 254/258] update CRTL documentation --- docs/doc/lr/libfuns.gml | 3 ++- docs/doc/lr/src/brk.gml | 36 ++++++++++++++++++++++++++++++++++++ docs/doc/lr/src/clibover.gml | 2 ++ docs/doc/lr/src/sbrk.gml | 23 +++++++++++------------ 4 files changed, 51 insertions(+), 13 deletions(-) create mode 100644 docs/doc/lr/src/brk.gml diff --git a/docs/doc/lr/libfuns.gml b/docs/doc/lr/libfuns.gml index eda31afeb5..3323e94f4e 100644 --- a/docs/doc/lr/libfuns.gml +++ b/docs/doc/lr/libfuns.gml @@ -89,6 +89,7 @@ .fnc break&grpsfx break breakoff.gml DOS .fnc break_off break breakoff.gml DOS .fnc break_on break breakoff.gml DOS +.fnc brk brk brk.gml DOS QNX W .fnc bsearch bsearch bsearch.gml DOS QNX W WIN32 .fnc bsearch_s bsearch_s bsrch_s.gml DOS QNX W WIN32 .fnc btom btom btom.gml NEC @@ -564,7 +565,7 @@ .fnc intr intr intr.gml DOS QNX W .fnc intrf intrf intrf.gml DOS QNX W .fnc isalkana isalkana isalkana.gml NEC -.fnc isalnmkana isalnmkana isalnmkana.gmlNEC +.fnc isalnmkana isalnmkana isalnmka.gml NEC .fnc isalnum isalnum isalnum.gml DOS QNX W WIN32 .fnw iswalnum isalnum isalnum.gml DOS QNX W WIN32 .fnc isalpha isalpha isalpha.gml DOS QNX W WIN32 diff --git a/docs/doc/lr/src/brk.gml b/docs/doc/lr/src/brk.gml new file mode 100644 index 0000000000..1eaff1403a --- /dev/null +++ b/docs/doc/lr/src/brk.gml @@ -0,0 +1,36 @@ +.func brk +.synop begin +#include +int brk( void __near *addr ); +.ixfunc2 '&Memory' &funcb +.synop end +.desc begin +Change data segment size, the "break" value. +The "break" value is the address of the first byte of unallocated +memory. +When a program starts execution, the break value is placed following +the code and constant data for the program. +As memory is allocated, this pointer will advance when there is no +freed block large enough to satisfy an allocation request. +The +.id &funcb. +function can be used to set a new "break" value for the program. +.np +This value may be changed by a program at any time. +.desc end +.return begin +If the call to +.id &funcb. +succeeds, "break" value is set to new value and 0 is returned. +If the call to +.id &funcb. +fails, &minus.1 is returned. +.im errnoref +.return end +.see begin +.im seealloc +.see end +.exmp begin +.exmp end +.class WATCOM +.system diff --git a/docs/doc/lr/src/clibover.gml b/docs/doc/lr/src/clibover.gml index 32d76402fb..e6f2b3a914 100644 --- a/docs/doc/lr/src/clibover.gml +++ b/docs/doc/lr/src/clibover.gml @@ -1326,6 +1326,8 @@ allocate a memory block from a based heap return the size of a memory block .fd _brealloc re-allocate a memory block in a based heap +.fd brk +set allocation "break" position .fd calloc allocate and zero memory .fd _expand diff --git a/docs/doc/lr/src/sbrk.gml b/docs/doc/lr/src/sbrk.gml index 79cfa7af1e..6b2fa1b722 100644 --- a/docs/doc/lr/src/sbrk.gml +++ b/docs/doc/lr/src/sbrk.gml @@ -1,7 +1,6 @@ .func sbrk .synop begin #include -int brk( void __near *addr ); void __near *sbrk( int increment ); .ixfunc2 '&Memory' &funcb .synop end @@ -91,26 +90,26 @@ fails, &minus.1 is returned. .exmp break void main() { - void *brk; + void *brkval; .exmp break #if defined(M_I86) - alloc( 0x0000, brk ); + alloc( 0x0000, brkval ); /* calling printf will cause an allocation */ - printf( "Original break value %p\n", brk ); + printf( "Original break value %p\n", brkval ); printf( "Current amblksiz value %x\n", _amblksiz ); - alloc( 0x0000, brk ); - printf( "New break value after printf \t\t%p\n", brk ); + alloc( 0x0000, brkval ); + printf( "New break value after printf \t\t%p\n", brkval ); #endif - alloc( 0x3100, brk ); + alloc( 0x3100, brkval ); printf( "New break value after sbrk( 0x3100 ) \t%p\n", - brk ); - alloc( 0x0200, brk ); + brkval ); + alloc( 0x0200, brkval ); printf( "New break value after sbrk( 0x0200 ) \t%p\n", - brk ); + brkval ); #if defined(M_I86) - alloc( -0x0100, brk ); + alloc( -0x0100, brkval ); printf( "New break value after sbrk( -0x0100 ) \t%p\n", - brk ); + brkval ); #endif } .exmp end From 693b0fff49114b505f287c54b99a25b29b94b388 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Tue, 21 Nov 2023 16:46:10 +0100 Subject: [PATCH 255/258] cleanup C++ compiler code --- bld/plusplus/c/type.c | 6 +++--- bld/plusplus/h/symtype.h | 15 +++++++++------ 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/bld/plusplus/c/type.c b/bld/plusplus/c/type.c index 63c34337f2..fec22a6e0c 100644 --- a/bld/plusplus/c/type.c +++ b/bld/plusplus/c/type.c @@ -991,7 +991,7 @@ void CheckUniqueType( TYPE newtype ) { #ifdef XTRA_RPT ExtraRptTabIncr( ctr_type_ids, newtype->id, 0 ); - ExtraRptTabIncr( ctr_type_ids, TYP_TOTAL, 0 ); + ExtraRptTabIncr( ctr_type_ids, RPT_TYP_TOTAL, 0 ); if( newtype->id == TYP_FUNCTION ) { unsigned num_args = newtype->u.f.args->num_args; if( num_args < ARGS_MAX ) { @@ -1039,7 +1039,7 @@ static TYPE typeDuplicated( // GET DUPLICATED TYPE ExtraRptIncrementCtr( ctr_cg_dups_fail ); } ExtraRptTabIncr( ctr_type_ids, newtype->id, 0 ); - ExtraRptTabIncr( ctr_type_ids, TYP_TOTAL, 0 ); + ExtraRptTabIncr( ctr_type_ids, RPT_TYP_TOTAL, 0 ); if( newtype->id == TYP_FUNCTION ) { unsigned num_args = newtype->u.f.args->num_args; if( num_args < ARGS_MAX ) { @@ -1113,7 +1113,7 @@ TYPE CheckDupType( TYPE newtype ) ExtraRptIncrementCtr( ctr_cg_dups_fail ); } ExtraRptTabIncr( ctr_type_ids, id, 0 ); - ExtraRptTabIncr( ctr_type_ids, TYP_TOTAL, 0 ); + ExtraRptTabIncr( ctr_type_ids, RPT_TYP_TOTAL, 0 ); if( id == TYP_FUNCTION ) { num_args = newtype->u.f.args->num_args; if( num_args < ARGS_MAX ) { diff --git a/bld/plusplus/h/symtype.h b/bld/plusplus/h/symtype.h index 164b245611..58bd20ce2a 100644 --- a/bld/plusplus/h/symtype.h +++ b/bld/plusplus/h/symtype.h @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -231,16 +231,19 @@ typedef enum { #include "_typdefs.h" #undef pick TYP_NONE, - TYP_MAX, -#ifdef XTRA_RPT - TYP_TOTAL = TYP_MAX, -#endif - RPT_TYP_MAX, + TYP_MAX } type_id; #define TYP_FIRST_FUNDAMENTAL TYP_BOOL #define TYP_LAST_FUNDAMENTAL TYP_LONG_DOUBLE +#ifdef XTRA_RPT +#define RPT_TYP_TOTAL TYP_MAX +#define RPT_TYP_MAX (TYP_MAX + 1) +#else +#define RPT_TYP_MAX TYP_MAX +#endif + typedef enum { TF1_FIRST = 0x00000001, // TYP_ERROR TF1_SPECIAL_FMT = 0x00000002, From 8ac5395179fcfde4f67c53bff9948ccfbc0ab277 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Tue, 21 Nov 2023 21:22:15 +0100 Subject: [PATCH 256/258] cleanup code --- bld/dip/dwarf/c/dfloc.c | 2 +- bld/trmem/trmem.c | 16 +--------------- 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/bld/dip/dwarf/c/dfloc.c b/bld/dip/dwarf/c/dfloc.c index acb90797cd..d2b1c25407 100644 --- a/bld/dip/dwarf/c/dfloc.c +++ b/bld/dip/dwarf/c/dfloc.c @@ -150,7 +150,7 @@ typedef enum { #include "dwregx86.h" #undef pick DW_X86_MAX -}dw_X86_regs; +} dw_X86_regs; typedef struct { unsigned ci : 5; diff --git a/bld/trmem/trmem.c b/bld/trmem/trmem.c index d195c92355..7154e65264 100644 --- a/bld/trmem/trmem.c +++ b/bld/trmem/trmem.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2015-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2015-2023 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -146,9 +146,6 @@ struct _trmem_internal { static int isValidChunk( entry_ptr, const char *, _trmem_who, _trmem_hdl ); -#ifdef __WATCOMC__ -//#pragma disable_message( 579 ) // shut up pointer truncated warning -#endif static void setSize( entry_ptr p, size_t size ) { p->size = size ^ (size_t)p->mem ^ (size_t)p->who ^ (size_t)p; @@ -158,9 +155,6 @@ static size_t getSize( entry_ptr p ) { return( p->size ^ (size_t)p->mem ^ (size_t)p->who ^ (size_t)p ); } -#ifdef __WATCOMC__ -//#pragma enable_message( 579 ) // reenable pointer truncated warning. -#endif static char *mystpcpy( char *dest, const char *src ) { @@ -194,20 +188,13 @@ static char * formFarPtr( char *ptr, void __far *data ) ptr = formHex( ptr, _FP_SEG( data ), 2 ); *ptr = ':'; ptr++; -#ifdef __WATCOMC__ -//#pragma disable_message( 579 ) // shut up pointer truncated warning for _FP_OFF -#endif return formHex( ptr, _FP_OFF( data ), sizeof( void __near * ) ); -#ifdef __WATCOMC__ -//#pragma enable_message( 579 ) // reenable pointer truncated warning -#endif } #endif static char * formCodePtr( _trmem_hdl hdl, char *ptr, _trmem_who who ) { #ifdef __WINDOWS__ -//#pragma disable_message( 579 ) // shut up pointer truncated warning for _FP_OFF GLOBALENTRY entry; if( hdl->use_code_seg_num ) { @@ -223,7 +210,6 @@ static char * formCodePtr( _trmem_hdl hdl, char *ptr, _trmem_who who ) } } } -//#pragma enable_message( 579 ) // reenable pointer truncated warning #else hdl = hdl; #endif From 48b3d2c381b455e690fcb751396ba5ea0080aacb Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Wed, 22 Nov 2023 22:07:42 +0100 Subject: [PATCH 257/258] attempt to fix issue #1155 suppress -gz on OSX for gcc --- build/mif/local.mif | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/build/mif/local.mif b/build/mif/local.mif index 25c2a41494..ba2b3bedfb 100644 --- a/build/mif/local.mif +++ b/build/mif/local.mif @@ -348,19 +348,26 @@ common_cppflags_osx_arm = -D__OSX_ARM__ common_cppflags_osx_a64 = -D__OSX_ARM64__ # common release/debug options -common_flags_rel = -O -g1 -gz -gdwarf-2 -common_flags_dbg = -g -gz -gdwarf +common_flags_rel = -O -g1 -gdwarf-2 +common_flags_dbg = -g -gdwarf +# common debug info compression options +!ifdef __CLANG_TOOLS__ +common_flags_compr = -gz +!else ifndef __OSX__ +common_flags_compr = -gz +!endif + !ifeq debug 0 -common_flags = $(common_flags_rel) +common_flags = $(common_flags_rel) $(common_flags_compr) !else -common_flags = $(common_flags_dbg) +common_flags = $(common_flags_dbg) $(common_flags_compr) !endif # Warning flags: all enabled except the ones that have no use besides annoy people !ifdef __CLANG_TOOLS__ common_cflags_wng = -Wall -Wno-switch -Wno-missing-braces -Wno-parentheses -Wno-pragma-pack -Wno-implicit-exception-spec-mismatch -ferror-limit=200 !else -common_cflags_wng = -Wall -Wno-switch -Wno-missing-braces -Wno-parentheses +common_cflags_wng = -Wall -Wno-switch -Wno-missing-braces -Wno-parentheses -Wno-pragma-pack !endif common_cflags = $(common_cflags_wng) From 4e0b93434fc970ba8e8972b06cb7e857b50ee923 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Mal=C3=A1k?= Date: Thu, 23 Nov 2023 19:16:54 +0100 Subject: [PATCH 258/258] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 303ee7a1a8..d6ee0f8164 100644 --- a/README.md +++ b/README.md @@ -74,7 +74,7 @@ The directory layout is as follows: several environment variables. Note: the rel directory structure is created on the fly. The - location of rel tree can be changed by `OWRELROOT` environment + location of rel tree can be changed by OWRELROOT environment variable. OpenWatcom Installation