summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbapt <bapt@FreeBSD.org>2015-06-20 00:58:46 +0000
committerbapt <bapt@FreeBSD.org>2015-06-20 00:58:46 +0000
commitbb8dfd5e7e9ae9f11af6d8bc1e6993e7490d8530 (patch)
treefc0773ee0b0110256bf52c4846f02ccaec2c6e6d
parentdfe0a3d0ebe1a9f827bcae5ac6c246fa0b50e817 (diff)
parentb7b105f7f3482125c0a0cd3901ba022144b964b1 (diff)
downloadFreeBSD-src-bb8dfd5e7e9ae9f11af6d8bc1e6993e7490d8530.zip
FreeBSD-src-bb8dfd5e7e9ae9f11af6d8bc1e6993e7490d8530.tar.gz
Merge from head @274131
-rw-r--r--Makefile4
-rw-r--r--UPDATING21
-rw-r--r--bin/cat/Makefile.depend2
-rw-r--r--bin/ls/Makefile.depend1
-rw-r--r--bin/ls/print.c6
-rw-r--r--contrib/gcc/longlong.h10
-rw-r--r--contrib/libcxxrt/FREEBSD-upgrade2
-rw-r--r--contrib/libcxxrt/libelftc_dem_gnu3.c502
-rw-r--r--etc/devd/usb.conf46
-rw-r--r--gnu/lib/libgcc/Makefile5
-rw-r--r--gnu/lib/libgcc/Makefile.depend1
-rw-r--r--gnu/usr.bin/binutils/as/Makefile.depend1
-rw-r--r--gnu/usr.bin/binutils/ld/Makefile.depend.amd642
-rw-r--r--gnu/usr.bin/binutils/libbinutils/Makefile.depend1
-rw-r--r--include/Makefile.depend1
-rw-r--r--kerberos5/lib/libasn1/Makefile.depend1
-rw-r--r--kerberos5/lib/libheimbase/Makefile.depend1
-rw-r--r--kerberos5/lib/libheimipcc/Makefile.depend1
-rw-r--r--kerberos5/lib/libhx509/Makefile2
-rw-r--r--kerberos5/lib/libhx509/Makefile.depend2
-rw-r--r--kerberos5/lib/libkrb5/Makefile.depend1
-rw-r--r--kerberos5/lib/libroken/Makefile.depend1
-rw-r--r--kerberos5/lib/libwind/Makefile.depend1
-rw-r--r--lib/clang/liblldb/Makefile.depend28
-rw-r--r--lib/clang/liblldbAPI/Makefile.depend338
-rw-r--r--lib/clang/liblldbBreakpoint/Makefile.depend88
-rw-r--r--lib/clang/liblldbCommands/Makefile.depend352
-rw-r--r--lib/clang/liblldbCore/Makefile.depend289
-rw-r--r--lib/clang/liblldbDataFormatters/Makefile.depend248
-rw-r--r--lib/clang/liblldbExpression/Makefile.depend195
-rw-r--r--lib/clang/liblldbHostCommon/Makefile.depend46
-rw-r--r--lib/clang/liblldbHostFreeBSD/Makefile.depend25
-rw-r--r--lib/clang/liblldbHostPOSIX/Makefile.depend15
-rw-r--r--lib/clang/liblldbInterpreter/Makefile.depend233
-rw-r--r--lib/clang/liblldbPluginABISysV_ppc/Makefile.depend24
-rw-r--r--lib/clang/liblldbPluginABISysV_ppc64/Makefile.depend24
-rw-r--r--lib/clang/liblldbPluginABISysV_x86_64/Makefile.depend24
-rw-r--r--lib/clang/liblldbPluginCXXItaniumABI/Makefile.depend24
-rw-r--r--lib/clang/liblldbPluginDisassemblerLLVM/Makefile.depend24
-rw-r--r--lib/clang/liblldbPluginDynamicLoaderPosixDYLD/Makefile.depend34
-rw-r--r--lib/clang/liblldbPluginDynamicLoaderStatic/Makefile.depend24
-rw-r--r--lib/clang/liblldbPluginInstructionARM/Makefile.depend16
-rw-r--r--lib/clang/liblldbPluginInstructionARM64/Makefile.depend15
-rw-r--r--lib/clang/liblldbPluginInstrumentationRuntimeAddressSanitizer/Makefile.depend28
-rw-r--r--lib/clang/liblldbPluginJITLoaderGDB/Makefile.depend24
-rw-r--r--lib/clang/liblldbPluginMemoryHistoryASan/Makefile.depend24
-rw-r--r--lib/clang/liblldbPluginObjectContainerBSDArchive/Makefile.depend24
-rw-r--r--lib/clang/liblldbPluginObjectFileELF/Makefile.depend24
-rw-r--r--lib/clang/liblldbPluginObjectFileJIT/Makefile.depend28
-rw-r--r--lib/clang/liblldbPluginPlatformFreeBSD/Makefile.depend28
-rw-r--r--lib/clang/liblldbPluginPlatformGDB/Makefile.depend28
-rw-r--r--lib/clang/liblldbPluginProcessElfCore/Makefile.depend26
-rw-r--r--lib/clang/liblldbPluginProcessFreeBSD/Makefile.depend22
-rw-r--r--lib/clang/liblldbPluginProcessGDBRemote/Makefile.depend50
-rw-r--r--lib/clang/liblldbPluginProcessPOSIX/Makefile.depend48
-rw-r--r--lib/clang/liblldbPluginProcessUtility/Makefile.depend90
-rw-r--r--lib/clang/liblldbPluginSymbolFileDWARF/Makefile.depend199
-rw-r--r--lib/clang/liblldbPluginSymbolFileSymtab/Makefile.depend24
-rw-r--r--lib/clang/liblldbPluginSymbolVendorELF/Makefile.depend24
-rw-r--r--lib/clang/liblldbPluginUnwindAssemblyInstEmulation/Makefile.depend18
-rw-r--r--lib/clang/liblldbPluginUnwindAssemblyX86/Makefile.depend18
-rw-r--r--lib/clang/liblldbSymbol/Makefile.depend208
-rw-r--r--lib/clang/liblldbTarget/Makefile.depend224
-rw-r--r--lib/clang/liblldbUtility/Makefile.depend15
-rw-r--r--lib/clang/libllvmexecutionengine/Makefile.depend2
-rw-r--r--lib/clang/libllvmmcdisassembler/Makefile.depend2
-rw-r--r--lib/clang/libllvmmcjit/Makefile.depend2
-rw-r--r--lib/clang/libllvmruntimedyld/Makefile.depend2
-rw-r--r--lib/libbegemot/Makefile.depend1
-rw-r--r--lib/libc/Makefile.depend1
-rw-r--r--lib/libcom_err/Makefile.depend1
-rw-r--r--lib/libcrypt/Makefile.depend1
-rw-r--r--lib/libdwarf/Makefile.depend2
-rw-r--r--lib/libfetch/Makefile.depend1
-rw-r--r--lib/libipsec/Makefile.depend1
-rw-r--r--lib/libldns/Makefile.depend1
-rw-r--r--lib/liblzma/Makefile.depend1
-rw-r--r--lib/libmagic/Makefile.depend1
-rw-r--r--lib/libmd/Makefile.depend1
-rw-r--r--lib/libmd/Makefile.depend.host3
-rw-r--r--lib/libmp/Makefile.depend1
-rw-r--r--lib/libopie/Makefile.depend1
-rw-r--r--lib/libpam/libpam/Makefile.depend1
-rw-r--r--lib/libradius/Makefile.depend1
-rw-r--r--lib/libsbuf/Makefile.depend1
-rw-r--r--lib/libthr/Makefile.depend1
-rw-r--r--lib/libthread_db/Makefile.depend1
-rw-r--r--lib/libutil/Makefile.depend1
-rw-r--r--lib/libvmmapi/vmmapi.c320
-rw-r--r--lib/libvmmapi/vmmapi.h52
-rw-r--r--lib/libypclnt/Makefile.depend1
-rw-r--r--lib/libz/Makefile.depend1
-rw-r--r--lib/msun/Makefile.depend1
-rw-r--r--lib/ncurses/ncurses/Makefile.depend1
-rw-r--r--lib/ncurses/ncursesw/Makefile.depend1
-rw-r--r--lib/ncurses/panel/Makefile.depend2
-rw-r--r--lib/ncurses/panelw/Makefile.depend2
-rw-r--r--libexec/rtld-elf/Makefile.depend1
-rw-r--r--release/Makefile.azure53
-rw-r--r--release/Makefile.vm1
-rw-r--r--release/arm/BEAGLEBONE.conf2
-rw-r--r--release/arm/CUBOX-HUMMINGBOARD.conf2
-rw-r--r--release/arm/GUMSTIX.conf2
-rw-r--r--release/arm/PANDABOARD.conf2
-rw-r--r--release/arm/RPI-B.conf2
-rw-r--r--release/arm/RPI2.conf2
-rw-r--r--release/arm/WANDBOARD.conf2
-rw-r--r--release/tools/azure.conf4
-rw-r--r--sbin/atm/atmconfig/Makefile.depend1
-rw-r--r--sbin/devd/Makefile.depend1
-rw-r--r--sbin/init/Makefile.depend1
-rw-r--r--sbin/umount/umount.85
-rw-r--r--secure/lib/libcrypt/crypt-blowfish.c3
-rw-r--r--secure/lib/libcrypto/Makefile.depend1
-rw-r--r--secure/lib/libssh/Makefile.depend1
-rw-r--r--secure/lib/libssl/Makefile.depend1
-rw-r--r--share/doc/usd/13.viref/Makefile11
-rw-r--r--share/doc/usd/13.viref/merge.awk17
-rwxr-xr-xshare/examples/bhyve/vmrun.sh12
-rw-r--r--share/i18n/csmapper/Makefile.depend1
-rw-r--r--share/i18n/esdb/Makefile.depend1
-rw-r--r--share/man/man4/aacraid.49
-rw-r--r--share/man/man4/acpi_hp.416
-rw-r--r--share/man/man4/acpi_ibm.48
-rw-r--r--share/man/man4/acpi_panasonic.44
-rw-r--r--share/man/man4/ada.420
-rw-r--r--share/man/man9/pci_iov_schema.914
-rw-r--r--share/man/man9/sbuf.92
-rw-r--r--share/man/man9/taskqueue.94
-rw-r--r--share/mk/bsd.doc.mk2
-rw-r--r--share/mk/local.sys.env.mk43
-rw-r--r--share/mk/local.sys.mk38
-rw-r--r--share/mk/meta.stage.mk13
-rw-r--r--share/mk/src.opts.mk1
-rw-r--r--share/mk/src.sys.env.mk24
-rw-r--r--share/mk/src.sys.mk15
-rw-r--r--share/mk/sys.mk20
-rw-r--r--sys/amd64/include/vmm.h35
-rw-r--r--sys/amd64/include/vmm_dev.h38
-rw-r--r--sys/amd64/vmm/amd/svm.c2
-rw-r--r--sys/amd64/vmm/intel/vmx.c2
-rw-r--r--sys/amd64/vmm/io/ppt.c16
-rw-r--r--sys/amd64/vmm/vmm.c471
-rw-r--r--sys/amd64/vmm/vmm_dev.c398
-rw-r--r--sys/amd64/vmm/vmm_instruction_emul.c12
-rw-r--r--sys/amd64/vmm/vmm_mem.c32
-rw-r--r--sys/amd64/vmm/vmm_mem.h2
-rw-r--r--sys/arm/conf/BEAGLEBONE8
-rw-r--r--sys/arm/ti/am335x/am335x_lcd.c579
-rw-r--r--sys/arm/ti/am335x/am335x_lcd.h8
-rw-r--r--sys/arm/ti/am335x/am335x_prcm.c88
-rw-r--r--sys/arm/ti/am335x/files.am335x3
-rw-r--r--sys/arm/ti/am335x/hdmi.h (renamed from usr.bin/make/proc.h)37
-rw-r--r--sys/arm/ti/am335x/hdmi_if.m50
-rw-r--r--sys/arm/ti/am335x/tda19988.c810
-rw-r--r--sys/arm/ti/omap4/omap4_prcm_clks.c14
-rw-r--r--sys/arm/ti/ti_prcm.c37
-rw-r--r--sys/arm/ti/ti_prcm.h3
-rw-r--r--sys/boot/Makefile2
-rw-r--r--sys/boot/common/Makefile10
-rw-r--r--sys/boot/common/Makefile.inc5
-rw-r--r--sys/boot/fdt/dts/arm/beaglebone-black.dts22
-rw-r--r--sys/boot/i386/loader/Makefile1
-rw-r--r--sys/boot/mips/beri/loader/Makefile1
-rw-r--r--sys/boot/pc98/loader/Makefile1
-rw-r--r--sys/boot/powerpc/kboot/Makefile1
-rw-r--r--sys/boot/powerpc/ofw/Makefile1
-rw-r--r--sys/boot/powerpc/ps3/Makefile1
-rw-r--r--sys/boot/sparc64/loader/Makefile1
-rw-r--r--sys/boot/uboot/lib/copy.c7
-rw-r--r--sys/boot/uboot/lib/glue.c2
-rw-r--r--sys/cam/ctl/scsi_ctl.c61
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c6
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c34
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_tx.c4
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dnode.c76
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dnode_sync.c4
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dbuf.h4
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c2
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/sys/sysmacros.h11
-rw-r--r--sys/conf/NOTES2
-rw-r--r--sys/conf/files1
-rw-r--r--sys/conf/files.mips2
-rwxr-xr-xsys/contrib/dev/acpica/acpica_prep.sh24
-rw-r--r--sys/contrib/dev/acpica/changes.txt129
-rw-r--r--sys/contrib/dev/acpica/common/adisasm.c2
-rw-r--r--sys/contrib/dev/acpica/common/ahids.c2
-rw-r--r--sys/contrib/dev/acpica/common/ahpredef.c2
-rw-r--r--sys/contrib/dev/acpica/common/ahuuids.c2
-rw-r--r--sys/contrib/dev/acpica/common/dmextern.c16
-rw-r--r--sys/contrib/dev/acpica/common/dmrestag.c8
-rw-r--r--sys/contrib/dev/acpica/common/dmtable.c4
-rw-r--r--sys/contrib/dev/acpica/common/dmtbdump.c6
-rw-r--r--sys/contrib/dev/acpica/common/dmtbinfo.c13
-rw-r--r--sys/contrib/dev/acpica/common/getopt.c4
-rw-r--r--sys/contrib/dev/acpica/compiler/aslanalyze.c10
-rw-r--r--sys/contrib/dev/acpica/compiler/aslascii.c2
-rw-r--r--sys/contrib/dev/acpica/compiler/aslcodegen.c11
-rw-r--r--sys/contrib/dev/acpica/compiler/aslcompile.c13
-rw-r--r--sys/contrib/dev/acpica/compiler/aslcompiler.h2
-rw-r--r--sys/contrib/dev/acpica/compiler/aslcompiler.l2
-rw-r--r--sys/contrib/dev/acpica/compiler/asldefine.h5
-rw-r--r--sys/contrib/dev/acpica/compiler/aslerror.c6
-rw-r--r--sys/contrib/dev/acpica/compiler/aslfileio.c38
-rw-r--r--sys/contrib/dev/acpica/compiler/aslfiles.c55
-rw-r--r--sys/contrib/dev/acpica/compiler/aslfold.c59
-rw-r--r--sys/contrib/dev/acpica/compiler/aslglobal.h4
-rw-r--r--sys/contrib/dev/acpica/compiler/aslmain.c2
-rw-r--r--sys/contrib/dev/acpica/compiler/aslmapenter.c8
-rw-r--r--sys/contrib/dev/acpica/compiler/aslmapoutput.c4
-rw-r--r--sys/contrib/dev/acpica/compiler/aslmethod.c4
-rw-r--r--sys/contrib/dev/acpica/compiler/aslopcodes.c6
-rw-r--r--sys/contrib/dev/acpica/compiler/asloperands.c6
-rw-r--r--sys/contrib/dev/acpica/compiler/aslopt.c22
-rw-r--r--sys/contrib/dev/acpica/compiler/asloptions.c1
-rw-r--r--sys/contrib/dev/acpica/compiler/aslprintf.c4
-rw-r--r--sys/contrib/dev/acpica/compiler/aslstartup.c2
-rw-r--r--sys/contrib/dev/acpica/compiler/aslsupport.l9
-rw-r--r--sys/contrib/dev/acpica/compiler/asltypes.h54
-rw-r--r--sys/contrib/dev/acpica/compiler/aslutils.c25
-rw-r--r--sys/contrib/dev/acpica/compiler/asluuid.c2
-rw-r--r--sys/contrib/dev/acpica/compiler/dtcompile.c8
-rw-r--r--sys/contrib/dev/acpica/compiler/dtcompiler.h8
-rw-r--r--sys/contrib/dev/acpica/compiler/dtexpress.c2
-rw-r--r--sys/contrib/dev/acpica/compiler/dtfield.c12
-rw-r--r--sys/contrib/dev/acpica/compiler/dtio.c30
-rw-r--r--sys/contrib/dev/acpica/compiler/dtparser.y15
-rw-r--r--sys/contrib/dev/acpica/compiler/dtsubtable.c4
-rw-r--r--sys/contrib/dev/acpica/compiler/dttable.c6
-rw-r--r--sys/contrib/dev/acpica/compiler/dttemplate.c28
-rw-r--r--sys/contrib/dev/acpica/compiler/dttemplate.h11
-rw-r--r--sys/contrib/dev/acpica/compiler/dtutils.c10
-rw-r--r--sys/contrib/dev/acpica/compiler/prparser.y11
-rw-r--r--sys/contrib/dev/acpica/compiler/prscan.c160
-rw-r--r--sys/contrib/dev/acpica/compiler/prutils.c9
-rw-r--r--sys/contrib/dev/acpica/components/debugger/dbcmds.c16
-rw-r--r--sys/contrib/dev/acpica/components/debugger/dbconvert.c8
-rw-r--r--sys/contrib/dev/acpica/components/debugger/dbdisply.c2
-rw-r--r--sys/contrib/dev/acpica/components/debugger/dbexec.c14
-rw-r--r--sys/contrib/dev/acpica/components/debugger/dbfileio.c2
-rw-r--r--sys/contrib/dev/acpica/components/debugger/dbhistry.c8
-rw-r--r--sys/contrib/dev/acpica/components/debugger/dbinput.c10
-rw-r--r--sys/contrib/dev/acpica/components/debugger/dbmethod.c8
-rw-r--r--sys/contrib/dev/acpica/components/debugger/dbnames.c10
-rw-r--r--sys/contrib/dev/acpica/components/debugger/dbtest.c20
-rw-r--r--sys/contrib/dev/acpica/components/debugger/dbutils.c4
-rw-r--r--sys/contrib/dev/acpica/components/debugger/dbxface.c2
-rw-r--r--sys/contrib/dev/acpica/components/disassembler/dmbuffer.c8
-rw-r--r--sys/contrib/dev/acpica/components/disassembler/dmcstyle.c89
-rw-r--r--sys/contrib/dev/acpica/components/disassembler/dmopcode.c6
-rw-r--r--sys/contrib/dev/acpica/components/dispatcher/dsfield.c2
-rw-r--r--sys/contrib/dev/acpica/components/dispatcher/dsinit.c2
-rw-r--r--sys/contrib/dev/acpica/components/dispatcher/dsobject.c4
-rw-r--r--sys/contrib/dev/acpica/components/dispatcher/dsutils.c2
-rw-r--r--sys/contrib/dev/acpica/components/dispatcher/dswload.c15
-rw-r--r--sys/contrib/dev/acpica/components/events/evgpe.c5
-rw-r--r--sys/contrib/dev/acpica/components/events/evgpeinit.c2
-rw-r--r--sys/contrib/dev/acpica/components/executer/exconfig.c2
-rw-r--r--sys/contrib/dev/acpica/components/executer/exconvrt.c4
-rw-r--r--sys/contrib/dev/acpica/components/executer/exdebug.c35
-rw-r--r--sys/contrib/dev/acpica/components/executer/exdump.c13
-rw-r--r--sys/contrib/dev/acpica/components/executer/exfield.c2
-rw-r--r--sys/contrib/dev/acpica/components/executer/exfldio.c18
-rw-r--r--sys/contrib/dev/acpica/components/executer/exmisc.c18
-rw-r--r--sys/contrib/dev/acpica/components/executer/exnames.c2
-rw-r--r--sys/contrib/dev/acpica/components/executer/exoparg2.c9
-rw-r--r--sys/contrib/dev/acpica/components/executer/exoparg3.c2
-rw-r--r--sys/contrib/dev/acpica/components/executer/exregion.c4
-rw-r--r--sys/contrib/dev/acpica/components/executer/exstorob.c12
-rw-r--r--sys/contrib/dev/acpica/components/executer/exutils.c37
-rw-r--r--sys/contrib/dev/acpica/components/hardware/hwgpe.c13
-rw-r--r--sys/contrib/dev/acpica/components/hardware/hwxfsleep.c93
-rw-r--r--sys/contrib/dev/acpica/components/namespace/nsaccess.c17
-rw-r--r--sys/contrib/dev/acpica/components/namespace/nsconvert.c4
-rw-r--r--sys/contrib/dev/acpica/components/namespace/nsdump.c2
-rw-r--r--sys/contrib/dev/acpica/components/namespace/nseval.c7
-rw-r--r--sys/contrib/dev/acpica/components/namespace/nsinit.c4
-rw-r--r--sys/contrib/dev/acpica/components/namespace/nsparse.c8
-rw-r--r--sys/contrib/dev/acpica/components/namespace/nsrepair2.c2
-rw-r--r--sys/contrib/dev/acpica/components/namespace/nssearch.c38
-rw-r--r--sys/contrib/dev/acpica/components/namespace/nsutils.c2
-rw-r--r--sys/contrib/dev/acpica/components/namespace/nsxfeval.c4
-rw-r--r--sys/contrib/dev/acpica/components/namespace/nsxfname.c32
-rw-r--r--sys/contrib/dev/acpica/components/parser/psutils.c2
-rw-r--r--sys/contrib/dev/acpica/components/resources/rscreate.c4
-rw-r--r--sys/contrib/dev/acpica/components/resources/rsmisc.c8
-rw-r--r--sys/contrib/dev/acpica/components/resources/rsutils.c8
-rw-r--r--sys/contrib/dev/acpica/components/resources/rsxface.c6
-rw-r--r--sys/contrib/dev/acpica/components/tables/tbdata.c4
-rw-r--r--sys/contrib/dev/acpica/components/tables/tbfadt.c21
-rw-r--r--sys/contrib/dev/acpica/components/tables/tbfind.c14
-rw-r--r--sys/contrib/dev/acpica/components/tables/tbinstal.c4
-rw-r--r--sys/contrib/dev/acpica/components/tables/tbprint.c6
-rw-r--r--sys/contrib/dev/acpica/components/tables/tbutils.c34
-rw-r--r--sys/contrib/dev/acpica/components/tables/tbxface.c6
-rw-r--r--sys/contrib/dev/acpica/components/tables/tbxfload.c13
-rw-r--r--sys/contrib/dev/acpica/components/utilities/utalloc.c6
-rw-r--r--sys/contrib/dev/acpica/components/utilities/utbuffer.c4
-rw-r--r--sys/contrib/dev/acpica/components/utilities/utcache.c6
-rw-r--r--sys/contrib/dev/acpica/components/utilities/utcopy.c16
-rw-r--r--sys/contrib/dev/acpica/components/utilities/utids.c104
-rw-r--r--sys/contrib/dev/acpica/components/utilities/utmisc.c7
-rw-r--r--sys/contrib/dev/acpica/components/utilities/utosi.c8
-rw-r--r--sys/contrib/dev/acpica/components/utilities/utpredef.c4
-rw-r--r--sys/contrib/dev/acpica/components/utilities/utprint.c6
-rw-r--r--sys/contrib/dev/acpica/components/utilities/utstring.c32
-rw-r--r--sys/contrib/dev/acpica/components/utilities/uttrack.c8
-rw-r--r--sys/contrib/dev/acpica/components/utilities/utxface.c6
-rw-r--r--sys/contrib/dev/acpica/components/utilities/utxfinit.c11
-rw-r--r--sys/contrib/dev/acpica/include/acclib.h167
-rw-r--r--sys/contrib/dev/acpica/include/accommon.h3
-rw-r--r--sys/contrib/dev/acpica/include/acglobal.h2
-rw-r--r--sys/contrib/dev/acpica/include/acinterp.h5
-rw-r--r--sys/contrib/dev/acpica/include/aclocal.h1
-rw-r--r--sys/contrib/dev/acpica/include/acnames.h1
-rw-r--r--sys/contrib/dev/acpica/include/acnamesp.h1
-rw-r--r--sys/contrib/dev/acpica/include/acobject.h15
-rw-r--r--sys/contrib/dev/acpica/include/acoutput.h13
-rw-r--r--sys/contrib/dev/acpica/include/acpixf.h26
-rw-r--r--sys/contrib/dev/acpica/include/acstruct.h1
-rw-r--r--sys/contrib/dev/acpica/include/actbl.h1
-rw-r--r--sys/contrib/dev/acpica/include/actbl1.h14
-rw-r--r--sys/contrib/dev/acpica/include/actbl2.h87
-rw-r--r--sys/contrib/dev/acpica/include/actbl3.h39
-rw-r--r--sys/contrib/dev/acpica/include/actypes.h37
-rw-r--r--sys/contrib/dev/acpica/include/acutils.h113
-rw-r--r--sys/contrib/dev/acpica/include/platform/acenv.h38
-rw-r--r--sys/contrib/dev/acpica/include/platform/acenvex.h6
-rw-r--r--sys/contrib/dev/acpica/include/platform/acgcc.h4
-rw-r--r--sys/ddb/db_sym.c2
-rw-r--r--sys/dev/atkbdc/psm.c27
-rw-r--r--sys/dev/bxe/bxe.c5
-rw-r--r--sys/dev/bxe/ecore_sp.c2
-rw-r--r--sys/dev/filemon/filemon.h2
-rw-r--r--sys/dev/filemon/filemon_wrapper.c12
-rw-r--r--sys/dev/isp/isp_freebsd.c8
-rw-r--r--sys/dev/iwn/if_iwn.c140
-rw-r--r--sys/dev/iwn/if_iwnvar.h11
-rw-r--r--sys/dev/ixl/if_ixl.c2
-rw-r--r--sys/dev/mii/mii.h2
-rw-r--r--sys/dev/videomode/videomode.h1
-rw-r--r--sys/dev/virtio/mmio/virtio_mmio.h4
-rw-r--r--sys/dev/xen/blkfront/blkfront.c81
-rw-r--r--sys/fs/nfsclient/nfs_clbio.c6
-rw-r--r--sys/fs/tmpfs/tmpfs_subr.c1
-rw-r--r--sys/geom/label/g_label.c15
-rw-r--r--sys/geom/label/g_label.h2
-rw-r--r--sys/geom/label/g_label_iso9660.c10
-rw-r--r--sys/geom/label/g_label_msdosfs.c10
-rw-r--r--sys/kern/imgact_binmisc.c87
-rw-r--r--sys/kern/kern_jail.c2
-rw-r--r--sys/kern/stack_protector.c5
-rw-r--r--sys/kern/vfs_subr.c46
-rw-r--r--sys/modules/usb/Makefile2
-rw-r--r--sys/netinet/if_ether.c15
-rw-r--r--sys/netinet/ip_encap.c49
-rw-r--r--sys/netinet/sctp_asconf.c3
-rw-r--r--sys/netinet/sctp_input.c42
-rw-r--r--sys/netinet/sctp_input.h2
-rw-r--r--sys/netinet/sctp_os_bsd.h9
-rw-r--r--sys/netinet/sctp_output.c25
-rw-r--r--sys/netinet/sctp_output.h6
-rw-r--r--sys/netinet/sctp_pcb.c5
-rw-r--r--sys/netinet/sctp_pcb.h1
-rw-r--r--sys/netinet/sctp_syscalls.c8
-rw-r--r--sys/netinet/sctp_usrreq.c38
-rw-r--r--sys/netinet/sctputil.c8
-rw-r--r--sys/netinet/sctputil.h2
-rw-r--r--sys/netinet6/sctp6_usrreq.c4
-rw-r--r--sys/opencrypto/crypto.c2
-rw-r--r--sys/ufs/ffs/ffs_vfsops.c14
-rw-r--r--sys/vm/swap_pager.c4
-rw-r--r--sys/vm/vm_pager.c72
-rw-r--r--sys/vm/vm_pager.h40
-rw-r--r--sys/x86/acpica/acpi_wakeup.c4
-rw-r--r--targets/pseudo/clang/Makefile.depend8
-rw-r--r--targets/pseudo/toolchain/Makefile.depend2
-rw-r--r--targets/pseudo/userland/gnu/Makefile.depend6
-rw-r--r--tools/build/mk/OptionalObsoleteFiles.inc4
-rw-r--r--usr.bin/Makefile4
-rw-r--r--usr.bin/addr2line/Makefile.depend21
-rw-r--r--usr.bin/ar/Makefile.depend1
-rw-r--r--usr.bin/bmake/Makefile.depend1
-rw-r--r--usr.bin/calendar/calendars/calendar.freebsd1
-rw-r--r--usr.bin/clang/clang-tblgen/Makefile.depend1
-rw-r--r--usr.bin/clang/clang/Makefile.depend26
-rw-r--r--usr.bin/clang/lldb/Makefile.depend146
-rw-r--r--usr.bin/clang/tblgen/Makefile.depend3
-rw-r--r--usr.bin/colldef/Makefile.depend1
-rw-r--r--usr.bin/ee/Makefile.depend1
-rw-r--r--usr.bin/elfcopy/Makefile.depend2
-rw-r--r--usr.bin/find/Makefile.depend1
-rw-r--r--usr.bin/getconf/Makefile.depend1
-rw-r--r--usr.bin/grep/Makefile.depend1
-rw-r--r--usr.bin/kdump/Makefile.depend3
-rw-r--r--usr.bin/less/Makefile.depend1
-rw-r--r--usr.bin/lessecho/Makefile.depend1
-rw-r--r--usr.bin/lesskey/Makefile.depend1
-rw-r--r--usr.bin/make/GNode.h224
-rw-r--r--usr.bin/make/Makefile120
-rw-r--r--usr.bin/make/Makefile.dist10
-rw-r--r--usr.bin/make/arch.c1224
-rw-r--r--usr.bin/make/arch.h61
-rw-r--r--usr.bin/make/buf.c291
-rw-r--r--usr.bin/make/buf.h92
-rw-r--r--usr.bin/make/cond.c1221
-rw-r--r--usr.bin/make/cond.h73
-rw-r--r--usr.bin/make/config.h111
-rw-r--r--usr.bin/make/dir.c1217
-rw-r--r--usr.bin/make/dir.h72
-rw-r--r--usr.bin/make/for.c267
-rw-r--r--usr.bin/make/globals.h116
-rw-r--r--usr.bin/make/hash.c398
-rw-r--r--usr.bin/make/hash.h103
-rw-r--r--usr.bin/make/hash_tables.c130
-rw-r--r--usr.bin/make/job.c3391
-rw-r--r--usr.bin/make/job.h80
-rw-r--r--usr.bin/make/lst.c344
-rw-r--r--usr.bin/make/lst.h175
-rw-r--r--usr.bin/make/main.c1339
-rw-r--r--usr.bin/make/make.11843
-rw-r--r--usr.bin/make/make.c819
-rw-r--r--usr.bin/make/make.h75
-rw-r--r--usr.bin/make/parse.c2545
-rw-r--r--usr.bin/make/parse.h86
-rw-r--r--usr.bin/make/pathnames.h56
-rw-r--r--usr.bin/make/proc.c134
-rw-r--r--usr.bin/make/shell.c472
-rw-r--r--usr.bin/make/shell.h110
-rw-r--r--usr.bin/make/str.c559
-rw-r--r--usr.bin/make/str.h81
-rw-r--r--usr.bin/make/suff.c2205
-rw-r--r--usr.bin/make/suff.h61
-rw-r--r--usr.bin/make/targ.c472
-rw-r--r--usr.bin/make/targ.h73
-rw-r--r--usr.bin/make/util.c316
-rw-r--r--usr.bin/make/util.h116
-rw-r--r--usr.bin/make/var.c2623
-rw-r--r--usr.bin/make/var.h85
-rw-r--r--usr.bin/mandoc/Makefile.depend1
-rw-r--r--usr.bin/mklocale/Makefile.depend1
-rw-r--r--usr.bin/nm/Makefile.depend21
-rw-r--r--usr.bin/readelf/Makefile.depend21
-rw-r--r--usr.bin/size/Makefile.depend (renamed from usr.bin/make/Makefile.depend)9
-rw-r--r--usr.bin/sockstat/sockstat.c69
-rw-r--r--usr.bin/sort/Makefile.depend1
-rw-r--r--usr.bin/strings/Makefile.depend20
-rw-r--r--usr.bin/top/Makefile.depend1
-rw-r--r--usr.bin/truss/Makefile.depend.amd641
-rw-r--r--usr.bin/xinstall/Makefile.depend.host1
-rw-r--r--usr.bin/xlint/lint1/Makefile.depend1
-rw-r--r--usr.bin/xlint/llib/Makefile.depend3
-rw-r--r--usr.sbin/bhyve/Makefile1
-rw-r--r--usr.sbin/bhyve/bhyve.828
-rw-r--r--usr.sbin/bhyve/bhyverun.c93
-rw-r--r--usr.sbin/bhyve/bootrom.c111
-rw-r--r--usr.sbin/bhyve/bootrom.h (renamed from usr.bin/make/hash_tables.h)22
-rw-r--r--usr.sbin/bhyve/pci_lpc.c27
-rw-r--r--usr.sbin/bhyve/pci_lpc.h1
-rw-r--r--usr.sbin/bhyve/pci_passthru.c8
-rw-r--r--usr.sbin/bhyvectl/Makefile2
-rw-r--r--usr.sbin/bhyvectl/bhyvectl.c111
-rw-r--r--usr.sbin/bhyveload/bhyveload.85
-rw-r--r--usr.sbin/bhyveload/bhyveload.c11
-rw-r--r--usr.sbin/bsdconfig/usermgmt/share/group.subr10
-rw-r--r--usr.sbin/bsdconfig/usermgmt/share/user.subr10
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_atm/Makefile.depend1
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_bridge/Makefile.depend1
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_hostres/Makefile.depend1
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_lm75/Makefile.depend1
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_mibII/Makefile.depend1
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_netgraph/Makefile.depend1
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_pf/Makefile.depend1
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_target/Makefile.depend1
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_usm/Makefile.depend1
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_vacm/Makefile.depend1
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_wlan/Makefile.depend1
-rw-r--r--usr.sbin/crunch/crunchgen/Makefile.depend1
-rw-r--r--usr.sbin/ctld/token.l2
-rw-r--r--usr.sbin/fstyp/Makefile34
-rw-r--r--usr.sbin/fstyp/cd9660.c10
-rw-r--r--usr.sbin/fstyp/fstyp.848
-rw-r--r--usr.sbin/fstyp/fstyp.c44
-rw-r--r--usr.sbin/fstyp/fstyp.h5
-rw-r--r--usr.sbin/fstyp/geli.c (renamed from usr.bin/make/for.h)72
-rw-r--r--usr.sbin/fstyp/msdosfs.c10
-rw-r--r--usr.sbin/fstyp/zfs.c73
-rw-r--r--usr.sbin/nologin/Makefile.depend1
-rw-r--r--usr.sbin/ntp/libntp/Makefile.depend1
-rw-r--r--usr.sbin/ntp/ntp-keygen/Makefile.depend1
-rw-r--r--usr.sbin/ntp/ntpd/Makefile.depend3
-rw-r--r--usr.sbin/ntp/ntpdate/Makefile.depend4
-rw-r--r--usr.sbin/ntp/ntpdc/Makefile.depend5
-rw-r--r--usr.sbin/ntp/ntpq/Makefile.depend3
-rw-r--r--usr.sbin/ntp/sntp/Makefile.depend2
-rw-r--r--usr.sbin/syslogd/syslogd.84
-rw-r--r--usr.sbin/syslogd/syslogd.c67
497 files changed, 9828 insertions, 25991 deletions
diff --git a/Makefile b/Makefile
index d643447..2b207fe 100644
--- a/Makefile
+++ b/Makefile
@@ -442,10 +442,9 @@ universe_${target}_prologue: universe_prologue
universe_${target}_worlds:
.if !defined(MAKE_JUST_KERNELS)
+universe_${target}_done: universe_${target}_worlds
.for target_arch in ${TARGET_ARCHES_${target}}
-universe_${target}: universe_${target}_${target_arch}
universe_${target}_worlds: universe_${target}_${target_arch}
-universe_${target}_done: universe_${target}_worlds
universe_${target}_${target_arch}: universe_${target}_prologue .MAKE
@echo ">> ${target}.${target_arch} ${UNIVERSE_TARGET} started on `LC_ALL=C date`"
@(cd ${.CURDIR} && env __MAKE_CONF=/dev/null \
@@ -461,7 +460,6 @@ universe_${target}_${target_arch}: universe_${target}_prologue .MAKE
.endif # !MAKE_JUST_KERNELS
.if !defined(MAKE_JUST_WORLDS)
-universe_${target}: universe_${target}_kernels
universe_${target}_done: universe_${target}_kernels
universe_${target}_kernels: universe_${target}_worlds
universe_${target}_kernels: universe_${target}_prologue .MAKE
diff --git a/UPDATING b/UPDATING
index 5472d97..0b046f5 100644
--- a/UPDATING
+++ b/UPDATING
@@ -31,6 +31,27 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 11.x IS SLOW:
disable the most expensive debugging functionality run
"ln -s 'abort:false,junk:false' /etc/malloc.conf".)
+20150616:
+ /etc/make.conf now included earlier.
+ sys.mk now includes /etc/make.conf and {local,src}.sys.mk earlier
+ than previously.
+ This makes it simple to interpose external toolchains etc.
+ However it may cause problems for users who have things like::
+
+ INSTALL+= something
+
+ in /etc/make.conf, since INSTALL is not yet defined.
+ A safe fix for that is to have::
+
+ INSTALL?= install
+ INSTALL+= something
+
+ which is equivalent to previous behavior.
+
+20150616:
+ FreeBSD's old make (fmake) has been removed from the system. It is
+ available as the devel/fmake port or via pkg install fmake.
+
20150615:
The fix for the issue described in the 20150614 sendmail entry
below has been been committed in revision 284436. The work
diff --git a/bin/cat/Makefile.depend b/bin/cat/Makefile.depend
index ec7b59b..3646e2e 100644
--- a/bin/cat/Makefile.depend
+++ b/bin/cat/Makefile.depend
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/bin/ls/Makefile.depend b/bin/ls/Makefile.depend
index e36f602..6151c71 100644
--- a/bin/ls/Makefile.depend
+++ b/bin/ls/Makefile.depend
@@ -10,6 +10,7 @@ DIRDEPS = \
lib/libc \
lib/libcompiler_rt \
lib/libutil \
+ lib/libxo \
lib/ncurses/ncursesw \
diff --git a/bin/ls/print.c b/bin/ls/print.c
index c96fe7c..2d1425d 100644
--- a/bin/ls/print.c
+++ b/bin/ls/print.c
@@ -178,7 +178,7 @@ printlong(const DISPLAY *dp)
sp = p->fts_statp;
name = getname(p->fts_name);
if (name)
- xo_emit("{ke:name}", name);
+ xo_emit("{ke:name/%hs}", name);
if (f_inode)
xo_emit("{:inode/%*ju} ",
dp->s_inode, (uintmax_t)sp->st_ino);
@@ -214,7 +214,7 @@ printlong(const DISPLAY *dp)
#endif
if (name) {
- xo_emit("{dk:name}", name);
+ xo_emit("{dk:name/%hs}", name);
free(name);
}
@@ -425,7 +425,7 @@ printtime(const char *field, time_t ftime)
format = d_first ? "%e %b %Y" : "%b %e %Y";
strftime(longstring, sizeof(longstring), format, localtime(&ftime));
- snprintf(fmt, sizeof(fmt), "{:%s/%%s} ", field);
+ snprintf(fmt, sizeof(fmt), "{:%s/%%hs} ", field);
xo_attr("value", "%ld", (long) ftime);
xo_emit(fmt, longstring);
}
diff --git a/contrib/gcc/longlong.h b/contrib/gcc/longlong.h
index 304ee8d..01f8885 100644
--- a/contrib/gcc/longlong.h
+++ b/contrib/gcc/longlong.h
@@ -584,11 +584,11 @@ UDItype __umulsidi3 (USItype, USItype);
#if defined (__mips__) && W_TYPE_SIZE == 32
#define umul_ppmm(w1, w0, u, v) \
- __asm__ ("multu %2,%3" \
- : "=l" ((USItype) (w0)), \
- "=h" ((USItype) (w1)) \
- : "d" ((USItype) (u)), \
- "d" ((USItype) (v)))
+ do { \
+ UDItype __x = (UDItype) (USItype) (u) * (USItype) (v); \
+ w1 = __x >> 32; \
+ w0 = __x; \
+ } while (0)
#define UMUL_TIME 10
#define UDIV_TIME 100
#endif /* __mips__ */
diff --git a/contrib/libcxxrt/FREEBSD-upgrade b/contrib/libcxxrt/FREEBSD-upgrade
index ac62556..bdd74f3 100644
--- a/contrib/libcxxrt/FREEBSD-upgrade
+++ b/contrib/libcxxrt/FREEBSD-upgrade
@@ -3,4 +3,4 @@ $FreeBSD$
This is the FreeBSD copy of libcxxrt. It contains the src directory from the
upstream repository.
-When updating, copy *.{c,cc,h} and typeinfo from the upstream src/.
+When updating, copy *.{c,cc,h} from the upstream src/.
diff --git a/contrib/libcxxrt/libelftc_dem_gnu3.c b/contrib/libcxxrt/libelftc_dem_gnu3.c
index 11c2ca2..70ef3e8 100644
--- a/contrib/libcxxrt/libelftc_dem_gnu3.c
+++ b/contrib/libcxxrt/libelftc_dem_gnu3.c
@@ -59,7 +59,7 @@ struct vector_str {
enum type_qualifier {
TYPE_PTR, TYPE_REF, TYPE_CMX, TYPE_IMG, TYPE_EXT, TYPE_RST, TYPE_VAT,
- TYPE_CST
+ TYPE_CST, TYPE_VEC
};
struct vector_type_qualifier {
@@ -397,6 +397,8 @@ static int cpp_demangle_read_array(struct cpp_demangle_data *);
static int cpp_demangle_read_encoding(struct cpp_demangle_data *);
static int cpp_demangle_read_expr_primary(struct cpp_demangle_data *);
static int cpp_demangle_read_expression(struct cpp_demangle_data *);
+static int cpp_demangle_read_expression_flat(struct cpp_demangle_data *,
+ char **);
static int cpp_demangle_read_expression_binary(struct cpp_demangle_data *,
const char *, size_t);
static int cpp_demangle_read_expression_unary(struct cpp_demangle_data *,
@@ -408,8 +410,12 @@ static int cpp_demangle_read_function(struct cpp_demangle_data *, int *,
static int cpp_demangle_local_source_name(struct cpp_demangle_data *ddata);
static int cpp_demangle_read_local_name(struct cpp_demangle_data *);
static int cpp_demangle_read_name(struct cpp_demangle_data *);
+static int cpp_demangle_read_name_flat(struct cpp_demangle_data *,
+ char**);
static int cpp_demangle_read_nested_name(struct cpp_demangle_data *);
static int cpp_demangle_read_number(struct cpp_demangle_data *, long *);
+static int cpp_demangle_read_number_as_string(struct cpp_demangle_data *,
+ char **);
static int cpp_demangle_read_nv_offset(struct cpp_demangle_data *);
static int cpp_demangle_read_offset(struct cpp_demangle_data *);
static int cpp_demangle_read_offset_number(struct cpp_demangle_data *);
@@ -423,6 +429,8 @@ static int cpp_demangle_read_tmpl_arg(struct cpp_demangle_data *);
static int cpp_demangle_read_tmpl_args(struct cpp_demangle_data *);
static int cpp_demangle_read_tmpl_param(struct cpp_demangle_data *);
static int cpp_demangle_read_type(struct cpp_demangle_data *, int);
+static int cpp_demangle_read_type_flat(struct cpp_demangle_data *,
+ char **);
static int cpp_demangle_read_uqname(struct cpp_demangle_data *);
static int cpp_demangle_read_v_offset(struct cpp_demangle_data *);
static char *decode_fp_to_double(const char *, size_t);
@@ -601,17 +609,18 @@ cpp_demangle_push_fp(struct cpp_demangle_data *ddata,
fp = ddata->cur;
while (*ddata->cur != 'E')
++ddata->cur;
- ++ddata->cur;
if ((f = decoder(fp, ddata->cur - fp)) == NULL)
return (0);
rtn = 0;
if ((len = strlen(f)) > 0)
- rtn = cpp_demangle_push_str(ddata, f, len);
+ rtn = cpp_demangle_push_str(ddata, f, len);
free(f);
+ ++ddata->cur;
+
return (rtn);
}
@@ -695,7 +704,8 @@ cpp_demangle_push_type_qualifier(struct cpp_demangle_data *ddata,
if (type_str != NULL) {
if (!vector_str_push(&subst_v, "*", 1))
goto clean;
- if (!cpp_demangle_push_subst_v(ddata, &subst_v))
+ if (!cpp_demangle_push_subst_v(ddata,
+ &subst_v))
goto clean;
}
break;
@@ -706,7 +716,8 @@ cpp_demangle_push_type_qualifier(struct cpp_demangle_data *ddata,
if (type_str != NULL) {
if (!vector_str_push(&subst_v, "&", 1))
goto clean;
- if (!cpp_demangle_push_subst_v(ddata, &subst_v))
+ if (!cpp_demangle_push_subst_v(ddata,
+ &subst_v))
goto clean;
}
break;
@@ -717,7 +728,8 @@ cpp_demangle_push_type_qualifier(struct cpp_demangle_data *ddata,
if (type_str != NULL) {
if (!vector_str_push(&subst_v, " complex", 8))
goto clean;
- if (!cpp_demangle_push_subst_v(ddata, &subst_v))
+ if (!cpp_demangle_push_subst_v(ddata,
+ &subst_v))
goto clean;
}
break;
@@ -726,23 +738,26 @@ cpp_demangle_push_type_qualifier(struct cpp_demangle_data *ddata,
if (!cpp_demangle_push_str(ddata, " imaginary", 10))
goto clean;
if (type_str != NULL) {
- if (!vector_str_push(&subst_v, " imaginary", 10))
+ if (!vector_str_push(&subst_v, " imaginary",
+ 10))
goto clean;
- if (!cpp_demangle_push_subst_v(ddata, &subst_v))
+ if (!cpp_demangle_push_subst_v(ddata,
+ &subst_v))
goto clean;
}
break;
case TYPE_EXT:
- if (e_idx > v->ext_name.size - 1)
+ if (v->ext_name.size == 0 ||
+ e_idx > v->ext_name.size - 1)
goto clean;
- if ((e_len = strlen(v->ext_name.container[e_idx])) == 0)
+ if ((e_len = strlen(v->ext_name.container[e_idx])) ==
+ 0)
goto clean;
- if ((buf = malloc(sizeof(char) * (e_len + 1))) == NULL)
+ if ((buf = malloc(e_len + 2)) == NULL)
goto clean;
-
- memcpy(buf, " ", 1);
- memcpy(buf + 1, v->ext_name.container[e_idx], e_len);
+ snprintf(buf, e_len + 2, " %s",
+ v->ext_name.container[e_idx]);
if (!cpp_demangle_push_str(ddata, buf, e_len + 1)) {
free(buf);
@@ -755,7 +770,8 @@ cpp_demangle_push_type_qualifier(struct cpp_demangle_data *ddata,
free(buf);
goto clean;
}
- if (!cpp_demangle_push_subst_v(ddata, &subst_v)) {
+ if (!cpp_demangle_push_subst_v(ddata,
+ &subst_v)) {
free(buf);
goto clean;
}
@@ -770,7 +786,8 @@ cpp_demangle_push_type_qualifier(struct cpp_demangle_data *ddata,
if (type_str != NULL) {
if (!vector_str_push(&subst_v, " restrict", 9))
goto clean;
- if (!cpp_demangle_push_subst_v(ddata, &subst_v))
+ if (!cpp_demangle_push_subst_v(ddata,
+ &subst_v))
goto clean;
}
break;
@@ -781,7 +798,8 @@ cpp_demangle_push_type_qualifier(struct cpp_demangle_data *ddata,
if (type_str != NULL) {
if (!vector_str_push(&subst_v, " volatile", 9))
goto clean;
- if (!cpp_demangle_push_subst_v(ddata, &subst_v))
+ if (!cpp_demangle_push_subst_v(ddata,
+ &subst_v))
goto clean;
}
break;
@@ -792,11 +810,42 @@ cpp_demangle_push_type_qualifier(struct cpp_demangle_data *ddata,
if (type_str != NULL) {
if (!vector_str_push(&subst_v, " const", 6))
goto clean;
- if (!cpp_demangle_push_subst_v(ddata, &subst_v))
+ if (!cpp_demangle_push_subst_v(ddata,
+ &subst_v))
goto clean;
}
break;
+ case TYPE_VEC:
+ if (v->ext_name.size == 0 ||
+ e_idx > v->ext_name.size - 1)
+ goto clean;
+ if ((e_len = strlen(v->ext_name.container[e_idx])) ==
+ 0)
+ goto clean;
+ if ((buf = malloc(e_len + 12)) == NULL)
+ goto clean;
+ snprintf(buf, e_len + 12, " __vector(%s)",
+ v->ext_name.container[e_idx]);
+ if (!cpp_demangle_push_str(ddata, buf, e_len + 11)) {
+ free(buf);
+ goto clean;
+ }
+ if (type_str != NULL) {
+ if (!vector_str_push(&subst_v, buf,
+ e_len + 11)) {
+ free(buf);
+ goto clean;
+ }
+ if (!cpp_demangle_push_subst_v(ddata,
+ &subst_v)) {
+ free(buf);
+ goto clean;
+ }
+ }
+ free(buf);
+ ++e_idx;
+ break;
};
--idx;
}
@@ -947,10 +996,14 @@ cpp_demangle_read_expr_primary(struct cpp_demangle_data *ddata)
switch (*ddata->cur) {
case 'b':
+ if (*(ddata->cur + 2) != 'E')
+ return (0);
switch (*(++ddata->cur)) {
case '0':
+ ddata->cur += 2;
return (cpp_demangle_push_str(ddata, "false", 5));
case '1':
+ ddata->cur += 2;
return (cpp_demangle_push_str(ddata, "true", 4));
default:
return (0);
@@ -999,7 +1052,8 @@ cpp_demangle_read_expr_primary(struct cpp_demangle_data *ddata)
++ddata->cur;
}
++ddata->cur;
- return (cpp_demangle_push_str(ddata, num, ddata->cur - num));
+ return (cpp_demangle_push_str(ddata, num,
+ ddata->cur - num - 1));
default:
return (0);
@@ -1291,6 +1345,38 @@ cpp_demangle_read_expression(struct cpp_demangle_data *ddata)
}
static int
+cpp_demangle_read_expression_flat(struct cpp_demangle_data *ddata, char **str)
+{
+ struct vector_str *output;
+ size_t i, p_idx, idx, exp_len;
+ char *exp;
+
+ output = ddata->push_head > 0 ? &ddata->output_tmp :
+ &ddata->output;
+
+ p_idx = output->size;
+
+ if (!cpp_demangle_read_expression(ddata))
+ return (0);
+
+ if ((exp = vector_str_substr(output, p_idx, output->size - 1,
+ &exp_len)) == NULL)
+ return (0);
+
+ idx = output->size;
+ for (i = p_idx; i < idx; ++i) {
+ if (!vector_str_pop(output)) {
+ free(exp);
+ return (0);
+ }
+ }
+
+ *str = exp;
+
+ return (1);
+}
+
+static int
cpp_demangle_read_expression_binary(struct cpp_demangle_data *ddata,
const char *name, size_t len)
{
@@ -1419,12 +1505,65 @@ cpp_demangle_read_function(struct cpp_demangle_data *ddata, int *ext_c,
static int
cpp_demangle_read_encoding(struct cpp_demangle_data *ddata)
{
+ char *name, *type, *num_str;
+ long offset;
+ int rtn;
if (ddata == NULL || *ddata->cur == '\0')
return (0);
/* special name */
switch (SIMPLE_HASH(*ddata->cur, *(ddata->cur + 1))) {
+ case SIMPLE_HASH('G', 'A'):
+ if (!cpp_demangle_push_str(ddata, "hidden alias for ", 17))
+ return (0);
+ ddata->cur += 2;
+ if (*ddata->cur == '\0')
+ return (0);
+ return (cpp_demangle_read_encoding(ddata));
+
+ case SIMPLE_HASH('G', 'R'):
+ if (!cpp_demangle_push_str(ddata, "reference temporary #", 21))
+ return (0);
+ ddata->cur += 2;
+ if (*ddata->cur == '\0')
+ return (0);
+ if (!cpp_demangle_read_name_flat(ddata, &name))
+ return (0);
+ rtn = 0;
+ if (!cpp_demangle_read_number_as_string(ddata, &num_str))
+ goto clean1;
+ if (!cpp_demangle_push_str(ddata, num_str, strlen(num_str)))
+ goto clean2;
+ if (!cpp_demangle_push_str(ddata, " for ", 5))
+ goto clean2;
+ if (!cpp_demangle_push_str(ddata, name, strlen(name)))
+ goto clean2;
+ rtn = 1;
+ clean2:
+ free(num_str);
+ clean1:
+ free(name);
+ return (rtn);
+
+ case SIMPLE_HASH('G', 'T'):
+ ddata->cur += 2;
+ if (*ddata->cur == '\0')
+ return (0);
+ switch (*ddata->cur) {
+ case 'n':
+ if (!cpp_demangle_push_str(ddata,
+ "non-transaction clone for ", 26))
+ return (0);
+ case 't':
+ default:
+ if (!cpp_demangle_push_str(ddata,
+ "transaction clone for ", 22))
+ return (0);
+ }
+ ++ddata->cur;
+ return (cpp_demangle_read_encoding(ddata));
+
case SIMPLE_HASH('G', 'V'):
/* sentry object for 1 time init */
if (!cpp_demangle_push_str(ddata, "guard variable for ", 20))
@@ -1446,14 +1585,49 @@ cpp_demangle_read_encoding(struct cpp_demangle_data *ddata)
return (0);
return (cpp_demangle_read_encoding(ddata));
+ case SIMPLE_HASH('T', 'C'):
+ /* construction vtable */
+ if (!cpp_demangle_push_str(ddata, "construction vtable for ",
+ 24))
+ return (0);
+ ddata->cur += 2;
+ if (*ddata->cur == '\0')
+ return (0);
+ if (!cpp_demangle_read_type_flat(ddata, &type))
+ return (0);
+ rtn = 0;
+ if (!cpp_demangle_read_number(ddata, &offset))
+ goto clean3;
+ if (*ddata->cur++ != '_')
+ goto clean3;
+ if (!cpp_demangle_read_type(ddata, 0))
+ goto clean3;
+ if (!cpp_demangle_push_str(ddata, "-in-", 4))
+ goto clean3;
+ if (!cpp_demangle_push_str(ddata, type, strlen(type)))
+ goto clean3;
+ rtn = 1;
+ clean3:
+ free(type);
+ return (rtn);
+
case SIMPLE_HASH('T', 'D'):
/* typeinfo common proxy */
break;
+ case SIMPLE_HASH('T', 'F'):
+ /* typeinfo fn */
+ if (!cpp_demangle_push_str(ddata, "typeinfo fn for ", 16))
+ return (0);
+ ddata->cur += 2;
+ if (*ddata->cur == '\0')
+ return (0);
+ return (cpp_demangle_read_type(ddata, 0));
+
case SIMPLE_HASH('T', 'h'):
/* virtual function non-virtual override thunk */
- if (cpp_demangle_push_str(ddata,
- "virtual function non-virtual override ", 38) == 0)
+ if (!cpp_demangle_push_str(ddata,
+ "virtual function non-virtual override ", 38))
return (0);
ddata->cur += 2;
if (*ddata->cur == '\0')
@@ -1462,24 +1636,51 @@ cpp_demangle_read_encoding(struct cpp_demangle_data *ddata)
return (0);
return (cpp_demangle_read_encoding(ddata));
+ case SIMPLE_HASH('T', 'H'):
+ /* TLS init function */
+ if (!cpp_demangle_push_str(ddata, "TLS init function for ",
+ 22))
+ return (0);
+ ddata->cur += 2;
+ if (*ddata->cur == '\0')
+ return (0);
+ break;
+
case SIMPLE_HASH('T', 'I'):
/* typeinfo structure */
- /* FALLTHROUGH */
+ if (!cpp_demangle_push_str(ddata, "typeinfo for ", 13))
+ return (0);
+ ddata->cur += 2;
+ if (*ddata->cur == '\0')
+ return (0);
+ return (cpp_demangle_read_type(ddata, 0));
+
+ case SIMPLE_HASH('T', 'J'):
+ /* java class */
+ if (!cpp_demangle_push_str(ddata, "java Class for ", 15))
+ return (0);
+ ddata->cur += 2;
+ if (*ddata->cur == '\0')
+ return (0);
+ return (cpp_demangle_read_type(ddata, 0));
+
case SIMPLE_HASH('T', 'S'):
/* RTTI name (NTBS) */
- if (!cpp_demangle_push_str(ddata, "typeinfo for ", 14))
+ if (!cpp_demangle_push_str(ddata, "typeinfo name for ", 18))
return (0);
ddata->cur += 2;
if (*ddata->cur == '\0')
return (0);
- return (cpp_demangle_read_type(ddata, 1));
+ return (cpp_demangle_read_type(ddata, 0));
case SIMPLE_HASH('T', 'T'):
/* VTT table */
if (!cpp_demangle_push_str(ddata, "VTT for ", 8))
return (0);
ddata->cur += 2;
- return (cpp_demangle_read_type(ddata, 1));
+ if (*ddata->cur == '\0')
+ return (0);
+ return (cpp_demangle_read_type(ddata, 0));
case SIMPLE_HASH('T', 'v'):
/* virtual function virtual override thunk */
@@ -1500,7 +1701,17 @@ cpp_demangle_read_encoding(struct cpp_demangle_data *ddata)
ddata->cur += 2;
if (*ddata->cur == '\0')
return (0);
- return (cpp_demangle_read_type(ddata, 1));
+ return (cpp_demangle_read_type(ddata, 0));
+
+ case SIMPLE_HASH('T', 'W'):
+ /* TLS wrapper function */
+ if (!cpp_demangle_push_str(ddata, "TLS wrapper function for ",
+ 25))
+ return (0);
+ ddata->cur += 2;
+ if (*ddata->cur == '\0')
+ return (0);
+ break;
};
return (cpp_demangle_read_name(ddata));
@@ -1618,6 +1829,38 @@ clean:
}
static int
+cpp_demangle_read_name_flat(struct cpp_demangle_data *ddata, char **str)
+{
+ struct vector_str *output;
+ size_t i, p_idx, idx, name_len;
+ char *name;
+
+ output = ddata->push_head > 0 ? &ddata->output_tmp :
+ &ddata->output;
+
+ p_idx = output->size;
+
+ if (!cpp_demangle_read_name(ddata))
+ return (0);
+
+ if ((name = vector_str_substr(output, p_idx, output->size - 1,
+ &name_len)) == NULL)
+ return (0);
+
+ idx = output->size;
+ for (i = p_idx; i < idx; ++i) {
+ if (!vector_str_pop(output)) {
+ free(name);
+ return (0);
+ }
+ }
+
+ *str = name;
+
+ return (1);
+}
+
+static int
cpp_demangle_read_nested_name(struct cpp_demangle_data *ddata)
{
struct vector_str *output, v;
@@ -1743,6 +1986,24 @@ cpp_demangle_read_number(struct cpp_demangle_data *ddata, long *rtn)
}
static int
+cpp_demangle_read_number_as_string(struct cpp_demangle_data *ddata, char **str)
+{
+ long n;
+
+ if (!cpp_demangle_read_number(ddata, &n)) {
+ *str = NULL;
+ return (0);
+ }
+
+ if (asprintf(str, "%ld", n) < 0) {
+ *str = NULL;
+ return (0);
+ }
+
+ return (1);
+}
+
+static int
cpp_demangle_read_nv_offset(struct cpp_demangle_data *ddata)
{
@@ -1877,11 +2138,11 @@ cpp_demangle_read_sname(struct cpp_demangle_data *ddata)
len <= 0)
return (0);
- if (len == 12 && (memcmp("_GLOBAL__N_1", ddata->cur, 12) == 0))
+ if (len == 12 && (memcmp("_GLOBAL__N_1", ddata->cur, 12) == 0))
err = cpp_demangle_push_str(ddata, "(anonymous namespace)", 21);
else
err = cpp_demangle_push_str(ddata, ddata->cur, len);
-
+
if (err == 0)
return (0);
@@ -2232,7 +2493,7 @@ cpp_demangle_read_type(struct cpp_demangle_data *ddata, int delimit)
size_t p_idx, type_str_len;
int extern_c, is_builtin;
long len;
- char *type_str;
+ char *type_str, *exp_str, *num_str;
if (ddata == NULL)
return (0);
@@ -2274,7 +2535,7 @@ cpp_demangle_read_type(struct cpp_demangle_data *ddata, int delimit)
extern_c = 0;
is_builtin = 1;
p_idx = output->size;
- type_str = NULL;
+ type_str = exp_str = num_str = NULL;
again:
/* builtin type */
switch (*ddata->cur) {
@@ -2320,6 +2581,82 @@ again:
++ddata->cur;
goto rtn;
+ case 'D':
+ ++ddata->cur;
+ switch (*ddata->cur) {
+ case 'd':
+ /* IEEE 754r decimal floating point (64 bits) */
+ if (!cpp_demangle_push_str(ddata, "decimal64", 9))
+ goto clean;
+ ++ddata->cur;
+ break;
+ case 'e':
+ /* IEEE 754r decimal floating point (128 bits) */
+ if (!cpp_demangle_push_str(ddata, "decimal128", 10))
+ goto clean;
+ ++ddata->cur;
+ break;
+ case 'f':
+ /* IEEE 754r decimal floating point (32 bits) */
+ if (!cpp_demangle_push_str(ddata, "decimal32", 9))
+ goto clean;
+ ++ddata->cur;
+ break;
+ case 'h':
+ /* IEEE 754r half-precision floating point (16 bits) */
+ if (!cpp_demangle_push_str(ddata, "half", 4))
+ goto clean;
+ ++ddata->cur;
+ break;
+ case 'i':
+ /* char32_t */
+ if (!cpp_demangle_push_str(ddata, "char32_t", 8))
+ goto clean;
+ ++ddata->cur;
+ break;
+ case 'n':
+ /* std::nullptr_t (i.e., decltype(nullptr)) */
+ if (!cpp_demangle_push_str(ddata, "decltype(nullptr)",
+ 17))
+ goto clean;
+ ++ddata->cur;
+ break;
+ case 's':
+ /* char16_t */
+ if (!cpp_demangle_push_str(ddata, "char16_t", 8))
+ goto clean;
+ ++ddata->cur;
+ break;
+ case 'v':
+ /* gcc vector_size extension. */
+ ++ddata->cur;
+ if (*ddata->cur == '_') {
+ ++ddata->cur;
+ if (!cpp_demangle_read_expression_flat(ddata,
+ &exp_str))
+ goto clean;
+ if (!vector_str_push(&v.ext_name, exp_str,
+ strlen(exp_str)))
+ goto clean;
+ } else {
+ if (!cpp_demangle_read_number_as_string(ddata,
+ &num_str))
+ goto clean;
+ if (!vector_str_push(&v.ext_name, num_str,
+ strlen(num_str)))
+ goto clean;
+ }
+ if (*ddata->cur != '_')
+ goto clean;
+ ++ddata->cur;
+ if (!vector_type_qualifier_push(&v, TYPE_VEC))
+ goto clean;
+ goto again;
+ default:
+ goto clean;
+ }
+ goto rtn;
+
case 'e':
/* long double */
if (!cpp_demangle_push_str(ddata, "long double", 11))
@@ -2414,7 +2751,7 @@ again:
case 'o':
/* unsigned __int128 */
- if (!cpp_demangle_push_str(ddata, "unsigned _;int128", 17))
+ if (!cpp_demangle_push_str(ddata, "unsigned __int128", 17))
goto clean;
++ddata->cur;
goto rtn;
@@ -2485,6 +2822,8 @@ again:
if (!vector_str_push(&v.ext_name, ddata->cur, len))
return (0);
ddata->cur += len;
+ if (!vector_type_qualifier_push(&v, TYPE_EXT))
+ goto clean;
goto again;
case 'v':
@@ -2549,6 +2888,8 @@ rtn:
goto clean;
free(type_str);
+ free(exp_str);
+ free(num_str);
vector_type_qualifier_dest(&v);
if (ddata->push_head > 0) {
@@ -2580,11 +2921,45 @@ rtn:
return (1);
clean:
free(type_str);
+ free(exp_str);
+ free(num_str);
vector_type_qualifier_dest(&v);
return (0);
}
+static int
+cpp_demangle_read_type_flat(struct cpp_demangle_data *ddata, char **str)
+{
+ struct vector_str *output;
+ size_t i, p_idx, idx, type_len;
+ char *type;
+
+ output = ddata->push_head > 0 ? &ddata->output_tmp :
+ &ddata->output;
+
+ p_idx = output->size;
+
+ if (!cpp_demangle_read_type(ddata, 0))
+ return (0);
+
+ if ((type = vector_str_substr(output, p_idx, output->size - 1,
+ &type_len)) == NULL)
+ return (0);
+
+ idx = output->size;
+ for (i = p_idx; i < idx; ++i) {
+ if (!vector_str_pop(output)) {
+ free(type);
+ return (0);
+ }
+ }
+
+ *str = type;
+
+ return (1);
+}
+
/*
* read unqualified-name, unqualified name are operator-name, ctor-dtor-name,
* source-name
@@ -3008,39 +3383,38 @@ cpp_demangle_read_uqname(struct cpp_demangle_data *ddata)
if (ELFTC_ISDIGIT(*ddata->cur) != 0)
return (cpp_demangle_read_sname(ddata));
-
- /* local source name */
- if (*ddata->cur == 'L')
- return (cpp_demangle_local_source_name(ddata));
-
- return (1);
-}
-
-/*
- * Read local source name.
- *
- * References:
- * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31775
- * http://gcc.gnu.org/viewcvs?view=rev&revision=124467
- */
-static int
-cpp_demangle_local_source_name(struct cpp_demangle_data *ddata)
-{
- /* L */
- if (ddata == NULL || *ddata->cur != 'L')
- return (0);
- ++ddata->cur;
-
- /* source name */
- if (!cpp_demangle_read_sname(ddata))
- return (0);
-
- /* discriminator */
- if (*ddata->cur == '_') {
- ++ddata->cur;
- while (ELFTC_ISDIGIT(*ddata->cur) != 0)
- ++ddata->cur;
- }
+ /* local source name */
+ if (*ddata->cur == 'L')
+ return (cpp_demangle_local_source_name(ddata));
+
+ return (1);
+}
+
+/*
+ * Read local source name.
+ *
+ * References:
+ * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31775
+ * http://gcc.gnu.org/viewcvs?view=rev&revision=124467
+ */
+static int
+cpp_demangle_local_source_name(struct cpp_demangle_data *ddata)
+{
+ /* L */
+ if (ddata == NULL || *ddata->cur != 'L')
+ return (0);
+ ++ddata->cur;
+
+ /* source name */
+ if (!cpp_demangle_read_sname(ddata))
+ return (0);
+
+ /* discriminator */
+ if (*ddata->cur == '_') {
+ ++ddata->cur;
+ while (ELFTC_ISDIGIT(*ddata->cur) != 0)
+ ++ddata->cur;
+ }
return (1);
}
diff --git a/etc/devd/usb.conf b/etc/devd/usb.conf
index 9baa070..3c3cd34 100644
--- a/etc/devd/usb.conf
+++ b/etc/devd/usb.conf
@@ -145,7 +145,7 @@ nomatch 32 {
match "bus" "uhub[0-9]+";
match "mode" "host";
match "vendor" "0x0403";
- match "product" "(0x6001|0x6004|0x6006|0x6006|0x6010|0x6011|0x6014|0x6015|0x8372|0x9378|0x9379|0x937a|0x937c|0x9868|0x9e90|0x9f80|0xa6d0|0xa6d1|0xabb8|0xb810|0xb811|0xb812|0xbaf8|0xbbe2|0xbca0|0xbca1|0xbca2|0xbca4|0xbcd8|0xbcd9|0xbcda|0xbdc8|0xbfd8|0xbfd9|0xbfda|0xbfdb|0xbfdc|0xc7d0|0xc850|0xc991|0xcaa0|0xcc48|0xcc49|0xcc4a|0xd010|0xd011|0xd012|0xd013|0xd014|0xd015|0xd016|0xd017|0xd070|0xd071|0xd388|0xd389|0xd38a|0xd38b|0xd38c|0xd38d|0xd38e|0xd38f|0xd578|0xd678|0xd738|0xd780|0xdaf8|0xdaf9|0xdafa|0xdafb|0xdafc|0xdafd|0xdafe|0xdaff|0xdc00|0xdc01|0xdd20|0xdf28|0xdf30|0xdf31|0xdf32|0xdf33|0xdf35|0xe000|0xe001|0xe002|0xe004|0xe006|0xe008|0xe009|0xe00a|0xe050|0xe0e8|0xe0e9|0xe0ea|0xe0eb|0xe0ec|0xe0ed|0xe0ee|0xe0ef|0xe0f0|0xe0f1|0xe0f2|0xe0f3|0xe0f4|0xe0f5|0xe0f6|0xe0f7|0xe40b|0xe520|0xe548|0xe6c8|0xe700|0xe729|0xe808|0xe809|0xe80a|0xe80b|0xe80c|0xe80d|0xe80e|0xe80f|0xe888|0xe889|0xe88a|0xe88b|0xe88c|0xe88d|0xe88e|0xe88f|0xea90|0xebe0|0xec88|0xec89|0xed22|0xed71|0xed72|0xed73|0xed74|0xee18|0xeee8|0xeee9|0xeeea|0xeeeb|0xeeec|0xeeed|0xeeee|0xeeef|0xef50|0xef51|0xf068|0xf069|0xf06a|0xf06b|0xf06c|0xf06d|0xf06e|0xf06f|0xf070|0xf0c0|0xf0c8|0xf208|0xf2d0|0xf3c0|0xf3c1|0xf3c2|0xf448|0xf449|0xf44a|0xf44b|0xf44c|0xf460|0xf608|0xf60b|0xf680|0xf850|0xf857|0xf9d0|0xf9d1|0xf9d2|0xf9d3|0xf9d4|0xf9d5|0xfa00|0xfa01|0xfa02|0xfa03|0xfa04|0xfa05|0xfa06|0xfa10|0xfa33|0xfa88|0xfad0|0xfaf0|0xfb58|0xfb59|0xfb5a|0xfb5b|0xfb5c|0xfb5d|0xfb5e|0xfb5f|0xfb80|0xfb99|0xfbfa|0xfc08|0xfc09|0xfc0a|0xfc0b|0xfc0c|0xfc0d|0xfc0e|0xfc0f|0xfc60|0xfc70|0xfc71|0xfc72|0xfc73|0xfc82|0xfd60|0xfe38|0xff00|0xff18|0xff1c|0xff1d|0xff20|0xff38|0xff39|0xff3a|0xff3b|0xff3c|0xff3d|0xff3e|0xff3f|0xffa8)";
+ match "product" "(0x5259|0x6001|0x6004|0x6006|0x6006|0x6010|0x6011|0x6014|0x6015|0x8372|0x9378|0x9379|0x937a|0x937c|0x9868|0x9e90|0x9f80|0xa6d0|0xa6d1|0xabb8|0xb810|0xb811|0xb812|0xbaf8|0xbbe2|0xbca0|0xbca1|0xbca2|0xbca4|0xbcd8|0xbcd9|0xbcda|0xbdc8|0xbfd8|0xbfd9|0xbfda|0xbfdb|0xbfdc|0xc7d0|0xc850|0xc991|0xcaa0|0xcc48|0xcc49|0xcc4a|0xd010|0xd011|0xd012|0xd013|0xd014|0xd015|0xd016|0xd017|0xd070|0xd071|0xd388|0xd389|0xd38a|0xd38b|0xd38c|0xd38d|0xd38e|0xd38f|0xd578|0xd678|0xd738|0xd780|0xdaf8|0xdaf9|0xdafa|0xdafb|0xdafc|0xdafd|0xdafe|0xdaff|0xdc00|0xdc01|0xdd20|0xdf28|0xdf30|0xdf31|0xdf32|0xdf33|0xdf35|0xe000|0xe001|0xe002|0xe004|0xe006|0xe008|0xe009|0xe00a|0xe050|0xe0e8|0xe0e9|0xe0ea|0xe0eb|0xe0ec|0xe0ed|0xe0ee|0xe0ef|0xe0f0|0xe0f1|0xe0f2|0xe0f3|0xe0f4|0xe0f5|0xe0f6|0xe0f7|0xe40b|0xe520|0xe548|0xe6c8|0xe700|0xe729|0xe808|0xe809|0xe80a|0xe80b|0xe80c|0xe80d|0xe80e|0xe80f|0xe888|0xe889|0xe88a|0xe88b|0xe88c|0xe88d|0xe88e|0xe88f|0xea90|0xebe0|0xec88|0xec89|0xed22|0xed71|0xed72|0xed73|0xed74|0xee18|0xeee8|0xeee9|0xeeea|0xeeeb|0xeeec|0xeeed|0xeeee|0xeeef|0xef50|0xef51|0xf068|0xf069|0xf06a|0xf06b|0xf06c|0xf06d|0xf06e|0xf06f|0xf070|0xf0c0|0xf0c8|0xf208|0xf2d0|0xf3c0|0xf3c1|0xf3c2|0xf448|0xf449|0xf44a|0xf44b|0xf44c|0xf460|0xf608|0xf60b|0xf680|0xf850|0xf857|0xf9d0|0xf9d1|0xf9d2|0xf9d3|0xf9d4|0xf9d5|0xfa00|0xfa01|0xfa02|0xfa03|0xfa04|0xfa05|0xfa06|0xfa10|0xfa33|0xfa88|0xfad0|0xfaf0|0xfb58|0xfb59|0xfb5a|0xfb5b|0xfb5c|0xfb5d|0xfb5e|0xfb5f|0xfb80|0xfb99|0xfbfa|0xfc08|0xfc09|0xfc0a|0xfc0b|0xfc0c|0xfc0d|0xfc0e|0xfc0f|0xfc60|0xfc70|0xfc71|0xfc72|0xfc73|0xfc82|0xfd60|0xfe38|0xff00|0xff18|0xff1c|0xff1d|0xff20|0xff38|0xff39|0xff3a|0xff3b|0xff3c|0xff3d|0xff3e|0xff3f|0xffa8)";
action "kldload -n uftdi";
};
@@ -281,7 +281,7 @@ nomatch 32 {
match "bus" "uhub[0-9]+";
match "mode" "host";
match "vendor" "0x0411";
- match "product" "(0x0148|0x0150|0x015d|0x016f|0x01a2|0x01ee)";
+ match "product" "(0x0148|0x0150|0x015d|0x016f|0x01a2|0x01a8|0x01ee)";
action "kldload -n if_run";
};
@@ -1193,7 +1193,7 @@ nomatch 32 {
match "bus" "uhub[0-9]+";
match "mode" "host";
match "vendor" "0x05c6";
- match "product" "(0x1000|0x6000|0x6500|0x6613|0x9000|0x9204|0x9205)";
+ match "product" "(0x1000|0x6000|0x6500|0x6613|0x9000|0x9002|0x9204|0x9205)";
action "kldload -n u3g";
};
@@ -2561,7 +2561,7 @@ nomatch 32 {
match "bus" "uhub[0-9]+";
match "mode" "host";
match "vendor" "0x0bda";
- match "product" "(0x8176|0x8176|0x8177|0x8178|0x8179|0x817a|0x817b|0x817c|0x817d|0x817e|0x817f)";
+ match "product" "(0x8176|0x8177|0x8178|0x8179|0x817a|0x817b|0x817c|0x817d|0x817e|0x817f)";
action "kldload -n if_urtwn";
};
@@ -2577,7 +2577,7 @@ nomatch 32 {
match "bus" "uhub[0-9]+";
match "mode" "host";
match "vendor" "0x0bda";
- match "product" "0x818a";
+ match "product" "(0x818a|0x8191)";
action "kldload -n if_urtwn";
};
@@ -2680,6 +2680,14 @@ nomatch 32 {
nomatch 32 {
match "bus" "uhub[0-9]+";
match "mode" "host";
+ match "vendor" "0x0c45";
+ match "product" "0x7401";
+ action "kldload -n ugold";
+};
+
+nomatch 32 {
+ match "bus" "uhub[0-9]+";
+ match "mode" "host";
match "vendor" "0x0c52";
match "product" "(0x2101|0x2102|0x2103|0x2104|0x2211|0x2212|0x2213|0x2221|0x2222|0x2223|0x2411|0x2412|0x2413|0x2421|0x2422|0x2423|0x2431|0x2432|0x2433|0x2441|0x2442|0x2443|0x2811|0x2812|0x2813|0x2821|0x2822|0x2823|0x2831|0x2832|0x2833|0x2841|0x2842|0x2843|0x2851|0x2852|0x2853|0x2861|0x2862|0x2863|0x2871|0x2872|0x2873|0x2881|0x2882|0x2883|0x9020)";
action "kldload -n uftdi";
@@ -3521,7 +3529,7 @@ nomatch 32 {
match "bus" "uhub[0-9]+";
match "mode" "host";
match "vendor" "0x1199";
- match "product" "(0x6802|0x6803|0x6804|0x6805|0x6808|0x6809|0x6812|0x6813|0x6815|0x6816|0x6820|0x6821|0x6822|0x6832|0x6833|0x6834|0x6835|0x6838|0x6839|0x683a|0x683b|0x683c|0x683d|0x683e|0x6850|0x6851|0x6852|0x6853|0x6855|0x6856|0x6859|0x685a|0x6880|0x6890|0x6891|0x6892|0x6893|0x68a3)";
+ match "product" "(0x6802|0x6803|0x6804|0x6805|0x6808|0x6809|0x6812|0x6813|0x6815|0x6816|0x6820|0x6820|0x6821|0x6822|0x6832|0x6833|0x6834|0x6835|0x6838|0x6839|0x683a|0x683b|0x683c|0x683d|0x683e|0x6850|0x6851|0x6852|0x6853|0x6855|0x6856|0x6859|0x685a|0x6880|0x6890|0x6891|0x6892|0x6893|0x68a3)";
action "kldload -n u3g";
};
@@ -4424,6 +4432,22 @@ nomatch 32 {
nomatch 32 {
match "bus" "uhub[0-9]+";
match "mode" "host";
+ match "vendor" "0x17e9";
+ match "product" "(0x0059|0x0100|0x0117|0x0136|0x0138|0x0141|0x015a|0x0198|0x019b|0x01ba|0x01bb|0x01d4|0x01d7|0x01e2|0x0215|0x024c|0x02a9|0x0377|0x03e0|0x401a)";
+ action "kldload -n udl";
+};
+
+nomatch 32 {
+ match "bus" "uhub[0-9]+";
+ match "mode" "host";
+ match "vendor" "0x17ef";
+ match "product" "0x304b";
+ action "kldload -n if_axge";
+};
+
+nomatch 32 {
+ match "bus" "uhub[0-9]+";
+ match "mode" "host";
match "vendor" "0x17ef";
match "product" "0x7203";
action "kldload -n if_axe";
@@ -4505,7 +4529,7 @@ nomatch 32 {
match "bus" "uhub[0-9]+";
match "mode" "host";
match "vendor" "0x19d2";
- match "product" "(0x0001|0x0002|0x0003|0x0004|0x0005|0x0006|0x0007|0x0008|0x0009|0x000a|0x000b|0x000c|0x000d|0x000e|0x000f|0x0010|0x0011|0x0012|0x0013|0x0014|0x0015|0x0016|0x0017|0x0018|0x0019|0x0020|0x0021|0x0022|0x0023|0x0024|0x0025|0x0026|0x0027|0x0028|0x0029|0x0030|0x0031|0x0032|0x0033|0x0037|0x0039|0x0042|0x0043|0x0048|0x0049|0x0051|0x0052|0x0053|0x0054|0x0055|0x0057|0x0058|0x0059|0x0060|0x0061|0x0062|0x0063|0x0064|0x0066|0x0069|0x0070|0x0073|0x0076|0x0078|0x0082|0x0086|0x0117|0x1179|0x1181|0x1514|0x1516|0x2000|0x2002|0x2003|0xffdd|0xffde|0xfff1|0xfff5|0xfffe)";
+ match "product" "(0x0001|0x0002|0x0003|0x0004|0x0005|0x0006|0x0007|0x0008|0x0009|0x000a|0x000b|0x000c|0x000d|0x000e|0x000f|0x0010|0x0011|0x0012|0x0013|0x0014|0x0015|0x0016|0x0017|0x0018|0x0019|0x0020|0x0021|0x0022|0x0023|0x0024|0x0025|0x0026|0x0027|0x0028|0x0029|0x0030|0x0031|0x0032|0x0033|0x0037|0x0039|0x0042|0x0043|0x0048|0x0049|0x0051|0x0052|0x0053|0x0054|0x0055|0x0057|0x0058|0x0059|0x0060|0x0061|0x0062|0x0063|0x0064|0x0066|0x0069|0x0070|0x0073|0x0076|0x0078|0x0082|0x0086|0x0117|0x1179|0x1181|0x1420|0x1514|0x1516|0x2000|0x2002|0x2003|0xffdd|0xffde|0xfff1|0xfff5|0xfffe)";
action "kldload -n u3g";
};
@@ -4785,7 +4809,7 @@ nomatch 32 {
match "bus" "uhub[0-9]+";
match "mode" "host";
match "vendor" "0x2001";
- match "product" "(0x7e12|0xa805)";
+ match "product" "(0x7d02|0x7e12|0xa707|0xa805)";
action "kldload -n u3g";
};
@@ -5393,7 +5417,7 @@ nomatch 32 {
nomatch 32 {
match "bus" "uhub[0-9]+";
- match "mode" "host";
+ match "mode" "(host|device)";
match "intclass" "0x02";
match "intsubclass" "0x02";
match "intprotocol" "0x00";
@@ -5402,7 +5426,7 @@ nomatch 32 {
nomatch 32 {
match "bus" "uhub[0-9]+";
- match "mode" "host";
+ match "mode" "(host|device)";
match "intclass" "0x02";
match "intsubclass" "0x02";
match "intprotocol" "0x01";
@@ -5552,5 +5576,5 @@ nomatch 32 {
action "kldload -n umass";
};
-# 2658 USB entries processed
+# 2687 USB entries processed
diff --git a/gnu/lib/libgcc/Makefile b/gnu/lib/libgcc/Makefile
index f0efff4..6972146 100644
--- a/gnu/lib/libgcc/Makefile
+++ b/gnu/lib/libgcc/Makefile
@@ -338,7 +338,7 @@ libgcc_eh.a: ${EH_OBJS_T}
@${AR} ${ARFLAGS} ${.TARGET} `lorder ${EH_OBJS_T} | tsort -q`
${RANLIB} ${RANLIBFLAGS} ${.TARGET}
-all: libgcc_eh.a
+_LIBS+= libgcc_eh.a
.if ${MK_PROFILE} != "no"
libgcc_eh_p.a: ${EH_OBJS_P}
@@ -346,7 +346,8 @@ libgcc_eh_p.a: ${EH_OBJS_P}
@rm -f ${.TARGET}
@${AR} ${ARFLAGS} ${.TARGET} `lorder ${EH_OBJS_P} | tsort -q`
${RANLIB} ${RANLIBFLAGS} ${.TARGET}
-all: libgcc_eh_p.a
+
+_LIBS+= libgcc_eh_p.a
.endif
_libinstall: _lib-eh-install
diff --git a/gnu/lib/libgcc/Makefile.depend b/gnu/lib/libgcc/Makefile.depend
index ce72494..6dd413b 100644
--- a/gnu/lib/libgcc/Makefile.depend
+++ b/gnu/lib/libgcc/Makefile.depend
@@ -7,6 +7,7 @@ DIRDEPS = \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
+ usr.bin/xinstall.host \
.include <dirdeps.mk>
diff --git a/gnu/usr.bin/binutils/as/Makefile.depend b/gnu/usr.bin/binutils/as/Makefile.depend
index 1480a25..e48f450 100644
--- a/gnu/usr.bin/binutils/as/Makefile.depend
+++ b/gnu/usr.bin/binutils/as/Makefile.depend
@@ -3,6 +3,7 @@
DIRDEPS = \
gnu/lib/csu \
+ gnu/lib/libgcc \
gnu/usr.bin/binutils/libbfd \
gnu/usr.bin/binutils/libiberty \
gnu/usr.bin/binutils/libopcodes \
diff --git a/gnu/usr.bin/binutils/ld/Makefile.depend.amd64 b/gnu/usr.bin/binutils/ld/Makefile.depend.amd64
index 95df873..72682c3 100644
--- a/gnu/usr.bin/binutils/ld/Makefile.depend.amd64
+++ b/gnu/usr.bin/binutils/ld/Makefile.depend.amd64
@@ -3,6 +3,7 @@
DIRDEPS = \
gnu/lib/csu \
+ gnu/lib/libgcc \
gnu/usr.bin/binutils/libbfd \
gnu/usr.bin/binutils/libiberty \
include \
@@ -10,6 +11,7 @@ DIRDEPS = \
lib/${CSU_DIR} \
lib/libc \
lib/libcompiler_rt \
+ usr.bin/yacc.host \
.include <dirdeps.mk>
diff --git a/gnu/usr.bin/binutils/libbinutils/Makefile.depend b/gnu/usr.bin/binutils/libbinutils/Makefile.depend
index 74e2b22..f3e9e22 100644
--- a/gnu/usr.bin/binutils/libbinutils/Makefile.depend
+++ b/gnu/usr.bin/binutils/libbinutils/Makefile.depend
@@ -5,6 +5,7 @@ DIRDEPS = \
gnu/usr.bin/binutils/libbfd \
include \
include/xlocale \
+ usr.bin/yacc.host \
.include <dirdeps.mk>
diff --git a/include/Makefile.depend b/include/Makefile.depend
index f80275d..d7cfba0 100644
--- a/include/Makefile.depend
+++ b/include/Makefile.depend
@@ -2,6 +2,7 @@
# Autogenerated - do NOT edit!
DIRDEPS = \
+ usr.bin/xinstall.host \
.include <dirdeps.mk>
diff --git a/kerberos5/lib/libasn1/Makefile.depend b/kerberos5/lib/libasn1/Makefile.depend
index b944759..2b73dcd 100644
--- a/kerberos5/lib/libasn1/Makefile.depend
+++ b/kerberos5/lib/libasn1/Makefile.depend
@@ -12,6 +12,7 @@ DIRDEPS = \
lib/libc \
lib/libcom_err \
lib/libcompiler_rt \
+ usr.bin/xinstall.host \
.include <dirdeps.mk>
diff --git a/kerberos5/lib/libheimbase/Makefile.depend b/kerberos5/lib/libheimbase/Makefile.depend
index 7b92dbd..0a2f351 100644
--- a/kerberos5/lib/libheimbase/Makefile.depend
+++ b/kerberos5/lib/libheimbase/Makefile.depend
@@ -10,6 +10,7 @@ DIRDEPS = \
lib/libc \
lib/libcompiler_rt \
lib/libthr \
+ usr.bin/xinstall.host \
.include <dirdeps.mk>
diff --git a/kerberos5/lib/libheimipcc/Makefile.depend b/kerberos5/lib/libheimipcc/Makefile.depend
index 78a2d56..f59f10f 100644
--- a/kerberos5/lib/libheimipcc/Makefile.depend
+++ b/kerberos5/lib/libheimipcc/Makefile.depend
@@ -14,6 +14,7 @@ DIRDEPS = \
lib/libc \
lib/libcompiler_rt \
lib/libthr \
+ usr.bin/xinstall.host \
.include <dirdeps.mk>
diff --git a/kerberos5/lib/libhx509/Makefile b/kerberos5/lib/libhx509/Makefile
index 091fe8f..d7bedfc 100644
--- a/kerberos5/lib/libhx509/Makefile
+++ b/kerberos5/lib/libhx509/Makefile
@@ -268,7 +268,7 @@ CLEANFILES= ${GEN} ${GEN:S/.x$/.c/:S/.hx$/.h/} ocsp_asn1_files \
INCS+= ocsp_asn1.h pkcs10_asn1.h crmf_asn1.h
-.ORDER: ${GEN_OSCP}
+.ORDER: ${GEN_OCSP}
${GEN_OCSP}: ocsp.asn1 ocsp.opt
${ASN1_COMPILE} --option-file=${.ALLSRC:M*.opt} \
${.ALLSRC:M*.asn1} ocsp_asn1
diff --git a/kerberos5/lib/libhx509/Makefile.depend b/kerberos5/lib/libhx509/Makefile.depend
index 98eb044..d737a69 100644
--- a/kerberos5/lib/libhx509/Makefile.depend
+++ b/kerberos5/lib/libhx509/Makefile.depend
@@ -15,6 +15,8 @@ DIRDEPS = \
lib/libcom_err \
lib/libcompiler_rt \
secure/lib/libcrypto \
+ usr.bin/xinstall.host \
+ usr.bin/yacc.host \
.include <dirdeps.mk>
diff --git a/kerberos5/lib/libkrb5/Makefile.depend b/kerberos5/lib/libkrb5/Makefile.depend
index 0adc7b6..edf6cf8 100644
--- a/kerberos5/lib/libkrb5/Makefile.depend
+++ b/kerberos5/lib/libkrb5/Makefile.depend
@@ -19,6 +19,7 @@ DIRDEPS = \
lib/libcompiler_rt \
lib/libcrypt \
secure/lib/libcrypto \
+ usr.bin/xinstall.host \
.include <dirdeps.mk>
diff --git a/kerberos5/lib/libroken/Makefile.depend b/kerberos5/lib/libroken/Makefile.depend
index e280c94..102ac86 100644
--- a/kerberos5/lib/libroken/Makefile.depend
+++ b/kerberos5/lib/libroken/Makefile.depend
@@ -11,6 +11,7 @@ DIRDEPS = \
lib/libc \
lib/libcompiler_rt \
lib/libcrypt \
+ usr.bin/xinstall.host \
.include <dirdeps.mk>
diff --git a/kerberos5/lib/libwind/Makefile.depend b/kerberos5/lib/libwind/Makefile.depend
index 87bc4c1..6ed1a57 100644
--- a/kerberos5/lib/libwind/Makefile.depend
+++ b/kerberos5/lib/libwind/Makefile.depend
@@ -12,6 +12,7 @@ DIRDEPS = \
lib/libc \
lib/libcom_err \
lib/libcompiler_rt \
+ usr.bin/xinstall.host \
.include <dirdeps.mk>
diff --git a/lib/clang/liblldb/Makefile.depend b/lib/clang/liblldb/Makefile.depend
new file mode 100644
index 0000000..9e9f114
--- /dev/null
+++ b/lib/clang/liblldb/Makefile.depend
@@ -0,0 +1,28 @@
+# $FreeBSD$
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/libc++ \
+ lib/msun \
+ usr.bin/clang/clang-tblgen.host \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+lldb.o: AttrList.inc.h
+lldb.o: Attrs.inc.h
+lldb.o: CommentCommandList.inc.h
+lldb.o: DeclNodes.inc.h
+lldb.o: DiagnosticCommonKinds.inc.h
+lldb.o: StmtNodes.inc.h
+lldb.po: AttrList.inc.h
+lldb.po: Attrs.inc.h
+lldb.po: CommentCommandList.inc.h
+lldb.po: DeclNodes.inc.h
+lldb.po: DiagnosticCommonKinds.inc.h
+lldb.po: StmtNodes.inc.h
+.endif
diff --git a/lib/clang/liblldbAPI/Makefile.depend b/lib/clang/liblldbAPI/Makefile.depend
new file mode 100644
index 0000000..8c55ae9
--- /dev/null
+++ b/lib/clang/liblldbAPI/Makefile.depend
@@ -0,0 +1,338 @@
+# $FreeBSD$
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/libc++ \
+ lib/msun \
+ usr.bin/clang/clang-tblgen.host \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+SBAddress.o: CommentCommandList.inc.h
+SBAddress.o: DeclNodes.inc.h
+SBAddress.o: DiagnosticCommonKinds.inc.h
+SBAddress.o: StmtNodes.inc.h
+SBAddress.po: CommentCommandList.inc.h
+SBAddress.po: DeclNodes.inc.h
+SBAddress.po: DiagnosticCommonKinds.inc.h
+SBAddress.po: StmtNodes.inc.h
+SBBlock.o: DiagnosticCommonKinds.inc.h
+SBBlock.po: DiagnosticCommonKinds.inc.h
+SBBreakpoint.o: AttrList.inc.h
+SBBreakpoint.o: Attrs.inc.h
+SBBreakpoint.o: CommentCommandList.inc.h
+SBBreakpoint.o: DeclNodes.inc.h
+SBBreakpoint.o: DiagnosticCommonKinds.inc.h
+SBBreakpoint.o: StmtNodes.inc.h
+SBBreakpoint.po: AttrList.inc.h
+SBBreakpoint.po: Attrs.inc.h
+SBBreakpoint.po: CommentCommandList.inc.h
+SBBreakpoint.po: DeclNodes.inc.h
+SBBreakpoint.po: DiagnosticCommonKinds.inc.h
+SBBreakpoint.po: StmtNodes.inc.h
+SBBreakpointLocation.o: AttrList.inc.h
+SBBreakpointLocation.o: Attrs.inc.h
+SBBreakpointLocation.o: CommentCommandList.inc.h
+SBBreakpointLocation.o: DeclNodes.inc.h
+SBBreakpointLocation.o: DiagnosticCommonKinds.inc.h
+SBBreakpointLocation.o: StmtNodes.inc.h
+SBBreakpointLocation.po: AttrList.inc.h
+SBBreakpointLocation.po: Attrs.inc.h
+SBBreakpointLocation.po: CommentCommandList.inc.h
+SBBreakpointLocation.po: DeclNodes.inc.h
+SBBreakpointLocation.po: DiagnosticCommonKinds.inc.h
+SBBreakpointLocation.po: StmtNodes.inc.h
+SBCommandInterpreter.o: AttrList.inc.h
+SBCommandInterpreter.o: Attrs.inc.h
+SBCommandInterpreter.o: CommentCommandList.inc.h
+SBCommandInterpreter.o: DeclNodes.inc.h
+SBCommandInterpreter.o: DiagnosticCommonKinds.inc.h
+SBCommandInterpreter.o: StmtNodes.inc.h
+SBCommandInterpreter.po: AttrList.inc.h
+SBCommandInterpreter.po: Attrs.inc.h
+SBCommandInterpreter.po: CommentCommandList.inc.h
+SBCommandInterpreter.po: DeclNodes.inc.h
+SBCommandInterpreter.po: DiagnosticCommonKinds.inc.h
+SBCommandInterpreter.po: StmtNodes.inc.h
+SBCompileUnit.o: CommentCommandList.inc.h
+SBCompileUnit.o: DeclNodes.inc.h
+SBCompileUnit.o: DiagnosticCommonKinds.inc.h
+SBCompileUnit.o: StmtNodes.inc.h
+SBCompileUnit.po: CommentCommandList.inc.h
+SBCompileUnit.po: DeclNodes.inc.h
+SBCompileUnit.po: DiagnosticCommonKinds.inc.h
+SBCompileUnit.po: StmtNodes.inc.h
+SBDebugger.o: AttrList.inc.h
+SBDebugger.o: Attrs.inc.h
+SBDebugger.o: CommentCommandList.inc.h
+SBDebugger.o: DeclNodes.inc.h
+SBDebugger.o: DiagnosticCommonKinds.inc.h
+SBDebugger.o: StmtNodes.inc.h
+SBDebugger.po: AttrList.inc.h
+SBDebugger.po: Attrs.inc.h
+SBDebugger.po: CommentCommandList.inc.h
+SBDebugger.po: DeclNodes.inc.h
+SBDebugger.po: DiagnosticCommonKinds.inc.h
+SBDebugger.po: StmtNodes.inc.h
+SBEvent.o: AttrList.inc.h
+SBEvent.o: Attrs.inc.h
+SBEvent.o: CommentCommandList.inc.h
+SBEvent.o: DeclNodes.inc.h
+SBEvent.o: DiagnosticCommonKinds.inc.h
+SBEvent.o: StmtNodes.inc.h
+SBEvent.po: AttrList.inc.h
+SBEvent.po: Attrs.inc.h
+SBEvent.po: CommentCommandList.inc.h
+SBEvent.po: DeclNodes.inc.h
+SBEvent.po: DiagnosticCommonKinds.inc.h
+SBEvent.po: StmtNodes.inc.h
+SBExpressionOptions.o: DiagnosticCommonKinds.inc.h
+SBExpressionOptions.po: DiagnosticCommonKinds.inc.h
+SBFrame.o: DiagnosticCommonKinds.inc.h
+SBFrame.po: DiagnosticCommonKinds.inc.h
+SBFunction.o: CommentCommandList.inc.h
+SBFunction.o: DeclNodes.inc.h
+SBFunction.o: DiagnosticCommonKinds.inc.h
+SBFunction.o: StmtNodes.inc.h
+SBFunction.po: CommentCommandList.inc.h
+SBFunction.po: DeclNodes.inc.h
+SBFunction.po: DiagnosticCommonKinds.inc.h
+SBFunction.po: StmtNodes.inc.h
+SBInstruction.o: CommentCommandList.inc.h
+SBInstruction.o: DeclNodes.inc.h
+SBInstruction.o: DiagnosticCommonKinds.inc.h
+SBInstruction.o: StmtNodes.inc.h
+SBInstruction.po: CommentCommandList.inc.h
+SBInstruction.po: DeclNodes.inc.h
+SBInstruction.po: DiagnosticCommonKinds.inc.h
+SBInstruction.po: StmtNodes.inc.h
+SBInstructionList.o: CommentCommandList.inc.h
+SBInstructionList.o: DeclNodes.inc.h
+SBInstructionList.o: DiagnosticCommonKinds.inc.h
+SBInstructionList.o: StmtNodes.inc.h
+SBInstructionList.po: CommentCommandList.inc.h
+SBInstructionList.po: DeclNodes.inc.h
+SBInstructionList.po: DiagnosticCommonKinds.inc.h
+SBInstructionList.po: StmtNodes.inc.h
+SBListener.o: AttrList.inc.h
+SBListener.o: Attrs.inc.h
+SBListener.o: CommentCommandList.inc.h
+SBListener.o: DeclNodes.inc.h
+SBListener.o: DiagnosticCommonKinds.inc.h
+SBListener.o: StmtNodes.inc.h
+SBListener.po: AttrList.inc.h
+SBListener.po: Attrs.inc.h
+SBListener.po: CommentCommandList.inc.h
+SBListener.po: DeclNodes.inc.h
+SBListener.po: DiagnosticCommonKinds.inc.h
+SBListener.po: StmtNodes.inc.h
+SBModule.o: CommentCommandList.inc.h
+SBModule.o: DeclNodes.inc.h
+SBModule.o: DiagnosticCommonKinds.inc.h
+SBModule.o: StmtNodes.inc.h
+SBModule.po: CommentCommandList.inc.h
+SBModule.po: DeclNodes.inc.h
+SBModule.po: DiagnosticCommonKinds.inc.h
+SBModule.po: StmtNodes.inc.h
+SBModuleSpec.o: CommentCommandList.inc.h
+SBModuleSpec.o: DeclNodes.inc.h
+SBModuleSpec.o: DiagnosticCommonKinds.inc.h
+SBModuleSpec.o: StmtNodes.inc.h
+SBModuleSpec.po: CommentCommandList.inc.h
+SBModuleSpec.po: DeclNodes.inc.h
+SBModuleSpec.po: DiagnosticCommonKinds.inc.h
+SBModuleSpec.po: StmtNodes.inc.h
+SBPlatform.o: DiagnosticCommonKinds.inc.h
+SBPlatform.po: DiagnosticCommonKinds.inc.h
+SBProcess.o: AttrList.inc.h
+SBProcess.o: Attrs.inc.h
+SBProcess.o: CommentCommandList.inc.h
+SBProcess.o: DeclNodes.inc.h
+SBProcess.o: DiagnosticCommonKinds.inc.h
+SBProcess.o: StmtNodes.inc.h
+SBProcess.po: AttrList.inc.h
+SBProcess.po: Attrs.inc.h
+SBProcess.po: CommentCommandList.inc.h
+SBProcess.po: DeclNodes.inc.h
+SBProcess.po: DiagnosticCommonKinds.inc.h
+SBProcess.po: StmtNodes.inc.h
+SBQueue.o: DiagnosticCommonKinds.inc.h
+SBQueue.po: DiagnosticCommonKinds.inc.h
+SBQueueItem.o: DiagnosticCommonKinds.inc.h
+SBQueueItem.po: DiagnosticCommonKinds.inc.h
+SBSection.o: CommentCommandList.inc.h
+SBSection.o: DeclNodes.inc.h
+SBSection.o: DiagnosticCommonKinds.inc.h
+SBSection.o: StmtNodes.inc.h
+SBSection.po: CommentCommandList.inc.h
+SBSection.po: DeclNodes.inc.h
+SBSection.po: DiagnosticCommonKinds.inc.h
+SBSection.po: StmtNodes.inc.h
+SBSourceManager.o: AttrList.inc.h
+SBSourceManager.o: Attrs.inc.h
+SBSourceManager.o: CommentCommandList.inc.h
+SBSourceManager.o: DeclNodes.inc.h
+SBSourceManager.o: DiagnosticCommonKinds.inc.h
+SBSourceManager.o: StmtNodes.inc.h
+SBSourceManager.po: AttrList.inc.h
+SBSourceManager.po: Attrs.inc.h
+SBSourceManager.po: CommentCommandList.inc.h
+SBSourceManager.po: DeclNodes.inc.h
+SBSourceManager.po: DiagnosticCommonKinds.inc.h
+SBSourceManager.po: StmtNodes.inc.h
+SBSymbol.o: CommentCommandList.inc.h
+SBSymbol.o: DeclNodes.inc.h
+SBSymbol.o: DiagnosticCommonKinds.inc.h
+SBSymbol.o: StmtNodes.inc.h
+SBSymbol.po: CommentCommandList.inc.h
+SBSymbol.po: DeclNodes.inc.h
+SBSymbol.po: DiagnosticCommonKinds.inc.h
+SBSymbol.po: StmtNodes.inc.h
+SBSymbolContext.o: CommentCommandList.inc.h
+SBSymbolContext.o: DeclNodes.inc.h
+SBSymbolContext.o: DiagnosticCommonKinds.inc.h
+SBSymbolContext.o: StmtNodes.inc.h
+SBSymbolContext.po: CommentCommandList.inc.h
+SBSymbolContext.po: DeclNodes.inc.h
+SBSymbolContext.po: DiagnosticCommonKinds.inc.h
+SBSymbolContext.po: StmtNodes.inc.h
+SBTarget.o: AttrList.inc.h
+SBTarget.o: Attrs.inc.h
+SBTarget.o: CommentCommandList.inc.h
+SBTarget.o: DeclNodes.inc.h
+SBTarget.o: DiagnosticCommonKinds.inc.h
+SBTarget.o: StmtNodes.inc.h
+SBTarget.po: AttrList.inc.h
+SBTarget.po: Attrs.inc.h
+SBTarget.po: CommentCommandList.inc.h
+SBTarget.po: DeclNodes.inc.h
+SBTarget.po: DiagnosticCommonKinds.inc.h
+SBTarget.po: StmtNodes.inc.h
+SBThread.o: AttrList.inc.h
+SBThread.o: Attrs.inc.h
+SBThread.o: CommentCommandList.inc.h
+SBThread.o: DeclNodes.inc.h
+SBThread.o: DiagnosticCommonKinds.inc.h
+SBThread.o: StmtNodes.inc.h
+SBThread.po: AttrList.inc.h
+SBThread.po: Attrs.inc.h
+SBThread.po: CommentCommandList.inc.h
+SBThread.po: DeclNodes.inc.h
+SBThread.po: DiagnosticCommonKinds.inc.h
+SBThread.po: StmtNodes.inc.h
+SBThreadPlan.o: AttrList.inc.h
+SBThreadPlan.o: Attrs.inc.h
+SBThreadPlan.o: CommentCommandList.inc.h
+SBThreadPlan.o: DeclNodes.inc.h
+SBThreadPlan.o: DiagnosticCommonKinds.inc.h
+SBThreadPlan.o: StmtNodes.inc.h
+SBThreadPlan.po: AttrList.inc.h
+SBThreadPlan.po: Attrs.inc.h
+SBThreadPlan.po: CommentCommandList.inc.h
+SBThreadPlan.po: DeclNodes.inc.h
+SBThreadPlan.po: DiagnosticCommonKinds.inc.h
+SBThreadPlan.po: StmtNodes.inc.h
+SBType.o: CommentCommandList.inc.h
+SBType.o: DeclNodes.inc.h
+SBType.o: DiagnosticCommonKinds.inc.h
+SBType.o: StmtNodes.inc.h
+SBType.po: CommentCommandList.inc.h
+SBType.po: DeclNodes.inc.h
+SBType.po: DiagnosticCommonKinds.inc.h
+SBType.po: StmtNodes.inc.h
+SBTypeCategory.o: AttrList.inc.h
+SBTypeCategory.o: Attrs.inc.h
+SBTypeCategory.o: CommentCommandList.inc.h
+SBTypeCategory.o: DeclNodes.inc.h
+SBTypeCategory.o: DiagnosticCommonKinds.inc.h
+SBTypeCategory.o: StmtNodes.inc.h
+SBTypeCategory.po: AttrList.inc.h
+SBTypeCategory.po: Attrs.inc.h
+SBTypeCategory.po: CommentCommandList.inc.h
+SBTypeCategory.po: DeclNodes.inc.h
+SBTypeCategory.po: DiagnosticCommonKinds.inc.h
+SBTypeCategory.po: StmtNodes.inc.h
+SBTypeEnumMember.o: DiagnosticCommonKinds.inc.h
+SBTypeEnumMember.po: DiagnosticCommonKinds.inc.h
+SBTypeFilter.o: AttrList.inc.h
+SBTypeFilter.o: Attrs.inc.h
+SBTypeFilter.o: CommentCommandList.inc.h
+SBTypeFilter.o: DeclNodes.inc.h
+SBTypeFilter.o: DiagnosticCommonKinds.inc.h
+SBTypeFilter.o: StmtNodes.inc.h
+SBTypeFilter.po: AttrList.inc.h
+SBTypeFilter.po: Attrs.inc.h
+SBTypeFilter.po: CommentCommandList.inc.h
+SBTypeFilter.po: DeclNodes.inc.h
+SBTypeFilter.po: DiagnosticCommonKinds.inc.h
+SBTypeFilter.po: StmtNodes.inc.h
+SBTypeFormat.o: AttrList.inc.h
+SBTypeFormat.o: Attrs.inc.h
+SBTypeFormat.o: CommentCommandList.inc.h
+SBTypeFormat.o: DeclNodes.inc.h
+SBTypeFormat.o: DiagnosticCommonKinds.inc.h
+SBTypeFormat.o: StmtNodes.inc.h
+SBTypeFormat.po: AttrList.inc.h
+SBTypeFormat.po: Attrs.inc.h
+SBTypeFormat.po: CommentCommandList.inc.h
+SBTypeFormat.po: DeclNodes.inc.h
+SBTypeFormat.po: DiagnosticCommonKinds.inc.h
+SBTypeFormat.po: StmtNodes.inc.h
+SBTypeNameSpecifier.o: AttrList.inc.h
+SBTypeNameSpecifier.o: Attrs.inc.h
+SBTypeNameSpecifier.o: CommentCommandList.inc.h
+SBTypeNameSpecifier.o: DeclNodes.inc.h
+SBTypeNameSpecifier.o: DiagnosticCommonKinds.inc.h
+SBTypeNameSpecifier.o: StmtNodes.inc.h
+SBTypeNameSpecifier.po: AttrList.inc.h
+SBTypeNameSpecifier.po: Attrs.inc.h
+SBTypeNameSpecifier.po: CommentCommandList.inc.h
+SBTypeNameSpecifier.po: DeclNodes.inc.h
+SBTypeNameSpecifier.po: DiagnosticCommonKinds.inc.h
+SBTypeNameSpecifier.po: StmtNodes.inc.h
+SBTypeSummary.o: AttrList.inc.h
+SBTypeSummary.o: Attrs.inc.h
+SBTypeSummary.o: CommentCommandList.inc.h
+SBTypeSummary.o: DeclNodes.inc.h
+SBTypeSummary.o: DiagnosticCommonKinds.inc.h
+SBTypeSummary.o: StmtNodes.inc.h
+SBTypeSummary.po: AttrList.inc.h
+SBTypeSummary.po: Attrs.inc.h
+SBTypeSummary.po: CommentCommandList.inc.h
+SBTypeSummary.po: DeclNodes.inc.h
+SBTypeSummary.po: DiagnosticCommonKinds.inc.h
+SBTypeSummary.po: StmtNodes.inc.h
+SBTypeSynthetic.o: AttrList.inc.h
+SBTypeSynthetic.o: Attrs.inc.h
+SBTypeSynthetic.o: CommentCommandList.inc.h
+SBTypeSynthetic.o: DeclNodes.inc.h
+SBTypeSynthetic.o: DiagnosticCommonKinds.inc.h
+SBTypeSynthetic.o: StmtNodes.inc.h
+SBTypeSynthetic.po: AttrList.inc.h
+SBTypeSynthetic.po: Attrs.inc.h
+SBTypeSynthetic.po: CommentCommandList.inc.h
+SBTypeSynthetic.po: DeclNodes.inc.h
+SBTypeSynthetic.po: DiagnosticCommonKinds.inc.h
+SBTypeSynthetic.po: StmtNodes.inc.h
+SBUnixSignals.o: DiagnosticCommonKinds.inc.h
+SBUnixSignals.po: DiagnosticCommonKinds.inc.h
+SBValue.o: AttrList.inc.h
+SBValue.o: Attrs.inc.h
+SBValue.o: CommentCommandList.inc.h
+SBValue.o: DeclNodes.inc.h
+SBValue.o: DiagnosticCommonKinds.inc.h
+SBValue.o: StmtNodes.inc.h
+SBValue.po: AttrList.inc.h
+SBValue.po: Attrs.inc.h
+SBValue.po: CommentCommandList.inc.h
+SBValue.po: DeclNodes.inc.h
+SBValue.po: DiagnosticCommonKinds.inc.h
+SBValue.po: StmtNodes.inc.h
+SBWatchpoint.o: DiagnosticCommonKinds.inc.h
+SBWatchpoint.po: DiagnosticCommonKinds.inc.h
+.endif
diff --git a/lib/clang/liblldbBreakpoint/Makefile.depend b/lib/clang/liblldbBreakpoint/Makefile.depend
new file mode 100644
index 0000000..12728ea
--- /dev/null
+++ b/lib/clang/liblldbBreakpoint/Makefile.depend
@@ -0,0 +1,88 @@
+# $FreeBSD$
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/libc++ \
+ lib/msun \
+ usr.bin/clang/clang-tblgen.host \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+Breakpoint.o: CommentCommandList.inc.h
+Breakpoint.o: DeclNodes.inc.h
+Breakpoint.o: DiagnosticCommonKinds.inc.h
+Breakpoint.o: StmtNodes.inc.h
+Breakpoint.po: CommentCommandList.inc.h
+Breakpoint.po: DeclNodes.inc.h
+Breakpoint.po: DiagnosticCommonKinds.inc.h
+Breakpoint.po: StmtNodes.inc.h
+BreakpointIDList.o: DiagnosticCommonKinds.inc.h
+BreakpointIDList.po: DiagnosticCommonKinds.inc.h
+BreakpointList.o: DiagnosticCommonKinds.inc.h
+BreakpointList.po: DiagnosticCommonKinds.inc.h
+BreakpointLocation.o: AttrList.inc.h
+BreakpointLocation.o: Attrs.inc.h
+BreakpointLocation.o: CommentCommandList.inc.h
+BreakpointLocation.o: DeclNodes.inc.h
+BreakpointLocation.o: DiagnosticCommonKinds.inc.h
+BreakpointLocation.o: StmtNodes.inc.h
+BreakpointLocation.po: AttrList.inc.h
+BreakpointLocation.po: Attrs.inc.h
+BreakpointLocation.po: CommentCommandList.inc.h
+BreakpointLocation.po: DeclNodes.inc.h
+BreakpointLocation.po: DiagnosticCommonKinds.inc.h
+BreakpointLocation.po: StmtNodes.inc.h
+BreakpointLocationCollection.o: DiagnosticCommonKinds.inc.h
+BreakpointLocationCollection.po: DiagnosticCommonKinds.inc.h
+BreakpointLocationList.o: CommentCommandList.inc.h
+BreakpointLocationList.o: DeclNodes.inc.h
+BreakpointLocationList.o: DiagnosticCommonKinds.inc.h
+BreakpointLocationList.o: StmtNodes.inc.h
+BreakpointLocationList.po: CommentCommandList.inc.h
+BreakpointLocationList.po: DeclNodes.inc.h
+BreakpointLocationList.po: DiagnosticCommonKinds.inc.h
+BreakpointLocationList.po: StmtNodes.inc.h
+BreakpointOptions.o: DiagnosticCommonKinds.inc.h
+BreakpointOptions.po: DiagnosticCommonKinds.inc.h
+BreakpointResolver.o: DiagnosticCommonKinds.inc.h
+BreakpointResolver.po: DiagnosticCommonKinds.inc.h
+BreakpointResolverAddress.o: DiagnosticCommonKinds.inc.h
+BreakpointResolverAddress.po: DiagnosticCommonKinds.inc.h
+BreakpointResolverFileLine.o: CommentCommandList.inc.h
+BreakpointResolverFileLine.o: DeclNodes.inc.h
+BreakpointResolverFileLine.o: DiagnosticCommonKinds.inc.h
+BreakpointResolverFileLine.o: StmtNodes.inc.h
+BreakpointResolverFileLine.po: CommentCommandList.inc.h
+BreakpointResolverFileLine.po: DeclNodes.inc.h
+BreakpointResolverFileLine.po: DiagnosticCommonKinds.inc.h
+BreakpointResolverFileLine.po: StmtNodes.inc.h
+BreakpointResolverFileRegex.o: DiagnosticCommonKinds.inc.h
+BreakpointResolverFileRegex.po: DiagnosticCommonKinds.inc.h
+BreakpointResolverName.o: CommentCommandList.inc.h
+BreakpointResolverName.o: DeclNodes.inc.h
+BreakpointResolverName.o: DiagnosticCommonKinds.inc.h
+BreakpointResolverName.o: StmtNodes.inc.h
+BreakpointResolverName.po: CommentCommandList.inc.h
+BreakpointResolverName.po: DeclNodes.inc.h
+BreakpointResolverName.po: DiagnosticCommonKinds.inc.h
+BreakpointResolverName.po: StmtNodes.inc.h
+BreakpointSite.o: DiagnosticCommonKinds.inc.h
+BreakpointSite.po: DiagnosticCommonKinds.inc.h
+Watchpoint.o: CommentCommandList.inc.h
+Watchpoint.o: DeclNodes.inc.h
+Watchpoint.o: DiagnosticCommonKinds.inc.h
+Watchpoint.o: StmtNodes.inc.h
+Watchpoint.po: CommentCommandList.inc.h
+Watchpoint.po: DeclNodes.inc.h
+Watchpoint.po: DiagnosticCommonKinds.inc.h
+Watchpoint.po: StmtNodes.inc.h
+WatchpointList.o: DiagnosticCommonKinds.inc.h
+WatchpointList.po: DiagnosticCommonKinds.inc.h
+WatchpointOptions.o: DiagnosticCommonKinds.inc.h
+WatchpointOptions.po: DiagnosticCommonKinds.inc.h
+.endif
diff --git a/lib/clang/liblldbCommands/Makefile.depend b/lib/clang/liblldbCommands/Makefile.depend
new file mode 100644
index 0000000..a854483
--- /dev/null
+++ b/lib/clang/liblldbCommands/Makefile.depend
@@ -0,0 +1,352 @@
+# $FreeBSD$
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/libc++ \
+ lib/msun \
+ usr.bin/clang/clang-tblgen.host \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+CommandCompletions.o: AttrList.inc.h
+CommandCompletions.o: Attrs.inc.h
+CommandCompletions.o: CommentCommandList.inc.h
+CommandCompletions.o: DeclNodes.inc.h
+CommandCompletions.o: DiagnosticCommonKinds.inc.h
+CommandCompletions.o: StmtNodes.inc.h
+CommandCompletions.po: AttrList.inc.h
+CommandCompletions.po: Attrs.inc.h
+CommandCompletions.po: CommentCommandList.inc.h
+CommandCompletions.po: DeclNodes.inc.h
+CommandCompletions.po: DiagnosticCommonKinds.inc.h
+CommandCompletions.po: StmtNodes.inc.h
+CommandObjectApropos.o: AttrList.inc.h
+CommandObjectApropos.o: Attrs.inc.h
+CommandObjectApropos.o: CommentCommandList.inc.h
+CommandObjectApropos.o: DeclNodes.inc.h
+CommandObjectApropos.o: DiagnosticCommonKinds.inc.h
+CommandObjectApropos.o: StmtNodes.inc.h
+CommandObjectApropos.po: AttrList.inc.h
+CommandObjectApropos.po: Attrs.inc.h
+CommandObjectApropos.po: CommentCommandList.inc.h
+CommandObjectApropos.po: DeclNodes.inc.h
+CommandObjectApropos.po: DiagnosticCommonKinds.inc.h
+CommandObjectApropos.po: StmtNodes.inc.h
+CommandObjectArgs.o: AttrList.inc.h
+CommandObjectArgs.o: Attrs.inc.h
+CommandObjectArgs.o: CommentCommandList.inc.h
+CommandObjectArgs.o: DeclNodes.inc.h
+CommandObjectArgs.o: DiagnosticCommonKinds.inc.h
+CommandObjectArgs.o: StmtNodes.inc.h
+CommandObjectArgs.po: AttrList.inc.h
+CommandObjectArgs.po: Attrs.inc.h
+CommandObjectArgs.po: CommentCommandList.inc.h
+CommandObjectArgs.po: DeclNodes.inc.h
+CommandObjectArgs.po: DiagnosticCommonKinds.inc.h
+CommandObjectArgs.po: StmtNodes.inc.h
+CommandObjectBreakpoint.o: AttrList.inc.h
+CommandObjectBreakpoint.o: Attrs.inc.h
+CommandObjectBreakpoint.o: CommentCommandList.inc.h
+CommandObjectBreakpoint.o: DeclNodes.inc.h
+CommandObjectBreakpoint.o: DiagnosticCommonKinds.inc.h
+CommandObjectBreakpoint.o: StmtNodes.inc.h
+CommandObjectBreakpoint.po: AttrList.inc.h
+CommandObjectBreakpoint.po: Attrs.inc.h
+CommandObjectBreakpoint.po: CommentCommandList.inc.h
+CommandObjectBreakpoint.po: DeclNodes.inc.h
+CommandObjectBreakpoint.po: DiagnosticCommonKinds.inc.h
+CommandObjectBreakpoint.po: StmtNodes.inc.h
+CommandObjectBreakpointCommand.o: AttrList.inc.h
+CommandObjectBreakpointCommand.o: Attrs.inc.h
+CommandObjectBreakpointCommand.o: CommentCommandList.inc.h
+CommandObjectBreakpointCommand.o: DeclNodes.inc.h
+CommandObjectBreakpointCommand.o: DiagnosticCommonKinds.inc.h
+CommandObjectBreakpointCommand.o: StmtNodes.inc.h
+CommandObjectBreakpointCommand.po: AttrList.inc.h
+CommandObjectBreakpointCommand.po: Attrs.inc.h
+CommandObjectBreakpointCommand.po: CommentCommandList.inc.h
+CommandObjectBreakpointCommand.po: DeclNodes.inc.h
+CommandObjectBreakpointCommand.po: DiagnosticCommonKinds.inc.h
+CommandObjectBreakpointCommand.po: StmtNodes.inc.h
+CommandObjectCommands.o: AttrList.inc.h
+CommandObjectCommands.o: Attrs.inc.h
+CommandObjectCommands.o: CommentCommandList.inc.h
+CommandObjectCommands.o: DeclNodes.inc.h
+CommandObjectCommands.o: DiagnosticCommonKinds.inc.h
+CommandObjectCommands.o: StmtNodes.inc.h
+CommandObjectCommands.po: AttrList.inc.h
+CommandObjectCommands.po: Attrs.inc.h
+CommandObjectCommands.po: CommentCommandList.inc.h
+CommandObjectCommands.po: DeclNodes.inc.h
+CommandObjectCommands.po: DiagnosticCommonKinds.inc.h
+CommandObjectCommands.po: StmtNodes.inc.h
+CommandObjectDisassemble.o: AttrList.inc.h
+CommandObjectDisassemble.o: Attrs.inc.h
+CommandObjectDisassemble.o: CommentCommandList.inc.h
+CommandObjectDisassemble.o: DeclNodes.inc.h
+CommandObjectDisassemble.o: DiagnosticCommonKinds.inc.h
+CommandObjectDisassemble.o: StmtNodes.inc.h
+CommandObjectDisassemble.po: AttrList.inc.h
+CommandObjectDisassemble.po: Attrs.inc.h
+CommandObjectDisassemble.po: CommentCommandList.inc.h
+CommandObjectDisassemble.po: DeclNodes.inc.h
+CommandObjectDisassemble.po: DiagnosticCommonKinds.inc.h
+CommandObjectDisassemble.po: StmtNodes.inc.h
+CommandObjectExpression.o: AttrList.inc.h
+CommandObjectExpression.o: Attrs.inc.h
+CommandObjectExpression.o: CommentCommandList.inc.h
+CommandObjectExpression.o: DeclNodes.inc.h
+CommandObjectExpression.o: DiagnosticCommonKinds.inc.h
+CommandObjectExpression.o: StmtNodes.inc.h
+CommandObjectExpression.po: AttrList.inc.h
+CommandObjectExpression.po: Attrs.inc.h
+CommandObjectExpression.po: CommentCommandList.inc.h
+CommandObjectExpression.po: DeclNodes.inc.h
+CommandObjectExpression.po: DiagnosticCommonKinds.inc.h
+CommandObjectExpression.po: StmtNodes.inc.h
+CommandObjectFrame.o: AttrList.inc.h
+CommandObjectFrame.o: Attrs.inc.h
+CommandObjectFrame.o: CommentCommandList.inc.h
+CommandObjectFrame.o: DeclNodes.inc.h
+CommandObjectFrame.o: DiagnosticCommonKinds.inc.h
+CommandObjectFrame.o: StmtNodes.inc.h
+CommandObjectFrame.po: AttrList.inc.h
+CommandObjectFrame.po: Attrs.inc.h
+CommandObjectFrame.po: CommentCommandList.inc.h
+CommandObjectFrame.po: DeclNodes.inc.h
+CommandObjectFrame.po: DiagnosticCommonKinds.inc.h
+CommandObjectFrame.po: StmtNodes.inc.h
+CommandObjectGUI.o: AttrList.inc.h
+CommandObjectGUI.o: Attrs.inc.h
+CommandObjectGUI.o: CommentCommandList.inc.h
+CommandObjectGUI.o: DeclNodes.inc.h
+CommandObjectGUI.o: DiagnosticCommonKinds.inc.h
+CommandObjectGUI.o: StmtNodes.inc.h
+CommandObjectGUI.po: AttrList.inc.h
+CommandObjectGUI.po: Attrs.inc.h
+CommandObjectGUI.po: CommentCommandList.inc.h
+CommandObjectGUI.po: DeclNodes.inc.h
+CommandObjectGUI.po: DiagnosticCommonKinds.inc.h
+CommandObjectGUI.po: StmtNodes.inc.h
+CommandObjectHelp.o: AttrList.inc.h
+CommandObjectHelp.o: Attrs.inc.h
+CommandObjectHelp.o: CommentCommandList.inc.h
+CommandObjectHelp.o: DeclNodes.inc.h
+CommandObjectHelp.o: DiagnosticCommonKinds.inc.h
+CommandObjectHelp.o: StmtNodes.inc.h
+CommandObjectHelp.po: AttrList.inc.h
+CommandObjectHelp.po: Attrs.inc.h
+CommandObjectHelp.po: CommentCommandList.inc.h
+CommandObjectHelp.po: DeclNodes.inc.h
+CommandObjectHelp.po: DiagnosticCommonKinds.inc.h
+CommandObjectHelp.po: StmtNodes.inc.h
+CommandObjectLog.o: AttrList.inc.h
+CommandObjectLog.o: Attrs.inc.h
+CommandObjectLog.o: CommentCommandList.inc.h
+CommandObjectLog.o: DeclNodes.inc.h
+CommandObjectLog.o: DiagnosticCommonKinds.inc.h
+CommandObjectLog.o: StmtNodes.inc.h
+CommandObjectLog.po: AttrList.inc.h
+CommandObjectLog.po: Attrs.inc.h
+CommandObjectLog.po: CommentCommandList.inc.h
+CommandObjectLog.po: DeclNodes.inc.h
+CommandObjectLog.po: DiagnosticCommonKinds.inc.h
+CommandObjectLog.po: StmtNodes.inc.h
+CommandObjectMemory.o: AttrList.inc.h
+CommandObjectMemory.o: Attrs.inc.h
+CommandObjectMemory.o: CommentCommandList.inc.h
+CommandObjectMemory.o: DeclNodes.inc.h
+CommandObjectMemory.o: DiagnosticCommonKinds.inc.h
+CommandObjectMemory.o: StmtNodes.inc.h
+CommandObjectMemory.po: AttrList.inc.h
+CommandObjectMemory.po: Attrs.inc.h
+CommandObjectMemory.po: CommentCommandList.inc.h
+CommandObjectMemory.po: DeclNodes.inc.h
+CommandObjectMemory.po: DiagnosticCommonKinds.inc.h
+CommandObjectMemory.po: StmtNodes.inc.h
+CommandObjectMultiword.o: AttrList.inc.h
+CommandObjectMultiword.o: Attrs.inc.h
+CommandObjectMultiword.o: CommentCommandList.inc.h
+CommandObjectMultiword.o: DeclNodes.inc.h
+CommandObjectMultiword.o: DiagnosticCommonKinds.inc.h
+CommandObjectMultiword.o: StmtNodes.inc.h
+CommandObjectMultiword.po: AttrList.inc.h
+CommandObjectMultiword.po: Attrs.inc.h
+CommandObjectMultiword.po: CommentCommandList.inc.h
+CommandObjectMultiword.po: DeclNodes.inc.h
+CommandObjectMultiword.po: DiagnosticCommonKinds.inc.h
+CommandObjectMultiword.po: StmtNodes.inc.h
+CommandObjectPlatform.o: AttrList.inc.h
+CommandObjectPlatform.o: Attrs.inc.h
+CommandObjectPlatform.o: CommentCommandList.inc.h
+CommandObjectPlatform.o: DeclNodes.inc.h
+CommandObjectPlatform.o: DiagnosticCommonKinds.inc.h
+CommandObjectPlatform.o: StmtNodes.inc.h
+CommandObjectPlatform.po: AttrList.inc.h
+CommandObjectPlatform.po: Attrs.inc.h
+CommandObjectPlatform.po: CommentCommandList.inc.h
+CommandObjectPlatform.po: DeclNodes.inc.h
+CommandObjectPlatform.po: DiagnosticCommonKinds.inc.h
+CommandObjectPlatform.po: StmtNodes.inc.h
+CommandObjectPlugin.o: AttrList.inc.h
+CommandObjectPlugin.o: Attrs.inc.h
+CommandObjectPlugin.o: CommentCommandList.inc.h
+CommandObjectPlugin.o: DeclNodes.inc.h
+CommandObjectPlugin.o: DiagnosticCommonKinds.inc.h
+CommandObjectPlugin.o: StmtNodes.inc.h
+CommandObjectPlugin.po: AttrList.inc.h
+CommandObjectPlugin.po: Attrs.inc.h
+CommandObjectPlugin.po: CommentCommandList.inc.h
+CommandObjectPlugin.po: DeclNodes.inc.h
+CommandObjectPlugin.po: DiagnosticCommonKinds.inc.h
+CommandObjectPlugin.po: StmtNodes.inc.h
+CommandObjectProcess.o: AttrList.inc.h
+CommandObjectProcess.o: Attrs.inc.h
+CommandObjectProcess.o: CommentCommandList.inc.h
+CommandObjectProcess.o: DeclNodes.inc.h
+CommandObjectProcess.o: DiagnosticCommonKinds.inc.h
+CommandObjectProcess.o: StmtNodes.inc.h
+CommandObjectProcess.po: AttrList.inc.h
+CommandObjectProcess.po: Attrs.inc.h
+CommandObjectProcess.po: CommentCommandList.inc.h
+CommandObjectProcess.po: DeclNodes.inc.h
+CommandObjectProcess.po: DiagnosticCommonKinds.inc.h
+CommandObjectProcess.po: StmtNodes.inc.h
+CommandObjectQuit.o: AttrList.inc.h
+CommandObjectQuit.o: Attrs.inc.h
+CommandObjectQuit.o: CommentCommandList.inc.h
+CommandObjectQuit.o: DeclNodes.inc.h
+CommandObjectQuit.o: DiagnosticCommonKinds.inc.h
+CommandObjectQuit.o: StmtNodes.inc.h
+CommandObjectQuit.po: AttrList.inc.h
+CommandObjectQuit.po: Attrs.inc.h
+CommandObjectQuit.po: CommentCommandList.inc.h
+CommandObjectQuit.po: DeclNodes.inc.h
+CommandObjectQuit.po: DiagnosticCommonKinds.inc.h
+CommandObjectQuit.po: StmtNodes.inc.h
+CommandObjectRegister.o: AttrList.inc.h
+CommandObjectRegister.o: Attrs.inc.h
+CommandObjectRegister.o: CommentCommandList.inc.h
+CommandObjectRegister.o: DeclNodes.inc.h
+CommandObjectRegister.o: DiagnosticCommonKinds.inc.h
+CommandObjectRegister.o: StmtNodes.inc.h
+CommandObjectRegister.po: AttrList.inc.h
+CommandObjectRegister.po: Attrs.inc.h
+CommandObjectRegister.po: CommentCommandList.inc.h
+CommandObjectRegister.po: DeclNodes.inc.h
+CommandObjectRegister.po: DiagnosticCommonKinds.inc.h
+CommandObjectRegister.po: StmtNodes.inc.h
+CommandObjectSettings.o: AttrList.inc.h
+CommandObjectSettings.o: Attrs.inc.h
+CommandObjectSettings.o: CommentCommandList.inc.h
+CommandObjectSettings.o: DeclNodes.inc.h
+CommandObjectSettings.o: DiagnosticCommonKinds.inc.h
+CommandObjectSettings.o: StmtNodes.inc.h
+CommandObjectSettings.po: AttrList.inc.h
+CommandObjectSettings.po: Attrs.inc.h
+CommandObjectSettings.po: CommentCommandList.inc.h
+CommandObjectSettings.po: DeclNodes.inc.h
+CommandObjectSettings.po: DiagnosticCommonKinds.inc.h
+CommandObjectSettings.po: StmtNodes.inc.h
+CommandObjectSource.o: AttrList.inc.h
+CommandObjectSource.o: Attrs.inc.h
+CommandObjectSource.o: CommentCommandList.inc.h
+CommandObjectSource.o: DeclNodes.inc.h
+CommandObjectSource.o: DiagnosticCommonKinds.inc.h
+CommandObjectSource.o: StmtNodes.inc.h
+CommandObjectSource.po: AttrList.inc.h
+CommandObjectSource.po: Attrs.inc.h
+CommandObjectSource.po: CommentCommandList.inc.h
+CommandObjectSource.po: DeclNodes.inc.h
+CommandObjectSource.po: DiagnosticCommonKinds.inc.h
+CommandObjectSource.po: StmtNodes.inc.h
+CommandObjectSyntax.o: AttrList.inc.h
+CommandObjectSyntax.o: Attrs.inc.h
+CommandObjectSyntax.o: CommentCommandList.inc.h
+CommandObjectSyntax.o: DeclNodes.inc.h
+CommandObjectSyntax.o: DiagnosticCommonKinds.inc.h
+CommandObjectSyntax.o: StmtNodes.inc.h
+CommandObjectSyntax.po: AttrList.inc.h
+CommandObjectSyntax.po: Attrs.inc.h
+CommandObjectSyntax.po: CommentCommandList.inc.h
+CommandObjectSyntax.po: DeclNodes.inc.h
+CommandObjectSyntax.po: DiagnosticCommonKinds.inc.h
+CommandObjectSyntax.po: StmtNodes.inc.h
+CommandObjectTarget.o: AttrList.inc.h
+CommandObjectTarget.o: Attrs.inc.h
+CommandObjectTarget.o: CommentCommandList.inc.h
+CommandObjectTarget.o: DeclNodes.inc.h
+CommandObjectTarget.o: DiagnosticCommonKinds.inc.h
+CommandObjectTarget.o: StmtNodes.inc.h
+CommandObjectTarget.po: AttrList.inc.h
+CommandObjectTarget.po: Attrs.inc.h
+CommandObjectTarget.po: CommentCommandList.inc.h
+CommandObjectTarget.po: DeclNodes.inc.h
+CommandObjectTarget.po: DiagnosticCommonKinds.inc.h
+CommandObjectTarget.po: StmtNodes.inc.h
+CommandObjectThread.o: AttrList.inc.h
+CommandObjectThread.o: Attrs.inc.h
+CommandObjectThread.o: CommentCommandList.inc.h
+CommandObjectThread.o: DeclNodes.inc.h
+CommandObjectThread.o: DiagnosticCommonKinds.inc.h
+CommandObjectThread.o: StmtNodes.inc.h
+CommandObjectThread.po: AttrList.inc.h
+CommandObjectThread.po: Attrs.inc.h
+CommandObjectThread.po: CommentCommandList.inc.h
+CommandObjectThread.po: DeclNodes.inc.h
+CommandObjectThread.po: DiagnosticCommonKinds.inc.h
+CommandObjectThread.po: StmtNodes.inc.h
+CommandObjectType.o: AttrList.inc.h
+CommandObjectType.o: Attrs.inc.h
+CommandObjectType.o: CommentCommandList.inc.h
+CommandObjectType.o: DeclNodes.inc.h
+CommandObjectType.o: DiagnosticCommonKinds.inc.h
+CommandObjectType.o: StmtNodes.inc.h
+CommandObjectType.po: AttrList.inc.h
+CommandObjectType.po: Attrs.inc.h
+CommandObjectType.po: CommentCommandList.inc.h
+CommandObjectType.po: DeclNodes.inc.h
+CommandObjectType.po: DiagnosticCommonKinds.inc.h
+CommandObjectType.po: StmtNodes.inc.h
+CommandObjectVersion.o: AttrList.inc.h
+CommandObjectVersion.o: Attrs.inc.h
+CommandObjectVersion.o: CommentCommandList.inc.h
+CommandObjectVersion.o: DeclNodes.inc.h
+CommandObjectVersion.o: DiagnosticCommonKinds.inc.h
+CommandObjectVersion.o: StmtNodes.inc.h
+CommandObjectVersion.po: AttrList.inc.h
+CommandObjectVersion.po: Attrs.inc.h
+CommandObjectVersion.po: CommentCommandList.inc.h
+CommandObjectVersion.po: DeclNodes.inc.h
+CommandObjectVersion.po: DiagnosticCommonKinds.inc.h
+CommandObjectVersion.po: StmtNodes.inc.h
+CommandObjectWatchpoint.o: AttrList.inc.h
+CommandObjectWatchpoint.o: Attrs.inc.h
+CommandObjectWatchpoint.o: CommentCommandList.inc.h
+CommandObjectWatchpoint.o: DeclNodes.inc.h
+CommandObjectWatchpoint.o: DiagnosticCommonKinds.inc.h
+CommandObjectWatchpoint.o: StmtNodes.inc.h
+CommandObjectWatchpoint.po: AttrList.inc.h
+CommandObjectWatchpoint.po: Attrs.inc.h
+CommandObjectWatchpoint.po: CommentCommandList.inc.h
+CommandObjectWatchpoint.po: DeclNodes.inc.h
+CommandObjectWatchpoint.po: DiagnosticCommonKinds.inc.h
+CommandObjectWatchpoint.po: StmtNodes.inc.h
+CommandObjectWatchpointCommand.o: AttrList.inc.h
+CommandObjectWatchpointCommand.o: Attrs.inc.h
+CommandObjectWatchpointCommand.o: CommentCommandList.inc.h
+CommandObjectWatchpointCommand.o: DeclNodes.inc.h
+CommandObjectWatchpointCommand.o: DiagnosticCommonKinds.inc.h
+CommandObjectWatchpointCommand.o: StmtNodes.inc.h
+CommandObjectWatchpointCommand.po: AttrList.inc.h
+CommandObjectWatchpointCommand.po: Attrs.inc.h
+CommandObjectWatchpointCommand.po: CommentCommandList.inc.h
+CommandObjectWatchpointCommand.po: DeclNodes.inc.h
+CommandObjectWatchpointCommand.po: DiagnosticCommonKinds.inc.h
+CommandObjectWatchpointCommand.po: StmtNodes.inc.h
+.endif
diff --git a/lib/clang/liblldbCore/Makefile.depend b/lib/clang/liblldbCore/Makefile.depend
new file mode 100644
index 0000000..865dfa0
--- /dev/null
+++ b/lib/clang/liblldbCore/Makefile.depend
@@ -0,0 +1,289 @@
+# $FreeBSD$
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/libc++ \
+ lib/libedit \
+ lib/msun \
+ lib/ncurses/ncursesw \
+ lib/ncurses/panelw \
+ usr.bin/clang/clang-tblgen.host \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+Address.o: CommentCommandList.inc.h
+Address.o: DeclNodes.inc.h
+Address.o: DiagnosticCommonKinds.inc.h
+Address.o: StmtNodes.inc.h
+Address.po: CommentCommandList.inc.h
+Address.po: DeclNodes.inc.h
+Address.po: DiagnosticCommonKinds.inc.h
+Address.po: StmtNodes.inc.h
+AddressRange.o: CommentCommandList.inc.h
+AddressRange.o: DeclNodes.inc.h
+AddressRange.o: DiagnosticCommonKinds.inc.h
+AddressRange.o: StmtNodes.inc.h
+AddressRange.po: CommentCommandList.inc.h
+AddressRange.po: DeclNodes.inc.h
+AddressRange.po: DiagnosticCommonKinds.inc.h
+AddressRange.po: StmtNodes.inc.h
+AddressResolver.o: DiagnosticCommonKinds.inc.h
+AddressResolver.po: DiagnosticCommonKinds.inc.h
+AddressResolverFileLine.o: DiagnosticCommonKinds.inc.h
+AddressResolverFileLine.po: DiagnosticCommonKinds.inc.h
+AddressResolverName.o: CommentCommandList.inc.h
+AddressResolverName.o: DeclNodes.inc.h
+AddressResolverName.o: DiagnosticCommonKinds.inc.h
+AddressResolverName.o: StmtNodes.inc.h
+AddressResolverName.po: CommentCommandList.inc.h
+AddressResolverName.po: DeclNodes.inc.h
+AddressResolverName.po: DiagnosticCommonKinds.inc.h
+AddressResolverName.po: StmtNodes.inc.h
+ArchSpec.o: DiagnosticCommonKinds.inc.h
+ArchSpec.po: DiagnosticCommonKinds.inc.h
+DataExtractor.o: CommentCommandList.inc.h
+DataExtractor.o: DeclNodes.inc.h
+DataExtractor.o: DiagnosticCommonKinds.inc.h
+DataExtractor.o: StmtNodes.inc.h
+DataExtractor.po: CommentCommandList.inc.h
+DataExtractor.po: DeclNodes.inc.h
+DataExtractor.po: DiagnosticCommonKinds.inc.h
+DataExtractor.po: StmtNodes.inc.h
+Debugger.o: AttrList.inc.h
+Debugger.o: Attrs.inc.h
+Debugger.o: CommentCommandList.inc.h
+Debugger.o: DeclNodes.inc.h
+Debugger.o: DiagnosticCommonKinds.inc.h
+Debugger.o: StmtNodes.inc.h
+Debugger.po: AttrList.inc.h
+Debugger.po: Attrs.inc.h
+Debugger.po: CommentCommandList.inc.h
+Debugger.po: DeclNodes.inc.h
+Debugger.po: DiagnosticCommonKinds.inc.h
+Debugger.po: StmtNodes.inc.h
+Disassembler.o: AttrList.inc.h
+Disassembler.o: Attrs.inc.h
+Disassembler.o: CommentCommandList.inc.h
+Disassembler.o: DeclNodes.inc.h
+Disassembler.o: DiagnosticCommonKinds.inc.h
+Disassembler.o: StmtNodes.inc.h
+Disassembler.po: AttrList.inc.h
+Disassembler.po: Attrs.inc.h
+Disassembler.po: CommentCommandList.inc.h
+Disassembler.po: DeclNodes.inc.h
+Disassembler.po: DiagnosticCommonKinds.inc.h
+Disassembler.po: StmtNodes.inc.h
+DynamicLoader.o: CommentCommandList.inc.h
+DynamicLoader.o: DeclNodes.inc.h
+DynamicLoader.o: DiagnosticCommonKinds.inc.h
+DynamicLoader.o: StmtNodes.inc.h
+DynamicLoader.po: CommentCommandList.inc.h
+DynamicLoader.po: DeclNodes.inc.h
+DynamicLoader.po: DiagnosticCommonKinds.inc.h
+DynamicLoader.po: StmtNodes.inc.h
+EmulateInstruction.o: DiagnosticCommonKinds.inc.h
+EmulateInstruction.po: DiagnosticCommonKinds.inc.h
+Event.o: DiagnosticCommonKinds.inc.h
+Event.po: DiagnosticCommonKinds.inc.h
+FileLineResolver.o: DiagnosticCommonKinds.inc.h
+FileLineResolver.po: DiagnosticCommonKinds.inc.h
+IOHandler.o: AttrList.inc.h
+IOHandler.o: Attrs.inc.h
+IOHandler.o: CommentCommandList.inc.h
+IOHandler.o: DeclNodes.inc.h
+IOHandler.o: DiagnosticCommonKinds.inc.h
+IOHandler.o: StmtNodes.inc.h
+IOHandler.po: AttrList.inc.h
+IOHandler.po: Attrs.inc.h
+IOHandler.po: CommentCommandList.inc.h
+IOHandler.po: DeclNodes.inc.h
+IOHandler.po: DiagnosticCommonKinds.inc.h
+IOHandler.po: StmtNodes.inc.h
+Log.o: AttrList.inc.h
+Log.o: Attrs.inc.h
+Log.o: CommentCommandList.inc.h
+Log.o: DeclNodes.inc.h
+Log.o: DiagnosticCommonKinds.inc.h
+Log.o: StmtNodes.inc.h
+Log.po: AttrList.inc.h
+Log.po: Attrs.inc.h
+Log.po: CommentCommandList.inc.h
+Log.po: DeclNodes.inc.h
+Log.po: DiagnosticCommonKinds.inc.h
+Log.po: StmtNodes.inc.h
+Mangled.o: DiagnosticCommonKinds.inc.h
+Mangled.po: DiagnosticCommonKinds.inc.h
+Module.o: AttrList.inc.h
+Module.o: Attrs.inc.h
+Module.o: CommentCommandList.inc.h
+Module.o: DeclNodes.inc.h
+Module.o: DiagnosticCommonKinds.inc.h
+Module.o: StmtNodes.inc.h
+Module.po: AttrList.inc.h
+Module.po: Attrs.inc.h
+Module.po: CommentCommandList.inc.h
+Module.po: DeclNodes.inc.h
+Module.po: DiagnosticCommonKinds.inc.h
+Module.po: StmtNodes.inc.h
+ModuleList.o: CommentCommandList.inc.h
+ModuleList.o: DeclNodes.inc.h
+ModuleList.o: DiagnosticCommonKinds.inc.h
+ModuleList.o: StmtNodes.inc.h
+ModuleList.po: CommentCommandList.inc.h
+ModuleList.po: DeclNodes.inc.h
+ModuleList.po: DiagnosticCommonKinds.inc.h
+ModuleList.po: StmtNodes.inc.h
+PluginManager.o: AttrList.inc.h
+PluginManager.o: Attrs.inc.h
+PluginManager.o: CommentCommandList.inc.h
+PluginManager.o: DeclNodes.inc.h
+PluginManager.o: DiagnosticCommonKinds.inc.h
+PluginManager.o: StmtNodes.inc.h
+PluginManager.po: AttrList.inc.h
+PluginManager.po: Attrs.inc.h
+PluginManager.po: CommentCommandList.inc.h
+PluginManager.po: DeclNodes.inc.h
+PluginManager.po: DiagnosticCommonKinds.inc.h
+PluginManager.po: StmtNodes.inc.h
+SearchFilter.o: CommentCommandList.inc.h
+SearchFilter.o: DeclNodes.inc.h
+SearchFilter.o: DiagnosticCommonKinds.inc.h
+SearchFilter.o: StmtNodes.inc.h
+SearchFilter.po: CommentCommandList.inc.h
+SearchFilter.po: DeclNodes.inc.h
+SearchFilter.po: DiagnosticCommonKinds.inc.h
+SearchFilter.po: StmtNodes.inc.h
+Section.o: CommentCommandList.inc.h
+Section.o: DeclNodes.inc.h
+Section.o: DiagnosticCommonKinds.inc.h
+Section.o: StmtNodes.inc.h
+Section.po: CommentCommandList.inc.h
+Section.po: DeclNodes.inc.h
+Section.po: DiagnosticCommonKinds.inc.h
+Section.po: StmtNodes.inc.h
+SourceManager.o: AttrList.inc.h
+SourceManager.o: Attrs.inc.h
+SourceManager.o: CommentCommandList.inc.h
+SourceManager.o: DeclNodes.inc.h
+SourceManager.o: DiagnosticCommonKinds.inc.h
+SourceManager.o: StmtNodes.inc.h
+SourceManager.po: AttrList.inc.h
+SourceManager.po: Attrs.inc.h
+SourceManager.po: CommentCommandList.inc.h
+SourceManager.po: DeclNodes.inc.h
+SourceManager.po: DiagnosticCommonKinds.inc.h
+SourceManager.po: StmtNodes.inc.h
+UserSettingsController.o: AttrList.inc.h
+UserSettingsController.o: Attrs.inc.h
+UserSettingsController.o: CommentCommandList.inc.h
+UserSettingsController.o: DeclNodes.inc.h
+UserSettingsController.o: DiagnosticCommonKinds.inc.h
+UserSettingsController.o: StmtNodes.inc.h
+UserSettingsController.po: AttrList.inc.h
+UserSettingsController.po: Attrs.inc.h
+UserSettingsController.po: CommentCommandList.inc.h
+UserSettingsController.po: DeclNodes.inc.h
+UserSettingsController.po: DiagnosticCommonKinds.inc.h
+UserSettingsController.po: StmtNodes.inc.h
+Value.o: CommentCommandList.inc.h
+Value.o: DeclNodes.inc.h
+Value.o: DiagnosticCommonKinds.inc.h
+Value.o: StmtNodes.inc.h
+Value.po: CommentCommandList.inc.h
+Value.po: DeclNodes.inc.h
+Value.po: DiagnosticCommonKinds.inc.h
+Value.po: StmtNodes.inc.h
+ValueObject.o: AttrList.inc.h
+ValueObject.o: Attrs.inc.h
+ValueObject.o: CommentCommandList.inc.h
+ValueObject.o: DeclNodes.inc.h
+ValueObject.o: DiagnosticCommonKinds.inc.h
+ValueObject.o: StmtNodes.inc.h
+ValueObject.po: AttrList.inc.h
+ValueObject.po: Attrs.inc.h
+ValueObject.po: CommentCommandList.inc.h
+ValueObject.po: DeclNodes.inc.h
+ValueObject.po: DiagnosticCommonKinds.inc.h
+ValueObject.po: StmtNodes.inc.h
+ValueObjectCast.o: CommentCommandList.inc.h
+ValueObjectCast.o: DeclNodes.inc.h
+ValueObjectCast.o: DiagnosticCommonKinds.inc.h
+ValueObjectCast.o: StmtNodes.inc.h
+ValueObjectCast.po: CommentCommandList.inc.h
+ValueObjectCast.po: DeclNodes.inc.h
+ValueObjectCast.po: DiagnosticCommonKinds.inc.h
+ValueObjectCast.po: StmtNodes.inc.h
+ValueObjectChild.o: CommentCommandList.inc.h
+ValueObjectChild.o: DeclNodes.inc.h
+ValueObjectChild.o: DiagnosticCommonKinds.inc.h
+ValueObjectChild.o: StmtNodes.inc.h
+ValueObjectChild.po: CommentCommandList.inc.h
+ValueObjectChild.po: DeclNodes.inc.h
+ValueObjectChild.po: DiagnosticCommonKinds.inc.h
+ValueObjectChild.po: StmtNodes.inc.h
+ValueObjectConstResult.o: CommentCommandList.inc.h
+ValueObjectConstResult.o: DeclNodes.inc.h
+ValueObjectConstResult.o: DiagnosticCommonKinds.inc.h
+ValueObjectConstResult.o: StmtNodes.inc.h
+ValueObjectConstResult.po: CommentCommandList.inc.h
+ValueObjectConstResult.po: DeclNodes.inc.h
+ValueObjectConstResult.po: DiagnosticCommonKinds.inc.h
+ValueObjectConstResult.po: StmtNodes.inc.h
+ValueObjectConstResultChild.o: CommentCommandList.inc.h
+ValueObjectConstResultChild.o: DeclNodes.inc.h
+ValueObjectConstResultChild.o: DiagnosticCommonKinds.inc.h
+ValueObjectConstResultChild.o: StmtNodes.inc.h
+ValueObjectConstResultChild.po: CommentCommandList.inc.h
+ValueObjectConstResultChild.po: DeclNodes.inc.h
+ValueObjectConstResultChild.po: DiagnosticCommonKinds.inc.h
+ValueObjectConstResultChild.po: StmtNodes.inc.h
+ValueObjectConstResultImpl.o: CommentCommandList.inc.h
+ValueObjectConstResultImpl.o: DeclNodes.inc.h
+ValueObjectConstResultImpl.o: DiagnosticCommonKinds.inc.h
+ValueObjectConstResultImpl.o: StmtNodes.inc.h
+ValueObjectConstResultImpl.po: CommentCommandList.inc.h
+ValueObjectConstResultImpl.po: DeclNodes.inc.h
+ValueObjectConstResultImpl.po: DiagnosticCommonKinds.inc.h
+ValueObjectConstResultImpl.po: StmtNodes.inc.h
+ValueObjectDynamicValue.o: CommentCommandList.inc.h
+ValueObjectDynamicValue.o: DeclNodes.inc.h
+ValueObjectDynamicValue.o: DiagnosticCommonKinds.inc.h
+ValueObjectDynamicValue.o: StmtNodes.inc.h
+ValueObjectDynamicValue.po: CommentCommandList.inc.h
+ValueObjectDynamicValue.po: DeclNodes.inc.h
+ValueObjectDynamicValue.po: DiagnosticCommonKinds.inc.h
+ValueObjectDynamicValue.po: StmtNodes.inc.h
+ValueObjectList.o: DiagnosticCommonKinds.inc.h
+ValueObjectList.po: DiagnosticCommonKinds.inc.h
+ValueObjectMemory.o: CommentCommandList.inc.h
+ValueObjectMemory.o: DeclNodes.inc.h
+ValueObjectMemory.o: DiagnosticCommonKinds.inc.h
+ValueObjectMemory.o: StmtNodes.inc.h
+ValueObjectMemory.po: CommentCommandList.inc.h
+ValueObjectMemory.po: DeclNodes.inc.h
+ValueObjectMemory.po: DiagnosticCommonKinds.inc.h
+ValueObjectMemory.po: StmtNodes.inc.h
+ValueObjectRegister.o: CommentCommandList.inc.h
+ValueObjectRegister.o: DeclNodes.inc.h
+ValueObjectRegister.o: DiagnosticCommonKinds.inc.h
+ValueObjectRegister.o: StmtNodes.inc.h
+ValueObjectRegister.po: CommentCommandList.inc.h
+ValueObjectRegister.po: DeclNodes.inc.h
+ValueObjectRegister.po: DiagnosticCommonKinds.inc.h
+ValueObjectRegister.po: StmtNodes.inc.h
+ValueObjectSyntheticFilter.o: DiagnosticCommonKinds.inc.h
+ValueObjectSyntheticFilter.po: DiagnosticCommonKinds.inc.h
+ValueObjectVariable.o: CommentCommandList.inc.h
+ValueObjectVariable.o: DeclNodes.inc.h
+ValueObjectVariable.o: DiagnosticCommonKinds.inc.h
+ValueObjectVariable.o: StmtNodes.inc.h
+ValueObjectVariable.po: CommentCommandList.inc.h
+ValueObjectVariable.po: DeclNodes.inc.h
+ValueObjectVariable.po: DiagnosticCommonKinds.inc.h
+ValueObjectVariable.po: StmtNodes.inc.h
+.endif
diff --git a/lib/clang/liblldbDataFormatters/Makefile.depend b/lib/clang/liblldbDataFormatters/Makefile.depend
new file mode 100644
index 0000000..e35e5d7
--- /dev/null
+++ b/lib/clang/liblldbDataFormatters/Makefile.depend
@@ -0,0 +1,248 @@
+# $FreeBSD$
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/libc++ \
+ lib/msun \
+ usr.bin/clang/clang-tblgen.host \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+CF.o: CommentCommandList.inc.h
+CF.o: DeclNodes.inc.h
+CF.o: DiagnosticCommonKinds.inc.h
+CF.o: StmtNodes.inc.h
+CF.po: CommentCommandList.inc.h
+CF.po: DeclNodes.inc.h
+CF.po: DiagnosticCommonKinds.inc.h
+CF.po: StmtNodes.inc.h
+CXXFormatterFunctions.o: CommentCommandList.inc.h
+CXXFormatterFunctions.o: DeclNodes.inc.h
+CXXFormatterFunctions.o: DiagnosticCommonKinds.inc.h
+CXXFormatterFunctions.o: StmtNodes.inc.h
+CXXFormatterFunctions.po: CommentCommandList.inc.h
+CXXFormatterFunctions.po: DeclNodes.inc.h
+CXXFormatterFunctions.po: DiagnosticCommonKinds.inc.h
+CXXFormatterFunctions.po: StmtNodes.inc.h
+Cocoa.o: CommentCommandList.inc.h
+Cocoa.o: DeclNodes.inc.h
+Cocoa.o: DiagnosticCommonKinds.inc.h
+Cocoa.o: StmtNodes.inc.h
+Cocoa.po: CommentCommandList.inc.h
+Cocoa.po: DeclNodes.inc.h
+Cocoa.po: DiagnosticCommonKinds.inc.h
+Cocoa.po: StmtNodes.inc.h
+DataVisualization.o: AttrList.inc.h
+DataVisualization.o: Attrs.inc.h
+DataVisualization.o: CommentCommandList.inc.h
+DataVisualization.o: DeclNodes.inc.h
+DataVisualization.o: DiagnosticCommonKinds.inc.h
+DataVisualization.o: StmtNodes.inc.h
+DataVisualization.po: AttrList.inc.h
+DataVisualization.po: Attrs.inc.h
+DataVisualization.po: CommentCommandList.inc.h
+DataVisualization.po: DeclNodes.inc.h
+DataVisualization.po: DiagnosticCommonKinds.inc.h
+DataVisualization.po: StmtNodes.inc.h
+FormatCache.o: DiagnosticCommonKinds.inc.h
+FormatCache.po: DiagnosticCommonKinds.inc.h
+FormatClasses.o: DiagnosticCommonKinds.inc.h
+FormatClasses.po: DiagnosticCommonKinds.inc.h
+FormatManager.o: AttrList.inc.h
+FormatManager.o: Attrs.inc.h
+FormatManager.o: CommentCommandList.inc.h
+FormatManager.o: DeclNodes.inc.h
+FormatManager.o: DiagnosticCommonKinds.inc.h
+FormatManager.o: StmtNodes.inc.h
+FormatManager.po: AttrList.inc.h
+FormatManager.po: Attrs.inc.h
+FormatManager.po: CommentCommandList.inc.h
+FormatManager.po: DeclNodes.inc.h
+FormatManager.po: DiagnosticCommonKinds.inc.h
+FormatManager.po: StmtNodes.inc.h
+LibCxx.o: AttrList.inc.h
+LibCxx.o: Attrs.inc.h
+LibCxx.o: CommentCommandList.inc.h
+LibCxx.o: DeclNodes.inc.h
+LibCxx.o: DiagnosticCommonKinds.inc.h
+LibCxx.o: StmtNodes.inc.h
+LibCxx.po: AttrList.inc.h
+LibCxx.po: Attrs.inc.h
+LibCxx.po: CommentCommandList.inc.h
+LibCxx.po: DeclNodes.inc.h
+LibCxx.po: DiagnosticCommonKinds.inc.h
+LibCxx.po: StmtNodes.inc.h
+LibCxxInitializerList.o: CommentCommandList.inc.h
+LibCxxInitializerList.o: DeclNodes.inc.h
+LibCxxInitializerList.o: DiagnosticCommonKinds.inc.h
+LibCxxInitializerList.o: StmtNodes.inc.h
+LibCxxInitializerList.po: CommentCommandList.inc.h
+LibCxxInitializerList.po: DeclNodes.inc.h
+LibCxxInitializerList.po: DiagnosticCommonKinds.inc.h
+LibCxxInitializerList.po: StmtNodes.inc.h
+LibCxxList.o: CommentCommandList.inc.h
+LibCxxList.o: DeclNodes.inc.h
+LibCxxList.o: DiagnosticCommonKinds.inc.h
+LibCxxList.o: StmtNodes.inc.h
+LibCxxList.po: CommentCommandList.inc.h
+LibCxxList.po: DeclNodes.inc.h
+LibCxxList.po: DiagnosticCommonKinds.inc.h
+LibCxxList.po: StmtNodes.inc.h
+LibCxxMap.o: CommentCommandList.inc.h
+LibCxxMap.o: DeclNodes.inc.h
+LibCxxMap.o: DiagnosticCommonKinds.inc.h
+LibCxxMap.o: StmtNodes.inc.h
+LibCxxMap.po: CommentCommandList.inc.h
+LibCxxMap.po: DeclNodes.inc.h
+LibCxxMap.po: DiagnosticCommonKinds.inc.h
+LibCxxMap.po: StmtNodes.inc.h
+LibCxxUnorderedMap.o: CommentCommandList.inc.h
+LibCxxUnorderedMap.o: DeclNodes.inc.h
+LibCxxUnorderedMap.o: DiagnosticCommonKinds.inc.h
+LibCxxUnorderedMap.o: StmtNodes.inc.h
+LibCxxUnorderedMap.po: CommentCommandList.inc.h
+LibCxxUnorderedMap.po: DeclNodes.inc.h
+LibCxxUnorderedMap.po: DiagnosticCommonKinds.inc.h
+LibCxxUnorderedMap.po: StmtNodes.inc.h
+LibCxxVector.o: CommentCommandList.inc.h
+LibCxxVector.o: DeclNodes.inc.h
+LibCxxVector.o: DiagnosticCommonKinds.inc.h
+LibCxxVector.o: StmtNodes.inc.h
+LibCxxVector.po: CommentCommandList.inc.h
+LibCxxVector.po: DeclNodes.inc.h
+LibCxxVector.po: DiagnosticCommonKinds.inc.h
+LibCxxVector.po: StmtNodes.inc.h
+LibStdcpp.o: CommentCommandList.inc.h
+LibStdcpp.o: DeclNodes.inc.h
+LibStdcpp.o: DiagnosticCommonKinds.inc.h
+LibStdcpp.o: StmtNodes.inc.h
+LibStdcpp.po: CommentCommandList.inc.h
+LibStdcpp.po: DeclNodes.inc.h
+LibStdcpp.po: DiagnosticCommonKinds.inc.h
+LibStdcpp.po: StmtNodes.inc.h
+NSArray.o: CommentCommandList.inc.h
+NSArray.o: DeclNodes.inc.h
+NSArray.o: DiagnosticCommonKinds.inc.h
+NSArray.o: StmtNodes.inc.h
+NSArray.po: CommentCommandList.inc.h
+NSArray.po: DeclNodes.inc.h
+NSArray.po: DiagnosticCommonKinds.inc.h
+NSArray.po: StmtNodes.inc.h
+NSDictionary.o: AttrList.inc.h
+NSDictionary.o: Attrs.inc.h
+NSDictionary.o: CommentCommandList.inc.h
+NSDictionary.o: DeclNodes.inc.h
+NSDictionary.o: DiagnosticCommonKinds.inc.h
+NSDictionary.o: StmtNodes.inc.h
+NSDictionary.po: AttrList.inc.h
+NSDictionary.po: Attrs.inc.h
+NSDictionary.po: CommentCommandList.inc.h
+NSDictionary.po: DeclNodes.inc.h
+NSDictionary.po: DiagnosticCommonKinds.inc.h
+NSDictionary.po: StmtNodes.inc.h
+NSIndexPath.o: CommentCommandList.inc.h
+NSIndexPath.o: DeclNodes.inc.h
+NSIndexPath.o: DiagnosticCommonKinds.inc.h
+NSIndexPath.o: StmtNodes.inc.h
+NSIndexPath.po: CommentCommandList.inc.h
+NSIndexPath.po: DeclNodes.inc.h
+NSIndexPath.po: DiagnosticCommonKinds.inc.h
+NSIndexPath.po: StmtNodes.inc.h
+NSSet.o: CommentCommandList.inc.h
+NSSet.o: DeclNodes.inc.h
+NSSet.o: DiagnosticCommonKinds.inc.h
+NSSet.o: StmtNodes.inc.h
+NSSet.po: CommentCommandList.inc.h
+NSSet.po: DeclNodes.inc.h
+NSSet.po: DiagnosticCommonKinds.inc.h
+NSSet.po: StmtNodes.inc.h
+StringPrinter.o: AttrList.inc.h
+StringPrinter.o: Attrs.inc.h
+StringPrinter.o: CommentCommandList.inc.h
+StringPrinter.o: DeclNodes.inc.h
+StringPrinter.o: DiagnosticCommonKinds.inc.h
+StringPrinter.o: StmtNodes.inc.h
+StringPrinter.po: AttrList.inc.h
+StringPrinter.po: Attrs.inc.h
+StringPrinter.po: CommentCommandList.inc.h
+StringPrinter.po: DeclNodes.inc.h
+StringPrinter.po: DiagnosticCommonKinds.inc.h
+StringPrinter.po: StmtNodes.inc.h
+TypeCategory.o: AttrList.inc.h
+TypeCategory.o: Attrs.inc.h
+TypeCategory.o: CommentCommandList.inc.h
+TypeCategory.o: DeclNodes.inc.h
+TypeCategory.o: DiagnosticCommonKinds.inc.h
+TypeCategory.o: StmtNodes.inc.h
+TypeCategory.po: AttrList.inc.h
+TypeCategory.po: Attrs.inc.h
+TypeCategory.po: CommentCommandList.inc.h
+TypeCategory.po: DeclNodes.inc.h
+TypeCategory.po: DiagnosticCommonKinds.inc.h
+TypeCategory.po: StmtNodes.inc.h
+TypeCategoryMap.o: AttrList.inc.h
+TypeCategoryMap.o: Attrs.inc.h
+TypeCategoryMap.o: CommentCommandList.inc.h
+TypeCategoryMap.o: DeclNodes.inc.h
+TypeCategoryMap.o: DiagnosticCommonKinds.inc.h
+TypeCategoryMap.o: StmtNodes.inc.h
+TypeCategoryMap.po: AttrList.inc.h
+TypeCategoryMap.po: Attrs.inc.h
+TypeCategoryMap.po: CommentCommandList.inc.h
+TypeCategoryMap.po: DeclNodes.inc.h
+TypeCategoryMap.po: DiagnosticCommonKinds.inc.h
+TypeCategoryMap.po: StmtNodes.inc.h
+TypeFormat.o: AttrList.inc.h
+TypeFormat.o: Attrs.inc.h
+TypeFormat.o: CommentCommandList.inc.h
+TypeFormat.o: DeclNodes.inc.h
+TypeFormat.o: DiagnosticCommonKinds.inc.h
+TypeFormat.o: StmtNodes.inc.h
+TypeFormat.po: AttrList.inc.h
+TypeFormat.po: Attrs.inc.h
+TypeFormat.po: CommentCommandList.inc.h
+TypeFormat.po: DeclNodes.inc.h
+TypeFormat.po: DiagnosticCommonKinds.inc.h
+TypeFormat.po: StmtNodes.inc.h
+TypeSummary.o: AttrList.inc.h
+TypeSummary.o: Attrs.inc.h
+TypeSummary.o: CommentCommandList.inc.h
+TypeSummary.o: DeclNodes.inc.h
+TypeSummary.o: DiagnosticCommonKinds.inc.h
+TypeSummary.o: StmtNodes.inc.h
+TypeSummary.po: AttrList.inc.h
+TypeSummary.po: Attrs.inc.h
+TypeSummary.po: CommentCommandList.inc.h
+TypeSummary.po: DeclNodes.inc.h
+TypeSummary.po: DiagnosticCommonKinds.inc.h
+TypeSummary.po: StmtNodes.inc.h
+TypeSynthetic.o: AttrList.inc.h
+TypeSynthetic.o: Attrs.inc.h
+TypeSynthetic.o: CommentCommandList.inc.h
+TypeSynthetic.o: DeclNodes.inc.h
+TypeSynthetic.o: DiagnosticCommonKinds.inc.h
+TypeSynthetic.o: StmtNodes.inc.h
+TypeSynthetic.po: AttrList.inc.h
+TypeSynthetic.po: Attrs.inc.h
+TypeSynthetic.po: CommentCommandList.inc.h
+TypeSynthetic.po: DeclNodes.inc.h
+TypeSynthetic.po: DiagnosticCommonKinds.inc.h
+TypeSynthetic.po: StmtNodes.inc.h
+ValueObjectPrinter.o: AttrList.inc.h
+ValueObjectPrinter.o: Attrs.inc.h
+ValueObjectPrinter.o: CommentCommandList.inc.h
+ValueObjectPrinter.o: DeclNodes.inc.h
+ValueObjectPrinter.o: DiagnosticCommonKinds.inc.h
+ValueObjectPrinter.o: StmtNodes.inc.h
+ValueObjectPrinter.po: AttrList.inc.h
+ValueObjectPrinter.po: Attrs.inc.h
+ValueObjectPrinter.po: CommentCommandList.inc.h
+ValueObjectPrinter.po: DeclNodes.inc.h
+ValueObjectPrinter.po: DiagnosticCommonKinds.inc.h
+ValueObjectPrinter.po: StmtNodes.inc.h
+.endif
diff --git a/lib/clang/liblldbExpression/Makefile.depend b/lib/clang/liblldbExpression/Makefile.depend
new file mode 100644
index 0000000..e7aa336
--- /dev/null
+++ b/lib/clang/liblldbExpression/Makefile.depend
@@ -0,0 +1,195 @@
+# $FreeBSD$
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/libc++ \
+ lib/msun \
+ usr.bin/clang/clang-tblgen.host \
+ usr.bin/clang/tblgen.host \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+ASTDumper.o: AttrList.inc.h
+ASTDumper.o: Attrs.inc.h
+ASTDumper.o: DeclNodes.inc.h
+ASTDumper.o: DiagnosticCommonKinds.inc.h
+ASTDumper.o: StmtNodes.inc.h
+ASTDumper.po: AttrList.inc.h
+ASTDumper.po: Attrs.inc.h
+ASTDumper.po: DeclNodes.inc.h
+ASTDumper.po: DiagnosticCommonKinds.inc.h
+ASTDumper.po: StmtNodes.inc.h
+ASTResultSynthesizer.o: AttrList.inc.h
+ASTResultSynthesizer.o: AttrParsedAttrList.inc.h
+ASTResultSynthesizer.o: Attrs.inc.h
+ASTResultSynthesizer.o: CommentCommandList.inc.h
+ASTResultSynthesizer.o: DeclNodes.inc.h
+ASTResultSynthesizer.o: DiagnosticCommonKinds.inc.h
+ASTResultSynthesizer.o: DiagnosticSemaKinds.inc.h
+ASTResultSynthesizer.o: StmtNodes.inc.h
+ASTResultSynthesizer.po: AttrList.inc.h
+ASTResultSynthesizer.po: AttrParsedAttrList.inc.h
+ASTResultSynthesizer.po: Attrs.inc.h
+ASTResultSynthesizer.po: CommentCommandList.inc.h
+ASTResultSynthesizer.po: DeclNodes.inc.h
+ASTResultSynthesizer.po: DiagnosticCommonKinds.inc.h
+ASTResultSynthesizer.po: DiagnosticSemaKinds.inc.h
+ASTResultSynthesizer.po: StmtNodes.inc.h
+ASTStructExtractor.o: AttrList.inc.h
+ASTStructExtractor.o: AttrParsedAttrList.inc.h
+ASTStructExtractor.o: Attrs.inc.h
+ASTStructExtractor.o: CommentCommandList.inc.h
+ASTStructExtractor.o: DeclNodes.inc.h
+ASTStructExtractor.o: DiagnosticCommonKinds.inc.h
+ASTStructExtractor.o: StmtNodes.inc.h
+ASTStructExtractor.po: AttrList.inc.h
+ASTStructExtractor.po: AttrParsedAttrList.inc.h
+ASTStructExtractor.po: Attrs.inc.h
+ASTStructExtractor.po: CommentCommandList.inc.h
+ASTStructExtractor.po: DeclNodes.inc.h
+ASTStructExtractor.po: DiagnosticCommonKinds.inc.h
+ASTStructExtractor.po: StmtNodes.inc.h
+ClangASTSource.o: AttrList.inc.h
+ClangASTSource.o: Attrs.inc.h
+ClangASTSource.o: CommentCommandList.inc.h
+ClangASTSource.o: DeclNodes.inc.h
+ClangASTSource.o: DiagnosticCommonKinds.inc.h
+ClangASTSource.o: StmtNodes.inc.h
+ClangASTSource.po: AttrList.inc.h
+ClangASTSource.po: Attrs.inc.h
+ClangASTSource.po: CommentCommandList.inc.h
+ClangASTSource.po: DeclNodes.inc.h
+ClangASTSource.po: DiagnosticCommonKinds.inc.h
+ClangASTSource.po: StmtNodes.inc.h
+ClangExpressionDeclMap.o: AttrList.inc.h
+ClangExpressionDeclMap.o: Attrs.inc.h
+ClangExpressionDeclMap.o: CommentCommandList.inc.h
+ClangExpressionDeclMap.o: DeclNodes.inc.h
+ClangExpressionDeclMap.o: DiagnosticCommonKinds.inc.h
+ClangExpressionDeclMap.o: StmtNodes.inc.h
+ClangExpressionDeclMap.po: AttrList.inc.h
+ClangExpressionDeclMap.po: Attrs.inc.h
+ClangExpressionDeclMap.po: CommentCommandList.inc.h
+ClangExpressionDeclMap.po: DeclNodes.inc.h
+ClangExpressionDeclMap.po: DiagnosticCommonKinds.inc.h
+ClangExpressionDeclMap.po: StmtNodes.inc.h
+ClangExpressionParser.o: AttrList.inc.h
+ClangExpressionParser.o: Attrs.inc.h
+ClangExpressionParser.o: CommentCommandList.inc.h
+ClangExpressionParser.o: DeclNodes.inc.h
+ClangExpressionParser.o: DiagnosticCommonKinds.inc.h
+ClangExpressionParser.o: DiagnosticFrontendKinds.inc.h
+ClangExpressionParser.o: StmtNodes.inc.h
+ClangExpressionParser.po: AttrList.inc.h
+ClangExpressionParser.po: Attrs.inc.h
+ClangExpressionParser.po: CommentCommandList.inc.h
+ClangExpressionParser.po: DeclNodes.inc.h
+ClangExpressionParser.po: DiagnosticCommonKinds.inc.h
+ClangExpressionParser.po: DiagnosticFrontendKinds.inc.h
+ClangExpressionParser.po: StmtNodes.inc.h
+ClangExpressionVariable.o: CommentCommandList.inc.h
+ClangExpressionVariable.o: DeclNodes.inc.h
+ClangExpressionVariable.o: DiagnosticCommonKinds.inc.h
+ClangExpressionVariable.o: StmtNodes.inc.h
+ClangExpressionVariable.po: CommentCommandList.inc.h
+ClangExpressionVariable.po: DeclNodes.inc.h
+ClangExpressionVariable.po: DiagnosticCommonKinds.inc.h
+ClangExpressionVariable.po: StmtNodes.inc.h
+ClangFunction.o: AttrList.inc.h
+ClangFunction.o: Attrs.inc.h
+ClangFunction.o: CommentCommandList.inc.h
+ClangFunction.o: DeclNodes.inc.h
+ClangFunction.o: DiagnosticCommonKinds.inc.h
+ClangFunction.o: StmtNodes.inc.h
+ClangFunction.po: AttrList.inc.h
+ClangFunction.po: Attrs.inc.h
+ClangFunction.po: CommentCommandList.inc.h
+ClangFunction.po: DeclNodes.inc.h
+ClangFunction.po: DiagnosticCommonKinds.inc.h
+ClangFunction.po: StmtNodes.inc.h
+ClangModulesDeclVendor.o: AttrList.inc.h
+ClangModulesDeclVendor.o: AttrParsedAttrList.inc.h
+ClangModulesDeclVendor.o: Attrs.inc.h
+ClangModulesDeclVendor.o: CommentCommandList.inc.h
+ClangModulesDeclVendor.o: DeclNodes.inc.h
+ClangModulesDeclVendor.o: DiagnosticCommonKinds.inc.h
+ClangModulesDeclVendor.o: StmtNodes.inc.h
+ClangModulesDeclVendor.po: AttrList.inc.h
+ClangModulesDeclVendor.po: AttrParsedAttrList.inc.h
+ClangModulesDeclVendor.po: Attrs.inc.h
+ClangModulesDeclVendor.po: CommentCommandList.inc.h
+ClangModulesDeclVendor.po: DeclNodes.inc.h
+ClangModulesDeclVendor.po: DiagnosticCommonKinds.inc.h
+ClangModulesDeclVendor.po: StmtNodes.inc.h
+ClangPersistentVariables.o: DiagnosticCommonKinds.inc.h
+ClangPersistentVariables.po: DiagnosticCommonKinds.inc.h
+ClangUserExpression.o: AttrList.inc.h
+ClangUserExpression.o: Attrs.inc.h
+ClangUserExpression.o: CommentCommandList.inc.h
+ClangUserExpression.o: DeclNodes.inc.h
+ClangUserExpression.o: DiagnosticCommonKinds.inc.h
+ClangUserExpression.o: StmtNodes.inc.h
+ClangUserExpression.po: AttrList.inc.h
+ClangUserExpression.po: Attrs.inc.h
+ClangUserExpression.po: CommentCommandList.inc.h
+ClangUserExpression.po: DeclNodes.inc.h
+ClangUserExpression.po: DiagnosticCommonKinds.inc.h
+ClangUserExpression.po: StmtNodes.inc.h
+ClangUtilityFunction.o: CommentCommandList.inc.h
+ClangUtilityFunction.o: DeclNodes.inc.h
+ClangUtilityFunction.o: DiagnosticCommonKinds.inc.h
+ClangUtilityFunction.o: StmtNodes.inc.h
+ClangUtilityFunction.po: CommentCommandList.inc.h
+ClangUtilityFunction.po: DeclNodes.inc.h
+ClangUtilityFunction.po: DiagnosticCommonKinds.inc.h
+ClangUtilityFunction.po: StmtNodes.inc.h
+DWARFExpression.o: DeclNodes.inc.h
+DWARFExpression.o: DiagnosticCommonKinds.inc.h
+DWARFExpression.po: DeclNodes.inc.h
+DWARFExpression.po: DiagnosticCommonKinds.inc.h
+ExpressionSourceCode.o: DiagnosticCommonKinds.inc.h
+ExpressionSourceCode.po: DiagnosticCommonKinds.inc.h
+IRDynamicChecks.o: DiagnosticCommonKinds.inc.h
+IRDynamicChecks.po: DiagnosticCommonKinds.inc.h
+IRExecutionUnit.o: AttrList.inc.h
+IRExecutionUnit.o: Attrs.inc.h
+IRExecutionUnit.o: CommentCommandList.inc.h
+IRExecutionUnit.o: DeclNodes.inc.h
+IRExecutionUnit.o: DiagnosticCommonKinds.inc.h
+IRExecutionUnit.o: StmtNodes.inc.h
+IRExecutionUnit.po: AttrList.inc.h
+IRExecutionUnit.po: Attrs.inc.h
+IRExecutionUnit.po: CommentCommandList.inc.h
+IRExecutionUnit.po: DeclNodes.inc.h
+IRExecutionUnit.po: DiagnosticCommonKinds.inc.h
+IRExecutionUnit.po: StmtNodes.inc.h
+IRForTarget.o: CommentCommandList.inc.h
+IRForTarget.o: DeclNodes.inc.h
+IRForTarget.o: DiagnosticCommonKinds.inc.h
+IRForTarget.o: Intrinsics.inc.h
+IRForTarget.o: StmtNodes.inc.h
+IRForTarget.po: CommentCommandList.inc.h
+IRForTarget.po: DeclNodes.inc.h
+IRForTarget.po: DiagnosticCommonKinds.inc.h
+IRForTarget.po: Intrinsics.inc.h
+IRForTarget.po: StmtNodes.inc.h
+IRInterpreter.o: DiagnosticCommonKinds.inc.h
+IRInterpreter.o: Intrinsics.inc.h
+IRInterpreter.po: DiagnosticCommonKinds.inc.h
+IRInterpreter.po: Intrinsics.inc.h
+IRMemoryMap.o: DiagnosticCommonKinds.inc.h
+IRMemoryMap.po: DiagnosticCommonKinds.inc.h
+Materializer.o: CommentCommandList.inc.h
+Materializer.o: DeclNodes.inc.h
+Materializer.o: DiagnosticCommonKinds.inc.h
+Materializer.o: StmtNodes.inc.h
+Materializer.po: CommentCommandList.inc.h
+Materializer.po: DeclNodes.inc.h
+Materializer.po: DiagnosticCommonKinds.inc.h
+Materializer.po: StmtNodes.inc.h
+.endif
diff --git a/lib/clang/liblldbHostCommon/Makefile.depend b/lib/clang/liblldbHostCommon/Makefile.depend
new file mode 100644
index 0000000..4ad7db2
--- /dev/null
+++ b/lib/clang/liblldbHostCommon/Makefile.depend
@@ -0,0 +1,46 @@
+# $FreeBSD$
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/arpa \
+ include/xlocale \
+ lib/libc++ \
+ lib/libedit \
+ lib/msun \
+ usr.bin/clang/clang-tblgen.host \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+Host.o: AttrList.inc.h
+Host.o: Attrs.inc.h
+Host.o: CommentCommandList.inc.h
+Host.o: DeclNodes.inc.h
+Host.o: DiagnosticCommonKinds.inc.h
+Host.o: StmtNodes.inc.h
+Host.po: AttrList.inc.h
+Host.po: Attrs.inc.h
+Host.po: CommentCommandList.inc.h
+Host.po: DeclNodes.inc.h
+Host.po: DiagnosticCommonKinds.inc.h
+Host.po: StmtNodes.inc.h
+MonitoringProcessLauncher.o: CommentCommandList.inc.h
+MonitoringProcessLauncher.o: DeclNodes.inc.h
+MonitoringProcessLauncher.o: DiagnosticCommonKinds.inc.h
+MonitoringProcessLauncher.o: StmtNodes.inc.h
+MonitoringProcessLauncher.po: CommentCommandList.inc.h
+MonitoringProcessLauncher.po: DeclNodes.inc.h
+MonitoringProcessLauncher.po: DiagnosticCommonKinds.inc.h
+MonitoringProcessLauncher.po: StmtNodes.inc.h
+Symbols.o: CommentCommandList.inc.h
+Symbols.o: DeclNodes.inc.h
+Symbols.o: DiagnosticCommonKinds.inc.h
+Symbols.o: StmtNodes.inc.h
+Symbols.po: CommentCommandList.inc.h
+Symbols.po: DeclNodes.inc.h
+Symbols.po: DiagnosticCommonKinds.inc.h
+Symbols.po: StmtNodes.inc.h
+.endif
diff --git a/lib/clang/liblldbHostFreeBSD/Makefile.depend b/lib/clang/liblldbHostFreeBSD/Makefile.depend
new file mode 100644
index 0000000..5bd9586
--- /dev/null
+++ b/lib/clang/liblldbHostFreeBSD/Makefile.depend
@@ -0,0 +1,25 @@
+# $FreeBSD$
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/libc++ \
+ lib/libexecinfo \
+ lib/msun \
+ usr.bin/clang/clang-tblgen.host \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+Host.o: CommentCommandList.inc.h
+Host.o: DeclNodes.inc.h
+Host.o: DiagnosticCommonKinds.inc.h
+Host.o: StmtNodes.inc.h
+Host.po: CommentCommandList.inc.h
+Host.po: DeclNodes.inc.h
+Host.po: DiagnosticCommonKinds.inc.h
+Host.po: StmtNodes.inc.h
+.endif
diff --git a/lib/clang/liblldbHostPOSIX/Makefile.depend b/lib/clang/liblldbHostPOSIX/Makefile.depend
new file mode 100644
index 0000000..3e7f3f5
--- /dev/null
+++ b/lib/clang/liblldbHostPOSIX/Makefile.depend
@@ -0,0 +1,15 @@
+# $FreeBSD$
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/libc++ \
+ lib/msun \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/lib/clang/liblldbInterpreter/Makefile.depend b/lib/clang/liblldbInterpreter/Makefile.depend
new file mode 100644
index 0000000..528ca90
--- /dev/null
+++ b/lib/clang/liblldbInterpreter/Makefile.depend
@@ -0,0 +1,233 @@
+# $FreeBSD$
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/libc++ \
+ lib/libedit \
+ lib/msun \
+ usr.bin/clang/clang-tblgen.host \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+Args.o: AttrList.inc.h
+Args.o: Attrs.inc.h
+Args.o: CommentCommandList.inc.h
+Args.o: DeclNodes.inc.h
+Args.o: DiagnosticCommonKinds.inc.h
+Args.o: StmtNodes.inc.h
+Args.po: AttrList.inc.h
+Args.po: Attrs.inc.h
+Args.po: CommentCommandList.inc.h
+Args.po: DeclNodes.inc.h
+Args.po: DiagnosticCommonKinds.inc.h
+Args.po: StmtNodes.inc.h
+CommandInterpreter.o: AttrList.inc.h
+CommandInterpreter.o: Attrs.inc.h
+CommandInterpreter.o: CommentCommandList.inc.h
+CommandInterpreter.o: DeclNodes.inc.h
+CommandInterpreter.o: DiagnosticCommonKinds.inc.h
+CommandInterpreter.o: StmtNodes.inc.h
+CommandInterpreter.po: AttrList.inc.h
+CommandInterpreter.po: Attrs.inc.h
+CommandInterpreter.po: CommentCommandList.inc.h
+CommandInterpreter.po: DeclNodes.inc.h
+CommandInterpreter.po: DiagnosticCommonKinds.inc.h
+CommandInterpreter.po: StmtNodes.inc.h
+CommandObject.o: AttrList.inc.h
+CommandObject.o: Attrs.inc.h
+CommandObject.o: CommentCommandList.inc.h
+CommandObject.o: DeclNodes.inc.h
+CommandObject.o: DiagnosticCommonKinds.inc.h
+CommandObject.o: StmtNodes.inc.h
+CommandObject.po: AttrList.inc.h
+CommandObject.po: Attrs.inc.h
+CommandObject.po: CommentCommandList.inc.h
+CommandObject.po: DeclNodes.inc.h
+CommandObject.po: DiagnosticCommonKinds.inc.h
+CommandObject.po: StmtNodes.inc.h
+CommandObjectRegexCommand.o: AttrList.inc.h
+CommandObjectRegexCommand.o: Attrs.inc.h
+CommandObjectRegexCommand.o: CommentCommandList.inc.h
+CommandObjectRegexCommand.o: DeclNodes.inc.h
+CommandObjectRegexCommand.o: DiagnosticCommonKinds.inc.h
+CommandObjectRegexCommand.o: StmtNodes.inc.h
+CommandObjectRegexCommand.po: AttrList.inc.h
+CommandObjectRegexCommand.po: Attrs.inc.h
+CommandObjectRegexCommand.po: CommentCommandList.inc.h
+CommandObjectRegexCommand.po: DeclNodes.inc.h
+CommandObjectRegexCommand.po: DiagnosticCommonKinds.inc.h
+CommandObjectRegexCommand.po: StmtNodes.inc.h
+CommandObjectScript.o: AttrList.inc.h
+CommandObjectScript.o: Attrs.inc.h
+CommandObjectScript.o: CommentCommandList.inc.h
+CommandObjectScript.o: DeclNodes.inc.h
+CommandObjectScript.o: DiagnosticCommonKinds.inc.h
+CommandObjectScript.o: StmtNodes.inc.h
+CommandObjectScript.po: AttrList.inc.h
+CommandObjectScript.po: Attrs.inc.h
+CommandObjectScript.po: CommentCommandList.inc.h
+CommandObjectScript.po: DeclNodes.inc.h
+CommandObjectScript.po: DiagnosticCommonKinds.inc.h
+CommandObjectScript.po: StmtNodes.inc.h
+CommandOptionValidators.o: AttrList.inc.h
+CommandOptionValidators.o: Attrs.inc.h
+CommandOptionValidators.o: CommentCommandList.inc.h
+CommandOptionValidators.o: DeclNodes.inc.h
+CommandOptionValidators.o: DiagnosticCommonKinds.inc.h
+CommandOptionValidators.o: StmtNodes.inc.h
+CommandOptionValidators.po: AttrList.inc.h
+CommandOptionValidators.po: Attrs.inc.h
+CommandOptionValidators.po: CommentCommandList.inc.h
+CommandOptionValidators.po: DeclNodes.inc.h
+CommandOptionValidators.po: DiagnosticCommonKinds.inc.h
+CommandOptionValidators.po: StmtNodes.inc.h
+OptionGroupFormat.o: AttrList.inc.h
+OptionGroupFormat.o: Attrs.inc.h
+OptionGroupFormat.o: CommentCommandList.inc.h
+OptionGroupFormat.o: DeclNodes.inc.h
+OptionGroupFormat.o: DiagnosticCommonKinds.inc.h
+OptionGroupFormat.o: StmtNodes.inc.h
+OptionGroupFormat.po: AttrList.inc.h
+OptionGroupFormat.po: Attrs.inc.h
+OptionGroupFormat.po: CommentCommandList.inc.h
+OptionGroupFormat.po: DeclNodes.inc.h
+OptionGroupFormat.po: DiagnosticCommonKinds.inc.h
+OptionGroupFormat.po: StmtNodes.inc.h
+OptionGroupPlatform.o: AttrList.inc.h
+OptionGroupPlatform.o: Attrs.inc.h
+OptionGroupPlatform.o: CommentCommandList.inc.h
+OptionGroupPlatform.o: DeclNodes.inc.h
+OptionGroupPlatform.o: DiagnosticCommonKinds.inc.h
+OptionGroupPlatform.o: StmtNodes.inc.h
+OptionGroupPlatform.po: AttrList.inc.h
+OptionGroupPlatform.po: Attrs.inc.h
+OptionGroupPlatform.po: CommentCommandList.inc.h
+OptionGroupPlatform.po: DeclNodes.inc.h
+OptionGroupPlatform.po: DiagnosticCommonKinds.inc.h
+OptionGroupPlatform.po: StmtNodes.inc.h
+OptionGroupValueObjectDisplay.o: AttrList.inc.h
+OptionGroupValueObjectDisplay.o: Attrs.inc.h
+OptionGroupValueObjectDisplay.o: CommentCommandList.inc.h
+OptionGroupValueObjectDisplay.o: DeclNodes.inc.h
+OptionGroupValueObjectDisplay.o: DiagnosticCommonKinds.inc.h
+OptionGroupValueObjectDisplay.o: StmtNodes.inc.h
+OptionGroupValueObjectDisplay.po: AttrList.inc.h
+OptionGroupValueObjectDisplay.po: Attrs.inc.h
+OptionGroupValueObjectDisplay.po: CommentCommandList.inc.h
+OptionGroupValueObjectDisplay.po: DeclNodes.inc.h
+OptionGroupValueObjectDisplay.po: DiagnosticCommonKinds.inc.h
+OptionGroupValueObjectDisplay.po: StmtNodes.inc.h
+OptionGroupVariable.o: AttrList.inc.h
+OptionGroupVariable.o: Attrs.inc.h
+OptionGroupVariable.o: CommentCommandList.inc.h
+OptionGroupVariable.o: DeclNodes.inc.h
+OptionGroupVariable.o: DiagnosticCommonKinds.inc.h
+OptionGroupVariable.o: StmtNodes.inc.h
+OptionGroupVariable.po: AttrList.inc.h
+OptionGroupVariable.po: Attrs.inc.h
+OptionGroupVariable.po: CommentCommandList.inc.h
+OptionGroupVariable.po: DeclNodes.inc.h
+OptionGroupVariable.po: DiagnosticCommonKinds.inc.h
+OptionGroupVariable.po: StmtNodes.inc.h
+OptionValueArch.o: AttrList.inc.h
+OptionValueArch.o: Attrs.inc.h
+OptionValueArch.o: CommentCommandList.inc.h
+OptionValueArch.o: DeclNodes.inc.h
+OptionValueArch.o: DiagnosticCommonKinds.inc.h
+OptionValueArch.o: StmtNodes.inc.h
+OptionValueArch.po: AttrList.inc.h
+OptionValueArch.po: Attrs.inc.h
+OptionValueArch.po: CommentCommandList.inc.h
+OptionValueArch.po: DeclNodes.inc.h
+OptionValueArch.po: DiagnosticCommonKinds.inc.h
+OptionValueArch.po: StmtNodes.inc.h
+OptionValueDictionary.o: AttrList.inc.h
+OptionValueDictionary.o: Attrs.inc.h
+OptionValueDictionary.o: CommentCommandList.inc.h
+OptionValueDictionary.o: DeclNodes.inc.h
+OptionValueDictionary.o: DiagnosticCommonKinds.inc.h
+OptionValueDictionary.o: StmtNodes.inc.h
+OptionValueDictionary.po: AttrList.inc.h
+OptionValueDictionary.po: Attrs.inc.h
+OptionValueDictionary.po: CommentCommandList.inc.h
+OptionValueDictionary.po: DeclNodes.inc.h
+OptionValueDictionary.po: DiagnosticCommonKinds.inc.h
+OptionValueDictionary.po: StmtNodes.inc.h
+OptionValueFileSpec.o: AttrList.inc.h
+OptionValueFileSpec.o: Attrs.inc.h
+OptionValueFileSpec.o: CommentCommandList.inc.h
+OptionValueFileSpec.o: DeclNodes.inc.h
+OptionValueFileSpec.o: DiagnosticCommonKinds.inc.h
+OptionValueFileSpec.o: StmtNodes.inc.h
+OptionValueFileSpec.po: AttrList.inc.h
+OptionValueFileSpec.po: Attrs.inc.h
+OptionValueFileSpec.po: CommentCommandList.inc.h
+OptionValueFileSpec.po: DeclNodes.inc.h
+OptionValueFileSpec.po: DiagnosticCommonKinds.inc.h
+OptionValueFileSpec.po: StmtNodes.inc.h
+OptionValueFormat.o: AttrList.inc.h
+OptionValueFormat.o: Attrs.inc.h
+OptionValueFormat.o: CommentCommandList.inc.h
+OptionValueFormat.o: DeclNodes.inc.h
+OptionValueFormat.o: DiagnosticCommonKinds.inc.h
+OptionValueFormat.o: StmtNodes.inc.h
+OptionValueFormat.po: AttrList.inc.h
+OptionValueFormat.po: Attrs.inc.h
+OptionValueFormat.po: CommentCommandList.inc.h
+OptionValueFormat.po: DeclNodes.inc.h
+OptionValueFormat.po: DiagnosticCommonKinds.inc.h
+OptionValueFormat.po: StmtNodes.inc.h
+OptionValueUUID.o: AttrList.inc.h
+OptionValueUUID.o: Attrs.inc.h
+OptionValueUUID.o: CommentCommandList.inc.h
+OptionValueUUID.o: DeclNodes.inc.h
+OptionValueUUID.o: DiagnosticCommonKinds.inc.h
+OptionValueUUID.o: StmtNodes.inc.h
+OptionValueUUID.po: AttrList.inc.h
+OptionValueUUID.po: Attrs.inc.h
+OptionValueUUID.po: CommentCommandList.inc.h
+OptionValueUUID.po: DeclNodes.inc.h
+OptionValueUUID.po: DiagnosticCommonKinds.inc.h
+OptionValueUUID.po: StmtNodes.inc.h
+Options.o: AttrList.inc.h
+Options.o: Attrs.inc.h
+Options.o: CommentCommandList.inc.h
+Options.o: DeclNodes.inc.h
+Options.o: DiagnosticCommonKinds.inc.h
+Options.o: StmtNodes.inc.h
+Options.po: AttrList.inc.h
+Options.po: Attrs.inc.h
+Options.po: CommentCommandList.inc.h
+Options.po: DeclNodes.inc.h
+Options.po: DiagnosticCommonKinds.inc.h
+Options.po: StmtNodes.inc.h
+Property.o: AttrList.inc.h
+Property.o: Attrs.inc.h
+Property.o: CommentCommandList.inc.h
+Property.o: DeclNodes.inc.h
+Property.o: DiagnosticCommonKinds.inc.h
+Property.o: StmtNodes.inc.h
+Property.po: AttrList.inc.h
+Property.po: Attrs.inc.h
+Property.po: CommentCommandList.inc.h
+Property.po: DeclNodes.inc.h
+Property.po: DiagnosticCommonKinds.inc.h
+Property.po: StmtNodes.inc.h
+ScriptInterpreterNone.o: AttrList.inc.h
+ScriptInterpreterNone.o: Attrs.inc.h
+ScriptInterpreterNone.o: CommentCommandList.inc.h
+ScriptInterpreterNone.o: DeclNodes.inc.h
+ScriptInterpreterNone.o: DiagnosticCommonKinds.inc.h
+ScriptInterpreterNone.o: StmtNodes.inc.h
+ScriptInterpreterNone.po: AttrList.inc.h
+ScriptInterpreterNone.po: Attrs.inc.h
+ScriptInterpreterNone.po: CommentCommandList.inc.h
+ScriptInterpreterNone.po: DeclNodes.inc.h
+ScriptInterpreterNone.po: DiagnosticCommonKinds.inc.h
+ScriptInterpreterNone.po: StmtNodes.inc.h
+.endif
diff --git a/lib/clang/liblldbPluginABISysV_ppc/Makefile.depend b/lib/clang/liblldbPluginABISysV_ppc/Makefile.depend
new file mode 100644
index 0000000..99d245e
--- /dev/null
+++ b/lib/clang/liblldbPluginABISysV_ppc/Makefile.depend
@@ -0,0 +1,24 @@
+# $FreeBSD$
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/libc++ \
+ lib/msun \
+ usr.bin/clang/clang-tblgen.host \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+ABISysV_ppc.o: CommentCommandList.inc.h
+ABISysV_ppc.o: DeclNodes.inc.h
+ABISysV_ppc.o: DiagnosticCommonKinds.inc.h
+ABISysV_ppc.o: StmtNodes.inc.h
+ABISysV_ppc.po: CommentCommandList.inc.h
+ABISysV_ppc.po: DeclNodes.inc.h
+ABISysV_ppc.po: DiagnosticCommonKinds.inc.h
+ABISysV_ppc.po: StmtNodes.inc.h
+.endif
diff --git a/lib/clang/liblldbPluginABISysV_ppc64/Makefile.depend b/lib/clang/liblldbPluginABISysV_ppc64/Makefile.depend
new file mode 100644
index 0000000..7b45794
--- /dev/null
+++ b/lib/clang/liblldbPluginABISysV_ppc64/Makefile.depend
@@ -0,0 +1,24 @@
+# $FreeBSD$
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/libc++ \
+ lib/msun \
+ usr.bin/clang/clang-tblgen.host \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+ABISysV_ppc64.o: CommentCommandList.inc.h
+ABISysV_ppc64.o: DeclNodes.inc.h
+ABISysV_ppc64.o: DiagnosticCommonKinds.inc.h
+ABISysV_ppc64.o: StmtNodes.inc.h
+ABISysV_ppc64.po: CommentCommandList.inc.h
+ABISysV_ppc64.po: DeclNodes.inc.h
+ABISysV_ppc64.po: DiagnosticCommonKinds.inc.h
+ABISysV_ppc64.po: StmtNodes.inc.h
+.endif
diff --git a/lib/clang/liblldbPluginABISysV_x86_64/Makefile.depend b/lib/clang/liblldbPluginABISysV_x86_64/Makefile.depend
new file mode 100644
index 0000000..219b76f
--- /dev/null
+++ b/lib/clang/liblldbPluginABISysV_x86_64/Makefile.depend
@@ -0,0 +1,24 @@
+# $FreeBSD$
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/libc++ \
+ lib/msun \
+ usr.bin/clang/clang-tblgen.host \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+ABISysV_x86_64.o: CommentCommandList.inc.h
+ABISysV_x86_64.o: DeclNodes.inc.h
+ABISysV_x86_64.o: DiagnosticCommonKinds.inc.h
+ABISysV_x86_64.o: StmtNodes.inc.h
+ABISysV_x86_64.po: CommentCommandList.inc.h
+ABISysV_x86_64.po: DeclNodes.inc.h
+ABISysV_x86_64.po: DiagnosticCommonKinds.inc.h
+ABISysV_x86_64.po: StmtNodes.inc.h
+.endif
diff --git a/lib/clang/liblldbPluginCXXItaniumABI/Makefile.depend b/lib/clang/liblldbPluginCXXItaniumABI/Makefile.depend
new file mode 100644
index 0000000..2307823
--- /dev/null
+++ b/lib/clang/liblldbPluginCXXItaniumABI/Makefile.depend
@@ -0,0 +1,24 @@
+# $FreeBSD$
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/libc++ \
+ lib/msun \
+ usr.bin/clang/clang-tblgen.host \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+ItaniumABILanguageRuntime.o: CommentCommandList.inc.h
+ItaniumABILanguageRuntime.o: DeclNodes.inc.h
+ItaniumABILanguageRuntime.o: DiagnosticCommonKinds.inc.h
+ItaniumABILanguageRuntime.o: StmtNodes.inc.h
+ItaniumABILanguageRuntime.po: CommentCommandList.inc.h
+ItaniumABILanguageRuntime.po: DeclNodes.inc.h
+ItaniumABILanguageRuntime.po: DiagnosticCommonKinds.inc.h
+ItaniumABILanguageRuntime.po: StmtNodes.inc.h
+.endif
diff --git a/lib/clang/liblldbPluginDisassemblerLLVM/Makefile.depend b/lib/clang/liblldbPluginDisassemblerLLVM/Makefile.depend
new file mode 100644
index 0000000..7e043ab
--- /dev/null
+++ b/lib/clang/liblldbPluginDisassemblerLLVM/Makefile.depend
@@ -0,0 +1,24 @@
+# $FreeBSD$
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/libc++ \
+ lib/msun \
+ usr.bin/clang/clang-tblgen.host \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+DisassemblerLLVMC.o: CommentCommandList.inc.h
+DisassemblerLLVMC.o: DeclNodes.inc.h
+DisassemblerLLVMC.o: DiagnosticCommonKinds.inc.h
+DisassemblerLLVMC.o: StmtNodes.inc.h
+DisassemblerLLVMC.po: CommentCommandList.inc.h
+DisassemblerLLVMC.po: DeclNodes.inc.h
+DisassemblerLLVMC.po: DiagnosticCommonKinds.inc.h
+DisassemblerLLVMC.po: StmtNodes.inc.h
+.endif
diff --git a/lib/clang/liblldbPluginDynamicLoaderPosixDYLD/Makefile.depend b/lib/clang/liblldbPluginDynamicLoaderPosixDYLD/Makefile.depend
new file mode 100644
index 0000000..1f641be
--- /dev/null
+++ b/lib/clang/liblldbPluginDynamicLoaderPosixDYLD/Makefile.depend
@@ -0,0 +1,34 @@
+# $FreeBSD$
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/libc++ \
+ lib/msun \
+ usr.bin/clang/clang-tblgen.host \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+AuxVector.o: DiagnosticCommonKinds.inc.h
+AuxVector.po: DiagnosticCommonKinds.inc.h
+DYLDRendezvous.o: CommentCommandList.inc.h
+DYLDRendezvous.o: DeclNodes.inc.h
+DYLDRendezvous.o: DiagnosticCommonKinds.inc.h
+DYLDRendezvous.o: StmtNodes.inc.h
+DYLDRendezvous.po: CommentCommandList.inc.h
+DYLDRendezvous.po: DeclNodes.inc.h
+DYLDRendezvous.po: DiagnosticCommonKinds.inc.h
+DYLDRendezvous.po: StmtNodes.inc.h
+DynamicLoaderPOSIXDYLD.o: CommentCommandList.inc.h
+DynamicLoaderPOSIXDYLD.o: DeclNodes.inc.h
+DynamicLoaderPOSIXDYLD.o: DiagnosticCommonKinds.inc.h
+DynamicLoaderPOSIXDYLD.o: StmtNodes.inc.h
+DynamicLoaderPOSIXDYLD.po: CommentCommandList.inc.h
+DynamicLoaderPOSIXDYLD.po: DeclNodes.inc.h
+DynamicLoaderPOSIXDYLD.po: DiagnosticCommonKinds.inc.h
+DynamicLoaderPOSIXDYLD.po: StmtNodes.inc.h
+.endif
diff --git a/lib/clang/liblldbPluginDynamicLoaderStatic/Makefile.depend b/lib/clang/liblldbPluginDynamicLoaderStatic/Makefile.depend
new file mode 100644
index 0000000..74529c2
--- /dev/null
+++ b/lib/clang/liblldbPluginDynamicLoaderStatic/Makefile.depend
@@ -0,0 +1,24 @@
+# $FreeBSD$
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/libc++ \
+ lib/msun \
+ usr.bin/clang/clang-tblgen.host \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+DynamicLoaderStatic.o: CommentCommandList.inc.h
+DynamicLoaderStatic.o: DeclNodes.inc.h
+DynamicLoaderStatic.o: DiagnosticCommonKinds.inc.h
+DynamicLoaderStatic.o: StmtNodes.inc.h
+DynamicLoaderStatic.po: CommentCommandList.inc.h
+DynamicLoaderStatic.po: DeclNodes.inc.h
+DynamicLoaderStatic.po: DiagnosticCommonKinds.inc.h
+DynamicLoaderStatic.po: StmtNodes.inc.h
+.endif
diff --git a/lib/clang/liblldbPluginInstructionARM/Makefile.depend b/lib/clang/liblldbPluginInstructionARM/Makefile.depend
new file mode 100644
index 0000000..264ede1
--- /dev/null
+++ b/lib/clang/liblldbPluginInstructionARM/Makefile.depend
@@ -0,0 +1,16 @@
+# $FreeBSD$
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/libc++ \
+ lib/msun \
+ usr.bin/clang/clang-tblgen.host \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/lib/clang/liblldbPluginInstructionARM64/Makefile.depend b/lib/clang/liblldbPluginInstructionARM64/Makefile.depend
new file mode 100644
index 0000000..3e7f3f5
--- /dev/null
+++ b/lib/clang/liblldbPluginInstructionARM64/Makefile.depend
@@ -0,0 +1,15 @@
+# $FreeBSD$
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/libc++ \
+ lib/msun \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/lib/clang/liblldbPluginInstrumentationRuntimeAddressSanitizer/Makefile.depend b/lib/clang/liblldbPluginInstrumentationRuntimeAddressSanitizer/Makefile.depend
new file mode 100644
index 0000000..12b075f
--- /dev/null
+++ b/lib/clang/liblldbPluginInstrumentationRuntimeAddressSanitizer/Makefile.depend
@@ -0,0 +1,28 @@
+# $FreeBSD$
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/libc++ \
+ lib/msun \
+ usr.bin/clang/clang-tblgen.host \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+AddressSanitizerRuntime.o: AttrList.inc.h
+AddressSanitizerRuntime.o: Attrs.inc.h
+AddressSanitizerRuntime.o: CommentCommandList.inc.h
+AddressSanitizerRuntime.o: DeclNodes.inc.h
+AddressSanitizerRuntime.o: DiagnosticCommonKinds.inc.h
+AddressSanitizerRuntime.o: StmtNodes.inc.h
+AddressSanitizerRuntime.po: AttrList.inc.h
+AddressSanitizerRuntime.po: Attrs.inc.h
+AddressSanitizerRuntime.po: CommentCommandList.inc.h
+AddressSanitizerRuntime.po: DeclNodes.inc.h
+AddressSanitizerRuntime.po: DiagnosticCommonKinds.inc.h
+AddressSanitizerRuntime.po: StmtNodes.inc.h
+.endif
diff --git a/lib/clang/liblldbPluginJITLoaderGDB/Makefile.depend b/lib/clang/liblldbPluginJITLoaderGDB/Makefile.depend
new file mode 100644
index 0000000..fafe676
--- /dev/null
+++ b/lib/clang/liblldbPluginJITLoaderGDB/Makefile.depend
@@ -0,0 +1,24 @@
+# $FreeBSD$
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/libc++ \
+ lib/msun \
+ usr.bin/clang/clang-tblgen.host \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+JITLoaderGDB.o: CommentCommandList.inc.h
+JITLoaderGDB.o: DeclNodes.inc.h
+JITLoaderGDB.o: DiagnosticCommonKinds.inc.h
+JITLoaderGDB.o: StmtNodes.inc.h
+JITLoaderGDB.po: CommentCommandList.inc.h
+JITLoaderGDB.po: DeclNodes.inc.h
+JITLoaderGDB.po: DiagnosticCommonKinds.inc.h
+JITLoaderGDB.po: StmtNodes.inc.h
+.endif
diff --git a/lib/clang/liblldbPluginMemoryHistoryASan/Makefile.depend b/lib/clang/liblldbPluginMemoryHistoryASan/Makefile.depend
new file mode 100644
index 0000000..19db265
--- /dev/null
+++ b/lib/clang/liblldbPluginMemoryHistoryASan/Makefile.depend
@@ -0,0 +1,24 @@
+# $FreeBSD$
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/libc++ \
+ lib/msun \
+ usr.bin/clang/clang-tblgen.host \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+MemoryHistoryASan.o: CommentCommandList.inc.h
+MemoryHistoryASan.o: DeclNodes.inc.h
+MemoryHistoryASan.o: DiagnosticCommonKinds.inc.h
+MemoryHistoryASan.o: StmtNodes.inc.h
+MemoryHistoryASan.po: CommentCommandList.inc.h
+MemoryHistoryASan.po: DeclNodes.inc.h
+MemoryHistoryASan.po: DiagnosticCommonKinds.inc.h
+MemoryHistoryASan.po: StmtNodes.inc.h
+.endif
diff --git a/lib/clang/liblldbPluginObjectContainerBSDArchive/Makefile.depend b/lib/clang/liblldbPluginObjectContainerBSDArchive/Makefile.depend
new file mode 100644
index 0000000..0f05ea5
--- /dev/null
+++ b/lib/clang/liblldbPluginObjectContainerBSDArchive/Makefile.depend
@@ -0,0 +1,24 @@
+# $FreeBSD$
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/libc++ \
+ lib/msun \
+ usr.bin/clang/clang-tblgen.host \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+ObjectContainerBSDArchive.o: CommentCommandList.inc.h
+ObjectContainerBSDArchive.o: DeclNodes.inc.h
+ObjectContainerBSDArchive.o: DiagnosticCommonKinds.inc.h
+ObjectContainerBSDArchive.o: StmtNodes.inc.h
+ObjectContainerBSDArchive.po: CommentCommandList.inc.h
+ObjectContainerBSDArchive.po: DeclNodes.inc.h
+ObjectContainerBSDArchive.po: DiagnosticCommonKinds.inc.h
+ObjectContainerBSDArchive.po: StmtNodes.inc.h
+.endif
diff --git a/lib/clang/liblldbPluginObjectFileELF/Makefile.depend b/lib/clang/liblldbPluginObjectFileELF/Makefile.depend
new file mode 100644
index 0000000..6690c9f
--- /dev/null
+++ b/lib/clang/liblldbPluginObjectFileELF/Makefile.depend
@@ -0,0 +1,24 @@
+# $FreeBSD$
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/libc++ \
+ lib/msun \
+ usr.bin/clang/clang-tblgen.host \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+ObjectFileELF.o: CommentCommandList.inc.h
+ObjectFileELF.o: DeclNodes.inc.h
+ObjectFileELF.o: DiagnosticCommonKinds.inc.h
+ObjectFileELF.o: StmtNodes.inc.h
+ObjectFileELF.po: CommentCommandList.inc.h
+ObjectFileELF.po: DeclNodes.inc.h
+ObjectFileELF.po: DiagnosticCommonKinds.inc.h
+ObjectFileELF.po: StmtNodes.inc.h
+.endif
diff --git a/lib/clang/liblldbPluginObjectFileJIT/Makefile.depend b/lib/clang/liblldbPluginObjectFileJIT/Makefile.depend
new file mode 100644
index 0000000..d5e55b1
--- /dev/null
+++ b/lib/clang/liblldbPluginObjectFileJIT/Makefile.depend
@@ -0,0 +1,28 @@
+# $FreeBSD$
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/libc++ \
+ lib/msun \
+ usr.bin/clang/clang-tblgen.host \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+ObjectFileJIT.o: AttrList.inc.h
+ObjectFileJIT.o: Attrs.inc.h
+ObjectFileJIT.o: CommentCommandList.inc.h
+ObjectFileJIT.o: DeclNodes.inc.h
+ObjectFileJIT.o: DiagnosticCommonKinds.inc.h
+ObjectFileJIT.o: StmtNodes.inc.h
+ObjectFileJIT.po: AttrList.inc.h
+ObjectFileJIT.po: Attrs.inc.h
+ObjectFileJIT.po: CommentCommandList.inc.h
+ObjectFileJIT.po: DeclNodes.inc.h
+ObjectFileJIT.po: DiagnosticCommonKinds.inc.h
+ObjectFileJIT.po: StmtNodes.inc.h
+.endif
diff --git a/lib/clang/liblldbPluginPlatformFreeBSD/Makefile.depend b/lib/clang/liblldbPluginPlatformFreeBSD/Makefile.depend
new file mode 100644
index 0000000..e4c467b
--- /dev/null
+++ b/lib/clang/liblldbPluginPlatformFreeBSD/Makefile.depend
@@ -0,0 +1,28 @@
+# $FreeBSD$
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/libc++ \
+ lib/msun \
+ usr.bin/clang/clang-tblgen.host \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+PlatformFreeBSD.o: AttrList.inc.h
+PlatformFreeBSD.o: Attrs.inc.h
+PlatformFreeBSD.o: CommentCommandList.inc.h
+PlatformFreeBSD.o: DeclNodes.inc.h
+PlatformFreeBSD.o: DiagnosticCommonKinds.inc.h
+PlatformFreeBSD.o: StmtNodes.inc.h
+PlatformFreeBSD.po: AttrList.inc.h
+PlatformFreeBSD.po: Attrs.inc.h
+PlatformFreeBSD.po: CommentCommandList.inc.h
+PlatformFreeBSD.po: DeclNodes.inc.h
+PlatformFreeBSD.po: DiagnosticCommonKinds.inc.h
+PlatformFreeBSD.po: StmtNodes.inc.h
+.endif
diff --git a/lib/clang/liblldbPluginPlatformGDB/Makefile.depend b/lib/clang/liblldbPluginPlatformGDB/Makefile.depend
new file mode 100644
index 0000000..114af26
--- /dev/null
+++ b/lib/clang/liblldbPluginPlatformGDB/Makefile.depend
@@ -0,0 +1,28 @@
+# $FreeBSD$
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/libc++ \
+ lib/msun \
+ usr.bin/clang/clang-tblgen.host \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+PlatformRemoteGDBServer.o: AttrList.inc.h
+PlatformRemoteGDBServer.o: Attrs.inc.h
+PlatformRemoteGDBServer.o: CommentCommandList.inc.h
+PlatformRemoteGDBServer.o: DeclNodes.inc.h
+PlatformRemoteGDBServer.o: DiagnosticCommonKinds.inc.h
+PlatformRemoteGDBServer.o: StmtNodes.inc.h
+PlatformRemoteGDBServer.po: AttrList.inc.h
+PlatformRemoteGDBServer.po: Attrs.inc.h
+PlatformRemoteGDBServer.po: CommentCommandList.inc.h
+PlatformRemoteGDBServer.po: DeclNodes.inc.h
+PlatformRemoteGDBServer.po: DiagnosticCommonKinds.inc.h
+PlatformRemoteGDBServer.po: StmtNodes.inc.h
+.endif
diff --git a/lib/clang/liblldbPluginProcessElfCore/Makefile.depend b/lib/clang/liblldbPluginProcessElfCore/Makefile.depend
new file mode 100644
index 0000000..3714330
--- /dev/null
+++ b/lib/clang/liblldbPluginProcessElfCore/Makefile.depend
@@ -0,0 +1,26 @@
+# $FreeBSD$
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/libc++ \
+ lib/msun \
+ usr.bin/clang/clang-tblgen.host \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+ProcessElfCore.o: CommentCommandList.inc.h
+ProcessElfCore.o: DeclNodes.inc.h
+ProcessElfCore.o: DiagnosticCommonKinds.inc.h
+ProcessElfCore.o: StmtNodes.inc.h
+ProcessElfCore.po: CommentCommandList.inc.h
+ProcessElfCore.po: DeclNodes.inc.h
+ProcessElfCore.po: DiagnosticCommonKinds.inc.h
+ProcessElfCore.po: StmtNodes.inc.h
+ThreadElfCore.o: DiagnosticCommonKinds.inc.h
+ThreadElfCore.po: DiagnosticCommonKinds.inc.h
+.endif
diff --git a/lib/clang/liblldbPluginProcessFreeBSD/Makefile.depend b/lib/clang/liblldbPluginProcessFreeBSD/Makefile.depend
new file mode 100644
index 0000000..4b79ea4
--- /dev/null
+++ b/lib/clang/liblldbPluginProcessFreeBSD/Makefile.depend
@@ -0,0 +1,22 @@
+# $FreeBSD$
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/libc++ \
+ lib/msun \
+ usr.bin/clang/clang-tblgen.host \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+FreeBSDThread.o: DiagnosticCommonKinds.inc.h
+FreeBSDThread.po: DiagnosticCommonKinds.inc.h
+ProcessFreeBSD.o: DiagnosticCommonKinds.inc.h
+ProcessFreeBSD.po: DiagnosticCommonKinds.inc.h
+ProcessMonitor.o: DiagnosticCommonKinds.inc.h
+ProcessMonitor.po: DiagnosticCommonKinds.inc.h
+.endif
diff --git a/lib/clang/liblldbPluginProcessGDBRemote/Makefile.depend b/lib/clang/liblldbPluginProcessGDBRemote/Makefile.depend
new file mode 100644
index 0000000..a8571b4
--- /dev/null
+++ b/lib/clang/liblldbPluginProcessGDBRemote/Makefile.depend
@@ -0,0 +1,50 @@
+# $FreeBSD$
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/libc++ \
+ lib/msun \
+ usr.bin/clang/clang-tblgen.host \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+GDBRemoteCommunication.o: DiagnosticCommonKinds.inc.h
+GDBRemoteCommunication.po: DiagnosticCommonKinds.inc.h
+GDBRemoteCommunicationClient.o: DiagnosticCommonKinds.inc.h
+GDBRemoteCommunicationClient.po: DiagnosticCommonKinds.inc.h
+GDBRemoteCommunicationServer.o: AttrList.inc.h
+GDBRemoteCommunicationServer.o: Attrs.inc.h
+GDBRemoteCommunicationServer.o: CommentCommandList.inc.h
+GDBRemoteCommunicationServer.o: DeclNodes.inc.h
+GDBRemoteCommunicationServer.o: DiagnosticCommonKinds.inc.h
+GDBRemoteCommunicationServer.o: StmtNodes.inc.h
+GDBRemoteCommunicationServer.po: AttrList.inc.h
+GDBRemoteCommunicationServer.po: Attrs.inc.h
+GDBRemoteCommunicationServer.po: CommentCommandList.inc.h
+GDBRemoteCommunicationServer.po: DeclNodes.inc.h
+GDBRemoteCommunicationServer.po: DiagnosticCommonKinds.inc.h
+GDBRemoteCommunicationServer.po: StmtNodes.inc.h
+GDBRemoteRegisterContext.o: DiagnosticCommonKinds.inc.h
+GDBRemoteRegisterContext.po: DiagnosticCommonKinds.inc.h
+ProcessGDBRemote.o: AttrList.inc.h
+ProcessGDBRemote.o: Attrs.inc.h
+ProcessGDBRemote.o: CommentCommandList.inc.h
+ProcessGDBRemote.o: DeclNodes.inc.h
+ProcessGDBRemote.o: DiagnosticCommonKinds.inc.h
+ProcessGDBRemote.o: StmtNodes.inc.h
+ProcessGDBRemote.po: AttrList.inc.h
+ProcessGDBRemote.po: Attrs.inc.h
+ProcessGDBRemote.po: CommentCommandList.inc.h
+ProcessGDBRemote.po: DeclNodes.inc.h
+ProcessGDBRemote.po: DiagnosticCommonKinds.inc.h
+ProcessGDBRemote.po: StmtNodes.inc.h
+ProcessGDBRemoteLog.o: DiagnosticCommonKinds.inc.h
+ProcessGDBRemoteLog.po: DiagnosticCommonKinds.inc.h
+ThreadGDBRemote.o: DiagnosticCommonKinds.inc.h
+ThreadGDBRemote.po: DiagnosticCommonKinds.inc.h
+.endif
diff --git a/lib/clang/liblldbPluginProcessPOSIX/Makefile.depend b/lib/clang/liblldbPluginProcessPOSIX/Makefile.depend
new file mode 100644
index 0000000..6a083b8
--- /dev/null
+++ b/lib/clang/liblldbPluginProcessPOSIX/Makefile.depend
@@ -0,0 +1,48 @@
+# $FreeBSD$
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/libc++ \
+ lib/msun \
+ usr.bin/clang/clang-tblgen.host \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+POSIXStopInfo.o: DiagnosticCommonKinds.inc.h
+POSIXStopInfo.po: DiagnosticCommonKinds.inc.h
+POSIXThread.o: AttrList.inc.h
+POSIXThread.o: Attrs.inc.h
+POSIXThread.o: CommentCommandList.inc.h
+POSIXThread.o: DeclNodes.inc.h
+POSIXThread.o: DiagnosticCommonKinds.inc.h
+POSIXThread.o: StmtNodes.inc.h
+POSIXThread.po: AttrList.inc.h
+POSIXThread.po: Attrs.inc.h
+POSIXThread.po: CommentCommandList.inc.h
+POSIXThread.po: DeclNodes.inc.h
+POSIXThread.po: DiagnosticCommonKinds.inc.h
+POSIXThread.po: StmtNodes.inc.h
+ProcessPOSIX.o: CommentCommandList.inc.h
+ProcessPOSIX.o: DeclNodes.inc.h
+ProcessPOSIX.o: DiagnosticCommonKinds.inc.h
+ProcessPOSIX.o: StmtNodes.inc.h
+ProcessPOSIX.po: CommentCommandList.inc.h
+ProcessPOSIX.po: DeclNodes.inc.h
+ProcessPOSIX.po: DiagnosticCommonKinds.inc.h
+ProcessPOSIX.po: StmtNodes.inc.h
+ProcessPOSIXLog.o: DiagnosticCommonKinds.inc.h
+ProcessPOSIXLog.po: DiagnosticCommonKinds.inc.h
+RegisterContextPOSIXProcessMonitor_arm64.o: DiagnosticCommonKinds.inc.h
+RegisterContextPOSIXProcessMonitor_arm64.po: DiagnosticCommonKinds.inc.h
+RegisterContextPOSIXProcessMonitor_mips64.o: DiagnosticCommonKinds.inc.h
+RegisterContextPOSIXProcessMonitor_mips64.po: DiagnosticCommonKinds.inc.h
+RegisterContextPOSIXProcessMonitor_powerpc.o: DiagnosticCommonKinds.inc.h
+RegisterContextPOSIXProcessMonitor_powerpc.po: DiagnosticCommonKinds.inc.h
+RegisterContextPOSIXProcessMonitor_x86.o: DiagnosticCommonKinds.inc.h
+RegisterContextPOSIXProcessMonitor_x86.po: DiagnosticCommonKinds.inc.h
+.endif
diff --git a/lib/clang/liblldbPluginProcessUtility/Makefile.depend b/lib/clang/liblldbPluginProcessUtility/Makefile.depend
new file mode 100644
index 0000000..e9bd3c9
--- /dev/null
+++ b/lib/clang/liblldbPluginProcessUtility/Makefile.depend
@@ -0,0 +1,90 @@
+# $FreeBSD$
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/libc++ \
+ lib/msun \
+ usr.bin/clang/clang-tblgen.host \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+DynamicRegisterInfo.o: AttrList.inc.h
+DynamicRegisterInfo.o: Attrs.inc.h
+DynamicRegisterInfo.o: CommentCommandList.inc.h
+DynamicRegisterInfo.o: DeclNodes.inc.h
+DynamicRegisterInfo.o: DiagnosticCommonKinds.inc.h
+DynamicRegisterInfo.o: StmtNodes.inc.h
+DynamicRegisterInfo.po: AttrList.inc.h
+DynamicRegisterInfo.po: Attrs.inc.h
+DynamicRegisterInfo.po: CommentCommandList.inc.h
+DynamicRegisterInfo.po: DeclNodes.inc.h
+DynamicRegisterInfo.po: DiagnosticCommonKinds.inc.h
+DynamicRegisterInfo.po: StmtNodes.inc.h
+HistoryThread.o: DiagnosticCommonKinds.inc.h
+HistoryThread.po: DiagnosticCommonKinds.inc.h
+HistoryUnwind.o: DiagnosticCommonKinds.inc.h
+HistoryUnwind.po: DiagnosticCommonKinds.inc.h
+InferiorCallPOSIX.o: CommentCommandList.inc.h
+InferiorCallPOSIX.o: DeclNodes.inc.h
+InferiorCallPOSIX.o: DiagnosticCommonKinds.inc.h
+InferiorCallPOSIX.o: StmtNodes.inc.h
+InferiorCallPOSIX.po: CommentCommandList.inc.h
+InferiorCallPOSIX.po: DeclNodes.inc.h
+InferiorCallPOSIX.po: DiagnosticCommonKinds.inc.h
+InferiorCallPOSIX.po: StmtNodes.inc.h
+RegisterContextDummy.o: CommentCommandList.inc.h
+RegisterContextDummy.o: DeclNodes.inc.h
+RegisterContextDummy.o: DiagnosticCommonKinds.inc.h
+RegisterContextDummy.o: StmtNodes.inc.h
+RegisterContextDummy.po: CommentCommandList.inc.h
+RegisterContextDummy.po: DeclNodes.inc.h
+RegisterContextDummy.po: DiagnosticCommonKinds.inc.h
+RegisterContextDummy.po: StmtNodes.inc.h
+RegisterContextHistory.o: CommentCommandList.inc.h
+RegisterContextHistory.o: DeclNodes.inc.h
+RegisterContextHistory.o: DiagnosticCommonKinds.inc.h
+RegisterContextHistory.o: StmtNodes.inc.h
+RegisterContextHistory.po: CommentCommandList.inc.h
+RegisterContextHistory.po: DeclNodes.inc.h
+RegisterContextHistory.po: DiagnosticCommonKinds.inc.h
+RegisterContextHistory.po: StmtNodes.inc.h
+RegisterContextLLDB.o: CommentCommandList.inc.h
+RegisterContextLLDB.o: DeclNodes.inc.h
+RegisterContextLLDB.o: DiagnosticCommonKinds.inc.h
+RegisterContextLLDB.o: StmtNodes.inc.h
+RegisterContextLLDB.po: CommentCommandList.inc.h
+RegisterContextLLDB.po: DeclNodes.inc.h
+RegisterContextLLDB.po: DiagnosticCommonKinds.inc.h
+RegisterContextLLDB.po: StmtNodes.inc.h
+RegisterContextMemory.o: DiagnosticCommonKinds.inc.h
+RegisterContextMemory.po: DiagnosticCommonKinds.inc.h
+RegisterContextPOSIX_arm64.o: DiagnosticCommonKinds.inc.h
+RegisterContextPOSIX_arm64.po: DiagnosticCommonKinds.inc.h
+RegisterContextPOSIX_mips64.o: DiagnosticCommonKinds.inc.h
+RegisterContextPOSIX_mips64.po: DiagnosticCommonKinds.inc.h
+RegisterContextPOSIX_powerpc.o: DiagnosticCommonKinds.inc.h
+RegisterContextPOSIX_powerpc.po: DiagnosticCommonKinds.inc.h
+RegisterContextPOSIX_x86.o: DiagnosticCommonKinds.inc.h
+RegisterContextPOSIX_x86.po: DiagnosticCommonKinds.inc.h
+RegisterContextThreadMemory.o: DiagnosticCommonKinds.inc.h
+RegisterContextThreadMemory.po: DiagnosticCommonKinds.inc.h
+StopInfoMachException.o: DiagnosticCommonKinds.inc.h
+StopInfoMachException.po: DiagnosticCommonKinds.inc.h
+ThreadMemory.o: DiagnosticCommonKinds.inc.h
+ThreadMemory.po: DiagnosticCommonKinds.inc.h
+UnwindLLDB.o: CommentCommandList.inc.h
+UnwindLLDB.o: DeclNodes.inc.h
+UnwindLLDB.o: DiagnosticCommonKinds.inc.h
+UnwindLLDB.o: StmtNodes.inc.h
+UnwindLLDB.po: CommentCommandList.inc.h
+UnwindLLDB.po: DeclNodes.inc.h
+UnwindLLDB.po: DiagnosticCommonKinds.inc.h
+UnwindLLDB.po: StmtNodes.inc.h
+UnwindMacOSXFrameBackchain.o: DiagnosticCommonKinds.inc.h
+UnwindMacOSXFrameBackchain.po: DiagnosticCommonKinds.inc.h
+.endif
diff --git a/lib/clang/liblldbPluginSymbolFileDWARF/Makefile.depend b/lib/clang/liblldbPluginSymbolFileDWARF/Makefile.depend
new file mode 100644
index 0000000..bd5227d
--- /dev/null
+++ b/lib/clang/liblldbPluginSymbolFileDWARF/Makefile.depend
@@ -0,0 +1,199 @@
+# $FreeBSD$
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/libc++ \
+ lib/msun \
+ usr.bin/clang/clang-tblgen.host \
+ usr.bin/clang/tblgen.host \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+DWARFAbbreviationDeclaration.o: CommentCommandList.inc.h
+DWARFAbbreviationDeclaration.o: DeclNodes.inc.h
+DWARFAbbreviationDeclaration.o: DiagnosticCommonKinds.inc.h
+DWARFAbbreviationDeclaration.o: StmtNodes.inc.h
+DWARFAbbreviationDeclaration.po: CommentCommandList.inc.h
+DWARFAbbreviationDeclaration.po: DeclNodes.inc.h
+DWARFAbbreviationDeclaration.po: DiagnosticCommonKinds.inc.h
+DWARFAbbreviationDeclaration.po: StmtNodes.inc.h
+DWARFCompileUnit.o: CommentCommandList.inc.h
+DWARFCompileUnit.o: DeclNodes.inc.h
+DWARFCompileUnit.o: DiagnosticCommonKinds.inc.h
+DWARFCompileUnit.o: StmtNodes.inc.h
+DWARFCompileUnit.po: CommentCommandList.inc.h
+DWARFCompileUnit.po: DeclNodes.inc.h
+DWARFCompileUnit.po: DiagnosticCommonKinds.inc.h
+DWARFCompileUnit.po: StmtNodes.inc.h
+DWARFDIECollection.o: CommentCommandList.inc.h
+DWARFDIECollection.o: DeclNodes.inc.h
+DWARFDIECollection.o: DiagnosticCommonKinds.inc.h
+DWARFDIECollection.o: StmtNodes.inc.h
+DWARFDIECollection.po: CommentCommandList.inc.h
+DWARFDIECollection.po: DeclNodes.inc.h
+DWARFDIECollection.po: DiagnosticCommonKinds.inc.h
+DWARFDIECollection.po: StmtNodes.inc.h
+DWARFDebugAbbrev.o: CommentCommandList.inc.h
+DWARFDebugAbbrev.o: DeclNodes.inc.h
+DWARFDebugAbbrev.o: DiagnosticCommonKinds.inc.h
+DWARFDebugAbbrev.o: StmtNodes.inc.h
+DWARFDebugAbbrev.po: CommentCommandList.inc.h
+DWARFDebugAbbrev.po: DeclNodes.inc.h
+DWARFDebugAbbrev.po: DiagnosticCommonKinds.inc.h
+DWARFDebugAbbrev.po: StmtNodes.inc.h
+DWARFDebugArangeSet.o: CommentCommandList.inc.h
+DWARFDebugArangeSet.o: DeclNodes.inc.h
+DWARFDebugArangeSet.o: DiagnosticCommonKinds.inc.h
+DWARFDebugArangeSet.o: StmtNodes.inc.h
+DWARFDebugArangeSet.po: CommentCommandList.inc.h
+DWARFDebugArangeSet.po: DeclNodes.inc.h
+DWARFDebugArangeSet.po: DiagnosticCommonKinds.inc.h
+DWARFDebugArangeSet.po: StmtNodes.inc.h
+DWARFDebugAranges.o: CommentCommandList.inc.h
+DWARFDebugAranges.o: DeclNodes.inc.h
+DWARFDebugAranges.o: DiagnosticCommonKinds.inc.h
+DWARFDebugAranges.o: StmtNodes.inc.h
+DWARFDebugAranges.po: CommentCommandList.inc.h
+DWARFDebugAranges.po: DeclNodes.inc.h
+DWARFDebugAranges.po: DiagnosticCommonKinds.inc.h
+DWARFDebugAranges.po: StmtNodes.inc.h
+DWARFDebugInfo.o: CommentCommandList.inc.h
+DWARFDebugInfo.o: DeclNodes.inc.h
+DWARFDebugInfo.o: DiagnosticCommonKinds.inc.h
+DWARFDebugInfo.o: StmtNodes.inc.h
+DWARFDebugInfo.po: CommentCommandList.inc.h
+DWARFDebugInfo.po: DeclNodes.inc.h
+DWARFDebugInfo.po: DiagnosticCommonKinds.inc.h
+DWARFDebugInfo.po: StmtNodes.inc.h
+DWARFDebugInfoEntry.o: CommentCommandList.inc.h
+DWARFDebugInfoEntry.o: DeclNodes.inc.h
+DWARFDebugInfoEntry.o: DiagnosticCommonKinds.inc.h
+DWARFDebugInfoEntry.o: StmtNodes.inc.h
+DWARFDebugInfoEntry.po: CommentCommandList.inc.h
+DWARFDebugInfoEntry.po: DeclNodes.inc.h
+DWARFDebugInfoEntry.po: DiagnosticCommonKinds.inc.h
+DWARFDebugInfoEntry.po: StmtNodes.inc.h
+DWARFDebugLine.o: CommentCommandList.inc.h
+DWARFDebugLine.o: DeclNodes.inc.h
+DWARFDebugLine.o: DiagnosticCommonKinds.inc.h
+DWARFDebugLine.o: StmtNodes.inc.h
+DWARFDebugLine.po: CommentCommandList.inc.h
+DWARFDebugLine.po: DeclNodes.inc.h
+DWARFDebugLine.po: DiagnosticCommonKinds.inc.h
+DWARFDebugLine.po: StmtNodes.inc.h
+DWARFDebugMacinfo.o: CommentCommandList.inc.h
+DWARFDebugMacinfo.o: DeclNodes.inc.h
+DWARFDebugMacinfo.o: DiagnosticCommonKinds.inc.h
+DWARFDebugMacinfo.o: StmtNodes.inc.h
+DWARFDebugMacinfo.po: CommentCommandList.inc.h
+DWARFDebugMacinfo.po: DeclNodes.inc.h
+DWARFDebugMacinfo.po: DiagnosticCommonKinds.inc.h
+DWARFDebugMacinfo.po: StmtNodes.inc.h
+DWARFDebugMacinfoEntry.o: CommentCommandList.inc.h
+DWARFDebugMacinfoEntry.o: DeclNodes.inc.h
+DWARFDebugMacinfoEntry.o: DiagnosticCommonKinds.inc.h
+DWARFDebugMacinfoEntry.o: StmtNodes.inc.h
+DWARFDebugMacinfoEntry.po: CommentCommandList.inc.h
+DWARFDebugMacinfoEntry.po: DeclNodes.inc.h
+DWARFDebugMacinfoEntry.po: DiagnosticCommonKinds.inc.h
+DWARFDebugMacinfoEntry.po: StmtNodes.inc.h
+DWARFDebugPubnames.o: CommentCommandList.inc.h
+DWARFDebugPubnames.o: DeclNodes.inc.h
+DWARFDebugPubnames.o: DiagnosticCommonKinds.inc.h
+DWARFDebugPubnames.o: StmtNodes.inc.h
+DWARFDebugPubnames.po: CommentCommandList.inc.h
+DWARFDebugPubnames.po: DeclNodes.inc.h
+DWARFDebugPubnames.po: DiagnosticCommonKinds.inc.h
+DWARFDebugPubnames.po: StmtNodes.inc.h
+DWARFDebugPubnamesSet.o: CommentCommandList.inc.h
+DWARFDebugPubnamesSet.o: DeclNodes.inc.h
+DWARFDebugPubnamesSet.o: DiagnosticCommonKinds.inc.h
+DWARFDebugPubnamesSet.o: StmtNodes.inc.h
+DWARFDebugPubnamesSet.po: CommentCommandList.inc.h
+DWARFDebugPubnamesSet.po: DeclNodes.inc.h
+DWARFDebugPubnamesSet.po: DiagnosticCommonKinds.inc.h
+DWARFDebugPubnamesSet.po: StmtNodes.inc.h
+DWARFDebugRanges.o: CommentCommandList.inc.h
+DWARFDebugRanges.o: DeclNodes.inc.h
+DWARFDebugRanges.o: DiagnosticCommonKinds.inc.h
+DWARFDebugRanges.o: StmtNodes.inc.h
+DWARFDebugRanges.po: CommentCommandList.inc.h
+DWARFDebugRanges.po: DeclNodes.inc.h
+DWARFDebugRanges.po: DiagnosticCommonKinds.inc.h
+DWARFDebugRanges.po: StmtNodes.inc.h
+DWARFFormValue.o: CommentCommandList.inc.h
+DWARFFormValue.o: DeclNodes.inc.h
+DWARFFormValue.o: DiagnosticCommonKinds.inc.h
+DWARFFormValue.o: StmtNodes.inc.h
+DWARFFormValue.po: CommentCommandList.inc.h
+DWARFFormValue.po: DeclNodes.inc.h
+DWARFFormValue.po: DiagnosticCommonKinds.inc.h
+DWARFFormValue.po: StmtNodes.inc.h
+DWARFLocationDescription.o: CommentCommandList.inc.h
+DWARFLocationDescription.o: DeclNodes.inc.h
+DWARFLocationDescription.o: DiagnosticCommonKinds.inc.h
+DWARFLocationDescription.o: StmtNodes.inc.h
+DWARFLocationDescription.po: CommentCommandList.inc.h
+DWARFLocationDescription.po: DeclNodes.inc.h
+DWARFLocationDescription.po: DiagnosticCommonKinds.inc.h
+DWARFLocationDescription.po: StmtNodes.inc.h
+DWARFLocationList.o: CommentCommandList.inc.h
+DWARFLocationList.o: DeclNodes.inc.h
+DWARFLocationList.o: DiagnosticCommonKinds.inc.h
+DWARFLocationList.o: StmtNodes.inc.h
+DWARFLocationList.po: CommentCommandList.inc.h
+DWARFLocationList.po: DeclNodes.inc.h
+DWARFLocationList.po: DiagnosticCommonKinds.inc.h
+DWARFLocationList.po: StmtNodes.inc.h
+LogChannelDWARF.o: CommentCommandList.inc.h
+LogChannelDWARF.o: DeclNodes.inc.h
+LogChannelDWARF.o: DiagnosticCommonKinds.inc.h
+LogChannelDWARF.o: StmtNodes.inc.h
+LogChannelDWARF.po: CommentCommandList.inc.h
+LogChannelDWARF.po: DeclNodes.inc.h
+LogChannelDWARF.po: DiagnosticCommonKinds.inc.h
+LogChannelDWARF.po: StmtNodes.inc.h
+NameToDIE.o: CommentCommandList.inc.h
+NameToDIE.o: DeclNodes.inc.h
+NameToDIE.o: DiagnosticCommonKinds.inc.h
+NameToDIE.o: StmtNodes.inc.h
+NameToDIE.po: CommentCommandList.inc.h
+NameToDIE.po: DeclNodes.inc.h
+NameToDIE.po: DiagnosticCommonKinds.inc.h
+NameToDIE.po: StmtNodes.inc.h
+SymbolFileDWARF.o: AttrList.inc.h
+SymbolFileDWARF.o: AttrParsedAttrList.inc.h
+SymbolFileDWARF.o: Attrs.inc.h
+SymbolFileDWARF.o: CommentCommandList.inc.h
+SymbolFileDWARF.o: DeclNodes.inc.h
+SymbolFileDWARF.o: DiagnosticCommonKinds.inc.h
+SymbolFileDWARF.o: StmtNodes.inc.h
+SymbolFileDWARF.po: AttrList.inc.h
+SymbolFileDWARF.po: AttrParsedAttrList.inc.h
+SymbolFileDWARF.po: Attrs.inc.h
+SymbolFileDWARF.po: CommentCommandList.inc.h
+SymbolFileDWARF.po: DeclNodes.inc.h
+SymbolFileDWARF.po: DiagnosticCommonKinds.inc.h
+SymbolFileDWARF.po: StmtNodes.inc.h
+SymbolFileDWARFDebugMap.o: CommentCommandList.inc.h
+SymbolFileDWARFDebugMap.o: DeclNodes.inc.h
+SymbolFileDWARFDebugMap.o: DiagnosticCommonKinds.inc.h
+SymbolFileDWARFDebugMap.o: StmtNodes.inc.h
+SymbolFileDWARFDebugMap.po: CommentCommandList.inc.h
+SymbolFileDWARFDebugMap.po: DeclNodes.inc.h
+SymbolFileDWARFDebugMap.po: DiagnosticCommonKinds.inc.h
+SymbolFileDWARFDebugMap.po: StmtNodes.inc.h
+UniqueDWARFASTType.o: CommentCommandList.inc.h
+UniqueDWARFASTType.o: DeclNodes.inc.h
+UniqueDWARFASTType.o: DiagnosticCommonKinds.inc.h
+UniqueDWARFASTType.o: StmtNodes.inc.h
+UniqueDWARFASTType.po: CommentCommandList.inc.h
+UniqueDWARFASTType.po: DeclNodes.inc.h
+UniqueDWARFASTType.po: DiagnosticCommonKinds.inc.h
+UniqueDWARFASTType.po: StmtNodes.inc.h
+.endif
diff --git a/lib/clang/liblldbPluginSymbolFileSymtab/Makefile.depend b/lib/clang/liblldbPluginSymbolFileSymtab/Makefile.depend
new file mode 100644
index 0000000..f23a43d
--- /dev/null
+++ b/lib/clang/liblldbPluginSymbolFileSymtab/Makefile.depend
@@ -0,0 +1,24 @@
+# $FreeBSD$
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/libc++ \
+ lib/msun \
+ usr.bin/clang/clang-tblgen.host \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+SymbolFileSymtab.o: CommentCommandList.inc.h
+SymbolFileSymtab.o: DeclNodes.inc.h
+SymbolFileSymtab.o: DiagnosticCommonKinds.inc.h
+SymbolFileSymtab.o: StmtNodes.inc.h
+SymbolFileSymtab.po: CommentCommandList.inc.h
+SymbolFileSymtab.po: DeclNodes.inc.h
+SymbolFileSymtab.po: DiagnosticCommonKinds.inc.h
+SymbolFileSymtab.po: StmtNodes.inc.h
+.endif
diff --git a/lib/clang/liblldbPluginSymbolVendorELF/Makefile.depend b/lib/clang/liblldbPluginSymbolVendorELF/Makefile.depend
new file mode 100644
index 0000000..9871a5f
--- /dev/null
+++ b/lib/clang/liblldbPluginSymbolVendorELF/Makefile.depend
@@ -0,0 +1,24 @@
+# $FreeBSD$
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/libc++ \
+ lib/msun \
+ usr.bin/clang/clang-tblgen.host \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+SymbolVendorELF.o: CommentCommandList.inc.h
+SymbolVendorELF.o: DeclNodes.inc.h
+SymbolVendorELF.o: DiagnosticCommonKinds.inc.h
+SymbolVendorELF.o: StmtNodes.inc.h
+SymbolVendorELF.po: CommentCommandList.inc.h
+SymbolVendorELF.po: DeclNodes.inc.h
+SymbolVendorELF.po: DiagnosticCommonKinds.inc.h
+SymbolVendorELF.po: StmtNodes.inc.h
+.endif
diff --git a/lib/clang/liblldbPluginUnwindAssemblyInstEmulation/Makefile.depend b/lib/clang/liblldbPluginUnwindAssemblyInstEmulation/Makefile.depend
new file mode 100644
index 0000000..b8b6989
--- /dev/null
+++ b/lib/clang/liblldbPluginUnwindAssemblyInstEmulation/Makefile.depend
@@ -0,0 +1,18 @@
+# $FreeBSD$
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/libc++ \
+ lib/msun \
+ usr.bin/clang/clang-tblgen.host \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+UnwindAssemblyInstEmulation.o: DiagnosticCommonKinds.inc.h
+UnwindAssemblyInstEmulation.po: DiagnosticCommonKinds.inc.h
+.endif
diff --git a/lib/clang/liblldbPluginUnwindAssemblyX86/Makefile.depend b/lib/clang/liblldbPluginUnwindAssemblyX86/Makefile.depend
new file mode 100644
index 0000000..d01a053
--- /dev/null
+++ b/lib/clang/liblldbPluginUnwindAssemblyX86/Makefile.depend
@@ -0,0 +1,18 @@
+# $FreeBSD$
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/libc++ \
+ lib/msun \
+ usr.bin/clang/clang-tblgen.host \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+UnwindAssembly-x86.o: DiagnosticCommonKinds.inc.h
+UnwindAssembly-x86.po: DiagnosticCommonKinds.inc.h
+.endif
diff --git a/lib/clang/liblldbSymbol/Makefile.depend b/lib/clang/liblldbSymbol/Makefile.depend
new file mode 100644
index 0000000..486a3ae
--- /dev/null
+++ b/lib/clang/liblldbSymbol/Makefile.depend
@@ -0,0 +1,208 @@
+# $FreeBSD$
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/libc++ \
+ lib/msun \
+ usr.bin/clang/clang-tblgen.host \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+Block.o: CommentCommandList.inc.h
+Block.o: DeclNodes.inc.h
+Block.o: DiagnosticCommonKinds.inc.h
+Block.o: StmtNodes.inc.h
+Block.po: CommentCommandList.inc.h
+Block.po: DeclNodes.inc.h
+Block.po: DiagnosticCommonKinds.inc.h
+Block.po: StmtNodes.inc.h
+ClangASTContext.o: AttrList.inc.h
+ClangASTContext.o: Attrs.inc.h
+ClangASTContext.o: CommentCommandList.inc.h
+ClangASTContext.o: DeclNodes.inc.h
+ClangASTContext.o: DiagnosticCommonKinds.inc.h
+ClangASTContext.o: StmtNodes.inc.h
+ClangASTContext.po: AttrList.inc.h
+ClangASTContext.po: Attrs.inc.h
+ClangASTContext.po: CommentCommandList.inc.h
+ClangASTContext.po: DeclNodes.inc.h
+ClangASTContext.po: DiagnosticCommonKinds.inc.h
+ClangASTContext.po: StmtNodes.inc.h
+ClangASTImporter.o: AttrList.inc.h
+ClangASTImporter.o: Attrs.inc.h
+ClangASTImporter.o: CommentCommandList.inc.h
+ClangASTImporter.o: DeclNodes.inc.h
+ClangASTImporter.o: DiagnosticCommonKinds.inc.h
+ClangASTImporter.o: StmtNodes.inc.h
+ClangASTImporter.po: AttrList.inc.h
+ClangASTImporter.po: Attrs.inc.h
+ClangASTImporter.po: CommentCommandList.inc.h
+ClangASTImporter.po: DeclNodes.inc.h
+ClangASTImporter.po: DiagnosticCommonKinds.inc.h
+ClangASTImporter.po: StmtNodes.inc.h
+ClangASTType.o: AttrList.inc.h
+ClangASTType.o: Attrs.inc.h
+ClangASTType.o: CommentCommandList.inc.h
+ClangASTType.o: DeclNodes.inc.h
+ClangASTType.o: DiagnosticCommonKinds.inc.h
+ClangASTType.o: StmtNodes.inc.h
+ClangASTType.po: AttrList.inc.h
+ClangASTType.po: Attrs.inc.h
+ClangASTType.po: CommentCommandList.inc.h
+ClangASTType.po: DeclNodes.inc.h
+ClangASTType.po: DiagnosticCommonKinds.inc.h
+ClangASTType.po: StmtNodes.inc.h
+ClangExternalASTSourceCallbacks.o: DeclNodes.inc.h
+ClangExternalASTSourceCallbacks.o: DiagnosticCommonKinds.inc.h
+ClangExternalASTSourceCallbacks.po: DeclNodes.inc.h
+ClangExternalASTSourceCallbacks.po: DiagnosticCommonKinds.inc.h
+ClangExternalASTSourceCommon.o: DeclNodes.inc.h
+ClangExternalASTSourceCommon.o: DiagnosticCommonKinds.inc.h
+ClangExternalASTSourceCommon.po: DeclNodes.inc.h
+ClangExternalASTSourceCommon.po: DiagnosticCommonKinds.inc.h
+ClangNamespaceDecl.o: DeclNodes.inc.h
+ClangNamespaceDecl.o: DiagnosticCommonKinds.inc.h
+ClangNamespaceDecl.po: DeclNodes.inc.h
+ClangNamespaceDecl.po: DiagnosticCommonKinds.inc.h
+CompactUnwindInfo.o: CommentCommandList.inc.h
+CompactUnwindInfo.o: DeclNodes.inc.h
+CompactUnwindInfo.o: DiagnosticCommonKinds.inc.h
+CompactUnwindInfo.o: StmtNodes.inc.h
+CompactUnwindInfo.po: CommentCommandList.inc.h
+CompactUnwindInfo.po: DeclNodes.inc.h
+CompactUnwindInfo.po: DiagnosticCommonKinds.inc.h
+CompactUnwindInfo.po: StmtNodes.inc.h
+CompileUnit.o: CommentCommandList.inc.h
+CompileUnit.o: DeclNodes.inc.h
+CompileUnit.o: DiagnosticCommonKinds.inc.h
+CompileUnit.o: StmtNodes.inc.h
+CompileUnit.po: CommentCommandList.inc.h
+CompileUnit.po: DeclNodes.inc.h
+CompileUnit.po: DiagnosticCommonKinds.inc.h
+CompileUnit.po: StmtNodes.inc.h
+DWARFCallFrameInfo.o: CommentCommandList.inc.h
+DWARFCallFrameInfo.o: DeclNodes.inc.h
+DWARFCallFrameInfo.o: DiagnosticCommonKinds.inc.h
+DWARFCallFrameInfo.o: StmtNodes.inc.h
+DWARFCallFrameInfo.po: CommentCommandList.inc.h
+DWARFCallFrameInfo.po: DeclNodes.inc.h
+DWARFCallFrameInfo.po: DiagnosticCommonKinds.inc.h
+DWARFCallFrameInfo.po: StmtNodes.inc.h
+FuncUnwinders.o: DiagnosticCommonKinds.inc.h
+FuncUnwinders.po: DiagnosticCommonKinds.inc.h
+Function.o: CommentCommandList.inc.h
+Function.o: DeclNodes.inc.h
+Function.o: DiagnosticCommonKinds.inc.h
+Function.o: StmtNodes.inc.h
+Function.po: CommentCommandList.inc.h
+Function.po: DeclNodes.inc.h
+Function.po: DiagnosticCommonKinds.inc.h
+Function.po: StmtNodes.inc.h
+LineEntry.o: DiagnosticCommonKinds.inc.h
+LineEntry.po: DiagnosticCommonKinds.inc.h
+LineTable.o: CommentCommandList.inc.h
+LineTable.o: DeclNodes.inc.h
+LineTable.o: DiagnosticCommonKinds.inc.h
+LineTable.o: StmtNodes.inc.h
+LineTable.po: CommentCommandList.inc.h
+LineTable.po: DeclNodes.inc.h
+LineTable.po: DiagnosticCommonKinds.inc.h
+LineTable.po: StmtNodes.inc.h
+ObjectFile.o: CommentCommandList.inc.h
+ObjectFile.o: DeclNodes.inc.h
+ObjectFile.o: DiagnosticCommonKinds.inc.h
+ObjectFile.o: StmtNodes.inc.h
+ObjectFile.po: CommentCommandList.inc.h
+ObjectFile.po: DeclNodes.inc.h
+ObjectFile.po: DiagnosticCommonKinds.inc.h
+ObjectFile.po: StmtNodes.inc.h
+Symbol.o: CommentCommandList.inc.h
+Symbol.o: DeclNodes.inc.h
+Symbol.o: DiagnosticCommonKinds.inc.h
+Symbol.o: StmtNodes.inc.h
+Symbol.po: CommentCommandList.inc.h
+Symbol.po: DeclNodes.inc.h
+Symbol.po: DiagnosticCommonKinds.inc.h
+Symbol.po: StmtNodes.inc.h
+SymbolContext.o: CommentCommandList.inc.h
+SymbolContext.o: DeclNodes.inc.h
+SymbolContext.o: DiagnosticCommonKinds.inc.h
+SymbolContext.o: StmtNodes.inc.h
+SymbolContext.po: CommentCommandList.inc.h
+SymbolContext.po: DeclNodes.inc.h
+SymbolContext.po: DiagnosticCommonKinds.inc.h
+SymbolContext.po: StmtNodes.inc.h
+SymbolFile.o: CommentCommandList.inc.h
+SymbolFile.o: DeclNodes.inc.h
+SymbolFile.o: DiagnosticCommonKinds.inc.h
+SymbolFile.o: StmtNodes.inc.h
+SymbolFile.po: CommentCommandList.inc.h
+SymbolFile.po: DeclNodes.inc.h
+SymbolFile.po: DiagnosticCommonKinds.inc.h
+SymbolFile.po: StmtNodes.inc.h
+SymbolVendor.o: CommentCommandList.inc.h
+SymbolVendor.o: DeclNodes.inc.h
+SymbolVendor.o: DiagnosticCommonKinds.inc.h
+SymbolVendor.o: StmtNodes.inc.h
+SymbolVendor.po: CommentCommandList.inc.h
+SymbolVendor.po: DeclNodes.inc.h
+SymbolVendor.po: DiagnosticCommonKinds.inc.h
+SymbolVendor.po: StmtNodes.inc.h
+Symtab.o: CommentCommandList.inc.h
+Symtab.o: DeclNodes.inc.h
+Symtab.o: DiagnosticCommonKinds.inc.h
+Symtab.o: StmtNodes.inc.h
+Symtab.po: CommentCommandList.inc.h
+Symtab.po: DeclNodes.inc.h
+Symtab.po: DiagnosticCommonKinds.inc.h
+Symtab.po: StmtNodes.inc.h
+Type.o: CommentCommandList.inc.h
+Type.o: DeclNodes.inc.h
+Type.o: DiagnosticCommonKinds.inc.h
+Type.o: StmtNodes.inc.h
+Type.po: CommentCommandList.inc.h
+Type.po: DeclNodes.inc.h
+Type.po: DiagnosticCommonKinds.inc.h
+Type.po: StmtNodes.inc.h
+TypeList.o: AttrList.inc.h
+TypeList.o: Attrs.inc.h
+TypeList.o: CommentCommandList.inc.h
+TypeList.o: DeclNodes.inc.h
+TypeList.o: DiagnosticCommonKinds.inc.h
+TypeList.o: StmtNodes.inc.h
+TypeList.po: AttrList.inc.h
+TypeList.po: Attrs.inc.h
+TypeList.po: CommentCommandList.inc.h
+TypeList.po: DeclNodes.inc.h
+TypeList.po: DiagnosticCommonKinds.inc.h
+TypeList.po: StmtNodes.inc.h
+UnwindPlan.o: DiagnosticCommonKinds.inc.h
+UnwindPlan.po: DiagnosticCommonKinds.inc.h
+UnwindTable.o: CommentCommandList.inc.h
+UnwindTable.o: DeclNodes.inc.h
+UnwindTable.o: DiagnosticCommonKinds.inc.h
+UnwindTable.o: StmtNodes.inc.h
+UnwindTable.po: CommentCommandList.inc.h
+UnwindTable.po: DeclNodes.inc.h
+UnwindTable.po: DiagnosticCommonKinds.inc.h
+UnwindTable.po: StmtNodes.inc.h
+Variable.o: CommentCommandList.inc.h
+Variable.o: DeclNodes.inc.h
+Variable.o: DiagnosticCommonKinds.inc.h
+Variable.o: StmtNodes.inc.h
+Variable.po: CommentCommandList.inc.h
+Variable.po: DeclNodes.inc.h
+Variable.po: DiagnosticCommonKinds.inc.h
+Variable.po: StmtNodes.inc.h
+VariableList.o: DiagnosticCommonKinds.inc.h
+VariableList.po: DiagnosticCommonKinds.inc.h
+VerifyDecl.o: DeclNodes.inc.h
+VerifyDecl.o: DiagnosticCommonKinds.inc.h
+VerifyDecl.po: DeclNodes.inc.h
+VerifyDecl.po: DiagnosticCommonKinds.inc.h
+.endif
diff --git a/lib/clang/liblldbTarget/Makefile.depend b/lib/clang/liblldbTarget/Makefile.depend
new file mode 100644
index 0000000..e9ffeed
--- /dev/null
+++ b/lib/clang/liblldbTarget/Makefile.depend
@@ -0,0 +1,224 @@
+# $FreeBSD$
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/libc++ \
+ lib/msun \
+ usr.bin/clang/clang-tblgen.host \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+ABI.o: DiagnosticCommonKinds.inc.h
+ABI.po: DiagnosticCommonKinds.inc.h
+CPPLanguageRuntime.o: DiagnosticCommonKinds.inc.h
+CPPLanguageRuntime.po: DiagnosticCommonKinds.inc.h
+ExecutionContext.o: DiagnosticCommonKinds.inc.h
+ExecutionContext.po: DiagnosticCommonKinds.inc.h
+InstrumentationRuntime.o: DiagnosticCommonKinds.inc.h
+InstrumentationRuntime.po: DiagnosticCommonKinds.inc.h
+InstrumentationRuntimeStopInfo.o: DiagnosticCommonKinds.inc.h
+InstrumentationRuntimeStopInfo.po: DiagnosticCommonKinds.inc.h
+JITLoader.o: DiagnosticCommonKinds.inc.h
+JITLoader.po: DiagnosticCommonKinds.inc.h
+LanguageRuntime.o: DiagnosticCommonKinds.inc.h
+LanguageRuntime.po: DiagnosticCommonKinds.inc.h
+Memory.o: DiagnosticCommonKinds.inc.h
+Memory.po: DiagnosticCommonKinds.inc.h
+ObjCLanguageRuntime.o: CommentCommandList.inc.h
+ObjCLanguageRuntime.o: DeclNodes.inc.h
+ObjCLanguageRuntime.o: DiagnosticCommonKinds.inc.h
+ObjCLanguageRuntime.o: StmtNodes.inc.h
+ObjCLanguageRuntime.po: CommentCommandList.inc.h
+ObjCLanguageRuntime.po: DeclNodes.inc.h
+ObjCLanguageRuntime.po: DiagnosticCommonKinds.inc.h
+ObjCLanguageRuntime.po: StmtNodes.inc.h
+Platform.o: DiagnosticCommonKinds.inc.h
+Platform.po: DiagnosticCommonKinds.inc.h
+Process.o: AttrList.inc.h
+Process.o: Attrs.inc.h
+Process.o: CommentCommandList.inc.h
+Process.o: DeclNodes.inc.h
+Process.o: DiagnosticCommonKinds.inc.h
+Process.o: StmtNodes.inc.h
+Process.po: AttrList.inc.h
+Process.po: Attrs.inc.h
+Process.po: CommentCommandList.inc.h
+Process.po: DeclNodes.inc.h
+Process.po: DiagnosticCommonKinds.inc.h
+Process.po: StmtNodes.inc.h
+ProcessLaunchInfo.o: AttrList.inc.h
+ProcessLaunchInfo.o: Attrs.inc.h
+ProcessLaunchInfo.o: CommentCommandList.inc.h
+ProcessLaunchInfo.o: DeclNodes.inc.h
+ProcessLaunchInfo.o: DiagnosticCommonKinds.inc.h
+ProcessLaunchInfo.o: StmtNodes.inc.h
+ProcessLaunchInfo.po: AttrList.inc.h
+ProcessLaunchInfo.po: Attrs.inc.h
+ProcessLaunchInfo.po: CommentCommandList.inc.h
+ProcessLaunchInfo.po: DeclNodes.inc.h
+ProcessLaunchInfo.po: DiagnosticCommonKinds.inc.h
+ProcessLaunchInfo.po: StmtNodes.inc.h
+Queue.o: DiagnosticCommonKinds.inc.h
+Queue.po: DiagnosticCommonKinds.inc.h
+QueueItem.o: DiagnosticCommonKinds.inc.h
+QueueItem.po: DiagnosticCommonKinds.inc.h
+QueueList.o: DiagnosticCommonKinds.inc.h
+QueueList.po: DiagnosticCommonKinds.inc.h
+RegisterContext.o: DiagnosticCommonKinds.inc.h
+RegisterContext.po: DiagnosticCommonKinds.inc.h
+SectionLoadList.o: CommentCommandList.inc.h
+SectionLoadList.o: DeclNodes.inc.h
+SectionLoadList.o: DiagnosticCommonKinds.inc.h
+SectionLoadList.o: StmtNodes.inc.h
+SectionLoadList.po: CommentCommandList.inc.h
+SectionLoadList.po: DeclNodes.inc.h
+SectionLoadList.po: DiagnosticCommonKinds.inc.h
+SectionLoadList.po: StmtNodes.inc.h
+StackFrame.o: AttrList.inc.h
+StackFrame.o: Attrs.inc.h
+StackFrame.o: CommentCommandList.inc.h
+StackFrame.o: DeclNodes.inc.h
+StackFrame.o: DiagnosticCommonKinds.inc.h
+StackFrame.o: StmtNodes.inc.h
+StackFrame.po: AttrList.inc.h
+StackFrame.po: Attrs.inc.h
+StackFrame.po: CommentCommandList.inc.h
+StackFrame.po: DeclNodes.inc.h
+StackFrame.po: DiagnosticCommonKinds.inc.h
+StackFrame.po: StmtNodes.inc.h
+StackFrameList.o: DiagnosticCommonKinds.inc.h
+StackFrameList.po: DiagnosticCommonKinds.inc.h
+StackID.o: DiagnosticCommonKinds.inc.h
+StackID.po: DiagnosticCommonKinds.inc.h
+StopInfo.o: AttrList.inc.h
+StopInfo.o: Attrs.inc.h
+StopInfo.o: CommentCommandList.inc.h
+StopInfo.o: DeclNodes.inc.h
+StopInfo.o: DiagnosticCommonKinds.inc.h
+StopInfo.o: StmtNodes.inc.h
+StopInfo.po: AttrList.inc.h
+StopInfo.po: Attrs.inc.h
+StopInfo.po: CommentCommandList.inc.h
+StopInfo.po: DeclNodes.inc.h
+StopInfo.po: DiagnosticCommonKinds.inc.h
+StopInfo.po: StmtNodes.inc.h
+SystemRuntime.o: DiagnosticCommonKinds.inc.h
+SystemRuntime.po: DiagnosticCommonKinds.inc.h
+Target.o: AttrList.inc.h
+Target.o: Attrs.inc.h
+Target.o: CommentCommandList.inc.h
+Target.o: DeclNodes.inc.h
+Target.o: DiagnosticCommonKinds.inc.h
+Target.o: StmtNodes.inc.h
+Target.po: AttrList.inc.h
+Target.po: Attrs.inc.h
+Target.po: CommentCommandList.inc.h
+Target.po: DeclNodes.inc.h
+Target.po: DiagnosticCommonKinds.inc.h
+Target.po: StmtNodes.inc.h
+TargetList.o: AttrList.inc.h
+TargetList.o: Attrs.inc.h
+TargetList.o: CommentCommandList.inc.h
+TargetList.o: DeclNodes.inc.h
+TargetList.o: DiagnosticCommonKinds.inc.h
+TargetList.o: StmtNodes.inc.h
+TargetList.po: AttrList.inc.h
+TargetList.po: Attrs.inc.h
+TargetList.po: CommentCommandList.inc.h
+TargetList.po: DeclNodes.inc.h
+TargetList.po: DiagnosticCommonKinds.inc.h
+TargetList.po: StmtNodes.inc.h
+Thread.o: AttrList.inc.h
+Thread.o: Attrs.inc.h
+Thread.o: CommentCommandList.inc.h
+Thread.o: DeclNodes.inc.h
+Thread.o: DiagnosticCommonKinds.inc.h
+Thread.o: StmtNodes.inc.h
+Thread.po: AttrList.inc.h
+Thread.po: Attrs.inc.h
+Thread.po: CommentCommandList.inc.h
+Thread.po: DeclNodes.inc.h
+Thread.po: DiagnosticCommonKinds.inc.h
+Thread.po: StmtNodes.inc.h
+ThreadList.o: DiagnosticCommonKinds.inc.h
+ThreadList.po: DiagnosticCommonKinds.inc.h
+ThreadPlan.o: AttrList.inc.h
+ThreadPlan.o: Attrs.inc.h
+ThreadPlan.o: CommentCommandList.inc.h
+ThreadPlan.o: DeclNodes.inc.h
+ThreadPlan.o: DiagnosticCommonKinds.inc.h
+ThreadPlan.o: StmtNodes.inc.h
+ThreadPlan.po: AttrList.inc.h
+ThreadPlan.po: Attrs.inc.h
+ThreadPlan.po: CommentCommandList.inc.h
+ThreadPlan.po: DeclNodes.inc.h
+ThreadPlan.po: DiagnosticCommonKinds.inc.h
+ThreadPlan.po: StmtNodes.inc.h
+ThreadPlanBase.o: DiagnosticCommonKinds.inc.h
+ThreadPlanBase.po: DiagnosticCommonKinds.inc.h
+ThreadPlanCallFunction.o: CommentCommandList.inc.h
+ThreadPlanCallFunction.o: DeclNodes.inc.h
+ThreadPlanCallFunction.o: DiagnosticCommonKinds.inc.h
+ThreadPlanCallFunction.o: StmtNodes.inc.h
+ThreadPlanCallFunction.po: CommentCommandList.inc.h
+ThreadPlanCallFunction.po: DeclNodes.inc.h
+ThreadPlanCallFunction.po: DiagnosticCommonKinds.inc.h
+ThreadPlanCallFunction.po: StmtNodes.inc.h
+ThreadPlanCallUserExpression.o: DiagnosticCommonKinds.inc.h
+ThreadPlanCallUserExpression.po: DiagnosticCommonKinds.inc.h
+ThreadPlanPython.o: AttrList.inc.h
+ThreadPlanPython.o: Attrs.inc.h
+ThreadPlanPython.o: CommentCommandList.inc.h
+ThreadPlanPython.o: DeclNodes.inc.h
+ThreadPlanPython.o: DiagnosticCommonKinds.inc.h
+ThreadPlanPython.o: StmtNodes.inc.h
+ThreadPlanPython.po: AttrList.inc.h
+ThreadPlanPython.po: Attrs.inc.h
+ThreadPlanPython.po: CommentCommandList.inc.h
+ThreadPlanPython.po: DeclNodes.inc.h
+ThreadPlanPython.po: DiagnosticCommonKinds.inc.h
+ThreadPlanPython.po: StmtNodes.inc.h
+ThreadPlanRunToAddress.o: DiagnosticCommonKinds.inc.h
+ThreadPlanRunToAddress.po: DiagnosticCommonKinds.inc.h
+ThreadPlanShouldStopHere.o: DiagnosticCommonKinds.inc.h
+ThreadPlanShouldStopHere.po: DiagnosticCommonKinds.inc.h
+ThreadPlanStepInRange.o: CommentCommandList.inc.h
+ThreadPlanStepInRange.o: DeclNodes.inc.h
+ThreadPlanStepInRange.o: DiagnosticCommonKinds.inc.h
+ThreadPlanStepInRange.o: StmtNodes.inc.h
+ThreadPlanStepInRange.po: CommentCommandList.inc.h
+ThreadPlanStepInRange.po: DeclNodes.inc.h
+ThreadPlanStepInRange.po: DiagnosticCommonKinds.inc.h
+ThreadPlanStepInRange.po: StmtNodes.inc.h
+ThreadPlanStepInstruction.o: DiagnosticCommonKinds.inc.h
+ThreadPlanStepInstruction.po: DiagnosticCommonKinds.inc.h
+ThreadPlanStepOut.o: DiagnosticCommonKinds.inc.h
+ThreadPlanStepOut.po: DiagnosticCommonKinds.inc.h
+ThreadPlanStepOverBreakpoint.o: DiagnosticCommonKinds.inc.h
+ThreadPlanStepOverBreakpoint.po: DiagnosticCommonKinds.inc.h
+ThreadPlanStepOverRange.o: DiagnosticCommonKinds.inc.h
+ThreadPlanStepOverRange.po: DiagnosticCommonKinds.inc.h
+ThreadPlanStepRange.o: DiagnosticCommonKinds.inc.h
+ThreadPlanStepRange.po: DiagnosticCommonKinds.inc.h
+ThreadPlanStepThrough.o: DiagnosticCommonKinds.inc.h
+ThreadPlanStepThrough.po: DiagnosticCommonKinds.inc.h
+ThreadPlanStepUntil.o: DiagnosticCommonKinds.inc.h
+ThreadPlanStepUntil.po: DiagnosticCommonKinds.inc.h
+ThreadPlanTracer.o: AttrList.inc.h
+ThreadPlanTracer.o: Attrs.inc.h
+ThreadPlanTracer.o: CommentCommandList.inc.h
+ThreadPlanTracer.o: DeclNodes.inc.h
+ThreadPlanTracer.o: DiagnosticCommonKinds.inc.h
+ThreadPlanTracer.o: StmtNodes.inc.h
+ThreadPlanTracer.po: AttrList.inc.h
+ThreadPlanTracer.po: Attrs.inc.h
+ThreadPlanTracer.po: CommentCommandList.inc.h
+ThreadPlanTracer.po: DeclNodes.inc.h
+ThreadPlanTracer.po: DiagnosticCommonKinds.inc.h
+ThreadPlanTracer.po: StmtNodes.inc.h
+.endif
diff --git a/lib/clang/liblldbUtility/Makefile.depend b/lib/clang/liblldbUtility/Makefile.depend
new file mode 100644
index 0000000..3e7f3f5
--- /dev/null
+++ b/lib/clang/liblldbUtility/Makefile.depend
@@ -0,0 +1,15 @@
+# $FreeBSD$
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/libc++ \
+ lib/msun \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/lib/clang/libllvmexecutionengine/Makefile.depend b/lib/clang/libllvmexecutionengine/Makefile.depend
index c9899bc..3e7f3f5 100644
--- a/lib/clang/libllvmexecutionengine/Makefile.depend
+++ b/lib/clang/libllvmexecutionengine/Makefile.depend
@@ -1,8 +1,6 @@
# $FreeBSD$
# Autogenerated - do NOT edit!
-DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
-
DIRDEPS = \
include \
include/xlocale \
diff --git a/lib/clang/libllvmmcdisassembler/Makefile.depend b/lib/clang/libllvmmcdisassembler/Makefile.depend
index c9899bc..3e7f3f5 100644
--- a/lib/clang/libllvmmcdisassembler/Makefile.depend
+++ b/lib/clang/libllvmmcdisassembler/Makefile.depend
@@ -1,8 +1,6 @@
# $FreeBSD$
# Autogenerated - do NOT edit!
-DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
-
DIRDEPS = \
include \
include/xlocale \
diff --git a/lib/clang/libllvmmcjit/Makefile.depend b/lib/clang/libllvmmcjit/Makefile.depend
index c9899bc..3e7f3f5 100644
--- a/lib/clang/libllvmmcjit/Makefile.depend
+++ b/lib/clang/libllvmmcjit/Makefile.depend
@@ -1,8 +1,6 @@
# $FreeBSD$
# Autogenerated - do NOT edit!
-DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
-
DIRDEPS = \
include \
include/xlocale \
diff --git a/lib/clang/libllvmruntimedyld/Makefile.depend b/lib/clang/libllvmruntimedyld/Makefile.depend
index c9899bc..3e7f3f5 100644
--- a/lib/clang/libllvmruntimedyld/Makefile.depend
+++ b/lib/clang/libllvmruntimedyld/Makefile.depend
@@ -1,8 +1,6 @@
# $FreeBSD$
# Autogenerated - do NOT edit!
-DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
-
DIRDEPS = \
include \
include/xlocale \
diff --git a/lib/libbegemot/Makefile.depend b/lib/libbegemot/Makefile.depend
index 9e2283a..dde2d60 100644
--- a/lib/libbegemot/Makefile.depend
+++ b/lib/libbegemot/Makefile.depend
@@ -2,7 +2,6 @@
# Autogenerated - do NOT edit!
DIRDEPS = \
- bin/cat.host \
gnu/lib/csu \
gnu/lib/libgcc \
include \
diff --git a/lib/libc/Makefile.depend b/lib/libc/Makefile.depend
index 9e7bf04..05b44c8 100644
--- a/lib/libc/Makefile.depend
+++ b/lib/libc/Makefile.depend
@@ -8,6 +8,7 @@ DIRDEPS = \
include/rpcsvc \
lib/${CSU_DIR} \
lib/libcompiler_rt \
+ usr.bin/yacc.host \
.include <dirdeps.mk>
diff --git a/lib/libcom_err/Makefile.depend b/lib/libcom_err/Makefile.depend
index 3646e2e..dde2d60 100644
--- a/lib/libcom_err/Makefile.depend
+++ b/lib/libcom_err/Makefile.depend
@@ -9,6 +9,7 @@ DIRDEPS = \
lib/${CSU_DIR} \
lib/libc \
lib/libcompiler_rt \
+ usr.bin/xinstall.host \
.include <dirdeps.mk>
diff --git a/lib/libcrypt/Makefile.depend b/lib/libcrypt/Makefile.depend
index 54c1f6f..69d1724 100644
--- a/lib/libcrypt/Makefile.depend
+++ b/lib/libcrypt/Makefile.depend
@@ -10,6 +10,7 @@ DIRDEPS = \
lib/${CSU_DIR} \
lib/libc \
lib/libcompiler_rt \
+ usr.bin/xinstall.host \
.include <dirdeps.mk>
diff --git a/lib/libdwarf/Makefile.depend b/lib/libdwarf/Makefile.depend
index 2a416d0..36075d5 100644
--- a/lib/libdwarf/Makefile.depend
+++ b/lib/libdwarf/Makefile.depend
@@ -1,8 +1,6 @@
# $FreeBSD$
# Autogenerated - do NOT edit!
-DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
-
DIRDEPS = \
gnu/lib/csu \
gnu/lib/libgcc \
diff --git a/lib/libfetch/Makefile.depend b/lib/libfetch/Makefile.depend
index df3495b..4bcc4bf 100644
--- a/lib/libfetch/Makefile.depend
+++ b/lib/libfetch/Makefile.depend
@@ -2,7 +2,6 @@
# Autogenerated - do NOT edit!
DIRDEPS = \
- bin/cat.host \
gnu/lib/csu \
gnu/lib/libgcc \
include \
diff --git a/lib/libipsec/Makefile.depend b/lib/libipsec/Makefile.depend
index 56cf3d8..d1ba46b 100644
--- a/lib/libipsec/Makefile.depend
+++ b/lib/libipsec/Makefile.depend
@@ -11,6 +11,7 @@ DIRDEPS = \
lib/libc \
lib/libcompiler_rt \
usr.bin/xinstall.host \
+ usr.bin/yacc.host \
.include <dirdeps.mk>
diff --git a/lib/libldns/Makefile.depend b/lib/libldns/Makefile.depend
index b3f22d1..f35aa11 100644
--- a/lib/libldns/Makefile.depend
+++ b/lib/libldns/Makefile.depend
@@ -12,6 +12,7 @@ DIRDEPS = \
lib/libcompiler_rt \
secure/lib/libcrypto \
secure/lib/libssl \
+ usr.bin/xinstall.host \
.include <dirdeps.mk>
diff --git a/lib/liblzma/Makefile.depend b/lib/liblzma/Makefile.depend
index 21499e6..18b76e5 100644
--- a/lib/liblzma/Makefile.depend
+++ b/lib/liblzma/Makefile.depend
@@ -2,7 +2,6 @@
# Autogenerated - do NOT edit!
DIRDEPS = \
- bin/cat.host \
gnu/lib/csu \
gnu/lib/libgcc \
include \
diff --git a/lib/libmagic/Makefile.depend b/lib/libmagic/Makefile.depend
index 002f937..3842c54 100644
--- a/lib/libmagic/Makefile.depend
+++ b/lib/libmagic/Makefile.depend
@@ -2,7 +2,6 @@
# Autogenerated - do NOT edit!
DIRDEPS = \
- bin/cat.host \
gnu/lib/csu \
gnu/lib/libgcc \
include \
diff --git a/lib/libmd/Makefile.depend b/lib/libmd/Makefile.depend
index 00038a0..c145c03 100644
--- a/lib/libmd/Makefile.depend
+++ b/lib/libmd/Makefile.depend
@@ -9,6 +9,7 @@ DIRDEPS = \
lib/${CSU_DIR} \
lib/libc \
lib/libcompiler_rt \
+ usr.bin/xinstall.host \
.include <dirdeps.mk>
diff --git a/lib/libmd/Makefile.depend.host b/lib/libmd/Makefile.depend.host
index fd7c8da..771b816 100644
--- a/lib/libmd/Makefile.depend.host
+++ b/lib/libmd/Makefile.depend.host
@@ -2,6 +2,9 @@
# Autogenerated - do NOT edit!
DIRDEPS = \
+ gnu/usr.bin/binutils/ld \
+ gnu/usr.bin/binutils/nm \
+ usr.bin/xinstall \
.include <dirdeps.mk>
diff --git a/lib/libmp/Makefile.depend b/lib/libmp/Makefile.depend
index 6476d4c..5781764 100644
--- a/lib/libmp/Makefile.depend
+++ b/lib/libmp/Makefile.depend
@@ -2,7 +2,6 @@
# Autogenerated - do NOT edit!
DIRDEPS = \
- bin/cat.host \
gnu/lib/csu \
gnu/lib/libgcc \
include \
diff --git a/lib/libopie/Makefile.depend b/lib/libopie/Makefile.depend
index 6a2d406..4ed0db2 100644
--- a/lib/libopie/Makefile.depend
+++ b/lib/libopie/Makefile.depend
@@ -11,6 +11,7 @@ DIRDEPS = \
lib/libc \
lib/libcompiler_rt \
lib/libmd \
+ usr.bin/xinstall.host \
.include <dirdeps.mk>
diff --git a/lib/libpam/libpam/Makefile.depend b/lib/libpam/libpam/Makefile.depend
index 3646e2e..dde2d60 100644
--- a/lib/libpam/libpam/Makefile.depend
+++ b/lib/libpam/libpam/Makefile.depend
@@ -9,6 +9,7 @@ DIRDEPS = \
lib/${CSU_DIR} \
lib/libc \
lib/libcompiler_rt \
+ usr.bin/xinstall.host \
.include <dirdeps.mk>
diff --git a/lib/libradius/Makefile.depend b/lib/libradius/Makefile.depend
index f318cc1..5d73f97 100644
--- a/lib/libradius/Makefile.depend
+++ b/lib/libradius/Makefile.depend
@@ -11,6 +11,7 @@ DIRDEPS = \
lib/libc \
lib/libcompiler_rt \
secure/lib/libcrypto \
+ usr.bin/xinstall.host \
.include <dirdeps.mk>
diff --git a/lib/libsbuf/Makefile.depend b/lib/libsbuf/Makefile.depend
index 9e2283a..dde2d60 100644
--- a/lib/libsbuf/Makefile.depend
+++ b/lib/libsbuf/Makefile.depend
@@ -2,7 +2,6 @@
# Autogenerated - do NOT edit!
DIRDEPS = \
- bin/cat.host \
gnu/lib/csu \
gnu/lib/libgcc \
include \
diff --git a/lib/libthr/Makefile.depend b/lib/libthr/Makefile.depend
index 9cb890b..3699b06 100644
--- a/lib/libthr/Makefile.depend
+++ b/lib/libthr/Makefile.depend
@@ -8,6 +8,7 @@ DIRDEPS = \
lib/${CSU_DIR} \
lib/libc \
lib/libcompiler_rt \
+ usr.bin/xinstall.host \
.include <dirdeps.mk>
diff --git a/lib/libthread_db/Makefile.depend b/lib/libthread_db/Makefile.depend
index 9e2283a..dde2d60 100644
--- a/lib/libthread_db/Makefile.depend
+++ b/lib/libthread_db/Makefile.depend
@@ -2,7 +2,6 @@
# Autogenerated - do NOT edit!
DIRDEPS = \
- bin/cat.host \
gnu/lib/csu \
gnu/lib/libgcc \
include \
diff --git a/lib/libutil/Makefile.depend b/lib/libutil/Makefile.depend
index 54c1f6f..69d1724 100644
--- a/lib/libutil/Makefile.depend
+++ b/lib/libutil/Makefile.depend
@@ -10,6 +10,7 @@ DIRDEPS = \
lib/${CSU_DIR} \
lib/libc \
lib/libcompiler_rt \
+ usr.bin/xinstall.host \
.include <dirdeps.mk>
diff --git a/lib/libvmmapi/vmmapi.c b/lib/libvmmapi/vmmapi.c
index 1e6e627..d5f387a 100644
--- a/lib/libvmmapi/vmmapi.c
+++ b/lib/libvmmapi/vmmapi.c
@@ -58,15 +58,23 @@ __FBSDID("$FreeBSD$");
#define MB (1024 * 1024UL)
#define GB (1024 * 1024 * 1024UL)
+/*
+ * Size of the guard region before and after the virtual address space
+ * mapping the guest physical memory. This must be a multiple of the
+ * superpage size for performance reasons.
+ */
+#define VM_MMAP_GUARD_SIZE (4 * MB)
+
+#define PROT_RW (PROT_READ | PROT_WRITE)
+#define PROT_ALL (PROT_READ | PROT_WRITE | PROT_EXEC)
+
struct vmctx {
int fd;
uint32_t lowmem_limit;
- enum vm_mmap_style vms;
int memflags;
size_t lowmem;
- char *lowmem_addr;
size_t highmem;
- char *highmem_addr;
+ char *baseaddr;
char *name;
};
@@ -157,22 +165,6 @@ vm_parse_memsize(const char *optarg, size_t *ret_memsize)
return (error);
}
-int
-vm_get_memory_seg(struct vmctx *ctx, vm_paddr_t gpa, size_t *ret_len,
- int *wired)
-{
- int error;
- struct vm_memory_segment seg;
-
- bzero(&seg, sizeof(seg));
- seg.gpa = gpa;
- error = ioctl(ctx->fd, VM_GET_MEMORY_SEG, &seg);
- *ret_len = seg.len;
- if (wired != NULL)
- *wired = seg.wired;
- return (error);
-}
-
uint32_t
vm_get_lowmem_limit(struct vmctx *ctx)
{
@@ -194,39 +186,184 @@ vm_set_memflags(struct vmctx *ctx, int flags)
ctx->memflags = flags;
}
+int
+vm_get_memflags(struct vmctx *ctx)
+{
+
+ return (ctx->memflags);
+}
+
+/*
+ * Map segment 'segid' starting at 'off' into guest address range [gpa,gpa+len).
+ */
+int
+vm_mmap_memseg(struct vmctx *ctx, vm_paddr_t gpa, int segid, vm_ooffset_t off,
+ size_t len, int prot)
+{
+ struct vm_memmap memmap;
+ int error, flags;
+
+ memmap.gpa = gpa;
+ memmap.segid = segid;
+ memmap.segoff = off;
+ memmap.len = len;
+ memmap.prot = prot;
+ memmap.flags = 0;
+
+ if (ctx->memflags & VM_MEM_F_WIRED)
+ memmap.flags |= VM_MEMMAP_F_WIRED;
+
+ /*
+ * If this mapping already exists then don't create it again. This
+ * is the common case for SYSMEM mappings created by bhyveload(8).
+ */
+ error = vm_mmap_getnext(ctx, &gpa, &segid, &off, &len, &prot, &flags);
+ if (error == 0 && gpa == memmap.gpa) {
+ if (segid != memmap.segid || off != memmap.segoff ||
+ prot != memmap.prot || flags != memmap.flags) {
+ errno = EEXIST;
+ return (-1);
+ } else {
+ return (0);
+ }
+ }
+
+ error = ioctl(ctx->fd, VM_MMAP_MEMSEG, &memmap);
+ return (error);
+}
+
+int
+vm_mmap_getnext(struct vmctx *ctx, vm_paddr_t *gpa, int *segid,
+ vm_ooffset_t *segoff, size_t *len, int *prot, int *flags)
+{
+ struct vm_memmap memmap;
+ int error;
+
+ bzero(&memmap, sizeof(struct vm_memmap));
+ memmap.gpa = *gpa;
+ error = ioctl(ctx->fd, VM_MMAP_GETNEXT, &memmap);
+ if (error == 0) {
+ *gpa = memmap.gpa;
+ *segid = memmap.segid;
+ *segoff = memmap.segoff;
+ *len = memmap.len;
+ *prot = memmap.prot;
+ *flags = memmap.flags;
+ }
+ return (error);
+}
+
+/*
+ * Return 0 if the segments are identical and non-zero otherwise.
+ *
+ * This is slightly complicated by the fact that only device memory segments
+ * are named.
+ */
+static int
+cmpseg(size_t len, const char *str, size_t len2, const char *str2)
+{
+
+ if (len == len2) {
+ if ((!str && !str2) || (str && str2 && !strcmp(str, str2)))
+ return (0);
+ }
+ return (-1);
+}
+
static int
-setup_memory_segment(struct vmctx *ctx, vm_paddr_t gpa, size_t len, char **addr)
+vm_alloc_memseg(struct vmctx *ctx, int segid, size_t len, const char *name)
{
- int error, mmap_flags;
- struct vm_memory_segment seg;
+ struct vm_memseg memseg;
+ size_t n;
+ int error;
/*
- * Create and optionally map 'len' bytes of memory at guest
- * physical address 'gpa'
+ * If the memory segment has already been created then just return.
+ * This is the usual case for the SYSMEM segment created by userspace
+ * loaders like bhyveload(8).
*/
- bzero(&seg, sizeof(seg));
- seg.gpa = gpa;
- seg.len = len;
- error = ioctl(ctx->fd, VM_MAP_MEMORY, &seg);
- if (error == 0 && addr != NULL) {
- mmap_flags = MAP_SHARED;
- if ((ctx->memflags & VM_MEM_F_INCORE) == 0)
- mmap_flags |= MAP_NOCORE;
- *addr = mmap(NULL, len, PROT_READ | PROT_WRITE, mmap_flags,
- ctx->fd, gpa);
+ error = vm_get_memseg(ctx, segid, &memseg.len, memseg.name,
+ sizeof(memseg.name));
+ if (error)
+ return (error);
+
+ if (memseg.len != 0) {
+ if (cmpseg(len, name, memseg.len, VM_MEMSEG_NAME(&memseg))) {
+ errno = EINVAL;
+ return (-1);
+ } else {
+ return (0);
+ }
+ }
+
+ bzero(&memseg, sizeof(struct vm_memseg));
+ memseg.segid = segid;
+ memseg.len = len;
+ if (name != NULL) {
+ n = strlcpy(memseg.name, name, sizeof(memseg.name));
+ if (n >= sizeof(memseg.name)) {
+ errno = ENAMETOOLONG;
+ return (-1);
+ }
}
+
+ error = ioctl(ctx->fd, VM_ALLOC_MEMSEG, &memseg);
return (error);
}
int
-vm_setup_memory(struct vmctx *ctx, size_t memsize, enum vm_mmap_style vms)
+vm_get_memseg(struct vmctx *ctx, int segid, size_t *lenp, char *namebuf,
+ size_t bufsize)
{
- char **addr;
+ struct vm_memseg memseg;
+ size_t n;
int error;
- /* XXX VM_MMAP_SPARSE not implemented yet */
- assert(vms == VM_MMAP_NONE || vms == VM_MMAP_ALL);
- ctx->vms = vms;
+ memseg.segid = segid;
+ error = ioctl(ctx->fd, VM_GET_MEMSEG, &memseg);
+ if (error == 0) {
+ *lenp = memseg.len;
+ n = strlcpy(namebuf, memseg.name, bufsize);
+ if (n >= bufsize) {
+ errno = ENAMETOOLONG;
+ error = -1;
+ }
+ }
+ return (error);
+}
+
+static int
+setup_memory_segment(struct vmctx *ctx, vm_paddr_t gpa, size_t len, char *base)
+{
+ char *ptr;
+ int error, flags;
+
+ /* Map 'len' bytes starting at 'gpa' in the guest address space */
+ error = vm_mmap_memseg(ctx, gpa, VM_SYSMEM, gpa, len, PROT_ALL);
+ if (error)
+ return (error);
+
+ flags = MAP_SHARED | MAP_FIXED;
+ if ((ctx->memflags & VM_MEM_F_INCORE) == 0)
+ flags |= MAP_NOCORE;
+
+ /* mmap into the process address space on the host */
+ ptr = mmap(base + gpa, len, PROT_RW, flags, ctx->fd, gpa);
+ if (ptr == MAP_FAILED)
+ return (-1);
+
+ return (0);
+}
+
+int
+vm_setup_memory(struct vmctx *ctx, size_t memsize, enum vm_mmap_style vms)
+{
+ size_t objsize, len;
+ vm_paddr_t gpa;
+ char *baseaddr, *ptr;
+ int error, flags;
+
+ assert(vms == VM_MMAP_ALL);
/*
* If 'memsize' cannot fit entirely in the 'lowmem' segment then
@@ -234,46 +371,63 @@ vm_setup_memory(struct vmctx *ctx, size_t memsize, enum vm_mmap_style vms)
*/
if (memsize > ctx->lowmem_limit) {
ctx->lowmem = ctx->lowmem_limit;
- ctx->highmem = memsize - ctx->lowmem;
+ ctx->highmem = memsize - ctx->lowmem_limit;
+ objsize = 4*GB + ctx->highmem;
} else {
ctx->lowmem = memsize;
ctx->highmem = 0;
+ objsize = ctx->lowmem;
}
- if (ctx->lowmem > 0) {
- addr = (vms == VM_MMAP_ALL) ? &ctx->lowmem_addr : NULL;
- error = setup_memory_segment(ctx, 0, ctx->lowmem, addr);
+ error = vm_alloc_memseg(ctx, VM_SYSMEM, objsize, NULL);
+ if (error)
+ return (error);
+
+ /*
+ * Stake out a contiguous region covering the guest physical memory
+ * and the adjoining guard regions.
+ */
+ len = VM_MMAP_GUARD_SIZE + objsize + VM_MMAP_GUARD_SIZE;
+ flags = MAP_PRIVATE | MAP_ANON | MAP_NOCORE | MAP_ALIGNED_SUPER;
+ ptr = mmap(NULL, len, PROT_NONE, flags, -1, 0);
+ if (ptr == MAP_FAILED)
+ return (-1);
+
+ baseaddr = ptr + VM_MMAP_GUARD_SIZE;
+ if (ctx->highmem > 0) {
+ gpa = 4*GB;
+ len = ctx->highmem;
+ error = setup_memory_segment(ctx, gpa, len, baseaddr);
if (error)
return (error);
}
- if (ctx->highmem > 0) {
- addr = (vms == VM_MMAP_ALL) ? &ctx->highmem_addr : NULL;
- error = setup_memory_segment(ctx, 4*GB, ctx->highmem, addr);
+ if (ctx->lowmem > 0) {
+ gpa = 0;
+ len = ctx->lowmem;
+ error = setup_memory_segment(ctx, gpa, len, baseaddr);
if (error)
return (error);
}
+ ctx->baseaddr = baseaddr;
+
return (0);
}
void *
vm_map_gpa(struct vmctx *ctx, vm_paddr_t gaddr, size_t len)
{
+ vm_paddr_t start, end, mapend;
- /* XXX VM_MMAP_SPARSE not implemented yet */
- assert(ctx->vms == VM_MMAP_ALL);
-
- if (gaddr < ctx->lowmem && gaddr + len <= ctx->lowmem)
- return ((void *)(ctx->lowmem_addr + gaddr));
-
- if (gaddr >= 4*GB) {
- gaddr -= 4*GB;
- if (gaddr < ctx->highmem && gaddr + len <= ctx->highmem)
- return ((void *)(ctx->highmem_addr + gaddr));
- }
+ start = gaddr;
+ end = gaddr + len;
+ mapend = ctx->highmem ? 4*GB + ctx->highmem : ctx->lowmem;
- return (NULL);
+ if (start <= end && end <= mapend)
+ return (ctx->baseaddr + start);
+ else
+ return (NULL);
}
size_t
@@ -290,6 +444,56 @@ vm_get_highmem_size(struct vmctx *ctx)
return (ctx->highmem);
}
+void *
+vm_create_devmem(struct vmctx *ctx, int segid, const char *name, size_t len)
+{
+ char pathname[MAXPATHLEN];
+ size_t len2;
+ char *base, *ptr;
+ int fd, error, flags;
+
+ fd = -1;
+ ptr = MAP_FAILED;
+ if (name == NULL || strlen(name) == 0) {
+ errno = EINVAL;
+ goto done;
+ }
+
+ error = vm_alloc_memseg(ctx, segid, len, name);
+ if (error)
+ goto done;
+
+ strlcpy(pathname, "/dev/vmm/", sizeof(pathname));
+ strlcat(pathname, ctx->name, sizeof(pathname));
+ strlcat(pathname, ".", sizeof(pathname));
+ strlcat(pathname, name, sizeof(pathname));
+
+ fd = open(pathname, O_RDWR);
+ if (fd < 0)
+ goto done;
+
+ /*
+ * Stake out a contiguous region covering the device memory and the
+ * adjoining guard regions.
+ */
+ len2 = VM_MMAP_GUARD_SIZE + len + VM_MMAP_GUARD_SIZE;
+ flags = MAP_PRIVATE | MAP_ANON | MAP_NOCORE | MAP_ALIGNED_SUPER;
+ base = mmap(NULL, len2, PROT_NONE, flags, -1, 0);
+ if (base == MAP_FAILED)
+ goto done;
+
+ flags = MAP_SHARED | MAP_FIXED;
+ if ((ctx->memflags & VM_MEM_F_INCORE) == 0)
+ flags |= MAP_NOCORE;
+
+ /* mmap the devmem region in the host address space */
+ ptr = mmap(base + VM_MMAP_GUARD_SIZE, len, PROT_RW, flags, fd, 0);
+done:
+ if (fd >= 0)
+ close(fd);
+ return (ptr);
+}
+
int
vm_set_desc(struct vmctx *ctx, int vcpu, int reg,
uint64_t base, uint32_t limit, uint32_t access)
diff --git a/lib/libvmmapi/vmmapi.h b/lib/libvmmapi/vmmapi.h
index d3ecdc4..57f8c56 100644
--- a/lib/libvmmapi/vmmapi.h
+++ b/lib/libvmmapi/vmmapi.h
@@ -36,7 +36,7 @@
* API version for out-of-tree consumers like grub-bhyve for making compile
* time decisions.
*/
-#define VMMAPI_VERSION 0101 /* 2 digit major followed by 2 digit minor */
+#define VMMAPI_VERSION 0102 /* 2 digit major followed by 2 digit minor */
struct iovec;
struct vmctx;
@@ -52,14 +52,59 @@ enum vm_mmap_style {
VM_MMAP_SPARSE, /* mappings created on-demand */
};
+/*
+ * 'flags' value passed to 'vm_set_memflags()'.
+ */
#define VM_MEM_F_INCORE 0x01 /* include guest memory in core file */
+#define VM_MEM_F_WIRED 0x02 /* guest memory is wired */
+
+/*
+ * Identifiers for memory segments:
+ * - vm_setup_memory() uses VM_SYSMEM for the system memory segment.
+ * - the remaining identifiers can be used to create devmem segments.
+ */
+enum {
+ VM_SYSMEM,
+ VM_BOOTROM,
+ VM_FRAMEBUFFER,
+};
+
+/*
+ * Get the length and name of the memory segment identified by 'segid'.
+ * Note that system memory segments are identified with a nul name.
+ *
+ * Returns 0 on success and non-zero otherwise.
+ */
+int vm_get_memseg(struct vmctx *ctx, int ident, size_t *lenp, char *name,
+ size_t namesiz);
+
+/*
+ * Iterate over the guest address space. This function finds an address range
+ * that starts at an address >= *gpa.
+ *
+ * Returns 0 if the next address range was found and non-zero otherwise.
+ */
+int vm_mmap_getnext(struct vmctx *ctx, vm_paddr_t *gpa, int *segid,
+ vm_ooffset_t *segoff, size_t *len, int *prot, int *flags);
+/*
+ * Create a device memory segment identified by 'segid'.
+ *
+ * Returns a pointer to the memory segment on success and MAP_FAILED otherwise.
+ */
+void *vm_create_devmem(struct vmctx *ctx, int segid, const char *name,
+ size_t len);
+
+/*
+ * Map the memory segment identified by 'segid' into the guest address space
+ * at [gpa,gpa+len) with protection 'prot'.
+ */
+int vm_mmap_memseg(struct vmctx *ctx, vm_paddr_t gpa, int segid,
+ vm_ooffset_t segoff, size_t len, int prot);
int vm_create(const char *name);
struct vmctx *vm_open(const char *name);
void vm_destroy(struct vmctx *ctx);
int vm_parse_memsize(const char *optarg, size_t *memsize);
-int vm_get_memory_seg(struct vmctx *ctx, vm_paddr_t gpa, size_t *ret_len,
- int *wired);
int vm_setup_memory(struct vmctx *ctx, size_t len, enum vm_mmap_style s);
void *vm_map_gpa(struct vmctx *ctx, vm_paddr_t gaddr, size_t len);
int vm_get_gpa_pmap(struct vmctx *, uint64_t gpa, uint64_t *pte, int *num);
@@ -68,6 +113,7 @@ int vm_gla2gpa(struct vmctx *, int vcpuid, struct vm_guest_paging *paging,
uint32_t vm_get_lowmem_limit(struct vmctx *ctx);
void vm_set_lowmem_limit(struct vmctx *ctx, uint32_t limit);
void vm_set_memflags(struct vmctx *ctx, int flags);
+int vm_get_memflags(struct vmctx *ctx);
size_t vm_get_lowmem_size(struct vmctx *ctx);
size_t vm_get_highmem_size(struct vmctx *ctx);
int vm_set_desc(struct vmctx *ctx, int vcpu, int reg,
diff --git a/lib/libypclnt/Makefile.depend b/lib/libypclnt/Makefile.depend
index 8ee531b..36ab5e3 100644
--- a/lib/libypclnt/Makefile.depend
+++ b/lib/libypclnt/Makefile.depend
@@ -11,6 +11,7 @@ DIRDEPS = \
lib/${CSU_DIR} \
lib/libc \
lib/libcompiler_rt \
+ usr.bin/xinstall.host \
.include <dirdeps.mk>
diff --git a/lib/libz/Makefile.depend b/lib/libz/Makefile.depend
index 3646e2e..dde2d60 100644
--- a/lib/libz/Makefile.depend
+++ b/lib/libz/Makefile.depend
@@ -9,6 +9,7 @@ DIRDEPS = \
lib/${CSU_DIR} \
lib/libc \
lib/libcompiler_rt \
+ usr.bin/xinstall.host \
.include <dirdeps.mk>
diff --git a/lib/msun/Makefile.depend b/lib/msun/Makefile.depend
index 3646e2e..dde2d60 100644
--- a/lib/msun/Makefile.depend
+++ b/lib/msun/Makefile.depend
@@ -9,6 +9,7 @@ DIRDEPS = \
lib/${CSU_DIR} \
lib/libc \
lib/libcompiler_rt \
+ usr.bin/xinstall.host \
.include <dirdeps.mk>
diff --git a/lib/ncurses/ncurses/Makefile.depend b/lib/ncurses/ncurses/Makefile.depend
index 4a07eb0..df76371 100644
--- a/lib/ncurses/ncurses/Makefile.depend
+++ b/lib/ncurses/ncurses/Makefile.depend
@@ -2,7 +2,6 @@
# Autogenerated - do NOT edit!
DIRDEPS = \
- bin/cat.host \
gnu/lib/csu \
gnu/lib/libgcc \
include \
diff --git a/lib/ncurses/ncursesw/Makefile.depend b/lib/ncurses/ncursesw/Makefile.depend
index 1855faf..443698d 100644
--- a/lib/ncurses/ncursesw/Makefile.depend
+++ b/lib/ncurses/ncursesw/Makefile.depend
@@ -2,7 +2,6 @@
# Autogenerated - do NOT edit!
DIRDEPS = \
- bin/cat.host \
gnu/lib/csu \
gnu/lib/libgcc \
include \
diff --git a/lib/ncurses/panel/Makefile.depend b/lib/ncurses/panel/Makefile.depend
index 3f7129c..fa0a8e0 100644
--- a/lib/ncurses/panel/Makefile.depend
+++ b/lib/ncurses/panel/Makefile.depend
@@ -1,8 +1,6 @@
# $FreeBSD$
# Autogenerated - do NOT edit!
-DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
-
DIRDEPS = \
gnu/lib/csu \
gnu/lib/libgcc \
diff --git a/lib/ncurses/panelw/Makefile.depend b/lib/ncurses/panelw/Makefile.depend
index 0e508be..0db3540 100644
--- a/lib/ncurses/panelw/Makefile.depend
+++ b/lib/ncurses/panelw/Makefile.depend
@@ -1,8 +1,6 @@
# $FreeBSD$
# Autogenerated - do NOT edit!
-DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
-
DIRDEPS = \
gnu/lib/csu \
gnu/lib/libgcc \
diff --git a/libexec/rtld-elf/Makefile.depend b/libexec/rtld-elf/Makefile.depend
index 920c1eb..2eb281b 100644
--- a/libexec/rtld-elf/Makefile.depend
+++ b/libexec/rtld-elf/Makefile.depend
@@ -2,7 +2,6 @@
# Autogenerated - do NOT edit!
DIRDEPS = \
- bin/cat.host \
include \
include/xlocale \
lib/libc \
diff --git a/release/Makefile.azure b/release/Makefile.azure
new file mode 100644
index 0000000..01e2204
--- /dev/null
+++ b/release/Makefile.azure
@@ -0,0 +1,53 @@
+#
+# $FreeBSD$
+#
+#
+# Makefile for uploading Microsoft Azure disk images.
+#
+
+AZURE_IMG?= ${.OBJDIR}/azure.vhdf
+AZURE_UPLOAD_TGTS= azure-check-depends \
+ azure-do-upload
+CLEANFILES+= ${AZURE_UPLOAD_TGTS}
+
+.if defined(AZURE_UPLOAD_CONF) && !empty(AZURE_UPLOAD_CONF)
+. for VAR in _STORAGE _ACCOUNT _KEY
+AZURE${VAR}!= grep -E ^AZURE${VAR} ${AZURE_UPLOAD_CONF} | awk -F' ' '{print $$2}'
+. endfor
+.endif
+
+.if ${BRANCH} == "STABLE" || ${BRANCH} == "CURRENT"
+SNAPSHOT_DATE!= date +-%Y-%m-%d
+.endif
+
+AZURE_TARGET:= ${OSRELEASE}${SNAPSHOT_DATE}.vhd
+
+azure-upload: ${AZURE_UPLOAD_TGTS}
+
+azure-check-depends:
+.for VAR in _STORAGE _ACCOUNT _KEY
+. if !defined(AZURE${VAR}) || empty(AZURE${VAR})
+ @echo "Variable AZURE${VAR} cannot be empty."
+ @false
+. endif
+.endfor
+.if !exists(/usr/local/bin/azure)
+. if !exists(/usr/local/bin/npm)
+. if !exists(${PORTSDIR}/www/npm/Makefile)
+. if !exists(/usr/local/sbin/pkg-static)
+ env ASSUME_ALWAYS_YES=yes pkg bootstrap -yf
+. endif
+ env ASSUME_ALWAYS_YES=yes pkg install -y www/npm
+. else
+ make -C ${PORTSDIR}/www/npm BATCH=1 all install clean
+. endif
+. endif
+ npm install -g azure-cli
+.endif
+
+azure-do-upload:
+ /usr/local/bin/azure storage blob upload \
+ ${AZURE_IMG} ${AZURE_STORAGE} ${AZURE_TARGET} \
+ -t page -a ${AZURE_ACCOUNT} -k "${AZURE_KEY}"
+ touch ${.OBJDIR}/${.TARGET}
+
diff --git a/release/Makefile.vm b/release/Makefile.vm
index 6599702..ae7c3aa 100644
--- a/release/Makefile.vm
+++ b/release/Makefile.vm
@@ -154,3 +154,4 @@ cloudware-install:
.endif
.include "${.CURDIR}/Makefile.ec2"
+.include "${.CURDIR}/Makefile.azure"
diff --git a/release/arm/BEAGLEBONE.conf b/release/arm/BEAGLEBONE.conf
index 48375b3..4fcb07d 100644
--- a/release/arm/BEAGLEBONE.conf
+++ b/release/arm/BEAGLEBONE.conf
@@ -9,7 +9,7 @@ EMBEDDED_TARGET_ARCH="armv6"
EMBEDDEDPORTS="sysutils/u-boot-beaglebone"
KERNEL="BEAGLEBONE"
WORLD_FLAGS="${WORLD_FLAGS} UBLDR_LOADADDR=0x88000000"
-IMAGE_SIZE="480M"
+IMAGE_SIZE="1G"
PART_SCHEME="MBR"
FAT_SIZE="2m"
FAT_TYPE="12"
diff --git a/release/arm/CUBOX-HUMMINGBOARD.conf b/release/arm/CUBOX-HUMMINGBOARD.conf
index 5c82d40..79e9389 100644
--- a/release/arm/CUBOX-HUMMINGBOARD.conf
+++ b/release/arm/CUBOX-HUMMINGBOARD.conf
@@ -9,7 +9,7 @@ EMBEDDED_TARGET_ARCH="armv6"
EMBEDDEDPORTS="sysutils/u-boot-cubox-hummingboard"
KERNEL="IMX6"
WORLD_FLAGS="${WORLD_FLAGS} UBLDR_LOADADDR=0x12000000"
-IMAGE_SIZE="480M"
+IMAGE_SIZE="1G"
PART_SCHEME="MBR"
FAT_SIZE="50m -b 16384"
FAT_TYPE="16"
diff --git a/release/arm/GUMSTIX.conf b/release/arm/GUMSTIX.conf
index 92e8476..6812a5f 100644
--- a/release/arm/GUMSTIX.conf
+++ b/release/arm/GUMSTIX.conf
@@ -9,7 +9,7 @@ EMBEDDED_TARGET_ARCH="armv6"
EMBEDDEDPORTS="sysutils/u-boot-duovero"
KERNEL="GUMSTIX"
WORLD_FLAGS="${WORLD_FLAGS} UBLDR_LOADADDR=0x88000000"
-IMAGE_SIZE="480M"
+IMAGE_SIZE="1G"
PART_SCHEME="MBR"
FAT_SIZE="2m"
FAT_TYPE="12"
diff --git a/release/arm/PANDABOARD.conf b/release/arm/PANDABOARD.conf
index 0a51b30..6b75566 100644
--- a/release/arm/PANDABOARD.conf
+++ b/release/arm/PANDABOARD.conf
@@ -9,7 +9,7 @@ EMBEDDED_TARGET_ARCH="armv6"
EMBEDDEDPORTS="sysutils/u-boot-pandaboard"
KERNEL="PANDABOARD"
WORLD_FLAGS="${WORLD_FLAGS} UBLDR_LOADADDR=0x88000000"
-IMAGE_SIZE="480M"
+IMAGE_SIZE="1G"
PART_SCHEME="MBR"
FAT_SIZE="2m"
FAT_TYPE="12"
diff --git a/release/arm/RPI-B.conf b/release/arm/RPI-B.conf
index ee3974b..e5abaab 100644
--- a/release/arm/RPI-B.conf
+++ b/release/arm/RPI-B.conf
@@ -9,7 +9,7 @@ EMBEDDED_TARGET_ARCH="armv6"
EMBEDDEDPORTS="sysutils/u-boot-rpi"
KERNEL="RPI-B"
WORLD_FLAGS="${WORLD_FLAGS} UBLDR_LOADADDR=0x2000000"
-IMAGE_SIZE="480M"
+IMAGE_SIZE="1G"
PART_SCHEME="MBR"
FAT_SIZE="17m"
FAT_TYPE="16"
diff --git a/release/arm/RPI2.conf b/release/arm/RPI2.conf
index d5fbb18..2da7e96 100644
--- a/release/arm/RPI2.conf
+++ b/release/arm/RPI2.conf
@@ -9,7 +9,7 @@ EMBEDDED_TARGET_ARCH="armv6"
EMBEDDEDPORTS="sysutils/u-boot-rpi2"
KERNEL="RPI2"
WORLD_FLAGS="${WORLD_FLAGS} UBLDR_LOADADDR=0x2000000"
-IMAGE_SIZE="480M"
+IMAGE_SIZE="1G"
PART_SCHEME="MBR"
FAT_SIZE="50m"
FAT_TYPE="16"
diff --git a/release/arm/WANDBOARD.conf b/release/arm/WANDBOARD.conf
index 3e5fae4..4033d09 100644
--- a/release/arm/WANDBOARD.conf
+++ b/release/arm/WANDBOARD.conf
@@ -9,7 +9,7 @@ EMBEDDED_TARGET_ARCH="armv6"
EMBEDDEDPORTS="sysutils/u-boot-wandboard"
KERNEL="IMX6"
WORLD_FLAGS="${WORLD_FLAGS} UBLDR_LOADADDR=0x12000000"
-IMAGE_SIZE="480M"
+IMAGE_SIZE="1G"
PART_SCHEME="MBR"
FAT_SIZE="50m -b 16384"
FAT_TYPE="16"
diff --git a/release/tools/azure.conf b/release/tools/azure.conf
index 922f8d9..4267f97 100644
--- a/release/tools/azure.conf
+++ b/release/tools/azure.conf
@@ -14,8 +14,8 @@ export VM_EXTRA_PACKAGES="sysutils/azure-agent"
export VM_RC_LIST=
vm_extra_pre_umount() {
- chroot ${DESTDIR} /usr/sbin/waagent -verbose -install
- yes | chroot ${DESTDIR} /usr/sbin/waagent -deprovision
+ chroot ${DESTDIR} /usr/local/sbin/waagent -verbose -install
+ yes | chroot ${DESTDIR} /usr/local/sbin/waagent -deprovision
echo 'sshd_enable="YES"' >> ${DESTDIR}/etc/rc.conf
echo 'ifconfig_hn0="SYNCDHCP"' >> ${DESTDIR}/etc/rc.conf
echo 'waagent_enable="YES"' >> ${DESTDIR}/etc/rc.conf
diff --git a/sbin/atm/atmconfig/Makefile.depend b/sbin/atm/atmconfig/Makefile.depend
index 7df1c10..c790621 100644
--- a/sbin/atm/atmconfig/Makefile.depend
+++ b/sbin/atm/atmconfig/Makefile.depend
@@ -2,7 +2,6 @@
# Autogenerated - do NOT edit!
DIRDEPS = \
- bin/cat.host \
gnu/lib/csu \
gnu/lib/libgcc \
include \
diff --git a/sbin/devd/Makefile.depend b/sbin/devd/Makefile.depend
index eb9beeb..2611200 100644
--- a/sbin/devd/Makefile.depend
+++ b/sbin/devd/Makefile.depend
@@ -3,6 +3,7 @@
DIRDEPS = \
gnu/lib/csu \
+ gnu/lib/libgcc \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/sbin/init/Makefile.depend b/sbin/init/Makefile.depend
index 10a95e7..d8297c2 100644
--- a/sbin/init/Makefile.depend
+++ b/sbin/init/Makefile.depend
@@ -3,6 +3,7 @@
DIRDEPS = \
gnu/lib/csu \
+ gnu/lib/libgcc \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/sbin/umount/umount.8 b/sbin/umount/umount.8
index e62bcc5..2ddbf5a 100644
--- a/sbin/umount/umount.8
+++ b/sbin/umount/umount.8
@@ -28,7 +28,7 @@
.\" @(#)umount.8 8.2 (Berkeley) 5/8/95
.\" $FreeBSD$
.\"
-.Dd November 22, 2014
+.Dd June 17, 2015
.Dt UMOUNT 8
.Os
.Sh NAME
@@ -81,6 +81,9 @@ The root file system cannot be forcibly unmounted.
For NFS, a forced dismount can take up to 1 minute or more to
complete against an unresponsive server and may throw away
data not yet written to the server for this case.
+Also, doing a forced dismount of an NFSv3 mount when
+.Xr rpc.lockd 8
+is running is unsafe and can result in a crash.
.It Fl h Ar host
Only file systems mounted from the specified host will be
unmounted.
diff --git a/secure/lib/libcrypt/crypt-blowfish.c b/secure/lib/libcrypt/crypt-blowfish.c
index 35fb581..acd9057 100644
--- a/secure/lib/libcrypt/crypt-blowfish.c
+++ b/secure/lib/libcrypt/crypt-blowfish.c
@@ -167,6 +167,9 @@ crypt_blowfish(const char *key, const char *salt)
switch (salt[1]) {
case 'a': /* 'ab' should not yield the same as 'abab' */
case 'b': /* cap input length at 72 bytes */
+ case 'y': /* same as 'b', for compatibility
+ * with openwall crypt_blowfish
+ */
minr = salt[1];
salt++;
break;
diff --git a/secure/lib/libcrypto/Makefile.depend b/secure/lib/libcrypto/Makefile.depend
index 0742ab2..723f45e 100644
--- a/secure/lib/libcrypto/Makefile.depend
+++ b/secure/lib/libcrypto/Makefile.depend
@@ -11,6 +11,7 @@ DIRDEPS = \
lib/libc \
lib/libcompiler_rt \
lib/msun \
+ usr.bin/xinstall.host \
.include <dirdeps.mk>
diff --git a/secure/lib/libssh/Makefile.depend b/secure/lib/libssh/Makefile.depend
index 51e45b4..fbf95e5 100644
--- a/secure/lib/libssh/Makefile.depend
+++ b/secure/lib/libssh/Makefile.depend
@@ -17,6 +17,7 @@ DIRDEPS = \
lib/libz \
secure/lib/libcrypto \
secure/lib/libssl \
+ usr.bin/xinstall.host \
.include <dirdeps.mk>
diff --git a/secure/lib/libssl/Makefile.depend b/secure/lib/libssl/Makefile.depend
index f318cc1..5d73f97 100644
--- a/secure/lib/libssl/Makefile.depend
+++ b/secure/lib/libssl/Makefile.depend
@@ -11,6 +11,7 @@ DIRDEPS = \
lib/libc \
lib/libcompiler_rt \
secure/lib/libcrypto \
+ usr.bin/xinstall.host \
.include <dirdeps.mk>
diff --git a/share/doc/usd/13.viref/Makefile b/share/doc/usd/13.viref/Makefile
index 49226ba..a60e326 100644
--- a/share/doc/usd/13.viref/Makefile
+++ b/share/doc/usd/13.viref/Makefile
@@ -2,7 +2,6 @@
# $FreeBSD$
VOLUME= usd/13.viref
-SRCS= vi.ref-patched
EXTRA= ex.cmd.roff ref.so set.opt.roff vi.cmd.roff
MACROS= -me
CLEANFILES= vi.ref-patched index
@@ -15,18 +14,22 @@ vi.ref-patched: vi.ref
PRINTERDEVICE?= ascii
.for _dev in ${PRINTERDEVICE}
+SRCS+= vi.ref-${_dev}
EXTRA+= index.so.${_dev}
-CLEANFILES+= index.so.${_dev}
+CLEANFILES+= index.so.${_dev} vi.ref-${_dev}
+
+vi.ref-${_dev}: index.so.${_dev}
+ sed -e 's:^\.so index\.so\.\\\*\[\.T\]$$:${_dev}:' vi.ref-patched > ${.TARGET}
# Build index.so as a side-effect of building the paper.
-index.so.${_dev}: ${SRCS} ${EXTRA:Nindex.so.${_dev}}
+index.so.${_dev}: vi.ref-patched ${EXTRA:Nindex.so.${_dev}}
sed -e 's:^\.so index\.so\.\\\*\[\.T\]$$::' vi.ref-patched | \
${ROFF.${_dev}} -U -z
sed -e 's/MINUSSIGN/-/' \
-e 's/DOUBLEQUOTE/""/' \
-e "s/SQUOTE/'/" \
-e 's/ /__SPACE/g' < index | \
- sort -u '-t ' -k 1,1 -k 2n | awk -f ${SRCDIR}/merge.awk | \
+ sort -u '-t ' -k 1,1 -k 2n | awk -f ${.CURDIR}/merge.awk | \
sed -e 's/__SPACE/ /g' \
-e "s/^\\(['\\.]\\)/\\\\\&\\1/" > ${.TARGET}
.endfor
diff --git a/share/doc/usd/13.viref/merge.awk b/share/doc/usd/13.viref/merge.awk
new file mode 100644
index 0000000..e85f7d3
--- /dev/null
+++ b/share/doc/usd/13.viref/merge.awk
@@ -0,0 +1,17 @@
+# $FreeBSD$
+# @(#)merge.awk 8.3 (Berkeley) 5/25/94
+#
+# merge index entries into one line per label
+$1 == prev {
+ printf ", %s", $2;
+ next;
+}
+{
+ if (NR != 1)
+ printf "\n";
+ printf "%s \t%s", $1, $2;
+ prev = $1;
+}
+END {
+ printf "\n"
+}
diff --git a/share/examples/bhyve/vmrun.sh b/share/examples/bhyve/vmrun.sh
index 88cbd7c..58bfa4a 100755
--- a/share/examples/bhyve/vmrun.sh
+++ b/share/examples/bhyve/vmrun.sh
@@ -87,15 +87,15 @@ console=${DEFAULT_CONSOLE}
cpus=${DEFAULT_CPUS}
tap_total=0
disk_total=0
-apic_opt=""
gdbport=0
loader_opt=""
+bhyverun_opt="-H -A -P"
pass_total=0
while getopts ac:C:d:e:g:hH:iI:m:p:t: c ; do
case $c in
a)
- apic_opt="-a"
+ bhyverun_opt="${bhyverun_opt} -a"
;;
c)
cpus=${OPTARG}
@@ -163,6 +163,12 @@ if [ -n "${host_base}" ]; then
loader_opt="${loader_opt} -h ${host_base}"
fi
+# If PCI passthru devices are configured then guest memory must be wired
+if [ ${pass_total} -gt 0 ]; then
+ loader_opt="${loader_opt} -S"
+ bhyverun_opt="${bhyverun_opt} -S"
+fi
+
make_and_check_diskdev()
{
local virtio_diskdev="$1"
@@ -263,7 +269,7 @@ while [ 1 ]; do
i=$(($i + 1))
done
- ${FBSDRUN} -c ${cpus} -m ${memsize} ${apic_opt} -A -H -P \
+ ${FBSDRUN} -c ${cpus} -m ${memsize} ${bhyverun_opt} \
-g ${gdbport} \
-s 0:0,hostbridge \
-s 1:0,lpc \
diff --git a/share/i18n/csmapper/Makefile.depend b/share/i18n/csmapper/Makefile.depend
index a969dcd..b221179 100644
--- a/share/i18n/csmapper/Makefile.depend
+++ b/share/i18n/csmapper/Makefile.depend
@@ -2,7 +2,6 @@
# Autogenerated - do NOT edit!
DIRDEPS = \
- bin/cat.host \
share/i18n/csmapper/APPLE \
share/i18n/csmapper/AST \
share/i18n/csmapper/BIG5 \
diff --git a/share/i18n/esdb/Makefile.depend b/share/i18n/esdb/Makefile.depend
index d4f32a8..2b8adbf 100644
--- a/share/i18n/esdb/Makefile.depend
+++ b/share/i18n/esdb/Makefile.depend
@@ -2,7 +2,6 @@
# Autogenerated - do NOT edit!
DIRDEPS = \
- bin/cat.host \
share/i18n/esdb/APPLE \
share/i18n/esdb/AST \
share/i18n/esdb/BIG5 \
diff --git a/share/man/man4/aacraid.4 b/share/man/man4/aacraid.4
index 2ca830d..9172591 100644
--- a/share/man/man4/aacraid.4
+++ b/share/man/man4/aacraid.4
@@ -23,7 +23,7 @@
.\" SUCH DAMAGE.
.\"
.\" $FreeBSD$
-.Dd April 09, 2013
+.Dd June 19, 2015
.Dt AACRAID 4
.Os
.Sh NAME
@@ -58,8 +58,9 @@ The RAID containers are handled via the
bus.
The physical buses are represented by the
.Nm aacraidp?
-devices (beginning with aacraidp1). These devices enable the
-SCSI pass-thru interface and allows devices connected
+devices (beginning with aacraidp1).
+These devices enable the
+SCSI pass-passthrough interface and allows devices connected
to the card such as CD-ROMs to be available via the CAM
.Xr scsi 4
subsystem.
@@ -129,7 +130,7 @@ and are also queued for retrieval by a management application.
.Xr kldload 8
.Sh AUTHORS
.An Achim Leubner Aq Mt achim@FreeBSD.org
-.An Ed Maste Aq Mt emaste@FreeBSD.org
+.An \&Ed Maste Aq Mt emaste@FreeBSD.org
.An Scott Long Aq Mt scottl@FreeBSD.org
.Sh BUGS
The controller is not actually paused on suspend/resume.
diff --git a/share/man/man4/acpi_hp.4 b/share/man/man4/acpi_hp.4
index 2ea74cf..cf67385 100644
--- a/share/man/man4/acpi_hp.4
+++ b/share/man/man4/acpi_hp.4
@@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd February 8, 2010
+.Dd June 19, 2015
.Dt ACPI_HP 4
.Os
.Sh NAME
@@ -48,7 +48,7 @@ acpi_hp_load="YES"
The
.Nm
driver provides support for ACPI-controlled features found on HP laptops
-that use a WMI enabled BIOS (e.g. HP Compaq 8510p and 6510p).
+that use a WMI enabled BIOS (e.g., HP Compaq 8510p and 6510p).
.Pp
The main purpose of this driver is to provide an interface,
accessible via
@@ -58,7 +58,7 @@ accessible via
through which applications can determine and change the status of
various laptop components and BIOS settings.
.Pp
-.Ss Xr devd 8 Ss Events
+.Ss Xr devd 8 Events
Devd events received by
.Xr devd 8
provide the following information:
@@ -91,7 +91,7 @@ WWAN on air status changed to 0 (not on air)
.It Li 0xe1
WWAN on air status changed to 1 (on air)
.El
-.Ss Xr devfs 8 Ss Device
+.Ss Xr devfs 8 Device
You can read /dev/hpcmi to see your current BIOS settings.
The detail level can be adjusted by setting the sysctl
.Va cmi_detail
@@ -197,8 +197,7 @@ Interface to read BIOS settings
.Sh EXAMPLES
The following can be added to
.Xr devd.conf 5
-in order disable the LAN interface when WLAN on air and reenable if it's
-not:
+in order disable the LAN interface when WLAN on air and reenable if it is not:
.Bd -literal -offset indent
notify 0 {
match "system" "ACPI";
@@ -281,7 +280,10 @@ This driver is experimental and has only been tested on i386 on an
HP Compaq 8510p which featured all supported wireless devices (WWAN/BT/WLAN).
Expect undefined results when operating on different hardware.
.Pp
-Loading the driver is slow. Reading from /dev/hpcmi is even slower.
+Loading the driver is slow.
+Reading from
+.Pa /dev/hpcmi
+is even slower.
.Pp
Additional features like HP specific sensor readings or writing BIOS
settings are not supported.
diff --git a/share/man/man4/acpi_ibm.4 b/share/man/man4/acpi_ibm.4
index d566207..15a5bee 100644
--- a/share/man/man4/acpi_ibm.4
+++ b/share/man/man4/acpi_ibm.4
@@ -25,7 +25,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd June 24, 2012
+.Dd June 19, 2015
.Dt ACPI_IBM 4
.Os
.Sh NAME
@@ -74,7 +74,7 @@ sysctl, is set to
.Va availmask
by default, a value representing all possible keypress events on the specific
ThinkPad model.
-.Ss Xr devd 8 Ss Events
+.Ss Xr devd 8 Events
Hotkey events received by
.Xr devd 8
provide the following information:
@@ -144,7 +144,7 @@ Mute
.It Li 0x18
Access IBM Button
.El
-.Ss Xr led 4 Ss Interface
+.Ss Xr led 4 Interface
The
.Nm
driver provides a
@@ -344,7 +344,7 @@ when
is set to 1.
Events are specified as a whitespace-separated list of event code in
hexadecimal or decimal form.
-Note that the event maybe handled twice (eg. Brightness up/down) if ACPI BIOS
+Note that the event maybe handled twice (e.g., Brightness up/down) if ACPI BIOS
already handled the event.
.El
.Pp
diff --git a/share/man/man4/acpi_panasonic.4 b/share/man/man4/acpi_panasonic.4
index 9ea36e4..6b0f350 100644
--- a/share/man/man4/acpi_panasonic.4
+++ b/share/man/man4/acpi_panasonic.4
@@ -25,7 +25,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd February 25, 2012
+.Dd June 19, 2015
.Dt ACPI_PANASONIC 4
.Os
.Sh NAME
@@ -100,7 +100,7 @@ For the other events such as
mixer control and showing battery status,
.Xr devd 8
should take the role as described below.
-.Ss Xr devd 8 Ss Events
+.Ss Xr devd 8 Events
When notified to
.Xr devd 8 ,
the hotkey event provides the following information:
diff --git a/share/man/man4/ada.4 b/share/man/man4/ada.4
index 6f2964e..3a186ae 100644
--- a/share/man/man4/ada.4
+++ b/share/man/man4/ada.4
@@ -25,7 +25,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd October 22, 2014
+.Dd June 19, 2015
.Dt ADA 4
.Os
.Sh NAME
@@ -45,14 +45,14 @@ The host adapter must also be separately configured into the system before an
.Tn ATA
direct access device can be configured.
.Sh COMMAND QUEUING
-Command queueing allows the device to process multiple transactions
+Command queuing allows the device to process multiple transactions
concurrently, often re-ordering them to reduce the number and length of
seeks.
.Tn ATA
-defines two types of queueing:
-.Tn TCQ (Tagged Command Queueing, PATA legacy)
+defines two types of queuing:
+.Tn TCQ (Tagged Command Queuing, PATA legacy)
and
-.Tn NCQ (Native Command Queueing, SATA) .
+.Tn NCQ (Native Command Queuing, SATA) .
The
.Nm
device driver takes full advantage of NCQ, when supported.
@@ -146,6 +146,16 @@ instead of
.Pa /etc/sysctl.conf .
The global default is currently 1.
The per-device default is to leave it as-is (follow global setting).
+.It Va kern.cam.ada.legacy_aliases
+.Pp
+This variable determines whether
+.Pa /dev/ad Ns Ar Y
+symbolic links are created,
+which tries to mimic old
+.Xr ata 4
+numbering.
+Set to 1 to enable legacy aliases symlinks, 0 to disable.
+The default is currently enabled.
.El
.Sh FILES
.Bl -tag -width ".Pa /dev/ada*" -compact
diff --git a/share/man/man9/pci_iov_schema.9 b/share/man/man9/pci_iov_schema.9
index 36c0189..52e5c8b 100644
--- a/share/man/man9/pci_iov_schema.9
+++ b/share/man/man9/pci_iov_schema.9
@@ -25,8 +25,8 @@
.\"
.\" $FreeBSD$
.\"
-.Dd May 28, 2015
-.Dt pci_iov_schema 9
+.Dd June 18, 2015
+.Dt PCI_IOV_SCHEMA 9
.Os
.Sh NAME
.Nm pci_iov_schema ,
@@ -67,7 +67,7 @@
.Fn pci_iov_schema_add_unicast_mac "nvlist_t *schema" "const char *name" \
"uint32_t flags" "const uint8_t *defaultVal"
.Sh DESCRIPTION
-The PCI Single-Root I/O Virtualization
+The PCI Single-Root I/O Virtualization
.Pq SR-IOV
configuration schema is a data
structure that describes the device-specific configuration parameters that a PF
@@ -147,9 +147,9 @@ the VF was allowed to change its MAC address, it would not be appropriate to
set this parameter as optional.
The PF driver must either allow the MAC to change or not, so it would be more
appropriate for the PF driver to document the default behaviour by specifying
-a default value in the schema
+a default value in the schema
.Po or potentially force the user to make the choice by setting the parameter
-to be required
+to be required
.Pc .
.Pp
Configuration parameters that have security implications must default to the
@@ -226,7 +226,7 @@ and having a
type.
Values of type
.Vt uint32_t
-are unsigned integers in the range 0 to
+are unsigned integers in the range 0 to
.Po 2**32 - 1 Pc ,
inclusive.
.Pp
@@ -240,7 +240,7 @@ and having a
type.
Values of type
.Vt uint64_t
-are unsigned integers in the range 0 to
+are unsigned integers in the range 0 to
.Po 2**64 - 1 Pc ,
inclusive.
.Pp
diff --git a/share/man/man9/sbuf.9 b/share/man/man9/sbuf.9
index 21faf97..0014884 100644
--- a/share/man/man9/sbuf.9
+++ b/share/man/man9/sbuf.9
@@ -117,7 +117,7 @@
.Ft ssize_t
.Fn sbuf_end_section "struct sbuf *s" "ssize_t old_len" "size_t pad" "int c"
.Ft void
-.Fo sbuf_hexdump
+.Fo sbuf_hexdump
.Fa "struct sbuf *sb"
.Fa "void *ptr"
.Fa "int length"
diff --git a/share/man/man9/taskqueue.9 b/share/man/man9/taskqueue.9
index e2b105f..5f2bcf6 100644
--- a/share/man/man9/taskqueue.9
+++ b/share/man/man9/taskqueue.9
@@ -288,11 +288,11 @@ are enqueued on the taskqueue to finish.
Tasks posted to the taskqueue after
.Fn taskqueue_drain_all
begins processing,
-including pending enqueues scheduled by a previous call to
+including pending enqueues scheduled by a previous call to
.Fn taskqueue_enqueue_timeout ,
do not extend the wait time of
.Fn taskqueue_drain_all
-and may complete after
+and may complete after
.Fn taskqueue_drain_all
returns.
.Pp
diff --git a/share/mk/bsd.doc.mk b/share/mk/bsd.doc.mk
index 74a2ab5..c221f56 100644
--- a/share/mk/bsd.doc.mk
+++ b/share/mk/bsd.doc.mk
@@ -75,7 +75,7 @@ TRFLAGS+= -p
TRFLAGS+= -R
.endif
.if defined(USE_SOELIM)
-TRFLAGS+= -I${SRCDIR}
+TRFLAGS+= -I${.CURDIR}
.endif
.if defined(USE_TBL)
TRFLAGS+= -t
diff --git a/share/mk/local.sys.env.mk b/share/mk/local.sys.env.mk
new file mode 100644
index 0000000..ca3f7a0
--- /dev/null
+++ b/share/mk/local.sys.env.mk
@@ -0,0 +1,43 @@
+# $FreeBSD$
+
+# This makefile is for customizations that should be done early
+
+.if !defined(_TARGETS)
+# some things we do only once
+_TARGETS:= ${.TARGETS}
+.export _TARGETS
+.endif
+
+# some handy macros
+_this = ${.PARSEDIR:tA}/${.PARSEFILE}
+# some useful modifiers
+
+# A useful trick for testing multiple :M's against something
+# :L says to use the variable's name as its value - ie. literal
+# got = ${clean* destroy:${M_ListToMatch:S,V,.TARGETS,}}
+M_ListToMatch = L:@m@$${V:M$$m}@
+# match against our initial targets (see above)
+M_L_TARGETS = ${M_ListToMatch:S,V,_TARGETS,}
+
+# turn a list into a set of :N modifiers
+# NskipFoo = ${Foo:${M_ListToSkip}}
+M_ListToSkip= O:u:ts::S,:,:N,g:S,^,N,
+
+# type should be a builtin in any sh since about 1980,
+# AUTOCONF := ${autoconf:L:${M_whence}}
+M_type = @x@(type $$x 2> /dev/null); echo;@:sh:[0]:N* found*:[@]:C,[()],,g
+M_whence = ${M_type}:M/*:[1]
+
+# convert a path to a valid shell variable
+M_P2V = tu:C,[./-],_,g
+
+# these are handy
+# we can use this for a cheap timestamp at the start of a target's script,
+# but not at the end - since make will expand both at the same time.
+TIME_STAMP_FMT = @ %s [%Y-%m-%d %T]
+TIME_STAMP = ${TIME_STAMP_FMT:localtime}
+# this will produce the same output but as of when date(1) is run.
+TIME_STAMP_DATE = `date '+${TIME_STAMP_FMT}'`
+TIME_STAMP_END?= ${TIME_STAMP_DATE}
+
+.include "src.sys.env.mk"
diff --git a/share/mk/local.sys.mk b/share/mk/local.sys.mk
index 87f945e..d542f8b 100644
--- a/share/mk/local.sys.mk
+++ b/share/mk/local.sys.mk
@@ -1,34 +1,5 @@
# $FreeBSD$
-.if !defined(_TARGETS)
-# some things we do only once
-_TARGETS:= ${.TARGETS}
-.export _TARGETS
-.endif
-
-# some handy macros
-_this = ${.PARSEDIR:tA}/${.PARSEFILE}
-# some useful modifiers
-
-# A useful trick for testing multiple :M's against something
-# :L says to use the variable's name as its value - ie. literal
-# got = ${clean* destroy:${M_ListToMatch:S,V,.TARGETS,}}
-M_ListToMatch = L:@m@$${V:M$$m}@
-# match against our initial targets (see above)
-M_L_TARGETS = ${M_ListToMatch:S,V,_TARGETS,}
-
-# turn a list into a set of :N modifiers
-# NskipFoo = ${Foo:${M_ListToSkip}}
-M_ListToSkip= O:u:ts::S,:,:N,g:S,^,N,
-
-# type should be a builtin in any sh since about 1980,
-# AUTOCONF := ${autoconf:L:${M_whence}}
-M_type = @x@(type $$x 2> /dev/null); echo;@:sh:[0]:N* found*:[@]:C,[()],,g
-M_whence = ${M_type}:M/*:[1]
-
-# convert a path to a valid shell variable
-M_P2V = tu:C,[./-],_,g
-
.if ${MK_META_MODE} == "yes"
MAKE_PRINT_VAR_ON_ERROR+= \
.CURDIR \
@@ -51,13 +22,4 @@ MAKE_PRINT_VAR_ON_ERROR += .MAKE.MAKEFILES .PATH
.endif
.endif
-# these are handy
-# we can use this for a cheap timestamp at the start of a target's script,
-# but not at the end - since make will expand both at the same time.
-TIME_STAMP_FMT = @ %s [%Y-%m-%d %T]
-TIME_STAMP = ${TIME_STAMP_FMT:localtime}
-# this will produce the same output but as of when date(1) is run.
-TIME_STAMP_DATE = `date '+${TIME_STAMP_FMT}'`
-TIME_STAMP_END?= ${TIME_STAMP_DATE}
-
.include "src.sys.mk"
diff --git a/share/mk/meta.stage.mk b/share/mk/meta.stage.mk
index 2301b8f..467e339 100644
--- a/share/mk/meta.stage.mk
+++ b/share/mk/meta.stage.mk
@@ -60,14 +60,23 @@ LN_CP_SCRIPT = LnCp() { \
ln $$1 $$2 2> /dev/null || \
cp -p $$1 $$2; }
+# a staging conflict should cause an error
+# a warning is handy when bootstapping different options.
+STAGE_CONFLICT?= ERROR
+.if ${STAGE_CONFLICT:tl} == "error"
+STAGE_CONFLICT_ACTION= exit 1;
+.else
+STAGE_CONFLICT_ACTION=
+.endif
+
# it is an error for more than one src dir to try and stage
# the same file
STAGE_DIRDEP_SCRIPT = ${LN_CP_SCRIPT}; StageDirdep() { \
t=$$1; \
if [ -s $$t.dirdep ]; then \
cmp -s .dirdep $$t.dirdep && return; \
- echo "ERROR: $$t installed by `cat $$t.dirdep` not ${_dirdep}" >&2; \
- exit 1; \
+ echo "${STAGE_CONFLICT}: $$t installed by `cat $$t.dirdep` not ${_dirdep}" >&2; \
+ ${STAGE_CONFLICT_ACTION} \
fi; \
LnCp .dirdep $$t.dirdep || exit 1; }
diff --git a/share/mk/src.opts.mk b/share/mk/src.opts.mk
index 127b81c..3331f6f 100644
--- a/share/mk/src.opts.mk
+++ b/share/mk/src.opts.mk
@@ -179,7 +179,6 @@ __DEFAULT_NO_OPTIONS = \
BSD_GREP \
CLANG_EXTRAS \
EISA \
- FMAKE \
HESIOD \
LLDB \
NAND \
diff --git a/share/mk/src.sys.env.mk b/share/mk/src.sys.env.mk
new file mode 100644
index 0000000..0516075
--- /dev/null
+++ b/share/mk/src.sys.env.mk
@@ -0,0 +1,24 @@
+# $FreeBSD$
+
+# early setup only see also src.sys.mk
+
+# make sure this is defined in a consistent manner
+SRCTOP:= ${.PARSEDIR:tA:H:H}
+
+# site customizations that do not depend on anything!
+SRC_ENV_CONF?= /etc/src-env.conf
+.if !empty(SRC_ENV_CONF) && !target(_src_env_conf_included_)
+.-include "${SRC_ENV_CONF}"
+_src_env_conf_included_: .NOTMAIN
+.endif
+
+# If we were found via .../share/mk we need to replace that
+# with ${.PARSEDIR:tA} so that we can be found by
+# sub-makes launched from objdir.
+.if ${.MAKEFLAGS:M.../share/mk} != ""
+.MAKEFLAGS:= ${.MAKEFLAGS:S,.../share/mk,${.PARSEDIR:tA},}
+.endif
+.if ${MAKESYSPATH:Uno:M*.../*} != ""
+MAKESYSPATH:= ${MAKESYSPATH:S,.../share/mk,${.PARSEDIR:tA},}
+.export MAKESYSPATH
+.endif
diff --git a/share/mk/src.sys.mk b/share/mk/src.sys.mk
index f8dea28..81ecaf6 100644
--- a/share/mk/src.sys.mk
+++ b/share/mk/src.sys.mk
@@ -5,24 +5,13 @@
# to preserve historical (and useful) behavior. Changes here need to
# be reflected there so SRCCONF isn't included multiple times.
-# make sure this is defined in a consistent manner
-SRCTOP:= ${.PARSEDIR:tA:H:H}
-
# Allow user to configure things that only effect src tree builds.
SRCCONF?= /etc/src.conf
.if (exists(${SRCCONF}) || ${SRCCONF} != "/etc/src.conf") && !target(_srcconf_included_)
.sinclude "${SRCCONF}"
_srcconf_included_: .NOTMAIN
.endif
-# If we were found via .../share/mk we need to replace that
-# with ${.PARSEDIR:tA} so that we can be found by
-# sub-makes launched from objdir.
-.if ${.MAKEFLAGS:M.../share/mk} != ""
-.MAKEFLAGS:= ${.MAKEFLAGS:S,.../share/mk,${.PARSEDIR:tA},}
-.endif
-.if ${MAKESYSPATH:Uno:M*.../*} != ""
-MAKESYSPATH:= ${MAKESYSPATH:S,.../share/mk,${.PARSEDIR:tA},}
-.export MAKESYSPATH
-.endif
+
# tempting, but bsd.compiler.mk causes problems this early
+# probably need to remove dependence on bsd.own.mk
#.include "src.opts.mk"
diff --git a/share/mk/sys.mk b/share/mk/sys.mk
index f3534a6..d23d1d7 100644
--- a/share/mk/sys.mk
+++ b/share/mk/sys.mk
@@ -31,15 +31,9 @@ __DEFAULT_DEPENDENT_OPTIONS= \
.include <bsd.mkopt.mk>
-# Pull in global settings.
-__MAKE_CONF?=/etc/make.conf
-.if exists(${__MAKE_CONF})
-.include "${__MAKE_CONF}"
-.endif
-
-# Set any local definitions first. Place this early, but it needs
-# MACHINE_CPUARCH to be defined.
-.-include <local.sys.mk>
+# early include for customization
+# see local.sys.mk below
+.-include <local.sys.env.mk>
.if ${MK_META_MODE} == "yes"
.-include <meta.sys.mk>
@@ -360,6 +354,14 @@ YFLAGS ?= -d
rm -f ${.PREFIX}.tmp.c
${CTFCONVERT_CMD}
+# Pull in global settings.
+__MAKE_CONF?=/etc/make.conf
+.if exists(${__MAKE_CONF})
+.include "${__MAKE_CONF}"
+.endif
+
+# late include for customization
+.-include <local.sys.mk>
.if defined(__MAKE_SHELL) && !empty(__MAKE_SHELL)
SHELL= ${__MAKE_SHELL}
diff --git a/sys/amd64/include/vmm.h b/sys/amd64/include/vmm.h
index 1a4e5ab..f2de960 100644
--- a/sys/amd64/include/vmm.h
+++ b/sys/amd64/include/vmm.h
@@ -108,7 +108,6 @@ enum x2apic_state {
struct vm;
struct vm_exception;
-struct vm_memory_segment;
struct seg_desc;
struct vm_exit;
struct vm_run;
@@ -175,17 +174,33 @@ int vm_create(const char *name, struct vm **retvm);
void vm_destroy(struct vm *vm);
int vm_reinit(struct vm *vm);
const char *vm_name(struct vm *vm);
-int vm_malloc(struct vm *vm, vm_paddr_t gpa, size_t len);
+
+/*
+ * APIs that modify the guest memory map require all vcpus to be frozen.
+ */
+int vm_mmap_memseg(struct vm *vm, vm_paddr_t gpa, int segid, vm_ooffset_t off,
+ size_t len, int prot, int flags);
+int vm_alloc_memseg(struct vm *vm, int ident, size_t len, bool sysmem);
+void vm_free_memseg(struct vm *vm, int ident);
int vm_map_mmio(struct vm *vm, vm_paddr_t gpa, size_t len, vm_paddr_t hpa);
int vm_unmap_mmio(struct vm *vm, vm_paddr_t gpa, size_t len);
-void *vm_gpa_hold(struct vm *, vm_paddr_t gpa, size_t len, int prot,
- void **cookie);
+int vm_assign_pptdev(struct vm *vm, int bus, int slot, int func);
+int vm_unassign_pptdev(struct vm *vm, int bus, int slot, int func);
+
+/*
+ * APIs that inspect the guest memory map require only a *single* vcpu to
+ * be frozen. This acts like a read lock on the guest memory map since any
+ * modification requires *all* vcpus to be frozen.
+ */
+int vm_mmap_getnext(struct vm *vm, vm_paddr_t *gpa, int *segid,
+ vm_ooffset_t *segoff, size_t *len, int *prot, int *flags);
+int vm_get_memseg(struct vm *vm, int ident, size_t *len, bool *sysmem,
+ struct vm_object **objptr);
+void *vm_gpa_hold(struct vm *, int vcpuid, vm_paddr_t gpa, size_t len,
+ int prot, void **cookie);
void vm_gpa_release(void *cookie);
-int vm_gpabase2memseg(struct vm *vm, vm_paddr_t gpabase,
- struct vm_memory_segment *seg);
-int vm_get_memobj(struct vm *vm, vm_paddr_t gpa, size_t len,
- vm_offset_t *offset, struct vm_object **object);
-boolean_t vm_mem_allocated(struct vm *vm, vm_paddr_t gpa);
+bool vm_mem_allocated(struct vm *vm, int vcpuid, vm_paddr_t gpa);
+
int vm_get_register(struct vm *vm, int vcpu, int reg, uint64_t *retval);
int vm_set_register(struct vm *vm, int vcpu, int reg, uint64_t val);
int vm_get_seg_desc(struct vm *vm, int vcpu, int reg,
@@ -302,8 +317,6 @@ vcpu_should_yield(struct vm *vm, int vcpu)
void *vcpu_stats(struct vm *vm, int vcpu);
void vcpu_notify_event(struct vm *vm, int vcpuid, bool lapic_intr);
struct vmspace *vm_get_vmspace(struct vm *vm);
-int vm_assign_pptdev(struct vm *vm, int bus, int slot, int func);
-int vm_unassign_pptdev(struct vm *vm, int bus, int slot, int func);
struct vatpic *vm_atpic(struct vm *vm);
struct vatpit *vm_atpit(struct vm *vm);
struct vpmtmr *vm_pmtmr(struct vm *vm);
diff --git a/sys/amd64/include/vmm_dev.h b/sys/amd64/include/vmm_dev.h
index 9d031a9..1af75a3 100644
--- a/sys/amd64/include/vmm_dev.h
+++ b/sys/amd64/include/vmm_dev.h
@@ -34,10 +34,22 @@ void vmmdev_init(void);
int vmmdev_cleanup(void);
#endif
-struct vm_memory_segment {
- vm_paddr_t gpa; /* in */
+struct vm_memmap {
+ vm_paddr_t gpa;
+ int segid; /* memory segment */
+ vm_ooffset_t segoff; /* offset into memory segment */
+ size_t len; /* mmap length */
+ int prot; /* RWX */
+ int flags;
+};
+#define VM_MEMMAP_F_WIRED 0x01
+#define VM_MEMMAP_F_IOMMU 0x02
+
+#define VM_MEMSEG_NAME(m) ((m)->name[0] != '\0' ? (m)->name : NULL)
+struct vm_memseg {
+ int segid;
size_t len;
- int wired;
+ char name[SPECNAMELEN + 1];
};
struct vm_register {
@@ -214,10 +226,14 @@ enum {
IOCNUM_REINIT = 5,
/* memory apis */
- IOCNUM_MAP_MEMORY = 10,
- IOCNUM_GET_MEMORY_SEG = 11,
+ IOCNUM_MAP_MEMORY = 10, /* deprecated */
+ IOCNUM_GET_MEMORY_SEG = 11, /* deprecated */
IOCNUM_GET_GPA_PMAP = 12,
IOCNUM_GLA2GPA = 13,
+ IOCNUM_ALLOC_MEMSEG = 14,
+ IOCNUM_GET_MEMSEG = 15,
+ IOCNUM_MMAP_MEMSEG = 16,
+ IOCNUM_MMAP_GETNEXT = 17,
/* register/state accessors */
IOCNUM_SET_REGISTER = 20,
@@ -278,10 +294,14 @@ enum {
_IOW('v', IOCNUM_SUSPEND, struct vm_suspend)
#define VM_REINIT \
_IO('v', IOCNUM_REINIT)
-#define VM_MAP_MEMORY \
- _IOWR('v', IOCNUM_MAP_MEMORY, struct vm_memory_segment)
-#define VM_GET_MEMORY_SEG \
- _IOWR('v', IOCNUM_GET_MEMORY_SEG, struct vm_memory_segment)
+#define VM_ALLOC_MEMSEG \
+ _IOW('v', IOCNUM_ALLOC_MEMSEG, struct vm_memseg)
+#define VM_GET_MEMSEG \
+ _IOWR('v', IOCNUM_GET_MEMSEG, struct vm_memseg)
+#define VM_MMAP_MEMSEG \
+ _IOW('v', IOCNUM_MMAP_MEMSEG, struct vm_memmap)
+#define VM_MMAP_GETNEXT \
+ _IOWR('v', IOCNUM_MMAP_GETNEXT, struct vm_memmap)
#define VM_SET_REGISTER \
_IOW('v', IOCNUM_SET_REGISTER, struct vm_register)
#define VM_GET_REGISTER \
diff --git a/sys/amd64/vmm/amd/svm.c b/sys/amd64/vmm/amd/svm.c
index b25d69d..6d44801 100644
--- a/sys/amd64/vmm/amd/svm.c
+++ b/sys/amd64/vmm/amd/svm.c
@@ -1477,7 +1477,7 @@ svm_vmexit(struct svm_softc *svm_sc, int vcpu, struct vm_exit *vmexit)
VCPU_CTR2(svm_sc->vm, vcpu, "nested page fault with "
"reserved bits set: info1(%#lx) info2(%#lx)",
info1, info2);
- } else if (vm_mem_allocated(svm_sc->vm, info2)) {
+ } else if (vm_mem_allocated(svm_sc->vm, vcpu, info2)) {
vmexit->exitcode = VM_EXITCODE_PAGING;
vmexit->u.paging.gpa = info2;
vmexit->u.paging.fault_type = npf_fault_type(info1);
diff --git a/sys/amd64/vmm/intel/vmx.c b/sys/amd64/vmm/intel/vmx.c
index f590586..517a374 100644
--- a/sys/amd64/vmm/intel/vmx.c
+++ b/sys/amd64/vmm/intel/vmx.c
@@ -2425,7 +2425,7 @@ vmx_exit_process(struct vmx *vmx, int vcpu, struct vm_exit *vmexit)
* this must be an instruction that accesses MMIO space.
*/
gpa = vmcs_gpa();
- if (vm_mem_allocated(vmx->vm, gpa) ||
+ if (vm_mem_allocated(vmx->vm, vcpu, gpa) ||
apic_access_fault(vmx, vcpu, gpa)) {
vmexit->exitcode = VM_EXITCODE_PAGING;
vmexit->inst_length = 0;
diff --git a/sys/amd64/vmm/io/ppt.c b/sys/amd64/vmm/io/ppt.c
index b789f77..692190a 100644
--- a/sys/amd64/vmm/io/ppt.c
+++ b/sys/amd64/vmm/io/ppt.c
@@ -76,11 +76,17 @@ struct pptintr_arg { /* pptintr(pptintr_arg) */
uint64_t msg_data;
};
+struct pptseg {
+ vm_paddr_t gpa;
+ size_t len;
+ int wired;
+};
+
struct pptdev {
device_t dev;
struct vm *vm; /* owner of this device */
TAILQ_ENTRY(pptdev) next;
- struct vm_memory_segment mmio[MAX_MMIOSEGS];
+ struct pptseg mmio[MAX_MMIOSEGS];
struct {
int num_msgs; /* guest state */
@@ -207,14 +213,14 @@ static void
ppt_unmap_mmio(struct vm *vm, struct pptdev *ppt)
{
int i;
- struct vm_memory_segment *seg;
+ struct pptseg *seg;
for (i = 0; i < MAX_MMIOSEGS; i++) {
seg = &ppt->mmio[i];
if (seg->len == 0)
continue;
(void)vm_unmap_mmio(vm, seg->gpa, seg->len);
- bzero(seg, sizeof(struct vm_memory_segment));
+ bzero(seg, sizeof(struct pptseg));
}
}
@@ -324,7 +330,7 @@ ppt_is_mmio(struct vm *vm, vm_paddr_t gpa)
{
int i;
struct pptdev *ppt;
- struct vm_memory_segment *seg;
+ struct pptseg *seg;
TAILQ_FOREACH(ppt, &pptdev_list, next) {
if (ppt->vm != vm)
@@ -410,7 +416,7 @@ ppt_map_mmio(struct vm *vm, int bus, int slot, int func,
vm_paddr_t gpa, size_t len, vm_paddr_t hpa)
{
int i, error;
- struct vm_memory_segment *seg;
+ struct pptseg *seg;
struct pptdev *ppt;
ppt = ppt_find(bus, slot, func);
diff --git a/sys/amd64/vmm/vmm.c b/sys/amd64/vmm/vmm.c
index 2c37a1a..0987059 100644
--- a/sys/amd64/vmm/vmm.c
+++ b/sys/amd64/vmm/vmm.c
@@ -119,12 +119,21 @@ struct vcpu {
#define vcpu_assert_locked(v) mtx_assert(&((v)->mtx), MA_OWNED)
struct mem_seg {
+ size_t len;
+ bool sysmem;
+ struct vm_object *object;
+};
+#define VM_MAX_MEMSEGS 2
+
+struct mem_map {
vm_paddr_t gpa;
size_t len;
- boolean_t wired;
- vm_object_t object;
+ vm_ooffset_t segoff;
+ int segid;
+ int prot;
+ int flags;
};
-#define VM_MAX_MEMORY_SEGMENTS 2
+#define VM_MAX_MEMMAPS 4
/*
* Initialization:
@@ -150,8 +159,8 @@ struct vm {
void *rendezvous_arg; /* (x) rendezvous func/arg */
vm_rendezvous_func_t rendezvous_func;
struct mtx rendezvous_mtx; /* (o) rendezvous lock */
- int num_mem_segs; /* (o) guest memory segments */
- struct mem_seg mem_segs[VM_MAX_MEMORY_SEGMENTS];
+ struct mem_map mem_maps[VM_MAX_MEMMAPS]; /* (i) guest address space */
+ struct mem_seg mem_segs[VM_MAX_MEMSEGS]; /* (o) guest memory regions */
struct vmspace *vmspace; /* (o) guest's address space */
char name[VM_MAX_NAMELEN]; /* (o) virtual machine name */
struct vcpu vcpu[VM_MAXCPU]; /* (i) guest vcpus */
@@ -222,6 +231,8 @@ TUNABLE_INT("hw.vmm.force_iommu", &vmm_force_iommu);
SYSCTL_INT(_hw_vmm, OID_AUTO, force_iommu, CTLFLAG_RDTUN, &vmm_force_iommu, 0,
"Force use of I/O MMU even if no passthrough devices were found.");
+static void vm_free_memmap(struct vm *vm, int ident);
+static bool sysmem_mapping(struct vm *vm, struct mem_map *mm);
static void vcpu_notify_event_locked(struct vcpu *vcpu, bool lapic_intr);
#ifdef KTR
@@ -442,7 +453,6 @@ vm_create(const char *name, struct vm **retvm)
vm = malloc(sizeof(struct vm), M_VM, M_WAITOK | M_ZERO);
strcpy(vm->name, name);
- vm->num_mem_segs = 0;
vm->vmspace = vmspace;
mtx_init(&vm->rendezvous_mtx, "vm rendezvous lock", 0, MTX_DEF);
@@ -453,18 +463,9 @@ vm_create(const char *name, struct vm **retvm)
}
static void
-vm_free_mem_seg(struct vm *vm, struct mem_seg *seg)
-{
-
- if (seg->object != NULL)
- vmm_mem_free(vm->vmspace, seg->gpa, seg->len);
-
- bzero(seg, sizeof(*seg));
-}
-
-static void
vm_cleanup(struct vm *vm, bool destroy)
{
+ struct mem_map *mm;
int i;
ppt_unassign_all(vm);
@@ -487,11 +488,23 @@ vm_cleanup(struct vm *vm, bool destroy)
VMCLEANUP(vm->cookie);
- if (destroy) {
- for (i = 0; i < vm->num_mem_segs; i++)
- vm_free_mem_seg(vm, &vm->mem_segs[i]);
+ /*
+ * System memory is removed from the guest address space only when
+ * the VM is destroyed. This is because the mapping remains the same
+ * across VM reset.
+ *
+ * Device memory can be relocated by the guest (e.g. using PCI BARs)
+ * so those mappings are removed on a VM reset.
+ */
+ for (i = 0; i < VM_MAX_MEMMAPS; i++) {
+ mm = &vm->mem_maps[i];
+ if (destroy || !sysmem_mapping(vm, mm))
+ vm_free_memmap(vm, i);
+ }
- vm->num_mem_segs = 0;
+ if (destroy) {
+ for (i = 0; i < VM_MAX_MEMSEGS; i++)
+ vm_free_memseg(vm, i);
VMSPACE_FREE(vm->vmspace);
vm->vmspace = NULL;
@@ -549,146 +562,243 @@ vm_unmap_mmio(struct vm *vm, vm_paddr_t gpa, size_t len)
return (0);
}
-boolean_t
-vm_mem_allocated(struct vm *vm, vm_paddr_t gpa)
+/*
+ * Return 'true' if 'gpa' is allocated in the guest address space.
+ *
+ * This function is called in the context of a running vcpu which acts as
+ * an implicit lock on 'vm->mem_maps[]'.
+ */
+bool
+vm_mem_allocated(struct vm *vm, int vcpuid, vm_paddr_t gpa)
{
+ struct mem_map *mm;
int i;
- vm_paddr_t gpabase, gpalimit;
- for (i = 0; i < vm->num_mem_segs; i++) {
- gpabase = vm->mem_segs[i].gpa;
- gpalimit = gpabase + vm->mem_segs[i].len;
- if (gpa >= gpabase && gpa < gpalimit)
- return (TRUE); /* 'gpa' is regular memory */
+#ifdef INVARIANTS
+ int hostcpu, state;
+ state = vcpu_get_state(vm, vcpuid, &hostcpu);
+ KASSERT(state == VCPU_RUNNING && hostcpu == curcpu,
+ ("%s: invalid vcpu state %d/%d", __func__, state, hostcpu));
+#endif
+
+ for (i = 0; i < VM_MAX_MEMMAPS; i++) {
+ mm = &vm->mem_maps[i];
+ if (mm->len != 0 && gpa >= mm->gpa && gpa < mm->gpa + mm->len)
+ return (true); /* 'gpa' is sysmem or devmem */
}
if (ppt_is_mmio(vm, gpa))
- return (TRUE); /* 'gpa' is pci passthru mmio */
+ return (true); /* 'gpa' is pci passthru mmio */
- return (FALSE);
+ return (false);
}
int
-vm_malloc(struct vm *vm, vm_paddr_t gpa, size_t len)
+vm_alloc_memseg(struct vm *vm, int ident, size_t len, bool sysmem)
{
- int available, allocated;
struct mem_seg *seg;
- vm_object_t object;
- vm_paddr_t g;
+ vm_object_t obj;
- if ((gpa & PAGE_MASK) || (len & PAGE_MASK) || len == 0)
+ if (ident < 0 || ident >= VM_MAX_MEMSEGS)
return (EINVAL);
-
- available = allocated = 0;
- g = gpa;
- while (g < gpa + len) {
- if (vm_mem_allocated(vm, g))
- allocated++;
- else
- available++;
- g += PAGE_SIZE;
- }
-
- /*
- * If there are some allocated and some available pages in the address
- * range then it is an error.
- */
- if (allocated && available)
+ if (len == 0 || (len & PAGE_MASK))
return (EINVAL);
- /*
- * If the entire address range being requested has already been
- * allocated then there isn't anything more to do.
- */
- if (allocated && available == 0)
- return (0);
-
- if (vm->num_mem_segs >= VM_MAX_MEMORY_SEGMENTS)
- return (E2BIG);
-
- seg = &vm->mem_segs[vm->num_mem_segs];
+ seg = &vm->mem_segs[ident];
+ if (seg->object != NULL) {
+ if (seg->len == len && seg->sysmem == sysmem)
+ return (EEXIST);
+ else
+ return (EINVAL);
+ }
- if ((object = vmm_mem_alloc(vm->vmspace, gpa, len)) == NULL)
+ obj = vm_object_allocate(OBJT_DEFAULT, len >> PAGE_SHIFT);
+ if (obj == NULL)
return (ENOMEM);
- seg->gpa = gpa;
seg->len = len;
- seg->object = object;
- seg->wired = FALSE;
+ seg->object = obj;
+ seg->sysmem = sysmem;
+ return (0);
+}
- vm->num_mem_segs++;
+int
+vm_get_memseg(struct vm *vm, int ident, size_t *len, bool *sysmem,
+ vm_object_t *objptr)
+{
+ struct mem_seg *seg;
+
+ if (ident < 0 || ident >= VM_MAX_MEMSEGS)
+ return (EINVAL);
+ seg = &vm->mem_segs[ident];
+ if (len)
+ *len = seg->len;
+ if (sysmem)
+ *sysmem = seg->sysmem;
+ if (objptr)
+ *objptr = seg->object;
return (0);
}
-static vm_paddr_t
-vm_maxmem(struct vm *vm)
+void
+vm_free_memseg(struct vm *vm, int ident)
{
- int i;
- vm_paddr_t gpa, maxmem;
+ struct mem_seg *seg;
- maxmem = 0;
- for (i = 0; i < vm->num_mem_segs; i++) {
- gpa = vm->mem_segs[i].gpa + vm->mem_segs[i].len;
- if (gpa > maxmem)
- maxmem = gpa;
+ KASSERT(ident >= 0 && ident < VM_MAX_MEMSEGS,
+ ("%s: invalid memseg ident %d", __func__, ident));
+
+ seg = &vm->mem_segs[ident];
+ if (seg->object != NULL) {
+ vm_object_deallocate(seg->object);
+ bzero(seg, sizeof(struct mem_seg));
}
- return (maxmem);
}
-static void
-vm_gpa_unwire(struct vm *vm)
+int
+vm_mmap_memseg(struct vm *vm, vm_paddr_t gpa, int segid, vm_ooffset_t first,
+ size_t len, int prot, int flags)
{
- int i, rv;
struct mem_seg *seg;
+ struct mem_map *m, *map;
+ vm_ooffset_t last;
+ int i, error;
- for (i = 0; i < vm->num_mem_segs; i++) {
- seg = &vm->mem_segs[i];
- if (!seg->wired)
- continue;
+ if (prot == 0 || (prot & ~(VM_PROT_ALL)) != 0)
+ return (EINVAL);
+
+ if (flags & ~VM_MEMMAP_F_WIRED)
+ return (EINVAL);
+
+ if (segid < 0 || segid >= VM_MAX_MEMSEGS)
+ return (EINVAL);
- rv = vm_map_unwire(&vm->vmspace->vm_map,
- seg->gpa, seg->gpa + seg->len,
- VM_MAP_WIRE_USER | VM_MAP_WIRE_NOHOLES);
- KASSERT(rv == KERN_SUCCESS, ("vm(%s) memory segment "
- "%#lx/%ld could not be unwired: %d",
- vm_name(vm), seg->gpa, seg->len, rv));
+ seg = &vm->mem_segs[segid];
+ if (seg->object == NULL)
+ return (EINVAL);
+
+ last = first + len;
+ if (first < 0 || first >= last || last > seg->len)
+ return (EINVAL);
+
+ if ((gpa | first | last) & PAGE_MASK)
+ return (EINVAL);
+
+ map = NULL;
+ for (i = 0; i < VM_MAX_MEMMAPS; i++) {
+ m = &vm->mem_maps[i];
+ if (m->len == 0) {
+ map = m;
+ break;
+ }
+ }
- seg->wired = FALSE;
+ if (map == NULL)
+ return (ENOSPC);
+
+ error = vm_map_find(&vm->vmspace->vm_map, seg->object, first, &gpa,
+ len, 0, VMFS_NO_SPACE, prot, prot, 0);
+ if (error != KERN_SUCCESS)
+ return (EFAULT);
+
+ vm_object_reference(seg->object);
+
+ if (flags & VM_MEMMAP_F_WIRED) {
+ error = vm_map_wire(&vm->vmspace->vm_map, gpa, gpa + len,
+ VM_MAP_WIRE_USER | VM_MAP_WIRE_NOHOLES);
+ if (error != KERN_SUCCESS) {
+ vm_map_remove(&vm->vmspace->vm_map, gpa, gpa + len);
+ return (EFAULT);
+ }
}
+
+ map->gpa = gpa;
+ map->len = len;
+ map->segoff = first;
+ map->segid = segid;
+ map->prot = prot;
+ map->flags = flags;
+ return (0);
}
-static int
-vm_gpa_wire(struct vm *vm)
+int
+vm_mmap_getnext(struct vm *vm, vm_paddr_t *gpa, int *segid,
+ vm_ooffset_t *segoff, size_t *len, int *prot, int *flags)
{
- int i, rv;
- struct mem_seg *seg;
+ struct mem_map *mm, *mmnext;
+ int i;
- for (i = 0; i < vm->num_mem_segs; i++) {
- seg = &vm->mem_segs[i];
- if (seg->wired)
+ mmnext = NULL;
+ for (i = 0; i < VM_MAX_MEMMAPS; i++) {
+ mm = &vm->mem_maps[i];
+ if (mm->len == 0 || mm->gpa < *gpa)
continue;
+ if (mmnext == NULL || mm->gpa < mmnext->gpa)
+ mmnext = mm;
+ }
- /* XXX rlimits? */
- rv = vm_map_wire(&vm->vmspace->vm_map,
- seg->gpa, seg->gpa + seg->len,
- VM_MAP_WIRE_USER | VM_MAP_WIRE_NOHOLES);
- if (rv != KERN_SUCCESS)
- break;
-
- seg->wired = TRUE;
+ if (mmnext != NULL) {
+ *gpa = mmnext->gpa;
+ if (segid)
+ *segid = mmnext->segid;
+ if (segoff)
+ *segoff = mmnext->segoff;
+ if (len)
+ *len = mmnext->len;
+ if (prot)
+ *prot = mmnext->prot;
+ if (flags)
+ *flags = mmnext->flags;
+ return (0);
+ } else {
+ return (ENOENT);
}
+}
- if (i < vm->num_mem_segs) {
- /*
- * Undo the wiring before returning an error.
- */
- vm_gpa_unwire(vm);
- return (EAGAIN);
+static void
+vm_free_memmap(struct vm *vm, int ident)
+{
+ struct mem_map *mm;
+ int error;
+
+ mm = &vm->mem_maps[ident];
+ if (mm->len) {
+ error = vm_map_remove(&vm->vmspace->vm_map, mm->gpa,
+ mm->gpa + mm->len);
+ KASSERT(error == KERN_SUCCESS, ("%s: vm_map_remove error %d",
+ __func__, error));
+ bzero(mm, sizeof(struct mem_map));
}
+}
- return (0);
+static __inline bool
+sysmem_mapping(struct vm *vm, struct mem_map *mm)
+{
+
+ if (mm->len != 0 && vm->mem_segs[mm->segid].sysmem)
+ return (true);
+ else
+ return (false);
+}
+
+static vm_paddr_t
+sysmem_maxaddr(struct vm *vm)
+{
+ struct mem_map *mm;
+ vm_paddr_t maxaddr;
+ int i;
+
+ maxaddr = 0;
+ for (i = 0; i < VM_MAX_MEMMAPS; i++) {
+ mm = &vm->mem_maps[i];
+ if (sysmem_mapping(vm, mm)) {
+ if (maxaddr < mm->gpa + mm->len)
+ maxaddr = mm->gpa + mm->len;
+ }
+ }
+ return (maxaddr);
}
static void
@@ -696,20 +806,36 @@ vm_iommu_modify(struct vm *vm, boolean_t map)
{
int i, sz;
vm_paddr_t gpa, hpa;
- struct mem_seg *seg;
+ struct mem_map *mm;
void *vp, *cookie, *host_domain;
sz = PAGE_SIZE;
host_domain = iommu_host_domain();
- for (i = 0; i < vm->num_mem_segs; i++) {
- seg = &vm->mem_segs[i];
- KASSERT(seg->wired, ("vm(%s) memory segment %#lx/%ld not wired",
- vm_name(vm), seg->gpa, seg->len));
+ for (i = 0; i < VM_MAX_MEMMAPS; i++) {
+ mm = &vm->mem_maps[i];
+ if (!sysmem_mapping(vm, mm))
+ continue;
- gpa = seg->gpa;
- while (gpa < seg->gpa + seg->len) {
- vp = vm_gpa_hold(vm, gpa, PAGE_SIZE, VM_PROT_WRITE,
+ if (map) {
+ KASSERT((mm->flags & VM_MEMMAP_F_IOMMU) == 0,
+ ("iommu map found invalid memmap %#lx/%#lx/%#x",
+ mm->gpa, mm->len, mm->flags));
+ if ((mm->flags & VM_MEMMAP_F_WIRED) == 0)
+ continue;
+ mm->flags |= VM_MEMMAP_F_IOMMU;
+ } else {
+ if ((mm->flags & VM_MEMMAP_F_IOMMU) == 0)
+ continue;
+ mm->flags &= ~VM_MEMMAP_F_IOMMU;
+ KASSERT((mm->flags & VM_MEMMAP_F_WIRED) != 0,
+ ("iommu unmap found invalid memmap %#lx/%#lx/%#x",
+ mm->gpa, mm->len, mm->flags));
+ }
+
+ gpa = mm->gpa;
+ while (gpa < mm->gpa + mm->len) {
+ vp = vm_gpa_hold(vm, -1, gpa, PAGE_SIZE, VM_PROT_WRITE,
&cookie);
KASSERT(vp != NULL, ("vm(%s) could not map gpa %#lx",
vm_name(vm), gpa));
@@ -751,10 +877,9 @@ vm_unassign_pptdev(struct vm *vm, int bus, int slot, int func)
if (error)
return (error);
- if (ppt_assigned_devices(vm) == 0) {
+ if (ppt_assigned_devices(vm) == 0)
vm_iommu_unmap(vm);
- vm_gpa_unwire(vm);
- }
+
return (0);
}
@@ -764,23 +889,12 @@ vm_assign_pptdev(struct vm *vm, int bus, int slot, int func)
int error;
vm_paddr_t maxaddr;
- /*
- * Virtual machines with pci passthru devices get special treatment:
- * - the guest physical memory is wired
- * - the iommu is programmed to do the 'gpa' to 'hpa' translation
- *
- * We need to do this before the first pci passthru device is attached.
- */
+ /* Set up the IOMMU to do the 'gpa' to 'hpa' translation */
if (ppt_assigned_devices(vm) == 0) {
KASSERT(vm->iommu == NULL,
("vm_assign_pptdev: iommu must be NULL"));
- maxaddr = vm_maxmem(vm);
+ maxaddr = sysmem_maxaddr(vm);
vm->iommu = iommu_create_domain(maxaddr);
-
- error = vm_gpa_wire(vm);
- if (error)
- return (error);
-
vm_iommu_map(vm);
}
@@ -789,18 +903,43 @@ vm_assign_pptdev(struct vm *vm, int bus, int slot, int func)
}
void *
-vm_gpa_hold(struct vm *vm, vm_paddr_t gpa, size_t len, int reqprot,
+vm_gpa_hold(struct vm *vm, int vcpuid, vm_paddr_t gpa, size_t len, int reqprot,
void **cookie)
{
- int count, pageoff;
+ int i, count, pageoff;
+ struct mem_map *mm;
vm_page_t m;
-
+#ifdef INVARIANTS
+ /*
+ * All vcpus are frozen by ioctls that modify the memory map
+ * (e.g. VM_MMAP_MEMSEG). Therefore 'vm->memmap[]' stability is
+ * guaranteed if at least one vcpu is in the VCPU_FROZEN state.
+ */
+ int state;
+ KASSERT(vcpuid >= -1 || vcpuid < VM_MAXCPU, ("%s: invalid vcpuid %d",
+ __func__, vcpuid));
+ for (i = 0; i < VM_MAXCPU; i++) {
+ if (vcpuid != -1 && vcpuid != i)
+ continue;
+ state = vcpu_get_state(vm, i, NULL);
+ KASSERT(state == VCPU_FROZEN, ("%s: invalid vcpu state %d",
+ __func__, state));
+ }
+#endif
pageoff = gpa & PAGE_MASK;
if (len > PAGE_SIZE - pageoff)
panic("vm_gpa_hold: invalid gpa/len: 0x%016lx/%lu", gpa, len);
- count = vm_fault_quick_hold_pages(&vm->vmspace->vm_map,
- trunc_page(gpa), PAGE_SIZE, reqprot, &m, 1);
+ count = 0;
+ for (i = 0; i < VM_MAX_MEMMAPS; i++) {
+ mm = &vm->mem_maps[i];
+ if (sysmem_mapping(vm, mm) && gpa >= mm->gpa &&
+ gpa < mm->gpa + mm->len) {
+ count = vm_fault_quick_hold_pages(&vm->vmspace->vm_map,
+ trunc_page(gpa), PAGE_SIZE, reqprot, &m, 1);
+ break;
+ }
+ }
if (count == 1) {
*cookie = m;
@@ -822,50 +961,6 @@ vm_gpa_release(void *cookie)
}
int
-vm_gpabase2memseg(struct vm *vm, vm_paddr_t gpabase,
- struct vm_memory_segment *seg)
-{
- int i;
-
- for (i = 0; i < vm->num_mem_segs; i++) {
- if (gpabase == vm->mem_segs[i].gpa) {
- seg->gpa = vm->mem_segs[i].gpa;
- seg->len = vm->mem_segs[i].len;
- seg->wired = vm->mem_segs[i].wired;
- return (0);
- }
- }
- return (-1);
-}
-
-int
-vm_get_memobj(struct vm *vm, vm_paddr_t gpa, size_t len,
- vm_offset_t *offset, struct vm_object **object)
-{
- int i;
- size_t seg_len;
- vm_paddr_t seg_gpa;
- vm_object_t seg_obj;
-
- for (i = 0; i < vm->num_mem_segs; i++) {
- if ((seg_obj = vm->mem_segs[i].object) == NULL)
- continue;
-
- seg_gpa = vm->mem_segs[i].gpa;
- seg_len = vm->mem_segs[i].len;
-
- if (gpa >= seg_gpa && gpa < seg_gpa + seg_len) {
- *offset = gpa - seg_gpa;
- *object = seg_obj;
- vm_object_reference(seg_obj);
- return (0);
- }
- }
-
- return (EINVAL);
-}
-
-int
vm_get_register(struct vm *vm, int vcpu, int reg, uint64_t *retval)
{
@@ -2423,8 +2518,8 @@ vm_copy_setup(struct vm *vm, int vcpuid, struct vm_guest_paging *paging,
}
for (idx = 0; idx < nused; idx++) {
- hva = vm_gpa_hold(vm, copyinfo[idx].gpa, copyinfo[idx].len,
- prot, &cookie);
+ hva = vm_gpa_hold(vm, vcpuid, copyinfo[idx].gpa,
+ copyinfo[idx].len, prot, &cookie);
if (hva == NULL)
break;
copyinfo[idx].hva = hva;
diff --git a/sys/amd64/vmm/vmm_dev.c b/sys/amd64/vmm/vmm_dev.c
index e3e140a..4ef1482 100644
--- a/sys/amd64/vmm/vmm_dev.c
+++ b/sys/amd64/vmm/vmm_dev.c
@@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$");
#include <vm/vm.h>
#include <vm/pmap.h>
#include <vm/vm_map.h>
+#include <vm/vm_object.h>
#include <machine/vmparam.h>
#include <machine/vmm.h>
@@ -60,10 +61,19 @@ __FBSDID("$FreeBSD$");
#include "io/vhpet.h"
#include "io/vrtc.h"
+struct devmem_softc {
+ int segid;
+ char *name;
+ struct cdev *cdev;
+ struct vmmdev_softc *sc;
+ SLIST_ENTRY(devmem_softc) link;
+};
+
struct vmmdev_softc {
struct vm *vm; /* vm instance cookie */
struct cdev *cdev;
SLIST_ENTRY(vmmdev_softc) link;
+ SLIST_HEAD(, devmem_softc) devmem;
int flags;
};
#define VSC_LINKED 0x01
@@ -76,6 +86,63 @@ static MALLOC_DEFINE(M_VMMDEV, "vmmdev", "vmmdev");
SYSCTL_DECL(_hw_vmm);
+static int devmem_create_cdev(const char *vmname, int id, char *devmem);
+static void devmem_destroy(void *arg);
+
+static int
+vcpu_lock_one(struct vmmdev_softc *sc, int vcpu)
+{
+ int error;
+
+ if (vcpu < 0 || vcpu >= VM_MAXCPU)
+ return (EINVAL);
+
+ error = vcpu_set_state(sc->vm, vcpu, VCPU_FROZEN, true);
+ return (error);
+}
+
+static void
+vcpu_unlock_one(struct vmmdev_softc *sc, int vcpu)
+{
+ enum vcpu_state state;
+
+ state = vcpu_get_state(sc->vm, vcpu, NULL);
+ if (state != VCPU_FROZEN) {
+ panic("vcpu %s(%d) has invalid state %d", vm_name(sc->vm),
+ vcpu, state);
+ }
+
+ vcpu_set_state(sc->vm, vcpu, VCPU_IDLE, false);
+}
+
+static int
+vcpu_lock_all(struct vmmdev_softc *sc)
+{
+ int error, vcpu;
+
+ for (vcpu = 0; vcpu < VM_MAXCPU; vcpu++) {
+ error = vcpu_lock_one(sc, vcpu);
+ if (error)
+ break;
+ }
+
+ if (error) {
+ while (--vcpu >= 0)
+ vcpu_unlock_one(sc, vcpu);
+ }
+
+ return (error);
+}
+
+static void
+vcpu_unlock_all(struct vmmdev_softc *sc)
+{
+ int vcpu;
+
+ for (vcpu = 0; vcpu < VM_MAXCPU; vcpu++)
+ vcpu_unlock_one(sc, vcpu);
+}
+
static struct vmmdev_softc *
vmmdev_lookup(const char *name)
{
@@ -108,12 +175,16 @@ vmmdev_rw(struct cdev *cdev, struct uio *uio, int flags)
void *hpa, *cookie;
struct vmmdev_softc *sc;
- static char zerobuf[PAGE_SIZE];
-
- error = 0;
sc = vmmdev_lookup2(cdev);
if (sc == NULL)
- error = ENXIO;
+ return (ENXIO);
+
+ /*
+ * Get a read lock on the guest memory map by freezing any vcpu.
+ */
+ error = vcpu_lock_one(sc, VM_MAXCPU - 1);
+ if (error)
+ return (error);
prot = (uio->uio_rw == UIO_WRITE ? VM_PROT_WRITE : VM_PROT_READ);
while (uio->uio_resid > 0 && error == 0) {
@@ -129,10 +200,11 @@ vmmdev_rw(struct cdev *cdev, struct uio *uio, int flags)
* Since this device does not support lseek(2), dd(1) will
* read(2) blocks of data to simulate the lseek(2).
*/
- hpa = vm_gpa_hold(sc->vm, gpa, c, prot, &cookie);
+ hpa = vm_gpa_hold(sc->vm, VM_MAXCPU - 1, gpa, c, prot, &cookie);
if (hpa == NULL) {
if (uio->uio_rw == UIO_READ)
- error = uiomove(zerobuf, c, uio);
+ error = uiomove(__DECONST(void *, zero_region),
+ c, uio);
else
error = EFAULT;
} else {
@@ -140,6 +212,70 @@ vmmdev_rw(struct cdev *cdev, struct uio *uio, int flags)
vm_gpa_release(cookie);
}
}
+ vcpu_unlock_one(sc, VM_MAXCPU - 1);
+ return (error);
+}
+
+CTASSERT(sizeof(((struct vm_memseg *)0)->name) >= SPECNAMELEN + 1);
+
+static int
+get_memseg(struct vmmdev_softc *sc, struct vm_memseg *mseg)
+{
+ struct devmem_softc *dsc;
+ int error;
+ bool sysmem;
+
+ error = vm_get_memseg(sc->vm, mseg->segid, &mseg->len, &sysmem, NULL);
+ if (error || mseg->len == 0)
+ return (error);
+
+ if (!sysmem) {
+ SLIST_FOREACH(dsc, &sc->devmem, link) {
+ if (dsc->segid == mseg->segid)
+ break;
+ }
+ KASSERT(dsc != NULL, ("%s: devmem segment %d not found",
+ __func__, mseg->segid));
+ error = copystr(dsc->name, mseg->name, SPECNAMELEN + 1, NULL);
+ } else {
+ bzero(mseg->name, sizeof(mseg->name));
+ }
+
+ return (error);
+}
+
+static int
+alloc_memseg(struct vmmdev_softc *sc, struct vm_memseg *mseg)
+{
+ char *name;
+ int error;
+ bool sysmem;
+
+ error = 0;
+ name = NULL;
+ sysmem = true;
+
+ if (VM_MEMSEG_NAME(mseg)) {
+ sysmem = false;
+ name = malloc(SPECNAMELEN + 1, M_VMMDEV, M_WAITOK);
+ error = copystr(VM_MEMSEG_NAME(mseg), name, SPECNAMELEN + 1, 0);
+ if (error)
+ goto done;
+ }
+
+ error = vm_alloc_memseg(sc->vm, mseg->segid, mseg->len, sysmem);
+ if (error)
+ goto done;
+
+ if (VM_MEMSEG_NAME(mseg)) {
+ error = devmem_create_cdev(vm_name(sc->vm), mseg->segid, name);
+ if (error)
+ vm_free_memseg(sc->vm, mseg->segid);
+ else
+ name = NULL; /* freed when 'cdev' is destroyed */
+ }
+done:
+ free(name, M_VMMDEV);
return (error);
}
@@ -150,7 +286,6 @@ vmmdev_ioctl(struct cdev *cdev, u_long cmd, caddr_t data, int fflag,
int error, vcpu, state_changed, size;
cpuset_t *cpuset;
struct vmmdev_softc *sc;
- struct vm_memory_segment *seg;
struct vm_register *vmreg;
struct vm_seg_desc *vmsegdesc;
struct vm_run *vmrun;
@@ -177,6 +312,7 @@ vmmdev_ioctl(struct cdev *cdev, u_long cmd, caddr_t data, int fflag,
struct vm_intinfo *vmii;
struct vm_rtc_time *rtctime;
struct vm_rtc_data *rtcdata;
+ struct vm_memmap *mm;
sc = vmmdev_lookup2(cdev);
if (sc == NULL)
@@ -211,43 +347,41 @@ vmmdev_ioctl(struct cdev *cdev, u_long cmd, caddr_t data, int fflag,
* Assumes that the first field of the ioctl data is the vcpu.
*/
vcpu = *(int *)data;
- if (vcpu < 0 || vcpu >= VM_MAXCPU) {
- error = EINVAL;
- goto done;
- }
-
- error = vcpu_set_state(sc->vm, vcpu, VCPU_FROZEN, true);
+ error = vcpu_lock_one(sc, vcpu);
if (error)
goto done;
-
state_changed = 1;
break;
case VM_MAP_PPTDEV_MMIO:
case VM_BIND_PPTDEV:
case VM_UNBIND_PPTDEV:
- case VM_MAP_MEMORY:
+ case VM_ALLOC_MEMSEG:
+ case VM_MMAP_MEMSEG:
case VM_REINIT:
/*
* ioctls that operate on the entire virtual machine must
* prevent all vcpus from running.
*/
- error = 0;
- for (vcpu = 0; vcpu < VM_MAXCPU; vcpu++) {
- error = vcpu_set_state(sc->vm, vcpu, VCPU_FROZEN, true);
- if (error)
- break;
- }
-
- if (error) {
- while (--vcpu >= 0)
- vcpu_set_state(sc->vm, vcpu, VCPU_IDLE, false);
+ error = vcpu_lock_all(sc);
+ if (error)
goto done;
- }
-
state_changed = 2;
break;
+ case VM_GET_MEMSEG:
+ case VM_MMAP_GETNEXT:
+ /*
+ * Lock a vcpu to make sure that the memory map cannot be
+ * modified while it is being inspected.
+ */
+ vcpu = VM_MAXCPU - 1;
+ error = vcpu_lock_one(sc, vcpu);
+ if (error)
+ goto done;
+ state_changed = 1;
+ break;
+
default:
break;
}
@@ -372,15 +506,21 @@ vmmdev_ioctl(struct cdev *cdev, u_long cmd, caddr_t data, int fflag,
error = vatpic_set_irq_trigger(sc->vm,
isa_irq_trigger->atpic_irq, isa_irq_trigger->trigger);
break;
- case VM_MAP_MEMORY:
- seg = (struct vm_memory_segment *)data;
- error = vm_malloc(sc->vm, seg->gpa, seg->len);
+ case VM_MMAP_GETNEXT:
+ mm = (struct vm_memmap *)data;
+ error = vm_mmap_getnext(sc->vm, &mm->gpa, &mm->segid,
+ &mm->segoff, &mm->len, &mm->prot, &mm->flags);
break;
- case VM_GET_MEMORY_SEG:
- seg = (struct vm_memory_segment *)data;
- seg->len = 0;
- (void)vm_gpabase2memseg(sc->vm, seg->gpa, seg);
- error = 0;
+ case VM_MMAP_MEMSEG:
+ mm = (struct vm_memmap *)data;
+ error = vm_mmap_memseg(sc->vm, mm->gpa, mm->segid, mm->segoff,
+ mm->len, mm->prot, mm->flags);
+ break;
+ case VM_ALLOC_MEMSEG:
+ error = alloc_memseg(sc, (struct vm_memseg *)data);
+ break;
+ case VM_GET_MEMSEG:
+ error = get_memseg(sc, (struct vm_memseg *)data);
break;
case VM_GET_REGISTER:
vmreg = (struct vm_register *)data;
@@ -505,12 +645,10 @@ vmmdev_ioctl(struct cdev *cdev, u_long cmd, caddr_t data, int fflag,
break;
}
- if (state_changed == 1) {
- vcpu_set_state(sc->vm, vcpu, VCPU_IDLE, false);
- } else if (state_changed == 2) {
- for (vcpu = 0; vcpu < VM_MAXCPU; vcpu++)
- vcpu_set_state(sc->vm, vcpu, VCPU_IDLE, false);
- }
+ if (state_changed == 1)
+ vcpu_unlock_one(sc, vcpu);
+ else if (state_changed == 2)
+ vcpu_unlock_all(sc);
done:
/* Make sure that no handler returns a bogus value like ERESTART */
@@ -519,26 +657,79 @@ done:
}
static int
-vmmdev_mmap_single(struct cdev *cdev, vm_ooffset_t *offset,
- vm_size_t size, struct vm_object **object, int nprot)
+vmmdev_mmap_single(struct cdev *cdev, vm_ooffset_t *offset, vm_size_t mapsize,
+ struct vm_object **objp, int nprot)
{
- int error;
struct vmmdev_softc *sc;
+ vm_paddr_t gpa;
+ size_t len;
+ vm_ooffset_t segoff, first, last;
+ int error, found, segid;
+ bool sysmem;
+
+ first = *offset;
+ last = first + mapsize;
+ if ((nprot & PROT_EXEC) || first < 0 || first >= last)
+ return (EINVAL);
sc = vmmdev_lookup2(cdev);
- if (sc != NULL && (nprot & PROT_EXEC) == 0)
- error = vm_get_memobj(sc->vm, *offset, size, offset, object);
- else
- error = EINVAL;
+ if (sc == NULL) {
+ /* virtual machine is in the process of being created */
+ return (EINVAL);
+ }
+ /*
+ * Get a read lock on the guest memory map by freezing any vcpu.
+ */
+ error = vcpu_lock_one(sc, VM_MAXCPU - 1);
+ if (error)
+ return (error);
+
+ gpa = 0;
+ found = 0;
+ while (!found) {
+ error = vm_mmap_getnext(sc->vm, &gpa, &segid, &segoff, &len,
+ NULL, NULL);
+ if (error)
+ break;
+
+ if (first >= gpa && last <= gpa + len)
+ found = 1;
+ else
+ gpa += len;
+ }
+
+ if (found) {
+ error = vm_get_memseg(sc->vm, segid, &len, &sysmem, objp);
+ KASSERT(error == 0 && *objp != NULL,
+ ("%s: invalid memory segment %d", __func__, segid));
+ if (sysmem) {
+ vm_object_reference(*objp);
+ *offset = segoff + (first - gpa);
+ } else {
+ error = EINVAL;
+ }
+ }
+ vcpu_unlock_one(sc, VM_MAXCPU - 1);
return (error);
}
static void
vmmdev_destroy(void *arg)
{
-
struct vmmdev_softc *sc = arg;
+ struct devmem_softc *dsc;
+ int error;
+
+ error = vcpu_lock_all(sc);
+ KASSERT(error == 0, ("%s: error %d freezing vcpus", __func__, error));
+
+ while ((dsc = SLIST_FIRST(&sc->devmem)) != NULL) {
+ KASSERT(dsc->cdev == NULL, ("%s: devmem not free", __func__));
+ SLIST_REMOVE_HEAD(&sc->devmem, link);
+ free(dsc->name, M_VMMDEV);
+ free(dsc, M_VMMDEV);
+ }
if (sc->cdev != NULL)
destroy_dev(sc->cdev);
@@ -560,6 +751,7 @@ sysctl_vmm_destroy(SYSCTL_HANDLER_ARGS)
{
int error;
char buf[VM_MAX_NAMELEN];
+ struct devmem_softc *dsc;
struct vmmdev_softc *sc;
struct cdev *cdev;
@@ -578,22 +770,30 @@ sysctl_vmm_destroy(SYSCTL_HANDLER_ARGS)
/*
* The 'cdev' will be destroyed asynchronously when 'si_threadcount'
* goes down to 0 so we should not do it again in the callback.
+ *
+ * Setting 'sc->cdev' to NULL is also used to indicate that the VM
+ * is scheduled for destruction.
*/
cdev = sc->cdev;
sc->cdev = NULL;
mtx_unlock(&vmmdev_mtx);
/*
- * Schedule the 'cdev' to be destroyed:
+ * Schedule all cdevs to be destroyed:
*
- * - any new operations on this 'cdev' will return an error (ENXIO).
+ * - any new operations on the 'cdev' will return an error (ENXIO).
*
* - when the 'si_threadcount' dwindles down to zero the 'cdev' will
* be destroyed and the callback will be invoked in a taskqueue
* context.
+ *
+ * - the 'devmem' cdevs are destroyed before the virtual machine 'cdev'
*/
+ SLIST_FOREACH(dsc, &sc->devmem, link) {
+ KASSERT(dsc->cdev != NULL, ("devmem cdev already destroyed"));
+ destroy_dev_sched_cb(dsc->cdev, devmem_destroy, dsc);
+ }
destroy_dev_sched_cb(cdev, vmmdev_destroy, sc);
-
return (0);
}
SYSCTL_PROC(_hw_vmm, OID_AUTO, destroy, CTLTYPE_STRING | CTLFLAG_RW,
@@ -634,6 +834,7 @@ sysctl_vmm_create(SYSCTL_HANDLER_ARGS)
sc = malloc(sizeof(struct vmmdev_softc), M_VMMDEV, M_WAITOK | M_ZERO);
sc->vm = vm;
+ SLIST_INIT(&sc->devmem);
/*
* Lookup the name again just in case somebody sneaked in when we
@@ -687,3 +888,96 @@ vmmdev_cleanup(void)
return (error);
}
+
+static int
+devmem_mmap_single(struct cdev *cdev, vm_ooffset_t *offset, vm_size_t len,
+ struct vm_object **objp, int nprot)
+{
+ struct devmem_softc *dsc;
+ vm_ooffset_t first, last;
+ size_t seglen;
+ int error;
+ bool sysmem;
+
+ dsc = cdev->si_drv1;
+ if (dsc == NULL) {
+ /* 'cdev' has been created but is not ready for use */
+ return (ENXIO);
+ }
+
+ first = *offset;
+ last = *offset + len;
+ if ((nprot & PROT_EXEC) || first < 0 || first >= last)
+ return (EINVAL);
+
+ error = vcpu_lock_one(dsc->sc, VM_MAXCPU - 1);
+ if (error)
+ return (error);
+
+ error = vm_get_memseg(dsc->sc->vm, dsc->segid, &seglen, &sysmem, objp);
+ KASSERT(error == 0 && !sysmem && *objp != NULL,
+ ("%s: invalid devmem segment %d", __func__, dsc->segid));
+
+ vcpu_unlock_one(dsc->sc, VM_MAXCPU - 1);
+
+ if (seglen >= last) {
+ vm_object_reference(*objp);
+ return (0);
+ } else {
+ return (EINVAL);
+ }
+}
+
+static struct cdevsw devmemsw = {
+ .d_name = "devmem",
+ .d_version = D_VERSION,
+ .d_mmap_single = devmem_mmap_single,
+};
+
+static int
+devmem_create_cdev(const char *vmname, int segid, char *devname)
+{
+ struct devmem_softc *dsc;
+ struct vmmdev_softc *sc;
+ struct cdev *cdev;
+ int error;
+
+ error = make_dev_p(MAKEDEV_CHECKNAME, &cdev, &devmemsw, NULL,
+ UID_ROOT, GID_WHEEL, 0600, "vmm/%s.%s", vmname, devname);
+ if (error)
+ return (error);
+
+ dsc = malloc(sizeof(struct devmem_softc), M_VMMDEV, M_WAITOK | M_ZERO);
+
+ mtx_lock(&vmmdev_mtx);
+ sc = vmmdev_lookup(vmname);
+ KASSERT(sc != NULL, ("%s: vm %s softc not found", __func__, vmname));
+ if (sc->cdev == NULL) {
+ /* virtual machine is being created or destroyed */
+ mtx_unlock(&vmmdev_mtx);
+ free(dsc, M_VMMDEV);
+ destroy_dev_sched_cb(cdev, NULL, 0);
+ return (ENODEV);
+ }
+
+ dsc->segid = segid;
+ dsc->name = devname;
+ dsc->cdev = cdev;
+ dsc->sc = sc;
+ SLIST_INSERT_HEAD(&sc->devmem, dsc, link);
+ mtx_unlock(&vmmdev_mtx);
+
+ /* The 'cdev' is ready for use after 'si_drv1' is initialized */
+ cdev->si_drv1 = dsc;
+ return (0);
+}
+
+static void
+devmem_destroy(void *arg)
+{
+ struct devmem_softc *dsc = arg;
+
+ KASSERT(dsc->cdev, ("%s: devmem cdev already destroyed", __func__));
+ dsc->cdev = NULL;
+ dsc->sc = NULL;
+}
diff --git a/sys/amd64/vmm/vmm_instruction_emul.c b/sys/amd64/vmm/vmm_instruction_emul.c
index 758b7e8..6dadcc1 100644
--- a/sys/amd64/vmm/vmm_instruction_emul.c
+++ b/sys/amd64/vmm/vmm_instruction_emul.c
@@ -1677,12 +1677,12 @@ ptp_release(void **cookie)
}
static void *
-ptp_hold(struct vm *vm, vm_paddr_t ptpphys, size_t len, void **cookie)
+ptp_hold(struct vm *vm, int vcpu, vm_paddr_t ptpphys, size_t len, void **cookie)
{
void *ptr;
ptp_release(cookie);
- ptr = vm_gpa_hold(vm, ptpphys, len, VM_PROT_RW, cookie);
+ ptr = vm_gpa_hold(vm, vcpu, ptpphys, len, VM_PROT_RW, cookie);
return (ptr);
}
@@ -1729,7 +1729,8 @@ restart:
/* Zero out the lower 12 bits. */
ptpphys &= ~0xfff;
- ptpbase32 = ptp_hold(vm, ptpphys, PAGE_SIZE, &cookie);
+ ptpbase32 = ptp_hold(vm, vcpuid, ptpphys, PAGE_SIZE,
+ &cookie);
if (ptpbase32 == NULL)
goto error;
@@ -1788,7 +1789,8 @@ restart:
/* Zero out the lower 5 bits and the upper 32 bits */
ptpphys &= 0xffffffe0UL;
- ptpbase = ptp_hold(vm, ptpphys, sizeof(*ptpbase) * 4, &cookie);
+ ptpbase = ptp_hold(vm, vcpuid, ptpphys, sizeof(*ptpbase) * 4,
+ &cookie);
if (ptpbase == NULL)
goto error;
@@ -1811,7 +1813,7 @@ restart:
/* Zero out the lower 12 bits and the upper 12 bits */
ptpphys >>= 12; ptpphys <<= 24; ptpphys >>= 12;
- ptpbase = ptp_hold(vm, ptpphys, PAGE_SIZE, &cookie);
+ ptpbase = ptp_hold(vm, vcpuid, ptpphys, PAGE_SIZE, &cookie);
if (ptpbase == NULL)
goto error;
diff --git a/sys/amd64/vmm/vmm_mem.c b/sys/amd64/vmm/vmm_mem.c
index 1019f2b..c9be6c9 100644
--- a/sys/amd64/vmm/vmm_mem.c
+++ b/sys/amd64/vmm/vmm_mem.c
@@ -114,38 +114,6 @@ vmm_mmio_free(struct vmspace *vmspace, vm_paddr_t gpa, size_t len)
vm_map_remove(&vmspace->vm_map, gpa, gpa + len);
}
-vm_object_t
-vmm_mem_alloc(struct vmspace *vmspace, vm_paddr_t gpa, size_t len)
-{
- int error;
- vm_object_t obj;
-
- if (gpa & PAGE_MASK)
- panic("vmm_mem_alloc: invalid gpa %#lx", gpa);
-
- if (len == 0 || (len & PAGE_MASK) != 0)
- panic("vmm_mem_alloc: invalid allocation size %lu", len);
-
- obj = vm_object_allocate(OBJT_DEFAULT, len >> PAGE_SHIFT);
- if (obj != NULL) {
- error = vm_map_find(&vmspace->vm_map, obj, 0, &gpa, len, 0,
- VMFS_NO_SPACE, VM_PROT_ALL, VM_PROT_ALL, 0);
- if (error != KERN_SUCCESS) {
- vm_object_deallocate(obj);
- obj = NULL;
- }
- }
-
- return (obj);
-}
-
-void
-vmm_mem_free(struct vmspace *vmspace, vm_paddr_t gpa, size_t len)
-{
-
- vm_map_remove(&vmspace->vm_map, gpa, gpa + len);
-}
-
vm_paddr_t
vmm_mem_maxaddr(void)
{
diff --git a/sys/amd64/vmm/vmm_mem.h b/sys/amd64/vmm/vmm_mem.h
index a375070..7773faa 100644
--- a/sys/amd64/vmm/vmm_mem.h
+++ b/sys/amd64/vmm/vmm_mem.h
@@ -33,10 +33,8 @@ struct vmspace;
struct vm_object;
int vmm_mem_init(void);
-struct vm_object *vmm_mem_alloc(struct vmspace *, vm_paddr_t gpa, size_t size);
struct vm_object *vmm_mmio_alloc(struct vmspace *, vm_paddr_t gpa, size_t len,
vm_paddr_t hpa);
-void vmm_mem_free(struct vmspace *, vm_paddr_t gpa, size_t size);
void vmm_mmio_free(struct vmspace *, vm_paddr_t gpa, size_t size);
vm_paddr_t vmm_mem_maxaddr(void);
diff --git a/sys/arm/conf/BEAGLEBONE b/sys/arm/conf/BEAGLEBONE
index 38c6b4a..8b06d20 100644
--- a/sys/arm/conf/BEAGLEBONE
+++ b/sys/arm/conf/BEAGLEBONE
@@ -138,3 +138,11 @@ device fdt_pinctrl
# Flattened Device Tree
options FDT # Configure using FDT/DTB data
+
+# Comment following lines for boot console on serial port
+device vt
+device videomode
+device hdmi
+device ums
+device ukbd
+device kbdmux
diff --git a/sys/arm/ti/am335x/am335x_lcd.c b/sys/arm/ti/am335x/am335x_lcd.c
index 501042a..1f38664 100644
--- a/sys/arm/ti/am335x/am335x_lcd.c
+++ b/sys/arm/ti/am335x/am335x_lcd.c
@@ -52,6 +52,10 @@ __FBSDID("$FreeBSD$");
#include <dev/ofw/ofw_bus.h>
#include <dev/ofw/ofw_bus_subr.h>
+#include <arm/ti/am335x/hdmi.h>
+#include <dev/videomode/videomode.h>
+#include <dev/videomode/edidvar.h>
+
#include <dev/fb/fbreg.h>
#ifdef DEV_SC
#include <dev/syscons/syscons.h>
@@ -66,6 +70,7 @@ __FBSDID("$FreeBSD$");
#include "am335x_pwm.h"
#include "fb_if.h"
+#include "hdmi_if.h"
#define LCD_PID 0x00
#define LCD_CTRL 0x04
@@ -176,11 +181,20 @@ __FBSDID("$FreeBSD$");
#define LCD_WRITE4(_sc, reg, value) \
bus_write_4((_sc)->sc_mem_res, reg, value);
-
/* Backlight is controlled by eCAS interface on PWM unit 0 */
#define PWM_UNIT 0
#define PWM_PERIOD 100
+#define MODE_HBP(mode) ((mode)->htotal - (mode)->hsync_end)
+#define MODE_HFP(mode) ((mode)->hsync_start - (mode)->hdisplay)
+#define MODE_HSW(mode) ((mode)->hsync_end - (mode)->hsync_start)
+#define MODE_VBP(mode) ((mode)->vtotal - (mode)->vsync_end)
+#define MODE_VFP(mode) ((mode)->vsync_start - (mode)->vdisplay)
+#define MODE_VSW(mode) ((mode)->vsync_end - (mode)->vsync_start)
+
+#define MAX_PIXEL_CLOCK 126000
+#define MAX_BANDWIDTH (1280*1024*60)
+
struct am335x_lcd_softc {
device_t sc_dev;
struct fb_info sc_fb_info;
@@ -191,12 +205,18 @@ struct am335x_lcd_softc {
int sc_backlight;
struct sysctl_oid *sc_oid;
+ struct panel_info sc_panel;
+
/* Framebuffer */
bus_dma_tag_t sc_dma_tag;
bus_dmamap_t sc_dma_map;
size_t sc_fb_size;
bus_addr_t sc_fb_phys;
uint8_t *sc_fb_base;
+
+ /* HDMI framer */
+ phandle_t sc_hdmi_framer;
+ eventhandler_tag sc_hdmi_evh;
};
static void
@@ -214,13 +234,22 @@ am335x_fb_dmamap_cb(void *arg, bus_dma_segment_t *segs, int nseg, int err)
static uint32_t
am335x_lcd_calc_divisor(uint32_t reference, uint32_t freq)
{
- uint32_t div;
+ uint32_t div, i;
+ uint32_t delta, min_delta;
+
+ min_delta = freq;
+ div = 255;
+
/* Raster mode case: divisors are in range from 2 to 255 */
- for (div = 2; div < 255; div++)
- if (reference/div <= freq)
- return (div);
+ for (i = 2; i < 255; i++) {
+ delta = abs(reference/i - freq);
+ if (delta < min_delta) {
+ div = i;
+ min_delta = delta;
+ }
+ }
- return (255);
+ return (div);
}
static int
@@ -229,7 +258,7 @@ am335x_lcd_sysctl_backlight(SYSCTL_HANDLER_ARGS)
struct am335x_lcd_softc *sc = (struct am335x_lcd_softc*)arg1;
int error;
int backlight;
-
+
backlight = sc->sc_backlight;
error = sysctl_handle_int(oidp, &backlight, 0, req);
@@ -251,6 +280,81 @@ am335x_lcd_sysctl_backlight(SYSCTL_HANDLER_ARGS)
return (error);
}
+static uint32_t
+am335x_mode_vrefresh(const struct videomode *mode)
+{
+ uint32_t refresh;
+
+ /* Calculate vertical refresh rate */
+ refresh = (mode->dot_clock * 1000 / mode->htotal);
+ refresh = (refresh + mode->vtotal / 2) / mode->vtotal;
+
+ if (mode->flags & VID_INTERLACE)
+ refresh *= 2;
+ if (mode->flags & VID_DBLSCAN)
+ refresh /= 2;
+
+ return refresh;
+}
+
+static int
+am335x_mode_is_valid(const struct videomode *mode)
+{
+ uint32_t hbp, hfp, hsw;
+ uint32_t vbp, vfp, vsw;
+
+ if (mode->dot_clock > MAX_PIXEL_CLOCK)
+ return (0);
+
+ if (mode->hdisplay & 0xf)
+ return (0);
+
+ if (mode->vdisplay > 2048)
+ return (0);
+
+ /* Check ranges for timing parameters */
+ hbp = MODE_HBP(mode) - 1;
+ hfp = MODE_HFP(mode) - 1;
+ hsw = MODE_HSW(mode) - 1;
+ vbp = MODE_VBP(mode);
+ vfp = MODE_VFP(mode);
+ vsw = MODE_VSW(mode) - 1;
+
+ if (hbp > 0x3ff)
+ return (0);
+ if (hfp > 0x3ff)
+ return (0);
+ if (hsw > 0x3ff)
+ return (0);
+
+ if (vbp > 0xff)
+ return (0);
+ if (vfp > 0xff)
+ return (0);
+ if (vsw > 0x3f)
+ return (0);
+ if (mode->vdisplay*mode->hdisplay*am335x_mode_vrefresh(mode)
+ > MAX_BANDWIDTH)
+ return (0);
+
+ return (1);
+}
+
+static void
+am335x_read_hdmi_property(device_t dev)
+{
+ phandle_t node;
+ phandle_t hdmi_xref;
+ struct am335x_lcd_softc *sc;
+
+ sc = device_get_softc(dev);
+ node = ofw_bus_get_node(dev);
+ if (OF_getencprop(node, "hdmi", &hdmi_xref, sizeof(hdmi_xref)) == -1)
+ sc->sc_hdmi_framer = 0;
+ else
+ sc->sc_hdmi_framer = hdmi_xref;
+}
+
static int
am335x_read_property(device_t dev, phandle_t node, const char *name, uint32_t *val)
{
@@ -343,44 +447,34 @@ out:
static int
am335x_read_panel_info(device_t dev, phandle_t node, struct panel_info *panel)
{
- int error;
phandle_t panel_info_node;
panel_info_node = ofw_bus_find_child(node, "panel-info");
if (panel_info_node == 0)
return (-1);
- error = 0;
-
- if ((error = am335x_read_property(dev, panel_info_node,
- "ac-bias", &panel->ac_bias)))
- goto out;
+ am335x_read_property(dev, panel_info_node,
+ "ac-bias", &panel->ac_bias);
- if ((error = am335x_read_property(dev, panel_info_node,
- "ac-bias-intrpt", &panel->ac_bias_intrpt)))
- goto out;
+ am335x_read_property(dev, panel_info_node,
+ "ac-bias-intrpt", &panel->ac_bias_intrpt);
- if ((error = am335x_read_property(dev, panel_info_node,
- "dma-burst-sz", &panel->dma_burst_sz)))
- goto out;
+ am335x_read_property(dev, panel_info_node,
+ "dma-burst-sz", &panel->dma_burst_sz);
- if ((error = am335x_read_property(dev, panel_info_node,
- "bpp", &panel->bpp)))
- goto out;
+ am335x_read_property(dev, panel_info_node,
+ "bpp", &panel->bpp);
- if ((error = am335x_read_property(dev, panel_info_node,
- "fdd", &panel->fdd)))
- goto out;
+ am335x_read_property(dev, panel_info_node,
+ "fdd", &panel->fdd);
- if ((error = am335x_read_property(dev, panel_info_node,
- "sync-edge", &panel->sync_edge)))
- goto out;
+ am335x_read_property(dev, panel_info_node,
+ "sync-edge", &panel->sync_edge);
- error = am335x_read_property(dev, panel_info_node,
+ am335x_read_property(dev, panel_info_node,
"sync-ctrl", &panel->sync_ctrl);
-out:
- return (error);
+ return (0);
}
static void
@@ -442,119 +536,75 @@ done:
reg = LCD_READ4(sc, LCD_END_OF_INT_IND);
}
-static int
-am335x_lcd_probe(device_t dev)
+static const struct videomode *
+am335x_lcd_pick_mode(struct edid_info *ei)
{
-#ifdef DEV_SC
- int err;
-#endif
-
- if (!ofw_bus_status_okay(dev))
- return (ENXIO);
+ const struct videomode *videomode;
+ const struct videomode *m;
+ int n;
- if (!ofw_bus_is_compatible(dev, "ti,am33xx-tilcdc"))
- return (ENXIO);
+ /* Get standard VGA as default */
+ videomode = NULL;
- device_set_desc(dev, "AM335x LCD controller");
+ /*
+ * Pick a mode.
+ */
+ if (ei->edid_preferred_mode != NULL) {
+ if (am335x_mode_is_valid(ei->edid_preferred_mode))
+ videomode = ei->edid_preferred_mode;
+ }
-#ifdef DEV_SC
- err = sc_probe_unit(device_get_unit(dev),
- device_get_flags(dev) | SC_AUTODETECT_KBD);
- if (err != 0)
- return (err);
-#endif
+ if (videomode == NULL) {
+ m = ei->edid_modes;
+
+ sort_modes(ei->edid_modes,
+ &ei->edid_preferred_mode,
+ ei->edid_nmodes);
+ for (n = 0; n < ei->edid_nmodes; n++)
+ if (am335x_mode_is_valid(&m[n])) {
+ videomode = &m[n];
+ break;
+ }
+ }
- return (BUS_PROBE_DEFAULT);
+ return videomode;
}
static int
-am335x_lcd_attach(device_t dev)
+am335x_lcd_configure(struct am335x_lcd_softc *sc)
{
- struct am335x_lcd_softc *sc;
- int rid;
int div;
- struct panel_info panel;
uint32_t reg, timing0, timing1, timing2;
- struct sysctl_ctx_list *ctx;
- struct sysctl_oid *tree;
uint32_t burst_log;
- int err;
size_t dma_size;
uint32_t hbp, hfp, hsw;
uint32_t vbp, vfp, vsw;
uint32_t width, height;
- phandle_t root, panel_node;
-
- sc = device_get_softc(dev);
- sc->sc_dev = dev;
-
- root = OF_finddevice("/");
- if (root == 0) {
- device_printf(dev, "failed to get FDT root node\n");
- return (ENXIO);
- }
-
- panel_node = fdt_find_compatible(root, "ti,tilcdc,panel", 1);
- if (panel_node == 0) {
- device_printf(dev, "failed to find compatible panel in FDT blob\n");
- return (ENXIO);
- }
-
- if (am335x_read_panel_info(dev, panel_node, &panel)) {
- device_printf(dev, "failed to read panel info\n");
- return (ENXIO);
- }
+ unsigned int ref_freq;
+ int err;
- if (am335x_read_timing(dev, panel_node, &panel)) {
- device_printf(dev, "failed to read timings\n");
+ /*
+ * try to adjust clock to get double of requested frequency
+ * HDMI/DVI displays are very sensitive to error in frequncy value
+ */
+ if (ti_prcm_clk_set_source_freq(LCDC_CLK, sc->sc_panel.panel_pxl_clk*2)) {
+ device_printf(sc->sc_dev, "can't set source frequency\n");
return (ENXIO);
}
- int ref_freq = 0;
- ti_prcm_clk_enable(LCDC_CLK);
if (ti_prcm_clk_get_source_freq(LCDC_CLK, &ref_freq)) {
- device_printf(dev, "Can't get reference frequency\n");
+ device_printf(sc->sc_dev, "can't get reference frequency\n");
return (ENXIO);
}
- rid = 0;
- sc->sc_mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid,
- RF_ACTIVE);
- if (!sc->sc_mem_res) {
- device_printf(dev, "cannot allocate memory window\n");
- return (ENXIO);
- }
-
- rid = 0;
- sc->sc_irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid,
- RF_ACTIVE);
- if (!sc->sc_irq_res) {
- bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->sc_mem_res);
- device_printf(dev, "cannot allocate interrupt\n");
- return (ENXIO);
- }
-
- if (bus_setup_intr(dev, sc->sc_irq_res, INTR_TYPE_MISC | INTR_MPSAFE,
- NULL, am335x_lcd_intr, sc,
- &sc->sc_intr_hl) != 0) {
- bus_release_resource(dev, SYS_RES_IRQ, rid,
- sc->sc_irq_res);
- bus_release_resource(dev, SYS_RES_MEMORY, rid,
- sc->sc_mem_res);
- device_printf(dev, "Unable to setup the irq handler.\n");
- return (ENXIO);
- }
-
- LCD_LOCK_INIT(sc);
-
/* Panle initialization */
- dma_size = round_page(panel.panel_width*panel.panel_height*panel.bpp/8);
+ dma_size = round_page(sc->sc_panel.panel_width*sc->sc_panel.panel_height*sc->sc_panel.bpp/8);
/*
* Now allocate framebuffer memory
*/
err = bus_dma_tag_create(
- bus_get_dma_tag(dev),
+ bus_get_dma_tag(sc->sc_dev),
4, 0, /* alignment, boundary */
BUS_SPACE_MAXADDR_32BIT, /* lowaddr */
BUS_SPACE_MAXADDR, /* highaddr */
@@ -564,49 +614,49 @@ am335x_lcd_attach(device_t dev)
NULL, NULL, /* lockfunc, lockarg */
&sc->sc_dma_tag);
if (err)
- goto fail;
+ goto done;
err = bus_dmamem_alloc(sc->sc_dma_tag, (void **)&sc->sc_fb_base,
BUS_DMA_COHERENT, &sc->sc_dma_map);
if (err) {
- device_printf(dev, "cannot allocate framebuffer\n");
- goto fail;
+ device_printf(sc->sc_dev, "cannot allocate framebuffer\n");
+ goto done;
}
err = bus_dmamap_load(sc->sc_dma_tag, sc->sc_dma_map, sc->sc_fb_base,
dma_size, am335x_fb_dmamap_cb, &sc->sc_fb_phys, BUS_DMA_NOWAIT);
if (err) {
- device_printf(dev, "cannot load DMA map\n");
- goto fail;
+ device_printf(sc->sc_dev, "cannot load DMA map\n");
+ goto done;
}
/* Make sure it's blank */
- memset(sc->sc_fb_base, 0x00, dma_size);
+ memset(sc->sc_fb_base, 0x0, dma_size);
/* Calculate actual FB Size */
- sc->sc_fb_size = panel.panel_width*panel.panel_height*panel.bpp/8;
+ sc->sc_fb_size = sc->sc_panel.panel_width*sc->sc_panel.panel_height*sc->sc_panel.bpp/8;
/* Only raster mode is supported */
reg = CTRL_RASTER_MODE;
- div = am335x_lcd_calc_divisor(ref_freq, panel.panel_pxl_clk);
+ div = am335x_lcd_calc_divisor(ref_freq, sc->sc_panel.panel_pxl_clk);
reg |= (div << CTRL_DIV_SHIFT);
LCD_WRITE4(sc, LCD_CTRL, reg);
/* Set timing */
timing0 = timing1 = timing2 = 0;
- hbp = panel.panel_hbp - 1;
- hfp = panel.panel_hfp - 1;
- hsw = panel.panel_hsw - 1;
+ hbp = sc->sc_panel.panel_hbp - 1;
+ hfp = sc->sc_panel.panel_hfp - 1;
+ hsw = sc->sc_panel.panel_hsw - 1;
- vbp = panel.panel_vbp;
- vfp = panel.panel_vfp;
- vsw = panel.panel_vsw - 1;
+ vbp = sc->sc_panel.panel_vbp;
+ vfp = sc->sc_panel.panel_vfp;
+ vsw = sc->sc_panel.panel_vsw - 1;
- height = panel.panel_height - 1;
- width = panel.panel_width - 1;
+ height = sc->sc_panel.panel_height - 1;
+ width = sc->sc_panel.panel_width - 1;
/* Horizontal back porch */
timing0 |= (hbp & 0xff) << RASTER_TIMING_0_HBP_SHIFT;
@@ -636,22 +686,22 @@ am335x_lcd_attach(device_t dev)
<< RASTER_TIMING_2_LPP_B10_SHIFT;
/* clock signal settings */
- if (panel.sync_ctrl)
+ if (sc->sc_panel.sync_ctrl)
timing2 |= RASTER_TIMING_2_PHSVS;
- if (panel.sync_edge)
+ if (sc->sc_panel.sync_edge)
timing2 |= RASTER_TIMING_2_PHSVS_RISE;
else
timing2 |= RASTER_TIMING_2_PHSVS_FALL;
- if (panel.hsync_active == 0)
+ if (sc->sc_panel.hsync_active == 0)
timing2 |= RASTER_TIMING_2_IHS;
- if (panel.vsync_active == 0)
+ if (sc->sc_panel.vsync_active == 0)
timing2 |= RASTER_TIMING_2_IVS;
- if (panel.pixelclk_active == 0)
+ if (sc->sc_panel.pixelclk_active == 0)
timing2 |= RASTER_TIMING_2_IPC;
/* AC bias */
- timing2 |= (panel.ac_bias << RASTER_TIMING_2_ACB_SHIFT);
- timing2 |= (panel.ac_bias_intrpt << RASTER_TIMING_2_ACBI_SHIFT);
+ timing2 |= (sc->sc_panel.ac_bias << RASTER_TIMING_2_ACB_SHIFT);
+ timing2 |= (sc->sc_panel.ac_bias_intrpt << RASTER_TIMING_2_ACBI_SHIFT);
LCD_WRITE4(sc, LCD_RASTER_TIMING_0, timing0);
LCD_WRITE4(sc, LCD_RASTER_TIMING_1, timing1);
@@ -660,7 +710,7 @@ am335x_lcd_attach(device_t dev)
/* DMA settings */
reg = LCDDMA_CTRL_FB0_FB1;
/* Find power of 2 for current burst size */
- switch (panel.dma_burst_sz) {
+ switch (sc->sc_panel.dma_burst_sz) {
case 1:
burst_log = 0;
break;
@@ -690,11 +740,11 @@ am335x_lcd_attach(device_t dev)
/* Enable LCD */
reg = RASTER_CTRL_LCDTFT;
- reg |= (panel.fdd << RASTER_CTRL_REQDLY_SHIFT);
+ reg |= (sc->sc_panel.fdd << RASTER_CTRL_REQDLY_SHIFT);
reg |= (PALETTE_DATA_ONLY << RASTER_CTRL_PALMODE_SHIFT);
- if (panel.bpp >= 24)
+ if (sc->sc_panel.bpp >= 24)
reg |= RASTER_CTRL_TFT24;
- if (panel.bpp == 32)
+ if (sc->sc_panel.bpp == 32)
reg |= RASTER_CTRL_TFT24_UNPACKED;
LCD_WRITE4(sc, LCD_RASTER_CTRL, reg);
@@ -717,54 +767,241 @@ am335x_lcd_attach(device_t dev)
LCD_WRITE4(sc, LCD_SYSCONFIG,
SYSCONFIG_STANDBY_SMART | SYSCONFIG_IDLE_SMART);
- /* Init backlight interface */
- ctx = device_get_sysctl_ctx(sc->sc_dev);
- tree = device_get_sysctl_tree(sc->sc_dev);
- sc->sc_oid = SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
- "backlight", CTLTYPE_INT | CTLFLAG_RW, sc, 0,
- am335x_lcd_sysctl_backlight, "I", "LCD backlight");
- sc->sc_backlight = 0;
- /* Check if eCAS interface is available at this point */
- if (am335x_pwm_config_ecap(PWM_UNIT,
- PWM_PERIOD, PWM_PERIOD) == 0)
- sc->sc_backlight = 100;
-
sc->sc_fb_info.fb_name = device_get_nameunit(sc->sc_dev);
sc->sc_fb_info.fb_vbase = (intptr_t)sc->sc_fb_base;
sc->sc_fb_info.fb_pbase = sc->sc_fb_phys;
sc->sc_fb_info.fb_size = sc->sc_fb_size;
- sc->sc_fb_info.fb_bpp = sc->sc_fb_info.fb_depth = panel.bpp;
- sc->sc_fb_info.fb_stride = panel.panel_width*panel.bpp / 8;
- sc->sc_fb_info.fb_width = panel.panel_width;
- sc->sc_fb_info.fb_height = panel.panel_height;
+ sc->sc_fb_info.fb_bpp = sc->sc_fb_info.fb_depth = sc->sc_panel.bpp;
+ sc->sc_fb_info.fb_stride = sc->sc_panel.panel_width*sc->sc_panel.bpp / 8;
+ sc->sc_fb_info.fb_width = sc->sc_panel.panel_width;
+ sc->sc_fb_info.fb_height = sc->sc_panel.panel_height;
#ifdef DEV_SC
- err = (sc_attach_unit(device_get_unit(dev),
- device_get_flags(dev) | SC_AUTODETECT_KBD));
+ err = (sc_attach_unit(device_get_unit(sc->sc_dev),
+ device_get_flags(sc->sc_dev) | SC_AUTODETECT_KBD));
if (err) {
- device_printf(dev, "failed to attach syscons\n");
+ device_printf(sc->sc_dev, "failed to attach syscons\n");
goto fail;
}
am335x_lcd_syscons_setup((vm_offset_t)sc->sc_fb_base, sc->sc_fb_phys, &panel);
#else /* VT */
- device_t fbd = device_add_child(dev, "fbd",
- device_get_unit(dev));
- if (fbd == NULL) {
- device_printf(dev, "Failed to add fbd child\n");
- goto fail;
+ device_t fbd = device_add_child(sc->sc_dev, "fbd",
+ device_get_unit(sc->sc_dev));
+ if (fbd != NULL) {
+ if (device_probe_and_attach(fbd) != 0)
+ device_printf(sc->sc_dev, "failed to attach fbd device\n");
+ } else
+ device_printf(sc->sc_dev, "failed to add fbd child\n");
+#endif
+
+done:
+ return (err);
+}
+
+static void
+am335x_lcd_hdmi_event(void *arg)
+{
+ struct am335x_lcd_softc *sc;
+ const struct videomode *videomode;
+ struct videomode hdmi_mode;
+ device_t hdmi_dev;
+ uint8_t *edid;
+ uint32_t edid_len;
+ struct edid_info ei;
+
+ sc = arg;
+
+ /* Nothing to work with */
+ if (!sc->sc_hdmi_framer) {
+ device_printf(sc->sc_dev, "HDMI event without HDMI framer set\n");
+ return;
}
- if (device_probe_and_attach(fbd) != 0) {
- device_printf(dev, "Failed to attach fbd device\n");
- goto fail;
+
+ hdmi_dev = OF_device_from_xref(sc->sc_hdmi_framer);
+ if (!hdmi_dev) {
+ device_printf(sc->sc_dev, "no actual device for \"hdmi\" property\n");
+ return;
}
+
+ edid = NULL;
+ edid_len = 0;
+ if (HDMI_GET_EDID(hdmi_dev, &edid, &edid_len) != 0) {
+ device_printf(sc->sc_dev, "failed to get EDID info from HDMI framer\n");
+ return;
+ }
+
+ videomode = NULL;
+
+ if (edid_parse(edid, &ei) == 0) {
+ edid_print(&ei);
+ videomode = am335x_lcd_pick_mode(&ei);
+ } else
+ device_printf(sc->sc_dev, "failed to parse EDID\n");
+
+ /* Use standard VGA as fallback */
+ if (videomode == NULL)
+ videomode = pick_mode_by_ref(640, 480, 60);
+
+ if (videomode == NULL) {
+ device_printf(sc->sc_dev, "failed to find usable videomode");
+ return;
+ }
+
+ device_printf(sc->sc_dev, "detected videomode: %dx%d @ %dKHz\n", videomode->hdisplay,
+ videomode->vdisplay, am335x_mode_vrefresh(videomode));
+
+ sc->sc_panel.panel_width = videomode->hdisplay;
+ sc->sc_panel.panel_height = videomode->vdisplay;
+ sc->sc_panel.panel_hfp = videomode->hsync_start - videomode->hdisplay;
+ sc->sc_panel.panel_hbp = videomode->htotal - videomode->hsync_end;
+ sc->sc_panel.panel_hsw = videomode->hsync_end - videomode->hsync_start;
+ sc->sc_panel.panel_vfp = videomode->vsync_start - videomode->vdisplay;
+ sc->sc_panel.panel_vbp = videomode->vtotal - videomode->vsync_end;
+ sc->sc_panel.panel_vsw = videomode->vsync_end - videomode->vsync_start;
+ sc->sc_panel.pixelclk_active = 1;
+
+ /* logic for HSYNC should be reversed */
+ if (videomode->flags & VID_NHSYNC)
+ sc->sc_panel.hsync_active = 1;
+ else
+ sc->sc_panel.hsync_active = 0;
+
+ if (videomode->flags & VID_NVSYNC)
+ sc->sc_panel.vsync_active = 0;
+ else
+ sc->sc_panel.vsync_active = 1;
+
+ sc->sc_panel.panel_pxl_clk = videomode->dot_clock * 1000;
+
+ am335x_lcd_configure(sc);
+
+ memcpy(&hdmi_mode, videomode, sizeof(hdmi_mode));
+ hdmi_mode.hskew = videomode->hsync_end - videomode->hsync_start;
+ hdmi_mode.flags |= VID_HSKEW;
+
+ HDMI_SET_VIDEOMODE(hdmi_dev, &hdmi_mode);
+}
+
+static int
+am335x_lcd_probe(device_t dev)
+{
+#ifdef DEV_SC
+ int err;
#endif
- return (0);
+ if (!ofw_bus_status_okay(dev))
+ return (ENXIO);
-fail:
- return (err);
+ if (!ofw_bus_is_compatible(dev, "ti,am33xx-tilcdc"))
+ return (ENXIO);
+
+ device_set_desc(dev, "AM335x LCD controller");
+
+#ifdef DEV_SC
+ err = sc_probe_unit(device_get_unit(dev),
+ device_get_flags(dev) | SC_AUTODETECT_KBD);
+ if (err != 0)
+ return (err);
+#endif
+
+ return (BUS_PROBE_DEFAULT);
+}
+
+static int
+am335x_lcd_attach(device_t dev)
+{
+ struct am335x_lcd_softc *sc;
+
+ int err;
+ int rid;
+ struct sysctl_ctx_list *ctx;
+ struct sysctl_oid *tree;
+ phandle_t root, panel_node;
+
+ err = 0;
+ sc = device_get_softc(dev);
+ sc->sc_dev = dev;
+
+ am335x_read_hdmi_property(dev);
+
+ root = OF_finddevice("/");
+ if (root == 0) {
+ device_printf(dev, "failed to get FDT root node\n");
+ return (ENXIO);
+ }
+
+ sc->sc_panel.ac_bias = 255;
+ sc->sc_panel.ac_bias_intrpt = 0;
+ sc->sc_panel.dma_burst_sz = 16;
+ sc->sc_panel.bpp = 16;
+ sc->sc_panel.fdd = 128;
+ sc->sc_panel.sync_edge = 0;
+ sc->sc_panel.sync_ctrl = 1;
+
+ panel_node = fdt_find_compatible(root, "ti,tilcdc,panel", 1);
+ if (panel_node != 0) {
+ device_printf(dev, "using static panel info\n");
+ if (am335x_read_panel_info(dev, panel_node, &sc->sc_panel)) {
+ device_printf(dev, "failed to read panel info\n");
+ return (ENXIO);
+ }
+
+ if (am335x_read_timing(dev, panel_node, &sc->sc_panel)) {
+ device_printf(dev, "failed to read timings\n");
+ return (ENXIO);
+ }
+ }
+
+ ti_prcm_clk_enable(LCDC_CLK);
+
+ rid = 0;
+ sc->sc_mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid,
+ RF_ACTIVE);
+ if (!sc->sc_mem_res) {
+ device_printf(dev, "cannot allocate memory window\n");
+ return (ENXIO);
+ }
+
+ rid = 0;
+ sc->sc_irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid,
+ RF_ACTIVE);
+ if (!sc->sc_irq_res) {
+ bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->sc_mem_res);
+ device_printf(dev, "cannot allocate interrupt\n");
+ return (ENXIO);
+ }
+
+ if (bus_setup_intr(dev, sc->sc_irq_res, INTR_TYPE_MISC | INTR_MPSAFE,
+ NULL, am335x_lcd_intr, sc,
+ &sc->sc_intr_hl) != 0) {
+ bus_release_resource(dev, SYS_RES_IRQ, rid,
+ sc->sc_irq_res);
+ bus_release_resource(dev, SYS_RES_MEMORY, rid,
+ sc->sc_mem_res);
+ device_printf(dev, "Unable to setup the irq handler.\n");
+ return (ENXIO);
+ }
+
+ LCD_LOCK_INIT(sc);
+
+ /* Init backlight interface */
+ ctx = device_get_sysctl_ctx(sc->sc_dev);
+ tree = device_get_sysctl_tree(sc->sc_dev);
+ sc->sc_oid = SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
+ "backlight", CTLTYPE_INT | CTLFLAG_RW, sc, 0,
+ am335x_lcd_sysctl_backlight, "I", "LCD backlight");
+ sc->sc_backlight = 0;
+ /* Check if eCAS interface is available at this point */
+ if (am335x_pwm_config_ecap(PWM_UNIT,
+ PWM_PERIOD, PWM_PERIOD) == 0)
+ sc->sc_backlight = 100;
+
+ sc->sc_hdmi_evh = EVENTHANDLER_REGISTER(hdmi_event,
+ am335x_lcd_hdmi_event, sc, 0);
+
+ return (0);
}
static int
diff --git a/sys/arm/ti/am335x/am335x_lcd.h b/sys/arm/ti/am335x/am335x_lcd.h
index e3c82db..ed0779f 100644
--- a/sys/arm/ti/am335x/am335x_lcd.h
+++ b/sys/arm/ti/am335x/am335x_lcd.h
@@ -29,6 +29,7 @@
#define __AM335X_LCD_H__
struct panel_info {
+ /* Timing part */
uint32_t panel_width;
uint32_t panel_height;
uint32_t panel_hfp;
@@ -37,16 +38,17 @@ struct panel_info {
uint32_t panel_vfp;
uint32_t panel_vbp;
uint32_t panel_vsw;
+ uint32_t hsync_active;
+ uint32_t vsync_active;
+ uint32_t panel_pxl_clk;
+
uint32_t ac_bias;
uint32_t ac_bias_intrpt;
uint32_t dma_burst_sz;
uint32_t bpp;
uint32_t fdd;
- uint32_t hsync_active;
- uint32_t vsync_active;
uint32_t sync_edge;
uint32_t sync_ctrl;
- uint32_t panel_pxl_clk;
uint32_t pixelclk_active;
};
diff --git a/sys/arm/ti/am335x/am335x_prcm.c b/sys/arm/ti/am335x/am335x_prcm.c
index fa47f63..69fa6e2 100644
--- a/sys/arm/ti/am335x/am335x_prcm.c
+++ b/sys/arm/ti/am335x/am335x_prcm.c
@@ -151,6 +151,7 @@ static int am335x_clk_hsmmc_get_source_freq(struct ti_clock_dev *clkdev, unsign
static int am335x_clk_get_sysclk_freq(struct ti_clock_dev *clkdev, unsigned int *freq);
static int am335x_clk_get_arm_fclk_freq(struct ti_clock_dev *clkdev, unsigned int *freq);
static int am335x_clk_get_arm_disp_freq(struct ti_clock_dev *clkdev, unsigned int *freq);
+static int am335x_clk_set_arm_disp_freq(struct ti_clock_dev *clkdev, unsigned int freq);
static void am335x_prcm_reset(void);
static int am335x_clk_cpsw_activate(struct ti_clock_dev *clkdev);
static int am335x_clk_musb0_activate(struct ti_clock_dev *clkdev);
@@ -163,7 +164,8 @@ static int am335x_clk_pruss_activate(struct ti_clock_dev *clkdev);
.clk_deactivate = am335x_clk_noop_deactivate, \
.clk_set_source = am335x_clk_noop_set_source, \
.clk_accessible = NULL, \
- .clk_get_source_freq = NULL \
+ .clk_get_source_freq = NULL, \
+ .clk_set_source_freq = NULL \
}
#define AM335X_GENERIC_CLOCK_DEV(i) \
@@ -172,7 +174,8 @@ static int am335x_clk_pruss_activate(struct ti_clock_dev *clkdev);
.clk_deactivate = am335x_clk_generic_deactivate, \
.clk_set_source = am335x_clk_generic_set_source, \
.clk_accessible = NULL, \
- .clk_get_source_freq = NULL \
+ .clk_get_source_freq = NULL, \
+ .clk_set_source_freq = NULL \
}
#define AM335X_GPIO_CLOCK_DEV(i) \
@@ -181,7 +184,8 @@ static int am335x_clk_pruss_activate(struct ti_clock_dev *clkdev);
.clk_deactivate = am335x_clk_generic_deactivate, \
.clk_set_source = am335x_clk_generic_set_source, \
.clk_accessible = NULL, \
- .clk_get_source_freq = NULL \
+ .clk_get_source_freq = NULL, \
+ .clk_set_source_freq = NULL \
}
#define AM335X_MMCHS_CLOCK_DEV(i) \
@@ -190,7 +194,8 @@ static int am335x_clk_pruss_activate(struct ti_clock_dev *clkdev);
.clk_deactivate = am335x_clk_generic_deactivate, \
.clk_set_source = am335x_clk_generic_set_source, \
.clk_accessible = NULL, \
- .clk_get_source_freq = am335x_clk_hsmmc_get_source_freq \
+ .clk_get_source_freq = am335x_clk_hsmmc_get_source_freq, \
+ .clk_set_source_freq = NULL \
}
struct ti_clock_dev ti_am335x_clk_devmap[] = {
@@ -201,6 +206,7 @@ struct ti_clock_dev ti_am335x_clk_devmap[] = {
.clk_set_source = NULL,
.clk_accessible = NULL,
.clk_get_source_freq = am335x_clk_get_sysclk_freq,
+ .clk_set_source_freq = NULL,
},
/* MPU (ARM) core clocks */
{ .id = MPU_CLK,
@@ -209,6 +215,7 @@ struct ti_clock_dev ti_am335x_clk_devmap[] = {
.clk_set_source = NULL,
.clk_accessible = NULL,
.clk_get_source_freq = am335x_clk_get_arm_fclk_freq,
+ .clk_set_source_freq = NULL,
},
/* CPSW Ethernet Switch core clocks */
{ .id = CPSW_CLK,
@@ -217,6 +224,7 @@ struct ti_clock_dev ti_am335x_clk_devmap[] = {
.clk_set_source = NULL,
.clk_accessible = NULL,
.clk_get_source_freq = NULL,
+ .clk_set_source_freq = NULL,
},
/* Mentor USB HS controller core clocks */
@@ -226,6 +234,7 @@ struct ti_clock_dev ti_am335x_clk_devmap[] = {
.clk_set_source = NULL,
.clk_accessible = NULL,
.clk_get_source_freq = NULL,
+ .clk_set_source_freq = NULL,
},
/* LCD controller clocks */
@@ -235,6 +244,7 @@ struct ti_clock_dev ti_am335x_clk_devmap[] = {
.clk_set_source = NULL,
.clk_accessible = NULL,
.clk_get_source_freq = am335x_clk_get_arm_disp_freq,
+ .clk_set_source_freq = am335x_clk_set_arm_disp_freq,
},
/* UART */
@@ -296,6 +306,7 @@ struct ti_clock_dev ti_am335x_clk_devmap[] = {
.clk_set_source = NULL,
.clk_accessible = NULL,
.clk_get_source_freq = NULL,
+ .clk_set_source_freq = NULL,
},
/* RTC */
@@ -627,6 +638,8 @@ am335x_clk_get_sysclk_freq(struct ti_clock_dev *clkdev, unsigned int *freq)
#define DPLL_BYP_CLKSEL(reg) ((reg>>23) & 1)
#define DPLL_DIV(reg) ((reg & 0x7f)+1)
#define DPLL_MULT(reg) ((reg>>8) & 0x7FF)
+#define DPLL_MAX_MUL 0x800
+#define DPLL_MAX_DIV 0x80
static int
am335x_clk_get_arm_fclk_freq(struct ti_clock_dev *clkdev, unsigned int *freq)
@@ -662,6 +675,52 @@ am335x_clk_get_arm_disp_freq(struct ti_clock_dev *clkdev, unsigned int *freq)
return(0);
}
+static int
+am335x_clk_set_arm_disp_freq(struct ti_clock_dev *clkdev, unsigned int freq)
+{
+ uint32_t sysclk;
+ uint32_t mul, div;
+ uint32_t i, j;
+ unsigned int delta, min_delta;
+
+ am335x_clk_get_sysclk_freq(NULL, &sysclk);
+
+ /* Bypass mode */
+ prcm_write_4(CM_WKUP_CM_CLKMODE_DPLL_DISP, 0x4);
+
+ /* Make sure it's in bypass mode */
+ while (!(prcm_read_4(CM_WKUP_CM_IDLEST_DPLL_DISP)
+ & (1 << 8)))
+ DELAY(10);
+
+ /* Dumb and non-optimal implementation */
+ min_delta = freq;
+ for (i = 1; i < DPLL_MAX_MUL; i++) {
+ for (j = 1; j < DPLL_MAX_DIV; j++) {
+ delta = abs(freq - i*(sysclk/j));
+ if (delta < min_delta) {
+ mul = i;
+ div = j;
+ min_delta = delta;
+ }
+ if (min_delta == 0)
+ break;
+ }
+ }
+
+ prcm_write_4(CM_WKUP_CM_CLKSEL_DPLL_DISP, (mul << 8) | (div - 1));
+
+ /* Locked mode */
+ prcm_write_4(CM_WKUP_CM_CLKMODE_DPLL_DISP, 0x7);
+
+ int timeout = 10000;
+ while ((!(prcm_read_4(CM_WKUP_CM_IDLEST_DPLL_DISP)
+ & (1 << 0))) && timeout--)
+ DELAY(10);
+
+ return(0);
+}
+
static void
am335x_prcm_reset(void)
{
@@ -724,27 +783,10 @@ am335x_clk_lcdc_activate(struct ti_clock_dev *clkdev)
if (sc == NULL)
return (ENXIO);
- /* Bypass mode */
- prcm_write_4(CM_WKUP_CM_CLKMODE_DPLL_DISP, 0x4);
-
- /* Make sure it's in bypass mode */
- while (!(prcm_read_4(CM_WKUP_CM_IDLEST_DPLL_DISP)
- & (1 << 8)))
- DELAY(10);
-
/*
- * For now set frequency to 99*SYSFREQ/8 which is twice as
- * HDMI 1080p pixel clock (minimum LCDC freq divisor is 2)
+ * For now set frequency to 2*VGA_PIXEL_CLOCK
*/
- prcm_write_4(CM_WKUP_CM_CLKSEL_DPLL_DISP, (99 << 8) | 8);
-
- /* Locked mode */
- prcm_write_4(CM_WKUP_CM_CLKMODE_DPLL_DISP, 0x7);
-
- int timeout = 10000;
- while ((!(prcm_read_4(CM_WKUP_CM_IDLEST_DPLL_DISP)
- & (1 << 0))) && timeout--)
- DELAY(10);
+ am335x_clk_set_arm_disp_freq(clkdev, 25175000*2);
/*set MODULEMODE to ENABLE(2) */
prcm_write_4(CM_PER_LCDC_CLKCTRL, 2);
diff --git a/sys/arm/ti/am335x/files.am335x b/sys/arm/ti/am335x/files.am335x
index 277ee52..7293fd0 100644
--- a/sys/arm/ti/am335x/files.am335x
+++ b/sys/arm/ti/am335x/files.am335x
@@ -16,5 +16,8 @@ arm/ti/am335x/am335x_scm_padconf.c standard
arm/ti/am335x/am335x_usbss.c optional musb fdt
arm/ti/am335x/am335x_musb.c optional musb fdt
+arm/ti/am335x/hdmi_if.m optional hdmi
+arm/ti/am335x/tda19988.c optional hdmi
+
arm/ti/ti_edma3.c standard
arm/ti/cpsw/if_cpsw.c optional cpsw
diff --git a/usr.bin/make/proc.h b/sys/arm/ti/am335x/hdmi.h
index a4ce6d3..989d132 100644
--- a/usr.bin/make/proc.h
+++ b/sys/arm/ti/am335x/hdmi.h
@@ -1,6 +1,6 @@
/*-
- * Copyright (C) 2005 Max Okumoto.
- * All rights reserved.
+ * Copyright (c) 2015 Oleksandr Tymoshenko
+ * All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -11,10 +11,10 @@
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
- * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR OR CONTRIBUTORS BE LIABLE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR 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)
@@ -23,31 +23,16 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD$
+ * $FreeBSD$
*/
-#ifndef proc_h_458845848
-#define proc_h_458845848
+#ifndef _HDMI_H_
+#define _HDMI_H_
-/**
- * Information used to create a new process.
- */
-typedef struct ProcStuff {
- int in; /* stdin for new process */
- int out; /* stdout for new process */
- int err; /* stderr for new process */
-
- int merge_errors; /* true if stderr is redirected to stdin */
- int pgroup; /* true if new process a process leader */
- int searchpath; /* true if binary should be found via $PATH */
-
- char **argv;
- int argv_free; /* release argv after use */
- int errCheck;
+#include <sys/eventhandler.h>
- pid_t child_pid;
-} ProcStuff;
+typedef void (*hdmi_event_hook)(void *, int);
+EVENTHANDLER_DECLARE(hdmi_event, hdmi_event_hook);
-void Proc_Exec(const ProcStuff *) __dead2;
+#endif /* !_HDMI_H_ */
-#endif /* proc_h_458845848 */
diff --git a/sys/arm/ti/am335x/hdmi_if.m b/sys/arm/ti/am335x/hdmi_if.m
new file mode 100644
index 0000000..e5c6080
--- /dev/null
+++ b/sys/arm/ti/am335x/hdmi_if.m
@@ -0,0 +1,50 @@
+#-
+# Copyright (c) 2015 Oleksandr Tymoshenko <gonzo@freebsd.org>
+# 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 distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+#
+# $FreeBSD$
+#
+
+#include <sys/bus.h>
+#include <dev/videomode/videomode.h>
+#include <dev/videomode/edidvar.h>
+
+INTERFACE hdmi;
+
+#
+# Get EDID info
+#
+METHOD int get_edid {
+ device_t dev;
+ uint8_t **edid;
+ uint32_t *edid_length;
+};
+
+#
+# Set videomode
+#
+METHOD int set_videomode {
+ device_t dev;
+ const struct videomode *videomode;
+};
diff --git a/sys/arm/ti/am335x/tda19988.c b/sys/arm/ti/am335x/tda19988.c
new file mode 100644
index 0000000..83dcf43
--- /dev/null
+++ b/sys/arm/ti/am335x/tda19988.c
@@ -0,0 +1,810 @@
+/*-
+ * Copyright (c) 2015 Oleksandr Tymoshenko <gonzo@freebsd.org>
+ * 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 distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+/*
+* NXP TDA19988 HDMI encoder
+*/
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/module.h>
+#include <sys/clock.h>
+#include <sys/time.h>
+#include <sys/bus.h>
+#include <sys/resource.h>
+#include <sys/rman.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+
+#include <dev/iicbus/iicbus.h>
+#include <dev/iicbus/iiconf.h>
+
+#include <dev/ofw/openfirm.h>
+#include <dev/ofw/ofw_bus.h>
+#include <dev/ofw/ofw_bus_subr.h>
+
+#include <dev/videomode/videomode.h>
+#include <dev/videomode/edidvar.h>
+#include <arm/ti/am335x/hdmi.h>
+
+#include "iicbus_if.h"
+#include "hdmi_if.h"
+
+#define MKREG(page, addr) (((page) << 8) | (addr))
+
+#define REGPAGE(reg) (((reg) >> 8) & 0xff)
+#define REGADDR(reg) ((reg) & 0xff)
+
+#define TDA_VERSION MKREG(0x00, 0x00)
+#define TDA_MAIN_CNTRL0 MKREG(0x00, 0x01)
+#define MAIN_CNTRL0_SR (1 << 0)
+#define TDA_VERSION_MSB MKREG(0x00, 0x02)
+#define TDA_SOFTRESET MKREG(0x00, 0x0a)
+#define SOFTRESET_I2C (1 << 1)
+#define SOFTRESET_AUDIO (1 << 0)
+#define TDA_DDC_CTRL MKREG(0x00, 0x0b)
+#define DDC_ENABLE 0
+#define TDA_CCLK MKREG(0x00, 0x0c)
+#define CCLK_ENABLE 1
+#define TDA_INT_FLAGS_2 MKREG(0x00, 0x11)
+#define INT_FLAGS_2_EDID_BLK_RD (1 << 1)
+
+#define TDA_VIP_CNTRL_0 MKREG(0x00, 0x20)
+#define TDA_VIP_CNTRL_1 MKREG(0x00, 0x21)
+#define TDA_VIP_CNTRL_2 MKREG(0x00, 0x22)
+#define TDA_VIP_CNTRL_3 MKREG(0x00, 0x23)
+#define VIP_CNTRL_3_SYNC_HS (2 << 4)
+#define VIP_CNTRL_3_V_TGL (1 << 2)
+#define VIP_CNTRL_3_H_TGL (1 << 1)
+
+#define TDA_VIP_CNTRL_4 MKREG(0x00, 0x24)
+#define VIP_CNTRL_4_BLANKIT_NDE (0 << 2)
+#define VIP_CNTRL_4_BLANKIT_HS_VS (1 << 2)
+#define VIP_CNTRL_4_BLANKIT_NHS_VS (2 << 2)
+#define VIP_CNTRL_4_BLANKIT_HE_VE (3 << 2)
+#define VIP_CNTRL_4_BLC_NONE (0 << 0)
+#define VIP_CNTRL_4_BLC_RGB444 (1 << 0)
+#define VIP_CNTRL_4_BLC_YUV444 (2 << 0)
+#define VIP_CNTRL_4_BLC_YUV422 (3 << 0)
+#define TDA_VIP_CNTRL_5 MKREG(0x00, 0x25)
+#define VIP_CNTRL_5_SP_CNT(n) (((n) & 3) << 1)
+#define TDA_MUX_VP_VIP_OUT MKREG(0x00, 0x27)
+#define TDA_MAT_CONTRL MKREG(0x00, 0x80)
+#define MAT_CONTRL_MAT_BP (1 << 2)
+#define TDA_VIDFORMAT MKREG(0x00, 0xa0)
+#define TDA_REFPIX_MSB MKREG(0x00, 0xa1)
+#define TDA_REFPIX_LSB MKREG(0x00, 0xa2)
+#define TDA_REFLINE_MSB MKREG(0x00, 0xa3)
+#define TDA_REFLINE_LSB MKREG(0x00, 0xa4)
+#define TDA_NPIX_MSB MKREG(0x00, 0xa5)
+#define TDA_NPIX_LSB MKREG(0x00, 0xa6)
+#define TDA_NLINE_MSB MKREG(0x00, 0xa7)
+#define TDA_NLINE_LSB MKREG(0x00, 0xa8)
+#define TDA_VS_LINE_STRT_1_MSB MKREG(0x00, 0xa9)
+#define TDA_VS_LINE_STRT_1_LSB MKREG(0x00, 0xaa)
+#define TDA_VS_PIX_STRT_1_MSB MKREG(0x00, 0xab)
+#define TDA_VS_PIX_STRT_1_LSB MKREG(0x00, 0xac)
+#define TDA_VS_LINE_END_1_MSB MKREG(0x00, 0xad)
+#define TDA_VS_LINE_END_1_LSB MKREG(0x00, 0xae)
+#define TDA_VS_PIX_END_1_MSB MKREG(0x00, 0xaf)
+#define TDA_VS_PIX_END_1_LSB MKREG(0x00, 0xb0)
+#define TDA_VS_LINE_STRT_2_MSB MKREG(0x00, 0xb1)
+#define TDA_VS_LINE_STRT_2_LSB MKREG(0x00, 0xb2)
+#define TDA_VS_PIX_STRT_2_MSB MKREG(0x00, 0xb3)
+#define TDA_VS_PIX_STRT_2_LSB MKREG(0x00, 0xb4)
+#define TDA_VS_LINE_END_2_MSB MKREG(0x00, 0xb5)
+#define TDA_VS_LINE_END_2_LSB MKREG(0x00, 0xb6)
+#define TDA_VS_PIX_END_2_MSB MKREG(0x00, 0xb7)
+#define TDA_VS_PIX_END_2_LSB MKREG(0x00, 0xb8)
+#define TDA_HS_PIX_START_MSB MKREG(0x00, 0xb9)
+#define TDA_HS_PIX_START_LSB MKREG(0x00, 0xba)
+#define TDA_HS_PIX_STOP_MSB MKREG(0x00, 0xbb)
+#define TDA_HS_PIX_STOP_LSB MKREG(0x00, 0xbc)
+#define TDA_VWIN_START_1_MSB MKREG(0x00, 0xbd)
+#define TDA_VWIN_START_1_LSB MKREG(0x00, 0xbe)
+#define TDA_VWIN_END_1_MSB MKREG(0x00, 0xbf)
+#define TDA_VWIN_END_1_LSB MKREG(0x00, 0xc0)
+#define TDA_VWIN_START_2_MSB MKREG(0x00, 0xc1)
+#define TDA_VWIN_START_2_LSB MKREG(0x00, 0xc2)
+#define TDA_VWIN_END_2_MSB MKREG(0x00, 0xc3)
+#define TDA_VWIN_END_2_LSB MKREG(0x00, 0xc4)
+#define TDA_DE_START_MSB MKREG(0x00, 0xc5)
+#define TDA_DE_START_LSB MKREG(0x00, 0xc6)
+#define TDA_DE_STOP_MSB MKREG(0x00, 0xc7)
+#define TDA_DE_STOP_LSB MKREG(0x00, 0xc8)
+
+#define TDA_TBG_CNTRL_0 MKREG(0x00, 0xca)
+#define TBG_CNTRL_0_SYNC_ONCE (1 << 7)
+#define TBG_CNTRL_0_SYNC_MTHD (1 << 6)
+
+#define TDA_TBG_CNTRL_1 MKREG(0x00, 0xcb)
+#define TBG_CNTRL_1_DWIN_DIS (1 << 6)
+#define TBG_CNTRL_1_TGL_EN (1 << 2)
+#define TBG_CNTRL_1_V_TGL (1 << 1)
+#define TBG_CNTRL_1_H_TGL (1 << 0)
+
+#define TDA_HVF_CNTRL_0 MKREG(0x00, 0xe4)
+#define HVF_CNTRL_0_PREFIL_NONE (0 << 2)
+#define HVF_CNTRL_0_INTPOL_BYPASS (0 << 0)
+#define TDA_HVF_CNTRL_1 MKREG(0x00, 0xe5)
+#define HVF_CNTRL_1_VQR(x) (((x) & 3) << 2)
+#define HVF_CNTRL_1_VQR_FULL HVF_CNTRL_1_VQR(0)
+#define TDA_ENABLE_SPACE MKREG(0x00, 0xd6)
+#define TDA_RPT_CNTRL MKREG(0x00, 0xf0)
+
+#define TDA_PLL_SERIAL_1 MKREG(0x02, 0x00)
+#define PLL_SERIAL_1_SRL_MAN_IP (1 << 6)
+#define TDA_PLL_SERIAL_2 MKREG(0x02, 0x01)
+#define PLL_SERIAL_2_SRL_PR(x) (((x) & 0xf) << 4)
+#define PLL_SERIAL_2_SRL_NOSC(x) (((x) & 0x3) << 0)
+#define TDA_PLL_SERIAL_3 MKREG(0x02, 0x02)
+#define PLL_SERIAL_3_SRL_PXIN_SEL (1 << 4)
+#define PLL_SERIAL_3_SRL_DE (1 << 2)
+#define PLL_SERIAL_3_SRL_CCIR (1 << 0)
+#define TDA_SERIALIZER MKREG(0x02, 0x03)
+#define TDA_BUFFER_OUT MKREG(0x02, 0x04)
+#define TDA_PLL_SCG1 MKREG(0x02, 0x05)
+#define TDA_PLL_SCG2 MKREG(0x02, 0x06)
+#define TDA_PLL_SCGN1 MKREG(0x02, 0x07)
+#define TDA_PLL_SCGN2 MKREG(0x02, 0x08)
+#define TDA_PLL_SCGR1 MKREG(0x02, 0x09)
+#define TDA_PLL_SCGR2 MKREG(0x02, 0x0a)
+
+#define TDA_SEL_CLK MKREG(0x02, 0x11)
+#define SEL_CLK_ENA_SC_CLK (1 << 3)
+#define SEL_CLK_SEL_VRF_CLK(x) (((x) & 3) << 1)
+#define SEL_CLK_SEL_CLK1 (1 << 0)
+#define TDA_ANA_GENERAL MKREG(0x02, 0x12)
+
+#define TDA_EDID_DATA0 MKREG(0x09, 0x00)
+#define TDA_EDID_CTRL MKREG(0x09, 0xfa)
+#define TDA_DDC_ADDR MKREG(0x09, 0xfb)
+#define TDA_DDC_OFFS MKREG(0x09, 0xfc)
+#define TDA_DDC_SEGM_ADDR MKREG(0x09, 0xfd)
+#define TDA_DDC_SEGM MKREG(0x09, 0xfe)
+
+#define TDA_IF_VSP MKREG(0x10, 0x20)
+#define TDA_IF_AVI MKREG(0x10, 0x40)
+#define TDA_IF_SPD MKREG(0x10, 0x60)
+#define TDA_IF_AUD MKREG(0x10, 0x80)
+#define TDA_IF_MPS MKREG(0x10, 0xa0)
+
+#define TDA_ENC_CNTRL MKREG(0x11, 0x0d)
+#define ENC_CNTRL_DVI_MODE (0 << 2)
+#define ENC_CNTRL_HDMI_MODE (1 << 2)
+#define TDA_DIP_IF_FLAGS MKREG(0x11, 0x0f)
+#define DIP_IF_FLAGS_IF5 (1 << 5)
+#define DIP_IF_FLAGS_IF4 (1 << 4)
+#define DIP_IF_FLAGS_IF3 (1 << 3)
+#define DIP_IF_FLAGS_IF2 (1 << 2) /* AVI IF on page 10h */
+#define DIP_IF_FLAGS_IF1 (1 << 1)
+
+#define TDA_TX3 MKREG(0x12, 0x9a)
+#define TDA_TX4 MKREG(0x12, 0x9b)
+#define TX4_PD_RAM (1 << 1)
+#define TDA_HDCP_TX33 MKREG(0x12, 0xb8)
+#define HDCP_TX33_HDMI (1 << 1)
+
+#define TDA_CURPAGE_ADDR 0xff
+
+#define TDA_CEC_ENAMODS 0xff
+#define ENAMODS_RXSENS (1 << 2)
+#define ENAMODS_HDMI (1 << 1)
+#define TDA_CEC_FRO_IM_CLK_CTRL 0xfb
+#define CEC_FRO_IM_CLK_CTRL_GHOST_DIS (1 << 7)
+#define CEC_FRO_IM_CLK_CTRL_IMCLK_SEL (1 << 1)
+
+/* EDID reading */
+#define EDID_LENGTH 0x80
+#define MAX_READ_ATTEMPTS 100
+
+/* EDID fields */
+#define EDID_MODES0 35
+#define EDID_MODES1 36
+#define EDID_TIMING_START 38
+#define EDID_TIMING_END 54
+#define EDID_TIMING_X(v) (((v) + 31) * 8)
+#define EDID_FREQ(v) (((v) & 0x3f) + 60)
+#define EDID_RATIO(v) (((v) >> 6) & 0x3)
+#define EDID_RATIO_10x16 0
+#define EDID_RATIO_3x4 1
+#define EDID_RATIO_4x5 2
+#define EDID_RATIO_9x16 3
+
+#define TDA19988 0x0301
+
+struct tda19988_softc {
+ device_t sc_dev;
+ uint32_t sc_addr;
+ uint32_t sc_cec_addr;
+ uint16_t sc_version;
+ struct intr_config_hook enum_hook;
+ int sc_current_page;
+ uint8_t *sc_edid;
+ uint32_t sc_edid_len;
+};
+
+static int
+tda19988_set_page(struct tda19988_softc *sc, uint8_t page)
+{
+ uint8_t addr = TDA_CURPAGE_ADDR;
+ uint8_t cmd[2];
+ int result;
+ struct iic_msg msg[] = {
+ { sc->sc_addr, IIC_M_WR, 2, cmd },
+ };
+
+ cmd[0] = addr;
+ cmd[1] = page;
+
+ result = (iicbus_transfer(sc->sc_dev, msg, 1));
+ if (result)
+ printf("tda19988_set_page failed: %d\n", result);
+ else
+ sc->sc_current_page = page;
+
+ return (result);
+}
+
+static int
+tda19988_cec_read(struct tda19988_softc *sc, uint8_t addr, uint8_t *data)
+{
+ int result;
+ struct iic_msg msg[] = {
+ { sc->sc_cec_addr, IIC_M_WR, 1, &addr },
+ { sc->sc_cec_addr, IIC_M_RD, 1, data },
+ };
+
+ result = iicbus_transfer(sc->sc_dev, msg, 2);
+ if (result)
+ printf("tda19988_cec_read failed: %d\n", result);
+ return (result);
+}
+
+static int
+tda19988_cec_write(struct tda19988_softc *sc, uint8_t address, uint8_t data)
+{
+ uint8_t cmd[2];
+ int result;
+ struct iic_msg msg[] = {
+ { sc->sc_cec_addr, IIC_M_WR, 2, cmd },
+ };
+
+ cmd[0] = address;
+ cmd[1] = data;
+
+ result = iicbus_transfer(sc->sc_dev, msg, 1);
+ if (result)
+ printf("tda19988_cec_write failed: %d\n", result);
+ return (result);
+}
+
+static int
+tda19988_block_read(struct tda19988_softc *sc, uint16_t addr, uint8_t *data, int len)
+{
+ uint8_t reg;
+ int result;
+ struct iic_msg msg[] = {
+ { sc->sc_addr, IIC_M_WR, 1, &reg },
+ { sc->sc_addr, IIC_M_RD, len, data },
+ };
+
+ reg = REGADDR(addr);
+
+ if (sc->sc_current_page != REGPAGE(addr))
+ tda19988_set_page(sc, REGPAGE(addr));
+
+ result = (iicbus_transfer(sc->sc_dev, msg, 2));
+ if (result)
+ device_printf(sc->sc_dev, "tda19988_block_read failed: %d\n", result);
+ return (result);
+}
+
+static int
+tda19988_reg_read(struct tda19988_softc *sc, uint16_t addr, uint8_t *data)
+{
+ uint8_t reg;
+ int result;
+ struct iic_msg msg[] = {
+ { sc->sc_addr, IIC_M_WR, 1, &reg },
+ { sc->sc_addr, IIC_M_RD, 1, data },
+ };
+
+ reg = REGADDR(addr);
+
+ if (sc->sc_current_page != REGPAGE(addr))
+ tda19988_set_page(sc, REGPAGE(addr));
+
+ result = (iicbus_transfer(sc->sc_dev, msg, 2));
+ if (result)
+ device_printf(sc->sc_dev, "tda19988_reg_read failed: %d\n", result);
+ return (result);
+}
+
+static int
+tda19988_reg_write(struct tda19988_softc *sc, uint16_t address, uint8_t data)
+{
+ uint8_t cmd[2];
+ int result;
+ struct iic_msg msg[] = {
+ { sc->sc_addr, IIC_M_WR, 2, cmd },
+ };
+
+ cmd[0] = REGADDR(address);
+ cmd[1] = data;
+
+ if (sc->sc_current_page != REGPAGE(address))
+ tda19988_set_page(sc, REGPAGE(address));
+
+ result = iicbus_transfer(sc->sc_dev, msg, 1);
+ if (result)
+ device_printf(sc->sc_dev, "tda19988_reg_write failed: %d\n", result);
+
+ return (result);
+}
+
+static int
+tda19988_reg_write2(struct tda19988_softc *sc, uint16_t address, uint16_t data)
+{
+ uint8_t cmd[3];
+ int result;
+ struct iic_msg msg[] = {
+ { sc->sc_addr, IIC_M_WR, 3, cmd },
+ };
+
+ cmd[0] = REGADDR(address);
+ cmd[1] = (data >> 8);
+ cmd[2] = (data & 0xff);
+
+ if (sc->sc_current_page != REGPAGE(address))
+ tda19988_set_page(sc, REGPAGE(address));
+
+ result = iicbus_transfer(sc->sc_dev, msg, 1);
+ if (result)
+ device_printf(sc->sc_dev, "tda19988_reg_write2 failed: %d\n", result);
+
+ return (result);
+}
+
+static void
+tda19988_reg_set(struct tda19988_softc *sc, uint16_t addr, uint8_t flags)
+{
+ uint8_t data;
+
+ tda19988_reg_read(sc, addr, &data);
+ data |= flags;
+ tda19988_reg_write(sc, addr, data);
+}
+
+static void
+tda19988_reg_clear(struct tda19988_softc *sc, uint16_t addr, uint8_t flags)
+{
+ uint8_t data;
+
+ tda19988_reg_read(sc, addr, &data);
+ data &= ~flags;
+ tda19988_reg_write(sc, addr, data);
+}
+
+static int
+tda19988_probe(device_t dev)
+{
+
+ if (!ofw_bus_is_compatible(dev, "nxp,tda998x"))
+ return (ENXIO);
+
+ return (BUS_PROBE_DEFAULT);
+}
+
+static void
+tda19988_init_encoder(struct tda19988_softc *sc, const struct videomode *mode)
+{
+ uint16_t ref_pix, ref_line, n_pix, n_line;
+ uint16_t hs_pix_start, hs_pix_stop;
+ uint16_t vs1_pix_start, vs1_pix_stop;
+ uint16_t vs1_line_start, vs1_line_end;
+ uint16_t vs2_pix_start, vs2_pix_stop;
+ uint16_t vs2_line_start, vs2_line_end;
+ uint16_t vwin1_line_start, vwin1_line_end;
+ uint16_t vwin2_line_start, vwin2_line_end;
+ uint16_t de_start, de_stop;
+ uint8_t reg, div;
+
+ n_pix = mode->htotal;
+ n_line = mode->vtotal;
+
+ hs_pix_stop = mode->hsync_end - mode->hdisplay;
+ hs_pix_start = mode->hsync_start - mode->hdisplay;
+
+ de_stop = mode->htotal;
+ de_start = mode->htotal - mode->hdisplay;
+ ref_pix = hs_pix_start + 3;
+
+ if (mode->flags & VID_HSKEW)
+ ref_pix += mode->hskew;
+
+ if ((mode->flags & VID_INTERLACE) == 0) {
+ ref_line = 1 + mode->vsync_start - mode->vdisplay;
+ vwin1_line_start = mode->vtotal - mode->vdisplay - 1;
+ vwin1_line_end = vwin1_line_start + mode->vdisplay;
+
+ vs1_pix_start = vs1_pix_stop = hs_pix_start;
+ vs1_line_start = mode->vsync_start - mode->vdisplay;
+ vs1_line_end = vs1_line_start + mode->vsync_end - mode->vsync_start;
+
+ vwin2_line_start = vwin2_line_end = 0;
+ vs2_pix_start = vs2_pix_stop = 0;
+ vs2_line_start = vs2_line_end = 0;
+ } else {
+ ref_line = 1 + (mode->vsync_start - mode->vdisplay)/2;
+ vwin1_line_start = (mode->vtotal - mode->vdisplay)/2;
+ vwin1_line_end = vwin1_line_start + mode->vdisplay/2;
+
+ vs1_pix_start = vs1_pix_stop = hs_pix_start;
+ vs1_line_start = (mode->vsync_start - mode->vdisplay)/2;
+ vs1_line_end = vs1_line_start + (mode->vsync_end - mode->vsync_start)/2;
+
+ vwin2_line_start = vwin1_line_start + mode->vtotal/2;
+ vwin2_line_end = vwin2_line_start + mode->vdisplay/2;
+
+ vs2_pix_start = vs2_pix_stop = hs_pix_start + mode->htotal/2;
+ vs2_line_start = vs1_line_start + mode->vtotal/2 ;
+ vs2_line_end = vs2_line_start + (mode->vsync_end - mode->vsync_start)/2;
+ }
+
+ div = 148500 / mode->dot_clock;
+ if (div != 0) {
+ div--;
+ if (div > 3)
+ div = 3;
+ }
+
+ /* set HDMI HDCP mode off */
+ tda19988_reg_set(sc, TDA_TBG_CNTRL_1, TBG_CNTRL_1_DWIN_DIS);
+ tda19988_reg_clear(sc, TDA_HDCP_TX33, HDCP_TX33_HDMI);
+ tda19988_reg_write(sc, TDA_ENC_CNTRL, ENC_CNTRL_DVI_MODE);
+
+ /* no pre-filter or interpolator */
+ tda19988_reg_write(sc, TDA_HVF_CNTRL_0,
+ HVF_CNTRL_0_INTPOL_BYPASS | HVF_CNTRL_0_PREFIL_NONE);
+ tda19988_reg_write(sc, TDA_VIP_CNTRL_5, VIP_CNTRL_5_SP_CNT(0));
+ tda19988_reg_write(sc, TDA_VIP_CNTRL_4,
+ VIP_CNTRL_4_BLANKIT_NDE | VIP_CNTRL_4_BLC_NONE);
+
+ tda19988_reg_clear(sc, TDA_PLL_SERIAL_3, PLL_SERIAL_3_SRL_CCIR);
+ tda19988_reg_clear(sc, TDA_PLL_SERIAL_1, PLL_SERIAL_1_SRL_MAN_IP);
+ tda19988_reg_clear(sc, TDA_PLL_SERIAL_3, PLL_SERIAL_3_SRL_DE);
+ tda19988_reg_write(sc, TDA_SERIALIZER, 0);
+ tda19988_reg_write(sc, TDA_HVF_CNTRL_1, HVF_CNTRL_1_VQR_FULL);
+
+ tda19988_reg_write(sc, TDA_RPT_CNTRL, 0);
+ tda19988_reg_write(sc, TDA_SEL_CLK, SEL_CLK_SEL_VRF_CLK(0) |
+ SEL_CLK_SEL_CLK1 | SEL_CLK_ENA_SC_CLK);
+
+ tda19988_reg_write(sc, TDA_PLL_SERIAL_2, PLL_SERIAL_2_SRL_NOSC(div) |
+ PLL_SERIAL_2_SRL_PR(0));
+
+ tda19988_reg_set(sc, TDA_MAT_CONTRL, MAT_CONTRL_MAT_BP);
+
+ tda19988_reg_write(sc, TDA_ANA_GENERAL, 0x09);
+
+ tda19988_reg_clear(sc, TDA_TBG_CNTRL_0, TBG_CNTRL_0_SYNC_MTHD);
+
+ /*
+ * Sync on rising HSYNC/VSYNC
+ */
+ reg = VIP_CNTRL_3_SYNC_HS;
+ if (mode->flags & VID_NHSYNC)
+ reg |= VIP_CNTRL_3_H_TGL;
+ if (mode->flags & VID_NVSYNC)
+ reg |= VIP_CNTRL_3_V_TGL;
+ tda19988_reg_write(sc, TDA_VIP_CNTRL_3, reg);
+
+ reg = TBG_CNTRL_1_TGL_EN;
+ if (mode->flags & VID_NHSYNC)
+ reg |= TBG_CNTRL_1_H_TGL;
+ if (mode->flags & VID_NVSYNC)
+ reg |= TBG_CNTRL_1_V_TGL;
+ tda19988_reg_write(sc, TDA_TBG_CNTRL_1, reg);
+
+ /* Program timing */
+ tda19988_reg_write(sc, TDA_VIDFORMAT, 0x00);
+
+ tda19988_reg_write2(sc, TDA_REFPIX_MSB, ref_pix);
+ tda19988_reg_write2(sc, TDA_REFLINE_MSB, ref_line);
+ tda19988_reg_write2(sc, TDA_NPIX_MSB, n_pix);
+ tda19988_reg_write2(sc, TDA_NLINE_MSB, n_line);
+
+ tda19988_reg_write2(sc, TDA_VS_LINE_STRT_1_MSB, vs1_line_start);
+ tda19988_reg_write2(sc, TDA_VS_PIX_STRT_1_MSB, vs1_pix_start);
+ tda19988_reg_write2(sc, TDA_VS_LINE_END_1_MSB, vs1_line_end);
+ tda19988_reg_write2(sc, TDA_VS_PIX_END_1_MSB, vs1_pix_stop);
+ tda19988_reg_write2(sc, TDA_VS_LINE_STRT_2_MSB, vs2_line_start);
+ tda19988_reg_write2(sc, TDA_VS_PIX_STRT_2_MSB, vs2_pix_start);
+ tda19988_reg_write2(sc, TDA_VS_LINE_END_2_MSB, vs2_line_end);
+ tda19988_reg_write2(sc, TDA_VS_PIX_END_2_MSB, vs2_pix_stop);
+ tda19988_reg_write2(sc, TDA_HS_PIX_START_MSB, hs_pix_start);
+ tda19988_reg_write2(sc, TDA_HS_PIX_STOP_MSB, hs_pix_stop);
+ tda19988_reg_write2(sc, TDA_VWIN_START_1_MSB, vwin1_line_start);
+ tda19988_reg_write2(sc, TDA_VWIN_END_1_MSB, vwin1_line_end);
+ tda19988_reg_write2(sc, TDA_VWIN_START_2_MSB, vwin2_line_start);
+ tda19988_reg_write2(sc, TDA_VWIN_END_2_MSB, vwin2_line_end);
+ tda19988_reg_write2(sc, TDA_DE_START_MSB, de_start);
+ tda19988_reg_write2(sc, TDA_DE_STOP_MSB, de_stop);
+
+ if (sc->sc_version == TDA19988)
+ tda19988_reg_write(sc, TDA_ENABLE_SPACE, 0x00);
+
+ /* must be last register set */
+ tda19988_reg_clear(sc, TDA_TBG_CNTRL_0, TBG_CNTRL_0_SYNC_ONCE);
+}
+
+static int
+tda19988_read_edid_block(struct tda19988_softc *sc, uint8_t *buf, int block)
+{
+ int attempt, err;
+ uint8_t data;
+
+ err = 0;
+
+ tda19988_reg_set(sc, TDA_INT_FLAGS_2, INT_FLAGS_2_EDID_BLK_RD);
+
+ /* Block 0 */
+ tda19988_reg_write(sc, TDA_DDC_ADDR, 0xa0);
+ tda19988_reg_write(sc, TDA_DDC_OFFS, (block % 2) ? 128 : 0);
+ tda19988_reg_write(sc, TDA_DDC_SEGM_ADDR, 0x60);
+ tda19988_reg_write(sc, TDA_DDC_SEGM, block / 2);
+
+ tda19988_reg_write(sc, TDA_EDID_CTRL, 1);
+ tda19988_reg_write(sc, TDA_EDID_CTRL, 0);
+
+ data = 0;
+ for (attempt = 0; attempt < MAX_READ_ATTEMPTS; attempt++) {
+ tda19988_reg_read(sc, TDA_INT_FLAGS_2, &data);
+ if (data & INT_FLAGS_2_EDID_BLK_RD)
+ break;
+ pause("EDID", 1);
+ }
+
+ if (attempt == MAX_READ_ATTEMPTS) {
+ err = -1;
+ goto done;
+ }
+
+ if (tda19988_block_read(sc, TDA_EDID_DATA0, buf, EDID_LENGTH) != 0) {
+ err = -1;
+ goto done;
+ }
+
+done:
+ tda19988_reg_clear(sc, TDA_INT_FLAGS_2, INT_FLAGS_2_EDID_BLK_RD);
+
+ return (err);
+}
+
+static int
+tda19988_read_edid(struct tda19988_softc *sc)
+{
+ int err;
+ int blocks, i;
+ uint8_t *buf;
+
+ err = 0;
+ if (sc->sc_version == TDA19988)
+ tda19988_reg_clear(sc, TDA_TX4, TX4_PD_RAM);
+
+ err = tda19988_read_edid_block(sc, sc->sc_edid, 0);
+ if (err)
+ goto done;
+
+ blocks = sc->sc_edid[0x7e];
+ if (blocks > 0) {
+ sc->sc_edid = realloc(sc->sc_edid,
+ EDID_LENGTH*(blocks+1), M_DEVBUF, M_WAITOK);
+ sc->sc_edid_len = EDID_LENGTH*(blocks+1);
+ for (i = 0; i < blocks; i++) {
+ /* TODO: check validity */
+ buf = sc->sc_edid + EDID_LENGTH*(i+1);
+ err = tda19988_read_edid_block(sc, buf, i);
+ if (err)
+ goto done;
+ }
+ }
+
+ EVENTHANDLER_INVOKE(hdmi_event, 0);
+done:
+ if (sc->sc_version == TDA19988)
+ tda19988_reg_set(sc, TDA_TX4, TX4_PD_RAM);
+
+ return (err);
+}
+
+static void
+tda19988_start(void *xdev)
+{
+ struct tda19988_softc *sc;
+ device_t dev = (device_t)xdev;
+ uint8_t data;
+ uint16_t version;
+
+ sc = device_get_softc(dev);
+
+ tda19988_cec_write(sc, TDA_CEC_ENAMODS, ENAMODS_RXSENS | ENAMODS_HDMI);
+ DELAY(1000);
+ tda19988_cec_read(sc, 0xfe, &data);
+
+ /* Reset core */
+ tda19988_reg_set(sc, TDA_SOFTRESET, 3);
+ DELAY(100);
+ tda19988_reg_clear(sc, TDA_SOFTRESET, 3);
+ DELAY(100);
+
+ /* reset transmitter: */
+ tda19988_reg_set(sc, TDA_MAIN_CNTRL0, MAIN_CNTRL0_SR);
+ tda19988_reg_clear(sc, TDA_MAIN_CNTRL0, MAIN_CNTRL0_SR);
+
+ /* PLL registers common configuration */
+ tda19988_reg_write(sc, TDA_PLL_SERIAL_1, 0x00);
+ tda19988_reg_write(sc, TDA_PLL_SERIAL_2, PLL_SERIAL_2_SRL_NOSC(1));
+ tda19988_reg_write(sc, TDA_PLL_SERIAL_3, 0x00);
+ tda19988_reg_write(sc, TDA_SERIALIZER, 0x00);
+ tda19988_reg_write(sc, TDA_BUFFER_OUT, 0x00);
+ tda19988_reg_write(sc, TDA_PLL_SCG1, 0x00);
+ tda19988_reg_write(sc, TDA_SEL_CLK, SEL_CLK_SEL_CLK1 | SEL_CLK_ENA_SC_CLK);
+ tda19988_reg_write(sc, TDA_PLL_SCGN1, 0xfa);
+ tda19988_reg_write(sc, TDA_PLL_SCGN2, 0x00);
+ tda19988_reg_write(sc, TDA_PLL_SCGR1, 0x5b);
+ tda19988_reg_write(sc, TDA_PLL_SCGR2, 0x00);
+ tda19988_reg_write(sc, TDA_PLL_SCG2, 0x10);
+
+ /* Write the default value MUX register */
+ tda19988_reg_write(sc, TDA_MUX_VP_VIP_OUT, 0x24);
+
+ version = 0;
+ tda19988_reg_read(sc, TDA_VERSION, &data);
+ version |= data;
+ tda19988_reg_read(sc, TDA_VERSION_MSB, &data);
+ version |= (data << 8);
+
+ /* Clear feature bits */
+ sc->sc_version = version & ~0x30;
+ switch (sc->sc_version) {
+ case TDA19988:
+ device_printf(dev, "TDA19988\n");
+ break;
+ default:
+ device_printf(dev, "Unknown device: %04x\n", sc->sc_version);
+ goto done;
+ }
+
+ tda19988_reg_write(sc, TDA_DDC_CTRL, DDC_ENABLE);
+ tda19988_reg_write(sc, TDA_TX3, 39);
+
+ tda19988_cec_write(sc, TDA_CEC_FRO_IM_CLK_CTRL,
+ CEC_FRO_IM_CLK_CTRL_GHOST_DIS | CEC_FRO_IM_CLK_CTRL_IMCLK_SEL);
+
+ if (tda19988_read_edid(sc) < 0) {
+ device_printf(dev, "failed to read EDID\n");
+ goto done;
+ }
+
+ /* Default values for RGB 4:4:4 mapping */
+ tda19988_reg_write(sc, TDA_VIP_CNTRL_0, 0x23);
+ tda19988_reg_write(sc, TDA_VIP_CNTRL_1, 0x45);
+ tda19988_reg_write(sc, TDA_VIP_CNTRL_2, 0x01);
+
+done:
+ config_intrhook_disestablish(&sc->enum_hook);
+}
+
+static int
+tda19988_attach(device_t dev)
+{
+ struct tda19988_softc *sc;
+ phandle_t node;
+
+ sc = device_get_softc(dev);
+
+ sc->sc_dev = dev;
+ sc->sc_addr = iicbus_get_addr(dev) << 1;
+ sc->sc_cec_addr = (0x34 << 1); /* hardcoded */
+ sc->sc_edid = malloc(EDID_LENGTH, M_DEVBUF, M_WAITOK | M_ZERO);
+ sc->sc_edid_len = EDID_LENGTH;
+
+ device_set_desc(dev, "NXP TDA19988 HDMI transmitter");
+
+ sc->enum_hook.ich_func = tda19988_start;
+ sc->enum_hook.ich_arg = dev;
+
+ if (config_intrhook_establish(&sc->enum_hook) != 0)
+ return (ENOMEM);
+
+ node = ofw_bus_get_node(dev);
+ OF_device_register_xref(OF_xref_from_node(node), dev);
+
+ return (0);
+}
+
+static int
+tda19988_detach(device_t dev)
+{
+
+ /* XXX: Do not let unload drive */
+ return (EBUSY);
+}
+
+static int
+tda19988_get_edid(device_t dev, uint8_t **edid, uint32_t *edid_len)
+{
+ struct tda19988_softc *sc;
+
+ sc = device_get_softc(dev);
+
+ if (sc->sc_edid) {
+ *edid = sc->sc_edid;
+ *edid_len = sc->sc_edid_len;
+ } else
+ return (ENXIO);
+
+ return (0);
+}
+
+static int
+tda19988_set_videomode(device_t dev, const struct videomode *mode)
+{
+ struct tda19988_softc *sc;
+
+ sc = device_get_softc(dev);
+
+ tda19988_init_encoder(sc, mode);
+
+ return (0);
+}
+
+static device_method_t tda_methods[] = {
+ DEVMETHOD(device_probe, tda19988_probe),
+ DEVMETHOD(device_attach, tda19988_attach),
+ DEVMETHOD(device_detach, tda19988_detach),
+
+ /* HDMI methods */
+ DEVMETHOD(hdmi_get_edid, tda19988_get_edid),
+ DEVMETHOD(hdmi_set_videomode, tda19988_set_videomode),
+ {0, 0},
+};
+
+static driver_t tda_driver = {
+ "tda",
+ tda_methods,
+ sizeof(struct tda19988_softc),
+};
+
+static devclass_t tda_devclass;
+
+DRIVER_MODULE(tda, iicbus, tda_driver, tda_devclass, 0, 0);
+MODULE_VERSION(tda, 1);
+MODULE_DEPEND(tda, iicbus, 1, 1, 1);
diff --git a/sys/arm/ti/omap4/omap4_prcm_clks.c b/sys/arm/ti/omap4/omap4_prcm_clks.c
index 8b1cb6e..fc5fb97 100644
--- a/sys/arm/ti/omap4/omap4_prcm_clks.c
+++ b/sys/arm/ti/omap4/omap4_prcm_clks.c
@@ -217,7 +217,8 @@ static int omap4_clk_get_arm_fclk_freq(struct ti_clock_dev *clkdev, unsigned int
.clk_deactivate = omap4_clk_generic_deactivate, \
.clk_set_source = omap4_clk_generic_set_source, \
.clk_accessible = omap4_clk_generic_accessible, \
- .clk_get_source_freq = omap4_clk_generic_get_source_freq \
+ .clk_get_source_freq = omap4_clk_generic_get_source_freq, \
+ .clk_set_source_freq = NULL \
}
#define OMAP4_GPTIMER_CLOCK_DEV(i) \
@@ -226,7 +227,8 @@ static int omap4_clk_get_arm_fclk_freq(struct ti_clock_dev *clkdev, unsigned int
.clk_deactivate = omap4_clk_generic_deactivate, \
.clk_set_source = omap4_clk_gptimer_set_source, \
.clk_accessible = omap4_clk_generic_accessible, \
- .clk_get_source_freq = omap4_clk_gptimer_get_source_freq \
+ .clk_get_source_freq = omap4_clk_gptimer_get_source_freq, \
+ .clk_set_source_freq = NULL \
}
#define OMAP4_HSMMC_CLOCK_DEV(i) \
@@ -235,7 +237,8 @@ static int omap4_clk_get_arm_fclk_freq(struct ti_clock_dev *clkdev, unsigned int
.clk_deactivate = omap4_clk_generic_deactivate, \
.clk_set_source = omap4_clk_hsmmc_set_source, \
.clk_accessible = omap4_clk_generic_accessible, \
- .clk_get_source_freq = omap4_clk_hsmmc_get_source_freq \
+ .clk_get_source_freq = omap4_clk_hsmmc_get_source_freq, \
+ .clk_set_source_freq = NULL \
}
#define OMAP4_HSUSBHOST_CLOCK_DEV(i) \
@@ -244,7 +247,8 @@ static int omap4_clk_get_arm_fclk_freq(struct ti_clock_dev *clkdev, unsigned int
.clk_deactivate = omap4_clk_hsusbhost_deactivate, \
.clk_set_source = omap4_clk_hsusbhost_set_source, \
.clk_accessible = omap4_clk_hsusbhost_accessible, \
- .clk_get_source_freq = NULL \
+ .clk_get_source_freq = NULL, \
+ .clk_set_source_freq = NULL \
}
@@ -257,6 +261,7 @@ struct ti_clock_dev ti_omap4_clk_devmap[] = {
.clk_set_source = NULL,
.clk_accessible = NULL,
.clk_get_source_freq = omap4_clk_get_sysclk_freq,
+ .clk_set_source_freq = NULL,
},
/* MPU (ARM) core clocks */
{ .id = MPU_CLK,
@@ -265,6 +270,7 @@ struct ti_clock_dev ti_omap4_clk_devmap[] = {
.clk_set_source = NULL,
.clk_accessible = NULL,
.clk_get_source_freq = omap4_clk_get_arm_fclk_freq,
+ .clk_set_source_freq = NULL,
},
diff --git a/sys/arm/ti/ti_prcm.c b/sys/arm/ti/ti_prcm.c
index 3c073f9..c5ab9c7 100644
--- a/sys/arm/ti/ti_prcm.c
+++ b/sys/arm/ti/ti_prcm.c
@@ -285,7 +285,7 @@ ti_prcm_clk_set_source(clk_ident_t clk, clk_src_t clksrc)
* @clk: identifier for the module to enable, see ti_prcm.h for a list
* of possible modules.
* @freq: pointer to an integer that upon return will contain the src freq
- *
+ *
* This function returns the frequency of the source clock.
*
* The real work done to enable the clock is really done in the callback
@@ -319,6 +319,39 @@ ti_prcm_clk_get_source_freq(clk_ident_t clk, unsigned int *freq)
ret = clk_dev->clk_get_source_freq(clk_dev, freq);
else
ret = EINVAL;
-
+
+ return (ret);
+}
+
+/**
+ * ti_prcm_clk_set_source_freq - sets the source clock frequency as close to freq as possible
+ * @clk: identifier for the module to enable, see ti_prcm.h for a list
+ * of possible modules.
+ * @freq: requested freq
+ *
+ * LOCKING:
+ * Internally locks the driver context.
+ *
+ * RETURNS:
+ * Returns 0 on success or positive error code on failure.
+ */
+int
+ti_prcm_clk_set_source_freq(clk_ident_t clk, unsigned int freq)
+{
+ struct ti_clock_dev *clk_dev;
+ int ret;
+
+ clk_dev = ti_prcm_clk_dev(clk);
+
+ /* Sanity check we managed to find the clock */
+ if (clk_dev == NULL)
+ return (EINVAL);
+
+ /* Get the source frequency of the clock */
+ if (clk_dev->clk_set_source_freq)
+ ret = clk_dev->clk_set_source_freq(clk_dev, freq);
+ else
+ ret = EINVAL;
+
return (ret);
}
diff --git a/sys/arm/ti/ti_prcm.h b/sys/arm/ti/ti_prcm.h
index eaea990..c40439a 100644
--- a/sys/arm/ti/ti_prcm.h
+++ b/sys/arm/ti/ti_prcm.h
@@ -184,6 +184,8 @@ struct ti_clock_dev {
int (*clk_set_source)(struct ti_clock_dev *clkdev,
clk_src_t clksrc);
int (*clk_accessible)(struct ti_clock_dev *clkdev);
+ int (*clk_set_source_freq)(struct ti_clock_dev *clkdev,
+ unsigned int freq);
int (*clk_get_source_freq)(struct ti_clock_dev *clkdev,
unsigned int *freq);
};
@@ -194,6 +196,7 @@ int ti_prcm_clk_disable(clk_ident_t clk);
int ti_prcm_clk_accessible(clk_ident_t clk);
int ti_prcm_clk_disable_autoidle(clk_ident_t clk);
int ti_prcm_clk_set_source(clk_ident_t clk, clk_src_t clksrc);
+int ti_prcm_clk_set_source_freq(clk_ident_t clk, unsigned int freq);
int ti_prcm_clk_get_source_freq(clk_ident_t clk, unsigned int *freq);
void ti_prcm_reset(void);
diff --git a/sys/boot/Makefile b/sys/boot/Makefile
index 2aa76b7..2607651 100644
--- a/sys/boot/Makefile
+++ b/sys/boot/Makefile
@@ -8,6 +8,8 @@ SUBDIR+= ficl
SUBDIR+= forth
.endif
+SUBDIR+= common
+
.include <bsd.arch.inc.mk>
# Pick the machine-dependent subdir based on the target architecture.
diff --git a/sys/boot/common/Makefile b/sys/boot/common/Makefile
new file mode 100644
index 0000000..fcca328
--- /dev/null
+++ b/sys/boot/common/Makefile
@@ -0,0 +1,10 @@
+# $FreeBSD$
+
+.include <src.opts.mk>
+
+MAN+= loader.8
+.if ${MK_ZFS} != "no"
+MAN+= zfsloader.8
+.endif
+
+.include <bsd.prog.mk>
diff --git a/sys/boot/common/Makefile.inc b/sys/boot/common/Makefile.inc
index 54e8617..d647fe3 100644
--- a/sys/boot/common/Makefile.inc
+++ b/sys/boot/common/Makefile.inc
@@ -68,8 +68,3 @@ CFLAGS+= -DBOOT_PROMPT_123
SRCS+= install.c
CFLAGS+=-I${.CURDIR}/../../../../lib/libstand
.endif
-
-MAN+= loader.8
-.if ${MK_ZFS} != "no"
-MAN+= zfsloader.8
-.endif
diff --git a/sys/boot/fdt/dts/arm/beaglebone-black.dts b/sys/boot/fdt/dts/arm/beaglebone-black.dts
index f5144dd..21cbf83 100644
--- a/sys/boot/fdt/dts/arm/beaglebone-black.dts
+++ b/sys/boot/fdt/dts/arm/beaglebone-black.dts
@@ -29,3 +29,25 @@
#include "am335x-boneblack.dts"
#include "beaglebone-common.dtsi"
+
+&i2c0 {
+ tda998x: hdmi-encoder {
+ compatible = "nxp,tda998x";
+ reg = <0x70>;
+
+ pinctrl-names = "default", "off";
+ pinctrl-0 = <&nxp_hdmi_bonelt_pins>;
+ pinctrl-1 = <&nxp_hdmi_bonelt_off_pins>;
+ status = "okay";
+ };
+};
+
+&lcdc {
+ hdmi = <&tda998x>;
+};
+
+/ {
+ hdmi {
+ status = "disabled";
+ };
+};
diff --git a/sys/boot/i386/loader/Makefile b/sys/boot/i386/loader/Makefile
index 6e735a4..ade6054 100644
--- a/sys/boot/i386/loader/Makefile
+++ b/sys/boot/i386/loader/Makefile
@@ -5,6 +5,7 @@ MK_SSP= no
LOADER?= loader
PROG= ${LOADER}.sym
+MAN=
INTERNALPROG=
NEWVERSWHAT?= "bootstrap loader" x86
diff --git a/sys/boot/mips/beri/loader/Makefile b/sys/boot/mips/beri/loader/Makefile
index d4292cc..a134f3d 100644
--- a/sys/boot/mips/beri/loader/Makefile
+++ b/sys/boot/mips/beri/loader/Makefile
@@ -31,6 +31,7 @@
.include <src.opts.mk>
MK_SSP= no
+MAN=
PROG?= loader
NEWVERSWHAT= "BERI loader" ${MACHINE_CPUARCH}
diff --git a/sys/boot/pc98/loader/Makefile b/sys/boot/pc98/loader/Makefile
index a001c20..9333f3c 100644
--- a/sys/boot/pc98/loader/Makefile
+++ b/sys/boot/pc98/loader/Makefile
@@ -2,6 +2,7 @@
.include <src.opts.mk>
MK_SSP= no
+MAN=
LOADER?= loader
PROG= ${LOADER}.sym
diff --git a/sys/boot/powerpc/kboot/Makefile b/sys/boot/powerpc/kboot/Makefile
index 0ca7d20..4601f29 100644
--- a/sys/boot/powerpc/kboot/Makefile
+++ b/sys/boot/powerpc/kboot/Makefile
@@ -2,6 +2,7 @@
.include <src.opts.mk>
MK_SSP= no
+MAN=
PROG= loader.kboot
NEWVERSWHAT= "kboot loader" ${MACHINE_ARCH}
diff --git a/sys/boot/powerpc/ofw/Makefile b/sys/boot/powerpc/ofw/Makefile
index 65b79ea..6a2fc70 100644
--- a/sys/boot/powerpc/ofw/Makefile
+++ b/sys/boot/powerpc/ofw/Makefile
@@ -2,6 +2,7 @@
.include <src.opts.mk>
MK_SSP= no
+MAN=
PROG= loader
NEWVERSWHAT= "Open Firmware loader" ${MACHINE_ARCH}
diff --git a/sys/boot/powerpc/ps3/Makefile b/sys/boot/powerpc/ps3/Makefile
index 3bb9cb3..861872f 100644
--- a/sys/boot/powerpc/ps3/Makefile
+++ b/sys/boot/powerpc/ps3/Makefile
@@ -2,6 +2,7 @@
.include <src.opts.mk>
MK_SSP= no
+MAN=
PROG= loader.ps3
NEWVERSWHAT= "Playstation 3 loader" ${MACHINE_ARCH}
diff --git a/sys/boot/sparc64/loader/Makefile b/sys/boot/sparc64/loader/Makefile
index ca2853c..5c9bfbb 100644
--- a/sys/boot/sparc64/loader/Makefile
+++ b/sys/boot/sparc64/loader/Makefile
@@ -2,6 +2,7 @@
.include <src.opts.mk>
MK_SSP= no
+MAN=
PROG?= loader
NEWVERSWHAT?= "bootstrap loader" sparc64
diff --git a/sys/boot/uboot/lib/copy.c b/sys/boot/uboot/lib/copy.c
index bb658e3..51416ac 100644
--- a/sys/boot/uboot/lib/copy.c
+++ b/sys/boot/uboot/lib/copy.c
@@ -118,6 +118,13 @@ uboot_loadaddr(u_int type, void *data, uint64_t addr)
this_block = eubldr;
this_size = eblock - eubldr;
}
+ } else if (subldr < sblock && eubldr < eblock) {
+ /* Loader is below or engulfs the sblock */
+ this_block = (eubldr < sblock) ? sblock : eubldr;
+ this_size = eblock - this_block;
+ } else {
+ this_block = 0;
+ this_size = 0;
}
if (biggest_size < this_size) {
biggest_block = this_block;
diff --git a/sys/boot/uboot/lib/glue.c b/sys/boot/uboot/lib/glue.c
index d01e33b..32c4df2 100644
--- a/sys/boot/uboot/lib/glue.c
+++ b/sys/boot/uboot/lib/glue.c
@@ -513,7 +513,7 @@ ub_env_enum(const char *last)
if (!syscall(API_ENV_ENUM, NULL, (uint32_t)last, (uint32_t)&env))
return (NULL);
- if (env == NULL)
+ if (env == NULL || last == env)
/* no more env. variables to enumerate */
return (NULL);
diff --git a/sys/cam/ctl/scsi_ctl.c b/sys/cam/ctl/scsi_ctl.c
index 74ec3df..693fd07 100644
--- a/sys/cam/ctl/scsi_ctl.c
+++ b/sys/cam/ctl/scsi_ctl.c
@@ -104,10 +104,10 @@ struct ctlfe_lun_softc {
uint64_t ccbs_freed;
uint64_t ctios_sent;
uint64_t ctios_returned;
- uint64_t atios_sent;
- uint64_t atios_returned;
- uint64_t inots_sent;
- uint64_t inots_returned;
+ uint64_t atios_alloced;
+ uint64_t atios_freed;
+ uint64_t inots_alloced;
+ uint64_t inots_freed;
/* bus_dma_tag_t dma_tag; */
TAILQ_HEAD(, ccb_hdr) work_queue;
STAILQ_ENTRY(ctlfe_lun_softc) links;
@@ -546,6 +546,7 @@ ctlferegister(struct cam_periph *periph, void *arg)
status = CAM_RESRC_UNAVAIL;
break;
}
+ softc->atios_alloced++;
new_ccb->ccb_h.io_ptr = new_io;
xpt_setup_ccb(&new_ccb->ccb_h, periph->path, /*priority*/ 1);
@@ -553,7 +554,6 @@ ctlferegister(struct cam_periph *periph, void *arg)
new_ccb->ccb_h.cbfcnp = ctlfedone;
new_ccb->ccb_h.flags |= CAM_UNLOCKED;
xpt_action(new_ccb);
- softc->atios_sent++;
status = new_ccb->ccb_h.status;
if ((status & CAM_STATUS_MASK) != CAM_REQ_INPROG) {
ctl_free_io(new_io);
@@ -591,6 +591,7 @@ ctlferegister(struct cam_periph *periph, void *arg)
status = CAM_RESRC_UNAVAIL;
break;
}
+ softc->inots_alloced++;
new_ccb->ccb_h.io_ptr = new_io;
xpt_setup_ccb(&new_ccb->ccb_h, periph->path, /*priority*/ 1);
@@ -598,7 +599,6 @@ ctlferegister(struct cam_periph *periph, void *arg)
new_ccb->ccb_h.cbfcnp = ctlfedone;
new_ccb->ccb_h.flags |= CAM_UNLOCKED;
xpt_action(new_ccb);
- softc->inots_sent++;
status = new_ccb->ccb_h.status;
if ((status & CAM_STATUS_MASK) != CAM_REQ_INPROG) {
/*
@@ -650,10 +650,6 @@ ctlfeoninvalidate(struct cam_periph *periph)
* XXX KDM what do we do now?
*/
}
- xpt_print(periph->path, "LUN removed, %ju ATIOs outstanding, %ju "
- "INOTs outstanding, %d refs\n", softc->atios_sent -
- softc->atios_returned, softc->inots_sent -
- softc->inots_returned, periph->refcount);
bus_softc = softc->parent_softc;
mtx_lock(&bus_softc->lun_softc_mtx);
@@ -666,13 +662,20 @@ ctlfecleanup(struct cam_periph *periph)
{
struct ctlfe_lun_softc *softc;
- xpt_print(periph->path, "%s: Called\n", __func__);
-
softc = (struct ctlfe_lun_softc *)periph->softc;
- /*
- * XXX KDM is there anything else that needs to be done here?
- */
+ KASSERT(softc->ccbs_freed == softc->ccbs_alloced, ("%s: "
+ "ccbs_freed %ju != ccbs_alloced %ju", __func__,
+ softc->ccbs_freed, softc->ccbs_alloced));
+ KASSERT(softc->ctios_returned == softc->ctios_sent, ("%s: "
+ "ctios_returned %ju != ctios_sent %ju", __func__,
+ softc->ctios_returned, softc->ctios_sent));
+ KASSERT(softc->atios_freed == softc->atios_alloced, ("%s: "
+ "atios_freed %ju != atios_alloced %ju", __func__,
+ softc->atios_freed, softc->atios_alloced));
+ KASSERT(softc->inots_freed == softc->inots_alloced, ("%s: "
+ "inots_freed %ju != inots_alloced %ju", __func__,
+ softc->inots_freed, softc->inots_alloced));
free(softc, M_CTLFE);
}
@@ -871,7 +874,6 @@ ctlfestart(struct cam_periph *periph, union ccb *start_ccb)
* Send the ATIO back down to the SIM.
*/
xpt_action((union ccb *)atio);
- softc->atios_sent++;
/*
* If we still have work to do, ask for
@@ -989,11 +991,11 @@ ctlfe_free_ccb(struct cam_periph *periph, union ccb *ccb)
switch (ccb->ccb_h.func_code) {
case XPT_ACCEPT_TARGET_IO:
- softc->atios_returned++;
+ softc->atios_freed++;
break;
case XPT_IMMEDIATE_NOTIFY:
case XPT_NOTIFY_ACKNOWLEDGE:
- softc->inots_returned++;
+ softc->inots_freed++;
break;
default:
break;
@@ -1002,20 +1004,20 @@ ctlfe_free_ccb(struct cam_periph *periph, union ccb *ccb)
ctl_free_io(ccb->ccb_h.io_ptr);
free(ccb, M_CTLFE);
- KASSERT(softc->atios_returned <= softc->atios_sent, ("%s: "
- "atios_returned %ju > atios_sent %ju", __func__,
- softc->atios_returned, softc->atios_sent));
- KASSERT(softc->inots_returned <= softc->inots_sent, ("%s: "
- "inots_returned %ju > inots_sent %ju", __func__,
- softc->inots_returned, softc->inots_sent));
+ KASSERT(softc->atios_freed <= softc->atios_alloced, ("%s: "
+ "atios_freed %ju > atios_alloced %ju", __func__,
+ softc->atios_freed, softc->atios_alloced));
+ KASSERT(softc->inots_freed <= softc->inots_alloced, ("%s: "
+ "inots_freed %ju > inots_alloced %ju", __func__,
+ softc->inots_freed, softc->inots_alloced));
/*
* If we have received all of our CCBs, we can release our
* reference on the peripheral driver. It will probably go away
* now.
*/
- if ((softc->atios_returned == softc->atios_sent)
- && (softc->inots_returned == softc->inots_sent)) {
+ if ((softc->atios_freed == softc->atios_alloced)
+ && (softc->inots_freed == softc->inots_alloced)) {
cam_periph_release_locked(periph);
}
}
@@ -1135,8 +1137,6 @@ ctlfedone(struct cam_periph *periph, union ccb *done_ccb)
atio = &done_ccb->atio;
- softc->atios_returned++;
-
resubmit:
/*
* Allocate a ctl_io, pass it to CTL, and wait for the
@@ -1291,7 +1291,6 @@ ctlfedone(struct cam_periph *periph, union ccb *done_ccb)
if (periph->flags & CAM_PERIPH_INVALID) {
ctlfe_free_ccb(periph, (union ccb *)atio);
} else {
- softc->atios_sent++;
mtx_unlock(mtx);
xpt_action((union ccb *)atio);
return;
@@ -1422,8 +1421,6 @@ ctlfedone(struct cam_periph *periph, union ccb *done_ccb)
inot = &done_ccb->cin1;
- softc->inots_returned++;
-
frozen = (done_ccb->ccb_h.status & CAM_DEV_QFRZN) != 0;
printf("%s: got XPT_IMMEDIATE_NOTIFY status %#x tag %#x "
@@ -1543,7 +1540,6 @@ ctlfedone(struct cam_periph *periph, union ccb *done_ccb)
*/
done_ccb->ccb_h.func_code = XPT_IMMEDIATE_NOTIFY;
xpt_action(done_ccb);
- softc->inots_sent++;
break;
case XPT_SET_SIM_KNOB:
case XPT_GET_SIM_KNOB:
@@ -2043,7 +2039,6 @@ ctlfe_done(union ctl_io *io)
if (periph->flags & CAM_PERIPH_INVALID) {
ctlfe_free_ccb(periph, ccb);
} else {
- softc->atios_sent++;
cam_periph_unlock(periph);
xpt_action(ccb);
return;
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
index 30ca7b9..affda74 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
@@ -1826,7 +1826,7 @@ arc_hdr_destroy(arc_buf_hdr_t *hdr)
if (l2hdr != NULL) {
trim_map_free(l2hdr->b_dev->l2ad_vdev, l2hdr->b_daddr,
- hdr->b_size, 0);
+ l2hdr->b_asize, 0);
list_remove(l2hdr->b_dev->l2ad_buflist, hdr);
arc_buf_l2_cdata_free(hdr);
ARCSTAT_INCR(arcstat_l2_size, -hdr->b_size);
@@ -3868,7 +3868,7 @@ arc_release(arc_buf_t *buf, void *tag)
vdev_space_update(l2hdr->b_dev->l2ad_vdev,
-l2hdr->b_asize, 0, 0);
trim_map_free(l2hdr->b_dev->l2ad_vdev, l2hdr->b_daddr,
- hdr->b_size, 0);
+ l2hdr->b_asize, 0);
kmem_free(l2hdr, sizeof (l2arc_buf_hdr_t));
ARCSTAT_INCR(arcstat_l2_size, -buf_size);
mutex_exit(&l2arc_buflist_mtx);
@@ -4813,7 +4813,7 @@ l2arc_write_done(zio_t *zio)
bytes_dropped += abl2->b_asize;
hdr->b_l2hdr = NULL;
trim_map_free(abl2->b_dev->l2ad_vdev, abl2->b_daddr,
- hdr->b_size, 0);
+ abl2->b_asize, 0);
kmem_free(abl2, sizeof (l2arc_buf_hdr_t));
ARCSTAT_INCR(arcstat_l2_size, -hdr->b_size);
}
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c
index ea3c688..2b55290 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c
@@ -21,7 +21,7 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
- * Copyright (c) 2012, 2014 by Delphix. All rights reserved.
+ * Copyright (c) 2012, 2015 by Delphix. All rights reserved.
* Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
* Copyright (c) 2013, Joyent, Inc. All rights reserved.
*/
@@ -1298,6 +1298,16 @@ dbuf_undirty(dmu_buf_impl_t *db, dmu_tx_t *tx)
dbuf_dirty_record_t *dr, **drp;
ASSERT(txg != 0);
+
+ /*
+ * Due to our use of dn_nlevels below, this can only be called
+ * in open context, unless we are operating on the MOS.
+ * From syncing context, dn_nlevels may be different from the
+ * dn_nlevels used when dbuf was dirtied.
+ */
+ ASSERT(db->db_objset ==
+ dmu_objset_pool(db->db_objset)->dp_meta_objset ||
+ txg != spa_syncing_txg(dmu_objset_spa(db->db_objset)));
ASSERT(db->db_blkid != DMU_BONUS_BLKID);
ASSERT0(db->db_level);
ASSERT(MUTEX_HELD(&db->db_mtx));
@@ -1320,11 +1330,8 @@ dbuf_undirty(dmu_buf_impl_t *db, dmu_tx_t *tx)
ASSERT(db->db.db_size != 0);
- /*
- * Any space we accounted for in dp_dirty_* will be cleaned up by
- * dsl_pool_sync(). This is relatively rare so the discrepancy
- * is not a big deal.
- */
+ dsl_pool_undirty_space(dmu_objset_pool(dn->dn_objset),
+ dr->dr_accounted, txg);
*drp = dr->dr_next;
@@ -1339,7 +1346,7 @@ dbuf_undirty(dmu_buf_impl_t *db, dmu_tx_t *tx)
list_remove(&dr->dr_parent->dt.di.dr_children, dr);
mutex_exit(&dr->dr_parent->dt.di.dr_mtx);
} else if (db->db_blkid == DMU_SPILL_BLKID ||
- db->db_level+1 == dn->dn_nlevels) {
+ db->db_level + 1 == dn->dn_nlevels) {
ASSERT(db->db_blkptr == NULL || db->db_parent == dn->dn_dbuf);
mutex_enter(&dn->dn_mtx);
list_remove(&dn->dn_dirty_records[txg & TXG_MASK], dr);
@@ -1356,11 +1363,6 @@ dbuf_undirty(dmu_buf_impl_t *db, dmu_tx_t *tx)
VERIFY(arc_buf_remove_ref(dr->dt.dl.dr_data, db));
}
- if (db->db_level != 0) {
- mutex_destroy(&dr->dt.di.dr_mtx);
- list_destroy(&dr->dt.di.dr_children);
- }
-
kmem_free(dr, sizeof (dbuf_dirty_record_t));
ASSERT(db->db_dirtycnt > 0);
@@ -2318,7 +2320,7 @@ dbuf_sync_indirect(dbuf_dirty_record_t *dr, dmu_tx_t *tx)
zio = dr->dr_zio;
mutex_enter(&dr->dt.di.dr_mtx);
- dbuf_sync_list(&dr->dt.di.dr_children, tx);
+ dbuf_sync_list(&dr->dt.di.dr_children, db->db_level - 1, tx);
ASSERT(list_head(&dr->dt.di.dr_children) == NULL);
mutex_exit(&dr->dt.di.dr_mtx);
zio_nowait(zio);
@@ -2464,7 +2466,7 @@ dbuf_sync_leaf(dbuf_dirty_record_t *dr, dmu_tx_t *tx)
}
void
-dbuf_sync_list(list_t *list, dmu_tx_t *tx)
+dbuf_sync_list(list_t *list, int level, dmu_tx_t *tx)
{
dbuf_dirty_record_t *dr;
@@ -2481,6 +2483,10 @@ dbuf_sync_list(list_t *list, dmu_tx_t *tx)
DMU_META_DNODE_OBJECT);
break;
}
+ if (dr->dr_dbuf->db_blkid != DMU_BONUS_BLKID &&
+ dr->dr_dbuf->db_blkid != DMU_SPILL_BLKID) {
+ VERIFY3U(dr->dr_dbuf->db_level, ==, level);
+ }
list_remove(list, dr);
if (dr->dr_dbuf->db_level > 0)
dbuf_sync_indirect(dr, tx);
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_tx.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_tx.c
index 1f42704..dff9fab 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_tx.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_tx.c
@@ -21,7 +21,7 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
- * Copyright (c) 2012, 2014 by Delphix. All rights reserved.
+ * Copyright (c) 2012, 2015 by Delphix. All rights reserved.
*/
#include <sys/dmu.h>
@@ -686,7 +686,7 @@ dmu_tx_hold_free(dmu_tx_t *tx, uint64_t object, uint64_t off, uint64_t len)
uint64_t ibyte = i << shift;
err = dnode_next_offset(dn, 0, &ibyte, 2, 1, 0);
i = ibyte >> shift;
- if (err == ESRCH)
+ if (err == ESRCH || i > end)
break;
if (err) {
tx->tx_err = err;
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dnode.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dnode.c
index 938b5d6..a6e0197 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dnode.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dnode.c
@@ -20,7 +20,7 @@
*/
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2012, 2014 by Delphix. All rights reserved.
+ * Copyright (c) 2012, 2015 by Delphix. All rights reserved.
*/
#include <sys/zfs_context.h>
@@ -1492,6 +1492,16 @@ out:
rw_downgrade(&dn->dn_struct_rwlock);
}
+static void
+dnode_dirty_l1(dnode_t *dn, uint64_t l1blkid, dmu_tx_t *tx)
+{
+ dmu_buf_impl_t *db = dbuf_hold_level(dn, 1, l1blkid, FTAG);
+ if (db != NULL) {
+ dmu_buf_will_dirty(&db->db, tx);
+ dbuf_rele(db, FTAG);
+ }
+}
+
void
dnode_free_range(dnode_t *dn, uint64_t off, uint64_t len, dmu_tx_t *tx)
{
@@ -1612,27 +1622,67 @@ dnode_free_range(dnode_t *dn, uint64_t off, uint64_t len, dmu_tx_t *tx)
nblks += 1;
/*
- * Dirty the first and last indirect blocks, as they (and/or their
- * parents) will need to be written out if they were only
- * partially freed. Interior indirect blocks will be themselves freed,
- * by free_children(), so they need not be dirtied. Note that these
- * interior blocks have already been prefetched by dmu_tx_hold_free().
+ * Dirty all the indirect blocks in this range. Note that only
+ * the first and last indirect blocks can actually be written
+ * (if they were partially freed) -- they must be dirtied, even if
+ * they do not exist on disk yet. The interior blocks will
+ * be freed by free_children(), so they will not actually be written.
+ * Even though these interior blocks will not be written, we
+ * dirty them for two reasons:
+ *
+ * - It ensures that the indirect blocks remain in memory until
+ * syncing context. (They have already been prefetched by
+ * dmu_tx_hold_free(), so we don't have to worry about reading
+ * them serially here.)
+ *
+ * - The dirty space accounting will put pressure on the txg sync
+ * mechanism to begin syncing, and to delay transactions if there
+ * is a large amount of freeing. Even though these indirect
+ * blocks will not be written, we could need to write the same
+ * amount of space if we copy the freed BPs into deadlists.
*/
if (dn->dn_nlevels > 1) {
uint64_t first, last;
first = blkid >> epbs;
- if (db = dbuf_hold_level(dn, 1, first, FTAG)) {
- dmu_buf_will_dirty(&db->db, tx);
- dbuf_rele(db, FTAG);
- }
+ dnode_dirty_l1(dn, first, tx);
if (trunc)
last = dn->dn_maxblkid >> epbs;
else
last = (blkid + nblks - 1) >> epbs;
- if (last > first && (db = dbuf_hold_level(dn, 1, last, FTAG))) {
- dmu_buf_will_dirty(&db->db, tx);
- dbuf_rele(db, FTAG);
+ if (last != first)
+ dnode_dirty_l1(dn, last, tx);
+
+ int shift = dn->dn_datablkshift + dn->dn_indblkshift -
+ SPA_BLKPTRSHIFT;
+ for (uint64_t i = first + 1; i < last; i++) {
+ /*
+ * Set i to the blockid of the next non-hole
+ * level-1 indirect block at or after i. Note
+ * that dnode_next_offset() operates in terms of
+ * level-0-equivalent bytes.
+ */
+ uint64_t ibyte = i << shift;
+ int err = dnode_next_offset(dn, DNODE_FIND_HAVELOCK,
+ &ibyte, 2, 1, 0);
+ i = ibyte >> shift;
+ if (i >= last)
+ break;
+
+ /*
+ * Normally we should not see an error, either
+ * from dnode_next_offset() or dbuf_hold_level()
+ * (except for ESRCH from dnode_next_offset).
+ * If there is an i/o error, then when we read
+ * this block in syncing context, it will use
+ * ZIO_FLAG_MUSTSUCCEED, and thus hang/panic according
+ * to the "failmode" property. dnode_next_offset()
+ * doesn't have a flag to indicate MUSTSUCCEED.
+ */
+ if (err != 0)
+ break;
+
+ dnode_dirty_l1(dn, i, tx);
}
}
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dnode_sync.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dnode_sync.c
index 63bfc94..418d318 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dnode_sync.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dnode_sync.c
@@ -21,7 +21,7 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2012, 2014 by Delphix. All rights reserved.
+ * Copyright (c) 2012, 2015 by Delphix. All rights reserved.
*/
#include <sys/zfs_context.h>
@@ -712,7 +712,7 @@ dnode_sync(dnode_t *dn, dmu_tx_t *tx)
mutex_exit(&dn->dn_mtx);
}
- dbuf_sync_list(list, tx);
+ dbuf_sync_list(list, dn->dn_phys->dn_nlevels - 1, tx);
if (!DMU_OBJECT_IS_SPECIAL(dn->dn_object)) {
ASSERT3P(list_head(list), ==, NULL);
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dbuf.h b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dbuf.h
index 8be8ed6b..319406a 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dbuf.h
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dbuf.h
@@ -20,7 +20,7 @@
*/
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2012, 2014 by Delphix. All rights reserved.
+ * Copyright (c) 2012, 2015 by Delphix. All rights reserved.
* Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
*/
@@ -287,7 +287,7 @@ void dbuf_evict(dmu_buf_impl_t *db);
void dbuf_setdirty(dmu_buf_impl_t *db, dmu_tx_t *tx);
void dbuf_unoverride(dbuf_dirty_record_t *dr);
-void dbuf_sync_list(list_t *list, dmu_tx_t *tx);
+void dbuf_sync_list(list_t *list, int level, dmu_tx_t *tx);
void dbuf_release_bp(dmu_buf_impl_t *db);
void dbuf_free_range(struct dnode *dn, uint64_t start, uint64_t end,
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
index 5bd6725..1038a87 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
@@ -5734,8 +5734,6 @@ zfs_getpages(struct vnode *vp, vm_page_t *m, int count, int reqpage)
object = mreq->object;
error = 0;
- KASSERT(vp->v_object == object, ("mismatching object"));
-
if (pcount > 1 && zp->z_blksz > PAGESIZE) {
startoff = rounddown(IDX_TO_OFF(mreq->pindex), zp->z_blksz);
reqstart = OFF_TO_IDX(round_page(startoff));
diff --git a/sys/cddl/contrib/opensolaris/uts/common/sys/sysmacros.h b/sys/cddl/contrib/opensolaris/uts/common/sys/sysmacros.h
index 3003514..aa84f36 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/sys/sysmacros.h
+++ b/sys/cddl/contrib/opensolaris/uts/common/sys/sysmacros.h
@@ -32,6 +32,9 @@
#include <sys/param.h>
#include <sys/isa_defs.h>
+#if defined(__FreeBSD__) && defined(_KERNEL)
+#include <sys/libkern.h>
+#endif
#ifdef __cplusplus
extern "C" {
@@ -382,6 +385,9 @@ extern unsigned char bcd_to_byte[256];
static __inline int
highbit(ulong_t i)
{
+#if defined(__FreeBSD__) && defined(_KERNEL) && defined(HAVE_INLINE_FLSL)
+ return (flsl(i));
+#else
register int h = 1;
if (i == 0)
@@ -407,6 +413,7 @@ highbit(ulong_t i)
h += 1;
}
return (h);
+#endif
}
/*
@@ -416,6 +423,9 @@ highbit(ulong_t i)
static __inline int
highbit64(uint64_t i)
{
+#if defined(__FreeBSD__) && defined(_KERNEL) && defined(HAVE_INLINE_FLSLL)
+ return (flsll(i));
+#else
int h = 1;
if (i == 0)
@@ -439,6 +449,7 @@ highbit64(uint64_t i)
h += 1;
}
return (h);
+#endif
}
#ifdef __cplusplus
diff --git a/sys/conf/NOTES b/sys/conf/NOTES
index 90fc66e..554a234 100644
--- a/sys/conf/NOTES
+++ b/sys/conf/NOTES
@@ -2645,6 +2645,8 @@ device usb
device udbp
# USB Fm Radio
device ufm
+# USB temperature meter
+device ugold
# USB LED
device uled
# Human Interface Device (anything with buttons and dials)
diff --git a/sys/conf/files b/sys/conf/files
index 0217e46..65606b0 100644
--- a/sys/conf/files
+++ b/sys/conf/files
@@ -2545,6 +2545,7 @@ dev/usb/serial/usb_serial.c optional ucom | u3g | uark | ubsa | ubser | \
#
dev/usb/misc/ufm.c optional ufm
dev/usb/misc/udbp.c optional udbp
+dev/usb/misc/ugold.c optional ugold
dev/usb/misc/uled.c optional uled
#
# USB input drivers
diff --git a/sys/conf/files.mips b/sys/conf/files.mips
index 4bc6775a1..f476307 100644
--- a/sys/conf/files.mips
+++ b/sys/conf/files.mips
@@ -61,6 +61,8 @@ libkern/flsll.c standard
libkern/memmove.c standard
libkern/cmpdi2.c optional mips | mipsel
libkern/ucmpdi2.c optional mips | mipsel
+libkern/ashldi3.c standard
+libkern/ashrdi3.c standard
# cfe support
dev/cfe/cfe_api.c optional cfe
diff --git a/sys/contrib/dev/acpica/acpica_prep.sh b/sys/contrib/dev/acpica/acpica_prep.sh
index faf850e..e6bf575 100755
--- a/sys/contrib/dev/acpica/acpica_prep.sh
+++ b/sys/contrib/dev/acpica/acpica_prep.sh
@@ -19,20 +19,20 @@ fulldirs="common compiler components include os_specific"
# files to remove
stripdirs="generate libraries tests tools"
stripfiles="Makefile README accygwin.h acdragonfly.h acdragonflyex.h \
- acefi.h achaiku.h acintel.h aclinux.h aclinuxex.h acmacosx.h \
- acmsvc.h acnetbsd.h acos2.h acwin.h acwin64.h new_table.txt \
- osbsdtbl.c osefitbl.c osefixf.c osfreebsdtbl.c oslinuxtbl.c \
- osunixdir.c osunixmap.c oswindir.c oswintbl.c oswinxf.c \
- readme.txt utclib.c"
+ acefi.h acefiex.h achaiku.h acintel.h aclinux.h aclinuxex.h \
+ acmacosx.h acmsvc.h acnetbsd.h acos2.h acwin.h acwin64.h \
+ new_table.txt osbsdtbl.c osefitbl.c osefixf.c osfreebsdtbl.c \
+ oslinuxtbl.c osunixdir.c osunixmap.c oswindir.c oswintbl.c \
+ oswinxf.c readme.txt utclib.c"
# include files to canonify
-src_headers="acapps.h acbuffer.h accommon.h acconfig.h acdebug.h \
- acdisasm.h acdispat.h acevents.h acexcep.h acglobal.h achware.h \
- acinterp.h aclocal.h acmacros.h acnames.h acnamesp.h acobject.h \
- acopcode.h acoutput.h acparser.h acpi.h acpiosxf.h acpixf.h \
- acpredef.h acresrc.h acrestyp.h acstruct.h actables.h actbl.h \
- actbl1.h actbl2.h actbl3.h actypes.h acutils.h amlcode.h \
- amlresrc.h platform/acenv.h platform/acenvex.h \
+src_headers="acapps.h acbuffer.h acclib.h accommon.h acconfig.h \
+ acdebug.h acdisasm.h acdispat.h acevents.h acexcep.h acglobal.h \
+ achware.h acinterp.h aclocal.h acmacros.h acnames.h acnamesp.h \
+ acobject.h acopcode.h acoutput.h acparser.h acpi.h acpiosxf.h \
+ acpixf.h acpredef.h acresrc.h acrestyp.h acstruct.h actables.h \
+ actbl.h actbl1.h actbl2.h actbl3.h actypes.h acutils.h acuuid.h \
+ amlcode.h amlresrc.h platform/acenv.h platform/acenvex.h \
platform/acfreebsd.h platform/acgcc.h"
comp_headers="aslcompiler.h asldefine.h aslglobal.h aslmessages.h \
aslsupport.l asltypes.h dtcompiler.h dttemplate.h preprocess.h"
diff --git a/sys/contrib/dev/acpica/changes.txt b/sys/contrib/dev/acpica/changes.txt
index 511652f..9abe735 100644
--- a/sys/contrib/dev/acpica/changes.txt
+++ b/sys/contrib/dev/acpica/changes.txt
@@ -1,5 +1,130 @@
----------------------------------------
-08 April 2015. Summary of changes for version 20150515:
+19 June 2015. Summary of changes for version 20150619:
+
+Two regressions in version 20150616 have been addressed:
+
+Fixes some problems/issues with the C library macro removal (ACPI_STRLEN,
+etc.) This update changes ACPICA to only use the standard headers for
+functions, or the prototypes for the local versions of the C library
+functions. Across the source code, this required some additional casts
+for some Clib invocations for portability. Moved all local prototypes to
+a new file, acclib.h
+
+Fixes several problems with recent changes to the handling of the FACS
+table that could cause some systems not to boot.
+
+
+----------------------------------------
+16 June 2015. Summary of changes for version 20150616:
+
+
+1) ACPICA kernel-resident subsystem:
+
+Across the entire ACPICA source code base, the various macros for the C
+library functions (such as ACPI_STRLEN, etc.) have been removed and
+replaced by the standard C library names (strlen, etc.) The original
+purpose for these macros is no longer applicable. This simplification
+reduces the number of macros used in the ACPICA source code
+significantly, improving readability and maintainability.
+
+Implemented support for a new ACPI table, the OSDT. This table, the
+"override" SDT, can be loaded directly by the host OS at boot time. It
+enables the replacement of existing namespace objects that were installed
+via the DSDT and/or SSDTs. The primary purpose for this is to replace
+buggy or incorrect ASL/AML code obtained via the BIOS. The OSDT is slated
+for inclusion in a future version of the ACPI Specification. Lv Zheng/Bob
+Moore.
+
+Added support for systems with (improperly) two FACS tables -- a "32-bit"
+table (via FADT 32-bit legacy field) and a "64-bit" table (via the 64-bit
+X field). This change will support both automatically. There continues to
+be systems found with this issue. This support requires a change to the
+AcpiSetFirmwareWakingVector interface. Also, a public global variable has
+been added to allow the host to select which FACS is desired
+(AcpiGbl_Use32BitFacsAddresses). See the ACPICA reference for more
+details Lv Zheng.
+
+Added a new feature to allow for systems that do not contain an FACS.
+Although this is already supported on hardware-reduced platforms, the
+feature has been extended for all platforms. The reasoning is that we do
+not want to abort the entire ACPICA initialization just because the
+system is seriously buggy and has no FACS.
+
+Fixed a problem where the GUID strings for NFIT tables (in acuuid.h) were
+not correctly transcribed from the ACPI specification in ACPICA version
+20150515.
+
+Implemented support for the _CLS object in the AcpiGetObjectInfo external
+interface.
+
+Updated the definitions of the TCPA and TPM2 ACPI tables to the more
+recent TCG ACPI Specification, December 14, 2014. Table disassembler and
+compiler also updated. Note: The TCPA "server" table is not supported by
+the disassembler/table-compiler at this time.
+
+ACPI 6.0: Added definitions for the new GIC version field in the MADT.
+
+Example Code and Data Size: These are the sizes for the OS-independent
+acpica.lib produced by the Microsoft Visual C++ 9.0 32-bit compiler. The
+debug version of the code includes the debug output trace mechanism and
+has a much larger code and data size.
+
+ Current Release:
+ Non-Debug Version: 100.6K Code, 27.6K Data, 128.2K Total
+ Debug Version: 196.2K Code, 81.0K Data, 277.2K Total
+ Previous Release:
+ Non-Debug Version: 99.9K Code, 27.5K Data, 127.4K Total
+ Debug Version: 195.2K Code, 80.8K Data, 276.0K Total
+
+
+2) iASL Compiler/Disassembler and Tools:
+
+Disassembler: Fixed a problem with the new symbolic operator disassembler
+where incorrect ASL code could be emitted in some cases for the "non-
+commutative" operators -- Subtract, Divide, Modulo, ShiftLeft, and
+ShiftRight. The actual problem cases seem to be rather unusual in common
+ASL code, however. David Box.
+
+Modified the linux version of acpidump to obtain ACPI tables from not
+just /dev/mem (which may not exist) and /sys/firmware/acpi/tables. Lv
+Zheng.
+
+iASL: Fixed a problem where the user preprocessor output file (.i)
+contained extra data that was not expected. The compiler was using this
+file as a temporary file and passed through #line directives in order to
+keep compiler error messages in sync with the input file and line number
+across multiple include files. The (.i) is no longer a temporary file as
+the compiler uses a new, different file for the original purpose.
+
+iASL: Fixed a problem where comments within the original ASL source code
+file were not passed through to the preprocessor output file, nor any
+listing files.
+
+iASL: Fixed some issues for the handling of the "#include" preprocessor
+directive and the similar (but not the same) "Include" ASL operator.
+
+iASL: Add support for the new OSDT in both the disassembler and compiler.
+
+iASL: Fixed a problem with the constant folding support where a Buffer
+object could be incorrectly generated (incorrectly formed) during a
+conversion to a Store() operator.
+
+AcpiHelp: Updated for new NFIT GUIDs, "External" AML opcode, and new
+description text for the _REV predefined name. _REV now permanently
+returns 2, as per the ACPI 6.0 specification.
+
+Debugger: Enhanced the output of the Debug ASL object for references
+produced by the Index operator. For Buffers and strings, only output the
+actual byte pointed to by the index. For packages, only print the single
+package element decoded by the index. Previously, the entire
+buffer/string/package was emitted.
+
+iASL/Table-compiler: Fixed a regression where the "generic" data types
+were no longer recognized, causing errors.
+
+
+----------------------------------------
+15 May 2015. Summary of changes for version 20150515:
This release implements most of ACPI 6.0 as described below.
@@ -34,7 +159,7 @@ iASL disassembler and table compiler: Added ACPI 6.0 changes to existing
tables: FADT, MADT.
iASL preprocessor: Added a new directive to enable inclusion of binary
-blobs into ASL code. The new directive is #includebinary. It takes a
+blobs into ASL code. The new directive is #includebuffer. It takes a
binary file as input and emits a named ascii buffer object into the ASL
code.
diff --git a/sys/contrib/dev/acpica/common/adisasm.c b/sys/contrib/dev/acpica/common/adisasm.c
index 5d0cee2..5942476 100644
--- a/sys/contrib/dev/acpica/common/adisasm.c
+++ b/sys/contrib/dev/acpica/common/adisasm.c
@@ -243,7 +243,7 @@ AdAmlDisassemble (
while (ExternalFileList)
{
ExternalFilename = ExternalFileList->Path;
- if (!ACPI_STRCMP (ExternalFilename, Filename))
+ if (!strcmp (ExternalFilename, Filename))
{
/* Next external file */
diff --git a/sys/contrib/dev/acpica/common/ahids.c b/sys/contrib/dev/acpica/common/ahids.c
index 038d9f6..1af6b41 100644
--- a/sys/contrib/dev/acpica/common/ahids.c
+++ b/sys/contrib/dev/acpica/common/ahids.c
@@ -230,7 +230,7 @@ AcpiAhMatchHardwareId (
for (Info = AslDeviceIds; Info->Name; Info++)
{
- if (!ACPI_STRCMP (HardwareId, Info->Name))
+ if (!strcmp (HardwareId, Info->Name))
{
return (Info);
}
diff --git a/sys/contrib/dev/acpica/common/ahpredef.c b/sys/contrib/dev/acpica/common/ahpredef.c
index 1454880..3026ce3 100644
--- a/sys/contrib/dev/acpica/common/ahpredef.c
+++ b/sys/contrib/dev/acpica/common/ahpredef.c
@@ -249,7 +249,7 @@ const AH_PREDEFINED_NAME AslPredefinedInfo[] =
AH_PREDEF ("_RBW", "Register Bit Width", "Resource Descriptor field"),
AH_PREDEF ("_RDI", "Resource Dependencies for Idle", "Returns a list of dependencies for idle states"),
AH_PREDEF ("_REG", "Region Availability", "Inform AML code of an operation region availability change"),
- AH_PREDEF ("_REV", "Supported ACPI Revision", "Returns the revision of the ACPI specification that is implemented"),
+ AH_PREDEF ("_REV", "Supported Integer Width", "Returns the supported integer width (<= 1: 32 bits only, >=2: both 32 and 64 bits"),
AH_PREDEF ("_RMV", "Removal Status", "Returns a device's removal ability status (docking)"),
AH_PREDEF ("_RNG", "Range", "Memory range type, Resource Descriptor field"),
AH_PREDEF ("_RST", "Device Reset", "Executes a reset on a device"),
diff --git a/sys/contrib/dev/acpica/common/ahuuids.c b/sys/contrib/dev/acpica/common/ahuuids.c
index eeec8b8..46b52eb 100644
--- a/sys/contrib/dev/acpica/common/ahuuids.c
+++ b/sys/contrib/dev/acpica/common/ahuuids.c
@@ -122,7 +122,7 @@ AcpiAhMatchUuid (
AcpiUtConvertStringToUuid (Info->String, UuidBuffer);
- if (!ACPI_MEMCMP (Data, UuidBuffer, UUID_BUFFER_LENGTH))
+ if (!memcmp (Data, UuidBuffer, UUID_BUFFER_LENGTH))
{
return (Info->Description);
}
diff --git a/sys/contrib/dev/acpica/common/dmextern.c b/sys/contrib/dev/acpica/common/dmextern.c
index 2ea54ad..22d54e9 100644
--- a/sys/contrib/dev/acpica/common/dmextern.c
+++ b/sys/contrib/dev/acpica/common/dmextern.c
@@ -224,7 +224,7 @@ AcpiDmNormalizeParentPrefix (
return (NULL);
}
- Length = (ACPI_STRLEN (ParentPath) + ACPI_STRLEN (Path) + 1);
+ Length = (strlen (ParentPath) + strlen (Path) + 1);
if (ParentPath[1])
{
/*
@@ -253,7 +253,7 @@ AcpiDmNormalizeParentPrefix (
*
* Copy the parent path
*/
- ACPI_STRCPY (Fullpath, &ParentPath[Index]);
+ strcpy (Fullpath, &ParentPath[Index]);
/*
* Add dot separator
@@ -261,12 +261,12 @@ AcpiDmNormalizeParentPrefix (
*/
if (ParentPath[1])
{
- ACPI_STRCAT (Fullpath, ".");
+ strcat (Fullpath, ".");
}
/* Copy child path (carat parent prefix(es) were skipped above) */
- ACPI_STRCAT (Fullpath, Path);
+ strcat (Fullpath, Path);
Cleanup:
ACPI_FREE (ParentPath);
@@ -648,13 +648,13 @@ AcpiDmAddNodeToExternalList (
if ((*ExternalPath == AML_ROOT_PREFIX) && (ExternalPath[1]))
{
- Temp = ACPI_ALLOCATE_ZEROED (ACPI_STRLEN (ExternalPath) + 1);
+ Temp = ACPI_ALLOCATE_ZEROED (strlen (ExternalPath) + 1);
if (!Temp)
{
return_VOID;
}
- ACPI_STRCPY (Temp, &ExternalPath[1]);
+ strcpy (Temp, &ExternalPath[1]);
ACPI_FREE (ExternalPath);
ExternalPath = Temp;
}
@@ -806,7 +806,7 @@ AcpiDmCreateNewExternal (
NextExternal = AcpiGbl_ExternalList;
while (NextExternal)
{
- if (!ACPI_STRCMP (ExternalPath, NextExternal->Path))
+ if (!strcmp (ExternalPath, NextExternal->Path))
{
/* Duplicate method, check that the Value (ArgCount) is the same */
@@ -849,7 +849,7 @@ AcpiDmCreateNewExternal (
NewExternal->Value = Value;
NewExternal->Path = ExternalPath;
NewExternal->Type = Type;
- NewExternal->Length = (UINT16) ACPI_STRLEN (ExternalPath);
+ NewExternal->Length = (UINT16) strlen (ExternalPath);
NewExternal->InternalPath = InternalPath;
/* Link the new descriptor into the global list, alphabetically ordered */
diff --git a/sys/contrib/dev/acpica/common/dmrestag.c b/sys/contrib/dev/acpica/common/dmrestag.c
index c457658..4296039 100644
--- a/sys/contrib/dev/acpica/common/dmrestag.c
+++ b/sys/contrib/dev/acpica/common/dmrestag.c
@@ -679,10 +679,10 @@ AcpiGetTagPathname (
* end up in the final compiled AML, it's just an appearance issue for the
* disassembled code.
*/
- Pathname[ACPI_STRLEN (Pathname) - ACPI_NAME_SIZE] = 0;
- ACPI_STRNCAT (Pathname, ResourceNode->Name.Ascii, ACPI_NAME_SIZE);
- ACPI_STRCAT (Pathname, ".");
- ACPI_STRNCAT (Pathname, Tag, ACPI_NAME_SIZE);
+ Pathname[strlen (Pathname) - ACPI_NAME_SIZE] = 0;
+ strncat (Pathname, ResourceNode->Name.Ascii, ACPI_NAME_SIZE);
+ strcat (Pathname, ".");
+ strncat (Pathname, Tag, ACPI_NAME_SIZE);
/* Internalize the namepath to AML format */
diff --git a/sys/contrib/dev/acpica/common/dmtable.c b/sys/contrib/dev/acpica/common/dmtable.c
index 3820c94..0b1f68e 100644
--- a/sys/contrib/dev/acpica/common/dmtable.c
+++ b/sys/contrib/dev/acpica/common/dmtable.c
@@ -528,7 +528,7 @@ AcpiDmDumpDataTable (
TableData = AcpiDmGetTableData (Table->Signature);
if (!TableData)
{
- if (!ACPI_STRNCMP (Table->Signature, "OEM", 3))
+ if (!strncmp (Table->Signature, "OEM", 3))
{
AcpiOsPrintf ("\n**** OEM-defined ACPI table [%4.4s], unknown contents\n\n",
Table->Signature);
@@ -856,7 +856,7 @@ AcpiDmDumpTable (
case ACPI_DMT_STRING:
- ByteLength = ACPI_STRLEN (ACPI_CAST_PTR (char, Target)) + 1;
+ ByteLength = strlen (ACPI_CAST_PTR (char, Target)) + 1;
break;
case ACPI_DMT_GAS:
diff --git a/sys/contrib/dev/acpica/common/dmtbdump.c b/sys/contrib/dev/acpica/common/dmtbdump.c
index 94358e8..67d0f1c 100644
--- a/sys/contrib/dev/acpica/common/dmtbdump.c
+++ b/sys/contrib/dev/acpica/common/dmtbdump.c
@@ -155,7 +155,7 @@ AcpiDmDumpUnicode (
for (i = 0; i < Length; i += 2)
{
- if (!ACPI_IS_PRINT (Buffer[i]))
+ if (!isprint (Buffer[i]))
{
goto DumpRawBuffer;
}
@@ -1701,7 +1701,7 @@ AcpiDmDumpIort (
InfoTable = AcpiDmTableInfoIort1;
Length = ACPI_OFFSET (ACPI_IORT_NAMED_COMPONENT, DeviceName);
String = ACPI_ADD_PTR (char, IortNode, NodeOffset + Length);
- Length += ACPI_STRLEN (String) + 1;
+ Length += strlen (String) + 1;
break;
case ACPI_IORT_NODE_PCI_ROOT_COMPLEX:
@@ -3344,7 +3344,7 @@ AcpiDmDumpStao (
while (Offset < Table->Length)
{
Namepath = ACPI_ADD_PTR (char, Table, Offset);
- StringLength = ACPI_STRLEN (Namepath) + 1;
+ StringLength = strlen (Namepath) + 1;
AcpiDmLineHeader (Offset, StringLength, "Namestring");
AcpiOsPrintf ("\"%s\"\n", Namepath);
diff --git a/sys/contrib/dev/acpica/common/dmtbinfo.c b/sys/contrib/dev/acpica/common/dmtbinfo.c
index a803c70..af67d43 100644
--- a/sys/contrib/dev/acpica/common/dmtbinfo.c
+++ b/sys/contrib/dev/acpica/common/dmtbinfo.c
@@ -113,7 +113,7 @@
#define ACPI_SPMI_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TABLE_SPMI,f)
#define ACPI_SRAT_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TABLE_SRAT,f)
#define ACPI_STAO_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TABLE_STAO,f)
-#define ACPI_TCPA_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TABLE_TCPA,f)
+#define ACPI_TCPA_CLIENT_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TABLE_TCPA_CLIENT,f)
#define ACPI_TPM2_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TABLE_TPM2,f)
#define ACPI_UEFI_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TABLE_UEFI,f)
#define ACPI_WAET_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TABLE_WAET,f)
@@ -2611,15 +2611,15 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoStaoStr[] =
/*******************************************************************************
*
- * TCPA - Trusted Computing Platform Alliance table
+ * TCPA - Trusted Computing Platform Alliance table (Client)
*
******************************************************************************/
ACPI_DMTABLE_INFO AcpiDmTableInfoTcpa[] =
{
- {ACPI_DMT_UINT16, ACPI_TCPA_OFFSET (Reserved), "Reserved", 0},
- {ACPI_DMT_UINT32, ACPI_TCPA_OFFSET (MaxLogLength), "Max Event Log Length", 0},
- {ACPI_DMT_UINT64, ACPI_TCPA_OFFSET (LogAddress), "Event Log Address", 0},
+ {ACPI_DMT_UINT16, ACPI_TCPA_CLIENT_OFFSET (PlatformClass), "Platform Class", 0},
+ {ACPI_DMT_UINT32, ACPI_TCPA_CLIENT_OFFSET (MinimumLogLength), "Min Event Log Length", 0},
+ {ACPI_DMT_UINT64, ACPI_TCPA_CLIENT_OFFSET (LogAddress), "Event Log Address", 0},
ACPI_DMT_TERMINATOR
};
@@ -2632,7 +2632,8 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoTcpa[] =
ACPI_DMTABLE_INFO AcpiDmTableInfoTpm2[] =
{
- {ACPI_DMT_UINT32, ACPI_TPM2_OFFSET (Flags), "Flags", 0},
+ {ACPI_DMT_UINT16, ACPI_TPM2_OFFSET (PlatformClass), "Platform Class", 0},
+ {ACPI_DMT_UINT16, ACPI_TPM2_OFFSET (Reserved), "Reserved", 0},
{ACPI_DMT_UINT64, ACPI_TPM2_OFFSET (ControlAddress), "Control Address", 0},
{ACPI_DMT_UINT32, ACPI_TPM2_OFFSET (StartMethod), "Start Method", 0},
ACPI_DMT_TERMINATOR
diff --git a/sys/contrib/dev/acpica/common/getopt.c b/sys/contrib/dev/acpica/common/getopt.c
index b93156c..4a199c0 100644
--- a/sys/contrib/dev/acpica/common/getopt.c
+++ b/sys/contrib/dev/acpica/common/getopt.c
@@ -145,7 +145,7 @@ AcpiGetopt(
{
return (ACPI_OPT_END);
}
- else if (ACPI_STRCMP (argv[AcpiGbl_Optind], "--") == 0)
+ else if (strcmp (argv[AcpiGbl_Optind], "--") == 0)
{
AcpiGbl_Optind++;
return (ACPI_OPT_END);
@@ -159,7 +159,7 @@ AcpiGetopt(
/* Make sure that the option is legal */
if (CurrentChar == ':' ||
- (OptsPtr = ACPI_STRCHR (opts, CurrentChar)) == NULL)
+ (OptsPtr = strchr (opts, CurrentChar)) == NULL)
{
ACPI_OPTION_ERROR ("Illegal option: -", CurrentChar);
diff --git a/sys/contrib/dev/acpica/compiler/aslanalyze.c b/sys/contrib/dev/acpica/compiler/aslanalyze.c
index 3c3eee8..e9b6fb2 100644
--- a/sys/contrib/dev/acpica/compiler/aslanalyze.c
+++ b/sys/contrib/dev/acpica/compiler/aslanalyze.c
@@ -67,8 +67,8 @@ AnIsInternalMethod (
ACPI_PARSE_OBJECT *Op)
{
- if ((!ACPI_STRCMP (Op->Asl.ExternalName, "\\_OSI")) ||
- (!ACPI_STRCMP (Op->Asl.ExternalName, "_OSI")))
+ if ((!strcmp (Op->Asl.ExternalName, "\\_OSI")) ||
+ (!strcmp (Op->Asl.ExternalName, "_OSI")))
{
return (TRUE);
}
@@ -94,8 +94,8 @@ AnGetInternalMethodReturnType (
ACPI_PARSE_OBJECT *Op)
{
- if ((!ACPI_STRCMP (Op->Asl.ExternalName, "\\_OSI")) ||
- (!ACPI_STRCMP (Op->Asl.ExternalName, "_OSI")))
+ if ((!strcmp (Op->Asl.ExternalName, "\\_OSI")) ||
+ (!strcmp (Op->Asl.ExternalName, "_OSI")))
{
return (ACPI_BTYPE_STRING);
}
@@ -462,7 +462,7 @@ ApCheckForGpeNameConflict (
/* Verify 3rd/4th chars are a valid hex value */
- GpeNumber = ACPI_STRTOUL (&Name[2], NULL, 16);
+ GpeNumber = strtoul (&Name[2], NULL, 16);
if (GpeNumber == ACPI_UINT32_MAX)
{
return;
diff --git a/sys/contrib/dev/acpica/compiler/aslascii.c b/sys/contrib/dev/acpica/compiler/aslascii.c
index 08e4630..1583dc3 100644
--- a/sys/contrib/dev/acpica/compiler/aslascii.c
+++ b/sys/contrib/dev/acpica/compiler/aslascii.c
@@ -226,7 +226,7 @@ FlCheckForAscii (
/* Ensure character is either printable or a "space" char */
- else if (!ACPI_IS_PRINT (Byte) && !ACPI_IS_SPACE (Byte))
+ else if (!isprint (Byte) && !isspace (Byte))
{
if ((BadBytes < 10) && (DisplayErrors))
{
diff --git a/sys/contrib/dev/acpica/compiler/aslcodegen.c b/sys/contrib/dev/acpica/compiler/aslcodegen.c
index 8dd30f3..a01afb7 100644
--- a/sys/contrib/dev/acpica/compiler/aslcodegen.c
+++ b/sys/contrib/dev/acpica/compiler/aslcodegen.c
@@ -110,7 +110,7 @@ CgGenerateAmlOutput (
DbgPrint (ASL_TREE_OUTPUT,
"%*s Value P_Op A_Op OpLen PByts Len SubLen PSubLen OpPtr"
- " Parent Child Next Flags AcTyp Final Col L\n",
+ " Parent Child Next Flags AcTyp Final Col L# EL# LL# ELL#\n",
76, " ");
CgCloseTable ();
@@ -145,7 +145,7 @@ CgAmlWriteWalk (
"Final parse tree used for AML output:\n");
DbgPrint (ASL_TREE_OUTPUT,
"%*s Value P_Op A_Op OpLen PByts Len SubLen PSubLen OpPtr"
- " Parent Child Next Flags AcTyp Final Col L\n",
+ " Parent Child Next Flags AcTyp Final Col L# EL# LL# ELL#\n",
76, " ");
}
@@ -169,7 +169,7 @@ CgAmlWriteWalk (
DbgPrint (ASL_TREE_OUTPUT,
"%08X %04X %04X %01X %04X %04X %04X %04X "
- "%08X %08X %08X %08X %08X %08X %04X %02d %02d\n",
+ "%08X %08X %08X %08X %08X %08X %04X %02d %02d %02d %02d %02d\n",
/* 1 */ (UINT32) Op->Asl.Value.Integer,
/* 2 */ Op->Asl.ParseOpcode,
/* 3 */ Op->Asl.AmlOpcode,
@@ -186,7 +186,10 @@ CgAmlWriteWalk (
/* 14 */ Op->Asl.AcpiBtype,
/* 15 */ Op->Asl.FinalAmlLength,
/* 16 */ Op->Asl.Column,
- /* 17 */ Op->Asl.LineNumber);
+ /* 17 */ Op->Asl.LineNumber,
+ /* 18 */ Op->Asl.EndLine,
+ /* 19 */ Op->Asl.LogicalLineNumber,
+ /* 20 */ Op->Asl.EndLogicalLine);
/* Generate the AML for this node */
diff --git a/sys/contrib/dev/acpica/compiler/aslcompile.c b/sys/contrib/dev/acpica/compiler/aslcompile.c
index 0b0ca7a..9aaac3b 100644
--- a/sys/contrib/dev/acpica/compiler/aslcompile.c
+++ b/sys/contrib/dev/acpica/compiler/aslcompile.c
@@ -103,6 +103,9 @@ CmDoCompile (
/* Preprocessor */
PrDoPreprocess ();
+ Gbl_CurrentLineNumber = 1;
+ Gbl_LogicalLineNumber = 1;
+
if (Gbl_PreprocessOnly)
{
UtEndEvent (Event);
@@ -112,6 +115,7 @@ CmDoCompile (
}
UtEndEvent (Event);
+
/* Build the parse tree */
Event = UtBeginEvent ("Parse source code and build parse tree");
@@ -708,7 +712,7 @@ CmCleanupAndExit (
/* Close all open files */
/*
- * Take care with the preprocessor file (.i), it might be the same
+ * Take care with the preprocessor file (.pre), it might be the same
* as the "input" file, depending on where the compiler has terminated
* or aborted. Prevent attempt to close the same file twice in
* loop below.
@@ -733,10 +737,9 @@ CmCleanupAndExit (
FlDeleteFile (ASL_FILE_AML_OUTPUT);
}
- /* Delete the preprocessor output file (.i) unless -li flag is set */
+ /* Delete the preprocessor temp file unless full debug was specified */
- if (!Gbl_PreprocessorOutputFlag &&
- Gbl_PreprocessFlag)
+ if (Gbl_PreprocessFlag && !Gbl_KeepPreprocessorTempFile)
{
FlDeleteFile (ASL_FILE_PREPROCESSOR);
}
@@ -752,8 +755,6 @@ CmCleanupAndExit (
* Note: Handles are cleared by FlCloseFile above, so we look at the
* filename instead, to determine if the .SRC file was actually
* created.
- *
- * TBD: SourceOutput should be .TMP, then rename if we want to keep it?
*/
if (!Gbl_SourceOutputFlag)
{
diff --git a/sys/contrib/dev/acpica/compiler/aslcompiler.h b/sys/contrib/dev/acpica/compiler/aslcompiler.h
index 181b36c..f84f988 100644
--- a/sys/contrib/dev/acpica/compiler/aslcompiler.h
+++ b/sys/contrib/dev/acpica/compiler/aslcompiler.h
@@ -1003,7 +1003,7 @@ UtDoConstant (
char *String);
ACPI_STATUS
-UtStrtoul64 (
+stroul64 (
char *String,
UINT32 Base,
UINT64 *RetInteger);
diff --git a/sys/contrib/dev/acpica/compiler/aslcompiler.l b/sys/contrib/dev/acpica/compiler/aslcompiler.l
index 621f5ae..6a3541b 100644
--- a/sys/contrib/dev/acpica/compiler/aslcompiler.l
+++ b/sys/contrib/dev/acpica/compiler/aslcompiler.l
@@ -709,7 +709,7 @@ NamePathTail [.]{NameSeg}
return (PARSEOP_NAMESTRING); }
. { count (1);
- if (ACPI_IS_PRINT (*AslCompilertext))
+ if (isprint ((int) *AslCompilertext))
{
sprintf (MsgBuffer,
"Invalid character (%c), expecting ASL keyword or name",
diff --git a/sys/contrib/dev/acpica/compiler/asldefine.h b/sys/contrib/dev/acpica/compiler/asldefine.h
index 0697276..0b5f614 100644
--- a/sys/contrib/dev/acpica/compiler/asldefine.h
+++ b/sys/contrib/dev/acpica/compiler/asldefine.h
@@ -105,7 +105,8 @@
/* filename suffixes for output files */
-#define FILE_SUFFIX_PREPROCESSOR "i"
+#define FILE_SUFFIX_PREPROC_USER "i "
+#define FILE_SUFFIX_PREPROCESSOR "pre"
#define FILE_SUFFIX_AML_CODE "aml"
#define FILE_SUFFIX_MAP "map"
#define FILE_SUFFIX_LISTING "lst"
@@ -136,6 +137,8 @@
#define ASL_ABORT TRUE
#define ASL_NO_ABORT FALSE
#define ASL_EOF ACPI_UINT32_MAX
+#define ASL_WITHIN_COMMENT (ACPI_UINT32_MAX -1)
+#define ASL_BLANK_LINE (ACPI_UINT32_MAX -1)
/* Listings */
diff --git a/sys/contrib/dev/acpica/compiler/aslerror.c b/sys/contrib/dev/acpica/compiler/aslerror.c
index 9b8928c..870e30b 100644
--- a/sys/contrib/dev/acpica/compiler/aslerror.c
+++ b/sys/contrib/dev/acpica/compiler/aslerror.c
@@ -561,11 +561,11 @@ AslCommonError2 (
/* Keep a copy of the extra message */
- ACPI_STRCPY (MessageBuffer, ExtraMessage);
+ strcpy (MessageBuffer, ExtraMessage);
}
LineBuffer = UtLocalCalloc (strlen (SourceLine) + 1);
- ACPI_STRCPY (LineBuffer, SourceLine);
+ strcpy (LineBuffer, SourceLine);
/* Initialize the error node */
@@ -647,7 +647,7 @@ AslCommonError (
/* Keep a copy of the extra message */
- ACPI_STRCPY (MessageBuffer, ExtraMessage);
+ strcpy (MessageBuffer, ExtraMessage);
}
/* Initialize the error node */
diff --git a/sys/contrib/dev/acpica/compiler/aslfileio.c b/sys/contrib/dev/acpica/compiler/aslfileio.c
index cf726dd..3feb8ea 100644
--- a/sys/contrib/dev/acpica/compiler/aslfileio.c
+++ b/sys/contrib/dev/acpica/compiler/aslfileio.c
@@ -218,6 +218,19 @@ FlWriteFile (
FlFileError (FileId, ASL_MSG_WRITE);
AslAbort ();
}
+
+ if ((FileId == ASL_FILE_PREPROCESSOR) && Gbl_PreprocessorOutputFlag)
+ {
+ /* Duplicate the output to the user preprocessor (.i) file */
+
+ Actual = fwrite ((char *) Buffer, 1, Length,
+ Gbl_Files[ASL_FILE_PREPROCESSOR_USER].Handle);
+ if (Actual != Length)
+ {
+ FlFileError (FileId, ASL_MSG_WRITE);
+ AslAbort ();
+ }
+ }
}
@@ -247,7 +260,6 @@ FlPrintFile (
va_start (Args, Format);
-
Actual = vfprintf (Gbl_Files[FileId].Handle, Format, Args);
va_end (Args);
@@ -256,6 +268,30 @@ FlPrintFile (
FlFileError (FileId, ASL_MSG_WRITE);
AslAbort ();
}
+
+ if ((FileId == ASL_FILE_PREPROCESSOR) && Gbl_PreprocessorOutputFlag)
+ {
+ /*
+ * Duplicate the output to the user preprocessor (.i) file,
+ * except: no #line directives.
+ */
+ if (!strncmp (Format, "#line", 5))
+ {
+ return;
+ }
+
+ va_start (Args, Format);
+ Actual = vfprintf (Gbl_Files[ASL_FILE_PREPROCESSOR_USER].Handle,
+ Format, Args);
+ va_end (Args);
+
+ if (Actual == -1)
+ {
+ FlFileError (FileId, ASL_MSG_WRITE);
+ AslAbort ();
+ }
+ }
+
}
diff --git a/sys/contrib/dev/acpica/compiler/aslfiles.c b/sys/contrib/dev/acpica/compiler/aslfiles.c
index d8c9ed5..37043cb 100644
--- a/sys/contrib/dev/acpica/compiler/aslfiles.c
+++ b/sys/contrib/dev/acpica/compiler/aslfiles.c
@@ -43,6 +43,7 @@
#include <contrib/dev/acpica/compiler/aslcompiler.h>
#include <contrib/dev/acpica/include/acapps.h>
+#include <contrib/dev/acpica/compiler/dtcompiler.h>
#define _COMPONENT ACPI_COMPILER
ACPI_MODULE_NAME ("aslfiles")
@@ -84,7 +85,6 @@ FlSetLineNumber (
LineNumber, Gbl_LogicalLineNumber);
Gbl_CurrentLineNumber = LineNumber;
- Gbl_LogicalLineNumber = LineNumber;
}
@@ -303,6 +303,7 @@ FlOpenIncludeWithPrefix (
{
FILE *IncludeFile;
char *Pathname;
+ UINT32 OriginalLineNumber;
/* Build the full pathname to the file */
@@ -322,13 +323,20 @@ FlOpenIncludeWithPrefix (
return (NULL);
}
-#ifdef _MUST_HANDLE_COMMENTS
/*
- * Check entire include file for any # preprocessor directives.
+ * Check the entire include file for any # preprocessor directives.
* This is because there may be some confusion between the #include
- * preprocessor directive and the ASL Include statement.
+ * preprocessor directive and the ASL Include statement. A file included
+ * by the ASL include cannot contain preprocessor directives because
+ * the preprocessor has already run by the time the ASL include is
+ * recognized (by the compiler, not the preprocessor.)
+ *
+ * Note: DtGetNextLine strips/ignores comments.
+ * Save current line number since DtGetNextLine modifies it.
*/
- while (fgets (Gbl_CurrentLineBuffer, Gbl_LineBufferSize, IncludeFile))
+ Gbl_CurrentLineNumber--;
+ OriginalLineNumber = Gbl_CurrentLineNumber;
+ while (DtGetNextLine (IncludeFile, DT_ALLOW_MULTILINE_QUOTES) != ASL_EOF)
{
if (Gbl_CurrentLineBuffer[0] == '#')
{
@@ -336,7 +344,7 @@ FlOpenIncludeWithPrefix (
Op, "use #include instead");
}
}
-#endif
+ Gbl_CurrentLineNumber = OriginalLineNumber;
/* Must seek back to the start of the file */
@@ -579,8 +587,6 @@ FlOpenMiscOutputFiles (
/* Open the debug file as STDERR, text mode */
- /* TBD: hide this behind a FlReopenFile function */
-
Gbl_Files[ASL_FILE_DEBUG_OUTPUT].Filename = Filename;
Gbl_Files[ASL_FILE_DEBUG_OUTPUT].Handle =
freopen (Filename, "w+t", stderr);
@@ -588,13 +594,15 @@ FlOpenMiscOutputFiles (
if (!Gbl_Files[ASL_FILE_DEBUG_OUTPUT].Handle)
{
/*
- * A problem with freopen is that on error,
- * we no longer have stderr.
+ * A problem with freopen is that on error, we no longer
+ * have stderr and cannot emit normal error messages.
+ * Emit error to stdout, close files, and exit.
*/
- Gbl_DebugFlag = FALSE;
- memcpy (stderr, stdout, sizeof (FILE));
- FlFileError (ASL_FILE_DEBUG_OUTPUT, ASL_MSG_DEBUG_FILENAME);
- AslAbort ();
+ fprintf (stdout,
+ "\nCould not open debug output file: %s\n\n", Filename);
+
+ CmCleanupAndExit ();
+ exit (1);
}
AslCompilerSignon (ASL_FILE_DEBUG_OUTPUT);
@@ -621,7 +629,7 @@ FlOpenMiscOutputFiles (
AslCompilerFileHeader (ASL_FILE_LISTING_OUTPUT);
}
- /* Create the preprocessor output file if preprocessor enabled */
+ /* Create the preprocessor output temp file if preprocessor enabled */
if (Gbl_PreprocessFlag)
{
@@ -636,6 +644,23 @@ FlOpenMiscOutputFiles (
FlOpenFile (ASL_FILE_PREPROCESSOR, Filename, "w+t");
}
+ /*
+ * Create the "user" preprocessor output file if -li flag set.
+ * Note, this file contains no embedded #line directives.
+ */
+ if (Gbl_PreprocessorOutputFlag)
+ {
+ Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_PREPROC_USER);
+ if (!Filename)
+ {
+ AslCommonError (ASL_ERROR, ASL_MSG_PREPROCESSOR_FILENAME,
+ 0, 0, 0, 0, NULL, NULL);
+ return (AE_ERROR);
+ }
+
+ FlOpenFile (ASL_FILE_PREPROCESSOR_USER, Filename, "w+t");
+ }
+
/* All done for data table compiler */
if (Gbl_FileType == ASL_INPUT_TYPE_ASCII_DATA)
diff --git a/sys/contrib/dev/acpica/compiler/aslfold.c b/sys/contrib/dev/acpica/compiler/aslfold.c
index 26b786d..af7a019 100644
--- a/sys/contrib/dev/acpica/compiler/aslfold.c
+++ b/sys/contrib/dev/acpica/compiler/aslfold.c
@@ -236,6 +236,8 @@ OpcAmlCheckForConstant (
*/
if (WalkState->Opcode == AML_BUFFER_OP)
{
+ DbgPrint (ASL_PARSE_OUTPUT,
+ "\nBuffer+Buffer->Buffer constant reduction is not supported yet");
Status = AE_TYPE;
goto CleanupAndExit;
}
@@ -380,10 +382,12 @@ TrSimpleConstantReduction (
return (Status);
}
+ /* Disconnect any existing children, install new constant */
+
+ Op->Asl.Child = NULL;
TrInstallReducedConstant (Op, ObjDesc);
UtSetParseOpName (Op);
- Op->Asl.Child = NULL;
return (AE_OK);
}
@@ -494,6 +498,10 @@ TrTransformToStoreOp (
goto EvalError;
}
+ /* Truncate any subtree expressions, they have been evaluated */
+
+ Child1->Asl.Child = NULL;
+
/* Folded constant is in ObjDesc, store into Child1 */
TrInstallReducedConstant (Child1, ObjDesc);
@@ -505,11 +513,6 @@ TrTransformToStoreOp (
UtSetParseOpName (Op);
Op->Common.Parent = OriginalParent;
- /* Truncate any subtree expressions, they have been evaluated */
-
- Child1->Asl.Child = NULL;
- Child2->Asl.Child = NULL;
-
/* First child is the folded constant */
/* Second child will be the target */
@@ -547,7 +550,8 @@ TrInstallReducedConstant (
ACPI_PARSE_OBJECT *Op,
ACPI_OPERAND_OBJECT *ObjDesc)
{
- ACPI_PARSE_OBJECT *RootOp;
+ ACPI_PARSE_OBJECT *LengthOp;
+ ACPI_PARSE_OBJECT *DataOp;
TotalFolds++;
@@ -574,17 +578,22 @@ TrInstallReducedConstant (
Op->Asl.ParseOpcode = PARSEOP_STRING_LITERAL;
Op->Common.AmlOpcode = AML_STRING_OP;
- Op->Asl.AmlLength = ACPI_STRLEN (ObjDesc->String.Pointer) + 1;
+ Op->Asl.AmlLength = strlen (ObjDesc->String.Pointer) + 1;
Op->Common.Value.String = ObjDesc->String.Pointer;
DbgPrint (ASL_PARSE_OUTPUT,
"Constant expression reduced to (STRING) %s\n\n",
Op->Common.Value.String);
-
break;
case ACPI_TYPE_BUFFER:
-
+ /*
+ * Create a new parse subtree of the form:
+ *
+ * BUFFER (Buffer AML opcode)
+ * INTEGER (Buffer length in bytes)
+ * RAW_DATA (Buffer byte data)
+ */
Op->Asl.ParseOpcode = PARSEOP_BUFFER;
Op->Common.AmlOpcode = AML_BUFFER_OP;
Op->Asl.CompileFlags = NODE_AML_PACKAGE;
@@ -592,28 +601,24 @@ TrInstallReducedConstant (
/* Child node is the buffer length */
- RootOp = TrAllocateNode (PARSEOP_INTEGER);
+ LengthOp = TrAllocateNode (PARSEOP_INTEGER);
- RootOp->Asl.AmlOpcode = AML_DWORD_OP;
- RootOp->Asl.Value.Integer = ObjDesc->Buffer.Length;
- RootOp->Asl.Parent = Op;
+ LengthOp->Asl.AmlOpcode = AML_DWORD_OP;
+ LengthOp->Asl.Value.Integer = ObjDesc->Buffer.Length;
+ LengthOp->Asl.Parent = Op;
+ (void) OpcSetOptimalIntegerSize (LengthOp);
- (void) OpcSetOptimalIntegerSize (RootOp);
-
- Op->Asl.Child = RootOp;
- Op = RootOp;
- UtSetParseOpName (Op);
+ Op->Asl.Child = LengthOp;
- /* Peer to the child is the raw buffer data */
+ /* Next child is the raw buffer data */
- RootOp = TrAllocateNode (PARSEOP_RAW_DATA);
- RootOp->Asl.AmlOpcode = AML_RAW_DATA_BUFFER;
- RootOp->Asl.AmlLength = ObjDesc->Buffer.Length;
- RootOp->Asl.Value.String = (char *) ObjDesc->Buffer.Pointer;
- RootOp->Asl.Parent = Op->Asl.Parent;
+ DataOp = TrAllocateNode (PARSEOP_RAW_DATA);
+ DataOp->Asl.AmlOpcode = AML_RAW_DATA_BUFFER;
+ DataOp->Asl.AmlLength = ObjDesc->Buffer.Length;
+ DataOp->Asl.Value.String = (char *) ObjDesc->Buffer.Pointer;
+ DataOp->Asl.Parent = Op;
- Op->Asl.Next = RootOp;
- Op = RootOp;
+ LengthOp->Asl.Next = DataOp;
DbgPrint (ASL_PARSE_OUTPUT,
"Constant expression reduced to (BUFFER) length %X\n\n",
diff --git a/sys/contrib/dev/acpica/compiler/aslglobal.h b/sys/contrib/dev/acpica/compiler/aslglobal.h
index c61b8ff..0696b67 100644
--- a/sys/contrib/dev/acpica/compiler/aslglobal.h
+++ b/sys/contrib/dev/acpica/compiler/aslglobal.h
@@ -73,6 +73,7 @@ ASL_FILE_INFO Gbl_Files [ASL_NUM_FILES] =
{NULL, NULL, "Binary Output:", "AML Output"},
{NULL, NULL, "Source Output:", "Source Output"},
{NULL, NULL, "Preprocessor: ", "Preprocessor Output"},
+ {NULL, NULL, "Preprocessor: ", "Preprocessor Temp File"},
{NULL, NULL, "Listing File: ", "Listing Output"},
{NULL, NULL, "Hex Dump: ", "Hex Table Output"},
{NULL, NULL, "Namespace: ", "Namespace Output"},
@@ -123,10 +124,10 @@ ASL_EXTERN char ASL_INIT_GLOBAL (*Gbl_CurrentLineBuffer, NUL
ASL_EXTERN char ASL_INIT_GLOBAL (*Gbl_LineBufPtr, NULL);
ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_LineBufferSize, ASL_DEFAULT_LINE_BUFFER_SIZE);
ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_CurrentColumn, 0);
-ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_PreviousLineNumber, 0);
ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_CurrentLineNumber, 1);
ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_LogicalLineNumber, 1);
ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_CurrentLineOffset, 0);
+ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_OriginalInputFileSize, 0);
ASL_EXTERN UINT8 ASL_INIT_GLOBAL (Gbl_SyntaxError, 0);
/* Exception reporting */
@@ -146,6 +147,7 @@ ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_UseDefaultAmlFilename,
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_MapfileFlag, FALSE);
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_NsOutputFlag, FALSE);
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_PreprocessorOutputFlag, FALSE);
+ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_KeepPreprocessorTempFile, FALSE);
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_DebugFlag, FALSE);
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_AsmOutputFlag, FALSE);
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_C_OutputFlag, FALSE);
diff --git a/sys/contrib/dev/acpica/compiler/aslmain.c b/sys/contrib/dev/acpica/compiler/aslmain.c
index 99745ad..611183a 100644
--- a/sys/contrib/dev/acpica/compiler/aslmain.c
+++ b/sys/contrib/dev/acpica/compiler/aslmain.c
@@ -261,7 +261,7 @@ AslSignalHandler (
/* Close all open files */
- Gbl_Files[ASL_FILE_PREPROCESSOR].Handle = NULL; /* the .i file is same as source file */
+ Gbl_Files[ASL_FILE_PREPROCESSOR].Handle = NULL; /* the .pre file is same as source file */
for (i = ASL_FILE_INPUT; i < ASL_MAX_FILE_TYPE; i++)
{
diff --git a/sys/contrib/dev/acpica/compiler/aslmapenter.c b/sys/contrib/dev/acpica/compiler/aslmapenter.c
index 87ad28a..2d2b863 100644
--- a/sys/contrib/dev/acpica/compiler/aslmapenter.c
+++ b/sys/contrib/dev/acpica/compiler/aslmapenter.c
@@ -239,7 +239,7 @@ MpCreateGpioInfo (
/* Sort on source DeviceName first */
while (NextGpio &&
- (ACPI_STRCMP (DeviceName, NextGpio->DeviceName) > 0))
+ (strcmp (DeviceName, NextGpio->DeviceName) > 0))
{
PrevGpio = NextGpio;
NextGpio = NextGpio->Next;
@@ -249,7 +249,7 @@ MpCreateGpioInfo (
while (NextGpio &&
(NextGpio->PinNumber < PinNumber) &&
- !ACPI_STRCMP (DeviceName, NextGpio->DeviceName))
+ !strcmp (DeviceName, NextGpio->DeviceName))
{
PrevGpio = NextGpio;
NextGpio = NextGpio->Next;
@@ -316,7 +316,7 @@ MpCreateSerialInfo (
/* Sort on source DeviceName */
while (NextSerial &&
- (ACPI_STRCMP (DeviceName, NextSerial->DeviceName) > 0))
+ (strcmp (DeviceName, NextSerial->DeviceName) > 0))
{
PrevSerial = NextSerial;
NextSerial = NextSerial->Next;
@@ -326,7 +326,7 @@ MpCreateSerialInfo (
while (NextSerial &&
(NextSerial->Address < Address) &&
- !ACPI_STRCMP (DeviceName, NextSerial->DeviceName))
+ !strcmp (DeviceName, NextSerial->DeviceName))
{
PrevSerial = NextSerial;
NextSerial = NextSerial->Next;
diff --git a/sys/contrib/dev/acpica/compiler/aslmapoutput.c b/sys/contrib/dev/acpica/compiler/aslmapoutput.c
index 622b1bd..1cf1e53 100644
--- a/sys/contrib/dev/acpica/compiler/aslmapoutput.c
+++ b/sys/contrib/dev/acpica/compiler/aslmapoutput.c
@@ -207,7 +207,7 @@ MpEmitGpioInfo (
/* Print header info for the controller itself */
if (!PrevDeviceName ||
- ACPI_STRCMP (PrevDeviceName, Info->DeviceName))
+ strcmp (PrevDeviceName, Info->DeviceName))
{
FlPrintFile (ASL_FILE_MAP_OUTPUT,
"\n\nGPIO Controller: %-8s %-28s",
@@ -360,7 +360,7 @@ MpEmitSerialInfo (
/* Print header info for the controller itself */
if (!PrevDeviceName ||
- ACPI_STRCMP (PrevDeviceName, Info->DeviceName))
+ strcmp (PrevDeviceName, Info->DeviceName))
{
FlPrintFile (ASL_FILE_MAP_OUTPUT, "\n\n%s Controller: ",
Type);
diff --git a/sys/contrib/dev/acpica/compiler/aslmethod.c b/sys/contrib/dev/acpica/compiler/aslmethod.c
index fa9216e..bee488f 100644
--- a/sys/contrib/dev/acpica/compiler/aslmethod.c
+++ b/sys/contrib/dev/acpica/compiler/aslmethod.c
@@ -430,7 +430,7 @@ MtMethodAnalysisWalkBegin (
/* Special typechecking for _HID */
- if (!ACPI_STRCMP (METHOD_NAME__HID, Op->Asl.NameSeg))
+ if (!strcmp (METHOD_NAME__HID, Op->Asl.NameSeg))
{
Next = Op->Asl.Child->Asl.Next;
AnCheckId (Next, ASL_TYPE_HID);
@@ -438,7 +438,7 @@ MtMethodAnalysisWalkBegin (
/* Special typechecking for _CID */
- else if (!ACPI_STRCMP (METHOD_NAME__CID, Op->Asl.NameSeg))
+ else if (!strcmp (METHOD_NAME__CID, Op->Asl.NameSeg))
{
Next = Op->Asl.Child->Asl.Next;
diff --git a/sys/contrib/dev/acpica/compiler/aslopcodes.c b/sys/contrib/dev/acpica/compiler/aslopcodes.c
index d4dbbe3..43628f9 100644
--- a/sys/contrib/dev/acpica/compiler/aslopcodes.c
+++ b/sys/contrib/dev/acpica/compiler/aslopcodes.c
@@ -636,7 +636,7 @@ OpcDoEisaId (
* The EISAID string must be exactly 7 characters and of the form
* "UUUXXXX" -- 3 uppercase letters and 4 hex digits (e.g., "PNP0001")
*/
- if (ACPI_STRLEN (InString) != 7)
+ if (strlen (InString) != 7)
{
Status = AE_BAD_PARAMETER;
}
@@ -855,7 +855,7 @@ OpcFindName (
for (i = 0, Str = List[0]; Str; i++, Str = List[i])
{
- if (!(ACPI_STRNCMP (Str, Name, ACPI_STRLEN (Name))))
+ if (!(strncmp (Str, Name, strlen (Name))))
{
*Index = i;
return (TRUE);
@@ -907,7 +907,7 @@ OpcDoPld (
return;
}
- ACPI_MEMSET (&PldInfo, 0, sizeof (ACPI_PLD_INFO));
+ memset (&PldInfo, 0, sizeof (ACPI_PLD_INFO));
Node = Op->Asl.Child;
while (Node)
diff --git a/sys/contrib/dev/acpica/compiler/asloperands.c b/sys/contrib/dev/acpica/compiler/asloperands.c
index b2972d4..df63357 100644
--- a/sys/contrib/dev/acpica/compiler/asloperands.c
+++ b/sys/contrib/dev/acpica/compiler/asloperands.c
@@ -932,7 +932,7 @@ OpnDoDefinitionBlock (
if (Child->Asl.Value.String)
{
Gbl_TableSignature = Child->Asl.Value.String;
- if (ACPI_STRLEN (Gbl_TableSignature) != 4)
+ if (strlen (Gbl_TableSignature) != 4)
{
AslError (ASL_ERROR, ASL_MSG_TABLE_SIGNATURE, Child,
"Length not exactly 4");
@@ -967,9 +967,9 @@ OpnDoDefinitionBlock (
Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
if (Child->Asl.Value.String)
{
- Length = ACPI_STRLEN (Child->Asl.Value.String);
+ Length = strlen (Child->Asl.Value.String);
Gbl_TableId = UtStringCacheCalloc (Length + 1);
- ACPI_STRCPY (Gbl_TableId, Child->Asl.Value.String);
+ strcpy (Gbl_TableId, Child->Asl.Value.String);
/*
* Convert anything non-alphanumeric to an underscore. This
diff --git a/sys/contrib/dev/acpica/compiler/aslopt.c b/sys/contrib/dev/acpica/compiler/aslopt.c
index 1079f9c..a65a25e 100644
--- a/sys/contrib/dev/acpica/compiler/aslopt.c
+++ b/sys/contrib/dev/acpica/compiler/aslopt.c
@@ -168,9 +168,9 @@ OptSearchToRoot (
/* We must allocate a new string for the name (TargetPath gets deleted) */
*NewPath = UtStringCacheCalloc (ACPI_NAME_SIZE + 1);
- ACPI_STRCPY (*NewPath, Path);
+ strcpy (*NewPath, Path);
- if (ACPI_STRNCMP (*NewPath, "_T_", 3))
+ if (strncmp (*NewPath, "_T_", 3))
{
AslError (ASL_OPTIMIZATION, ASL_MSG_SINGLE_NAME_OPTIMIZATION, Op,
*NewPath);
@@ -341,7 +341,7 @@ OptBuildShortestPath (
Index = TargetPath->Length;
}
- ACPI_STRCPY (&NewPathExternal[i], &((char *) TargetPath->Pointer)[Index]);
+ strcpy (&NewPathExternal[i], &((char *) TargetPath->Pointer)[Index]);
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, " %-24s", NewPathExternal));
/*
@@ -358,11 +358,11 @@ OptBuildShortestPath (
return (Status);
}
- if (ACPI_STRLEN (NewPath) >= AmlNameStringLength)
+ if (strlen (NewPath) >= AmlNameStringLength)
{
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS,
" NOT SHORTER (New %u old %u)",
- (UINT32) ACPI_STRLEN (NewPath), (UINT32) AmlNameStringLength));
+ (UINT32) strlen (NewPath), (UINT32) AmlNameStringLength));
ACPI_FREE (NewPathExternal);
return (AE_NOT_FOUND);
}
@@ -597,7 +597,7 @@ OptOptimizeNamePath (
* The original path must be longer than one NameSeg (4 chars) for there
* to be any possibility that it can be optimized to a shorter string
*/
- AmlNameStringLength = ACPI_STRLEN (AmlNameString);
+ AmlNameStringLength = strlen (AmlNameString);
if (AmlNameStringLength <= ACPI_NAME_SIZE)
{
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS,
@@ -745,7 +745,7 @@ OptOptimizeNamePath (
*/
if (ACPI_SUCCESS (Status))
{
- HowMuchShorter = (AmlNameStringLength - ACPI_STRLEN (NewPath));
+ HowMuchShorter = (AmlNameStringLength - strlen (NewPath));
OptTotal += HowMuchShorter;
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS,
@@ -761,12 +761,12 @@ OptOptimizeNamePath (
* (alias name) is the second operand
*/
Op->Asl.Child->Asl.Next->Asl.Value.String = NewPath;
- Op->Asl.Child->Asl.Next->Asl.AmlLength = ACPI_STRLEN (NewPath);
+ Op->Asl.Child->Asl.Next->Asl.AmlLength = strlen (NewPath);
}
else
{
Op->Asl.Child->Asl.Value.String = NewPath;
- Op->Asl.Child->Asl.AmlLength = ACPI_STRLEN (NewPath);
+ Op->Asl.Child->Asl.AmlLength = strlen (NewPath);
}
}
else if (Flags & AML_CREATE)
@@ -781,14 +781,14 @@ OptOptimizeNamePath (
/* Update the parse node with the new NamePath */
NextOp->Asl.Value.String = NewPath;
- NextOp->Asl.AmlLength = ACPI_STRLEN (NewPath);
+ NextOp->Asl.AmlLength = strlen (NewPath);
}
else
{
/* Update the parse node with the new NamePath */
Op->Asl.Value.String = NewPath;
- Op->Asl.AmlLength = ACPI_STRLEN (NewPath);
+ Op->Asl.AmlLength = strlen (NewPath);
}
}
else
diff --git a/sys/contrib/dev/acpica/compiler/asloptions.c b/sys/contrib/dev/acpica/compiler/asloptions.c
index cc20bcd..4cff853 100644
--- a/sys/contrib/dev/acpica/compiler/asloptions.c
+++ b/sys/contrib/dev/acpica/compiler/asloptions.c
@@ -194,6 +194,7 @@ AslDoOptions (
DtParserdebug = 1;
PrParserdebug = 1;
Gbl_DebugFlag = TRUE;
+ Gbl_KeepPreprocessorTempFile = TRUE;
break;
case 'p': /* Prune ASL parse tree */
diff --git a/sys/contrib/dev/acpica/compiler/aslprintf.c b/sys/contrib/dev/acpica/compiler/aslprintf.c
index c8647ea..1d8d4d7 100644
--- a/sys/contrib/dev/acpica/compiler/aslprintf.c
+++ b/sys/contrib/dev/acpica/compiler/aslprintf.c
@@ -186,7 +186,7 @@ OpcParsePrintf (
if (StringToProcess)
{
NewString = UtStringCacheCalloc (StringLength + 1);
- ACPI_STRNCPY (NewString, StartPosition, StringLength);
+ strncpy (NewString, StartPosition, StringLength);
NewOp = TrAllocateNode (PARSEOP_STRING_LITERAL);
NewOp->Asl.Value.String = NewString;
@@ -275,7 +275,7 @@ OpcParsePrintf (
if (StringToProcess)
{
NewString = UtStringCacheCalloc (StringLength + 1);
- ACPI_STRNCPY (NewString, StartPosition, StringLength);
+ strncpy (NewString, StartPosition, StringLength);
NewOp = TrAllocateNode (PARSEOP_STRING_LITERAL);
NewOp->Asl.Value.String = NewString;
diff --git a/sys/contrib/dev/acpica/compiler/aslstartup.c b/sys/contrib/dev/acpica/compiler/aslstartup.c
index 85e2f88..211658b 100644
--- a/sys/contrib/dev/acpica/compiler/aslstartup.c
+++ b/sys/contrib/dev/acpica/compiler/aslstartup.c
@@ -359,6 +359,8 @@ AslDoOneFile (
return (AE_ERROR);
}
+ Gbl_OriginalInputFileSize = FlGetFileSize (ASL_FILE_INPUT);
+
/* Determine input file type */
Gbl_FileType = AslDetectSourceFileType (&Gbl_Files[ASL_FILE_INPUT]);
diff --git a/sys/contrib/dev/acpica/compiler/aslsupport.l b/sys/contrib/dev/acpica/compiler/aslsupport.l
index b3149cf..0016626 100644
--- a/sys/contrib/dev/acpica/compiler/aslsupport.l
+++ b/sys/contrib/dev/acpica/compiler/aslsupport.l
@@ -113,6 +113,7 @@ AslDoLineDirective (
char *Filename;
UINT32 i;
+ Gbl_HasIncludeFiles = TRUE;
/* Eat the entire line that contains the #line directive */
@@ -713,7 +714,7 @@ DoCharacter:
* string and resume processing of the next character
*/
ConvertBuffer[i] = 0;
- Digit = (UINT8) ACPI_STRTOUL (ConvertBuffer, NULL, 8);
+ Digit = (UINT8) strtoul (ConvertBuffer, NULL, 8);
/* Check for NULL or non-ascii character (ignore if so) */
@@ -749,7 +750,7 @@ DoCharacter:
/* Up to two hex digits allowed */
- if (!ACPI_IS_XDIGIT (StringChar) ||
+ if (!isxdigit (StringChar) ||
(i > 1))
{
/*
@@ -757,7 +758,7 @@ DoCharacter:
* string and resume processing of the next character
*/
ConvertBuffer[i] = 0;
- Digit = (UINT8) ACPI_STRTOUL (ConvertBuffer, NULL, 16);
+ Digit = (UINT8) strtoul (ConvertBuffer, NULL, 16);
/* Check for NULL or non-ascii character (ignore if so) */
@@ -830,7 +831,7 @@ CompletedString:
return (FALSE);
}
- ACPI_STRCPY (CleanString, MsgBuffer);
+ strcpy (CleanString, MsgBuffer);
AslCompilerlval.s = CleanString;
return (TRUE);
diff --git a/sys/contrib/dev/acpica/compiler/asltypes.h b/sys/contrib/dev/acpica/compiler/asltypes.h
index 4bd24da..343c364 100644
--- a/sys/contrib/dev/acpica/compiler/asltypes.h
+++ b/sys/contrib/dev/acpica/compiler/asltypes.h
@@ -148,32 +148,56 @@ typedef struct asl_file_status
/*
* File types. Note: Any changes to this table must also be reflected
* in the Gbl_Files array.
+ *
+ * Corresponding filename suffixes are in comments
+ *
+ * NOTE: Don't move the first 4 file types
*/
typedef enum
{
ASL_FILE_STDOUT = 0,
ASL_FILE_STDERR,
- ASL_FILE_INPUT,
- ASL_FILE_AML_OUTPUT, /* Don't move these first 4 file types */
- ASL_FILE_SOURCE_OUTPUT,
- ASL_FILE_PREPROCESSOR,
- ASL_FILE_LISTING_OUTPUT,
- ASL_FILE_HEX_OUTPUT,
- ASL_FILE_NAMESPACE_OUTPUT,
- ASL_FILE_DEBUG_OUTPUT,
- ASL_FILE_ASM_SOURCE_OUTPUT,
- ASL_FILE_C_SOURCE_OUTPUT,
- ASL_FILE_ASM_INCLUDE_OUTPUT,
- ASL_FILE_C_INCLUDE_OUTPUT,
- ASL_FILE_C_OFFSET_OUTPUT,
- ASL_FILE_MAP_OUTPUT
+ ASL_FILE_INPUT, /* .asl */
+ ASL_FILE_AML_OUTPUT, /* .aml */
+ ASL_FILE_SOURCE_OUTPUT, /* .src */
+ ASL_FILE_PREPROCESSOR, /* .pre */
+ ASL_FILE_PREPROCESSOR_USER, /* .i */
+ ASL_FILE_LISTING_OUTPUT, /* .lst */
+ ASL_FILE_HEX_OUTPUT, /* .hex */
+ ASL_FILE_NAMESPACE_OUTPUT, /* .nsp */
+ ASL_FILE_DEBUG_OUTPUT, /* .txt */
+ ASL_FILE_ASM_SOURCE_OUTPUT, /* .asm */
+ ASL_FILE_C_SOURCE_OUTPUT, /* .c */
+ ASL_FILE_ASM_INCLUDE_OUTPUT,/* .inc */
+ ASL_FILE_C_INCLUDE_OUTPUT, /* .h */
+ ASL_FILE_C_OFFSET_OUTPUT, /* offset.h */
+ ASL_FILE_MAP_OUTPUT /* .map */
} ASL_FILE_TYPES;
-#define ASL_MAX_FILE_TYPE 15
+#define ASL_MAX_FILE_TYPE 16
#define ASL_NUM_FILES (ASL_MAX_FILE_TYPE + 1)
+/* filename suffixes for output files */
+
+#define FILE_SUFFIX_PREPROC_USER "i "
+#define FILE_SUFFIX_PREPROCESSOR "pre"
+#define FILE_SUFFIX_AML_CODE "aml"
+#define FILE_SUFFIX_MAP "map"
+#define FILE_SUFFIX_LISTING "lst"
+#define FILE_SUFFIX_HEX_DUMP "hex"
+#define FILE_SUFFIX_DEBUG "txt"
+#define FILE_SUFFIX_SOURCE "src"
+#define FILE_SUFFIX_NAMESPACE "nsp"
+#define FILE_SUFFIX_ASM_SOURCE "asm"
+#define FILE_SUFFIX_C_SOURCE "c"
+#define FILE_SUFFIX_DISASSEMBLY "dsl"
+#define FILE_SUFFIX_ASM_INCLUDE "inc"
+#define FILE_SUFFIX_C_INCLUDE "h"
+#define FILE_SUFFIX_ASL_CODE "asl"
+#define FILE_SUFFIX_C_OFFSET "offset.h"
+
/* Cache block structure for ParseOps and Strings */
diff --git a/sys/contrib/dev/acpica/compiler/aslutils.c b/sys/contrib/dev/acpica/compiler/aslutils.c
index dadd6b1..e0511a4 100644
--- a/sys/contrib/dev/acpica/compiler/aslutils.c
+++ b/sys/contrib/dev/acpica/compiler/aslutils.c
@@ -441,17 +441,20 @@ UtDisplaySummary (
"%-14s %s - %u lines, %u bytes, %u keywords\n",
"ASL Input:",
Gbl_Files[ASL_FILE_INPUT].Filename, Gbl_CurrentLineNumber,
- Gbl_InputByteCount, TotalKeywords);
+ Gbl_OriginalInputFileSize, TotalKeywords);
/* AML summary */
if ((Gbl_ExceptionCount[ASL_ERROR] == 0) || (Gbl_IgnoreErrors))
{
- FlPrintFile (FileId,
- "%-14s %s - %u bytes, %u named objects, %u executable opcodes\n",
- "AML Output:",
- Gbl_Files[ASL_FILE_AML_OUTPUT].Filename, Gbl_TableLength,
- TotalNamedObjects, TotalExecutableOpcodes);
+ if (Gbl_Files[ASL_FILE_AML_OUTPUT].Handle)
+ {
+ FlPrintFile (FileId,
+ "%-14s %s - %u bytes, %u named objects, %u executable opcodes\n",
+ "AML Output:",
+ Gbl_Files[ASL_FILE_AML_OUTPUT].Filename, Gbl_TableLength,
+ TotalNamedObjects, TotalExecutableOpcodes);
+ }
}
}
@@ -471,9 +474,9 @@ UtDisplaySummary (
continue;
}
- /* .I is a temp file unless specifically requested */
+ /* .PRE is the preprocessor intermediate file */
- if ((i == ASL_FILE_PREPROCESSOR) && (!Gbl_PreprocessorOutputFlag))
+ if ((i == ASL_FILE_PREPROCESSOR) && (!Gbl_KeepPreprocessorTempFile))
{
continue;
}
@@ -932,7 +935,7 @@ UtDoConstant (
char ErrBuf[64];
- Status = UtStrtoul64 (String, 0, &Converted);
+ Status = stroul64 (String, 0, &Converted);
if (ACPI_FAILURE (Status))
{
sprintf (ErrBuf, "%s %s\n", "Conversion error:",
@@ -948,7 +951,7 @@ UtDoConstant (
/*******************************************************************************
*
- * FUNCTION: UtStrtoul64
+ * FUNCTION: stroul64
*
* PARAMETERS: String - Null terminated string
* Terminater - Where a pointer to the terminating byte
@@ -962,7 +965,7 @@ UtDoConstant (
******************************************************************************/
ACPI_STATUS
-UtStrtoul64 (
+stroul64 (
char *String,
UINT32 Base,
UINT64 *RetInteger)
diff --git a/sys/contrib/dev/acpica/compiler/asluuid.c b/sys/contrib/dev/acpica/compiler/asluuid.c
index 4e345e9..850ac6a 100644
--- a/sys/contrib/dev/acpica/compiler/asluuid.c
+++ b/sys/contrib/dev/acpica/compiler/asluuid.c
@@ -69,7 +69,7 @@ AuValidateUuid (
UINT32 i;
- if (!InString || (ACPI_STRLEN (InString) != UUID_STRING_LENGTH))
+ if (!InString || (strlen (InString) != UUID_STRING_LENGTH))
{
return (AE_BAD_PARAMETER);
}
diff --git a/sys/contrib/dev/acpica/compiler/dtcompile.c b/sys/contrib/dev/acpica/compiler/dtcompile.c
index 20da143..506c4cd 100644
--- a/sys/contrib/dev/acpica/compiler/dtcompile.c
+++ b/sys/contrib/dev/acpica/compiler/dtcompile.c
@@ -302,7 +302,7 @@ DtCompileDataTable (
return (AE_ERROR);
}
- Gbl_Signature = UtStringCacheCalloc (ACPI_STRLEN (Signature) + 1);
+ Gbl_Signature = UtStringCacheCalloc (strlen (Signature) + 1);
strcpy (Gbl_Signature, Signature);
/*
@@ -358,6 +358,8 @@ DtCompileDataTable (
TableData = AcpiDmGetTableData (Signature);
if (!TableData || Gbl_CompileGeneric)
{
+ /* Unknown table signature and/or force generic compile */
+
DtCompileGeneric ((void **) FieldList, NULL, NULL);
goto FinishHeader;
}
@@ -454,7 +456,7 @@ DtCompileTable (
/* Ignore optional subtable if name does not match */
if ((Info->Flags & DT_OPTIONAL) &&
- ACPI_STRCMP ((*Field)->Name, Info->Name))
+ strcmp ((*Field)->Name, Info->Name))
{
*RetSubtable = NULL;
return (AE_OK);
@@ -591,7 +593,7 @@ DtCompileTable (
DtSetSubtableLength (InlineSubtable);
- ACPI_MEMCPY (Buffer, InlineSubtable->Buffer, FieldLength);
+ memcpy (Buffer, InlineSubtable->Buffer, FieldLength);
LocalField = *Field;
break;
diff --git a/sys/contrib/dev/acpica/compiler/dtcompiler.h b/sys/contrib/dev/acpica/compiler/dtcompiler.h
index 201b2db..daff7aa 100644
--- a/sys/contrib/dev/acpica/compiler/dtcompiler.h
+++ b/sys/contrib/dev/acpica/compiler/dtcompiler.h
@@ -181,7 +181,13 @@ DtCompilePadding (
UINT32
DtGetNextLine (
- FILE *Handle);
+ FILE *Handle,
+ UINT32 Flags);
+
+/* Flags for DtGetNextLine */
+
+#define DT_ALLOW_MULTILINE_QUOTES 0x01
+
DT_FIELD *
DtScanFile (
diff --git a/sys/contrib/dev/acpica/compiler/dtexpress.c b/sys/contrib/dev/acpica/compiler/dtexpress.c
index 90054c9..4316b79 100644
--- a/sys/contrib/dev/acpica/compiler/dtexpress.c
+++ b/sys/contrib/dev/acpica/compiler/dtexpress.c
@@ -413,7 +413,7 @@ DtLookupLabel (
LabelField = Gbl_LabelList;
while (LabelField)
{
- if (!ACPI_STRCMP (Name, LabelField->Value))
+ if (!strcmp (Name, LabelField->Value))
{
return (LabelField);
}
diff --git a/sys/contrib/dev/acpica/compiler/dtfield.c b/sys/contrib/dev/acpica/compiler/dtfield.c
index 3b191ab..621636c 100644
--- a/sys/contrib/dev/acpica/compiler/dtfield.c
+++ b/sys/contrib/dev/acpica/compiler/dtfield.c
@@ -166,7 +166,7 @@ DtCompileString (
UINT32 Length;
- Length = ACPI_STRLEN (Field->Value);
+ Length = strlen (Field->Value);
/* Check if the string is too long for the field */
@@ -177,7 +177,7 @@ DtCompileString (
Length = ByteLength;
}
- ACPI_MEMCPY (Buffer, Field->Value, Length);
+ memcpy (Buffer, Field->Value, Length);
}
@@ -212,7 +212,7 @@ DtCompileUnicode (
AsciiString = Field->Value;
UnicodeString = (UINT16 *) Buffer;
- Count = ACPI_STRLEN (AsciiString) + 1;
+ Count = strlen (AsciiString) + 1;
/* Convert to Unicode string (including null terminator) */
@@ -318,7 +318,7 @@ DtCompileInteger (
/* TBD: Should use a flag rather than compare "Reserved" */
- if (!ACPI_STRCMP (Field->Name, "Reserved"))
+ if (!strcmp (Field->Name, "Reserved"))
{
if (Flags & DT_NON_ZERO)
{
@@ -359,7 +359,7 @@ DtCompileInteger (
DtError (ASL_ERROR, ASL_MSG_INTEGER_SIZE, Field, MsgBuffer);
}
- ACPI_MEMCPY (Buffer, &Value, ByteLength);
+ memcpy (Buffer, &Value, ByteLength);
return;
}
@@ -391,7 +391,7 @@ DtNormalizeBuffer (
char c;
- NewBuffer = UtLocalCalloc (ACPI_STRLEN (Buffer) + 1);
+ NewBuffer = UtLocalCalloc (strlen (Buffer) + 1);
TmpBuffer = NewBuffer;
while ((c = *Buffer++))
diff --git a/sys/contrib/dev/acpica/compiler/dtio.c b/sys/contrib/dev/acpica/compiler/dtio.c
index 4b05bd0..fed9925 100644
--- a/sys/contrib/dev/acpica/compiler/dtio.c
+++ b/sys/contrib/dev/acpica/compiler/dtio.c
@@ -129,7 +129,7 @@ DtTrim (
/* Skip lines that start with a space */
- if (!ACPI_STRCMP (String, " "))
+ if (!strcmp (String, " "))
{
ReturnString = UtStringCacheCalloc (1);
return (ReturnString);
@@ -138,7 +138,7 @@ DtTrim (
/* Setup pointers to start and end of input string */
Start = String;
- End = String + ACPI_STRLEN (String) - 1;
+ End = String + strlen (String) - 1;
/* Find first non-whitespace character */
@@ -180,9 +180,9 @@ DtTrim (
Length = ACPI_PTR_DIFF (End, Start) + 1;
ReturnString = UtStringCacheCalloc (Length + 1);
- if (ACPI_STRLEN (Start))
+ if (strlen (Start))
{
- ACPI_STRNCPY (ReturnString, Start, Length);
+ strncpy (ReturnString, Start, Length);
}
ReturnString[Length] = 0;
@@ -313,7 +313,7 @@ DtParseLine (
Length = ACPI_PTR_DIFF (End, Start);
TmpName = UtLocalCalloc (Length + 1);
- ACPI_STRNCPY (TmpName, Start, Length);
+ strncpy (TmpName, Start, Length);
Name = DtTrim (TmpName);
ACPI_FREE (TmpName);
@@ -360,7 +360,7 @@ DtParseLine (
Length = ACPI_PTR_DIFF (End, Start);
TmpValue = UtLocalCalloc (Length + 1);
- ACPI_STRNCPY (TmpValue, Start, Length);
+ strncpy (TmpValue, Start, Length);
Value = DtTrim (TmpValue);
ACPI_FREE (TmpValue);
@@ -406,7 +406,8 @@ DtParseLine (
UINT32
DtGetNextLine (
- FILE *Handle)
+ FILE *Handle,
+ UINT32 Flags)
{
BOOLEAN LineNotAllBlanks = FALSE;
UINT32 State = DT_NORMAL_TEXT;
@@ -415,7 +416,7 @@ DtGetNextLine (
int c;
- ACPI_MEMSET (Gbl_CurrentLineBuffer, 0, Gbl_LineBufferSize);
+ memset (Gbl_CurrentLineBuffer, 0, Gbl_LineBufferSize);
for (i = 0; ;)
{
/*
@@ -550,9 +551,12 @@ DtGetNextLine (
case '\n':
- AcpiOsPrintf ("ERROR at line %u: Unterminated quoted string\n",
- Gbl_CurrentLineNumber++);
- State = DT_NORMAL_TEXT;
+ if (!(Flags & DT_ALLOW_MULTILINE_QUOTES))
+ {
+ AcpiOsPrintf ("ERROR at line %u: Unterminated quoted string\n",
+ Gbl_CurrentLineNumber++);
+ State = DT_NORMAL_TEXT;
+ }
break;
default: /* Get next character */
@@ -746,7 +750,7 @@ DtScanFile (
/* Scan line-by-line */
- while ((Offset = DtGetNextLine (Handle)) != ASL_EOF)
+ while ((Offset = DtGetNextLine (Handle, 0)) != ASL_EOF)
{
ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Line %2.2u/%4.4X - %s",
Gbl_CurrentLineNumber, Offset, Gbl_CurrentLineBuffer));
@@ -897,7 +901,7 @@ DtDumpBuffer (
}
BufChar = Buffer[(ACPI_SIZE) i + j];
- if (ACPI_IS_PRINT (BufChar))
+ if (isprint (BufChar))
{
FlPrintFile (FileId, "%c", BufChar);
}
diff --git a/sys/contrib/dev/acpica/compiler/dtparser.y b/sys/contrib/dev/acpica/compiler/dtparser.y
index 0271d78..9d6f1e2 100644
--- a/sys/contrib/dev/acpica/compiler/dtparser.y
+++ b/sys/contrib/dev/acpica/compiler/dtparser.y
@@ -48,6 +48,13 @@
#define _COMPONENT DT_COMPILER
ACPI_MODULE_NAME ("dtparser")
+void * AslLocalAllocate (unsigned int Size);
+
+/* Bison/yacc configuration */
+
+#undef alloca
+#define alloca AslLocalAllocate
+
int DtParserlex (void);
int DtParserparse (void);
void DtParsererror (char const *msg);
@@ -162,15 +169,15 @@ Expression
/* Default base for a non-prefixed integer is 16 */
- | EXPOP_NUMBER { UtStrtoul64 (DtParsertext, 16, &$$);}
+ | EXPOP_NUMBER { stroul64 (DtParsertext, 16, &$$);}
/* Standard hex number (0x1234) */
- | EXPOP_HEX_NUMBER { UtStrtoul64 (DtParsertext, 16, &$$);}
+ | EXPOP_HEX_NUMBER { stroul64 (DtParsertext, 16, &$$);}
- /* TBD: Decimal number with prefix (0d1234) - Not supported by UtStrtoul64 at this time */
+ /* TBD: Decimal number with prefix (0d1234) - Not supported by stroul64 at this time */
- | EXPOP_DECIMAL_NUMBER { UtStrtoul64 (DtParsertext, 10, &$$);}
+ | EXPOP_DECIMAL_NUMBER { stroul64 (DtParsertext, 10, &$$);}
;
%%
diff --git a/sys/contrib/dev/acpica/compiler/dtsubtable.c b/sys/contrib/dev/acpica/compiler/dtsubtable.c
index 1152656..8cb5253 100644
--- a/sys/contrib/dev/acpica/compiler/dtsubtable.c
+++ b/sys/contrib/dev/acpica/compiler/dtsubtable.c
@@ -80,7 +80,7 @@ DtCreateSubtable (
String = UtStringCacheCalloc (Length);
Subtable->Buffer = ACPI_CAST_PTR (UINT8, String);
- ACPI_MEMCPY (Subtable->Buffer, Buffer, Length);
+ memcpy (Subtable->Buffer, Buffer, Length);
Subtable->Length = Length;
Subtable->TotalLength = Length;
@@ -379,6 +379,6 @@ DtSetSubtableLength (
return;
}
- ACPI_MEMCPY (Subtable->LengthField, &Subtable->TotalLength,
+ memcpy (Subtable->LengthField, &Subtable->TotalLength,
Subtable->SizeOfLengthField);
}
diff --git a/sys/contrib/dev/acpica/compiler/dttable.c b/sys/contrib/dev/acpica/compiler/dttable.c
index bae80ad..1c32fe0 100644
--- a/sys/contrib/dev/acpica/compiler/dttable.c
+++ b/sys/contrib/dev/acpica/compiler/dttable.c
@@ -1824,7 +1824,7 @@ DtCompileIvrs (
if (IvrsHeader->Type == ACPI_IVRS_TYPE_HARDWARE)
{
while (*PFieldList &&
- !ACPI_STRCMP ((*PFieldList)->Name, "Entry Type"))
+ !strcmp ((*PFieldList)->Name, "Entry Type"))
{
SubtableStart = *PFieldList;
DtCompileInteger (&EntryType, *PFieldList, 1, 0);
@@ -3403,13 +3403,13 @@ DtCompileGeneric (
/* Now we can actually compile the parse tree */
- if (*Length)
+ if (Length && *Length)
{
*Length = 0;
}
while (*PFieldList)
{
- if (Name && !ACPI_STRCMP ((*PFieldList)->Name, Name))
+ if (Name && !strcmp ((*PFieldList)->Name, Name))
{
break;
}
diff --git a/sys/contrib/dev/acpica/compiler/dttemplate.c b/sys/contrib/dev/acpica/compiler/dttemplate.c
index 90b6b17..07e930f 100644
--- a/sys/contrib/dev/acpica/compiler/dttemplate.c
+++ b/sys/contrib/dev/acpica/compiler/dttemplate.c
@@ -85,6 +85,7 @@ AcpiUtIsSpecialTable (
{
if (ACPI_COMPARE_NAME (Signature, ACPI_SIG_DSDT) ||
+ ACPI_COMPARE_NAME (Signature, ACPI_SIG_OSDT) ||
ACPI_COMPARE_NAME (Signature, ACPI_SIG_SSDT) ||
ACPI_COMPARE_NAME (Signature, ACPI_SIG_FACS) ||
ACPI_COMPARE_NAME (Signature, ACPI_RSDP_NAME))
@@ -127,8 +128,8 @@ DtCreateTemplates (
}
AcpiUtStrupr (Signature);
- if (!ACPI_STRCMP (Signature, "ALL") ||
- !ACPI_STRCMP (Signature, "*"))
+ if (!strcmp (Signature, "ALL") ||
+ !strcmp (Signature, "*"))
{
/* Create all available/known templates */
@@ -327,7 +328,7 @@ DtCreateOneTemplate (
AcpiOsPrintf ("/*\n");
AcpiOsPrintf (ACPI_COMMON_HEADER ("iASL Compiler/Disassembler", " * "));
- AcpiOsPrintf (" * Template for [%4.4s] ACPI Table\n",
+ AcpiOsPrintf (" * Template for [%4.4s] ACPI Table",
Signature);
/* Dump the actual ACPI table */
@@ -336,6 +337,8 @@ DtCreateOneTemplate (
{
/* Normal case, tables that appear in AcpiDmTableData */
+ AcpiOsPrintf (" (static data table)\n");
+
if (Gbl_VerboseTemplates)
{
AcpiOsPrintf (" * Format: [HexOffset DecimalOffset ByteLength]"
@@ -344,7 +347,7 @@ DtCreateOneTemplate (
else
{
AcpiOsPrintf (" * Format: [ByteLength]"
- " FieldName : HexFieldValue\n */\n\n");
+ " FieldName : HexFieldValue\n */\n");
}
AcpiDmDumpDataTable (ACPI_CAST_PTR (ACPI_TABLE_HEADER,
@@ -352,9 +355,11 @@ DtCreateOneTemplate (
}
else
{
- /* Special ACPI tables - DSDT, SSDT, FADT, RSDP */
+ /* Special ACPI tables - DSDT, SSDT, OSDT, FADT, RSDP */
+
+ AcpiOsPrintf (" (AML byte code table)\n");
- AcpiOsPrintf (" */\n\n");
+ AcpiOsPrintf (" */\n");
if (ACPI_COMPARE_NAME (Signature, ACPI_SIG_DSDT))
{
Actual = fwrite (TemplateDsdt, 1, sizeof (TemplateDsdt) -1, File);
@@ -377,6 +382,17 @@ DtCreateOneTemplate (
goto Cleanup;
}
}
+ else if (ACPI_COMPARE_NAME (Signature, ACPI_SIG_OSDT))
+ {
+ Actual = fwrite (TemplateOsdt, 1, sizeof (TemplateOsdt) -1, File);
+ if (Actual != sizeof (TemplateOsdt) -1)
+ {
+ fprintf (stderr,
+ "Could not write to output file %s\n", DisasmFilename);
+ Status = AE_ERROR;
+ goto Cleanup;
+ }
+ }
else if (ACPI_COMPARE_NAME (Signature, ACPI_SIG_FACS)) /* FADT */
{
AcpiDmDumpDataTable (ACPI_CAST_PTR (ACPI_TABLE_HEADER,
diff --git a/sys/contrib/dev/acpica/compiler/dttemplate.h b/sys/contrib/dev/acpica/compiler/dttemplate.h
index 1b27b4e..6d76f4d 100644
--- a/sys/contrib/dev/acpica/compiler/dttemplate.h
+++ b/sys/contrib/dev/acpica/compiler/dttemplate.h
@@ -45,7 +45,7 @@
#define __DTTEMPLATE_H
-/* Special templates for DSDT and SSDT (AML byte-code tables) */
+/* Special templates for the ASL/AML tables: DSDT, SSDT, and OSDT */
const char TemplateDsdt[] =
"DefinitionBlock (\"dsdt.aml\", \"DSDT\", 2, \"Intel\", \"Template\", 0x00000001)\n"
@@ -65,6 +65,15 @@ const char TemplateSsdt[] =
" }\n"
"}\n\n";
+const char TemplateOsdt[] =
+ "DefinitionBlock (\"osdt.aml\", \"OSDT\", 2, \"Intel\", \"Template\", 0x00000001)\n"
+ "{\n"
+ " Method (MAIN, 0, NotSerialized)\n"
+ " {\n"
+ " Return (Zero)\n"
+ " }\n"
+ "}\n\n";
+
/* Templates for ACPI data tables */
diff --git a/sys/contrib/dev/acpica/compiler/dtutils.c b/sys/contrib/dev/acpica/compiler/dtutils.c
index 2d5b762..ce996c4 100644
--- a/sys/contrib/dev/acpica/compiler/dtutils.c
+++ b/sys/contrib/dev/acpica/compiler/dtutils.c
@@ -241,7 +241,7 @@ DtStrtoul64 (
while (*ThisChar)
{
- if (ACPI_IS_DIGIT (*ThisChar))
+ if (isdigit ((int) *ThisChar))
{
/* Convert ASCII 0-9 to Decimal value */
@@ -249,8 +249,8 @@ DtStrtoul64 (
}
else /* Letter */
{
- ThisDigit = (UINT32) ACPI_TOUPPER (*ThisChar);
- if (!ACPI_IS_XDIGIT ((char) ThisDigit))
+ ThisDigit = (UINT32) toupper ((int) *ThisChar);
+ if (!isxdigit ((int) ThisDigit))
{
/* Not A-F */
@@ -568,7 +568,7 @@ DtGetFieldLength (
Value = DtGetFieldValue (Field);
if (Value)
{
- ByteLength = ACPI_STRLEN (Value) + 1;
+ ByteLength = strlen (Value) + 1;
}
else
{ /* At this point, this is a fatal error */
@@ -633,7 +633,7 @@ DtGetFieldLength (
/* TBD: error if Value is NULL? (as below?) */
- ByteLength = (ACPI_STRLEN (Value) + 1) * sizeof(UINT16);
+ ByteLength = (strlen (Value) + 1) * sizeof(UINT16);
break;
default:
diff --git a/sys/contrib/dev/acpica/compiler/prparser.y b/sys/contrib/dev/acpica/compiler/prparser.y
index 20d6e6a..f0c5f9b 100644
--- a/sys/contrib/dev/acpica/compiler/prparser.y
+++ b/sys/contrib/dev/acpica/compiler/prparser.y
@@ -48,6 +48,13 @@
#define _COMPONENT ASL_PREPROCESSOR
ACPI_MODULE_NAME ("prparser")
+void * AslLocalAllocate (unsigned int Size);
+
+/* Bison/yacc configuration */
+
+#undef alloca
+#define alloca AslLocalAllocate
+
int PrParserlex (void);
int PrParserparse (void);
void PrParsererror (char const *msg);
@@ -175,11 +182,11 @@ Expression
/* Default base for a non-prefixed integer is 10 */
- | EXPOP_NUMBER { UtStrtoul64 (PrParsertext, 10, &$$);}
+ | EXPOP_NUMBER { stroul64 (PrParsertext, 10, &$$);}
/* Standard hex number (0x1234) */
- | EXPOP_HEX_NUMBER { UtStrtoul64 (PrParsertext, 16, &$$);}
+ | EXPOP_HEX_NUMBER { stroul64 (PrParsertext, 16, &$$);}
;
%%
diff --git a/sys/contrib/dev/acpica/compiler/prscan.c b/sys/contrib/dev/acpica/compiler/prscan.c
index 12d303c..cbf82a9 100644
--- a/sys/contrib/dev/acpica/compiler/prscan.c
+++ b/sys/contrib/dev/acpica/compiler/prscan.c
@@ -67,6 +67,14 @@ PrDoDirective (
char *DirectiveToken,
char **Next);
+static void
+PrGetNextLineInit (
+ void);
+
+static UINT32
+PrGetNextLine (
+ FILE *Handle);
+
static int
PrMatchDirective (
char *Directive);
@@ -186,7 +194,7 @@ PrInitializeGlobals (
/* Init globals */
Gbl_InputFileList = NULL;
- Gbl_CurrentLineNumber = 0;
+ Gbl_CurrentLineNumber = 1;
Gbl_PreprocessorLineNumber = 1;
Gbl_PreprocessorError = FALSE;
@@ -271,7 +279,7 @@ PrDoPreprocess (
} while (MoreInputFiles);
- /* Point compiler input to the new preprocessor output file (.i) */
+ /* Point compiler input to the new preprocessor output file (.pre) */
FlCloseFile (ASL_FILE_INPUT);
Gbl_Files[ASL_FILE_INPUT].Handle = Gbl_Files[ASL_FILE_PREPROCESSOR].Handle;
@@ -280,7 +288,10 @@ PrDoPreprocess (
/* Reset globals to allow compiler to run */
FlSeekFile (ASL_FILE_INPUT, 0);
- Gbl_CurrentLineNumber = 1;
+ if (!Gbl_PreprocessOnly)
+ {
+ Gbl_CurrentLineNumber = 0;
+ }
DbgPrint (ASL_DEBUG_OUTPUT, "Preprocessing phase complete \n\n");
}
@@ -297,7 +308,8 @@ PrDoPreprocess (
* DESCRIPTION: Preprocess one entire file, line-by-line.
*
* Input: Raw user ASL from ASL_FILE_INPUT
- * Output: Preprocessed file written to ASL_FILE_PREPROCESSOR
+ * Output: Preprocessed file written to ASL_FILE_PREPROCESSOR and
+ * (optionally) ASL_FILE_PREPROCESSOR_USER
*
******************************************************************************/
@@ -305,7 +317,7 @@ static void
PrPreprocessInputFile (
void)
{
- UINT32 Offset;
+ UINT32 Status;
char *Token;
char *ReplaceString;
PR_DEFINE_INFO *DefineInfo;
@@ -314,10 +326,21 @@ PrPreprocessInputFile (
int OffsetAdjust;
+ PrGetNextLineInit ();
+
/* Scan line-by-line. Comments and blank lines are skipped by this function */
- while ((Offset = DtGetNextLine (Gbl_Files[ASL_FILE_INPUT].Handle)) != ASL_EOF)
+ while ((Status = PrGetNextLine (Gbl_Files[ASL_FILE_INPUT].Handle)) != ASL_EOF)
{
+ Gbl_CurrentLineNumber++;
+ Gbl_LogicalLineNumber++;
+
+ if ((Status == ASL_WITHIN_COMMENT) ||
+ (Status == ASL_BLANK_LINE))
+ {
+ goto WriteEntireLine;
+ }
+
/* Need a copy of the input line for strok() */
strcpy (Gbl_MainTokenBuffer, Gbl_CurrentLineBuffer);
@@ -397,24 +420,13 @@ PrPreprocessInputFile (
Token = PrGetNextToken (NULL, PR_TOKEN_SEPARATORS, &Next);
}
- /*
- * Emit a #line directive if necessary, to keep the line numbers in
- * the (.i) file synchronized with the original source code file, so
- * that the correct line number appears in any error messages
- * generated by the actual compiler.
- */
- if (Gbl_CurrentLineNumber > (Gbl_PreviousLineNumber + 1))
- {
- FlPrintFile (ASL_FILE_PREPROCESSOR, "#line %u\n",
- Gbl_CurrentLineNumber);
- }
-
- Gbl_PreviousLineNumber = Gbl_CurrentLineNumber;
Gbl_PreprocessorLineNumber++;
+
+WriteEntireLine:
/*
* Now we can write the possibly modified source line to the
- * preprocessor (.i) file
+ * preprocessor file(s).
*/
FlWriteFile (ASL_FILE_PREPROCESSOR, Gbl_CurrentLineBuffer,
strlen (Gbl_CurrentLineBuffer));
@@ -654,7 +666,7 @@ PrDoDirective (
{
#ifndef MACROS_SUPPORTED
AcpiOsPrintf ("%s ERROR - line %u: #define macros are not supported yet\n",
- Gbl_CurrentLineBuffer, Gbl_CurrentLineNumber);
+ Gbl_CurrentLineBuffer, Gbl_LogicalLineNumber);
exit(1);
#else
PrAddMacro (Token, Next);
@@ -691,7 +703,7 @@ PrDoDirective (
#endif
DbgPrint (ASL_PARSE_OUTPUT, PR_PREFIX_ID
"New #define: %s->%s\n",
- Gbl_CurrentLineNumber, Token, Token2);
+ Gbl_LogicalLineNumber, Token, Token2);
PrAddDefine (Token, Token2, FALSE);
}
@@ -760,10 +772,7 @@ PrDoDirective (
"User #line invocation %s\n", Gbl_CurrentLineNumber,
Token);
- /* Update local line numbers */
-
Gbl_CurrentLineNumber = (UINT32) Value;
- Gbl_PreviousLineNumber = 0;
/* Emit #line into the preprocessor file */
@@ -839,6 +848,107 @@ SyntaxError:
/*******************************************************************************
*
+ * FUNCTION: PrGetNextLine, PrGetNextLineInit
+ *
+ * PARAMETERS: Handle - Open file handle for the source file
+ *
+ * RETURN: Status of the GetLine operation:
+ * AE_OK - Normal line, OK status
+ * ASL_WITHIN_COMMENT - Line is part of a multi-line comment
+ * ASL_EOF - End-of-file reached
+ *
+ * DESCRIPTION: Get the next text line from the input file. Does not strip
+ * comments.
+ *
+ ******************************************************************************/
+
+#define PR_NORMAL_TEXT 0
+#define PR_WITHIN_COMMENT 1
+
+static UINT8 AcpiGbl_LineScanState = PR_NORMAL_TEXT;
+
+static void
+PrGetNextLineInit (
+ void)
+{
+ AcpiGbl_LineScanState = 0;
+}
+
+static UINT32
+PrGetNextLine (
+ FILE *Handle)
+{
+ UINT32 i;
+ int c = 0;
+ int PreviousChar;
+
+
+ /* Always clear the global line buffer */
+
+ memset (Gbl_CurrentLineBuffer, 0, Gbl_LineBufferSize);
+ for (i = 0; ;)
+ {
+ /*
+ * If line is too long, expand the line buffers. Also increases
+ * Gbl_LineBufferSize.
+ */
+ if (i >= Gbl_LineBufferSize)
+ {
+ UtExpandLineBuffers ();
+ }
+
+ PreviousChar = c;
+ c = getc (Handle);
+ if (c == EOF)
+ {
+ return (ASL_EOF);
+ }
+
+ /* We need to worry about multi-line slash-asterisk comments */
+
+ /* Check for comment open */
+
+ if ((AcpiGbl_LineScanState == PR_NORMAL_TEXT) &&
+ (PreviousChar == '/') && (c == '*'))
+ {
+ AcpiGbl_LineScanState = PR_WITHIN_COMMENT;
+ }
+
+ /* Check for comment close */
+
+ if ((AcpiGbl_LineScanState == PR_WITHIN_COMMENT) &&
+ (PreviousChar == '*') && (c == '/'))
+ {
+ AcpiGbl_LineScanState = PR_NORMAL_TEXT;
+ }
+
+ /* Always copy the character into line buffer */
+
+ Gbl_CurrentLineBuffer[i] = (char) c;
+ i++;
+
+ /* Always exit on end-of-line */
+
+ if (c == '\n')
+ {
+ /* Handle multi-line comments */
+
+ if (AcpiGbl_LineScanState == PR_WITHIN_COMMENT)
+ {
+ return (ASL_WITHIN_COMMENT);
+ }
+ if (i == 1)
+ {
+ return (ASL_BLANK_LINE);
+ }
+ return (AE_OK);
+ }
+ }
+}
+
+
+/*******************************************************************************
+ *
* FUNCTION: PrMatchDirective
*
* PARAMETERS: Directive - Pointer to directive name token
diff --git a/sys/contrib/dev/acpica/compiler/prutils.c b/sys/contrib/dev/acpica/compiler/prutils.c
index 7e880b1..751d1a0 100644
--- a/sys/contrib/dev/acpica/compiler/prutils.c
+++ b/sys/contrib/dev/acpica/compiler/prutils.c
@@ -382,6 +382,8 @@ PrPushInputFileStack (
PR_FILE_NODE *Fnode;
+ Gbl_HasIncludeFiles = TRUE;
+
/* Save the current state in an Fnode */
Fnode = UtLocalCalloc (sizeof (PR_FILE_NODE));
@@ -406,11 +408,11 @@ PrPushInputFileStack (
strcpy (Gbl_Files[ASL_FILE_INPUT].Filename, Filename);
Gbl_Files[ASL_FILE_INPUT].Handle = InputFile;
- Gbl_PreviousLineNumber = 0;
- Gbl_CurrentLineNumber = 0;
+ Gbl_CurrentLineNumber = 1;
/* Emit a new #line directive for the include file */
+ Gbl_CurrentLineNumber = 1;
FlPrintFile (ASL_FILE_PREPROCESSOR, "#line %u \"%s\"\n", 1, Filename);
}
@@ -460,12 +462,11 @@ PrPopInputFileStack (
Gbl_Files[ASL_FILE_INPUT].Filename = Fnode->Filename;
Gbl_Files[ASL_FILE_INPUT].Handle = Fnode->File;
Gbl_CurrentLineNumber = Fnode->CurrentLineNumber;
- Gbl_PreviousLineNumber = 0;
/* Emit a new #line directive after the include file */
FlPrintFile (ASL_FILE_PREPROCESSOR, "#line %u \"%s\"\n",
- Gbl_CurrentLineNumber + 1, Fnode->Filename);
+ Gbl_CurrentLineNumber, Fnode->Filename);
/* All done with this node */
diff --git a/sys/contrib/dev/acpica/components/debugger/dbcmds.c b/sys/contrib/dev/acpica/components/debugger/dbcmds.c
index c11451d..0f236d2 100644
--- a/sys/contrib/dev/acpica/components/debugger/dbcmds.c
+++ b/sys/contrib/dev/acpica/components/debugger/dbcmds.c
@@ -111,7 +111,7 @@ AcpiDbConvertToNode (
{
/* Numeric argument, convert */
- Address = ACPI_STRTOUL (InString, NULL, 16);
+ Address = strtoul (InString, NULL, 16);
Node = ACPI_TO_POINTER (Address);
if (!AcpiOsReadable (Node, sizeof (ACPI_NAMESPACE_NODE)))
{
@@ -189,7 +189,7 @@ AcpiDbSleep (
/* Convert argument to binary and invoke the sleep state */
- SleepState = (UINT8) ACPI_STRTOUL (ObjectArg, NULL, 0);
+ SleepState = (UINT8) strtoul (ObjectArg, NULL, 0);
AcpiDbDoOneSleepState (SleepState);
return_ACPI_STATUS (AE_OK);
}
@@ -561,7 +561,7 @@ AcpiDbDisplayInterfaces (
/* Install - install an interface */
- SubString = ACPI_STRSTR ("INSTALL", ActionArg);
+ SubString = strstr ("INSTALL", ActionArg);
if (SubString)
{
Status = AcpiInstallInterface (InterfaceNameArg);
@@ -575,7 +575,7 @@ AcpiDbDisplayInterfaces (
/* Remove - remove an interface */
- SubString = ACPI_STRSTR ("REMOVE", ActionArg);
+ SubString = strstr ("REMOVE", ActionArg);
if (SubString)
{
Status = AcpiRemoveInterface (InterfaceNameArg);
@@ -736,7 +736,7 @@ AcpiDmCompareAmlResources (
/* Check for descriptor byte match */
- else if (ACPI_MEMCMP (Aml1, Aml2, Aml1Length))
+ else if (memcmp (Aml1, Aml2, Aml1Length))
{
AcpiOsPrintf (
"**** Data mismatch in descriptor [%.2X] type %2.2X, Offset %8.8X ****\n",
@@ -1138,7 +1138,7 @@ AcpiDbDisplayResources (
/* Asterisk means "display resources for all devices" */
- if (!ObjectArg || (!ACPI_STRCMP (ObjectArg, "*")))
+ if (!ObjectArg || (!strcmp (ObjectArg, "*")))
{
(void) AcpiWalkNamespace (ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
ACPI_UINT32_MAX, AcpiDbDeviceResources, NULL, NULL, NULL);
@@ -1191,7 +1191,7 @@ AcpiDbGenerateGpe (
ACPI_GPE_EVENT_INFO *GpeEventInfo;
- GpeNumber = ACPI_STRTOUL (GpeArg, NULL, 0);
+ GpeNumber = strtoul (GpeArg, NULL, 0);
/*
* If no block arg, or block arg == 0 or 1, use the FADT-defined
@@ -1199,7 +1199,7 @@ AcpiDbGenerateGpe (
*/
if (BlockArg)
{
- BlockNumber = ACPI_STRTOUL (BlockArg, NULL, 0);
+ BlockNumber = strtoul (BlockArg, NULL, 0);
if (BlockNumber == 1)
{
BlockNumber = 0;
diff --git a/sys/contrib/dev/acpica/components/debugger/dbconvert.c b/sys/contrib/dev/acpica/components/debugger/dbconvert.c
index f6c0286..08931e4 100644
--- a/sys/contrib/dev/acpica/components/debugger/dbconvert.c
+++ b/sys/contrib/dev/acpica/components/debugger/dbconvert.c
@@ -77,7 +77,7 @@ AcpiDbHexCharToValue (
/* Digit must be ascii [0-9a-fA-F] */
- if (!ACPI_IS_XDIGIT (HexChar))
+ if (!isxdigit (HexChar))
{
return (AE_BAD_HEX_CONSTANT);
}
@@ -88,7 +88,7 @@ AcpiDbHexCharToValue (
}
else
{
- Value = (UINT8) (ACPI_TOUPPER (HexChar) - 0x37);
+ Value = (UINT8) (toupper (HexChar) - 0x37);
}
*ReturnValue = Value;
@@ -306,7 +306,7 @@ AcpiDbConvertToObject (
Object->Type = ACPI_TYPE_STRING;
Object->String.Pointer = String;
- Object->String.Length = (UINT32) ACPI_STRLEN (String);
+ Object->String.Length = (UINT32) strlen (String);
break;
case ACPI_TYPE_BUFFER:
@@ -471,7 +471,7 @@ AcpiDbDumpPldBuffer (
/* The two bit-packed buffers should match */
- if (ACPI_MEMCMP (NewBuffer, BufferDesc->Buffer.Pointer,
+ if (memcmp (NewBuffer, BufferDesc->Buffer.Pointer,
BufferDesc->Buffer.Length))
{
AcpiOsPrintf ("Converted _PLD buffer does not compare. New:\n");
diff --git a/sys/contrib/dev/acpica/components/debugger/dbdisply.c b/sys/contrib/dev/acpica/components/debugger/dbdisply.c
index 507c2b0..d71d21d 100644
--- a/sys/contrib/dev/acpica/components/debugger/dbdisply.c
+++ b/sys/contrib/dev/acpica/components/debugger/dbdisply.c
@@ -141,7 +141,7 @@ AcpiDbGetPointer (
ACPI_SIZE Address;
- Address = ACPI_STRTOUL (Target, NULL, 16);
+ Address = strtoul (Target, NULL, 16);
ObjPtr = ACPI_TO_POINTER (Address);
return (ObjPtr);
}
diff --git a/sys/contrib/dev/acpica/components/debugger/dbexec.c b/sys/contrib/dev/acpica/components/debugger/dbexec.c
index 79c0ee9..c8a4112 100644
--- a/sys/contrib/dev/acpica/components/debugger/dbexec.c
+++ b/sys/contrib/dev/acpica/components/debugger/dbexec.c
@@ -433,15 +433,15 @@ AcpiDbExecute (
}
else
{
- NameString = ACPI_ALLOCATE (ACPI_STRLEN (Name) + 1);
+ NameString = ACPI_ALLOCATE (strlen (Name) + 1);
if (!NameString)
{
return;
}
- ACPI_MEMSET (&AcpiGbl_DbMethodInfo, 0, sizeof (ACPI_DB_METHOD_INFO));
+ memset (&AcpiGbl_DbMethodInfo, 0, sizeof (ACPI_DB_METHOD_INFO));
- ACPI_STRCPY (NameString, Name);
+ strcpy (NameString, Name);
AcpiUtStrupr (NameString);
AcpiGbl_DbMethodInfo.Name = NameString;
AcpiGbl_DbMethodInfo.Args = Args;
@@ -669,8 +669,8 @@ AcpiDbCreateExecutionThreads (
/* Get the arguments */
- NumThreads = ACPI_STRTOUL (NumThreadsArg, NULL, 0);
- NumLoops = ACPI_STRTOUL (NumLoopsArg, NULL, 0);
+ NumThreads = strtoul (NumThreadsArg, NULL, 0);
+ NumLoops = strtoul (NumLoopsArg, NULL, 0);
if (!NumThreads || !NumLoops)
{
@@ -714,7 +714,7 @@ AcpiDbCreateExecutionThreads (
return;
}
- ACPI_MEMSET (&AcpiGbl_DbMethodInfo, 0, sizeof (ACPI_DB_METHOD_INFO));
+ memset (&AcpiGbl_DbMethodInfo, 0, sizeof (ACPI_DB_METHOD_INFO));
/* Array to store IDs of threads */
@@ -729,7 +729,7 @@ AcpiDbCreateExecutionThreads (
(void) AcpiOsDeleteSemaphore (InfoGate);
return;
}
- ACPI_MEMSET (AcpiGbl_DbMethodInfo.Threads, 0, Size);
+ memset (AcpiGbl_DbMethodInfo.Threads, 0, Size);
/* Setup the context to be passed to each thread */
diff --git a/sys/contrib/dev/acpica/components/debugger/dbfileio.c b/sys/contrib/dev/acpica/components/debugger/dbfileio.c
index 59a9a52..f39fac1 100644
--- a/sys/contrib/dev/acpica/components/debugger/dbfileio.c
+++ b/sys/contrib/dev/acpica/components/debugger/dbfileio.c
@@ -112,7 +112,7 @@ AcpiDbOpenDebugFile (
}
AcpiOsPrintf ("Debug output file %s opened\n", Name);
- ACPI_STRNCPY (AcpiGbl_DbDebugFilename, Name,
+ strncpy (AcpiGbl_DbDebugFilename, Name,
sizeof (AcpiGbl_DbDebugFilename));
AcpiGbl_DbOutputToFile = TRUE;
diff --git a/sys/contrib/dev/acpica/components/debugger/dbhistry.c b/sys/contrib/dev/acpica/components/debugger/dbhistry.c
index e945779..6674fdb 100644
--- a/sys/contrib/dev/acpica/components/debugger/dbhistry.c
+++ b/sys/contrib/dev/acpica/components/debugger/dbhistry.c
@@ -92,7 +92,7 @@ AcpiDbAddToHistory (
/* Put command into the next available slot */
- CmdLen = (UINT16) ACPI_STRLEN (CommandLine);
+ CmdLen = (UINT16) strlen (CommandLine);
if (!CmdLen)
{
return;
@@ -100,7 +100,7 @@ AcpiDbAddToHistory (
if (AcpiGbl_HistoryBuffer[AcpiGbl_NextHistoryIndex].Command != NULL)
{
- BufferLen = (UINT16) ACPI_STRLEN (
+ BufferLen = (UINT16) strlen (
AcpiGbl_HistoryBuffer[AcpiGbl_NextHistoryIndex].Command);
if (CmdLen > BufferLen)
{
@@ -116,7 +116,7 @@ AcpiDbAddToHistory (
AcpiOsAllocate (CmdLen + 1);
}
- ACPI_STRCPY (AcpiGbl_HistoryBuffer[AcpiGbl_NextHistoryIndex].Command,
+ strcpy (AcpiGbl_HistoryBuffer[AcpiGbl_NextHistoryIndex].Command,
CommandLine);
AcpiGbl_HistoryBuffer[AcpiGbl_NextHistoryIndex].CmdNum =
@@ -217,7 +217,7 @@ AcpiDbGetFromHistory (
else
{
- CmdNum = ACPI_STRTOUL (CommandNumArg, NULL, 0);
+ CmdNum = strtoul (CommandNumArg, NULL, 0);
}
return (AcpiDbGetHistoryByIndex (CmdNum));
diff --git a/sys/contrib/dev/acpica/components/debugger/dbinput.c b/sys/contrib/dev/acpica/components/debugger/dbinput.c
index 623bc48..f7e59d8 100644
--- a/sys/contrib/dev/acpica/components/debugger/dbinput.c
+++ b/sys/contrib/dev/acpica/components/debugger/dbinput.c
@@ -361,7 +361,7 @@ AcpiDbMatchCommandHelp (
while ((*Command) && (*Invocation) && (*Invocation != ' '))
{
- if (ACPI_TOLOWER (*Command) != ACPI_TOLOWER (*Invocation))
+ if (tolower ((int) *Command) != tolower ((int) *Invocation))
{
return (FALSE);
}
@@ -702,7 +702,7 @@ AcpiDbMatchCommand (
for (i = CMD_FIRST_VALID; AcpiGbl_DbCommands[i].Name; i++)
{
- if (ACPI_STRSTR (AcpiGbl_DbCommands[i].Name, UserCommand) ==
+ if (strstr (AcpiGbl_DbCommands[i].Name, UserCommand) ==
AcpiGbl_DbCommands[i].Name)
{
return (i);
@@ -946,7 +946,7 @@ AcpiDbCommandDispatch (
else if (ParamCount == 2)
{
Temp = AcpiGbl_DbConsoleDebugLevel;
- AcpiGbl_DbConsoleDebugLevel = ACPI_STRTOUL (AcpiGbl_DbArgs[1],
+ AcpiGbl_DbConsoleDebugLevel = strtoul (AcpiGbl_DbArgs[1],
NULL, 16);
AcpiOsPrintf (
"Debug Level for console output was %8.8lX, now %8.8lX\n",
@@ -955,7 +955,7 @@ AcpiDbCommandDispatch (
else
{
Temp = AcpiGbl_DbDebugLevel;
- AcpiGbl_DbDebugLevel = ACPI_STRTOUL (AcpiGbl_DbArgs[1], NULL, 16);
+ AcpiGbl_DbDebugLevel = strtoul (AcpiGbl_DbArgs[1], NULL, 16);
AcpiOsPrintf (
"Debug Level for file output was %8.8lX, now %8.8lX\n",
Temp, AcpiGbl_DbDebugLevel);
@@ -994,7 +994,7 @@ AcpiDbCommandDispatch (
case CMD_NOTIFY:
- Temp = ACPI_STRTOUL (AcpiGbl_DbArgs[2], NULL, 0);
+ Temp = strtoul (AcpiGbl_DbArgs[2], NULL, 0);
AcpiDbSendNotify (AcpiGbl_DbArgs[1], Temp);
break;
diff --git a/sys/contrib/dev/acpica/components/debugger/dbmethod.c b/sys/contrib/dev/acpica/components/debugger/dbmethod.c
index 5224854..65266c1 100644
--- a/sys/contrib/dev/acpica/components/debugger/dbmethod.c
+++ b/sys/contrib/dev/acpica/components/debugger/dbmethod.c
@@ -89,7 +89,7 @@ AcpiDbSetMethodBreakpoint (
/* Get and verify the breakpoint address */
- Address = ACPI_STRTOUL (Location, NULL, 16);
+ Address = strtoul (Location, NULL, 16);
if (Address <= Op->Common.AmlOffset)
{
AcpiOsPrintf ("Breakpoint %X is beyond current address %X\n",
@@ -174,7 +174,7 @@ AcpiDbSetMethodData (
return;
}
- Value = ACPI_STRTOUL (ValueArg, NULL, 16);
+ Value = strtoul (ValueArg, NULL, 16);
if (Type == 'N')
{
@@ -196,7 +196,7 @@ AcpiDbSetMethodData (
/* Get the index and value */
- Index = ACPI_STRTOUL (IndexArg, NULL, 16);
+ Index = strtoul (IndexArg, NULL, 16);
WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
if (!WalkState)
@@ -304,7 +304,7 @@ AcpiDbDisassembleAml (
if (Statements)
{
- NumStatements = ACPI_STRTOUL (Statements, NULL, 0);
+ NumStatements = strtoul (Statements, NULL, 0);
}
#ifdef ACPI_DISASSEMBLER
diff --git a/sys/contrib/dev/acpica/components/debugger/dbnames.c b/sys/contrib/dev/acpica/components/debugger/dbnames.c
index d749b1d..67cf517 100644
--- a/sys/contrib/dev/acpica/components/debugger/dbnames.c
+++ b/sys/contrib/dev/acpica/components/debugger/dbnames.c
@@ -248,7 +248,7 @@ AcpiDbDumpNamespace (
if (DepthArg)
{
- MaxDepth = ACPI_STRTOUL (DepthArg, NULL, 0);
+ MaxDepth = strtoul (DepthArg, NULL, 0);
}
}
@@ -319,13 +319,13 @@ AcpiDbDumpNamespaceByOwner (
ACPI_OWNER_ID OwnerId;
- OwnerId = (ACPI_OWNER_ID) ACPI_STRTOUL (OwnerArg, NULL, 0);
+ OwnerId = (ACPI_OWNER_ID) strtoul (OwnerArg, NULL, 0);
/* Now we can check for the depth argument */
if (DepthArg)
{
- MaxDepth = ACPI_STRTOUL (DepthArg, NULL, 0);
+ MaxDepth = strtoul (DepthArg, NULL, 0);
}
AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT);
@@ -426,7 +426,7 @@ AcpiDbFindNameInNamespace (
char *AcpiNamePtr = AcpiName;
- if (ACPI_STRLEN (NameArg) > 4)
+ if (strlen (NameArg) > 4)
{
AcpiOsPrintf ("Name must be no longer than 4 characters\n");
return (AE_OK);
@@ -830,7 +830,7 @@ AcpiDbFindReferences (
/* Convert string to object pointer */
- Address = ACPI_STRTOUL (ObjectArg, NULL, 16);
+ Address = strtoul (ObjectArg, NULL, 16);
ObjDesc = ACPI_TO_POINTER (Address);
/* Search all nodes in namespace */
diff --git a/sys/contrib/dev/acpica/components/debugger/dbtest.c b/sys/contrib/dev/acpica/components/debugger/dbtest.c
index ab14984..ce3347c 100644
--- a/sys/contrib/dev/acpica/components/debugger/dbtest.c
+++ b/sys/contrib/dev/acpica/components/debugger/dbtest.c
@@ -646,7 +646,7 @@ AcpiDbTestBufferType (
* count is not an integral number of bytes. Zero out the
* unused bits.
*/
- ACPI_MEMSET (Buffer, BUFFER_FILL_VALUE, ByteLength);
+ memset (Buffer, BUFFER_FILL_VALUE, ByteLength);
ExtraBits = BitLength % 8;
if (ExtraBits)
{
@@ -671,7 +671,7 @@ AcpiDbTestBufferType (
goto Exit;
}
- if (ACPI_MEMCMP (Temp2->Buffer.Pointer, Buffer, ByteLength))
+ if (memcmp (Temp2->Buffer.Pointer, Buffer, ByteLength))
{
AcpiOsPrintf (" MISMATCH 2: New buffer value");
}
@@ -695,7 +695,7 @@ AcpiDbTestBufferType (
goto Exit;
}
- if (ACPI_MEMCMP (Temp1->Buffer.Pointer, Temp3->Buffer.Pointer, ByteLength))
+ if (memcmp (Temp1->Buffer.Pointer, Temp3->Buffer.Pointer, ByteLength))
{
AcpiOsPrintf (" MISMATCH 3: While restoring original buffer");
}
@@ -751,7 +751,7 @@ AcpiDbTestStringType (
/* Write a new value */
WriteValue.Type = ACPI_TYPE_STRING;
- WriteValue.String.Length = ACPI_STRLEN (ValueToWrite);
+ WriteValue.String.Length = strlen (ValueToWrite);
WriteValue.String.Pointer = ValueToWrite;
Status = AcpiDbWriteToObject (Node, &WriteValue);
@@ -768,7 +768,7 @@ AcpiDbTestStringType (
goto Exit;
}
- if (ACPI_STRCMP (Temp2->String.Pointer, ValueToWrite))
+ if (strcmp (Temp2->String.Pointer, ValueToWrite))
{
AcpiOsPrintf (" MISMATCH 2: %s, expecting %s",
Temp2->String.Pointer, ValueToWrite);
@@ -776,7 +776,7 @@ AcpiDbTestStringType (
/* Write back the original value */
- WriteValue.String.Length = ACPI_STRLEN (Temp1->String.Pointer);
+ WriteValue.String.Length = strlen (Temp1->String.Pointer);
WriteValue.String.Pointer = Temp1->String.Pointer;
Status = AcpiDbWriteToObject (Node, &WriteValue);
@@ -793,7 +793,7 @@ AcpiDbTestStringType (
goto Exit;
}
- if (ACPI_STRCMP (Temp1->String.Pointer, Temp3->String.Pointer))
+ if (strcmp (Temp1->String.Pointer, Temp3->String.Pointer))
{
AcpiOsPrintf (" MISMATCH 3: %s, expecting %s",
Temp3->String.Pointer, Temp1->String.Pointer);
@@ -926,7 +926,7 @@ AcpiDbWriteToObject (
/* Copy the incoming user parameter */
- ACPI_MEMCPY (&Params[1], Value, sizeof (ACPI_OBJECT));
+ memcpy (&Params[1], Value, sizeof (ACPI_OBJECT));
ParamObjects.Count = 2;
ParamObjects.Pointer = Params;
@@ -970,7 +970,7 @@ AcpiDbEvaluateAllPredefinedNames (
if (CountArg)
{
- Info.MaxCount = ACPI_STRTOUL (CountArg, NULL, 0);
+ Info.MaxCount = strtoul (CountArg, NULL, 0);
}
/* Search all nodes in namespace */
@@ -1077,7 +1077,7 @@ AcpiDbEvaluateOnePredefinedName (
case ACPI_TYPE_STRING:
ThisParam->String.Pointer = "This is the default argument string";
- ThisParam->String.Length = ACPI_STRLEN (ThisParam->String.Pointer);
+ ThisParam->String.Length = strlen (ThisParam->String.Pointer);
break;
case ACPI_TYPE_BUFFER:
diff --git a/sys/contrib/dev/acpica/components/debugger/dbutils.c b/sys/contrib/dev/acpica/components/debugger/dbutils.c
index 5db98e1..eeb5f82 100644
--- a/sys/contrib/dev/acpica/components/debugger/dbutils.c
+++ b/sys/contrib/dev/acpica/components/debugger/dbutils.c
@@ -96,7 +96,7 @@ AcpiDbMatchArgument (
for (i = 0; Arguments[i].Name; i++)
{
- if (ACPI_STRSTR (Arguments[i].Name, UserArgument) == Arguments[i].Name)
+ if (strstr (Arguments[i].Name, UserArgument) == Arguments[i].Name)
{
return (i);
}
@@ -375,7 +375,7 @@ AcpiDbUint32ToHexString (
if (Value == 0)
{
- ACPI_STRCPY (Buffer, "0");
+ strcpy (Buffer, "0");
return;
}
diff --git a/sys/contrib/dev/acpica/components/debugger/dbxface.c b/sys/contrib/dev/acpica/components/debugger/dbxface.c
index d72ee5e..6609962 100644
--- a/sys/contrib/dev/acpica/components/debugger/dbxface.c
+++ b/sys/contrib/dev/acpica/components/debugger/dbxface.c
@@ -435,7 +435,7 @@ AcpiDbInitialize (
{
return_ACPI_STATUS (AE_NO_MEMORY);
}
- ACPI_MEMSET (AcpiGbl_DbBuffer, 0, ACPI_DEBUG_BUFFER_SIZE);
+ memset (AcpiGbl_DbBuffer, 0, ACPI_DEBUG_BUFFER_SIZE);
/* Initial scope is the root */
diff --git a/sys/contrib/dev/acpica/components/disassembler/dmbuffer.c b/sys/contrib/dev/acpica/components/disassembler/dmbuffer.c
index 15b7e87..fbd8f0b 100644
--- a/sys/contrib/dev/acpica/components/disassembler/dmbuffer.c
+++ b/sys/contrib/dev/acpica/components/disassembler/dmbuffer.c
@@ -205,7 +205,7 @@ AcpiDmDisasmByteList (
}
BufChar = ByteData[CurrentIndex];
- if (ACPI_IS_PRINT (BufChar))
+ if (isprint (BufChar))
{
AcpiOsPrintf ("%c", BufChar);
}
@@ -554,7 +554,7 @@ AcpiDmIsStringBuffer (
* they will be handled in the string output routine
*/
- if (!ACPI_IS_PRINT (ByteData[i]))
+ if (!isprint (ByteData[i]))
{
return (FALSE);
}
@@ -836,7 +836,7 @@ AcpiDmUnicode (
{
AcpiOsPrintf ("\\%c", OutputValue);
}
- else if (!ACPI_IS_PRINT (OutputValue))
+ else if (!isprint (OutputValue))
{
AcpiOsPrintf ("\\x%2.2X", OutputValue);
}
@@ -902,7 +902,7 @@ AcpiDmGetHardwareIdType (
for (i = 0; i < 3; i++)
{
if (!ACPI_IS_ASCII (Prefix[i]) ||
- !ACPI_IS_ALPHA (Prefix[i]))
+ !isalpha (Prefix[i]))
{
return;
}
diff --git a/sys/contrib/dev/acpica/components/disassembler/dmcstyle.c b/sys/contrib/dev/acpica/components/disassembler/dmcstyle.c
index b66dbed..11814a4 100644
--- a/sys/contrib/dev/acpica/components/disassembler/dmcstyle.c
+++ b/sys/contrib/dev/acpica/components/disassembler/dmcstyle.c
@@ -337,23 +337,70 @@ AcpiDmCheckForSymbolicOpcode (
*/
AcpiDmPromoteTarget (Op, Target);
- /*
- * Check for possible conversion to a "Compound Assignment".
- *
- * Determine if either operand is the same as the target
- * and display compound assignment operator and other operand.
- */
- if ((AcpiDmIsTargetAnOperand (Target, Child1, TRUE)) ||
- (AcpiDmIsTargetAnOperand (Target, Child2, TRUE)))
+ /* Check operands for conversion to a "Compound Assignment" */
+
+ switch (Op->Common.AmlOpcode)
{
- Target->Common.OperatorSymbol =
- AcpiDmGetCompoundSymbol (Op->Common.AmlOpcode);
+ /* Commutative operators */
+
+ case AML_ADD_OP:
+ case AML_MULTIPLY_OP:
+ case AML_BIT_AND_OP:
+ case AML_BIT_OR_OP:
+ case AML_BIT_XOR_OP:
+ /*
+ * For the commutative operators, we can convert to a
+ * compound statement only if at least one (either) operand
+ * is the same as the target.
+ *
+ * Add (A, B, A) --> A += B
+ * Add (B, A, A) --> A += B
+ * Add (B, C, A) --> A = (B + C)
+ */
+ if ((AcpiDmIsTargetAnOperand (Target, Child1, TRUE)) ||
+ (AcpiDmIsTargetAnOperand (Target, Child2, TRUE)))
+ {
+ Target->Common.OperatorSymbol =
+ AcpiDmGetCompoundSymbol (Op->Common.AmlOpcode);
- /* Convert operator to compound assignment */
+ /* Convert operator to compound assignment */
- Op->Common.DisasmFlags |= ACPI_PARSEOP_COMPOUND;
- Child1->Common.OperatorSymbol = NULL;
- return (TRUE);
+ Op->Common.DisasmFlags |= ACPI_PARSEOP_COMPOUND;
+ Child1->Common.OperatorSymbol = NULL;
+ return (TRUE);
+ }
+ break;
+
+ /* Non-commutative operators */
+
+ case AML_SUBTRACT_OP:
+ case AML_DIVIDE_OP:
+ case AML_MOD_OP:
+ case AML_SHIFT_LEFT_OP:
+ case AML_SHIFT_RIGHT_OP:
+ /*
+ * For the non-commutative operators, we can convert to a
+ * compound statement only if the target is the same as the
+ * first operand.
+ *
+ * Subtract (A, B, A) --> A -= B
+ * Subtract (B, A, A) --> A = (B - A)
+ */
+ if ((AcpiDmIsTargetAnOperand (Target, Child1, TRUE)))
+ {
+ Target->Common.OperatorSymbol =
+ AcpiDmGetCompoundSymbol (Op->Common.AmlOpcode);
+
+ /* Convert operator to compound assignment */
+
+ Op->Common.DisasmFlags |= ACPI_PARSEOP_COMPOUND;
+ Child1->Common.OperatorSymbol = NULL;
+ return (TRUE);
+ }
+ break;
+
+ default:
+ break;
}
/*
@@ -423,8 +470,12 @@ AcpiDmCheckForSymbolicOpcode (
* source so that the target is processed first.
*/
Target = Child1->Common.Next;
- AcpiDmPromoteTarget (Op, Target);
+ if (!Target)
+ {
+ return (FALSE);
+ }
+ AcpiDmPromoteTarget (Op, Target);
if (!Target->Common.OperatorSymbol)
{
Target->Common.OperatorSymbol = " = ";
@@ -674,7 +725,8 @@ AcpiDmPromoteTarget (
*
* DESCRIPTION: Determine if a Target Op is a placeholder Op or a real Target.
* In other words, determine if the optional target is used or
- * not.
+ * not. Note: If Target is NULL, something is seriously wrong,
+ * probably with the parse tree.
*
******************************************************************************/
@@ -683,6 +735,11 @@ AcpiDmIsValidTarget (
ACPI_PARSE_OBJECT *Target)
{
+ if (!Target)
+ {
+ return (FALSE);
+ }
+
if ((Target->Common.AmlOpcode == AML_INT_NAMEPATH_OP) &&
(Target->Common.Value.Arg == NULL))
{
diff --git a/sys/contrib/dev/acpica/components/disassembler/dmopcode.c b/sys/contrib/dev/acpica/components/disassembler/dmopcode.c
index b10d433..6b7c1f5 100644
--- a/sys/contrib/dev/acpica/components/disassembler/dmopcode.c
+++ b/sys/contrib/dev/acpica/components/disassembler/dmopcode.c
@@ -269,10 +269,10 @@ AcpiDmPredefinedDescription (
* Note: NameString is guaranteed to be upper case here.
*/
LastCharIsDigit =
- (ACPI_IS_DIGIT (NameString[3])); /* d */
+ (isdigit ((int) NameString[3])); /* d */
LastCharsAreHex =
- (ACPI_IS_XDIGIT (NameString[2]) && /* xx */
- ACPI_IS_XDIGIT (NameString[3]));
+ (isxdigit ((int) NameString[2]) && /* xx */
+ isxdigit ((int) NameString[3]));
switch (NameString[1])
{
diff --git a/sys/contrib/dev/acpica/components/dispatcher/dsfield.c b/sys/contrib/dev/acpica/components/dispatcher/dsfield.c
index d376bb1..81cf410 100644
--- a/sys/contrib/dev/acpica/components/dispatcher/dsfield.c
+++ b/sys/contrib/dev/acpica/components/dispatcher/dsfield.c
@@ -530,7 +530,7 @@ AcpiDsCreateField (
}
}
- ACPI_MEMSET (&Info, 0, sizeof (ACPI_CREATE_FIELD_INFO));
+ memset (&Info, 0, sizeof (ACPI_CREATE_FIELD_INFO));
/* Second arg is the field flags */
diff --git a/sys/contrib/dev/acpica/components/dispatcher/dsinit.c b/sys/contrib/dev/acpica/components/dispatcher/dsinit.c
index 62f9bde..921f556 100644
--- a/sys/contrib/dev/acpica/components/dispatcher/dsinit.c
+++ b/sys/contrib/dev/acpica/components/dispatcher/dsinit.c
@@ -224,7 +224,7 @@ AcpiDsInitializeObjects (
/* Set all init info to zero */
- ACPI_MEMSET (&Info, 0, sizeof (ACPI_INIT_WALK_INFO));
+ memset (&Info, 0, sizeof (ACPI_INIT_WALK_INFO));
Info.OwnerId = OwnerId;
Info.TableIndex = TableIndex;
diff --git a/sys/contrib/dev/acpica/components/dispatcher/dsobject.c b/sys/contrib/dev/acpica/components/dispatcher/dsobject.c
index 106c6ab..33d0392 100644
--- a/sys/contrib/dev/acpica/components/dispatcher/dsobject.c
+++ b/sys/contrib/dev/acpica/components/dispatcher/dsobject.c
@@ -348,7 +348,7 @@ AcpiDsBuildInternalBufferObj (
if (ByteList)
{
- ACPI_MEMCPY (ObjDesc->Buffer.Pointer, ByteList->Named.Data,
+ memcpy (ObjDesc->Buffer.Pointer, ByteList->Named.Data,
ByteListLength);
}
}
@@ -775,7 +775,7 @@ AcpiDsInitObjectFromOp (
case ACPI_TYPE_STRING:
ObjDesc->String.Pointer = Op->Common.Value.String;
- ObjDesc->String.Length = (UINT32) ACPI_STRLEN (Op->Common.Value.String);
+ ObjDesc->String.Length = (UINT32) strlen (Op->Common.Value.String);
/*
* The string is contained in the ACPI table, don't ever try
diff --git a/sys/contrib/dev/acpica/components/dispatcher/dsutils.c b/sys/contrib/dev/acpica/components/dispatcher/dsutils.c
index a115b2e..9b23c11 100644
--- a/sys/contrib/dev/acpica/components/dispatcher/dsutils.c
+++ b/sys/contrib/dev/acpica/components/dispatcher/dsutils.c
@@ -605,7 +605,7 @@ AcpiDsCreateOperand (
ObjDesc = AcpiUtCreateStringObject ((ACPI_SIZE) NameLength);
- ACPI_STRNCPY (ObjDesc->String.Pointer, NameString, NameLength);
+ strncpy (ObjDesc->String.Pointer, NameString, NameLength);
Status = AE_OK;
}
else
diff --git a/sys/contrib/dev/acpica/components/dispatcher/dswload.c b/sys/contrib/dev/acpica/components/dispatcher/dswload.c
index 8bc425a..755b15e 100644
--- a/sys/contrib/dev/acpica/components/dispatcher/dswload.c
+++ b/sys/contrib/dev/acpica/components/dispatcher/dswload.c
@@ -325,9 +325,18 @@ AcpiDsLoad1BeginOp (
if ((WalkState->Opcode != AML_SCOPE_OP) &&
(!(WalkState->ParseFlags & ACPI_PARSE_DEFERRED_OP)))
{
- Flags |= ACPI_NS_ERROR_IF_FOUND;
- ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[%s] Cannot already exist\n",
- AcpiUtGetTypeName (ObjectType)));
+ if (WalkState->NamespaceOverride)
+ {
+ Flags |= ACPI_NS_OVERRIDE_IF_FOUND;
+ ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[%s] Override allowed\n",
+ AcpiUtGetTypeName (ObjectType)));
+ }
+ else
+ {
+ Flags |= ACPI_NS_ERROR_IF_FOUND;
+ ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[%s] Cannot already exist\n",
+ AcpiUtGetTypeName (ObjectType)));
+ }
}
else
{
diff --git a/sys/contrib/dev/acpica/components/events/evgpe.c b/sys/contrib/dev/acpica/components/events/evgpe.c
index 99043ad..0083e60 100644
--- a/sys/contrib/dev/acpica/components/events/evgpe.c
+++ b/sys/contrib/dev/acpica/components/events/evgpe.c
@@ -104,6 +104,7 @@ AcpiEvUpdateGpeEnableMask (
{
ACPI_SET_BIT (GpeRegisterInfo->EnableForRun, (UINT8) RegisterBit);
}
+ GpeRegisterInfo->EnableMask = GpeRegisterInfo->EnableForRun;
return_ACPI_STATUS (AE_OK);
}
@@ -141,7 +142,7 @@ AcpiEvEnableGpe (
/* Enable the requested GPE */
- Status = AcpiHwLowSetGpe (GpeEventInfo, ACPI_GPE_ENABLE_SAVE);
+ Status = AcpiHwLowSetGpe (GpeEventInfo, ACPI_GPE_ENABLE);
return_ACPI_STATUS (Status);
}
@@ -231,7 +232,7 @@ AcpiEvRemoveGpeReference (
Status = AcpiEvUpdateGpeEnableMask (GpeEventInfo);
if (ACPI_SUCCESS (Status))
{
- Status = AcpiHwLowSetGpe (GpeEventInfo, ACPI_GPE_DISABLE_SAVE);
+ Status = AcpiHwLowSetGpe (GpeEventInfo, ACPI_GPE_DISABLE);
}
if (ACPI_FAILURE (Status))
diff --git a/sys/contrib/dev/acpica/components/events/evgpeinit.c b/sys/contrib/dev/acpica/components/events/evgpeinit.c
index 0e53a1d..63a4c4a 100644
--- a/sys/contrib/dev/acpica/components/events/evgpeinit.c
+++ b/sys/contrib/dev/acpica/components/events/evgpeinit.c
@@ -395,7 +395,7 @@ AcpiEvMatchGpeMethod (
/* 4) The last two characters of the name are the hex GPE Number */
- GpeNumber = ACPI_STRTOUL (&Name[2], NULL, 16);
+ GpeNumber = strtoul (&Name[2], NULL, 16);
if (GpeNumber == ACPI_UINT32_MAX)
{
/* Conversion failed; invalid method, just ignore it */
diff --git a/sys/contrib/dev/acpica/components/executer/exconfig.c b/sys/contrib/dev/acpica/components/executer/exconfig.c
index 0627f99..96188e6 100644
--- a/sys/contrib/dev/acpica/components/executer/exconfig.c
+++ b/sys/contrib/dev/acpica/components/executer/exconfig.c
@@ -515,7 +515,7 @@ AcpiExLoadOp (
return_ACPI_STATUS (AE_NO_MEMORY);
}
- ACPI_MEMCPY (Table, TableHeader, Length);
+ memcpy (Table, TableHeader, Length);
break;
default:
diff --git a/sys/contrib/dev/acpica/components/executer/exconvrt.c b/sys/contrib/dev/acpica/components/executer/exconvrt.c
index 50ccf26..ac881cb 100644
--- a/sys/contrib/dev/acpica/components/executer/exconvrt.c
+++ b/sys/contrib/dev/acpica/components/executer/exconvrt.c
@@ -251,7 +251,7 @@ AcpiExConvertToBuffer (
/* Copy the integer to the buffer, LSB first */
NewBuf = ReturnDesc->Buffer.Pointer;
- ACPI_MEMCPY (NewBuf,
+ memcpy (NewBuf,
&ObjDesc->Integer.Value,
AcpiGbl_IntegerByteWidth);
break;
@@ -276,7 +276,7 @@ AcpiExConvertToBuffer (
/* Copy the string to the buffer */
NewBuf = ReturnDesc->Buffer.Pointer;
- ACPI_STRNCPY ((char *) NewBuf, (char *) ObjDesc->String.Pointer,
+ strncpy ((char *) NewBuf, (char *) ObjDesc->String.Pointer,
ObjDesc->String.Length);
break;
diff --git a/sys/contrib/dev/acpica/components/executer/exdebug.c b/sys/contrib/dev/acpica/components/executer/exdebug.c
index 5e98fd5..d174ccd 100644
--- a/sys/contrib/dev/acpica/components/executer/exdebug.c
+++ b/sys/contrib/dev/acpica/components/executer/exdebug.c
@@ -81,6 +81,8 @@ AcpiExDoDebugObject (
{
UINT32 i;
UINT32 Timer;
+ ACPI_OPERAND_OBJECT *ObjectDesc;
+ UINT32 Value;
ACPI_FUNCTION_TRACE_PTR (ExDoDebugObject, SourceDesc);
@@ -267,8 +269,37 @@ AcpiExDoDebugObject (
}
else
{
- AcpiExDoDebugObject (SourceDesc->Reference.Object,
- Level+4, 0);
+ ObjectDesc = SourceDesc->Reference.Object;
+ Value = SourceDesc->Reference.Value;
+
+ switch (ObjectDesc->Common.Type)
+ {
+ case ACPI_TYPE_BUFFER:
+
+ AcpiOsPrintf ("Buffer[%u] = 0x%2.2X\n",
+ Value, *SourceDesc->Reference.IndexPointer);
+ break;
+
+ case ACPI_TYPE_STRING:
+
+ AcpiOsPrintf ("String[%u] = \"%c\" (0x%2.2X)\n",
+ Value, *SourceDesc->Reference.IndexPointer,
+ *SourceDesc->Reference.IndexPointer);
+ break;
+
+ case ACPI_TYPE_PACKAGE:
+
+ AcpiOsPrintf ("Package[%u] = ", Value);
+ AcpiExDoDebugObject (*SourceDesc->Reference.Where,
+ Level+4, 0);
+ break;
+
+ default:
+
+ AcpiOsPrintf ("Unknown Reference object type %X\n",
+ ObjectDesc->Common.Type);
+ break;
+ }
}
}
break;
diff --git a/sys/contrib/dev/acpica/components/executer/exdump.c b/sys/contrib/dev/acpica/components/executer/exdump.c
index 622dc14..1a14d38 100644
--- a/sys/contrib/dev/acpica/components/executer/exdump.c
+++ b/sys/contrib/dev/acpica/components/executer/exdump.c
@@ -238,7 +238,7 @@ static ACPI_EXDUMP_INFO AcpiExDumpIndexField[5] =
{ACPI_EXD_POINTER, ACPI_EXD_OFFSET (IndexField.DataObj), "Data Object"}
};
-static ACPI_EXDUMP_INFO AcpiExDumpReference[8] =
+static ACPI_EXDUMP_INFO AcpiExDumpReference[9] =
{
{ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpReference), NULL},
{ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Reference.Class), "Class"},
@@ -247,6 +247,7 @@ static ACPI_EXDUMP_INFO AcpiExDumpReference[8] =
{ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Reference.Object), "Object Desc"},
{ACPI_EXD_NODE, ACPI_EXD_OFFSET (Reference.Node), "Node"},
{ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Reference.Where), "Where"},
+ {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Reference.IndexPointer), "Index Pointer"},
{ACPI_EXD_REFERENCE,0, NULL}
};
@@ -1053,16 +1054,18 @@ AcpiExDumpReferenceObj (
{
if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_OPERAND)
{
- AcpiOsPrintf (" Target: %p", ObjDesc->Reference.Object);
+ AcpiOsPrintf ("%22s %p", "Target :",
+ ObjDesc->Reference.Object);
if (ObjDesc->Reference.Class == ACPI_REFCLASS_TABLE)
{
- AcpiOsPrintf (" Table Index: %X\n", ObjDesc->Reference.Value);
+ AcpiOsPrintf (" Table Index: %X\n",
+ ObjDesc->Reference.Value);
}
else
{
- AcpiOsPrintf (" Target: %p [%s]\n", ObjDesc->Reference.Object,
+ AcpiOsPrintf (" [%s]\n",
AcpiUtGetTypeName (((ACPI_OPERAND_OBJECT *)
- ObjDesc->Reference.Object)->Common.Type));
+ ObjDesc->Reference.Object)->Common.Type));
}
}
else
diff --git a/sys/contrib/dev/acpica/components/executer/exfield.c b/sys/contrib/dev/acpica/components/executer/exfield.c
index 836a378..ad2d05a 100644
--- a/sys/contrib/dev/acpica/components/executer/exfield.c
+++ b/sys/contrib/dev/acpica/components/executer/exfield.c
@@ -460,7 +460,7 @@ AcpiExWriteDataToField (
}
Buffer = BufferDesc->Buffer.Pointer;
- ACPI_MEMCPY (Buffer, SourceDesc->Buffer.Pointer, Length);
+ memcpy (Buffer, SourceDesc->Buffer.Pointer, Length);
/* Lock entire transaction if requested */
diff --git a/sys/contrib/dev/acpica/components/executer/exfldio.c b/sys/contrib/dev/acpica/components/executer/exfldio.c
index 2908da4..31727de 100644
--- a/sys/contrib/dev/acpica/components/executer/exfldio.c
+++ b/sys/contrib/dev/acpica/components/executer/exfldio.c
@@ -456,7 +456,7 @@ AcpiExFieldDatumIo (
* Copy the data from the source buffer.
* Length is the field width in bytes.
*/
- ACPI_MEMCPY (Value,
+ memcpy (Value,
(ObjDesc->BufferField.BufferObj)->Buffer.Pointer +
ObjDesc->BufferField.BaseByteOffset +
FieldDatumByteOffset,
@@ -468,7 +468,7 @@ AcpiExFieldDatumIo (
* Copy the data to the target buffer.
* Length is the field width in bytes.
*/
- ACPI_MEMCPY ((ObjDesc->BufferField.BufferObj)->Buffer.Pointer +
+ memcpy ((ObjDesc->BufferField.BufferObj)->Buffer.Pointer +
ObjDesc->BufferField.BaseByteOffset +
FieldDatumByteOffset,
Value, ObjDesc->CommonField.AccessByteWidth);
@@ -748,7 +748,7 @@ AcpiExExtractFromField (
return_ACPI_STATUS (AE_BUFFER_OVERFLOW);
}
- ACPI_MEMSET (Buffer, 0, BufferLength);
+ memset (Buffer, 0, BufferLength);
AccessBitWidth = ACPI_MUL_8 (ObjDesc->CommonField.AccessByteWidth);
/* Handle the simple case here */
@@ -765,7 +765,7 @@ AcpiExExtractFromField (
/* Use RawDatum (UINT64) to handle buffers < 64 bits */
Status = AcpiExFieldDatumIo (ObjDesc, 0, &RawDatum, ACPI_READ);
- ACPI_MEMCPY (Buffer, &RawDatum, BufferLength);
+ memcpy (Buffer, &RawDatum, BufferLength);
}
return_ACPI_STATUS (Status);
@@ -835,7 +835,7 @@ AcpiExExtractFromField (
/* Write merged datum to target buffer */
- ACPI_MEMCPY (((char *) Buffer) + BufferOffset, &MergedDatum,
+ memcpy (((char *) Buffer) + BufferOffset, &MergedDatum,
ACPI_MIN(ObjDesc->CommonField.AccessByteWidth,
BufferLength - BufferOffset));
@@ -853,7 +853,7 @@ AcpiExExtractFromField (
/* Write the last datum to the buffer */
- ACPI_MEMCPY (((char *) Buffer) + BufferOffset, &MergedDatum,
+ memcpy (((char *) Buffer) + BufferOffset, &MergedDatum,
ACPI_MIN(ObjDesc->CommonField.AccessByteWidth,
BufferLength - BufferOffset));
@@ -926,7 +926,7 @@ AcpiExInsertIntoField (
* at Byte zero. All unused (upper) bytes of the
* buffer will be 0.
*/
- ACPI_MEMCPY ((char *) NewBuffer, (char *) Buffer, BufferLength);
+ memcpy ((char *) NewBuffer, (char *) Buffer, BufferLength);
Buffer = NewBuffer;
BufferLength = RequiredLength;
}
@@ -969,7 +969,7 @@ AcpiExInsertIntoField (
/* Get initial Datum from the input buffer */
- ACPI_MEMCPY (&RawDatum, Buffer,
+ memcpy (&RawDatum, Buffer,
ACPI_MIN(ObjDesc->CommonField.AccessByteWidth,
BufferLength - BufferOffset));
@@ -1021,7 +1021,7 @@ AcpiExInsertIntoField (
/* Get the next input datum from the buffer */
BufferOffset += ObjDesc->CommonField.AccessByteWidth;
- ACPI_MEMCPY (&RawDatum, ((char *) Buffer) + BufferOffset,
+ memcpy (&RawDatum, ((char *) Buffer) + BufferOffset,
ACPI_MIN(ObjDesc->CommonField.AccessByteWidth,
BufferLength - BufferOffset));
diff --git a/sys/contrib/dev/acpica/components/executer/exmisc.c b/sys/contrib/dev/acpica/components/executer/exmisc.c
index d4e1a3b..df02e03 100644
--- a/sys/contrib/dev/acpica/components/executer/exmisc.c
+++ b/sys/contrib/dev/acpica/components/executer/exmisc.c
@@ -225,8 +225,8 @@ AcpiExConcatTemplate (
* EndTag descriptor is copied from Operand1.
*/
NewBuf = ReturnDesc->Buffer.Pointer;
- ACPI_MEMCPY (NewBuf, Operand0->Buffer.Pointer, Length0);
- ACPI_MEMCPY (NewBuf + Length0, Operand1->Buffer.Pointer, Length1);
+ memcpy (NewBuf, Operand0->Buffer.Pointer, Length0);
+ memcpy (NewBuf + Length0, Operand1->Buffer.Pointer, Length1);
/* Insert EndTag and set the checksum to zero, means "ignore checksum" */
@@ -340,12 +340,12 @@ AcpiExDoConcatenate (
/* Copy the first integer, LSB first */
- ACPI_MEMCPY (NewBuf, &Operand0->Integer.Value,
+ memcpy (NewBuf, &Operand0->Integer.Value,
AcpiGbl_IntegerByteWidth);
/* Copy the second integer (LSB first) after the first */
- ACPI_MEMCPY (NewBuf + AcpiGbl_IntegerByteWidth,
+ memcpy (NewBuf + AcpiGbl_IntegerByteWidth,
&LocalOperand1->Integer.Value,
AcpiGbl_IntegerByteWidth);
break;
@@ -367,8 +367,8 @@ AcpiExDoConcatenate (
/* Concatenate the strings */
- ACPI_STRCPY (NewBuf, Operand0->String.Pointer);
- ACPI_STRCPY (NewBuf + Operand0->String.Length,
+ strcpy (NewBuf, Operand0->String.Pointer);
+ strcpy (NewBuf + Operand0->String.Length,
LocalOperand1->String.Pointer);
break;
@@ -389,9 +389,9 @@ AcpiExDoConcatenate (
/* Concatenate the buffers */
- ACPI_MEMCPY (NewBuf, Operand0->Buffer.Pointer,
+ memcpy (NewBuf, Operand0->Buffer.Pointer,
Operand0->Buffer.Length);
- ACPI_MEMCPY (NewBuf + Operand0->Buffer.Length,
+ memcpy (NewBuf + Operand0->Buffer.Length,
LocalOperand1->Buffer.Pointer,
LocalOperand1->Buffer.Length);
break;
@@ -712,7 +712,7 @@ AcpiExDoLogicalOp (
/* Lexicographic compare: compare the data bytes */
- Compare = ACPI_MEMCMP (Operand0->Buffer.Pointer,
+ Compare = memcmp (Operand0->Buffer.Pointer,
LocalOperand1->Buffer.Pointer,
(Length0 > Length1) ? Length1 : Length0);
diff --git a/sys/contrib/dev/acpica/components/executer/exnames.c b/sys/contrib/dev/acpica/components/executer/exnames.c
index b213165..a6c9e6b 100644
--- a/sys/contrib/dev/acpica/components/executer/exnames.c
+++ b/sys/contrib/dev/acpica/components/executer/exnames.c
@@ -221,7 +221,7 @@ AcpiExNameSegment (
if (NameString)
{
- ACPI_STRCAT (NameString, CharBuf);
+ strcat (NameString, CharBuf);
ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
"Appended to - %s\n", NameString));
}
diff --git a/sys/contrib/dev/acpica/components/executer/exoparg2.c b/sys/contrib/dev/acpica/components/executer/exoparg2.c
index da1eb6c..e11c0b3 100644
--- a/sys/contrib/dev/acpica/components/executer/exoparg2.c
+++ b/sys/contrib/dev/acpica/components/executer/exoparg2.c
@@ -368,7 +368,7 @@ AcpiExOpcode_2A_1T_1R (
* Copy the raw buffer data with no transform.
* (NULL terminated already)
*/
- ACPI_MEMCPY (ReturnDesc->String.Pointer,
+ memcpy (ReturnDesc->String.Pointer,
Operand[0]->Buffer.Pointer, Length);
break;
@@ -412,6 +412,8 @@ AcpiExOpcode_2A_1T_1R (
}
ReturnDesc->Reference.TargetType = ACPI_TYPE_BUFFER_FIELD;
+ ReturnDesc->Reference.IndexPointer =
+ &(Operand[0]->Buffer.Pointer [Index]);
break;
case ACPI_TYPE_BUFFER:
@@ -423,6 +425,8 @@ AcpiExOpcode_2A_1T_1R (
}
ReturnDesc->Reference.TargetType = ACPI_TYPE_BUFFER_FIELD;
+ ReturnDesc->Reference.IndexPointer =
+ &(Operand[0]->Buffer.Pointer [Index]);
break;
case ACPI_TYPE_PACKAGE:
@@ -434,7 +438,8 @@ AcpiExOpcode_2A_1T_1R (
}
ReturnDesc->Reference.TargetType = ACPI_TYPE_PACKAGE;
- ReturnDesc->Reference.Where = &Operand[0]->Package.Elements [Index];
+ ReturnDesc->Reference.Where =
+ &Operand[0]->Package.Elements [Index];
break;
default:
diff --git a/sys/contrib/dev/acpica/components/executer/exoparg3.c b/sys/contrib/dev/acpica/components/executer/exoparg3.c
index da873c3..54636bc 100644
--- a/sys/contrib/dev/acpica/components/executer/exoparg3.c
+++ b/sys/contrib/dev/acpica/components/executer/exoparg3.c
@@ -261,7 +261,7 @@ AcpiExOpcode_3A_1T_1R (
{
/* We have a buffer, copy the portion requested */
- ACPI_MEMCPY (Buffer, Operand[0]->String.Pointer + Index,
+ memcpy (Buffer, Operand[0]->String.Pointer + Index,
Length);
}
diff --git a/sys/contrib/dev/acpica/components/executer/exregion.c b/sys/contrib/dev/acpica/components/executer/exregion.c
index 59b4612..6bfdf7b 100644
--- a/sys/contrib/dev/acpica/components/executer/exregion.c
+++ b/sys/contrib/dev/acpica/components/executer/exregion.c
@@ -558,13 +558,13 @@ AcpiExDataTableSpaceHandler (
{
case ACPI_READ:
- ACPI_MEMCPY (ACPI_CAST_PTR (char, Value), ACPI_PHYSADDR_TO_PTR (Address),
+ memcpy (ACPI_CAST_PTR (char, Value), ACPI_PHYSADDR_TO_PTR (Address),
ACPI_DIV_8 (BitWidth));
break;
case ACPI_WRITE:
- ACPI_MEMCPY (ACPI_PHYSADDR_TO_PTR (Address), ACPI_CAST_PTR (char, Value),
+ memcpy (ACPI_PHYSADDR_TO_PTR (Address), ACPI_CAST_PTR (char, Value),
ACPI_DIV_8 (BitWidth));
break;
diff --git a/sys/contrib/dev/acpica/components/executer/exstorob.c b/sys/contrib/dev/acpica/components/executer/exstorob.c
index c238310..683bfce 100644
--- a/sys/contrib/dev/acpica/components/executer/exstorob.c
+++ b/sys/contrib/dev/acpica/components/executer/exstorob.c
@@ -109,8 +109,8 @@ AcpiExStoreBufferToBuffer (
{
/* Clear existing buffer and copy in the new one */
- ACPI_MEMSET (TargetDesc->Buffer.Pointer, 0, TargetDesc->Buffer.Length);
- ACPI_MEMCPY (TargetDesc->Buffer.Pointer, Buffer, Length);
+ memset (TargetDesc->Buffer.Pointer, 0, TargetDesc->Buffer.Length);
+ memcpy (TargetDesc->Buffer.Pointer, Buffer, Length);
#ifdef ACPI_OBSOLETE_BEHAVIOR
/*
@@ -139,7 +139,7 @@ AcpiExStoreBufferToBuffer (
{
/* Truncate the source, copy only what will fit */
- ACPI_MEMCPY (TargetDesc->Buffer.Pointer, Buffer,
+ memcpy (TargetDesc->Buffer.Pointer, Buffer,
TargetDesc->Buffer.Length);
ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
@@ -203,9 +203,9 @@ AcpiExStoreStringToString (
* String will fit in existing non-static buffer.
* Clear old string and copy in the new one
*/
- ACPI_MEMSET (TargetDesc->String.Pointer, 0,
+ memset (TargetDesc->String.Pointer, 0,
(ACPI_SIZE) TargetDesc->String.Length + 1);
- ACPI_MEMCPY (TargetDesc->String.Pointer, Buffer, Length);
+ memcpy (TargetDesc->String.Pointer, Buffer, Length);
}
else
{
@@ -229,7 +229,7 @@ AcpiExStoreStringToString (
}
TargetDesc->Common.Flags &= ~AOPOBJ_STATIC_POINTER;
- ACPI_MEMCPY (TargetDesc->String.Pointer, Buffer, Length);
+ memcpy (TargetDesc->String.Pointer, Buffer, Length);
}
/* Set the new target length */
diff --git a/sys/contrib/dev/acpica/components/executer/exutils.c b/sys/contrib/dev/acpica/components/executer/exutils.c
index a55b171..1cd60fa 100644
--- a/sys/contrib/dev/acpica/components/executer/exutils.c
+++ b/sys/contrib/dev/acpica/components/executer/exutils.c
@@ -433,6 +433,43 @@ AcpiExIntegerToString (
/*******************************************************************************
*
+ * FUNCTION: AcpiExPciClsToString
+ *
+ * PARAMETERS: OutString - Where to put the converted string (7 bytes)
+ * PARAMETERS: ClassCode - PCI class code to be converted (3 bytes)
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Convert 3-bytes PCI class code to string representation.
+ * Return buffer must be large enough to hold the string. The
+ * string returned is always exactly of length
+ * ACPI_PCICLS_STRING_SIZE (includes null terminator).
+ *
+ ******************************************************************************/
+
+void
+AcpiExPciClsToString (
+ char *OutString,
+ UINT8 ClassCode[3])
+{
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ /* All 3 bytes are hexadecimal */
+
+ OutString[0] = AcpiUtHexToAsciiChar ((UINT64) ClassCode[0], 4);
+ OutString[1] = AcpiUtHexToAsciiChar ((UINT64) ClassCode[0], 0);
+ OutString[2] = AcpiUtHexToAsciiChar ((UINT64) ClassCode[1], 4);
+ OutString[3] = AcpiUtHexToAsciiChar ((UINT64) ClassCode[1], 0);
+ OutString[4] = AcpiUtHexToAsciiChar ((UINT64) ClassCode[2], 4);
+ OutString[5] = AcpiUtHexToAsciiChar ((UINT64) ClassCode[2], 0);
+ OutString[6] = 0;
+}
+
+
+/*******************************************************************************
+ *
* FUNCTION: AcpiIsValidSpaceId
*
* PARAMETERS: SpaceId - ID to be validated
diff --git a/sys/contrib/dev/acpica/components/hardware/hwgpe.c b/sys/contrib/dev/acpica/components/hardware/hwgpe.c
index 093ba80..c293bef 100644
--- a/sys/contrib/dev/acpica/components/hardware/hwgpe.c
+++ b/sys/contrib/dev/acpica/components/hardware/hwgpe.c
@@ -97,6 +97,8 @@ AcpiHwGetGpeRegisterBit (
* RETURN: Status
*
* DESCRIPTION: Enable or disable a single GPE in the parent enable register.
+ * The EnableMask field of the involved GPE register must be
+ * updated by the caller if necessary.
*
******************************************************************************/
@@ -133,7 +135,7 @@ AcpiHwLowSetGpe (
/* Set or clear just the bit that corresponds to this GPE */
RegisterBit = AcpiHwGetGpeRegisterBit (GpeEventInfo);
- switch (Action & ~ACPI_GPE_SAVE_MASK)
+ switch (Action)
{
case ACPI_GPE_CONDITIONAL_ENABLE:
@@ -165,10 +167,6 @@ AcpiHwLowSetGpe (
/* Write the updated enable mask */
Status = AcpiHwWrite (EnableMask, &GpeRegisterInfo->EnableAddress);
- if (ACPI_SUCCESS (Status) && (Action & ACPI_GPE_SAVE_MASK))
- {
- GpeRegisterInfo->EnableMask = (UINT8) EnableMask;
- }
return (Status);
}
@@ -334,11 +332,8 @@ AcpiHwGpeEnableWrite (
ACPI_STATUS Status;
+ GpeRegisterInfo->EnableMask = EnableMask;
Status = AcpiHwWrite (EnableMask, &GpeRegisterInfo->EnableAddress);
- if (ACPI_SUCCESS (Status))
- {
- GpeRegisterInfo->EnableMask = EnableMask;
- }
return (Status);
}
diff --git a/sys/contrib/dev/acpica/components/hardware/hwxfsleep.c b/sys/contrib/dev/acpica/components/hardware/hwxfsleep.c
index 8d5ba97..5610398 100644
--- a/sys/contrib/dev/acpica/components/hardware/hwxfsleep.c
+++ b/sys/contrib/dev/acpica/components/hardware/hwxfsleep.c
@@ -51,6 +51,14 @@
/* Local prototypes */
+#if (!ACPI_REDUCED_HARDWARE)
+static ACPI_STATUS
+AcpiHwSetFirmwareWakingVector (
+ ACPI_TABLE_FACS *Facs,
+ ACPI_PHYSICAL_ADDRESS PhysicalAddress,
+ ACPI_PHYSICAL_ADDRESS PhysicalAddress64);
+#endif
+
static ACPI_STATUS
AcpiHwSleepDispatch (
UINT8 SleepState,
@@ -77,29 +85,33 @@ static ACPI_SLEEP_FUNCTIONS AcpiSleepDispatch[] =
/*
* These functions are removed for the ACPI_REDUCED_HARDWARE case:
* AcpiSetFirmwareWakingVector
- * AcpiSetFirmwareWakingVector64
* AcpiEnterSleepStateS4bios
*/
#if (!ACPI_REDUCED_HARDWARE)
/*******************************************************************************
*
- * FUNCTION: AcpiSetFirmwareWakingVector
+ * FUNCTION: AcpiHwSetFirmwareWakingVector
*
- * PARAMETERS: PhysicalAddress - 32-bit physical address of ACPI real mode
- * entry point.
+ * PARAMETERS: Facs - Pointer to FACS table
+ * PhysicalAddress - 32-bit physical address of ACPI real mode
+ * entry point
+ * PhysicalAddress64 - 64-bit physical address of ACPI protected
+ * entry point
*
* RETURN: Status
*
- * DESCRIPTION: Sets the 32-bit FirmwareWakingVector field of the FACS
+ * DESCRIPTION: Sets the FirmwareWakingVector fields of the FACS
*
******************************************************************************/
-ACPI_STATUS
-AcpiSetFirmwareWakingVector (
- UINT32 PhysicalAddress)
+static ACPI_STATUS
+AcpiHwSetFirmwareWakingVector (
+ ACPI_TABLE_FACS *Facs,
+ ACPI_PHYSICAL_ADDRESS PhysicalAddress,
+ ACPI_PHYSICAL_ADDRESS PhysicalAddress64)
{
- ACPI_FUNCTION_TRACE (AcpiSetFirmwareWakingVector);
+ ACPI_FUNCTION_TRACE (AcpiHwSetFirmwareWakingVector);
/*
@@ -112,60 +124,73 @@ AcpiSetFirmwareWakingVector (
/* Set the 32-bit vector */
- AcpiGbl_FACS->FirmwareWakingVector = PhysicalAddress;
+ Facs->FirmwareWakingVector = (UINT32) PhysicalAddress;
- /* Clear the 64-bit vector if it exists */
-
- if ((AcpiGbl_FACS->Length > 32) && (AcpiGbl_FACS->Version >= 1))
+ if (Facs->Length > 32)
{
- AcpiGbl_FACS->XFirmwareWakingVector = 0;
+ if (Facs->Version >= 1)
+ {
+ /* Set the 64-bit vector */
+
+ Facs->XFirmwareWakingVector = PhysicalAddress64;
+ }
+ else
+ {
+ /* Clear the 64-bit vector if it exists */
+
+ Facs->XFirmwareWakingVector = 0;
+ }
}
return_ACPI_STATUS (AE_OK);
}
-ACPI_EXPORT_SYMBOL (AcpiSetFirmwareWakingVector)
-
-#if ACPI_MACHINE_WIDTH == 64
/*******************************************************************************
*
- * FUNCTION: AcpiSetFirmwareWakingVector64
+ * FUNCTION: AcpiSetFirmwareWakingVector
*
- * PARAMETERS: PhysicalAddress - 64-bit physical address of ACPI protected
- * mode entry point.
+ * PARAMETERS: PhysicalAddress - 32-bit physical address of ACPI real mode
+ * entry point
+ * PhysicalAddress64 - 64-bit physical address of ACPI protected
+ * entry point
*
* RETURN: Status
*
- * DESCRIPTION: Sets the 64-bit X_FirmwareWakingVector field of the FACS, if
- * it exists in the table. This function is intended for use with
- * 64-bit host operating systems.
+ * DESCRIPTION: Sets the FirmwareWakingVector fields of the FACS
*
******************************************************************************/
ACPI_STATUS
-AcpiSetFirmwareWakingVector64 (
- UINT64 PhysicalAddress)
+AcpiSetFirmwareWakingVector (
+ ACPI_PHYSICAL_ADDRESS PhysicalAddress,
+ ACPI_PHYSICAL_ADDRESS PhysicalAddress64)
{
- ACPI_FUNCTION_TRACE (AcpiSetFirmwareWakingVector64);
+ ACPI_FUNCTION_TRACE (AcpiSetFirmwareWakingVector);
- /* Determine if the 64-bit vector actually exists */
+ /* If Hardware Reduced flag is set, there is no FACS */
- if ((AcpiGbl_FACS->Length <= 32) || (AcpiGbl_FACS->Version < 1))
+ if (AcpiGbl_ReducedHardware)
{
- return_ACPI_STATUS (AE_NOT_EXIST);
+ return_ACPI_STATUS (AE_OK);
}
- /* Clear 32-bit vector, set the 64-bit X_ vector */
+ if (AcpiGbl_Facs32)
+ {
+ (void) AcpiHwSetFirmwareWakingVector (AcpiGbl_Facs32,
+ PhysicalAddress, PhysicalAddress64);
+ }
+ if (AcpiGbl_Facs64)
+ {
+ (void) AcpiHwSetFirmwareWakingVector (AcpiGbl_Facs64,
+ PhysicalAddress, PhysicalAddress64);
+ }
- AcpiGbl_FACS->FirmwareWakingVector = 0;
- AcpiGbl_FACS->XFirmwareWakingVector = PhysicalAddress;
return_ACPI_STATUS (AE_OK);
}
-ACPI_EXPORT_SYMBOL (AcpiSetFirmwareWakingVector64)
-#endif
+ACPI_EXPORT_SYMBOL (AcpiSetFirmwareWakingVector)
/*******************************************************************************
diff --git a/sys/contrib/dev/acpica/components/namespace/nsaccess.c b/sys/contrib/dev/acpica/components/namespace/nsaccess.c
index 667b5af..46a64f5 100644
--- a/sys/contrib/dev/acpica/components/namespace/nsaccess.c
+++ b/sys/contrib/dev/acpica/components/namespace/nsaccess.c
@@ -111,7 +111,7 @@ AcpiNsRootInitialize (
{
/* _OSI is optional for now, will be permanent later */
- if (!ACPI_STRCMP (InitVal->Name, "_OSI") && !AcpiGbl_CreateOsiMethod)
+ if (!strcmp (InitVal->Name, "_OSI") && !AcpiGbl_CreateOsiMethod)
{
continue;
}
@@ -191,7 +191,7 @@ AcpiNsRootInitialize (
/* Build an object around the static string */
- ObjDesc->String.Length = (UINT32) ACPI_STRLEN (Val);
+ ObjDesc->String.Length = (UINT32) strlen (Val);
ObjDesc->String.Pointer = Val;
ObjDesc->Common.Flags |= AOPOBJ_STATIC_POINTER;
break;
@@ -212,7 +212,7 @@ AcpiNsRootInitialize (
/* Special case for ACPI Global Lock */
- if (ACPI_STRCMP (InitVal->Name, "_GL_") == 0)
+ if (strcmp (InitVal->Name, "_GL_") == 0)
{
AcpiGbl_GlobalLockMutex = ObjDesc;
@@ -319,7 +319,9 @@ AcpiNsLookup (
return_ACPI_STATUS (AE_BAD_PARAMETER);
}
- LocalFlags = Flags & ~(ACPI_NS_ERROR_IF_FOUND | ACPI_NS_SEARCH_PARENT);
+ LocalFlags = Flags &
+ ~(ACPI_NS_ERROR_IF_FOUND | ACPI_NS_OVERRIDE_IF_FOUND |
+ ACPI_NS_SEARCH_PARENT);
*ReturnNode = ACPI_ENTRY_NOT_FOUND;
AcpiGbl_NsLookupCount++;
@@ -571,6 +573,13 @@ AcpiNsLookup (
{
LocalFlags |= ACPI_NS_ERROR_IF_FOUND;
}
+
+ /* Set override flag according to caller */
+
+ if (Flags & ACPI_NS_OVERRIDE_IF_FOUND)
+ {
+ LocalFlags |= ACPI_NS_OVERRIDE_IF_FOUND;
+ }
}
/* Extract one ACPI name from the front of the pathname */
diff --git a/sys/contrib/dev/acpica/components/namespace/nsconvert.c b/sys/contrib/dev/acpica/components/namespace/nsconvert.c
index 091c5cc..99883c2 100644
--- a/sys/contrib/dev/acpica/components/namespace/nsconvert.c
+++ b/sys/contrib/dev/acpica/components/namespace/nsconvert.c
@@ -202,7 +202,7 @@ AcpiNsConvertToString (
* Copy the raw buffer data with no transform. String is already NULL
* terminated at Length+1.
*/
- ACPI_MEMCPY (NewObject->String.Pointer,
+ memcpy (NewObject->String.Pointer,
OriginalObject->Buffer.Pointer, Length);
break;
@@ -269,7 +269,7 @@ AcpiNsConvertToBuffer (
return (AE_NO_MEMORY);
}
- ACPI_MEMCPY (NewObject->Buffer.Pointer,
+ memcpy (NewObject->Buffer.Pointer,
OriginalObject->String.Pointer, OriginalObject->String.Length);
break;
diff --git a/sys/contrib/dev/acpica/components/namespace/nsdump.c b/sys/contrib/dev/acpica/components/namespace/nsdump.c
index 77fb279..f3f3fed 100644
--- a/sys/contrib/dev/acpica/components/namespace/nsdump.c
+++ b/sys/contrib/dev/acpica/components/namespace/nsdump.c
@@ -122,7 +122,7 @@ AcpiNsPrintPathname (
{
for (i = 0; i < 4; i++)
{
- ACPI_IS_PRINT (Pathname[i]) ?
+ isprint ((int) Pathname[i]) ?
AcpiOsPrintf ("%c", Pathname[i]) :
AcpiOsPrintf ("?");
}
diff --git a/sys/contrib/dev/acpica/components/namespace/nseval.c b/sys/contrib/dev/acpica/components/namespace/nseval.c
index ac1d9a9..fb39171 100644
--- a/sys/contrib/dev/acpica/components/namespace/nseval.c
+++ b/sys/contrib/dev/acpica/components/namespace/nseval.c
@@ -63,15 +63,14 @@ AcpiNsExecModuleCode (
*
* FUNCTION: AcpiNsEvaluate
*
- * PARAMETERS: Info - Evaluation info block, contains:
+ * PARAMETERS: Info - Evaluation info block, contains these fields
+ * and more:
* PrefixNode - Prefix or Method/Object Node to execute
* RelativePath - Name of method to execute, If NULL, the
* Node is the object to execute
* Parameters - List of parameters to pass to the method,
* terminated by NULL. Params itself may be
* NULL if no parameters are being passed.
- * ReturnObject - Where to put method's return value (if
- * any). If NULL, no value is returned.
* ParameterType - Type of Parameter list
* ReturnObject - Where to put method's return value (if
* any). If NULL, no value is returned.
@@ -463,7 +462,7 @@ AcpiNsExecModuleCode (
/* Initialize the evaluation information block */
- ACPI_MEMSET (Info, 0, sizeof (ACPI_EVALUATE_INFO));
+ memset (Info, 0, sizeof (ACPI_EVALUATE_INFO));
Info->PrefixNode = ParentNode;
/*
diff --git a/sys/contrib/dev/acpica/components/namespace/nsinit.c b/sys/contrib/dev/acpica/components/namespace/nsinit.c
index 847bf72..cbfc4a6f 100644
--- a/sys/contrib/dev/acpica/components/namespace/nsinit.c
+++ b/sys/contrib/dev/acpica/components/namespace/nsinit.c
@@ -105,7 +105,7 @@ AcpiNsInitializeObjects (
/* Set all init info to zero */
- ACPI_MEMSET (&Info, 0, sizeof (ACPI_INIT_WALK_INFO));
+ memset (&Info, 0, sizeof (ACPI_INIT_WALK_INFO));
/* Walk entire namespace from the supplied root */
@@ -614,7 +614,7 @@ AcpiNsInitOneDevice (
ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname (
ACPI_TYPE_METHOD, DeviceNode, METHOD_NAME__INI));
- ACPI_MEMSET (Info, 0, sizeof (ACPI_EVALUATE_INFO));
+ memset (Info, 0, sizeof (ACPI_EVALUATE_INFO));
Info->PrefixNode = DeviceNode;
Info->RelativePathname = METHOD_NAME__INI;
Info->Parameters = NULL;
diff --git a/sys/contrib/dev/acpica/components/namespace/nsparse.c b/sys/contrib/dev/acpica/components/namespace/nsparse.c
index 0f87fa1..7c6d29a 100644
--- a/sys/contrib/dev/acpica/components/namespace/nsparse.c
+++ b/sys/contrib/dev/acpica/components/namespace/nsparse.c
@@ -129,6 +129,14 @@ AcpiNsOneCompleteParse (
AmlStart, AmlLength, NULL, (UINT8) PassNumber);
}
+ /* Found OSDT table, enable the namespace override feature */
+
+ if (ACPI_COMPARE_NAME(Table->Signature, ACPI_SIG_OSDT) &&
+ PassNumber == ACPI_IMODE_LOAD_PASS1)
+ {
+ WalkState->NamespaceOverride = TRUE;
+ }
+
if (ACPI_FAILURE (Status))
{
AcpiDsDeleteWalkState (WalkState);
diff --git a/sys/contrib/dev/acpica/components/namespace/nsrepair2.c b/sys/contrib/dev/acpica/components/namespace/nsrepair2.c
index 410b009..24ac8b4 100644
--- a/sys/contrib/dev/acpica/components/namespace/nsrepair2.c
+++ b/sys/contrib/dev/acpica/components/namespace/nsrepair2.c
@@ -637,7 +637,7 @@ AcpiNsRepair_HID (
*/
for (Dest = NewString->String.Pointer; *Source; Dest++, Source++)
{
- *Dest = (char) ACPI_TOUPPER (*Source);
+ *Dest = (char) toupper ((int) *Source);
}
AcpiUtRemoveReference (ReturnObject);
diff --git a/sys/contrib/dev/acpica/components/namespace/nssearch.c b/sys/contrib/dev/acpica/components/namespace/nssearch.c
index 9f24f1c..a1e6d1a 100644
--- a/sys/contrib/dev/acpica/components/namespace/nssearch.c
+++ b/sys/contrib/dev/acpica/components/namespace/nssearch.c
@@ -338,10 +338,42 @@ AcpiNsSearchAndEnter (
* If we found it AND the request specifies that a find is an error,
* return the error
*/
- if ((Status == AE_OK) &&
- (Flags & ACPI_NS_ERROR_IF_FOUND))
+ if (Status == AE_OK)
{
- Status = AE_ALREADY_EXISTS;
+ /* The node was found in the namespace */
+
+ /*
+ * If the namespace override feature is enabled for this node,
+ * delete any existing attached sub-object and make the node
+ * look like a new node that is owned by the override table.
+ */
+ if (Flags & ACPI_NS_OVERRIDE_IF_FOUND)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
+ "Namespace override: %4.4s pass %u type %X Owner %X\n",
+ ACPI_CAST_PTR(char, &TargetName), InterpreterMode,
+ (*ReturnNode)->Type, WalkState->OwnerId));
+
+ AcpiNsDeleteChildren (*ReturnNode);
+ if (AcpiGbl_RuntimeNamespaceOverride)
+ {
+ AcpiUtRemoveReference ((*ReturnNode)->Object);
+ (*ReturnNode)->Object = NULL;
+ (*ReturnNode)->OwnerId = WalkState->OwnerId;
+ }
+ else
+ {
+ AcpiNsRemoveNode (*ReturnNode);
+ *ReturnNode = ACPI_ENTRY_NOT_FOUND;
+ }
+ }
+
+ /* Return an error if we don't expect to find the object */
+
+ else if (Flags & ACPI_NS_ERROR_IF_FOUND)
+ {
+ Status = AE_ALREADY_EXISTS;
+ }
}
#ifdef ACPI_ASL_COMPILER
diff --git a/sys/contrib/dev/acpica/components/namespace/nsutils.c b/sys/contrib/dev/acpica/components/namespace/nsutils.c
index d7320a6..4a59784 100644
--- a/sys/contrib/dev/acpica/components/namespace/nsutils.c
+++ b/sys/contrib/dev/acpica/components/namespace/nsutils.c
@@ -347,7 +347,7 @@ AcpiNsBuildInternalName (
{
/* Convert the character to uppercase and save it */
- Result[i] = (char) ACPI_TOUPPER ((int) *ExternalName);
+ Result[i] = (char) toupper ((int) *ExternalName);
ExternalName++;
}
}
diff --git a/sys/contrib/dev/acpica/components/namespace/nsxfeval.c b/sys/contrib/dev/acpica/components/namespace/nsxfeval.c
index 93226ef..9b4d2db 100644
--- a/sys/contrib/dev/acpica/components/namespace/nsxfeval.c
+++ b/sys/contrib/dev/acpica/components/namespace/nsxfeval.c
@@ -758,7 +758,7 @@ AcpiNsGetDeviceCallback (
return (AE_CTRL_DEPTH);
}
- NoMatch = ACPI_STRCMP (Hid->String, Info->Hid);
+ NoMatch = strcmp (Hid->String, Info->Hid);
ACPI_FREE (Hid);
if (NoMatch)
@@ -782,7 +782,7 @@ AcpiNsGetDeviceCallback (
Found = FALSE;
for (i = 0; i < Cid->Count; i++)
{
- if (ACPI_STRCMP (Cid->Ids[i].String, Info->Hid) == 0)
+ if (strcmp (Cid->Ids[i].String, Info->Hid) == 0)
{
/* Found a matching CID */
diff --git a/sys/contrib/dev/acpica/components/namespace/nsxfname.c b/sys/contrib/dev/acpica/components/namespace/nsxfname.c
index 804ea94..7ee3fdd 100644
--- a/sys/contrib/dev/acpica/components/namespace/nsxfname.c
+++ b/sys/contrib/dev/acpica/components/namespace/nsxfname.c
@@ -126,7 +126,7 @@ AcpiGetHandle (
/* Special case for root-only, since we can't search for it */
- if (!ACPI_STRCMP (Pathname, ACPI_NS_ROOT_PATH))
+ if (!strcmp (Pathname, ACPI_NS_ROOT_PATH))
{
*RetHandle = ACPI_CAST_PTR (ACPI_HANDLE, AcpiGbl_RootNode);
return (AE_OK);
@@ -271,7 +271,7 @@ AcpiNsCopyDeviceId (
/* Copy actual string and return a pointer to the next string area */
- ACPI_MEMCPY (StringArea, Source->String, Source->Length);
+ memcpy (StringArea, Source->String, Source->Length);
return (StringArea + Source->Length);
}
@@ -290,7 +290,7 @@ AcpiNsCopyDeviceId (
* control methods (Such as in the case of a device.)
*
* For Device and Processor objects, run the Device _HID, _UID, _CID, _SUB,
- * _STA, _ADR, _SxW, and _SxD methods.
+ * _CLS, _STA, _ADR, _SxW, and _SxD methods.
*
* Note: Allocates the return buffer, must be freed by the caller.
*
@@ -307,11 +307,12 @@ AcpiGetObjectInfo (
ACPI_PNP_DEVICE_ID *Hid = NULL;
ACPI_PNP_DEVICE_ID *Uid = NULL;
ACPI_PNP_DEVICE_ID *Sub = NULL;
+ ACPI_PNP_DEVICE_ID *Cls = NULL;
char *NextIdString;
ACPI_OBJECT_TYPE Type;
ACPI_NAME Name;
UINT8 ParamCount= 0;
- UINT8 Valid = 0;
+ UINT16 Valid = 0;
UINT32 InfoSize;
UINT32 i;
ACPI_STATUS Status;
@@ -359,7 +360,7 @@ AcpiGetObjectInfo (
{
/*
* Get extra info for ACPI Device/Processor objects only:
- * Run the Device _HID, _UID, _SUB, and _CID methods.
+ * Run the Device _HID, _UID, _SUB, _CID, and _CLS methods.
*
* Note: none of these methods are required, so they may or may
* not be present for this device. The Info->Valid bitfield is used
@@ -403,6 +404,15 @@ AcpiGetObjectInfo (
InfoSize += (CidList->ListSize - sizeof (ACPI_PNP_DEVICE_ID_LIST));
Valid |= ACPI_VALID_CID;
}
+
+ /* Execute the Device._CLS method */
+
+ Status = AcpiUtExecute_CLS (Node, &Cls);
+ if (ACPI_SUCCESS (Status))
+ {
+ InfoSize += Cls->Length;
+ Valid |= ACPI_VALID_CLS;
+ }
}
/*
@@ -534,6 +544,12 @@ AcpiGetObjectInfo (
}
}
+ if (Cls)
+ {
+ NextIdString = AcpiNsCopyDeviceId (&Info->ClassCode,
+ Cls, NextIdString);
+ }
+
/* Copy the fixed-length data */
Info->InfoSize = InfoSize;
@@ -563,6 +579,10 @@ Cleanup:
{
ACPI_FREE (CidList);
}
+ if (Cls)
+ {
+ ACPI_FREE (Cls);
+ }
return (Status);
}
@@ -684,7 +704,7 @@ AcpiInstallMethod (
/* Copy the method AML to the local buffer */
- ACPI_MEMCPY (AmlBuffer, AmlStart, AmlLength);
+ memcpy (AmlBuffer, AmlStart, AmlLength);
/* Initialize the method object with the new method's information */
diff --git a/sys/contrib/dev/acpica/components/parser/psutils.c b/sys/contrib/dev/acpica/components/parser/psutils.c
index 1a269a6..8581a94 100644
--- a/sys/contrib/dev/acpica/components/parser/psutils.c
+++ b/sys/contrib/dev/acpica/components/parser/psutils.c
@@ -104,7 +104,7 @@ AcpiPsInitOp (
Op->Common.DescriptorType = ACPI_DESC_TYPE_PARSER;
Op->Common.AmlOpcode = Opcode;
- ACPI_DISASM_ONLY_MEMBERS (ACPI_STRNCPY (Op->Common.AmlOpName,
+ ACPI_DISASM_ONLY_MEMBERS (strncpy (Op->Common.AmlOpName,
(AcpiPsGetOpcodeInfo (Opcode))->Name,
sizeof (Op->Common.AmlOpName)));
}
diff --git a/sys/contrib/dev/acpica/components/resources/rscreate.c b/sys/contrib/dev/acpica/components/resources/rscreate.c
index c646129..6225590 100644
--- a/sys/contrib/dev/acpica/components/resources/rscreate.c
+++ b/sys/contrib/dev/acpica/components/resources/rscreate.c
@@ -374,12 +374,12 @@ AcpiRsCreatePciRoutingTable (
/* +1 to include null terminator */
- UserPrt->Length += (UINT32) ACPI_STRLEN (UserPrt->Source) + 1;
+ UserPrt->Length += (UINT32) strlen (UserPrt->Source) + 1;
break;
case ACPI_TYPE_STRING:
- ACPI_STRCPY (UserPrt->Source, ObjDesc->String.Pointer);
+ strcpy (UserPrt->Source, ObjDesc->String.Pointer);
/*
* Add to the Length field the length of the string
diff --git a/sys/contrib/dev/acpica/components/resources/rsmisc.c b/sys/contrib/dev/acpica/components/resources/rsmisc.c
index bc5b803..cef8000 100644
--- a/sys/contrib/dev/acpica/components/resources/rsmisc.c
+++ b/sys/contrib/dev/acpica/components/resources/rsmisc.c
@@ -130,7 +130,7 @@ AcpiRsConvertAmlToResource (
/*
* Get the resource type and the initial (minimum) length
*/
- ACPI_MEMSET (Resource, 0, INIT_RESOURCE_LENGTH (Info));
+ memset (Resource, 0, INIT_RESOURCE_LENGTH (Info));
Resource->Type = INIT_RESOURCE_TYPE (Info);
Resource->Length = INIT_RESOURCE_LENGTH (Info);
break;
@@ -326,13 +326,13 @@ AcpiRsConvertAmlToResource (
case ACPI_RSC_SET8:
- ACPI_MEMSET (Destination, Info->AmlOffset, Info->Value);
+ memset (Destination, Info->AmlOffset, Info->Value);
break;
case ACPI_RSC_DATA8:
Target = ACPI_ADD_PTR (char, Resource, Info->Value);
- ACPI_MEMCPY (Destination, Source, ACPI_GET16 (Target));
+ memcpy (Destination, Source, ACPI_GET16 (Target));
break;
case ACPI_RSC_ADDRESS:
@@ -505,7 +505,7 @@ AcpiRsConvertResourceToAml (
{
case ACPI_RSC_INITSET:
- ACPI_MEMSET (Aml, 0, INIT_RESOURCE_LENGTH (Info));
+ memset (Aml, 0, INIT_RESOURCE_LENGTH (Info));
AmlLength = INIT_RESOURCE_LENGTH (Info);
AcpiRsSetResourceHeader (INIT_RESOURCE_TYPE (Info), AmlLength, Aml);
break;
diff --git a/sys/contrib/dev/acpica/components/resources/rsutils.c b/sys/contrib/dev/acpica/components/resources/rsutils.c
index c0e7b78..1bab925 100644
--- a/sys/contrib/dev/acpica/components/resources/rsutils.c
+++ b/sys/contrib/dev/acpica/components/resources/rsutils.c
@@ -174,7 +174,7 @@ AcpiRsMoveData (
case ACPI_RSC_MOVE_SERIAL_VEN:
case ACPI_RSC_MOVE_SERIAL_RES:
- ACPI_MEMCPY (Destination, Source, ItemCount);
+ memcpy (Destination, Source, ItemCount);
return;
/*
@@ -408,11 +408,11 @@ AcpiRsGetResourceSource (
*
* Zero the entire area of the buffer.
*/
- TotalLength = (UINT32) ACPI_STRLEN (
+ TotalLength = (UINT32) strlen (
ACPI_CAST_PTR (char, &AmlResourceSource[1])) + 1;
TotalLength = (UINT32) ACPI_ROUND_UP_TO_NATIVE_WORD (TotalLength);
- ACPI_MEMSET (ResourceSource->StringPtr, 0, TotalLength);
+ memset (ResourceSource->StringPtr, 0, TotalLength);
/* Copy the ResourceSource string to the destination */
@@ -477,7 +477,7 @@ AcpiRsSetResourceSource (
/* Copy the ResourceSource string */
- ACPI_STRCPY (ACPI_CAST_PTR (char, &AmlResourceSource[1]),
+ strcpy (ACPI_CAST_PTR (char, &AmlResourceSource[1]),
ResourceSource->StringPtr);
/*
diff --git a/sys/contrib/dev/acpica/components/resources/rsxface.c b/sys/contrib/dev/acpica/components/resources/rsxface.c
index a477f20..66c26e1 100644
--- a/sys/contrib/dev/acpica/components/resources/rsxface.c
+++ b/sys/contrib/dev/acpica/components/resources/rsxface.c
@@ -447,7 +447,7 @@ AcpiResourceToAddress64 (
/* Simple copy for 64 bit source */
- ACPI_MEMCPY (Out, &Resource->Data, sizeof (ACPI_RESOURCE_ADDRESS64));
+ memcpy (Out, &Resource->Data, sizeof (ACPI_RESOURCE_ADDRESS64));
break;
default:
@@ -558,7 +558,7 @@ AcpiRsMatchVendorResource (
*/
if ((Vendor->ByteLength < (ACPI_UUID_LENGTH + 1)) ||
(Vendor->UuidSubtype != Info->Uuid->Subtype) ||
- (ACPI_MEMCMP (Vendor->Uuid, Info->Uuid->Data, ACPI_UUID_LENGTH)))
+ (memcmp (Vendor->Uuid, Info->Uuid->Data, ACPI_UUID_LENGTH)))
{
return (AE_OK);
}
@@ -574,7 +574,7 @@ AcpiRsMatchVendorResource (
/* Found the correct resource, copy and return it */
- ACPI_MEMCPY (Buffer->Pointer, Resource, Resource->Length);
+ memcpy (Buffer->Pointer, Resource, Resource->Length);
Buffer->Length = Resource->Length;
/* Found the desired descriptor, terminate resource walk */
diff --git a/sys/contrib/dev/acpica/components/tables/tbdata.c b/sys/contrib/dev/acpica/components/tables/tbdata.c
index 70bac2c..b44dec0 100644
--- a/sys/contrib/dev/acpica/components/tables/tbdata.c
+++ b/sys/contrib/dev/acpica/components/tables/tbdata.c
@@ -77,7 +77,7 @@ AcpiTbInitTableDescriptor (
* Initialize the table descriptor. Set the pointer to NULL, since the
* table is not fully mapped at this time.
*/
- ACPI_MEMSET (TableDesc, 0, sizeof (ACPI_TABLE_DESC));
+ memset (TableDesc, 0, sizeof (ACPI_TABLE_DESC));
TableDesc->Address = Address;
TableDesc->Length = Table->Length;
TableDesc->Flags = Flags;
@@ -511,7 +511,7 @@ AcpiTbResizeRootTableList (
if (AcpiGbl_RootTableList.Tables)
{
- ACPI_MEMCPY (Tables, AcpiGbl_RootTableList.Tables,
+ memcpy (Tables, AcpiGbl_RootTableList.Tables,
(ACPI_SIZE) TableCount * sizeof (ACPI_TABLE_DESC));
if (AcpiGbl_RootTableList.Flags & ACPI_ROOT_ORIGIN_ALLOCATED)
diff --git a/sys/contrib/dev/acpica/components/tables/tbfadt.c b/sys/contrib/dev/acpica/components/tables/tbfadt.c
index f35e217..0917157 100644
--- a/sys/contrib/dev/acpica/components/tables/tbfadt.c
+++ b/sys/contrib/dev/acpica/components/tables/tbfadt.c
@@ -382,8 +382,16 @@ AcpiTbParseFadt (
if (!AcpiGbl_ReducedHardware)
{
- AcpiTbInstallFixedTable ((ACPI_PHYSICAL_ADDRESS) AcpiGbl_FADT.XFacs,
- ACPI_SIG_FACS, ACPI_TABLE_INDEX_FACS);
+ if (AcpiGbl_FADT.Facs)
+ {
+ AcpiTbInstallFixedTable ((ACPI_PHYSICAL_ADDRESS) AcpiGbl_FADT.Facs,
+ ACPI_SIG_FACS, ACPI_TABLE_INDEX_FACS);
+ }
+ if (AcpiGbl_FADT.XFacs)
+ {
+ AcpiTbInstallFixedTable ((ACPI_PHYSICAL_ADDRESS) AcpiGbl_FADT.XFacs,
+ ACPI_SIG_FACS, ACPI_TABLE_INDEX_X_FACS);
+ }
}
}
@@ -425,11 +433,11 @@ AcpiTbCreateLocalFadt (
/* Clear the entire local FADT */
- ACPI_MEMSET (&AcpiGbl_FADT, 0, sizeof (ACPI_TABLE_FADT));
+ memset (&AcpiGbl_FADT, 0, sizeof (ACPI_TABLE_FADT));
/* Copy the original FADT, up to sizeof (ACPI_TABLE_FADT) */
- ACPI_MEMCPY (&AcpiGbl_FADT, Table,
+ memcpy (&AcpiGbl_FADT, Table,
ACPI_MIN (Length, sizeof (ACPI_TABLE_FADT)));
/* Take a copy of the Hardware Reduced flag */
@@ -533,12 +541,9 @@ AcpiTbConvertFadt (
AcpiGbl_FADT.Header.Length = sizeof (ACPI_TABLE_FADT);
/*
- * Expand the 32-bit FACS and DSDT addresses to 64-bit as necessary.
+ * Expand the 32-bit DSDT addresses to 64-bit as necessary.
* Later ACPICA code will always use the X 64-bit field.
*/
- AcpiGbl_FADT.XFacs = AcpiTbSelectAddress ("FACS",
- AcpiGbl_FADT.Facs, AcpiGbl_FADT.XFacs);
-
AcpiGbl_FADT.XDsdt = AcpiTbSelectAddress ("DSDT",
AcpiGbl_FADT.Dsdt, AcpiGbl_FADT.XDsdt);
diff --git a/sys/contrib/dev/acpica/components/tables/tbfind.c b/sys/contrib/dev/acpica/components/tables/tbfind.c
index 30a5750..e5c4cee 100644
--- a/sys/contrib/dev/acpica/components/tables/tbfind.c
+++ b/sys/contrib/dev/acpica/components/tables/tbfind.c
@@ -83,16 +83,16 @@ AcpiTbFindTable (
/* Normalize the input strings */
- ACPI_MEMSET (&Header, 0, sizeof (ACPI_TABLE_HEADER));
+ memset (&Header, 0, sizeof (ACPI_TABLE_HEADER));
ACPI_MOVE_NAME (Header.Signature, Signature);
- ACPI_STRNCPY (Header.OemId, OemId, ACPI_OEM_ID_SIZE);
- ACPI_STRNCPY (Header.OemTableId, OemTableId, ACPI_OEM_TABLE_ID_SIZE);
+ strncpy (Header.OemId, OemId, ACPI_OEM_ID_SIZE);
+ strncpy (Header.OemTableId, OemTableId, ACPI_OEM_TABLE_ID_SIZE);
/* Search for the table */
for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; ++i)
{
- if (ACPI_MEMCMP (&(AcpiGbl_RootTableList.Tables[i].Signature),
+ if (memcmp (&(AcpiGbl_RootTableList.Tables[i].Signature),
Header.Signature, ACPI_NAME_SIZE))
{
/* Not the requested table */
@@ -120,13 +120,13 @@ AcpiTbFindTable (
/* Check for table match on all IDs */
- if (!ACPI_MEMCMP (AcpiGbl_RootTableList.Tables[i].Pointer->Signature,
+ if (!memcmp (AcpiGbl_RootTableList.Tables[i].Pointer->Signature,
Header.Signature, ACPI_NAME_SIZE) &&
(!OemId[0] ||
- !ACPI_MEMCMP (AcpiGbl_RootTableList.Tables[i].Pointer->OemId,
+ !memcmp (AcpiGbl_RootTableList.Tables[i].Pointer->OemId,
Header.OemId, ACPI_OEM_ID_SIZE)) &&
(!OemTableId[0] ||
- !ACPI_MEMCMP (AcpiGbl_RootTableList.Tables[i].Pointer->OemTableId,
+ !memcmp (AcpiGbl_RootTableList.Tables[i].Pointer->OemTableId,
Header.OemTableId, ACPI_OEM_TABLE_ID_SIZE)))
{
*TableIndex = i;
diff --git a/sys/contrib/dev/acpica/components/tables/tbinstal.c b/sys/contrib/dev/acpica/components/tables/tbinstal.c
index d77d2c8..a6680cf 100644
--- a/sys/contrib/dev/acpica/components/tables/tbinstal.c
+++ b/sys/contrib/dev/acpica/components/tables/tbinstal.c
@@ -94,7 +94,7 @@ AcpiTbCompareTables (
* not just the header.
*/
IsIdentical = (BOOLEAN)((TableDesc->Length != TableLength ||
- ACPI_MEMCMP (TableDesc->Pointer, Table, TableLength)) ?
+ memcmp (TableDesc->Pointer, Table, TableLength)) ?
FALSE : TRUE);
/* Release the acquired table */
@@ -309,7 +309,7 @@ AcpiTbInstallStandardTable (
*/
if ((NewTableDesc.Signature.Ascii[0] != 0x00) &&
(!ACPI_COMPARE_NAME (&NewTableDesc.Signature, ACPI_SIG_SSDT)) &&
- (ACPI_STRNCMP (NewTableDesc.Signature.Ascii, "OEM", 3)))
+ (strncmp (NewTableDesc.Signature.Ascii, "OEM", 3)))
{
ACPI_BIOS_ERROR ((AE_INFO,
"Table has invalid signature [%4.4s] (0x%8.8X), "
diff --git a/sys/contrib/dev/acpica/components/tables/tbprint.c b/sys/contrib/dev/acpica/components/tables/tbprint.c
index f0ea090..f56d002 100644
--- a/sys/contrib/dev/acpica/components/tables/tbprint.c
+++ b/sys/contrib/dev/acpica/components/tables/tbprint.c
@@ -84,7 +84,7 @@ AcpiTbFixString (
while (Length && *String)
{
- if (!ACPI_IS_PRINT (*String))
+ if (!isprint ((int) *String))
{
*String = '?';
}
@@ -114,7 +114,7 @@ AcpiTbCleanupTableHeader (
ACPI_TABLE_HEADER *Header)
{
- ACPI_MEMCPY (OutHeader, Header, sizeof (ACPI_TABLE_HEADER));
+ memcpy (OutHeader, Header, sizeof (ACPI_TABLE_HEADER));
AcpiTbFixString (OutHeader->Signature, ACPI_NAME_SIZE);
AcpiTbFixString (OutHeader->OemId, ACPI_OEM_ID_SIZE);
@@ -156,7 +156,7 @@ AcpiTbPrintTableHeader (
{
/* RSDP has no common fields */
- ACPI_MEMCPY (LocalHeader.OemId,
+ memcpy (LocalHeader.OemId,
ACPI_CAST_PTR (ACPI_TABLE_RSDP, Header)->OemId, ACPI_OEM_ID_SIZE);
AcpiTbFixString (LocalHeader.OemId, ACPI_OEM_ID_SIZE);
diff --git a/sys/contrib/dev/acpica/components/tables/tbutils.c b/sys/contrib/dev/acpica/components/tables/tbutils.c
index 8b80025..94ac4f9 100644
--- a/sys/contrib/dev/acpica/components/tables/tbutils.c
+++ b/sys/contrib/dev/acpica/components/tables/tbutils.c
@@ -75,8 +75,6 @@ ACPI_STATUS
AcpiTbInitializeFacs (
void)
{
- ACPI_STATUS Status;
-
/* If Hardware Reduced flag is set, there is no FACS */
@@ -86,9 +84,23 @@ AcpiTbInitializeFacs (
return (AE_OK);
}
- Status = AcpiGetTableByIndex (ACPI_TABLE_INDEX_FACS,
- ACPI_CAST_INDIRECT_PTR (ACPI_TABLE_HEADER, &AcpiGbl_FACS));
- return (Status);
+ (void) AcpiGetTableByIndex (ACPI_TABLE_INDEX_FACS,
+ ACPI_CAST_INDIRECT_PTR (ACPI_TABLE_HEADER, &AcpiGbl_Facs32));
+ (void) AcpiGetTableByIndex (ACPI_TABLE_INDEX_X_FACS,
+ ACPI_CAST_INDIRECT_PTR (ACPI_TABLE_HEADER, &AcpiGbl_Facs64));
+
+ if (AcpiGbl_Facs64 && (!AcpiGbl_Facs32 || !AcpiGbl_Use32BitFacsAddresses))
+ {
+ AcpiGbl_FACS = AcpiGbl_Facs64;
+ }
+ else if (AcpiGbl_Facs32)
+ {
+ AcpiGbl_FACS = AcpiGbl_Facs32;
+ }
+
+ /* If there is no FACS, just continue. There was already an error msg */
+
+ return (AE_OK);
}
#endif /* !ACPI_REDUCED_HARDWARE */
@@ -111,7 +123,7 @@ AcpiTbTablesLoaded (
void)
{
- if (AcpiGbl_RootTableList.CurrentTableCount >= 3)
+ if (AcpiGbl_RootTableList.CurrentTableCount >= 4)
{
return (TRUE);
}
@@ -190,7 +202,7 @@ AcpiTbCopyDsdt (
return (NULL);
}
- ACPI_MEMCPY (NewTable, TableDesc->Pointer, TableDesc->Length);
+ memcpy (NewTable, TableDesc->Pointer, TableDesc->Length);
AcpiTbUninstallTable (TableDesc);
AcpiTbInitTableDescriptor (
@@ -389,11 +401,11 @@ AcpiTbParseRootTable (
TableEntry = ACPI_ADD_PTR (UINT8, Table, sizeof (ACPI_TABLE_HEADER));
/*
- * First two entries in the table array are reserved for the DSDT
- * and FACS, which are not actually present in the RSDT/XSDT - they
- * come from the FADT
+ * First three entries in the table array are reserved for the DSDT
+ * and 32bit/64bit FACS, which are not actually present in the
+ * RSDT/XSDT - they come from the FADT
*/
- AcpiGbl_RootTableList.CurrentTableCount = 2;
+ AcpiGbl_RootTableList.CurrentTableCount = 3;
/* Initialize the root table array from the RSDT/XSDT */
diff --git a/sys/contrib/dev/acpica/components/tables/tbxface.c b/sys/contrib/dev/acpica/components/tables/tbxface.c
index 7336b18..67f6fea 100644
--- a/sys/contrib/dev/acpica/components/tables/tbxface.c
+++ b/sys/contrib/dev/acpica/components/tables/tbxface.c
@@ -132,7 +132,7 @@ AcpiInitializeTables (
{
/* Root Table Array has been statically allocated by the host */
- ACPI_MEMSET (InitialTableArray, 0,
+ memset (InitialTableArray, 0,
(ACPI_SIZE) InitialTableCount * sizeof (ACPI_TABLE_DESC));
AcpiGbl_RootTableList.Tables = InitialTableArray;
@@ -271,7 +271,7 @@ AcpiGetTableHeader (
return (AE_NO_MEMORY);
}
- ACPI_MEMCPY (OutTableHeader, Header,
+ memcpy (OutTableHeader, Header,
sizeof (ACPI_TABLE_HEADER));
AcpiOsUnmapMemory (Header, sizeof (ACPI_TABLE_HEADER));
}
@@ -282,7 +282,7 @@ AcpiGetTableHeader (
}
else
{
- ACPI_MEMCPY (OutTableHeader,
+ memcpy (OutTableHeader,
AcpiGbl_RootTableList.Tables[i].Pointer,
sizeof (ACPI_TABLE_HEADER));
}
diff --git a/sys/contrib/dev/acpica/components/tables/tbxfload.c b/sys/contrib/dev/acpica/components/tables/tbxfload.c
index 805bbad..014d68b 100644
--- a/sys/contrib/dev/acpica/components/tables/tbxfload.c
+++ b/sys/contrib/dev/acpica/components/tables/tbxfload.c
@@ -164,7 +164,7 @@ AcpiTbLoadNamespace (
* Save the original DSDT header for detection of table corruption
* and/or replacement of the DSDT from outside the OS.
*/
- ACPI_MEMCPY (&AcpiGbl_OriginalDsdtHeader, AcpiGbl_DSDT,
+ memcpy (&AcpiGbl_OriginalDsdtHeader, AcpiGbl_DSDT,
sizeof (ACPI_TABLE_HEADER));
(void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
@@ -182,10 +182,13 @@ AcpiTbLoadNamespace (
(void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; ++i)
{
- if ((!ACPI_COMPARE_NAME (&(AcpiGbl_RootTableList.Tables[i].Signature),
+ if (!AcpiGbl_RootTableList.Tables[i].Address ||
+ (!ACPI_COMPARE_NAME (&(AcpiGbl_RootTableList.Tables[i].Signature),
ACPI_SIG_SSDT) &&
!ACPI_COMPARE_NAME (&(AcpiGbl_RootTableList.Tables[i].Signature),
- ACPI_SIG_PSDT)) ||
+ ACPI_SIG_PSDT) &&
+ !ACPI_COMPARE_NAME (&(AcpiGbl_RootTableList.Tables[i].Signature),
+ ACPI_SIG_OSDT)) ||
ACPI_FAILURE (AcpiTbValidateTable (
&AcpiGbl_RootTableList.Tables[i])))
{
@@ -238,11 +241,11 @@ AcpiInstallTable (
if (Physical)
{
- Flags = ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL;
+ Flags = ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL;
}
else
{
- Flags = ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL;
+ Flags = ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL;
}
Status = AcpiTbInstallStandardTable (Address, Flags,
diff --git a/sys/contrib/dev/acpica/components/utilities/utalloc.c b/sys/contrib/dev/acpica/components/utilities/utalloc.c
index 99fb15a1..c26259d 100644
--- a/sys/contrib/dev/acpica/components/utilities/utalloc.c
+++ b/sys/contrib/dev/acpica/components/utilities/utalloc.c
@@ -79,7 +79,7 @@ AcpiOsAllocateZeroed (
{
/* Clear the memory block */
- ACPI_MEMSET (Allocation, 0, Size);
+ memset (Allocation, 0, Size);
}
return (Allocation);
@@ -189,7 +189,7 @@ AcpiUtDeleteCaches (
if (AcpiGbl_DisplayFinalMemStats)
{
- ACPI_STRCPY (Buffer, "MEMORY");
+ strcpy (Buffer, "MEMORY");
(void) AcpiDbDisplayStatistics (Buffer);
}
#endif
@@ -359,6 +359,6 @@ AcpiUtInitializeBuffer (
/* Have a valid buffer, clear it */
- ACPI_MEMSET (Buffer->Pointer, 0, RequiredLength);
+ memset (Buffer->Pointer, 0, RequiredLength);
return (AE_OK);
}
diff --git a/sys/contrib/dev/acpica/components/utilities/utbuffer.c b/sys/contrib/dev/acpica/components/utilities/utbuffer.c
index cc41419..08a42cd 100644
--- a/sys/contrib/dev/acpica/components/utilities/utbuffer.c
+++ b/sys/contrib/dev/acpica/components/utilities/utbuffer.c
@@ -168,7 +168,7 @@ AcpiUtDumpBuffer (
}
BufChar = Buffer[(ACPI_SIZE) i + j];
- if (ACPI_IS_PRINT (BufChar))
+ if (isprint (BufChar))
{
AcpiOsPrintf ("%c", BufChar);
}
@@ -341,7 +341,7 @@ AcpiUtDumpBufferToFile (
}
BufChar = Buffer[(ACPI_SIZE) i + j];
- if (ACPI_IS_PRINT (BufChar))
+ if (isprint (BufChar))
{
AcpiUtFilePrintf (File, "%c", BufChar);
}
diff --git a/sys/contrib/dev/acpica/components/utilities/utcache.c b/sys/contrib/dev/acpica/components/utilities/utcache.c
index aa0161c..c252d8a 100644
--- a/sys/contrib/dev/acpica/components/utilities/utcache.c
+++ b/sys/contrib/dev/acpica/components/utilities/utcache.c
@@ -92,7 +92,7 @@ AcpiOsCreateCache (
/* Populate the cache object and return it */
- ACPI_MEMSET (Cache, 0, sizeof (ACPI_MEMORY_LIST));
+ memset (Cache, 0, sizeof (ACPI_MEMORY_LIST));
Cache->ListName = CacheName;
Cache->ObjectSize = ObjectSize;
Cache->MaxDepth = MaxDepth;
@@ -242,7 +242,7 @@ AcpiOsReleaseObject (
/* Mark the object as cached */
- ACPI_MEMSET (Object, 0xCA, Cache->ObjectSize);
+ memset (Object, 0xCA, Cache->ObjectSize);
ACPI_SET_DESCRIPTOR_TYPE (Object, ACPI_DESC_TYPE_CACHED);
/* Put the object at the head of the cache list */
@@ -318,7 +318,7 @@ AcpiOsAcquireObject (
/* Clear (zero) the previously used Object */
- ACPI_MEMSET (Object, 0, Cache->ObjectSize);
+ memset (Object, 0, Cache->ObjectSize);
}
else
{
diff --git a/sys/contrib/dev/acpica/components/utilities/utcopy.c b/sys/contrib/dev/acpica/components/utilities/utcopy.c
index 8a94ea6..2032dd4 100644
--- a/sys/contrib/dev/acpica/components/utilities/utcopy.c
+++ b/sys/contrib/dev/acpica/components/utilities/utcopy.c
@@ -146,7 +146,7 @@ AcpiUtCopyIsimpleToEsimple (
/* Always clear the external object */
- ACPI_MEMSET (ExternalObject, 0, sizeof (ACPI_OBJECT));
+ memset (ExternalObject, 0, sizeof (ACPI_OBJECT));
/*
* In general, the external object will be the same type as
@@ -165,7 +165,7 @@ AcpiUtCopyIsimpleToEsimple (
*BufferSpaceUsed = ACPI_ROUND_UP_TO_NATIVE_WORD (
(ACPI_SIZE) InternalObject->String.Length + 1);
- ACPI_MEMCPY ((void *) DataSpace,
+ memcpy ((void *) DataSpace,
(void *) InternalObject->String.Pointer,
(ACPI_SIZE) InternalObject->String.Length + 1);
break;
@@ -177,7 +177,7 @@ AcpiUtCopyIsimpleToEsimple (
*BufferSpaceUsed = ACPI_ROUND_UP_TO_NATIVE_WORD (
InternalObject->String.Length);
- ACPI_MEMCPY ((void *) DataSpace,
+ memcpy ((void *) DataSpace,
(void *) InternalObject->Buffer.Pointer,
InternalObject->Buffer.Length);
break;
@@ -528,7 +528,7 @@ AcpiUtCopyEsimpleToIsimple (
goto ErrorExit;
}
- ACPI_MEMCPY (InternalObject->String.Pointer,
+ memcpy (InternalObject->String.Pointer,
ExternalObject->String.Pointer,
ExternalObject->String.Length);
@@ -544,7 +544,7 @@ AcpiUtCopyEsimpleToIsimple (
goto ErrorExit;
}
- ACPI_MEMCPY (InternalObject->Buffer.Pointer,
+ memcpy (InternalObject->Buffer.Pointer,
ExternalObject->Buffer.Pointer,
ExternalObject->Buffer.Length);
@@ -732,7 +732,7 @@ AcpiUtCopySimpleObject (
CopySize = sizeof (ACPI_NAMESPACE_NODE);
}
- ACPI_MEMCPY (ACPI_CAST_PTR (char, DestDesc),
+ memcpy (ACPI_CAST_PTR (char, DestDesc),
ACPI_CAST_PTR (char, SourceDesc), CopySize);
/* Restore the saved fields */
@@ -766,7 +766,7 @@ AcpiUtCopySimpleObject (
/* Copy the actual buffer data */
- ACPI_MEMCPY (DestDesc->Buffer.Pointer,
+ memcpy (DestDesc->Buffer.Pointer,
SourceDesc->Buffer.Pointer, SourceDesc->Buffer.Length);
}
break;
@@ -788,7 +788,7 @@ AcpiUtCopySimpleObject (
/* Copy the actual string data */
- ACPI_MEMCPY (DestDesc->String.Pointer, SourceDesc->String.Pointer,
+ memcpy (DestDesc->String.Pointer, SourceDesc->String.Pointer,
(ACPI_SIZE) SourceDesc->String.Length + 1);
}
break;
diff --git a/sys/contrib/dev/acpica/components/utilities/utids.c b/sys/contrib/dev/acpica/components/utilities/utids.c
index 7d31429..6378e26 100644
--- a/sys/contrib/dev/acpica/components/utilities/utids.c
+++ b/sys/contrib/dev/acpica/components/utilities/utids.c
@@ -1,6 +1,6 @@
/******************************************************************************
*
- * Module Name: utids - support for device IDs - HID, UID, CID
+ * Module Name: utids - support for device IDs - HID, UID, CID, SUB, CLS
*
*****************************************************************************/
@@ -121,7 +121,7 @@ AcpiUtExecute_HID (
}
else
{
- ACPI_STRCPY (Hid->String, ObjDesc->String.Pointer);
+ strcpy (Hid->String, ObjDesc->String.Pointer);
}
Hid->Length = Length;
@@ -194,7 +194,7 @@ AcpiUtExecute_SUB (
/* Simply copy existing string */
- ACPI_STRCPY (Sub->String, ObjDesc->String.Pointer);
+ strcpy (Sub->String, ObjDesc->String.Pointer);
Sub->Length = Length;
*ReturnId = Sub;
@@ -279,7 +279,7 @@ AcpiUtExecute_UID (
}
else
{
- ACPI_STRCPY (Uid->String, ObjDesc->String.Pointer);
+ strcpy (Uid->String, ObjDesc->String.Pointer);
}
Uid->Length = Length;
@@ -426,7 +426,7 @@ AcpiUtExecute_CID (
{
/* Copy the String CID from the returned object */
- ACPI_STRCPY (NextIdString, CidObjects[i]->String.Pointer);
+ strcpy (NextIdString, CidObjects[i]->String.Pointer);
Length = CidObjects[i]->String.Length + 1;
}
@@ -449,3 +449,97 @@ Cleanup:
AcpiUtRemoveReference (ObjDesc);
return_ACPI_STATUS (Status);
}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtExecute_CLS
+ *
+ * PARAMETERS: DeviceNode - Node for the device
+ * ReturnId - Where the _CLS is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Executes the _CLS control method that returns PCI-defined
+ * class code of the device. The _CLS value is always a package
+ * containing PCI class information as a list of integers.
+ * The returned string has format "BBSSPP", where:
+ * BB = Base-class code
+ * SS = Sub-class code
+ * PP = Programming Interface code
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiUtExecute_CLS (
+ ACPI_NAMESPACE_NODE *DeviceNode,
+ ACPI_PNP_DEVICE_ID **ReturnId)
+{
+ ACPI_OPERAND_OBJECT *ObjDesc;
+ ACPI_OPERAND_OBJECT **ClsObjects;
+ UINT32 Count;
+ ACPI_PNP_DEVICE_ID *Cls;
+ UINT32 Length;
+ ACPI_STATUS Status;
+ UINT8 ClassCode[3] = {0, 0, 0};
+
+
+ ACPI_FUNCTION_TRACE (UtExecute_CLS);
+
+
+ Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__CLS,
+ ACPI_BTYPE_PACKAGE, &ObjDesc);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Get the size of the String to be returned, includes null terminator */
+
+ Length = ACPI_PCICLS_STRING_SIZE;
+ ClsObjects = ObjDesc->Package.Elements;
+ Count = ObjDesc->Package.Count;
+
+ if (ObjDesc->Common.Type == ACPI_TYPE_PACKAGE)
+ {
+ if (Count > 0 && ClsObjects[0]->Common.Type == ACPI_TYPE_INTEGER)
+ {
+ ClassCode[0] = (UINT8) ClsObjects[0]->Integer.Value;
+ }
+ if (Count > 1 && ClsObjects[1]->Common.Type == ACPI_TYPE_INTEGER)
+ {
+ ClassCode[1] = (UINT8) ClsObjects[1]->Integer.Value;
+ }
+ if (Count > 2 && ClsObjects[2]->Common.Type == ACPI_TYPE_INTEGER)
+ {
+ ClassCode[2] = (UINT8) ClsObjects[2]->Integer.Value;
+ }
+ }
+
+ /* Allocate a buffer for the CLS */
+
+ Cls = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_PNP_DEVICE_ID) + (ACPI_SIZE) Length);
+ if (!Cls)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ /* Area for the string starts after PNP_DEVICE_ID struct */
+
+ Cls->String = ACPI_ADD_PTR (char, Cls, sizeof (ACPI_PNP_DEVICE_ID));
+
+ /* Simply copy existing string */
+
+ AcpiExPciClsToString (Cls->String, ClassCode);
+ Cls->Length = Length;
+ *ReturnId = Cls;
+
+
+Cleanup:
+
+ /* On exit, we must delete the return object */
+
+ AcpiUtRemoveReference (ObjDesc);
+ return_ACPI_STATUS (Status);
+}
diff --git a/sys/contrib/dev/acpica/components/utilities/utmisc.c b/sys/contrib/dev/acpica/components/utilities/utmisc.c
index f3d2222..1aa02b8 100644
--- a/sys/contrib/dev/acpica/components/utilities/utmisc.c
+++ b/sys/contrib/dev/acpica/components/utilities/utmisc.c
@@ -71,10 +71,10 @@ AcpiUtIsPciRootBridge (
* Check if this is a PCI root bridge.
* ACPI 3.0+: check for a PCI Express root also.
*/
- if (!(ACPI_STRCMP (Id,
+ if (!(strcmp (Id,
PCI_ROOT_HID_STRING)) ||
- !(ACPI_STRCMP (Id,
+ !(strcmp (Id,
PCI_EXPRESS_ROOT_HID_STRING)))
{
return (TRUE);
@@ -108,7 +108,8 @@ AcpiUtIsAmlTable (
if (ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_DSDT) ||
ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_PSDT) ||
- ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_SSDT))
+ ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_SSDT) ||
+ ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_OSDT))
{
return (TRUE);
}
diff --git a/sys/contrib/dev/acpica/components/utilities/utosi.c b/sys/contrib/dev/acpica/components/utilities/utosi.c
index bf6ba86..d0dd1dc 100644
--- a/sys/contrib/dev/acpica/components/utilities/utosi.c
+++ b/sys/contrib/dev/acpica/components/utilities/utosi.c
@@ -256,7 +256,7 @@ AcpiUtInstallInterface (
return (AE_NO_MEMORY);
}
- InterfaceInfo->Name = ACPI_ALLOCATE_ZEROED (ACPI_STRLEN (InterfaceName) + 1);
+ InterfaceInfo->Name = ACPI_ALLOCATE_ZEROED (strlen (InterfaceName) + 1);
if (!InterfaceInfo->Name)
{
ACPI_FREE (InterfaceInfo);
@@ -265,7 +265,7 @@ AcpiUtInstallInterface (
/* Initialize new info and insert at the head of the global list */
- ACPI_STRCPY (InterfaceInfo->Name, InterfaceName);
+ strcpy (InterfaceInfo->Name, InterfaceName);
InterfaceInfo->Flags = ACPI_OSI_DYNAMIC;
InterfaceInfo->Next = AcpiGbl_SupportedInterfaces;
@@ -298,7 +298,7 @@ AcpiUtRemoveInterface (
PreviousInterface = NextInterface = AcpiGbl_SupportedInterfaces;
while (NextInterface)
{
- if (!ACPI_STRCMP (InterfaceName, NextInterface->Name))
+ if (!strcmp (InterfaceName, NextInterface->Name))
{
/* Found: name is in either the static list or was added at runtime */
@@ -419,7 +419,7 @@ AcpiUtGetInterface (
NextInterface = AcpiGbl_SupportedInterfaces;
while (NextInterface)
{
- if (!ACPI_STRCMP (InterfaceName, NextInterface->Name))
+ if (!strcmp (InterfaceName, NextInterface->Name))
{
return (NextInterface);
}
diff --git a/sys/contrib/dev/acpica/components/utilities/utpredef.c b/sys/contrib/dev/acpica/components/utilities/utpredef.c
index a445f85..fed8154 100644
--- a/sys/contrib/dev/acpica/components/utilities/utpredef.c
+++ b/sys/contrib/dev/acpica/components/utilities/utpredef.c
@@ -166,7 +166,7 @@ AcpiUtGetExpectedReturnTypes (
if (!ExpectedBtypes)
{
- ACPI_STRCPY (Buffer, "NONE");
+ strcpy (Buffer, "NONE");
return;
}
@@ -180,7 +180,7 @@ AcpiUtGetExpectedReturnTypes (
if (ExpectedBtypes & ThisRtype)
{
- ACPI_STRCAT (Buffer, &UtRtypeNames[i][j]);
+ strcat (Buffer, &UtRtypeNames[i][j]);
j = 0; /* Use name separator from now on */
}
diff --git a/sys/contrib/dev/acpica/components/utilities/utprint.c b/sys/contrib/dev/acpica/components/utilities/utprint.c
index 62aecf0..dee3a71 100644
--- a/sys/contrib/dev/acpica/components/utilities/utprint.c
+++ b/sys/contrib/dev/acpica/components/utilities/utprint.c
@@ -227,7 +227,7 @@ AcpiUtScanNumber (
UINT64 Number = 0;
- while (ACPI_IS_DIGIT (*String))
+ while (isdigit ((int) *String))
{
Number *= 10;
Number += *(String++) - '0';
@@ -505,7 +505,7 @@ AcpiUtVsnprintf (
/* Process width */
Width = -1;
- if (ACPI_IS_DIGIT (*Format))
+ if (isdigit ((int) *Format))
{
Format = AcpiUtScanNumber (Format, &Number);
Width = (INT32) Number;
@@ -527,7 +527,7 @@ AcpiUtVsnprintf (
if (*Format == '.')
{
++Format;
- if (ACPI_IS_DIGIT(*Format))
+ if (isdigit ((int) *Format))
{
Format = AcpiUtScanNumber (Format, &Number);
Precision = (INT32) Number;
diff --git a/sys/contrib/dev/acpica/components/utilities/utstring.c b/sys/contrib/dev/acpica/components/utilities/utstring.c
index 4cbf435..6d38a5b 100644
--- a/sys/contrib/dev/acpica/components/utilities/utstring.c
+++ b/sys/contrib/dev/acpica/components/utilities/utstring.c
@@ -89,7 +89,7 @@ AcpiUtStrlwr (
for (String = SrcString; *String; String++)
{
- *String = (char) ACPI_TOLOWER (*String);
+ *String = (char) tolower ((int) *String);
}
return;
@@ -168,7 +168,7 @@ AcpiUtStrupr (
for (String = SrcString; *String; String++)
{
- *String = (char) ACPI_TOUPPER (*String);
+ *String = (char) toupper ((int) *String);
}
return;
@@ -234,7 +234,7 @@ AcpiUtStrtoul64 (
/* Skip over any white space in the buffer */
- while ((*String) && (ACPI_IS_SPACE (*String) || *String == '\t'))
+ while ((*String) && (isspace ((int) *String) || *String == '\t'))
{
String++;
}
@@ -245,7 +245,7 @@ AcpiUtStrtoul64 (
* Base equal to ACPI_ANY_BASE means 'ToInteger operation case'.
* We need to determine if it is decimal or hexadecimal.
*/
- if ((*String == '0') && (ACPI_TOLOWER (*(String + 1)) == 'x'))
+ if ((*String == '0') && (tolower ((int) *(String + 1)) == 'x'))
{
SignOf0x = 1;
Base = 16;
@@ -261,7 +261,7 @@ AcpiUtStrtoul64 (
/* Any string left? Check that '0x' is not followed by white space. */
- if (!(*String) || ACPI_IS_SPACE (*String) || *String == '\t')
+ if (!(*String) || isspace ((int) *String) || *String == '\t')
{
if (ToIntegerOp)
{
@@ -283,7 +283,7 @@ AcpiUtStrtoul64 (
while (*String)
{
- if (ACPI_IS_DIGIT (*String))
+ if (isdigit ((int) *String))
{
/* Convert ASCII 0-9 to Decimal value */
@@ -297,8 +297,8 @@ AcpiUtStrtoul64 (
}
else
{
- ThisDigit = (UINT8) ACPI_TOUPPER (*String);
- if (ACPI_IS_XDIGIT ((char) ThisDigit))
+ ThisDigit = (UINT8) toupper ((int) *String);
+ if (isxdigit ((int) ThisDigit))
{
/* Convert ASCII Hex char to value */
@@ -469,7 +469,7 @@ AcpiUtPrintString (
/* Check for printable character or hex escape */
- if (ACPI_IS_PRINT (String[i]))
+ if (isprint ((int) String[i]))
{
/* This is a normal character */
@@ -711,12 +711,12 @@ AcpiUtSafeStrcpy (
char *Source)
{
- if (ACPI_STRLEN (Source) >= DestSize)
+ if (strlen (Source) >= DestSize)
{
return (TRUE);
}
- ACPI_STRCPY (Dest, Source);
+ strcpy (Dest, Source);
return (FALSE);
}
@@ -727,12 +727,12 @@ AcpiUtSafeStrcat (
char *Source)
{
- if ((ACPI_STRLEN (Dest) + ACPI_STRLEN (Source)) >= DestSize)
+ if ((strlen (Dest) + strlen (Source)) >= DestSize)
{
return (TRUE);
}
- ACPI_STRCAT (Dest, Source);
+ strcat (Dest, Source);
return (FALSE);
}
@@ -747,14 +747,14 @@ AcpiUtSafeStrncat (
ACPI_SIZE ActualTransferLength;
- ActualTransferLength = ACPI_MIN (MaxTransferLength, ACPI_STRLEN (Source));
+ ActualTransferLength = ACPI_MIN (MaxTransferLength, strlen (Source));
- if ((ACPI_STRLEN (Dest) + ActualTransferLength) >= DestSize)
+ if ((strlen (Dest) + ActualTransferLength) >= DestSize)
{
return (TRUE);
}
- ACPI_STRNCAT (Dest, Source, MaxTransferLength);
+ strncat (Dest, Source, MaxTransferLength);
return (FALSE);
}
#endif
diff --git a/sys/contrib/dev/acpica/components/utilities/uttrack.c b/sys/contrib/dev/acpica/components/utilities/uttrack.c
index 5f208b5..d780397 100644
--- a/sys/contrib/dev/acpica/components/utilities/uttrack.c
+++ b/sys/contrib/dev/acpica/components/utilities/uttrack.c
@@ -113,7 +113,7 @@ AcpiUtCreateList (
return (AE_NO_MEMORY);
}
- ACPI_MEMSET (Cache, 0, sizeof (ACPI_MEMORY_LIST));
+ memset (Cache, 0, sizeof (ACPI_MEMORY_LIST));
Cache->ListName = ListName;
Cache->ObjectSize = ObjectSize;
@@ -445,7 +445,7 @@ AcpiUtTrackAllocation (
Allocation->Component = Component;
Allocation->Line = Line;
- ACPI_STRNCPY (Allocation->Module, Module, ACPI_MAX_MODULE_NAME);
+ strncpy (Allocation->Module, Module, ACPI_MAX_MODULE_NAME);
Allocation->Module[ACPI_MAX_MODULE_NAME-1] = 0;
if (!Element)
@@ -556,7 +556,7 @@ AcpiUtRemoveAllocation (
/* Mark the segment as deleted */
- ACPI_MEMSET (&Allocation->UserSpace, 0xEA, Allocation->Size);
+ memset (&Allocation->UserSpace, 0xEA, Allocation->Size);
Status = AcpiUtReleaseMutex (ACPI_MTX_MEMORY);
return (Status);
@@ -667,7 +667,7 @@ AcpiUtDumpAllocations (
while (Element)
{
if ((Element->Component & Component) &&
- ((Module == NULL) || (0 == ACPI_STRCMP (Module, Element->Module))))
+ ((Module == NULL) || (0 == strcmp (Module, Element->Module))))
{
Descriptor = ACPI_CAST_PTR (ACPI_DESCRIPTOR, &Element->UserSpace);
diff --git a/sys/contrib/dev/acpica/components/utilities/utxface.c b/sys/contrib/dev/acpica/components/utilities/utxface.c
index aab7473..eb311ec 100644
--- a/sys/contrib/dev/acpica/components/utilities/utxface.c
+++ b/sys/contrib/dev/acpica/components/utilities/utxface.c
@@ -263,7 +263,7 @@ AcpiGetStatistics (
Stats->SciCount = AcpiSciCount;
Stats->GpeCount = AcpiGpeCount;
- ACPI_MEMCPY (Stats->FixedEventCount, AcpiFixedEventCount,
+ memcpy (Stats->FixedEventCount, AcpiFixedEventCount,
sizeof (AcpiFixedEventCount));
@@ -367,7 +367,7 @@ AcpiInstallInterface (
/* Parameter validation */
- if (!InterfaceName || (ACPI_STRLEN (InterfaceName) == 0))
+ if (!InterfaceName || (strlen (InterfaceName) == 0))
{
return (AE_BAD_PARAMETER);
}
@@ -432,7 +432,7 @@ AcpiRemoveInterface (
/* Parameter validation */
- if (!InterfaceName || (ACPI_STRLEN (InterfaceName) == 0))
+ if (!InterfaceName || (strlen (InterfaceName) == 0))
{
return (AE_BAD_PARAMETER);
}
diff --git a/sys/contrib/dev/acpica/components/utilities/utxfinit.c b/sys/contrib/dev/acpica/components/utilities/utxfinit.c
index 36107ca..04cd24f 100644
--- a/sys/contrib/dev/acpica/components/utilities/utxfinit.c
+++ b/sys/contrib/dev/acpica/components/utilities/utxfinit.c
@@ -194,11 +194,14 @@ AcpiEnableSubsystem (
* Obtain a permanent mapping for the FACS. This is required for the
* Global Lock and the Firmware Waking Vector
*/
- Status = AcpiTbInitializeFacs ();
- if (ACPI_FAILURE (Status))
+ if (!(Flags & ACPI_NO_FACS_INIT))
{
- ACPI_WARNING ((AE_INFO, "Could not map the FACS table"));
- return_ACPI_STATUS (Status);
+ Status = AcpiTbInitializeFacs ();
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_WARNING ((AE_INFO, "Could not map the FACS table"));
+ return_ACPI_STATUS (Status);
+ }
}
#endif /* !ACPI_REDUCED_HARDWARE */
diff --git a/sys/contrib/dev/acpica/include/acclib.h b/sys/contrib/dev/acpica/include/acclib.h
new file mode 100644
index 0000000..ed310cc
--- /dev/null
+++ b/sys/contrib/dev/acpica/include/acclib.h
@@ -0,0 +1,167 @@
+/******************************************************************************
+ *
+ * Name: acclib.h -- C library support. Prototypes for the (optional) local
+ * implementations of required C library functions.
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2015, Intel Corp.
+ * 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,
+ * without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ * substantially similar to the "NO WARRANTY" disclaimer below
+ * ("Disclaimer") and any redistribution must be conditioned upon
+ * including a substantially similar Disclaimer requirement for further
+ * binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ * of any contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR 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 DAMAGES.
+ */
+
+#ifndef _ACCLIB_H
+#define _ACCLIB_H
+
+
+/*
+ * Prototypes and macros for local implementations of C library functions
+ */
+
+/* is* functions. The AcpiGbl_Ctypes array is defined in utclib.c */
+
+extern const UINT8 AcpiGbl_Ctypes[];
+
+#define _ACPI_XA 0x00 /* extra alphabetic - not supported */
+#define _ACPI_XS 0x40 /* extra space */
+#define _ACPI_BB 0x00 /* BEL, BS, etc. - not supported */
+#define _ACPI_CN 0x20 /* CR, FF, HT, NL, VT */
+#define _ACPI_DI 0x04 /* '0'-'9' */
+#define _ACPI_LO 0x02 /* 'a'-'z' */
+#define _ACPI_PU 0x10 /* punctuation */
+#define _ACPI_SP 0x08 /* space, tab, CR, LF, VT, FF */
+#define _ACPI_UP 0x01 /* 'A'-'Z' */
+#define _ACPI_XD 0x80 /* '0'-'9', 'A'-'F', 'a'-'f' */
+
+#define isdigit(c) (AcpiGbl_Ctypes[(unsigned char)(c)] & (_ACPI_DI))
+#define isspace(c) (AcpiGbl_Ctypes[(unsigned char)(c)] & (_ACPI_SP))
+#define isxdigit(c) (AcpiGbl_Ctypes[(unsigned char)(c)] & (_ACPI_XD))
+#define isupper(c) (AcpiGbl_Ctypes[(unsigned char)(c)] & (_ACPI_UP))
+#define islower(c) (AcpiGbl_Ctypes[(unsigned char)(c)] & (_ACPI_LO))
+#define isprint(c) (AcpiGbl_Ctypes[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP | _ACPI_DI | _ACPI_XS | _ACPI_PU))
+#define isalpha(c) (AcpiGbl_Ctypes[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP))
+
+
+/* Strings */
+
+char *
+strcat (
+ char *DstString,
+ const char *SrcString);
+
+char *
+strchr (
+ const char *String,
+ int ch);
+
+char *
+strcpy (
+ char *DstString,
+ const char *SrcString);
+
+int
+strcmp (
+ const char *String1,
+ const char *String2);
+
+ACPI_SIZE
+strlen (
+ const char *String);
+
+char *
+strncat (
+ char *DstString,
+ const char *SrcString,
+ ACPI_SIZE Count);
+
+int
+strncmp (
+ const char *String1,
+ const char *String2,
+ ACPI_SIZE Count);
+
+char *
+strncpy (
+ char *DstString,
+ const char *SrcString,
+ ACPI_SIZE Count);
+
+char *
+strstr (
+ char *String1,
+ char *String2);
+
+
+/* Conversion */
+
+UINT32
+strtoul (
+ const char *String,
+ char **Terminator,
+ UINT32 Base);
+
+
+/* Memory */
+
+int
+memcmp (
+ void *Buffer1,
+ void *Buffer2,
+ ACPI_SIZE Count);
+
+void *
+memcpy (
+ void *Dest,
+ const void *Src,
+ ACPI_SIZE Count);
+
+void *
+memset (
+ void *Dest,
+ int Value,
+ ACPI_SIZE Count);
+
+
+/* upper/lower case */
+
+int
+tolower (
+ int c);
+
+int
+toupper (
+ int c);
+
+#endif /* _ACCLIB_H */
diff --git a/sys/contrib/dev/acpica/include/accommon.h b/sys/contrib/dev/acpica/include/accommon.h
index e63943b..322222a 100644
--- a/sys/contrib/dev/acpica/include/accommon.h
+++ b/sys/contrib/dev/acpica/include/accommon.h
@@ -59,6 +59,9 @@
#include <contrib/dev/acpica/include/acglobal.h> /* All global variables */
#include <contrib/dev/acpica/include/achware.h> /* Hardware defines and interfaces */
#include <contrib/dev/acpica/include/acutils.h> /* Utility interfaces */
+#ifndef ACPI_USE_SYSTEM_CLIBRARY
+#include <contrib/dev/acpica/include/acclib.h> /* C library interfaces */
+#endif /* !ACPI_USE_SYSTEM_CLIBRARY */
#endif /* __ACCOMMON_H__ */
diff --git a/sys/contrib/dev/acpica/include/acglobal.h b/sys/contrib/dev/acpica/include/acglobal.h
index ab2fc26..9e7da94 100644
--- a/sys/contrib/dev/acpica/include/acglobal.h
+++ b/sys/contrib/dev/acpica/include/acglobal.h
@@ -62,6 +62,8 @@ ACPI_GLOBAL (ACPI_TABLE_HEADER, AcpiGbl_OriginalDsdtHeader);
#if (!ACPI_REDUCED_HARDWARE)
ACPI_GLOBAL (ACPI_TABLE_FACS *, AcpiGbl_FACS);
+ACPI_GLOBAL (ACPI_TABLE_FACS *, AcpiGbl_Facs32);
+ACPI_GLOBAL (ACPI_TABLE_FACS *, AcpiGbl_Facs64);
#endif /* !ACPI_REDUCED_HARDWARE */
diff --git a/sys/contrib/dev/acpica/include/acinterp.h b/sys/contrib/dev/acpica/include/acinterp.h
index 66463d6..00eb8f0 100644
--- a/sys/contrib/dev/acpica/include/acinterp.h
+++ b/sys/contrib/dev/acpica/include/acinterp.h
@@ -638,6 +638,11 @@ AcpiExIntegerToString (
char *Dest,
UINT64 Value);
+void
+AcpiExPciClsToString (
+ char *Dest,
+ UINT8 ClassCode[3]);
+
BOOLEAN
AcpiIsValidSpaceId (
UINT8 SpaceId);
diff --git a/sys/contrib/dev/acpica/include/aclocal.h b/sys/contrib/dev/acpica/include/aclocal.h
index 4c96303..dc1afff 100644
--- a/sys/contrib/dev/acpica/include/aclocal.h
+++ b/sys/contrib/dev/acpica/include/aclocal.h
@@ -238,6 +238,7 @@ typedef struct acpi_table_list
#define ACPI_TABLE_INDEX_DSDT (0)
#define ACPI_TABLE_INDEX_FACS (1)
+#define ACPI_TABLE_INDEX_X_FACS (2)
typedef struct acpi_find_context
diff --git a/sys/contrib/dev/acpica/include/acnames.h b/sys/contrib/dev/acpica/include/acnames.h
index 6bb6bbf..6887d42 100644
--- a/sys/contrib/dev/acpica/include/acnames.h
+++ b/sys/contrib/dev/acpica/include/acnames.h
@@ -51,6 +51,7 @@
#define METHOD_NAME__BBN "_BBN"
#define METHOD_NAME__CBA "_CBA"
#define METHOD_NAME__CID "_CID"
+#define METHOD_NAME__CLS "_CLS"
#define METHOD_NAME__CRS "_CRS"
#define METHOD_NAME__DDN "_DDN"
#define METHOD_NAME__HID "_HID"
diff --git a/sys/contrib/dev/acpica/include/acnamesp.h b/sys/contrib/dev/acpica/include/acnamesp.h
index 07e76b5..786fd29 100644
--- a/sys/contrib/dev/acpica/include/acnamesp.h
+++ b/sys/contrib/dev/acpica/include/acnamesp.h
@@ -67,6 +67,7 @@
#define ACPI_NS_PREFIX_IS_SCOPE 0x10
#define ACPI_NS_EXTERNAL 0x20
#define ACPI_NS_TEMPORARY 0x40
+#define ACPI_NS_OVERRIDE_IF_FOUND 0x80
/* Flags for AcpiNsWalkNamespace */
diff --git a/sys/contrib/dev/acpica/include/acobject.h b/sys/contrib/dev/acpica/include/acobject.h
index b7b624b..481eb44 100644
--- a/sys/contrib/dev/acpica/include/acobject.h
+++ b/sys/contrib/dev/acpica/include/acobject.h
@@ -430,13 +430,14 @@ typedef struct acpi_object_addr_handler
typedef struct acpi_object_reference
{
ACPI_OBJECT_COMMON_HEADER
- UINT8 Class; /* Reference Class */
- UINT8 TargetType; /* Used for Index Op */
- UINT8 Reserved;
- void *Object; /* NameOp=>HANDLE to obj, IndexOp=>ACPI_OPERAND_OBJECT */
- ACPI_NAMESPACE_NODE *Node; /* RefOf or Namepath */
- union acpi_operand_object **Where; /* Target of Index */
- UINT32 Value; /* Used for Local/Arg/Index/DdbHandle */
+ UINT8 Class; /* Reference Class */
+ UINT8 TargetType; /* Used for Index Op */
+ UINT8 Reserved;
+ void *Object; /* NameOp=>HANDLE to obj, IndexOp=>ACPI_OPERAND_OBJECT */
+ ACPI_NAMESPACE_NODE *Node; /* RefOf or Namepath */
+ union acpi_operand_object **Where; /* Target of Index */
+ UINT8 *IndexPointer; /* Used for Buffers and Strings */
+ UINT32 Value; /* Used for Local/Arg/Index/DdbHandle */
} ACPI_OBJECT_REFERENCE;
diff --git a/sys/contrib/dev/acpica/include/acoutput.h b/sys/contrib/dev/acpica/include/acoutput.h
index ab07809..0ef98eb 100644
--- a/sys/contrib/dev/acpica/include/acoutput.h
+++ b/sys/contrib/dev/acpica/include/acoutput.h
@@ -298,8 +298,12 @@
/* DEBUG_PRINT functions */
-#define ACPI_DEBUG_PRINT(plist) ACPI_ACTUAL_DEBUG plist
-#define ACPI_DEBUG_PRINT_RAW(plist) ACPI_ACTUAL_DEBUG_RAW plist
+#ifndef COMPILER_VA_MACRO
+
+#define ACPI_DEBUG_PRINT(plist) AcpiDebugPrint plist
+#define ACPI_DEBUG_PRINT_RAW(plist) AcpiDebugPrintRaw plist
+
+#else
/* Helper macros for DEBUG_PRINT */
@@ -319,6 +323,11 @@
ACPI_DO_DEBUG_PRINT (AcpiDebugPrintRaw, Level, Line, \
Filename, Modulename, Component, __VA_ARGS__)
+#define ACPI_DEBUG_PRINT(plist) ACPI_ACTUAL_DEBUG plist
+#define ACPI_DEBUG_PRINT_RAW(plist) ACPI_ACTUAL_DEBUG_RAW plist
+
+#endif
+
/*
* Function entry tracing
diff --git a/sys/contrib/dev/acpica/include/acpixf.h b/sys/contrib/dev/acpica/include/acpixf.h
index 8d972eb..037ffef 100644
--- a/sys/contrib/dev/acpica/include/acpixf.h
+++ b/sys/contrib/dev/acpica/include/acpixf.h
@@ -46,7 +46,7 @@
/* Current ACPICA subsystem version in YYYYMMDD format */
-#define ACPI_CA_VERSION 0x20150515
+#define ACPI_CA_VERSION 0x20150619
#include <contrib/dev/acpica/include/acconfig.h>
#include <contrib/dev/acpica/include/actypes.h>
@@ -202,6 +202,15 @@ ACPI_INIT_GLOBAL (UINT8, AcpiGbl_DoNotUseXsdt, FALSE);
ACPI_INIT_GLOBAL (UINT8, AcpiGbl_Use32BitFadtAddresses, FALSE);
/*
+ * Optionally use 32-bit FACS table addresses.
+ * It is reported that some platforms fail to resume from system suspending
+ * if 64-bit FACS table address is selected:
+ * https://bugzilla.kernel.org/show_bug.cgi?id=74021
+ * Default is TRUE, favor the 32-bit addresses.
+ */
+ACPI_INIT_GLOBAL (UINT8, AcpiGbl_Use32BitFacsAddresses, TRUE);
+
+/*
* Optionally truncate I/O addresses to 16 bits. Provides compatibility
* with other ACPI implementations. NOTE: During ACPICA initialization,
* this value is set to TRUE if any Windows OSI strings have been
@@ -222,6 +231,11 @@ ACPI_INIT_GLOBAL (UINT8, AcpiGbl_DisableAutoRepair, FALSE);
ACPI_INIT_GLOBAL (UINT8, AcpiGbl_DisableSsdtTableInstall, FALSE);
/*
+ * Optionally enable runtime namespace override.
+ */
+ACPI_INIT_GLOBAL (UINT8, AcpiGbl_RuntimeNamespaceOverride, TRUE);
+
+/*
* We keep track of the latest version of Windows that has been requested by
* the BIOS. ACPI 5.0.
*/
@@ -1066,14 +1080,8 @@ AcpiLeaveSleepState (
ACPI_HW_DEPENDENT_RETURN_STATUS (
ACPI_STATUS
AcpiSetFirmwareWakingVector (
- UINT32 PhysicalAddress))
-
-#if ACPI_MACHINE_WIDTH == 64
-ACPI_HW_DEPENDENT_RETURN_STATUS (
-ACPI_STATUS
-AcpiSetFirmwareWakingVector64 (
- UINT64 PhysicalAddress))
-#endif
+ ACPI_PHYSICAL_ADDRESS PhysicalAddress,
+ ACPI_PHYSICAL_ADDRESS PhysicalAddress64))
/*
diff --git a/sys/contrib/dev/acpica/include/acstruct.h b/sys/contrib/dev/acpica/include/acstruct.h
index 547921b..3a6faa6 100644
--- a/sys/contrib/dev/acpica/include/acstruct.h
+++ b/sys/contrib/dev/acpica/include/acstruct.h
@@ -85,6 +85,7 @@ typedef struct acpi_walk_state
UINT8 ReturnUsed;
UINT8 ScopeDepth;
UINT8 PassNumber; /* Parse pass during table load */
+ BOOLEAN NamespaceOverride; /* Override existing objects */
UINT8 ResultSize; /* Total elements for the result stack */
UINT8 ResultCount; /* Current number of occupied elements of result stack */
UINT32 AmlOffset;
diff --git a/sys/contrib/dev/acpica/include/actbl.h b/sys/contrib/dev/acpica/include/actbl.h
index ceef763..f1c3496 100644
--- a/sys/contrib/dev/acpica/include/actbl.h
+++ b/sys/contrib/dev/acpica/include/actbl.h
@@ -67,6 +67,7 @@
#define ACPI_SIG_DSDT "DSDT" /* Differentiated System Description Table */
#define ACPI_SIG_FADT "FACP" /* Fixed ACPI Description Table */
#define ACPI_SIG_FACS "FACS" /* Firmware ACPI Control Structure */
+#define ACPI_SIG_OSDT "OSDT" /* Override System Description Table */
#define ACPI_SIG_PSDT "PSDT" /* Persistent System Description Table */
#define ACPI_SIG_RSDP "RSD PTR " /* Root System Description Pointer */
#define ACPI_SIG_RSDT "RSDT" /* Root System Description Table */
diff --git a/sys/contrib/dev/acpica/include/actbl1.h b/sys/contrib/dev/acpica/include/actbl1.h
index 962324a..3a11553 100644
--- a/sys/contrib/dev/acpica/include/actbl1.h
+++ b/sys/contrib/dev/acpica/include/actbl1.h
@@ -974,10 +974,22 @@ typedef struct acpi_madt_generic_distributor
UINT64 BaseAddress;
UINT32 GlobalIrqBase;
UINT8 Version;
- UINT8 Reserved2[3]; /* Reserved - must be zero */
+ UINT8 Reserved2[3]; /* Reserved - must be zero */
} ACPI_MADT_GENERIC_DISTRIBUTOR;
+/* Values for Version field above */
+
+enum AcpiMadtGicVersion
+{
+ ACPI_MADT_GIC_VERSION_NONE = 0,
+ ACPI_MADT_GIC_VERSION_V1 = 1,
+ ACPI_MADT_GIC_VERSION_V2 = 2,
+ ACPI_MADT_GIC_VERSION_V3 = 3,
+ ACPI_MADT_GIC_VERSION_V4 = 4,
+ ACPI_MADT_GIC_VERSION_RESERVED = 5 /* 5 and greater are reserved */
+};
+
/* 13: Generic MSI Frame (ACPI 5.1) */
diff --git a/sys/contrib/dev/acpica/include/actbl2.h b/sys/contrib/dev/acpica/include/actbl2.h
index 654495f..6ee36a6 100644
--- a/sys/contrib/dev/acpica/include/actbl2.h
+++ b/sys/contrib/dev/acpica/include/actbl2.h
@@ -52,8 +52,8 @@
* These tables are not consumed directly by the ACPICA subsystem, but are
* included here to support device drivers and the AML disassembler.
*
- * The tables in this file are defined by third-party specifications, and are
- * not defined directly by the ACPI specification itself.
+ * Generally, the tables in this file are defined by third-party specifications,
+ * and are not defined directly by the ACPI specification itself.
*
******************************************************************************/
@@ -82,6 +82,7 @@
#define ACPI_SIG_SPCR "SPCR" /* Serial Port Console Redirection table */
#define ACPI_SIG_SPMI "SPMI" /* Server Platform Management Interface table */
#define ACPI_SIG_TCPA "TCPA" /* Trusted Computing Platform Alliance table */
+#define ACPI_SIG_TPM2 "TPM2" /* Trusted Platform Module 2.0 H/W interface table */
#define ACPI_SIG_UEFI "UEFI" /* Uefi Boot Optimization Table */
#define ACPI_SIG_VRTC "VRTC" /* Virtual Real Time Clock Table */
#define ACPI_SIG_WAET "WAET" /* Windows ACPI Emulated devices Table */
@@ -1369,21 +1370,91 @@ enum AcpiSpmiInterfaceTypes
/*******************************************************************************
*
* TCPA - Trusted Computing Platform Alliance table
- * Version 1
+ * Version 2
+ *
+ * Conforms to "TCG ACPI Specification, Family 1.2 and 2.0",
+ * December 19, 2014
*
- * Conforms to "TCG PC Specific Implementation Specification",
- * Version 1.1, August 18, 2003
+ * NOTE: There are two versions of the table with the same signature --
+ * the client version and the server version.
*
******************************************************************************/
-typedef struct acpi_table_tcpa
+typedef struct acpi_table_tcpa_client
+{
+ ACPI_TABLE_HEADER Header; /* Common ACPI table header */
+ UINT16 PlatformClass;
+ UINT32 MinimumLogLength; /* Minimum length for the event log area */
+ UINT64 LogAddress; /* Address of the event log area */
+
+} ACPI_TABLE_TCPA_CLIENT;
+
+typedef struct acpi_table_tcpa_server
{
ACPI_TABLE_HEADER Header; /* Common ACPI table header */
+ UINT16 PlatformClass;
UINT16 Reserved;
- UINT32 MaxLogLength; /* Maximum length for the event log area */
+ UINT64 MinimumLogLength; /* Minimum length for the event log area */
UINT64 LogAddress; /* Address of the event log area */
+ UINT16 SpecRevision;
+ UINT8 DeviceFlags;
+ UINT8 InterruptFlags;
+ UINT8 GpeNumber;
+ UINT8 Reserved2[3];
+ UINT32 GlobalInterrupt;
+ ACPI_GENERIC_ADDRESS Address;
+ UINT32 Reserved3;
+ ACPI_GENERIC_ADDRESS ConfigAddress;
+ UINT8 Group;
+ UINT8 Bus; /* PCI Bus/Segment/Function numbers */
+ UINT8 Device;
+ UINT8 Function;
+
+} ACPI_TABLE_TCPA_SERVER;
+
+/* Values for DeviceFlags above */
+
+#define ACPI_TCPA_PCI_DEVICE (1)
+#define ACPI_TCPA_BUS_PNP (1<<1)
+#define ACPI_TCPA_ADDRESS_VALID (1<<2)
+
+/* Values for InterruptFlags above */
+
+#define ACPI_TCPA_INTERRUPT_MODE (1)
+#define ACPI_TCPA_INTERRUPT_POLARITY (1<<1)
+#define ACPI_TCPA_SCI_VIA_GPE (1<<2)
+#define ACPI_TCPA_GLOBAL_INTERRUPT (1<<3)
+
+
+/*******************************************************************************
+ *
+ * TPM2 - Trusted Platform Module (TPM) 2.0 Hardware Interface Table
+ * Version 4
+ *
+ * Conforms to "TCG ACPI Specification, Family 1.2 and 2.0",
+ * December 19, 2014
+ *
+ ******************************************************************************/
+
+typedef struct acpi_table_tpm2
+{
+ ACPI_TABLE_HEADER Header; /* Common ACPI table header */
+ UINT16 PlatformClass;
+ UINT16 Reserved;
+ UINT64 ControlAddress;
+ UINT32 StartMethod;
+
+ /* Platform-specific data follows */
+
+} ACPI_TABLE_TPM2;
+
+/* Values for StartMethod above */
-} ACPI_TABLE_TCPA;
+#define ACPI_TPM2_NOT_ALLOWED 0
+#define ACPI_TPM2_START_METHOD 2
+#define ACPI_TPM2_MEMORY_MAPPED 6
+#define ACPI_TPM2_COMMAND_BUFFER 7
+#define ACPI_TPM2_COMMAND_BUFFER_WITH_START_METHOD 8
/*******************************************************************************
diff --git a/sys/contrib/dev/acpica/include/actbl3.h b/sys/contrib/dev/acpica/include/actbl3.h
index f575d08..7da6bc6 100644
--- a/sys/contrib/dev/acpica/include/actbl3.h
+++ b/sys/contrib/dev/acpica/include/actbl3.h
@@ -52,7 +52,8 @@
* These tables are not consumed directly by the ACPICA subsystem, but are
* included here to support device drivers and the AML disassembler.
*
- * The tables in this file are fully defined within the ACPI specification.
+ * In general, the tables in this file are fully defined within the ACPI
+ * specification.
*
******************************************************************************/
@@ -71,7 +72,6 @@
#define ACPI_SIG_PMTT "PMTT" /* Platform Memory Topology Table */
#define ACPI_SIG_RASF "RASF" /* RAS Feature table */
#define ACPI_SIG_STAO "STAO" /* Status Override table */
-#define ACPI_SIG_TPM2 "TPM2" /* Trusted Platform Module 2.0 H/W interface table */
#define ACPI_SIG_WPBT "WPBT" /* Windows Platform Binary Table */
#define ACPI_SIG_XENV "XENV" /* Xen Environment table */
@@ -848,41 +848,6 @@ typedef struct acpi_table_stao
/*******************************************************************************
*
- * TPM2 - Trusted Platform Module (TPM) 2.0 Hardware Interface Table
- * Version 3
- *
- * Conforms to "TPM 2.0 Hardware Interface Table (TPM2)" 29 November 2011
- *
- ******************************************************************************/
-
-typedef struct acpi_table_tpm2
-{
- ACPI_TABLE_HEADER Header; /* Common ACPI table header */
- UINT32 Flags;
- UINT64 ControlAddress;
- UINT32 StartMethod;
-
-} ACPI_TABLE_TPM2;
-
-/* Control area structure (not part of table, pointed to by ControlAddress) */
-
-typedef struct acpi_tpm2_control
-{
- UINT32 Reserved;
- UINT32 Error;
- UINT32 Cancel;
- UINT32 Start;
- UINT64 InterruptControl;
- UINT32 CommandSize;
- UINT64 CommandAddress;
- UINT32 ResponseSize;
- UINT64 ResponseAddress;
-
-} ACPI_TPM2_CONTROL;
-
-
-/*******************************************************************************
- *
* WPBT - Windows Platform Environment Table (ACPI 6.0)
* Version 1
*
diff --git a/sys/contrib/dev/acpica/include/actypes.h b/sys/contrib/dev/acpica/include/actypes.h
index 0bee2a7..837c784 100644
--- a/sys/contrib/dev/acpica/include/actypes.h
+++ b/sys/contrib/dev/acpica/include/actypes.h
@@ -555,14 +555,14 @@ typedef UINT64 ACPI_INTEGER;
#define ACPI_COMPARE_NAME(a,b) (*ACPI_CAST_PTR (UINT32, (a)) == *ACPI_CAST_PTR (UINT32, (b)))
#define ACPI_MOVE_NAME(dest,src) (*ACPI_CAST_PTR (UINT32, (dest)) = *ACPI_CAST_PTR (UINT32, (src)))
#else
-#define ACPI_COMPARE_NAME(a,b) (!ACPI_STRNCMP (ACPI_CAST_PTR (char, (a)), ACPI_CAST_PTR (char, (b)), ACPI_NAME_SIZE))
-#define ACPI_MOVE_NAME(dest,src) (ACPI_STRNCPY (ACPI_CAST_PTR (char, (dest)), ACPI_CAST_PTR (char, (src)), ACPI_NAME_SIZE))
+#define ACPI_COMPARE_NAME(a,b) (!strncmp (ACPI_CAST_PTR (char, (a)), ACPI_CAST_PTR (char, (b)), ACPI_NAME_SIZE))
+#define ACPI_MOVE_NAME(dest,src) (strncpy (ACPI_CAST_PTR (char, (dest)), ACPI_CAST_PTR (char, (src)), ACPI_NAME_SIZE))
#endif
/* Support for the special RSDP signature (8 characters) */
-#define ACPI_VALIDATE_RSDP_SIG(a) (!ACPI_STRNCMP (ACPI_CAST_PTR (char, (a)), ACPI_SIG_RSDP, 8))
-#define ACPI_MAKE_RSDP_SIG(dest) (ACPI_MEMCPY (ACPI_CAST_PTR (char, (dest)), ACPI_SIG_RSDP, 8))
+#define ACPI_VALIDATE_RSDP_SIG(a) (!strncmp (ACPI_CAST_PTR (char, (a)), ACPI_SIG_RSDP, 8))
+#define ACPI_MAKE_RSDP_SIG(dest) (memcpy (ACPI_CAST_PTR (char, (dest)), ACPI_SIG_RSDP, 8))
/*******************************************************************************
@@ -582,6 +582,7 @@ typedef UINT64 ACPI_INTEGER;
#define ACPI_NO_ACPI_ENABLE 0x10
#define ACPI_NO_DEVICE_INIT 0x20
#define ACPI_NO_OBJECT_INIT 0x40
+#define ACPI_NO_FACS_INIT 0x80
/*
* Initialization state
@@ -767,10 +768,6 @@ typedef UINT32 ACPI_EVENT_STATUS;
#define ACPI_GPE_ENABLE 0
#define ACPI_GPE_DISABLE 1
#define ACPI_GPE_CONDITIONAL_ENABLE 2
-#define ACPI_GPE_SAVE_MASK 4
-
-#define ACPI_GPE_ENABLE_SAVE (ACPI_GPE_ENABLE | ACPI_GPE_SAVE_MASK)
-#define ACPI_GPE_DISABLE_SAVE (ACPI_GPE_DISABLE | ACPI_GPE_SAVE_MASK)
/*
* GPE info flags - Per GPE
@@ -1227,6 +1224,10 @@ UINT32 (*ACPI_INTERFACE_HANDLER) (
#define ACPI_UUID_LENGTH 16
+/* Length of 3-byte PCI class code values when converted back to a string */
+
+#define ACPI_PCICLS_STRING_SIZE 7 /* Includes null terminator */
+
/* Structures used for device/processor HID, UID, CID, and SUB */
@@ -1255,7 +1256,7 @@ typedef struct acpi_device_info
UINT32 Name; /* ACPI object Name */
ACPI_OBJECT_TYPE Type; /* ACPI object Type */
UINT8 ParamCount; /* If a method, required parameter count */
- UINT8 Valid; /* Indicates which optional fields are valid */
+ UINT16 Valid; /* Indicates which optional fields are valid */
UINT8 Flags; /* Miscellaneous info */
UINT8 HighestDstates[4]; /* _SxD values: 0xFF indicates not valid */
UINT8 LowestDstates[5]; /* _SxW values: 0xFF indicates not valid */
@@ -1264,6 +1265,7 @@ typedef struct acpi_device_info
ACPI_PNP_DEVICE_ID HardwareId; /* _HID value */
ACPI_PNP_DEVICE_ID UniqueId; /* _UID value */
ACPI_PNP_DEVICE_ID SubsystemId; /* _SUB value */
+ ACPI_PNP_DEVICE_ID ClassCode; /* _CLS value */
ACPI_PNP_DEVICE_ID_LIST CompatibleIdList; /* _CID list <must be last> */
} ACPI_DEVICE_INFO;
@@ -1274,14 +1276,15 @@ typedef struct acpi_device_info
/* Flags for Valid field above (AcpiGetObjectInfo) */
-#define ACPI_VALID_STA 0x01
-#define ACPI_VALID_ADR 0x02
-#define ACPI_VALID_HID 0x04
-#define ACPI_VALID_UID 0x08
-#define ACPI_VALID_SUB 0x10
-#define ACPI_VALID_CID 0x20
-#define ACPI_VALID_SXDS 0x40
-#define ACPI_VALID_SXWS 0x80
+#define ACPI_VALID_STA 0x0001
+#define ACPI_VALID_ADR 0x0002
+#define ACPI_VALID_HID 0x0004
+#define ACPI_VALID_UID 0x0008
+#define ACPI_VALID_SUB 0x0010
+#define ACPI_VALID_CID 0x0020
+#define ACPI_VALID_CLS 0x0040
+#define ACPI_VALID_SXDS 0x0100
+#define ACPI_VALID_SXWS 0x0200
/* Flags for _STA return value (CurrentStatus above) */
diff --git a/sys/contrib/dev/acpica/include/acutils.h b/sys/contrib/dev/acpica/include/acutils.h
index fe6c057..b7c2a64 100644
--- a/sys/contrib/dev/acpica/include/acutils.h
+++ b/sys/contrib/dev/acpica/include/acutils.h
@@ -246,116 +246,8 @@ AcpiUtSubsystemShutdown (
void);
-/*
- * utclib - Local implementations of C library functions
- */
-#ifndef ACPI_USE_SYSTEM_CLIBRARY
-
-ACPI_SIZE
-AcpiUtStrlen (
- const char *String);
-
-char *
-AcpiUtStrchr (
- const char *String,
- int ch);
-
-char *
-AcpiUtStrcpy (
- char *DstString,
- const char *SrcString);
-
-char *
-AcpiUtStrncpy (
- char *DstString,
- const char *SrcString,
- ACPI_SIZE Count);
-
-int
-AcpiUtMemcmp (
- const char *Buffer1,
- const char *Buffer2,
- ACPI_SIZE Count);
-
-int
-AcpiUtStrncmp (
- const char *String1,
- const char *String2,
- ACPI_SIZE Count);
-
-int
-AcpiUtStrcmp (
- const char *String1,
- const char *String2);
-
-char *
-AcpiUtStrcat (
- char *DstString,
- const char *SrcString);
-
-char *
-AcpiUtStrncat (
- char *DstString,
- const char *SrcString,
- ACPI_SIZE Count);
-
-UINT32
-AcpiUtStrtoul (
- const char *String,
- char **Terminator,
- UINT32 Base);
-
-char *
-AcpiUtStrstr (
- char *String1,
- char *String2);
-
-void *
-AcpiUtMemcpy (
- void *Dest,
- const void *Src,
- ACPI_SIZE Count);
-
-void *
-AcpiUtMemset (
- void *Dest,
- UINT8 Value,
- ACPI_SIZE Count);
-
-int
-AcpiUtToUpper (
- int c);
-
-int
-AcpiUtToLower (
- int c);
-
-extern const UINT8 _acpi_ctype[];
-
-#define _ACPI_XA 0x00 /* extra alphabetic - not supported */
-#define _ACPI_XS 0x40 /* extra space */
-#define _ACPI_BB 0x00 /* BEL, BS, etc. - not supported */
-#define _ACPI_CN 0x20 /* CR, FF, HT, NL, VT */
-#define _ACPI_DI 0x04 /* '0'-'9' */
-#define _ACPI_LO 0x02 /* 'a'-'z' */
-#define _ACPI_PU 0x10 /* punctuation */
-#define _ACPI_SP 0x08 /* space, tab, CR, LF, VT, FF */
-#define _ACPI_UP 0x01 /* 'A'-'Z' */
-#define _ACPI_XD 0x80 /* '0'-'9', 'A'-'F', 'a'-'f' */
-
-#define ACPI_IS_DIGIT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_DI))
-#define ACPI_IS_SPACE(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_SP))
-#define ACPI_IS_XDIGIT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_XD))
-#define ACPI_IS_UPPER(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_UP))
-#define ACPI_IS_LOWER(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO))
-#define ACPI_IS_PRINT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP | _ACPI_DI | _ACPI_XS | _ACPI_PU))
-#define ACPI_IS_ALPHA(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP))
-
-#endif /* !ACPI_USE_SYSTEM_CLIBRARY */
-
#define ACPI_IS_ASCII(c) ((c) < 0x80)
-
/*
* utcopy - Object construction and conversion interfaces
*/
@@ -602,6 +494,11 @@ AcpiUtExecute_CID (
ACPI_NAMESPACE_NODE *DeviceNode,
ACPI_PNP_DEVICE_ID_LIST **ReturnCidList);
+ACPI_STATUS
+AcpiUtExecute_CLS (
+ ACPI_NAMESPACE_NODE *DeviceNode,
+ ACPI_PNP_DEVICE_ID **ReturnId);
+
/*
* utlock - reader/writer locks
diff --git a/sys/contrib/dev/acpica/include/platform/acenv.h b/sys/contrib/dev/acpica/include/platform/acenv.h
index 88b1ffc..90ace88 100644
--- a/sys/contrib/dev/acpica/include/platform/acenv.h
+++ b/sys/contrib/dev/acpica/include/platform/acenv.h
@@ -349,28 +349,6 @@
/* We will be linking to the standard Clib functions */
-#define ACPI_STRSTR(s1,s2) strstr((s1), (s2))
-#define ACPI_STRCHR(s1,c) strchr((s1), (c))
-#define ACPI_STRLEN(s) (ACPI_SIZE) strlen((s))
-#define ACPI_STRCPY(d,s) (void) strcpy((d), (s))
-#define ACPI_STRNCPY(d,s,n) (void) strncpy((d), (s), (ACPI_SIZE)(n))
-#define ACPI_STRNCMP(d,s,n) strncmp((d), (s), (ACPI_SIZE)(n))
-#define ACPI_STRCMP(d,s) strcmp((d), (s))
-#define ACPI_STRCAT(d,s) (void) strcat((d), (s))
-#define ACPI_STRNCAT(d,s,n) strncat((d), (s), (ACPI_SIZE)(n))
-#define ACPI_STRTOUL(d,s,n) strtoul((d), (s), (ACPI_SIZE)(n))
-#define ACPI_MEMCMP(s1,s2,n) memcmp((const char *)(s1), (const char *)(s2), (ACPI_SIZE)(n))
-#define ACPI_MEMCPY(d,s,n) (void) memcpy((d), (s), (ACPI_SIZE)(n))
-#define ACPI_MEMSET(d,s,n) (void) memset((d), (s), (ACPI_SIZE)(n))
-#define ACPI_TOUPPER(i) toupper((int) (i))
-#define ACPI_TOLOWER(i) tolower((int) (i))
-#define ACPI_IS_XDIGIT(i) isxdigit((int) (i))
-#define ACPI_IS_DIGIT(i) isdigit((int) (i))
-#define ACPI_IS_SPACE(i) isspace((int) (i))
-#define ACPI_IS_UPPER(i) isupper((int) (i))
-#define ACPI_IS_PRINT(i) isprint((int) (i))
-#define ACPI_IS_ALPHA(i) isalpha((int) (i))
-
#else
/******************************************************************************
@@ -408,22 +386,6 @@ typedef char *va_list;
/* Use the local (ACPICA) definitions of the clib functions */
-#define ACPI_STRSTR(s1,s2) AcpiUtStrstr ((s1), (s2))
-#define ACPI_STRCHR(s1,c) AcpiUtStrchr ((s1), (c))
-#define ACPI_STRLEN(s) (ACPI_SIZE) AcpiUtStrlen ((s))
-#define ACPI_STRCPY(d,s) (void) AcpiUtStrcpy ((d), (s))
-#define ACPI_STRNCPY(d,s,n) (void) AcpiUtStrncpy ((d), (s), (ACPI_SIZE)(n))
-#define ACPI_STRNCMP(d,s,n) AcpiUtStrncmp ((d), (s), (ACPI_SIZE)(n))
-#define ACPI_STRCMP(d,s) AcpiUtStrcmp ((d), (s))
-#define ACPI_STRCAT(d,s) (void) AcpiUtStrcat ((d), (s))
-#define ACPI_STRNCAT(d,s,n) AcpiUtStrncat ((d), (s), (ACPI_SIZE)(n))
-#define ACPI_STRTOUL(d,s,n) AcpiUtStrtoul ((d), (s), (ACPI_SIZE)(n))
-#define ACPI_MEMCMP(s1,s2,n) AcpiUtMemcmp((const char *)(s1), (const char *)(s2), (ACPI_SIZE)(n))
-#define ACPI_MEMCPY(d,s,n) (void) AcpiUtMemcpy ((d), (s), (ACPI_SIZE)(n))
-#define ACPI_MEMSET(d,v,n) (void) AcpiUtMemset ((d), (v), (ACPI_SIZE)(n))
-#define ACPI_TOUPPER(c) AcpiUtToUpper ((int) (c))
-#define ACPI_TOLOWER(c) AcpiUtToLower ((int) (c))
-
#endif /* ACPI_USE_SYSTEM_CLIBRARY */
#ifndef ACPI_FILE
diff --git a/sys/contrib/dev/acpica/include/platform/acenvex.h b/sys/contrib/dev/acpica/include/platform/acenvex.h
index 6e1130e..c799fd8 100644
--- a/sys/contrib/dev/acpica/include/platform/acenvex.h
+++ b/sys/contrib/dev/acpica/include/platform/acenvex.h
@@ -56,6 +56,12 @@
#if defined(_LINUX) || defined(__linux__)
#include "aclinuxex.h"
+#elif defined(_AED_EFI)
+#include "acefiex.h"
+
+#elif defined(_GNU_EFI)
+#include "acefiex.h"
+
#elif defined(__DragonFly__)
#include "acdragonflyex.h"
diff --git a/sys/contrib/dev/acpica/include/platform/acgcc.h b/sys/contrib/dev/acpica/include/platform/acgcc.h
index 2a27445..472b6d7 100644
--- a/sys/contrib/dev/acpica/include/platform/acgcc.h
+++ b/sys/contrib/dev/acpica/include/platform/acgcc.h
@@ -75,4 +75,8 @@
#undef strchr
#endif
+/* GCC supports __VA_ARGS__ in macros */
+
+#define COMPILER_VA_MACRO 1
+
#endif /* __ACGCC_H__ */
diff --git a/sys/ddb/db_sym.c b/sys/ddb/db_sym.c
index 8386c64..61c1d5f 100644
--- a/sys/ddb/db_sym.c
+++ b/sys/ddb/db_sym.c
@@ -160,7 +160,7 @@ db_var_curvnet(struct db_variable *vp, db_expr_t *valuep, int op)
return (0);
default:
- db_printf("db_var_curcpu: unknown operation\n");
+ db_printf("db_var_curvnet: unknown operation\n");
return (0);
}
}
diff --git a/sys/dev/atkbdc/psm.c b/sys/dev/atkbdc/psm.c
index a82a767..b034ef7 100644
--- a/sys/dev/atkbdc/psm.c
+++ b/sys/dev/atkbdc/psm.c
@@ -4839,9 +4839,7 @@ enable_synaptics(struct psm_softc *sc, enum probearg arg)
synaptics_set_mode(sc, synaptics_preferred_mode(sc));
if (trackpoint_support && synhw.capPassthrough) {
- synaptics_passthrough_on(sc);
enable_trackpoint(sc, arg);
- synaptics_passthrough_off(sc);
}
VLOG(3, (LOG_DEBUG, "synaptics: END init (%d buttons)\n", buttons));
@@ -5096,16 +5094,29 @@ enable_trackpoint(struct psm_softc *sc, enum probearg arg)
KBDC kbdc = sc->kbdc;
int id;
+ /*
+ * If called from enable_synaptics(), make sure that passthrough
+ * mode is enabled so we can reach the trackpoint.
+ * However, passthrough mode must be disabled before setting the
+ * trackpoint parameters, as rackpoint_command() enables and disables
+ * passthrough mode on its own.
+ */
+ if (sc->synhw.capPassthrough)
+ synaptics_passthrough_on(sc);
+
if (send_aux_command(kbdc, 0xe1) != PSM_ACK ||
read_aux_data(kbdc) != 0x01)
- return (FALSE);
+ goto no_trackpoint;
id = read_aux_data(kbdc);
if (id < 0x01)
- return (FALSE);
+ goto no_trackpoint;
if (arg == PROBE)
sc->tphw = id;
if (!trackpoint_support)
- return (FALSE);
+ goto no_trackpoint;
+
+ if (sc->synhw.capPassthrough)
+ synaptics_passthrough_off(sc);
if (arg == PROBE) {
trackpoint_sysctl_create_tree(sc);
@@ -5122,6 +5133,12 @@ enable_trackpoint(struct psm_softc *sc, enum probearg arg)
set_trackpoint_parameters(sc);
return (TRUE);
+
+no_trackpoint:
+ if (sc->synhw.capPassthrough)
+ synaptics_passthrough_off(sc);
+
+ return (FALSE);
}
/* Interlink electronics VersaPad */
diff --git a/sys/dev/bxe/bxe.c b/sys/dev/bxe/bxe.c
index f274016..2a2a81c 100644
--- a/sys/dev/bxe/bxe.c
+++ b/sys/dev/bxe/bxe.c
@@ -12525,6 +12525,7 @@ bxe_init_mcast_macs_list(struct bxe_softc *sc,
BLOGE(sc, "Failed to allocate temp mcast list\n");
return (-1);
}
+ bzero(mta, (sizeof(unsigned char) * ETHER_ADDR_LEN * mc_count));
mc_mac = malloc(sizeof(*mc_mac) * mc_count, M_DEVBUF,
(M_NOWAIT | M_ZERO));
@@ -12533,12 +12534,13 @@ bxe_init_mcast_macs_list(struct bxe_softc *sc,
BLOGE(sc, "Failed to allocate temp mcast list\n");
return (-1);
}
+ bzero(mc_mac, (sizeof(*mc_mac) * mc_count));
if_multiaddr_array(ifp, mta, &mcnt, mc_count); /* mta and mcnt not expected
to be different */
for(i=0; i< mcnt; i++) {
- bcopy((mta + (i * ETHER_ADDR_LEN)), mc_mac->mac, ETHER_ADDR_LEN);
+ mc_mac->mac = (uint8_t *)(mta + (i * ETHER_ADDR_LEN));
ECORE_LIST_PUSH_TAIL(&mc_mac->link, &p->mcast_list);
BLOGD(sc, DBG_LOAD,
@@ -12583,6 +12585,7 @@ bxe_set_mc_list(struct bxe_softc *sc)
rc = ecore_config_mcast(sc, &rparam, ECORE_MCAST_CMD_DEL);
if (rc < 0) {
BLOGE(sc, "Failed to clear multicast configuration: %d\n", rc);
+ BXE_MCAST_UNLOCK(sc);
return (rc);
}
diff --git a/sys/dev/bxe/ecore_sp.c b/sys/dev/bxe/ecore_sp.c
index b716085..2685453 100644
--- a/sys/dev/bxe/ecore_sp.c
+++ b/sys/dev/bxe/ecore_sp.c
@@ -474,7 +474,7 @@ static void __ecore_vlan_mac_h_exec_pending(struct bxe_softc *sc,
o->head_exe_request = FALSE;
o->saved_ramrod_flags = 0;
rc = ecore_exe_queue_step(sc, &o->exe_queue, &ramrod_flags);
- if (rc != ECORE_SUCCESS) {
+ if ((rc != ECORE_SUCCESS) && (rc != ECORE_PENDING)) {
ECORE_ERR("execution of pending commands failed with rc %d\n",
rc);
#ifdef ECORE_STOP_ON_ERROR
diff --git a/sys/dev/filemon/filemon.h b/sys/dev/filemon/filemon.h
index 95d2ef3..b3fa061 100644
--- a/sys/dev/filemon/filemon.h
+++ b/sys/dev/filemon/filemon.h
@@ -30,5 +30,5 @@
#define FILEMON_SET_FD _IOWR('S', 1, int)
#define FILEMON_SET_PID _IOWR('S', 2, pid_t)
-#define FILEMON_VERSION 4 /* output format
+#define FILEMON_VERSION 5 /* output format
(bump when adding record types) */
diff --git a/sys/dev/filemon/filemon_wrapper.c b/sys/dev/filemon/filemon_wrapper.c
index f92dbe9..4a1259a 100644
--- a/sys/dev/filemon/filemon_wrapper.c
+++ b/sys/dev/filemon/filemon_wrapper.c
@@ -28,6 +28,8 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+#include <sys/sx.h>
+
#include "opt_compat.h"
#if __FreeBSD_version > 800032
@@ -84,13 +86,17 @@ filemon_pid_check(struct proc *p)
{
struct filemon *filemon;
- while (p->p_pptr) {
+ sx_slock(&proctree_lock);
+ while (p != initproc) {
TAILQ_FOREACH(filemon, &filemons_inuse, link) {
- if (p->p_pid == filemon->pid)
+ if (p->p_pid == filemon->pid) {
+ sx_sunlock(&proctree_lock);
return (filemon);
+ }
}
- p = p->p_pptr;
+ p = proc_realparent(p);
}
+ sx_sunlock(&proctree_lock);
return (NULL);
}
diff --git a/sys/dev/isp/isp_freebsd.c b/sys/dev/isp/isp_freebsd.c
index 881f58a..46edd3e 100644
--- a/sys/dev/isp/isp_freebsd.c
+++ b/sys/dev/isp/isp_freebsd.c
@@ -2931,6 +2931,14 @@ isp_handle_platform_ctio(ispsoftc_t *isp, void *arg)
atp = isp_find_atpd(isp, tptr, ((ct_entry_t *)arg)->ct_fwhandle);
}
if (atp == NULL) {
+ /*
+ * In case of target mode disable at least ISP2532 return
+ * invalid zero ct_rxid value. Try to workaround that using
+ * tag_id from the CCB, pointed by valid ct_syshandle.
+ */
+ atp = isp_find_atpd(isp, tptr, ccb->csio.tag_id);
+ }
+ if (atp == NULL) {
rls_lun_statep(isp, tptr);
isp_prt(isp, ISP_LOGERR, "%s: cannot find adjunct for %x after I/O", __func__, ccb->csio.tag_id);
return;
diff --git a/sys/dev/iwn/if_iwn.c b/sys/dev/iwn/if_iwn.c
index a04d446..f3cf2ae 100644
--- a/sys/dev/iwn/if_iwn.c
+++ b/sys/dev/iwn/if_iwn.c
@@ -232,6 +232,7 @@ static int iwn_tx_data(struct iwn_softc *, struct mbuf *,
static int iwn_tx_data_raw(struct iwn_softc *, struct mbuf *,
struct ieee80211_node *,
const struct ieee80211_bpf_params *params);
+static void iwn_xmit_task(void *arg0, int pending);
static int iwn_raw_xmit(struct ieee80211_node *, struct mbuf *,
const struct ieee80211_bpf_params *);
static void iwn_start(struct ifnet *);
@@ -682,6 +683,9 @@ iwn_attach(device_t dev)
TASK_INIT(&sc->sc_radioon_task, 0, iwn_radio_on, sc);
TASK_INIT(&sc->sc_radiooff_task, 0, iwn_radio_off, sc);
TASK_INIT(&sc->sc_panic_task, 0, iwn_panicked, sc);
+ TASK_INIT(&sc->sc_xmit_task, 0, iwn_xmit_task, sc);
+
+ mbufq_init(&sc->sc_xmit_queue, 1024);
sc->sc_tq = taskqueue_create("iwn_taskq", M_WAITOK,
taskqueue_thread_enqueue, &sc->sc_tq);
@@ -1360,6 +1364,28 @@ iwn_vap_delete(struct ieee80211vap *vap)
free(ivp, M_80211_VAP);
}
+static void
+iwn_xmit_queue_drain(struct iwn_softc *sc)
+{
+ struct mbuf *m;
+ struct ieee80211_node *ni;
+
+ IWN_LOCK_ASSERT(sc);
+ while ((m = mbufq_dequeue(&sc->sc_xmit_queue)) != NULL) {
+ ni = (struct ieee80211_node *)m->m_pkthdr.rcvif;
+ ieee80211_free_node(ni);
+ m_freem(m);
+ }
+}
+
+static int
+iwn_xmit_queue_enqueue(struct iwn_softc *sc, struct mbuf *m)
+{
+
+ IWN_LOCK_ASSERT(sc);
+ return (mbufq_enqueue(&sc->sc_xmit_queue, m));
+}
+
static int
iwn_detach(device_t dev)
{
@@ -1373,6 +1399,11 @@ iwn_detach(device_t dev)
if (ifp != NULL) {
ic = ifp->if_l2com;
+ /* Free the mbuf queue and node references */
+ IWN_LOCK(sc);
+ iwn_xmit_queue_drain(sc);
+ IWN_UNLOCK(sc);
+
ieee80211_draintask(ic, &sc->sc_reinit_task);
ieee80211_draintask(ic, &sc->sc_radioon_task);
ieee80211_draintask(ic, &sc->sc_radiooff_task);
@@ -2831,6 +2862,9 @@ iwn_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg)
sc->rxon->filter &= ~htole32(IWN_FILTER_BSS);
sc->calib.state = IWN_CALIB_STATE_INIT;
+ /* Wait until we hear a beacon before we transmit */
+ sc->sc_beacon_wait = 1;
+
if ((error = iwn_auth(sc, vap)) != 0) {
device_printf(sc->sc_dev,
"%s: could not move to auth state\n", __func__);
@@ -2846,6 +2880,9 @@ iwn_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg)
break;
}
+ /* Wait until we hear a beacon before we transmit */
+ sc->sc_beacon_wait = 1;
+
/*
* !RUN -> RUN requires setting the association id
* which is done with a firmware cmd. We also defer
@@ -2859,6 +2896,12 @@ iwn_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg)
case IEEE80211_S_INIT:
sc->calib.state = IWN_CALIB_STATE_INIT;
+ /*
+ * Purge the xmit queue so we don't have old frames
+ * during a new association attempt.
+ */
+ sc->sc_beacon_wait = 0;
+ iwn_xmit_queue_drain(sc);
break;
default:
@@ -3066,6 +3109,32 @@ iwn_rx_done(struct iwn_softc *sc, struct iwn_rx_desc *desc,
}
}
+ /*
+ * If it's a beacon and we're waiting, then do the
+ * wakeup. This should unblock raw_xmit/start.
+ */
+ if (sc->sc_beacon_wait) {
+ uint8_t type, subtype;
+ /* NB: Re-assign wh */
+ wh = mtod(m, struct ieee80211_frame *);
+ type = wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK;
+ subtype = wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK;
+ /*
+ * This assumes at this point we've received our own
+ * beacon.
+ */
+ DPRINTF(sc, IWN_DEBUG_TRACE,
+ "%s: beacon_wait, type=%d, subtype=%d\n",
+ __func__, type, subtype);
+ if (type == IEEE80211_FC0_TYPE_MGT &&
+ subtype == IEEE80211_FC0_SUBTYPE_BEACON) {
+ DPRINTF(sc, IWN_DEBUG_TRACE | IWN_DEBUG_XMIT,
+ "%s: waking things up\n", __func__);
+ /* queue taskqueue to transmit! */
+ taskqueue_enqueue(sc->sc_tq, &sc->sc_xmit_task);
+ }
+ }
+
IWN_UNLOCK(sc);
/* Send the frame to the 802.11 layer. */
@@ -4802,6 +4871,51 @@ iwn_tx_data_raw(struct iwn_softc *sc, struct mbuf *m,
return 0;
}
+static void
+iwn_xmit_task(void *arg0, int pending)
+{
+ struct iwn_softc *sc = arg0;
+ struct ifnet *ifp = sc->sc_ifp;
+ struct ieee80211_node *ni;
+ struct mbuf *m;
+ int error;
+ struct ieee80211_bpf_params p;
+ int have_p;
+
+ DPRINTF(sc, IWN_DEBUG_XMIT, "%s: called\n", __func__);
+
+ IWN_LOCK(sc);
+ /*
+ * Dequeue frames, attempt to transmit,
+ * then disable beaconwait when we're done.
+ */
+ while ((m = mbufq_dequeue(&sc->sc_xmit_queue)) != NULL) {
+ have_p = 0;
+ ni = (struct ieee80211_node *)m->m_pkthdr.rcvif;
+
+ /* Get xmit params if appropriate */
+ if (ieee80211_get_xmit_params(m, &p) == 0)
+ have_p = 1;
+
+ DPRINTF(sc, IWN_DEBUG_XMIT, "%s: m=%p, have_p=%d\n",
+ __func__, m, have_p);
+
+ /* If we have xmit params, use them */
+ if (have_p)
+ error = iwn_tx_data_raw(sc, m, ni, &p);
+ else
+ error = iwn_tx_data(sc, m, ni);
+
+ if (error != 0) {
+ ieee80211_free_node(ni);
+ if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
+ }
+ }
+
+ sc->sc_beacon_wait = 0;
+ IWN_UNLOCK(sc);
+}
+
static int
iwn_raw_xmit(struct ieee80211_node *ni, struct mbuf *m,
const struct ieee80211_bpf_params *params)
@@ -4819,7 +4933,25 @@ iwn_raw_xmit(struct ieee80211_node *ni, struct mbuf *m,
return ENETDOWN;
}
+ /* XXX? net80211 doesn't set this on xmit'ed raw frames? */
+ m->m_pkthdr.rcvif = (void *) ni;
+
IWN_LOCK(sc);
+
+ /* queue frame if we have to */
+ if (sc->sc_beacon_wait) {
+ if (iwn_xmit_queue_enqueue(sc, m) != 0) {
+ m_freem(m);
+ ieee80211_free_node(ni);
+ if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
+ IWN_UNLOCK(sc);
+ return (ENOBUFS);
+ }
+ /* Queued, so just return OK */
+ IWN_UNLOCK(sc);
+ return (0);
+ }
+
if (params == NULL) {
/*
* Legacy path; interpret frame contents to decide
@@ -4866,6 +4998,14 @@ iwn_start_locked(struct ifnet *ifp)
IWN_LOCK_ASSERT(sc);
+ /*
+ * If we're waiting for a beacon, we can just exit out here
+ * and wait for the taskqueue to be kicked.
+ */
+ if (sc->sc_beacon_wait) {
+ return;
+ }
+
DPRINTF(sc, IWN_DEBUG_XMIT, "%s: called\n", __func__);
if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0 ||
diff --git a/sys/dev/iwn/if_iwnvar.h b/sys/dev/iwn/if_iwnvar.h
index b14158b..9366fc2 100644
--- a/sys/dev/iwn/if_iwnvar.h
+++ b/sys/dev/iwn/if_iwnvar.h
@@ -309,6 +309,7 @@ struct iwn_softc {
struct task sc_radioon_task;
struct task sc_radiooff_task;
struct task sc_panic_task;
+ struct task sc_xmit_task;
/* Taskqueue */
struct taskqueue *sc_tq;
@@ -385,6 +386,9 @@ struct iwn_softc {
/* Are we doing a scan? */
int sc_is_scanning;
+ /* Are we waiting for a beacon before xmit? */
+ int sc_beacon_wait;
+
struct ieee80211_tx_ampdu *qid2tap[IWN5000_NTXQUEUES];
int (*sc_ampdu_rx_start)(struct ieee80211_node *,
@@ -417,6 +421,13 @@ struct iwn_softc {
#define IWN_UCODE_API(ver) (((ver) & 0x0000FF00) >> 8)
uint32_t ucode_rev;
+
+ /*
+ * Global queue for queuing xmit frames
+ * when we can't yet transmit (eg raw
+ * frames whilst waiting for beacons.)
+ */
+ struct mbufq sc_xmit_queue;
};
#define IWN_LOCK_INIT(_sc) \
diff --git a/sys/dev/ixl/if_ixl.c b/sys/dev/ixl/if_ixl.c
index 13a678c..1a36c2a 100644
--- a/sys/dev/ixl/if_ixl.c
+++ b/sys/dev/ixl/if_ixl.c
@@ -2551,7 +2551,7 @@ ixl_setup_interface(device_t dev, struct ixl_vsi *vsi)
}
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_mtu = ETHERMTU;
- ifp->if_baudrate = 4000000000; // ??
+ ifp->if_baudrate = IF_Gbps(40);
ifp->if_init = ixl_init;
ifp->if_softc = vsi;
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
diff --git a/sys/dev/mii/mii.h b/sys/dev/mii/mii.h
index 297ef21..fa1ec84 100644
--- a/sys/dev/mii/mii.h
+++ b/sys/dev/mii/mii.h
@@ -204,7 +204,7 @@
#define MII_PSESR 0x0c /* PSE status register */
#define PSESR_PWRDENIED 0x1000 /* Power Denied */
#define PSESR_VALSIG 0x0800 /* Valid PD signature detected */
-#define PSESR_INVALSIG 0x0400 /* Inalid PD signature detected */
+#define PSESR_INVALSIG 0x0400 /* Invalid PD signature detected */
#define PSESR_SHORTCIRC 0x0200 /* Short circuit condition detected */
#define PSESR_OVERLOAD 0x0100 /* Overload condition detected */
#define PSESR_MPSABSENT 0x0080 /* MPS absent condition detected */
diff --git a/sys/dev/videomode/videomode.h b/sys/dev/videomode/videomode.h
index b223da8..3e64444 100644
--- a/sys/dev/videomode/videomode.h
+++ b/sys/dev/videomode/videomode.h
@@ -43,6 +43,7 @@ struct videomode {
int vtotal;
int flags; /* Video mode flags; see below. */
const char *name;
+ int hskew;
};
/*
diff --git a/sys/dev/virtio/mmio/virtio_mmio.h b/sys/dev/virtio/mmio/virtio_mmio.h
index 30e0286..81e87b7 100644
--- a/sys/dev/virtio/mmio/virtio_mmio.h
+++ b/sys/dev/virtio/mmio/virtio_mmio.h
@@ -36,10 +36,6 @@
#define VIRTIO_MMIO_MAGIC_VALUE 0x000
#define VIRTIO_MMIO_VERSION 0x004
#define VIRTIO_MMIO_DEVICE_ID 0x008
-
-#define VIRTIO_MMIO_MAGIC_VALUE 0x000
-#define VIRTIO_MMIO_VERSION 0x004
-#define VIRTIO_MMIO_DEVICE_ID 0x008
#define VIRTIO_MMIO_VENDOR_ID 0x00c
#define VIRTIO_MMIO_HOST_FEATURES 0x010
#define VIRTIO_MMIO_HOST_FEATURES_SEL 0x014
diff --git a/sys/dev/xen/blkfront/blkfront.c b/sys/dev/xen/blkfront/blkfront.c
index a71251d..3991f96 100644
--- a/sys/dev/xen/blkfront/blkfront.c
+++ b/sys/dev/xen/blkfront/blkfront.c
@@ -156,44 +156,14 @@ xbd_free_command(struct xbd_command *cm)
}
static void
-xbd_queue_cb(void *arg, bus_dma_segment_t *segs, int nsegs, int error)
+mksegarray(bus_dma_segment_t *segs, int nsegs,
+ grant_ref_t * gref_head, int otherend_id, int readonly,
+ grant_ref_t * sg_ref, blkif_request_segment_t * sg)
{
- struct xbd_softc *sc;
- struct xbd_command *cm;
- blkif_request_t *ring_req;
- struct blkif_request_segment *sg;
- struct blkif_request_segment *last_block_sg;
- grant_ref_t *sg_ref;
+ struct blkif_request_segment *last_block_sg = sg + nsegs;
vm_paddr_t buffer_ma;
uint64_t fsect, lsect;
int ref;
- int op;
- int block_segs;
-
- cm = arg;
- sc = cm->cm_sc;
-
- if (error) {
- cm->cm_bp->bio_error = EIO;
- biodone(cm->cm_bp);
- xbd_free_command(cm);
- return;
- }
-
- /* Fill out a communications ring structure. */
- ring_req = RING_GET_REQUEST(&sc->xbd_ring, sc->xbd_ring.req_prod_pvt);
- sc->xbd_ring.req_prod_pvt++;
- ring_req->id = cm->cm_id;
- ring_req->operation = cm->cm_operation;
- ring_req->sector_number = cm->cm_sector_number;
- ring_req->handle = (blkif_vdev_t)(uintptr_t)sc->xbd_disk;
- ring_req->nr_segments = nsegs;
- cm->cm_nseg = nsegs;
-
- block_segs = MIN(nsegs, BLKIF_MAX_SEGMENTS_PER_REQUEST);
- sg = ring_req->seg;
- last_block_sg = sg + block_segs;
- sg_ref = cm->cm_sg_refs;
while (sg < last_block_sg) {
buffer_ma = segs->ds_addr;
@@ -204,7 +174,7 @@ xbd_queue_cb(void *arg, bus_dma_segment_t *segs, int nsegs, int error)
"cross a page boundary"));
/* install a grant reference. */
- ref = gnttab_claim_grant_reference(&cm->cm_gref_head);
+ ref = gnttab_claim_grant_reference(gref_head);
/*
* GNTTAB_LIST_END == 0xffffffff, but it is private
@@ -214,9 +184,9 @@ xbd_queue_cb(void *arg, bus_dma_segment_t *segs, int nsegs, int error)
gnttab_grant_foreign_access_ref(
ref,
- xenbus_get_otherend_id(sc->xbd_dev),
+ otherend_id,
buffer_ma >> PAGE_SHIFT,
- ring_req->operation == BLKIF_OP_WRITE);
+ readonly);
*sg_ref = ref;
*sg = (struct blkif_request_segment) {
@@ -227,8 +197,43 @@ xbd_queue_cb(void *arg, bus_dma_segment_t *segs, int nsegs, int error)
sg++;
sg_ref++;
segs++;
- nsegs--;
}
+}
+
+static void
+xbd_queue_cb(void *arg, bus_dma_segment_t *segs, int nsegs, int error)
+{
+ struct xbd_softc *sc;
+ struct xbd_command *cm;
+ blkif_request_t *ring_req;
+ int op;
+
+ cm = arg;
+ sc = cm->cm_sc;
+
+ if (error) {
+ cm->cm_bp->bio_error = EIO;
+ biodone(cm->cm_bp);
+ xbd_free_command(cm);
+ return;
+ }
+
+ KASSERT(nsegs <= BLKIF_MAX_SEGMENTS_PER_REQUEST,
+ ("Too many segments in a blkfront I/O"));
+
+ /* Fill out a communications ring structure. */
+ ring_req = RING_GET_REQUEST(&sc->xbd_ring, sc->xbd_ring.req_prod_pvt);
+ sc->xbd_ring.req_prod_pvt++;
+ ring_req->id = cm->cm_id;
+ ring_req->operation = cm->cm_operation;
+ ring_req->sector_number = cm->cm_sector_number;
+ ring_req->handle = (blkif_vdev_t)(uintptr_t)sc->xbd_disk;
+ ring_req->nr_segments = nsegs;
+ cm->cm_nseg = nsegs;
+ mksegarray(segs, nsegs, &cm->cm_gref_head,
+ xenbus_get_otherend_id(sc->xbd_dev),
+ cm->cm_operation == BLKIF_OP_WRITE,
+ cm->cm_sg_refs, ring_req->seg);
if (cm->cm_operation == BLKIF_OP_READ)
op = BUS_DMASYNC_PREREAD;
diff --git a/sys/fs/nfsclient/nfs_clbio.c b/sys/fs/nfsclient/nfs_clbio.c
index e8de4a5..53ba7ef 100644
--- a/sys/fs/nfsclient/nfs_clbio.c
+++ b/sys/fs/nfsclient/nfs_clbio.c
@@ -129,12 +129,6 @@ ncl_getpages(struct vop_getpages_args *ap)
npages = btoc(count);
/*
- * Since the caller has busied the requested page, that page's valid
- * field will not be changed by other threads.
- */
- vm_page_assert_xbusied(pages[ap->a_reqpage]);
-
- /*
* If the requested page is partially valid, just return it and
* allow the pager to zero-out the blanks. Partially valid pages
* can only occur at the file EOF.
diff --git a/sys/fs/tmpfs/tmpfs_subr.c b/sys/fs/tmpfs/tmpfs_subr.c
index 5e2a825..6114608 100644
--- a/sys/fs/tmpfs/tmpfs_subr.c
+++ b/sys/fs/tmpfs/tmpfs_subr.c
@@ -1031,6 +1031,7 @@ tmpfs_dir_detach(struct vnode *vp, struct tmpfs_dirent *de)
tmpfs_free_dirent(tmp, xde);
}
}
+ de->td_cookie = de->td_hash;
} else
RB_REMOVE(tmpfs_dir, head, de);
diff --git a/sys/geom/label/g_label.c b/sys/geom/label/g_label.c
index 36498e1..b4a1365 100644
--- a/sys/geom/label/g_label.c
+++ b/sys/geom/label/g_label.c
@@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$");
#include <sys/malloc.h>
#include <sys/libkern.h>
#include <sys/sbuf.h>
+#include <sys/stddef.h>
#include <sys/sysctl.h>
#include <geom/geom.h>
#include <geom/geom_slice.h>
@@ -96,6 +97,20 @@ const struct g_label_desc *g_labels[] = {
NULL
};
+void
+g_label_rtrim(char *label, size_t size)
+{
+ ptrdiff_t i;
+
+ for (i = size - 1; i >= 0; i--) {
+ if (label[i] == '\0')
+ continue;
+ else if (label[i] == ' ')
+ label[i] = '\0';
+ else
+ break;
+ }
+}
static int
g_label_destroy_geom(struct gctl_req *req __unused, struct g_class *mp,
diff --git a/sys/geom/label/g_label.h b/sys/geom/label/g_label.h
index 66b762c..9092d98 100644
--- a/sys/geom/label/g_label.h
+++ b/sys/geom/label/g_label.h
@@ -86,6 +86,8 @@ extern struct g_label_desc g_label_ntfs;
extern struct g_label_desc g_label_gpt;
extern struct g_label_desc g_label_gpt_uuid;
extern struct g_label_desc g_label_disk_ident;
+
+extern void g_label_rtrim(char *label, size_t size);
#endif /* _KERNEL */
struct g_label_metadata {
diff --git a/sys/geom/label/g_label_iso9660.c b/sys/geom/label/g_label_iso9660.c
index 154cefc..c3c49b0 100644
--- a/sys/geom/label/g_label_iso9660.c
+++ b/sys/geom/label/g_label_iso9660.c
@@ -47,7 +47,6 @@ g_label_iso9660_taste(struct g_consumer *cp, char *label, size_t size)
{
struct g_provider *pp;
char *sector, *volume;
- int i;
g_topology_assert_not();
pp = cp->provider;
@@ -68,14 +67,7 @@ g_label_iso9660_taste(struct g_consumer *cp, char *label, size_t size)
bzero(label, size);
strlcpy(label, volume, MIN(size, VOLUME_LEN));
g_free(sector);
- for (i = size - 1; i > 0; i--) {
- if (label[i] == '\0')
- continue;
- else if (label[i] == ' ')
- label[i] = '\0';
- else
- break;
- }
+ g_label_rtrim(label, size);
}
struct g_label_desc g_label_iso9660 = {
diff --git a/sys/geom/label/g_label_msdosfs.c b/sys/geom/label/g_label_msdosfs.c
index 5f65a72..918fabc 100644
--- a/sys/geom/label/g_label_msdosfs.c
+++ b/sys/geom/label/g_label_msdosfs.c
@@ -48,7 +48,6 @@ g_label_msdosfs_taste(struct g_consumer *cp, char *label, size_t size)
FAT32_BSBPB *pfat32_bsbpb;
FAT_DES *pfat_entry;
uint8_t *sector0, *sector;
- uint32_t i;
g_topology_assert_not();
pp = cp->provider;
@@ -200,14 +199,7 @@ g_label_msdosfs_taste(struct g_consumer *cp, char *label, size_t size)
}
endofchecks:
- for (i = size - 1; i > 0; i--) {
- if (label[i] == '\0')
- continue;
- else if (label[i] == ' ')
- label[i] = '\0';
- else
- break;
- }
+ g_label_rtrim(label, size);
error:
if (sector0 != NULL)
diff --git a/sys/kern/imgact_binmisc.c b/sys/kern/imgact_binmisc.c
index 5f324d3..5ee9bb8 100644
--- a/sys/kern/imgact_binmisc.c
+++ b/sys/kern/imgact_binmisc.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2013, Stacey D. Son
+ * Copyright (c) 2013-15, Stacey D. Son
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -41,6 +41,9 @@ __FBSDID("$FreeBSD$");
#include <sys/malloc.h>
#include <sys/mutex.h>
#include <sys/sysctl.h>
+#include <sys/sx.h>
+
+#include <machine/atomic.h>
/**
* Miscellaneous binary interpreter image activator.
@@ -96,7 +99,7 @@ static SLIST_HEAD(, imgact_binmisc_entry) interpreter_list =
static int interp_list_entry_count = 0;
-static struct mtx interp_list_mtx;
+static struct sx interp_list_sx;
int imgact_binmisc_exec(struct image_params *imgp);
@@ -111,7 +114,7 @@ imgact_binmisc_populate_interp(char *str, imgact_binmisc_entry_t *ibe)
char t[IBE_INTERP_LEN_MAX];
char *sp, *tp;
- bzero(t, sizeof(t));
+ memset(t, 0, sizeof(t));
/*
* Normalize interpreter string. Replace white space between args with
@@ -152,8 +155,6 @@ imgact_binmisc_new_entry(ximgact_binmisc_entry_t *xbe)
imgact_binmisc_entry_t *ibe = NULL;
size_t namesz = min(strlen(xbe->xbe_name) + 1, IBE_NAME_MAX);
- mtx_assert(&interp_list_mtx, MA_NOTOWNED);
-
ibe = malloc(sizeof(*ibe), M_BINMISC, M_WAITOK|M_ZERO);
ibe->ibe_name = malloc(namesz, M_BINMISC, M_WAITOK|M_ZERO);
@@ -203,7 +204,7 @@ imgact_binmisc_find_entry(char *name)
{
imgact_binmisc_entry_t *ibe;
- mtx_assert(&interp_list_mtx, MA_OWNED);
+ sx_assert(&interp_list_sx, SA_LOCKED);
SLIST_FOREACH(ibe, &interpreter_list, link) {
if (strncmp(name, ibe->ibe_name, IBE_NAME_MAX) == 0)
@@ -260,21 +261,20 @@ imgact_binmisc_add_entry(ximgact_binmisc_entry_t *xbe)
}
}
- mtx_lock(&interp_list_mtx);
+ sx_xlock(&interp_list_sx);
if (imgact_binmisc_find_entry(xbe->xbe_name) != NULL) {
- mtx_unlock(&interp_list_mtx);
+ sx_xunlock(&interp_list_sx);
return (EEXIST);
}
- mtx_unlock(&interp_list_mtx);
+ /* Preallocate a new entry. */
ibe = imgact_binmisc_new_entry(xbe);
if (!ibe)
return (ENOMEM);
- mtx_lock(&interp_list_mtx);
SLIST_INSERT_HEAD(&interpreter_list, ibe, link);
interp_list_entry_count++;
- mtx_unlock(&interp_list_mtx);
+ sx_xunlock(&interp_list_sx);
return (0);
}
@@ -288,14 +288,14 @@ imgact_binmisc_remove_entry(char *name)
{
imgact_binmisc_entry_t *ibe;
- mtx_lock(&interp_list_mtx);
+ sx_xlock(&interp_list_sx);
if ((ibe = imgact_binmisc_find_entry(name)) == NULL) {
- mtx_unlock(&interp_list_mtx);
+ sx_xunlock(&interp_list_sx);
return (ENOENT);
}
SLIST_REMOVE(&interpreter_list, ibe, imgact_binmisc_entry, link);
interp_list_entry_count--;
- mtx_unlock(&interp_list_mtx);
+ sx_xunlock(&interp_list_sx);
imgact_binmisc_destroy_entry(ibe);
@@ -311,14 +311,14 @@ imgact_binmisc_disable_entry(char *name)
{
imgact_binmisc_entry_t *ibe;
- mtx_lock(&interp_list_mtx);
+ sx_slock(&interp_list_sx);
if ((ibe = imgact_binmisc_find_entry(name)) == NULL) {
- mtx_unlock(&interp_list_mtx);
+ sx_sunlock(&interp_list_sx);
return (ENOENT);
}
- ibe->ibe_flags &= ~IBF_ENABLED;
- mtx_unlock(&interp_list_mtx);
+ atomic_clear_32(&ibe->ibe_flags, IBF_ENABLED);
+ sx_sunlock(&interp_list_sx);
return (0);
}
@@ -332,14 +332,14 @@ imgact_binmisc_enable_entry(char *name)
{
imgact_binmisc_entry_t *ibe;
- mtx_lock(&interp_list_mtx);
+ sx_slock(&interp_list_sx);
if ((ibe = imgact_binmisc_find_entry(name)) == NULL) {
- mtx_unlock(&interp_list_mtx);
+ sx_sunlock(&interp_list_sx);
return (ENOENT);
}
- ibe->ibe_flags |= IBF_ENABLED;
- mtx_unlock(&interp_list_mtx);
+ atomic_set_32(&ibe->ibe_flags, IBF_ENABLED);
+ sx_sunlock(&interp_list_sx);
return (0);
}
@@ -350,9 +350,9 @@ imgact_binmisc_populate_xbe(ximgact_binmisc_entry_t *xbe,
{
uint32_t i;
- mtx_assert(&interp_list_mtx, MA_OWNED);
+ sx_assert(&interp_list_sx, SA_LOCKED);
- bzero(xbe, sizeof(*xbe));
+ memset(xbe, 0, sizeof(*xbe));
strlcpy(xbe->xbe_name, ibe->ibe_name, IBE_NAME_MAX);
/* Copy interpreter string. Replace NULL breaks with space. */
@@ -382,14 +382,14 @@ imgact_binmisc_lookup_entry(char *name, ximgact_binmisc_entry_t *xbe)
imgact_binmisc_entry_t *ibe;
int error = 0;
- mtx_lock(&interp_list_mtx);
+ sx_slock(&interp_list_sx);
if ((ibe = imgact_binmisc_find_entry(name)) == NULL) {
- mtx_unlock(&interp_list_mtx);
+ sx_sunlock(&interp_list_sx);
return (ENOENT);
}
error = imgact_binmisc_populate_xbe(xbe, ibe);
- mtx_unlock(&interp_list_mtx);
+ sx_sunlock(&interp_list_sx);
return (error);
}
@@ -404,14 +404,9 @@ imgact_binmisc_get_all_entries(struct sysctl_req *req)
imgact_binmisc_entry_t *ibe;
int error = 0, count;
- mtx_lock(&interp_list_mtx);
+ sx_slock(&interp_list_sx);
count = interp_list_entry_count;
- /* Don't block in malloc() while holding lock. */
- xbe = malloc(sizeof(*xbe) * count, M_BINMISC, M_NOWAIT|M_ZERO);
- if (!xbe) {
- mtx_unlock(&interp_list_mtx);
- return (ENOMEM);
- }
+ xbe = malloc(sizeof(*xbe) * count, M_BINMISC, M_WAITOK|M_ZERO);
xbep = xbe;
SLIST_FOREACH(ibe, &interpreter_list, link) {
@@ -419,7 +414,7 @@ imgact_binmisc_get_all_entries(struct sysctl_req *req)
if (error)
break;
}
- mtx_unlock(&interp_list_mtx);
+ sx_sunlock(&interp_list_sx);
if (!error)
error = SYSCTL_OUT(req, xbe, sizeof(*xbe) * count);
@@ -556,7 +551,7 @@ imgact_binmisc_find_interpreter(const char *image_header)
int i;
size_t sz;
- mtx_assert(&interp_list_mtx, MA_OWNED);
+ sx_assert(&interp_list_sx, SA_LOCKED);
SLIST_FOREACH(ibe, &interpreter_list, link) {
if (!(IBF_ENABLED & ibe->ibe_flags))
@@ -593,15 +588,15 @@ imgact_binmisc_exec(struct image_params *imgp)
char *s, *d;
/* Do we have an interpreter for the given image header? */
- mtx_lock(&interp_list_mtx);
+ sx_slock(&interp_list_sx);
if ((ibe = imgact_binmisc_find_interpreter(image_header)) == NULL) {
- mtx_unlock(&interp_list_mtx);
+ sx_sunlock(&interp_list_sx);
return (-1);
}
/* No interpreter nesting allowed. */
if (imgp->interpreted & IMGACT_BINMISC) {
- mtx_unlock(&interp_list_mtx);
+ sx_sunlock(&interp_list_sx);
return (ENOEXEC);
}
@@ -649,7 +644,7 @@ imgact_binmisc_exec(struct image_params *imgp)
default:
/* Hmm... This shouldn't happen. */
- mtx_unlock(&interp_list_mtx);
+ sx_sunlock(&interp_list_sx);
printf("%s: Unknown macro #%c sequence in "
"interpreter string\n", KMOD_NAME, *(s + 1));
error = EINVAL;
@@ -660,7 +655,7 @@ imgact_binmisc_exec(struct image_params *imgp)
/* Check to make sure we won't overrun the stringspace. */
if (offset > imgp->args->stringspace) {
- mtx_unlock(&interp_list_mtx);
+ sx_sunlock(&interp_list_sx);
error = E2BIG;
goto done;
}
@@ -720,7 +715,7 @@ imgact_binmisc_exec(struct image_params *imgp)
s++;
}
*d = '\0';
- mtx_unlock(&interp_list_mtx);
+ sx_sunlock(&interp_list_sx);
if (!error)
imgp->interpreter_name = imgp->args->begin_argv;
@@ -736,7 +731,7 @@ static void
imgact_binmisc_init(void *arg)
{
- mtx_init(&interp_list_mtx, KMOD_NAME, NULL, MTX_DEF);
+ sx_init(&interp_list_sx, KMOD_NAME);
}
static void
@@ -745,15 +740,15 @@ imgact_binmisc_fini(void *arg)
imgact_binmisc_entry_t *ibe, *ibe_tmp;
/* Free all the interpreters. */
- mtx_lock(&interp_list_mtx);
+ sx_xlock(&interp_list_sx);
SLIST_FOREACH_SAFE(ibe, &interpreter_list, link, ibe_tmp) {
SLIST_REMOVE(&interpreter_list, ibe, imgact_binmisc_entry,
link);
imgact_binmisc_destroy_entry(ibe);
}
- mtx_unlock(&interp_list_mtx);
+ sx_xunlock(&interp_list_sx);
- mtx_destroy(&interp_list_mtx);
+ sx_destroy(&interp_list_sx);
}
SYSINIT(imgact_binmisc, SI_SUB_EXEC, SI_ORDER_MIDDLE, imgact_binmisc_init, 0);
diff --git a/sys/kern/kern_jail.c b/sys/kern/kern_jail.c
index c87c4e2..c118d74 100644
--- a/sys/kern/kern_jail.c
+++ b/sys/kern/kern_jail.c
@@ -1331,7 +1331,7 @@ kern_jail_set(struct thread *td, struct uio *optuio, int flags)
pr->pr_securelevel = ppr->pr_securelevel;
pr->pr_allow = JAIL_DEFAULT_ALLOW & ppr->pr_allow;
- pr->pr_enforce_statfs = JAIL_DEFAULT_ENFORCE_STATFS;
+ pr->pr_enforce_statfs = jail_default_enforce_statfs;
pr->pr_devfs_rsnum = ppr->pr_devfs_rsnum;
pr->pr_osreldate = osreldt ? osreldt : ppr->pr_osreldate;
diff --git a/sys/kern/stack_protector.c b/sys/kern/stack_protector.c
index b5f9973..77be64f 100644
--- a/sys/kern/stack_protector.c
+++ b/sys/kern/stack_protector.c
@@ -17,15 +17,14 @@ __stack_chk_fail(void)
panic("stack overflow detected; backtrace may be corrupted");
}
-#define __arraycount(__x) (sizeof(__x) / sizeof(__x[0]))
static void
__stack_chk_init(void *dummy __unused)
{
size_t i;
- long guard[__arraycount(__stack_chk_guard)];
+ long guard[nitems(__stack_chk_guard)];
arc4rand(guard, sizeof(guard), 0);
- for (i = 0; i < __arraycount(guard); i++)
+ for (i = 0; i < nitems(guard); i++)
__stack_chk_guard[i] = guard[i];
}
SYSINIT(stack_chk, SI_SUB_RANDOM, SI_ORDER_ANY, __stack_chk_init, NULL);
diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c
index 625d193..ce194f9 100644
--- a/sys/kern/vfs_subr.c
+++ b/sys/kern/vfs_subr.c
@@ -173,6 +173,11 @@ static int reassignbufcalls;
SYSCTL_INT(_vfs, OID_AUTO, reassignbufcalls, CTLFLAG_RW, &reassignbufcalls, 0,
"Number of calls to reassignbuf");
+static u_long free_owe_inact;
+SYSCTL_ULONG(_vfs, OID_AUTO, free_owe_inact, CTLFLAG_RD, &free_owe_inact, 0,
+ "Number of times free vnodes kept on active list due to VFS "
+ "owing inactivation");
+
/*
* Cache for the mount type id assigned to NFS. This is used for
* special checks in nfs/nfs_nqlease.c and vm/vnode_pager.c.
@@ -2368,11 +2373,8 @@ vholdl(struct vnode *vp)
CTR2(KTR_VFS, "%s: vp %p", __func__, vp);
#ifdef INVARIANTS
/* getnewvnode() calls v_incr_usecount() without holding interlock. */
- if (vp->v_type != VNON || vp->v_data != NULL) {
+ if (vp->v_type != VNON || vp->v_data != NULL)
ASSERT_VI_LOCKED(vp, "vholdl");
- VNASSERT(vp->v_holdcnt > 0 || (vp->v_iflag & VI_FREE) != 0,
- vp, ("vholdl: free vnode is held"));
- }
#endif
vp->v_holdcnt++;
if ((vp->v_iflag & VI_FREE) == 0)
@@ -2443,23 +2445,29 @@ vdropl(struct vnode *vp)
VNASSERT(vp->v_holdcnt == 0, vp,
("vdropl: freeing when we shouldn't"));
active = vp->v_iflag & VI_ACTIVE;
- vp->v_iflag &= ~VI_ACTIVE;
- mp = vp->v_mount;
- mtx_lock(&vnode_free_list_mtx);
- if (active) {
- TAILQ_REMOVE(&mp->mnt_activevnodelist, vp,
- v_actfreelist);
- mp->mnt_activevnodelistsize--;
- }
- if (vp->v_iflag & VI_AGE) {
- TAILQ_INSERT_HEAD(&vnode_free_list, vp, v_actfreelist);
+ if ((vp->v_iflag & VI_OWEINACT) == 0) {
+ vp->v_iflag &= ~VI_ACTIVE;
+ mp = vp->v_mount;
+ mtx_lock(&vnode_free_list_mtx);
+ if (active) {
+ TAILQ_REMOVE(&mp->mnt_activevnodelist, vp,
+ v_actfreelist);
+ mp->mnt_activevnodelistsize--;
+ }
+ if (vp->v_iflag & VI_AGE) {
+ TAILQ_INSERT_HEAD(&vnode_free_list, vp,
+ v_actfreelist);
+ } else {
+ TAILQ_INSERT_TAIL(&vnode_free_list, vp,
+ v_actfreelist);
+ }
+ freevnodes++;
+ vp->v_iflag &= ~VI_AGE;
+ vp->v_iflag |= VI_FREE;
+ mtx_unlock(&vnode_free_list_mtx);
} else {
- TAILQ_INSERT_TAIL(&vnode_free_list, vp, v_actfreelist);
+ atomic_add_long(&free_owe_inact, 1);
}
- freevnodes++;
- vp->v_iflag &= ~VI_AGE;
- vp->v_iflag |= VI_FREE;
- mtx_unlock(&vnode_free_list_mtx);
VI_UNLOCK(vp);
return;
}
diff --git a/sys/modules/usb/Makefile b/sys/modules/usb/Makefile
index 84d5ef2..da3d776 100644
--- a/sys/modules/usb/Makefile
+++ b/sys/modules/usb/Makefile
@@ -53,7 +53,7 @@ SUBDIR += ${_dwc_otg} ehci ${_musb} ohci uhci xhci ${_uss820dci} ${_at91dci} \
${_atmegadci} ${_avr32dci} ${_rsu} ${_rsufw} ${_saf1761otg}
SUBDIR += ${_rum} ${_run} ${_runfw} ${_uath} upgt usie ural ${_zyd} ${_urtw}
SUBDIR += ${_urtwn} ${_urtwnfw}
-SUBDIR += atp uhid ukbd ums udbp ufm uep wsp uled
+SUBDIR += atp uhid ukbd ums udbp ufm uep wsp ugold uled
SUBDIR += ucom u3g uark ubsa ubser uchcom ucycom ufoma uftdi ugensa uipaq ulpt \
umct umcs umodem umoscom uplcom uslcom uvisor uvscom
SUBDIR += udl
diff --git a/sys/netinet/if_ether.c b/sys/netinet/if_ether.c
index fec6aa0..aa370d6 100644
--- a/sys/netinet/if_ether.c
+++ b/sys/netinet/if_ether.c
@@ -364,6 +364,7 @@ retry:
if ((la->la_flags & LLE_VALID) &&
((la->la_flags & LLE_STATIC) || la->la_expire > time_uptime)) {
bcopy(&la->ll_addr, desten, ifp->if_addrlen);
+ renew = 0;
/*
* If entry has an expiry time and it is approaching,
* see if we need to send an ARP request within this
@@ -371,14 +372,22 @@ retry:
*/
if (!(la->la_flags & LLE_STATIC) &&
time_uptime + la->la_preempt > la->la_expire) {
- arprequest(ifp, NULL, &SIN(dst)->sin_addr, NULL);
+ renew = 1;
la->la_preempt--;
}
if (pflags != NULL)
*pflags = la->la_flags;
- error = 0;
- goto done;
+
+ if (flags & LLE_EXCLUSIVE)
+ LLE_WUNLOCK(la);
+ else
+ LLE_RUNLOCK(la);
+
+ if (renew == 1)
+ arprequest(ifp, NULL, &SIN(dst)->sin_addr, NULL);
+
+ return (0);
}
if (la->la_flags & LLE_STATIC) { /* should not happen! */
diff --git a/sys/netinet/ip_encap.c b/sys/netinet/ip_encap.c
index fcd048a..d3d0116 100644
--- a/sys/netinet/ip_encap.c
+++ b/sys/netinet/ip_encap.c
@@ -95,14 +95,14 @@ static MALLOC_DEFINE(M_NETADDR, "encap_export_host", "Export host address struct
static void encap_add(struct encaptab *);
static int mask_match(const struct encaptab *, const struct sockaddr *,
const struct sockaddr *);
-static void encap_fillarg(struct mbuf *, const struct encaptab *);
+static void encap_fillarg(struct mbuf *, void *);
/*
* All global variables in ip_encap.c are locked using encapmtx.
*/
static struct mtx encapmtx;
MTX_SYSINIT(encapmtx, &encapmtx, "encapmtx", MTX_DEF);
-LIST_HEAD(, encaptab) encaptab = LIST_HEAD_INITIALIZER(encaptab);
+static LIST_HEAD(, encaptab) encaptab = LIST_HEAD_INITIALIZER(encaptab);
/*
* We currently keey encap_init() for source code compatibility reasons --
@@ -122,12 +122,12 @@ encap4_input(struct mbuf **mp, int *offp, int proto)
struct sockaddr_in s, d;
const struct protosw *psw;
struct encaptab *ep, *match;
+ void *arg;
int matchprio, off, prio;
m = *mp;
off = *offp;
ip = mtod(m, struct ip *);
- *mp = NULL;
bzero(&s, sizeof(s));
s.sin_family = AF_INET;
@@ -138,6 +138,8 @@ encap4_input(struct mbuf **mp, int *offp, int proto)
d.sin_len = sizeof(struct sockaddr_in);
d.sin_addr = ip->ip_dst;
+ arg = NULL;
+ psw = NULL;
match = NULL;
matchprio = 0;
mtx_lock(&encapmtx);
@@ -182,14 +184,16 @@ encap4_input(struct mbuf **mp, int *offp, int proto)
match = ep;
}
}
+ if (match != NULL) {
+ psw = match->psw;
+ arg = match->arg;
+ }
mtx_unlock(&encapmtx);
- if (match) {
+ if (match != NULL) {
/* found a match, "match" has the best one */
- psw = match->psw;
- if (psw && psw->pr_input) {
- encap_fillarg(m, match);
- *mp = m;
+ if (psw != NULL && psw->pr_input != NULL) {
+ encap_fillarg(m, arg);
(*psw->pr_input)(mp, offp, proto);
} else
m_freem(m);
@@ -197,7 +201,6 @@ encap4_input(struct mbuf **mp, int *offp, int proto)
}
/* last resort: inject to raw socket */
- *mp = m;
return (rip_input(mp, offp, proto));
}
#endif
@@ -211,6 +214,7 @@ encap6_input(struct mbuf **mp, int *offp, int proto)
struct sockaddr_in6 s, d;
const struct protosw *psw;
struct encaptab *ep, *match;
+ void *arg;
int prio, matchprio;
ip6 = mtod(m, struct ip6_hdr *);
@@ -224,6 +228,8 @@ encap6_input(struct mbuf **mp, int *offp, int proto)
d.sin6_len = sizeof(struct sockaddr_in6);
d.sin6_addr = ip6->ip6_dst;
+ arg = NULL;
+ psw = NULL;
match = NULL;
matchprio = 0;
mtx_lock(&encapmtx);
@@ -251,17 +257,20 @@ encap6_input(struct mbuf **mp, int *offp, int proto)
match = ep;
}
}
+ if (match != NULL) {
+ psw = match->psw;
+ arg = match->arg;
+ }
mtx_unlock(&encapmtx);
- if (match) {
+ if (match != NULL) {
/* found a match */
- psw = match->psw;
- if (psw && psw->pr_input) {
- encap_fillarg(m, match);
+ if (psw != NULL && psw->pr_input != NULL) {
+ encap_fillarg(m, arg);
return (*psw->pr_input)(mp, offp, proto);
} else {
m_freem(m);
- return IPPROTO_DONE;
+ return (IPPROTO_DONE);
}
}
@@ -440,14 +449,16 @@ mask_match(const struct encaptab *ep, const struct sockaddr *sp,
}
static void
-encap_fillarg(struct mbuf *m, const struct encaptab *ep)
+encap_fillarg(struct mbuf *m, void *arg)
{
struct m_tag *tag;
- tag = m_tag_get(PACKET_TAG_ENCAP, sizeof (void*), M_NOWAIT);
- if (tag) {
- *(void**)(tag+1) = ep->arg;
- m_tag_prepend(m, tag);
+ if (arg != NULL) {
+ tag = m_tag_get(PACKET_TAG_ENCAP, sizeof(void *), M_NOWAIT);
+ if (tag != NULL) {
+ *(void**)(tag+1) = arg;
+ m_tag_prepend(m, tag);
+ }
}
}
diff --git a/sys/netinet/sctp_asconf.c b/sys/netinet/sctp_asconf.c
index 9015d80..a64e7f9 100644
--- a/sys/netinet/sctp_asconf.c
+++ b/sys/netinet/sctp_asconf.c
@@ -1109,7 +1109,8 @@ sctp_path_check_and_react(struct sctp_tcb *stcb, struct sctp_ifa *newifa)
* not be changed.
*/
SCTP_RTALLOC((sctp_route_t *) & net->ro,
- stcb->sctp_ep->def_vrf_id);
+ stcb->sctp_ep->def_vrf_id,
+ stcb->sctp_ep->fibnum);
if (net->ro.ro_rt == NULL)
continue;
diff --git a/sys/netinet/sctp_input.c b/sys/netinet/sctp_input.c
index 89047cb..c6bea83 100644
--- a/sys/netinet/sctp_input.c
+++ b/sys/netinet/sctp_input.c
@@ -186,7 +186,7 @@ sctp_handle_init(struct mbuf *m, int iphlen, int offset,
op_err = sctp_generate_cause(SCTP_BASE_SYSCTL(sctp_diag_info_code),
"No listener");
sctp_send_abort(m, iphlen, src, dst, sh, 0, op_err,
- mflowtype, mflowid,
+ mflowtype, mflowid, inp->fibnum,
vrf_id, port);
}
goto outnow;
@@ -1484,7 +1484,7 @@ sctp_process_cookie_existing(struct mbuf *m, int iphlen, int offset,
sctp_send_shutdown_ack(stcb, stcb->asoc.primary_destination);
op_err = sctp_generate_cause(SCTP_CAUSE_COOKIE_IN_SHUTDOWN, "");
sctp_send_operr_to(src, dst, sh, cookie->peers_vtag, op_err,
- mflowtype, mflowid,
+ mflowtype, mflowid, inp->fibnum,
vrf_id, net->port);
if (how_indx < sizeof(asoc->cookie_how))
asoc->cookie_how[how_indx] = 2;
@@ -1694,7 +1694,7 @@ sctp_process_cookie_existing(struct mbuf *m, int iphlen, int offset,
*/
op_err = sctp_generate_cause(SCTP_CAUSE_NAT_COLLIDING_STATE, "");
sctp_send_abort(m, iphlen, src, dst, sh, 0, op_err,
- mflowtype, mflowid,
+ mflowtype, mflowid, inp->fibnum,
vrf_id, port);
return (NULL);
}
@@ -2572,7 +2572,7 @@ sctp_handle_cookie_echo(struct mbuf *m, int iphlen, int offset,
tim = now.tv_usec - cookie->time_entered.tv_usec;
scm->time_usec = htonl(tim);
sctp_send_operr_to(src, dst, sh, cookie->peers_vtag, op_err,
- mflowtype, mflowid,
+ mflowtype, mflowid, l_inp->fibnum,
vrf_id, port);
return (NULL);
}
@@ -2676,8 +2676,9 @@ sctp_handle_cookie_echo(struct mbuf *m, int iphlen, int offset,
/* still no TCB... must be bad cookie-echo */
return (NULL);
}
- if ((*netp != NULL) && (mflowtype != M_HASHTYPE_NONE)) {
+ if (*netp != NULL) {
(*netp)->flowtype = mflowtype;
+ (*netp)->flowid = mflowid;
}
/*
* Ok, we built an association so confirm the address we sent the
@@ -2794,6 +2795,7 @@ sctp_handle_cookie_echo(struct mbuf *m, int iphlen, int offset,
inp->partial_delivery_point = (*inp_p)->partial_delivery_point;
inp->sctp_context = (*inp_p)->sctp_context;
inp->local_strreset_support = (*inp_p)->local_strreset_support;
+ inp->fibnum = (*inp_p)->fibnum;
inp->inp_starting_point_for_iterator = NULL;
/*
* copy in the authentication parameters from the
@@ -4404,7 +4406,7 @@ __attribute__((noinline))
struct sockaddr *src, struct sockaddr *dst,
struct sctphdr *sh, struct sctp_chunkhdr *ch, struct sctp_inpcb *inp,
struct sctp_tcb *stcb, struct sctp_nets **netp, int *fwd_tsn_seen,
- uint8_t mflowtype, uint32_t mflowid,
+ uint8_t mflowtype, uint32_t mflowid, uint16_t fibnum,
uint32_t vrf_id, uint16_t port)
{
struct sctp_association *asoc;
@@ -4568,7 +4570,7 @@ __attribute__((noinline))
msg);
/* no association, so it's out of the blue... */
sctp_handle_ootb(m, iphlen, *offset, src, dst, sh, inp, op_err,
- mflowtype, mflowid,
+ mflowtype, mflowid, inp->fibnum,
vrf_id, port);
*offset = length;
if (locked_tcb) {
@@ -4612,7 +4614,7 @@ __attribute__((noinline))
msg);
sctp_handle_ootb(m, iphlen, *offset, src, dst,
sh, inp, op_err,
- mflowtype, mflowid,
+ mflowtype, mflowid, fibnum,
vrf_id, port);
return (NULL);
}
@@ -5622,7 +5624,7 @@ sctp_common_input_processing(struct mbuf **mm, int iphlen, int offset, int lengt
uint8_t compute_crc,
#endif
uint8_t ecn_bits,
- uint8_t mflowtype, uint32_t mflowid,
+ uint8_t mflowtype, uint32_t mflowid, uint16_t fibnum,
uint32_t vrf_id, uint16_t port)
{
uint32_t high_tsn;
@@ -5661,8 +5663,9 @@ sctp_common_input_processing(struct mbuf **mm, int iphlen, int offset, int lengt
net->port = port;
}
#endif
- if ((net != NULL) && (mflowtype != M_HASHTYPE_NONE)) {
+ if (net != NULL) {
net->flowtype = mflowtype;
+ net->flowid = mflowid;
}
if ((inp != NULL) && (stcb != NULL)) {
sctp_send_packet_dropped(stcb, net, m, length, iphlen, 1);
@@ -5691,8 +5694,9 @@ sctp_common_input_processing(struct mbuf **mm, int iphlen, int offset, int lengt
net->port = port;
}
#endif
- if ((net != NULL) && (mflowtype != M_HASHTYPE_NONE)) {
+ if (net != NULL) {
net->flowtype = mflowtype;
+ net->flowid = mflowid;
}
if (inp == NULL) {
SCTP_STAT_INCR(sctps_noport);
@@ -5701,7 +5705,7 @@ sctp_common_input_processing(struct mbuf **mm, int iphlen, int offset, int lengt
}
if (ch->chunk_type == SCTP_SHUTDOWN_ACK) {
sctp_send_shutdown_complete2(src, dst, sh,
- mflowtype, mflowid,
+ mflowtype, mflowid, fibnum,
vrf_id, port);
goto out;
}
@@ -5716,7 +5720,7 @@ sctp_common_input_processing(struct mbuf **mm, int iphlen, int offset, int lengt
"Out of the blue");
sctp_send_abort(m, iphlen, src, dst,
sh, 0, op_err,
- mflowtype, mflowid,
+ mflowtype, mflowid, fibnum,
vrf_id, port);
}
}
@@ -5775,7 +5779,7 @@ sctp_common_input_processing(struct mbuf **mm, int iphlen, int offset, int lengt
op_err = sctp_generate_cause(SCTP_BASE_SYSCTL(sctp_diag_info_code),
msg);
sctp_handle_ootb(m, iphlen, offset, src, dst, sh, inp, op_err,
- mflowtype, mflowid,
+ mflowtype, mflowid, inp->fibnum,
vrf_id, port);
goto out;
}
@@ -5786,7 +5790,7 @@ sctp_common_input_processing(struct mbuf **mm, int iphlen, int offset, int lengt
stcb = sctp_process_control(m, iphlen, &offset, length,
src, dst, sh, ch,
inp, stcb, &net, &fwd_tsn_seen,
- mflowtype, mflowid,
+ mflowtype, mflowid, fibnum,
vrf_id, port);
if (stcb) {
/*
@@ -5827,7 +5831,7 @@ sctp_common_input_processing(struct mbuf **mm, int iphlen, int offset, int lengt
op_err = sctp_generate_cause(SCTP_BASE_SYSCTL(sctp_diag_info_code),
msg);
sctp_handle_ootb(m, iphlen, offset, src, dst, sh, inp, op_err,
- mflowtype, mflowid,
+ mflowtype, mflowid, fibnum,
vrf_id, port);
goto out;
}
@@ -5899,7 +5903,7 @@ sctp_common_input_processing(struct mbuf **mm, int iphlen, int offset, int lengt
op_err = sctp_generate_cause(SCTP_BASE_SYSCTL(sctp_diag_info_code),
msg);
sctp_handle_ootb(m, iphlen, offset, src, dst, sh, inp, op_err,
- mflowtype, mflowid,
+ mflowtype, mflowid, inp->fibnum,
vrf_id, port);
goto out;
/* sa_ignore NOTREACHED */
@@ -6023,6 +6027,7 @@ sctp_input_with_port(struct mbuf *i_pak, int off, uint16_t port)
#endif
uint32_t mflowid;
uint8_t mflowtype;
+ uint16_t fibnum;
iphlen = off;
if (SCTP_GET_PKT_VRFID(i_pak, vrf_id)) {
@@ -6048,6 +6053,7 @@ sctp_input_with_port(struct mbuf *i_pak, int off, uint16_t port)
(int)m->m_pkthdr.csum_flags, CSUM_BITS);
mflowid = m->m_pkthdr.flowid;
mflowtype = M_HASHTYPE_GET(m);
+ fibnum = M_GETFIB(m);
SCTP_STAT_INCR(sctps_recvpackets);
SCTP_STAT_INCR_COUNTER64(sctps_inpackets);
/* Get IP, SCTP, and first chunk header together in the first mbuf. */
@@ -6107,7 +6113,7 @@ sctp_input_with_port(struct mbuf *i_pak, int off, uint16_t port)
compute_crc,
#endif
ecn_bits,
- mflowtype, mflowid,
+ mflowtype, mflowid, fibnum,
vrf_id, port);
out:
if (m) {
diff --git a/sys/netinet/sctp_input.h b/sys/netinet/sctp_input.h
index 0c3f8a5..148864b 100644
--- a/sys/netinet/sctp_input.h
+++ b/sys/netinet/sctp_input.h
@@ -45,7 +45,7 @@ sctp_common_input_processing(struct mbuf **, int, int, int,
uint8_t,
#endif
uint8_t,
- uint8_t, uint32_t,
+ uint8_t, uint32_t, uint16_t,
uint32_t, uint16_t);
struct sctp_stream_reset_request *
diff --git a/sys/netinet/sctp_os_bsd.h b/sys/netinet/sctp_os_bsd.h
index 140f341..bae67f0 100644
--- a/sys/netinet/sctp_os_bsd.h
+++ b/sys/netinet/sctp_os_bsd.h
@@ -413,13 +413,8 @@ typedef struct callout sctp_os_timer_t;
typedef struct route sctp_route_t;
typedef struct rtentry sctp_rtentry_t;
-/*
- * XXX multi-FIB support was backed out in r179783 and it seems clear that the
- * VRF support as currently in FreeBSD is not ready to support multi-FIB.
- * It might be best to implement multi-FIB support for both v4 and v6 indepedent
- * of VRFs and leave those to a real MPLS stack.
- */
-#define SCTP_RTALLOC(ro, vrf_id) rtalloc_ign((struct route *)ro, 0UL)
+#define SCTP_RTALLOC(ro, vrf_id, fibnum) \
+ rtalloc_ign_fib((struct route *)ro, 0UL, fibnum)
/* Future zero copy wakeup/send function */
#define SCTP_ZERO_COPY_EVENT(inp, so)
diff --git a/sys/netinet/sctp_output.c b/sys/netinet/sctp_output.c
index a52ed4e..3ef837c 100644
--- a/sys/netinet/sctp_output.c
+++ b/sys/netinet/sctp_output.c
@@ -3389,7 +3389,7 @@ sctp_source_address_selection(struct sctp_inpcb *inp,
/*
* Need a route to cache.
*/
- SCTP_RTALLOC(ro, vrf_id);
+ SCTP_RTALLOC(ro, vrf_id, inp->fibnum);
}
if (ro->ro_rt == NULL) {
return (NULL);
@@ -4170,7 +4170,7 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp,
sctp_free_ifa(_lsrc);
} else {
ip->ip_src = over_addr->sin.sin_addr;
- SCTP_RTALLOC(ro, vrf_id);
+ SCTP_RTALLOC(ro, vrf_id, inp->fibnum);
}
}
if (port) {
@@ -4484,7 +4484,7 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp,
sctp_free_ifa(_lsrc);
} else {
lsa6->sin6_addr = over_addr->sin6.sin6_addr;
- SCTP_RTALLOC(ro, vrf_id);
+ SCTP_RTALLOC(ro, vrf_id, inp->fibnum);
}
(void)sa6_recoverscope(sin6);
}
@@ -5511,7 +5511,7 @@ sctp_send_initiate_ack(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
op_err = sctp_generate_cause(SCTP_BASE_SYSCTL(sctp_diag_info_code),
"Address added");
sctp_send_abort(init_pkt, iphlen, src, dst, sh, 0, op_err,
- mflowtype, mflowid,
+ mflowtype, mflowid, inp->fibnum,
vrf_id, port);
return;
}
@@ -5530,7 +5530,7 @@ do_a_abort:
}
sctp_send_abort(init_pkt, iphlen, src, dst, sh,
init_chk->init.initiate_tag, op_err,
- mflowtype, mflowid,
+ mflowtype, mflowid, inp->fibnum,
vrf_id, port);
return;
}
@@ -10839,7 +10839,7 @@ static void
sctp_send_resp_msg(struct sockaddr *src, struct sockaddr *dst,
struct sctphdr *sh, uint32_t vtag,
uint8_t type, struct mbuf *cause,
- uint8_t mflowtype, uint32_t mflowid,
+ uint8_t mflowtype, uint32_t mflowid, uint16_t fibnum,
uint32_t vrf_id, uint16_t port)
{
struct mbuf *o_pak;
@@ -10919,6 +10919,7 @@ sctp_send_resp_msg(struct sockaddr *src, struct sockaddr *dst,
SCTP_BUF_RESV_UF(mout, max_linkhdr);
SCTP_BUF_LEN(mout) = len;
SCTP_BUF_NEXT(mout) = cause;
+ M_SETFIB(mout, fibnum);
mout->m_pkthdr.flowid = mflowid;
M_HASHTYPE_SET(mout, mflowtype);
#ifdef INET
@@ -11106,11 +11107,11 @@ sctp_send_resp_msg(struct sockaddr *src, struct sockaddr *dst,
void
sctp_send_shutdown_complete2(struct sockaddr *src, struct sockaddr *dst,
struct sctphdr *sh,
- uint8_t mflowtype, uint32_t mflowid,
+ uint8_t mflowtype, uint32_t mflowid, uint16_t fibnum,
uint32_t vrf_id, uint16_t port)
{
sctp_send_resp_msg(src, dst, sh, 0, SCTP_SHUTDOWN_COMPLETE, NULL,
- mflowtype, mflowid,
+ mflowtype, mflowid, fibnum,
vrf_id, port);
}
@@ -11929,7 +11930,7 @@ skip_stuff:
void
sctp_send_abort(struct mbuf *m, int iphlen, struct sockaddr *src, struct sockaddr *dst,
struct sctphdr *sh, uint32_t vtag, struct mbuf *cause,
- uint8_t mflowtype, uint32_t mflowid,
+ uint8_t mflowtype, uint32_t mflowid, uint16_t fibnum,
uint32_t vrf_id, uint16_t port)
{
/* Don't respond to an ABORT with an ABORT. */
@@ -11939,7 +11940,7 @@ sctp_send_abort(struct mbuf *m, int iphlen, struct sockaddr *src, struct sockadd
return;
}
sctp_send_resp_msg(src, dst, sh, vtag, SCTP_ABORT_ASSOCIATION, cause,
- mflowtype, mflowid,
+ mflowtype, mflowid, fibnum,
vrf_id, port);
return;
}
@@ -11947,11 +11948,11 @@ sctp_send_abort(struct mbuf *m, int iphlen, struct sockaddr *src, struct sockadd
void
sctp_send_operr_to(struct sockaddr *src, struct sockaddr *dst,
struct sctphdr *sh, uint32_t vtag, struct mbuf *cause,
- uint8_t mflowtype, uint32_t mflowid,
+ uint8_t mflowtype, uint32_t mflowid, uint16_t fibnum,
uint32_t vrf_id, uint16_t port)
{
sctp_send_resp_msg(src, dst, sh, vtag, SCTP_OPERATION_ERROR, cause,
- mflowtype, mflowid,
+ mflowtype, mflowid, fibnum,
vrf_id, port);
return;
}
diff --git a/sys/netinet/sctp_output.h b/sys/netinet/sctp_output.h
index 8789df9..8e45e5c 100644
--- a/sys/netinet/sctp_output.h
+++ b/sys/netinet/sctp_output.h
@@ -117,7 +117,7 @@ void sctp_send_shutdown_complete(struct sctp_tcb *, struct sctp_nets *, int);
void
sctp_send_shutdown_complete2(struct sockaddr *, struct sockaddr *,
struct sctphdr *,
- uint8_t, uint32_t,
+ uint8_t, uint32_t, uint16_t,
uint32_t, uint16_t);
void sctp_send_asconf(struct sctp_tcb *, struct sctp_nets *, int addr_locked);
@@ -187,13 +187,13 @@ sctp_send_str_reset_req(struct sctp_tcb *, uint16_t, uint16_t *, uint8_t,
void
sctp_send_abort(struct mbuf *, int, struct sockaddr *, struct sockaddr *,
struct sctphdr *, uint32_t, struct mbuf *,
- uint8_t, uint32_t,
+ uint8_t, uint32_t, uint16_t,
uint32_t, uint16_t);
void
sctp_send_operr_to(struct sockaddr *, struct sockaddr *,
struct sctphdr *, uint32_t, struct mbuf *,
- uint8_t, uint32_t,
+ uint8_t, uint32_t, uint16_t,
uint32_t, uint16_t);
#endif /* _KERNEL || __Userspace__ */
diff --git a/sys/netinet/sctp_pcb.c b/sys/netinet/sctp_pcb.c
index 6fcb6d2..541d4ca 100644
--- a/sys/netinet/sctp_pcb.c
+++ b/sys/netinet/sctp_pcb.c
@@ -2485,6 +2485,7 @@ sctp_inpcb_alloc(struct socket *so, uint32_t vrf_id)
inp->reconfig_supported = (uint8_t) SCTP_BASE_SYSCTL(sctp_reconfig_enable);
inp->nrsack_supported = (uint8_t) SCTP_BASE_SYSCTL(sctp_nrsack_enable);
inp->pktdrop_supported = (uint8_t) SCTP_BASE_SYSCTL(sctp_pktdrop_enable);
+ inp->fibnum = so->so_fibnum;
/* init the small hash table we use to track asocid <-> tcb */
inp->sctp_asocidhash = SCTP_HASH_INIT(SCTP_STACK_VTAG_HASH_SIZE, &inp->hashasocidmark);
if (inp->sctp_asocidhash == NULL) {
@@ -3949,7 +3950,9 @@ sctp_add_remote_addr(struct sctp_tcb *stcb, struct sockaddr *newaddr,
sin6->sin6_scope_id = 0;
}
#endif
- SCTP_RTALLOC((sctp_route_t *) & net->ro, stcb->asoc.vrf_id);
+ SCTP_RTALLOC((sctp_route_t *) & net->ro,
+ stcb->asoc.vrf_id,
+ stcb->sctp_ep->fibnum);
if (SCTP_ROUTE_HAS_VALID_IFN(&net->ro)) {
/* Get source address */
diff --git a/sys/netinet/sctp_pcb.h b/sys/netinet/sctp_pcb.h
index 963b89f..f5ede2a 100644
--- a/sys/netinet/sctp_pcb.h
+++ b/sys/netinet/sctp_pcb.h
@@ -430,6 +430,7 @@ struct sctp_inpcb {
struct mtx inp_rdata_mtx;
int32_t refcount;
uint32_t def_vrf_id;
+ uint16_t fibnum;
uint32_t total_sends;
uint32_t total_recvs;
uint32_t last_abort_code;
diff --git a/sys/netinet/sctp_syscalls.c b/sys/netinet/sctp_syscalls.c
index 28b4445..71e2f72 100644
--- a/sys/netinet/sctp_syscalls.c
+++ b/sys/netinet/sctp_syscalls.c
@@ -277,6 +277,10 @@ sys_sctp_generic_sendmsg (td, uap)
auio.uio_td = td;
auio.uio_offset = 0; /* XXX */
auio.uio_resid = 0;
+#ifdef KTRACE
+ if (KTRPOINT(td, KTR_GENIO))
+ ktruio = cloneuio(&auio);
+#endif /* KTRACE */
len = auio.uio_resid = uap->mlen;
CURVNET_SET(so->so_vnet);
error = sctp_lower_sosend(so, to, &auio, (struct mbuf *)NULL,
@@ -400,6 +404,10 @@ sys_sctp_generic_sendmsg_iov(td, uap)
goto sctp_bad;
}
}
+#ifdef KTRACE
+ if (KTRPOINT(td, KTR_GENIO))
+ ktruio = cloneuio(&auio);
+#endif /* KTRACE */
len = auio.uio_resid;
CURVNET_SET(so->so_vnet);
error = sctp_lower_sosend(so, to, &auio,
diff --git a/sys/netinet/sctp_usrreq.c b/sys/netinet/sctp_usrreq.c
index 3d06a52..907412c 100644
--- a/sys/netinet/sctp_usrreq.c
+++ b/sys/netinet/sctp_usrreq.c
@@ -5678,16 +5678,23 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
}
if ((stcb != NULL) && (net != NULL)) {
- if ((net != stcb->asoc.primary_destination) &&
- (!(net->dest_state & SCTP_ADDR_UNCONFIRMED))) {
- /* Ok we need to set it */
- if (sctp_set_primary_addr(stcb, (struct sockaddr *)NULL, net) == 0) {
- if ((stcb->asoc.alternate) &&
- (!(net->dest_state & SCTP_ADDR_PF)) &&
- (net->dest_state & SCTP_ADDR_REACHABLE)) {
- sctp_free_remote_addr(stcb->asoc.alternate);
- stcb->asoc.alternate = NULL;
+ if (net != stcb->asoc.primary_destination) {
+ if (!(net->dest_state & SCTP_ADDR_UNCONFIRMED)) {
+ /* Ok we need to set it */
+ if (sctp_set_primary_addr(stcb, (struct sockaddr *)NULL, net) == 0) {
+ if ((stcb->asoc.alternate) &&
+ (!(net->dest_state & SCTP_ADDR_PF)) &&
+ (net->dest_state & SCTP_ADDR_REACHABLE)) {
+ sctp_free_remote_addr(stcb->asoc.alternate);
+ stcb->asoc.alternate = NULL;
+ }
+ } else {
+ SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL);
+ error = EINVAL;
}
+ } else {
+ SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL);
+ error = EINVAL;
}
}
} else {
@@ -6712,7 +6719,20 @@ sctp_ctloutput(struct socket *so, struct sockopt *sopt)
size_t optsize = 0;
void *p;
int error = 0;
+ struct sctp_inpcb *inp;
+ if ((sopt->sopt_level == SOL_SOCKET) &&
+ (sopt->sopt_name == SO_SETFIB)) {
+ inp = (struct sctp_inpcb *)so->so_pcb;
+ if (inp == NULL) {
+ SCTP_LTRACE_ERR_RET(so->so_pcb, NULL, NULL, SCTP_FROM_SCTP_USRREQ, ENOBUFS);
+ return (EINVAL);
+ }
+ SCTP_INP_WLOCK(inp);
+ inp->fibnum = so->so_fibnum;
+ SCTP_INP_WUNLOCK(inp);
+ return (0);
+ }
if (sopt->sopt_level != IPPROTO_SCTP) {
/* wrong proto level... send back up to IP */
#ifdef INET6
diff --git a/sys/netinet/sctputil.c b/sys/netinet/sctputil.c
index 24110dd..c25ec39 100644
--- a/sys/netinet/sctputil.c
+++ b/sys/netinet/sctputil.c
@@ -3895,7 +3895,7 @@ sctp_abort_association(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
stcb->asoc.state |= SCTP_STATE_WAS_ABORTED;
}
sctp_send_abort(m, iphlen, src, dst, sh, vtag, op_err,
- mflowtype, mflowid,
+ mflowtype, mflowid, inp->fibnum,
vrf_id, port);
if (stcb != NULL) {
/* Ok, now lets free it */
@@ -4051,7 +4051,7 @@ sctp_handle_ootb(struct mbuf *m, int iphlen, int offset,
struct sockaddr *src, struct sockaddr *dst,
struct sctphdr *sh, struct sctp_inpcb *inp,
struct mbuf *cause,
- uint8_t mflowtype, uint32_t mflowid,
+ uint8_t mflowtype, uint32_t mflowid, uint16_t fibnum,
uint32_t vrf_id, uint16_t port)
{
struct sctp_chunkhdr *ch, chunk_buf;
@@ -4093,7 +4093,7 @@ sctp_handle_ootb(struct mbuf *m, int iphlen, int offset,
return;
case SCTP_SHUTDOWN_ACK:
sctp_send_shutdown_complete2(src, dst, sh,
- mflowtype, mflowid,
+ mflowtype, mflowid, fibnum,
vrf_id, port);
return;
default:
@@ -4107,7 +4107,7 @@ sctp_handle_ootb(struct mbuf *m, int iphlen, int offset,
((SCTP_BASE_SYSCTL(sctp_blackhole) == 1) &&
(contains_init_chunk == 0))) {
sctp_send_abort(m, iphlen, src, dst, sh, 0, cause,
- mflowtype, mflowid,
+ mflowtype, mflowid, fibnum,
vrf_id, port);
}
}
diff --git a/sys/netinet/sctputil.h b/sys/netinet/sctputil.h
index 2ffbc2a..7df0a6c 100644
--- a/sys/netinet/sctputil.h
+++ b/sys/netinet/sctputil.h
@@ -208,7 +208,7 @@ sctp_handle_ootb(struct mbuf *, int, int,
struct sockaddr *, struct sockaddr *,
struct sctphdr *, struct sctp_inpcb *,
struct mbuf *,
- uint8_t, uint32_t,
+ uint8_t, uint32_t, uint16_t,
uint32_t, uint16_t);
int
diff --git a/sys/netinet6/sctp6_usrreq.c b/sys/netinet6/sctp6_usrreq.c
index 54c65b6..009c47f 100644
--- a/sys/netinet6/sctp6_usrreq.c
+++ b/sys/netinet6/sctp6_usrreq.c
@@ -84,6 +84,7 @@ sctp6_input_with_port(struct mbuf **i_pak, int *offp, uint16_t port)
#endif
uint32_t mflowid;
uint8_t mflowtype;
+ uint16_t fibnum;
iphlen = *offp;
if (SCTP_GET_PKT_VRFID(*i_pak, vrf_id)) {
@@ -109,6 +110,7 @@ sctp6_input_with_port(struct mbuf **i_pak, int *offp, uint16_t port)
(int)m->m_pkthdr.csum_flags, CSUM_BITS);
mflowid = m->m_pkthdr.flowid;
mflowtype = M_HASHTYPE_GET(m);
+ fibnum = M_GETFIB(m);
SCTP_STAT_INCR(sctps_recvpackets);
SCTP_STAT_INCR_COUNTER64(sctps_inpackets);
/* Get IP, SCTP, and first chunk header together in the first mbuf. */
@@ -169,7 +171,7 @@ sctp6_input_with_port(struct mbuf **i_pak, int *offp, uint16_t port)
compute_crc,
#endif
ecn_bits,
- mflowtype, mflowid,
+ mflowtype, mflowid, fibnum,
vrf_id, port);
out:
if (m) {
diff --git a/sys/opencrypto/crypto.c b/sys/opencrypto/crypto.c
index 0ecdeb3..d084b77 100644
--- a/sys/opencrypto/crypto.c
+++ b/sys/opencrypto/crypto.c
@@ -1181,8 +1181,8 @@ crypto_kdone(struct cryptkop *krp)
/* XXX: What if driver is loaded in the meantime? */
if (krp->krp_hid < crypto_drivers_num) {
cap = &crypto_drivers[krp->krp_hid];
+ KASSERT(cap->cc_koperations > 0, ("cc_koperations == 0"));
cap->cc_koperations--;
- KASSERT(cap->cc_koperations >= 0, ("cc_koperations < 0"));
if (cap->cc_flags & CRYPTOCAP_F_CLEANUP)
crypto_remove(cap);
}
diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c
index ce43bcd..ffd8802 100644
--- a/sys/ufs/ffs/ffs_vfsops.c
+++ b/sys/ufs/ffs/ffs_vfsops.c
@@ -1410,6 +1410,14 @@ ffs_statfs(mp, sbp)
return (0);
}
+static bool
+sync_doupdate(struct inode *ip)
+{
+
+ return ((ip->i_flag & (IN_ACCESS | IN_CHANGE | IN_MODIFIED |
+ IN_UPDATE)) != 0);
+}
+
/*
* For a lazy sync, we only care about access times, quotas and the
* superblock. Other filesystem changes are already converted to
@@ -1443,15 +1451,15 @@ ffs_sync_lazy(mp)
* Test also all the other timestamp flags too, to pick up
* any other cases that could be missed.
*/
- if ((ip->i_flag & (IN_ACCESS | IN_CHANGE | IN_MODIFIED |
- IN_UPDATE)) == 0) {
+ if (!sync_doupdate(ip) && (vp->v_iflag & VI_OWEINACT) == 0) {
VI_UNLOCK(vp);
continue;
}
if ((error = vget(vp, LK_EXCLUSIVE | LK_NOWAIT | LK_INTERLOCK,
td)) != 0)
continue;
- error = ffs_update(vp, 0);
+ if (sync_doupdate(ip))
+ error = ffs_update(vp, 0);
if (error != 0)
allerror = error;
vput(vp);
diff --git a/sys/vm/swap_pager.c b/sys/vm/swap_pager.c
index 5ade2bc..b3ad70e 100644
--- a/sys/vm/swap_pager.c
+++ b/sys/vm/swap_pager.c
@@ -1118,10 +1118,6 @@ swap_pager_getpages(vm_object_t object, vm_page_t *m, int count, int reqpage)
mreq = m[reqpage];
- KASSERT(mreq->object == object,
- ("swap_pager_getpages: object mismatch %p/%p",
- object, mreq->object));
-
/*
* Calculate range to retrieve. The pages have already been assigned
* their swapblks. We require a *contiguous* range but we know it to
diff --git a/sys/vm/vm_pager.c b/sys/vm/vm_pager.c
index ed9b562..b4fe8d0 100644
--- a/sys/vm/vm_pager.c
+++ b/sys/vm/vm_pager.c
@@ -250,8 +250,78 @@ vm_pager_deallocate(object)
(*pagertab[object->type]->pgo_dealloc) (object);
}
+static void
+vm_pager_assert_in(vm_object_t object, vm_page_t *m, int count)
+{
+#ifdef INVARIANTS
+
+ VM_OBJECT_ASSERT_WLOCKED(object);
+ KASSERT(count > 0, ("%s: 0 count", __func__));
+ /*
+ * All pages must be busied, not mapped, not fully valid,
+ * not dirty and belong to the proper object.
+ */
+ for (int i = 0 ; i < count; i++) {
+ vm_page_assert_xbusied(m[i]);
+ KASSERT(!pmap_page_is_mapped(m[i]),
+ ("%s: page %p is mapped", __func__, m[i]));
+ KASSERT(m[i]->valid != VM_PAGE_BITS_ALL,
+ ("%s: request for a valid page %p", __func__, m[i]));
+ KASSERT(m[i]->dirty == 0,
+ ("%s: page %p is dirty", __func__, m[i]));
+ KASSERT(m[i]->object == object,
+ ("%s: wrong object %p/%p", __func__, object, m[i]->object));
+ }
+#endif
+}
+
+/*
+ * Page in the pages for the object using its associated pager.
+ * The requested page must be fully valid on successful return.
+ */
+int
+vm_pager_get_pages(vm_object_t object, vm_page_t *m, int count, int reqpage)
+{
+ int r;
+
+ vm_pager_assert_in(object, m, count);
+
+ r = (*pagertab[object->type]->pgo_getpages)(object, m, count, reqpage);
+ if (r != VM_PAGER_OK)
+ return (r);
+
+ /*
+ * If pager has replaced the page, assert that it had
+ * updated the array. Also assert that page is still
+ * busied.
+ */
+ KASSERT(m[reqpage] == vm_page_lookup(object, m[reqpage]->pindex),
+ ("%s: mismatch page %p pindex %ju", __func__,
+ m[reqpage], (uintmax_t )m[reqpage]->pindex));
+ vm_page_assert_xbusied(m[reqpage]);
+
+ /*
+ * Pager didn't fill up entire page. Zero out
+ * partially filled data.
+ */
+ if (m[reqpage]->valid != VM_PAGE_BITS_ALL)
+ vm_page_zero_invalid(m[reqpage], TRUE);
+
+ return (VM_PAGER_OK);
+}
+
+int
+vm_pager_get_pages_async(vm_object_t object, vm_page_t *m, int count,
+ int reqpage, pgo_getpages_iodone_t iodone, void *arg)
+{
+
+ vm_pager_assert_in(object, m, count);
+
+ return ((*pagertab[object->type]->pgo_getpages_async)(object, m,
+ count, reqpage, iodone, arg));
+}
+
/*
- * vm_pager_get_pages() - inline, see vm/vm_pager.h
* vm_pager_put_pages() - inline, see vm/vm_pager.h
* vm_pager_has_page() - inline, see vm/vm_pager.h
*/
diff --git a/sys/vm/vm_pager.h b/sys/vm/vm_pager.h
index 3accc69..6884729 100644
--- a/sys/vm/vm_pager.h
+++ b/sys/vm/vm_pager.h
@@ -106,49 +106,15 @@ vm_object_t vm_pager_allocate(objtype_t, void *, vm_ooffset_t, vm_prot_t,
vm_ooffset_t, struct ucred *);
void vm_pager_bufferinit(void);
void vm_pager_deallocate(vm_object_t);
-static __inline int vm_pager_get_pages(vm_object_t, vm_page_t *, int, int);
-static inline int vm_pager_get_pages_async(vm_object_t, vm_page_t *, int,
- int, pgo_getpages_iodone_t, void *);
+int vm_pager_get_pages(vm_object_t, vm_page_t *, int, int);
+int vm_pager_get_pages_async(vm_object_t, vm_page_t *, int, int,
+ pgo_getpages_iodone_t, void *);
static __inline boolean_t vm_pager_has_page(vm_object_t, vm_pindex_t, int *, int *);
void vm_pager_init(void);
vm_object_t vm_pager_object_lookup(struct pagerlst *, void *);
void vm_pager_free_nonreq(vm_object_t object, vm_page_t ma[], int reqpage,
int npages, boolean_t object_locked);
-/*
- * vm_page_get_pages:
- *
- * Retrieve pages from the VM system in order to map them into an object
- * ( or into VM space somewhere ). If the pagein was successful, we
- * must fully validate it.
- */
-static __inline int
-vm_pager_get_pages(
- vm_object_t object,
- vm_page_t *m,
- int count,
- int reqpage
-) {
- int r;
-
- VM_OBJECT_ASSERT_WLOCKED(object);
- r = (*pagertab[object->type]->pgo_getpages)(object, m, count, reqpage);
- if (r == VM_PAGER_OK && m[reqpage]->valid != VM_PAGE_BITS_ALL) {
- vm_page_zero_invalid(m[reqpage], TRUE);
- }
- return (r);
-}
-
-static inline int
-vm_pager_get_pages_async(vm_object_t object, vm_page_t *m, int count,
- int reqpage, pgo_getpages_iodone_t iodone, void *arg)
-{
-
- VM_OBJECT_ASSERT_WLOCKED(object);
- return ((*pagertab[object->type]->pgo_getpages_async)(object, m,
- count, reqpage, iodone, arg));
-}
-
static __inline void
vm_pager_put_pages(
vm_object_t object,
diff --git a/sys/x86/acpica/acpi_wakeup.c b/sys/x86/acpica/acpi_wakeup.c
index 0eb6823..bc1c55c 100644
--- a/sys/x86/acpica/acpi_wakeup.c
+++ b/sys/x86/acpica/acpi_wakeup.c
@@ -210,7 +210,7 @@ acpi_sleep_machdep(struct acpi_softc *sc, int state)
if (acpi_resume_beep != 0)
timer_spkr_acquire();
- AcpiSetFirmwareWakingVector(WAKECODE_PADDR(sc));
+ AcpiSetFirmwareWakingVector(WAKECODE_PADDR(sc), 0);
intr_suspend();
@@ -298,7 +298,7 @@ acpi_wakeup_machdep(struct acpi_softc *sc, int state, int sleep_result,
#endif
intr_resume(/*suspend_cancelled*/false);
- AcpiSetFirmwareWakingVector(0);
+ AcpiSetFirmwareWakingVector(0, 0);
} else {
/* Wakeup MD procedures in interrupt enabled context */
if (sleep_result == 1 && mem_range_softc.mr_op != NULL &&
diff --git a/targets/pseudo/clang/Makefile.depend b/targets/pseudo/clang/Makefile.depend
index ae94010..4dbc0af 100644
--- a/targets/pseudo/clang/Makefile.depend
+++ b/targets/pseudo/clang/Makefile.depend
@@ -2,6 +2,10 @@
# This file is not autogenerated - take care!
+.if !defined(MK_LLDB)
+.include <src.opts.mk>
+.endif
+
DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
DIRDEPS = \
@@ -11,5 +15,9 @@ DIRDEPS = \
usr.bin/clang/clang-tblgen \
usr.bin/clang/tblgen \
+.if ${MK_LLDB} == "yes"
+DIRDEPS+= \
+ usr.bin/clang/lldb
+.endif
.include <dirdeps.mk>
diff --git a/targets/pseudo/toolchain/Makefile.depend b/targets/pseudo/toolchain/Makefile.depend
index 92d1c88..e2e0202 100644
--- a/targets/pseudo/toolchain/Makefile.depend
+++ b/targets/pseudo/toolchain/Makefile.depend
@@ -31,7 +31,7 @@ DIRDEPS+= \
.endif
-DIRDEPS= \
+DIRDEPS+= \
usr.bin/xinstall \
gnu/usr.bin/binutils/ar \
gnu/usr.bin/binutils/as \
diff --git a/targets/pseudo/userland/gnu/Makefile.depend b/targets/pseudo/userland/gnu/Makefile.depend
index a95692b..fb5f711 100644
--- a/targets/pseudo/userland/gnu/Makefile.depend
+++ b/targets/pseudo/userland/gnu/Makefile.depend
@@ -16,7 +16,6 @@ DIRDEPS = \
gnu/lib/libssp/libssp_nonshared \
gnu/lib/libstdc++ \
gnu/lib/libsupc++ \
- gnu/usr.bin/binutils/addr2line \
gnu/usr.bin/binutils/ar \
gnu/usr.bin/binutils/as \
gnu/usr.bin/binutils/doc \
@@ -25,14 +24,9 @@ DIRDEPS = \
gnu/usr.bin/binutils/libbinutils \
gnu/usr.bin/binutils/libiberty \
gnu/usr.bin/binutils/libopcodes \
- gnu/usr.bin/binutils/nm \
gnu/usr.bin/binutils/objcopy \
gnu/usr.bin/binutils/objdump \
gnu/usr.bin/binutils/ranlib \
- gnu/usr.bin/binutils/readelf \
- gnu/usr.bin/binutils/size \
- gnu/usr.bin/binutils/strings \
- gnu/usr.bin/binutils/strip \
gnu/usr.bin/dialog \
gnu/usr.bin/diff/doc \
gnu/usr.bin/diff3 \
diff --git a/tools/build/mk/OptionalObsoleteFiles.inc b/tools/build/mk/OptionalObsoleteFiles.inc
index ae415a9..fbbb32d 100644
--- a/tools/build/mk/OptionalObsoleteFiles.inc
+++ b/tools/build/mk/OptionalObsoleteFiles.inc
@@ -5102,9 +5102,7 @@ OLD_FILES+=usr/share/misc/mail.tildehelp
.if ${MK_MAILWRAPPER} == no
OLD_FILES+=etc/mail/mailer.conf
-.if ${MK_SENDMAIL} == no
OLD_FILES+=usr/sbin/mailwrapper
-.endif
OLD_FILES+=usr/share/man/man8/mailwrapper.8.gz
.endif
@@ -6335,9 +6333,7 @@ OLD_FILES+=etc/periodic/daily/150.clean-hoststat
OLD_FILES+=etc/periodic/daily/440.status-mailq
OLD_FILES+=etc/periodic/daily/460.status-mail-rejects
OLD_FILES+=etc/periodic/daily/500.queuerun
-.if ${MK_MAILWRAPPER} == no
OLD_FILES+=bin/rmail
-.endif
OLD_FILES+=usr/bin/vacation
OLD_FILES+=usr/include/libmilter/mfapi.h
OLD_FILES+=usr/include/libmilter/mfdef.h
diff --git a/usr.bin/Makefile b/usr.bin/Makefile
index c77f89a..1187dc2 100644
--- a/usr.bin/Makefile
+++ b/usr.bin/Makefile
@@ -253,10 +253,6 @@ SUBDIR+= file
SUBDIR+= finger
.endif
-.if ${MK_FMAKE} != "no"
-SUBDIR+= make
-.endif
-
.if ${MK_FTP} != "no"
SUBDIR+= ftp
.endif
diff --git a/usr.bin/addr2line/Makefile.depend b/usr.bin/addr2line/Makefile.depend
new file mode 100644
index 0000000..20f498c
--- /dev/null
+++ b/usr.bin/addr2line/Makefile.depend
@@ -0,0 +1,21 @@
+# $FreeBSD$
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ gnu/lib/csu \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libcompiler_rt \
+ lib/libdwarf \
+ lib/libelf \
+ lib/libelftc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.bin/ar/Makefile.depend b/usr.bin/ar/Makefile.depend
index cb166c0..cabff68 100644
--- a/usr.bin/ar/Makefile.depend
+++ b/usr.bin/ar/Makefile.depend
@@ -3,6 +3,7 @@
DIRDEPS = \
gnu/lib/csu \
+ gnu/lib/libgcc \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.bin/bmake/Makefile.depend b/usr.bin/bmake/Makefile.depend
index 6cfaab1..3646e2e 100644
--- a/usr.bin/bmake/Makefile.depend
+++ b/usr.bin/bmake/Makefile.depend
@@ -3,6 +3,7 @@
DIRDEPS = \
gnu/lib/csu \
+ gnu/lib/libgcc \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.bin/calendar/calendars/calendar.freebsd b/usr.bin/calendar/calendars/calendar.freebsd
index 9ea3d81..41e8ea6 100644
--- a/usr.bin/calendar/calendars/calendar.freebsd
+++ b/usr.bin/calendar/calendars/calendar.freebsd
@@ -199,6 +199,7 @@
06/06 Alan Eldridge <alane@FreeBSD.org> died in Denver, Colorado, 2003
06/07 Jimmy Olgeni <olgeni@FreeBSD.org> born in Milano, Italy, 1976
06/07 Benjamin Close <benjsc@FreeBSD.org> born in Adelaide, Australia, 1978
+06/11 Alonso Cardenas Marquez <acm@FreeBSD.org> born in Arequipa, Peru, 1979
06/14 Josh Paetzel <jpaetzel@FreeBSD.org> born in Minneapolis, Minnesota, United States, 1973
06/17 Tilman Linneweh <arved@FreeBSD.org> born in Weinheim, Baden-Wuerttemberg, Germany, 1978
06/18 Li-Wen Hsu <lwhsu@FreeBSD.org> born in Taipei, Taiwan, Republic of China, 1984
diff --git a/usr.bin/clang/clang-tblgen/Makefile.depend b/usr.bin/clang/clang-tblgen/Makefile.depend
index e1ee91c..0e9e94c 100644
--- a/usr.bin/clang/clang-tblgen/Makefile.depend
+++ b/usr.bin/clang/clang-tblgen/Makefile.depend
@@ -3,6 +3,7 @@
DIRDEPS = \
gnu/lib/csu \
+ gnu/lib/libgcc \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.bin/clang/clang/Makefile.depend b/usr.bin/clang/clang/Makefile.depend
index 900b8c8..9d31380 100644
--- a/usr.bin/clang/clang/Makefile.depend
+++ b/usr.bin/clang/clang/Makefile.depend
@@ -1,10 +1,9 @@
# $FreeBSD$
# Autogenerated - do NOT edit!
-DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
-
DIRDEPS = \
gnu/lib/csu \
+ gnu/lib/libgcc \
include \
include/xlocale \
lib/${CSU_DIR} \
@@ -20,22 +19,19 @@ DIRDEPS = \
lib/clang/libclanglex \
lib/clang/libclangparse \
lib/clang/libclangrewrite \
- lib/clang/libllvmaarch64disassembler \
- lib/clang/libllvmaarch64codegen \
- lib/clang/libllvmaarch64asmparser \
- lib/clang/libllvmaarch64desc \
- lib/clang/libllvmaarch64info \
- lib/clang/libllvmaarch64instprinter \
- lib/clang/libllvmaarch64utils \
- lib/clang/libllvmpowerpcdisassembler \
- lib/clang/libllvmprofiledata \
- lib/clang/libclangrewritecore \
lib/clang/libclangrewritefrontend \
lib/clang/libclangsema \
lib/clang/libclangserialization \
lib/clang/libclangstaticanalyzercheckers \
lib/clang/libclangstaticanalyzercore \
lib/clang/libclangstaticanalyzerfrontend \
+ lib/clang/libllvmaarch64asmparser \
+ lib/clang/libllvmaarch64codegen \
+ lib/clang/libllvmaarch64desc \
+ lib/clang/libllvmaarch64disassembler \
+ lib/clang/libllvmaarch64info \
+ lib/clang/libllvmaarch64instprinter \
+ lib/clang/libllvmaarch64utils \
lib/clang/libllvmanalysis \
lib/clang/libllvmarmasmparser \
lib/clang/libllvmarmcodegen \
@@ -56,6 +52,7 @@ DIRDEPS = \
lib/clang/libllvmirreader \
lib/clang/libllvmlinker \
lib/clang/libllvmmc \
+ lib/clang/libllvmmcdisassembler \
lib/clang/libllvmmcparser \
lib/clang/libllvmmipsasmparser \
lib/clang/libllvmmipscodegen \
@@ -69,8 +66,10 @@ DIRDEPS = \
lib/clang/libllvmpowerpcasmparser \
lib/clang/libllvmpowerpccodegen \
lib/clang/libllvmpowerpcdesc \
+ lib/clang/libllvmpowerpcdisassembler \
lib/clang/libllvmpowerpcinfo \
lib/clang/libllvmpowerpcinstprinter \
+ lib/clang/libllvmprofiledata \
lib/clang/libllvmscalaropts \
lib/clang/libllvmselectiondag \
lib/clang/libllvmsparcasmparser \
@@ -93,6 +92,7 @@ DIRDEPS = \
lib/libc \
lib/libc++ \
lib/libcompiler_rt \
+ lib/libz \
lib/msun \
lib/ncurses/ncursesw \
usr.bin/clang/clang-tblgen.host \
@@ -111,12 +111,10 @@ cc1_main.po: DiagnosticCommonKinds.inc.h
cc1_main.po: DiagnosticDriverKinds.inc.h
cc1_main.po: DiagnosticFrontendKinds.inc.h
cc1_main.po: Options.inc.h
-cc1as_main.o: CC1AsOptions.inc.h
cc1as_main.o: DiagnosticCommonKinds.inc.h
cc1as_main.o: DiagnosticDriverKinds.inc.h
cc1as_main.o: DiagnosticFrontendKinds.inc.h
cc1as_main.o: Options.inc.h
-cc1as_main.po: CC1AsOptions.inc.h
cc1as_main.po: DiagnosticCommonKinds.inc.h
cc1as_main.po: DiagnosticDriverKinds.inc.h
cc1as_main.po: DiagnosticFrontendKinds.inc.h
diff --git a/usr.bin/clang/lldb/Makefile.depend b/usr.bin/clang/lldb/Makefile.depend
new file mode 100644
index 0000000..17b44d8
--- /dev/null
+++ b/usr.bin/clang/lldb/Makefile.depend
@@ -0,0 +1,146 @@
+# $FreeBSD$
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ gnu/lib/csu \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/clang/libclanganalysis \
+ lib/clang/libclangast \
+ lib/clang/libclangbasic \
+ lib/clang/libclangcodegen \
+ lib/clang/libclangdriver \
+ lib/clang/libclangedit \
+ lib/clang/libclangfrontend \
+ lib/clang/libclanglex \
+ lib/clang/libclangparse \
+ lib/clang/libclangsema \
+ lib/clang/libclangserialization \
+ lib/clang/liblldb \
+ lib/clang/liblldbAPI \
+ lib/clang/liblldbBreakpoint \
+ lib/clang/liblldbCommands \
+ lib/clang/liblldbCore \
+ lib/clang/liblldbDataFormatters \
+ lib/clang/liblldbExpression \
+ lib/clang/liblldbHostCommon \
+ lib/clang/liblldbHostFreeBSD \
+ lib/clang/liblldbHostPOSIX \
+ lib/clang/liblldbInterpreter \
+ lib/clang/liblldbPluginABISysV_ppc \
+ lib/clang/liblldbPluginABISysV_ppc64 \
+ lib/clang/liblldbPluginABISysV_x86_64 \
+ lib/clang/liblldbPluginCXXItaniumABI \
+ lib/clang/liblldbPluginDisassemblerLLVM \
+ lib/clang/liblldbPluginDynamicLoaderPosixDYLD \
+ lib/clang/liblldbPluginDynamicLoaderStatic \
+ lib/clang/liblldbPluginInstructionARM \
+ lib/clang/liblldbPluginInstructionARM64 \
+ lib/clang/liblldbPluginInstrumentationRuntimeAddressSanitizer \
+ lib/clang/liblldbPluginJITLoaderGDB \
+ lib/clang/liblldbPluginMemoryHistoryASan \
+ lib/clang/liblldbPluginObjectContainerBSDArchive \
+ lib/clang/liblldbPluginObjectFileELF \
+ lib/clang/liblldbPluginObjectFileJIT \
+ lib/clang/liblldbPluginPlatformFreeBSD \
+ lib/clang/liblldbPluginPlatformGDB \
+ lib/clang/liblldbPluginProcessElfCore \
+ lib/clang/liblldbPluginProcessFreeBSD \
+ lib/clang/liblldbPluginProcessGDBRemote \
+ lib/clang/liblldbPluginProcessPOSIX \
+ lib/clang/liblldbPluginProcessUtility \
+ lib/clang/liblldbPluginSymbolFileDWARF \
+ lib/clang/liblldbPluginSymbolFileSymtab \
+ lib/clang/liblldbPluginSymbolVendorELF \
+ lib/clang/liblldbPluginUnwindAssemblyInstEmulation \
+ lib/clang/liblldbPluginUnwindAssemblyX86 \
+ lib/clang/liblldbSymbol \
+ lib/clang/liblldbTarget \
+ lib/clang/liblldbUtility \
+ lib/clang/libllvmaarch64asmparser \
+ lib/clang/libllvmaarch64codegen \
+ lib/clang/libllvmaarch64desc \
+ lib/clang/libllvmaarch64disassembler \
+ lib/clang/libllvmaarch64info \
+ lib/clang/libllvmaarch64instprinter \
+ lib/clang/libllvmaarch64utils \
+ lib/clang/libllvmanalysis \
+ lib/clang/libllvmarmasmparser \
+ lib/clang/libllvmarmcodegen \
+ lib/clang/libllvmarmdesc \
+ lib/clang/libllvmarmdisassembler \
+ lib/clang/libllvmarminfo \
+ lib/clang/libllvmarminstprinter \
+ lib/clang/libllvmasmparser \
+ lib/clang/libllvmasmprinter \
+ lib/clang/libllvmbitreader \
+ lib/clang/libllvmbitwriter \
+ lib/clang/libllvmcodegen \
+ lib/clang/libllvmcore \
+ lib/clang/libllvmexecutionengine \
+ lib/clang/libllvminstcombine \
+ lib/clang/libllvminstrumentation \
+ lib/clang/libllvmipa \
+ lib/clang/libllvmipo \
+ lib/clang/libllvmirreader \
+ lib/clang/libllvmlinker \
+ lib/clang/libllvmmc \
+ lib/clang/libllvmmcdisassembler \
+ lib/clang/libllvmmcjit \
+ lib/clang/libllvmmcparser \
+ lib/clang/libllvmmipsasmparser \
+ lib/clang/libllvmmipscodegen \
+ lib/clang/libllvmmipsdesc \
+ lib/clang/libllvmmipsdisassembler \
+ lib/clang/libllvmmipsinfo \
+ lib/clang/libllvmmipsinstprinter \
+ lib/clang/libllvmobjcarcopts \
+ lib/clang/libllvmobject \
+ lib/clang/libllvmoption \
+ lib/clang/libllvmpowerpcasmparser \
+ lib/clang/libllvmpowerpccodegen \
+ lib/clang/libllvmpowerpcdesc \
+ lib/clang/libllvmpowerpcdisassembler \
+ lib/clang/libllvmpowerpcinfo \
+ lib/clang/libllvmpowerpcinstprinter \
+ lib/clang/libllvmprofiledata \
+ lib/clang/libllvmruntimedyld \
+ lib/clang/libllvmscalaropts \
+ lib/clang/libllvmselectiondag \
+ lib/clang/libllvmsparcasmparser \
+ lib/clang/libllvmsparccodegen \
+ lib/clang/libllvmsparcdesc \
+ lib/clang/libllvmsparcdisassembler \
+ lib/clang/libllvmsparcinfo \
+ lib/clang/libllvmsparcinstprinter \
+ lib/clang/libllvmsupport \
+ lib/clang/libllvmtarget \
+ lib/clang/libllvmtransformutils \
+ lib/clang/libllvmvectorize \
+ lib/clang/libllvmx86asmparser \
+ lib/clang/libllvmx86codegen \
+ lib/clang/libllvmx86desc \
+ lib/clang/libllvmx86disassembler \
+ lib/clang/libllvmx86info \
+ lib/clang/libllvmx86instprinter \
+ lib/clang/libllvmx86utils \
+ lib/libc \
+ lib/libc++ \
+ lib/libcompiler_rt \
+ lib/libedit \
+ lib/libelf \
+ lib/libexecinfo \
+ lib/libthr \
+ lib/libz \
+ lib/msun \
+ lib/ncurses/ncursesw \
+ lib/ncurses/panel \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.bin/clang/tblgen/Makefile.depend b/usr.bin/clang/tblgen/Makefile.depend
index 4d35366..0e9e94c 100644
--- a/usr.bin/clang/tblgen/Makefile.depend
+++ b/usr.bin/clang/tblgen/Makefile.depend
@@ -1,10 +1,9 @@
# $FreeBSD$
# Autogenerated - do NOT edit!
-DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
-
DIRDEPS = \
gnu/lib/csu \
+ gnu/lib/libgcc \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.bin/colldef/Makefile.depend b/usr.bin/colldef/Makefile.depend
index dc467b2..3ca32c6 100644
--- a/usr.bin/colldef/Makefile.depend
+++ b/usr.bin/colldef/Makefile.depend
@@ -11,6 +11,7 @@ DIRDEPS = \
lib/libc \
lib/libcompiler_rt \
usr.bin/lex/lib \
+ usr.bin/yacc.host \
.include <dirdeps.mk>
diff --git a/usr.bin/ee/Makefile.depend b/usr.bin/ee/Makefile.depend
index 072cd05..59bc828 100644
--- a/usr.bin/ee/Makefile.depend
+++ b/usr.bin/ee/Makefile.depend
@@ -2,7 +2,6 @@
# Autogenerated - do NOT edit!
DIRDEPS = \
- bin/cat.host \
gnu/lib/csu \
gnu/lib/libgcc \
include \
diff --git a/usr.bin/elfcopy/Makefile.depend b/usr.bin/elfcopy/Makefile.depend
index 72ff635..7c3c6db 100644
--- a/usr.bin/elfcopy/Makefile.depend
+++ b/usr.bin/elfcopy/Makefile.depend
@@ -4,6 +4,8 @@
DIRDEPS = \
gnu/lib/csu \
gnu/lib/libgcc \
+ include \
+ include/xlocale \
lib/${CSU_DIR} \
lib/libarchive \
lib/libbz2 \
diff --git a/usr.bin/find/Makefile.depend b/usr.bin/find/Makefile.depend
index e907014..9de4374 100644
--- a/usr.bin/find/Makefile.depend
+++ b/usr.bin/find/Makefile.depend
@@ -9,6 +9,7 @@ DIRDEPS = \
lib/${CSU_DIR} \
lib/libc \
lib/libcompiler_rt \
+ usr.bin/yacc.host \
.include <dirdeps.mk>
diff --git a/usr.bin/getconf/Makefile.depend b/usr.bin/getconf/Makefile.depend
index c15e42c..cd02691 100644
--- a/usr.bin/getconf/Makefile.depend
+++ b/usr.bin/getconf/Makefile.depend
@@ -2,7 +2,6 @@
# Autogenerated - do NOT edit!
DIRDEPS = \
- bin/cat.host \
gnu/lib/csu \
gnu/lib/libgcc \
include \
diff --git a/usr.bin/grep/Makefile.depend b/usr.bin/grep/Makefile.depend
index 65b372e..ca0df56 100644
--- a/usr.bin/grep/Makefile.depend
+++ b/usr.bin/grep/Makefile.depend
@@ -2,7 +2,6 @@
# Autogenerated - do NOT edit!
DIRDEPS = \
- bin/cat.host \
gnu/lib/csu \
gnu/lib/libgcc \
gnu/lib/libregex \
diff --git a/usr.bin/kdump/Makefile.depend b/usr.bin/kdump/Makefile.depend
index a2afa1e..e0397fe 100644
--- a/usr.bin/kdump/Makefile.depend
+++ b/usr.bin/kdump/Makefile.depend
@@ -2,7 +2,6 @@
# Autogenerated - do NOT edit!
DIRDEPS = \
- bin/cat.host \
gnu/lib/csu \
gnu/lib/libgcc \
include \
@@ -23,8 +22,10 @@ DIRDEPS = \
ioctl.o: ioctl.c
ioctl.po: ioctl.c
kdump.o: kdump_subr.h
+kdump.o: linux32_syscalls.c
kdump.o: linux_syscalls.c
kdump.po: kdump_subr.h
+kdump.po: linux32_syscalls.c
kdump.po: linux_syscalls.c
kdump_subr.o: kdump_subr.c
kdump_subr.o: kdump_subr.h
diff --git a/usr.bin/less/Makefile.depend b/usr.bin/less/Makefile.depend
index 072cd05..59bc828 100644
--- a/usr.bin/less/Makefile.depend
+++ b/usr.bin/less/Makefile.depend
@@ -2,7 +2,6 @@
# Autogenerated - do NOT edit!
DIRDEPS = \
- bin/cat.host \
gnu/lib/csu \
gnu/lib/libgcc \
include \
diff --git a/usr.bin/lessecho/Makefile.depend b/usr.bin/lessecho/Makefile.depend
index 23b58e0..3646e2e 100644
--- a/usr.bin/lessecho/Makefile.depend
+++ b/usr.bin/lessecho/Makefile.depend
@@ -2,7 +2,6 @@
# Autogenerated - do NOT edit!
DIRDEPS = \
- bin/cat.host \
gnu/lib/csu \
gnu/lib/libgcc \
include \
diff --git a/usr.bin/lesskey/Makefile.depend b/usr.bin/lesskey/Makefile.depend
index 23b58e0..3646e2e 100644
--- a/usr.bin/lesskey/Makefile.depend
+++ b/usr.bin/lesskey/Makefile.depend
@@ -2,7 +2,6 @@
# Autogenerated - do NOT edit!
DIRDEPS = \
- bin/cat.host \
gnu/lib/csu \
gnu/lib/libgcc \
include \
diff --git a/usr.bin/make/GNode.h b/usr.bin/make/GNode.h
deleted file mode 100644
index 05af1d0..0000000
--- a/usr.bin/make/GNode.h
+++ /dev/null
@@ -1,224 +0,0 @@
-/*-
- * Copyright (c) 1988, 1989, 1990, 1993
- * The Regents of the University of California. All rights reserved.
- * Copyright (c) 1989 by Berkeley Softworks
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Adam de Boor.
- *
- * 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.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
- *
- * $FreeBSD$
- */
-
-#ifndef GNode_h_39503bf2
-#define GNode_h_39503bf2
-
-#include "lst.h"
-#include "util.h"
-
-struct Suff;
-
-/*
- * The structure for an individual graph node. Each node has several
- * pieces of data associated with it.
- */
-typedef struct GNode {
- char *name; /* The target's name */
- char *path; /* The full pathname of the target file */
-
- /*
- * The type of operator used to define the sources (qv. parse.c)
- *
- * The OP_ constants are used when parsing a dependency line as a way of
- * communicating to other parts of the program the way in which a target
- * should be made. These constants are bitwise-OR'ed together and
- * placed in the 'type' field of each node. Any node that has
- * a 'type' field which satisfies the OP_NOP function was never never on
- * the lefthand side of an operator, though it may have been on the
- * righthand side...
- */
- int type;
-#define OP_DEPENDS 0x00000001 /* Execution of commands depends on
- * kids (:) */
-#define OP_FORCE 0x00000002 /* Always execute commands (!) */
-#define OP_DOUBLEDEP 0x00000004 /* Execution of commands depends on
- * kids per line (::) */
-#define OP_OPMASK (OP_DEPENDS|OP_FORCE|OP_DOUBLEDEP)
-
-#define OP_OPTIONAL 0x00000008 /* Don't care if the target doesn't
- * exist and can't be created */
-#define OP_USE 0x00000010 /*
- * Use associated commands for
- * parents
- */
-#define OP_EXEC 0x00000020 /* Target is never out of date, but
- * always execute commands anyway.
- * Its time doesn't matter, so it has
- * none...sort of
- */
-#define OP_IGNORE 0x00000040 /*
- * Ignore errors when creating the node
- */
-#define OP_PRECIOUS 0x00000080 /* Don't remove the target when
- * interrupted */
-#define OP_SILENT 0x00000100 /* Don't echo commands when executed */
-#define OP_MAKE 0x00000200 /*
- * Target is a recurrsive make so its
- * commands should always be executed
- * when it is out of date, regardless
- * of the state of the -n or -t flags
- */
-#define OP_JOIN 0x00000400 /* Target is out-of-date only if any of
- * its children was out-of-date */
-#define OP_INVISIBLE 0x00004000 /* The node is invisible to its parents.
- * I.e. it doesn't show up in the
- * parents's local variables. */
-#define OP_NOTMAIN 0x00008000 /* The node is exempt from normal 'main
- * target' processing in parse.c */
-#define OP_PHONY 0x00010000 /* Not a file target; run always */
-/* Attributes applied by PMake */
-#define OP_TRANSFORM 0x80000000 /* The node is a transformation rule */
-#define OP_MEMBER 0x40000000 /* Target is a member of an archive */
-#define OP_LIB 0x20000000 /* Target is a library */
-#define OP_ARCHV 0x10000000 /* Target is an archive construct */
-#define OP_HAS_COMMANDS 0x08000000 /* Target has all the commands it
- * should. Used when parsing to catch
- * multiple commands for a target */
-#define OP_SAVE_CMDS 0x04000000 /* Saving commands on .END (Compat) */
-#define OP_DEPS_FOUND 0x02000000 /* Already processed by Suff_FindDeps */
-
-/*
- * OP_NOP will return TRUE if the node with the given type was not the
- * object of a dependency operator
- */
-#define OP_NOP(t) (((t) & OP_OPMASK) == 0x00000000)
-
- int order; /* Its wait weight */
-
- Boolean make; /* TRUE if this target needs to be remade */
-
- /* Set to reflect the state of processing on this node */
- enum {
- UNMADE, /* Not examined yet */
-
- /*
- * Target is already being made. Indicates a cycle in the graph.
- * (compat mode only)
- */
- BEINGMADE,
-
- MADE, /* Was out-of-date and has been made */
- UPTODATE, /* Was already up-to-date */
-
- /*
- * An error occurred while it was being
- * made (used only in compat mode)
- */
- ERROR,
-
- /*
- * The target was aborted due to an
- * error making an inferior (compat).
- */
- ABORTED,
-
- /*
- * Marked as potentially being part of a graph cycle. If we
- * come back to a node marked this way, it is printed and
- * 'made' is changed to ENDCYCLE.
- */
- CYCLE,
-
- /*
- * The cycle has been completely printed. Go back and
- * unmark all its members.
- */
- ENDCYCLE
- } made;
-
- /* TRUE if one of this target's children was made */
- Boolean childMade;
-
- int unmade; /* The number of unmade children */
- int mtime; /* Its modification time */
- int cmtime; /* Modification time of its youngest child */
- struct GNode *cmtime_gn;/* Youngest child */
-
- /*
- * Links to parents for which this is an implied source, if any. (nodes
- * that depend on this, as gleaned from the transformation rules.
- */
- Lst iParents;
-
- /* List of nodes of the same name created by the :: operator */
- Lst cohorts;
-
- /* Lst of nodes for which this is a source (that depend on this one) */
- Lst parents;
-
- /* List of nodes on which this depends */
- Lst children;
-
- /*
- * List of nodes that must be made (if they're made) after this node is,
- * but that do not depend on this node, in the normal sense.
- */
- Lst successors;
-
- /*
- * List of nodes that must be made (if they're made) before this node
- * can be, but that do no enter into the datedness of this node.
- */
- Lst preds;
-
- /*
- * List of ``local'' variables that are specific to this target
- * and this target only (qv. var.c [$@ $< $?, etc.])
- */
- Lst context;
-
- /*
- * List of strings that are commands to be given to a shell
- * to create this target.
- */
- Lst commands;
-
- /* current command executing in compat mode */
- LstNode *compat_command;
-
- /*
- * Suffix for the node (determined by Suff_FindDeps and opaque to
- * everyone but the Suff module)
- */
- struct Suff *suffix;
-} GNode;
-
-#endif /* GNode_h_39503bf2 */
diff --git a/usr.bin/make/Makefile b/usr.bin/make/Makefile
deleted file mode 100644
index 1d366a5..0000000
--- a/usr.bin/make/Makefile
+++ /dev/null
@@ -1,120 +0,0 @@
-# @(#)Makefile 5.2 (Berkeley) 12/28/90
-# $Id: Makefile,v 1.6 1994/06/30 05:33:39 cgd Exp $
-# $FreeBSD$
-
-.include <src.opts.mk>
-
-PROG= make
-CFLAGS+=-I${.CURDIR}
-SRCS= arch.c buf.c cond.c dir.c for.c hash.c hash_tables.c job.c \
- lst.c main.c make.c parse.c proc.c shell.c str.c suff.c targ.c \
- util.c var.c
-
-.if !defined(MK_SHARED_TOOLCHAIN) || ${MK_SHARED_TOOLCHAIN} == "no"
-NO_SHARED?= YES
-.endif
-
-# Version has the RYYYYMMDDX format, where R is from RELENG_<R>
-CFLAGS+=-DMAKE_VERSION=\"10201205300\"
-
-# There is no obvious performance improvement currently.
-# CFLAGS+=-DUSE_KQUEUE
-
-# Make object files which depend on preprocessor symbols defined in
-# the Makefile which are not compilation options but rather configuration
-# options dependend on the Makefile. main.c needs MAKE_VERSION while
-# shell.c uses DEFSHELLNAME. This will cause recompilation in the case
-# the definition is changed in the makefile. It will of course not cause
-# recompilation if one does 'make MAKE_SHELL=csh'.
-main.o shell.o: ${MAKEFILE}
-
-# Directive and keyword tables. We use hash tables. These hash tables have been
-# generated with mph (ports/devel/mph)
-# If you change the directives or keywords (adding, deleting, reordering) you
-# need to create new tables and hash functions (directive_hash, keyword_hash).
-#
-# The following changes have been made to the generated code:
-#
-# o prefix the names of the g, T0 and T1 arrays with 'directive_'
-# resp. 'keyword_'.
-#
-# o make the type of the tables 'const [un]signed char' (if you change
-# anything make sure that the numbers fit into a char).
-#
-# o make the hash function use the length for termination,
-# not the trailing '\0', via the -l flag in emitc and some editing
-# (only for directive_hash).
-
-LOCALBASE ?= /usr/local
-MPH ?= ${LOCALBASE}/bin/mph
-EMITC ?= ${LOCALBASE}/bin/emitc
-
-.PRECIOUS: hash
-
-hash:
- ( echo '/*' ; \
- echo ' * DO NOT EDIT' ; \
- echo ' * $$''FreeBSD$$' ; \
- echo -n ' * auto-generated from ' ; \
- sed -nEe '/\$$FreeBSD/s/^.*\$$(.*)\$$.*$$/\1/p' \
- ${.CURDIR}/parse.c ; \
- echo ' * DO NOT EDIT' ; \
- echo ' */' ; \
- echo '#include <sys/types.h>' ; \
- echo ; \
- echo '#include "hash_tables.h"' ; \
- echo ; \
- cat ${.CURDIR}/parse.c | sed \
- -e '1,/DIRECTIVES-START-TAG/d' \
- -e '/DIRECTIVES-END-TAG/,$$d' \
- -e 's/^[^"]*"\([^"]*\)".*$$/\1/' | \
- ${MPH} -d2 -m1 | ${EMITC} -l -s | \
- sed \
- -e 's/^static int g\[\]/static const signed char directive_g[]/' \
- -e 's/^static int T0\[\]/static const u_char directive_T0[]/' \
- -e 's/^static int T1\[\]/static const u_char directive_T1[]/' \
- -e '/^#define uchar unsigned char/d' \
- -e 's/uchar/u_char/g' \
- -e 's/^hash(/directive_hash(/' \
- -e 's/; \*kp;/; kp < key + len;/' \
- -e 's/int len)/size_t len)/' \
- -e 's/= T0\[/= directive_T0\[/' \
- -e 's/= T1\[/= directive_T1\[/' \
- -e 's/g\[f/directive_g[f/g' ; \
- cat ${.CURDIR}/parse.c | sed \
- -e '1,/KEYWORD-START-TAG/d' \
- -e '/KEYWORD-END-TAG/,$$d' \
- -e 's/^[^"]*"\([^"]*\)".*$$/\1/' | \
- ${MPH} -d2 -m1 | ${EMITC} -l -s | \
- sed \
- -e 's/^static int g\[\]/static const signed char keyword_g[]/' \
- -e 's/^static int T0\[\]/static const u_char keyword_T0[]/' \
- -e 's/^static int T1\[\]/static const u_char keyword_T1[]/' \
- -e '/^#define uchar unsigned char/d' \
- -e 's/uchar/u_char/g' \
- -e 's/^hash(/keyword_hash(/' \
- -e 's/int len)/size_t len)/' \
- -e 's/= T0\[/= keyword_T0\[/' \
- -e 's/= T1\[/= keyword_T1\[/' \
- -e 's/g\[f/keyword_g[f/g' \
- ) > ${.CURDIR}/hash_tables.c
-
-# Set the shell which make(1) uses. Bourne is the default, but a decent
-# Korn shell works fine, and much faster. Using the C shell for this
-# will almost certainly break everything, but it's Unix tradition to
-# allow you to shoot yourself in the foot if you want to :-)
-
-MAKE_SHELL?= sh
-.if ${MAKE_SHELL} == "csh" || ${MAKE_SHELL} == "sh" || ${MAKE_SHELL} == "ksh"
-CFLAGS+= -DDEFSHELLNAME=\"${MAKE_SHELL}\"
-.else
-.error "MAKE_SHELL must be set to one of \"csh\", \"sh\" or \"ksh\"."
-.endif
-
-# if we are here we don't want this called 'make'
-PROG= fmake
-CLEANFILES+= fmake.1
-fmake.1: make.1
- ${CP} ${.ALLSRC} ${.TARGET}
-
-.include <bsd.prog.mk>
diff --git a/usr.bin/make/Makefile.dist b/usr.bin/make/Makefile.dist
deleted file mode 100644
index 8823d74..0000000
--- a/usr.bin/make/Makefile.dist
+++ /dev/null
@@ -1,10 +0,0 @@
-# $FreeBSD$
-# a simple makefile to help builds on !FreeBSD systems
-pmake:
- @echo 'make started.'
- cc -D__dead2="" -D__unused="" -Darc4random=random -D__FBSDID="static const char *id=" -DDEFSHELLNAME=\"sh\" -I. -c *.c
- cc *.o -o pmake
- @echo 'make completed.'
-
-clean:
- @rm -f *.o pmake
diff --git a/usr.bin/make/arch.c b/usr.bin/make/arch.c
deleted file mode 100644
index e4f6b0d..0000000
--- a/usr.bin/make/arch.c
+++ /dev/null
@@ -1,1224 +0,0 @@
-/*-
- * Copyright (c) 1988, 1989, 1990, 1993
- * The Regents of the University of California. All rights reserved.
- * Copyright (c) 1989 by Berkeley Softworks
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Adam de Boor.
- *
- * 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.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
- *
- * @(#)arch.c 8.2 (Berkeley) 1/2/94
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-/*-
- * arch.c --
- * Functions to manipulate libraries, archives and their members.
- *
- * Once again, cacheing/hashing comes into play in the manipulation
- * of archives. The first time an archive is referenced, all of its members'
- * headers are read and hashed and the archive closed again. All hashed
- * archives are kept on a list which is searched each time an archive member
- * is referenced.
- *
- * The interface to this module is:
- * Arch_ParseArchive Given an archive specification, return a list
- * of GNode's, one for each member in the spec.
- * FALSE is returned if the specification is
- * invalid for some reason.
- *
- * Arch_Touch Alter the modification time of the archive
- * member described by the given node to be
- * the current time.
- *
- * Arch_TouchLib Update the modification time of the library
- * described by the given node. This is special
- * because it also updates the modification time
- * of the library's table of contents.
- *
- * Arch_MTime Find the modification time of a member of
- * an archive *in the archive*. The time is also
- * placed in the member's GNode. Returns the
- * modification time.
- *
- * Arch_MemTime Find the modification time of a member of
- * an archive. Called when the member doesn't
- * already exist. Looks in the archive for the
- * modification time. Returns the modification
- * time.
- *
- * Arch_FindLib Search for a library along a path. The
- * library name in the GNode should be in
- * -l<name> format.
- *
- * Arch_LibOODate Special function to decide if a library node
- * is out-of-date.
- *
- * Arch_Init Initialize this module.
- */
-
-#include <sys/param.h>
-#include <sys/queue.h>
-#include <sys/types.h>
-#include <ar.h>
-#include <ctype.h>
-#include <errno.h>
-#include <inttypes.h>
-#include <limits.h>
-#include <regex.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <utime.h>
-
-#include "arch.h"
-#include "buf.h"
-#include "config.h"
-#include "dir.h"
-#include "globals.h"
-#include "GNode.h"
-#include "hash.h"
-#include "make.h"
-#include "parse.h"
-#include "targ.h"
-#include "util.h"
-#include "var.h"
-
-typedef struct Arch {
- char *name; /* Name of archive */
-
- /*
- * All the members of the archive described
- * by <name, struct ar_hdr *> key/value pairs
- */
- Hash_Table members;
-
- TAILQ_ENTRY(Arch) link; /* link all cached archives */
-} Arch;
-
-/* Lst of archives we've already examined */
-static TAILQ_HEAD(, Arch) archives = TAILQ_HEAD_INITIALIZER(archives);
-
-
-/* size of the name field in the archive member header */
-#define AR_NAMSIZ sizeof(((struct ar_hdr *)0)->ar_name)
-
-/*
- * This structure is used while reading/writing an archive
- */
-struct arfile {
- FILE *fp; /* archive file */
- char *fname; /* name of the file */
- struct ar_hdr hdr; /* current header */
- char sname[AR_NAMSIZ + 1]; /* short name */
- char *member; /* (long) member name */
- size_t mlen; /* size of the above */
- char *nametab; /* name table */
- size_t nametablen; /* size of the table */
- int64_t time; /* from ar_date */
- uint64_t size; /* from ar_size */
- off_t pos; /* header pos of current entry */
-};
-
-/*
- * Name of the symbol table. The original BSD used "__.SYMDEF". Rumours go
- * that this name may have a slash appended sometimes. Actually FreeBSD
- * uses "/" which probably came from SVR4.
- */
-#define SVR4_RANLIBMAG "/"
-#define BSD_RANLIBMAG "__.SYMDEF"
-
-/*
- * Name of the filename table. The 4.4BSD ar format did not use this, but
- * puts long filenames directly between the member header and the object
- * file.
- */
-#define SVR4_NAMEMAG "//"
-#define BSD_NAMEMAG "ARFILENAMES/"
-
-/*
- * 44BSD long filename key. Use a local define here instead of relying
- * on ar.h because we want this to continue working even when the
- * definition is removed from ar.h.
- */
-#define BSD_EXT1 "#1/"
-#define BSD_EXT1LEN 3
-
-/* if this is TRUE make archive errors fatal */
-Boolean arch_fatal = TRUE;
-
-/**
- * ArchError
- * An error happened while handling an archive. BSDmake traditionally
- * ignored these errors. Now this is dependent on the global arch_fatal
- * which, if true, makes these errors fatal and, if false, just emits an
- * error message.
- */
-#define ArchError(ARGS) do { \
- if (arch_fatal) \
- Fatal ARGS; \
- else \
- Error ARGS; \
- } while (0)
-
-/*-
- *-----------------------------------------------------------------------
- * Arch_ParseArchive --
- * Parse the archive specification in the given line and find/create
- * the nodes for the specified archive members, placing their nodes
- * on the given list, given the pointer to the start of the
- * specification, a Lst on which to place the nodes, and a context
- * in which to expand variables.
- *
- * Results:
- * TRUE if it was a valid specification. The linePtr is updated
- * to point to the first non-space after the archive spec. The
- * nodes for the members are placed on the given list.
- *
- * Side Effects:
- * Some nodes may be created. The given list is extended.
- *
- *-----------------------------------------------------------------------
- */
-Boolean
-Arch_ParseArchive(char **linePtr, Lst *nodeLst, GNode *ctxt)
-{
- char *cp; /* Pointer into line */
- GNode *gn; /* New node */
- char *libName; /* Library-part of specification */
- char *memName; /* Member-part of specification */
- char *nameBuf; /* temporary place for node name */
- char saveChar; /* Ending delimiter of member-name */
- Boolean subLibName; /* TRUE if libName should have/had
- * variable substitution performed on it */
-
- libName = *linePtr;
-
- subLibName = FALSE;
-
- for (cp = libName; *cp != '(' && *cp != '\0'; cp++) {
- if (*cp == '$') {
- /*
- * Variable spec, so call the Var module to parse the
- * puppy so we can safely advance beyond it...
- */
- size_t length = 0;
- Boolean freeIt;
- char *result;
-
- result = Var_Parse(cp, ctxt, TRUE, &length, &freeIt);
- if (result == var_Error) {
- return (FALSE);
- }
- subLibName = TRUE;
-
- if (freeIt) {
- free(result);
- }
- cp += length - 1;
- }
- }
-
- *cp++ = '\0';
- if (subLibName) {
- libName = Buf_Peel(Var_Subst(libName, ctxt, TRUE));
- }
-
- for (;;) {
- /*
- * First skip to the start of the member's name, mark that
- * place and skip to the end of it (either white-space or
- * a close paren).
- */
-
- /*
- * TRUE if need to substitute in memName
- */
- Boolean doSubst = FALSE;
-
- while (*cp != '\0' && *cp != ')' &&
- isspace((unsigned char)*cp)) {
- cp++;
- }
-
- memName = cp;
- while (*cp != '\0' && *cp != ')' &&
- !isspace((unsigned char)*cp)) {
- if (*cp == '$') {
- /*
- * Variable spec, so call the Var module to
- * parse the puppy so we can safely advance
- * beyond it...
- */
- size_t length = 0;
- Boolean freeIt;
- char *result;
-
- result = Var_Parse(cp, ctxt, TRUE,
- &length, &freeIt);
- if (result == var_Error) {
- return (FALSE);
- }
- doSubst = TRUE;
-
- if (freeIt) {
- free(result);
- }
- cp += length;
- } else {
- cp++;
- }
- }
-
- /*
- * If the specification ends without a closing parenthesis,
- * chances are there's something wrong (like a missing
- * backslash), so it's better to return failure than allow
- * such things to happen
- */
- if (*cp == '\0') {
- printf("No closing parenthesis in archive "
- "specification\n");
- return (FALSE);
- }
-
- /*
- * If we didn't move anywhere, we must be done
- */
- if (cp == memName) {
- break;
- }
-
- saveChar = *cp;
- *cp = '\0';
-
- /*
- * XXX: This should be taken care of intelligently by
- * SuffExpandChildren, both for the archive and the member
- * portions.
- */
- /*
- * If member contains variables, try and substitute for them.
- * This will slow down archive specs with dynamic sources, of
- * course, since we'll be (non-)substituting them three times,
- * but them's the breaks -- we need to do this since
- * SuffExpandChildren calls us, otherwise we could assume the
- * thing would be taken care of later.
- */
- if (doSubst) {
- char *buf;
- char *sacrifice;
- char *oldMemName = memName;
- size_t sz;
- Buffer *buf1;
-
- /*
- * Now form an archive spec and recurse to deal with
- * nested variables and multi-word variable values....
- * The results are just placed at the end of the
- * nodeLst we're returning.
- */
- buf1 = Var_Subst(memName, ctxt, TRUE);
- memName = Buf_Data(buf1);
-
- sz = strlen(memName) + strlen(libName) + 3;
- buf = emalloc(sz);
-
- snprintf(buf, sz, "%s(%s)", libName, memName);
-
- sacrifice = buf;
-
- if (strchr(memName, '$') &&
- strcmp(memName, oldMemName) == 0) {
- /*
- * Must contain dynamic sources, so we can't
- * deal with it now.
- * Just create an ARCHV node for the thing and
- * let SuffExpandChildren handle it...
- */
- gn = Targ_FindNode(buf, TARG_CREATE);
-
- if (gn == NULL) {
- free(buf);
- Buf_Destroy(buf1, FALSE);
- return (FALSE);
- }
- gn->type |= OP_ARCHV;
- Lst_AtEnd(nodeLst, (void *)gn);
- } else if (!Arch_ParseArchive(&sacrifice, nodeLst,
- ctxt)) {
- /*
- * Error in nested call -- free buffer and
- * return FALSE ourselves.
- */
- free(buf);
- Buf_Destroy(buf1, FALSE);
- return (FALSE);
- }
-
- /* Free buffer and continue with our work. */
- free(buf);
- Buf_Destroy(buf1, FALSE);
-
- } else if (Dir_HasWildcards(memName)) {
- Lst members = Lst_Initializer(members);
- char *member;
- size_t sz = MAXPATHLEN;
- size_t nsz;
-
- nameBuf = emalloc(sz);
-
- Path_Expand(memName, &dirSearchPath, &members);
- while (!Lst_IsEmpty(&members)) {
- member = Lst_DeQueue(&members);
- nsz = strlen(libName) + strlen(member) + 3;
- if (nsz > sz) {
- sz = nsz * 2;
- nameBuf = erealloc(nameBuf, sz);
- }
-
- snprintf(nameBuf, sz, "%s(%s)",
- libName, member);
- free(member);
- gn = Targ_FindNode(nameBuf, TARG_CREATE);
- if (gn == NULL) {
- free(nameBuf);
- /* XXXHB Lst_Destroy(&members) */
- return (FALSE);
- }
- /*
- * We've found the node, but have to make sure
- * the rest of the world knows it's an archive
- * member, without having to constantly check
- * for parentheses, so we type the thing with
- * the OP_ARCHV bit before we place it on the
- * end of the provided list.
- */
- gn->type |= OP_ARCHV;
- Lst_AtEnd(nodeLst, gn);
- }
- free(nameBuf);
- } else {
- size_t sz = strlen(libName) + strlen(memName) + 3;
-
- nameBuf = emalloc(sz);
- snprintf(nameBuf, sz, "%s(%s)", libName, memName);
- gn = Targ_FindNode(nameBuf, TARG_CREATE);
- free(nameBuf);
- if (gn == NULL) {
- return (FALSE);
- }
- /*
- * We've found the node, but have to make sure the
- * rest of the world knows it's an archive member,
- * without having to constantly check for parentheses,
- * so we type the thing with the OP_ARCHV bit before
- * we place it on the end of the provided list.
- */
- gn->type |= OP_ARCHV;
- Lst_AtEnd(nodeLst, gn);
- }
- if (doSubst) {
- free(memName);
- }
-
- *cp = saveChar;
- }
-
- /*
- * If substituted libName, free it now, since we need it no longer.
- */
- if (subLibName) {
- free(libName);
- }
-
- /*
- * We promised the pointer would be set up at the next non-space, so
- * we must advance cp there before setting *linePtr... (note that on
- * entrance to the loop, cp is guaranteed to point at a ')')
- */
- do {
- cp++;
- } while (*cp != '\0' && isspace((unsigned char)*cp));
-
- *linePtr = cp;
- return (TRUE);
-}
-
-/*
- * Close an archive file an free all resources
- */
-static void
-ArchArchiveClose(struct arfile *ar)
-{
-
- if (ar->nametab != NULL)
- free(ar->nametab);
- free(ar->member);
- if (ar->fp != NULL) {
- if (fclose(ar->fp) == EOF)
- ArchError(("%s: close error", ar->fname));
- }
- free(ar->fname);
- free(ar);
-}
-
-/*
- * Open an archive file.
- */
-static struct arfile *
-ArchArchiveOpen(const char *archive, const char *mode)
-{
- struct arfile *ar;
- char magic[SARMAG];
-
- ar = emalloc(sizeof(*ar));
- ar->fname = estrdup(archive);
- ar->mlen = 100;
- ar->member = emalloc(ar->mlen);
- ar->nametab = NULL;
- ar->nametablen = 0;
-
- if ((ar->fp = fopen(ar->fname, mode)) == NULL) {
- DEBUGM(ARCH, ("%s", ar->fname));
- ArchArchiveClose(ar);
- return (NULL);
- }
-
- /* read MAGIC */
- if (fread(magic, SARMAG, 1, ar->fp) != 1 ||
- strncmp(magic, ARMAG, SARMAG) != 0) {
- ArchError(("%s: bad archive magic\n", ar->fname));
- ArchArchiveClose(ar);
- return (NULL);
- }
-
- ar->pos = 0;
- return (ar);
-}
-
-/*
- * Read the next header from the archive. The return value will be +1 if
- * the header is read successfully, 0 on EOF and -1 if an error happened.
- * On a successful return sname contains the truncated member name and
- * member the full name. hdr contains the member header. For the symbol table
- * names of length 0 are returned. The entry for the file name table is never
- * returned.
- */
-static int
-ArchArchiveNext(struct arfile *ar)
-{
- char *end;
- int have_long_name;
- u_long offs;
- char *ptr;
- size_t ret;
- char buf[MAX(sizeof(ar->hdr.ar_size), sizeof(ar->hdr.ar_date)) + 1];
-
- next:
- /*
- * Seek to the next header.
- */
- if (ar->pos == 0) {
- ar->pos = SARMAG;
- } else {
- ar->pos += sizeof(ar->hdr) + ar->size;
- if (ar->size % 2 == 1)
- ar->pos++;
- }
-
- if (fseeko(ar->fp, ar->pos, SEEK_SET) == -1) {
- ArchError(("%s: cannot seek to %jd: %s", ar->fname,
- (intmax_t)ar->pos, strerror(errno)));
- return (-1);
- }
-
- /*
- * Read next member header
- */
- ret = fread(&ar->hdr, sizeof(ar->hdr), 1, ar->fp);
- if (ret != 1) {
- if (feof(ar->fp))
- return (0);
- ArchError(("%s: error reading member header: %s", ar->fname,
- strerror(errno)));
- return (-1);
- }
- if (strncmp(ar->hdr.ar_fmag, ARFMAG, sizeof(ar->hdr.ar_fmag)) != 0) {
- ArchError(("%s: bad entry magic", ar->fname));
- return (-1);
- }
-
- /*
- * looks like a member - get name by stripping trailing spaces
- * and NUL terminating.
- */
- strlcpy(ar->sname, ar->hdr.ar_name, AR_NAMSIZ + 1);
- for (ptr = ar->sname + AR_NAMSIZ; ptr > ar->sname; ptr--)
- if (ptr[-1] != ' ')
- break;
-
- *ptr = '\0';
-
- /*
- * Parse the size. All entries need to have a size. Be careful
- * to not allow buffer overruns.
- */
- strlcpy(buf, ar->hdr.ar_size, sizeof(ar->hdr.ar_size) + 1);
-
- errno = 0;
- ar->size = strtoumax(buf, &end, 10);
- if (errno != 0 || strspn(end, " ") != strlen(end)) {
- ArchError(("%s: bad size format in archive '%s'",
- ar->fname, buf));
- return (-1);
- }
-
- /*
- * Look for the extended name table. Do this before parsing
- * the date because this table doesn't need a date.
- */
- if (strcmp(ar->sname, BSD_NAMEMAG) == 0 ||
- strcmp(ar->sname, SVR4_NAMEMAG) == 0) {
- /* filename table - read it in */
- ar->nametablen = ar->size;
- ar->nametab = emalloc(ar->nametablen);
-
- ret = fread(ar->nametab, 1, ar->nametablen, ar->fp);
- if (ret != ar->nametablen) {
- if (ferror(ar->fp)) {
- ArchError(("%s: cannot read nametab: %s",
- ar->fname, strerror(errno)));
- } else {
- ArchError(("%s: cannot read nametab: "
- "short read", ar->fname, strerror(errno)));
- }
- return (-1);
- }
-
- /*
- * NUL terminate the entries. Entries are \n terminated
- * and may have a trailing / or \.
- */
- ptr = ar->nametab;
- while (ptr < ar->nametab + ar->nametablen) {
- if (*ptr == '\n') {
- if (ptr[-1] == '/' || ptr[-1] == '\\')
- ptr[-1] = '\0';
- *ptr = '\0';
- }
- ptr++;
- }
-
- /* get next archive entry */
- goto next;
- }
-
- /*
- * Now parse the modification date. Be careful to not overrun
- * buffers.
- */
- strlcpy(buf, ar->hdr.ar_date, sizeof(ar->hdr.ar_date) + 1);
-
- errno = 0;
- ar->time = (int64_t)strtoll(buf, &end, 10);
- if (errno != 0 || strspn(end, " ") != strlen(end)) {
- ArchError(("%s: bad date format in archive '%s'",
- ar->fname, buf));
- return (-1);
- }
-
- /*
- * Now check for the symbol table. This should really be the first
- * entry, but we don't check this.
- */
- if (strcmp(ar->sname, BSD_RANLIBMAG) == 0 ||
- strcmp(ar->sname, SVR4_RANLIBMAG) == 0) {
- /* symbol table - return a zero length name */
- ar->member[0] = '\0';
- ar->sname[0] = '\0';
- return (1);
- }
-
- have_long_name = 0;
-
- /*
- * Look whether this is a long name. There are several variants
- * of long names:
- * "#1/12 " - 12 length of following filename
- * "/17 " - index into name table
- * " 17 " - index into name table
- * Note that in the last case we must also check that there is no
- * slash in the name because of filenames with leading spaces:
- * " 777.o/ " - filename 777.o
- */
- if (ar->sname[0] == '/' || (ar->sname[0] == ' ' &&
- strchr(ar->sname, '/') == NULL)) {
- /* SVR4 extended name */
- errno = 0;
- offs = strtoul(ar->sname + 1, &end, 10);
- if (errno != 0 || *end != '\0' || offs >= ar->nametablen ||
- end == ar->sname + 1) {
- ArchError(("%s: bad extended name '%s'", ar->fname,
- ar->sname));
- return (-1);
- }
-
- /* fetch the name */
- if (ar->mlen <= strlen(ar->nametab + offs)) {
- ar->mlen = strlen(ar->nametab + offs) + 1;
- ar->member = erealloc(ar->member, ar->mlen);
- }
- strcpy(ar->member, ar->nametab + offs);
-
- have_long_name = 1;
-
- } else if (strncmp(ar->sname, BSD_EXT1, BSD_EXT1LEN) == 0 &&
- isdigit(ar->sname[BSD_EXT1LEN])) {
- /* BSD4.4 extended name */
- errno = 0;
- offs = strtoul(ar->sname + BSD_EXT1LEN, &end, 10);
- if (errno != 0 || *end != '\0' ||
- end == ar->sname + BSD_EXT1LEN) {
- ArchError(("%s: bad extended name '%s'", ar->fname,
- ar->sname));
- return (-1);
- }
-
- /* read it from the archive */
- if (ar->mlen <= offs) {
- ar->mlen = offs + 1;
- ar->member = erealloc(ar->member, ar->mlen);
- }
- ret = fread(ar->member, 1, offs, ar->fp);
- if (ret != offs) {
- if (ferror(ar->fp)) {
- ArchError(("%s: reading extended name: %s",
- ar->fname, strerror(errno)));
- } else {
- ArchError(("%s: reading extended name: "
- "short read", ar->fname));
- }
- return (-1);
- }
- ar->member[offs] = '\0';
-
- have_long_name = 1;
- }
-
- /*
- * Now remove the trailing slash that Svr4 puts at
- * the end of the member name to support trailing spaces in names.
- */
- if (ptr > ar->sname && ptr[-1] == '/')
- *--ptr = '\0';
-
- if (!have_long_name) {
- if (strlen(ar->sname) >= ar->mlen) {
- ar->mlen = strlen(ar->sname) + 1;
- ar->member = erealloc(ar->member, ar->mlen);
- }
- strcpy(ar->member, ar->sname);
- }
-
- return (1);
-}
-
-/*
- * Touch the current archive member by writing a new header with an
- * updated timestamp. The return value is 0 for success and -1 for errors.
- */
-static int
-ArchArchiveTouch(struct arfile *ar, int64_t ts)
-{
-
- /* seek to our header */
- if (fseeko(ar->fp, ar->pos, SEEK_SET) == -1) {
- ArchError(("%s: cannot seek to %jd: %s", ar->fname,
- (intmax_t)ar->pos, strerror(errno)));
- return (-1);
- }
-
- /*
- * change timestamp, be sure to not NUL-terminated it, but
- * to fill with spaces.
- */
- snprintf(ar->hdr.ar_date, sizeof(ar->hdr.ar_date), "%jd",
- (intmax_t)ts);
- memset(ar->hdr.ar_date + strlen(ar->hdr.ar_date),
- ' ', sizeof(ar->hdr.ar_date) - strlen(ar->hdr.ar_date));
-
- if (fwrite(&ar->hdr, sizeof(ar->hdr), 1, ar->fp) != 1) {
- ArchError(("%s: cannot touch: %s", ar->fname, strerror(errno)));
- return (-1);
- }
- return (0);
-}
-
-/*-
- *-----------------------------------------------------------------------
- * ArchFindMember --
- * Locate a member of an archive, given the path of the archive and
- * the path of the desired member. If the archive is to be modified,
- * the mode should be "r+", if not, it should be "r". The archive
- * file is returned positioned at the correct header.
- *
- * Results:
- * A struct arfile *, opened for reading and, possibly writing,
- * positioned at the member's header, or NULL if the member was
- * nonexistent.
- *
- *-----------------------------------------------------------------------
- */
-static struct arfile *
-ArchFindMember(const char *archive, const char *member, const char *mode)
-{
- struct arfile *ar;
- const char *cp; /* Useful character pointer */
-
- if ((ar = ArchArchiveOpen(archive, mode)) == NULL)
- return (NULL);
-
- /*
- * Because of space constraints and similar things, files are archived
- * using their final path components, not the entire thing, so we need
- * to point 'member' to the final component, if there is one, to make
- * the comparisons easier...
- */
- if (member != NULL) {
- cp = strrchr(member, '/');
- if (cp != NULL) {
- member = cp + 1;
- }
- }
-
- while (ArchArchiveNext(ar) > 0) {
- /*
- * When comparing there are actually three cases:
- * (1) the name fits into the limit og af_name,
- * (2) the name is longer and the archive supports long names,
- * (3) the name is longer and the archive doesn't support long
- * names.
- * Because we don't know whether the archive supports long
- * names or not we need to be careful.
- */
- if (member == NULL) {
- /* special case - symbol table */
- if (ar->member[0] == '\0')
- return (ar);
- } else if (strlen(member) <= AR_NAMSIZ) {
- /* case (1) */
- if (strcmp(ar->member, member) == 0)
- return (ar);
- } else if (strcmp(ar->member, member) == 0) {
- /* case (3) */
- return (ar);
- } else {
- /* case (2) */
- if (strlen(ar->member) == AR_NAMSIZ &&
- strncmp(member, ar->member, AR_NAMSIZ) == 0)
- return (ar);
- }
- }
-
- /* not found */
- ArchArchiveClose(ar);
- return (NULL);
-}
-
-/*-
- *-----------------------------------------------------------------------
- * ArchStatMember --
- * Locate a member of an archive, given the path of the archive and
- * the path of the desired member, and a boolean representing whether
- * or not the archive should be hashed (if not already hashed).
- *
- * Results:
- * A pointer to the current struct ar_hdr structure for the member. Note
- * That no position is returned, so this is not useful for touching
- * archive members. This is mostly because we have no assurances that
- * The archive will remain constant after we read all the headers, so
- * there's not much point in remembering the position...
- *
- * Side Effects:
- *
- *-----------------------------------------------------------------------
- */
-static int64_t
-ArchStatMember(const char *archive, const char *member, Boolean hash)
-{
- struct arfile *arf;
- int64_t ret;
- int t;
- char *cp; /* Useful character pointer */
- Arch *ar; /* Archive descriptor */
- Hash_Entry *he; /* Entry containing member's description */
- char copy[AR_NAMSIZ + 1];
-
- /*
- * Because of space constraints and similar things, files are archived
- * using their final path components, not the entire thing, so we need
- * to point 'member' to the final component, if there is one, to make
- * the comparisons easier...
- */
- if (member != NULL) {
- cp = strrchr(member, '/');
- if (cp != NULL)
- member = cp + 1;
- }
-
- TAILQ_FOREACH(ar, &archives, link) {
- if (strcmp(archive, ar->name) == 0)
- break;
- }
- if (ar == NULL) {
- /* archive not found */
- if (!hash) {
- /*
- * Caller doesn't want the thing hashed, just use
- * ArchFindMember to read the header for the member
- * out and close down the stream again.
- */
- arf = ArchFindMember(archive, member, "r");
- if (arf == NULL) {
- return (INT64_MIN);
- }
- ret = arf->time;
- ArchArchiveClose(arf);
- return (ret);
- }
-
- /*
- * We don't have this archive on the list yet, so we want to
- * find out everything that's in it and cache it so we can get
- * at it quickly.
- */
- arf = ArchArchiveOpen(archive, "r");
- if (arf == NULL) {
- return (INT64_MIN);
- }
-
- /* create archive data structure */
- ar = emalloc(sizeof(*ar));
- ar->name = estrdup(archive);
- Hash_InitTable(&ar->members, -1);
-
- while ((t = ArchArchiveNext(arf)) > 0) {
- he = Hash_CreateEntry(&ar->members, arf->member, NULL);
- Hash_SetValue(he, emalloc(sizeof(int64_t)));
- *(int64_t *)Hash_GetValue(he) = arf->time;
- }
-
- ArchArchiveClose(arf);
-
- if (t < 0) {
- /* error happened - throw away everything */
- Hash_DeleteTable(&ar->members);
- free(ar->name);
- free(ar);
- return (INT64_MIN);
- }
-
- TAILQ_INSERT_TAIL(&archives, ar, link);
- }
-
- /*
- * Now that the archive has been read and cached, we can look into
- * the hash table to find the desired member's header.
- */
- he = Hash_FindEntry(&ar->members, member);
- if (he != NULL)
- return (*(int64_t *)Hash_GetValue (he));
-
- if (member != NULL && strlen(member) > AR_NAMSIZ) {
- /* Try truncated name */
- strlcpy(copy, member, AR_NAMSIZ + 1);
-
- if ((he = Hash_FindEntry(&ar->members, copy)) != NULL)
- return (*(int64_t *)Hash_GetValue(he));
- }
-
- return (INT64_MIN);
-}
-
-/*-
- *-----------------------------------------------------------------------
- * Arch_Touch --
- * Touch a member of an archive.
- *
- * Results:
- * The 'time' field of the member's header is updated.
- *
- * Side Effects:
- * The modification time of the entire archive is also changed.
- * For a library, this could necessitate the re-ranlib'ing of the
- * whole thing.
- *
- *-----------------------------------------------------------------------
- */
-void
-Arch_Touch(GNode *gn)
-{
- struct arfile *ar;
-
- ar = ArchFindMember(Var_Value(ARCHIVE, gn),
- Var_Value(TARGET, gn), "r+");
-
- if (ar != NULL) {
- ArchArchiveTouch(ar, (int64_t)now);
- ArchArchiveClose(ar);
- }
-}
-
-/*-
- *-----------------------------------------------------------------------
- * Arch_TouchLib --
- * Given a node which represents a library, touch the thing, making
- * sure that the table of contents also is touched.
- *
- * Results:
- * None.
- *
- * Side Effects:
- * Both the modification time of the library and of the RANLIBMAG
- * member are set to 'now'.
- *
- *-----------------------------------------------------------------------
- */
-void
-Arch_TouchLib(GNode *gn)
-{
- struct arfile *ar; /* Open archive */
- struct utimbuf times; /* Times for utime() call */
-
- ar = ArchFindMember(gn->path, NULL, "r+");
- if (ar != NULL) {
- ArchArchiveTouch(ar, (int64_t)now);
- ArchArchiveClose(ar);
-
- times.actime = times.modtime = now;
- utime(gn->path, &times);
- }
-}
-
-/*-
- *-----------------------------------------------------------------------
- * Arch_MTime --
- * Return the modification time of a member of an archive, given its
- * name.
- *
- * Results:
- * The modification time(seconds).
- * XXXHB this should be a long.
- *
- * Side Effects:
- * The mtime field of the given node is filled in with the value
- * returned by the function.
- *
- *-----------------------------------------------------------------------
- */
-int
-Arch_MTime(GNode *gn)
-{
- int64_t mtime;
-
- mtime = ArchStatMember(Var_Value(ARCHIVE, gn),
- Var_Value(TARGET, gn), TRUE);
-
- if (mtime == INT_MIN) {
- mtime = 0;
- }
- gn->mtime = (int)mtime; /* XXX */
- return (gn->mtime);
-}
-
-/*-
- *-----------------------------------------------------------------------
- * Arch_MemMTime --
- * Given a non-existent archive member's node, get its modification
- * time from its archived form, if it exists.
- *
- * Results:
- * The modification time.
- *
- * Side Effects:
- * The mtime field is filled in.
- *
- *-----------------------------------------------------------------------
- */
-int
-Arch_MemMTime(GNode *gn)
-{
- LstNode *ln;
- GNode *pgn;
- char *nameStart;
- char *nameEnd;
-
- for (ln = Lst_First(&gn->parents); ln != NULL; ln = Lst_Succ(ln)) {
- pgn = Lst_Datum(ln);
-
- if (pgn->type & OP_ARCHV) {
- /*
- * If the parent is an archive specification and is
- * being made and its member's name matches the name of
- * the node we were given, record the modification time
- * of the parent in the child. We keep searching its
- * parents in case some other parent requires this
- * child to exist...
- */
- nameStart = strchr(pgn->name, '(') + 1;
- nameEnd = strchr(nameStart, ')');
-
- if (pgn->make && strncmp(nameStart, gn->name,
- nameEnd - nameStart) == 0) {
- gn->mtime = Arch_MTime(pgn);
- }
- } else if (pgn->make) {
- /*
- * Something which isn't a library depends on the
- * existence of this target, so it needs to exist.
- */
- gn->mtime = 0;
- break;
- }
- }
- return (gn->mtime);
-}
-
-/*-
- *-----------------------------------------------------------------------
- * Arch_FindLib --
- * Search for a named library along the given search path.
- *
- * Results:
- * None.
- *
- * Side Effects:
- * The node's 'path' field is set to the found path (including the
- * actual file name, not -l...). If the system can handle the -L
- * flag when linking (or we cannot find the library), we assume that
- * the user has placed the .LIBRARIES variable in the final linking
- * command (or the linker will know where to find it) and set the
- * TARGET variable for this node to be the node's name. Otherwise,
- * we set the TARGET variable to be the full path of the library,
- * as returned by Path_FindFile.
- *
- *-----------------------------------------------------------------------
- */
-void
-Arch_FindLib(GNode *gn, struct Path *path)
-{
- char *libName; /* file name for archive */
- size_t sz;
-
- sz = strlen(gn->name) + 4;
- libName = emalloc(sz);
- snprintf(libName, sz, "lib%s.a", &gn->name[2]);
-
- gn->path = Path_FindFile(libName, path);
-
- free(libName);
-
-#ifdef LIBRARIES
- Var_Set(TARGET, gn->name, gn);
-#else
- Var_Set(TARGET, gn->path == NULL ? gn->name : gn->path, gn);
-#endif /* LIBRARIES */
-}
-
-/*-
- *-----------------------------------------------------------------------
- * Arch_LibOODate --
- * Decide if a node with the OP_LIB attribute is out-of-date. Called
- * from Make_OODate to make its life easier, with the library's
- * graph node.
- *
- * There are several ways for a library to be out-of-date that are
- * not available to ordinary files. In addition, there are ways
- * that are open to regular files that are not available to
- * libraries. A library that is only used as a source is never
- * considered out-of-date by itself. This does not preclude the
- * library's modification time from making its parent be out-of-date.
- * A library will be considered out-of-date for any of these reasons,
- * given that it is a target on a dependency line somewhere:
- * Its modification time is less than that of one of its
- * sources (gn->mtime < gn->cmtime).
- * Its modification time is greater than the time at which the
- * make began (i.e. it's been modified in the course
- * of the make, probably by archiving).
- * The modification time of one of its sources is greater than
- * the one of its RANLIBMAG member (i.e. its table of contents
- * is out-of-date). We don't compare of the archive time
- * vs. TOC time because they can be too close. In my
- * opinion we should not bother with the TOC at all since
- * this is used by 'ar' rules that affect the data contents
- * of the archive, not by ranlib rules, which affect the
- * TOC.
- *
- * Results:
- * TRUE if the library is out-of-date. FALSE otherwise.
- *
- * Side Effects:
- * The library will be hashed if it hasn't been already.
- *
- *-----------------------------------------------------------------------
- */
-Boolean
-Arch_LibOODate(GNode *gn)
-{
- int64_t mtime; /* The table-of-contents's mod time */
-
- if (OP_NOP(gn->type) && Lst_IsEmpty(&gn->children)) {
- return (FALSE);
- }
- if (gn->mtime > now || gn->mtime < gn->cmtime) {
- return (TRUE);
- }
-
- mtime = ArchStatMember(gn->path, NULL, FALSE);
- if (mtime == INT64_MIN) {
- /*
- * Not found. A library w/o a table of contents is out-of-date
- */
- if (DEBUG(ARCH) || DEBUG(MAKE)) {
- Debug("No TOC...");
- }
- return (TRUE);
- }
-
- /* XXX choose one. */
- if (DEBUG(ARCH) || DEBUG(MAKE)) {
- Debug("TOC modified %s...", Targ_FmtTime(mtime));
- }
- return (gn->cmtime > mtime);
-}
diff --git a/usr.bin/make/arch.h b/usr.bin/make/arch.h
deleted file mode 100644
index 3c28b2f..0000000
--- a/usr.bin/make/arch.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*-
- * Copyright (c) 1988, 1989, 1990, 1993
- * The Regents of the University of California. All rights reserved.
- * Copyright (c) 1989 by Berkeley Softworks
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Adam de Boor.
- *
- * 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.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
- *
- * $FreeBSD$
- */
-
-#ifndef arch_h_488adf7a
-#define arch_h_488adf7a
-
-#include "util.h"
-
-struct GNode;
-struct Lst;
-struct Path;
-
-/* archive errors are fatal */
-extern Boolean arch_fatal;
-
-Boolean Arch_ParseArchive(char **, struct Lst *, struct GNode *);
-void Arch_Touch(struct GNode *);
-void Arch_TouchLib(struct GNode *);
-int Arch_MTime(struct GNode *);
-int Arch_MemMTime(struct GNode *);
-void Arch_FindLib(struct GNode *, struct Path *);
-Boolean Arch_LibOODate(struct GNode *);
-
-#endif /* arch_h_488adf7a */
diff --git a/usr.bin/make/buf.c b/usr.bin/make/buf.c
deleted file mode 100644
index fa866d3..0000000
--- a/usr.bin/make/buf.c
+++ /dev/null
@@ -1,291 +0,0 @@
-/*-
- * Copyright (c) 2005 Max Okumoto
- * Copyright (c) 1988, 1989, 1990, 1993
- * The Regents of the University of California. All rights reserved.
- * Copyright (c) 1988, 1989 by Adam de Boor
- * Copyright (c) 1989 by Berkeley Softworks
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Adam de Boor.
- *
- * 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.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
- *
- * @(#)buf.c 8.1 (Berkeley) 6/6/93
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-/*
- * buf.c
- * Functions for automatically-expanded buffers.
- */
-
-#include <string.h>
-#include <stdlib.h>
-
-#include "buf.h"
-#include "util.h"
-
-/**
- * Returns the number of bytes in the buffer. Doesn't include the
- * null-terminating byte.
- */
-size_t
-Buf_Size(const Buffer *buf)
-{
-
- return (buf->end - buf->buf);
-}
-
-/**
- * Returns a reference to the data contained in the buffer.
- *
- * @note Adding data to the Buffer object may invalidate the reference.
- */
-char *
-Buf_Data(const Buffer *bp)
-{
-
- return (bp->buf);
-}
-
-/**
- * Expand the buffer to hold the number of additional bytes, plus
- * space to store a terminating NULL byte.
- */
-static inline void
-BufExpand(Buffer *bp, size_t nb)
-{
- size_t len = Buf_Size(bp);
- size_t size;
-
- if (bp->size < len + nb + 1) {
- size = bp->size + MAX(nb + 1, BUF_ADD_INC);
- bp->size = size;
- bp->buf = erealloc(bp->buf, size);
- bp->end = bp->buf + len;
- }
-}
-
-/**
- * Add a single byte to the buffer.
- */
-void
-Buf_AddByte(Buffer *bp, Byte byte)
-{
-
- BufExpand(bp, 1);
-
- *bp->end = byte;
- bp->end++;
- *bp->end = '\0';
-}
-
-/**
- * Add bytes to the buffer.
- */
-void
-Buf_AddBytes(Buffer *bp, size_t len, const Byte *bytes)
-{
-
- BufExpand(bp, len);
-
- memcpy(bp->end, bytes, len);
- bp->end += len;
- *bp->end = '\0';
-}
-
-/**
- * Get a reference to the internal buffer.
- *
- * len:
- * Pointer to where we return the number of bytes in the internal buffer.
- *
- * Returns:
- * return A pointer to the data.
- */
-Byte *
-Buf_GetAll(Buffer *bp, size_t *len)
-{
-
- if (len != NULL)
- *len = Buf_Size(bp);
-
- return (bp->buf);
-}
-
-/**
- * Get the contents of a buffer and destroy the buffer. If the buffer
- * is NULL, return NULL.
- *
- * Returns:
- * the pointer to the data.
- */
-char *
-Buf_Peel(Buffer *bp)
-{
- char *ret;
-
- if (bp == NULL)
- return (NULL);
- ret = bp->buf;
- free(bp);
- return (ret);
-}
-
-/**
- * Initialize a buffer. If no initial size is given, a reasonable
- * default is used.
- *
- * Returns:
- * A buffer object to be given to other functions in this library.
- *
- * Side Effects:
- * Space is allocated for the Buffer object and a internal buffer.
- */
-Buffer *
-Buf_Init(size_t size)
-{
- Buffer *bp; /* New Buffer */
-
- if (size <= 0)
- size = BUF_DEF_SIZE;
-
- bp = emalloc(sizeof(*bp));
- bp->size = size;
- bp->buf = emalloc(size);
- bp->end = bp->buf;
- *bp->end = '\0';
-
- return (bp);
-}
-
-/**
- * Destroy a buffer, and optionally free its data, too.
- *
- * Side Effects:
- * Space for the Buffer object and possibly the internal buffer
- * is de-allocated.
- */
-void
-Buf_Destroy(Buffer *buf, Boolean freeData)
-{
-
- if (freeData)
- free(buf->buf);
- free(buf);
-}
-
-/**
- * Replace the last byte in a buffer. If the buffer was empty
- * initially, then a new byte will be added.
- */
-void
-Buf_ReplaceLastByte(Buffer *bp, Byte byte)
-{
-
- if (bp->end == bp->buf) {
- Buf_AddByte(bp, byte);
- } else {
- *(bp->end - 1) = byte;
- }
-}
-
-/**
- * Append characters in str to Buffer object
- */
-void
-Buf_Append(Buffer *bp, const char str[])
-{
-
- Buf_AddBytes(bp, strlen(str), str);
-}
-
-/**
- * Append characters in buf to Buffer object
- */
-void
-Buf_AppendBuf(Buffer *bp, const Buffer *buf)
-{
-
- Buf_AddBytes(bp, Buf_Size(buf), buf->buf);
-}
-
-/**
- * Append characters between str and end to Buffer object.
- */
-void
-Buf_AppendRange(Buffer *bp, const char str[], const char *end)
-{
-
- Buf_AddBytes(bp, end - str, str);
-}
-
-/**
- * Convert newlines in buffer to spaces. The trailing newline is
- * removed.
- */
-void
-Buf_StripNewlines(Buffer *bp)
-{
- char *ptr = bp->end;
-
- /*
- * If there is anything in the buffer, remove the last
- * newline character.
- */
- if (ptr != bp->buf) {
- if (*(ptr - 1) == '\n') {
- /* shorten buffer */
- *(ptr - 1) = '\0';
- --bp->end;
- }
- --ptr;
- }
-
- /* Convert newline characters to a space characters. */
- while (ptr != bp->buf) {
- if (*ptr == '\n') {
- *ptr = ' ';
- }
- --ptr;
- }
-}
-/**
- * Clear the contents of the buffer.
- */
-void
-Buf_Clear(Buffer *bp)
-{
-
- bp->end = bp->buf;
- *bp->end = '\0';
-}
diff --git a/usr.bin/make/buf.h b/usr.bin/make/buf.h
deleted file mode 100644
index 106f348..0000000
--- a/usr.bin/make/buf.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/*-
- * Copyright (c) 1988, 1989, 1990, 1993
- * The Regents of the University of California. All rights reserved.
- * Copyright (c) 1988, 1989 by Adam de Boor
- * Copyright (c) 1989 by Berkeley Softworks
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Adam de Boor.
- *
- * 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.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
- *
- * @(#)buf.h 8.2 (Berkeley) 4/28/95
- * $FreeBSD$
- */
-
-#ifndef buf_h_a61a6812
-#define buf_h_a61a6812
-
-/*-
- * buf.h --
- * Header for users of the buf library.
- */
-
-#include <sys/types.h>
-
-#include "util.h"
-
-/*
- * There are several places where expandable buffers are used (parse.c and
- * var.c). This constant is merely the starting point for those buffers. If
- * lines tend to be much shorter than this, it would be best to reduce BSIZE.
- * If longer, it should be increased. Reducing it will cause more copying to
- * be done for longer lines, but will save space for shorter ones. In any
- * case, it ought to be a power of two simply because most storage allocation
- * schemes allocate in powers of two.
- */
-#define MAKE_BSIZE 256 /* starting size for expandable buffers */
-
-#define BUF_DEF_SIZE 256 /* Default buffer size */
-#define BUF_ADD_INC 256 /* Expansion increment when Adding */
-
-typedef char Byte;
-
-typedef struct Buffer {
- size_t size; /* Current size of the buffer */
- Byte *buf; /* The buffer itself */
- Byte *end; /* Place to write to */
-} Buffer;
-
-void Buf_AddByte(Buffer *, Byte);
-void Buf_AddBytes(Buffer *, size_t, const Byte *);
-void Buf_Append(Buffer *, const char []);
-void Buf_AppendBuf(Buffer *, const Buffer *);
-void Buf_AppendRange(Buffer *, const char [], const char *);
-void Buf_Clear(Buffer *);
-char *Buf_Data(const Buffer *);
-void Buf_Destroy(Buffer *, Boolean);
-Byte *Buf_GetAll(Buffer *, size_t *);
-Buffer *Buf_Init(size_t);
-char *Buf_Peel(Buffer *);
-void Buf_ReplaceLastByte(Buffer *, Byte);
-size_t Buf_Size(const Buffer *);
-void Buf_StripNewlines(Buffer *);
-
-#endif /* buf_h_a61a6812 */
diff --git a/usr.bin/make/cond.c b/usr.bin/make/cond.c
deleted file mode 100644
index 6e7a094..0000000
--- a/usr.bin/make/cond.c
+++ /dev/null
@@ -1,1221 +0,0 @@
-/*-
- * Copyright (c) 1988, 1989, 1990, 1993
- * The Regents of the University of California. All rights reserved.
- * Copyright (c) 1988, 1989 by Adam de Boor
- * Copyright (c) 1989 by Berkeley Softworks
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Adam de Boor.
- *
- * 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.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
- *
- * @(#)cond.c 8.2 (Berkeley) 1/2/94
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-/*
- * Functions to handle conditionals in a makefile.
- *
- * Interface:
- * Cond_Eval Evaluate the conditional in the passed line.
- */
-
-#include <ctype.h>
-#include <string.h>
-#include <stdlib.h>
-
-#include "buf.h"
-#include "cond.h"
-#include "dir.h"
-#include "globals.h"
-#include "GNode.h"
-#include "make.h"
-#include "parse.h"
-#include "str.h"
-#include "targ.h"
-#include "util.h"
-#include "var.h"
-
-/*
- * The parsing of conditional expressions is based on this grammar:
- * E -> F || E
- * E -> F
- * F -> T && F
- * F -> T
- * T -> defined(variable)
- * T -> make(target)
- * T -> exists(file)
- * T -> empty(varspec)
- * T -> target(name)
- * T -> symbol
- * T -> $(varspec) op value
- * T -> $(varspec) == "string"
- * T -> $(varspec) != "string"
- * T -> ( E )
- * T -> ! T
- * op -> == | != | > | < | >= | <=
- *
- * 'symbol' is some other symbol to which the default function (condDefProc)
- * is applied.
- *
- * Tokens are scanned from the 'condExpr' string. The scanner (CondToken)
- * will return And for '&' and '&&', Or for '|' and '||', Not for '!',
- * LParen for '(', RParen for ')' and will evaluate the other terminal
- * symbols, using either the default function or the function given in the
- * terminal, and return the result as either True or False.
- *
- * All Non-Terminal functions (CondE, CondF and CondT) return Err on error.
- */
-typedef enum {
- And,
- Or,
- Not,
- True,
- False,
- LParen,
- RParen,
- EndOfFile,
- None,
- Err
-} Token;
-
-typedef Boolean CondProc(int, char *);
-
-/*-
- * Structures to handle elegantly the different forms of #if's. The
- * last two fields are stored in condInvert and condDefProc, respectively.
- */
-static void CondPushBack(Token);
-static int CondGetArg(char **, char **, const char *, Boolean);
-static CondProc CondDoDefined;
-static CondProc CondDoMake;
-static CondProc CondDoExists;
-static CondProc CondDoTarget;
-static char *CondCvtArg(char *, double *);
-static Token CondToken(Boolean);
-static Token CondT(Boolean);
-static Token CondF(Boolean);
-static Token CondE(Boolean);
-
-static const struct If {
- Boolean doNot; /* TRUE if default function should be negated */
- CondProc *defProc; /* Default function to apply */
- Boolean isElse; /* actually el<XXX> */
-} ifs[] = {
- [COND_IF] = { FALSE, CondDoDefined, FALSE },
- [COND_IFDEF] = { FALSE, CondDoDefined, FALSE },
- [COND_IFNDEF] = { TRUE, CondDoDefined, FALSE },
- [COND_IFMAKE] = { FALSE, CondDoMake, FALSE },
- [COND_IFNMAKE] = { TRUE, CondDoMake, FALSE },
- [COND_ELIF] = { FALSE, CondDoDefined, TRUE },
- [COND_ELIFDEF] = { FALSE, CondDoDefined, TRUE },
- [COND_ELIFNDEF] = { TRUE, CondDoDefined, TRUE },
- [COND_ELIFMAKE] = { FALSE, CondDoMake, TRUE },
- [COND_ELIFNMAKE] = { TRUE, CondDoMake, TRUE },
-};
-
-static Boolean condInvert; /* Invert the default function */
-static CondProc *condDefProc; /* default function to apply */
-static char *condExpr; /* The expression to parse */
-static Token condPushBack = None; /* Single push-back token in parsing */
-
-#define MAXIF 30 /* greatest depth of #if'ing */
-
-static Boolean condStack[MAXIF]; /* Stack of conditionals's values */
-static int condLineno[MAXIF]; /* Line numbers of the opening .if */
-static int condTop = MAXIF; /* Top-most conditional */
-static int skipIfLevel = 0; /* Depth of skipped conditionals */
-static int skipIfLineno[MAXIF]; /* Line numbers of skipped .ifs */
-Boolean skipLine = FALSE; /* Whether the parse module is skipping
- * lines */
-
-/**
- * CondPushBack
- * Push back the most recent token read. We only need one level of
- * this, so the thing is just stored in 'condPushback'.
- *
- * Side Effects:
- * condPushback is overwritten.
- */
-static void
-CondPushBack(Token t)
-{
-
- condPushBack = t;
-}
-
-/**
- * CondGetArg
- * Find the argument of a built-in function. parens is set to TRUE
- * if the arguments are bounded by parens.
- *
- * Results:
- * The length of the argument and the address of the argument.
- *
- * Side Effects:
- * The pointer is set to point to the closing parenthesis of the
- * function call.
- */
-static int
-CondGetArg(char **linePtr, char **argPtr, const char *func, Boolean parens)
-{
- char *cp;
- size_t argLen;
- Buffer *buf;
-
- cp = *linePtr;
- if (parens) {
- while (*cp != '(' && *cp != '\0') {
- cp++;
- }
- if (*cp == '(') {
- cp++;
- }
- }
-
- if (*cp == '\0') {
- /*
- * No arguments whatsoever. Because 'make' and 'defined'
- * aren't really "reserved words", we don't print a message.
- * I think this is better than hitting the user with a warning
- * message every time s/he uses the word 'make' or 'defined'
- * at the beginning of a symbol...
- */
- *argPtr = cp;
- return (0);
- }
-
- while (*cp == ' ' || *cp == '\t') {
- cp++;
- }
-
- /*
- * Create a buffer for the argument and start it out at 16 characters
- * long. Why 16? Why not?
- */
- buf = Buf_Init(16);
-
- while ((strchr(" \t)&|", *cp) == NULL) && (*cp != '\0')) {
- if (*cp == '$') {
- /*
- * Parse the variable spec and install it as part of
- * the argument if it's valid. We tell Var_Parse to
- * complain on an undefined variable, so we don't do
- * it too. Nor do we return an error, though perhaps
- * we should...
- */
- char *cp2;
- size_t len = 0;
- Boolean doFree;
-
- cp2 = Var_Parse(cp, VAR_CMD, TRUE, &len, &doFree);
-
- Buf_Append(buf, cp2);
- if (doFree) {
- free(cp2);
- }
- cp += len;
- } else {
- Buf_AddByte(buf, (Byte)*cp);
- cp++;
- }
- }
-
- Buf_AddByte(buf, (Byte)'\0');
- *argPtr = (char *)Buf_GetAll(buf, &argLen);
- Buf_Destroy(buf, FALSE);
-
- while (*cp == ' ' || *cp == '\t') {
- cp++;
- }
- if (parens && *cp != ')') {
- Parse_Error(PARSE_WARNING,
- "Missing closing parenthesis for %s()", func);
- return (0);
- } else if (parens) {
- /*
- * Advance pointer past close parenthesis.
- */
- cp++;
- }
-
- *linePtr = cp;
- return (argLen);
-}
-
-/**
- * CondDoDefined
- * Handle the 'defined' function for conditionals.
- *
- * Results:
- * TRUE if the given variable is defined.
- */
-static Boolean
-CondDoDefined(int argLen, char *arg)
-{
- char savec = arg[argLen];
- Boolean result;
-
- arg[argLen] = '\0';
- if (Var_Value(arg, VAR_CMD) != NULL) {
- result = TRUE;
- } else {
- result = FALSE;
- }
- arg[argLen] = savec;
- return (result);
-}
-
-/**
- * CondDoMake
- * Handle the 'make' function for conditionals.
- *
- * Results:
- * TRUE if the given target is being made.
- */
-static Boolean
-CondDoMake(int argLen, char *arg)
-{
- char savec = arg[argLen];
- Boolean result;
- const LstNode *ln;
-
- arg[argLen] = '\0';
- result = FALSE;
- LST_FOREACH(ln, &create) {
- if (Str_Match(Lst_Datum(ln), arg)) {
- result = TRUE;
- break;
- }
- }
- arg[argLen] = savec;
- return (result);
-}
-
-/**
- * CondDoExists
- * See if the given file exists.
- *
- * Results:
- * TRUE if the file exists and FALSE if it does not.
- */
-static Boolean
-CondDoExists(int argLen, char *arg)
-{
- char savec = arg[argLen];
- Boolean result;
- char *path;
-
- arg[argLen] = '\0';
- path = Path_FindFile(arg, &dirSearchPath);
- if (path != NULL) {
- result = TRUE;
- free(path);
- } else {
- result = FALSE;
- }
- arg[argLen] = savec;
- return (result);
-}
-
-/**
- * CondDoTarget
- * See if the given node exists and is an actual target.
- *
- * Results:
- * TRUE if the node exists as a target and FALSE if it does not.
- */
-static Boolean
-CondDoTarget(int argLen, char *arg)
-{
- char savec = arg[argLen];
- Boolean result;
- GNode *gn;
-
- arg[argLen] = '\0';
- gn = Targ_FindNode(arg, TARG_NOCREATE);
- if ((gn != NULL) && !OP_NOP(gn->type)) {
- result = TRUE;
- } else {
- result = FALSE;
- }
- arg[argLen] = savec;
- return (result);
-}
-
-/**
- * CondCvtArg
- * Convert the given number into a double. If the number begins
- * with 0x, it is interpreted as a hexadecimal integer
- * and converted to a double from there. All other strings just have
- * strtod called on them.
- *
- * Results:
- * Sets 'value' to double value of string.
- * Returns address of the first character after the last valid
- * character of the converted number.
- *
- * Side Effects:
- * Can change 'value' even if string is not a valid number.
- */
-static char *
-CondCvtArg(char *str, double *value)
-{
-
- if ((*str == '0') && (str[1] == 'x')) {
- long i;
-
- for (str += 2, i = 0; ; str++) {
- int x;
-
- if (isdigit((unsigned char)*str))
- x = *str - '0';
- else if (isxdigit((unsigned char)*str))
- x = 10 + *str -
- isupper((unsigned char)*str) ? 'A' : 'a';
- else {
- *value = (double)i;
- return (str);
- }
- i = (i << 4) + x;
- }
-
- } else {
- char *eptr;
-
- *value = strtod(str, &eptr);
- return (eptr);
- }
-}
-
-/**
- * CondToken
- * Return the next token from the input.
- *
- * Results:
- * A Token for the next lexical token in the stream.
- *
- * Side Effects:
- * condPushback will be set back to None if it is used.
- */
-static Token
-CondToken(Boolean doEval)
-{
- Token t;
-
- if (condPushBack != None) {
- t = condPushBack;
- condPushBack = None;
- return (t);
- }
-
- while (*condExpr == ' ' || *condExpr == '\t') {
- condExpr++;
- }
- switch (*condExpr) {
- case '(':
- t = LParen;
- condExpr++;
- break;
- case ')':
- t = RParen;
- condExpr++;
- break;
- case '|':
- if (condExpr[1] == '|') {
- condExpr++;
- }
- condExpr++;
- t = Or;
- break;
- case '&':
- if (condExpr[1] == '&') {
- condExpr++;
- }
- condExpr++;
- t = And;
- break;
- case '!':
- t = Not;
- condExpr++;
- break;
- case '\n':
- case '\0':
- t = EndOfFile;
- break;
- case '$': {
- char *lhs;
- const char *op;
- char *rhs;
- char zero[] = "0";
- size_t varSpecLen = 0;
- Boolean doFree;
-
- /*
- * Parse the variable spec and skip over it, saving its
- * value in lhs.
- */
- t = Err;
- lhs = Var_Parse(condExpr, VAR_CMD, doEval,
- &varSpecLen, &doFree);
- if (lhs == var_Error) {
- /*
- * Even if !doEval, we still report syntax
- * errors, which is what getting var_Error
- * back with !doEval means.
- */
- return (Err);
- }
- condExpr += varSpecLen;
-
- if (!isspace((unsigned char)*condExpr) &&
- strchr("!=><", *condExpr) == NULL) {
- Buffer *buf;
-
- buf = Buf_Init(0);
-
- Buf_Append(buf, lhs);
-
- if (doFree)
- free(lhs);
-
- for (;*condExpr &&
- !isspace((unsigned char)*condExpr);
- condExpr++)
- Buf_AddByte(buf, (Byte)*condExpr);
-
- Buf_AddByte(buf, (Byte)'\0');
- lhs = (char *)Buf_GetAll(buf, &varSpecLen);
- Buf_Destroy(buf, FALSE);
-
- doFree = TRUE;
- }
-
- /*
- * Skip whitespace to get to the operator
- */
- while (isspace((unsigned char)*condExpr))
- condExpr++;
-
- /*
- * Make sure the operator is a valid one. If it isn't a
- * known relational operator, pretend we got a
- * != 0 comparison.
- */
- op = condExpr;
- switch (*condExpr) {
- case '!':
- case '=':
- case '<':
- case '>':
- if (condExpr[1] == '=') {
- condExpr += 2;
- } else {
- condExpr += 1;
- }
- while (isspace((unsigned char)*condExpr)) {
- condExpr++;
- }
- if (*condExpr == '\0') {
- Parse_Error(PARSE_WARNING,
- "Missing right-hand-side of operator");
- goto error;
- }
- rhs = condExpr;
- break;
-
- default:
- op = "!=";
- rhs = zero;
- break;
- }
- if (*rhs == '"') {
- /*
- * Doing a string comparison. Only allow == and
- * != for * operators.
- */
- char *string;
- char *cp, *cp2;
- int qt;
- Buffer *buf;
-
- do_string_compare:
- if (((*op != '!') && (*op != '=')) ||
- (op[1] != '=')) {
- Parse_Error(PARSE_WARNING,
- "String comparison operator should "
- "be either == or !=");
- goto error;
- }
-
- buf = Buf_Init(0);
- qt = *rhs == '"' ? 1 : 0;
-
- for (cp = &rhs[qt];
- ((qt && (*cp != '"')) ||
- (!qt && strchr(" \t)", *cp) == NULL)) &&
- (*cp != '\0'); cp++) {
- if ((*cp == '\\') && (cp[1] != '\0')) {
- /*
- * Backslash escapes things --
- * skip over next character, * if it exists.
- */
- cp++;
- Buf_AddByte(buf, (Byte)*cp);
-
- } else if (*cp == '$') {
- size_t len = 0;
- Boolean freeIt;
-
- cp2 = Var_Parse(cp, VAR_CMD,
- doEval, &len, &freeIt);
- if (cp2 != var_Error) {
- Buf_Append(buf, cp2);
- if (freeIt) {
- free(cp2);
- }
- cp += len - 1;
- } else {
- Buf_AddByte(buf,
- (Byte)*cp);
- }
- } else {
- Buf_AddByte(buf, (Byte)*cp);
- }
- }
-
- string = Buf_Peel(buf);
-
- DEBUGF(COND, ("lhs = \"%s\", rhs = \"%s\", "
- "op = %.2s\n", lhs, string, op));
- /*
- * Null-terminate rhs and perform the
- * comparison. t is set to the result.
- */
- if (*op == '=') {
- t = strcmp(lhs, string) ? False : True;
- } else {
- t = strcmp(lhs, string) ? True : False;
- }
- free(string);
- if (rhs == condExpr) {
- if (*cp == '\0' || (!qt && *cp == ')'))
- condExpr = cp;
- else
- condExpr = cp + 1;
- }
- } else {
- /*
- * rhs is either a float or an integer.
- * Convert both the lhs and the rhs to a
- * double and compare the two.
- */
- double left, right;
- char *string;
-
- if (*CondCvtArg(lhs, &left) != '\0')
- goto do_string_compare;
- if (*rhs == '$') {
- size_t len = 0;
- Boolean freeIt;
-
- string = Var_Parse(rhs, VAR_CMD, doEval,
- &len, &freeIt);
- if (string == var_Error) {
- right = 0.0;
- } else {
- if (*CondCvtArg(string,
- &right) != '\0') {
- if (freeIt)
- free(string);
- goto do_string_compare;
- }
- if (freeIt)
- free(string);
- if (rhs == condExpr)
- condExpr += len;
- }
- } else {
- char *c = CondCvtArg(rhs, &right);
-
- if (c == rhs)
- goto do_string_compare;
- if (rhs == condExpr) {
- /*
- * Skip over the right-hand side
- */
- condExpr = c;
- }
- }
-
- DEBUGF(COND, ("left = %f, right = %f, "
- "op = %.2s\n", left, right, op));
- switch (op[0]) {
- case '!':
- if (op[1] != '=') {
- Parse_Error(PARSE_WARNING,
- "Unknown operator");
- goto error;
- }
- t = (left != right ? True : False);
- break;
- case '=':
- if (op[1] != '=') {
- Parse_Error(PARSE_WARNING,
- "Unknown operator");
- goto error;
- }
- t = (left == right ? True : False);
- break;
- case '<':
- if (op[1] == '=') {
- t = (left <= right?True:False);
- } else {
- t = (left < right?True:False);
- }
- break;
- case '>':
- if (op[1] == '=') {
- t = (left >= right?True:False);
- } else {
- t = (left > right?True:False);
- }
- break;
- default:
- break;
- }
- }
- error:
- if (doFree)
- free(lhs);
- break;
- }
-
- default: {
- CondProc *evalProc;
- Boolean invert = FALSE;
- char *arg;
- int arglen;
-
- if (strncmp(condExpr, "defined", 7) == 0) {
- /*
- * Use CondDoDefined to evaluate the argument
- * and CondGetArg to extract the argument from
- * the 'function call'.
- */
- evalProc = CondDoDefined;
- condExpr += 7;
- arglen = CondGetArg(&condExpr, &arg,
- "defined", TRUE);
- if (arglen == 0) {
- condExpr -= 7;
- goto use_default;
- }
-
- } else if (strncmp(condExpr, "make", 4) == 0) {
- /*
- * Use CondDoMake to evaluate the argument and
- * CondGetArg to extract the argument from the
- * 'function call'.
- */
- evalProc = CondDoMake;
- condExpr += 4;
- arglen = CondGetArg(&condExpr, &arg,
- "make", TRUE);
- if (arglen == 0) {
- condExpr -= 4;
- goto use_default;
- }
-
- } else if (strncmp(condExpr, "exists", 6) == 0) {
- /*
- * Use CondDoExists to evaluate the argument and
- * CondGetArg to extract the argument from the
- * 'function call'.
- */
- evalProc = CondDoExists;
- condExpr += 6;
- arglen = CondGetArg(&condExpr, &arg,
- "exists", TRUE);
- if (arglen == 0) {
- condExpr -= 6;
- goto use_default;
- }
-
- } else if (strncmp(condExpr, "empty", 5) == 0) {
- /*
- * Use Var_Parse to parse the spec in parens and
- * return True if the resulting string is empty.
- */
- size_t length;
- Boolean doFree;
- char *val;
-
- condExpr += 5;
-
- for (arglen = 0;
- condExpr[arglen] != '(' &&
- condExpr[arglen] != '\0'; arglen += 1)
- continue;
-
- if (condExpr[arglen] != '\0') {
- length = 0;
- val = Var_Parse(&condExpr[arglen - 1],
- VAR_CMD, FALSE, &length, &doFree);
- if (val == var_Error) {
- t = Err;
- } else {
- /*
- * A variable is empty when it
- * just contains spaces...
- * 4/15/92, christos
- */
- char *p;
-
- for (p = val;
- *p &&
- isspace((unsigned char)*p);
- p++)
- continue;
- t = (*p == '\0') ? True : False;
- }
- if (doFree) {
- free(val);
- }
- /*
- * Advance condExpr to beyond the
- * closing ). Note that we subtract
- * one from arglen + length b/c length
- * is calculated from
- * condExpr[arglen - 1].
- */
- condExpr += arglen + length - 1;
- } else {
- condExpr -= 5;
- goto use_default;
- }
- break;
-
- } else if (strncmp(condExpr, "target", 6) == 0) {
- /*
- * Use CondDoTarget to evaluate the argument and
- * CondGetArg to extract the argument from the
- * 'function call'.
- */
- evalProc = CondDoTarget;
- condExpr += 6;
- arglen = CondGetArg(&condExpr, &arg,
- "target", TRUE);
- if (arglen == 0) {
- condExpr -= 6;
- goto use_default;
- }
-
- } else {
- /*
- * The symbol is itself the argument to the
- * default function. We advance condExpr to
- * the end of the symbol by hand (the next
- * whitespace, closing paren or binary operator)
- * and set to invert the evaluation
- * function if condInvert is TRUE.
- */
- use_default:
- invert = condInvert;
- evalProc = condDefProc;
- arglen = CondGetArg(&condExpr, &arg, "", FALSE);
- }
-
- /*
- * Evaluate the argument using the set function. If
- * invert is TRUE, we invert the sense of the function.
- */
- t = (!doEval || (* evalProc) (arglen, arg) ?
- (invert ? False : True) :
- (invert ? True : False));
- free(arg);
- break;
- }
- }
- return (t);
-}
-
-/**
- * CondT
- * Parse a single term in the expression. This consists of a terminal
- * symbol or Not and a terminal symbol (not including the binary
- * operators):
- * T -> defined(variable) | make(target) | exists(file) | symbol
- * T -> ! T | ( E )
- *
- * Results:
- * True, False or Err.
- *
- * Side Effects:
- * Tokens are consumed.
- */
-static Token
-CondT(Boolean doEval)
-{
- Token t;
-
- t = CondToken(doEval);
- if (t == EndOfFile) {
- /*
- * If we reached the end of the expression, the expression
- * is malformed...
- */
- t = Err;
- } else if (t == LParen) {
- /*
- * T -> ( E )
- */
- t = CondE(doEval);
- if (t != Err) {
- if (CondToken(doEval) != RParen) {
- t = Err;
- }
- }
- } else if (t == Not) {
- t = CondT(doEval);
- if (t == True) {
- t = False;
- } else if (t == False) {
- t = True;
- }
- }
- return (t);
-}
-
-/**
- * CondF --
- * Parse a conjunctive factor (nice name, wot?)
- * F -> T && F | T
- *
- * Results:
- * True, False or Err
- *
- * Side Effects:
- * Tokens are consumed.
- */
-static Token
-CondF(Boolean doEval)
-{
- Token l, o;
-
- l = CondT(doEval);
- if (l != Err) {
- o = CondToken(doEval);
-
- if (o == And) {
- /*
- * F -> T && F
- *
- * If T is False, the whole thing will be False, but
- * we have to parse the r.h.s. anyway (to throw it
- * away). If T is True, the result is the r.h.s.,
- * be it an Err or no.
- */
- if (l == True) {
- l = CondF(doEval);
- } else {
- CondF(FALSE);
- }
- } else {
- /*
- * F -> T
- */
- CondPushBack(o);
- }
- }
- return (l);
-}
-
-/**
- * CondE --
- * Main expression production.
- * E -> F || E | F
- *
- * Results:
- * True, False or Err.
- *
- * Side Effects:
- * Tokens are, of course, consumed.
- */
-static Token
-CondE(Boolean doEval)
-{
- Token l, o;
-
- l = CondF(doEval);
- if (l != Err) {
- o = CondToken(doEval);
-
- if (o == Or) {
- /*
- * E -> F || E
- *
- * A similar thing occurs for ||, except that here we
- * make sure the l.h.s. is False before we bother to
- * evaluate the r.h.s. Once again, if l is False, the
- * result is the r.h.s. and once again if l is True,
- * we parse the r.h.s. to throw it away.
- */
- if (l == False) {
- l = CondE(doEval);
- } else {
- CondE(FALSE);
- }
- } else {
- /*
- * E -> F
- */
- CondPushBack(o);
- }
- }
- return (l);
-}
-
-/**
- * Cond_If
- * Handle .if<X> and .elif<X> directives.
- * This function is called even when we're skipping.
- */
-void
-Cond_If(char *line, int code, int lineno)
-{
- const struct If *ifp;
- Boolean value;
-
- ifp = &ifs[code];
-
- if (ifp->isElse) {
- if (condTop == MAXIF) {
- Parse_Error(PARSE_FATAL, "if-less elif");
- return;
- }
- if (skipIfLevel != 0) {
- /*
- * If skipping this conditional, just ignore
- * the whole thing. If we don't, the user
- * might be employing a variable that's
- * undefined, for which there's an enclosing
- * ifdef that we're skipping...
- */
- skipIfLineno[skipIfLevel - 1] = lineno;
- return;
- }
-
- } else if (skipLine) {
- /*
- * Don't even try to evaluate a conditional that's
- * not an else if we're skipping things...
- */
- skipIfLineno[skipIfLevel] = lineno;
- skipIfLevel += 1;
- return;
- }
-
- /*
- * Initialize file-global variables for parsing
- */
- condDefProc = ifp->defProc;
- condInvert = ifp->doNot;
-
- while (*line == ' ' || *line == '\t') {
- line++;
- }
-
- condExpr = line;
- condPushBack = None;
-
- switch (CondE(TRUE)) {
- case True:
- if (CondToken(TRUE) != EndOfFile)
- goto err;
- value = TRUE;
- break;
-
- case False:
- if (CondToken(TRUE) != EndOfFile)
- goto err;
- value = FALSE;
- break;
-
- case Err:
- err: Parse_Error(PARSE_FATAL, "Malformed conditional (%s)", line);
- return;
-
- default:
- abort();
- }
-
- if (!ifp->isElse) {
- /* push this value */
- condTop -= 1;
-
- } else if (skipIfLevel != 0 || condStack[condTop]) {
- /*
- * If this is an else-type conditional, it should only take
- * effect if its corresponding if was evaluated and FALSE.
- * If its if was TRUE or skipped, we return COND_SKIP (and
- * start skipping in case we weren't already), leaving the
- * stack unmolested so later elif's don't screw up...
- */
- skipLine = TRUE;
- return;
- }
-
- if (condTop < 0) {
- /*
- * This is the one case where we can definitely proclaim a fatal
- * error. If we don't, we're hosed.
- */
- Parse_Error(PARSE_FATAL, "Too many nested if's. %d max.",MAXIF);
- return;
- }
-
- /* push */
- condStack[condTop] = value;
- condLineno[condTop] = lineno;
- skipLine = !value;
-}
-
-/**
- * Cond_Else
- * Handle .else statement.
- */
-void
-Cond_Else(char *line __unused, int code __unused, int lineno __unused)
-{
-
- while (isspace((u_char)*line))
- line++;
-
- if (*line != '\0' && (warn_flags & WARN_DIRSYNTAX)) {
- Parse_Error(PARSE_WARNING, "junk after .else ignored '%s'",
- line);
- }
-
- if (condTop == MAXIF) {
- Parse_Error(PARSE_FATAL, "if-less else");
- return;
- }
- if (skipIfLevel != 0)
- return;
-
- if (skipIfLevel != 0 || condStack[condTop]) {
- /*
- * An else should only take effect if its corresponding if was
- * evaluated and FALSE.
- * If its if was TRUE or skipped, we return COND_SKIP (and
- * start skipping in case we weren't already), leaving the
- * stack unmolested so later elif's don't screw up...
- * XXX How does this work with two .else's?
- */
- skipLine = TRUE;
- return;
- }
-
- /* inverse value */
- condStack[condTop] = !condStack[condTop];
- skipLine = !condStack[condTop];
-}
-
-/**
- * Cond_Endif
- * Handle .endif statement.
- */
-void
-Cond_Endif(char *line __unused, int code __unused, int lineno __unused)
-{
-
- while (isspace((u_char)*line))
- line++;
-
- if (*line != '\0' && (warn_flags & WARN_DIRSYNTAX)) {
- Parse_Error(PARSE_WARNING, "junk after .endif ignored '%s'",
- line);
- }
-
- /*
- * End of a conditional section. If skipIfLevel is non-zero,
- * that conditional was skipped, so lines following it should
- * also be skipped. Hence, we return COND_SKIP. Otherwise,
- * the conditional was read so succeeding lines should be
- * parsed (think about it...) so we return COND_PARSE, unless
- * this endif isn't paired with a decent if.
- */
- if (skipIfLevel != 0) {
- skipIfLevel -= 1;
- return;
- }
-
- if (condTop == MAXIF) {
- Parse_Error(PARSE_FATAL, "if-less endif");
- return;
- }
-
- /* pop */
- skipLine = FALSE;
- condTop += 1;
-}
-
-/**
- * Cond_End
- * Make sure everything's clean at the end of a makefile.
- *
- * Side Effects:
- * Parse_Error will be called if open conditionals are around.
- */
-void
-Cond_End(void)
-{
- int level;
-
- if (condTop != MAXIF) {
- Parse_Error(PARSE_FATAL, "%d open conditional%s:",
- MAXIF - condTop + skipIfLevel,
- MAXIF - condTop + skipIfLevel== 1 ? "" : "s");
-
- for (level = skipIfLevel; level > 0; level--)
- Parse_Error(PARSE_FATAL, "\t%*sat line %d (skipped)",
- MAXIF - condTop + level + 1, "",
- skipIfLineno[level - 1]);
- for (level = condTop; level < MAXIF; level++)
- Parse_Error(PARSE_FATAL, "\t%*sat line %d "
- "(evaluated to %s)", MAXIF - level + skipIfLevel,
- "", condLineno[level],
- condStack[level] ? "true" : "false");
- }
- condTop = MAXIF;
-}
diff --git a/usr.bin/make/cond.h b/usr.bin/make/cond.h
deleted file mode 100644
index 9a8dbdc..0000000
--- a/usr.bin/make/cond.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/*-
- * Copyright (c) 1988, 1989, 1990, 1993
- * The Regents of the University of California. All rights reserved.
- * Copyright (c) 1989 by Berkeley Softworks
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Adam de Boor.
- *
- * 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.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
- *
- * $FreeBSD$
- */
-
-#ifndef cond_h_6e96ad7c
-#define cond_h_6e96ad7c
-
-/*
- * Values returned by Cond_Eval.
- */
-#define COND_PARSE 0 /* Parse the next lines */
-#define COND_SKIP 1 /* Skip the next lines */
-#define COND_INVALID 2 /* Not a conditional statement */
-
-enum {
- COND_IF,
- COND_IFDEF,
- COND_IFNDEF,
- COND_IFMAKE,
- COND_IFNMAKE,
- COND_ELSE,
- COND_ELIF,
- COND_ELIFDEF,
- COND_ELIFNDEF,
- COND_ELIFMAKE,
- COND_ELIFNMAKE,
- COND_ENDIF,
-};
-
-void Cond_If(char *, int, int);
-void Cond_Else(char *, int, int);
-void Cond_Endif(char *, int, int);
-void Cond_End(void);
-
-extern Boolean skipLine;
-
-#endif /* cond_h_6e96ad7c */
diff --git a/usr.bin/make/config.h b/usr.bin/make/config.h
deleted file mode 100644
index 06b0f8e..0000000
--- a/usr.bin/make/config.h
+++ /dev/null
@@ -1,111 +0,0 @@
-/*-
- * Copyright (c) 1988, 1989, 1990, 1993
- * The Regents of the University of California. All rights reserved.
- * Copyright (c) 1988, 1989 by Adam de Boor
- * Copyright (c) 1989 by Berkeley Softworks
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Adam de Boor.
- *
- * 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.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
- *
- * @(#)config.h 8.2 (Berkeley) 4/28/95
- * $FreeBSD$
- */
-
-#ifndef config_h_efe0765e
-#define config_h_efe0765e
-
-/*
- * DEFMAXJOBS
- * This control the default concurrency. On no occasion will more
- * than DEFMAXJOBS targets be created at once.
- */
-#define DEFMAXJOBS 1
-
-/*
- * INCLUDES
- * LIBRARIES
- * These control the handling of the .INCLUDES and .LIBS variables.
- * If INCLUDES is defined, the .INCLUDES variable will be filled
- * from the search paths of those suffixes which are marked by
- * .INCLUDES dependency lines. Similarly for LIBRARIES and .LIBS
- * See suff.c for more details.
- */
-#define INCLUDES
-#define LIBRARIES
-
-/*
- * LIBSUFF
- * Is the suffix used to denote libraries and is used by the Suff module
- * to find the search path on which to seek any -l<xx> targets.
- *
- * RECHECK
- * If defined, Make_Update will check a target for its current
- * modification time after it has been re-made, setting it to the
- * starting time of the make only if the target still doesn't exist.
- * Unfortunately, under NFS the modification time often doesn't
- * get updated in time, so a target will appear to not have been
- * re-made, causing later targets to appear up-to-date. On systems
- * that don't have this problem, you should defined this. Under
- * NFS you probably should not, unless you aren't exporting jobs.
- */
-#define LIBSUFF ".a"
-#define RECHECK
-
-/*
- * SYSVINCLUDE
- * Recognize system V like include directives [include "filename"]
- * SYSVVARSUB
- * Recognize system V like ${VAR:x=y} variable substitutions
- */
-#define SYSVINCLUDE
-#define SYSVVARSUB
-
-/*
- * SUNSHCMD
- * Recognize SunOS and Solaris:
- * VAR :sh= CMD # Assign VAR to the command substitution of CMD
- * ${VAR:sh} # Return the command substitution of the value
- * # of ${VAR}
- */
-#define SUNSHCMD
-
-#if !defined(__svr4__) && !defined(__SVR4) && !defined(__ELF__)
-# ifndef RANLIBMAG
-# define RANLIBMAG "__.SYMDEF"
-# endif
-#else
-# ifndef RANLIBMAG
-# define RANLIBMAG "/"
-# endif
-#endif
-
-#endif /* config_h_efe0765e */
diff --git a/usr.bin/make/dir.c b/usr.bin/make/dir.c
deleted file mode 100644
index 7cee3d4..0000000
--- a/usr.bin/make/dir.c
+++ /dev/null
@@ -1,1217 +0,0 @@
-/*-
- * Copyright (c) 1988, 1989, 1990, 1993
- * The Regents of the University of California. All rights reserved.
- * Copyright (c) 1988, 1989 by Adam de Boor
- * Copyright (c) 1989 by Berkeley Softworks
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Adam de Boor.
- *
- * 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.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
- *
- * @(#)dir.c 8.2 (Berkeley) 1/2/94
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-/*-
- * dir.c --
- * Directory searching using wildcards and/or normal names...
- * Used both for source wildcarding in the Makefile and for finding
- * implicit sources.
- *
- * The interface for this module is:
- * Dir_Init Initialize the module.
- *
- * Dir_HasWildcards Returns TRUE if the name given it needs to
- * be wildcard-expanded.
- *
- * Path_Expand Given a pattern and a path, return a Lst of names
- * which match the pattern on the search path.
- *
- * Path_FindFile Searches for a file on a given search path.
- * If it exists, the entire path is returned.
- * Otherwise NULL is returned.
- *
- * Dir_FindHereOrAbove Search for a path in the current directory and
- * then all the directories above it in turn until
- * the path is found or we reach the root ("/").
- *
- * Dir_MTime Return the modification time of a node. The file
- * is searched for along the default search path.
- * The path and mtime fields of the node are filled in.
- *
- * Path_AddDir Add a directory to a search path.
- *
- * Dir_MakeFlags Given a search path and a command flag, create
- * a string with each of the directories in the path
- * preceded by the command flag and all of them
- * separated by a space.
- *
- * Dir_Destroy Destroy an element of a search path. Frees up all
- * things that can be freed for the element as long
- * as the element is no longer referenced by any other
- * search path.
- *
- * Dir_ClearPath Resets a search path to the empty list.
- *
- * For debugging:
- * Dir_PrintDirectories Print stats about the directory cache.
- */
-
-#include <sys/param.h>
-#include <sys/stat.h>
-#include <dirent.h>
-#include <err.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "arch.h"
-#include "dir.h"
-#include "globals.h"
-#include "GNode.h"
-#include "hash.h"
-#include "lst.h"
-#include "str.h"
-#include "targ.h"
-#include "util.h"
-
-/*
- * A search path consists of a list of Dir structures. A Dir structure
- * has in it the name of the directory and a hash table of all the files
- * in the directory. This is used to cut down on the number of system
- * calls necessary to find implicit dependents and their like. Since
- * these searches are made before any actions are taken, we need not
- * worry about the directory changing due to creation commands. If this
- * hampers the style of some makefiles, they must be changed.
- *
- * A list of all previously-read directories is kept in the
- * openDirectories list. This list is checked first before a directory
- * is opened.
- *
- * The need for the caching of whole directories is brought about by
- * the multi-level transformation code in suff.c, which tends to search
- * for far more files than regular make does. In the initial
- * implementation, the amount of time spent performing "stat" calls was
- * truly astronomical. The problem with hashing at the start is,
- * of course, that pmake doesn't then detect changes to these directories
- * during the course of the make. Three possibilities suggest themselves:
- *
- * 1) just use stat to test for a file's existence. As mentioned
- * above, this is very inefficient due to the number of checks
- * engendered by the multi-level transformation code.
- * 2) use readdir() and company to search the directories, keeping
- * them open between checks. I have tried this and while it
- * didn't slow down the process too much, it could severely
- * affect the amount of parallelism available as each directory
- * open would take another file descriptor out of play for
- * handling I/O for another job. Given that it is only recently
- * that UNIX OS's have taken to allowing more than 20 or 32
- * file descriptors for a process, this doesn't seem acceptable
- * to me.
- * 3) record the mtime of the directory in the Dir structure and
- * verify the directory hasn't changed since the contents were
- * hashed. This will catch the creation or deletion of files,
- * but not the updating of files. However, since it is the
- * creation and deletion that is the problem, this could be
- * a good thing to do. Unfortunately, if the directory (say ".")
- * were fairly large and changed fairly frequently, the constant
- * rehashing could seriously degrade performance. It might be
- * good in such cases to keep track of the number of rehashes
- * and if the number goes over a (small) limit, resort to using
- * stat in its place.
- *
- * An additional thing to consider is that pmake is used primarily
- * to create C programs and until recently pcc-based compilers refused
- * to allow you to specify where the resulting object file should be
- * placed. This forced all objects to be created in the current
- * directory. This isn't meant as a full excuse, just an explanation of
- * some of the reasons for the caching used here.
- *
- * One more note: the location of a target's file is only performed
- * on the downward traversal of the graph and then only for terminal
- * nodes in the graph. This could be construed as wrong in some cases,
- * but prevents inadvertent modification of files when the "installed"
- * directory for a file is provided in the search path.
- *
- * Another data structure maintained by this module is an mtime
- * cache used when the searching of cached directories fails to find
- * a file. In the past, Path_FindFile would simply perform an access()
- * call in such a case to determine if the file could be found using
- * just the name given. When this hit, however, all that was gained
- * was the knowledge that the file existed. Given that an access() is
- * essentially a stat() without the copyout() call, and that the same
- * filesystem overhead would have to be incurred in Dir_MTime, it made
- * sense to replace the access() with a stat() and record the mtime
- * in a cache for when Dir_MTime was actually called.
- */
-
-typedef struct Dir {
- char *name; /* Name of directory */
- int refCount; /* No. of paths with this directory */
- int hits; /* No. of times a file has been found here */
- Hash_Table files; /* Hash table of files in directory */
- TAILQ_ENTRY(Dir) link; /* allDirs link */
-} Dir;
-
-/*
- * A path is a list of pointers to directories. These directories are
- * reference counted so a directory can be on more than one path.
- */
-struct PathElement {
- struct Dir *dir; /* pointer to the directory */
- TAILQ_ENTRY(PathElement) link; /* path link */
-};
-
-/* main search path */
-struct Path dirSearchPath = TAILQ_HEAD_INITIALIZER(dirSearchPath);
-
-/* the list of all open directories */
-static TAILQ_HEAD(, Dir) openDirectories =
- TAILQ_HEAD_INITIALIZER(openDirectories);
-
-/*
- * Variables for gathering statistics on the efficiency of the hashing
- * mechanism.
- */
-static int hits; /* Found in directory cache */
-static int misses; /* Sad, but not evil misses */
-static int nearmisses; /* Found under search path */
-static int bigmisses; /* Sought by itself */
-
-static Dir *dot; /* contents of current directory */
-
-/* Results of doing a last-resort stat in Path_FindFile --
- * if we have to go to the system to find the file, we might as well
- * have its mtime on record.
- * XXX: If this is done way early, there's a chance other rules will
- * have already updated the file, in which case we'll update it again.
- * Generally, there won't be two rules to update a single file, so this
- * should be ok, but...
- */
-static Hash_Table mtimes;
-
-/*-
- *-----------------------------------------------------------------------
- * Dir_Init --
- * initialize things for this module
- *
- * Results:
- * none
- *
- * Side Effects:
- * none
- *-----------------------------------------------------------------------
- */
-void
-Dir_Init(void)
-{
-
- Hash_InitTable(&mtimes, 0);
-}
-
-/*-
- *-----------------------------------------------------------------------
- * Dir_InitDot --
- * initialize the "." directory
- *
- * Results:
- * none
- *
- * Side Effects:
- * some directories may be opened.
- *-----------------------------------------------------------------------
- */
-void
-Dir_InitDot(void)
-{
-
- dot = Path_AddDir(NULL, ".");
- if (dot == NULL)
- err(1, "cannot open current directory");
-
- /*
- * We always need to have dot around, so we increment its
- * reference count to make sure it's not destroyed.
- */
- dot->refCount += 1;
-}
-
-/*-
- *-----------------------------------------------------------------------
- * Dir_HasWildcards --
- * See if the given name has any wildcard characters in it.
- *
- * Results:
- * returns TRUE if the word should be expanded, FALSE otherwise
- *
- * Side Effects:
- * none
- *-----------------------------------------------------------------------
- */
-Boolean
-Dir_HasWildcards(const char *name)
-{
- const char *cp;
- int wild = 0, brace = 0, bracket = 0;
-
- for (cp = name; *cp; cp++) {
- switch (*cp) {
- case '{':
- brace++;
- wild = 1;
- break;
- case '}':
- brace--;
- break;
- case '[':
- bracket++;
- wild = 1;
- break;
- case ']':
- bracket--;
- break;
- case '?':
- case '*':
- wild = 1;
- break;
- default:
- break;
- }
- }
- return (wild && bracket == 0 && brace == 0);
-}
-
-/*-
- *-----------------------------------------------------------------------
- * DirMatchFiles --
- * Given a pattern and a Dir structure, see if any files
- * match the pattern and add their names to the 'expansions' list if
- * any do. This is incomplete -- it doesn't take care of patterns like
- * src / *src / *.c properly (just *.c on any of the directories), but it
- * will do for now.
- *
- * Results:
- * Always returns 0
- *
- * Side Effects:
- * File names are added to the expansions lst. The directory will be
- * fully hashed when this is done.
- *-----------------------------------------------------------------------
- */
-static int
-DirMatchFiles(const char *pattern, const Dir *p, Lst *expansions)
-{
- Hash_Search search; /* Index into the directory's table */
- Hash_Entry *entry; /* Current entry in the table */
- Boolean isDot; /* TRUE if the directory being searched is . */
-
- isDot = (*p->name == '.' && p->name[1] == '\0');
-
- for (entry = Hash_EnumFirst(&p->files, &search);
- entry != NULL;
- entry = Hash_EnumNext(&search)) {
- /*
- * See if the file matches the given pattern. Note we follow
- * the UNIX convention that dot files will only be found if
- * the pattern begins with a dot (note also that as a side
- * effect of the hashing scheme, .* won't match . or ..
- * since they aren't hashed).
- */
- if (Str_Match(entry->name, pattern) &&
- ((entry->name[0] != '.') ||
- (pattern[0] == '.'))) {
- Lst_AtEnd(expansions, (isDot ? estrdup(entry->name) :
- str_concat(p->name, entry->name, STR_ADDSLASH)));
- }
- }
- return (0);
-}
-
-/*-
- *-----------------------------------------------------------------------
- * DirExpandCurly --
- * Expand curly braces like the C shell. Does this recursively.
- * Note the special case: if after the piece of the curly brace is
- * done there are no wildcard characters in the result, the result is
- * placed on the list WITHOUT CHECKING FOR ITS EXISTENCE. The
- * given arguments are the entire word to expand, the first curly
- * brace in the word, the search path, and the list to store the
- * expansions in.
- *
- * Results:
- * None.
- *
- * Side Effects:
- * The given list is filled with the expansions...
- *
- *-----------------------------------------------------------------------
- */
-static void
-DirExpandCurly(const char *word, const char *brace, struct Path *path,
- Lst *expansions)
-{
- const char *end; /* Character after the closing brace */
- const char *cp; /* Current position in brace clause */
- const char *start; /* Start of current piece of brace clause */
- int bracelevel; /* Number of braces we've seen. If we see a right brace
- * when this is 0, we've hit the end of the clause. */
- char *file; /* Current expansion */
- int otherLen; /* The length of the other pieces of the expansion
- * (chars before and after the clause in 'word') */
- char *cp2; /* Pointer for checking for wildcards in
- * expansion before calling Dir_Expand */
-
- start = brace + 1;
-
- /*
- * Find the end of the brace clause first, being wary of nested brace
- * clauses.
- */
- for (end = start, bracelevel = 0; *end != '\0'; end++) {
- if (*end == '{')
- bracelevel++;
- else if ((*end == '}') && (bracelevel-- == 0))
- break;
- }
- if (*end == '\0') {
- Error("Unterminated {} clause \"%s\"", start);
- return;
- } else
- end++;
-
- otherLen = brace - word + strlen(end);
-
- for (cp = start; cp < end; cp++) {
- /*
- * Find the end of this piece of the clause.
- */
- bracelevel = 0;
- while (*cp != ',') {
- if (*cp == '{')
- bracelevel++;
- else if ((*cp == '}') && (bracelevel-- <= 0))
- break;
- cp++;
- }
- /*
- * Allocate room for the combination and install the
- * three pieces.
- */
- file = emalloc(otherLen + cp - start + 1);
- if (brace != word)
- strncpy(file, word, brace - word);
- if (cp != start)
- strncpy(&file[brace - word], start, cp - start);
- strcpy(&file[(brace - word) + (cp - start)], end);
-
- /*
- * See if the result has any wildcards in it. If we find one,
- * call Dir_Expand right away, telling it to place the result
- * on our list of expansions.
- */
- for (cp2 = file; *cp2 != '\0'; cp2++) {
- switch (*cp2) {
- case '*':
- case '?':
- case '{':
- case '[':
- Path_Expand(file, path, expansions);
- goto next;
- default:
- break;
- }
- }
- if (*cp2 == '\0') {
- /*
- * Hit the end w/o finding any wildcards, so stick
- * the expansion on the end of the list.
- */
- Lst_AtEnd(expansions, file);
- } else {
- next:
- free(file);
- }
- start = cp + 1;
- }
-}
-
-/*-
- *-----------------------------------------------------------------------
- * DirExpandInt --
- * Internal expand routine. Passes through the directories in the
- * path one by one, calling DirMatchFiles for each. NOTE: This still
- * doesn't handle patterns in directories... Works given a word to
- * expand, a path to look in, and a list to store expansions in.
- *
- * Results:
- * None.
- *
- * Side Effects:
- * Things are added to the expansions list.
- *
- *-----------------------------------------------------------------------
- */
-static void
-DirExpandInt(const char *word, const struct Path *path, Lst *expansions)
-{
- struct PathElement *pe;
-
- TAILQ_FOREACH(pe, path, link)
- DirMatchFiles(word, pe->dir, expansions);
-}
-
-/*-
- *-----------------------------------------------------------------------
- * Dir_Expand --
- * Expand the given word into a list of words by globbing it looking
- * in the directories on the given search path.
- *
- * Results:
- * A list of words consisting of the files which exist along the search
- * path matching the given pattern is placed in expansions.
- *
- * Side Effects:
- * Directories may be opened. Who knows?
- *-----------------------------------------------------------------------
- */
-void
-Path_Expand(char *word, struct Path *path, Lst *expansions)
-{
- LstNode *ln;
- char *cp;
-
- DEBUGF(DIR, ("expanding \"%s\"...", word));
-
- cp = strchr(word, '{');
- if (cp != NULL)
- DirExpandCurly(word, cp, path, expansions);
- else {
- cp = strchr(word, '/');
- if (cp != NULL) {
- /*
- * The thing has a directory component -- find the
- * first wildcard in the string.
- */
- for (cp = word; *cp != '\0'; cp++) {
- if (*cp == '?' || *cp == '[' ||
- *cp == '*' || *cp == '{') {
- break;
- }
- }
- if (*cp == '{') {
- /*
- * This one will be fun.
- */
- DirExpandCurly(word, cp, path, expansions);
- return;
- } else if (*cp != '\0') {
- /*
- * Back up to the start of the component
- */
- char *dirpath;
-
- while (cp > word && *cp != '/')
- cp--;
- if (cp != word) {
- char sc;
-
- /*
- * If the glob isn't in the first
- * component, try and find all the
- * components up to the one with a
- * wildcard.
- */
- sc = cp[1];
- cp[1] = '\0';
- dirpath = Path_FindFile(word, path);
- cp[1] = sc;
- /*
- * dirpath is null if can't find the
- * leading component
- * XXX: Path_FindFile won't find internal
- * components. i.e. if the path contains
- * ../Etc/Object and we're looking for
- * Etc, * it won't be found. Ah well.
- * Probably not important.
- */
- if (dirpath != NULL) {
- char *dp =
- &dirpath[strlen(dirpath)
- - 1];
- struct Path tp =
- TAILQ_HEAD_INITIALIZER(tp);
-
- if (*dp == '/')
- *dp = '\0';
- Path_AddDir(&tp, dirpath);
- DirExpandInt(cp + 1, &tp,
- expansions);
- Path_Clear(&tp);
- }
- } else {
- /*
- * Start the search from the local
- * directory
- */
- DirExpandInt(word, path, expansions);
- }
- } else {
- /*
- * Return the file -- this should never happen.
- */
- DirExpandInt(word, path, expansions);
- }
- } else {
- /*
- * First the files in dot
- */
- DirMatchFiles(word, dot, expansions);
-
- /*
- * Then the files in every other directory on the path.
- */
- DirExpandInt(word, path, expansions);
- }
- }
- if (DEBUG(DIR)) {
- LST_FOREACH(ln, expansions)
- DEBUGF(DIR, ("%s ", (const char *)Lst_Datum(ln)));
- DEBUGF(DIR, ("\n"));
- }
-}
-
-/**
- * Path_FindFile
- * Find the file with the given name along the given search path.
- *
- * Results:
- * The path to the file or NULL. This path is guaranteed to be in a
- * different part of memory than name and so may be safely free'd.
- *
- * Side Effects:
- * If the file is found in a directory which is not on the path
- * already (either 'name' is absolute or it is a relative path
- * [ dir1/.../dirn/file ] which exists below one of the directories
- * already on the search path), its directory is added to the end
- * of the path on the assumption that there will be more files in
- * that directory later on. Sometimes this is true. Sometimes not.
- */
-char *
-Path_FindFile(char *name, struct Path *path)
-{
- char *p1; /* pointer into p->name */
- char *p2; /* pointer into name */
- char *file; /* the current filename to check */
- const struct PathElement *pe; /* current path member */
- char *cp; /* final component of the name */
- Boolean hasSlash; /* true if 'name' contains a / */
- struct stat stb; /* Buffer for stat, if necessary */
- Hash_Entry *entry; /* Entry for mtimes table */
-
- /*
- * Find the final component of the name and note whether it has a
- * slash in it (the name, I mean)
- */
- cp = strrchr(name, '/');
- if (cp != NULL) {
- hasSlash = TRUE;
- cp += 1;
- } else {
- hasSlash = FALSE;
- cp = name;
- }
-
- DEBUGF(DIR, ("Searching for %s...", name));
- /*
- * No matter what, we always look for the file in the current directory
- * before anywhere else and we *do not* add the ./ to it if it exists.
- * This is so there are no conflicts between what the user specifies
- * (fish.c) and what pmake finds (./fish.c).
- */
- if ((!hasSlash || (cp - name == 2 && *name == '.')) &&
- (Hash_FindEntry(&dot->files, cp) != NULL)) {
- DEBUGF(DIR, ("in '.'\n"));
- hits += 1;
- dot->hits += 1;
- return (estrdup(name));
- }
-
- /*
- * We look through all the directories on the path seeking one which
- * contains the final component of the given name and whose final
- * component(s) match the name's initial component(s). If such a beast
- * is found, we concatenate the directory name and the final component
- * and return the resulting string. If we don't find any such thing,
- * we go on to phase two...
- */
- TAILQ_FOREACH(pe, path, link) {
- DEBUGF(DIR, ("%s...", pe->dir->name));
- if (Hash_FindEntry(&pe->dir->files, cp) != NULL) {
- DEBUGF(DIR, ("here..."));
- if (hasSlash) {
- /*
- * If the name had a slash, its initial
- * components and p's final components must
- * match. This is false if a mismatch is
- * encountered before all of the initial
- * components have been checked (p2 > name at
- * the end of the loop), or we matched only
- * part of one of the components of p
- * along with all the rest of them (*p1 != '/').
- */
- p1 = pe->dir->name + strlen(pe->dir->name) - 1;
- p2 = cp - 2;
- while (p2 >= name && p1 >= pe->dir->name &&
- *p1 == *p2) {
- p1 -= 1; p2 -= 1;
- }
- if (p2 >= name || (p1 >= pe->dir->name &&
- *p1 != '/')) {
- DEBUGF(DIR, ("component mismatch -- "
- "continuing..."));
- continue;
- }
- }
- file = str_concat(pe->dir->name, cp, STR_ADDSLASH);
- DEBUGF(DIR, ("returning %s\n", file));
- pe->dir->hits += 1;
- hits += 1;
- return (file);
- } else if (hasSlash) {
- /*
- * If the file has a leading path component and that
- * component exactly matches the entire name of the
- * current search directory, we assume the file
- * doesn't exist and return NULL.
- */
- for (p1 = pe->dir->name, p2 = name; *p1 && *p1 == *p2;
- p1++, p2++)
- continue;
- if (*p1 == '\0' && p2 == cp - 1) {
- if (*cp == '\0' || ISDOT(cp) || ISDOTDOT(cp)) {
- DEBUGF(DIR, ("returning %s\n", name));
- return (estrdup(name));
- } else {
- DEBUGF(DIR, ("must be here but isn't --"
- " returning NULL\n"));
- return (NULL);
- }
- }
- }
- }
-
- /*
- * We didn't find the file on any existing members of the directory.
- * If the name doesn't contain a slash, that means it doesn't exist.
- * If it *does* contain a slash, however, there is still hope: it
- * could be in a subdirectory of one of the members of the search
- * path. (eg. /usr/include and sys/types.h. The above search would
- * fail to turn up types.h in /usr/include, but it *is* in
- * /usr/include/sys/types.h) If we find such a beast, we assume there
- * will be more (what else can we assume?) and add all but the last
- * component of the resulting name onto the search path (at the
- * end). This phase is only performed if the file is *not* absolute.
- */
- if (!hasSlash) {
- DEBUGF(DIR, ("failed.\n"));
- misses += 1;
- return (NULL);
- }
-
- if (*name != '/') {
- Boolean checkedDot = FALSE;
-
- DEBUGF(DIR, ("failed. Trying subdirectories..."));
- TAILQ_FOREACH(pe, path, link) {
- if (pe->dir != dot) {
- file = str_concat(pe->dir->name,
- name, STR_ADDSLASH);
- } else {
- /*
- * Checking in dot -- DON'T put a leading ./
- * on the thing.
- */
- file = estrdup(name);
- checkedDot = TRUE;
- }
- DEBUGF(DIR, ("checking %s...", file));
-
- if (stat(file, &stb) == 0) {
- DEBUGF(DIR, ("got it.\n"));
-
- /*
- * We've found another directory to search. We
- * know there's a slash in 'file' because we put
- * one there. We nuke it after finding it and
- * call Path_AddDir to add this new directory
- * onto the existing search path. Once that's
- * done, we restore the slash and triumphantly
- * return the file name, knowing that should a
- * file in this directory every be referenced
- * again in such a manner, we will find it
- * without having to do numerous numbers of
- * access calls. Hurrah!
- */
- cp = strrchr(file, '/');
- *cp = '\0';
- Path_AddDir(path, file);
- *cp = '/';
-
- /*
- * Save the modification time so if
- * it's needed, we don't have to fetch it again.
- */
- DEBUGF(DIR, ("Caching %s for %s\n",
- Targ_FmtTime(stb.st_mtime), file));
- entry = Hash_CreateEntry(&mtimes, file,
- (Boolean *)NULL);
- Hash_SetValue(entry,
- (void *)(long)stb.st_mtime);
- nearmisses += 1;
- return (file);
- } else {
- free(file);
- }
- }
-
- DEBUGF(DIR, ("failed. "));
-
- if (checkedDot) {
- /*
- * Already checked by the given name, since . was in
- * the path, so no point in proceeding...
- */
- DEBUGF(DIR, ("Checked . already, returning NULL\n"));
- return (NULL);
- }
- }
-
- /*
- * Didn't find it that way, either. Sigh. Phase 3. Add its directory
- * onto the search path in any case, just in case, then look for the
- * thing in the hash table. If we find it, grand. We return a new
- * copy of the name. Otherwise we sadly return a NULL pointer. Sigh.
- * Note that if the directory holding the file doesn't exist, this will
- * do an extra search of the final directory on the path. Unless
- * something weird happens, this search won't succeed and life will
- * be groovy.
- *
- * Sigh. We cannot add the directory onto the search path because
- * of this amusing case:
- * $(INSTALLDIR)/$(FILE): $(FILE)
- *
- * $(FILE) exists in $(INSTALLDIR) but not in the current one.
- * When searching for $(FILE), we will find it in $(INSTALLDIR)
- * b/c we added it here. This is not good...
- */
- DEBUGF(DIR, ("Looking for \"%s\"...", name));
-
- bigmisses += 1;
- entry = Hash_FindEntry(&mtimes, name);
- if (entry != NULL) {
- DEBUGF(DIR, ("got it (in mtime cache)\n"));
- return (estrdup(name));
- } else if (stat (name, &stb) == 0) {
- entry = Hash_CreateEntry(&mtimes, name, (Boolean *)NULL);
- DEBUGF(DIR, ("Caching %s for %s\n",
- Targ_FmtTime(stb.st_mtime), name));
- Hash_SetValue(entry, (void *)(long)stb.st_mtime);
- return (estrdup(name));
- } else {
- DEBUGF(DIR, ("failed. Returning NULL\n"));
- return (NULL);
- }
-}
-
-/*-
- *-----------------------------------------------------------------------
- * Dir_FindHereOrAbove --
- * search for a path starting at a given directory and then working
- * our way up towards the root.
- *
- * Input:
- * here starting directory
- * search_path the path we are looking for
- * result the result of a successful search is placed here
- * rlen the length of the result buffer
- * (typically MAXPATHLEN + 1)
- *
- * Results:
- * 0 on failure, 1 on success [in which case the found path is put
- * in the result buffer].
- *
- * Side Effects:
- *-----------------------------------------------------------------------
- */
-int
-Dir_FindHereOrAbove(char *here, char *search_path, char *result, int rlen)
-{
- struct stat st;
- char dirbase[MAXPATHLEN + 1], *db_end;
- char try[MAXPATHLEN + 1], *try_end;
-
- /* copy out our starting point */
- snprintf(dirbase, sizeof(dirbase), "%s", here);
- db_end = dirbase + strlen(dirbase);
-
- /* loop until we determine a result */
- while (1) {
- /* try and stat(2) it ... */
- snprintf(try, sizeof(try), "%s/%s", dirbase, search_path);
- if (stat(try, &st) != -1) {
- /*
- * Success! If we found a file, chop off
- * the filename so we return a directory.
- */
- if ((st.st_mode & S_IFMT) != S_IFDIR) {
- try_end = try + strlen(try);
- while (try_end > try && *try_end != '/')
- try_end--;
- if (try_end > try)
- *try_end = 0; /* chop! */
- }
-
- /*
- * Done!
- */
- snprintf(result, rlen, "%s", try);
- return(1);
- }
-
- /*
- * Nope, we didn't find it. If we used up dirbase we've
- * reached the root and failed.
- */
- if (db_end == dirbase)
- break; /* Failed! */
-
- /*
- * truncate dirbase from the end to move up a dir
- */
- while (db_end > dirbase && *db_end != '/')
- db_end--;
- *db_end = 0; /* chop! */
-
- } /* while (1) */
-
- /*
- * We failed...
- */
- return(0);
-}
-
-/*-
- *-----------------------------------------------------------------------
- * Dir_MTime --
- * Find the modification time of the file described by gn along the
- * search path dirSearchPath.
- *
- * Results:
- * The modification time or 0 if it doesn't exist
- *
- * Side Effects:
- * The modification time is placed in the node's mtime slot.
- * If the node didn't have a path entry before, and Path_FindFile
- * found one for it, the full name is placed in the path slot.
- *-----------------------------------------------------------------------
- */
-int
-Dir_MTime(GNode *gn)
-{
- char *fullName; /* the full pathname of name */
- struct stat stb; /* buffer for finding the mod time */
- Hash_Entry *entry;
-
- if (gn->type & OP_ARCHV)
- return (Arch_MTime(gn));
-
- else if (gn->path == NULL)
- fullName = Path_FindFile(gn->name, &dirSearchPath);
- else
- fullName = gn->path;
-
- if (fullName == NULL)
- fullName = estrdup(gn->name);
-
- entry = Hash_FindEntry(&mtimes, fullName);
- if (entry != NULL) {
- /*
- * Only do this once -- the second time folks are checking to
- * see if the file was actually updated, so we need to
- * actually go to the filesystem.
- */
- DEBUGF(DIR, ("Using cached time %s for %s\n",
- Targ_FmtTime((time_t)(long)Hash_GetValue(entry)),
- fullName));
- stb.st_mtime = (time_t)(long)Hash_GetValue(entry);
- Hash_DeleteEntry(&mtimes, entry);
- } else if (stat(fullName, &stb) < 0) {
- if (gn->type & OP_MEMBER) {
- if (fullName != gn->path)
- free(fullName);
- return (Arch_MemMTime(gn));
- } else {
- stb.st_mtime = 0;
- }
- }
- if (fullName && gn->path == (char *)NULL)
- gn->path = fullName;
-
- gn->mtime = stb.st_mtime;
- return (gn->mtime);
-}
-
-/*-
- *-----------------------------------------------------------------------
- * Path_AddDir --
- * Add the given name to the end of the given path.
- *
- * Results:
- * none
- *
- * Side Effects:
- * A structure is added to the list and the directory is
- * read and hashed.
- *-----------------------------------------------------------------------
- */
-struct Dir *
-Path_AddDir(struct Path *path, const char *name)
-{
- Dir *d; /* pointer to new Path structure */
- DIR *dir; /* for reading directory */
- struct PathElement *pe;
- struct dirent *dp; /* entry in directory */
-
- /* check whether we know this directory */
- TAILQ_FOREACH(d, &openDirectories, link) {
- if (strcmp(d->name, name) == 0) {
- /* Found it. */
- if (path == NULL)
- return (d);
-
- /* Check whether its already on the path. */
- TAILQ_FOREACH(pe, path, link) {
- if (pe->dir == d)
- return (d);
- }
- /* Add it to the path */
- d->refCount += 1;
- pe = emalloc(sizeof(*pe));
- pe->dir = d;
- TAILQ_INSERT_TAIL(path, pe, link);
- return (d);
- }
- }
-
- DEBUGF(DIR, ("Caching %s...", name));
-
- if ((dir = opendir(name)) == NULL) {
- DEBUGF(DIR, (" cannot open\n"));
- return (NULL);
- }
-
- d = emalloc(sizeof(*d));
- d->name = estrdup(name);
- d->hits = 0;
- d->refCount = 1;
- Hash_InitTable(&d->files, -1);
-
- while ((dp = readdir(dir)) != NULL) {
-#if defined(sun) && defined(d_ino) /* d_ino is a sunos4 #define for d_fileno */
- /*
- * The sun directory library doesn't check for
- * a 0 inode (0-inode slots just take up space),
- * so we have to do it ourselves.
- */
- if (dp->d_fileno == 0)
- continue;
-#endif /* sun && d_ino */
-
- /* Skip the '.' and '..' entries by checking
- * for them specifically instead of assuming
- * readdir() reuturns them in that order when
- * first going through a directory. This is
- * needed for XFS over NFS filesystems since
- * SGI does not guarantee that these are the
- * first two entries returned from readdir().
- */
- if (ISDOT(dp->d_name) || ISDOTDOT(dp->d_name))
- continue;
-
- Hash_CreateEntry(&d->files, dp->d_name, (Boolean *)NULL);
- }
- closedir(dir);
-
- if (path != NULL) {
- /* Add it to the path */
- d->refCount += 1;
- pe = emalloc(sizeof(*pe));
- pe->dir = d;
- TAILQ_INSERT_TAIL(path, pe, link);
- }
-
- /* Add to list of all directories */
- TAILQ_INSERT_TAIL(&openDirectories, d, link);
-
- DEBUGF(DIR, ("done\n"));
-
- return (d);
-}
-
-/**
- * Path_Duplicate
- * Duplicate a path. Ups the reference count for the directories.
- */
-void
-Path_Duplicate(struct Path *dst, const struct Path *src)
-{
- struct PathElement *ped, *pes;
-
- TAILQ_FOREACH(pes, src, link) {
- ped = emalloc(sizeof(*ped));
- ped->dir = pes->dir;
- ped->dir->refCount++;
- TAILQ_INSERT_TAIL(dst, ped, link);
- }
-}
-
-/**
- * Path_MakeFlags
- * Make a string by taking all the directories in the given search
- * path and preceding them by the given flag. Used by the suffix
- * module to create variables for compilers based on suffix search
- * paths.
- *
- * Results:
- * The string mentioned above. Note that there is no space between
- * the given flag and each directory. The empty string is returned if
- * Things don't go well.
- */
-char *
-Path_MakeFlags(const char *flag, const struct Path *path)
-{
- char *str; /* the string which will be returned */
- char *tstr; /* the current directory preceded by 'flag' */
- char *nstr;
- const struct PathElement *pe;
-
- str = estrdup("");
-
- TAILQ_FOREACH(pe, path, link) {
- tstr = str_concat(flag, pe->dir->name, 0);
- nstr = str_concat(str, tstr, STR_ADDSPACE);
- free(str);
- free(tstr);
- str = nstr;
- }
-
- return (str);
-}
-
-/**
- * Path_Clear
- *
- * Destroy a path. This decrements the reference counts of all
- * directories of this path and, if a reference count goes 0,
- * destroys the directory object.
- */
-void
-Path_Clear(struct Path *path)
-{
- struct PathElement *pe;
-
- while ((pe = TAILQ_FIRST(path)) != NULL) {
- pe->dir->refCount--;
- TAILQ_REMOVE(path, pe, link);
- if (pe->dir->refCount == 0) {
- TAILQ_REMOVE(&openDirectories, pe->dir, link);
- Hash_DeleteTable(&pe->dir->files);
- free(pe->dir->name);
- free(pe->dir);
- }
- free(pe);
- }
-}
-
-/**
- * Path_Concat
- *
- * Concatenate two paths, adding the second to the end of the first.
- * Make sure to avoid duplicates.
- *
- * Side Effects:
- * Reference counts for added dirs are upped.
- */
-void
-Path_Concat(struct Path *path1, const struct Path *path2)
-{
- struct PathElement *p1, *p2;
-
- TAILQ_FOREACH(p2, path2, link) {
- TAILQ_FOREACH(p1, path1, link) {
- if (p1->dir == p2->dir)
- break;
- }
- if (p1 == NULL) {
- p1 = emalloc(sizeof(*p1));
- p1->dir = p2->dir;
- p1->dir->refCount++;
- TAILQ_INSERT_TAIL(path1, p1, link);
- }
- }
-}
-
-/********** DEBUG INFO **********/
-void
-Dir_PrintDirectories(void)
-{
- const Dir *d;
-
- printf("#*** Directory Cache:\n");
- printf("# Stats: %d hits %d misses %d near misses %d losers (%d%%)\n",
- hits, misses, nearmisses, bigmisses,
- (hits + bigmisses + nearmisses ?
- hits * 100 / (hits + bigmisses + nearmisses) : 0));
- printf("# %-20s referenced\thits\n", "directory");
- TAILQ_FOREACH(d, &openDirectories, link)
- printf("# %-20s %10d\t%4d\n", d->name, d->refCount, d->hits);
-}
-
-void
-Path_Print(const struct Path *path)
-{
- const struct PathElement *p;
-
- TAILQ_FOREACH(p, path, link)
- printf("%s ", p->dir->name);
-}
diff --git a/usr.bin/make/dir.h b/usr.bin/make/dir.h
deleted file mode 100644
index 1ae89ae..0000000
--- a/usr.bin/make/dir.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*-
- * Copyright (c) 1988, 1989, 1990, 1993
- * The Regents of the University of California. All rights reserved.
- * Copyright (c) 1988, 1989 by Adam de Boor
- * Copyright (c) 1989 by Berkeley Softworks
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Adam de Boor.
- *
- * 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.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
- *
- * @(#)dir.h 8.2 (Berkeley) 4/28/95
- * $FreeBSD$
- */
-
-#ifndef dir_h_6002e3b8
-#define dir_h_6002e3b8
-
-#include <sys/queue.h>
-#include "hash.h"
-
-struct GNode;
-struct Lst;
-struct Dir;
-
-struct PathElement;
-TAILQ_HEAD(Path, PathElement);
-
-void Dir_Init(void);
-void Dir_InitDot(void);
-Boolean Dir_HasWildcards(const char *);
-int Dir_FindHereOrAbove(char *, char *, char *, int);
-int Dir_MTime(struct GNode *);
-void Dir_PrintDirectories(void);
-
-struct Dir *Path_AddDir(struct Path *, const char *);
-void Path_Clear(struct Path *);
-void Path_Concat(struct Path *, const struct Path *);
-void Path_Duplicate(struct Path *, const struct Path *);
-void Path_Expand(char *, struct Path *, struct Lst *);
-char *Path_FindFile(char *, struct Path *);
-char *Path_MakeFlags(const char *, const struct Path *);
-void Path_Print(const struct Path *);
-
-#endif /* dir_h_6002e3b8 */
diff --git a/usr.bin/make/for.c b/usr.bin/make/for.c
deleted file mode 100644
index 1b2e578..0000000
--- a/usr.bin/make/for.c
+++ /dev/null
@@ -1,267 +0,0 @@
-/*-
- * Copyright (c) 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Christos Zoulas.
- *
- * 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.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
- *
- * @(#)for.c 8.1 (Berkeley) 6/6/93
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-/*-
- * for.c --
- * Functions to handle loops in a makefile.
- *
- * Interface:
- * For_Eval Evaluate the loop in the passed line.
- * For_Run Run accumulated loop
- *
- */
-
-#include <ctype.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "buf.h"
-#include "for.h"
-#include "globals.h"
-#include "lst.h"
-#include "parse.h"
-#include "str.h"
-#include "util.h"
-#include "var.h"
-
-/*
- * For statements are of the form:
- *
- * .for <variable> in <varlist>
- * ...
- * .endfor
- *
- * The trick is to look for the matching end inside for for loop
- * To do that, we count the current nesting level of the for loops.
- * and the .endfor statements, accumulating all the statements between
- * the initial .for loop and the matching .endfor;
- * then we evaluate the for loop for each variable in the varlist.
- */
-
-static int forLevel = 0; /* Nesting level */
-static char *forVar; /* Iteration variable */
-static Buffer *forBuf; /* Commands in loop */
-static Lst forLst; /* List of items */
-
-/**
- * For_For
- * Evaluate the for loop in the passed line. The line
- * looks like this:
- * .for <variable> in <varlist>
- * The line pointer points just behind the for.
- *
- * Results:
- * TRUE: Syntax ok.
- * FALSE: Syntax error.
- */
-Boolean
-For_For(char *line)
-{
- char *ptr;
- char *wrd;
- char *sub;
- Buffer *buf;
- size_t varlen;
- int i;
- ArgArray words;
-
- ptr = line;
-
- /*
- * Skip space between for and the variable.
- */
- for (ptr++; *ptr && isspace((u_char)*ptr); ptr++)
- ;
-
- /*
- * Grab the variable
- */
- for (wrd = ptr; *ptr && !isspace((u_char)*ptr); ptr++)
- ;
-
- buf = Buf_Init(0);
- Buf_AppendRange(buf, wrd, ptr);
- forVar = Buf_GetAll(buf, &varlen);
-
- if (varlen == 0) {
- Buf_Destroy(buf, TRUE);
- Parse_Error(PARSE_FATAL, "missing variable in for");
- return (FALSE);
- }
- Buf_Destroy(buf, FALSE);
-
- /*
- * Skip to 'in'.
- */
- while (*ptr && isspace((u_char)*ptr))
- ptr++;
-
- /*
- * Grab the `in'
- */
- if (ptr[0] != 'i' || ptr[1] != 'n' || !isspace((u_char)ptr[2])) {
- free(forVar);
- Parse_Error(PARSE_FATAL, "missing `in' in for");
- fprintf(stderr, "%s\n", ptr);
- return (FALSE);
- }
- ptr += 3;
-
- /*
- * Skip to values
- */
- while (*ptr && isspace((u_char)*ptr))
- ptr++;
-
- /*
- * Make a list with the remaining words
- */
- sub = Buf_Peel(Var_Subst(ptr, VAR_CMD, FALSE));
- brk_string(&words, sub, FALSE);
- Lst_Init(&forLst);
- for (i = 1; i < words.argc; i++) {
- if (words.argv[i][0] != '\0')
- Lst_AtFront(&forLst, estrdup(words.argv[i]));
- }
- ArgArray_Done(&words);
- DEBUGF(FOR, ("For: Iterator %s List %s\n", forVar, sub));
- free(sub);
-
- forBuf = Buf_Init(0);
- forLevel++;
- return (TRUE);
-}
-
-/**
- * For_Eval
- * Eat a line of the .for body looking for embedded .for loops
- * and the .endfor
- */
-Boolean
-For_Eval(char *line)
-{
- char *ptr;
-
- ptr = line;
-
- if (*ptr == '.') {
- /*
- * Need to check for 'endfor' and 'for' to find the end
- * of our loop or to find embedded for loops.
- */
- for (ptr++; *ptr != '\0' && isspace((u_char)*ptr); ptr++)
- ;
-
- /* XXX the isspace is wrong */
- if (strncmp(ptr, "endfor", 6) == 0 &&
- (isspace((u_char)ptr[6]) || ptr[6] == '\0')) {
- DEBUGF(FOR, ("For: end for %d\n", forLevel));
- if (forLevel == 0) {
- /* should not be here */
- abort();
- }
- forLevel--;
-
- } else if (strncmp(ptr, "for", 3) == 0 &&
- isspace((u_char)ptr[3])) {
- forLevel++;
- DEBUGF(FOR, ("For: new loop %d\n", forLevel));
- }
- }
-
- if (forLevel != 0) {
- /*
- * Still in loop - append the line
- */
- Buf_Append(forBuf, line);
- Buf_AddByte(forBuf, (Byte)'\n');
- return (TRUE);
- }
-
- return (FALSE);
-}
-
-/*-
- *-----------------------------------------------------------------------
- * For_Run --
- * Run the for loop, imitating the actions of an include file
- *
- * Results:
- * None.
- *
- * Side Effects:
- * The values of the variables forLst, forVar and forBuf are freed.
- *
- *-----------------------------------------------------------------------
- */
-void
-For_Run(int lineno)
-{
- Lst values; /* list of values for the variable */
- char *var; /* the variable's name */
- Buffer *buf; /* the contents of the for loop */
- const char *val; /* current value of loop variable */
- LstNode *ln;
- char *str;
-
- if (forVar == NULL || forBuf == NULL)
- return;
-
- /* copy the global variables to have them free for embedded fors */
- var = forVar;
- buf = forBuf;
- Lst_Init(&values);
- Lst_Concat(&values, &forLst, LST_CONCLINK);
-
- forVar = NULL;
- forBuf = NULL;
-
- LST_FOREACH(ln, &values) {
- val = Lst_Datum(ln);
- Var_SetGlobal(var, val);
-
- DEBUGF(FOR, ("--- %s = %s\n", var, val));
- str = Buf_Peel(Var_SubstOnly(var, Buf_Data(buf), FALSE));
-
- Parse_FromString(str, lineno);
- Var_Delete(var, VAR_GLOBAL);
- }
-
- free(var);
- Lst_Destroy(&values, free);
- Buf_Destroy(buf, TRUE);
-}
diff --git a/usr.bin/make/globals.h b/usr.bin/make/globals.h
deleted file mode 100644
index e3ce51b..0000000
--- a/usr.bin/make/globals.h
+++ /dev/null
@@ -1,116 +0,0 @@
-/*-
- * Copyright (c) 1988, 1989, 1990, 1993
- * The Regents of the University of California. All rights reserved.
- * Copyright (c) 1989 by Berkeley Softworks
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Adam de Boor.
- *
- * 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.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
- *
- * $FreeBSD$
- */
-
-#ifndef globals_h_1c1edb96
-#define globals_h_1c1edb96
-
-/*
- * Global Variables
- */
-
-#include "lst.h"
-#include "util.h"
-
-struct GNode;
-struct Path;
-
-/*
- * The list of target names specified on the command line.
- * Used to resolve #if make(...) statements
- */
-extern Lst create;
-
-/* The list of directories to search when looking for targets */
-extern struct Path dirSearchPath;
-
-/* The list of directories to search when looking for includes */
-extern struct Path parseIncPath;
-
-/* The system include path. */
-extern struct Path sysIncPath;
-
-extern int jobLimit; /* -j argument: maximum number of jobs */
-extern int makeErrors; /* Number of targets not remade due to errors */
-extern Boolean jobsRunning; /* True if jobs are running */
-extern Boolean compatMake; /* True if we are make compatible */
-extern Boolean ignoreErrors; /* True if should ignore all errors */
-extern Boolean beSilent; /* True if should print no commands */
-extern Boolean beVerbose; /* True if should print extra cruft */
-extern Boolean beQuiet; /* True if want quiet headers with -j */
-extern Boolean noExecute; /* True if should execute nothing */
-extern Boolean printGraphOnly; /* -p flag */
-extern Boolean allPrecious; /* True if every target is precious */
-extern Boolean is_posix; /* .POSIX target seen */
-extern Boolean mfAutoDeps; /* .MAKEFILEDEPS target seen */
-extern Boolean remakingMakefiles; /* True if remaking makefiles is in progress */
-
-/* True if should continue on unaffected portions of the graph
- * when have an error in one portion */
-extern Boolean keepgoing;
-
-/* TRUE if targets should just be 'touched'if out of date. Set by the -t flag */
-extern Boolean touchFlag;
-
-/* TRUE if should capture the output of subshells by means of pipes.
- * Otherwise it is routed to temporary files from which it is retrieved
- * when the shell exits */
-extern Boolean usePipes;
-
-/* TRUE if we aren't supposed to really make anything, just see if the
- * targets are out-of-date */
-extern Boolean queryFlag;
-
-/* List of specific variables for which the environment should be
- * searched before the global context */
-extern Lst envFirstVars;
-
-extern struct GNode *DEFAULT; /* .DEFAULT rule */
-
-/* The time at the start of this whole process */
-extern time_t now;
-
-extern int debug;
-
-/* warning flags */
-extern uint32_t warn_cmd; /* positive warning flags on command line */
-extern uint32_t warn_nocmd; /* negative warning flags on command line */
-extern uint32_t warn_flags; /* current warning flags */
-
-#endif /* globals_h_1c1edb96 */
diff --git a/usr.bin/make/hash.c b/usr.bin/make/hash.c
deleted file mode 100644
index b5ea6bc..0000000
--- a/usr.bin/make/hash.c
+++ /dev/null
@@ -1,398 +0,0 @@
-/*-
- * Copyright (c) 1988, 1989, 1990, 1993
- * The Regents of the University of California. All rights reserved.
- * Copyright (c) 1988, 1989 by Adam de Boor
- * Copyright (c) 1989 by Berkeley Softworks
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Adam de Boor.
- *
- * 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.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
- *
- * @(#)hash.c 8.1 (Berkeley) 6/6/93
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-/* hash.c --
- *
- * This module contains routines to manipulate a hash table.
- * See hash.h for a definition of the structure of the hash
- * table. Hash tables grow automatically as the amount of
- * information increases.
- */
-
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#include "hash.h"
-#include "util.h"
-
-/*
- * Forward references to local procedures that are used before they're
- * defined:
- */
-static void RebuildTable(Hash_Table *);
-
-/*
- * The following defines the ratio of # entries to # buckets
- * at which we rebuild the table to make it larger.
- */
-
-#define rebuildLimit 8
-
-/*
- *---------------------------------------------------------
- *
- * Hash_InitTable --
- *
- * Set up the hash table t with a given number of buckets, or a
- * reasonable default if the number requested is less than or
- * equal to zero. Hash tables will grow in size as needed.
- *
- *
- * Results:
- * None.
- *
- * Side Effects:
- * Memory is allocated for the initial bucket area.
- *
- *---------------------------------------------------------
- */
-void
-Hash_InitTable(Hash_Table *t, int numBuckets)
-{
- int i;
- struct Hash_Entry **hp;
-
- /*
- * Round up the size to a power of two.
- */
- if (numBuckets <= 0)
- i = 16;
- else {
- for (i = 2; i < numBuckets; i <<= 1)
- continue;
- }
- t->numEntries = 0;
- t->size = i;
- t->mask = i - 1;
- t->bucketPtr = hp = emalloc(sizeof(*hp) * i);
- while (--i >= 0)
- *hp++ = NULL;
-}
-
-/*
- *---------------------------------------------------------
- *
- * Hash_DeleteTable --
- *
- * This routine removes everything from a hash table
- * and frees up the memory space it occupied (except for
- * the space in the Hash_Table structure).
- *
- * Results:
- * None.
- *
- * Side Effects:
- * Lots of memory is freed up.
- *
- *---------------------------------------------------------
- */
-void
-Hash_DeleteTable(Hash_Table *t)
-{
- struct Hash_Entry **hp, *h, *nexth = NULL;
- int i;
-
- for (hp = t->bucketPtr, i = t->size; --i >= 0;) {
- for (h = *hp++; h != NULL; h = nexth) {
- nexth = h->next;
- free(h);
- }
- }
- free(t->bucketPtr);
-
- /*
- * Set up the hash table to cause memory faults on any future access
- * attempts until re-initialization.
- */
- t->bucketPtr = NULL;
-}
-
-/*
- *---------------------------------------------------------
- *
- * Hash_FindEntry --
- *
- * Searches a hash table for an entry corresponding to key.
- *
- * Results:
- * The return value is a pointer to the entry for key,
- * if key was present in the table. If key was not
- * present, NULL is returned.
- *
- * Side Effects:
- * None.
- *
- *---------------------------------------------------------
- */
-Hash_Entry *
-Hash_FindEntry(const Hash_Table *t, const char *key)
-{
- Hash_Entry *e;
- unsigned h;
- const char *p;
-
- for (h = 0, p = key; *p;)
- h = (h << 5) - h + *p++;
- p = key;
- for (e = t->bucketPtr[h & t->mask]; e != NULL; e = e->next)
- if (e->namehash == h && strcmp(e->name, p) == 0)
- return (e);
- return (NULL);
-}
-
-/*
- *---------------------------------------------------------
- *
- * Hash_CreateEntry --
- *
- * Searches a hash table for an entry corresponding to
- * key. If no entry is found, then one is created.
- *
- * Results:
- * The return value is a pointer to the entry. If *newPtr
- * isn't NULL, then *newPtr is filled in with TRUE if a
- * new entry was created, and FALSE if an entry already existed
- * with the given key.
- *
- * Side Effects:
- * Memory may be allocated, and the hash buckets may be modified.
- *---------------------------------------------------------
- */
-Hash_Entry *
-Hash_CreateEntry(Hash_Table *t, const char *key, Boolean *newPtr)
-{
- Hash_Entry *e;
- unsigned int h;
- const char *p;
- int keylen;
- struct Hash_Entry **hp;
-
- /*
- * Hash the key. As a side effect, save the length (strlen) of the
- * key in case we need to create the entry.
- */
- for (h = 0, p = key; *p;)
- h = (h << 5) - h + *p++;
- keylen = p - key;
- p = key;
- for (e = t->bucketPtr[h & t->mask]; e != NULL; e = e->next) {
- if (e->namehash == h && strcmp(e->name, p) == 0) {
- if (newPtr != NULL)
- *newPtr = FALSE;
- return (e);
- }
- }
-
- /*
- * The desired entry isn't there. Before allocating a new entry,
- * expand the table if necessary (and this changes the resulting
- * bucket chain).
- */
- if (t->numEntries >= rebuildLimit * t->size)
- RebuildTable(t);
- e = emalloc(sizeof(*e) + keylen);
- hp = &t->bucketPtr[h & t->mask];
- e->next = *hp;
- *hp = e;
- e->clientData = NULL;
- e->namehash = h;
- strcpy(e->name, p);
- t->numEntries++;
-
- if (newPtr != NULL)
- *newPtr = TRUE;
- return (e);
-}
-
-/*
- *---------------------------------------------------------
- *
- * Hash_DeleteEntry --
- *
- * Delete the given hash table entry and free memory associated with
- * it.
- *
- * Results:
- * None.
- *
- * Side Effects:
- * Hash chain that entry lives in is modified and memory is freed.
- *
- *---------------------------------------------------------
- */
-void
-Hash_DeleteEntry(Hash_Table *t, Hash_Entry *e)
-{
- Hash_Entry **hp, *p;
-
- if (e == NULL)
- return;
- for (hp = &t->bucketPtr[e->namehash & t->mask];
- (p = *hp) != NULL; hp = &p->next) {
- if (p == e) {
- *hp = p->next;
- free(p);
- t->numEntries--;
- return;
- }
- }
- write(STDERR_FILENO, "bad call to Hash_DeleteEntry\n", 29);
- abort();
-}
-
-/*
- *---------------------------------------------------------
- *
- * Hash_EnumFirst --
- * This procedure sets things up for a complete search
- * of all entries recorded in the hash table.
- *
- * Results:
- * The return value is the address of the first entry in
- * the hash table, or NULL if the table is empty.
- *
- * Side Effects:
- * The information in searchPtr is initialized so that successive
- * calls to Hash_Next will return successive HashEntry's
- * from the table.
- *
- *---------------------------------------------------------
- */
-Hash_Entry *
-Hash_EnumFirst(const Hash_Table *t, Hash_Search *searchPtr)
-{
-
- searchPtr->tablePtr = t;
- searchPtr->nextIndex = 0;
- searchPtr->hashEntryPtr = NULL;
- return (Hash_EnumNext(searchPtr));
-}
-
-/*
- *---------------------------------------------------------
- *
- * Hash_EnumNext --
- * This procedure returns successive entries in the hash table.
- *
- * Results:
- * The return value is a pointer to the next HashEntry
- * in the table, or NULL when the end of the table is
- * reached.
- *
- * Side Effects:
- * The information in searchPtr is modified to advance to the
- * next entry.
- *
- *---------------------------------------------------------
- */
-Hash_Entry *
-Hash_EnumNext(Hash_Search *searchPtr)
-{
- Hash_Entry *e;
- const Hash_Table *t = searchPtr->tablePtr;
-
- /*
- * The hashEntryPtr field points to the most recently returned
- * entry, or is NULL if we are starting up. If not NULL, we have
- * to start at the next one in the chain.
- */
- e = searchPtr->hashEntryPtr;
- if (e != NULL)
- e = e->next;
- /*
- * If the chain ran out, or if we are starting up, we need to
- * find the next nonempty chain.
- */
- while (e == NULL) {
- if (searchPtr->nextIndex >= t->size)
- return (NULL);
- e = t->bucketPtr[searchPtr->nextIndex++];
- }
- searchPtr->hashEntryPtr = e;
- return (e);
-}
-
-/*
- *---------------------------------------------------------
- *
- * RebuildTable --
- * This local routine makes a new hash table that
- * is larger than the old one.
- *
- * Results:
- * None.
- *
- * Side Effects:
- * The entire hash table is moved, so any bucket numbers
- * from the old table are invalid.
- *
- *---------------------------------------------------------
- */
-static void
-RebuildTable(Hash_Table *t)
-{
- Hash_Entry *e, *next = NULL, **hp, **xp;
- int i, mask;
- Hash_Entry **oldhp;
- int oldsize;
-
- oldhp = t->bucketPtr;
- oldsize = i = t->size;
- i <<= 1;
- t->size = i;
- t->mask = mask = i - 1;
- t->bucketPtr = hp = emalloc(sizeof(*hp) * i);
- while (--i >= 0)
- *hp++ = NULL;
- for (hp = oldhp, i = oldsize; --i >= 0;) {
- for (e = *hp++; e != NULL; e = next) {
- next = e->next;
- xp = &t->bucketPtr[e->namehash & mask];
- e->next = *xp;
- *xp = e;
- }
- }
- free(oldhp);
-}
diff --git a/usr.bin/make/hash.h b/usr.bin/make/hash.h
deleted file mode 100644
index 80dd74d..0000000
--- a/usr.bin/make/hash.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/*-
- * Copyright (c) 1988, 1989, 1990, 1993
- * The Regents of the University of California. All rights reserved.
- * Copyright (c) 1988, 1989 by Adam de Boor
- * Copyright (c) 1989 by Berkeley Softworks
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Adam de Boor.
- *
- * 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.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
- *
- * @(#)hash.h 8.1 (Berkeley) 6/6/93
- * $FreeBSD$
- */
-
-#ifndef hash_h_f6312f46
-#define hash_h_f6312f46
-
-/* hash.h --
- *
- * This file contains definitions used by the hash module,
- * which maintains hash tables.
- */
-
-#include "util.h"
-
-/*
- * The following defines one entry in the hash table.
- */
-typedef struct Hash_Entry {
- struct Hash_Entry *next; /* Link entries within same bucket. */
- void *clientData; /* Data associated with key. */
- unsigned namehash; /* hash value of key */
- char name[1]; /* key string */
-} Hash_Entry;
-
-typedef struct Hash_Table {
- struct Hash_Entry **bucketPtr; /* Buckets in the table */
- int size; /* Actual size of array. */
- int numEntries; /* Number of entries in the table. */
- int mask; /* Used to select bits for hashing. */
-} Hash_Table;
-
-/*
- * The following structure is used by the searching routines
- * to record where we are in the search.
- */
-typedef struct Hash_Search {
- const Hash_Table *tablePtr; /* Table being searched. */
- int nextIndex; /* Next bucket to check */
- Hash_Entry *hashEntryPtr; /* Next entry in current bucket */
-} Hash_Search;
-
-/*
- * Macros.
- */
-
-/*
- * void *Hash_GetValue(const Hash_Entry *h)
- */
-#define Hash_GetValue(h) ((h)->clientData)
-
-/*
- * Hash_SetValue(Hash_Entry *h, void *val);
- */
-#define Hash_SetValue(h, val) ((h)->clientData = (val))
-
-void Hash_InitTable(Hash_Table *, int);
-void Hash_DeleteTable(Hash_Table *);
-Hash_Entry *Hash_FindEntry(const Hash_Table *, const char *);
-Hash_Entry *Hash_CreateEntry(Hash_Table *, const char *, Boolean *);
-void Hash_DeleteEntry(Hash_Table *, Hash_Entry *);
-Hash_Entry *Hash_EnumFirst(const Hash_Table *, Hash_Search *);
-Hash_Entry *Hash_EnumNext(Hash_Search *);
-
-#endif /* hash_h_f6312f46 */
diff --git a/usr.bin/make/hash_tables.c b/usr.bin/make/hash_tables.c
deleted file mode 100644
index 27909d0..0000000
--- a/usr.bin/make/hash_tables.c
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * DO NOT EDIT
- * $FreeBSD$
- * auto-generated from FreeBSD: src/usr.bin/make/parse.c,v 1.114 2008/03/12 14:50:58 obrien Exp
- * DO NOT EDIT
- */
-#include <sys/types.h>
-
-#include "hash_tables.h"
-
-/*
- * d=2
- * n=40
- * m=19
- * c=2.09
- * maxlen=1
- * minklen=2
- * maxklen=9
- * minchar=97
- * maxchar=119
- * loop=0
- * numiter=1
- * seed=
- */
-
-static const signed char directive_g[] = {
- 8, 0, 0, 5, 6, -1, 17, 15, 10, 6,
- -1, -1, 10, 0, 0, -1, 18, 2, 3, 0,
- 7, -1, -1, -1, 0, 14, -1, -1, 11, 16,
- -1, -1, 0, -1, 0, 0, 17, 0, -1, 1,
-};
-
-static const u_char directive_T0[] = {
- 26, 14, 19, 35, 10, 34, 18, 27, 1, 17,
- 22, 37, 12, 12, 36, 21, 0, 6, 1, 25,
- 9, 4, 19,
-};
-
-static const u_char directive_T1[] = {
- 25, 22, 19, 0, 2, 18, 33, 18, 30, 4,
- 30, 9, 21, 19, 16, 12, 35, 34, 4, 19,
- 9, 33, 16,
-};
-
-
-int
-directive_hash(const u_char *key, size_t len)
-{
- unsigned f0, f1;
- const u_char *kp = key;
-
- if (len < 2 || len > 9)
- return -1;
-
- for (f0=f1=0; kp < key + len; ++kp) {
- if (*kp < 97 || *kp > 119)
- return -1;
- f0 += directive_T0[-97 + *kp];
- f1 += directive_T1[-97 + *kp];
- }
-
- f0 %= 40;
- f1 %= 40;
-
- return (directive_g[f0] + directive_g[f1]) % 19;
-}
-/*
- * d=2
- * n=74
- * m=35
- * c=2.09
- * maxlen=1
- * minklen=4
- * maxklen=13
- * minchar=46
- * maxchar=95
- * loop=0
- * numiter=4
- * seed=
- */
-
-static const signed char keyword_g[] = {
- 12, 18, 7, 25, 30, 5, -1, -1, -1, 7,
- -1, 0, 33, 0, 4, -1, -1, 13, 29, 0,
- -1, 28, -1, 28, -1, 0, -1, 27, 4, 34,
- -1, -1, -1, 30, 13, 10, -1, -1, 0, 10,
- 24, -1, -1, -1, 0, 6, 0, 0, -1, 23,
- -1, -1, -1, 0, -1, 23, -1, -1, 19, 4,
- -1, 31, 12, 16, -1, 20, 22, 9, 0, -1,
- -1, 9, 4, 0,
-};
-
-static const u_char keyword_T0[] = {
- 34, 28, 50, 61, 14, 57, 48, 60, 20, 67,
- 60, 63, 0, 24, 28, 2, 49, 64, 18, 23,
- 36, 33, 40, 14, 38, 42, 71, 49, 2, 53,
- 53, 37, 7, 29, 24, 21, 12, 50, 59, 10,
- 43, 23, 0, 44, 47, 6, 46, 22, 48, 64,
-};
-
-static const u_char keyword_T1[] = {
- 18, 67, 39, 60, 7, 70, 2, 26, 31, 18,
- 73, 47, 61, 17, 38, 50, 22, 52, 13, 55,
- 56, 32, 63, 4, 64, 55, 49, 21, 47, 67,
- 33, 66, 60, 73, 30, 68, 69, 32, 72, 4,
- 28, 49, 51, 15, 66, 68, 43, 67, 46, 56,
-};
-
-
-int
-keyword_hash(const u_char *key, size_t len)
-{
- unsigned f0, f1;
- const u_char *kp = key;
-
- if (len < 4 || len > 13)
- return -1;
-
- for (f0=f1=0; *kp; ++kp) {
- if (*kp < 46 || *kp > 95)
- return -1;
- f0 += keyword_T0[-46 + *kp];
- f1 += keyword_T1[-46 + *kp];
- }
-
- f0 %= 74;
- f1 %= 74;
-
- return (keyword_g[f0] + keyword_g[f1]) % 35;
-}
diff --git a/usr.bin/make/job.c b/usr.bin/make/job.c
deleted file mode 100644
index 6fee0ec..0000000
--- a/usr.bin/make/job.c
+++ /dev/null
@@ -1,3391 +0,0 @@
-/*-
- * Copyright (c) 1988, 1989, 1990, 1993
- * The Regents of the University of California. All rights reserved.
- * Copyright (c) 1988, 1989 by Adam de Boor
- * Copyright (c) 1989 by Berkeley Softworks
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Adam de Boor.
- *
- * 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.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
- *
- * @(#)job.c 8.2 (Berkeley) 3/19/94
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-/*-
- * job.c --
- * handle the creation etc. of our child processes.
- *
- * Interface:
- * Job_Make Start the creation of the given target.
- *
- * Job_CatchChildren
- * Check for and handle the termination of any children.
- * This must be called reasonably frequently to keep the
- * whole make going at a decent clip, since job table
- * entries aren't removed until their process is caught
- * this way. Its single argument is TRUE if the function
- * should block waiting for a child to terminate.
- *
- * Job_CatchOutput Print any output our children have produced. Should
- * also be called fairly frequently to keep the user
- * informed of what's going on. If no output is waiting,
- * it will block for a time given by the SEL_* constants,
- * below, or until output is ready.
- *
- * Job_Init Called to intialize this module. in addition, any
- * commands attached to the .BEGIN target are executed
- * before this function returns. Hence, the makefile must
- * have been parsed before this function is called.
- *
- * Job_Full Return TRUE if the job table is filled.
- *
- * Job_Empty Return TRUE if the job table is completely empty.
- *
- * Job_Finish Perform any final processing which needs doing. This
- * includes the execution of any commands which have
- * been/were attached to the .END target. It should only
- * be called when the job table is empty.
- *
- * Job_AbortAll Abort all currently running jobs. It doesn't handle
- * output or do anything for the jobs, just kills them.
- * It should only be called in an emergency, as it were.
- *
- * Job_CheckCommands
- * Verify that the commands for a target are ok. Provide
- * them if necessary and possible.
- *
- * Job_Touch Update a target without really updating it.
- *
- * Job_Wait Wait for all currently-running jobs to finish.
- *
- * compat.c --
- * The routines in this file implement the full-compatibility
- * mode of PMake. Most of the special functionality of PMake
- * is available in this mode. Things not supported:
- * - different shells.
- * - friendly variable substitution.
- *
- * Interface:
- * Compat_Run Initialize things for this module and recreate
- * thems as need creatin'
- */
-
-#include <sys/queue.h>
-#include <sys/types.h>
-#include <sys/select.h>
-#include <sys/stat.h>
-#ifdef USE_KQUEUE
-#include <sys/event.h>
-#endif
-#include <sys/wait.h>
-#include <ctype.h>
-#include <err.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <inttypes.h>
-#include <limits.h>
-#include <paths.h>
-#include <string.h>
-#include <signal.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <utime.h>
-
-#include "arch.h"
-#include "buf.h"
-#include "config.h"
-#include "dir.h"
-#include "globals.h"
-#include "GNode.h"
-#include "job.h"
-#include "make.h"
-#include "parse.h"
-#include "proc.h"
-#include "shell.h"
-#include "str.h"
-#include "suff.h"
-#include "targ.h"
-#include "util.h"
-#include "var.h"
-
-#define TMPPAT "makeXXXXXXXXXX"
-
-#ifndef USE_KQUEUE
-/*
- * The SEL_ constants determine the maximum amount of time spent in select
- * before coming out to see if a child has finished. SEL_SEC is the number of
- * seconds and SEL_USEC is the number of micro-seconds
- */
-#define SEL_SEC 2
-#define SEL_USEC 0
-#endif /* !USE_KQUEUE */
-
-/*
- * Job Table definitions.
- *
- * The job "table" is kept as a linked Lst in 'jobs', with the number of
- * active jobs maintained in the 'nJobs' variable. At no time will this
- * exceed the value of 'maxJobs', initialized by the Job_Init function.
- *
- * When a job is finished, the Make_Update function is called on each of the
- * parents of the node which was just remade. This takes care of the upward
- * traversal of the dependency graph.
- */
-#define JOB_BUFSIZE 1024
-typedef struct Job {
- pid_t pid; /* The child's process ID */
-
- struct GNode *node; /* The target the child is making */
-
- /*
- * A LstNode for the first command to be saved after the job completes.
- * This is NULL if there was no "..." in the job's commands.
- */
- LstNode *tailCmds;
-
- /*
- * An FILE* for writing out the commands. This is only
- * used before the job is actually started.
- */
- FILE *cmdFILE;
-
- /*
- * A word of flags which determine how the module handles errors,
- * echoing, etc. for the job
- */
- short flags; /* Flags to control treatment of job */
-#define JOB_IGNERR 0x001 /* Ignore non-zero exits */
-#define JOB_SILENT 0x002 /* no output */
-#define JOB_SPECIAL 0x004 /* Target is a special one. i.e. run it locally
- * if we can't export it and maxLocal is 0 */
-#define JOB_IGNDOTS 0x008 /* Ignore "..." lines when processing
- * commands */
-#define JOB_FIRST 0x020 /* Job is first job for the node */
-#define JOB_RESTART 0x080 /* Job needs to be completely restarted */
-#define JOB_RESUME 0x100 /* Job needs to be resumed b/c it stopped,
- * for some reason */
-#define JOB_CONTINUING 0x200 /* We are in the process of resuming this job.
- * Used to avoid infinite recursion between
- * JobFinish and JobRestart */
-
- /* union for handling shell's output */
- union {
- /*
- * This part is used when usePipes is true.
- * The output is being caught via a pipe and the descriptors
- * of our pipe, an array in which output is line buffered and
- * the current position in that buffer are all maintained for
- * each job.
- */
- struct {
- /*
- * Input side of pipe associated with
- * job's output channel
- */
- int op_inPipe;
-
- /*
- * Output side of pipe associated with job's
- * output channel
- */
- int op_outPipe;
-
- /*
- * Buffer for storing the output of the
- * job, line by line
- */
- char op_outBuf[JOB_BUFSIZE + 1];
-
- /* Current position in op_outBuf */
- int op_curPos;
- } o_pipe;
-
- /*
- * If usePipes is false the output is routed to a temporary
- * file and all that is kept is the name of the file and the
- * descriptor open to the file.
- */
- struct {
- /* Name of file to which shell output was rerouted */
- char of_outFile[PATH_MAX];
-
- /*
- * Stream open to the output file. Used to funnel all
- * from a single job to one file while still allowing
- * multiple shell invocations
- */
- int of_outFd;
- } o_file;
-
- } output; /* Data for tracking a shell's output */
-
- TAILQ_ENTRY(Job) link; /* list link */
-} Job;
-
-#define outPipe output.o_pipe.op_outPipe
-#define inPipe output.o_pipe.op_inPipe
-#define outBuf output.o_pipe.op_outBuf
-#define curPos output.o_pipe.op_curPos
-#define outFile output.o_file.of_outFile
-#define outFd output.o_file.of_outFd
-
-TAILQ_HEAD(JobList, Job);
-
-/*
- * error handling variables
- */
-static int aborting = 0; /* why is the make aborting? */
-#define ABORT_ERROR 1 /* Because of an error */
-#define ABORT_INTERRUPT 2 /* Because it was interrupted */
-#define ABORT_WAIT 3 /* Waiting for jobs to finish */
-
-/*
- * XXX: Avoid SunOS bug... FILENO() is fp->_file, and file
- * is a char! So when we go above 127 we turn negative!
- */
-#define FILENO(a) ((unsigned)fileno(a))
-
-/*
- * post-make command processing. The node postCommands is really just the
- * .END target but we keep it around to avoid having to search for it
- * all the time.
- */
-static GNode *postCommands;
-
-/*
- * The number of commands actually printed for a target. Should this
- * number be 0, no shell will be executed.
- */
-static int numCommands;
-
-/*
- * Return values from JobStart.
- */
-#define JOB_RUNNING 0 /* Job is running */
-#define JOB_ERROR 1 /* Error in starting the job */
-#define JOB_FINISHED 2 /* The job is already finished */
-#define JOB_STOPPED 3 /* The job is stopped */
-
-/*
- * The maximum number of jobs that may run. This is initialize from the
- * -j argument for the leading make and from the FIFO for sub-makes.
- */
-static int maxJobs;
-
-static int nJobs; /* The number of children currently running */
-
-/* The structures that describe them */
-static struct JobList jobs = TAILQ_HEAD_INITIALIZER(jobs);
-
-static Boolean jobFull; /* Flag to tell when the job table is full. It
- * is set TRUE when (1) the total number of
- * running jobs equals the maximum allowed */
-#ifdef USE_KQUEUE
-static int kqfd; /* File descriptor obtained by kqueue() */
-#else
-static fd_set outputs; /* Set of descriptors of pipes connected to
- * the output channels of children */
-#endif
-
-static GNode *lastNode; /* The node for which output was most recently
- * produced. */
-static const char *targFmt; /* Format string to use to head output from a
- * job when it's not the most-recent job heard
- * from */
-static char *targPrefix = NULL; /* What we print at the start of targFmt */
-
-#define TARG_FMT "%s %s ---\n" /* Default format */
-#define MESSAGE(fp, gn) \
- fprintf(fp, targFmt, targPrefix, gn->name);
-
-/*
- * When JobStart attempts to run a job but isn't allowed to
- * or when Job_CatchChildren detects a job that has
- * been stopped somehow, the job is placed on the stoppedJobs queue to be run
- * when the next job finishes.
- *
- * Lst of Job structures describing jobs that were stopped due to
- * concurrency limits or externally
- */
-static struct JobList stoppedJobs = TAILQ_HEAD_INITIALIZER(stoppedJobs);
-
-static int fifoFd; /* Fd of our job fifo */
-static char fifoName[] = "/tmp/make_fifo_XXXXXXXXX";
-static int fifoMaster;
-
-static volatile sig_atomic_t interrupted;
-
-
-#if defined(USE_PGRP) && defined(SYSV)
-# define KILL(pid, sig) killpg(-(pid), (sig))
-#else
-# if defined(USE_PGRP)
-# define KILL(pid, sig) killpg((pid), (sig))
-# else
-# define KILL(pid, sig) kill((pid), (sig))
-# endif
-#endif
-
-/*
- * Grmpf... There is no way to set bits of the wait structure
- * anymore with the stupid W*() macros. I liked the union wait
- * stuff much more. So, we devise our own macros... This is
- * really ugly, use dramamine sparingly. You have been warned.
- */
-#define W_SETMASKED(st, val, fun) \
- { \
- int sh = (int)~0; \
- int mask = fun(sh); \
- \
- for (sh = 0; ((mask >> sh) & 1) == 0; sh++) \
- continue; \
- *(st) = (*(st) & ~mask) | ((val) << sh); \
- }
-
-#define W_SETTERMSIG(st, val) W_SETMASKED(st, val, WTERMSIG)
-#define W_SETEXITSTATUS(st, val) W_SETMASKED(st, val, WEXITSTATUS)
-
-static void JobRestart(Job *);
-static int JobStart(GNode *, int, Job *);
-static void JobDoOutput(Job *, Boolean);
-static void JobInterrupt(int, int);
-static void JobRestartJobs(void);
-static int Compat_RunCommand(LstNode *, struct GNode *);
-
-static GNode *curTarg = NULL;
-static GNode *ENDNode;
-
-/**
- * Create a fifo file with a uniq filename, and returns a file
- * descriptor to that fifo.
- */
-static int
-mkfifotemp(char *template)
-{
- char *start;
- char *pathend;
- char *ptr;
- const unsigned char padchar[] =
- "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
-
- if (template[0] == '\0') {
- errno = EINVAL; /* bad input string */
- return (-1);
- }
-
- /* Find end of template string. */
- pathend = strchr(template, '\0');
- ptr = pathend - 1;
-
- /*
- * Starting from the end of the template replace spaces with 'X' in
- * them with random characters until there are no more 'X'.
- */
- while (ptr >= template && *ptr == 'X') {
- uint32_t rand_num =
-#if __FreeBSD_version < 800041
- arc4random() % (sizeof(padchar) - 1);
-#else
- arc4random_uniform(sizeof(padchar) - 1);
-#endif
- *ptr-- = padchar[rand_num];
- }
- start = ptr + 1;
-
- /* Check the target directory. */
- for (; ptr > template; --ptr) {
- if (*ptr == '/') {
- struct stat sbuf;
-
- *ptr = '\0';
- if (stat(template, &sbuf) != 0)
- return (-1);
-
- if (!S_ISDIR(sbuf.st_mode)) {
- errno = ENOTDIR;
- return (-1);
- }
- *ptr = '/';
- break;
- }
- }
-
- for (;;) {
- if (mkfifo(template, 0600) == 0) {
- int fd;
-
- if ((fd = open(template, O_RDWR, 0600)) < 0) {
- unlink(template);
- return (-1);
- } else {
- return (fd);
- }
- } else {
- if (errno != EEXIST) {
- return (-1);
- }
- }
-
- /*
- * If we have a collision, cycle through the space of
- * filenames.
- */
- for (ptr = start;;) {
- char *pad;
-
- if (*ptr == '\0' || ptr == pathend)
- return (-1);
-
- pad = strchr(padchar, *ptr);
- if (pad == NULL || *++pad == '\0') {
- *ptr++ = padchar[0];
- } else {
- *ptr++ = *pad;
- break;
- }
- }
- }
- /*NOTREACHED*/
-}
-
-static void
-catch_child(int sig __unused)
-{
-}
-
-/**
- */
-void
-Proc_Init(void)
-{
- /*
- * Catch SIGCHLD so that we get kicked out of select() when we
- * need to look at a child. This is only known to matter for the
- * -j case (perhaps without -P).
- *
- * XXX this is intentionally misplaced.
- */
- struct sigaction sa;
-
- sigemptyset(&sa.sa_mask);
- sa.sa_flags = SA_RESTART | SA_NOCLDSTOP;
- sa.sa_handler = catch_child;
- sigaction(SIGCHLD, &sa, NULL);
-}
-
-/**
- * Wait for child process to terminate.
- */
-static int
-ProcWait(ProcStuff *ps)
-{
- pid_t pid;
- int status;
-
- /*
- * Wait for the process to exit.
- */
- for (;;) {
- pid = wait(&status);
- if (pid == -1 && errno != EINTR) {
- Fatal("error in wait: %d", pid);
- /* NOTREACHED */
- }
- if (pid == ps->child_pid) {
- break;
- }
- if (interrupted) {
- break;
- }
- }
-
- return (status);
-}
-
-/**
- * JobCatchSignal
- * Got a signal. Set global variables and hope that someone will
- * handle it.
- */
-static void
-JobCatchSig(int signo)
-{
-
- interrupted = signo;
-}
-
-/**
- * JobPassSig --
- * Pass a signal on to all local jobs if
- * USE_PGRP is defined, then die ourselves.
- *
- * Side Effects:
- * We die by the same signal.
- */
-static void
-JobPassSig(int signo)
-{
- Job *job;
- sigset_t nmask, omask;
- struct sigaction act;
-
- sigemptyset(&nmask);
- sigaddset(&nmask, signo);
- sigprocmask(SIG_SETMASK, &nmask, &omask);
-
- DEBUGF(JOB, ("JobPassSig(%d) called.\n", signo));
- TAILQ_FOREACH(job, &jobs, link) {
- DEBUGF(JOB, ("JobPassSig passing signal %d to child %jd.\n",
- signo, (intmax_t)job->pid));
- KILL(job->pid, signo);
- }
-
- /*
- * Deal with proper cleanup based on the signal received. We only run
- * the .INTERRUPT target if the signal was in fact an interrupt.
- * The other three termination signals are more of a "get out *now*"
- * command.
- */
- if (signo == SIGINT) {
- JobInterrupt(TRUE, signo);
- } else if (signo == SIGHUP || signo == SIGTERM || signo == SIGQUIT) {
- JobInterrupt(FALSE, signo);
- }
-
- /*
- * Leave gracefully if SIGQUIT, rather than core dumping.
- */
- if (signo == SIGQUIT) {
- signo = SIGINT;
- }
-
- /*
- * Send ourselves the signal now we've given the message to everyone
- * else. Note we block everything else possible while we're getting
- * the signal. This ensures that all our jobs get continued when we
- * wake up before we take any other signal.
- * XXX this comment seems wrong.
- */
- act.sa_handler = SIG_DFL;
- sigemptyset(&act.sa_mask);
- act.sa_flags = 0;
- sigaction(signo, &act, NULL);
-
- DEBUGF(JOB, ("JobPassSig passing signal to self, mask = %x.\n",
- ~0 & ~(1 << (signo - 1))));
- signal(signo, SIG_DFL);
-
- KILL(getpid(), signo);
-
- signo = SIGCONT;
- TAILQ_FOREACH(job, &jobs, link) {
- DEBUGF(JOB, ("JobPassSig passing signal %d to child %jd.\n",
- signo, (intmax_t)job->pid));
- KILL(job->pid, signo);
- }
-
- sigprocmask(SIG_SETMASK, &omask, NULL);
- sigprocmask(SIG_SETMASK, &omask, NULL);
- act.sa_handler = JobPassSig;
- sigaction(signo, &act, NULL);
-}
-
-/**
- * JobPrintCommand --
- * Put out another command for the given job. If the command starts
- * with an @ or a - we process it specially. In the former case,
- * so long as the -s and -n flags weren't given to make, we stick
- * a shell-specific echoOff command in the script. In the latter,
- * we ignore errors for the entire job, unless the shell has error
- * control.
- * If the command is just "..." we take all future commands for this
- * job to be commands to be executed once the entire graph has been
- * made and return non-zero to signal that the end of the commands
- * was reached. These commands are later attached to the postCommands
- * node and executed by Job_Finish when all things are done.
- * This function is called from JobStart via LST_FOREACH.
- *
- * Results:
- * Always 0, unless the command was "..."
- *
- * Side Effects:
- * If the command begins with a '-' and the shell has no error control,
- * the JOB_IGNERR flag is set in the job descriptor.
- * If the command is "..." and we're not ignoring such things,
- * tailCmds is set to the successor node of the cmd.
- * numCommands is incremented if the command is actually printed.
- */
-static int
-JobPrintCommand(LstNode *cmdNode, Job *job)
-{
- Boolean noSpecials; /* true if we shouldn't worry about
- * inserting special commands into
- * the input stream. */
- Boolean shutUp = FALSE; /* true if we put a no echo command
- * into the command file */
- Boolean errOff = FALSE; /* true if we turned error checking
- * off before printing the command
- * and need to turn it back on */
- const char *cmdTemplate;/* Template to use when printing the command */
- char *cmd; /* Expanded command */
-
- noSpecials = (noExecute && !(job->node->type & OP_MAKE));
-
-#define DBPRINTF(fmt, arg) \
- DEBUGF(JOB, (fmt, arg)); \
- fprintf(job->cmdFILE, fmt, arg); \
- fflush(job->cmdFILE);
-
- /*
- * For debugging, we replace each command with the result of expanding
- * the variables in the command.
- */
- cmd = Buf_Peel(Var_Subst(Lst_Datum(cmdNode), job->node, FALSE));
- if (strcmp(cmd, "...") == 0) {
- free(cmd);
- job->node->type |= OP_SAVE_CMDS;
- if ((job->flags & JOB_IGNDOTS) == 0) {
- job->tailCmds = Lst_Succ(cmdNode);
- return (1);
- }
- return (0);
- }
- Lst_Replace(cmdNode, cmd);
-
- /*
- * Check for leading @', -' or +'s to control echoing, error checking,
- * and execution on -n.
- */
- while (*cmd == '@' || *cmd == '-' || *cmd == '+') {
- switch (*cmd) {
-
- case '@':
- shutUp = DEBUG(LOUD) ? FALSE : TRUE;
- break;
-
- case '-':
- errOff = TRUE;
- break;
-
- case '+':
- if (noSpecials) {
- /*
- * We're not actually exececuting anything...
- * but this one needs to be - use compat mode
- * just for it.
- */
- Compat_RunCommand(cmdNode, job->node);
- return (0);
- }
- break;
- }
- cmd++;
- }
-
- while (isspace((unsigned char)*cmd))
- cmd++;
-
- /*
- * Ignore empty commands
- */
- if (*cmd == '\0') {
- return (0);
- }
-
- cmdTemplate = "%s\n";
- numCommands += 1;
-
- if (shutUp) {
- if (!(job->flags & JOB_SILENT) && !noSpecials &&
- commandShell->hasEchoCtl) {
- DBPRINTF("%s\n", commandShell->echoOff);
- } else {
- shutUp = FALSE;
- }
- }
-
- if (errOff) {
- if (!(job->flags & JOB_IGNERR) && !noSpecials) {
- if (commandShell->hasErrCtl) {
- /*
- * We don't want the error-control commands
- * showing up either, so we turn off echoing
- * while executing them. We could put another
- * field in the shell structure to tell
- * JobDoOutput to look for this string too,
- * but why make it any more complex than
- * it already is?
- */
- if (!(job->flags & JOB_SILENT) && !shutUp &&
- commandShell->hasEchoCtl) {
- DBPRINTF("%s\n", commandShell->echoOff);
- DBPRINTF("%s\n", commandShell->ignErr);
- DBPRINTF("%s\n", commandShell->echoOn);
- } else {
- DBPRINTF("%s\n", commandShell->ignErr);
- }
- } else if (commandShell->ignErr &&
- *commandShell->ignErr != '\0') {
- /*
- * The shell has no error control, so we need to
- * be weird to get it to ignore any errors from
- * the command. If echoing is turned on, we turn
- * it off and use the errCheck template to echo
- * the command. Leave echoing off so the user
- * doesn't see the weirdness we go through to
- * ignore errors. Set cmdTemplate to use the
- * weirdness instead of the simple "%s\n"
- * template.
- */
- if (!(job->flags & JOB_SILENT) && !shutUp &&
- commandShell->hasEchoCtl) {
- DBPRINTF("%s\n", commandShell->echoOff);
- DBPRINTF(commandShell->errCheck, cmd);
- shutUp = TRUE;
- }
- cmdTemplate = commandShell->ignErr;
- /*
- * The error ignoration (hee hee) is already
- * taken care of by the ignErr template, so
- * pretend error checking is still on.
- */
- errOff = FALSE;
- } else {
- errOff = FALSE;
- }
- } else {
- errOff = FALSE;
- }
- }
-
- DBPRINTF(cmdTemplate, cmd);
-
- if (errOff) {
- /*
- * If echoing is already off, there's no point in issuing the
- * echoOff command. Otherwise we issue it and pretend it was on
- * for the whole command...
- */
- if (!shutUp && !(job->flags & JOB_SILENT) &&
- commandShell->hasEchoCtl) {
- DBPRINTF("%s\n", commandShell->echoOff);
- shutUp = TRUE;
- }
- DBPRINTF("%s\n", commandShell->errCheck);
- }
- if (shutUp) {
- DBPRINTF("%s\n", commandShell->echoOn);
- }
- return (0);
-}
-
-/**
- * JobClose --
- * Called to close both input and output pipes when a job is finished.
- *
- * Side Effects:
- * The file descriptors associated with the job are closed.
- */
-static void
-JobClose(Job *job)
-{
-
- if (usePipes) {
-#if !defined(USE_KQUEUE)
- FD_CLR(job->inPipe, &outputs);
-#endif
- if (job->outPipe != job->inPipe) {
- close(job->outPipe);
- }
- JobDoOutput(job, TRUE);
- close(job->inPipe);
- } else {
- close(job->outFd);
- JobDoOutput(job, TRUE);
- }
-}
-
-/**
- * JobFinish --
- * Do final processing for the given job including updating
- * parents and starting new jobs as available/necessary. Note
- * that we pay no attention to the JOB_IGNERR flag here.
- * This is because when we're called because of a noexecute flag
- * or something, jstat.w_status is 0 and when called from
- * Job_CatchChildren, the status is zeroed if it s/b ignored.
- *
- * Side Effects:
- * Some nodes may be put on the toBeMade queue.
- * Final commands for the job are placed on postCommands.
- *
- * If we got an error and are aborting (aborting == ABORT_ERROR) and
- * the job list is now empty, we are done for the day.
- * If we recognized an error (makeErrors !=0), we set the aborting flag
- * to ABORT_ERROR so no more jobs will be started.
- */
-static void
-JobFinish(Job *job, int *status)
-{
- Boolean done;
- LstNode *ln;
-
- if (WIFEXITED(*status)) {
- int job_status = WEXITSTATUS(*status);
-
- JobClose(job);
- /*
- * Deal with ignored errors in -B mode. We need to
- * print a message telling of the ignored error as
- * well as setting status.w_status to 0 so the next
- * command gets run. To do this, we set done to be
- * TRUE if in -B mode and the job exited non-zero.
- */
- if (job_status == 0) {
- done = FALSE;
- } else {
- if (job->flags & JOB_IGNERR) {
- done = TRUE;
- } else {
- /*
- * If it exited non-zero and either we're
- * doing things our way or we're not ignoring
- * errors, the job is finished. Similarly, if
- * the shell died because of a signal the job
- * is also finished. In these cases, finish
- * out the job's output before printing the
- * exit status...
- */
- done = TRUE;
- if (job->cmdFILE != NULL &&
- job->cmdFILE != stdout) {
- fclose(job->cmdFILE);
- }
-
- }
- }
- } else if (WIFSIGNALED(*status)) {
- if (WTERMSIG(*status) == SIGCONT) {
- /*
- * No need to close things down or anything.
- */
- done = FALSE;
- } else {
- /*
- * If it exited non-zero and either we're
- * doing things our way or we're not ignoring
- * errors, the job is finished. Similarly, if
- * the shell died because of a signal the job
- * is also finished. In these cases, finish
- * out the job's output before printing the
- * exit status...
- */
- JobClose(job);
- if (job->cmdFILE != NULL &&
- job->cmdFILE != stdout) {
- fclose(job->cmdFILE);
- }
- done = TRUE;
- }
- } else {
- /*
- * No need to close things down or anything.
- */
- done = FALSE;
- }
-
- if (WIFEXITED(*status)) {
- if (done || DEBUG(JOB)) {
- FILE *out;
-
- if (compatMake &&
- !usePipes &&
- (job->flags & JOB_IGNERR)) {
- /*
- * If output is going to a file and this job
- * is ignoring errors, arrange to have the
- * exit status sent to the output file as
- * well.
- */
- out = fdopen(job->outFd, "w");
- if (out == NULL)
- Punt("Cannot fdopen");
- } else {
- out = stdout;
- }
-
- DEBUGF(JOB, ("Process %jd exited.\n",
- (intmax_t)job->pid));
-
- if (WEXITSTATUS(*status) == 0) {
- if (DEBUG(JOB)) {
- if (usePipes && job->node != lastNode) {
- MESSAGE(out, job->node);
- lastNode = job->node;
- }
- fprintf(out,
- "*** [%s] Completed successfully\n",
- job->node->name);
- }
- } else {
- if (usePipes && job->node != lastNode) {
- MESSAGE(out, job->node);
- lastNode = job->node;
- }
- fprintf(out, "*** [%s] Error code %d%s\n",
- job->node->name,
- WEXITSTATUS(*status),
- (job->flags & JOB_IGNERR) ?
- " (ignored)" : "");
-
- if (job->flags & JOB_IGNERR) {
- *status = 0;
- }
- }
-
- fflush(out);
- }
- } else if (WIFSIGNALED(*status)) {
- if (done || DEBUG(JOB) || (WTERMSIG(*status) == SIGCONT)) {
- FILE *out;
-
- if (compatMake &&
- !usePipes &&
- (job->flags & JOB_IGNERR)) {
- /*
- * If output is going to a file and this job
- * is ignoring errors, arrange to have the
- * exit status sent to the output file as
- * well.
- */
- out = fdopen(job->outFd, "w");
- if (out == NULL)
- Punt("Cannot fdopen");
- } else {
- out = stdout;
- }
-
- if (WTERMSIG(*status) == SIGCONT) {
- /*
- * If the beastie has continued, shift the
- * Job from the stopped list to the running
- * one (or re-stop it if concurrency is
- * exceeded) and go and get another child.
- */
- if (job->flags & (JOB_RESUME | JOB_RESTART)) {
- if (usePipes && job->node != lastNode) {
- MESSAGE(out, job->node);
- lastNode = job->node;
- }
- fprintf(out, "*** [%s] Continued\n",
- job->node->name);
- }
- if (!(job->flags & JOB_CONTINUING)) {
- DEBUGF(JOB, ("Warning: process %jd was not "
- "continuing.\n", (intmax_t) job->pid));
- }
- job->flags &= ~JOB_CONTINUING;
- TAILQ_INSERT_TAIL(&jobs, job, link);
- nJobs += 1;
- DEBUGF(JOB, ("Process %jd is continuing locally.\n",
- (intmax_t) job->pid));
- if (nJobs == maxJobs) {
- jobFull = TRUE;
- DEBUGF(JOB, ("Job queue is full.\n"));
- }
- fflush(out);
- return;
-
- } else {
- if (usePipes && job->node != lastNode) {
- MESSAGE(out, job->node);
- lastNode = job->node;
- }
- fprintf(out,
- "*** [%s] Signal %d\n", job->node->name,
- WTERMSIG(*status));
- fflush(out);
- }
- }
- } else {
- /* STOPPED */
- FILE *out;
-
- if (compatMake && !usePipes && (job->flags & JOB_IGNERR)) {
- /*
- * If output is going to a file and this job
- * is ignoring errors, arrange to have the
- * exit status sent to the output file as
- * well.
- */
- out = fdopen(job->outFd, "w");
- if (out == NULL)
- Punt("Cannot fdopen");
- } else {
- out = stdout;
- }
-
- DEBUGF(JOB, ("Process %jd stopped.\n", (intmax_t) job->pid));
- if (usePipes && job->node != lastNode) {
- MESSAGE(out, job->node);
- lastNode = job->node;
- }
- fprintf(out, "*** [%s] Stopped -- signal %d\n",
- job->node->name, WSTOPSIG(*status));
- job->flags |= JOB_RESUME;
- TAILQ_INSERT_TAIL(&stoppedJobs, job, link);
- fflush(out);
- return;
- }
-
- /*
- * Now handle the -B-mode stuff. If the beast still isn't finished,
- * try and restart the job on the next command. If JobStart says it's
- * ok, it's ok. If there's an error, this puppy is done.
- */
- if (compatMake && WIFEXITED(*status) &&
- Lst_Succ(job->node->compat_command) != NULL) {
- switch (JobStart(job->node, job->flags & JOB_IGNDOTS, job)) {
- case JOB_RUNNING:
- done = FALSE;
- break;
- case JOB_ERROR:
- done = TRUE;
- W_SETEXITSTATUS(status, 1);
- break;
- case JOB_FINISHED:
- /*
- * If we got back a JOB_FINISHED code, JobStart has
- * already called Make_Update and freed the job
- * descriptor. We set done to false here to avoid fake
- * cycles and double frees. JobStart needs to do the
- * update so we can proceed up the graph when given
- * the -n flag..
- */
- done = FALSE;
- break;
- default:
- break;
- }
- } else {
- done = TRUE;
- }
-
- if (done && aborting != ABORT_ERROR &&
- aborting != ABORT_INTERRUPT && *status == 0) {
- /*
- * As long as we aren't aborting and the job didn't return a
- * non-zero status that we shouldn't ignore, we call
- * Make_Update to update the parents. In addition, any saved
- * commands for the node are placed on the .END target.
- */
- for (ln = job->tailCmds; ln != NULL; ln = LST_NEXT(ln)) {
- Lst_AtEnd(&postCommands->commands,
- Buf_Peel(
- Var_Subst(Lst_Datum(ln), job->node, FALSE)));
- }
-
- job->node->made = MADE;
- Make_Update(job->node);
- free(job);
-
- } else if (*status != 0) {
- makeErrors++;
- free(job);
- }
-
- JobRestartJobs();
-
- /*
- * Set aborting if any error.
- */
- if (makeErrors && !keepgoing && aborting != ABORT_INTERRUPT) {
- /*
- * If we found any errors in this batch of children and the -k
- * flag wasn't given, we set the aborting flag so no more jobs
- * get started.
- */
- aborting = ABORT_ERROR;
- }
-
- if (aborting == ABORT_ERROR && Job_Empty()) {
- /*
- * If we are aborting and the job table is now empty, we finish.
- */
- Finish(makeErrors);
- }
-}
-
-/**
- * Job_Touch
- * Touch the given target. Called by JobStart when the -t flag was
- * given. Prints messages unless told to be silent.
- *
- * Side Effects:
- * The data modification of the file is changed. In addition, if the
- * file did not exist, it is created.
- */
-void
-Job_Touch(GNode *gn, Boolean silent)
-{
- int streamID; /* ID of stream opened to do the touch */
- struct utimbuf times; /* Times for utime() call */
-
- if (gn->type & (OP_JOIN | OP_USE | OP_EXEC | OP_OPTIONAL)) {
- /*
- * .JOIN, .USE, .ZEROTIME and .OPTIONAL targets are "virtual"
- * targets and, as such, shouldn't really be created.
- */
- return;
- }
-
- if (!silent) {
- fprintf(stdout, "touch %s\n", gn->name);
- fflush(stdout);
- }
-
- if (noExecute) {
- return;
- }
-
- if (gn->type & OP_ARCHV) {
- Arch_Touch(gn);
- } else if (gn->type & OP_LIB) {
- Arch_TouchLib(gn);
- } else {
- char *file = gn->path ? gn->path : gn->name;
-
- times.actime = times.modtime = now;
- if (utime(file, &times) < 0) {
- streamID = open(file, O_RDWR | O_CREAT, 0666);
-
- if (streamID >= 0) {
- char c;
-
- /*
- * Read and write a byte to the file to change
- * the modification time, then close the file.
- */
- if (read(streamID, &c, 1) == 1) {
- lseek(streamID, (off_t)0, SEEK_SET);
- write(streamID, &c, 1);
- }
-
- close(streamID);
- } else {
- fprintf(stdout, "*** couldn't touch %s: %s",
- file, strerror(errno));
- fflush(stdout);
- }
- }
- }
-}
-
-/**
- * Job_CheckCommands
- * Make sure the given node has all the commands it needs.
- *
- * Results:
- * TRUE if the commands list is/was ok.
- *
- * Side Effects:
- * The node will have commands from the .DEFAULT rule added to it
- * if it needs them.
- */
-Boolean
-Job_CheckCommands(GNode *gn, void (*abortProc)(const char *, ...))
-{
-
- if (OP_NOP(gn->type) && Lst_IsEmpty(&gn->commands) &&
- (gn->type & OP_LIB) == 0) {
- /*
- * No commands. Look for .DEFAULT rule from which we might infer
- * commands.
- */
- if (DEFAULT != NULL && !Lst_IsEmpty(&DEFAULT->commands)) {
- /*
- * Make only looks for a .DEFAULT if the node was
- * never the target of an operator, so that's what we
- * do too. If a .DEFAULT was given, we substitute its
- * commands for gn's commands and set the IMPSRC
- * variable to be the target's name The DEFAULT node
- * acts like a transformation rule, in that gn also
- * inherits any attributes or sources attached to
- * .DEFAULT itself.
- */
- Make_HandleUse(DEFAULT, gn);
- Var_Set(IMPSRC, Var_Value(TARGET, gn), gn);
-
- } else if (Dir_MTime(gn) == 0) {
- /*
- * The node wasn't the target of an operator we have
- * no .DEFAULT rule to go on and the target doesn't
- * already exist. There's nothing more we can do for
- * this branch. If the -k flag wasn't given, we stop
- * in our tracks, otherwise we just don't update
- * this node's parents so they never get examined.
- */
- static const char msg[] =
- "make: don't know how to make";
-
- if (gn->type & OP_OPTIONAL) {
- fprintf(stdout, "%s %s(ignored)\n",
- msg, gn->name);
- fflush(stdout);
- } else if (keepgoing) {
- fprintf(stdout, "%s %s(continuing)\n",
- msg, gn->name);
- fflush(stdout);
- return (FALSE);
- } else {
-#ifndef WITHOUT_OLD_JOKE
- if (strcmp(gn->name,"love") == 0)
- (*abortProc)("Not war.");
- else
-#endif
- (*abortProc)("%s %s. Stop",
- msg, gn->name);
- return (FALSE);
- }
- }
- }
- return (TRUE);
-}
-
-/**
- * JobExec
- * Execute the shell for the given job. Called from JobStart and
- * JobRestart.
- *
- * Side Effects:
- * A shell is executed, outputs is altered and the Job structure added
- * to the job table.
- */
-static void
-JobExec(Job *job, char **argv)
-{
- ProcStuff ps;
-
- if (DEBUG(JOB)) {
- int i;
-
- DEBUGF(JOB, ("Running %s\n", job->node->name));
- DEBUGF(JOB, ("\tCommand: "));
- for (i = 0; argv[i] != NULL; i++) {
- DEBUGF(JOB, ("%s ", argv[i]));
- }
- DEBUGF(JOB, ("\n"));
- }
-
- /*
- * Some jobs produce no output and it's disconcerting to have
- * no feedback of their running (since they produce no output, the
- * banner with their name in it never appears). This is an attempt to
- * provide that feedback, even if nothing follows it.
- */
- if (lastNode != job->node && (job->flags & JOB_FIRST) &&
- !(job->flags & JOB_SILENT)) {
- MESSAGE(stdout, job->node);
- lastNode = job->node;
- }
-
- ps.in = FILENO(job->cmdFILE);
- if (usePipes) {
- /*
- * Set up the child's output to be routed through the
- * pipe we've created for it.
- */
- ps.out = job->outPipe;
- } else {
- /*
- * We're capturing output in a file, so we duplicate
- * the descriptor to the temporary file into the
- * standard output.
- */
- ps.out = job->outFd;
- }
- ps.err = STDERR_FILENO;
-
- ps.merge_errors = 1;
- ps.pgroup = 1;
- ps.searchpath = 0;
-
- ps.argv = argv;
- ps.argv_free = 0;
-
- /*
- * Fork. Warning since we are doing vfork() instead of fork(),
- * do not allocate memory in the child process!
- */
- if ((ps.child_pid = vfork()) == -1) {
- Punt("Cannot fork");
-
-
- } else if (ps.child_pid == 0) {
- /*
- * Child
- */
- if (fifoFd >= 0)
- close(fifoFd);
-
- Proc_Exec(&ps);
- /* NOTREACHED */
- }
-
- /*
- * Parent
- */
- job->pid = ps.child_pid;
-
- if (usePipes && (job->flags & JOB_FIRST)) {
- /*
- * The first time a job is run for a node, we set the
- * current position in the buffer to the beginning and
- * mark another stream to watch in the outputs mask.
- */
-#ifdef USE_KQUEUE
- struct kevent kev[2];
-#endif
- job->curPos = 0;
-
-#if defined(USE_KQUEUE)
- EV_SET(&kev[0], job->inPipe, EVFILT_READ, EV_ADD, 0, 0, job);
- EV_SET(&kev[1], job->pid, EVFILT_PROC,
- EV_ADD | EV_ONESHOT, NOTE_EXIT, 0, NULL);
- if (kevent(kqfd, kev, 2, NULL, 0, NULL) != 0) {
- /*
- * kevent() will fail if the job is already
- * finished
- */
- if (errno != EINTR && errno != EBADF && errno != ESRCH)
- Punt("kevent: %s", strerror(errno));
- }
-#else
- FD_SET(job->inPipe, &outputs);
-#endif /* USE_KQUEUE */
- }
-
- if (job->cmdFILE != NULL && job->cmdFILE != stdout) {
- fclose(job->cmdFILE);
- job->cmdFILE = NULL;
- }
-
- /*
- * Now the job is actually running, add it to the table.
- */
- nJobs += 1;
- TAILQ_INSERT_TAIL(&jobs, job, link);
- if (nJobs == maxJobs) {
- jobFull = TRUE;
- }
-}
-
-/**
- * JobMakeArgv
- * Create the argv needed to execute the shell for a given job.
- */
-static void
-JobMakeArgv(Job *job, char **argv)
-{
- int argc;
- static char args[10]; /* For merged arguments */
-
- argv[0] = commandShell->name;
- argc = 1;
-
- if ((commandShell->exit && *commandShell->exit != '-') ||
- (commandShell->echo && *commandShell->echo != '-')) {
- /*
- * At least one of the flags doesn't have a minus before it, so
- * merge them together. Have to do this because the *(&(@*#*&#$#
- * Bourne shell thinks its second argument is a file to source.
- * Grrrr. Note the ten-character limitation on the combined
- * arguments.
- */
- sprintf(args, "-%s%s", (job->flags & JOB_IGNERR) ? "" :
- commandShell->exit ? commandShell->exit : "",
- (job->flags & JOB_SILENT) ? "" :
- commandShell->echo ? commandShell->echo : "");
-
- if (args[1]) {
- argv[argc] = args;
- argc++;
- }
- } else {
- if (!(job->flags & JOB_IGNERR) && commandShell->exit) {
- argv[argc] = commandShell->exit;
- argc++;
- }
- if (!(job->flags & JOB_SILENT) && commandShell->echo) {
- argv[argc] = commandShell->echo;
- argc++;
- }
- }
- argv[argc] = NULL;
-}
-
-/**
- * JobRestart
- * Restart a job that stopped for some reason. The job must be neither
- * on the jobs nor on the stoppedJobs list.
- *
- * Side Effects:
- * jobFull will be set if the job couldn't be run.
- */
-static void
-JobRestart(Job *job)
-{
-
- if (job->flags & JOB_RESTART) {
- /*
- * Set up the control arguments to the shell. This is based on
- * the flags set earlier for this job. If the JOB_IGNERR flag
- * is clear, the 'exit' flag of the commandShell is used to
- * cause it to exit upon receiving an error. If the JOB_SILENT
- * flag is clear, the 'echo' flag of the commandShell is used
- * to get it to start echoing as soon as it starts
- * processing commands.
- */
- char *argv[4];
-
- JobMakeArgv(job, argv);
-
- DEBUGF(JOB, ("Restarting %s...", job->node->name));
- if (nJobs >= maxJobs && !(job->flags & JOB_SPECIAL)) {
- /*
- * Not allowed to run -- put it back on the hold
- * queue and mark the table full
- */
- DEBUGF(JOB, ("holding\n"));
- TAILQ_INSERT_HEAD(&stoppedJobs, job, link);
- jobFull = TRUE;
- DEBUGF(JOB, ("Job queue is full.\n"));
- return;
- } else {
- /*
- * Job may be run locally.
- */
- DEBUGF(JOB, ("running locally\n"));
- }
- JobExec(job, argv);
-
- } else {
- /*
- * The job has stopped and needs to be restarted.
- * Why it stopped, we don't know...
- */
- DEBUGF(JOB, ("Resuming %s...", job->node->name));
- if ((nJobs < maxJobs || ((job->flags & JOB_SPECIAL) &&
- maxJobs == 0)) && nJobs != maxJobs) {
- /*
- * If we haven't reached the concurrency limit already
- * (or the job must be run and maxJobs is 0), it's ok
- * to resume it.
- */
- Boolean error;
- int status;
-
- error = (KILL(job->pid, SIGCONT) != 0);
-
- if (!error) {
- /*
- * Make sure the user knows we've continued
- * the beast and actually put the thing in the
- * job table.
- */
- job->flags |= JOB_CONTINUING;
- status = 0;
- W_SETTERMSIG(&status, SIGCONT);
- JobFinish(job, &status);
-
- job->flags &= ~(JOB_RESUME|JOB_CONTINUING);
- DEBUGF(JOB, ("done\n"));
- } else {
- Error("couldn't resume %s: %s",
- job->node->name, strerror(errno));
- status = 0;
- W_SETEXITSTATUS(&status, 1);
- JobFinish(job, &status);
- }
- } else {
- /*
- * Job cannot be restarted. Mark the table as full and
- * place the job back on the list of stopped jobs.
- */
- DEBUGF(JOB, ("table full\n"));
- TAILQ_INSERT_HEAD(&stoppedJobs, job, link);
- jobFull = TRUE;
- DEBUGF(JOB, ("Job queue is full.\n"));
- }
- }
-}
-
-/**
- * JobStart
- * Start a target-creation process going for the target described
- * by the graph node gn.
- *
- * Results:
- * JOB_ERROR if there was an error in the commands, JOB_FINISHED
- * if there isn't actually anything left to do for the job and
- * JOB_RUNNING if the job has been started.
- *
- * Side Effects:
- * A new Job node is created and added to the list of running
- * jobs. PMake is forked and a child shell created.
- */
-static int
-JobStart(GNode *gn, int flags, Job *previous)
-{
- Job *job; /* new job descriptor */
- char *argv[4]; /* Argument vector to shell */
- Boolean cmdsOK; /* true if the nodes commands were all right */
- Boolean noExec; /* Set true if we decide not to run the job */
- int tfd; /* File descriptor for temp file */
- LstNode *ln;
- char tfile[PATH_MAX];
- const char *tdir;
-
- if (interrupted) {
- JobPassSig(interrupted);
- return (JOB_ERROR);
- }
- if (previous != NULL) {
- previous->flags &= ~(JOB_FIRST | JOB_IGNERR | JOB_SILENT);
- job = previous;
- } else {
- job = emalloc(sizeof(Job));
- flags |= JOB_FIRST;
- }
-
- job->node = gn;
- job->tailCmds = NULL;
-
- /*
- * Set the initial value of the flags for this job based on the global
- * ones and the node's attributes... Any flags supplied by the caller
- * are also added to the field.
- */
- job->flags = 0;
- if (Targ_Ignore(gn)) {
- job->flags |= JOB_IGNERR;
- }
- if (Targ_Silent(gn)) {
- job->flags |= JOB_SILENT;
- }
- job->flags |= flags;
-
- /*
- * Check the commands now so any attributes from .DEFAULT have a chance
- * to migrate to the node.
- */
- if (!compatMake && (job->flags & JOB_FIRST)) {
- cmdsOK = Job_CheckCommands(gn, Error);
- } else {
- cmdsOK = TRUE;
- }
-
- if ((tdir = getenv("TMPDIR")) == NULL)
- tdir = _PATH_TMP;
-
- /*
- * If the -n flag wasn't given, we open up OUR (not the child's)
- * temporary file to stuff commands in it. The thing is rd/wr so we
- * don't need to reopen it to feed it to the shell. If the -n flag
- * *was* given, we just set the file to be stdout. Cute, huh?
- */
- if ((gn->type & OP_MAKE) || (!noExecute && !touchFlag)) {
- /*
- * We're serious here, but if the commands were bogus, we're
- * also dead...
- */
- if (!cmdsOK) {
- DieHorribly();
- }
-
- snprintf(tfile, sizeof(tfile), "%s/%s", tdir, TMPPAT);
- if ((tfd = mkstemp(tfile)) == -1)
- Punt("Cannot create temp file: %s", strerror(errno));
- job->cmdFILE = fdopen(tfd, "w+");
- eunlink(tfile);
- if (job->cmdFILE == NULL) {
- close(tfd);
- Punt("Could not open %s", tfile);
- }
- fcntl(FILENO(job->cmdFILE), F_SETFD, 1);
- /*
- * Send the commands to the command file, flush all its
- * buffers then rewind and remove the thing.
- */
- noExec = FALSE;
-
- /*
- * Used to be backwards; replace when start doing multiple
- * commands per shell.
- */
- if (compatMake) {
- /*
- * Be compatible: If this is the first time for this
- * node, verify its commands are ok and open the
- * commands list for sequential access by later
- * invocations of JobStart. Once that is done, we take
- * the next command off the list and print it to the
- * command file. If the command was an ellipsis, note
- * that there's nothing more to execute.
- */
- if (job->flags & JOB_FIRST)
- gn->compat_command = Lst_First(&gn->commands);
- else
- gn->compat_command =
- Lst_Succ(gn->compat_command);
-
- if (gn->compat_command == NULL ||
- JobPrintCommand(gn->compat_command, job))
- noExec = TRUE;
-
- if (noExec && !(job->flags & JOB_FIRST)) {
- /*
- * If we're not going to execute anything, the
- * job is done and we need to close down the
- * various file descriptors we've opened for
- * output, then call JobDoOutput to catch the
- * final characters or send the file to the
- * screen... Note that the i/o streams are only
- * open if this isn't the first job. Note also
- * that this could not be done in
- * Job_CatchChildren b/c it wasn't clear if
- * there were more commands to execute or not...
- */
- JobClose(job);
- }
- } else {
- /*
- * We can do all the commands at once. hooray for sanity
- */
- numCommands = 0;
- LST_FOREACH(ln, &gn->commands) {
- if (JobPrintCommand(ln, job))
- break;
- }
-
- /*
- * If we didn't print out any commands to the shell
- * script, there's not much point in executing the
- * shell, is there?
- */
- if (numCommands == 0) {
- noExec = TRUE;
- }
- }
-
- } else if (noExecute) {
- /*
- * Not executing anything -- just print all the commands to
- * stdout in one fell swoop. This will still set up
- * job->tailCmds correctly.
- */
- if (lastNode != gn) {
- MESSAGE(stdout, gn);
- lastNode = gn;
- }
- job->cmdFILE = stdout;
-
- /*
- * Only print the commands if they're ok, but don't die if
- * they're not -- just let the user know they're bad and keep
- * going. It doesn't do any harm in this case and may do
- * some good.
- */
- if (cmdsOK) {
- LST_FOREACH(ln, &gn->commands) {
- if (JobPrintCommand(ln, job))
- break;
- }
- }
- /*
- * Don't execute the shell, thank you.
- */
- noExec = TRUE;
-
- } else {
- /*
- * Just touch the target and note that no shell should be
- * executed. Set cmdFILE to stdout to make life easier. Check
- * the commands, too, but don't die if they're no good -- it
- * does no harm to keep working up the graph.
- */
- job->cmdFILE = stdout;
- Job_Touch(gn, job->flags & JOB_SILENT);
- noExec = TRUE;
- }
-
- /*
- * If we're not supposed to execute a shell, don't.
- */
- if (noExec) {
- /*
- * Unlink and close the command file if we opened one
- */
- if (job->cmdFILE != stdout) {
- if (job->cmdFILE != NULL)
- fclose(job->cmdFILE);
- } else {
- fflush(stdout);
- }
-
- /*
- * We only want to work our way up the graph if we aren't here
- * because the commands for the job were no good.
- */
- if (cmdsOK) {
- if (aborting == 0) {
- for (ln = job->tailCmds; ln != NULL;
- ln = LST_NEXT(ln)) {
- Lst_AtEnd(&postCommands->commands,
- Buf_Peel(Var_Subst(Lst_Datum(ln),
- job->node, FALSE)));
- }
- job->node->made = MADE;
- Make_Update(job->node);
- }
- free(job);
- return(JOB_FINISHED);
- } else {
- free(job);
- return(JOB_ERROR);
- }
- } else {
- fflush(job->cmdFILE);
- }
-
- /*
- * Set up the control arguments to the shell. This is based on the flags
- * set earlier for this job.
- */
- JobMakeArgv(job, argv);
-
- /*
- * If we're using pipes to catch output, create the pipe by which we'll
- * get the shell's output. If we're using files, print out that we're
- * starting a job and then set up its temporary-file name.
- */
- if (!compatMake || (job->flags & JOB_FIRST)) {
- if (usePipes) {
- int fd[2];
-
- if (pipe(fd) == -1)
- Punt("Cannot create pipe: %s", strerror(errno));
- job->inPipe = fd[0];
- job->outPipe = fd[1];
- fcntl(job->inPipe, F_SETFD, 1);
- fcntl(job->outPipe, F_SETFD, 1);
- } else {
- fprintf(stdout, "Remaking `%s'\n", gn->name);
- fflush(stdout);
- snprintf(job->outFile, sizeof(job->outFile), "%s/%s",
- tdir, TMPPAT);
- if ((job->outFd = mkstemp(job->outFile)) == -1)
- Punt("cannot create temp file: %s",
- strerror(errno));
- fcntl(job->outFd, F_SETFD, 1);
- }
- }
-
- if (nJobs >= maxJobs && !(job->flags & JOB_SPECIAL) && maxJobs != 0) {
- /*
- * We've hit the limit of concurrency, so put the job on hold
- * until some other job finishes. Note that the special jobs
- * (.BEGIN, .INTERRUPT and .END) may be run even when the
- * limit has been reached (e.g. when maxJobs == 0).
- */
- jobFull = TRUE;
-
- DEBUGF(JOB, ("Can only run job locally.\n"));
- job->flags |= JOB_RESTART;
- TAILQ_INSERT_TAIL(&stoppedJobs, job, link);
- } else {
- if (nJobs >= maxJobs) {
- /*
- * If we're running this job as a special case
- * (see above), at least say the table is full.
- */
- jobFull = TRUE;
- DEBUGF(JOB, ("Local job queue is full.\n"));
- }
- JobExec(job, argv);
- }
- return (JOB_RUNNING);
-}
-
-static char *
-JobOutput(Job *job, char *cp, char *endp, int msg)
-{
- char *ecp;
-
- if (commandShell->noPrint) {
- ecp = strstr(cp, commandShell->noPrint);
- while (ecp != NULL) {
- if (cp != ecp) {
- *ecp = '\0';
- if (msg && job->node != lastNode) {
- MESSAGE(stdout, job->node);
- lastNode = job->node;
- }
- /*
- * The only way there wouldn't be a newline
- * after this line is if it were the last in
- * the buffer. However, since the non-printable
- * comes after it, there must be a newline, so
- * we don't print one.
- */
- fprintf(stdout, "%s", cp);
- fflush(stdout);
- }
- cp = ecp + strlen(commandShell->noPrint);
- if (cp != endp) {
- /*
- * Still more to print, look again after
- * skipping the whitespace following the
- * non-printable command....
- */
- cp++;
- while (*cp == ' ' || *cp == '\t' ||
- *cp == '\n') {
- cp++;
- }
- ecp = strstr(cp, commandShell->noPrint);
- } else {
- return (cp);
- }
- }
- }
- return (cp);
-}
-
-/**
- * JobDoOutput
- * This function is called at different times depending on
- * whether the user has specified that output is to be collected
- * via pipes or temporary files. In the former case, we are called
- * whenever there is something to read on the pipe. We collect more
- * output from the given job and store it in the job's outBuf. If
- * this makes up a line, we print it tagged by the job's identifier,
- * as necessary.
- * If output has been collected in a temporary file, we open the
- * file and read it line by line, transferring it to our own
- * output channel until the file is empty. At which point we
- * remove the temporary file.
- * In both cases, however, we keep our figurative eye out for the
- * 'noPrint' line for the shell from which the output came. If
- * we recognize a line, we don't print it. If the command is not
- * alone on the line (the character after it is not \0 or \n), we
- * do print whatever follows it.
- *
- * Side Effects:
- * curPos may be shifted as may the contents of outBuf.
- */
-static void
-JobDoOutput(Job *job, Boolean finish)
-{
- Boolean gotNL = FALSE; /* true if got a newline */
- Boolean fbuf; /* true if our buffer filled up */
- int nr; /* number of bytes read */
- int i; /* auxiliary index into outBuf */
- int max; /* limit for i (end of current data) */
- int nRead; /* (Temporary) number of bytes read */
- FILE *oFILE; /* Stream pointer to shell's output file */
- char inLine[132];
-
- if (usePipes) {
- /*
- * Read as many bytes as will fit in the buffer.
- */
- end_loop:
- gotNL = FALSE;
- fbuf = FALSE;
-
- nRead = read(job->inPipe, &job->outBuf[job->curPos],
- JOB_BUFSIZE - job->curPos);
- /*
- * Check for interrupt here too, because the above read may
- * block when the child process is stopped. In this case the
- * interrupt will unblock it (we don't use SA_RESTART).
- */
- if (interrupted)
- JobPassSig(interrupted);
-
- if (nRead < 0) {
- DEBUGF(JOB, ("JobDoOutput(piperead)"));
- nr = 0;
- } else {
- nr = nRead;
- }
-
- /*
- * If we hit the end-of-file (the job is dead), we must flush
- * its remaining output, so pretend we read a newline if
- * there's any output remaining in the buffer.
- * Also clear the 'finish' flag so we stop looping.
- */
- if (nr == 0 && job->curPos != 0) {
- job->outBuf[job->curPos] = '\n';
- nr = 1;
- finish = FALSE;
- } else if (nr == 0) {
- finish = FALSE;
- }
-
- /*
- * Look for the last newline in the bytes we just got. If there
- * is one, break out of the loop with 'i' as its index and
- * gotNL set TRUE.
- */
- max = job->curPos + nr;
- for (i = job->curPos + nr - 1; i >= job->curPos; i--) {
- if (job->outBuf[i] == '\n') {
- gotNL = TRUE;
- break;
- } else if (job->outBuf[i] == '\0') {
- /*
- * Why?
- */
- job->outBuf[i] = ' ';
- }
- }
-
- if (!gotNL) {
- job->curPos += nr;
- if (job->curPos == JOB_BUFSIZE) {
- /*
- * If we've run out of buffer space, we have
- * no choice but to print the stuff. sigh.
- */
- fbuf = TRUE;
- i = job->curPos;
- }
- }
- if (gotNL || fbuf) {
- /*
- * Need to send the output to the screen. Null terminate
- * it first, overwriting the newline character if there
- * was one. So long as the line isn't one we should
- * filter (according to the shell description), we print
- * the line, preceded by a target banner if this target
- * isn't the same as the one for which we last printed
- * something. The rest of the data in the buffer are
- * then shifted down to the start of the buffer and
- * curPos is set accordingly.
- */
- job->outBuf[i] = '\0';
- if (i >= job->curPos) {
- char *cp;
-
- cp = JobOutput(job, job->outBuf,
- &job->outBuf[i], FALSE);
-
- /*
- * There's still more in that buffer. This time,
- * though, we know there's no newline at the
- * end, so we add one of our own free will.
- */
- if (*cp != '\0') {
- if (job->node != lastNode) {
- MESSAGE(stdout, job->node);
- lastNode = job->node;
- }
- fprintf(stdout, "%s%s", cp,
- gotNL ? "\n" : "");
- fflush(stdout);
- }
- }
- if (i < max - 1) {
- /* shift the remaining characters down */
- memcpy(job->outBuf, &job->outBuf[i + 1],
- max - (i + 1));
- job->curPos = max - (i + 1);
-
- } else {
- /*
- * We have written everything out, so we just
- * start over from the start of the buffer.
- * No copying. No nothing.
- */
- job->curPos = 0;
- }
- }
- if (finish) {
- /*
- * If the finish flag is true, we must loop until we hit
- * end-of-file on the pipe. This is guaranteed to happen
- * eventually since the other end of the pipe is now
- * closed (we closed it explicitly and the child has
- * exited). When we do get an EOF, finish will be set
- * FALSE and we'll fall through and out.
- */
- goto end_loop;
- }
-
- } else {
- /*
- * We've been called to retrieve the output of the job from the
- * temporary file where it's been squirreled away. This consists
- * of opening the file, reading the output line by line, being
- * sure not to print the noPrint line for the shell we used,
- * then close and remove the temporary file. Very simple.
- *
- * Change to read in blocks and do FindSubString type things
- * as for pipes? That would allow for "@echo -n..."
- */
- oFILE = fopen(job->outFile, "r");
- if (oFILE != NULL) {
- fprintf(stdout, "Results of making %s:\n",
- job->node->name);
- fflush(stdout);
-
- while (fgets(inLine, sizeof(inLine), oFILE) != NULL) {
- char *cp, *endp, *oendp;
-
- cp = inLine;
- oendp = endp = inLine + strlen(inLine);
- if (endp[-1] == '\n') {
- *--endp = '\0';
- }
- cp = JobOutput(job, inLine, endp, FALSE);
-
- /*
- * There's still more in that buffer. This time,
- * though, we know there's no newline at the
- * end, so we add one of our own free will.
- */
- fprintf(stdout, "%s", cp);
- fflush(stdout);
- if (endp != oendp) {
- fprintf(stdout, "\n");
- fflush(stdout);
- }
- }
- fclose(oFILE);
- eunlink(job->outFile);
- }
- }
-}
-
-/**
- * Job_CatchChildren
- * Handle the exit of a child. Called from Make_Make.
- *
- * Side Effects:
- * The job descriptor is removed from the list of children.
- *
- * Notes:
- * We do waits, blocking or not, according to the wisdom of our
- * caller, until there are no more children to report. For each
- * job, call JobFinish to finish things off. This will take care of
- * putting jobs on the stoppedJobs queue.
- */
-void
-Job_CatchChildren(Boolean block)
-{
- pid_t pid; /* pid of dead child */
- Job *job; /* job descriptor for dead child */
- int status; /* Exit/termination status */
-
- /*
- * Don't even bother if we know there's no one around.
- */
- if (nJobs == 0) {
- return;
- }
-
- for (;;) {
- pid = waitpid(-1, &status,
- (block ? 0 : WNOHANG) | WUNTRACED);
- if (pid <= 0)
- break;
-
- DEBUGF(JOB, ("Process %jd exited or stopped.\n",
- (intmax_t)pid));
-
- TAILQ_FOREACH(job, &jobs, link) {
- if (job->pid == pid)
- break;
- }
-
- if (job == NULL) {
- if (WIFSIGNALED(status) &&
- (WTERMSIG(status) == SIGCONT)) {
- TAILQ_FOREACH(job, &jobs, link) {
- if (job->pid == pid)
- break;
- }
- if (job == NULL) {
- Error("Resumed child (%jd) "
- "not in table", (intmax_t)pid);
- continue;
- }
- TAILQ_REMOVE(&stoppedJobs, job, link);
- } else {
- Error("Child (%jd) not in table?",
- (intmax_t)pid);
- continue;
- }
- } else {
- TAILQ_REMOVE(&jobs, job, link);
- nJobs -= 1;
- if (fifoFd >= 0 && maxJobs > 1) {
- write(fifoFd, "+", 1);
- maxJobs--;
- if (nJobs >= maxJobs)
- jobFull = TRUE;
- else
- jobFull = FALSE;
- } else {
- DEBUGF(JOB, ("Job queue is no longer full.\n"));
- jobFull = FALSE;
- }
- }
-
- JobFinish(job, &status);
- }
- if (interrupted)
- JobPassSig(interrupted);
-}
-
-/**
- * Job_CatchOutput
- * Catch the output from our children, if we're using
- * pipes do so. Otherwise just block time until we get a
- * signal(most likely a SIGCHLD) since there's no point in
- * just spinning when there's nothing to do and the reaping
- * of a child can wait for a while.
- *
- * Side Effects:
- * Output is read from pipes if we're piping.
- * -----------------------------------------------------------------------
- */
-void
-#ifdef USE_KQUEUE
-Job_CatchOutput(int flag __unused)
-#else
-Job_CatchOutput(int flag)
-#endif
-{
- int nfds;
-#ifdef USE_KQUEUE
-#define KEV_SIZE 4
- struct kevent kev[KEV_SIZE];
- int i;
-#else
- struct timeval timeout;
- fd_set readfds;
- Job *job;
-#endif
-
- fflush(stdout);
-
- if (usePipes) {
-#ifdef USE_KQUEUE
- if ((nfds = kevent(kqfd, NULL, 0, kev, KEV_SIZE, NULL)) == -1) {
- if (errno != EINTR)
- Punt("kevent: %s", strerror(errno));
- if (interrupted)
- JobPassSig(interrupted);
- } else {
- for (i = 0; i < nfds; i++) {
- if (kev[i].flags & EV_ERROR) {
- warnc(kev[i].data, "kevent");
- continue;
- }
- switch (kev[i].filter) {
- case EVFILT_READ:
- JobDoOutput(kev[i].udata, FALSE);
- break;
- case EVFILT_PROC:
- /*
- * Just wake up and let
- * Job_CatchChildren() collect the
- * terminated job.
- */
- break;
- }
- }
- }
-#else
- readfds = outputs;
- timeout.tv_sec = SEL_SEC;
- timeout.tv_usec = SEL_USEC;
- if (flag && jobFull && fifoFd >= 0)
- FD_SET(fifoFd, &readfds);
-
- nfds = select(FD_SETSIZE, &readfds, (fd_set *)NULL,
- (fd_set *)NULL, &timeout);
- if (nfds <= 0) {
- if (interrupted)
- JobPassSig(interrupted);
- return;
- }
- if (fifoFd >= 0 && FD_ISSET(fifoFd, &readfds)) {
- if (--nfds <= 0)
- return;
- }
- job = TAILQ_FIRST(&jobs);
- while (nfds != 0 && job != NULL) {
- if (FD_ISSET(job->inPipe, &readfds)) {
- JobDoOutput(job, FALSE);
- nfds--;
- }
- job = TAILQ_NEXT(job, link);
- }
-#endif /* !USE_KQUEUE */
- }
-}
-
-/**
- * Job_Make
- * Start the creation of a target. Basically a front-end for
- * JobStart used by the Make module.
- *
- * Side Effects:
- * Another job is started.
- */
-void
-Job_Make(GNode *gn)
-{
-
- JobStart(gn, 0, NULL);
-}
-
-void
-Job_SetPrefix(void)
-{
-
- if (targPrefix) {
- free(targPrefix);
- } else if (!Var_Exists(MAKE_JOB_PREFIX, VAR_GLOBAL)) {
- Var_SetGlobal(MAKE_JOB_PREFIX, "---");
- }
- targPrefix = Var_Subst("${" MAKE_JOB_PREFIX "}", VAR_GLOBAL, 0)->buf;
-}
-
-/**
- * Job_Init
- * Initialize the process module, given a maximum number of jobs.
- *
- * Side Effects:
- * lists and counters are initialized
- */
-void
-Job_Init(int maxproc)
-{
- GNode *begin; /* node for commands to do at the very start */
- const char *env;
- struct sigaction sa;
-
- fifoFd = -1;
- env = getenv("MAKE_JOBS_FIFO");
-
- if (env == NULL && maxproc > 1) {
- /*
- * We did not find the environment variable so we are the
- * leader. Create the fifo, open it, write one char per
- * allowed job into the pipe.
- */
- fifoFd = mkfifotemp(fifoName);
- if (fifoFd < 0) {
- env = NULL;
- } else {
- fifoMaster = 1;
- fcntl(fifoFd, F_SETFL, O_NONBLOCK);
- env = fifoName;
- setenv("MAKE_JOBS_FIFO", env, 1);
- while (maxproc-- > 0) {
- write(fifoFd, "+", 1);
- }
- /* The master make does not get a magic token */
- jobFull = TRUE;
- maxJobs = 0;
- }
-
- } else if (env != NULL) {
- /*
- * We had the environment variable so we are a slave.
- * Open fifo and give ourselves a magic token which represents
- * the token our parent make has grabbed to start his make
- * process. Otherwise the sub-makes would gobble up tokens and
- * the proper number of tokens to specify to -j would depend
- * on the depth of the tree and the order of execution.
- */
- fifoFd = open(env, O_RDWR, 0);
- if (fifoFd >= 0) {
- fcntl(fifoFd, F_SETFL, O_NONBLOCK);
- maxJobs = 1;
- jobFull = FALSE;
- }
- }
- if (fifoFd < 0) {
- maxJobs = maxproc;
- jobFull = FALSE;
- } else {
- }
- nJobs = 0;
-
- aborting = 0;
- makeErrors = 0;
-
- lastNode = NULL;
- if ((maxJobs == 1 && fifoFd < 0) || !beVerbose || is_posix || beQuiet) {
- /*
- * If only one job can run at a time, there's no need for a
- * banner, no is there?
- */
- targFmt = "";
- } else {
- targFmt = TARG_FMT;
- }
-
- /*
- * Catch the four signals that POSIX specifies if they aren't ignored.
- * JobCatchSignal will just set global variables and hope someone
- * else is going to handle the interrupt.
- */
- sa.sa_handler = JobCatchSig;
- sigemptyset(&sa.sa_mask);
- sa.sa_flags = 0;
-
- if (signal(SIGINT, SIG_IGN) != SIG_IGN) {
- sigaction(SIGINT, &sa, NULL);
- }
- if (signal(SIGHUP, SIG_IGN) != SIG_IGN) {
- sigaction(SIGHUP, &sa, NULL);
- }
- if (signal(SIGQUIT, SIG_IGN) != SIG_IGN) {
- sigaction(SIGQUIT, &sa, NULL);
- }
- if (signal(SIGTERM, SIG_IGN) != SIG_IGN) {
- sigaction(SIGTERM, &sa, NULL);
- }
- /*
- * There are additional signals that need to be caught and passed if
- * either the export system wants to be told directly of signals or if
- * we're giving each job its own process group (since then it won't get
- * signals from the terminal driver as we own the terminal)
- */
-#if defined(USE_PGRP)
- if (signal(SIGTSTP, SIG_IGN) != SIG_IGN) {
- sigaction(SIGTSTP, &sa, NULL);
- }
- if (signal(SIGTTOU, SIG_IGN) != SIG_IGN) {
- sigaction(SIGTTOU, &sa, NULL);
- }
- if (signal(SIGTTIN, SIG_IGN) != SIG_IGN) {
- sigaction(SIGTTIN, &sa, NULL);
- }
- if (signal(SIGWINCH, SIG_IGN) != SIG_IGN) {
- sigaction(SIGWINCH, &sa, NULL);
- }
-#endif
-
-#ifdef USE_KQUEUE
- if ((kqfd = kqueue()) == -1) {
- Punt("kqueue: %s", strerror(errno));
- }
-#endif
-
- begin = Targ_FindNode(".BEGIN", TARG_NOCREATE);
-
- if (begin != NULL) {
- JobStart(begin, JOB_SPECIAL, (Job *)NULL);
- while (nJobs) {
- Job_CatchOutput(0);
- Job_CatchChildren(!usePipes);
- }
- }
- postCommands = Targ_FindNode(".END", TARG_CREATE);
-}
-
-/**
- * Job_Full
- * See if the job table is full. It is considered full if it is OR
- * if we are in the process of aborting OR if we have
- * reached/exceeded our local quota. This prevents any more jobs
- * from starting up.
- *
- * Results:
- * TRUE if the job table is full, FALSE otherwise
- */
-Boolean
-Job_Full(void)
-{
- char c;
- int i;
-
- if (aborting)
- return (aborting);
- if (fifoFd >= 0 && jobFull) {
- i = read(fifoFd, &c, 1);
- if (i > 0) {
- maxJobs++;
- jobFull = FALSE;
- }
- }
- return (jobFull);
-}
-
-/**
- * Job_Empty
- * See if the job table is empty. Because the local concurrency may
- * be set to 0, it is possible for the job table to become empty,
- * while the list of stoppedJobs remains non-empty. In such a case,
- * we want to restart as many jobs as we can.
- *
- * Results:
- * TRUE if it is. FALSE if it ain't.
- */
-Boolean
-Job_Empty(void)
-{
- if (nJobs == 0) {
- if (!TAILQ_EMPTY(&stoppedJobs) && !aborting) {
- /*
- * The job table is obviously not full if it has no
- * jobs in it...Try and restart the stopped jobs.
- */
- jobFull = FALSE;
- JobRestartJobs();
- return (FALSE);
- } else {
- return (TRUE);
- }
- } else {
- return (FALSE);
- }
-}
-
-/**
- * JobInterrupt
- * Handle the receipt of an interrupt.
- *
- * Side Effects:
- * All children are killed. Another job will be started if the
- * .INTERRUPT target was given.
- */
-static void
-JobInterrupt(int runINTERRUPT, int signo)
-{
- Job *job; /* job descriptor in that element */
- GNode *interrupt; /* the node describing the .INTERRUPT target */
-
- aborting = ABORT_INTERRUPT;
-
- TAILQ_FOREACH(job, &jobs, link) {
- if (!Targ_Precious(job->node)) {
- char *file = (job->node->path == NULL ?
- job->node->name : job->node->path);
-
- if (!noExecute && eunlink(file) != -1) {
- Error("*** %s removed", file);
- }
- }
- if (job->pid) {
- DEBUGF(JOB, ("JobInterrupt passing signal to child "
- "%jd.\n", (intmax_t)job->pid));
- KILL(job->pid, signo);
- }
- }
-
- if (runINTERRUPT && !touchFlag) {
- /*
- * clear the interrupted flag because we would get an
- * infinite loop otherwise.
- */
- interrupted = 0;
-
- interrupt = Targ_FindNode(".INTERRUPT", TARG_NOCREATE);
- if (interrupt != NULL) {
- ignoreErrors = FALSE;
-
- JobStart(interrupt, JOB_IGNDOTS, (Job *)NULL);
- while (nJobs) {
- Job_CatchOutput(0);
- Job_CatchChildren(!usePipes);
- }
- }
- }
- if (fifoMaster)
- unlink(fifoName);
-}
-
-/**
- * Job_Finish
- * Do final processing such as the running of the commands
- * attached to the .END target.
- *
- * Results:
- * None.
- */
-void
-Job_Finish(void)
-{
-
- if (postCommands != NULL && !Lst_IsEmpty(&postCommands->commands)) {
- if (makeErrors) {
- Error("Errors reported so .END ignored");
- } else {
- JobStart(postCommands, JOB_SPECIAL | JOB_IGNDOTS, NULL);
-
- while (nJobs) {
- Job_CatchOutput(0);
- Job_CatchChildren(!usePipes);
- }
- }
- }
- if (fifoFd >= 0) {
- close(fifoFd);
- fifoFd = -1;
- if (fifoMaster)
- unlink(fifoName);
- }
-}
-
-/**
- * Job_Wait
- * Waits for all running jobs to finish and returns. Sets 'aborting'
- * to ABORT_WAIT to prevent other jobs from starting.
- *
- * Side Effects:
- * Currently running jobs finish.
- */
-void
-Job_Wait(void)
-{
-
- aborting = ABORT_WAIT;
- while (nJobs != 0) {
- Job_CatchOutput(0);
- Job_CatchChildren(!usePipes);
- }
- aborting = 0;
-}
-
-/**
- * Job_AbortAll
- * Abort all currently running jobs without handling output or anything.
- * This function is to be called only in the event of a major
- * error. Most definitely NOT to be called from JobInterrupt.
- *
- * Side Effects:
- * All children are killed, not just the firstborn
- */
-void
-Job_AbortAll(void)
-{
- Job *job; /* the job descriptor in that element */
- int foo;
-
- aborting = ABORT_ERROR;
-
- if (nJobs) {
- TAILQ_FOREACH(job, &jobs, link) {
- /*
- * kill the child process with increasingly drastic
- * signals to make darn sure it's dead.
- */
- KILL(job->pid, SIGINT);
- KILL(job->pid, SIGKILL);
- }
- }
-
- /*
- * Catch as many children as want to report in at first, then give up
- */
- while (waitpid(-1, &foo, WNOHANG) > 0)
- ;
-}
-
-/**
- * JobRestartJobs
- * Tries to restart stopped jobs if there are slots available.
- * Note that this tries to restart them regardless of pending errors.
- * It's not good to leave stopped jobs lying around!
- *
- * Side Effects:
- * Resumes(and possibly migrates) jobs.
- */
-static void
-JobRestartJobs(void)
-{
- Job *job;
-
- while (!jobFull && (job = TAILQ_FIRST(&stoppedJobs)) != NULL) {
- DEBUGF(JOB, ("Job queue is not full. "
- "Restarting a stopped job.\n"));
- TAILQ_REMOVE(&stoppedJobs, job, link);
- JobRestart(job);
- }
-}
-
-/**
- * Cmd_Exec
- * Execute the command in cmd, and return the output of that command
- * in a string.
- *
- * Results:
- * A string containing the output of the command, or the empty string
- * If error is not NULL, it contains the reason for the command failure
- * Any output sent to stderr in the child process is passed to stderr,
- * and not captured in the string.
- *
- * Side Effects:
- * The string must be freed by the caller.
- */
-Buffer *
-Cmd_Exec(const char *cmd, const char **error)
-{
- int fds[2]; /* Pipe streams */
- int status; /* command exit status */
- Buffer *buf; /* buffer to store the result */
- ssize_t rcnt;
- ProcStuff ps;
-
- *error = NULL;
- buf = Buf_Init(0);
-
- /*
- * Open a pipe for fetching its output
- */
- if (pipe(fds) == -1) {
- *error = "Couldn't create pipe for \"%s\"";
- return (buf);
- }
-
- /* Set close-on-exec on read side of pipe. */
- fcntl(fds[0], F_SETFD, fcntl(fds[0], F_GETFD) | FD_CLOEXEC);
-
- ps.in = STDIN_FILENO;
- ps.out = fds[1];
- ps.err = STDERR_FILENO;
-
- ps.merge_errors = 0;
- ps.pgroup = 0;
- ps.searchpath = 0;
-
- /* Set up arguments for shell */
- ps.argv = emalloc(4 * sizeof(char *));
- ps.argv[0] = strdup(commandShell->name);
- ps.argv[1] = strdup("-c");
- ps.argv[2] = strdup(cmd);
- ps.argv[3] = NULL;
- ps.argv_free = 1;
-
- /*
- * Fork. Warning since we are doing vfork() instead of fork(),
- * do not allocate memory in the child process!
- */
- if ((ps.child_pid = vfork()) == -1) {
- *error = "Couldn't exec \"%s\"";
- return (buf);
-
- } else if (ps.child_pid == 0) {
- /*
- * Child
- */
- Proc_Exec(&ps);
- /* NOTREACHED */
- }
-
- free(ps.argv[2]);
- free(ps.argv[1]);
- free(ps.argv[0]);
- free(ps.argv);
-
- close(fds[1]); /* No need for the writing half of the pipe. */
-
- do {
- char result[BUFSIZ];
-
- rcnt = read(fds[0], result, sizeof(result));
- if (rcnt != -1)
- Buf_AddBytes(buf, (size_t)rcnt, (Byte *)result);
- } while (rcnt > 0 || (rcnt == -1 && errno == EINTR));
-
- if (rcnt == -1)
- *error = "Error reading shell's output for \"%s\"";
-
- /*
- * Close the input side of the pipe.
- */
- close(fds[0]);
-
- status = ProcWait(&ps);
-
- if (status)
- *error = "\"%s\" returned non-zero status";
-
- Buf_StripNewlines(buf);
-
- return (buf);
-}
-
-
-/*
- * Interrupt handler - set flag and defer handling to the main code
- */
-static void
-CompatCatchSig(int signo)
-{
-
- interrupted = signo;
-}
-
-/*-
- *-----------------------------------------------------------------------
- * CompatInterrupt --
- * Interrupt the creation of the current target and remove it if
- * it ain't precious.
- *
- * Results:
- * None.
- *
- * Side Effects:
- * The target is removed and the process exits. If .INTERRUPT exists,
- * its commands are run first WITH INTERRUPTS IGNORED..
- *
- *-----------------------------------------------------------------------
- */
-static void
-CompatInterrupt(int signo)
-{
- GNode *gn;
- sigset_t nmask, omask;
- LstNode *ln;
-
- sigemptyset(&nmask);
- sigaddset(&nmask, SIGINT);
- sigaddset(&nmask, SIGTERM);
- sigaddset(&nmask, SIGHUP);
- sigaddset(&nmask, SIGQUIT);
- sigprocmask(SIG_SETMASK, &nmask, &omask);
-
- /* prevent recursion in evaluation of .INTERRUPT */
- interrupted = 0;
-
- if (curTarg != NULL && !Targ_Precious(curTarg)) {
- const char *file = Var_Value(TARGET, curTarg);
-
- if (!noExecute && eunlink(file) != -1) {
- printf("*** %s removed\n", file);
- }
- }
-
- /*
- * Run .INTERRUPT only if hit with interrupt signal
- */
- if (signo == SIGINT) {
- gn = Targ_FindNode(".INTERRUPT", TARG_NOCREATE);
- if (gn != NULL) {
- LST_FOREACH(ln, &gn->commands) {
- if (Compat_RunCommand(ln, gn))
- break;
- }
- }
- }
-
- sigprocmask(SIG_SETMASK, &omask, NULL);
-
- if (signo == SIGQUIT)
- exit(signo);
- signal(signo, SIG_DFL);
- kill(getpid(), signo);
-}
-
-/**
- * shellneed
- *
- * Results:
- * Returns NULL if a specified line must be executed by the shell,
- * and an argument vector if it can be run via execvp().
- *
- * Side Effects:
- * Uses brk_string so destroys the contents of argv.
- */
-static char **
-shellneed(ArgArray *aa, char *cmd)
-{
- char **p;
- int ret;
-
- if (commandShell->meta == NULL || commandShell->builtins.argc <= 1)
- /* use shell */
- return (NULL);
-
- if (strpbrk(cmd, commandShell->meta) != NULL)
- return (NULL);
-
- /*
- * Break the command into words to form an argument
- * vector we can execute.
- */
- brk_string(aa, cmd, TRUE);
- for (p = commandShell->builtins.argv + 1; *p != 0; p++) {
- if ((ret = strcmp(aa->argv[1], *p)) == 0) {
- /* found - use shell */
- ArgArray_Done(aa);
- return (NULL);
- }
- if (ret < 0) {
- /* not found */
- break;
- }
- }
- return (aa->argv + 1);
-}
-
-/**
- * Execute the next command for a target. If the command returns an
- * error, the node's made field is set to ERROR and creation stops.
- * The node from which the command came is also given. This is used
- * to execute the commands in compat mode and when executing commands
- * with the '+' flag in non-compat mode. In these modes each command
- * line should be executed by its own shell. We do some optimisation here:
- * if the shell description defines both a string of meta characters and
- * a list of builtins and the command line neither contains a meta character
- * nor starts with one of the builtins then we execute the command directly
- * without invoking a shell.
- *
- * Results:
- * 0 if the command succeeded, 1 if an error occurred.
- *
- * Side Effects:
- * The node's 'made' field may be set to ERROR.
- */
-static int
-Compat_RunCommand(LstNode *cmdNode, GNode *gn)
-{
- ArgArray aa;
- char *cmd; /* Expanded command */
- Boolean silent; /* Don't print command */
- Boolean doit; /* Execute even in -n */
- Boolean errCheck; /* Check errors */
- int reason; /* Reason for child's death */
- int status; /* Description of child's death */
- char **av; /* Argument vector for thing to exec */
- ProcStuff ps;
-
- silent = gn->type & OP_SILENT;
- errCheck = !(gn->type & OP_IGNORE);
- doit = FALSE;
-
- cmd = Buf_Peel(Var_Subst(Lst_Datum(cmdNode), gn, FALSE));
- if ((gn->type & OP_SAVE_CMDS) && (gn != ENDNode)) {
- Lst_AtEnd(&ENDNode->commands, cmd);
- return (0);
- } else if (strcmp(cmd, "...") == 0) {
- free(cmd);
- gn->type |= OP_SAVE_CMDS;
- return (0);
- }
- Lst_Replace(cmdNode, cmd);
-
- while (*cmd == '@' || *cmd == '-' || *cmd == '+') {
- switch (*cmd) {
-
- case '@':
- silent = DEBUG(LOUD) ? FALSE : TRUE;
- break;
-
- case '-':
- errCheck = FALSE;
- break;
-
- case '+':
- doit = TRUE;
- break;
- }
- cmd++;
- }
-
- while (isspace((unsigned char)*cmd))
- cmd++;
-
- /*
- * Ignore empty commands
- */
- if (*cmd == '\0') {
- return (0);
- }
-
- /*
- * Print the command before echoing if we're not supposed to be quiet
- * for this one. We also print the command if -n given, but not if '+'.
- */
- if (!silent || (noExecute && !doit)) {
- printf("%s\n", cmd);
- fflush(stdout);
- }
-
- /*
- * If we're not supposed to execute any commands, this is as far as
- * we go...
- */
- if (!doit && noExecute) {
- return (0);
- }
-
- ps.in = STDIN_FILENO;
- ps.out = STDOUT_FILENO;
- ps.err = STDERR_FILENO;
-
- ps.merge_errors = 0;
- ps.pgroup = 0;
- ps.searchpath = 1;
-
- if ((av = shellneed(&aa, cmd)) == NULL) {
- /*
- * Shell meta character or shell builtin found - pass
- * command to shell. We give the shell the -e flag as
- * well as -c if it is supposed to exit when it hits an error.
- */
- ps.argv = emalloc(4 * sizeof(char *));
- ps.argv[0] = strdup(commandShell->path);
- ps.argv[1] = strdup(errCheck ? "-ec" : "-c");
- ps.argv[2] = strdup(cmd);
- ps.argv[3] = NULL;
- ps.argv_free = 1;
- } else {
- ps.argv = av;
- ps.argv_free = 0;
- }
- ps.errCheck = errCheck;
-
- /*
- * Warning since we are doing vfork() instead of fork(),
- * do not allocate memory in the child process!
- */
- if ((ps.child_pid = vfork()) == -1) {
- Fatal("Could not fork");
-
- } else if (ps.child_pid == 0) {
- /*
- * Child
- */
- Proc_Exec(&ps);
- /* NOTREACHED */
-
- } else {
- if (ps.argv_free) {
- free(ps.argv[2]);
- free(ps.argv[1]);
- free(ps.argv[0]);
- free(ps.argv);
- } else {
- ArgArray_Done(&aa);
- }
-
- /*
- * we need to print out the command associated with this
- * Gnode in Targ_PrintCmd from Targ_PrintGraph when debugging
- * at level g2, in main(), Fatal() and DieHorribly(),
- * therefore do not free it when debugging.
- */
- if (!DEBUG(GRAPH2)) {
- free(Lst_Datum(cmdNode));
- Lst_Replace(cmdNode, NULL);
- }
-
- /*
- * The child is off and running. Now all we can do is wait...
- */
- reason = ProcWait(&ps);
-
- if (interrupted)
- CompatInterrupt(interrupted);
-
- /*
- * Decode and report the reason child exited, then
- * indicate how we handled it.
- */
- if (WIFEXITED(reason)) {
- status = WEXITSTATUS(reason);
- if (status == 0) {
- return (0);
- } else {
- printf("*** [%s] Error code %d",
- gn->name, status);
- }
- } else if (WIFSTOPPED(reason)) {
- status = WSTOPSIG(reason);
- } else {
- status = WTERMSIG(reason);
- printf("*** [%s] Signal %d",
- gn->name, status);
- }
-
- if (ps.errCheck) {
- gn->made = ERROR;
- if (keepgoing) {
- /*
- * Abort the current
- * target, but let
- * others continue.
- */
- printf(" (continuing)\n");
- }
- return (status);
- } else {
- /*
- * Continue executing
- * commands for this target.
- * If we return 0, this will
- * happen...
- */
- printf(" (ignored)\n");
- return (0);
- }
- }
-}
-
-/*-
- *-----------------------------------------------------------------------
- * Compat_Make --
- * Make a target, given the parent, to abort if necessary.
- *
- * Side Effects:
- * If an error is detected and not being ignored, the process exits.
- *
- *-----------------------------------------------------------------------
- */
-int
-Compat_Make(GNode *gn, GNode *pgn)
-{
- LstNode *ln;
-
- if (gn->type & OP_USE) {
- Make_HandleUse(gn, pgn);
-
- } else if (gn->made == UNMADE) {
- /*
- * First mark ourselves to be made, then apply whatever
- * transformations the suffix module thinks are necessary.
- * Once that's done, we can descend and make all our children.
- * If any of them has an error but the -k flag was given, our
- * 'make' field will be set FALSE again. This is our signal to
- * not attempt to do anything but abort our parent as well.
- */
- gn->make = TRUE;
- gn->made = BEINGMADE;
- Suff_FindDeps(gn);
- LST_FOREACH(ln, &gn->children)
- Compat_Make(Lst_Datum(ln), gn);
- if (!gn->make) {
- gn->made = ABORTED;
- pgn->make = FALSE;
- return (0);
- }
-
- if (Lst_Member(&gn->iParents, pgn) != NULL) {
- Var_Set(IMPSRC, Var_Value(TARGET, gn), pgn);
- }
-
- /*
- * All the children were made ok. Now cmtime contains the
- * modification time of the newest child, we need to find out
- * if we exist and when we were modified last. The criteria for
- * datedness are defined by the Make_OODate function.
- */
- DEBUGF(MAKE, ("Examining %s...", gn->name));
- if (!Make_OODate(gn)) {
- gn->made = UPTODATE;
- DEBUGF(MAKE, ("up-to-date.\n"));
- return (0);
- } else {
- DEBUGF(MAKE, ("out-of-date.\n"));
- }
-
- /*
- * If the user is just seeing if something is out-of-date,
- * exit now to tell him/her "yes".
- */
- if (queryFlag) {
- exit(1);
- }
-
- /*
- * We need to be re-made. We also have to make sure we've got
- * a $? variable. To be nice, we also define the $> variable
- * using Make_DoAllVar().
- */
- Make_DoAllVar(gn);
-
- /*
- * Alter our type to tell if errors should be ignored or things
- * should not be printed so Compat_RunCommand knows what to do.
- */
- if (Targ_Ignore(gn)) {
- gn->type |= OP_IGNORE;
- }
- if (Targ_Silent(gn)) {
- gn->type |= OP_SILENT;
- }
-
- if (Job_CheckCommands(gn, Fatal)) {
- /*
- * Our commands are ok, but we still have to worry
- * about the -t flag...
- */
- if (!touchFlag) {
- curTarg = gn;
- LST_FOREACH(ln, &gn->commands) {
- if (Compat_RunCommand(ln, gn))
- break;
- }
- curTarg = NULL;
- } else {
- Job_Touch(gn, gn->type & OP_SILENT);
- }
- } else {
- gn->made = ERROR;
- }
-
- if (gn->made != ERROR) {
- /*
- * If the node was made successfully, mark it so, update
- * its modification time and timestamp all its parents.
- * Note that for .ZEROTIME targets, the timestamping
- * isn't done. This is to keep its state from affecting
- * that of its parent.
- */
- gn->made = MADE;
-#ifndef RECHECK
- /*
- * We can't re-stat the thing, but we can at least take
- * care of rules where a target depends on a source that
- * actually creates the target, but only if it has
- * changed, e.g.
- *
- * parse.h : parse.o
- *
- * parse.o : parse.y
- * yacc -d parse.y
- * cc -c y.tab.c
- * mv y.tab.o parse.o
- * cmp -s y.tab.h parse.h || mv y.tab.h parse.h
- *
- * In this case, if the definitions produced by yacc
- * haven't changed from before, parse.h won't have been
- * updated and gn->mtime will reflect the current
- * modification time for parse.h. This is something of a
- * kludge, I admit, but it's a useful one..
- *
- * XXX: People like to use a rule like
- *
- * FRC:
- *
- * To force things that depend on FRC to be made, so we
- * have to check for gn->children being empty as well...
- */
- if (!Lst_IsEmpty(&gn->commands) ||
- Lst_IsEmpty(&gn->children)) {
- gn->mtime = now;
- }
-#else
- /*
- * This is what Make does and it's actually a good
- * thing, as it allows rules like
- *
- * cmp -s y.tab.h parse.h || cp y.tab.h parse.h
- *
- * to function as intended. Unfortunately, thanks to
- * the stateless nature of NFS (and the speed of this
- * program), there are times when the modification time
- * of a file created on a remote machine will not be
- * modified before the stat() implied by the Dir_MTime
- * occurs, thus leading us to believe that the file
- * is unchanged, wreaking havoc with files that depend
- * on this one.
- *
- * I have decided it is better to make too much than to
- * make too little, so this stuff is commented out
- * unless you're sure it's ok.
- * -- ardeb 1/12/88
- */
- if (noExecute || Dir_MTime(gn) == 0) {
- gn->mtime = now;
- }
- if (gn->cmtime > gn->mtime)
- gn->mtime = gn->cmtime;
- DEBUGF(MAKE, ("update time: %s\n",
- Targ_FmtTime(gn->mtime)));
-#endif
- if (!(gn->type & OP_EXEC)) {
- pgn->childMade = TRUE;
- Make_TimeStamp(pgn, gn);
- }
-
- } else if (keepgoing) {
- pgn->make = FALSE;
-
- } else {
- printf("\n\nStop in %s.\n", Var_Value(".CURDIR", gn));
- exit(1);
- }
- } else if (gn->made == ERROR) {
- /*
- * Already had an error when making this beastie. Tell the
- * parent to abort.
- */
- pgn->make = FALSE;
- } else {
- if (Lst_Member(&gn->iParents, pgn) != NULL) {
- Var_Set(IMPSRC, Var_Value(TARGET, gn), pgn);
- }
- switch(gn->made) {
- case BEINGMADE:
- Error("Graph cycles through %s\n", gn->name);
- gn->made = ERROR;
- pgn->make = FALSE;
- break;
- case MADE:
- if ((gn->type & OP_EXEC) == 0) {
- pgn->childMade = TRUE;
- Make_TimeStamp(pgn, gn);
- }
- break;
- case UPTODATE:
- if ((gn->type & OP_EXEC) == 0) {
- Make_TimeStamp(pgn, gn);
- }
- break;
- default:
- break;
- }
- }
-
- return (0);
-}
-
-/*-
- * Install signal handlers for Compat_Run
- */
-void
-Compat_InstallSignalHandlers(void)
-{
-
- if (signal(SIGINT, SIG_IGN) != SIG_IGN) {
- signal(SIGINT, CompatCatchSig);
- }
- if (signal(SIGTERM, SIG_IGN) != SIG_IGN) {
- signal(SIGTERM, CompatCatchSig);
- }
- if (signal(SIGHUP, SIG_IGN) != SIG_IGN) {
- signal(SIGHUP, CompatCatchSig);
- }
- if (signal(SIGQUIT, SIG_IGN) != SIG_IGN) {
- signal(SIGQUIT, CompatCatchSig);
- }
-}
-
-/*-
- *-----------------------------------------------------------------------
- * Compat_Run --
- * Start making again, given a list of target nodes.
- *
- * Results:
- * None.
- *
- * Side Effects:
- * Guess what?
- *
- *-----------------------------------------------------------------------
- */
-void
-Compat_Run(Lst *targs)
-{
- GNode *gn = NULL; /* Current root target */
- LstNode *ln;
-
- Compat_InstallSignalHandlers();
- ENDNode = Targ_FindNode(".END", TARG_CREATE);
- /*
- * If the user has defined a .BEGIN target, execute the commands
- * attached to it.
- */
- if (!queryFlag) {
- gn = Targ_FindNode(".BEGIN", TARG_NOCREATE);
- if (gn != NULL) {
- LST_FOREACH(ln, &gn->commands) {
- if (Compat_RunCommand(ln, gn))
- break;
- }
- if (gn->made == ERROR) {
- printf("\n\nStop.\n");
- exit(1);
- }
- }
- }
-
- /*
- * For each entry in the list of targets to create, call Compat_Make on
- * it to create the thing. Compat_Make will leave the 'made' field of gn
- * in one of several states:
- * UPTODATE gn was already up-to-date
- * MADE gn was recreated successfully
- * ERROR An error occurred while gn was being created
- * ABORTED gn was not remade because one of its inferiors
- * could not be made due to errors.
- */
- makeErrors = 0;
- while (!Lst_IsEmpty(targs)) {
- gn = Lst_DeQueue(targs);
- Compat_Make(gn, gn);
-
- if (gn->made == UPTODATE) {
- printf("`%s' is up to date.\n", gn->name);
- } else if (gn->made == ABORTED) {
- printf("`%s' not remade because of errors.\n",
- gn->name);
- makeErrors++;
- } else if (gn->made == ERROR) {
- makeErrors++;
- }
- }
-
- /*
- * If the user has defined a .END target, run its commands.
- */
- if (makeErrors == 0) {
- LST_FOREACH(ln, &ENDNode->commands) {
- if (Compat_RunCommand(ln, ENDNode))
- break;
- }
- }
-}
diff --git a/usr.bin/make/job.h b/usr.bin/make/job.h
deleted file mode 100644
index 31e1cb7..0000000
--- a/usr.bin/make/job.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/*-
- * Copyright (c) 1988, 1989, 1990, 1993
- * The Regents of the University of California. All rights reserved.
- * Copyright (c) 1988, 1989 by Adam de Boor
- * Copyright (c) 1989 by Berkeley Softworks
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Adam de Boor.
- *
- * 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.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
- *
- * @(#)job.h 8.1 (Berkeley) 6/6/93
- * $FreeBSD$
- */
-
-#ifndef job_h_4678dfd1
-#define job_h_4678dfd1
-
-/*-
- * job.h --
- * Definitions pertaining to the running of jobs in parallel mode.
- */
-
-#include <stdio.h>
-
-#include "util.h"
-
-struct Buffer;
-struct GNode;
-struct Lst;
-
-void Job_Touch(struct GNode *, Boolean);
-Boolean Job_CheckCommands(struct GNode *, void (*abortProc)(const char *, ...));
-void Job_CatchChildren(Boolean);
-void Job_CatchOutput(int flag);
-void Job_Make(struct GNode *);
-void Job_Init(int);
-Boolean Job_Full(void);
-Boolean Job_Empty(void);
-void Job_Finish(void);
-void Job_Wait(void);
-void Job_AbortAll(void);
-void Job_SetPrefix(void);
-
-void Proc_Init(void);
-
-struct Buffer *Cmd_Exec(const char *, const char **);
-
-int Compat_Make(struct GNode *gn, struct GNode *pgn);
-void Compat_InstallSignalHandlers(void);
-void Compat_Run(struct Lst *);
-
-#endif /* job_h_4678dfd1 */
diff --git a/usr.bin/make/lst.c b/usr.bin/make/lst.c
deleted file mode 100644
index d57c34b..0000000
--- a/usr.bin/make/lst.c
+++ /dev/null
@@ -1,344 +0,0 @@
-/*-
- * Copyright (c) 1988, 1989, 1990, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Adam de Boor.
- *
- * 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.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
- *
- * $FreeBSD$
- */
-
-/*-
- * lst.c --
- * Routines to maintain a linked list of objects.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "lst.h"
-#include "util.h"
-
-/**
- * Lst_Append
- * Create a new node and add it to the given list after the given node.
- *
- * Arguments:
- * l affected list
- * ln node after which to append the datum
- * d said datum
- *
- * Side Effects:
- * A new LstNode is created and linked in to the List. The lastPtr
- * field of the List will be altered if ln is the last node in the
- * list. lastPtr and firstPtr will alter if the list was empty and
- * ln was NULL.
- */
-void
-Lst_Append(Lst *list, LstNode *ln, void *d)
-{
- LstNode *nLNode;
-
- nLNode = emalloc(sizeof(*nLNode));
- nLNode->datum = d;
-
- if (ln == NULL) {
- nLNode->nextPtr = nLNode->prevPtr = NULL;
- list->firstPtr = list->lastPtr = nLNode;
- } else {
- nLNode->prevPtr = ln;
- nLNode->nextPtr = ln->nextPtr;
-
- ln->nextPtr = nLNode;
- if (nLNode->nextPtr != NULL) {
- nLNode->nextPtr->prevPtr = nLNode;
- }
-
- if (ln == list->lastPtr) {
- list->lastPtr = nLNode;
- }
- }
-}
-
-/**
- * Lst_Concat
- * Concatenate two lists. New elements are created to hold the data
- * elements, if specified, but the elements themselves are not copied.
- * If the elements should be duplicated to avoid confusion with another
- * list, the Lst_Duplicate function should be called first.
- *
- * Arguments:
- * list1 The list to which list2 is to be appended
- * list2 The list to append to list1
- * flags LST_CONCNEW if LstNode's should be duplicated
- * LST_CONCLINK if should just be relinked
- *
- * Side Effects:
- * New elements are created and appended the first list.
- */
-void
-Lst_Concat(Lst *list1, Lst *list2, int flags)
-{
- LstNode *ln; /* original LstNode */
- LstNode *nln; /* new LstNode */
- LstNode *last; /* the last element in the list. Keeps
- * bookkeeping until the end */
-
- if (list2->firstPtr == NULL)
- return;
-
- if (flags == LST_CONCLINK) {
- /*
- * Link the first element of the second list to the last
- * element of the first list. If the first list isn't empty,
- * we then link the last element of the list to the first
- * element of the second list. The last element of the second
- * list, if it exists, then becomes the last element of the
- * first list.
- */
- list2->firstPtr->prevPtr = list1->lastPtr;
- if (list1->lastPtr != NULL)
- list1->lastPtr->nextPtr = list2->firstPtr;
- else
- list1->firstPtr = list2->firstPtr;
- list1->lastPtr = list2->lastPtr;
-
- Lst_Init(list2);
- } else {
- /*
- * The loop simply goes through the entire second list creating
- * new LstNodes and filling in the nextPtr, and prevPtr to fit
- * into list1 and its datum field from the datum field of the
- * corresponding element in list2. The 'last' node follows the
- * last of the new nodes along until the entire list2 has been
- * appended. Only then does the bookkeeping catch up with the
- * changes. During the first iteration of the loop, if 'last'
- * is NULL, the first list must have been empty so the
- * newly-created node is made the first node of the list.
- */
- for (last = list1->lastPtr, ln = list2->firstPtr;
- ln != NULL;
- ln = ln->nextPtr) {
- nln = emalloc(sizeof(*nln));
- nln->datum = ln->datum;
- if (last != NULL) {
- last->nextPtr = nln;
- } else {
- list1->firstPtr = nln;
- }
- nln->prevPtr = last;
- last = nln;
- }
-
- /*
- * Finish bookkeeping. The last new element becomes the last
- * element of list one.
- */
- list1->lastPtr = last;
- last->nextPtr = NULL;
- }
-}
-
-/**
- * Lst_DeQueue
- * Remove and return the datum at the head of the given list.
- *
- * Results:
- * The datum in the node at the head or (ick) NULL if the list
- * is empty.
- *
- * Side Effects:
- * The head node is removed from the list.
- */
-void *
-Lst_DeQueue(Lst *l)
-{
- void *rd;
- LstNode *tln;
-
- tln = Lst_First(l);
- if (tln == NULL) {
- return (NULL);
- }
-
- rd = tln->datum;
- Lst_Remove(l, tln);
- return (rd);
-}
-
-/**
- * Lst_Destroy
- * Destroy a list and free all its resources. If the freeProc is
- * given, it is called with the datum from each node in turn before
- * the node is freed.
- *
- * Side Effects:
- * The given list is freed in its entirety.
- */
-void
-Lst_Destroy(Lst *list, FreeProc *freeProc)
-{
- LstNode *ln;
-
- if (list->firstPtr == NULL)
- return;
-
- if (freeProc != NOFREE) {
- while ((ln = list->firstPtr) != NULL) {
- list->firstPtr = ln->nextPtr;
- (*freeProc)(ln->datum);
- free(ln);
- }
- } else {
- while ((ln = list->firstPtr) != NULL) {
- list->firstPtr = ln->nextPtr;
- free(ln);
- }
- }
- list->lastPtr = NULL;
-}
-
-/**
- * Lst_Duplicate
- * Duplicate an entire list. If a function to copy a void * is
- * given, the individual client elements will be duplicated as well.
- *
- * Arguments:
- * dst the destination list (initialized)
- * src the list to duplicate
- * copyProc A function to duplicate each void
- */
-void
-Lst_Duplicate(Lst *dst, Lst *src, DuplicateProc *copyProc)
-{
- LstNode *ln;
-
- ln = src->firstPtr;
- while (ln != NULL) {
- if (copyProc != NOCOPY)
- Lst_AtEnd(dst, (*copyProc)(ln->datum));
- else
- Lst_AtEnd(dst, ln->datum);
- ln = ln->nextPtr;
- }
-}
-
-/**
- * Lst_Insert
- * Insert a new node with the given piece of data before the given
- * node in the given list.
- *
- * Parameters:
- * l list to manipulate
- * ln node before which to insert d
- * d datum to be inserted
- *
- * Side Effects:
- * the firstPtr field will be changed if ln is the first node in the
- * list.
- */
-void
-Lst_Insert(Lst *list, LstNode *ln, void *d)
-{
- LstNode *nLNode; /* new lnode for d */
-
- nLNode = emalloc(sizeof(*nLNode));
- nLNode->datum = d;
-
- if (ln == NULL) {
- nLNode->prevPtr = nLNode->nextPtr = NULL;
- list->firstPtr = list->lastPtr = nLNode;
- } else {
- nLNode->prevPtr = ln->prevPtr;
- nLNode->nextPtr = ln;
-
- if (nLNode->prevPtr != NULL) {
- nLNode->prevPtr->nextPtr = nLNode;
- }
- ln->prevPtr = nLNode;
-
- if (ln == list->firstPtr) {
- list->firstPtr = nLNode;
- }
- }
-}
-
-LstNode *
-Lst_Member(Lst *list, void *d)
-{
- LstNode *lNode;
-
- lNode = list->firstPtr;
- if (lNode == NULL) {
- return (NULL);
- }
-
- do {
- if (lNode->datum == d) {
- return (lNode);
- }
- lNode = lNode->nextPtr;
- } while (lNode != NULL && lNode != list->firstPtr);
-
- return (NULL);
-}
-
-/**
- * Lst_Remove
- * Remove the given node from the given list.
- *
- * Side Effects:
- * The list's firstPtr will be set to NULL if ln is the last
- * node on the list. firsPtr and lastPtr will be altered if ln is
- * either the first or last node, respectively, on the list.
- */
-void
-Lst_Remove(Lst *list, LstNode *ln)
-{
- /*
- * unlink it from the list
- */
- if (ln->nextPtr != NULL)
- /* unlink from the backward chain */
- ln->nextPtr->prevPtr = ln->prevPtr;
- else
- /* this was the last element */
- list->lastPtr = ln->prevPtr;
-
- if (ln->prevPtr != NULL)
- /* unlink from the forward chain */
- ln->prevPtr->nextPtr = ln->nextPtr;
- else
- /* this was the first element */
- list->firstPtr = ln->nextPtr;
-
- /*
- * note that the datum is unmolested. The caller must free it as
- * necessary and as expected.
- */
- free(ln);
-}
diff --git a/usr.bin/make/lst.h b/usr.bin/make/lst.h
deleted file mode 100644
index 1199e94..0000000
--- a/usr.bin/make/lst.h
+++ /dev/null
@@ -1,175 +0,0 @@
-/*-
- * Copyright (c) 1988, 1989, 1990, 1993
- * The Regents of the University of California. All rights reserved.
- * Copyright (c) 1988, 1989 by Adam de Boor
- * Copyright (c) 1989 by Berkeley Softworks
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Adam de Boor.
- *
- * 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.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
- *
- * @(#)lst.h 8.2 (Berkeley) 4/28/95
- * $FreeBSD$
- */
-
-#ifndef lst_h_38f3ead1
-#define lst_h_38f3ead1
-
-/*-
- * lst.h --
- * Header for using the list library
- */
-
-/*
- * Structure of a list node.
- */
-struct LstNode {
- struct LstNode *prevPtr; /* previous element in list */
- struct LstNode *nextPtr; /* next in list */
- void *datum; /* datum associated with this element */
-};
-typedef struct LstNode LstNode;
-
-/*
- * The list itself
- */
-struct Lst {
- LstNode *firstPtr; /* first node in list */
- LstNode *lastPtr; /* last node in list */
-};
-typedef struct Lst Lst;
-
-typedef void *DuplicateProc(void *);
-typedef void FreeProc(void *);
-
-/*
- * NOFREE can be used as the freeProc to Lst_Destroy when the elements are
- * not to be freed.
- * NOCOPY performs similarly when given as the copyProc to Lst_Duplicate.
- */
-#define NOFREE ((FreeProc *)NULL)
-#define NOCOPY ((DuplicateProc *)NULL)
-
-#define LST_CONCNEW 0 /* create new LstNode's when using Lst_Concat */
-#define LST_CONCLINK 1 /* relink LstNode's when using Lst_Concat */
-
-/*
- * Creation/destruction functions
- */
-/* Create a new list */
-#define Lst_Init(LST) do { \
- (LST)->firstPtr = NULL; \
- (LST)->lastPtr = NULL; \
- } while (0)
-#define Lst_Initializer(NAME) { NULL, NULL }
-
-/* Duplicate an existing list */
-void Lst_Duplicate(Lst *, Lst *, DuplicateProc *);
-
-/* Destroy an old one */
-void Lst_Destroy(Lst *, FreeProc *);
-
-/*
- * Functions to modify a list
- */
-/* Insert an element before another */
-void Lst_Insert(Lst *, LstNode *, void *);
-/* Insert an element after another */
-void Lst_Append(Lst *, LstNode *, void *);
-/* Place an element at the front of a lst. */
-#define Lst_AtFront(LST, D) (Lst_Insert((LST), Lst_First(LST), (D)))
-/* Place an element at the end of a lst. */
-#define Lst_AtEnd(LST, D) (Lst_Append((LST), Lst_Last(LST), (D)))
-/* Remove an element */
-void Lst_Remove(Lst *, LstNode *);
-/* Replace a node with a new value */
-#define Lst_Replace(NODE, D) ((void)((NODE)->datum = (D)))
-/* Concatenate two lists */
-void Lst_Concat(Lst *, Lst *, int);
-
-/*
- * Node-specific functions
- */
-/* Return first element in list */
-#define Lst_First(LST) ((Lst_Valid(LST) && !Lst_IsEmpty(LST)) \
- ? (LST)->firstPtr : NULL)
-/* Return last element in list */
-#define Lst_Last(LST) ((Lst_Valid(LST) && !Lst_IsEmpty(LST)) \
- ? (LST)->lastPtr : NULL)
-/* Return successor to given element */
-#define Lst_Succ(NODE) (((NODE) == NULL) ? NULL : (NODE)->nextPtr)
-#define LST_NEXT(NODE) ((NODE)->nextPtr)
-/* Get datum from LstNode */
-#define Lst_Datum(NODE) ((NODE)->datum)
-
-/*
- * Functions for entire lists
- */
-
-/*
- * See if the given datum is on the list. Returns the LstNode containing
- * the datum
- */
-LstNode *Lst_Member(Lst *, void *);
-
-/* Loop through a list. Note, that you may not delete the list element. */
-#define LST_FOREACH(PTR, LST) \
- for ((PTR) = (LST)->firstPtr; (PTR) != NULL; (PTR) = (PTR)->nextPtr)
-
-/*
- * for using the list as a queue
- */
-/* Place an element at tail of queue */
-#define Lst_EnQueue(LST, D) (Lst_Valid(LST) \
- ? Lst_Append((LST), Lst_Last(LST), (D)) \
- : (void)0)
-/* Remove an element from head of queue */
-void *Lst_DeQueue(Lst *);
-
-/*
- * LstValid (L) --
- * Return TRUE if the list L is valid
- */
-#define Lst_Valid(L) (((L) == NULL) ? FALSE : TRUE)
-
-/*
- * LstNodeValid (LN, L) --
- * Return TRUE if the LstNode LN is valid with respect to L
- */
-#define Lst_NodeValid(LN, L) (((LN) == NULL) ? FALSE : TRUE)
-
-/*
- * Lst_IsEmpty(L) --
- * TRUE if the list L is empty.
- */
-#define Lst_IsEmpty(L) (!Lst_Valid(L) || (L)->firstPtr == NULL)
-
-#endif /* lst_h_38f3ead1 */
diff --git a/usr.bin/make/main.c b/usr.bin/make/main.c
deleted file mode 100644
index f019d52..0000000
--- a/usr.bin/make/main.c
+++ /dev/null
@@ -1,1339 +0,0 @@
-/*-
- * Copyright (c) 1988, 1989, 1990, 1993
- * The Regents of the University of California. All rights reserved.
- * Copyright (c) 1989 by Berkeley Softworks
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Adam de Boor.
- *
- * 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.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
- *
- * @(#)main.c 8.3 (Berkeley) 3/19/94
- */
-
-#ifndef lint
-#if 0
-static char copyright[] =
-"@(#) Copyright (c) 1988, 1989, 1990, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif
-#endif /* not lint */
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-/*
- * main.c
- * The main file for this entire program. Exit routines etc
- * reside here.
- *
- * Utility functions defined in this file:
- * Main_ParseArgLine
- * Takes a line of arguments, breaks them and
- * treats them as if they were given when first
- * invoked. Used by the parse module to implement
- * the .MFLAGS target.
- */
-
-#include <sys/param.h>
-#include <sys/stat.h>
-#include <sys/time.h>
-#include <sys/queue.h>
-#include <sys/resource.h>
-#include <sys/utsname.h>
-#include <sys/wait.h>
-#include <err.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#include "arch.h"
-#include "buf.h"
-#include "config.h"
-#include "dir.h"
-#include "globals.h"
-#include "GNode.h"
-#include "job.h"
-#include "make.h"
-#include "parse.h"
-#include "pathnames.h"
-#include "shell.h"
-#include "str.h"
-#include "suff.h"
-#include "targ.h"
-#include "util.h"
-#include "var.h"
-
-extern char **environ; /* XXX what header declares this variable? */
-
-#define WANT_ENV_MKLVL 1
-#define MKLVL_MAXVAL 500
-#define MKLVL_ENVVAR "__MKLVL__"
-
-/* ordered list of makefiles to read */
-static Lst makefiles = Lst_Initializer(makefiles);
-
-/* ordered list of source makefiles */
-static Lst source_makefiles = Lst_Initializer(source_makefiles);
-
-/* list of variables to print */
-static Lst variables = Lst_Initializer(variables);
-
-static Boolean expandVars; /* fully expand printed variables */
-static Boolean noBuiltins; /* -r flag */
-static Boolean forceJobs; /* -j argument given */
-static char *curdir; /* startup directory */
-static char *objdir; /* where we chdir'ed to */
-static char **save_argv; /* saved argv */
-static char *save_makeflags;/* saved MAKEFLAGS */
-
-/* (-E) vars to override from env */
-Lst envFirstVars = Lst_Initializer(envFirstVars);
-
-/* Targets to be made */
-Lst create = Lst_Initializer(create);
-
-Boolean allPrecious; /* .PRECIOUS given on line by itself */
-Boolean is_posix; /* .POSIX target seen */
-Boolean mfAutoDeps; /* .MAKEFILEDEPS target seen */
-Boolean remakingMakefiles; /* True if remaking makefiles is in progress */
-Boolean beSilent; /* -s flag */
-Boolean beVerbose; /* -v flag */
-Boolean beQuiet; /* -Q flag */
-Boolean compatMake; /* -B argument */
-int debug; /* -d flag */
-Boolean ignoreErrors; /* -i flag */
-int jobLimit; /* -j argument */
-int makeErrors; /* Number of targets not remade due to errors */
-Boolean jobsRunning; /* TRUE if the jobs might be running */
-Boolean keepgoing; /* -k flag */
-Boolean noExecute; /* -n flag */
-Boolean printGraphOnly; /* -p flag */
-Boolean queryFlag; /* -q flag */
-Boolean touchFlag; /* -t flag */
-Boolean usePipes; /* !-P flag */
-uint32_t warn_cmd; /* command line warning flags */
-uint32_t warn_flags; /* actual warning flags */
-uint32_t warn_nocmd; /* command line no-warning flags */
-
-time_t now; /* Time at start of make */
-struct GNode *DEFAULT; /* .DEFAULT node */
-
-static struct {
- const char *foreign_name;
- const char *freebsd_name;
-} arch_aliases[] = {
- { "x86_64", "amd64" },
- { "mipsel", "mips" },
-};
-
-/**
- * Exit with usage message.
- */
-static void
-usage(void)
-{
- fprintf(stderr,
- "usage: make [-BPSXeiknpqrstv] [-C directory] [-D variable]\n"
- "\t[-d flags] [-E variable] [-f makefile] [-I directory]\n"
- "\t[-j max_jobs] [-m directory] [-V variable]\n"
- "\t[variable=value] [target ...]\n");
- exit(2);
-}
-
-/**
- * MFLAGS_append
- * Append a flag with an optional argument to MAKEFLAGS and MFLAGS
- */
-static void
-MFLAGS_append(const char *flag, char *arg)
-{
- char *str;
-
- Var_Append(".MAKEFLAGS", flag, VAR_GLOBAL);
- if (arg != NULL) {
- str = MAKEFLAGS_quote(arg);
- Var_Append(".MAKEFLAGS", str, VAR_GLOBAL);
- free(str);
- }
-
- Var_Append("MFLAGS", flag, VAR_GLOBAL);
- if (arg != NULL) {
- str = MAKEFLAGS_quote(arg);
- Var_Append("MFLAGS", str, VAR_GLOBAL);
- free(str);
- }
-}
-
-/**
- * Main_ParseWarn
- *
- * Handle argument to warning option.
- */
-int
-Main_ParseWarn(const char *arg, int iscmd)
-{
- int i, neg;
-
- static const struct {
- const char *option;
- uint32_t flag;
- } options[] = {
- { "dirsyntax", WARN_DIRSYNTAX },
- { NULL, 0 }
- };
-
- neg = 0;
- if (arg[0] == 'n' && arg[1] == 'o') {
- neg = 1;
- arg += 2;
- }
-
- for (i = 0; options[i].option != NULL; i++)
- if (strcmp(arg, options[i].option) == 0)
- break;
-
- if (options[i].option == NULL)
- /* unknown option */
- return (-1);
-
- if (iscmd) {
- if (!neg) {
- warn_cmd |= options[i].flag;
- warn_nocmd &= ~options[i].flag;
- warn_flags |= options[i].flag;
- } else {
- warn_nocmd |= options[i].flag;
- warn_cmd &= ~options[i].flag;
- warn_flags &= ~options[i].flag;
- }
- } else {
- if (!neg) {
- warn_flags |= (options[i].flag & ~warn_nocmd);
- } else {
- warn_flags &= ~(options[i].flag | warn_cmd);
- }
- }
- return (0);
-}
-
-/**
- * Open and parse the given makefile.
- *
- * Results:
- * TRUE if ok. FALSE if couldn't open file.
- */
-static Boolean
-ReadMakefile(const char p[])
-{
- char *fname, *fnamesave; /* makefile to read */
- FILE *stream;
- char *name, path[MAXPATHLEN];
- char *MAKEFILE;
- int setMAKEFILE;
-
- /* XXX - remove this once constification is done */
- fnamesave = fname = estrdup(p);
-
- if (!strcmp(fname, "-")) {
- Parse_File("(stdin)", stdin);
- Var_SetGlobal("MAKEFILE", "");
- } else {
- setMAKEFILE = strcmp(fname, ".depend");
-
- /* if we've chdir'd, rebuild the path name */
- if (curdir != objdir && *fname != '/') {
- snprintf(path, MAXPATHLEN, "%s/%s", curdir, fname);
- /*
- * XXX The realpath stuff breaks relative includes
- * XXX in some cases. The problem likely is in
- * XXX parse.c where it does special things in
- * XXX ParseDoInclude if the file is relative
- * XXX or absolute and not a system file. There
- * XXX it assumes that if the current file that's
- * XXX being included is absolute, that any files
- * XXX that it includes shouldn't do the -I path
- * XXX stuff, which is inconsistent with historical
- * XXX behavior. However, I can't penetrate the mists
- * XXX further, so I'm putting this workaround in
- * XXX here until such time as the underlying bug
- * XXX can be fixed.
- */
-#if THIS_BREAKS_THINGS
- if (realpath(path, path) != NULL &&
- (stream = fopen(path, "r")) != NULL) {
- MAKEFILE = fname;
- fname = path;
- goto found;
- }
- } else if (realpath(fname, path) != NULL) {
- MAKEFILE = fname;
- fname = path;
- if ((stream = fopen(fname, "r")) != NULL)
- goto found;
- }
-#else
- if ((stream = fopen(path, "r")) != NULL) {
- MAKEFILE = fname;
- fname = path;
- goto found;
- }
- } else {
- MAKEFILE = fname;
- if ((stream = fopen(fname, "r")) != NULL)
- goto found;
- }
-#endif
- /* look in -I and system include directories. */
- name = Path_FindFile(fname, &parseIncPath);
- if (!name)
- name = Path_FindFile(fname, &sysIncPath);
- if (!name || !(stream = fopen(name, "r"))) {
- free(fnamesave);
- return (FALSE);
- }
- MAKEFILE = fname = name;
- /*
- * set the MAKEFILE variable desired by System V fans -- the
- * placement of the setting here means it gets set to the last
- * makefile specified, as it is set by SysV make.
- */
-found:
- if (setMAKEFILE)
- Var_SetGlobal("MAKEFILE", MAKEFILE);
- Parse_File(fname, stream);
- }
- free(fnamesave);
- return (TRUE);
-}
-
-/**
- * Open and parse the given makefile.
- * If open is successful add it to the list of makefiles.
- *
- * Results:
- * TRUE if ok. FALSE if couldn't open file.
- */
-static Boolean
-TryReadMakefile(const char p[])
-{
- char *data;
- LstNode *last = Lst_Last(&source_makefiles);
-
- if (!ReadMakefile(p))
- return (FALSE);
-
- data = estrdup(p);
- if (last == NULL) {
- LstNode *first = Lst_First(&source_makefiles);
- Lst_Insert(&source_makefiles, first, data);
- } else
- Lst_Append(&source_makefiles, last, estrdup(p));
- return (TRUE);
-}
-
-/**
- * MainParseArgs
- * Parse a given argument vector. Called from main() and from
- * Main_ParseArgLine() when the .MAKEFLAGS target is used.
- *
- * XXX: Deal with command line overriding .MAKEFLAGS in makefile
- *
- * Side Effects:
- * Various global and local flags will be set depending on the flags
- * given
- */
-static void
-MainParseArgs(int argc, char **argv)
-{
- int c;
- Boolean found_dd = FALSE;
- char found_dir[MAXPATHLEN + 1]; /* for searching for sys.mk */
-
-rearg:
- optind = 1; /* since we're called more than once */
- optreset = 1;
-#define OPTFLAGS "ABC:D:d:E:ef:I:ij:km:nPpQqrSstV:vXx:"
- for (;;) {
- if ((optind < argc) && strcmp(argv[optind], "--") == 0) {
- found_dd = TRUE;
- }
- if ((c = getopt(argc, argv, OPTFLAGS)) == -1) {
- break;
- }
- switch(c) {
-
- case 'A':
- arch_fatal = FALSE;
- MFLAGS_append("-A", NULL);
- break;
- case 'B':
- compatMake = TRUE;
- MFLAGS_append("-B", NULL);
- unsetenv("MAKE_JOBS_FIFO");
- break;
- case 'C':
- if (chdir(optarg) == -1)
- err(1, "chdir %s", optarg);
- if (getcwd(curdir, MAXPATHLEN) == NULL)
- err(2, NULL);
- break;
- case 'D':
- Var_SetGlobal(optarg, "1");
- MFLAGS_append("-D", optarg);
- break;
- case 'd': {
- char *modules = optarg;
-
- for (; *modules; ++modules)
- switch (*modules) {
- case 'A':
- debug = ~0;
- break;
- case 'a':
- debug |= DEBUG_ARCH;
- break;
- case 'c':
- debug |= DEBUG_COND;
- break;
- case 'd':
- debug |= DEBUG_DIR;
- break;
- case 'f':
- debug |= DEBUG_FOR;
- break;
- case 'g':
- if (modules[1] == '1') {
- debug |= DEBUG_GRAPH1;
- ++modules;
- }
- else if (modules[1] == '2') {
- debug |= DEBUG_GRAPH2;
- ++modules;
- }
- break;
- case 'j':
- debug |= DEBUG_JOB;
- break;
- case 'l':
- debug |= DEBUG_LOUD;
- break;
- case 'm':
- debug |= DEBUG_MAKE;
- break;
- case 's':
- debug |= DEBUG_SUFF;
- break;
- case 't':
- debug |= DEBUG_TARG;
- break;
- case 'v':
- debug |= DEBUG_VAR;
- break;
- default:
- warnx("illegal argument to d option "
- "-- %c", *modules);
- usage();
- }
- MFLAGS_append("-d", optarg);
- break;
- }
- case 'E':
- Lst_AtEnd(&envFirstVars, estrdup(optarg));
- MFLAGS_append("-E", optarg);
- break;
- case 'e':
- checkEnvFirst = TRUE;
- MFLAGS_append("-e", NULL);
- break;
- case 'f':
- Lst_AtEnd(&makefiles, estrdup(optarg));
- break;
- case 'I':
- Parse_AddIncludeDir(optarg);
- MFLAGS_append("-I", optarg);
- break;
- case 'i':
- ignoreErrors = TRUE;
- MFLAGS_append("-i", NULL);
- break;
- case 'j': {
- char *endptr;
-
- forceJobs = TRUE;
- jobLimit = strtol(optarg, &endptr, 10);
- if (jobLimit <= 0 || *endptr != '\0') {
- warnx("illegal number, -j argument -- %s",
- optarg);
- usage();
- }
- MFLAGS_append("-j", optarg);
- break;
- }
- case 'k':
- keepgoing = TRUE;
- MFLAGS_append("-k", NULL);
- break;
- case 'm':
- /* look for magic parent directory search string */
- if (strncmp(".../", optarg, 4) == 0) {
- if (!Dir_FindHereOrAbove(curdir, optarg + 4,
- found_dir, sizeof(found_dir)))
- break; /* nothing doing */
- Path_AddDir(&sysIncPath, found_dir);
- } else {
- Path_AddDir(&sysIncPath, optarg);
- }
- MFLAGS_append("-m", optarg);
- break;
- case 'n':
- noExecute = TRUE;
- MFLAGS_append("-n", NULL);
- break;
- case 'P':
- usePipes = FALSE;
- MFLAGS_append("-P", NULL);
- break;
- case 'p':
- printGraphOnly = TRUE;
- debug |= DEBUG_GRAPH1;
- break;
- case 'Q':
- beQuiet = TRUE;
- beVerbose = FALSE;
- MFLAGS_append("-Q", NULL);
- break;
- case 'q':
- queryFlag = TRUE;
- /* Kind of nonsensical, wot? */
- MFLAGS_append("-q", NULL);
- break;
- case 'r':
- noBuiltins = TRUE;
- MFLAGS_append("-r", NULL);
- break;
- case 'S':
- keepgoing = FALSE;
- MFLAGS_append("-S", NULL);
- break;
- case 's':
- beSilent = TRUE;
- MFLAGS_append("-s", NULL);
- break;
- case 't':
- touchFlag = TRUE;
- MFLAGS_append("-t", NULL);
- break;
- case 'V':
- Lst_AtEnd(&variables, estrdup(optarg));
- MFLAGS_append("-V", optarg);
- break;
- case 'v':
- beVerbose = TRUE;
- beQuiet = FALSE;
- MFLAGS_append("-v", NULL);
- break;
- case 'X':
- expandVars = FALSE;
- break;
- case 'x':
- if (Main_ParseWarn(optarg, 1) != -1)
- MFLAGS_append("-x", optarg);
- break;
-
- default:
- case '?':
- usage();
- }
- }
- argv += optind;
- argc -= optind;
-
- oldVars = TRUE;
-
- /*
- * Parse the rest of the arguments.
- * o Check for variable assignments and perform them if so.
- * o Check for more flags and restart getopt if so.
- * o Anything else is taken to be a target and added
- * to the end of the "create" list.
- */
- for (; *argv != NULL; ++argv, --argc) {
- if (Parse_IsVar(*argv)) {
- char *ptr = MAKEFLAGS_quote(*argv);
- char *v = estrdup(*argv);
-
- Var_Append(".MAKEFLAGS", ptr, VAR_GLOBAL);
- Parse_DoVar(v, VAR_CMD);
- free(ptr);
- free(v);
-
- } else if ((*argv)[0] == '-') {
- if ((*argv)[1] == '\0') {
- /*
- * (*argv) is a single dash, so we
- * just ignore it.
- */
- } else if (found_dd) {
- /*
- * Double dash has been found, ignore
- * any more options. But what do we do
- * with it? For now treat it like a target.
- */
- Lst_AtEnd(&create, estrdup(*argv));
- } else {
- /*
- * (*argv) is a -flag, so backup argv and
- * argc. getopt() expects options to start
- * in the 2nd position.
- */
- argc++;
- argv--;
- goto rearg;
- }
-
- } else if ((*argv)[0] == '\0') {
- Punt("illegal (null) argument.");
-
- } else {
- Lst_AtEnd(&create, estrdup(*argv));
- }
- }
-}
-
-/**
- * Main_ParseArgLine
- * Used by the parse module when a .MFLAGS or .MAKEFLAGS target
- * is encountered and by main() when reading the .MAKEFLAGS envariable.
- * Takes a line of arguments and breaks it into its
- * component words and passes those words and the number of them to the
- * MainParseArgs function.
- * The line should have all its leading whitespace removed.
- *
- * Side Effects:
- * Only those that come from the various arguments.
- */
-void
-Main_ParseArgLine(char *line, int mflags)
-{
- ArgArray aa;
-
- if (line == NULL)
- return;
- for (; *line == ' '; ++line)
- continue;
- if (!*line)
- return;
-
- if (mflags)
- MAKEFLAGS_break(&aa, line);
- else
- brk_string(&aa, line, TRUE);
-
- MainParseArgs(aa.argc, aa.argv);
- ArgArray_Done(&aa);
-}
-
-static char *
-chdir_verify_path(const char *path, char *obpath)
-{
- struct stat sb;
-
- if (stat(path, &sb) == 0 && S_ISDIR(sb.st_mode)) {
- if (chdir(path) == -1 || getcwd(obpath, MAXPATHLEN) == NULL) {
- warn("warning: %s", path);
- return (NULL);
- }
- return (obpath);
- }
-
- return (NULL);
-}
-
-/**
- * In lieu of a good way to prevent every possible looping in make(1), stop
- * there from being more than MKLVL_MAXVAL processes forked by make(1), to
- * prevent a forkbomb from happening, in a dumb and mechanical way.
- *
- * Side Effects:
- * Creates or modifies environment variable MKLVL_ENVVAR via setenv().
- */
-static void
-check_make_level(void)
-{
-#ifdef WANT_ENV_MKLVL
- char *value = getenv(MKLVL_ENVVAR);
- int level = (value == NULL) ? 0 : atoi(value);
-
- if (level < 0) {
- errx(2, "Invalid value for recursion level (%d).", level);
- } else if (level > MKLVL_MAXVAL) {
- errx(2, "Max recursion level (%d) exceeded.", MKLVL_MAXVAL);
- } else {
- char new_value[32];
- sprintf(new_value, "%d", level + 1);
- setenv(MKLVL_ENVVAR, new_value, 1);
- }
-#endif /* WANT_ENV_MKLVL */
-}
-
-/**
- * Main_AddSourceMakefile
- * Add a file to the list of source makefiles
- */
-void
-Main_AddSourceMakefile(const char *name)
-{
-
- Lst_AtEnd(&source_makefiles, estrdup(name));
-}
-
-/**
- * Remake_Makefiles
- * Remake all the makefiles
- */
-static void
-Remake_Makefiles(void)
-{
- Lst cleanup;
- LstNode *ln;
- int error_cnt = 0;
- int remade_cnt = 0;
-
- Compat_InstallSignalHandlers();
- if (curdir != objdir) {
- if (chdir(curdir) < 0)
- Fatal("Failed to change directory to %s.", curdir);
- }
-
- Lst_Init(&cleanup);
- LST_FOREACH(ln, &source_makefiles) {
- LstNode *ln2;
- struct GNode *gn;
- const char *name = Lst_Datum(ln);
- Boolean saveTouchFlag = touchFlag;
- Boolean saveQueryFlag = queryFlag;
- Boolean saveNoExecute = noExecute;
- int mtime;
-
- /*
- * Create node
- */
- gn = Targ_FindNode(name, TARG_CREATE);
- DEBUGF(MAKE, ("Checking %s...", gn->name));
- Suff_FindDeps(gn);
-
- /*
- * -t, -q and -n has no effect unless the makefile is
- * specified as one of the targets explicitly in the
- * command line
- */
- LST_FOREACH(ln2, &create) {
- if (!strcmp(gn->name, Lst_Datum(ln2))) {
- /* found as a target */
- break;
- }
- }
- if (ln2 == NULL) {
- touchFlag = FALSE;
- queryFlag = FALSE;
- noExecute = FALSE;
- }
-
- /*
- * Check and remake the makefile
- */
- mtime = Dir_MTime(gn);
- remakingMakefiles = TRUE;
- Compat_Make(gn, gn);
- remakingMakefiles = FALSE;
-
- /*
- * Restore -t, -q and -n behaviour
- */
- touchFlag = saveTouchFlag;
- queryFlag = saveQueryFlag;
- noExecute = saveNoExecute;
-
- /*
- * Compat_Make will leave the 'made' field of gn
- * in one of the following states:
- * UPTODATE gn was already up-to-date
- * MADE gn was recreated successfully
- * ERROR An error occurred while gn was being created
- * ABORTED gn was not remade because one of its inferiors
- * could not be made due to errors.
- */
- if (gn->made == MADE) {
- if (mtime != Dir_MTime(gn)) {
- DEBUGF(MAKE,
- ("%s updated (%d -> %d).\n",
- gn->name, mtime, gn->mtime));
- remade_cnt++;
- } else {
- DEBUGF(MAKE,
- ("%s not updated: skipping restart.\n",
- gn->name));
- }
- } else if (gn->made == ERROR)
- error_cnt++;
- else if (gn->made == ABORTED) {
- printf("`%s' not remade because of errors.\n",
- gn->name);
- error_cnt++;
- } else if (gn->made == UPTODATE) {
- Lst_EnQueue(&cleanup, gn);
- }
- }
-
- if (error_cnt > 0)
- Fatal("Failed to remake Makefiles.");
- if (remade_cnt > 0) {
- DEBUGF(MAKE, ("Restarting `%s'.\n", save_argv[0]));
-
- /*
- * Some of makefiles were remade -- restart from clean state
- */
- if (save_makeflags != NULL)
- setenv("MAKEFLAGS", save_makeflags, 1);
- else
- unsetenv("MAKEFLAGS");
- if (execvp(save_argv[0], save_argv) < 0) {
- Fatal("Can't restart `%s': %s.",
- save_argv[0], strerror(errno));
- }
- }
-
- while (!Lst_IsEmpty(&cleanup)) {
- GNode *gn = Lst_DeQueue(&cleanup);
-
- gn->unmade = 0;
- gn->make = FALSE;
- gn->made = UNMADE;
- gn->childMade = FALSE;
- gn->mtime = gn->cmtime = 0;
- gn->cmtime_gn = NULL;
-
- LST_FOREACH(ln, &gn->children) {
- GNode *cgn = Lst_Datum(ln);
-
- gn->unmade++;
- Lst_EnQueue(&cleanup, cgn);
- }
- }
-
- if (curdir != objdir) {
- if (chdir(objdir) < 0)
- Fatal("Failed to change directory to %s.", objdir);
- }
-}
-
-/**
- * main
- * The main function, for obvious reasons. Initializes variables
- * and a few modules, then parses the arguments give it in the
- * environment and on the command line. Reads the system makefile
- * followed by either Makefile, makefile or the file given by the
- * -f argument. Sets the .MAKEFLAGS PMake variable based on all the
- * flags it has received by then uses either the Make or the Compat
- * module to create the initial list of targets.
- *
- * Results:
- * If -q was given, exits -1 if anything was out-of-date. Else it exits
- * 0.
- *
- * Side Effects:
- * The program exits when done. Targets are created. etc. etc. etc.
- */
-int
-main(int argc, char **argv)
-{
- const char *machine;
- const char *machine_arch;
- const char *machine_cpu;
- Boolean outOfDate = TRUE; /* FALSE if all targets up to date */
- const char *p;
- const char *pathp;
- const char *path;
- char mdpath[MAXPATHLEN];
- char obpath[MAXPATHLEN];
- char cdpath[MAXPATHLEN];
- char found_dir[MAXPATHLEN + 1]; /* for searching for sys.mk */
- char *cp = NULL, *start;
-
- save_argv = argv;
- save_makeflags = getenv("MAKEFLAGS");
- if (save_makeflags != NULL)
- save_makeflags = estrdup(save_makeflags);
-
- /*
- * Initialize file global variables.
- */
- expandVars = TRUE;
- noBuiltins = FALSE; /* Read the built-in rules */
- forceJobs = FALSE; /* No -j flag */
- curdir = cdpath;
-
- /*
- * Initialize program global variables.
- */
- beSilent = FALSE; /* Print commands as executed */
- ignoreErrors = FALSE; /* Pay attention to non-zero returns */
- noExecute = FALSE; /* Execute all commands */
- printGraphOnly = FALSE; /* Don't stop after printing graph */
- keepgoing = FALSE; /* Stop on error */
- allPrecious = FALSE; /* Remove targets when interrupted */
- queryFlag = FALSE; /* This is not just a check-run */
- touchFlag = FALSE; /* Actually update targets */
- usePipes = TRUE; /* Catch child output in pipes */
- debug = 0; /* No debug verbosity, please. */
- jobsRunning = FALSE;
-
- jobLimit = DEFMAXJOBS;
- compatMake = FALSE; /* No compat mode */
-
- check_make_level();
-
-#ifdef RLIMIT_NOFILE
- /*
- * get rid of resource limit on file descriptors
- */
- {
- struct rlimit rl;
- if (getrlimit(RLIMIT_NOFILE, &rl) == -1) {
- err(2, "getrlimit");
- }
- rl.rlim_cur = rl.rlim_max;
- if (setrlimit(RLIMIT_NOFILE, &rl) == -1) {
- err(2, "setrlimit");
- }
- }
-#endif
-
- /*
- * Get the name of this type of MACHINE from utsname
- * so we can share an executable for similar machines.
- * (i.e. m68k: amiga hp300, mac68k, sun3, ...)
- *
- * Note that both MACHINE and MACHINE_ARCH are decided at
- * run-time.
- */
- if ((machine = getenv("MACHINE")) == NULL) {
- static struct utsname utsname;
- unsigned int i;
-
- if (uname(&utsname) == -1)
- err(2, "uname");
- machine = utsname.machine;
-
- /* Canonicalize non-FreeBSD naming conventions */
- for (i = 0; i < sizeof(arch_aliases)
- / sizeof(arch_aliases[0]); i++)
- if (!strcmp(machine, arch_aliases[i].foreign_name)) {
- machine = arch_aliases[i].freebsd_name;
- break;
- }
- }
-
- if ((machine_arch = getenv("MACHINE_ARCH")) == NULL) {
-#ifdef MACHINE_ARCH
- machine_arch = MACHINE_ARCH;
-#else
- machine_arch = "unknown";
-#endif
- }
-
- /*
- * Set machine_cpu to the minimum supported CPU revision based
- * on the target architecture, if not already set.
- */
- if ((machine_cpu = getenv("MACHINE_CPU")) == NULL) {
- if (!strcmp(machine_arch, "i386"))
- machine_cpu = "i486";
- else
- machine_cpu = "unknown";
- }
-
- /*
- * Initialize the parsing, directory and variable modules to prepare
- * for the reading of inclusion paths and variable settings on the
- * command line
- */
- Proc_Init();
-
- Dir_Init(); /* Initialize directory structures so -I flags
- * can be processed correctly */
- Var_Init(environ); /* As well as the lists of variables for
- * parsing arguments */
-
- /*
- * Initialize the Shell so that we have a shell for != assignments
- * on the command line.
- */
- Shell_Init();
-
- /*
- * Initialize various variables.
- * MAKE also gets this name, for compatibility
- * .MAKEFLAGS gets set to the empty string just in case.
- * MFLAGS also gets initialized empty, for compatibility.
- */
- Var_SetGlobal("MAKE", argv[0]);
- Var_SetGlobal(".MAKEFLAGS", "");
- Var_SetGlobal("MFLAGS", "");
- Var_SetGlobal("MACHINE", machine);
- Var_SetGlobal("MACHINE_ARCH", machine_arch);
- Var_SetGlobal("MACHINE_CPU", machine_cpu);
-#ifdef MAKE_VERSION
- Var_SetGlobal("MAKE_VERSION", MAKE_VERSION);
-#endif
- Var_SetGlobal(".newline", "\n"); /* handy for :@ loops */
- {
- char tmp[64];
-
- snprintf(tmp, sizeof(tmp), "%u", getpid());
- Var_SetGlobal(".MAKE.PID", tmp);
- snprintf(tmp, sizeof(tmp), "%u", getppid());
- Var_SetGlobal(".MAKE.PPID", tmp);
- }
- Job_SetPrefix();
-
- /*
- * Find where we are...
- */
- if (getcwd(curdir, MAXPATHLEN) == NULL)
- err(2, NULL);
-
- /*
- * First snag things out of the MAKEFLAGS environment
- * variable. Then parse the command line arguments.
- */
- Main_ParseArgLine(getenv("MAKEFLAGS"), 1);
-
- MainParseArgs(argc, argv);
-
- /*
- * Verify that cwd is sane (after -C may have changed it).
- */
- {
- struct stat sa;
-
- if (stat(curdir, &sa) == -1)
- err(2, "%s", curdir);
- }
-
- /*
- * The object directory location is determined using the
- * following order of preference:
- *
- * 1. MAKEOBJDIRPREFIX`cwd`
- * 2. MAKEOBJDIR
- * 3. PATH_OBJDIR.${MACHINE}
- * 4. PATH_OBJDIR
- * 5. PATH_OBJDIRPREFIX`cwd`
- *
- * If one of the first two fails, use the current directory.
- * If the remaining three all fail, use the current directory.
- *
- * Once things are initted,
- * have to add the original directory to the search path,
- * and modify the paths for the Makefiles appropriately. The
- * current directory is also placed as a variable for make scripts.
- */
- if (!(pathp = getenv("MAKEOBJDIRPREFIX"))) {
- if (!(path = getenv("MAKEOBJDIR"))) {
- path = PATH_OBJDIR;
- pathp = PATH_OBJDIRPREFIX;
- snprintf(mdpath, MAXPATHLEN, "%s.%s", path, machine);
- if (!(objdir = chdir_verify_path(mdpath, obpath)))
- if (!(objdir=chdir_verify_path(path, obpath))) {
- snprintf(mdpath, MAXPATHLEN,
- "%s%s", pathp, curdir);
- if (!(objdir=chdir_verify_path(mdpath,
- obpath)))
- objdir = curdir;
- }
- }
- else if (!(objdir = chdir_verify_path(path, obpath)))
- objdir = curdir;
- }
- else {
- snprintf(mdpath, MAXPATHLEN, "%s%s", pathp, curdir);
- if (!(objdir = chdir_verify_path(mdpath, obpath)))
- objdir = curdir;
- }
- Dir_InitDot(); /* Initialize the "." directory */
- if (objdir != curdir)
- Path_AddDir(&dirSearchPath, curdir);
- Var_SetGlobal(".ST_EXPORTVAR", "YES");
- Var_SetGlobal(".CURDIR", curdir);
- Var_SetGlobal(".OBJDIR", objdir);
-
- if (getenv("MAKE_JOBS_FIFO") != NULL)
- forceJobs = TRUE;
- /*
- * Be compatible if user did not specify -j and did not explicitly
- * turned compatibility on
- */
- if (!compatMake && !forceJobs)
- compatMake = TRUE;
-
- /*
- * Initialize target and suffix modules in preparation for
- * parsing the makefile(s)
- */
- Targ_Init();
- Suff_Init();
-
- DEFAULT = NULL;
- time(&now);
-
- /*
- * Set up the .TARGETS variable to contain the list of targets to be
- * created. If none specified, make the variable empty -- the parser
- * will fill the thing in with the default or .MAIN target.
- */
- if (Lst_IsEmpty(&create)) {
- Var_SetGlobal(".TARGETS", "");
- } else {
- LstNode *ln;
-
- for (ln = Lst_First(&create); ln != NULL; ln = Lst_Succ(ln)) {
- char *name = Lst_Datum(ln);
-
- Var_Append(".TARGETS", name, VAR_GLOBAL);
- }
- }
-
-
- /*
- * If no user-supplied system path was given (through the -m option)
- * add the directories from the DEFSYSPATH (more than one may be given
- * as dir1:...:dirn) to the system include path.
- */
- if (TAILQ_EMPTY(&sysIncPath)) {
- char defsyspath[] = PATH_DEFSYSPATH;
- char *syspath = getenv("MAKESYSPATH");
-
- /*
- * If no user-supplied system path was given (thru -m option)
- * add the directories from the DEFSYSPATH (more than one may
- * be given as dir1:...:dirn) to the system include path.
- */
- if (syspath == NULL || *syspath == '\0')
- syspath = defsyspath;
- else
- syspath = estrdup(syspath);
-
- for (start = syspath; *start != '\0'; start = cp) {
- for (cp = start; *cp != '\0' && *cp != ':'; cp++)
- continue;
- if (*cp == ':') {
- *cp++ = '\0';
- }
- /* look for magic parent directory search string */
- if (strncmp(".../", start, 4) == 0) {
- if (Dir_FindHereOrAbove(curdir, start + 4,
- found_dir, sizeof(found_dir))) {
- Path_AddDir(&sysIncPath, found_dir);
- }
- } else {
- Path_AddDir(&sysIncPath, start);
- }
- }
- if (syspath != defsyspath)
- free(syspath);
- }
-
- /*
- * Read in the built-in rules first, followed by the specified
- * makefile, if it was (makefile != (char *) NULL), or the default
- * Makefile and makefile, in that order, if it wasn't.
- */
- if (!noBuiltins) {
- /* Path of sys.mk */
- Lst sysMkPath = Lst_Initializer(sysMkPath);
- LstNode *ln;
- char defsysmk[] = PATH_DEFSYSMK;
-
- Path_Expand(defsysmk, &sysIncPath, &sysMkPath);
- if (Lst_IsEmpty(&sysMkPath))
- Fatal("make: no system rules (%s).", PATH_DEFSYSMK);
- LST_FOREACH(ln, &sysMkPath) {
- if (!ReadMakefile(Lst_Datum(ln)))
- break;
- }
- if (ln != NULL)
- Fatal("make: cannot open %s.", (char *)Lst_Datum(ln));
- Lst_Destroy(&sysMkPath, free);
- }
-
- if (!Lst_IsEmpty(&makefiles)) {
- LstNode *ln;
-
- LST_FOREACH(ln, &makefiles) {
- if (!TryReadMakefile(Lst_Datum(ln)))
- break;
- }
- if (ln != NULL)
- Fatal("make: cannot open %s.", (char *)Lst_Datum(ln));
- } else if (!TryReadMakefile("BSDmakefile"))
- if (!TryReadMakefile("makefile"))
- TryReadMakefile("Makefile");
-
- ReadMakefile(".depend");
-
- /* Install all the flags into the MAKEFLAGS envariable. */
- if (((p = Var_Value(".MAKEFLAGS", VAR_GLOBAL)) != NULL) && *p)
- setenv("MAKEFLAGS", p, 1);
- else
- setenv("MAKEFLAGS", "", 1);
-
- /*
- * For compatibility, look at the directories in the VPATH variable
- * and add them to the search path, if the variable is defined. The
- * variable's value is in the same format as the PATH envariable, i.e.
- * <directory>:<directory>:<directory>...
- */
- if (Var_Exists("VPATH", VAR_CMD)) {
- /*
- * GCC stores string constants in read-only memory, but
- * Var_Subst will want to write this thing, so store it
- * in an array
- */
- static char VPATH[] = "${VPATH}";
- Buffer *buf;
- char *vpath;
- char *ptr;
- char savec;
-
- buf = Var_Subst(VPATH, VAR_CMD, FALSE);
-
- vpath = Buf_Data(buf);
- do {
- /* skip to end of directory */
- for (ptr = vpath; *ptr != ':' && *ptr != '\0'; ptr++)
- ;
-
- /* Save terminator character so know when to stop */
- savec = *ptr;
- *ptr = '\0';
-
- /* Add directory to search path */
- Path_AddDir(&dirSearchPath, vpath);
-
- vpath = ptr + 1;
- } while (savec != '\0');
-
- Buf_Destroy(buf, TRUE);
- }
-
- /*
- * Now that all search paths have been read for suffixes et al, it's
- * time to add the default search path to their lists...
- */
- Suff_DoPaths();
-
- /* print the initial graph, if the user requested it */
- if (DEBUG(GRAPH1))
- Targ_PrintGraph(1);
-
- /* print the values of any variables requested by the user */
- if (Lst_IsEmpty(&variables) && !printGraphOnly) {
- /*
- * Since the user has not requested that any variables
- * be printed, we can build targets.
- *
- * Have read the entire graph and need to make a list of targets
- * to create. If none was given on the command line, we consult
- * the parsing module to find the main target(s) to create.
- */
- Lst targs = Lst_Initializer(targs);
-
- if (!is_posix && mfAutoDeps) {
- /*
- * Check if any of the makefiles are out-of-date.
- */
- Remake_Makefiles();
- }
-
- if (Lst_IsEmpty(&create))
- Parse_MainName(&targs);
- else
- Targ_FindList(&targs, &create, TARG_CREATE);
-
- if (compatMake) {
- /*
- * Compat_Init will take care of creating
- * all the targets as well as initializing
- * the module.
- */
- Compat_Run(&targs);
- outOfDate = 0;
- } else {
- /*
- * Initialize job module before traversing
- * the graph, now that any .BEGIN and .END
- * targets have been read. This is done
- * only if the -q flag wasn't given (to
- * prevent the .BEGIN from being executed
- * should it exist).
- */
- if (!queryFlag) {
- Job_Init(jobLimit);
- jobsRunning = TRUE;
- }
-
- /* Traverse the graph, checking on all the targets */
- outOfDate = Make_Run(&targs);
- }
- Lst_Destroy(&targs, NOFREE);
-
- } else {
- Var_Print(&variables, expandVars);
- }
-
- Lst_Destroy(&variables, free);
- Lst_Destroy(&makefiles, free);
- Lst_Destroy(&source_makefiles, free);
- Lst_Destroy(&create, free);
-
- /* print the graph now it's been processed if the user requested it */
- if (DEBUG(GRAPH2))
- Targ_PrintGraph(2);
-
- if (queryFlag)
- return (outOfDate);
-
- if (makeErrors != 0)
- Finish(makeErrors);
-
- return (0);
-}
diff --git a/usr.bin/make/make.1 b/usr.bin/make/make.1
deleted file mode 100644
index 63da1aa..0000000
--- a/usr.bin/make/make.1
+++ /dev/null
@@ -1,1843 +0,0 @@
-.\" Copyright (c) 1990, 1993
-.\" The Regents of the University of California. 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 distribution.
-.\" 3. Neither the name of the University nor the names of its contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
-.\"
-.\" @(#)make.1 8.8 (Berkeley) 6/13/95
-.\" $FreeBSD$
-.\"
-.Dd May 30, 2012
-.Dt MAKE 1
-.Os
-.Sh NAME
-.Nm make
-.Nd maintain program dependencies
-.Sh SYNOPSIS
-.Nm
-.Op Fl ABPSXeiknpqrstv
-.Op Fl C Ar directory
-.Op Fl D Ar variable
-.Op Fl d Ar flags
-.Op Fl E Ar variable
-.Op Fl f Ar makefile
-.Op Fl I Ar directory
-.Bk -words
-.Op Fl j Ar max_jobs
-.Op Fl m Ar directory
-.Ek
-.Op Fl V Ar variable
-.Op Fl x Ar warning_options
-.Op Ar variable Ns No = Ns Ar value
-.Op Ar target ...
-.Sh DESCRIPTION
-The
-.Nm
-utility is a program designed to simplify the maintenance of other programs.
-Its input is a list of specifications
-describing dependency relationships between the generation of
-files and programs.
-.Pp
-First of all, the initial list of specifications will be read
-from the system makefile,
-.Pa sys.mk ,
-unless inhibited with the
-.Fl r
-option.
-The standard
-.Pa sys.mk
-as shipped with
-.Fx
-also handles
-.Xr make.conf 5 ,
-the default path to which
-can be altered via the
-.Nm
-variable
-.Va __MAKE_CONF .
-.Pp
-Then the first of
-.Pa BSDmakefile ,
-.Pa makefile ,
-and
-.Pa Makefile
-that can be found in the current directory, object directory (see
-.Va .OBJDIR ) ,
-or search path (see the
-.Fl I
-option)
-will be read for the main list of dependency specifications.
-A different makefile or list of them can be supplied via the
-.Fl f
-option(s).
-Finally, if the file
-.Pa .depend
-can be found in any of the aforesaid locations, it will also be read (see
-.Xr mkdep 1 ) .
-.Pp
-When
-.Nm
-searches for a makefile, its name takes precedence over its location.
-For instance,
-.Pa BSDmakefile
-in the object directory will be favored over
-.Pa Makefile
-in the current directory.
-.Pp
-The options are as follows:
-.Bl -tag -width Ds
-.It Fl A
-Make archive errors non-fatal, causing
-.Nm
-to just skip the remainder
-or all of the archive and continue after printing a message.
-.It Fl B
-Try to be backwards compatible by executing a single shell per command and
-by executing the commands to make the sources of a dependency line in sequence.
-This is turned on by default unless
-.Fl j
-is used.
-.It Fl C Ar directory
-Change to
-.Ar directory
-before reading the makefiles or doing anything else.
-If multiple
-.Fl C
-options are specified, each is interpreted relative to the previous one:
-.Fl C Pa / Fl C Pa etc
-is equivalent to
-.Fl C Pa /etc .
-.It Fl D Ar variable
-Define
-.Ar variable
-to be 1, in the global context.
-.It Fl d Ar flags
-Turn on debugging, and specify which portions of
-.Nm
-are to print debugging information.
-Argument
-.Ar flags
-is one or more of the following:
-.Bl -tag -width Ds
-.It Ar A
-Print all possible debugging information;
-equivalent to specifying all of the debugging flags.
-.It Ar a
-Print debugging information about archive searching and caching.
-.It Ar c
-Print debugging information about conditional evaluation.
-.It Ar d
-Print debugging information about directory searching and caching.
-.It Ar f
-Print debugging information about the execution of for loops.
-.It Ar "g1"
-Print the input graph before making anything.
-.It Ar "g2"
-Print the input graph after making everything, or before exiting
-on error.
-.It Ar j
-Print debugging information about running multiple shells.
-.It Ar l
-Print commands in Makefiles regardless of whether or not they are prefixed
-by @ or other "quiet" flags.
-Also known as "loud" behavior.
-.It Ar m
-Print debugging information about making targets, including modification
-dates.
-.It Ar s
-Print debugging information about suffix-transformation rules.
-.It Ar t
-Print debugging information about target list maintenance.
-.It Ar v
-Print debugging information about variable assignment.
-.El
-.It Fl E Ar variable
-Specify a variable whose environment value (if any) will override
-macro assignments within makefiles.
-.It Fl e
-Specify that environment values override macro assignments within
-makefiles for all variables.
-.It Fl f Ar makefile
-Specify a makefile to read instead of the default one.
-If
-.Ar makefile
-is not an absolute pathname,
-.Nm
-will search for it as described above.
-In case
-.Ar makefile
-is
-.Sq Fl ,
-standard input is read.
-Multiple
-.Fl f
-options can be supplied,
-and the makefiles will be read in that order.
-Unlike the other command-line options,
-.Fl f
-is neither stored in
-.Va .MAKEFLAGS
-nor pushed down to sub-makes via
-.Ev MAKEFLAGS .
-See below for more details on these variables.
-.It Fl I Ar directory
-Specify a directory in which to search for makefiles and included makefiles.
-Multiple
-.Fl I
-options can be specified to form a search path.
-The system makefile directory (or directories, see the
-.Fl m
-option) is automatically appended at the tail of this path.
-.It Fl i
-Ignore non-zero exit of shell commands in the makefile.
-Equivalent to specifying
-.Sq Ic \-
-before each command line in the makefile.
-.It Fl j Ar max_jobs
-Specify the maximum number of jobs that
-.Nm
-may have running at any one time.
-Turns compatibility mode off, unless the
-.Fl B
-flag is also specified.
-.It Fl k
-Continue processing after errors are encountered, but only on those targets
-that do not depend on the target whose creation caused the error.
-.It Fl m Ar directory
-Specify a directory in which to search for
-the system makefile and makefiles included via the <...> style.
-Multiple
-.Fl m
-options can be specified to form a search path.
-This path will override the default system include path,
-.Pa /usr/share/mk .
-The system include path will always be appended to the search path used
-for "..."-style inclusions and makefile searches (see the
-.Fl I
-option).
-.Pp
-If a file or directory name in the
-.Fl m
-argument (or the
-.Ev MAKESYSPATH
-environment variable) starts with the string
-.Qq \&.../
-then
-.Nm
-will search for the specified file or directory named in the remaining part
-of the argument string.
-The search starts with the current directory of the Makefile and then works
-upward towards the root of the filesystem.
-If the search is successful,
-then the resulting directory replaces the
-.Qq \&.../
-specification in the
-.Fl m
-argument.
-If used, this feature allows
-.Nm
-to easily search in the current source tree for customized sys.mk files
-(e.g. by using
-.Qq \&.../mk/sys.mk
-as an argument).
-Note that a
-.Fl C
-that are earlier on the command line affect where
-.Fl m Qq \&.../
-searches.
-.It Fl n
-Display the commands that would have been executed, but do not actually
-execute them.
-.It Fl P
-Collate the output of a given job and display it only when the job finishes,
-instead of mixing the output of parallel jobs together.
-This option has no effect unless
-.Fl j
-is used too.
-.It Fl p
-Only print the input graph, not executing any commands.
-The output is the same as
-.Fl d Ar g1 .
-When combined with
-.Fl f Pa /dev/null ,
-only the builtin rules of
-.Nm
-are displayed.
-.It Fl Q
-Be extra quiet.
-For multi-job makes, this will cause file banners not to be generated.
-.It Fl q
-Do not execute any commands, but exit 0 if the specified targets are
-up-to-date and 1, otherwise.
-.It Fl r
-Do not process the system makefile.
-.It Fl S
-Stop processing when an error is encountered.
-Default behaviour.
-This is needed to negate the
-.Fl k
-option during recursive builds.
-.It Fl s
-Do not echo any commands as they are executed.
-Equivalent to specifying
-.Sq Ic @
-before each command line in the makefile.
-.It Fl t
-Rather than re-building a target as specified in the makefile, create it
-or update its modification time to make it appear up-to-date.
-.It Fl V Ar variable
-Print
-.Nm Ns 's
-idea of the value of
-.Ar variable ,
-in the global context.
-Do not build any targets.
-Multiple instances of this option may be specified;
-the variables will be printed one per line,
-with a blank line for each null or undefined variable.
-If
-.Ar variable
-contains a
-.Sq Ic $
-then the value will be expanded before printing.
-.It Fl v
-Be extra verbose.
-Print any extra information.
-.It Fl X
-When using the
-.Fl V
-option to print the values of variables,
-do not recursively expand the values.
-.It Ar variable Ns No = Ns Ar value
-Set the value of the variable
-.Ar variable
-to
-.Ar value .
-.It Fl x Ar warning_options
-Specify extended warning options.
-This option may be specified several times.
-A
-.Ar warning_option
-can be prefixed with
-.Dq Li no
-in which case the warning is switched off.
-The currently available options are:
-.Bl -tag -width indent
-.It Li dirsyntax
-Warn if anything except blanks and comments follows an
-.Ic .endif
-or
-.Ic .else
-directive.
-.El
-.Pp
-See also the
-.Ic .WARN
-special target.
-.El
-.Pp
-There are seven different types of lines in a makefile: file dependency
-specifications, shell commands, variable assignments, include statements,
-conditional directives, for loops, and comments.
-.Pp
-In general, lines may be continued from one line to the next by ending
-them with a backslash
-.Pq Ql \e .
-The trailing newline character and initial whitespace on the following
-line are compressed into a single space.
-.Sh FILE DEPENDENCY SPECIFICATIONS
-Dependency lines consist of one or more targets, an operator, and zero
-or more sources.
-This creates a relationship where the targets
-.Dq depend
-on the sources
-and are usually created from them.
-The exact relationship between the target and the source is determined
-by the operator that separates them.
-The three operators are as follows:
-.Bl -tag -width flag
-.It Ic \&:
-A target is considered out-of-date if its modification time is less than
-those of any of its sources.
-Sources for a target accumulate over dependency lines when this operator
-is used.
-The target is removed if
-.Nm
-is interrupted.
-.It Ic \&!
-Targets are always re-created, but not until all sources have been
-examined and re-created as necessary.
-Sources for a target accumulate over dependency lines when this operator
-is used.
-The target is removed if
-.Nm
-is interrupted.
-.It Ic ::
-If no sources are specified, the target is always re-created.
-Otherwise, a target is considered out-of-date if any of its sources has
-been modified more recently than the target.
-Sources for a target do not accumulate over dependency lines when this
-operator is used.
-The target will not be removed if
-.Nm
-is interrupted.
-.El
-.Pp
-Targets and sources may contain the shell wildcard expressions
-.Ql \&? ,
-.Ql * ,
-.Ql []
-and
-.Ql {} .
-The expressions
-.Ql \&? ,
-.Ql *
-and
-.Ql []
-may only be used as part of the final
-component of the target or source, and must be used to describe existing
-files.
-The expression
-.Ql {}
-need not necessarily be used to describe existing files.
-Expansion is in directory order, not alphabetically as done in the shell.
-.Sh SHELL COMMANDS
-Each target may have associated with it a series of shell commands, normally
-used to create the target.
-Each of the commands in this script
-.Em must
-be preceded by a tab.
-While any target may appear on a dependency line, only one of these
-dependencies may be followed by a creation script, unless the
-.Sq Ic ::
-operator is used.
-.Pp
-If the first characters of the command line are
-.Sq Ic @ ,
-.Sq Ic \- ,
-and/or
-.Sq Ic + ,
-the command is treated specially.
-A
-.Sq Ic @
-causes the command not to be echoed before it is executed.
-A
-.Sq Ic \-
-causes any non-zero exit status of the command line to be ignored.
-A
-.Sq Ic +
-causes the command to be executed even if
-.Fl n
-is specified on the command line.
-.Sh VARIABLE ASSIGNMENTS
-Variables in
-.Nm
-are much like variables in the shell, and, by tradition,
-consist of all upper-case letters.
-The five operators that can be used to assign values to variables are as
-follows:
-.Bl -tag -width Ds
-.It Ic =
-Assign the value to the variable.
-Any previous value is overridden.
-.It Ic +=
-Append the value to the current value of the variable.
-.It Ic ?=
-Assign the value to the variable if it is not already defined.
-.It Ic :=
-Assign with expansion, i.e., expand the value before assigning it
-to the variable.
-Normally, expansion is not done until the variable is referenced.
-.It Ic !=
-Expand the value and pass it to the shell for execution and assign
-the result to the variable.
-Any newlines in the result are replaced with spaces.
-.El
-.Pp
-Any whitespace before the assigned
-.Ar value
-is removed; if the value is being appended, a single space is inserted
-between the previous contents of the variable and the appended value.
-.Pp
-Variables are expanded by surrounding the variable name with either
-curly braces
-.Pq Ql {}
-or parentheses
-.Pq Ql ()
-and preceding it with
-a dollar sign
-.Pq Ql $ .
-If the variable name contains only a single letter, the surrounding
-braces or parentheses are not required.
-This shorter form is not recommended.
-.Pp
-Variable substitution occurs at two distinct times, depending on where
-the variable is being used.
-Variables in dependency lines are expanded as the line is read.
-Variables in shell commands are expanded when the shell command is
-executed.
-.Pp
-The four different classes of variables (in order of increasing precedence)
-are:
-.Bl -tag -width Ds
-.It Environment variables
-Variables defined as part of
-.Nm Ns 's
-environment.
-.It Global variables
-Variables defined in the makefile or in included makefiles.
-.It Command line variables
-Variables defined as part of the command line and variables
-obtained from the
-.Ev MAKEFLAGS
-environment variable or the
-.Ic .MAKEFLAGS
-target.
-.It Local variables
-Variables that are defined specific to a certain target.
-.El
-.Pp
-If the name of an environment variable appears in a makefile
-on the left-hand side of an assignment,
-a global variable with the same name is created, and the latter
-shadows the former as per their relative precedences.
-The environment is not changed in this case, and the change
-is not exported to programs executed by
-.Nm .
-However, a command-line variable actually replaces
-the environment variable of the same name if the latter exists,
-which is visible to child programs.
-.Pp
-There are seven local variables in
-.Nm :
-.Bl -tag -width ".ARCHIVE"
-.It Va .ALLSRC
-The list of all sources for this target; also known as
-.Sq Va > .
-.It Va .ARCHIVE
-The name of the archive file; also known as
-.Sq Va \&! .
-.It Va .IMPSRC
-The name/path of the source from which the target is to be transformed
-(the
-.Dq implied
-source); also known as
-.Sq Va < .
-.It Va .MEMBER
-The name of the archive member; also known as
-.Sq Va % .
-.It Va .OODATE
-The list of sources for this target that were deemed out-of-date; also
-known as
-.Sq Va \&? .
-.It Va .PREFIX
-The file prefix of the file, containing only the file portion, no suffix
-or preceding directory components; also known as
-.Sq Va * .
-.It Va .TARGET
-The name of the target; also known as
-.Sq Va @ .
-.El
-.Pp
-The shorter forms
-.Sq Va @ ,
-.Sq Va \&! ,
-.Sq Va < ,
-.Sq Va % ,
-.Sq Va \&? ,
-.Sq Va > ,
-and
-.Sq Va *
-are permitted for backward
-compatibility and are not recommended.
-The six variables
-.Sq Va @F ,
-.Sq Va @D ,
-.Sq Va <F ,
-.Sq Va <D ,
-.Sq Va *F ,
-and
-.Sq Va *D
-are
-permitted for compatibility with
-.At V
-makefiles and are not recommended.
-.Pp
-Four of the local variables may be used in sources on dependency lines
-because they expand to the proper value for each target on the line.
-These variables are
-.Va .TARGET ,
-.Va .PREFIX ,
-.Va .ARCHIVE ,
-and
-.Va .MEMBER .
-.Pp
-In addition,
-.Nm
-sets or knows about the following internal variables or environment
-variables:
-.Bl -tag -width ".Va .MAKEFILE_LIST"
-.It Va $
-A single dollar sign
-.Ql $ ,
-i.e.\&
-.Ql $$
-expands to a single dollar
-sign.
-.It Va MAKE
-The name that
-.Nm
-was executed with
-.Pq Va argv Ns Op 0 .
-.It Va .CURDIR
-A path to the directory where
-.Nm
-was executed.
-The
-.Nm
-utility sets
-.Va .CURDIR
-to the canonical path given by
-.Xr getcwd 3 .
-.It Va .OBJDIR
-A path to the directory where the targets are built.
-At startup,
-.Nm
-searches for an alternate directory to place target files.
-It will attempt to change into this special directory
-and will search this directory for makefiles
-not found in the current directory.
-The following directories are tried in order:
-.Pp
-.Bl -enum -compact
-.It
-${MAKEOBJDIRPREFIX}/`pwd -P`
-.It
-${MAKEOBJDIR}
-.It
-obj.${MACHINE}
-.It
-obj
-.It
-/usr/obj/`pwd -P`
-.El
-.Pp
-The first directory that
-.Nm
-successfully changes into is used.
-If either
-.Ev MAKEOBJDIRPREFIX
-or
-.Ev MAKEOBJDIR
-is set in the environment but
-.Nm
-is unable to change into the corresponding directory,
-then the current directory is used
-without checking the remainder of the list.
-If they are undefined and
-.Nm
-is unable to change into any of the remaining three directories,
-then the current directory is used.
-Note, that
-.Ev MAKEOBJDIRPREFIX
-and
-.Ev MAKEOBJDIR
-must be environment variables and should not be set on
-.Nm Ns 's
-command line.
-.Pp
-The
-.Nm
-utility sets
-.Va .OBJDIR
-to the canonical path given by
-.Xr getcwd 3 .
-.It Va .MAKEFILE_LIST
-As
-.Nm
-reads various makefiles, including the default files and any
-obtained from the command line and
-.Ic .include
-and
-.Ic .sinclude
-directives, their names will be automatically appended to the
-.Va .MAKEFILE_LIST
-variable.
-They are added right before
-.Nm
-begins to parse them, so that the name of the current makefile is the
-last word in this variable.
-.It Ev MAKEFLAGS
-The environment variable
-.Ev MAKEFLAGS
-may initially contain anything that
-may be specified on
-.Nm Ns 's
-command line,
-including
-.Fl f
-option(s).
-After processing, its contents are stored in the
-.Va .MAKEFLAGS
-global variable, although any
-.Fl f
-options are omitted.
-Then all options and variable assignments specified on
-.Nm Ns 's
-command line, except for
-.Fl f ,
-are appended to the
-.Va .MAKEFLAGS
-variable.
-.Pp
-Whenever
-.Nm
-executes a program, it sets
-.Ev MAKEFLAGS
-in the program's environment to the current value of the
-.Va .MAKEFLAGS
-global variable.
-Thus, if
-.Ev MAKEFLAGS
-in
-.Nm Ns 's
-environment contains any
-.Fl f
-options, they will not be pushed down to child programs automatically.
-The
-.Nm
-utility effectively filters out
-.Fl f
-options from the environment and command line although it
-passes the rest of its options down to sub-makes via
-.Ev MAKEFLAGS
-by default.
-.Pp
-When passing macro definitions and flag arguments in the
-.Ev MAKEFLAGS
-environment variable,
-space and tab characters are quoted by preceding them with a backslash.
-When reading the
-.Ev MAKEFLAGS
-variable from the environment,
-all sequences of a backslash and one of space or tab
-are replaced just with their second character
-without causing a word break.
-Any other occurrences of a backslash are retained.
-Groups of unquoted space, tab and newline characters cause word
-breaking.
-.It Va .MAKEFLAGS
-Initially, this global variable contains
-.Nm Ns 's
-current run-time options from the environment
-and command line as described above, under
-.Ev MAKEFLAGS .
-By modifying the contents of the
-.Va .MAKEFLAGS
-global variable, the makefile can alter the contents of the
-.Ev MAKEFLAGS
-environment variable made available for all programs which
-.Nm
-executes.
-This includes adding
-.Fl f
-option(s).
-The current value of
-.Va .MAKEFLAGS
-is just copied verbatim to
-.Ev MAKEFLAGS
-in the environment of child programs.
-.Pp
-Note that any options entered to
-.Va .MAKEFLAGS
-neither affect the current instance of
-.Nm
-nor show up in its own copy of
-.Ev MAKEFLAGS
-instantly.
-However, they do show up in the
-.Ev MAKEFLAGS
-environment variable of programs executed by
-.Nm .
-On the other hand, a direct assignment to
-.Ev MAKEFLAGS
-neither affects the current instance of
-.Nm
-nor is passed down to
-.Nm Ns 's
-children.
-Compare with the
-.Ic .MAKEFLAGS
-special target below.
-.It Va MFLAGS
-This variable is provided for backward compatibility and
-contains all the options from the
-.Ev MAKEFLAGS
-environment variable plus any options specified on
-.Nm Ns 's
-command line.
-.It Va .MAKE.PID
-The process-id of
-.Nm .
-.It Va .MAKE.PPID
-The parent process-id of
-.Nm .
-.It Va .MAKE.JOB.PREFIX
-If
-.Nm
-is run with
-.Fl j Fl v
-then output for each target is prefixed with a token
-.Ql --- target ---
-the first part of which can be controlled via
-.Va .MAKE.JOB.PREFIX .
-.br
-For example:
-.Li .MAKE.JOB.PREFIX=${.newline}---${MAKE:T}[${.MAKE.PID}]
-would produce tokens like
-.Ql ---make[1234] target ---
-or
-.Li .MAKE.JOB.PREFIX=---pid[${.MAKE.PID}],ppid[${.MAKE.PPID}]
-would produce tokens like
-.Ql ---pid[56789],ppid[1234] target ---
-making it easier to track the degree of parallelism being achieved.
-.It Va .TARGETS
-List of targets
-.Nm
-is currently building.
-.It Va .INCLUDES
-See
-.Ic .INCLUDES
-special target.
-.It Va .LIBS
-See
-.Ic .LIBS
-special target.
-.It Va MACHINE
-Name of the machine architecture
-.Nm
-is running on, obtained from the
-.Ev MACHINE
-environment variable, or through
-.Xr uname 3
-if not defined.
-.It Va MACHINE_ARCH
-Name of the machine architecture
-.Nm
-was compiled for, defined at compilation time.
-.It Va VPATH
-Makefiles may assign a colon-delimited list of directories to
-.Va VPATH .
-These directories will be searched for source files by
-.Nm
-after it has finished parsing all input makefiles.
-.El
-.Ss Variable Modifiers
-Variable expansion may be modified to select or modify each word of the
-variable (where a
-.Dq word
-is whitespace-delimited sequence of characters).
-The general format of a variable expansion is as follows:
-.Pp
-.Dl {variable[:modifier[:...]]}
-.Pp
-Each modifier begins with a colon and one of the following
-special characters.
-The colon may be escaped with a backslash
-.Pq Ql \e .
-.Bl -tag -width Cm
-.Sm off
-.It Cm :C No / Ar pattern Xo
-.No / Ar replacement
-.No / Op Cm 1g
-.Xc
-.Sm on
-Modify each word of the value,
-substituting every match of the extended regular expression
-.Ar pattern
-(see
-.Xr re_format 7 )
-with the
-.Xr ed 1 Ns \-style
-.Ar replacement
-string.
-Normally, the first occurrence of the pattern in
-each word of the value is changed.
-The
-.Ql 1
-modifier causes the substitution to apply to at most one word; the
-.Ql g
-modifier causes the substitution to apply to as many instances of the
-search pattern as occur in the word or words it is found in.
-Note that
-.Ql 1
-and
-.Ql g
-are orthogonal; the former specifies whether multiple words are
-potentially affected, the latter whether multiple substitutions can
-potentially occur within each affected word.
-.It Cm :E
-Replaces each word in the variable with its suffix.
-.It Cm :H
-Replaces each word in the variable with everything but the last component.
-.It Cm :L
-Converts variable to lower-case letters.
-(deprecated)
-.It Cm :M Ns Ar pattern
-Select only those words that match the rest of the modifier.
-The standard shell wildcard characters
-.Pf ( Ql * ,
-.Ql \&? ,
-and
-.Ql [] )
-may
-be used.
-The wildcard characters may be escaped with a backslash
-.Pq Ql \e .
-.It Cm :N Ns Ar pattern
-This is identical to
-.Cm :M ,
-but selects all words which do not match
-the rest of the modifier.
-.It Cm :O
-Order every word in the variable alphabetically.
-.It Cm :Q
-Quotes every shell meta-character in the variable, so that it can be passed
-safely through recursive invocations of
-.Nm .
-.It Cm :R
-Replaces each word in the variable with everything but its suffix.
-.Sm off
-.It Cm :S No / Ar old_string Xo
-.No / Ar new_string
-.No / Op Cm g
-.Xc
-.Sm on
-Modify the first occurrence of
-.Ar old_string
-in each word of the variable's value, replacing it with
-.Ar new_string .
-If a
-.Ql g
-is appended to the last slash of the pattern, all occurrences
-in each word are replaced.
-If
-.Ar old_string
-begins with a caret
-.Pq Ql ^ ,
-.Ar old_string
-is anchored at the beginning of each word.
-If
-.Ar old_string
-ends with a dollar sign
-.Pq Ql $ ,
-it is anchored at the end of each word.
-Inside
-.Ar new_string ,
-an ampersand
-.Pq Ql &
-is replaced by
-.Ar old_string .
-Any character may be used as a delimiter for the parts of the modifier
-string.
-The anchoring, ampersand, and delimiter characters may be escaped with a
-backslash
-.Pq Ql \e .
-.Pp
-Variable expansion occurs in the normal fashion inside both
-.Ar old_string
-and
-.Ar new_string
-with the single exception that a backslash is used to prevent the expansion
-of a dollar sign
-.Pq Ql $ ,
-not a preceding dollar sign as is usual.
-.It Ar :old_string=new_string
-This is the
-.At V
-style variable substitution.
-It must be the last modifier specified.
-If
-.Ar old_string
-or
-.Ar new_string
-do not contain the pattern matching character
-.Ar %
-then it is assumed that they are
-anchored at the end of each word, so only suffixes or entire
-words may be replaced.
-Otherwise
-.Ar %
-is the substring of
-.Ar old_string
-to be replaced in
-.Ar new_string .
-.It Cm :T
-Replaces each word in the variable with its last component.
-.It Cm :tl
-Converts variable to lower-case letters.
-.It Cm :tu
-Converts variable to upper-case letters.
-.It Cm :U
-Converts variable to upper-case letters.
-(deprecated)
-.It Cm :u
-Remove adjacent duplicate words (like
-.Xr uniq 1 ) .
-.El
-.Sh DIRECTIVES, CONDITIONALS, AND FOR LOOPS
-Directives, conditionals, and for loops reminiscent
-of the C programming language are provided in
-.Nm .
-All such structures are identified by a line beginning with a single
-dot
-.Pq Ql \&.
-character.
-The following directives are supported:
-.Bl -tag -width Ds
-.It Ic .include Ar <file>
-.It Ic .include Ar \*qfile\*q
-Include the specified makefile.
-Variables between the angle brackets
-or double quotes are expanded to form the file name.
-If angle brackets
-are used, the included makefile is expected to be in the system
-makefile directory.
-If double quotes are used, the including
-makefile's directory and any directories specified using the
-.Fl I
-option are searched before the system
-makefile directory.
-.It Ic .sinclude Ar <file>
-.It Ic .sinclude Ar \*qfile\*q
-Like
-.Ic .include ,
-but silently ignored if the file cannot be found and opened.
-.It Ic .undef Ar variable
-Un-define the specified global variable.
-Only global variables may be un-defined.
-.It Ic .error Ar message
-Terminate processing of the makefile immediately.
-The filename of the
-makefile, the line on which the error was encountered and the specified
-message are printed to the standard error output and
-.Nm
-terminates with exit code 1.
-Variables in the message are expanded.
-.It Ic .warning Ar message
-Emit a warning message.
-The filename of the makefile,
-the line on which the warning was encountered,
-and the specified message are printed to the standard error output.
-Variables in the message are expanded.
-.El
-.Pp
-Conditionals are used to determine which parts of the Makefile
-to process.
-They are used similarly to the conditionals supported
-by the C pre-processor.
-The following conditionals are supported:
-.Bl -tag -width Ds
-.It Xo
-.Ic .if
-.Oo \&! Oc Ns Ar expression
-.Op Ar operator expression ...
-.Xc
-Test the value of an expression.
-.It Xo
-.Ic .ifdef
-.Oo \&! Oc Ns Ar variable
-.Op Ar operator variable ...
-.Xc
-Test the value of a variable.
-.It Xo
-.Ic .ifndef
-.Oo \&! Oc Ns Ar variable
-.Op Ar operator variable ...
-.Xc
-Test the value of a variable.
-.It Xo
-.Ic .ifmake
-.Oo \&! Oc Ns Ar target
-.Op Ar operator target ...
-.Xc
-Test the target being built.
-.It Xo
-.Ic .ifnmake
-.Oo \&! Oc Ns Ar target
-.Op Ar operator target ...
-.Xc
-Test the target being built.
-.It Ic .else
-Reverse the sense of the last conditional.
-.It Xo
-.Ic .elif
-.Oo \&! Oc Ns Ar expression
-.Op Ar operator expression ...
-.Xc
-A combination of
-.Ic .else
-followed by
-.Ic .if .
-.It Xo
-.Ic .elifdef
-.Oo \&! Oc Ns Ar variable
-.Op Ar operator variable ...
-.Xc
-A combination of
-.Ic .else
-followed by
-.Ic .ifdef .
-.It Xo
-.Ic .elifndef
-.Oo \&! Oc Ns Ar variable
-.Op Ar operator variable ...
-.Xc
-A combination of
-.Ic .else
-followed by
-.Ic .ifndef .
-.It Xo
-.Ic .elifmake
-.Oo \&! Oc Ns Ar target
-.Op Ar operator target ...
-.Xc
-A combination of
-.Ic .else
-followed by
-.Ic .ifmake .
-.It Xo
-.Ic .elifnmake
-.Oo \&! Oc Ns Ar target
-.Op Ar operator target ...
-.Xc
-A combination of
-.Ic .else
-followed by
-.Ic .ifnmake .
-.It Ic .endif
-End the body of the conditional.
-.El
-.Pp
-The
-.Ar operator
-may be any one of the following:
-.Bl -tag -width "Cm XX"
-.It Cm ||
-Logical
-.Tn OR
-.It Cm &&
-Logical
-.Tn AND ;
-of higher precedence than
-.Sq Ic || .
-.El
-.Pp
-As in C,
-.Nm
-will only evaluate a conditional as far as is necessary to determine
-its value.
-Parentheses may be used to change the order of evaluation.
-The boolean operator
-.Sq Ic !\&
-may be used to logically negate an entire
-conditional.
-It is of higher precedence than
-.Sq Ic && .
-.Pp
-The value of
-.Ar expression
-may be any of the following:
-.Bl -tag -width Ic
-.It Ic defined
-Takes a variable name as an argument and evaluates to true if the variable
-has been defined.
-.It Ic make
-Takes a target name as an argument and evaluates to true if the target
-was specified as part of
-.Nm Ns 's
-command line or was declared the default target (either implicitly or
-explicitly, see
-.Va .MAIN )
-before the line containing the conditional.
-.It Ic empty
-Takes a variable, with possible modifiers, and evaluates to true if
-the expansion of the variable would result in an empty string.
-.It Ic exists
-Takes a file name as an argument and evaluates to true if the file exists.
-The file is searched for on the system search path (see
-.Va .PATH ) .
-.It Ic target
-Takes a target name as an argument and evaluates to true if the target
-has been defined.
-.El
-.Pp
-An
-.Ar expression
-may also be a numeric or string comparison:
-in this case, the left-hand side
-.Ar must be
-a variable expansion, whereas the right-hand side can be a
-constant or a variable expansion.
-Variable expansion is performed on both sides, after which the resulting
-values are compared.
-A value is interpreted as hexadecimal if it is
-preceded by 0x, otherwise it is decimal; octal numbers are not supported.
-.Pp
-String comparison can only use the
-.Sq Ic ==
-or
-.Sq Ic !=
-operators, whereas numeric values (both integer and floating point)
-can also be compared using the
-.Sq Ic > ,
-.Sq Ic >= ,
-.Sq Ic <
-and
-.Sq Ic <=
-operators.
-.Pp
-If no relational operator (and right-hand value) are given, an implicit
-.Sq Ic != 0
-is used.
-However be very careful in using this feature especially
-when the left-hand side variable expansion returns a string.
-.Pp
-When
-.Nm
-is evaluating one of these conditional expressions, and it encounters
-a word it does not recognize, either the
-.Dq make
-or
-.Dq defined
-expression is applied to it, depending on the form of the conditional.
-If the form is
-.Ic .if ,
-.Ic .ifdef
-or
-.Ic .ifndef ,
-the
-.Dq defined
-expression is applied.
-Similarly, if the form is
-.Ic .ifmake
-or
-.Ic .ifnmake ,
-the
-.Dq make
-expression is applied.
-.Pp
-If the conditional evaluates to true the parsing of the makefile continues
-as before.
-If it evaluates to false, the following lines are skipped.
-In both cases this continues until a
-.Ic .else
-or
-.Ic .endif
-is found.
-.Pp
-For loops are typically used to apply a set of rules to a list of files.
-The syntax of a for loop is:
-.Pp
-.Bl -tag -width indent -compact
-.It Ic .for Ar variable Ic in Ar expression
-.It <make-rules>
-.It Ic .endfor
-.El
-.Pp
-After the for
-.Ar expression
-is evaluated, it is split into words.
-The
-iteration
-.Ar variable
-is successively set to each word, and substituted in the
-.Ic make-rules
-inside the body of the for loop.
-.Sh COMMENTS
-Comments begin with a hash
-.Pq Ql #
-character, anywhere but in a shell
-command line, and continue to the end of the line.
-.Sh SPECIAL SOURCES
-.Bl -tag -width Ic
-.It Ic .IGNORE
-Ignore any errors from the commands associated with this target, exactly
-as if they all were preceded by a dash
-.Pq Ql \- .
-.It Ic .MAKE
-Execute the commands associated with this target even if the
-.Fl n
-or
-.Fl t
-options were specified.
-Normally used to mark recursive
-.Nm Ns 's .
-.It Ic .NOTMAIN
-Normally
-.Nm
-selects the first target it encounters as the default target to be built
-if no target was specified.
-This source prevents this target from being selected.
-.It Ic .OPTIONAL
-If a target is marked with this attribute and
-.Nm
-cannot figure out how to create it, it will ignore this fact and assume
-the file is not needed or already exists.
-.It Ic .PRECIOUS
-When
-.Nm
-is interrupted, it removes any partially made targets.
-This source prevents the target from being removed.
-.It Ic .SILENT
-Do not echo any of the commands associated with this target, exactly
-as if they all were preceded by an at sign
-.Pq Ql @ .
-.It Ic .USE
-Turn the target into
-.Nm Ns 's
-version of a macro.
-When the target is used as a source for another target, the other target
-acquires the commands, sources, and attributes (except for
-.Ic .USE )
-of the
-source.
-If the target already has commands, the
-.Ic .USE
-target's commands are appended
-to them.
-.It Ic .WAIT
-If special
-.Ic .WAIT
-source appears in a dependency line, the sources that precede it are
-made before the sources that succeed it in the line.
-Loops are not being
-detected and targets that form loops will be silently ignored.
-.El
-.Sh SPECIAL TARGETS
-Special targets may not be included with other targets, i.e., they must be
-the only target specified.
-.Bl -tag -width Ic
-.It Ic .BEGIN
-Any command lines attached to this target are executed before anything
-else is done.
-.It Ic .DEFAULT
-This is sort of a
-.Ic .USE
-rule for any target (that was used only as a
-source) that
-.Nm
-cannot figure out any other way to create.
-Only the shell script is used.
-The
-.Ic .IMPSRC
-variable of a target that inherits
-.Ic .DEFAULT Ns 's
-commands is set
-to the target's own name.
-.It Ic .END
-Any command lines attached to this target are executed after everything
-else is done.
-.It Ic .IGNORE
-Mark each of the sources with the
-.Ic .IGNORE
-attribute.
-If no sources are specified, this is the equivalent of specifying the
-.Fl i
-option.
-.It Ic .INCLUDES
-A list of suffixes that indicate files that can be included in a source
-file.
-The suffix must have already been declared with
-.Ic .SUFFIXES ;
-any suffix so declared will have the directories on its search path (see
-.Ic .PATH )
-placed in the
-.Va .INCLUDES
-special variable, each preceded by a
-.Fl I
-flag.
-.It Ic .INTERRUPT
-If
-.Nm
-is interrupted, the commands for this target will be executed.
-.It Ic .LIBS
-This does for libraries what
-.Ic .INCLUDES
-does for include files, except that the flag used is
-.Fl L .
-.It Ic .MAIN
-If no target is specified when
-.Nm
-is invoked, this target will be built.
-This is always set, either
-explicitly, or implicitly when
-.Nm
-selects the default target, to give the user a way to refer to the default
-target on the command line.
-.It Ic .MAKEFILEDEPS
-Enable the
-.Dq Remaking Makefiles
-functionality, as explained in the
-.Sx REMAKING MAKEFILES
-section below.
-.It Ic .MAKEFLAGS
-This target provides a way to specify flags for
-.Nm
-when the makefile is used.
-The flags are as if typed to the shell, though the
-.Fl f
-option will have
-no effect.
-Flags (except for
-.Fl f )
-and variable assignments specified as the source
-for this target are also appended to the
-.Va .MAKEFLAGS
-internal variable.
-Please note the difference between this target and the
-.Va .MAKEFLAGS
-internal variable: specifying an option or variable
-assignment as the source for this target will affect
-.Em both
-the current makefile and all processes that
-.Nm
-executes.
-.It Ic .MFLAGS
-Same as above, for backward compatibility.
-.\" XXX: NOT YET!!!!
-.\" .It Ic .NOTPARALLEL
-.\" The named targets are executed in non parallel mode. If no targets are
-.\" specified, then all targets are executed in non parallel mode.
-.It Ic .NOTPARALLEL
-Disable parallel mode.
-.It Ic .NO_PARALLEL
-Same as above, for compatibility with other
-.Nm pmake
-variants.
-.It Ic .ORDER
-The named targets are made in sequence.
-.\" XXX: NOT YET!!!!
-.\" .It Ic .PARALLEL
-.\" The named targets are executed in parallel mode. If no targets are
-.\" specified, then all targets are executed in parallel mode.
-.It Ic .PATH
-The sources are directories which are to be searched for files not
-found in the current directory.
-If no sources are specified, any previously specified directories are
-deleted.
-Where possible, use of
-.Ic .PATH
-is preferred over use of the
-.Va VPATH
-variable.
-.It Ic .PATH\fIsuffix\fR
-The sources are directories which are to be searched for suffixed files
-not found in the current directory.
-The
-.Nm
-utility
-first searches the suffixed search path, before reverting to the default
-path if the file is not found there.
-This form is required for
-.Ic .LIBS
-and
-.Ic .INCLUDES
-to work.
-.It Ic .PHONY
-Apply the
-.Ic .PHONY
-attribute to any specified sources.
-Targets with this attribute are always
-considered to be out of date.
-.It Ic .POSIX
-Adjust
-.Nm Ap s
-behavior to match the applicable
-.Tn POSIX
-specifications.
-(Note this disables the
-.Dq Remaking Makefiles
-feature.)
-.It Ic .PRECIOUS
-Apply the
-.Ic .PRECIOUS
-attribute to any specified sources.
-If no sources are specified, the
-.Ic .PRECIOUS
-attribute is applied to every
-target in the file.
-.It Ic .SHELL
-Select another shell.
-The sources of this target have the format
-.Ar key Ns = Ns Ar value .
-The
-.Ar key
-is one of:
-.Bl -tag -width ".Va hasErrCtl"
-.It Va path
-Specify the path to the new shell.
-.It Va name
-Specify the name of the new shell.
-This may be either one of the three builtin shells (see below) or any
-other name.
-.It Va quiet
-Specify the shell command to turn echoing off.
-.It Va echo
-Specify the shell command to turn echoing on.
-.It Va filter
-Usually shells print the echo off command before turning echoing off.
-This is the exact string that will be printed by the shell and is used
-to filter the shell output to remove the echo off command.
-.It Va echoFlag
-The shell option that turns echoing on.
-.It Va errFlag
-The shell option to turn on error checking.
-If error checking is on, the shell should exit if a command returns
-a non-zero status.
-.It Va hasErrCtl
-True if the shell has error control.
-.It Va check
-If
-.Va hasErrCtl
-is true then this is the shell command to turn error checking on.
-If
-.Va hasErrCtl
-is false then this is a command template to echo commands for which error
-checking is disabled.
-The template must contain a
-.Ql %s .
-.It Va ignore
-If
-.Va hasErrCtl
-is true, this is the shell command to turn error checking off.
-If
-.Va hasErrCtl
-is false, this is a command template to execute a command so that errors
-are ignored.
-The template must contain a
-.Ql %s .
-.It Va meta
-This is a string of meta characters of the shell.
-.It Va builtins
-This is a string holding all the shell's builtin commands separated by blanks.
-The
-.Va meta
-and
-.Va builtins
-strings are used in compat mode.
-When a command line contains neither a meta
-character nor starts with a shell builtin, it is executed directly without
-invoking a shell.
-When one of these strings (or both) is empty all commands are executed
-through a shell.
-.It Va unsetenv
-If true, remove the
-.Ev ENV
-environment variable before executing any command.
-This is useful for the Korn-shell
-.Pq Nm ksh .
-.El
-.Pp
-Values that are strings must be surrounded by double quotes.
-Boolean values are specified as
-.Ql T
-or
-.Ql Y
-(in either case) to mean true.
-Any other value is taken to mean false.
-.Pp
-There are several uses of the
-.Ic .SHELL
-target:
-.Bl -bullet
-.It
-Selecting one of the builtin shells.
-This is done by just specifying the name of the shell with the
-.Va name
-keyword.
-It is also possible to modify the parameters of the builtin shell by just
-specifying other keywords (except for
-.Va path ) .
-.It
-Using another executable for one of the builtin shells.
-This is done by specifying the path to the executable with the
-.Va path
-keyword.
-If the last component is the same as the name of the builtin shell, no
-name needs to be specified; if it is different, the name must be given:
-.Bd -literal -offset indent
-\&.SHELL: path="/usr/local/bin/sh"
-.Ed
-.Pp
-selects the builtin shell
-.Dq Li sh
-but will execute it from
-.Pa /usr/local/bin/sh .
-Like in the previous case, it is possible to modify parameters of the builtin
-shell by just specifying them.
-.It
-Using an entirely different shell.
-This is done by specifying all keywords.
-.El
-.Pp
-The builtin shells are
-.Dq Li sh ,
-.Dq Li csh
-and
-.Dq Li ksh .
-Because
-.Fx
-has no
-.Nm ksh
-in
-.Pa /bin ,
-it is unwise to specify
-.Va name Ns = Ns Qq Li ksh
-without also specifying a path.
-.It Ic .SILENT
-Apply the
-.Ic .SILENT
-attribute to any specified sources.
-If no sources are specified, the
-.Ic .SILENT
-attribute is applied to every
-command in the file.
-.It Ic .SUFFIXES
-Each source specifies a suffix to
-.Nm .
-If no sources are specified, any previous specified suffixes are deleted.
-.It Ic .WARN
-Each source specifies a warning flag as previously described for the
-.Fl x
-command line option.
-Warning flags specified on the command line take precedence over flags
-specified in the makefile.
-Also, command line warning flags are pushed to sub-makes through the
-.Ev MAKEFLAGS
-environment variables so that a warning flag specified on the command
-line will influence all sub-makes.
-Several flags can be specified on a single
-.Ic .WARN
-target by separating them with blanks.
-.El
-.Sh REMAKING MAKEFILES
-If the special target
-.Ic .MAKEFILEDEPS
-exists in the Makefile,
-.Nm
-enables the
-.Dq Remaking Makefiles
-feature.
-After reading Makefile and all the files that are included using
-.Ic .include
-or
-.Ic .sinclude
-directives (source Makefiles)
-.Nm
-considers each source Makefile as a target and tries to rebuild it.
-Both explicit and implicit rules are checked and all source Makefiles
-are updated if necessary. If any of the source Makefiles were rebuilt,
-.Nm
-restarts from clean state.
-.Pp
-To prevent infinite loops the following source Makefile targets are ignored:
-.Bl -bullet
-.It
-.Ic ::
-targets that have no prerequisites
-.It
-.Ic \&!
-targets
-.It
-targets that have
-.Ic .PHONY
-or
-.Ic .EXEC
-attributes
-.It
-targets without prerequisites and without commands
-.El
-.Pp
-When remaking a source Makefile options
-.Ic -t
-(touch target),
-.Ic -q
-(query mode), and
-.Ic -n
-(no exec) do not take effect, unless source Makefile is specified
-explicitly as a target in
-.Nm
-command line.
-.Pp
-Additionally, system makefiles and
-.Ic .depend
-are not considered as Makefiles that can be rebuilt.
-.Sh ENVIRONMENT
-The
-.Nm
-utility uses the following environment variables, if they exist:
-.Ev MACHINE ,
-.Ev MAKE ,
-.Ev MAKEFLAGS ,
-.Ev MAKEOBJDIR ,
-.Ev MAKEOBJDIRPREFIX ,
-and
-.Ev MAKESYSPATH .
-.Sh FILES
-.Bl -tag -width /usr/share/doc/psd/12.make -compact
-.It Pa .depend
-list of dependencies
-.It Pa Makefile
-list of dependencies
-.It Pa makefile
-list of dependencies
-.It Pa obj
-object directory
-.It Pa sys.mk
-system makefile
-.It Pa /usr/share/mk
-default system makefile directory
-.It Pa /usr/share/doc/psd/12.make
-PMake tutorial
-.It Pa /usr/obj
-default
-.Ev MAKEOBJDIRPREFIX
-directory.
-.It Pa /etc/make.conf
-default path to
-.Xr make.conf 5
-.El
-.Sh EXAMPLES
-List all included makefiles in order visited:
-.Pp
-.Dl "make -V .MAKEFILE_LIST | tr \e\ \e\en"
-.Sh COMPATIBILITY
-Older versions of
-.Nm
-used
-.Ev MAKE
-instead of
-.Ev MAKEFLAGS .
-This was removed for
-.Tn POSIX
-compatibility.
-The internal variable
-.Va MAKE
-is set to the same value as
-.Va .MAKE ;
-support for this may be removed in the future.
-.Pp
-The use of the
-.Cm :L
-and
-.Cm :U
-modifiers are deprecated
-in
-.Fx 10.0
-and the more portable (among Pmake decedents)
-.Cm :tl
-and
-.Cm :tu
-should be used instead.
-.Pp
-Most of the more esoteric features of
-.Nm
-should probably be avoided for greater compatibility.
-.Sh SEE ALSO
-.Xr mkdep 1 ,
-.Xr make.conf 5
-.Rs
-.%T "PMake - A Tutorial"
-.Re
-in
-.Pa /usr/share/doc/psd/12.make
-.Sh HISTORY
-A
-.Nm
-command appeared in PWB UNIX.
-.Sh BUGS
-The determination of
-.Va .OBJDIR
-is contorted to the point of absurdity.
-.Pp
-In the presence of several
-.Ic .MAIN
-special targets,
-.Nm
-silently ignores all but the first.
-.Pp
-.Va .TARGETS
-is not set to the default target when
-.Nm
-is invoked without a target name and no
-.Ic .MAIN
-special target exists.
-.Pp
-The evaluation of
-.Ar expression
-in a test is very simple-minded.
-Currently, the only form that works is
-.Ql .if ${VAR} op something .
-For instance, you should write tests as
-.Ql .if ${VAR} == "string"
-not the other way around, which would give you an error.
-.Pp
-For loops are expanded before tests, so a fragment such as:
-.Bd -literal -offset indent
-\&.for ARCH in ${SHARED_ARCHS}
-\&.if ${ARCH} == ${MACHINE}
- ...
-\&.endif
-\&.endfor
-.Ed
-.Pp
-will not work, and should be rewritten as:
-.Bd -literal -offset indent
-\&.for ARCH in ${SHARED_ARCHS}
-\&.if ${MACHINE} == ${ARCH}
- ...
-\&.endif
-\&.endfor
-.Ed
-.Pp
-The parsing code is broken with respect to handling a semicolon
-after a colon, so a fragment like this will fail:
-.Bd -literal -offset indent
-HDRS= foo.h bar.h
-
-all:
-\&.for h in ${HDRS:S;^;${.CURDIR}/;}
- ...
-\&.endfor
-.Ed
-.Pp
-A trailing backslash in a variable value defined on the command line causes
-the delimiting space in the
-.Ev MAKEFLAGS
-environment variable to be preceded by that backslash.
-That causes a submake to not treat that space as a word delimiter.
-Fixing this requires a larger rewrite of the code handling command line
-macros and assignments to
-.Va .MAKEFLAGS .
diff --git a/usr.bin/make/make.c b/usr.bin/make/make.c
deleted file mode 100644
index 3e6cb42..0000000
--- a/usr.bin/make/make.c
+++ /dev/null
@@ -1,819 +0,0 @@
-/*-
- * Copyright (c) 1988, 1989, 1990, 1993
- * The Regents of the University of California. All rights reserved.
- * Copyright (c) 1989 by Berkeley Softworks
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Adam de Boor.
- *
- * 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.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
- *
- * @(#)make.c 8.1 (Berkeley) 6/6/93
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-/*
- * make.c
- * The functions which perform the examination of targets and
- * their suitability for creation
- *
- * Interface:
- * Make_Run Initialize things for the module and recreate
- * whatever needs recreating. Returns TRUE if
- * work was (or would have been) done and FALSE
- * otherwise.
- *
- * Make_Update Update all parents of a given child. Performs
- * various bookkeeping chores like the updating
- * of the cmtime field of the parent, filling
- * of the IMPSRC context variable, etc. It will
- * place the parent on the toBeMade queue if it should be.
- *
- * Make_TimeStamp Function to set the parent's cmtime field
- * based on a child's modification time.
- *
- * Make_DoAllVar Set up the various local variables for a
- * target, including the .ALLSRC variable, making
- * sure that any variable that needs to exist
- * at the very least has the empty value.
- *
- * Make_OODate Determine if a target is out-of-date.
- *
- * Make_HandleUse See if a child is a .USE node for a parent
- * and perform the .USE actions if so.
- */
-
-#include "arch.h"
-#include "config.h"
-#include "dir.h"
-#include "globals.h"
-#include "GNode.h"
-#include "job.h"
-#include "make.h"
-#include "parse.h"
-#include "suff.h"
-#include "targ.h"
-#include "util.h"
-#include "var.h"
-
-/* The current fringe of the graph. These are nodes which await examination
- * by MakeOODate. It is added to by Make_Update and subtracted from by
- * MakeStartJobs */
-static Lst toBeMade = Lst_Initializer(toBeMade);
-
-/*
- * Number of nodes to be processed. If this is non-zero when Job_Empty()
- * returns TRUE, there's a cycle in the graph.
- */
-static int numNodes;
-
-static Boolean MakeStartJobs(void);
-
-/**
- * Make_TimeStamp
- * Set the cmtime field of a parent node based on the mtime stamp in its
- * child. Called from MakeOODate via LST_FOREACH.
- *
- * Results:
- * Always returns 0.
- *
- * Side Effects:
- * The cmtime of the parent node will be changed if the mtime
- * field of the child is greater than it.
- */
-int
-Make_TimeStamp(GNode *pgn, GNode *cgn)
-{
-
- if (cgn->mtime > pgn->cmtime) {
- pgn->cmtime = cgn->mtime;
- pgn->cmtime_gn = cgn;
- }
- return (0);
-}
-
-/**
- * Make_OODate
- * See if a given node is out of date with respect to its sources.
- * Used by Make_Run when deciding which nodes to place on the
- * toBeMade queue initially and by Make_Update to screen out USE and
- * EXEC nodes. In the latter case, however, any other sort of node
- * must be considered out-of-date since at least one of its children
- * will have been recreated.
- *
- * Results:
- * TRUE if the node is out of date. FALSE otherwise.
- *
- * Side Effects:
- * The mtime field of the node and the cmtime field of its parents
- * will/may be changed.
- */
-Boolean
-Make_OODate(GNode *gn)
-{
- Boolean oodate;
- LstNode *ln;
-
- /*
- * Certain types of targets needn't even be sought as their datedness
- * doesn't depend on their modification time...
- */
- if ((gn->type & (OP_JOIN | OP_USE | OP_EXEC)) == 0) {
- Dir_MTime(gn);
- if (gn->mtime != 0) {
- DEBUGF(MAKE, ("modified %s...",
- Targ_FmtTime(gn->mtime)));
- } else {
- DEBUGF(MAKE, ("non-existent..."));
- }
- }
-
- /*
- * A target is remade in one of the following circumstances:
- * its modification time is smaller than that of its youngest child
- * and it would actually be run (has commands or type OP_NOP)
- * it's the object of a force operator
- * it has no children, was on the lhs of an operator and doesn't
- * exist already.
- *
- * Libraries are only considered out-of-date if the archive module says
- * they are.
- *
- * These weird rules are brought to you by Backward-Compatibility and
- * the strange people who wrote 'Make'.
- */
- if (gn->type & OP_USE) {
- /*
- * If the node is a USE node it is *never* out of date
- * no matter *what*.
- */
- DEBUGF(MAKE, (".USE node..."));
- oodate = FALSE;
-
- } else if (gn->type & OP_LIB) {
- DEBUGF(MAKE, ("library..."));
-
- /*
- * always out of date if no children and :: target
- */
- oodate = Arch_LibOODate(gn) ||
- ((gn->cmtime == 0) && (gn->type & OP_DOUBLEDEP));
-
- } else if (gn->type & OP_JOIN) {
- /*
- * A target with the .JOIN attribute is only considered
- * out-of-date if any of its children was out-of-date.
- */
- DEBUGF(MAKE, (".JOIN node..."));
- oodate = gn->childMade;
-
- } else if (gn->type & (OP_FORCE|OP_EXEC|OP_PHONY)) {
- /*
- * A node which is the object of the force (!) operator or
- * which has the .EXEC attribute is always considered
- * out-of-date.
- */
- if (gn->type & OP_FORCE) {
- DEBUGF(MAKE, ("! operator..."));
- } else if (gn->type & OP_PHONY) {
- DEBUGF(MAKE, (".PHONY node..."));
- } else {
- DEBUGF(MAKE, (".EXEC node..."));
- }
-
- if (remakingMakefiles) {
- DEBUGF(MAKE, ("skipping (remaking makefiles)..."));
- oodate = FALSE;
- } else {
- oodate = TRUE;
- }
- } else if (gn->mtime < gn->cmtime ||
- (gn->cmtime == 0 && (gn->mtime == 0 || (gn->type & OP_DOUBLEDEP)))) {
- /*
- * A node whose modification time is less than that of its
- * youngest child or that has no children (cmtime == 0) and
- * either doesn't exist (mtime == 0) or was the object of a
- * :: operator is out-of-date. Why? Because that's the way
- * Make does it.
- */
- if (gn->mtime < gn->cmtime) {
- DEBUGF(MAKE, ("modified before source (%s)...",
- gn->cmtime_gn ? gn->cmtime_gn->path : "???"));
- oodate = TRUE;
- } else if (gn->mtime == 0) {
- DEBUGF(MAKE, ("non-existent and no sources..."));
- if (remakingMakefiles && Lst_IsEmpty(&gn->commands)) {
- DEBUGF(MAKE, ("skipping (no commands and remaking makefiles)..."));
- oodate = FALSE;
- } else {
- oodate = TRUE;
- }
- } else {
- DEBUGF(MAKE, (":: operator and no sources..."));
- if (remakingMakefiles) {
- DEBUGF(MAKE, ("skipping (remaking makefiles)..."));
- oodate = FALSE;
- } else {
- oodate = TRUE;
- }
- }
- } else
- oodate = FALSE;
-
- /*
- * If the target isn't out-of-date, the parents need to know its
- * modification time. Note that targets that appear to be out-of-date
- * but aren't, because they have no commands and aren't of type OP_NOP,
- * have their mtime stay below their children's mtime to keep parents
- * from thinking they're out-of-date.
- */
- if (!oodate) {
- LST_FOREACH(ln, &gn->parents)
- if (Make_TimeStamp(Lst_Datum(ln), gn))
- break;
- }
-
- return (oodate);
-}
-
-/**
- * Make_HandleUse
- * Function called by Make_Run and SuffApplyTransform on the downward
- * pass to handle .USE and transformation nodes. A callback function
- * for LST_FOREACH, it implements the .USE and transformation
- * functionality by copying the node's commands, type flags
- * and children to the parent node. Should be called before the
- * children are enqueued to be looked at.
- *
- * A .USE node is much like an explicit transformation rule, except
- * its commands are always added to the target node, even if the
- * target already has commands.
- *
- * Results:
- * returns 0.
- *
- * Side Effects:
- * Children and commands may be added to the parent and the parent's
- * type may be changed.
- *
- *-----------------------------------------------------------------------
- */
-int
-Make_HandleUse(GNode *cgn, GNode *pgn)
-{
- GNode *gn; /* A child of the .USE node */
- LstNode *ln; /* An element in the children list */
-
- if (cgn->type & (OP_USE | OP_TRANSFORM)) {
- if ((cgn->type & OP_USE) || Lst_IsEmpty(&pgn->commands)) {
- /*
- * .USE or transformation and target has no commands --
- * append the child's commands to the parent.
- */
- Lst_Concat(&pgn->commands, &cgn->commands, LST_CONCNEW);
- }
-
- for (ln = Lst_First(&cgn->children); ln != NULL;
- ln = Lst_Succ(ln)) {
- gn = Lst_Datum(ln);
-
- if (Lst_Member(&pgn->children, gn) == NULL) {
- Lst_AtEnd(&pgn->children, gn);
- Lst_AtEnd(&gn->parents, pgn);
- pgn->unmade += 1;
- }
- }
-
- pgn->type |= cgn->type & ~(OP_OPMASK | OP_USE | OP_TRANSFORM);
-
- /*
- * This child node is now "made", so we decrement the count of
- * unmade children in the parent... We also remove the child
- * from the parent's list to accurately reflect the number of
- * decent children the parent has. This is used by Make_Run to
- * decide whether to queue the parent or examine its children...
- */
- if (cgn->type & OP_USE) {
- pgn->unmade--;
- }
- }
- return (0);
-}
-
-/**
- * Make_Update
- * Perform update on the parents of a node. Used by JobFinish once
- * a node has been dealt with and by MakeStartJobs if it finds an
- * up-to-date node.
- *
- * Results:
- * Always returns 0
- *
- * Side Effects:
- * The unmade field of pgn is decremented and pgn may be placed on
- * the toBeMade queue if this field becomes 0.
- *
- * If the child was made, the parent's childMade field will be set true
- * and its cmtime set to now.
- *
- * If the child wasn't made, the cmtime field of the parent will be
- * altered if the child's mtime is big enough.
- *
- * Finally, if the child is the implied source for the parent, the
- * parent's IMPSRC variable is set appropriately.
- */
-void
-Make_Update(GNode *cgn)
-{
- GNode *pgn; /* the parent node */
- const char *cname; /* the child's name */
- LstNode *ln; /* Element in parents and iParents lists */
- const char *cpref;
-
- cname = Var_Value(TARGET, cgn);
-
- /*
- * If the child was actually made, see what its modification time is
- * now -- some rules won't actually update the file. If the file still
- * doesn't exist, make its mtime now.
- */
- if (cgn->made != UPTODATE) {
-#ifndef RECHECK
- /*
- * We can't re-stat the thing, but we can at least take care
- * of rules where a target depends on a source that actually
- * creates the target, but only if it has changed, e.g.
- *
- * parse.h : parse.o
- *
- * parse.o : parse.y
- * yacc -d parse.y
- * cc -c y.tab.c
- * mv y.tab.o parse.o
- * cmp -s y.tab.h parse.h || mv y.tab.h parse.h
- *
- * In this case, if the definitions produced by yacc haven't
- * changed from before, parse.h won't have been updated and
- * cgn->mtime will reflect the current modification time for
- * parse.h. This is something of a kludge, I admit, but it's a
- * useful one..
- * XXX: People like to use a rule like
- *
- * FRC:
- *
- * To force things that depend on FRC to be made, so we have to
- * check for gn->children being empty as well...
- */
- if (!Lst_IsEmpty(&cgn->commands) ||
- Lst_IsEmpty(&cgn->children)) {
- cgn->mtime = now;
- }
- #else
- /*
- * This is what Make does and it's actually a good thing, as it
- * allows rules like
- *
- * cmp -s y.tab.h parse.h || cp y.tab.h parse.h
- *
- * to function as intended. Unfortunately, thanks to the
- * stateless nature of NFS (by which I mean the loose coupling
- * of two clients using the same file from a common server),
- * there are times when the modification time of a file created
- * on a remote machine will not be modified before the local
- * stat() implied by the Dir_MTime occurs, thus leading us to
- * believe that the file is unchanged, wreaking havoc with
- * files that depend on this one.
- *
- * I have decided it is better to make too much than to make too
- * little, so this stuff is commented out unless you're sure
- * it's ok.
- * -- ardeb 1/12/88
- */
- /*
- * Christos, 4/9/92: If we are saving commands pretend that
- * the target is made now. Otherwise archives with ... rules
- * don't work!
- */
- if (noExecute || (cgn->type & OP_SAVE_CMDS) ||
- Dir_MTime(cgn) == 0) {
- cgn->mtime = now;
- }
- DEBUGF(MAKE, ("update time: %s\n", Targ_FmtTime(cgn->mtime)));
-#endif
- }
-
- for (ln = Lst_First(&cgn->parents); ln != NULL; ln = Lst_Succ(ln)) {
- pgn = Lst_Datum(ln);
- if (pgn->make) {
- pgn->unmade -= 1;
-
- if (!(cgn->type & (OP_EXEC | OP_USE))) {
- if (cgn->made == MADE)
- pgn->childMade = TRUE;
- Make_TimeStamp(pgn, cgn);
- }
- if (pgn->unmade == 0) {
- /*
- * Queue the node up -- any unmade predecessors
- * will be dealt with in MakeStartJobs.
- */
- Lst_EnQueue(&toBeMade, pgn);
- } else if (pgn->unmade < 0) {
- Error("Graph cycles through %s", pgn->name);
- }
- }
- }
-
- /*
- * Deal with successor nodes. If any is marked for making and has an
- * unmade count of 0, has not been made and isn't in the examination
- * queue, it means we need to place it in the queue as it restrained
- * itself before.
- */
- for (ln = Lst_First(&cgn->successors); ln != NULL; ln = Lst_Succ(ln)) {
- GNode *succ = Lst_Datum(ln);
-
- if (succ->make && succ->unmade == 0 && succ->made == UNMADE &&
- Lst_Member(&toBeMade, succ) == NULL) {
- Lst_EnQueue(&toBeMade, succ);
- }
- }
-
- /*
- * Set the .PREFIX and .IMPSRC variables for all the implied parents
- * of this node.
- */
- cpref = Var_Value(PREFIX, cgn);
- for (ln = Lst_First(&cgn->iParents); ln != NULL; ln = Lst_Succ(ln)) {
- pgn = Lst_Datum(ln);
- if (pgn->make) {
- Var_Set(IMPSRC, cname, pgn);
- Var_Set(PREFIX, cpref, pgn);
- }
- }
-}
-
-/**
- * Make_DoAllVar
- * Set up the ALLSRC and OODATE variables. Sad to say, it must be
- * done separately, rather than while traversing the graph. This is
- * because Make defined OODATE to contain all sources whose modification
- * times were later than that of the target, *not* those sources that
- * were out-of-date. Since in both compatibility and native modes,
- * the modification time of the parent isn't found until the child
- * has been dealt with, we have to wait until now to fill in the
- * variable. As for ALLSRC, the ordering is important and not
- * guaranteed when in native mode, so it must be set here, too.
- *
- * Side Effects:
- * The ALLSRC and OODATE variables of the given node is filled in.
- * If the node is a .JOIN node, its TARGET variable will be set to
- * match its ALLSRC variable.
- */
-void
-Make_DoAllVar(GNode *gn)
-{
- LstNode *ln;
- GNode *cgn;
- const char *child;
-
- LST_FOREACH(ln, &gn->children) {
- /*
- * Add the child's name to the ALLSRC and OODATE variables of
- * the given node. The child is added only if it has not been
- * given the .EXEC, .USE or .INVISIBLE attributes. .EXEC and
- * .USE children are very rarely going to be files, so...
- *
- * A child is added to the OODATE variable if its modification
- * time is later than that of its parent, as defined by Make,
- * except if the parent is a .JOIN node. In that case, it is
- * only added to the OODATE variable if it was actually made
- * (since .JOIN nodes don't have modification times, the
- * comparison is rather unfair...).
- */
- cgn = Lst_Datum(ln);
-
- if ((cgn->type & (OP_EXEC | OP_USE | OP_INVISIBLE)) == 0) {
- if (OP_NOP(cgn->type)) {
- /*
- * this node is only source; use the specific
- * pathname for it
- */
- child = cgn->path ? cgn->path : cgn->name;
- } else
- child = Var_Value(TARGET, cgn);
- Var_Append(ALLSRC, child, gn);
- if (gn->type & OP_JOIN) {
- if (cgn->made == MADE) {
- Var_Append(OODATE, child, gn);
- }
- } else if (gn->mtime < cgn->mtime ||
- (cgn->mtime >= now && cgn->made == MADE)) {
- /*
- * It goes in the OODATE variable if the parent
- * is younger than the child or if the child has
- * been modified more recently than the start of
- * the make. This is to keep pmake from getting
- * confused if something else updates the parent
- * after the make starts (shouldn't happen, I
- * know, but sometimes it does). In such a case,
- * if we've updated the kid, the parent is
- * likely to have a modification time later than
- * that of the kid and anything that relies on
- * the OODATE variable will be hosed.
- *
- * XXX: This will cause all made children to
- * go in the OODATE variable, even if they're
- * not touched, if RECHECK isn't defined, since
- * cgn->mtime is set to now in Make_Update.
- * According to some people, this is good...
- */
- Var_Append(OODATE, child, gn);
- }
- }
- }
-
- if (!Var_Exists (OODATE, gn)) {
- Var_Set(OODATE, "", gn);
- }
- if (!Var_Exists (ALLSRC, gn)) {
- Var_Set(ALLSRC, "", gn);
- }
-
- if (gn->type & OP_JOIN) {
- Var_Set(TARGET, Var_Value(ALLSRC, gn), gn);
- }
-}
-
-/**
- * MakeStartJobs
- * Start as many jobs as possible.
- *
- * Results:
- * If the query flag was given to pmake, no job will be started,
- * but as soon as an out-of-date target is found, this function
- * returns TRUE. At all other times, this function returns FALSE.
- *
- * Side Effects:
- * Nodes are removed from the toBeMade queue and job table slots
- * are filled.
- */
-static Boolean
-MakeStartJobs(void)
-{
- GNode *gn;
-
- while (!Lst_IsEmpty(&toBeMade) && !Job_Full()) {
- gn = Lst_DeQueue(&toBeMade);
- DEBUGF(MAKE, ("Examining %s...", gn->name));
-
- /*
- * Make sure any and all predecessors that are going to be made,
- * have been.
- */
- if (!Lst_IsEmpty(&gn->preds)) {
- LstNode *ln;
-
- for (ln = Lst_First(&gn->preds); ln != NULL;
- ln = Lst_Succ(ln)){
- GNode *pgn = Lst_Datum(ln);
-
- if (pgn->make && pgn->made == UNMADE) {
- DEBUGF(MAKE, ("predecessor %s not made "
- "yet.\n", pgn->name));
- break;
- }
- }
- /*
- * If ln isn't NULL, there's a predecessor as yet
- * unmade, so we just drop this node on the floor.
- * When the node in question has been made, it will
- * notice this node as being ready to make but as yet
- * unmade and will place the node on the queue.
- */
- if (ln != NULL) {
- continue;
- }
- }
-
- numNodes--;
- if (Make_OODate(gn)) {
- DEBUGF(MAKE, ("out-of-date\n"));
- if (queryFlag) {
- return (TRUE);
- }
- Make_DoAllVar(gn);
- Job_Make(gn);
- } else {
- DEBUGF(MAKE, ("up-to-date\n"));
- gn->made = UPTODATE;
- if (gn->type & OP_JOIN) {
- /*
- * Even for an up-to-date .JOIN node, we need
- * it to have its context variables so
- * references to it get the correct value for
- * .TARGET when building up the context
- * variables of its parent(s)...
- */
- Make_DoAllVar(gn);
- }
-
- Make_Update(gn);
- }
- }
- return (FALSE);
-}
-
-/**
- * MakePrintStatus
- * Print the status of a top-level node, viz. it being up-to-date
- * already or not created due to an error in a lower level.
- * Callback function for Make_Run via LST_FOREACH. If gn->unmade is
- * nonzero and that is meant to imply a cycle in the graph, then
- * cycle is TRUE.
- *
- * Side Effects:
- * A message may be printed.
- */
-static void
-MakePrintStatus(GNode *gn, Boolean cycle)
-{
- LstNode *ln;
-
- if (gn->made == UPTODATE) {
- printf("`%s' is up to date.\n", gn->name);
-
- } else if (gn->unmade != 0) {
- if (cycle) {
- /*
- * If printing cycles and came to one that has unmade
- * children, print out the cycle by recursing on its
- * children. Note a cycle like:
- * a : b
- * b : c
- * c : b
- * will cause this to erroneously complain about a
- * being in the cycle, but this is a good approximation.
- */
- if (gn->made == CYCLE) {
- Error("Graph cycles through `%s'", gn->name);
- gn->made = ENDCYCLE;
- LST_FOREACH(ln, &gn->children)
- MakePrintStatus(Lst_Datum(ln), TRUE);
- gn->made = UNMADE;
- } else if (gn->made != ENDCYCLE) {
- gn->made = CYCLE;
- LST_FOREACH(ln, &gn->children)
- MakePrintStatus(Lst_Datum(ln), TRUE);
- }
- } else {
- printf("`%s' not remade because of errors.\n",
- gn->name);
- }
- }
-}
-
-/**
- * Make_Run
- * Initialize the nodes to remake and the list of nodes which are
- * ready to be made by doing a breadth-first traversal of the graph
- * starting from the nodes in the given list. Once this traversal
- * is finished, all the 'leaves' of the graph are in the toBeMade
- * queue.
- * Using this queue and the Job module, work back up the graph,
- * calling on MakeStartJobs to keep the job table as full as
- * possible.
- *
- * Results:
- * TRUE if work was done. FALSE otherwise.
- *
- * Side Effects:
- * The make field of all nodes involved in the creation of the given
- * targets is set to 1. The toBeMade list is set to contain all the
- * 'leaves' of these subgraphs.
- */
-Boolean
-Make_Run(Lst *targs)
-{
- GNode *gn; /* a temporary pointer */
- GNode *cgn;
- Lst examine; /* List of targets to examine */
- LstNode *ln;
-
- Lst_Init(&examine);
- Lst_Duplicate(&examine, targs, NOCOPY);
- numNodes = 0;
-
- /*
- * Make an initial downward pass over the graph, marking nodes to be
- * made as we go down. We call Suff_FindDeps to find where a node is and
- * to get some children for it if it has none and also has no commands.
- * If the node is a leaf, we stick it on the toBeMade queue to
- * be looked at in a minute, otherwise we add its children to our queue
- * and go on about our business.
- */
- while (!Lst_IsEmpty(&examine)) {
- gn = Lst_DeQueue(&examine);
-
- if (!gn->make) {
- gn->make = TRUE;
- numNodes++;
-
- /*
- * Apply any .USE rules before looking for implicit
- * dependencies to make sure everything has commands
- * that should...
- */
- LST_FOREACH(ln, &gn->children)
- if (Make_HandleUse(Lst_Datum(ln), gn))
- break;
-
- Suff_FindDeps(gn);
-
- if (gn->unmade != 0) {
- LST_FOREACH(ln, &gn->children) {
- cgn = Lst_Datum(ln);
- if (!cgn->make && !(cgn->type & OP_USE))
- Lst_EnQueue(&examine, cgn);
- }
- } else {
- Lst_EnQueue(&toBeMade, gn);
- }
- }
- }
-
- if (queryFlag) {
- /*
- * We wouldn't do any work unless we could start some jobs in
- * the next loop... (we won't actually start any, of course,
- * this is just to see if any of the targets was out of date)
- */
- return (MakeStartJobs());
-
- } else {
- /*
- * Initialization. At the moment, no jobs are running and
- * until some get started, nothing will happen since the
- * remaining upward traversal of the graph is performed by the
- * routines in job.c upon the finishing of a job. So we fill
- * the Job table as much as we can before going into our loop.
- */
- MakeStartJobs();
- }
-
- /*
- * Main Loop: The idea here is that the ending of jobs will take
- * care of the maintenance of data structures and the waiting for output
- * will cause us to be idle most of the time while our children run as
- * much as possible. Because the job table is kept as full as possible,
- * the only time when it will be empty is when all the jobs which need
- * running have been run, so that is the end condition of this loop.
- * Note that the Job module will exit if there were any errors unless
- * the keepgoing flag was given.
- */
- while (!Job_Empty()) {
- Job_CatchOutput(!Lst_IsEmpty(&toBeMade));
- Job_CatchChildren(!usePipes);
- MakeStartJobs();
- }
-
- Job_Finish();
-
- /*
- * Print the final status of each target. E.g. if it wasn't made
- * because some inferior reported an error.
- */
- LST_FOREACH(ln, targs)
- MakePrintStatus(Lst_Datum(ln), (makeErrors == 0) && (numNodes != 0));
-
- return (TRUE);
-}
diff --git a/usr.bin/make/make.h b/usr.bin/make/make.h
deleted file mode 100644
index 6e2813d..0000000
--- a/usr.bin/make/make.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/*-
- * Copyright (c) 1988, 1989, 1990, 1993
- * The Regents of the University of California. All rights reserved.
- * Copyright (c) 1989 by Berkeley Softworks
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Adam de Boor.
- *
- * 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.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
- *
- * @(#)make.h 8.3 (Berkeley) 6/13/95
- * $FreeBSD$
- */
-
-#ifndef make_h_a91074b9
-#define make_h_a91074b9
-
-/**
- * make.h
- * The global definitions for make
- */
-
-#include "util.h"
-
-#define MAKE_JOB_PREFIX ".MAKE.JOB.PREFIX"
-
-struct GNode;
-struct Lst;
-struct Buffer;
-
-/*
- * Warning flags
- */
-enum {
- WARN_DIRSYNTAX = 0x0001, /* syntax errors in directives */
-};
-
-int Make_TimeStamp(struct GNode *, struct GNode *);
-Boolean Make_OODate(struct GNode *);
-int Make_HandleUse(struct GNode *, struct GNode *);
-void Make_Update(struct GNode *);
-void Make_DoAllVar(struct GNode *);
-Boolean Make_Run(struct Lst *);
-void Main_ParseArgLine(char *, int);
-int Main_ParseWarn(const char *, int);
-void Main_AddSourceMakefile(const char *);
-
-#endif /* make_h_a91074b9 */
diff --git a/usr.bin/make/parse.c b/usr.bin/make/parse.c
deleted file mode 100644
index 134d905..0000000
--- a/usr.bin/make/parse.c
+++ /dev/null
@@ -1,2545 +0,0 @@
-/*-
- * Copyright (c) 1988, 1989, 1990, 1993
- * The Regents of the University of California. All rights reserved.
- * Copyright (c) 1989 by Berkeley Softworks
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Adam de Boor.
- *
- * 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.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
- *
- * @(#)parse.c 8.3 (Berkeley) 3/19/94
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-/*-
- * parse.c --
- * Functions to parse a makefile.
- *
- * Most important structures are kept in Lsts. Directories for
- * the #include "..." function are kept in the 'parseIncPath' Lst, while
- * those for the #include <...> are kept in the 'sysIncPath' Lst. The
- * targets currently being defined are kept in the 'targets' Lst.
- *
- * Interface:
- *
- * Parse_File Function used to parse a makefile. It must
- * be given the name of the file, which should
- * already have been opened, and a function
- * to call to read a character from the file.
- *
- * Parse_IsVar Returns TRUE if the given line is a
- * variable assignment. Used by MainParseArgs
- * to determine if an argument is a target
- * or a variable assignment. Used internally
- * for pretty much the same thing...
- *
- * Parse_Error Function called when an error occurs in
- * parsing. Used by the variable and
- * conditional modules.
- *
- * Parse_MainName Returns a Lst of the main target to create.
- */
-
-#include <assert.h>
-#include <ctype.h>
-#include <stdarg.h>
-#include <string.h>
-#include <stdlib.h>
-#include <err.h>
-
-#include "arch.h"
-#include "buf.h"
-#include "cond.h"
-#include "config.h"
-#include "dir.h"
-#include "for.h"
-#include "globals.h"
-#include "GNode.h"
-#include "hash_tables.h"
-#include "job.h"
-#include "make.h"
-#include "parse.h"
-#include "pathnames.h"
-#include "shell.h"
-#include "str.h"
-#include "suff.h"
-#include "targ.h"
-#include "util.h"
-#include "var.h"
-
-/*
- * These values are returned by ParsePopInput to tell Parse_File whether to
- * CONTINUE parsing, i.e. it had only reached the end of an include file,
- * or if it's DONE.
- */
-#define CONTINUE 1
-#define DONE 0
-
-/* targets we're working on */
-static Lst targets = Lst_Initializer(targets);
-
-/* true if currently in a dependency line or its commands */
-static Boolean inLine;
-
-static int fatals = 0;
-
-/*
- * The main target to create. This is the first target on the
- * first dependency line in the first makefile.
- */
-static GNode *mainNode;
-
-/*
- * Definitions for handling #include specifications
- */
-struct IFile {
- char *fname; /* name of previous file */
- int lineno; /* saved line number */
- FILE *F; /* the open stream */
- char *str; /* the string when parsing a string */
- char *ptr; /* the current pointer when parsing a string */
- TAILQ_ENTRY(IFile) link;/* stack the files */
-};
-
-/* stack of IFiles generated by * #includes */
-static TAILQ_HEAD(, IFile) includes = TAILQ_HEAD_INITIALIZER(includes);
-
-/* access current file */
-#define CURFILE (TAILQ_FIRST(&includes))
-
-/* list of directories for "..." includes */
-struct Path parseIncPath = TAILQ_HEAD_INITIALIZER(parseIncPath);
-
-/* list of directories for <...> includes */
-struct Path sysIncPath = TAILQ_HEAD_INITIALIZER(sysIncPath);
-
-/*
- * specType contains the SPECial TYPE of the current target. It is
- * Not if the target is unspecial. If it *is* special, however, the children
- * are linked as children of the parent but not vice versa. This variable is
- * set in ParseDoDependency
- */
-typedef enum {
- Begin, /* .BEGIN */
- Default, /* .DEFAULT */
- End, /* .END */
- ExportVar, /* .EXPORTVAR */
- Ignore, /* .IGNORE */
- Includes, /* .INCLUDES */
- Interrupt, /* .INTERRUPT */
- Libs, /* .LIBS */
- MFlags, /* .MFLAGS or .MAKEFLAGS */
- Main, /* .MAIN and we don't have anyth. user-spec. to make */
- Not, /* Not special */
- NotParallel, /* .NOTPARALELL */
- Null, /* .NULL */
- Order, /* .ORDER */
- Parallel, /* .PARALLEL */
- ExPath, /* .PATH */
- Phony, /* .PHONY */
- Posix, /* .POSIX */
- MakefileDeps, /* .MAKEFILEDEPS */
- Precious, /* .PRECIOUS */
- ExShell, /* .SHELL */
- Silent, /* .SILENT */
- SingleShell, /* .SINGLESHELL */
- Suffixes, /* .SUFFIXES */
- Wait, /* .WAIT */
- Warn, /* .WARN */
- Attribute /* Generic attribute */
-} ParseSpecial;
-
-static ParseSpecial specType;
-static int waiting;
-
-/*
- * Predecessor node for handling .ORDER. Initialized to NULL when .ORDER
- * seen, then set to each successive source on the line.
- */
-static GNode *predecessor;
-
-/*
- * The parseKeywords table is searched using binary search when deciding
- * if a target or source is special. The 'spec' field is the ParseSpecial
- * type of the keyword ("Not" if the keyword isn't special as a target) while
- * the 'op' field is the operator to apply to the list of targets if the
- * keyword is used as a source ("0" if the keyword isn't special as a source)
- */
-static const struct keyword {
- const char *name; /* Name of keyword */
- ParseSpecial spec; /* Type when used as a target */
- int op; /* Operator when used as a source */
-} parseKeywords[] = {
- /* KEYWORD-START-TAG */
- { ".BEGIN", Begin, 0 },
- { ".DEFAULT", Default, 0 },
- { ".END", End, 0 },
- { ".EXEC", Attribute, OP_EXEC },
- { ".EXPORTVAR", ExportVar, 0 },
- { ".IGNORE", Ignore, OP_IGNORE },
- { ".INCLUDES", Includes, 0 },
- { ".INTERRUPT", Interrupt, 0 },
- { ".INVISIBLE", Attribute, OP_INVISIBLE },
- { ".JOIN", Attribute, OP_JOIN },
- { ".LIBS", Libs, 0 },
- { ".MAIN", Main, 0 },
- { ".MAKE", Attribute, OP_MAKE },
- { ".MAKEFILEDEPS", MakefileDeps, 0 },
- { ".MAKEFLAGS", MFlags, 0 },
- { ".MFLAGS", MFlags, 0 },
- { ".NOTMAIN", Attribute, OP_NOTMAIN },
- { ".NOTPARALLEL", NotParallel, 0 },
- { ".NO_PARALLEL", NotParallel, 0 },
- { ".NULL", Null, 0 },
- { ".OPTIONAL", Attribute, OP_OPTIONAL },
- { ".ORDER", Order, 0 },
- { ".PARALLEL", Parallel, 0 },
- { ".PATH", ExPath, 0 },
- { ".PHONY", Phony, OP_PHONY },
- { ".POSIX", Posix, 0 },
- { ".PRECIOUS", Precious, OP_PRECIOUS },
- { ".RECURSIVE", Attribute, OP_MAKE },
- { ".SHELL", ExShell, 0 },
- { ".SILENT", Silent, OP_SILENT },
- { ".SINGLESHELL", SingleShell, 0 },
- { ".SUFFIXES", Suffixes, 0 },
- { ".USE", Attribute, OP_USE },
- { ".WAIT", Wait, 0 },
- { ".WARN", Warn, 0 },
- /* KEYWORD-END-TAG */
-};
-#define NKEYWORDS (sizeof(parseKeywords) / sizeof(parseKeywords[0]))
-
-static void parse_include(char *, int, int);
-static void parse_sinclude(char *, int, int);
-static void parse_message(char *, int, int);
-static void parse_undef(char *, int, int);
-static void parse_for(char *, int, int);
-static void parse_endfor(char *, int, int);
-
-static const struct directive {
- const char *name;
- int code;
- Boolean skip_flag; /* execute even when skipped */
- void (*func)(char *, int, int);
-} directives[] = {
- /* DIRECTIVES-START-TAG */
- { "elif", COND_ELIF, TRUE, Cond_If },
- { "elifdef", COND_ELIFDEF, TRUE, Cond_If },
- { "elifmake", COND_ELIFMAKE, TRUE, Cond_If },
- { "elifndef", COND_ELIFNDEF, TRUE, Cond_If },
- { "elifnmake", COND_ELIFNMAKE, TRUE, Cond_If },
- { "else", COND_ELSE, TRUE, Cond_Else },
- { "endfor", 0, FALSE, parse_endfor },
- { "endif", COND_ENDIF, TRUE, Cond_Endif },
- { "error", 1, FALSE, parse_message },
- { "for", 0, FALSE, parse_for },
- { "if", COND_IF, TRUE, Cond_If },
- { "ifdef", COND_IFDEF, TRUE, Cond_If },
- { "ifmake", COND_IFMAKE, TRUE, Cond_If },
- { "ifndef", COND_IFNDEF, TRUE, Cond_If },
- { "ifnmake", COND_IFNMAKE, TRUE, Cond_If },
- { "include", 0, FALSE, parse_include },
- { "sinclude", 0, FALSE, parse_sinclude },
- { "undef", 0, FALSE, parse_undef },
- { "warning", 0, FALSE, parse_message },
- /* DIRECTIVES-END-TAG */
-};
-#define NDIRECTS (sizeof(directives) / sizeof(directives[0]))
-
-/*-
- * ParseFindKeyword
- * Look in the table of keywords for one matching the given string.
- *
- * Results:
- * The pointer to keyword table entry or NULL.
- */
-static const struct keyword *
-ParseFindKeyword(const char *str)
-{
- int kw;
-
- kw = keyword_hash(str, strlen(str));
- if (kw < 0 || kw >= (int)NKEYWORDS ||
- strcmp(str, parseKeywords[kw].name) != 0)
- return (NULL);
- return (&parseKeywords[kw]);
-}
-
-/*-
- * Parse_Error --
- * Error message abort function for parsing. Prints out the context
- * of the error (line number and file) as well as the message with
- * two optional arguments.
- *
- * Results:
- * None
- *
- * Side Effects:
- * "fatals" is incremented if the level is PARSE_FATAL.
- */
-/* VARARGS */
-void
-Parse_Error(int type, const char *fmt, ...)
-{
- va_list ap;
-
- va_start(ap, fmt);
- if (CURFILE != NULL)
- fprintf(stderr, "\"%s\", line %d: ",
- CURFILE->fname, CURFILE->lineno);
- if (type == PARSE_WARNING)
- fprintf(stderr, "warning: ");
- vfprintf(stderr, fmt, ap);
- va_end(ap);
- fprintf(stderr, "\n");
- fflush(stderr);
- if (type == PARSE_FATAL)
- fatals += 1;
-}
-
-/**
- * ParsePushInput
- *
- * Push a new input source onto the input stack. If ptr is NULL
- * the fullname is used to fopen the file. If it is not NULL,
- * ptr is assumed to point to the string to be parsed. If opening the
- * file fails, the fullname is freed.
- */
-static void
-ParsePushInput(char *fullname, FILE *fp, char *ptr, int lineno)
-{
- struct IFile *nf;
-
- nf = emalloc(sizeof(*nf));
- nf->fname = fullname;
- nf->lineno = lineno;
-
- if (ptr == NULL) {
- /* the input source is a file */
- if ((nf->F = fp) == NULL) {
- nf->F = fopen(fullname, "r");
- if (nf->F == NULL) {
- Parse_Error(PARSE_FATAL, "Cannot open %s",
- fullname);
- free(fullname);
- free(nf);
- return;
- }
- }
- nf->str = nf->ptr = NULL;
- Var_Append(".MAKEFILE_LIST", fullname, VAR_GLOBAL);
- } else {
- nf->str = nf->ptr = ptr;
- nf->F = NULL;
- }
- TAILQ_INSERT_HEAD(&includes, nf, link);
-}
-
-/**
- * ParsePopInput
- * Called when EOF is reached in the current file. If we were reading
- * an include file, the includes stack is popped and things set up
- * to go back to reading the previous file at the previous location.
- *
- * Results:
- * CONTINUE if there's more to do. DONE if not.
- *
- * Side Effects:
- * The old curFile.F is closed. The includes list is shortened.
- * curFile.lineno, curFile.F, and curFile.fname are changed if
- * CONTINUE is returned.
- */
-static int
-ParsePopInput(void)
-{
- struct IFile *ifile; /* the state on the top of the includes stack */
-
- assert(!TAILQ_EMPTY(&includes));
-
- ifile = TAILQ_FIRST(&includes);
- TAILQ_REMOVE(&includes, ifile, link);
-
- free(ifile->fname);
- if (ifile->F != NULL) {
- fclose(ifile->F);
- Var_Append(".MAKEFILE_LIST", "..", VAR_GLOBAL);
- }
- if (ifile->str != NULL) {
- free(ifile->str);
- }
- free(ifile);
-
- return (TAILQ_EMPTY(&includes) ? DONE : CONTINUE);
-}
-
-/**
- * parse_warn
- * Parse the .WARN pseudo-target.
- */
-static void
-parse_warn(char *line)
-{
- ArgArray aa;
- int i;
-
- brk_string(&aa, line, TRUE);
-
- for (i = 1; i < aa.argc; i++)
- Main_ParseWarn(aa.argv[i], 0);
-}
-
-/*-
- *---------------------------------------------------------------------
- * ParseLinkSrc --
- * Link the parent nodes to their new child. Used by
- * ParseDoDependency. If the specType isn't 'Not', the parent
- * isn't linked as a parent of the child.
- *
- * Side Effects:
- * New elements are added to the parents lists of cgn and the
- * children list of cgn. the unmade field of pgn is updated
- * to reflect the additional child.
- *---------------------------------------------------------------------
- */
-static void
-ParseLinkSrc(Lst *parents, GNode *cgn)
-{
- LstNode *ln;
- GNode *pgn;
-
- LST_FOREACH(ln, parents) {
- pgn = Lst_Datum(ln);
- if (Lst_Member(&pgn->children, cgn) == NULL) {
- Lst_AtEnd(&pgn->children, cgn);
- if (specType == Not) {
- Lst_AtEnd(&cgn->parents, pgn);
- }
- pgn->unmade += 1;
- }
- }
-}
-
-/*-
- *---------------------------------------------------------------------
- * ParseDoOp --
- * Apply the parsed operator to all target nodes. Used in
- * ParseDoDependency once all targets have been found and their
- * operator parsed. If the previous and new operators are incompatible,
- * a major error is taken.
- *
- * Side Effects:
- * The type field of the node is altered to reflect any new bits in
- * the op.
- *---------------------------------------------------------------------
- */
-static void
-ParseDoOp(int op)
-{
- GNode *cohort;
- LstNode *ln;
- GNode *gn;
-
- LST_FOREACH(ln, &targets) {
- gn = Lst_Datum(ln);
-
- /*
- * If the dependency mask of the operator and the node don't
- * match and the node has actually had an operator applied to
- * it before, and the operator actually has some dependency
- * information in it, complain.
- */
- if ((op & OP_OPMASK) != (gn->type & OP_OPMASK) &&
- !OP_NOP(gn->type) && !OP_NOP(op)) {
- Parse_Error(PARSE_FATAL, "Inconsistent operator for %s",
- gn->name);
- return;
- }
-
- if (op == OP_DOUBLEDEP &&
- (gn->type & OP_OPMASK) == OP_DOUBLEDEP) {
- /*
- * If the node was the object of a :: operator, we need
- * to create a new instance of it for the children and
- * commands on this dependency line. The new instance
- * is placed on the 'cohorts' list of the initial one
- * (note the initial one is not on its own cohorts list)
- * and the new instance is linked to all parents of the
- * initial instance.
- */
- cohort = Targ_NewGN(gn->name);
-
- /*
- * Duplicate links to parents so graph traversal is
- * simple. Perhaps some type bits should be duplicated?
- *
- * Make the cohort invisible as well to avoid
- * duplicating it into other variables. True, parents
- * of this target won't tend to do anything with their
- * local variables, but better safe than sorry.
- */
- ParseLinkSrc(&gn->parents, cohort);
- cohort->type = OP_DOUBLEDEP|OP_INVISIBLE;
- Lst_AtEnd(&gn->cohorts, cohort);
-
- /*
- * Replace the node in the targets list with the
- * new copy
- */
- Lst_Replace(ln, cohort);
- gn = cohort;
- }
- /*
- * We don't want to nuke any previous flags (whatever they were)
- * so we just OR the new operator into the old
- */
- gn->type |= op;
- }
-}
-
-/*-
- *---------------------------------------------------------------------
- * ParseDoSrc --
- * Given the name of a source, figure out if it is an attribute
- * and apply it to the targets if it is. Else decide if there is
- * some attribute which should be applied *to* the source because
- * of some special target and apply it if so. Otherwise, make the
- * source be a child of the targets in the list 'targets'
- *
- * Results:
- * None
- *
- * Side Effects:
- * Operator bits may be added to the list of targets or to the source.
- * The targets may have a new source added to their lists of children.
- *---------------------------------------------------------------------
- */
-static void
-ParseDoSrc(int tOp, char *src, Lst *allsrc)
-{
- GNode *gn = NULL;
- const struct keyword *kw;
-
- if (src[0] == '.' && isupper ((unsigned char)src[1])) {
- if ((kw = ParseFindKeyword(src)) != NULL) {
- if (kw->op != 0) {
- ParseDoOp(kw->op);
- return;
- }
- if (kw->spec == Wait) {
- waiting++;
- return;
- }
- }
- }
-
- switch (specType) {
- case Main:
- /*
- * If we have noted the existence of a .MAIN, it means we need
- * to add the sources of said target to the list of things
- * to create. The string 'src' is likely to be free, so we
- * must make a new copy of it. Note that this will only be
- * invoked if the user didn't specify a target on the command
- * line. This is to allow #ifmake's to succeed, or something...
- */
- Lst_AtEnd(&create, estrdup(src));
- /*
- * Add the name to the .TARGETS variable as well, so the user
- * can employ that, if desired.
- */
- Var_Append(".TARGETS", src, VAR_GLOBAL);
- return;
-
- case Order:
- /*
- * Create proper predecessor/successor links between the
- * previous source and the current one.
- */
- gn = Targ_FindNode(src, TARG_CREATE);
- if (predecessor != NULL) {
- Lst_AtEnd(&predecessor->successors, gn);
- Lst_AtEnd(&gn->preds, predecessor);
- }
- /*
- * The current source now becomes the predecessor for the next
- * one.
- */
- predecessor = gn;
- break;
-
- default:
- /*
- * If the source is not an attribute, we need to find/create
- * a node for it. After that we can apply any operator to it
- * from a special target or link it to its parents, as
- * appropriate.
- *
- * In the case of a source that was the object of a :: operator,
- * the attribute is applied to all of its instances (as kept in
- * the 'cohorts' list of the node) or all the cohorts are linked
- * to all the targets.
- */
- gn = Targ_FindNode(src, TARG_CREATE);
- if (tOp) {
- gn->type |= tOp;
- } else {
- ParseLinkSrc(&targets, gn);
- }
- if ((gn->type & OP_OPMASK) == OP_DOUBLEDEP) {
- GNode *cohort;
- LstNode *ln;
-
- for (ln = Lst_First(&gn->cohorts); ln != NULL;
- ln = Lst_Succ(ln)) {
- cohort = Lst_Datum(ln);
- if (tOp) {
- cohort->type |= tOp;
- } else {
- ParseLinkSrc(&targets, cohort);
- }
- }
- }
- break;
- }
-
- gn->order = waiting;
- Lst_AtEnd(allsrc, gn);
- if (waiting) {
- LstNode *ln;
- GNode *p;
-
- /*
- * Check if GNodes needs to be synchronized.
- * This has to be when two nodes are on different sides of a
- * .WAIT directive.
- */
- LST_FOREACH(ln, allsrc) {
- p = Lst_Datum(ln);
-
- if (p->order >= gn->order)
- break;
- /*
- * XXX: This can cause loops, and loops can cause
- * unmade targets, but checking is tedious, and the
- * debugging output can show the problem
- */
- Lst_AtEnd(&p->successors, gn);
- Lst_AtEnd(&gn->preds, p);
- }
- }
-}
-
-
-/*-
- *---------------------------------------------------------------------
- * ParseDoDependency --
- * Parse the dependency line in line.
- *
- * Results:
- * None
- *
- * Side Effects:
- * The nodes of the sources are linked as children to the nodes of the
- * targets. Some nodes may be created.
- *
- * We parse a dependency line by first extracting words from the line and
- * finding nodes in the list of all targets with that name. This is done
- * until a character is encountered which is an operator character. Currently
- * these are only ! and :. At this point the operator is parsed and the
- * pointer into the line advanced until the first source is encountered.
- * The parsed operator is applied to each node in the 'targets' list,
- * which is where the nodes found for the targets are kept, by means of
- * the ParseDoOp function.
- * The sources are read in much the same way as the targets were except
- * that now they are expanded using the wildcarding scheme of the C-Shell
- * and all instances of the resulting words in the list of all targets
- * are found. Each of the resulting nodes is then linked to each of the
- * targets as one of its children.
- * Certain targets are handled specially. These are the ones detailed
- * by the specType variable.
- * The storing of transformation rules is also taken care of here.
- * A target is recognized as a transformation rule by calling
- * Suff_IsTransform. If it is a transformation rule, its node is gotten
- * from the suffix module via Suff_AddTransform rather than the standard
- * Targ_FindNode in the target module.
- *---------------------------------------------------------------------
- */
-static void
-ParseDoDependency(char *line)
-{
- char *cp; /* our current position */
- char *lstart = line; /* original input line */
- GNode *gn; /* a general purpose temporary node */
- int op; /* the operator on the line */
- char savec; /* a place to save a character */
- Lst paths; /* Search paths to alter when parsing .PATH targets */
- int tOp; /* operator from special target */
- LstNode *ln;
- const struct keyword *kw;
-
- tOp = 0;
-
- specType = Not;
- waiting = 0;
- Lst_Init(&paths);
-
- do {
- for (cp = line;
- *cp && !isspace((unsigned char)*cp) && *cp != '(';
- cp++) {
- if (*cp == '$') {
- /*
- * Must be a dynamic source (would have been
- * expanded otherwise), so call the Var module
- * to parse the puppy so we can safely advance
- * beyond it...There should be no errors in this
- * as they would have been discovered in the
- * initial Var_Subst and we wouldn't be here.
- */
- size_t length = 0;
- Boolean freeIt;
- char *result;
-
- result = Var_Parse(cp, VAR_CMD, TRUE,
- &length, &freeIt);
-
- if (freeIt) {
- free(result);
- }
- cp += length - 1;
-
- } else if (*cp == '!' || *cp == ':') {
- /*
- * We don't want to end a word on ':' or '!' if
- * there is a better match later on in the
- * string (greedy matching).
- * This allows the user to have targets like:
- * fie::fi:fo: fum
- * foo::bar:
- * where "fie::fi:fo" and "foo::bar" are the
- * targets. In real life this is used for perl5
- * library man pages where "::" separates an
- * object from its class. Ie:
- * "File::Spec::Unix". This behaviour is also
- * consistent with other versions of make.
- */
- char *p = cp + 1;
-
- if (*cp == ':' && *p == ':')
- p++;
-
- /* Found the best match already. */
- if (*p == '\0' || isspace(*p))
- break;
-
- p += strcspn(p, "!:");
-
- /* No better match later on... */
- if (*p == '\0')
- break;
- }
- continue;
- }
- if (*cp == '(') {
- /*
- * Archives must be handled specially to make sure the
- * OP_ARCHV flag is set in their 'type' field, for one
- * thing, and because things like "archive(file1.o
- * file2.o file3.o)" are permissible. Arch_ParseArchive
- * will set 'line' to be the first non-blank after the
- * archive-spec. It creates/finds nodes for the members
- * and places them on the given list, returning TRUE
- * if all went well and FALSE if there was an error in
- * the specification. On error, line should remain
- * untouched.
- */
- if (!Arch_ParseArchive(&line, &targets, VAR_CMD)) {
- Parse_Error(PARSE_FATAL,
- "Error in archive specification: \"%s\"",
- line);
- return;
- } else {
- cp = line;
- continue;
- }
- }
- savec = *cp;
-
- if (!*cp) {
- /*
- * Ending a dependency line without an operator is a * Bozo no-no. As a heuristic, this is also often
- * triggered by undetected conflicts from cvs/rcs
- * merges.
- */
- if (strncmp(line, "<<<<<<", 6) == 0 ||
- strncmp(line, "||||||", 6) == 0 ||
- strncmp(line, "======", 6) == 0 ||
- strncmp(line, ">>>>>>", 6) == 0) {
- Parse_Error(PARSE_FATAL, "Makefile appears to "
- "contain unresolved cvs/rcs/??? merge "
- "conflicts");
- } else
- Parse_Error(PARSE_FATAL, lstart[0] == '.' ?
- "Unknown directive" : "Need an operator");
- return;
- }
- *cp = '\0';
- /*
- * Have a word in line. See if it's a special target and set
- * specType to match it.
- */
- if (*line == '.' && isupper((unsigned char)line[1])) {
- /*
- * See if the target is a special target that must have
- * it or its sources handled specially.
- */
- if ((kw = ParseFindKeyword(line)) != NULL) {
- if (specType == ExPath && kw->spec != ExPath) {
- Parse_Error(PARSE_FATAL,
- "Mismatched special targets");
- return;
- }
-
- specType = kw->spec;
- tOp = kw->op;
-
- /*
- * Certain special targets have special
- * semantics:
- * .PATH Have to set the dirSearchPath
- * variable too
- * .MAIN Its sources are only used if
- * nothing has been specified to
- * create.
- * .DEFAULT Need to create a node to hang
- * commands on, but we don't want
- * it in the graph, nor do we want
- * it to be the Main Target, so we
- * create it, set OP_NOTMAIN and
- * add it to the list, setting
- * DEFAULT to the new node for
- * later use. We claim the node is
- * A transformation rule to make
- * life easier later, when we'll
- * use Make_HandleUse to actually
- * apply the .DEFAULT commands.
- * .PHONY The list of targets
- * .BEGIN
- * .END
- * .INTERRUPT Are not to be considered the
- * main target.
- * .NOTPARALLEL Make only one target at a time.
- * .SINGLESHELL Create a shell for each
- * command.
- * .ORDER Must set initial predecessor
- * to NULL
- */
- switch (specType) {
- case ExPath:
- Lst_AtEnd(&paths, &dirSearchPath);
- break;
- case Main:
- if (!Lst_IsEmpty(&create)) {
- specType = Not;
- }
- break;
- case Begin:
- case End:
- case Interrupt:
- gn = Targ_FindNode(line, TARG_CREATE);
- gn->type |= OP_NOTMAIN;
- Lst_AtEnd(&targets, gn);
- break;
- case Default:
- gn = Targ_NewGN(".DEFAULT");
- gn->type |= (OP_NOTMAIN|OP_TRANSFORM);
- Lst_AtEnd(&targets, gn);
- DEFAULT = gn;
- break;
- case NotParallel:
- jobLimit = 1;
- break;
- case SingleShell:
- compatMake = 1;
- break;
- case Order:
- predecessor = NULL;
- break;
- default:
- break;
- }
-
- } else if (strncmp(line, ".PATH", 5) == 0) {
- /*
- * .PATH<suffix> has to be handled specially.
- * Call on the suffix module to give us a path
- * to modify.
- */
- struct Path *path;
-
- specType = ExPath;
- path = Suff_GetPath(&line[5]);
- if (path == NULL) {
- Parse_Error(PARSE_FATAL, "Suffix '%s' "
- "not defined (yet)", &line[5]);
- return;
- } else
- Lst_AtEnd(&paths, path);
- }
- }
-
- /*
- * Have word in line. Get or create its node and stick it at
- * the end of the targets list
- */
- if (specType == Not && *line != '\0') {
-
- /* target names to be found and added to targets list */
- Lst curTargs = Lst_Initializer(curTargs);
-
- if (Dir_HasWildcards(line)) {
- /*
- * Targets are to be sought only in the current
- * directory, so create an empty path for the
- * thing. Note we need to use Path_Clear in the
- * destruction of the path as the Dir module
- * could have added a directory to the path...
- */
- struct Path emptyPath =
- TAILQ_HEAD_INITIALIZER(emptyPath);
-
- Path_Expand(line, &emptyPath, &curTargs);
- Path_Clear(&emptyPath);
-
- } else {
- /*
- * No wildcards, but we want to avoid code
- * duplication, so create a list with the word
- * on it.
- */
- Lst_AtEnd(&curTargs, line);
- }
-
- while (!Lst_IsEmpty(&curTargs)) {
- char *targName = Lst_DeQueue(&curTargs);
-
- if (!Suff_IsTransform (targName)) {
- gn = Targ_FindNode(targName,
- TARG_CREATE);
- } else {
- gn = Suff_AddTransform(targName);
- }
-
- Lst_AtEnd(&targets, gn);
- }
- } else if (specType == ExPath && *line != '.' && *line != '\0'){
- Parse_Error(PARSE_WARNING, "Extra target (%s) ignored",
- line);
- }
-
- *cp = savec;
- /*
- * If it is a special type and not .PATH, it's the only
- * target we allow on this line...
- */
- if (specType != Not && specType != ExPath) {
- Boolean warnFlag = FALSE;
-
- while (*cp != '!' && *cp != ':' && *cp) {
- if (*cp != ' ' && *cp != '\t') {
- warnFlag = TRUE;
- }
- cp++;
- }
- if (warnFlag) {
- Parse_Error(PARSE_WARNING,
- "Extra target ignored");
- }
- } else {
- while (*cp && isspace((unsigned char)*cp)) {
- cp++;
- }
- }
- line = cp;
- } while (*line != '!' && *line != ':' && *line);
-
- if (!Lst_IsEmpty(&targets)) {
- switch (specType) {
- default:
- Parse_Error(PARSE_WARNING, "Special and mundane "
- "targets don't mix. Mundane ones ignored");
- break;
- case Default:
- case Begin:
- case End:
- case Interrupt:
- /*
- * These four create nodes on which to hang commands, so
- * targets shouldn't be empty...
- */
- case Not:
- /*
- * Nothing special here -- targets can be empty if it
- * wants.
- */
- break;
- }
- }
-
- /*
- * Have now parsed all the target names. Must parse the operator next.
- * The result is left in op.
- */
- if (*cp == '!') {
- op = OP_FORCE;
- } else if (*cp == ':') {
- if (cp[1] == ':') {
- op = OP_DOUBLEDEP;
- cp++;
- } else {
- op = OP_DEPENDS;
- }
- } else {
- Parse_Error(PARSE_FATAL, lstart[0] == '.' ?
- "Unknown directive" : "Missing dependency operator");
- return;
- }
-
- cp++; /* Advance beyond operator */
-
- ParseDoOp(op);
-
- /*
- * Get to the first source
- */
- while (*cp && isspace((unsigned char)*cp)) {
- cp++;
- }
- line = cp;
-
- /*
- * Several special targets take different actions if present with no
- * sources:
- * a .SUFFIXES line with no sources clears out all old suffixes
- * a .PRECIOUS line makes all targets precious
- * a .IGNORE line ignores errors for all targets
- * a .SILENT line creates silence when making all targets
- * a .PATH removes all directories from the search path(s).
- */
- if (!*line) {
- switch (specType) {
- case Suffixes:
- Suff_ClearSuffixes();
- break;
- case Precious:
- allPrecious = TRUE;
- break;
- case Ignore:
- ignoreErrors = TRUE;
- break;
- case Silent:
- beSilent = TRUE;
- break;
- case ExPath:
- LST_FOREACH(ln, &paths)
- Path_Clear(Lst_Datum(ln));
- break;
- case MakefileDeps:
- mfAutoDeps = TRUE;
- break;
- case Posix:
- is_posix = TRUE;
- Var_SetGlobal("%POSIX", "1003.2");
- break;
- default:
- break;
- }
-
- } else if (specType == MFlags) {
- /*
- * Call on functions in main.c to deal with these arguments and
- * set the initial character to a null-character so the loop to
- * get sources won't get anything
- */
- Main_ParseArgLine(line, 0);
- *line = '\0';
-
- } else if (specType == Warn) {
- parse_warn(line);
- *line = '\0';
-
- } else if (specType == ExShell) {
- if (!Shell_Parse(line)) {
- Parse_Error(PARSE_FATAL,
- "improper shell specification");
- return;
- }
- *line = '\0';
-
- } else if (specType == NotParallel || specType == SingleShell) {
- *line = '\0';
- }
-
- /*
- * NOW GO FOR THE SOURCES
- */
- if (specType == Suffixes || specType == ExPath ||
- specType == Includes || specType == Libs ||
- specType == Null) {
- while (*line) {
- /*
- * If the target was one that doesn't take files as its
- * sources but takes something like suffixes, we take
- * each space-separated word on the line as a something
- * and deal with it accordingly.
- *
- * If the target was .SUFFIXES, we take each source as
- * a suffix and add it to the list of suffixes
- * maintained by the Suff module.
- *
- * If the target was a .PATH, we add the source as a
- * directory to search on the search path.
- *
- * If it was .INCLUDES, the source is taken to be the
- * suffix of files which will be #included and whose
- * search path should be present in the .INCLUDES
- * variable.
- *
- * If it was .LIBS, the source is taken to be the
- * suffix of files which are considered libraries and
- * whose search path should be present in the .LIBS
- * variable.
- *
- * If it was .NULL, the source is the suffix to use
- * when a file has no valid suffix.
- */
- char savech;
- while (*cp && !isspace((unsigned char)*cp)) {
- cp++;
- }
- savech = *cp;
- *cp = '\0';
- switch (specType) {
- case Suffixes:
- Suff_AddSuffix(line);
- break;
- case ExPath:
- LST_FOREACH(ln, &paths)
- Path_AddDir(Lst_Datum(ln), line);
- break;
- case Includes:
- Suff_AddInclude(line);
- break;
- case Libs:
- Suff_AddLib(line);
- break;
- case Null:
- Suff_SetNull(line);
- break;
- default:
- break;
- }
- *cp = savech;
- if (savech != '\0') {
- cp++;
- }
- while (*cp && isspace((unsigned char)*cp)) {
- cp++;
- }
- line = cp;
- }
- Lst_Destroy(&paths, NOFREE);
-
- } else if (specType == ExportVar) {
- Var_SetEnv(line, VAR_GLOBAL);
-
- } else {
- /* list of sources in order */
- Lst curSrcs = Lst_Initializer(curSrc);
-
- while (*line) {
- /*
- * The targets take real sources, so we must beware of
- * archive specifications (i.e. things with left
- * parentheses in them) and handle them accordingly.
- */
- while (*cp && !isspace((unsigned char)*cp)) {
- if (*cp == '(' && cp > line && cp[-1] != '$') {
- /*
- * Only stop for a left parenthesis if
- * it isn't at the start of a word
- * (that'll be for variable changes
- * later) and isn't preceded by a dollar
- * sign (a dynamic source).
- */
- break;
- } else {
- cp++;
- }
- }
-
- if (*cp == '(') {
- GNode *gnp;
-
- /* list of archive source names after exp. */
- Lst sources = Lst_Initializer(sources);
-
- if (!Arch_ParseArchive(&line, &sources,
- VAR_CMD)) {
- Parse_Error(PARSE_FATAL, "Error in "
- "source archive spec \"%s\"", line);
- return;
- }
-
- while (!Lst_IsEmpty(&sources)) {
- gnp = Lst_DeQueue(&sources);
- ParseDoSrc(tOp, gnp->name, &curSrcs);
- }
- cp = line;
- } else {
- if (*cp) {
- *cp = '\0';
- cp += 1;
- }
-
- ParseDoSrc(tOp, line, &curSrcs);
- }
- while (*cp && isspace((unsigned char)*cp)) {
- cp++;
- }
- line = cp;
- }
- Lst_Destroy(&curSrcs, NOFREE);
- }
-
- if (mainNode == NULL) {
- /*
- * If we have yet to decide on a main target to make, in the
- * absence of any user input, we want the first target on
- * the first dependency line that is actually a real target
- * (i.e. isn't a .USE or .EXEC rule) to be made.
- */
- LST_FOREACH(ln, &targets) {
- gn = Lst_Datum(ln);
- if ((gn->type & (OP_NOTMAIN | OP_USE |
- OP_EXEC | OP_TRANSFORM)) == 0) {
- mainNode = gn;
- Targ_SetMain(gn);
- break;
- }
- }
- }
-}
-
-/*-
- *---------------------------------------------------------------------
- * Parse_IsVar --
- * Return TRUE if the passed line is a variable assignment. A variable
- * assignment consists of a single word followed by optional whitespace
- * followed by either a += or an = operator.
- * This function is used both by the Parse_File function and main when
- * parsing the command-line arguments.
- *
- * Results:
- * TRUE if it is. FALSE if it ain't
- *
- * Side Effects:
- * none
- *---------------------------------------------------------------------
- */
-Boolean
-Parse_IsVar(char *line)
-{
- Boolean wasSpace = FALSE; /* set TRUE if found a space */
- Boolean haveName = FALSE; /* Set TRUE if have a variable name */
-
- int level = 0;
-#define ISEQOPERATOR(c) \
- ((c) == '+' || (c) == ':' || (c) == '?' || (c) == '!')
-
- /*
- * Skip to variable name
- */
- for (; *line == ' ' || *line == '\t'; line++)
- continue;
-
- for (; *line != '=' || level != 0; line++) {
- switch (*line) {
- case '\0':
- /*
- * end-of-line -- can't be a variable assignment.
- */
- return (FALSE);
-
- case ' ':
- case '\t':
- /*
- * there can be as much white space as desired so long
- * as there is only one word before the operator
- */
- wasSpace = TRUE;
- break;
-
- case '(':
- case '{':
- level++;
- break;
-
- case '}':
- case ')':
- level--;
- break;
-
- default:
- if (wasSpace && haveName) {
- if (ISEQOPERATOR(*line)) {
- /*
- * We must have a finished word
- */
- if (level != 0)
- return (FALSE);
-
- /*
- * When an = operator [+?!:] is found,
- * the next character must be an = or
- * it ain't a valid assignment.
- */
- if (line[1] == '=')
- return (haveName);
-#ifdef SUNSHCMD
- /*
- * This is a shell command
- */
- if (strncmp(line, ":sh", 3) == 0)
- return (haveName);
-#endif
- }
- /*
- * This is the start of another word, so not
- * assignment.
- */
- return (FALSE);
-
- } else {
- haveName = TRUE;
- wasSpace = FALSE;
- }
- break;
- }
- }
-
- return (haveName);
-}
-
-/*-
- *---------------------------------------------------------------------
- * Parse_DoVar --
- * Take the variable assignment in the passed line and do it in the
- * global context.
- *
- * Note: There is a lexical ambiguity with assignment modifier characters
- * in variable names. This routine interprets the character before the =
- * as a modifier. Therefore, an assignment like
- * C++=/usr/bin/CC
- * is interpreted as "C+ +=" instead of "C++ =".
- *
- * Results:
- * none
- *
- * Side Effects:
- * the variable structure of the given variable name is altered in the
- * global context.
- *---------------------------------------------------------------------
- */
-void
-Parse_DoVar(char *line, GNode *ctxt)
-{
- char *cp; /* pointer into line */
- enum {
- VAR_SUBST,
- VAR_APPEND,
- VAR_SHELL,
- VAR_NORMAL
- } type; /* Type of assignment */
- char *opc; /* ptr to operator character to
- * null-terminate the variable name */
-
- /*
- * Skip to variable name
- */
- while (*line == ' ' || *line == '\t') {
- line++;
- }
-
- /*
- * Skip to operator character, nulling out whitespace as we go
- */
- for (cp = line + 1; *cp != '='; cp++) {
- if (isspace((unsigned char)*cp)) {
- *cp = '\0';
- }
- }
- opc = cp - 1; /* operator is the previous character */
- *cp++ = '\0'; /* nuke the = */
-
- /*
- * Check operator type
- */
- switch (*opc) {
- case '+':
- type = VAR_APPEND;
- *opc = '\0';
- break;
-
- case '?':
- /*
- * If the variable already has a value, we don't do anything.
- */
- *opc = '\0';
- if (Var_Exists(line, ctxt)) {
- return;
- } else {
- type = VAR_NORMAL;
- }
- break;
-
- case ':':
- type = VAR_SUBST;
- *opc = '\0';
- break;
-
- case '!':
- type = VAR_SHELL;
- *opc = '\0';
- break;
-
- default:
-#ifdef SUNSHCMD
- while (*opc != ':') {
- if (opc == line)
- break;
- else
- --opc;
- }
-
- if (strncmp(opc, ":sh", 3) == 0) {
- type = VAR_SHELL;
- *opc = '\0';
- break;
- }
-#endif
- type = VAR_NORMAL;
- break;
- }
-
- while (isspace((unsigned char)*cp)) {
- cp++;
- }
-
- if (type == VAR_APPEND) {
- Var_Append(line, cp, ctxt);
-
- } else if (type == VAR_SUBST) {
- /*
- * Allow variables in the old value to be undefined, but leave
- * their invocation alone -- this is done by forcing oldVars
- * to be false.
- * XXX: This can cause recursive variables, but that's not
- * hard to do, and this allows someone to do something like
- *
- * CFLAGS = $(.INCLUDES)
- * CFLAGS := -I.. $(CFLAGS)
- *
- * And not get an error.
- */
- Boolean oldOldVars = oldVars;
-
- oldVars = FALSE;
-
- /*
- * make sure that we set the variable the first time to nothing
- * so that it gets substituted!
- */
- if (!Var_Exists(line, ctxt))
- Var_Set(line, "", ctxt);
-
- cp = Buf_Peel(Var_Subst(cp, ctxt, FALSE));
-
- oldVars = oldOldVars;
-
- Var_Set(line, cp, ctxt);
- free(cp);
-
- } else if (type == VAR_SHELL) {
- /*
- * TRUE if the command needs to be freed, i.e.
- * if any variable expansion was performed
- */
- Boolean freeCmd = FALSE;
- Buffer *buf;
- const char *error;
-
- if (strchr(cp, '$') != NULL) {
- /*
- * There's a dollar sign in the command, so perform
- * variable expansion on the whole thing. The
- * resulting string will need freeing when we're done,
- * so set freeCmd to TRUE.
- */
- cp = Buf_Peel(Var_Subst(cp, VAR_CMD, TRUE));
- freeCmd = TRUE;
- }
-
- buf = Cmd_Exec(cp, &error);
- Var_Set(line, Buf_Data(buf), ctxt);
- Buf_Destroy(buf, TRUE);
-
- if (error)
- Parse_Error(PARSE_WARNING, error, cp);
-
- if (freeCmd)
- free(cp);
-
- } else {
- /*
- * Normal assignment -- just do it.
- */
- Var_Set(line, cp, ctxt);
- }
- if (strcmp(line, MAKE_JOB_PREFIX) == 0)
- Job_SetPrefix();
-}
-
-/*-
- *-----------------------------------------------------------------------
- * ParseHasCommands --
- * Callback procedure for Parse_File when destroying the list of
- * targets on the last dependency line. Marks a target as already
- * having commands if it does, to keep from having shell commands
- * on multiple dependency lines.
- *
- * Results:
- * None
- *
- * Side Effects:
- * OP_HAS_COMMANDS may be set for the target.
- *
- *-----------------------------------------------------------------------
- */
-static void
-ParseHasCommands(void *gnp)
-{
- GNode *gn = gnp;
-
- if (!Lst_IsEmpty(&gn->commands)) {
- gn->type |= OP_HAS_COMMANDS;
- }
-}
-
-/*-
- *-----------------------------------------------------------------------
- * Parse_AddIncludeDir --
- * Add a directory to the path searched for included makefiles
- * bracketed by double-quotes. Used by functions in main.c
- *
- * Results:
- * None.
- *
- * Side Effects:
- * The directory is appended to the list.
- *
- *-----------------------------------------------------------------------
- */
-void
-Parse_AddIncludeDir(char *dir)
-{
-
- Path_AddDir(&parseIncPath, dir);
-}
-
-/*-
- *---------------------------------------------------------------------
- * Parse_FromString --
- * Start Parsing from the given string
- *
- * Results:
- * None
- *
- * Side Effects:
- * A structure is added to the includes Lst and readProc, curFile.lineno,
- * curFile.fname and curFile.F are altered for the new file
- *---------------------------------------------------------------------
- */
-void
-Parse_FromString(char *str, int lineno)
-{
-
- DEBUGF(FOR, ("%s\n---- at line %d\n", str, lineno));
-
- ParsePushInput(estrdup(CURFILE->fname), NULL, str, lineno);
-}
-
-#ifdef SYSVINCLUDE
-/*-
- *---------------------------------------------------------------------
- * ParseTraditionalInclude --
- * Push to another file.
- *
- * The input is the line minus the "include". The file name is
- * the string following the "include".
- *
- * Results:
- * None
- *
- * Side Effects:
- * A structure is added to the includes Lst and readProc, curFile.lineno,
- * curFile.fname and curFile.F are altered for the new file
- *---------------------------------------------------------------------
- */
-static void
-ParseTraditionalInclude(char *file)
-{
- char *fullname; /* full pathname of file */
- char *cp; /* current position in file spec */
-
- /*
- * Skip over whitespace
- */
- while (*file == ' ' || *file == '\t') {
- file++;
- }
-
- if (*file == '\0') {
- Parse_Error(PARSE_FATAL, "Filename missing from \"include\"");
- return;
- }
-
- /*
- * Skip to end of line or next whitespace
- */
- for (cp = file; *cp && *cp != '\n' && *cp != '\t' && *cp != ' '; cp++) {
- continue;
- }
-
- *cp = '\0';
-
- /*
- * Substitute for any variables in the file name before trying to
- * find the thing.
- */
- file = Buf_Peel(Var_Subst(file, VAR_CMD, FALSE));
-
- /*
- * Now we know the file's name, we attempt to find the durn thing.
- * Search for it first on the -I search path, then on the .PATH
- * search path, if not found in a -I directory.
- */
- fullname = Path_FindFile(file, &parseIncPath);
- if (fullname == NULL) {
- fullname = Path_FindFile(file, &dirSearchPath);
- }
-
- if (fullname == NULL) {
- /*
- * Still haven't found the makefile. Look for it on the system
- * path as a last resort.
- */
- fullname = Path_FindFile(file, &sysIncPath);
- }
-
- if (fullname == NULL) {
- Parse_Error(PARSE_FATAL, "Could not find %s", file);
- /* XXXHB free(file) */
- return;
- }
-
- /* XXXHB free(file) */
-
- /*
- * We set up the name of the file to be the absolute
- * name of the include file so error messages refer to the right
- * place.
- */
- ParsePushInput(fullname, NULL, NULL, 0);
-}
-#endif
-
-/*-
- *---------------------------------------------------------------------
- * ParseReadc --
- * Read a character from the current file
- *
- * Results:
- * The character that was read
- *
- * Side Effects:
- *---------------------------------------------------------------------
- */
-static int
-ParseReadc(void)
-{
-
- if (CURFILE->F != NULL)
- return (fgetc(CURFILE->F));
-
- if (CURFILE->str != NULL && *CURFILE->ptr != '\0')
- return (*CURFILE->ptr++);
-
- return (EOF);
-}
-
-
-/*-
- *---------------------------------------------------------------------
- * ParseUnreadc --
- * Put back a character to the current file
- *
- * Results:
- * None.
- *
- * Side Effects:
- *---------------------------------------------------------------------
- */
-static void
-ParseUnreadc(int c)
-{
-
- if (CURFILE->F != NULL) {
- ungetc(c, CURFILE->F);
- return;
- }
- if (CURFILE->str != NULL) {
- *--(CURFILE->ptr) = c;
- return;
- }
-}
-
-/* ParseSkipLine():
- * Grab the next line unless it begins with a dot (`.') and we're told to
- * ignore such lines.
- */
-static char *
-ParseSkipLine(int skip, int keep_newline)
-{
- char *line;
- int c, lastc;
- Buffer *buf;
-
- buf = Buf_Init(MAKE_BSIZE);
-
- do {
- Buf_Clear(buf);
- lastc = '\0';
-
- while (((c = ParseReadc()) != '\n' || lastc == '\\')
- && c != EOF) {
- if (skip && c == '#' && lastc != '\\') {
- /*
- * let a comment be terminated even by an
- * escaped \n. This is consistent to comment
- * handling in ParseReadLine
- */
- while ((c = ParseReadc()) != '\n' && c != EOF)
- ;
- break;
- }
- if (c == '\n') {
- if (keep_newline)
- Buf_AddByte(buf, (Byte)c);
- else
- Buf_ReplaceLastByte(buf, (Byte)' ');
- CURFILE->lineno++;
-
- while ((c = ParseReadc()) == ' ' || c == '\t')
- continue;
-
- if (c == EOF)
- break;
- }
-
- Buf_AddByte(buf, (Byte)c);
- lastc = c;
- }
-
- if (c == EOF) {
- Parse_Error(PARSE_FATAL,
- "Unclosed conditional/for loop");
- Buf_Destroy(buf, TRUE);
- return (NULL);
- }
-
- CURFILE->lineno++;
- Buf_AddByte(buf, (Byte)'\0');
- line = Buf_Data(buf);
- } while (skip == 1 && line[0] != '.');
-
- Buf_Destroy(buf, FALSE);
- return (line);
-}
-
-/*-
- *---------------------------------------------------------------------
- * ParseReadLine --
- * Read an entire line from the input file. Called only by Parse_File.
- * To facilitate escaped newlines and what have you, a character is
- * buffered in 'lastc', which is '\0' when no characters have been
- * read. When we break out of the loop, c holds the terminating
- * character and lastc holds a character that should be added to
- * the line (unless we don't read anything but a terminator).
- *
- * Results:
- * A line w/o its newline
- *
- * Side Effects:
- * Only those associated with reading a character
- *---------------------------------------------------------------------
- */
-static char *
-ParseReadLine(void)
-{
- Buffer *buf; /* Buffer for current line */
- int c; /* the current character */
- int lastc; /* The most-recent character */
- Boolean semiNL; /* treat semi-colons as newlines */
- Boolean ignDepOp; /* TRUE if should ignore dependency operators
- * for the purposes of setting semiNL */
- Boolean ignComment; /* TRUE if should ignore comments (in a
- * shell command */
- char *line; /* Result */
- char *ep; /* to strip trailing blanks */
-
- again:
- semiNL = FALSE;
- ignDepOp = FALSE;
- ignComment = FALSE;
-
- lastc = '\0';
-
- /*
- * Handle tab at the beginning of the line. A leading tab (shell
- * command) forces us to ignore comments and dependency operators and
- * treat semi-colons as semi-colons (by leaving semiNL FALSE).
- * This also discards completely blank lines.
- */
- for (;;) {
- c = ParseReadc();
- if (c == EOF) {
- if (ParsePopInput() == DONE) {
- /* End of all inputs - return NULL */
- return (NULL);
- }
- continue;
- }
-
- if (c == '\t') {
- ignComment = ignDepOp = TRUE;
- lastc = c;
- break;
- }
- if (c != '\n') {
- ParseUnreadc(c);
- break;
- }
- CURFILE->lineno++;
- }
-
- buf = Buf_Init(MAKE_BSIZE);
-
- while (((c = ParseReadc()) != '\n' || lastc == '\\') && c != EOF) {
- test_char:
- switch (c) {
- case '\n':
- /*
- * Escaped newline: read characters until a
- * non-space or an unescaped newline and
- * replace them all by a single space. This is
- * done by storing the space over the backslash
- * and dropping through with the next nonspace.
- * If it is a semi-colon and semiNL is TRUE,
- * it will be recognized as a newline in the
- * code below this...
- */
- CURFILE->lineno++;
- lastc = ' ';
- while ((c = ParseReadc()) == ' ' || c == '\t') {
- continue;
- }
- if (c == EOF || c == '\n') {
- goto line_read;
- } else {
- /*
- * Check for comments, semiNL's, etc. --
- * easier than ParseUnreadc(c);
- * continue;
- */
- goto test_char;
- }
- /*NOTREACHED*/
- break;
-
- case ';':
- /*
- * Semi-colon: Need to see if it should be
- * interpreted as a newline
- */
- if (semiNL) {
- /*
- * To make sure the command that may
- * be following this semi-colon begins
- * with a tab, we push one back into the
- * input stream. This will overwrite the
- * semi-colon in the buffer. If there is
- * no command following, this does no
- * harm, since the newline remains in
- * the buffer and the
- * whole line is ignored.
- */
- ParseUnreadc('\t');
- goto line_read;
- }
- break;
- case '=':
- if (!semiNL) {
- /*
- * Haven't seen a dependency operator
- * before this, so this must be a
- * variable assignment -- don't pay
- * attention to dependency operators
- * after this.
- */
- ignDepOp = TRUE;
- } else if (lastc == ':' || lastc == '!') {
- /*
- * Well, we've seen a dependency
- * operator already, but it was the
- * previous character, so this is really
- * just an expanded variable assignment.
- * Revert semi-colons to being just
- * semi-colons again and ignore any more
- * dependency operators.
- *
- * XXX: Note that a line like
- * "foo : a:=b" will blow up, but who'd
- * write a line like that anyway?
- */
- ignDepOp = TRUE;
- semiNL = FALSE;
- }
- break;
- case '#':
- if (!ignComment) {
- if (lastc != '\\') {
- /*
- * If the character is a hash
- * mark and it isn't escaped
- * (or we're being compatible),
- * the thing is a comment.
- * Skip to the end of the line.
- */
- do {
- c = ParseReadc();
- } while (c != '\n' && c != EOF);
- goto line_read;
- } else {
- /*
- * Don't add the backslash.
- * Just let the # get copied
- * over.
- */
- lastc = c;
- continue;
- }
- }
- break;
-
- case ':':
- case '!':
- if (!ignDepOp) {
- /*
- * A semi-colon is recognized as a
- * newline only on dependency lines.
- * Dependency lines are lines with a
- * colon or an exclamation point.
- * Ergo...
- */
- semiNL = TRUE;
- }
- break;
-
- default:
- break;
- }
- /*
- * Copy in the previous character (there may be none if this
- * was the first character) and save this one in
- * lastc.
- */
- if (lastc != '\0')
- Buf_AddByte(buf, (Byte)lastc);
- lastc = c;
- }
- line_read:
- CURFILE->lineno++;
-
- if (lastc != '\0') {
- Buf_AddByte(buf, (Byte)lastc);
- }
- Buf_AddByte(buf, (Byte)'\0');
- line = Buf_Peel(buf);
-
- /*
- * Strip trailing blanks and tabs from the line.
- * Do not strip a blank or tab that is preceded by
- * a '\'
- */
- ep = line;
- while (*ep)
- ++ep;
- while (ep > line + 1 && (ep[-1] == ' ' || ep[-1] == '\t')) {
- if (ep > line + 1 && ep[-2] == '\\')
- break;
- --ep;
- }
- *ep = 0;
-
- if (line[0] == '\0') {
- /* empty line - just ignore */
- free(line);
- goto again;
- }
-
- return (line);
-}
-
-/*-
- *-----------------------------------------------------------------------
- * ParseFinishLine --
- * Handle the end of a dependency group.
- *
- * Results:
- * Nothing.
- *
- * Side Effects:
- * inLine set FALSE. 'targets' list destroyed.
- *
- *-----------------------------------------------------------------------
- */
-static void
-ParseFinishLine(void)
-{
- const LstNode *ln;
-
- if (inLine) {
- LST_FOREACH(ln, &targets) {
- if (((const GNode *)Lst_Datum(ln))->type & OP_TRANSFORM)
- Suff_EndTransform(Lst_Datum(ln));
- }
- Lst_Destroy(&targets, ParseHasCommands);
- inLine = FALSE;
- }
-}
-
-/**
- * xparse_include
- * Parse an .include directive and push the file onto the input stack.
- * The input is the line minus the .include. A file spec is a string
- * enclosed in <> or "". The former is looked for only in sysIncPath.
- * The latter in . and the directories specified by -I command line
- * options
- */
-static void
-xparse_include(char *file, int sinclude)
-{
- char *fullname; /* full pathname of file */
- char endc; /* the character which ends the file spec */
- char *cp; /* current position in file spec */
- Boolean isSystem; /* TRUE if makefile is a system makefile */
- char *prefEnd, *Fname;
- char *newName;
-
- /*
- * Skip to delimiter character so we know where to look
- */
- while (*file == ' ' || *file == '\t') {
- file++;
- }
-
- if (*file != '"' && *file != '<') {
- Parse_Error(PARSE_FATAL,
- ".include filename must be delimited by '\"' or '<'");
- return;
- }
-
- /*
- * Set the search path on which to find the include file based on the
- * characters which bracket its name. Angle-brackets imply it's
- * a system Makefile while double-quotes imply it's a user makefile
- */
- if (*file == '<') {
- isSystem = TRUE;
- endc = '>';
- } else {
- isSystem = FALSE;
- endc = '"';
- }
-
- /*
- * Skip to matching delimiter
- */
- for (cp = ++file; *cp != endc; cp++) {
- if (*cp == '\0') {
- Parse_Error(PARSE_FATAL,
- "Unclosed .include filename. '%c' expected", endc);
- return;
- }
- }
- *cp = '\0';
-
- /*
- * Substitute for any variables in the file name before trying to
- * find the thing.
- */
- file = Buf_Peel(Var_Subst(file, VAR_CMD, FALSE));
-
- /*
- * Now we know the file's name and its search path, we attempt to
- * find the durn thing. A return of NULL indicates the file don't
- * exist.
- */
- if (!isSystem) {
- /*
- * Include files contained in double-quotes are first searched
- * for relative to the including file's location. We don't want
- * to cd there, of course, so we just tack on the old file's
- * leading path components and call Path_FindFile to see if
- * we can locate the beast.
- */
-
- /* Make a temporary copy of this, to be safe. */
- Fname = estrdup(CURFILE->fname);
-
- prefEnd = strrchr(Fname, '/');
- if (prefEnd != NULL) {
- *prefEnd = '\0';
- if (file[0] == '/')
- newName = estrdup(file);
- else
- newName = str_concat(Fname, file, STR_ADDSLASH);
- fullname = Path_FindFile(newName, &parseIncPath);
- if (fullname == NULL) {
- fullname = Path_FindFile(newName,
- &dirSearchPath);
- }
- free(newName);
- *prefEnd = '/';
- } else {
- fullname = NULL;
- }
- free(Fname);
- if (fullname == NULL) {
- /*
- * Makefile wasn't found in same directory as included
- * makefile. Search for it first on the -I search path,
- * then on the .PATH search path, if not found in a -I
- * directory.
- * XXX: Suffix specific?
- */
- fullname = Path_FindFile(file, &parseIncPath);
- if (fullname == NULL) {
- fullname = Path_FindFile(file, &dirSearchPath);
- }
- }
- } else {
- fullname = NULL;
- }
-
- if (fullname == NULL) {
- /*
- * System makefile or still haven't found the makefile.
- * Look for it on the system path.
- */
- fullname = Path_FindFile(file, &sysIncPath);
- }
-
- if (fullname == NULL) {
- *cp = endc;
- if (!sinclude)
- Parse_Error(PARSE_FATAL, "Could not find %s", file);
- else
- Main_AddSourceMakefile(file);
- free(file);
- return;
- }
- Main_AddSourceMakefile(fullname);
- free(file);
-
- /*
- * We set up the name of the file to be the absolute
- * name of the include file so error messages refer to the right
- * place.
- */
- ParsePushInput(fullname, NULL, NULL, 0);
- DEBUGF(DIR, (".include %s\n", fullname));
-}
-
-static void
-parse_include(char *file, int code __unused, int lineno __unused)
-{
- xparse_include(file, 0);
-}
-
-static void
-parse_sinclude(char *file, int code __unused, int lineno __unused)
-{
- xparse_include(file, 1);
-}
-
-/**
- * parse_message
- * Parse a .warning or .error directive
- *
- * The input is the line minus the ".error"/".warning". We substitute
- * variables, print the message and exit(1) (for .error) or just print
- * a warning if the directive is malformed.
- */
-static void
-parse_message(char *line, int iserror, int lineno __unused)
-{
-
- if (!isspace((u_char)*line)) {
- Parse_Error(PARSE_WARNING, "invalid syntax: .%s%s",
- iserror ? "error" : "warning", line);
- return;
- }
-
- while (isspace((u_char)*line))
- line++;
-
- line = Buf_Peel(Var_Subst(line, VAR_CMD, FALSE));
- Parse_Error(iserror ? PARSE_FATAL : PARSE_WARNING, "%s", line);
- free(line);
-
- if (iserror) {
- /* Terminate immediately. */
- exit(1);
- }
-}
-
-/**
- * parse_undef
- * Parse an .undef directive.
- */
-static void
-parse_undef(char *line, int code __unused, int lineno __unused)
-{
- char *cp;
-
- while (isspace((u_char)*line))
- line++;
-
- for (cp = line; !isspace((u_char)*cp) && *cp != '\0'; cp++) {
- ;
- }
- *cp = '\0';
-
- cp = Buf_Peel(Var_Subst(line, VAR_CMD, FALSE));
- Var_Delete(cp, VAR_GLOBAL);
- free(cp);
-}
-
-/**
- * parse_for
- * Parse a .for directive.
- */
-static void
-parse_for(char *line, int code __unused, int lineno)
-{
-
- if (!For_For(line)) {
- /* syntax error */
- return;
- }
- line = NULL;
-
- /*
- * Skip after the matching endfor.
- */
- do {
- free(line);
- line = ParseSkipLine(0, 1);
- if (line == NULL) {
- Parse_Error(PARSE_FATAL,
- "Unexpected end of file in for loop.\n");
- return;
- }
- } while (For_Eval(line));
- free(line);
-
- /* execute */
- For_Run(lineno);
-}
-
-/**
- * parse_endfor
- * Parse endfor. This may only happen if there was no matching .for.
- */
-static void
-parse_endfor(char *line __unused, int code __unused, int lineno __unused)
-{
-
- Parse_Error(PARSE_FATAL, "for-less endfor");
-}
-
-/**
- * parse_directive
- * Got a line starting with a '.'. Check if this is a directive
- * and parse it.
- *
- * return:
- * TRUE if line was a directive, FALSE otherwise.
- */
-static Boolean
-parse_directive(char *line)
-{
- char *start;
- char *cp;
- int dir;
-
- /*
- * Get the keyword:
- * .[[:space:]]*\([[:alpha:]][[:alnum:]_]*\).*
- * \1 is the keyword.
- */
- for (start = line; isspace((u_char)*start); start++) {
- ;
- }
-
- if (!isalpha((u_char)*start)) {
- return (FALSE);
- }
-
- cp = start + 1;
- while (isalnum((u_char)*cp) || *cp == '_') {
- cp++;
- }
-
- dir = directive_hash(start, cp - start);
- if (dir < 0 || dir >= (int)NDIRECTS ||
- (size_t)(cp - start) != strlen(directives[dir].name) ||
- strncmp(start, directives[dir].name, cp - start) != 0) {
- /* not actually matched */
- return (FALSE);
- }
-
- if (!skipLine || directives[dir].skip_flag)
- (*directives[dir].func)(cp, directives[dir].code,
- CURFILE->lineno);
- return (TRUE);
-}
-
-/*-
- *---------------------------------------------------------------------
- * Parse_File --
- * Parse a file into its component parts, incorporating it into the
- * current dependency graph. This is the main function and controls
- * almost every other function in this module
- *
- * Results:
- * None
- *
- * Side Effects:
- * Loads. Nodes are added to the list of all targets, nodes and links
- * are added to the dependency graph. etc. etc. etc.
- *---------------------------------------------------------------------
- */
-void
-Parse_File(const char *name, FILE *stream)
-{
- char *cp; /* pointer into the line */
- char *line; /* the line we're working on */
-
- inLine = FALSE;
- fatals = 0;
-
- ParsePushInput(estrdup(name), stream, NULL, 0);
-
- while ((line = ParseReadLine()) != NULL) {
- if (*line == '.' && parse_directive(line + 1)) {
- /* directive consumed */
- goto nextLine;
- }
- if (skipLine || *line == '#') {
- /* Skipping .if block or comment. */
- goto nextLine;
- }
-
- if (*line == '\t') {
- /*
- * If a line starts with a tab, it can only
- * hope to be a creation command.
- */
- for (cp = line + 1; isspace((unsigned char)*cp); cp++) {
- continue;
- }
- if (*cp) {
- if (inLine) {
- LstNode *ln;
- GNode *gn;
-
- /*
- * So long as it's not a blank
- * line and we're actually in a
- * dependency spec, add the
- * command to the list of
- * commands of all targets in
- * the dependency spec.
- */
- LST_FOREACH(ln, &targets) {
- gn = Lst_Datum(ln);
-
- /*
- * if target already
- * supplied, ignore
- * commands
- */
- if (!(gn->type & OP_HAS_COMMANDS))
- Lst_AtEnd(&gn->commands, cp);
- else
- Parse_Error(PARSE_WARNING, "duplicate script "
- "for target \"%s\" ignored", gn->name);
- }
- continue;
- } else {
- Parse_Error(PARSE_FATAL,
- "Unassociated shell command \"%s\"",
- cp);
- }
- }
-#ifdef SYSVINCLUDE
- } else if (strncmp(line, "include", 7) == 0 &&
- isspace((unsigned char)line[7]) &&
- strchr(line, ':') == NULL) {
- /*
- * It's an S3/S5-style "include".
- */
- ParseTraditionalInclude(line + 7);
- goto nextLine;
-#endif
- } else if (Parse_IsVar(line)) {
- ParseFinishLine();
- Parse_DoVar(line, VAR_GLOBAL);
-
- } else {
- /*
- * We now know it's a dependency line so it
- * needs to have all variables expanded before
- * being parsed. Tell the variable module to
- * complain if some variable is undefined...
- * To make life easier on novices, if the line
- * is indented we first make sure the line has
- * a dependency operator in it. If it doesn't
- * have an operator and we're in a dependency
- * line's script, we assume it's actually a
- * shell command and add it to the current
- * list of targets. XXX this comment seems wrong.
- */
- cp = line;
- if (isspace((unsigned char)line[0])) {
- while (*cp != '\0' &&
- isspace((unsigned char)*cp)) {
- cp++;
- }
- if (*cp == '\0') {
- goto nextLine;
- }
- }
-
- ParseFinishLine();
-
- cp = Buf_Peel(Var_Subst(line, VAR_CMD, TRUE));
-
- free(line);
- line = cp;
-
- /*
- * Need a non-circular list for the target nodes
- */
- Lst_Destroy(&targets, NOFREE);
- inLine = TRUE;
-
- ParseDoDependency(line);
- }
-
- nextLine:
- free(line);
- }
-
- ParseFinishLine();
-
- /*
- * Make sure conditionals are clean
- */
- Cond_End();
-
- if (fatals)
- errx(1, "fatal errors encountered -- cannot continue");
-}
-
-/*-
- *-----------------------------------------------------------------------
- * Parse_MainName --
- * Return a Lst of the main target to create for main()'s sake. If
- * no such target exists, we Punt with an obnoxious error message.
- *
- * Results:
- * A Lst of the single node to create.
- *
- * Side Effects:
- * None.
- *
- *-----------------------------------------------------------------------
- */
-void
-Parse_MainName(Lst *listmain)
-{
-
- if (mainNode == NULL) {
- Punt("no target to make.");
- /*NOTREACHED*/
- } else if (mainNode->type & OP_DOUBLEDEP) {
- Lst_AtEnd(listmain, mainNode);
- Lst_Concat(listmain, &mainNode->cohorts, LST_CONCNEW);
- } else
- Lst_AtEnd(listmain, mainNode);
-}
diff --git a/usr.bin/make/parse.h b/usr.bin/make/parse.h
deleted file mode 100644
index 6ee15f9..0000000
--- a/usr.bin/make/parse.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/*-
- * Copyright (c) 1988, 1989, 1990, 1993
- * The Regents of the University of California. All rights reserved.
- * Copyright (c) 1989 by Berkeley Softworks
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Adam de Boor.
- *
- * 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.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
- *
- * $FreeBSD$
- */
-
-#ifndef parse_h_470eeb9a
-#define parse_h_470eeb9a
-
-#include <stdio.h>
-
-#include "util.h"
-
-struct GNode;
-struct Lst;
-
-/*
- * Error levels for parsing. PARSE_FATAL means the process cannot continue
- * once the makefile has been parsed. PARSE_WARNING means it can. Passed
- * as the first argument to Parse_Error.
- */
-#define PARSE_WARNING 2
-#define PARSE_FATAL 1
-
-/*
- * Definitions for the "local" variables. Used only for clarity.
- */
-#define TARGET "@" /* Target of dependency */
-#define OODATE "?" /* All out-of-date sources */
-#define ALLSRC ">" /* All sources */
-#define IMPSRC "<" /* Source implied by transformation */
-#define PREFIX "*" /* Common prefix */
-#define ARCHIVE "!" /* Archive in "archive(member)" syntax */
-#define MEMBER "%" /* Member in "archive(member)" syntax */
-
-#define FTARGET "@F" /* file part of TARGET */
-#define DTARGET "@D" /* directory part of TARGET */
-#define FIMPSRC "<F" /* file part of IMPSRC */
-#define DIMPSRC "<D" /* directory part of IMPSRC */
-#define FPREFIX "*F" /* file part of PREFIX */
-#define DPREFIX "*D" /* directory part of PREFIX */
-
-void Parse_Error(int, const char *, ...);
-Boolean Parse_AnyExport(void);
-Boolean Parse_IsVar(char *);
-void Parse_DoVar(char *, struct GNode *);
-void Parse_AddIncludeDir(char *);
-void Parse_File(const char *, FILE *);
-void Parse_FromString(char *, int);
-void Parse_MainName(struct Lst *);
-
-#endif /* parse_h_470eeb9a */
diff --git a/usr.bin/make/pathnames.h b/usr.bin/make/pathnames.h
deleted file mode 100644
index 5fb4ceb..0000000
--- a/usr.bin/make/pathnames.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*-
- * Copyright (c) 1990, 1993
- * The Regents of the University of California. 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 distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
- *
- * @(#)pathnames.h 8.2 (Berkeley) 4/28/95
- * $FreeBSD$
- */
-
-#ifndef pathnames_h_235b888a
-#define pathnames_h_235b888a
-
-#ifndef PATH_OBJDIR
-#define PATH_OBJDIR "obj"
-#endif /* ! PATH_OBJDIR */
-
-#ifndef PATH_OBJDIRPREFIX
-#define PATH_OBJDIRPREFIX "/usr/obj"
-#endif /* ! PATH_OBJDIRPREFIX */
-
-#ifndef PATH_DEFSHELLDIR
-#define PATH_DEFSHELLDIR "/bin"
-#endif /* ! PATH_DEFSHELLDIR */
-
-#ifndef PATH_DEFSYSMK
-#define PATH_DEFSYSMK "sys.mk"
-#endif /* ! PATH_DEFSYSMK */
-
-#ifndef PATH_DEFSYSPATH
-#define PATH_DEFSYSPATH "/usr/share/mk"
-#endif /* ! PATH_DEFSYSPATH */
-
-#endif /* pathnames_h_235b888a */
diff --git a/usr.bin/make/proc.c b/usr.bin/make/proc.c
deleted file mode 100644
index 3a7e4f6..0000000
--- a/usr.bin/make/proc.c
+++ /dev/null
@@ -1,134 +0,0 @@
-/*-
- * Copyright (C) 2005 Max Okumoto.
- * 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 distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY AUTHOR 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 AUTHOR 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.
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <unistd.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-#include <fcntl.h>
-
-#include "proc.h"
-#include "shell.h"
-#include "util.h"
-
-/**
- * Replace the current process.
- */
-void
-Proc_Exec(const ProcStuff *ps)
-{
-
- if (ps->in != STDIN_FILENO) {
- /*
- * Redirect the child's stdin to the input fd
- * and reset it to the beginning (again).
- */
- if (dup2(ps->in, STDIN_FILENO) == -1)
- Punt("Cannot dup2: %s", strerror(errno));
- lseek(STDIN_FILENO, (off_t)0, SEEK_SET);
- }
-
- if (ps->out != STDOUT_FILENO) {
- /*
- * Redirect the child's stdout to the output fd.
- */
- if (dup2(ps->out, STDOUT_FILENO) == -1)
- Punt("Cannot dup2: %s", strerror(errno));
- close(ps->out);
- }
-
- if (ps->err != STDERR_FILENO) {
- /*
- * Redirect the child's stderr to the err fd.
- */
- if (dup2(ps->err, STDERR_FILENO) == -1)
- Punt("Cannot dup2: %s", strerror(errno));
- close(ps->err);
- }
-
- if (ps->merge_errors) {
- /*
- * Send stderr to parent process too.
- */
- if (dup2(STDOUT_FILENO, STDERR_FILENO) == -1)
- Punt("Cannot dup2: %s", strerror(errno));
- }
-
- if (commandShell->unsetenv) {
- /* for the benfit of ksh */
- unsetenv("ENV");
- }
-
- /*
- * The file descriptors for stdin, stdout, or stderr might
- * have been marked close-on-exec. Clear the flag on all
- * of them.
- */
- fcntl(STDIN_FILENO, F_SETFD,
- fcntl(STDIN_FILENO, F_GETFD) & (~FD_CLOEXEC));
- fcntl(STDOUT_FILENO, F_SETFD,
- fcntl(STDOUT_FILENO, F_GETFD) & (~FD_CLOEXEC));
- fcntl(STDERR_FILENO, F_SETFD,
- fcntl(STDERR_FILENO, F_GETFD) & (~FD_CLOEXEC));
-
- if (ps->pgroup) {
-#ifdef USE_PGRP
- /*
- * Become a process group leader, so we can kill it and all
- * its descendants in one fell swoop, by killing its process
- * family, but not commit suicide.
- */
-#if defined(SYSV)
- setsid();
-#else
- setpgid(0, getpid());
-#endif
-#endif /* USE_PGRP */
- }
-
- if (ps->searchpath) {
- execvp(ps->argv[0], ps->argv);
-
- write(STDERR_FILENO, ps->argv[0], strlen(ps->argv[0]));
- write(STDERR_FILENO, ": ", 2);
- write(STDERR_FILENO, strerror(errno), strlen(strerror(errno)));
- write(STDERR_FILENO, "\n", 1);
- } else {
- execv(commandShell->path, ps->argv);
-
- write(STDERR_FILENO,
- "Could not execute shell\n",
- sizeof("Could not execute shell"));
- }
-
- /*
- * Since we are the child process, exit without flushing buffers.
- */
- _exit(1);
-}
diff --git a/usr.bin/make/shell.c b/usr.bin/make/shell.c
deleted file mode 100644
index c1f82d1..0000000
--- a/usr.bin/make/shell.c
+++ /dev/null
@@ -1,472 +0,0 @@
-/*-
- * Copyright (c) 1988, 1989, 1990, 1993
- * The Regents of the University of California. All rights reserved.
- * Copyright (c) 1988, 1989 by Adam de Boor
- * Copyright (c) 1989 by Berkeley Softworks
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Adam de Boor.
- *
- * 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.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/queue.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "parse.h"
-#include "pathnames.h"
-#include "shell.h"
-#include "util.h"
-
-/*
- * Descriptions for various shells. What the list of builtins should contain
- * is debatable: either all builtins or only those which may specified on
- * a single line without use of meta-characters. For correct makefiles that
- * contain only correct command lines there is no difference. But if a command
- * line, for example, is: 'if -foo bar' and there is an executable named 'if'
- * in the path, the first possibility would execute that 'if' while in the
- * second case the shell would give an error. Histerically only a small
- * subset of the builtins and no reserved words where given in the list which
- * corresponds roughly to the first variant. So go with this but add missing
- * words.
- */
-#define CSH_BUILTINS \
- "alias cd eval exec exit read set ulimit unalias " \
- "umask unset wait"
-
-#define SH_BUILTINS \
- "alias cd eval exec exit read set ulimit unalias " \
- "umask unset wait"
-
-#define CSH_META "#=|^(){};&<>*?[]:$`\\@\n"
-#define SH_META "#=|^(){};&<>*?[]:$`\\\n"
-
-static const char *const shells_init[] = {
- /*
- * CSH description. The csh can do echo control by playing
- * with the setting of the 'echo' shell variable. Sadly,
- * however, it is unable to do error control nicely.
- */
- "name=csh path='" PATH_DEFSHELLDIR "/csh' "
- "quiet='unset verbose' echo='set verbose' filter='unset verbose' "
- "hasErrCtl=N check='echo \"%s\"\n' ignore='csh -c \"%s || exit 0\"' "
- "echoFlag=v errFlag=e "
- "meta='" CSH_META "' builtins='" CSH_BUILTINS "'",
-
- /*
- * SH description. Echo control is also possible and, under
- * sun UNIX anyway, one can even control error checking.
- */
- "name=sh path='" PATH_DEFSHELLDIR "/sh' "
- "quiet='set -' echo='set -v' filter='set -' "
- "hasErrCtl=Y check='set -e' ignore='set +e' "
- "echoFlag=v errFlag=e "
- "meta='" SH_META "' builtins='" SH_BUILTINS "'",
-
- /*
- * KSH description. The Korn shell has a superset of
- * the Bourne shell's functionality. There are probably builtins
- * missing here.
- */
- "name=ksh path='" PATH_DEFSHELLDIR "/ksh' "
- "quiet='set -' echo='set -v' filter='set -' "
- "hasErrCtl=Y check='set -e' ignore='set +e' "
- "echoFlag=v errFlag=e "
- "meta='" SH_META "' builtins='" SH_BUILTINS "' unsetenv=T",
-
- NULL
-};
-
-/*
- * This is the shell to which we pass all commands in the Makefile.
- * It is set by the Job_ParseShell function.
- */
-struct Shell *commandShell;
-
-/*
- * This is the list of all known shells.
- */
-static struct Shells shells = TAILQ_HEAD_INITIALIZER(shells);
-
-void ShellDump(const struct Shell *) __unused;
-
-/**
- * Helper function for sorting the builtin list alphabetically.
- */
-static int
-sort_builtins(const void *p1, const void *p2)
-{
-
- return (strcmp(*(const char* const*)p1, *(const char* const*)p2));
-}
-
-/**
- * Free a shell structure and all associated strings.
- */
-static void
-ShellFree(struct Shell *sh)
-{
-
- if (sh != NULL) {
- free(sh->name);
- free(sh->path);
- free(sh->echoOff);
- free(sh->echoOn);
- free(sh->noPrint);
- free(sh->errCheck);
- free(sh->ignErr);
- free(sh->echo);
- free(sh->exit);
- ArgArray_Done(&sh->builtins);
- free(sh->meta);
- free(sh);
- }
-}
-
-/**
- * Dump a shell specification to stderr.
- */
-void
-ShellDump(const struct Shell *sh)
-{
- int i;
-
- fprintf(stderr, "Shell %p:\n", sh);
- fprintf(stderr, " name='%s' path='%s'\n", sh->name, sh->path);
- fprintf(stderr, " hasEchoCtl=%d echoOff='%s' echoOn='%s'\n",
- sh->hasEchoCtl, sh->echoOff, sh->echoOn);
- fprintf(stderr, " noPrint='%s'\n", sh->noPrint);
- fprintf(stderr, " hasErrCtl=%d errCheck='%s' ignErr='%s'\n",
- sh->hasErrCtl, sh->errCheck, sh->ignErr);
- fprintf(stderr, " echo='%s' exit='%s'\n", sh->echo, sh->exit);
- fprintf(stderr, " builtins=%d\n", sh->builtins.argc - 1);
- for (i = 1; i < sh->builtins.argc; i++)
- fprintf(stderr, " '%s'", sh->builtins.argv[i]);
- fprintf(stderr, "\n meta='%s'\n", sh->meta);
- fprintf(stderr, " unsetenv=%d\n", sh->unsetenv);
-}
-
-/**
- * Parse a shell specification line and return the new Shell structure.
- * In case of an error a message is printed and NULL is returned.
- */
-static struct Shell *
-ShellParseSpec(const char *spec, Boolean *fullSpec)
-{
- ArgArray aa;
- struct Shell *sh;
- char *eq;
- char *keyw;
- int arg;
-
- *fullSpec = FALSE;
-
- sh = emalloc(sizeof(*sh));
- memset(sh, 0, sizeof(*sh));
- ArgArray_Init(&sh->builtins);
-
- /*
- * Parse the specification by keyword but skip the first word
- */
- brk_string(&aa, spec, TRUE);
-
- for (arg = 1; arg < aa.argc; arg++) {
- /*
- * Split keyword and value
- */
- keyw = aa.argv[arg];
- if ((eq = strchr(keyw, '=')) == NULL) {
- Parse_Error(PARSE_FATAL, "missing '=' in shell "
- "specification keyword '%s'", keyw);
- ArgArray_Done(&aa);
- ShellFree(sh);
- return (NULL);
- }
- *eq++ = '\0';
-
- if (strcmp(keyw, "path") == 0) {
- free(sh->path);
- sh->path = estrdup(eq);
- } else if (strcmp(keyw, "name") == 0) {
- free(sh->name);
- sh->name = estrdup(eq);
- } else if (strcmp(keyw, "quiet") == 0) {
- free(sh->echoOff);
- sh->echoOff = estrdup(eq);
- *fullSpec = TRUE;
- } else if (strcmp(keyw, "echo") == 0) {
- free(sh->echoOn);
- sh->echoOn = estrdup(eq);
- *fullSpec = TRUE;
- } else if (strcmp(keyw, "filter") == 0) {
- free(sh->noPrint);
- sh->noPrint = estrdup(eq);
- *fullSpec = TRUE;
- } else if (strcmp(keyw, "echoFlag") == 0) {
- free(sh->echo);
- sh->echo = estrdup(eq);
- *fullSpec = TRUE;
- } else if (strcmp(keyw, "errFlag") == 0) {
- free(sh->exit);
- sh->exit = estrdup(eq);
- *fullSpec = TRUE;
- } else if (strcmp(keyw, "hasErrCtl") == 0) {
- sh->hasErrCtl = (*eq == 'Y' || *eq == 'y' ||
- *eq == 'T' || *eq == 't');
- *fullSpec = TRUE;
- } else if (strcmp(keyw, "check") == 0) {
- free(sh->errCheck);
- sh->errCheck = estrdup(eq);
- *fullSpec = TRUE;
- } else if (strcmp(keyw, "ignore") == 0) {
- free(sh->ignErr);
- sh->ignErr = estrdup(eq);
- *fullSpec = TRUE;
- } else if (strcmp(keyw, "builtins") == 0) {
- ArgArray_Done(&sh->builtins);
- brk_string(&sh->builtins, eq, TRUE);
- qsort(sh->builtins.argv + 1, sh->builtins.argc - 1,
- sizeof(char *), sort_builtins);
- *fullSpec = TRUE;
- } else if (strcmp(keyw, "meta") == 0) {
- free(sh->meta);
- sh->meta = estrdup(eq);
- *fullSpec = TRUE;
- } else if (strcmp(keyw, "unsetenv") == 0) {
- sh->unsetenv = (*eq == 'Y' || *eq == 'y' ||
- *eq == 'T' || *eq == 't');
- *fullSpec = TRUE;
- } else {
- Parse_Error(PARSE_FATAL, "unknown keyword in shell "
- "specification '%s'", keyw);
- ArgArray_Done(&aa);
- ShellFree(sh);
- return (NULL);
- }
- }
- ArgArray_Done(&aa);
-
- /*
- * Some checks (could be more)
- */
- if (*fullSpec) {
- if ((sh->echoOn != NULL) ^ (sh->echoOff != NULL)) {
- Parse_Error(PARSE_FATAL, "Shell must have either both "
- "echoOff and echoOn or none of them");
- ShellFree(sh);
- return (NULL);
- }
-
- if (sh->echoOn != NULL && sh->echoOff != NULL)
- sh->hasEchoCtl = TRUE;
- }
-
- return (sh);
-}
-
-/**
- * Parse the builtin shell specifications and put them into the shell
- * list. Then select the default shell to be the current shell. This
- * is called from main() before any parsing (including MAKEFLAGS and
- * command line) is done.
- */
-void
-Shell_Init(void)
-{
- int i;
- struct Shell *sh;
- Boolean fullSpec;
-
- for (i = 0; shells_init[i] != NULL; i++) {
- sh = ShellParseSpec(shells_init[i], &fullSpec);
- TAILQ_INSERT_TAIL(&shells, sh, link);
- if (strcmp(sh->name, DEFSHELLNAME) == 0)
- commandShell = sh;
- }
-}
-
-/**
- * Find a matching shell in 'shells' given its final component.
- *
- * Results:
- * A pointer to a freshly allocated Shell structure with the contents
- * from static description or NULL if no shell with the given name
- * is found.
- */
-static struct Shell *
-ShellMatch(const char *name)
-{
- struct Shell *sh;
-
- TAILQ_FOREACH(sh, &shells, link)
- if (strcmp(sh->name, name) == 0)
- return (sh);
-
- return (NULL);
-}
-
-/**
- * Parse a shell specification and set up commandShell appropriately.
- *
- * Results:
- * TRUE if the specification was correct. FALSE otherwise.
- *
- * Side Effects:
- * commandShell points to a Shell structure.
- * created from the shell spec).
- *
- * Notes:
- * A shell specification consists of a .SHELL target, with dependency
- * operator, followed by a series of blank-separated words. Double
- * quotes can be used to use blanks in words. A backslash escapes
- * anything (most notably a double-quote and a space) and
- * provides the functionality it does in C. Each word consists of
- * keyword and value separated by an equal sign. There should be no
- * unnecessary spaces in the word. The keywords are as follows:
- * name Name of shell.
- * path Location of shell. Overrides "name" if given
- * quiet Command to turn off echoing.
- * echo Command to turn echoing on
- * filter Result of turning off echoing that shouldn't be
- * printed.
- * echoFlag Flag to turn echoing on at the start
- * errFlag Flag to turn error checking on at the start
- * hasErrCtl True if shell has error checking control
- * check Command to turn on error checking if hasErrCtl
- * is TRUE or template of command to echo a command
- * for which error checking is off if hasErrCtl is
- * FALSE.
- * ignore Command to turn off error checking if hasErrCtl
- * is TRUE or template of command to execute a
- * command so as to ignore any errors it returns if
- * hasErrCtl is FALSE.
- * builtins A space separated list of builtins. If one
- * of these builtins is detected when make wants
- * to execute a command line, the command line is
- * handed to the shell. Otherwise make may try to
- * execute the command directly. If this list is empty
- * it is assumed, that the command must always be
- * handed over to the shell.
- * meta The shell meta characters. If this is not specified
- * or empty, commands are alway passed to the shell.
- * Otherwise they are not passed when they contain
- * neither a meta character nor a builtin command.
- * unsetenv Unsetenv("ENV") before executing anything.
- */
-Boolean
-Shell_Parse(const char line[])
-{
- Boolean fullSpec;
- struct Shell *sh;
- struct Shell *match;
-
- /* parse the specification */
- if ((sh = ShellParseSpec(line, &fullSpec)) == NULL)
- return (FALSE);
-
- if (sh->path == NULL) {
- /*
- * If no path was given, the user wants one of the pre-defined
- * shells, yes? So we find the one s/he wants with the help of
- * JobMatchShell and set things up the right way.
- */
- if (sh->name == NULL) {
- Parse_Error(PARSE_FATAL,
- "Neither path nor name specified");
- ShellFree(sh);
- return (FALSE);
- }
- if (fullSpec) {
- /*
- * XXX May want to merge sh into match. But this
- * require ShellParseSpec to return information
- * which attributes actuall have been specified.
- */
- Parse_Error(PARSE_FATAL, "No path specified");
- ShellFree(sh);
- return (FALSE);
- }
- if ((match = ShellMatch(sh->name)) == NULL) {
- Parse_Error(PARSE_FATAL, "%s: no matching shell",
- sh->name);
- ShellFree(sh);
- return (FALSE);
- }
- ShellFree(sh);
- commandShell = match;
-
- return (TRUE);
- }
-
- /*
- * The user provided a path. If s/he gave nothing else
- * (fullSpec is FALSE), try and find a matching shell in the
- * ones we know of. Else we just take the specification at its
- * word and copy it to a new location. In either case, we need
- * to record the path the user gave for the shell.
- */
- if (sh->name == NULL) {
- /* get the base name as the name */
- if ((sh->name = strrchr(sh->path, '/')) == NULL) {
- sh->name = estrdup(sh->path);
- } else {
- sh->name = estrdup(sh->name + 1);
- }
- }
-
- if (!fullSpec) {
- if ((match = ShellMatch(sh->name)) == NULL) {
- Parse_Error(PARSE_FATAL,
- "%s: no matching shell", sh->name);
- ShellFree(sh);
- return (FALSE);
- }
-
- /* set the patch on the matching shell */
- free(match->path);
- match->path = sh->path;
- sh->path = NULL;
-
- ShellFree(sh);
- commandShell = match;
- return (TRUE);
- }
-
- TAILQ_INSERT_HEAD(&shells, sh, link);
-
- /* set the new shell */
- commandShell = sh;
- return (TRUE);
-}
diff --git a/usr.bin/make/shell.h b/usr.bin/make/shell.h
deleted file mode 100644
index a317058..0000000
--- a/usr.bin/make/shell.h
+++ /dev/null
@@ -1,110 +0,0 @@
-/*-
- * Copyright (c) 1988, 1989, 1990, 1993
- * The Regents of the University of California. All rights reserved.
- * Copyright (c) 1988, 1989 by Adam de Boor
- * Copyright (c) 1989 by Berkeley Softworks
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Adam de Boor.
- *
- * 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.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
- *
- * $FreeBSD$
- */
-
-#ifndef shell_h_6002e3b8
-#define shell_h_6002e3b8
-
-#include <sys/queue.h>
-
-#include "str.h"
-#include "util.h"
-
-/**
- * Shell Specifications:
- *
- * Some special stuff goes on if a shell doesn't have error control. In such
- * a case, errCheck becomes a printf template for echoing the command,
- * should echoing be on and ignErr becomes another printf template for
- * executing the command while ignoring the return status. If either of these
- * strings is empty when hasErrCtl is FALSE, the command will be executed
- * anyway as is and if it causes an error, so be it.
- */
-struct Shell {
- TAILQ_ENTRY(Shell) link; /* link all shell descriptions */
-
- /*
- * the name of the shell. For Bourne and C shells, this is used
- * only to find the shell description when used as the single
- * source of a .SHELL target.
- */
- char *name;
-
- char *path; /* full path to the shell */
-
- /* True if both echoOff and echoOn defined */
- Boolean hasEchoCtl;
-
- char *echoOff; /* command to turn off echo */
- char *echoOn; /* command to turn it back on */
-
- /*
- * What the shell prints, and its length, when given the
- * echo-off command. This line will not be printed when
- * received from the shell. This is usually the command which
- * was executed to turn off echoing
- */
- char *noPrint;
-
- /* set if can control error checking for individual commands */
- Boolean hasErrCtl;
-
- /* string to turn error checking on */
- char *errCheck;
-
- /* string to turn off error checking */
- char *ignErr;
-
- char *echo; /* command line flag: echo commands */
- char *exit; /* command line flag: exit on error */
-
- ArgArray builtins; /* ordered list of shell builtins */
- char *meta; /* shell meta characters */
-
- Boolean unsetenv; /* unsetenv("ENV") before exec */
-};
-TAILQ_HEAD(Shells, Shell);
-
-extern struct Shell *commandShell;
-
-void Shell_Init(void);
-Boolean Shell_Parse(const char []);
-
-#endif /* shell_h_6002e3b8 */
diff --git a/usr.bin/make/str.c b/usr.bin/make/str.c
deleted file mode 100644
index ce4ac05..0000000
--- a/usr.bin/make/str.c
+++ /dev/null
@@ -1,559 +0,0 @@
-/*-
- * Copyright (c) 1988, 1989, 1990, 1993
- * The Regents of the University of California. All rights reserved.
- * Copyright (c) 1989 by Berkeley Softworks
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Adam de Boor.
- *
- * 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.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
- *
- * @(#)str.c 5.8 (Berkeley) 6/1/90
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <stdlib.h>
-#include <string.h>
-
-#include "buf.h"
-#include "str.h"
-#include "util.h"
-
-/**
- * Initialize the argument array object. The array is initially
- * eight positions, and will be expanded as necessary. The first
- * position is set to NULL since everything ignores it. We allocate
- * (size + 1) since we need space for the terminating NULL. The
- * buffer is set to NULL, since no common buffer is allocated yet.
- */
-void
-ArgArray_Init(ArgArray *aa)
-{
-
- aa->size = 8;
- aa->argv = emalloc((aa->size + 1) * sizeof(char *));
- aa->argc = 0;
- aa->argv[aa->argc++] = NULL;
- aa->len = 0;
- aa->buffer = NULL;
-}
-
-/**
- * Cleanup the memory allocated for in the argument array object.
- */
-void
-ArgArray_Done(ArgArray *aa)
-{
-
- if (aa->buffer == NULL) {
- int i;
- /* args are individually allocated */
- for (i = 0; i < aa->argc; ++i) {
- if (aa->argv[i]) {
- free(aa->argv[i]);
- aa->argv[i] = NULL;
- }
- }
- } else {
- /* args are part of a single allocation */
- free(aa->buffer);
- aa->buffer = NULL;
- }
- free(aa->argv);
- aa->argv = NULL;
- aa->argc = 0;
- aa->size = 0;
-}
-
-/*-
- * str_concat --
- * concatenate the two strings, inserting a space or slash between them.
- *
- * returns --
- * the resulting string in allocated space.
- */
-char *
-str_concat(const char *s1, const char *s2, int flags)
-{
- int len1, len2;
- char *result;
-
- /* get the length of both strings */
- len1 = strlen(s1);
- len2 = strlen(s2);
-
- /* allocate length plus separator plus EOS */
- result = emalloc(len1 + len2 + 2);
-
- /* copy first string into place */
- memcpy(result, s1, len1);
-
- /* add separator character */
- if (flags & STR_ADDSPACE) {
- result[len1] = ' ';
- ++len1;
- } else if (flags & STR_ADDSLASH) {
- result[len1] = '/';
- ++len1;
- }
-
- /* copy second string plus EOS into place */
- memcpy(result + len1, s2, len2 + 1);
-
- return (result);
-}
-
-/**
- * Fracture a string into an array of words (as delineated by tabs or
- * spaces) taking quotation marks into account. Leading tabs/spaces
- * are ignored.
- */
-void
-brk_string(ArgArray *aa, const char str[], Boolean expand)
-{
- char inquote;
- char *start;
- char *arg;
-
- /* skip leading space chars. */
- for (; *str == ' ' || *str == '\t'; ++str)
- continue;
-
- ArgArray_Init(aa);
-
- aa->buffer = estrdup(str);
-
- arg = aa->buffer;
- start = arg;
- inquote = '\0';
-
- /*
- * copy the string; at the same time, parse backslashes,
- * quotes and build the argument list.
- */
- for (;;) {
- switch (str[0]) {
- case '"':
- case '\'':
- if (inquote == '\0') {
- inquote = str[0];
- if (expand)
- break;
- if (start == NULL)
- start = arg;
- } else if (inquote == str[0]) {
- inquote = '\0';
- /* Don't miss "" or '' */
- if (start == NULL)
- start = arg;
- if (expand)
- break;
- } else {
- /* other type of quote found */
- if (start == NULL)
- start = arg;
- }
- *arg++ = str[0];
- break;
- case ' ':
- case '\t':
- case '\n':
- if (inquote) {
- if (start == NULL)
- start = arg;
- *arg++ = str[0];
- break;
- }
- if (start == NULL)
- break;
- /* FALLTHROUGH */
- case '\0':
- /*
- * end of a token -- make sure there's enough argv
- * space and save off a pointer.
- */
- if (aa->argc == aa->size) {
- aa->size *= 2; /* ramp up fast */
- aa->argv = erealloc(aa->argv,
- (aa->size + 1) * sizeof(char *));
- }
-
- *arg++ = '\0';
- if (start == NULL) {
- aa->argv[aa->argc] = start;
- return;
- }
- if (str[0] == '\n' || str[0] == '\0') {
- aa->argv[aa->argc++] = start;
- aa->argv[aa->argc] = NULL;
- return;
- } else {
- aa->argv[aa->argc++] = start;
- start = NULL;
- break;
- }
- case '\\':
- if (start == NULL)
- start = arg;
- if (expand) {
- switch (str[1]) {
- case '\0':
- case '\n':
- /* hmmm; fix it up as best we can */
- *arg++ = '\\';
- break;
- case 'b':
- *arg++ = '\b';
- ++str;
- break;
- case 'f':
- *arg++ = '\f';
- ++str;
- break;
- case 'n':
- *arg++ = '\n';
- ++str;
- break;
- case 'r':
- *arg++ = '\r';
- ++str;
- break;
- case 't':
- *arg++ = '\t';
- ++str;
- break;
- default:
- *arg++ = str[1];
- ++str;
- break;
- }
- } else {
- *arg++ = str[0];
- if (str[1] != '\0') {
- ++str;
- *arg++ = str[0];
- }
- }
- break;
- default:
- if (start == NULL)
- start = arg;
- *arg++ = str[0];
- break;
- }
- ++str;
- }
-}
-
-/*
- * Quote a string for appending it to MAKEFLAGS. According to Posix the
- * kind of quoting here is implementation-defined. This quoting must ensure
- * that the parsing of MAKEFLAGS's contents in a sub-shell yields the same
- * options, option arguments and macro definitions as in the calling make.
- * We simply quote all blanks, which according to Posix are space and tab
- * in the POSIX locale. Don't use isblank because in that case makes with
- * different locale settings could not communicate. We must also quote
- * backslashes obviously.
- */
-char *
-MAKEFLAGS_quote(const char *str)
-{
- char *ret, *q;
- const char *p;
-
- /* assume worst case - everything has to be quoted */
- ret = emalloc(strlen(str) * 2 + 1);
-
- p = str;
- q = ret;
- while (*p != '\0') {
- switch (*p) {
-
- case ' ':
- case '\t':
- *q++ = '\\';
- break;
-
- default:
- break;
- }
- *q++ = *p++;
- }
- *q++ = '\0';
- return (ret);
-}
-
-void
-MAKEFLAGS_break(ArgArray *aa, const char str[])
-{
- char *arg;
- char *start;
-
- ArgArray_Init(aa);
-
- aa->buffer = strdup(str);
-
- arg = aa->buffer;
- start = NULL;
-
- for (;;) {
- switch (str[0]) {
- case ' ':
- case '\t':
- /* word separator */
- if (start == NULL) {
- /* not in a word */
- str++;
- continue;
- }
- /* FALLTHRU */
- case '\0':
- if (aa->argc == aa->size) {
- aa->size *= 2;
- aa->argv = erealloc(aa->argv,
- (aa->size + 1) * sizeof(char *));
- }
-
- *arg++ = '\0';
- if (start == NULL) {
- aa->argv[aa->argc] = start;
- return;
- }
- if (str[0] == '\0') {
- aa->argv[aa->argc++] = start;
- aa->argv[aa->argc] = NULL;
- return;
- } else {
- aa->argv[aa->argc++] = start;
- start = NULL;
- str++;
- continue;
- }
-
- case '\\':
- if (str[1] == ' ' || str[1] == '\t')
- str++;
- break;
-
- default:
- break;
- }
- if (start == NULL)
- start = arg;
- *arg++ = *str++;
- }
-}
-
-/*
- * Str_Match --
- *
- * See if a particular string matches a particular pattern.
- *
- * Results: Non-zero is returned if string matches pattern, 0 otherwise. The
- * matching operation permits the following special characters in the
- * pattern: *?\[] (see the man page for details on what these mean).
- *
- * Side effects: None.
- */
-int
-Str_Match(const char *string, const char *pattern)
-{
- char c2;
-
- for (;;) {
- /*
- * See if we're at the end of both the pattern and the
- * string. If, we succeeded. If we're at the end of the
- * pattern but not at the end of the string, we failed.
- */
- if (*pattern == 0)
- return (!*string);
- if (*string == 0 && *pattern != '*')
- return (0);
- /*
- * Check for a "*" as the next pattern character. It matches
- * any substring. We handle this by calling ourselves
- * recursively for each postfix of string, until either we
- * match or we reach the end of the string.
- */
- if (*pattern == '*') {
- pattern += 1;
- if (*pattern == 0)
- return (1);
- while (*string != 0) {
- if (Str_Match(string, pattern))
- return (1);
- ++string;
- }
- return (0);
- }
- /*
- * Check for a "?" as the next pattern character. It matches
- * any single character.
- */
- if (*pattern == '?')
- goto thisCharOK;
- /*
- * Check for a "[" as the next pattern character. It is
- * followed by a list of characters that are acceptable, or
- * by a range (two characters separated by "-").
- */
- if (*pattern == '[') {
- ++pattern;
- for (;;) {
- if ((*pattern == ']') || (*pattern == 0))
- return (0);
- if (*pattern == *string)
- break;
- if (pattern[1] == '-') {
- c2 = pattern[2];
- if (c2 == 0)
- return (0);
- if ((*pattern <= *string) &&
- (c2 >= *string))
- break;
- if ((*pattern >= *string) &&
- (c2 <= *string))
- break;
- pattern += 2;
- }
- ++pattern;
- }
- while ((*pattern != ']') && (*pattern != 0))
- ++pattern;
- goto thisCharOK;
- }
- /*
- * If the next pattern character is '/', just strip off the
- * '/' so we do exact matching on the character that follows.
- */
- if (*pattern == '\\') {
- ++pattern;
- if (*pattern == 0)
- return (0);
- }
- /*
- * There's no special character. Just make sure that the
- * next characters of each string match.
- */
- if (*pattern != *string)
- return (0);
-thisCharOK: ++pattern;
- ++string;
- }
-}
-
-
-/**
- * Str_SYSVMatch
- * Check word against pattern for a match (% is wild),
- *
- * Results:
- * Returns the beginning position of a match or null. The number
- * of characters matched is returned in len.
- */
-const char *
-Str_SYSVMatch(const char *word, const char *pattern, int *len)
-{
- const char *m, *p, *w;
-
- p = pattern;
- w = word;
-
- if (*w == '\0') {
- /* Zero-length word cannot be matched against */
- *len = 0;
- return (NULL);
- }
-
- if (*p == '\0') {
- /* Null pattern is the whole string */
- *len = strlen(w);
- return (w);
- }
-
- if ((m = strchr(p, '%')) != NULL) {
- /* check that the prefix matches */
- for (; p != m && *w && *w == *p; w++, p++)
- continue;
-
- if (p != m)
- return (NULL); /* No match */
-
- if (*++p == '\0') {
- /* No more pattern, return the rest of the string */
- *len = strlen(w);
- return (w);
- }
- }
-
- m = w;
-
- /* Find a matching tail */
- do
- if (strcmp(p, w) == 0) {
- *len = w - m;
- return (m);
- }
- while (*w++ != '\0');
-
- return (NULL);
-}
-
-
-/**
- * Str_SYSVSubst
- * Substitute '%' on the pattern with len characters from src.
- * If the pattern does not contain a '%' prepend len characters
- * from src.
- *
- * Side Effects:
- * Places result on buf
- */
-void
-Str_SYSVSubst(Buffer *buf, const char *pat, const char *src, int len)
-{
- const char *m;
-
- if ((m = strchr(pat, '%')) != NULL) {
- /* Copy the prefix */
- Buf_AppendRange(buf, pat, m);
- /* skip the % */
- pat = m + 1;
- }
-
- /* Copy the pattern */
- Buf_AddBytes(buf, len, (const Byte *)src);
-
- /* append the rest */
- Buf_Append(buf, pat);
-}
diff --git a/usr.bin/make/str.h b/usr.bin/make/str.h
deleted file mode 100644
index e8cf10c..0000000
--- a/usr.bin/make/str.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/*-
- * Copyright (c) 1988, 1989, 1990, 1993
- * The Regents of the University of California. All rights reserved.
- * Copyright (c) 1989 by Berkeley Softworks
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Adam de Boor.
- *
- * 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.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
- *
- * $FreeBSD$
- */
-
-#ifndef str_h_44db59e6
-#define str_h_44db59e6
-
-#include "util.h"
-
-struct Buffer;
-
-/**
- * An array of c-strings. The pointers stored in argv, point to
- * strings stored in buffer.
- */
-typedef struct ArgArray {
- int size; /* size of argv array */
- int argc; /* strings referenced in argv */
- char **argv; /* array of string pointers */
- size_t len; /* size of buffer */
- char *buffer; /* data buffer */
-} ArgArray;
-
-/*
- * These constants are all used by the Str_Concat function to decide how the
- * final string should look. If STR_ADDSPACE is given, a space will be
- * placed between the two strings. If STR_ADDSLASH is given, a '/' will
- * be used instead of a space. If neither is given, no intervening characters
- * will be placed between the two strings in the final output.
- */
-#define STR_ADDSPACE 0x01 /* add a space when Str_Concat'ing */
-#define STR_ADDSLASH 0x04 /* add a slash when Str_Concat'ing */
-
-void ArgArray_Init(ArgArray *);
-void ArgArray_Done(ArgArray *);
-
-char *str_concat(const char *, const char *, int);
-void brk_string(ArgArray *, const char [], Boolean);
-char *MAKEFLAGS_quote(const char *);
-void MAKEFLAGS_break(ArgArray *, const char []);
-int Str_Match(const char *, const char *);
-const char *Str_SYSVMatch(const char *, const char *, int *);
-void Str_SYSVSubst(struct Buffer *, const char *, const char *, int);
-
-#endif /* str_h_44db59e6 */
diff --git a/usr.bin/make/suff.c b/usr.bin/make/suff.c
deleted file mode 100644
index bed6c7a..0000000
--- a/usr.bin/make/suff.c
+++ /dev/null
@@ -1,2205 +0,0 @@
-/*-
- * Copyright (c) 1988, 1989, 1990, 1993
- * The Regents of the University of California. All rights reserved.
- * Copyright (c) 1989 by Berkeley Softworks
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Adam de Boor.
- *
- * 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.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
- *
- * @(#)suff.c 8.4 (Berkeley) 3/21/94
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-/*-
- * suff.c --
- * Functions to maintain suffix lists and find implicit dependents
- * using suffix transformation rules
- *
- * Interface:
- * Suff_Init Initialize all things to do with suffixes.
- *
- * Suff_DoPaths This function is used to make life easier
- * when searching for a file according to its
- * suffix. It takes the global search path,
- * as defined using the .PATH: target, and appends
- * its directories to the path of each of the
- * defined suffixes, as specified using
- * .PATH<suffix>: targets. In addition, all
- * directories given for suffixes labeled as
- * include files or libraries, using the .INCLUDES
- * or .LIBS targets, are played with using
- * Dir_MakeFlags to create the .INCLUDES and
- * .LIBS global variables.
- *
- * Suff_ClearSuffixes Clear out all the suffixes and defined
- * transformations.
- *
- * Suff_IsTransform Return TRUE if the passed string is the lhs
- * of a transformation rule.
- *
- * Suff_AddSuffix Add the passed string as another known suffix.
- *
- * Suff_GetPath Return the search path for the given suffix.
- *
- * Suff_AddInclude Mark the given suffix as denoting an include
- * file.
- *
- * Suff_AddLib Mark the given suffix as denoting a library.
- *
- * Suff_AddTransform Add another transformation to the suffix
- * graph. Returns GNode suitable for framing, I
- * mean, tacking commands, attributes, etc. on.
- *
- * Suff_SetNull Define the suffix to consider the suffix of
- * any file that doesn't have a known one.
- *
- * Suff_FindDeps Find implicit sources for and the location of
- * a target based on its suffix. Returns the
- * bottom-most node added to the graph or NULL
- * if the target had no implicit sources.
- */
-
-#include <sys/queue.h>
-#include <assert.h>
-#include <string.h>
-#include <stdlib.h>
-
-#include "arch.h"
-#include "buf.h"
-#include "config.h"
-#include "dir.h"
-#include "globals.h"
-#include "GNode.h"
-#include "lst.h"
-#include "make.h"
-#include "parse.h"
-#include "str.h"
-#include "suff.h"
-#include "targ.h"
-#include "util.h"
-#include "var.h"
-
-/* Lst of suffixes */
-static Lst sufflist = Lst_Initializer(sufflist);
-
-/* Lst of suffixes to be cleaned */
-static Lst suffClean = Lst_Initializer(suffClean);
-
-/* Lst of sources */
-static Lst srclist = Lst_Initializer(srclist);
-
-/* Lst of transformation rules */
-static Lst transforms = Lst_Initializer(transforms);
-
-/* Counter for assigning suffix numbers */
-static int sNum = 0;
-
-/*
- * Structure describing an individual suffix.
- */
-typedef struct Suff {
- char *name; /* The suffix itself */
- int nameLen; /* Length of the suffix */
- short flags; /* Type of suffix */
-#define SUFF_INCLUDE 0x01 /* One which is #include'd */
-#define SUFF_LIBRARY 0x02 /* One which contains a library */
-#define SUFF_NULL 0x04 /* The empty suffix */
- struct Path searchPath; /* Path for files with this suffix */
- int sNum; /* The suffix number */
- int refCount; /* Reference count of list membership */
- Lst parents; /* Suffixes we have a transformation to */
- Lst children; /* Suffixes we have a transformation from */
- Lst ref; /* List of lists this suffix is referenced */
-} Suff;
-
-/*
- * Structure used in the search for implied sources.
- */
-typedef struct Src {
- char *file; /* The file to look for */
- char *pref; /* Prefix from which file was formed */
- Suff *suff; /* The suffix on the file */
- struct Src *parent; /* The Src for which this is a source */
- GNode *node; /* The node describing the file */
- int children; /* Count of existing children (so we don't free
- * this thing too early or never nuke it) */
-#ifdef DEBUG_SRC
- Lst cp; /* Debug; children list */
-#endif
-} Src;
-
-/* The NULL suffix for this run */
-static Suff *suffNull;
-
-/* The empty suffix required for POSIX single-suffix transformation rules */
-static Suff *emptySuff;
-
-static void SuffFindDeps(GNode *, Lst *);
-
-
-/*-
- *-----------------------------------------------------------------------
- * SuffSuffIsSuffix --
- * See if suff is a suffix of str.
- *
- * Results:
- * NULL if it ain't, pointer to character in str before suffix if
- * it is.
- *
- * Side Effects:
- * None
- *-----------------------------------------------------------------------
- */
-static char *
-SuffSuffIsSuffix(const Suff *s, char *str)
-{
- const char *p1; /* Pointer into suffix name */
- char *p2; /* Pointer into string being examined */
- size_t len;
-
- len = strlen(str);
- p1 = s->name + s->nameLen;
- p2 = str + len;
-
- while (p1 >= s->name && len > 0 && *p1 == *p2) {
- p1--;
- p2--;
- len--;
- }
-
- return (p1 == s->name - 1 ? p2 : NULL);
-}
-
-/*-
- *-----------------------------------------------------------------------
- * SuffSuffFind --
- * Find a suffix given its name.
- *
- * Results:
- * The suffix or NULL.
- *
- * Side Effects:
- * None
- *-----------------------------------------------------------------------
- */
-static Suff *
-SuffSuffFind(const char *s)
-{
- LstNode *ln;
-
- LST_FOREACH(ln, &sufflist) {
- if (strcmp(s, ((const Suff *)Lst_Datum(ln))->name) == 0)
- return (Lst_Datum(ln));
- }
- return (NULL);
-}
-
-/*-
- *-----------------------------------------------------------------------
- * SuffTransFind
- * Find a transform.
- *
- * Results:
- * transform or NULL.
- *
- * Side Effects:
- * None
- *-----------------------------------------------------------------------
- */
-static GNode *
-SuffTransFind(const char *name)
-{
- LstNode *ln;
-
- LST_FOREACH(ln, &transforms) {
- if (strcmp(name, ((const GNode *)Lst_Datum(ln))->name) == 0)
- return (Lst_Datum(ln));
- }
- return (NULL);
-}
-
- /*********** Maintenance Functions ************/
-
-#if 0
-/*
- * Keep this function for now until it is clear why a .SUFFIXES: doesn't
- * actually delete the suffixes but just puts them on the suffClean list.
- */
-/*-
- *-----------------------------------------------------------------------
- * SuffFree --
- * Free up all memory associated with the given suffix structure.
- *
- * Results:
- * none
- *
- * Side Effects:
- * the suffix entry is detroyed
- *-----------------------------------------------------------------------
- */
-static void
-SuffFree(void *sp)
-{
- Suff *s = sp;
-
- if (s == suffNull)
- suffNull = NULL;
-
- if (s == emptySuff)
- emptySuff = NULL;
-
- Lst_Destroy(&s->ref, NOFREE);
- Lst_Destroy(&s->children, NOFREE);
- Lst_Destroy(&s->parents, NOFREE);
- Lst_Destroy(&s->searchPath, Dir_Destroy);
-
- free(s->name);
- free(s);
-}
-#endif
-
-/*-
- *-----------------------------------------------------------------------
- * SuffRemove --
- * Remove the suffix into the list
- *
- * Results:
- * None
- *
- * Side Effects:
- * The reference count for the suffix is decremented
- *-----------------------------------------------------------------------
- */
-static void
-SuffRemove(Lst *l, Suff *s)
-{
- LstNode *ln = Lst_Member(l, s);
-
- if (ln != NULL) {
- Lst_Remove(l, ln);
- s->refCount--;
- }
-}
-
-/*-
- *-----------------------------------------------------------------------
- * SuffInsert --
- * Insert the suffix into the list keeping the list ordered by suffix
- * numbers.
- *
- * Results:
- * None
- *
- * Side Effects:
- * The reference count of the suffix is incremented
- *-----------------------------------------------------------------------
- */
-static void
-SuffInsert(Lst *l, Suff *s)
-{
- LstNode *ln; /* current element in l we're examining */
- Suff *s2; /* the suffix descriptor in this element */
-
- s2 = NULL;
- for (ln = Lst_First(l); ln != NULL; ln = Lst_Succ(ln)) {
- s2 = Lst_Datum(ln);
- if (s2->sNum >= s->sNum)
- break;
- }
- if (s2 == NULL) {
- DEBUGF(SUFF, ("inserting an empty list?..."));
- }
-
- DEBUGF(SUFF, ("inserting %s(%d)...", s->name, s->sNum));
- if (ln == NULL) {
- DEBUGF(SUFF, ("at end of list\n"));
- Lst_AtEnd(l, s);
- s->refCount++;
- Lst_AtEnd(&s->ref, l);
- } else if (s2->sNum != s->sNum) {
- DEBUGF(SUFF, ("before %s(%d)\n", s2->name, s2->sNum));
- Lst_Insert(l, ln, s);
- s->refCount++;
- Lst_AtEnd(&s->ref, l);
- } else {
- DEBUGF(SUFF, ("already there\n"));
- }
-}
-
-/*-
- *-----------------------------------------------------------------------
- * Suff_ClearSuffixes --
- * This is gross. Nuke the list of suffixes but keep all transformation
- * rules around. The transformation graph is destroyed in this process,
- * but we leave the list of rules so when a new graph is formed the rules
- * will remain.
- * This function is called from the parse module when a
- * .SUFFIXES:\n line is encountered.
- *
- * Results:
- * none
- *
- * Side Effects:
- * the sufflist and its graph nodes are destroyed
- *-----------------------------------------------------------------------
- */
-void
-Suff_ClearSuffixes(void)
-{
-
- Lst_Concat(&suffClean, &sufflist, LST_CONCLINK);
-
- sNum = 1;
- suffNull = emptySuff;
- /*
- * Clear suffNull's children list (the other suffixes are built new, but
- * suffNull is used as is).
- * NOFREE is used because all suffixes are are on the suffClean list.
- * suffNull should not have parents.
- */
- Lst_Destroy(&suffNull->children, NOFREE);
-}
-
-/*-
- *-----------------------------------------------------------------------
- * SuffParseTransform --
- * Parse a transformation string to find its two component suffixes.
- *
- * Results:
- * TRUE if the string is a valid transformation and FALSE otherwise.
- *
- * Side Effects:
- * The passed pointers are overwritten.
- *
- *-----------------------------------------------------------------------
- */
-static Boolean
-SuffParseTransform(char *str, Suff **srcPtr, Suff **targPtr)
-{
- LstNode *srcLn; /* element in suffix list of trans source*/
- Suff *src; /* Source of transformation */
- char *str2; /* Extra pointer (maybe target suffix) */
- LstNode *singleLn; /* element in suffix list of any suffix
- * that exactly matches str */
- Suff *single = NULL; /* Source of possible transformation to
- * null suffix */
-
- singleLn = NULL;
-
- /*
- * Loop looking first for a suffix that matches the start of the
- * string and then for one that exactly matches the rest of it. If
- * we can find two that meet these criteria, we've successfully
- * parsed the string.
- */
- srcLn = Lst_First(&sufflist);
- for (;;) {
- /* advance to next possible suffix */
- while (srcLn != NULL) {
- src = Lst_Datum(srcLn);
- if (strncmp(str, src->name, strlen(src->name)) == 0)
- break;
- srcLn = LST_NEXT(srcLn);
- }
-
- if (srcLn == NULL) {
- /*
- * Ran out of source suffixes -- no such rule
- */
- if (singleLn != NULL) {
- /*
- * Not so fast Mr. Smith! There was a suffix
- * that encompassed the entire string, so we
- * assume it was a transformation to the null
- * suffix (thank you POSIX). We still prefer to
- * find a double rule over a singleton, hence we
- * leave this check until the end.
- *
- * XXX: Use emptySuff over suffNull?
- */
- *srcPtr = single;
- *targPtr = suffNull;
- return (TRUE);
- }
- return (FALSE);
- }
- str2 = str + src->nameLen;
- if (*str2 == '\0') {
- single = src;
- singleLn = srcLn;
- } else {
-
- *targPtr = SuffSuffFind(str2);
- if (*targPtr != NULL) {
- *srcPtr = src;
- return (TRUE);
- }
- }
- /* next one */
- srcLn = LST_NEXT(srcLn);
- }
-}
-
-/*-
- *-----------------------------------------------------------------------
- * Suff_IsTransform --
- * Return TRUE if the given string is a transformation rule
- *
- *
- * Results:
- * TRUE if the string is a concatenation of two known suffixes.
- * FALSE otherwise
- *
- * Side Effects:
- * None
- *-----------------------------------------------------------------------
- */
-Boolean
-Suff_IsTransform(char *str)
-{
- Suff *src, *targ;
-
- return (SuffParseTransform(str, &src, &targ));
-}
-
-/*-
- *-----------------------------------------------------------------------
- * Suff_AddTransform --
- * Add the transformation rule described by the line to the
- * list of rules and place the transformation itself in the graph
- *
- * Results:
- * The node created for the transformation in the transforms list
- *
- * Side Effects:
- * The node is placed on the end of the transforms Lst and links are
- * made between the two suffixes mentioned in the target name
- *-----------------------------------------------------------------------
- */
-GNode *
-Suff_AddTransform(char *line)
-{
- GNode *gn; /* GNode of transformation rule */
- Suff *s; /* source suffix */
- Suff *t; /* target suffix */
-
- s = t = NULL; /* silence gcc */
- gn = SuffTransFind(line);
- if (gn == NULL) {
- /*
- * Make a new graph node for the transformation.
- * It will be filled in by the Parse module.
- */
- gn = Targ_NewGN(line);
- Lst_AtEnd(&transforms, gn);
- } else {
- /*
- * New specification for transformation rule. Just nuke the
- * old list of commands so they can be filled in again...
- * We don't actually free the commands themselves, because a
- * given command can be attached to several different
- * transformations.
- */
- Lst_Destroy(&gn->commands, NOFREE);
- Lst_Destroy(&gn->children, NOFREE);
- }
-
- gn->type = OP_TRANSFORM;
-
- SuffParseTransform(line, &s, &t);
-
- /*
- * link the two together in the proper relationship and order
- */
- DEBUGF(SUFF, ("defining transformation from `%s' to `%s'\n",
- s->name, t->name));
- SuffInsert(&t->children, s);
- SuffInsert(&s->parents, t);
-
- return (gn);
-}
-
-/*-
- *-----------------------------------------------------------------------
- * Suff_EndTransform --
- * Handle the finish of a transformation definition, removing the
- * transformation from the graph if it has neither commands nor
- * sources. This is called from the Parse module at the end of
- * a dependency block.
- *
- * Side Effects:
- * If the node has no commands or children, the children and parents
- * lists of the affected suffices are altered.
- *
- *-----------------------------------------------------------------------
- */
-void
-Suff_EndTransform(const GNode *gn)
-{
- Suff *s, *t;
-
- if (!Lst_IsEmpty(&gn->commands) || !Lst_IsEmpty(&gn->children)) {
- DEBUGF(SUFF, ("transformation %s complete\n", gn->name));
- return;
- }
-
- /*
- * SuffParseTransform() may fail for special rules which are not
- * actual transformation rules (e.g., .DEFAULT).
- */
- if (!SuffParseTransform(gn->name, &s, &t))
- return;
-
- DEBUGF(SUFF, ("deleting transformation from `%s' to `%s'\n",
- s->name, t->name));
-
- /*
- * Remove the source from the target's children list. We check
- * for a NULL return to handle a beanhead saying something like
- * .c.o .c.o:
- *
- * We'll be called twice when the next target is seen, but .c
- * and .o are only linked once...
- */
- SuffRemove(&t->children, s);
-
- /*
- * Remove the target from the source's parents list
- */
- SuffRemove(&s->parents, t);
-}
-
-/*-
- *-----------------------------------------------------------------------
- * SuffRebuildGraph --
- * Called from Suff_AddSuffix via LST_FOREACH to search through the
- * list of existing transformation rules and rebuild the transformation
- * graph when it has been destroyed by Suff_ClearSuffixes. If the
- * given rule is a transformation involving this suffix and another,
- * existing suffix, the proper relationship is established between
- * the two.
- *
- * Side Effects:
- * The appropriate links will be made between this suffix and
- * others if transformation rules exist for it.
- *
- *-----------------------------------------------------------------------
- */
-static void
-SuffRebuildGraph(const GNode *transform, Suff *s)
-{
- char *cp;
- Suff *s2 = NULL;
-
- /*
- * First see if it is a transformation from this suffix.
- */
- if (strncmp(transform->name, s->name, strlen(s->name)) == 0) {
- cp = transform->name + strlen(s->name);
-
- if (cp[0] == '\0') /* null rule */
- s2 = suffNull;
- else
- s2 = SuffSuffFind(cp);
- if (s2 != NULL) {
- /*
- * Found target. Link in and return, since it can't be
- * anything else.
- */
- SuffInsert(&s2->children, s);
- SuffInsert(&s->parents, s2);
- return;
- }
- }
-
- /*
- * Not from, maybe to?
- */
- cp = SuffSuffIsSuffix(s, transform->name);
- if (cp != NULL) {
- /*
- * Null-terminate the source suffix in order to find it.
- */
- cp[1] = '\0';
- s2 = SuffSuffFind(transform->name);
-
- /*
- * Replace the start of the target suffix
- */
- cp[1] = s->name[0];
- if (s2 != NULL) {
- /*
- * Found it -- establish the proper relationship
- */
- SuffInsert(&s->children, s2);
- SuffInsert(&s2->parents, s);
- }
- }
-}
-
-/*-
- *-----------------------------------------------------------------------
- * Suff_AddSuffix --
- * Add the suffix in string to the end of the list of known suffixes.
- * Should we restructure the suffix graph? Make doesn't...
- *
- * Results:
- * None
- *
- * Side Effects:
- * A GNode is created for the suffix and a Suff structure is created and
- * added to the suffixes list unless the suffix was already known.
- *-----------------------------------------------------------------------
- */
-void
-Suff_AddSuffix(char *str)
-{
- Suff *s; /* new suffix descriptor */
- LstNode *ln;
-
- if (SuffSuffFind(str) != NULL)
- /*
- * Already known
- */
- return;
-
- s = emalloc(sizeof(Suff));
-
- s->name = estrdup(str);
- s->nameLen = strlen(s->name);
- TAILQ_INIT(&s->searchPath);
- Lst_Init(&s->children);
- Lst_Init(&s->parents);
- Lst_Init(&s->ref);
- s->sNum = sNum++;
- s->flags = 0;
- s->refCount = 0;
-
- Lst_AtEnd(&sufflist, s);
-
- /*
- * Look for any existing transformations from or to this suffix.
- * XXX: Only do this after a Suff_ClearSuffixes?
- */
- LST_FOREACH(ln, &transforms)
- SuffRebuildGraph(Lst_Datum(ln), s);
-}
-
-/*-
- *-----------------------------------------------------------------------
- * Suff_GetPath --
- * Return the search path for the given suffix, if it's defined.
- *
- * Results:
- * The searchPath for the desired suffix or NULL if the suffix isn't
- * defined.
- *
- * Side Effects:
- * None
- *-----------------------------------------------------------------------
- */
-struct Path *
-Suff_GetPath(char *sname)
-{
- Suff *s;
-
- s = SuffSuffFind(sname);
- if (s == NULL)
- return (NULL);
- return (&s->searchPath);
-}
-
-/*-
- *-----------------------------------------------------------------------
- * Suff_DoPaths --
- * Extend the search paths for all suffixes to include the default
- * search path.
- *
- * Results:
- * None.
- *
- * Side Effects:
- * The searchPath field of all the suffixes is extended by the
- * directories in dirSearchPath. If paths were specified for the
- * ".h" suffix, the directories are stuffed into a global variable
- * called ".INCLUDES" with each directory preceded by a -I. The same
- * is done for the ".a" suffix, except the variable is called
- * ".LIBS" and the flag is -L.
- *-----------------------------------------------------------------------
- */
-void
-Suff_DoPaths(void)
-{
- Suff *s;
- LstNode *ln;
- char *ptr;
- struct Path inIncludes; /* Cumulative .INCLUDES path */
- struct Path inLibs; /* Cumulative .LIBS path */
-
- TAILQ_INIT(&inIncludes);
- TAILQ_INIT(&inLibs);
-
- for (ln = Lst_First(&sufflist); ln != NULL; ln = Lst_Succ(ln)) {
- s = Lst_Datum(ln);
-#ifdef INCLUDES
- if (s->flags & SUFF_INCLUDE) {
- Path_Concat(&inIncludes, &s->searchPath);
- }
-#endif /* INCLUDES */
-#ifdef LIBRARIES
- if (s->flags & SUFF_LIBRARY) {
- Path_Concat(&inLibs, &s->searchPath);
- }
-#endif /* LIBRARIES */
- Path_Concat(&s->searchPath, &dirSearchPath);
- }
-
- ptr = Path_MakeFlags("-I", &inIncludes);
- Var_SetGlobal(".INCLUDES", ptr);
- free(ptr);
-
- ptr = Path_MakeFlags("-L", &inLibs);
- Var_SetGlobal(".LIBS", ptr);
- free(ptr);
-
- Path_Clear(&inIncludes);
- Path_Clear(&inLibs);
-}
-
-/*-
- *-----------------------------------------------------------------------
- * Suff_AddInclude --
- * Add the given suffix as a type of file which gets included.
- * Called from the parse module when a .INCLUDES line is parsed.
- * The suffix must have already been defined.
- *
- * Results:
- * None.
- *
- * Side Effects:
- * The SUFF_INCLUDE bit is set in the suffix's flags field
- *
- *-----------------------------------------------------------------------
- */
-void
-Suff_AddInclude(char *sname)
-{
- Suff *s;
-
- if ((s = SuffSuffFind(sname)) != NULL)
- s->flags |= SUFF_INCLUDE;
-}
-
-/*-
- *-----------------------------------------------------------------------
- * Suff_AddLib --
- * Add the given suffix as a type of file which is a library.
- * Called from the parse module when parsing a .LIBS line. The
- * suffix must have been defined via .SUFFIXES before this is
- * called.
- *
- * Results:
- * None.
- *
- * Side Effects:
- * The SUFF_LIBRARY bit is set in the suffix's flags field
- *
- *-----------------------------------------------------------------------
- */
-void
-Suff_AddLib(char *sname)
-{
- Suff *s;
-
- if ((s = SuffSuffFind(sname)) != NULL)
- s->flags |= SUFF_LIBRARY;
-}
-
-/*
- * Create a new Src structure
- */
-static Src *
-SuffSrcCreate(char *file, char *prefix, Suff *suff, Src *parent, GNode *node)
-{
- Src *s;
-
- s = emalloc(sizeof(*s));
- s->file = file;
- s->pref = prefix;
- s->suff = suff;
- s->parent = parent;
- s->node = node;
- s->children = 0;
-
-#ifdef DEBUG_SRC
- Lst_Init(&s->cp);
-#endif
-
- return (s);
-}
-
- /********** Implicit Source Search Functions *********/
-
-/*-
- *-----------------------------------------------------------------------
- * SuffAddLevel --
- * Add all the children of targ as Src structures to the given list:
- * Add a suffix as a Src structure to the given list with its parent
- * being the given Src structure. If the suffix is the null suffix,
- * the prefix is used unaltered as the file name in the Src structure.
- *
- * Results:
- * None
- *
- * Side Effects:
- * Lots of structures are created and added to the list
- *-----------------------------------------------------------------------
- */
-static void
-SuffAddLevel(Lst *l, Src *targ)
-{
- LstNode *ln;
- Suff *suff;
- Src *s2;
-#ifdef DEBUG_SRC
- const LstNode *ln1;
-#endif
-
- LST_FOREACH(ln, &targ->suff->children) {
- suff = Lst_Datum(ln);
-
- if ((suff->flags & SUFF_NULL) && *suff->name != '\0') {
- /*
- * If the suffix has been marked as the NULL suffix,
- * also create a Src structure for a file with no suffix
- * attached. Two birds, and all that...
- */
- s2 = SuffSrcCreate(estrdup(targ->pref), targ->pref,
- suff, targ, NULL);
- suff->refCount++;
- targ->children += 1;
- Lst_AtEnd(l, s2);
-#ifdef DEBUG_SRC
- Lst_AtEnd(&targ->cp, s2);
- printf("1 add %p %p to %p:", targ, s2, l);
- LST_FOREACH(ln1, l)
- printf("%p ", (const void *)Lst_Datum(ln1));
- printf("\n");
-#endif
- }
- s2 = SuffSrcCreate(str_concat(targ->pref, suff->name, 0),
- targ->pref, suff, targ, NULL);
- suff->refCount++;
- targ->children += 1;
- Lst_AtEnd(l, s2);
-#ifdef DEBUG_SRC
- Lst_AtEnd(&targ->cp, s2);
- printf("2 add %p %p to %p:", targ, s2, l);
- LST_FOREACH(ln1, l)
- printf("%p ", (const void *)Lst_Datum(ln1));
- printf("\n");
-#endif
- }
-}
-
-/*-
- *----------------------------------------------------------------------
- * SuffRemoveSrc --
- * Free all src structures in list that don't have a reference count
- * XXX this actually frees only the first of these.
- *
- * Results:
- * True if a src was removed
- *
- * Side Effects:
- * The memory is free'd.
- *----------------------------------------------------------------------
- */
-static int
-SuffRemoveSrc(Lst *l)
-{
- LstNode *ln, *ln1;
- Src *s;
- int t = 0;
-
-#ifdef DEBUG_SRC
- printf("cleaning %lx: ", (unsigned long) l);
- LST_FOREACH(ln, l)
- printf("%p ", (const void *)Lst_Datum(ln));
- printf("\n");
-#endif
-
- for (ln = Lst_First(l); ln != NULL; ln = ln1) {
- ln1 = Lst_Succ(ln);
-
- s = (Src *)Lst_Datum(ln);
- if (s->children == 0) {
- free(s->file);
- if (!s->parent)
- free(s->pref);
- else {
-#ifdef DEBUG_SRC
- LstNode *ln = Lst_Member(&s->parent->cp, s);
- if (ln != NULL)
- Lst_Remove(&s->parent->cp, ln);
-#endif
- --s->parent->children;
- }
-#ifdef DEBUG_SRC
- printf("free: [l=%p] p=%p %d\n", l, s, s->children);
- Lst_Destroy(&s->cp, NOFREE);
-#endif
- Lst_Remove(l, ln);
- free(s);
- t |= 1;
- return (TRUE);
- }
-#ifdef DEBUG_SRC
- else {
- const LstNode *tln;
-
- printf("keep: [l=%p] p=%p %d: ", l, s, s->children);
- LST_FOREACH(tln, &s->cp)
- printf("%p ", (const void *)Lst_Datum(tln));
- printf("\n");
- }
-#endif
- }
-
- return (t);
-}
-
-/*-
- *-----------------------------------------------------------------------
- * SuffFindThem --
- * Find the first existing file/target in the list srcs
- *
- * Results:
- * The lowest structure in the chain of transformations
- *
- * Side Effects:
- * None
- *-----------------------------------------------------------------------
- */
-static Src *
-SuffFindThem(Lst *srcs, Lst *slst)
-{
- Src *s; /* current Src */
- Src *rs; /* returned Src */
- char *ptr;
-
- rs = NULL;
-
- while (!Lst_IsEmpty (srcs)) {
- s = Lst_DeQueue(srcs);
-
- DEBUGF(SUFF, ("\ttrying %s...", s->file));
-
- /*
- * A file is considered to exist if either a node exists in the
- * graph for it or the file actually exists.
- */
- if (Targ_FindNode(s->file, TARG_NOCREATE) != NULL) {
-#ifdef DEBUG_SRC
- printf("remove %p from %p\n", s, srcs);
-#endif
- rs = s;
- break;
- }
-
- if ((ptr = Path_FindFile(s->file,
- &s->suff->searchPath)) != NULL) {
- rs = s;
-#ifdef DEBUG_SRC
- printf("remove %p from %p\n", s, srcs);
-#endif
- free(ptr);
- break;
- }
-
- DEBUGF(SUFF, ("not there\n"));
-
- SuffAddLevel(srcs, s);
- Lst_AtEnd(slst, s);
- }
-
- if (rs) {
- DEBUGF(SUFF, ("got it\n"));
- }
- return (rs);
-}
-
-/*-
- *-----------------------------------------------------------------------
- * SuffFindCmds --
- * See if any of the children of the target in the Src structure is
- * one from which the target can be transformed. If there is one,
- * a Src structure is put together for it and returned.
- *
- * Results:
- * The Src structure of the "winning" child, or NULL if no such beast.
- *
- * Side Effects:
- * A Src structure may be allocated.
- *
- *-----------------------------------------------------------------------
- */
-static Src *
-SuffFindCmds(Src *targ, Lst *slst)
-{
- LstNode *ln; /* General-purpose list node */
- GNode *t; /* Target GNode */
- GNode *s; /* Source GNode */
- int prefLen;/* The length of the defined prefix */
- Suff *suff; /* Suffix on matching beastie */
- Src *ret; /* Return value */
- char *cp;
-
- t = targ->node;
- prefLen = strlen(targ->pref);
-
- for (ln = Lst_First(&t->children); ln != NULL; ln = Lst_Succ(ln)) {
- s = Lst_Datum(ln);
-
- cp = strrchr(s->name, '/');
- if (cp == NULL) {
- cp = s->name;
- } else {
- cp++;
- }
- if (strncmp(cp, targ->pref, prefLen) == 0) {
- /*
- * The node matches the prefix ok, see if it has
- * a known suffix.
- */
- suff = SuffSuffFind(&cp[prefLen]);
- if (suff != NULL) {
- /*
- * It even has a known suffix, see if there's
- * a transformation defined between the node's
- * suffix and the target's suffix.
- *
- * XXX: Handle multi-stage transformations
- * here, too.
- */
- if (Lst_Member(&suff->parents,
- targ->suff) != NULL) {
- /*
- * Hot Damn! Create a new Src structure
- * to describe this transformation
- * (making sure to duplicate the
- * source node's name so Suff_FindDeps
- * can free it again (ick)), and return
- * the new structure.
- */
- ret = SuffSrcCreate(estrdup(s->name),
- targ->pref, suff, targ, s);
- suff->refCount++;
- targ->children += 1;
-#ifdef DEBUG_SRC
- printf("3 add %p %p\n", &targ, ret);
- Lst_AtEnd(&targ->cp, ret);
-#endif
- Lst_AtEnd(slst, ret);
- DEBUGF(SUFF, ("\tusing existing source "
- "%s\n", s->name));
- return (ret);
- }
- }
- }
- }
- return (NULL);
-}
-
-/*-
- * The child node contains variable references. Expand them and return
- * a list of expansions.
- */
-static void
-SuffExpandVariables(GNode *parent, GNode *child, Lst *members)
-{
- Buffer *buf;
- char *cp;
- char *start;
-
- Lst_Init(members);
-
- DEBUGF(SUFF, ("Expanding \"%s\"...", child->name));
- buf = Var_Subst(child->name, parent, TRUE);
- cp = Buf_Data(buf);
-
- if (child->type & OP_ARCHV) {
- /*
- * Node was an archive(member) target, so we
- * want to call on the Arch module to find the
- * nodes for us, expanding variables in the
- * parent's context.
- */
- Arch_ParseArchive(&cp, members, parent);
- Buf_Destroy(buf, TRUE);
- return;
- }
- /*
- * Break the result into a vector of strings whose nodes we can find,
- * then add those nodes to the members list. Unfortunately, we can't use
- * brk_string b/c it doesn't understand about variable specifications
- * with spaces in them... XXX
- */
- for (start = cp; *start == ' ' || *start == '\t'; start++)
- ;
-
- for (cp = start; *cp != '\0'; cp++) {
- if (*cp == ' ' || *cp == '\t') {
- /*
- * White-space -- terminate element, find the node,
- * add it, skip any further spaces.
- */
- *cp++ = '\0';
- Lst_AtEnd(members, Targ_FindNode(start, TARG_CREATE));
-
- while (*cp == ' ' || *cp == '\t') {
- cp++;
- }
- /*
- * Adjust cp for increment at
- * start of loop, but set start
- * to first non-space.
- */
- start = cp--;
-
- } else if (*cp == '$') {
- /*
- * Start of a variable spec -- contact variable module
- * to find the end so we can skip over it.
- */
- char *junk;
- size_t len = 0;
- Boolean doFree;
-
- junk = Var_Parse(cp, parent, TRUE, &len, &doFree);
- if (junk != var_Error) {
- cp += len - 1;
- }
- if (doFree) {
- free(junk);
- }
-
- } else if (*cp == '\\' && *cp != '\0') {
- /*
- * Escaped something -- skip over it
- */
- cp++;
- }
- }
-
- if (cp != start) {
- /*
- * Stuff left over -- add it to the
- * list too
- */
- Lst_AtEnd(members, Targ_FindNode(start, TARG_CREATE));
- }
-
- Buf_Destroy(buf, TRUE);
-}
-
-/*-
- * The child node contains wildcards. Expand them and return a list of
- * expansions.
- */
-static void
-SuffExpandWildcards(GNode *child, Lst *members)
-{
- char *cp;
- Lst exp; /* List of expansions */
- LstNode *ln;
- struct Path *path; /* Search path along which to expand */
-
- Lst_Init(members);
-
- /*
- * Find a path along which to expand the word.
- *
- * If the word has a known suffix, use that path.
- * If it has no known suffix and we're allowed to use the null
- * suffix, use its path.
- * Else use the default system search path.
- */
- LST_FOREACH(ln, &sufflist) {
- if (SuffSuffIsSuffix(Lst_Datum(ln), child->name) != NULL)
- break;
- }
-
- DEBUGF(SUFF, ("Wildcard expanding \"%s\"...", child->name));
-
- if (ln != NULL) {
- Suff *s = Lst_Datum(ln);
-
- DEBUGF(SUFF, ("suffix is \"%s\"...", s->name));
- path = &s->searchPath;
- } else {
- /*
- * Use default search path
- */
- path = &dirSearchPath;
- }
-
- /*
- * Expand the word along the chosen path
- */
- Lst_Init(&exp);
- Path_Expand(child->name, path, &exp);
-
- while (!Lst_IsEmpty(&exp)) {
- /*
- * Fetch next expansion off the list and find its GNode
- */
- cp = Lst_DeQueue(&exp);
-
- DEBUGF(SUFF, ("%s...", cp));
- Lst_AtEnd(members, Targ_FindNode(cp, TARG_CREATE));
- }
-}
-
-/*-
- *-----------------------------------------------------------------------
- * SuffExpandChildren --
- * Expand the names of any children of a given node that contain
- * variable invocations or file wildcards into actual targets.
- *
- * Results:
- * == 0 (continue)
- *
- * Side Effects:
- * The expanded node is removed from the parent's list of children,
- * and the parent's unmade counter is decremented, but other nodes
- * may be added.
- *
- *-----------------------------------------------------------------------
- */
-static void
-SuffExpandChildren(GNode *parent, LstNode *current)
-{
- GNode *cchild; /* current child */
- GNode *gn;
- LstNode *prev; /* node after which to append new source */
- Lst members; /* expanded nodes */
-
- if (current == NULL) {
- /* start from begin of parent's children list */
- current = Lst_First(&parent->children);
- }
-
- while (current != NULL) {
- cchild = Lst_Datum(current);
-
- /*
- * First do variable expansion -- this takes precedence over
- * wildcard expansion. If the result contains wildcards, they'll
- * be gotten to later since the resulting words are tacked
- * instead of the current child onto the children list.
- *
- * XXXHB what if cchild contains lib.a(t1.o t2.o t3.o) but
- * no $?
- */
- if (strchr(cchild->name, '$') != NULL) {
- SuffExpandVariables(parent, cchild, &members);
-
- } else if (Dir_HasWildcards(cchild->name)) {
- SuffExpandWildcards(cchild, &members);
-
- } else {
- /* nothing special just advance to next child */
- current = LST_NEXT(current);
- continue;
- }
-
- /*
- * New nodes effectively take the place of the child,
- * so place them after the child
- */
- prev = current;
-
- /*
- * Add all new elements to the parent node if they aren't
- * already children of it.
- */
- while(!Lst_IsEmpty(&members)) {
- gn = Lst_DeQueue(&members);
-
- DEBUGF(SUFF, ("%s...", gn->name));
- if (Lst_Member(&parent->children, gn) == NULL) {
- Lst_Append(&parent->children, prev, gn);
- prev = Lst_Succ(prev);
- Lst_AtEnd(&gn->parents, parent);
- parent->unmade++;
- }
- }
-
- /*
- * Now the source is expanded, remove it from the list
- * of children to keep it from being processed.
- * Advance to the next child.
- */
- prev = current;
- current = LST_NEXT(current);
-
- parent->unmade--;
- Lst_Remove(&parent->children, prev);
- DEBUGF(SUFF, ("\n"));
- }
-}
-
-/*-
- *-----------------------------------------------------------------------
- * SuffApplyTransform --
- * Apply a transformation rule, given the source and target nodes
- * and suffixes.
- *
- * Results:
- * TRUE if successful, FALSE if not.
- *
- * Side Effects:
- * The source and target are linked and the commands from the
- * transformation are added to the target node's commands list.
- * All attributes but OP_DEPMASK and OP_TRANSFORM are applied
- * to the target. The target also inherits all the sources for
- * the transformation rule.
- *
- *-----------------------------------------------------------------------
- */
-static Boolean
-SuffApplyTransform(GNode *tGn, GNode *sGn, Suff *t, Suff *s)
-{
- LstNode *ln; /* General node */
- char *tname; /* Name of transformation rule */
- GNode *gn; /* Node for same */
-
- if (Lst_Member(&tGn->children, sGn) == NULL) {
- /*
- * Not already linked, so form the proper links between the
- * target and source.
- */
- Lst_AtEnd(&tGn->children, sGn);
- Lst_AtEnd(&sGn->parents, tGn);
- tGn->unmade += 1;
- }
-
- if ((sGn->type & OP_OPMASK) == OP_DOUBLEDEP) {
- /*
- * When a :: node is used as the implied source of a node,
- * we have to link all its cohorts in as sources as well. Only
- * the initial sGn gets the target in its iParents list, however
- * as that will be sufficient to get the .IMPSRC variable set
- * for tGn
- */
- for (ln = Lst_First(&sGn->cohorts); ln != NULL;
- ln = Lst_Succ(ln)) {
- gn = Lst_Datum(ln);
-
- if (Lst_Member(&tGn->children, gn) == NULL) {
- /*
- * Not already linked, so form the proper
- * links between the target and source.
- */
- Lst_AtEnd(&tGn->children, gn);
- Lst_AtEnd(&gn->parents, tGn);
- tGn->unmade += 1;
- }
- }
- }
- /*
- * Locate the transformation rule itself
- */
- tname = str_concat(s->name, t->name, 0);
- gn = SuffTransFind(tname);
- free(tname);
-
- if (gn == NULL) {
- /*
- * Not really such a transformation rule (can happen when we're
- * called to link an OP_MEMBER and OP_ARCHV node), so return
- * FALSE.
- */
- return (FALSE);
- }
-
- DEBUGF(SUFF, ("\tapplying %s -> %s to \"%s\"\n",
- s->name, t->name, tGn->name));
-
- /*
- * Record last child for expansion purposes
- */
- ln = Lst_Last(&tGn->children);
-
- /*
- * Pass the buck to Make_HandleUse to apply the rule
- */
- Make_HandleUse(gn, tGn);
-
- /*
- * Deal with wildcards and variables in any acquired sources
- */
- ln = Lst_Succ(ln);
- if (ln != NULL) {
- SuffExpandChildren(tGn, ln);
- }
-
- /*
- * Keep track of another parent to which this beast is transformed so
- * the .IMPSRC variable can be set correctly for the parent.
- */
- Lst_AtEnd(&sGn->iParents, tGn);
-
- return (TRUE);
-}
-
-
-/*-
- *-----------------------------------------------------------------------
- * SuffFindArchiveDeps --
- * Locate dependencies for an OP_ARCHV node.
- *
- * Results:
- * None
- *
- * Side Effects:
- * Same as Suff_FindDeps
- *
- *-----------------------------------------------------------------------
- */
-static void
-SuffFindArchiveDeps(GNode *gn, Lst *slst)
-{
- char *eoarch; /* End of archive portion */
- char *eoname; /* End of member portion */
- char *name; /* Start of member's name */
- GNode *mem; /* Node for member */
- Suff *ms; /* Suffix descriptor for member */
-
- static const char *copy[] = {
- TARGET, /* Must be first */
- PREFIX, /* Must be second */
- };
-
- /*
- * The node is an archive(member) pair. so we must find a
- * suffix for both of them.
- */
- eoarch = strchr(gn->name, '(');
- eoname = strchr(eoarch, ')');
-
- *eoname = '\0'; /* Nuke parentheses during suffix search */
- *eoarch = '\0'; /* So a suffix can be found */
-
- name = eoarch + 1;
-
- /*
- * To simplify things, call Suff_FindDeps recursively on the member now,
- * so we can simply compare the member's .PREFIX and .TARGET variables
- * to locate its suffix. This allows us to figure out the suffix to
- * use for the archive without having to do a quadratic search over the
- * suffix list, backtracking for each one...
- */
- mem = Targ_FindNode(name, TARG_CREATE);
- SuffFindDeps(mem, slst);
-
- /*
- * Create the link between the two nodes right off
- */
- if (Lst_Member(&gn->children, mem) == NULL) {
- Lst_AtEnd(&gn->children, mem);
- Lst_AtEnd(&mem->parents, gn);
- gn->unmade += 1;
- }
-
- /*
- * Copy in the variables from the member node to this one.
- */
- Var_Set(copy[1], Var_Value(copy[1], mem), gn);
- Var_Set(copy[0], Var_Value(copy[0], mem), gn);
-
- ms = mem->suffix;
- if (ms == NULL) {
- /*
- * Didn't know what it was -- use .NULL suffix if not in
- * make mode
- */
- DEBUGF(SUFF, ("using null suffix\n"));
- ms = suffNull;
- }
-
- /*
- * Set the other two local variables required for this target.
- */
- Var_Set(MEMBER, name, gn);
- Var_Set(ARCHIVE, gn->name, gn);
-
- if (ms != NULL) {
- /*
- * Member has a known suffix, so look for a transformation rule
- * from it to a possible suffix of the archive. Rather than
- * searching through the entire list, we just look at suffixes
- * to which the member's suffix may be transformed...
- */
- LstNode *ln;
-
- /*
- * Use first matching suffix...
- */
- LST_FOREACH(ln, &ms->parents) {
- if (SuffSuffIsSuffix(Lst_Datum(ln), gn->name) != NULL)
- break;
- }
-
- if (ln != NULL) {
- /*
- * Got one -- apply it
- */
- if (!SuffApplyTransform(gn, mem, Lst_Datum(ln), ms)) {
- DEBUGF(SUFF, ("\tNo transformation from "
- "%s -> %s\n", ms->name,
- ((Suff *)Lst_Datum(ln))->name));
- }
- }
- }
-
- /*
- * Replace the opening and closing parens now we've no need
- * of the separate pieces.
- */
- *eoarch = '(';
- *eoname = ')';
-
- /*
- * Pretend gn appeared to the left of a dependency operator so
- * the user needn't provide a transformation from the member to the
- * archive.
- */
- if (OP_NOP(gn->type)) {
- gn->type |= OP_DEPENDS;
- }
-
- /*
- * Flag the member as such so we remember to look in the archive for
- * its modification time.
- */
- mem->type |= OP_MEMBER;
-}
-
-/*-
- *-----------------------------------------------------------------------
- * SuffFindNormalDeps --
- * Locate implicit dependencies for regular targets.
- *
- * Results:
- * None.
- *
- * Side Effects:
- * Same as Suff_FindDeps...
- *
- *-----------------------------------------------------------------------
- */
-static void
-SuffFindNormalDeps(GNode *gn, Lst *slst)
-{
- char *eoname; /* End of name */
- char *sopref; /* Start of prefix */
- LstNode *ln; /* Next suffix node to check */
- Lst srcs; /* List of sources at which to look */
- Lst targs; /* List of targets to which things can be
- * transformed. They all have the same file,
- * but different suff and pref fields */
- Src *bottom; /* Start of found transformation path */
- Src *src; /* General Src pointer */
- char *pref; /* Prefix to use */
- Src *targ; /* General Src target pointer */
-
- eoname = gn->name + strlen(gn->name);
- sopref = gn->name;
-
- /*
- * Begin at the beginning...
- */
- ln = Lst_First(&sufflist);
- Lst_Init(&srcs);
- Lst_Init(&targs);
-
- /*
- * We're caught in a catch-22 here. On the one hand, we want to use any
- * transformation implied by the target's sources, but we can't examine
- * the sources until we've expanded any variables/wildcards they may
- * hold, and we can't do that until we've set up the target's local
- * variables and we can't do that until we know what the proper suffix
- * for the target is (in case there are two suffixes one of which is a
- * suffix of the other) and we can't know that until we've found its
- * implied source, which we may not want to use if there's an existing
- * source that implies a different transformation.
- *
- * In an attempt to get around this, which may not work all the time,
- * but should work most of the time, we look for implied sources first,
- * checking transformations to all possible suffixes of the target,
- * use what we find to set the target's local variables, expand the
- * children, then look for any overriding transformations they imply.
- * Should we find one, we discard the one we found before.
- */
-
- while (ln != NULL) {
- /*
- * Look for next possible suffix...
- */
- while (ln != NULL) {
- if (SuffSuffIsSuffix(Lst_Datum(ln), gn->name) != NULL)
- break;
- ln = LST_NEXT(ln);
- }
-
- if (ln != NULL) {
- int prefLen; /* Length of the prefix */
- Src *target;
-
- /*
- * Allocate a Src structure to which things can be
- * transformed
- */
- target = SuffSrcCreate(estrdup(gn->name), NULL,
- Lst_Datum(ln), NULL, gn);
- target->suff->refCount++;
-
- /*
- * Allocate room for the prefix, whose end is found
- * by subtracting the length of the suffix from
- * the end of the name.
- */
- prefLen = (eoname - target->suff->nameLen) - sopref;
- assert(prefLen >= 0);
- target->pref = emalloc(prefLen + 1);
- memcpy(target->pref, sopref, prefLen);
- target->pref[prefLen] = '\0';
-
- /*
- * Add nodes from which the target can be made
- */
- SuffAddLevel(&srcs, target);
-
- /*
- * Record the target so we can nuke it
- */
- Lst_AtEnd(&targs, target);
-
- /*
- * Search from this suffix's successor...
- */
- ln = Lst_Succ(ln);
- }
- }
-
- /*
- * Handle target of unknown suffix...
- */
- if (Lst_IsEmpty(&targs) && suffNull != NULL) {
- DEBUGF(SUFF, ("\tNo known suffix on %s. Using .NULL suffix\n",
- gn->name));
-
- targ = SuffSrcCreate(estrdup(gn->name), estrdup(sopref),
- suffNull, NULL, gn);
- targ->suff->refCount++;
-
- /*
- * Only use the default suffix rules if we don't have commands
- * or dependencies defined for this gnode
- */
- if (Lst_IsEmpty(&gn->commands) && Lst_IsEmpty(&gn->children))
- SuffAddLevel(&srcs, targ);
- else {
- DEBUGF(SUFF, ("not "));
- }
-
- DEBUGF(SUFF, ("adding suffix rules\n"));
-
- Lst_AtEnd(&targs, targ);
- }
-
- /*
- * Using the list of possible sources built up from the target
- * suffix(es), try and find an existing file/target that matches.
- */
- bottom = SuffFindThem(&srcs, slst);
-
- if (bottom == NULL) {
- /*
- * No known transformations -- use the first suffix found for
- * setting the local variables.
- */
- if (!Lst_IsEmpty(&targs)) {
- targ = Lst_Datum(Lst_First(&targs));
- } else {
- targ = NULL;
- }
- } else {
- /*
- * Work up the transformation path to find the suffix of the
- * target to which the transformation was made.
- */
- for (targ = bottom; targ->parent != NULL; targ = targ->parent)
- continue;
- }
-
- /*
- * The .TARGET variable we always set to be the name at this point,
- * since it's only set to the path if the thing is only a source and
- * if it's only a source, it doesn't matter what we put here as far
- * as expanding sources is concerned, since it has none...
- */
- Var_Set(TARGET, gn->name, gn);
-
- pref = (targ != NULL) ? targ->pref : gn->name;
- Var_Set(PREFIX, pref, gn);
-
- /*
- * Now we've got the important local variables set, expand any sources
- * that still contain variables or wildcards in their names.
- */
- SuffExpandChildren(gn, NULL);
-
- if (targ == NULL) {
- DEBUGF(SUFF, ("\tNo valid suffix on %s\n", gn->name));
-
- sfnd_abort:
- /*
- * Deal with finding the thing on the default search path if the
- * node is only a source (not on the lhs of a dependency
- * operator or [XXX] it has neither children or commands).
- */
- if (OP_NOP(gn->type) || (Lst_IsEmpty(&gn->children) &&
- Lst_IsEmpty(&gn->commands))) {
- gn->path = Path_FindFile(gn->name,
- (targ == NULL ? &dirSearchPath :
- &targ->suff->searchPath));
- if (gn->path != NULL) {
- char *ptr;
- Var_Set(TARGET, gn->path, gn);
-
- if (targ != NULL) {
- /*
- * Suffix known for the thing -- trim
- * the suffix off the path to form the
- * proper .PREFIX variable.
- */
- int savep = strlen(gn->path) -
- targ->suff->nameLen;
- char savec;
-
- if (gn->suffix)
- gn->suffix->refCount--;
- gn->suffix = targ->suff;
- gn->suffix->refCount++;
-
- savec = gn->path[savep];
- gn->path[savep] = '\0';
-
- if ((ptr = strrchr(gn->path, '/')) != NULL)
- ptr++;
- else
- ptr = gn->path;
-
- Var_Set(PREFIX, ptr, gn);
-
- gn->path[savep] = savec;
- } else {
- /*
- * The .PREFIX gets the full path if
- * the target has no known suffix.
- */
- if (gn->suffix)
- gn->suffix->refCount--;
- gn->suffix = NULL;
-
- if ((ptr = strrchr(gn->path, '/')) != NULL)
- ptr++;
- else
- ptr = gn->path;
-
- Var_Set(PREFIX, ptr, gn);
- }
- }
- } else {
- /*
- * Not appropriate to search for the thing -- set the
- * path to be the name so Dir_MTime won't go
- * grovelling for it.
- */
- if (gn->suffix)
- gn->suffix->refCount--;
- gn->suffix = (targ == NULL) ? NULL : targ->suff;
- if (gn->suffix)
- gn->suffix->refCount++;
- free(gn->path);
- gn->path = estrdup(gn->name);
- }
-
- goto sfnd_return;
- }
-
- /*
- * If the suffix indicates that the target is a library, mark that in
- * the node's type field.
- */
- if (targ->suff->flags & SUFF_LIBRARY) {
- gn->type |= OP_LIB;
- }
-
- /*
- * Check for overriding transformation rule implied by sources
- */
- if (!Lst_IsEmpty(&gn->children)) {
- src = SuffFindCmds(targ, slst);
-
- if (src != NULL) {
- /*
- * Free up all the Src structures in the
- * transformation path up to, but not including,
- * the parent node.
- */
- while (bottom && bottom->parent != NULL) {
- if (Lst_Member(slst, bottom) == NULL) {
- Lst_AtEnd(slst, bottom);
- }
- bottom = bottom->parent;
- }
- bottom = src;
- }
- }
-
- if (bottom == NULL) {
- /*
- * No idea from where it can come -- return now.
- */
- goto sfnd_abort;
- }
-
- /*
- * We now have a list of Src structures headed by 'bottom' and linked
- * via their 'parent' pointers. What we do next is create links between
- * source and target nodes (which may or may not have been created)
- * and set the necessary local variables in each target. The
- * commands for each target are set from the commands of the
- * transformation rule used to get from the src suffix to the targ
- * suffix. Note that this causes the commands list of the original
- * node, gn, to be replaced by the commands of the final
- * transformation rule. Also, the unmade field of gn is incremented.
- * Etc.
- */
- if (bottom->node == NULL) {
- bottom->node = Targ_FindNode(bottom->file, TARG_CREATE);
- }
-
- for (src = bottom; src->parent != NULL; src = src->parent) {
- targ = src->parent;
-
- if (src->node->suffix)
- src->node->suffix->refCount--;
- src->node->suffix = src->suff;
- src->node->suffix->refCount++;
-
- if (targ->node == NULL) {
- targ->node = Targ_FindNode(targ->file, TARG_CREATE);
- }
-
- SuffApplyTransform(targ->node, src->node,
- targ->suff, src->suff);
-
- if (targ->node != gn) {
- /*
- * Finish off the dependency-search process for any
- * nodes between bottom and gn (no point in questing
- * around the filesystem for their implicit source
- * when it's already known). Note that the node can't
- * have any sources that need expanding, since
- * SuffFindThem will stop on an existing
- * node, so all we need to do is set the standard and
- * System V variables.
- */
- targ->node->type |= OP_DEPS_FOUND;
-
- Var_Set(PREFIX, targ->pref, targ->node);
- Var_Set(TARGET, targ->node->name, targ->node);
- }
- }
-
- if (gn->suffix)
- gn->suffix->refCount--;
- gn->suffix = src->suff;
- gn->suffix->refCount++;
-
- /*
- * So Dir_MTime doesn't go questing for it...
- */
- free(gn->path);
- gn->path = estrdup(gn->name);
-
- /*
- * Nuke the transformation path and the Src structures left over in the
- * two lists.
- */
- sfnd_return:
- if (bottom)
- if (Lst_Member(slst, bottom) == NULL)
- Lst_AtEnd(slst, bottom);
-
- while (SuffRemoveSrc(&srcs) || SuffRemoveSrc(&targs))
- continue;
-
- Lst_Concat(slst, &srcs, LST_CONCLINK);
- Lst_Concat(slst, &targs, LST_CONCLINK);
-}
-
-/*-
- *-----------------------------------------------------------------------
- * Suff_FindDeps --
- * Find implicit sources for the target described by the graph node
- * gn
- *
- * Results:
- * Nothing.
- *
- * Side Effects:
- * Nodes are added to the graph below the passed-in node. The nodes
- * are marked to have their IMPSRC variable filled in. The
- * PREFIX variable is set for the given node and all its
- * implied children.
- *
- * Notes:
- * The path found by this target is the shortest path in the
- * transformation graph, which may pass through non-existent targets,
- * to an existing target. The search continues on all paths from the
- * root suffix until a file is found. I.e. if there's a path
- * .o -> .c -> .l -> .l,v from the root and the .l,v file exists but
- * the .c and .l files don't, the search will branch out in
- * all directions from .o and again from all the nodes on the
- * next level until the .l,v node is encountered.
- *
- *-----------------------------------------------------------------------
- */
-void
-Suff_FindDeps(GNode *gn)
-{
-
- SuffFindDeps(gn, &srclist);
- while (SuffRemoveSrc(&srclist))
- continue;
-}
-
-
-static void
-SuffFindDeps(GNode *gn, Lst *slst)
-{
-
- if (gn->type & OP_DEPS_FOUND) {
- /*
- * If dependencies already found, no need to do it again...
- */
- return;
- } else {
- gn->type |= OP_DEPS_FOUND;
- }
-
- DEBUGF(SUFF, ("SuffFindDeps (%s)\n", gn->name));
-
- if (gn->type & OP_ARCHV) {
- SuffFindArchiveDeps(gn, slst);
-
- } else if (gn->type & OP_LIB) {
- /*
- * If the node is a library, it is the arch module's job to find
- * it and set the TARGET variable accordingly. We merely provide
- * the search path, assuming all libraries end in ".a" (if the
- * suffix hasn't been defined, there's nothing we can do for it,
- * so we just set the TARGET variable to the node's name in order
- * to give it a value).
- */
- Suff *s;
-
- s = SuffSuffFind(LIBSUFF);
- if (gn->suffix)
- gn->suffix->refCount--;
- if (s != NULL) {
- gn->suffix = s;
- gn->suffix->refCount++;
- Arch_FindLib(gn, &s->searchPath);
- } else {
- gn->suffix = NULL;
- Var_Set(TARGET, gn->name, gn);
- }
-
- /*
- * Because a library (-lfoo) target doesn't follow the standard
- * filesystem conventions, we don't set the regular variables for
- * the thing. .PREFIX is simply made empty...
- */
- Var_Set(PREFIX, "", gn);
-
- } else {
- SuffFindNormalDeps(gn, slst);
- }
-}
-
-/*-
- *-----------------------------------------------------------------------
- * Suff_SetNull --
- * Define which suffix is the null suffix.
- *
- * Results:
- * None.
- *
- * Side Effects:
- * 'suffNull' is altered.
- *
- * Notes:
- * Need to handle the changing of the null suffix gracefully so the
- * old transformation rules don't just go away.
- *
- *-----------------------------------------------------------------------
- */
-void
-Suff_SetNull(char *name)
-{
- Suff *s;
-
- if ((s = SuffSuffFind(name)) == NULL) {
- Parse_Error(PARSE_WARNING, "Desired null suffix %s "
- "not defined.", name);
- return;
- }
-
- if (suffNull != NULL) {
- suffNull->flags &= ~SUFF_NULL;
- }
- s->flags |= SUFF_NULL;
-
- /*
- * XXX: Here's where the transformation mangling
- * would take place
- */
- suffNull = s;
-}
-
-/*-
- *-----------------------------------------------------------------------
- * Suff_Init --
- * Initialize suffixes module
- *
- * Results:
- * None
- *
- * Side Effects:
- * Many
- *-----------------------------------------------------------------------
- */
-void
-Suff_Init(void)
-{
-
- sNum = 0;
- /*
- * Create null suffix for single-suffix rules (POSIX). The thing doesn't
- * actually go on the suffix list or everyone will think that's its
- * suffix.
- */
- emptySuff = suffNull = emalloc(sizeof(Suff));
-
- suffNull->name = estrdup("");
- suffNull->nameLen = 0;
- TAILQ_INIT(&suffNull->searchPath);
- Path_Concat(&suffNull->searchPath, &dirSearchPath);
- Lst_Init(&suffNull->children);
- Lst_Init(&suffNull->parents);
- Lst_Init(&suffNull->ref);
- suffNull->sNum = sNum++;
- suffNull->flags = SUFF_NULL;
- suffNull->refCount = 1;
-}
-
-/********************* DEBUGGING FUNCTIONS **********************/
-
-void
-Suff_PrintAll(void)
-{
- const LstNode *ln;
- const LstNode *tln;
- const GNode *gn;
- const Suff *s;
-
- static const struct flag2str suff_flags[] = {
- { SUFF_INCLUDE, "INCLUDE" },
- { SUFF_LIBRARY, "LIBRARY" },
- { SUFF_NULL, "NULL" },
- { 0, NULL }
- };
-
- printf("#*** Suffixes:\n");
- LST_FOREACH(ln, &sufflist) {
- s = Lst_Datum(ln);
- printf("# `%s' [%d] ", s->name, s->refCount);
-
- if (s->flags != 0) {
- printf(" ");
- print_flags(stdout, suff_flags, s->flags, 1);
- }
-
- printf("\n#\tTo: ");
- LST_FOREACH(tln, &s->parents)
- printf("`%s' ", ((const Suff *)Lst_Datum(tln))->name);
-
- printf("\n#\tFrom: ");
- LST_FOREACH(tln, &s->children)
- printf("`%s' ", ((const Suff *)Lst_Datum(tln))->name);
-
- printf("\n#\tSearch Path: ");
- Path_Print(&s->searchPath);
-
- printf("\n");
- }
-
- printf("#*** Transformations:\n");
- LST_FOREACH(ln, &transforms) {
- gn = Lst_Datum(ln);
- printf("%-16s: ", gn->name);
- Targ_PrintType(gn->type);
- printf("\n");
- LST_FOREACH(tln, &gn->commands)
- printf("\t%s\n", (const char *)Lst_Datum(tln));
- printf("\n");
- }
-}
diff --git a/usr.bin/make/suff.h b/usr.bin/make/suff.h
deleted file mode 100644
index 9982ab4..0000000
--- a/usr.bin/make/suff.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*-
- * Copyright (c) 1988, 1989, 1990, 1993
- * The Regents of the University of California. All rights reserved.
- * Copyright (c) 1989 by Berkeley Softworks
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Adam de Boor.
- *
- * 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.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
- *
- * $FreeBSD$
- */
-
-#ifndef suff_h_2d5a821c
-#define suff_h_2d5a821c
-
-struct GNode;
-struct Path;
-
-void Suff_ClearSuffixes(void);
-Boolean Suff_IsTransform(char *);
-struct GNode *Suff_AddTransform(char *);
-void Suff_EndTransform(const struct GNode *);
-void Suff_AddSuffix(char *);
-struct Path *Suff_GetPath(char *);
-void Suff_DoPaths(void);
-void Suff_AddInclude(char *);
-void Suff_AddLib(char *);
-void Suff_FindDeps(struct GNode *);
-void Suff_SetNull(char *);
-void Suff_Init(void);
-void Suff_PrintAll(void);
-
-#endif /* suff_h_2d5a821c */
diff --git a/usr.bin/make/targ.c b/usr.bin/make/targ.c
deleted file mode 100644
index 75ced89..0000000
--- a/usr.bin/make/targ.c
+++ /dev/null
@@ -1,472 +0,0 @@
-/*-
- * Copyright (c) 1988, 1989, 1990, 1993
- * The Regents of the University of California. All rights reserved.
- * Copyright (c) 1989 by Berkeley Softworks
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Adam de Boor.
- *
- * 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.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
- *
- * @(#)targ.c 8.2 (Berkeley) 3/19/94
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-/*
- * Functions for maintaining the Lst allTargets. Target nodes are
- * kept in two structures: a Lst, maintained by the list library, and a
- * hash table, maintained by the hash library.
- *
- * Interface:
- * Targ_Init Initialization procedure.
- *
- * Targ_NewGN Create a new GNode for the passed target (string).
- * The node is *not* placed in the hash table, though all
- * its fields are initialized.
- *
- * Targ_FindNode Find the node for a given target, creating and storing
- * it if it doesn't exist and the flags are right
- * (TARG_CREATE)
- *
- * Targ_FindList Given a list of names, find nodes for all of them. If a
- * name doesn't exist and the TARG_NOCREATE flag was given,
- * an error message is printed. Else, if a name doesn't
- * exist, its node is created.
- *
- * Targ_Ignore Return TRUE if errors should be ignored when creating
- * the given target.
- *
- * Targ_Silent Return TRUE if we should be silent when creating the
- * given target.
- *
- * Targ_Precious Return TRUE if the target is precious and should not
- * be removed if we are interrupted.
- *
- * Debugging:
- * Targ_PrintGraph Print out the entire graphm all variables and statistics
- * for the directory cache. Should print something for
- * suffixes, too, but...
- */
-
-#include <stdio.h>
-
-#include "dir.h"
-#include "globals.h"
-#include "GNode.h"
-#include "hash.h"
-#include "suff.h"
-#include "targ.h"
-#include "util.h"
-#include "var.h"
-
-/* the list of all targets found so far */
-static Lst allTargets = Lst_Initializer(allTargets);
-
-static Hash_Table targets; /* a hash table of same */
-
-#define HTSIZE 191 /* initial size of hash table */
-
-/**
- * Targ_Init
- * Initialize this module
- *
- * Side Effects:
- * The allTargets list and the targets hash table are initialized
- */
-void
-Targ_Init(void)
-{
-
- Hash_InitTable(&targets, HTSIZE);
-}
-
-/**
- * Targ_NewGN
- * Create and initialize a new graph node
- *
- * Results:
- * An initialized graph node with the name field filled with a copy
- * of the passed name
- *
- * Side Effects:
- * The gnode is added to the list of all gnodes.
- */
-GNode *
-Targ_NewGN(const char *name)
-{
- GNode *gn;
-
- gn = emalloc(sizeof(GNode));
- gn->name = estrdup(name);
- gn->path = NULL;
- if (name[0] == '-' && name[1] == 'l') {
- gn->type = OP_LIB;
- } else {
- gn->type = 0;
- }
- gn->unmade = 0;
- gn->make = FALSE;
- gn->made = UNMADE;
- gn->childMade = FALSE;
- gn->order = 0;
- gn->mtime = gn->cmtime = 0;
- gn->cmtime_gn = NULL;
- Lst_Init(&gn->iParents);
- Lst_Init(&gn->cohorts);
- Lst_Init(&gn->parents);
- Lst_Init(&gn->children);
- Lst_Init(&gn->successors);
- Lst_Init(&gn->preds);
- Lst_Init(&gn->context);
- Lst_Init(&gn->commands);
- gn->suffix = NULL;
-
- return (gn);
-}
-
-/**
- * Targ_FindNode
- * Find a node in the list using the given name for matching
- *
- * Results:
- * The node in the list if it was. If it wasn't, return NULL of
- * flags was TARG_NOCREATE or the newly created and initialized node
- * if it was TARG_CREATE
- *
- * Side Effects:
- * Sometimes a node is created and added to the list
- */
-GNode *
-Targ_FindNode(const char *name, int flags)
-{
- GNode *gn; /* node in that element */
- Hash_Entry *he; /* New or used hash entry for node */
- Boolean isNew; /* Set TRUE if Hash_CreateEntry had to create */
- /* an entry for the node */
-
- if (flags & TARG_CREATE) {
- he = Hash_CreateEntry(&targets, name, &isNew);
- if (isNew) {
- gn = Targ_NewGN(name);
- Hash_SetValue(he, gn);
- Lst_AtEnd(&allTargets, gn);
- }
- } else {
- he = Hash_FindEntry(&targets, name);
- }
-
- if (he == NULL) {
- return (NULL);
- } else {
- return (Hash_GetValue(he));
- }
-}
-
-/**
- * Targ_FindList
- * Make a complete list of GNodes from the given list of names
- *
- * Results:
- * A complete list of graph nodes corresponding to all instances of all
- * the names in names.
- *
- * Side Effects:
- * If flags is TARG_CREATE, nodes will be created for all names in
- * names which do not yet have graph nodes. If flags is TARG_NOCREATE,
- * an error message will be printed for each name which can't be found.
- */
-void
-Targ_FindList(Lst *nodes, Lst *names, int flags)
-{
- LstNode *ln; /* name list element */
- GNode *gn; /* node in tLn */
- char *name;
-
- for (ln = Lst_First(names); ln != NULL; ln = Lst_Succ(ln)) {
- name = Lst_Datum(ln);
- gn = Targ_FindNode(name, flags);
- if (gn != NULL) {
- /*
- * Note: Lst_AtEnd must come before the Lst_Concat so
- * the nodes are added to the list in the order in which
- * they were encountered in the makefile.
- */
- Lst_AtEnd(nodes, gn);
- if (gn->type & OP_DOUBLEDEP) {
- Lst_Concat(nodes, &gn->cohorts, LST_CONCNEW);
- }
-
- } else if (flags == TARG_NOCREATE) {
- Error("\"%s\" -- target unknown.", name);
- }
- }
-}
-
-/**
- * Targ_Ignore
- * Return true if should ignore errors when creating gn
- *
- * Results:
- * TRUE if should ignore errors
- */
-Boolean
-Targ_Ignore(GNode *gn)
-{
-
- if (ignoreErrors || (gn->type & OP_IGNORE)) {
- return (TRUE);
- } else {
- return (FALSE);
- }
-}
-
-/**
- * Targ_Silent
- * Return true if be silent when creating gn
- *
- * Results:
- * TRUE if should be silent
- */
-Boolean
-Targ_Silent(GNode *gn)
-{
-
- if (beSilent || (gn->type & OP_SILENT)) {
- return (TRUE);
- } else {
- return (FALSE);
- }
-}
-
-/**
- * Targ_Precious
- * See if the given target is precious
- *
- * Results:
- * TRUE if it is precious. FALSE otherwise
- */
-Boolean
-Targ_Precious(GNode *gn)
-{
-
- if (allPrecious || (gn->type & (OP_PRECIOUS | OP_DOUBLEDEP))) {
- return (TRUE);
- } else {
- return (FALSE);
- }
-}
-
-static GNode *mainTarg; /* the main target, as set by Targ_SetMain */
-
-/**
- * Targ_SetMain
- * Set our idea of the main target we'll be creating. Used for
- * debugging output.
- *
- * Side Effects:
- * "mainTarg" is set to the main target's node.
- */
-void
-Targ_SetMain(GNode *gn)
-{
-
- mainTarg = gn;
-}
-
-/**
- * Targ_FmtTime
- * Format a modification time in some reasonable way and return it.
- *
- * Results:
- * The time reformatted.
- *
- * Side Effects:
- * The time is placed in a static area, so it is overwritten
- * with each call.
- */
-char *
-Targ_FmtTime(time_t modtime)
-{
- struct tm *parts;
- static char buf[128];
-
- parts = localtime(&modtime);
-
- strftime(buf, sizeof(buf), "%H:%M:%S %b %d, %Y", parts);
- buf[sizeof(buf) - 1] = '\0';
- return (buf);
-}
-
-/**
- * Targ_PrintType
- * Print out a type field giving only those attributes the user can
- * set.
- */
-void
-Targ_PrintType(int type)
-{
- static const struct flag2str type2str[] = {
- { OP_OPTIONAL, ".OPTIONAL" },
- { OP_USE, ".USE" },
- { OP_EXEC, ".EXEC" },
- { OP_IGNORE, ".IGNORE" },
- { OP_PRECIOUS, ".PRECIOUS" },
- { OP_SILENT, ".SILENT" },
- { OP_MAKE, ".MAKE" },
- { OP_JOIN, ".JOIN" },
- { OP_INVISIBLE, ".INVISIBLE" },
- { OP_NOTMAIN, ".NOTMAIN" },
- { OP_PHONY, ".PHONY" },
- { OP_LIB, ".LIB" },
- { OP_MEMBER, ".MEMBER" },
- { OP_ARCHV, ".ARCHV" },
- { 0, NULL }
- };
-
- type &= ~OP_OPMASK;
- if (!DEBUG(TARG))
- type &= ~(OP_ARCHV | OP_LIB | OP_MEMBER);
- print_flags(stdout, type2str, type, 0);
-}
-
-/**
- * TargPrintNode
- * print the contents of a node
- */
-static int
-TargPrintNode(const GNode *gn, int pass)
-{
- const LstNode *tln;
-
- if (!OP_NOP(gn->type)) {
- printf("#\n");
- if (gn == mainTarg) {
- printf("# *** MAIN TARGET ***\n");
- }
- if (pass == 2) {
- if (gn->unmade) {
- printf("# %d unmade children\n", gn->unmade);
- } else {
- printf("# No unmade children\n");
- }
- if (!(gn->type & (OP_JOIN | OP_USE | OP_EXEC))) {
- if (gn->mtime != 0) {
- printf("# last modified %s: %s\n",
- Targ_FmtTime(gn->mtime),
- gn->made == UNMADE ? "unmade" :
- gn->made == MADE ? "made" :
- gn->made == UPTODATE ? "up-to-date":
- "error when made");
- } else if (gn->made != UNMADE) {
- printf("# non-existent (maybe): %s\n",
- gn->made == MADE ? "made" :
- gn->made == UPTODATE ? "up-to-date":
- gn->made == ERROR?"error when made":
- "aborted");
- } else {
- printf("# unmade\n");
- }
- }
- if (!Lst_IsEmpty(&gn->iParents)) {
- printf("# implicit parents: ");
- LST_FOREACH(tln, &gn->iParents)
- printf("%s ", ((const GNode *)
- Lst_Datum(tln))->name);
- printf("\n");
- }
- }
- if (!Lst_IsEmpty(&gn->parents)) {
- printf("# parents: ");
- LST_FOREACH(tln, &gn->parents)
- printf("%s ", ((const GNode *)
- Lst_Datum(tln))->name);
- printf("\n");
- }
-
- printf("%-16s", gn->name);
- switch (gn->type & OP_OPMASK) {
- case OP_DEPENDS:
- printf(": ");
- break;
- case OP_FORCE:
- printf("! ");
- break;
- case OP_DOUBLEDEP:
- printf(":: ");
- break;
- default:
- break;
- }
- Targ_PrintType(gn->type);
- LST_FOREACH(tln, &gn->children)
- printf("%s ", ((const GNode *)Lst_Datum(tln))->name);
- printf("\n");
- LST_FOREACH(tln, &gn->commands)
- printf("\t%s\n", (const char *)Lst_Datum(tln));
- printf("\n\n");
- if (gn->type & OP_DOUBLEDEP) {
- LST_FOREACH(tln, &gn->cohorts)
- TargPrintNode((const GNode *)Lst_Datum(tln),
- pass);
- }
- }
- return (0);
-}
-
-/**
- * Targ_PrintGraph
- * Print the entire graph.
- */
-void
-Targ_PrintGraph(int pass)
-{
- const GNode *gn;
- const LstNode *tln;
-
- printf("#*** Input graph:\n");
- LST_FOREACH(tln, &allTargets)
- TargPrintNode((const GNode *)Lst_Datum(tln), pass);
- printf("\n\n");
-
- printf("#\n# Files that are only sources:\n");
- LST_FOREACH(tln, &allTargets) {
- gn = Lst_Datum(tln);
- if (OP_NOP(gn->type))
- printf("#\t%s [%s]\n", gn->name,
- gn->path ? gn->path : gn->name);
- }
- Var_Dump();
- printf("\n");
- Dir_PrintDirectories();
- printf("\n");
- Suff_PrintAll();
-}
diff --git a/usr.bin/make/targ.h b/usr.bin/make/targ.h
deleted file mode 100644
index 3882833..0000000
--- a/usr.bin/make/targ.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/*-
- * Copyright (c) 1988, 1989, 1990, 1993
- * The Regents of the University of California. All rights reserved.
- * Copyright (c) 1989 by Berkeley Softworks
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Adam de Boor.
- *
- * 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.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
- *
- * $FreeBSD$
- */
-
-#ifndef targ_h_6ded1830
-#define targ_h_6ded1830
-
-#include <time.h>
-
-/*
- * The TARG_ constants are used when calling the Targ_FindNode and
- * Targ_FindList functions in targ.c. They simply tell the functions what to
- * do if the desired node(s) is (are) not found. If the TARG_CREATE constant
- * is given, a new, empty node will be created for the target, placed in the
- * table of all targets and its address returned. If TARG_NOCREATE is given,
- * a NULL pointer will be returned.
- */
-#define TARG_CREATE 0x01 /* create node if not found */
-#define TARG_NOCREATE 0x00 /* don't create it */
-
-struct GNode;
-struct Lst;
-
-void Targ_Init(void);
-struct GNode *Targ_NewGN(const char *);
-struct GNode *Targ_FindNode(const char *, int);
-void Targ_FindList(struct Lst *, struct Lst *, int);
-Boolean Targ_Ignore(struct GNode *);
-Boolean Targ_Silent(struct GNode *);
-Boolean Targ_Precious(struct GNode *);
-void Targ_SetMain(struct GNode *);
-int Targ_PrintCmd(void *, void *);
-char *Targ_FmtTime(time_t);
-void Targ_PrintType(int);
-void Targ_PrintGraph(int);
-
-#endif /* targ_h_6ded1830 */
diff --git a/usr.bin/make/util.c b/usr.bin/make/util.c
deleted file mode 100644
index 3a27b0a..0000000
--- a/usr.bin/make/util.c
+++ /dev/null
@@ -1,316 +0,0 @@
-/*-
- * Copyright (c) 2002 Juli Mallett. All rights reserved.
- * Copyright (c) 1988, 1989, 1990, 1993
- * The Regents of the University of California. All rights reserved.
- * Copyright (c) 1989 by Berkeley Softworks
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Adam de Boor.
- *
- * 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.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
- *
- * @(#)main.c 8.3 (Berkeley) 3/19/94
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-/*-
- * util.c --
- * General utilitarian routines for make(1).
- */
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <err.h>
-#include <errno.h>
-#include <stdarg.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#include "globals.h"
-#include "job.h"
-#include "targ.h"
-#include "util.h"
-
-static void enomem(void) __dead2;
-
-/*-
- * Debug --
- * Print a debugging message given its format.
- *
- * Results:
- * None.
- *
- * Side Effects:
- * The message is printed.
- */
-/* VARARGS */
-void
-Debug(const char *fmt, ...)
-{
- va_list ap;
-
- va_start(ap, fmt);
- vfprintf(stderr, fmt, ap);
- va_end(ap);
- fflush(stderr);
-}
-
-/*-
- * Print a debugging message given its format and append the current
- * errno description. Terminate with a newline.
- */
-/* VARARGS */
-void
-DebugM(const char *fmt, ...)
-{
- va_list ap;
- int e = errno;
-
- va_start(ap, fmt);
- vfprintf(stderr, fmt, ap);
- fprintf(stderr, ": %s\n", strerror(e));
- va_end(ap);
- fflush(stderr);
-}
-
-/*-
- * Error --
- * Print an error message given its format.
- *
- * Results:
- * None.
- *
- * Side Effects:
- * The message is printed.
- */
-/* VARARGS */
-void
-Error(const char *fmt, ...)
-{
- va_list ap;
-
- va_start(ap, fmt);
- vfprintf(stderr, fmt, ap);
- va_end(ap);
- fprintf(stderr, "\n");
- fflush(stderr);
-}
-
-/*-
- * Fatal --
- * Produce a Fatal error message. If jobs are running, waits for them
- * to finish.
- *
- * Results:
- * None
- *
- * Side Effects:
- * The program exits
- */
-/* VARARGS */
-void
-Fatal(const char *fmt, ...)
-{
- va_list ap;
-
- va_start(ap, fmt);
- if (jobsRunning)
- Job_Wait();
-
- vfprintf(stderr, fmt, ap);
- va_end(ap);
- fprintf(stderr, "\n");
- fflush(stderr);
-
- if (DEBUG(GRAPH2))
- Targ_PrintGraph(2);
- exit(2); /* Not 1 so -q can distinguish error */
-}
-
-/*
- * Punt --
- * Major exception once jobs are being created. Kills all jobs, prints
- * a message and exits.
- *
- * Results:
- * None
- *
- * Side Effects:
- * All children are killed indiscriminately and the program Lib_Exits
- */
-/* VARARGS */
-void
-Punt(const char *fmt, ...)
-{
- va_list ap;
-
- va_start(ap, fmt);
- fprintf(stderr, "make: ");
- vfprintf(stderr, fmt, ap);
- va_end(ap);
- fprintf(stderr, "\n");
- fflush(stderr);
-
- DieHorribly();
-}
-
-/*-
- * DieHorribly --
- * Exit without giving a message.
- *
- * Results:
- * None
- *
- * Side Effects:
- * A big one...
- */
-void
-DieHorribly(void)
-{
- if (jobsRunning)
- Job_AbortAll();
- if (DEBUG(GRAPH2))
- Targ_PrintGraph(2);
- exit(2); /* Not 1, so -q can distinguish error */
-}
-
-/*
- * Finish --
- * Called when aborting due to errors in child shell to signal
- * abnormal exit, with the number of errors encountered in Make_Make.
- *
- * Results:
- * None
- *
- * Side Effects:
- * The program exits
- */
-void
-Finish(int errors)
-{
-
- Fatal("%d error%s", errors, errors == 1 ? "" : "s");
-}
-
-/*
- * emalloc --
- * malloc, but die on error.
- */
-void *
-emalloc(size_t len)
-{
- void *p;
-
- if ((p = malloc(len)) == NULL)
- enomem();
- return (p);
-}
-
-/*
- * estrdup --
- * strdup, but die on error.
- */
-char *
-estrdup(const char *str)
-{
- char *p;
-
- if ((p = strdup(str)) == NULL)
- enomem();
- return (p);
-}
-
-/*
- * erealloc --
- * realloc, but die on error.
- */
-void *
-erealloc(void *ptr, size_t size)
-{
-
- if ((ptr = realloc(ptr, size)) == NULL)
- enomem();
- return (ptr);
-}
-
-/*
- * enomem --
- * die when out of memory.
- */
-static void
-enomem(void)
-{
- err(2, NULL);
-}
-
-/*
- * enunlink --
- * Remove a file carefully, avoiding directories.
- */
-int
-eunlink(const char *file)
-{
- struct stat st;
-
- if (lstat(file, &st) == -1)
- return (-1);
-
- if (S_ISDIR(st.st_mode)) {
- errno = EISDIR;
- return (-1);
- }
- return (unlink(file));
-}
-
-/*
- * Convert a flag word to a printable thing and print it
- */
-void
-print_flags(FILE *fp, const struct flag2str *tab, u_int flags, int par)
-{
- int first = 1;
-
- if (par)
- fprintf(fp, "(");
- while (tab->str != NULL) {
- if (flags & tab->flag) {
- if (!first)
- fprintf(fp, par ? "|" : " ");
- first = 0;
- fprintf(fp, "%s", tab->str);
- }
- tab++;
- }
- if (par)
- fprintf(fp, ")");
-}
diff --git a/usr.bin/make/util.h b/usr.bin/make/util.h
deleted file mode 100644
index 9a1dedf..0000000
--- a/usr.bin/make/util.h
+++ /dev/null
@@ -1,116 +0,0 @@
-/*-
- * Copyright (c) 1988, 1989, 1990, 1993
- * The Regents of the University of California. All rights reserved.
- * Copyright (c) 1989 by Berkeley Softworks
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Adam de Boor.
- *
- * 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.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
- *
- * $FreeBSD$
- */
-
-#ifndef util_h_b7020fdb
-#define util_h_b7020fdb
-
-#include <sys/types.h>
-#include <stdio.h>
-
-/*
- * A boolean type is defined as an integer, not an enum. This allows a
- * boolean argument to be an expression that isn't strictly 0 or 1 valued.
- */
-
-typedef int Boolean;
-#ifndef TRUE
-#define TRUE 1
-#define FALSE 0
-#endif /* TRUE */
-
-#define CONCAT(a,b) a##b
-
-struct flag2str {
- u_int flag;
- const char *str;
-};
-
-/*
- * debug control:
- * There is one bit per module. It is up to the module what debug
- * information to print.
- */
-#define DEBUG_ARCH 0x0001
-#define DEBUG_COND 0x0002
-#define DEBUG_DIR 0x0004
-#define DEBUG_GRAPH1 0x0008
-#define DEBUG_GRAPH2 0x0010
-#define DEBUG_JOB 0x0020
-#define DEBUG_MAKE 0x0040
-#define DEBUG_SUFF 0x0080
-#define DEBUG_TARG 0x0100
-#define DEBUG_VAR 0x0200
-#define DEBUG_FOR 0x0400
-#define DEBUG_LOUD 0x0800
-
-#define DEBUG(module) (debug & CONCAT(DEBUG_,module))
-#define DEBUGF(module,args) \
-do { \
- if (DEBUG(module)) { \
- Debug args ; \
- } \
-} while (0)
-#define DEBUGM(module, args) do { \
- if (DEBUG(module)) { \
- DebugM args; \
- } \
- } while (0)
-
-#define ISDOT(c) ((c)[0] == '.' && (((c)[1] == '\0') || ((c)[1] == '/')))
-#define ISDOTDOT(c) ((c)[0] == '.' && ISDOT(&((c)[1])))
-
-#ifndef MAX
-#define MAX(a, b) ((a) > (b) ? (a) : (b))
-#endif
-
-void Debug(const char *, ...);
-void DebugM(const char *, ...);
-void Error(const char *, ...);
-void Fatal(const char *, ...) __dead2;
-void Punt(const char *, ...) __dead2;
-void DieHorribly(void) __dead2;
-void Finish(int) __dead2;
-char *estrdup(const char *);
-void *emalloc(size_t);
-void *erealloc(void *, size_t);
-int eunlink(const char *);
-void print_flags(FILE *, const struct flag2str *, u_int, int);
-
-#endif /* util_h_b7020fdb */
diff --git a/usr.bin/make/var.c b/usr.bin/make/var.c
deleted file mode 100644
index cbaea9e..0000000
--- a/usr.bin/make/var.c
+++ /dev/null
@@ -1,2623 +0,0 @@
-/*-
- * Copyright (c) 2002 Juli Mallett.
- * Copyright (c) 1988, 1989, 1990, 1993
- * The Regents of the University of California. All rights reserved.
- * Copyright (c) 1989 by Berkeley Softworks
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Adam de Boor.
- *
- * 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.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
- *
- * @(#)var.c 8.3 (Berkeley) 3/19/94
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-/**
- * var.c --
- * Variable-handling functions
- *
- * Interface:
- * Var_Set Set the value of a variable in the given
- * context. The variable is created if it doesn't
- * yet exist. The value and variable name need not
- * be preserved.
- *
- * Var_Append Append more characters to an existing variable
- * in the given context. The variable needn't
- * exist already -- it will be created if it doesn't.
- * A space is placed between the old value and the
- * new one.
- *
- * Var_Exists See if a variable exists.
- *
- * Var_Value Return the value of a variable in a context or
- * NULL if the variable is undefined.
- *
- * Var_Subst Substitute named variable, or all variables if
- * NULL in a string using
- * the given context as the top-most one. If the
- * third argument is non-zero, Parse_Error is
- * called if any variables are undefined.
- *
- * Var_Parse Parse a variable expansion from a string and
- * return the result and the number of characters
- * consumed.
- *
- * Var_Delete Delete a variable in a context.
- *
- * Var_Init Initialize this module.
- *
- * Debugging:
- * Var_Dump Print out all variables defined in the given
- * context.
- *
- * XXX: There's a lot of duplication in these functions.
- */
-
-#include <ctype.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <regex.h>
-
-#include "buf.h"
-#include "config.h"
-#include "globals.h"
-#include "GNode.h"
-#include "job.h"
-#include "lst.h"
-#include "parse.h"
-#include "str.h"
-#include "targ.h"
-#include "util.h"
-#include "var.h"
-
-/**
- *
- */
-typedef struct VarParser {
- const char *const input; /* pointer to input string */
- const char *ptr; /* current parser pos in input str */
- GNode *ctxt;
- Boolean err;
- Boolean execute;
-} VarParser;
-
-typedef struct Var {
- char *name; /* the variable's name */
- struct Buffer *val; /* its value */
- int flags; /* miscellaneous status flags */
-
-#define VAR_IN_USE 1 /* Variable's value currently being used.
- * Used to avoid recursion */
-
-#define VAR_JUNK 4 /* Variable is a junk variable that
- * should be destroyed when done with
- * it. Used by Var_Parse for undefined,
- * modified variables */
-
-#define VAR_TO_ENV 8 /* Place variable in environment */
-} Var;
-
-typedef struct {
- struct Buffer *lhs; /* String to match */
- struct Buffer *rhs; /* Replacement string (w/ &'s removed) */
-
- regex_t re;
- int nsub;
- regmatch_t *matches;
-
- int flags;
-#define VAR_SUB_GLOBAL 0x01 /* Apply substitution globally */
-#define VAR_SUB_ONE 0x02 /* Apply substitution to one word */
-#define VAR_SUB_MATCHED 0x04 /* There was a match */
-#define VAR_MATCH_START 0x08 /* Match at start of word */
-#define VAR_MATCH_END 0x10 /* Match at end of word */
-} VarPattern;
-
-typedef Boolean VarModifyProc(const char *, Boolean, struct Buffer *, void *);
-
-static char *VarParse(VarParser *, Boolean *);
-
-/*
- * This is a harmless return value for Var_Parse that can be used by Var_Subst
- * to determine if there was an error in parsing -- easier than returning
- * a flag, as things outside this module don't give a hoot.
- */
-char var_Error[] = "";
-
-/*
- * Similar to var_Error, but returned when the 'err' flag for Var_Parse is
- * set false. Why not just use a constant? Well, gcc likes to condense
- * identical string instances...
- */
-static char varNoError[] = "";
-
-/*
- * Internally, variables are contained in four different contexts.
- * 1) the environment. They may not be changed. If an environment
- * variable is appended-to, the result is placed in the global
- * context.
- * 2) the global context. Variables set in the Makefile are located in
- * the global context. It is the penultimate context searched when
- * substituting.
- * 3) the command-line context. All variables set on the command line
- * are placed in this context. They are UNALTERABLE once placed here.
- * 4) the local context. Each target has associated with it a context
- * list. On this list are located the structures describing such
- * local variables as $(@) and $(*)
- * The four contexts are searched in the reverse order from which they are
- * listed.
- */
-static GNode *VAR_ENV; /* variables from the environment */
-GNode *VAR_GLOBAL; /* variables from the makefile */
-GNode *VAR_CMD; /* variables defined on the command-line */
-
-Boolean oldVars; /* variable substitution style */
-Boolean checkEnvFirst; /* -e flag */
-
-#define OPEN_PAREN '('
-#define CLOSE_PAREN ')'
-#define OPEN_BRACE '{'
-#define CLOSE_BRACE '}'
-
-/**
- * Create a Var object.
- *
- * Params:
- * name Name of variable (copied).
- * value Value of variable (copied) or NULL.
- * flags Flags set on variable.
- *
- * Returns:
- * New variable.
- */
-static Var *
-VarCreate(const char name[], const char value[], int flags)
-{
- Var *v;
-
- v = emalloc(sizeof(Var));
- v->name = estrdup(name);
- v->val = Buf_Init(0);
- v->flags = flags;
-
- if (value != NULL) {
- Buf_Append(v->val, value);
- }
- return (v);
-}
-
-/**
- * Destroy a Var object.
- *
- * Params:
- * v Object to destroy.
- * f True if internal buffer in Buffer object is to be removed.
- */
-static void
-VarDestroy(Var *v, Boolean f)
-{
-
- Buf_Destroy(v->val, f);
- free(v->name);
- free(v);
-}
-
-/**
- * Remove the tail of the given word and place the result in the given
- * buffer.
- *
- * Results:
- * TRUE if characters were added to the buffer (a space needs to be
- * added to the buffer before the next word).
- *
- * Side Effects:
- * The trimmed word is added to the buffer.
- */
-static Boolean
-VarHead(const char *word, Boolean addSpace, Buffer *buf, void *dummy __unused)
-{
- char *slash;
-
- slash = strrchr(word, '/');
- if (slash != NULL) {
- if (addSpace) {
- Buf_AddByte(buf, (Byte)' ');
- }
- Buf_AppendRange(buf, word, slash);
- } else {
- /*
- * If no directory part, give . (q.v. the POSIX standard)
- */
- if (addSpace) {
- Buf_Append(buf, " .");
- } else {
- Buf_AddByte(buf, (Byte)'.');
- }
- }
- return (TRUE);
-}
-
-/**
- * Remove the head of the given word and place the result in the given
- * buffer.
- *
- * Results:
- * TRUE if characters were added to the buffer (a space needs to be
- * added to the buffer before the next word).
- *
- * Side Effects:
- * The trimmed word is added to the buffer.
- */
-static Boolean
-VarTail(const char *word, Boolean addSpace, Buffer *buf, void *dummy __unused)
-{
- const char *slash;
-
- if (addSpace) {
- Buf_AddByte (buf, (Byte)' ');
- }
-
- slash = strrchr(word, '/');
- if (slash != NULL) {
- slash++;
- Buf_Append(buf, slash);
- } else {
- Buf_Append(buf, word);
- }
- return (TRUE);
-}
-
-/**
- * Place the suffix of the given word in the given buffer.
- *
- * Results:
- * TRUE if characters were added to the buffer (a space needs to be
- * added to the buffer before the next word).
- *
- * Side Effects:
- * The suffix from the word is placed in the buffer.
- */
-static Boolean
-VarSuffix(const char *word, Boolean addSpace, Buffer *buf, void *dummy __unused)
-{
- const char *dot;
-
- dot = strrchr(word, '.');
- if (dot != NULL) {
- if (addSpace) {
- Buf_AddByte(buf, (Byte)' ');
- }
- dot++;
- Buf_Append(buf, dot);
- addSpace = TRUE;
- }
- return (addSpace);
-}
-
-/**
- * Remove the suffix of the given word and place the result in the
- * buffer.
- *
- * Results:
- * TRUE if characters were added to the buffer (a space needs to be
- * added to the buffer before the next word).
- *
- * Side Effects:
- * The trimmed word is added to the buffer.
- */
-static Boolean
-VarRoot(const char *word, Boolean addSpace, Buffer *buf, void *dummy __unused)
-{
- char *dot;
-
- if (addSpace) {
- Buf_AddByte(buf, (Byte)' ');
- }
-
- dot = strrchr(word, '.');
- if (dot != NULL) {
- Buf_AppendRange(buf, word, dot);
- } else {
- Buf_Append(buf, word);
- }
- return (TRUE);
-}
-
-/**
- * Place the word in the buffer if it matches the given pattern.
- * Callback function for VarModify to implement the :M modifier.
- * A space will be added if requested. A pattern is supplied
- * which the word must match.
- *
- * Results:
- * TRUE if a space should be placed in the buffer before the next
- * word.
- *
- * Side Effects:
- * The word may be copied to the buffer.
- */
-static Boolean
-VarMatch(const char *word, Boolean addSpace, Buffer *buf, void *pattern)
-{
-
- if (Str_Match(word, pattern)) {
- if (addSpace) {
- Buf_AddByte(buf, (Byte)' ');
- }
- addSpace = TRUE;
- Buf_Append(buf, word);
- }
- return (addSpace);
-}
-
-#ifdef SYSVVARSUB
-/**
- * Place the word in the buffer if it matches the given pattern.
- * Callback function for VarModify to implement the System V %
- * modifiers. A space is added if requested.
- *
- * Results:
- * TRUE if a space should be placed in the buffer before the next
- * word.
- *
- * Side Effects:
- * The word may be copied to the buffer.
- */
-static Boolean
-VarSYSVMatch(const char *word, Boolean addSpace, Buffer *buf, void *patp)
-{
- int len;
- const char *ptr;
- VarPattern *pat = (VarPattern *)patp;
-
- if (addSpace)
- Buf_AddByte(buf, (Byte)' ');
-
- addSpace = TRUE;
-
- if ((ptr = Str_SYSVMatch(word, Buf_Data(pat->lhs), &len)) != NULL)
- Str_SYSVSubst(buf, Buf_Data(pat->rhs), ptr, len);
- else
- Buf_Append(buf, word);
-
- return (addSpace);
-}
-#endif
-
-/**
- * Place the word in the buffer if it doesn't match the given pattern.
- * Callback function for VarModify to implement the :N modifier. A
- * space is added if requested.
- *
- * Results:
- * TRUE if a space should be placed in the buffer before the next
- * word.
- *
- * Side Effects:
- * The word may be copied to the buffer.
- */
-static Boolean
-VarNoMatch(const char *word, Boolean addSpace, Buffer *buf, void *pattern)
-{
-
- if (!Str_Match(word, pattern)) {
- if (addSpace) {
- Buf_AddByte(buf, (Byte)' ');
- }
- addSpace = TRUE;
- Buf_Append(buf, word);
- }
- return (addSpace);
-}
-
-/**
- * Perform a string-substitution on the given word, placing the
- * result in the passed buffer. A space is added if requested.
- *
- * Results:
- * TRUE if a space is needed before more characters are added.
- */
-static Boolean
-VarSubstitute(const char *word, Boolean addSpace, Buffer *buf, void *patternp)
-{
- size_t wordLen; /* Length of word */
- const char *cp; /* General pointer */
- VarPattern *pattern = patternp;
-
- wordLen = strlen(word);
- if (1) { /* substitute in each word of the variable */
- /*
- * Break substitution down into simple anchored cases
- * and if none of them fits, perform the general substitution
- * case.
- */
- if ((pattern->flags & VAR_MATCH_START) &&
- (strncmp(word, Buf_Data(pattern->lhs),
- Buf_Size(pattern->lhs)) == 0)) {
- /*
- * Anchored at start and beginning of word matches
- * pattern.
- */
- if ((pattern->flags & VAR_MATCH_END) &&
- (wordLen == Buf_Size(pattern->lhs))) {
- /*
- * Also anchored at end and matches to the end
- * (word is same length as pattern) add space
- * and rhs only if rhs is non-null.
- */
- if (Buf_Size(pattern->rhs) != 0) {
- if (addSpace) {
- Buf_AddByte(buf, (Byte)' ');
- }
- addSpace = TRUE;
- Buf_AppendBuf(buf, pattern->rhs);
- }
-
- } else if (pattern->flags & VAR_MATCH_END) {
- /*
- * Doesn't match to end -- copy word wholesale
- */
- goto nosub;
-
- } else {
- /*
- * Matches at start but need to copy in
- * trailing characters.
- */
- if ((Buf_Size(pattern->rhs) + wordLen -
- Buf_Size(pattern->lhs)) != 0) {
- if (addSpace) {
- Buf_AddByte(buf, (Byte)' ');
- }
- addSpace = TRUE;
- }
- Buf_AppendBuf(buf, pattern->rhs);
- Buf_AddBytes(buf, wordLen -
- Buf_Size(pattern->lhs),
- (word + Buf_Size(pattern->lhs)));
- }
-
- } else if (pattern->flags & VAR_MATCH_START) {
- /*
- * Had to match at start of word and didn't -- copy
- * whole word.
- */
- goto nosub;
-
- } else if (pattern->flags & VAR_MATCH_END) {
- /*
- * Anchored at end, Find only place match could occur
- * (leftLen characters from the end of the word) and
- * see if it does. Note that because the $ will be
- * left at the end of the lhs, we have to use strncmp.
- */
- cp = word + (wordLen - Buf_Size(pattern->lhs));
- if ((cp >= word) && (strncmp(cp, Buf_Data(pattern->lhs),
- Buf_Size(pattern->lhs)) == 0)) {
- /*
- * Match found. If we will place characters in
- * the buffer, add a space before hand as
- * indicated by addSpace, then stuff in the
- * initial, unmatched part of the word followed
- * by the right-hand-side.
- */
- if ((cp - word) + Buf_Size(pattern->rhs) != 0) {
- if (addSpace) {
- Buf_AddByte(buf, (Byte)' ');
- }
- addSpace = TRUE;
- }
- Buf_AppendRange(buf, word, cp);
- Buf_AppendBuf(buf, pattern->rhs);
-
- } else {
- /*
- * Had to match at end and didn't. Copy entire
- * word.
- */
- goto nosub;
- }
- } else {
- /*
- * Pattern is unanchored: search for the pattern in the
- * word using strstr(3), copying unmatched portions and
- * the right-hand-side for each match found, handling
- * non-global substitutions correctly, etc. When the
- * loop is done, any remaining part of the word (word
- * and wordLen are adjusted accordingly through the
- * loop) is copied straight into the buffer.
- * addSpace is set FALSE as soon as a space is added
- * to the buffer.
- */
- Boolean done;
- size_t origSize;
-
- done = FALSE;
- origSize = Buf_Size(buf);
- while (!done) {
- cp = strstr(word, Buf_Data(pattern->lhs));
- if (cp != NULL) {
- if (addSpace && (((cp - word) +
- Buf_Size(pattern->rhs)) != 0)) {
- Buf_AddByte(buf, (Byte)' ');
- addSpace = FALSE;
- }
- Buf_AppendRange(buf, word, cp);
- Buf_AppendBuf(buf, pattern->rhs);
- wordLen -= (cp - word) +
- Buf_Size(pattern->lhs);
- word = cp + Buf_Size(pattern->lhs);
- if (wordLen == 0 || (pattern->flags &
- VAR_SUB_GLOBAL) == 0) {
- done = TRUE;
- }
- } else {
- done = TRUE;
- }
- }
- if (wordLen != 0) {
- if (addSpace) {
- Buf_AddByte(buf, (Byte)' ');
- }
- Buf_AddBytes(buf, wordLen, (const Byte *)word);
- }
-
- /*
- * If added characters to the buffer, need to add a
- * space before we add any more. If we didn't add any,
- * just return the previous value of addSpace.
- */
- return ((Buf_Size(buf) != origSize) || addSpace);
- }
- /*
- * Common code for anchored substitutions:
- * addSpace was set TRUE if characters were added to the buffer.
- */
- return (addSpace);
- }
- nosub:
- if (addSpace) {
- Buf_AddByte(buf, (Byte)' ');
- }
- Buf_AddBytes(buf, wordLen, (const Byte *)word);
- return (TRUE);
-}
-
-/**
- * Print the error caused by a regcomp or regexec call.
- *
- * Side Effects:
- * An error gets printed.
- */
-static void
-VarREError(int err, regex_t *pat, const char *str)
-{
- char *errbuf;
- int errlen;
-
- errlen = regerror(err, pat, 0, 0);
- errbuf = emalloc(errlen);
- regerror(err, pat, errbuf, errlen);
- Error("%s: %s", str, errbuf);
- free(errbuf);
-}
-
-
-/**
- * Perform a regex substitution on the given word, placing the
- * result in the passed buffer. A space is added if requested.
- *
- * Results:
- * TRUE if a space is needed before more characters are added.
- */
-static Boolean
-VarRESubstitute(const char *word, Boolean addSpace, Buffer *buf, void *patternp)
-{
- VarPattern *pat;
- int xrv;
- const char *wp;
- char *rp;
- int added;
- int flags = 0;
-
-#define MAYBE_ADD_SPACE() \
- if (addSpace && !added) \
- Buf_AddByte(buf, (Byte)' '); \
- added = 1
-
- added = 0;
- wp = word;
- pat = patternp;
-
- if ((pat->flags & (VAR_SUB_ONE | VAR_SUB_MATCHED)) ==
- (VAR_SUB_ONE | VAR_SUB_MATCHED)) {
- xrv = REG_NOMATCH;
- } else {
- tryagain:
- xrv = regexec(&pat->re, wp, pat->nsub, pat->matches, flags);
- }
-
- switch (xrv) {
- case 0:
- pat->flags |= VAR_SUB_MATCHED;
- if (pat->matches[0].rm_so > 0) {
- MAYBE_ADD_SPACE();
- Buf_AddBytes(buf, pat->matches[0].rm_so,
- (const Byte *)wp);
- }
-
- for (rp = Buf_Data(pat->rhs); *rp; rp++) {
- if ((*rp == '\\') && ((rp[1] == '&') || (rp[1] == '\\'))) {
- MAYBE_ADD_SPACE();
- Buf_AddByte(buf, (Byte)rp[1]);
- rp++;
-
- } else if ((*rp == '&') ||
- ((*rp == '\\') && isdigit((unsigned char)rp[1]))) {
- int n;
- const char *subbuf;
- int sublen;
- char errstr[3];
-
- if (*rp == '&') {
- n = 0;
- errstr[0] = '&';
- errstr[1] = '\0';
- } else {
- n = rp[1] - '0';
- errstr[0] = '\\';
- errstr[1] = rp[1];
- errstr[2] = '\0';
- rp++;
- }
-
- if (n > pat->nsub) {
- Error("No subexpression %s",
- &errstr[0]);
- subbuf = "";
- sublen = 0;
-
- } else if ((pat->matches[n].rm_so == -1) &&
- (pat->matches[n].rm_eo == -1)) {
- Error("No match for subexpression %s",
- &errstr[0]);
- subbuf = "";
- sublen = 0;
-
- } else {
- subbuf = wp + pat->matches[n].rm_so;
- sublen = pat->matches[n].rm_eo -
- pat->matches[n].rm_so;
- }
-
- if (sublen > 0) {
- MAYBE_ADD_SPACE();
- Buf_AddBytes(buf, sublen,
- (const Byte *)subbuf);
- }
- } else {
- MAYBE_ADD_SPACE();
- Buf_AddByte(buf, (Byte)*rp);
- }
- }
- wp += pat->matches[0].rm_eo;
- if (pat->flags & VAR_SUB_GLOBAL) {
- flags |= REG_NOTBOL;
- if (pat->matches[0].rm_so == 0 &&
- pat->matches[0].rm_eo == 0) {
- MAYBE_ADD_SPACE();
- Buf_AddByte(buf, (Byte)*wp);
- wp++;
- }
- if (*wp)
- goto tryagain;
- }
- if (*wp) {
- MAYBE_ADD_SPACE();
- Buf_Append(buf, wp);
- }
- break;
-
- default:
- VarREError(xrv, &pat->re, "Unexpected regex error");
- /* fall through */
-
- case REG_NOMATCH:
- if (*wp) {
- MAYBE_ADD_SPACE();
- Buf_Append(buf, wp);
- }
- break;
- }
- return (addSpace || added);
-}
-
-/**
- * Find a variable in a variable list.
- */
-static Var *
-VarLookup(Lst *vlist, const char *name)
-{
- LstNode *ln;
-
- LST_FOREACH(ln, vlist)
- if (strcmp(((const Var *)Lst_Datum(ln))->name, name) == 0)
- return (Lst_Datum(ln));
- return (NULL);
-}
-
-/**
- * Expand a variable name's embedded variables in the given context.
- *
- * Results:
- * The contents of name, possibly expanded.
- */
-static char *
-VarPossiblyExpand(const char *name, GNode *ctxt)
-{
- Buffer *buf;
-
- if (strchr(name, '$') != NULL) {
- buf = Var_Subst(name, ctxt, 0);
- return (Buf_Peel(buf));
- } else {
- return estrdup(name);
- }
-}
-
-/**
- * If the variable name begins with a '.', it could very well be
- * one of the local ones. We check the name against all the local
- * variables and substitute the short version in for 'name' if it
- * matches one of them.
- */
-static const char *
-VarLocal(const char name[])
-{
- if (name[0] == '.') {
- switch (name[1]) {
- case 'A':
- if (!strcmp(name, ".ALLSRC"))
- return (ALLSRC);
- if (!strcmp(name, ".ARCHIVE"))
- return (ARCHIVE);
- break;
- case 'I':
- if (!strcmp(name, ".IMPSRC"))
- return (IMPSRC);
- break;
- case 'M':
- if (!strcmp(name, ".MEMBER"))
- return (MEMBER);
- break;
- case 'O':
- if (!strcmp(name, ".OODATE"))
- return (OODATE);
- break;
- case 'P':
- if (!strcmp(name, ".PREFIX"))
- return (PREFIX);
- break;
- case 'T':
- if (!strcmp(name, ".TARGET"))
- return (TARGET);
- break;
- default:
- break;
- }
- }
- return (name);
-}
-
-/**
- * Find the given variable in the given context and the environment.
- *
- * Results:
- * A pointer to the structure describing the desired variable or
- * NULL if the variable does not exist.
- */
-static Var *
-VarFindEnv(const char name[], GNode *ctxt)
-{
- Var *var;
-
- name = VarLocal(name);
-
- if ((var = VarLookup(&ctxt->context, name)) != NULL)
- return (var);
-
- if ((var = VarLookup(&VAR_ENV->context, name)) != NULL)
- return (var);
-
- return (NULL);
-}
-
-/**
- * Look for the variable in the given context.
- */
-static Var *
-VarFindOnly(const char name[], GNode *ctxt)
-{
- Var *var;
-
- name = VarLocal(name);
-
- if ((var = VarLookup(&ctxt->context, name)) != NULL)
- return (var);
-
- return (NULL);
-}
-
-/**
- * Look for the variable in all contexts.
- */
-static Var *
-VarFindAny(const char name[], GNode *ctxt)
-{
- Boolean localCheckEnvFirst;
- LstNode *ln;
- Var *var;
-
- name = VarLocal(name);
-
- /*
- * Note whether this is one of the specific variables we were told
- * through the -E flag to use environment-variable-override for.
- */
- localCheckEnvFirst = FALSE;
- LST_FOREACH(ln, &envFirstVars) {
- if (strcmp(Lst_Datum(ln), name) == 0) {
- localCheckEnvFirst = TRUE;
- break;
- }
- }
-
- /*
- * First look for the variable in the given context. If it's not there,
- * look for it in VAR_CMD, VAR_GLOBAL and the environment,
- * in that order, depending on the FIND_* flags in 'flags'
- */
- if ((var = VarLookup(&ctxt->context, name)) != NULL)
- return (var);
-
- /* not there - try command line context */
- if (ctxt != VAR_CMD) {
- if ((var = VarLookup(&VAR_CMD->context, name)) != NULL)
- return (var);
- }
-
- /* not there - try global context, but only if not -e/-E */
- if (ctxt != VAR_GLOBAL && (!checkEnvFirst && !localCheckEnvFirst)) {
- if ((var = VarLookup(&VAR_GLOBAL->context, name)) != NULL)
- return (var);
- }
-
- if ((var = VarLookup(&VAR_ENV->context, name)) != NULL)
- return (var);
-
- /* deferred check for the environment (in case of -e/-E) */
- if ((ctxt != VAR_GLOBAL) && (checkEnvFirst || localCheckEnvFirst)) {
- if ((var = VarLookup(&VAR_GLOBAL->context, name)) != NULL)
- return (var);
- }
-
- return (NULL);
-}
-
-/**
- * Add a new variable of name name and value val to the given context.
- *
- * Side Effects:
- * The new variable is placed at the front of the given context
- * The name and val arguments are duplicated so they may
- * safely be freed.
- */
-static Var *
-VarAdd(const char *name, const char *val, GNode *ctxt)
-{
- Var *v;
-
- Lst_AtFront(&ctxt->context, v = VarCreate(name, val, 0));
- DEBUGF(VAR, ("%s:%s = %s\n", ctxt->name, name, val));
- return (v);
-}
-
-/**
- * Remove a variable from a context.
- *
- * Side Effects:
- * The Var structure is removed and freed.
- */
-void
-Var_Delete(const char *name, GNode *ctxt)
-{
- LstNode *ln;
-
- DEBUGF(VAR, ("%s:delete %s\n", ctxt->name, name));
- LST_FOREACH(ln, &ctxt->context) {
- if (strcmp(((const Var *)Lst_Datum(ln))->name, name) == 0) {
- VarDestroy(Lst_Datum(ln), TRUE);
- Lst_Remove(&ctxt->context, ln);
- break;
- }
- }
-}
-
-/**
- * Set the variable name to the value val in the given context.
- *
- * Side Effects:
- * If the variable doesn't yet exist, a new record is created for it.
- * Else the old value is freed and the new one stuck in its place
- *
- * Notes:
- * The variable is searched for only in its context before being
- * created in that context. I.e. if the context is VAR_GLOBAL,
- * only VAR_GLOBAL->context is searched. Likewise if it is VAR_CMD, only
- * VAR_CMD->context is searched. This is done to avoid the literally
- * thousands of unnecessary strcmp's that used to be done to
- * set, say, $(@) or $(<).
- */
-void
-Var_Set(const char *name, const char *val, GNode *ctxt)
-{
- Var *v;
- char *n;
-
- /*
- * We only look for a variable in the given context since anything
- * set here will override anything in a lower context, so there's not
- * much point in searching them all just to save a bit of memory...
- */
- n = VarPossiblyExpand(name, ctxt);
- v = VarFindOnly(n, ctxt);
- if (v == NULL) {
- v = VarAdd(n, val, ctxt);
- } else {
- Buf_Clear(v->val);
- Buf_Append(v->val, val);
- DEBUGF(VAR, ("%s:%s = %s\n", ctxt->name, n, val));
- }
-
- if (ctxt == VAR_CMD || (v->flags & VAR_TO_ENV)) {
- /*
- * Any variables given on the command line
- * are automatically exported to the
- * environment (as per POSIX standard)
- */
- setenv(n, val, 1);
- }
-
- free(n);
-}
-
-/**
- * Set the a global name variable to the value.
- */
-void
-Var_SetGlobal(const char name[], const char value[])
-{
-
- Var_Set(name, value, VAR_GLOBAL);
-}
-
-
-/**
- * Set the VAR_TO_ENV flag on a variable
- */
-void
-Var_SetEnv(const char *name, GNode *ctxt)
-{
- Var *v;
-
- v = VarFindOnly(name, VAR_CMD);
- if (v != NULL) {
- /*
- * Do not allow .EXPORT: to be set on variables
- * from the comand line or MAKEFLAGS.
- */
- Error(
- "Warning: Did not set .EXPORTVAR: on %s because it "
- "is from the comand line or MAKEFLAGS", name);
- return;
- }
-
- v = VarFindAny(name, ctxt);
- if (v == NULL) {
- Lst_AtFront(&VAR_ENV->context,
- VarCreate(name, NULL, VAR_TO_ENV));
- setenv(name, "", 1);
- Error("Warning: .EXPORTVAR: set on undefined variable %s", name);
- } else {
- if ((v->flags & VAR_TO_ENV) == 0) {
- v->flags |= VAR_TO_ENV;
- setenv(v->name, Buf_Data(v->val), 1);
- }
- }
-}
-
-/**
- * The variable of the given name has the given value appended to it in
- * the given context.
- *
- * Side Effects:
- * If the variable doesn't exist, it is created. Else the strings
- * are concatenated (with a space in between).
- *
- * Notes:
- * Only if the variable is being sought in the global context is the
- * environment searched.
- * XXX: Knows its calling circumstances in that if called with ctxt
- * an actual target, it will only search that context since only
- * a local variable could be being appended to. This is actually
- * a big win and must be tolerated.
- */
-void
-Var_Append(const char *name, const char *val, GNode *ctxt)
-{
- Var *v;
- char *n;
-
- n = VarPossiblyExpand(name, ctxt);
- if (ctxt == VAR_GLOBAL) {
- v = VarFindEnv(n, ctxt);
- } else {
- v = VarFindOnly(n, ctxt);
- }
- if (v == NULL) {
- VarAdd(n, val, ctxt);
- } else {
- Buf_AddByte(v->val, (Byte)' ');
- Buf_Append(v->val, val);
- DEBUGF(VAR, ("%s:%s = %s\n", ctxt->name, n, Buf_Data(v->val)));
- }
- free(n);
-}
-
-/**
- * See if the given variable exists.
- *
- * Results:
- * TRUE if it does, FALSE if it doesn't
- */
-Boolean
-Var_Exists(const char *name, GNode *ctxt)
-{
- Var *v;
- char *n;
-
- n = VarPossiblyExpand(name, ctxt);
- v = VarFindAny(n, ctxt);
- if (v == NULL) {
- free(n);
- return (FALSE);
- } else {
- free(n);
- return (TRUE);
- }
-}
-
-/**
- * Return the value of the named variable in the given context
- *
- * Results:
- * The value if the variable exists, NULL if it doesn't.
- */
-const char *
-Var_Value(const char name[], GNode *ctxt)
-{
- Var *v;
- char *n;
-
- n = VarPossiblyExpand(name, ctxt);
- v = VarFindAny(n, ctxt);
- free(n);
- if (v == NULL) {
- return (NULL);
- } else {
- return (Buf_Data(v->val));
- }
-}
-
-/**
- * Modify each of the words of the passed string using the given
- * function. Used to implement all modifiers.
- *
- * Results:
- * A string of all the words modified appropriately.
- *
- * Side Effects:
- * Uses brk_string() so it invalidates any previous call to
- * brk_string().
- */
-static char *
-VarModify(const char *str, VarModifyProc *modProc, void *datum)
-{
- ArgArray aa;
- Buffer *buf; /* Buffer for the new string */
- int i;
- Boolean addSpace; /*
- * TRUE if need to add a space to
- * the buffer before adding the
- * trimmed word
- */
-
- brk_string(&aa, str, FALSE);
-
- addSpace = FALSE;
- buf = Buf_Init(0);
- for (i = 1; i < aa.argc; i++)
- addSpace = (*modProc)(aa.argv[i], addSpace, buf, datum);
-
- ArgArray_Done(&aa);
- return (Buf_Peel(buf));
-}
-
-/**
- * Sort the words in the string.
- *
- * Input:
- * str String whose words should be sorted
- * cmp A comparison function to control the ordering
- *
- * Results:
- * A string containing the words sorted
- */
-static char *
-VarSortWords(const char *str, int (*cmp)(const void *, const void *))
-{
- ArgArray aa;
- Buffer *buf;
- int i;
-
- brk_string(&aa, str, FALSE);
- qsort(aa.argv + 1, aa.argc - 1, sizeof(char *), cmp);
-
- buf = Buf_Init(0);
- for (i = 1; i < aa.argc; i++) {
- Buf_Append(buf, aa.argv[i]);
- Buf_AddByte(buf, (Byte)((i < aa.argc - 1) ? ' ' : '\0'));
- }
-
- ArgArray_Done(&aa);
- return (Buf_Peel(buf));
-}
-
-static int
-SortIncreasing(const void *l, const void *r)
-{
-
- return (strcmp(*(const char* const*)l, *(const char* const*)r));
-}
-
-/**
- * Remove adjacent duplicate words.
- *
- * Results:
- * A string containing the resulting words.
- */
-static char *
-VarUniq(const char *str)
-{
- ArgArray aa;
- Buffer *buf; /* Buffer for new string */
- int i, j;
-
- buf = Buf_Init(0);
- brk_string(&aa, str, FALSE);
-
- if (aa.argc > 2) {
- for (j = 1, i = 2; i < aa.argc; i++) {
- if (strcmp(aa.argv[i], aa.argv[j]) != 0 && (++j != i))
- aa.argv[j] = aa.argv[i];
- }
- aa.argc = j + 1;
- }
-
- for (i = 1; i < aa.argc; i++) {
- Buf_AddBytes(buf, strlen(aa.argv[i]), (Byte *)aa.argv[i]);
- if (i != aa.argc - 1)
- Buf_AddByte(buf, ' ');
- }
- Buf_AddByte(buf, '\0');
-
- ArgArray_Done(&aa);
- return (Buf_Peel(buf));
-}
-
-/**
- * Pass through the tstr looking for 1) escaped delimiters,
- * '$'s and backslashes (place the escaped character in
- * uninterpreted) and 2) unescaped $'s that aren't before
- * the delimiter (expand the variable substitution).
- * Return the expanded string or NULL if the delimiter was missing
- * If pattern is specified, handle escaped ampersands, and replace
- * unescaped ampersands with the lhs of the pattern.
- *
- * Results:
- * A string of all the words modified appropriately.
- * If length is specified, return the string length of the buffer
- * If flags is specified and the last character of the pattern is a
- * $ set the VAR_MATCH_END bit of flags.
- */
-static Buffer *
-VarGetPattern(VarParser *vp, int delim, int *flags, VarPattern *patt)
-{
- Buffer *buf;
-
- buf = Buf_Init(0);
-
- /*
- * Skim through until the matching delimiter is found; pick up
- * variable substitutions on the way. Also allow backslashes to quote
- * the delimiter, $, and \, but don't touch other backslashes.
- */
- while (*vp->ptr != '\0') {
- if (*vp->ptr == delim) {
- return (buf);
-
- } else if ((vp->ptr[0] == '\\') &&
- ((vp->ptr[1] == delim) ||
- (vp->ptr[1] == '\\') ||
- (vp->ptr[1] == '$') ||
- (vp->ptr[1] == '&' && patt != NULL))) {
- vp->ptr++; /* consume backslash */
- Buf_AddByte(buf, (Byte)vp->ptr[0]);
- vp->ptr++;
-
- } else if (vp->ptr[0] == '$') {
- if (vp->ptr[1] == delim) {
- if (flags == NULL) {
- Buf_AddByte(buf, (Byte)vp->ptr[0]);
- vp->ptr++;
- } else {
- /*
- * Unescaped $ at end of patt =>
- * anchor patt at end.
- */
- *flags |= VAR_MATCH_END;
- vp->ptr++;
- }
- } else {
- VarParser subvp = {
- vp->ptr,
- vp->ptr,
- vp->ctxt,
- vp->err,
- vp->execute
- };
- char *rval;
- Boolean rfree;
-
- /*
- * If unescaped dollar sign not
- * before the delimiter, assume it's
- * a variable substitution and
- * recurse.
- */
- rval = VarParse(&subvp, &rfree);
- Buf_Append(buf, rval);
- if (rfree)
- free(rval);
- vp->ptr = subvp.ptr;
- }
- } else if (vp->ptr[0] == '&' && patt != NULL) {
- Buf_AppendBuf(buf, patt->lhs);
- vp->ptr++;
- } else {
- Buf_AddByte(buf, (Byte)vp->ptr[0]);
- vp->ptr++;
- }
- }
-
- Buf_Destroy(buf, TRUE);
- return (NULL);
-}
-
-/**
- * Make sure this variable is fully expanded.
- */
-static char *
-VarExpand(Var *v, VarParser *vp)
-{
- char *value;
- char *result;
-
- if (v->flags & VAR_IN_USE) {
- Fatal("Variable %s is recursive.", v->name);
- /* NOTREACHED */
- }
-
- v->flags |= VAR_IN_USE;
-
- /*
- * Before doing any modification, we have to make sure the
- * value has been fully expanded. If it looks like recursion
- * might be necessary (there's a dollar sign somewhere in the
- * variable's value) we just call Var_Subst to do any other
- * substitutions that are necessary. Note that the value
- * returned by Var_Subst will have been
- * dynamically-allocated, so it will need freeing when we
- * return.
- */
- value = Buf_Data(v->val);
- if (strchr(value, '$') == NULL) {
- result = strdup(value);
- } else {
- Buffer *buf;
-
- buf = Var_Subst(value, vp->ctxt, vp->err);
- result = Buf_Peel(buf);
- }
-
- v->flags &= ~VAR_IN_USE;
-
- return (result);
-}
-
-/**
- * Select only those words in value that match the modifier.
- */
-static char *
-modifier_M(VarParser *vp, const char value[], char endc)
-{
- char *patt;
- char *ptr;
- char *newValue;
- char modifier;
-
- modifier = vp->ptr[0];
- vp->ptr++; /* consume 'M' or 'N' */
-
- /*
- * Compress the \:'s out of the pattern, so allocate enough
- * room to hold the uncompressed pattern and compress the
- * pattern into that space.
- */
- patt = estrdup(vp->ptr);
- ptr = patt;
- while (vp->ptr[0] != '\0') {
- if (vp->ptr[0] == endc || vp->ptr[0] == ':') {
- break;
- }
- if (vp->ptr[0] == '\\' &&
- (vp->ptr[1] == endc || vp->ptr[1] == ':')) {
- vp->ptr++; /* consume backslash */
- }
- *ptr = vp->ptr[0];
- ptr++;
- vp->ptr++;
- }
- *ptr = '\0';
- DEBUGF(VAR, ("Pattern :%s\n", patt));
-
- if (modifier == 'M') {
- newValue = VarModify(value, VarMatch, patt);
- } else {
- newValue = VarModify(value, VarNoMatch, patt);
- }
- free(patt);
-
- return (newValue);
-}
-
-/**
- * Substitute the replacement string for the pattern. The substitution
- * is applied to each word in value.
- */
-static char *
-modifier_S(VarParser *vp, const char value[], Var *v)
-{
- VarPattern patt;
- char delim;
- char *newValue;
-
- patt.flags = 0;
-
- vp->ptr++; /* consume 'S' */
-
- delim = *vp->ptr; /* used to find end of pattern */
- vp->ptr++; /* consume 1st delim */
-
- /*
- * If pattern begins with '^', it is anchored to the start of the
- * word -- skip over it and flag pattern.
- */
- if (*vp->ptr == '^') {
- patt.flags |= VAR_MATCH_START;
- vp->ptr++;
- }
-
- patt.lhs = VarGetPattern(vp, delim, &patt.flags, NULL);
- if (patt.lhs == NULL) {
- /*
- * LHS didn't end with the delim, complain and exit.
- */
- Fatal("Unclosed substitution for %s (%c missing)",
- v->name, delim);
- }
-
- vp->ptr++; /* consume 2nd delim */
-
- patt.rhs = VarGetPattern(vp, delim, NULL, &patt);
- if (patt.rhs == NULL) {
- /*
- * RHS didn't end with the delim, complain and exit.
- */
- Fatal("Unclosed substitution for %s (%c missing)",
- v->name, delim);
- }
-
- vp->ptr++; /* consume last delim */
-
- /*
- * Check for global substitution. If 'g' after the final delimiter,
- * substitution is global and is marked that way.
- */
- if (vp->ptr[0] == 'g') {
- patt.flags |= VAR_SUB_GLOBAL;
- vp->ptr++;
- }
-
- /*
- * Global substitution of the empty string causes an infinite number
- * of matches, unless anchored by '^' (start of string) or '$' (end
- * of string). Catch the infinite substitution here. Note that flags
- * can only contain the 3 bits we're interested in so we don't have
- * to mask unrelated bits. We can test for equality.
- */
- if (Buf_Size(patt.lhs) == 0 && patt.flags == VAR_SUB_GLOBAL)
- Fatal("Global substitution of the empty string");
-
- newValue = VarModify(value, VarSubstitute, &patt);
-
- /*
- * Free the two strings.
- */
- free(patt.lhs);
- free(patt.rhs);
-
- return (newValue);
-}
-
-static char *
-modifier_C(VarParser *vp, char value[], Var *v)
-{
- VarPattern patt;
- char delim;
- int error;
- char *newValue;
-
- patt.flags = 0;
-
- vp->ptr++; /* consume 'C' */
-
- delim = *vp->ptr; /* delimiter between sections */
-
- vp->ptr++; /* consume 1st delim */
-
- patt.lhs = VarGetPattern(vp, delim, NULL, NULL);
- if (patt.lhs == NULL) {
- Fatal("Unclosed substitution for %s (%c missing)",
- v->name, delim);
- }
-
- vp->ptr++; /* consume 2st delim */
-
- patt.rhs = VarGetPattern(vp, delim, NULL, NULL);
- if (patt.rhs == NULL) {
- Fatal("Unclosed substitution for %s (%c missing)",
- v->name, delim);
- }
-
- vp->ptr++; /* consume last delim */
-
- switch (*vp->ptr) {
- case 'g':
- patt.flags |= VAR_SUB_GLOBAL;
- vp->ptr++; /* consume 'g' */
- break;
- case '1':
- patt.flags |= VAR_SUB_ONE;
- vp->ptr++; /* consume '1' */
- break;
- default:
- break;
- }
-
- error = regcomp(&patt.re, Buf_Data(patt.lhs), REG_EXTENDED);
- if (error) {
- VarREError(error, &patt.re, "RE substitution error");
- free(patt.rhs);
- free(patt.lhs);
- return (var_Error);
- }
-
- patt.nsub = patt.re.re_nsub + 1;
- if (patt.nsub < 1)
- patt.nsub = 1;
- if (patt.nsub > 10)
- patt.nsub = 10;
- patt.matches = emalloc(patt.nsub * sizeof(regmatch_t));
-
- newValue = VarModify(value, VarRESubstitute, &patt);
-
- regfree(&patt.re);
- free(patt.matches);
- free(patt.rhs);
- free(patt.lhs);
-
- return (newValue);
-}
-
-static char *
-sysVvarsub(VarParser *vp, char startc, Var *v, const char value[])
-{
-#ifdef SYSVVARSUB
- /*
- * This can either be a bogus modifier or a System-V substitution
- * command.
- */
- char endc;
- VarPattern patt;
- Boolean eqFound;
- int cnt;
- char *newStr;
- const char *cp;
-
- endc = (startc == OPEN_PAREN) ? CLOSE_PAREN : CLOSE_BRACE;
-
- patt.flags = 0;
-
- /*
- * First we make a pass through the string trying to verify it is a
- * SYSV-make-style translation: it must be: <string1>=<string2>)
- */
- eqFound = FALSE;
- cp = vp->ptr;
- cnt = 1;
- while (*cp != '\0' && cnt) {
- if (*cp == '=') {
- eqFound = TRUE;
- /* continue looking for endc */
- } else if (*cp == endc)
- cnt--;
- else if (*cp == startc)
- cnt++;
- if (cnt)
- cp++;
- }
-
- if (*cp == endc && eqFound) {
- /*
- * Now we break this sucker into the lhs and rhs.
- */
- patt.lhs = VarGetPattern(vp, '=', &patt.flags, NULL);
- if (patt.lhs == NULL) {
- Fatal("Unclosed substitution for %s (%c missing)",
- v->name, '=');
- }
- vp->ptr++; /* consume '=' */
-
- patt.rhs = VarGetPattern(vp, endc, NULL, &patt);
- if (patt.rhs == NULL) {
- Fatal("Unclosed substitution for %s (%c missing)",
- v->name, endc);
- }
-
- /*
- * SYSV modifications happen through the whole string. Note
- * the pattern is anchored at the end.
- */
- newStr = VarModify(value, VarSYSVMatch, &patt);
-
- free(patt.lhs);
- free(patt.rhs);
- } else
-#endif
- {
- Error("Unknown modifier '%c'\n", *vp->ptr);
- vp->ptr++;
- while (*vp->ptr != '\0') {
- if (*vp->ptr == endc && *vp->ptr == ':') {
- break;
- }
- vp->ptr++;
- }
- newStr = var_Error;
- }
-
- return (newStr);
-}
-
-/**
- * Quote shell meta-characters in the string
- *
- * Results:
- * The quoted string
- */
-static char *
-Var_Quote(const char *str)
-{
- Buffer *buf;
- /* This should cover most shells :-( */
- static char meta[] = "\n \t'`\";&<>()|*?{}[]\\$!#^~";
-
- buf = Buf_Init(MAKE_BSIZE);
- for (; *str; str++) {
- if (strchr(meta, *str) != NULL)
- Buf_AddByte(buf, (Byte)'\\');
- Buf_AddByte(buf, (Byte)*str);
- }
-
- return (Buf_Peel(buf));
-}
-
-
-/*
- * Now we need to apply any modifiers the user wants applied.
- * These are:
- * :M<pattern>
- * words which match the given <pattern>.
- * <pattern> is of the standard file
- * wildcarding form.
- * :N<pattern>
- * words which do not match the given <pattern>
- * <pattern> is of the standard file
- * wildcarding form.
- * :S<d><pat1><d><pat2><d>[g]
- * Substitute <pat2> for <pat1> in the value
- * :C<d><pat1><d><pat2><d>[g]
- * Substitute <pat2> for regex <pat1> in the value
- * :H Substitute the head of each word
- * :T Substitute the tail of each word
- * :E Substitute the extension (minus '.') of
- * each word
- * :R Substitute the root of each word
- * (pathname minus the suffix).
- * :lhs=rhs
- * Like :S, but the rhs goes to the end of
- * the invocation.
- * :U Converts variable to upper-case.
- * :L Converts variable to lower-case.
- * :O ("Order") Alphabeticaly sort words in variable.
- * :u ("uniq") Remove adjacent duplicate words.
- */
-static char *
-ParseModifier(VarParser *vp, char startc, Var *v, Boolean *freeResult)
-{
- char *value;
- char endc;
-
- value = VarExpand(v, vp);
- *freeResult = TRUE;
-
- endc = (startc == OPEN_PAREN) ? CLOSE_PAREN : CLOSE_BRACE;
-
- vp->ptr++; /* consume first colon */
-
- while (*vp->ptr != '\0') {
- char *newStr; /* New value to return */
-
- if (*vp->ptr == endc) {
- return (value);
- }
-
- DEBUGF(VAR, ("Applying :%c to \"%s\"\n", *vp->ptr, value));
- switch (*vp->ptr) {
- case 'N':
- case 'M':
- newStr = modifier_M(vp, value, endc);
- break;
- case 'S':
- newStr = modifier_S(vp, value, v);
- break;
- case 'C':
- newStr = modifier_C(vp, value, v);
- break;
- case 't':
- /* :tl :tu for OSF ODE & NetBSD make compatibility */
- switch (vp->ptr[1]) {
- case 'l':
- vp->ptr++;
- goto mod_lower;
- break;
- case 'u':
- vp->ptr++;
- goto mod_upper;
- break;
- }
- /* FALLTHROUGH */
- default:
- if (vp->ptr[1] != endc && vp->ptr[1] != ':') {
-#ifdef SUNSHCMD
- if ((vp->ptr[0] == 's') &&
- (vp->ptr[1] == 'h') &&
- (vp->ptr[2] == endc || vp->ptr[2] == ':')) {
- const char *error = NULL;
-
- if (vp->execute) {
- newStr = Buf_Peel(
- Cmd_Exec(value, &error));
- } else {
- newStr = estrdup("");
- }
-
- if (error)
- Error(error, value);
- vp->ptr += 2;
- } else
-#endif
- {
- newStr = sysVvarsub(vp, startc, v, value);
- }
- break;
- }
-
- switch (vp->ptr[0]) {
- case 'L':
- mod_lower:
- {
- const char *cp;
- Buffer *buf;
- buf = Buf_Init(MAKE_BSIZE);
- for (cp = value; *cp; cp++)
- Buf_AddByte(buf, (Byte)tolower(*cp));
-
- newStr = Buf_Peel(buf);
-
- vp->ptr++;
- break;
- }
- case 'O':
- newStr = VarSortWords(value, SortIncreasing);
- vp->ptr++;
- break;
- case 'Q':
- newStr = Var_Quote(value);
- vp->ptr++;
- break;
- case 'T':
- newStr = VarModify(value, VarTail, NULL);
- vp->ptr++;
- break;
- case 'U':
- mod_upper:
- {
- const char *cp;
- Buffer *buf;
- buf = Buf_Init(MAKE_BSIZE);
- for (cp = value; *cp; cp++)
- Buf_AddByte(buf, (Byte)toupper(*cp));
-
- newStr = Buf_Peel(buf);
-
- vp->ptr++;
- break;
- }
- case 'H':
- newStr = VarModify(value, VarHead, NULL);
- vp->ptr++;
- break;
- case 'E':
- newStr = VarModify(value, VarSuffix, NULL);
- vp->ptr++;
- break;
- case 'R':
- newStr = VarModify(value, VarRoot, NULL);
- vp->ptr++;
- break;
- case 'u':
- newStr = VarUniq(value);
- vp->ptr++;
- break;
- default:
- newStr = sysVvarsub(vp, startc, v, value);
- break;
- }
- break;
- }
-
- DEBUGF(VAR, ("Result is \"%s\"\n", newStr));
- if (*freeResult) {
- free(value);
- }
-
- value = newStr;
- *freeResult = (value == var_Error) ? FALSE : TRUE;
-
- if (vp->ptr[0] == ':') {
- vp->ptr++; /* consume colon */
- }
- }
-
- return (value);
-}
-
-static char *
-ParseRestModifier(VarParser *vp, char startc, Buffer *buf, Boolean *freeResult)
-{
- const char *vname;
- size_t vlen;
- Var *v;
- char *value;
-
- vname = Buf_GetAll(buf, &vlen);
-
- v = VarFindAny(vname, vp->ctxt);
- if (v != NULL) {
- value = ParseModifier(vp, startc, v, freeResult);
- return (value);
- }
-
- if ((vp->ctxt == VAR_CMD) || (vp->ctxt == VAR_GLOBAL)) {
- size_t consumed;
- /*
- * Still need to get to the end of the variable
- * specification, so kludge up a Var structure for the
- * modifications
- */
- v = VarCreate(vname, NULL, VAR_JUNK);
- value = ParseModifier(vp, startc, v, freeResult);
- if (*freeResult) {
- free(value);
- }
- VarDestroy(v, TRUE);
-
- consumed = vp->ptr - vp->input + 1;
- /*
- * If substituting a local variable in a non-local context,
- * assume it's for dynamic source stuff. We have to handle
- * this specially and return the longhand for the variable
- * with the dollar sign escaped so it makes it back to the
- * caller. Only four of the local variables are treated
- * specially as they are the only four that will be set when
- * dynamic sources are expanded.
- */
- if (vlen == 1 ||
- (vlen == 2 && (vname[1] == 'F' || vname[1] == 'D'))) {
- if (strchr("!%*@", vname[0]) != NULL) {
- value = emalloc(consumed + 1);
- strncpy(value, vp->input, consumed);
- value[consumed] = '\0';
-
- *freeResult = TRUE;
- return (value);
- }
- }
- if (vlen > 2 &&
- vname[0] == '.' &&
- isupper((unsigned char)vname[1])) {
- if ((strncmp(vname, ".TARGET", vlen - 1) == 0) ||
- (strncmp(vname, ".ARCHIVE", vlen - 1) == 0) ||
- (strncmp(vname, ".PREFIX", vlen - 1) == 0) ||
- (strncmp(vname, ".MEMBER", vlen - 1) == 0)) {
- value = emalloc(consumed + 1);
- strncpy(value, vp->input, consumed);
- value[consumed] = '\0';
-
- *freeResult = TRUE;
- return (value);
- }
- }
-
- *freeResult = FALSE;
- return (vp->err ? var_Error : varNoError);
- } else {
- /*
- * Check for D and F forms of local variables since we're in
- * a local context and the name is the right length.
- */
- if (vlen == 2 &&
- (vname[1] == 'F' || vname[1] == 'D') &&
- (strchr("!%*<>@", vname[0]) != NULL)) {
- char name[2];
-
- name[0] = vname[0];
- name[1] = '\0';
-
- v = VarFindOnly(name, vp->ctxt);
- if (v != NULL) {
- value = ParseModifier(vp, startc, v, freeResult);
- return (value);
- }
- }
-
- /*
- * Still need to get to the end of the variable
- * specification, so kludge up a Var structure for the
- * modifications
- */
- v = VarCreate(vname, NULL, VAR_JUNK);
- value = ParseModifier(vp, startc, v, freeResult);
- if (*freeResult) {
- free(value);
- }
- VarDestroy(v, TRUE);
-
- *freeResult = FALSE;
- return (vp->err ? var_Error : varNoError);
- }
-}
-
-static char *
-ParseRestEnd(VarParser *vp, Buffer *buf, Boolean *freeResult)
-{
- const char *vname;
- size_t vlen;
- Var *v;
- char *value;
-
- vname = Buf_GetAll(buf, &vlen);
-
- v = VarFindAny(vname, vp->ctxt);
- if (v != NULL) {
- value = VarExpand(v, vp);
- *freeResult = TRUE;
- return (value);
- }
-
- if ((vp->ctxt == VAR_CMD) || (vp->ctxt == VAR_GLOBAL)) {
- size_t consumed = vp->ptr - vp->input + 1;
-
- /*
- * If substituting a local variable in a non-local context,
- * assume it's for dynamic source stuff. We have to handle
- * this specially and return the longhand for the variable
- * with the dollar sign escaped so it makes it back to the
- * caller. Only four of the local variables are treated
- * specially as they are the only four that will be set when
- * dynamic sources are expanded.
- */
- if (vlen == 1 ||
- (vlen == 2 && (vname[1] == 'F' || vname[1] == 'D'))) {
- if (strchr("!%*@", vname[0]) != NULL) {
- value = emalloc(consumed + 1);
- strncpy(value, vp->input, consumed);
- value[consumed] = '\0';
-
- *freeResult = TRUE;
- return (value);
- }
- }
- if (vlen > 2 &&
- vname[0] == '.' &&
- isupper((unsigned char)vname[1])) {
- if ((strncmp(vname, ".TARGET", vlen - 1) == 0) ||
- (strncmp(vname, ".ARCHIVE", vlen - 1) == 0) ||
- (strncmp(vname, ".PREFIX", vlen - 1) == 0) ||
- (strncmp(vname, ".MEMBER", vlen - 1) == 0)) {
- value = emalloc(consumed + 1);
- strncpy(value, vp->input, consumed);
- value[consumed] = '\0';
-
- *freeResult = TRUE;
- return (value);
- }
- }
- } else {
- /*
- * Check for D and F forms of local variables since we're in
- * a local context and the name is the right length.
- */
- if (vlen == 2 &&
- (vname[1] == 'F' || vname[1] == 'D') &&
- (strchr("!%*<>@", vname[0]) != NULL)) {
- char name[2];
-
- name[0] = vname[0];
- name[1] = '\0';
-
- v = VarFindOnly(name, vp->ctxt);
- if (v != NULL) {
- char *val;
- /*
- * No need for nested expansion or anything,
- * as we're the only one who sets these
- * things and we sure don't put nested
- * invocations in them...
- */
- val = Buf_Data(v->val);
-
- if (vname[1] == 'D') {
- val = VarModify(val, VarHead, NULL);
- } else {
- val = VarModify(val, VarTail, NULL);
- }
-
- *freeResult = TRUE;
- return (val);
- }
- }
- }
-
- *freeResult = FALSE;
- return (vp->err ? var_Error : varNoError);
-}
-
-/**
- * Parse a multi letter variable name, and return it's value.
- */
-static char *
-VarParseLong(VarParser *vp, Boolean *freeResult)
-{
- Buffer *buf;
- char startc;
- char endc;
- char *value;
-
- buf = Buf_Init(MAKE_BSIZE);
-
- startc = vp->ptr[0];
- vp->ptr++; /* consume opening paren or brace */
-
- endc = (startc == OPEN_PAREN) ? CLOSE_PAREN : CLOSE_BRACE;
-
- /*
- * Process characters until we reach an end character or a colon,
- * replacing embedded variables as we go.
- */
- while (*vp->ptr != '\0') {
- if (*vp->ptr == endc) {
- value = ParseRestEnd(vp, buf, freeResult);
- vp->ptr++; /* consume closing paren or brace */
- Buf_Destroy(buf, TRUE);
- return (value);
-
- } else if (*vp->ptr == ':') {
- value = ParseRestModifier(vp, startc, buf, freeResult);
- vp->ptr++; /* consume closing paren or brace */
- Buf_Destroy(buf, TRUE);
- return (value);
-
- } else if (*vp->ptr == '$') {
- VarParser subvp = {
- vp->ptr,
- vp->ptr,
- vp->ctxt,
- vp->err,
- vp->execute
- };
- char *rval;
- Boolean rfree;
-
- rval = VarParse(&subvp, &rfree);
- if (rval == var_Error) {
- Fatal("Error expanding embedded variable.");
- }
- Buf_Append(buf, rval);
- if (rfree)
- free(rval);
- vp->ptr = subvp.ptr;
- } else {
- Buf_AddByte(buf, (Byte)*vp->ptr);
- vp->ptr++;
- }
- }
-
- /* If we did not find the end character, return var_Error */
- Buf_Destroy(buf, TRUE);
- *freeResult = FALSE;
- return (var_Error);
-}
-
-/**
- * Parse a single letter variable name, and return it's value.
- */
-static char *
-VarParseShort(VarParser *vp, Boolean *freeResult)
-{
- char vname[2];
- Var *v;
- char *value;
-
- vname[0] = vp->ptr[0];
- vname[1] = '\0';
-
- vp->ptr++; /* consume single letter */
-
- v = VarFindAny(vname, vp->ctxt);
- if (v != NULL) {
- value = VarExpand(v, vp);
- *freeResult = TRUE;
- return (value);
- }
-
- /*
- * If substituting a local variable in a non-local context, assume
- * it's for dynamic source stuff. We have to handle this specially
- * and return the longhand for the variable with the dollar sign
- * escaped so it makes it back to the caller. Only four of the local
- * variables are treated specially as they are the only four that
- * will be set when dynamic sources are expanded.
- */
- if ((vp->ctxt == VAR_CMD) || (vp->ctxt == VAR_GLOBAL)) {
-
- /* XXX: It looks like $% and $! are reversed here */
- switch (vname[0]) {
- case '@':
- *freeResult = TRUE;
- return (estrdup("$(.TARGET)"));
- case '%':
- *freeResult = TRUE;
- return (estrdup("$(.ARCHIVE)"));
- case '*':
- *freeResult = TRUE;
- return (estrdup("$(.PREFIX)"));
- case '!':
- *freeResult = TRUE;
- return (estrdup("$(.MEMBER)"));
- default:
- *freeResult = FALSE;
- return (vp->err ? var_Error : varNoError);
- }
- }
-
- /* Variable name was not found. */
- *freeResult = FALSE;
- return (vp->err ? var_Error : varNoError);
-}
-
-static char *
-VarParse(VarParser *vp, Boolean *freeResult)
-{
-
- vp->ptr++; /* consume '$' or last letter of conditional */
-
- if (vp->ptr[0] == '\0') {
- /* Error, there is only a dollar sign in the input string. */
- *freeResult = FALSE;
- return (vp->err ? var_Error : varNoError);
-
- } else if (vp->ptr[0] == OPEN_PAREN || vp->ptr[0] == OPEN_BRACE) {
- /* multi letter variable name */
- return (VarParseLong(vp, freeResult));
-
- } else {
- /* single letter variable name */
- return (VarParseShort(vp, freeResult));
- }
-}
-
-/**
- * Given the start of a variable invocation, extract the variable
- * name and find its value, then modify it according to the
- * specification.
- *
- * Results:
- * The value of the variable or var_Error if the specification
- * is invalid. The number of characters in the specification
- * is placed in the variable pointed to by consumed. (for
- * invalid specifications, this is just 2 to skip the '$' and
- * the following letter, or 1 if '$' was the last character
- * in the string). A Boolean in *freeResult telling whether the
- * returned string should be freed by the caller.
- */
-char *
-Var_Parse(const char input[], GNode *ctxt, Boolean err,
- size_t *consumed, Boolean *freeResult)
-{
- VarParser vp = {
- input,
- input,
- ctxt,
- err,
- TRUE
- };
- char *value;
-
- value = VarParse(&vp, freeResult);
- *consumed += vp.ptr - vp.input;
- return (value);
-}
-
-/*
- * Given the start of a variable invocation, determine the length
- * of the specification.
- *
- * Results:
- * The number of characters in the specification. For invalid
- * specifications, this is just 2 to skip the '$' and the
- * following letter, or 1 if '$' was the last character in the
- * string.
- */
-size_t
-Var_Match(const char input[], GNode *ctxt)
-{
- VarParser vp = {
- input,
- input,
- ctxt,
- FALSE,
- FALSE
- };
- char *value;
- Boolean freeResult;
-
- value = VarParse(&vp, &freeResult);
- if (freeResult) {
- free(value);
- }
- return (vp.ptr - vp.input);
-}
-
-static int
-match_var(const char str[], const char var[])
-{
- const char *start = str;
- size_t len;
-
- str++; /* consume '$' */
-
- if (str[0] == OPEN_PAREN || str[0] == OPEN_BRACE) {
- str++; /* consume opening paren or brace */
-
- while (str[0] != '\0') {
- if (str[0] == '$') {
- /*
- * A variable inside the variable. We cannot
- * expand the external variable yet.
- */
- return (str - start);
- } else if (str[0] == ':' ||
- str[0] == CLOSE_PAREN ||
- str[0] == CLOSE_BRACE) {
- len = str - (start + 2);
-
- if (strncmp(var, start + 2, len) == 0 && var[len] == '\0') {
- return (0); /* match */
- } else {
- /*
- * Not the variable we want to
- * expand.
- */
- return (str - start);
- }
- } else {
- ++str;
- }
- }
- return (str - start);
- } else {
- /* Single letter variable name */
- if (var[1] == '\0' && var[0] == str[0]) {
- return (0); /* match */
- } else {
- str++; /* consume variable name */
- return (str - start);
- }
- }
-}
-
-/**
- * Substitute for all variables in the given string in the given
- * context If err is TRUE, Parse_Error will be called when an
- * undefined variable is encountered.
- *
- * Results:
- * The resulting string.
- *
- * Side Effects:
- * None. The old string must be freed by the caller
- */
-Buffer *
-Var_Subst(const char *str, GNode *ctxt, Boolean err)
-{
- Boolean errorReported;
- Buffer *buf; /* Buffer for forming things */
-
- /*
- * Set TRUE if an error has already been reported to prevent a
- * plethora of messages when recursing. XXXHB this comment sounds
- * wrong.
- */
- errorReported = FALSE;
-
- buf = Buf_Init(0);
- while (str[0] != '\0') {
- if ((str[0] == '$') && (str[1] == '$')) {
- /*
- * A dollar sign may be escaped with another dollar
- * sign. In such a case, we skip over the escape
- * character and store the dollar sign into the
- * buffer directly.
- */
- str++;
- Buf_AddByte(buf, (Byte)str[0]);
- str++;
-
- } else if (str[0] == '$') {
- /* Variable invocation. */
- VarParser subvp = {
- str,
- str,
- ctxt,
- err,
- TRUE
- };
- char *rval;
- Boolean rfree;
-
- rval = VarParse(&subvp, &rfree);
-
- /*
- * When we come down here, val should either point to
- * the value of this variable, suitably modified, or
- * be NULL. Length should be the total length of the
- * potential variable invocation (from $ to end
- * character...)
- */
- if (rval == var_Error || rval == varNoError) {
- /*
- * If performing old-time variable
- * substitution, skip over the variable and
- * continue with the substitution. Otherwise,
- * store the dollar sign and advance str so
- * we continue with the string...
- */
- if (oldVars) {
- str = subvp.ptr;
- } else if (err) {
- /*
- * If variable is undefined, complain
- * and skip the variable. The
- * complaint will stop us from doing
- * anything when the file is parsed.
- */
- if (!errorReported) {
- Parse_Error(PARSE_FATAL,
- "Undefined variable \"%.*s\"", subvp.ptr - subvp.input, str);
- }
- errorReported = TRUE;
- str = subvp.ptr;
- } else {
- Buf_AddByte(buf, (Byte)str[0]);
- str++;
- }
- } else {
- /*
- * Copy all the characters from the variable
- * value straight into the new string.
- */
- Buf_Append(buf, rval);
- if (rfree) {
- free(rval);
- }
- str = subvp.ptr;
- }
- } else {
- Buf_AddByte(buf, (Byte)str[0]);
- str++;
- }
- }
-
- return (buf);
-}
-
-/**
- * Substitute for all variables except if it is the same as 'var',
- * in the given string in the given context. If err is TRUE,
- * Parse_Error will be called when an undefined variable is
- * encountered.
- *
- * Results:
- * The resulting string.
- *
- * Side Effects:
- * None. The old string must be freed by the caller
- */
-Buffer *
-Var_SubstOnly(const char *var, const char *str, Boolean err)
-{
- GNode *ctxt = VAR_GLOBAL;
- Boolean errorReported;
- Buffer *buf; /* Buffer for forming things */
-
- /*
- * Set TRUE if an error has already been reported to prevent a
- * plethora of messages when recursing. XXXHB this comment sounds
- * wrong.
- */
- errorReported = FALSE;
-
- buf = Buf_Init(0);
- while (str[0] != '\0') {
- if (str[0] == '$') {
- int skip;
-
- skip = match_var(str, var);
- if (skip > 0) {
- Buf_AddBytes(buf, skip, str);
- str += skip;
- } else {
- /* Variable invocation. */
- VarParser subvp = {
- str,
- str,
- ctxt,
- err,
- TRUE
- };
- char *rval;
- Boolean rfree;
-
- rval = VarParse(&subvp, &rfree);
-
- /*
- * When we get down here, rval should either
- * point to the value of this variable, or be
- * NULL.
- */
- if (rval == var_Error || rval == varNoError) {
- /*
- * If performing old-time variable
- * substitution, skip over the
- * variable and continue with the
- * substitution. Otherwise, store the
- * dollar sign and advance str so we
- * continue with the string...
- */
- if (oldVars) {
- str = subvp.ptr;
- } else if (err) {
- /*
- * If variable is undefined,
- * complain and skip the
- * variable. The complaint
- * will stop us from doing
- * anything when the file is
- * parsed.
- */
- if (!errorReported) {
- Parse_Error(PARSE_FATAL,
- "Undefined variable \"%.*s\"", subvp.ptr - subvp.input, str);
- }
- errorReported = TRUE;
- str = subvp.ptr;
- } else {
- Buf_AddByte(buf, (Byte)str[0]);
- str++;
- }
- } else {
- /*
- * Copy all the characters from the
- * variable value straight into the
- * new string.
- */
- Buf_Append(buf, rval);
- if (rfree) {
- free(rval);
- }
- str = subvp.ptr;
- }
- }
- } else {
- Buf_AddByte(buf, (Byte)str[0]);
- str++;
- }
- }
-
- return (buf);
-}
-
-/**
- * Initialize the module
- *
- * Side Effects:
- * The VAR_CMD and VAR_GLOBAL contexts are created
- */
-void
-Var_Init(char **env)
-{
- char **ptr;
-
- VAR_CMD = Targ_NewGN("Command");
- VAR_ENV = Targ_NewGN("Environment");
- VAR_GLOBAL = Targ_NewGN("Global");
-
- /*
- * Copy user environment variables into ENV context.
- */
- for (ptr = env; *ptr != NULL; ++ptr) {
- char *tmp = estrdup(*ptr);
- const char *name = tmp;
- char *sep = strchr(name, '=');
- const char *value = sep + 1;
-
- if (sep != NULL) {
- *sep = '\0';
- VarAdd(name, value, VAR_ENV);
- }
- free(tmp);
- }
-}
-
-/**
- * Print all variables in global and command line contexts.
- */
-void
-Var_Dump(void)
-{
- const LstNode *ln;
- const Var *v;
-
- printf("#*** Global Variables:\n");
- LST_FOREACH(ln, &VAR_GLOBAL->context) {
- v = Lst_Datum(ln);
- printf("%-16s = %s\n", v->name, Buf_Data(v->val));
- }
-
- printf("#*** Command-line Variables:\n");
- LST_FOREACH(ln, &VAR_CMD->context) {
- v = Lst_Datum(ln);
- printf("%-16s = %s\n", v->name, Buf_Data(v->val));
- }
-}
-
-/**
- * Print the values of any variables requested by
- * the user.
- */
-void
-Var_Print(Lst *vlist, Boolean expandVars)
-{
- LstNode *n;
- char *name;
-
- LST_FOREACH(n, vlist) {
- name = Lst_Datum(n);
- if (expandVars) {
- char *value;
- char *v;
-
- if (*name == '$') {
- v = name;
- } else {
- v = emalloc(strlen(name) + 1 + 3);
- sprintf(v, "${%s}", name);
- }
- value = Buf_Peel(Var_Subst(v, VAR_GLOBAL, FALSE));
- printf("%s\n", value);
-
- if (v != name)
- free(v);
- free(value);
- } else {
- const char *value = Var_Value(name, VAR_GLOBAL);
- printf("%s\n", value != NULL ? value : "");
- }
- }
-}
-
diff --git a/usr.bin/make/var.h b/usr.bin/make/var.h
deleted file mode 100644
index 618cf7a..0000000
--- a/usr.bin/make/var.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/*-
- * Copyright (c) 2002 Juli Mallett.
- * Copyright (c) 1988, 1989, 1990, 1993
- * The Regents of the University of California. All rights reserved.
- * Copyright (c) 1989 by Berkeley Softworks
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Adam de Boor.
- *
- * 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.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
- *
- * $FreeBSD$
- */
-
-#ifndef var_h_9cccafce
-#define var_h_9cccafce
-
-struct Buffer;
-struct GNode;
-struct List;
-
-/* Variables defined in a global context, e.g in the Makefile itself */
-extern struct GNode *VAR_GLOBAL;
-
-/* Variables defined on the command line */
-extern struct GNode *VAR_CMD;
-
-/*
- * Value returned by Var_Parse when an error is encountered. It actually
- * points to an empty string, so naive callers needn't worry about it.
- */
-extern char var_Error[];
-
-/*
- * TRUE if environment should be searched for all variables before
- * the global context
- */
-extern Boolean checkEnvFirst;
-
-/* Do old-style variable substitution */
-extern Boolean oldVars;
-
-void Var_Append(const char *, const char *, struct GNode *);
-void Var_Delete(const char *, struct GNode *);
-void Var_Dump(void);
-Boolean Var_Exists(const char *, struct GNode *);
-void Var_Init(char **);
-size_t Var_Match(const char [], struct GNode *);
-char *Var_Parse(const char *, struct GNode *, Boolean, size_t *, Boolean *);
-void Var_Print(struct Lst *, Boolean);
-void Var_Set(const char *, const char *, struct GNode *);
-void Var_SetGlobal(const char *, const char *);
-void Var_SetEnv(const char *, struct GNode *);
-struct Buffer *Var_Subst(const char *, struct GNode *, Boolean);
-struct Buffer *Var_SubstOnly(const char *, const char *, Boolean);
-const char *Var_Value(const char [], struct GNode *);
-
-#endif /* var_h_9cccafce */
diff --git a/usr.bin/mandoc/Makefile.depend b/usr.bin/mandoc/Makefile.depend
index 66bb233..e3848e3 100644
--- a/usr.bin/mandoc/Makefile.depend
+++ b/usr.bin/mandoc/Makefile.depend
@@ -12,6 +12,7 @@ DIRDEPS = \
lib/libohash \
lib/libsqlite3 \
lib/libthr \
+ lib/libz \
.include <dirdeps.mk>
diff --git a/usr.bin/mklocale/Makefile.depend b/usr.bin/mklocale/Makefile.depend
index 00205d3..b3bfc6d 100644
--- a/usr.bin/mklocale/Makefile.depend
+++ b/usr.bin/mklocale/Makefile.depend
@@ -10,6 +10,7 @@ DIRDEPS = \
lib/${CSU_DIR} \
lib/libc \
lib/libcompiler_rt \
+ usr.bin/yacc.host \
.include <dirdeps.mk>
diff --git a/usr.bin/nm/Makefile.depend b/usr.bin/nm/Makefile.depend
new file mode 100644
index 0000000..20f498c
--- /dev/null
+++ b/usr.bin/nm/Makefile.depend
@@ -0,0 +1,21 @@
+# $FreeBSD$
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ gnu/lib/csu \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libcompiler_rt \
+ lib/libdwarf \
+ lib/libelf \
+ lib/libelftc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.bin/readelf/Makefile.depend b/usr.bin/readelf/Makefile.depend
new file mode 100644
index 0000000..20f498c
--- /dev/null
+++ b/usr.bin/readelf/Makefile.depend
@@ -0,0 +1,21 @@
+# $FreeBSD$
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ gnu/lib/csu \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libcompiler_rt \
+ lib/libdwarf \
+ lib/libelf \
+ lib/libelftc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.bin/make/Makefile.depend b/usr.bin/size/Makefile.depend
index 2f3ce42..40241f3 100644
--- a/usr.bin/make/Makefile.depend
+++ b/usr.bin/size/Makefile.depend
@@ -1,15 +1,16 @@
# $FreeBSD$
# Autogenerated - do NOT edit!
-DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
-
-DEP_MACHINE := ${.PARSEFILE:E}
-
DIRDEPS = \
+ gnu/lib/csu \
+ gnu/lib/libgcc \
include \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
+ lib/libcompiler_rt \
+ lib/libelf \
+ lib/libelftc \
.include <dirdeps.mk>
diff --git a/usr.bin/sockstat/sockstat.c b/usr.bin/sockstat/sockstat.c
index a1edd34..991b074 100644
--- a/usr.bin/sockstat/sockstat.c
+++ b/usr.bin/sockstat/sockstat.c
@@ -255,6 +255,26 @@ sockaddr(struct sockaddr_storage *sa, int af, void *addr, int port)
}
static void
+free_socket(struct sock *sock)
+{
+ struct addr *cur, *next;
+
+ cur = sock->laddr;
+ while (cur != NULL) {
+ next = cur->next;
+ free(cur);
+ cur = next;
+ }
+ cur = sock->faddr;
+ while (cur != NULL) {
+ next = cur->next;
+ free(cur);
+ cur = next;
+ }
+ free(sock);
+}
+
+static void
gather_sctp(void)
{
struct sock *sock;
@@ -366,14 +386,17 @@ gather_sctp(void)
while (offset < len) {
xstcb = (struct xsctp_tcb *)(void *)(buf + offset);
offset += sizeof(struct xsctp_tcb);
- if (no_stcb &&
- opt_l &&
- (!opt_L || !local_all_loopback) &&
- ((xinpcb->flags & SCTP_PCB_FLAGS_UDPTYPE) ||
- (xstcb->last == 1))) {
- hash = (int)((uintptr_t)sock->socket % HASHSIZE);
- sock->next = sockhash[hash];
- sockhash[hash] = sock;
+ if (no_stcb) {
+ if (opt_l &&
+ (!opt_L || !local_all_loopback) &&
+ ((xinpcb->flags & SCTP_PCB_FLAGS_UDPTYPE) ||
+ (xstcb->last == 1))) {
+ hash = (int)((uintptr_t)sock->socket % HASHSIZE);
+ sock->next = sockhash[hash];
+ sockhash[hash] = sock;
+ } else {
+ free_socket(sock);
+ }
}
if (xstcb->last == 1)
break;
@@ -476,11 +499,14 @@ gather_sctp(void)
prev_faddr->next = faddr;
prev_faddr = faddr;
}
- if (opt_c &&
- (!opt_L || !(local_all_loopback || foreign_all_loopback))) {
- hash = (int)((uintptr_t)sock->socket % HASHSIZE);
- sock->next = sockhash[hash];
- sockhash[hash] = sock;
+ if (opt_c) {
+ if (!opt_L || !(local_all_loopback || foreign_all_loopback)) {
+ hash = (int)((uintptr_t)sock->socket % HASHSIZE);
+ sock->next = sockhash[hash];
+ sockhash[hash] = sock;
+ } else {
+ free_socket(sock);
+ }
}
}
xinpcb = (struct xsctp_inpcb *)(void *)(buf + offset);
@@ -865,6 +891,7 @@ displaysock(struct sock *s, int pos)
void *p;
int hash;
struct addr *laddr, *faddr;
+ struct sock *s_tmp;
while (pos < 29)
pos += xprintf(" ");
@@ -908,18 +935,20 @@ displaysock(struct sock *s, int pos)
}
pos += xprintf("-> ");
for (hash = 0; hash < HASHSIZE; ++hash) {
- for (s = sockhash[hash]; s != NULL; s = s->next)
- if (s->pcb == p)
+ for (s_tmp = sockhash[hash];
+ s_tmp != NULL;
+ s_tmp = s_tmp->next)
+ if (s_tmp->pcb == p)
break;
- if (s != NULL)
+ if (s_tmp != NULL)
break;
}
- if (s == NULL ||
- s->laddr == NULL ||
- s->laddr->address.ss_len == 0)
+ if (s_tmp == NULL ||
+ s_tmp->laddr == NULL ||
+ s_tmp->laddr->address.ss_len == 0)
pos += xprintf("??");
else
- pos += printaddr(&s->laddr->address);
+ pos += printaddr(&s_tmp->laddr->address);
break;
default:
abort();
diff --git a/usr.bin/sort/Makefile.depend b/usr.bin/sort/Makefile.depend
index bbb63ce..0940f16 100644
--- a/usr.bin/sort/Makefile.depend
+++ b/usr.bin/sort/Makefile.depend
@@ -2,7 +2,6 @@
# Autogenerated - do NOT edit!
DIRDEPS = \
- bin/cat.host \
gnu/lib/csu \
gnu/lib/libgcc \
include \
diff --git a/usr.bin/strings/Makefile.depend b/usr.bin/strings/Makefile.depend
new file mode 100644
index 0000000..40241f3
--- /dev/null
+++ b/usr.bin/strings/Makefile.depend
@@ -0,0 +1,20 @@
+# $FreeBSD$
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ gnu/lib/csu \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libcompiler_rt \
+ lib/libelf \
+ lib/libelftc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.bin/top/Makefile.depend b/usr.bin/top/Makefile.depend
index 9d6b4ed..4a6d98d 100644
--- a/usr.bin/top/Makefile.depend
+++ b/usr.bin/top/Makefile.depend
@@ -2,7 +2,6 @@
# Autogenerated - do NOT edit!
DIRDEPS = \
- bin/cat.host \
gnu/lib/csu \
gnu/lib/libgcc \
include \
diff --git a/usr.bin/truss/Makefile.depend.amd64 b/usr.bin/truss/Makefile.depend.amd64
index f14f937..fa75c7d 100644
--- a/usr.bin/truss/Makefile.depend.amd64
+++ b/usr.bin/truss/Makefile.depend.amd64
@@ -2,7 +2,6 @@
# Autogenerated - do NOT edit!
DIRDEPS = \
- bin/cat.host \
gnu/lib/csu \
gnu/lib/libgcc \
include \
diff --git a/usr.bin/xinstall/Makefile.depend.host b/usr.bin/xinstall/Makefile.depend.host
index 35734ab..abd0b21 100644
--- a/usr.bin/xinstall/Makefile.depend.host
+++ b/usr.bin/xinstall/Makefile.depend.host
@@ -2,6 +2,7 @@
# Autogenerated - do NOT edit!
DIRDEPS = \
+ gnu/usr.bin/binutils/ld \
lib/libmd \
diff --git a/usr.bin/xlint/lint1/Makefile.depend b/usr.bin/xlint/lint1/Makefile.depend
index b252e82..22a5556 100644
--- a/usr.bin/xlint/lint1/Makefile.depend
+++ b/usr.bin/xlint/lint1/Makefile.depend
@@ -2,7 +2,6 @@
# Autogenerated - do NOT edit!
DIRDEPS = \
- bin/cat.host \
gnu/lib/csu \
gnu/lib/libgcc \
include \
diff --git a/usr.bin/xlint/llib/Makefile.depend b/usr.bin/xlint/llib/Makefile.depend
index f80275d..19a3979 100644
--- a/usr.bin/xlint/llib/Makefile.depend
+++ b/usr.bin/xlint/llib/Makefile.depend
@@ -2,6 +2,9 @@
# Autogenerated - do NOT edit!
DIRDEPS = \
+ include \
+ lib/msun \
+ usr.bin/xlint/xlint.host \
.include <dirdeps.mk>
diff --git a/usr.sbin/bhyve/Makefile b/usr.sbin/bhyve/Makefile
index 70b7041..5a923e0 100644
--- a/usr.sbin/bhyve/Makefile
+++ b/usr.sbin/bhyve/Makefile
@@ -14,6 +14,7 @@ SRCS= \
acpi.c \
bhyverun.c \
block_if.c \
+ bootrom.c \
consport.c \
dbgport.c \
inout.c \
diff --git a/usr.sbin/bhyve/bhyve.8 b/usr.sbin/bhyve/bhyve.8
index ee0f2ca..c5de82a 100644
--- a/usr.sbin/bhyve/bhyve.8
+++ b/usr.sbin/bhyve/bhyve.8
@@ -32,7 +32,7 @@
.Nd "run a guest operating system inside a virtual machine"
.Sh SYNOPSIS
.Nm
-.Op Fl abehuwxACHPWY
+.Op Fl abehuwxACHPSWY
.Op Fl c Ar numcpus
.Op Fl g Ar gdbport
.Op Fl l Ar lpcdev Ns Op , Ns Ar conf
@@ -99,10 +99,12 @@ Yield the virtual CPU thread when a HLT instruction is detected.
If this option is not specified, virtual CPUs will use 100% of a host CPU.
.It Fl l Ar lpcdev Ns Op , Ns Ar conf
Allow devices behind the LPC PCI-ISA bridge to be configured.
-The only supported devices are the TTY-class devices,
-.Li com1
+The only supported devices are the TTY-class devices
+.Ar com1
and
-.Li com2 .
+.Ar com2
+and the boot ROM device
+.Ar bootrom .
.It Fl m Ar size Ns Op Ar K|k|M|m|G|g|T|t
Guest physical memory size in bytes.
This must be the same size that was given to
@@ -165,8 +167,8 @@ AHCI controller attached to a SATA hard-drive.
.It Li uart
PCI 16550 serial device.
.It Li lpc
-LPC PCI-ISA bridge with COM1 and COM2 16550 serial ports. The LPC bridge
-emulation can only be configured on bus 0.
+LPC PCI-ISA bridge with COM1 and COM2 16550 serial ports and a boot ROM.
+The LPC bridge emulation can only be configured on bus 0.
.El
.It Op Ar conf
This optional parameter describes the backend for device emulations.
@@ -224,6 +226,14 @@ the bhyve process.
Use the host TTY device for serial port I/O.
.El
.Pp
+Boot ROM device:
+.Bl -tag -width 10n
+.It Pa romfile
+Map
+.Ar romfile
+in the guest address space reserved for boot firmware.
+.El
+.Pp
Pass-through devices:
.Bl -tag -width 10n
.It Ns Ar slot Ns / Ns Ar bus Ns / Ns Ar function
@@ -235,11 +245,17 @@ and
numbers.
.El
.Pp
+Guest memory must be wired using the
+.Fl S
+option when a pass-through device is configured.
+.Pp
The host device must have been reserved at boot-time using the
.Va pptdev
loader variable as described in
.Xr vmm 4 .
.El
+.It Fl S
+Wire guest memory.
.It Fl u
RTC keeps UTC time.
.It Fl U Ar uuid
diff --git a/usr.sbin/bhyve/bhyverun.c b/usr.sbin/bhyve/bhyverun.c
index ee0f106..cfb3fe4 100644
--- a/usr.sbin/bhyve/bhyverun.c
+++ b/usr.sbin/bhyve/bhyverun.c
@@ -47,6 +47,7 @@ __FBSDID("$FreeBSD$");
#include <pthread.h>
#include <pthread_np.h>
#include <sysexits.h>
+#include <stdbool.h>
#include <machine/vmm.h>
#include <vmmapi.h>
@@ -122,7 +123,7 @@ usage(int code)
{
fprintf(stderr,
- "Usage: %s [-abehuwxACHPWY] [-c vcpus] [-g <gdb port>] [-l <lpc>]\n"
+ "Usage: %s [-abehuwxACHPSWY] [-c vcpus] [-g <gdb port>] [-l <lpc>]\n"
" %*s [-m mem] [-p vcpu:hostcpu] [-s <pci>] [-U uuid] <vm>\n"
" -a: local apic is in xAPIC mode (deprecated)\n"
" -A: create ACPI tables\n"
@@ -137,6 +138,7 @@ usage(int code)
" -p: pin 'vcpu' to 'hostcpu'\n"
" -P: vmexit from the guest on pause\n"
" -s: <slot,driver,configinfo> PCI slot config\n"
+ " -S: guest memory cannot be swapped\n"
" -u: RTC keeps UTC time\n"
" -U: uuid\n"
" -w: ignore unimplemented MSRs\n"
@@ -700,26 +702,82 @@ fbsdrun_set_capabilities(struct vmctx *ctx, int cpu)
vm_set_capability(ctx, cpu, VM_CAP_ENABLE_INVPCID, 1);
}
+static struct vmctx *
+do_open(const char *vmname)
+{
+ struct vmctx *ctx;
+ int error;
+ bool reinit, romboot;
+
+ reinit = romboot = false;
+
+ if (lpc_bootrom())
+ romboot = true;
+
+ error = vm_create(vmname);
+ if (error) {
+ if (errno == EEXIST) {
+ if (romboot) {
+ reinit = true;
+ } else {
+ /*
+ * The virtual machine has been setup by the
+ * userspace bootloader.
+ */
+ }
+ } else {
+ perror("vm_create");
+ exit(1);
+ }
+ } else {
+ if (!romboot) {
+ /*
+ * If the virtual machine was just created then a
+ * bootrom must be configured to boot it.
+ */
+ fprintf(stderr, "virtual machine cannot be booted\n");
+ exit(1);
+ }
+ }
+
+ ctx = vm_open(vmname);
+ if (ctx == NULL) {
+ perror("vm_open");
+ exit(1);
+ }
+
+ if (reinit) {
+ error = vm_reinit(ctx);
+ if (error) {
+ perror("vm_reinit");
+ exit(1);
+ }
+ }
+ return (ctx);
+}
+
int
main(int argc, char *argv[])
{
int c, error, gdb_port, err, bvmcons;
- int dump_guest_memory, max_vcpus, mptgen;
+ int max_vcpus, mptgen, memflags;
int rtc_localtime;
struct vmctx *ctx;
uint64_t rip;
size_t memsize;
+ char *optstr;
bvmcons = 0;
- dump_guest_memory = 0;
progname = basename(argv[0]);
gdb_port = 0;
guest_ncpus = 1;
memsize = 256 * MB;
mptgen = 1;
rtc_localtime = 1;
+ memflags = 0;
- while ((c = getopt(argc, argv, "abehuwxACHIPWYp:g:c:s:m:l:U:")) != -1) {
+ optstr = "abehuwxACHIPSWYp:g:c:s:m:l:U:";
+ while ((c = getopt(argc, argv, optstr)) != -1) {
switch (c) {
case 'a':
x2apic_mode = 0;
@@ -740,7 +798,7 @@ main(int argc, char *argv[])
guest_ncpus = atoi(optarg);
break;
case 'C':
- dump_guest_memory = 1;
+ memflags |= VM_MEM_F_INCORE;
break;
case 'g':
gdb_port = atoi(optarg);
@@ -756,6 +814,9 @@ main(int argc, char *argv[])
exit(1);
else
break;
+ case 'S':
+ memflags |= VM_MEM_F_WIRED;
+ break;
case 'm':
error = vm_parse_memsize(optarg, &memsize);
if (error)
@@ -810,12 +871,7 @@ main(int argc, char *argv[])
usage(1);
vmname = argv[0];
-
- ctx = vm_open(vmname);
- if (ctx == NULL) {
- perror("vm_open");
- exit(1);
- }
+ ctx = do_open(vmname);
if (guest_ncpus < 1) {
fprintf(stderr, "Invalid guest vCPUs (%d)\n", guest_ncpus);
@@ -831,11 +887,10 @@ main(int argc, char *argv[])
fbsdrun_set_capabilities(ctx, BSP);
- if (dump_guest_memory)
- vm_set_memflags(ctx, VM_MEM_F_INCORE);
+ vm_set_memflags(ctx, memflags);
err = vm_setup_memory(ctx, memsize, VM_MMAP_ALL);
if (err) {
- fprintf(stderr, "Unable to setup memory (%d)\n", err);
+ fprintf(stderr, "Unable to setup memory (%d)\n", errno);
exit(1);
}
@@ -865,6 +920,16 @@ main(int argc, char *argv[])
if (bvmcons)
init_bvmcons();
+ if (lpc_bootrom()) {
+ if (vm_set_capability(ctx, BSP, VM_CAP_UNRESTRICTED_GUEST, 1)) {
+ fprintf(stderr, "ROM boot failed: unrestricted guest "
+ "capability not available\n");
+ exit(1);
+ }
+ error = vcpu_reset(ctx, BSP);
+ assert(error == 0);
+ }
+
error = vm_get_register(ctx, BSP, VM_REG_GUEST_RIP, &rip);
assert(error == 0);
diff --git a/usr.sbin/bhyve/bootrom.c b/usr.sbin/bhyve/bootrom.c
new file mode 100644
index 0000000..5e4e0e9
--- /dev/null
+++ b/usr.sbin/bhyve/bootrom.c
@@ -0,0 +1,111 @@
+/*-
+ * Copyright (c) 2015 Neel Natu <neel@freebsd.org>
+ * 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 distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
+ */
+
+#include <sys/param.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/types.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+
+#include <machine/vmm.h>
+
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <stdbool.h>
+
+#include <vmmapi.h>
+#include "bhyverun.h"
+#include "bootrom.h"
+
+#define MAX_BOOTROM_SIZE (16 * 1024 * 1024) /* 16 MB */
+
+int
+bootrom_init(struct vmctx *ctx, const char *romfile)
+{
+ struct stat sbuf;
+ vm_paddr_t gpa;
+ ssize_t rlen;
+ char *ptr;
+ int fd, i, rv, prot;
+
+ rv = -1;
+ fd = open(romfile, O_RDONLY);
+ if (fd < 0) {
+ fprintf(stderr, "Error opening bootrom \"%s\": %s\n",
+ romfile, strerror(errno));
+ goto done;
+ }
+
+ if (fstat(fd, &sbuf) < 0) {
+ fprintf(stderr, "Could not fstat bootrom file \"%s\": %s\n",
+ romfile, strerror(errno));
+ goto done;
+ }
+
+ /*
+ * Limit bootrom size to 16MB so it doesn't encroach into reserved
+ * MMIO space (e.g. APIC, HPET, MSI).
+ */
+ if (sbuf.st_size > MAX_BOOTROM_SIZE || sbuf.st_size < PAGE_SIZE) {
+ fprintf(stderr, "Invalid bootrom size %ld\n", sbuf.st_size);
+ goto done;
+ }
+
+ if (sbuf.st_size & PAGE_MASK) {
+ fprintf(stderr, "Bootrom size %ld is not a multiple of the "
+ "page size\n", sbuf.st_size);
+ goto done;
+ }
+
+ ptr = vm_create_devmem(ctx, VM_BOOTROM, "bootrom", sbuf.st_size);
+ if (ptr == MAP_FAILED)
+ goto done;
+
+ /* Map the bootrom into the guest address space */
+ prot = PROT_READ | PROT_EXEC;
+ gpa = (1ULL << 32) - sbuf.st_size;
+ if (vm_mmap_memseg(ctx, gpa, VM_BOOTROM, 0, sbuf.st_size, prot) != 0)
+ goto done;
+
+ /* Read 'romfile' into the guest address space */
+ for (i = 0; i < sbuf.st_size / PAGE_SIZE; i++) {
+ rlen = read(fd, ptr + i * PAGE_SIZE, PAGE_SIZE);
+ if (rlen != PAGE_SIZE) {
+ fprintf(stderr, "Incomplete read of page %d of bootrom "
+ "file %s: %ld bytes\n", i, romfile, rlen);
+ goto done;
+ }
+ }
+ rv = 0;
+done:
+ if (fd >= 0)
+ close(fd);
+ return (rv);
+}
diff --git a/usr.bin/make/hash_tables.h b/usr.sbin/bhyve/bootrom.h
index 8fa43a5..af150d3 100644
--- a/usr.bin/make/hash_tables.h
+++ b/usr.sbin/bhyve/bootrom.h
@@ -1,6 +1,6 @@
-/*
- * Copyright (C) 2005 Max Okumoto.
- * All rights reserved.
+/*-
+ * Copyright (c) 2015 Neel Natu <neel@freebsd.org>
+ * All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -11,10 +11,10 @@
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
- * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR OR CONTRIBUTORS BE LIABLE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR 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)
@@ -25,12 +25,14 @@
*
* $FreeBSD$
*/
-#ifndef hash_tables_h_
-#define hash_tables_h_
-#include <sys/types.h>
+#ifndef _BOOTROM_H_
+#define _BOOTROM_H_
-int directive_hash(const u_char *, size_t);
-int keyword_hash(const u_char *, size_t);
+#include <stdbool.h>
+
+struct vmctx;
+
+int bootrom_init(struct vmctx *ctx, const char *romfile);
#endif
diff --git a/usr.sbin/bhyve/pci_lpc.c b/usr.sbin/bhyve/pci_lpc.c
index e98b141..2203a00 100644
--- a/usr.sbin/bhyve/pci_lpc.c
+++ b/usr.sbin/bhyve/pci_lpc.c
@@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$");
#include <vmmapi.h>
#include "acpi.h"
+#include "bootrom.h"
#include "inout.h"
#include "pci_emul.h"
#include "pci_irq.h"
@@ -62,6 +63,8 @@ SYSRES_IO(NMISC_PORT, 1);
static struct pci_devinst *lpc_bridge;
+static const char *romfile;
+
#define LPC_UART_NUM 2
static struct lpc_uart_softc {
struct uart_softc *uart_softc;
@@ -76,7 +79,7 @@ static const char *lpc_uart_names[LPC_UART_NUM] = { "COM1", "COM2" };
/*
* LPC device configuration is in the following form:
* <lpc_device_name>[,<options>]
- * For e.g. "com1,stdio"
+ * For e.g. "com1,stdio" or "bootrom,/var/romfile"
*/
int
lpc_device_parse(const char *opts)
@@ -88,6 +91,11 @@ lpc_device_parse(const char *opts)
str = cpy = strdup(opts);
lpcdev = strsep(&str, ",");
if (lpcdev != NULL) {
+ if (strcasecmp(lpcdev, "bootrom") == 0) {
+ romfile = str;
+ error = 0;
+ goto done;
+ }
for (unit = 0; unit < LPC_UART_NUM; unit++) {
if (strcasecmp(lpcdev, lpc_uart_names[unit]) == 0) {
lpc_uart_softc[unit].opts = str;
@@ -104,6 +112,13 @@ done:
return (error);
}
+const char *
+lpc_bootrom(void)
+{
+
+ return (romfile);
+}
+
static void
lpc_uart_intr_assert(void *arg)
{
@@ -156,13 +171,19 @@ lpc_uart_io_handler(struct vmctx *ctx, int vcpu, int in, int port, int bytes,
}
static int
-lpc_init(void)
+lpc_init(struct vmctx *ctx)
{
struct lpc_uart_softc *sc;
struct inout_port iop;
const char *name;
int unit, error;
+ if (romfile != NULL) {
+ error = bootrom_init(ctx, romfile);
+ if (error)
+ return (error);
+ }
+
/* COM1 and COM2 */
for (unit = 0; unit < LPC_UART_NUM; unit++) {
sc = &lpc_uart_softc[unit];
@@ -379,7 +400,7 @@ pci_lpc_init(struct vmctx *ctx, struct pci_devinst *pi, char *opts)
return (-1);
}
- if (lpc_init() != 0)
+ if (lpc_init(ctx) != 0)
return (-1);
/* initialize config space */
diff --git a/usr.sbin/bhyve/pci_lpc.h b/usr.sbin/bhyve/pci_lpc.h
index 55a5865..431f5cf 100644
--- a/usr.sbin/bhyve/pci_lpc.h
+++ b/usr.sbin/bhyve/pci_lpc.h
@@ -68,5 +68,6 @@ struct lpc_sysres {
int lpc_device_parse(const char *opt);
char *lpc_pirq_name(int pin);
void lpc_pirq_routed(void);
+const char *lpc_bootrom(void);
#endif
diff --git a/usr.sbin/bhyve/pci_passthru.c b/usr.sbin/bhyve/pci_passthru.c
index 04d68c4..5b52b05 100644
--- a/usr.sbin/bhyve/pci_passthru.c
+++ b/usr.sbin/bhyve/pci_passthru.c
@@ -548,12 +548,18 @@ done:
static int
passthru_init(struct vmctx *ctx, struct pci_devinst *pi, char *opts)
{
- int bus, slot, func, error;
+ int bus, slot, func, error, memflags;
struct passthru_softc *sc;
sc = NULL;
error = 1;
+ memflags = vm_get_memflags(ctx);
+ if (!(memflags & VM_MEM_F_WIRED)) {
+ fprintf(stderr, "passthru requires guest memory to be wired\n");
+ goto done;
+ }
+
if (pcifd < 0) {
pcifd = open(_PATH_DEVPCI, O_RDWR, 0);
if (pcifd < 0)
diff --git a/usr.sbin/bhyvectl/Makefile b/usr.sbin/bhyvectl/Makefile
index 5c088a3..c48ca6e 100644
--- a/usr.sbin/bhyvectl/Makefile
+++ b/usr.sbin/bhyvectl/Makefile
@@ -8,7 +8,7 @@ PACKAGE= bhyve
MAN=
-LIBADD= vmmapi
+LIBADD= vmmapi util
WARNS?= 3
diff --git a/usr.sbin/bhyvectl/bhyvectl.c b/usr.sbin/bhyvectl/bhyvectl.c
index 7d3017f..51bade1 100644
--- a/usr.sbin/bhyvectl/bhyvectl.c
+++ b/usr.sbin/bhyvectl/bhyvectl.c
@@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$");
#include <sys/sysctl.h>
#include <sys/errno.h>
#include <sys/mman.h>
+#include <sys/cpuset.h>
#include <stdio.h>
#include <stdlib.h>
@@ -47,10 +48,12 @@ __FBSDID("$FreeBSD$");
#include <getopt.h>
#include <time.h>
#include <assert.h>
+#include <libutil.h>
#include <machine/cpufunc.h>
-#include <machine/vmm.h>
#include <machine/specialreg.h>
+#include <machine/vmm.h>
+#include <machine/vmm_dev.h>
#include <vmmapi.h>
#include "amd/vmcb.h"
@@ -236,7 +239,7 @@ static int get_stats, getcap, setcap, capval, get_gpa_pmap;
static int inject_nmi, assert_lapic_lvt;
static int force_reset, force_poweroff;
static const char *capname;
-static int create, destroy, get_lowmem, get_highmem;
+static int create, destroy, get_memmap, get_memseg;
static int get_intinfo;
static int get_active_cpus, get_suspended_cpus;
static uint64_t memsize;
@@ -1320,8 +1323,8 @@ setup_options(bool cpu_intel)
{ "get-desc-gdtr", NO_ARG, &get_desc_gdtr, 1 },
{ "set-desc-idtr", NO_ARG, &set_desc_idtr, 1 },
{ "get-desc-idtr", NO_ARG, &get_desc_idtr, 1 },
- { "get-lowmem", NO_ARG, &get_lowmem, 1 },
- { "get-highmem",NO_ARG, &get_highmem, 1 },
+ { "get-memmap", NO_ARG, &get_memmap, 1 },
+ { "get-memseg", NO_ARG, &get_memseg, 1 },
{ "get-efer", NO_ARG, &get_efer, 1 },
{ "get-cr0", NO_ARG, &get_cr0, 1 },
{ "get-cr3", NO_ARG, &get_cr3, 1 },
@@ -1520,18 +1523,92 @@ mon_str(int idx)
return ("UNK");
}
+static int
+show_memmap(struct vmctx *ctx)
+{
+ char name[SPECNAMELEN + 1], numbuf[8];
+ vm_ooffset_t segoff;
+ vm_paddr_t gpa;
+ size_t maplen, seglen;
+ int error, flags, prot, segid, delim;
+
+ printf("Address Length Segment Offset ");
+ printf("Prot Flags\n");
+
+ gpa = 0;
+ while (1) {
+ error = vm_mmap_getnext(ctx, &gpa, &segid, &segoff, &maplen,
+ &prot, &flags);
+ if (error)
+ return (errno == ENOENT ? 0 : error);
+
+ error = vm_get_memseg(ctx, segid, &seglen, name, sizeof(name));
+ if (error)
+ return (error);
+
+ printf("%-12lX", gpa);
+ humanize_number(numbuf, sizeof(numbuf), maplen, "B",
+ HN_AUTOSCALE, HN_NOSPACE);
+ printf("%-12s", numbuf);
+
+ printf("%-12s", name[0] ? name : "sysmem");
+ printf("%-12lX", segoff);
+ printf("%c%c%c ", prot & PROT_READ ? 'R' : '-',
+ prot & PROT_WRITE ? 'W' : '-',
+ prot & PROT_EXEC ? 'X' : '-');
+
+ delim = '\0';
+ if (flags & VM_MEMMAP_F_WIRED) {
+ printf("%cwired", delim);
+ delim = '/';
+ }
+ if (flags & VM_MEMMAP_F_IOMMU) {
+ printf("%ciommu", delim);
+ delim = '/';
+ }
+ printf("\n");
+
+ gpa += maplen;
+ }
+}
+
+static int
+show_memseg(struct vmctx *ctx)
+{
+ char name[SPECNAMELEN + 1], numbuf[8];
+ size_t seglen;
+ int error, segid;
+
+ printf("ID Length Name\n");
+
+ segid = 0;
+ while (1) {
+ error = vm_get_memseg(ctx, segid, &seglen, name, sizeof(name));
+ if (error)
+ return (errno == EINVAL ? 0 : error);
+
+ if (seglen) {
+ printf("%-4d", segid);
+ humanize_number(numbuf, sizeof(numbuf), seglen, "B",
+ HN_AUTOSCALE, HN_NOSPACE);
+ printf("%-12s", numbuf);
+ printf("%s", name[0] ? name : "sysmem");
+ printf("\n");
+ }
+ segid++;
+ }
+}
+
int
main(int argc, char *argv[])
{
char *vmname;
int error, ch, vcpu, ptenum;
- vm_paddr_t gpa, gpa_pmap;
- size_t len;
+ vm_paddr_t gpa_pmap;
struct vm_exit vmexit;
uint64_t rax, cr0, cr3, cr4, dr7, rsp, rip, rflags, efer, pat;
uint64_t eptp, bm, addr, u64, pteval[4], *pte, info[2];
struct vmctx *ctx;
- int wired;
cpuset_t cpus;
bool cpu_intel;
uint64_t cs, ds, es, fs, gs, ss, tr, ldtr;
@@ -1703,7 +1780,7 @@ main(int argc, char *argv[])
}
if (!error && memsize)
- error = vm_setup_memory(ctx, memsize, VM_MMAP_NONE);
+ error = vm_setup_memory(ctx, memsize, VM_MMAP_ALL);
if (!error && set_efer)
error = vm_set_register(ctx, vcpu, VM_REG_GUEST_EFER, efer);
@@ -1838,21 +1915,11 @@ main(int argc, char *argv[])
error = vm_lapic_local_irq(ctx, vcpu, assert_lapic_lvt);
}
- if (!error && (get_lowmem || get_all)) {
- gpa = 0;
- error = vm_get_memory_seg(ctx, gpa, &len, &wired);
- if (error == 0)
- printf("lowmem\t\t0x%016lx/%ld%s\n", gpa, len,
- wired ? " wired" : "");
- }
+ if (!error && (get_memseg || get_all))
+ error = show_memseg(ctx);
- if (!error && (get_highmem || get_all)) {
- gpa = 4 * GB;
- error = vm_get_memory_seg(ctx, gpa, &len, &wired);
- if (error == 0)
- printf("highmem\t\t0x%016lx/%ld%s\n", gpa, len,
- wired ? " wired" : "");
- }
+ if (!error && (get_memmap || get_all))
+ error = show_memmap(ctx);
if (!error)
error = get_all_registers(ctx, vcpu);
diff --git a/usr.sbin/bhyveload/bhyveload.8 b/usr.sbin/bhyveload/bhyveload.8
index c168832..fc9c8e1 100644
--- a/usr.sbin/bhyveload/bhyveload.8
+++ b/usr.sbin/bhyveload/bhyveload.8
@@ -35,6 +35,7 @@
guest inside a bhyve virtual machine
.Sh SYNOPSIS
.Nm
+.Op Fl S
.Op Fl c Ar cons-dev
.Op Fl d Ar disk-path
.Op Fl e Ar name=value
@@ -111,8 +112,10 @@ respectively.
The default value of
.Ar mem-size
is 256M.
-.El
+.It Fl S
+Wire guest memory.
.Sh EXAMPLES
+.El
To create a virtual machine named
.Ar freebsd-vm
that boots off the ISO image
diff --git a/usr.sbin/bhyveload/bhyveload.c b/usr.sbin/bhyveload/bhyveload.c
index 8ebf116..8178bb2 100644
--- a/usr.sbin/bhyveload/bhyveload.c
+++ b/usr.sbin/bhyveload/bhyveload.c
@@ -629,7 +629,7 @@ usage(void)
{
fprintf(stderr,
- "usage: %s [-c <console-device>] [-d <disk-path>] [-e <name=value>]\n"
+ "usage: %s [-S][-c <console-device>] [-d <disk-path>] [-e <name=value>]\n"
" %*s [-h <host-path>] [-m mem-size] <vmname>\n",
progname,
(int)strlen(progname), "");
@@ -642,16 +642,17 @@ main(int argc, char** argv)
void *h;
void (*func)(struct loader_callbacks *, void *, int, int);
uint64_t mem_size;
- int opt, error, need_reinit;
+ int opt, error, need_reinit, memflags;
progname = basename(argv[0]);
+ memflags = 0;
mem_size = 256 * MB;
consin_fd = STDIN_FILENO;
consout_fd = STDOUT_FILENO;
- while ((opt = getopt(argc, argv, "c:d:e:h:m:")) != -1) {
+ while ((opt = getopt(argc, argv, "Sc:d:e:h:m:")) != -1) {
switch (opt) {
case 'c':
error = altcons_open(optarg);
@@ -678,6 +679,9 @@ main(int argc, char** argv)
if (error != 0)
errx(EX_USAGE, "Invalid memsize '%s'", optarg);
break;
+ case 'S':
+ memflags |= VM_MEM_F_WIRED;
+ break;
case '?':
usage();
}
@@ -715,6 +719,7 @@ main(int argc, char** argv)
}
}
+ vm_set_memflags(ctx, memflags);
error = vm_setup_memory(ctx, mem_size, VM_MMAP_ALL);
if (error) {
perror("vm_setup_memory");
diff --git a/usr.sbin/bsdconfig/usermgmt/share/group.subr b/usr.sbin/bsdconfig/usermgmt/share/group.subr
index fb320d1..e9c8b16 100644
--- a/usr.sbin/bsdconfig/usermgmt/share/group.subr
+++ b/usr.sbin/bsdconfig/usermgmt/share/group.subr
@@ -82,9 +82,9 @@ f_group_add()
#
# NB: pw(8) has a ``feature'' wherein `-n name' can be taken as GID
# instead of name. Work-around is to also pass `-g GID' at the same
- # time (any GID will do; but `-1' is appropriate for this context).
+ # time (the GID is ignored in this case, so any GID will do).
#
- if [ "$input" ] && f_quietly pw groupshow -n "$input" -g -1; then
+ if [ "$input" ] && f_quietly pw groupshow -n "$input" -g 1337; then
f_show_err "$msg_group_already_used" "$input"
return $FAILURE
fi
@@ -182,7 +182,7 @@ f_group_add()
1) # Group Name (prompt for new group name)
f_dialog_input_group_name input "$group_name" ||
continue
- if f_quietly pw groupshow -n "$input" -g -1; then
+ if f_quietly pw groupshow -n "$input" -g 1337; then
f_show_err "$msg_group_already_used" "$input"
continue
fi
@@ -368,9 +368,9 @@ f_group_edit()
#
# NB: pw(8) has a ``feature'' wherein `-n name' can be taken as GID
# instead of name. Work-around is to also pass `-g GID' at the same
- # time (any GID will do; but `-1' is appropriate for this context).
+ # time (the GID is ignored in this case, so any GID will do).
#
- if [ "$input" ] && ! f_quietly pw groupshow -n "$input" -g -1; then
+ if [ "$input" ] && ! f_quietly pw groupshow -n "$input" -g 1337; then
f_show_err "$msg_group_not_found" "$input"
return $FAILURE
fi
diff --git a/usr.sbin/bsdconfig/usermgmt/share/user.subr b/usr.sbin/bsdconfig/usermgmt/share/user.subr
index d0e3887..27d9d66 100644
--- a/usr.sbin/bsdconfig/usermgmt/share/user.subr
+++ b/usr.sbin/bsdconfig/usermgmt/share/user.subr
@@ -231,9 +231,9 @@ f_user_add()
#
# NB: pw(8) has a ``feature'' wherein `-n name' can be taken as UID
# instead of name. Work-around is to also pass `-u UID' at the same
- # time (any UID will do; but `-1' is appropriate for this context).
+ # time (the UID is ignored in this case, so any UID will do).
#
- if [ "$input" ] && f_quietly pw usershow -n "$input" -u -1; then
+ if [ "$input" ] && f_quietly pw usershow -n "$input" -u 1337; then
f_show_err "$msg_login_already_used" "$input"
return $FAILURE
fi
@@ -414,7 +414,7 @@ f_user_add()
1) # Login (prompt for new login name)
f_dialog_input_name input "$user_name" ||
continue
- if f_quietly pw usershow -n "$input" -u -1; then
+ if f_quietly pw usershow -n "$input" -u 1337; then
f_show_err "$msg_login_already_used" "$input"
continue
fi
@@ -920,9 +920,9 @@ f_user_edit()
#
# NB: pw(8) has a ``feature'' wherein `-n name' can be taken as UID
# instead of name. Work-around is to also pass `-u UID' at the same
- # time (any UID will do; but `-1' is appropriate for this context).
+ # time (the UID is ignored in this case, so any UID will do).
#
- if [ "$input" ] && ! f_quietly pw usershow -n "$input" -u -1; then
+ if [ "$input" ] && ! f_quietly pw usershow -n "$input" -u 1337; then
f_show_err "$msg_login_not_found" "$input"
return $FAILURE
fi
diff --git a/usr.sbin/bsnmpd/modules/snmp_atm/Makefile.depend b/usr.sbin/bsnmpd/modules/snmp_atm/Makefile.depend
index a511f26..06b5e37 100644
--- a/usr.sbin/bsnmpd/modules/snmp_atm/Makefile.depend
+++ b/usr.sbin/bsnmpd/modules/snmp_atm/Makefile.depend
@@ -2,7 +2,6 @@
# Autogenerated - do NOT edit!
DIRDEPS = \
- bin/cat.host \
gnu/lib/csu \
gnu/lib/libgcc \
include \
diff --git a/usr.sbin/bsnmpd/modules/snmp_bridge/Makefile.depend b/usr.sbin/bsnmpd/modules/snmp_bridge/Makefile.depend
index 24fcca9..7d1ccb6 100644
--- a/usr.sbin/bsnmpd/modules/snmp_bridge/Makefile.depend
+++ b/usr.sbin/bsnmpd/modules/snmp_bridge/Makefile.depend
@@ -2,7 +2,6 @@
# Autogenerated - do NOT edit!
DIRDEPS = \
- bin/cat.host \
gnu/lib/csu \
gnu/lib/libgcc \
include \
diff --git a/usr.sbin/bsnmpd/modules/snmp_hostres/Makefile.depend b/usr.sbin/bsnmpd/modules/snmp_hostres/Makefile.depend
index d6b14d8..64bb2df 100644
--- a/usr.sbin/bsnmpd/modules/snmp_hostres/Makefile.depend
+++ b/usr.sbin/bsnmpd/modules/snmp_hostres/Makefile.depend
@@ -2,7 +2,6 @@
# Autogenerated - do NOT edit!
DIRDEPS = \
- bin/cat.host \
gnu/lib/csu \
gnu/lib/libgcc \
include \
diff --git a/usr.sbin/bsnmpd/modules/snmp_lm75/Makefile.depend b/usr.sbin/bsnmpd/modules/snmp_lm75/Makefile.depend
index 98ed0f6..ea1a0a5 100644
--- a/usr.sbin/bsnmpd/modules/snmp_lm75/Makefile.depend
+++ b/usr.sbin/bsnmpd/modules/snmp_lm75/Makefile.depend
@@ -2,7 +2,6 @@
# Autogenerated - do NOT edit!
DIRDEPS = \
- bin/cat.host \
gnu/lib/csu \
gnu/lib/libgcc \
include \
diff --git a/usr.sbin/bsnmpd/modules/snmp_mibII/Makefile.depend b/usr.sbin/bsnmpd/modules/snmp_mibII/Makefile.depend
index 25da87b..8e546b0 100644
--- a/usr.sbin/bsnmpd/modules/snmp_mibII/Makefile.depend
+++ b/usr.sbin/bsnmpd/modules/snmp_mibII/Makefile.depend
@@ -2,7 +2,6 @@
# Autogenerated - do NOT edit!
DIRDEPS = \
- bin/cat.host \
gnu/lib/csu \
gnu/lib/libgcc \
include \
diff --git a/usr.sbin/bsnmpd/modules/snmp_netgraph/Makefile.depend b/usr.sbin/bsnmpd/modules/snmp_netgraph/Makefile.depend
index 547a1b8..19bbcd5 100644
--- a/usr.sbin/bsnmpd/modules/snmp_netgraph/Makefile.depend
+++ b/usr.sbin/bsnmpd/modules/snmp_netgraph/Makefile.depend
@@ -2,7 +2,6 @@
# Autogenerated - do NOT edit!
DIRDEPS = \
- bin/cat.host \
gnu/lib/csu \
gnu/lib/libgcc \
include \
diff --git a/usr.sbin/bsnmpd/modules/snmp_pf/Makefile.depend b/usr.sbin/bsnmpd/modules/snmp_pf/Makefile.depend
index 868588e..6843d75 100644
--- a/usr.sbin/bsnmpd/modules/snmp_pf/Makefile.depend
+++ b/usr.sbin/bsnmpd/modules/snmp_pf/Makefile.depend
@@ -2,7 +2,6 @@
# Autogenerated - do NOT edit!
DIRDEPS = \
- bin/cat.host \
gnu/lib/csu \
gnu/lib/libgcc \
include \
diff --git a/usr.sbin/bsnmpd/modules/snmp_target/Makefile.depend b/usr.sbin/bsnmpd/modules/snmp_target/Makefile.depend
index 7b6ccee..c8536c4 100644
--- a/usr.sbin/bsnmpd/modules/snmp_target/Makefile.depend
+++ b/usr.sbin/bsnmpd/modules/snmp_target/Makefile.depend
@@ -2,7 +2,6 @@
# Autogenerated - do NOT edit!
DIRDEPS = \
- bin/cat.host \
gnu/lib/csu \
gnu/lib/libgcc \
include \
diff --git a/usr.sbin/bsnmpd/modules/snmp_usm/Makefile.depend b/usr.sbin/bsnmpd/modules/snmp_usm/Makefile.depend
index 143eb6b..2e9a3fe 100644
--- a/usr.sbin/bsnmpd/modules/snmp_usm/Makefile.depend
+++ b/usr.sbin/bsnmpd/modules/snmp_usm/Makefile.depend
@@ -2,7 +2,6 @@
# Autogenerated - do NOT edit!
DIRDEPS = \
- bin/cat.host \
gnu/lib/csu \
gnu/lib/libgcc \
include \
diff --git a/usr.sbin/bsnmpd/modules/snmp_vacm/Makefile.depend b/usr.sbin/bsnmpd/modules/snmp_vacm/Makefile.depend
index c3e56fe..25501c8 100644
--- a/usr.sbin/bsnmpd/modules/snmp_vacm/Makefile.depend
+++ b/usr.sbin/bsnmpd/modules/snmp_vacm/Makefile.depend
@@ -2,7 +2,6 @@
# Autogenerated - do NOT edit!
DIRDEPS = \
- bin/cat.host \
gnu/lib/csu \
gnu/lib/libgcc \
include \
diff --git a/usr.sbin/bsnmpd/modules/snmp_wlan/Makefile.depend b/usr.sbin/bsnmpd/modules/snmp_wlan/Makefile.depend
index 5e42346..80b1aea 100644
--- a/usr.sbin/bsnmpd/modules/snmp_wlan/Makefile.depend
+++ b/usr.sbin/bsnmpd/modules/snmp_wlan/Makefile.depend
@@ -2,7 +2,6 @@
# Autogenerated - do NOT edit!
DIRDEPS = \
- bin/cat.host \
gnu/lib/csu \
gnu/lib/libgcc \
include \
diff --git a/usr.sbin/crunch/crunchgen/Makefile.depend b/usr.sbin/crunch/crunchgen/Makefile.depend
index 11f6434..f384605 100644
--- a/usr.sbin/crunch/crunchgen/Makefile.depend
+++ b/usr.sbin/crunch/crunchgen/Makefile.depend
@@ -2,7 +2,6 @@
# Autogenerated - do NOT edit!
DIRDEPS = \
- bin/cat.host \
gnu/lib/csu \
gnu/lib/libgcc \
include \
diff --git a/usr.sbin/ctld/token.l b/usr.sbin/ctld/token.l
index 54b803b..caf59cc 100644
--- a/usr.sbin/ctld/token.l
+++ b/usr.sbin/ctld/token.l
@@ -80,7 +80,7 @@ target { return TARGET; }
timeout { return TIMEOUT; }
\"[^"]+\" { yylval.str = strndup(yytext + 1,
strlen(yytext) - 2); return STR; }
-[a-zA-Z0-9\.\-_/\:\[\]]+ { yylval.str = strdup(yytext); return STR; }
+[a-zA-Z0-9\.\-@_/\:\[\]]+ { yylval.str = strdup(yytext); return STR; }
\{ { return OPENING_BRACKET; }
\} { return CLOSING_BRACKET; }
#.*$ /* ignore comments */;
diff --git a/usr.sbin/fstyp/Makefile b/usr.sbin/fstyp/Makefile
index d0b14d1..d1de06e 100644
--- a/usr.sbin/fstyp/Makefile
+++ b/usr.sbin/fstyp/Makefile
@@ -1,9 +1,41 @@
# $FreeBSD$
+.include <src.opts.mk>
+
PROG= fstyp
-SRCS= fstyp.c ext2fs.c cd9660.c msdosfs.c ntfs.c ufs.c
+SRCS= cd9660.c ext2fs.c fstyp.c geli.c msdosfs.c ntfs.c ufs.c
+
+.if ${MK_CDDL} != "no"
+SRCS += zfs.c
+.endif
+
MAN= fstyp.8
WARNS= 6
+.if ${MK_CDDL} != "no"
+IGNORE_PRAGMA= YES
+
+CFLAGS+= -DNEED_SOLARIS_BOOLEAN -DHAVE_CDDL
+CFLAGS+= -I${.CURDIR}/../../sys/cddl/compat/opensolaris
+CFLAGS+= -I${.CURDIR}/../../cddl/compat/opensolaris/include
+CFLAGS+= -I${.CURDIR}/../../cddl/compat/opensolaris/lib/libumem
+CFLAGS+= -I${.CURDIR}/../../cddl/contrib/opensolaris/lib/libnvpair
+CFLAGS+= -I${.CURDIR}/../../cddl/contrib/opensolaris/lib/libzpool/common
+CFLAGS+= -I${.CURDIR}/../../sys/cddl/contrib/opensolaris/uts/common/fs/zfs
+CFLAGS+= -I${.CURDIR}/../../sys/cddl/contrib/opensolaris/uts/common
+CFLAGS+= -I${.CURDIR}/../../sys/cddl/contrib/opensolaris/uts/common/sys
+CFLAGS+= -I${.CURDIR}/../../cddl/contrib/opensolaris/head
+.endif
+
+CFLAGS+=-I${.CURDIR}/../../sys
+
+DPADD= ${LIBGEOM} ${LIBMD}
+LDADD= -lgeom -lmd
+
+.if ${MK_CDDL} != "no"
+DPADD += ${LIBNVPAIR} ${LIBZFS}
+LDADD += -lnvpair -lzfs
+.endif
+
.include <bsd.prog.mk>
diff --git a/usr.sbin/fstyp/cd9660.c b/usr.sbin/fstyp/cd9660.c
index ee6af11..658af33 100644
--- a/usr.sbin/fstyp/cd9660.c
+++ b/usr.sbin/fstyp/cd9660.c
@@ -45,7 +45,6 @@ int
fstyp_cd9660(FILE *fp, char *label, size_t size)
{
char *sector, *volume;
- int i;
sector = read_buf(fp, ISO9660_OFFSET, 512);
if (sector == NULL)
@@ -58,13 +57,6 @@ fstyp_cd9660(FILE *fp, char *label, size_t size)
bzero(label, size);
strlcpy(label, volume, MIN(size, VOLUME_LEN));
free(sector);
- for (i = size - 1; i > 0; i--) {
- if (label[i] == '\0')
- continue;
- else if (label[i] == ' ')
- label[i] = '\0';
- else
- break;
- }
+ rtrim(label, size);
return (0);
}
diff --git a/usr.sbin/fstyp/fstyp.8 b/usr.sbin/fstyp/fstyp.8
index 5223f81..981a8d3 100644
--- a/usr.sbin/fstyp/fstyp.8
+++ b/usr.sbin/fstyp/fstyp.8
@@ -27,7 +27,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd January 14, 2015
+.Dd June 15, 2015
.Dt FSTYP 8
.Os
.Sh NAME
@@ -37,20 +37,42 @@
.Nm
.Op Fl l
.Op Fl s
+.Op Fl u
.Ar special
.Sh DESCRIPTION
The
.Nm
utility is used to determine the filesystem type on a given device.
It can recognize ISO-9660, Ext2, FAT, NTFS, and UFS filesystems.
+When the
+.Fl u
+flag is specified,
+.Nm
+also recognizes certain additional metadata formats that cannot be
+handled using
+.Xr mount 8 ,
+such as ZFS pools and
+.Xr geli 8
+providers.
+.Pp
The filesystem name is printed to the standard output
-as, respectively,
-.Li cd9660 ,
-.Li ext2fs ,
-.Li msdosfs ,
-.Li ntfs ,
-or
-.Li ufs .
+as, respectively:
+.Bl -item -offset indent -compact
+.It
+cd9660
+.It
+ext2fs
+.It
+geli
+.It
+msdosfs
+.It
+ntfs
+.It
+ufs
+.It
+zfs
+.El
.Pp
Because
.Nm
@@ -73,6 +95,9 @@ By default,
only works on regular files and disk-like device nodes.
Trying to read other file types might have unexpected consequences or hang
indefinitely.
+.It Fl u
+Include filesystems and devices that cannot be mounted directly by
+.Xr mount 8 .
.El
.Sh EXIT STATUS
The
@@ -82,8 +107,11 @@ type is not recognized.
.Sh SEE ALSO
.Xr file 1 ,
.Xr capsicum 4 ,
+.Xr autofs 8 ,
+.Xr geli 8 ,
.Xr glabel 8 ,
-.Xr mount 8
+.Xr mount 8 ,
+.Xr zpool 8
.Sh HISTORY
The
.Nm
@@ -95,3 +123,5 @@ The
utility was developed by
.An Edward Tomasz Napierala Aq Mt trasz@FreeBSD.org
under sponsorship from the FreeBSD Foundation.
+ZFS and GELI support was added by
+.An Allan Jude Aq Mt allanjude@FreeBSD.org
diff --git a/usr.sbin/fstyp/fstyp.c b/usr.sbin/fstyp/fstyp.c
index d6a48f6..95218ca 100644
--- a/usr.sbin/fstyp/fstyp.c
+++ b/usr.sbin/fstyp/fstyp.c
@@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$");
#include <err.h>
#include <errno.h>
#include <stdbool.h>
+#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
@@ -54,13 +55,18 @@ typedef int (*fstyp_function)(FILE *, char *, size_t);
static struct {
const char *name;
fstyp_function function;
+ bool unmountable;
} fstypes[] = {
- { "cd9660", &fstyp_cd9660 },
- { "ext2fs", &fstyp_ext2fs },
- { "msdosfs", &fstyp_msdosfs },
- { "ntfs", &fstyp_ntfs },
- { "ufs", &fstyp_ufs },
- { NULL, NULL }
+ { "cd9660", &fstyp_cd9660, false },
+ { "ext2fs", &fstyp_ext2fs, false },
+ { "geli", &fstyp_geli, true },
+ { "msdosfs", &fstyp_msdosfs, false },
+ { "ntfs", &fstyp_ntfs, false },
+ { "ufs", &fstyp_ufs, false },
+#ifdef HAVE_CDDL
+ { "zfs", &fstyp_zfs, true },
+#endif
+ { NULL, NULL, NULL }
};
void *
@@ -104,11 +110,26 @@ checked_strdup(const char *s)
return (c);
}
+void
+rtrim(char *label, size_t size)
+{
+ ptrdiff_t i;
+
+ for (i = size - 1; i >= 0; i--) {
+ if (label[i] == '\0')
+ continue;
+ else if (label[i] == ' ')
+ label[i] = '\0';
+ else
+ break;
+ }
+}
+
static void
usage(void)
{
- fprintf(stderr, "usage: fstyp [-l][-s] special\n");
+ fprintf(stderr, "usage: fstyp [-l] [-s] [-u] special\n");
exit(1);
}
@@ -137,13 +158,13 @@ int
main(int argc, char **argv)
{
int ch, error, i, nbytes;
- bool ignore_type = false, show_label = false;
+ bool ignore_type = false, show_label = false, show_unmountable = false;
char label[LABEL_LEN + 1], strvised[LABEL_LEN * 4 + 1];
char *path;
FILE *fp;
fstyp_function fstyp_f;
- while ((ch = getopt(argc, argv, "ls")) != -1) {
+ while ((ch = getopt(argc, argv, "lsu")) != -1) {
switch (ch) {
case 'l':
show_label = true;
@@ -151,6 +172,9 @@ main(int argc, char **argv)
case 's':
ignore_type = true;
break;
+ case 'u':
+ show_unmountable = true;
+ break;
default:
usage();
}
@@ -177,6 +201,8 @@ main(int argc, char **argv)
memset(label, '\0', sizeof(label));
for (i = 0;; i++) {
+ if (show_unmountable == false && fstypes[i].unmountable == true)
+ continue;
fstyp_f = fstypes[i].function;
if (fstyp_f == NULL)
break;
diff --git a/usr.sbin/fstyp/fstyp.h b/usr.sbin/fstyp/fstyp.h
index 4474ffe..ca778ba 100644
--- a/usr.sbin/fstyp/fstyp.h
+++ b/usr.sbin/fstyp/fstyp.h
@@ -36,11 +36,16 @@
void *read_buf(FILE *fp, off_t off, size_t len);
char *checked_strdup(const char *s);
+void rtrim(char *label, size_t size);
int fstyp_cd9660(FILE *fp, char *label, size_t size);
int fstyp_ext2fs(FILE *fp, char *label, size_t size);
+int fstyp_geli(FILE *fp, char *label, size_t size);
int fstyp_msdosfs(FILE *fp, char *label, size_t size);
int fstyp_ntfs(FILE *fp, char *label, size_t size);
int fstyp_ufs(FILE *fp, char *label, size_t size);
+#ifdef HAVE_CDDL
+int fstyp_zfs(FILE *fp, char *label, size_t size);
+#endif
#endif /* !FSTYP_H */
diff --git a/usr.bin/make/for.h b/usr.sbin/fstyp/geli.c
index 0e43c4a..1c15ca6 100644
--- a/usr.bin/make/for.h
+++ b/usr.sbin/fstyp/geli.c
@@ -1,11 +1,9 @@
/*-
- * Copyright (c) 1988, 1989, 1990, 1993
- * The Regents of the University of California. All rights reserved.
- * Copyright (c) 1989 by Berkeley Softworks
+ * Copyright (c) 2015 Allan Jude <allanjude@FreeBSD.org>
* All rights reserved.
*
- * This code is derived from software contributed to Berkeley by
- * Adam de Boor.
+ * This software was developed by Edward Tomasz Napierala under sponsorship
+ * from the FreeBSD Foundation.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -15,18 +13,11 @@
* 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.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * 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 REGENTS OR CONTRIBUTORS BE LIABLE
+ * 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)
@@ -34,17 +25,52 @@
* 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.
- *
- * $FreeBSD$
*/
-#ifndef for_h_9d770f33
-#define for_h_9d770f33
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/disk.h>
+#include <sys/types.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <geom/eli/g_eli.h>
+
+#include "fstyp.h"
+
+int
+fstyp_geli(FILE *fp, char *label __unused, size_t labelsize __unused)
+{
+ int error;
+ off_t mediasize;
+ u_int sectorsize;
+ struct g_eli_metadata md;
+ u_char *buf;
+
+ error = ioctl(fileno(fp), DIOCGMEDIASIZE, &mediasize);
+ if (error != 0)
+ return (1);
+ error = ioctl(fileno(fp), DIOCGSECTORSIZE, &sectorsize);
+ if (error != 0)
+ return (1);
+ buf = (u_char *)read_buf(fp, mediasize - sectorsize, sectorsize);
+ if (buf == NULL)
+ goto gelierr;
+ error = eli_metadata_decode(buf, &md);
+ if (error)
+ goto gelierr;
-#include "util.h"
+ if (strncmp(md.md_magic, "GEOM::ELI", 9) == 0) {
+ free(buf);
+ return (0);
+ }
-Boolean For_For(char *);
-Boolean For_Eval(char *);
-void For_Run(int);
+gelierr:
+ free(buf);
-#endif /* for_h_9d770f33 */
+ return (1);
+}
diff --git a/usr.sbin/fstyp/msdosfs.c b/usr.sbin/fstyp/msdosfs.c
index b299243..3d86802 100644
--- a/usr.sbin/fstyp/msdosfs.c
+++ b/usr.sbin/fstyp/msdosfs.c
@@ -48,7 +48,6 @@ fstyp_msdosfs(FILE *fp, char *label, size_t size)
FAT32_BSBPB *pfat32_bsbpb;
FAT_DES *pfat_entry;
uint8_t *sector0, *sector;
- uint32_t i;
sector0 = NULL;
sector = NULL;
@@ -161,14 +160,7 @@ fstyp_msdosfs(FILE *fp, char *label, size_t size)
}
endofchecks:
- for (i = size - 1; i > 0; i--) {
- if (label[i] == '\0')
- continue;
- else if (label[i] == ' ')
- label[i] = '\0';
- else
- break;
- }
+ rtrim(label, size);
free(sector0);
free(sector);
diff --git a/usr.sbin/fstyp/zfs.c b/usr.sbin/fstyp/zfs.c
new file mode 100644
index 0000000..9d91db6
--- /dev/null
+++ b/usr.sbin/fstyp/zfs.c
@@ -0,0 +1,73 @@
+/*-
+ * Copyright (c) 2015 Allan Jude <allanjude@FreeBSD.org>
+ * All rights reserved.
+ *
+ * This software was developed by Edward Tomasz Napierala under sponsorship
+ * from the FreeBSD Foundation.
+ *
+ * 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.
+ *
+ * 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/types.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <libnvpair.h>
+#include <sys/vdev_impl.h>
+
+#include "fstyp.h"
+
+int
+fstyp_zfs(FILE *fp, char *label, size_t labelsize)
+{
+ vdev_label_t *zpool_ptr = NULL;
+ vdev_label_t zpool_label;
+ char *buf = zpool_label.vl_vdev_phys.vp_nvlist;
+ char *zpool_name = NULL;
+ size_t buflen = sizeof (zpool_label.vl_vdev_phys.vp_nvlist);
+ nvlist_t *config = NULL;
+
+ zpool_ptr = (vdev_label_t *)read_buf(fp, 0, sizeof(zpool_label));
+ if (zpool_ptr == NULL)
+ return (1);
+ zpool_label = *zpool_ptr;
+ if (nvlist_unpack(buf, buflen, &config, 0) != 0)
+ goto zfserr;
+ if (nvlist_lookup_string(config, "name", &zpool_name) != 0)
+ goto zfserr;
+ strlcpy(label, zpool_name, labelsize);
+ nvlist_free(config);
+ free(zpool_ptr);
+ return (0);
+
+zfserr:
+ nvlist_free(config);
+ free(zpool_ptr);
+
+ return (1);
+}
diff --git a/usr.sbin/nologin/Makefile.depend b/usr.sbin/nologin/Makefile.depend
index cae7e64..9cb890b 100644
--- a/usr.sbin/nologin/Makefile.depend
+++ b/usr.sbin/nologin/Makefile.depend
@@ -3,6 +3,7 @@
DIRDEPS = \
gnu/lib/csu \
+ gnu/lib/libgcc \
include \
lib/${CSU_DIR} \
lib/libc \
diff --git a/usr.sbin/ntp/libntp/Makefile.depend b/usr.sbin/ntp/libntp/Makefile.depend
index 3214852..aa72b94 100644
--- a/usr.sbin/ntp/libntp/Makefile.depend
+++ b/usr.sbin/ntp/libntp/Makefile.depend
@@ -2,7 +2,6 @@
# Autogenerated - do NOT edit!
DIRDEPS = \
- bin/cat.host \
include \
include/arpa \
include/xlocale \
diff --git a/usr.sbin/ntp/ntp-keygen/Makefile.depend b/usr.sbin/ntp/ntp-keygen/Makefile.depend
index 47e365e..88a55c0 100644
--- a/usr.sbin/ntp/ntp-keygen/Makefile.depend
+++ b/usr.sbin/ntp/ntp-keygen/Makefile.depend
@@ -10,7 +10,6 @@ DIRDEPS = \
lib/${CSU_DIR} \
lib/libc \
lib/libcompiler_rt \
- lib/libmd \
lib/libthr \
lib/msun \
secure/lib/libcrypto \
diff --git a/usr.sbin/ntp/ntpd/Makefile.depend b/usr.sbin/ntp/ntpd/Makefile.depend
index c2cd9f7..0fc69e4 100644
--- a/usr.sbin/ntp/ntpd/Makefile.depend
+++ b/usr.sbin/ntp/ntpd/Makefile.depend
@@ -2,7 +2,6 @@
# Autogenerated - do NOT edit!
DIRDEPS = \
- bin/cat.host \
gnu/lib/csu \
gnu/lib/libgcc \
include \
@@ -11,8 +10,6 @@ DIRDEPS = \
lib/${CSU_DIR} \
lib/libc \
lib/libcompiler_rt \
- lib/libmd \
- lib/librt \
lib/libthr \
lib/msun \
secure/lib/libcrypto \
diff --git a/usr.sbin/ntp/ntpdate/Makefile.depend b/usr.sbin/ntp/ntpdate/Makefile.depend
index 986d60f..31c07ab 100644
--- a/usr.sbin/ntp/ntpdate/Makefile.depend
+++ b/usr.sbin/ntp/ntpdate/Makefile.depend
@@ -2,7 +2,6 @@
# Autogenerated - do NOT edit!
DIRDEPS = \
- bin/cat.host \
gnu/lib/csu \
gnu/lib/libgcc \
include \
@@ -11,12 +10,9 @@ DIRDEPS = \
lib/${CSU_DIR} \
lib/libc \
lib/libcompiler_rt \
- lib/libmd \
- lib/librt \
lib/libthr \
lib/msun \
secure/lib/libcrypto \
- secure/lib/libssl \
usr.sbin/ntp/libntp \
diff --git a/usr.sbin/ntp/ntpdc/Makefile.depend b/usr.sbin/ntp/ntpdc/Makefile.depend
index ffa29bb..7531e73 100644
--- a/usr.sbin/ntp/ntpdc/Makefile.depend
+++ b/usr.sbin/ntp/ntpdc/Makefile.depend
@@ -2,10 +2,8 @@
# Autogenerated - do NOT edit!
DIRDEPS = \
- bin/cat.host \
gnu/lib/csu \
gnu/lib/libgcc \
- gnu/lib/libreadline/readline \
include \
include/arpa \
include/xlocale \
@@ -13,13 +11,10 @@ DIRDEPS = \
lib/libc \
lib/libcompiler_rt \
lib/libedit \
- lib/libmd \
lib/libthr \
lib/msun \
- lib/ncurses/ncurses \
lib/ncurses/ncursesw \
secure/lib/libcrypto \
- secure/lib/libssl \
usr.sbin/ntp/libntp \
usr.sbin/ntp/libopts \
diff --git a/usr.sbin/ntp/ntpq/Makefile.depend b/usr.sbin/ntp/ntpq/Makefile.depend
index ac816a3..7531e73 100644
--- a/usr.sbin/ntp/ntpq/Makefile.depend
+++ b/usr.sbin/ntp/ntpq/Makefile.depend
@@ -2,7 +2,6 @@
# Autogenerated - do NOT edit!
DIRDEPS = \
- bin/cat.host \
gnu/lib/csu \
gnu/lib/libgcc \
include \
@@ -12,12 +11,10 @@ DIRDEPS = \
lib/libc \
lib/libcompiler_rt \
lib/libedit \
- lib/libmd \
lib/libthr \
lib/msun \
lib/ncurses/ncursesw \
secure/lib/libcrypto \
- secure/lib/libssl \
usr.sbin/ntp/libntp \
usr.sbin/ntp/libopts \
diff --git a/usr.sbin/ntp/sntp/Makefile.depend b/usr.sbin/ntp/sntp/Makefile.depend
index d849eed..9f44d40 100644
--- a/usr.sbin/ntp/sntp/Makefile.depend
+++ b/usr.sbin/ntp/sntp/Makefile.depend
@@ -10,11 +10,9 @@ DIRDEPS = \
lib/${CSU_DIR} \
lib/libc \
lib/libcompiler_rt \
- lib/libmd \
lib/libthr \
lib/msun \
secure/lib/libcrypto \
- secure/lib/libssl \
usr.sbin/ntp/libntp \
usr.sbin/ntp/libntpevent \
usr.sbin/ntp/libopts \
diff --git a/usr.sbin/syslogd/syslogd.8 b/usr.sbin/syslogd/syslogd.8
index b2e8818..3074d08 100644
--- a/usr.sbin/syslogd/syslogd.8
+++ b/usr.sbin/syslogd/syslogd.8
@@ -28,7 +28,7 @@
.\" @(#)syslogd.8 8.1 (Berkeley) 6/6/93
.\" $FreeBSD$
.\"
-.Dd March 3, 2015
+.Dd June 16, 2015
.Dt SYSLOGD 8
.Os
.Sh NAME
@@ -194,6 +194,8 @@ The default
.Ar service
is
.Ql syslog .
+This option can be specified multiple times to bind to
+multiple addresses and/or ports.
.It Fl C
Create log files that do not exist (permission is set to
.Li 0600 ) .
diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c
index baa79c8..ff3e524 100644
--- a/usr.sbin/syslogd/syslogd.c
+++ b/usr.sbin/syslogd/syslogd.c
@@ -124,6 +124,15 @@ const char ctty[] = _PATH_CONSOLE;
#define MAXUNAMES 20 /* maximum number of user names */
/*
+ * List of hosts for binding.
+ */
+static STAILQ_HEAD(, host) hqueue;
+struct host {
+ char *name;
+ STAILQ_ENTRY(host) next;
+};
+
+/*
* Unix sockets.
* We have two default sockets, one with 666 permissions,
* and one for privileged programs.
@@ -275,7 +284,7 @@ static int Foreground = 0; /* Run in foreground, instead of daemonizing */
static int resolve = 1; /* resolve hostname */
static char LocalHostName[MAXHOSTNAMELEN]; /* our hostname */
static const char *LocalDomain; /* our local domain name */
-static int *finet; /* Internet datagram socket */
+static int *finet; /* Internet datagram sockets */
static int fklog = -1; /* /dev/klog */
static int Initialized; /* set when we have initialized ourselves */
static int MarkInterval = 20 * 60; /* interval between marks in seconds */
@@ -348,10 +357,10 @@ main(int argc, char *argv[])
struct sockaddr_storage frominet;
fd_set *fdsr = NULL;
char line[MAXLINE + 1];
- char *bindhostname;
const char *hname;
struct timeval tv, *tvp;
struct sigaction sact;
+ struct host *host;
struct funix *fx, *fx1;
sigset_t mask;
pid_t ppid = 1, spid;
@@ -360,7 +369,8 @@ main(int argc, char *argv[])
if (madvise(NULL, 0, MADV_PROTECT) != 0)
dprintf("madvise() failed: %s\n", strerror(errno));
- bindhostname = NULL;
+ STAILQ_INIT(&hqueue);
+
while ((ch = getopt(argc, argv, "468Aa:b:cCdf:Fkl:m:nNop:P:sS:Tuv"))
!= -1)
switch (ch) {
@@ -383,8 +393,13 @@ main(int argc, char *argv[])
usage();
break;
case 'b':
- bindhostname = optarg;
+ {
+ if ((host = malloc(sizeof(struct host))) == NULL)
+ err(1, "malloc failed");
+ host->name = optarg;
+ STAILQ_INSERT_TAIL(&hqueue, host, next);
break;
+ }
case 'c':
no_compress++;
break;
@@ -433,7 +448,7 @@ main(int argc, char *argv[])
if (strlen(name) >= sizeof(sunx.sun_path))
errx(1, "%s path too long, exiting", name);
if ((fx = malloc(sizeof(struct funix))) == NULL)
- errx(1, "malloc failed");
+ err(1, "malloc failed");
fx->s = -1;
fx->name = name;
fx->mode = mode;
@@ -555,8 +570,27 @@ main(int argc, char *argv[])
}
increase_rcvbuf(fx->s);
}
- if (SecureMode <= 1)
- finet = socksetup(family, bindhostname);
+ if (SecureMode <= 1) {
+ if (STAILQ_EMPTY(&hqueue))
+ finet = socksetup(family, NULL);
+ STAILQ_FOREACH(host, &hqueue, next) {
+ int *finet0, total;
+ finet0 = socksetup(family, host->name);
+ if (finet0 && !finet) {
+ finet = finet0;
+ } else if (finet0 && finet) {
+ total = *finet0 + *finet + 1;
+ finet = realloc(finet, total * sizeof(int));
+ if (finet == NULL)
+ err(1, "realloc failed");
+ for (i = 1; i <= *finet0; i++) {
+ finet[(*finet)+i] = finet0[i];
+ }
+ *finet = total - 1;
+ free(finet0);
+ }
+ }
+ }
if (finet) {
if (SecureMode) {
@@ -1569,6 +1603,24 @@ init(int signo)
}
/*
+ * Load / reload timezone data (in case it changed).
+ *
+ * Just calling tzset() again does not work, the timezone code
+ * caches the result. However, by setting the TZ variable, one
+ * can defeat the caching and have the timezone code really
+ * reload the timezone data. Respect any initial setting of
+ * TZ, in case the system is configured specially.
+ */
+ dprintf("loading timezone data via tzset()\n");
+ if (getenv("TZ")) {
+ tzset();
+ } else {
+ setenv("TZ", ":/etc/localtime", 1);
+ tzset();
+ unsetenv("TZ");
+ }
+
+ /*
* Close all open log files.
*/
Initialized = 0;
@@ -2730,6 +2782,7 @@ socksetup(int af, char *bindhostname)
}
(*socks)++;
+ dprintf("socksetup: new socket fd is %d\n", *s);
s++;
}
OpenPOWER on IntegriCloud