CVS commit: src/usr.sbin/cpuctl/arch
Module Name:src Committed By: msaitoh Date: Wed Jul 5 02:54:37 UTC 2023 Modified Files: src/usr.sbin/cpuctl/arch: i386.c Log Message: CPU model 0x5a is not Atom E3500 but Atom Z3500. To generate a diff of this commit: cvs rdiff -u -r1.136 -r1.137 src/usr.sbin/cpuctl/arch/i386.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/cpuctl/arch/i386.c diff -u src/usr.sbin/cpuctl/arch/i386.c:1.136 src/usr.sbin/cpuctl/arch/i386.c:1.137 --- src/usr.sbin/cpuctl/arch/i386.c:1.136 Tue Feb 14 15:46:06 2023 +++ src/usr.sbin/cpuctl/arch/i386.c Wed Jul 5 02:54:37 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: i386.c,v 1.136 2023/02/14 15:46:06 msaitoh Exp $ */ +/* $NetBSD: i386.c,v 1.137 2023/07/05 02:54:37 msaitoh Exp $ */ /*- * Copyright (c) 1999, 2000, 2001, 2006, 2007, 2008 The NetBSD Foundation, Inc. @@ -57,7 +57,7 @@ #include #ifndef lint -__RCSID("$NetBSD: i386.c,v 1.136 2023/02/14 15:46:06 msaitoh Exp $"); +__RCSID("$NetBSD: i386.c,v 1.137 2023/07/05 02:54:37 msaitoh Exp $"); #endif /* not lint */ #include @@ -335,7 +335,7 @@ const struct cpu_cpuid_nameclass i386_cp [0x55] = "Xeon Scalable (Skylake, Cascade Lake, Copper Lake)", [0x56] = "Xeon D-1500 (Broadwell)", [0x57] = "Xeon Phi [357]200 (Knights Landing)", -[0x5a] = "Atom E3500", +[0x5a] = "Atom Z3500", [0x5c] = "Atom (Goldmont)", [0x5d] = "Atom X3-C3000 (Silvermont)", [0x5e] = "6th gen Core, Xeon E3-1[25]00 v5 (Skylake)",
CVS commit: src/usr.sbin/cpuctl/arch
Module Name:src Committed By: msaitoh Date: Wed Jul 5 02:54:37 UTC 2023 Modified Files: src/usr.sbin/cpuctl/arch: i386.c Log Message: CPU model 0x5a is not Atom E3500 but Atom Z3500. To generate a diff of this commit: cvs rdiff -u -r1.136 -r1.137 src/usr.sbin/cpuctl/arch/i386.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/lib/libbsdmalloc
Module Name:src Committed By: riastradh Date: Wed Jul 5 01:15:47 UTC 2023 Modified Files: src/lib/libbsdmalloc: malloc.c Log Message: libbsdmalloc: Fix build with DEBUG. Nix __P while here. XXX pullup-10 To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/lib/libbsdmalloc/malloc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/lib/libbsdmalloc
Module Name:src Committed By: riastradh Date: Wed Jul 5 01:15:47 UTC 2023 Modified Files: src/lib/libbsdmalloc: malloc.c Log Message: libbsdmalloc: Fix build with DEBUG. Nix __P while here. XXX pullup-10 To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/lib/libbsdmalloc/malloc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libbsdmalloc/malloc.c diff -u src/lib/libbsdmalloc/malloc.c:1.5 src/lib/libbsdmalloc/malloc.c:1.6 --- src/lib/libbsdmalloc/malloc.c:1.5 Tue Jul 4 18:40:14 2023 +++ src/lib/libbsdmalloc/malloc.c Wed Jul 5 01:15:47 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: malloc.c,v 1.5 2023/07/04 18:40:14 riastradh Exp $ */ +/* $NetBSD: malloc.c,v 1.6 2023/07/05 01:15:47 riastradh Exp $ */ /* * Copyright (c) 1983, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)malloc.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: malloc.c,v 1.5 2023/07/04 18:40:14 riastradh Exp $"); +__RCSID("$NetBSD: malloc.c,v 1.6 2023/07/05 01:15:47 riastradh Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -128,32 +128,31 @@ static u_int nmalloc[NBUCKETS]; static mutex_t malloc_mutex = MUTEX_INITIALIZER; #endif -static void morecore __P((int)); -static int findbucket __P((union overhead *, int)); +static void morecore(int); +static int findbucket(union overhead *, int); #ifdef MSTATS -void mstats __P((const char *)); +void mstats(const char *); #endif #if defined(DEBUG) || defined(RCHECK) #define ASSERT(p) if (!(p)) botch(__STRING(p)) -static void botch __P((const char *)); +static void botch(const char *); /* * NOTE: since this may be called while malloc_mutex is locked, stdio must not * be used in this function. */ static void -botch(s) - const char *s; +botch(const char *s) { struct iovec iov[3]; - iov[0].iov_base = "\nassertion botched: "; + iov[0].iov_base = __UNCONST("\nassertion botched: "); iov[0].iov_len = 20; - iov[1].iov_base = (void *)s; + iov[1].iov_base = __UNCONST(s); iov[1].iov_len = strlen(s); - iov[2].iov_base = "\n"; + iov[2].iov_base = __UNCONST("\n"); iov[2].iov_len = 1; /*
CVS commit: src
Module Name:src Committed By: gutteridge Date: Wed Jul 5 00:26:38 UTC 2023 Modified Files: src/distrib/sets/lists/misc: mi src/external/bsd/dhcpcd/examples: Makefile Added Files: src/external/bsd/dhcpcd/examples/conf: Makefile Log Message: Install a copy of dhcpcd.conf under /usr/share/examples Addresses PR bin/57487 from Taylor R Campbell. To generate a diff of this commit: cvs rdiff -u -r1.224 -r1.225 src/distrib/sets/lists/misc/mi cvs rdiff -u -r1.1 -r1.2 src/external/bsd/dhcpcd/examples/Makefile cvs rdiff -u -r0 -r1.1 src/external/bsd/dhcpcd/examples/conf/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/distrib/sets/lists/misc/mi diff -u src/distrib/sets/lists/misc/mi:1.224 src/distrib/sets/lists/misc/mi:1.225 --- src/distrib/sets/lists/misc/mi:1.224 Fri Oct 14 19:43:35 2022 +++ src/distrib/sets/lists/misc/mi Wed Jul 5 00:26:38 2023 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.224 2022/10/14 19:43:35 ryo Exp $ +# $NetBSD: mi,v 1.225 2023/07/05 00:26:38 gutteridge Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. # @@ -1368,6 +1368,7 @@ ./usr/share/examples/atf/tests-results.css misc-atf-examples share,atf,!kyua ./usr/share/examples/atf/tests-results.css misc-obsolete share,kyua,obsolete ./usr/share/examples/dhcp/dhcpd.conf misc-dhcpd-examples share +./usr/share/examples/dhcpcd/dhcpcd.conf misc-dhcpcd-examples share ./usr/share/examples/dhcpcd/hooks/10-wpa_supplicant misc-dhcpcd-examples share ./usr/share/examples/dhcpcd/hooks/15-timezone misc-dhcpcd-examples share ./usr/share/examples/dhcpcd/hooks/29-lookup-hostname misc-dhcpcd-examples share Index: src/external/bsd/dhcpcd/examples/Makefile diff -u src/external/bsd/dhcpcd/examples/Makefile:1.1 src/external/bsd/dhcpcd/examples/Makefile:1.2 --- src/external/bsd/dhcpcd/examples/Makefile:1.1 Sun Apr 2 20:18:37 2017 +++ src/external/bsd/dhcpcd/examples/Makefile Wed Jul 5 00:26:38 2023 @@ -1,5 +1,5 @@ -# $NetBSD: Makefile,v 1.1 2017/04/02 20:18:37 roy Exp $ +# $NetBSD: Makefile,v 1.2 2023/07/05 00:26:38 gutteridge Exp $ -SUBDIR= hooks +SUBDIR= conf hooks .include Added files: Index: src/external/bsd/dhcpcd/examples/conf/Makefile diff -u /dev/null src/external/bsd/dhcpcd/examples/conf/Makefile:1.1 --- /dev/null Wed Jul 5 00:26:38 2023 +++ src/external/bsd/dhcpcd/examples/conf/Makefile Wed Jul 5 00:26:38 2023 @@ -0,0 +1,14 @@ +# $NetBSD: Makefile,v 1.1 2023/07/05 00:26:38 gutteridge Exp $ + +.include + +.include "../../Makefile.inc" +.PATH: ${DIST}/src + +.if ${MKSHARE} != "no" +FILES= dhcpcd.conf + +FILESDIR= /usr/share/examples/dhcpcd/ +.endif + +.include
CVS commit: src
Module Name:src Committed By: gutteridge Date: Wed Jul 5 00:26:38 UTC 2023 Modified Files: src/distrib/sets/lists/misc: mi src/external/bsd/dhcpcd/examples: Makefile Added Files: src/external/bsd/dhcpcd/examples/conf: Makefile Log Message: Install a copy of dhcpcd.conf under /usr/share/examples Addresses PR bin/57487 from Taylor R Campbell. To generate a diff of this commit: cvs rdiff -u -r1.224 -r1.225 src/distrib/sets/lists/misc/mi cvs rdiff -u -r1.1 -r1.2 src/external/bsd/dhcpcd/examples/Makefile cvs rdiff -u -r0 -r1.1 src/external/bsd/dhcpcd/examples/conf/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/external/gpl2/groff/tmac
Module Name:src Committed By: uwe Date: Tue Jul 4 23:52:44 UTC 2023 Modified Files: src/external/gpl2/groff/tmac: mdoc.local Log Message: mdoc.local: fix libbsdmalloc string name To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/external/gpl2/groff/tmac/mdoc.local Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/external/gpl2/groff/tmac
Module Name:src Committed By: uwe Date: Tue Jul 4 23:52:44 UTC 2023 Modified Files: src/external/gpl2/groff/tmac: mdoc.local Log Message: mdoc.local: fix libbsdmalloc string name To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/external/gpl2/groff/tmac/mdoc.local Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/gpl2/groff/tmac/mdoc.local diff -u src/external/gpl2/groff/tmac/mdoc.local:1.10 src/external/gpl2/groff/tmac/mdoc.local:1.11 --- src/external/gpl2/groff/tmac/mdoc.local:1.10 Tue Jul 4 16:23:15 2023 +++ src/external/gpl2/groff/tmac/mdoc.local Tue Jul 4 23:52:44 2023 @@ -1,4 +1,4 @@ -.\" $NetBSD: mdoc.local,v 1.10 2023/07/04 16:23:15 riastradh Exp $ +.\" $NetBSD: mdoc.local,v 1.11 2023/07/04 23:52:44 uwe Exp $ .\" .\" Copyright (c) 2003, 2004 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -152,7 +152,7 @@ .\" Local libraries not in groff .ds doc-str-Lb-libarchive Reading and Writing Streaming Archives Library (libarchive, \-larchive) .ds doc-str-Lb-libbluetooth Bluetooth Library (libbluetooth, \-lbluetooth) -.ds doc-str-Lb-bsdmallocHistoric BSD allocator (libbsdmalloc, \-lbsdmalloc) +.ds doc-str-Lb-libbsdmalloc Historic BSD allocator (libbsdmalloc, \-lbsdmalloc) .ds doc-str-Lb-libdmDevice-mapper Library (libdm, \-ldm) .ds doc-str-Lb-libexecinfo Backtrace Access Library (libexecinfo, \-lexecinfo) .ds doc-str-Lb-libfetch File Transfer Library for URLs (libfetch, \-lfetch)
CVS commit: src/sbin/fsck_ffs
Module Name:src Committed By: riastradh Date: Tue Jul 4 20:40:53 UTC 2023 Modified Files: src/sbin/fsck_ffs: dir.c extern.h fsck.h inode.c main.c pass1.c pass2.c pass4.c pass5.c pass6.c quota2.c setup.c utilities.c Log Message: fsck_ffs(8): Fix whitespace issues. - Nix trailing whitespace. - Omit excessive blank lines. - Insert missing blank lines between $NetBSD$ and copyright. No functional change intended. To generate a diff of this commit: cvs rdiff -u -r1.61 -r1.62 src/sbin/fsck_ffs/dir.c cvs rdiff -u -r1.28 -r1.29 src/sbin/fsck_ffs/extern.h cvs rdiff -u -r1.57 -r1.58 src/sbin/fsck_ffs/fsck.h src/sbin/fsck_ffs/pass5.c cvs rdiff -u -r1.76 -r1.77 src/sbin/fsck_ffs/inode.c cvs rdiff -u -r1.91 -r1.92 src/sbin/fsck_ffs/main.c cvs rdiff -u -r1.63 -r1.64 src/sbin/fsck_ffs/pass1.c cvs rdiff -u -r1.52 -r1.53 src/sbin/fsck_ffs/pass2.c cvs rdiff -u -r1.30 -r1.31 src/sbin/fsck_ffs/pass4.c cvs rdiff -u -r1.4 -r1.5 src/sbin/fsck_ffs/pass6.c cvs rdiff -u -r1.7 -r1.8 src/sbin/fsck_ffs/quota2.c cvs rdiff -u -r1.107 -r1.108 src/sbin/fsck_ffs/setup.c cvs rdiff -u -r1.69 -r1.70 src/sbin/fsck_ffs/utilities.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/fsck_ffs/dir.c diff -u src/sbin/fsck_ffs/dir.c:1.61 src/sbin/fsck_ffs/dir.c:1.62 --- src/sbin/fsck_ffs/dir.c:1.61 Sun May 5 14:59:06 2019 +++ src/sbin/fsck_ffs/dir.c Tue Jul 4 20:40:53 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: dir.c,v 1.61 2019/05/05 14:59:06 christos Exp $ */ +/* $NetBSD: dir.c,v 1.62 2023/07/04 20:40:53 riastradh Exp $ */ /* * Copyright (c) 1980, 1986, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)dir.c 8.8 (Berkeley) 4/28/95"; #else -__RCSID("$NetBSD: dir.c,v 1.61 2019/05/05 14:59:06 christos Exp $"); +__RCSID("$NetBSD: dir.c,v 1.62 2023/07/04 20:40:53 riastradh Exp $"); #endif #endif /* not lint */ @@ -230,7 +230,7 @@ dirscan(struct inodesc *idesc) dirty(bp); sbdirty(); } - if (n & STOP) + if (n & STOP) return (n); } return (idesc->id_filesize > 0 ? KEEPON : STOP); @@ -265,7 +265,7 @@ fsck_readdir(struct inodesc *idesc) dp->d_name[0] = '\0'; if (fix) dirty(bp); - else + else markclean = 0; idesc->id_loc += dirblksiz; idesc->id_filesize -= dirblksiz; @@ -294,7 +294,7 @@ dpok: dp->d_reclen = iswap16(iswap16(dp->d_reclen) + size); if (fix) dirty(bp); - else + else markclean = 0; } return (dp); @@ -308,7 +308,7 @@ dpok: * 0: bad */ static int -dircheck(struct inodesc *idesc, struct direct *dp, struct bufarea *bp) +dircheck(struct inodesc *idesc, struct direct *dp, struct bufarea *bp) { uint8_t namlen, type; uint16_t reclen; @@ -497,7 +497,7 @@ adjust(struct inodesc *idesc, int lcnt) if (preen || reply("ADJUST") == 1) { DIP_SET(dp, nlink, iswap16(nlink - lcnt)); inodirty(); - } else + } else markclean = 0; } } @@ -715,7 +715,7 @@ makeentry(ino_t parent, ino_t ino, const union dinode *dp; struct inodesc idesc; char pathbuf[MAXPATHLEN + 1]; - + if (parent < UFS_ROOTINO || parent >= maxino || ino < UFS_ROOTINO || ino >= maxino) return (0); Index: src/sbin/fsck_ffs/extern.h diff -u src/sbin/fsck_ffs/extern.h:1.28 src/sbin/fsck_ffs/extern.h:1.29 --- src/sbin/fsck_ffs/extern.h:1.28 Thu Nov 17 06:40:38 2022 +++ src/sbin/fsck_ffs/extern.h Tue Jul 4 20:40:53 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: extern.h,v 1.28 2022/11/17 06:40:38 chs Exp $ */ +/* $NetBSD: extern.h,v 1.29 2023/07/04 20:40:53 riastradh Exp $ */ /* * Copyright (c) 1994 James A. Jegers @@ -88,7 +88,6 @@ void remove_uquot(struct uquot_hash *,s void update_uquot(ino_t, uid_t, gid_t, int64_t, int64_t); int is_quota_inode(ino_t); - int check_wapbl(void); void replay_wapbl(void); void cleanup_wapbl(void); Index: src/sbin/fsck_ffs/fsck.h diff -u src/sbin/fsck_ffs/fsck.h:1.57 src/sbin/fsck_ffs/fsck.h:1.58 --- src/sbin/fsck_ffs/fsck.h:1.57 Sat Jan 14 12:12:50 2023 +++ src/sbin/fsck_ffs/fsck.h Tue Jul 4 20:40:53 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: fsck.h,v 1.57 2023/01/14 12:12:50 christos Exp $ */ +/* $NetBSD: fsck.h,v 1.58 2023/07/04 20:40:53 riastradh Exp $ */ /* * Copyright (c) 1980, 1986, 1993 @@ -101,7 +101,6 @@ extern struct inostatlist { struct inostat *il_stat;/* inostat info for this cylinder group */ } *inostathead; - /* * buffer cache structure. */ @@ -205,14 +204,14 @@ struct inodesc { /* * Linked list of duplicate blocks. - * + * * The list is composed of two parts. The first part of the * list (from duplist through the node pointed to by muldup) - * contains a single copy of each duplicate block that has been + * contains a single copy of each duplicate block that has been * found. The second part of the list (from muldup to the end) * contains duplicate blocks that have been found more than once. * To check if a block has been found as a duplicate it is only - * necessary to
CVS commit: src/sbin/fsck_ffs
Module Name:src Committed By: riastradh Date: Tue Jul 4 20:40:53 UTC 2023 Modified Files: src/sbin/fsck_ffs: dir.c extern.h fsck.h inode.c main.c pass1.c pass2.c pass4.c pass5.c pass6.c quota2.c setup.c utilities.c Log Message: fsck_ffs(8): Fix whitespace issues. - Nix trailing whitespace. - Omit excessive blank lines. - Insert missing blank lines between $NetBSD$ and copyright. No functional change intended. To generate a diff of this commit: cvs rdiff -u -r1.61 -r1.62 src/sbin/fsck_ffs/dir.c cvs rdiff -u -r1.28 -r1.29 src/sbin/fsck_ffs/extern.h cvs rdiff -u -r1.57 -r1.58 src/sbin/fsck_ffs/fsck.h src/sbin/fsck_ffs/pass5.c cvs rdiff -u -r1.76 -r1.77 src/sbin/fsck_ffs/inode.c cvs rdiff -u -r1.91 -r1.92 src/sbin/fsck_ffs/main.c cvs rdiff -u -r1.63 -r1.64 src/sbin/fsck_ffs/pass1.c cvs rdiff -u -r1.52 -r1.53 src/sbin/fsck_ffs/pass2.c cvs rdiff -u -r1.30 -r1.31 src/sbin/fsck_ffs/pass4.c cvs rdiff -u -r1.4 -r1.5 src/sbin/fsck_ffs/pass6.c cvs rdiff -u -r1.7 -r1.8 src/sbin/fsck_ffs/quota2.c cvs rdiff -u -r1.107 -r1.108 src/sbin/fsck_ffs/setup.c cvs rdiff -u -r1.69 -r1.70 src/sbin/fsck_ffs/utilities.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sbin/nvmectl
Module Name:src Committed By: riastradh Date: Tue Jul 4 20:40:43 UTC 2023 Modified Files: src/sbin/nvmectl: firmware.c wdc.c Log Message: nvmectl(8): Ensure A divides S before aligned_alloc(A, S). Required by C11 Sec. 7.22.3.1 The aligned_alloc function, para. 2, p. 348: The value of alignment shall be a valid alignment supported by the implementation and the value of size shall be an integral multiple of alignment. XXX pullup-10 To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sbin/nvmectl/firmware.c src/sbin/nvmectl/wdc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/nvmectl/firmware.c diff -u src/sbin/nvmectl/firmware.c:1.4 src/sbin/nvmectl/firmware.c:1.5 --- src/sbin/nvmectl/firmware.c:1.4 Wed Apr 18 10:11:44 2018 +++ src/sbin/nvmectl/firmware.c Tue Jul 4 20:40:43 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: firmware.c,v 1.4 2018/04/18 10:11:44 nonaka Exp $ */ +/* $NetBSD: firmware.c,v 1.5 2023/07/04 20:40:43 riastradh Exp $ */ /*- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD @@ -33,7 +33,7 @@ #include #ifndef lint -__RCSID("$NetBSD: firmware.c,v 1.4 2018/04/18 10:11:44 nonaka Exp $"); +__RCSID("$NetBSD: firmware.c,v 1.5 2023/07/04 20:40:43 riastradh Exp $"); #if 0 __FBSDID("$FreeBSD: head/sbin/nvmecontrol/firmware.c 329824 2018-02-22 13:32:31Z wma $"); #endif @@ -123,6 +123,7 @@ update_firmware(int fd, uint8_t *payload off = 0; resid = payload_size; + __CTASSERT((NVME_MAX_XFER_SIZE % PAGE_SIZE) == 0); if ((chunk = aligned_alloc(PAGE_SIZE, NVME_MAX_XFER_SIZE)) == NULL) errx(1, "unable to malloc %d bytes", NVME_MAX_XFER_SIZE); Index: src/sbin/nvmectl/wdc.c diff -u src/sbin/nvmectl/wdc.c:1.4 src/sbin/nvmectl/wdc.c:1.5 --- src/sbin/nvmectl/wdc.c:1.4 Wed Apr 18 10:11:44 2018 +++ src/sbin/nvmectl/wdc.c Tue Jul 4 20:40:43 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: wdc.c,v 1.4 2018/04/18 10:11:44 nonaka Exp $ */ +/* $NetBSD: wdc.c,v 1.5 2023/07/04 20:40:43 riastradh Exp $ */ /*- * Copyright (c) 2017 Netflix, Inc @@ -28,7 +28,7 @@ #include #ifndef lint -__RCSID("$NetBSD: wdc.c,v 1.4 2018/04/18 10:11:44 nonaka Exp $"); +__RCSID("$NetBSD: wdc.c,v 1.5 2023/07/04 20:40:43 riastradh Exp $"); #if 0 __FBSDID("$FreeBSD: head/sbin/nvmecontrol/wdc.c 329824 2018-02-22 13:32:31Z wma $"); #endif @@ -125,7 +125,7 @@ wdc_do_dump(int fd, char *tmpl, const ch fd2 = open(tmpl, O_WRONLY | O_CREAT | O_TRUNC, 0644); if (fd2 < 0) err(1, "open %s", tmpl); - buf = aligned_alloc(page_size, NVME_MAX_XFER_SIZE); + buf = aligned_alloc(page_size, roundup(NVME_MAX_XFER_SIZE, page_size)); if (buf == NULL) errx(1, "Can't get buffer to read dump"); offset = 0;
CVS commit: src/sbin/nvmectl
Module Name:src Committed By: riastradh Date: Tue Jul 4 20:40:43 UTC 2023 Modified Files: src/sbin/nvmectl: firmware.c wdc.c Log Message: nvmectl(8): Ensure A divides S before aligned_alloc(A, S). Required by C11 Sec. 7.22.3.1 The aligned_alloc function, para. 2, p. 348: The value of alignment shall be a valid alignment supported by the implementation and the value of size shall be an integral multiple of alignment. XXX pullup-10 To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sbin/nvmectl/firmware.c src/sbin/nvmectl/wdc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sbin/newfs
Module Name:src Committed By: riastradh Date: Tue Jul 4 20:40:34 UTC 2023 Modified Files: src/sbin/newfs: mkfs.c newfs.c Log Message: newfs(8): Ensure A divides S before aligned_alloc(A, S). Required by C11 Sec. 7.22.3.1 The aligned_alloc function, para. 2, p. 348: The value of alignment shall be a valid alignment supported by the implementation and the value of size shall be an integral multiple of alignment. XXX pullup-10 To generate a diff of this commit: cvs rdiff -u -r1.133 -r1.134 src/sbin/newfs/mkfs.c cvs rdiff -u -r1.118 -r1.119 src/sbin/newfs/newfs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/newfs/mkfs.c diff -u src/sbin/newfs/mkfs.c:1.133 src/sbin/newfs/mkfs.c:1.134 --- src/sbin/newfs/mkfs.c:1.133 Sat Jan 7 19:41:29 2023 +++ src/sbin/newfs/mkfs.c Tue Jul 4 20:40:34 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: mkfs.c,v 1.133 2023/01/07 19:41:29 chs Exp $ */ +/* $NetBSD: mkfs.c,v 1.134 2023/07/04 20:40:34 riastradh Exp $ */ /* * Copyright (c) 1980, 1989, 1993 @@ -73,7 +73,7 @@ #if 0 static char sccsid[] = "@(#)mkfs.c 8.11 (Berkeley) 5/3/95"; #else -__RCSID("$NetBSD: mkfs.c,v 1.133 2023/01/07 19:41:29 chs Exp $"); +__RCSID("$NetBSD: mkfs.c,v 1.134 2023/07/04 20:40:34 riastradh Exp $"); #endif #endif /* not lint */ @@ -201,9 +201,11 @@ mkfs(const char *fsys, int fi, int fo, exit(12); } #endif + __CTASSERT((sizeof(*fsun) % DEV_BSIZE) == 0); if ((fsun = aligned_alloc(DEV_BSIZE, sizeof(*fsun))) == NULL) exit(12); memset(fsun, 0, sizeof(*fsun)); + __CTASSERT((sizeof(*cgun) % DEV_BSIZE) == 0); if ((cgun = aligned_alloc(DEV_BSIZE, sizeof(*cgun))) == NULL) exit(12); memset(cgun, 0, sizeof(*cgun)); Index: src/sbin/newfs/newfs.c diff -u src/sbin/newfs/newfs.c:1.118 src/sbin/newfs/newfs.c:1.119 --- src/sbin/newfs/newfs.c:1.118 Thu Nov 17 06:40:39 2022 +++ src/sbin/newfs/newfs.c Tue Jul 4 20:40:34 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: newfs.c,v 1.118 2022/11/17 06:40:39 chs Exp $ */ +/* $NetBSD: newfs.c,v 1.119 2023/07/04 20:40:34 riastradh Exp $ */ /* * Copyright (c) 1983, 1989, 1993, 1994 @@ -78,7 +78,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 19 #if 0 static char sccsid[] = "@(#)newfs.c 8.13 (Berkeley) 5/1/95"; #else -__RCSID("$NetBSD: newfs.c,v 1.118 2022/11/17 06:40:39 chs Exp $"); +__RCSID("$NetBSD: newfs.c,v 1.119 2023/07/04 20:40:34 riastradh Exp $"); #endif #endif /* not lint */ @@ -624,7 +624,9 @@ main(int argc, char *argv[]) } else bufsize = sfs.f_iosize; - if ((buf = aligned_alloc(DEV_BSIZE, bufsize)) == NULL) + __CTASSERT(powerof2(DEV_BSIZE)); + if ((buf = aligned_alloc(DEV_BSIZE, + roundup2(bufsize, DEV_BSIZE))) == NULL) err(1, "can't malloc buffer of %d", bufsize); memset(buf, 0, bufsize);
CVS commit: src/sbin/newfs
Module Name:src Committed By: riastradh Date: Tue Jul 4 20:40:34 UTC 2023 Modified Files: src/sbin/newfs: mkfs.c newfs.c Log Message: newfs(8): Ensure A divides S before aligned_alloc(A, S). Required by C11 Sec. 7.22.3.1 The aligned_alloc function, para. 2, p. 348: The value of alignment shall be a valid alignment supported by the implementation and the value of size shall be an integral multiple of alignment. XXX pullup-10 To generate a diff of this commit: cvs rdiff -u -r1.133 -r1.134 src/sbin/newfs/mkfs.c cvs rdiff -u -r1.118 -r1.119 src/sbin/newfs/newfs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sbin/fsck_ffs
Module Name:src Committed By: riastradh Date: Tue Jul 4 20:40:22 UTC 2023 Modified Files: src/sbin/fsck_ffs: inode.c setup.c utilities.c Log Message: fsck_ffs(8): Ensure A divides S before aligned_alloc(A, S). Required by C11 Sec. 7.22.3.1 The aligned_alloc function, para. 2, p. 348: The value of alignment shall be a valid alignment supported by the implementation and the value of size shall be an integral multiple of alignment. XXX pullup-10 To generate a diff of this commit: cvs rdiff -u -r1.75 -r1.76 src/sbin/fsck_ffs/inode.c cvs rdiff -u -r1.106 -r1.107 src/sbin/fsck_ffs/setup.c cvs rdiff -u -r1.68 -r1.69 src/sbin/fsck_ffs/utilities.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/fsck_ffs/inode.c diff -u src/sbin/fsck_ffs/inode.c:1.75 src/sbin/fsck_ffs/inode.c:1.76 --- src/sbin/fsck_ffs/inode.c:1.75 Sat Jan 14 17:01:10 2023 +++ src/sbin/fsck_ffs/inode.c Tue Jul 4 20:40:22 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: inode.c,v 1.75 2023/01/14 17:01:10 kre Exp $ */ +/* $NetBSD: inode.c,v 1.76 2023/07/04 20:40:22 riastradh Exp $ */ /* * Copyright (c) 1980, 1986, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)inode.c 8.8 (Berkeley) 4/28/95"; #else -__RCSID("$NetBSD: inode.c,v 1.75 2023/01/14 17:01:10 kre Exp $"); +__RCSID("$NetBSD: inode.c,v 1.76 2023/07/04 20:40:22 riastradh Exp $"); #endif #endif /* not lint */ @@ -462,8 +462,10 @@ setinodebuf(ino_t inum) partialcnt = fullcnt; partialsize = inobufsize; } + __CTASSERT(powerof2(DEV_BSIZE)); if (inodebuf == NULL && - (inodebuf = aligned_alloc(DEV_BSIZE, (unsigned)inobufsize)) == NULL) + (inodebuf = aligned_alloc(DEV_BSIZE, + roundup2((unsigned)inobufsize, DEV_BSIZE))) == NULL) errexit("Cannot allocate space for inode buffer"); } Index: src/sbin/fsck_ffs/setup.c diff -u src/sbin/fsck_ffs/setup.c:1.106 src/sbin/fsck_ffs/setup.c:1.107 --- src/sbin/fsck_ffs/setup.c:1.106 Sun Jan 8 05:25:24 2023 +++ src/sbin/fsck_ffs/setup.c Tue Jul 4 20:40:22 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: setup.c,v 1.106 2023/01/08 05:25:24 chs Exp $ */ +/* $NetBSD: setup.c,v 1.107 2023/07/04 20:40:22 riastradh Exp $ */ /* * Copyright (c) 1980, 1986, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)setup.c 8.10 (Berkeley) 5/9/95"; #else -__RCSID("$NetBSD: setup.c,v 1.106 2023/01/08 05:25:24 chs Exp $"); +__RCSID("$NetBSD: setup.c,v 1.107 2023/07/04 20:40:22 riastradh Exp $"); #endif #endif /* not lint */ @@ -127,6 +127,7 @@ setup(const char *dev, const char *origd lfdir = 0; initbarea(); initbarea(); + __CTASSERT((SBLOCKSIZE % DEV_BSIZE) == 0); sblk.b_un.b_buf = aligned_alloc(DEV_BSIZE, SBLOCKSIZE); sblock = aligned_alloc(DEV_BSIZE, SBLOCKSIZE); asblk.b_un.b_buf = aligned_alloc(DEV_BSIZE, SBLOCKSIZE); @@ -459,8 +460,9 @@ setup(const char *dev, const char *origd * read in the summary info. */ asked = 0; + __CTASSERT(powerof2(DEV_BSIZE)); sblock->fs_csp = (struct csum *)aligned_alloc(DEV_BSIZE, - sblock->fs_cssize); + roundup2(sblock->fs_cssize, DEV_BSIZE)); if (sblock->fs_csp == NULL) { pwarn("cannot alloc %u bytes for summary info\n", sblock->fs_cssize); @@ -495,7 +497,9 @@ setup(const char *dev, const char *origd * allocate and initialize the necessary maps */ bmapsize = roundup(howmany(maxfsblock, NBBY), sizeof(int16_t)); - blockmap = aligned_alloc(DEV_BSIZE, (unsigned)bmapsize); + __CTASSERT(powerof2(DEV_BSIZE)); + blockmap = aligned_alloc(DEV_BSIZE, + roundup2((unsigned)bmapsize, DEV_BSIZE)); if (blockmap == NULL) { pwarn("cannot alloc %u bytes for blockmap\n", (unsigned)bmapsize); @@ -530,7 +534,9 @@ setup(const char *dev, const char *origd (unsigned)(numdirs * sizeof(struct inoinfo *))); goto badsblabel; } - cgrp = aligned_alloc(DEV_BSIZE, sblock->fs_cgsize); + __CTASSERT(powerof2(DEV_BSIZE)); + cgrp = aligned_alloc(DEV_BSIZE, + roundup2(sblock->fs_cgsize, DEV_BSIZE)); if (cgrp == NULL) { pwarn("cannot alloc %u bytes for cylinder group\n", sblock->fs_cgsize); Index: src/sbin/fsck_ffs/utilities.c diff -u src/sbin/fsck_ffs/utilities.c:1.68 src/sbin/fsck_ffs/utilities.c:1.69 --- src/sbin/fsck_ffs/utilities.c:1.68 Sat Jan 14 12:12:50 2023 +++ src/sbin/fsck_ffs/utilities.c Tue Jul 4 20:40:22 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: utilities.c,v 1.68 2023/01/14 12:12:50 christos Exp $ */ +/* $NetBSD: utilities.c,v 1.69 2023/07/04 20:40:22 riastradh Exp $ */ /* * Copyright (c) 1980, 1986, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)utilities.c 8.6 (Berkeley) 5/19/95"; #else -__RCSID("$NetBSD: utilities.c,v 1.68 2023/01/14 12:12:50 christos Exp $"); +__RCSID("$NetBSD: utilities.c,v 1.69 2023/07/04 20:40:22 riastradh Exp $"); #endif #endif /* not lint */ @@ -135,12 +135,15 @@ bufinit(void) char *bufp; pbp = pdirbp = (struct bufarea *)0; - bufp = aligned_alloc(DEV_BSIZE,
CVS commit: src/sbin/fsck_ffs
Module Name:src Committed By: riastradh Date: Tue Jul 4 20:40:22 UTC 2023 Modified Files: src/sbin/fsck_ffs: inode.c setup.c utilities.c Log Message: fsck_ffs(8): Ensure A divides S before aligned_alloc(A, S). Required by C11 Sec. 7.22.3.1 The aligned_alloc function, para. 2, p. 348: The value of alignment shall be a valid alignment supported by the implementation and the value of size shall be an integral multiple of alignment. XXX pullup-10 To generate a diff of this commit: cvs rdiff -u -r1.75 -r1.76 src/sbin/fsck_ffs/inode.c cvs rdiff -u -r1.106 -r1.107 src/sbin/fsck_ffs/setup.c cvs rdiff -u -r1.68 -r1.69 src/sbin/fsck_ffs/utilities.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/lib/libc/dlfcn
Module Name:src Committed By: riastradh Date: Tue Jul 4 19:24:25 UTC 2023 Modified Files: src/lib/libc/dlfcn: dlfcn_elf.c Log Message: libc: Fix missing membar_consumer in dl_iterate_phdr. Pairs with the existing membar_producer. XXX pullup-8 XXX pullup-9 XXX pullup-10 To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/lib/libc/dlfcn/dlfcn_elf.c 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/dlfcn/dlfcn_elf.c diff -u src/lib/libc/dlfcn/dlfcn_elf.c:1.16 src/lib/libc/dlfcn/dlfcn_elf.c:1.17 --- src/lib/libc/dlfcn/dlfcn_elf.c:1.16 Fri Jul 13 19:49:47 2018 +++ src/lib/libc/dlfcn/dlfcn_elf.c Tue Jul 4 19:24:25 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: dlfcn_elf.c,v 1.16 2018/07/13 19:49:47 joerg Exp $ */ +/* $NetBSD: dlfcn_elf.c,v 1.17 2023/07/04 19:24:25 riastradh Exp $ */ /* * Copyright (c) 2000 Takuya SHIOZAKI @@ -27,7 +27,7 @@ #include #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: dlfcn_elf.c,v 1.16 2018/07/13 19:49:47 joerg Exp $"); +__RCSID("$NetBSD: dlfcn_elf.c,v 1.17 2023/07/04 19:24:25 riastradh Exp $"); #endif /* LIBC_SCCS and not lint */ #include "namespace.h" @@ -207,6 +207,7 @@ dl_iterate_phdr(int (*callback)(struct d membar_producer(); setup_done = true; } + membar_consumer(); memset(_info, 0, sizeof(phdr_info)); phdr_info.dlpi_addr = dlpi_addr;
CVS commit: src/lib/libc/dlfcn
Module Name:src Committed By: riastradh Date: Tue Jul 4 19:24:25 UTC 2023 Modified Files: src/lib/libc/dlfcn: dlfcn_elf.c Log Message: libc: Fix missing membar_consumer in dl_iterate_phdr. Pairs with the existing membar_producer. XXX pullup-8 XXX pullup-9 XXX pullup-10 To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/lib/libc/dlfcn/dlfcn_elf.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/lib/libbsdmalloc
Module Name:src Committed By: riastradh Date: Tue Jul 4 18:40:15 UTC 2023 Modified Files: src/lib/libbsdmalloc: Makefile malloc.c Log Message: libbsdmalloc: Nix K definitions. Bump WARNS to 3. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/lib/libbsdmalloc/Makefile cvs rdiff -u -r1.4 -r1.5 src/lib/libbsdmalloc/malloc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libbsdmalloc/Makefile diff -u src/lib/libbsdmalloc/Makefile:1.6 src/lib/libbsdmalloc/Makefile:1.7 --- src/lib/libbsdmalloc/Makefile:1.6 Tue Jul 4 16:23:15 2023 +++ src/lib/libbsdmalloc/Makefile Tue Jul 4 18:40:14 2023 @@ -1,6 +1,6 @@ -# $NetBSD: Makefile,v 1.6 2023/07/04 16:23:15 riastradh Exp $ +# $NetBSD: Makefile,v 1.7 2023/07/04 18:40:14 riastradh Exp $ -WARNS= 2 +WARNS= 3 .include Index: src/lib/libbsdmalloc/malloc.c diff -u src/lib/libbsdmalloc/malloc.c:1.4 src/lib/libbsdmalloc/malloc.c:1.5 --- src/lib/libbsdmalloc/malloc.c:1.4 Tue Jul 4 15:09:04 2023 +++ src/lib/libbsdmalloc/malloc.c Tue Jul 4 18:40:14 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: malloc.c,v 1.4 2023/07/04 15:09:04 riastradh Exp $ */ +/* $NetBSD: malloc.c,v 1.5 2023/07/04 18:40:14 riastradh Exp $ */ /* * Copyright (c) 1983, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)malloc.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: malloc.c,v 1.4 2023/07/04 15:09:04 riastradh Exp $"); +__RCSID("$NetBSD: malloc.c,v 1.5 2023/07/04 18:40:14 riastradh Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -176,8 +176,7 @@ botch(s) #endif void * -malloc(nbytes) - size_t nbytes; +malloc(size_t nbytes) { union overhead *op; int bucket; @@ -270,8 +269,7 @@ malloc(nbytes) * Allocate more memory to the indicated bucket. */ static void -morecore(bucket) - int bucket; +morecore(int bucket) { union overhead *op; long sz; /* size of desired block */ @@ -313,8 +311,7 @@ morecore(bucket) } void -free(cp) - void *cp; +free(void *cp) { long size; union overhead *op; @@ -357,9 +354,7 @@ free(cp) int __realloc_srchlen = 4; /* 4 should be plenty, -1 =>'s whole list */ void * -realloc(cp, nbytes) - void *cp; - size_t nbytes; +realloc(void *cp, size_t nbytes) { u_long onb; long i; @@ -448,9 +443,7 @@ realloc(cp, nbytes) * Return bucket number, or -1 if not found. */ static int -findbucket(freep, srchlen) - union overhead *freep; - int srchlen; +findbucket(union overhead *freep, int srchlen) { union overhead *p; int i, j; @@ -475,8 +468,7 @@ findbucket(freep, srchlen) * frees for each size category. */ void -mstats(s) - char *s; +mstats(char *s) { int i, j; union overhead *p;
CVS commit: src/lib/libbsdmalloc
Module Name:src Committed By: riastradh Date: Tue Jul 4 18:40:15 UTC 2023 Modified Files: src/lib/libbsdmalloc: Makefile malloc.c Log Message: libbsdmalloc: Nix K definitions. Bump WARNS to 3. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/lib/libbsdmalloc/Makefile cvs rdiff -u -r1.4 -r1.5 src/lib/libbsdmalloc/malloc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src
Module Name:src Committed By: riastradh Date: Tue Jul 4 16:23:15 UTC 2023 Modified Files: src/distrib/sets/lists/comp: mi src/external/gpl2/groff/tmac: mdoc.local src/lib/libbsdmalloc: Makefile Added Files: src/lib/libbsdmalloc: bsdmalloc.3 Log Message: libbsdmalloc: New man page. XXX pullup-10 To generate a diff of this commit: cvs rdiff -u -r1.2433 -r1.2434 src/distrib/sets/lists/comp/mi cvs rdiff -u -r1.9 -r1.10 src/external/gpl2/groff/tmac/mdoc.local cvs rdiff -u -r1.5 -r1.6 src/lib/libbsdmalloc/Makefile cvs rdiff -u -r0 -r1.1 src/lib/libbsdmalloc/bsdmalloc.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/distrib/sets/lists/comp/mi diff -u src/distrib/sets/lists/comp/mi:1.2433 src/distrib/sets/lists/comp/mi:1.2434 --- src/distrib/sets/lists/comp/mi:1.2433 Tue Jun 20 23:09:13 2023 +++ src/distrib/sets/lists/comp/mi Tue Jul 4 16:23:15 2023 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.2433 2023/06/20 23:09:13 wiz Exp $ +# $NetBSD: mi,v 1.2434 2023/07/04 16:23:15 riastradh Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. ./etc/mtree/set.compcomp-sys-root @@ -6657,6 +6657,7 @@ ./usr/share/man/cat3/bottom_panel.0 comp-c-catman .cat ./usr/share/man/cat3/box.0 comp-c-catman .cat ./usr/share/man/cat3/bsd_signal.0 comp-c-catman .cat +./usr/share/man/cat3/bsdmalloc.0 comp-c-catman .cat ./usr/share/man/cat3/bsearch.0 comp-c-catman .cat ./usr/share/man/cat3/bstring.0 comp-c-catman .cat ./usr/share/man/cat3/bswap.0 comp-c-catman .cat @@ -15142,6 +15143,7 @@ ./usr/share/man/html3/bottom_panel.html comp-c-htmlman html ./usr/share/man/html3/box.html comp-c-htmlman html ./usr/share/man/html3/bsd_signal.html comp-c-htmlman html +./usr/share/man/html3/bsdmalloc.html comp-c-htmlman html ./usr/share/man/html3/bsearch.html comp-c-htmlman html ./usr/share/man/html3/bstring.html comp-c-htmlman html ./usr/share/man/html3/bswap.html comp-c-htmlman html @@ -23470,6 +23472,7 @@ ./usr/share/man/man3/bottom_panel.3 comp-c-man .man ./usr/share/man/man3/box.3 comp-c-man .man ./usr/share/man/man3/bsd_signal.3 comp-c-man .man +./usr/share/man/man3/bsdmalloc.3 comp-c-man .man ./usr/share/man/man3/bsearch.3 comp-c-man .man ./usr/share/man/man3/bstring.3 comp-c-man .man ./usr/share/man/man3/bswap.3 comp-c-man .man Index: src/external/gpl2/groff/tmac/mdoc.local diff -u src/external/gpl2/groff/tmac/mdoc.local:1.9 src/external/gpl2/groff/tmac/mdoc.local:1.10 --- src/external/gpl2/groff/tmac/mdoc.local:1.9 Sat Dec 17 11:51:52 2022 +++ src/external/gpl2/groff/tmac/mdoc.local Tue Jul 4 16:23:15 2023 @@ -1,4 +1,4 @@ -.\" $NetBSD: mdoc.local,v 1.9 2022/12/17 11:51:52 kim Exp $ +.\" $NetBSD: mdoc.local,v 1.10 2023/07/04 16:23:15 riastradh Exp $ .\" .\" Copyright (c) 2003, 2004 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -152,6 +152,7 @@ .\" Local libraries not in groff .ds doc-str-Lb-libarchive Reading and Writing Streaming Archives Library (libarchive, \-larchive) .ds doc-str-Lb-libbluetooth Bluetooth Library (libbluetooth, \-lbluetooth) +.ds doc-str-Lb-bsdmallocHistoric BSD allocator (libbsdmalloc, \-lbsdmalloc) .ds doc-str-Lb-libdmDevice-mapper Library (libdm, \-ldm) .ds doc-str-Lb-libexecinfo Backtrace Access Library (libexecinfo, \-lexecinfo) .ds doc-str-Lb-libfetch File Transfer Library for URLs (libfetch, \-lfetch) Index: src/lib/libbsdmalloc/Makefile diff -u src/lib/libbsdmalloc/Makefile:1.5 src/lib/libbsdmalloc/Makefile:1.6 --- src/lib/libbsdmalloc/Makefile:1.5 Tue Jul 4 15:08:55 2023 +++ src/lib/libbsdmalloc/Makefile Tue Jul 4 16:23:15 2023 @@ -1,6 +1,4 @@ -# $NetBSD: Makefile,v 1.5 2023/07/04 15:08:55 riastradh Exp $ - -NOMAN=1 +# $NetBSD: Makefile,v 1.6 2023/07/04 16:23:15 riastradh Exp $ WARNS= 2 @@ -8,6 +6,7 @@ WARNS= 2 LIB= bsdmalloc SRCS= malloc.c +MAN= bsdmalloc.3 CFLAGS+= -fno-builtin-aligned_alloc CFLAGS+= -fno-builtin-calloc Added files: Index: src/lib/libbsdmalloc/bsdmalloc.3 diff -u /dev/null src/lib/libbsdmalloc/bsdmalloc.3:1.1 --- /dev/null Tue Jul 4 16:23:15 2023 +++ src/lib/libbsdmalloc/bsdmalloc.3 Tue Jul 4 16:23:15 2023 @@ -0,0 +1,86 @@ +.\" $NetBSD: bsdmalloc.3,v 1.1 2023/07/04 16:23:15 riastradh Exp $ +.\" +.\" Copyright (c) 2023 The NetBSD Foundation, Inc. +.\" 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
CVS commit: src
Module Name:src Committed By: riastradh Date: Tue Jul 4 16:23:15 UTC 2023 Modified Files: src/distrib/sets/lists/comp: mi src/external/gpl2/groff/tmac: mdoc.local src/lib/libbsdmalloc: Makefile Added Files: src/lib/libbsdmalloc: bsdmalloc.3 Log Message: libbsdmalloc: New man page. XXX pullup-10 To generate a diff of this commit: cvs rdiff -u -r1.2433 -r1.2434 src/distrib/sets/lists/comp/mi cvs rdiff -u -r1.9 -r1.10 src/external/gpl2/groff/tmac/mdoc.local cvs rdiff -u -r1.5 -r1.6 src/lib/libbsdmalloc/Makefile cvs rdiff -u -r0 -r1.1 src/lib/libbsdmalloc/bsdmalloc.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src
Module Name:src Committed By: riastradh Date: Tue Jul 4 16:22:11 UTC 2023 Modified Files: src/distrib/sets/lists/base: shl.mi src/distrib/sets/lists/debug: shl.mi src/lib/libbsdmalloc: shlib_version Log Message: libbsdmalloc: Bump shlib minor. New symbols, new minor. XXX pullup-10 To generate a diff of this commit: cvs rdiff -u -r1.951 -r1.952 src/distrib/sets/lists/base/shl.mi cvs rdiff -u -r1.312 -r1.313 src/distrib/sets/lists/debug/shl.mi cvs rdiff -u -r1.1 -r1.2 src/lib/libbsdmalloc/shlib_version Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/distrib/sets/lists/base/shl.mi diff -u src/distrib/sets/lists/base/shl.mi:1.951 src/distrib/sets/lists/base/shl.mi:1.952 --- src/distrib/sets/lists/base/shl.mi:1.951 Thu Jun 8 22:56:14 2023 +++ src/distrib/sets/lists/base/shl.mi Tue Jul 4 16:22:10 2023 @@ -1,4 +1,4 @@ -# $NetBSD: shl.mi,v 1.951 2023/06/08 22:56:14 kre Exp $ +# $NetBSD: shl.mi,v 1.952 2023/07/04 16:22:10 riastradh Exp $ # # Note: Don't delete entries from here - mark them as "obsolete" instead, # unless otherwise stated below. @@ -250,7 +250,7 @@ ./usr/lib/libbozohttpd.so.0.0 base-sys-shlib compatfile ./usr/lib/libbsdmalloc.so base-sys-shlib compatfile ./usr/lib/libbsdmalloc.so.0 base-sys-shlib compatfile -./usr/lib/libbsdmalloc.so.0.0 base-sys-shlib compatfile +./usr/lib/libbsdmalloc.so.0.1 base-sys-shlib compatfile ./usr/lib/libbz2.sobase-sys-shlib compatfile ./usr/lib/libbz2.so.1base-sys-shlib compatfile ./usr/lib/libbz2.so.1.1base-sys-shlib compatfile Index: src/distrib/sets/lists/debug/shl.mi diff -u src/distrib/sets/lists/debug/shl.mi:1.312 src/distrib/sets/lists/debug/shl.mi:1.313 --- src/distrib/sets/lists/debug/shl.mi:1.312 Thu Jun 8 21:14:09 2023 +++ src/distrib/sets/lists/debug/shl.mi Tue Jul 4 16:22:10 2023 @@ -1,4 +1,4 @@ -# $NetBSD: shl.mi,v 1.312 2023/06/08 21:14:09 nikita Exp $ +# $NetBSD: shl.mi,v 1.313 2023/07/04 16:22:10 riastradh Exp $ ./usr/lib/libbfd_g.a comp-c-debuglib debuglib,compatfile,binutils ./usr/libdata/debug/lib base-sys-usr debug,dynamicroot,compatdir ./usr/libdata/debug/lib/libavl.so.0.0.debug comp-zfs-debug debug,dynamicroot,zfs @@ -84,7 +84,7 @@ ./usr/libdata/debug/usr/lib/libblocklist.so.0.0.debug comp-sys-debug debug,compatfile ./usr/libdata/debug/usr/lib/libbluetooth.so.4.2.debug comp-sys-debug debug,compatfile ./usr/libdata/debug/usr/lib/libbozohttpd.so.0.0.debug comp-sys-debug debug,compatfile -./usr/libdata/debug/usr/lib/libbsdmalloc.so.0.0.debug comp-sys-debug debug,compatfile +./usr/libdata/debug/usr/lib/libbsdmalloc.so.0.1.debug comp-sys-debug debug,compatfile ./usr/libdata/debug/usr/lib/libbz2.so.1.1.debug comp-sys-debug debug,compatfile ./usr/libdata/debug/usr/lib/libc++.so.1.0.debug comp-sys-debug debug,compatfile,libcxx ./usr/libdata/debug/usr/lib/libc.so.12.220.debug comp-sys-debug debug,compatfile Index: src/lib/libbsdmalloc/shlib_version diff -u src/lib/libbsdmalloc/shlib_version:1.1 src/lib/libbsdmalloc/shlib_version:1.2 --- src/lib/libbsdmalloc/shlib_version:1.1 Mon Apr 21 22:21:07 2003 +++ src/lib/libbsdmalloc/shlib_version Tue Jul 4 16:22:11 2023 @@ -1,5 +1,5 @@ -# $NetBSD: shlib_version,v 1.1 2003/04/21 22:21:07 elric Exp $ +# $NetBSD: shlib_version,v 1.2 2023/07/04 16:22:11 riastradh Exp $ # Remember to update distrib/sets/lists/base/shl.* when changing major=0 -minor=0 +minor=1
CVS commit: src
Module Name:src Committed By: riastradh Date: Tue Jul 4 16:22:11 UTC 2023 Modified Files: src/distrib/sets/lists/base: shl.mi src/distrib/sets/lists/debug: shl.mi src/lib/libbsdmalloc: shlib_version Log Message: libbsdmalloc: Bump shlib minor. New symbols, new minor. XXX pullup-10 To generate a diff of this commit: cvs rdiff -u -r1.951 -r1.952 src/distrib/sets/lists/base/shl.mi cvs rdiff -u -r1.312 -r1.313 src/distrib/sets/lists/debug/shl.mi cvs rdiff -u -r1.1 -r1.2 src/lib/libbsdmalloc/shlib_version Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/lib/libbsdmalloc
Module Name:src Committed By: riastradh Date: Tue Jul 4 15:09:04 UTC 2023 Modified Files: src/lib/libbsdmalloc: malloc.c Log Message: libbsdmalloc: Nix trailing whitespace. No functional change intended. XXX pullup-10 To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/lib/libbsdmalloc/malloc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libbsdmalloc/malloc.c diff -u src/lib/libbsdmalloc/malloc.c:1.3 src/lib/libbsdmalloc/malloc.c:1.4 --- src/lib/libbsdmalloc/malloc.c:1.3 Tue Jul 4 15:08:55 2023 +++ src/lib/libbsdmalloc/malloc.c Tue Jul 4 15:09:04 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: malloc.c,v 1.3 2023/07/04 15:08:55 riastradh Exp $ */ +/* $NetBSD: malloc.c,v 1.4 2023/07/04 15:09:04 riastradh Exp $ */ /* * Copyright (c) 1983, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)malloc.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: malloc.c,v 1.3 2023/07/04 15:08:55 riastradh Exp $"); +__RCSID("$NetBSD: malloc.c,v 1.4 2023/07/04 15:09:04 riastradh Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -42,9 +42,9 @@ __RCSID("$NetBSD: malloc.c,v 1.3 2023/07 * malloc.c (Caltech) 2/21/82 * Chris Kingsley, kingsley@cit-20. * - * This is a very fast storage allocator. It allocates blocks of a small + * This is a very fast storage allocator. It allocates blocks of a small * number of different sizes, and keeps free lists of each size. Blocks that - * don't exactly fit are passed up to the next larger size. In this + * don't exactly fit are passed up to the next larger size. In this * implementation, the available sizes are 2^n-4 (or 2^n-10) bytes long. * This is designed for use in a virtual memory environment. */ @@ -164,7 +164,7 @@ botch(s) * might, depending on the implementation, result in another malloc() * to be executed, and ii) it is really not desirable to let execution * continue. `Fix me.' - * + * * Note that holding mutex_lock during abort() is safe. */ @@ -315,7 +315,7 @@ morecore(bucket) void free(cp) void *cp; -{ +{ long size; union overhead *op; @@ -358,9 +358,9 @@ int __realloc_srchlen = 4; /* 4 should b void * realloc(cp, nbytes) - void *cp; + void *cp; size_t nbytes; -{ +{ u_long onb; long i; union overhead *op; @@ -418,7 +418,7 @@ realloc(cp, nbytes) #endif mutex_unlock(_mutex); return (cp); - + } #ifndef _REENT else @@ -469,7 +469,7 @@ findbucket(freep, srchlen) #ifdef MSTATS /* * mstats - print out statistics about malloc - * + * * Prints two lines of numbers, one showing the length of the free list * for each size category, the second showing the number of mallocs - * frees for each size category.
CVS commit: src/lib/libbsdmalloc
Module Name:src Committed By: riastradh Date: Tue Jul 4 15:08:55 UTC 2023 Modified Files: src/lib/libbsdmalloc: Makefile malloc.c Log Message: libbsdmalloc: Provide all allocator front ends and fork hooks. Front ends: - aligned_alloc - calloc - posix_memalign Fork hooks: - _malloc_prefork - _malloc_postfork - _malloc_postfork_child Otherwise these will pull in the jemalloc definitions from libc, which (a) defeats the purpose, and (b) won't work correctly with fork and threads. Thanks to kre@ and the thread on tech-userlevel for pointing me in the right direction to making this actually work to override jemalloc: https://mail-index.netbsd.org/tech-userlevel/2023/06/30/msg013957.html Note: libbsdmalloc doesn't set errno=ENOMEM on malloc failure, but these front ends do (even aligned_alloc, which is from C11, which doesn't define ENOMEM at all, but this pacifies our aligned_alloc tests in t_posix_memalign.c). Might want to fix that. XXX pullup-10 To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/lib/libbsdmalloc/Makefile cvs rdiff -u -r1.2 -r1.3 src/lib/libbsdmalloc/malloc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libbsdmalloc/Makefile diff -u src/lib/libbsdmalloc/Makefile:1.4 src/lib/libbsdmalloc/Makefile:1.5 --- src/lib/libbsdmalloc/Makefile:1.4 Wed Mar 21 10:08:30 2012 +++ src/lib/libbsdmalloc/Makefile Tue Jul 4 15:08:55 2023 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.4 2012/03/21 10:08:30 matt Exp $ +# $NetBSD: Makefile,v 1.5 2023/07/04 15:08:55 riastradh Exp $ NOMAN=1 @@ -9,6 +9,13 @@ WARNS= 2 LIB= bsdmalloc SRCS= malloc.c +CFLAGS+= -fno-builtin-aligned_alloc +CFLAGS+= -fno-builtin-calloc +CFLAGS+= -fno-builtin-free +CFLAGS+= -fno-builtin-malloc +CFLAGS+= -fno-builtin-posix_memalign +CFLAGS+= -fno-builtin-realloc + CPPFLAGS+= -D_REENT -D_REENTRANT -I${.CURDIR}/../libc/include/ .include Index: src/lib/libbsdmalloc/malloc.c diff -u src/lib/libbsdmalloc/malloc.c:1.2 src/lib/libbsdmalloc/malloc.c:1.3 --- src/lib/libbsdmalloc/malloc.c:1.2 Thu Aug 7 16:42:01 2003 +++ src/lib/libbsdmalloc/malloc.c Tue Jul 4 15:08:55 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: malloc.c,v 1.2 2003/08/07 16:42:01 agc Exp $ */ +/* $NetBSD: malloc.c,v 1.3 2023/07/04 15:08:55 riastradh Exp $ */ /* * Copyright (c) 1983, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)malloc.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: malloc.c,v 1.2 2003/08/07 16:42:01 agc Exp $"); +__RCSID("$NetBSD: malloc.c,v 1.3 2023/07/04 15:08:55 riastradh Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -53,12 +53,18 @@ __RCSID("$NetBSD: malloc.c,v 1.2 2003/08 #if defined(DEBUG) || defined(RCHECK) #include #endif + +#include +#include +#include +#include #if defined(RCHECK) || defined(MSTATS) #include #endif #include #include #include + #include "reentrant.h" @@ -166,7 +172,7 @@ botch(s) abort(); } #else -#define ASSERT(p) +#define ASSERT(p) ((void)sizeof((long)(p))) #endif void * @@ -493,3 +499,115 @@ mstats(s) totused, totfree); } #endif + +/* + * Additional front ends: + * - aligned_alloc (C11) + * - calloc(n,m) = malloc(n*m) without overflow + * - posix_memalign (POSIX) + * + * These must all be in the same compilation unit as malloc, realloc, + * and free (or -lbsdmalloc must be surrounded by -Wl,--whole-archive + * -lbsdmalloc -Wl,--no-whole-archive) in order to override the libc + * built-in malloc implementation. + * + * Allocations of size n, up to and including the page size, are + * already aligned by malloc on multiples of n. Larger alignment is + * not supported. + */ + +static long __constfunc +cachedpagesize(void) +{ + long n; + + /* XXX atomic_load_relaxed, but that's not defined in userland atm */ + if (__predict_false((n = pagesz) == 0)) { + mutex_lock(_mutex); + if ((n = pagesz) == 0) + n = pagesz = getpagesize(); + mutex_unlock(_mutex); + } + + return n; +} + +void * +aligned_alloc(size_t alignment, size_t size) +{ + char *p; + + if (alignment == 0 || + (alignment & (alignment - 1)) != 0 || + alignment > cachedpagesize() || + (size & (alignment - 1)) != 0) { + errno = EINVAL; + return NULL; + } + p = malloc(size); + if (__predict_false(p == NULL)) + ASSERT((uintptr_t)p % alignment == 0); + return p; +} + +void * +calloc(size_t nmemb, size_t size) +{ + void *p; + size_t n; + + if (__builtin_mul_overflow_p(nmemb, size, (size_t)0)) { + errno = ENOMEM; + return NULL; + } + n = nmemb * size; + p = malloc(n); + if (__predict_false(p == NULL)) + return NULL; + memset(p, 0, n); + return p; +} + +int +posix_memalign(void **memptr, size_t alignment, size_t size) +{ + char *p; + + if (alignment < sizeof(void *) || + (alignment & (alignment - 1)) != 0 || + alignment > cachedpagesize()) + return EINVAL; + p = malloc(size < alignment ? alignment : size); + if (__predict_false(p == NULL)) +
CVS commit: src/lib/libbsdmalloc
Module Name:src Committed By: riastradh Date: Tue Jul 4 15:09:04 UTC 2023 Modified Files: src/lib/libbsdmalloc: malloc.c Log Message: libbsdmalloc: Nix trailing whitespace. No functional change intended. XXX pullup-10 To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/lib/libbsdmalloc/malloc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/lib/libbsdmalloc
Module Name:src Committed By: riastradh Date: Tue Jul 4 15:08:55 UTC 2023 Modified Files: src/lib/libbsdmalloc: Makefile malloc.c Log Message: libbsdmalloc: Provide all allocator front ends and fork hooks. Front ends: - aligned_alloc - calloc - posix_memalign Fork hooks: - _malloc_prefork - _malloc_postfork - _malloc_postfork_child Otherwise these will pull in the jemalloc definitions from libc, which (a) defeats the purpose, and (b) won't work correctly with fork and threads. Thanks to kre@ and the thread on tech-userlevel for pointing me in the right direction to making this actually work to override jemalloc: https://mail-index.netbsd.org/tech-userlevel/2023/06/30/msg013957.html Note: libbsdmalloc doesn't set errno=ENOMEM on malloc failure, but these front ends do (even aligned_alloc, which is from C11, which doesn't define ENOMEM at all, but this pacifies our aligned_alloc tests in t_posix_memalign.c). Might want to fix that. XXX pullup-10 To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/lib/libbsdmalloc/Makefile cvs rdiff -u -r1.2 -r1.3 src/lib/libbsdmalloc/malloc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libc/stdlib
Module Name:src Committed By: riastradh Date: Tue Jul 4 15:06:36 UTC 2023 Modified Files: src/tests/lib/libc/stdlib: Makefile t_posix_memalign.c Log Message: t_posix_memalign: Expand test cases and properties. - Test cartesian product of a sampling of sizes and a sampling of alignments. - Verify all the edge cases I could find in posix_memalign and aligned_alloc, including failure modes. - Test an unreasonably large (but aligned) allocation size. - Use ATF_CHECK_* instead of ATF_REQUIRE_* so all failures will be reported, not just the first one. - While here, build with -fno-builtin-aligned_alloc and with -fno-builtin-posix_memalign to make sure the compiler doesn't try any shenanigans. XXX pullup-10 To generate a diff of this commit: cvs rdiff -u -r1.33 -r1.34 src/tests/lib/libc/stdlib/Makefile cvs rdiff -u -r1.5 -r1.6 src/tests/lib/libc/stdlib/t_posix_memalign.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/stdlib/Makefile diff -u src/tests/lib/libc/stdlib/Makefile:1.33 src/tests/lib/libc/stdlib/Makefile:1.34 --- src/tests/lib/libc/stdlib/Makefile:1.33 Wed Jul 1 07:16:37 2020 +++ src/tests/lib/libc/stdlib/Makefile Tue Jul 4 15:06:36 2023 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.33 2020/07/01 07:16:37 jruoho Exp $ +# $NetBSD: Makefile,v 1.34 2023/07/04 15:06:36 riastradh Exp $ .include @@ -31,6 +31,9 @@ BINDIR= ${TESTSDIR} PROGS+= h_atexit PROGS+= h_getopt h_getopt_long +CFLAGS.t_posix_memalign.c+= -fno-builtin-posix_memalign +CFLAGS.t_posix_memalign.c+= -fno-builtin-aligned_alloc + CPPFLAGS.t_strtod.c+= -D__TEST_FENV LDADD.t_strtod= -lm DPADD.t_strtod+= ${LIBM} Index: src/tests/lib/libc/stdlib/t_posix_memalign.c diff -u src/tests/lib/libc/stdlib/t_posix_memalign.c:1.5 src/tests/lib/libc/stdlib/t_posix_memalign.c:1.6 --- src/tests/lib/libc/stdlib/t_posix_memalign.c:1.5 Sun Jul 29 01:45:25 2018 +++ src/tests/lib/libc/stdlib/t_posix_memalign.c Tue Jul 4 15:06:36 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: t_posix_memalign.c,v 1.5 2018/07/29 01:45:25 maya Exp $ */ +/* $NetBSD: t_posix_memalign.c,v 1.6 2023/07/04 15:06:36 riastradh Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -32,7 +32,7 @@ #include __COPYRIGHT("@(#) Copyright (c) 2008\ The NetBSD Foundation, inc. All rights reserved."); -__RCSID("$NetBSD: t_posix_memalign.c,v 1.5 2018/07/29 01:45:25 maya Exp $"); +__RCSID("$NetBSD: t_posix_memalign.c,v 1.6 2023/07/04 15:06:36 riastradh Exp $"); #include @@ -43,6 +43,8 @@ __RCSID("$NetBSD: t_posix_memalign.c,v 1 #include #include +#define rounddown(x, n) (((x) / (n)) * (n)) + ATF_TC(posix_memalign_basic); ATF_TC_HEAD(posix_memalign_basic, tc) { @@ -50,32 +52,77 @@ ATF_TC_HEAD(posix_memalign_basic, tc) } ATF_TC_BODY(posix_memalign_basic, tc) { - static const size_t size[] = { - 1, 2, 3, 4, 10, 100, 16384, 32768, 65536 - }; + enum { maxaligntest = 16384 }; static const size_t align[] = { - 512, 1024, 16, 32, 64, 4, 2048, 16, 2 + 0, 1, 2, 3, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, + 8192, maxaligntest, + }; + static const size_t size[] = { + 0, 1, 2, 3, 4, 10, 100, 1, 16384, 32768, 65536, + rounddown(SIZE_MAX, maxaligntest), }; + size_t i, j; - size_t i; - void *p; + for (i = 0; i < __arraycount(align); i++) { + for (j = 0; j < __arraycount(size); j++) { + void *p = (void *)0x1; + const int ret = posix_memalign(, align[i], size[j]); + + if (align[i] == 0 || + (align[i] & (align[i] - 1)) != 0 || + align[i] < sizeof(void *)) { +ATF_CHECK_EQ_MSG(ret, EINVAL, +"posix_memalign(, %zu, %zu): %s", +align[i], size[j], strerror(ret)); +continue; + } + if (size[j] == rounddown(SIZE_MAX, maxaligntest) && + ret != EINVAL) { +/* + * If obscenely large alignment isn't + * rejected as EINVAL, we can't + * allocate that much memory anyway. + */ +ATF_CHECK_EQ_MSG(ret, ENOMEM, +"posix_memalign(, %zu, %zu): %s", +align[i], size[j], strerror(ret)); +continue; + } + + /* + * Allocation should fail only if the alignment + * isn't supported, in which case it will fail + * with EINVAL. No standard criterion for what + * alignments are supported, so just stop here + * on EINVAL. + */ + if (ret == EINVAL) +continue; + + ATF_CHECK_EQ_MSG(ret, 0, + "posix_memalign(, %zu, %zu): %s", + align[i], size[j], strerror(ret)); + ATF_CHECK_EQ_MSG((intptr_t)p & (align[i] - 1), 0, + "posix_memalign(, %zu, %zu): %p", + align[i], size[j], p); + + if (size[j] != 0) { +if (p == NULL) { + atf_tc_fail_nonfatal( + "%s:%d:" + "posix_memalign(, %zu, %zu):" + " %p", + __FILE__, __LINE__, + align[i], size[j], p); +} + } else { +/* + * No guarantees about whether + * zero-size allocation yields null +
CVS commit: src/tests/lib/libc/stdlib
Module Name:src Committed By: riastradh Date: Tue Jul 4 15:06:36 UTC 2023 Modified Files: src/tests/lib/libc/stdlib: Makefile t_posix_memalign.c Log Message: t_posix_memalign: Expand test cases and properties. - Test cartesian product of a sampling of sizes and a sampling of alignments. - Verify all the edge cases I could find in posix_memalign and aligned_alloc, including failure modes. - Test an unreasonably large (but aligned) allocation size. - Use ATF_CHECK_* instead of ATF_REQUIRE_* so all failures will be reported, not just the first one. - While here, build with -fno-builtin-aligned_alloc and with -fno-builtin-posix_memalign to make sure the compiler doesn't try any shenanigans. XXX pullup-10 To generate a diff of this commit: cvs rdiff -u -r1.33 -r1.34 src/tests/lib/libc/stdlib/Makefile cvs rdiff -u -r1.5 -r1.6 src/tests/lib/libc/stdlib/t_posix_memalign.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/external/bsd/jemalloc/dist/src
Module Name:src Committed By: riastradh Date: Tue Jul 4 15:06:28 UTC 2023 Modified Files: src/external/bsd/jemalloc/dist/src: jemalloc.c Log Message: jemalloc: Enforce alignment-must-divide-size rule of aligned_alloc. C11, Sec. 7.22.3.1 The aligned_alloc function, paragraph 2, p. 348: The value of alignment shall be a valid alignment supported by the implementation and the value of size shall be an integral multiple of alignment. posix_memalign does not appear to have any corresponding constraint. XXX pullup-10 To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/external/bsd/jemalloc/dist/src/jemalloc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/external/bsd/jemalloc/dist/src
Module Name:src Committed By: riastradh Date: Tue Jul 4 15:06:28 UTC 2023 Modified Files: src/external/bsd/jemalloc/dist/src: jemalloc.c Log Message: jemalloc: Enforce alignment-must-divide-size rule of aligned_alloc. C11, Sec. 7.22.3.1 The aligned_alloc function, paragraph 2, p. 348: The value of alignment shall be a valid alignment supported by the implementation and the value of size shall be an integral multiple of alignment. posix_memalign does not appear to have any corresponding constraint. XXX pullup-10 To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/external/bsd/jemalloc/dist/src/jemalloc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/jemalloc/dist/src/jemalloc.c diff -u src/external/bsd/jemalloc/dist/src/jemalloc.c:1.10 src/external/bsd/jemalloc/dist/src/jemalloc.c:1.11 --- src/external/bsd/jemalloc/dist/src/jemalloc.c:1.10 Sat Jul 1 06:29:14 2023 +++ src/external/bsd/jemalloc/dist/src/jemalloc.c Tue Jul 4 15:06:28 2023 @@ -1635,6 +1635,9 @@ struct static_opts_s { /* Whether to set errno when we encounter an error condition. */ bool set_errno_on_error; + /* Whether the alignment must divide the size. */ + bool alignment_must_divide_size; + /* * The minimum valid alignment for functions requesting aligned storage. */ @@ -1662,6 +1665,7 @@ static_opts_init(static_opts_t *static_o static_opts->assert_nonempty_alloc = false; static_opts->null_out_result_on_error = false; static_opts->set_errno_on_error = false; + static_opts->alignment_must_divide_size = false; static_opts->min_alignment = 0; static_opts->oom_string = ""; static_opts->invalid_alignment_string = ""; @@ -1857,6 +1861,11 @@ imalloc_body(static_opts_t *sopts, dynam || (dopts->alignment & (dopts->alignment - 1)) != 0)) { goto label_invalid_alignment; } + if (sopts->alignment_must_divide_size) { + if (unlikely(dopts->item_size % dopts->alignment)) { + goto label_invalid_alignment; + } + } /* This is the beginning of the "core" algorithm. */ @@ -2125,6 +2134,7 @@ je_aligned_alloc(size_t alignment, size_ sopts.bump_empty_alloc = true; sopts.null_out_result_on_error = true; sopts.set_errno_on_error = true; + sopts.alignment_must_divide_size = true; sopts.min_alignment = 1; sopts.oom_string = ": Error allocating aligned memory: out of memory\n";