mirror of
https://git.planet-casio.com/Lephenixnoir/OpenLibm.git
synced 2025-04-04 09:37:13 +02:00
Compare commits
97 commits
Author | SHA1 | Date | |
---|---|---|---|
|
9828d2e3f2 | ||
|
65aaba96e1 | ||
|
feba6242e4 | ||
|
63c74a4b92 | ||
|
e67d553764 | ||
|
08f772e6ab | ||
|
1cf5a91b46 | ||
|
8afd538dc8 | ||
|
39ede78797 | ||
|
668336366e | ||
|
d241d4f77a | ||
|
07a9090c98 | ||
|
f052f42bb3 | ||
|
711654eeab | ||
|
aeab19f47e | ||
|
5449705906 | ||
|
98f87135b0 | ||
|
6a85b33182 | ||
|
40dac9dd77 | ||
|
2d10c90c77 | ||
|
5d70ac564c | ||
|
63aa8757f3 | ||
|
22428cc5d2 | ||
|
9152b0d1b0 | ||
|
3cb804556f | ||
|
c8561015a4 | ||
|
be31bff11d | ||
|
69b3140a0d | ||
|
998328ebc0 | ||
|
44c1cbb8eb | ||
|
89b463b811 | ||
|
1b364a5edf | ||
|
eb21e8abd1 | ||
|
b34f107e24 | ||
|
5a27b4c0c0 | ||
|
878948d3dd | ||
|
508603d2f6 | ||
|
0276147a68 | ||
|
f2a8b3690a | ||
|
1d6befd0df | ||
|
4f559d4c14 | ||
|
0418324ca4 | ||
|
861b2ad19d | ||
|
5b0e7e9813 | ||
|
382b8e92f4 | ||
|
f6ad75aa67 | ||
|
5efed306d5 | ||
|
e6ac7d7f52 | ||
|
f731481b25 | ||
|
f952e167d2 | ||
|
97de1a46a9 | ||
|
c4dca1e84a | ||
|
d4077aa131 | ||
|
ea065f90cb | ||
|
2080b23690 | ||
|
14bf902a7e | ||
|
3bb221576c | ||
|
33c8313e0b | ||
|
72f33a3bf9 | ||
|
f24b1bfe55 | ||
|
0f22aeb0a9 | ||
|
c68e7d2f1f | ||
|
b524581774 | ||
|
ebbba438ae | ||
|
4e3d70965d | ||
|
65d7406056 | ||
|
2a1e56858a | ||
|
cca41bc1ab | ||
|
74b54c71f7 | ||
|
ce69bf1f32 | ||
|
a96f0740e3 | ||
|
c782ca2e84 | ||
|
52df60bfd3 | ||
|
ce33de1ca9 | ||
|
4971b56998 | ||
|
ca996acc2e | ||
|
73b3d88ef1 | ||
|
3aa5c3bc47 | ||
|
4b4b41c941 | ||
|
a4b3fdeb76 | ||
|
ad9673e637 | ||
|
4dcc76ed96 | ||
|
4f5112ea59 | ||
|
a24a5ebb6e | ||
|
a40570be06 | ||
|
787652b054 | ||
|
a844d584d3 | ||
|
72bfab46a0 | ||
|
48c6c2c2ac | ||
|
bf188aeb23 | ||
|
b7b3b4bc31 | ||
|
d134c84e91 | ||
|
8d91ecb38a | ||
|
c99ab08afe | ||
|
3db5e546e4 | ||
|
b2520473c2 | ||
|
238a90959f |
120 changed files with 2626 additions and 199 deletions
1
.github/FUNDING.yml
vendored
Normal file
1
.github/FUNDING.yml
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
github: [JuliaLang]
|
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -5,3 +5,7 @@
|
|||
*.so*
|
||||
*.dylib*
|
||||
*.pc
|
||||
|
||||
# GiteaPC config files
|
||||
giteapc-config-*.make
|
||||
giteapc-config.make
|
||||
|
|
33
.travis.yml
33
.travis.yml
|
@ -69,5 +69,38 @@ matrix:
|
|||
- libc6-dev-ppc64el-cross
|
||||
- qemu-user-static
|
||||
- binfmt-support
|
||||
|
||||
- os: linux
|
||||
env: FLAGS="CC=mips-linux-gnu-gcc" TEST_FLAGS="LDFLAGS=-static"
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- sourceline: "deb http://archive.ubuntu.com/ubuntu/ xenial main universe"
|
||||
packages:
|
||||
- gcc-mips-linux-gnu
|
||||
- libc6-dev-mips-cross
|
||||
- qemu-user-binfmt
|
||||
|
||||
- os: linux
|
||||
env: FLAGS="CC=mipsel-linux-gnu-gcc" TEST_FLAGS="LDFLAGS=-static"
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- sourceline: "deb http://archive.ubuntu.com/ubuntu/ xenial main universe"
|
||||
packages:
|
||||
- gcc-mipsel-linux-gnu
|
||||
- libc6-dev-mipsel-cross
|
||||
- qemu-user-binfmt
|
||||
|
||||
- os: linux
|
||||
env: FLAGS="CC=mips64el-linux-gnuabi64-gcc" TEST_FLAGS="LDFLAGS=-static"
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- sourceline: "deb http://archive.ubuntu.com/ubuntu/ xenial main universe"
|
||||
packages:
|
||||
- gcc-mips64el-linux-gnuabi64
|
||||
- libc6-dev-mips64el-cross
|
||||
- qemu-user-binfmt
|
||||
notifications:
|
||||
email: false
|
||||
|
|
|
@ -16,7 +16,7 @@ are under the LGPL.
|
|||
## Parts copyrighted by the Julia project (MIT License)
|
||||
|
||||
> Copyright (c) 2011-14 The Julia Project.
|
||||
> https://github.com/JuliaLang/openlibm/graphs/contributors
|
||||
> https://github.com/JuliaMath/openlibm/graphs/contributors
|
||||
>
|
||||
> Permission is hereby granted, free of charge, to any person obtaining
|
||||
> a copy of this software and associated documentation files (the
|
||||
|
|
84
Make.inc
84
Make.inc
|
@ -6,44 +6,44 @@ default: all
|
|||
OS := $(shell uname)
|
||||
# Do not forget to bump SOMINOR when changing VERSION,
|
||||
# and SOMAJOR when breaking ABI in a backward-incompatible way
|
||||
VERSION = 0.5.5
|
||||
SOMAJOR = 2
|
||||
SOMINOR = 4
|
||||
VERSION = 0.7.0
|
||||
SOMAJOR = 3
|
||||
SOMINOR = 0
|
||||
DESTDIR =
|
||||
prefix = /usr/local
|
||||
bindir = $(prefix)/bin
|
||||
libdir = $(prefix)/lib
|
||||
includedir = $(prefix)/include
|
||||
prefix ?= /usr/local
|
||||
bindir ?= $(prefix)/bin
|
||||
libdir ?= $(prefix)/lib
|
||||
includedir ?= $(prefix)/include
|
||||
|
||||
ifeq ($(OS), FreeBSD)
|
||||
pkgconfigdir = $(prefix)/libdata/pkgconfig
|
||||
pkgconfigdir ?= $(prefix)/libdata/pkgconfig
|
||||
else
|
||||
pkgconfigdir = $(libdir)/pkgconfig
|
||||
pkgconfigdir ?= $(libdir)/pkgconfig
|
||||
endif
|
||||
|
||||
USEGCC = 1
|
||||
USECLANG = 0
|
||||
USEGCC ?= 1
|
||||
USECLANG ?= 0
|
||||
|
||||
ifeq ($(OS), Darwin)
|
||||
USEGCC = 0
|
||||
ifneq (,$(findstring $(OS),Darwin FreeBSD OpenBSD))
|
||||
USEGCC ?= 0
|
||||
USECLANG ?= 1
|
||||
endif
|
||||
|
||||
ifeq ($(ARCH),wasm32)
|
||||
USECLANG = 1
|
||||
TOOLPREFIX = llvm-
|
||||
endif
|
||||
|
||||
ifeq ($(OS), FreeBSD)
|
||||
USEGCC = 0
|
||||
USECLANG = 1
|
||||
endif
|
||||
|
||||
AR = ar
|
||||
AR ?= $(TOOLPREFIX)ar
|
||||
|
||||
ifeq ($(USECLANG),1)
|
||||
USEGCC = 0
|
||||
USEGCC ?= 0
|
||||
CC = clang
|
||||
CFLAGS_add += -fno-builtin -fno-strict-aliasing
|
||||
endif
|
||||
|
||||
ifeq ($(USEGCC),1)
|
||||
CC = gcc
|
||||
CC ?= $(TOOLPREFIX)gcc
|
||||
CFLAGS_add += -fno-gnu89-inline -fno-builtin
|
||||
endif
|
||||
|
||||
|
@ -54,6 +54,9 @@ $(error "the mingw32 compiler you are using fails the openblas testsuite. please
|
|||
endif
|
||||
|
||||
# OS-specific stuff
|
||||
ifeq ($(ARCH),arm64)
|
||||
override ARCH := aarch64
|
||||
endif
|
||||
ifeq ($(findstring arm,$(ARCH)),arm)
|
||||
override ARCH := arm
|
||||
MARCH ?= armv7-a
|
||||
|
@ -65,6 +68,9 @@ endif
|
|||
ifeq ($(findstring ppc,$(ARCH)),ppc)
|
||||
override ARCH := powerpc
|
||||
endif
|
||||
ifeq ($(findstring s390,$(ARCH)),s390)
|
||||
override ARCH := s390
|
||||
endif
|
||||
ifneq ($(filter $(ARCH),i386 i486 i586 i686 i387 i487 i587 i687),)
|
||||
override ARCH := i387
|
||||
MARCH ?= i686
|
||||
|
@ -72,6 +78,9 @@ endif
|
|||
ifeq ($(ARCH),x86_64)
|
||||
override ARCH := amd64
|
||||
endif
|
||||
ifeq ($(findstring mips,$(ARCH)),mips)
|
||||
override ARCH := mips
|
||||
endif
|
||||
|
||||
# If CFLAGS does not contain a -O optimization flag, default to -O3
|
||||
ifeq ($(findstring -O,$(CFLAGS)),)
|
||||
|
@ -96,7 +105,9 @@ else
|
|||
SHLIB_EXT = so
|
||||
SONAME_FLAG = -soname
|
||||
endif
|
||||
ifneq ($(ARCH),sh3eb)
|
||||
CFLAGS_add += -fPIC
|
||||
endif
|
||||
shlibdir = $(libdir)
|
||||
endif
|
||||
|
||||
|
@ -117,6 +128,14 @@ SFLAGS_arch += -m64
|
|||
LDFLAGS_arch += -m64
|
||||
endif
|
||||
|
||||
ifeq ($(ARCH),wasm32)
|
||||
CFLAGS_arch += -ffreestanding -nostdlib -nostdinc --target=wasm32-unknown-unknown
|
||||
endif
|
||||
|
||||
ifeq ($(ARCH),sh3eb)
|
||||
CFLAGS_arch += -ffreestanding -nostdlib -m3 -mb
|
||||
endif
|
||||
|
||||
# Add our "arch"-related FLAGS in. We separate arch-related flags out so that
|
||||
# we can conveniently get at them for targets that don't want the rest of
|
||||
# *FLAGS_add, such as the testing Makefile targets
|
||||
|
@ -125,17 +144,24 @@ SFLAGS_add += $(SFLAGS_arch)
|
|||
LDFLAGS_add += $(LDFLAGS_arch)
|
||||
|
||||
CFLAGS_add += -std=c99 -Wall -I$(OPENLIBM_HOME) -I$(OPENLIBM_HOME)/include -I$(OPENLIBM_HOME)/$(ARCH) -I$(OPENLIBM_HOME)/src -DASSEMBLER -D__BSD_VISIBLE -Wno-implicit-function-declaration
|
||||
ifneq ($(filter $(ARCH),i387 amd64 aarch64 powerpc),)
|
||||
ifneq ($(filter $(ARCH),i387 amd64 powerpc),)
|
||||
CFLAGS_add += -I$(OPENLIBM_HOME)/ld80
|
||||
else
|
||||
ifneq ($(filter $(ARCH),aarch64),)
|
||||
CFLAGS_add += -I$(OPENLIBM_HOME)/ld128
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
# *int / *intf need to be built with -O0
|
||||
src/%int.c.o: src/%int.c
|
||||
$(CC) $(CPPFLAGS) -O0 $(CFLAGS_add) -c $< -o $@
|
||||
|
||||
src/%intf.c.o: src/%intf.c
|
||||
$(CC) $(CPPFLAGS) -O0 $(CFLAGS_add) -c $< -o $@
|
||||
ifneq ($(filter $(ARCH),i387 amd64),)
|
||||
# Determines whether `long double` is the same as `double` on this arch.
|
||||
# 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)
|
||||
ifneq ($(OS),Darwin)
|
||||
LONG_DOUBLE_NOT_DOUBLE := 1
|
||||
endif
|
||||
endif
|
||||
|
||||
%.c.o: %.c
|
||||
$(CC) $(CPPFLAGS) $(CFLAGS) $(CFLAGS_add) -c $< -o $@
|
||||
|
|
43
Makefile
43
Makefile
|
@ -2,9 +2,16 @@ OPENLIBM_HOME=$(abspath .)
|
|||
include ./Make.inc
|
||||
|
||||
SUBDIRS = src $(ARCH) bsdsrc
|
||||
ifeq ($(LONG_DOUBLE_NOT_DOUBLE),1)
|
||||
# Add ld80 directory on x86 and x64
|
||||
ifneq ($(filter $(ARCH),i387 amd64),)
|
||||
SUBDIRS += ld80
|
||||
else
|
||||
ifneq ($(filter $(ARCH),aarch64),)
|
||||
SUBDIRS += ld128
|
||||
else
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
define INC_template
|
||||
|
@ -44,7 +51,13 @@ endif
|
|||
.PHONY: all check test clean distclean \
|
||||
install install-static install-shared install-pkgconfig install-headers
|
||||
|
||||
all: libopenlibm.a libopenlibm.$(OLM_MAJOR_MINOR_SHLIB_EXT)
|
||||
|
||||
OLM_LIBS := libopenlibm.a
|
||||
ifeq ($(filter wasm32 sh3eb,$(ARCH)),)
|
||||
OLM_LIBS += libopenlibm.$(OLM_MAJOR_MINOR_SHLIB_EXT)
|
||||
endif
|
||||
|
||||
all : $(OLM_LIBS)
|
||||
|
||||
check test: test/test-double test/test-float
|
||||
test/test-double
|
||||
|
@ -67,7 +80,7 @@ test/test-float: libopenlibm.$(OLM_MAJOR_MINOR_SHLIB_EXT)
|
|||
$(MAKE) -C test test-float
|
||||
|
||||
clean:
|
||||
rm -f aarch64/*.o amd64/*.o arm/*.o bsdsrc/*.o i387/*.o ld80/*.o ld128/*.o src/*.o powerpc/*.o
|
||||
rm -f aarch64/*.o amd64/*.o arm/*.o bsdsrc/*.o i387/*.o ld80/*.o ld128/*.o src/*.o powerpc/*.o mips/*.o s390/*.o sh3eb/*.o
|
||||
rm -f libopenlibm.a libopenlibm.*$(SHLIB_EXT)*
|
||||
$(MAKE) -C test clean
|
||||
|
||||
|
@ -78,19 +91,33 @@ openlibm.pc: openlibm.pc.in Make.inc Makefile
|
|||
|
||||
install-static: libopenlibm.a
|
||||
mkdir -p $(DESTDIR)$(libdir)
|
||||
cp -f -a libopenlibm.a $(DESTDIR)$(libdir)/
|
||||
cp -RpP -f libopenlibm.a $(DESTDIR)$(libdir)/
|
||||
|
||||
install-static-superh: install-static
|
||||
ln -sf libopenlibm.a $(DESTDIR)$(libdir)/libm.a
|
||||
|
||||
install-shared: libopenlibm.$(OLM_MAJOR_MINOR_SHLIB_EXT)
|
||||
mkdir -p $(DESTDIR)$(shlibdir)
|
||||
cp -f -a libopenlibm.*$(SHLIB_EXT)* $(DESTDIR)$(shlibdir)/
|
||||
cp -RpP -f libopenlibm.*$(SHLIB_EXT)* $(DESTDIR)$(shlibdir)/
|
||||
|
||||
install-pkgconfig: openlibm.pc
|
||||
mkdir -p $(DESTDIR)$(pkgconfigdir)
|
||||
cp -f -a openlibm.pc $(DESTDIR)$(pkgconfigdir)/
|
||||
cp -RpP -f openlibm.pc $(DESTDIR)$(pkgconfigdir)/
|
||||
|
||||
install-headers:
|
||||
mkdir -p $(DESTDIR)$(includedir)/openlibm
|
||||
cp -f -a include/*.h $(DESTDIR)$(includedir)/openlibm
|
||||
cp -f -a src/*.h $(DESTDIR)$(includedir)/openlibm
|
||||
cp -RpP -f include/*.h $(DESTDIR)$(includedir)/openlibm
|
||||
cp -RpP -f src/*.h $(DESTDIR)$(includedir)/openlibm
|
||||
|
||||
install: install-static install-shared install-pkgconfig install-headers
|
||||
install-headers-superh:
|
||||
mkdir -p $(DESTDIR)$(includedir)
|
||||
cp -RpP -f \
|
||||
include/openlibm.h \
|
||||
include/openlibm_complex.h \
|
||||
include/openlibm_defs.h \
|
||||
include/openlibm_fenv.h \
|
||||
include/openlibm_fenv_sh3eb.h \
|
||||
include/openlibm_math.h \
|
||||
$(DESTDIR)$(includedir)
|
||||
|
||||
install: install-static install-shared install-pkgconfig
|
||||
|
|
38
README-OpenLibm.md
Normal file
38
README-OpenLibm.md
Normal file
|
@ -0,0 +1,38 @@
|
|||
# OpenLibm
|
||||
|
||||
[](https://travis-ci.org/JuliaMath/openlibm)
|
||||
[](https://ci.appveyor.com/project/ararslan/openlibm-19152/branch/master)
|
||||
|
||||
[OpenLibm](https://openlibm.org/) is an effort to have a high quality, portable, standalone
|
||||
C mathematical library ([`libm`](http://en.wikipedia.org/wiki/libm)).
|
||||
It can be used standalone in applications and programming language
|
||||
implementations.
|
||||
|
||||
The project was born out of a need to have a good `libm` for the
|
||||
[Julia programming language](http://www.julialang.org) that worked
|
||||
consistently across compilers and operating systems, and in 32-bit and
|
||||
64-bit environments.
|
||||
|
||||
## Platform support
|
||||
|
||||
OpenLibm builds on Linux, macOS, Windows, FreeBSD, OpenBSD, NetBSD, and
|
||||
DragonFly BSD. It builds with both GCC and clang. Although largely
|
||||
tested and widely used on the x86 and x86-64 architectures, OpenLibm
|
||||
also supports arm, aarch64, ppc64le, mips, wasm32, and s390(x).
|
||||
|
||||
## Build instructions
|
||||
|
||||
1. Use GNU Make to build OpenLibm. This is `make` on most systems, but `gmake` on BSDs.
|
||||
2. Use `make USEGCC=1` to build with GCC. This is the default on
|
||||
Linux and Windows.
|
||||
3. Use `make USECLANG=1` to build with clang. This is the default on OS X, FreeBSD,
|
||||
and OpenBSD.
|
||||
4. Use `make ARCH=wasm32` to build the wasm32 library with clang. Requires clang-8.
|
||||
5. Architectures are auto-detected. Use `make ARCH=i386` to force a
|
||||
build for i386. Other supported architectures are i486, i586, and
|
||||
i686. GCC 4.8 is the minimum requirement for correct codegen on
|
||||
older 32-bit architectures.
|
||||
|
||||
## Acknowledgements
|
||||
|
||||
PowerPC support for openlibm was graciously sponsored by IBM.
|
82
README.md
82
README.md
|
@ -1,40 +1,60 @@
|
|||
# OpenLibm
|
||||
# Soft-FP sh3eb port of OpenLibm
|
||||
|
||||
[](https://travis-ci.org/JuliaLang/openlibm)
|
||||
This is a fork of [OpenLibm](https://github.com/JuliaMath/openlibm) with support for the sh3eb architecture, intended for add-in programming on SuperH CASIO calculators.
|
||||
|
||||
[OpenLibm](http://www.openlibm.org) is an effort to have a high quality, portable, standalone
|
||||
C mathematical library ([`libm`](http://en.wikipedia.org/wiki/libm)).
|
||||
It can be used standalone in applications and programming language
|
||||
implementations.
|
||||
## Installing with GiteaPC
|
||||
|
||||
The project was born out of a need to have a good `libm` for the
|
||||
[Julia programming langage](http://www.julialang.org) that worked
|
||||
consistently across compilers and operating systems, and in 32-bit and
|
||||
64-bit environments.
|
||||
This library can be installed automatically as part of the fxSDK with [GiteaPC](https://gitea.planet-casio.com/Lephenixnoir/GiteaPC):
|
||||
|
||||
## Platform support
|
||||
```bash
|
||||
% giteapc install Lephenixnoir/OpenLibm
|
||||
```
|
||||
|
||||
OpenLibm builds on Linux, Mac OS X, Windows, FreeBSD, OpenBSD, and DragonFly BSD.
|
||||
It builds with both GCC and clang. Although largely tested and widely
|
||||
used on x86 architectures, openlibm also supports ARM and
|
||||
powerPC.
|
||||
## Building manually
|
||||
|
||||
## Build instructions
|
||||
You will need a GCC toolchain built with `--target=sh3eb-elf`, such as the [`sh-elf-gcc`](https://gitea.planet-casio.com/Lephenixnoir/sh-elf-gcc) commonly used on Planète Casio.
|
||||
|
||||
1. Use `make` to build OpenLibm.
|
||||
2. Use `make USEGCC=1` to build with GCC. This is the default on
|
||||
Linux and Windows.
|
||||
3. Use `make USECLANG=1` to build with clang. This is the default on OS X
|
||||
and FreeBSD.
|
||||
4. Architectures are auto-detected. Use `make ARCH=i386` to force a
|
||||
build for i386. Other supported architectures are i486, i586, and
|
||||
i686. GCC 4.8 is the minimum requirement for correct codegen on
|
||||
older 32-bit architectures.
|
||||
5. On OpenBSD, you need to install GNU Make (port name: `gmake`) and a recent
|
||||
version of `gcc` (tested: 4.9.2), as the default version provided by OpenBSD
|
||||
is too old (4.2.1). If you use OpenBSD's port system for this (port name:
|
||||
`gcc`), run `make CC=egcc` to force Make to use the newer `gcc`.
|
||||
You can install directly in the internal folder of your compiler, or somewhere else if you have a more detailed setup.
|
||||
|
||||
## Acknowledgements
|
||||
```bash
|
||||
# Example 1: Use the compiler's internal folder
|
||||
% COMPILER_DIR="$(sh-elf-gcc --print-file-name=.)"
|
||||
% LIBDIR="$COMPILER_DIR"
|
||||
% INCDIR="$COMPILER_DIR/include"
|
||||
# Example 2: Using the fxSDK's custom setup
|
||||
% LIBDIR="$(fxsdk path lib)"
|
||||
% INCDIR="$(fxsdk path include)"
|
||||
```
|
||||
|
||||
PowerPC support for openlibm was graciously sponsored by IBM.
|
||||
You can then build and install the static library and the headers.
|
||||
|
||||
```bash
|
||||
% make USEGCC=1 TOOLPREFIX=sh-elf- AR=sh-elf-ar CC=sh-elf-gcc \
|
||||
libdir="$LIBDIR" includedir="$INCDIR" \
|
||||
install-static-superh install-headers-superh
|
||||
```
|
||||
|
||||
The `-superh` targets differ from the the normal targets in the following ways:
|
||||
|
||||
* `install-static-superh` also creates a symlink `libm.a -> libopenlibm.a`.
|
||||
* `install-headers-superh` installs directly in `$LIBDIR` instead of `$LIBDIR/openlibm` since OpenLibm headers reference each other without that prefix and enforcing the correct `-I` in every project is quite painful. In addition, it skips internal and non-SuperH headers.
|
||||
|
||||
## Using the library
|
||||
|
||||
Include the headers `<openlibm_complex.h>`, `<openlibm_fenv.h>` and `<openlibm_math.h>`. Or, if you are using a suitable libc like [fxlibc](https://gitea.planet-casio.com/Vhex-Kernel-Core/fxlibc/), include directly the standard headers `<complex.h>`, `<fenv.h>` and `<math.h>`.
|
||||
|
||||
Link with `-lm`. In a Makefile, update your `LDFLAGS`:
|
||||
|
||||
```
|
||||
LDFLAGS += -lm
|
||||
```
|
||||
|
||||
In CMake, use [`target_link_libraries()`](https://cmake.org/cmake/help/latest/command/target_link_libraries.html):
|
||||
|
||||
```cmake
|
||||
target_link_libraries(<TARGET> PUBLIC -lm)
|
||||
```
|
||||
|
||||
## README and Licensing
|
||||
|
||||
See the original README file in [README-OpenLibm.md](README-OpenLibm.md). OpenLibm contains code covered by various licenses, see [LICENSE.md](LICENSE.md).
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
* $FreeBSD: src/lib/msun/arm/fenv.c,v 1.3 2011/10/16 05:37:56 das Exp $
|
||||
*/
|
||||
|
||||
#define __fenv_static
|
||||
#include <openlibm_fenv.h>
|
||||
|
||||
#ifdef __GNUC_GNU_INLINE__
|
||||
|
|
37
appveyor.yml
Normal file
37
appveyor.yml
Normal file
|
@ -0,0 +1,37 @@
|
|||
environment:
|
||||
matrix:
|
||||
- ARCH: "x86_64"
|
||||
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
- /release-.*/
|
||||
|
||||
skip_commits:
|
||||
message: /\[av skip\]/
|
||||
|
||||
notifications:
|
||||
- provider: Email
|
||||
on_build_success: false
|
||||
on_build_failure: false
|
||||
on_build_status_changed: false
|
||||
|
||||
init:
|
||||
- git config --global core.autocrlf input
|
||||
|
||||
build_script:
|
||||
- ps: if ($env:APPVEYOR_PULL_REQUEST_NUMBER -and $env:APPVEYOR_BUILD_NUMBER -ne ((Invoke-RestMethod `
|
||||
https://ci.appveyor.com/api/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/history?recordsNumber=50).builds | `
|
||||
Where-Object pullRequestId -eq $env:APPVEYOR_PULL_REQUEST_NUMBER)[0].buildNumber) { `
|
||||
throw "There are newer queued builds for this pull request, failing early." }
|
||||
- if %ARCH%==i686 ( set EXCEPT=dwarf ) else set EXCEPT=seh
|
||||
- if %ARCH%==i686 ( set MINGW=mingw32 ) else set MINGW=mingw64
|
||||
- set PATH=C:\MinGW-w64\%ARCH%-6.3.0-posix-%EXCEPT%-rt_v5-rev1\%MINGW%\bin;%PATH%
|
||||
- mingw32-make.exe ARCH=%ARCH% CC=%ARCH%-w64-mingw32-gcc
|
||||
- mingw32-make.exe test ARCH=%ARCH% CC=%ARCH%-w64-mingw32-gcc
|
||||
|
||||
on_finish:
|
||||
# Uncomment the following line for interactive debugging, which
|
||||
# will print login data for a temporary remote session after the
|
||||
# build. This requires an RDP version 6 client, e.g., FreeRDP.
|
||||
#- ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
|
|
@ -38,6 +38,7 @@
|
|||
* acknowledged.
|
||||
*/
|
||||
|
||||
#include <float.h>
|
||||
#include <openlibm_math.h>
|
||||
|
||||
#include "mathimpl.h"
|
||||
|
@ -312,3 +313,7 @@ neg_gam(x)
|
|||
if (sgn < 0) y = -y;
|
||||
return (M_PI / (y*z));
|
||||
}
|
||||
|
||||
#if (LDBL_MANT_DIG == 53)
|
||||
openlibm_weak_reference(tgamma, tgammal);
|
||||
#endif
|
||||
|
|
1
docs/CNAME
Normal file
1
docs/CNAME
Normal file
|
@ -0,0 +1 @@
|
|||
openlibm.org
|
BIN
docs/images/arrow-down.png
Normal file
BIN
docs/images/arrow-down.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 216 B |
BIN
docs/images/octocat-small.png
Normal file
BIN
docs/images/octocat-small.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 357 B |
93
docs/index.html
Normal file
93
docs/index.html
Normal file
|
@ -0,0 +1,93 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="chrome=1">
|
||||
<title>OpenLibm</title>
|
||||
|
||||
<link rel="stylesheet" href="stylesheets/styles.css">
|
||||
<link rel="stylesheet" href="stylesheets/pygment_trac.css">
|
||||
<script src="javascripts/scale.fix.js"></script>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
|
||||
</head>
|
||||
<body>
|
||||
<div class="wrapper">
|
||||
<header>
|
||||
<h1 class="header">OpenLibm</h1>
|
||||
<p class="header">A high quality system independent, portable, open source libm implementation</p>
|
||||
|
||||
<ul>
|
||||
<li class="download"><a class="buttons" href="https://github.com/JuliaMath/openlibm/releases">Download</a></li>
|
||||
<li><a class="buttons github" href="https://github.com/JuliaMath/openlibm">View On GitHub</a></li>
|
||||
</ul>
|
||||
|
||||
<p class="header">This project is maintained by <a class="header name" href="https://julialang.org/">the Julia Project</a></p>
|
||||
|
||||
|
||||
</header>
|
||||
<section>
|
||||
<h2>
|
||||
<a id="openlibm" class="anchor" href="#openlibm" aria-hidden="true"><span class="octicon octicon-link"></span></a>OpenLibm</h2>
|
||||
|
||||
<p><a href="http://www.openlibm.org">OpenLibm</a> is an effort to have a high quality, portable, standalone
|
||||
C mathematical library (<a href="http://en.wikipedia.org/wiki/libm"><code>libm</code></a>).
|
||||
It can be used standalone in applications and programming language
|
||||
implementations.</p>
|
||||
|
||||
<p>The project was born out of a need to have a good <code>libm</code> for the
|
||||
<a href="http://www.julialang.org">Julia programming langage</a> that worked
|
||||
consistently across compilers and operating systems, and in 32-bit and
|
||||
64-bit environments.</p>
|
||||
|
||||
<h3>
|
||||
<a id="history" class="anchor" href="#history" aria-hidden="true"><span class="octicon octicon-link"></span></a>History</h3>
|
||||
|
||||
<p>The OpenLibm code derives from the <a href="http://svnweb.freebsd.org/base/head/lib/msun/">FreeBSD
|
||||
msun</a> and <a href="http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/lib/libm/src/">OpenBSD
|
||||
libm</a>
|
||||
implementations, which in turn derive from <a href="http://www.netlib.org/fdlibm/">FDLIBM
|
||||
5.3</a>. Over and above that, OpenLibm itself has received a number of patches to make it platform independent and portable.</p>
|
||||
|
||||
<h3>
|
||||
<a id="platform-support" class="anchor" href="#platform-support" aria-hidden="true"><span class="octicon octicon-link"></span></a>Platform support</h3>
|
||||
|
||||
<p>OpenLibm builds on Linux, macOS, Windows, FreeBSD, OpenBSD, NetBSD, and
|
||||
DragonFly BSD. It builds with both GCC and clang. Although largely
|
||||
tested and widely used on the x86 and x86-64 architectures, OpenLibm
|
||||
also supports arm, aarch64, ppc64le, mips, wasm32, and s390(x).
|
||||
|
||||
<h3>
|
||||
<a id="other-relevant-projects" class="anchor" href="#other-relevant-projects" aria-hidden="true"><span class="octicon octicon-link"></span></a>Other relevant projects</h3>
|
||||
|
||||
<ol>
|
||||
<li> <a href="https://git.musl-libc.org/cgit/musl/tree/src/math">MUSL</a> The libm library in the musl-libc project</li>
|
||||
<li> <a href="http://www.netlib.org/fdlibm/">FDLIBM</a>: Freely Distributable Math Library</li>
|
||||
<li> <a href="https://github.com/freebsd/freebsd/tree/master/lib/msun">FreeBSD msun</a>: FreeBSD's math library</li>
|
||||
<li> <a href="https://github.com/JuliaIntervals/CRlibm.jl">CRlibm</a>: Correctly Rounded mathematical library</li>
|
||||
</ol>
|
||||
|
||||
<h3>
|
||||
<a id="Acknowledgements" class="anchor" href="#Acknowledgements" aria-hidden="true"><span class="octicon octicon-link"></span></a>Acknowledgements</h3>
|
||||
|
||||
<p>PowerPC support for OpenLibm was graciously sponsored by IBM.
|
||||
|
||||
|
||||
</section>
|
||||
<footer>
|
||||
<p><small>Hosted on <a href="http://pages.github.com">GitHub Pages</a> using the Dinky theme</small></p>
|
||||
</footer>
|
||||
</div>
|
||||
<!--[if !IE]><script>fixScale(document);</script><![endif]-->
|
||||
<script type="text/javascript">
|
||||
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
|
||||
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
|
||||
</script>
|
||||
<script type="text/javascript">
|
||||
try {
|
||||
var pageTracker = _gat._getTracker("UA-28835595-4");
|
||||
pageTracker._trackPageview();
|
||||
} catch(err) {}
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
20
docs/javascripts/scale.fix.js
Normal file
20
docs/javascripts/scale.fix.js
Normal file
|
@ -0,0 +1,20 @@
|
|||
fixScale = function(doc) {
|
||||
|
||||
var addEvent = 'addEventListener',
|
||||
type = 'gesturestart',
|
||||
qsa = 'querySelectorAll',
|
||||
scales = [1, 1],
|
||||
meta = qsa in doc ? doc[qsa]('meta[name=viewport]') : [];
|
||||
|
||||
function fix() {
|
||||
meta.content = 'width=device-width,minimum-scale=' + scales[0] + ',maximum-scale=' + scales[1];
|
||||
doc.removeEventListener(type, fix, true);
|
||||
}
|
||||
|
||||
if ((meta = meta[meta.length - 1]) && addEvent in doc) {
|
||||
fix();
|
||||
scales = [.25, 1.6];
|
||||
doc[addEvent](type, fix, true);
|
||||
}
|
||||
|
||||
};
|
1
docs/params.json
Normal file
1
docs/params.json
Normal file
|
@ -0,0 +1 @@
|
|||
{"name":"OpenLibm","tagline":"A high quality system independent, portable, open source libm implementation","body":"## OpenLibm\r\n\r\n[OpenLibm](http://www.openlibm.org) is an effort to have a high quality, portable, standalone\r\nC mathematical library ([`libm`](http://en.wikipedia.org/wiki/libm)).\r\nIt can be used standalone in applications and programming language\r\nimplementations.\r\n\r\nThe project was born out of a need to have a good `libm` for the\r\n[Julia programming langage](http://www.julialang.org) that worked\r\nconsistently across compilers and operating systems, and in 32-bit and\r\n64-bit environments.\r\n\r\n### History\r\n\r\nThe OpenLibm code derives from the [FreeBSD\r\nmsun](http://svnweb.freebsd.org/base/head/lib/msun/) and [OpenBSD\r\nlibm](http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/lib/libm/src/)\r\nimplementations, which in turn derives from [FDLIBM\r\n5.3](http://www.netlib.org/fdlibm/). As a result, it includes a number\r\nof fixes and updates to FDLIBM that have accumulated over the years in\r\n`msun`, and optimized versions of many functions.\r\n\r\n### Platform support\r\n\r\nOpenLibm builds on Linux, Mac OS X, and Windows, and with little\r\neffort, should build on FreeBSD as well. It builds with both GCC and\r\nclang. Although largely tested on x86, it also includes experimental\r\nsupport for ARM. The original `msun` also includes support for mips,\r\nsparc64, powerpc, ia64, and alpha. These are present in the OpenLibm\r\nsource tree, but no attempt has been made to build any of these.\r\n\r\n### Build instructions\r\n\r\n1. `make` or `make USEGCC=1` to build with GCC. This is the default on\r\n Linux and Windows.\r\n2. `make USECLANG=1` to build with clang. This is the default on OS X.\r\n","google":"UA-28835595-4","note":"Don't delete this file! It's used internally to help with page regeneration."}
|
69
docs/stylesheets/pygment_trac.css
Normal file
69
docs/stylesheets/pygment_trac.css
Normal file
|
@ -0,0 +1,69 @@
|
|||
.highlight { background: #ffffff; }
|
||||
.highlight .c { color: #999988; font-style: italic } /* Comment */
|
||||
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
|
||||
.highlight .k { font-weight: bold } /* Keyword */
|
||||
.highlight .o { font-weight: bold } /* Operator */
|
||||
.highlight .cm { color: #999988; font-style: italic } /* Comment.Multiline */
|
||||
.highlight .cp { color: #999999; font-weight: bold } /* Comment.Preproc */
|
||||
.highlight .c1 { color: #999988; font-style: italic } /* Comment.Single */
|
||||
.highlight .cs { color: #999999; font-weight: bold; font-style: italic } /* Comment.Special */
|
||||
.highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
|
||||
.highlight .gd .x { color: #000000; background-color: #ffaaaa } /* Generic.Deleted.Specific */
|
||||
.highlight .ge { font-style: italic } /* Generic.Emph */
|
||||
.highlight .gr { color: #aa0000 } /* Generic.Error */
|
||||
.highlight .gh { color: #999999 } /* Generic.Heading */
|
||||
.highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
|
||||
.highlight .gi .x { color: #000000; background-color: #aaffaa } /* Generic.Inserted.Specific */
|
||||
.highlight .go { color: #888888 } /* Generic.Output */
|
||||
.highlight .gp { color: #555555 } /* Generic.Prompt */
|
||||
.highlight .gs { font-weight: bold } /* Generic.Strong */
|
||||
.highlight .gu { color: #800080; font-weight: bold; } /* Generic.Subheading */
|
||||
.highlight .gt { color: #aa0000 } /* Generic.Traceback */
|
||||
.highlight .kc { font-weight: bold } /* Keyword.Constant */
|
||||
.highlight .kd { font-weight: bold } /* Keyword.Declaration */
|
||||
.highlight .kn { font-weight: bold } /* Keyword.Namespace */
|
||||
.highlight .kp { font-weight: bold } /* Keyword.Pseudo */
|
||||
.highlight .kr { font-weight: bold } /* Keyword.Reserved */
|
||||
.highlight .kt { color: #445588; font-weight: bold } /* Keyword.Type */
|
||||
.highlight .m { color: #009999 } /* Literal.Number */
|
||||
.highlight .s { color: #d14 } /* Literal.String */
|
||||
.highlight .na { color: #008080 } /* Name.Attribute */
|
||||
.highlight .nb { color: #0086B3 } /* Name.Builtin */
|
||||
.highlight .nc { color: #445588; font-weight: bold } /* Name.Class */
|
||||
.highlight .no { color: #008080 } /* Name.Constant */
|
||||
.highlight .ni { color: #800080 } /* Name.Entity */
|
||||
.highlight .ne { color: #990000; font-weight: bold } /* Name.Exception */
|
||||
.highlight .nf { color: #990000; font-weight: bold } /* Name.Function */
|
||||
.highlight .nn { color: #555555 } /* Name.Namespace */
|
||||
.highlight .nt { color: #000080 } /* Name.Tag */
|
||||
.highlight .nv { color: #008080 } /* Name.Variable */
|
||||
.highlight .ow { font-weight: bold } /* Operator.Word */
|
||||
.highlight .w { color: #bbbbbb } /* Text.Whitespace */
|
||||
.highlight .mf { color: #009999 } /* Literal.Number.Float */
|
||||
.highlight .mh { color: #009999 } /* Literal.Number.Hex */
|
||||
.highlight .mi { color: #009999 } /* Literal.Number.Integer */
|
||||
.highlight .mo { color: #009999 } /* Literal.Number.Oct */
|
||||
.highlight .sb { color: #d14 } /* Literal.String.Backtick */
|
||||
.highlight .sc { color: #d14 } /* Literal.String.Char */
|
||||
.highlight .sd { color: #d14 } /* Literal.String.Doc */
|
||||
.highlight .s2 { color: #d14 } /* Literal.String.Double */
|
||||
.highlight .se { color: #d14 } /* Literal.String.Escape */
|
||||
.highlight .sh { color: #d14 } /* Literal.String.Heredoc */
|
||||
.highlight .si { color: #d14 } /* Literal.String.Interpol */
|
||||
.highlight .sx { color: #d14 } /* Literal.String.Other */
|
||||
.highlight .sr { color: #009926 } /* Literal.String.Regex */
|
||||
.highlight .s1 { color: #d14 } /* Literal.String.Single */
|
||||
.highlight .ss { color: #990073 } /* Literal.String.Symbol */
|
||||
.highlight .bp { color: #999999 } /* Name.Builtin.Pseudo */
|
||||
.highlight .vc { color: #008080 } /* Name.Variable.Class */
|
||||
.highlight .vg { color: #008080 } /* Name.Variable.Global */
|
||||
.highlight .vi { color: #008080 } /* Name.Variable.Instance */
|
||||
.highlight .il { color: #009999 } /* Literal.Number.Integer.Long */
|
||||
|
||||
.type-csharp .highlight .k { color: #0000FF }
|
||||
.type-csharp .highlight .kt { color: #0000FF }
|
||||
.type-csharp .highlight .nf { color: #000000; font-weight: normal }
|
||||
.type-csharp .highlight .nc { color: #2B91AF }
|
||||
.type-csharp .highlight .nn { color: #000000 }
|
||||
.type-csharp .highlight .s { color: #A31515 }
|
||||
.type-csharp .highlight .sc { color: #A31515 }
|
423
docs/stylesheets/styles.css
Normal file
423
docs/stylesheets/styles.css
Normal file
|
@ -0,0 +1,423 @@
|
|||
@import url(https://fonts.googleapis.com/css?family=Arvo:400,700,400italic);
|
||||
|
||||
/* MeyerWeb Reset */
|
||||
|
||||
html, body, div, span, applet, object, iframe,
|
||||
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
|
||||
a, abbr, acronym, address, big, cite, code,
|
||||
del, dfn, em, img, ins, kbd, q, s, samp,
|
||||
small, strike, strong, sub, sup, tt, var,
|
||||
b, u, i, center,
|
||||
dl, dt, dd, ol, ul, li,
|
||||
fieldset, form, label, legend,
|
||||
table, caption, tbody, tfoot, thead, tr, th, td,
|
||||
article, aside, canvas, details, embed,
|
||||
figure, figcaption, footer, header, hgroup,
|
||||
menu, nav, output, ruby, section, summary,
|
||||
time, mark, audio, video {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
font: inherit;
|
||||
vertical-align: baseline;
|
||||
}
|
||||
|
||||
|
||||
/* Base text styles */
|
||||
|
||||
body {
|
||||
padding:10px 50px 0 0;
|
||||
font-family:"Helvetica Neue", Helvetica, Arial, sans-serif;
|
||||
font-size: 14px;
|
||||
color: #232323;
|
||||
background-color: #FBFAF7;
|
||||
margin: 0;
|
||||
line-height: 1.8em;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
|
||||
}
|
||||
|
||||
h1, h2, h3, h4, h5, h6 {
|
||||
color:#232323;
|
||||
margin:36px 0 10px;
|
||||
}
|
||||
|
||||
p, ul, ol, table, dl {
|
||||
margin:0 0 22px;
|
||||
}
|
||||
|
||||
h1, h2, h3 {
|
||||
font-family: Arvo, Monaco, serif;
|
||||
line-height:1.3;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
h1,h2, h3 {
|
||||
display: block;
|
||||
border-bottom: 1px solid #ccc;
|
||||
padding-bottom: 5px;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 30px;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
h3 {
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
h4, h5, h6 {
|
||||
font-family: Arvo, Monaco, serif;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
a {
|
||||
color:#C30000;
|
||||
font-weight:200;
|
||||
text-decoration:none;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
a small {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
em {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
strong {
|
||||
font-weight:700;
|
||||
}
|
||||
|
||||
ul {
|
||||
list-style-position: inside;
|
||||
list-style: disc;
|
||||
padding-left: 25px;
|
||||
}
|
||||
|
||||
ol {
|
||||
list-style-position: inside;
|
||||
list-style: decimal;
|
||||
padding-left: 25px;
|
||||
}
|
||||
|
||||
blockquote {
|
||||
margin: 0;
|
||||
padding: 0 0 0 20px;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
dl, dt, dd, dl p {
|
||||
font-color: #444;
|
||||
}
|
||||
|
||||
dl dt {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
dl dd {
|
||||
padding-left: 20px;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
dl p {
|
||||
padding-left: 20px;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
hr {
|
||||
border:0;
|
||||
background:#ccc;
|
||||
height:1px;
|
||||
margin:0 0 24px;
|
||||
}
|
||||
|
||||
/* Images */
|
||||
|
||||
img {
|
||||
position: relative;
|
||||
margin: 0 auto;
|
||||
max-width: 650px;
|
||||
padding: 5px;
|
||||
margin: 10px 0 32px 0;
|
||||
border: 1px solid #ccc;
|
||||
}
|
||||
|
||||
p img {
|
||||
display: inline;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
vertical-align: middle;
|
||||
text-align: center;
|
||||
border: none;
|
||||
}
|
||||
|
||||
/* Code blocks */
|
||||
|
||||
code, pre {
|
||||
font-family: Monaco, "Bitstream Vera Sans Mono", "Lucida Console", Terminal, monospace;
|
||||
color:#000;
|
||||
font-size:14px;
|
||||
}
|
||||
|
||||
pre {
|
||||
padding: 4px 12px;
|
||||
background: #FDFEFB;
|
||||
border-radius:4px;
|
||||
border:1px solid #D7D8C8;
|
||||
overflow: auto;
|
||||
overflow-y: hidden;
|
||||
margin-bottom: 32px;
|
||||
}
|
||||
|
||||
|
||||
/* Tables */
|
||||
|
||||
table {
|
||||
width:100%;
|
||||
}
|
||||
|
||||
table {
|
||||
border: 1px solid #ccc;
|
||||
margin-bottom: 32px;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
th {
|
||||
font-family: 'Arvo', Helvetica, Arial, sans-serif;
|
||||
font-size: 18px;
|
||||
font-weight: normal;
|
||||
padding: 10px;
|
||||
background: #232323;
|
||||
color: #FDFEFB;
|
||||
}
|
||||
|
||||
td {
|
||||
padding: 10px;
|
||||
background: #ccc;
|
||||
}
|
||||
|
||||
|
||||
/* Wrapper */
|
||||
.wrapper {
|
||||
width:960px;
|
||||
}
|
||||
|
||||
|
||||
/* Header */
|
||||
|
||||
header {
|
||||
background-color: #171717;
|
||||
color: #FDFDFB;
|
||||
width:170px;
|
||||
float:left;
|
||||
position:fixed;
|
||||
border: 1px solid #000;
|
||||
-webkit-border-top-right-radius: 4px;
|
||||
-webkit-border-bottom-right-radius: 4px;
|
||||
-moz-border-radius-topright: 4px;
|
||||
-moz-border-radius-bottomright: 4px;
|
||||
border-top-right-radius: 4px;
|
||||
border-bottom-right-radius: 4px;
|
||||
padding: 34px 25px 22px 50px;
|
||||
margin: 30px 25px 0 0;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
}
|
||||
|
||||
p.header {
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
h1.header {
|
||||
font-family: Arvo, sans-serif;
|
||||
font-size: 30px;
|
||||
font-weight: 300;
|
||||
line-height: 1.3em;
|
||||
border-bottom: none;
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
|
||||
h1.header, a.header, a.name, header a{
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
a.header {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
a.name {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
header ul {
|
||||
list-style:none;
|
||||
padding:0;
|
||||
}
|
||||
|
||||
header li {
|
||||
list-style-type: none;
|
||||
width:132px;
|
||||
height:15px;
|
||||
margin-bottom: 12px;
|
||||
line-height: 1em;
|
||||
padding: 6px 6px 6px 7px;
|
||||
|
||||
background: #AF0011;
|
||||
background: -moz-linear-gradient(top, #AF0011 0%, #820011 100%);
|
||||
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f8f8f8), color-stop(100%,#dddddd));
|
||||
background: -webkit-linear-gradient(top, #AF0011 0%,#820011 100%);
|
||||
background: -o-linear-gradient(top, #AF0011 0%,#820011 100%);
|
||||
background: -ms-linear-gradient(top, #AF0011 0%,#820011 100%);
|
||||
background: linear-gradient(top, #AF0011 0%,#820011 100%);
|
||||
|
||||
border-radius:4px;
|
||||
border:1px solid #0D0D0D;
|
||||
|
||||
-webkit-box-shadow: inset 0px 1px 1px 0 rgba(233,2,38, 1);
|
||||
box-shadow: inset 0px 1px 1px 0 rgba(233,2,38, 1);
|
||||
|
||||
}
|
||||
|
||||
header li:hover {
|
||||
background: #C3001D;
|
||||
background: -moz-linear-gradient(top, #C3001D 0%, #950119 100%);
|
||||
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f8f8f8), color-stop(100%,#dddddd));
|
||||
background: -webkit-linear-gradient(top, #C3001D 0%,#950119 100%);
|
||||
background: -o-linear-gradient(top, #C3001D 0%,#950119 100%);
|
||||
background: -ms-linear-gradient(top, #C3001D 0%,#950119 100%);
|
||||
background: linear-gradient(top, #C3001D 0%,#950119 100%);
|
||||
}
|
||||
|
||||
a.buttons {
|
||||
-webkit-font-smoothing: antialiased;
|
||||
background: url(../images/arrow-down.png) no-repeat;
|
||||
font-weight: normal;
|
||||
text-shadow: rgba(0, 0, 0, 0.4) 0 -1px 0;
|
||||
padding: 2px 2px 2px 22px;
|
||||
height: 30px;
|
||||
}
|
||||
|
||||
a.github {
|
||||
background: url(../images/octocat-small.png) no-repeat 1px;
|
||||
}
|
||||
|
||||
a.buttons:hover {
|
||||
color: #fff;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
|
||||
/* Section - for main page content */
|
||||
|
||||
section {
|
||||
width:650px;
|
||||
float:right;
|
||||
padding-bottom:50px;
|
||||
}
|
||||
|
||||
|
||||
/* Footer */
|
||||
|
||||
footer {
|
||||
width:170px;
|
||||
float:left;
|
||||
position:fixed;
|
||||
bottom:10px;
|
||||
padding-left: 50px;
|
||||
}
|
||||
|
||||
@media print, screen and (max-width: 960px) {
|
||||
|
||||
div.wrapper {
|
||||
width:auto;
|
||||
margin:0;
|
||||
}
|
||||
|
||||
header, section, footer {
|
||||
float:none;
|
||||
position:static;
|
||||
width:auto;
|
||||
}
|
||||
|
||||
footer {
|
||||
border-top: 1px solid #ccc;
|
||||
margin:0 84px 0 50px;
|
||||
padding:0;
|
||||
}
|
||||
|
||||
header {
|
||||
padding-right:320px;
|
||||
}
|
||||
|
||||
section {
|
||||
padding:20px 84px 20px 50px;
|
||||
margin:0 0 20px;
|
||||
}
|
||||
|
||||
header a small {
|
||||
display:inline;
|
||||
}
|
||||
|
||||
header ul {
|
||||
position:absolute;
|
||||
right:130px;
|
||||
top:84px;
|
||||
}
|
||||
}
|
||||
|
||||
@media print, screen and (max-width: 720px) {
|
||||
body {
|
||||
word-wrap:break-word;
|
||||
}
|
||||
|
||||
header {
|
||||
padding:10px 20px 0;
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
section {
|
||||
padding:10px 0 10px 20px;
|
||||
margin:0 0 30px;
|
||||
}
|
||||
|
||||
footer {
|
||||
margin: 0 0 0 30px;
|
||||
}
|
||||
|
||||
header ul, header p.view {
|
||||
position:static;
|
||||
}
|
||||
}
|
||||
|
||||
@media print, screen and (max-width: 480px) {
|
||||
|
||||
header ul li.download {
|
||||
display:none;
|
||||
}
|
||||
|
||||
footer {
|
||||
margin: 0 0 0 20px;
|
||||
}
|
||||
|
||||
footer a{
|
||||
display:block;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@media print {
|
||||
body {
|
||||
padding:0.4in;
|
||||
font-size:12pt;
|
||||
color:#444;
|
||||
}
|
||||
}
|
24
giteapc.make
Normal file
24
giteapc.make
Normal file
|
@ -0,0 +1,24 @@
|
|||
# giteapc: version=1 depends=Lephenixnoir/fxsdk,Lephenixnoir/sh-elf-gcc
|
||||
|
||||
-include giteapc-config.make
|
||||
|
||||
# Use the fxSDK's default paths unless specified otherwise on the command line
|
||||
LIBDIR ?= $(shell fxsdk path lib)
|
||||
INCDIR ?= $(shell fxsdk path include)
|
||||
|
||||
FLAGS := USEGCC=1 TOOLPREFIX=sh-elf- CC=sh-elf-gcc AR=sh-elf-ar \
|
||||
libdir="$(LIBDIR)" includedir="$(INCDIR)"
|
||||
|
||||
configure:
|
||||
@ true
|
||||
|
||||
build:
|
||||
@ make $(FLAGS)
|
||||
|
||||
install:
|
||||
@ make $(FLAGS) install-static-superh install-headers-superh
|
||||
|
||||
uninstall:
|
||||
@ echo "uninstall not supported for OpenLibm, skipping"
|
||||
|
||||
.PHONY: configure build install uninstall
|
14
include/openlibm_defs.h
Normal file
14
include/openlibm_defs.h
Normal file
|
@ -0,0 +1,14 @@
|
|||
#ifndef OPENLIBM_DEFS_H_
|
||||
#define OPENLIBM_DEFS_H_
|
||||
|
||||
#ifdef _WIN32
|
||||
# ifdef IMPORT_EXPORTS
|
||||
# define OLM_DLLEXPORT __declspec(dllimport)
|
||||
# else
|
||||
# define OLM_DLLEXPORT __declspec(dllexport)
|
||||
# endif
|
||||
#else
|
||||
#define OLM_DLLEXPORT __attribute__ ((visibility("default")))
|
||||
#endif
|
||||
|
||||
#endif // OPENLIBM_DEFS_H_
|
|
@ -10,6 +10,12 @@
|
|||
#include <openlibm_fenv_i387.h>
|
||||
#elif defined(__powerpc__)
|
||||
#include <openlibm_fenv_powerpc.h>
|
||||
#elif defined(__mips__)
|
||||
#include <openlibm_fenv_mips.h>
|
||||
#elif defined(__s390__)
|
||||
#include <openlibm_fenv_s390.h>
|
||||
#elif defined(__sh3__)
|
||||
#include <openlibm_fenv_sh3eb.h>
|
||||
#else
|
||||
#error "Unsupported platform"
|
||||
#endif
|
||||
|
|
|
@ -29,11 +29,10 @@
|
|||
#ifndef _FENV_H_
|
||||
#define _FENV_H_
|
||||
|
||||
#include <openlibm_defs.h>
|
||||
#include "cdefs-compat.h"
|
||||
#include "types-compat.h"
|
||||
|
||||
#include "math_private.h"
|
||||
|
||||
#ifndef __fenv_static
|
||||
#define __fenv_static static
|
||||
#endif
|
||||
|
|
278
include/openlibm_fenv_mips.h
Normal file
278
include/openlibm_fenv_mips.h
Normal file
|
@ -0,0 +1,278 @@
|
|||
/*-
|
||||
* Copyright (c) 2004-2005 David Schultz <das@FreeBSD.ORG>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#ifndef _FENV_H_
|
||||
#define _FENV_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include "cdefs-compat.h"
|
||||
|
||||
#ifndef __fenv_static
|
||||
#define __fenv_static static
|
||||
#endif
|
||||
|
||||
typedef uint32_t fenv_t;
|
||||
typedef uint32_t fexcept_t;
|
||||
|
||||
/* Exception flags */
|
||||
#ifdef __mips_soft_float
|
||||
#define _FPUSW_SHIFT 16
|
||||
#define FE_INVALID 0x0001
|
||||
#define FE_DIVBYZERO 0x0002
|
||||
#define FE_OVERFLOW 0x0004
|
||||
#define FE_UNDERFLOW 0x0008
|
||||
#define FE_INEXACT 0x0010
|
||||
#else
|
||||
#define _FCSR_CAUSE_SHIFT 10
|
||||
#define FE_INVALID 0x0040
|
||||
#define FE_DIVBYZERO 0x0020
|
||||
#define FE_OVERFLOW 0x0010
|
||||
#define FE_UNDERFLOW 0x0008
|
||||
#define FE_INEXACT 0x0004
|
||||
#endif
|
||||
#define FE_ALL_EXCEPT (FE_DIVBYZERO | FE_INEXACT | \
|
||||
FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW)
|
||||
|
||||
/* Rounding modes */
|
||||
#define FE_TONEAREST 0x0000
|
||||
#define FE_TOWARDZERO 0x0001
|
||||
#define FE_UPWARD 0x0002
|
||||
#define FE_DOWNWARD 0x0003
|
||||
#define _ROUND_MASK (FE_TONEAREST | FE_DOWNWARD | \
|
||||
FE_UPWARD | FE_TOWARDZERO)
|
||||
__BEGIN_DECLS
|
||||
|
||||
/* Default floating-point environment */
|
||||
extern const fenv_t __fe_dfl_env;
|
||||
#define FE_DFL_ENV (&__fe_dfl_env)
|
||||
|
||||
/* We need to be able to map status flag positions to mask flag positions */
|
||||
#define _ENABLE_SHIFT 5
|
||||
#define _ENABLE_MASK (FE_ALL_EXCEPT << _ENABLE_SHIFT)
|
||||
|
||||
#ifndef __mips_soft_float
|
||||
#define __cfc1(__fcsr) __asm __volatile("cfc1 %0, $31" : "=r" (__fcsr))
|
||||
#define __ctc1(__fcsr) __asm __volatile("ctc1 %0, $31" :: "r" (__fcsr))
|
||||
#endif
|
||||
|
||||
#ifdef __mips_soft_float
|
||||
int feclearexcept(int __excepts);
|
||||
int fegetexceptflag(fexcept_t *__flagp, int __excepts);
|
||||
int fesetexceptflag(const fexcept_t *__flagp, int __excepts);
|
||||
int feraiseexcept(int __excepts);
|
||||
int fetestexcept(int __excepts);
|
||||
int fegetround(void);
|
||||
int fesetround(int __round);
|
||||
int fegetenv(fenv_t *__envp);
|
||||
int feholdexcept(fenv_t *__envp);
|
||||
int fesetenv(const fenv_t *__envp);
|
||||
int feupdateenv(const fenv_t *__envp);
|
||||
#else
|
||||
__fenv_static inline int
|
||||
feclearexcept(int __excepts)
|
||||
{
|
||||
fexcept_t fcsr;
|
||||
|
||||
__excepts &= FE_ALL_EXCEPT;
|
||||
__cfc1(fcsr);
|
||||
fcsr &= ~(__excepts | (__excepts << _FCSR_CAUSE_SHIFT));
|
||||
__ctc1(fcsr);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
__fenv_static inline int
|
||||
fegetexceptflag(fexcept_t *__flagp, int __excepts)
|
||||
{
|
||||
fexcept_t fcsr;
|
||||
|
||||
__excepts &= FE_ALL_EXCEPT;
|
||||
__cfc1(fcsr);
|
||||
*__flagp = fcsr & __excepts;
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
__fenv_static inline int
|
||||
fesetexceptflag(const fexcept_t *__flagp, int __excepts)
|
||||
{
|
||||
fexcept_t fcsr;
|
||||
|
||||
__excepts &= FE_ALL_EXCEPT;
|
||||
__cfc1(fcsr);
|
||||
fcsr &= ~__excepts;
|
||||
fcsr |= *__flagp & __excepts;
|
||||
__ctc1(fcsr);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
__fenv_static inline int
|
||||
feraiseexcept(int __excepts)
|
||||
{
|
||||
fexcept_t fcsr;
|
||||
|
||||
__excepts &= FE_ALL_EXCEPT;
|
||||
__cfc1(fcsr);
|
||||
fcsr |= __excepts | (__excepts << _FCSR_CAUSE_SHIFT);
|
||||
__ctc1(fcsr);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
__fenv_static inline int
|
||||
fetestexcept(int __excepts)
|
||||
{
|
||||
fexcept_t fcsr;
|
||||
|
||||
__excepts &= FE_ALL_EXCEPT;
|
||||
__cfc1(fcsr);
|
||||
|
||||
return (fcsr & __excepts);
|
||||
}
|
||||
|
||||
__fenv_static inline int
|
||||
fegetround(void)
|
||||
{
|
||||
fexcept_t fcsr;
|
||||
|
||||
__cfc1(fcsr);
|
||||
|
||||
return (fcsr & _ROUND_MASK);
|
||||
}
|
||||
|
||||
__fenv_static inline int
|
||||
fesetround(int __round)
|
||||
{
|
||||
fexcept_t fcsr;
|
||||
|
||||
if (__round & ~_ROUND_MASK)
|
||||
return (-1);
|
||||
|
||||
__cfc1(fcsr);
|
||||
fcsr &= ~_ROUND_MASK;
|
||||
fcsr |= __round;
|
||||
__ctc1(fcsr);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
__fenv_static inline int
|
||||
fegetenv(fenv_t *__envp)
|
||||
{
|
||||
|
||||
__cfc1(*__envp);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
__fenv_static inline int
|
||||
feholdexcept(fenv_t *__envp)
|
||||
{
|
||||
fexcept_t fcsr;
|
||||
|
||||
__cfc1(fcsr);
|
||||
*__envp = fcsr;
|
||||
fcsr &= ~(FE_ALL_EXCEPT | _ENABLE_MASK);
|
||||
__ctc1(fcsr);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
__fenv_static inline int
|
||||
fesetenv(const fenv_t *__envp)
|
||||
{
|
||||
|
||||
__ctc1(*__envp);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
__fenv_static inline int
|
||||
feupdateenv(const fenv_t *__envp)
|
||||
{
|
||||
fexcept_t fcsr;
|
||||
|
||||
__cfc1(fcsr);
|
||||
fesetenv(__envp);
|
||||
feraiseexcept(fcsr);
|
||||
|
||||
return (0);
|
||||
}
|
||||
#endif /* !__mips_soft_float */
|
||||
|
||||
#if __BSD_VISIBLE
|
||||
|
||||
/* We currently provide no external definitions of the functions below. */
|
||||
|
||||
#ifdef __mips_soft_float
|
||||
int feenableexcept(int __mask);
|
||||
int fedisableexcept(int __mask);
|
||||
int fegetexcept(void);
|
||||
#else
|
||||
static inline int
|
||||
feenableexcept(int __mask)
|
||||
{
|
||||
fenv_t __old_fcsr, __new_fcsr;
|
||||
|
||||
__cfc1(__old_fcsr);
|
||||
__new_fcsr = __old_fcsr | (__mask & FE_ALL_EXCEPT) << _ENABLE_SHIFT;
|
||||
__ctc1(__new_fcsr);
|
||||
|
||||
return ((__old_fcsr >> _ENABLE_SHIFT) & FE_ALL_EXCEPT);
|
||||
}
|
||||
|
||||
static inline int
|
||||
fedisableexcept(int __mask)
|
||||
{
|
||||
fenv_t __old_fcsr, __new_fcsr;
|
||||
|
||||
__cfc1(__old_fcsr);
|
||||
__new_fcsr = __old_fcsr & ~((__mask & FE_ALL_EXCEPT) << _ENABLE_SHIFT);
|
||||
__ctc1(__new_fcsr);
|
||||
|
||||
return ((__old_fcsr >> _ENABLE_SHIFT) & FE_ALL_EXCEPT);
|
||||
}
|
||||
|
||||
static inline int
|
||||
fegetexcept(void)
|
||||
{
|
||||
fexcept_t fcsr;
|
||||
|
||||
__cfc1(fcsr);
|
||||
|
||||
return ((fcsr & _ENABLE_MASK) >> _ENABLE_SHIFT);
|
||||
}
|
||||
|
||||
#endif /* !__mips_soft_float */
|
||||
|
||||
#endif /* __BSD_VISIBLE */
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* !_FENV_H_ */
|
235
include/openlibm_fenv_s390.h
Normal file
235
include/openlibm_fenv_s390.h
Normal file
|
@ -0,0 +1,235 @@
|
|||
/*-
|
||||
* Copyright (c) 2016 Dan Horák <dan[at]danny.cz>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#ifndef _FENV_H_
|
||||
#define _FENV_H_
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifndef __fenv_static
|
||||
#define __fenv_static static
|
||||
#endif
|
||||
|
||||
typedef __uint32_t fenv_t;
|
||||
typedef __uint32_t fexcept_t;
|
||||
|
||||
/* Exception flags */
|
||||
#define FE_INEXACT 0x080000
|
||||
#define FE_UNDERFLOW 0x100000
|
||||
#define FE_OVERFLOW 0x200000
|
||||
#define FE_DIVBYZERO 0x400000
|
||||
#define FE_INVALID 0x800000 /* all types of invalid FP ops */
|
||||
|
||||
#define FE_ALL_EXCEPT (FE_INVALID | FE_DIVBYZERO | FE_INEXACT | FE_OVERFLOW | FE_UNDERFLOW)
|
||||
|
||||
/* Rounding modes */
|
||||
#define FE_TONEAREST 0x0000
|
||||
#define FE_TOWARDZERO 0x0001
|
||||
#define FE_UPWARD 0x0002
|
||||
#define FE_DOWNWARD 0x0003
|
||||
#define _ROUND_MASK (FE_TONEAREST | FE_DOWNWARD | \
|
||||
FE_UPWARD | FE_TOWARDZERO)
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
/* Default floating-point environment */
|
||||
extern const fenv_t __fe_dfl_env;
|
||||
#define FE_DFL_ENV (&__fe_dfl_env)
|
||||
|
||||
/* We need to be able to map status flag positions to mask flag positions */
|
||||
#define _FPC_EXC_MASK_SHIFT 8
|
||||
#define _ENABLE_MASK ((FE_DIVBYZERO | FE_INEXACT | FE_INVALID | \
|
||||
FE_OVERFLOW | FE_UNDERFLOW) << _FPC_EXC_MASK_SHIFT)
|
||||
|
||||
/* Macros for accessing the hardware control word. */
|
||||
#define _FPU_GETCW(cw) __asm__ __volatile__ ("efpc %0,0" : "=d" (cw))
|
||||
#define _FPU_SETCW(cw) __asm__ __volatile__ ("sfpc %0,0" : : "d" (cw))
|
||||
|
||||
__fenv_static inline int
|
||||
feclearexcept(int __excepts)
|
||||
{
|
||||
fexcept_t __r;
|
||||
|
||||
if (__excepts & FE_INVALID)
|
||||
__excepts |= FE_ALL_EXCEPT;
|
||||
_FPU_GETCW(__r);
|
||||
__r &= ~__excepts;
|
||||
_FPU_SETCW(__r);
|
||||
return (0);
|
||||
}
|
||||
|
||||
__fenv_static inline int
|
||||
fegetexceptflag(fexcept_t *__flagp, int __excepts)
|
||||
{
|
||||
fexcept_t __r;
|
||||
|
||||
_FPU_GETCW(__r);
|
||||
*__flagp = __r & __excepts;
|
||||
return (0);
|
||||
}
|
||||
|
||||
__fenv_static inline int
|
||||
fesetexceptflag(const fexcept_t *__flagp, int __excepts)
|
||||
{
|
||||
fexcept_t __r;
|
||||
|
||||
if (__excepts & FE_INVALID)
|
||||
__excepts |= FE_ALL_EXCEPT;
|
||||
_FPU_GETCW(__r);
|
||||
__r &= ~__excepts;
|
||||
__r |= *__flagp & __excepts;
|
||||
_FPU_SETCW(__r);
|
||||
return (0);
|
||||
}
|
||||
|
||||
__fenv_static inline int
|
||||
feraiseexcept(int __excepts)
|
||||
{
|
||||
fexcept_t __r;
|
||||
|
||||
_FPU_GETCW(__r);
|
||||
__r |= __excepts;
|
||||
_FPU_SETCW(__r);
|
||||
return (0);
|
||||
}
|
||||
|
||||
__fenv_static inline int
|
||||
fetestexcept(int __excepts)
|
||||
{
|
||||
fexcept_t __r;
|
||||
|
||||
_FPU_GETCW(__r);
|
||||
return (__r & __excepts);
|
||||
}
|
||||
|
||||
__fenv_static inline int
|
||||
fegetround(void)
|
||||
{
|
||||
fexcept_t __r;
|
||||
|
||||
_FPU_GETCW(__r);
|
||||
return (__r & _ROUND_MASK);
|
||||
}
|
||||
|
||||
__fenv_static inline int
|
||||
fesetround(int __round)
|
||||
{
|
||||
fexcept_t __r;
|
||||
|
||||
if (__round & ~_ROUND_MASK)
|
||||
return (-1);
|
||||
|
||||
_FPU_GETCW(__r);
|
||||
__r &= ~_ROUND_MASK;
|
||||
__r |= __round;
|
||||
_FPU_SETCW(__r);
|
||||
return (0);
|
||||
}
|
||||
|
||||
__fenv_static inline int
|
||||
fegetenv(fenv_t *__envp)
|
||||
{
|
||||
_FPU_GETCW(*__envp);
|
||||
return (0);
|
||||
}
|
||||
|
||||
__fenv_static inline int
|
||||
feholdexcept(fenv_t *__envp)
|
||||
{
|
||||
fexcept_t __r;
|
||||
|
||||
_FPU_GETCW(__r);
|
||||
*__envp = __r;
|
||||
__r &= ~(FE_ALL_EXCEPT | _ENABLE_MASK);
|
||||
_FPU_SETCW(__r);
|
||||
return (0);
|
||||
}
|
||||
|
||||
__fenv_static inline int
|
||||
fesetenv(const fenv_t *__envp)
|
||||
{
|
||||
_FPU_SETCW(*__envp);
|
||||
return (0);
|
||||
}
|
||||
|
||||
__fenv_static inline int
|
||||
feupdateenv(const fenv_t *__envp)
|
||||
{
|
||||
fexcept_t __r;
|
||||
|
||||
_FPU_GETCW(__r);
|
||||
__r &= FE_ALL_EXCEPT;
|
||||
__r |= *__envp;
|
||||
_FPU_SETCW(__r);
|
||||
return (0);
|
||||
}
|
||||
|
||||
#if __BSD_VISIBLE
|
||||
|
||||
/* We currently provide no external definitions of the functions below. */
|
||||
|
||||
static inline int
|
||||
feenableexcept(int __mask)
|
||||
{
|
||||
fenv_t __r;
|
||||
fenv_t __oldmask;
|
||||
|
||||
_FPU_GETCW(__r);
|
||||
__oldmask = __r;
|
||||
__r |= (__mask & FE_ALL_EXCEPT) << _FPC_EXC_MASK_SHIFT;
|
||||
_FPU_SETCW(__r);
|
||||
return ((__oldmask & _ENABLE_MASK) >> _FPC_EXC_MASK_SHIFT);
|
||||
}
|
||||
|
||||
static inline int
|
||||
fedisableexcept(int __mask)
|
||||
{
|
||||
fenv_t __r;
|
||||
fenv_t __oldmask;
|
||||
|
||||
_FPU_GETCW(__r);
|
||||
__oldmask = __r;
|
||||
__r &= ~((__mask & FE_ALL_EXCEPT) << _FPC_EXC_MASK_SHIFT);
|
||||
_FPU_SETCW(__r);
|
||||
return ((__oldmask & _ENABLE_MASK) >> _FPC_EXC_MASK_SHIFT);
|
||||
}
|
||||
|
||||
static inline int
|
||||
fegetexcept(void)
|
||||
{
|
||||
fexcept_t __r;
|
||||
|
||||
_FPU_GETCW(__r);
|
||||
return (__r & (_ENABLE_MASK >> _FPC_EXC_MASK_SHIFT));
|
||||
}
|
||||
|
||||
#endif /* __BSD_VISIBLE */
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* !_FENV_H_ */
|
98
include/openlibm_fenv_sh3eb.h
Normal file
98
include/openlibm_fenv_sh3eb.h
Normal file
|
@ -0,0 +1,98 @@
|
|||
/*-
|
||||
* Copyright (c) 2004-2005 David Schultz <das@FreeBSD.ORG>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#ifndef _FENV_H_
|
||||
#define _FENV_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifndef __fenv_static
|
||||
#define __fenv_static static
|
||||
#endif
|
||||
|
||||
typedef uint32_t fenv_t;
|
||||
typedef uint32_t fexcept_t;
|
||||
|
||||
/* Exception flags */
|
||||
#define _FPUSW_SHIFT 16
|
||||
#define FE_INVALID 0x0001
|
||||
#define FE_DIVBYZERO 0x0002
|
||||
#define FE_OVERFLOW 0x0004
|
||||
#define FE_UNDERFLOW 0x0008
|
||||
#define FE_INEXACT 0x0010
|
||||
|
||||
#define FE_ALL_EXCEPT (FE_DIVBYZERO | FE_INEXACT | \
|
||||
FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW)
|
||||
|
||||
/* Rounding modes */
|
||||
#define FE_TONEAREST 0x0000
|
||||
#define FE_TOWARDZERO 0x0001
|
||||
#define FE_UPWARD 0x0002
|
||||
#define FE_DOWNWARD 0x0003
|
||||
#define _ROUND_MASK (FE_TONEAREST | FE_DOWNWARD | \
|
||||
FE_UPWARD | FE_TOWARDZERO)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Default floating-point environment */
|
||||
extern const fenv_t __fe_dfl_env;
|
||||
#define FE_DFL_ENV (&__fe_dfl_env)
|
||||
|
||||
/* We need to be able to map status flag positions to mask flag positions */
|
||||
#define _ENABLE_SHIFT 5
|
||||
#define _ENABLE_MASK (FE_ALL_EXCEPT << _ENABLE_SHIFT)
|
||||
|
||||
int feclearexcept(int __excepts);
|
||||
int fegetexceptflag(fexcept_t *__flagp, int __excepts);
|
||||
int fesetexceptflag(const fexcept_t *__flagp, int __excepts);
|
||||
int feraiseexcept(int __excepts);
|
||||
int fetestexcept(int __excepts);
|
||||
int fegetround(void);
|
||||
int fesetround(int __round);
|
||||
int fegetenv(fenv_t *__envp);
|
||||
int feholdexcept(fenv_t *__envp);
|
||||
int fesetenv(const fenv_t *__envp);
|
||||
int feupdateenv(const fenv_t *__envp);
|
||||
|
||||
#if __BSD_VISIBLE
|
||||
|
||||
/* We currently provide no external definitions of the functions below. */
|
||||
|
||||
int feenableexcept(int __mask);
|
||||
int fedisableexcept(int __mask);
|
||||
int fegetexcept(void);
|
||||
|
||||
#endif /* __BSD_VISIBLE */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* !_FENV_H_ */
|
|
@ -18,6 +18,8 @@
|
|||
#include <math.h>
|
||||
#else /* !OPENLIBM_USE_HOST_MATH_H */
|
||||
|
||||
#include <openlibm_defs.h>
|
||||
|
||||
#ifndef OPENLIBM_MATH_H
|
||||
#define OPENLIBM_MATH_H
|
||||
|
||||
|
@ -25,24 +27,14 @@
|
|||
#define __WIN32__
|
||||
#endif
|
||||
|
||||
#ifndef __arm__
|
||||
#define LONG_DOUBLE
|
||||
#if !defined(__arm__) && !defined(__wasm__)
|
||||
#define OLM_LONG_DOUBLE
|
||||
#endif
|
||||
|
||||
#ifndef __pure2
|
||||
#define __pure2
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
# ifdef IMPORT_EXPORTS
|
||||
# define OLM_DLLEXPORT __declspec(dllimport)
|
||||
# else
|
||||
# define OLM_DLLEXPORT __declspec(dllexport)
|
||||
# endif
|
||||
#else
|
||||
#define OLM_DLLEXPORT __attribute__ ((visibility("default")))
|
||||
#endif
|
||||
|
||||
/*
|
||||
* ANSI/POSIX
|
||||
*/
|
||||
|
@ -312,6 +304,7 @@ OLM_DLLEXPORT double trunc(double);
|
|||
* BSD math library entry points
|
||||
*/
|
||||
#if __BSD_VISIBLE
|
||||
OLM_DLLEXPORT int isinff(float) __pure2;
|
||||
OLM_DLLEXPORT int isnanf(float) __pure2;
|
||||
|
||||
/*
|
||||
|
|
|
@ -1 +1,13 @@
|
|||
SRCS = invtrig.c k_cosl.c k_sinl.c k_tanl.c # s_nanl.c s_exp2l.c
|
||||
$(CUR_SRCS) += invtrig.c \
|
||||
e_acoshl.c e_powl.c k_tanl.c s_exp2l.c \
|
||||
e_atanhl.c e_lgammal_r.c e_sinhl.c s_asinhl.c s_expm1l.c \
|
||||
e_coshl.c e_log10l.c e_tgammal.c \
|
||||
e_expl.c e_log2l.c k_cosl.c s_log1pl.c s_tanhl.c \
|
||||
e_logl.c k_sinl.c s_erfl.c
|
||||
|
||||
# s_remquol.c e_fmodl.c s_truncl.c
|
||||
# e_hypotl.c s_floorl.c s_nextafterl.c s_ceill.c s_modfl.c
|
||||
|
||||
ifneq ($(OS), WINNT)
|
||||
$(CUR_SRCS) += s_nanl.c
|
||||
endif
|
||||
|
|
1
mips/Make.files
Normal file
1
mips/Make.files
Normal file
|
@ -0,0 +1 @@
|
|||
$(CUR_SRCS) = fenv.c
|
184
mips/fenv-softfloat.h
Normal file
184
mips/fenv-softfloat.h
Normal file
|
@ -0,0 +1,184 @@
|
|||
/*-
|
||||
* Copyright (c) 2004-2011 David Schultz <das@FreeBSD.ORG>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#ifndef _FENV_H_
|
||||
#error "This file is meant to be included only by <fenv.h>."
|
||||
#endif
|
||||
|
||||
/*
|
||||
* This file implements the functionality of <fenv.h> on platforms that
|
||||
* lack an FPU and use softfloat in libc for floating point. To use it,
|
||||
* you must write an <fenv.h> that provides the following:
|
||||
*
|
||||
* - a typedef for fenv_t, which may be an integer or struct type
|
||||
* - a typedef for fexcept_t (XXX This file assumes fexcept_t is a
|
||||
* simple integer type containing the exception mask.)
|
||||
* - definitions of FE_* constants for the five exceptions and four
|
||||
* rounding modes in IEEE 754, as described in fenv(3)
|
||||
* - a definition, and the corresponding external symbol, for FE_DFL_ENV
|
||||
* - a macro __set_env(env, flags, mask, rnd), which sets the given fenv_t
|
||||
* from the exception flags, mask, and rounding mode
|
||||
* - macros __env_flags(env), __env_mask(env), and __env_round(env), which
|
||||
* extract fields from an fenv_t
|
||||
* - a definition of __fenv_static
|
||||
*
|
||||
* If the architecture supports an optional FPU, it's recommended that you
|
||||
* define fenv_t and fexcept_t to match the hardware ABI. Otherwise, it
|
||||
* doesn't matter how you define them.
|
||||
*/
|
||||
|
||||
extern int __softfloat_float_exception_flags;
|
||||
extern int __softfloat_float_exception_mask;
|
||||
extern int __softfloat_float_rounding_mode;
|
||||
void __softfloat_float_raise(int);
|
||||
|
||||
__fenv_static inline int
|
||||
feclearexcept(int __excepts)
|
||||
{
|
||||
|
||||
__softfloat_float_exception_flags &= ~__excepts;
|
||||
return (0);
|
||||
}
|
||||
|
||||
__fenv_static inline int
|
||||
fegetexceptflag(fexcept_t *__flagp, int __excepts)
|
||||
{
|
||||
|
||||
*__flagp = __softfloat_float_exception_flags & __excepts;
|
||||
return (0);
|
||||
}
|
||||
|
||||
__fenv_static inline int
|
||||
fesetexceptflag(const fexcept_t *__flagp, int __excepts)
|
||||
{
|
||||
|
||||
__softfloat_float_exception_flags &= ~__excepts;
|
||||
__softfloat_float_exception_flags |= *__flagp & __excepts;
|
||||
return (0);
|
||||
}
|
||||
|
||||
__fenv_static inline int
|
||||
feraiseexcept(int __excepts)
|
||||
{
|
||||
|
||||
__softfloat_float_raise(__excepts);
|
||||
return (0);
|
||||
}
|
||||
|
||||
__fenv_static inline int
|
||||
fetestexcept(int __excepts)
|
||||
{
|
||||
|
||||
return (__softfloat_float_exception_flags & __excepts);
|
||||
}
|
||||
|
||||
__fenv_static inline int
|
||||
fegetround(void)
|
||||
{
|
||||
|
||||
return (__softfloat_float_rounding_mode);
|
||||
}
|
||||
|
||||
__fenv_static inline int
|
||||
fesetround(int __round)
|
||||
{
|
||||
|
||||
__softfloat_float_rounding_mode = __round;
|
||||
return (0);
|
||||
}
|
||||
|
||||
__fenv_static inline int
|
||||
fegetenv(fenv_t *__envp)
|
||||
{
|
||||
|
||||
__set_env(*__envp, __softfloat_float_exception_flags,
|
||||
__softfloat_float_exception_mask, __softfloat_float_rounding_mode);
|
||||
return (0);
|
||||
}
|
||||
|
||||
__fenv_static inline int
|
||||
feholdexcept(fenv_t *__envp)
|
||||
{
|
||||
fenv_t __env;
|
||||
|
||||
fegetenv(__envp);
|
||||
__softfloat_float_exception_flags = 0;
|
||||
__softfloat_float_exception_mask = 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
__fenv_static inline int
|
||||
fesetenv(const fenv_t *__envp)
|
||||
{
|
||||
|
||||
__softfloat_float_exception_flags = __env_flags(*__envp);
|
||||
__softfloat_float_exception_mask = __env_mask(*__envp);
|
||||
__softfloat_float_rounding_mode = __env_round(*__envp);
|
||||
return (0);
|
||||
}
|
||||
|
||||
__fenv_static inline int
|
||||
feupdateenv(const fenv_t *__envp)
|
||||
{
|
||||
int __oflags = __softfloat_float_exception_flags;
|
||||
|
||||
fesetenv(__envp);
|
||||
feraiseexcept(__oflags);
|
||||
return (0);
|
||||
}
|
||||
|
||||
#if __BSD_VISIBLE
|
||||
|
||||
/* We currently provide no external definitions of the functions below. */
|
||||
|
||||
__fenv_static inline int
|
||||
feenableexcept(int __mask)
|
||||
{
|
||||
int __omask = __softfloat_float_exception_mask;
|
||||
|
||||
__softfloat_float_exception_mask |= __mask;
|
||||
return (__omask);
|
||||
}
|
||||
|
||||
__fenv_static inline int
|
||||
fedisableexcept(int __mask)
|
||||
{
|
||||
int __omask = __softfloat_float_exception_mask;
|
||||
|
||||
__softfloat_float_exception_mask &= ~__mask;
|
||||
return (__omask);
|
||||
}
|
||||
|
||||
__fenv_static inline int
|
||||
fegetexcept(void)
|
||||
{
|
||||
|
||||
return (__softfloat_float_exception_mask);
|
||||
}
|
||||
|
||||
#endif /* __BSD_VISIBLE */
|
67
mips/fenv.c
Normal file
67
mips/fenv.c
Normal file
|
@ -0,0 +1,67 @@
|
|||
/*-
|
||||
* Copyright (c) 2004 David Schultz <das@FreeBSD.ORG>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#define __fenv_static
|
||||
#include "openlibm_fenv.h"
|
||||
|
||||
#ifdef __GNUC_GNU_INLINE__
|
||||
#error "This file must be compiled with C99 'inline' semantics"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Hopefully the system ID byte is immutable, so it's valid to use
|
||||
* this as a default environment.
|
||||
*/
|
||||
const fenv_t __fe_dfl_env = 0;
|
||||
|
||||
#ifdef __mips_soft_float
|
||||
#define __set_env(env, flags, mask, rnd) env = ((flags) \
|
||||
| (mask)<<_FPUSW_SHIFT \
|
||||
| (rnd) << 24)
|
||||
#define __env_flags(env) ((env) & FE_ALL_EXCEPT)
|
||||
#define __env_mask(env) (((env) >> _FPUSW_SHIFT) \
|
||||
& FE_ALL_EXCEPT)
|
||||
#define __env_round(env) (((env) >> 24) & _ROUND_MASK)
|
||||
#include "fenv-softfloat.h"
|
||||
#endif
|
||||
|
||||
extern inline int feclearexcept(int __excepts);
|
||||
extern inline int fegetexceptflag(fexcept_t *__flagp, int __excepts);
|
||||
extern inline int fesetexceptflag(const fexcept_t *__flagp, int __excepts);
|
||||
extern inline int feraiseexcept(int __excepts);
|
||||
extern inline int fetestexcept(int __excepts);
|
||||
extern inline int fegetround(void);
|
||||
extern inline int fesetround(int __round);
|
||||
extern inline int fegetenv(fenv_t *__envp);
|
||||
extern inline int feholdexcept(fenv_t *__envp);
|
||||
extern inline int fesetenv(const fenv_t *__envp);
|
||||
extern inline int feupdateenv(const fenv_t *__envp);
|
||||
extern inline int feenableexcept(int __mask);
|
||||
extern inline int fedisableexcept(int __mask);
|
||||
extern inline int fegetexcept(void);
|
||||
|
|
@ -4,7 +4,7 @@ libdir=${exec_prefix}/lib
|
|||
|
||||
Name: openlibm
|
||||
Version: ${version}
|
||||
URL: https://github.com/JuliaLang/openlibm
|
||||
URL: https://github.com/JuliaMath/openlibm
|
||||
Description: High quality system independent, open source libm.
|
||||
Cflags: -I${includedir}
|
||||
Libs: -L${libdir} -lopenlibm
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#define __fenv_static
|
||||
#include <openlibm_fenv.h>
|
||||
|
||||
#ifdef __GNUC_GNU_INLINE__
|
||||
|
|
1
s390/Make.files
Normal file
1
s390/Make.files
Normal file
|
@ -0,0 +1 @@
|
|||
$(CUR_SRCS) = fenv.c
|
50
s390/fenv.c
Normal file
50
s390/fenv.c
Normal file
|
@ -0,0 +1,50 @@
|
|||
/*-
|
||||
* Copyright (c) 2016 Dan Horák <dan[at]danny.cz>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*
|
||||
* cloned from ppc/fenv.c
|
||||
*/
|
||||
|
||||
#define __fenv_static
|
||||
#include <openlibm_fenv.h>
|
||||
|
||||
#ifdef __GNUC_GNU_INLINE__
|
||||
#error "This file must be compiled with C99 'inline' semantics"
|
||||
#endif
|
||||
|
||||
const fenv_t __fe_dfl_env = 0x00000000;
|
||||
|
||||
extern inline int feclearexcept(int __excepts);
|
||||
extern inline int fegetexceptflag(fexcept_t *__flagp, int __excepts);
|
||||
extern inline int fesetexceptflag(const fexcept_t *__flagp, int __excepts);
|
||||
extern inline int feraiseexcept(int __excepts);
|
||||
extern inline int fetestexcept(int __excepts);
|
||||
extern inline int fegetround(void);
|
||||
extern inline int fesetround(int __round);
|
||||
extern inline int fegetenv(fenv_t *__envp);
|
||||
extern inline int feholdexcept(fenv_t *__envp);
|
||||
extern inline int fesetenv(const fenv_t *__envp);
|
||||
extern inline int feupdateenv(const fenv_t *__envp);
|
1
sh3eb/Make.files
Normal file
1
sh3eb/Make.files
Normal file
|
@ -0,0 +1 @@
|
|||
$(CUR_SRCS) = fenv.c
|
2
sh3eb/assert.h
Normal file
2
sh3eb/assert.h
Normal file
|
@ -0,0 +1,2 @@
|
|||
#pragma once
|
||||
#define assert(b)
|
7
sh3eb/ctype.h
Normal file
7
sh3eb/ctype.h
Normal file
|
@ -0,0 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
static int isxdigit(int c)
|
||||
{
|
||||
return (c >= '0' && c <= '9') || (c >= 'A' && c <= 'F') ||
|
||||
(c >= 'a' && c <= 'f');
|
||||
}
|
183
sh3eb/fenv-softfloat.h
Normal file
183
sh3eb/fenv-softfloat.h
Normal file
|
@ -0,0 +1,183 @@
|
|||
/*-
|
||||
* Copyright (c) 2004-2011 David Schultz <das@FreeBSD.ORG>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#ifndef _FENV_H_
|
||||
#error "This file is meant to be included only by <fenv.h>."
|
||||
#endif
|
||||
|
||||
/*
|
||||
* This file implements the functionality of <fenv.h> on platforms that
|
||||
* lack an FPU and use softfloat in libc for floating point. To use it,
|
||||
* you must write an <fenv.h> that provides the following:
|
||||
*
|
||||
* - a typedef for fenv_t, which may be an integer or struct type
|
||||
* - a typedef for fexcept_t (XXX This file assumes fexcept_t is a
|
||||
* simple integer type containing the exception mask.)
|
||||
* - definitions of FE_* constants for the five exceptions and four
|
||||
* rounding modes in IEEE 754, as described in fenv(3)
|
||||
* - a definition, and the corresponding external symbol, for FE_DFL_ENV
|
||||
* - a macro __set_env(env, flags, mask, rnd), which sets the given fenv_t
|
||||
* from the exception flags, mask, and rounding mode
|
||||
* - macros __env_flags(env), __env_mask(env), and __env_round(env), which
|
||||
* extract fields from an fenv_t
|
||||
* - a definition of __fenv_static
|
||||
*
|
||||
* If the architecture supports an optional FPU, it's recommended that you
|
||||
* define fenv_t and fexcept_t to match the hardware ABI. Otherwise, it
|
||||
* doesn't matter how you define them.
|
||||
*/
|
||||
|
||||
extern int __softfloat_float_exception_flags;
|
||||
extern int __softfloat_float_exception_mask;
|
||||
extern int __softfloat_float_rounding_mode;
|
||||
|
||||
__fenv_static inline int
|
||||
feclearexcept(int __excepts)
|
||||
{
|
||||
|
||||
__softfloat_float_exception_flags &= ~__excepts;
|
||||
return (0);
|
||||
}
|
||||
|
||||
__fenv_static inline int
|
||||
fegetexceptflag(fexcept_t *__flagp, int __excepts)
|
||||
{
|
||||
|
||||
*__flagp = __softfloat_float_exception_flags & __excepts;
|
||||
return (0);
|
||||
}
|
||||
|
||||
__fenv_static inline int
|
||||
fesetexceptflag(const fexcept_t *__flagp, int __excepts)
|
||||
{
|
||||
|
||||
__softfloat_float_exception_flags &= ~__excepts;
|
||||
__softfloat_float_exception_flags |= *__flagp & __excepts;
|
||||
return (0);
|
||||
}
|
||||
|
||||
__fenv_static inline int
|
||||
feraiseexcept(int __excepts)
|
||||
{
|
||||
|
||||
__softfloat_float_exception_flags |= __excepts;
|
||||
return (0);
|
||||
}
|
||||
|
||||
__fenv_static inline int
|
||||
fetestexcept(int __excepts)
|
||||
{
|
||||
|
||||
return (__softfloat_float_exception_flags & __excepts);
|
||||
}
|
||||
|
||||
__fenv_static inline int
|
||||
fegetround(void)
|
||||
{
|
||||
|
||||
return (__softfloat_float_rounding_mode);
|
||||
}
|
||||
|
||||
__fenv_static inline int
|
||||
fesetround(int __round)
|
||||
{
|
||||
|
||||
__softfloat_float_rounding_mode = __round;
|
||||
return (0);
|
||||
}
|
||||
|
||||
__fenv_static inline int
|
||||
fegetenv(fenv_t *__envp)
|
||||
{
|
||||
|
||||
__set_env(*__envp, __softfloat_float_exception_flags,
|
||||
__softfloat_float_exception_mask, __softfloat_float_rounding_mode);
|
||||
return (0);
|
||||
}
|
||||
|
||||
__fenv_static inline int
|
||||
feholdexcept(fenv_t *__envp)
|
||||
{
|
||||
fenv_t __env;
|
||||
|
||||
fegetenv(__envp);
|
||||
__softfloat_float_exception_flags = 0;
|
||||
__softfloat_float_exception_mask = 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
__fenv_static inline int
|
||||
fesetenv(const fenv_t *__envp)
|
||||
{
|
||||
|
||||
__softfloat_float_exception_flags = __env_flags(*__envp);
|
||||
__softfloat_float_exception_mask = __env_mask(*__envp);
|
||||
__softfloat_float_rounding_mode = __env_round(*__envp);
|
||||
return (0);
|
||||
}
|
||||
|
||||
__fenv_static inline int
|
||||
feupdateenv(const fenv_t *__envp)
|
||||
{
|
||||
int __oflags = __softfloat_float_exception_flags;
|
||||
|
||||
fesetenv(__envp);
|
||||
feraiseexcept(__oflags);
|
||||
return (0);
|
||||
}
|
||||
|
||||
#if __BSD_VISIBLE
|
||||
|
||||
/* We currently provide no external definitions of the functions below. */
|
||||
|
||||
__fenv_static inline int
|
||||
feenableexcept(int __mask)
|
||||
{
|
||||
int __omask = __softfloat_float_exception_mask;
|
||||
|
||||
__softfloat_float_exception_mask |= __mask;
|
||||
return (__omask);
|
||||
}
|
||||
|
||||
__fenv_static inline int
|
||||
fedisableexcept(int __mask)
|
||||
{
|
||||
int __omask = __softfloat_float_exception_mask;
|
||||
|
||||
__softfloat_float_exception_mask &= ~__mask;
|
||||
return (__omask);
|
||||
}
|
||||
|
||||
__fenv_static inline int
|
||||
fegetexcept(void)
|
||||
{
|
||||
|
||||
return (__softfloat_float_exception_mask);
|
||||
}
|
||||
|
||||
#endif /* __BSD_VISIBLE */
|
71
sh3eb/fenv.c
Normal file
71
sh3eb/fenv.c
Normal file
|
@ -0,0 +1,71 @@
|
|||
/*-
|
||||
* Copyright (c) 2004 David Schultz <das@FreeBSD.ORG>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#define __fenv_static
|
||||
#include "openlibm_fenv.h"
|
||||
|
||||
#include <float.h>
|
||||
|
||||
#ifdef __GNUC_GNU_INLINE__
|
||||
#error "This file must be compiled with C99 'inline' semantics"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Hopefully the system ID byte is immutable, so it's valid to use
|
||||
* this as a default environment.
|
||||
*/
|
||||
const fenv_t __fe_dfl_env = 0;
|
||||
|
||||
int __softfloat_float_exception_flags = 0;
|
||||
int __softfloat_float_exception_mask = 0;
|
||||
int __softfloat_float_rounding_mode = FLT_ROUNDS;
|
||||
|
||||
#define __set_env(env, flags, mask, rnd) env = ((flags) \
|
||||
| (mask)<<_FPUSW_SHIFT \
|
||||
| (rnd) << 24)
|
||||
#define __env_flags(env) ((env) & FE_ALL_EXCEPT)
|
||||
#define __env_mask(env) (((env) >> _FPUSW_SHIFT) \
|
||||
& FE_ALL_EXCEPT)
|
||||
#define __env_round(env) (((env) >> 24) & _ROUND_MASK)
|
||||
#include "fenv-softfloat.h"
|
||||
|
||||
extern inline int feclearexcept(int __excepts);
|
||||
extern inline int fegetexceptflag(fexcept_t *__flagp, int __excepts);
|
||||
extern inline int fesetexceptflag(const fexcept_t *__flagp, int __excepts);
|
||||
extern inline int feraiseexcept(int __excepts);
|
||||
extern inline int fetestexcept(int __excepts);
|
||||
extern inline int fegetround(void);
|
||||
extern inline int fesetround(int __round);
|
||||
extern inline int fegetenv(fenv_t *__envp);
|
||||
extern inline int feholdexcept(fenv_t *__envp);
|
||||
extern inline int fesetenv(const fenv_t *__envp);
|
||||
extern inline int feupdateenv(const fenv_t *__envp);
|
||||
extern inline int feenableexcept(int __mask);
|
||||
extern inline int fedisableexcept(int __mask);
|
||||
extern inline int fegetexcept(void);
|
||||
|
4
sh3eb/string.h
Normal file
4
sh3eb/string.h
Normal file
|
@ -0,0 +1,4 @@
|
|||
#pragma once
|
||||
#include <stddef.h>
|
||||
|
||||
void *memset(void *mem, int fill, size_t size);
|
|
@ -15,15 +15,14 @@ $(CUR_SRCS) = common.c \
|
|||
s_copysign.c s_copysignf.c s_cos.c s_cosf.c \
|
||||
s_csqrt.c s_csqrtf.c s_erf.c s_erff.c \
|
||||
s_exp2.c s_exp2f.c s_expm1.c s_expm1f.c s_fabs.c s_fabsf.c s_fdim.c \
|
||||
s_floor.c s_floorf.c s_fma.c s_fmaf.c \
|
||||
s_floor.c s_floorf.c \
|
||||
s_fmax.c s_fmaxf.c s_fmin.c \
|
||||
s_fminf.c s_fpclassify.c \
|
||||
s_frexp.c s_frexpf.c s_ilogb.c s_ilogbf.c \
|
||||
s_isinf.c s_isfinite.c s_isnormal.c s_isnan.c \
|
||||
s_llrint.c s_llrintf.c s_llround.c s_llroundf.c \
|
||||
s_log1p.c s_log1pf.c s_logb.c s_logbf.c s_lrint.c s_lrintf.c \
|
||||
s_lround.c s_lroundf.c s_modf.c s_modff.c \
|
||||
s_nearbyint.c s_nextafter.c s_nextafterf.c \
|
||||
s_log1p.c s_log1pf.c s_logb.c s_logbf.c \
|
||||
s_modf.c s_modff.c \
|
||||
s_nextafter.c s_nextafterf.c \
|
||||
s_nexttowardf.c s_remquo.c s_remquof.c \
|
||||
s_rint.c s_rintf.c s_round.c s_roundf.c \
|
||||
s_scalbln.c s_scalbn.c s_scalbnf.c s_signbit.c \
|
||||
|
@ -32,12 +31,20 @@ $(CUR_SRCS) = common.c \
|
|||
s_trunc.c s_truncf.c s_cpow.c s_cpowf.c \
|
||||
w_cabs.c w_cabsf.c
|
||||
|
||||
ifneq ($(ARCH), wasm32)
|
||||
|
||||
$(CUR_SRCS) += \
|
||||
s_fma.c s_fmaf.c s_lrint.c s_lrintf.c s_lround.c s_lroundf.c \
|
||||
s_llrint.c s_llrintf.c s_llround.c s_llroundf.c s_nearbyint.c
|
||||
|
||||
ifneq ($(OS), WINNT)
|
||||
$(CUR_SRCS) += s_nan.c
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
# Add in long double functions for x86, x64 and aarch64
|
||||
ifneq ($(filter $(ARCH),i387 amd64 aarch64),)
|
||||
ifeq ($(LONG_DOUBLE_NOT_DOUBLE),1)
|
||||
# C99 long double functions
|
||||
$(CUR_SRCS) += s_copysignl.c s_fabsl.c s_llrintl.c s_lrintl.c s_modfl.c
|
||||
|
||||
|
|
|
@ -78,12 +78,14 @@
|
|||
/*
|
||||
* Macro to test if we're using a specific version of gcc or later.
|
||||
*/
|
||||
#ifndef __GNUC_PREREQ__
|
||||
#if defined(__GNUC__) && !defined(__INTEL_COMPILER)
|
||||
#define __GNUC_PREREQ__(ma, mi) \
|
||||
(__GNUC__ > (ma) || __GNUC__ == (ma) && __GNUC_MINOR__ >= (mi))
|
||||
#else
|
||||
#define __GNUC_PREREQ__(ma, mi) 0
|
||||
#endif
|
||||
#endif /* __GNUC_PREREQ__ */
|
||||
|
||||
/*
|
||||
* Compiler-dependent macro to help declare pure (no side effects) functions.
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#ifndef _CDEFS_COMPAT_H_
|
||||
#define _CDEFS_COMPAT_H_
|
||||
|
||||
#if !defined(__BEGIN_DECLS)
|
||||
#if defined(__cplusplus)
|
||||
#define __BEGIN_DECLS extern "C" {
|
||||
#define __END_DECLS }
|
||||
|
@ -8,61 +9,94 @@
|
|||
#define __BEGIN_DECLS
|
||||
#define __END_DECLS
|
||||
#endif
|
||||
#endif /* !defined(__BEGIN_DECLS) */
|
||||
|
||||
#ifdef __GNUC__
|
||||
#ifndef __strong_reference
|
||||
#ifdef __APPLE__
|
||||
#define __strong_reference(sym,aliassym) __weak_reference(sym,aliassym)
|
||||
#if defined(__strong_alias) && defined(__NetBSD__)
|
||||
#define openlibm_strong_reference(sym,alias) __strong_alias(alias,sym)
|
||||
#elif defined(__strong_reference)
|
||||
#define openlibm_strong_reference(sym,alias) __strong_reference(sym,alias)
|
||||
#else
|
||||
#define __strong_reference(sym,aliassym) \
|
||||
OLM_DLLEXPORT extern __typeof (sym) aliassym __attribute__ ((__alias__ (#sym)));
|
||||
#ifdef __APPLE__
|
||||
#define openlibm_strong_reference(sym,aliassym) openlibm_weak_reference(sym,aliassym)
|
||||
#else
|
||||
#define openlibm_strong_reference(sym,aliassym) \
|
||||
OLM_DLLEXPORT extern __typeof (aliassym) aliassym __attribute__ ((__alias__ (#sym)));
|
||||
#endif /* __APPLE__ */
|
||||
#endif /* __strong_reference */
|
||||
|
||||
#ifndef __weak_reference
|
||||
#ifdef __wasm__
|
||||
#define openlibm_weak_reference(sym,alias) openlibm_strong_reference(sym,alias)
|
||||
#elif defined(__weak_alias) && defined(__NetBSD__)
|
||||
#define openlibm_weak_reference(sym,alias) __weak_alias(alias,sym)
|
||||
#elif defined(__weak_reference)
|
||||
#define openlibm_weak_reference(sym,alias) __weak_reference(sym,alias)
|
||||
#else
|
||||
#ifdef __ELF__
|
||||
#ifdef __STDC__
|
||||
#define __weak_reference(sym,alias) \
|
||||
#if defined(__sh3__)
|
||||
#define openlibm_weak_reference(sym,alias) \
|
||||
__asm__(".weak _" #alias); \
|
||||
__asm__(".equ _" #alias ", _" #sym)
|
||||
#else
|
||||
#define openlibm_weak_reference(sym,alias) \
|
||||
__asm__(".weak " #alias); \
|
||||
__asm__(".equ " #alias ", " #sym)
|
||||
#define __warn_references(sym,msg) \
|
||||
#endif /* __sh3__ */
|
||||
#ifdef __warn_references
|
||||
#define openlibm_warn_references(sym,msg) __warn_references(sym,msg)
|
||||
#else
|
||||
#define openlibm_warn_references(sym,msg) \
|
||||
__asm__(".section .gnu.warning." #sym); \
|
||||
__asm__(".asciz \"" msg "\""); \
|
||||
__asm__(".previous")
|
||||
#endif /* __warn_references */
|
||||
#else
|
||||
#define __weak_reference(sym,alias) \
|
||||
#define openlibm_weak_reference(sym,alias) \
|
||||
__asm__(".weak alias"); \
|
||||
__asm__(".equ alias, sym")
|
||||
#define __warn_references(sym,msg) \
|
||||
#ifdef __warn_references
|
||||
#define openlibm_warn_references(sym,msg) __warn_references(sym,msg)
|
||||
#else
|
||||
#define openlibm_warn_references(sym,msg) \
|
||||
__asm__(".section .gnu.warning.sym"); \
|
||||
__asm__(".asciz \"msg\""); \
|
||||
__asm__(".previous")
|
||||
#endif /* __warn_references */
|
||||
#endif /* __STDC__ */
|
||||
#elif defined(__clang__) /* CLANG */
|
||||
#ifdef __STDC__
|
||||
#define __weak_reference(sym,alias) \
|
||||
#define openlibm_weak_reference(sym,alias) \
|
||||
__asm__(".weak_reference " #alias); \
|
||||
__asm__(".set " #alias ", " #sym)
|
||||
#else
|
||||
#define __weak_reference(sym,alias) \
|
||||
#define openlibm_weak_reference(sym,alias) \
|
||||
__asm__(".weak_reference alias");\
|
||||
__asm__(".set alias, sym")
|
||||
#endif
|
||||
#else /* !__ELF__ */
|
||||
#ifdef __STDC__
|
||||
#define __weak_reference(sym,alias) \
|
||||
#define openlibm_weak_reference(sym,alias) \
|
||||
__asm__(".stabs \"_" #alias "\",11,0,0,0"); \
|
||||
__asm__(".stabs \"_" #sym "\",1,0,0,0")
|
||||
#define __warn_references(sym,msg) \
|
||||
#ifdef __warn_references
|
||||
#define openlibm_warn_references(sym,msg) __warn_references(sym,msg)
|
||||
#else
|
||||
#define openlibm_warn_references(sym,msg) \
|
||||
__asm__(".stabs \"" msg "\",30,0,0,0"); \
|
||||
__asm__(".stabs \"_" #sym "\",1,0,0,0")
|
||||
#endif /* __warn_references */
|
||||
#else
|
||||
#define __weak_reference(sym,alias) \
|
||||
#define openlibm_weak_reference(sym,alias) \
|
||||
__asm__(".stabs \"_/**/alias\",11,0,0,0"); \
|
||||
__asm__(".stabs \"_/**/sym\",1,0,0,0")
|
||||
#define __warn_references(sym,msg) \
|
||||
#ifdef __warn_references
|
||||
#define openlibm_warn_references(sym,msg) __warn_references(sym,msg)
|
||||
#else
|
||||
#define openlibm_warn_references(sym,msg) \
|
||||
__asm__(".stabs msg,30,0,0,0"); \
|
||||
__asm__(".stabs \"_/**/sym\",1,0,0,0")
|
||||
#endif /* __warn_references */
|
||||
#endif /* __STDC__ */
|
||||
#endif /* __ELF__ */
|
||||
#endif /* __weak_reference */
|
||||
|
|
|
@ -107,5 +107,5 @@ __ieee754_acos(double x)
|
|||
}
|
||||
|
||||
#if LDBL_MANT_DIG == 53
|
||||
__weak_reference(acos, acosl);
|
||||
openlibm_weak_reference(acos, acosl);
|
||||
#endif
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
* acosh(NaN) is NaN without signal.
|
||||
*/
|
||||
|
||||
#include <float.h>
|
||||
#include <openlibm_math.h>
|
||||
|
||||
#include "math_private.h"
|
||||
|
@ -61,3 +62,7 @@ __ieee754_acosh(double x)
|
|||
return log1p(t+sqrt(2.0*t+t*t));
|
||||
}
|
||||
}
|
||||
|
||||
#if (LDBL_MANT_DIG == 53)
|
||||
openlibm_weak_reference(acosh, acoshl);
|
||||
#endif
|
||||
|
|
|
@ -113,5 +113,5 @@ __ieee754_asin(double x)
|
|||
}
|
||||
|
||||
#if LDBL_MANT_DIG == 53
|
||||
__weak_reference(asin, asinl);
|
||||
openlibm_weak_reference(asin, asinl);
|
||||
#endif
|
||||
|
|
|
@ -71,7 +71,7 @@ __ieee754_atan2(double y, double x)
|
|||
if(((ix|((lx|-lx)>>31))>0x7ff00000)||
|
||||
((iy|((ly|-ly)>>31))>0x7ff00000)) /* x or y is NaN */
|
||||
return x+y;
|
||||
if(((hx-0x3ff00000)|lx)==0) return atan(y); /* x=1.0 */
|
||||
if(hx==0x3ff00000&&lx==0) return atan(y); /* x=1.0 */
|
||||
m = ((hy>>31)&1)|((hx>>30)&2); /* 2*sign(x)+sign(y) */
|
||||
|
||||
/* when y = 0 */
|
||||
|
@ -125,5 +125,5 @@ __ieee754_atan2(double y, double x)
|
|||
}
|
||||
|
||||
#if LDBL_MANT_DIG == 53
|
||||
__weak_reference(atan2, atan2l);
|
||||
openlibm_weak_reference(atan2, atan2l);
|
||||
#endif
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#include <float.h>
|
||||
#include <openlibm_math.h>
|
||||
|
||||
#include "math_private.h"
|
||||
|
@ -61,3 +62,7 @@ __ieee754_atanh(double x)
|
|||
t = 0.5*log1p((x+x)/(one-x));
|
||||
if(hx>=0) return t; else return -t;
|
||||
}
|
||||
|
||||
#if (LDBL_MANT_DIG == 53)
|
||||
openlibm_weak_reference(atanh, atanhl);
|
||||
#endif
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
* only cosh(0)=1 is exact for finite x.
|
||||
*/
|
||||
|
||||
#include <float.h>
|
||||
#include <openlibm_math.h>
|
||||
|
||||
#include "math_private.h"
|
||||
|
@ -78,3 +79,7 @@ __ieee754_cosh(double x)
|
|||
/* |x| > overflowthresold, cosh(x) overflow */
|
||||
return huge*huge;
|
||||
}
|
||||
|
||||
#if (LDBL_MANT_DIG == 53)
|
||||
openlibm_weak_reference(cosh, coshl);
|
||||
#endif
|
||||
|
|
|
@ -165,3 +165,7 @@ __ieee754_exp(double x) /* default IEEE double exp */
|
|||
return y*twopk*twom1000;
|
||||
}
|
||||
}
|
||||
|
||||
#if (LDBL_MANT_DIG == 53)
|
||||
openlibm_weak_reference(exp, expl);
|
||||
#endif
|
||||
|
|
|
@ -127,5 +127,5 @@ __ieee754_hypot(double x, double y)
|
|||
}
|
||||
|
||||
#if LDBL_MANT_DIG == 53
|
||||
__weak_reference(hypot, hypotl);
|
||||
openlibm_weak_reference(hypot, hypotl);
|
||||
#endif
|
||||
|
|
|
@ -82,7 +82,7 @@ hypotl(long double x, long double y)
|
|||
man_t manh, manl;
|
||||
GET_LDBL_MAN(manh,manl,b);
|
||||
if((manh|manl)==0) return a;
|
||||
t1=0;
|
||||
t1=1;
|
||||
SET_HIGH_WORD(t1,ESW(MAX_EXP-2)); /* t1=2^(MAX_EXP-2) */
|
||||
b *= t1;
|
||||
a *= t1;
|
||||
|
|
|
@ -65,6 +65,7 @@
|
|||
* to produce the hexadecimal values shown.
|
||||
*/
|
||||
|
||||
#include <float.h>
|
||||
#include <openlibm_math.h>
|
||||
|
||||
#include "math_private.h"
|
||||
|
@ -139,3 +140,7 @@ __ieee754_log(double x)
|
|||
return dk*ln2_hi-((s*(f-R)-dk*ln2_lo)-f);
|
||||
}
|
||||
}
|
||||
|
||||
#if (LDBL_MANT_DIG == 53)
|
||||
openlibm_weak_reference(log, logl);
|
||||
#endif
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
* in not-quite-routine extra precision.
|
||||
*/
|
||||
|
||||
#include <float.h>
|
||||
#include <openlibm_math.h>
|
||||
|
||||
#include "math_private.h"
|
||||
|
@ -86,3 +87,7 @@ __ieee754_log10(double x)
|
|||
|
||||
return val_lo + val_hi;
|
||||
}
|
||||
|
||||
#if (LDBL_MANT_DIG == 53)
|
||||
openlibm_weak_reference(log10, log10l);
|
||||
#endif
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
* in not-quite-routine extra precision.
|
||||
*/
|
||||
|
||||
#include <float.h>
|
||||
#include <openlibm_math.h>
|
||||
|
||||
#include "math_private.h"
|
||||
|
@ -109,3 +110,7 @@ __ieee754_log2(double x)
|
|||
|
||||
return val_lo + val_hi;
|
||||
}
|
||||
|
||||
#if (LDBL_MANT_DIG == 53)
|
||||
openlibm_weak_reference(log2, log2l);
|
||||
#endif
|
||||
|
|
|
@ -57,6 +57,7 @@
|
|||
* to produce the hexadecimal values shown.
|
||||
*/
|
||||
|
||||
#include <float.h>
|
||||
#include <openlibm_math.h>
|
||||
|
||||
#include "math_private.h"
|
||||
|
@ -310,3 +311,7 @@ __ieee754_pow(double x, double y)
|
|||
else SET_HIGH_WORD(z,j);
|
||||
return s*z;
|
||||
}
|
||||
|
||||
#if (LDBL_MANT_DIG == 53)
|
||||
openlibm_weak_reference(pow, powl);
|
||||
#endif
|
||||
|
|
26
src/e_powf.c
26
src/e_powf.c
|
@ -25,6 +25,9 @@ bp[] = {1.0, 1.5,},
|
|||
dp_h[] = { 0.0, 5.84960938e-01,}, /* 0x3f15c000 */
|
||||
dp_l[] = { 0.0, 1.56322085e-06,}, /* 0x35d1cfdc */
|
||||
zero = 0.0,
|
||||
half = 0.5,
|
||||
qrtr = 0.25,
|
||||
thrd = 3.33333343e-01, /* 0x3eaaaaab */
|
||||
one = 1.0,
|
||||
two = 2.0,
|
||||
two24 = 16777216.0, /* 0x4b800000 */
|
||||
|
@ -74,7 +77,7 @@ __ieee754_powf(float x, float y)
|
|||
/* y!=zero: result is NaN if either arg is NaN */
|
||||
if(ix > 0x7f800000 ||
|
||||
iy > 0x7f800000)
|
||||
return (x+0.0F)+(y+0.0F);
|
||||
return nan_mix(x, y);
|
||||
|
||||
/* determine if y is an odd int when x < 0
|
||||
* yisint = 0 ... y is not an integer
|
||||
|
@ -103,15 +106,10 @@ __ieee754_powf(float x, float y)
|
|||
if(iy==0x3f800000) { /* y is +-1 */
|
||||
if(hy<0) return one/x; else return x;
|
||||
}
|
||||
if(hy==0x40000000) return x*x; /* y is 2 */
|
||||
if(hy==0x40400000) return x*x*x; /* y is 3 */
|
||||
if(hy==0x40800000) { /* y is 4 */
|
||||
u = x*x;
|
||||
return u*u;
|
||||
}
|
||||
if(hy==0x3f000000) { /* y is 0.5 */
|
||||
if(hy==0x40000000) return x*x; /* y is 2 */
|
||||
if(hy==0x3f000000) { /* y is 0.5 */
|
||||
if(hx>=0) /* x >= +0 */
|
||||
return __ieee754_sqrtf(x);
|
||||
return __ieee754_sqrtf(x);
|
||||
}
|
||||
|
||||
ax = fabsf(x);
|
||||
|
@ -139,12 +137,12 @@ __ieee754_powf(float x, float y)
|
|||
/* |y| is huge */
|
||||
if(iy>0x4d000000) { /* if |y| > 2**27 */
|
||||
/* over/underflow if x is not close to one */
|
||||
if(ix<0x3f7ffff8) return (hy<0)? sn*huge*huge:sn*tiny*tiny;
|
||||
if(ix<0x3f7ffff7) return (hy<0)? sn*huge*huge:sn*tiny*tiny;
|
||||
if(ix>0x3f800007) return (hy>0)? sn*huge*huge:sn*tiny*tiny;
|
||||
/* now |1-x| is tiny <= 2**-20, suffice to compute
|
||||
log(x) by x-x^2/2+x^3/3-x^4/4 */
|
||||
t = ax-1; /* t has 20 trailing zeros */
|
||||
w = (t*t)*((float)0.5-t*((float)0.333333333333-t*(float)0.25));
|
||||
w = (t*t)*(half-t*(thrd-t*qrtr));
|
||||
u = ivln2_h*t; /* ivln2_h has 16 sig. bits */
|
||||
v = t*ivln2_l-w*ivln2;
|
||||
t1 = u+v;
|
||||
|
@ -183,10 +181,10 @@ __ieee754_powf(float x, float y)
|
|||
r = s2*s2*(L1+s2*(L2+s2*(L3+s2*(L4+s2*(L5+s2*L6)))));
|
||||
r += s_l*(s_h+s);
|
||||
s2 = s_h*s_h;
|
||||
t_h = (float)3.0+s2+r;
|
||||
t_h = 3+s2+r;
|
||||
GET_FLOAT_WORD(is,t_h);
|
||||
SET_FLOAT_WORD(t_h,is&0xfffff000);
|
||||
t_l = r-((t_h-(float)3.0)-s2);
|
||||
t_l = r-((t_h-3)-s2);
|
||||
/* u+v = s*(1+...) */
|
||||
u = s_h*t_h;
|
||||
v = s_l*t_h+t_l*s;
|
||||
|
@ -198,7 +196,7 @@ __ieee754_powf(float x, float y)
|
|||
z_h = cp_h*p_h; /* cp_h+cp_l = 2/(3*log2) */
|
||||
z_l = cp_l*p_h+p_l*cp+dp_l[k];
|
||||
/* log2(ax) = (s+..)*2/(3*log2) = n + dp_h + z_h + z_l */
|
||||
t = (float)n;
|
||||
t = n;
|
||||
t1 = (((z_h+z_l)+dp_h[k])+t);
|
||||
GET_FLOAT_WORD(is,t1);
|
||||
SET_FLOAT_WORD(t1,is&0xfffff000);
|
||||
|
|
|
@ -75,5 +75,5 @@ __ieee754_remainder(double x, double p)
|
|||
}
|
||||
|
||||
#if LDBL_MANT_DIG == 53
|
||||
__weak_reference(remainder, remainderl);
|
||||
openlibm_weak_reference(remainder, remainderl);
|
||||
#endif
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
* only sinh(0)=0 is exact for finite x.
|
||||
*/
|
||||
|
||||
#include <float.h>
|
||||
#include <openlibm_math.h>
|
||||
|
||||
#include "math_private.h"
|
||||
|
@ -72,3 +73,7 @@ __ieee754_sinh(double x)
|
|||
/* |x| > overflowthresold, sinh(x) overflow */
|
||||
return x*shuge;
|
||||
}
|
||||
|
||||
#if (LDBL_MANT_DIG == 53)
|
||||
openlibm_weak_reference(sinh, sinhl);
|
||||
#endif
|
||||
|
|
|
@ -189,7 +189,7 @@ __ieee754_sqrt(double x)
|
|||
}
|
||||
|
||||
#if (LDBL_MANT_DIG == 53)
|
||||
__weak_reference(sqrt, sqrtl);
|
||||
openlibm_weak_reference(sqrt, sqrtl);
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
|
|
@ -39,6 +39,12 @@
|
|||
#endif
|
||||
#elif defined(__powerpc__)
|
||||
#include "powerpc_fpmath.h"
|
||||
#elif defined(__mips__)
|
||||
#include "mips_fpmath.h"
|
||||
#elif defined(__s390__)
|
||||
#include "s390_fpmath.h"
|
||||
#elif defined(__sh3__)
|
||||
#include "sh3eb_fpmath.h"
|
||||
#endif
|
||||
|
||||
/* Definitions provided directly by GCC and Clang. */
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#define _MATH_PRIVATE_H_
|
||||
|
||||
#include <openlibm_complex.h>
|
||||
|
||||
#include <openlibm_defs.h>
|
||||
#include "cdefs-compat.h"
|
||||
#include "types-compat.h"
|
||||
#include "fpmath.h"
|
||||
|
@ -203,10 +203,9 @@ do { \
|
|||
} while (0)
|
||||
|
||||
|
||||
//VBS
|
||||
#ifndef __FreeBSD__
|
||||
#define STRICT_ASSIGN(type, lval, rval) ((lval) = (rval))
|
||||
|
||||
/* VBS
|
||||
#else
|
||||
#ifdef FLT_EVAL_METHOD
|
||||
// Attempt to get strict C99 semantics for assignment with non-C99 compilers.
|
||||
#if FLT_EVAL_METHOD == 0 || __GNUC__ == 0
|
||||
|
@ -215,7 +214,7 @@ do { \
|
|||
#define STRICT_ASSIGN(type, lval, rval) do { \
|
||||
volatile type __lval; \
|
||||
\
|
||||
if (sizeof(type) >= sizeof(double)) \
|
||||
if (sizeof(type) >= sizeof(long double)) \
|
||||
(lval) = (rval); \
|
||||
else { \
|
||||
__lval = (rval); \
|
||||
|
@ -224,13 +223,31 @@ do { \
|
|||
} while (0)
|
||||
#endif
|
||||
#endif
|
||||
*/
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Common routine to process the arguments to nan(), nanf(), and nanl().
|
||||
*/
|
||||
void __scan_nan(u_int32_t *__words, int __num_words, const char *__s);
|
||||
|
||||
/*
|
||||
* Mix 1 or 2 NaNs. First add 0 to each arg. This normally just turns
|
||||
* signaling NaNs into quiet NaNs by setting a quiet bit. We do this
|
||||
* because we want to never return a signaling NaN, and also because we
|
||||
* don't want the quiet bit to affect the result. Then mix the converted
|
||||
* args using addition. The result is typically the arg whose mantissa
|
||||
* bits (considered as in integer) are largest.
|
||||
*
|
||||
* Technical complications: the result in bits might depend on the precision
|
||||
* and/or on compiler optimizations, especially when different register sets
|
||||
* are used for different precisions. Try to make the result not depend on
|
||||
* at least the precision by always doing the main mixing step in long double
|
||||
* precision. Try to reduce dependencies on optimizations by adding the
|
||||
* the 0's in different precisions (unless everything is in long double
|
||||
* precision).
|
||||
*/
|
||||
#define nan_mix(x, y) (((x) + 0.0L) + ((y) + 0))
|
||||
|
||||
#ifdef __GNUCLIKE_ASM
|
||||
|
||||
/* Asm versions of some functions. */
|
||||
|
@ -355,16 +372,4 @@ long double __kernel_sinl(long double, long double, int);
|
|||
long double __kernel_cosl(long double, long double);
|
||||
long double __kernel_tanl(long double, long double, int);
|
||||
|
||||
#undef OLM_DLLEXPORT
|
||||
#ifdef _WIN32
|
||||
# ifdef IMPORT_EXPORTS
|
||||
# define OLM_DLLEXPORT __declspec(dllimport)
|
||||
# else
|
||||
# define OLM_DLLEXPORT __declspec(dllexport)
|
||||
# endif
|
||||
#else
|
||||
#define OLM_DLLEXPORT __attribute__ ((visibility("default")))
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* !_MATH_PRIVATE_H_ */
|
||||
|
|
57
src/mips_fpmath.h
Normal file
57
src/mips_fpmath.h
Normal file
|
@ -0,0 +1,57 @@
|
|||
/*-
|
||||
* Copyright (c) 2002, 2003 David Schultz <das@FreeBSD.ORG>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
union IEEEl2bits {
|
||||
long double e;
|
||||
struct {
|
||||
#ifndef __MIPSEB__
|
||||
unsigned int manl :32;
|
||||
unsigned int manh :20;
|
||||
unsigned int exp :11;
|
||||
unsigned int sign :1;
|
||||
#else
|
||||
unsigned int sign :1;
|
||||
unsigned int exp :11;
|
||||
unsigned int manh :20;
|
||||
unsigned int manl :32;
|
||||
#endif
|
||||
} bits;
|
||||
};
|
||||
|
||||
#define LDBL_NBIT 0
|
||||
#define mask_nbit_l(u) ((void)0)
|
||||
#define LDBL_IMPLICIT_NBIT
|
||||
|
||||
#define LDBL_MANH_SIZE 20
|
||||
#define LDBL_MANL_SIZE 32
|
||||
|
||||
#define LDBL_TO_ARRAY32(u, a) do { \
|
||||
(a)[0] = (uint32_t)(u).bits.manl; \
|
||||
(a)[1] = (uint32_t)(u).bits.manh; \
|
||||
} while(0)
|
||||
|
51
src/s390_fpmath.h
Normal file
51
src/s390_fpmath.h
Normal file
|
@ -0,0 +1,51 @@
|
|||
/*-
|
||||
* Copyright (c) 2016 Dan Horák <dan[at]danny.cz>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*
|
||||
* cloned from powerpc_fpmath.h
|
||||
*/
|
||||
|
||||
union IEEEl2bits {
|
||||
long double e;
|
||||
struct {
|
||||
unsigned int sign :1;
|
||||
unsigned int exp :11;
|
||||
unsigned int manh :20;
|
||||
unsigned int manl :32;
|
||||
} bits;
|
||||
};
|
||||
|
||||
#define mask_nbit_l(u) ((void)0)
|
||||
#define LDBL_IMPLICIT_NBIT
|
||||
#define LDBL_NBIT 0
|
||||
|
||||
#define LDBL_MANH_SIZE 20
|
||||
#define LDBL_MANL_SIZE 32
|
||||
|
||||
#define LDBL_TO_ARRAY32(u, a) do { \
|
||||
(a)[0] = (uint32_t)(u).bits.manl; \
|
||||
(a)[1] = (uint32_t)(u).bits.manh; \
|
||||
} while(0)
|
|
@ -24,6 +24,7 @@
|
|||
* := sign(x)*log1p(|x| + x^2/(1 + sqrt(1+x^2)))
|
||||
*/
|
||||
|
||||
#include <float.h>
|
||||
#include <openlibm_math.h>
|
||||
|
||||
#include "math_private.h"
|
||||
|
@ -55,3 +56,7 @@ asinh(double x)
|
|||
}
|
||||
if(hx>0) return w; else return -w;
|
||||
}
|
||||
|
||||
#if (LDBL_MANT_DIG == 53)
|
||||
openlibm_weak_reference(asinh, asinhl);
|
||||
#endif
|
||||
|
|
|
@ -120,5 +120,5 @@ atan(double x)
|
|||
}
|
||||
|
||||
#if LDBL_MANT_DIG == 53
|
||||
__weak_reference(atan, atanl);
|
||||
openlibm_weak_reference(atan, atanl);
|
||||
#endif
|
||||
|
|
|
@ -50,6 +50,8 @@
|
|||
#include <openlibm_complex.h>
|
||||
#include <openlibm_math.h>
|
||||
|
||||
#include "math_private.h"
|
||||
|
||||
double complex
|
||||
cacos(double complex z)
|
||||
{
|
||||
|
@ -61,5 +63,5 @@ cacos(double complex z)
|
|||
}
|
||||
|
||||
#if LDBL_MANT_DIG == DBL_MANT_DIG
|
||||
__strong_alias(cacosl, cacos);
|
||||
openlibm_strong_reference(cacos, cacosl);
|
||||
#endif /* LDBL_MANT_DIG == DBL_MANT_DIG */
|
||||
|
|
|
@ -46,6 +46,8 @@
|
|||
#include <openlibm_complex.h>
|
||||
#include <openlibm_math.h>
|
||||
|
||||
#include "math_private.h"
|
||||
|
||||
double complex
|
||||
cacosh(double complex z)
|
||||
{
|
||||
|
@ -56,5 +58,5 @@ cacosh(double complex z)
|
|||
}
|
||||
|
||||
#if LDBL_MANT_DIG == DBL_MANT_DIG
|
||||
__strong_alias(cacoshl, cacosh);
|
||||
openlibm_strong_reference(cacosh, cacoshl);
|
||||
#endif /* LDBL_MANT_DIG == DBL_MANT_DIG */
|
||||
|
|
|
@ -53,6 +53,8 @@
|
|||
#include <openlibm_complex.h>
|
||||
#include <openlibm_math.h>
|
||||
|
||||
#include "math_private.h"
|
||||
|
||||
double complex
|
||||
casin(double complex z)
|
||||
{
|
||||
|
@ -130,5 +132,5 @@ casin(double complex z)
|
|||
}
|
||||
|
||||
#if LDBL_MANT_DIG == DBL_MANT_DIG
|
||||
__strong_alias(casinl, casin);
|
||||
openlibm_strong_reference(casin, casinl);
|
||||
#endif /* LDBL_MANT_DIG == DBL_MANT_DIG */
|
||||
|
|
|
@ -46,6 +46,8 @@
|
|||
#include <openlibm_complex.h>
|
||||
#include <openlibm_math.h>
|
||||
|
||||
#include "math_private.h"
|
||||
|
||||
double complex
|
||||
casinh(double complex z)
|
||||
{
|
||||
|
@ -56,5 +58,5 @@ casinh(double complex z)
|
|||
}
|
||||
|
||||
#if LDBL_MANT_DIG == DBL_MANT_DIG
|
||||
__strong_alias(casinhl, casinh);
|
||||
openlibm_strong_reference(casinh, casinhl);
|
||||
#endif /* LDBL_MANT_DIG == DBL_MANT_DIG */
|
||||
|
|
|
@ -66,6 +66,8 @@
|
|||
#include <openlibm_complex.h>
|
||||
#include <openlibm_math.h>
|
||||
|
||||
#include "math_private.h"
|
||||
|
||||
#define MAXNUM 1.0e308
|
||||
|
||||
static const double DP1 = 3.14159265160560607910E0;
|
||||
|
@ -127,5 +129,5 @@ ovrf:
|
|||
}
|
||||
|
||||
#if LDBL_MANT_DIG == DBL_MANT_DIG
|
||||
__strong_alias(catanl, catan);
|
||||
openlibm_strong_reference(catan, catanl);
|
||||
#endif /* LDBL_MANT_DIG == DBL_MANT_DIG */
|
||||
|
|
|
@ -46,6 +46,8 @@
|
|||
#include <openlibm_complex.h>
|
||||
#include <openlibm_math.h>
|
||||
|
||||
#include "math_private.h"
|
||||
|
||||
double complex
|
||||
catanh(double complex z)
|
||||
{
|
||||
|
@ -56,5 +58,5 @@ catanh(double complex z)
|
|||
}
|
||||
|
||||
#if LDBL_MANT_DIG == DBL_MANT_DIG
|
||||
__strong_alias(catanhl, catanh);
|
||||
openlibm_strong_reference(catanh, catanhl);
|
||||
#endif /* LDBL_MANT_DIG == DBL_MANT_DIG */
|
||||
|
|
|
@ -114,5 +114,5 @@ cbrt(double x)
|
|||
}
|
||||
|
||||
#if (LDBL_MANT_DIG == 53)
|
||||
__weak_reference(cbrt, cbrtl);
|
||||
openlibm_weak_reference(cbrt, cbrtl);
|
||||
#endif
|
||||
|
|
|
@ -73,5 +73,5 @@ ceil(double x)
|
|||
}
|
||||
|
||||
#if LDBL_MANT_DIG == 53
|
||||
__weak_reference(ceil, ceill);
|
||||
openlibm_weak_reference(ceil, ceill);
|
||||
#endif
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
* If z = x + iy, r = sqrt( x**2 + y**2 ),
|
||||
* then
|
||||
* w = log(r) + i arctan(y/x).
|
||||
*
|
||||
*
|
||||
* The arctangent ranges from -PI to +PI.
|
||||
*
|
||||
*
|
||||
|
@ -58,6 +58,8 @@
|
|||
#include <openlibm_complex.h>
|
||||
#include <openlibm_math.h>
|
||||
|
||||
#include "math_private.h"
|
||||
|
||||
double complex
|
||||
clog(double complex z)
|
||||
{
|
||||
|
@ -73,5 +75,5 @@ clog(double complex z)
|
|||
}
|
||||
|
||||
#if LDBL_MANT_DIG == DBL_MANT_DIG
|
||||
__strong_alias(clogl, clog);
|
||||
openlibm_strong_reference(clog, clogl);
|
||||
#endif /* LDBL_MANT_DIG == DBL_MANT_DIG */
|
||||
|
|
|
@ -85,5 +85,5 @@ cos(double x)
|
|||
}
|
||||
|
||||
#if (LDBL_MANT_DIG == 53)
|
||||
__weak_reference(cos, cosl);
|
||||
openlibm_weak_reference(cos, cosl);
|
||||
#endif
|
||||
|
|
|
@ -74,5 +74,5 @@ cpow(double complex a, double complex z)
|
|||
}
|
||||
|
||||
#if LDBL_MANT_DIG == DBL_MANT_DIG
|
||||
__strong_alias(cpowl, cpow);
|
||||
openlibm_strong_reference(cpow, cpowl);
|
||||
#endif /* LDBL_MANT_DIG == DBL_MANT_DIG */
|
||||
|
|
|
@ -43,5 +43,5 @@ cproj(double complex z)
|
|||
}
|
||||
|
||||
#if LDBL_MANT_DIG == 53
|
||||
__weak_reference(cproj, cprojl);
|
||||
openlibm_weak_reference(cproj, cprojl);
|
||||
#endif
|
||||
|
|
|
@ -110,5 +110,5 @@ csqrt(double complex z)
|
|||
}
|
||||
|
||||
#if LDBL_MANT_DIG == 53
|
||||
__weak_reference(csqrt, csqrtl);
|
||||
openlibm_weak_reference(csqrt, csqrtl);
|
||||
#endif
|
||||
|
|
|
@ -107,6 +107,7 @@
|
|||
* erfc/erf(NaN) is NaN
|
||||
*/
|
||||
|
||||
#include <float.h>
|
||||
#include <openlibm_math.h>
|
||||
|
||||
#include "math_private.h"
|
||||
|
@ -299,3 +300,8 @@ erfc(double x)
|
|||
if(hx>0) return tiny*tiny; else return two-tiny;
|
||||
}
|
||||
}
|
||||
|
||||
#if (LDBL_MANT_DIG == 53)
|
||||
openlibm_weak_reference(erf, erfl);
|
||||
openlibm_weak_reference(erfc, erfcl);
|
||||
#endif
|
||||
|
|
|
@ -392,5 +392,5 @@ exp2(double x)
|
|||
}
|
||||
|
||||
#if (LDBL_MANT_DIG == 53)
|
||||
__weak_reference(exp2, exp2l);
|
||||
openlibm_weak_reference(exp2, exp2l);
|
||||
#endif
|
||||
|
|
|
@ -147,7 +147,7 @@ expm1(double x)
|
|||
GET_LOW_WORD(low,x);
|
||||
if(((hx&0xfffff)|low)!=0)
|
||||
return x+x; /* NaN */
|
||||
else return (xsb==0)? x:-1.0;/* exp(+-inf)={inf,-1} */
|
||||
else return (xsb==0)? x:-1.0;/* exp(+-inf)-1={inf,-1} */
|
||||
}
|
||||
if(x > o_threshold) return huge*huge; /* overflow */
|
||||
}
|
||||
|
@ -215,3 +215,7 @@ expm1(double x)
|
|||
}
|
||||
return y;
|
||||
}
|
||||
|
||||
#if (LDBL_MANT_DIG == 53)
|
||||
openlibm_weak_reference(expm1, expm1l);
|
||||
#endif
|
||||
|
|
|
@ -43,4 +43,6 @@ fn(type x, type y) \
|
|||
|
||||
DECL(double, fdim)
|
||||
DECL(float, fdimf)
|
||||
#ifdef OLM_LONG_DOUBLE
|
||||
DECL(long double, fdiml)
|
||||
#endif
|
||||
|
|
|
@ -74,5 +74,5 @@ floor(double x)
|
|||
}
|
||||
|
||||
#if LDBL_MANT_DIG == 53
|
||||
__weak_reference(floor, floorl);
|
||||
openlibm_weak_reference(floor, floorl);
|
||||
#endif
|
||||
|
|
|
@ -280,5 +280,5 @@ fma(double x, double y, double z)
|
|||
}
|
||||
|
||||
#if (LDBL_MANT_DIG == 53)
|
||||
__weak_reference(fma, fmal);
|
||||
openlibm_weak_reference(fma, fmal);
|
||||
#endif
|
||||
|
|
|
@ -72,7 +72,7 @@ __fpclassifyf(float f)
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef LONG_DOUBLE
|
||||
#ifdef OLM_LONG_DOUBLE
|
||||
OLM_DLLEXPORT int
|
||||
__fpclassifyl(long double e)
|
||||
{
|
||||
|
|
|
@ -52,5 +52,5 @@ frexp(double x, int *eptr)
|
|||
}
|
||||
|
||||
#if (LDBL_MANT_DIG == 53)
|
||||
__weak_reference(frexp, frexpl);
|
||||
openlibm_weak_reference(frexp, frexpl);
|
||||
#endif
|
||||
|
|
|
@ -49,7 +49,7 @@ __isfinitef(float f)
|
|||
return (u.bits.exp != 255);
|
||||
}
|
||||
|
||||
#ifdef LONG_DOUBLE
|
||||
#ifdef OLM_LONG_DOUBLE
|
||||
OLM_DLLEXPORT int
|
||||
__isfinitel(long double e)
|
||||
{
|
||||
|
|
|
@ -51,7 +51,7 @@ __isinff(float f)
|
|||
return (u.bits.exp == 255 && u.bits.man == 0);
|
||||
}
|
||||
|
||||
#ifdef LONG_DOUBLE
|
||||
#ifdef OLM_LONG_DOUBLE
|
||||
OLM_DLLEXPORT int
|
||||
__isinfl(long double e)
|
||||
{
|
||||
|
@ -63,4 +63,4 @@ __isinfl(long double e)
|
|||
}
|
||||
#endif
|
||||
|
||||
__weak_reference(__isinff, isinff);
|
||||
openlibm_weak_reference(__isinff, isinff);
|
||||
|
|
|
@ -52,7 +52,7 @@ __isnanf(float f)
|
|||
return (u.bits.exp == 255 && u.bits.man != 0);
|
||||
}
|
||||
|
||||
#ifdef LONG_DOUBLE
|
||||
#ifdef OLM_LONG_DOUBLE
|
||||
OLM_DLLEXPORT int
|
||||
__isnanl(long double e)
|
||||
{
|
||||
|
@ -64,4 +64,4 @@ __isnanl(long double e)
|
|||
}
|
||||
#endif
|
||||
|
||||
__weak_reference(__isnanf, isnanf);
|
||||
openlibm_weak_reference(__isnanf, isnanf);
|
||||
|
|
|
@ -49,7 +49,7 @@ __isnormalf(float f)
|
|||
return (u.bits.exp != 0 && u.bits.exp != 255);
|
||||
}
|
||||
|
||||
#ifdef LONG_DOUBLE
|
||||
#ifdef OLM_LONG_DOUBLE
|
||||
OLM_DLLEXPORT int
|
||||
__isnormall(long double e)
|
||||
{
|
||||
|
|
|
@ -173,3 +173,7 @@ log1p(double x)
|
|||
if(k==0) return f-(hfsq-s*(hfsq+R)); else
|
||||
return k*ln2_hi-((hfsq-(s*(hfsq+R)+(k*ln2_lo+c)))-f);
|
||||
}
|
||||
|
||||
#if (LDBL_MANT_DIG == 53)
|
||||
openlibm_weak_reference(log1p, log1pl);
|
||||
#endif
|
||||
|
|
|
@ -45,5 +45,5 @@ logb(double x)
|
|||
}
|
||||
|
||||
#if (LDBL_MANT_DIG == 53)
|
||||
__weak_reference(logb, logbl);
|
||||
openlibm_weak_reference(logb, logbl);
|
||||
#endif
|
||||
|
|
|
@ -120,5 +120,5 @@ nanf(const char *s)
|
|||
}
|
||||
|
||||
#if (LDBL_MANT_DIG == 53)
|
||||
__weak_reference(nan, nanl);
|
||||
openlibm_weak_reference(nan, nanl);
|
||||
#endif
|
||||
|
|
|
@ -77,7 +77,7 @@ nextafter(double x, double y)
|
|||
}
|
||||
|
||||
#if (LDBL_MANT_DIG == 53)
|
||||
__weak_reference(nextafter, nexttoward);
|
||||
__weak_reference(nextafter, nexttowardl);
|
||||
__weak_reference(nextafter, nextafterl);
|
||||
openlibm_weak_reference(nextafter, nexttoward);
|
||||
openlibm_weak_reference(nextafter, nexttowardl);
|
||||
openlibm_weak_reference(nextafter, nextafterl);
|
||||
#endif
|
||||
|
|
|
@ -77,4 +77,4 @@ nextafterl(long double x, long double y)
|
|||
return ux.e;
|
||||
}
|
||||
|
||||
__strong_reference(nextafterl, nexttowardl);
|
||||
openlibm_strong_reference(nextafterl, nexttowardl);
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
#define LDBL_INFNAN_EXP (LDBL_MAX_EXP * 2 - 1)
|
||||
|
||||
#ifdef LONG_DOUBLE
|
||||
#ifdef OLM_LONG_DOUBLE
|
||||
OLM_DLLEXPORT float
|
||||
nexttowardf(float x, long double y)
|
||||
{
|
||||
|
|
|
@ -154,5 +154,5 @@ fixup:
|
|||
}
|
||||
|
||||
#if LDBL_MANT_DIG == 53
|
||||
__weak_reference(remquo, remquol);
|
||||
openlibm_weak_reference(remquo, remquol);
|
||||
#endif
|
||||
|
|
|
@ -88,5 +88,5 @@ rint(double x)
|
|||
}
|
||||
|
||||
#if (LDBL_MANT_DIG == 53)
|
||||
__weak_reference(rint, rintl);
|
||||
openlibm_weak_reference(rint, rintl);
|
||||
#endif
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue