From owner-svn-src-projects@FreeBSD.ORG Fri May 9 07:07:42 2014 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 16402B79; Fri, 9 May 2014 07:07:42 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 00847F24; Fri, 9 May 2014 07:07:42 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s4977fhW092678; Fri, 9 May 2014 07:07:41 GMT (envelope-from markm@svn.freebsd.org) Received: (from markm@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s4977cbw092654; Fri, 9 May 2014 07:07:38 GMT (envelope-from markm@svn.freebsd.org) Message-Id: <201405090707.s4977cbw092654@svn.freebsd.org> From: Mark Murray Date: Fri, 9 May 2014 07:07:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r265743 - in projects/random_number_generator: . bin/dd bin/sh/tests/builtins cddl/compat/opensolaris/include cddl/compat/opensolaris/misc cddl/contrib/opensolaris/lib/libdtrace/common ... X-SVN-Group: projects 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.18 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: Fri, 09 May 2014 07:07:42 -0000 Author: markm Date: Fri May 9 07:07:38 2014 New Revision: 265743 URL: http://svnweb.freebsd.org/changeset/base/265743 Log: MFC - tracking commit. Merging r265457 through r265740. Added: projects/random_number_generator/bin/sh/tests/builtins/getopts3.0 - copied unchanged from r265740, head/bin/sh/tests/builtins/getopts3.0 projects/random_number_generator/bin/sh/tests/builtins/getopts4.0 - copied unchanged from r265740, head/bin/sh/tests/builtins/getopts4.0 projects/random_number_generator/bin/sh/tests/builtins/getopts5.0 - copied unchanged from r265740, head/bin/sh/tests/builtins/getopts5.0 projects/random_number_generator/cddl/compat/opensolaris/misc/thread_pool.c - copied unchanged from r265740, head/cddl/compat/opensolaris/misc/thread_pool.c projects/random_number_generator/cddl/compat/opensolaris/misc/thread_pool_impl.h - copied unchanged from r265740, head/cddl/compat/opensolaris/misc/thread_pool_impl.h projects/random_number_generator/release/doc/share/xml/sponsor.ent - copied unchanged from r265740, head/release/doc/share/xml/sponsor.ent projects/random_number_generator/release/doc/share/xml/vendor.ent - copied unchanged from r265740, head/release/doc/share/xml/vendor.ent projects/random_number_generator/share/man/man4/mrsas.4 - copied unchanged from r265740, head/share/man/man4/mrsas.4 projects/random_number_generator/sys/arm/mv/armadaxp/mptramp.S - copied unchanged from r265740, head/sys/arm/mv/armadaxp/mptramp.S projects/random_number_generator/sys/arm/rockchip/rk30xx_mp.c - copied unchanged from r265740, head/sys/arm/rockchip/rk30xx_mp.c projects/random_number_generator/sys/dev/mrsas/ - copied from r265740, head/sys/dev/mrsas/ projects/random_number_generator/sys/modules/mrsas/ - copied from r265740, head/sys/modules/mrsas/ Modified: projects/random_number_generator/ObsoleteFiles.inc projects/random_number_generator/UPDATING projects/random_number_generator/bin/dd/dd.c projects/random_number_generator/bin/dd/dd.h projects/random_number_generator/bin/dd/misc.c projects/random_number_generator/bin/sh/tests/builtins/Makefile projects/random_number_generator/cddl/compat/opensolaris/include/thread_pool.h projects/random_number_generator/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c projects/random_number_generator/cddl/lib/libzfs/Makefile projects/random_number_generator/contrib/llvm/tools/clang/include/clang/Driver/Options.td projects/random_number_generator/contrib/llvm/tools/clang/include/clang/Frontend/CodeGenOptions.h projects/random_number_generator/contrib/llvm/tools/clang/lib/CodeGen/CGDebugInfo.cpp projects/random_number_generator/contrib/llvm/tools/clang/lib/Driver/Tools.cpp projects/random_number_generator/contrib/llvm/tools/clang/lib/Frontend/CompilerInvocation.cpp projects/random_number_generator/contrib/ntp/ntpd/ntp_request.c projects/random_number_generator/etc/defaults/rc.conf projects/random_number_generator/gnu/usr.bin/groff/tmac/mdoc.local projects/random_number_generator/lib/libc/sys/msync.2 projects/random_number_generator/lib/libmagic/Makefile projects/random_number_generator/lib/librtld_db/librtld_db.3 projects/random_number_generator/lib/librtld_db/rtld_db.c projects/random_number_generator/lib/librtld_db/rtld_db.h projects/random_number_generator/libexec/rtld-elf/Symbol.map projects/random_number_generator/libexec/rtld-elf/rtld.c projects/random_number_generator/release/doc/en_US.ISO8859-1/hardware/article.xml projects/random_number_generator/release/doc/en_US.ISO8859-1/relnotes/article.xml projects/random_number_generator/release/doc/share/xml/catalog.xml projects/random_number_generator/release/doc/share/xml/release.xsl projects/random_number_generator/sbin/gvinum/gvinum.c projects/random_number_generator/sbin/route/route.c projects/random_number_generator/share/man/man4/Makefile projects/random_number_generator/share/man/man4/bce.4 projects/random_number_generator/share/man/man4/bxe.4 projects/random_number_generator/share/mk/Makefile projects/random_number_generator/share/mk/bsd.compiler.mk projects/random_number_generator/share/mk/bsd.mkopt.mk projects/random_number_generator/share/mk/bsd.opts.mk projects/random_number_generator/share/mk/bsd.prog.mk projects/random_number_generator/share/mk/src.opts.mk projects/random_number_generator/sys/arm/arm/locore.S projects/random_number_generator/sys/arm/conf/RADXA projects/random_number_generator/sys/arm/mv/armadaxp/files.armadaxp projects/random_number_generator/sys/arm/rockchip/files.rk30xx projects/random_number_generator/sys/arm/rockchip/rk30xx_machdep.c projects/random_number_generator/sys/arm/xilinx/zy7_devcfg.c projects/random_number_generator/sys/boot/fdt/dts/arm/rk3188.dtsi projects/random_number_generator/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c projects/random_number_generator/sys/conf/files projects/random_number_generator/sys/dev/ath/if_ath_rx.c projects/random_number_generator/sys/dev/ath/if_ath_tdma.c projects/random_number_generator/sys/dev/bce/if_bce.c projects/random_number_generator/sys/dev/bce/if_bcefw.h projects/random_number_generator/sys/dev/bce/if_bcereg.h projects/random_number_generator/sys/dev/bxe/bxe.c projects/random_number_generator/sys/dev/mpr/mpr.c projects/random_number_generator/sys/dev/mpr/mpr_sas.c projects/random_number_generator/sys/dev/mpr/mpr_sas_lsi.c projects/random_number_generator/sys/dev/mpr/mpr_user.c projects/random_number_generator/sys/dev/mps/mps_sas.c projects/random_number_generator/sys/dev/vt/hw/fb/vt_early_fb.c projects/random_number_generator/sys/dev/vt/vt.h projects/random_number_generator/sys/dev/vt/vt_buf.c projects/random_number_generator/sys/dev/vt/vt_consolectl.c projects/random_number_generator/sys/dev/vt/vt_core.c projects/random_number_generator/sys/dev/vt/vt_sysmouse.c projects/random_number_generator/sys/geom/part/g_part_mbr.c projects/random_number_generator/sys/geom/part/g_part_pc98.c projects/random_number_generator/sys/geom/part/g_part_vtoc8.c projects/random_number_generator/sys/modules/Makefile projects/random_number_generator/sys/modules/bce/Makefile projects/random_number_generator/sys/net/rtsock.c projects/random_number_generator/sys/netinet/ip_output.c projects/random_number_generator/sys/ufs/ffs/ffs_softdep.c projects/random_number_generator/sys/vm/vm_mmap.c projects/random_number_generator/usr.bin/elfdump/elfdump.c projects/random_number_generator/usr.bin/mkimg/apm.c projects/random_number_generator/usr.bin/mkimg/bsd.c projects/random_number_generator/usr.bin/mkimg/ebr.c projects/random_number_generator/usr.bin/mkimg/gpt.c projects/random_number_generator/usr.bin/mkimg/mbr.c projects/random_number_generator/usr.bin/mkimg/mkimg.c (contents, props changed) projects/random_number_generator/usr.bin/mkimg/mkimg.h projects/random_number_generator/usr.bin/mkimg/pc98.c projects/random_number_generator/usr.bin/mkimg/vtoc8.c projects/random_number_generator/usr.bin/printf/printf.c projects/random_number_generator/usr.bin/stat/stat.1 projects/random_number_generator/usr.bin/stat/stat.c Directory Properties: projects/random_number_generator/ (props changed) projects/random_number_generator/cddl/ (props changed) projects/random_number_generator/cddl/contrib/opensolaris/ (props changed) projects/random_number_generator/contrib/llvm/ (props changed) projects/random_number_generator/contrib/llvm/tools/clang/ (props changed) projects/random_number_generator/contrib/ntp/ (props changed) projects/random_number_generator/etc/ (props changed) projects/random_number_generator/lib/libc/ (props changed) projects/random_number_generator/sbin/ (props changed) projects/random_number_generator/share/man/man4/ (props changed) projects/random_number_generator/sys/ (props changed) projects/random_number_generator/sys/boot/ (props changed) projects/random_number_generator/sys/cddl/contrib/opensolaris/ (props changed) projects/random_number_generator/sys/conf/ (props changed) Modified: projects/random_number_generator/ObsoleteFiles.inc ============================================================================== --- projects/random_number_generator/ObsoleteFiles.inc Fri May 9 07:07:25 2014 (r265742) +++ projects/random_number_generator/ObsoleteFiles.inc Fri May 9 07:07:38 2014 (r265743) @@ -38,6 +38,8 @@ # xargs -n1 | sort | uniq -d; # done +# 20140505: Bogusly installing src.opts.mk +OLD_FILES+=usr/share/mk/src.opts.mk # 20140505: Reject PR kern/187551 OLD_DIRS+=usr/tests/sbin/ifconfig OLD_FILES+=usr/tests/sbin/ifconfig/Kyuafile Modified: projects/random_number_generator/UPDATING ============================================================================== --- projects/random_number_generator/UPDATING Fri May 9 07:07:25 2014 (r265742) +++ projects/random_number_generator/UPDATING Fri May 9 07:07:38 2014 (r265743) @@ -31,6 +31,11 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 11 disable the most expensive debugging functionality run "ln -s 'abort:false,junk:false' /etc/malloc.conf".) +20140508: + We bogusly installed src.opts.mk in /usr/share/mk. This file should + be removed to avoid issues in the future (and has been added to + ObsoleteFiles.inc). + 20140505: /etc/src.conf now affects only builds of the FreeBSD src tree. In the past, it affected all builds that used the bsd.*.mk files. The old @@ -44,6 +49,11 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 11 temporary breakage was fixed with MAKESYSPATH settings for buildworld as well... + One side effect of all this cleaning up is that bsd.compiler.mk + is no longer implicitly included by bsd.own.mk. If you wish to + use COMPILER_TYPE, you must now explicitly include bsd.compiler.mk + as well. + 20140430: The lindev device has been removed since /dev/full has been made a standard device. __FreeBSD_version has been bumped. Modified: projects/random_number_generator/bin/dd/dd.c ============================================================================== --- projects/random_number_generator/bin/dd/dd.c Fri May 9 07:07:25 2014 (r265742) +++ projects/random_number_generator/bin/dd/dd.c Fri May 9 07:07:38 2014 (r265743) @@ -50,8 +50,8 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include +#include #include #include #include @@ -61,6 +61,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include "dd.h" @@ -76,6 +77,7 @@ STAT st; /* statistics */ void (*cfunc)(void); /* conversion function */ uintmax_t cpy_cnt; /* # of blocks to copy */ static off_t pending = 0; /* pending seek if sparse */ +static off_t last_sp = 0; /* size of last added sparse block */ u_int ddflags = 0; /* conversion options */ size_t cbsz; /* conversion block size */ uintmax_t files_cnt = 1; /* # of files to copy */ @@ -123,7 +125,6 @@ static void setup(void) { u_int cnt; - struct timeval tv; if (in.name == NULL) { in.name = "stdin"; @@ -173,6 +174,8 @@ setup(void) } else if ((in.db = malloc(MAX(in.dbsz, cbsz) + cbsz)) == NULL || (out.db = malloc(out.dbsz + cbsz)) == NULL) err(1, "output buffer"); + + /* dbp is the first free position in each buffer. */ in.dbp = in.db; out.dbp = out.db; @@ -240,8 +243,8 @@ setup(void) ctab = casetab; } - (void)gettimeofday(&tv, NULL); - st.start = tv.tv_sec + tv.tv_usec * 1e-6; + if (clock_gettime(CLOCK_MONOTONIC, &st.start)) + err(1, "clock_gettime"); } static void @@ -434,8 +437,15 @@ dd_out(int force) * we play games with the buffer size, and it's usually a partial write. */ outp = out.db; + + /* + * If force, first try to write all pending data, else try to write + * just one block. Subsequently always write data one full block at + * a time at most. + */ for (n = force ? out.dbcnt : out.dbsz;; n = out.dbsz) { - for (cnt = n;; cnt -= nw) { + cnt = n; + do { sparse = 0; if (ddflags & C_SPARSE) { sparse = 1; /* Is buffer sparse? */ @@ -447,18 +457,24 @@ dd_out(int force) } if (sparse && !force) { pending += cnt; + last_sp = cnt; nw = cnt; } else { if (pending != 0) { - if (force) - pending--; + /* If forced to write, and we have no + * data left, we need to write the last + * sparse block explicitly. + */ + if (force && cnt == 0) { + pending -= last_sp; + assert(outp == out.db); + memset(outp, 0, cnt); + } if (lseek(out.fd, pending, SEEK_CUR) == -1) err(2, "%s: seek error creating sparse file", out.name); - if (force) - write(out.fd, outp, 1); - pending = 0; + pending = last_sp = 0; } if (cnt) nw = write(out.fd, outp, cnt); @@ -473,27 +489,29 @@ dd_out(int force) err(1, "%s", out.name); nw = 0; } + outp += nw; st.bytes += nw; - if ((size_t)nw == n) { - if (n != out.dbsz) - ++st.out_part; - else - ++st.out_full; - break; - } - ++st.out_part; - if ((size_t)nw == cnt) - break; - if (out.flags & ISTAPE) - errx(1, "%s: short write on tape device", - out.name); - if (out.flags & ISCHR && !warned) { - warned = 1; - warnx("%s: short write on character device", - out.name); + + if ((size_t)nw == n && n == out.dbsz) + ++st.out_full; + else + ++st.out_part; + + if ((size_t) nw != cnt) { + if (out.flags & ISTAPE) + errx(1, "%s: short write on tape device", + out.name); + if (out.flags & ISCHR && !warned) { + warned = 1; + warnx("%s: short write on character device", + out.name); + } } - } + + cnt -= nw; + } while (cnt != 0); + if ((out.dbcnt -= n) < out.dbsz) break; } Modified: projects/random_number_generator/bin/dd/dd.h ============================================================================== --- projects/random_number_generator/bin/dd/dd.h Fri May 9 07:07:25 2014 (r265742) +++ projects/random_number_generator/bin/dd/dd.h Fri May 9 07:07:38 2014 (r265743) @@ -64,7 +64,7 @@ typedef struct { uintmax_t trunc; /* # of truncated records */ uintmax_t swab; /* # of odd-length swab blocks */ uintmax_t bytes; /* # of bytes written */ - double start; /* start time of dd */ + struct timespec start; /* start time of dd */ } STAT; /* Flags (in ddflags). */ Modified: projects/random_number_generator/bin/dd/misc.c ============================================================================== --- projects/random_number_generator/bin/dd/misc.c Fri May 9 07:07:25 2014 (r265742) +++ projects/random_number_generator/bin/dd/misc.c Fri May 9 07:07:38 2014 (r265743) @@ -40,14 +40,15 @@ static char sccsid[] = "@(#)misc.c 8.3 ( __FBSDID("$FreeBSD$"); #include -#include +#include #include #include #include #include #include #include +#include #include #include "dd.h" @@ -56,16 +57,21 @@ __FBSDID("$FreeBSD$"); void summary(void) { - struct timeval tv; - double secs; + struct timespec end, ts_res; + double secs, res; if (ddflags & C_NOINFO) return; - (void)gettimeofday(&tv, NULL); - secs = tv.tv_sec + tv.tv_usec * 1e-6 - st.start; - if (secs < 1e-6) - secs = 1e-6; + if (clock_gettime(CLOCK_MONOTONIC, &end)) + err(1, "clock_gettime"); + if (clock_getres(CLOCK_MONOTONIC, &ts_res)) + err(1, "clock_getres"); + secs = (end.tv_sec - st.start.tv_sec) + \ + (end.tv_nsec - st.start.tv_nsec) * 1e-9; + res = ts_res.tv_sec + ts_res.tv_nsec * 1e-9; + if (secs < res) + secs = res; (void)fprintf(stderr, "%ju+%ju records in\n%ju+%ju records out\n", st.in_full, st.in_part, st.out_full, st.out_part); Modified: projects/random_number_generator/bin/sh/tests/builtins/Makefile ============================================================================== --- projects/random_number_generator/bin/sh/tests/builtins/Makefile Fri May 9 07:07:25 2014 (r265742) +++ projects/random_number_generator/bin/sh/tests/builtins/Makefile Fri May 9 07:07:38 2014 (r265743) @@ -80,6 +80,9 @@ FILES+= for2.0 FILES+= for3.0 FILES+= getopts1.0 getopts1.0.stdout FILES+= getopts2.0 getopts2.0.stdout +FILES+= getopts3.0 +FILES+= getopts4.0 +FILES+= getopts5.0 FILES+= hash1.0 hash1.0.stdout FILES+= hash2.0 hash2.0.stdout FILES+= hash3.0 hash3.0.stdout Copied: projects/random_number_generator/bin/sh/tests/builtins/getopts3.0 (from r265740, head/bin/sh/tests/builtins/getopts3.0) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/random_number_generator/bin/sh/tests/builtins/getopts3.0 Fri May 9 07:07:38 2014 (r265743, copy of r265740, head/bin/sh/tests/builtins/getopts3.0) @@ -0,0 +1,6 @@ +# $FreeBSD$ + +shift $# +getopts x opt +r=$? +[ "$r" != 0 ] && [ "$OPTIND" = 1 ] Copied: projects/random_number_generator/bin/sh/tests/builtins/getopts4.0 (from r265740, head/bin/sh/tests/builtins/getopts4.0) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/random_number_generator/bin/sh/tests/builtins/getopts4.0 Fri May 9 07:07:38 2014 (r265743, copy of r265740, head/bin/sh/tests/builtins/getopts4.0) @@ -0,0 +1,10 @@ +# $FreeBSD$ + +set -- -x +opt=not +getopts x opt +r1=$? OPTIND1=$OPTIND opt1=$opt +getopts x opt +r2=$? OPTIND2=$OPTIND +[ "$r1" = 0 ] && [ "$OPTIND1" = 2 ] && [ "$opt1" = x ] && [ "$r2" != 0 ] && + [ "$OPTIND2" = 2 ] Copied: projects/random_number_generator/bin/sh/tests/builtins/getopts5.0 (from r265740, head/bin/sh/tests/builtins/getopts5.0) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/random_number_generator/bin/sh/tests/builtins/getopts5.0 Fri May 9 07:07:38 2014 (r265743, copy of r265740, head/bin/sh/tests/builtins/getopts5.0) @@ -0,0 +1,10 @@ +# $FreeBSD$ + +set -- -x arg +opt=not +getopts x opt +r1=$? OPTIND1=$OPTIND opt1=$opt +getopts x opt +r2=$? OPTIND2=$OPTIND +[ "$r1" = 0 ] && [ "$OPTIND1" = 2 ] && [ "$opt1" = x ] && [ "$r2" != 0 ] && + [ "$OPTIND2" = 2 ] Modified: projects/random_number_generator/cddl/compat/opensolaris/include/thread_pool.h ============================================================================== --- projects/random_number_generator/cddl/compat/opensolaris/include/thread_pool.h Fri May 9 07:07:25 2014 (r265742) +++ projects/random_number_generator/cddl/compat/opensolaris/include/thread_pool.h Fri May 9 07:07:38 2014 (r265743) @@ -1,39 +1,78 @@ -/*- - * Copyright (c) 2010 Pawel Jakub Dawidek - * All rights reserved. +/* + * CDDL HEADER START * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* * $FreeBSD$ */ -#ifndef _OPENSOLARIS_THREAD_POOL_H_ -#define _OPENSOLARIS_THREAD_POOL_H_ +#ifndef _THREAD_POOL_H_ +#define _THREAD_POOL_H_ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct tpool tpool_t; /* opaque thread pool descriptor */ + +#if defined(__STDC__) + +extern tpool_t *tpool_create(uint_t min_threads, uint_t max_threads, + uint_t linger, pthread_attr_t *attr); +extern int tpool_dispatch(tpool_t *tpool, + void (*func)(void *), void *arg); +extern void tpool_destroy(tpool_t *tpool); +extern void tpool_abandon(tpool_t *tpool); +extern void tpool_wait(tpool_t *tpool); +extern void tpool_suspend(tpool_t *tpool); +extern int tpool_suspended(tpool_t *tpool); +extern void tpool_resume(tpool_t *tpool); +extern int tpool_member(tpool_t *tpool); + +#else /* Non ANSI */ + +extern tpool_t *tpool_create(); +extern int tpool_dispatch(); +extern void tpool_destroy(); +extern void tpool_abandon(); +extern void tpool_wait(); +extern void tpool_suspend(); +extern int tpool_suspended(); +extern void tpool_resume(); +extern int tpool_member(); -typedef int tpool_t; +#endif /* __STDC__ */ -#define tpool_create(a, b, c, d) (0) -#define tpool_dispatch(pool, func, arg) func(arg) -#define tpool_wait(pool) do { } while (0) -#define tpool_destroy(pool) do { } while (0) +#ifdef __cplusplus +} +#endif -#endif /* !_OPENSOLARIS_THREAD_POOL_H_ */ +#endif /* _THREAD_POOL_H_ */ Copied: projects/random_number_generator/cddl/compat/opensolaris/misc/thread_pool.c (from r265740, head/cddl/compat/opensolaris/misc/thread_pool.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/random_number_generator/cddl/compat/opensolaris/misc/thread_pool.c Fri May 9 07:07:38 2014 (r265743, copy of r265740, head/cddl/compat/opensolaris/misc/thread_pool.c) @@ -0,0 +1,430 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#include +__FBSDID("$FreeBSD$"); + +#pragma ident "%Z%%M% %I% %E% SMI" + +#include +#include +#include +#include "thread_pool_impl.h" + +typedef void (*_Voidfp)(void*); /* pointer to extern "C" function */ + +static void +delete_pool(tpool_t *tpool) +{ + tpool_job_t *job; + + /* + * There should be no pending jobs, but just in case... + */ + for (job = tpool->tp_head; job != NULL; job = tpool->tp_head) { + tpool->tp_head = job->tpj_next; + free(job); + } + (void) pthread_attr_destroy(&tpool->tp_attr); + free(tpool); +} + +/* + * Worker thread is terminating. + */ +static void +worker_cleanup(void *arg) +{ + tpool_t *tpool = arg; + + if (--tpool->tp_current == 0 && + (tpool->tp_flags & (TP_DESTROY | TP_ABANDON))) { + if (tpool->tp_flags & TP_ABANDON) { + pthread_mutex_unlock(&tpool->tp_mutex); + delete_pool(tpool); + return; + } + if (tpool->tp_flags & TP_DESTROY) + (void) pthread_cond_broadcast(&tpool->tp_busycv); + } + pthread_mutex_unlock(&tpool->tp_mutex); +} + +static void +notify_waiters(tpool_t *tpool) +{ + if (tpool->tp_head == NULL && tpool->tp_active == NULL) { + tpool->tp_flags &= ~TP_WAIT; + (void) pthread_cond_broadcast(&tpool->tp_waitcv); + } +} + +/* + * Called by a worker thread on return from a tpool_dispatch()d job. + */ +static void +job_cleanup(void *arg) +{ + tpool_t *tpool = arg; + pthread_t my_tid = pthread_self(); + tpool_active_t *activep; + tpool_active_t **activepp; + + pthread_mutex_lock(&tpool->tp_mutex); + /* CSTYLED */ + for (activepp = &tpool->tp_active;; activepp = &activep->tpa_next) { + activep = *activepp; + if (activep->tpa_tid == my_tid) { + *activepp = activep->tpa_next; + break; + } + } + if (tpool->tp_flags & TP_WAIT) + notify_waiters(tpool); +} + +static void * +tpool_worker(void *arg) +{ + tpool_t *tpool = (tpool_t *)arg; + int elapsed; + tpool_job_t *job; + void (*func)(void *); + tpool_active_t active; + sigset_t maskset; + + pthread_mutex_lock(&tpool->tp_mutex); + pthread_cleanup_push(worker_cleanup, tpool); + + /* + * This is the worker's main loop. + * It will only be left if a timeout or an error has occured. + */ + active.tpa_tid = pthread_self(); + for (;;) { + elapsed = 0; + tpool->tp_idle++; + if (tpool->tp_flags & TP_WAIT) + notify_waiters(tpool); + while ((tpool->tp_head == NULL || + (tpool->tp_flags & TP_SUSPEND)) && + !(tpool->tp_flags & (TP_DESTROY | TP_ABANDON))) { + if (tpool->tp_current <= tpool->tp_minimum || + tpool->tp_linger == 0) { + (void) pthread_cond_wait(&tpool->tp_workcv, + &tpool->tp_mutex); + } else { + struct timespec timeout; + + clock_gettime(CLOCK_MONOTONIC, &timeout); + timeout.tv_sec += tpool->tp_linger; + if (pthread_cond_timedwait(&tpool->tp_workcv, + &tpool->tp_mutex, &timeout) != 0) { + elapsed = 1; + break; + } + } + } + tpool->tp_idle--; + if (tpool->tp_flags & TP_DESTROY) + break; + if (tpool->tp_flags & TP_ABANDON) { + /* can't abandon a suspended pool */ + if (tpool->tp_flags & TP_SUSPEND) { + tpool->tp_flags &= ~TP_SUSPEND; + (void) pthread_cond_broadcast(&tpool->tp_workcv); + } + if (tpool->tp_head == NULL) + break; + } + if ((job = tpool->tp_head) != NULL && + !(tpool->tp_flags & TP_SUSPEND)) { + elapsed = 0; + func = job->tpj_func; + arg = job->tpj_arg; + tpool->tp_head = job->tpj_next; + if (job == tpool->tp_tail) + tpool->tp_tail = NULL; + tpool->tp_njobs--; + active.tpa_next = tpool->tp_active; + tpool->tp_active = &active; + pthread_mutex_unlock(&tpool->tp_mutex); + pthread_cleanup_push(job_cleanup, tpool); + free(job); + /* + * Call the specified function. + */ + func(arg); + /* + * We don't know what this thread has been doing, + * so we reset its signal mask and cancellation + * state back to the initial values. + */ + sigfillset(&maskset); + (void) pthread_sigmask(SIG_SETMASK, &maskset, NULL); + (void) pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, + NULL); + (void) pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, + NULL); + pthread_cleanup_pop(1); + } + if (elapsed && tpool->tp_current > tpool->tp_minimum) { + /* + * We timed out and there is no work to be done + * and the number of workers exceeds the minimum. + * Exit now to reduce the size of the pool. + */ + break; + } + } + pthread_cleanup_pop(1); + return (arg); +} + +/* + * Create a worker thread, with all signals blocked. + */ +static int +create_worker(tpool_t *tpool) +{ + sigset_t maskset, oset; + pthread_t thread; + int error; + + sigfillset(&maskset); + (void) pthread_sigmask(SIG_SETMASK, &maskset, &oset); + error = pthread_create(&thread, &tpool->tp_attr, tpool_worker, tpool); + (void) pthread_sigmask(SIG_SETMASK, &oset, NULL); + return (error); +} + +tpool_t * +tpool_create(uint_t min_threads, uint_t max_threads, uint_t linger, + pthread_attr_t *attr) +{ + tpool_t *tpool; + int error; + + if (min_threads > max_threads || max_threads < 1) { + errno = EINVAL; + return (NULL); + } + + tpool = malloc(sizeof (*tpool)); + if (tpool == NULL) { + errno = ENOMEM; + return (NULL); + } + bzero(tpool, sizeof(*tpool)); + (void) pthread_mutex_init(&tpool->tp_mutex, NULL); + (void) pthread_cond_init(&tpool->tp_busycv, NULL); + (void) pthread_cond_init(&tpool->tp_workcv, NULL); + (void) pthread_cond_init(&tpool->tp_waitcv, NULL); + tpool->tp_minimum = min_threads; + tpool->tp_maximum = max_threads; + tpool->tp_linger = linger; + + /* make all pool threads be detached daemon threads */ + (void) pthread_attr_init(&tpool->tp_attr); + (void) pthread_attr_setdetachstate(&tpool->tp_attr, + PTHREAD_CREATE_DETACHED); + + return (tpool); +} + +/* + * Dispatch a work request to the thread pool. + * If there are idle workers, awaken one. + * Else, if the maximum number of workers has + * not been reached, spawn a new worker thread. + * Else just return with the job added to the queue. + */ +int +tpool_dispatch(tpool_t *tpool, void (*func)(void *), void *arg) +{ + tpool_job_t *job; + + if ((job = malloc(sizeof (*job))) == NULL) + return (-1); + bzero(job, sizeof(*job)); + job->tpj_next = NULL; + job->tpj_func = func; + job->tpj_arg = arg; + + pthread_mutex_lock(&tpool->tp_mutex); + + if (tpool->tp_head == NULL) + tpool->tp_head = job; + else + tpool->tp_tail->tpj_next = job; + tpool->tp_tail = job; + tpool->tp_njobs++; + + if (!(tpool->tp_flags & TP_SUSPEND)) { + if (tpool->tp_idle > 0) + (void) pthread_cond_signal(&tpool->tp_workcv); + else if (tpool->tp_current < tpool->tp_maximum && + create_worker(tpool) == 0) + tpool->tp_current++; + } + + pthread_mutex_unlock(&tpool->tp_mutex); + return (0); +} + +/* + * Assumes: by the time tpool_destroy() is called no one will use this + * thread pool in any way and no one will try to dispatch entries to it. + * Calling tpool_destroy() from a job in the pool will cause deadlock. + */ +void +tpool_destroy(tpool_t *tpool) +{ + tpool_active_t *activep; + + pthread_mutex_lock(&tpool->tp_mutex); + pthread_cleanup_push((_Voidfp)pthread_mutex_unlock, &tpool->tp_mutex); + + /* mark the pool as being destroyed; wakeup idle workers */ + tpool->tp_flags |= TP_DESTROY; + tpool->tp_flags &= ~TP_SUSPEND; + (void) pthread_cond_broadcast(&tpool->tp_workcv); + + /* cancel all active workers */ + for (activep = tpool->tp_active; activep; activep = activep->tpa_next) + (void) pthread_cancel(activep->tpa_tid); + + /* wait for all active workers to finish */ + while (tpool->tp_active != NULL) { + tpool->tp_flags |= TP_WAIT; + (void) pthread_cond_wait(&tpool->tp_waitcv, &tpool->tp_mutex); + } + + /* the last worker to terminate will wake us up */ + while (tpool->tp_current != 0) + (void) pthread_cond_wait(&tpool->tp_busycv, &tpool->tp_mutex); + + pthread_cleanup_pop(1); /* pthread_mutex_unlock(&tpool->tp_mutex); */ + delete_pool(tpool); +} + +/* + * Like tpool_destroy(), but don't cancel workers or wait for them to finish. + * The last worker to terminate will delete the pool. + */ +void +tpool_abandon(tpool_t *tpool) +{ + + pthread_mutex_lock(&tpool->tp_mutex); + if (tpool->tp_current == 0) { + /* no workers, just delete the pool */ + pthread_mutex_unlock(&tpool->tp_mutex); + delete_pool(tpool); + } else { + /* wake up all workers, last one will delete the pool */ + tpool->tp_flags |= TP_ABANDON; + tpool->tp_flags &= ~TP_SUSPEND; + (void) pthread_cond_broadcast(&tpool->tp_workcv); + pthread_mutex_unlock(&tpool->tp_mutex); + } +} + +/* + * Wait for all jobs to complete. + * Calling tpool_wait() from a job in the pool will cause deadlock. + */ +void +tpool_wait(tpool_t *tpool) +{ + + pthread_mutex_lock(&tpool->tp_mutex); + pthread_cleanup_push((_Voidfp)pthread_mutex_unlock, &tpool->tp_mutex); + while (tpool->tp_head != NULL || tpool->tp_active != NULL) { + tpool->tp_flags |= TP_WAIT; + (void) pthread_cond_wait(&tpool->tp_waitcv, &tpool->tp_mutex); + } + pthread_cleanup_pop(1); /* pthread_mutex_unlock(&tpool->tp_mutex); */ +} + +void +tpool_suspend(tpool_t *tpool) +{ + + pthread_mutex_lock(&tpool->tp_mutex); + tpool->tp_flags |= TP_SUSPEND; + pthread_mutex_unlock(&tpool->tp_mutex); +} + +int +tpool_suspended(tpool_t *tpool) +{ + int suspended; + + pthread_mutex_lock(&tpool->tp_mutex); + suspended = (tpool->tp_flags & TP_SUSPEND) != 0; + pthread_mutex_unlock(&tpool->tp_mutex); + + return (suspended); +} + +void +tpool_resume(tpool_t *tpool) +{ + int excess; + + pthread_mutex_lock(&tpool->tp_mutex); + if (!(tpool->tp_flags & TP_SUSPEND)) { + pthread_mutex_unlock(&tpool->tp_mutex); + return; + } + tpool->tp_flags &= ~TP_SUSPEND; + (void) pthread_cond_broadcast(&tpool->tp_workcv); + excess = tpool->tp_njobs - tpool->tp_idle; + while (excess-- > 0 && tpool->tp_current < tpool->tp_maximum) { + if (create_worker(tpool) != 0) + break; /* pthread_create() failed */ + tpool->tp_current++; + } + pthread_mutex_unlock(&tpool->tp_mutex); +} + +int +tpool_member(tpool_t *tpool) +{ + pthread_t my_tid = pthread_self(); + tpool_active_t *activep; + + pthread_mutex_lock(&tpool->tp_mutex); + for (activep = tpool->tp_active; activep; activep = activep->tpa_next) { + if (activep->tpa_tid == my_tid) { + pthread_mutex_unlock(&tpool->tp_mutex); + return (1); + } + } + pthread_mutex_unlock(&tpool->tp_mutex); + return (0); +} Copied: projects/random_number_generator/cddl/compat/opensolaris/misc/thread_pool_impl.h (from r265740, head/cddl/compat/opensolaris/misc/thread_pool_impl.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/random_number_generator/cddl/compat/opensolaris/misc/thread_pool_impl.h Fri May 9 07:07:38 2014 (r265743, copy of r265740, head/cddl/compat/opensolaris/misc/thread_pool_impl.h) @@ -0,0 +1,99 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * $FreeBSD$ + */ + +#ifndef _THREAD_POOL_IMPL_H +#define _THREAD_POOL_IMPL_H + +#pragma ident "%Z%%M% %I% %E% SMI" + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Thread pool implementation definitions. + * See for interface declarations. + */ + +/* + * FIFO queued job + */ +typedef struct tpool_job tpool_job_t; +struct tpool_job { + tpool_job_t *tpj_next; /* list of jobs */ + void (*tpj_func)(void *); /* function to call */ + void *tpj_arg; /* its argument */ +}; + +/* + * List of active threads, linked through their stacks. + */ +typedef struct tpool_active tpool_active_t; +struct tpool_active { + tpool_active_t *tpa_next; /* list of active threads */ + pthread_t tpa_tid; /* active thread id */ +}; + +/* + * The thread pool. + */ +struct tpool { + tpool_t *tp_forw; /* circular list of all thread pools */ + tpool_t *tp_back; + mutex_t tp_mutex; /* protects the pool data */ + cond_t tp_busycv; /* synchronization in tpool_dispatch */ + cond_t tp_workcv; /* synchronization with workers */ + cond_t tp_waitcv; /* synchronization in tpool_wait() */ + tpool_active_t *tp_active; /* threads performing work */ + tpool_job_t *tp_head; /* FIFO job queue */ + tpool_job_t *tp_tail; + pthread_attr_t tp_attr; /* attributes of the workers */ + int tp_flags; /* see below */ + uint_t tp_linger; /* seconds before idle workers exit */ + int tp_njobs; /* number of jobs in job queue */ + int tp_minimum; /* minimum number of worker threads */ + int tp_maximum; /* maximum number of worker threads */ + int tp_current; /* current number of worker threads */ + int tp_idle; /* number of idle workers */ +}; + +/* tp_flags */ +#define TP_WAIT 0x01 /* waiting in tpool_wait() */ +#define TP_SUSPEND 0x02 /* pool is being suspended */ +#define TP_DESTROY 0x04 /* pool is being destroyed */ +#define TP_ABANDON 0x08 /* pool is abandoned (auto-destroy) */ + +#ifdef __cplusplus +} +#endif + +#endif /* _THREAD_POOL_IMPL_H */ Modified: projects/random_number_generator/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c ============================================================================== --- projects/random_number_generator/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c Fri May 9 07:07:25 2014 (r265742) +++ projects/random_number_generator/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c Fri May 9 07:07:38 2014 (r265743) @@ -1138,7 +1138,7 @@ alloc: #if defined(sun) dtp->dt_prcmode = DT_PROC_STOP_PREINIT; #else - dtp->dt_prcmode = DT_PROC_STOP_MAIN; + dtp->dt_prcmode = DT_PROC_STOP_POSTINIT; #endif dtp->dt_linkmode = DT_LINK_KERNEL; dtp->dt_linktype = DT_LTYP_ELF; Modified: projects/random_number_generator/cddl/lib/libzfs/Makefile ============================================================================== --- projects/random_number_generator/cddl/lib/libzfs/Makefile Fri May 9 07:07:25 2014 (r265742) +++ projects/random_number_generator/cddl/lib/libzfs/Makefile Fri May 9 07:07:38 2014 (r265743) @@ -14,6 +14,7 @@ SRCS= deviceid.c \ fsshare.c \ mkdirp.c \ mnttab.c \ + thread_pool.c \ zmount.c \ zone.c Modified: projects/random_number_generator/contrib/llvm/tools/clang/include/clang/Driver/Options.td ============================================================================== --- projects/random_number_generator/contrib/llvm/tools/clang/include/clang/Driver/Options.td Fri May 9 07:07:25 2014 (r265742) +++ projects/random_number_generator/contrib/llvm/tools/clang/include/clang/Driver/Options.td Fri May 9 07:07:38 2014 (r265743) @@ -549,8 +549,6 @@ def finstrument_functions : Flag<["-"], def fkeep_inline_functions : Flag<["-"], "fkeep-inline-functions">, Group; def flat__namespace : Flag<["-"], "flat_namespace">; def flax_vector_conversions : Flag<["-"], "flax-vector-conversions">, Group; -def flimit_debug_info : Flag<["-"], "flimit-debug-info">, Group, Flags<[CC1Option]>, - HelpText<"Limit debug information produced to reduce size of debug binary">; def flimited_precision_EQ : Joined<["-"], "flimited-precision=">, Group; def flto : Flag<["-"], "flto">, Group; def fno_lto : Flag<["-"], "fno-lto">, Group; @@ -645,8 +643,6 @@ def fno_inline : Flag<["-"], "fno-inline def fno_keep_inline_functions : Flag<["-"], "fno-keep-inline-functions">, Group; def fno_lax_vector_conversions : Flag<["-"], "fno-lax-vector-conversions">, Group, HelpText<"Disallow implicit conversions between vectors with a different number of elements or different element types">, Flags<[CC1Option]>; -def fno_limit_debug_info : Flag<["-"], "fno-limit-debug-info">, Group, Flags<[CC1Option]>, - HelpText<"Do not limit debug information produced to reduce size of debug binary">; def fno_merge_all_constants : Flag<["-"], "fno-merge-all-constants">, Group, Flags<[CC1Option]>, HelpText<"Disallow merging of constants">; def fno_modules : Flag <["-"], "fno-modules">, Group, @@ -774,6 +770,12 @@ def fno_signed_char : Flag<["-"], "fno-s def fsplit_stack : Flag<["-"], "fsplit-stack">, Group; def fstack_protector_all : Flag<["-"], "fstack-protector-all">, Group; def fstack_protector : Flag<["-"], "fstack-protector">, Group; +def fstandalone_debug : Flag<["-"], "fstandalone-debug">, Group, Flags<[CC1Option]>, + HelpText<"Emit full debug info for all types used by the program">; +def fno_standalone_debug : Flag<["-"], "fno-standalone-debug">, Group, Flags<[CC1Option]>, + HelpText<"Limit debug information produced to reduce size of debug binary">; +def flimit_debug_info : Flag<["-"], "flimit-debug-info">, Alias; +def fno_limit_debug_info : Flag<["-"], "fno-limit-debug-info">, Alias; def fstrict_aliasing : Flag<["-"], "fstrict-aliasing">, Group; def fstrict_enums : Flag<["-"], "fstrict-enums">, Group, Flags<[CC1Option]>, HelpText<"Enable optimizations based on the strict definition of an enum's " Modified: projects/random_number_generator/contrib/llvm/tools/clang/include/clang/Frontend/CodeGenOptions.h ============================================================================== --- projects/random_number_generator/contrib/llvm/tools/clang/include/clang/Frontend/CodeGenOptions.h Fri May 9 07:07:25 2014 (r265742) +++ projects/random_number_generator/contrib/llvm/tools/clang/include/clang/Frontend/CodeGenOptions.h Fri May 9 07:07:38 2014 (r265743) @@ -50,12 +50,20 @@ public: }; enum DebugInfoKind { - NoDebugInfo, // Don't generate debug info. *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***