Browse Source

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@
OPENBSD_6_1
guenther 7 years ago
parent
commit
502002cd1a
12 changed files with 36 additions and 228 deletions
  1. +4
    -4
      src/lib/libc/stdlib/Makefile.inc
  2. +3
    -4
      src/lib/libc/stdlib/div.3
  3. +3
    -4
      src/lib/libc/stdlib/imaxdiv.3
  4. +8
    -2
      src/lib/libc/stdlib/labs.3
  5. +3
    -4
      src/lib/libc/stdlib/ldiv.3
  6. +3
    -1
      src/lib/libc/stdlib/llabs.c
  7. +9
    -4
      src/lib/libc/stdlib/lldiv.3
  8. +3
    -1
      src/lib/libc/stdlib/lldiv.c
  9. +0
    -56
      src/lib/libc/stdlib/qabs.3
  10. +0
    -37
      src/lib/libc/stdlib/qabs.c
  11. +0
    -61
      src/lib/libc/stdlib/qdiv.3
  12. +0
    -50
      src/lib/libc/stdlib/qdiv.c

+ 4
- 4
src/lib/libc/stdlib/Makefile.inc View File

@ -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

+ 3
- 4
src/lib/libc/stdlib/div.3 View File

@ -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


+ 3
- 4
src/lib/libc/stdlib/imaxdiv.3 View File

@ -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


+ 8
- 2
src/lib/libc/stdlib/labs.3 View File

@ -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 ,


+ 3
- 4
src/lib/libc/stdlib/ldiv.3 View File

@ -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


+ 3
- 1
src/lib/libc/stdlib/llabs.c View File

@ -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);

+ 9
- 4
src/lib/libc/stdlib/lldiv.3 View File

@ -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


+ 3
- 1
src/lib/libc/stdlib/lldiv.c View File

@ -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);

+ 0
- 56
src/lib/libc/stdlib/qabs.3 View File

@ -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.

+ 0
- 37
src/lib/libc/stdlib/qabs.c View File

@ -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 <stdlib.h>
quad_t
qabs(quad_t j)
{
return(j < 0 ? -j : j);
}

+ 0
- 61
src/lib/libc/stdlib/qdiv.3 View File

@ -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

+ 0
- 50
src/lib/libc/stdlib/qdiv.c View File

@ -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 <stdlib.h> /* 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);
}

Loading…
Cancel
Save