From d3401ff6810ab0e5141c3cc0e07c1218fdf3dae1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Mal=C3=A1k?= Date: Sat, 13 Apr 2024 15:38:27 +0200 Subject: [PATCH] cg: change cg_init_info structure to be up-to-date --- bld/cc/c/cgen.c | 6 +++--- bld/cg/c/be.c | 17 ++++++++--------- bld/cg/c/bestub.c | 12 ++++++------ bld/cg/c/intrface.c | 23 +++++++++++------------ bld/cg/doc/cgref.gml | 10 +++------- bld/cg/h/cg.h | 20 ++++++++------------ bld/f77/wfc/c/fcgmain.c | 14 +++++++------- bld/plusplus/c/cgbkmain.c | 4 ++-- 8 files changed, 48 insertions(+), 58 deletions(-) diff --git a/bld/cc/c/cgen.c b/bld/cc/c/cgen.c index c5d26831f8..a95c43dacc 100644 --- a/bld/cc/c/cgen.c +++ b/bld/cc/c/cgen.c @@ -1895,7 +1895,7 @@ void DoCompile( void ) { jmp_buf *old_env; jmp_buf env; - cg_init_info cgi_info; + cg_init_info cg_info; old_env = Environment; if( setjmp( env ) == 0 ) { @@ -1914,8 +1914,8 @@ void DoCompile( void ) if( CompFlags.rent ) { GenSwitches |= CGSW_GEN_POSITION_INDEPENDANT; } - cgi_info = BEInit( GenSwitches, TargetSwitches, OptSize, ProcRevision ); - if( cgi_info.success ) { + cg_info = BEInit( GenSwitches, TargetSwitches, OptSize, ProcRevision ); + if( cg_info.revision != 0 || cg_info.target != 0 ) { #if _CPU == 386 if( TargetSwitches & (CGSW_X86_P5_PROFILING | CGSW_X86_NEW_P5_PROFILING) ) { FunctionProfileSegId = AddSegName( "TI", "DATA", SEGTYPE_INITFINI ); diff --git a/bld/cg/c/be.c b/bld/cg/c/be.c index 623daf5601..22e0814b09 100644 --- a/bld/cg/c/be.c +++ b/bld/cg/c/be.c @@ -77,7 +77,7 @@ extern cg_init_info BEInit( cg_switches cg_data, cg_target_switches tg_data, uint opt_size, proc_revision proc ) { //=================================================================== - cg_init_info info; + cg_init_info cg_info; int i; Model = cg_data; @@ -132,22 +132,21 @@ extern cg_init_info BEInit( cg_switches cg_data, cg_target_switches tg_data, CodeSeg = -1; TargTypeInit(); Action( "BEInit%n" ); - info.version.is_large = true; - info.version.revision = II_REVISION; + cg_info.revision = II_REVISION; #if _TARGET & _TARG_8086 - info.version.target = II_TARG_8086; + cg_info.target = II_TARG_8086; #elif _TARGET & _TARG_80386 - info.version.target = II_TARG_80386; + cg_info.target = II_TARG_80386; #elif _TARGET & _TARG_AXP - info.version.target = II_TARG_AXP; + cg_info.target = II_TARG_AXP; #elif _TARGET & _TARG_PPC - info.version.target = II_TARG_PPC; + cg_info.target = II_TARG_PPC; #elif _TARGET & _TARG_MIPS - info.version.target = II_TARG_MIPS; + cg_info.target = II_TARG_MIPS; #else #error UNKNOWN TARGET #endif - return( info ); + return( cg_info ); } extern void BECloseFiles() { diff --git a/bld/cg/c/bestub.c b/bld/cg/c/bestub.c index 186379fa8f..8d65bb8058 100644 --- a/bld/cg/c/bestub.c +++ b/bld/cg/c/bestub.c @@ -49,15 +49,15 @@ typedef union hdl_type { extern cg_init_info BEInit(cg_switches switches, cg_target_switches tg_switches, uint size,proc_revision proc) { - cg_init_info info; - info.version.is_large = true; - info.version.revision = II_REVISION; + cg_init_info cg_info; + + cg_info.revision = II_REVISION; #if _TARGET & _TARG_8086 - info.version.target = II_TARG_8086; + cg_info.target = II_TARG_8086; #else - info.version.target = II_TARG_80386; + cg_info.target = II_TARG_80386; #endif - return( info ); + return( cg_info ); } extern void BEStart() {} extern void BEStop() {} diff --git a/bld/cg/c/intrface.c b/bld/cg/c/intrface.c index ab21702e6d..c2cca4419e 100644 --- a/bld/cg/c/intrface.c +++ b/bld/cg/c/intrface.c @@ -121,7 +121,7 @@ cg_init_info _CGAPI BEInitCg( cg_switches switches, proc_revision proc ) /**************************************************************/ { - cg_init_info info; + cg_init_info cg_info; OptForSize = (byte)optsize; CGProcessorVersion = proc; /* so _CPULevel works */ @@ -153,26 +153,25 @@ cg_init_info _CGAPI BEInitCg( cg_switches switches, TypeInit(); TInit(); if( !CGOpenf() ) { - info.success = 0; + cg_info.revision = 0; + cg_info.target = 0; } else { - info.success = 1; - info.version.is_large = true; + cg_info.revision = II_REVISION; #if _TARGET & _TARG_8086 - info.version.target = II_TARG_8086; + cg_info.target = II_TARG_8086; #elif _TARGET & _TARG_80386 - info.version.target = II_TARG_80386; + cg_info.target = II_TARG_80386; #elif _TARGET & _TARG_370 - info.version.target = II_TARG_370; /* NYI -- for now */ + cg_info.target = II_TARG_370; /* NYI -- for now */ #elif _TARGET & _TARG_AXP - info.version.target = II_TARG_AXP; + cg_info.target = II_TARG_AXP; #elif _TARGET & _TARG_PPC - info.version.target = II_TARG_PPC; + cg_info.target = II_TARG_PPC; #elif _TARGET & _TARG_MIPS - info.version.target = II_TARG_MIPS; + cg_info.target = II_TARG_MIPS; #endif - info.version.revision = II_REVISION; } - return( info ); + return( cg_info ); } cg_init_info _CGAPI BEInit( cg_switches switches, diff --git a/bld/cg/doc/cgref.gml b/bld/cg/doc/cgref.gml index 2a21e0593f..f2c39b7137 100644 --- a/bld/cg/doc/cgref.gml +++ b/bld/cg/doc/cgref.gml @@ -340,13 +340,9 @@ SET_WTK( proc, WTK_3167 ); The return value structure is defined as follows: .np :XMP. -typedef union cg_init_info { - struct { - unsigned revision : 10; /* contains II_REVISION */ - unsigned target : 5; /* has II_TARG_??? */ - unsigned is_large : 1; /* 1 if 16 bit host */ - } version; - int success; +typedef struct cg_init_info { + unsigned short revision; /* contains II_REVISION */ + unsigned short target; /* has II_TARG_??? */ } cg_init_info; enum { diff --git a/bld/cg/h/cg.h b/bld/cg/h/cg.h index fe8d343770..ac67649d09 100644 --- a/bld/cg/h/cg.h +++ b/bld/cg/h/cg.h @@ -204,13 +204,9 @@ typedef enum { #define DBG_NIL_TYPE ((dbg_type)0) #define DBG_FWD_TYPE ((dbg_type)-1) -typedef union cg_init_info { - struct { - unsigned revision : 10; - unsigned target : 5; - unsigned is_large : 1; - } version; - int success; +typedef struct cg_init_info { + unsigned short revision; + unsigned short target; } cg_init_info; enum { @@ -229,16 +225,16 @@ enum { /* Front end should do - cg_init_info info; + cg_init_info cg_info; - info = BEInit(...); - if( info.success == 0 ) { + cg_info = BEInit(...); + if( cg_info.revision == 0 && cg_info.target == 0 ) { // The code generator didn't initialize! terminate (dnpg,dncthd) } else { - if( info.version.revision != II_REVISION ) { + if( cg_info.revision != II_REVISION ) { // crap out --- wrong version of code generator } - // look at info.version.is_large and info.version.target + // look at cg_info.target } */ diff --git a/bld/f77/wfc/c/fcgmain.c b/bld/f77/wfc/c/fcgmain.c index dcc3b82262..376a86456f 100644 --- a/bld/f77/wfc/c/fcgmain.c +++ b/bld/f77/wfc/c/fcgmain.c @@ -347,21 +347,21 @@ static void CGStart( void ) } cg_info = BEInit( cg_gen_opts, cg_target_opts, space_time, cpu ); - if( cg_info.success != 0 ) { - if( ( cg_info.version.target == II_TARG_STUB ) || - ( cg_info.version.target == II_TARG_CHECK ) ) { + if( cg_info.target != 0 || cg_info.revision != 0 ) { + if( ( cg_info.target == II_TARG_STUB ) || + ( cg_info.target == II_TARG_CHECK ) ) { InitCG(); #if _CPU == 8086 - } else if( cg_info.version.target == II_TARG_8086 ) { + } else if( cg_info.target == II_TARG_8086 ) { InitCG(); #elif _CPU == 386 - } else if( cg_info.version.target == II_TARG_80386 ) { + } else if( cg_info.target == II_TARG_80386 ) { InitCG(); #elif _CPU == _AXP - } else if( cg_info.version.target == II_TARG_AXP ) { + } else if( cg_info.target == II_TARG_AXP ) { InitCG(); #elif _CPU == _PPC - } else if( cg_info.version.target == II_TARG_PPC ) { + } else if( cg_info.target == II_TARG_PPC ) { InitCG(); #else #error no or invalid target specified diff --git a/bld/plusplus/c/cgbkmain.c b/bld/plusplus/c/cgbkmain.c index db5fda67e7..811c36b069 100644 --- a/bld/plusplus/c/cgbkmain.c +++ b/bld/plusplus/c/cgbkmain.c @@ -3143,11 +3143,11 @@ void CgBackEnd( // BACK-END CONTROLLER CtxSetCurrContext( CTX_CG_FUNC ); if( BELoad( NULL ) ) { cg_info = BEInitCg( GenSwitches, TargetSwitches, OptSize, CpuSwitches ); - if( !cg_info.success ) { + if( cg_info.revision == 0 && cg_info.target == 0 ) { CErr1( ERR_CODEGEN_CANT_INITIALIZE ); CSuicide(); #ifdef DEVBUILD - } else if( cg_info.version.revision != II_REVISION ) { + } else if( cg_info.revision != II_REVISION ) { CFatal( "Incorrect Code Generator version" ); #endif } else {