Merge branch 'master' of github.com:/atgreen/libffi

Add ChangeLog entry.
This commit is contained in:
Anthony Green
2013-11-30 20:54:54 -05:00
16 changed files with 809 additions and 630 deletions

2
.gitignore vendored
View File

@@ -19,3 +19,5 @@ autom4te.cache
libffi.xcodeproj/xcuserdata libffi.xcodeproj/xcuserdata
libffi.xcodeproj/project.xcworkspace libffi.xcodeproj/project.xcworkspace
ios/ ios/
osx/
build_*/

View File

@@ -1,3 +1,26 @@
2012-11-30 Zachary Waldowski <zwaldowski@gmail.com>
* src/arm/ffi.c, src/dlmalloc.c, src/x86/ffi.c: Silence Clang
warnings.
* src/arm/sysv.S: Simplify RETLDM arguments for LLVM 3.1. More
Clang clean-ups.
* .gitignore: Exclude OS X generated source and build_.
* generate-osx-source-and-headers.py: Clean up, modernize scripts.
* generate-ios-source-and-headers.py: Ditto, and add __arm64__
support.
* include/ffi_common.h: Test for HAVE_STRING_H.
* src/closures.c (open_temp_exec_file_dir): Use size_t.
* src/prep_cif (ffi_prep_cif_core): Cast ALIGN result.
* src/x86/ffi64.c: More Clang warning clean-ups.
* src/aarch64/sysv.S: Use CNAME for global symbols. Only use
.size for ELF targets.
* src/aarch64/ffi.c: Clean up for double == long double. Clean up
for Xcode warnings. Use Clang cache invalidation builtin. Use
size_t in place of unsigned in many places.
* libffi.xcodeproj/project.pbxproj: Include x86_64+aarch64 pieces
in library. Export headers properly.
* build-ios.sh: Remove.
2013-11-21 Anthony Green <green@moxielogic.com> 2013-11-21 Anthony Green <green@moxielogic.com>
* configure, Makefile.in, include/Makefile.in, include/ffi.h.in, * configure, Makefile.in, include/Makefile.in, include/ffi.h.in,

View File

@@ -1,67 +0,0 @@
#!/bin/sh
PLATFORM_IOS=/Developer/Platforms/iPhoneOS.platform/
PLATFORM_IOS_SIM=/Developer/Platforms/iPhoneSimulator.platform/
SDK_IOS_VERSION="4.2"
MIN_IOS_VERSION="3.0"
OUTPUT_DIR="universal-ios"
build_target () {
local platform=$1
local sdk=$2
local arch=$3
local triple=$4
local builddir=$5
mkdir -p "${builddir}"
pushd "${builddir}"
export CC="${platform}"/Developer/usr/bin/gcc-4.2
export CFLAGS="-arch ${arch} -isysroot ${sdk} -miphoneos-version-min=${MIN_IOS_VERSION}"
../configure --host=${triple} && make
popd
}
# Build all targets
build_target "${PLATFORM_IOS}" "${PLATFORM_IOS}/Developer/SDKs/iPhoneOS${SDK_IOS_VERSION}.sdk/" armv6 arm-apple-darwin10 armv6-ios
build_target "${PLATFORM_IOS}" "${PLATFORM_IOS}/Developer/SDKs/iPhoneOS${SDK_IOS_VERSION}.sdk/" armv7 arm-apple-darwin10 armv7-ios
build_target "${PLATFORM_IOS_SIM}" "${PLATFORM_IOS_SIM}/Developer/SDKs/iPhoneSimulator${SDK_IOS_VERSION}.sdk/" i386 i386-apple-darwin10 i386-ios-sim
# Create universal output directories
mkdir -p "${OUTPUT_DIR}"
mkdir -p "${OUTPUT_DIR}/include"
mkdir -p "${OUTPUT_DIR}/include/armv6"
mkdir -p "${OUTPUT_DIR}/include/armv7"
mkdir -p "${OUTPUT_DIR}/include/i386"
# Create the universal binary
lipo -create armv6-ios/.libs/libffi.a armv7-ios/.libs/libffi.a i386-ios-sim/.libs/libffi.a -output "${OUTPUT_DIR}/libffi.a"
# Copy in the headers
copy_headers () {
local src=$1
local dest=$2
# Fix non-relative header reference
sed 's/<ffitarget.h>/"ffitarget.h"/' < "${src}/include/ffi.h" > "${dest}/ffi.h"
cp "${src}/include/ffitarget.h" "${dest}"
}
copy_headers armv6-ios "${OUTPUT_DIR}/include/armv6"
copy_headers armv7-ios "${OUTPUT_DIR}/include/armv7"
copy_headers i386-ios-sim "${OUTPUT_DIR}/include/i386"
# Create top-level header
(
cat << EOF
#ifdef __arm__
#include <arm/arch.h>
#ifdef _ARM_ARCH_6
#include "include/armv6/ffi.h"
#elif _ARM_ARCH_7
#include "include/armv7/ffi.h"
#endif
#elif defined(__i386__)
#include "include/i386/ffi.h"
#endif
EOF
) > "${OUTPUT_DIR}/ffi.h"

View File

@@ -1,29 +1,40 @@
#!/usr/bin/env python #!/usr/bin/env python
import subprocess import subprocess
import re import re
import os import os
import errno import errno
import collections import collections
import sys
class Platform(object): class Platform(object):
pass pass
sdk_re = re.compile(r'.*-sdk ([a-zA-Z0-9.]*)') sdk_re = re.compile(r'.*-sdk ([a-zA-Z0-9.]*)')
def sdkinfo(sdkname): def sdkinfo(sdkname):
ret = {} ret = {}
for line in subprocess.Popen(['xcodebuild', '-sdk', sdkname, '-version'], stdout=subprocess.PIPE).stdout: for line in subprocess.Popen(['xcodebuild', '-sdk', sdkname, '-version'], stdout=subprocess.PIPE).stdout:
kv = line.strip().split(': ', 1) kv = line.strip().split(': ', 1)
if len(kv) == 2: if len(kv) == 2:
k,v = kv k, v = kv
ret[k] = v ret[k] = v
return ret return ret
def mkdir_p(path):
try:
os.makedirs(path)
except OSError as exc: # Python >2.5
if exc.errno == errno.EEXIST:
pass
else:
raise
sim_sdk_info = sdkinfo('iphonesimulator') sim_sdk_info = sdkinfo('iphonesimulator')
device_sdk_info = sdkinfo('iphoneos') device_sdk_info = sdkinfo('iphoneos')
def latest_sdks(): def latest_sdks():
latest_sim = None latest_sim = None
latest_device = None latest_device = None
@@ -39,36 +50,62 @@ def latest_sdks():
sim_sdk, device_sdk = latest_sdks() sim_sdk, device_sdk = latest_sdks()
class simulator_platform(Platform):
sdk='iphonesimulator'
arch = 'i386'
name = 'simulator'
triple = 'i386-apple-darwin10'
sdkroot = sim_sdk_info['Path']
prefix = "#if !defined(__arm__) && defined(__i386__)\n\n" class simulator_platform(Platform):
sdk = 'iphonesimulator'
arch = 'i386'
short_arch = arch
triple = 'i386-apple-darwin11'
sdkroot = sim_sdk_info['Path']
version_min = '5.1.1'
prefix = "#ifdef __i386__\n\n"
suffix = "\n\n#endif" suffix = "\n\n#endif"
class simulator64_platform(Platform):
sdk = 'iphonesimulator'
arch = 'x86_64'
short_arch = arch
triple = 'x86_64-apple-darwin13'
sdkroot = sim_sdk_info['Path']
version_min = '7.0'
prefix = "#ifdef __x86_64__\n\n"
suffix = "\n\n#endif"
class device_platform(Platform): class device_platform(Platform):
sdk='iphoneos' sdk = 'iphoneos'
name = 'ios'
arch = 'armv7' arch = 'armv7'
triple = 'arm-apple-darwin10' short_arch = 'arm'
triple = 'arm-apple-darwin11'
sdkroot = device_sdk_info['Path'] sdkroot = device_sdk_info['Path']
version_min = '5.1.1'
prefix = "#ifdef __arm__\n\n" prefix = "#ifdef __arm__\n\n"
suffix = "\n\n#endif" suffix = "\n\n#endif"
def move_file(src_dir, dst_dir, filename, file_suffix=None, prefix='', suffix=''): class device64_platform(Platform):
if not os.path.exists(dst_dir): sdk = 'iphoneos'
os.makedirs(dst_dir) arch = 'arm64'
short_arch = 'arm64'
triple = 'aarch64-apple-darwin13'
sdkroot = device_sdk_info['Path']
version_min = '7.0'
prefix = "#ifdef __arm64__\n\n"
suffix = "\n\n#endif"
def move_file(src_dir, dst_dir, filename, file_suffix=None, prefix='', suffix=''):
mkdir_p(dst_dir)
out_filename = filename out_filename = filename
if file_suffix: if file_suffix:
split_name = os.path.splitext(filename) split_name = os.path.splitext(filename)
out_filename = "%s_%s%s" % (split_name[0], file_suffix, split_name[1]) out_filename = "%s_%s%s" % (split_name[0], file_suffix, split_name[1])
with open(os.path.join(src_dir, filename)) as in_file: with open(os.path.join(src_dir, filename)) as in_file:
with open(os.path.join(dst_dir, out_filename), 'w') as out_file: with open(os.path.join(dst_dir, out_filename), 'w') as out_file:
@@ -82,16 +119,15 @@ def move_file(src_dir, dst_dir, filename, file_suffix=None, prefix='', suffix=''
headers_seen = collections.defaultdict(set) headers_seen = collections.defaultdict(set)
def move_source_tree(src_dir, dest_dir, dest_include_dir, arch=None, prefix=None, suffix=None): def move_source_tree(src_dir, dest_dir, dest_include_dir, arch=None, prefix=None, suffix=None):
for root, dirs, files in os.walk(src_dir, followlinks=True): for root, dirs, files in os.walk(src_dir, followlinks=True):
relroot = os.path.relpath(root,src_dir) relroot = os.path.relpath(root, src_dir)
def move_dir(arch, prefix='', suffix='', files=[]): def move_dir(arch, prefix='', suffix='', files=[]):
for file in files: for file in files:
file_suffix = None
if file.endswith('.h'): if file.endswith('.h'):
if dest_include_dir: if dest_include_dir:
file_suffix = arch
if arch: if arch:
headers_seen[file].add(arch) headers_seen[file].add(arch)
move_file(root, dest_include_dir, file, arch, prefix=prefix, suffix=suffix) move_file(root, dest_include_dir, file, arch, prefix=prefix, suffix=suffix)
@@ -109,46 +145,66 @@ def move_source_tree(src_dir, dest_dir, dest_include_dir, arch=None, prefix=None
move_dir(arch='arm', move_dir(arch='arm',
prefix="#ifdef __arm__\n\n", prefix="#ifdef __arm__\n\n",
suffix="\n\n#endif", suffix="\n\n#endif",
files=files) files=['sysv.S', 'trampoline.S', 'ffi.c'])
elif relroot == 'aarch64':
move_dir(arch='arm64',
prefix="#ifdef __arm64__\n\n",
suffix="\n\n#endif",
files=['sysv.S', 'ffi.c'])
elif relroot == 'x86': elif relroot == 'x86':
move_dir(arch='i386', move_dir(arch='i386',
prefix="#if !defined(__arm__) && defined(__i386__)\n\n", prefix="#ifdef __i386__\n\n",
suffix="\n\n#endif", suffix="\n\n#endif",
files=files) files=['darwin.S', 'ffi.c'])
move_dir(arch='x86_64',
prefix="#ifdef __x86_64__\n\n",
suffix="\n\n#endif",
files=['darwin64.S', 'ffi64.c'])
def build_target(platform): def build_target(platform):
def xcrun_cmd(cmd): def xcrun_cmd(cmd):
return subprocess.check_output(['xcrun', '-sdk', platform.sdkroot, '-find', cmd]).strip() return subprocess.check_output(['xcrun', '-sdk', platform.sdkroot, '-find', cmd]).strip()
build_dir = 'build_' + platform.name build_dir = 'build_' + platform.short_arch
if not os.path.exists(build_dir): mkdir_p(build_dir)
os.makedirs(build_dir) env = dict(CC=xcrun_cmd('clang'),
env = dict(CC=xcrun_cmd('clang'), LD=xcrun_cmd('ld'),
LD=xcrun_cmd('ld'), CFLAGS='-arch %s -isysroot %s -miphoneos-version-min=%s' % (platform.arch, platform.sdkroot, platform.version_min))
CFLAGS='-arch %s -isysroot %s -miphoneos-version-min=4.0' % (platform.arch, platform.sdkroot)) working_dir = os.getcwd()
working_dir=os.getcwd() try:
try: os.chdir(build_dir)
os.chdir(build_dir) subprocess.check_call(['../configure', '-host', platform.triple], env=env)
subprocess.check_call(['../configure', '-host', platform.triple], env=env) move_source_tree('.', None, '../ios/include',
move_source_tree('.', None, '../ios/include', arch=platform.short_arch,
arch=platform.arch, prefix=platform.prefix,
prefix=platform.prefix, suffix=platform.suffix)
suffix=platform.suffix) move_source_tree('./include', None, '../ios/include',
move_source_tree('./include', None, '../ios/include', arch=platform.short_arch,
arch=platform.arch, prefix=platform.prefix,
prefix=platform.prefix, suffix=platform.suffix)
suffix=platform.suffix) finally:
finally: os.chdir(working_dir)
os.chdir(working_dir)
for header_name, archs in headers_seen.iteritems():
basename, suffix = os.path.splitext(header_name)
def make_tramp():
with open('src/arm/trampoline.S', 'w') as tramp_out:
p = subprocess.Popen(['bash', 'src/arm/gentramp.sh'], stdout=tramp_out)
p.wait()
for header_name, archs in headers_seen.iteritems():
basename, suffix = os.path.splitext(header_name)
def main(): def main():
make_tramp()
move_source_tree('src', 'ios/src', 'ios/include') move_source_tree('src', 'ios/src', 'ios/include')
move_source_tree('include', None, 'ios/include') move_source_tree('include', None, 'ios/include')
build_target(simulator_platform) build_target(simulator_platform)
build_target(simulator64_platform)
build_target(device_platform) build_target(device_platform)
build_target(device64_platform)
for header_name, archs in headers_seen.iteritems(): for header_name, archs in headers_seen.iteritems():
basename, suffix = os.path.splitext(header_name) basename, suffix = os.path.splitext(header_name)

View File

@@ -4,24 +4,36 @@ import re
import os import os
import errno import errno
import collections import collections
import sys
class Platform(object): class Platform(object):
pass pass
sdk_re = re.compile(r'.*-sdk ([a-zA-Z0-9.]*)') sdk_re = re.compile(r'.*-sdk ([a-zA-Z0-9.]*)')
def sdkinfo(sdkname): def sdkinfo(sdkname):
ret = {} ret = {}
for line in subprocess.Popen(['xcodebuild', '-sdk', sdkname, '-version'], stdout=subprocess.PIPE).stdout: for line in subprocess.Popen(['xcodebuild', '-sdk', sdkname, '-version'], stdout=subprocess.PIPE).stdout:
kv = line.strip().split(': ', 1) kv = line.strip().split(': ', 1)
if len(kv) == 2: if len(kv) == 2:
k,v = kv k, v = kv
ret[k] = v ret[k] = v
return ret return ret
def mkdir_p(path):
try:
os.makedirs(path)
except OSError as exc: # Python >2.5
if exc.errno == errno.EEXIST:
pass
else:
raise
desktop_sdk_info = sdkinfo('macosx') desktop_sdk_info = sdkinfo('macosx')
def latest_sdks(): def latest_sdks():
latest_desktop = None latest_desktop = None
for line in subprocess.Popen(['xcodebuild', '-showsdks'], stdout=subprocess.PIPE).stdout: for line in subprocess.Popen(['xcodebuild', '-showsdks'], stdout=subprocess.PIPE).stdout:
@@ -34,35 +46,38 @@ def latest_sdks():
desktop_sdk = latest_sdks() desktop_sdk = latest_sdks()
class desktop_platform_32(Platform):
sdk='macosx' class desktop32_platform(Platform):
sdk = 'macosx'
arch = 'i386' arch = 'i386'
name = 'mac32' name = 'mac32'
triple = 'i386-apple-darwin10' triple = 'i386-apple-darwin11'
sdkroot = desktop_sdk_info['Path'] sdkroot = desktop_sdk_info['Path']
version_min = '10.7'
prefix = "#if defined(__i386__) && !defined(__x86_64__)\n\n" prefix = "#ifdef __i386__\n\n"
suffix = "\n\n#endif" suffix = "\n\n#endif"
class desktop_platform_64(Platform):
sdk='macosx' class desktop64_platform(Platform):
sdk = 'macosx'
arch = 'x86_64' arch = 'x86_64'
name = 'mac' name = 'mac'
triple = 'x86_64-apple-darwin10' triple = 'x86_64-apple-darwin11'
sdkroot = desktop_sdk_info['Path'] sdkroot = desktop_sdk_info['Path']
version_min = '10.7'
prefix = "#if !defined(__i386__) && defined(__x86_64__)\n\n" prefix = "#ifdef __x86_64__\n\n"
suffix = "\n\n#endif" suffix = "\n\n#endif"
def move_file(src_dir, dst_dir, filename, file_suffix=None, prefix='', suffix=''):
if not os.path.exists(dst_dir):
os.makedirs(dst_dir)
def move_file(src_dir, dst_dir, filename, file_suffix=None, prefix='', suffix=''):
mkdir_p(dst_dir)
out_filename = filename out_filename = filename
if file_suffix: if file_suffix:
split_name = os.path.splitext(filename) split_name = os.path.splitext(filename)
out_filename = "%s_%s%s" % (split_name[0], file_suffix, split_name[1]) out_filename = "%s_%s%s" % (split_name[0], file_suffix, split_name[1])
with open(os.path.join(src_dir, filename)) as in_file: with open(os.path.join(src_dir, filename)) as in_file:
with open(os.path.join(dst_dir, out_filename), 'w') as out_file: with open(os.path.join(dst_dir, out_filename), 'w') as out_file:
@@ -76,16 +91,15 @@ def move_file(src_dir, dst_dir, filename, file_suffix=None, prefix='', suffix=''
headers_seen = collections.defaultdict(set) headers_seen = collections.defaultdict(set)
def move_source_tree(src_dir, dest_dir, dest_include_dir, arch=None, prefix=None, suffix=None): def move_source_tree(src_dir, dest_dir, dest_include_dir, arch=None, prefix=None, suffix=None):
for root, dirs, files in os.walk(src_dir, followlinks=True): for root, dirs, files in os.walk(src_dir, followlinks=True):
relroot = os.path.relpath(root,src_dir) relroot = os.path.relpath(root, src_dir)
def move_dir(arch, prefix='', suffix='', files=[]): def move_dir(arch, prefix='', suffix='', files=[]):
for file in files: for file in files:
file_suffix = None
if file.endswith('.h'): if file.endswith('.h'):
if dest_include_dir: if dest_include_dir:
file_suffix = arch
if arch: if arch:
headers_seen[file].add(arch) headers_seen[file].add(arch)
move_file(root, dest_include_dir, file, arch, prefix=prefix, suffix=suffix) move_file(root, dest_include_dir, file, arch, prefix=prefix, suffix=suffix)
@@ -101,13 +115,14 @@ def move_source_tree(src_dir, dest_dir, dest_include_dir, arch=None, prefix=None
suffix=suffix) suffix=suffix)
elif relroot == 'x86': elif relroot == 'x86':
move_dir(arch='i386', move_dir(arch='i386',
prefix="#if defined(__i386__) && !defined(__x86_64__)\n\n", prefix="#ifdef __i386__\n\n",
suffix="\n\n#endif", suffix="\n\n#endif",
files=files) files=['darwin.S', 'ffi.c'])
move_dir(arch='x86_64', move_dir(arch='x86_64',
prefix="#if !defined(__i386__) && defined(__x86_64__)\n\n", prefix="#ifdef __x86_64__\n\n",
suffix="\n\n#endif", suffix="\n\n#endif",
files=files) files=['darwin64.S', 'ffi64.c'])
def build_target(platform): def build_target(platform):
def xcrun_cmd(cmd): def xcrun_cmd(cmd):
@@ -118,8 +133,8 @@ def build_target(platform):
os.makedirs(build_dir) os.makedirs(build_dir)
env = dict(CC=xcrun_cmd('clang'), env = dict(CC=xcrun_cmd('clang'),
LD=xcrun_cmd('ld'), LD=xcrun_cmd('ld'),
CFLAGS='-arch %s -isysroot %s -mmacosx-version-min=10.6' % (platform.arch, platform.sdkroot)) CFLAGS='-arch %s -isysroot %s -mmacosx-version-min=%s' % (platform.arch, platform.sdkroot, platform.version_min))
working_dir=os.getcwd() working_dir = os.getcwd()
try: try:
os.chdir(build_dir) os.chdir(build_dir)
subprocess.check_call(['../configure', '-host', platform.triple], env=env) subprocess.check_call(['../configure', '-host', platform.triple], env=env)
@@ -137,11 +152,12 @@ def build_target(platform):
for header_name, archs in headers_seen.iteritems(): for header_name, archs in headers_seen.iteritems():
basename, suffix = os.path.splitext(header_name) basename, suffix = os.path.splitext(header_name)
def main(): def main():
move_source_tree('src', 'osx/src', 'osx/include') move_source_tree('src', 'osx/src', 'osx/include')
move_source_tree('include', None, 'osx/include') move_source_tree('include', None, 'osx/include')
build_target(desktop_platform_32) build_target(desktop32_platform)
build_target(desktop_platform_64) build_target(desktop64_platform)
for header_name, archs in headers_seen.iteritems(): for header_name, archs in headers_seen.iteritems():
basename, suffix = os.path.splitext(header_name) basename, suffix = os.path.splitext(header_name)

View File

@@ -48,7 +48,7 @@ char *alloca ();
#endif #endif
/* Check for the existence of memcpy. */ /* Check for the existence of memcpy. */
#if STDC_HEADERS #if STDC_HEADERS || HAVE_STRING_H
# include <string.h> # include <string.h>
#else #else
# ifndef HAVE_MEMCPY # ifndef HAVE_MEMCPY

File diff suppressed because it is too large Load Diff

View File

@@ -49,14 +49,29 @@ struct call_context
} v [AARCH64_N_VREG]; } v [AARCH64_N_VREG];
}; };
#if defined(__clang__) && defined(__APPLE__)
void sys_icache_invalidate(void *start, size_t len);
#endif
static inline void ffi_clear_cache(void *start, void *end)
{
#if defined(__clang__) && defined(__APPLE__)
sys_icache_invalidate(start, (char *)end-(char *)start);
#elif defined(__GNUC__)
__builtin___clear_cache(start, end);
#else
#error "Missing builtin to flush instruction cache"
#endif
}
static void * static void *
get_x_addr (struct call_context *context, unsigned n) get_x_addr (struct call_context *context, size_t n)
{ {
return &context->x[n]; return &context->x[n];
} }
static void * static void *
get_s_addr (struct call_context *context, unsigned n) get_s_addr (struct call_context *context, size_t n)
{ {
#if defined __AARCH64EB__ #if defined __AARCH64EB__
return &context->v[n].d[1].s[1]; return &context->v[n].d[1].s[1];
@@ -66,7 +81,7 @@ get_s_addr (struct call_context *context, unsigned n)
} }
static void * static void *
get_d_addr (struct call_context *context, unsigned n) get_d_addr (struct call_context *context, size_t n)
{ {
#if defined __AARCH64EB__ #if defined __AARCH64EB__
return &context->v[n].d[1]; return &context->v[n].d[1];
@@ -76,7 +91,7 @@ get_d_addr (struct call_context *context, unsigned n)
} }
static void * static void *
get_v_addr (struct call_context *context, unsigned n) get_v_addr (struct call_context *context, size_t n)
{ {
return &context->v[n]; return &context->v[n];
} }
@@ -94,8 +109,10 @@ get_basic_type_addr (unsigned short type, struct call_context *context,
return get_s_addr (context, n); return get_s_addr (context, n);
case FFI_TYPE_DOUBLE: case FFI_TYPE_DOUBLE:
return get_d_addr (context, n); return get_d_addr (context, n);
#if FFI_TYPE_DOUBLE != FFI_TYPE_LONGDOUBLE
case FFI_TYPE_LONGDOUBLE: case FFI_TYPE_LONGDOUBLE:
return get_v_addr (context, n); return get_v_addr (context, n);
#endif
case FFI_TYPE_UINT8: case FFI_TYPE_UINT8:
case FFI_TYPE_SINT8: case FFI_TYPE_SINT8:
case FFI_TYPE_UINT16: case FFI_TYPE_UINT16:
@@ -123,8 +140,10 @@ get_basic_type_alignment (unsigned short type)
case FFI_TYPE_FLOAT: case FFI_TYPE_FLOAT:
case FFI_TYPE_DOUBLE: case FFI_TYPE_DOUBLE:
return sizeof (UINT64); return sizeof (UINT64);
#if FFI_TYPE_DOUBLE != FFI_TYPE_LONGDOUBLE
case FFI_TYPE_LONGDOUBLE: case FFI_TYPE_LONGDOUBLE:
return sizeof (long double); return sizeof (long double);
#endif
case FFI_TYPE_UINT8: case FFI_TYPE_UINT8:
case FFI_TYPE_SINT8: case FFI_TYPE_SINT8:
case FFI_TYPE_UINT16: case FFI_TYPE_UINT16:
@@ -154,8 +173,10 @@ get_basic_type_size (unsigned short type)
return sizeof (UINT32); return sizeof (UINT32);
case FFI_TYPE_DOUBLE: case FFI_TYPE_DOUBLE:
return sizeof (UINT64); return sizeof (UINT64);
#if FFI_TYPE_DOUBLE != FFI_TYPE_LONGDOUBLE
case FFI_TYPE_LONGDOUBLE: case FFI_TYPE_LONGDOUBLE:
return sizeof (long double); return sizeof (long double);
#endif
case FFI_TYPE_UINT8: case FFI_TYPE_UINT8:
return sizeof (UINT8); return sizeof (UINT8);
case FFI_TYPE_SINT8: case FFI_TYPE_SINT8:
@@ -186,7 +207,7 @@ ffi_call_SYSV (unsigned (*)(struct call_context *context, unsigned char *,
extended_cif *), extended_cif *),
struct call_context *context, struct call_context *context,
extended_cif *, extended_cif *,
unsigned, size_t,
void (*fn)(void)); void (*fn)(void));
extern void extern void
@@ -305,7 +326,9 @@ is_register_candidate (ffi_type *ty)
case FFI_TYPE_VOID: case FFI_TYPE_VOID:
case FFI_TYPE_FLOAT: case FFI_TYPE_FLOAT:
case FFI_TYPE_DOUBLE: case FFI_TYPE_DOUBLE:
#if FFI_TYPE_DOUBLE != FFI_TYPE_LONGDOUBLE
case FFI_TYPE_LONGDOUBLE: case FFI_TYPE_LONGDOUBLE:
#endif
case FFI_TYPE_UINT8: case FFI_TYPE_UINT8:
case FFI_TYPE_UINT16: case FFI_TYPE_UINT16:
case FFI_TYPE_UINT32: case FFI_TYPE_UINT32:
@@ -365,14 +388,14 @@ is_v_register_candidate (ffi_type *ty)
struct arg_state struct arg_state
{ {
unsigned ngrn; /* Next general-purpose register number. */ size_t ngrn; /* Next general-purpose register number. */
unsigned nsrn; /* Next vector register number. */ size_t nsrn; /* Next vector register number. */
unsigned nsaa; /* Next stack offset. */ size_t nsaa; /* Next stack offset. */
}; };
/* Initialize a procedure call argument marshalling state. */ /* Initialize a procedure call argument marshalling state. */
static void static void
arg_init (struct arg_state *state, unsigned call_frame_size) arg_init (struct arg_state *state, size_t call_frame_size)
{ {
state->ngrn = 0; state->ngrn = 0;
state->nsrn = 0; state->nsrn = 0;
@@ -382,7 +405,7 @@ arg_init (struct arg_state *state, unsigned call_frame_size)
/* Return the number of available consecutive core argument /* Return the number of available consecutive core argument
registers. */ registers. */
static unsigned static size_t
available_x (struct arg_state *state) available_x (struct arg_state *state)
{ {
return N_X_ARG_REG - state->ngrn; return N_X_ARG_REG - state->ngrn;
@@ -391,7 +414,7 @@ available_x (struct arg_state *state)
/* Return the number of available consecutive vector argument /* Return the number of available consecutive vector argument
registers. */ registers. */
static unsigned static size_t
available_v (struct arg_state *state) available_v (struct arg_state *state)
{ {
return N_V_ARG_REG - state->nsrn; return N_V_ARG_REG - state->nsrn;
@@ -427,8 +450,8 @@ allocate_to_v (struct call_context *context, struct arg_state *state)
/* Allocate an aligned slot on the stack and return a pointer to it. */ /* Allocate an aligned slot on the stack and return a pointer to it. */
static void * static void *
allocate_to_stack (struct arg_state *state, void *stack, unsigned alignment, allocate_to_stack (struct arg_state *state, void *stack, size_t alignment,
unsigned size) size_t size)
{ {
void *allocation; void *allocation;
@@ -457,9 +480,11 @@ copy_basic_type (void *dest, void *source, unsigned short type)
case FFI_TYPE_DOUBLE: case FFI_TYPE_DOUBLE:
*(double *) dest = *(double *) source; *(double *) dest = *(double *) source;
break; break;
#if FFI_TYPE_DOUBLE != FFI_TYPE_LONGDOUBLE
case FFI_TYPE_LONGDOUBLE: case FFI_TYPE_LONGDOUBLE:
*(long double *) dest = *(long double *) source; *(long double *) dest = *(long double *) source;
break; break;
#endif
case FFI_TYPE_UINT8: case FFI_TYPE_UINT8:
*(ffi_arg *) dest = *(UINT8 *) source; *(ffi_arg *) dest = *(UINT8 *) source;
break; break;
@@ -514,8 +539,8 @@ copy_hfa_to_reg_or_stack (void *memory,
{ {
int i; int i;
unsigned short type = get_homogeneous_type (ty); unsigned short type = get_homogeneous_type (ty);
unsigned elems = element_count (ty); unsigned count = element_count (ty);
for (i = 0; i < elems; i++) for (i = 0; i < count; i++)
{ {
void *reg = allocate_to_v (context, state); void *reg = allocate_to_v (context, state);
copy_basic_type (reg, memory, type); copy_basic_type (reg, memory, type);
@@ -548,11 +573,13 @@ allocate_to_register_or_stack (struct call_context *context,
return allocate_to_d (context, state); return allocate_to_d (context, state);
state->nsrn = N_V_ARG_REG; state->nsrn = N_V_ARG_REG;
break; break;
#if FFI_TYPE_DOUBLE != FFI_TYPE_LONGDOUBLE
case FFI_TYPE_LONGDOUBLE: case FFI_TYPE_LONGDOUBLE:
if (state->nsrn < N_V_ARG_REG) if (state->nsrn < N_V_ARG_REG)
return allocate_to_v (context, state); return allocate_to_v (context, state);
state->nsrn = N_V_ARG_REG; state->nsrn = N_V_ARG_REG;
break; break;
#endif
case FFI_TYPE_UINT8: case FFI_TYPE_UINT8:
case FFI_TYPE_SINT8: case FFI_TYPE_SINT8:
case FFI_TYPE_UINT16: case FFI_TYPE_UINT16:
@@ -615,7 +642,9 @@ aarch64_prep_args (struct call_context *context, unsigned char *stack,
appropriate register, or if none are available, to the stack. */ appropriate register, or if none are available, to the stack. */
case FFI_TYPE_FLOAT: case FFI_TYPE_FLOAT:
case FFI_TYPE_DOUBLE: case FFI_TYPE_DOUBLE:
#if FFI_TYPE_DOUBLE != FFI_TYPE_LONGDOUBLE
case FFI_TYPE_LONGDOUBLE: case FFI_TYPE_LONGDOUBLE:
#endif
case FFI_TYPE_UINT8: case FFI_TYPE_UINT8:
case FFI_TYPE_SINT8: case FFI_TYPE_SINT8:
case FFI_TYPE_UINT16: case FFI_TYPE_UINT16:
@@ -728,7 +757,7 @@ ffi_call (ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
case FFI_SYSV: case FFI_SYSV:
{ {
struct call_context context; struct call_context context;
unsigned stack_bytes; size_t stack_bytes;
/* Figure out the total amount of stack space we need, the /* Figure out the total amount of stack space we need, the
above call frame space needs to be 16 bytes aligned to above call frame space needs to be 16 bytes aligned to
@@ -745,7 +774,9 @@ ffi_call (ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
case FFI_TYPE_VOID: case FFI_TYPE_VOID:
case FFI_TYPE_FLOAT: case FFI_TYPE_FLOAT:
case FFI_TYPE_DOUBLE: case FFI_TYPE_DOUBLE:
#if FFI_TYPE_DOUBLE != FFI_TYPE_LONGDOUBLE
case FFI_TYPE_LONGDOUBLE: case FFI_TYPE_LONGDOUBLE:
#endif
case FFI_TYPE_UINT8: case FFI_TYPE_UINT8:
case FFI_TYPE_SINT8: case FFI_TYPE_SINT8:
case FFI_TYPE_UINT16: case FFI_TYPE_UINT16:
@@ -778,7 +809,7 @@ ffi_call (ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
} }
else if ((cif->rtype->size + 7) / 8 < N_X_ARG_REG) else if ((cif->rtype->size + 7) / 8 < N_X_ARG_REG)
{ {
unsigned size = ALIGN (cif->rtype->size, sizeof (UINT64)); size_t size = ALIGN (cif->rtype->size, sizeof (UINT64));
memcpy (rvalue, get_x_addr (&context, 0), size); memcpy (rvalue, get_x_addr (&context, 0), size);
} }
else else
@@ -824,7 +855,7 @@ static unsigned char trampoline [] =
memcpy (__tramp + 12, &__fun, sizeof (__fun)); \ memcpy (__tramp + 12, &__fun, sizeof (__fun)); \
memcpy (__tramp + 20, &__ctx, sizeof (__ctx)); \ memcpy (__tramp + 20, &__ctx, sizeof (__ctx)); \
memcpy (__tramp + 28, &__flags, sizeof (__flags)); \ memcpy (__tramp + 28, &__flags, sizeof (__flags)); \
__clear_cache(__tramp, __tramp + FFI_TRAMPOLINE_SIZE); \ ffi_clear_cache(__tramp, __tramp + FFI_TRAMPOLINE_SIZE); \
}) })
ffi_status ffi_status
@@ -864,6 +895,9 @@ ffi_prep_closure_loc (ffi_closure* closure,
value back into the call context. */ value back into the call context. */
void void
ffi_closure_SYSV_inner (ffi_closure *closure, struct call_context *context,
void *stack);
void
ffi_closure_SYSV_inner (ffi_closure *closure, struct call_context *context, ffi_closure_SYSV_inner (ffi_closure *closure, struct call_context *context,
void *stack) void *stack)
{ {
@@ -897,11 +931,12 @@ ffi_closure_SYSV_inner (ffi_closure *closure, struct call_context *context,
case FFI_TYPE_SINT64: case FFI_TYPE_SINT64:
case FFI_TYPE_FLOAT: case FFI_TYPE_FLOAT:
case FFI_TYPE_DOUBLE: case FFI_TYPE_DOUBLE:
#if FFI_TYPE_DOUBLE != FFI_TYPE_LONGDOUBLE
case FFI_TYPE_LONGDOUBLE: case FFI_TYPE_LONGDOUBLE:
avalue[i] = allocate_to_register_or_stack (context, stack, avalue[i] = allocate_to_register_or_stack (context, stack,
&state, ty->type); &state, ty->type);
break; break;
#endif
case FFI_TYPE_STRUCT: case FFI_TYPE_STRUCT:
if (is_hfa (ty)) if (is_hfa (ty))
{ {
@@ -958,11 +993,13 @@ ffi_closure_SYSV_inner (ffi_closure *closure, struct call_context *context,
break; break;
} }
#if FFI_TYPE_DOUBLE != FFI_TYPE_LONGDOUBLE
case FFI_TYPE_LONGDOUBLE: case FFI_TYPE_LONGDOUBLE:
memcpy (&avalue[i], memcpy (&avalue[i],
allocate_to_v (context, &state), allocate_to_v (context, &state),
sizeof (*avalue)); sizeof (*avalue));
break; break;
#endif
default: default:
FFI_ASSERT (0); FFI_ASSERT (0);
@@ -1033,7 +1070,9 @@ ffi_closure_SYSV_inner (ffi_closure *closure, struct call_context *context,
case FFI_TYPE_SINT64: case FFI_TYPE_SINT64:
case FFI_TYPE_FLOAT: case FFI_TYPE_FLOAT:
case FFI_TYPE_DOUBLE: case FFI_TYPE_DOUBLE:
#if FFI_TYPE_DOUBLE != FFI_TYPE_LONGDOUBLE
case FFI_TYPE_LONGDOUBLE: case FFI_TYPE_LONGDOUBLE:
#endif
{ {
void *addr = get_basic_type_addr (cif->rtype->type, context, 0); void *addr = get_basic_type_addr (cif->rtype->type, context, 0);
copy_basic_type (addr, rvalue, cif->rtype->type); copy_basic_type (addr, rvalue, cif->rtype->type);
@@ -1042,10 +1081,10 @@ ffi_closure_SYSV_inner (ffi_closure *closure, struct call_context *context,
case FFI_TYPE_STRUCT: case FFI_TYPE_STRUCT:
if (is_hfa (cif->rtype)) if (is_hfa (cif->rtype))
{ {
int i; int j;
unsigned short type = get_homogeneous_type (cif->rtype); unsigned short type = get_homogeneous_type (cif->rtype);
unsigned elems = element_count (cif->rtype); unsigned elems = element_count (cif->rtype);
for (i = 0; i < elems; i++) for (j = 0; j < elems; i++)
{ {
void *reg = get_basic_type_addr (type, context, i); void *reg = get_basic_type_addr (type, context, i);
copy_basic_type (reg, rvalue, type); copy_basic_type (reg, rvalue, type);
@@ -1054,7 +1093,7 @@ ffi_closure_SYSV_inner (ffi_closure *closure, struct call_context *context,
} }
else if ((cif->rtype->size + 7) / 8 < N_X_ARG_REG) else if ((cif->rtype->size + 7) / 8 < N_X_ARG_REG)
{ {
unsigned size = ALIGN (cif->rtype->size, sizeof (UINT64)) ; size_t size = ALIGN (cif->rtype->size, sizeof (UINT64)) ;
memcpy (get_x_addr (context, 0), rvalue, size); memcpy (get_x_addr (context, 0), rvalue, size);
} }
else else
@@ -1073,4 +1112,3 @@ ffi_closure_SYSV_inner (ffi_closure *closure, struct call_context *context,
(closure->fun) (cif, rvalue, avalue, closure->user_data); (closure->fun) (cif, rvalue, avalue, closure->user_data);
} }
} }

View File

@@ -23,15 +23,25 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#include <fficonfig.h> #include <fficonfig.h>
#include <ffi.h> #include <ffi.h>
#ifdef HAVE_MACHINE_ASM_H
#include <machine/asm.h>
#else
#ifdef __USER_LABEL_PREFIX__
#define CONCAT1(a, b) CONCAT2(a, b)
#define CONCAT2(a, b) a ## b
/* Use the right prefix for global labels. */
#define CNAME(x) CONCAT1 (__USER_LABEL_PREFIX__, x)
#else
#define CNAME(x) x
#endif
#endif
#define cfi_adjust_cfa_offset(off) .cfi_adjust_cfa_offset off #define cfi_adjust_cfa_offset(off) .cfi_adjust_cfa_offset off
#define cfi_rel_offset(reg, off) .cfi_rel_offset reg, off #define cfi_rel_offset(reg, off) .cfi_rel_offset reg, off
#define cfi_restore(reg) .cfi_restore reg #define cfi_restore(reg) .cfi_restore reg
#define cfi_def_cfa_register(reg) .cfi_def_cfa_register reg #define cfi_def_cfa_register(reg) .cfi_def_cfa_register reg
.text
.globl ffi_call_SYSV
.type ffi_call_SYSV, #function
/* ffi_call_SYSV() /* ffi_call_SYSV()
Create a stack frame, setup an argument context, call the callee Create a stack frame, setup an argument context, call the callee
@@ -53,7 +63,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
extended_cif *), extended_cif *),
struct call_context *context, struct call_context *context,
extended_cif *, extended_cif *,
unsigned required_stack_size, size_t required_stack_size,
void (*fn)(void)); void (*fn)(void));
Therefore on entry we have: Therefore on entry we have:
@@ -81,8 +91,13 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#define ffi_call_SYSV_FS (8 * 4) #define ffi_call_SYSV_FS (8 * 4)
.text
.globl CNAME(ffi_call_SYSV)
#ifdef __ELF__
.type CNAME(ffi_call_SYSV), #function
#endif
.cfi_startproc .cfi_startproc
ffi_call_SYSV: CNAME(ffi_call_SYSV):
stp x29, x30, [sp, #-16]! stp x29, x30, [sp, #-16]!
cfi_adjust_cfa_offset (16) cfi_adjust_cfa_offset (16)
cfi_rel_offset (x29, 0) cfi_rel_offset (x29, 0)
@@ -92,11 +107,11 @@ ffi_call_SYSV:
cfi_def_cfa_register (x29) cfi_def_cfa_register (x29)
sub sp, sp, #ffi_call_SYSV_FS sub sp, sp, #ffi_call_SYSV_FS
stp x21, x22, [sp, 0] stp x21, x22, [sp, #0]
cfi_rel_offset (x21, 0 - ffi_call_SYSV_FS) cfi_rel_offset (x21, 0 - ffi_call_SYSV_FS)
cfi_rel_offset (x22, 8 - ffi_call_SYSV_FS) cfi_rel_offset (x22, 8 - ffi_call_SYSV_FS)
stp x23, x24, [sp, 16] stp x23, x24, [sp, #16]
cfi_rel_offset (x23, 16 - ffi_call_SYSV_FS) cfi_rel_offset (x23, 16 - ffi_call_SYSV_FS)
cfi_rel_offset (x24, 24 - ffi_call_SYSV_FS) cfi_rel_offset (x24, 24 - ffi_call_SYSV_FS)
@@ -180,7 +195,9 @@ ffi_call_SYSV:
ret ret
.cfi_endproc .cfi_endproc
.size ffi_call_SYSV, .-ffi_call_SYSV #ifdef __ELF__
.size CNAME(ffi_call_SYSV), .-CNAME(ffi_call_SYSV)
#endif
#define ffi_closure_SYSV_FS (8 * 2 + AARCH64_CALL_CONTEXT_SIZE) #define ffi_closure_SYSV_FS (8 * 2 + AARCH64_CALL_CONTEXT_SIZE)
@@ -221,10 +238,10 @@ ffi_call_SYSV:
Voila! */ Voila! */
.text .text
.globl ffi_closure_SYSV .globl CNAME(ffi_closure_SYSV)
.cfi_startproc .cfi_startproc
ffi_closure_SYSV: CNAME(ffi_closure_SYSV):
stp x29, x30, [sp, #-16]! stp x29, x30, [sp, #-16]!
cfi_adjust_cfa_offset (16) cfi_adjust_cfa_offset (16)
cfi_rel_offset (x29, 0) cfi_rel_offset (x29, 0)
@@ -270,7 +287,7 @@ ffi_closure_SYSV:
trampoline was called. */ trampoline was called. */
add x2, x29, #16 add x2, x29, #16
bl ffi_closure_SYSV_inner bl CNAME(ffi_closure_SYSV_inner)
/* Figure out if we should touch the vector registers. */ /* Figure out if we should touch the vector registers. */
ldr x0, [x22, #8] ldr x0, [x22, #8]
@@ -304,4 +321,6 @@ ffi_closure_SYSV:
ret ret
.cfi_endproc .cfi_endproc
.size ffi_closure_SYSV, .-ffi_closure_SYSV #ifdef __ELF__
.size CNAME(ffi_closure_SYSV), .-CNAME(ffi_closure_SYSV)
#endif

View File

@@ -122,6 +122,7 @@ static size_t ffi_put_arg(ffi_type **arg_type, void **arg, char *stack)
value is cif->vfp_used (word bitset of VFP regs used for passing value is cif->vfp_used (word bitset of VFP regs used for passing
arguments). These are only used for the VFP hard-float ABI. arguments). These are only used for the VFP hard-float ABI.
*/ */
int ffi_prep_args_SYSV(char *stack, extended_cif *ecif, float *vfp_space);
int ffi_prep_args_SYSV(char *stack, extended_cif *ecif, float *vfp_space) int ffi_prep_args_SYSV(char *stack, extended_cif *ecif, float *vfp_space)
{ {
register unsigned int i; register unsigned int i;
@@ -149,6 +150,7 @@ int ffi_prep_args_SYSV(char *stack, extended_cif *ecif, float *vfp_space)
return 0; return 0;
} }
int ffi_prep_args_VFP(char *stack, extended_cif *ecif, float *vfp_space);
int ffi_prep_args_VFP(char *stack, extended_cif *ecif, float *vfp_space) int ffi_prep_args_VFP(char *stack, extended_cif *ecif, float *vfp_space)
{ {
// make sure we are using FFI_VFP // make sure we are using FFI_VFP
@@ -160,7 +162,7 @@ int ffi_prep_args_VFP(char *stack, extended_cif *ecif, float *vfp_space)
register ffi_type **p_arg; register ffi_type **p_arg;
char stack_used = 0; char stack_used = 0;
char done_with_regs = 0; char done_with_regs = 0;
char is_vfp_type; int is_vfp_type;
/* the first 4 words on the stack are used for values passed in core /* the first 4 words on the stack are used for values passed in core
* registers. */ * registers. */
@@ -346,9 +348,9 @@ void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
FFI_ASSERT(0); FFI_ASSERT(0);
break; break;
} }
if (small_struct) if (small_struct && rvalue != NULL)
memcpy (rvalue, &temp, cif->rtype->size); memcpy (rvalue, &temp, cif->rtype->size);
else if (vfp_struct) else if (vfp_struct && rvalue != NULL)
memcpy (rvalue, ecif.rvalue, cif->rtype->size); memcpy (rvalue, ecif.rvalue, cif->rtype->size);
} }
@@ -366,6 +368,7 @@ void ffi_closure_VFP (ffi_closure *);
/* This function is jumped to by the trampoline */ /* This function is jumped to by the trampoline */
unsigned int ffi_closure_inner (ffi_closure *closure, void **respp, void *args, void *vfp_args);
unsigned int unsigned int
ffi_closure_inner (ffi_closure *closure, ffi_closure_inner (ffi_closure *closure,
void **respp, void *args, void *vfp_args) void **respp, void *args, void *vfp_args)
@@ -447,7 +450,7 @@ ffi_prep_incoming_args_VFP(char *stack, void **rvalue,
register ffi_type **p_arg; register ffi_type **p_arg;
char done_with_regs = 0; char done_with_regs = 0;
char stack_used = 0; char stack_used = 0;
char is_vfp_type; int is_vfp_type;
FFI_ASSERT(cif->abi == FFI_VFP); FFI_ASSERT(cif->abi == FFI_VFP);
regp = stack; regp = stack;
@@ -881,7 +884,7 @@ static int place_vfp_arg (ffi_cif *cif, ffi_type *t)
} }
/* Found regs to allocate. */ /* Found regs to allocate. */
cif->vfp_used |= new_used; cif->vfp_used |= new_used;
cif->vfp_args[cif->vfp_nargs++] = reg; cif->vfp_args[cif->vfp_nargs++] = (typeof(*(cif->vfp_args)))reg;
/* Update vfp_reg_free. */ /* Update vfp_reg_free. */
if (cif->vfp_used & (1 << cif->vfp_reg_free)) if (cif->vfp_used & (1 << cif->vfp_reg_free))
@@ -889,7 +892,7 @@ static int place_vfp_arg (ffi_cif *cif, ffi_type *t)
reg += nregs; reg += nregs;
while (cif->vfp_used & (1 << reg)) while (cif->vfp_used & (1 << reg))
reg += 1; reg += 1;
cif->vfp_reg_free = reg; cif->vfp_reg_free = (typeof(cif->vfp_reg_free))reg;
} }
return 0; return 0;
next_reg: ; next_reg: ;

View File

@@ -109,58 +109,35 @@
#define UNWIND @ #define UNWIND @
#endif #endif
.syntax unified
#if defined(__thumb__) && !defined(__THUMB_INTERWORK__) #if defined(__thumb__) && !defined(__THUMB_INTERWORK__)
.macro ARM_FUNC_START name #define ARM_FUNC_START(name) \
.text .text; \
.align 0 .align 2; \
.thumb .thumb; \
.thumb_func .thumb_func; \
#ifdef __APPLE__ ENTRY(name); \
ENTRY($0) bx pc; \
nop; \
.arm; \
UNWIND .fnstart; \
_L__##name:
#else #else
ENTRY(\name) #define ARM_FUNC_START(name) \
#endif .text; \
bx pc .align 2; \
nop .arm; \
.arm ENTRY(name); \
UNWIND .fnstart UNWIND .fnstart
/* A hook to tell gdb that we've switched to ARM mode. Also used to call
directly from other local arm routines. */
#ifdef __APPLE__
_L__$0:
#else
_L__\name:
#endif
.endm
#else
.macro ARM_FUNC_START name
.text
.align 0
.arm
#ifdef __APPLE__
ENTRY($0)
#else
ENTRY(\name)
#endif
UNWIND .fnstart
.endm
#endif #endif
.macro RETLDM regs=, cond=, dirn=ia .macro RETLDM
#if defined (__INTERWORKING__) #if defined (__INTERWORKING__)
.ifc "\regs","" ldr lr, [sp], #4
ldr\cond lr, [sp], #4 bx lr
.else
ldm\cond\dirn sp!, {\regs, lr}
.endif
bx\cond lr
#else #else
.ifc "\regs","" ldr pc, [sp], #4
ldr\cond pc, [sp], #4
.else
ldm\cond\dirn sp!, {\regs, pc}
.endif
#endif #endif
.endm .endm
@@ -171,7 +148,7 @@ _L__\name:
@ sp+0: ecif.rvalue @ sp+0: ecif.rvalue
@ This assumes we are using gas. @ This assumes we are using gas.
ARM_FUNC_START ffi_call_SYSV ARM_FUNC_START(ffi_call_SYSV)
@ Save registers @ Save registers
stmfd sp!, {r0-r3, fp, lr} stmfd sp!, {r0-r3, fp, lr}
UNWIND .save {r0-r3, fp, lr} UNWIND .save {r0-r3, fp, lr}
@@ -228,7 +205,7 @@ ARM_FUNC_START ffi_call_SYSV
#if defined(__SOFTFP__) || defined(__ARM_EABI__) #if defined(__SOFTFP__) || defined(__ARM_EABI__)
cmpne r3, #FFI_TYPE_DOUBLE cmpne r3, #FFI_TYPE_DOUBLE
#endif #endif
stmeqia r2, {r0, r1} stmiaeq r2, {r0, r1}
#if !defined(__SOFTFP__) && !defined(__ARM_EABI__) #if !defined(__SOFTFP__) && !defined(__ARM_EABI__)
beq LSYM(Lepilogue) beq LSYM(Lepilogue)
@@ -266,7 +243,7 @@ LSYM(Lepilogue):
void *args; void *args;
*/ */
ARM_FUNC_START ffi_closure_SYSV ARM_FUNC_START(ffi_closure_SYSV)
UNWIND .pad #16 UNWIND .pad #16
add ip, sp, #16 add ip, sp, #16
stmfd sp!, {ip, lr} stmfd sp!, {ip, lr}
@@ -345,7 +322,7 @@ ARM_FUNC_START ffi_closure_SYSV
@ r3: fig->flags @ r3: fig->flags
@ sp+0: ecif.rvalue @ sp+0: ecif.rvalue
ARM_FUNC_START ffi_call_VFP ARM_FUNC_START(ffi_call_VFP)
@ Save registers @ Save registers
stmfd sp!, {r0-r3, fp, lr} stmfd sp!, {r0-r3, fp, lr}
UNWIND .save {r0-r3, fp, lr} UNWIND .save {r0-r3, fp, lr}
@@ -433,7 +410,7 @@ LSYM(Lepilogue_vfp):
.size CNAME(ffi_call_VFP),.ffi_call_VFP_end-CNAME(ffi_call_VFP) .size CNAME(ffi_call_VFP),.ffi_call_VFP_end-CNAME(ffi_call_VFP)
ARM_FUNC_START ffi_closure_VFP ARM_FUNC_START(ffi_closure_VFP)
fstmfdd sp!, {d0-d7} fstmfdd sp!, {d0-d7}
@ r0-r3, then d0-d7 @ r0-r3, then d0-d7
UNWIND .pad #80 UNWIND .pad #80

View File

@@ -264,7 +264,7 @@ static int
open_temp_exec_file_dir (const char *dir) open_temp_exec_file_dir (const char *dir)
{ {
static const char suffix[] = "/ffiXXXXXX"; static const char suffix[] = "/ffiXXXXXX";
int lendir = strlen (dir); size_t lendir = strlen (dir);
char *tempname = __builtin_alloca (lendir + sizeof (suffix)); char *tempname = __builtin_alloca (lendir + sizeof (suffix));
if (!tempname) if (!tempname)

View File

@@ -1661,7 +1661,7 @@ struct malloc_chunk {
typedef struct malloc_chunk mchunk; typedef struct malloc_chunk mchunk;
typedef struct malloc_chunk* mchunkptr; typedef struct malloc_chunk* mchunkptr;
typedef struct malloc_chunk* sbinptr; /* The type of bins of chunks */ typedef struct malloc_chunk* sbinptr; /* The type of bins of chunks */
typedef unsigned int bindex_t; /* Described below */ typedef size_t bindex_t; /* Described below */
typedef unsigned int binmap_t; /* Described below */ typedef unsigned int binmap_t; /* Described below */
typedef unsigned int flag_t; /* The type of various bit flag sets */ typedef unsigned int flag_t; /* The type of various bit flag sets */
@@ -3388,7 +3388,7 @@ static void add_segment(mstate m, char* tbase, size_t tsize, flag_t mmapped) {
*ss = m->seg; /* Push current record */ *ss = m->seg; /* Push current record */
m->seg.base = tbase; m->seg.base = tbase;
m->seg.size = tsize; m->seg.size = tsize;
set_segment_flags(&m->seg, mmapped); (void)set_segment_flags(&m->seg, mmapped);
m->seg.next = ss; m->seg.next = ss;
/* Insert trailing fenceposts */ /* Insert trailing fenceposts */
@@ -3548,7 +3548,7 @@ static void* sys_alloc(mstate m, size_t nb) {
if (!is_initialized(m)) { /* first-time initialization */ if (!is_initialized(m)) { /* first-time initialization */
m->seg.base = m->least_addr = tbase; m->seg.base = m->least_addr = tbase;
m->seg.size = tsize; m->seg.size = tsize;
set_segment_flags(&m->seg, mmap_flag); (void)set_segment_flags(&m->seg, mmap_flag);
m->magic = mparams.magic; m->magic = mparams.magic;
init_bins(m); init_bins(m);
if (is_global(m)) if (is_global(m))

View File

@@ -187,7 +187,7 @@ ffi_status FFI_HIDDEN ffi_prep_cif_core(ffi_cif *cif, ffi_abi abi,
{ {
/* Add any padding if necessary */ /* Add any padding if necessary */
if (((*ptr)->alignment - 1) & bytes) if (((*ptr)->alignment - 1) & bytes)
bytes = ALIGN(bytes, (*ptr)->alignment); bytes = (unsigned)ALIGN(bytes, (*ptr)->alignment);
#ifdef TILE #ifdef TILE
if (bytes < 10 * FFI_SIZEOF_ARG && if (bytes < 10 * FFI_SIZEOF_ARG &&

View File

@@ -42,6 +42,7 @@
/* ffi_prep_args is called by the assembly routine once stack space /* ffi_prep_args is called by the assembly routine once stack space
has been allocated for the function's arguments */ has been allocated for the function's arguments */
void ffi_prep_args(char *stack, extended_cif *ecif);
void ffi_prep_args(char *stack, extended_cif *ecif) void ffi_prep_args(char *stack, extended_cif *ecif)
{ {
register unsigned int i; register unsigned int i;

View File

@@ -168,7 +168,7 @@ classify_argument (ffi_type *type, enum x86_64_reg_class classes[],
case FFI_TYPE_SINT64: case FFI_TYPE_SINT64:
case FFI_TYPE_POINTER: case FFI_TYPE_POINTER:
{ {
int size = byte_offset + type->size; size_t size = byte_offset + type->size;
if (size <= 4) if (size <= 4)
{ {
@@ -210,7 +210,7 @@ classify_argument (ffi_type *type, enum x86_64_reg_class classes[],
case FFI_TYPE_STRUCT: case FFI_TYPE_STRUCT:
{ {
const int UNITS_PER_WORD = 8; const int UNITS_PER_WORD = 8;
int words = (type->size + UNITS_PER_WORD - 1) / UNITS_PER_WORD; int words = ((int)type->size + UNITS_PER_WORD - 1) / UNITS_PER_WORD;
ffi_type **ptr; ffi_type **ptr;
int i; int i;
enum x86_64_reg_class subclasses[MAX_CLASSES]; enum x86_64_reg_class subclasses[MAX_CLASSES];
@@ -242,7 +242,7 @@ classify_argument (ffi_type *type, enum x86_64_reg_class classes[],
return 0; return 0;
for (i = 0; i < num; i++) for (i = 0; i < num; i++)
{ {
int pos = byte_offset / 8; size_t pos = byte_offset / 8;
classes[i + pos] = classes[i + pos] =
merge_classes (subclasses[i], classes[i + pos]); merge_classes (subclasses[i], classes[i + pos]);
} }
@@ -411,7 +411,7 @@ ffi_prep_cif_machdep (ffi_cif *cif)
if (ssecount) if (ssecount)
flags |= 1 << 11; flags |= 1 << 11;
cif->flags = flags; cif->flags = flags;
cif->bytes = ALIGN (bytes, 8); cif->bytes = (unsigned)ALIGN (bytes, 8);
return FFI_OK; return FFI_OK;
} }