summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorJiaojinxing <jiaojinxing1987@gmail.com>2018-03-20 02:26:51 (GMT)
committer Jiaojinxing <jiaojinxing1987@gmail.com>2018-03-20 02:26:51 (GMT)
commitf5d2ea09aca7b1265f696bb5313283a3ea6e76b2 (patch)
tree5d278e192416d8cd9bca92821b52db680be50acf
parentd7bef02ebafdc7d8cc587ff62f9d3156cde2807c (diff)
downloadlibffi-f5d2ea09aca7b1265f696bb5313283a3ea6e76b2.zip
libffi-f5d2ea09aca7b1265f696bb5313283a3ea6e76b2.tar.gz
libffi-f5d2ea09aca7b1265f696bb5313283a3ea6e76b2.tar.bz2
Ported to SylixOS.
-rw-r--r--.reproject1
-rw-r--r--Makefile1
-rw-r--r--libffi.mk3
-rw-r--r--libffi/include/mips/ffi.h4
-rw-r--r--libffi/include/mips64/ffi.h4
-rw-r--r--libffi/include/ppc/ffi.h4
-rw-r--r--libffi/include/ppc/fficonfig.h2
-rw-r--r--libffi/include/ppc/ffitarget.h2
-rw-r--r--libffi/src/arm/ffi.c13
-rw-r--r--libffi/src/closures.c2
-rw-r--r--libffi/src/mips/ffi.c5
-rw-r--r--libffi/src/powerpc/ffi_sysv.c4
-rw-r--r--libffi/src/powerpc/ffitarget.h2
-rw-r--r--libffi/src/x86/ffi.c9
-rw-r--r--libffi/src/x86/ffi64.c2
15 files changed, 43 insertions, 15 deletions
diff --git a/.reproject b/.reproject
index 072e49e..0f85d41 100644
--- a/.reproject
+++ b/.reproject
@@ -9,7 +9,6 @@
<BuildSetting CoustomCfgMakefile="false" NeedReBuild="false" NotScanSourceFile="true"/>
<UploadPath>
<PairItem key="$(WORKSPACE_libffi)\$(Output)\strip\libffi.so" value="/lib/libffi.so"/>
-<PairItem key="$(WORKSPACE_libffi)\$(Output)\strip\test" value="/apps/libffi/test"/>
</UploadPath>
<DeviceSetting DevName="192.168.7.91" WorkDir="/lib"/>
</SylixOSSetting>
diff --git a/Makefile b/Makefile
index e9715ed..7c25e8a 100644
--- a/Makefile
+++ b/Makefile
@@ -75,7 +75,6 @@ include $(MKTEMP)/header.mk
# Include targets makefiles
#*********************************************************************************************************
include libffi.mk
-include test.mk
#*********************************************************************************************************
# Include end.mk
diff --git a/libffi.mk b/libffi.mk
index bb8d96e..e4ebdcd 100644
--- a/libffi.mk
+++ b/libffi.mk
@@ -49,10 +49,11 @@ LOCAL_MIPS_SRCS := \
LOCAL_MIPS64_SRCS := \
./libffi/src/mips/ffi.c \
-./libffi/src/mips/o32.S
+./libffi/src/mips/n32.S
LOCAL_PPC_SRCS := \
./libffi/src/powerpc/ffi.c \
+./libffi/src/powerpc/ffi_sysv.c \
./libffi/src/powerpc/sysv.S \
./libffi/src/powerpc/ppc_closure.S
diff --git a/libffi/include/mips/ffi.h b/libffi/include/mips/ffi.h
index f8ab214..d2a9881 100644
--- a/libffi/include/mips/ffi.h
+++ b/libffi/include/mips/ffi.h
@@ -194,7 +194,7 @@ FFI_EXTERN ffi_type ffi_type_float;
FFI_EXTERN ffi_type ffi_type_double;
FFI_EXTERN ffi_type ffi_type_pointer;
-#if defined(__mips64)
+#if defined(__mips64) && !defined(SYLIXOS)
FFI_EXTERN ffi_type ffi_type_longdouble;
#else
#define ffi_type_longdouble ffi_type_double
@@ -460,7 +460,7 @@ void ffi_call(ffi_cif *cif,
#define FFI_TYPE_INT 1
#define FFI_TYPE_FLOAT 2
#define FFI_TYPE_DOUBLE 3
-#if defined(__mips64)
+#if defined(__mips64) && !defined(SYLIXOS)
#define FFI_TYPE_LONGDOUBLE 4
#else
#define FFI_TYPE_LONGDOUBLE FFI_TYPE_DOUBLE
diff --git a/libffi/include/mips64/ffi.h b/libffi/include/mips64/ffi.h
index f8ab214..d2a9881 100644
--- a/libffi/include/mips64/ffi.h
+++ b/libffi/include/mips64/ffi.h
@@ -194,7 +194,7 @@ FFI_EXTERN ffi_type ffi_type_float;
FFI_EXTERN ffi_type ffi_type_double;
FFI_EXTERN ffi_type ffi_type_pointer;
-#if defined(__mips64)
+#if defined(__mips64) && !defined(SYLIXOS)
FFI_EXTERN ffi_type ffi_type_longdouble;
#else
#define ffi_type_longdouble ffi_type_double
@@ -460,7 +460,7 @@ void ffi_call(ffi_cif *cif,
#define FFI_TYPE_INT 1
#define FFI_TYPE_FLOAT 2
#define FFI_TYPE_DOUBLE 3
-#if defined(__mips64)
+#if defined(__mips64) && !defined(SYLIXOS)
#define FFI_TYPE_LONGDOUBLE 4
#else
#define FFI_TYPE_LONGDOUBLE FFI_TYPE_DOUBLE
diff --git a/libffi/include/ppc/ffi.h b/libffi/include/ppc/ffi.h
index a881c6f..0bf77a9 100644
--- a/libffi/include/ppc/ffi.h
+++ b/libffi/include/ppc/ffi.h
@@ -194,7 +194,7 @@ FFI_EXTERN ffi_type ffi_type_float;
FFI_EXTERN ffi_type ffi_type_double;
FFI_EXTERN ffi_type ffi_type_pointer;
-#if 1
+#if 0
FFI_EXTERN ffi_type ffi_type_longdouble;
#else
#define ffi_type_longdouble ffi_type_double
@@ -460,7 +460,7 @@ void ffi_call(ffi_cif *cif,
#define FFI_TYPE_INT 1
#define FFI_TYPE_FLOAT 2
#define FFI_TYPE_DOUBLE 3
-#if 1
+#if 0
#define FFI_TYPE_LONGDOUBLE 4
#else
#define FFI_TYPE_LONGDOUBLE FFI_TYPE_DOUBLE
diff --git a/libffi/include/ppc/fficonfig.h b/libffi/include/ppc/fficonfig.h
index f8eee8e..ba04883 100644
--- a/libffi/include/ppc/fficonfig.h
+++ b/libffi/include/ppc/fficonfig.h
@@ -75,7 +75,7 @@
/* #undef HAVE_LONG_DOUBLE */
/* Define if you support more than one size of the long double type */
-#define HAVE_LONG_DOUBLE_VARIANT 1
+/* #undef HAVE_LONG_DOUBLE_VARIANT */
/* Define to 1 if you have the `memcpy' function. */
/* #undef HAVE_MEMCPY */
diff --git a/libffi/include/ppc/ffitarget.h b/libffi/include/ppc/ffitarget.h
index b47b0f5..66d5de9 100644
--- a/libffi/include/ppc/ffitarget.h
+++ b/libffi/include/ppc/ffitarget.h
@@ -116,7 +116,7 @@ typedef enum ffi_abi {
| FFI_SYSV_SOFT_FLOAT
# endif
# if (defined (__SVR4_STRUCT_RETURN) \
- || defined (POWERPC_FREEBSD) && !defined (__AIX_STRUCT_RETURN))
+ || defined (POWERPC_FREEBSD) && !defined (__AIX_STRUCT_RETURN)) || defined(SYLIXOS)
| FFI_SYSV_STRUCT_RET
# endif
# if __LDBL_MANT_DIG__ == 106
diff --git a/libffi/src/arm/ffi.c b/libffi/src/arm/ffi.c
index 6691ab5..40758c1 100644
--- a/libffi/src/arm/ffi.c
+++ b/libffi/src/arm/ffi.c
@@ -751,6 +751,7 @@ ffi_closure_free (void *ptr)
#else
+#ifndef SYLIXOS
#define FFI_INIT_TRAMPOLINE(TRAMP,FUN,CTX) \
({ unsigned char *__tramp = (unsigned char*)(TRAMP); \
unsigned int __fun = (unsigned int)(FUN); \
@@ -764,6 +765,18 @@ ffi_closure_free (void *ptr)
/* Clear instruction \
mapping. */ \
})
+#else
+#define FFI_INIT_TRAMPOLINE(TRAMP,FUN,CTX) \
+({ unsigned char *__tramp = (unsigned char*)(TRAMP); \
+ unsigned int __fun = (unsigned int)(FUN); \
+ unsigned int __ctx = (unsigned int)(CTX); \
+ unsigned char *insns = (unsigned char *)(CTX); \
+ memcpy (__tramp, ffi_arm_trampoline, sizeof ffi_arm_trampoline); \
+ *(unsigned int*) &__tramp[12] = __ctx; \
+ *(unsigned int*) &__tramp[16] = __fun; \
+ API_CacheTextUpdate(__tramp, FFI_TRAMPOLINE_SIZE); /* flush cache. */ \
+ })
+#endif
#endif
diff --git a/libffi/src/closures.c b/libffi/src/closures.c
index 2beea75..f1bd897 100644
--- a/libffi/src/closures.c
+++ b/libffi/src/closures.c
@@ -47,7 +47,7 @@
# define FFI_MMAP_EXEC_WRIT 1
# define HAVE_MNTENT 1
# endif
-# if defined(X86_WIN32) || defined(X86_WIN64) || defined(__OS2__) || defined (SYLIXOS)
+# if defined(X86_WIN32) || defined(X86_WIN64) || defined(__OS2__)
/* Windows systems may have Data Execution Protection (DEP) enabled,
which requires the use of VirtualMalloc/VirtualFree to alloc/free
executable memory. */
diff --git a/libffi/src/mips/ffi.c b/libffi/src/mips/ffi.c
index 4f862fc..bc92293 100644
--- a/libffi/src/mips/ffi.c
+++ b/libffi/src/mips/ffi.c
@@ -472,6 +472,7 @@ ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
((cif->arg_types)[index]->type << (arg_reg * FFI_FLAG_BITS));
arg_reg++;
break;
+#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
case FFI_TYPE_LONGDOUBLE:
/* Align it. */
arg_reg = ALIGN(arg_reg, 2);
@@ -490,6 +491,7 @@ ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
arg_reg++;
}
break;
+#endif
case FFI_TYPE_STRUCT:
loc = arg_reg * FFI_SIZEOF_ARG;
@@ -552,6 +554,7 @@ ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
cif->flags += cif->rtype->type << (FFI_FLAG_BITS * 8);
break;
+#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
case FFI_TYPE_LONGDOUBLE:
/* Long double is returned as if it were a struct containing
two doubles. */
@@ -568,6 +571,8 @@ ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
<< (4 + (FFI_FLAG_BITS * 8));
}
break;
+#endif
+
default:
cif->flags += FFI_TYPE_INT << (FFI_FLAG_BITS * 8);
break;
diff --git a/libffi/src/powerpc/ffi_sysv.c b/libffi/src/powerpc/ffi_sysv.c
index fbe85fe..ee168c5 100644
--- a/libffi/src/powerpc/ffi_sysv.c
+++ b/libffi/src/powerpc/ffi_sysv.c
@@ -665,7 +665,11 @@ ffi_prep_closure_loc_sysv (ffi_closure *closure,
*(void **) &tramp[3] = codeloc; /* context */
/* Flush the icache. */
+#ifndef SYLIXOS
flush_icache ((char *)tramp, (char *)codeloc, FFI_TRAMPOLINE_SIZE);
+#else
+ API_CacheTextUpdate((char *)tramp, FFI_TRAMPOLINE_SIZE);
+#endif
closure->cif = cif;
closure->fun = fun;
diff --git a/libffi/src/powerpc/ffitarget.h b/libffi/src/powerpc/ffitarget.h
index b47b0f5..66d5de9 100644
--- a/libffi/src/powerpc/ffitarget.h
+++ b/libffi/src/powerpc/ffitarget.h
@@ -116,7 +116,7 @@ typedef enum ffi_abi {
| FFI_SYSV_SOFT_FLOAT
# endif
# if (defined (__SVR4_STRUCT_RETURN) \
- || defined (POWERPC_FREEBSD) && !defined (__AIX_STRUCT_RETURN))
+ || defined (POWERPC_FREEBSD) && !defined (__AIX_STRUCT_RETURN)) || defined(SYLIXOS)
| FFI_SYSV_STRUCT_RET
# endif
# if __LDBL_MANT_DIG__ == 106
diff --git a/libffi/src/x86/ffi.c b/libffi/src/x86/ffi.c
index 006c95d..da7220f 100644
--- a/libffi/src/x86/ffi.c
+++ b/libffi/src/x86/ffi.c
@@ -340,12 +340,15 @@ extern int
ffi_call_win64(unsigned int (*)(char *, extended_cif *), extended_cif *,
unsigned, unsigned, unsigned *, void (*fn)(void));
#else
+#ifdef X86_WIN32
extern void
ffi_call_win32(unsigned int (*)(char *, extended_cif *), extended_cif *,
unsigned, unsigned, unsigned, unsigned *, void (*fn)(void));
+#else
extern void ffi_call_SYSV(void (*)(char *, extended_cif *), extended_cif *,
unsigned, unsigned, unsigned *, void (*fn)(void));
#endif
+#endif
void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
{
@@ -393,6 +396,7 @@ void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
case FFI_SYSV:
case FFI_MS_CDECL:
#endif
+#ifdef X86_WIN32
case FFI_STDCALL:
case FFI_THISCALL:
case FFI_FASTCALL:
@@ -402,6 +406,7 @@ void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
ecif.rvalue, fn);
break;
#endif
+#endif
default:
FFI_ASSERT(0);
break;
@@ -741,6 +746,7 @@ ffi_prep_closure_loc (ffi_closure* closure,
&ffi_closure_SYSV,
(void*)codeloc);
}
+#ifdef X86_WIN32
else if (cif->abi == FFI_REGISTER)
{
FFI_INIT_TRAMPOLINE_WIN32 (&closure->tramp[0],
@@ -765,7 +771,6 @@ ffi_prep_closure_loc (ffi_closure* closure,
&ffi_closure_STDCALL,
(void*)codeloc);
}
-#ifdef X86_WIN32
else if (cif->abi == FFI_MS_CDECL)
{
FFI_INIT_TRAMPOLINE (&closure->tramp[0],
@@ -909,7 +914,7 @@ ffi_raw_call(ffi_cif *cif, void (*fn)(void), void *rvalue, ffi_raw *fake_avalue)
case FFI_SYSV:
case FFI_MS_CDECL:
#endif
-#ifndef X86_WIN64
+#ifdef X86_WIN32
case FFI_STDCALL:
case FFI_THISCALL:
case FFI_FASTCALL:
diff --git a/libffi/src/x86/ffi64.c b/libffi/src/x86/ffi64.c
index 37eee7e..5c52793 100644
--- a/libffi/src/x86/ffi64.c
+++ b/libffi/src/x86/ffi64.c
@@ -564,7 +564,9 @@ ffi_prep_closure_loc (ffi_closure* closure,
closure->fun = fun;
closure->user_data = user_data;
+#ifdef SYLIXOS
API_CacheTextUpdate((void *)tramp, FFI_TRAMPOLINE_SIZE);
+#endif
return FFI_OK;
}