From fc5323864be27714faa0c2912228fbb5ed69bb14 Mon Sep 17 00:00:00 2001 From: Prashanth Swaminathan Date: Tue, 6 Jun 2023 16:17:40 -0700 Subject: Add riscv64 target to libffi In order to build VTS tests, libffi is a requirement. Add the configuration to build libffi for 'riscv64'. Bug: 282104321 Test: Verified vts build no longer fails on 'libffi'. Change-Id: I4cf5fe4c91a1eeead065756aa691e456577e91ae --- Android.bp | 7 ++ linux-riscv64/ffi.h | 27 ++++++++ linux-riscv64/fficonfig.h | 164 ++++++++++++++++++++++++++++++++++++++++++++++ linux-riscv64/ffitarget.h | 18 +++++ 4 files changed, 216 insertions(+) create mode 100644 linux-riscv64/ffi.h create mode 100644 linux-riscv64/fficonfig.h create mode 100644 linux-riscv64/ffitarget.h diff --git a/Android.bp b/Android.bp index 32c473b3..97ec54d9 100644 --- a/Android.bp +++ b/Android.bp @@ -132,6 +132,13 @@ cc_library { ], export_include_dirs: ["linux-x86_64"], }, + riscv64: { + srcs: [ + "src/riscv/ffi.c", + "src/riscv/sysv.S", + ], + export_include_dirs: ["linux-riscv64"], + }, }, apex_available: [ "//apex_available:platform", diff --git a/linux-riscv64/ffi.h b/linux-riscv64/ffi.h new file mode 100644 index 00000000..be6c7cc8 --- /dev/null +++ b/linux-riscv64/ffi.h @@ -0,0 +1,27 @@ +/* + * Copyright 2023, The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef LIBFFI_H + +#define RISCV64 +#define CONF_HAVE_LONG_DOUBLE 1 + +#define LIBFFI_H +#include "../src/riscv/ffitarget.h" +#undef LIBFFI_H + +#include "ffi_gen.h" + +#endif diff --git a/linux-riscv64/fficonfig.h b/linux-riscv64/fficonfig.h new file mode 100644 index 00000000..5db20304 --- /dev/null +++ b/linux-riscv64/fficonfig.h @@ -0,0 +1,164 @@ +/* fficonfig.h.in. Generated from configure.ac by autoheader. */ + +/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP + systems. This function is required for `alloca.c' support on those systems. + */ +#undef CRAY_STACKSEG_END + +/* Define to 1 if using `alloca.c'. */ +#undef C_ALLOCA + +/* Define to the flags needed for the .section .eh_frame directive. */ +#define EH_FRAME_FLAGS "aw" + +/* 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. */ +#define HAVE_ALLOCA 1 + +/* Define to 1 if you have and it should be used (not on Ultrix). + */ +#define HAVE_ALLOCA_H 1 + +/* 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 to 1 if you have the header file. */ +#define HAVE_DLFCN_H 1 + +/* Define if __attribute__((visibility("hidden"))) is supported. */ +#define HAVE_HIDDEN_VISIBILITY_ATTRIBUTE 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_INTTYPES_H 1 + +/* 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. */ +#define HAVE_MEMCPY 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the `mmap' function. */ +#define HAVE_MMAP 1 + +/* Define if mmap with MAP_ANON(YMOUS) works. */ +#define HAVE_MMAP_ANON 1 + +/* Define if mmap of /dev/zero works. */ +#define HAVE_MMAP_DEV_ZERO 1 + +/* Define if read-only mmap of a plain file works. */ +#define HAVE_MMAP_FILE 1 + +/* Define if .eh_frame sections should be read-only. */ +#undef HAVE_RO_EH_FRAME + +/* Define to 1 if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRINGS_H + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_MMAN_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to 1 if your C compiler doesn't accept -c and -o together. */ +#undef NO_MINUS_C_MINUS_O + +/* Name of package */ +#define PACKAGE "libffi" + +/* 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. */ +#define SIZEOF_DOUBLE 8 + +/* The size of `long double', as computed by sizeof. */ +#undef SIZEOF_LONG_DOUBLE 16 + +/* 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. */ +#define STDC_HEADERS 1 + +/* 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 +#ifdef __APPLE__ +#define FFI_HIDDEN(name) .private_extern name +#else +#define FFI_HIDDEN(name) .hidden name +#endif +#else +#define FFI_HIDDEN __attribute__ ((visibility ("hidden"))) +#endif +#else +#ifdef LIBFFI_ASM +#define FFI_HIDDEN(name) +#else +#define FFI_HIDDEN +#endif +#endif + diff --git a/linux-riscv64/ffitarget.h b/linux-riscv64/ffitarget.h new file mode 100644 index 00000000..97a4b03a --- /dev/null +++ b/linux-riscv64/ffitarget.h @@ -0,0 +1,18 @@ +/* + * Copyright 2023, The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef LIBFFI_TARGET_H +#include "../src/riscv/ffitarget.h" +#endif -- cgit v1.2.3