src/java.base/share/native/libfdlibm/fdlibm.h
author igerasim
Wed, 21 Aug 2019 13:49:16 -0700
changeset 57826 bf4c808a4488
parent 47216 71c04702a3d5
permissions -rw-r--r--
8211360: Change #if DEF to #if defined(DEF) Reviewed-by: bpb, vtewari
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
57826
bf4c808a4488 8211360: Change #if DEF to #if defined(DEF)
igerasim
parents: 47216
diff changeset
     2
 * Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * 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
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4286
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4286
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4286
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4286
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 10143
diff changeset
    26
#ifdef _ALLBSD_SOURCE
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 10143
diff changeset
    27
#include <machine/endian.h>
57826
bf4c808a4488 8211360: Change #if DEF to #if defined(DEF)
igerasim
parents: 47216
diff changeset
    28
#elif defined(__linux__)
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 10143
diff changeset
    29
#define __USE_BSD 1
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 10143
diff changeset
    30
#include <endian.h>
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 10143
diff changeset
    31
#endif
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
#include "jfdlibm.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
#ifdef __NEWVALID       /* special setup for Sun test regime */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
#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
    36
    defined(intel) || defined(x86) || defined(arm) || \
46870
942b678b7869 8166748: Clean out Windows IA64 support
gtriantafill
parents: 39759
diff changeset
    37
    defined(i86pc) || defined(ia64)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
#define _LITTLE_ENDIAN
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
#ifdef _LITTLE_ENDIAN
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
#define __HI(x) *(1+(int*)&x)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
#define __LO(x) *(int*)&x
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
#define __HIp(x) *(1+(int*)x)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
#define __LOp(x) *(int*)x
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
#define __HI(x) *(int*)&x
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
#define __LO(x) *(1+(int*)&x)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
#define __HIp(x) *(int*)x
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
#define __LOp(x) *(1+(int*)x)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
6850
56966b0a6a0d 6989466: Miscellaneous compiler warnings in java/lang, java/util, java/io, sun/misc native code
alanb
parents: 5506
diff changeset
    54
#ifndef __P
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
#ifdef __STDC__
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
#define __P(p)  p
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
#define __P(p)  ()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
#endif
6850
56966b0a6a0d 6989466: Miscellaneous compiler warnings in java/lang, java/util, java/io, sun/misc native code
alanb
parents: 5506
diff changeset
    60
#endif
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * ANSI/POSIX
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
extern int signgam;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
#define MAXFLOAT        ((float)3.40282346638528860e+38)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
enum fdversion {fdlibm_ieee = -1, fdlibm_svid, fdlibm_xopen, fdlibm_posix};
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
#define _LIB_VERSION_TYPE enum fdversion
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
#define _LIB_VERSION _fdlib_version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
/* if global variable _LIB_VERSION is not desirable, one may
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 * change the following to be a constant by:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 *      #define _LIB_VERSION_TYPE const enum version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 * In that case, after one initializes the value _LIB_VERSION (see
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
 * s_lib_version.c) during compile time, it cannot be modified
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
 * in the middle of a program
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
extern  _LIB_VERSION_TYPE  _LIB_VERSION;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
#define _IEEE_  fdlibm_ieee
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
#define _SVID_  fdlibm_svid
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
#define _XOPEN_ fdlibm_xopen
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
#define _POSIX_ fdlibm_posix
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
struct exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        int type;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
        char *name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
        double arg1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        double arg2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        double retval;
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 HUGE            MAXFLOAT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
 * set X_TLOSS = pi*2**52, which is possibly defined in <values.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
 * (one may replace the following line by "#include <values.h>")
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
#define X_TLOSS         1.41484755040568800000e+16
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
#define DOMAIN          1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
#define SING            2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
#define OVERFLOW        3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
#define UNDERFLOW       4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
#define TLOSS           5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
#define PLOSS           6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
 * ANSI/POSIX
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
extern double acos __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
extern double asin __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
extern double atan __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
extern double atan2 __P((double, double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
extern double cos __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
extern double sin __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
extern double tan __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
extern double cosh __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
extern double sinh __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
extern double tanh __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
extern double exp __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
extern double frexp __P((double, int *));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
extern double ldexp __P((double, int));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
extern double log __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
extern double log10 __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
extern double modf __P((double, double *));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
extern double sqrt __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
extern double ceil __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
extern double fabs __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
extern double floor __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
extern double fmod __P((double, double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
extern double hypot __P((double, double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
extern int isnan __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
extern int finite __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
extern double atanh __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
extern double cbrt __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
extern double logb __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
extern double nextafter __P((double, double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
extern double remainder __P((double, double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
#ifdef _SCALB_INT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
extern double scalb __P((double, int));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
extern double scalb __P((double, double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
extern int matherr __P((struct exception *));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
 * IEEE Test Vector
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
extern double significand __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
 * Functions callable from C, intended to support IEEE arithmetic.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
extern double copysign __P((double, double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
extern int ilogb __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
extern double rint __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
extern double scalbn __P((double, int));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
 * BSD math library entry points
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
extern double expm1 __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
extern double log1p __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
/* ieee style elementary functions */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
extern double __ieee754_sqrt __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
extern double __ieee754_acos __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
extern double __ieee754_log __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
extern double __ieee754_atanh __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
extern double __ieee754_asin __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
extern double __ieee754_atan2 __P((double,double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
extern double __ieee754_exp __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
extern double __ieee754_cosh __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
extern double __ieee754_fmod __P((double,double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
extern double __ieee754_log10 __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
extern double __ieee754_sinh __P((double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
extern double __ieee754_hypot __P((double,double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
extern double __ieee754_remainder __P((double,double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
extern int    __ieee754_rem_pio2 __P((double,double*));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
#ifdef _SCALB_INT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
extern double __ieee754_scalb __P((double,int));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
extern double __ieee754_scalb __P((double,double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
/* fdlibm kernel function */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
extern double __kernel_standard __P((double,double,int));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
extern double __kernel_sin __P((double,double,int));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
extern double __kernel_cos __P((double,double));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
extern double __kernel_tan __P((double,double,int));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
extern int    __kernel_rem_pio2 __P((double*,double*,int,int,int,const int*));