imaxabs.c revision e8031f0a8ed0e45c6d8847c5e09424e66fd34a4b
992413f4053d9470046876b234fe094062b730b7Garrett D'Amore/*
992413f4053d9470046876b234fe094062b730b7Garrett D'Amore * CDDL HEADER START
992413f4053d9470046876b234fe094062b730b7Garrett D'Amore *
992413f4053d9470046876b234fe094062b730b7Garrett D'Amore * The contents of this file are subject to the terms of the
992413f4053d9470046876b234fe094062b730b7Garrett D'Amore * Common Development and Distribution License, Version 1.0 only
992413f4053d9470046876b234fe094062b730b7Garrett D'Amore * (the "License"). You may not use this file except in compliance
992413f4053d9470046876b234fe094062b730b7Garrett D'Amore * with the License.
992413f4053d9470046876b234fe094062b730b7Garrett D'Amore *
992413f4053d9470046876b234fe094062b730b7Garrett D'Amore * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
992413f4053d9470046876b234fe094062b730b7Garrett D'Amore * or http://www.opensolaris.org/os/licensing.
992413f4053d9470046876b234fe094062b730b7Garrett D'Amore * See the License for the specific language governing permissions
992413f4053d9470046876b234fe094062b730b7Garrett D'Amore * and limitations under the License.
992413f4053d9470046876b234fe094062b730b7Garrett D'Amore *
992413f4053d9470046876b234fe094062b730b7Garrett D'Amore * When distributing Covered Code, include this CDDL HEADER in each
992413f4053d9470046876b234fe094062b730b7Garrett D'Amore * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
992413f4053d9470046876b234fe094062b730b7Garrett D'Amore * If applicable, add the following below this CDDL HEADER, with the
992413f4053d9470046876b234fe094062b730b7Garrett D'Amore * fields enclosed by brackets "[]" replaced with your own identifying
992413f4053d9470046876b234fe094062b730b7Garrett D'Amore * information: Portions Copyright [yyyy] [name of copyright owner]
992413f4053d9470046876b234fe094062b730b7Garrett D'Amore *
992413f4053d9470046876b234fe094062b730b7Garrett D'Amore * CDDL HEADER END
992413f4053d9470046876b234fe094062b730b7Garrett D'Amore */
992413f4053d9470046876b234fe094062b730b7Garrett D'Amore
23a1ccea6aac035f084a7a4cdc968687d1b02dafRoger A. Faulkner/*
992413f4053d9470046876b234fe094062b730b7Garrett D'Amore * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
992413f4053d9470046876b234fe094062b730b7Garrett D'Amore * Use is subject to license terms.
992413f4053d9470046876b234fe094062b730b7Garrett D'Amore */
992413f4053d9470046876b234fe094062b730b7Garrett D'Amore
992413f4053d9470046876b234fe094062b730b7Garrett D'Amore#pragma ident "%Z%%M% %I% %E% SMI"
992413f4053d9470046876b234fe094062b730b7Garrett D'Amore
992413f4053d9470046876b234fe094062b730b7Garrett D'Amore#include "synonyms.h"
992413f4053d9470046876b234fe094062b730b7Garrett D'Amore#include <sys/types.h>
992413f4053d9470046876b234fe094062b730b7Garrett D'Amore#include <stdlib.h>
992413f4053d9470046876b234fe094062b730b7Garrett D'Amore
992413f4053d9470046876b234fe094062b730b7Garrett D'Amore/*
992413f4053d9470046876b234fe094062b730b7Garrett D'Amore * Added for SUSv3 standard
992413f4053d9470046876b234fe094062b730b7Garrett D'Amore */
992413f4053d9470046876b234fe094062b730b7Garrett D'Amore
992413f4053d9470046876b234fe094062b730b7Garrett D'Amoreintmax_t
992413f4053d9470046876b234fe094062b730b7Garrett D'Amoreimaxabs(intmax_t arg)
992413f4053d9470046876b234fe094062b730b7Garrett D'Amore{
992413f4053d9470046876b234fe094062b730b7Garrett D'Amore return ((intmax_t)llabs((long long)arg));
992413f4053d9470046876b234fe094062b730b7Garrett D'Amore}
992413f4053d9470046876b234fe094062b730b7Garrett D'Amore
992413f4053d9470046876b234fe094062b730b7Garrett D'Amore#if !defined(_LP64)
992413f4053d9470046876b234fe094062b730b7Garrett D'Amore
992413f4053d9470046876b234fe094062b730b7Garrett D'Amore/*
992413f4053d9470046876b234fe094062b730b7Garrett D'Amore * 32-bit shadow function of imaxabs.
992413f4053d9470046876b234fe094062b730b7Garrett D'Amore * When using the c89 compiler the largest int is 32-bits hence
992413f4053d9470046876b234fe094062b730b7Garrett D'Amore * this function. The pragma redefine_extname in inttypes.h selects
992413f4053d9470046876b234fe094062b730b7Garrett D'Amore * the proper routine at compile time for the user application.
992413f4053d9470046876b234fe094062b730b7Garrett D'Amore * NOTE: this function is only available in the 32-bit library.
992413f4053d9470046876b234fe094062b730b7Garrett D'Amore */
992413f4053d9470046876b234fe094062b730b7Garrett D'Amore
992413f4053d9470046876b234fe094062b730b7Garrett D'Amoreint32_t
992413f4053d9470046876b234fe094062b730b7Garrett D'Amore_imaxabs_c89(int32_t arg)
992413f4053d9470046876b234fe094062b730b7Garrett D'Amore{
992413f4053d9470046876b234fe094062b730b7Garrett D'Amore return (abs(arg));
992413f4053d9470046876b234fe094062b730b7Garrett D'Amore}
992413f4053d9470046876b234fe094062b730b7Garrett D'Amore#endif
992413f4053d9470046876b234fe094062b730b7Garrett D'Amore