xref: /openbsd-src/lib/libc/arch/arm/gen/fabs.c (revision aeb694e3afa554db8dd44ee8140d036724efada5)
1*aeb694e3Smartynas /*	$OpenBSD: fabs.c,v 1.7 2011/07/08 22:28:33 martynas Exp $	*/
2*aeb694e3Smartynas /*
3*aeb694e3Smartynas  * Copyright (c) 2008 Martynas Venckus <martynas@openbsd.org>
4*aeb694e3Smartynas  *
5*aeb694e3Smartynas  * Permission to use, copy, modify, and distribute this software for any
6*aeb694e3Smartynas  * purpose with or without fee is hereby granted, provided that the above
7*aeb694e3Smartynas  * copyright notice and this permission notice appear in all copies.
8*aeb694e3Smartynas  *
9*aeb694e3Smartynas  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10*aeb694e3Smartynas  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11*aeb694e3Smartynas  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12*aeb694e3Smartynas  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13*aeb694e3Smartynas  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14*aeb694e3Smartynas  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15*aeb694e3Smartynas  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16*aeb694e3Smartynas  */
17*aeb694e3Smartynas 
18*aeb694e3Smartynas #include <sys/cdefs.h>
19*aeb694e3Smartynas #include <sys/types.h>
20*aeb694e3Smartynas #include <machine/ieee.h>
21*aeb694e3Smartynas 
22*aeb694e3Smartynas /*
23*aeb694e3Smartynas  * fabs(d) returns the absolute value of d.
24*aeb694e3Smartynas  */
25*aeb694e3Smartynas double
26*aeb694e3Smartynas fabs(double d)
27*aeb694e3Smartynas {
28*aeb694e3Smartynas 	struct ieee_double *p = (struct ieee_double *)&d;
29*aeb694e3Smartynas 
30*aeb694e3Smartynas 	p->dbl_sign = 0;
31*aeb694e3Smartynas 
32*aeb694e3Smartynas 	return(d);
33*aeb694e3Smartynas }
34*aeb694e3Smartynas 
35*aeb694e3Smartynas __weak_alias(fabsl, fabs);
36