xref: /minix3/lib/libm/src/w_fmod.c (revision 84d9c625bfea59e274550651111ae9edfdc40fbd)
12fe8fb19SBen Gras /* @(#)w_fmod.c 5.1 93/09/24 */
22fe8fb19SBen Gras /*
32fe8fb19SBen Gras  * ====================================================
42fe8fb19SBen Gras  * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
52fe8fb19SBen Gras  *
62fe8fb19SBen Gras  * Developed at SunPro, a Sun Microsystems, Inc. business.
72fe8fb19SBen Gras  * Permission to use, copy, modify, and distribute this
82fe8fb19SBen Gras  * software is freely granted, provided that this notice
92fe8fb19SBen Gras  * is preserved.
102fe8fb19SBen Gras  * ====================================================
112fe8fb19SBen Gras  */
122fe8fb19SBen Gras 
132fe8fb19SBen Gras #include <sys/cdefs.h>
142fe8fb19SBen Gras #if defined(LIBM_SCCS) && !defined(lint)
15*84d9c625SLionel Sambuc __RCSID("$NetBSD: w_fmod.c,v 1.10 2013/11/12 16:48:39 joerg Exp $");
162fe8fb19SBen Gras #endif
172fe8fb19SBen Gras 
182fe8fb19SBen Gras /*
192fe8fb19SBen Gras  * wrapper fmod(x,y)
202fe8fb19SBen Gras  */
212fe8fb19SBen Gras 
222fe8fb19SBen Gras #include "math.h"
232fe8fb19SBen Gras #include "math_private.h"
242fe8fb19SBen Gras 
25*84d9c625SLionel Sambuc #ifndef __HAVE_LONG_DOUBLE
__strong_alias(_fmodl,fmod)26*84d9c625SLionel Sambuc __strong_alias(_fmodl, fmod)
27*84d9c625SLionel Sambuc __weak_alias(fmodl, fmod)
28*84d9c625SLionel Sambuc #endif
292fe8fb19SBen Gras 
302fe8fb19SBen Gras double
312fe8fb19SBen Gras fmod(double x, double y)	/* wrapper fmod */
322fe8fb19SBen Gras {
332fe8fb19SBen Gras #ifdef _IEEE_LIBM
342fe8fb19SBen Gras 	return __ieee754_fmod(x,y);
352fe8fb19SBen Gras #else
362fe8fb19SBen Gras 	double z;
372fe8fb19SBen Gras 	z = __ieee754_fmod(x,y);
382fe8fb19SBen Gras 	if(_LIB_VERSION == _IEEE_ ||isnan(y)||isnan(x)) return z;
392fe8fb19SBen Gras 	if(y==0.0) {
402fe8fb19SBen Gras 	        return __kernel_standard(x,y,27); /* fmod(x,0) */
412fe8fb19SBen Gras 	} else
422fe8fb19SBen Gras 	    return z;
432fe8fb19SBen Gras #endif
442fe8fb19SBen Gras }
45