Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sagesmc
Path: blob/master/build/pkgs/cephes/patches/bsd.patch
8822 views
1
diff -drNu src.orig/c9x-complex/cgamma.c src/c9x-complex/cgamma.c
2
--- src.orig/c9x-complex/cgamma.c 2010-04-06 11:46:28.000000000 +0200
3
+++ src/c9x-complex/cgamma.c 2013-01-08 15:07:41.335642544 +0100
4
@@ -258,7 +258,7 @@
5
w = clgam(1.0 - x);
6
c = LOGPI - clog( u ) - w;
7
/* Adjust for reduced sine arg. */
8
- cimag(c) += PI * p;
9
+ (double)(__imag__ c = (cimag(c) + PI * p));
10
}
11
goto ldone;
12
}
13
diff -drNu src.orig/c9x-complex/cgammaf.c src/c9x-complex/cgammaf.c
14
--- src.orig/c9x-complex/cgammaf.c 2010-04-06 11:46:28.000000000 +0200
15
+++ src/c9x-complex/cgammaf.c 2013-01-08 15:07:41.343641844 +0100
16
@@ -80,7 +80,7 @@
17
Copyright 1984, 1998 Stephen L. Moshier
18
*/
19
20
-#include <complex.h>
21
+#include "complex.h"
22
#include "mconf.h"
23
24
#define MAXGAM 171.624376956302725
25
@@ -101,8 +101,14 @@
26
static float SQTPI = 2.50662827463100050242f;
27
28
extern float MAXLOGF, MAXNUMF, PIF;
29
-#ifndef ANSIPROT
30
+#ifdef ANSIPROT
31
+extern float sinhf ( float x );
32
+extern float coshf ( float x );
33
+extern float sinf ( float x );
34
+extern float cosf ( float x );
35
+#else
36
float logf(), sinf(), polevlf(), p1evlf(), floorf(), fabsf();
37
+float cosf(), sinhf(), coshf();
38
float complex cpowf(), cexpf(), cabsf();
39
#endif
40
41
@@ -145,6 +151,7 @@
42
{
43
float p, q;
44
float complex c, u;
45
+int k;
46
47
if( fabsf(crealf(x)) > 13.0f )
48
{
49
@@ -152,14 +159,25 @@
50
{
51
q = crealf(x);
52
p = floorf(q);
53
- if( p == q )
54
+ if((p == q ) && (cimag(x) == 0.0f))
55
{
56
cgoverf:
57
mtherr( "cgammaf", OVERFLOW );
58
return( MAXNUMF + I * MAXNUMF);
59
}
60
- c = csinf( PIF * (x - p) );
61
- c = PIF/(c * cgammaf(1.0f - x) );
62
+ /* Compute sin(pi x) */
63
+ k = q - 2.0f * floorf (0.5f * q);
64
+ q = PIF * (q - p);
65
+ p = PIF * cimag(x);
66
+ c = sinf(q) * coshf(p) + cosf(q) * sinhf(p) * I;
67
+ if (k & 1)
68
+ c = -c;
69
+ /* Reflection formula.
70
+ ??? The denominator has been observed to overflow,
71
+ producing a NaN result on a SPARCstation instead of zero.
72
+ Example:
73
+ cgammaf(-19.425196335160404f - 18.188121066880587f*I) */
74
+ c = PIF/(c * cgammaf(1.0f - x));
75
}
76
else
77
{
78
@@ -173,8 +191,8 @@
79
u = x;
80
while( crealf(u) < 13.0f )
81
{
82
- if (crealf(u) == 0.0f)
83
- goto cgoverf;
84
+ if ((crealf(u) == 0.0f) && (cimagf(u) == 0.0f))
85
+ goto cgoverf;
86
c *= u;
87
p += 1.0f;
88
u = x + p;
89
@@ -223,7 +241,7 @@
90
}
91
92
/* Reflection formula -z gamma(-z) gamma(z) = pi / sin(pi z) */
93
-if( crealf(x) < -7.0f )
94
+if((crealf(x) < -7.0f) || (cimagf(x) < -7.0f))
95
{
96
q = crealf(x);
97
p = floorf(q);
98
@@ -247,7 +265,8 @@
99
w = clgamf(1.0f - x);
100
c = LOGPI - clogf( u ) - w;
101
/* Adjust for reduced sine arg. */
102
- cimagf(c) += PIF * p;
103
+ //cimagf(c) += PIF * p;
104
+ (float)(__imag__ c = (cimagf(c) + PIF * p));
105
}
106
goto ldone;
107
}
108
diff -drNu src.orig/c9x-complex/cgammal.c src/c9x-complex/cgammal.c
109
--- src.orig/c9x-complex/cgammal.c 2010-04-06 11:46:28.000000000 +0200
110
+++ src/c9x-complex/cgammal.c 2013-01-08 15:07:41.351641311 +0100
111
@@ -134,8 +134,14 @@
112
static long double SQTPIL = 2.50662827463100050241576528481104525L;
113
114
extern long double MAXLOGL, MAXNUML, PIL;
115
-#ifndef ANSIPROT
116
+#ifdef ANSIPROT
117
+extern long double sinhl ( long double x );
118
+extern long double coshl ( long double x );
119
+extern long double sinl ( long double x );
120
+extern long double cosl ( long double x );
121
+#else
122
long double logl(), sinl(), polevll(), p1evll(), floorl(), fabsl();
123
+long double sinhl(), coshl(), cosl();
124
long double complex cpowl(), cexpl(), cabsl();
125
#endif
126
127
@@ -174,7 +180,7 @@
128
{
129
long double complex c, u;
130
long double p, q;
131
-int cj;
132
+int cj, k;
133
134
cj = 0;
135
if (cimagl(x) < 0.0L)
136
@@ -183,34 +189,41 @@
137
x = conj(x);
138
}
139
140
-q = creall(x);
141
-if( fabsl(q) > NGITER )
142
+if( fabsl(creall(x)) > NGITER )
143
{
144
- if( q < 0.0L )
145
+ if( creall(x) < 0.0L )
146
{
147
+ q = creall(x);
148
p = floorl(q);
149
- if( p == q )
150
+ if(( p == q ) && (cimagl(x) == 0.0L))
151
{
152
mtherr( "cgammal", OVERFLOW );
153
c = MAXNUML + I * MAXNUML;
154
goto gamdone;
155
}
156
- c = csinl( PIL * (x - p) );
157
+ /* c = csinl( PIL * x );*/
158
+ /* Compute sin(pi x) */
159
+ k = q - 2.0L * floorl (0.5L * q);
160
+ q = PIL * (q - p);
161
+ p = PIL * cimagl(x);
162
+ c = sinl(q) * coshl(p) + cosl(q) * sinhl(p) * I;
163
+ if (k & 1)
164
+ c = -c;
165
c = PIL/(c * cgammal(1.0L - x) );
166
+ goto gamdone;
167
}
168
else
169
{
170
- c = cstirfl(x);
171
+ c = cstirfl(x);
172
+ goto gamdone;
173
}
174
- goto gamdone;
175
}
176
-
177
c = 1.0L;
178
p = 0.0L;
179
u = x;
180
while( creall(u) < NGITER )
181
{
182
- if( fabsl (creall(u)) < GSMALL )
183
+ if((fabsl (creall(u)) < GSMALL) && (fabsl (cimagl(u)) < GSMALL))
184
goto small;
185
c *= u;
186
p += 1.0L;
187
@@ -222,7 +235,7 @@
188
189
190
small:
191
-if( creall(x) == 0.0L )
192
+if((creall(x) == 0.0L) && (cimagl(x) == 0.0L))
193
{
194
mtherr( "cgammal", SING );
195
c = MAXNUML + MAXNUML * I;
196
@@ -280,7 +293,7 @@
197
198
/* -z gamma(-z) gamma(z) = pi / sin(pi z) */
199
/* log gamma(z) = log pi - log sin(pi z) - log(-z) - log gamma(-z) */
200
-if( creall(x) < -NLGITER )
201
+if((creall(x) < -NLGITER) || (cimagl(x) < -NLGITER))
202
{
203
q = creall(x);
204
p = floorl(q);
205
@@ -304,7 +317,8 @@
206
w = clgaml(1.0L - x);
207
c = LOGPIL - clogl( u ) - w;
208
/* Adjust for reduced sine arg. */
209
- cimagl(c) += PIL * p;
210
+ //cimagl(c) += PIL * p;
211
+ (long double)(__imag__ c = cimagl(c) + PIL * p);
212
}
213
goto ldone;
214
}
215
diff -drNu src.orig/c9x-complex/complex.h src/c9x-complex/complex.h
216
--- src.orig/c9x-complex/complex.h 2000-02-06 02:39:53.000000000 +0100
217
+++ src/c9x-complex/complex.h 2013-01-08 15:07:41.359640920 +0100
218
@@ -1,126 +1,131 @@
219
-/* This is a C9X complex.h implementation for the GNU C compiler.
220
- It uses GNU extensions such as __complex__, but defines them
221
- so the syntax specified by C9X works.
222
+/*
223
+** Replacement <complex.h> merging host version with cephes functions
224
+*/
225
226
- S. L. Moshier
227
- February, 1997 */
228
+/* Start by using host complex file.
229
+ * This has to come before the following protective #ifdef so that
230
+ * #include "complex.h" is correctly handled. */
231
+#include_next <complex.h>
232
233
+#ifndef __CEPHES_COMPLEX_H
234
+#define __CEPHES_COMPLEX_H
235
236
-/* This may look like something else, but it is really C9X. */
237
+#if defined(__cplusplus)
238
+extern "C" {
239
+#endif
240
241
-/* Use `I' as the imaginary unit.
242
- Initialize complex constants like this:
243
- double complex c = 1.0 + 2.0 * I; */
244
-#define _Imaginary_I (1.0fi)
245
-#define I _Imaginary_I
246
+/* The following content is derived from
247
+ * http://www.opengroup.org/onlinepubs/9699919799/basedefs/complex.h.html
248
+ */
249
+extern double (cabs)(double complex);
250
+extern float (cabsf)(float complex);
251
+extern long double (cabsl)(long double complex);
252
+extern double complex (cacos)(double complex);
253
+extern float complex (cacosf)(float complex);
254
+extern double complex (cacosh)(double complex);
255
+extern float complex (cacoshf)(float complex);
256
+extern long double complex (cacoshl)(long double complex);
257
+extern long double complex (cacosl)(long double complex);
258
+extern double complex (cadd)(double complex a, double complex b); /*ceph*/
259
+extern double (carg)(double complex);
260
+extern float (cargf)(float complex);
261
+extern long double (cargl)(long double complex);
262
+extern double complex (casin)(double complex);
263
+extern float complex (casinf)(float complex);
264
+extern double complex (casinh)(double complex);
265
+extern float complex (casinhf)(float complex);
266
+extern long double complex (casinhl)(long double complex);
267
+extern long double complex (casinl)(long double complex);
268
+extern double complex (catan)(double complex);
269
+extern float complex (catanf)(float complex);
270
+extern double complex (catanh)(double complex);
271
+extern float complex (catanhf)(float complex);
272
+extern long double complex (catanhl)(long double complex);
273
+extern long double complex (catanl)(long double complex);
274
+extern double complex (ccos)(double complex);
275
+extern float complex (ccosf)(float complex);
276
+extern double complex (ccosh)(double complex);
277
+extern float complex (ccoshf)(float complex);
278
+extern long double complex (ccoshl)(long double complex);
279
+extern long double complex (ccosl)(long double complex);
280
+extern double complex (ccot)(double complex z); /*ceph*/
281
+extern float complex (ccotf)(float complex z); /*ceph*/
282
+extern long double complex (ccotl)(long double complex z); /*ceph*/
283
+extern double complex (cdiv)(double complex a, double complex b); /*ceph*/
284
+extern double complex (cexp)(double complex);
285
+extern float complex (cexpf)(float complex);
286
+extern long double complex (cexpl)(long double complex);
287
+extern double complex (cgamma)(double complex z); /*ceph*/
288
+extern float complex (cgammaf)(float complex z); /*ceph*/
289
+extern long double complex (cgammal)(long double complex z); /*ceph*/
290
+extern double (cimag)(double complex);
291
+extern float (cimagf)(float complex);
292
+extern long double (cimagl)(long double complex);
293
+extern double complex (clgam)(double complex z); /*ceph*/
294
+extern float complex (clgamf)(float complex z); /*ceph*/
295
+extern long double complex (clgaml)(long double complex z); /*ceph*/
296
+extern double complex (clog)(double complex);
297
+extern float complex (clogf)(float complex);
298
+extern long double complex (clogl)(long double complex);
299
+extern double complex (cmul)(double complex a, double complex b); /*ceph*/
300
+extern double complex (conj)(double complex);
301
+extern float complex (conjf)(float complex);
302
+extern long double complex (conjl)(long double complex);
303
+extern double complex (cpow)(double complex, double complex);
304
+extern float complex (cpowf)(float complex, float complex);
305
+extern long double complex (cpowl)(long double complex, long double complex);
306
+extern double complex (cproj)(double complex);
307
+extern float complex (cprojf)(float complex);
308
+extern long double complex (cprojl)(long double complex);
309
+extern double (creal)(double complex);
310
+extern float (crealf)(float complex);
311
+extern long double (creall)(long double complex);
312
+extern double complex (csin)(double complex);
313
+extern float complex (csinf)(float complex);
314
+extern double complex (csinh)(double complex);
315
+extern float complex (csinhf)(float complex);
316
+extern long double complex (csinhl)(long double complex);
317
+extern long double complex (csinl)(long double complex);
318
+extern double complex (csqrt)(double complex);
319
+extern float complex (csqrtf)(float complex);
320
+extern long double complex (csqrtl)(long double complex);
321
+extern double complex (csub)(double complex a, double complex b); /*ceph*/
322
+extern double complex (ctan)(double complex);
323
+extern float complex (ctanf)(float complex);
324
+extern double complex (ctanh)(double complex);
325
+extern float complex (ctanhf)(float complex);
326
+extern long double complex (ctanhl)(long double complex);
327
+extern long double complex (ctanl)(long double complex);
328
329
+/* macro versions of some of the above functions, from the cephes complex.h */
330
/* These are not typed in gcc. They preseve the type of the argument. */
331
/* Complex conjugate function. */
332
#define conj(x) (~(x))
333
/* Function to get imaginary part. */
334
-#define cimag(x) (__imag__ (x))
335
+#define cimag(x) (__imag__(x))
336
/* Function to get real part. */
337
-#define creal(x) (__real__ (x))
338
+#define creal(x) (__real__(x))
339
340
-extern double atan2 (double, double);
341
-#define carg(z) (atan2 ((double) cimag (z), (double) creal (z)))
342
+extern double (atan2)(double, double);
343
+#define carg(z) (atan2((double)cimag(z), (double)creal(z)))
344
345
-/* This is the new C language key word.
346
- ... Actually, the key word that the compiler is supposed to reserve
347
- and understand as part of the language is spelled "_Complex" but
348
- gcc understands "__complex__." The macro "complex" is supposed to
349
- exist and expand to _Complex in complex.h. But "_Complex" will seldom
350
- if ever appear in user programs. */
351
-#define complex __complex__
352
-/* Remove this whenever gcc implements _Complex as a key word. */
353
-#define _Complex __complex__
354
+/* There are float and long double sizes, too. */
355
+#define cimagf(x) ((float)__imag__(x))
356
+#define crealf(x) ((float)__real__(x))
357
+extern float (atan2f)(float, float);
358
+#define cargf(z) (atan2f((float)cimag(z), (float)creal(z)))
359
+
360
+#define cimagl(x) ((long double)__imag__(x))
361
+#define creall(x) ((long double)__real__(x))
362
+extern long double (atan2l)(long double, long double);
363
+#define cargl(z) (atan2l((long double)cimag(z), (long double)creal(z)))
364
365
/* These pragmas can't work without a compiler modification. */
366
#define CX_LIMITED_RANGE_ON
367
#define CX_LIMITED_RANGE_OFF
368
#define CX_LIMITED_RANGE_DEFAULT CX_LIMITED_RANGE_ON
369
370
-/* The builtin complex absolute value in gcc currently is unreachable
371
- due to overzealous type checking. */
372
-extern double cabs ( double complex z );
373
-extern double hypot ( double x, double y );
374
-
375
-/* Prototypes for clog.c.
376
- This is how you declare complex things in the new C language. */
377
-extern double complex clog ( double complex z );
378
-extern double complex cexp ( double complex z );
379
-extern double complex csqrt ( double complex z );
380
-extern double complex csin ( double complex z );
381
-extern double complex ccos ( double complex z );
382
-extern double complex ctan ( double complex z );
383
-extern double complex ccot ( double complex z );
384
-extern double complex casin ( double complex z );
385
-extern double complex cacos ( double complex z );
386
-extern double complex catan ( double complex z );
387
-extern double complex csinh ( double complex z );
388
-extern double complex casinh ( double complex z );
389
-extern double complex ccosh ( double complex z );
390
-extern double complex cacosh ( double complex z );
391
-extern double complex ctanh ( double complex z );
392
-extern double complex catanh ( double complex z );
393
-extern double complex cpow (double complex a, double complex z);
394
-
395
-/* These functions might be used if the compiler were to generate
396
- subroutine calls. But their names would be spelled some other way. */
397
-extern double complex cadd ( double complex a, double complex b );
398
-extern double complex csub ( double complex a, double complex b );
399
-extern double complex cmul ( double complex a, double complex b );
400
-extern double complex cdiv ( double complex a, double complex b );
401
-
402
-/* There are float and long double sizes, too. */
403
-#define cimagf(x) ((float) __imag__ (x))
404
-#define crealf(x) ((float) __real__ (x))
405
-extern float atan2f (float, float);
406
-#define cargf(z) (atan2f ((float) cimag (z), (float) creal (z)))
407
-extern float cabsf ( float complex z );
408
-extern float complex clogf ( float complex z );
409
-extern float complex cexpf ( float complex z );
410
-extern float complex csqrtf ( float complex z );
411
-extern float complex csinf ( float complex z );
412
-extern float complex ccosf ( float complex z );
413
-extern float complex ctanf ( float complex z );
414
-extern float complex ccotf ( float complex z );
415
-extern float complex casinf ( float complex z );
416
-extern float complex cacosf ( float complex z );
417
-extern float complex catanf ( float complex z );
418
-extern float complex csinhf ( float complex z );
419
-extern float complex casinhf ( float complex z );
420
-extern float complex ccoshf ( float complex z );
421
-extern float complex cacoshf ( float complex z );
422
-extern float complex ctanhf ( float complex z );
423
-extern float complex catanhf ( float complex z );
424
-extern float complex cpowf (float complex a, float complex z);
425
-
426
-#define cimagl(x) ((long double) __imag__ (x))
427
-#define creall(x) ((long double) __real__ (x))
428
-extern long double atan2l (long double, long double);
429
-#define cargl(z) (atan2l ((long double) cimag (z), (long double) creal (z)))
430
-extern long double cabsl ( long double complex z );
431
-extern long double complex clogl ( long double complex z );
432
-extern long double complex cexpl ( long double complex z );
433
-extern long double complex csqrtl ( long double complex z );
434
-extern long double complex csinl ( long double complex z );
435
-extern long double complex ccosl ( long double complex z );
436
-extern long double complex ctanl ( long double complex z );
437
-extern long double complex ccotl ( long double complex z );
438
-extern long double complex casinl ( long double complex z );
439
-extern long double complex cacosl ( long double complex z );
440
-extern long double complex catanl ( long double complex z );
441
-extern long double complex csinhl ( long double complex z );
442
-extern long double complex casinhl ( long double complex z );
443
-extern long double complex ccoshl ( long double complex z );
444
-extern long double complex cacoshl ( long double complex z );
445
-extern long double complex ctanhl ( long double complex z );
446
-extern long double complex catanhl ( long double complex z );
447
-extern long double complex cpowl (long double complex a, long double complex z);
448
-extern float complex clgamf ( float complex z );
449
-extern double complex clgam ( double complex z );
450
-extern long double complex clgaml ( long double complex z );
451
-extern float complex cgammaf ( float complex z );
452
-extern double complex cgamma ( double complex z );
453
-extern long double complex cgammal ( long double complex z );
454
+#if defined(__cplusplus)
455
+}
456
+#endif
457
+#endif
458
diff -drNu src.orig/c9x-complex/makefile src/c9x-complex/makefile
459
--- src.orig/c9x-complex/makefile 2010-04-06 11:46:28.000000000 +0200
460
+++ src/c9x-complex/makefile 2013-01-08 15:07:41.367640529 +0100
461
@@ -1,17 +1,25 @@
462
# Makefile for C9X complex variables library
463
# Edit endian-ness and computer type properly in mconf.h before compiling.
464
+# For additional test programs see also celefunt.mak.
465
466
-#CC = gcc
467
-CC=/b/gnu/linux/gcc/xgcc -B/b/gnu/linux/gcc/ -I/b/gnu/linux/include
468
+# Caution: the tests contain some references to the cephes math library
469
+# or references to standard float or long double functions that might
470
+# not be available.
471
+# This should be enough to run at least the double precision functions:
472
+LIBS = stubs.o -lm
473
+# These are intended to get the cephes libraries:
474
+#LIBS = -lml -lmd -lmf
475
+#LIBS = ../libml.a ../libmd.a ../libmf.a
476
+
477
+CC = gcc
478
+#CC = /b/gnu/gcc-build/gcc/xgcc -B/b/gnu/gcc-build/gcc/ -I/b/gnu/gcc-build/gcc
479
# For 128-bit wide long double
480
#PRECFLAGS = -DLD128BITS
481
PRECFLAGS =
482
-CFLAGS = $(PRECFLAGS) -g -O2 -Wall
483
-# This should be enough to run at least the double precision functions
484
-#LIBS = stubs.o -lm
485
-# These are intended to get the cephes libraries
486
-LIBS = -lml -lmd -lmf
487
-#LIBS = ../libml.a ../libmd.a ../libmf.a
488
+CFLAGS = $(PRECFLAGS) -I. -g -O2 -Wall
489
+#CFLAGS = $(PRECFLAGS) -I. -g -O1 -Wall
490
+#CFLAGS = $(PRECFLAGS) -I. -g -O0 -Wall
491
+
492
# float precision
493
SFILES = cmplxf.o clogf.o cgammaf.o
494
# double precision
495
@@ -22,7 +30,7 @@
496
LIBMCFILES = $(SFILES) $(DFILES) $(LFILES)
497
498
# mtstf and mtstl test the float and long double functions.
499
-all: libmc.a mtst cvect dccalc mtstf mtstl
500
+all: libmc.a mtst cvect dccalc mtstf whitebxf whitebx
501
502
mtst: mtst.o $(DFILES) stubs.o
503
$(CC) -v -o mtst mtst.o $(DFILES) $(LIBS)
504
@@ -36,8 +44,19 @@
505
cvect: cvect.o clog.o cmplx.o stubs.o
506
$(CC) -o cvect cvect.o clog.o cmplx.o $(LIBS)
507
508
-cvect-nans: cvect-nans.o clog-nans.o cmplx-nans.o
509
- $(CC) -o cvect-nans cvect-nans.o clog-nans.o cmplx-nans.o $(LIBS)
510
+#cvect-nans: cvect-nans.o clog-nans.o cmplx-nans.o
511
+# $(CC) -o cvect-nans cvect-nans.o clog-nans.o cmplx-nans.o $(LIBS)
512
+
513
+whitebxf: whitebxf.o libmc.a
514
+ $(CC) $(CFLAGS) -o whitebxf whitebxf.o libmc.a $(LIBS)
515
+
516
+whitebxf.o: whitebxf.c complex.h
517
+
518
+whitebx: whitebx.o libmc.a
519
+ $(CC) $(CFLAGS) -o whitebx whitebx.o libmc.a $(LIBS)
520
+
521
+whitebx.o: whitebx.c complex.h
522
+
523
524
libmc.a: $(LIBMCFILES)
525
rm -f libmc.a
526
@@ -66,11 +85,13 @@
527
#clog-nans.o: clog-nans.c complex.h protos.h
528
#cmplx-nans.o: cmplx-nans.c complex.h protos.h
529
530
-check: mtst cvect mtstf
531
- -mtstf
532
- -cvect
533
- -mtst
534
- -mtstl
535
+check: mtst cvect mtstf whitebxf whitebx
536
+ -./mtstf
537
+ -./cvect
538
+ -./mtst
539
+ -./whitebxf
540
+ -./whitebx
541
+ echo For additional tests, make -f celefunt.mak
542
543
clean:
544
rm -f *.o
545
@@ -93,11 +114,13 @@
546
rm -f tcsinf
547
rm -f tcsqrt
548
rm -f tcsqrtf
549
+ rm -f whitebxf
550
+ rm -f whitebx
551
552
-zip:
553
- rm -f c9x-complex.zip
554
- rm -f c9x-complex.shar
555
- rm -f c9x-complex.shar.gz
556
- zip c9x-complex.zip *.c *.h *.pat *.doc *.mak makefile read.me
557
- shar *.c *.h *.pat *.doc *.mak makefile read.me > c9x-complex.shar
558
- gzip c9x-complex.shar
559
+#zip:
560
+# rm -f c9x-complex.zip
561
+# rm -f c9x-complex.shar
562
+# rm -f c9x-complex.shar.gz
563
+# zip c9x-complex.zip *.c *.h *.pat *.doc *.mak makefile read.me
564
+# shar *.c *.h *.pat *.doc *.mak makefile read.me > c9x-complex.shar
565
+# gzip c9x-complex.shar
566
diff -drNu src.orig/complex.h src/complex.h
567
--- src.orig/complex.h 2000-02-06 02:39:53.000000000 +0100
568
+++ src/complex.h 2013-01-08 15:07:41.375640150 +0100
569
@@ -1,126 +1,131 @@
570
-/* This is a C9X complex.h implementation for the GNU C compiler.
571
- It uses GNU extensions such as __complex__, but defines them
572
- so the syntax specified by C9X works.
573
+/*
574
+** Replacement <complex.h> merging host version with cephes functions
575
+*/
576
577
- S. L. Moshier
578
- February, 1997 */
579
+/* Start by using host complex file.
580
+ * This has to come before the following protective #ifdef so that
581
+ * #include "complex.h" is correctly handled. */
582
+#include_next <complex.h>
583
584
+#ifndef __CEPHES_COMPLEX_H
585
+#define __CEPHES_COMPLEX_H
586
587
-/* This may look like something else, but it is really C9X. */
588
+#if defined(__cplusplus)
589
+extern "C" {
590
+#endif
591
592
-/* Use `I' as the imaginary unit.
593
- Initialize complex constants like this:
594
- double complex c = 1.0 + 2.0 * I; */
595
-#define _Imaginary_I (1.0fi)
596
-#define I _Imaginary_I
597
+/* The following content is derived from
598
+ * http://www.opengroup.org/onlinepubs/9699919799/basedefs/complex.h.html
599
+ */
600
+extern double (cabs)(double complex);
601
+extern float (cabsf)(float complex);
602
+extern long double (cabsl)(long double complex);
603
+extern double complex (cacos)(double complex);
604
+extern float complex (cacosf)(float complex);
605
+extern double complex (cacosh)(double complex);
606
+extern float complex (cacoshf)(float complex);
607
+extern long double complex (cacoshl)(long double complex);
608
+extern long double complex (cacosl)(long double complex);
609
+extern double complex (cadd)(double complex a, double complex b); /*ceph*/
610
+extern double (carg)(double complex);
611
+extern float (cargf)(float complex);
612
+extern long double (cargl)(long double complex);
613
+extern double complex (casin)(double complex);
614
+extern float complex (casinf)(float complex);
615
+extern double complex (casinh)(double complex);
616
+extern float complex (casinhf)(float complex);
617
+extern long double complex (casinhl)(long double complex);
618
+extern long double complex (casinl)(long double complex);
619
+extern double complex (catan)(double complex);
620
+extern float complex (catanf)(float complex);
621
+extern double complex (catanh)(double complex);
622
+extern float complex (catanhf)(float complex);
623
+extern long double complex (catanhl)(long double complex);
624
+extern long double complex (catanl)(long double complex);
625
+extern double complex (ccos)(double complex);
626
+extern float complex (ccosf)(float complex);
627
+extern double complex (ccosh)(double complex);
628
+extern float complex (ccoshf)(float complex);
629
+extern long double complex (ccoshl)(long double complex);
630
+extern long double complex (ccosl)(long double complex);
631
+extern double complex (ccot)(double complex z); /*ceph*/
632
+extern float complex (ccotf)(float complex z); /*ceph*/
633
+extern long double complex (ccotl)(long double complex z); /*ceph*/
634
+extern double complex (cdiv)(double complex a, double complex b); /*ceph*/
635
+extern double complex (cexp)(double complex);
636
+extern float complex (cexpf)(float complex);
637
+extern long double complex (cexpl)(long double complex);
638
+extern double complex (cgamma)(double complex z); /*ceph*/
639
+extern float complex (cgammaf)(float complex z); /*ceph*/
640
+extern long double complex (cgammal)(long double complex z); /*ceph*/
641
+extern double (cimag)(double complex);
642
+extern float (cimagf)(float complex);
643
+extern long double (cimagl)(long double complex);
644
+extern double complex (clgam)(double complex z); /*ceph*/
645
+extern float complex (clgamf)(float complex z); /*ceph*/
646
+extern long double complex (clgaml)(long double complex z); /*ceph*/
647
+extern double complex (clog)(double complex);
648
+extern float complex (clogf)(float complex);
649
+extern long double complex (clogl)(long double complex);
650
+extern double complex (cmul)(double complex a, double complex b); /*ceph*/
651
+extern double complex (conj)(double complex);
652
+extern float complex (conjf)(float complex);
653
+extern long double complex (conjl)(long double complex);
654
+extern double complex (cpow)(double complex, double complex);
655
+extern float complex (cpowf)(float complex, float complex);
656
+extern long double complex (cpowl)(long double complex, long double complex);
657
+extern double complex (cproj)(double complex);
658
+extern float complex (cprojf)(float complex);
659
+extern long double complex (cprojl)(long double complex);
660
+extern double (creal)(double complex);
661
+extern float (crealf)(float complex);
662
+extern long double (creall)(long double complex);
663
+extern double complex (csin)(double complex);
664
+extern float complex (csinf)(float complex);
665
+extern double complex (csinh)(double complex);
666
+extern float complex (csinhf)(float complex);
667
+extern long double complex (csinhl)(long double complex);
668
+extern long double complex (csinl)(long double complex);
669
+extern double complex (csqrt)(double complex);
670
+extern float complex (csqrtf)(float complex);
671
+extern long double complex (csqrtl)(long double complex);
672
+extern double complex (csub)(double complex a, double complex b); /*ceph*/
673
+extern double complex (ctan)(double complex);
674
+extern float complex (ctanf)(float complex);
675
+extern double complex (ctanh)(double complex);
676
+extern float complex (ctanhf)(float complex);
677
+extern long double complex (ctanhl)(long double complex);
678
+extern long double complex (ctanl)(long double complex);
679
680
+/* macro versions of some of the above functions, from the cephes complex.h */
681
/* These are not typed in gcc. They preseve the type of the argument. */
682
/* Complex conjugate function. */
683
#define conj(x) (~(x))
684
/* Function to get imaginary part. */
685
-#define cimag(x) (__imag__ (x))
686
+#define cimag(x) (__imag__(x))
687
/* Function to get real part. */
688
-#define creal(x) (__real__ (x))
689
+#define creal(x) (__real__(x))
690
691
-extern double atan2 (double, double);
692
-#define carg(z) (atan2 ((double) cimag (z), (double) creal (z)))
693
+extern double (atan2)(double, double);
694
+#define carg(z) (atan2((double)cimag(z), (double)creal(z)))
695
696
-/* This is the new C language key word.
697
- ... Actually, the key word that the compiler is supposed to reserve
698
- and understand as part of the language is spelled "_Complex" but
699
- gcc understands "__complex__." The macro "complex" is supposed to
700
- exist and expand to _Complex in complex.h. But "_Complex" will seldom
701
- if ever appear in user programs. */
702
-#define complex __complex__
703
-/* Remove this whenever gcc implements _Complex as a key word. */
704
-#define _Complex __complex__
705
+/* There are float and long double sizes, too. */
706
+#define cimagf(x) ((float)__imag__(x))
707
+#define crealf(x) ((float)__real__(x))
708
+extern float (atan2f)(float, float);
709
+#define cargf(z) (atan2f((float)cimag(z), (float)creal(z)))
710
+
711
+#define cimagl(x) ((long double)__imag__(x))
712
+#define creall(x) ((long double)__real__(x))
713
+extern long double (atan2l)(long double, long double);
714
+#define cargl(z) (atan2l((long double)cimag(z), (long double)creal(z)))
715
716
/* These pragmas can't work without a compiler modification. */
717
#define CX_LIMITED_RANGE_ON
718
#define CX_LIMITED_RANGE_OFF
719
#define CX_LIMITED_RANGE_DEFAULT CX_LIMITED_RANGE_ON
720
721
-/* The builtin complex absolute value in gcc currently is unreachable
722
- due to overzealous type checking. */
723
-extern double cabs ( double complex z );
724
-extern double hypot ( double x, double y );
725
-
726
-/* Prototypes for clog.c.
727
- This is how you declare complex things in the new C language. */
728
-extern double complex clog ( double complex z );
729
-extern double complex cexp ( double complex z );
730
-extern double complex csqrt ( double complex z );
731
-extern double complex csin ( double complex z );
732
-extern double complex ccos ( double complex z );
733
-extern double complex ctan ( double complex z );
734
-extern double complex ccot ( double complex z );
735
-extern double complex casin ( double complex z );
736
-extern double complex cacos ( double complex z );
737
-extern double complex catan ( double complex z );
738
-extern double complex csinh ( double complex z );
739
-extern double complex casinh ( double complex z );
740
-extern double complex ccosh ( double complex z );
741
-extern double complex cacosh ( double complex z );
742
-extern double complex ctanh ( double complex z );
743
-extern double complex catanh ( double complex z );
744
-extern double complex cpow (double complex a, double complex z);
745
-
746
-/* These functions might be used if the compiler were to generate
747
- subroutine calls. But their names would be spelled some other way. */
748
-extern double complex cadd ( double complex a, double complex b );
749
-extern double complex csub ( double complex a, double complex b );
750
-extern double complex cmul ( double complex a, double complex b );
751
-extern double complex cdiv ( double complex a, double complex b );
752
-
753
-/* There are float and long double sizes, too. */
754
-#define cimagf(x) ((float) __imag__ (x))
755
-#define crealf(x) ((float) __real__ (x))
756
-extern float atan2f (float, float);
757
-#define cargf(z) (atan2f ((float) cimag (z), (float) creal (z)))
758
-extern float cabsf ( float complex z );
759
-extern float complex clogf ( float complex z );
760
-extern float complex cexpf ( float complex z );
761
-extern float complex csqrtf ( float complex z );
762
-extern float complex csinf ( float complex z );
763
-extern float complex ccosf ( float complex z );
764
-extern float complex ctanf ( float complex z );
765
-extern float complex ccotf ( float complex z );
766
-extern float complex casinf ( float complex z );
767
-extern float complex cacosf ( float complex z );
768
-extern float complex catanf ( float complex z );
769
-extern float complex csinhf ( float complex z );
770
-extern float complex casinhf ( float complex z );
771
-extern float complex ccoshf ( float complex z );
772
-extern float complex cacoshf ( float complex z );
773
-extern float complex ctanhf ( float complex z );
774
-extern float complex catanhf ( float complex z );
775
-extern float complex cpowf (float complex a, float complex z);
776
-
777
-#define cimagl(x) ((long double) __imag__ (x))
778
-#define creall(x) ((long double) __real__ (x))
779
-extern long double atan2l (long double, long double);
780
-#define cargl(z) (atan2l ((long double) cimag (z), (long double) creal (z)))
781
-extern long double cabsl ( long double complex z );
782
-extern long double complex clogl ( long double complex z );
783
-extern long double complex cexpl ( long double complex z );
784
-extern long double complex csqrtl ( long double complex z );
785
-extern long double complex csinl ( long double complex z );
786
-extern long double complex ccosl ( long double complex z );
787
-extern long double complex ctanl ( long double complex z );
788
-extern long double complex ccotl ( long double complex z );
789
-extern long double complex casinl ( long double complex z );
790
-extern long double complex cacosl ( long double complex z );
791
-extern long double complex catanl ( long double complex z );
792
-extern long double complex csinhl ( long double complex z );
793
-extern long double complex casinhl ( long double complex z );
794
-extern long double complex ccoshl ( long double complex z );
795
-extern long double complex cacoshl ( long double complex z );
796
-extern long double complex ctanhl ( long double complex z );
797
-extern long double complex catanhl ( long double complex z );
798
-extern long double complex cpowl (long double complex a, long double complex z);
799
-extern float complex clgamf ( float complex z );
800
-extern double complex clgam ( double complex z );
801
-extern long double complex clgaml ( long double complex z );
802
-extern float complex cgammaf ( float complex z );
803
-extern double complex cgamma ( double complex z );
804
-extern long double complex cgammal ( long double complex z );
805
+#if defined(__cplusplus)
806
+}
807
+#endif
808
+#endif
809
diff -drNu src.orig/double/makefile src/double/makefile
810
--- src.orig/double/makefile 2010-04-06 11:46:28.000000000 +0200
811
+++ src/double/makefile 2013-01-08 15:07:41.383639902 +0100
812
@@ -22,7 +22,13 @@
813
tan.o tandg.o tanh.o unity.o yn.o zeta.o zetac.o \
814
sqrt.o floor.o setprec.o mtherr.o
815
816
-all: libmd.a mtst dtestvec monot dcalc paranoia # stamp-timing
817
+all: libmd.a mtst dtestvec monot dcalc # stamp-timing
818
+
819
+check: mtst dtestvec monot dcalc
820
+ ./mtst
821
+ ./dtestvec
822
+ ./monot
823
+ ./dcalc
824
825
stamp-timing: libmd.a mtst time-it
826
time-it "mtst > /dev/null"
827
@@ -86,14 +92,14 @@
828
# $(AS) -o setprec.o setprec.387
829
830
# ELF versions for linux (no underscores)
831
-sqrt.o: sqrtelf.387
832
- $(AS) -o sqrt.o sqrtelf.387
833
+#sqrt.o: sqrtelf.387
834
+# $(AS) -o sqrt.o sqrtelf.387
835
836
#floor.o: floorelf.387
837
# $(AS) -o floor.o floorelf.387
838
839
-setprec.o: setprelf.387
840
- $(AS) -o setprec.o setprelf.387
841
+#setprec.o: setprelf.387
842
+# $(AS) -o setprec.o setprelf.387
843
844
# Motorola 68881. Caution, subroutine return conventions vary.
845
#sqrt.o: sqrt.688
846
diff -drNu src.orig/ldouble/gammal.c src/ldouble/gammal.c
847
--- src.orig/ldouble/gammal.c 2000-05-28 17:21:01.000000000 +0200
848
+++ src/ldouble/gammal.c 2013-01-08 15:07:41.391639726 +0100
849
@@ -6,20 +6,16 @@
850
*
851
* SYNOPSIS:
852
*
853
- * long double x, y, gammal();
854
- * extern int sgngam;
855
+ * long double x, y, tgammal();
856
*
857
- * y = gammal( x );
858
+ * y = tgammal( x );
859
*
860
*
861
*
862
* DESCRIPTION:
863
*
864
* Returns gamma function of the argument. The result is
865
- * correctly signed, and the sign (+1 or -1) is also
866
- * returned in a global (extern) variable named sgngam.
867
- * This variable is also filled in by the logarithmic gamma
868
- * function lgam().
869
+ * correctly signed.
870
*
871
* Arguments |x| <= 13 are reduced by recurrence and the function
872
* approximated by a rational function of degree 7/8 in the
873
@@ -38,7 +34,7 @@
874
* Accuracy for large arguments is dominated by error in powl().
875
*
876
*/
877
-/* lgaml()
878
+/* lgammal()
879
*
880
* Natural logarithm of gamma function
881
*
882
@@ -46,10 +42,10 @@
883
*
884
* SYNOPSIS:
885
*
886
- * long double x, y, lgaml();
887
- * extern int sgngam;
888
+ * long double x, y, lgammal();
889
+ * extern int signgam;
890
*
891
- * y = lgaml( x );
892
+ * y = lgammal( x );
893
*
894
*
895
*
896
@@ -58,7 +54,7 @@
897
* Returns the base e (2.718...) logarithm of the absolute
898
* value of the gamma function of the argument.
899
* The sign (+1 or -1) of the gamma function is returned in a
900
- * global (extern) variable named sgngam.
901
+ * global (extern) variable named signgam.
902
*
903
* For arguments greater than 33, the logarithm of the gamma
904
* function is approximated by the logarithmic version of
905
@@ -90,7 +86,6 @@
906
Copyright 1994 by Stephen L. Moshier
907
*/
908
909
-
910
#include "mconf.h"
911
/*
912
gamma(x+2) = gamma(x+2) P(x)/Q(x)
913
@@ -336,18 +331,18 @@
914
};
915
#endif
916
917
-int sgngaml = 0;
918
-extern int sgngaml;
919
+/*int signgam = 0;*/
920
+extern int signgam;
921
extern long double MAXLOGL, MAXNUML, PIL;
922
/* #define PIL 3.14159265358979323846L */
923
/* #define MAXNUML 1.189731495357231765021263853E4932L */
924
925
#ifdef ANSIPROT
926
extern long double fabsl ( long double );
927
-extern long double lgaml ( long double );
928
+extern long double lgammal ( long double );
929
extern long double logl ( long double );
930
extern long double expl ( long double );
931
-extern long double gammal ( long double );
932
+extern long double tgammal ( long double );
933
extern long double sinl ( long double );
934
extern long double floorl ( long double );
935
extern long double powl ( long double, long double );
936
@@ -357,7 +352,7 @@
937
extern int isfinitel ( long double );
938
static long double stirf ( long double );
939
#else
940
-long double fabsl(), lgaml(), logl(), expl(), gammal(), sinl();
941
+long double fabsl(), lgammal(), logl(), expl(), tgammal(), sinl();
942
long double floorl(), powl(), polevll(), p1evll(), isnanl(), isfinitel();
943
static long double stirf();
944
#endif
945
@@ -403,13 +398,13 @@
946
947
948
949
-long double gammal(x)
950
+long double tgammal(x)
951
long double x;
952
{
953
long double p, q, z;
954
int i;
955
+int signgam = 1;
956
957
-sgngaml = 1;
958
#ifdef NANS
959
if( isnanl(x) )
960
return(NANL);
961
@@ -435,7 +430,7 @@
962
{
963
gamnan:
964
#ifdef NANS
965
- mtherr( "gammal", DOMAIN );
966
+ mtherr( "tgammal", DOMAIN );
967
return (NANL);
968
#else
969
goto goverf;
970
@@ -443,7 +438,7 @@
971
}
972
i = p;
973
if( (i & 1) == 0 )
974
- sgngaml = -1;
975
+ signgam = -1;
976
z = q - p;
977
if( z > 0.5L )
978
{
979
@@ -456,10 +451,10 @@
980
{
981
goverf:
982
#ifdef INFINITIES
983
- return( sgngaml * INFINITYL);
984
+ return( signgam * INFINITYL);
985
#else
986
- mtherr( "gammal", OVERFLOW );
987
- return( sgngaml * MAXNUML);
988
+ mtherr( "tgammal", OVERFLOW );
989
+ return( signgam * MAXNUML);
990
#endif
991
}
992
z = PIL/z;
993
@@ -468,7 +463,7 @@
994
{
995
z = stirf(x);
996
}
997
- return( sgngaml * z );
998
+ return( signgam * z );
999
}
1000
1001
z = 1.0L;
1002
@@ -642,13 +637,13 @@
1003
/* Logarithm of gamma function */
1004
1005
1006
-long double lgaml(x)
1007
+long double lgammal(x)
1008
long double x;
1009
{
1010
long double p, q, w, z, f, nx;
1011
int i;
1012
1013
-sgngaml = 1;
1014
+signgam = 1;
1015
#ifdef NANS
1016
if( isnanl(x) )
1017
return(NANL);
1018
@@ -660,12 +655,12 @@
1019
if( x < -34.0L )
1020
{
1021
q = -x;
1022
- w = lgaml(q); /* note this modifies sgngam! */
1023
+ w = lgammal(q); /* note this modifies signgam! */
1024
p = floorl(q);
1025
if( p == q )
1026
{
1027
#ifdef INFINITIES
1028
- mtherr( "lgaml", SING );
1029
+ mtherr( "lgammal", SING );
1030
return (INFINITYL);
1031
#else
1032
goto loverf;
1033
@@ -673,9 +668,9 @@
1034
}
1035
i = p;
1036
if( (i & 1) == 0 )
1037
- sgngaml = -1;
1038
+ signgam = -1;
1039
else
1040
- sgngaml = 1;
1041
+ signgam = 1;
1042
z = q - p;
1043
if( z > 0.5L )
1044
{
1045
@@ -711,11 +706,11 @@
1046
}
1047
if( z < 0.0L )
1048
{
1049
- sgngaml = -1;
1050
+ signgam = -1;
1051
z = -z;
1052
}
1053
else
1054
- sgngaml = 1;
1055
+ signgam = 1;
1056
if( x == 2.0L )
1057
return( logl(z) );
1058
x = (nx - 2.0L) + f;
1059
@@ -727,10 +722,10 @@
1060
{
1061
loverf:
1062
#ifdef INFINITIES
1063
- return( sgngaml * INFINITYL );
1064
+ return( signgam * INFINITYL );
1065
#else
1066
- mtherr( "lgaml", OVERFLOW );
1067
- return( sgngaml * MAXNUML );
1068
+ mtherr( "lgammal", OVERFLOW );
1069
+ return( signgam * MAXNUML );
1070
#endif
1071
}
1072
1073
@@ -754,11 +749,11 @@
1074
q = z / (x * polevll( x, S, 8 ));
1075
if( q < 0.0L )
1076
{
1077
- sgngaml = -1;
1078
+ signgam = -1;
1079
q = -q;
1080
}
1081
else
1082
- sgngaml = 1;
1083
+ signgam = 1;
1084
q = logl( q );
1085
return(q);
1086
}
1087
diff -drNu src.orig/ldouble/makefile src/ldouble/makefile
1088
--- src.orig/ldouble/makefile 2010-04-06 11:46:28.000000000 +0200
1089
+++ src/ldouble/makefile 2013-01-08 15:07:41.399639696 +0100
1090
@@ -12,11 +12,11 @@
1091
exp10l.o exp2l.o expl.o fdtrl.o gammal.o gdtrl.o igamil.o igaml.o \
1092
incbetl.o incbil.o isnanl.o j0l.o j1l.o jnl.o ldrand.o log10l.o log2l.o \
1093
logl.o nbdtrl.o ndtril.o ndtrl.o pdtrl.o powl.o powil.o sinhl.o sinl.o \
1094
-sqrtl.o stdtrl.o tanhl.o tanl.o unityl.o ynl.o \
1095
+sqrtl.o stdtrl.o tanhl.o tanl.o ynl.o \
1096
floorl.o polevll.o unityl.o mtherr.o
1097
# cmplxl.o clogl.o
1098
1099
-all: mtstl lparanoi lcalc fltestl nantst testvect monotl libml.a
1100
+all: mtstl lcalc fltestl nantst testvect monotl libml.a
1101
1102
mtstl: libml.a mtstl.o $(OBJS)
1103
$(CC) $(CFLAGS) -o mtstl mtstl.o libml.a $(LIBS)
1104
@@ -59,10 +59,10 @@
1105
# ELF versions for linux
1106
#floorl.o: floorlelf.387
1107
# as -o floorl.o floorlelf.387
1108
-sqrtl.o: sqrtlelf.387
1109
- as -o sqrtl.o sqrtlelf.387
1110
-setprec.o: setprelf.387
1111
- as -o setprec.o setprelf.387
1112
+#sqrtl.o: sqrtlelf.387
1113
+# as -o sqrtl.o sqrtlelf.387
1114
+#setprec.o: setprelf.387
1115
+# as -o setprec.o setprelf.387
1116
1117
# 68K routines
1118
# For Sun 3
1119
diff -drNu src.orig/Makefile src/Makefile
1120
--- src.orig/Makefile 1970-01-01 01:00:00.000000000 +0100
1121
+++ src/Makefile 2013-01-08 15:08:01.743638992 +0100
1122
@@ -0,0 +1,68 @@
1123
+# FreeBSD makefile for cephes.
1124
+
1125
+# Build tools
1126
+CC ?= gcc
1127
+LD ?= ld
1128
+CP ?= cp
1129
+INSTALL ?= install
1130
+
1131
+# Intermediate (ar) libraries
1132
+LIBS=c9x-complex/libmc.a double/libmd.a ldouble/libml.a single/libmf.a
1133
+
1134
+all: libm.so
1135
+
1136
+install: libm.so complex.h math.h
1137
+ ${INSTALL} -C -m 644 complex.h math.h "${SAGE_LOCAL}/include"
1138
+ ${INSTALL} -C -m 755 libm.so "${SAGE_LOCAL}/lib"
1139
+
1140
+check:
1141
+ cd c9x-complex && ${MAKE} "CC=${CC}" check
1142
+ cd double && ${MAKE} "CC=${CC}" check
1143
+ cd ldouble && ${MAKE} "CC=${CC}" check
1144
+ cd single && ${MAKE} "CC=${CC}" check
1145
+# cd c9x-complex && ${MAKE} "LIBS=-L.. -rpath .. -lm" "CC=${CC}" check
1146
+# cd double && ${MAKE} "LIBS=-L.. -rpath .. -lm" "CC=${CC}" check
1147
+# cd ldouble && ${MAKE} "LIBS=-L.. -rpath .. -lm" "CC=${CC}" check
1148
+# cd single && ${MAKE} "LIBS=-L.. -rpath .. -lm" "CC=${CC}" check
1149
+# TBD
1150
+
1151
+clean:
1152
+ rm -f libm.so syms.c99 syms.libm syms.wanted
1153
+ cd c9x-complex && ${MAKE} clean
1154
+ cd double && ${MAKE} clean
1155
+ cd ldouble && ${MAKE} clean
1156
+ cd single && ${MAKE} clean
1157
+
1158
+# FreeBSD includes some but not all of the C99 maths functions. Build
1159
+# a "new" libm.so that uses cephes functions to replace the missing ones
1160
+# (listed in syms.wanted) and then fallback to the base libm.so
1161
+libm.so: ${LIBS} syms.wanted
1162
+ ${LD} -shared -o $@ $$(sed 's/^/-u /' syms.wanted) -L/usr/lib -lc -lm \
1163
+ ${LIBS} -lgcc
1164
+
1165
+# List of symbols defined in the FreeBSD base libc.so and libm.so
1166
+# libc.so is included because some math-related functions are in libc.so
1167
+syms.libm: /usr/lib/libc.so /usr/lib/libm.so
1168
+ nm -Dgp $^ | sed 's/^.* //' | sort -uo $@
1169
+
1170
+# List of symbols defined in C99 math.h and complex.h
1171
+# Doing it this way saves having to maintain a second list
1172
+syms.c99: math.h complex.h
1173
+ sed -ne 's/)(.*//' -e '/^extern/s/^.* (//p' $^ | sort -uo $@
1174
+
1175
+# List of symbols in C99 not defined in FreeBSD
1176
+syms.wanted: syms.libm syms.c99
1177
+ comm -23 syms.c99 syms.libm > $@
1178
+
1179
+# Force compilation in PIC mode to allow creation of a shared library
1180
+c9x-complex/libmc.a: c9x-complex/complex.h
1181
+ cd c9x-complex && ${MAKE} "CC=${CC} -DPIC -fpic" libmc.a
1182
+
1183
+double/libmd.a:
1184
+ cd double && ${MAKE} "CC=${CC} -DPIC -fpic" libmd.a
1185
+
1186
+ldouble/libml.a:
1187
+ cd ldouble && ${MAKE} "CC=${CC} -DPIC -fpic" libml.a
1188
+
1189
+single/libmf.a:
1190
+ cd single && ${MAKE} "CC=${CC} -DPIC -fpic" libmf.a
1191
diff -drNu src.orig/math.h src/math.h
1192
--- src.orig/math.h 1970-01-01 01:00:00.000000000 +0100
1193
+++ src/math.h 2013-01-08 15:07:41.407639759 +0100
1194
@@ -0,0 +1,201 @@
1195
+/*
1196
+** Replacement <math.h> merging host version with cephes functions
1197
+*/
1198
+
1199
+/* Start by using host math file.
1200
+ * This has to come before the following protective #ifdef so that
1201
+ * #include "math.h" is correctly handled. */
1202
+#include_next <math.h>
1203
+
1204
+#ifndef __CEPHES_MATH_H
1205
+#define __CEPHES_MATH_H
1206
+
1207
+#if defined(__cplusplus)
1208
+extern "C" {
1209
+#endif
1210
+
1211
+/* The following content is derived from
1212
+ * http://www.opengroup.org/onlinepubs/9699919799/basedefs/math.h.html
1213
+ */
1214
+extern double (acos)(double);
1215
+extern float (acosf)(float);
1216
+extern double (acosh)(double);
1217
+extern float (acoshf)(float);
1218
+extern long double (acoshl)(long double);
1219
+extern long double (acosl)(long double);
1220
+extern double (asin)(double);
1221
+extern float (asinf)(float);
1222
+extern double (asinh)(double);
1223
+extern float (asinhf)(float);
1224
+extern long double (asinhl)(long double);
1225
+extern long double (asinl)(long double);
1226
+extern double (atan)(double);
1227
+extern double (atan2)(double, double);
1228
+extern float (atan2f)(float, float);
1229
+extern long double (atan2l)(long double, long double);
1230
+extern float (atanf)(float);
1231
+extern double (atanh)(double);
1232
+extern float (atanhf)(float);
1233
+extern long double (atanhl)(long double);
1234
+extern long double (atanl)(long double);
1235
+extern double (cbrt)(double);
1236
+extern float (cbrtf)(float);
1237
+extern long double (cbrtl)(long double);
1238
+extern double (ceil)(double);
1239
+extern float (ceilf)(float);
1240
+extern long double (ceill)(long double);
1241
+extern double (copysign)(double, double);
1242
+extern float (copysignf)(float, float);
1243
+extern long double (copysignl)(long double, long double);
1244
+extern double (cos)(double);
1245
+extern float (cosf)(float);
1246
+extern double (cosh)(double);
1247
+extern float (coshf)(float);
1248
+extern long double (coshl)(long double);
1249
+extern long double (cosl)(long double);
1250
+extern double (erf)(double);
1251
+extern double (erfc)(double);
1252
+extern float (erfcf)(float);
1253
+extern long double (erfcl)(long double);
1254
+extern float (erff)(float);
1255
+extern long double (erfl)(long double);
1256
+extern double (exp)(double);
1257
+extern double (exp2)(double);
1258
+extern float (exp2f)(float);
1259
+extern long double (exp2l)(long double);
1260
+extern float (expf)(float);
1261
+extern long double (expl)(long double);
1262
+extern double (expm1)(double);
1263
+extern float (expm1f)(float);
1264
+extern long double (expm1l)(long double);
1265
+extern double (fabs)(double);
1266
+extern float (fabsf)(float);
1267
+extern long double (fabsl)(long double);
1268
+extern double (fdim)(double, double);
1269
+extern float (fdimf)(float, float);
1270
+extern long double (fdiml)(long double, long double);
1271
+extern double (floor)(double);
1272
+extern float (floorf)(float);
1273
+extern long double (floorl)(long double);
1274
+extern double (fma)(double, double, double);
1275
+extern float (fmaf)(float, float, float);
1276
+extern long double (fmal)(long double, long double, long double);
1277
+extern double (fmax)(double, double);
1278
+extern float (fmaxf)(float, float);
1279
+extern long double (fmaxl)(long double, long double);
1280
+extern double (fmin)(double, double);
1281
+extern float (fminf)(float, float);
1282
+extern long double (fminl)(long double, long double);
1283
+extern double (fmod)(double, double);
1284
+extern float (fmodf)(float, float);
1285
+extern long double (fmodl)(long double, long double);
1286
+extern double (frexp)(double, int *);
1287
+extern float (frexpf)(float, int *);
1288
+extern long double (frexpl)(long double, int *);
1289
+extern double (hypot)(double, double);
1290
+extern float (hypotf)(float, float);
1291
+extern long double (hypotl)(long double, long double);
1292
+extern int (ilogb)(double);
1293
+extern int (ilogbf)(float);
1294
+extern int (ilogbl)(long double);
1295
+extern double (j0)(double); /* XSI extension */
1296
+extern double (j1)(double); /* XSI extension */
1297
+extern double (jn)(int, double); /* XSI extension */
1298
+extern double (ldexp)(double, int);
1299
+extern float (ldexpf)(float, int);
1300
+extern long double (ldexpl)(long double, int);
1301
+extern double (lgamma)(double);
1302
+extern float (lgammaf)(float);
1303
+extern long double (lgammal)(long double);
1304
+extern long long (llrint)(double);
1305
+extern long long (llrintf)(float);
1306
+extern long long (llrintl)(long double);
1307
+extern long long (llround)(double);
1308
+extern long long (llroundf)(float);
1309
+extern long long (llroundl)(long double);
1310
+extern double (log)(double);
1311
+extern double (log10)(double);
1312
+extern float (log10f)(float);
1313
+extern long double (log10l)(long double);
1314
+extern double (log1p)(double);
1315
+extern float (log1pf)(float);
1316
+extern long double (log1pl)(long double);
1317
+extern double (log2)(double);
1318
+extern float (log2f)(float);
1319
+extern long double (log2l)(long double);
1320
+extern double (logb)(double);
1321
+extern float (logbf)(float);
1322
+extern long double (logbl)(long double);
1323
+extern float (logf)(float);
1324
+extern long double (logl)(long double);
1325
+extern long (lrint)(double);
1326
+extern long (lrintf)(float);
1327
+extern long (lrintl)(long double);
1328
+extern long (lround)(double);
1329
+extern long (lroundf)(float);
1330
+extern long (lroundl)(long double);
1331
+extern double (modf)(double, double *);
1332
+extern float (modff)(float, float *);
1333
+extern long double (modfl)(long double, long double *);
1334
+extern double (nan)(const char *);
1335
+extern float (nanf)(const char *);
1336
+extern long double (nanl)(const char *);
1337
+extern double (nearbyint)(double);
1338
+extern float (nearbyintf)(float);
1339
+extern long double (nearbyintl)(long double);
1340
+extern double (nextafter)(double, double);
1341
+extern float (nextafterf)(float, float);
1342
+extern long double (nextafterl)(long double, long double);
1343
+extern double (nexttoward)(double, long double);
1344
+extern float (nexttowardf)(float, long double);
1345
+extern long double (nexttowardl)(long double, long double);
1346
+extern double (pow)(double, double);
1347
+extern float (powf)(float, float);
1348
+extern long double (powl)(long double, long double);
1349
+extern double (remainder)(double, double);
1350
+extern float (remainderf)(float, float);
1351
+extern long double (remainderl)(long double, long double);
1352
+extern double (remquo)(double, double, int *);
1353
+extern float (remquof)(float, float, int *);
1354
+extern long double (remquol)(long double, long double, int *);
1355
+extern double (rint)(double);
1356
+extern float (rintf)(float);
1357
+extern long double (rintl)(long double);
1358
+extern double (round)(double);
1359
+extern float (roundf)(float);
1360
+extern long double (roundl)(long double);
1361
+extern double (scalbln)(double, long);
1362
+extern float (scalblnf)(float, long);
1363
+extern long double (scalblnl)(long double, long);
1364
+extern double (scalbn)(double, int);
1365
+extern float (scalbnf)(float, int);
1366
+extern long double (scalbnl)(long double, int);
1367
+extern double (sin)(double);
1368
+extern float (sinf)(float);
1369
+extern double (sinh)(double);
1370
+extern float (sinhf)(float);
1371
+extern long double (sinhl)(long double);
1372
+extern long double (sinl)(long double);
1373
+extern double (sqrt)(double);
1374
+extern float (sqrtf)(float);
1375
+extern long double (sqrtl)(long double);
1376
+extern double (tan)(double);
1377
+extern float (tanf)(float);
1378
+extern double (tanh)(double);
1379
+extern float (tanhf)(float);
1380
+extern long double (tanhl)(long double);
1381
+extern long double (tanl)(long double);
1382
+extern double (tgamma)(double);
1383
+extern float (tgammaf)(float);
1384
+extern long double (tgammal)(long double);
1385
+extern double (trunc)(double);
1386
+extern float (truncf)(float);
1387
+extern long double (truncl)(long double);
1388
+extern double (y0)(double); /* XSI extension */
1389
+extern double (y1)(double); /* XSI extension */
1390
+extern double (yn)(int, double); /* XSI extension */
1391
+
1392
+#if defined(__cplusplus)
1393
+}
1394
+#endif
1395
+#endif
1396
1397