From 502002cd1aaa0de2444e3f8cbcacef3d2f7000c7 Mon Sep 17 00:00:00 2001 From: guenther <> Date: Sun, 14 Aug 2016 23:18:03 +0000 Subject: [PATCH] Reduce qabs() and qdiv() to aliases of llabs() and lldiv(). Merge the manual pages and call them deprecated there. ok and manpage tweak jmc@, ok natano@ --- src/lib/libc/stdlib/Makefile.inc | 8 ++--- src/lib/libc/stdlib/div.3 | 7 ++-- src/lib/libc/stdlib/imaxdiv.3 | 7 ++-- src/lib/libc/stdlib/labs.3 | 10 ++++-- src/lib/libc/stdlib/ldiv.3 | 7 ++-- src/lib/libc/stdlib/llabs.c | 4 ++- src/lib/libc/stdlib/lldiv.3 | 13 ++++--- src/lib/libc/stdlib/lldiv.c | 4 ++- src/lib/libc/stdlib/qabs.3 | 56 ----------------------------- src/lib/libc/stdlib/qabs.c | 37 ------------------- src/lib/libc/stdlib/qdiv.3 | 61 -------------------------------- src/lib/libc/stdlib/qdiv.c | 50 -------------------------- 12 files changed, 36 insertions(+), 228 deletions(-) delete mode 100644 src/lib/libc/stdlib/qabs.3 delete mode 100644 src/lib/libc/stdlib/qabs.c delete mode 100644 src/lib/libc/stdlib/qdiv.3 delete mode 100644 src/lib/libc/stdlib/qdiv.c diff --git a/src/lib/libc/stdlib/Makefile.inc b/src/lib/libc/stdlib/Makefile.inc index e04d13b8..3489e440 100644 --- a/src/lib/libc/stdlib/Makefile.inc +++ b/src/lib/libc/stdlib/Makefile.inc @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile.inc,v 1.60 2016/05/02 12:59:24 millert Exp $ +# $OpenBSD: Makefile.inc,v 1.61 2016/08/14 23:18:03 guenther Exp $ # stdlib sources .PATH: ${LIBCSRCDIR}/arch/${MACHINE_CPU}/stdlib ${LIBCSRCDIR}/stdlib @@ -11,8 +11,8 @@ SRCS+= a64l.c abort.c atexit.c atoi.c atof.c atol.c atoll.c bsearch.c \ realpath.c remque.c setenv.c strtoimax.c \ strtol.c strtoll.c strtonum.c strtoul.c strtoull.c strtoumax.c \ system.c tfind.c tsearch.c _rand48.c drand48.c erand48.c jrand48.c \ - lcong48.c lrand48.c mrand48.c nrand48.c seed48.c srand48.c qabs.c \ - qdiv.c _Exit.c icdb.c + lcong48.c lrand48.c mrand48.c nrand48.c seed48.c srand48.c \ + _Exit.c icdb.c .if (${MACHINE_CPU} == "i386") SRCS+= abs.S div.S labs.S ldiv.S @@ -27,5 +27,5 @@ MAN+= a64l.3 abort.3 abs.3 alloca.3 atexit.3 atof.3 atoi.3 atol.3 atoll.3 \ bsearch.3 div.3 ecvt.3 exit.3 getenv.3 getopt.3 getopt_long.3 \ getsubopt.3 hcreate.3 imaxabs.3 imaxdiv.3 insque.3 labs.3 ldiv.3 \ lldiv.3 lsearch.3 malloc.3 posix_memalign.3 posix_openpt.3 ptsname.3 \ - qabs.3 qdiv.3 qsort.3 radixsort.3 rand48.3 rand.3 random.3 realpath.3 \ + qsort.3 radixsort.3 rand48.3 rand.3 random.3 realpath.3 \ strtod.3 strtonum.3 strtol.3 strtoul.3 system.3 tsearch.3 diff --git a/src/lib/libc/stdlib/div.3 b/src/lib/libc/stdlib/div.3 index 1a2a3262..421400a2 100644 --- a/src/lib/libc/stdlib/div.3 +++ b/src/lib/libc/stdlib/div.3 @@ -27,9 +27,9 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $OpenBSD: div.3,v 1.11 2013/06/05 03:39:23 tedu Exp $ +.\" $OpenBSD: div.3,v 1.12 2016/08/14 23:18:03 guenther Exp $ .\" -.Dd $Mdocdate: June 5 2013 $ +.Dd $Mdocdate: August 14 2016 $ .Dt DIV 3 .Os .Sh NAME @@ -55,8 +55,7 @@ and .Sh SEE ALSO .Xr imaxdiv 3 , .Xr ldiv 3 , -.Xr lldiv 3 , -.Xr qdiv 3 +.Xr lldiv 3 .Sh STANDARDS The .Fn div diff --git a/src/lib/libc/stdlib/imaxdiv.3 b/src/lib/libc/stdlib/imaxdiv.3 index 20f02e75..0d4f7653 100644 --- a/src/lib/libc/stdlib/imaxdiv.3 +++ b/src/lib/libc/stdlib/imaxdiv.3 @@ -29,9 +29,9 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $OpenBSD: imaxdiv.3,v 1.6 2014/11/30 21:21:59 schwarze Exp $ +.\" $OpenBSD: imaxdiv.3,v 1.7 2016/08/14 23:18:03 guenther Exp $ .\" -.Dd $Mdocdate: November 30 2014 $ +.Dd $Mdocdate: August 14 2016 $ .Dt IMAXDIV 3 .Os .Sh NAME @@ -57,8 +57,7 @@ and .Sh SEE ALSO .Xr div 3 , .Xr ldiv 3 , -.Xr lldiv 3 , -.Xr qdiv 3 +.Xr lldiv 3 .Sh STANDARDS The .Fn imaxdiv diff --git a/src/lib/libc/stdlib/labs.3 b/src/lib/libc/stdlib/labs.3 index 55cf548e..272a14e3 100644 --- a/src/lib/libc/stdlib/labs.3 +++ b/src/lib/libc/stdlib/labs.3 @@ -29,9 +29,9 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $OpenBSD: labs.3,v 1.13 2014/11/30 21:21:59 schwarze Exp $ +.\" $OpenBSD: labs.3,v 1.14 2016/08/14 23:18:03 guenther Exp $ .\" -.Dd $Mdocdate: November 30 2014 $ +.Dd $Mdocdate: August 14 2016 $ .Dt LABS 3 .Os .Sh NAME @@ -44,6 +44,8 @@ .Fn labs "long i" .Ft long long .Fn llabs "long long j" +.Ft quad_t +.Fn qabs "quad_t j" .Sh DESCRIPTION The .Fn labs @@ -53,6 +55,10 @@ The .Fn llabs function returns the absolute value of the long long integer .Fa j . +The +.Fn qabs +function is a deprecated equivalent of +.Fn llabs . .Sh SEE ALSO .Xr abs 3 , .Xr cabs 3 , diff --git a/src/lib/libc/stdlib/ldiv.3 b/src/lib/libc/stdlib/ldiv.3 index a8835ab6..1fa6f38c 100644 --- a/src/lib/libc/stdlib/ldiv.3 +++ b/src/lib/libc/stdlib/ldiv.3 @@ -29,9 +29,9 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $OpenBSD: ldiv.3,v 1.12 2013/07/17 05:42:11 schwarze Exp $ +.\" $OpenBSD: ldiv.3,v 1.13 2016/08/14 23:18:03 guenther Exp $ .\" -.Dd $Mdocdate: July 17 2013 $ +.Dd $Mdocdate: August 14 2016 $ .Dt LDIV 3 .Os .Sh NAME @@ -57,8 +57,7 @@ and .Sh SEE ALSO .Xr div 3 , .Xr imaxdiv 3 , -.Xr lldiv 3 , -.Xr qdiv 3 +.Xr lldiv 3 .Sh STANDARDS The .Fn ldiv diff --git a/src/lib/libc/stdlib/llabs.c b/src/lib/libc/stdlib/llabs.c index fc2cd826..f4a260f4 100644 --- a/src/lib/libc/stdlib/llabs.c +++ b/src/lib/libc/stdlib/llabs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: llabs.c,v 1.3 2007/01/08 19:39:25 deraadt Exp $ */ +/* $OpenBSD: llabs.c,v 1.4 2016/08/14 23:18:03 guenther Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. @@ -36,3 +36,5 @@ llabs(long long j) { return (j < 0 ? -j : j); } + +__weak_alias(qabs, llabs); diff --git a/src/lib/libc/stdlib/lldiv.3 b/src/lib/libc/stdlib/lldiv.3 index cb2abf68..ab0bec9f 100644 --- a/src/lib/libc/stdlib/lldiv.3 +++ b/src/lib/libc/stdlib/lldiv.3 @@ -29,9 +29,9 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $OpenBSD: lldiv.3,v 1.5 2014/11/30 21:21:59 schwarze Exp $ +.\" $OpenBSD: lldiv.3,v 1.6 2016/08/14 23:18:03 guenther Exp $ .\" -.Dd $Mdocdate: November 30 2014 $ +.Dd $Mdocdate: August 14 2016 $ .Dt LLDIV 3 .Os .Sh NAME @@ -41,6 +41,8 @@ .In stdlib.h .Ft lldiv_t .Fn lldiv "long long num" "long long denom" +.Ft qdiv_t +.Fn qdiv "quad_t num" "quad_t denom" .Sh DESCRIPTION The .Fn lldiv @@ -54,11 +56,14 @@ members named .Fa quot and .Fa rem . +The +.Fn qdiv +function is a deprecated equivalent of +.Fn lldiv . .Sh SEE ALSO .Xr div 3 , .Xr imaxdiv 3 , -.Xr ldiv 3 , -.Xr qdiv 3 +.Xr ldiv 3 .Sh STANDARDS The .Fn lldiv diff --git a/src/lib/libc/stdlib/lldiv.c b/src/lib/libc/stdlib/lldiv.c index e8d6c978..59c37b87 100644 --- a/src/lib/libc/stdlib/lldiv.c +++ b/src/lib/libc/stdlib/lldiv.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lldiv.c,v 1.1 2006/01/13 17:58:09 millert Exp $ */ +/* $OpenBSD: lldiv.c,v 1.2 2016/08/14 23:18:03 guenther Exp $ */ /* * Copyright (c) 1990 Regents of the University of California. * All rights reserved. @@ -48,3 +48,5 @@ lldiv(long long num, long long denom) } return (r); } + +__weak_alias(qdiv, lldiv); diff --git a/src/lib/libc/stdlib/qabs.3 b/src/lib/libc/stdlib/qabs.3 deleted file mode 100644 index 6703072e..00000000 --- a/src/lib/libc/stdlib/qabs.3 +++ /dev/null @@ -1,56 +0,0 @@ -.\" 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. 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. -.\" -.\" $OpenBSD: qabs.3,v 1.13 2013/06/05 03:39:23 tedu Exp $ -.\" -.Dd $Mdocdate: June 5 2013 $ -.Dt QABS 3 -.Os -.Sh NAME -.Nm qabs -.Nd return the absolute value of a quad integer -.Sh SYNOPSIS -.In stdlib.h -.Ft quad_t -.Fn qabs "quad_t j" -.Sh DESCRIPTION -The -.Fn qabs -function returns the absolute value of the quad integer -.Fa j . -.Sh SEE ALSO -.Xr abs 3 , -.Xr cabs 3 , -.Xr floor 3 , -.Xr imaxabs 3 , -.Xr labs 3 -.Sh BUGS -The absolute value of the most negative integer remains negative. diff --git a/src/lib/libc/stdlib/qabs.c b/src/lib/libc/stdlib/qabs.c deleted file mode 100644 index 656b93c8..00000000 --- a/src/lib/libc/stdlib/qabs.c +++ /dev/null @@ -1,37 +0,0 @@ -/* $OpenBSD: qabs.c,v 1.5 2005/08/08 08:05:37 espie Exp $ */ -/*- - * 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. 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 - -quad_t -qabs(quad_t j) -{ - return(j < 0 ? -j : j); -} diff --git a/src/lib/libc/stdlib/qdiv.3 b/src/lib/libc/stdlib/qdiv.3 deleted file mode 100644 index 5f527549..00000000 --- a/src/lib/libc/stdlib/qdiv.3 +++ /dev/null @@ -1,61 +0,0 @@ -.\" Copyright (c) 1990, 1991 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. -.\" -.\" $OpenBSD: qdiv.3,v 1.10 2013/06/05 03:39:23 tedu Exp $ -.\" -.Dd $Mdocdate: June 5 2013 $ -.Dt QDIV 3 -.Os -.Sh NAME -.Nm qdiv -.Nd return quotient and remainder from division -.Sh SYNOPSIS -.In stdlib.h -.Ft qdiv_t -.Fn qdiv "quad_t num" "quad_t denom" -.Sh DESCRIPTION -The -.Fn qdiv -function computes the value -.Fa num Ns / Ns Fa denom -and returns the quotient and remainder in a structure named -.Li qdiv_t -that contains two -.Li quad integer -members named -.Fa quot -and -.Fa rem . -.Sh SEE ALSO -.Xr div 3 , -.Xr imaxdiv 3 , -.Xr ldiv 3 , -.Xr lldiv 3 diff --git a/src/lib/libc/stdlib/qdiv.c b/src/lib/libc/stdlib/qdiv.c deleted file mode 100644 index f3db0915..00000000 --- a/src/lib/libc/stdlib/qdiv.c +++ /dev/null @@ -1,50 +0,0 @@ -/* $OpenBSD: qdiv.c,v 1.5 2005/08/08 08:05:37 espie Exp $ */ -/* - * Copyright (c) 1990 Regents of the University of California. - * All 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 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. - */ - -#include /* qdiv_t */ - -qdiv_t -qdiv(quad_t num, quad_t denom) -{ - qdiv_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); -}