Re: [Chicken-hackers] [PATCH] Simplify and correct C_SIXTY_FOUR check (fix #979)

2013-08-20 Thread Moritz Heidkamp
Peter Bex peter@xs4all.nl writes:
 I've tested this change on NetBSD/amd64 with GCC and LLVM/Clang,
 and on Linux/i386 with GCC.  I'd appreciate it if people on other
 platforms/compilers (especially Windows and OS X) could test this.

Since no further make check results came in we decided to push it
now. But keep the results coming anyway. You can just use the current
master version (37cf50fe7f4dd2335fa330ab9538d245f1f58a06) now.

Moritz

___
Chicken-hackers mailing list
Chicken-hackers@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-hackers


Re: [Chicken-hackers] [PATCH] Simplify and correct C_SIXTY_FOUR check (fix #979)

2013-08-18 Thread Jim Ursetto
On Aug 17, 2013, at 2:36 PM, Peter Bex peter@xs4all.nl wrote:

 I've tested this change on NetBSD/amd64 with GCC and LLVM/Clang,
 and on Linux/i386 with GCC.  I'd appreciate it if people on other
 platforms/compilers (especially Windows and OS X) could test this.

Works fine on 64-bit Mac OS X 10.8.3 with gcc and clang.

Jim


___
Chicken-hackers mailing list
Chicken-hackers@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-hackers


[Chicken-hackers] [PATCH] Simplify and correct C_SIXTY_FOUR check (fix #979)

2013-08-17 Thread Peter Bex
Hi all,

As has been pointed out in #979, our detection logic aronud the setting
of the C_SIXTY_FOUR macro (which indicates we're running on a 64-bit
machine) is a little iffy; it mixes up features, architectures and
operating systems and tries to say yep, this is a 64-bit machine
from that.  This check is broken at least for Windows, because it
checks for __MINGW64__, but of course that's not defined by MSVC or
Watcom C.

Here's a patch that simplifies this check.  While looking for the
correct way to do this, I've found a resource which may not be 100%
complete but is still useful: http://predef.sf.net - a list of
predefined compiler macros for a lot of platforms and systems.

According to its page about data models, __LP64__ is defined by
GCC and _LP64 is defined by HP aCC and SunW.
https://sourceforge.net/p/predef/wiki/DataModels/
Windows doesn't do this, but there we should have _WIN64 (which is LLP64):
https://sourceforge.net/p/predef/wiki/OperatingSystems/#windows

I've tested this change on NetBSD/amd64 with GCC and LLVM/Clang,
and on Linux/i386 with GCC.  I'd appreciate it if people on other
platforms/compilers (especially Windows and OS X) could test this.

According to https://sourceforge.net/p/predef/wiki/Endianness/
we should probably also revise our ENDIAN checks, but I don't quite
dare to attack that one yet.  Let's see how bad the fallout from
this change is, first.

Cheers,
Peter
-- 
http://www.more-magic.net
From c40d58b812d4022552a7b2b34575bf8e04682bf0 Mon Sep 17 00:00:00 2001
From: Peter Bex peter@xs4all.nl
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 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_MININT64_MIN
 #define C_S64_MAXINT64_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

___
Chicken-hackers mailing list
Chicken-hackers@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-hackers