jdk/src/share/native/java/lang/fdlibm/include/fdlibm.h
author gbenson
Mon, 23 Nov 2009 10:04:47 +0000
changeset 4286 ac64f44f4d19
parent 2 90ce3da70b43
child 5506 202f599c92aa
permissions -rw-r--r--
6903453: Zero build on ARM and IA-64 Summary: Correctly set uname on ARM, and correctly build fdlibm on IA-64 Reviewed-by: ohair
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
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * Copyright 1998-2002 Sun Microsystems, Inc.  All Rights Reserved.
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 * by Sun in the LICENSE file that accompanied this code.
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
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
#include "jfdlibm.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
#ifdef __NEWVALID       /* special setup for Sun test regime */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
#if defined(i386) || defined(i486) || \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
        defined(intel) || defined(x86) || \
4286
ac64f44f4d19 6903453: Zero build on ARM and IA-64
gbenson
parents: 2
diff changeset
    32
        defined(i86pc) || defined(_M_IA64) || defined(ia64)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
#define _LITTLE_ENDIAN
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
#ifdef _LITTLE_ENDIAN
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
#define __HI(x) *(1+(int*)&x)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
#define __LO(x) *(int*)&x
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
#define __HIp(x) *(1+(int*)x)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
#define __LOp(x) *(int*)x
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
#define __HI(x) *(int*)&x
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
#define __LO(x) *(1+(int*)&x)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
#define __HIp(x) *(int*)x
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
#define __LOp(x) *(1+(int*)x)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
#ifdef __STDC__
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
#define __P(p)  p
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
#define __P(p)  ()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * ANSI/POSIX
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
extern int signgam;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
#define MAXFLOAT        ((float)3.40282346638528860e+38)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
enum fdversion {fdlibm_ieee = -1, fdlibm_svid, fdlibm_xopen, fdlibm_posix};
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
#define _LIB_VERSION_TYPE enum fdversion
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
#define _LIB_VERSION _fdlib_version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
/* if global variable _LIB_VERSION is not desirable, one may
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 * change the following to be a constant by:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 *      #define _LIB_VERSION_TYPE const enum version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 * In that case, after one initializes the value _LIB_VERSION (see
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 * s_lib_version.c) during compile time, it cannot be modified
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 * in the middle of a program
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
extern  _LIB_VERSION_TYPE  _LIB_VERSION;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
#define _IEEE_  fdlibm_ieee
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
#define _SVID_  fdlibm_svid
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
#define _XOPEN_ fdlibm_xopen
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
#define _POSIX_ fdlibm_posix
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
struct exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
        int type;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
        char *name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
        double arg1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
        double arg2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        double retval;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
#define HUGE            MAXFLOAT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
 * set X_TLOSS = pi*2**52, which is possibly defined in <values.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
 * (one may replace the following line by "#include <values.h>")
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
#define X_TLOSS         1.41484755040568800000e+16
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
#define DOMAIN          1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
#define SING            2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
#define OVERFLOW        3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
#define UNDERFLOW       4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
#define TLOSS           5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
#define PLOSS           6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
 * ANSI/POSIX
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
extern double acos __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
extern double asin __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
extern double atan __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
extern double atan2 __P((double, double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
extern double cos __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
extern double sin __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
extern double tan __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
extern double cosh __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
extern double sinh __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
extern double tanh __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
extern double exp __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
extern double frexp __P((double, int *));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
extern double ldexp __P((double, int));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
extern double log __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
extern double log10 __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
extern double modf __P((double, double *));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
extern double pow __P((double, double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
extern double sqrt __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
extern double ceil __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
extern double fabs __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
extern double floor __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
extern double fmod __P((double, double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
extern double erf __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
extern double erfc __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
extern double gamma __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
extern double hypot __P((double, double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
extern int isnan __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
extern int finite __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
extern double j0 __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
extern double j1 __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
extern double jn __P((int, double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
extern double lgamma __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
extern double y0 __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
extern double y1 __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
extern double yn __P((int, double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
extern double acosh __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
extern double asinh __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
extern double atanh __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
extern double cbrt __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
extern double logb __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
extern double nextafter __P((double, double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
extern double remainder __P((double, double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
#ifdef _SCALB_INT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
extern double scalb __P((double, int));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
extern double scalb __P((double, double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
extern int matherr __P((struct exception *));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
 * IEEE Test Vector
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
extern double significand __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
 * Functions callable from C, intended to support IEEE arithmetic.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
extern double copysign __P((double, double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
extern int ilogb __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
extern double rint __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
extern double scalbn __P((double, int));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
 * BSD math library entry points
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
extern double expm1 __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
extern double log1p __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
 * Reentrant version of gamma & lgamma; passes signgam back by reference
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
 * as the second argument; user must allocate space for signgam.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
#ifdef _REENTRANT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
extern double gamma_r __P((double, int *));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
extern double lgamma_r __P((double, int *));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
#endif  /* _REENTRANT */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
/* ieee style elementary functions */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
extern double __ieee754_sqrt __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
extern double __ieee754_acos __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
extern double __ieee754_acosh __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
extern double __ieee754_log __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
extern double __ieee754_atanh __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
extern double __ieee754_asin __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
extern double __ieee754_atan2 __P((double,double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
extern double __ieee754_exp __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
extern double __ieee754_cosh __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
extern double __ieee754_fmod __P((double,double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
extern double __ieee754_pow __P((double,double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
extern double __ieee754_lgamma_r __P((double,int *));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
extern double __ieee754_gamma_r __P((double,int *));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
extern double __ieee754_lgamma __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
extern double __ieee754_gamma __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
extern double __ieee754_log10 __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
extern double __ieee754_sinh __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
extern double __ieee754_hypot __P((double,double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
extern double __ieee754_j0 __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
extern double __ieee754_j1 __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
extern double __ieee754_y0 __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
extern double __ieee754_y1 __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
extern double __ieee754_jn __P((int,double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
extern double __ieee754_yn __P((int,double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
extern double __ieee754_remainder __P((double,double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
extern int    __ieee754_rem_pio2 __P((double,double*));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
#ifdef _SCALB_INT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
extern double __ieee754_scalb __P((double,int));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
extern double __ieee754_scalb __P((double,double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
/* fdlibm kernel function */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
extern double __kernel_standard __P((double,double,int));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
extern double __kernel_sin __P((double,double,int));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
extern double __kernel_cos __P((double,double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
extern double __kernel_tan __P((double,double,int));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
extern int    __kernel_rem_pio2 __P((double*,double*,int,int,int,const int*));