Skip to content

Commit

Permalink
* added changes to allow Watcom C to compile
Browse files Browse the repository at this point in the history
  • Loading branch information
shawnpringle committed Oct 22, 2019
1 parent 7aa8fa7 commit 0a614b0
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 7 deletions.
9 changes: 3 additions & 6 deletions source/Makefile.wat
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ EU_CORE_FILES = &
coverage.e &
emit.e &
error.e &
fenv.e &
fwdref.e &
global.e &
inline.e &
Expand Down Expand Up @@ -437,7 +436,7 @@ OSFLAG=EWINDOWS
LIBTARGET=$(BUILDDIR)\$(LIBRARY_NAME).lib
CC = wcc386
.ERASE
COMMON_FLAGS = $(DEBUGFLAG) -DARCH=ix86
COMMON_FLAGS = $(DEBUGFLAG) -DARCH=ix86 -DEX86=1
FE_FLAGS = /bt=nt /mf /w0 /zq /j /zp4 /fp5 /fpi87 /5r /otimra /s /I$(TRUNKDIR) $(EREL_TYPE)
BE_FLAGS = /ol /zp4 /d$(OSFLAG) /5r /dEWATCOM /dEOW $(SETALIGN4) $(NOASSERT) $(HEAPCHECKFLAG) $(%ERUNTIME) $(EXTRACHECKFLAG) $(EXTRASTATSFLAG) $(MEMFLAG) $(EREL_TYPE)

Expand Down Expand Up @@ -551,21 +550,19 @@ report: .SYMBOLIC
$(EUTEST) -process-log -html > ..\reports\report.html
cd ..\source

!ifndef BASE
tester: .SYMBOLIC
wmake -h $(BUILDDIR)\eutest\eutest.exe SRCDIR=source BASE=eutest $(VARS)

binder : .SYMBOLIC $(BUILDDIR)\eubind.exe

$(BUILDDIR)\eubind.exe : $(BUILDDIR)\euc.exe $(BUILDDIR)\eu.lib $(TRUNKDIR)\source\eubind.ex
wmake -h $(BUILDDIR)\eubind.exe SRCDIR=source BASE=eubind $(VARS)
$(BUILDDIR)\euc.exe -con -wat -lib $(BUILDDIR)\eu.lib $(TRUNKDIR)\source\eubind.ex -o $(BUILDDIR)\eubind.exe

shrouder : .SYMBOLIC $(BUILDDIR)\eushroud.exe

$(BUILDDIR)\eushroud.exe : $(BUILDDIR)\euc.exe $(BUILDDIR)\eu.lib $(TRUNKDIR)\source\eushroud.ex
wmake -h $(BUILDDIR)\eushroud.exe SRCDIR=source BASE=eushroud $(VARS)
$(BUILDDIR)\euc.exe -con -wat -lib $(BUILDDIR)\eu.lib $(TRUNKDIR)\source\eubind.ex -o $(BUILDDIR)\eushroud.exe

!endif
tools: .SYMBOLIC
@echo ------- TOOLS -----------
wmake -h $(BUILDDIR)\eutest.exe SRCDIR=source BASE=eutest $(VARS)
Expand Down
58 changes: 58 additions & 0 deletions source/be_execute.c
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,62 @@ static object do_peek4(object a, int b )
#define POKE_LIMIT(x) "poke" #x " is limited to 64-bit numbers"
#endif

#ifdef __WATCOMC__
// 754 - double format as a struct with bitfields.
typedef struct {
unsigned int frac2:32;
unsigned int frac1:20;
unsigned int exp:11;
unsigned int sign:1;
} dbl64_format;

union ds {
double n;
dbl64_format s;
};

static double trunc(const double f) {
union ds d;
signed int ff;
d.n = f;
// A smaller ff number means a greater value of d.n.
ff = 1043 - d.s.exp;
#if DDEBUG
printf("f = %.15g: sign = %d, exp = %d, frac = %u %u. ff = %d:", d.n, d.s.sign, d.s.exp, d.s.frac1, d.s.frac2, ff);
#endif
if (d.s.sign == 0 && d.s.exp == 0 && d.s.frac1 == 0 && d.s.frac2 == 0) {
#if DDEBUG
printf("==> trunc(f) = %0.3g\n", 0.0);
#endif
return f;
}
#if DDEBUG
printf("2**ff: %d", (1 << ff));
#endif
if (ff >= 0) {
d.s.frac1 &= ~((1 << ff) - 1);
d.s.frac2 = 0;
} else if (ff > -32) {
ff += 32;
d.s.frac2 &= ~((1 << ff) - 1);
} // else no bits in d.s.frac* are non-integer valued
// so leave both d.s.frac* as they are

if (d.s.exp < 1023 && d.s.frac1 == 0 && d.s.frac2 == 0) {
// the implicitly bit when frac1==0 and d.s.exp<1023 is <1. Set this to
// special zero case.
d.s.exp = 0;
d.s.sign = 0;
}
//d.s.frac1 &= (((ff + 1) << 1) - 1);
#if DDEBUG
printf("sign = %d, exp = %d, frac = %u %u", d.s.sign, d.s.exp, d.s.frac1, d.s.frac2);
printf("==> trunc(f) = %.14g\n", d.n);
#endif
return d.n;
}
#endif

static void do_poke2(object a, object top)
// moved it here because it was causing bad code generation for WIN32
{
Expand Down Expand Up @@ -965,8 +1021,10 @@ void InitExecute()
// detect matherr support
#if defined(DOMAIN) && defined(SING) && defined(OVERFLOW) && defined(UNDERFLOW) && defined(TLOSS) && defined(PLOSS)
// enable our matherr function
#ifndef __WATCOMC__
_LIB_VERSION = _SVID_;
#endif
#endif

#ifdef _WIN32
/* Prevent "Send Error Report to Microsoft dialog from coming up
Expand Down
3 changes: 3 additions & 0 deletions source/be_runtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -5047,6 +5047,9 @@ void system_call(object command, object wait)
RestoreConfig();
}

#ifdef __WATCOMC__
#define _spawnvp spawnvp
#endif

object system_exec_call(object command, object wait)
/* Run a .exe or .com file, then restore the graphics mode.
Expand Down
2 changes: 1 addition & 1 deletion source/mkver.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ int main(int argc, char **argv)
char new_ver[BUF_SIZE], new_date[BUF_SIZE];
int old_rev = 0, new_rev = 0;
int had_old_info = 0;
int system_return_value;

if (argc < 4)
{
Expand Down Expand Up @@ -141,7 +142,6 @@ int main(int argc, char **argv)
"\"%s\" show --format=%s%%H%%n%%at%%n-1%%n%s > %s",
hg_executable, clq, clq, cache_filename);

int system_return_value;
if ((system_return_value = system(tmp)) != 0)
{
/*
Expand Down

0 comments on commit 0a614b0

Please sign in to comment.