From d4226c20f2873364504b3a2eb16479ef3170d62d Mon Sep 17 00:00:00 2001 From: Nick Briggs Date: Thu, 1 Sep 2022 14:11:54 -0700 Subject: [PATCH] Replace Addr68k related macros with NativeAligned inline functions Addr68k_from_LADDR always produced a 2-byte aligned pointer which was frequently cast to a type requiring 4-byte alignment. This commit changes Addr68k_from_LADDR uses to one of two new inline procedures, NativeAligned2FromLAddr or NativeAligned4FromLAddr, which produce a result with the appropriate alignment for the context. This permits checking for cases where the Lisp address is not appropriately aligned for the usage context, and localizes compiler warnings to these two procedures. Similarly, the Addr68k_from_StkOffset macros are replaced by NativeAligned2FromStackOffset and NativeAligned4FromStackOffset. NativeAligned4FromLPage replaces Addr68k_from_LPAGE as page address will always be at least 4-byte aligned. LAddrFromNative, LPageFromNative, and StackOffsetFromNative complete the set, replacing LADDR_from_68k, LPAGE_from_68k, and StkOffset_from_68K (note K not k) respectively. --- inc/adr68k.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/inc/adr68k.h b/inc/adr68k.h index faa31e4..4582889 100644 --- a/inc/adr68k.h +++ b/inc/adr68k.h @@ -59,10 +59,10 @@ static inline LispPTR *NativeAligned4FromLPage(LispPTR LPage) return (LispPTR *)(Lisp_world + (LPage << 8)); } -static inline DLword StackOffsetFromNative(DLword *SAddr) +static inline DLword StackOffsetFromNative(void *SAddr) { /* Stack offsets are expressed as an offset in DLwords from the stack base */ - ptrdiff_t hoffset = SAddr - Stackspace; + ptrdiff_t hoffset = (DLword *)SAddr - Stackspace; if (hoffset > 0xffff) { printf("Stack offset is too large: 0x%tx\n", hoffset); }