mirror of
https://github.com/Interlisp/maiko.git
synced 2026-04-17 08:10:55 +00:00
Convert from Addr68k_from_LADDR to NativeAligned2FromLAddr/NativeAligned4FromLAddr etc. in foreign.c
This commit is contained in:
@@ -18,6 +18,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
|
|
||||||
|
#include "byteswapdefs.h"
|
||||||
#include "dld.h"
|
#include "dld.h"
|
||||||
#include "lispemul.h"
|
#include "lispemul.h"
|
||||||
#include "lspglob.h"
|
#include "lspglob.h"
|
||||||
@@ -48,20 +49,20 @@
|
|||||||
short *sbase; \
|
short *sbase; \
|
||||||
int i; \
|
int i; \
|
||||||
\
|
\
|
||||||
arrayp = (OneDArray *)(Addr68k_from_LADDR((unsigned int)Lisp)); \
|
arrayp = (OneDArray *)(NativeAligned4FromLAddr((unsigned int)Lisp)); \
|
||||||
Len = min(MaxLen, arrayp->fillpointer); \
|
Len = min(MaxLen, arrayp->fillpointer); \
|
||||||
\
|
\
|
||||||
switch (arrayp->typenumber) { \
|
switch (arrayp->typenumber) { \
|
||||||
case THIN_CHAR_TYPENUMBER: \
|
case THIN_CHAR_TYPENUMBER: \
|
||||||
base = \
|
base = \
|
||||||
((char *)(Addr68k_from_LADDR((unsigned int)arrayp->base))) + ((int)(arrayp->offset)); \
|
((char *)(NativeAligned2FromLAddr((unsigned int)arrayp->base))) + ((int)(arrayp->offset)); \
|
||||||
for (i = 0; i < Len; i++) C[i] = base[i]; \
|
for (i = 0; i < Len; i++) C[i] = base[i]; \
|
||||||
C[Len] = '\0'; \
|
C[Len] = '\0'; \
|
||||||
break; \
|
break; \
|
||||||
\
|
\
|
||||||
case FAT_CHAR_TYPENUMBER: \
|
case FAT_CHAR_TYPENUMBER: \
|
||||||
sbase = \
|
sbase = \
|
||||||
((short *)(Addr68k_from_LADDR((unsigned int)arrayp->base))) + ((int)(arrayp->offset)); \
|
((short *)(NativeAligned2FromLAddr((unsigned int)arrayp->base))) + ((int)(arrayp->offset)); \
|
||||||
base = (char *)sbase; \
|
base = (char *)sbase; \
|
||||||
for (i = 0; i < Len * 2; i++) C[i] = base[i]; \
|
for (i = 0; i < Len * 2; i++) C[i] = base[i]; \
|
||||||
C[Len * 2] = '\0'; \
|
C[Len * 2] = '\0'; \
|
||||||
@@ -122,7 +123,7 @@ LispPTR call_c_fn(LispPTR *args) {
|
|||||||
ByteCode *pc;
|
ByteCode *pc;
|
||||||
|
|
||||||
/* Initialize the variables from the descriptorblock */
|
/* Initialize the variables from the descriptorblock */
|
||||||
descriptorblock = (int *)Addr68k_from_LADDR(args[0]);
|
descriptorblock = (int *)NativeAligned4FromLAddr(args[0]);
|
||||||
fnaddr = *descriptorblock++;
|
fnaddr = *descriptorblock++;
|
||||||
resulttype = *descriptorblock++;
|
resulttype = *descriptorblock++;
|
||||||
errorflag = descriptorblock++;
|
errorflag = descriptorblock++;
|
||||||
@@ -146,7 +147,7 @@ LispPTR call_c_fn(LispPTR *args) {
|
|||||||
int *tracedesc;
|
int *tracedesc;
|
||||||
|
|
||||||
printf("Start Foreign function call=====\n");
|
printf("Start Foreign function call=====\n");
|
||||||
tracedesc = (int *)Addr68k_from_LADDR(args[0]);
|
tracedesc = (int *)NativeAligned4FromLAddr(args[0]);
|
||||||
printf("fnaddr: %d\n", *tracedesc++);
|
printf("fnaddr: %d\n", *tracedesc++);
|
||||||
printf("resulttype: %d\n", *tracedesc++);
|
printf("resulttype: %d\n", *tracedesc++);
|
||||||
printf("errorflag: %d\n", *tracedesc++);
|
printf("errorflag: %d\n", *tracedesc++);
|
||||||
@@ -196,7 +197,7 @@ LispPTR call_c_fn(LispPTR *args) {
|
|||||||
case TYPE_LITATOM:
|
case TYPE_LITATOM:
|
||||||
case TYPE_NEWATOM:
|
case TYPE_NEWATOM:
|
||||||
if (expectedtype == TYPE_LITATOM) {
|
if (expectedtype == TYPE_LITATOM) {
|
||||||
intarg[j] = *(int *)Addr68k_from_LADDR(args[i]);
|
intarg[j] = *(int *)NativeAligned4FromLAddr(args[i]);
|
||||||
} else {
|
} else {
|
||||||
*errorflag = i;
|
*errorflag = i;
|
||||||
return (NIL);
|
return (NIL);
|
||||||
@@ -204,7 +205,7 @@ LispPTR call_c_fn(LispPTR *args) {
|
|||||||
break;
|
break;
|
||||||
case TYPE_LISTP:
|
case TYPE_LISTP:
|
||||||
if (expectedtype == TYPE_LISTP) {
|
if (expectedtype == TYPE_LISTP) {
|
||||||
intarg[j] = *(int *)Addr68k_from_LADDR(args[i]);
|
intarg[j] = *(int *)NativeAligned4FromLAddr(args[i]);
|
||||||
} else {
|
} else {
|
||||||
*errorflag = i;
|
*errorflag = i;
|
||||||
return (NIL);
|
return (NIL);
|
||||||
@@ -212,7 +213,7 @@ LispPTR call_c_fn(LispPTR *args) {
|
|||||||
break;
|
break;
|
||||||
case TYPE_ARRAYP:
|
case TYPE_ARRAYP:
|
||||||
if (expectedtype == TYPE_ARRAYP) {
|
if (expectedtype == TYPE_ARRAYP) {
|
||||||
intarg[j] = *(int *)Addr68k_from_LADDR(args[i]);
|
intarg[j] = *(int *)NativeAligned4FromLAddr(args[i]);
|
||||||
} else {
|
} else {
|
||||||
*errorflag = i;
|
*errorflag = i;
|
||||||
return (NIL);
|
return (NIL);
|
||||||
@@ -244,7 +245,7 @@ LispPTR call_c_fn(LispPTR *args) {
|
|||||||
break;
|
break;
|
||||||
case TYPE_BITMAP:
|
case TYPE_BITMAP:
|
||||||
if (expectedtype == TYPE_BITMAP) {
|
if (expectedtype == TYPE_BITMAP) {
|
||||||
intarg[j] = *(int *)Addr68k_from_LADDR(args[i]);
|
intarg[j] = *(int *)NativeAligned4FromLAddr(args[i]);
|
||||||
} else {
|
} else {
|
||||||
*errorflag = i;
|
*errorflag = i;
|
||||||
return (NIL);
|
return (NIL);
|
||||||
@@ -253,7 +254,7 @@ LispPTR call_c_fn(LispPTR *args) {
|
|||||||
case TYPE_COMPILED_CLOSURE: break;
|
case TYPE_COMPILED_CLOSURE: break;
|
||||||
case TYPE_ONED_ARRAY:
|
case TYPE_ONED_ARRAY:
|
||||||
if (expectedtype == TYPE_ONED_ARRAY) {
|
if (expectedtype == TYPE_ONED_ARRAY) {
|
||||||
intarg[j] = *(int *)Addr68k_from_LADDR(args[i]);
|
intarg[j] = *(int *)NativeAligned4FromLAddr(args[i]);
|
||||||
} else {
|
} else {
|
||||||
*errorflag = i;
|
*errorflag = i;
|
||||||
return (NIL);
|
return (NIL);
|
||||||
@@ -261,7 +262,7 @@ LispPTR call_c_fn(LispPTR *args) {
|
|||||||
break;
|
break;
|
||||||
case TYPE_TWOD_ARRAY:
|
case TYPE_TWOD_ARRAY:
|
||||||
if (expectedtype == TYPE_TWOD_ARRAY) {
|
if (expectedtype == TYPE_TWOD_ARRAY) {
|
||||||
intarg[j] = *(int *)Addr68k_from_LADDR(args[i]);
|
intarg[j] = *(int *)NativeAligned4FromLAddr(args[i]);
|
||||||
} else {
|
} else {
|
||||||
*errorflag = i;
|
*errorflag = i;
|
||||||
return (NIL);
|
return (NIL);
|
||||||
@@ -269,7 +270,7 @@ LispPTR call_c_fn(LispPTR *args) {
|
|||||||
break;
|
break;
|
||||||
case TYPE_GENERAL_ARRAY:
|
case TYPE_GENERAL_ARRAY:
|
||||||
if (expectedtype == TYPE_GENERAL_ARRAY) {
|
if (expectedtype == TYPE_GENERAL_ARRAY) {
|
||||||
intarg[j] = *(int *)Addr68k_from_LADDR(args[i]);
|
intarg[j] = *(int *)NativeAligned4FromLAddr(args[i]);
|
||||||
} else {
|
} else {
|
||||||
*errorflag = i;
|
*errorflag = i;
|
||||||
return (NIL);
|
return (NIL);
|
||||||
@@ -277,7 +278,7 @@ LispPTR call_c_fn(LispPTR *args) {
|
|||||||
break;
|
break;
|
||||||
case TYPE_BIGNUM:
|
case TYPE_BIGNUM:
|
||||||
if (expectedtype == TYPE_BIGNUM) {
|
if (expectedtype == TYPE_BIGNUM) {
|
||||||
intarg[j] = *(int *)Addr68k_from_LADDR(args[i]);
|
intarg[j] = *(int *)NativeAligned4FromLAddr(args[i]);
|
||||||
} else {
|
} else {
|
||||||
*errorflag = i;
|
*errorflag = i;
|
||||||
return (NIL);
|
return (NIL);
|
||||||
@@ -285,7 +286,7 @@ LispPTR call_c_fn(LispPTR *args) {
|
|||||||
break;
|
break;
|
||||||
case TYPE_RATIO:
|
case TYPE_RATIO:
|
||||||
if (expectedtype == TYPE_RATIO) {
|
if (expectedtype == TYPE_RATIO) {
|
||||||
intarg[j] = *(int *)Addr68k_from_LADDR(args[i]);
|
intarg[j] = *(int *)NativeAligned4FromLAddr(args[i]);
|
||||||
} else {
|
} else {
|
||||||
*errorflag = i;
|
*errorflag = i;
|
||||||
return (NIL);
|
return (NIL);
|
||||||
@@ -293,7 +294,7 @@ LispPTR call_c_fn(LispPTR *args) {
|
|||||||
break;
|
break;
|
||||||
case TYPE_COMPLEX:
|
case TYPE_COMPLEX:
|
||||||
if (expectedtype == TYPE_COMPLEX) {
|
if (expectedtype == TYPE_COMPLEX) {
|
||||||
intarg[j] = *(int *)Addr68k_from_LADDR(args[i]);
|
intarg[j] = *(int *)NativeAligned4FromLAddr(args[i]);
|
||||||
} else {
|
} else {
|
||||||
*errorflag = i;
|
*errorflag = i;
|
||||||
return (NIL);
|
return (NIL);
|
||||||
@@ -315,7 +316,7 @@ LispPTR call_c_fn(LispPTR *args) {
|
|||||||
intarg[20], intarg[21], intarg[22], intarg[23], intarg[24], intarg[25],
|
intarg[20], intarg[21], intarg[22], intarg[23], intarg[24], intarg[25],
|
||||||
intarg[26], intarg[27], intarg[28], intarg[29], intarg[30], intarg[31]);
|
intarg[26], intarg[27], intarg[28], intarg[29], intarg[30], intarg[31]);
|
||||||
caller = (FX2 *)CURRENTFX; /* Don't return values, just continue. */
|
caller = (FX2 *)CURRENTFX; /* Don't return values, just continue. */
|
||||||
fnhead = (struct fnhead *)Addr68k_from_LADDR(POINTERMASK & swapx((int)caller->fnheader));
|
fnhead = (struct fnhead *)NativeAligned4FromLAddr(POINTERMASK & swapx((int)caller->fnheader));
|
||||||
pc = (ByteCode *)fnhead + (caller->pc);
|
pc = (ByteCode *)fnhead + (caller->pc);
|
||||||
break;
|
break;
|
||||||
case TYPE_SMALLP:
|
case TYPE_SMALLP:
|
||||||
@@ -348,7 +349,7 @@ LispPTR call_c_fn(LispPTR *args) {
|
|||||||
intarg[27], intarg[28], intarg[29], intarg[30], intarg[31]);
|
intarg[27], intarg[28], intarg[29], intarg[30], intarg[31]);
|
||||||
fword = createcell68k(TYPE_FLOATP);
|
fword = createcell68k(TYPE_FLOATP);
|
||||||
*((float *)fword) = fresult;
|
*((float *)fword) = fresult;
|
||||||
return (LADDR_from_68k(fword));
|
return (LAddrFromNative(fword));
|
||||||
break;
|
break;
|
||||||
default: *errorflag = -2; break;
|
default: *errorflag = -2; break;
|
||||||
}
|
}
|
||||||
@@ -402,7 +403,7 @@ LispPTR smashing_c_fn(LispPTR *args) {
|
|||||||
ByteCode *pc;
|
ByteCode *pc;
|
||||||
|
|
||||||
/* Initialize the variables from the descriptorblock */
|
/* Initialize the variables from the descriptorblock */
|
||||||
descriptorblock = (int *)Addr68k_from_LADDR(args[0]);
|
descriptorblock = (int *)NativeAligned4FromLAddr(args[0]);
|
||||||
fnaddr = *descriptorblock++;
|
fnaddr = *descriptorblock++;
|
||||||
resulttype = *descriptorblock++;
|
resulttype = *descriptorblock++;
|
||||||
errorflag = descriptorblock++;
|
errorflag = descriptorblock++;
|
||||||
@@ -412,7 +413,7 @@ LispPTR smashing_c_fn(LispPTR *args) {
|
|||||||
*errorflag = 0;
|
*errorflag = 0;
|
||||||
|
|
||||||
/* Initialize the valueplace */
|
/* Initialize the valueplace */
|
||||||
valueplace = (int *)Addr68k_from_LADDR(args[1]);
|
valueplace = (int *)NativeAligned4FromLAddr(args[1]);
|
||||||
|
|
||||||
/* Initialize the argvector */
|
/* Initialize the argvector */
|
||||||
for (i = 0; i < Max_Arg; i++) { intarg[i] = 0; };
|
for (i = 0; i < Max_Arg; i++) { intarg[i] = 0; };
|
||||||
@@ -463,7 +464,7 @@ LispPTR smashing_c_fn(LispPTR *args) {
|
|||||||
case TYPE_LITATOM:
|
case TYPE_LITATOM:
|
||||||
case TYPE_NEWATOM:
|
case TYPE_NEWATOM:
|
||||||
if (expectedtype == TYPE_LITATOM) {
|
if (expectedtype == TYPE_LITATOM) {
|
||||||
intarg[j] = *(int *)Addr68k_from_LADDR(args[i]);
|
intarg[j] = *(int *)NativeAligned4FromLAddr(args[i]);
|
||||||
} else {
|
} else {
|
||||||
*errorflag = i;
|
*errorflag = i;
|
||||||
return (NIL);
|
return (NIL);
|
||||||
@@ -471,7 +472,7 @@ LispPTR smashing_c_fn(LispPTR *args) {
|
|||||||
break;
|
break;
|
||||||
case TYPE_LISTP:
|
case TYPE_LISTP:
|
||||||
if (expectedtype == TYPE_LISTP) {
|
if (expectedtype == TYPE_LISTP) {
|
||||||
intarg[j] = *(int *)Addr68k_from_LADDR(args[i]);
|
intarg[j] = *(int *)NativeAligned4FromLAddr(args[i]);
|
||||||
} else {
|
} else {
|
||||||
*errorflag = i;
|
*errorflag = i;
|
||||||
return (NIL);
|
return (NIL);
|
||||||
@@ -479,7 +480,7 @@ LispPTR smashing_c_fn(LispPTR *args) {
|
|||||||
break;
|
break;
|
||||||
case TYPE_ARRAYP:
|
case TYPE_ARRAYP:
|
||||||
if (expectedtype == TYPE_ARRAYP) {
|
if (expectedtype == TYPE_ARRAYP) {
|
||||||
intarg[j] = *(int *)Addr68k_from_LADDR(args[i]);
|
intarg[j] = *(int *)NativeAligned4FromLAddr(args[i]);
|
||||||
} else {
|
} else {
|
||||||
*errorflag = i;
|
*errorflag = i;
|
||||||
return (NIL);
|
return (NIL);
|
||||||
@@ -511,7 +512,7 @@ LispPTR smashing_c_fn(LispPTR *args) {
|
|||||||
break;
|
break;
|
||||||
case TYPE_BITMAP:
|
case TYPE_BITMAP:
|
||||||
if (expectedtype == TYPE_BITMAP) {
|
if (expectedtype == TYPE_BITMAP) {
|
||||||
intarg[j] = *(int *)Addr68k_from_LADDR(args[i]);
|
intarg[j] = *(int *)NativeAligned4FromLAddr(args[i]);
|
||||||
} else {
|
} else {
|
||||||
*errorflag = i;
|
*errorflag = i;
|
||||||
return (NIL);
|
return (NIL);
|
||||||
@@ -520,7 +521,7 @@ LispPTR smashing_c_fn(LispPTR *args) {
|
|||||||
case TYPE_COMPILED_CLOSURE: break;
|
case TYPE_COMPILED_CLOSURE: break;
|
||||||
case TYPE_ONED_ARRAY:
|
case TYPE_ONED_ARRAY:
|
||||||
if (expectedtype == TYPE_ONED_ARRAY) {
|
if (expectedtype == TYPE_ONED_ARRAY) {
|
||||||
intarg[j] = *(int *)Addr68k_from_LADDR(args[i]);
|
intarg[j] = *(int *)NativeAligned4FromLAddr(args[i]);
|
||||||
} else {
|
} else {
|
||||||
*errorflag = i;
|
*errorflag = i;
|
||||||
return (NIL);
|
return (NIL);
|
||||||
@@ -528,7 +529,7 @@ LispPTR smashing_c_fn(LispPTR *args) {
|
|||||||
break;
|
break;
|
||||||
case TYPE_TWOD_ARRAY:
|
case TYPE_TWOD_ARRAY:
|
||||||
if (expectedtype == TYPE_TWOD_ARRAY) {
|
if (expectedtype == TYPE_TWOD_ARRAY) {
|
||||||
intarg[j] = *(int *)Addr68k_from_LADDR(args[i]);
|
intarg[j] = *(int *)NativeAligned4FromLAddr(args[i]);
|
||||||
} else {
|
} else {
|
||||||
*errorflag = i;
|
*errorflag = i;
|
||||||
return (NIL);
|
return (NIL);
|
||||||
@@ -536,7 +537,7 @@ LispPTR smashing_c_fn(LispPTR *args) {
|
|||||||
break;
|
break;
|
||||||
case TYPE_GENERAL_ARRAY:
|
case TYPE_GENERAL_ARRAY:
|
||||||
if (expectedtype == TYPE_GENERAL_ARRAY) {
|
if (expectedtype == TYPE_GENERAL_ARRAY) {
|
||||||
intarg[j] = *(int *)Addr68k_from_LADDR(args[i]);
|
intarg[j] = *(int *)NativeAligned4FromLAddr(args[i]);
|
||||||
} else {
|
} else {
|
||||||
*errorflag = i;
|
*errorflag = i;
|
||||||
return (NIL);
|
return (NIL);
|
||||||
@@ -544,7 +545,7 @@ LispPTR smashing_c_fn(LispPTR *args) {
|
|||||||
break;
|
break;
|
||||||
case TYPE_BIGNUM:
|
case TYPE_BIGNUM:
|
||||||
if (expectedtype == TYPE_BIGNUM) {
|
if (expectedtype == TYPE_BIGNUM) {
|
||||||
intarg[j] = *(int *)Addr68k_from_LADDR(args[i]);
|
intarg[j] = *(int *)NativeAligned4FromLAddr(args[i]);
|
||||||
} else {
|
} else {
|
||||||
*errorflag = i;
|
*errorflag = i;
|
||||||
return (NIL);
|
return (NIL);
|
||||||
@@ -552,7 +553,7 @@ LispPTR smashing_c_fn(LispPTR *args) {
|
|||||||
break;
|
break;
|
||||||
case TYPE_RATIO:
|
case TYPE_RATIO:
|
||||||
if (expectedtype == TYPE_RATIO) {
|
if (expectedtype == TYPE_RATIO) {
|
||||||
intarg[j] = *(int *)Addr68k_from_LADDR(args[i]);
|
intarg[j] = *(int *)NativeAligned4FromLAddr(args[i]);
|
||||||
} else {
|
} else {
|
||||||
*errorflag = i;
|
*errorflag = i;
|
||||||
return (NIL);
|
return (NIL);
|
||||||
@@ -560,7 +561,7 @@ LispPTR smashing_c_fn(LispPTR *args) {
|
|||||||
break;
|
break;
|
||||||
case TYPE_COMPLEX:
|
case TYPE_COMPLEX:
|
||||||
if (expectedtype == TYPE_COMPLEX) {
|
if (expectedtype == TYPE_COMPLEX) {
|
||||||
intarg[j] = *(int *)Addr68k_from_LADDR(args[i]);
|
intarg[j] = *(int *)NativeAligned4FromLAddr(args[i]);
|
||||||
} else {
|
} else {
|
||||||
*errorflag = i;
|
*errorflag = i;
|
||||||
return (NIL);
|
return (NIL);
|
||||||
@@ -582,7 +583,7 @@ LispPTR smashing_c_fn(LispPTR *args) {
|
|||||||
intarg[20], intarg[21], intarg[22], intarg[23], intarg[24], intarg[25],
|
intarg[20], intarg[21], intarg[22], intarg[23], intarg[24], intarg[25],
|
||||||
intarg[26], intarg[27], intarg[28], intarg[29], intarg[30], intarg[31]);
|
intarg[26], intarg[27], intarg[28], intarg[29], intarg[30], intarg[31]);
|
||||||
caller = (FX2 *)CURRENTFX; /* Don't return values, just continue. */
|
caller = (FX2 *)CURRENTFX; /* Don't return values, just continue. */
|
||||||
fnhead = (struct fnhead *)Addr68k_from_LADDR(POINTERMASK & swapx((int)caller->fnheader));
|
fnhead = (struct fnhead *)NativeAligned4FromLAddr(POINTERMASK & swapx((int)caller->fnheader));
|
||||||
pc = (ByteCode *)fnhead + (caller->pc);
|
pc = (ByteCode *)fnhead + (caller->pc);
|
||||||
break;
|
break;
|
||||||
case TYPE_SMALLP:
|
case TYPE_SMALLP:
|
||||||
@@ -928,7 +929,7 @@ int get_c_basebyte(LispPTR *args) {
|
|||||||
case 4: /* float */
|
case 4: /* float */
|
||||||
fword = createcell68k(TYPE_FLOATP);
|
fword = createcell68k(TYPE_FLOATP);
|
||||||
*((float *)fword) = *(float *)((addr & 0xFFFFFFFE) + (offset << 2));
|
*((float *)fword) = *(float *)((addr & 0xFFFFFFFE) + (offset << 2));
|
||||||
return (LADDR_from_68k(fword));
|
return (LAddrFromNative(fword));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user