This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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: rewrite ia64 libffi support


On Fri, Dec 31, 2004 at 09:33:20PM +0100, Andreas Schwab wrote:
> > ! #if defined X86 || defined ARM || defined M68K || SH
> 
> I think this will give a syntax error when compiling for the SH because
> the target macros are defined as empty.

Fixed thus.  No more nasty ifdefs at all.


r~


        * src/types.c (FFI_AGGREGATE_TYPEDEF): Remove.
        (FFI_TYPEDEF): Rename from FFI_INTEGRAL_TYPEDEF.  Replace size and
        offset parameters with a type parameter; deduce size and structure
        alignment.  Update all users.

Index: src/types.c
===================================================================
RCS file: /cvs/gcc/gcc/libffi/src/types.c,v
retrieving revision 1.18
diff -u -p -c -r1.18 types.c
*** src/types.c	31 Dec 2004 20:11:16 -0000	1.18
--- src/types.c	31 Dec 2004 22:02:22 -0000
***************
*** 28,98 ****
  
  /* Type definitions */
  
! #define FFI_INTEGRAL_TYPEDEF(n, s, a, t) ffi_type ffi_type_##n = { s, a, t, NULL }
! #define FFI_AGGREGATE_TYPEDEF(n, e) ffi_type ffi_type_##n = { 0, 0, FFI_TYPE_STRUCT, e }
  
  /* Size and alignment are fake here. They must not be 0. */
! FFI_INTEGRAL_TYPEDEF(void, 1, 1, FFI_TYPE_VOID);
! 
! FFI_INTEGRAL_TYPEDEF(uint8, 1, 1, FFI_TYPE_UINT8);
! FFI_INTEGRAL_TYPEDEF(sint8, 1, 1, FFI_TYPE_SINT8);
! FFI_INTEGRAL_TYPEDEF(uint16, 2, 2, FFI_TYPE_UINT16);
! FFI_INTEGRAL_TYPEDEF(sint16, 2, 2, FFI_TYPE_SINT16);
! FFI_INTEGRAL_TYPEDEF(uint32, 4, 4, FFI_TYPE_UINT32);
! FFI_INTEGRAL_TYPEDEF(sint32, 4, 4, FFI_TYPE_SINT32);
! FFI_INTEGRAL_TYPEDEF(float, 4, 4, FFI_TYPE_FLOAT);
! 
! FFI_INTEGRAL_TYPEDEF(pointer, sizeof(void*), sizeof(void*), FFI_TYPE_POINTER);
! 
! #if defined X86 || defined ARM || defined M68K || SH
! 
! FFI_INTEGRAL_TYPEDEF(uint64, 8, 4, FFI_TYPE_UINT64);
! FFI_INTEGRAL_TYPEDEF(sint64, 8, 4, FFI_TYPE_SINT64);
! 
! #else
! 
! FFI_INTEGRAL_TYPEDEF(uint64, 8, 8, FFI_TYPE_UINT64);
! FFI_INTEGRAL_TYPEDEF(sint64, 8, 8, FFI_TYPE_SINT64);
! 
! #endif
! 
! 
! #if defined X86 || defined X86_WIN32 || defined M68K
! 
! #ifdef X86_WIN32
! FFI_INTEGRAL_TYPEDEF(double, 8, 8, FFI_TYPE_DOUBLE);
! #else
! FFI_INTEGRAL_TYPEDEF(double, 8, 4, FFI_TYPE_DOUBLE);
! #endif
! FFI_INTEGRAL_TYPEDEF(longdouble, 12, 4, FFI_TYPE_LONGDOUBLE);
! 
! #elif defined ARM || defined SH || defined POWERPC_AIX || defined M32R
! 
! FFI_INTEGRAL_TYPEDEF(double, 8, 4, FFI_TYPE_DOUBLE);
! FFI_INTEGRAL_TYPEDEF(longdouble, 8, 4, FFI_TYPE_LONGDOUBLE);
! 
! #elif defined POWERPC_DARWIN
! 
! FFI_INTEGRAL_TYPEDEF(double, 8, 4, FFI_TYPE_DOUBLE);
! FFI_INTEGRAL_TYPEDEF(longdouble, 16, 16, FFI_TYPE_LONGDOUBLE);
! 
! #elif defined SPARC
! 
! FFI_INTEGRAL_TYPEDEF(double, 8, 8, FFI_TYPE_DOUBLE);
! #ifdef SPARC64
! FFI_INTEGRAL_TYPEDEF(longdouble, 16, 16, FFI_TYPE_LONGDOUBLE);
! #else
! FFI_INTEGRAL_TYPEDEF(longdouble, 16, 8, FFI_TYPE_LONGDOUBLE);
! #endif
! 
! #elif defined X86_64 || defined POWERPC64 || defined IA64
! 
! FFI_INTEGRAL_TYPEDEF(double, 8, 8, FFI_TYPE_DOUBLE);
! FFI_INTEGRAL_TYPEDEF(longdouble, 16, 16, FFI_TYPE_LONGDOUBLE);
! 
! #else
! 
! FFI_INTEGRAL_TYPEDEF(double, 8, 8, FFI_TYPE_DOUBLE);
! FFI_INTEGRAL_TYPEDEF(longdouble, 8, 8, FFI_TYPE_LONGDOUBLE);
! 
! #endif
--- 28,60 ----
  
  /* Type definitions */
  
! #define FFI_TYPEDEF(name, type, id)		\
! struct struct_align_##name {			\
!   char c;					\
!   type x;					\
! };						\
! ffi_type ffi_type_##name = {			\
!   sizeof(type),					\
!   offsetof(struct struct_align_##name, x),	\
!   id, NULL					\
! }
  
  /* Size and alignment are fake here. They must not be 0. */
! ffi_type ffi_type_void = {
!   1, 1, FFI_TYPE_VOID, NULL
! };
! 
! FFI_TYPEDEF(uint8, UINT8, FFI_TYPE_UINT8);
! FFI_TYPEDEF(sint8, SINT8, FFI_TYPE_SINT8);
! FFI_TYPEDEF(uint16, UINT16, FFI_TYPE_UINT16);
! FFI_TYPEDEF(sint16, SINT16, FFI_TYPE_SINT16);
! FFI_TYPEDEF(uint32, UINT32, FFI_TYPE_UINT32);
! FFI_TYPEDEF(sint32, SINT32, FFI_TYPE_SINT32);
! FFI_TYPEDEF(uint64, UINT64, FFI_TYPE_UINT64);
! FFI_TYPEDEF(sint64, SINT64, FFI_TYPE_SINT64);
! 
! FFI_TYPEDEF(pointer, void*, FFI_TYPE_POINTER);
! 
! FFI_TYPEDEF(float, float, FFI_TYPE_FLOAT);
! FFI_TYPEDEF(double, double, FFI_TYPE_DOUBLE);
! FFI_TYPEDEF(longdouble, long double, FFI_TYPE_LONGDOUBLE);


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