Browse files

strip some unused code from amalgamated libffi

  • Loading branch information...
1 parent 79e0875 commit a96a22706f505a712da7af7e346565c57acb1a65 @timburks committed Jul 9, 2011
Showing with 13 additions and 311 deletions.
  1. +2 −10 libffi/ffi.S
  2. +10 −137 libffi/ffi.c
  3. +1 −164 libffi/ffi.h
View
12 libffi/ffi.S
@@ -1,7 +1,6 @@
-/* This file is mangled from the original to compile using Apple's AS, not GAS */
-
#import "TargetConditionals.h"
+/* This file is mangled from the original to compile using Apple's AS, not GAS */
#if !TARGET_IPHONE_SIMULATOR
#define __SOFTFP__
@@ -317,8 +316,7 @@ _ffi_closure_SYSV:
#endif
-// Import TARGET_IPHONE_SIMULATOR definition
-#import "TargetConditionals.h"
+
#if TARGET_IPHONE_SIMULATOR
/* -----------------------------------------------------------------------
@@ -578,7 +576,6 @@ _ffi_closure_SYSV:
ret $4
.LFE2:
-#if !FFI_NO_RAW_API
#define RAW_CLOSURE_CIF_OFFSET ((FFI_TRAMPOLINE_SIZE + 3) & ~3)
#define RAW_CLOSURE_FUN_OFFSET (RAW_CLOSURE_CIF_OFFSET + 4)
@@ -648,7 +645,6 @@ _ffi_closure_raw_SYSV:
movl -20(%ebp), %edx
jmp .Lrcls_epilogue
.LFE3:
-#endif
.section __IMPORT,__jump_table,symbol_stubs,self_modifying_code+pure_instructions,5
L_ffi_closure_SYSV_inner$stub:
@@ -727,8 +723,6 @@ LASFDE2:
.align 2
LEFDE2:
-#if !FFI_NO_RAW_API
-
.globl _ffi_closure_raw_SYSV.eh
_ffi_closure_raw_SYSV.eh:
LSFDE3:
@@ -760,8 +754,6 @@ LASFDE3:
.align 2
LEFDE3:
-#endif
-
#endif /* ifndef __x86_64__ */
#endif
View
147 libffi/ffi.c
@@ -29,7 +29,8 @@
#define LIBFFI_HIDE_BASIC_TYPES
#include "ffi.h"
-
+#include <stdlib.h>
+#include <TargetConditionals.h>
/* -----------------------------------------------------------------------
ffi_common.h - Copyright (c) 1996 Red Hat, Inc.
@@ -39,43 +40,27 @@
libffi.
----------------------------------------------------------------------- */
-#ifndef FFI_COMMON_H
-#define FFI_COMMON_H
-
#ifdef __cplusplus
extern "C" {
#endif
-
-
+
/* Do not move this. Some versions of AIX are very picky about where
this is positioned. */
#ifdef __GNUC__
//## # define alloca __builtin_alloca
# define MAYBE_UNUSED __attribute__((__unused__))
#else
# define MAYBE_UNUSED
-# if HAVE_ALLOCA_H
-# include <alloca.h>
-# else
-# ifdef _AIX
-#pragma alloca
-# else
+
# ifndef alloca /* predefined by HP cc +Olibcalls */
char *alloca ();
# endif
-# endif
-# endif
+
#endif
- /* Check for the existence of memcpy. */
-#if STDC_HEADERS
-# include <string.h>
-#else
-# ifndef HAVE_MEMCPY
- void bcopy(const void *s1, void *s2, size_t n);
-# define memcpy(d, s, n) bcopy ((s), (d), (n))
-# endif
-#endif
+void bcopy(const void *s1, void *s2, size_t n);
+#define memcpy(d, s, n) bcopy ((s), (d), (n))
+
#if defined(FFI_DEBUG)
#include <stdio.h>
@@ -127,9 +112,6 @@ extern "C" {
}
#endif
-#endif
-
-
/* Type definitions */
#define FFI_TYPEDEF(name, type, id) \
@@ -203,11 +185,8 @@ FFI_TYPEDEF(longdouble, long double, FFI_TYPE_LONGDOUBLE);
/* This file defines generic functions for use with the raw api. */
-#include "ffi.h"
#include <alloca.h>
-#if !FFI_NO_RAW_API
-
size_t
ffi_raw_size (ffi_cif *cif)
{
@@ -218,11 +197,9 @@ ffi_raw_size (ffi_cif *cif)
for (i = cif->nargs-1; i >= 0; i--, at++)
{
-#if !FFI_NO_STRUCTS
if ((*at)->type == FFI_TYPE_STRUCT)
result += ALIGN (sizeof (void*), FFI_SIZEOF_ARG);
else
-#endif
result += ALIGN ((*at)->size, FFI_SIZEOF_ARG);
}
@@ -236,70 +213,19 @@ ffi_raw_to_ptrarray (ffi_cif *cif, ffi_raw *raw, void **args)
unsigned i;
ffi_type **tp = cif->arg_types;
-#if WORDS_BIGENDIAN
-
+ /* assume little endian */
for (i = 0; i < cif->nargs; i++, tp++, args++)
{
- switch ((*tp)->type)
- {
- case FFI_TYPE_UINT8:
- case FFI_TYPE_SINT8:
- *args = (void*) ((char*)(raw++) + FFI_SIZEOF_ARG - 1);
- break;
-
- case FFI_TYPE_UINT16:
- case FFI_TYPE_SINT16:
- *args = (void*) ((char*)(raw++) + FFI_SIZEOF_ARG - 2);
- break;
-
-#if FFI_SIZEOF_ARG >= 4
- case FFI_TYPE_UINT32:
- case FFI_TYPE_SINT32:
- *args = (void*) ((char*)(raw++) + FFI_SIZEOF_ARG - 4);
- break;
-#endif
-
-#if !FFI_NO_STRUCTS
- case FFI_TYPE_STRUCT:
- *args = (raw++)->ptr;
- break;
-#endif
-
- case FFI_TYPE_POINTER:
- *args = (void*) &(raw++)->ptr;
- break;
-
- default:
- *args = raw;
- raw += ALIGN ((*tp)->size, FFI_SIZEOF_ARG) / FFI_SIZEOF_ARG;
- }
- }
-
-#else /* WORDS_BIGENDIAN */
-
-#if !PDP
-
- /* then assume little endian */
- for (i = 0; i < cif->nargs; i++, tp++, args++)
- {
-#if !FFI_NO_STRUCTS
if ((*tp)->type == FFI_TYPE_STRUCT)
{
*args = (raw++)->ptr;
}
else
-#endif
{
*args = (void*) raw;
raw += ALIGN ((*tp)->size, sizeof (void*)) / sizeof (void*);
}
}
-
-#else
-#error "pdp endian not supported"
-#endif /* ! PDP */
-
-#endif /* WORDS_BIGENDIAN */
}
void
@@ -338,11 +264,9 @@ ffi_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_raw *raw)
break;
#endif
-#if !FFI_NO_STRUCTS
case FFI_TYPE_STRUCT:
(raw++)->ptr = *args;
break;
-#endif
case FFI_TYPE_POINTER:
(raw++)->ptr = **(void***) args;
@@ -428,7 +352,6 @@ ffi_prep_raw_closure (ffi_raw_closure* cl,
#endif /* FFI_CLOSURES */
-#endif /* !FFI_NO_RAW_API */
/* -----------------------------------------------------------------------
prep_cif.c - Copyright (c) 1996, 1998, 2007 Red Hat, Inc.
@@ -453,9 +376,6 @@ ffi_prep_raw_closure (ffi_raw_closure* cl,
DEALINGS IN THE SOFTWARE.
----------------------------------------------------------------------- */
-#include "ffi.h"
-#include <stdlib.h>
-
/* Round up to FFI_SIZEOF_ARG. */
#define STACK_ARG_SIZE(x) ALIGN(x, FFI_SIZEOF_ARG)
@@ -602,7 +522,7 @@ ffi_prep_closure (ffi_closure* closure,
}
#endif
-#include "TargetConditionals.h"
+
#if !TARGET_IPHONE_SIMULATOR
#ifdef __arm__
@@ -639,10 +559,6 @@ extern void __clear_cache (void *beg, void *end);
DEALINGS IN THE SOFTWARE.
----------------------------------------------------------------------- */
-#include "ffi.h"
-
-#include <stdlib.h>
-
/* ffi_prep_args is called by the assembly routine once stack space
has been allocated for the function's arguments */
@@ -979,10 +895,6 @@ ffi_prep_closure_loc (ffi_closure* closure,
#ifndef __x86_64__
-#include "ffi.h"
-
-#include <stdlib.h>
-
/* ffi_prep_args is called by the assembly routine once stack space
has been allocated for the function's arguments */
@@ -1130,11 +1042,6 @@ ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
extern void ffi_call_SYSV(void (*)(char *, extended_cif *), extended_cif *,
unsigned, unsigned, unsigned *, void (*fn)(void));
-#ifdef X86_WIN32
-extern void ffi_call_STDCALL(void (*)(char *, extended_cif *), extended_cif *,
- unsigned, unsigned, unsigned *, void (*fn)(void));
-
-#endif /* X86_WIN32 */
void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
{
@@ -1160,12 +1067,6 @@ void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
ffi_call_SYSV(ffi_prep_args, &ecif, cif->bytes, cif->flags, ecif.rvalue,
fn);
break;
-#ifdef X86_WIN32
- case FFI_STDCALL:
- ffi_call_STDCALL(ffi_prep_args, &ecif, cif->bytes, cif->flags,
- ecif.rvalue, fn);
- break;
-#endif /* X86_WIN32 */
default:
FFI_ASSERT(0);
break;
@@ -1183,10 +1084,6 @@ unsigned int FFI_HIDDEN ffi_closure_SYSV_inner (ffi_closure *, void **, void *)
__attribute__ ((regparm(1)));
void FFI_HIDDEN ffi_closure_raw_SYSV (ffi_raw_closure *)
__attribute__ ((regparm(1)));
-#ifdef X86_WIN32
-void FFI_HIDDEN ffi_closure_STDCALL (ffi_closure *)
- __attribute__ ((regparm(1)));
-#endif
/* This function is jumped to by the trampoline */
@@ -1298,14 +1195,6 @@ ffi_prep_closure_loc (ffi_closure* closure,
&ffi_closure_SYSV,
(void*)codeloc);
}
-#ifdef X86_WIN32
- else if (cif->abi == FFI_STDCALL)
- {
- FFI_INIT_TRAMPOLINE_STDCALL (&closure->tramp[0],
- &ffi_closure_STDCALL,
- (void*)codeloc, cif->bytes);
- }
-#endif
else
{
return FFI_BAD_ABI;
@@ -1320,8 +1209,6 @@ ffi_prep_closure_loc (ffi_closure* closure,
/* ------- Native raw API support -------------------------------- */
-#if !FFI_NO_RAW_API
-
ffi_status
ffi_prep_raw_closure_loc (ffi_raw_closure* closure,
ffi_cif* cif,
@@ -1372,12 +1259,6 @@ extern void
ffi_call_SYSV(void (*)(char *, extended_cif *), extended_cif *, unsigned,
unsigned, unsigned *, void (*fn)(void));
-#ifdef X86_WIN32
-extern void
-ffi_call_STDCALL(void (*)(char *, extended_cif *), extended_cif *, unsigned,
- unsigned, unsigned *, void (*fn)(void));
-#endif /* X86_WIN32 */
-
void
ffi_raw_call(ffi_cif *cif, void (*fn)(void), void *rvalue, ffi_raw *fake_avalue)
{
@@ -1405,20 +1286,12 @@ ffi_raw_call(ffi_cif *cif, void (*fn)(void), void *rvalue, ffi_raw *fake_avalue)
ffi_call_SYSV(ffi_prep_args_raw, &ecif, cif->bytes, cif->flags,
ecif.rvalue, fn);
break;
-#ifdef X86_WIN32
- case FFI_STDCALL:
- ffi_call_STDCALL(ffi_prep_args_raw, &ecif, cif->bytes, cif->flags,
- ecif.rvalue, fn);
- break;
-#endif /* X86_WIN32 */
default:
FFI_ASSERT(0);
break;
}
}
-#endif
-
#endif /* __x86_64__ */
#endif
View
165 libffi/ffi.h
@@ -1,170 +1,19 @@
#include "TargetConditionals.h"
-/* fficonfig.h.in. Generated from configure.ac by autoheader. */
-
-/* Define to 1 if using `alloca.c'. */
-#undef C_ALLOCA
-
-/* Define to the flags needed for the .section .eh_frame directive. */
-#undef EH_FRAME_FLAGS
-
/* Define this if you want extra debugging. */
#undef FFI_DEBUG
-/* Define this is you do not want support for the raw API. */
-#undef FFI_NO_RAW_API
-
-/* Define this is you do not want support for aggregate types. */
-#undef FFI_NO_STRUCTS
-
-/* Define to 1 if you have `alloca', as a function or macro. */
-#undef HAVE_ALLOCA
-
-/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix).
- */
-#undef HAVE_ALLOCA_H
-
-/* Define if your assembler supports .cfi_* directives. */
-#undef HAVE_AS_CFI_PSEUDO_OP
-
-/* Define if your assembler supports .register. */
-#undef HAVE_AS_REGISTER_PSEUDO_OP
-
-/* Define if your assembler and linker support unaligned PC relative relocs.
- */
-#undef HAVE_AS_SPARC_UA_PCREL
-
-/* Define if your assembler supports PC relative relocs. */
-#undef HAVE_AS_X86_PCREL
-
-/* Define to 1 if you have the <dlfcn.h> header file. */
-#undef HAVE_DLFCN_H
-
-/* Define if __attribute__((visibility("hidden"))) is supported. */
-#undef HAVE_HIDDEN_VISIBILITY_ATTRIBUTE
-
-/* Define to 1 if you have the <inttypes.h> header file. */
-#undef HAVE_INTTYPES_H
-
-/* Define if you have the long double type and it is bigger than a double */
-#undef HAVE_LONG_DOUBLE
-
-/* Define to 1 if you have the `memcpy' function. */
-#undef HAVE_MEMCPY
-
-/* Define to 1 if you have the <memory.h> header file. */
-#undef HAVE_MEMORY_H
-
-/* Define to 1 if you have the `mmap' function. */
-#undef HAVE_MMAP
-
-/* Define if mmap with MAP_ANON(YMOUS) works. */
-#undef HAVE_MMAP_ANON
-
-/* Define if mmap of /dev/zero works. */
-#undef HAVE_MMAP_DEV_ZERO
-
-/* Define if read-only mmap of a plain file works. */
-#undef HAVE_MMAP_FILE
-
-/* Define if .eh_frame sections should be read-only. */
-#undef HAVE_RO_EH_FRAME
-
-/* Define to 1 if you have the <stdint.h> header file. */
-#undef HAVE_STDINT_H
-
-/* Define to 1 if you have the <stdlib.h> header file. */
-#undef HAVE_STDLIB_H
-
-/* Define to 1 if you have the <strings.h> header file. */
-#undef HAVE_STRINGS_H
-
-/* Define to 1 if you have the <string.h> header file. */
-#undef HAVE_STRING_H
-
-/* Define to 1 if you have the <sys/mman.h> header file. */
-#undef HAVE_SYS_MMAN_H
-
-/* Define to 1 if you have the <sys/stat.h> header file. */
-#undef HAVE_SYS_STAT_H
-
-/* Define to 1 if you have the <sys/types.h> header file. */
-#undef HAVE_SYS_TYPES_H
-
-/* Define to 1 if you have the <unistd.h> header file. */
-#undef HAVE_UNISTD_H
-
-/* Define to 1 if your C compiler doesn't accept -c and -o together. */
-#undef NO_MINUS_C_MINUS_O
-
-/* Name of package */
-#undef PACKAGE
-
-/* Define to the address where bug reports for this package should be sent. */
-#undef PACKAGE_BUGREPORT
-
-/* Define to the full name of this package. */
-#undef PACKAGE_NAME
-
-/* Define to the full name and version of this package. */
-#undef PACKAGE_STRING
-
-/* Define to the one symbol short name of this package. */
-#undef PACKAGE_TARNAME
-
-/* Define to the version of this package. */
-#undef PACKAGE_VERSION
-
-/* The size of `double', as computed by sizeof. */
-#undef SIZEOF_DOUBLE
-
-/* The size of `long double', as computed by sizeof. */
-#undef SIZEOF_LONG_DOUBLE
-
-/* If using the C implementation of alloca, define if you know the
- direction of stack growth for your system; otherwise it will be
- automatically deduced at runtime.
- STACK_DIRECTION > 0 => grows toward higher addresses
- STACK_DIRECTION < 0 => grows toward lower addresses
- STACK_DIRECTION = 0 => direction of growth unknown */
-#undef STACK_DIRECTION
-
-/* Define to 1 if you have the ANSI C header files. */
-#undef STDC_HEADERS
-
-/* Define this if you are using Purify and want to suppress spurious messages.
- */
-#undef USING_PURIFY
-
-/* Version number of package */
-#undef VERSION
-
-/* Define to 1 if your processor stores words with the most significant byte
- first (like Motorola and SPARC, unlike Intel and VAX). */
-#undef WORDS_BIGENDIAN
-
-
-#ifdef HAVE_HIDDEN_VISIBILITY_ATTRIBUTE
-#ifdef LIBFFI_ASM
-#define FFI_HIDDEN(name) .hidden name
-#else
-#define FFI_HIDDEN __attribute__ ((visibility ("hidden")))
-#endif
-#else
#ifdef LIBFFI_ASM
#define FFI_HIDDEN(name)
#else
#define FFI_HIDDEN
#endif
-#endif
-
#if defined (X86_64) && defined (__i386__)
#undef X86_64
#define X86
#endif
-
#if TARGET_IPHONE_SIMULATOR
/* -----------------------------------------------------------------*-C-*-
@@ -214,16 +63,8 @@ typedef signed long ffi_sarg;
typedef enum ffi_abi {
FFI_FIRST_ABI = 0,
- /* ---- Intel x86 Win32 ---------- */
-#ifdef X86_WIN32
- FFI_SYSV,
- FFI_STDCALL,
- /* TODO: Add fastcall support for the sake of completeness */
- FFI_DEFAULT_ABI = FFI_SYSV,
-#endif
-
/* ---- Intel x86 and AMD x86-64 - */
-#if !defined(X86_WIN32) && (defined(__i386__) || defined(__x86_64__))
+#if (defined(__i386__) || defined(__x86_64__))
FFI_SYSV,
FFI_UNIX64, /* Unix variants all use the same ABI for x86-64 */
#ifdef __i386__
@@ -247,11 +88,7 @@ typedef enum ffi_abi {
#define FFI_TRAMPOLINE_SIZE 24
#define FFI_NATIVE_RAW_API 0
#else
-#ifdef X86_WIN32
-#define FFI_TRAMPOLINE_SIZE 13
-#else
#define FFI_TRAMPOLINE_SIZE 10
-#endif
#define FFI_NATIVE_RAW_API 1 /* x86 has native raw api support */
#endif

0 comments on commit a96a227

Please sign in to comment.