Skip to content

Commit

Permalink
cleanup C and C++ compilers code
Browse files Browse the repository at this point in the history
  • Loading branch information
jmalak committed Dec 17, 2023
1 parent fb99ee1 commit db3e552
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 44 deletions.
26 changes: 13 additions & 13 deletions bld/cc/h/cvars.h
Original file line number Diff line number Diff line change
Expand Up @@ -608,26 +608,26 @@ extern MEPTR MacroScan( void );
extern TOKEN Process_Pragma( void );

/* cmath.c */
extern TREEPTR AddOp(TREEPTR,TOKEN,TREEPTR);
extern TREEPTR InitAsgn( TYPEPTR,TREEPTR );
extern TREEPTR AsgnOp(TREEPTR,TOKEN,TREEPTR);
extern TREEPTR BinOp(TREEPTR,TOKEN,TREEPTR);
extern TREEPTR AddOp( TREEPTR, TOKEN, TREEPTR );
extern TREEPTR InitAsgn( TYPEPTR, TREEPTR );
extern TREEPTR AsgnOp( TREEPTR, TOKEN, TREEPTR );
extern TREEPTR BinOp( TREEPTR, TOKEN, TREEPTR );
extern bool IsPtrConvSafe( TREEPTR, TYPEPTR, TYPEPTR );
extern TREEPTR CnvOp( TREEPTR, TYPEPTR, bool );
extern TREEPTR FlowOp(TREEPTR,opr_code,TREEPTR);
extern TREEPTR IntOp(TREEPTR,TOKEN,TREEPTR);
extern TREEPTR RelOp(TREEPTR,TOKEN,TREEPTR);
extern TREEPTR ShiftOp(TREEPTR,TOKEN,TREEPTR);
extern TYPEPTR TernType(TREEPTR,TREEPTR);
extern TYPEPTR TypeOf(TREEPTR);
extern TREEPTR UComplement(TREEPTR);
extern TREEPTR UMinus(TREEPTR);
extern TREEPTR FlowOp( TREEPTR, opr_code, TREEPTR );
extern TREEPTR IntOp( TREEPTR, TOKEN, TREEPTR );
extern TREEPTR RelOp( TREEPTR, TOKEN, TREEPTR );
extern TREEPTR ShiftOp( TREEPTR, TOKEN, TREEPTR );
extern TYPEPTR TernType( TREEPTR, TREEPTR );
extern TYPEPTR TypeOf( TREEPTR );
extern TREEPTR UComplement( TREEPTR );
extern TREEPTR UMinus( TREEPTR );
extern DATA_TYPE BinExprType( TYPEPTR, TYPEPTR );
extern DATA_TYPE DataTypeOf( TYPEPTR );
extern bool IsFuncPtr( TYPEPTR );
extern TREEPTR FixupAss( TREEPTR opnd, TYPEPTR newtyp );
extern pointer_class ExprTypeClass( TYPEPTR typ );
extern TREEPTR LCastAdj( TREEPTR tree );
extern TREEPTR LCastAdj( TREEPTR tree );

/* cmodel */
extern char *BadCmdLine( int, const char * );
Expand Down
2 changes: 1 addition & 1 deletion bld/plusplus/c/cginfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -1099,7 +1099,7 @@ static void addDefaultImports( void )
}
#endif
if( CompFlags.pgm_used_8087 || CompFlags.float_used ) {
if( CpuSwitches & FPU_EMU ) {
if( GET_FPU_EMU( CpuSwitches ) ) {
#if _CPU == 8086
CgInfoAddImport( "__init_87_emulator" );
#else
Expand Down
32 changes: 24 additions & 8 deletions bld/plusplus/c/cmdlnx86.c
Original file line number Diff line number Diff line change
Expand Up @@ -342,15 +342,14 @@ static void setMemoryModel( OPT_STORAGE *data )
#if _CPU == 8086
data->mem_model = OPT_ENUM_mem_model_ms;
#else
data->mem_model = OPT_ENUM_mem_model_mf;
if( TargetSystem == TS_NETWARE
|| TargetSystem == TS_NETWARE5 ) {
data->mem_model = OPT_ENUM_mem_model_ms;
} else {
data->mem_model = OPT_ENUM_mem_model_mf;
}
#endif
}
#if _CPU == 386
if( TargetSystem == TS_NETWARE
|| TargetSystem == TS_NETWARE5 ) {
data->mem_model = OPT_ENUM_mem_model_ms;
}
#endif
bit = 0;
if( CompFlags.non_iso_compliant_names_enabled ) {
switch( data->mem_model ) {
Expand Down Expand Up @@ -469,7 +468,7 @@ static void setMemoryModel( OPT_STORAGE *data )
}
#if _CPU == 386
/*
* 32-bit code with zld option has DS pegged
* 32-bit code with zdl option has DS pegged
*/
if( data->zdl ) {
TargetSwitches |= CGSW_X86_LOAD_DS_DIRECTLY;
Expand Down Expand Up @@ -711,6 +710,9 @@ static void setMemoryModel( OPT_STORAGE *data )
static void setIntelArchitecture( OPT_STORAGE *data )
{
#if _CPU == 8086
/*
* Set CPU for 16-bit architecture, default is 8086
*/
switch( data->arch_i86 ) {
case OPT_ENUM_arch_i86_default:
case OPT_ENUM_arch_i86__0:
Expand All @@ -736,6 +738,9 @@ static void setIntelArchitecture( OPT_STORAGE *data )
break;
}
#else
/*
* Set CPU for 32-bit architecture, default is 80686
*/
switch( data->arch_386 ) {
case OPT_ENUM_arch_386__3s:
CompFlags.register_conventions = false;
Expand Down Expand Up @@ -771,12 +776,19 @@ static void setIntelArchitecture( OPT_STORAGE *data )
SET_CPU( CpuSwitches, CPU_686 );
break;
}
/*
* NETWARE uses stack based calling conventions
* by default - silly people.
*/
if( TargetSystem == TS_NETWARE
|| TargetSystem == TS_NETWARE5 ) {
CompFlags.register_conventions = false;
}
#endif

/*
* Set FPU level, default is 8087/80387
*/
switch( data->intel_fpu_level ) {
case OPT_ENUM_intel_fpu_level_fp6:
SET_FPU_LEVEL( CpuSwitches, FPU_686 );
Expand All @@ -797,6 +809,9 @@ static void setIntelArchitecture( OPT_STORAGE *data )
SET_FPU_LEVEL( CpuSwitches, FPU_87 );
break;
}
/*
* Set FPU model, default is fpi
*/
switch( data->intel_fpu_model ) {
case OPT_ENUM_intel_fpu_model_default:
case OPT_ENUM_intel_fpu_model_fpi:
Expand Down Expand Up @@ -1034,6 +1049,7 @@ static void macroDefs( void )
break;
DbgDefault( "macroDefs -- invalid exception switch" );
}

switch( GET_CPU( CpuSwitches ) ) {
case CPU_86:
DefSwitchMacro( "0" );
Expand Down
2 changes: 1 addition & 1 deletion bld/plusplus/gml/options.gml
Original file line number Diff line number Diff line change
Expand Up @@ -1418,7 +1418,7 @@
:jusage. 無メッセージモードで動作します(エラーメッセージのみ表示されます)

:option. zro
:target. any
:target. i86 386
:enumerate. fp_rounding
:usage. omit floating point rounding calls (non ANSI)
:jusage. omit floating point rounding calls (non ANSI)
Expand Down
40 changes: 20 additions & 20 deletions bld/plusplus/h/compflag.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@

typedef struct comp_flags {
/*****************************************************************************
// //
// execution status flags //
// //
*****************************************************************************/
*
* execution status flags
*
*****************************************************************************/

boolbit float_used : 1;
boolbit stats_printed : 1;
Expand Down Expand Up @@ -89,24 +89,24 @@ typedef struct comp_flags {
boolbit namespace_checks_done : 1; // namespace ref/def checks done

/*****************************************************************************
// //
// Command Line Option flags //
// //
*****************************************************************************/
*
* Command Line Option flags
*
*****************************************************************************/

/*****************************************************************************
// //
// 'dbg' target flags //
// //
*****************************************************************************/
*
* 'dbg' target flags
*
*****************************************************************************/

boolbit extra_stats_wanted : 1;

/*****************************************************************************
// //
// 'any' target flags //
// //
*****************************************************************************/
*
* 'any' target flags
*
*****************************************************************************/

boolbit signed_char : 1;
boolbit check_syntax : 1;
Expand Down Expand Up @@ -194,10 +194,10 @@ typedef struct comp_flags {
boolbit non_iso_compliant_names_enabled : 1; // enable all compiler non-ISO compliant names (macros, symbols, etc.)

/*****************************************************************************
// //
// 'i86' '386' target flags
// //
*****************************************************************************/
*
* 'i86' '386' target flags
*
*****************************************************************************/

boolbit register_conventions : 1; // on for -3r, off for -3s
boolbit strings_in_code_segment : 1; // on => put strings in CODE
Expand Down
2 changes: 1 addition & 1 deletion bld/plusplus/h/preproc.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
#define PPOPERATOR_PRAGMA "_Pragma"

#define IS_PPOPERATOR_DEFINED(s) (strcmp(s, PPOPERATOR_DEFINED) == 0)
#define IS_PPOPERATOR_PRAGMA(s,l) ((CompFlags.extensions_enabled || CHECK_STD( >= , CXX0X )) \
#define IS_PPOPERATOR_PRAGMA(s,l) ((CompFlags.extensions_enabled || CHECK_STD( > , CXX98 )) \
&& l == (sizeof(PPOPERATOR_PRAGMA) - 1) \
&& memcmp(s, PPOPERATOR_PRAGMA, sizeof(PPOPERATOR_PRAGMA)) == 0)

Expand Down

0 comments on commit db3e552

Please sign in to comment.