Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libc/stdlib Collect also the division functions to singl...



details:   https://anonhg.NetBSD.org/src/rev/f09c30042207
branches:  trunk
changeset: 764175:f09c30042207
user:      jruoho <jruoho%NetBSD.org@localhost>
date:      Wed Apr 13 07:12:52 2011 +0000

description:
Collect also the division functions to single place, div(3).

diffstat:

 lib/libc/stdlib/Makefile.inc |   9 +++-
 lib/libc/stdlib/div.3        |  64 +++++++++++++++++++++++--------------
 lib/libc/stdlib/imaxdiv.3    |  75 --------------------------------------------
 lib/libc/stdlib/ldiv.3       |  73 ------------------------------------------
 lib/libc/stdlib/lldiv.3      |  73 ------------------------------------------
 5 files changed, 46 insertions(+), 248 deletions(-)

diffs (truncated from 354 to 300 lines):

diff -r f0631f4a7545 -r f09c30042207 lib/libc/stdlib/Makefile.inc
--- a/lib/libc/stdlib/Makefile.inc      Wed Apr 13 06:56:50 2011 +0000
+++ b/lib/libc/stdlib/Makefile.inc      Wed Apr 13 07:12:52 2011 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile.inc,v 1.76 2011/04/13 06:56:50 jruoho Exp $
+#      $NetBSD: Makefile.inc,v 1.77 2011/04/13 07:12:52 jruoho Exp $
 #      from: @(#)Makefile.inc  8.3 (Berkeley) 2/4/95
 
 # stdlib sources
@@ -43,9 +43,9 @@
        exit.3 \
        getenv.3 getopt.3 getopt_long.3 getsubopt.3 grantpt.3 \
        hcreate.3 \
-       imaxdiv.3 insque.3 \
+       insque.3 \
        jemalloc.3 \
-       ldiv.3 lldiv.3 lsearch.3 \
+       lsearch.3 \
        malloc.3 memory.3 mi_vector_hash.3 \
        posix_memalign.3 posix_openpt.3 ptsname.3 \
        qabs.3 qdiv.3 qsort.3 \
@@ -59,6 +59,9 @@
 MLINKS+=abs.3 labs.3 \
        abs.3 llabs.3 \
        abs.3 imaxabs.3
+MLINKS+=div.3 ldiv.3 \
+       div.3 lldiv.3 \
+       div.3 imaxdiv.3
 MLINKS+=getenv.3 setenv.3 getenv.3 unsetenv.3 getenv.3 putenv.3
 MLINKS+=getenv.3 getenv_r.3
 MLINKS+=hcreate.3 hdestroy.3 hcreate.3 hsearch.3
diff -r f0631f4a7545 -r f09c30042207 lib/libc/stdlib/div.3
--- a/lib/libc/stdlib/div.3     Wed Apr 13 06:56:50 2011 +0000
+++ b/lib/libc/stdlib/div.3     Wed Apr 13 07:12:52 2011 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: div.3,v 1.12 2008/08/04 21:29:27 matt Exp $
+.\"    $NetBSD: div.3,v 1.13 2011/04/13 07:12:52 jruoho Exp $
 .\"
 .\" Copyright (c) 1990, 1991, 1993
 .\"    The Regents of the University of California.  All rights reserved.
@@ -31,41 +31,57 @@
 .\"
 .\"     from: @(#)div.3        8.1 (Berkeley) 6/4/93
 .\"
-.Dd June 4, 1993
+.Dd April 13, 2011
 .Dt DIV 3
 .Os
 .Sh NAME
-.Nm div
-.Nd return quotient and remainder from division
+.Nm div ,
+.Nm ldiv ,
+.Nm lldiv ,
+.Nm imaxdiv
+.Nd quotient and remainder from division
 .Sh LIBRARY
 .Lb libc
 .Sh SYNOPSIS
 .In stdlib.h
 .Ft div_t
 .Fn div "int num" "int denom"
+.Ft ldiv_t
+.Fn ldiv "long int num" "long int denom"
+.Ft lldiv_t
+.Fn lldiv "long long int num" "long long int denom"
+.In inttypes.h
+.Ft imaxdiv_t
+.Fn imaxdiv "intmax_t num" "intmax_t denom"
 .Sh DESCRIPTION
-The
-.Fn div
-function
-computes the value
-.Fa num/denom
-and returns the quotient and remainder in a structure named
-.Fa div_t
-that contains two
-.Em int
-members named
-.Fa quot
+These functions compute the value of
+.Fa num / denom
+and return the quotient and remainder in a specific divison structure.
+The functions differ only with respect to the type of the return value and
+the parameters.
+.Pp
+The returned structure always contains two members named
+.Vt quot
 and
-.Fa rem .
+.Vt rem ,
+denoting the quotient and the remainder.
+The type of these correspond with the underlying type of the function.
+.Sh EXAMPLES
+The following example demonstrate the basic usage of the functions.
+.Bd -literal -offset indent
+div_t d;
+
+int a = 4321;
+int b = 1234;
+
+d = div(a, b);
+
+(void)printf(\*[q]%d %d\en\*[q], d.quot, d.rem);
+.Ed
 .Sh SEE ALSO
-.Xr imaxdiv 3 ,
-.Xr ldiv 3 ,
-.Xr lldiv 3 ,
+.Xr fast_divide32 3 ,
 .Xr math 3 ,
 .Xr qdiv 3
 .Sh STANDARDS
-The
-.Fn div
-function
-conforms to
-.St -ansiC .
+All described functions conform to
+.St -isoC-99 .
diff -r f0631f4a7545 -r f09c30042207 lib/libc/stdlib/imaxdiv.3
--- a/lib/libc/stdlib/imaxdiv.3 Wed Apr 13 06:56:50 2011 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,75 +0,0 @@
-.\"    $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 -r f0631f4a7545 -r f09c30042207 lib/libc/stdlib/ldiv.3
--- a/lib/libc/stdlib/ldiv.3    Wed Apr 13 06:56:50 2011 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,73 +0,0 @@
-.\"    $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.
-.\"
-.\" 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 June 4, 1993
-.Dt LDIV 3
-.Os
-.Sh NAME
-.Nm ldiv
-.Nd return quotient and remainder from division
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In stdlib.h
-.Ft ldiv_t
-.Fn ldiv "long int num" "long int denom"
-.Sh DESCRIPTION
-The
-.Fn ldiv
-function
-computes the value
-.Ar num/denom
-and returns the quotient and remainder in a structure named
-.Ar ldiv_t
-that contains two
-.Em long integer
-members named
-.Ar quot
-and
-.Ar rem .
-.Sh SEE ALSO
-.Xr div 3 ,
-.Xr imaxdiv 3 ,
-.Xr lldiv 3 ,
-.Xr math 3 ,
-.Xr qdiv 3
-.Sh STANDARDS
-The
-.Fn ldiv
-function
-conforms to
-.St -ansiC .
diff -r f0631f4a7545 -r f09c30042207 lib/libc/stdlib/lldiv.3
--- a/lib/libc/stdlib/lldiv.3   Wed Apr 13 06:56:50 2011 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,73 +0,0 @@
-.\"    $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.
-.\"
-.\" 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



Home | Main Index | Thread Index | Old Index