~ chicken-core (chicken-5) 37cf50fe7f4dd2335fa330ab9538d245f1f58a06
commit 37cf50fe7f4dd2335fa330ab9538d245f1f58a06
Author: Peter Bex <peter.bex@xs4all.nl>
AuthorDate: Sat Aug 17 20:27:28 2013 +0200
Commit: Moritz Heidkamp <moritz@twoticketsplease.de>
CommitDate: Tue Aug 20 22:12:14 2013 +0200
Clean up 64-bit detection logic (fixes #979)
Affects C_SIXTY_FOUR and C_LLP. 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).
Signed-off-by: Moritz Heidkamp <moritz@twoticketsplease.de>
diff --git a/chicken.h b/chicken.h
index d828a668..044dddef 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 <time.h>
#include <math.h>
+/* This check is exceedingly strange */
#if !defined(C_NONUNIX) || defined(__MINGW32__) || defined(__WATCOMC__)
# include <unistd.h>
# include <inttypes.h>
@@ -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 c018f8bc..bc7d7d32 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;
Trap