Module Name: src Committed By: jruoho Date: Wed Apr 13 07:12:52 UTC 2011
Modified Files: src/lib/libc/stdlib: Makefile.inc div.3 Removed Files: src/lib/libc/stdlib: imaxdiv.3 ldiv.3 lldiv.3 Log Message: Collect also the division functions to single place, div(3). To generate a diff of this commit: cvs rdiff -u -r1.76 -r1.77 src/lib/libc/stdlib/Makefile.inc cvs rdiff -u -r1.12 -r1.13 src/lib/libc/stdlib/div.3 cvs rdiff -u -r1.1 -r0 src/lib/libc/stdlib/imaxdiv.3 cvs rdiff -u -r1.13 -r0 src/lib/libc/stdlib/ldiv.3 cvs rdiff -u -r1.7 -r0 src/lib/libc/stdlib/lldiv.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/lib/libc/stdlib/Makefile.inc diff -u src/lib/libc/stdlib/Makefile.inc:1.76 src/lib/libc/stdlib/Makefile.inc:1.77 --- src/lib/libc/stdlib/Makefile.inc:1.76 Wed Apr 13 06:56:50 2011 +++ src/lib/libc/stdlib/Makefile.inc Wed Apr 13 07:12:52 2011 @@ -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 Index: src/lib/libc/stdlib/div.3 diff -u src/lib/libc/stdlib/div.3:1.12 src/lib/libc/stdlib/div.3:1.13 --- src/lib/libc/stdlib/div.3:1.12 Mon Aug 4 21:29:27 2008 +++ src/lib/libc/stdlib/div.3 Wed Apr 13 07:12:52 2011 @@ -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 .