The branch main has been updated by obiwac: URL: https://cgit.FreeBSD.org/src/commit/?id=c242bf1b70796313dabb5594b5aacdf4c20377aa
commit c242bf1b70796313dabb5594b5aacdf4c20377aa Author: Aymeric Wibo <[email protected]> AuthorDate: 2026-02-21 23:14:23 +0000 Commit: Aymeric Wibo <[email protected]> CommitDate: 2026-02-21 23:19:25 +0000 libc: Roll {l,ll,imax}div(3) manpages into just div(3) No need to have 4 separate manpages for these functions. Reviewed by: ziaee, rpokala, des Approved by: rpokala, des Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D55360 --- lib/libc/stdlib/Makefile.inc | 5 ++- lib/libc/stdlib/div.3 | 86 ++++++++++++++++++++++++++++++++------------ lib/libc/stdlib/imaxdiv.3 | 71 ------------------------------------ lib/libc/stdlib/ldiv.3 | 76 --------------------------------------- lib/libc/stdlib/lldiv.3 | 71 ------------------------------------ 5 files changed, 67 insertions(+), 242 deletions(-) diff --git a/lib/libc/stdlib/Makefile.inc b/lib/libc/stdlib/Makefile.inc index c2107fdaeaae..3698377b9b27 100644 --- a/lib/libc/stdlib/Makefile.inc +++ b/lib/libc/stdlib/Makefile.inc @@ -91,7 +91,7 @@ SYM_MAPS+= ${LIBC_SRCTOP}/stdlib/Symbol.map MAN+= a64l.3 abort.3 abs.3 atexit.3 atof.3 \ atoi.3 atol.3 at_quick_exit.3 bsearch.3 \ div.3 exit.3 getenv.3 getopt.3 getopt_long.3 getsubopt.3 \ - hcreate.3 imaxabs.3 imaxdiv.3 insque.3 labs.3 ldiv.3 llabs.3 lldiv.3 \ + hcreate.3 imaxabs.3 insque.3 labs.3 llabs.3 \ lsearch.3 memalignment.3 memory.3 ptsname.3 qsort.3 \ quick_exit.3 \ radixsort.3 rand.3 random.3 reallocarray.3 reallocf.3 realpath.3 \ @@ -102,6 +102,9 @@ MAN+= a64l.3 abort.3 abs.3 atexit.3 atof.3 \ MLINKS+=a64l.3 l64a.3 \ a64l.3 l64a_r.3 MLINKS+=atol.3 atoll.3 +MLINKS+=div.3 ldiv.3 \ + div.3 lldiv.3 \ + div.3 imaxdiv.3 MLINKS+=exit.3 _Exit.3 MLINKS+=getenv.3 clearenv.3 \ getenv.3 putenv.3 \ diff --git a/lib/libc/stdlib/div.3 b/lib/libc/stdlib/div.3 index 87b9665684fb..6565a4159562 100644 --- a/lib/libc/stdlib/div.3 +++ b/lib/libc/stdlib/div.3 @@ -1,8 +1,12 @@ .\" Copyright (c) 1990, 1991, 1993 .\" The Regents of the University of California. All rights reserved. +.\" Copyright (c) 2001 Mike Barcroft <[email protected]> +.\" Copyright (c) 2026 Aymeric Wibo <[email protected]> .\" .\" This code is derived from software contributed to Berkeley by -.\" Chris Torek. +.\" 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: @@ -27,41 +31,77 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd February 12, 2026 +.Dd February 18, 2026 .Dt DIV 3 .Os .Sh NAME -.Nm div +.Nm div , +.Nm ldiv , +.Nm lldiv , +.Nm imaxdiv .Nd return quotient and remainder from division -.Sh LIBRARY -.Lb libc .Sh SYNOPSIS +.Lb libc .In stdlib.h .Ft div_t .Fn div "int numer" "int denom" +.Ft ldiv_t +.Fn ldiv "long numer" "long denom" +.Ft lldiv_t +.Fn lldiv "long long numer" "long long denom" +.In inttypes.h +.Ft imaxdiv_t +.Fn imaxdiv "intmax_t numer" "intmax_t denom" .Sh DESCRIPTION The -.Fn div -function -computes the value -.Fa numer Ns / Ns Fa denom -(numerator/denominator). -It returns a structure named -.Fa div_t -that contains two -.Vt int +.Fn div , +.Fn ldiv , +.Fn lldiv , +and +.Fn imaxdiv +functions compute the value of +.Fa numer +(the numerator) divided by +.Fa denom +(the denominator) and return the stored result in the form of the +.Fa div_t , +.Fa ldiv_t , +.Fa lldiv_t , +or +.Fa imaxdiv_t +types, respectively. +These types are structs which contain two +.Vt int , +.Vt long , +.Vt long long , +or +.Vt intmax_t members named .Va quot -(quotient) and +(the quotient) and .Va rem -(remainder). -.Sh SEE ALSO -.Xr imaxdiv 3 , -.Xr ldiv 3 , -.Xr lldiv 3 +(the remainder). .Sh STANDARDS The +.Fn div , +.Fn ldiv , +.Fn lldiv , +and +.Fn imaxdiv +functions conform to +.St -isoC-2023 +and +.St -p1003.1-2024 . +.Sh HISTORY +The .Fn div -function -conforms to -.St -isoC-99 . +and +.Fn ldiv +functions first appeared in +.Bx 4.3 . +The +.Fn lldiv +and +.Fn imaxdiv +functions first appeared in +.Fx 5.0 . diff --git a/lib/libc/stdlib/imaxdiv.3 b/lib/libc/stdlib/imaxdiv.3 deleted file mode 100644 index 9e51c47b53c3..000000000000 --- a/lib/libc/stdlib/imaxdiv.3 +++ /dev/null @@ -1,71 +0,0 @@ -.\" Copyright (c) 2001 Mike Barcroft <[email protected]> -.\" 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. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. -.\" -.Dd February 12, 2026 -.Dt IMAXDIV 3 -.Os -.Sh NAME -.Nm imaxdiv -.Nd returns quotient and remainder -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In inttypes.h -.Ft imaxdiv_t -.Fn imaxdiv "intmax_t numer" "intmax_t denom" -.Sh DESCRIPTION -The -.Fn imaxdiv -function computes the value of -.Fa numer -(numerator) divided by -.Fa denom -(denominator) and returns the stored result in the form of the -.Vt imaxdiv_t -type. -.Pp -The -.Vt imaxdiv_t -type is defined as: -.Bd -literal -offset indent -typedef struct { - intmax_t quot; /* Quotient. */ - intmax_t rem; /* Remainder. */ -} imaxdiv_t; -.Ed -.Sh SEE ALSO -.Xr div 3 , -.Xr ldiv 3 , -.Xr lldiv 3 , -.Xr math 3 -.Sh STANDARDS -The -.Fn imaxdiv -function conforms to -.St -isoC-99 . -.Sh HISTORY -The -.Fn imaxdiv -function first appeared in -.Fx 5.0 . diff --git a/lib/libc/stdlib/ldiv.3 b/lib/libc/stdlib/ldiv.3 deleted file mode 100644 index c2ab444bdcab..000000000000 --- a/lib/libc/stdlib/ldiv.3 +++ /dev/null @@ -1,76 +0,0 @@ -.\" 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. -.\" -.Dd February 12, 2026 -.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 numer" "long denom" -.Sh DESCRIPTION -The -.Fn ldiv -function -computes the value -.Fa numer Ns / Ns Fa denom -(numerator/denominator). -It returns the quotient and remainder in a structure named -.Vt ldiv_t -that contains two -.Vt long -members named -.Va quot -(quotient) and -.Va rem -(remainder). -.Sh SEE ALSO -.Xr div 3 , -.Xr imaxdiv 3 , -.Xr lldiv 3 , -.Xr math 3 -.Sh STANDARDS -The -.Fn ldiv -function -conforms to -.St -isoC-99 . -.Sh HISTORY -An -.Fn ldiv -function with similar functionality, but a different calling convention, -first appeared in -.At v4 . diff --git a/lib/libc/stdlib/lldiv.3 b/lib/libc/stdlib/lldiv.3 deleted file mode 100644 index 783ea3df6554..000000000000 --- a/lib/libc/stdlib/lldiv.3 +++ /dev/null @@ -1,71 +0,0 @@ -.\" Copyright (c) 2001 Mike Barcroft <[email protected]> -.\" 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. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. -.\" -.Dd February 12, 2026 -.Dt LLDIV 3 -.Os -.Sh NAME -.Nm lldiv -.Nd returns quotient and remainder -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In stdlib.h -.Ft lldiv_t -.Fn lldiv "long long numer" "long long denom" -.Sh DESCRIPTION -The -.Fn lldiv -function computes the value of -.Fa numer -(numerator) divided by -.Fa denom -(denominator) and returns the stored result in the form of the -.Vt lldiv_t -type. -.Pp -The -.Vt lldiv_t -type is defined as: -.Bd -literal -offset indent -typedef struct { - long long quot; /* Quotient. */ - long long rem; /* Remainder. */ -} lldiv_t; -.Ed -.Sh SEE ALSO -.Xr div 3 , -.Xr imaxdiv 3 , -.Xr ldiv 3 , -.Xr math 3 -.Sh STANDARDS -The -.Fn lldiv -function conforms to -.St -isoC-99 . -.Sh HISTORY -The -.Fn lldiv -function first appeared in -.Fx 5.0 .
