File antlr-64bit.diff of Package antlr3c

Date: 2014-08-17 03:38:36.721411308 +0200
From: Jan Engelhardt <jengelh@inai.de>

Do not unconditionally add _ANY_ -m32/-m64 onto the command line.
Instead, default to what the compiler uses (which may be influenced
by the user thorugh CFLAGS).

Use uintptr_t instead of guessing the size of pointers, which is a
lot more portable than this type mess.

With this done, one can see that USE_64BIT reduces to a choice of
size model which seems independent of pointer size.

---
 configure.ac         |   12 +++++++-----
 include/antlr3defs.h |   12 ++++++------
 2 files changed, 13 insertions(+), 11 deletions(-)

Index: libantlr3c-3.4/configure.ac
===================================================================
--- libantlr3c-3.4.orig/configure.ac
+++ libantlr3c-3.4/configure.ac
@@ -40,8 +40,8 @@ AC_ARG_ENABLE([debuginfo],
 		[], [enable_debuginfo=no])
 
 AC_ARG_ENABLE([64bit],
-		[AS_HELP_STRING([--enable-64bit], [Turns on flags that produce 64 bit object code if any are required (default --disable-64bit)])],
-		[], [enable_64bit=no])
+		[AS_HELP_STRING([--enable-64bit], [Turns on flags that produce 64 bit object code if any are required (default: use compiler default)])],
+		[enable_64bit="$enableval"], [enable_64bit="auto"])
 
 AC_ARG_ENABLE([abiflags],
 		[AS_HELP_STRING([--disable-abiflags], [Does not add ABI flags -m32 or -m64 for older versions of gcc, such as itanium 3.x (default --enable-abiflags=yes)])],
@@ -70,7 +70,7 @@ xlc*)
  if test x"$enable_64bit" = xyes; then
   CCFLAGS64="-q64 -Wl,-b64"
   OBJECT_MODE="64"
- else
+ elif test x"$enable_64bit" = xno; then
   OBJECT_MODE="32"
  fi
  OPTIMFLAGS="-O2"
@@ -94,7 +94,7 @@ gcc*)
  CPPCMNTFLAGS=
  if test x"$enable_64bit" = xyes; then
   GCCABIFLAGS="-m64"
- else
+ elif test x"$enable_64bit" = xno; then
   GCCABIFLAGS="-m32"
  fi
  if test x"$enable_abiflags" = xyes; then
@@ -139,7 +139,9 @@ AC_MSG_RESULT([$CFLAGS])
 AC_SUBST([OBJECT_MODE])
 
 AS_IF([test "x$enable_antlrdebug" = xno], [AC_DEFINE([ANTLR3_NODEBUGGER], [1], [Define if ANTLR debugger not required])], [])
-AS_IF([test x"$enable_64bit" = xyes], [AC_DEFINE([ANTLR3_USE_64BIT], [1], [Define if 64 bit mode required])], [])
+AC_CHECK_SIZEOF([void *])
+AC_CHECK_SIZEOF([long])
+AS_IF([test "$ac_cv_sizeof_void_p" = "$ac_cv_sizeof_long"], [AC_DEFINE([ANTLR3_USE_64BIT], [1], [Define if 64 bit model wanted])], [])
 
 AC_PROG_INSTALL
 AC_PROG_LN_S
Index: libantlr3c-3.4/include/antlr3defs.h
===================================================================
--- libantlr3c-3.4.orig/include/antlr3defs.h
+++ libantlr3c-3.4/include/antlr3defs.h
@@ -414,15 +414,15 @@ typedef FILE *	    ANTLR3_FDSC;
 typedef	struct stat ANTLR3_FSTAT_STRUCT;
 
 #ifdef	ANTLR3_USE_64BIT
-#define	ANTLR3_FUNC_PTR(ptr)    (void *)((ANTLR3_UINT64)(ptr))
-#define ANTLR3_UINT64_CAST(ptr)	(ANTLR3_UINT64)(ptr))
-#define	ANTLR3_UINT32_CAST(ptr) (ANTLR3_UINT32)((ANTLR3_UINT64)(ptr))
+#define	ANTLR3_FUNC_PTR(ptr)    ((void *)(uintptr_t)(ptr))
+#define ANTLR3_UINT64_CAST(ptr)	((ANTLR3_UINT64)(uintptr_t)(ptr))
+#define	ANTLR3_UINT32_CAST(ptr) ((ANTLR3_UINT32)(uintptr_t)(ptr))
 typedef ANTLR3_INT64		ANTLR3_MARKER;
 typedef ANTLR3_UINT64		ANTLR3_INTKEY;
 #else
-#define	ANTLR3_FUNC_PTR(ptr)	(void *)((ANTLR3_UINT32)(ptr))
-#define ANTLR3_UINT64_CAST(ptr) (ANTLR3_UINT64)((ANTLR3_UINT32)(ptr))
-#define	ANTLR3_UINT32_CAST(ptr)	(ANTLR3_UINT32)(ptr)
+#define	ANTLR3_FUNC_PTR(ptr)	((void *)(uintptr_t)(ptr))
+#define ANTLR3_UINT64_CAST(ptr) ((ANTLR3_UINT64)(uintptr_t)(ptr))
+#define	ANTLR3_UINT32_CAST(ptr)	((ANTLR3_UINT32)(uintptr_t)(ptr))
 typedef	ANTLR3_INT32		ANTLR3_MARKER;
 typedef ANTLR3_UINT32		ANTLR3_INTKEY;
 #endif