Source-Changes-HG archive

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

[src/trunk]: src/lib/libc/stdlib put reallocarray() in the public namespace



details:   https://anonhg.NetBSD.org/src/rev/f23e17f183aa
branches:  trunk
changeset: 372138:f23e17f183aa
user:      wiz <wiz%NetBSD.org@localhost>
date:      Fri Oct 28 09:43:58 2022 +0000

description:
put reallocarray() in the public namespace

reallocarray() will be part of the next POSIX release, see
https://austingroupbugs.net/view.php?id=1218

adapt an errno value to match POSIX expectations

As discussed on tech-userlevel

diffstat:

 external/mit/xorg/bin/fslsfonts/Makefile                     |   4 +-
 external/mit/xorg/bin/xauth/Makefile                         |   3 +-
 external/mit/xorg/bin/xrdb/Makefile                          |   3 +-
 external/mit/xorg/lib/libFS/Makefile                         |   3 +-
 external/mit/xorg/lib/libX11/Makefile.libx11                 |   4 +-
 external/mit/xorg/lib/libXfont2/Makefile                     |   4 +-
 external/mit/xorg/lib/libfontenc/Makefile                    |   4 +-
 external/mit/xorg/server/xorg-server/Makefile.serverlib      |   4 +-
 external/mit/xorg/server/xorg-server/Makefile.servermod      |   4 +-
 external/mit/xorg/server/xorg-server/hw/netbsd/x68k/Makefile |   3 +-
 external/mit/xorg/server/xorg-server/hw/sun/Makefile.Xsun    |   4 +-
 external/mit/xorg/server/xorg-server/hw/vfb/Makefile         |   5 +-
 external/mit/xorg/server/xorg-server/os/Makefile             |   3 +-
 include/stdlib.h                                             |   4 +-
 lib/libc/stdlib/reallocarray.3                               |  29 ++++-------
 lib/libc/stdlib/reallocarray.c                               |  10 ++-
 16 files changed, 43 insertions(+), 48 deletions(-)

diffs (truncated from 359 to 300 lines):

diff -r 2e372f3ebcba -r f23e17f183aa external/mit/xorg/bin/fslsfonts/Makefile
--- a/external/mit/xorg/bin/fslsfonts/Makefile  Fri Oct 28 08:16:57 2022 +0000
+++ b/external/mit/xorg/bin/fslsfonts/Makefile  Fri Oct 28 09:43:58 2022 +0000
@@ -1,10 +1,10 @@
-#      $NetBSD: Makefile,v 1.4 2022/10/16 23:38:02 mrg Exp $
+#      $NetBSD: Makefile,v 1.5 2022/10/28 09:43:58 wiz Exp $
 
 .include <bsd.own.mk>
 
 PROG=  fslsfonts
 
-CPPFLAGS+=     -DHAVE_REALLOCARRAY -D_OPENBSD_SOURCE
+CPPFLAGS+=     -DHAVE_REALLOCARRAY
 
 LDADD+=        -lFS
 DPADD+=        ${LIBFS}
diff -r 2e372f3ebcba -r f23e17f183aa external/mit/xorg/bin/xauth/Makefile
--- a/external/mit/xorg/bin/xauth/Makefile      Fri Oct 28 08:16:57 2022 +0000
+++ b/external/mit/xorg/bin/xauth/Makefile      Fri Oct 28 09:43:58 2022 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.8 2021/04/12 06:08:30 mrg Exp $
+#      $NetBSD: Makefile,v 1.9 2022/10/28 09:43:58 wiz Exp $
 
 .include <bsd.own.mk>
 
@@ -7,6 +7,7 @@
 
 CPPFLAGS+=             -DRETSIGTYPE=void -DPACKAGE_VERSION=\"1.0.8\"
 CPPFLAGS+=             -DHAVE_STRLCPY
+CPPFLAGS+=             -DHAVE_REALLOCARRAY
 CPPFLAGS.gethost.c=    ${X11FLAGS.CONNECTION}
 CPPFLAGS.parsedpy.c=   ${X11FLAGS.CONNECTION}
 
diff -r 2e372f3ebcba -r f23e17f183aa external/mit/xorg/bin/xrdb/Makefile
--- a/external/mit/xorg/bin/xrdb/Makefile       Fri Oct 28 08:16:57 2022 +0000
+++ b/external/mit/xorg/bin/xrdb/Makefile       Fri Oct 28 09:43:58 2022 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.9 2022/09/19 18:46:06 christos Exp $
+#      $NetBSD: Makefile,v 1.10 2022/10/28 09:43:58 wiz Exp $
 
 .include <bsd.own.mk>
 
@@ -6,6 +6,7 @@
 
 CPPFLAGS+=-DCPP="\"/usr/bin/tradcpp -nostdinc\"" -DHAVE_MKSTEMP        # XXX
 CPPFLAGS+=-DHAVE_ASPRINTF
+CPPFLAGS+=-DHAVE_REALLOCARRAY
 
 LDADD+=        -lXmuu -lXt -lSM -lICE -lXext -lX11
 DPADD+=        ${LIBXMUU} ${LIBXT} ${LIBSM} ${LIBICE} ${LIBXEXT} ${LIBX11}
diff -r 2e372f3ebcba -r f23e17f183aa external/mit/xorg/lib/libFS/Makefile
--- a/external/mit/xorg/lib/libFS/Makefile      Fri Oct 28 08:16:57 2022 +0000
+++ b/external/mit/xorg/lib/libFS/Makefile      Fri Oct 28 09:43:58 2022 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.4 2022/09/09 03:46:29 mrg Exp $
+#      $NetBSD: Makefile,v 1.5 2022/10/28 09:43:58 wiz Exp $
 
 .include <bsd.own.mk>
 
@@ -18,7 +18,6 @@
 INCSDIR=${X11INCDIR}/X11/fonts
 
 CPPFLAGS+=     -I${DESTDIR}${X11INCDIR}/X11/fonts \
-               -D_OPENBSD_SOURCE \
                -DHAVE_REALLOCARRAY \
                -DHAVE_STRNLEN \
                -DHAVE_STRLCPY \
diff -r 2e372f3ebcba -r f23e17f183aa external/mit/xorg/lib/libX11/Makefile.libx11
--- a/external/mit/xorg/lib/libX11/Makefile.libx11      Fri Oct 28 08:16:57 2022 +0000
+++ b/external/mit/xorg/lib/libX11/Makefile.libx11      Fri Oct 28 09:43:58 2022 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile.libx11,v 1.24 2022/07/14 07:40:48 mrg Exp $
+#      $NetBSD: Makefile.libx11,v 1.25 2022/10/28 09:43:58 wiz Exp $
 
 LIB=   X11
 .PATH: ${X11SRCDIR.${LIB}}/src
@@ -404,7 +404,7 @@
 CPPFLAGS+=     -DHAVE_UNISTD_H
 CPPFLAGS+=     -DHAVE_STRCASECMP -DHAVE_STRLCPY -DHAVE_STRTOL
 CPPFLAGS+=     -DHAVE_SYS_FILIO_H -DHAVE_SYS_IOCTL_H -DHAVE_SYS_SOCKET_H
-CPPFLAGS+=     -DHAVE_REALLOCARRAY -D_OPENBSD_SOURCE
+CPPFLAGS+=     -DHAVE_REALLOCARRAY
 CPPFLAGS+=     -DHAVE_STRCASECMP -DHAVE_STRLCPY -DHAVE___BUILTIN_POPCOUNTL
 CPPFLAGS+=     -DUSE_THREAD_SAFETY_CONSTRUCTOR
 
diff -r 2e372f3ebcba -r f23e17f183aa external/mit/xorg/lib/libXfont2/Makefile
--- a/external/mit/xorg/lib/libXfont2/Makefile  Fri Oct 28 08:16:57 2022 +0000
+++ b/external/mit/xorg/lib/libXfont2/Makefile  Fri Oct 28 09:43:58 2022 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.10 2022/09/14 07:37:05 mrg Exp $
+#      $NetBSD: Makefile,v 1.11 2022/10/28 09:43:58 wiz Exp $
 
 USE_FORT?=     yes # data-driven bugs?
 
@@ -104,7 +104,7 @@
 
 CPPFLAGS+=     ${X11FLAGS.THREADLIB} ${X11FLAGS.CONNECTION}
 CPPFLAGS+=     -DHAVE_STRLCPY
-CPPFLAGS+=     -DHAVE_REALLOCARRAY -D_OPENBSD_SOURCE
+CPPFLAGS+=     -DHAVE_REALLOCARRAY
 CPPFLAGS+=     -DHAVE_READLINK
 CPPFLAGS+=     -DHAVE_STDINT_H
 CPPFLAGS+=     -DHAVE_STRLCPY
diff -r 2e372f3ebcba -r f23e17f183aa external/mit/xorg/lib/libfontenc/Makefile
--- a/external/mit/xorg/lib/libfontenc/Makefile Fri Oct 28 08:16:57 2022 +0000
+++ b/external/mit/xorg/lib/libfontenc/Makefile Fri Oct 28 09:43:58 2022 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.4 2022/09/09 03:49:19 mrg Exp $
+#      $NetBSD: Makefile,v 1.5 2022/10/28 09:43:59 wiz Exp $
 
 .include <bsd.own.mk>
 
@@ -14,7 +14,7 @@
 CPPFLAGS+=     -DFONTENC_NO_LIBFONT
 CPPFLAGS+=     -DFONT_ENCODINGS_DIRECTORY=\"${X11FONTDIR}/encodings/encodings.dir\"
 CPPFLAGS+=     -I${DESTDIR}${X11INCDIR}/X11/fonts
-CPPFLAGS+=     -DHAVE_REALLOCARRAY -D_OPENBSD_SOURCE
+CPPFLAGS+=     -DHAVE_REALLOCARRAY
 
 LIBDPLIBS+=    z ${NETBSDSRCDIR}/lib/libz
 
diff -r 2e372f3ebcba -r f23e17f183aa external/mit/xorg/server/xorg-server/Makefile.serverlib
--- a/external/mit/xorg/server/xorg-server/Makefile.serverlib   Fri Oct 28 08:16:57 2022 +0000
+++ b/external/mit/xorg/server/xorg-server/Makefile.serverlib   Fri Oct 28 09:43:58 2022 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile.serverlib,v 1.16 2022/07/15 04:18:54 mrg Exp $
+#      $NetBSD: Makefile.serverlib,v 1.17 2022/10/28 09:43:59 wiz Exp $
 
 NOFULLRELRO=   yes
 
@@ -22,7 +22,7 @@
 X_BYTE_ORDER=0
 .endif
 
-CPPFLAGS+=     ${X11FLAGS.SERVER} -D_OPENBSD_SOURCE
+CPPFLAGS+=     ${X11FLAGS.SERVER}
 CPPFLAGS+=     -DXORG_VERSION_CURRENT=${XORG_VERSION_CURRENT}
 
 .if ${HAVE_XORG_GLAMOR} != "no"
diff -r 2e372f3ebcba -r f23e17f183aa external/mit/xorg/server/xorg-server/Makefile.servermod
--- a/external/mit/xorg/server/xorg-server/Makefile.servermod   Fri Oct 28 08:16:57 2022 +0000
+++ b/external/mit/xorg/server/xorg-server/Makefile.servermod   Fri Oct 28 09:43:58 2022 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile.servermod,v 1.9 2022/07/15 04:18:54 mrg Exp $
+#      $NetBSD: Makefile.servermod,v 1.10 2022/10/28 09:43:59 wiz Exp $
 
 NOFULLRELRO=   yes
 
@@ -28,7 +28,7 @@
 CPPFLAGS+=     ${X11FLAGS.LOADABLE}
 .endif
 
-CPPFLAGS+=     ${X11FLAGS.DIX} -D_OPENBSD_SOURCE
+CPPFLAGS+=     ${X11FLAGS.DIX}
 
 # IOPortBase is particularly annoying to fix
 COPTS+=         ${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} >= 10:? -fcommon :}
diff -r 2e372f3ebcba -r f23e17f183aa external/mit/xorg/server/xorg-server/hw/netbsd/x68k/Makefile
--- a/external/mit/xorg/server/xorg-server/hw/netbsd/x68k/Makefile      Fri Oct 28 08:16:57 2022 +0000
+++ b/external/mit/xorg/server/xorg-server/hw/netbsd/x68k/Makefile      Fri Oct 28 09:43:58 2022 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.13 2022/07/15 19:12:39 mrg Exp $
+#      $NetBSD: Makefile,v 1.14 2022/10/28 09:43:59 wiz Exp $
 
 .include <bsd.own.mk>
 
@@ -33,7 +33,6 @@
                -UXF86DRI -UXF86BIGFONT
 
 CPPFLAGS+=     -UHAVE_XORG_CONFIG_H
-CPPFLAGS+=     -D_OPENBSD_SOURCE
 
 CPPFLAGS.x68kConfig.c=  -DX11_LIBDIR=\"${X11ETCDIR}\"
 
diff -r 2e372f3ebcba -r f23e17f183aa external/mit/xorg/server/xorg-server/hw/sun/Makefile.Xsun
--- a/external/mit/xorg/server/xorg-server/hw/sun/Makefile.Xsun Fri Oct 28 08:16:57 2022 +0000
+++ b/external/mit/xorg/server/xorg-server/hw/sun/Makefile.Xsun Fri Oct 28 09:43:58 2022 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile.Xsun,v 1.7 2022/07/15 19:12:39 mrg Exp $
+#      $NetBSD: Makefile.Xsun,v 1.8 2022/10/28 09:43:59 wiz Exp $
 
 .include <bsd.own.mk>
 
@@ -15,7 +15,7 @@
 BUILDSYMLINKS=
 CPPFLAGS+=     -DDEFAULT_LOGDIR=\"/var/log\" -DDEFAULT_LOGPREFIX=\"${PROG}.\"
 CPPFLAGS+=     -DINCLUDE_CG2_HEADER
-CPPFLAGS+=     -D_OPENBSD_SOURCE -D_XTYPEDEF_POINTER=1
+CPPFLAGS+=     -D_XTYPEDEF_POINTER=1
 #CPPFLAGS+=    -DLOWMEMFTPT
 
 # for Xsun (8bpp)
diff -r 2e372f3ebcba -r f23e17f183aa external/mit/xorg/server/xorg-server/hw/vfb/Makefile
--- a/external/mit/xorg/server/xorg-server/hw/vfb/Makefile      Fri Oct 28 08:16:57 2022 +0000
+++ b/external/mit/xorg/server/xorg-server/hw/vfb/Makefile      Fri Oct 28 09:43:58 2022 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.22 2022/07/15 19:12:39 mrg Exp $
+#      $NetBSD: Makefile,v 1.23 2022/10/28 09:43:59 wiz Exp $
 
 .include <bsd.own.mk>
 
@@ -28,8 +28,7 @@
                -UGLXEXT
 
 CPPFLAGS+=     ${X11FLAGS.OS_DEFINES} ${X11FLAGS.DIX} \
-               -DHAS_SHM -DHAS_MMAP -UXFree86LOADER \
-               -D_OPENBSD_SOURCE
+               -DHAS_SHM -DHAS_MMAP -UXFree86LOADER
 
 .include "../../Makefile.common"
 
diff -r 2e372f3ebcba -r f23e17f183aa external/mit/xorg/server/xorg-server/os/Makefile
--- a/external/mit/xorg/server/xorg-server/os/Makefile  Fri Oct 28 08:16:57 2022 +0000
+++ b/external/mit/xorg/server/xorg-server/os/Makefile  Fri Oct 28 09:43:58 2022 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.18 2022/07/15 04:18:56 mrg Exp $
+#      $NetBSD: Makefile,v 1.19 2022/10/28 09:43:59 wiz Exp $
 
 .include "../Makefile.serverlib"
 .include "../Makefile.servermod"
@@ -11,7 +11,6 @@
        oscolor.c ospoll.c osinit.c utils.c xdmauth.c \
        xstrans.c xprintf.c log.c xdmcp.c busfault.c \
        rpcauth.c xsha1.c \
-       reallocarray.c \
        timingsafe_memcmp.c
 
 CPPFLAGS+=     -I${X11SRCDIR.xorg-server}/include \
diff -r 2e372f3ebcba -r f23e17f183aa include/stdlib.h
--- a/include/stdlib.h  Fri Oct 28 08:16:57 2022 +0000
+++ b/include/stdlib.h  Fri Oct 28 09:43:58 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: stdlib.h,v 1.124 2022/10/05 12:09:07 nia Exp $ */
+/*     $NetBSD: stdlib.h,v 1.125 2022/10/28 09:43:59 wiz Exp $ */
 
 /*-
  * Copyright (c) 1990, 1993
@@ -118,6 +118,7 @@
 void    qsort(void *, size_t, size_t, int (*)(const void *, const void *));
 int     rand(void);
 void   *realloc(void *, size_t);
+void   *reallocarray(void *, size_t, size_t);
 void    srand(unsigned);
 double  strtod(const char * __restrict, char ** __restrict);
 long    strtol(const char * __restrict, char ** __restrict, int);
@@ -125,7 +126,6 @@
         strtoul(const char * __restrict, char ** __restrict, int);
 #ifdef _OPENBSD_SOURCE
 long long strtonum(const char *, long long, long long, const char **);
-void   *reallocarray(void *, size_t, size_t);
 #endif
 int     system(const char *);
 
diff -r 2e372f3ebcba -r f23e17f183aa lib/libc/stdlib/reallocarray.3
--- a/lib/libc/stdlib/reallocarray.3    Fri Oct 28 08:16:57 2022 +0000
+++ b/lib/libc/stdlib/reallocarray.3    Fri Oct 28 09:43:58 2022 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: reallocarray.3,v 1.4 2015/07/26 02:29:44 kamil Exp $
+.\" $NetBSD: reallocarray.3,v 1.5 2022/10/28 09:43:59 wiz Exp $
 .\"
 .\" Copyright (c) 2015 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -27,14 +27,13 @@
 .\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd February 5, 2015
+.Dd September 9, 2022
 .Dt REALLOCARRAY 3
 .Os
 .Sh NAME
 .Nm reallocarray
 .Nd reallocate memory for an array of elements checking for overflow
 .Sh SYNOPSIS
-.Vt #define _OPENBSD_SOURCE
 .In stdlib.h
 .Ft void *
 .Fo reallocarray
@@ -55,12 +54,8 @@
 .Xr realloc 3
 and making sure that overflow does not happen in the multiplication of
 .Dq "nmemb * size" .
-.Pp
-This function is provided for source compatibility with
-.Ox
-and
-its use is discouraged in preference to
-.Xr reallocarr 3 .
+Otherwise it behaves like
+.Xr realloc 3 .
 .Sh RETURN VALUES
 The
 .Fn reallocarray
@@ -71,18 +66,15 @@
 failed setting
 .Va errno
 to
-.Dv EOVERFLOW
+.Dv ENOMEM
 or preserving the value from



Home | Main Index | Thread Index | Old Index