From f3ecbd5c2b52b6194090d503767f794f560b11c3 Mon Sep 17 00:00:00 2001 From: David Brown Date: Mon, 22 Aug 2016 18:24:03 +0100 Subject: [PATCH] Remove SYSTEM.H includes (string.h and stdint.h). --- bootstrap/unix-44/Files.c | 8 ++--- bootstrap/unix-44/OPB.c | 26 ++++++++-------- bootstrap/unix-44/OPC.c | 14 ++++----- bootstrap/unix-44/OPM.c | 4 +-- bootstrap/unix-44/OPS.c | 8 ++--- bootstrap/unix-44/OPV.c | 10 +++--- bootstrap/unix-44/Reals.c | 10 +++--- bootstrap/unix-44/SYSTEM.h | 52 ++++++++++++++++++------------- bootstrap/unix-44/Strings.c | 14 ++++----- bootstrap/unix-44/Texts.c | 8 ++--- bootstrap/unix-48/Files.c | 8 ++--- bootstrap/unix-48/OPB.c | 26 ++++++++-------- bootstrap/unix-48/OPC.c | 14 ++++----- bootstrap/unix-48/OPM.c | 4 +-- bootstrap/unix-48/OPS.c | 8 ++--- bootstrap/unix-48/OPV.c | 10 +++--- bootstrap/unix-48/Reals.c | 10 +++--- bootstrap/unix-48/SYSTEM.h | 52 ++++++++++++++++++------------- bootstrap/unix-48/Strings.c | 14 ++++----- bootstrap/unix-48/Texts.c | 8 ++--- bootstrap/unix-88/Files.c | 4 +-- bootstrap/unix-88/OPB.c | 24 +++++++------- bootstrap/unix-88/OPC.c | 14 ++++----- bootstrap/unix-88/OPS.c | 8 ++--- bootstrap/unix-88/OPV.c | 10 +++--- bootstrap/unix-88/Reals.c | 4 +-- bootstrap/unix-88/SYSTEM.h | 52 ++++++++++++++++++------------- bootstrap/unix-88/Strings.c | 14 ++++----- bootstrap/unix-88/Texts.c | 8 ++--- bootstrap/windows-48/Files.c | 8 ++--- bootstrap/windows-48/OPB.c | 26 ++++++++-------- bootstrap/windows-48/OPC.c | 14 ++++----- bootstrap/windows-48/OPM.c | 4 +-- bootstrap/windows-48/OPS.c | 8 ++--- bootstrap/windows-48/OPV.c | 10 +++--- bootstrap/windows-48/Platform.c | 4 +-- bootstrap/windows-48/Reals.c | 10 +++--- bootstrap/windows-48/SYSTEM.h | 52 ++++++++++++++++++------------- bootstrap/windows-48/Strings.c | 14 ++++----- bootstrap/windows-48/Texts.c | 8 ++--- bootstrap/windows-88/Files.c | 4 +-- bootstrap/windows-88/OPB.c | 24 +++++++------- bootstrap/windows-88/OPC.c | 14 ++++----- bootstrap/windows-88/OPS.c | 8 ++--- bootstrap/windows-88/OPV.c | 10 +++--- bootstrap/windows-88/Platform.c | 4 +-- bootstrap/windows-88/Reals.c | 4 +-- bootstrap/windows-88/SYSTEM.h | 52 ++++++++++++++++++------------- bootstrap/windows-88/Strings.c | 14 ++++----- bootstrap/windows-88/Texts.c | 8 ++--- src/system/SYSTEM.h | 55 +++++++++++++++++++-------------- 51 files changed, 424 insertions(+), 377 deletions(-) diff --git a/bootstrap/unix-44/Files.c b/bootstrap/unix-44/Files.c index f03aafe1..e83999fd 100644 --- a/bootstrap/unix-44/Files.c +++ b/bootstrap/unix-44/Files.c @@ -858,7 +858,7 @@ void Files_ReadLInt (Files_Rider *R, LONGINT *R__typ, LONGINT *x) { CHAR b[4]; Files_ReadBytes(&*R, R__typ, (void*)b, ((LONGINT)(4)), ((LONGINT)(4))); - *x = ((LONGINT)((int)b[0] + __ASHL((int)b[1], 8)) + __ASHL((LONGINT)b[2], 16)) + __ASHL((LONGINT)b[3], 24); + *x = ((int)((int)b[0] + __ASHL((int)b[1], 8)) + __ASHL((int)b[2], 16)) + __ASHL((int)b[3], 24); } void Files_ReadSet (Files_Rider *R, LONGINT *R__typ, SET *x) @@ -866,7 +866,7 @@ void Files_ReadSet (Files_Rider *R, LONGINT *R__typ, SET *x) CHAR b[4]; LONGINT l; Files_ReadBytes(&*R, R__typ, (void*)b, ((LONGINT)(4)), ((LONGINT)(4))); - l = ((LONGINT)((int)b[0] + __ASHL((int)b[1], 8)) + __ASHL((LONGINT)b[2], 16)) + __ASHL((LONGINT)b[3], 24); + l = ((int)((int)b[0] + __ASHL((int)b[1], 8)) + __ASHL((int)b[2], 16)) + __ASHL((int)b[3], 24); *x = (SET)l; } @@ -923,11 +923,11 @@ void Files_ReadNum (Files_Rider *R, LONGINT *R__typ, LONGINT *x) n = 0; Files_Read(&*R, R__typ, (void*)&ch); while ((int)ch >= 128) { - n += __ASH((LONGINT)((int)ch - 128), s); + n += __ASH((int)((int)ch - 128), s); s += 7; Files_Read(&*R, R__typ, (void*)&ch); } - n += __ASH((LONGINT)(__MASK((int)ch, -64) - __ASHL(__ASHR((int)ch, 6), 6)), s); + n += __ASH((int)(__MASK((int)ch, -64) - __ASHL(__ASHR((int)ch, 6), 6)), s); *x = n; } diff --git a/bootstrap/unix-44/OPB.c b/bootstrap/unix-44/OPB.c index d16ae3b0..be093f93 100644 --- a/bootstrap/unix-44/OPB.c +++ b/bootstrap/unix-44/OPB.c @@ -242,7 +242,7 @@ static INTEGER OPB_SignedByteSize (LONGINT n) static LONGINT OPB_ShorterSize (LONGINT i) { LONGINT _o_result; - if (i >= (LONGINT)OPM_LIntSize) { + if (i >= (int)OPM_LIntSize) { _o_result = OPM_IntSize; return _o_result; } else { @@ -255,7 +255,7 @@ static LONGINT OPB_ShorterSize (LONGINT i) static LONGINT OPB_LongerSize (LONGINT i) { LONGINT _o_result; - if (i <= (LONGINT)OPM_SIntSize) { + if (i <= (int)OPM_SIntSize) { _o_result = OPM_IntSize; return _o_result; } else { @@ -520,7 +520,7 @@ void OPB_In (OPT_Node *x, OPT_Node y) } else if ((__IN(f, 0x70) && y->typ->form == 9)) { if ((*x)->class == 7) { k = (*x)->conval->intval; - if (k < 0 || k > (LONGINT)OPM_MaxSet) { + if (k < 0 || k > (int)OPM_MaxSet) { OPB_err(202); } else if (y->class == 7) { (*x)->conval->intval = OPB_BoolToInt(__IN(k, y->conval->setval)); @@ -1201,7 +1201,7 @@ static void OPB_Convert (OPT_Node *x, OPT_Struct typ) OPB_err(203); r = (LONGREAL)1; } - (*x)->conval->intval = (LONGINT)__ENTIER(r); + (*x)->conval->intval = (int)__ENTIER(r); OPB_SetIntType(*x); } } @@ -1553,13 +1553,13 @@ void OPB_SetRange (OPT_Node *x, OPT_Node y) } else if ((__IN((*x)->typ->form, 0x70) && __IN(y->typ->form, 0x70))) { if ((*x)->class == 7) { k = (*x)->conval->intval; - if (0 > k || k > (LONGINT)OPM_MaxSet) { + if (0 > k || k > (int)OPM_MaxSet) { OPB_err(202); } } if (y->class == 7) { l = y->conval->intval; - if (0 > l || l > (LONGINT)OPM_MaxSet) { + if (0 > l || l > (int)OPM_MaxSet) { OPB_err(202); } } @@ -1589,7 +1589,7 @@ void OPB_SetElem (OPT_Node *x) OPB_err(93); } else if ((*x)->class == 7) { k = (*x)->conval->intval; - if ((0 <= k && k <= (LONGINT)OPM_MaxSet)) { + if ((0 <= k && k <= (int)OPM_MaxSet)) { (*x)->conval->setval = __SETOF(k); } else { OPB_err(202); @@ -1894,7 +1894,7 @@ void OPB_StPar0 (OPT_Node *par0, INTEGER fctno) case 10: if (x->class == 8 || x->class == 9) { OPB_err(126); - } else if ((__IN(f, 0x70) && x->typ->size > (LONGINT)OPM_SIntSize)) { + } else if ((__IN(f, 0x70) && x->typ->size > (int)OPM_SIntSize)) { OPB_Convert(&x, OPB_IntType(OPB_ShorterSize(x->typ->size))); } else if (f == 8) { OPB_Convert(&x, OPT_realtyp); @@ -1905,7 +1905,7 @@ void OPB_StPar0 (OPT_Node *par0, INTEGER fctno) case 11: if (x->class == 8 || x->class == 9) { OPB_err(126); - } else if ((__IN(f, 0x70) && x->typ->size < (LONGINT)OPM_LIntSize)) { + } else if ((__IN(f, 0x70) && x->typ->size < (int)OPM_LIntSize)) { OPB_Convert(&x, OPB_IntType(OPB_LongerSize(x->typ->size))); } else if (f == 7) { OPB_Convert(&x, OPT_lrltyp); @@ -1954,7 +1954,7 @@ void OPB_StPar0 (OPT_Node *par0, INTEGER fctno) if (x->class == 8 || x->class == 9) { OPB_err(126); } else if (__IN(f, 0x70)) { - if (x->typ->size != (LONGINT)OPM_LIntSize) { + if (x->typ->size != (int)OPM_LIntSize) { OPB_Convert(&x, OPT_linttyp); } } else { @@ -1994,7 +1994,7 @@ void OPB_StPar0 (OPT_Node *par0, INTEGER fctno) OPB_err(126); } else if ((((x->class == 7 && __IN(f, 0x70))) && x->typ->size < OPT_linttyp->size)) { OPB_Convert(&x, OPT_linttyp); - } else if (!((__IN(x->typ->form, 0x2070) && x->typ->size == (LONGINT)OPM_PointerSize))) { + } else if (!((__IN(x->typ->form, 0x2070) && x->typ->size == (int)OPM_PointerSize))) { OPB_err(111); x->typ = OPT_linttyp; } @@ -2092,7 +2092,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno) if (x->class == 8 || x->class == 9) { OPB_err(126); } else if (__IN(f, 0x70)) { - if ((x->class == 7 && (0 > x->conval->intval || x->conval->intval > (LONGINT)OPM_MaxSet))) { + if ((x->class == 7 && (0 > x->conval->intval || x->conval->intval > (int)OPM_MaxSet))) { OPB_err(202); } p = NewOp__57(19, fctno, p, x); @@ -2263,7 +2263,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno) OPB_err(126); } else if ((((x->class == 7 && __IN(f, 0x70))) && x->typ->size < OPT_linttyp->size)) { OPB_Convert(&x, OPT_linttyp); - } else if (!((__IN(x->typ->form, 0x2070) && x->typ->size == (LONGINT)OPM_PointerSize))) { + } else if (!((__IN(x->typ->form, 0x2070) && x->typ->size == (int)OPM_PointerSize))) { OPB_err(111); x->typ = OPT_linttyp; } diff --git a/bootstrap/unix-44/OPC.c b/bootstrap/unix-44/OPC.c index b2b9c32a..617bf8e8 100644 --- a/bootstrap/unix-44/OPC.c +++ b/bootstrap/unix-44/OPC.c @@ -318,7 +318,7 @@ void OPC_Andent (OPT_Struct typ) static BOOLEAN OPC_Undefined (OPT_Object obj) { BOOLEAN _o_result; - _o_result = obj->name[0] == 0x00 || (((obj->mnolev >= 0 && obj->linkadr != (LONGINT)(3 + OPM_currFile))) && obj->linkadr != 2); + _o_result = obj->name[0] == 0x00 || (((obj->mnolev >= 0 && obj->linkadr != (int)(3 + OPM_currFile))) && obj->linkadr != 2); return _o_result; } @@ -826,7 +826,7 @@ void OPC_TDescDecl (OPT_Struct typ) OPC_Str1((CHAR*)", #), {", (LONGINT)8, typ->size); nofptrs = 0; OPC_PutPtrOffsets(typ, ((LONGINT)(0)), &nofptrs); - OPC_Str1((CHAR*)"#}}", (LONGINT)4, -((nofptrs + 1) * (LONGINT)OPM_LIntSize)); + OPC_Str1((CHAR*)"#}}", (LONGINT)4, -((nofptrs + 1) * (int)OPM_LIntSize)); OPC_EndStat(); } @@ -872,7 +872,7 @@ LONGINT OPC_SizeAlignment (LONGINT size) { LONGINT _o_result; LONGINT alignment; - if (size < (LONGINT)OPM_Alignment) { + if (size < (int)OPM_Alignment) { alignment = 1; while (alignment < size) { alignment = __ASHL(alignment, 1); @@ -909,11 +909,11 @@ static void OPC_FillGap (LONGINT gap, LONGINT off, LONGINT align, LONGINT *n, LO if ((*curAlign < align && gap - (adr - off) >= align)) { gap -= (adr - off) + align; OPC_BegStat(); - if (align == (LONGINT)OPM_IntSize) { + if (align == (int)OPM_IntSize) { OPM_WriteString((CHAR*)"INTEGER", (LONGINT)8); - } else if (align == (LONGINT)OPM_LIntSize) { + } else if (align == (int)OPM_LIntSize) { OPM_WriteString((CHAR*)"LONGINT", (LONGINT)8); - } else if (align == (LONGINT)OPM_LRealSize) { + } else if (align == (int)OPM_LRealSize) { OPM_WriteString((CHAR*)"LONGREAL", (LONGINT)9); } OPC_Str1((CHAR*)" _prvt#", (LONGINT)8, *n); @@ -978,7 +978,7 @@ static void OPC_FieldList (OPT_Struct typ, BOOLEAN last, LONGINT *off, LONGINT * } } if (last) { - adr = typ->size - (LONGINT)__ASHR(typ->sysflag, 8); + adr = typ->size - (int)__ASHR(typ->sysflag, 8); if (adr == 0) { gap = 1; } else { diff --git a/bootstrap/unix-44/OPM.c b/bootstrap/unix-44/OPM.c index dc580662..db989d91 100644 --- a/bootstrap/unix-44/OPM.c +++ b/bootstrap/unix-44/OPM.c @@ -872,13 +872,13 @@ void OPM_WriteReal (LONGREAL r, CHAR suffx) CHAR s[32]; CHAR ch; INTEGER i; - if ((((r < OPM_SignedMaximum(OPM_LIntSize) && r > OPM_SignedMinimum(OPM_LIntSize))) && r == ((LONGINT)__ENTIER(r)))) { + if ((((r < OPM_SignedMaximum(OPM_LIntSize) && r > OPM_SignedMinimum(OPM_LIntSize))) && r == ((int)__ENTIER(r)))) { if (suffx == 'f') { OPM_WriteString((CHAR*)"(REAL)", (LONGINT)7); } else { OPM_WriteString((CHAR*)"(LONGREAL)", (LONGINT)11); } - OPM_WriteInt((LONGINT)__ENTIER(r)); + OPM_WriteInt((int)__ENTIER(r)); } else { Texts_OpenWriter(&W, Texts_Writer__typ); if (suffx == 'f') { diff --git a/bootstrap/unix-44/OPS.c b/bootstrap/unix-44/OPS.c index 3f1f738f..474724c8 100644 --- a/bootstrap/unix-44/OPS.c +++ b/bootstrap/unix-44/OPS.c @@ -173,7 +173,7 @@ static void OPS_Number (void) OPS_numtyp = 1; if (n <= 2) { while (i < n) { - OPS_intval = __ASHL(OPS_intval, 4) + (LONGINT)Ord__7(dig[i], 1); + OPS_intval = __ASHL(OPS_intval, 4) + (int)Ord__7(dig[i], 1); i += 1; } } else { @@ -188,7 +188,7 @@ static void OPS_Number (void) OPS_intval = -1; } while (i < n) { - OPS_intval = __ASHL(OPS_intval, 4) + (LONGINT)Ord__7(dig[i], 1); + OPS_intval = __ASHL(OPS_intval, 4) + (int)Ord__7(dig[i], 1); i += 1; } } else { @@ -199,8 +199,8 @@ static void OPS_Number (void) while (i < n) { d = Ord__7(dig[i], 0); i += 1; - if (OPS_intval <= __DIV(2147483647 - (LONGINT)d, 10)) { - OPS_intval = OPS_intval * 10 + (LONGINT)d; + if (OPS_intval <= __DIV(2147483647 - (int)d, 10)) { + OPS_intval = OPS_intval * 10 + (int)d; } else { OPS_err(203); } diff --git a/bootstrap/unix-44/OPV.c b/bootstrap/unix-44/OPV.c index 0545e468..85aca692 100644 --- a/bootstrap/unix-44/OPV.c +++ b/bootstrap/unix-44/OPV.c @@ -86,7 +86,7 @@ void OPV_TypSize (OPT_Struct typ) base = OPC_SizeAlignment(OPM_RecSize); } else { OPV_TypSize(btyp); - offset = btyp->size - (LONGINT)__ASHR(btyp->sysflag, 8); + offset = btyp->size - (int)__ASHR(btyp->sysflag, 8); base = btyp->align; } fld = typ->link; @@ -468,12 +468,10 @@ static void OPV_Entier (OPT_Node n, INTEGER prec) static void OPV_SizeCast (LONGINT size) { - if (size <= (LONGINT)OPM_SIntSize) { - OPM_WriteString((CHAR*)"(int)", (LONGINT)6); - } else if (size <= (LONGINT)OPM_IntSize) { + if (size <= 4) { OPM_WriteString((CHAR*)"(int)", (LONGINT)6); } else { - OPM_WriteString((CHAR*)"(LONGINT)", (LONGINT)10); + OPM_WriteString((CHAR*)"(SYSTEM_INT64)", (LONGINT)15); } } @@ -650,7 +648,7 @@ static void OPV_design (OPT_Node n, INTEGER prec) } if (n->typ->comp == 3) { OPM_Write(')'); - while ((LONGINT)i < __ASHR(d->typ->size - 4, 2)) { + while ((int)i < __ASHR(d->typ->size - 4, 2)) { OPM_WriteString((CHAR*)" * ", (LONGINT)4); OPV_Len(d, i); i += 1; diff --git a/bootstrap/unix-44/Reals.c b/bootstrap/unix-44/Reals.c index 4e478345..43583aa9 100644 --- a/bootstrap/unix-44/Reals.c +++ b/bootstrap/unix-44/Reals.c @@ -89,8 +89,8 @@ void Reals_ConvertL (LONGREAL x, INTEGER n, CHAR *d, LONGINT d__len) } k = 0; if (n > 9) { - i = (LONGINT)__ENTIER(x / (LONGREAL)(LONGREAL)1000000000); - j = (LONGINT)__ENTIER(x - i * (LONGREAL)1000000000); + i = (int)__ENTIER(x / (LONGREAL)(LONGREAL)1000000000); + j = (int)__ENTIER(x - i * (LONGREAL)1000000000); if (j < 0) { j = 0; } @@ -100,9 +100,9 @@ void Reals_ConvertL (LONGREAL x, INTEGER n, CHAR *d, LONGINT d__len) k += 1; } } else { - i = (LONGINT)__ENTIER(x); + i = (int)__ENTIER(x); } - while (k < (LONGINT)n) { + while (k < (int)n) { d[__X(k, d__len)] = (CHAR)(__MOD(i, 10) + 48); i = __DIV(i, 10); k += 1; @@ -134,7 +134,7 @@ static void Reals_BytesToHex (SYSTEM_BYTE *b, LONGINT b__len, SYSTEM_BYTE *d, LO CHAR by; i = 0; l = b__len; - while ((LONGINT)i < l) { + while ((int)i < l) { by = __VAL(CHAR, b[__X(i, b__len)]); d[__X(__ASHL(i, 1), d__len)] = Reals_ToHex(__ASHR((int)by, 4)); d[__X(__ASHL(i, 1) + 1, d__len)] = Reals_ToHex(__MASK((int)by, -16)); diff --git a/bootstrap/unix-44/SYSTEM.h b/bootstrap/unix-44/SYSTEM.h index 7ea8b8de..35ca975e 100644 --- a/bootstrap/unix-44/SYSTEM.h +++ b/bootstrap/unix-44/SYSTEM.h @@ -1,30 +1,40 @@ #ifndef SYSTEM__h #define SYSTEM__h -#ifndef _WIN32 - - // Building for a Unix/Linux based system - - // TODO: Remove these includes - #include // For memcpy ... - #include // For uintptr_t ... - +#if defined(_WIN64) + typedef long long SYSTEM_INT64; + typedef unsigned long long SYSTEM_CARD64; #else - - // Building for Windows platform with either mingw under cygwin, or the MS C compiler - #ifdef _WIN64 - typedef unsigned long long size_t; - typedef unsigned long long uintptr_t; - #else - typedef unsigned int size_t; - typedef unsigned int uintptr_t; - #endif /* _WIN64 */ - - typedef unsigned int uint32_t; - void * __cdecl memcpy(void * dest, const void * source, size_t size); - + typedef long SYSTEM_INT64; + typedef unsigned long SYSTEM_CARD64; #endif +typedef int SYSTEM_INT32; +typedef unsigned int SYSTEM_CARD32; +typedef short int SYSTEM_INT16; +typedef unsigned short int SYSTEM_CARD16; +typedef signed char SYSTEM_INT8; +typedef unsigned char SYSTEM_CARD8; + +#if (__SIZEOF_POINTER__ == 8) + #if defined(_WIN64) + typedef unsigned long long SYSTEM_PTRINT; + typedef unsigned long long uintptr_t; + typedef unsigned long long size_t; + #else + typedef unsigned long SYSTEM_PTRINT; + typedef unsigned long uintptr_t; + typedef unsigned long size_t; + #endif +#else + typedef unsigned int SYSTEM_PTRINT; + typedef unsigned int uintptr_t; + typedef unsigned int size_t; +#endif + +void * __cdecl memcpy(void *dest, const void *source, size_t size); + + // The compiler uses 'import' and 'export' which translate to 'extern' and // nothing respectively. diff --git a/bootstrap/unix-44/Strings.c b/bootstrap/unix-44/Strings.c index 02755657..51468a69 100644 --- a/bootstrap/unix-44/Strings.c +++ b/bootstrap/unix-44/Strings.c @@ -21,7 +21,7 @@ INTEGER Strings_Length (CHAR *s, LONGINT s__len) INTEGER i; __DUP(s, s__len, CHAR); i = 0; - while (((LONGINT)i < s__len && s[__X(i, s__len)] != 0x00)) { + while (((int)i < s__len && s[__X(i, s__len)] != 0x00)) { i += 1; } _o_result = i; @@ -36,11 +36,11 @@ void Strings_Append (CHAR *extra, LONGINT extra__len, CHAR *dest, LONGINT dest__ n1 = Strings_Length(dest, dest__len); n2 = Strings_Length(extra, extra__len); i = 0; - while ((i < n2 && (LONGINT)(i + n1) < dest__len)) { + while ((i < n2 && (int)(i + n1) < dest__len)) { dest[__X(i + n1, dest__len)] = extra[__X(i, extra__len)]; i += 1; } - if ((LONGINT)(i + n1) < dest__len) { + if ((int)(i + n1) < dest__len) { dest[__X(i + n1, dest__len)] = 0x00; } __DEL(extra); @@ -59,10 +59,10 @@ void Strings_Insert (CHAR *source, LONGINT source__len, INTEGER pos, CHAR *dest, Strings_Append(dest, dest__len, (void*)source, source__len); return; } - if ((LONGINT)(pos + n2) < dest__len) { + if ((int)(pos + n2) < dest__len) { i = n1; while (i >= pos) { - if ((LONGINT)(i + n2) < dest__len) { + if ((int)(i + n2) < dest__len) { dest[__X(i + n2, dest__len)] = dest[__X(i, dest__len)]; } i -= 1; @@ -91,7 +91,7 @@ void Strings_Delete (CHAR *s, LONGINT s__len, INTEGER pos, INTEGER n) s[__X(i - n, s__len)] = s[__X(i, s__len)]; i += 1; } - if ((LONGINT)(i - n) < s__len) { + if ((int)(i - n) < s__len) { s[__X(i - n, s__len)] = 0x00; } } else { @@ -121,7 +121,7 @@ void Strings_Extract (CHAR *source, LONGINT source__len, INTEGER pos, INTEGER n, return; } i = 0; - while (((((LONGINT)(pos + i) <= source__len && source[__X(pos + i, source__len)] != 0x00)) && i < n)) { + while (((((int)(pos + i) <= source__len && source[__X(pos + i, source__len)] != 0x00)) && i < n)) { if (i < destLen) { dest[__X(i, dest__len)] = source[__X(pos + i, source__len)]; } diff --git a/bootstrap/unix-44/Texts.c b/bootstrap/unix-44/Texts.c index 5dc7c946..24941032 100644 --- a/bootstrap/unix-44/Texts.c +++ b/bootstrap/unix-44/Texts.c @@ -839,7 +839,7 @@ void Texts_Scan (Texts_Scanner *S, LONGINT *S__typ) k -= 16; } while (j < i) { - k = __ASHL(k, 4) + (LONGINT)((int)d[__X(j, ((LONGINT)(32)))] - 48); + k = __ASHL(k, 4) + (int)((int)d[__X(j, ((LONGINT)(32)))] - 48); j += 1; } if (neg) { @@ -929,7 +929,7 @@ void Texts_Scan (Texts_Scanner *S, LONGINT *S__typ) (*S).class = 3; k = 0; do { - k = k * 10 + (LONGINT)((int)d[__X(j, ((LONGINT)(32)))] - 48); + k = k * 10 + (int)((int)d[__X(j, ((LONGINT)(32)))] - 48); j += 1; } while (!(j == i)); if (neg) { @@ -1067,7 +1067,7 @@ void Texts_WriteInt (Texts_Writer *W, LONGINT *W__typ, LONGINT x, LONGINT n) x0 = __DIV(x0, 10); i += 1; } while (!(x0 == 0)); - while (n > (LONGINT)i) { + while (n > (int)i) { Texts_Write(&*W, W__typ, ' '); n -= 1; } @@ -1319,7 +1319,7 @@ void Texts_WriteLongReal (Texts_Writer *W, LONGINT *W__typ, LONGREAL x, INTEGER } else { Texts_Write(&*W, W__typ, ' '); } - e = (int)__ASHR((LONGINT)(e - 1023) * 77, 8); + e = (int)__ASHR((int)(e - 1023) * 77, 8); if (e >= 0) { x = x / (LONGREAL)Reals_TenL(e); } else { diff --git a/bootstrap/unix-48/Files.c b/bootstrap/unix-48/Files.c index f03aafe1..e83999fd 100644 --- a/bootstrap/unix-48/Files.c +++ b/bootstrap/unix-48/Files.c @@ -858,7 +858,7 @@ void Files_ReadLInt (Files_Rider *R, LONGINT *R__typ, LONGINT *x) { CHAR b[4]; Files_ReadBytes(&*R, R__typ, (void*)b, ((LONGINT)(4)), ((LONGINT)(4))); - *x = ((LONGINT)((int)b[0] + __ASHL((int)b[1], 8)) + __ASHL((LONGINT)b[2], 16)) + __ASHL((LONGINT)b[3], 24); + *x = ((int)((int)b[0] + __ASHL((int)b[1], 8)) + __ASHL((int)b[2], 16)) + __ASHL((int)b[3], 24); } void Files_ReadSet (Files_Rider *R, LONGINT *R__typ, SET *x) @@ -866,7 +866,7 @@ void Files_ReadSet (Files_Rider *R, LONGINT *R__typ, SET *x) CHAR b[4]; LONGINT l; Files_ReadBytes(&*R, R__typ, (void*)b, ((LONGINT)(4)), ((LONGINT)(4))); - l = ((LONGINT)((int)b[0] + __ASHL((int)b[1], 8)) + __ASHL((LONGINT)b[2], 16)) + __ASHL((LONGINT)b[3], 24); + l = ((int)((int)b[0] + __ASHL((int)b[1], 8)) + __ASHL((int)b[2], 16)) + __ASHL((int)b[3], 24); *x = (SET)l; } @@ -923,11 +923,11 @@ void Files_ReadNum (Files_Rider *R, LONGINT *R__typ, LONGINT *x) n = 0; Files_Read(&*R, R__typ, (void*)&ch); while ((int)ch >= 128) { - n += __ASH((LONGINT)((int)ch - 128), s); + n += __ASH((int)((int)ch - 128), s); s += 7; Files_Read(&*R, R__typ, (void*)&ch); } - n += __ASH((LONGINT)(__MASK((int)ch, -64) - __ASHL(__ASHR((int)ch, 6), 6)), s); + n += __ASH((int)(__MASK((int)ch, -64) - __ASHL(__ASHR((int)ch, 6), 6)), s); *x = n; } diff --git a/bootstrap/unix-48/OPB.c b/bootstrap/unix-48/OPB.c index d16ae3b0..be093f93 100644 --- a/bootstrap/unix-48/OPB.c +++ b/bootstrap/unix-48/OPB.c @@ -242,7 +242,7 @@ static INTEGER OPB_SignedByteSize (LONGINT n) static LONGINT OPB_ShorterSize (LONGINT i) { LONGINT _o_result; - if (i >= (LONGINT)OPM_LIntSize) { + if (i >= (int)OPM_LIntSize) { _o_result = OPM_IntSize; return _o_result; } else { @@ -255,7 +255,7 @@ static LONGINT OPB_ShorterSize (LONGINT i) static LONGINT OPB_LongerSize (LONGINT i) { LONGINT _o_result; - if (i <= (LONGINT)OPM_SIntSize) { + if (i <= (int)OPM_SIntSize) { _o_result = OPM_IntSize; return _o_result; } else { @@ -520,7 +520,7 @@ void OPB_In (OPT_Node *x, OPT_Node y) } else if ((__IN(f, 0x70) && y->typ->form == 9)) { if ((*x)->class == 7) { k = (*x)->conval->intval; - if (k < 0 || k > (LONGINT)OPM_MaxSet) { + if (k < 0 || k > (int)OPM_MaxSet) { OPB_err(202); } else if (y->class == 7) { (*x)->conval->intval = OPB_BoolToInt(__IN(k, y->conval->setval)); @@ -1201,7 +1201,7 @@ static void OPB_Convert (OPT_Node *x, OPT_Struct typ) OPB_err(203); r = (LONGREAL)1; } - (*x)->conval->intval = (LONGINT)__ENTIER(r); + (*x)->conval->intval = (int)__ENTIER(r); OPB_SetIntType(*x); } } @@ -1553,13 +1553,13 @@ void OPB_SetRange (OPT_Node *x, OPT_Node y) } else if ((__IN((*x)->typ->form, 0x70) && __IN(y->typ->form, 0x70))) { if ((*x)->class == 7) { k = (*x)->conval->intval; - if (0 > k || k > (LONGINT)OPM_MaxSet) { + if (0 > k || k > (int)OPM_MaxSet) { OPB_err(202); } } if (y->class == 7) { l = y->conval->intval; - if (0 > l || l > (LONGINT)OPM_MaxSet) { + if (0 > l || l > (int)OPM_MaxSet) { OPB_err(202); } } @@ -1589,7 +1589,7 @@ void OPB_SetElem (OPT_Node *x) OPB_err(93); } else if ((*x)->class == 7) { k = (*x)->conval->intval; - if ((0 <= k && k <= (LONGINT)OPM_MaxSet)) { + if ((0 <= k && k <= (int)OPM_MaxSet)) { (*x)->conval->setval = __SETOF(k); } else { OPB_err(202); @@ -1894,7 +1894,7 @@ void OPB_StPar0 (OPT_Node *par0, INTEGER fctno) case 10: if (x->class == 8 || x->class == 9) { OPB_err(126); - } else if ((__IN(f, 0x70) && x->typ->size > (LONGINT)OPM_SIntSize)) { + } else if ((__IN(f, 0x70) && x->typ->size > (int)OPM_SIntSize)) { OPB_Convert(&x, OPB_IntType(OPB_ShorterSize(x->typ->size))); } else if (f == 8) { OPB_Convert(&x, OPT_realtyp); @@ -1905,7 +1905,7 @@ void OPB_StPar0 (OPT_Node *par0, INTEGER fctno) case 11: if (x->class == 8 || x->class == 9) { OPB_err(126); - } else if ((__IN(f, 0x70) && x->typ->size < (LONGINT)OPM_LIntSize)) { + } else if ((__IN(f, 0x70) && x->typ->size < (int)OPM_LIntSize)) { OPB_Convert(&x, OPB_IntType(OPB_LongerSize(x->typ->size))); } else if (f == 7) { OPB_Convert(&x, OPT_lrltyp); @@ -1954,7 +1954,7 @@ void OPB_StPar0 (OPT_Node *par0, INTEGER fctno) if (x->class == 8 || x->class == 9) { OPB_err(126); } else if (__IN(f, 0x70)) { - if (x->typ->size != (LONGINT)OPM_LIntSize) { + if (x->typ->size != (int)OPM_LIntSize) { OPB_Convert(&x, OPT_linttyp); } } else { @@ -1994,7 +1994,7 @@ void OPB_StPar0 (OPT_Node *par0, INTEGER fctno) OPB_err(126); } else if ((((x->class == 7 && __IN(f, 0x70))) && x->typ->size < OPT_linttyp->size)) { OPB_Convert(&x, OPT_linttyp); - } else if (!((__IN(x->typ->form, 0x2070) && x->typ->size == (LONGINT)OPM_PointerSize))) { + } else if (!((__IN(x->typ->form, 0x2070) && x->typ->size == (int)OPM_PointerSize))) { OPB_err(111); x->typ = OPT_linttyp; } @@ -2092,7 +2092,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno) if (x->class == 8 || x->class == 9) { OPB_err(126); } else if (__IN(f, 0x70)) { - if ((x->class == 7 && (0 > x->conval->intval || x->conval->intval > (LONGINT)OPM_MaxSet))) { + if ((x->class == 7 && (0 > x->conval->intval || x->conval->intval > (int)OPM_MaxSet))) { OPB_err(202); } p = NewOp__57(19, fctno, p, x); @@ -2263,7 +2263,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno) OPB_err(126); } else if ((((x->class == 7 && __IN(f, 0x70))) && x->typ->size < OPT_linttyp->size)) { OPB_Convert(&x, OPT_linttyp); - } else if (!((__IN(x->typ->form, 0x2070) && x->typ->size == (LONGINT)OPM_PointerSize))) { + } else if (!((__IN(x->typ->form, 0x2070) && x->typ->size == (int)OPM_PointerSize))) { OPB_err(111); x->typ = OPT_linttyp; } diff --git a/bootstrap/unix-48/OPC.c b/bootstrap/unix-48/OPC.c index b2b9c32a..617bf8e8 100644 --- a/bootstrap/unix-48/OPC.c +++ b/bootstrap/unix-48/OPC.c @@ -318,7 +318,7 @@ void OPC_Andent (OPT_Struct typ) static BOOLEAN OPC_Undefined (OPT_Object obj) { BOOLEAN _o_result; - _o_result = obj->name[0] == 0x00 || (((obj->mnolev >= 0 && obj->linkadr != (LONGINT)(3 + OPM_currFile))) && obj->linkadr != 2); + _o_result = obj->name[0] == 0x00 || (((obj->mnolev >= 0 && obj->linkadr != (int)(3 + OPM_currFile))) && obj->linkadr != 2); return _o_result; } @@ -826,7 +826,7 @@ void OPC_TDescDecl (OPT_Struct typ) OPC_Str1((CHAR*)", #), {", (LONGINT)8, typ->size); nofptrs = 0; OPC_PutPtrOffsets(typ, ((LONGINT)(0)), &nofptrs); - OPC_Str1((CHAR*)"#}}", (LONGINT)4, -((nofptrs + 1) * (LONGINT)OPM_LIntSize)); + OPC_Str1((CHAR*)"#}}", (LONGINT)4, -((nofptrs + 1) * (int)OPM_LIntSize)); OPC_EndStat(); } @@ -872,7 +872,7 @@ LONGINT OPC_SizeAlignment (LONGINT size) { LONGINT _o_result; LONGINT alignment; - if (size < (LONGINT)OPM_Alignment) { + if (size < (int)OPM_Alignment) { alignment = 1; while (alignment < size) { alignment = __ASHL(alignment, 1); @@ -909,11 +909,11 @@ static void OPC_FillGap (LONGINT gap, LONGINT off, LONGINT align, LONGINT *n, LO if ((*curAlign < align && gap - (adr - off) >= align)) { gap -= (adr - off) + align; OPC_BegStat(); - if (align == (LONGINT)OPM_IntSize) { + if (align == (int)OPM_IntSize) { OPM_WriteString((CHAR*)"INTEGER", (LONGINT)8); - } else if (align == (LONGINT)OPM_LIntSize) { + } else if (align == (int)OPM_LIntSize) { OPM_WriteString((CHAR*)"LONGINT", (LONGINT)8); - } else if (align == (LONGINT)OPM_LRealSize) { + } else if (align == (int)OPM_LRealSize) { OPM_WriteString((CHAR*)"LONGREAL", (LONGINT)9); } OPC_Str1((CHAR*)" _prvt#", (LONGINT)8, *n); @@ -978,7 +978,7 @@ static void OPC_FieldList (OPT_Struct typ, BOOLEAN last, LONGINT *off, LONGINT * } } if (last) { - adr = typ->size - (LONGINT)__ASHR(typ->sysflag, 8); + adr = typ->size - (int)__ASHR(typ->sysflag, 8); if (adr == 0) { gap = 1; } else { diff --git a/bootstrap/unix-48/OPM.c b/bootstrap/unix-48/OPM.c index dc580662..db989d91 100644 --- a/bootstrap/unix-48/OPM.c +++ b/bootstrap/unix-48/OPM.c @@ -872,13 +872,13 @@ void OPM_WriteReal (LONGREAL r, CHAR suffx) CHAR s[32]; CHAR ch; INTEGER i; - if ((((r < OPM_SignedMaximum(OPM_LIntSize) && r > OPM_SignedMinimum(OPM_LIntSize))) && r == ((LONGINT)__ENTIER(r)))) { + if ((((r < OPM_SignedMaximum(OPM_LIntSize) && r > OPM_SignedMinimum(OPM_LIntSize))) && r == ((int)__ENTIER(r)))) { if (suffx == 'f') { OPM_WriteString((CHAR*)"(REAL)", (LONGINT)7); } else { OPM_WriteString((CHAR*)"(LONGREAL)", (LONGINT)11); } - OPM_WriteInt((LONGINT)__ENTIER(r)); + OPM_WriteInt((int)__ENTIER(r)); } else { Texts_OpenWriter(&W, Texts_Writer__typ); if (suffx == 'f') { diff --git a/bootstrap/unix-48/OPS.c b/bootstrap/unix-48/OPS.c index 3f1f738f..474724c8 100644 --- a/bootstrap/unix-48/OPS.c +++ b/bootstrap/unix-48/OPS.c @@ -173,7 +173,7 @@ static void OPS_Number (void) OPS_numtyp = 1; if (n <= 2) { while (i < n) { - OPS_intval = __ASHL(OPS_intval, 4) + (LONGINT)Ord__7(dig[i], 1); + OPS_intval = __ASHL(OPS_intval, 4) + (int)Ord__7(dig[i], 1); i += 1; } } else { @@ -188,7 +188,7 @@ static void OPS_Number (void) OPS_intval = -1; } while (i < n) { - OPS_intval = __ASHL(OPS_intval, 4) + (LONGINT)Ord__7(dig[i], 1); + OPS_intval = __ASHL(OPS_intval, 4) + (int)Ord__7(dig[i], 1); i += 1; } } else { @@ -199,8 +199,8 @@ static void OPS_Number (void) while (i < n) { d = Ord__7(dig[i], 0); i += 1; - if (OPS_intval <= __DIV(2147483647 - (LONGINT)d, 10)) { - OPS_intval = OPS_intval * 10 + (LONGINT)d; + if (OPS_intval <= __DIV(2147483647 - (int)d, 10)) { + OPS_intval = OPS_intval * 10 + (int)d; } else { OPS_err(203); } diff --git a/bootstrap/unix-48/OPV.c b/bootstrap/unix-48/OPV.c index 0545e468..85aca692 100644 --- a/bootstrap/unix-48/OPV.c +++ b/bootstrap/unix-48/OPV.c @@ -86,7 +86,7 @@ void OPV_TypSize (OPT_Struct typ) base = OPC_SizeAlignment(OPM_RecSize); } else { OPV_TypSize(btyp); - offset = btyp->size - (LONGINT)__ASHR(btyp->sysflag, 8); + offset = btyp->size - (int)__ASHR(btyp->sysflag, 8); base = btyp->align; } fld = typ->link; @@ -468,12 +468,10 @@ static void OPV_Entier (OPT_Node n, INTEGER prec) static void OPV_SizeCast (LONGINT size) { - if (size <= (LONGINT)OPM_SIntSize) { - OPM_WriteString((CHAR*)"(int)", (LONGINT)6); - } else if (size <= (LONGINT)OPM_IntSize) { + if (size <= 4) { OPM_WriteString((CHAR*)"(int)", (LONGINT)6); } else { - OPM_WriteString((CHAR*)"(LONGINT)", (LONGINT)10); + OPM_WriteString((CHAR*)"(SYSTEM_INT64)", (LONGINT)15); } } @@ -650,7 +648,7 @@ static void OPV_design (OPT_Node n, INTEGER prec) } if (n->typ->comp == 3) { OPM_Write(')'); - while ((LONGINT)i < __ASHR(d->typ->size - 4, 2)) { + while ((int)i < __ASHR(d->typ->size - 4, 2)) { OPM_WriteString((CHAR*)" * ", (LONGINT)4); OPV_Len(d, i); i += 1; diff --git a/bootstrap/unix-48/Reals.c b/bootstrap/unix-48/Reals.c index 4e478345..43583aa9 100644 --- a/bootstrap/unix-48/Reals.c +++ b/bootstrap/unix-48/Reals.c @@ -89,8 +89,8 @@ void Reals_ConvertL (LONGREAL x, INTEGER n, CHAR *d, LONGINT d__len) } k = 0; if (n > 9) { - i = (LONGINT)__ENTIER(x / (LONGREAL)(LONGREAL)1000000000); - j = (LONGINT)__ENTIER(x - i * (LONGREAL)1000000000); + i = (int)__ENTIER(x / (LONGREAL)(LONGREAL)1000000000); + j = (int)__ENTIER(x - i * (LONGREAL)1000000000); if (j < 0) { j = 0; } @@ -100,9 +100,9 @@ void Reals_ConvertL (LONGREAL x, INTEGER n, CHAR *d, LONGINT d__len) k += 1; } } else { - i = (LONGINT)__ENTIER(x); + i = (int)__ENTIER(x); } - while (k < (LONGINT)n) { + while (k < (int)n) { d[__X(k, d__len)] = (CHAR)(__MOD(i, 10) + 48); i = __DIV(i, 10); k += 1; @@ -134,7 +134,7 @@ static void Reals_BytesToHex (SYSTEM_BYTE *b, LONGINT b__len, SYSTEM_BYTE *d, LO CHAR by; i = 0; l = b__len; - while ((LONGINT)i < l) { + while ((int)i < l) { by = __VAL(CHAR, b[__X(i, b__len)]); d[__X(__ASHL(i, 1), d__len)] = Reals_ToHex(__ASHR((int)by, 4)); d[__X(__ASHL(i, 1) + 1, d__len)] = Reals_ToHex(__MASK((int)by, -16)); diff --git a/bootstrap/unix-48/SYSTEM.h b/bootstrap/unix-48/SYSTEM.h index 7ea8b8de..35ca975e 100644 --- a/bootstrap/unix-48/SYSTEM.h +++ b/bootstrap/unix-48/SYSTEM.h @@ -1,30 +1,40 @@ #ifndef SYSTEM__h #define SYSTEM__h -#ifndef _WIN32 - - // Building for a Unix/Linux based system - - // TODO: Remove these includes - #include // For memcpy ... - #include // For uintptr_t ... - +#if defined(_WIN64) + typedef long long SYSTEM_INT64; + typedef unsigned long long SYSTEM_CARD64; #else - - // Building for Windows platform with either mingw under cygwin, or the MS C compiler - #ifdef _WIN64 - typedef unsigned long long size_t; - typedef unsigned long long uintptr_t; - #else - typedef unsigned int size_t; - typedef unsigned int uintptr_t; - #endif /* _WIN64 */ - - typedef unsigned int uint32_t; - void * __cdecl memcpy(void * dest, const void * source, size_t size); - + typedef long SYSTEM_INT64; + typedef unsigned long SYSTEM_CARD64; #endif +typedef int SYSTEM_INT32; +typedef unsigned int SYSTEM_CARD32; +typedef short int SYSTEM_INT16; +typedef unsigned short int SYSTEM_CARD16; +typedef signed char SYSTEM_INT8; +typedef unsigned char SYSTEM_CARD8; + +#if (__SIZEOF_POINTER__ == 8) + #if defined(_WIN64) + typedef unsigned long long SYSTEM_PTRINT; + typedef unsigned long long uintptr_t; + typedef unsigned long long size_t; + #else + typedef unsigned long SYSTEM_PTRINT; + typedef unsigned long uintptr_t; + typedef unsigned long size_t; + #endif +#else + typedef unsigned int SYSTEM_PTRINT; + typedef unsigned int uintptr_t; + typedef unsigned int size_t; +#endif + +void * __cdecl memcpy(void *dest, const void *source, size_t size); + + // The compiler uses 'import' and 'export' which translate to 'extern' and // nothing respectively. diff --git a/bootstrap/unix-48/Strings.c b/bootstrap/unix-48/Strings.c index 02755657..51468a69 100644 --- a/bootstrap/unix-48/Strings.c +++ b/bootstrap/unix-48/Strings.c @@ -21,7 +21,7 @@ INTEGER Strings_Length (CHAR *s, LONGINT s__len) INTEGER i; __DUP(s, s__len, CHAR); i = 0; - while (((LONGINT)i < s__len && s[__X(i, s__len)] != 0x00)) { + while (((int)i < s__len && s[__X(i, s__len)] != 0x00)) { i += 1; } _o_result = i; @@ -36,11 +36,11 @@ void Strings_Append (CHAR *extra, LONGINT extra__len, CHAR *dest, LONGINT dest__ n1 = Strings_Length(dest, dest__len); n2 = Strings_Length(extra, extra__len); i = 0; - while ((i < n2 && (LONGINT)(i + n1) < dest__len)) { + while ((i < n2 && (int)(i + n1) < dest__len)) { dest[__X(i + n1, dest__len)] = extra[__X(i, extra__len)]; i += 1; } - if ((LONGINT)(i + n1) < dest__len) { + if ((int)(i + n1) < dest__len) { dest[__X(i + n1, dest__len)] = 0x00; } __DEL(extra); @@ -59,10 +59,10 @@ void Strings_Insert (CHAR *source, LONGINT source__len, INTEGER pos, CHAR *dest, Strings_Append(dest, dest__len, (void*)source, source__len); return; } - if ((LONGINT)(pos + n2) < dest__len) { + if ((int)(pos + n2) < dest__len) { i = n1; while (i >= pos) { - if ((LONGINT)(i + n2) < dest__len) { + if ((int)(i + n2) < dest__len) { dest[__X(i + n2, dest__len)] = dest[__X(i, dest__len)]; } i -= 1; @@ -91,7 +91,7 @@ void Strings_Delete (CHAR *s, LONGINT s__len, INTEGER pos, INTEGER n) s[__X(i - n, s__len)] = s[__X(i, s__len)]; i += 1; } - if ((LONGINT)(i - n) < s__len) { + if ((int)(i - n) < s__len) { s[__X(i - n, s__len)] = 0x00; } } else { @@ -121,7 +121,7 @@ void Strings_Extract (CHAR *source, LONGINT source__len, INTEGER pos, INTEGER n, return; } i = 0; - while (((((LONGINT)(pos + i) <= source__len && source[__X(pos + i, source__len)] != 0x00)) && i < n)) { + while (((((int)(pos + i) <= source__len && source[__X(pos + i, source__len)] != 0x00)) && i < n)) { if (i < destLen) { dest[__X(i, dest__len)] = source[__X(pos + i, source__len)]; } diff --git a/bootstrap/unix-48/Texts.c b/bootstrap/unix-48/Texts.c index ad722e53..627370de 100644 --- a/bootstrap/unix-48/Texts.c +++ b/bootstrap/unix-48/Texts.c @@ -839,7 +839,7 @@ void Texts_Scan (Texts_Scanner *S, LONGINT *S__typ) k -= 16; } while (j < i) { - k = __ASHL(k, 4) + (LONGINT)((int)d[__X(j, ((LONGINT)(32)))] - 48); + k = __ASHL(k, 4) + (int)((int)d[__X(j, ((LONGINT)(32)))] - 48); j += 1; } if (neg) { @@ -929,7 +929,7 @@ void Texts_Scan (Texts_Scanner *S, LONGINT *S__typ) (*S).class = 3; k = 0; do { - k = k * 10 + (LONGINT)((int)d[__X(j, ((LONGINT)(32)))] - 48); + k = k * 10 + (int)((int)d[__X(j, ((LONGINT)(32)))] - 48); j += 1; } while (!(j == i)); if (neg) { @@ -1067,7 +1067,7 @@ void Texts_WriteInt (Texts_Writer *W, LONGINT *W__typ, LONGINT x, LONGINT n) x0 = __DIV(x0, 10); i += 1; } while (!(x0 == 0)); - while (n > (LONGINT)i) { + while (n > (int)i) { Texts_Write(&*W, W__typ, ' '); n -= 1; } @@ -1319,7 +1319,7 @@ void Texts_WriteLongReal (Texts_Writer *W, LONGINT *W__typ, LONGREAL x, INTEGER } else { Texts_Write(&*W, W__typ, ' '); } - e = (int)__ASHR((LONGINT)(e - 1023) * 77, 8); + e = (int)__ASHR((int)(e - 1023) * 77, 8); if (e >= 0) { x = x / (LONGREAL)Reals_TenL(e); } else { diff --git a/bootstrap/unix-88/Files.c b/bootstrap/unix-88/Files.c index 5806666c..c6b41705 100644 --- a/bootstrap/unix-88/Files.c +++ b/bootstrap/unix-88/Files.c @@ -924,11 +924,11 @@ void Files_ReadNum (Files_Rider *R, LONGINT *R__typ, LONGINT *x) n = 0; Files_Read(&*R, R__typ, (void*)&ch); while ((int)ch >= 128) { - n += __ASH((LONGINT)((int)ch - 128), s); + n += __ASH((SYSTEM_INT64)((int)ch - 128), s); s += 7; Files_Read(&*R, R__typ, (void*)&ch); } - n += __ASH((LONGINT)(__MASK((int)ch, -64) - __ASHL(__ASHR((int)ch, 6), 6)), s); + n += __ASH((SYSTEM_INT64)(__MASK((int)ch, -64) - __ASHL(__ASHR((int)ch, 6), 6)), s); *x = n; } diff --git a/bootstrap/unix-88/OPB.c b/bootstrap/unix-88/OPB.c index 1fb8ad2b..654fd595 100644 --- a/bootstrap/unix-88/OPB.c +++ b/bootstrap/unix-88/OPB.c @@ -243,7 +243,7 @@ static INTEGER OPB_SignedByteSize (LONGINT n) static LONGINT OPB_ShorterSize (LONGINT i) { LONGINT _o_result; - if (i >= (LONGINT)OPM_LIntSize) { + if (i >= (SYSTEM_INT64)OPM_LIntSize) { _o_result = OPM_IntSize; return _o_result; } else { @@ -256,7 +256,7 @@ static LONGINT OPB_ShorterSize (LONGINT i) static LONGINT OPB_LongerSize (LONGINT i) { LONGINT _o_result; - if (i <= (LONGINT)OPM_SIntSize) { + if (i <= (SYSTEM_INT64)OPM_SIntSize) { _o_result = OPM_IntSize; return _o_result; } else { @@ -521,7 +521,7 @@ void OPB_In (OPT_Node *x, OPT_Node y) } else if ((__IN(f, 0x70) && y->typ->form == 9)) { if ((*x)->class == 7) { k = (*x)->conval->intval; - if (k < 0 || k > (LONGINT)OPM_MaxSet) { + if (k < 0 || k > (SYSTEM_INT64)OPM_MaxSet) { OPB_err(202); } else if (y->class == 7) { (*x)->conval->intval = OPB_BoolToInt(__IN(k, y->conval->setval)); @@ -1554,13 +1554,13 @@ void OPB_SetRange (OPT_Node *x, OPT_Node y) } else if ((__IN((*x)->typ->form, 0x70) && __IN(y->typ->form, 0x70))) { if ((*x)->class == 7) { k = (*x)->conval->intval; - if (0 > k || k > (LONGINT)OPM_MaxSet) { + if (0 > k || k > (SYSTEM_INT64)OPM_MaxSet) { OPB_err(202); } } if (y->class == 7) { l = y->conval->intval; - if (0 > l || l > (LONGINT)OPM_MaxSet) { + if (0 > l || l > (SYSTEM_INT64)OPM_MaxSet) { OPB_err(202); } } @@ -1590,7 +1590,7 @@ void OPB_SetElem (OPT_Node *x) OPB_err(93); } else if ((*x)->class == 7) { k = (*x)->conval->intval; - if ((0 <= k && k <= (LONGINT)OPM_MaxSet)) { + if ((0 <= k && k <= (SYSTEM_INT64)OPM_MaxSet)) { (*x)->conval->setval = __SETOF(k); } else { OPB_err(202); @@ -1895,7 +1895,7 @@ void OPB_StPar0 (OPT_Node *par0, INTEGER fctno) case 10: if (x->class == 8 || x->class == 9) { OPB_err(126); - } else if ((__IN(f, 0x70) && x->typ->size > (LONGINT)OPM_SIntSize)) { + } else if ((__IN(f, 0x70) && x->typ->size > (SYSTEM_INT64)OPM_SIntSize)) { OPB_Convert(&x, OPB_IntType(OPB_ShorterSize(x->typ->size))); } else if (f == 8) { OPB_Convert(&x, OPT_realtyp); @@ -1906,7 +1906,7 @@ void OPB_StPar0 (OPT_Node *par0, INTEGER fctno) case 11: if (x->class == 8 || x->class == 9) { OPB_err(126); - } else if ((__IN(f, 0x70) && x->typ->size < (LONGINT)OPM_LIntSize)) { + } else if ((__IN(f, 0x70) && x->typ->size < (SYSTEM_INT64)OPM_LIntSize)) { OPB_Convert(&x, OPB_IntType(OPB_LongerSize(x->typ->size))); } else if (f == 7) { OPB_Convert(&x, OPT_lrltyp); @@ -1955,7 +1955,7 @@ void OPB_StPar0 (OPT_Node *par0, INTEGER fctno) if (x->class == 8 || x->class == 9) { OPB_err(126); } else if (__IN(f, 0x70)) { - if (x->typ->size != (LONGINT)OPM_LIntSize) { + if (x->typ->size != (SYSTEM_INT64)OPM_LIntSize) { OPB_Convert(&x, OPT_linttyp); } } else { @@ -1995,7 +1995,7 @@ void OPB_StPar0 (OPT_Node *par0, INTEGER fctno) OPB_err(126); } else if ((((x->class == 7 && __IN(f, 0x70))) && x->typ->size < OPT_linttyp->size)) { OPB_Convert(&x, OPT_linttyp); - } else if (!((__IN(x->typ->form, 0x2070) && x->typ->size == (LONGINT)OPM_PointerSize))) { + } else if (!((__IN(x->typ->form, 0x2070) && x->typ->size == (SYSTEM_INT64)OPM_PointerSize))) { OPB_err(111); x->typ = OPT_linttyp; } @@ -2093,7 +2093,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno) if (x->class == 8 || x->class == 9) { OPB_err(126); } else if (__IN(f, 0x70)) { - if ((x->class == 7 && (0 > x->conval->intval || x->conval->intval > (LONGINT)OPM_MaxSet))) { + if ((x->class == 7 && (0 > x->conval->intval || x->conval->intval > (SYSTEM_INT64)OPM_MaxSet))) { OPB_err(202); } p = NewOp__57(19, fctno, p, x); @@ -2264,7 +2264,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno) OPB_err(126); } else if ((((x->class == 7 && __IN(f, 0x70))) && x->typ->size < OPT_linttyp->size)) { OPB_Convert(&x, OPT_linttyp); - } else if (!((__IN(x->typ->form, 0x2070) && x->typ->size == (LONGINT)OPM_PointerSize))) { + } else if (!((__IN(x->typ->form, 0x2070) && x->typ->size == (SYSTEM_INT64)OPM_PointerSize))) { OPB_err(111); x->typ = OPT_linttyp; } diff --git a/bootstrap/unix-88/OPC.c b/bootstrap/unix-88/OPC.c index aac3cac5..f23a7c6f 100644 --- a/bootstrap/unix-88/OPC.c +++ b/bootstrap/unix-88/OPC.c @@ -319,7 +319,7 @@ void OPC_Andent (OPT_Struct typ) static BOOLEAN OPC_Undefined (OPT_Object obj) { BOOLEAN _o_result; - _o_result = obj->name[0] == 0x00 || (((obj->mnolev >= 0 && obj->linkadr != (LONGINT)(3 + OPM_currFile))) && obj->linkadr != 2); + _o_result = obj->name[0] == 0x00 || (((obj->mnolev >= 0 && obj->linkadr != (SYSTEM_INT64)(3 + OPM_currFile))) && obj->linkadr != 2); return _o_result; } @@ -827,7 +827,7 @@ void OPC_TDescDecl (OPT_Struct typ) OPC_Str1((CHAR*)", #), {", (LONGINT)8, typ->size); nofptrs = 0; OPC_PutPtrOffsets(typ, ((LONGINT)(0)), &nofptrs); - OPC_Str1((CHAR*)"#}}", (LONGINT)4, -((nofptrs + 1) * (LONGINT)OPM_LIntSize)); + OPC_Str1((CHAR*)"#}}", (LONGINT)4, -((nofptrs + 1) * (SYSTEM_INT64)OPM_LIntSize)); OPC_EndStat(); } @@ -873,7 +873,7 @@ LONGINT OPC_SizeAlignment (LONGINT size) { LONGINT _o_result; LONGINT alignment; - if (size < (LONGINT)OPM_Alignment) { + if (size < (SYSTEM_INT64)OPM_Alignment) { alignment = 1; while (alignment < size) { alignment = __ASHL(alignment, 1); @@ -910,11 +910,11 @@ static void OPC_FillGap (LONGINT gap, LONGINT off, LONGINT align, LONGINT *n, LO if ((*curAlign < align && gap - (adr - off) >= align)) { gap -= (adr - off) + align; OPC_BegStat(); - if (align == (LONGINT)OPM_IntSize) { + if (align == (SYSTEM_INT64)OPM_IntSize) { OPM_WriteString((CHAR*)"INTEGER", (LONGINT)8); - } else if (align == (LONGINT)OPM_LIntSize) { + } else if (align == (SYSTEM_INT64)OPM_LIntSize) { OPM_WriteString((CHAR*)"LONGINT", (LONGINT)8); - } else if (align == (LONGINT)OPM_LRealSize) { + } else if (align == (SYSTEM_INT64)OPM_LRealSize) { OPM_WriteString((CHAR*)"LONGREAL", (LONGINT)9); } OPC_Str1((CHAR*)" _prvt#", (LONGINT)8, *n); @@ -979,7 +979,7 @@ static void OPC_FieldList (OPT_Struct typ, BOOLEAN last, LONGINT *off, LONGINT * } } if (last) { - adr = typ->size - (LONGINT)__ASHR(typ->sysflag, 8); + adr = typ->size - (SYSTEM_INT64)__ASHR(typ->sysflag, 8); if (adr == 0) { gap = 1; } else { diff --git a/bootstrap/unix-88/OPS.c b/bootstrap/unix-88/OPS.c index 10244289..03b478b2 100644 --- a/bootstrap/unix-88/OPS.c +++ b/bootstrap/unix-88/OPS.c @@ -174,7 +174,7 @@ static void OPS_Number (void) OPS_numtyp = 1; if (n <= 2) { while (i < n) { - OPS_intval = __ASHL(OPS_intval, 4) + (LONGINT)Ord__7(dig[i], 1); + OPS_intval = __ASHL(OPS_intval, 4) + (SYSTEM_INT64)Ord__7(dig[i], 1); i += 1; } } else { @@ -189,7 +189,7 @@ static void OPS_Number (void) OPS_intval = -1; } while (i < n) { - OPS_intval = __ASHL(OPS_intval, 4) + (LONGINT)Ord__7(dig[i], 1); + OPS_intval = __ASHL(OPS_intval, 4) + (SYSTEM_INT64)Ord__7(dig[i], 1); i += 1; } } else { @@ -200,8 +200,8 @@ static void OPS_Number (void) while (i < n) { d = Ord__7(dig[i], 0); i += 1; - if (OPS_intval <= __DIV(9223372036854775807 - (LONGINT)d, 10)) { - OPS_intval = OPS_intval * 10 + (LONGINT)d; + if (OPS_intval <= __DIV(9223372036854775807 - (SYSTEM_INT64)d, 10)) { + OPS_intval = OPS_intval * 10 + (SYSTEM_INT64)d; } else { OPS_err(203); } diff --git a/bootstrap/unix-88/OPV.c b/bootstrap/unix-88/OPV.c index 399d7149..88cb137f 100644 --- a/bootstrap/unix-88/OPV.c +++ b/bootstrap/unix-88/OPV.c @@ -87,7 +87,7 @@ void OPV_TypSize (OPT_Struct typ) base = OPC_SizeAlignment(OPM_RecSize); } else { OPV_TypSize(btyp); - offset = btyp->size - (LONGINT)__ASHR(btyp->sysflag, 8); + offset = btyp->size - (SYSTEM_INT64)__ASHR(btyp->sysflag, 8); base = btyp->align; } fld = typ->link; @@ -469,12 +469,10 @@ static void OPV_Entier (OPT_Node n, INTEGER prec) static void OPV_SizeCast (LONGINT size) { - if (size <= (LONGINT)OPM_SIntSize) { - OPM_WriteString((CHAR*)"(int)", (LONGINT)6); - } else if (size <= (LONGINT)OPM_IntSize) { + if (size <= 4) { OPM_WriteString((CHAR*)"(int)", (LONGINT)6); } else { - OPM_WriteString((CHAR*)"(LONGINT)", (LONGINT)10); + OPM_WriteString((CHAR*)"(SYSTEM_INT64)", (LONGINT)15); } } @@ -651,7 +649,7 @@ static void OPV_design (OPT_Node n, INTEGER prec) } if (n->typ->comp == 3) { OPM_Write(')'); - while ((LONGINT)i < __ASHR(d->typ->size - 4, 2)) { + while ((SYSTEM_INT64)i < __ASHR(d->typ->size - 4, 2)) { OPM_WriteString((CHAR*)" * ", (LONGINT)4); OPV_Len(d, i); i += 1; diff --git a/bootstrap/unix-88/Reals.c b/bootstrap/unix-88/Reals.c index b88dd1e1..5dbc72b6 100644 --- a/bootstrap/unix-88/Reals.c +++ b/bootstrap/unix-88/Reals.c @@ -90,7 +90,7 @@ void Reals_ConvertL (LONGREAL x, INTEGER n, CHAR *d, LONGINT d__len) } k = 0; i = __ENTIER(x); - while (k < (LONGINT)n) { + while (k < (SYSTEM_INT64)n) { d[__X(k, d__len)] = (CHAR)(__MOD(i, 10) + 48); i = __DIV(i, 10); k += 1; @@ -122,7 +122,7 @@ static void Reals_BytesToHex (SYSTEM_BYTE *b, LONGINT b__len, SYSTEM_BYTE *d, LO CHAR by; i = 0; l = b__len; - while ((LONGINT)i < l) { + while ((SYSTEM_INT64)i < l) { by = __VAL(CHAR, b[__X(i, b__len)]); d[__X(__ASHL(i, 1), d__len)] = Reals_ToHex(__ASHR((int)by, 4)); d[__X(__ASHL(i, 1) + 1, d__len)] = Reals_ToHex(__MASK((int)by, -16)); diff --git a/bootstrap/unix-88/SYSTEM.h b/bootstrap/unix-88/SYSTEM.h index 7ea8b8de..35ca975e 100644 --- a/bootstrap/unix-88/SYSTEM.h +++ b/bootstrap/unix-88/SYSTEM.h @@ -1,30 +1,40 @@ #ifndef SYSTEM__h #define SYSTEM__h -#ifndef _WIN32 - - // Building for a Unix/Linux based system - - // TODO: Remove these includes - #include // For memcpy ... - #include // For uintptr_t ... - +#if defined(_WIN64) + typedef long long SYSTEM_INT64; + typedef unsigned long long SYSTEM_CARD64; #else - - // Building for Windows platform with either mingw under cygwin, or the MS C compiler - #ifdef _WIN64 - typedef unsigned long long size_t; - typedef unsigned long long uintptr_t; - #else - typedef unsigned int size_t; - typedef unsigned int uintptr_t; - #endif /* _WIN64 */ - - typedef unsigned int uint32_t; - void * __cdecl memcpy(void * dest, const void * source, size_t size); - + typedef long SYSTEM_INT64; + typedef unsigned long SYSTEM_CARD64; #endif +typedef int SYSTEM_INT32; +typedef unsigned int SYSTEM_CARD32; +typedef short int SYSTEM_INT16; +typedef unsigned short int SYSTEM_CARD16; +typedef signed char SYSTEM_INT8; +typedef unsigned char SYSTEM_CARD8; + +#if (__SIZEOF_POINTER__ == 8) + #if defined(_WIN64) + typedef unsigned long long SYSTEM_PTRINT; + typedef unsigned long long uintptr_t; + typedef unsigned long long size_t; + #else + typedef unsigned long SYSTEM_PTRINT; + typedef unsigned long uintptr_t; + typedef unsigned long size_t; + #endif +#else + typedef unsigned int SYSTEM_PTRINT; + typedef unsigned int uintptr_t; + typedef unsigned int size_t; +#endif + +void * __cdecl memcpy(void *dest, const void *source, size_t size); + + // The compiler uses 'import' and 'export' which translate to 'extern' and // nothing respectively. diff --git a/bootstrap/unix-88/Strings.c b/bootstrap/unix-88/Strings.c index 839b8b93..0932a656 100644 --- a/bootstrap/unix-88/Strings.c +++ b/bootstrap/unix-88/Strings.c @@ -22,7 +22,7 @@ INTEGER Strings_Length (CHAR *s, LONGINT s__len) INTEGER i; __DUP(s, s__len, CHAR); i = 0; - while (((LONGINT)i < s__len && s[__X(i, s__len)] != 0x00)) { + while (((SYSTEM_INT64)i < s__len && s[__X(i, s__len)] != 0x00)) { i += 1; } _o_result = i; @@ -37,11 +37,11 @@ void Strings_Append (CHAR *extra, LONGINT extra__len, CHAR *dest, LONGINT dest__ n1 = Strings_Length(dest, dest__len); n2 = Strings_Length(extra, extra__len); i = 0; - while ((i < n2 && (LONGINT)(i + n1) < dest__len)) { + while ((i < n2 && (SYSTEM_INT64)(i + n1) < dest__len)) { dest[__X(i + n1, dest__len)] = extra[__X(i, extra__len)]; i += 1; } - if ((LONGINT)(i + n1) < dest__len) { + if ((SYSTEM_INT64)(i + n1) < dest__len) { dest[__X(i + n1, dest__len)] = 0x00; } __DEL(extra); @@ -60,10 +60,10 @@ void Strings_Insert (CHAR *source, LONGINT source__len, INTEGER pos, CHAR *dest, Strings_Append(dest, dest__len, (void*)source, source__len); return; } - if ((LONGINT)(pos + n2) < dest__len) { + if ((SYSTEM_INT64)(pos + n2) < dest__len) { i = n1; while (i >= pos) { - if ((LONGINT)(i + n2) < dest__len) { + if ((SYSTEM_INT64)(i + n2) < dest__len) { dest[__X(i + n2, dest__len)] = dest[__X(i, dest__len)]; } i -= 1; @@ -92,7 +92,7 @@ void Strings_Delete (CHAR *s, LONGINT s__len, INTEGER pos, INTEGER n) s[__X(i - n, s__len)] = s[__X(i, s__len)]; i += 1; } - if ((LONGINT)(i - n) < s__len) { + if ((SYSTEM_INT64)(i - n) < s__len) { s[__X(i - n, s__len)] = 0x00; } } else { @@ -122,7 +122,7 @@ void Strings_Extract (CHAR *source, LONGINT source__len, INTEGER pos, INTEGER n, return; } i = 0; - while (((((LONGINT)(pos + i) <= source__len && source[__X(pos + i, source__len)] != 0x00)) && i < n)) { + while (((((SYSTEM_INT64)(pos + i) <= source__len && source[__X(pos + i, source__len)] != 0x00)) && i < n)) { if (i < destLen) { dest[__X(i, dest__len)] = source[__X(pos + i, source__len)]; } diff --git a/bootstrap/unix-88/Texts.c b/bootstrap/unix-88/Texts.c index d958df95..21a4804c 100644 --- a/bootstrap/unix-88/Texts.c +++ b/bootstrap/unix-88/Texts.c @@ -840,7 +840,7 @@ void Texts_Scan (Texts_Scanner *S, LONGINT *S__typ) k -= 16; } while (j < i) { - k = __ASHL(k, 4) + (LONGINT)((int)d[__X(j, ((LONGINT)(32)))] - 48); + k = __ASHL(k, 4) + (SYSTEM_INT64)((int)d[__X(j, ((LONGINT)(32)))] - 48); j += 1; } if (neg) { @@ -930,7 +930,7 @@ void Texts_Scan (Texts_Scanner *S, LONGINT *S__typ) (*S).class = 3; k = 0; do { - k = k * 10 + (LONGINT)((int)d[__X(j, ((LONGINT)(32)))] - 48); + k = k * 10 + (SYSTEM_INT64)((int)d[__X(j, ((LONGINT)(32)))] - 48); j += 1; } while (!(j == i)); if (neg) { @@ -1068,7 +1068,7 @@ void Texts_WriteInt (Texts_Writer *W, LONGINT *W__typ, LONGINT x, LONGINT n) x0 = __DIV(x0, 10); i += 1; } while (!(x0 == 0)); - while (n > (LONGINT)i) { + while (n > (SYSTEM_INT64)i) { Texts_Write(&*W, W__typ, ' '); n -= 1; } @@ -1320,7 +1320,7 @@ void Texts_WriteLongReal (Texts_Writer *W, LONGINT *W__typ, LONGREAL x, INTEGER } else { Texts_Write(&*W, W__typ, ' '); } - e = (int)__ASHR((LONGINT)(e - 1023) * 77, 8); + e = (int)__ASHR((SYSTEM_INT64)(e - 1023) * 77, 8); if (e >= 0) { x = x / (LONGREAL)Reals_TenL(e); } else { diff --git a/bootstrap/windows-48/Files.c b/bootstrap/windows-48/Files.c index 4d299348..f8f34677 100644 --- a/bootstrap/windows-48/Files.c +++ b/bootstrap/windows-48/Files.c @@ -858,7 +858,7 @@ void Files_ReadLInt (Files_Rider *R, LONGINT *R__typ, LONGINT *x) { CHAR b[4]; Files_ReadBytes(&*R, R__typ, (void*)b, ((LONGINT)(4)), ((LONGINT)(4))); - *x = ((LONGINT)((int)b[0] + __ASHL((int)b[1], 8)) + __ASHL((LONGINT)b[2], 16)) + __ASHL((LONGINT)b[3], 24); + *x = ((int)((int)b[0] + __ASHL((int)b[1], 8)) + __ASHL((int)b[2], 16)) + __ASHL((int)b[3], 24); } void Files_ReadSet (Files_Rider *R, LONGINT *R__typ, SET *x) @@ -866,7 +866,7 @@ void Files_ReadSet (Files_Rider *R, LONGINT *R__typ, SET *x) CHAR b[4]; LONGINT l; Files_ReadBytes(&*R, R__typ, (void*)b, ((LONGINT)(4)), ((LONGINT)(4))); - l = ((LONGINT)((int)b[0] + __ASHL((int)b[1], 8)) + __ASHL((LONGINT)b[2], 16)) + __ASHL((LONGINT)b[3], 24); + l = ((int)((int)b[0] + __ASHL((int)b[1], 8)) + __ASHL((int)b[2], 16)) + __ASHL((int)b[3], 24); *x = (SET)l; } @@ -923,11 +923,11 @@ void Files_ReadNum (Files_Rider *R, LONGINT *R__typ, LONGINT *x) n = 0; Files_Read(&*R, R__typ, (void*)&ch); while ((int)ch >= 128) { - n += __ASH((LONGINT)((int)ch - 128), s); + n += __ASH((int)((int)ch - 128), s); s += 7; Files_Read(&*R, R__typ, (void*)&ch); } - n += __ASH((LONGINT)(__MASK((int)ch, -64) - __ASHL(__ASHR((int)ch, 6), 6)), s); + n += __ASH((int)(__MASK((int)ch, -64) - __ASHL(__ASHR((int)ch, 6), 6)), s); *x = n; } diff --git a/bootstrap/windows-48/OPB.c b/bootstrap/windows-48/OPB.c index d16ae3b0..be093f93 100644 --- a/bootstrap/windows-48/OPB.c +++ b/bootstrap/windows-48/OPB.c @@ -242,7 +242,7 @@ static INTEGER OPB_SignedByteSize (LONGINT n) static LONGINT OPB_ShorterSize (LONGINT i) { LONGINT _o_result; - if (i >= (LONGINT)OPM_LIntSize) { + if (i >= (int)OPM_LIntSize) { _o_result = OPM_IntSize; return _o_result; } else { @@ -255,7 +255,7 @@ static LONGINT OPB_ShorterSize (LONGINT i) static LONGINT OPB_LongerSize (LONGINT i) { LONGINT _o_result; - if (i <= (LONGINT)OPM_SIntSize) { + if (i <= (int)OPM_SIntSize) { _o_result = OPM_IntSize; return _o_result; } else { @@ -520,7 +520,7 @@ void OPB_In (OPT_Node *x, OPT_Node y) } else if ((__IN(f, 0x70) && y->typ->form == 9)) { if ((*x)->class == 7) { k = (*x)->conval->intval; - if (k < 0 || k > (LONGINT)OPM_MaxSet) { + if (k < 0 || k > (int)OPM_MaxSet) { OPB_err(202); } else if (y->class == 7) { (*x)->conval->intval = OPB_BoolToInt(__IN(k, y->conval->setval)); @@ -1201,7 +1201,7 @@ static void OPB_Convert (OPT_Node *x, OPT_Struct typ) OPB_err(203); r = (LONGREAL)1; } - (*x)->conval->intval = (LONGINT)__ENTIER(r); + (*x)->conval->intval = (int)__ENTIER(r); OPB_SetIntType(*x); } } @@ -1553,13 +1553,13 @@ void OPB_SetRange (OPT_Node *x, OPT_Node y) } else if ((__IN((*x)->typ->form, 0x70) && __IN(y->typ->form, 0x70))) { if ((*x)->class == 7) { k = (*x)->conval->intval; - if (0 > k || k > (LONGINT)OPM_MaxSet) { + if (0 > k || k > (int)OPM_MaxSet) { OPB_err(202); } } if (y->class == 7) { l = y->conval->intval; - if (0 > l || l > (LONGINT)OPM_MaxSet) { + if (0 > l || l > (int)OPM_MaxSet) { OPB_err(202); } } @@ -1589,7 +1589,7 @@ void OPB_SetElem (OPT_Node *x) OPB_err(93); } else if ((*x)->class == 7) { k = (*x)->conval->intval; - if ((0 <= k && k <= (LONGINT)OPM_MaxSet)) { + if ((0 <= k && k <= (int)OPM_MaxSet)) { (*x)->conval->setval = __SETOF(k); } else { OPB_err(202); @@ -1894,7 +1894,7 @@ void OPB_StPar0 (OPT_Node *par0, INTEGER fctno) case 10: if (x->class == 8 || x->class == 9) { OPB_err(126); - } else if ((__IN(f, 0x70) && x->typ->size > (LONGINT)OPM_SIntSize)) { + } else if ((__IN(f, 0x70) && x->typ->size > (int)OPM_SIntSize)) { OPB_Convert(&x, OPB_IntType(OPB_ShorterSize(x->typ->size))); } else if (f == 8) { OPB_Convert(&x, OPT_realtyp); @@ -1905,7 +1905,7 @@ void OPB_StPar0 (OPT_Node *par0, INTEGER fctno) case 11: if (x->class == 8 || x->class == 9) { OPB_err(126); - } else if ((__IN(f, 0x70) && x->typ->size < (LONGINT)OPM_LIntSize)) { + } else if ((__IN(f, 0x70) && x->typ->size < (int)OPM_LIntSize)) { OPB_Convert(&x, OPB_IntType(OPB_LongerSize(x->typ->size))); } else if (f == 7) { OPB_Convert(&x, OPT_lrltyp); @@ -1954,7 +1954,7 @@ void OPB_StPar0 (OPT_Node *par0, INTEGER fctno) if (x->class == 8 || x->class == 9) { OPB_err(126); } else if (__IN(f, 0x70)) { - if (x->typ->size != (LONGINT)OPM_LIntSize) { + if (x->typ->size != (int)OPM_LIntSize) { OPB_Convert(&x, OPT_linttyp); } } else { @@ -1994,7 +1994,7 @@ void OPB_StPar0 (OPT_Node *par0, INTEGER fctno) OPB_err(126); } else if ((((x->class == 7 && __IN(f, 0x70))) && x->typ->size < OPT_linttyp->size)) { OPB_Convert(&x, OPT_linttyp); - } else if (!((__IN(x->typ->form, 0x2070) && x->typ->size == (LONGINT)OPM_PointerSize))) { + } else if (!((__IN(x->typ->form, 0x2070) && x->typ->size == (int)OPM_PointerSize))) { OPB_err(111); x->typ = OPT_linttyp; } @@ -2092,7 +2092,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno) if (x->class == 8 || x->class == 9) { OPB_err(126); } else if (__IN(f, 0x70)) { - if ((x->class == 7 && (0 > x->conval->intval || x->conval->intval > (LONGINT)OPM_MaxSet))) { + if ((x->class == 7 && (0 > x->conval->intval || x->conval->intval > (int)OPM_MaxSet))) { OPB_err(202); } p = NewOp__57(19, fctno, p, x); @@ -2263,7 +2263,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno) OPB_err(126); } else if ((((x->class == 7 && __IN(f, 0x70))) && x->typ->size < OPT_linttyp->size)) { OPB_Convert(&x, OPT_linttyp); - } else if (!((__IN(x->typ->form, 0x2070) && x->typ->size == (LONGINT)OPM_PointerSize))) { + } else if (!((__IN(x->typ->form, 0x2070) && x->typ->size == (int)OPM_PointerSize))) { OPB_err(111); x->typ = OPT_linttyp; } diff --git a/bootstrap/windows-48/OPC.c b/bootstrap/windows-48/OPC.c index b2b9c32a..617bf8e8 100644 --- a/bootstrap/windows-48/OPC.c +++ b/bootstrap/windows-48/OPC.c @@ -318,7 +318,7 @@ void OPC_Andent (OPT_Struct typ) static BOOLEAN OPC_Undefined (OPT_Object obj) { BOOLEAN _o_result; - _o_result = obj->name[0] == 0x00 || (((obj->mnolev >= 0 && obj->linkadr != (LONGINT)(3 + OPM_currFile))) && obj->linkadr != 2); + _o_result = obj->name[0] == 0x00 || (((obj->mnolev >= 0 && obj->linkadr != (int)(3 + OPM_currFile))) && obj->linkadr != 2); return _o_result; } @@ -826,7 +826,7 @@ void OPC_TDescDecl (OPT_Struct typ) OPC_Str1((CHAR*)", #), {", (LONGINT)8, typ->size); nofptrs = 0; OPC_PutPtrOffsets(typ, ((LONGINT)(0)), &nofptrs); - OPC_Str1((CHAR*)"#}}", (LONGINT)4, -((nofptrs + 1) * (LONGINT)OPM_LIntSize)); + OPC_Str1((CHAR*)"#}}", (LONGINT)4, -((nofptrs + 1) * (int)OPM_LIntSize)); OPC_EndStat(); } @@ -872,7 +872,7 @@ LONGINT OPC_SizeAlignment (LONGINT size) { LONGINT _o_result; LONGINT alignment; - if (size < (LONGINT)OPM_Alignment) { + if (size < (int)OPM_Alignment) { alignment = 1; while (alignment < size) { alignment = __ASHL(alignment, 1); @@ -909,11 +909,11 @@ static void OPC_FillGap (LONGINT gap, LONGINT off, LONGINT align, LONGINT *n, LO if ((*curAlign < align && gap - (adr - off) >= align)) { gap -= (adr - off) + align; OPC_BegStat(); - if (align == (LONGINT)OPM_IntSize) { + if (align == (int)OPM_IntSize) { OPM_WriteString((CHAR*)"INTEGER", (LONGINT)8); - } else if (align == (LONGINT)OPM_LIntSize) { + } else if (align == (int)OPM_LIntSize) { OPM_WriteString((CHAR*)"LONGINT", (LONGINT)8); - } else if (align == (LONGINT)OPM_LRealSize) { + } else if (align == (int)OPM_LRealSize) { OPM_WriteString((CHAR*)"LONGREAL", (LONGINT)9); } OPC_Str1((CHAR*)" _prvt#", (LONGINT)8, *n); @@ -978,7 +978,7 @@ static void OPC_FieldList (OPT_Struct typ, BOOLEAN last, LONGINT *off, LONGINT * } } if (last) { - adr = typ->size - (LONGINT)__ASHR(typ->sysflag, 8); + adr = typ->size - (int)__ASHR(typ->sysflag, 8); if (adr == 0) { gap = 1; } else { diff --git a/bootstrap/windows-48/OPM.c b/bootstrap/windows-48/OPM.c index dc580662..db989d91 100644 --- a/bootstrap/windows-48/OPM.c +++ b/bootstrap/windows-48/OPM.c @@ -872,13 +872,13 @@ void OPM_WriteReal (LONGREAL r, CHAR suffx) CHAR s[32]; CHAR ch; INTEGER i; - if ((((r < OPM_SignedMaximum(OPM_LIntSize) && r > OPM_SignedMinimum(OPM_LIntSize))) && r == ((LONGINT)__ENTIER(r)))) { + if ((((r < OPM_SignedMaximum(OPM_LIntSize) && r > OPM_SignedMinimum(OPM_LIntSize))) && r == ((int)__ENTIER(r)))) { if (suffx == 'f') { OPM_WriteString((CHAR*)"(REAL)", (LONGINT)7); } else { OPM_WriteString((CHAR*)"(LONGREAL)", (LONGINT)11); } - OPM_WriteInt((LONGINT)__ENTIER(r)); + OPM_WriteInt((int)__ENTIER(r)); } else { Texts_OpenWriter(&W, Texts_Writer__typ); if (suffx == 'f') { diff --git a/bootstrap/windows-48/OPS.c b/bootstrap/windows-48/OPS.c index 3f1f738f..474724c8 100644 --- a/bootstrap/windows-48/OPS.c +++ b/bootstrap/windows-48/OPS.c @@ -173,7 +173,7 @@ static void OPS_Number (void) OPS_numtyp = 1; if (n <= 2) { while (i < n) { - OPS_intval = __ASHL(OPS_intval, 4) + (LONGINT)Ord__7(dig[i], 1); + OPS_intval = __ASHL(OPS_intval, 4) + (int)Ord__7(dig[i], 1); i += 1; } } else { @@ -188,7 +188,7 @@ static void OPS_Number (void) OPS_intval = -1; } while (i < n) { - OPS_intval = __ASHL(OPS_intval, 4) + (LONGINT)Ord__7(dig[i], 1); + OPS_intval = __ASHL(OPS_intval, 4) + (int)Ord__7(dig[i], 1); i += 1; } } else { @@ -199,8 +199,8 @@ static void OPS_Number (void) while (i < n) { d = Ord__7(dig[i], 0); i += 1; - if (OPS_intval <= __DIV(2147483647 - (LONGINT)d, 10)) { - OPS_intval = OPS_intval * 10 + (LONGINT)d; + if (OPS_intval <= __DIV(2147483647 - (int)d, 10)) { + OPS_intval = OPS_intval * 10 + (int)d; } else { OPS_err(203); } diff --git a/bootstrap/windows-48/OPV.c b/bootstrap/windows-48/OPV.c index 0545e468..85aca692 100644 --- a/bootstrap/windows-48/OPV.c +++ b/bootstrap/windows-48/OPV.c @@ -86,7 +86,7 @@ void OPV_TypSize (OPT_Struct typ) base = OPC_SizeAlignment(OPM_RecSize); } else { OPV_TypSize(btyp); - offset = btyp->size - (LONGINT)__ASHR(btyp->sysflag, 8); + offset = btyp->size - (int)__ASHR(btyp->sysflag, 8); base = btyp->align; } fld = typ->link; @@ -468,12 +468,10 @@ static void OPV_Entier (OPT_Node n, INTEGER prec) static void OPV_SizeCast (LONGINT size) { - if (size <= (LONGINT)OPM_SIntSize) { - OPM_WriteString((CHAR*)"(int)", (LONGINT)6); - } else if (size <= (LONGINT)OPM_IntSize) { + if (size <= 4) { OPM_WriteString((CHAR*)"(int)", (LONGINT)6); } else { - OPM_WriteString((CHAR*)"(LONGINT)", (LONGINT)10); + OPM_WriteString((CHAR*)"(SYSTEM_INT64)", (LONGINT)15); } } @@ -650,7 +648,7 @@ static void OPV_design (OPT_Node n, INTEGER prec) } if (n->typ->comp == 3) { OPM_Write(')'); - while ((LONGINT)i < __ASHR(d->typ->size - 4, 2)) { + while ((int)i < __ASHR(d->typ->size - 4, 2)) { OPM_WriteString((CHAR*)" * ", (LONGINT)4); OPV_Len(d, i); i += 1; diff --git a/bootstrap/windows-48/Platform.c b/bootstrap/windows-48/Platform.c index 21a2c472..bc7ebab6 100644 --- a/bootstrap/windows-48/Platform.c +++ b/bootstrap/windows-48/Platform.c @@ -334,8 +334,8 @@ void Platform_SetBadInstructionHandler (Platform_SignalHandler handler) static void Platform_YMDHMStoClock (INTEGER ye, INTEGER mo, INTEGER da, INTEGER ho, INTEGER mi, INTEGER se, LONGINT *t, LONGINT *d) { - *d = (__ASHL((LONGINT)(int)__MOD(ye, 100), 9) + __ASHL((LONGINT)(mo + 1), 5)) + (LONGINT)da; - *t = (__ASHL((LONGINT)ho, 12) + __ASHL((LONGINT)mi, 6)) + (LONGINT)se; + *d = (__ASHL((int)(int)__MOD(ye, 100), 9) + __ASHL((int)(mo + 1), 5)) + (int)da; + *t = (__ASHL((int)ho, 12) + __ASHL((int)mi, 6)) + (int)se; } void Platform_GetClock (LONGINT *t, LONGINT *d) diff --git a/bootstrap/windows-48/Reals.c b/bootstrap/windows-48/Reals.c index 4e478345..43583aa9 100644 --- a/bootstrap/windows-48/Reals.c +++ b/bootstrap/windows-48/Reals.c @@ -89,8 +89,8 @@ void Reals_ConvertL (LONGREAL x, INTEGER n, CHAR *d, LONGINT d__len) } k = 0; if (n > 9) { - i = (LONGINT)__ENTIER(x / (LONGREAL)(LONGREAL)1000000000); - j = (LONGINT)__ENTIER(x - i * (LONGREAL)1000000000); + i = (int)__ENTIER(x / (LONGREAL)(LONGREAL)1000000000); + j = (int)__ENTIER(x - i * (LONGREAL)1000000000); if (j < 0) { j = 0; } @@ -100,9 +100,9 @@ void Reals_ConvertL (LONGREAL x, INTEGER n, CHAR *d, LONGINT d__len) k += 1; } } else { - i = (LONGINT)__ENTIER(x); + i = (int)__ENTIER(x); } - while (k < (LONGINT)n) { + while (k < (int)n) { d[__X(k, d__len)] = (CHAR)(__MOD(i, 10) + 48); i = __DIV(i, 10); k += 1; @@ -134,7 +134,7 @@ static void Reals_BytesToHex (SYSTEM_BYTE *b, LONGINT b__len, SYSTEM_BYTE *d, LO CHAR by; i = 0; l = b__len; - while ((LONGINT)i < l) { + while ((int)i < l) { by = __VAL(CHAR, b[__X(i, b__len)]); d[__X(__ASHL(i, 1), d__len)] = Reals_ToHex(__ASHR((int)by, 4)); d[__X(__ASHL(i, 1) + 1, d__len)] = Reals_ToHex(__MASK((int)by, -16)); diff --git a/bootstrap/windows-48/SYSTEM.h b/bootstrap/windows-48/SYSTEM.h index 7ea8b8de..35ca975e 100644 --- a/bootstrap/windows-48/SYSTEM.h +++ b/bootstrap/windows-48/SYSTEM.h @@ -1,30 +1,40 @@ #ifndef SYSTEM__h #define SYSTEM__h -#ifndef _WIN32 - - // Building for a Unix/Linux based system - - // TODO: Remove these includes - #include // For memcpy ... - #include // For uintptr_t ... - +#if defined(_WIN64) + typedef long long SYSTEM_INT64; + typedef unsigned long long SYSTEM_CARD64; #else - - // Building for Windows platform with either mingw under cygwin, or the MS C compiler - #ifdef _WIN64 - typedef unsigned long long size_t; - typedef unsigned long long uintptr_t; - #else - typedef unsigned int size_t; - typedef unsigned int uintptr_t; - #endif /* _WIN64 */ - - typedef unsigned int uint32_t; - void * __cdecl memcpy(void * dest, const void * source, size_t size); - + typedef long SYSTEM_INT64; + typedef unsigned long SYSTEM_CARD64; #endif +typedef int SYSTEM_INT32; +typedef unsigned int SYSTEM_CARD32; +typedef short int SYSTEM_INT16; +typedef unsigned short int SYSTEM_CARD16; +typedef signed char SYSTEM_INT8; +typedef unsigned char SYSTEM_CARD8; + +#if (__SIZEOF_POINTER__ == 8) + #if defined(_WIN64) + typedef unsigned long long SYSTEM_PTRINT; + typedef unsigned long long uintptr_t; + typedef unsigned long long size_t; + #else + typedef unsigned long SYSTEM_PTRINT; + typedef unsigned long uintptr_t; + typedef unsigned long size_t; + #endif +#else + typedef unsigned int SYSTEM_PTRINT; + typedef unsigned int uintptr_t; + typedef unsigned int size_t; +#endif + +void * __cdecl memcpy(void *dest, const void *source, size_t size); + + // The compiler uses 'import' and 'export' which translate to 'extern' and // nothing respectively. diff --git a/bootstrap/windows-48/Strings.c b/bootstrap/windows-48/Strings.c index 02755657..51468a69 100644 --- a/bootstrap/windows-48/Strings.c +++ b/bootstrap/windows-48/Strings.c @@ -21,7 +21,7 @@ INTEGER Strings_Length (CHAR *s, LONGINT s__len) INTEGER i; __DUP(s, s__len, CHAR); i = 0; - while (((LONGINT)i < s__len && s[__X(i, s__len)] != 0x00)) { + while (((int)i < s__len && s[__X(i, s__len)] != 0x00)) { i += 1; } _o_result = i; @@ -36,11 +36,11 @@ void Strings_Append (CHAR *extra, LONGINT extra__len, CHAR *dest, LONGINT dest__ n1 = Strings_Length(dest, dest__len); n2 = Strings_Length(extra, extra__len); i = 0; - while ((i < n2 && (LONGINT)(i + n1) < dest__len)) { + while ((i < n2 && (int)(i + n1) < dest__len)) { dest[__X(i + n1, dest__len)] = extra[__X(i, extra__len)]; i += 1; } - if ((LONGINT)(i + n1) < dest__len) { + if ((int)(i + n1) < dest__len) { dest[__X(i + n1, dest__len)] = 0x00; } __DEL(extra); @@ -59,10 +59,10 @@ void Strings_Insert (CHAR *source, LONGINT source__len, INTEGER pos, CHAR *dest, Strings_Append(dest, dest__len, (void*)source, source__len); return; } - if ((LONGINT)(pos + n2) < dest__len) { + if ((int)(pos + n2) < dest__len) { i = n1; while (i >= pos) { - if ((LONGINT)(i + n2) < dest__len) { + if ((int)(i + n2) < dest__len) { dest[__X(i + n2, dest__len)] = dest[__X(i, dest__len)]; } i -= 1; @@ -91,7 +91,7 @@ void Strings_Delete (CHAR *s, LONGINT s__len, INTEGER pos, INTEGER n) s[__X(i - n, s__len)] = s[__X(i, s__len)]; i += 1; } - if ((LONGINT)(i - n) < s__len) { + if ((int)(i - n) < s__len) { s[__X(i - n, s__len)] = 0x00; } } else { @@ -121,7 +121,7 @@ void Strings_Extract (CHAR *source, LONGINT source__len, INTEGER pos, INTEGER n, return; } i = 0; - while (((((LONGINT)(pos + i) <= source__len && source[__X(pos + i, source__len)] != 0x00)) && i < n)) { + while (((((int)(pos + i) <= source__len && source[__X(pos + i, source__len)] != 0x00)) && i < n)) { if (i < destLen) { dest[__X(i, dest__len)] = source[__X(pos + i, source__len)]; } diff --git a/bootstrap/windows-48/Texts.c b/bootstrap/windows-48/Texts.c index ad722e53..627370de 100644 --- a/bootstrap/windows-48/Texts.c +++ b/bootstrap/windows-48/Texts.c @@ -839,7 +839,7 @@ void Texts_Scan (Texts_Scanner *S, LONGINT *S__typ) k -= 16; } while (j < i) { - k = __ASHL(k, 4) + (LONGINT)((int)d[__X(j, ((LONGINT)(32)))] - 48); + k = __ASHL(k, 4) + (int)((int)d[__X(j, ((LONGINT)(32)))] - 48); j += 1; } if (neg) { @@ -929,7 +929,7 @@ void Texts_Scan (Texts_Scanner *S, LONGINT *S__typ) (*S).class = 3; k = 0; do { - k = k * 10 + (LONGINT)((int)d[__X(j, ((LONGINT)(32)))] - 48); + k = k * 10 + (int)((int)d[__X(j, ((LONGINT)(32)))] - 48); j += 1; } while (!(j == i)); if (neg) { @@ -1067,7 +1067,7 @@ void Texts_WriteInt (Texts_Writer *W, LONGINT *W__typ, LONGINT x, LONGINT n) x0 = __DIV(x0, 10); i += 1; } while (!(x0 == 0)); - while (n > (LONGINT)i) { + while (n > (int)i) { Texts_Write(&*W, W__typ, ' '); n -= 1; } @@ -1319,7 +1319,7 @@ void Texts_WriteLongReal (Texts_Writer *W, LONGINT *W__typ, LONGREAL x, INTEGER } else { Texts_Write(&*W, W__typ, ' '); } - e = (int)__ASHR((LONGINT)(e - 1023) * 77, 8); + e = (int)__ASHR((int)(e - 1023) * 77, 8); if (e >= 0) { x = x / (LONGREAL)Reals_TenL(e); } else { diff --git a/bootstrap/windows-88/Files.c b/bootstrap/windows-88/Files.c index 0dc5def3..6a346319 100644 --- a/bootstrap/windows-88/Files.c +++ b/bootstrap/windows-88/Files.c @@ -924,11 +924,11 @@ void Files_ReadNum (Files_Rider *R, LONGINT *R__typ, LONGINT *x) n = 0; Files_Read(&*R, R__typ, (void*)&ch); while ((int)ch >= 128) { - n += __ASH((LONGINT)((int)ch - 128), s); + n += __ASH((SYSTEM_INT64)((int)ch - 128), s); s += 7; Files_Read(&*R, R__typ, (void*)&ch); } - n += __ASH((LONGINT)(__MASK((int)ch, -64) - __ASHL(__ASHR((int)ch, 6), 6)), s); + n += __ASH((SYSTEM_INT64)(__MASK((int)ch, -64) - __ASHL(__ASHR((int)ch, 6), 6)), s); *x = n; } diff --git a/bootstrap/windows-88/OPB.c b/bootstrap/windows-88/OPB.c index 1fb8ad2b..654fd595 100644 --- a/bootstrap/windows-88/OPB.c +++ b/bootstrap/windows-88/OPB.c @@ -243,7 +243,7 @@ static INTEGER OPB_SignedByteSize (LONGINT n) static LONGINT OPB_ShorterSize (LONGINT i) { LONGINT _o_result; - if (i >= (LONGINT)OPM_LIntSize) { + if (i >= (SYSTEM_INT64)OPM_LIntSize) { _o_result = OPM_IntSize; return _o_result; } else { @@ -256,7 +256,7 @@ static LONGINT OPB_ShorterSize (LONGINT i) static LONGINT OPB_LongerSize (LONGINT i) { LONGINT _o_result; - if (i <= (LONGINT)OPM_SIntSize) { + if (i <= (SYSTEM_INT64)OPM_SIntSize) { _o_result = OPM_IntSize; return _o_result; } else { @@ -521,7 +521,7 @@ void OPB_In (OPT_Node *x, OPT_Node y) } else if ((__IN(f, 0x70) && y->typ->form == 9)) { if ((*x)->class == 7) { k = (*x)->conval->intval; - if (k < 0 || k > (LONGINT)OPM_MaxSet) { + if (k < 0 || k > (SYSTEM_INT64)OPM_MaxSet) { OPB_err(202); } else if (y->class == 7) { (*x)->conval->intval = OPB_BoolToInt(__IN(k, y->conval->setval)); @@ -1554,13 +1554,13 @@ void OPB_SetRange (OPT_Node *x, OPT_Node y) } else if ((__IN((*x)->typ->form, 0x70) && __IN(y->typ->form, 0x70))) { if ((*x)->class == 7) { k = (*x)->conval->intval; - if (0 > k || k > (LONGINT)OPM_MaxSet) { + if (0 > k || k > (SYSTEM_INT64)OPM_MaxSet) { OPB_err(202); } } if (y->class == 7) { l = y->conval->intval; - if (0 > l || l > (LONGINT)OPM_MaxSet) { + if (0 > l || l > (SYSTEM_INT64)OPM_MaxSet) { OPB_err(202); } } @@ -1590,7 +1590,7 @@ void OPB_SetElem (OPT_Node *x) OPB_err(93); } else if ((*x)->class == 7) { k = (*x)->conval->intval; - if ((0 <= k && k <= (LONGINT)OPM_MaxSet)) { + if ((0 <= k && k <= (SYSTEM_INT64)OPM_MaxSet)) { (*x)->conval->setval = __SETOF(k); } else { OPB_err(202); @@ -1895,7 +1895,7 @@ void OPB_StPar0 (OPT_Node *par0, INTEGER fctno) case 10: if (x->class == 8 || x->class == 9) { OPB_err(126); - } else if ((__IN(f, 0x70) && x->typ->size > (LONGINT)OPM_SIntSize)) { + } else if ((__IN(f, 0x70) && x->typ->size > (SYSTEM_INT64)OPM_SIntSize)) { OPB_Convert(&x, OPB_IntType(OPB_ShorterSize(x->typ->size))); } else if (f == 8) { OPB_Convert(&x, OPT_realtyp); @@ -1906,7 +1906,7 @@ void OPB_StPar0 (OPT_Node *par0, INTEGER fctno) case 11: if (x->class == 8 || x->class == 9) { OPB_err(126); - } else if ((__IN(f, 0x70) && x->typ->size < (LONGINT)OPM_LIntSize)) { + } else if ((__IN(f, 0x70) && x->typ->size < (SYSTEM_INT64)OPM_LIntSize)) { OPB_Convert(&x, OPB_IntType(OPB_LongerSize(x->typ->size))); } else if (f == 7) { OPB_Convert(&x, OPT_lrltyp); @@ -1955,7 +1955,7 @@ void OPB_StPar0 (OPT_Node *par0, INTEGER fctno) if (x->class == 8 || x->class == 9) { OPB_err(126); } else if (__IN(f, 0x70)) { - if (x->typ->size != (LONGINT)OPM_LIntSize) { + if (x->typ->size != (SYSTEM_INT64)OPM_LIntSize) { OPB_Convert(&x, OPT_linttyp); } } else { @@ -1995,7 +1995,7 @@ void OPB_StPar0 (OPT_Node *par0, INTEGER fctno) OPB_err(126); } else if ((((x->class == 7 && __IN(f, 0x70))) && x->typ->size < OPT_linttyp->size)) { OPB_Convert(&x, OPT_linttyp); - } else if (!((__IN(x->typ->form, 0x2070) && x->typ->size == (LONGINT)OPM_PointerSize))) { + } else if (!((__IN(x->typ->form, 0x2070) && x->typ->size == (SYSTEM_INT64)OPM_PointerSize))) { OPB_err(111); x->typ = OPT_linttyp; } @@ -2093,7 +2093,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno) if (x->class == 8 || x->class == 9) { OPB_err(126); } else if (__IN(f, 0x70)) { - if ((x->class == 7 && (0 > x->conval->intval || x->conval->intval > (LONGINT)OPM_MaxSet))) { + if ((x->class == 7 && (0 > x->conval->intval || x->conval->intval > (SYSTEM_INT64)OPM_MaxSet))) { OPB_err(202); } p = NewOp__57(19, fctno, p, x); @@ -2264,7 +2264,7 @@ void OPB_StPar1 (OPT_Node *par0, OPT_Node x, SHORTINT fctno) OPB_err(126); } else if ((((x->class == 7 && __IN(f, 0x70))) && x->typ->size < OPT_linttyp->size)) { OPB_Convert(&x, OPT_linttyp); - } else if (!((__IN(x->typ->form, 0x2070) && x->typ->size == (LONGINT)OPM_PointerSize))) { + } else if (!((__IN(x->typ->form, 0x2070) && x->typ->size == (SYSTEM_INT64)OPM_PointerSize))) { OPB_err(111); x->typ = OPT_linttyp; } diff --git a/bootstrap/windows-88/OPC.c b/bootstrap/windows-88/OPC.c index aac3cac5..f23a7c6f 100644 --- a/bootstrap/windows-88/OPC.c +++ b/bootstrap/windows-88/OPC.c @@ -319,7 +319,7 @@ void OPC_Andent (OPT_Struct typ) static BOOLEAN OPC_Undefined (OPT_Object obj) { BOOLEAN _o_result; - _o_result = obj->name[0] == 0x00 || (((obj->mnolev >= 0 && obj->linkadr != (LONGINT)(3 + OPM_currFile))) && obj->linkadr != 2); + _o_result = obj->name[0] == 0x00 || (((obj->mnolev >= 0 && obj->linkadr != (SYSTEM_INT64)(3 + OPM_currFile))) && obj->linkadr != 2); return _o_result; } @@ -827,7 +827,7 @@ void OPC_TDescDecl (OPT_Struct typ) OPC_Str1((CHAR*)", #), {", (LONGINT)8, typ->size); nofptrs = 0; OPC_PutPtrOffsets(typ, ((LONGINT)(0)), &nofptrs); - OPC_Str1((CHAR*)"#}}", (LONGINT)4, -((nofptrs + 1) * (LONGINT)OPM_LIntSize)); + OPC_Str1((CHAR*)"#}}", (LONGINT)4, -((nofptrs + 1) * (SYSTEM_INT64)OPM_LIntSize)); OPC_EndStat(); } @@ -873,7 +873,7 @@ LONGINT OPC_SizeAlignment (LONGINT size) { LONGINT _o_result; LONGINT alignment; - if (size < (LONGINT)OPM_Alignment) { + if (size < (SYSTEM_INT64)OPM_Alignment) { alignment = 1; while (alignment < size) { alignment = __ASHL(alignment, 1); @@ -910,11 +910,11 @@ static void OPC_FillGap (LONGINT gap, LONGINT off, LONGINT align, LONGINT *n, LO if ((*curAlign < align && gap - (adr - off) >= align)) { gap -= (adr - off) + align; OPC_BegStat(); - if (align == (LONGINT)OPM_IntSize) { + if (align == (SYSTEM_INT64)OPM_IntSize) { OPM_WriteString((CHAR*)"INTEGER", (LONGINT)8); - } else if (align == (LONGINT)OPM_LIntSize) { + } else if (align == (SYSTEM_INT64)OPM_LIntSize) { OPM_WriteString((CHAR*)"LONGINT", (LONGINT)8); - } else if (align == (LONGINT)OPM_LRealSize) { + } else if (align == (SYSTEM_INT64)OPM_LRealSize) { OPM_WriteString((CHAR*)"LONGREAL", (LONGINT)9); } OPC_Str1((CHAR*)" _prvt#", (LONGINT)8, *n); @@ -979,7 +979,7 @@ static void OPC_FieldList (OPT_Struct typ, BOOLEAN last, LONGINT *off, LONGINT * } } if (last) { - adr = typ->size - (LONGINT)__ASHR(typ->sysflag, 8); + adr = typ->size - (SYSTEM_INT64)__ASHR(typ->sysflag, 8); if (adr == 0) { gap = 1; } else { diff --git a/bootstrap/windows-88/OPS.c b/bootstrap/windows-88/OPS.c index 10244289..03b478b2 100644 --- a/bootstrap/windows-88/OPS.c +++ b/bootstrap/windows-88/OPS.c @@ -174,7 +174,7 @@ static void OPS_Number (void) OPS_numtyp = 1; if (n <= 2) { while (i < n) { - OPS_intval = __ASHL(OPS_intval, 4) + (LONGINT)Ord__7(dig[i], 1); + OPS_intval = __ASHL(OPS_intval, 4) + (SYSTEM_INT64)Ord__7(dig[i], 1); i += 1; } } else { @@ -189,7 +189,7 @@ static void OPS_Number (void) OPS_intval = -1; } while (i < n) { - OPS_intval = __ASHL(OPS_intval, 4) + (LONGINT)Ord__7(dig[i], 1); + OPS_intval = __ASHL(OPS_intval, 4) + (SYSTEM_INT64)Ord__7(dig[i], 1); i += 1; } } else { @@ -200,8 +200,8 @@ static void OPS_Number (void) while (i < n) { d = Ord__7(dig[i], 0); i += 1; - if (OPS_intval <= __DIV(9223372036854775807 - (LONGINT)d, 10)) { - OPS_intval = OPS_intval * 10 + (LONGINT)d; + if (OPS_intval <= __DIV(9223372036854775807 - (SYSTEM_INT64)d, 10)) { + OPS_intval = OPS_intval * 10 + (SYSTEM_INT64)d; } else { OPS_err(203); } diff --git a/bootstrap/windows-88/OPV.c b/bootstrap/windows-88/OPV.c index 399d7149..88cb137f 100644 --- a/bootstrap/windows-88/OPV.c +++ b/bootstrap/windows-88/OPV.c @@ -87,7 +87,7 @@ void OPV_TypSize (OPT_Struct typ) base = OPC_SizeAlignment(OPM_RecSize); } else { OPV_TypSize(btyp); - offset = btyp->size - (LONGINT)__ASHR(btyp->sysflag, 8); + offset = btyp->size - (SYSTEM_INT64)__ASHR(btyp->sysflag, 8); base = btyp->align; } fld = typ->link; @@ -469,12 +469,10 @@ static void OPV_Entier (OPT_Node n, INTEGER prec) static void OPV_SizeCast (LONGINT size) { - if (size <= (LONGINT)OPM_SIntSize) { - OPM_WriteString((CHAR*)"(int)", (LONGINT)6); - } else if (size <= (LONGINT)OPM_IntSize) { + if (size <= 4) { OPM_WriteString((CHAR*)"(int)", (LONGINT)6); } else { - OPM_WriteString((CHAR*)"(LONGINT)", (LONGINT)10); + OPM_WriteString((CHAR*)"(SYSTEM_INT64)", (LONGINT)15); } } @@ -651,7 +649,7 @@ static void OPV_design (OPT_Node n, INTEGER prec) } if (n->typ->comp == 3) { OPM_Write(')'); - while ((LONGINT)i < __ASHR(d->typ->size - 4, 2)) { + while ((SYSTEM_INT64)i < __ASHR(d->typ->size - 4, 2)) { OPM_WriteString((CHAR*)" * ", (LONGINT)4); OPV_Len(d, i); i += 1; diff --git a/bootstrap/windows-88/Platform.c b/bootstrap/windows-88/Platform.c index 9d0decbc..fa1e8052 100644 --- a/bootstrap/windows-88/Platform.c +++ b/bootstrap/windows-88/Platform.c @@ -335,8 +335,8 @@ void Platform_SetBadInstructionHandler (Platform_SignalHandler handler) static void Platform_YMDHMStoClock (INTEGER ye, INTEGER mo, INTEGER da, INTEGER ho, INTEGER mi, INTEGER se, LONGINT *t, LONGINT *d) { - *d = (__ASHL((LONGINT)(int)__MOD(ye, 100), 9) + __ASHL((LONGINT)(mo + 1), 5)) + (LONGINT)da; - *t = (__ASHL((LONGINT)ho, 12) + __ASHL((LONGINT)mi, 6)) + (LONGINT)se; + *d = (__ASHL((SYSTEM_INT64)(int)__MOD(ye, 100), 9) + __ASHL((SYSTEM_INT64)(mo + 1), 5)) + (SYSTEM_INT64)da; + *t = (__ASHL((SYSTEM_INT64)ho, 12) + __ASHL((SYSTEM_INT64)mi, 6)) + (SYSTEM_INT64)se; } void Platform_GetClock (LONGINT *t, LONGINT *d) diff --git a/bootstrap/windows-88/Reals.c b/bootstrap/windows-88/Reals.c index b88dd1e1..5dbc72b6 100644 --- a/bootstrap/windows-88/Reals.c +++ b/bootstrap/windows-88/Reals.c @@ -90,7 +90,7 @@ void Reals_ConvertL (LONGREAL x, INTEGER n, CHAR *d, LONGINT d__len) } k = 0; i = __ENTIER(x); - while (k < (LONGINT)n) { + while (k < (SYSTEM_INT64)n) { d[__X(k, d__len)] = (CHAR)(__MOD(i, 10) + 48); i = __DIV(i, 10); k += 1; @@ -122,7 +122,7 @@ static void Reals_BytesToHex (SYSTEM_BYTE *b, LONGINT b__len, SYSTEM_BYTE *d, LO CHAR by; i = 0; l = b__len; - while ((LONGINT)i < l) { + while ((SYSTEM_INT64)i < l) { by = __VAL(CHAR, b[__X(i, b__len)]); d[__X(__ASHL(i, 1), d__len)] = Reals_ToHex(__ASHR((int)by, 4)); d[__X(__ASHL(i, 1) + 1, d__len)] = Reals_ToHex(__MASK((int)by, -16)); diff --git a/bootstrap/windows-88/SYSTEM.h b/bootstrap/windows-88/SYSTEM.h index 7ea8b8de..35ca975e 100644 --- a/bootstrap/windows-88/SYSTEM.h +++ b/bootstrap/windows-88/SYSTEM.h @@ -1,30 +1,40 @@ #ifndef SYSTEM__h #define SYSTEM__h -#ifndef _WIN32 - - // Building for a Unix/Linux based system - - // TODO: Remove these includes - #include // For memcpy ... - #include // For uintptr_t ... - +#if defined(_WIN64) + typedef long long SYSTEM_INT64; + typedef unsigned long long SYSTEM_CARD64; #else - - // Building for Windows platform with either mingw under cygwin, or the MS C compiler - #ifdef _WIN64 - typedef unsigned long long size_t; - typedef unsigned long long uintptr_t; - #else - typedef unsigned int size_t; - typedef unsigned int uintptr_t; - #endif /* _WIN64 */ - - typedef unsigned int uint32_t; - void * __cdecl memcpy(void * dest, const void * source, size_t size); - + typedef long SYSTEM_INT64; + typedef unsigned long SYSTEM_CARD64; #endif +typedef int SYSTEM_INT32; +typedef unsigned int SYSTEM_CARD32; +typedef short int SYSTEM_INT16; +typedef unsigned short int SYSTEM_CARD16; +typedef signed char SYSTEM_INT8; +typedef unsigned char SYSTEM_CARD8; + +#if (__SIZEOF_POINTER__ == 8) + #if defined(_WIN64) + typedef unsigned long long SYSTEM_PTRINT; + typedef unsigned long long uintptr_t; + typedef unsigned long long size_t; + #else + typedef unsigned long SYSTEM_PTRINT; + typedef unsigned long uintptr_t; + typedef unsigned long size_t; + #endif +#else + typedef unsigned int SYSTEM_PTRINT; + typedef unsigned int uintptr_t; + typedef unsigned int size_t; +#endif + +void * __cdecl memcpy(void *dest, const void *source, size_t size); + + // The compiler uses 'import' and 'export' which translate to 'extern' and // nothing respectively. diff --git a/bootstrap/windows-88/Strings.c b/bootstrap/windows-88/Strings.c index 839b8b93..0932a656 100644 --- a/bootstrap/windows-88/Strings.c +++ b/bootstrap/windows-88/Strings.c @@ -22,7 +22,7 @@ INTEGER Strings_Length (CHAR *s, LONGINT s__len) INTEGER i; __DUP(s, s__len, CHAR); i = 0; - while (((LONGINT)i < s__len && s[__X(i, s__len)] != 0x00)) { + while (((SYSTEM_INT64)i < s__len && s[__X(i, s__len)] != 0x00)) { i += 1; } _o_result = i; @@ -37,11 +37,11 @@ void Strings_Append (CHAR *extra, LONGINT extra__len, CHAR *dest, LONGINT dest__ n1 = Strings_Length(dest, dest__len); n2 = Strings_Length(extra, extra__len); i = 0; - while ((i < n2 && (LONGINT)(i + n1) < dest__len)) { + while ((i < n2 && (SYSTEM_INT64)(i + n1) < dest__len)) { dest[__X(i + n1, dest__len)] = extra[__X(i, extra__len)]; i += 1; } - if ((LONGINT)(i + n1) < dest__len) { + if ((SYSTEM_INT64)(i + n1) < dest__len) { dest[__X(i + n1, dest__len)] = 0x00; } __DEL(extra); @@ -60,10 +60,10 @@ void Strings_Insert (CHAR *source, LONGINT source__len, INTEGER pos, CHAR *dest, Strings_Append(dest, dest__len, (void*)source, source__len); return; } - if ((LONGINT)(pos + n2) < dest__len) { + if ((SYSTEM_INT64)(pos + n2) < dest__len) { i = n1; while (i >= pos) { - if ((LONGINT)(i + n2) < dest__len) { + if ((SYSTEM_INT64)(i + n2) < dest__len) { dest[__X(i + n2, dest__len)] = dest[__X(i, dest__len)]; } i -= 1; @@ -92,7 +92,7 @@ void Strings_Delete (CHAR *s, LONGINT s__len, INTEGER pos, INTEGER n) s[__X(i - n, s__len)] = s[__X(i, s__len)]; i += 1; } - if ((LONGINT)(i - n) < s__len) { + if ((SYSTEM_INT64)(i - n) < s__len) { s[__X(i - n, s__len)] = 0x00; } } else { @@ -122,7 +122,7 @@ void Strings_Extract (CHAR *source, LONGINT source__len, INTEGER pos, INTEGER n, return; } i = 0; - while (((((LONGINT)(pos + i) <= source__len && source[__X(pos + i, source__len)] != 0x00)) && i < n)) { + while (((((SYSTEM_INT64)(pos + i) <= source__len && source[__X(pos + i, source__len)] != 0x00)) && i < n)) { if (i < destLen) { dest[__X(i, dest__len)] = source[__X(pos + i, source__len)]; } diff --git a/bootstrap/windows-88/Texts.c b/bootstrap/windows-88/Texts.c index d958df95..21a4804c 100644 --- a/bootstrap/windows-88/Texts.c +++ b/bootstrap/windows-88/Texts.c @@ -840,7 +840,7 @@ void Texts_Scan (Texts_Scanner *S, LONGINT *S__typ) k -= 16; } while (j < i) { - k = __ASHL(k, 4) + (LONGINT)((int)d[__X(j, ((LONGINT)(32)))] - 48); + k = __ASHL(k, 4) + (SYSTEM_INT64)((int)d[__X(j, ((LONGINT)(32)))] - 48); j += 1; } if (neg) { @@ -930,7 +930,7 @@ void Texts_Scan (Texts_Scanner *S, LONGINT *S__typ) (*S).class = 3; k = 0; do { - k = k * 10 + (LONGINT)((int)d[__X(j, ((LONGINT)(32)))] - 48); + k = k * 10 + (SYSTEM_INT64)((int)d[__X(j, ((LONGINT)(32)))] - 48); j += 1; } while (!(j == i)); if (neg) { @@ -1068,7 +1068,7 @@ void Texts_WriteInt (Texts_Writer *W, LONGINT *W__typ, LONGINT x, LONGINT n) x0 = __DIV(x0, 10); i += 1; } while (!(x0 == 0)); - while (n > (LONGINT)i) { + while (n > (SYSTEM_INT64)i) { Texts_Write(&*W, W__typ, ' '); n -= 1; } @@ -1320,7 +1320,7 @@ void Texts_WriteLongReal (Texts_Writer *W, LONGINT *W__typ, LONGREAL x, INTEGER } else { Texts_Write(&*W, W__typ, ' '); } - e = (int)__ASHR((LONGINT)(e - 1023) * 77, 8); + e = (int)__ASHR((SYSTEM_INT64)(e - 1023) * 77, 8); if (e >= 0) { x = x / (LONGREAL)Reals_TenL(e); } else { diff --git a/src/system/SYSTEM.h b/src/system/SYSTEM.h index 7a4ca5f8..35ca975e 100644 --- a/src/system/SYSTEM.h +++ b/src/system/SYSTEM.h @@ -1,33 +1,40 @@ #ifndef SYSTEM__h #define SYSTEM__h -#ifndef _WIN32 - - // Building for a Unix/Linux based system - - // TODO: Remove these includes - #include // For memcpy ... - #include // For uintptr_t ... - - typedef long SYSTEM_INT64; - +#if defined(_WIN64) + typedef long long SYSTEM_INT64; + typedef unsigned long long SYSTEM_CARD64; #else - - // Building for Windows platform with either mingw under cygwin, or the MS C compiler - #ifdef _WIN64 - typedef unsigned long long size_t; - typedef unsigned long long uintptr_t; - #else - typedef unsigned int size_t; - typedef unsigned int uintptr_t; - #endif /* _WIN64 */ - - typedef long long SYSTEM_INT64 - typedef unsigned int uint32_t; - void * __cdecl memcpy(void *dest, const void *source, size_t size); - + typedef long SYSTEM_INT64; + typedef unsigned long SYSTEM_CARD64; #endif +typedef int SYSTEM_INT32; +typedef unsigned int SYSTEM_CARD32; +typedef short int SYSTEM_INT16; +typedef unsigned short int SYSTEM_CARD16; +typedef signed char SYSTEM_INT8; +typedef unsigned char SYSTEM_CARD8; + +#if (__SIZEOF_POINTER__ == 8) + #if defined(_WIN64) + typedef unsigned long long SYSTEM_PTRINT; + typedef unsigned long long uintptr_t; + typedef unsigned long long size_t; + #else + typedef unsigned long SYSTEM_PTRINT; + typedef unsigned long uintptr_t; + typedef unsigned long size_t; + #endif +#else + typedef unsigned int SYSTEM_PTRINT; + typedef unsigned int uintptr_t; + typedef unsigned int size_t; +#endif + +void * __cdecl memcpy(void *dest, const void *source, size_t size); + + // The compiler uses 'import' and 'export' which translate to 'extern' and // nothing respectively.