Compare commits

...

70 Commits

Author SHA1 Message Date
Lephenixnoir 9828d2e3f2
meta: update build instructions 2022-08-21 11:55:28 +02:00
Lephenixnoir 65aaba96e1
install: trim the set of installed headers (and libm.a)
This is because all of these headers are included in direct style with
no subfolder so we need them to be in a quite public `include/` folder.
The Makefile installs in `include/openlibm/` but this only works with
extra `-I` flags that are quite annoying to enforce.

With this change, the only OpenLibm headers that are installed are named
`openlibm_*.h`, which is sufficient in terms of namespacing.

Also add a symlink libm.a -> libopenlibm.a.
2022-08-19 16:02:05 +02:00
Lephenixnoir feba6242e4
fenv: avoid internal includes in user-facing headers
A future cleanup will drastically reduce the set of headers being installed,
and we don't want to install internal headers in particular.
2022-08-19 16:02:05 +02:00
Lephenixnoir 63c74a4b92
also update make settings on GiteaPC
Follow-up to 39ede78797.
2021-05-25 21:45:51 +02:00
Lephenixnoir e67d553764
make: do not compile the static archive with -fPIC
No idea why it is enabled in the static version.
2021-05-21 14:22:02 +02:00
Lephenixnoir 08f772e6ab
fenv: provide environment primitives 2021-05-21 14:21:51 +02:00
Lephenixnoir 1cf5a91b46
make: add the sh3eb folder to the clean target 2021-05-21 14:07:39 +02:00
Lephenixnoir 8afd538dc8
add missing weak references for long double functions
This ensures that all standard long double functions are defined when
building with 64-bit long double.
2021-05-20 23:30:25 +02:00
Lephenixnoir 39ede78797
README: update make command due to toolchain changes 2021-05-20 23:30:25 +02:00
Lephenixnoir 668336366e
merge from upstream, updated to 0.7.5 2021-05-20 21:31:25 +02:00
Lephenixnoir d241d4f77a
fix aliases not using underscore prefixes in assembler code
long double functions, that are identical to double functions, usually
define themselves as weak references to their double counterpart.
However, the piece of assembler written for that produces

  .equ <name>l, <name>

but on SuperH C-exported symbols have leading underscores. This commit
adds an SH3 exception to use instead

  .equ _<name>l, _<name>

which fixes a number of long double functions.
2021-05-20 21:27:38 +02:00
Lephenixnoir 07a9090c98
add CMake instructions in the README 2021-05-02 15:07:48 +02:00
Elliot Saba f052f42bb3
Merge pull request #228 from JuliaMath/aa/hypotl
Fix incorrect results in `hypotl` near underflow
2021-02-17 09:04:36 -08:00
Steven G. Kargl 711654eeab
Fix incorrect results in `hypotl` near underflow
Fixes #224.
2021-02-10 12:44:19 -08:00
Viral B. Shah aeab19f47e Fix for #211
Co-authored by: @kargl
2021-02-08 09:39:30 -05:00
Viral B. Shah 5449705906
Merge pull request #227 from JuliaMath/vs/powf
Fix #211
2021-02-06 18:25:12 -05:00
Viral B. Shah 98f87135b0 Fix #211
Patched by importing latest msun version
2021-02-06 18:10:09 -05:00
Viral B. Shah 6a85b33182
Merge pull request #225 from JuliaMath/vs/strict_assign
Restore STRICT_ASSIGN on FreeBSD as suggested in #215
2021-02-06 18:09:23 -05:00
Viral B. Shah 40dac9dd77 Restore STRICT_ASSIGN on FreeBSD as suggested in #215
Co-authored-by: @kargl
2021-02-06 17:27:15 -05:00
Viral B. Shah 2d10c90c77
Merge pull request #218 from jcestibariz/fix-wasm32
Fix compilation errors on wasm32
2021-02-06 11:55:26 -05:00
Elliot Saba 5d70ac564c
Merge pull request #221 from maleadt/tb/static_fenv 2021-02-02 11:43:04 -08:00
Tim Besard 63aa8757f3 Make fenv methods static on additional platforms. 2021-02-01 13:48:31 +01:00
Lephenixnoir 22428cc5d2
add support for quick build with GiteaPC 2021-01-25 17:57:54 +01:00
JC Estibariz 9152b0d1b0 Fix compilation errors on wasm32 2020-12-01 13:17:32 -05:00
Elliot Saba 3cb804556f
Merge pull request #217 from epsilon-0/master
don't alter toolchain vars if already provided
2020-11-30 09:25:02 -08:00
Elliot Saba c8561015a4
Merge pull request #219 from maleadt/tb/dont_export_fenv
Revert "Export `fenv` functions on all platforms (#213)"
2020-11-16 12:23:59 -08:00
Tim Besard be31bff11d Revert "Export `fenv` functions on all platforms (#213)"
The implementation of `fesetenv` cannot be portable, as the value of
`FE_DFL_ENV` differs between platforms. On FreeBSD, it is a actual
environment. With glibc however, it's a sentinel -1 handled in the
implementation of its floating point functions.

With openlibm based on FreeBSD's libm, it assumes `FE_DFL_ENV` to be an
actual environment. That assumption breaks using code that was compiled
against glibc, e.g., `libcuda`:

```
Thread 1 "julia-debug" received signal SIGSEGV, Segmentation fault.
0x00007ffff7b855d0 in fesetenv () from /home/tim/Julia/julia/build/release/usr/bin/../lib/libopenlibm.so
(gdb) bt
```

This reverts commit 5a27b4c0c0.

Fixes https://github.com/JuliaLang/julia/issues/38427.
2020-11-16 09:17:49 +01:00
Lephenixnoir 69b3140a0d
sh3eb: add new README file 2020-10-24 15:11:01 +02:00
Lephenixnoir 998328ebc0
sh3eb: move older README 2020-10-24 14:02:38 +02:00
Lephenixnoir 44c1cbb8eb
sh3eb: add suport for the sh3eb softfp platform 2020-10-24 13:55:39 +02:00
Lephenixnoir 89b463b811
sh3eb: only retain the softfp option of the MIPS fenv.h 2020-10-24 13:42:09 +02:00
Lephenixnoir 1b364a5edf
sh3eb: copy files from the MIPS softfp fenv.h 2020-10-24 13:42:09 +02:00
Aisha Tammy eb21e8abd1
don't alter toolchain vars if already provided 2020-10-23 15:36:23 +00:00
Keno Fischer b34f107e24
Fix Apple Silicon build (#214)
My previous Apple Silicon build went through, so I thought it already
worked, but it turns out it accidentally built an armv7 build instead.
This actually fixes the Apple Silicon build. One thing to note in
particular is that on Apple Silicong `long double` is the same as
`double` while on Linux `long double` is a 128 bit double-double
format.

Co-authored-by: Elliot Saba <staticfloat@gmail.com>
2020-09-03 18:27:17 -04:00
Elliot Saba 5a27b4c0c0
Export `fenv` functions on all platforms (#213)
Win32 has been using a hack to switch the `fenv` functions from `static`
to `DLLEXPORT`, we apply that hack to all platforms that do not use a
host `fenv.h`.
2020-09-02 12:33:04 -04:00
Viral B. Shah 878948d3dd
Update list of libm libraries 2020-08-29 11:25:56 -04:00
Viral B. Shah 508603d2f6
Update index.html 2020-08-29 11:18:18 -04:00
Viral B. Shah 0276147a68
Merge pull request #209 from embeddedartistry/master
Refactor: OLM_DLLEXPORT definition now lives in a standalone header.
2020-08-29 11:12:57 -04:00
Viral B. Shah f2a8b3690a
Update download links to point to releases 2020-08-29 11:11:35 -04:00
Elliot Saba 1d6befd0df
Merge pull request #208 from cndesantana/patch-1
Fix small typo
2020-08-26 14:58:02 -07:00
Keno Fischer 4f559d4c14
Replace a few remaining __strong_reference uses (#210)
__strong_alias is an ELF feature that is not available on Darwin/MachO.
We have openlibm_strong_reference to paper over these differences,
but we weren't using it consistently. In particular, we were still
using it to define long double -> double aliases on platforms where
these are the same type (e.g. aarch64). This didn't used to matter,
because the only such platform we supported was always Linux and
thus ELF. This patch fixes these instances thus fixing the build
on Apple Silicon.
2020-07-09 15:51:12 -04:00
Phillip Johnston 0418324ca4 Refactor: OLM_DLLEXPORT definition now lives in a standalone header.
On x86_64, openlibm_fenv.h is silently coupled to openlibm_complex.h due to the inclusion of math_private.h inside of openlibm_fenv_amd64.h. The math_private.h header was included to gain access to the OLM_DLLEXPORT macro. However, this macro is redefined, since it is originally defined in openlibm_math.h. This inclusion also exposes math_private.h to public clients, which is undesirable.

Instead, a standalone header is created to contain the OLM_DLLEXPORT definition. This header is used included in the appropriate files. openlibm_fenv_amd64.h is no longer coupled to math_private.h.
2020-06-10 15:57:08 -07:00
cndesantana 861b2ad19d
Fix small typo
replace langage by language
2020-03-31 12:37:11 +02:00
Viral B. Shah 5b0e7e9813
Update FUNDING.yml 2020-02-06 05:11:46 -05:00
Viral B. Shah 382b8e92f4 Add musl-libc math library to resources. 2019-12-09 21:56:36 -05:00
Viral B. Shah f6ad75aa67 update openlibm website. 2019-12-09 21:53:47 -05:00
Viral B. Shah 5efed306d5 Bump SONAME as discussed in #200 2019-12-09 21:43:44 -05:00
Viral B. Shah e6ac7d7f52 Update README with new OS and arch support 2019-12-09 21:38:44 -05:00
Viral B. Shah f731481b25
Merge pull request #199 from llucinat/wasm32-weakref
Fix weak reference macro redefinition in wasm32 target
2019-11-15 06:44:47 -05:00
llucinat f952e167d2 Fix weak reference macro redefinition in wasm32 target 2019-11-14 08:41:10 +01:00
Viral B. Shah 97de1a46a9
Merge pull request #198 from gufe44/netbsd-fix-openlibm_weak_reference
Netbsd fix openlibm weak reference
2019-10-26 10:28:11 -04:00
gufe44 c4dca1e84a
Add files via upload 2019-10-26 01:53:42 +02:00
gufe44 d4077aa131
Suggestions
https://github.com/JuliaMath/openlibm/pull/197#pullrequestreview-307404318
2019-10-26 01:05:27 +02:00
gufe44 ea065f90cb
Update src/cdefs-compat.h
Co-Authored-By: Jameson Nash <vtjnash@gmail.com>
2019-10-25 23:45:13 +02:00
gufe44 2080b23690
NetBSD fix 2019-10-25 18:32:47 +02:00
Viral B. Shah 14bf902a7e
Merge pull request #195 from ode33/patch-1
Update README.md
2019-08-11 20:30:42 +05:30
Oliver Dechant 3bb221576c
Update README.md
broken link
2019-08-11 09:47:20 -03:00
Viral B. Shah 33c8313e0b
Create FUNDING.yml 2019-06-26 17:30:47 -04:00
Daniel Mendler 72f33a3bf9 wasm32 support (#192) 2019-04-14 15:11:03 -07:00
Jeremy Soller f24b1bfe55 Fix compilation of gcc when using openlibm as system libm (#190)
For some sad reason, gcc poisons LONG_DOUBLE in sreal.c. The identifier has been changed to OLM_LONG_DOUBLE.
2019-01-14 11:53:14 -08:00
Viral B. Shah 0f22aeb0a9 Create CNAME 2018-12-22 17:40:45 -05:00
Viral B. Shah c68e7d2f1f Delete CNAME 2018-12-22 17:40:07 -05:00
Viral B. Shah b524581774 Rename doc -> docs 2018-12-22 17:28:59 -05:00
Viral B. Shah ebbba438ae Move website to doc/ on master instead of gh-pages branch 2018-12-22 17:27:26 -05:00
sharkcz 4e3d70965d update ULPs for s390 (#187) 2018-11-12 12:04:56 -08:00
Viral B. Shah 65d7406056
Merge pull request #185 from sharkcz/s390x
Add s390(x) port
2018-11-07 10:13:56 -05:00
Dan Horák 2a1e56858a s390(x) port 2018-11-07 12:11:15 +01:00
Viral B. Shah cca41bc1ab Merge branch 'master' of github.com:JuliaMath/openlibm 2018-06-18 18:14:22 -04:00
Viral B. Shah 74b54c71f7 Add MIPS 2018-06-18 18:13:49 -04:00
Alex Arslan ce69bf1f32
Update references to JuliaLang to point to JuliaMath (#182) 2018-06-18 14:48:23 -07:00
110 changed files with 1922 additions and 177 deletions

1
.github/FUNDING.yml vendored Normal file
View File

@ -0,0 +1 @@
github: [JuliaLang]

4
.gitignore vendored
View File

@ -5,3 +5,7 @@
*.so*
*.dylib*
*.pc
# GiteaPC config files
giteapc-config-*.make
giteapc-config.make

View File

@ -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

View File

@ -6,39 +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.6.0
SOMAJOR = 2
SOMINOR = 5
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
ifneq (,$(findstring $(OS),Darwin FreeBSD OpenBSD))
USEGCC = 0
USECLANG = 1
USEGCC ?= 0
USECLANG ?= 1
endif
AR = $(TOOLPREFIX)ar
ifeq ($(ARCH),wasm32)
USECLANG = 1
TOOLPREFIX = llvm-
endif
AR ?= $(TOOLPREFIX)ar
ifeq ($(USECLANG),1)
USEGCC = 0
USEGCC ?= 0
CC = clang
CFLAGS_add += -fno-builtin -fno-strict-aliasing
endif
ifeq ($(USEGCC),1)
CC = $(TOOLPREFIX)gcc
CC ?= $(TOOLPREFIX)gcc
CFLAGS_add += -fno-gnu89-inline -fno-builtin
endif
@ -49,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
@ -60,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
@ -94,7 +105,9 @@ else
SHLIB_EXT = so
SONAME_FLAG = -soname
endif
ifneq ($(ARCH),sh3eb)
CFLAGS_add += -fPIC
endif
shlibdir = $(libdir)
endif
@ -115,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
@ -131,6 +152,16 @@ CFLAGS_add += -I$(OPENLIBM_HOME)/ld128
endif
endif
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 $@

View File

@ -2,6 +2,7 @@ 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
@ -11,6 +12,7 @@ SUBDIRS += ld128
else
endif
endif
endif
define INC_template
TEST=test
@ -49,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
@ -72,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 mips/*.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
@ -85,6 +93,9 @@ install-static: libopenlibm.a
mkdir -p $(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 -RpP -f libopenlibm.*$(SHLIB_EXT)* $(DESTDIR)$(shlibdir)/
@ -98,4 +109,15 @@ install-headers:
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
View File

@ -0,0 +1,38 @@
# OpenLibm
[![Travis](https://travis-ci.org/JuliaMath/openlibm.svg?branch=master)](https://travis-ci.org/JuliaMath/openlibm)
[![AppVeyor](https://ci.appveyor.com/api/projects/status/sia04r4089rr19uc/branch/master?svg=true)](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.

View File

@ -1,37 +1,60 @@
# OpenLibm
# Soft-FP sh3eb port of OpenLibm
[![Travis](https://travis-ci.org/JuliaLang/openlibm.svg?branch=master)](https://travis-ci.org/JuliaLang/openlibm)
[![AppVeyor](https://ci.appveyor.com/api/projects/status/30kn644g79f0x6va/branch/master?svg=true)](https://ci.appveyor.com/project/ararslan/openlibm/branch/master)
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 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. 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.
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).

View File

@ -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__

View File

@ -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
View File

@ -0,0 +1 @@
openlibm.org

BIN
docs/images/arrow-down.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 216 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 357 B

93
docs/index.html Normal file
View 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>

View 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
View 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."}

View 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
View 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
View 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
View 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_

View File

@ -12,6 +12,10 @@
#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

View File

@ -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

View 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_ */

View 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_ */

View File

@ -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;
/*

View File

@ -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

View File

@ -26,7 +26,6 @@
* $FreeBSD$
*/
#define __fenv_static
#include <openlibm_fenv.h>
#ifdef __GNUC_GNU_INLINE__

1
s390/Make.files Normal file
View File

@ -0,0 +1 @@
$(CUR_SRCS) = fenv.c

50
s390/fenv.c Normal file
View 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
View File

@ -0,0 +1 @@
$(CUR_SRCS) = fenv.c

2
sh3eb/assert.h Normal file
View File

@ -0,0 +1,2 @@
#pragma once
#define assert(b)

7
sh3eb/ctype.h Normal file
View 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
View 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
View 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
View File

@ -0,0 +1,4 @@
#pragma once
#include <stddef.h>
void *memset(void *mem, int fill, size_t size);

View File

@ -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

View File

@ -12,33 +12,53 @@
#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)
#ifndef __warn_references
#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")
#ifndef __warn_references
#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")
@ -46,30 +66,34 @@
#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")
#ifndef __warn_references
#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")
#ifndef __warn_references
#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 */

View File

@ -107,5 +107,5 @@ __ieee754_acos(double x)
}
#if LDBL_MANT_DIG == 53
__weak_reference(acos, acosl);
openlibm_weak_reference(acos, acosl);
#endif

View File

@ -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

View File

@ -113,5 +113,5 @@ __ieee754_asin(double x)
}
#if LDBL_MANT_DIG == 53
__weak_reference(asin, asinl);
openlibm_weak_reference(asin, asinl);
#endif

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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;

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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);

View File

@ -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

View File

@ -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

View File

@ -189,7 +189,7 @@ __ieee754_sqrt(double x)
}
#if (LDBL_MANT_DIG == 53)
__weak_reference(sqrt, sqrtl);
openlibm_weak_reference(sqrt, sqrtl);
#endif
/*

View File

@ -41,6 +41,10 @@
#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. */

View File

@ -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_ */

51
src/s390_fpmath.h Normal file
View 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)

View File

@ -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

View File

@ -120,5 +120,5 @@ atan(double x)
}
#if LDBL_MANT_DIG == 53
__weak_reference(atan, atanl);
openlibm_weak_reference(atan, atanl);
#endif

View File

@ -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 */

View File

@ -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 */

View File

@ -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 */

View File

@ -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 */

View File

@ -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 */

View File

@ -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 */

View File

@ -114,5 +114,5 @@ cbrt(double x)
}
#if (LDBL_MANT_DIG == 53)
__weak_reference(cbrt, cbrtl);
openlibm_weak_reference(cbrt, cbrtl);
#endif

View File

@ -73,5 +73,5 @@ ceil(double x)
}
#if LDBL_MANT_DIG == 53
__weak_reference(ceil, ceill);
openlibm_weak_reference(ceil, ceill);
#endif

View File

@ -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 */

View File

@ -85,5 +85,5 @@ cos(double x)
}
#if (LDBL_MANT_DIG == 53)
__weak_reference(cos, cosl);
openlibm_weak_reference(cos, cosl);
#endif

View File

@ -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 */

View File

@ -43,5 +43,5 @@ cproj(double complex z)
}
#if LDBL_MANT_DIG == 53
__weak_reference(cproj, cprojl);
openlibm_weak_reference(cproj, cprojl);
#endif

View File

@ -110,5 +110,5 @@ csqrt(double complex z)
}
#if LDBL_MANT_DIG == 53
__weak_reference(csqrt, csqrtl);
openlibm_weak_reference(csqrt, csqrtl);
#endif

View File

@ -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

View File

@ -392,5 +392,5 @@ exp2(double x)
}
#if (LDBL_MANT_DIG == 53)
__weak_reference(exp2, exp2l);
openlibm_weak_reference(exp2, exp2l);
#endif

View File

@ -215,3 +215,7 @@ expm1(double x)
}
return y;
}
#if (LDBL_MANT_DIG == 53)
openlibm_weak_reference(expm1, expm1l);
#endif

View File

@ -43,4 +43,6 @@ fn(type x, type y) \
DECL(double, fdim)
DECL(float, fdimf)
#ifdef OLM_LONG_DOUBLE
DECL(long double, fdiml)
#endif

View File

@ -74,5 +74,5 @@ floor(double x)
}
#if LDBL_MANT_DIG == 53
__weak_reference(floor, floorl);
openlibm_weak_reference(floor, floorl);
#endif

View File

@ -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

View File

@ -72,7 +72,7 @@ __fpclassifyf(float f)
}
}
#ifdef LONG_DOUBLE
#ifdef OLM_LONG_DOUBLE
OLM_DLLEXPORT int
__fpclassifyl(long double e)
{

View File

@ -52,5 +52,5 @@ frexp(double x, int *eptr)
}
#if (LDBL_MANT_DIG == 53)
__weak_reference(frexp, frexpl);
openlibm_weak_reference(frexp, frexpl);
#endif

View File

@ -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)
{

View File

@ -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);

View File

@ -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);

View File

@ -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)
{

View File

@ -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

View File

@ -45,5 +45,5 @@ logb(double x)
}
#if (LDBL_MANT_DIG == 53)
__weak_reference(logb, logbl);
openlibm_weak_reference(logb, logbl);
#endif

View File

@ -120,5 +120,5 @@ nanf(const char *s)
}
#if (LDBL_MANT_DIG == 53)
__weak_reference(nan, nanl);
openlibm_weak_reference(nan, nanl);
#endif

View File

@ -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

View File

@ -77,4 +77,4 @@ nextafterl(long double x, long double y)
return ux.e;
}
__strong_reference(nextafterl, nexttowardl);
openlibm_strong_reference(nextafterl, nexttowardl);

View File

@ -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)
{

View File

@ -154,5 +154,5 @@ fixup:
}
#if LDBL_MANT_DIG == 53
__weak_reference(remquo, remquol);
openlibm_weak_reference(remquo, remquol);
#endif

View File

@ -88,5 +88,5 @@ rint(double x)
}
#if (LDBL_MANT_DIG == 53)
__weak_reference(rint, rintl);
openlibm_weak_reference(rint, rintl);
#endif

View File

@ -62,6 +62,7 @@ scalblnf (float x, long n)
return (scalbnf(x, in));
}
#ifdef OLM_LONG_DOUBLE
OLM_DLLEXPORT long double
scalblnl (long double x, long n)
{
@ -76,3 +77,4 @@ scalblnl (long double x, long n)
}
return (scalbnl(x, (int)n));
}
#endif

View File

@ -59,8 +59,8 @@ scalbn (double x, int n)
}
#if (LDBL_MANT_DIG == 53)
__weak_reference(scalbn, ldexpl);
__weak_reference(scalbn, scalbnl);
openlibm_weak_reference(scalbn, ldexpl);
openlibm_weak_reference(scalbn, scalbnl);
#endif
__strong_reference(scalbn, ldexp);
openlibm_strong_reference(scalbn, ldexp);

View File

@ -54,4 +54,4 @@ scalbnf (float x, int n)
return x*twom25;
}
__strong_reference(scalbnf, ldexpf);
openlibm_strong_reference(scalbnf, ldexpf);

View File

@ -67,4 +67,4 @@ scalbnl (long double x, int n)
return u.e*0x1p-128;
}
__strong_reference(scalbnl, ldexpl);
openlibm_strong_reference(scalbnl, ldexpl);

View File

@ -49,7 +49,7 @@ __signbitf(float f)
return (u.bits.sign);
}
#ifdef LONG_DOUBLE
#ifdef OLM_LONG_DOUBLE
OLM_DLLEXPORT int
__signbitl(long double e)
{

View File

@ -85,5 +85,5 @@ sin(double x)
}
#if (LDBL_MANT_DIG == 53)
__weak_reference(sin, sinl);
openlibm_weak_reference(sin, sinl);
#endif

View File

@ -146,5 +146,5 @@ sincos(double x, double * s, double * c)
}
#if (LDBL_MANT_DIG == 53)
__weak_reference(sincos, sincosl);
openlibm_weak_reference(sincos, sincosl);
#endif

View File

@ -79,5 +79,5 @@ tan(double x)
}
#if (LDBL_MANT_DIG == 53)
__weak_reference(tan, tanl);
openlibm_weak_reference(tan, tanl);
#endif

View File

@ -37,6 +37,7 @@
* only tanh(0)=0 is exact for finite argument.
*/
#include <float.h>
#include <openlibm_math.h>
#include "math_private.h"
@ -76,3 +77,7 @@ tanh(double x)
}
return (jx>=0)? z: -z;
}
#if (LDBL_MANT_DIG == 53)
openlibm_weak_reference(tanh, tanhl);
#endif

Some files were not shown because too many files have changed in this diff Show More