1
0
mirror of https://github.com/Interlisp/maiko.git synced 2026-01-15 07:54:13 +00:00

Inline GetSmalldata and GetSmallp to improve type diagnostics, code, and readability in arith.h

This commit is contained in:
Nick Briggs 2022-08-14 16:52:17 -07:00
parent 1fe71e5b84
commit 813d2aa2b5

View File

@ -22,15 +22,22 @@
#define MAX_FIXP 2147483647 /* == 0x7FFFFFFF */
#define MIN_FIXP (-2147483648) /* == 0x80000000 */
#define GetSmalldata(x) \
(((SEGMASK & (x)) == S_POSITIVE) \
? (0xFFFF & (x)) \
: (((SEGMASK & (x)) == S_NEGATIVE) ? (0xFFFF0000 | (x)) : error("Not smallp address")))
static inline int GetSmalldata(LispPTR x) {
if ((SEGMASK & (int)x) == S_POSITIVE) return (int)(x & 0xFFFF);
if ((SEGMASK & (int)x) == S_NEGATIVE) return (int)(x | 0xFFFF0000);
error("Not smallp address");
return (0);
}
#define GetSmallp(x) \
((0xFFFF0000 & (x)) ? (((0xFFFF0000 & (x)) == 0xFFFF0000) ? (S_NEGATIVE | (0xFFFF & (x))) \
: error("Not Smallp data")) \
: (S_POSITIVE | (0xFFFF & (x))))
static inline LispPTR GetSmallp(int x) {
if (x >= 0) {
if (x <= MAX_SMALL) return (LispPTR)(S_POSITIVE | x);
} else {
if (x >= MIN_SMALL) return (LispPTR)(S_NEGATIVE | (x & 0xFFFF));
}
error("Not Smallp data");
return (S_POSITIVE | 0);
}
#define FIXP_VALUE(dest) *((int *)Addr68k_from_LADDR(dest))