xref: /minix3/lib/libm/src/w_fmodl.c (revision 84d9c625bfea59e274550651111ae9edfdc40fbd)
1*84d9c625SLionel Sambuc /* @(#)w_fmod.c 5.1 93/09/24 */
2*84d9c625SLionel Sambuc /*
3*84d9c625SLionel Sambuc  * ====================================================
4*84d9c625SLionel Sambuc  * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
5*84d9c625SLionel Sambuc  *
6*84d9c625SLionel Sambuc  * Developed at SunPro, a Sun Microsystems, Inc. business.
7*84d9c625SLionel Sambuc  * Permission to use, copy, modify, and distribute this
8*84d9c625SLionel Sambuc  * software is freely granted, provided that this notice
9*84d9c625SLionel Sambuc  * is preserved.
10*84d9c625SLionel Sambuc  * ====================================================
11*84d9c625SLionel Sambuc  */
12*84d9c625SLionel Sambuc 
13*84d9c625SLionel Sambuc #include <sys/cdefs.h>
14*84d9c625SLionel Sambuc __RCSID("$NetBSD: w_fmodl.c,v 1.4 2013/11/21 13:41:10 martin Exp $");
15*84d9c625SLionel Sambuc 
16*84d9c625SLionel Sambuc /*
17*84d9c625SLionel Sambuc  * wrapper fmodl(x,y)
18*84d9c625SLionel Sambuc  */
19*84d9c625SLionel Sambuc #include "namespace.h"
20*84d9c625SLionel Sambuc 
21*84d9c625SLionel Sambuc #include "math.h"
22*84d9c625SLionel Sambuc #include "math_private.h"
23*84d9c625SLionel Sambuc 
24*84d9c625SLionel Sambuc #ifdef __HAVE_LONG_DOUBLE
25*84d9c625SLionel Sambuc 
26*84d9c625SLionel Sambuc #ifdef __weak_alias
__weak_alias(fmodl,_fmodl)27*84d9c625SLionel Sambuc __weak_alias(fmodl, _fmodl)
28*84d9c625SLionel Sambuc #endif
29*84d9c625SLionel Sambuc 
30*84d9c625SLionel Sambuc long double
31*84d9c625SLionel Sambuc fmodl(long double x, long double y)	/* wrapper fmod */
32*84d9c625SLionel Sambuc {
33*84d9c625SLionel Sambuc #ifdef _IEEE_LIBM
34*84d9c625SLionel Sambuc 	return __ieee754_fmodl(x,y);
35*84d9c625SLionel Sambuc #else
36*84d9c625SLionel Sambuc 	long double z;
37*84d9c625SLionel Sambuc 	z = __ieee754_fmodl(x,y);
38*84d9c625SLionel Sambuc 	if(_LIB_VERSION == _IEEE_ ||isnan(y)||isnan(x)) return z;
39*84d9c625SLionel Sambuc 	if(y==0.0) {
40*84d9c625SLionel Sambuc 	        return __kernel_standard(x,y,227); /* fmod(x,0) */
41*84d9c625SLionel Sambuc 	} else
42*84d9c625SLionel Sambuc 	    return z;
43*84d9c625SLionel Sambuc #endif
44*84d9c625SLionel Sambuc }
45*84d9c625SLionel Sambuc 
46*84d9c625SLionel Sambuc #endif
47