Uppercase internal SYSTEM.H types address, int*, uint*. Phase 1.

This commit is contained in:
David Brown 2016-11-08 11:48:33 +00:00
parent 1935f63cd6
commit baeb2db81f
205 changed files with 8388 additions and 8311 deletions

View file

@ -24,7 +24,7 @@
int64 SYSTEM_DIV(int64 x, int64 y)
INT64 SYSTEM_DIV(INT64 x, INT64 y)
{
if (x == 0) return 0;
if (x >= 0)
@ -35,7 +35,7 @@ int64 SYSTEM_DIV(int64 x, int64 y)
else {return (-x)/(-y);}
}
int64 SYSTEM_MOD(int64 x, int64 y)
INT64 SYSTEM_MOD(INT64 x, INT64 y)
{
if (x == 0) return 0;
if (x >= 0)
@ -46,31 +46,20 @@ int64 SYSTEM_MOD(int64 x, int64 y)
else {return -((-x) % (-y));}
}
// LONGINT SYSTEM_ENTIER(double x)
// {
// LONGINT y;
// if (x >= 0)
// return (LONGINT)x;
// else {
// y = (LONGINT)x;
// if (y <= x) return y; else return y - 1;
// }
// }
int64 SYSTEM_ENTIER(double x)
INT64 SYSTEM_ENTIER(double x)
{
int64 y;
INT64 y;
if (x >= 0)
return (int64)x;
return (INT64)x;
else {
y = (int64)x;
y = (INT64)x;
if (y <= x) return y; else return y - 1;
}
}
void SYSTEM_INHERIT(address *t, address *t0)
void SYSTEM_INHERIT(ADDRESS *t, ADDRESS *t0)
{
t -= __TPROC0OFF;
t0 -= __TPROC0OFF;
@ -78,23 +67,23 @@ void SYSTEM_INHERIT(address *t, address *t0)
}
void SYSTEM_ENUMP(void *adr, address n, void (*P)())
void SYSTEM_ENUMP(void *adr, ADDRESS n, void (*P)())
{
while (n > 0) {
P((address)(*((void**)(adr))));
P((ADDRESS)(*((void**)(adr))));
adr = ((void**)adr) + 1;
n--;
}
}
void SYSTEM_ENUMR(void *adr, address *typ, address size, address n, void (*P)())
void SYSTEM_ENUMR(void *adr, ADDRESS *typ, ADDRESS size, ADDRESS n, void (*P)())
{
address *t, off;
ADDRESS *t, off;
typ++;
while (n > 0) {
t = typ;
off = *t;
while (off >= 0) {P(*(address*)((char*)adr+off)); t++; off = *t;}
while (off >= 0) {P(*(ADDRESS*)((char*)adr+off)); t++; off = *t;}
adr = ((char*)adr) + size;
n--;
}
@ -103,19 +92,19 @@ void SYSTEM_ENUMR(void *adr, address *typ, address size, address n, void (*P)())
extern void Heap_Lock();
extern void Heap_Unlock();
SYSTEM_PTR SYSTEM_NEWARR(address *typ, address elemsz, int elemalgn, int nofdim, int nofdyn, ...)
SYSTEM_PTR SYSTEM_NEWARR(ADDRESS *typ, ADDRESS elemsz, int elemalgn, int nofdim, int nofdyn, ...)
{
address nofelems, size, dataoff, n, nptr, *x, *p, nofptrs, i, *ptab, off;
ADDRESS nofelems, size, dataoff, n, nptr, *x, *p, nofptrs, i, *ptab, off;
va_list ap;
va_start(ap, nofdyn);
nofelems = 1;
while (nofdim > 0) {
nofelems = nofelems * va_arg(ap, address); nofdim--;
nofelems = nofelems * va_arg(ap, ADDRESS); nofdim--;
if (nofelems <= 0) __HALT(-20);
}
va_end(ap);
dataoff = nofdyn * sizeof(address);
if (elemalgn > sizeof(address)) {
dataoff = nofdyn * sizeof(ADDRESS);
if (elemalgn > sizeof(ADDRESS)) {
n = dataoff % elemalgn;
if (n != 0) dataoff += elemalgn - n;
}
@ -125,37 +114,37 @@ SYSTEM_PTR SYSTEM_NEWARR(address *typ, address elemsz, int elemalgn, int nofdim,
/* element typ does not contain pointers */
x = Heap_NEWBLK(size);
}
else if (typ == (address*)POINTER__typ) {
else if (typ == (ADDRESS*)POINTER__typ) {
/* element type is a pointer */
x = Heap_NEWBLK(size + nofelems * sizeof(address));
p = (address*)(address)x[-1];
x = Heap_NEWBLK(size + nofelems * sizeof(ADDRESS));
p = (ADDRESS*)(ADDRESS)x[-1];
p[-nofelems] = *p; /* build new type desc in situ: 1. copy block size; 2. setup ptr tab; 3. set sentinel; 4. patch tag */
p -= nofelems - 1; n = 1; /* n =1 for skipping the size field */
while (n <= nofelems) {*p = n*sizeof(address); p++; n++;}
*p = - (nofelems + 1) * sizeof(address); /* sentinel */
x[-1] -= nofelems * sizeof(address);
while (n <= nofelems) {*p = n*sizeof(ADDRESS); p++; n++;}
*p = - (nofelems + 1) * sizeof(ADDRESS); /* sentinel */
x[-1] -= nofelems * sizeof(ADDRESS);
}
else {
/* element type is a record that contains pointers */
ptab = typ + 1; nofptrs = 0;
while (ptab[nofptrs] >= 0) {nofptrs++;} /* number of pointers per element */
nptr = nofelems * nofptrs; /* total number of pointers */
x = Heap_NEWBLK(size + nptr * sizeof(address));
p = (address*)(address)x[- 1];
x = Heap_NEWBLK(size + nptr * sizeof(ADDRESS));
p = (ADDRESS*)(ADDRESS)x[- 1];
p[-nptr] = *p; /* build new type desc in situ; 1. copy block size; 2. setup ptr tab; 3. set sentinel; 4. patch tag */
p -= nptr - 1; n = 0; off = dataoff;
while (n < nofelems) {i = 0;
while (i < nofptrs) {*p = off + ptab[i]; p++; i++;}
off += elemsz; n++;
}
*p = - (nptr + 1) * sizeof(address); /* sentinel */
x[-1] -= nptr * sizeof(address);
*p = - (nptr + 1) * sizeof(ADDRESS); /* sentinel */
x[-1] -= nptr * sizeof(ADDRESS);
}
if (nofdyn != 0) {
/* setup len vector for index checks */
va_start(ap, nofdyn);
p = x;
while (nofdyn > 0) {*p = va_arg(ap, address); p++, nofdyn--;}
while (nofdyn > 0) {*p = va_arg(ap, ADDRESS); p++, nofdyn--;}
va_end(ap);
}
Heap_Unlock();
@ -165,7 +154,7 @@ SYSTEM_PTR SYSTEM_NEWARR(address *typ, address elemsz, int elemalgn, int nofdim,
typedef void (*SystemSignalHandler)(int32); // = Platform_SignalHandler
typedef void (*SystemSignalHandler)(INT32); // = Platform_SignalHandler
#ifndef _WIN32
@ -177,7 +166,7 @@ typedef void (*SystemSignalHandler)(int32); // = Platform_SignalHandler
// (Ignore other signals)
}
void SystemSetHandler(int s, address h) {
void SystemSetHandler(int s, ADDRESS h) {
if (s >= 2 && s <= 4) {
int needtosetsystemhandler = handler[s-2] == 0;
handler[s-2] = (SystemSignalHandler)h;
@ -216,12 +205,12 @@ typedef void (*SystemSignalHandler)(int32); // = Platform_SignalHandler
}
}
void SystemSetInterruptHandler(address h) {
void SystemSetInterruptHandler(ADDRESS h) {
EnsureConsoleCtrlHandler();
SystemInterruptHandler = (SystemSignalHandler)h;
}
void SystemSetQuitHandler(address h) {
void SystemSetQuitHandler(ADDRESS h) {
EnsureConsoleCtrlHandler();
SystemQuitHandler = (SystemSignalHandler)h;
}