Commit Graph

89 Commits

Author SHA1 Message Date
Ed Schouten 7e5585aaca Rename openlibm.h to openlibm_math.h.
This is a bit more consistent with the naming of the other header files
(openlibm_complex.h and openlibm_fenv.h). Re-add an openlibm.h header
that includes all of the public headers as a shorthand.

Fix up all of the source files to include <openlibm_math.h> instead of
<openlibm.h>. While there, fix ordering of the includes.
2015-01-11 23:37:01 +01:00
Ed Schouten c2154fd3f3 Add missing void keyword to keep -Wold-style-definition happy. 2015-01-11 23:01:49 +01:00
Ed Schouten bc3f903bc2 Move public headers into include/ and private headers into src/.
While there, also modify the install target. We should make sure to
install all openlibm*.h headers. There is still some work to be done:
openlibm_fenv_*.h still depends on some additional bits. I'd propose
that we eventually create an include/openlibm_cdefs.h that contains all
of the macros we need.
2015-01-11 16:35:32 +01:00
Ed Schouten 23b8f663d4 Revert "Don't use __weak_reference() when a __strong_reference() is needed."
Unlike the __weak_reference() macro, __strong_reference() does type
checking. It can only create the reference if the type of the source and
the destination function match exactly.

Even if double == long double in practice, they remain unequal at the
language level.
2015-01-10 19:24:06 +01:00
Ed Schouten d07820351b Rename the fenv headers.
I guess the idea would be to eventually also install all of the
openlibm*.h headers, instead of just openlibm.h. Make openlibm_fenv.h
suitable for this purpose by moving all of the $ARCH/fenv.h headers next
to it.

We actually need this change to make OPENLIBM_USE_HOST_FENV_H work.
Right now it's still broken, because the "#include <fenv.h>" performed
by openlibm_fenv.h still pulls in $ARCH/fenv.h as $ARCH/ is added to the
compiler include path.
2015-01-10 10:21:57 +01:00
Ed Schouten 9ab9db387d Don't use __weak_reference() when a __strong_reference() is needed.
OpenLibm uses the __weak_reference() macro for platforms where double
and long double use the same layout. That way functions only need to be
provided by the library once. The point is, in this specific case we
want to use strong references; not weak references.

Strong references can be used to give a symbol a second name. If you
look at the resulting object file, you will have two symbols with the
same offset and size. Weak references are different, in the sense that
they are marked in such a way that they act as fallbacks. They are only
used if an explicitly matching symbol is missing.
2015-01-10 10:04:11 +01:00
Ed Schouten c253db68ca Add a new compilation flag: OPENLIBM_ONLY_THREAD_SAFE.
The global signgam variable is only part of the X/Open System
Interfaces. It is not part of the POSIX base definitions nor the C
standard.

I'd rather have it disabled for my specific use-case, so introduce a new
compilation flag that we can use to disable it.
2015-01-10 09:57:33 +01:00
Ed Schouten 9fdc4f9d9e Fix a small number of -Wmissing-prototypes compiler warnings in sincos().
- Add missing prototypes to openlibm.h for sincos() and sincosf().
- Mark the internal kernel functions static.
2015-01-10 09:44:31 +01:00
Ed Schouten 06dbb6e72b Use more uniform style of including headers.
Put external headers before internal ones. While there, replace a lot of
occurences of "openlibm.h" with <openlibm.h>. It should be thought of as
an external header, as it is installed along with the library.
2015-01-09 14:24:24 +01:00
Ed Schouten f6b045b4cd Add bits to openlibm headers to switch between using the host headers. 2015-01-09 14:11:11 +01:00
Ed Schouten 410e6ebb59 Move CMPLX() into <openlibm_complex.h>, as it is normally part of <complex.h>.
While there, make CMPLX() work with Clang by using compound literals.
Now that cimag*() uses __imag__, we can also just inline the unions.
There is no need for the separate types anymore.

Also just define CMPLX() unconditionally now, as we no longer pull in
the host's <complex.h>.
2015-01-09 14:04:44 +01:00
Ed Schouten a249c5ebb3 Simply use __imag__ to implement cimag().
We already use this construct in cabs() to call hypot(), so I guess we
can assume our targeted compilers support this construct.
2015-01-09 13:40:29 +01:00
Ed Schouten 08dbb2b517 Never include <complex.h>. Include <openlibm_complex.h> instead.
If we ship with a separate copy of <complex.h>, we should also use this
one instead of the one provided by the system.
2015-01-09 13:30:44 +01:00
Ed Schouten 17688c4487 Rename include/fenv.h to <openlibm_fenv.h>.
OpenLibm has an implementation of fenv.h internally. This may be
problematic in case you want it to build against the host system's
implementation, as it would require you to somehow take the fenv.h file
out of the compiler search path.

Simply use a different naming scheme, similar to openlibm.h and
openlibm_complex.h. If we want to build against the host's fenv.h, we
can simply add an '#include <fenv.h>' from within this header.
2015-01-09 13:11:12 +01:00
Viral B. Shah f5377fda83 Merge pull request #75 from NuxiNL/signgam
Clean up handling of signgam
2015-01-08 18:58:31 +05:30
Ed Schouten 5d6cb09b96 Change existing code to use CMPLX*() instead of cpack*() where possible.
I am currently working on building openlibm against stock copies of
<math.h>, instead of the openlibm.h header. It seems that a C compliant
<math.h> header can be used as a drop-in replacement for openlibm.h,
with the exception that it lacks cpack*().

In FreeBSD SVN r275819 I patched up the math library by replacing
cpack*() by CMPLX*(). That way many functions become less tied to the
intrinsics of the math library. Make the same change to openlibm.
2015-01-08 12:02:56 +01:00
Ed Schouten 55ac462808 Add lgammal_r().
We already provide lgammaf_r() and lgamma_r(). It's not hard to also add
lgammal_r(), for consistency.

I am currently working on porting openlibm to an environment where
global state, and thus signgam, is not available. By adding lgammal_r(),
I can trivially disable support for signgam by just patching up
src/e_lgamma{f,,l}.c. That way there is no need to patch up the actual
algorithms.
2015-01-08 11:23:28 +01:00
Ed Schouten 24cec16fcc Remove references to _DECLARE_C99_LDBL_MATH.
When building openlibm with Clang, I seem to get a lot of warnings in
ld80/ related to some prototypes for long double functions that are
missing. This seems to be because we don't define _DECLARE_C99_LDBL_MATH
anywhere.

It seems that this definition only existed on FreeBSD, as certain C99
math functions were not present yet. The prototypes were simply there as
placeholders. This flag has been removed upstream (FreeBSD SVN r236148).
2015-01-08 11:07:03 +01:00
Ed Schouten f9fd21c96f Don't define __ISO_C_VISIBLE unconditionally.
__ISO_C_VISIBLE is already defined on FreeBSD. By default, it has a
value of 2011. This causes a lot of compiler warnings.
2015-01-07 22:20:56 +01:00
Ed Schouten f835657bd8 Remove checks against header guards.
It seems that this header conditionally tests whether <complex.h> is
included, as the 'complex' keyword is otherwise not available. This
version of math_private.h includes <complex.h> unconditionally, so there
is no need to test against this.
2015-01-07 22:11:36 +01:00
Ed Schouten 71f60ec632 Prevent the use of deprecated or internal functions if possible.
The finite() function has been superseded by isfinite(). There is also
no need to use scalb(), as the exponent is also an integer value. We can
simply use scalbn().

There is also no need to use __isnanf(). The values passed are
guaranteed to be of type float, meaning we can safely use the standard
isnan().
2015-01-07 22:07:48 +01:00
Thomas Leonard 9c1af7f81e Don't build complex long double functions on ARM
ARM doesn't have long doubles.
2015-01-05 11:36:43 +00:00
Viral B. Shah d8c909a980 Add all the complex declarations to openlibm.h. 2014-12-05 00:37:39 +05:30
Viral B. Shah b7da33c990 Replace math.h with openlibm.h in the new complex math functions. 2014-12-05 00:29:54 +05:30
Viral B. Shah 9b7fb281fa Update Make.files 2014-12-05 00:24:55 +05:30
Viral B. Shah da782e78d9 Add various complex math routines from OpenBSD. 2014-12-05 00:13:36 +05:30
Viral B. Shah 9ecf223fc1 Get the ld80 routines from OpenBSD to build on mac and linux.
Bump version number and SO major version, since we have
introduced new long double APIs.
2014-12-04 23:56:11 +05:30
Viral B. Shah 8b3b520675 Fix #35 2014-12-04 21:41:37 +05:30
Viral B. Shah 2c9b14cabd Merge pull request #67 from eschnett/master
Simplify code, avoid compiler warnings
2014-12-02 09:50:49 +05:30
Thomas Leonard 4cb9231f1a Removed some uses of sys/types.h
It's useful to be able to compile openlibm in environments where this
doesn't exist (e.g. OS kernels).
2014-12-01 11:10:41 +00:00
Erik Schnetter 2b7040952e Add assert statements 2014-09-22 16:18:53 -04:00
Erik Schnetter 9c8e061ab1 Add comments describing valid argument range for internal functions 2014-09-22 16:01:47 -04:00
Erik Schnetter ca3aaa3a82 Remove trailing whitespace in makefile 2014-09-19 11:48:43 -04:00
Erik Schnetter e2138aed2e Avoid compiler warnings 2014-09-19 11:48:34 -04:00
Erik Schnetter c1a08f02af Simplify code, avoid compiler warnings 2014-09-19 11:36:33 -04:00
Viral B. Shah 4a70b227d4 Do not export rem_pio2 from openlibm. It will be exported from openspecfun. 2014-07-09 19:56:28 -04:00
Viral B. Shah 08f66bcea4 Revert "You can't have you cake and eat it, too."
This reverts commit 10fed4ae49.
2014-06-12 15:56:39 +05:30
Viral B. Shah f9cc2db46e Merge pull request #40 from weshatheleopard/patch-1
You can't have you cake and eat it, too.
2014-06-12 12:55:53 +05:30
Elliot Saba e9d02ee729 Fix compilation by including cdefs-compat.h in math_private.h
Also fix redefinition of __pure2
2014-06-05 22:08:41 -07:00
Thomas Leonard f22d7db106 Fixed build on ARM
Removed all long double support, since ARM doesn't have long doubles.
2014-05-26 10:55:49 +01:00
Thomas Leonard 15fa3252fc Merge noinc branch 2014-05-19 15:29:33 +01:00
Milan Bouchet-Valat 5a0e3e9c5c Fix missing includes
Last commit made defition of cpack() not available to files
which do not include openlibm.h.
2014-03-30 22:53:05 +02:00
Milan Bouchet-Valat 3e769e48b8 Move complex number declarations to openlibm.h
These are used by openspecfun, thus they need to be available
from public headers.
2014-03-29 11:24:31 +01:00
Jameson Nash 66e6f8ea91 normalize __WIN32__ to _WIN32, which is defined by all Windows compilers 2014-03-18 20:47:48 -04:00
Elliot Saba 7065fdf6c5 Remove {cdefs,types}-compat.h from openlibm.h 2014-02-08 21:35:14 -08:00
weshatheleopard 10fed4ae49 You can't have you cake and eat it, too.
If you declare zero=0.0, then USE it.
2014-01-31 16:34:46 -06:00
Jeff Bezanson 9ca11f20c6 updates to s_round.c from FreeBSD 2013-12-19 17:52:23 -05:00
Jeff Bezanson 3566e32d84 new polynomials for erff, by Steve Kargl
these are both faster and more accurate

see http://svnweb.freebsd.org/base/head/lib/msun/src/s_erff.c?view=log
2013-12-19 14:06:05 -05:00
Jeff Bezanson 89d232d114 more accurate comment for the x==1.0 hack 2013-12-14 15:49:02 -05:00
Jeff Bezanson 9bc257a323 special-case more accurate answer for exp(1.0) 2013-12-12 16:42:05 -05:00