Skip to content

Commit

Permalink
New RISC-V port (#281)
Browse files Browse the repository at this point in the history
* Add RISC-V support

This patch adds support for the RISC-V architecture (https://riscv.org).

This patch has been tested using QEMU user-mode emulation and GCC 7.2.0
in the following configurations:

* -march=rv32imac -mabi=ilp32
* -march=rv32g -mabi=ilp32d
* -march=rv64imac -mabi=lp64
* -march=rv64g -mabi=lp64d

The ABI currently can be found at
https://github.com/riscv/riscv-elf-psabi-doc/blob/master/riscv-elf.md .

* Add RISC-V to README

* RISC-V: fix configure.host
  • Loading branch information
sorear authored and atgreen committed Mar 11, 2018
1 parent dca52b5 commit 3840d49
Show file tree
Hide file tree
Showing 7 changed files with 739 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ noinst_HEADERS = \
src/or1k/ffitarget.h \
src/pa/ffitarget.h \
src/powerpc/ffitarget.h src/powerpc/asm.h src/powerpc/ffi_powerpc.h \
src/riscv/ffitarget.h \
src/s390/ffitarget.h src/s390/internal.h \
src/sh/ffitarget.h \
src/sh64/ffitarget.h \
Expand Down Expand Up @@ -144,6 +145,7 @@ EXTRA_libffi_la_SOURCES = \
src/powerpc/linux64_closure.S src/powerpc/ppc_closure.S \
src/powerpc/aix.S src/powerpc/darwin.S src/powerpc/aix_closure.S \
src/powerpc/darwin_closure.S src/powerpc/ffi_darwin.c \
src/riscv/ffi.c src/riscv/sysv.S \
src/s390/ffi.c src/s390/sysv.S \
src/sh/ffi.c src/sh/sysv.S \
src/sh64/ffi.c src/sh64/sysv.S \
Expand Down
3 changes: 3 additions & 0 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ tested:
| PowerPC 64-bit | FreeBSD | GCC |
| PowerPC 64-bit | Linux ELFv1 | GCC |
| PowerPC 64-bit | Linux ELFv2 | GCC |
| RISC-V 32-bit | Linux | GCC |
| RISC-V 64-bit | Linux | GCC |
| S390 | Linux | GCC |
| S390X | Linux | GCC |
| SPARC | Linux | GCC |
Expand Down Expand Up @@ -188,6 +190,7 @@ See the git log for details at http://github.com/libffi/libffi.

4.0 TBD
New API in support of GO closures.
Add RISC-V support.

3.2.1 Nov-12-14
Build fix for non-iOS AArch64 targets.
Expand Down
5 changes: 5 additions & 0 deletions configure.host
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,11 @@ case "${host}" in
TARGET=POWERPC; TARGETDIR=powerpc
;;

riscv*-*)
TARGET=RISCV; TARGETDIR=riscv
SOURCES="ffi.c sysv.S"
;;

s390-*-* | s390x-*-*)
TARGET=S390; TARGETDIR=s390
SOURCES="ffi.c sysv.S"
Expand Down
2 changes: 2 additions & 0 deletions include/ffi_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ void ffi_type_test(ffi_type *a, char *file, int line);
#define FFI_ASSERT_VALID_TYPE(x)
#endif

/* v cast to size_t and aligned up to a multiple of a */
#define FFI_ALIGN(v, a) (((((size_t) (v))-1) | ((a)-1))+1)
/* v cast to size_t and aligned down to a multiple of a */
#define ALIGN_DOWN(v, a) (((size_t) (v)) & -a)

/* Perform machine dependent cif processing */
Expand Down

0 comments on commit 3840d49

Please sign in to comment.