SYSTEM_PTR SYSTEM_NEWARR(SYSTEM_ADRINT *typ, SYSTEM_ARRLEN elemsz, int elemalgn, int nofdim, int nofdyn, ...) { SYSTEM_ADRINT *x, *ptab; SYSTEM_ARRLEN nofelems, size, dataoff, n, nptr, *p, nofptrs, i, off; va_list ap; va_start(ap, nofdyn); nofelems = 1; while (nofdim > 0) { nofelems = nofelems * va_arg(ap, SYSTEM_ARRLEN); nofdim--; if (nofelems <= 0) __HALT(-20); } va_end(ap); dataoff = nofdyn * sizeof(SYSTEM_ARRLEN); if (elemalgn > sizeof(SYSTEM_ARRLEN)) { n = dataoff % elemalgn; if (n != 0) dataoff += elemalgn - n; } size = dataoff + nofelems * elemsz; Heap_Lock(); if (typ == NIL) { /* element typ does not contain pointers */ x = Heap_NEWBLK(size); } else if (typ == (SYSTEM_ADRINT*)POINTER__typ) { /* element type is a pointer */ x = Heap_NEWBLK(size + nofelems * sizeof(SYSTEM_ADRINT)); p = (SYSTEM_ARRLEN*)(SYSTEM_ADRINT)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(SYSTEM_ADRINT); p++; n++;} *p = - (nofelems + 1) * sizeof(SYSTEM_ADRINT); /* sentinel */ x[-1] -= nofelems * sizeof(SYSTEM_ADRINT); } 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(SYSTEM_ADRINT)); p = (SYSTEM_ARRLEN*)(SYSTEM_ADRINT)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(SYSTEM_ADRINT); /* sentinel */ x[-1] -= nptr * sizeof(SYSTEM_ADRINT); } if (nofdyn != 0) { /* setup len vector for index checks */ va_start(ap, nofdyn); p = (SYSTEM_ARRLEN*)x; while (nofdyn > 0) {*p = va_arg(ap, SYSTEM_ARRLEN); p++, nofdyn--;} va_end(ap); } Heap_Unlock(); return x; }
void SYSTEM_STRCOPYTL(_CHAR x[], _CHAR y[], INTEGER n) /* ly := LONG(SHORT(lx)) */ { int i = 0; do { if (n-- == 0) __HALT(-8); y[i] = (x[i] & 0xff); } while ((x[i++] & 0xff) != 0); }
void SYSTEM_STRCOPYSL(SHORTCHAR x[], _CHAR y[], INTEGER n) /* ly := LONG(sx) */ { int i = 0; do { if (n-- == 0) __HALT(-8); y[i] = x[i]; } while (x[i++] != 0); }
void SYSTEM_STRCOPYLL(_CHAR x[], _CHAR y[], INTEGER n) /* ly := lx */ { int i = 0; do { if (n-- == 0) __HALT(-8); y[i] = x[i]; } while (x[i++] != 0); }
void SYSTEM_STRCOPYTS(_CHAR x[], SHORTCHAR y[], INTEGER n) /* sy := SHORT(lx) */ { int i = 0; do { if (n-- == 0) __HALT(-8); y[i] = (SHORTCHAR)x[i]; } while ((x[i++] & 0xff) != 0); }
void SYSTEM_STRCOPYSS(SHORTCHAR x[], SHORTCHAR y[], INTEGER n) /* sy := sx */ { int i = 0; do { if (n-- == 0) __HALT(-8); y[i] = x[i]; } while (x[i++] != 0); }
void SYSTEM_STRAPNDTL(_CHAR x[], _CHAR y[], INTEGER n) /* ly := ly + LONG(SHORT(lx)) */ { int i = 0, j = 0; while (y[j] != 0) j++; do { if (n-- == 0) __HALT(-8); y[j++] = (x[i] & 0xff); } while ((x[i++] & 0xff) != 0); }
void SYSTEM_STRAPNDSL(SHORTCHAR x[], _CHAR y[], INTEGER n) /* ly := ly + LONG(sx) */ { int i = 0, j = 0; while (y[j] != 0) j++; do { if (n-- == 0) __HALT(-8); y[j++] = x[i]; } while (x[i++] != 0); }
void SYSTEM_STRAPNDTS(_CHAR x[], SHORTCHAR y[], INTEGER n) /* sy := sy + SHORT(lx) */ { int i = 0, j = 0; while (y[j] != 0) j++; do { if (n-- == 0) __HALT(-8); y[j++] = (SHORTCHAR)x[i]; } while ((x[i++] & 0xff) != 0); }
void SYSTEM_STRAPNDSS(SHORTCHAR x[], SHORTCHAR y[], INTEGER n) /* sy := sy + sx */ { int i = 0, j = 0; while (y[j] != 0) j++; do { if (n-- == 0) __HALT(-8); y[j++] = x[i]; } while (x[i++] != 0); }
_CHAR* SYSTEM_LSTR(char *x) { _CHAR *str = SYSTEM_strBuf[SYSTEM_actual]; int i = 0; SYSTEM_actual = (SYSTEM_actual + 1) & 0x1F; do { if (i == 256) __HALT(-8); str[i] = x[i]; } while (x[i++] != 0); return str; }
LONGINT SYSTEM_DIVL(LONGINT x, LONGINT y) { if (y > 0) { if (x < 0) return ~(~x / y); else return x / y; } else if (y < 0) { if (x > 0) return ~((x - 1) / -y); else return -x / -y; } else { __HALT(-5); } }
LONGINT SYSTEM_MODL(LONGINT x, LONGINT y) { if (y > 0) { if (x < 0) return y + ~(~x % y); else return x % y; } else if (y < 0) { if (x > 0) return y + 1 + ((x - 1) % -y); else return -(-x % -y); } else { __HALT(-5); } }
INTEGER SYSTEM_MOD(INTEGER x, INTEGER y) { if (y > 0) { if (x < 0) return y + ~(~x % y); else return x % y; } else if (y < 0) { if (x > 0) return y + 1 + ((x - 1) % -y); else return -(-x % -y); } else { __HALT(-5); } }
LONGINT SYSTEM_MODL(LONGINT x, LONGINT y) { if (y > 0) { if (x < 0) return y - 1 + (x + 1) % y; else return x % y; } if (y < 0) { if (x > 0) return y + 1 + (x - 1) % y; else return x % y; } __HALT(-12); }
INTEGER SYSTEM_DIV(INTEGER x, INTEGER y) { if (y > 0) { if (x < 0) return ~(~x / y); else return x / y; } else if (y < 0) { if (x > 0) return ~((x - 1) / -y); else return -x / -y; } else { __HALT(-5); } }
LONGINT SYSTEM_DIVL(LONGINT x, LONGINT y) { if (y > 0) { if (x < 0) return -1 - (-1 - x) / y; else return x / y; } if (y < 0) { if (x > 0) return -1 + (x - 1) / y; else return x / y; } __HALT(-12); }
INTEGER SYSTEM_MOD(INTEGER x, INTEGER y) { if (y > 0) { if (x < 0) return y - 1 + (x + 1) % y; else return x % y; } if (y < 0) { if (x > 0) return y + 1 + (x - 1) % y; else return x % y; } __HALT(-12); }
INTEGER SYSTEM_DIV(INTEGER x, INTEGER y) { if (y > 0) { if (x < 0) return -1 - (-1 - x) / y; else return x / y; } if (y < 0) { if (x > 0) return -1 + (x - 1) / y; else return x / y; } __HALT(-12); }
INTEGER SYSTEM_XCHK(INTEGER i, INTEGER ub) { if ((unsigned)(i)>=(unsigned)(ub)) __HALT(-7); return i; }
void SIG1(CFTypeRef) { __HALT(); };;
CFStringRef SIG6(CFTypeRef) { __HALT(); return NULL; };
CFStringRef SIG5(CFTypeRef,CFDictionaryRef) { __HALT(); return NULL; };
CFHashCode SIG4(CFTypeRef) { __HALT(); return 0; };
Boolean SIG3(CFTypeRef,CFTypeRef) { __HALT(); return FALSE; };
CFTypeRef SIG2(CFAllocatorRef,CFTypeRef) { __HALT(); return NULL; };