diff options
| author | jtc <jtc@NetBSD.org> | 1995-03-22 00:36:52 +0000 |
|---|---|---|
| committer | jtc <jtc@NetBSD.org> | 1995-03-22 00:36:52 +0000 |
| commit | 7681b92c662431aa05e60d7d404fac8be4cfc12e (patch) | |
| tree | 9909d5479900549153fd888fe336ed37fccd7046 /lib/libc/stdlib | |
| parent | 918d73c578b7ecc0f75f48c9d9ab9497fc76ff4f (diff) | |
Enable qabs(), a quad_t version of abs() and labs().
Diffstat (limited to 'lib/libc/stdlib')
| -rw-r--r-- | lib/libc/stdlib/Makefile.inc | 9 | ||||
| -rw-r--r-- | lib/libc/stdlib/qabs.3 | 62 | ||||
| -rw-r--r-- | lib/libc/stdlib/qabs.c | 46 |
3 files changed, 113 insertions, 4 deletions
diff --git a/lib/libc/stdlib/Makefile.inc b/lib/libc/stdlib/Makefile.inc index 99b1ae9d12f..7569edbb309 100644 --- a/lib/libc/stdlib/Makefile.inc +++ b/lib/libc/stdlib/Makefile.inc @@ -1,5 +1,5 @@ # from: @(#)Makefile.inc 5.6 (Berkeley) 6/4/91 -# $Id: Makefile.inc,v 1.24 1995/03/21 23:12:35 jtc Exp $ +# $Id: Makefile.inc,v 1.25 1995/03/22 00:36:52 jtc Exp $ # stdlib sources .PATH: ${.CURDIR}/arch/${MACHINE_ARCH}/stdlib ${.CURDIR}/stdlib @@ -9,7 +9,7 @@ SRCS+= a64l.c abort.c atexit.c atoi.c atof.c atol.c bsearch.c calloc.c \ multibyte.c putenv.c qsort.c radixsort.c rand.c random.c realpath.c \ setenv.c strtod.c strtol.c strtoq.c strtoul.c strtouq.c system.c \ _rand48.c drand48.c erand48.c jrand48.c lcong48.c lrand48.c \ - mrand48.c nrand48.c seed48.c srand48.c qdiv.c + mrand48.c nrand48.c seed48.c srand48.c qabs.c qdiv.c .if (${MACHINE_ARCH} == "m68k") SRCS+= abs.S div.c labs.c ldiv.c @@ -30,8 +30,9 @@ SRCS+= abs.c div.c labs.c ldiv.c MAN+= abort.3 abs.3 alloca.3 atexit.3 atof.3 atoi.3 atol.3 bsearch.3 \ calloc.3 div.3 exit.3 free.3 getenv.3 getopt.3 labs.3 ldiv.3 \ - malloc.3 memory.3 qdiv.3 qsort.3 radixsort.3 rand48.3 rand.3 \ - random.3 realloc.3 realpath.3 strtod.3 strtol.3 strtoul.3 system.3 + malloc.3 memory.3 qabs.3 qdiv.3 qsort.3 radixsort.3 rand48.3 \ + rand.3 random.3 realloc.3 realpath.3 strtod.3 strtol.3 strtoul.3 \ + system.3 MLINKS+=getenv.3 setenv.3 getenv.3 unsetenv.3 getenv.3 putenv.3 MLINKS+=qsort.3 heapsort.3 qsort.3 mergesort.3 diff --git a/lib/libc/stdlib/qabs.3 b/lib/libc/stdlib/qabs.3 new file mode 100644 index 00000000000..5f48a2d62b3 --- /dev/null +++ b/lib/libc/stdlib/qabs.3 @@ -0,0 +1,62 @@ +.\" Copyright (c) 1990, 1991 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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 5.3 (Berkeley) 6/29/91 +.\" $Id: qabs.3,v 1.1 1995/03/22 00:36:56 jtc Exp $ +.\" +.Dd June 29, 1991 +.Dt QABS 3 +.Os +.Sh NAME +.Nm qabs +.Nd return the absolute value of a quad integer +.Sh SYNOPSIS +.Fd #include <stdlib.h> +.Ft quad_t +.Fn qabs "quad_t j" +.Sh DESCRIPTION +The +.Fn qabs +function +returns the absolute value of the quad integer +.Ar j . +.Sh SEE ALSO +.Xr abs 3 , +.Xr labs 3 , +.Xr floor 3 , +.Xr cabs 3 , +.Xr math 3 +.Sh BUGS +The absolute value of the most negative integer remains negative. diff --git a/lib/libc/stdlib/qabs.c b/lib/libc/stdlib/qabs.c new file mode 100644 index 00000000000..e86e87d49e9 --- /dev/null +++ b/lib/libc/stdlib/qabs.c @@ -0,0 +1,46 @@ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +/*static char *sccsid = "from: @(#)labs.c 5.2 (Berkeley) 5/17/90";*/ +static char *rcsid = "$Id: qabs.c,v 1.1 1995/03/22 00:36:55 jtc Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include <stdlib.h> + +quad_t +qabs(j) + quad_t j; +{ + return(j < 0 ? -j : j); +} |
