1
0
mirror of https://github.com/Interlisp/maiko.git synced 2026-04-30 05:45:43 +00:00

Correct various warning: implicit conversion changes signedness (15)

Correct various warning: implicit conversion loses integer precision (30)

Correct parameter type declaration error for  N_OP_aset1()
Ensure that appropriate types and casts are used in aref_switch()
Remove requirement for declaring "int new" when using aset_switch() macro
This commit is contained in:
Nick Briggs
2023-01-08 19:27:04 -08:00
parent 7aca8bf599
commit c10d339036
3 changed files with 47 additions and 39 deletions

View File

@@ -4,7 +4,7 @@
LispPTR N_OP_misc3(LispPTR baseL, LispPTR typenumber, LispPTR inx, int alpha); 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_misc4(LispPTR data, LispPTR base, LispPTR typenumber, LispPTR inx, int alpha);
LispPTR N_OP_aref1(LispPTR arrayarg, LispPTR inx); 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_aref2(LispPTR arrayarg, LispPTR inx0, LispPTR inx1);
LispPTR N_OP_aset2(LispPTR data, LispPTR arrayarg, LispPTR inx0, LispPTR inx1); LispPTR N_OP_aset2(LispPTR data, LispPTR arrayarg, LispPTR inx0, LispPTR inx1);
#endif #endif

View File

@@ -16,6 +16,7 @@
/* Manufactured in the United States of America. */ /* Manufactured in the United States of America. */
/* */ /* */
/************************************************************************/ /************************************************************************/
#include <sys/types.h> // for u_char
#include "version.h" // for BIGVM #include "version.h" // for BIGVM
#include "adr68k.h" // for NativeAligned2FromLAddr, NativeAligned4FromLAddr, LAddrFromNative #include "adr68k.h" // for NativeAligned2FromLAddr, NativeAligned4FromLAddr, LAddrFromNative
#include "arith.h" // for N_ARITH_SWITCH, N_GETNUMBER #include "arith.h" // for N_ARITH_SWITCH, N_GETNUMBER
@@ -62,33 +63,32 @@
(dest) = (arg) & 0xFFFF; \ (dest) = (arg) & 0xFFFF; \
else { \ else { \
if (GetTypeNumber(arg) != TYPE_FIXP) ERROR_EXIT(tos); \ if (GetTypeNumber(arg) != TYPE_FIXP) ERROR_EXIT(tos); \
if (((dest) = *((int *)NativeAligned4FromLAddr(arg))) & 0x80000000) \ (dest) = *((int *)NativeAligned4FromLAddr(arg)); \
ERROR_EXIT(tos); \ if ((unsigned)(dest) & 0x80000000) ERROR_EXIT(tos); \
} \ } \
} while (0) } while (0)
static inline LispPTR static inline LispPTR
aref_switch(unsigned type, LispPTR tos, LispPTR baseL, int index) aref_switch(unsigned type, LispPTR tos, LispPTR baseL, int index)
{ {
int result;
switch (type) switch (type)
{ {
case 38: /* pointer : 32 bits */ case 38: /* pointer : 32 bits */
return(*(((LispPTR *)NativeAligned4FromLAddr(baseL)) + index)); return(*(((LispPTR *)NativeAligned4FromLAddr(baseL)) + index));
case 20: /* signed : 16 bits */ case 20: { /* signed : 16 bits */
result = (GETWORD(((DLword *)NativeAligned2FromLAddr(baseL)) + index)) & 0xFFFF; DLword result = (GETWORD(((DLword *)NativeAligned2FromLAddr(baseL)) + index));
if (result & 0x8000) return(result | S_NEGATIVE); if (result & 0x8000) return(result | S_NEGATIVE);
else return(result | S_POSITIVE); else return(result | S_POSITIVE);
}
case 67: /* Character : 8 bits */ case 67: /* Character : 8 bits */
return(S_CHARACTER | ((GETBYTE(((char *)NativeAligned2FromLAddr(baseL)) + index)) & 0xFF)); return(S_CHARACTER | ((GETBYTE(((char *)NativeAligned2FromLAddr(baseL)) + index)) & 0xFF));
case 22: /* signed : 32 bits */ case 22: {/* signed : 32 bits */
result = *(((int *)NativeAligned4FromLAddr(baseL)) + index); int result = *(((int *)NativeAligned4FromLAddr(baseL)) + index);
N_ARITH_SWITCH(result); N_ARITH_SWITCH(result);
}
case 0: /* unsigned : 1 bit per element */ case 0: /* unsigned : 1 bit per element */
return(S_POSITIVE | (((GETBYTE(((char *)NativeAligned2FromLAddr(baseL)) + (index >> 3))) >> (7 - (index & 7))) & 1)); 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 { \ do { \
switch (type) { \ switch (type) { \
case 38: /* pointer : 32 bits */ \ case 38: /* pointer : 32 bits */ \
GCLOOKUP(*(((int *)NativeAligned4FromLAddr(base)) + index), DELREF); \ GCLOOKUP(*(((LispPTR *)NativeAligned4FromLAddr(base)) + index), DELREF); \
GCLOOKUP(data, ADDREF); \ GCLOOKUP(data, ADDREF); \
*(((int *)NativeAligned4FromLAddr(base)) + index) = data; \ *(((LispPTR *)NativeAligned4FromLAddr(base)) + index) = data; \
return(data); \ return(data); \
case 20: /* signed : 16 bits */ \ case 20: { /* signed : 16 bits */ \
new = data & 0xFFFF; \ DLword new = data & 0xFFFF; \
if ((((data & SEGMASK) == S_POSITIVE) && ((data & 0x8000) == 0)) ||\ if ((((data & SEGMASK) == S_POSITIVE) && ((data & 0x8000) == 0)) ||\
(((data & SEGMASK) == S_NEGATIVE) && (data & 0x8000))) \ (((data & SEGMASK) == S_NEGATIVE) && (data & 0x8000))) \
GETWORD(((DLword *)NativeAligned2FromLAddr(base)) + index) = new; \ GETWORD(((DLword *)NativeAligned2FromLAddr(base)) + index) = new; \
else ERROR_EXIT(tos); \ else ERROR_EXIT(tos); \
return(data); \ return(data); \
case 67: /* Character : 8 bits */ \ } \
if ((data & SEGMASK) != S_CHARACTER) ERROR_EXIT(tos); \ case 67: { /* Character : 8 bits */ \
new = data & 0xFFFF; \ DLword new = data & 0xFFFF; \
if ((data & SEGMASK) != S_CHARACTER) ERROR_EXIT(tos); \
if (new > 0xFF) 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); \ return(data); \
case 22: /* signed : 32 bits */ \ } \
case 22: { /* signed : 32 bits */ \
int new; \
N_GETNUMBER(data, new, doufn); \ N_GETNUMBER(data, new, doufn); \
*(((int *)NativeAligned4FromLAddr(base)) + index) = new; \ *(((int *)NativeAligned4FromLAddr(base)) + index) = new; \
return(data); \ return(data); \
case 0: /* unsigned : 1 bit per element */ \ } \
case 0: { /* unsigned : 1 bit per element */ \
int new; \
N_GetPos(data, new, tos); \ N_GetPos(data, new, tos); \
if (new > 1) ERROR_EXIT(tos); \ if (new > 1) ERROR_EXIT(tos); \
if (new) { \ if (new) { \
new = (1 << (7 - (index & 7))); \ new = (1 << (7 - (index & 7))); \
GETBYTE(((char *)NativeAligned2FromLAddr(base)) + (index >> 3)) |= new; \ GETBYTE(((u_char *)NativeAligned2FromLAddr(base)) + (index >> 3)) |= (u_char)new; \
} \ } \
else { \ else { \
new = 0xFF - (1 << (7 - (index & 7))); \ 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); \ return(data); \
case 3: /* unsigned : 8 bits per element */ \ } \
case 3: { /* unsigned : 8 bits per element */ \
int new; \
N_GetPos(data, new, tos); \ N_GetPos(data, new, tos); \
if (new > 0xFF) 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); \ return(data); \
case 4: /* unsigned : 16 bits per element */ \ } \
case 4: { /* unsigned : 16 bits per element */ \
int new; \
N_GetPos(data, new, tos); \ N_GetPos(data, new, tos); \
if (new > 0xFFFF) ERROR_EXIT(tos); \ if (new > 0xFFFF) ERROR_EXIT(tos); \
GETWORD(((DLword *)NativeAligned2FromLAddr(base)) + index) = new; \ GETWORD(((DLword *)NativeAligned2FromLAddr(base)) + index) = (DLword)new; \
return(data); \ return(data); \
} \
case 54: /* Float : 32 bits */ \ case 54: /* Float : 32 bits */ \
if (GetTypeNumber(data) != TYPE_FLOATP) ERROR_EXIT(tos); \ if (GetTypeNumber(data) != TYPE_FLOATP) ERROR_EXIT(tos); \
*(((int *)NativeAligned4FromLAddr(base)) + index) = *((int *)NativeAligned4FromLAddr(data)); \ *(((int *)NativeAligned4FromLAddr(base)) + index) = *((int *)NativeAligned4FromLAddr(data)); \
return(data); \ return(data); \
case 68: /* Character : 16 bits */ \ case 68: {/* Character : 16 bits */ \
if ((data & SEGMASK) != S_CHARACTER) ERROR_EXIT(tos); \ DLword new; \
if ((data & SEGMASK) != S_CHARACTER) ERROR_EXIT(tos); \
new = data & 0xFFFF; \ new = data & 0xFFFF; \
GETWORD(((DLword *)NativeAligned2FromLAddr(base)) + index) = new; \ GETWORD(((DLword *)NativeAligned2FromLAddr(base)) + index) = new; \
return(data); \ return(data); \
} \
case 86: /* XPointer : 32 bits */ \ case 86: /* XPointer : 32 bits */ \
*(((int *)NativeAligned4FromLAddr(base)) + index) = data; \ *(((LispPTR *)NativeAligned4FromLAddr(base)) + index) = data; \
return(data); \ return(data); \
default: /* Illegal or Unimplemented */ \ default: /* Illegal or Unimplemented */ \
ERROR_EXIT(tos); \ ERROR_EXIT(tos); \

View File

@@ -45,7 +45,7 @@ LispPTR N_OP_misc3(LispPTR baseL, LispPTR typenumber, LispPTR inx, int alpha) {
N_GetPos(typenumber, type, inx); N_GetPos(typenumber, type, inx);
/* dispatch on type */ /* dispatch on type */
return (aref_switch(type, inx, baseL, index)); return (aref_switch((unsigned)type, inx, baseL, index));
} /* end N_OP_misc3() */ } /* 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 N_OP_misc4(LispPTR data, LispPTR base, LispPTR typenumber,
LispPTR inx, int alpha) { LispPTR inx, int alpha) {
int new; int index, type;
int index;
int type;
if (alpha != 7) ERROR_EXIT(inx); 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; OneDArray *arrayblk;
LispPTR base; LispPTR base;
int new;
int index; int index;
/* verify array */ /* 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) { LispPTR N_OP_aset2(LispPTR data, LispPTR arrayarg, LispPTR inx0, LispPTR inx1) {
LispArray *arrayblk; LispArray *arrayblk;
LispPTR base; LispPTR base;
int new;
int index, temp; int index, temp;
int j; int j;