12be1a816SJohn Birrell# 22be1a816SJohn Birrell# CDDL HEADER START 32be1a816SJohn Birrell# 42be1a816SJohn Birrell# The contents of this file are subject to the terms of the 52be1a816SJohn Birrell# Common Development and Distribution License (the "License"). 62be1a816SJohn Birrell# You may not use this file except in compliance with the License. 72be1a816SJohn Birrell# 82be1a816SJohn Birrell# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 92be1a816SJohn Birrell# or http://www.opensolaris.org/os/licensing. 102be1a816SJohn Birrell# See the License for the specific language governing permissions 112be1a816SJohn Birrell# and limitations under the License. 122be1a816SJohn Birrell# 132be1a816SJohn Birrell# When distributing Covered Code, include this CDDL HEADER in each 142be1a816SJohn Birrell# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 152be1a816SJohn Birrell# If applicable, add the following below this CDDL HEADER, with the 162be1a816SJohn Birrell# fields enclosed by brackets "[]" replaced with your own identifying 172be1a816SJohn Birrell# information: Portions Copyright [yyyy] [name of copyright owner] 182be1a816SJohn Birrell# 192be1a816SJohn Birrell# CDDL HEADER END 202be1a816SJohn Birrell# 212be1a816SJohn Birrell 222be1a816SJohn Birrell# 232be1a816SJohn Birrell# Copyright 2007 Sun Microsystems, Inc. All rights reserved. 242be1a816SJohn Birrell# Use is subject to license terms. 252be1a816SJohn Birrell# 262be1a816SJohn Birrell# ident "%Z%%M% %I% %E% SMI" 272be1a816SJohn Birrell 282be1a816SJohn Birrellif [ $# != 1 ]; then 292be1a816SJohn Birrell echo expected one argument: '<'dtrace-path'>' 302be1a816SJohn Birrell exit 2 312be1a816SJohn Birrellfi 322be1a816SJohn Birrell 332be1a816SJohn Birrelldtrace=$1 342be1a816SJohn BirrellCFLAGS= 352be1a816SJohn Birrell 362be1a816SJohn Birrelldoit() 372be1a816SJohn Birrell{ 382be1a816SJohn Birrell file=$1 392be1a816SJohn Birrell ofile=$2 402be1a816SJohn Birrell errfile=$3 412be1a816SJohn Birrell cfile=${TMPDIR:-/tmp}/inc.$$.$file.c 422be1a816SJohn Birrell cofile=${TMPDIR:-/tmp}/inc.$$.$file 432be1a816SJohn Birrell cat > $cfile <<EOF 442be1a816SJohn Birrell#include <sys/$file> 452be1a816SJohn Birrellvoid 462be1a816SJohn Birrellmain() 472be1a816SJohn Birrell{} 482be1a816SJohn BirrellEOF 49*d0403385SMark Johnston if cc $CFLAGS -o $cofile $cfile >/dev/null 2>&1; then 502be1a816SJohn Birrell $dtrace -xerrtags -C -s /dev/stdin \ 512be1a816SJohn Birrell >/dev/null 2>$errfile <<EOF 522be1a816SJohn Birrell#include <sys/$file> 532be1a816SJohn BirrellBEGIN 542be1a816SJohn Birrell{ 552be1a816SJohn Birrell exit(0); 562be1a816SJohn Birrell} 572be1a816SJohn BirrellEOF 582be1a816SJohn Birrell if [ $? -ne 0 ]; then 592be1a816SJohn Birrell echo $inc failed: `cat $errfile | head -1` > $ofile 602be1a816SJohn Birrell else 612be1a816SJohn Birrell echo $inc succeeded > $ofile 622be1a816SJohn Birrell fi 632be1a816SJohn Birrell rm -f $errfile 642be1a816SJohn Birrell fi 652be1a816SJohn Birrell 662be1a816SJohn Birrell rm -f $cofile $cfile 2>/dev/null 672be1a816SJohn Birrell} 682be1a816SJohn Birrell 692be1a816SJohn Birrellconcurrency=`psrinfo | wc -l` 702be1a816SJohn Birrelllet concurrency=concurrency*4 712be1a816SJohn Birrelllet i=0 722be1a816SJohn Birrell 732be1a816SJohn Birrellfiles=/usr/include/sys/*.h 742be1a816SJohn Birrell 752be1a816SJohn Birrell# 762be1a816SJohn Birrell# There are a few files in /usr/include/sys that are known to be bad -- usually 772be1a816SJohn Birrell# because they include static globals (!) or function bodies (!!) in the header 782be1a816SJohn Birrell# file. Hopefully these remain sufficiently few that the O(#files * #badfiles) 792be1a816SJohn Birrell# algorithm, below, doesn't become a problem. (And yes, writing scripts in 802be1a816SJohn Birrell# something other than ksh1888 would probably be a good idea.) If this script 812be1a816SJohn Birrell# becomes a problem, kindly fix it by reducing the number of bad files! (That 822be1a816SJohn Birrell# is, fix it by fixing the broken file, not the broken script.) 832be1a816SJohn Birrell# 842be1a816SJohn Birrellbadfiles="ctype.h eri_msg.h ser_sync.h sbpro.h neti.h hook_event.h \ 852be1a816SJohn Birrell bootconf.h bootstat.h dtrace.h dumphdr.h exacct_impl.h fasttrap.h \ 862be1a816SJohn Birrell kobj.h kobj_impl.h ksyms.h lockstat.h smedia.h stat.h utsname.h" 872be1a816SJohn Birrell 882be1a816SJohn Birrellfor inc in $files; do 892be1a816SJohn Birrell file=`basename $inc` 902be1a816SJohn Birrell for bad in $badfiles; do 912be1a816SJohn Birrell if [ "$file" = "$bad" ]; then 922be1a816SJohn Birrell continue 2 932be1a816SJohn Birrell fi 942be1a816SJohn Birrell done 952be1a816SJohn Birrell 962be1a816SJohn Birrell ofile=${TMPDIR:-/tmp}/inc.$file.$$.out 972be1a816SJohn Birrell errfile=${TMPDIR:-/tmp}/inc.$file.$$.err 982be1a816SJohn Birrell doit $file $ofile $errfile & 992be1a816SJohn Birrell let i=i+1 1002be1a816SJohn Birrell 1012be1a816SJohn Birrell if [ $i -eq $concurrency ]; then 1022be1a816SJohn Birrell # 1032be1a816SJohn Birrell # This isn't optimal -- it creates a highly fluctuating load 1042be1a816SJohn Birrell # as we wait for all work to complete -- but it's an easy 1052be1a816SJohn Birrell # way of parallelizing work. 1062be1a816SJohn Birrell # 1072be1a816SJohn Birrell wait 1082be1a816SJohn Birrell let i=0 1092be1a816SJohn Birrell fi 1102be1a816SJohn Birrelldone 1112be1a816SJohn Birrell 1122be1a816SJohn Birrellwait 1132be1a816SJohn Birrell 1142be1a816SJohn Birrellbigofile=${TMPDIR:-/tmp}/inc.$$.out 1152be1a816SJohn Birrell 1162be1a816SJohn Birrellfor inc in $files; do 1172be1a816SJohn Birrell file=`basename $inc` 1182be1a816SJohn Birrell ofile=${TMPDIR:-/tmp}/inc.$file.$$.out 1192be1a816SJohn Birrell 1202be1a816SJohn Birrell if [ -f $ofile ]; then 1212be1a816SJohn Birrell cat $ofile >> $bigofile 1222be1a816SJohn Birrell rm $ofile 1232be1a816SJohn Birrell fi 1242be1a816SJohn Birrelldone 1252be1a816SJohn Birrell 1262be1a816SJohn Birrellstatus=$(grep "failed:" $bigofile | wc -l) 1272be1a816SJohn Birrellcat $bigofile 1282be1a816SJohn Birrellrm -f $bigofile 1292be1a816SJohn Birrellexit $status 130