public inbox for libffi-discuss@sourceware.org
 help / color / mirror / Atom feed
* porting to SVR5
@ 2013-06-04  6:11 Tim Rice
  0 siblings, 0 replies; only message in thread
From: Tim Rice @ 2013-06-04  6:11 UTC (permalink / raw)
  To: libffi-discuss

[-- Attachment #1: Type: TEXT/PLAIN, Size: 2564 bytes --]


Attached is my attempt at porting libffi-3.0.13 to SVR5 (32bit X86) platforms.
It builds now (and doesn't break other platforms) but I think I need
help with src/x86/sysv.S

All tests fail.
Adding the -v option to runtest I see errors like this.
.......
Testing libffi.call/closure_fn0.c
options: {additional_flags= } {additional_flags=-I/usr/local/src/libs/libffi-3.0.13/testsuite/../include -I/opt/src/libs/libffi-3.0.13/testsuite/../include  -I/usr/local/src/libs/libffi-3.0.13/testsuite/../include/..} additional_flags=-L/usr/local/src/libs/libffi-3.0.13/testsuite/../.libs {libs= -lffi}
doing compile
pid is 28227 -28227
close result is 28227 exp8 0 1
output is Undefined                     first referenced
symbol                              in file
FFI_TYPE_FLOAT                      libffi.so
FFI_TYPE_UINT8                      libffi.so
FFI_TYPE_UINT64                     libffi.so
FFI_TYPE_SINT64                     libffi.so
FFI_TYPE_INT                        libffi.so
FFI_TYPE_DOUBLE                     libffi.so
FFI_TYPE_STRUCT                     libffi.so
FFI_TYPE_LONGDOUBLE                 libffi.so
UX:ld: ERROR: Symbol referencing errors. No output written to ./closure_fn0.exe
 status 1
compiler exited with status 1
FAIL: libffi.call/closure_fn0.c (test for excess errors)
.......

I had to make a bunch of changes to src/x86/sysv.S like this
just to get it to compile.
.....
@@ -302,10 +302,10 @@
 	/* Handle FFI_TYPE_UINT8, FFI_TYPE_SINT8, FFI_TYPE_UINT16,
 	   FFI_TYPE_SINT16, FFI_TYPE_UINT32, FFI_TYPE_SINT32.  */
 	cmpl	$FFI_TYPE_UINT64, %eax
-	jge	0f
+	jge	.L920
 	cmpl	$FFI_TYPE_UINT8, %eax
 	jge	.Lrcls_retint
-0:
+.L920:
 	cmpl	$FFI_TYPE_FLOAT, %eax
 	je	.Lrcls_retfloat
 	cmpl	$FFI_TYPE_DOUBLE, %eax
.....

The older assemblers do not understand the 0f kind of syntax.

When I saw that support was added of for the Solaris native compilers
I hoped this hunk would do the trick.
@@ -182,7 +182,7 @@
 	leal	-24(%ebp), %edx
 	movl	%edx, -12(%ebp)	/* resp */
 	leal	8(%ebp), %edx
-#ifdef __SUNPRO_C
+#if defined(__SUNPRO_C) || defined(__USLC__)
 	/* The SUNPRO compiler doesn't support GCC's regparm function
   	   attribute, so we have to pass all three arguments to
 	   ffi_closure_SYSV_inner on the stack.  */

But I suspect we need something different because not only is 
the regparm function attribute not supported by the USL (UNIX System Labs)
compiler, but __attribute__ is not suported at all as you can see
from the changes to src/x86/ffi.c.

Any ideas?

Thanks.

-- 
Tim Rice				Multitalents
tim@multitalents.net

[-- Attachment #2: libffi-3.0.13-SVR5.patch --]
[-- Type: TEXT/PLAIN, Size: 5907 bytes --]

#
#	configure.ac
#	Add support for UnixWare
#
#	include/ffi.h.in
#	include/ffi_common.h
#	src/x86/ffitarget.h
#	src/x86/ffi.c
#	src/x86/sysv.S
#	fixes for usl compilers
#
#	m4/ax_compiler_vendor.m4
#	add support for usl compilers
#
--- libffi-3.0.13/configure.ac.old	2013-03-17 15:36:15.000000000 -0700
+++ libffi-3.0.13/configure.ac	2013-03-17 15:36:15.000000000 -0700
@@ -146,6 +146,10 @@
 	fi	  
 	;;
 
+   i?86-*-sysv5*)
+ 	TARGET=X86; TARGETDIR=x86
+ 	;;
+
   x86_64-*-darwin*)
 	TARGET=X86_DARWIN; TARGETDIR=x86
 	;;
--- libffi-3.0.13/src/x86/ffitarget.h.old	2013-03-16 04:19:39.000000000 -0700
+++ libffi-3.0.13/src/x86/ffitarget.h	2013-06-02 17:36:03.508875008 -0700
@@ -39,6 +39,10 @@
 /* For code common to all platforms on x86 and x86_64. */
 #define X86_ANY
 
+#if defined(__USLC__) && !defined(__i386__)
+#define __i386__
+#endif
+
 #if defined (X86_64) && defined (__i386__)
 #undef X86_64
 #define X86
--- libffi-3.0.13/include/ffi.h.in.old	2013-03-16 04:19:39.000000000 -0700
+++ libffi-3.0.13/include/ffi.h.in	2013-06-02 17:36:03.508875023 -0700
@@ -103,6 +103,9 @@
 #   undef  FFI_64_BIT_MAX
 #   define FFI_64_BIT_MAX 9223372036854775807LL
 #  endif
+#  ifdef __USLC__
+#  define FFI_LONG_LONG_MAX FFI_64_BIT_MAX
+#  endif
 # endif
 #endif
 
--- libffi-3.0.13/include/ffi_common.h.old	2013-03-16 04:19:39.000000000 -0700
+++ libffi-3.0.13/include/ffi_common.h	2013-06-02 17:52:05.878155002 -0700
@@ -87,7 +87,7 @@
 } extended_cif;
 
 /* Terse sized type definitions.  */
-#if defined(_MSC_VER) || defined(__sgi) || defined(__SUNPRO_C)
+#if defined(_MSC_VER) || defined(__sgi) || defined(__SUNPRO_C) || defined(__USLC__)
 typedef unsigned char UINT8;
 typedef signed char   SINT8;
 typedef unsigned short UINT16;
--- libffi-3.0.13/src/x86/ffi.c.old	2013-03-16 04:25:04.000000000 -0700
+++ libffi-3.0.13/src/x86/ffi.c	2013-06-02 17:36:03.508875062 -0700
@@ -425,6 +425,11 @@
    on MSVC or SUNPRO_C -- standard conventions apply. */
 static void ffi_prep_incoming_args_SYSV (char *stack, void **ret,
                                          void** args, ffi_cif* cif);
+#if defined(__USLC__)
+void FFI_HIDDEN ffi_closure_SYSV (ffi_closure *);
+unsigned int FFI_HIDDEN ffi_closure_SYSV_inner (ffi_closure *, void **, void *);
+void FFI_HIDDEN ffi_closure_raw_SYSV (ffi_raw_closure *);
+#else
 void FFI_HIDDEN ffi_closure_SYSV (ffi_closure *)
      __attribute__ ((regparm(1)));
 unsigned int FFI_HIDDEN ffi_closure_SYSV_inner (ffi_closure *, void **, void *)
@@ -439,6 +444,7 @@
 void FFI_HIDDEN ffi_closure_THISCALL (ffi_closure *)
      __attribute__ ((regparm(1)));
 #endif
+#endif
 #ifdef X86_WIN64
 void FFI_HIDDEN ffi_closure_win64 (ffi_closure *);
 #endif
@@ -475,7 +481,11 @@
 }
 
 #else
+# if defined(__USLC__)
+unsigned int FFI_HIDDEN
+# else
 unsigned int FFI_HIDDEN __attribute__ ((regparm(1)))
+# endif
 ffi_closure_SYSV_inner (ffi_closure *closure, void **respp, void *args)
 {
   /* our various things...  */
--- libffi-3.0.13/src/x86/sysv.S.old	2013-03-16 04:19:39.000000000 -0700
+++ libffi-3.0.13/src/x86/sysv.S	2013-06-03 09:06:14.929915003 -0700
@@ -72,7 +72,7 @@
 
 	/* If the return value pointer is NULL, assume no return value.  */
 	cmpl  $0,24(%ebp)
-	jne  0f
+	jne  .L900
 
 	/* Even if there is no space for the return value, we are 
 	   obliged to handle floating-point values.  */
@@ -82,8 +82,8 @@
 
         jmp   epilogue
 
-0:
-	call  1f
+.L900:
+	call  .L901
 
 .Lstore_table:
 	.long	noretval-.Lstore_table	/* FFI_TYPE_VOID */
@@ -102,7 +102,7 @@
 	.long	retstruct-.Lstore_table	/* FFI_TYPE_STRUCT */
 	.long	retint-.Lstore_table	/* FFI_TYPE_POINTER */
 
-1:
+.L901:
 	pop  %esi
 	add  (%esi, %ecx, 4), %esi
 	jmp  *%esi
@@ -182,7 +182,7 @@
 	leal	-24(%ebp), %edx
 	movl	%edx, -12(%ebp)	/* resp */
 	leal	8(%ebp), %edx
-#ifdef __SUNPRO_C
+#if defined(__SUNPRO_C) || defined(__USLC__)
 	/* The SUNPRO compiler doesn't support GCC's regparm function
   	   attribute, so we have to pass all three arguments to
 	   ffi_closure_SYSV_inner on the stack.  */
@@ -200,9 +200,9 @@
 #else
 	movl	%ebx, 8(%esp)
 .LCFI7:
-	call	1f
-1:	popl	%ebx
-	addl	$_GLOBAL_OFFSET_TABLE_+[.-1b], %ebx
+	call	.L911
+.L911:	popl	%ebx
+	addl	$_GLOBAL_OFFSET_TABLE_+[.L911], %ebx
 	call	ffi_closure_SYSV_inner@PLT
 	movl	8(%esp), %ebx
 #endif
@@ -213,11 +213,11 @@
 	/* Handle FFI_TYPE_UINT8, FFI_TYPE_SINT8, FFI_TYPE_UINT16,
 	   FFI_TYPE_SINT16, FFI_TYPE_UINT32, FFI_TYPE_SINT32.  */
 	cmpl	$FFI_TYPE_UINT64, %eax
-	jge	0f
+	jge	.L910
 	cmpl	$FFI_TYPE_UINT8, %eax
 	jge	.Lcls_retint
 	
-0:	cmpl	$FFI_TYPE_FLOAT, %eax
+.L910:	cmpl	$FFI_TYPE_FLOAT, %eax
 	je	.Lcls_retfloat
 	cmpl	$FFI_TYPE_DOUBLE, %eax
 	je	.Lcls_retdouble
@@ -302,10 +302,10 @@
 	/* Handle FFI_TYPE_UINT8, FFI_TYPE_SINT8, FFI_TYPE_UINT16,
 	   FFI_TYPE_SINT16, FFI_TYPE_UINT32, FFI_TYPE_SINT32.  */
 	cmpl	$FFI_TYPE_UINT64, %eax
-	jge	0f
+	jge	.L920
 	cmpl	$FFI_TYPE_UINT8, %eax
 	jge	.Lrcls_retint
-0:
+.L920:
 	cmpl	$FFI_TYPE_FLOAT, %eax
 	je	.Lrcls_retfloat
 	cmpl	$FFI_TYPE_DOUBLE, %eax
--- libffi-3.0.13/m4/ax_compiler_vendor.m4.old	2013-03-16 04:19:39.000000000 -0700
+++ libffi-3.0.13/m4/ax_compiler_vendor.m4	2013-03-16 04:19:39.000000000 -0700
@@ -44,7 +44,7 @@
 #   modified version of the Autoconf Macro, you may extend this special
 #   exception to the GPL to apply to your modified version as well.
 
-#serial 11
+#serial 12
 
 AC_DEFUN([AX_COMPILER_VENDOR],
 [AC_CACHE_CHECK([for _AC_LANG compiler vendor], ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor,
@@ -67,6 +67,7 @@
            metrowerks: __MWERKS__
            watcom:    __WATCOMC__
            portland:  __PGI
+           usl:       __USLC__,__SCO_VERSION__
            unknown:   UNKNOWN"
   for ventest in $vendors; do
     case $ventest in

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2013-06-04  6:11 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-04  6:11 porting to SVR5 Tim Rice

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).