Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
4349 Serge 1
 
2
/*
3
 * ====================================================
4
 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * Developed at SunPro, a Sun Microsystems, Inc. business.
7
 * Permission to use, copy, modify, and distribute this
8
 * software is freely granted, provided that this notice
9
 * is preserved.
10
 * ====================================================
11
 *
12
 */
13
14
 
15
#include 
16
17
 
18
#include 			/* fputs(), stderr */
19
#define	WRITE2(u,v)	fputs(u, stderr)
20
#else	/* !defined(_USE_WRITE) */
21
#include 			/* write */
22
#define	WRITE2(u,v)	write(2, u, v)
23
#undef fflush
24
#endif	/* !defined(_USE_WRITE) */
25
26
 
27
static const double zero = 0.0;	/* used as const */
28
#else
29
static double zero = 0.0;	/* used as const */
30
#endif
31
32
 
33
 * Standard conformance (non-IEEE) on exception cases.
34
 * Mapping:
35
 *	1 -- acos(|x|>1)
36
 *	2 -- asin(|x|>1)
37
 *	3 -- atan2(+-0,+-0)
38
 *	4 -- hypot overflow
39
 *	5 -- cosh overflow
40
 *	6 -- exp overflow
41
 *	7 -- exp underflow
42
 *	8 -- y0(0)
43
 *	9 -- y0(-ve)
44
 *	10-- y1(0)
45
 *	11-- y1(-ve)
46
 *	12-- yn(0)
47
 *	13-- yn(-ve)
48
 *	14-- lgamma(finite) overflow
49
 *	15-- lgamma(-integer)
50
 *	16-- log(0)
51
 *	17-- log(x<0)
52
 *	18-- log10(0)
53
 *	19-- log10(x<0)
54
 *	20-- pow(0.0,0.0)
55
 *	21-- pow(x,y) overflow
56
 *	22-- pow(x,y) underflow
57
 *	23-- pow(0,negative)
58
 *	24-- pow(neg,non-integral)
59
 *	25-- sinh(finite) overflow
60
 *	26-- sqrt(negative)
61
 *      27-- fmod(x,0)
62
 *      28-- remainder(x,0)
63
 *	29-- acosh(x<1)
64
 *	30-- atanh(|x|>1)
65
 *	31-- atanh(|x|=1)
66
 *	32-- scalb overflow
67
 *	33-- scalb underflow
68
 *	34-- j0(|x|>X_TLOSS)
69
 *	35-- y0(x>X_TLOSS)
70
 *	36-- j1(|x|>X_TLOSS)
71
 *	37-- y1(x>X_TLOSS)
72
 *	38-- jn(|x|>X_TLOSS, n)
73
 *	39-- yn(x>X_TLOSS, n)
74
 *	40-- gamma(finite) overflow
75
 *	41-- gamma(-integer)
76
 *	42-- pow(NaN,0.0)
77
 */
78
79
 
80
 
81
	double __kernel_standard(double x, double y, int type)
82
#else
83
	double __kernel_standard(x,y,type)
84
	double x,y; int type;
85
#endif
86
{
87
	struct exception exc;
88
#ifndef HUGE_VAL	/* this is the only routine that uses HUGE_VAL */
89
#define HUGE_VAL inf
90
	double inf = 0.0;
91
92
 
93
#endif
94
95
 
96
        /* (void) fflush(_stdout_r(p)); */
97
#endif
98
	exc.arg1 = x;
99
	exc.arg2 = y;
100
	exc.err = 0;
101
	switch(type) {
102
	    case 1:
103
	    case 101:
104
		/* acos(|x|>1) */
105
		exc.type = DOMAIN;
106
		exc.name = type < 100 ? "acos" : "acosf";
107
		exc.retval = zero;
108
		if (_LIB_VERSION == _POSIX_)
109
		  errno = EDOM;
110
		else if (!matherr(&exc)) {
111
		  /* if(_LIB_VERSION == _SVID_) {
112
		    (void) WRITE2("acos: DOMAIN error\n", 19);
113
		  } */
114
		  errno = EDOM;
115
		}
116
		break;
117
	    case 2:
118
	    case 102:
119
		/* asin(|x|>1) */
120
		exc.type = DOMAIN;
121
		exc.name = type < 100 ? "asin" : "asinf";
122
		exc.retval = zero;
123
		if(_LIB_VERSION == _POSIX_)
124
		  errno = EDOM;
125
		else if (!matherr(&exc)) {
126
		  /* if(_LIB_VERSION == _SVID_) {
127
		    	(void) WRITE2("asin: DOMAIN error\n", 19);
128
		  } */
129
		  errno = EDOM;
130
		}
131
		break;
132
	    case 3:
133
	    case 103:
134
		/* atan2(+-0,+-0) */
135
		exc.arg1 = y;
136
		exc.arg2 = x;
137
		exc.type = DOMAIN;
138
		exc.name = type < 100 ? "atan2" : "atan2f";
139
		exc.retval = zero;
140
		if(_LIB_VERSION == _POSIX_)
141
		  errno = EDOM;
142
		else if (!matherr(&exc)) {
143
		  /* if(_LIB_VERSION == _SVID_) {
144
			(void) WRITE2("atan2: DOMAIN error\n", 20);
145
		      } */
146
		  errno = EDOM;
147
		}
148
		break;
149
	    case 4:
150
	    case 104:
151
		/* hypot(finite,finite) overflow */
152
		exc.type = OVERFLOW;
153
		exc.name = type < 100 ? "hypot" : "hypotf";
154
		if (_LIB_VERSION == _SVID_)
155
		  exc.retval = HUGE;
156
		else
157
		  exc.retval = HUGE_VAL;
158
		if (_LIB_VERSION == _POSIX_)
159
		  errno = ERANGE;
160
		else if (!matherr(&exc)) {
161
			errno = ERANGE;
162
		}
163
		break;
164
	    case 5:
165
	    case 105:
166
		/* cosh(finite) overflow */
167
		exc.type = OVERFLOW;
168
		exc.name = type < 100 ? "cosh" : "coshf";
169
		if (_LIB_VERSION == _SVID_)
170
		  exc.retval = HUGE;
171
		else
172
		  exc.retval = HUGE_VAL;
173
		if (_LIB_VERSION == _POSIX_)
174
		  errno = ERANGE;
175
		else if (!matherr(&exc)) {
176
			errno = ERANGE;
177
		}
178
		break;
179
	    case 6:
180
	    case 106:
181
		/* exp(finite) overflow */
182
		exc.type = OVERFLOW;
183
		exc.name = type < 100 ? "exp" : "expf";
184
		if (_LIB_VERSION == _SVID_)
185
		  exc.retval = HUGE;
186
		else
187
		  exc.retval = HUGE_VAL;
188
		if (_LIB_VERSION == _POSIX_)
189
		  errno = ERANGE;
190
		else if (!matherr(&exc)) {
191
			errno = ERANGE;
192
		}
193
		break;
194
	    case 7:
195
	    case 107:
196
		/* exp(finite) underflow */
197
		exc.type = UNDERFLOW;
198
		exc.name = type < 100 ? "exp" : "expf";
199
		exc.retval = zero;
200
		if (_LIB_VERSION == _POSIX_)
201
		  errno = ERANGE;
202
		else if (!matherr(&exc)) {
203
			errno = ERANGE;
204
		}
205
		break;
206
	    case 8:
207
	    case 108:
208
		/* y0(0) = -inf */
209
		exc.type = DOMAIN;	/* should be SING for IEEE */
210
		exc.name = type < 100 ? "y0" : "y0f";
211
		if (_LIB_VERSION == _SVID_)
212
		  exc.retval = -HUGE;
213
		else
214
		  exc.retval = -HUGE_VAL;
215
		if (_LIB_VERSION == _POSIX_)
216
		  errno = EDOM;
217
		else if (!matherr(&exc)) {
218
		  /* if (_LIB_VERSION == _SVID_) {
219
			(void) WRITE2("y0: DOMAIN error\n", 17);
220
		      } */
221
		  errno = EDOM;
222
		}
223
		break;
224
	    case 9:
225
	    case 109:
226
		/* y0(x<0) = NaN */
227
		exc.type = DOMAIN;
228
		exc.name = type < 100 ? "y0" : "y0f";
229
		if (_LIB_VERSION == _SVID_)
230
		  exc.retval = -HUGE;
231
		else
232
		  exc.retval = -HUGE_VAL;
233
		if (_LIB_VERSION == _POSIX_)
234
		  errno = EDOM;
235
		else if (!matherr(&exc)) {
236
		  /*if (_LIB_VERSION == _SVID_) {
237
			(void) WRITE2("y0: DOMAIN error\n", 17);
238
		      } */
239
		  errno = EDOM;
240
		}
241
		break;
242
	    case 10:
243
	    case 110:
244
		/* y1(0) = -inf */
245
		exc.type = DOMAIN;	/* should be SING for IEEE */
246
		exc.name = type < 100 ? "y1" : "y1f";
247
		if (_LIB_VERSION == _SVID_)
248
		  exc.retval = -HUGE;
249
		else
250
		  exc.retval = -HUGE_VAL;
251
		if (_LIB_VERSION == _POSIX_)
252
		  errno = EDOM;
253
		else if (!matherr(&exc)) {
254
		  /* if (_LIB_VERSION == _SVID_) {
255
			(void) WRITE2("y1: DOMAIN error\n", 17);
256
		      } */
257
		  errno = EDOM;
258
		}
259
		break;
260
	    case 11:
261
	    case 111:
262
		/* y1(x<0) = NaN */
263
		exc.type = DOMAIN;
264
		exc.name = type < 100 ? "y1" : "y1f";
265
		if (_LIB_VERSION == _SVID_)
266
		  exc.retval = -HUGE;
267
		else
268
		  exc.retval = -HUGE_VAL;
269
		if (_LIB_VERSION == _POSIX_)
270
		  errno = EDOM;
271
		else if (!matherr(&exc)) {
272
		  /* if (_LIB_VERSION == _SVID_) {
273
			(void) WRITE2("y1: DOMAIN error\n", 17);
274
		      } */
275
		  errno = EDOM;
276
		}
277
		break;
278
	    case 12:
279
	    case 112:
280
		/* yn(n,0) = -inf */
281
		exc.type = DOMAIN;	/* should be SING for IEEE */
282
		exc.name = type < 100 ? "yn" : "ynf";
283
		if (_LIB_VERSION == _SVID_)
284
		  exc.retval = -HUGE;
285
		else
286
		  exc.retval = -HUGE_VAL;
287
		if (_LIB_VERSION == _POSIX_)
288
		  errno = EDOM;
289
		else if (!matherr(&exc)) {
290
		  /* if (_LIB_VERSION == _SVID_) {
291
			(void) WRITE2("yn: DOMAIN error\n", 17);
292
		      } */
293
		  errno = EDOM;
294
		}
295
		break;
296
	    case 13:
297
	    case 113:
298
		/* yn(x<0) = NaN */
299
		exc.type = DOMAIN;
300
		exc.name = type < 100 ? "yn" : "ynf";
301
		if (_LIB_VERSION == _SVID_)
302
		  exc.retval = -HUGE;
303
		else
304
		  exc.retval = -HUGE_VAL;
305
		if (_LIB_VERSION == _POSIX_)
306
		  errno = EDOM;
307
		else if (!matherr(&exc)) {
308
		  /* if (_LIB_VERSION == _SVID_) {
309
			(void) WRITE2("yn: DOMAIN error\n", 17);
310
		      } */
311
		  errno = EDOM;
312
		}
313
		break;
314
	    case 14:
315
	    case 114:
316
		/* lgamma(finite) overflow */
317
		exc.type = OVERFLOW;
318
		exc.name = type < 100 ? "lgamma" : "lgammaf";
319
                if (_LIB_VERSION == _SVID_)
320
                  exc.retval = HUGE;
321
                else
322
                  exc.retval = HUGE_VAL;
323
                if (_LIB_VERSION == _POSIX_)
324
			errno = ERANGE;
325
                else if (!matherr(&exc)) {
326
                        errno = ERANGE;
327
		}
328
		break;
329
	    case 15:
330
	    case 115:
331
		/* lgamma(-integer) or lgamma(0) */
332
		exc.type = SING;
333
		exc.name = type < 100 ? "lgamma" : "lgammaf";
334
                if (_LIB_VERSION == _SVID_)
335
                  exc.retval = HUGE;
336
                else
337
                  exc.retval = HUGE_VAL;
338
		if (_LIB_VERSION == _POSIX_)
339
		  errno = EDOM;
340
		else if (!matherr(&exc)) {
341
		  /* if (_LIB_VERSION == _SVID_) {
342
			(void) WRITE2("lgamma: SING error\n", 19);
343
		      } */
344
		  errno = EDOM;
345
		}
346
		break;
347
	    case 16:
348
	    case 116:
349
		/* log(0) */
350
		exc.type = SING;
351
		exc.name = type < 100 ? "log" : "logf";
352
		if (_LIB_VERSION == _SVID_)
353
		  exc.retval = -HUGE;
354
		else
355
		  exc.retval = -HUGE_VAL;
356
		if (_LIB_VERSION == _POSIX_)
357
		  errno = ERANGE;
358
		else if (!matherr(&exc)) {
359
		  /* if (_LIB_VERSION == _SVID_) {
360
			(void) WRITE2("log: SING error\n", 16);
361
		      } */
362
		  errno = EDOM;
363
		}
364
		break;
365
	    case 17:
366
	    case 117:
367
		/* log(x<0) */
368
		exc.type = DOMAIN;
369
		exc.name = type < 100 ? "log" : "logf";
370
		if (_LIB_VERSION == _SVID_)
371
		  exc.retval = -HUGE;
372
		else
373
		  exc.retval = -HUGE_VAL;
374
		if (_LIB_VERSION == _POSIX_)
375
		  errno = EDOM;
376
		else if (!matherr(&exc)) {
377
		  /* if (_LIB_VERSION == _SVID_) {
378
			(void) WRITE2("log: DOMAIN error\n", 18);
379
		      } */
380
		  errno = EDOM;
381
		}
382
		break;
383
	    case 18:
384
	    case 118:
385
		/* log10(0) */
386
		exc.type = SING;
387
		exc.name = type < 100 ? "log10" : "log10f";
388
		if (_LIB_VERSION == _SVID_)
389
		  exc.retval = -HUGE;
390
		else
391
		  exc.retval = -HUGE_VAL;
392
		if (_LIB_VERSION == _POSIX_)
393
		  errno = ERANGE;
394
		else if (!matherr(&exc)) {
395
		  /* if (_LIB_VERSION == _SVID_) {
396
			(void) WRITE2("log10: SING error\n", 18);
397
		      } */
398
		  errno = EDOM;
399
		}
400
		break;
401
	    case 19:
402
	    case 119:
403
		/* log10(x<0) */
404
		exc.type = DOMAIN;
405
		exc.name = type < 100 ? "log10" : "log10f";
406
		if (_LIB_VERSION == _SVID_)
407
		  exc.retval = -HUGE;
408
		else
409
		  exc.retval = -HUGE_VAL;
410
		if (_LIB_VERSION == _POSIX_)
411
		  errno = EDOM;
412
		else if (!matherr(&exc)) {
413
		  /* if (_LIB_VERSION == _SVID_) {
414
			(void) WRITE2("log10: DOMAIN error\n", 20);
415
		      } */
416
		  errno = EDOM;
417
		}
418
		break;
419
	    case 20:
420
	    case 120:
421
		/* pow(0.0,0.0) */
422
		/* error only if _LIB_VERSION == _SVID_ */
423
		exc.type = DOMAIN;
424
		exc.name = type < 100 ? "pow" : "powf";
425
		exc.retval = zero;
426
		if (_LIB_VERSION != _SVID_) exc.retval = 1.0;
427
		else if (!matherr(&exc)) {
428
		  /* (void) WRITE2("pow(0,0): DOMAIN error\n", 23); */
429
			errno = EDOM;
430
		}
431
		break;
432
	    case 21:
433
	    case 121:
434
		/* pow(x,y) overflow */
435
		exc.type = OVERFLOW;
436
		exc.name = type < 100 ? "pow" : "powf";
437
		if (_LIB_VERSION == _SVID_) {
438
		  exc.retval = HUGE;
439
		  y *= 0.5;
440
		  if(x
441
		} else {
442
		  exc.retval = HUGE_VAL;
443
		  y *= 0.5;
444
		  if(x
445
		}
446
		if (_LIB_VERSION == _POSIX_)
447
		  errno = ERANGE;
448
		else if (!matherr(&exc)) {
449
			errno = ERANGE;
450
		}
451
		break;
452
	    case 22:
453
	    case 122:
454
		/* pow(x,y) underflow */
455
		exc.type = UNDERFLOW;
456
		exc.name = type < 100 ? "pow" : "powf";
457
		exc.retval =  zero;
458
		if (_LIB_VERSION == _POSIX_)
459
		  errno = ERANGE;
460
		else if (!matherr(&exc)) {
461
			errno = ERANGE;
462
		}
463
		break;
464
	    case 23:
465
	    case 123:
466
		/* 0**neg */
467
		exc.type = DOMAIN;
468
		exc.name = type < 100 ? "pow" : "powf";
469
		if (_LIB_VERSION == _SVID_)
470
		  exc.retval = zero;
471
		else
472
		  exc.retval = -HUGE_VAL;
473
		if (_LIB_VERSION == _POSIX_)
474
		  errno = EDOM;
475
		else if (!matherr(&exc)) {
476
		  /* if (_LIB_VERSION == _SVID_) {
477
			(void) WRITE2("pow(0,neg): DOMAIN error\n", 25);
478
		      } */
479
		  errno = EDOM;
480
		}
481
		break;
482
	    case 24:
483
	    case 124:
484
		/* neg**non-integral */
485
		exc.type = DOMAIN;
486
		exc.name = type < 100 ? "pow" : "powf";
487
		if (_LIB_VERSION == _SVID_)
488
		    exc.retval = zero;
489
		else
490
		    exc.retval = zero/zero;	/* X/Open allow NaN */
491
		if (_LIB_VERSION == _POSIX_)
492
		   errno = EDOM;
493
		else if (!matherr(&exc)) {
494
		  /* if (_LIB_VERSION == _SVID_) {
495
			(void) WRITE2("neg**non-integral: DOMAIN error\n", 32);
496
		      } */
497
		  errno = EDOM;
498
		}
499
		break;
500
	    case 25:
501
	    case 125:
502
		/* sinh(finite) overflow */
503
		exc.type = OVERFLOW;
504
		exc.name = type < 100 ? "sinh" : "sinhf";
505
		if (_LIB_VERSION == _SVID_)
506
		  exc.retval = ( (x>zero) ? HUGE : -HUGE);
507
		else
508
		  exc.retval = ( (x>zero) ? HUGE_VAL : -HUGE_VAL);
509
		if (_LIB_VERSION == _POSIX_)
510
		  errno = ERANGE;
511
		else if (!matherr(&exc)) {
512
			errno = ERANGE;
513
		}
514
		break;
515
	    case 26:
516
	    case 126:
517
		/* sqrt(x<0) */
518
		exc.type = DOMAIN;
519
		exc.name = type < 100 ? "sqrt" : "sqrtf";
520
		if (_LIB_VERSION == _SVID_)
521
		  exc.retval = zero;
522
		else
523
		  exc.retval = zero/zero;
524
		if (_LIB_VERSION == _POSIX_)
525
		  errno = EDOM;
526
		else if (!matherr(&exc)) {
527
		  /* if (_LIB_VERSION == _SVID_) {
528
			(void) WRITE2("sqrt: DOMAIN error\n", 19);
529
		      } */
530
		  errno = EDOM;
531
		}
532
		break;
533
            case 27:
534
	    case 127:
535
                /* fmod(x,0) */
536
                exc.type = DOMAIN;
537
                exc.name = type < 100 ? "fmod" : "fmodf";
538
                if (_LIB_VERSION == _SVID_)
539
                    exc.retval = x;
540
		else
541
		    exc.retval = zero/zero;
542
                if (_LIB_VERSION == _POSIX_)
543
                  errno = EDOM;
544
                else if (!matherr(&exc)) {
545
                  /* if (_LIB_VERSION == _SVID_) {
546
                    (void) WRITE2("fmod:  DOMAIN error\n", 20);
547
                  } */
548
                  errno = EDOM;
549
                }
550
                break;
551
            case 28:
552
	    case 128:
553
                /* remainder(x,0) */
554
                exc.type = DOMAIN;
555
                exc.name = type < 100 ? "remainder" : "remainderf";
556
                exc.retval = zero/zero;
557
                if (_LIB_VERSION == _POSIX_)
558
                  errno = EDOM;
559
                else if (!matherr(&exc)) {
560
                  /* if (_LIB_VERSION == _SVID_) {
561
                    (void) WRITE2("remainder: DOMAIN error\n", 24);
562
                  } */
563
                  errno = EDOM;
564
                }
565
                break;
566
            case 29:
567
	    case 129:
568
                /* acosh(x<1) */
569
                exc.type = DOMAIN;
570
                exc.name = type < 100 ? "acosh" : "acoshf";
571
                exc.retval = zero/zero;
572
                if (_LIB_VERSION == _POSIX_)
573
                  errno = EDOM;
574
                else if (!matherr(&exc)) {
575
                  /* if (_LIB_VERSION == _SVID_) {
576
                    (void) WRITE2("acosh: DOMAIN error\n", 20);
577
                  } */
578
                  errno = EDOM;
579
                }
580
                break;
581
            case 30:
582
	    case 130:
583
                /* atanh(|x|>1) */
584
                exc.type = DOMAIN;
585
                exc.name = type < 100 ? "atanh" : "atanhf";
586
                exc.retval = zero/zero;
587
                if (_LIB_VERSION == _POSIX_)
588
                  errno = EDOM;
589
                else if (!matherr(&exc)) {
590
                  /* if (_LIB_VERSION == _SVID_) {
591
                    (void) WRITE2("atanh: DOMAIN error\n", 20);
592
                  } */
593
                  errno = EDOM;
594
                }
595
                break;
596
            case 31:
597
	    case 131:
598
                /* atanh(|x|=1) */
599
                exc.type = SING;
600
                exc.name = type < 100 ? "atanh" : "atanhf";
601
		exc.retval = x/zero;	/* sign(x)*inf */
602
                if (_LIB_VERSION == _POSIX_)
603
                  errno = EDOM;
604
                else if (!matherr(&exc)) {
605
                  /* if (_LIB_VERSION == _SVID_) {
606
                    (void) WRITE2("atanh: SING error\n", 18);
607
                  } */
608
                  errno = EDOM;
609
                }
610
                break;
611
	    case 32:
612
	    case 132:
613
		/* scalb overflow; SVID also returns +-HUGE_VAL */
614
		exc.type = OVERFLOW;
615
		exc.name = type < 100 ? "scalb" : "scalbf";
616
		exc.retval = x > zero ? HUGE_VAL : -HUGE_VAL;
617
		if (_LIB_VERSION == _POSIX_)
618
		  errno = ERANGE;
619
		else if (!matherr(&exc)) {
620
			errno = ERANGE;
621
		}
622
		break;
623
	    case 33:
624
	    case 133:
625
		/* scalb underflow */
626
		exc.type = UNDERFLOW;
627
		exc.name = type < 100 ? "scalb" : "scalbf";
628
		exc.retval = copysign(zero,x);
629
		if (_LIB_VERSION == _POSIX_)
630
		  errno = ERANGE;
631
		else if (!matherr(&exc)) {
632
			errno = ERANGE;
633
		}
634
		break;
635
	    case 34:
636
	    case 134:
637
		/* j0(|x|>X_TLOSS) */
638
                exc.type = TLOSS;
639
                exc.name = type < 100 ? "j0" : "j0f";
640
                exc.retval = zero;
641
                if (_LIB_VERSION == _POSIX_)
642
                        errno = ERANGE;
643
                else if (!matherr(&exc)) {
644
		  /* if (_LIB_VERSION == _SVID_) {
645
                                (void) WRITE2(exc.name, 2);
646
                                (void) WRITE2(": TLOSS error\n", 14);
647
                        } */
648
                        errno = ERANGE;
649
                }
650
		break;
651
	    case 35:
652
	    case 135:
653
		/* y0(x>X_TLOSS) */
654
                exc.type = TLOSS;
655
                exc.name = type < 100 ? "y0" : "y0f";
656
                exc.retval = zero;
657
                if (_LIB_VERSION == _POSIX_)
658
                        errno = ERANGE;
659
                else if (!matherr(&exc)) {
660
		  /* if (_LIB_VERSION == _SVID_) {
661
                                (void) WRITE2(exc.name, 2);
662
                                (void) WRITE2(": TLOSS error\n", 14);
663
                        } */
664
                        errno = ERANGE;
665
                }
666
		break;
667
	    case 36:
668
	    case 136:
669
		/* j1(|x|>X_TLOSS) */
670
                exc.type = TLOSS;
671
                exc.name = type < 100 ? "j1" : "j1f";
672
                exc.retval = zero;
673
                if (_LIB_VERSION == _POSIX_)
674
                        errno = ERANGE;
675
                else if (!matherr(&exc)) {
676
		  /* if (_LIB_VERSION == _SVID_) {
677
                                (void) WRITE2(exc.name, 2);
678
                                (void) WRITE2(": TLOSS error\n", 14);
679
                        } */
680
                        errno = ERANGE;
681
                }
682
		break;
683
	    case 37:
684
	    case 137:
685
		/* y1(x>X_TLOSS) */
686
                exc.type = TLOSS;
687
                exc.name = type < 100 ? "y1" : "y1f";
688
                exc.retval = zero;
689
                if (_LIB_VERSION == _POSIX_)
690
                        errno = ERANGE;
691
                else if (!matherr(&exc)) {
692
		  /* if (_LIB_VERSION == _SVID_) {
693
                                (void) WRITE2(exc.name, 2);
694
                                (void) WRITE2(": TLOSS error\n", 14);
695
                        } */
696
                        errno = ERANGE;
697
                }
698
		break;
699
	    case 38:
700
	    case 138:
701
		/* jn(|x|>X_TLOSS) */
702
                exc.type = TLOSS;
703
                exc.name = type < 100 ? "jn" : "jnf";
704
                exc.retval = zero;
705
                if (_LIB_VERSION == _POSIX_)
706
                        errno = ERANGE;
707
                else if (!matherr(&exc)) {
708
		  /* if (_LIB_VERSION == _SVID_) {
709
                                (void) WRITE2(exc.name, 2);
710
                                (void) WRITE2(": TLOSS error\n", 14);
711
                        } */
712
                        errno = ERANGE;
713
                }
714
		break;
715
	    case 39:
716
	    case 139:
717
		/* yn(x>X_TLOSS) */
718
                exc.type = TLOSS;
719
                exc.name = type < 100 ? "yn" : "ynf";
720
                exc.retval = zero;
721
                if (_LIB_VERSION == _POSIX_)
722
                        errno = ERANGE;
723
                else if (!matherr(&exc)) {
724
		  /* if (_LIB_VERSION == _SVID_) {
725
                                (void) WRITE2(exc.name, 2);
726
                                (void) WRITE2(": TLOSS error\n", 14);
727
                        } */
728
                        errno = ERANGE;
729
                }
730
		break;
731
	    case 40:
732
	    case 140:
733
		/* gamma(finite) overflow */
734
		exc.type = OVERFLOW;
735
		exc.name = type < 100 ? "gamma" : "gammaf";
736
                if (_LIB_VERSION == _SVID_)
737
                  exc.retval = HUGE;
738
                else
739
                  exc.retval = HUGE_VAL;
740
                if (_LIB_VERSION == _POSIX_)
741
		  errno = ERANGE;
742
                else if (!matherr(&exc)) {
743
                  errno = ERANGE;
744
                }
745
		break;
746
	    case 41:
747
	    case 141:
748
		/* gamma(-integer) or gamma(0) */
749
		exc.type = SING;
750
		exc.name = type < 100 ? "gamma" : "gammaf";
751
                if (_LIB_VERSION == _SVID_)
752
                  exc.retval = HUGE;
753
                else
754
                  exc.retval = HUGE_VAL;
755
		if (_LIB_VERSION == _POSIX_)
756
		  errno = EDOM;
757
		else if (!matherr(&exc)) {
758
		  /* if (_LIB_VERSION == _SVID_) {
759
			(void) WRITE2("gamma: SING error\n", 18);
760
		      } */
761
		  errno = EDOM;
762
		}
763
		break;
764
	    case 42:
765
	    case 142:
766
		/* pow(NaN,0.0) */
767
		/* error only if _LIB_VERSION == _SVID_ & _XOPEN_ */
768
		exc.type = DOMAIN;
769
		exc.name = type < 100 ? "pow" : "powf";
770
		exc.retval = x;
771
		if (_LIB_VERSION == _IEEE_ ||
772
		    _LIB_VERSION == _POSIX_) exc.retval = 1.0;
773
		else if (!matherr(&exc)) {
774
			errno = EDOM;
775
		}
776
		break;
777
	}
778
	if (exc.err != 0)
779
	    errno = exc.err;
780
	return exc.retval;
781
}
782
>
783
 
784