diff --git a/inc/arrayopsdefs.h b/inc/arrayopsdefs.h index 0f56d08..6b536c9 100644 --- a/inc/arrayopsdefs.h +++ b/inc/arrayopsdefs.h @@ -4,7 +4,7 @@ LispPTR N_OP_misc3(LispPTR baseL, LispPTR typenumber, LispPTR inx, int alpha); LispPTR N_OP_misc4(LispPTR data, LispPTR base, LispPTR typenumber, LispPTR inx, int alpha); LispPTR N_OP_aref1(LispPTR arrayarg, LispPTR inx); -LispPTR N_OP_aset1(LispPTR data, LispPTR arrayarg, int inx); +LispPTR N_OP_aset1(LispPTR data, LispPTR arrayarg, LispPTR inx); LispPTR N_OP_aref2(LispPTR arrayarg, LispPTR inx0, LispPTR inx1); LispPTR N_OP_aset2(LispPTR data, LispPTR arrayarg, LispPTR inx0, LispPTR inx1); #endif diff --git a/inc/my.h b/inc/my.h index e090ad2..f193568 100644 --- a/inc/my.h +++ b/inc/my.h @@ -16,6 +16,7 @@ /* Manufactured in the United States of America. */ /* */ /************************************************************************/ +#include // for u_char #include "version.h" // for BIGVM #include "adr68k.h" // for NativeAligned2FromLAddr, NativeAligned4FromLAddr, LAddrFromNative #include "arith.h" // for N_ARITH_SWITCH, N_GETNUMBER @@ -62,33 +63,32 @@ (dest) = (arg) & 0xFFFF; \ else { \ if (GetTypeNumber(arg) != TYPE_FIXP) ERROR_EXIT(tos); \ - if (((dest) = *((int *)NativeAligned4FromLAddr(arg))) & 0x80000000) \ - ERROR_EXIT(tos); \ - } \ + (dest) = *((int *)NativeAligned4FromLAddr(arg)); \ + if ((unsigned)(dest) & 0x80000000) ERROR_EXIT(tos); \ + } \ } while (0) static inline LispPTR aref_switch(unsigned type, LispPTR tos, LispPTR baseL, int index) { - int result; - switch (type) { case 38: /* pointer : 32 bits */ return(*(((LispPTR *)NativeAligned4FromLAddr(baseL)) + index)); - case 20: /* signed : 16 bits */ - result = (GETWORD(((DLword *)NativeAligned2FromLAddr(baseL)) + index)) & 0xFFFF; + case 20: { /* signed : 16 bits */ + DLword result = (GETWORD(((DLword *)NativeAligned2FromLAddr(baseL)) + index)); if (result & 0x8000) return(result | S_NEGATIVE); else return(result | S_POSITIVE); + } case 67: /* Character : 8 bits */ return(S_CHARACTER | ((GETBYTE(((char *)NativeAligned2FromLAddr(baseL)) + index)) & 0xFF)); - case 22: /* signed : 32 bits */ - result = *(((int *)NativeAligned4FromLAddr(baseL)) + index); + case 22: {/* signed : 32 bits */ + int result = *(((int *)NativeAligned4FromLAddr(baseL)) + index); N_ARITH_SWITCH(result); - + } case 0: /* unsigned : 1 bit per element */ return(S_POSITIVE | (((GETBYTE(((char *)NativeAligned2FromLAddr(baseL)) + (index >> 3))) >> (7 - (index & 7))) & 1)); @@ -120,60 +120,72 @@ aref_switch(unsigned type, LispPTR tos, LispPTR baseL, int index) do { \ switch (type) { \ case 38: /* pointer : 32 bits */ \ - GCLOOKUP(*(((int *)NativeAligned4FromLAddr(base)) + index), DELREF); \ + GCLOOKUP(*(((LispPTR *)NativeAligned4FromLAddr(base)) + index), DELREF); \ GCLOOKUP(data, ADDREF); \ - *(((int *)NativeAligned4FromLAddr(base)) + index) = data; \ + *(((LispPTR *)NativeAligned4FromLAddr(base)) + index) = data; \ return(data); \ - case 20: /* signed : 16 bits */ \ - new = data & 0xFFFF; \ + case 20: { /* signed : 16 bits */ \ + DLword new = data & 0xFFFF; \ if ((((data & SEGMASK) == S_POSITIVE) && ((data & 0x8000) == 0)) ||\ (((data & SEGMASK) == S_NEGATIVE) && (data & 0x8000))) \ GETWORD(((DLword *)NativeAligned2FromLAddr(base)) + index) = new; \ else ERROR_EXIT(tos); \ return(data); \ - case 67: /* Character : 8 bits */ \ - if ((data & SEGMASK) != S_CHARACTER) ERROR_EXIT(tos); \ - new = data & 0xFFFF; \ + } \ + case 67: { /* Character : 8 bits */ \ + DLword new = data & 0xFFFF; \ + if ((data & SEGMASK) != S_CHARACTER) ERROR_EXIT(tos); \ if (new > 0xFF) ERROR_EXIT(tos); \ - GETBYTE(((char *)NativeAligned2FromLAddr(base)) + index) = new; \ + GETBYTE(((char *)NativeAligned2FromLAddr(base)) + index) = (u_char)new; \ return(data); \ - case 22: /* signed : 32 bits */ \ + } \ + case 22: { /* signed : 32 bits */ \ + int new; \ N_GETNUMBER(data, new, doufn); \ - *(((int *)NativeAligned4FromLAddr(base)) + index) = new; \ + *(((int *)NativeAligned4FromLAddr(base)) + index) = new; \ return(data); \ - case 0: /* unsigned : 1 bit per element */ \ + } \ + case 0: { /* unsigned : 1 bit per element */ \ + int new; \ N_GetPos(data, new, tos); \ if (new > 1) ERROR_EXIT(tos); \ if (new) { \ new = (1 << (7 - (index & 7))); \ - GETBYTE(((char *)NativeAligned2FromLAddr(base)) + (index >> 3)) |= new; \ + GETBYTE(((u_char *)NativeAligned2FromLAddr(base)) + (index >> 3)) |= (u_char)new; \ } \ else { \ new = 0xFF - (1 << (7 - (index & 7))); \ - GETBYTE(((char *)NativeAligned2FromLAddr(base)) + (index >> 3)) &= new; \ + GETBYTE(((u_char *)NativeAligned2FromLAddr(base)) + (index >> 3)) &= (u_char)new; \ } \ return(data); \ - case 3: /* unsigned : 8 bits per element */ \ + } \ + case 3: { /* unsigned : 8 bits per element */ \ + int new; \ N_GetPos(data, new, tos); \ if (new > 0xFF) ERROR_EXIT(tos); \ - GETBYTE(((char *)NativeAligned2FromLAddr(base)) + index) = new; \ + GETBYTE(((char *)NativeAligned2FromLAddr(base)) + index) = (u_char)new; \ return(data); \ - case 4: /* unsigned : 16 bits per element */ \ + } \ + case 4: { /* unsigned : 16 bits per element */ \ + int new; \ N_GetPos(data, new, tos); \ if (new > 0xFFFF) ERROR_EXIT(tos); \ - GETWORD(((DLword *)NativeAligned2FromLAddr(base)) + index) = new; \ + GETWORD(((DLword *)NativeAligned2FromLAddr(base)) + index) = (DLword)new; \ return(data); \ + } \ case 54: /* Float : 32 bits */ \ if (GetTypeNumber(data) != TYPE_FLOATP) ERROR_EXIT(tos); \ *(((int *)NativeAligned4FromLAddr(base)) + index) = *((int *)NativeAligned4FromLAddr(data)); \ return(data); \ - case 68: /* Character : 16 bits */ \ - if ((data & SEGMASK) != S_CHARACTER) ERROR_EXIT(tos); \ + case 68: {/* Character : 16 bits */ \ + DLword new; \ + if ((data & SEGMASK) != S_CHARACTER) ERROR_EXIT(tos); \ new = data & 0xFFFF; \ - GETWORD(((DLword *)NativeAligned2FromLAddr(base)) + index) = new; \ + GETWORD(((DLword *)NativeAligned2FromLAddr(base)) + index) = new; \ return(data); \ + } \ case 86: /* XPointer : 32 bits */ \ - *(((int *)NativeAligned4FromLAddr(base)) + index) = data; \ + *(((LispPTR *)NativeAligned4FromLAddr(base)) + index) = data; \ return(data); \ default: /* Illegal or Unimplemented */ \ ERROR_EXIT(tos); \ diff --git a/src/arrayops.c b/src/arrayops.c index 5ca2dd7..254b0ab 100644 --- a/src/arrayops.c +++ b/src/arrayops.c @@ -45,7 +45,7 @@ LispPTR N_OP_misc3(LispPTR baseL, LispPTR typenumber, LispPTR inx, int alpha) { N_GetPos(typenumber, type, inx); /* dispatch on type */ - return (aref_switch(type, inx, baseL, index)); + return (aref_switch((unsigned)type, inx, baseL, index)); } /* end N_OP_misc3() */ /************************************************************************/ @@ -58,9 +58,7 @@ LispPTR N_OP_misc3(LispPTR baseL, LispPTR typenumber, LispPTR inx, int alpha) { LispPTR N_OP_misc4(LispPTR data, LispPTR base, LispPTR typenumber, LispPTR inx, int alpha) { - int new; - int index; - int type; + int index, type; if (alpha != 7) ERROR_EXIT(inx); @@ -110,10 +108,9 @@ LispPTR N_OP_aref1(LispPTR arrayarg, LispPTR inx) { /* */ /************************************************************************/ -LispPTR N_OP_aset1(LispPTR data, LispPTR arrayarg, int inx) { +LispPTR N_OP_aset1(LispPTR data, LispPTR arrayarg, LispPTR inx) { OneDArray *arrayblk; LispPTR base; - int new; int index; /* verify array */ @@ -172,7 +169,6 @@ LispPTR N_OP_aref2(LispPTR arrayarg, LispPTR inx0, LispPTR inx1) { LispPTR N_OP_aset2(LispPTR data, LispPTR arrayarg, LispPTR inx0, LispPTR inx1) { LispArray *arrayblk; LispPTR base; - int new; int index, temp; int j;