[PATCH/RFA] Fix libffi on mips-netbsd
Jason R Thorpe
thorpej@wasabisystems.com
Tue Sep 24 10:58:00 GMT 2002
libffi makes some bad (IMO :-) assumptions about what preprocessor macros
will be defined and which include files will be available on MIPS.
This patch makes it work on mips-netbsd, but I cannot verify it on
mips-linux or mips-sgi-irix.
That said, with this change, libjava hobbles along on mips-netbsd (I posted
a testsuite run with it enabled earlier today).
So, assuming someone can tell me this looks okay for mips-linux and
mips-sgi-irix, OK for mainline?
* configure.in (mips*-*-netbsd*): Treat it like mips*-*-linux*.
* configure: Regenerate.
* include/ffi.h.in: Test for FFI_MIPS_N32 rather than
_MIPS_SIM == _ABIN32.
* include/ffi_mips.h: If _MIPS_SIM is not defined, set
FFI_MIPS_N32 or FFI_MIPS_O32 based on the presence of
__mips_n32. Error out if __mips_n64 or __mips_o64 are defined.
* src/mips/ffi.c: Only include <sgidefs.h> if __sgi__ or
__linux__ are defined. Test for FFI_MIPS_N32 rather than
_MIPS_SIM == _MIPS_SIM_NABI32. Test for FFI_MIPS_O32 rathern
than _MIPS_SIM == _MIPS_SIM_ABI32.
--
-- Jason R. Thorpe <thorpej@wasabisystems.com>
-------------- next part --------------
Index: configure.in
===================================================================
RCS file: /cvs/gcc/gcc/libffi/configure.in,v
retrieving revision 1.31
diff -c -r1.31 configure.in
*** configure.in 19 Jul 2002 15:30:58 -0000 1.31
--- configure.in 24 Sep 2002 17:41:35 -0000
***************
*** 62,68 ****
ia64*-*-*) TARGET=IA64; TARGETDIR=ia64;;
m68k-*-linux*) TARGET=M68K; TARGETDIR=m68k;;
mips64*-*);;
! mips*-*-linux*) TARGET=MIPS_LINUX; TARGETDIR=mips;;
powerpc-*-linux* | powerpc-*-sysv*) TARGET=POWERPC; TARGETDIR=powerpc;;
powerpc-*-beos*) TARGET=POWERPC; TARGETDIR=powerpc;;
powerpc-*-darwin*) TARGET=POWERPC_DARWIN; TARGETDIR=powerpc;;
--- 62,68 ----
ia64*-*-*) TARGET=IA64; TARGETDIR=ia64;;
m68k-*-linux*) TARGET=M68K; TARGETDIR=m68k;;
mips64*-*);;
! mips*-*-linux* | mips*-*-netbsd*) TARGET=MIPS_LINUX; TARGETDIR=mips;;
powerpc-*-linux* | powerpc-*-sysv*) TARGET=POWERPC; TARGETDIR=powerpc;;
powerpc-*-beos*) TARGET=POWERPC; TARGETDIR=powerpc;;
powerpc-*-darwin*) TARGET=POWERPC_DARWIN; TARGETDIR=powerpc;;
Index: include/ffi.h.in
===================================================================
RCS file: /cvs/gcc/gcc/libffi/include/ffi.h.in,v
retrieving revision 1.17
diff -c -r1.17 ffi.h.in
*** include/ffi.h.in 19 Jul 2002 01:08:42 -0000 1.17
--- include/ffi.h.in 24 Sep 2002 17:41:35 -0000
***************
*** 316,325 ****
unsigned bytes;
unsigned flags;
! #ifdef MIPS
! #if _MIPS_SIM == _ABIN32
unsigned rstruct_flag;
- #endif
#endif
} ffi_cif;
--- 316,323 ----
unsigned bytes;
unsigned flags;
! #if defined(MIPS) && defined(FFI_MIPS_N32)
unsigned rstruct_flag;
#endif
} ffi_cif;
Index: include/ffi_mips.h
===================================================================
RCS file: /cvs/gcc/gcc/libffi/include/ffi_mips.h,v
retrieving revision 1.2
diff -c -r1.2 ffi_mips.h
*** include/ffi_mips.h 2 Mar 2001 22:21:22 -0000 1.2
--- include/ffi_mips.h 24 Sep 2002 17:41:35 -0000
***************
*** 28,34 ****
#include <ffi.h>
#if !defined(_MIPS_SIM)
! -- something is very wrong --
#else
# if _MIPS_SIM==_ABIN32 && defined(_ABIN32)
# define FFI_MIPS_N32
--- 28,41 ----
#include <ffi.h>
#if !defined(_MIPS_SIM)
! /* Try to intuit what we might have, and provide compatibility defns. */
! # if defined(__mips_n32)
! # define FFI_MIPS_N32
! # elif defined(__mips_n64) || defined(__mips_o64)
! -- this is an unsupported platform --
! # else
! # define FFI_MIPS_O32
! # endif
#else
# if _MIPS_SIM==_ABIN32 && defined(_ABIN32)
# define FFI_MIPS_N32
Index: src/mips/ffi.c
===================================================================
RCS file: /cvs/gcc/gcc/libffi/src/mips/ffi.c,v
retrieving revision 1.4
diff -c -r1.4 ffi.c
*** src/mips/ffi.c 18 Jul 2002 23:08:31 -0000 1.4
--- src/mips/ffi.c 24 Sep 2002 17:41:37 -0000
***************
*** 23,35 ****
OTHER DEALINGS IN THE SOFTWARE.
----------------------------------------------------------------------- */
#include <sgidefs.h>
#include <ffi.h>
#include <ffi_common.h>
#include <stdlib.h>
! #if _MIPS_SIM == _MIPS_SIM_NABI32
#define FIX_ARGP \
FFI_ASSERT(argp <= &stack[bytes]); \
if (argp == &stack[bytes]) \
--- 23,38 ----
OTHER DEALINGS IN THE SOFTWARE.
----------------------------------------------------------------------- */
+ #if defined(__sgi__) || defined(__linux__)
#include <sgidefs.h>
+ #endif
+
#include <ffi.h>
#include <ffi_common.h>
#include <stdlib.h>
! #if defined(FFI_MIPS_N32)
#define FIX_ARGP \
FFI_ASSERT(argp <= &stack[bytes]); \
if (argp == &stack[bytes]) \
***************
*** 55,61 ****
register char *argp;
register ffi_type **p_arg;
! #if _MIPS_SIM == _MIPS_SIM_NABI32
/* If more than 8 double words are used, the remainder go
on the stack. We reorder stuff on the stack here to
support this easily. */
--- 58,64 ----
register char *argp;
register ffi_type **p_arg;
! #if defined(FFI_MIPS_N32)
/* If more than 8 double words are used, the remainder go
on the stack. We reorder stuff on the stack here to
support this easily. */
***************
*** 69,75 ****
memset(stack, 0, bytes);
! #if _MIPS_SIM == _MIPS_SIM_NABI32
if ( ecif->cif->rstruct_flag != 0 )
#else
if ( ecif->cif->rtype->type == FFI_TYPE_STRUCT )
--- 72,78 ----
memset(stack, 0, bytes);
! #if defined(FFI_MIPS_N32)
if ( ecif->cif->rstruct_flag != 0 )
#else
if ( ecif->cif->rtype->type == FFI_TYPE_STRUCT )
***************
*** 92,98 ****
FIX_ARGP;
}
! #if _MIPS_SIM == _MIPS_SIM_ABI32
#define OFFSET 0
#else
#define OFFSET sizeof(int)
--- 95,101 ----
FIX_ARGP;
}
! #if defined(FFI_MIPS_O32)
#define OFFSET 0
#else
#define OFFSET sizeof(int)
***************
*** 146,152 ****
}
else
{
! #if _MIPS_SIM == _MIPS_SIM_ABI32
memcpy(argp, *p_argv, z);
#else
{
--- 149,155 ----
}
else
{
! #if defined(FFI_MIPS_O32)
memcpy(argp, *p_argv, z);
#else
{
***************
*** 178,184 ****
return;
}
! #if _MIPS_SIM == _MIPS_SIM_NABI32
/* The n32 spec says that if "a chunk consists solely of a double
float field (but not a double, which is part of a union), it
--- 181,187 ----
return;
}
! #if defined(FFI_MIPS_N32)
/* The n32 spec says that if "a chunk consists solely of a double
float field (but not a double, which is part of a union), it
***************
*** 267,273 ****
{
cif->flags = 0;
! #if _MIPS_SIM == _MIPS_SIM_ABI32
/* Set the flags necessary for O32 processing */
if (cif->rtype->type != FFI_TYPE_STRUCT)
--- 270,276 ----
{
cif->flags = 0;
! #if defined(FFI_MIPS_O32)
/* Set the flags necessary for O32 processing */
if (cif->rtype->type != FFI_TYPE_STRUCT)
***************
*** 322,328 ****
}
#endif
! #if _MIPS_SIM == _MIPS_SIM_NABI32
/* Set the flags necessary for N32 processing */
{
unsigned shift = 0;
--- 325,331 ----
}
#endif
! #if defined(FFI_MIPS_N32)
/* Set the flags necessary for N32 processing */
{
unsigned shift = 0;
***************
*** 441,454 ****
switch (cif->abi)
{
! #if _MIPS_SIM == _MIPS_SIM_ABI32
case FFI_O32:
ffi_call_O32(ffi_prep_args, &ecif, cif->bytes,
cif->flags, ecif.rvalue, fn);
break;
#endif
! #if _MIPS_SIM == _MIPS_SIM_NABI32
case FFI_N32:
ffi_call_N32(ffi_prep_args, &ecif, cif->bytes,
cif->flags, ecif.rvalue, fn);
--- 444,457 ----
switch (cif->abi)
{
! #if defined(FFI_MIPS_O32)
case FFI_O32:
ffi_call_O32(ffi_prep_args, &ecif, cif->bytes,
cif->flags, ecif.rvalue, fn);
break;
#endif
! #if defined(FFI_MIPS_N32)
case FFI_N32:
ffi_call_N32(ffi_prep_args, &ecif, cif->bytes,
cif->flags, ecif.rvalue, fn);
More information about the Gcc-patches
mailing list