summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatt <matt@NetBSD.org>2008-08-04 21:29:27 +0000
committermatt <matt@NetBSD.org>2008-08-04 21:29:27 +0000
commitcac8e449158efc7261bebc8657cbb0125a2cfdde (patch)
tree72b89c429f4be1ace8ebf5d61156daef8469c343
parent7ab651d699be8931e6858689c82fc99cd8ee9280 (diff)
Add C99 functions imaxabs and imaxdiv.
-rw-r--r--lib/libc/arch/alpha/stdlib/Makefile.inc4
-rw-r--r--lib/libc/arch/arm/stdlib/Makefile.inc4
-rw-r--r--lib/libc/arch/hppa/stdlib/Makefile.inc4
-rw-r--r--lib/libc/arch/i386/stdlib/Makefile.inc5
-rw-r--r--lib/libc/arch/i386/stdlib/llabs.S6
-rw-r--r--lib/libc/arch/ia64/stdlib/Makefile.inc4
-rw-r--r--lib/libc/arch/m68k/stdlib/llabs.S5
-rw-r--r--lib/libc/arch/mips/stdlib/Makefile.inc4
-rw-r--r--lib/libc/arch/powerpc/stdlib/Makefile.inc4
-rw-r--r--lib/libc/arch/powerpc64/stdlib/Makefile.inc4
-rw-r--r--lib/libc/arch/sh3/stdlib/Makefile.inc4
-rw-r--r--lib/libc/arch/sparc/stdlib/llabs.S6
-rw-r--r--lib/libc/arch/sparc64/stdlib/Makefile.inc4
-rw-r--r--lib/libc/arch/vax/stdlib/Makefile.inc4
-rw-r--r--lib/libc/arch/x86_64/stdlib/Makefile.inc5
-rw-r--r--lib/libc/include/namespace.h4
-rw-r--r--lib/libc/shlib_version4
-rw-r--r--lib/libc/stdlib/Lint_imaxabs.c15
-rw-r--r--lib/libc/stdlib/Makefile.inc25
-rw-r--r--lib/libc/stdlib/abs.33
-rw-r--r--lib/libc/stdlib/div.33
-rw-r--r--lib/libc/stdlib/imaxabs.368
-rw-r--r--lib/libc/stdlib/imaxabs.c49
-rw-r--r--lib/libc/stdlib/imaxdiv.375
-rw-r--r--lib/libc/stdlib/imaxdiv.c66
-rw-r--r--lib/libc/stdlib/labs.33
-rw-r--r--lib/libc/stdlib/ldiv.33
-rw-r--r--lib/libc/stdlib/llabs.33
-rw-r--r--lib/libc/stdlib/lldiv.33
-rw-r--r--lib/libc/stdlib/qabs.33
-rw-r--r--lib/libc/stdlib/qdiv.33
31 files changed, 347 insertions, 50 deletions
diff --git a/lib/libc/arch/alpha/stdlib/Makefile.inc b/lib/libc/arch/alpha/stdlib/Makefile.inc
index 491737e36d5..822d6015a12 100644
--- a/lib/libc/arch/alpha/stdlib/Makefile.inc
+++ b/lib/libc/arch/alpha/stdlib/Makefile.inc
@@ -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
diff --git a/lib/libc/arch/arm/stdlib/Makefile.inc b/lib/libc/arch/arm/stdlib/Makefile.inc
index 3d24ad51541..fbbee054ba6 100644
--- a/lib/libc/arch/arm/stdlib/Makefile.inc
+++ b/lib/libc/arch/arm/stdlib/Makefile.inc
@@ -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
diff --git a/lib/libc/arch/hppa/stdlib/Makefile.inc b/lib/libc/arch/hppa/stdlib/Makefile.inc
index 3d24ad51541..fbbee054ba6 100644
--- a/lib/libc/arch/hppa/stdlib/Makefile.inc
+++ b/lib/libc/arch/hppa/stdlib/Makefile.inc
@@ -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
diff --git a/lib/libc/arch/i386/stdlib/Makefile.inc b/lib/libc/arch/i386/stdlib/Makefile.inc
index 568da8cb1e5..88ebab0bac5 100644
--- a/lib/libc/arch/i386/stdlib/Makefile.inc
+++ b/lib/libc/arch/i386/stdlib/Makefile.inc
@@ -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}
diff --git a/lib/libc/arch/i386/stdlib/llabs.S b/lib/libc/arch/i386/stdlib/llabs.S
index f8eab5fbfcc..bc740ff4b78 100644
--- a/lib/libc/arch/i386/stdlib/llabs.S
+++ b/lib/libc/arch/i386/stdlib/llabs.S
@@ -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
diff --git a/lib/libc/arch/ia64/stdlib/Makefile.inc b/lib/libc/arch/ia64/stdlib/Makefile.inc
index 9132bae50c4..55cb7dc7d0e 100644
--- a/lib/libc/arch/ia64/stdlib/Makefile.inc
+++ b/lib/libc/arch/ia64/stdlib/Makefile.inc
@@ -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
diff --git a/lib/libc/arch/m68k/stdlib/llabs.S b/lib/libc/arch/m68k/stdlib/llabs.S
index 0640248c622..b565dedcb25 100644
--- a/lib/libc/arch/m68k/stdlib/llabs.S
+++ b/lib/libc/arch/m68k/stdlib/llabs.S
@@ -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 */
diff --git a/lib/libc/arch/mips/stdlib/Makefile.inc b/lib/libc/arch/mips/stdlib/Makefile.inc
index 491737e36d5..b1b5971772d 100644
--- a/lib/libc/arch/mips/stdlib/Makefile.inc
+++ b/lib/libc/arch/mips/stdlib/Makefile.inc
@@ -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
diff --git a/lib/libc/arch/powerpc/stdlib/Makefile.inc b/lib/libc/arch/powerpc/stdlib/Makefile.inc
index 491737e36d5..b1b5971772d 100644
--- a/lib/libc/arch/powerpc/stdlib/Makefile.inc
+++ b/lib/libc/arch/powerpc/stdlib/Makefile.inc
@@ -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
diff --git a/lib/libc/arch/powerpc64/stdlib/Makefile.inc b/lib/libc/arch/powerpc64/stdlib/Makefile.inc
index 84d1208bd39..3c7af23e98d 100644
--- a/lib/libc/arch/powerpc64/stdlib/Makefile.inc
+++ b/lib/libc/arch/powerpc64/stdlib/Makefile.inc
@@ -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
diff --git a/lib/libc/arch/sh3/stdlib/Makefile.inc b/lib/libc/arch/sh3/stdlib/Makefile.inc
index 491737e36d5..b1b5971772d 100644
--- a/lib/libc/arch/sh3/stdlib/Makefile.inc
+++ b/lib/libc/arch/sh3/stdlib/Makefile.inc
@@ -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
diff --git a/lib/libc/arch/sparc/stdlib/llabs.S b/lib/libc/arch/sparc/stdlib/llabs.S
index c1605907be8..ab81609cc8a 100644
--- a/lib/libc/arch/sparc/stdlib/llabs.S
+++ b/lib/libc/arch/sparc/stdlib/llabs.S
@@ -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
diff --git a/lib/libc/arch/sparc64/stdlib/Makefile.inc b/lib/libc/arch/sparc64/stdlib/Makefile.inc
index 491737e36d5..b1b5971772d 100644
--- a/lib/libc/arch/sparc64/stdlib/Makefile.inc
+++ b/lib/libc/arch/sparc64/stdlib/Makefile.inc
@@ -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
diff --git a/lib/libc/arch/vax/stdlib/Makefile.inc b/lib/libc/arch/vax/stdlib/Makefile.inc
index 04d3f3473a8..7c058b7d751 100644
--- a/lib/libc/arch/vax/stdlib/Makefile.inc
+++ b/lib/libc/arch/vax/stdlib/Makefile.inc
@@ -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
diff --git a/lib/libc/arch/x86_64/stdlib/Makefile.inc b/lib/libc/arch/x86_64/stdlib/Makefile.inc
index 9543e5728a8..4eadeaa3dcf 100644
--- a/lib/libc/arch/x86_64/stdlib/Makefile.inc
+++ b/lib/libc/arch/x86_64/stdlib/Makefile.inc
@@ -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}
diff --git a/lib/libc/include/namespace.h b/lib/libc/include/namespace.h
index daed09708df..0f983a7b621 100644
--- a/lib/libc/include/namespace.h
+++ b/lib/libc/include/namespace.h
@@ -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
diff --git a/lib/libc/shlib_version b/lib/libc/shlib_version
index a303d6d38df..db2e42e8f98 100644
--- a/lib/libc/shlib_version
+++ b/lib/libc/shlib_version
@@ -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
diff --git a/lib/libc/stdlib/Lint_imaxabs.c b/lib/libc/stdlib/Lint_imaxabs.c
new file mode 100644
index 00000000000..2dfc790d842
--- /dev/null
+++ b/lib/libc/stdlib/Lint_imaxabs.c
@@ -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);
+}
diff --git a/lib/libc/stdlib/Makefile.inc b/lib/libc/stdlib/Makefile.inc
index 8ddd44e21db..92ae88ef430 100644
--- a/lib/libc/stdlib/Makefile.inc
+++ b/lib/libc/stdlib/Makefile.inc
@@ -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
diff --git a/lib/libc/stdlib/abs.3 b/lib/libc/stdlib/abs.3
index c996f488eee..d9a8238f9bd 100644
--- a/lib/libc/stdlib/abs.3
+++ b/lib/libc/stdlib/abs.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
diff --git a/lib/libc/stdlib/div.3 b/lib/libc/stdlib/div.3
index 7679116bb84..062837d4277 100644
--- a/lib/libc/stdlib/div.3
+++ b/lib/libc/stdlib/div.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 ,
diff --git a/lib/libc/stdlib/imaxabs.3 b/lib/libc/stdlib/imaxabs.3
new file mode 100644
index 00000000000..cb87e4834f0
--- /dev/null
+++ b/lib/libc/stdlib/imaxabs.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.
diff --git a/lib/libc/stdlib/imaxabs.c b/lib/libc/stdlib/imaxabs.c
new file mode 100644
index 00000000000..f7fe28c9b51
--- /dev/null
+++ b/lib/libc/stdlib/imaxabs.c
@@ -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;
+}
diff --git a/lib/libc/stdlib/imaxdiv.3 b/lib/libc/stdlib/imaxdiv.3
new file mode 100644
index 00000000000..ebfd7f1ead5
--- /dev/null
+++ b/lib/libc/stdlib/imaxdiv.3
@@ -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 .
diff --git a/lib/libc/stdlib/imaxdiv.c b/lib/libc/stdlib/imaxdiv.c
new file mode 100644
index 00000000000..f9e1dc1d16c
--- /dev/null
+++ b/lib/libc/stdlib/imaxdiv.c
@@ -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);
+}
diff --git a/lib/libc/stdlib/labs.3 b/lib/libc/stdlib/labs.3
index 99193ab2ce8..3d07816a238 100644
--- a/lib/libc/stdlib/labs.3
+++ b/lib/libc/stdlib/labs.3
@@ -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
diff --git a/lib/libc/stdlib/ldiv.3 b/lib/libc/stdlib/ldiv.3
index 508397c56a5..95852ce71c6 100644
--- a/lib/libc/stdlib/ldiv.3
+++ b/lib/libc/stdlib/ldiv.3
@@ -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
diff --git a/lib/libc/stdlib/llabs.3 b/lib/libc/stdlib/llabs.3
index ad739a1ebe0..f36619b92c3 100644
--- a/lib/libc/stdlib/llabs.3
+++ b/lib/libc/stdlib/llabs.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
diff --git a/lib/libc/stdlib/lldiv.3 b/lib/libc/stdlib/lldiv.3
index fc3db17e0f5..4d2ccb0fd77 100644
--- a/lib/libc/stdlib/lldiv.3
+++ b/lib/libc/stdlib/lldiv.3
@@ -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
diff --git a/lib/libc/stdlib/qabs.3 b/lib/libc/stdlib/qabs.3
index 6ade54a32c2..95306af23c6 100644
--- a/lib/libc/stdlib/qabs.3
+++ b/lib/libc/stdlib/qabs.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
diff --git a/lib/libc/stdlib/qdiv.3 b/lib/libc/stdlib/qdiv.3
index e4af5a7ce62..0d3083725dd 100644
--- a/lib/libc/stdlib/qdiv.3
+++ b/lib/libc/stdlib/qdiv.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