Added streflop (standalone reproducible floating point library) layer to mega-glest (initial checkin only) and changed a few areas to use the library in linux

This commit is contained in:
Mark Vejvoda
2010-04-24 03:57:38 +00:00
parent a50b89e9cc
commit 2bfaa4d1d7
129 changed files with 15486 additions and 79 deletions

View File

@@ -0,0 +1,19 @@
This directory contains (in addition to this file):
- flt-32/ dbl-64/ ldbl-96/ headers/: These subdirectories are imported from the GNU libm automatically. Do not modify them manually. You may safely erase them and run the import.pl script again. The "clean-import" make target does just that.
- import.pl: A perl script that takes as argument the location of a valid glibc-2.4 source directory. It will create the aforementioned subdirectories and convert the original libm files. The conversion mainly concerns removing external dependencies, and making the c files and constructs compilable with the streflop wrapper types. See the import.pl script itself for the full list of modifications.
- Makefile: Instructions for compiling the subdirectories with the make command. You you re-use this as the basis for other build systems (like CMake, scons, etc.).
- streflop_libm_bridge.h: Contains the definitions and other macros that are necessary to compile libm, in a streflop framework. These declarations were either done by external files, or by other parts of the glibc that were not imported.
- e_expf.c: The float exp in e_expf.c uses doubles internally since revision 1.2 in the libm-ieee754 CVS attic! This is the slower, but purely float version, that is rolled back from the CVS attic.
- w_expf.c: A wrapper to expf that replaces the libm wrapper by a wraper to the float only version.
- (after compilation): flt-target dbl-target ldbl-target temporary files for the make process
The original GNU libm is released under the GNU LGPL license, and so are these modifications. See the LGPL.txt in the parent streflop main directory. See also the comments at the beginning of each file for particular information, especially the Sun Microsystems disclaimer.
If you import a version of glibc other than 2.4, please check the information there (in particular their LICENSES file) for potential inclusion of new files in the libm subdirectories that are used here.

View File

@@ -0,0 +1,5 @@
# Makefile automatically generated by import.pl
include ../../Makefile.common
CPPFLAGS += -I../headers -DLIBM_COMPILING_FLT32=1
all: e_acosf.o e_acoshf.o e_asinf.o e_atan2f.o e_atanhf.o e_coshf.o e_exp2f.o e_expf.o e_fmodf.o e_gammaf_r.o e_hypotf.o e_j0f.o e_j1f.o e_jnf.o e_lgammaf_r.o e_log10f.o e_log2f.o e_logf.o e_powf.o e_rem_pio2f.o e_remainderf.o e_sinhf.o e_sqrtf.o k_cosf.o k_rem_pio2f.o k_sinf.o k_tanf.o s_asinhf.o s_atanf.o s_cbrtf.o s_ceilf.o s_copysignf.o s_cosf.o s_erff.o s_expm1f.o s_fabsf.o s_finitef.o s_floorf.o s_fpclassifyf.o s_frexpf.o s_ilogbf.o s_isinff.o s_isnanf.o s_ldexpf.o s_llrintf.o s_llroundf.o s_log1pf.o s_logbf.o s_lrintf.o s_lroundf.o s_modff.o s_nearbyintf.o s_nextafterf.o s_remquof.o s_rintf.o s_roundf.o s_scalblnf.o s_scalbnf.o s_signbitf.o s_sincosf.o s_sinf.o s_tanf.o s_tanhf.o s_truncf.o w_expf.o
echo 'flt-32 done!'

View File

@@ -0,0 +1,355 @@
/* See the import.pl script for potential modifications */
/* Accurate tables for exp2f().
Copyright (C) 1998 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Geoffrey Keating <geoffk@ozemail.com.au>
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1f of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
/* This table has the property that, for all integers -128 <= i <= 127,
exp(i/256.0f + __exp2f_deltatable[i-128]) == __exp2f_atable[i+128] + r
for some -2^-35 < r < 2^-35 (abs(r) < 2^-36 if i <= 0); and that
__exp2f_deltatable[i+128] == t * 2^-30
for integer t so that abs(t) <= 43447 * 2^0. */
#define W30 (9.31322575e-10f)
static const Simple __exp2f_deltatable[256] = {
-810*W30, 283*W30, -1514*W30, 1304*W30,
-1148*W30, -98*W30, -744*W30, -156*W30,
-419*W30, -155*W30, 474*W30, 167*W30,
-1984*W30, -826*W30, 692*W30, 781*W30,
-578*W30, -411*W30, -129*W30, -1500*W30,
654*W30, -141*W30, -816*W30, -53*W30,
148*W30, 493*W30, -2214*W30, 760*W30,
260*W30, 750*W30, -1300*W30, 1424*W30,
-1445*W30, -339*W30, -680*W30, -349*W30,
-922*W30, 531*W30, 193*W30, -2892*W30,
290*W30, -2145*W30, -276*W30, 485*W30,
-695*W30, 215*W30, -7093*W30, 412*W30,
-4596*W30, 367*W30, 592*W30, -615*W30,
-97*W30, -1066*W30, 972*W30, -226*W30,
-625*W30, -374*W30, -5647*W30, -180*W30,
20349*W30, -447*W30, 111*W30, -4164*W30,
-87*W30, -21*W30, -251*W30, 66*W30,
-517*W30, 2093*W30, -263*W30, 182*W30,
-601*W30, 475*W30, -483*W30, -1251*W30,
-373*W30, 1471*W30, -92*W30, -215*W30,
-97*W30, -190*W30, 0*W30, -290*W30,
-2647*W30, 1940*W30, -582*W30, 28*W30,
833*W30, 1493*W30, 34*W30, 321*W30,
3327*W30, -35*W30, 177*W30, -135*W30,
-796*W30, -428*W30, 129*W30, 9332*W30,
-12*W30, -69*W30, -1743*W30, 6508*W30,
-60*W30, 359*W30, 43447*W30, 15*W30,
-23*W30, -305*W30, -375*W30, -652*W30,
667*W30, 269*W30, -1575*W30, 185*W30,
-329*W30, 200*W30, 6002*W30, 163*W30,
-647*W30, 19*W30, -603*W30, -755*W30,
742*W30, -438*W30, 3587*W30, 2560*W30,
0*W30, -520*W30, -241*W30, -299*W30,
-1270*W30, -991*W30, -1138*W30, 255*W30,
-1192*W30, 1722*W30, 1023*W30, 3700*W30,
-1388*W30, -1551*W30, -2549*W30, 27*W30,
282*W30, 673*W30, 113*W30, 1561*W30,
72*W30, 873*W30, 87*W30, -395*W30,
-433*W30, 629*W30, 3440*W30, -284*W30,
-592*W30, -103*W30, -46*W30, -3844*W30,
1712*W30, 303*W30, 1555*W30, -631*W30,
-1400*W30, -961*W30, -854*W30, -276*W30,
407*W30, 833*W30, -345*W30, -1501*W30,
121*W30, -1581*W30, 400*W30, 150*W30,
1224*W30, -139*W30, -563*W30, 879*W30,
933*W30, 2939*W30, 788*W30, 211*W30,
530*W30, -192*W30, 706*W30, -13347*W30,
1065*W30, 3*W30, 111*W30, -208*W30,
-360*W30, -532*W30, -291*W30, 483*W30,
987*W30, -33*W30, -1373*W30, -166*W30,
-1174*W30, -3955*W30, 1601*W30, -280*W30,
1405*W30, 600*W30, -1659*W30, -23*W30,
390*W30, 449*W30, 570*W30, -13143*W30,
-9*W30, -1646*W30, 1201*W30, 294*W30,
2181*W30, -1173*W30, 1388*W30, -4504*W30,
190*W30, -2304*W30, 211*W30, 239*W30,
48*W30, -817*W30, 1018*W30, 1828*W30,
-663*W30, 1408*W30, 408*W30, -36*W30,
1295*W30, -230*W30, 1341*W30, 9*W30,
40*W30, 705*W30, 186*W30, 376*W30,
557*W30, 5866*W30, 363*W30, -1558*W30,
718*W30, 669*W30, 1369*W30, -2972*W30,
-468*W30, -121*W30, -219*W30, 667*W30,
29954*W30, 366*W30, 48*W30, -203*W30
};
namespace streflop_libm {
static const Simple __exp2f_atable[256] /* __attribute__((mode(SF))) */ = {
0.707106411447f, /* 0x0.b504ecfff */
0.709024071690f, /* 0x0.b58299fff */
0.710945606239f, /* 0x0.b60088000 */
0.712874472142f, /* 0x0.b67ef1000 */
0.714806139464f, /* 0x0.b6fd88fff */
0.716744661340f, /* 0x0.b77c94000 */
0.718687653549f, /* 0x0.b7fbea000 */
0.720636486992f, /* 0x0.b87ba1fff */
0.722590208040f, /* 0x0.b8fbabfff */
0.724549472323f, /* 0x0.b97c12fff */
0.726514220228f, /* 0x0.b9fcd5fff */
0.728483855735f, /* 0x0.ba7deb000 */
0.730457961549f, /* 0x0.baff4afff */
0.732438981522f, /* 0x0.bb811efff */
0.734425544748f, /* 0x0.bc0350000 */
0.736416816713f, /* 0x0.bc85d0000 */
0.738412797450f, /* 0x0.bd089efff */
0.740414917465f, /* 0x0.bd8bd4fff */
0.742422521111f, /* 0x0.be0f66fff */
0.744434773914f, /* 0x0.be9346fff */
0.746454179287f, /* 0x0.bf179f000 */
0.748477637755f, /* 0x0.bf9c3afff */
0.750506639473f, /* 0x0.c02133fff */
0.752541840064f, /* 0x0.c0a694fff */
0.754582285889f, /* 0x0.c12c4e000 */
0.756628334525f, /* 0x0.c1b265000 */
0.758678436269f, /* 0x0.c238bffff */
0.760736882681f, /* 0x0.c2bfa6fff */
0.762799203401f, /* 0x0.c346cf000 */
0.764867603790f, /* 0x0.c3ce5d000 */
0.766940355298f, /* 0x0.c45633fff */
0.769021093841f, /* 0x0.c4de90fff */
0.771104693409f, /* 0x0.c5671dfff */
0.773195922364f, /* 0x0.c5f02afff */
0.775292098512f, /* 0x0.c6798afff */
0.777394294745f, /* 0x0.c70350000 */
0.779501736166f, /* 0x0.c78d6d000 */
0.781615912910f, /* 0x0.c817fafff */
0.783734917628f, /* 0x0.c8a2d9fff */
0.785858273516f, /* 0x0.c92e02000 */
0.787990570071f, /* 0x0.c9b9c0000 */
0.790125787245f, /* 0x0.ca45aefff */
0.792268991467f, /* 0x0.cad223fff */
0.794417440881f, /* 0x0.cb5ef0fff */
0.796570718287f, /* 0x0.cbec0efff */
0.798730909811f, /* 0x0.cc79a0fff */
0.800892710672f, /* 0x0.cd074dfff */
0.803068041795f, /* 0x0.cd95ddfff */
0.805242776881f, /* 0x0.ce2464000 */
0.807428598393f, /* 0x0.ceb3a3fff */
0.809617877002f, /* 0x0.cf431dfff */
0.811812341211f, /* 0x0.cfd2eefff */
0.814013659956f, /* 0x0.d06333000 */
0.816220164311f, /* 0x0.d0f3ce000 */
0.818434238424f, /* 0x0.d184e7fff */
0.820652604094f, /* 0x0.d21649fff */
0.822877407074f, /* 0x0.d2a818000 */
0.825108587751f, /* 0x0.d33a51000 */
0.827342867839f, /* 0x0.d3ccbdfff */
0.829588949684f, /* 0x0.d45ff1000 */
0.831849217401f, /* 0x0.d4f411fff */
0.834093391880f, /* 0x0.d58724fff */
0.836355149750f, /* 0x0.d61b5f000 */
0.838620424257f, /* 0x0.d6afd3fff */
0.840896368027f, /* 0x0.d744fc000 */
0.843176305293f, /* 0x0.d7da66fff */
0.845462262643f, /* 0x0.d87037000 */
0.847754716864f, /* 0x0.d90673fff */
0.850052893157f, /* 0x0.d99d10fff */
0.852359056469f, /* 0x0.da3433fff */
0.854668736446f, /* 0x0.dacb91fff */
0.856986224651f, /* 0x0.db6373000 */
0.859309315673f, /* 0x0.dbfbb1fff */
0.861639738080f, /* 0x0.dc946bfff */
0.863975346095f, /* 0x0.dd2d7d000 */
0.866317391394f, /* 0x0.ddc6f9fff */
0.868666708472f, /* 0x0.de60f1000 */
0.871022939695f, /* 0x0.defb5c000 */
0.873383641229f, /* 0x0.df9611fff */
0.875751554968f, /* 0x0.e03141000 */
0.878126025200f, /* 0x0.e0ccde000 */
0.880506813521f, /* 0x0.e168e4fff */
0.882894217966f, /* 0x0.e2055afff */
0.885287821299f, /* 0x0.e2a239000 */
0.887686729423f, /* 0x0.e33f6ffff */
0.890096127973f, /* 0x0.e3dd56fff */
0.892507970338f, /* 0x0.e47b67000 */
0.894928157336f, /* 0x0.e51a03000 */
0.897355020043f, /* 0x0.e5b90efff */
0.899788379682f, /* 0x0.e65888000 */
0.902227103705f, /* 0x0.e6f85afff */
0.904673457151f, /* 0x0.e798ae000 */
0.907128036008f, /* 0x0.e8398afff */
0.909585535528f, /* 0x0.e8da99000 */
0.912051796915f, /* 0x0.e97c3a000 */
0.914524436003f, /* 0x0.ea1e46000 */
0.917003571999f, /* 0x0.eac0bf000 */
0.919490039339f, /* 0x0.eb63b2fff */
0.921983361257f, /* 0x0.ec071a000 */
0.924488604054f, /* 0x0.ecab48fff */
0.926989555360f, /* 0x0.ed4f30000 */
0.929502844812f, /* 0x0.edf3e6000 */
0.932021975503f, /* 0x0.ee98fdfff */
0.934553921208f, /* 0x0.ef3eecfff */
0.937083780759f, /* 0x0.efe4b8fff */
0.939624726786f, /* 0x0.f08b3f000 */
0.942198514924f, /* 0x0.f133ebfff */
0.944726586343f, /* 0x0.f1d99a000 */
0.947287976728f, /* 0x0.f28176fff */
0.949856162070f, /* 0x0.f329c5fff */
0.952431440345f, /* 0x0.f3d28bfff */
0.955013573175f, /* 0x0.f47bc5000 */
0.957603693021f, /* 0x0.f52584000 */
0.960199773321f, /* 0x0.f5cfa7000 */
0.962801992906f, /* 0x0.f67a31000 */
0.965413510788f, /* 0x0.f72556fff */
0.968030691152f, /* 0x0.f7d0dc000 */
0.970655620084f, /* 0x0.f87ce2fff */
0.973290979849f, /* 0x0.f92998fff */
0.975926160805f, /* 0x0.f9d64bfff */
0.978571653370f, /* 0x0.fa83ac000 */
0.981225252139f, /* 0x0.fb3193fff */
0.983885228626f, /* 0x0.fbdfe6fff */
0.986552715296f, /* 0x0.fc8eb7fff */
0.989228487027f, /* 0x0.fd3e14000 */
0.991909801964f, /* 0x0.fdedcd000 */
0.994601726545f, /* 0x0.fe9e38000 */
0.997297704209f, /* 0x0.ff4ee6fff */
1.000000000000f, /* 0x1.000000000f */
1.002710938457f, /* 0x1.00b1aa000 */
1.005429744692f, /* 0x1.0163d7ffe */
1.008155703526f, /* 0x1.02167dffe */
1.010888457284f, /* 0x1.02c995fff */
1.013629436498f, /* 0x1.037d38000 */
1.016377568250f, /* 0x1.043152000f */
1.019134163841f, /* 0x1.04e5f9ffe */
1.021896362316f, /* 0x1.059b00000 */
1.024668931945f, /* 0x1.0650b3ffe */
1.027446627635f, /* 0x1.0706be001 */
1.030234098408f, /* 0x1.07bd6bffe */
1.033023953416f, /* 0x1.087441ffe */
1.035824656494f, /* 0x1.092bce000 */
1.038632392900f, /* 0x1.09e3d0001 */
1.041450142840f, /* 0x1.0a9c79ffe */
1.044273972530f, /* 0x1.0b558a001 */
1.047105550795f, /* 0x1.0c0f1c001 */
1.049944162390f, /* 0x1.0cc924001 */
1.052791833895f, /* 0x1.0d83c4001 */
1.055645227426f, /* 0x1.0e3ec3fff */
1.058507919326f, /* 0x1.0efa60001 */
1.061377286898f, /* 0x1.0fb66bfff */
1.064254641510f, /* 0x1.1072fdffe */
1.067140102389f, /* 0x1.113018000f */
1.070034146304f, /* 0x1.11edc1fff */
1.072937250162f, /* 0x1.12ac04001 */
1.075843691823f, /* 0x1.136a7dfff */
1.078760385496f, /* 0x1.1429a3ffe */
1.081685543070f, /* 0x1.14e958000f */
1.084618330005f, /* 0x1.15a98c000 */
1.087556362176f, /* 0x1.166a18001 */
1.090508937863f, /* 0x1.172b98001 */
1.093464612954f, /* 0x1.17ed4bfff */
1.096430182434f, /* 0x1.18afa5ffe */
1.099401354802f, /* 0x1.19725e000f */
1.102381587017f, /* 0x1.1a35adfff */
1.105370759965f, /* 0x1.1af994000 */
1.108367800686f, /* 0x1.1bbdfdffe */
1.111373305331f, /* 0x1.1c82f6000 */
1.114387035385f, /* 0x1.1d4878001 */
1.117408752440f, /* 0x1.1e0e7ffff */
1.120437502874f, /* 0x1.1ed4fe000 */
1.123474478729f, /* 0x1.1f9c06000 */
1.126521706601f, /* 0x1.2063ba001 */
1.129574775716f, /* 0x1.212bd0001 */
1.132638812065f, /* 0x1.21f49e000 */
1.135709524130f, /* 0x1.22bddbffe */
1.138789534565f, /* 0x1.2387b5fff */
1.141876101508f, /* 0x1.2451fe000 */
1.144971728301f, /* 0x1.251cddffe */
1.148077130296f, /* 0x1.25e861ffe */
1.151189923305f, /* 0x1.26b462001 */
1.154312610610f, /* 0x1.278107ffe */
1.157440662410f, /* 0x1.284e08001f */
1.160578370109f, /* 0x1.291baa001 */
1.163725256932f, /* 0x1.29e9e6000 */
1.166879892324f, /* 0x1.2ab8a3ffe */
1.170044302935f, /* 0x1.2b8805fff */
1.173205971694f, /* 0x1.2c5739ffe */
1.176397800428f, /* 0x1.2d2867ffe */
1.179586529747f, /* 0x1.2df962001 */
1.182784795737f, /* 0x1.2ecafbffe */
1.185991406414f, /* 0x1.2f9d21ffe */
1.189206838636f, /* 0x1.306fdc001 */
1.192430973067f, /* 0x1.314328000f */
1.195664167430f, /* 0x1.32170c001 */
1.198906540890f, /* 0x1.32eb8a001 */
1.202157497408f, /* 0x1.33c098000 */
1.205416083326f, /* 0x1.349625fff */
1.208683252332f, /* 0x1.356c43fff */
1.211961269402f, /* 0x1.364318001f */
1.215246438983f, /* 0x1.371a64000 */
1.218539118740f, /* 0x1.37f22dffe */
1.221847295770f, /* 0x1.38cafc000 */
1.225158572187f, /* 0x1.39a3fdfff */
1.228481650325f, /* 0x1.3a7dc5ffe */
1.231811761846f, /* 0x1.3b5803fff */
1.235149741144f, /* 0x1.3c32c5ffe */
1.238499879811f, /* 0x1.3d0e53ffe */
1.241858124726f, /* 0x1.3dea69fff */
1.245225191102f, /* 0x1.3ec713fff */
1.248601436624f, /* 0x1.3fa458000 */
1.251975655584f, /* 0x1.40817a001 */
1.255380749731f, /* 0x1.4160a2001 */
1.258783102010f, /* 0x1.423f9bffe */
1.262198328973f, /* 0x1.431f6e000 */
1.265619754780f, /* 0x1.43ffa7fff */
1.269052743928f, /* 0x1.44e0a4001 */
1.272490739830f, /* 0x1.45c1f4000 */
1.275942921659f, /* 0x1.46a432001 */
1.279397487615f, /* 0x1.478697ffe */
1.282870173427f, /* 0x1.486a2dffe */
1.286346316319f, /* 0x1.494dfdffe */
1.289836049094f, /* 0x1.4a32b2001 */
1.293333172770f, /* 0x1.4b17e1ffe */
1.296839594835f, /* 0x1.4bfdadfff */
1.300354957560f, /* 0x1.4ce40fffe */
1.303882122055f, /* 0x1.4dcb38001 */
1.307417988757f, /* 0x1.4eb2f1ffe */
1.310960650439f, /* 0x1.4f9b1dfff */
1.314516782746f, /* 0x1.50842bfff */
1.318079948424f, /* 0x1.516daffff */
1.321653246888f, /* 0x1.5257de000 */
1.325237751030f, /* 0x1.5342c8001 */
1.328829526907f, /* 0x1.542e2c000 */
1.332433700535f, /* 0x1.551a5fffe */
1.336045145966f, /* 0x1.56070dffe */
1.339667558645f, /* 0x1.56f473ffe */
1.343300342533f, /* 0x1.57e287ffe */
1.346941947961f, /* 0x1.58d130001 */
1.350594043714f, /* 0x1.59c087ffe */
1.354256033883f, /* 0x1.5ab085fff */
1.357932448365f, /* 0x1.5ba175ffe */
1.361609339707f, /* 0x1.5c926dfff */
1.365299344044f, /* 0x1.5d8441ffe */
1.369003057507f, /* 0x1.5e76fc001 */
1.372714757920f, /* 0x1.5f6a3c000 */
1.376437187179f, /* 0x1.605e2fffe */
1.380165219333f, /* 0x1.615282001f */
1.383909463864f, /* 0x1.6247e3ffe */
1.387661933907f, /* 0x1.633dd0000 */
1.391424179060f, /* 0x1.64345fffe */
1.395197510706f, /* 0x1.652ba9fff */
1.399006724329f, /* 0x1.66254dffe */
1.402773022651f, /* 0x1.671c22000 */
1.406576037403f, /* 0x1.68155dfff */
1.410389423392f, /* 0x1.690f48001 */
};
}

View File

@@ -0,0 +1,7 @@
/* Copied from math.h in same directory */
/* This file is stub automatically generated by import.pl */
// Include bridge, just in case math_private is not included
#include "../streflop_libm_bridge.h"

View File

@@ -0,0 +1,77 @@
/* See the import.pl script for potential modifications */
/* Copyright (C) 1992, 1996, 1997, 2000 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#ifndef _ENDIAN_H
#define _ENDIAN_H 1
#include "features.h"
/* Definitions for byte order, according to significance of bytes,
from low addresses to high addresses. The value is what you get by
putting '4' in the most significant byte, '3' in the second most
significant byte, '2' in the second least significant byte, and '1'
in the least significant byte, and then writing down one digit for
each byte, starting with the byte at the lowest address at the left,
and proceeding to the byte with the highest address at the right. */
#define __LITTLE_ENDIAN 1234
#define __BIG_ENDIAN 4321
#define __PDP_ENDIAN 3412
/* This file defines `__BYTE_ORDER' for the particular machine. */
#include "../streflop_libm_bridge.h"
/* Some machines may need to use a different endianness for floating point
values. */
#ifndef __FLOAT_WORD_ORDER
# define __FLOAT_WORD_ORDER __BYTE_ORDER
#endif
#ifdef __USE_BSD
# define LITTLE_ENDIAN __LITTLE_ENDIAN
# define BIG_ENDIAN __BIG_ENDIAN
# define PDP_ENDIAN __PDP_ENDIAN
# define BYTE_ORDER __BYTE_ORDER
#endif
#if __BYTE_ORDER == __LITTLE_ENDIAN
# define __LONG_LONG_PAIR(HI, LO) LO, HI
#elif __BYTE_ORDER == __BIG_ENDIAN
# define __LONG_LONG_PAIR(HI, LO) HI, LO
#endif
#endif /* endian.h */
//#include <string/endian.h>
#if 1
//#if defined _LIBC && !defined _ISOMAC
# if __FLOAT_WORD_ORDER == __BIG_ENDIAN
# define BIG_ENDI 1
# undef LITTLE_ENDI
# define HIGH_HALF 0
# define LOW_HALF 1
# else
# if __FLOAT_WORD_ORDER == __LITTLE_ENDIAN
# undef BIG_ENDI
# define LITTLE_ENDI 1
# define HIGH_HALF 1
# define LOW_HALF 0
# endif
# endif
#endif

View File

@@ -0,0 +1,350 @@
/* See the import.pl script for potential modifications */
/* Copyright (C) 1991,1992,1993,1995,1996,1997,1998,1999,2000,2001,2002,2003,2004,2005,2006
Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#ifndef _FEATURES_H
#define _FEATURES_H 1
/* These are defined by the user (or the compiler)
to specify the desired environment:
__STRICT_ANSI__ ISO Standard C.
_ISOC99_SOURCE Extensions to ISO C89 from ISO C99.
_POSIX_SOURCE IEEE Std 1003.1.
_POSIX_C_SOURCE If ==1, like _POSIX_SOURCE; if >=2 add IEEE Std 1003.2;
if >=199309L, add IEEE Std 1003.1b-1993;
if >=199506L, add IEEE Std 1003.1c-1995;
if >=200112L, all of IEEE 1003.1-2004
_XOPEN_SOURCE Includes POSIX and XPG things. Set to 500 if
Single Unix conformance is wanted, to 600 for the
upcoming sixth revision.
_XOPEN_SOURCE_EXTENDED XPG things and X/Open Unix extensions.
_LARGEFILE_SOURCE Some more functions for correct standard I/O.
_LARGEFILE64_SOURCE Additional functionality from LFS for large files.
_FILE_OFFSET_BITS=N Select default filesystem interface.
_BSD_SOURCE ISO C, POSIX, and 4.3BSD things.
_SVID_SOURCE ISO C, POSIX, and SVID things.
_ATFILE_SOURCE Additional *at interfaces.
_GNU_SOURCE All of the above, plus GNU extensions.
_REENTRANT Select additionally reentrant object.
_THREAD_SAFE Same as _REENTRANT, often used by other systems.
_FORTIFY_SOURCE If set to numeric value > 0 additional security
measures are defined, according to level.
The `-ansi' switch to the GNU C compiler defines __STRICT_ANSI__.
If none of these are defined, the default is to have _SVID_SOURCE,
_BSD_SOURCE, and _POSIX_SOURCE set to one and _POSIX_C_SOURCE set to
199506L. If more than one of these are defined, they accumulate.
For example __STRICT_ANSI__, _POSIX_SOURCE and _POSIX_C_SOURCE
together give you ISO C, 1003.1, and 1003.2, but nothing else.
These are defined by this file and are used by the
header files to decide what to declare or define:
__USE_ISOC99 Define ISO C99 things.
__USE_POSIX Define IEEE Std 1003.1 things.
__USE_POSIX2 Define IEEE Std 1003.2 things.
__USE_POSIX199309 Define IEEE Std 1003.1, and .1b things.
__USE_POSIX199506 Define IEEE Std 1003.1, .1b, .1c and .1i things.
__USE_XOPEN Define XPG things.
__USE_XOPEN_EXTENDED Define X/Open Unix things.
__USE_UNIX98 Define Single Unix V2 things.
__USE_XOPEN2K Define XPG6 things.
__USE_LARGEFILE Define correct standard I/O things.
__USE_LARGEFILE64 Define LFS things with separate names.
__USE_FILE_OFFSET64 Define 64bit interface as default.
__USE_BSD Define 4.3BSD things.
__USE_SVID Define SVID things.
__USE_MISC Define things common to BSD and System V Unix.
__USE_ATFILE Define *at interfaces and AT_* constants for them.
__USE_GNU Define GNU extensions.
__USE_REENTRANT Define reentrant/thread-safe *_r functions.
__USE_FORTIFY_LEVEL Additional security measures used, according to level.
__FAVOR_BSD Favor 4.3BSD things in cases of conflict.
The macros `__GNU_LIBRARY__', `__GLIBC__', and `__GLIBC_MINOR__' are
defined by this file unconditionally. `__GNU_LIBRARY__' is provided
only for compatibility. All new code should use the other symbols
to test for features.
All macros listed above as possibly being defined by this file are
explicitly undefined if they are not explicitly defined.
Feature-test macros that are not defined by the user or compiler
but are implied by the other feature-test macros defined (or by the
lack of any definitions) are defined by the file. */
/* Undefine everything, so we get a clean slate. */
#undef __USE_ISOC99
#undef __USE_POSIX
#undef __USE_POSIX2
#undef __USE_POSIX199309
#undef __USE_POSIX199506
#undef __USE_XOPEN
#undef __USE_XOPEN_EXTENDED
#undef __USE_UNIX98
#undef __USE_XOPEN2K
#undef __USE_LARGEFILE
#undef __USE_LARGEFILE64
#undef __USE_FILE_OFFSET64
#undef __USE_BSD
#undef __USE_SVID
#undef __USE_MISC
#undef __USE_ATFILE
#undef __USE_GNU
#undef __USE_REENTRANT
#undef __USE_FORTIFY_LEVEL
#undef __FAVOR_BSD
#undef __KERNEL_STRICT_NAMES
/* Suppress kernel-name space pollution unless user expressedly asks
for it. */
#ifndef _LOOSE_KERNEL_NAMES
# define __KERNEL_STRICT_NAMES
#endif
/* Always use ISO C things. */
#define __USE_ANSI 1
/* Convenience macros to test the versions of glibc and gcc.
Use them like this:
#if __GNUC_PREREQ (2,8)
... code requiring gcc 2.8 or later ...
#endif
Note - they won't work for gcc1 or glibc1, since the _MINOR macros
were not defined then. */
#if defined __GNUC__ && defined __GNUC_MINOR__
# define __GNUC_PREREQ(maj, min) \
((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
#else
# define __GNUC_PREREQ(maj, min) 0
#endif
/* If _BSD_SOURCE was defined by the user, favor BSD over POSIX. */
#if defined _BSD_SOURCE && \
!(defined _POSIX_SOURCE || defined _POSIX_C_SOURCE || \
defined _XOPEN_SOURCE || defined _XOPEN_SOURCE_EXTENDED || \
defined _GNU_SOURCE || defined _SVID_SOURCE)
# define __FAVOR_BSD 1
#endif
/* If _GNU_SOURCE was defined by the user, turn on all the other features. */
#ifdef _GNU_SOURCE
# undef _ISOC99_SOURCE
# define _ISOC99_SOURCE 1
# undef _POSIX_SOURCE
# define _POSIX_SOURCE 1
# undef _POSIX_C_SOURCE
# define _POSIX_C_SOURCE 199506L
# undef _XOPEN_SOURCE
# define _XOPEN_SOURCE 600
# undef _XOPEN_SOURCE_EXTENDED
# define _XOPEN_SOURCE_EXTENDED 1
# undef _LARGEFILE64_SOURCE
# define _LARGEFILE64_SOURCE 1
# undef _BSD_SOURCE
# define _BSD_SOURCE 1
# undef _SVID_SOURCE
# define _SVID_SOURCE 1
# undef _ATFILE_SOURCE
# define _ATFILE_SOURCE 1
#endif
/* If nothing (other than _GNU_SOURCE) is defined,
define _BSD_SOURCE and _SVID_SOURCE. */
#if (!defined __STRICT_ANSI__ && !defined _ISOC99_SOURCE && \
!defined _POSIX_SOURCE && !defined _POSIX_C_SOURCE && \
!defined _XOPEN_SOURCE && !defined _XOPEN_SOURCE_EXTENDED && \
!defined _BSD_SOURCE && !defined _SVID_SOURCE)
# define _BSD_SOURCE 1
# define _SVID_SOURCE 1
#endif
/* This is to enable the ISO C99 extension. Also recognize the old macro
which was used prior to the standard acceptance. This macro will
eventually go away and the features enabled by default once the ISO C99
standard is widely adopted. */
#if (defined _ISOC99_SOURCE || defined _ISOC9X_SOURCE \
|| (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L))
# define __USE_ISOC99 1
#endif
/* If none of the ANSI/POSIX macros are defined, use POSIX.1 and POSIX.2
(and IEEE Std 1003.1b-1993 unless _XOPEN_SOURCE is defined). */
#if ((!defined __STRICT_ANSI__ || (_XOPEN_SOURCE - 0) >= 500) && \
!defined _POSIX_SOURCE && !defined _POSIX_C_SOURCE)
# define _POSIX_SOURCE 1
# if defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) < 500
# define _POSIX_C_SOURCE 2
# elif defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) < 600
# define _POSIX_C_SOURCE 199506L
# else
# define _POSIX_C_SOURCE 200112L
# endif
#endif
#if defined _POSIX_SOURCE || _POSIX_C_SOURCE >= 1 || defined _XOPEN_SOURCE
# define __USE_POSIX 1
#endif
#if defined _POSIX_C_SOURCE && _POSIX_C_SOURCE >= 2 || defined _XOPEN_SOURCE
# define __USE_POSIX2 1
#endif
#if (_POSIX_C_SOURCE - 0) >= 199309L
# define __USE_POSIX199309 1
#endif
#if (_POSIX_C_SOURCE - 0) >= 199506L
# define __USE_POSIX199506 1
#endif
#if (_POSIX_C_SOURCE - 0) >= 200112L
# define __USE_XOPEN2K 1
#endif
#ifdef _XOPEN_SOURCE
# define __USE_XOPEN 1
# if (_XOPEN_SOURCE - 0) >= 500
# define __USE_XOPEN_EXTENDED 1
# define __USE_UNIX98 1
# undef _LARGEFILE_SOURCE
# define _LARGEFILE_SOURCE 1
# if (_XOPEN_SOURCE - 0) >= 600
# define __USE_XOPEN2K 1
# undef __USE_ISOC99
# define __USE_ISOC99 1
# endif
# else
# ifdef _XOPEN_SOURCE_EXTENDED
# define __USE_XOPEN_EXTENDED 1
# endif
# endif
#endif
#ifdef _LARGEFILE_SOURCE
# define __USE_LARGEFILE 1
#endif
#ifdef _LARGEFILE64_SOURCE
# define __USE_LARGEFILE64 1
#endif
#if defined _FILE_OFFSET_BITS && _FILE_OFFSET_BITS == 64
# define __USE_FILE_OFFSET64 1
#endif
#if defined _BSD_SOURCE || defined _SVID_SOURCE
# define __USE_MISC 1
#endif
#ifdef _BSD_SOURCE
# define __USE_BSD 1
#endif
#ifdef _SVID_SOURCE
# define __USE_SVID 1
#endif
#ifdef _ATFILE_SOURCE
# define __USE_ATFILE 1
#endif
#ifdef _GNU_SOURCE
# define __USE_GNU 1
#endif
#if defined _REENTRANT || defined _THREAD_SAFE
# define __USE_REENTRANT 1
#endif
#if defined _FORTIFY_SOURCE && _FORTIFY_SOURCE > 0 \
&& __GNUC_PREREQ (4, 1) && defined __OPTIMIZE__ && __OPTIMIZE__ > 0
# if _FORTIFY_SOURCE > 1
# define __USE_FORTIFY_LEVEL 2
# else
# define __USE_FORTIFY_LEVEL 1
# endif
#else
# define __USE_FORTIFY_LEVEL 0
#endif
/* We do support the IEC 559 math functionality, real and complex. */
#define __STDC_IEC_559__ 1
#define __STDC_IEC_559_COMPLEX__ 1
/* wchar_t uses ISO 10646-1 (2nd ed., published 2000-09-15) / Unicode 3.1. */
#define __STDC_ISO_10646__ 200009L
/* This macro indicates that the installed library is the GNU C Library.
For historic reasons the value now is 6 and this will stay from now
on. The use of this variable is deprecated. Use __GLIBC__ and
__GLIBC_MINOR__ now (see below) when you want to test for a specific
GNU C library version and use the values in <gnu/lib-names.h> to get
the sonames of the shared libraries. */
#undef __GNU_LIBRARY__
#define __GNU_LIBRARY__ 6
/* Major and minor version number of the GNU C library package. Use
these macros to test for features in specific releases. */
#define __GLIBC__ 2
#define __GLIBC_MINOR__ 4
#define __GLIBC_PREREQ(maj, min) \
((__GLIBC__ << 16) + __GLIBC_MINOR__ >= ((maj) << 16) + (min))
/* Decide whether a compiler supports the long long datatypes. */
#if defined __GNUC__ \
|| (defined __PGI && defined __i386__ ) \
|| (defined __INTEL_COMPILER && (defined __i386__ || defined __ia64__)) \
|| (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L)
# define __GLIBC_HAVE_LONG_LONG 1
#endif
/* This is here only because every header file already includes this one. */
#ifndef __ASSEMBLER__
# ifndef _SYS_CDEFS_H
//# include <sys/cdefs.h>
# endif
/* If we don't have __REDIRECT, prototypes will be missing if
__USE_FILE_OFFSET64 but not __USE_LARGEFILE[64]. */
# if defined __USE_FILE_OFFSET64 && !defined __REDIRECT
# define __USE_LARGEFILE 1
# define __USE_LARGEFILE64 1
# endif
#endif /* !ASSEMBLER */
/* Decide whether we can define 'extern inline' functions in headers. */
#if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ \
&& !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__
# define __USE_EXTERN_INLINES 1
#endif
/* This is here only because every header file already includes this one.
Get the definitions of all the appropriate `__stub_FUNCTION' symbols.
<gnu/stubs.h> contains `#define __stub_FUNCTION' when FUNCTION is a stub
that will always return failure (and set errno to ENOSYS). */
//#include <gnu/stubs.h>
#endif /* features.h */

View File

@@ -0,0 +1,223 @@
/* See the import.pl script for potential modifications */
/* Copyright (C) 1992, 1995, 1996, 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#ifndef _IEEE754_H
#define _IEEE754_H 1
#include "../streflop_libm_bridge.h"
#include "features.h"
#include "endian.h"
//__BEGIN_DECLS
#if defined(LIBM_COMPILING_FLT32)
union ieee754_float
{
int storage[sizeof(float)/sizeof(int)];
inline Simple& f() {return SIMPLE_FROM_INT_PTR(&storage[0]);}
inline const Simple& f() const {return CONST_SIMPLE_FROM_INT_PTR(&storage[0]);}
/* This is the IEEE 754 single-precision format. */
struct
{
#if __BYTE_ORDER == __BIG_ENDIAN
unsigned int negative:1;
unsigned int exponent:8;
unsigned int mantissa:23;
#endif /* Big endian. */
#if __BYTE_ORDER == __LITTLE_ENDIAN
unsigned int mantissa:23;
unsigned int exponent:8;
unsigned int negative:1;
#endif /* Little endian. */
} ieee;
/* This format makes it easier to see if a NaN is a signalling NaN. */
struct
{
#if __BYTE_ORDER == __BIG_ENDIAN
unsigned int negative:1;
unsigned int exponent:8;
unsigned int quiet_nan:1;
unsigned int mantissa:22;
#endif /* Big endian. */
#if __BYTE_ORDER == __LITTLE_ENDIAN
unsigned int mantissa:22;
unsigned int quiet_nan:1;
unsigned int exponent:8;
unsigned int negative:1;
#endif /* Little endian. */
} ieee_nan;
};
#define IEEE754_FLOAT_BIAS 0x7f /* Added to exponent. */
#endif
#if defined(LIBM_COMPILING_DBL64)
union ieee754_double
{
int storage[sizeof(double)/sizeof(int)];
inline Double& d() {return DOUBLE_FROM_INT_PTR(&storage[0]);}
inline const Double& d() const {return CONST_DOUBLE_FROM_INT_PTR(&storage[0]);}
/* This is the IEEE 754 double-precision format. */
struct
{
#if __BYTE_ORDER == __BIG_ENDIAN
unsigned int negative:1;
unsigned int exponent:11;
/* Together these comprise the mantissa. */
unsigned int mantissa0:20;
unsigned int mantissa1:32;
#endif /* Big endian. */
#if __BYTE_ORDER == __LITTLE_ENDIAN
# if __FLOAT_WORD_ORDER == BIG_ENDIAN
unsigned int mantissa0:20;
unsigned int exponent:11;
unsigned int negative:1;
unsigned int mantissa1:32;
# else
/* Together these comprise the mantissa. */
unsigned int mantissa1:32;
unsigned int mantissa0:20;
unsigned int exponent:11;
unsigned int negative:1;
# endif
#endif /* Little endian. */
} ieee;
/* This format makes it easier to see if a NaN is a signalling NaN. */
struct
{
#if __BYTE_ORDER == __BIG_ENDIAN
unsigned int negative:1;
unsigned int exponent:11;
unsigned int quiet_nan:1;
/* Together these comprise the mantissa. */
unsigned int mantissa0:19;
unsigned int mantissa1:32;
#else
# if __FLOAT_WORD_ORDER == BIG_ENDIAN
unsigned int mantissa0:19;
unsigned int quiet_nan:1;
unsigned int exponent:11;
unsigned int negative:1;
unsigned int mantissa1:32;
# else
/* Together these comprise the mantissa. */
unsigned int mantissa1:32;
unsigned int mantissa0:19;
unsigned int quiet_nan:1;
unsigned int exponent:11;
unsigned int negative:1;
# endif
#endif
} ieee_nan;
};
#define IEEE754_DOUBLE_BIAS 0x3ff /* Added to exponent. */
#endif
#if defined(LIBM_COMPILING_LDBL96)
#if defined(Extended)
union ieee854_long_double
{
int storage[sizeof(long double)/sizeof(int)];
inline Extended& d() {return EXTENDED_FROM_INT_PTR(&storage[0]);}
inline const Extended& d() const {return CONST_EXTENDED_FROM_INT_PTR(&storage[0]);}
/* This is the IEEE 854 double-extended-precision format. */
struct
{
#if __BYTE_ORDER == __BIG_ENDIAN
unsigned int negative:1;
unsigned int exponent:15;
unsigned int empty:16;
unsigned int mantissa0:32;
unsigned int mantissa1:32;
#endif
#if __BYTE_ORDER == __LITTLE_ENDIAN
# if __FLOAT_WORD_ORDER == BIG_ENDIAN
unsigned int exponent:15;
unsigned int negative:1;
unsigned int empty:16;
unsigned int mantissa0:32;
unsigned int mantissa1:32;
# else
unsigned int mantissa1:32;
unsigned int mantissa0:32;
unsigned int exponent:15;
unsigned int negative:1;
unsigned int empty:16;
# endif
#endif
} ieee;
/* This is for NaNs in the IEEE 854 double-extended-precision format. */
struct
{
#if __BYTE_ORDER == __BIG_ENDIAN
unsigned int negative:1;
unsigned int exponent:15;
unsigned int empty:16;
unsigned int one:1;
unsigned int quiet_nan:1;
unsigned int mantissa0:30;
unsigned int mantissa1:32;
#endif
#if __BYTE_ORDER == __LITTLE_ENDIAN
# if __FLOAT_WORD_ORDER == BIG_ENDIAN
unsigned int exponent:15;
unsigned int negative:1;
unsigned int empty:16;
unsigned int mantissa0:30;
unsigned int quiet_nan:1;
unsigned int one:1;
unsigned int mantissa1:32;
# else
unsigned int mantissa1:32;
unsigned int mantissa0:30;
unsigned int quiet_nan:1;
unsigned int one:1;
unsigned int exponent:15;
unsigned int negative:1;
unsigned int empty:16;
# endif
#endif
} ieee_nan;
};
#define IEEE854_LONG_DOUBLE_BIAS 0x3fff
#endif
#endif
//__END_DECLS
#endif /* ieee754.h */

View File

@@ -0,0 +1,5 @@
/* This file is stub automatically generated by import.pl */
// Include bridge, just in case math_private is not included
#include "../streflop_libm_bridge.h"

View File

@@ -0,0 +1,285 @@
/* See the import.pl script for potential modifications */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
* Developed at SunPro, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
* software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
/*
* from: @(#)fdlibm.h 5.1 93/09/24
*/
#ifndef _MATH_PRIVATE_H_
#define _MATH_PRIVATE_H_
/* import.pl: Skipped the macro definitions, keep only the declarations, converted to use streflop types (aliases or wrappers) */
#include "../streflop_libm_bridge.h"
namespace streflop_libm {
#ifdef LIBM_COMPILING_FLT32
#define __sqrtf __ieee754_sqrtf
#define fabsf __fabsf
#define copysignf __copysignf
extern Simple __log1pf(Simple x);
extern Simple __fabsf(Simple x);
extern Simple __atanf(Simple x);
extern Simple __expm1f(Simple x);
extern int __isinff(Simple x);
extern Simple __rintf(Simple x);
extern Simple __cosf(Simple x);
extern void __sincosf (Simple x, Simple *sinx, Simple *cosx);
extern Simple __floorf(Simple x);
extern Simple __scalbnf (Simple x, int n);
extern Simple __frexpf(Simple x, int *eptr);
extern Simple __ldexpf(Simple value, int exp);
extern int __finitef(Simple x);
#endif
#ifdef LIBM_COMPILING_DBL64
#define __sqrt __ieee754_sqrt
#define fabs __fabs
#define copysign __copysign
extern Double __log1p(Double x);
extern Double __fabs(Double x);
extern Double atan(Double x);
extern Double __expm1(Double x);
extern int __isinf(Double x);
extern Double __rint(Double x);
extern Double __cos(Double x);
extern void __sincos (Double x, Double *sinx, Double *cosx);
extern Double __floor(Double x);
extern Double __scalbn(Double x, int n);
extern Double __frexp(Double x, int *eptr);
extern Double __ldexp(Double value, int exp);
extern int __finite(Double x);
#endif
#ifdef LIBM_COMPILING_LDBL96
#if defined(Extended)
#define fabsl __fabsl
extern Extended __cosl(Extended x);
extern Extended __sinl(Extended x);
extern Extended __fabsl(Extended x);
#endif
#endif
#ifdef LIBM_COMPILING_DBL64
extern Double __ieee754_sqrt (Double);
extern Double __ieee754_acos (Double);
extern Double __ieee754_acosh (Double);
extern Double __ieee754_log (Double);
extern Double __ieee754_atanh (Double);
extern Double __ieee754_asin (Double);
extern Double __ieee754_atan2 (Double,Double);
extern Double __ieee754_exp (Double);
extern Double __ieee754_exp2 (Double);
extern Double __ieee754_exp10 (Double);
extern Double __ieee754_cosh (Double);
extern Double __ieee754_fmod (Double,Double);
extern Double __ieee754_pow (Double,Double);
extern Double __ieee754_lgamma_r (Double,int *);
extern Double __ieee754_gamma_r (Double,int *);
extern Double __ieee754_lgamma (Double);
extern Double __ieee754_gamma (Double);
extern Double __ieee754_log10 (Double);
extern Double __ieee754_log2 (Double);
extern Double __ieee754_sinh (Double);
extern Double __ieee754_hypot (Double,Double);
extern Double __ieee754_j0 (Double);
extern Double __ieee754_j1 (Double);
extern Double __ieee754_y0 (Double);
extern Double __ieee754_y1 (Double);
extern Double __ieee754_jn (int,Double);
extern Double __ieee754_yn (int,Double);
extern Double __ieee754_remainder (Double,Double);
extern int32_t __ieee754_rem_pio2 (Double,Double*);
extern Double __ieee754_scalb (Double,Double);
#endif
/* fdlibm kernel function */
#ifdef LIBM_COMPILING_DBL64
extern Double __kernel_standard (Double,Double,int);
extern Double __kernel_sin (Double,Double,int);
extern Double __kernel_cos (Double,Double);
extern Double __kernel_tan (Double,Double,int);
extern int __kernel_rem_pio2 (Double*,Double*,int,int,int, const int32_t*);
#endif
/* internal functions. */
#ifdef LIBM_COMPILING_DBL64
extern Double __copysign (Double x, Double __y);
#endif
#if 0
#ifdef LIBM_COMPILING_DBL64
extern inline Double __copysign (Double x, Double y)
{ return __builtin_copysign (x, y); }
#endif
#endif
/* ieee style elementary Simple functions */
#ifdef LIBM_COMPILING_FLT32
extern Simple __ieee754_sqrtf (Simple);
extern Simple __ieee754_acosf (Simple);
extern Simple __ieee754_acoshf (Simple);
extern Simple __ieee754_logf (Simple);
extern Simple __ieee754_atanhf (Simple);
extern Simple __ieee754_asinf (Simple);
extern Simple __ieee754_atan2f (Simple,Simple);
extern Simple __ieee754_expf (Simple);
extern Simple __ieee754_exp2f (Simple);
extern Simple __ieee754_exp10f (Simple);
extern Simple __ieee754_coshf (Simple);
extern Simple __ieee754_fmodf (Simple,Simple);
extern Simple __ieee754_powf (Simple,Simple);
extern Simple __ieee754_lgammaf_r (Simple,int *);
extern Simple __ieee754_gammaf_r (Simple,int *);
extern Simple __ieee754_lgammaf (Simple);
extern Simple __ieee754_gammaf (Simple);
extern Simple __ieee754_log10f (Simple);
extern Simple __ieee754_log2f (Simple);
extern Simple __ieee754_sinhf (Simple);
extern Simple __ieee754_hypotf (Simple,Simple);
extern Simple __ieee754_j0f (Simple);
extern Simple __ieee754_j1f (Simple);
extern Simple __ieee754_y0f (Simple);
extern Simple __ieee754_y1f (Simple);
extern Simple __ieee754_jnf (int,Simple);
extern Simple __ieee754_ynf (int,Simple);
extern Simple __ieee754_remainderf (Simple,Simple);
extern int32_t __ieee754_rem_pio2f (Simple,Simple*);
extern Simple __ieee754_scalbf (Simple,Simple);
#endif
/* Simple versions of fdlibm kernel functions */
#ifdef LIBM_COMPILING_FLT32
extern Simple __kernel_sinf (Simple,Simple,int);
extern Simple __kernel_cosf (Simple,Simple);
extern Simple __kernel_tanf (Simple,Simple,int);
extern int __kernel_rem_pio2f (Simple*,Simple*,int,int,int, const int32_t*);
#endif
/* internal functions. */
#ifdef LIBM_COMPILING_FLT32
extern Simple __copysignf (Simple x, Simple __y);
#endif
#if 0
#ifdef LIBM_COMPILING_FLT32
extern inline Simple __copysignf (Simple x, Simple y)
{ return __builtin_copysignf (x, y); }
#endif
#endif
#if defined(Extended)
/* ieee style elementary Extended functions */
#ifdef LIBM_COMPILING_LDBL96
extern Extended __ieee754_sqrtl (Extended);
extern Extended __ieee754_acosl (Extended);
extern Extended __ieee754_acoshl (Extended);
extern Extended __ieee754_logl (Extended);
extern Extended __ieee754_atanhl (Extended);
extern Extended __ieee754_asinl (Extended);
extern Extended __ieee754_atan2l (Extended,Extended);
extern Extended __ieee754_expl (Extended);
extern Extended __ieee754_exp2l (Extended);
extern Extended __ieee754_exp10l (Extended);
extern Extended __ieee754_coshl (Extended);
extern Extended __ieee754_fmodl (Extended,Extended);
extern Extended __ieee754_powl (Extended,Extended);
extern Extended __ieee754_lgammal_r (Extended,int *);
extern Extended __ieee754_gammal_r (Extended,int *);
extern Extended __ieee754_lgammal (Extended);
extern Extended __ieee754_gammal (Extended);
extern Extended __ieee754_log10l (Extended);
extern Extended __ieee754_log2l (Extended);
extern Extended __ieee754_sinhl (Extended);
extern Extended __ieee754_hypotl (Extended,Extended);
extern Extended __ieee754_j0l (Extended);
extern Extended __ieee754_j1l (Extended);
extern Extended __ieee754_y0l (Extended);
extern Extended __ieee754_y1l (Extended);
extern Extended __ieee754_jnl (int,Extended);
extern Extended __ieee754_ynl (int,Extended);
extern Extended __ieee754_remainderl (Extended,Extended);
extern int __ieee754_rem_pio2l (Extended,Extended*);
extern Extended __ieee754_scalbl (Extended,Extended);
#endif
/* Extended versions of fdlibm kernel functions */
#ifdef LIBM_COMPILING_LDBL96
extern Extended __kernel_sinl (Extended,Extended,int);
extern Extended __kernel_cosl (Extended,Extended);
extern Extended __kernel_tanl (Extended,Extended,int);
extern void __kernel_sincosl (Extended,Extended,
Extended *,Extended *, int);
extern int __kernel_rem_pio2l (Extended*,Extended*,int,int,
int,const int*);
#endif
#ifndef NO_LONG_DOUBLE
/* prototypes required to compile the ldbl-96 support without warnings */
#ifdef LIBM_COMPILING_LDBL96
extern int __finitel (Extended);
extern int __ilogbl (Extended);
extern int __isinfl (Extended);
extern int __isnanl (Extended);
extern Extended __atanl (Extended);
extern Extended __copysignl (Extended, Extended);
extern Extended __expm1l (Extended);
extern Extended __floorl (Extended);
extern Extended __frexpl (Extended, int *);
extern Extended __ldexpl (Extended, int);
extern Extended __log1pl (Extended);
extern Extended __nanl (const char *);
extern Extended __rintl (Extended);
extern Extended __scalbnl (Extended, int);
extern Extended __sqrtl (Extended x);
extern Extended fabsl (Extended x);
extern void __sincosl (Extended, Extended *, Extended *);
extern Extended __logbl (Extended x);
extern Extended __significandl (Extended x);
#endif
#if 0
#ifdef LIBM_COMPILING_LDBL96
extern inline Extended __copysignl (Extended x, Extended y)
{ return __builtin_copysignl (x, y); }
#endif
#endif
#endif
#endif
/* Prototypes for functions of the IBM Accurate Mathematical Library. */
#ifdef LIBM_COMPILING_DBL64
extern Double __exp1 (Double __x, Double __xx, Double __error);
extern Double __sin (Double __x);
extern Double __cos (Double __x);
extern int __branred (Double __x, Double *__a, Double *__aa);
extern void __doasin (Double __x, Double __dx, Double __v[]);
extern void __dubsin (Double __x, Double __dx, Double __v[]);
extern void __dubcos (Double __x, Double __dx, Double __v[]);
extern Double __halfulp (Double __x, Double __y);
extern Double __sin32 (Double __x, Double __res, Double __res1);
extern Double __cos32 (Double __x, Double __res, Double __res1);
extern Double __mpsin (Double __x, Double __dx);
extern Double __mpcos (Double __x, Double __dx);
extern Double __mpsin1 (Double __x);
extern Double __mpcos1 (Double __x);
extern Double __slowexp (Double __x);
extern Double __slowpow (Double __x, Double __y, Double __z);
extern void __docos (Double __x, Double __dx, Double __v[]);
#endif
}
#endif /* _MATH_PRIVATE_H_ */

View File

@@ -0,0 +1,26 @@
/* wchar_t type related definitions.
Copyright (C) 2000 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#ifndef _BITS_WCHAR_H
#define _BITS_WCHAR_H 1
#define __WCHAR_MIN (-2147483647 - 1)
#define __WCHAR_MAX (2147483647)
#endif /* bits/wchar.h */

View File

@@ -0,0 +1,536 @@
#!/usr/bin/perl
# streflop: STandalone REproducible FLOating-Point
# This script imports the GNU libm files and convert them in such a way they can be compiled with streflop types.
# Code released according to the GNU Lesser General Public License
# Nicolas Brodu, 2006
# Please read the history and copyright information in the accompanying documentation
if ($#ARGV==-1) {
print <<ENDHELP;
Perl script to import the libm components from the GNU glibc inside this project.
Tested with glibc-2.4
Usage: ./import.pl glibc_src_dir
Where: glibc_src_dir is the source directory obtained by uncompressing the GNU libc archive.
This script copies the libm directories for generic IEEE754 math with float (32 bits), double (64 bits) and long double (80 bits). The files are then post-processed to remove all dependencies from glibc so they can be compiled standalone.
ENDHELP
exit 0;
}
$dir=$ARGV[0];
if ((! -d "$dir/sysdeps/ieee754/flt-32")
|| (! -d "$dir/sysdeps/ieee754/dbl-64")
|| (! -d "$dir/sysdeps/ieee754/ldbl-96")
|| (! -r "$dir/math/s_ldexpf.c") # was put here for unknown reason, probably because not system-dependent
|| (! -r "$dir/math/s_ldexp.c") # was put here for unknown reason, probably because not system-dependent
|| (! -r "$dir/math/s_nextafter.c") # was put here for unknown reason, probably because not system-dependent
|| (! -r "$dir/math/math_private.h")
|| (! -r "$dir/sysdeps/ieee754/ieee754.h")
|| (! -r "$dir/include/features.h")
|| (! -r "$dir/string/endian.h")
|| (! -r "$dir/include/endian.h")
) {
print "Invalid glibc directory\n";
exit 1;
}
$importNotice="/* See the import.pl script for potential modifications */\n";
# Copy files
system("cp -r $dir/sysdeps/ieee754/flt-32 $dir/sysdeps/ieee754/dbl-64 $dir/sysdeps/ieee754/ldbl-96 .");
if (! -d "headers") {mkdir("headers");}
system("cp -r $dir/math/s_ldexpf.c flt-32");
system("cp -r $dir/math/s_ldexp.c $dir/math/s_nextafter.c dbl-64");
# this ldbl function is actually an alias to the dbl one in the libm. Make a hard copy here.
system("cp -r $dir/math/s_ldexp.c ldbl-96/s_ldexpl.c");
system("cp -r $dir/math/math_private.h $dir/sysdeps/ieee754/ieee754.h $dir/include/features.h $dir/string/endian.h $dir/bits/wchar.h headers/");
# Merge include files
system("cat $dir/include/endian.h >> headers/endian.h");
# remove some routines we don't need
if (-r "ldbl-96/printf_fphex.c") {unlink "ldbl-96/printf_fphex.c";}
if (-r "ldbl-96/strtold_l.c") {unlink "ldbl-96/strtold_l.c";}
if (-r "flt-32/mpn2flt.c") {unlink "flt-32/mpn2flt.c";}
if (-r "dbl-64/mpn2dbl.c") {unlink "dbl-64/mpn2dbl.c";}
if (-r "dbl-64/dbl2mpn.c") {unlink "dbl-64/dbl2mpn.c";}
if (-r "dbl-64/t_exp.c") {unlink "dbl-64/t_exp.c";}
if (-r "ldbl-96/mpn2ldbl.c") {unlink "ldbl-96/mpn2ldbl.c";}
if (-r "ldbl-96/ldbl2mpn.c") {unlink "ldbl-96/ldbl2mpn.c";}
if (-r "ldbl-96/s_nexttoward.c") {unlink "ldbl-96/s_nexttoward.c";}
if (-r "ldbl-96/s_nexttowardf.c") {unlink "ldbl-96/s_nexttowardf.c";}
if (-r "ldbl-96/math_ldbl.h") {unlink "ldbl-96/math_ldbl.h";}
# The float exp in e_expf.c uses doubles internally since revision 1.2 in the libm-ieee754 CVS attic!
# Roll back to the slower, but purely float version, and also overwrite the wrapper by a wraper to the float only version
system("cp -f w_expf.c e_expf.c flt-32");
# convert .c => .cpp for clarity
@filelist = glob("flt-32/*.c dbl-64/*.c ldbl-96/*.c");
foreach $f (@filelist) {
$g = $f;
$g =~ s/\.c$/.cpp/;
rename $f, $g;
}
# create dummy math.h stub
open(FILE, ">headers/math.h");
print FILE <<MATH_H;
/* This file is stub automatically generated by import.pl */
// Include bridge, just in case math_private is not included
#include "../streflop_libm_bridge.h"
MATH_H
close FILE;
# These files in the flt directory use double but could use floats instead
foreach $f ("flt-32/s_cbrtf.cpp", "flt-32/s_llrintf.cpp", "flt-32/s_lrintf.cpp") {
open(FILE,"<$f");
$content = "";
while(<FILE>) {
# replace double by float, OK in these files
s/double/float/g;
$content.=$_;
}
close FILE;
open(FILE,">$f");
print FILE $content;
close FILE;
}
# These files in the dbl directory wrongly use float, long double and float functions
foreach $f ("dbl-64/e_lgamma_r.cpp", "dbl-64/t_exp2.h", "dbl-64/s_llrint.cpp") {
open(FILE,"<$f");
$content = "";
while(<FILE>) {
s/fabsf/fabs/g;
s/float/double/g;
s/long double/double/g;
$content.=$_;
}
close FILE;
open(FILE,">$f");
print FILE $content;
close FILE;
}
# These files in the ldbl directory wrongly use lower precision types
foreach $f ("ldbl-96/e_lgammal_r.cpp", "ldbl-96/s_cbrtl.cpp", "ldbl-96/s_logbl.cpp", "ldbl-96/s_ldexpl.cpp") {
open(FILE,"<$f");
$content = "";
while(<FILE>) {
# do the substitution now
s/long double/Extended/g;
s/\(double\) i;/(long double) i;/g;
s/double (_|v)/long double $1/g;
s/const double factor/const long double factor/g;
s/fabs(?!l)/fabsl$1/g;
s/ldexp(?!l)/ldexpl$1/g;
s/__finite\(/__finitel\(/g;
s/__scalbn\(/__scalbnl\(/g;
$content.=$_;
}
close FILE;
open(FILE,">$f");
print FILE $content;
close FILE;
}
# DOUBLE_FROM_INT_PTR(x) could simply be *reinterpret_cast<double*>(x)
# for basic types, but may use a dedicated factory for Object wrappers
# BaseType is either the same as FloatType for plain old float/double, or it is
# the float/double type when FloatType is an Object wrapper
$xdaccessor=
"inline Double& d() {return DOUBLE_FROM_INT_PTR(&i[0]);}\n"
."inline Double& x() {return DOUBLE_FROM_INT_PTR(&i[0]);}\n"
."inline Double& d(int idx) {return DOUBLE_FROM_INT_PTR(&i[idx*(sizeof(double)/sizeof(i))]);}\n"
."inline Double& x(int idx) {return DOUBLE_FROM_INT_PTR(&i[idx*(sizeof(double)/sizeof(i))]);}\n"
."inline const Double& d() const {return CONST_DOUBLE_FROM_INT_PTR(&i[0]);}\n"
."inline const Double& x() const {return CONST_DOUBLE_FROM_INT_PTR(&i[0]);}\n"
."inline const Double& d(int idx) const {return CONST_DOUBLE_FROM_INT_PTR(&i[idx*(sizeof(double)/sizeof(i))]);}\n"
."inline const Double& x(int idx) const {return CONST_DOUBLE_FROM_INT_PTR(&i[idx*(sizeof(double)/sizeof(i))]);}\n"
;
@filelist = glob("flt-32/* dbl-64/* ldbl-96/*");
foreach $f (@filelist) {
open(FILE,"<$f");
$content = "";
$opened_namespace = 0;
while(<FILE>) {
# remove all system-wide includes
if (/.*?#include(.*?)<sys\/(.*)/) {$_="//".$_;}
# Convert all includes to local files
s/^([ \t]*)#include([ \t]*)<(.*)>(.*)/#$1include$2\"$3\"$4/g;
# fp environment is now handled directly by streflop (and FPUSettings.h)
s/fenv\.h/..\/streflop_libm_bridge.h/g;
# integer types handled by the bridge
s/inttypes\.h/..\/streflop_libm_bridge.h/g;
# get rid of stdlib too
s/stdlib\.h/..\/streflop_libm_bridge.h/g;
# and limits.h
s/limits\.h/..\/streflop_libm_bridge.h/g;
# float.h too
s/float\.h/..\/streflop_libm_bridge.h/g;
# errno.h falls back to system, remove it
s/errno\.h/..\/streflop_libm_bridge.h/g;
# replace all occurences of problematic union fields with objects
# by proper C++ accessors
s/\b(\.d(?!\[)\b|\.d\[(.*?)\])/.d($2)/g;
s/\b(\.x(?!\[)\b|\.x\[(.*?)\])/.x($2)/g;
s/\b(\.f(?!\[)\b|\.f\[(.*?)\])/.f($2)/g; # ieee754.h
s/\b(->d(?!\[)\b|->d\[(.*?)\])/->d($2)/g;
s/\b(->x(?!\[)\b|->x\[(.*?)\])/->x($2)/g;
s/\b(->f(?!\[)\b|->f\[(.*?)\])/->f($2)/g; # ieee754.h
# Some more occurences from arrays of such unions/structs
s/\]\.d\b/].d()/g;
# named field C construct is invalid (C++ would initialize first union member)
# and we replace unions by struct + accessor anyway
s/{ *?.i *?= *?{/{{/g;
# volatile declaration of static const global variables poses problem with the wrapper types
s/volatile //g;
# Now substitute the base types by their Simple/Double/Extended aliases or wrapper
s/long double/Extended/g; # before double
s/\bdouble\b/Double/g;
s/\bfloat\b/Simple/g;
# Replace problematic int += double
s/E(X|Y|Z)(.*?=.*?)ONE/E${1}${2}1/g;
# problematic ?: operator with different types. This simple check catches all problematic occurences
# if (/\?(.*?(\b0\.|\.0).*?:.*?|.*?:.*?(\b0\.|\.0).*?);/) {
# print "$f => ?$1;\n";
# }
if (/\?(.*?):(.*?)\b(0\.0|10\.0|1\.0)\b/) {
my $type = "";
if ($f =~ /flt-32/) {$type = "Simple";}
if ($f =~ /dbl-64/) {$type = "Double";}
if ($f =~ /ldbl-96/) {$type = "Extended";}
s/\?(.*?):(.*?)\b(0\.0|10\.0|1\.0)\b/?$1:$2$type($3)/g;
}
my $type = "";
my $flit = "";
if ($f =~ /flt-32/) {$type = "Simple"; $flit = "f";}
if ($f =~ /dbl-64/) {$type = "Double"; $flit = "";}
if ($f =~ /ldbl-96/) {$type = "Extended"; $flit = "l";}
# replace problematic mixed-type ?: operators where an int and a float are used as arguments, incompatible with wrappers
if (/\?(.*?)\b(0\.0|1\.0)\b(.*?):(.*?)/) {
s/\?(.*?)\b(0\.0|1\.0)\b(.*?):(.*?)/?$1$type($2)$3:$4/g;
}
# These special cases are OK because no other ?: pattern use them in the 3 subdirs
s/\?0:/?Double(0.0):/;
s/:0;/:Double(0.0);/;
# protect the new symbol names by namespace to avoid any conflict with system libm
if (((/#ifdef __STDC__/) || (/.*? (__|mcr|ss32)[a-z,A-Z,_,0-9]*?\(.*?{$/) || (/Double (atan2Mp|atanMp|slow|tanMp|__exp1|__ieee754_remainder|__ieee754_sqrt)/) || (/^(Simple|Double|Extended|void|int)$/) || ((/^#ifdef BIG_ENDI$/) && ($f =~ /(uatan|mpa2|mpexp|atnat|sincos32)/)) || (/^#define MM 5$/) || (/^void __mp(log|sqrt|exp|atan)\(/) || (/^int __(b|mp)ranred\(/)) && ($opened_namespace == 0)) {
$_ = "namespace streflop_libm {\n".$_;
$opened_namespace = 1;
}
# Prevent type promotion for native aliases
# Ex: promotion would cause computations like y = 0.5 * x to be done in double for x,y float, then cast back to float
# We want the whole computation done in float, not temporary switching to double.
# In some case the FPU internal precision is enough to mask the problem, but for SSE for example, the float/double
# are using different instructions and the problem cannot be ignored (in these cases, there are differences from
# soft float implementation)
# Cannot replace by s/blah/$type($1)/g; because of static order initialization fiasco with wrapper types
# So use next best option to use litteral type specification
# => this solves the problem for native types
# => wrappers are OK thanks to the redefinitions of the operators
s/\b((\d+\.\d*|\d*\.\d+)((e|E)[-+]?\d+)?)(f|F|l|L)?\b/$1$flit/g;
$content.=$_;
}
close FILE;
# multi-line spanning regexp
$content =~ s/union ?{(.*?);.*?Double.*?}/struct {\n$xdaccessor$1;}/sg;
# close opened namespace
if ($opened_namespace==1) {
$content .= "}\n";
}
open(FILE,">$f");
print FILE $importNotice;
print FILE $content;
close FILE;
}
# ieee754.h union+accessor
open(FILE,"<headers/ieee754.h");
$content = "";
while(<FILE>) {
# Comment out decls sections
if (/.*?__.*?_DECLS.*/) {$_="//".$_;}
# Convert all includes to local files
s/^([ \t]*)#include([ \t]*)<(.*)>(.*)/#$1include$2\"$3\"$4/g;
# insert our own bridge
if (/^#define _IEEE754_H.*/) {
$_.="#include \"../streflop_libm_bridge.h\"\n\n";
}
# Protect the Simple section by a #define
if (/.*?ieee754_float.*?/) {
$_ = "#if defined(LIBM_COMPILING_FLT32)\n".$_;
}
if (/.*?IEEE754_FLOAT_BIAS.*?/) {
$_ = $_."\n#endif\n";
}
# Protect the Double section by a #define
if (/.*?ieee754_double.*?/) {
$_ = "#if defined(LIBM_COMPILING_DBL64)\n".$_;
}
if (/.*?IEEE754_DOUBLE_BIAS.*?/) {
$_ = $_."\n#endif\n";
}
# Protect the Extended section by a #define
if (/.*?ieee854_long_double.*?/) {
$_ = "#if defined(Extended)\n".$_;
$_ = "#if defined(LIBM_COMPILING_LDBL96)\n".$_;
}
if (/.*?IEEE854_LONG_DOUBLE_BIAS.*?/) {
$_ = $_."\n#endif\n";
$_ = $_."\n#endif\n";
}
$content.=$_;
}
$ieeeAccessorSimple=
"inline Simple& f() {return SIMPLE_FROM_INT_PTR(&storage[0]);}\n"
."inline const Simple& f() const {return CONST_SIMPLE_FROM_INT_PTR(&storage[0]);}\n";
$ieeeAccessorDouble=
"inline Double& d() {return DOUBLE_FROM_INT_PTR(&storage[0]);}\n"
."inline const Double& d() const {return CONST_DOUBLE_FROM_INT_PTR(&storage[0]);}\n";
$ieeeAccessorExtended=
"inline Extended& d() {return EXTENDED_FROM_INT_PTR(&storage[0]);}\n"
."inline const Extended& d() const {return CONST_EXTENDED_FROM_INT_PTR(&storage[0]);}\n";
# multi-line spanning regexp
$content =~ s/union(.*?ieee854_long_double.*?){.*?;/union$1\{\nint storage[sizeof(long double)\/sizeof(int)];\n$ieeeAccessorExtended/sg;
$content =~ s/union(.*?ieee754_double.*?){.*?;/union$1\{\nint storage[sizeof(double)\/sizeof(int)];\n$ieeeAccessorDouble/sg;
$content =~ s/union(.*?ieee754_float.*?){.*?;/union$1\{\nint storage[sizeof(float)\/sizeof(int)];\n$ieeeAccessorSimple/sg;
close FILE;
open(FILE,">headers/ieee754.h");
print FILE $importNotice;
print FILE $content;
close FILE;
# math_private.h needs a special treatement to define the macros for the wrapper objects
# The macros will be defined separately
open(FILE,"<headers/math_private.h");
my $flag=1;
my $precisionMode = "none";
@convert=();
MPRIV_LOOP: while(<FILE>) {
# keep initial lines with header information and #define file protection
# skip all lines defining macros and unions
if (/^#define _MATH_PRIVATE_H_.*/) {
push @convert,$_;
push @convert,"\n/* import.pl: Skipped the macro definitions, keep only the declarations, converted to use streflop types (aliases or wrappers) */\n#include \"../streflop_libm_bridge.h\"\n\nnamespace streflop_libm {\n\n";
# ensure strict separation of precision mode, each one does not have access to the other names
push @convert,"#ifdef LIBM_COMPILING_FLT32\n";
# define wrappers as the libm would do in IEEE754 mode
push @convert,"#define __sqrtf __ieee754_sqrtf\n";
push @convert,"#define fabsf __fabsf\n";
push @convert,"#define copysignf __copysignf\n";
# add missing defines
push @convert,"extern Simple __log1pf(Simple x);\n";
push @convert,"extern Simple __fabsf(Simple x);\n";
push @convert,"extern Simple __atanf(Simple x);\n";
push @convert,"extern Simple __expm1f(Simple x);\n";
push @convert,"extern int __isinff(Simple x);\n";
push @convert,"extern Simple __rintf(Simple x);\n";
push @convert,"extern Simple __cosf(Simple x);\n";
push @convert,"extern void __sincosf (Simple x, Simple *sinx, Simple *cosx);\n";
push @convert,"extern Simple __floorf(Simple x);\n";
push @convert,"extern Simple __scalbnf (Simple x, int n);\n";
push @convert,"extern Simple __frexpf(Simple x, int *eptr);\n";
push @convert,"extern Simple __ldexpf(Simple value, int exp);\n";
push @convert,"extern int __finitef(Simple x);\n";
push @convert,"#endif\n\n";
push @convert,"#ifdef LIBM_COMPILING_DBL64\n";
push @convert,"#define __sqrt __ieee754_sqrt\n";
push @convert,"#define fabs __fabs\n";
push @convert,"#define copysign __copysign\n";
push @convert,"extern Double __log1p(Double x);\n";
push @convert,"extern Double __fabs(Double x);\n";
push @convert,"extern Double atan(Double x);\n";
push @convert,"extern Double __expm1(Double x);\n";
push @convert,"extern int __isinf(Double x);\n";
push @convert,"extern Double __rint(Double x);\n";
push @convert,"extern Double __cos(Double x);\n";
push @convert,"extern void __sincos (Double x, Double *sinx, Double *cosx);\n";
push @convert,"extern Double __floor(Double x);\n";
push @convert,"extern Double __scalbn(Double x, int n);\n";
push @convert,"extern Double __frexp(Double x, int *eptr);\n";
push @convert,"extern Double __ldexp(Double value, int exp);\n";
push @convert,"extern int __finite(Double x);\n";
push @convert,"#endif\n\n";
push @convert,"#ifdef LIBM_COMPILING_LDBL96\n";
push @convert,"#if defined(Extended)\n";
push @convert,"#define fabsl __fabsl\n";
push @convert,"extern Extended __cosl(Extended x);\n";
push @convert,"extern Extended __sinl(Extended x);\n";
push @convert,"extern Extended __fabsl(Extended x);\n";
push @convert,"#endif\n";
push @convert,"#endif\n";
push @convert,"\n";
$flag = 0;
}
if (/^extern(.*)/) {
$flag = 1;
}
if ($flag==0) {next MPRIV_LOOP;}
# Now substitute the base types by their Simple/Double/Extended aliases or wrapper
s/\blong double\b/Extended/g; # before double
s/\bdouble\b/Double/g;
s/\bfloat\b/Simple/g;
# Protect the Extended section by a #define
if (/.*?elementary Extended functions.*?/) {
$_ = "#if defined(Extended)\n".$_;
}
if (/.*?functions of the IBM.*?/) {
$_ = "#endif\n\n".$_;
}
# remove the inline aliases
s/__GNUC_PREREQ \(.*?\)/0/;
# end namespace protection
if (/^#endif.*_MATH_PRIVATE_H_/) {
$_ = "}\n\n".$_;
}
# now insert protection for symbols separation
if (/^extern(.*)/) {
$remline = $1;
if ($remline =~ /Extended/) {
if ($precisionMode ne "Extended") {
if ($precisionMode ne "none") {$_ = "#endif\n".$_;}
$_ = "#ifdef LIBM_COMPILING_LDBL96\n".$_;
$precisionMode = "Extended";
}
}
elsif ($remline =~ /Double/) {
if ($precisionMode ne "Double") {
if ($precisionMode ne "none") {$_ = "#endif\n".$_;}
$_ = "#ifdef LIBM_COMPILING_DBL64\n".$_;
$precisionMode = "Double";
}
}
elsif ($remline =~ /Simple/) {
if ($precisionMode ne "Simple") {
if ($precisionMode ne "none") {$_ = "#endif\n".$_;}
$_ = "#ifdef LIBM_COMPILING_FLT32\n".$_;
$precisionMode = "Simple";
}
}
} else {
$line = $_;
chomp $line;
if (($line =~ /^(\s)*$/) && ($precisionMode ne "none")) {
$_ = "#endif\n".$_;
$precisionMode = "none";
}
}
push @convert,$_;
}
close FILE;
open(FILE,">headers/math_private.h");
print FILE $importNotice;
print FILE @convert;
close FILE;
# features.h is nearly ready, just do not include more external defs
open(FILE,"<headers/features.h");
@convert=();
while(<FILE>) {
# commment out external includes
s,(.*?#.*?include.*),//$1,;
push @convert,$_;
}
close FILE;
open(FILE,">headers/features.h");
print FILE $importNotice;
print FILE @convert;
close FILE;
# headers/endian.h
open(FILE,"<headers/endian.h");
@convert=();
while(<FILE>) {
# change machine specific bits/endian by streflop configuration
if (/<bits\/endian\.h>/) {
s,<bits/endian\.h>,\"../streflop_libm_bridge.h\",;
#keep features.h, but locally
} elsif (/<features\.h>/) {
s,<features\.h>,"features.h",;
} else {
# commment out all other external includes
s,(.*?#.*?include.*),//$1,;
}
#unconditional definition of endian things
if (/defined _LIBC/) {
$_ = "#if 1\n//".$_;
}
push @convert,$_;
}
close FILE;
open(FILE,">headers/endian.h");
print FILE $importNotice;
print FILE @convert;
close FILE;
# include the bridge from mpa.h
open(FILE,"<dbl-64/mpa.h");
$content="#include \"../streflop_libm_bridge.h\"\nnamespace streflop_libm {";
while(<FILE>) {
# special case
s/->d\(\)/->mantissa/g;
$content.=$_;
}
close FILE;
$mpAccessor=
"inline Double& d(int idx) {return mantissa[idx];}\n"
."inline const Double& d(int idx) const {return mantissa[idx];}\n";
# multi-line spanning regexp
$content =~ s/Double d\[(.*?)\].*?} mp_no/Double mantissa[$1];\n$mpAccessor} mp_no/sg;
open(FILE,">dbl-64/mpa.h");
print FILE $content."}\n"; # also close namespace
close FILE;
# Generate specific Makefiles
$parentMakefile="";
foreach $dir ("flt-32", "dbl-64", "ldbl-96") {
@objFiles = glob("$dir/*.cpp");
$parentObjects = "$dir-objects =";
foreach $f (@objFiles) {
$f =~ s/\.cpp$/.o/;
$parentObjects .= " libm/$f";
$f =~ s/^$dir\///;
}
open(FILE, ">$dir/Makefile");
my $DIR = uc($dir);
$DIR =~ s/\-//;
print FILE "# Makefile automatically generated by import.pl\n"
."include ../../Makefile.common\n"
."CPPFLAGS += -I../headers -DLIBM_COMPILING_$DIR=1\n"
."all: @objFiles\n"
."\techo '$dir done!'\n";
close FILE;
$parentMakefile .= $parentObjects."\n\n";
}
# generate Makefile rule in parent directory
@projectFiles = glob("flt-32/* dbl-64/* ldbl-96/* headers/*");
foreach $f (@projectFiles) {$f = " libm/$f";}
open(FILE, ">../Makefile.libm_objects");
print FILE "# Makefile automatically generated by libm/import.pl. Do not edit.\n\n"
.$parentMakefile
."\nlibm-src =";
print FILE @projectFiles;
print FILE "\n";
close FILE;

View File

@@ -0,0 +1,438 @@
/*
This file acts as a bridge between the libm files and streflop.
It replaces the missing type definitions and macros that were defined
by the external files that were included by the libm, so it is now
standalone.
In addition, this allows to wrap the basic types for compiling
the libm, ex, with SoftFloat.
This file is NOT included by the streflop main files, and thus NOT
included by the user programs.
It is included by the libm converted files to produce the streflop binary,
that will be linked by the user program instead of the system libm.
Nicolas Brodu, 2006
Code released according to the GNU Lesser General Public License
*/
#ifndef STREFLOP_LIBM_BRIDGE
#define STREFLOP_LIBM_BRIDGE
// prevent inclusion of the main Math.h file
// => the function symbol are not defined when compiling libm
// => this adds a level of protection, a function inadvertantly using a wrong precision function is detected
#define STREFLOP_MATH_H
// First define our custom types
#include "../streflop.h"
// Export type definitions, etc.
using namespace streflop;
// for int32_t, etc. Assume WORDSIZE is defined by the Makefile.common
#include "../System.h"
#undef __USE_ISOC99
#undef __USE_POSIX
#undef __USE_POSIX2
#undef __USE_POSIX199309
#undef __USE_POSIX199506
#undef __USE_XOPEN
#undef __USE_XOPEN_EXTENDED
#undef __USE_UNIX98
#undef __USE_XOPEN2K
#undef __USE_LARGEFILE
#undef __USE_LARGEFILE64
#undef __USE_FILE_OFFSET64
#undef __USE_BSD
#undef __USE_SVID
#undef __USE_MISC
#undef __USE_GNU
#undef __USE_REENTRANT
#undef __USE_FORTIFY_LEVEL
#undef __FAVOR_BSD
#undef __KERNEL_STRICT_NAMES
#undef weak_alias
#undef strong_alias
#undef hidden_def
#undef libm_hidden_def
#undef INTDEF
#define weak_alias(x,y)
#define strong_alias(x,y)
#define hidden_def(x)
#define libm_hidden_def(x)
#define INTDEF(x)
#define __set_errno(x) do {} while (0)
#define _IEEE_LIBM 1
// u_int32_t is not C99 compliant
typedef streflop::uint32_t u_int32_t;
/////////////////////////////////////////////////////////////////////////////
// Common definitions
/////////////////////////////////////////////////////////////////////////////
// <float.h> is not included, define only these constants that are needed to compile libm
#define FLT_MIN_EXP (-128)
#define FLT_MAX_EXP 127
#define FLT_MANT_DIG 24
#define DBL_MIN_EXP (-1024)
#define DBL_MAX_EXP 1023
#define DBL_MANT_DIG 53
#define LDBL_MANT_DIG 64
#define HUGE_VALF SimplePositiveInfinity
#define HUGE_VAL DoublePositiveInfinity
#define HUGE_VALL ExtendedPositiveInfinity
#define INT_MAX ((-1)>>1)
// Stolen from bits/mathdef.h
#define FP_ILOGB0 (-2147483647)
#define FP_ILOGBNAN 2147483647
namespace streflop_libm {
// No template, only allow this for int types (could use traits, but it's simpler this way)
inline char abs(char x) {return x < 0 ? -x : x;}
inline short abs(short x) {return x < 0 ? -x : x;}
inline int abs(int x) {return x < 0 ? -x : x;}
inline long abs(long x) {return x < 0 ? -x : x;}
inline long long abs(long long x) {return x < 0 ? -x : x;}
inline char MIN(char x, char y) {return x<y ? x : y;}
inline short MIN(short x, short y) {return x<y ? x : y;}
inline int MIN(int x, int y) {return x<y ? x : y;}
inline long MIN(long x, long y) {return x<y ? x : y;}
inline long long MIN(long long x, long long y) {return x<y ? x : y;}
// Compensate lack of Math.h
enum
{
FP_NAN = 0,
FP_INFINITE = 1,
FP_ZERO = 2,
FP_SUBNORMAL = 3,
FP_NORMAL = 4
};
#ifdef LIBM_COMPILING_FLT32
extern int __fpclassifyf(Simple x);
extern int __isnanf(Simple x);
extern int __isinff(Simple x);
inline int fpclassify(Simple x) {return streflop_libm::__fpclassifyf(x);}
inline int isnan(Simple x) {return streflop_libm::__isnanf(x);}
inline int isinf(Simple x) {return streflop_libm::__isinff(x);}
inline int isfinite(Simple x) {return !(isnan(x) || isinf(x));}
inline int isnormal(Simple x) {return fpclassify(x) == FP_NORMAL;}
inline bool isunordered(Simple x, Simple y) {
return (fpclassify(x) == FP_NAN) || (fpclassify (y) == FP_NAN);
}
inline bool isgreater(Simple x, Simple y) {
return (!isunordered(x,y)) && (x > y);
}
inline bool isgreaterequal(Simple x, Simple y) {
return (!isunordered(x,y)) && (x >= y);
}
inline bool isless(Simple x, Simple y) {
return (!isunordered(x,y)) && (x < y);
}
inline bool islessequal(Simple x, Simple y) {
return (!isunordered(x,y)) && (x <= y);
}
inline bool islessgreater(Simple x, Simple y) {
return (!isunordered(x,y)) && ((x < y) || (x > y));
}
extern const Simple SimplePositiveInfinity;
extern const Simple SimpleNegativeInfinity;
extern const Simple SimpleNaN;
#endif
#ifdef LIBM_COMPILING_DBL64
extern int __fpclassify(Double x);
extern int __isnanl(Double x);
extern int __isinf(Double x);
inline int fpclassify(Double x) {return streflop_libm::__fpclassify(x);}
inline int isnan(Double x) {return streflop_libm::__isnanl(x);}
inline int isinf(Double x) {return streflop_libm::__isinf(x);}
inline int isfinite(Double x) {return !(isnan(x) || isinf(x));}
inline int isnormal(Double x) {return fpclassify(x) == FP_NORMAL;}
inline bool isunordered(Double x, Double y) {
return (fpclassify(x) == FP_NAN) || (fpclassify (y) == FP_NAN);
}
inline bool isgreater(Double x, Double y) {
return (!isunordered(x,y)) && (x > y);
}
inline bool isgreaterequal(Double x, Double y) {
return (!isunordered(x,y)) && (x >= y);
}
inline bool isless(Double x, Double y) {
return (!isunordered(x,y)) && (x < y);
}
inline bool islessequal(Double x, Double y) {
return (!isunordered(x,y)) && (x <= y);
}
inline bool islessgreater(Double x, Double y) {
return (!isunordered(x,y)) && ((x < y) || (x > y));
}
extern const Double DoublePositiveInfinity;
extern const Double DoubleNegativeInfinity;
extern const Double DoubleNaN;
#endif
#ifdef LIBM_COMPILING_LDBL96
#ifdef Extended
extern int __fpclassifyl(Extended x);
extern int __isnanl(Extended x);
extern int __isinfl(Extended x);
inline int fpclassify(Extended x) {return streflop_libm::__fpclassifyl(x);}
inline int isnan(Extended x) {return streflop_libm::__isnanl(x);}
inline int isinf(Extended x) {return streflop_libm::__isinfl(x);}
inline int isfinite(Extended x) {return !(isnan(x) || isinf(x));}
inline int isnormal(Extended x) {return fpclassify(x) == FP_NORMAL;}
inline bool isunordered(Extended x, Extended y) {
return (fpclassify(x) == FP_NAN) || (fpclassify (y) == FP_NAN);
}
inline bool isgreater(Extended x, Extended y) {
return (!isunordered(x,y)) && (x > y);
}
inline bool isgreaterequal(Extended x, Extended y) {
return (!isunordered(x,y)) && (x >= y);
}
inline bool isless(Extended x, Extended y) {
return (!isunordered(x,y)) && (x < y);
}
inline bool islessequal(Extended x, Extended y) {
return (!isunordered(x,y)) && (x <= y);
}
inline bool islessgreater(Extended x, Extended y) {
return (!isunordered(x,y)) && ((x < y) || (x > y));
}
extern const Extended ExtendedPositiveInfinity;
extern const Extended ExtendedNegativeInfinity;
extern const Extended ExtendedNaN;
#endif
#endif
}
// eval method is 0 for x87, sse, soft, that is float_t has size float and double_t has size double
#define FLT_EVAL_METHOD 0
// Endianity checking
#if __FLOAT_WORD_ORDER == 1234
#define LOW_WORD_IDX 0
#define HIGH_WORD_IDX 1
#elif __FLOAT_WORD_ORDER == 4321
#define LOW_WORD_IDX 1
#define HIGH_WORD_IDX 0
#else
#error unknown byte order
#endif
#ifdef Extended
// little endian
#if __FLOAT_WORD_ORDER == 1234
/// Little endian is fine, always the same offsets whatever the memory model
template<int N> struct ExtendedConverter {
// Sign and exponent
static inline SizedUnsignedInteger<16>::Type* sexpPtr(Extended* e) {
return reinterpret_cast<SizedUnsignedInteger<16>::Type*>(reinterpret_cast<char*>(e)+8);
}
// Mantissa
static inline SizedUnsignedInteger<32>::Type* mPtr(Extended* e) {
return reinterpret_cast<SizedUnsignedInteger<32>::Type*>(e);
}
};
// Big endian
#elif __FLOAT_WORD_ORDER == 4321
/// Extended is softfloat
template<> struct ExtendedConverter<10> {
// Sign and exponent
static inline SizedUnsignedInteger<16>::Type* sexpPtr(Extended* e) {
return reinterpret_cast<SizedUnsignedInteger<16>::Type*>(e);
}
// Mantissa
static inline SizedUnsignedInteger<32>::Type* mPtr(Extended* e) {
return reinterpret_cast<SizedUnsignedInteger<32>::Type*>(reinterpret_cast<char*>(e)+2);
}
};
/// Default gcc model for x87 - 32 bits (or with -m96bit-long-double)
template<> struct ExtendedConverter<12> {
// Sign and exponent
static inline SizedUnsignedInteger<16>::Type* sexpPtr(Extended* e) {
return reinterpret_cast<SizedUnsignedInteger<16>::Type*>(reinterpret_cast<char*>(e)+2);
}
// Mantissa
static inline SizedUnsignedInteger<32>::Type* mPtr(Extended* e) {
return reinterpret_cast<SizedUnsignedInteger<32>::Type*>(reinterpret_cast<char*>(e)+4);
}
};
/// Default gcc model for x87 - 64 bits (or with -m128bit-long-double)
template<> struct ExtendedConverter<16> {
// Sign and exponent
static inline SizedUnsignedInteger<16>::Type* sexpPtr(Extended* e) {
return reinterpret_cast<SizedUnsignedInteger<16>::Type*>(reinterpret_cast<char*>(e)+6);
}
// Mantissa
static inline SizedUnsignedInteger<32>::Type* mPtr(Extended* e) {
return reinterpret_cast<SizedUnsignedInteger<32>::Type*>(reinterpret_cast<char*>(e)+8);
}
};
#else
#error unknown byte order
#endif
#endif
// Simple
#ifdef LIBM_COMPILING_FLT32
// SSE is best case, always plain types
// X87 uses a wrapper for no denormals case
// First member of struct guaranted aligned at mem location => OK
// Idem for SoftFloat wrapper, though endianity has to be checked explicitly
#define SIMPLE_FROM_INT_PTR(x) *reinterpret_cast<Simple*>(x)
#define CONST_SIMPLE_FROM_INT_PTR(x) *reinterpret_cast<const Simple*>(x)
#define GET_FLOAT_WORD(i,d) \
do { \
Simple f = (d); \
(i) = *reinterpret_cast<streflop::uint32_t*>(&f); \
} while (0)
/* Set a float from a 32 bit int. */
#define SET_FLOAT_WORD(d,i) \
do { \
int ii = (i); \
(d) = *reinterpret_cast<Simple*>(&ii); \
} while (0)
#endif
// Double
#ifdef LIBM_COMPILING_DBL64
#define DOUBLE_FROM_INT_PTR(x) *reinterpret_cast<Double*>(x)
#define CONST_DOUBLE_FROM_INT_PTR(x) *reinterpret_cast<const Double*>(x)
#define EXTRACT_WORDS(ix0,ix1,d) \
do { \
Double f = (d); \
(ix0) = reinterpret_cast<streflop::uint32_t*>(&f)[HIGH_WORD_IDX]; \
(ix1) = reinterpret_cast<streflop::uint32_t*>(&f)[LOW_WORD_IDX]; \
} while (0)
#define GET_HIGH_WORD(i,d) \
do { \
Double f = (d); \
(i) = reinterpret_cast<streflop::uint32_t*>(&f)[HIGH_WORD_IDX]; \
} while (0)
#define GET_LOW_WORD(i,d) \
do { \
Double f = (d); \
(i) = reinterpret_cast<streflop::uint32_t*>(&f)[LOW_WORD_IDX]; \
} while (0)
#define INSERT_WORDS(d,ix0,ix1) \
do { \
Double f; \
reinterpret_cast<streflop::uint32_t*>(&f)[HIGH_WORD_IDX] = (ix0); \
reinterpret_cast<streflop::uint32_t*>(&f)[LOW_WORD_IDX] = (ix1); \
(d) = f; \
} while (0)
#define SET_HIGH_WORD(d,v) \
do { \
Double f = (d); \
reinterpret_cast<streflop::uint32_t*>(&f)[HIGH_WORD_IDX] = (v); \
(d) = f; \
} while (0)
#define SET_LOW_WORD(d,v) \
do { \
Double f = (d); \
reinterpret_cast<streflop::uint32_t*>(&f)[LOW_WORD_IDX] = (v); \
(d) = f; \
} while (0)
#endif
// Extended
#ifdef LIBM_COMPILING_LDBL96
#define EXTENDED_FROM_INT_PTR(x) *reinterpret_cast<Extended*>(x)
#define CONST_EXTENDED_FROM_INT_PTR(x) *reinterpret_cast<const Extended*>(x)
#define GET_LDOUBLE_WORDS(exp,ix0,ix1,d) \
do { \
Extended f = (d); \
(exp) = *ExtendedConverter<sizeof(Extended)>::sexpPtr(&f); \
(ix0) = ExtendedConverter<sizeof(Extended)>::mPtr(&f)[HIGH_WORD_IDX]; \
(ix1) = ExtendedConverter<sizeof(Extended)>::mPtr(&f)[LOW_WORD_IDX]; \
} while (0)
#define SET_LDOUBLE_WORDS(d,exp,ix0,ix1) \
do { \
Extended f; \
*ExtendedConverter<sizeof(Extended)>::sexpPtr(&f) = (exp); \
ExtendedConverter<sizeof(Extended)>::mPtr(&f)[HIGH_WORD_IDX] = (ix0); \
ExtendedConverter<sizeof(Extended)>::mPtr(&f)[LOW_WORD_IDX] = (ix1); \
(d) = f; \
} while (0)
#define GET_LDOUBLE_MSW(v,d) \
do { \
Extended f = (d); \
(v) = ExtendedConverter<sizeof(Extended)>::mPtr(&f)[HIGH_WORD_IDX]; \
} while (0)
#define SET_LDOUBLE_MSW(d,v) \
do { \
Extended f = (d); \
ExtendedConverter<sizeof(Extended)>::mPtr(&f)[HIGH_WORD_IDX] = (v); \
(d) = f; \
} while (0)
#define GET_LDOUBLE_EXP(exp,d) \
do { \
Extended f = (d); \
(exp) = *ExtendedConverter<sizeof(Extended)>::sexpPtr(&f); \
} while (0)
#define SET_LDOUBLE_EXP(d,exp) \
do { \
Extended f = (d); \
*ExtendedConverter<sizeof(Extended)>::sexpPtr(&f) = (exp); \
(d) = f; \
} while (0)
#endif
#ifdef _MSC_VER
// Even if MSVC != STDC, we still need to define it,
// otherwise MSVC chokes on the K&R style function headers.
# define __STDC__
#endif
#endif