Add C99 functions imaxabs and imaxdiv.
This commit is contained in:
parent
7ab651d699
commit
cac8e44915
|
@ -1,5 +1,5 @@
|
|||
# $NetBSD: Makefile.inc,v 1.3 2006/03/22 22:03:58 drochner Exp $
|
||||
# $NetBSD: Makefile.inc,v 1.4 2008/08/04 21:29:28 matt Exp $
|
||||
|
||||
SRCS+= abs.c div.c labs.c ldiv.c llabs.c
|
||||
SRCS+= abs.c div.c labs.c ldiv.c llabs.c imaxabs.c imaxdiv.c
|
||||
|
||||
SRCS+= erand48_ieee754.c
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# $NetBSD: Makefile.inc,v 1.2 2006/03/22 22:03:58 drochner Exp $
|
||||
# $NetBSD: Makefile.inc,v 1.3 2008/08/04 21:29:28 matt Exp $
|
||||
|
||||
SRCS+= abs.c div.c labs.c ldiv.c llabs.c
|
||||
SRCS+= abs.c div.c labs.c ldiv.c llabs.c imaxabs.c imaxdiv.c
|
||||
|
||||
SRCS+= erand48_ieee754.c
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# $NetBSD: Makefile.inc,v 1.2 2006/03/22 22:03:58 drochner Exp $
|
||||
# $NetBSD: Makefile.inc,v 1.3 2008/08/04 21:29:28 matt Exp $
|
||||
|
||||
SRCS+= abs.c div.c labs.c ldiv.c llabs.c
|
||||
SRCS+= abs.c div.c labs.c ldiv.c llabs.c imaxabs.c imaxdiv.c
|
||||
|
||||
SRCS+= erand48_ieee754.c
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: Makefile.inc,v 1.5 2006/03/22 22:03:58 drochner Exp $
|
||||
# $NetBSD: Makefile.inc,v 1.6 2008/08/04 21:29:28 matt Exp $
|
||||
|
||||
# objects built from assembler sources (need lint stubs)
|
||||
SRCS+= abs.S div.S labs.S ldiv.S llabs.S
|
||||
|
@ -6,7 +6,8 @@ SRCS+= abs.S div.S labs.S ldiv.S llabs.S
|
|||
# objects built from C sources
|
||||
SRCS+= erand48_ieee754.c
|
||||
|
||||
SRCS.i386.stdlib=Lint_abs.c Lint_div.c Lint_labs.c Lint_ldiv.c Lint_llabs.c
|
||||
SRCS.i386.stdlib=Lint_abs.c Lint_labs.c Lint_llabs.c Lint_imaxabs.c
|
||||
SRCS.i386.stdlib+=Lint_div.c Lint_ldiv.c
|
||||
LSRCS+= ${SRCS.i386.stdlib}
|
||||
DPSRCS+= ${SRCS.i386.stdlib}
|
||||
CLEANFILES+= ${SRCS.i386.stdlib}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: llabs.S,v 1.4 2003/08/07 16:42:07 agc Exp $ */
|
||||
/* $NetBSD: llabs.S,v 1.5 2008/08/04 21:29:28 matt Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
|
@ -36,16 +36,18 @@
|
|||
|
||||
#include <machine/asm.h>
|
||||
#if defined(LIBC_SCCS)
|
||||
RCSID("$NetBSD: llabs.S,v 1.4 2003/08/07 16:42:07 agc Exp $")
|
||||
RCSID("$NetBSD: llabs.S,v 1.5 2008/08/04 21:29:28 matt Exp $")
|
||||
#endif
|
||||
|
||||
#ifdef WEAK_ALIAS
|
||||
WEAK_ALIAS(llabs, _llabs)
|
||||
WEAK_ALIAS(imaxabs, _llabs)
|
||||
#endif
|
||||
|
||||
#ifdef WEAK_ALIAS
|
||||
ENTRY(_llabs)
|
||||
#else
|
||||
STRONG_ALIAS(imaxabs, llabs)
|
||||
ENTRY(llabs)
|
||||
#endif
|
||||
movl 8(%esp),%edx
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# $NetBSD: Makefile.inc,v 1.2 2006/09/23 17:39:34 cherry Exp $
|
||||
# $NetBSD: Makefile.inc,v 1.3 2008/08/04 21:29:28 matt Exp $
|
||||
|
||||
SRCS+= abs.c div.c labs.c ldiv.c llabs.c
|
||||
SRCS+= abs.c div.c labs.c ldiv.c llabs.c imaxabs.c
|
||||
|
||||
SRCS+= erand48_ieee754.c
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: llabs.S,v 1.3 2003/08/07 16:42:12 agc Exp $ */
|
||||
/* $NetBSD: llabs.S,v 1.4 2008/08/04 21:29:28 matt Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
|
@ -39,12 +39,13 @@
|
|||
#if 0
|
||||
RCSID("from: @(#)abs.s 5.1 (Berkeley) 5/12/90")
|
||||
#else
|
||||
RCSID("$NetBSD: llabs.S,v 1.3 2003/08/07 16:42:12 agc Exp $")
|
||||
RCSID("$NetBSD: llabs.S,v 1.4 2008/08/04 21:29:28 matt Exp $")
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#ifdef WEAK_ALIAS
|
||||
WEAK_ALIAS(llabs, _llabs)
|
||||
WEAK_ALIAS(imaxabs, _llabs)
|
||||
#endif
|
||||
/* llabs - long long int absolute value */
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# $NetBSD: Makefile.inc,v 1.3 2006/03/22 22:03:58 drochner Exp $
|
||||
# $NetBSD: Makefile.inc,v 1.4 2008/08/04 21:29:28 matt Exp $
|
||||
|
||||
SRCS+= abs.c div.c labs.c ldiv.c llabs.c
|
||||
SRCS+= abs.c div.c labs.c ldiv.c llabs.c imaxabs.c
|
||||
|
||||
SRCS+= erand48_ieee754.c
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# $NetBSD: Makefile.inc,v 1.3 2006/03/22 22:03:58 drochner Exp $
|
||||
# $NetBSD: Makefile.inc,v 1.4 2008/08/04 21:29:28 matt Exp $
|
||||
|
||||
SRCS+= abs.c div.c labs.c ldiv.c llabs.c
|
||||
SRCS+= abs.c div.c labs.c ldiv.c llabs.c imaxabs.c
|
||||
|
||||
SRCS+= erand48_ieee754.c
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# $NetBSD: Makefile.inc,v 1.1 2006/07/01 16:37:20 ross Exp $
|
||||
# $NetBSD: Makefile.inc,v 1.2 2008/08/04 21:29:28 matt Exp $
|
||||
|
||||
SRCS+= abs.c div.c labs.c ldiv.c llabs.c
|
||||
SRCS+= abs.c div.c labs.c ldiv.c llabs.c imaxabs.c
|
||||
|
||||
SRCS+= erand48_ieee754.c
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# $NetBSD: Makefile.inc,v 1.3 2006/03/22 22:03:58 drochner Exp $
|
||||
# $NetBSD: Makefile.inc,v 1.4 2008/08/04 21:29:28 matt Exp $
|
||||
|
||||
SRCS+= abs.c div.c labs.c ldiv.c llabs.c
|
||||
SRCS+= abs.c div.c labs.c ldiv.c llabs.c imaxabs.c
|
||||
|
||||
SRCS+= erand48_ieee754.c
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: llabs.S,v 1.3 2003/08/07 16:42:24 agc Exp $ */
|
||||
/* $NetBSD: llabs.S,v 1.4 2008/08/04 21:29:28 matt Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
|
@ -40,15 +40,17 @@
|
|||
#if 0
|
||||
.asciz "from: @(#)abs.s 8.1 (Berkeley) 6/4/93"
|
||||
#else
|
||||
RCSID("$NetBSD: llabs.S,v 1.3 2003/08/07 16:42:24 agc Exp $")
|
||||
RCSID("$NetBSD: llabs.S,v 1.4 2008/08/04 21:29:28 matt Exp $")
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#ifdef WEAK_ALIAS
|
||||
WEAK_ALIAS(llabs, _llabs)
|
||||
WEAK_ALIAS(imaxabs, _llabs)
|
||||
#endif
|
||||
|
||||
/* llabs - long long int absolute value */
|
||||
/* imaxabs - intmax_t absolute value */
|
||||
|
||||
|
||||
#ifdef WEAK_ALIAS
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# $NetBSD: Makefile.inc,v 1.3 2006/03/22 22:03:58 drochner Exp $
|
||||
# $NetBSD: Makefile.inc,v 1.4 2008/08/04 21:29:28 matt Exp $
|
||||
|
||||
SRCS+= abs.c div.c labs.c ldiv.c llabs.c
|
||||
SRCS+= abs.c div.c labs.c ldiv.c llabs.c imaxabs.c
|
||||
|
||||
SRCS+= erand48_ieee754.c
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# $NetBSD: Makefile.inc,v 1.3 2006/03/22 22:03:58 drochner Exp $
|
||||
# $NetBSD: Makefile.inc,v 1.4 2008/08/04 21:29:28 matt Exp $
|
||||
|
||||
SRCS+= abs.c div.c labs.c ldiv.c llabs.c
|
||||
SRCS+= abs.c div.c labs.c ldiv.c llabs.c imaxabs.c
|
||||
|
||||
SRCS+= erand48.c
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
# $NetBSD: Makefile.inc,v 1.3 2006/03/22 22:03:58 drochner Exp $
|
||||
# $NetBSD: Makefile.inc,v 1.4 2008/08/04 21:29:29 matt Exp $
|
||||
|
||||
# objects built from assembler sources (need lint stubs)
|
||||
SRCS+= abs.S div.S labs.S ldiv.S
|
||||
|
||||
SRCS+= erand48_ieee754.c
|
||||
|
||||
SRCS.x86_64.stdlib=Lint_abs.c Lint_div.c Lint_labs.c Lint_ldiv.c Lint_llabs.c
|
||||
SRCS.x86_64.stdlib=Lint_abs.c Lint_labs.c Lint_llabs.c Lint_imaxabs.c
|
||||
SRCS.x86_64.stdlib+=Lint_div.c Lint_ldiv.c
|
||||
LSRCS+= ${SRCS.x86_64.stdlib}
|
||||
DPSRCS+= ${SRCS.x86_64.stdlib}
|
||||
CLEANFILES+= ${SRCS.x86_64.stdlib}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: namespace.h,v 1.132 2008/06/25 11:10:25 ad Exp $ */
|
||||
/* $NetBSD: namespace.h,v 1.133 2008/08/04 21:29:27 matt Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997-2004 The NetBSD Foundation, Inc.
|
||||
|
@ -47,6 +47,8 @@
|
|||
#define ftello _ftello
|
||||
#define getcontext _getcontext
|
||||
#define getenv_r _getenv_r
|
||||
#define imaxabs _imaxabs
|
||||
#define imaxdiv _imaxdiv
|
||||
#define inet_aton _inet_aton
|
||||
#define inet_pton _inet_pton
|
||||
#define pipe _pipe
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: shlib_version,v 1.203 2008/06/30 19:04:00 matt Exp $
|
||||
# $NetBSD: shlib_version,v 1.204 2008/08/04 21:29:27 matt Exp $
|
||||
# Remember to update distrib/sets/lists/base/shl.* when changing
|
||||
#
|
||||
# things we wish to do on next major version bump:
|
||||
|
@ -26,4 +26,4 @@
|
|||
# - remove frexp, ldexp, modf: they belong to libm.
|
||||
# - make sure we can support thread local [on arm don't use r9 for example]
|
||||
major=12
|
||||
minor=162
|
||||
minor=163
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
/* $NetBSD: Lint_imaxabs.c,v 1.1 2008/08/04 21:29:27 matt Exp $ */
|
||||
|
||||
/*
|
||||
* This file placed in the public domain.
|
||||
* Matt Thomas, August 4, 2008.
|
||||
*/
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
/* ARGSUSED */
|
||||
intmax_t
|
||||
imaxabs(intmax_t j)
|
||||
{
|
||||
return (0);
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: Makefile.inc,v 1.68 2007/11/28 21:55:14 christos Exp $
|
||||
# $NetBSD: Makefile.inc,v 1.69 2008/08/04 21:29:27 matt Exp $
|
||||
# from: @(#)Makefile.inc 8.3 (Berkeley) 2/4/95
|
||||
|
||||
# stdlib sources
|
||||
|
@ -8,7 +8,7 @@ SRCS+= _rand48.c _strtoimax.c _strtoumax.c _strtoll.c _strtoull.c \
|
|||
a64l.c abort.c atexit.c atof.c atoi.c atol.c atoll.c \
|
||||
bsearch.c drand48.c exit.c \
|
||||
getenv.c getopt.c getopt_long.c getsubopt.c \
|
||||
hcreate.c heapsort.c insque.c jrand48.c l64a.c lldiv.c \
|
||||
hcreate.c heapsort.c imaxdiv.c insque.c jrand48.c l64a.c lldiv.c \
|
||||
lcong48.c lrand48.c lsearch.c merge.c mrand48.c \
|
||||
nrand48.c putenv.c qabs.c qdiv.c qsort.c posix_openpt.c pty.c \
|
||||
radixsort.c rand.c rand_r.c random.c remque.c \
|
||||
|
@ -25,18 +25,25 @@ SRCS+= malloc.c
|
|||
|
||||
# machine-dependent stdlib sources
|
||||
# m-d Makefile.inc must include sources for:
|
||||
# abs() div() labs() ldiv() llabs()
|
||||
# abs() div() labs() ldiv() llabs() imaxabs() imaxdiv()
|
||||
|
||||
.include "${ARCHDIR}/stdlib/Makefile.inc"
|
||||
|
||||
MAN+= a64l.3 abort.3 abs.3 alloca.3 atexit.3 atof.3 atoi.3 atol.3 atoll.3 \
|
||||
bsearch.3 div.3 exit.3 getenv.3 getopt.3 getopt_long.3 getsubopt.3 \
|
||||
grantpt.3 hcreate.3 insque.3 labs.3 ldiv.3 llabs.3 lldiv.3 lsearch.3 \
|
||||
bsearch.3 \
|
||||
div.3 \
|
||||
exit.3 \
|
||||
getenv.3 getopt.3 getopt_long.3 getsubopt.3 grantpt.3 \
|
||||
hcreate.3 \
|
||||
imaxabs.3 imaxdiv.3 insque.3 \
|
||||
labs.3 ldiv.3 llabs.3 lldiv.3 lsearch.3 \
|
||||
malloc.3 memory.3 \
|
||||
posix_memalign.3 posix_openpt.3 ptsname.3 qabs.3 \
|
||||
qdiv.3 qsort.3 radixsort.3 rand48.3 rand.3 random.3 \
|
||||
strsuftoll.3 strtod.3 strtol.3 strtoul.3 system.3 tsearch.3 unlockpt.3 \
|
||||
strfmon.3
|
||||
posix_memalign.3 posix_openpt.3 ptsname.3 \
|
||||
qabs.3 qdiv.3 qsort.3 \
|
||||
radixsort.3 rand48.3 rand.3 random.3 \
|
||||
strfmon.3 strsuftoll.3 strtod.3 strtol.3 strtoul.3 system.3 \
|
||||
tsearch.3 \
|
||||
unlockpt.3
|
||||
|
||||
MLINKS+=a64l.3 l64a.3
|
||||
MLINKS+=a64l.3 l64a_r.3
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
.\" $NetBSD: abs.3,v 1.12 2003/08/07 16:43:37 agc Exp $
|
||||
.\" $NetBSD: abs.3,v 1.13 2008/08/04 21:29:27 matt Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1990, 1991, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
|
@ -63,6 +63,7 @@ the absolute value.
|
|||
.Xr fabs 3 ,
|
||||
.Xr floor 3 ,
|
||||
.Xr hypot 3 ,
|
||||
.Xr imaxabs 3 ,
|
||||
.Xr labs 3 ,
|
||||
.Xr llabs 3 ,
|
||||
.Xr math 3
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
.\" $NetBSD: div.3,v 1.11 2003/08/07 16:43:39 agc Exp $
|
||||
.\" $NetBSD: div.3,v 1.12 2008/08/04 21:29:27 matt Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1990, 1991, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
|
@ -58,6 +58,7 @@ members named
|
|||
and
|
||||
.Fa rem .
|
||||
.Sh SEE ALSO
|
||||
.Xr imaxdiv 3 ,
|
||||
.Xr ldiv 3 ,
|
||||
.Xr lldiv 3 ,
|
||||
.Xr math 3 ,
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
.\" $NetBSD: imaxabs.3,v 1.1 2008/08/04 21:29:27 matt Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1990, 1991, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
.\"
|
||||
.\" This code is derived from software contributed to Berkeley by
|
||||
.\" the American National Standards Committee X3, on Information
|
||||
.\" Processing Systems.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\" 3. Neither the name of the University nor the names of its contributors
|
||||
.\" may be used to endorse or promote products derived from this software
|
||||
.\" without specific prior written permission.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" from: @(#)labs.3 8.1 (Berkeley) 6/4/93
|
||||
.\"
|
||||
.Dd March 6, 2000
|
||||
.Dt IMAXABS 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm imaxabs
|
||||
.Nd return the absolute value of a imaxint_t
|
||||
.Sh LIBRARY
|
||||
.Lb libc
|
||||
.Sh SYNOPSIS
|
||||
.In inttypes.h
|
||||
.Ft intmax_t
|
||||
.Fn imaxabs "intmax_t i"
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Fn imaxabs
|
||||
function
|
||||
returns the absolute value of the imaxint_t integer
|
||||
.Ar j .
|
||||
.Sh SEE ALSO
|
||||
.Xr abs 3 ,
|
||||
.Xr cabs 3 ,
|
||||
.Xr floor 3 ,
|
||||
.Xr labs 3 ,
|
||||
.Xr llabs 3 ,
|
||||
.Xr math 3
|
||||
.Sh STANDARDS
|
||||
The
|
||||
.Fn imaxabs
|
||||
function
|
||||
conforms to
|
||||
.St -isoC-99 .
|
||||
.Sh BUGS
|
||||
The absolute value of the most negative integer remains negative.
|
|
@ -0,0 +1,49 @@
|
|||
/* $NetBSD: imaxabs.c,v 1.1 2008/08/04 21:29:27 matt Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2008 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Matt Thomas <matt@3am-software.com>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#if !defined(lint)
|
||||
__RCSID("$NetBSD: imaxabs.c,v 1.1 2008/08/04 21:29:27 matt Exp $");
|
||||
#endif
|
||||
|
||||
#include "namespace.h"
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
#ifdef __weak_alias
|
||||
__weak_alias(imaxabs, _imaxabs)
|
||||
#endif
|
||||
|
||||
intmax_t
|
||||
imaxabs(intmax_t i)
|
||||
{
|
||||
return i < 0 ? -i : i;
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
.\" $NetBSD: imaxdiv.3,v 1.1 2008/08/04 21:29:27 matt Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1990, 1991, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
.\"
|
||||
.\" This code is derived from software contributed to Berkeley by
|
||||
.\" Chris Torek and the American National Standards Committee X3,
|
||||
.\" on Information Processing Systems.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\" 3. Neither the name of the University nor the names of its contributors
|
||||
.\" may be used to endorse or promote products derived from this software
|
||||
.\" without specific prior written permission.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" from: @(#)ldiv.3 8.1 (Berkeley) 6/4/93
|
||||
.\"
|
||||
.Dd March 6, 2000
|
||||
.Dt IMAXDIV 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm imaxdiv
|
||||
.Nd return quotient and remainder from division
|
||||
.Sh LIBRARY
|
||||
.Lb libc
|
||||
.Sh SYNOPSIS
|
||||
.In inttypes.h
|
||||
.Ft imaxdiv_t
|
||||
.Fn imaxdiv "intmax_t num" "intmax_t denom"
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Fn imaxdiv
|
||||
function
|
||||
divides
|
||||
.Ar num
|
||||
by
|
||||
.Ar denom
|
||||
and returns the resulting quotient and remainder in a structure named
|
||||
.Ar imaxdiv_t
|
||||
that contains two
|
||||
.Em imaxint_t
|
||||
members named
|
||||
.Ar quot
|
||||
and
|
||||
.Ar rem .
|
||||
.Sh SEE ALSO
|
||||
.Xr div 3 ,
|
||||
.Xr ldiv 3 ,
|
||||
.Xr lldiv 3 ,
|
||||
.Xr math 3 ,
|
||||
.Xr qdiv 3
|
||||
.Sh STANDARDS
|
||||
The
|
||||
.Fn imaxdiv
|
||||
function
|
||||
conforms to
|
||||
.St -isoC-99 .
|
|
@ -0,0 +1,66 @@
|
|||
/* $NetBSD: imaxdiv.c,v 1.1 2008/08/04 21:29:27 matt Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1990, 1993
|
||||
* The Regents of the University of California. Aimax rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Chris Torek.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the foimaxowing conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the foimaxowing disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the foimaxowing disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
#if 0
|
||||
static char sccsid[] = "from: @(#)ldiv.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: imaxdiv.c,v 1.1 2008/08/04 21:29:27 matt Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "namespace.h"
|
||||
#include <inttypes.h> /* imaxdiv_t */
|
||||
|
||||
#ifdef __weak_alias
|
||||
__weak_alias(imaxdiv, _imaxdiv)
|
||||
#endif
|
||||
|
||||
/* LONGLONG */
|
||||
imaxdiv_t
|
||||
imaxdiv(intmax_t num, intmax_t denom)
|
||||
{
|
||||
imaxdiv_t r;
|
||||
|
||||
/* see div.c for comments */
|
||||
|
||||
r.quot = num / denom;
|
||||
r.rem = num % denom;
|
||||
if (num >= 0 && r.rem < 0) {
|
||||
r.quot++;
|
||||
r.rem -= denom;
|
||||
}
|
||||
return (r);
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
.\" $NetBSD: labs.3,v 1.10 2003/08/07 16:43:41 agc Exp $
|
||||
.\" $NetBSD: labs.3,v 1.11 2008/08/04 21:29:27 matt Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1990, 1991, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
|
@ -55,6 +55,7 @@ returns the absolute value of the long integer
|
|||
.Xr abs 3 ,
|
||||
.Xr cabs 3 ,
|
||||
.Xr floor 3 ,
|
||||
.Xr imaxabs 3 ,
|
||||
.Xr llabs 3 ,
|
||||
.Xr math 3
|
||||
.Sh STANDARDS
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
.\" $NetBSD: ldiv.3,v 1.12 2003/08/07 16:43:41 agc Exp $
|
||||
.\" $NetBSD: ldiv.3,v 1.13 2008/08/04 21:29:27 matt Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1990, 1991, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
|
@ -61,6 +61,7 @@ and
|
|||
.Ar rem .
|
||||
.Sh SEE ALSO
|
||||
.Xr div 3 ,
|
||||
.Xr imaxdiv 3 ,
|
||||
.Xr lldiv 3 ,
|
||||
.Xr math 3 ,
|
||||
.Xr qdiv 3
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
.\" $NetBSD: llabs.3,v 1.6 2003/09/08 17:54:33 wiz Exp $
|
||||
.\" $NetBSD: llabs.3,v 1.7 2008/08/04 21:29:27 matt Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1990, 1991, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
|
@ -55,6 +55,7 @@ returns the absolute value of the long long integer
|
|||
.Xr abs 3 ,
|
||||
.Xr cabs 3 ,
|
||||
.Xr floor 3 ,
|
||||
.Xr imaxabs 3 ,
|
||||
.Xr labs 3 ,
|
||||
.Xr math 3
|
||||
.Sh STANDARDS
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
.\" $NetBSD: lldiv.3,v 1.6 2003/09/08 17:54:33 wiz Exp $
|
||||
.\" $NetBSD: lldiv.3,v 1.7 2008/08/04 21:29:27 matt Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1990, 1991, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
|
@ -61,6 +61,7 @@ and
|
|||
.Ar rem .
|
||||
.Sh SEE ALSO
|
||||
.Xr div 3 ,
|
||||
.Xr imaxdiv 3 ,
|
||||
.Xr ldiv 3 ,
|
||||
.Xr math 3 ,
|
||||
.Xr qdiv 3
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
.\" $NetBSD: qabs.3,v 1.8 2003/08/07 16:43:42 agc Exp $
|
||||
.\" $NetBSD: qabs.3,v 1.9 2008/08/04 21:29:27 matt Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1990, 1991 The Regents of the University of California.
|
||||
.\" All rights reserved.
|
||||
|
@ -55,6 +55,7 @@ returns the absolute value of the quad integer
|
|||
.Xr abs 3 ,
|
||||
.Xr cabs 3 ,
|
||||
.Xr floor 3 ,
|
||||
.Xr imaxabs 3 ,
|
||||
.Xr labs 3 ,
|
||||
.Xr llabs 3 ,
|
||||
.Xr math 3
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
.\" $NetBSD: qdiv.3,v 1.8 2003/08/07 16:43:42 agc Exp $
|
||||
.\" $NetBSD: qdiv.3,v 1.9 2008/08/04 21:29:27 matt Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1990, 1991 The Regents of the University of California.
|
||||
.\" All rights reserved.
|
||||
|
@ -61,6 +61,7 @@ and
|
|||
.Ar rem .
|
||||
.Sh SEE ALSO
|
||||
.Xr div 3 ,
|
||||
.Xr imaxdiv 3 ,
|
||||
.Xr ldiv 3 ,
|
||||
.Xr lldiv 3 ,
|
||||
.Xr math 3
|
||||
|
|
Loading…
Reference in New Issue