1*cac8e449Smatt /* $NetBSD: imaxabs.c,v 1.1 2008/08/04 21:29:27 matt Exp $ */
2*cac8e449Smatt
3*cac8e449Smatt /*-
4*cac8e449Smatt * Copyright (c) 2008 The NetBSD Foundation, Inc.
5*cac8e449Smatt * All rights reserved.
6*cac8e449Smatt *
7*cac8e449Smatt * This code is derived from software contributed to The NetBSD Foundation
8*cac8e449Smatt * by Matt Thomas <matt@3am-software.com>
9*cac8e449Smatt *
10*cac8e449Smatt * Redistribution and use in source and binary forms, with or without
11*cac8e449Smatt * modification, are permitted provided that the following conditions
12*cac8e449Smatt * are met:
13*cac8e449Smatt * 1. Redistributions of source code must retain the above copyright
14*cac8e449Smatt * notice, this list of conditions and the following disclaimer.
15*cac8e449Smatt * 2. Redistributions in binary form must reproduce the above copyright
16*cac8e449Smatt * notice, this list of conditions and the following disclaimer in the
17*cac8e449Smatt * documentation and/or other materials provided with the distribution.
18*cac8e449Smatt *
19*cac8e449Smatt * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20*cac8e449Smatt * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21*cac8e449Smatt * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22*cac8e449Smatt * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23*cac8e449Smatt * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24*cac8e449Smatt * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25*cac8e449Smatt * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26*cac8e449Smatt * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27*cac8e449Smatt * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28*cac8e449Smatt * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29*cac8e449Smatt * POSSIBILITY OF SUCH DAMAGE.
30*cac8e449Smatt */
31*cac8e449Smatt
32*cac8e449Smatt #include <sys/cdefs.h>
33*cac8e449Smatt #if !defined(lint)
34*cac8e449Smatt __RCSID("$NetBSD: imaxabs.c,v 1.1 2008/08/04 21:29:27 matt Exp $");
35*cac8e449Smatt #endif
36*cac8e449Smatt
37*cac8e449Smatt #include "namespace.h"
38*cac8e449Smatt
39*cac8e449Smatt #include <inttypes.h>
40*cac8e449Smatt
41*cac8e449Smatt #ifdef __weak_alias
__weak_alias(imaxabs,_imaxabs)42*cac8e449Smatt __weak_alias(imaxabs, _imaxabs)
43*cac8e449Smatt #endif
44*cac8e449Smatt
45*cac8e449Smatt intmax_t
46*cac8e449Smatt imaxabs(intmax_t i)
47*cac8e449Smatt {
48*cac8e449Smatt return i < 0 ? -i : i;
49*cac8e449Smatt }
50