Chapter 22
FreeBSD Math Library: liboskit_freebsd_m.a

22.1 Introduction

The OSKit’s math library provides the traditional UNIX “math library” functions as required by the POSIX.1 and X/Open CAE specifications. These functions are required by a number of non-trivial applications, such as a Java or SR runtime system. The library itself is taken directly from the FreeBSD source tree (/usr/src/lib/msun), though it was developed by Sun Microsystems.

22.1.1 Architecture Dependencies

The library supports both big or little endian architectures as well as multiple standards (with respect to how exceptions are handled and reported). The OSKit library also includes the i387-optimized versions of routines that were added by FreeBSD. The OSKit version is also built for “multi-standard” support with IEEE as the default.

22.1.2 External Dependencies

The file k_standard.c requires either write to file descriptor 2 or an fputs and fflush using stderr.

22.1.3 Caveats

The OSKit math library is largely untested.

There is currently no other floating point support in the OSKit. Most importantly, there is no floating point emulation code to allow math functions to run on systems without hardware FPUs. There is also no support for “context switching” floating point state. The default setjmp and longjmp calls do not save and restore floating point registers, nor does the default exception handler. Thus, any multi-threaded floating point application using a thread package built on top of these mechanisms would not work correctly. Finally, the minimal C library contains no functions for conversion or printing of floating point numbers.

22.2 Functions

Following is a list of the functions supported by the library. Since these functions and their implementations are fully standard, they are not described in detail here; refer to the ISO C and Unix standards for more information.

acos,asin,atan,atan2:
arc cosine, sine, tangent function
acosh,asinh,atanh:
inverse hyperbolic cosine, sine, tangent functions
cbrt:
cube root function
ceil:
ceiling value function
cos,sin,tan:
cosine, sine, tangent functions
cosh,sinh,tanh:
hyperbolic cosine, sine, tangent functions
erf,erfc:
error and complementary error functions
exp,expm1:
exponential function
fabs:
absolute value function
floor:
floor value function
fmod:
floating point remainder function
frexp:
extract mantissa and exponent from double precision number
gamma,lgamma:
log gamma functions
hypot:
Euclidean distance function
ilogb:
returns exponent part of a floating point number
isnan:
test for NaN
j0,j1,jn:
Bessel functions of the first kind
ldexp:
load exponent of a floating point number
log,log1p:
natural logarithm functions
log10:
base 10 logarithm function
logb:
radix-independent exponent function
modf:
decompose floating point number
nextafter:
return next representable double-precision floating point number
pow:
power function
remainder:
floating point remainder function
rint:
round to nearest integral value
scalb:
load exponent of a radix-independent floating point number
sqrt:
square root function
y0,y1,yn:
Bessel functions of the second kind