>From c40d58b812d4022552a7b2b34575bf8e04682bf0 Mon Sep 17 00:00:00 2001 From: Peter Bex Date: Sat, 17 Aug 2013 20:27:28 +0200 Subject: [PATCH] Clean up 64-bit detection logic, for C_SIXTY_FOUR and C_LLP (fixes #979) Also add some notes about C_NONUNIX being misleading and the check around unistd.h, inttypes.h and sys/types being very unsemantical (it's completely unclear what's being checked there). --- chicken.h | 21 +++++++++------------ runtime.c | 1 + 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/chicken.h b/chicken.h index d828a66..044ddde 100644 --- a/chicken.h +++ b/chicken.h @@ -61,16 +61,8 @@ /* Kind of platform */ -#ifndef C_SIXTY_FOUR -# if defined (__alpha__) || defined(__ia64__) || defined(__x86_64__) || defined(__LP64__) || defined(__powerpc64__) -# define C_SIXTY_FOUR -# elif (defined(__sparc_v9__) || defined(__sparcv9)) && defined(__arch64__) -# define C_SIXTY_FOUR -# elif defined(__mips64) && (!defined(__GNUC__) || _MIPS_SZPTR == 64) -# define C_SIXTY_FOUR -# elif defined(__MINGW64__) -# define C_SIXTY_FOUR -# endif +#if defined(__LP64__) || defined(_LP64) || defined(__MINGW64__) || defined(_WIN64) +# define C_SIXTY_FOUR #endif #if defined(__APPLE__) && defined(__MACH__) @@ -86,6 +78,10 @@ #endif #if defined(__MINGW32__) || defined(__WATCOMC__) || defined(__MWERKS__) +/* + * XXX This should probably be renamed or changed because it's misleading. + * For example, Haiku is not a Unix either, but this doesn't get defined there. + */ # define C_NONUNIX #endif @@ -93,7 +89,7 @@ # define C_SOLARIS #endif -#ifdef __MINGW64__ +#if defined(__MINGW64__) || defined(_WIN64) # define C_LLP #endif @@ -110,6 +106,7 @@ #include #include +/* This check is exceedingly strange */ #if !defined(C_NONUNIX) || defined(__MINGW32__) || defined(__WATCOMC__) # include # include @@ -556,7 +553,7 @@ static inline int isinf_ld (long double x) #define C_S64_MIN INT64_MIN #define C_S64_MAX INT64_MAX -#if defined(C_LLP) && defined(C_SIXTY_FOUR) +#if defined(C_LLP) # define C_long C_s64 # ifndef LONG_LONG_MAX # define C_LONG_MAX LLONG_MAX diff --git a/runtime.c b/runtime.c index c018f8b..bc7d7d3 100644 --- a/runtime.c +++ b/runtime.c @@ -6074,6 +6074,7 @@ void C_ccall C_apply(C_word c, C_word closure, C_word k, C_word fn, ...) /* 3 additional args + 1 slot for stack-pointer + two for stack-alignment to 16 bytes */ buf = alloca((n + 6) * sizeof(C_word)); # ifdef __x86_64__ + /* XXX Shouldn't this check for C_SIXTY_FOUR in general? */ buf = (void *)C_align16((C_uword)buf); # endif buf[ 0 ] = n + 2; -- 1.8.2.3