public inbox for libffi-discuss@sourceware.org
 help / color / mirror / Atom feed
* Mozilla bug# 545634 : Make the header compile on AIX with IBM XLC/C++ compiler
@ 2011-02-03 13:05 Uli Link
  2011-02-03 14:38 ` Anthony Green
  0 siblings, 1 reply; 2+ messages in thread
From: Uli Link @ 2011-02-03 13:05 UTC (permalink / raw)
  To: libffi-discuss; +Cc: dwitte

[-- Attachment #1: Type: text/plain, Size: 812 bytes --]

Dan Witte of Mozilla advised me to also push this patch back upstream.

libffi can easily compiled with GCC 4.x.x but Mozilla products must use 
the native IBM compiler on AIX.
So the header ffi.h must use properly type suffixed literals as the IBM 
compiler assume int32_t as size for unsuffixed literals so the 64bit 
comparison will fail, even if there is a int64_t on 32bit AIX5 (and 
later). When compiling in 64bit mode literals are also assumed 32bit max.

Reference:
<https://bugzilla.mozilla.org/show_bug.cgi?id=545634>
where most of the patch is for building only the libffi lib with GCC and 
else use XLC/C++ compiler on AIX.

The patch is tested with Firefox 3.6.13/3.6.14 and Thunderbird 3.1.7/3.1.8


With kind regards from Germany
-- 
Uli Link
Arnimstr. 8
D-81369 Munich
mailto: ulink@linkitup.de

[-- Attachment #2: libffi-aix5-ibm-xlc.patch --]
[-- Type: text/plain, Size: 2481 bytes --]

diff -r 9521cf441d3a libffi/include/ffi.h.in
--- a/libffi/include/ffi.h.in	Tue Feb 01 13:53:53 2011 -0600
+++ b/libffi/include/ffi.h.in	Thu Feb 03 13:49:13 2011 +0100
@@ -72,25 +72,37 @@ extern "C" {
 #endif
 
 #include <stddef.h>
 #include <limits.h>
 
 /* LONG_LONG_MAX is not always defined (not if STRICT_ANSI, for example).
    But we can find it either under the correct ANSI name, or under GNU
    C's internal name.  */
+
+#define FFI_64_BIT_MAX 9223372036854775807
+
 #ifdef LONG_LONG_MAX
 # define FFI_LONG_LONG_MAX LONG_LONG_MAX
 #else
 # ifdef LLONG_MAX
 #  define FFI_LONG_LONG_MAX LLONG_MAX
 # else
 #  ifdef __GNUC__
 #   define FFI_LONG_LONG_MAX __LONG_LONG_MAX__
 #  endif
+#  ifdef _AIX
+#   ifndef __PPC64__
+#    if defined (__IBMC__) || defined (__IBMCPP__)
+#     define FFI_LONG_LONG_MAX LONGLONG_MAX
+#    endif
+#   endif /* __PPC64__ */
+#   undef  FFI_64_BIT_MAX
+#   define FFI_64_BIT_MAX 9223372036854775807LL
+#  endif
 # endif
 #endif
 
 /* The closure code assumes that this works on pointers, i.e. a size_t	*/
 /* can hold a pointer.							*/
 
 typedef struct _ffi_type
 {
@@ -127,27 +139,27 @@ typedef struct _ffi_type
 #elif INT_MAX == 9223372036854775807
 # define ffi_type_uint         ffi_type_uint64
 # define ffi_type_sint         ffi_type_sint64
 #else
  #error "int size not supported"
 #endif
 
 #if LONG_MAX == 2147483647
-# if FFI_LONG_LONG_MAX != 9223372036854775807
+# if FFI_LONG_LONG_MAX != FFI_64_BIT_MAX
  #error "no 64-bit data type supported"
 # endif
-#elif LONG_MAX != 9223372036854775807
+#elif LONG_MAX != FFI_64_BIT_MAX
  #error "long size not supported"
 #endif
 
 #if LONG_MAX == 2147483647
 # define ffi_type_ulong        ffi_type_uint32
 # define ffi_type_slong        ffi_type_sint32
-#elif LONG_MAX == 9223372036854775807
+#elif LONG_MAX == FFI_64_BIT_MAX
 # define ffi_type_ulong        ffi_type_uint64
 # define ffi_type_slong        ffi_type_sint64
 #else
  #error "long size not supported"
 #endif
 
 /* These are defined in types.c */
 extern ffi_type ffi_type_void;
@@ -190,17 +202,17 @@ typedef struct {
 #endif
 } ffi_cif;
 
 /* ---- Definitions for the raw API -------------------------------------- */
 
 #ifndef FFI_SIZEOF_ARG
 # if LONG_MAX == 2147483647
 #  define FFI_SIZEOF_ARG        4
-# elif LONG_MAX == 9223372036854775807
+# elif LONG_MAX == FFI_64_BIT_MAX
 #  define FFI_SIZEOF_ARG        8
 # endif
 #endif
 
 #ifndef FFI_SIZEOF_JAVA_RAW
 #  define FFI_SIZEOF_JAVA_RAW FFI_SIZEOF_ARG
 #endif
 

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Mozilla bug# 545634 : Make the header compile on AIX with IBM XLC/C++ compiler
  2011-02-03 13:05 Mozilla bug# 545634 : Make the header compile on AIX with IBM XLC/C++ compiler Uli Link
@ 2011-02-03 14:38 ` Anthony Green
  0 siblings, 0 replies; 2+ messages in thread
From: Anthony Green @ 2011-02-03 14:38 UTC (permalink / raw)
  To: Uli Link; +Cc: libffi-discuss, dwitte

Uli Link <ul.mcamafia@linkitup.de> writes:

> Dan Witte of Mozilla advised me to also push this patch back upstream.

Thanks Uli.  It looks fine -- I'll merge it in.

AG


>
> libffi can easily compiled with GCC 4.x.x but Mozilla products must
> use the native IBM compiler on AIX.
> So the header ffi.h must use properly type suffixed literals as the
> IBM compiler assume int32_t as size for unsuffixed literals so the
> 64bit comparison will fail, even if there is a int64_t on 32bit AIX5
> (and later). When compiling in 64bit mode literals are also assumed
> 32bit max.
>
> Reference:
> <https://bugzilla.mozilla.org/show_bug.cgi?id=545634>
> where most of the patch is for building only the libffi lib with GCC
> and else use XLC/C++ compiler on AIX.
>
> The patch is tested with Firefox 3.6.13/3.6.14 and Thunderbird 3.1.7/3.1.8
>
>
> With kind regards from Germany

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-02-03 14:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-03 13:05 Mozilla bug# 545634 : Make the header compile on AIX with IBM XLC/C++ compiler Uli Link
2011-02-03 14:38 ` Anthony Green

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).