jdk/src/share/native/java/lang/fdlibm/include/fdlibm.h
author michaelm
Tue, 06 Mar 2012 20:34:38 +0000
changeset 12047 320a714614e9
parent 10143 4e1c885fb4f3
child 14342 8435a30053c1
permissions -rw-r--r--
7113349: Initial changeset for Macosx port to jdk Reviewed-by: jjh, alanb, dholmes, anthony, ohrstrom, ksrini, jrose, weijun, smarks Contributed-by: Alan Bateman <alan.bateman@oracle.com>, Alexander Potochkin <alexander.potochkin@oracle.com>, Alexander Zuev <alexander.zuev@oracle.com>, Andrew Brygin <andrew.brygin@oracle.com>, Artem Ananiev <artem.ananiev@oracle.com>, Alex Strange <astrange@apple.com>, Bino George <bino@apple.com>, Christine Lu <christine.lu@oracle.com>, David Katleman <david.katleman@oracle.com>, David Durrence <david_durrence@apple.com>, Dmitry Cherepanov <dmitry.cherepanov@oracle.com>, Greg Lewis <glewis@eyesbeyond.com>, Kevin Miller <kevin_m_miller@apple.com>, Kurt Miller <kurt@intricatesoftware.com>, Landon Fuller <landonf@plausiblelabs.com>, Leonid Romanov <leonid.romanov@oracle.com>, Loefty Walkowiak <loefty@apple.com>, Mark Reinhold <mark.reinhold@oracle.com>, Naoto Sato <naoto.sato@oracle.com>, Philip Race <philip.race@oracle.com>, Roger Hoover <rhoover@apple.com>, Scott Kovatch <scott.kovatch@oracle.com>, Sergey ByloKhov <sergey.bylokhov@oracle.com>, Mike Swingler <swingler@apple.com>, Tomas Hurka <tomas.hurka@oracle.com>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
/*
8796
604a43386301 7027910: Add basic cross-compilation support and add ARM/PPC to the known architectures in the open code
dholmes
parents: 7668
diff changeset
     3
 * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4286
diff changeset
     8
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4286
diff changeset
    10
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4286
diff changeset
    22
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4286
diff changeset
    23
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4286
diff changeset
    24
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 10143
diff changeset
    27
#ifdef _ALLBSD_SOURCE
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 10143
diff changeset
    28
#include <machine/endian.h>
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 10143
diff changeset
    29
#elif __linux__
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 10143
diff changeset
    30
#define __USE_BSD 1
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 10143
diff changeset
    31
#include <endian.h>
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 10143
diff changeset
    32
#endif
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
#include "jfdlibm.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
#ifdef __NEWVALID       /* special setup for Sun test regime */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
#if defined(i386) || defined(i486) || \
8796
604a43386301 7027910: Add basic cross-compilation support and add ARM/PPC to the known architectures in the open code
dholmes
parents: 7668
diff changeset
    37
    defined(intel) || defined(x86) || defined(arm) || \
604a43386301 7027910: Add basic cross-compilation support and add ARM/PPC to the known architectures in the open code
dholmes
parents: 7668
diff changeset
    38
    defined(i86pc) || defined(_M_IA64) || defined(ia64)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
#define _LITTLE_ENDIAN
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
#ifdef _LITTLE_ENDIAN
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
#define __HI(x) *(1+(int*)&x)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
#define __LO(x) *(int*)&x
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
#define __HIp(x) *(1+(int*)x)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
#define __LOp(x) *(int*)x
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
#define __HI(x) *(int*)&x
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
#define __LO(x) *(1+(int*)&x)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
#define __HIp(x) *(int*)x
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
#define __LOp(x) *(1+(int*)x)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
6850
56966b0a6a0d 6989466: Miscellaneous compiler warnings in java/lang, java/util, java/io, sun/misc native code
alanb
parents: 5506
diff changeset
    55
#ifndef __P
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
#ifdef __STDC__
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
#define __P(p)  p
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
#define __P(p)  ()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
#endif
6850
56966b0a6a0d 6989466: Miscellaneous compiler warnings in java/lang, java/util, java/io, sun/misc native code
alanb
parents: 5506
diff changeset
    61
#endif
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 * ANSI/POSIX
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
extern int signgam;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
#define MAXFLOAT        ((float)3.40282346638528860e+38)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
enum fdversion {fdlibm_ieee = -1, fdlibm_svid, fdlibm_xopen, fdlibm_posix};
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
#define _LIB_VERSION_TYPE enum fdversion
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
#define _LIB_VERSION _fdlib_version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
/* if global variable _LIB_VERSION is not desirable, one may
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 * change the following to be a constant by:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 *      #define _LIB_VERSION_TYPE const enum version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
 * In that case, after one initializes the value _LIB_VERSION (see
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
 * s_lib_version.c) during compile time, it cannot be modified
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
 * in the middle of a program
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
extern  _LIB_VERSION_TYPE  _LIB_VERSION;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
#define _IEEE_  fdlibm_ieee
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
#define _SVID_  fdlibm_svid
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
#define _XOPEN_ fdlibm_xopen
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
#define _POSIX_ fdlibm_posix
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
struct exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
        int type;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
        char *name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        double arg1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        double arg2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        double retval;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
#define HUGE            MAXFLOAT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
 * set X_TLOSS = pi*2**52, which is possibly defined in <values.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
 * (one may replace the following line by "#include <values.h>")
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
#define X_TLOSS         1.41484755040568800000e+16
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
#define DOMAIN          1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
#define SING            2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
#define OVERFLOW        3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
#define UNDERFLOW       4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
#define TLOSS           5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
#define PLOSS           6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
 * ANSI/POSIX
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
extern double acos __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
extern double asin __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
extern double atan __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
extern double atan2 __P((double, double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
extern double cos __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
extern double sin __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
extern double tan __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
extern double cosh __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
extern double sinh __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
extern double tanh __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
extern double exp __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
extern double frexp __P((double, int *));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
extern double ldexp __P((double, int));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
extern double log __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
extern double log10 __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
extern double modf __P((double, double *));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
extern double pow __P((double, double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
extern double sqrt __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
extern double ceil __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
extern double fabs __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
extern double floor __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
extern double fmod __P((double, double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
extern double hypot __P((double, double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
extern int isnan __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
extern int finite __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
extern double atanh __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
extern double cbrt __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
extern double logb __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
extern double nextafter __P((double, double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
extern double remainder __P((double, double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
#ifdef _SCALB_INT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
extern double scalb __P((double, int));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
extern double scalb __P((double, double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
extern int matherr __P((struct exception *));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
 * IEEE Test Vector
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
extern double significand __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
 * Functions callable from C, intended to support IEEE arithmetic.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
extern double copysign __P((double, double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
extern int ilogb __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
extern double rint __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
extern double scalbn __P((double, int));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
 * BSD math library entry points
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
extern double expm1 __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
extern double log1p __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
/* ieee style elementary functions */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
extern double __ieee754_sqrt __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
extern double __ieee754_acos __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
extern double __ieee754_log __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
extern double __ieee754_atanh __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
extern double __ieee754_asin __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
extern double __ieee754_atan2 __P((double,double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
extern double __ieee754_exp __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
extern double __ieee754_cosh __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
extern double __ieee754_fmod __P((double,double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
extern double __ieee754_pow __P((double,double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
extern double __ieee754_log10 __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
extern double __ieee754_sinh __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
extern double __ieee754_hypot __P((double,double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
extern double __ieee754_remainder __P((double,double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
extern int    __ieee754_rem_pio2 __P((double,double*));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
#ifdef _SCALB_INT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
extern double __ieee754_scalb __P((double,int));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
extern double __ieee754_scalb __P((double,double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
/* fdlibm kernel function */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
extern double __kernel_standard __P((double,double,int));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
extern double __kernel_sin __P((double,double,int));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
extern double __kernel_cos __P((double,double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
extern double __kernel_tan __P((double,double,int));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
extern int    __kernel_rem_pio2 __P((double*,double*,int,int,int,const int*));