From 0343c6f32c5bd8335e88595cb9d23506625b2586 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Mon, 12 Jan 2015 22:33:32 -0800 Subject: Fix for LLVM wchar_t literals not being four byte aligned, affecting OS X port. * configure: Detect a SIZEOF_WCHAR_T when detecting integer type that will hold a pointer. In the lit_align test, if we are on Apple Mac OSX, use a lit_align of 2, so the logic kicks in for padding literals and handling misalignment. * lib.h (litptr): Add a case for LIT_ALIGN < 4 and SIZEOF_WCHAR_T == 4. In this case we do the arithmetic on the pointer using short *, and then convert to wchar_t. * HACKING: New section 2.4.3 about new wchar_t hack. --- lib.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lib.h') diff --git a/lib.h b/lib.h index a95c2e3f..e55a3516 100644 --- a/lib.h +++ b/lib.h @@ -327,9 +327,12 @@ INLINE val static_str(const wchli_t *str) INLINE wchar_t *litptr(val obj) { -#if LIT_ALIGN < 4 +#if LIT_ALIGN < 4 && SIZEOF_WCHAR_T < 4 wchar_t *ret = coerce(wchar_t *, (coerce(cnum, obj) & ~TAG_MASK)); return (*ret == 0) ? ret + 1 : ret; +#elif LIT_ALIGN < 4 && SIZEOF_WCHAR_T == 4 + short *ret = coerce(short *, (coerce(cnum, obj) & ~TAG_MASK)); + return coerce(wchar_t *, (*ret == 0) ? ret + 1 : ret); #else return coerce(wchar_t *, coerce(cnum, obj) & ~TAG_MASK); #endif -- cgit v1.2.3