17a4a6327SMike Barcroft /*-
2*4d846d26SWarner Losh * SPDX-License-Identifier: BSD-2-Clause
3d915a14eSPedro F. Giffuni *
47a4a6327SMike Barcroft * Copyright (c) 2001 Mike Barcroft <mike@FreeBSD.org>
57a4a6327SMike Barcroft * All rights reserved.
67a4a6327SMike Barcroft *
77a4a6327SMike Barcroft * Redistribution and use in source and binary forms, with or without
87a4a6327SMike Barcroft * modification, are permitted provided that the following conditions
97a4a6327SMike Barcroft * are met:
107a4a6327SMike Barcroft * 1. Redistributions of source code must retain the above copyright
117a4a6327SMike Barcroft * notice, this list of conditions and the following disclaimer.
127a4a6327SMike Barcroft * 2. Redistributions in binary form must reproduce the above copyright
137a4a6327SMike Barcroft * notice, this list of conditions and the following disclaimer in the
147a4a6327SMike Barcroft * documentation and/or other materials provided with the distribution.
157a4a6327SMike Barcroft *
167a4a6327SMike Barcroft * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
177a4a6327SMike Barcroft * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
187a4a6327SMike Barcroft * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
197a4a6327SMike Barcroft * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
207a4a6327SMike Barcroft * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
217a4a6327SMike Barcroft * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
227a4a6327SMike Barcroft * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
237a4a6327SMike Barcroft * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
247a4a6327SMike Barcroft * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
257a4a6327SMike Barcroft * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
267a4a6327SMike Barcroft * SUCH DAMAGE.
277a4a6327SMike Barcroft */
287a4a6327SMike Barcroft
297a4a6327SMike Barcroft #include <inttypes.h>
307a4a6327SMike Barcroft
317a4a6327SMike Barcroft intmax_t
imaxabs(intmax_t j)327a4a6327SMike Barcroft imaxabs(intmax_t j)
337a4a6327SMike Barcroft {
347a4a6327SMike Barcroft return (j < 0 ? -j : j);
357a4a6327SMike Barcroft }
36