This is the mail archive of the libffi-discuss@sourceware.org mailing list for the libffi project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: IRIX/MIPSPro build of libffi 3.0.8, patches included


Frank Everdij wrote:
Hi libffi maintainers,
Thanks for the patch.

I plan on getting libffi 3.0.9 rc2 out sometime between Sunday and Tuesday, and will be sure to include this. Could you please send me a ChangeLog entry?

Thanks,

AG



I managed to compile libffi-3.0.8 on my SGI Origin 200 with IRIX 6.5.30m
and MIPSPro compiler 7.4.4m, MIPSEB N32 ABI

Initially libffi 1.2 was compiled on older IRIX systems, but apparently
lack of interest prevented the IRIX port from being maintained into the
3.x era.

I took up the job of compiling Python 3.1 on IRIX platforms, since
Blender 2.5 3D modelling package will depend on it, and got stuck in
Python's own subbuild of libffi. So i have set the task of trying to
compile libffi-3.0.8 for IRIX systems once again, to produce a working
Python 3.1.

Fortunately i can say that i've succeeded. The output of gmake test is:

=== libffi Summary ===

# of expected passes            1373
# of unexpected failures        8
# of unsupported tests          15

The 8 failures are related to the C++ code where exception handling is
being tested. Apparently the IRIX AS compiler does not issue the correct
DWARF exception handling section yet.

Also, long double support is functional. One of Python's regression
tests picked out the alignment problem of long double return value so i
fixed that aswell.

I've made care to not disturb the MIPSEL build by issuing #ifdef linux
for linux specific code and #ifdef __sgi for IRIX specific code.
Also i had to fix certain Gnu'isms via ifdef __GNUC__ since MIPSPro
doesn't handle f.i. the __attribute__ extension.

I've included this patch below the message, since i do not know if the
ezmlm is able to handle attachments.


I hope this can still be included in the 3.0.9 build of libffi. Let me
know if there are issues.

Yours

Frank
8<----------------------
--- src/mips/n32.S.save Fri Sep 25 11:23:22 2009
+++ src/mips/n32.S Fri Sep 25 13:06:33 2009
@@ -40,7 +40,9 @@
#define SIZEOF_FRAME ( 8 * FFI_SIZEOF_ARG )
+#ifdef linux
.abicalls
+#endif
.text
.align 2
.globl ffi_call_N32
@@ -474,6 +476,7 @@
.LFE2:
.end ffi_closure_N32
+#ifdef linux
.section .eh_frame,"aw",@progbits
.Lframe1:
.4byte .LECIE1-.LSCIE1 # length
@@ -530,5 +533,6 @@
.uleb128 (SIZEOF_FRAME2 - RA_OFF2)/4
.align EH_FRAME_ALIGN
.LEFDE3:
+#endif /* linux */

#endif
--- src/mips/ffi.c.save Tue Feb 26 09:34:36 2008
+++ src/mips/ffi.c Tue Oct 6 21:22:27 2009
@@ -684,9 +684,10 @@
{
if (i < 2 && !seen_int &&
(arg_types[i]->type == FFI_TYPE_FLOAT ||
- arg_types[i]->type == FFI_TYPE_DOUBLE))
+ arg_types[i]->type == FFI_TYPE_DOUBLE || + arg_types[i]->type == FFI_TYPE_LONGDOUBLE))
{
-#ifdef __MIPSEB__
+#if defined(__MIPSEB__) || defined(_MIPSEB)
if (arg_types[i]->type == FFI_TYPE_FLOAT)
avaluep[i] = ((char *) &fpr[i]) + sizeof (float);
else
@@ -839,10 +840,16 @@
while (i < avn)
{
if (arg_types[i]->type == FFI_TYPE_FLOAT
- || arg_types[i]->type == FFI_TYPE_DOUBLE)
+ || arg_types[i]->type == FFI_TYPE_DOUBLE
+ || arg_types[i]->type == FFI_TYPE_LONGDOUBLE)
{
ffi_arg *argp = argn >= 8 ? ar + argn : fpr + argn;
-#ifdef __MIPSEB__
+ if ((arg_types[i]->type == FFI_TYPE_LONGDOUBLE) && ((unsigned)argp & (arg_types[i]->alignment-1)))
+ {
+ argp=(ffi_arg*)ALIGN(argp,arg_types[i]->alignment);
+ argn++;
+ }
+#if defined(__MIPSEB__) || defined(_MIPSEB)
if (arg_types[i]->type == FFI_TYPE_FLOAT && argn < 8)
avaluep[i] = ((char *) argp) + sizeof (float);
else
--- src/mips/ffitarget.h.save Fri Sep 25 11:37:29 2009
+++ src/mips/ffitarget.h Fri Sep 25 11:58:27 2009
@@ -28,7 +28,10 @@
#define LIBFFI_TARGET_H
#ifdef linux
-#include <asm/sgidefs.h>
+# include <asm/sgidefs.h>
+#else
+# include <sgidefs.h>
+#endif
# ifndef _ABIN32
# define _ABIN32 _MIPS_SIM_NABI32
# endif
@@ -38,7 +41,6 @@
# ifndef _ABIO32
# define _ABIO32 _MIPS_SIM_ABI32
# endif
-#endif
#if !defined(_MIPS_SIM)
-- something is very wrong --
@@ -145,7 +147,8 @@
# endif /* _MIPS_SIM==_ABI64 */
#endif /* !FFI_MIPS_O32 */
#else /* !LIBFFI_ASM */
-#ifdef FFI_MIPS_O32
+# ifdef __GNUC__
+# ifdef FFI_MIPS_O32
/* O32 stack frames have 32bit integer args */
typedef unsigned int ffi_arg __attribute__((__mode__(__SI__)));
typedef signed int ffi_sarg __attribute__((__mode__(__SI__)));
@@ -153,7 +156,18 @@
/* N32 and N64 frames have 64bit integer args */
typedef unsigned int ffi_arg __attribute__((__mode__(__DI__)));
typedef signed int ffi_sarg __attribute__((__mode__(__DI__)));
-#endif
+# endif
+# else
+# ifdef FFI_MIPS_O32
+/* O32 stack frames have 32bit integer args */
+typedef __uint32_t ffi_arg;
+typedef __int32_t ffi_sarg;
+# else
+/* N32 and N64 frames have 64bit integer args */
+typedef __uint64_t ffi_arg;
+typedef __int64_t ffi_sarg;
+# endif
+# endif /* __GNUC__ */
typedef enum ffi_abi {
FFI_FIRST_ABI = 0,
--- include/ffi_common.h.save Wed Sep 9 20:59:10 2009
+++ include/ffi_common.h Fri Sep 25 11:53:48 2009
@@ -77,6 +77,7 @@
} extended_cif;
/* Terse sized type definitions. */
+#if defined(__GNUC__)
typedef unsigned int UINT8 __attribute__((__mode__(__QI__)));
typedef signed int SINT8 __attribute__((__mode__(__QI__)));
typedef unsigned int UINT16 __attribute__((__mode__(__HI__)));
@@ -85,6 +86,17 @@
typedef signed int SINT32 __attribute__((__mode__(__SI__)));
typedef unsigned int UINT64 __attribute__((__mode__(__DI__)));
typedef signed int SINT64 __attribute__((__mode__(__DI__)));
+#else
+#include <inttypes.h>
+typedef uint8_t UINT8;
+typedef int8_t SINT8;
+typedef uint16_t UINT16;
+typedef int16_t SINT16;
+typedef uint32_t UINT32;
+typedef int32_t SINT32;
+typedef uint64_t UINT64;
+typedef int64_t SINT64;
+#endif
typedef float FLOAT32;
--- include/ffi.h.in.save Wed Sep 9 21:05:17 2009
+++ include/ffi.h.in Fri Sep 25 13:05:05 2009
@@ -254,7 +254,11 @@
ffi_cif *cif;
void (*fun)(ffi_cif*,void*,void**,void*);
void *user_data;
+#ifdef __GNUC__
} ffi_closure __attribute__((aligned (8)));
+#else
+} ffi_closure;
+#endif
void *ffi_closure_alloc (size_t size, void **code);
void ffi_closure_free (void *);
8<----------------------





Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]