Back to index

lightning-sunbird  0.9+nobinonly
jslibmath.h
Go to the documentation of this file.
00001 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
00002  *
00003  * ***** BEGIN LICENSE BLOCK *****
00004  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00005  *
00006  * The contents of this file are subject to the Mozilla Public License Version
00007  * 1.1 (the "License"); you may not use this file except in compliance with
00008  * the License. You may obtain a copy of the License at
00009  * http://www.mozilla.org/MPL/
00010  *
00011  * Software distributed under the License is distributed on an "AS IS" basis,
00012  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00013  * for the specific language governing rights and limitations under the
00014  * License.
00015  *
00016  * The Original Code is Mozilla Communicator client code, released
00017  * March 31, 1998.
00018  *
00019  * The Initial Developer of the Original Code is
00020  * Netscape Communications Corporation.
00021  * Portions created by the Initial Developer are Copyright (C) 1998
00022  * the Initial Developer. All Rights Reserved.
00023  *
00024  * Contributor(s):
00025  *   IBM Corp.
00026  *
00027  * Alternatively, the contents of this file may be used under the terms of
00028  * either of the GNU General Public License Version 2 or later (the "GPL"),
00029  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00030  * in which case the provisions of the GPL or the LGPL are applicable instead
00031  * of those above. If you wish to allow use of your version of this file only
00032  * under the terms of either the GPL or the LGPL, and not to allow others to
00033  * use your version of this file under the terms of the MPL, indicate your
00034  * decision by deleting the provisions above and replace them with the notice
00035  * and other provisions required by the GPL or the LGPL. If you do not delete
00036  * the provisions above, a recipient may use your version of this file under
00037  * the terms of any one of the MPL, the GPL or the LGPL.
00038  *
00039  * ***** END LICENSE BLOCK ***** */
00040 
00041 /*
00042  * By default all math calls go to fdlibm.  The defines for each platform
00043  * remap the math calls to native routines.
00044  */
00045 
00046 #ifndef _LIBMATH_H
00047 #define _LIBMATH_H
00048 
00049 #include <math.h>
00050 #include "jsconfig.h"
00051 
00052 /*
00053  * Define on which platforms to use fdlibm. Not used by default under
00054  * assumption that native math library works unless proved guilty.
00055  * Plus there can be problems with endian-ness and such in fdlibm itself.
00056  *
00057  * fdlibm compatibility notes:
00058  * - fdlibm broken on OSF1/alpha
00059  */
00060 
00061 #ifndef JS_USE_FDLIBM_MATH
00062 #define JS_USE_FDLIBM_MATH 0
00063 #endif
00064 
00065 #if !JS_USE_FDLIBM_MATH
00066 
00067 /*
00068  * Use system provided math routines.
00069  */
00070 
00071 #define fd_acos acos
00072 #define fd_asin asin
00073 #define fd_atan atan
00074 #define fd_atan2 atan2
00075 #define fd_ceil ceil
00076 
00077 /* The right copysign function is not always named the same thing. */
00078 #if __GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
00079 #define fd_copysign __builtin_copysign
00080 #elif defined WINCE
00081 #define fd_copysign _copysign
00082 #elif defined _WIN32
00083 #if _MSC_VER < 1400
00084 /* Try to work around apparent _copysign bustage in VC6 and VC7. */
00085 #define fd_copysign js_copysign
00086 extern double js_copysign(double, double);
00087 #else
00088 #define fd_copysign _copysign
00089 #endif
00090 #else
00091 #define fd_copysign copysign
00092 #endif
00093 
00094 #define fd_cos cos
00095 #define fd_exp exp
00096 #define fd_fabs fabs
00097 #define fd_floor floor
00098 #define fd_fmod fmod
00099 #define fd_log log
00100 #define fd_pow pow
00101 #define fd_sin sin
00102 #define fd_sqrt sqrt
00103 #define fd_tan tan
00104 
00105 #else
00106 
00107 /*
00108  * Use math routines in fdlibm.
00109  */
00110 
00111 #undef __P
00112 #ifdef __STDC__
00113 #define __P(p)  p
00114 #else
00115 #define __P(p)  ()
00116 #endif
00117 
00118 #if (defined _WIN32 && !defined WINCE) || defined SUNOS4
00119 
00120 #define fd_acos acos
00121 #define fd_asin asin
00122 #define fd_atan atan
00123 #define fd_cos cos
00124 #define fd_sin sin
00125 #define fd_tan tan
00126 #define fd_exp exp
00127 #define fd_log log
00128 #define fd_sqrt sqrt
00129 #define fd_ceil ceil
00130 #define fd_fabs fabs
00131 #define fd_floor floor
00132 #define fd_fmod fmod
00133 
00134 extern double fd_atan2 __P((double, double));
00135 extern double fd_copysign __P((double, double));
00136 extern double fd_pow __P((double, double));
00137 
00138 #elif defined IRIX
00139 
00140 #define fd_acos acos
00141 #define fd_asin asin
00142 #define fd_atan atan
00143 #define fd_exp exp
00144 #define fd_log log
00145 #define fd_log10 log10
00146 #define fd_sqrt sqrt
00147 #define fd_fabs fabs
00148 #define fd_floor floor
00149 #define fd_fmod fmod
00150 
00151 extern double fd_cos __P((double));
00152 extern double fd_sin __P((double));
00153 extern double fd_tan __P((double));
00154 extern double fd_atan2 __P((double, double));
00155 extern double fd_pow __P((double, double));
00156 extern double fd_ceil __P((double));
00157 extern double fd_copysign __P((double, double));
00158 
00159 #elif defined SOLARIS
00160 
00161 #define fd_atan atan
00162 #define fd_cos cos
00163 #define fd_sin sin
00164 #define fd_tan tan
00165 #define fd_exp exp
00166 #define fd_sqrt sqrt
00167 #define fd_ceil ceil
00168 #define fd_fabs fabs
00169 #define fd_floor floor
00170 #define fd_fmod fmod
00171 
00172 extern double fd_acos __P((double));
00173 extern double fd_asin __P((double));
00174 extern double fd_log __P((double));
00175 extern double fd_atan2 __P((double, double));
00176 extern double fd_pow __P((double, double));
00177 extern double fd_copysign __P((double, double));
00178 
00179 #elif defined HPUX
00180 
00181 #define fd_cos cos
00182 #define fd_sin sin
00183 #define fd_exp exp
00184 #define fd_sqrt sqrt
00185 #define fd_fabs fabs
00186 #define fd_floor floor
00187 #define fd_fmod fmod
00188 
00189 extern double fd_ceil __P((double));
00190 extern double fd_acos __P((double));
00191 extern double fd_log __P((double));
00192 extern double fd_atan2 __P((double, double));
00193 extern double fd_tan __P((double));
00194 extern double fd_pow __P((double, double));
00195 extern double fd_asin __P((double));
00196 extern double fd_atan __P((double));
00197 extern double fd_copysign __P((double, double));
00198 
00199 #elif defined(OSF1)
00200 
00201 #define fd_acos acos
00202 #define fd_asin asin
00203 #define fd_atan atan
00204 #define fd_copysign copysign
00205 #define fd_cos cos
00206 #define fd_exp exp
00207 #define fd_fabs fabs
00208 #define fd_fmod fmod
00209 #define fd_sin sin
00210 #define fd_sqrt sqrt
00211 #define fd_tan tan
00212 
00213 extern double fd_atan2 __P((double, double));
00214 extern double fd_ceil __P((double));
00215 extern double fd_floor __P((double));
00216 extern double fd_log __P((double));
00217 extern double fd_pow __P((double, double));
00218 
00219 #elif defined(AIX)
00220 
00221 #define fd_acos acos
00222 #define fd_asin asin
00223 #define fd_atan2 atan2
00224 #define fd_copysign copysign
00225 #define fd_cos cos
00226 #define fd_exp exp
00227 #define fd_fabs fabs
00228 #define fd_floor floor
00229 #define fd_fmod fmod
00230 #define fd_log log
00231 #define fd_sin sin
00232 #define fd_sqrt sqrt
00233 
00234 extern double fd_atan __P((double));
00235 extern double fd_ceil __P((double));
00236 extern double fd_pow __P((double,double));
00237 extern double fd_tan __P((double));
00238 
00239 #else /* other platform.. generic paranoid slow fdlibm */
00240 
00241 extern double fd_acos __P((double));
00242 extern double fd_asin __P((double));
00243 extern double fd_atan __P((double));
00244 extern double fd_cos __P((double));
00245 extern double fd_sin __P((double));
00246 extern double fd_tan __P((double));
00247 
00248 extern double fd_exp __P((double));
00249 extern double fd_log __P((double));
00250 extern double fd_sqrt __P((double));
00251 
00252 extern double fd_ceil __P((double));
00253 extern double fd_fabs __P((double));
00254 extern double fd_floor __P((double));
00255 extern double fd_fmod __P((double, double));
00256 
00257 extern double fd_atan2 __P((double, double));
00258 extern double fd_pow __P((double, double));
00259 extern double fd_copysign __P((double, double));
00260 
00261 #endif
00262 
00263 #endif /* JS_USE_FDLIBM_MATH */
00264 
00265 #endif /* _LIBMATH_H */
00266