Skip to content

Commit

Permalink
Fix risc-v build
Browse files Browse the repository at this point in the history
Two fixes in one:

Firstly, replace non-standard __uint64_t with standard (but optional) uint64_t.
__uint64_t is not a part of C standard; it is defined by some platforms but might not
be present in every environment (e.g. in freestanding build). On the other hand, uint64_t
is standard C. It is optional but virtual guaranteed to be present for any 32/64 bit machine.

Secondly, mark riscv64 for 128-bit long double in make/cmake files. This fixes cmake
build (which detects presence of long double and tries to compile extended functions),
and brings make build to do the same.
  • Loading branch information
tea committed Jul 20, 2024
1 parent d66f477 commit a91cde1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ list(APPEND OPENLIBM_INCLUDE_DIRS
if(${OPENLIBM_ARCH_FOLDER} STREQUAL "i387" OR ${OPENLIBM_ARCH_FOLDER} STREQUAL "amd64" OR ${OPENLIBM_ARCH_FOLDER} STREQUAL "powerpc")
list(APPEND OPENLIBM_INCLUDE_DIRS "${PROJECT_SRC}/ld80")
else()
if(${OPENLIBM_ARCH_FOLDER} STREQUAL "aarch64")
if(${OPENLIBM_ARCH_FOLDER} STREQUAL "aarch64" OR ${OPENLIBM_ARCH_FOLDER} STREQUAL "riscv64")
list(APPEND OPENLIBM_INCLUDE_DIRS "${PROJECT_SRC}/ld128")
endif()
endif()
Expand Down
4 changes: 2 additions & 2 deletions Make.inc
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ CFLAGS_add += -std=c99 -Wall -I$(OPENLIBM_HOME) -I$(OPENLIBM_HOME)/include -I$(O
ifneq ($(filter $(ARCH),i387 amd64 powerpc),)
CFLAGS_add += -I$(OPENLIBM_HOME)/ld80
else
ifneq ($(filter $(ARCH),aarch64),)
ifneq ($(filter $(ARCH),aarch64 riscv64),)
CFLAGS_add += -I$(OPENLIBM_HOME)/ld128
endif
endif
Expand All @@ -165,7 +165,7 @@ ifneq ($(filter $(ARCH),i387 amd64),)
# linux x86_64, for instance, `long double` is 80 bits wide, whereas on macOS aarch64,
# `long double` is the same as `double`.
LONG_DOUBLE_NOT_DOUBLE := 1
else ifeq ($(ARCH), aarch64)
else ifeq ($(ARCH), aarch64 riscv64)
ifeq ($(filter $(OS),Darwin WINNT),)
LONG_DOUBLE_NOT_DOUBLE := 1
endif
Expand Down
4 changes: 2 additions & 2 deletions include/openlibm_fenv_riscv.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
#define __fenv_static static
#endif

typedef __uint64_t fenv_t;
typedef __uint64_t fexcept_t;
typedef uint64_t fenv_t;
typedef uint64_t fexcept_t;

/* Exception flags */
#define FE_INVALID 0x0010
Expand Down

0 comments on commit a91cde1

Please sign in to comment.