From owner-svn-src-projects@freebsd.org Thu Sep 19 19:26:17 2019 Return-Path: Delivered-To: svn-src-projects@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6082812C569 for ; Thu, 19 Sep 2019 19:26:17 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46Z6K52cBmz4B00; Thu, 19 Sep 2019 19:26:17 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 223491A1D7; Thu, 19 Sep 2019 19:26:17 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x8JJQHHn084927; Thu, 19 Sep 2019 19:26:17 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x8JJQCTP084903; Thu, 19 Sep 2019 19:26:12 GMT (envelope-from dim@FreeBSD.org) Message-Id: <201909191926.x8JJQCTP084903@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dim set sender to dim@FreeBSD.org using -f From: Dimitry Andric Date: Thu, 19 Sep 2019 19:26:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r352537 - in projects/clang900-import: . cddl/contrib/opensolaris/cmd/zfs cddl/contrib/opensolaris/lib/libzfs/common contrib/jemalloc/src contrib/netbsd-tests/lib/libc/sys lib lib/libar... X-SVN-Group: projects X-SVN-Commit-Author: dim X-SVN-Commit-Paths: in projects/clang900-import: . cddl/contrib/opensolaris/cmd/zfs cddl/contrib/opensolaris/lib/libzfs/common contrib/jemalloc/src contrib/netbsd-tests/lib/libc/sys lib lib/libarchive lib/libarchive/test... X-SVN-Commit-Revision: 352537 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Sep 2019 19:26:17 -0000 Author: dim Date: Thu Sep 19 19:26:12 2019 New Revision: 352537 URL: https://svnweb.freebsd.org/changeset/base/352537 Log: Merge ^/head r352436 through r352536. Added: projects/clang900-import/sys/dev/hwpmc/hwpmc_beri.c - copied unchanged from r352536, head/sys/dev/hwpmc/hwpmc_beri.c projects/clang900-import/sys/dev/hwpmc/hwpmc_beri.h - copied unchanged from r352536, head/sys/dev/hwpmc/hwpmc_beri.h projects/clang900-import/tests/sys/vm/page_fault_signal.c - copied unchanged from r352536, head/tests/sys/vm/page_fault_signal.c projects/clang900-import/tools/build/options/WITH_GOOGLETEST - copied unchanged from r352536, head/tools/build/options/WITH_GOOGLETEST Modified: projects/clang900-import/Makefile.inc1 projects/clang900-import/cddl/contrib/opensolaris/cmd/zfs/zfs.8 projects/clang900-import/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c projects/clang900-import/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h projects/clang900-import/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c projects/clang900-import/contrib/jemalloc/src/jemalloc.c projects/clang900-import/contrib/netbsd-tests/lib/libc/sys/t_stat.c projects/clang900-import/lib/Makefile projects/clang900-import/lib/libarchive/Makefile projects/clang900-import/lib/libarchive/tests/Makefile projects/clang900-import/lib/libbe/be.c projects/clang900-import/lib/libc/gen/sysctlnametomib.c projects/clang900-import/lib/libc/sys/open.2 projects/clang900-import/lib/libpmc/libpmc.c projects/clang900-import/sbin/ifconfig/ifmedia.c projects/clang900-import/share/man/man5/src.conf.5 projects/clang900-import/share/mk/src.libnames.mk projects/clang900-import/share/mk/src.opts.mk projects/clang900-import/stand/efi/libefi/efipart.c projects/clang900-import/stand/forth/loader.4th projects/clang900-import/stand/libsa/stand.h projects/clang900-import/stand/libsa/zalloc.c projects/clang900-import/stand/libsa/zalloc_defs.h projects/clang900-import/stand/libsa/zalloc_malloc.c projects/clang900-import/stand/libsa/zalloc_mem.h projects/clang900-import/stand/libsa/zalloc_protos.h projects/clang900-import/stand/mips/uboot/Makefile projects/clang900-import/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_scan.c projects/clang900-import/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c projects/clang900-import/sys/conf/files.mips projects/clang900-import/sys/dev/hwpmc/pmc_events.h projects/clang900-import/sys/dev/vt/vt_core.c projects/clang900-import/sys/fs/nfsclient/nfs_clport.c projects/clang900-import/sys/kern/kern_sysctl.c projects/clang900-import/sys/kern/vfs_cluster.c projects/clang900-import/sys/kern/vfs_default.c projects/clang900-import/sys/kern/vfs_vnops.c projects/clang900-import/sys/net/if.c projects/clang900-import/sys/net/if.h projects/clang900-import/sys/netinet/sctp_auth.c projects/clang900-import/sys/netinet/tcp_stacks/rack.c projects/clang900-import/sys/netinet6/ip6_input.c projects/clang900-import/sys/sys/pmc.h projects/clang900-import/sys/sys/sockio.h projects/clang900-import/sys/sys/sysctl.h projects/clang900-import/sys/vm/vm_glue.c projects/clang900-import/tests/sys/netpfil/common/forward.sh projects/clang900-import/tests/sys/netpfil/common/tos.sh projects/clang900-import/tests/sys/vm/Makefile projects/clang900-import/usr.bin/truss/syscall.h projects/clang900-import/usr.bin/truss/syscalls.c projects/clang900-import/usr.sbin/freebsd-update/freebsd-update.8 projects/clang900-import/usr.sbin/freebsd-update/freebsd-update.sh projects/clang900-import/usr.sbin/newsyslog/newsyslog.conf projects/clang900-import/usr.sbin/ntp/libntp/Makefile projects/clang900-import/usr.sbin/pkg/Makefile projects/clang900-import/usr.sbin/syslogd/syslog.conf Directory Properties: projects/clang900-import/ (props changed) projects/clang900-import/cddl/ (props changed) projects/clang900-import/cddl/contrib/opensolaris/ (props changed) projects/clang900-import/cddl/contrib/opensolaris/cmd/zfs/ (props changed) projects/clang900-import/cddl/contrib/opensolaris/lib/libzfs/ (props changed) projects/clang900-import/contrib/netbsd-tests/ (props changed) projects/clang900-import/sys/cddl/contrib/opensolaris/ (props changed) Modified: projects/clang900-import/Makefile.inc1 ============================================================================== --- projects/clang900-import/Makefile.inc1 Thu Sep 19 19:25:01 2019 (r352536) +++ projects/clang900-import/Makefile.inc1 Thu Sep 19 19:26:12 2019 (r352537) @@ -2773,6 +2773,7 @@ _prebuild_libs= ${_kerberos5_lib_libasn1} \ lib/libfigpar \ ${_lib_libgssapi} \ lib/libkiconv lib/libkvm lib/liblzma lib/libmd lib/libnv \ + lib/libzstd \ ${_lib_casper} \ lib/ncurses/ncurses lib/ncurses/ncursesw \ lib/libopie lib/libpam/libpam ${_lib_libthr} \ Modified: projects/clang900-import/cddl/contrib/opensolaris/cmd/zfs/zfs.8 ============================================================================== --- projects/clang900-import/cddl/contrib/opensolaris/cmd/zfs/zfs.8 Thu Sep 19 19:25:01 2019 (r352536) +++ projects/clang900-import/cddl/contrib/opensolaris/cmd/zfs/zfs.8 Thu Sep 19 19:26:12 2019 (r352537) @@ -190,8 +190,8 @@ .Ar snapshot .Nm .Cm send -.Op Fl Lce -.Op Fl i Ar snapshot Ns | Ns bookmark +.Op Fl LPcenv +.Op Fl i Ar snapshot Ns | Ns Ar bookmark .Ar filesystem Ns | Ns Ar volume Ns | Ns Ar snapshot .Nm .Cm send @@ -2766,7 +2766,7 @@ on future versions of .It Xo .Nm .Cm send -.Op Fl Lce +.Op Fl LPcenv .Op Fl i Ar snapshot Ns | Ns Ar bookmark .Ar filesystem Ns | Ns Ar volume Ns | Ns Ar snapshot .Xc @@ -2780,7 +2780,7 @@ stream generated from a filesystem or volume is receiv name will be .Pq --head-- . .Bl -tag -width indent -.It Fl i Ar snapshot Ns | Ns bookmark +.It Fl i Ar snapshot Ns | Ns Ar bookmark Generate an incremental send stream. The incremental source must be an earlier snapshot in the destination's history. @@ -2792,6 +2792,23 @@ specified as the last component of the name If the incremental target is a clone, the incremental source can be the origin snapshot, or an earlier snapshot in the origin's filesystem, or the origin's origin, etc. +.It Fl n, -dryrun +Do a dry-run +.Pq Qq No-op +send. +Do not generate any actual send data. +This is useful in conjunction with the +.Fl v +or +.Fl P +flags to determine what data will be sent. +In this case, the verbose output will be written to standard output +.Po contrast with a non-dry-run, where the stream is written to standard output +and the verbose output goes to standard error +.Pc . +.It Fl v, -verbose +Print verbose information about the stream package generated. +This information includes a per-second report of how much data has been sent. .It Fl L, -large-block Generate a stream which may contain blocks larger than 128KB. This flag @@ -2808,6 +2825,8 @@ See for details on ZFS feature flags and the .Sy large_blocks feature. +.It Fl P, -parsable +Print machine-parsable verbose information about the stream package generated. .It Fl c, -compressed Generate a more compact stream by using compressed WRITE records for blocks which are compressed on disk and in memory (see the Modified: projects/clang900-import/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c ============================================================================== --- projects/clang900-import/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c Thu Sep 19 19:25:01 2019 (r352536) +++ projects/clang900-import/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c Thu Sep 19 19:26:12 2019 (r352537) @@ -290,7 +290,7 @@ get_usage(zfs_help_t idx) case HELP_SEND: return (gettext("\tsend [-DnPpRvLec] [-[iI] snapshot] " "\n" - "\tsend [-Le] [-i snapshot|bookmark] " + "\tsend [-LPcenv] [-i snapshot|bookmark] " "\n" "\tsend [-nvPe] -t \n")); case HELP_SET: @@ -3928,13 +3928,11 @@ zfs_do_send(int argc, char **argv) if (strchr(argv[0], '@') == NULL || (fromname && strchr(fromname, '#') != NULL)) { char frombuf[ZFS_MAX_DATASET_NAME_LEN]; - enum lzc_send_flags lzc_flags = 0; if (flags.replicate || flags.doall || flags.props || - flags.dedup || flags.dryrun || flags.verbose || - flags.progress) { - (void) fprintf(stderr, - gettext("Error: " + flags.dedup || (strchr(argv[0], '@') == NULL && + (flags.dryrun || flags.verbose || flags.progress))) { + (void) fprintf(stderr, gettext("Error: " "Unsupported flag with filesystem or bookmark.\n")); return (1); } @@ -3943,13 +3941,6 @@ zfs_do_send(int argc, char **argv) if (zhp == NULL) return (1); - if (flags.largeblock) - lzc_flags |= LZC_SEND_FLAG_LARGE_BLOCK; - if (flags.embed_data) - lzc_flags |= LZC_SEND_FLAG_EMBED_DATA; - if (flags.compress) - lzc_flags |= LZC_SEND_FLAG_COMPRESS; - if (fromname != NULL && (fromname[0] == '#' || fromname[0] == '@')) { /* @@ -3963,7 +3954,7 @@ zfs_do_send(int argc, char **argv) (void) strlcat(frombuf, fromname, sizeof (frombuf)); fromname = frombuf; } - err = zfs_send_one(zhp, fromname, STDOUT_FILENO, lzc_flags); + err = zfs_send_one(zhp, fromname, STDOUT_FILENO, flags); zfs_close(zhp); return (err != 0); } Modified: projects/clang900-import/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h ============================================================================== --- projects/clang900-import/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h Thu Sep 19 19:25:01 2019 (r352536) +++ projects/clang900-import/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h Thu Sep 19 19:26:12 2019 (r352537) @@ -660,7 +660,7 @@ typedef boolean_t (snapfilter_cb_t)(zfs_handle_t *, vo extern int zfs_send(zfs_handle_t *, const char *, const char *, sendflags_t *, int, snapfilter_cb_t, void *, nvlist_t **); -extern int zfs_send_one(zfs_handle_t *, const char *, int, enum lzc_send_flags); +extern int zfs_send_one(zfs_handle_t *, const char *, int, sendflags_t flags); extern int zfs_send_resume(libzfs_handle_t *, sendflags_t *, int outfd, const char *); extern nvlist_t *zfs_send_resume_token_to_nvlist(libzfs_handle_t *hdl, Modified: projects/clang900-import/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c ============================================================================== --- projects/clang900-import/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c Thu Sep 19 19:25:01 2019 (r352536) +++ projects/clang900-import/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c Thu Sep 19 19:26:12 2019 (r352537) @@ -1190,16 +1190,14 @@ send_print_verbose(FILE *fout, const char *tosnap, con } } - if (size != 0) { - if (parsable) { - (void) fprintf(fout, "\t%llu", - (longlong_t)size); - } else { - char buf[16]; - zfs_nicenum(size, buf, sizeof (buf)); - (void) fprintf(fout, dgettext(TEXT_DOMAIN, - " estimated size is %s"), buf); - } + if (parsable) { + (void) fprintf(fout, "\t%llu", + (longlong_t)size); + } else if (size != 0) { + char buf[16]; + zfs_nicenum(size, buf, sizeof (buf)); + (void) fprintf(fout, dgettext(TEXT_DOMAIN, + " estimated size is %s"), buf); } (void) fprintf(fout, "\n"); } @@ -2037,17 +2035,40 @@ err_out: } int -zfs_send_one(zfs_handle_t *zhp, const char *from, int fd, - enum lzc_send_flags flags) +zfs_send_one(zfs_handle_t *zhp, const char *from, int fd, sendflags_t flags) { - int err; + int err = 0; libzfs_handle_t *hdl = zhp->zfs_hdl; - + enum lzc_send_flags lzc_flags = 0; + FILE *fout = (flags.verbose && flags.dryrun) ? stdout : stderr; char errbuf[1024]; + + if (flags.largeblock) + lzc_flags |= LZC_SEND_FLAG_LARGE_BLOCK; + if (flags.embed_data) + lzc_flags |= LZC_SEND_FLAG_EMBED_DATA; + if (flags.compress) + lzc_flags |= LZC_SEND_FLAG_COMPRESS; + + if (flags.verbose) { + uint64_t size = 0; + err = lzc_send_space(zhp->zfs_name, from, lzc_flags, &size); + if (err == 0) { + send_print_verbose(fout, zhp->zfs_name, from, size, + flags.parsable); + } else { + (void) fprintf(stderr, "Cannot estimate send size: " + "%s\n", strerror(errno)); + } + } + + if (flags.dryrun) + return (err); + (void) snprintf(errbuf, sizeof (errbuf), dgettext(TEXT_DOMAIN, "warning: cannot send '%s'"), zhp->zfs_name); - err = lzc_send(zhp->zfs_name, from, fd, flags); + err = lzc_send(zhp->zfs_name, from, fd, lzc_flags); if (err != 0) { switch (errno) { case EXDEV: Modified: projects/clang900-import/contrib/jemalloc/src/jemalloc.c ============================================================================== --- projects/clang900-import/contrib/jemalloc/src/jemalloc.c Thu Sep 19 19:25:01 2019 (r352536) +++ projects/clang900-import/contrib/jemalloc/src/jemalloc.c Thu Sep 19 19:26:12 2019 (r352537) @@ -2299,21 +2299,6 @@ je_realloc(void *ptr, size_t size) { LOG("core.realloc.entry", "ptr: %p, size: %zu\n", ptr, size); if (unlikely(size == 0)) { - if (ptr != NULL) { - /* realloc(ptr, 0) is equivalent to free(ptr). */ - UTRACE(ptr, 0, 0); - tcache_t *tcache; - tsd_t *tsd = tsd_fetch(); - if (tsd_reentrancy_level_get(tsd) == 0) { - tcache = tcache_get(tsd); - } else { - tcache = NULL; - } - ifree(tsd, ptr, tcache, true); - - LOG("core.realloc.exit", "result: %p", NULL); - return NULL; - } size = 1; } Modified: projects/clang900-import/contrib/netbsd-tests/lib/libc/sys/t_stat.c ============================================================================== --- projects/clang900-import/contrib/netbsd-tests/lib/libc/sys/t_stat.c Thu Sep 19 19:25:01 2019 (r352536) +++ projects/clang900-import/contrib/netbsd-tests/lib/libc/sys/t_stat.c Thu Sep 19 19:26:12 2019 (r352537) @@ -332,6 +332,9 @@ ATF_TC_BODY(stat_socket, tc) uint32_t iaddr; int fd, flags; + if (atf_tc_get_config_var_as_bool_wd(tc, "ci", false)) + atf_tc_skip("https://bugs.freebsd.org/240621"); + (void)memset(&st, 0, sizeof(struct stat)); (void)memset(&addr, 0, sizeof(struct sockaddr_in)); Modified: projects/clang900-import/lib/Makefile ============================================================================== --- projects/clang900-import/lib/Makefile Thu Sep 19 19:25:01 2019 (r352536) +++ projects/clang900-import/lib/Makefile Thu Sep 19 19:26:12 2019 (r352537) @@ -102,7 +102,7 @@ SUBDIR= ${SUBDIR_BOOTSTRAP} \ # libraries, those libraries should be listed as build order dependencies here. SUBDIR_DEPEND_geom= libufs -SUBDIR_DEPEND_libarchive= libz libbz2 libexpat liblzma libmd +SUBDIR_DEPEND_libarchive= libz libbz2 libexpat liblzma libmd libzstd SUBDIR_DEPEND_libauditdm= libbsm SUBDIR_DEPEND_libbsnmp= ${_libnetgraph} SUBDIR_DEPEND_libc++:= libcxxrt Modified: projects/clang900-import/lib/libarchive/Makefile ============================================================================== --- projects/clang900-import/lib/libarchive/Makefile Thu Sep 19 19:25:01 2019 (r352536) +++ projects/clang900-import/lib/libarchive/Makefile Thu Sep 19 19:26:12 2019 (r352537) @@ -6,8 +6,8 @@ _LIBARCHIVEDIR= ${SRCTOP}/contrib/libarchive LIB= archive -LIBADD= z bz2 lzma bsdxml -CFLAGS+= -DHAVE_BZLIB_H=1 -DHAVE_LIBLZMA=1 -DHAVE_LZMA_H=1 +LIBADD= z bz2 lzma bsdxml zstd +CFLAGS+= -DHAVE_BZLIB_H=1 -DHAVE_LIBLZMA=1 -DHAVE_LZMA_H=1 -DHAVE_ZSTD_H=1 -DHAVE_LIBZSTD=1 # FreeBSD SHLIB_MAJOR value is managed as part of the FreeBSD system. # It has no real relation to the libarchive version number. @@ -15,6 +15,7 @@ SHLIB_MAJOR= 7 CFLAGS+= -DPLATFORM_CONFIG_H=\"${.CURDIR}/config_freebsd.h\" CFLAGS+= -I${.OBJDIR} +CFLAGS+= -I${SRCTOP}/sys/contrib/zstd/lib .if ${MK_OPENSSL} != "no" CFLAGS+= -DWITH_OPENSSL Modified: projects/clang900-import/lib/libarchive/tests/Makefile ============================================================================== --- projects/clang900-import/lib/libarchive/tests/Makefile Thu Sep 19 19:25:01 2019 (r352536) +++ projects/clang900-import/lib/libarchive/tests/Makefile Thu Sep 19 19:26:12 2019 (r352537) @@ -305,6 +305,9 @@ BROKEN_TESTS+= test_read_disk_directory_traversals # (Times out?) [and] crashes BROKEN_TESTS+= test_fuzz_rar +# https://bugs.freebsd.org/240683 +BROKEN_TESTS+= test_write_filter_zstd + # Build the test program. SRCS.libarchive_test= \ ${TESTS_SRCS} \ @@ -517,12 +520,12 @@ ${PACKAGE}FILES+= test_read_format_rar5_blake2.rar.uu ${PACKAGE}FILES+= test_read_format_rar5_compressed.rar.uu ${PACKAGE}FILES+= test_read_format_rar5_different_window_size.rar.uu ${PACKAGE}FILES+= test_read_format_rar5_distance_overflow.rar.uu -${PACKAGE}FILES+= test_read_format_rar5_extra_field_version.rar.uu +${PACKAGE}FILES+= test_read_format_rar5_extra_field_version.rar.uu ${PACKAGE}FILES+= test_read_format_rar5_fileattr.rar.uu -${PACKAGE}FILES+= test_read_format_rar5_hardlink.rar.uu -${PACKAGE}FILES+= test_read_format_rar5_invalid_dict_reference.rar.uu -${PACKAGE}FILES+= test_read_format_rar5_leftshift1.rar.uu -${PACKAGE}FILES+= test_read_format_rar5_leftshift2.rar.uu +${PACKAGE}FILES+= test_read_format_rar5_hardlink.rar.uu +${PACKAGE}FILES+= test_read_format_rar5_invalid_dict_reference.rar.uu +${PACKAGE}FILES+= test_read_format_rar5_leftshift1.rar.uu +${PACKAGE}FILES+= test_read_format_rar5_leftshift2.rar.uu ${PACKAGE}FILES+= test_read_format_rar5_multiarchive.part01.rar.uu ${PACKAGE}FILES+= test_read_format_rar5_multiarchive.part02.rar.uu ${PACKAGE}FILES+= test_read_format_rar5_multiarchive.part03.rar.uu @@ -538,13 +541,13 @@ ${PACKAGE}FILES+= test_read_format_rar5_multiarchive_s ${PACKAGE}FILES+= test_read_format_rar5_multiple_files.rar.uu ${PACKAGE}FILES+= test_read_format_rar5_multiple_files_solid.rar.uu ${PACKAGE}FILES+= test_read_format_rar5_nonempty_dir_stream.rar.uu -${PACKAGE}FILES+= test_read_format_rar5_owner.rar.uu -${PACKAGE}FILES+= test_read_format_rar5_readtables_overflow.rar.uu +${PACKAGE}FILES+= test_read_format_rar5_owner.rar.uu +${PACKAGE}FILES+= test_read_format_rar5_readtables_overflow.rar.uu ${PACKAGE}FILES+= test_read_format_rar5_solid.rar.uu ${PACKAGE}FILES+= test_read_format_rar5_stored.rar.uu ${PACKAGE}FILES+= test_read_format_rar5_stored_manyfiles.rar.uu ${PACKAGE}FILES+= test_read_format_rar5_symlink.rar.uu -${PACKAGE}FILES+= test_read_format_rar5_truncated_huff.rar.uu +${PACKAGE}FILES+= test_read_format_rar5_truncated_huff.rar.uu ${PACKAGE}FILES+= test_read_format_rar5_win32.rar.uu ${PACKAGE}FILES+= test_read_format_raw.bufr.uu ${PACKAGE}FILES+= test_read_format_raw.data.Z.uu Modified: projects/clang900-import/lib/libbe/be.c ============================================================================== --- projects/clang900-import/lib/libbe/be.c Thu Sep 19 19:25:01 2019 (r352536) +++ projects/clang900-import/lib/libbe/be.c Thu Sep 19 19:26:12 2019 (r352537) @@ -775,6 +775,7 @@ be_export(libbe_handle_t *lbh, const char *bootenv, in char snap_name[BE_MAXPATHLEN]; char buf[BE_MAXPATHLEN]; zfs_handle_t *zfs; + sendflags_t flags = { 0 }; int err; if ((err = be_snapshot(lbh, bootenv, NULL, true, snap_name)) != 0) @@ -786,7 +787,7 @@ be_export(libbe_handle_t *lbh, const char *bootenv, in if ((zfs = zfs_open(lbh->lzh, buf, ZFS_TYPE_DATASET)) == NULL) return (set_error(lbh, BE_ERR_ZFSOPEN)); - err = zfs_send_one(zfs, NULL, fd, 0); + err = zfs_send_one(zfs, NULL, fd, flags); zfs_close(zfs); return (err); Modified: projects/clang900-import/lib/libc/gen/sysctlnametomib.c ============================================================================== --- projects/clang900-import/lib/libc/gen/sysctlnametomib.c Thu Sep 19 19:25:01 2019 (r352536) +++ projects/clang900-import/lib/libc/gen/sysctlnametomib.c Thu Sep 19 19:26:12 2019 (r352537) @@ -47,8 +47,8 @@ sysctlnametomib(const char *name, int *mibp, size_t *s int oid[2]; int error; - oid[0] = 0; - oid[1] = 3; + oid[0] = CTL_SYSCTL; + oid[1] = CTL_SYSCTL_NAME2OID; *sizep *= sizeof(int); error = sysctl(oid, 2, mibp, sizep, name, strlen(name)); Modified: projects/clang900-import/lib/libc/sys/open.2 ============================================================================== --- projects/clang900-import/lib/libc/sys/open.2 Thu Sep 19 19:25:01 2019 (r352536) +++ projects/clang900-import/lib/libc/sys/open.2 Thu Sep 19 19:26:12 2019 (r352537) @@ -28,7 +28,7 @@ .\" @(#)open.2 8.2 (Berkeley) 11/16/93 .\" $FreeBSD$ .\" -.Dd June 14, 2019 +.Dd September 17, 2019 .Dt OPEN 2 .Os .Sh NAME @@ -419,6 +419,11 @@ Too many symbolic links were encountered in translatin .It Bq Er EISDIR The named file is a directory, and the arguments specify it is to be modified. +.It Bq Er EISDIR +The named file is a directory, and the flags specified +.Dv O_CREAT +without +.Dv O_DIRECTORY . .It Bq Er EROFS The named file resides on a read-only file system, and the file is to be modified. Modified: projects/clang900-import/lib/libpmc/libpmc.c ============================================================================== --- projects/clang900-import/lib/libpmc/libpmc.c Thu Sep 19 19:25:01 2019 (r352536) +++ projects/clang900-import/lib/libpmc/libpmc.c Thu Sep 19 19:26:12 2019 (r352537) @@ -143,6 +143,7 @@ PMC_CLASSDEP_TABLE(k8, K8); PMC_CLASSDEP_TABLE(xscale, XSCALE); PMC_CLASSDEP_TABLE(armv7, ARMV7); PMC_CLASSDEP_TABLE(armv8, ARMV8); +PMC_CLASSDEP_TABLE(beri, BERI); PMC_CLASSDEP_TABLE(mips24k, MIPS24K); PMC_CLASSDEP_TABLE(mips74k, MIPS74K); PMC_CLASSDEP_TABLE(octeon, OCTEON); @@ -187,6 +188,7 @@ static const struct pmc_event_descr cortex_a57_event_t PMC_MDEP_TABLE(k8, K8, PMC_CLASS_SOFT, PMC_CLASS_TSC); PMC_MDEP_TABLE(xscale, XSCALE, PMC_CLASS_SOFT, PMC_CLASS_XSCALE); +PMC_MDEP_TABLE(beri, BERI, PMC_CLASS_SOFT, PMC_CLASS_BERI); PMC_MDEP_TABLE(cortex_a8, ARMV7, PMC_CLASS_SOFT, PMC_CLASS_ARMV7); PMC_MDEP_TABLE(cortex_a9, ARMV7, PMC_CLASS_SOFT, PMC_CLASS_ARMV7); PMC_MDEP_TABLE(cortex_a53, ARMV8, PMC_CLASS_SOFT, PMC_CLASS_ARMV8); @@ -235,6 +237,7 @@ PMC_CLASS_TABLE_DESC(cortex_a53, ARMV8, cortex_a53, ar PMC_CLASS_TABLE_DESC(cortex_a57, ARMV8, cortex_a57, arm64); #endif #if defined(__mips__) +PMC_CLASS_TABLE_DESC(beri, BERI, beri, mips); PMC_CLASS_TABLE_DESC(mips24k, MIPS24K, mips24k, mips); PMC_CLASS_TABLE_DESC(mips74k, MIPS74K, mips74k, mips); PMC_CLASS_TABLE_DESC(octeon, OCTEON, octeon, mips); @@ -829,6 +832,11 @@ arm64_allocate_pmc(enum pmc_event pe, char *ctrspec __ #if defined(__mips__) +static struct pmc_event_alias beri_aliases[] = { + EV_ALIAS("instructions", "INST"), + EV_ALIAS(NULL, NULL) +}; + static struct pmc_event_alias mips24k_aliases[] = { EV_ALIAS("instructions", "INSTR_EXECUTED"), EV_ALIAS("branches", "BRANCH_COMPLETED"), @@ -1267,6 +1275,10 @@ pmc_event_names_of_class(enum pmc_class cl, const char break; } break; + case PMC_CLASS_BERI: + ev = beri_event_table; + count = PMC_EVENT_TABLE_SIZE(beri); + break; case PMC_CLASS_MIPS24K: ev = mips24k_event_table; count = PMC_EVENT_TABLE_SIZE(mips24k); @@ -1508,6 +1520,10 @@ pmc_init(void) break; #endif #if defined(__mips__) + case PMC_CPU_MIPS_BERI: + PMC_MDEP_INIT(beri); + pmc_class_table[n] = &beri_class_table_descr; + break; case PMC_CPU_MIPS_24K: PMC_MDEP_INIT(mips24k); pmc_class_table[n] = &mips24k_class_table_descr; @@ -1645,6 +1661,9 @@ _pmc_name_of_event(enum pmc_event pe, enum pmc_cputype default: /* Unknown CPU type. */ break; } + } else if (pe >= PMC_EV_BERI_FIRST && pe <= PMC_EV_BERI_LAST) { + ev = beri_event_table; + evfence = beri_event_table + PMC_EVENT_TABLE_SIZE(beri); } else if (pe >= PMC_EV_MIPS24K_FIRST && pe <= PMC_EV_MIPS24K_LAST) { ev = mips24k_event_table; evfence = mips24k_event_table + PMC_EVENT_TABLE_SIZE(mips24k); Modified: projects/clang900-import/sbin/ifconfig/ifmedia.c ============================================================================== --- projects/clang900-import/sbin/ifconfig/ifmedia.c Thu Sep 19 19:25:01 2019 (r352536) +++ projects/clang900-import/sbin/ifconfig/ifmedia.c Thu Sep 19 19:26:12 2019 (r352537) @@ -80,6 +80,7 @@ #include #include #include +#include #include #include #include @@ -110,18 +111,20 @@ static void media_status(int s) { struct ifmediareq ifmr; + struct ifdownreason ifdr; int *media_list, i; - int xmedia = 1; + bool no_carrier, xmedia; (void) memset(&ifmr, 0, sizeof(ifmr)); (void) strlcpy(ifmr.ifm_name, name, sizeof(ifmr.ifm_name)); + xmedia = true; /* * Check if interface supports extended media types. */ if (ioctl(s, SIOCGIFXMEDIA, (caddr_t)&ifmr) < 0) - xmedia = 0; - if (xmedia == 0 && ioctl(s, SIOCGIFMEDIA, (caddr_t)&ifmr) < 0) { + xmedia = false; + if (!xmedia && ioctl(s, SIOCGIFMEDIA, (caddr_t)&ifmr) < 0) { /* * Interface doesn't support SIOC{G,S}IFMEDIA. */ @@ -158,6 +161,7 @@ media_status(int s) putchar('\n'); if (ifmr.ifm_status & IFM_AVALID) { + no_carrier = false; printf("\tstatus: "); switch (IFM_TYPE(ifmr.ifm_active)) { case IFM_ETHER: @@ -165,7 +169,7 @@ media_status(int s) if (ifmr.ifm_status & IFM_ACTIVE) printf("active"); else - printf("no carrier"); + no_carrier = true; break; case IFM_IEEE80211: @@ -176,8 +180,26 @@ media_status(int s) else printf("running"); } else - printf("no carrier"); + no_carrier = true; break; + } + if (no_carrier) { + printf("no carrier"); + memset(&ifdr, 0, sizeof(ifdr)); + strlcpy(ifdr.ifdr_name, name, sizeof(ifdr.ifdr_name)); + if (ioctl(s, SIOCGIFDOWNREASON, (caddr_t)&ifdr) == 0) { + switch (ifdr.ifdr_reason) { + case IFDR_REASON_MSG: + printf(" (%s)", ifdr.ifdr_msg); + break; + case IFDR_REASON_VENDOR: + printf(" (vendor code %d)", + ifdr.ifdr_vendor); + break; + default: + break; + } + } } putchar('\n'); } Modified: projects/clang900-import/share/man/man5/src.conf.5 ============================================================================== --- projects/clang900-import/share/man/man5/src.conf.5 Thu Sep 19 19:25:01 2019 (r352536) +++ projects/clang900-import/share/man/man5/src.conf.5 Thu Sep 19 19:26:12 2019 (r352537) @@ -1,6 +1,6 @@ .\" DO NOT EDIT-- this file is @generated by tools/build/options/makeman. .\" $FreeBSD$ -.Dd August 16, 2019 +.Dd September 17, 2019 .Dt SRC.CONF 5 .Os .Sh NAME @@ -831,6 +831,17 @@ Set to neither build nor install .Lb libgmock , .Lb libgtest , and dependent tests. +.Pp +This is a default setting on +mips/mipsel, mips/mips, mips/mips64el, mips/mips64, mips/mipsn32, mips/mipselhf, mips/mipshf, mips/mips64elhf and mips/mips64hf. +.It Va WITH_GOOGLETEST +Set to build and install +.Lb libgmock , +.Lb libgtest , +and dependent tests. +.Pp +This is a default setting on +amd64/amd64, arm/arm, arm/armv6, arm/armv7, arm64/aarch64, i386/i386, powerpc/powerpc, powerpc/powerpc64, powerpc/powerpcspe, riscv/riscv64 and sparc64/sparc64. .It Va WITHOUT_GPIO Set to not build .Xr gpioctl 8 Modified: projects/clang900-import/share/mk/src.libnames.mk ============================================================================== --- projects/clang900-import/share/mk/src.libnames.mk Thu Sep 19 19:25:01 2019 (r352536) +++ projects/clang900-import/share/mk/src.libnames.mk Thu Sep 19 19:26:12 2019 (r352537) @@ -230,7 +230,7 @@ LIBVERIEXEC?= ${LIBVERIEXECDIR}/libveriexec${PIE_SUFFI # Each library's LIBADD needs to be duplicated here for static linkage of # 2nd+ order consumers. Auto-generating this would be better. _DP_80211= sbuf bsdxml -_DP_archive= z bz2 lzma bsdxml +_DP_archive= z bz2 lzma bsdxml zstd _DP_zstd= pthread .if ${MK_BLACKLIST} != "no" _DP_blacklist+= pthread Modified: projects/clang900-import/share/mk/src.opts.mk ============================================================================== --- projects/clang900-import/share/mk/src.opts.mk Thu Sep 19 19:25:01 2019 (r352536) +++ projects/clang900-import/share/mk/src.opts.mk Thu Sep 19 19:26:12 2019 (r352537) @@ -108,7 +108,6 @@ __DEFAULT_YES_OPTIONS = \ GDB \ GNU_DIFF \ GNU_GREP \ - GOOGLETEST \ GPIO \ HAST \ HTML \ @@ -258,6 +257,15 @@ __T=${MACHINE_ARCH} __TT=${TARGET} .else __TT=${MACHINE} +.endif + +# Default GOOGLETEST to off for MIPS while LLVM PR 43263 is active. Part +# of the fusefs tests trigger excessively long compile times. It does +# eventually succeed, but this shouldn't be forced on those building by default. +.if ${__TT} == "mips" +__DEFAULT_NO_OPTIONS+= GOOGLETEST +.else +__DEFAULT_YES_OPTIONS+= GOOGLETEST .endif # All supported backends for LLVM_TARGET_XXX Modified: projects/clang900-import/stand/efi/libefi/efipart.c ============================================================================== --- projects/clang900-import/stand/efi/libefi/efipart.c Thu Sep 19 19:25:01 2019 (r352536) +++ projects/clang900-import/stand/efi/libefi/efipart.c Thu Sep 19 19:26:12 2019 (r352537) @@ -64,6 +64,9 @@ static int efipart_printhd(int); #define PNP0700 0x700 #define PNP0701 0x701 +/* Bounce buffer max size */ +#define BIO_BUFFER_SIZE 0x4000 + struct devsw efipart_fddev = { .dv_name = "fd", .dv_type = DEVT_FD, @@ -266,6 +269,12 @@ efipart_inithandles(void) continue; } + /* Allowed values are 0, 1 and power of 2. */ + if (blkio->Media->IoAlign > 1 && + !powerof2(blkio->Media->IoAlign)) { + continue; + } + /* This is bad. */ if ((pd = calloc(1, sizeof(*pd))) == NULL) { printf("efipart_inithandles: Out of memory.\n"); @@ -979,8 +988,10 @@ efipart_realstrategy(void *devdata, int rw, daddr_t bl EFI_BLOCK_IO *blkio; uint64_t off, disk_blocks, d_offset = 0; char *blkbuf; - size_t blkoff, blksz; - int error; + size_t blkoff, blksz, bio_size; + unsigned ioalign; + bool need_buf; + int rc; uint64_t diskend, readstart; if (dev == NULL || blk < 0) @@ -1028,40 +1039,118 @@ efipart_realstrategy(void *devdata, int rw, daddr_t bl size = size * blkio->Media->BlockSize; } - if (rsize != NULL) - *rsize = size; - + need_buf = true; + /* Do we need bounce buffer? */ if ((size % blkio->Media->BlockSize == 0) && (off % blkio->Media->BlockSize == 0)) - return (efipart_readwrite(blkio, rw, - off / blkio->Media->BlockSize, - size / blkio->Media->BlockSize, buf)); + need_buf = false; - /* - * The buffer size is not a multiple of the media block size. - */ - blkbuf = malloc(blkio->Media->BlockSize); + /* Do we have IO alignment requirement? */ + ioalign = blkio->Media->IoAlign; + if (ioalign == 0) + ioalign++; + + if (ioalign > 1 && (uintptr_t)buf != roundup2((uintptr_t)buf, ioalign)) + need_buf = true; + + if (need_buf) { + for (bio_size = BIO_BUFFER_SIZE; bio_size > 0; + bio_size -= blkio->Media->BlockSize) { + blkbuf = memalign(ioalign, bio_size); + if (blkbuf != NULL) + break; + } + } else { + blkbuf = buf; + bio_size = size; + } + if (blkbuf == NULL) return (ENOMEM); - error = 0; + if (rsize != NULL) + *rsize = size; + + rc = 0; blk = off / blkio->Media->BlockSize; blkoff = off % blkio->Media->BlockSize; - blksz = blkio->Media->BlockSize - blkoff; + while (size > 0) { - error = efipart_readwrite(blkio, rw, blk, 1, blkbuf); - if (error) + size_t x = min(size, bio_size); + + if (x < blkio->Media->BlockSize) + x = 1; + else + x /= blkio->Media->BlockSize; + + switch (rw & F_MASK) { + case F_READ: + blksz = blkio->Media->BlockSize * x - blkoff; + if (size < blksz) + blksz = size; + + rc = efipart_readwrite(blkio, rw, blk, x, blkbuf); + if (rc != 0) + goto error; + + if (need_buf) + bcopy(blkbuf + blkoff, buf, blksz); break; - if (size < blksz) - blksz = size; - bcopy(blkbuf + blkoff, buf, blksz); + case F_WRITE: + rc = 0; + if (blkoff != 0) { + /* + * We got offset to sector, read 1 sector to + * blkbuf. + */ + x = 1; + blksz = blkio->Media->BlockSize - blkoff; + blksz = min(blksz, size); + rc = efipart_readwrite(blkio, F_READ, blk, x, + blkbuf); + } else if (size < blkio->Media->BlockSize) { + /* + * The remaining block is not full + * sector. Read 1 sector to blkbuf. + */ + x = 1; + blksz = size; + rc = efipart_readwrite(blkio, F_READ, blk, x, + blkbuf); + } else { + /* We can write full sector(s). */ + blksz = blkio->Media->BlockSize * x; + } + + if (rc != 0) + goto error; + /* + * Put your Data In, Put your Data out, + * Put your Data In, and shake it all about + */ + if (need_buf) + bcopy(buf, blkbuf + blkoff, blksz); + rc = efipart_readwrite(blkio, F_WRITE, blk, x, blkbuf); + if (rc != 0) + goto error; + break; + default: + /* DO NOTHING */ + rc = EROFS; + goto error; + } + + blkoff = 0; buf += blksz; size -= blksz; - blk++; - blkoff = 0; - blksz = blkio->Media->BlockSize; + blk += x; } - free(blkbuf); - return (error); +error: + if (rsize != NULL) + *rsize -= size; + + if (need_buf) + free(blkbuf); + return (rc); } Modified: projects/clang900-import/stand/forth/loader.4th ============================================================================== --- projects/clang900-import/stand/forth/loader.4th Thu Sep 19 19:25:01 2019 (r352536) +++ projects/clang900-import/stand/forth/loader.4th Thu Sep 19 19:26:12 2019 (r352537) @@ -27,6 +27,29 @@ only forth definitions +\ provide u> if needed +s" u>" sfind [if] drop [else] + drop +: u> + 2dup u< if 2drop 0 exit then + swap u< if -1 exit then + 0 +; +[then] + +\ provide xemit if needed +s" xemit" sfind [if] drop [else] + drop +: xemit + dup 0x80 u< if emit exit then + 0 swap 0x3F + begin 2dup u> while + 2/ >r dup 0x3F and 0x80 or swap 6 rshift r> + repeat 0x7F xor 2* or + begin dup 0x80 u< 0= while emit repeat drop +; +[then] + s" arch-i386" environment? [if] [if] s" loader_version" environment? [if] 11 < [if] Modified: projects/clang900-import/stand/libsa/stand.h ============================================================================== --- projects/clang900-import/stand/libsa/stand.h Thu Sep 19 19:25:01 2019 (r352536) +++ projects/clang900-import/stand/libsa/stand.h Thu Sep 19 19:26:12 2019 (r352537) @@ -264,9 +264,6 @@ static __inline int tolower(int c) extern void setheap(void *base, void *top); extern char *sbrk(int incr); -extern void *reallocf(void *ptr, size_t size); -extern void mallocstats(void); - extern int printf(const char *fmt, ...) __printflike(1, 2); extern int asprintf(char **buf, const char *cfmt, ...) __printflike(2, 3); extern int sprintf(char *buf, const char *cfmt, ...) __printflike(2, 3); @@ -430,20 +427,27 @@ extern uint16_t ntohs(uint16_t); #endif void *Malloc(size_t, const char *, int); +void *Memalign(size_t, size_t, const char *, int); void *Calloc(size_t, size_t, const char *, int); void *Realloc(void *, size_t, const char *, int); +void *Reallocf(void *, size_t, const char *, int); void Free(void *, const char *, int); +extern void mallocstats(void); #ifdef DEBUG_MALLOC #define malloc(x) Malloc(x, __FILE__, __LINE__) +#define memalign(x, y) Memalign(x, y, __FILE__, __LINE__) #define calloc(x, y) Calloc(x, y, __FILE__, __LINE__) #define free(x) Free(x, __FILE__, __LINE__) #define realloc(x, y) Realloc(x, y, __FILE__, __LINE__) +#define reallocf(x, y) Reallocf(x, y, __FILE__, __LINE__) #else #define malloc(x) Malloc(x, NULL, 0) +#define memalign(x, y) Memalign(x, y, NULL, 0) #define calloc(x, y) Calloc(x, y, NULL, 0) #define free(x) Free(x, NULL, 0) #define realloc(x, y) Realloc(x, y, NULL, 0) +#define reallocf(x, y) Reallocf(x, y, NULL, 0) #endif #endif /* STAND_H */ Modified: projects/clang900-import/stand/libsa/zalloc.c ============================================================================== --- projects/clang900-import/stand/libsa/zalloc.c Thu Sep 19 19:25:01 2019 (r352536) +++ projects/clang900-import/stand/libsa/zalloc.c Thu Sep 19 19:26:12 2019 (r352537) @@ -1,5 +1,5 @@ /* - * This module derived from code donated to the FreeBSD Project by + * This module derived from code donated to the FreeBSD Project by * Matthew Dillon * * Copyright (c) 1998 The FreeBSD Project @@ -30,11 +30,13 @@ #include __FBSDID("$FreeBSD$"); +#include + /* - * LIB/MEMORY/ZALLOC.C - self contained low-overhead memory pool/allocation + * LIB/MEMORY/ZALLOC.C - self contained low-overhead memory pool/allocation * subsystem * - * This subsystem implements memory pools and memory allocation + * This subsystem implements memory pools and memory allocation * routines. * * Pools are managed via a linked list of 'free' areas. Allocating @@ -43,7 +45,7 @@ __FBSDID("$FreeBSD$"); * to allocate the entire pool without incuring any structural overhead. * * The system works best when allocating similarly-sized chunks of - * memory. Care must be taken to avoid fragmentation when + * memory. Care must be taken to avoid fragmentation when * allocating/deallocating dissimilar chunks. * * When a memory pool is first allocated, the entire pool is marked as @@ -53,7 +55,7 @@ __FBSDID("$FreeBSD$"); * available. * * z[n]xalloc() works like z[n]alloc() but the allocation is made from - * within the specified address range. If the segment could not be + * within the specified address range. If the segment could not be * allocated, NULL is returned. WARNING! The address range will be * aligned to an 8 or 16 byte boundry depending on the cpu so if you * give an unaligned address range, unexpected results may occur. @@ -86,58 +88,82 @@ typedef char assert_align[(sizeof(struct MemNode) <= M */ void * -znalloc(MemPool *mp, uintptr_t bytes) +znalloc(MemPool *mp, uintptr_t bytes, size_t align) { - /* - * align according to pool object size (can be 0). This is - * inclusive of the MEMNODE_SIZE_MASK minimum alignment. - * - */ - bytes = (bytes + MEMNODE_SIZE_MASK) & ~MEMNODE_SIZE_MASK; - - if (bytes == 0) - return((void *)-1); - - /* - * locate freelist entry big enough to hold the object. If all objects - * are the same size, this is a constant-time function. - */ - - if (bytes <= mp->mp_Size - mp->mp_Used) { MemNode **pmn; MemNode *mn; - for (pmn = &mp->mp_First; (mn=*pmn) != NULL; pmn = &mn->mr_Next) { - if (bytes > mn->mr_Bytes) - continue; + /* + * align according to pool object size (can be 0). This is + * inclusive of the MEMNODE_SIZE_MASK minimum alignment. + * + */ + bytes = (bytes + MEMNODE_SIZE_MASK) & ~MEMNODE_SIZE_MASK; - /* - * Cut a chunk of memory out of the beginning of this - * block and fixup the link appropriately. - */ + if (bytes == 0) + return ((void *)-1); - { + /* + * locate freelist entry big enough to hold the object. If all objects + * are the same size, this is a constant-time function. + */ + + if (bytes > mp->mp_Size - mp->mp_Used) + return (NULL); + + for (pmn = &mp->mp_First; (mn = *pmn) != NULL; pmn = &mn->mr_Next) { char *ptr = (char *)mn; + uintptr_t dptr; + char *aligned; + size_t extra; + dptr = (uintptr_t)(ptr + MALLOCALIGN); /* pointer to data */ + aligned = (char *)(roundup2(dptr, align) - MALLOCALIGN); + extra = aligned - ptr; + + if (bytes + extra > mn->mr_Bytes) + continue; + + /* + * Cut extra from head and create new memory node from reminder. + */ + + if (extra != 0) { + MemNode *new; + + new = (MemNode *)aligned; + new->mr_Next = mn->mr_Next; + new->mr_Bytes = mn->mr_Bytes - extra; + + /* And update current memory node */ + mn->mr_Bytes = extra; + mn->mr_Next = new; + /* In next iteration, we will get our aligned address */ + continue; + } + + /* + * Cut a chunk of memory out of the beginning of this + * block and fixup the link appropriately. + */ + if (mn->mr_Bytes == bytes) { - *pmn = mn->mr_Next; + *pmn = mn->mr_Next; } else { - mn = (MemNode *)((char *)mn + bytes); - mn->mr_Next = ((MemNode *)ptr)->mr_Next; - mn->mr_Bytes = ((MemNode *)ptr)->mr_Bytes - bytes; - *pmn = mn; + mn = (MemNode *)((char *)mn + bytes); + mn->mr_Next = ((MemNode *)ptr)->mr_Next; + mn->mr_Bytes = ((MemNode *)ptr)->mr_Bytes - bytes; + *pmn = mn; } mp->mp_Used += bytes; return(ptr); - } } - } - /* - * Memory pool is full, return NULL. - */ + /* + * Memory pool is full, return NULL. + */ *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***