Commit c4205f77 by Frank Everdij Committed by Anthony Green

IRIX support

From-SVN: r155470
parent 124f60ab
2009-12-25 Frank Everdij <f.p.x.everdij@tudelft.nl>
* include/ffi.h.in: Placed '__GNUC__' ifdef around
'__attribute__((aligned(8)))' in ffi_closure, fixes compile for
IRIX MIPSPro c99.
* include/ffi_common.h: Added '__sgi' define to non
'__attribute__((__mode__()))' integer typedefs.
* src/mips/ffi.c (ffi_call, ffi_closure_mips_inner_O32,
ffi_closure_mips_inner_N32): Added 'defined(_MIPSEB)' to BE check.
(ffi_closure_mips_inner_O32, ffi_closure_mips_inner_N32): Added
FFI_LONGDOUBLE support and alignment(N32 only).
* src/mips/ffitarget.h: Corrected '#include <sgidefs.h>' for IRIX and
fixed non '__attribute__((__mode__()))' integer typedefs.
* src/mips/n32.S: Put '#ifdef linux' around '.abicalls' and '.eh_frame'
since they are Linux/GNU Assembler specific.
2009-12-25 Bradley Smith <brad@brad-smith.co.uk> 2009-12-25 Bradley Smith <brad@brad-smith.co.uk>
* configure.ac, Makefile.am, src/avr32/ffi.c, * configure.ac, Makefile.am, src/avr32/ffi.c,
......
...@@ -256,7 +256,11 @@ typedef struct { ...@@ -256,7 +256,11 @@ typedef struct {
ffi_cif *cif; ffi_cif *cif;
void (*fun)(ffi_cif*,void*,void**,void*); void (*fun)(ffi_cif*,void*,void**,void*);
void *user_data; void *user_data;
#ifdef __GNUC__
} ffi_closure __attribute__((aligned (8))); } ffi_closure __attribute__((aligned (8)));
#else
} ffi_closure;
#endif
void *ffi_closure_alloc (size_t size, void **code); void *ffi_closure_alloc (size_t size, void **code);
void ffi_closure_free (void *); void ffi_closure_free (void *);
......
...@@ -84,15 +84,21 @@ typedef struct ...@@ -84,15 +84,21 @@ typedef struct
} extended_cif; } extended_cif;
/* Terse sized type definitions. */ /* Terse sized type definitions. */
#ifdef _MSC_VER #if defined(_MSC_VER) || defined(__sgi)
typedef unsigned char UINT8; typedef unsigned char UINT8;
typedef signed char SINT8; typedef signed char SINT8;
typedef unsigned short UINT16; typedef unsigned short UINT16;
typedef signed short SINT16; typedef signed short SINT16;
typedef unsigned int UINT32; typedef unsigned int UINT32;
typedef signed int SINT32; typedef signed int SINT32;
# ifdef _MSC_VER
typedef unsigned __int64 UINT64; typedef unsigned __int64 UINT64;
typedef signed __int64 SINT64; typedef signed __int64 SINT64;
# else
# include <inttypes.h>
typedef uint64_t UINT64;
typedef int64_t SINT64;
# endif
#else #else
typedef unsigned int UINT8 __attribute__((__mode__(__QI__))); typedef unsigned int UINT8 __attribute__((__mode__(__QI__)));
typedef signed int SINT8 __attribute__((__mode__(__QI__))); typedef signed int SINT8 __attribute__((__mode__(__QI__)));
......
...@@ -625,7 +625,7 @@ void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue) ...@@ -625,7 +625,7 @@ void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
{ {
rvalue_copy = alloca (8); rvalue_copy = alloca (8);
copy_rvalue = 1; copy_rvalue = 1;
#ifdef __MIPSEB__ #if defined(__MIPSEB__) || defined(_MIPSEB)
copy_offset = 4; copy_offset = 4;
#endif #endif
} }
...@@ -772,9 +772,10 @@ ffi_closure_mips_inner_O32 (ffi_closure *closure, ...@@ -772,9 +772,10 @@ ffi_closure_mips_inner_O32 (ffi_closure *closure,
{ {
if (i < 2 && !seen_int && if (i < 2 && !seen_int &&
(arg_types[i]->type == FFI_TYPE_FLOAT || (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) if (arg_types[i]->type == FFI_TYPE_FLOAT)
avaluep[i] = ((char *) &fpr[i]) + sizeof (float); avaluep[i] = ((char *) &fpr[i]) + sizeof (float);
else else
...@@ -931,10 +932,16 @@ ffi_closure_mips_inner_N32 (ffi_closure *closure, ...@@ -931,10 +932,16 @@ ffi_closure_mips_inner_N32 (ffi_closure *closure,
while (i < avn) while (i < avn)
{ {
if (arg_types[i]->type == FFI_TYPE_FLOAT 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)
{ {
argp = (argn >= 8 || soft_float) ? ar + argn : fpr + argn; argp = (argn >= 8 || soft_float) ? 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) if (arg_types[i]->type == FFI_TYPE_FLOAT && argn < 8)
avaluep[i] = ((char *) argp) + sizeof (float); avaluep[i] = ((char *) argp) + sizeof (float);
else else
......
...@@ -28,7 +28,10 @@ ...@@ -28,7 +28,10 @@
#define LIBFFI_TARGET_H #define LIBFFI_TARGET_H
#ifdef linux #ifdef linux
#include <asm/sgidefs.h> # include <asm/sgidefs.h>
#else
# include <sgidefs.h>
#endif
# ifndef _ABIN32 # ifndef _ABIN32
# define _ABIN32 _MIPS_SIM_NABI32 # define _ABIN32 _MIPS_SIM_NABI32
# endif # endif
...@@ -38,7 +41,6 @@ ...@@ -38,7 +41,6 @@
# ifndef _ABIO32 # ifndef _ABIO32
# define _ABIO32 _MIPS_SIM_ABI32 # define _ABIO32 _MIPS_SIM_ABI32
# endif # endif
#endif
#if !defined(_MIPS_SIM) #if !defined(_MIPS_SIM)
-- something is very wrong -- -- something is very wrong --
...@@ -154,7 +156,8 @@ ...@@ -154,7 +156,8 @@
# endif /* _MIPS_SIM==_ABI64 */ # endif /* _MIPS_SIM==_ABI64 */
#endif /* !FFI_MIPS_O32 */ #endif /* !FFI_MIPS_O32 */
#else /* !LIBFFI_ASM */ #else /* !LIBFFI_ASM */
#ifdef FFI_MIPS_O32 # ifdef __GNUC__
# ifdef FFI_MIPS_O32
/* O32 stack frames have 32bit integer args */ /* O32 stack frames have 32bit integer args */
typedef unsigned int ffi_arg __attribute__((__mode__(__SI__))); typedef unsigned int ffi_arg __attribute__((__mode__(__SI__)));
typedef signed int ffi_sarg __attribute__((__mode__(__SI__))); typedef signed int ffi_sarg __attribute__((__mode__(__SI__)));
...@@ -162,7 +165,18 @@ typedef signed int ffi_sarg __attribute__((__mode__(__SI__))); ...@@ -162,7 +165,18 @@ typedef signed int ffi_sarg __attribute__((__mode__(__SI__)));
/* N32 and N64 frames have 64bit integer args */ /* N32 and N64 frames have 64bit integer args */
typedef unsigned int ffi_arg __attribute__((__mode__(__DI__))); typedef unsigned int ffi_arg __attribute__((__mode__(__DI__)));
typedef signed int ffi_sarg __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 { typedef enum ffi_abi {
FFI_FIRST_ABI = 0, FFI_FIRST_ABI = 0,
......
...@@ -40,7 +40,9 @@ ...@@ -40,7 +40,9 @@
#define SIZEOF_FRAME ( 8 * FFI_SIZEOF_ARG ) #define SIZEOF_FRAME ( 8 * FFI_SIZEOF_ARG )
#ifdef linux
.abicalls .abicalls
#endif
.text .text
.align 2 .align 2
.globl ffi_call_N32 .globl ffi_call_N32
...@@ -527,6 +529,7 @@ cls_epilogue: ...@@ -527,6 +529,7 @@ cls_epilogue:
.LFE2: .LFE2:
.end ffi_closure_N32 .end ffi_closure_N32
#ifdef linux
.section .eh_frame,"aw",@progbits .section .eh_frame,"aw",@progbits
.Lframe1: .Lframe1:
.4byte .LECIE1-.LSCIE1 # length .4byte .LECIE1-.LSCIE1 # length
...@@ -583,5 +586,6 @@ cls_epilogue: ...@@ -583,5 +586,6 @@ cls_epilogue:
.uleb128 (SIZEOF_FRAME2 - RA_OFF2)/4 .uleb128 (SIZEOF_FRAME2 - RA_OFF2)/4
.align EH_FRAME_ALIGN .align EH_FRAME_ALIGN
.LEFDE3: .LEFDE3:
#endif /* linux */
#endif #endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment