diff --git a/.gitmodules b/.gitmodules index d750f8eb5b781..e840f4adaebbd 100644 --- a/.gitmodules +++ b/.gitmodules @@ -3,4 +3,4 @@ url = git://github.com/brson/llvm.git [submodule "src/libuv"] path = src/libuv - url = git://github.com/graydon/libuv.git + url = git://github.com/joyent/libuv.git diff --git a/AUTHORS.txt b/AUTHORS.txt index a7b55520b8d45..628fa4c86da00 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -29,6 +29,7 @@ Benjamin Peterson Bilal Husain Bill Fallon Brendan Eich +Brendan Zabarauskas Brian Anderson Brian J. Burg Brian Leibig @@ -80,6 +81,7 @@ Jeff Muizelaar Jeff Olson Jeffrey Yasskin Jens Nockert +Jesse Jones Jesse Ruderman Jim Blandy Jimmy Lu @@ -105,6 +107,7 @@ Mahmut Bulut Margaret Meyerhofer Marijn Haverbeke Mark Lacey <641@rudkx.com> +Mark Vian Martin DeMello Marvin Löbel Matt Brubeck @@ -114,6 +117,7 @@ Michael Arntzenius Michael Bebenita Michael Neumann Michael Sullivan +Mikko Perttunen Nick Desaulniers Niko Matsakis Or Brostovski @@ -148,6 +152,7 @@ Tim Taubert Tom Lee Tomoki Aonuma Tony Young +Trinick Tycho Sci Tyler Bindon Viktor Dahl diff --git a/configure b/configure index 531b3ce1efe06..d9f2db8e11099 100755 --- a/configure +++ b/configure @@ -394,6 +394,7 @@ probe CFG_PDFLATEX pdflatex probe CFG_XETEX xetex probe CFG_LUATEX luatex probe CFG_NODE nodejs node +probe CFG_GDB gdb if [ "$CFG_OSTYPE" = "unknown-linux-gnu" ] then probe CFG_PAXCTL paxctl /sbin/paxctl @@ -578,7 +579,7 @@ do make_dir rt/$t for i in \ isaac linenoise sync test arch/i386 arch/x86_64 \ - libuv libuv/src/ares libuv/src/eio libuv/src/ev + libuv do make_dir rt/$t/$i done @@ -619,6 +620,7 @@ do make_dir $h/test/bench make_dir $h/test/perf make_dir $h/test/pretty + make_dir $h/test/debug-info make_dir $h/test/doc-tutorial make_dir $h/test/doc-tutorial-ffi make_dir $h/test/doc-tutorial-macros diff --git a/mk/libuv/arm/unix/android/Makefile b/mk/libuv/arm/unix/android/Makefile deleted file mode 100755 index 16323af2cd75c..0000000000000 --- a/mk/libuv/arm/unix/android/Makefile +++ /dev/null @@ -1,354 +0,0 @@ -# We borrow heavily from the kernel build setup, though we are simpler since -# we don't have Kconfig tweaking settings on us. - -# The implicit make rules have it looking for RCS files, among other things. -# We instead explicitly write all the rules we care about. -# It's even quicker (saves ~200ms) to pass -r on the command line. -MAKEFLAGS=-r - -# The source directory tree. -srcdir := ../../../../.. -abs_srcdir := $(abspath $(srcdir)) - -# The name of the builddir. -builddir_name ?= out - -# The V=1 flag on command line makes us verbosely print command lines. -ifdef V - quiet= -else - quiet=quiet_ -endif - -# Specify BUILDTYPE=Release on the command line for a release build. -BUILDTYPE ?= Debug - -# Directory all our build output goes into. -# Note that this must be two directories beneath src/ for unit tests to pass, -# as they reach into the src/ directory for data with relative paths. -builddir ?= $(builddir_name)/$(BUILDTYPE) -abs_builddir := $(abspath $(builddir)) -depsdir := $(builddir)/.deps - -# Object output directory. -obj := $(builddir)/obj -abs_obj := $(abspath $(obj)) - -# We build up a list of every single one of the targets so we can slurp in the -# generated dependency rule Makefiles in one pass. -all_deps := - - - -# C++ apps need to be linked with g++. -# -# Note: flock is used to seralize linking. Linking is a memory-intensive -# process so running parallel links can often lead to thrashing. To disable -# the serialization, override LINK via an envrionment variable as follows: -# -# export LINK=g++ -# -# This will allow make to invoke N linker processes as specified in -jN. -LINK ?= flock $(builddir)/linker.lock $(CXX) - -CC.target ?= $(CC) -CFLAGS.target ?= $(CFLAGS) -CXX.target ?= $(CXX) -CXXFLAGS.target ?= $(CXXFLAGS) -LINK.target ?= $(LINK) -LDFLAGS.target ?= $(LDFLAGS) -AR.target ?= $(AR) -ARFLAGS.target ?= crsT - -# N.B.: the logic of which commands to run should match the computation done -# in gyp's make.py where ARFLAGS.host etc. is computed. -# TODO(evan): move all cross-compilation logic to gyp-time so we don't need -# to replicate this environment fallback in make as well. -CC.host ?= gcc -CFLAGS.host ?= -CXX.host ?= g++ -CXXFLAGS.host ?= -LINK.host ?= g++ -LDFLAGS.host ?= -AR.host ?= ar -ARFLAGS.host := crs - -# Define a dir function that can handle spaces. -# http://www.gnu.org/software/make/manual/make.html#Syntax-of-Functions -# "leading spaces cannot appear in the text of the first argument as written. -# These characters can be put into the argument value by variable substitution." -empty := -space := $(empty) $(empty) - -# http://stackoverflow.com/questions/1189781/using-make-dir-or-notdir-on-a-path-with-spaces -replace_spaces = $(subst $(space),?,$1) -unreplace_spaces = $(subst ?,$(space),$1) -dirx = $(call unreplace_spaces,$(dir $(call replace_spaces,$1))) - -# Flags to make gcc output dependency info. Note that you need to be -# careful here to use the flags that ccache and distcc can understand. -# We write to a dep file on the side first and then rename at the end -# so we can't end up with a broken dep file. -depfile = $(depsdir)/$(call replace_spaces,$@).d -DEPFLAGS = -MMD -MF $(depfile).raw - -# We have to fixup the deps output in a few ways. -# (1) the file output should mention the proper .o file. -# ccache or distcc lose the path to the target, so we convert a rule of -# the form: -# foobar.o: DEP1 DEP2 -# into -# path/to/foobar.o: DEP1 DEP2 -# (2) we want missing files not to cause us to fail to build. -# We want to rewrite -# foobar.o: DEP1 DEP2 \ -# DEP3 -# to -# DEP1: -# DEP2: -# DEP3: -# so if the files are missing, they're just considered phony rules. -# We have to do some pretty insane escaping to get those backslashes -# and dollar signs past make, the shell, and sed at the same time. -# Doesn't work with spaces, but that's fine: .d files have spaces in -# their names replaced with other characters. -define fixup_dep -# The depfile may not exist if the input file didn't have any #includes. -touch $(depfile).raw -# Fixup path as in (1). -sed -e "s|^$(notdir $@)|$@|" $(depfile).raw >> $(depfile) -# Add extra rules as in (2). -# We remove slashes and replace spaces with new lines; -# remove blank lines; -# delete the first line and append a colon to the remaining lines. -sed -e 's|\\||' -e 'y| |\n|' $(depfile).raw |\ - grep -v '^$$' |\ - sed -e 1d -e 's|$$|:|' \ - >> $(depfile) -rm $(depfile).raw -endef - -# Command definitions: -# - cmd_foo is the actual command to run; -# - quiet_cmd_foo is the brief-output summary of the command. - -quiet_cmd_cc = CC($(TOOLSET)) $@ -cmd_cc = $(CC.$(TOOLSET)) $(GYP_CFLAGS) $(DEPFLAGS) $(CFLAGS.$(TOOLSET)) -c -o $@ $< - -quiet_cmd_cxx = CXX($(TOOLSET)) $@ -cmd_cxx = $(CXX.$(TOOLSET)) $(GYP_CXXFLAGS) $(DEPFLAGS) $(CXXFLAGS.$(TOOLSET)) -c -o $@ $< - -quiet_cmd_touch = TOUCH $@ -cmd_touch = touch $@ - -quiet_cmd_copy = COPY $@ -# send stderr to /dev/null to ignore messages when linking directories. -cmd_copy = ln -f "$<" "$@" 2>/dev/null || (rm -rf "$@" && cp -af "$<" "$@") - -quiet_cmd_alink = AR($(TOOLSET)) $@ -cmd_alink = rm -f $@ && $(AR.$(TOOLSET)) $(ARFLAGS.$(TOOLSET)) $@ $(filter %.o,$^) - -# Due to circular dependencies between libraries :(, we wrap the -# special "figure out circular dependencies" flags around the entire -# input list during linking. -quiet_cmd_link = LINK($(TOOLSET)) $@ -cmd_link = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ -Wl,--start-group $(LD_INPUTS) -Wl,--end-group $(LIBS) - -# We support two kinds of shared objects (.so): -# 1) shared_library, which is just bundling together many dependent libraries -# into a link line. -# 2) loadable_module, which is generating a module intended for dlopen(). -# -# They differ only slightly: -# In the former case, we want to package all dependent code into the .so. -# In the latter case, we want to package just the API exposed by the -# outermost module. -# This means shared_library uses --whole-archive, while loadable_module doesn't. -# (Note that --whole-archive is incompatible with the --start-group used in -# normal linking.) - -# Other shared-object link notes: -# - Set SONAME to the library filename so our binaries don't reference -# the local, absolute paths used on the link command-line. -quiet_cmd_solink = SOLINK($(TOOLSET)) $@ -cmd_solink = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -Wl,-soname=$(@F) -o $@ -Wl,--whole-archive $(LD_INPUTS) -Wl,--no-whole-archive $(LIBS) - -quiet_cmd_solink_module = SOLINK_MODULE($(TOOLSET)) $@ -cmd_solink_module = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -Wl,-soname=$(@F) -o $@ -Wl,--start-group $(filter-out FORCE_DO_CMD, $^) -Wl,--end-group $(LIBS) - - -# Define an escape_quotes function to escape single quotes. -# This allows us to handle quotes properly as long as we always use -# use single quotes and escape_quotes. -escape_quotes = $(subst ','\'',$(1)) -# This comment is here just to include a ' to unconfuse syntax highlighting. -# Define an escape_vars function to escape '$' variable syntax. -# This allows us to read/write command lines with shell variables (e.g. -# $LD_LIBRARY_PATH), without triggering make substitution. -escape_vars = $(subst $$,$$$$,$(1)) -# Helper that expands to a shell command to echo a string exactly as it is in -# make. This uses printf instead of echo because printf's behaviour with respect -# to escape sequences is more portable than echo's across different shells -# (e.g., dash, bash). -exact_echo = printf '%s\n' '$(call escape_quotes,$(1))' - -# Helper to compare the command we're about to run against the command -# we logged the last time we ran the command. Produces an empty -# string (false) when the commands match. -# Tricky point: Make has no string-equality test function. -# The kernel uses the following, but it seems like it would have false -# positives, where one string reordered its arguments. -# arg_check = $(strip $(filter-out $(cmd_$(1)), $(cmd_$@)) \ -# $(filter-out $(cmd_$@), $(cmd_$(1)))) -# We instead substitute each for the empty string into the other, and -# say they're equal if both substitutions produce the empty string. -# .d files contain ? instead of spaces, take that into account. -command_changed = $(or $(subst $(cmd_$(1)),,$(cmd_$(call replace_spaces,$@))),\ - $(subst $(cmd_$(call replace_spaces,$@)),,$(cmd_$(1)))) - -# Helper that is non-empty when a prerequisite changes. -# Normally make does this implicitly, but we force rules to always run -# so we can check their command lines. -# $? -- new prerequisites -# $| -- order-only dependencies -prereq_changed = $(filter-out FORCE_DO_CMD,$(filter-out $|,$?)) - -# Helper that executes all postbuilds, and deletes the output file when done -# if any of the postbuilds failed. -define do_postbuilds - @E=0;\ - for p in $(POSTBUILDS); do\ - eval $$p;\ - F=$$?;\ - if [ $$F -ne 0 ]; then\ - E=$$F;\ - fi;\ - done;\ - if [ $$E -ne 0 ]; then\ - rm -rf "$@";\ - exit $$E;\ - fi -endef - -# do_cmd: run a command via the above cmd_foo names, if necessary. -# Should always run for a given target to handle command-line changes. -# Second argument, if non-zero, makes it do asm/C/C++ dependency munging. -# Third argument, if non-zero, makes it do POSTBUILDS processing. -# Note: We intentionally do NOT call dirx for depfile, since it contains ? for -# spaces already and dirx strips the ? characters. -define do_cmd -$(if $(or $(command_changed),$(prereq_changed)), - @$(call exact_echo, $($(quiet)cmd_$(1))) - @mkdir -p "$(call dirx,$@)" "$(dir $(depfile))" - $(if $(findstring flock,$(word 1,$(cmd_$1))), - @$(cmd_$(1)) - @echo " $(quiet_cmd_$(1)): Finished", - @$(cmd_$(1)) - ) - @$(call exact_echo,$(call escape_vars,cmd_$(call replace_spaces,$@) := $(cmd_$(1)))) > $(depfile) - @$(if $(2),$(fixup_dep)) - $(if $(and $(3), $(POSTBUILDS)), - $(call do_postbuilds) - ) -) -endef - -# Declare the "all" target first so it is the default, -# even though we don't have the deps yet. -.PHONY: all -all: - -# Use FORCE_DO_CMD to force a target to run. Should be coupled with -# do_cmd. -.PHONY: FORCE_DO_CMD -FORCE_DO_CMD: - -TOOLSET := target -# Suffix rules, putting all outputs into $(obj). -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.cc FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.cpp FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.cxx FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.S FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.s FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# Try building from generated source, too. -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cc FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cpp FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cxx FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.S FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.s FORCE_DO_CMD - @$(call do_cmd,cc,1) - -$(obj).$(TOOLSET)/%.o: $(obj)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.cc FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.cpp FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.cxx FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.S FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.s FORCE_DO_CMD - @$(call do_cmd,cc,1) - - -ifeq ($(strip $(foreach prefix,$(NO_LOAD),\ - $(findstring $(join ^,$(prefix)),\ - $(join ^,src/libuv/run-benchmarks.target.mk)))),) - include src/libuv/run-benchmarks.target.mk -endif -ifeq ($(strip $(foreach prefix,$(NO_LOAD),\ - $(findstring $(join ^,$(prefix)),\ - $(join ^,src/libuv/run-tests.target.mk)))),) - include src/libuv/run-tests.target.mk -endif -ifeq ($(strip $(foreach prefix,$(NO_LOAD),\ - $(findstring $(join ^,$(prefix)),\ - $(join ^,src/libuv/uv.target.mk)))),) - include src/libuv/uv.target.mk -endif - -#quiet_cmd_regen_makefile = ACTION Regenerating $@ -#cmd_regen_makefile = ./src/libuv/build/gyp/gyp -fmake --ignore-environment "--toplevel-dir=." -Isrc/libuv/common.gypi "--depth=." "--generator-output=mk/libuv/arm/unix/android" "-Ddefault_configuration=Default" "-Dcomponent=static_library" "-Dlibrary=static_library" "-Dtarget_arch=arm" "-DOS=linux" src/libuv/uv.gyp -#Makefile: $(srcdir)/src/libuv/uv.gyp $(srcdir)/src/libuv/common.gypi -# $(call do_cmd,regen_makefile) - -# "all" is a concatenation of the "all" targets from all the included -# sub-makefiles. This is just here to clarify. -all: - -# Add in dependency-tracking rules. $(all_deps) is the list of every single -# target in our tree. Only consider the ones with .d (dependency) info: -d_files := $(wildcard $(foreach f,$(all_deps),$(depsdir)/$(f).d)) -ifneq ($(d_files),) - # Rather than include each individual .d file, concatenate them into a - # single file which make is able to load faster. We split this into - # commands that take 1000 files at a time to avoid overflowing the - # command line. - $(shell cat $(wordlist 1,1000,$(d_files)) > $(depsdir)/all.deps) - - ifneq ($(word 1001,$(d_files)),) - $(error Found unprocessed dependency files (gyp didn't generate enough rules!)) - endif - - # make looks for ways to re-generate included makefiles, but in our case, we - # don't have a direct way. Explicitly telling make that it has nothing to do - # for them makes it go faster. - $(depsdir)/all.deps: ; - - include $(depsdir)/all.deps -endif diff --git a/mk/libuv/arm/unix/android/src/libuv/run-benchmarks.target.mk b/mk/libuv/arm/unix/android/src/libuv/run-benchmarks.target.mk deleted file mode 100755 index 20ff9609d8fd7..0000000000000 --- a/mk/libuv/arm/unix/android/src/libuv/run-benchmarks.target.mk +++ /dev/null @@ -1,115 +0,0 @@ -# This file is generated by gyp; do not edit. - -TOOLSET := target -TARGET := run-benchmarks -DEFS_Debug := '-D_LARGEFILE_SOURCE' \ - '-D_FILE_OFFSET_BITS=64' \ - '-D_GNU_SOURCE' \ - '-DEIO_STACKSIZE=262144' \ - '-DDEBUG' \ - '-D_DEBUG' \ - '-DEV_VERIFY=2' - -# Flags passed to all source files. -CFLAGS_Debug := \ - -Wall \ - -ansi \ - -fvisibility=hidden \ - -g \ - -O0 - -# Flags passed to only C files. -CFLAGS_C_Debug := - -# Flags passed to only C++ files. -CFLAGS_CC_Debug := -fno-rtti \ - -fno-exceptions - -INCS_Debug := -I$(srcdir)/src/libuv/include - -DEFS_Release := '-D_LARGEFILE_SOURCE' \ - '-D_FILE_OFFSET_BITS=64' \ - '-D_GNU_SOURCE' \ - '-DEIO_STACKSIZE=262144' \ - '-DNDEBUG' - -# Flags passed to all source files. -CFLAGS_Release := \ - -Wall \ - -ansi \ - -fvisibility=hidden \ - -O3 \ - -fomit-frame-pointer \ - -fdata-sections \ - -ffunction-sections - -# Flags passed to only C files. -CFLAGS_C_Release := - -# Flags passed to only C++ files. -CFLAGS_CC_Release := -fno-rtti \ - -fno-exceptions - -INCS_Release := -I$(srcdir)/src/libuv/include - -OBJS := $(obj).target/$(TARGET)/src/libuv/test/benchmark-ares.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-getaddrinfo.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-ping-pongs.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-pound.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-pump.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-sizes.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-spawn.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-thread.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-tcp-write-batch.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-udp-packet-storm.o \ - $(obj).target/$(TARGET)/src/libuv/test/dns-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/echo-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/blackhole-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/run-benchmarks.o \ - $(obj).target/$(TARGET)/src/libuv/test/runner.o \ - $(obj).target/$(TARGET)/src/libuv/test/runner-unix.o - -# Add to the list of files we specially track dependencies for. -all_deps += $(OBJS) - -# Make sure our dependencies are built before any of us. -$(OBJS): | $(obj).target/src/libuv/libuv.a - -# CFLAGS et al overrides must be target-local. -# See "Target-specific Variable Values" in the GNU Make manual. -$(OBJS): TOOLSET := $(TOOLSET) -$(OBJS): GYP_CFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) -$(OBJS): GYP_CXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) - -# Suffix rules, putting all outputs into $(obj). - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# Try building from generated source, too. - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# End of this set of suffix rules -### Rules for final target. - -$(builddir)/run-benchmarks: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE)) -$(builddir)/run-benchmarks: LIBS := $(LIBS) -$(builddir)/run-benchmarks: LD_INPUTS := $(OBJS) $(obj).target/src/libuv/libuv.a -$(builddir)/run-benchmarks: TOOLSET := $(TOOLSET) -$(builddir)/run-benchmarks: $(OBJS) $(obj).target/src/libuv/libuv.a FORCE_DO_CMD - $(call do_cmd,link) - -all_deps += $(builddir)/run-benchmarks -# Add target alias -.PHONY: run-benchmarks -run-benchmarks: $(builddir)/run-benchmarks - -# Add executable to "all" target. -.PHONY: all -all: $(builddir)/run-benchmarks - diff --git a/mk/libuv/arm/unix/android/src/libuv/run-tests.target.mk b/mk/libuv/arm/unix/android/src/libuv/run-tests.target.mk deleted file mode 100755 index c4d8c207c0884..0000000000000 --- a/mk/libuv/arm/unix/android/src/libuv/run-tests.target.mk +++ /dev/null @@ -1,158 +0,0 @@ -# This file is generated by gyp; do not edit. - -TOOLSET := target -TARGET := run-tests -DEFS_Debug := '-D_LARGEFILE_SOURCE' \ - '-D_FILE_OFFSET_BITS=64' \ - '-D_GNU_SOURCE' \ - '-DEIO_STACKSIZE=262144' \ - '-DDEBUG' \ - '-D_DEBUG' \ - '-DEV_VERIFY=2' - -# Flags passed to all source files. -CFLAGS_Debug := \ - -Wall \ - -ansi \ - -fvisibility=hidden \ - -g \ - -O0 - -# Flags passed to only C files. -CFLAGS_C_Debug := - -# Flags passed to only C++ files. -CFLAGS_CC_Debug := -fno-rtti \ - -fno-exceptions - -INCS_Debug := -I$(srcdir)/src/libuv/include - -DEFS_Release := '-D_LARGEFILE_SOURCE' \ - '-D_FILE_OFFSET_BITS=64' \ - '-D_GNU_SOURCE' \ - '-DEIO_STACKSIZE=262144' \ - '-DNDEBUG' - -# Flags passed to all source files. -CFLAGS_Release := \ - -Wall \ - -ansi \ - -fvisibility=hidden \ - -O3 \ - -fomit-frame-pointer \ - -fdata-sections \ - -ffunction-sections - -# Flags passed to only C files. -CFLAGS_C_Release := - -# Flags passed to only C++ files. -CFLAGS_CC_Release := -fno-rtti \ - -fno-exceptions - -INCS_Release := -I$(srcdir)/src/libuv/include - -OBJS := $(obj).target/$(TARGET)/src/libuv/test/blackhole-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/echo-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/run-tests.o \ - $(obj).target/$(TARGET)/src/libuv/test/runner.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-get-loadavg.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-util.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-async.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-callback-stack.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-connection-fail.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-cwd-and-chdir.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-delayed-accept.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-eio-overflow.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-fail-always.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-fs.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-fs-event.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-get-currentexe.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-get-memory.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-getaddrinfo.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-gethostbyname.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-getsockname.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-hrtime.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-idle.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-ipc.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-ipc-threads.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-loop-handles.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-multiple-listen.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-pass-always.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-ping-pong.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-pipe-bind-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-pipe-connect-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-platform-output.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-process-title.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-ref.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-shutdown-eof.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-spawn.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-stdio-over-pipes.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-bind-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-bind6-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-close.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-flags.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-connect-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-connect6-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-write-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-write-to-half-open-connection.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-writealot.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-threadpool.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-mutexes.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-thread.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-timer-again.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-timer.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tty.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-dgram-too-big.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-ipv6.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-options.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-send-and-recv.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-multicast-join.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-counters-init.o \ - $(obj).target/$(TARGET)/src/libuv/test/runner-unix.o - -# Add to the list of files we specially track dependencies for. -all_deps += $(OBJS) - -# Make sure our dependencies are built before any of us. -$(OBJS): | $(obj).target/src/libuv/libuv.a - -# CFLAGS et al overrides must be target-local. -# See "Target-specific Variable Values" in the GNU Make manual. -$(OBJS): TOOLSET := $(TOOLSET) -$(OBJS): GYP_CFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) -$(OBJS): GYP_CXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) - -# Suffix rules, putting all outputs into $(obj). - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# Try building from generated source, too. - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# End of this set of suffix rules -### Rules for final target. - -$(builddir)/run-tests: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE)) -$(builddir)/run-tests: LIBS := $(LIBS) -$(builddir)/run-tests: LD_INPUTS := $(OBJS) $(obj).target/src/libuv/libuv.a -$(builddir)/run-tests: TOOLSET := $(TOOLSET) -$(builddir)/run-tests: $(OBJS) $(obj).target/src/libuv/libuv.a FORCE_DO_CMD - $(call do_cmd,link) - -all_deps += $(builddir)/run-tests -# Add target alias -.PHONY: run-tests -run-tests: $(builddir)/run-tests - -# Add executable to "all" target. -.PHONY: all -all: $(builddir)/run-tests - diff --git a/mk/libuv/arm/unix/android/src/libuv/uv.Makefile b/mk/libuv/arm/unix/android/src/libuv/uv.Makefile deleted file mode 100755 index ba3abfe493648..0000000000000 --- a/mk/libuv/arm/unix/android/src/libuv/uv.Makefile +++ /dev/null @@ -1,6 +0,0 @@ -# This file is generated by gyp; do not edit. - -export builddir_name ?= mk/libuv/arm/unix/android/./src/libuv/out -.PHONY: all -all: - $(MAKE) -C ../.. uv run-benchmarks run-tests diff --git a/mk/libuv/arm/unix/android/src/libuv/uv.target.mk b/mk/libuv/arm/unix/android/src/libuv/uv.target.mk deleted file mode 100755 index 2c23caef29ccb..0000000000000 --- a/mk/libuv/arm/unix/android/src/libuv/uv.target.mk +++ /dev/null @@ -1,184 +0,0 @@ -# This file is generated by gyp; do not edit. - -TOOLSET := target -TARGET := uv -DEFS_Debug := '-D_LARGEFILE_SOURCE' \ - '-D_FILE_OFFSET_BITS=64' \ - '-D_GNU_SOURCE' \ - '-DEIO_STACKSIZE=262144' \ - '-DHAVE_CONFIG_H' \ - '-DEV_CONFIG_H="config_android.h"' \ - '-DEIO_CONFIG_H="config_android.h"' \ - '-DDEBUG' \ - '-D_DEBUG' \ - '-DEV_VERIFY=2' - -# Flags passed to all source files. -CFLAGS_Debug := \ - -Wall \ - -ansi \ - -fvisibility=hidden \ - -g \ - --std=gnu89 \ - -pedantic \ - -Wall \ - -Wextra \ - -Wno-unused-parameter \ - -g \ - -O0 - -# Flags passed to only C files. -CFLAGS_C_Debug := - -# Flags passed to only C++ files. -CFLAGS_CC_Debug := -fno-rtti \ - -fno-exceptions - -INCS_Debug := -I$(srcdir)/src/libuv/include \ - -I$(srcdir)/src/libuv/include/uv-private \ - -I$(srcdir)/src/libuv/src \ - -I$(srcdir)/src/libuv/src/unix/ev \ - -I$(srcdir)/src/libuv/src/ares/config_android - -DEFS_Release := '-D_LARGEFILE_SOURCE' \ - '-D_FILE_OFFSET_BITS=64' \ - '-D_GNU_SOURCE' \ - '-DEIO_STACKSIZE=262144' \ - '-DHAVE_CONFIG_H' \ - '-DEV_CONFIG_H="config_android.h"' \ - '-DEIO_CONFIG_H="config_android.h"' \ - '-DNDEBUG' - -# Flags passed to all source files. -CFLAGS_Release := \ - -Wall \ - -ansi \ - -fvisibility=hidden \ - -g \ - --std=gnu89 \ - -pedantic \ - -Wall \ - -Wextra \ - -Wno-unused-parameter \ - -O3 \ - -fomit-frame-pointer \ - -fdata-sections \ - -ffunction-sections - -# Flags passed to only C files. -CFLAGS_C_Release := - -# Flags passed to only C++ files. -CFLAGS_CC_Release := -fno-rtti \ - -fno-exceptions - -INCS_Release := -I$(srcdir)/src/libuv/include \ - -I$(srcdir)/src/libuv/include/uv-private \ - -I$(srcdir)/src/libuv/src \ - -I$(srcdir)/src/libuv/src/unix/ev \ - -I$(srcdir)/src/libuv/src/ares/config_android - -OBJS := $(obj).target/$(TARGET)/src/libuv/src/uv-common.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_cancel.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares__close_sockets.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_data.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_destroy.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_expand_name.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_expand_string.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_fds.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_free_hostent.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_free_string.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_gethostbyaddr.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_gethostbyname.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares__get_hostent.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_getnameinfo.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_getopt.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_getsock.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_init.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_library_init.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_llist.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_mkquery.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_nowarn.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_options.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_aaaa_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_a_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_mx_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_ns_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_ptr_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_srv_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_txt_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_process.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_query.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares__read_line.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_search.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_send.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_strcasecmp.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_strdup.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_strerror.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_timeout.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares__timeval.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_version.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_writev.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/bitncmp.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/inet_net_pton.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/inet_ntop.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/windows_port.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/core.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/uv-eio.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/fs.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/udp.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/tcp.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/pipe.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/tty.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/stream.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/cares.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/dl.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/error.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/thread.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/process.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/eio/eio.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/ev/ev.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/linux.o - -# Add to the list of files we specially track dependencies for. -all_deps += $(OBJS) - -# CFLAGS et al overrides must be target-local. -# See "Target-specific Variable Values" in the GNU Make manual. -$(OBJS): TOOLSET := $(TOOLSET) -$(OBJS): GYP_CFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) -$(OBJS): GYP_CXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) - -# Suffix rules, putting all outputs into $(obj). - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# Try building from generated source, too. - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# End of this set of suffix rules -### Rules for final target. - -LIBS := -lm - -$(obj).target/src/libuv/libuv.a: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE)) -$(obj).target/src/libuv/libuv.a: LIBS := $(LIBS) -$(obj).target/src/libuv/libuv.a: TOOLSET := $(TOOLSET) -$(obj).target/src/libuv/libuv.a: $(OBJS) FORCE_DO_CMD - $(call do_cmd,alink) - -all_deps += $(obj).target/src/libuv/libuv.a -# Add target alias -.PHONY: uv -uv: $(obj).target/src/libuv/libuv.a - -# Add target alias to "all" target. -.PHONY: all -all: uv - diff --git a/mk/libuv/ia32/mac/Makefile b/mk/libuv/ia32/mac/Makefile deleted file mode 100644 index 002fef0390ab8..0000000000000 --- a/mk/libuv/ia32/mac/Makefile +++ /dev/null @@ -1,379 +0,0 @@ -# We borrow heavily from the kernel build setup, though we are simpler since -# we don't have Kconfig tweaking settings on us. - -# The implicit make rules have it looking for RCS files, among other things. -# We instead explicitly write all the rules we care about. -# It's even quicker (saves ~200ms) to pass -r on the command line. -MAKEFLAGS=-r - -# The source directory tree. -srcdir := ../../../.. -abs_srcdir := $(abspath $(srcdir)) - -# The name of the builddir. -builddir_name ?= out - -# The V=1 flag on command line makes us verbosely print command lines. -ifdef V - quiet= -else - quiet=quiet_ -endif - -# Specify BUILDTYPE=Release on the command line for a release build. -BUILDTYPE ?= Debug - -# Directory all our build output goes into. -# Note that this must be two directories beneath src/ for unit tests to pass, -# as they reach into the src/ directory for data with relative paths. -builddir ?= $(builddir_name)/$(BUILDTYPE) -abs_builddir := $(abspath $(builddir)) -depsdir := $(builddir)/.deps - -# Object output directory. -obj := $(builddir)/obj -abs_obj := $(abspath $(obj)) - -# We build up a list of every single one of the targets so we can slurp in the -# generated dependency rule Makefiles in one pass. -all_deps := - - - -# C++ apps need to be linked with g++. -# -# Note: flock is used to seralize linking. Linking is a memory-intensive -# process so running parallel links can often lead to thrashing. To disable -# the serialization, override LINK via an envrionment variable as follows: -# -# export LINK=g++ -# -# This will allow make to invoke N linker processes as specified in -jN. -LINK ?= ./gyp-mac-tool flock $(builddir)/linker.lock $(CXX) - -CC.target ?= $(CC) -CFLAGS.target ?= $(CFLAGS) -CXX.target ?= $(CXX) -CXXFLAGS.target ?= $(CXXFLAGS) -LINK.target ?= $(LINK) -LDFLAGS.target ?= $(LDFLAGS) -AR.target ?= $(AR) -ARFLAGS.target ?= crs - -# N.B.: the logic of which commands to run should match the computation done -# in gyp's make.py where ARFLAGS.host etc. is computed. -# TODO(evan): move all cross-compilation logic to gyp-time so we don't need -# to replicate this environment fallback in make as well. -CC.host ?= gcc -CFLAGS.host ?= -CXX.host ?= g++ -CXXFLAGS.host ?= -LINK.host ?= g++ -LDFLAGS.host ?= -AR.host ?= ar -ARFLAGS.host := crs - -# Define a dir function that can handle spaces. -# http://www.gnu.org/software/make/manual/make.html#Syntax-of-Functions -# "leading spaces cannot appear in the text of the first argument as written. -# These characters can be put into the argument value by variable substitution." -empty := -space := $(empty) $(empty) - -# http://stackoverflow.com/questions/1189781/using-make-dir-or-notdir-on-a-path-with-spaces -replace_spaces = $(subst $(space),?,$1) -unreplace_spaces = $(subst ?,$(space),$1) -dirx = $(call unreplace_spaces,$(dir $(call replace_spaces,$1))) - -# Flags to make gcc output dependency info. Note that you need to be -# careful here to use the flags that ccache and distcc can understand. -# We write to a dep file on the side first and then rename at the end -# so we can't end up with a broken dep file. -depfile = $(depsdir)/$(call replace_spaces,$@).d -DEPFLAGS = -MMD -MF $(depfile).raw - -# We have to fixup the deps output in a few ways. -# (1) the file output should mention the proper .o file. -# ccache or distcc lose the path to the target, so we convert a rule of -# the form: -# foobar.o: DEP1 DEP2 -# into -# path/to/foobar.o: DEP1 DEP2 -# (2) we want missing files not to cause us to fail to build. -# We want to rewrite -# foobar.o: DEP1 DEP2 \ -# DEP3 -# to -# DEP1: -# DEP2: -# DEP3: -# so if the files are missing, they're just considered phony rules. -# We have to do some pretty insane escaping to get those backslashes -# and dollar signs past make, the shell, and sed at the same time. -# Doesn't work with spaces, but that's fine: .d files have spaces in -# their names replaced with other characters. -define fixup_dep -# The depfile may not exist if the input file didn't have any #includes. -touch $(depfile).raw -# Fixup path as in (1). -sed -e "s|^$(notdir $@)|$@|" $(depfile).raw >> $(depfile) -# Add extra rules as in (2). -# We remove slashes and replace spaces with new lines; -# remove blank lines; -# delete the first line and append a colon to the remaining lines. -sed -e 's|\\||' -e 'y| |\n|' $(depfile).raw |\ - grep -v '^$$' |\ - sed -e 1d -e 's|$$|:|' \ - >> $(depfile) -rm $(depfile).raw -endef - -# Command definitions: -# - cmd_foo is the actual command to run; -# - quiet_cmd_foo is the brief-output summary of the command. - -quiet_cmd_cc = CC($(TOOLSET)) $@ -cmd_cc = $(CC.$(TOOLSET)) $(GYP_CFLAGS) $(DEPFLAGS) $(CFLAGS.$(TOOLSET)) -c -o $@ $< - -quiet_cmd_cxx = CXX($(TOOLSET)) $@ -cmd_cxx = $(CXX.$(TOOLSET)) $(GYP_CXXFLAGS) $(DEPFLAGS) $(CXXFLAGS.$(TOOLSET)) -c -o $@ $< - -quiet_cmd_objc = CXX($(TOOLSET)) $@ -cmd_objc = $(CC.$(TOOLSET)) $(GYP_OBJCFLAGS) $(DEPFLAGS) -c -o $@ $< - -quiet_cmd_objcxx = CXX($(TOOLSET)) $@ -cmd_objcxx = $(CXX.$(TOOLSET)) $(GYP_OBJCXXFLAGS) $(DEPFLAGS) -c -o $@ $< - -# Commands for precompiled header files. -quiet_cmd_pch_c = CXX($(TOOLSET)) $@ -cmd_pch_c = $(CC.$(TOOLSET)) $(GYP_PCH_CFLAGS) $(DEPFLAGS) $(CXXFLAGS.$(TOOLSET)) -c -o $@ $< -quiet_cmd_pch_cc = CXX($(TOOLSET)) $@ -cmd_pch_cc = $(CC.$(TOOLSET)) $(GYP_PCH_CXXFLAGS) $(DEPFLAGS) $(CXXFLAGS.$(TOOLSET)) -c -o $@ $< -quiet_cmd_pch_m = CXX($(TOOLSET)) $@ -cmd_pch_m = $(CC.$(TOOLSET)) $(GYP_PCH_OBJCFLAGS) $(DEPFLAGS) -c -o $@ $< -quiet_cmd_pch_mm = CXX($(TOOLSET)) $@ -cmd_pch_mm = $(CC.$(TOOLSET)) $(GYP_PCH_OBJCXXFLAGS) $(DEPFLAGS) -c -o $@ $< - -# gyp-mac-tool is written next to the root Makefile by gyp. -# Use $(4) for the command, since $(2) and $(3) are used as flag by do_cmd -# already. -quiet_cmd_mac_tool = MACTOOL $(4) $< -cmd_mac_tool = ./gyp-mac-tool $(4) $< "$@" - -quiet_cmd_mac_package_framework = PACKAGE FRAMEWORK $@ -cmd_mac_package_framework = ./gyp-mac-tool package-framework "$@" $(4) - -quiet_cmd_infoplist = INFOPLIST $@ -cmd_infoplist = $(CC.$(TOOLSET)) -E -P -Wno-trigraphs -x c $(INFOPLIST_DEFINES) "$<" -o "$@" - -quiet_cmd_touch = TOUCH $@ -cmd_touch = touch $@ - -quiet_cmd_copy = COPY $@ -# send stderr to /dev/null to ignore messages when linking directories. -cmd_copy = ln -f "$<" "$@" 2>/dev/null || (rm -rf "$@" && cp -af "$<" "$@") - -quiet_cmd_alink = LIBTOOL-STATIC $@ -cmd_alink = rm -f $@ && libtool -static -o $@ $(filter %.o,$^) - -quiet_cmd_link = LINK($(TOOLSET)) $@ -cmd_link = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o "$@" $(LD_INPUTS) $(LIBS) - -# TODO(thakis): Find out and document the difference between shared_library and -# loadable_module on mac. -quiet_cmd_solink = SOLINK($(TOOLSET)) $@ -cmd_solink = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o "$@" $(LD_INPUTS) $(LIBS) - -# TODO(thakis): The solink_module rule is likely wrong. Xcode seems to pass -# -bundle -single_module here (for osmesa.so). -quiet_cmd_solink_module = SOLINK_MODULE($(TOOLSET)) $@ -cmd_solink_module = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $(filter-out FORCE_DO_CMD, $^) $(LIBS) - - -# Define an escape_quotes function to escape single quotes. -# This allows us to handle quotes properly as long as we always use -# use single quotes and escape_quotes. -escape_quotes = $(subst ','\'',$(1)) -# This comment is here just to include a ' to unconfuse syntax highlighting. -# Define an escape_vars function to escape '$' variable syntax. -# This allows us to read/write command lines with shell variables (e.g. -# $LD_LIBRARY_PATH), without triggering make substitution. -escape_vars = $(subst $$,$$$$,$(1)) -# Helper that expands to a shell command to echo a string exactly as it is in -# make. This uses printf instead of echo because printf's behaviour with respect -# to escape sequences is more portable than echo's across different shells -# (e.g., dash, bash). -exact_echo = printf '%s\n' '$(call escape_quotes,$(1))' - -# Helper to compare the command we're about to run against the command -# we logged the last time we ran the command. Produces an empty -# string (false) when the commands match. -# Tricky point: Make has no string-equality test function. -# The kernel uses the following, but it seems like it would have false -# positives, where one string reordered its arguments. -# arg_check = $(strip $(filter-out $(cmd_$(1)), $(cmd_$@)) \ -# $(filter-out $(cmd_$@), $(cmd_$(1)))) -# We instead substitute each for the empty string into the other, and -# say they're equal if both substitutions produce the empty string. -# .d files contain ? instead of spaces, take that into account. -command_changed = $(or $(subst $(cmd_$(1)),,$(cmd_$(call replace_spaces,$@))),\ - $(subst $(cmd_$(call replace_spaces,$@)),,$(cmd_$(1)))) - -# Helper that is non-empty when a prerequisite changes. -# Normally make does this implicitly, but we force rules to always run -# so we can check their command lines. -# $? -- new prerequisites -# $| -- order-only dependencies -prereq_changed = $(filter-out FORCE_DO_CMD,$(filter-out $|,$?)) - -# Helper that executes all postbuilds, and deletes the output file when done -# if any of the postbuilds failed. -define do_postbuilds - @E=0;\ - for p in $(POSTBUILDS); do\ - eval $$p;\ - F=$$?;\ - if [ $$F -ne 0 ]; then\ - E=$$F;\ - fi;\ - done;\ - if [ $$E -ne 0 ]; then\ - rm -rf "$@";\ - exit $$E;\ - fi -endef - -# do_cmd: run a command via the above cmd_foo names, if necessary. -# Should always run for a given target to handle command-line changes. -# Second argument, if non-zero, makes it do asm/C/C++ dependency munging. -# Third argument, if non-zero, makes it do POSTBUILDS processing. -# Note: We intentionally do NOT call dirx for depfile, since it contains ? for -# spaces already and dirx strips the ? characters. -define do_cmd -$(if $(or $(command_changed),$(prereq_changed)), - @$(call exact_echo, $($(quiet)cmd_$(1))) - @mkdir -p "$(call dirx,$@)" "$(dir $(depfile))" - $(if $(findstring flock,$(word 2,$(cmd_$1))), - @$(cmd_$(1)) - @echo " $(quiet_cmd_$(1)): Finished", - @$(cmd_$(1)) - ) - @$(call exact_echo,$(call escape_vars,cmd_$(call replace_spaces,$@) := $(cmd_$(1)))) > $(depfile) - @$(if $(2),$(fixup_dep)) - $(if $(and $(3), $(POSTBUILDS)), - $(call do_postbuilds) - ) -) -endef - -# Declare the "all" target first so it is the default, -# even though we don't have the deps yet. -.PHONY: all -all: - -# Use FORCE_DO_CMD to force a target to run. Should be coupled with -# do_cmd. -.PHONY: FORCE_DO_CMD -FORCE_DO_CMD: - -TOOLSET := target -# Suffix rules, putting all outputs into $(obj). -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.cc FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.cpp FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.cxx FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.m FORCE_DO_CMD - @$(call do_cmd,objc,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.mm FORCE_DO_CMD - @$(call do_cmd,objcxx,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.S FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.s FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# Try building from generated source, too. -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cc FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cpp FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cxx FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.m FORCE_DO_CMD - @$(call do_cmd,objc,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.mm FORCE_DO_CMD - @$(call do_cmd,objcxx,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.S FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.s FORCE_DO_CMD - @$(call do_cmd,cc,1) - -$(obj).$(TOOLSET)/%.o: $(obj)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.cc FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.cpp FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.cxx FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.m FORCE_DO_CMD - @$(call do_cmd,objc,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.mm FORCE_DO_CMD - @$(call do_cmd,objcxx,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.S FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.s FORCE_DO_CMD - @$(call do_cmd,cc,1) - - -ifeq ($(strip $(foreach prefix,$(NO_LOAD),\ - $(findstring $(join ^,$(prefix)),\ - $(join ^,src/libuv/run-benchmarks.target.mk)))),) - include src/libuv/run-benchmarks.target.mk -endif -ifeq ($(strip $(foreach prefix,$(NO_LOAD),\ - $(findstring $(join ^,$(prefix)),\ - $(join ^,src/libuv/run-tests.target.mk)))),) - include src/libuv/run-tests.target.mk -endif -ifeq ($(strip $(foreach prefix,$(NO_LOAD),\ - $(findstring $(join ^,$(prefix)),\ - $(join ^,src/libuv/uv.target.mk)))),) - include src/libuv/uv.target.mk -endif - -#quiet_cmd_regen_makefile = ACTION Regenerating $@ -#cmd_regen_makefile = ./src/libuv/build/gyp/gyp -fmake --ignore-environment "--toplevel-dir=." -Isrc/libuv/common.gypi "--depth=." "--generator-output=mk/libuv/ia32/mac" "-Ddefault_configuration=Default" "-Dcomponent=static_library" "-Dlibrary=static_library" "-Dtarget_arch=ia32" "-DOS=mac" src/libuv/uv.gyp -#Makefile: $(srcdir)/src/libuv/uv.gyp $(srcdir)/src/libuv/common.gypi -# $(call do_cmd,regen_makefile) - -# "all" is a concatenation of the "all" targets from all the included -# sub-makefiles. This is just here to clarify. -all: - -# Add in dependency-tracking rules. $(all_deps) is the list of every single -# target in our tree. Only consider the ones with .d (dependency) info: -d_files := $(wildcard $(foreach f,$(all_deps),$(depsdir)/$(f).d)) -ifneq ($(d_files),) - # Rather than include each individual .d file, concatenate them into a - # single file which make is able to load faster. We split this into - # commands that take 1000 files at a time to avoid overflowing the - # command line. - $(shell cat $(wordlist 1,1000,$(d_files)) > $(depsdir)/all.deps) - - ifneq ($(word 1001,$(d_files)),) - $(error Found unprocessed dependency files (gyp didn't generate enough rules!)) - endif - - # make looks for ways to re-generate included makefiles, but in our case, we - # don't have a direct way. Explicitly telling make that it has nothing to do - # for them makes it go faster. - $(depsdir)/all.deps: ; - - include $(depsdir)/all.deps -endif diff --git a/mk/libuv/ia32/mac/gyp-mac-tool b/mk/libuv/ia32/mac/gyp-mac-tool deleted file mode 100755 index bd4059840ea8a..0000000000000 --- a/mk/libuv/ia32/mac/gyp-mac-tool +++ /dev/null @@ -1,193 +0,0 @@ -#!/usr/bin/env python -# Generated by gyp. Do not edit. -# Copyright (c) 2011 Google Inc. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -"""Utility functions to perform Xcode-style build steps. - -These functions are executed via gyp-mac-tool when using the Makefile generator. -""" - -import os -import fcntl -import plistlib -import shutil -import string -import subprocess -import sys - - -def main(args): - executor = MacTool() - executor.Dispatch(args) - - -class MacTool(object): - """This class performs all the Mac tooling steps. The methods can either be - executed directly, or dispatched from an argument list.""" - - def Dispatch(self, args): - """Dispatches a string command to a method.""" - if len(args) < 1: - raise Exception("Not enough arguments") - - method = "Exec%s" % self._CommandifyName(args[0]) - getattr(self, method)(*args[1:]) - - def _CommandifyName(self, name_string): - """Transforms a tool name like copy-info-plist to CopyInfoPlist""" - return name_string.title().replace('-', '') - - def ExecFlock(self, lockfile, *cmd_list): - """Emulates the most basic behavior of Linux's flock(1).""" - # Rely on exception handling to report errors. - fd = os.open(lockfile, os.O_RDONLY|os.O_NOCTTY|os.O_CREAT, 0o666) - fcntl.flock(fd, fcntl.LOCK_EX) - return subprocess.call(cmd_list) - - def ExecCopyInfoPlist(self, source, dest): - """Copies the |source| Info.plist to the destination directory |dest|.""" - # Read the source Info.plist into memory. - fd = open(source, 'r') - lines = fd.read() - fd.close() - - # Go through all the environment variables and replace them as variables in - # the file. - for key in os.environ: - if key.startswith('_'): - continue - evar = '${%s}' % key - lines = string.replace(lines, evar, os.environ[key]) - - # Write out the file with variables replaced. - fd = open(dest, 'w') - fd.write(lines) - fd.close() - - # Now write out PkgInfo file now that the Info.plist file has been - # "compiled". - self._WritePkgInfo(dest) - - def _WritePkgInfo(self, info_plist): - """This writes the PkgInfo file from the data stored in Info.plist.""" - plist = plistlib.readPlist(info_plist) - if not plist: - return - - # Only create PkgInfo for executable types. - package_type = plist['CFBundlePackageType'] - if package_type != 'APPL': - return - - # The format of PkgInfo is eight characters, representing the bundle type - # and bundle signature, each four characters. If that is missing, four - # '?' characters are used instead. - signature_code = plist['CFBundleSignature'] - if len(signature_code) != 4: - signature_code = '?' * 4 - - dest = os.path.join(os.path.dirname(info_plist), 'PkgInfo') - fp = open(dest, 'w') - fp.write('%s%s' % (package_type, signature_code)) - fp.close() - - def ExecPackageFramework(self, framework, version): - """Takes a path to Something.framework and the Current version of that and - sets up all the symlinks.""" - # Find the name of the binary based on the part before the ".framework". - binary = os.path.basename(framework).split('.')[0] - - CURRENT = 'Current' - RESOURCES = 'Resources' - VERSIONS = 'Versions' - - if not os.path.exists(os.path.join(framework, VERSIONS, version, binary)): - # Binary-less frameworks don't seem to contain symlinks (see e.g. - # chromium's out/Debug/org.chromium.Chromium.manifest/ bundle). - return - - # Move into the framework directory to set the symlinks correctly. - pwd = os.getcwd() - os.chdir(framework) - - # Set up the Current version. - self._Relink(version, os.path.join(VERSIONS, CURRENT)) - - # Set up the root symlinks. - self._Relink(os.path.join(VERSIONS, CURRENT, binary), binary) - self._Relink(os.path.join(VERSIONS, CURRENT, RESOURCES), RESOURCES) - - # Back to where we were before! - os.chdir(pwd) - - def _Relink(self, dest, link): - """Creates a symlink to |dest| named |link|. If |link| already exists, - it is overwritten.""" - if os.path.lexists(link): - os.remove(link) - os.symlink(dest, link) - - def ExecCopyBundleResource(self, source, dest): - """Copies a resource file to the bundle/Resources directory, performing any - necessary compilation on each resource.""" - extension = os.path.splitext(source)[1].lower() - if os.path.isdir(source): - # Copy tree. - if os.path.exists(dest): - shutil.rmtree(dest) - shutil.copytree(source, dest) - elif extension == '.xib': - self._CopyXIBFile(source, dest) - elif extension == '.strings': - self._CopyStringsFile(source, dest) - # TODO: Given that files with arbitrary extensions can be copied to the - # bundle, we will want to get rid of this whitelist eventually. - elif extension in [ - '.icns', '.manifest', '.pak', '.pdf', '.png', '.sb', '.sh', - '.ttf', '.sdef']: - shutil.copyfile(source, dest) - else: - raise NotImplementedError( - "Don't know how to copy bundle resources of type %s while copying " - "%s to %s)" % (extension, source, dest)) - - def _CopyXIBFile(self, source, dest): - """Compiles a XIB file with ibtool into a binary plist in the bundle.""" - args = ['/Developer/usr/bin/ibtool', '--errors', '--warnings', - '--notices', '--output-format', 'human-readable-text', '--compile', - dest, source] - subprocess.call(args) - - def _CopyStringsFile(self, source, dest): - """Copies a .strings file using iconv to reconvert the input into UTF-16.""" - input_code = self._DetectInputEncoding(source) or "UTF-8" - fp = open(dest, 'w') - args = ['/usr/bin/iconv', '--from-code', input_code, '--to-code', - 'UTF-16', source] - subprocess.call(args, stdout=fp) - fp.close() - - def _DetectInputEncoding(self, file_name): - """Reads the first few bytes from file_name and tries to guess the text - encoding. Returns None as a guess if it can't detect it.""" - fp = open(file_name, 'rb') - try: - header = fp.read(3) - except e: - fp.close() - return None - fp.close() - if header.startswith("\xFE\xFF"): - return "UTF-16BE" - elif header.startswith("\xFF\xFE"): - return "UTF-16LE" - elif header.startswith("\xEF\xBB\xBF"): - return "UTF-8" - else: - return None - - -if __name__ == '__main__': - sys.exit(main(sys.argv[1:])) diff --git a/mk/libuv/ia32/mac/src/libuv/run-benchmarks.target.mk b/mk/libuv/ia32/mac/src/libuv/run-benchmarks.target.mk deleted file mode 100644 index b8cc0a1c483ec..0000000000000 --- a/mk/libuv/ia32/mac/src/libuv/run-benchmarks.target.mk +++ /dev/null @@ -1,149 +0,0 @@ -# This file is generated by gyp; do not edit. - -TOOLSET := target -TARGET := run-benchmarks -DEFS_Debug := '-D_LARGEFILE_SOURCE' \ - '-D_FILE_OFFSET_BITS=64' \ - '-D_GNU_SOURCE' \ - '-DEIO_STACKSIZE=262144' \ - '-DDEBUG' \ - '-D_DEBUG' \ - '-DEV_VERIFY=2' - -# Flags passed to all source files. -CFLAGS_Debug := -Os \ - -gdwarf-2 \ - -fvisibility=hidden \ - -Wnewline-eof \ - -arch i386 \ - -fno-strict-aliasing \ - -Wall \ - -Wendif-labels \ - -W \ - -Wno-unused-parameter - -# Flags passed to only C files. -CFLAGS_C_Debug := - -# Flags passed to only C++ files. -CFLAGS_CC_Debug := -fno-rtti \ - -fno-exceptions \ - -fvisibility-inlines-hidden \ - -fno-threadsafe-statics - -# Flags passed to only ObjC files. -CFLAGS_OBJC_Debug := - -# Flags passed to only ObjC++ files. -CFLAGS_OBJCC_Debug := - -INCS_Debug := -I$(srcdir)/src/libuv/include - -DEFS_Release := '-D_LARGEFILE_SOURCE' \ - '-D_FILE_OFFSET_BITS=64' \ - '-D_GNU_SOURCE' \ - '-DEIO_STACKSIZE=262144' \ - '-DNDEBUG' - -# Flags passed to all source files. -CFLAGS_Release := -Os \ - -gdwarf-2 \ - -fvisibility=hidden \ - -Wnewline-eof \ - -arch i386 \ - -fno-strict-aliasing \ - -Wall \ - -Wendif-labels \ - -W \ - -Wno-unused-parameter - -# Flags passed to only C files. -CFLAGS_C_Release := - -# Flags passed to only C++ files. -CFLAGS_CC_Release := -fno-rtti \ - -fno-exceptions \ - -fvisibility-inlines-hidden \ - -fno-threadsafe-statics - -# Flags passed to only ObjC files. -CFLAGS_OBJC_Release := - -# Flags passed to only ObjC++ files. -CFLAGS_OBJCC_Release := - -INCS_Release := -I$(srcdir)/src/libuv/include - -OBJS := $(obj).target/$(TARGET)/src/libuv/test/benchmark-ares.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-getaddrinfo.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-ping-pongs.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-pound.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-pump.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-sizes.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-spawn.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-thread.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-tcp-write-batch.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-udp-packet-storm.o \ - $(obj).target/$(TARGET)/src/libuv/test/dns-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/echo-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/blackhole-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/run-benchmarks.o \ - $(obj).target/$(TARGET)/src/libuv/test/runner.o \ - $(obj).target/$(TARGET)/src/libuv/test/runner-unix.o - -# Add to the list of files we specially track dependencies for. -all_deps += $(OBJS) - -# Make sure our dependencies are built before any of us. -$(OBJS): | $(builddir)/libuv.a - -# CFLAGS et al overrides must be target-local. -# See "Target-specific Variable Values" in the GNU Make manual. -$(OBJS): TOOLSET := $(TOOLSET) -$(OBJS): GYP_CFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) -$(OBJS): GYP_CXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) -$(OBJS): GYP_OBJCFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) $(CFLAGS_OBJC_$(BUILDTYPE)) -$(OBJS): GYP_OBJCXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) $(CFLAGS_OBJCC_$(BUILDTYPE)) - -# Suffix rules, putting all outputs into $(obj). - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# Try building from generated source, too. - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# End of this set of suffix rules -### Rules for final target. -LDFLAGS_Debug := -Wl,-search_paths_first \ - -arch i386 \ - -L$(builddir) - -LDFLAGS_Release := -Wl,-search_paths_first \ - -arch i386 \ - -L$(builddir) - -LIBS := -framework Carbon \ - -framework CoreServices - -$(builddir)/run-benchmarks: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE)) -$(builddir)/run-benchmarks: LIBS := $(LIBS) -$(builddir)/run-benchmarks: LD_INPUTS := $(OBJS) $(builddir)/libuv.a -$(builddir)/run-benchmarks: TOOLSET := $(TOOLSET) -$(builddir)/run-benchmarks: $(OBJS) $(builddir)/libuv.a FORCE_DO_CMD - $(call do_cmd,link) - -all_deps += $(builddir)/run-benchmarks -# Add target alias -.PHONY: run-benchmarks -run-benchmarks: $(builddir)/run-benchmarks - -# Add executable to "all" target. -.PHONY: all -all: $(builddir)/run-benchmarks - diff --git a/mk/libuv/ia32/mac/src/libuv/run-tests.target.mk b/mk/libuv/ia32/mac/src/libuv/run-tests.target.mk deleted file mode 100644 index be0c2c6085633..0000000000000 --- a/mk/libuv/ia32/mac/src/libuv/run-tests.target.mk +++ /dev/null @@ -1,192 +0,0 @@ -# This file is generated by gyp; do not edit. - -TOOLSET := target -TARGET := run-tests -DEFS_Debug := '-D_LARGEFILE_SOURCE' \ - '-D_FILE_OFFSET_BITS=64' \ - '-D_GNU_SOURCE' \ - '-DEIO_STACKSIZE=262144' \ - '-DDEBUG' \ - '-D_DEBUG' \ - '-DEV_VERIFY=2' - -# Flags passed to all source files. -CFLAGS_Debug := -Os \ - -gdwarf-2 \ - -fvisibility=hidden \ - -Wnewline-eof \ - -arch i386 \ - -fno-strict-aliasing \ - -Wall \ - -Wendif-labels \ - -W \ - -Wno-unused-parameter - -# Flags passed to only C files. -CFLAGS_C_Debug := - -# Flags passed to only C++ files. -CFLAGS_CC_Debug := -fno-rtti \ - -fno-exceptions \ - -fvisibility-inlines-hidden \ - -fno-threadsafe-statics - -# Flags passed to only ObjC files. -CFLAGS_OBJC_Debug := - -# Flags passed to only ObjC++ files. -CFLAGS_OBJCC_Debug := - -INCS_Debug := -I$(srcdir)/src/libuv/include - -DEFS_Release := '-D_LARGEFILE_SOURCE' \ - '-D_FILE_OFFSET_BITS=64' \ - '-D_GNU_SOURCE' \ - '-DEIO_STACKSIZE=262144' \ - '-DNDEBUG' - -# Flags passed to all source files. -CFLAGS_Release := -Os \ - -gdwarf-2 \ - -fvisibility=hidden \ - -Wnewline-eof \ - -arch i386 \ - -fno-strict-aliasing \ - -Wall \ - -Wendif-labels \ - -W \ - -Wno-unused-parameter - -# Flags passed to only C files. -CFLAGS_C_Release := - -# Flags passed to only C++ files. -CFLAGS_CC_Release := -fno-rtti \ - -fno-exceptions \ - -fvisibility-inlines-hidden \ - -fno-threadsafe-statics - -# Flags passed to only ObjC files. -CFLAGS_OBJC_Release := - -# Flags passed to only ObjC++ files. -CFLAGS_OBJCC_Release := - -INCS_Release := -I$(srcdir)/src/libuv/include - -OBJS := $(obj).target/$(TARGET)/src/libuv/test/blackhole-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/echo-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/run-tests.o \ - $(obj).target/$(TARGET)/src/libuv/test/runner.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-get-loadavg.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-util.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-async.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-callback-stack.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-connection-fail.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-cwd-and-chdir.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-delayed-accept.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-eio-overflow.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-fail-always.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-fs.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-fs-event.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-get-currentexe.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-get-memory.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-getaddrinfo.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-gethostbyname.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-getsockname.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-hrtime.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-idle.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-ipc.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-ipc-threads.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-loop-handles.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-multiple-listen.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-pass-always.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-ping-pong.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-pipe-bind-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-pipe-connect-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-platform-output.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-process-title.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-ref.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-shutdown-eof.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-spawn.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-stdio-over-pipes.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-bind-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-bind6-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-close.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-flags.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-connect-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-connect6-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-write-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-write-to-half-open-connection.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-writealot.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-threadpool.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-mutexes.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-thread.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-timer-again.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-timer.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tty.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-dgram-too-big.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-ipv6.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-options.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-send-and-recv.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-multicast-join.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-counters-init.o \ - $(obj).target/$(TARGET)/src/libuv/test/runner-unix.o - -# Add to the list of files we specially track dependencies for. -all_deps += $(OBJS) - -# Make sure our dependencies are built before any of us. -$(OBJS): | $(builddir)/libuv.a - -# CFLAGS et al overrides must be target-local. -# See "Target-specific Variable Values" in the GNU Make manual. -$(OBJS): TOOLSET := $(TOOLSET) -$(OBJS): GYP_CFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) -$(OBJS): GYP_CXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) -$(OBJS): GYP_OBJCFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) $(CFLAGS_OBJC_$(BUILDTYPE)) -$(OBJS): GYP_OBJCXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) $(CFLAGS_OBJCC_$(BUILDTYPE)) - -# Suffix rules, putting all outputs into $(obj). - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# Try building from generated source, too. - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# End of this set of suffix rules -### Rules for final target. -LDFLAGS_Debug := -Wl,-search_paths_first \ - -arch i386 \ - -L$(builddir) - -LDFLAGS_Release := -Wl,-search_paths_first \ - -arch i386 \ - -L$(builddir) - -LIBS := -framework Carbon \ - -framework CoreServices - -$(builddir)/run-tests: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE)) -$(builddir)/run-tests: LIBS := $(LIBS) -$(builddir)/run-tests: LD_INPUTS := $(OBJS) $(builddir)/libuv.a -$(builddir)/run-tests: TOOLSET := $(TOOLSET) -$(builddir)/run-tests: $(OBJS) $(builddir)/libuv.a FORCE_DO_CMD - $(call do_cmd,link) - -all_deps += $(builddir)/run-tests -# Add target alias -.PHONY: run-tests -run-tests: $(builddir)/run-tests - -# Add executable to "all" target. -.PHONY: all -all: $(builddir)/run-tests - diff --git a/mk/libuv/ia32/mac/src/libuv/uv.Makefile b/mk/libuv/ia32/mac/src/libuv/uv.Makefile deleted file mode 100644 index cef4568a6d0ba..0000000000000 --- a/mk/libuv/ia32/mac/src/libuv/uv.Makefile +++ /dev/null @@ -1,6 +0,0 @@ -# This file is generated by gyp; do not edit. - -export builddir_name ?= mk/libuv/ia32/mac/./src/libuv/out -.PHONY: all -all: - $(MAKE) -C ../.. uv run-benchmarks run-tests diff --git a/mk/libuv/ia32/mac/src/libuv/uv.target.mk b/mk/libuv/ia32/mac/src/libuv/uv.target.mk deleted file mode 100644 index 9838606098248..0000000000000 --- a/mk/libuv/ia32/mac/src/libuv/uv.target.mk +++ /dev/null @@ -1,202 +0,0 @@ -# This file is generated by gyp; do not edit. - -TOOLSET := target -TARGET := uv -DEFS_Debug := '-D_LARGEFILE_SOURCE' \ - '-D_FILE_OFFSET_BITS=64' \ - '-D_GNU_SOURCE' \ - '-DEIO_STACKSIZE=262144' \ - '-DHAVE_CONFIG_H' \ - '-DEV_CONFIG_H="config_darwin.h"' \ - '-DEIO_CONFIG_H="config_darwin.h"' \ - '-DDEBUG' \ - '-D_DEBUG' \ - '-DEV_VERIFY=2' - -# Flags passed to all source files. -CFLAGS_Debug := -Os \ - -gdwarf-2 \ - -fvisibility=hidden \ - -Wnewline-eof \ - -arch i386 \ - -fno-strict-aliasing \ - -Wall \ - -Wendif-labels \ - -W \ - -Wno-unused-parameter - -# Flags passed to only C files. -CFLAGS_C_Debug := - -# Flags passed to only C++ files. -CFLAGS_CC_Debug := -fno-rtti \ - -fno-exceptions \ - -fvisibility-inlines-hidden \ - -fno-threadsafe-statics - -# Flags passed to only ObjC files. -CFLAGS_OBJC_Debug := - -# Flags passed to only ObjC++ files. -CFLAGS_OBJCC_Debug := - -INCS_Debug := -I$(srcdir)/src/libuv/include \ - -I$(srcdir)/src/libuv/include/uv-private \ - -I$(srcdir)/src/libuv/src \ - -I$(srcdir)/src/libuv/src/unix/ev \ - -I$(srcdir)/src/libuv/src/ares/config_darwin - -DEFS_Release := '-D_LARGEFILE_SOURCE' \ - '-D_FILE_OFFSET_BITS=64' \ - '-D_GNU_SOURCE' \ - '-DEIO_STACKSIZE=262144' \ - '-DHAVE_CONFIG_H' \ - '-DEV_CONFIG_H="config_darwin.h"' \ - '-DEIO_CONFIG_H="config_darwin.h"' \ - '-DNDEBUG' - -# Flags passed to all source files. -CFLAGS_Release := -Os \ - -gdwarf-2 \ - -fvisibility=hidden \ - -Wnewline-eof \ - -arch i386 \ - -fno-strict-aliasing \ - -Wall \ - -Wendif-labels \ - -W \ - -Wno-unused-parameter - -# Flags passed to only C files. -CFLAGS_C_Release := - -# Flags passed to only C++ files. -CFLAGS_CC_Release := -fno-rtti \ - -fno-exceptions \ - -fvisibility-inlines-hidden \ - -fno-threadsafe-statics - -# Flags passed to only ObjC files. -CFLAGS_OBJC_Release := - -# Flags passed to only ObjC++ files. -CFLAGS_OBJCC_Release := - -INCS_Release := -I$(srcdir)/src/libuv/include \ - -I$(srcdir)/src/libuv/include/uv-private \ - -I$(srcdir)/src/libuv/src \ - -I$(srcdir)/src/libuv/src/unix/ev \ - -I$(srcdir)/src/libuv/src/ares/config_darwin - -OBJS := $(obj).target/$(TARGET)/src/libuv/src/uv-common.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_cancel.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares__close_sockets.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_data.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_destroy.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_expand_name.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_expand_string.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_fds.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_free_hostent.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_free_string.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_gethostbyaddr.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_gethostbyname.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares__get_hostent.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_getnameinfo.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_getopt.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_getsock.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_init.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_library_init.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_llist.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_mkquery.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_nowarn.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_options.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_aaaa_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_a_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_mx_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_ns_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_ptr_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_srv_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_txt_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_process.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_query.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares__read_line.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_search.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_send.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_strcasecmp.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_strdup.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_strerror.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_timeout.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares__timeval.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_version.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_writev.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/bitncmp.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/inet_net_pton.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/inet_ntop.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/windows_port.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/core.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/uv-eio.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/fs.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/udp.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/tcp.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/pipe.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/tty.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/stream.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/cares.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/dl.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/error.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/thread.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/process.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/eio/eio.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/ev/ev.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/darwin.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/kqueue.o - -# Add to the list of files we specially track dependencies for. -all_deps += $(OBJS) - -# CFLAGS et al overrides must be target-local. -# See "Target-specific Variable Values" in the GNU Make manual. -$(OBJS): TOOLSET := $(TOOLSET) -$(OBJS): GYP_CFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) -$(OBJS): GYP_CXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) -$(OBJS): GYP_OBJCFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) $(CFLAGS_OBJC_$(BUILDTYPE)) -$(OBJS): GYP_OBJCXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) $(CFLAGS_OBJCC_$(BUILDTYPE)) - -# Suffix rules, putting all outputs into $(obj). - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# Try building from generated source, too. - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# End of this set of suffix rules -### Rules for final target. -LDFLAGS_Debug := -arch i386 \ - -L$(builddir) - -LDFLAGS_Release := -arch i386 \ - -L$(builddir) - -LIBS := -lm - -$(builddir)/libuv.a: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE)) -$(builddir)/libuv.a: LIBS := $(LIBS) -$(builddir)/libuv.a: TOOLSET := $(TOOLSET) -$(builddir)/libuv.a: $(OBJS) FORCE_DO_CMD - $(call do_cmd,alink) - -all_deps += $(builddir)/libuv.a -# Add target alias -.PHONY: uv -uv: $(builddir)/libuv.a - -# Add target alias to "all" target. -.PHONY: all -all: uv - diff --git a/mk/libuv/ia32/unix/linux/Makefile b/mk/libuv/ia32/unix/linux/Makefile deleted file mode 100644 index 1afa619357014..0000000000000 --- a/mk/libuv/ia32/unix/linux/Makefile +++ /dev/null @@ -1,354 +0,0 @@ -# We borrow heavily from the kernel build setup, though we are simpler since -# we don't have Kconfig tweaking settings on us. - -# The implicit make rules have it looking for RCS files, among other things. -# We instead explicitly write all the rules we care about. -# It's even quicker (saves ~200ms) to pass -r on the command line. -MAKEFLAGS=-r - -# The source directory tree. -srcdir := ../../../../.. -abs_srcdir := $(abspath $(srcdir)) - -# The name of the builddir. -builddir_name ?= out - -# The V=1 flag on command line makes us verbosely print command lines. -ifdef V - quiet= -else - quiet=quiet_ -endif - -# Specify BUILDTYPE=Release on the command line for a release build. -BUILDTYPE ?= Debug - -# Directory all our build output goes into. -# Note that this must be two directories beneath src/ for unit tests to pass, -# as they reach into the src/ directory for data with relative paths. -builddir ?= $(builddir_name)/$(BUILDTYPE) -abs_builddir := $(abspath $(builddir)) -depsdir := $(builddir)/.deps - -# Object output directory. -obj := $(builddir)/obj -abs_obj := $(abspath $(obj)) - -# We build up a list of every single one of the targets so we can slurp in the -# generated dependency rule Makefiles in one pass. -all_deps := - - - -# C++ apps need to be linked with g++. -# -# Note: flock is used to seralize linking. Linking is a memory-intensive -# process so running parallel links can often lead to thrashing. To disable -# the serialization, override LINK via an envrionment variable as follows: -# -# export LINK=g++ -# -# This will allow make to invoke N linker processes as specified in -jN. -LINK ?= flock $(builddir)/linker.lock $(CXX) - -CC.target ?= $(CC) -CFLAGS.target ?= $(CFLAGS) -CXX.target ?= $(CXX) -CXXFLAGS.target ?= $(CXXFLAGS) -LINK.target ?= $(LINK) -LDFLAGS.target ?= $(LDFLAGS) -AR.target ?= $(AR) -ARFLAGS.target ?= crsT - -# N.B.: the logic of which commands to run should match the computation done -# in gyp's make.py where ARFLAGS.host etc. is computed. -# TODO(evan): move all cross-compilation logic to gyp-time so we don't need -# to replicate this environment fallback in make as well. -CC.host ?= gcc -CFLAGS.host ?= -CXX.host ?= g++ -CXXFLAGS.host ?= -LINK.host ?= g++ -LDFLAGS.host ?= -AR.host ?= ar -ARFLAGS.host := crsT - -# Define a dir function that can handle spaces. -# http://www.gnu.org/software/make/manual/make.html#Syntax-of-Functions -# "leading spaces cannot appear in the text of the first argument as written. -# These characters can be put into the argument value by variable substitution." -empty := -space := $(empty) $(empty) - -# http://stackoverflow.com/questions/1189781/using-make-dir-or-notdir-on-a-path-with-spaces -replace_spaces = $(subst $(space),?,$1) -unreplace_spaces = $(subst ?,$(space),$1) -dirx = $(call unreplace_spaces,$(dir $(call replace_spaces,$1))) - -# Flags to make gcc output dependency info. Note that you need to be -# careful here to use the flags that ccache and distcc can understand. -# We write to a dep file on the side first and then rename at the end -# so we can't end up with a broken dep file. -depfile = $(depsdir)/$(call replace_spaces,$@).d -DEPFLAGS = -MMD -MF $(depfile).raw - -# We have to fixup the deps output in a few ways. -# (1) the file output should mention the proper .o file. -# ccache or distcc lose the path to the target, so we convert a rule of -# the form: -# foobar.o: DEP1 DEP2 -# into -# path/to/foobar.o: DEP1 DEP2 -# (2) we want missing files not to cause us to fail to build. -# We want to rewrite -# foobar.o: DEP1 DEP2 \ -# DEP3 -# to -# DEP1: -# DEP2: -# DEP3: -# so if the files are missing, they're just considered phony rules. -# We have to do some pretty insane escaping to get those backslashes -# and dollar signs past make, the shell, and sed at the same time. -# Doesn't work with spaces, but that's fine: .d files have spaces in -# their names replaced with other characters. -define fixup_dep -# The depfile may not exist if the input file didn't have any #includes. -touch $(depfile).raw -# Fixup path as in (1). -sed -e "s|^$(notdir $@)|$@|" $(depfile).raw >> $(depfile) -# Add extra rules as in (2). -# We remove slashes and replace spaces with new lines; -# remove blank lines; -# delete the first line and append a colon to the remaining lines. -sed -e 's|\\||' -e 'y| |\n|' $(depfile).raw |\ - grep -v '^$$' |\ - sed -e 1d -e 's|$$|:|' \ - >> $(depfile) -rm $(depfile).raw -endef - -# Command definitions: -# - cmd_foo is the actual command to run; -# - quiet_cmd_foo is the brief-output summary of the command. - -quiet_cmd_cc = CC($(TOOLSET)) $@ -cmd_cc = $(CC.$(TOOLSET)) $(GYP_CFLAGS) $(DEPFLAGS) $(CFLAGS.$(TOOLSET)) -c -o $@ $< - -quiet_cmd_cxx = CXX($(TOOLSET)) $@ -cmd_cxx = $(CXX.$(TOOLSET)) $(GYP_CXXFLAGS) $(DEPFLAGS) $(CXXFLAGS.$(TOOLSET)) -c -o $@ $< - -quiet_cmd_touch = TOUCH $@ -cmd_touch = touch $@ - -quiet_cmd_copy = COPY $@ -# send stderr to /dev/null to ignore messages when linking directories. -cmd_copy = ln -f "$<" "$@" 2>/dev/null || (rm -rf "$@" && cp -af "$<" "$@") - -quiet_cmd_alink = AR($(TOOLSET)) $@ -cmd_alink = rm -f $@ && $(AR.$(TOOLSET)) $(ARFLAGS.$(TOOLSET)) $@ $(filter %.o,$^) - -# Due to circular dependencies between libraries :(, we wrap the -# special "figure out circular dependencies" flags around the entire -# input list during linking. -quiet_cmd_link = LINK($(TOOLSET)) $@ -cmd_link = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ -Wl,--start-group $(LD_INPUTS) -Wl,--end-group $(LIBS) - -# We support two kinds of shared objects (.so): -# 1) shared_library, which is just bundling together many dependent libraries -# into a link line. -# 2) loadable_module, which is generating a module intended for dlopen(). -# -# They differ only slightly: -# In the former case, we want to package all dependent code into the .so. -# In the latter case, we want to package just the API exposed by the -# outermost module. -# This means shared_library uses --whole-archive, while loadable_module doesn't. -# (Note that --whole-archive is incompatible with the --start-group used in -# normal linking.) - -# Other shared-object link notes: -# - Set SONAME to the library filename so our binaries don't reference -# the local, absolute paths used on the link command-line. -quiet_cmd_solink = SOLINK($(TOOLSET)) $@ -cmd_solink = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -Wl,-soname=$(@F) -o $@ -Wl,--whole-archive $(LD_INPUTS) -Wl,--no-whole-archive $(LIBS) - -quiet_cmd_solink_module = SOLINK_MODULE($(TOOLSET)) $@ -cmd_solink_module = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -Wl,-soname=$(@F) -o $@ -Wl,--start-group $(filter-out FORCE_DO_CMD, $^) -Wl,--end-group $(LIBS) - - -# Define an escape_quotes function to escape single quotes. -# This allows us to handle quotes properly as long as we always use -# use single quotes and escape_quotes. -escape_quotes = $(subst ','\'',$(1)) -# This comment is here just to include a ' to unconfuse syntax highlighting. -# Define an escape_vars function to escape '$' variable syntax. -# This allows us to read/write command lines with shell variables (e.g. -# $LD_LIBRARY_PATH), without triggering make substitution. -escape_vars = $(subst $$,$$$$,$(1)) -# Helper that expands to a shell command to echo a string exactly as it is in -# make. This uses printf instead of echo because printf's behaviour with respect -# to escape sequences is more portable than echo's across different shells -# (e.g., dash, bash). -exact_echo = printf '%s\n' '$(call escape_quotes,$(1))' - -# Helper to compare the command we're about to run against the command -# we logged the last time we ran the command. Produces an empty -# string (false) when the commands match. -# Tricky point: Make has no string-equality test function. -# The kernel uses the following, but it seems like it would have false -# positives, where one string reordered its arguments. -# arg_check = $(strip $(filter-out $(cmd_$(1)), $(cmd_$@)) \ -# $(filter-out $(cmd_$@), $(cmd_$(1)))) -# We instead substitute each for the empty string into the other, and -# say they're equal if both substitutions produce the empty string. -# .d files contain ? instead of spaces, take that into account. -command_changed = $(or $(subst $(cmd_$(1)),,$(cmd_$(call replace_spaces,$@))),\ - $(subst $(cmd_$(call replace_spaces,$@)),,$(cmd_$(1)))) - -# Helper that is non-empty when a prerequisite changes. -# Normally make does this implicitly, but we force rules to always run -# so we can check their command lines. -# $? -- new prerequisites -# $| -- order-only dependencies -prereq_changed = $(filter-out FORCE_DO_CMD,$(filter-out $|,$?)) - -# Helper that executes all postbuilds, and deletes the output file when done -# if any of the postbuilds failed. -define do_postbuilds - @E=0;\ - for p in $(POSTBUILDS); do\ - eval $$p;\ - F=$$?;\ - if [ $$F -ne 0 ]; then\ - E=$$F;\ - fi;\ - done;\ - if [ $$E -ne 0 ]; then\ - rm -rf "$@";\ - exit $$E;\ - fi -endef - -# do_cmd: run a command via the above cmd_foo names, if necessary. -# Should always run for a given target to handle command-line changes. -# Second argument, if non-zero, makes it do asm/C/C++ dependency munging. -# Third argument, if non-zero, makes it do POSTBUILDS processing. -# Note: We intentionally do NOT call dirx for depfile, since it contains ? for -# spaces already and dirx strips the ? characters. -define do_cmd -$(if $(or $(command_changed),$(prereq_changed)), - @$(call exact_echo, $($(quiet)cmd_$(1))) - @mkdir -p "$(call dirx,$@)" "$(dir $(depfile))" - $(if $(findstring flock,$(word 1,$(cmd_$1))), - @$(cmd_$(1)) - @echo " $(quiet_cmd_$(1)): Finished", - @$(cmd_$(1)) - ) - @$(call exact_echo,$(call escape_vars,cmd_$(call replace_spaces,$@) := $(cmd_$(1)))) > $(depfile) - @$(if $(2),$(fixup_dep)) - $(if $(and $(3), $(POSTBUILDS)), - $(call do_postbuilds) - ) -) -endef - -# Declare the "all" target first so it is the default, -# even though we don't have the deps yet. -.PHONY: all -all: - -# Use FORCE_DO_CMD to force a target to run. Should be coupled with -# do_cmd. -.PHONY: FORCE_DO_CMD -FORCE_DO_CMD: - -TOOLSET := target -# Suffix rules, putting all outputs into $(obj). -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.cc FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.cpp FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.cxx FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.S FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.s FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# Try building from generated source, too. -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cc FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cpp FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cxx FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.S FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.s FORCE_DO_CMD - @$(call do_cmd,cc,1) - -$(obj).$(TOOLSET)/%.o: $(obj)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.cc FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.cpp FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.cxx FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.S FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.s FORCE_DO_CMD - @$(call do_cmd,cc,1) - - -ifeq ($(strip $(foreach prefix,$(NO_LOAD),\ - $(findstring $(join ^,$(prefix)),\ - $(join ^,src/libuv/run-benchmarks.target.mk)))),) - include src/libuv/run-benchmarks.target.mk -endif -ifeq ($(strip $(foreach prefix,$(NO_LOAD),\ - $(findstring $(join ^,$(prefix)),\ - $(join ^,src/libuv/run-tests.target.mk)))),) - include src/libuv/run-tests.target.mk -endif -ifeq ($(strip $(foreach prefix,$(NO_LOAD),\ - $(findstring $(join ^,$(prefix)),\ - $(join ^,src/libuv/uv.target.mk)))),) - include src/libuv/uv.target.mk -endif - -#quiet_cmd_regen_makefile = ACTION Regenerating $@ -#cmd_regen_makefile = ./src/libuv/build/gyp/gyp -fmake --ignore-environment "--toplevel-dir=." -Isrc/libuv/common.gypi "--depth=." "--generator-output=mk/libuv/ia32/unix/linux" "-Ddefault_configuration=Default" "-Dcomponent=static_library" "-Dlibrary=static_library" "-Dtarget_arch=ia32" "-DOS=linux" src/libuv/uv.gyp -#Makefile: $(srcdir)/src/libuv/uv.gyp $(srcdir)/src/libuv/common.gypi -# $(call do_cmd,regen_makefile) - -# "all" is a concatenation of the "all" targets from all the included -# sub-makefiles. This is just here to clarify. -all: - -# Add in dependency-tracking rules. $(all_deps) is the list of every single -# target in our tree. Only consider the ones with .d (dependency) info: -d_files := $(wildcard $(foreach f,$(all_deps),$(depsdir)/$(f).d)) -ifneq ($(d_files),) - # Rather than include each individual .d file, concatenate them into a - # single file which make is able to load faster. We split this into - # commands that take 1000 files at a time to avoid overflowing the - # command line. - $(shell cat $(wordlist 1,1000,$(d_files)) > $(depsdir)/all.deps) - - ifneq ($(word 1001,$(d_files)),) - $(error Found unprocessed dependency files (gyp didn't generate enough rules!)) - endif - - # make looks for ways to re-generate included makefiles, but in our case, we - # don't have a direct way. Explicitly telling make that it has nothing to do - # for them makes it go faster. - $(depsdir)/all.deps: ; - - include $(depsdir)/all.deps -endif diff --git a/mk/libuv/ia32/unix/linux/src/libuv/run-benchmarks.target.mk b/mk/libuv/ia32/unix/linux/src/libuv/run-benchmarks.target.mk deleted file mode 100644 index 25b01014e79d4..0000000000000 --- a/mk/libuv/ia32/unix/linux/src/libuv/run-benchmarks.target.mk +++ /dev/null @@ -1,122 +0,0 @@ -# This file is generated by gyp; do not edit. - -TOOLSET := target -TARGET := run-benchmarks -DEFS_Debug := '-D_LARGEFILE_SOURCE' \ - '-D_FILE_OFFSET_BITS=64' \ - '-D_GNU_SOURCE' \ - '-DEIO_STACKSIZE=262144' \ - '-DDEBUG' \ - '-D_DEBUG' \ - '-DEV_VERIFY=2' - -# Flags passed to all source files. -CFLAGS_Debug := -pthread \ - -Wall \ - -ansi \ - -pthread \ - -fvisibility=hidden \ - -g \ - -O0 - -# Flags passed to only C files. -CFLAGS_C_Debug := - -# Flags passed to only C++ files. -CFLAGS_CC_Debug := -fno-rtti \ - -fno-exceptions - -INCS_Debug := -I$(srcdir)/src/libuv/include - -DEFS_Release := '-D_LARGEFILE_SOURCE' \ - '-D_FILE_OFFSET_BITS=64' \ - '-D_GNU_SOURCE' \ - '-DEIO_STACKSIZE=262144' \ - '-DNDEBUG' - -# Flags passed to all source files. -CFLAGS_Release := -pthread \ - -Wall \ - -ansi \ - -pthread \ - -fvisibility=hidden \ - -O3 \ - -fomit-frame-pointer \ - -fdata-sections \ - -ffunction-sections - -# Flags passed to only C files. -CFLAGS_C_Release := - -# Flags passed to only C++ files. -CFLAGS_CC_Release := -fno-rtti \ - -fno-exceptions - -INCS_Release := -I$(srcdir)/src/libuv/include - -OBJS := $(obj).target/$(TARGET)/src/libuv/test/benchmark-ares.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-getaddrinfo.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-ping-pongs.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-pound.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-pump.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-sizes.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-spawn.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-thread.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-tcp-write-batch.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-udp-packet-storm.o \ - $(obj).target/$(TARGET)/src/libuv/test/dns-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/echo-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/blackhole-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/run-benchmarks.o \ - $(obj).target/$(TARGET)/src/libuv/test/runner.o \ - $(obj).target/$(TARGET)/src/libuv/test/runner-unix.o - -# Add to the list of files we specially track dependencies for. -all_deps += $(OBJS) - -# Make sure our dependencies are built before any of us. -$(OBJS): | $(obj).target/src/libuv/libuv.a - -# CFLAGS et al overrides must be target-local. -# See "Target-specific Variable Values" in the GNU Make manual. -$(OBJS): TOOLSET := $(TOOLSET) -$(OBJS): GYP_CFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) -$(OBJS): GYP_CXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) - -# Suffix rules, putting all outputs into $(obj). - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# Try building from generated source, too. - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# End of this set of suffix rules -### Rules for final target. -LDFLAGS_Debug := -pthread - -LDFLAGS_Release := -pthread - -LIBS := -lrt - -$(builddir)/run-benchmarks: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE)) -$(builddir)/run-benchmarks: LIBS := $(LIBS) -$(builddir)/run-benchmarks: LD_INPUTS := $(OBJS) $(obj).target/src/libuv/libuv.a -$(builddir)/run-benchmarks: TOOLSET := $(TOOLSET) -$(builddir)/run-benchmarks: $(OBJS) $(obj).target/src/libuv/libuv.a FORCE_DO_CMD - $(call do_cmd,link) - -all_deps += $(builddir)/run-benchmarks -# Add target alias -.PHONY: run-benchmarks -run-benchmarks: $(builddir)/run-benchmarks - -# Add executable to "all" target. -.PHONY: all -all: $(builddir)/run-benchmarks - diff --git a/mk/libuv/ia32/unix/linux/src/libuv/run-tests.target.mk b/mk/libuv/ia32/unix/linux/src/libuv/run-tests.target.mk deleted file mode 100644 index a2fe0d2065e23..0000000000000 --- a/mk/libuv/ia32/unix/linux/src/libuv/run-tests.target.mk +++ /dev/null @@ -1,165 +0,0 @@ -# This file is generated by gyp; do not edit. - -TOOLSET := target -TARGET := run-tests -DEFS_Debug := '-D_LARGEFILE_SOURCE' \ - '-D_FILE_OFFSET_BITS=64' \ - '-D_GNU_SOURCE' \ - '-DEIO_STACKSIZE=262144' \ - '-DDEBUG' \ - '-D_DEBUG' \ - '-DEV_VERIFY=2' - -# Flags passed to all source files. -CFLAGS_Debug := -pthread \ - -Wall \ - -ansi \ - -pthread \ - -fvisibility=hidden \ - -g \ - -O0 - -# Flags passed to only C files. -CFLAGS_C_Debug := - -# Flags passed to only C++ files. -CFLAGS_CC_Debug := -fno-rtti \ - -fno-exceptions - -INCS_Debug := -I$(srcdir)/src/libuv/include - -DEFS_Release := '-D_LARGEFILE_SOURCE' \ - '-D_FILE_OFFSET_BITS=64' \ - '-D_GNU_SOURCE' \ - '-DEIO_STACKSIZE=262144' \ - '-DNDEBUG' - -# Flags passed to all source files. -CFLAGS_Release := -pthread \ - -Wall \ - -ansi \ - -pthread \ - -fvisibility=hidden \ - -O3 \ - -fomit-frame-pointer \ - -fdata-sections \ - -ffunction-sections - -# Flags passed to only C files. -CFLAGS_C_Release := - -# Flags passed to only C++ files. -CFLAGS_CC_Release := -fno-rtti \ - -fno-exceptions - -INCS_Release := -I$(srcdir)/src/libuv/include - -OBJS := $(obj).target/$(TARGET)/src/libuv/test/blackhole-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/echo-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/run-tests.o \ - $(obj).target/$(TARGET)/src/libuv/test/runner.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-get-loadavg.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-util.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-async.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-callback-stack.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-connection-fail.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-cwd-and-chdir.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-delayed-accept.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-eio-overflow.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-fail-always.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-fs.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-fs-event.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-get-currentexe.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-get-memory.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-getaddrinfo.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-gethostbyname.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-getsockname.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-hrtime.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-idle.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-ipc.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-ipc-threads.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-loop-handles.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-multiple-listen.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-pass-always.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-ping-pong.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-pipe-bind-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-pipe-connect-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-platform-output.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-process-title.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-ref.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-shutdown-eof.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-spawn.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-stdio-over-pipes.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-bind-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-bind6-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-close.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-flags.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-connect-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-connect6-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-write-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-write-to-half-open-connection.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-writealot.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-threadpool.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-mutexes.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-thread.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-timer-again.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-timer.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tty.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-dgram-too-big.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-ipv6.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-options.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-send-and-recv.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-multicast-join.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-counters-init.o \ - $(obj).target/$(TARGET)/src/libuv/test/runner-unix.o - -# Add to the list of files we specially track dependencies for. -all_deps += $(OBJS) - -# Make sure our dependencies are built before any of us. -$(OBJS): | $(obj).target/src/libuv/libuv.a - -# CFLAGS et al overrides must be target-local. -# See "Target-specific Variable Values" in the GNU Make manual. -$(OBJS): TOOLSET := $(TOOLSET) -$(OBJS): GYP_CFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) -$(OBJS): GYP_CXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) - -# Suffix rules, putting all outputs into $(obj). - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# Try building from generated source, too. - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# End of this set of suffix rules -### Rules for final target. -LDFLAGS_Debug := -pthread - -LDFLAGS_Release := -pthread - -LIBS := -lrt - -$(builddir)/run-tests: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE)) -$(builddir)/run-tests: LIBS := $(LIBS) -$(builddir)/run-tests: LD_INPUTS := $(OBJS) $(obj).target/src/libuv/libuv.a -$(builddir)/run-tests: TOOLSET := $(TOOLSET) -$(builddir)/run-tests: $(OBJS) $(obj).target/src/libuv/libuv.a FORCE_DO_CMD - $(call do_cmd,link) - -all_deps += $(builddir)/run-tests -# Add target alias -.PHONY: run-tests -run-tests: $(builddir)/run-tests - -# Add executable to "all" target. -.PHONY: all -all: $(builddir)/run-tests - diff --git a/mk/libuv/ia32/unix/linux/src/libuv/uv.Makefile b/mk/libuv/ia32/unix/linux/src/libuv/uv.Makefile deleted file mode 100644 index fb013a6f4b16b..0000000000000 --- a/mk/libuv/ia32/unix/linux/src/libuv/uv.Makefile +++ /dev/null @@ -1,6 +0,0 @@ -# This file is generated by gyp; do not edit. - -export builddir_name ?= mk/libuv/ia32/unix/linux/./src/libuv/out -.PHONY: all -all: - $(MAKE) -C ../.. uv run-benchmarks run-tests diff --git a/mk/libuv/ia32/unix/linux/src/libuv/uv.target.mk b/mk/libuv/ia32/unix/linux/src/libuv/uv.target.mk deleted file mode 100644 index 60e0e8fd2def6..0000000000000 --- a/mk/libuv/ia32/unix/linux/src/libuv/uv.target.mk +++ /dev/null @@ -1,189 +0,0 @@ -# This file is generated by gyp; do not edit. - -TOOLSET := target -TARGET := uv -DEFS_Debug := '-D_LARGEFILE_SOURCE' \ - '-D_FILE_OFFSET_BITS=64' \ - '-D_GNU_SOURCE' \ - '-DEIO_STACKSIZE=262144' \ - '-DHAVE_CONFIG_H' \ - '-DEV_CONFIG_H="config_linux.h"' \ - '-DEIO_CONFIG_H="config_linux.h"' \ - '-DDEBUG' \ - '-D_DEBUG' \ - '-DEV_VERIFY=2' - -# Flags passed to all source files. -CFLAGS_Debug := -pthread \ - -Wall \ - -ansi \ - -pthread \ - -fvisibility=hidden \ - -g \ - --std=gnu89 \ - -pedantic \ - -Wall \ - -Wextra \ - -Wno-unused-parameter \ - -g \ - -O0 - -# Flags passed to only C files. -CFLAGS_C_Debug := - -# Flags passed to only C++ files. -CFLAGS_CC_Debug := -fno-rtti \ - -fno-exceptions - -INCS_Debug := -I$(srcdir)/src/libuv/include \ - -I$(srcdir)/src/libuv/include/uv-private \ - -I$(srcdir)/src/libuv/src \ - -I$(srcdir)/src/libuv/src/unix/ev \ - -I$(srcdir)/src/libuv/src/ares/config_linux - -DEFS_Release := '-D_LARGEFILE_SOURCE' \ - '-D_FILE_OFFSET_BITS=64' \ - '-D_GNU_SOURCE' \ - '-DEIO_STACKSIZE=262144' \ - '-DHAVE_CONFIG_H' \ - '-DEV_CONFIG_H="config_linux.h"' \ - '-DEIO_CONFIG_H="config_linux.h"' \ - '-DNDEBUG' - -# Flags passed to all source files. -CFLAGS_Release := -pthread \ - -Wall \ - -ansi \ - -pthread \ - -fvisibility=hidden \ - -g \ - --std=gnu89 \ - -pedantic \ - -Wall \ - -Wextra \ - -Wno-unused-parameter \ - -O3 \ - -fomit-frame-pointer \ - -fdata-sections \ - -ffunction-sections - -# Flags passed to only C files. -CFLAGS_C_Release := - -# Flags passed to only C++ files. -CFLAGS_CC_Release := -fno-rtti \ - -fno-exceptions - -INCS_Release := -I$(srcdir)/src/libuv/include \ - -I$(srcdir)/src/libuv/include/uv-private \ - -I$(srcdir)/src/libuv/src \ - -I$(srcdir)/src/libuv/src/unix/ev \ - -I$(srcdir)/src/libuv/src/ares/config_linux - -OBJS := $(obj).target/$(TARGET)/src/libuv/src/uv-common.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_cancel.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares__close_sockets.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_data.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_destroy.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_expand_name.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_expand_string.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_fds.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_free_hostent.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_free_string.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_gethostbyaddr.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_gethostbyname.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares__get_hostent.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_getnameinfo.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_getopt.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_getsock.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_init.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_library_init.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_llist.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_mkquery.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_nowarn.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_options.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_aaaa_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_a_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_mx_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_ns_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_ptr_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_srv_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_txt_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_process.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_query.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares__read_line.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_search.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_send.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_strcasecmp.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_strdup.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_strerror.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_timeout.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares__timeval.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_version.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_writev.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/bitncmp.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/inet_net_pton.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/inet_ntop.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/windows_port.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/core.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/uv-eio.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/fs.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/udp.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/tcp.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/pipe.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/tty.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/stream.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/cares.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/dl.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/error.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/thread.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/process.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/eio/eio.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/ev/ev.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/linux.o - -# Add to the list of files we specially track dependencies for. -all_deps += $(OBJS) - -# CFLAGS et al overrides must be target-local. -# See "Target-specific Variable Values" in the GNU Make manual. -$(OBJS): TOOLSET := $(TOOLSET) -$(OBJS): GYP_CFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) -$(OBJS): GYP_CXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) - -# Suffix rules, putting all outputs into $(obj). - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# Try building from generated source, too. - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# End of this set of suffix rules -### Rules for final target. -LDFLAGS_Debug := -pthread - -LDFLAGS_Release := -pthread - -LIBS := -lm - -$(obj).target/src/libuv/libuv.a: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE)) -$(obj).target/src/libuv/libuv.a: LIBS := $(LIBS) -$(obj).target/src/libuv/libuv.a: TOOLSET := $(TOOLSET) -$(obj).target/src/libuv/libuv.a: $(OBJS) FORCE_DO_CMD - $(call do_cmd,alink) - -all_deps += $(obj).target/src/libuv/libuv.a -# Add target alias -.PHONY: uv -uv: $(obj).target/src/libuv/libuv.a - -# Add target alias to "all" target. -.PHONY: all -all: uv - diff --git a/mk/libuv/ia32/win/Makefile b/mk/libuv/ia32/win/Makefile deleted file mode 100644 index 8a6222228d891..0000000000000 --- a/mk/libuv/ia32/win/Makefile +++ /dev/null @@ -1,354 +0,0 @@ -# We borrow heavily from the kernel build setup, though we are simpler since -# we don't have Kconfig tweaking settings on us. - -# The implicit make rules have it looking for RCS files, among other things. -# We instead explicitly write all the rules we care about. -# It's even quicker (saves ~200ms) to pass -r on the command line. -MAKEFLAGS=-r - -# The source directory tree. -srcdir := ../../../.. -abs_srcdir := $(abspath $(srcdir)) - -# The name of the builddir. -builddir_name ?= out - -# The V=1 flag on command line makes us verbosely print command lines. -ifdef V - quiet= -else - quiet=quiet_ -endif - -# Specify BUILDTYPE=Release on the command line for a release build. -BUILDTYPE ?= Debug - -# Directory all our build output goes into. -# Note that this must be two directories beneath src/ for unit tests to pass, -# as they reach into the src/ directory for data with relative paths. -builddir ?= $(builddir_name)/$(BUILDTYPE) -abs_builddir := $(abspath $(builddir)) -depsdir := $(builddir)/.deps - -# Object output directory. -obj := $(builddir)/obj -abs_obj := $(abspath $(obj)) - -# We build up a list of every single one of the targets so we can slurp in the -# generated dependency rule Makefiles in one pass. -all_deps := - - - -# C++ apps need to be linked with g++. -# -# Note: flock is used to seralize linking. Linking is a memory-intensive -# process so running parallel links can often lead to thrashing. To disable -# the serialization, override LINK via an envrionment variable as follows: -# -# export LINK=g++ -# -# This will allow make to invoke N linker processes as specified in -jN. -LINK ?= flock $(builddir)/linker.lock $(CXX) - -CC.target ?= $(CC) -CFLAGS.target ?= $(CFLAGS) -CXX.target ?= $(CXX) -CXXFLAGS.target ?= $(CXXFLAGS) -LINK.target ?= $(LINK) -LDFLAGS.target ?= $(LDFLAGS) -AR.target ?= $(AR) -ARFLAGS.target ?= crsT - -# N.B.: the logic of which commands to run should match the computation done -# in gyp's make.py where ARFLAGS.host etc. is computed. -# TODO(evan): move all cross-compilation logic to gyp-time so we don't need -# to replicate this environment fallback in make as well. -CC.host ?= gcc -CFLAGS.host ?= -CXX.host ?= g++ -CXXFLAGS.host ?= -LINK.host ?= g++ -LDFLAGS.host ?= -AR.host ?= ar -ARFLAGS.host := crsT - -# Define a dir function that can handle spaces. -# http://www.gnu.org/software/make/manual/make.html#Syntax-of-Functions -# "leading spaces cannot appear in the text of the first argument as written. -# These characters can be put into the argument value by variable substitution." -empty := -space := $(empty) $(empty) - -# http://stackoverflow.com/questions/1189781/using-make-dir-or-notdir-on-a-path-with-spaces -replace_spaces = $(subst $(space),?,$1) -unreplace_spaces = $(subst ?,$(space),$1) -dirx = $(call unreplace_spaces,$(dir $(call replace_spaces,$1))) - -# Flags to make gcc output dependency info. Note that you need to be -# careful here to use the flags that ccache and distcc can understand. -# We write to a dep file on the side first and then rename at the end -# so we can't end up with a broken dep file. -depfile = $(depsdir)/$(call replace_spaces,$@).d -DEPFLAGS = -MMD -MF $(depfile).raw - -# We have to fixup the deps output in a few ways. -# (1) the file output should mention the proper .o file. -# ccache or distcc lose the path to the target, so we convert a rule of -# the form: -# foobar.o: DEP1 DEP2 -# into -# path/to/foobar.o: DEP1 DEP2 -# (2) we want missing files not to cause us to fail to build. -# We want to rewrite -# foobar.o: DEP1 DEP2 \ -# DEP3 -# to -# DEP1: -# DEP2: -# DEP3: -# so if the files are missing, they're just considered phony rules. -# We have to do some pretty insane escaping to get those backslashes -# and dollar signs past make, the shell, and sed at the same time. -# Doesn't work with spaces, but that's fine: .d files have spaces in -# their names replaced with other characters. -define fixup_dep -# The depfile may not exist if the input file didn't have any #includes. -touch $(depfile).raw -# Fixup path as in (1). -sed -e "s|^$(notdir $@)|$@|" $(depfile).raw >> $(depfile) -# Add extra rules as in (2). -# We remove slashes and replace spaces with new lines; -# remove blank lines; -# delete the first line and append a colon to the remaining lines. -sed -e 's|\\||' -e 'y| |\n|' $(depfile).raw |\ - grep -v '^$$' |\ - sed -e 1d -e 's|$$|:|' \ - >> $(depfile) -rm $(depfile).raw -endef - -# Command definitions: -# - cmd_foo is the actual command to run; -# - quiet_cmd_foo is the brief-output summary of the command. - -quiet_cmd_cc = CC($(TOOLSET)) $@ -cmd_cc = $(CC.$(TOOLSET)) $(GYP_CFLAGS) $(DEPFLAGS) $(CFLAGS.$(TOOLSET)) -c -o $@ $< - -quiet_cmd_cxx = CXX($(TOOLSET)) $@ -cmd_cxx = $(CXX.$(TOOLSET)) $(GYP_CXXFLAGS) $(DEPFLAGS) $(CXXFLAGS.$(TOOLSET)) -c -o $@ $< - -quiet_cmd_touch = TOUCH $@ -cmd_touch = touch $@ - -quiet_cmd_copy = COPY $@ -# send stderr to /dev/null to ignore messages when linking directories. -cmd_copy = ln -f "$<" "$@" 2>/dev/null || (rm -rf "$@" && cp -af "$<" "$@") - -quiet_cmd_alink = AR($(TOOLSET)) $@ -cmd_alink = rm -f $@ && $(AR.$(TOOLSET)) $(ARFLAGS.$(TOOLSET)) $@ $(filter %.o,$^) - -# Due to circular dependencies between libraries :(, we wrap the -# special "figure out circular dependencies" flags around the entire -# input list during linking. -quiet_cmd_link = LINK($(TOOLSET)) $@ -cmd_link = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ -Wl,--start-group $(LD_INPUTS) -Wl,--end-group $(LIBS) - -# We support two kinds of shared objects (.so): -# 1) shared_library, which is just bundling together many dependent libraries -# into a link line. -# 2) loadable_module, which is generating a module intended for dlopen(). -# -# They differ only slightly: -# In the former case, we want to package all dependent code into the .so. -# In the latter case, we want to package just the API exposed by the -# outermost module. -# This means shared_library uses --whole-archive, while loadable_module doesn't. -# (Note that --whole-archive is incompatible with the --start-group used in -# normal linking.) - -# Other shared-object link notes: -# - Set SONAME to the library filename so our binaries don't reference -# the local, absolute paths used on the link command-line. -quiet_cmd_solink = SOLINK($(TOOLSET)) $@ -cmd_solink = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -Wl,-soname=$(@F) -o $@ -Wl,--whole-archive $(LD_INPUTS) -Wl,--no-whole-archive $(LIBS) - -quiet_cmd_solink_module = SOLINK_MODULE($(TOOLSET)) $@ -cmd_solink_module = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -Wl,-soname=$(@F) -o $@ -Wl,--start-group $(filter-out FORCE_DO_CMD, $^) -Wl,--end-group $(LIBS) - - -# Define an escape_quotes function to escape single quotes. -# This allows us to handle quotes properly as long as we always use -# use single quotes and escape_quotes. -escape_quotes = $(subst ','\'',$(1)) -# This comment is here just to include a ' to unconfuse syntax highlighting. -# Define an escape_vars function to escape '$' variable syntax. -# This allows us to read/write command lines with shell variables (e.g. -# $LD_LIBRARY_PATH), without triggering make substitution. -escape_vars = $(subst $$,$$$$,$(1)) -# Helper that expands to a shell command to echo a string exactly as it is in -# make. This uses printf instead of echo because printf's behaviour with respect -# to escape sequences is more portable than echo's across different shells -# (e.g., dash, bash). -exact_echo = printf '%s\n' '$(call escape_quotes,$(1))' - -# Helper to compare the command we're about to run against the command -# we logged the last time we ran the command. Produces an empty -# string (false) when the commands match. -# Tricky point: Make has no string-equality test function. -# The kernel uses the following, but it seems like it would have false -# positives, where one string reordered its arguments. -# arg_check = $(strip $(filter-out $(cmd_$(1)), $(cmd_$@)) \ -# $(filter-out $(cmd_$@), $(cmd_$(1)))) -# We instead substitute each for the empty string into the other, and -# say they're equal if both substitutions produce the empty string. -# .d files contain ? instead of spaces, take that into account. -command_changed = $(or $(subst $(cmd_$(1)),,$(cmd_$(call replace_spaces,$@))),\ - $(subst $(cmd_$(call replace_spaces,$@)),,$(cmd_$(1)))) - -# Helper that is non-empty when a prerequisite changes. -# Normally make does this implicitly, but we force rules to always run -# so we can check their command lines. -# $? -- new prerequisites -# $| -- order-only dependencies -prereq_changed = $(filter-out FORCE_DO_CMD,$(filter-out $|,$?)) - -# Helper that executes all postbuilds, and deletes the output file when done -# if any of the postbuilds failed. -define do_postbuilds - @E=0;\ - for p in $(POSTBUILDS); do\ - eval $$p;\ - F=$$?;\ - if [ $$F -ne 0 ]; then\ - E=$$F;\ - fi;\ - done;\ - if [ $$E -ne 0 ]; then\ - rm -rf "$@";\ - exit $$E;\ - fi -endef - -# do_cmd: run a command via the above cmd_foo names, if necessary. -# Should always run for a given target to handle command-line changes. -# Second argument, if non-zero, makes it do asm/C/C++ dependency munging. -# Third argument, if non-zero, makes it do POSTBUILDS processing. -# Note: We intentionally do NOT call dirx for depfile, since it contains ? for -# spaces already and dirx strips the ? characters. -define do_cmd -$(if $(or $(command_changed),$(prereq_changed)), - @$(call exact_echo, $($(quiet)cmd_$(1))) - @mkdir -p "$(call dirx,$@)" "$(dir $(depfile))" - $(if $(findstring flock,$(word 1,$(cmd_$1))), - @$(cmd_$(1)) - @echo " $(quiet_cmd_$(1)): Finished", - @$(cmd_$(1)) - ) - @$(call exact_echo,$(call escape_vars,cmd_$(call replace_spaces,$@) := $(cmd_$(1)))) > $(depfile) - @$(if $(2),$(fixup_dep)) - $(if $(and $(3), $(POSTBUILDS)), - $(call do_postbuilds) - ) -) -endef - -# Declare the "all" target first so it is the default, -# even though we don't have the deps yet. -.PHONY: all -all: - -# Use FORCE_DO_CMD to force a target to run. Should be coupled with -# do_cmd. -.PHONY: FORCE_DO_CMD -FORCE_DO_CMD: - -TOOLSET := target -# Suffix rules, putting all outputs into $(obj). -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.cc FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.cpp FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.cxx FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.S FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.s FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# Try building from generated source, too. -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cc FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cpp FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cxx FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.S FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.s FORCE_DO_CMD - @$(call do_cmd,cc,1) - -$(obj).$(TOOLSET)/%.o: $(obj)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.cc FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.cpp FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.cxx FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.S FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.s FORCE_DO_CMD - @$(call do_cmd,cc,1) - - -ifeq ($(strip $(foreach prefix,$(NO_LOAD),\ - $(findstring $(join ^,$(prefix)),\ - $(join ^,src/libuv/run-benchmarks.target.mk)))),) - include src/libuv/run-benchmarks.target.mk -endif -ifeq ($(strip $(foreach prefix,$(NO_LOAD),\ - $(findstring $(join ^,$(prefix)),\ - $(join ^,src/libuv/run-tests.target.mk)))),) - include src/libuv/run-tests.target.mk -endif -ifeq ($(strip $(foreach prefix,$(NO_LOAD),\ - $(findstring $(join ^,$(prefix)),\ - $(join ^,src/libuv/uv.target.mk)))),) - include src/libuv/uv.target.mk -endif - -#quiet_cmd_regen_makefile = ACTION Regenerating $@ -#cmd_regen_makefile = ./src/libuv/build/gyp/gyp -fmake --ignore-environment "--toplevel-dir=." -Isrc/libuv/common.gypi "--depth=." "--generator-output=mk/libuv/ia32/win" "-Ddefault_configuration=Default" "-Dcomponent=static_library" "-Dlibrary=static_library" "-Dtarget_arch=ia32" "-DOS=win" src/libuv/uv.gyp -#Makefile: $(srcdir)/src/libuv/uv.gyp $(srcdir)/src/libuv/common.gypi -# $(call do_cmd,regen_makefile) - -# "all" is a concatenation of the "all" targets from all the included -# sub-makefiles. This is just here to clarify. -all: - -# Add in dependency-tracking rules. $(all_deps) is the list of every single -# target in our tree. Only consider the ones with .d (dependency) info: -d_files := $(wildcard $(foreach f,$(all_deps),$(depsdir)/$(f).d)) -ifneq ($(d_files),) - # Rather than include each individual .d file, concatenate them into a - # single file which make is able to load faster. We split this into - # commands that take 1000 files at a time to avoid overflowing the - # command line. - $(shell cat $(wordlist 1,1000,$(d_files)) > $(depsdir)/all.deps) - - ifneq ($(word 1001,$(d_files)),) - $(error Found unprocessed dependency files (gyp didn't generate enough rules!)) - endif - - # make looks for ways to re-generate included makefiles, but in our case, we - # don't have a direct way. Explicitly telling make that it has nothing to do - # for them makes it go faster. - $(depsdir)/all.deps: ; - - include $(depsdir)/all.deps -endif diff --git a/mk/libuv/ia32/win/src/libuv/run-benchmarks.target.mk b/mk/libuv/ia32/win/src/libuv/run-benchmarks.target.mk deleted file mode 100644 index 25bf58f854886..0000000000000 --- a/mk/libuv/ia32/win/src/libuv/run-benchmarks.target.mk +++ /dev/null @@ -1,110 +0,0 @@ -# This file is generated by gyp; do not edit. - -TOOLSET := target -TARGET := run-benchmarks -DEFS_Debug := '-DWIN32' \ - '-D_CRT_SECURE_NO_DEPRECATE' \ - '-D_CRT_NONSTDC_NO_DEPRECATE' \ - '-DDEBUG' \ - '-D_DEBUG' - -# Flags passed to all source files. -CFLAGS_Debug := -g \ - -O0 - -# Flags passed to only C files. -CFLAGS_C_Debug := - -# Flags passed to only C++ files. -CFLAGS_CC_Debug := - -INCS_Debug := -I$(srcdir)/src/libuv/include - -DEFS_Release := '-DWIN32' \ - '-D_CRT_SECURE_NO_DEPRECATE' \ - '-D_CRT_NONSTDC_NO_DEPRECATE' \ - '-DNDEBUG' - -# Flags passed to all source files. -CFLAGS_Release := -O3 \ - -fomit-frame-pointer \ - -fdata-sections \ - -ffunction-sections - -# Flags passed to only C files. -CFLAGS_C_Release := - -# Flags passed to only C++ files. -CFLAGS_CC_Release := - -INCS_Release := -I$(srcdir)/src/libuv/include - -OBJS := $(obj).target/$(TARGET)/src/libuv/test/benchmark-ares.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-getaddrinfo.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-ping-pongs.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-pound.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-pump.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-sizes.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-spawn.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-thread.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-tcp-write-batch.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-udp-packet-storm.o \ - $(obj).target/$(TARGET)/src/libuv/test/dns-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/echo-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/blackhole-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/run-benchmarks.o \ - $(obj).target/$(TARGET)/src/libuv/test/runner.o \ - $(obj).target/$(TARGET)/src/libuv/test/runner-win.o - -# Add to the list of files we specially track dependencies for. -all_deps += $(OBJS) - -# Make sure our dependencies are built before any of us. -$(OBJS): | $(obj).target/src/libuv/libuv.a - -# CFLAGS et al overrides must be target-local. -# See "Target-specific Variable Values" in the GNU Make manual. -$(OBJS): TOOLSET := $(TOOLSET) -$(OBJS): GYP_CFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) -$(OBJS): GYP_CXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) - -# Suffix rules, putting all outputs into $(obj). - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# Try building from generated source, too. - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# End of this set of suffix rules -### Rules for final target. -LDFLAGS_Debug := - -LDFLAGS_Release := - -LIBS := ws2_32.lib \ - -lws2_32.lib \ - -lpsapi.lib \ - -liphlpapi.lib - -$(builddir)/run-benchmarks: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE)) -$(builddir)/run-benchmarks: LIBS := $(LIBS) -$(builddir)/run-benchmarks: LD_INPUTS := $(OBJS) $(obj).target/src/libuv/libuv.a -$(builddir)/run-benchmarks: TOOLSET := $(TOOLSET) -$(builddir)/run-benchmarks: $(OBJS) $(obj).target/src/libuv/libuv.a FORCE_DO_CMD - $(call do_cmd,link) - -all_deps += $(builddir)/run-benchmarks -# Add target alias -.PHONY: run-benchmarks -run-benchmarks: $(builddir)/run-benchmarks - -# Add executable to "all" target. -.PHONY: all -all: $(builddir)/run-benchmarks - diff --git a/mk/libuv/ia32/win/src/libuv/run-tests.target.mk b/mk/libuv/ia32/win/src/libuv/run-tests.target.mk deleted file mode 100644 index 51b62f7a3e2d5..0000000000000 --- a/mk/libuv/ia32/win/src/libuv/run-tests.target.mk +++ /dev/null @@ -1,153 +0,0 @@ -# This file is generated by gyp; do not edit. - -TOOLSET := target -TARGET := run-tests -DEFS_Debug := '-DWIN32' \ - '-D_CRT_SECURE_NO_DEPRECATE' \ - '-D_CRT_NONSTDC_NO_DEPRECATE' \ - '-DDEBUG' \ - '-D_DEBUG' - -# Flags passed to all source files. -CFLAGS_Debug := -g \ - -O0 - -# Flags passed to only C files. -CFLAGS_C_Debug := - -# Flags passed to only C++ files. -CFLAGS_CC_Debug := - -INCS_Debug := -I$(srcdir)/src/libuv/include - -DEFS_Release := '-DWIN32' \ - '-D_CRT_SECURE_NO_DEPRECATE' \ - '-D_CRT_NONSTDC_NO_DEPRECATE' \ - '-DNDEBUG' - -# Flags passed to all source files. -CFLAGS_Release := -O3 \ - -fomit-frame-pointer \ - -fdata-sections \ - -ffunction-sections - -# Flags passed to only C files. -CFLAGS_C_Release := - -# Flags passed to only C++ files. -CFLAGS_CC_Release := - -INCS_Release := -I$(srcdir)/src/libuv/include - -OBJS := $(obj).target/$(TARGET)/src/libuv/test/blackhole-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/echo-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/run-tests.o \ - $(obj).target/$(TARGET)/src/libuv/test/runner.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-get-loadavg.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-util.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-async.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-callback-stack.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-connection-fail.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-cwd-and-chdir.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-delayed-accept.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-eio-overflow.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-fail-always.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-fs.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-fs-event.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-get-currentexe.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-get-memory.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-getaddrinfo.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-gethostbyname.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-getsockname.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-hrtime.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-idle.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-ipc.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-ipc-threads.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-loop-handles.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-multiple-listen.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-pass-always.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-ping-pong.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-pipe-bind-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-pipe-connect-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-platform-output.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-process-title.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-ref.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-shutdown-eof.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-spawn.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-stdio-over-pipes.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-bind-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-bind6-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-close.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-flags.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-connect-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-connect6-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-write-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-write-to-half-open-connection.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-writealot.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-threadpool.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-mutexes.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-thread.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-timer-again.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-timer.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tty.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-dgram-too-big.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-ipv6.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-options.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-send-and-recv.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-multicast-join.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-counters-init.o \ - $(obj).target/$(TARGET)/src/libuv/test/runner-win.o - -# Add to the list of files we specially track dependencies for. -all_deps += $(OBJS) - -# Make sure our dependencies are built before any of us. -$(OBJS): | $(obj).target/src/libuv/libuv.a - -# CFLAGS et al overrides must be target-local. -# See "Target-specific Variable Values" in the GNU Make manual. -$(OBJS): TOOLSET := $(TOOLSET) -$(OBJS): GYP_CFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) -$(OBJS): GYP_CXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) - -# Suffix rules, putting all outputs into $(obj). - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# Try building from generated source, too. - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# End of this set of suffix rules -### Rules for final target. -LDFLAGS_Debug := - -LDFLAGS_Release := - -LIBS := ws2_32.lib \ - -lws2_32.lib \ - -lpsapi.lib \ - -liphlpapi.lib - -$(builddir)/run-tests: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE)) -$(builddir)/run-tests: LIBS := $(LIBS) -$(builddir)/run-tests: LD_INPUTS := $(OBJS) $(obj).target/src/libuv/libuv.a -$(builddir)/run-tests: TOOLSET := $(TOOLSET) -$(builddir)/run-tests: $(OBJS) $(obj).target/src/libuv/libuv.a FORCE_DO_CMD - $(call do_cmd,link) - -all_deps += $(builddir)/run-tests -# Add target alias -.PHONY: run-tests -run-tests: $(builddir)/run-tests - -# Add executable to "all" target. -.PHONY: all -all: $(builddir)/run-tests - diff --git a/mk/libuv/ia32/win/src/libuv/uv.Makefile b/mk/libuv/ia32/win/src/libuv/uv.Makefile deleted file mode 100644 index 65df03050e5ce..0000000000000 --- a/mk/libuv/ia32/win/src/libuv/uv.Makefile +++ /dev/null @@ -1,6 +0,0 @@ -# This file is generated by gyp; do not edit. - -export builddir_name ?= mk/libuv/ia32/win/./src/libuv/out -.PHONY: all -all: - $(MAKE) -C ../.. uv run-benchmarks run-tests diff --git a/mk/libuv/ia32/win/src/libuv/uv.target.mk b/mk/libuv/ia32/win/src/libuv/uv.target.mk deleted file mode 100644 index 53576a0f93570..0000000000000 --- a/mk/libuv/ia32/win/src/libuv/uv.target.mk +++ /dev/null @@ -1,171 +0,0 @@ -# This file is generated by gyp; do not edit. - -TOOLSET := target -TARGET := uv -DEFS_Debug := '-DWIN32' \ - '-D_CRT_SECURE_NO_DEPRECATE' \ - '-D_CRT_NONSTDC_NO_DEPRECATE' \ - '-DHAVE_CONFIG_H' \ - '-D_WIN32_WINNT=0x0600' \ - '-DEIO_STACKSIZE=262144' \ - '-D_GNU_SOURCE' \ - '-DDEBUG' \ - '-D_DEBUG' - -# Flags passed to all source files. -CFLAGS_Debug := -g \ - -O0 - -# Flags passed to only C files. -CFLAGS_C_Debug := - -# Flags passed to only C++ files. -CFLAGS_CC_Debug := - -INCS_Debug := -I$(srcdir)/src/libuv/include \ - -I$(srcdir)/src/libuv/include/uv-private \ - -I$(srcdir)/src/libuv/src \ - -I$(srcdir)/src/libuv/src/ares/config_win32 - -DEFS_Release := '-DWIN32' \ - '-D_CRT_SECURE_NO_DEPRECATE' \ - '-D_CRT_NONSTDC_NO_DEPRECATE' \ - '-DHAVE_CONFIG_H' \ - '-D_WIN32_WINNT=0x0600' \ - '-DEIO_STACKSIZE=262144' \ - '-D_GNU_SOURCE' \ - '-DNDEBUG' - -# Flags passed to all source files. -CFLAGS_Release := -O3 \ - -fomit-frame-pointer \ - -fdata-sections \ - -ffunction-sections - -# Flags passed to only C files. -CFLAGS_C_Release := - -# Flags passed to only C++ files. -CFLAGS_CC_Release := - -INCS_Release := -I$(srcdir)/src/libuv/include \ - -I$(srcdir)/src/libuv/include/uv-private \ - -I$(srcdir)/src/libuv/src \ - -I$(srcdir)/src/libuv/src/ares/config_win32 - -OBJS := $(obj).target/$(TARGET)/src/libuv/src/uv-common.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_cancel.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares__close_sockets.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_data.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_destroy.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_expand_name.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_expand_string.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_fds.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_free_hostent.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_free_string.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_gethostbyaddr.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_gethostbyname.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares__get_hostent.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_getnameinfo.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_getopt.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_getsock.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_init.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_library_init.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_llist.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_mkquery.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_nowarn.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_options.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_aaaa_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_a_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_mx_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_ns_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_ptr_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_srv_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_txt_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_process.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_query.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares__read_line.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_search.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_send.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_strcasecmp.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_strdup.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_strerror.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_timeout.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares__timeval.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_version.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_writev.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/bitncmp.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/inet_net_pton.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/inet_ntop.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/windows_port.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_getenv.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_platform.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/async.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/cares.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/core.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/dl.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/error.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/fs.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/fs-event.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/getaddrinfo.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/handle.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/loop-watcher.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/pipe.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/thread.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/process.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/req.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/stream.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/tcp.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/tty.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/threadpool.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/timer.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/udp.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/util.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/winapi.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/winsock.o - -# Add to the list of files we specially track dependencies for. -all_deps += $(OBJS) - -# CFLAGS et al overrides must be target-local. -# See "Target-specific Variable Values" in the GNU Make manual. -$(OBJS): TOOLSET := $(TOOLSET) -$(OBJS): GYP_CFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) -$(OBJS): GYP_CXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) - -# Suffix rules, putting all outputs into $(obj). - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# Try building from generated source, too. - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# End of this set of suffix rules -### Rules for final target. -LDFLAGS_Debug := - -LDFLAGS_Release := - -LIBS := - -$(obj).target/src/libuv/libuv.a: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE)) -$(obj).target/src/libuv/libuv.a: LIBS := $(LIBS) -$(obj).target/src/libuv/libuv.a: TOOLSET := $(TOOLSET) -$(obj).target/src/libuv/libuv.a: $(OBJS) FORCE_DO_CMD - $(call do_cmd,alink) - -all_deps += $(obj).target/src/libuv/libuv.a -# Add target alias -.PHONY: uv -uv: $(obj).target/src/libuv/libuv.a - -# Add target alias to "all" target. -.PHONY: all -all: uv - diff --git a/mk/libuv/x86_64/mac/Makefile b/mk/libuv/x86_64/mac/Makefile deleted file mode 100644 index bae2ca0016bfd..0000000000000 --- a/mk/libuv/x86_64/mac/Makefile +++ /dev/null @@ -1,379 +0,0 @@ -# We borrow heavily from the kernel build setup, though we are simpler since -# we don't have Kconfig tweaking settings on us. - -# The implicit make rules have it looking for RCS files, among other things. -# We instead explicitly write all the rules we care about. -# It's even quicker (saves ~200ms) to pass -r on the command line. -MAKEFLAGS=-r - -# The source directory tree. -srcdir := ../../../.. -abs_srcdir := $(abspath $(srcdir)) - -# The name of the builddir. -builddir_name ?= out - -# The V=1 flag on command line makes us verbosely print command lines. -ifdef V - quiet= -else - quiet=quiet_ -endif - -# Specify BUILDTYPE=Release on the command line for a release build. -BUILDTYPE ?= Debug - -# Directory all our build output goes into. -# Note that this must be two directories beneath src/ for unit tests to pass, -# as they reach into the src/ directory for data with relative paths. -builddir ?= $(builddir_name)/$(BUILDTYPE) -abs_builddir := $(abspath $(builddir)) -depsdir := $(builddir)/.deps - -# Object output directory. -obj := $(builddir)/obj -abs_obj := $(abspath $(obj)) - -# We build up a list of every single one of the targets so we can slurp in the -# generated dependency rule Makefiles in one pass. -all_deps := - - - -# C++ apps need to be linked with g++. -# -# Note: flock is used to seralize linking. Linking is a memory-intensive -# process so running parallel links can often lead to thrashing. To disable -# the serialization, override LINK via an envrionment variable as follows: -# -# export LINK=g++ -# -# This will allow make to invoke N linker processes as specified in -jN. -LINK ?= ./gyp-mac-tool flock $(builddir)/linker.lock $(CXX) - -CC.target ?= $(CC) -CFLAGS.target ?= $(CFLAGS) -CXX.target ?= $(CXX) -CXXFLAGS.target ?= $(CXXFLAGS) -LINK.target ?= $(LINK) -LDFLAGS.target ?= $(LDFLAGS) -AR.target ?= $(AR) -ARFLAGS.target ?= crs - -# N.B.: the logic of which commands to run should match the computation done -# in gyp's make.py where ARFLAGS.host etc. is computed. -# TODO(evan): move all cross-compilation logic to gyp-time so we don't need -# to replicate this environment fallback in make as well. -CC.host ?= gcc -CFLAGS.host ?= -CXX.host ?= g++ -CXXFLAGS.host ?= -LINK.host ?= g++ -LDFLAGS.host ?= -AR.host ?= ar -ARFLAGS.host := crs - -# Define a dir function that can handle spaces. -# http://www.gnu.org/software/make/manual/make.html#Syntax-of-Functions -# "leading spaces cannot appear in the text of the first argument as written. -# These characters can be put into the argument value by variable substitution." -empty := -space := $(empty) $(empty) - -# http://stackoverflow.com/questions/1189781/using-make-dir-or-notdir-on-a-path-with-spaces -replace_spaces = $(subst $(space),?,$1) -unreplace_spaces = $(subst ?,$(space),$1) -dirx = $(call unreplace_spaces,$(dir $(call replace_spaces,$1))) - -# Flags to make gcc output dependency info. Note that you need to be -# careful here to use the flags that ccache and distcc can understand. -# We write to a dep file on the side first and then rename at the end -# so we can't end up with a broken dep file. -depfile = $(depsdir)/$(call replace_spaces,$@).d -DEPFLAGS = -MMD -MF $(depfile).raw - -# We have to fixup the deps output in a few ways. -# (1) the file output should mention the proper .o file. -# ccache or distcc lose the path to the target, so we convert a rule of -# the form: -# foobar.o: DEP1 DEP2 -# into -# path/to/foobar.o: DEP1 DEP2 -# (2) we want missing files not to cause us to fail to build. -# We want to rewrite -# foobar.o: DEP1 DEP2 \ -# DEP3 -# to -# DEP1: -# DEP2: -# DEP3: -# so if the files are missing, they're just considered phony rules. -# We have to do some pretty insane escaping to get those backslashes -# and dollar signs past make, the shell, and sed at the same time. -# Doesn't work with spaces, but that's fine: .d files have spaces in -# their names replaced with other characters. -define fixup_dep -# The depfile may not exist if the input file didn't have any #includes. -touch $(depfile).raw -# Fixup path as in (1). -sed -e "s|^$(notdir $@)|$@|" $(depfile).raw >> $(depfile) -# Add extra rules as in (2). -# We remove slashes and replace spaces with new lines; -# remove blank lines; -# delete the first line and append a colon to the remaining lines. -sed -e 's|\\||' -e 'y| |\n|' $(depfile).raw |\ - grep -v '^$$' |\ - sed -e 1d -e 's|$$|:|' \ - >> $(depfile) -rm $(depfile).raw -endef - -# Command definitions: -# - cmd_foo is the actual command to run; -# - quiet_cmd_foo is the brief-output summary of the command. - -quiet_cmd_cc = CC($(TOOLSET)) $@ -cmd_cc = $(CC.$(TOOLSET)) $(GYP_CFLAGS) $(DEPFLAGS) $(CFLAGS.$(TOOLSET)) -c -o $@ $< - -quiet_cmd_cxx = CXX($(TOOLSET)) $@ -cmd_cxx = $(CXX.$(TOOLSET)) $(GYP_CXXFLAGS) $(DEPFLAGS) $(CXXFLAGS.$(TOOLSET)) -c -o $@ $< - -quiet_cmd_objc = CXX($(TOOLSET)) $@ -cmd_objc = $(CC.$(TOOLSET)) $(GYP_OBJCFLAGS) $(DEPFLAGS) -c -o $@ $< - -quiet_cmd_objcxx = CXX($(TOOLSET)) $@ -cmd_objcxx = $(CXX.$(TOOLSET)) $(GYP_OBJCXXFLAGS) $(DEPFLAGS) -c -o $@ $< - -# Commands for precompiled header files. -quiet_cmd_pch_c = CXX($(TOOLSET)) $@ -cmd_pch_c = $(CC.$(TOOLSET)) $(GYP_PCH_CFLAGS) $(DEPFLAGS) $(CXXFLAGS.$(TOOLSET)) -c -o $@ $< -quiet_cmd_pch_cc = CXX($(TOOLSET)) $@ -cmd_pch_cc = $(CC.$(TOOLSET)) $(GYP_PCH_CXXFLAGS) $(DEPFLAGS) $(CXXFLAGS.$(TOOLSET)) -c -o $@ $< -quiet_cmd_pch_m = CXX($(TOOLSET)) $@ -cmd_pch_m = $(CC.$(TOOLSET)) $(GYP_PCH_OBJCFLAGS) $(DEPFLAGS) -c -o $@ $< -quiet_cmd_pch_mm = CXX($(TOOLSET)) $@ -cmd_pch_mm = $(CC.$(TOOLSET)) $(GYP_PCH_OBJCXXFLAGS) $(DEPFLAGS) -c -o $@ $< - -# gyp-mac-tool is written next to the root Makefile by gyp. -# Use $(4) for the command, since $(2) and $(3) are used as flag by do_cmd -# already. -quiet_cmd_mac_tool = MACTOOL $(4) $< -cmd_mac_tool = ./gyp-mac-tool $(4) $< "$@" - -quiet_cmd_mac_package_framework = PACKAGE FRAMEWORK $@ -cmd_mac_package_framework = ./gyp-mac-tool package-framework "$@" $(4) - -quiet_cmd_infoplist = INFOPLIST $@ -cmd_infoplist = $(CC.$(TOOLSET)) -E -P -Wno-trigraphs -x c $(INFOPLIST_DEFINES) "$<" -o "$@" - -quiet_cmd_touch = TOUCH $@ -cmd_touch = touch $@ - -quiet_cmd_copy = COPY $@ -# send stderr to /dev/null to ignore messages when linking directories. -cmd_copy = ln -f "$<" "$@" 2>/dev/null || (rm -rf "$@" && cp -af "$<" "$@") - -quiet_cmd_alink = LIBTOOL-STATIC $@ -cmd_alink = rm -f $@ && libtool -static -o $@ $(filter %.o,$^) - -quiet_cmd_link = LINK($(TOOLSET)) $@ -cmd_link = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o "$@" $(LD_INPUTS) $(LIBS) - -# TODO(thakis): Find out and document the difference between shared_library and -# loadable_module on mac. -quiet_cmd_solink = SOLINK($(TOOLSET)) $@ -cmd_solink = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o "$@" $(LD_INPUTS) $(LIBS) - -# TODO(thakis): The solink_module rule is likely wrong. Xcode seems to pass -# -bundle -single_module here (for osmesa.so). -quiet_cmd_solink_module = SOLINK_MODULE($(TOOLSET)) $@ -cmd_solink_module = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $(filter-out FORCE_DO_CMD, $^) $(LIBS) - - -# Define an escape_quotes function to escape single quotes. -# This allows us to handle quotes properly as long as we always use -# use single quotes and escape_quotes. -escape_quotes = $(subst ','\'',$(1)) -# This comment is here just to include a ' to unconfuse syntax highlighting. -# Define an escape_vars function to escape '$' variable syntax. -# This allows us to read/write command lines with shell variables (e.g. -# $LD_LIBRARY_PATH), without triggering make substitution. -escape_vars = $(subst $$,$$$$,$(1)) -# Helper that expands to a shell command to echo a string exactly as it is in -# make. This uses printf instead of echo because printf's behaviour with respect -# to escape sequences is more portable than echo's across different shells -# (e.g., dash, bash). -exact_echo = printf '%s\n' '$(call escape_quotes,$(1))' - -# Helper to compare the command we're about to run against the command -# we logged the last time we ran the command. Produces an empty -# string (false) when the commands match. -# Tricky point: Make has no string-equality test function. -# The kernel uses the following, but it seems like it would have false -# positives, where one string reordered its arguments. -# arg_check = $(strip $(filter-out $(cmd_$(1)), $(cmd_$@)) \ -# $(filter-out $(cmd_$@), $(cmd_$(1)))) -# We instead substitute each for the empty string into the other, and -# say they're equal if both substitutions produce the empty string. -# .d files contain ? instead of spaces, take that into account. -command_changed = $(or $(subst $(cmd_$(1)),,$(cmd_$(call replace_spaces,$@))),\ - $(subst $(cmd_$(call replace_spaces,$@)),,$(cmd_$(1)))) - -# Helper that is non-empty when a prerequisite changes. -# Normally make does this implicitly, but we force rules to always run -# so we can check their command lines. -# $? -- new prerequisites -# $| -- order-only dependencies -prereq_changed = $(filter-out FORCE_DO_CMD,$(filter-out $|,$?)) - -# Helper that executes all postbuilds, and deletes the output file when done -# if any of the postbuilds failed. -define do_postbuilds - @E=0;\ - for p in $(POSTBUILDS); do\ - eval $$p;\ - F=$$?;\ - if [ $$F -ne 0 ]; then\ - E=$$F;\ - fi;\ - done;\ - if [ $$E -ne 0 ]; then\ - rm -rf "$@";\ - exit $$E;\ - fi -endef - -# do_cmd: run a command via the above cmd_foo names, if necessary. -# Should always run for a given target to handle command-line changes. -# Second argument, if non-zero, makes it do asm/C/C++ dependency munging. -# Third argument, if non-zero, makes it do POSTBUILDS processing. -# Note: We intentionally do NOT call dirx for depfile, since it contains ? for -# spaces already and dirx strips the ? characters. -define do_cmd -$(if $(or $(command_changed),$(prereq_changed)), - @$(call exact_echo, $($(quiet)cmd_$(1))) - @mkdir -p "$(call dirx,$@)" "$(dir $(depfile))" - $(if $(findstring flock,$(word 2,$(cmd_$1))), - @$(cmd_$(1)) - @echo " $(quiet_cmd_$(1)): Finished", - @$(cmd_$(1)) - ) - @$(call exact_echo,$(call escape_vars,cmd_$(call replace_spaces,$@) := $(cmd_$(1)))) > $(depfile) - @$(if $(2),$(fixup_dep)) - $(if $(and $(3), $(POSTBUILDS)), - $(call do_postbuilds) - ) -) -endef - -# Declare the "all" target first so it is the default, -# even though we don't have the deps yet. -.PHONY: all -all: - -# Use FORCE_DO_CMD to force a target to run. Should be coupled with -# do_cmd. -.PHONY: FORCE_DO_CMD -FORCE_DO_CMD: - -TOOLSET := target -# Suffix rules, putting all outputs into $(obj). -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.cc FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.cpp FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.cxx FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.m FORCE_DO_CMD - @$(call do_cmd,objc,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.mm FORCE_DO_CMD - @$(call do_cmd,objcxx,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.S FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.s FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# Try building from generated source, too. -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cc FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cpp FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cxx FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.m FORCE_DO_CMD - @$(call do_cmd,objc,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.mm FORCE_DO_CMD - @$(call do_cmd,objcxx,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.S FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.s FORCE_DO_CMD - @$(call do_cmd,cc,1) - -$(obj).$(TOOLSET)/%.o: $(obj)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.cc FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.cpp FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.cxx FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.m FORCE_DO_CMD - @$(call do_cmd,objc,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.mm FORCE_DO_CMD - @$(call do_cmd,objcxx,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.S FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.s FORCE_DO_CMD - @$(call do_cmd,cc,1) - - -ifeq ($(strip $(foreach prefix,$(NO_LOAD),\ - $(findstring $(join ^,$(prefix)),\ - $(join ^,src/libuv/run-benchmarks.target.mk)))),) - include src/libuv/run-benchmarks.target.mk -endif -ifeq ($(strip $(foreach prefix,$(NO_LOAD),\ - $(findstring $(join ^,$(prefix)),\ - $(join ^,src/libuv/run-tests.target.mk)))),) - include src/libuv/run-tests.target.mk -endif -ifeq ($(strip $(foreach prefix,$(NO_LOAD),\ - $(findstring $(join ^,$(prefix)),\ - $(join ^,src/libuv/uv.target.mk)))),) - include src/libuv/uv.target.mk -endif - -#quiet_cmd_regen_makefile = ACTION Regenerating $@ -#cmd_regen_makefile = ./src/libuv/build/gyp/gyp -fmake --ignore-environment "--toplevel-dir=." -Isrc/libuv/common.gypi "--depth=." "--generator-output=mk/libuv/x86_64/mac" "-Ddefault_configuration=Default" "-Dcomponent=static_library" "-Dlibrary=static_library" "-Dtarget_arch=x86_64" "-DOS=mac" src/libuv/uv.gyp -#Makefile: $(srcdir)/src/libuv/uv.gyp $(srcdir)/src/libuv/common.gypi -# $(call do_cmd,regen_makefile) - -# "all" is a concatenation of the "all" targets from all the included -# sub-makefiles. This is just here to clarify. -all: - -# Add in dependency-tracking rules. $(all_deps) is the list of every single -# target in our tree. Only consider the ones with .d (dependency) info: -d_files := $(wildcard $(foreach f,$(all_deps),$(depsdir)/$(f).d)) -ifneq ($(d_files),) - # Rather than include each individual .d file, concatenate them into a - # single file which make is able to load faster. We split this into - # commands that take 1000 files at a time to avoid overflowing the - # command line. - $(shell cat $(wordlist 1,1000,$(d_files)) > $(depsdir)/all.deps) - - ifneq ($(word 1001,$(d_files)),) - $(error Found unprocessed dependency files (gyp didn't generate enough rules!)) - endif - - # make looks for ways to re-generate included makefiles, but in our case, we - # don't have a direct way. Explicitly telling make that it has nothing to do - # for them makes it go faster. - $(depsdir)/all.deps: ; - - include $(depsdir)/all.deps -endif diff --git a/mk/libuv/x86_64/mac/gyp-mac-tool b/mk/libuv/x86_64/mac/gyp-mac-tool deleted file mode 100755 index bd4059840ea8a..0000000000000 --- a/mk/libuv/x86_64/mac/gyp-mac-tool +++ /dev/null @@ -1,193 +0,0 @@ -#!/usr/bin/env python -# Generated by gyp. Do not edit. -# Copyright (c) 2011 Google Inc. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -"""Utility functions to perform Xcode-style build steps. - -These functions are executed via gyp-mac-tool when using the Makefile generator. -""" - -import os -import fcntl -import plistlib -import shutil -import string -import subprocess -import sys - - -def main(args): - executor = MacTool() - executor.Dispatch(args) - - -class MacTool(object): - """This class performs all the Mac tooling steps. The methods can either be - executed directly, or dispatched from an argument list.""" - - def Dispatch(self, args): - """Dispatches a string command to a method.""" - if len(args) < 1: - raise Exception("Not enough arguments") - - method = "Exec%s" % self._CommandifyName(args[0]) - getattr(self, method)(*args[1:]) - - def _CommandifyName(self, name_string): - """Transforms a tool name like copy-info-plist to CopyInfoPlist""" - return name_string.title().replace('-', '') - - def ExecFlock(self, lockfile, *cmd_list): - """Emulates the most basic behavior of Linux's flock(1).""" - # Rely on exception handling to report errors. - fd = os.open(lockfile, os.O_RDONLY|os.O_NOCTTY|os.O_CREAT, 0o666) - fcntl.flock(fd, fcntl.LOCK_EX) - return subprocess.call(cmd_list) - - def ExecCopyInfoPlist(self, source, dest): - """Copies the |source| Info.plist to the destination directory |dest|.""" - # Read the source Info.plist into memory. - fd = open(source, 'r') - lines = fd.read() - fd.close() - - # Go through all the environment variables and replace them as variables in - # the file. - for key in os.environ: - if key.startswith('_'): - continue - evar = '${%s}' % key - lines = string.replace(lines, evar, os.environ[key]) - - # Write out the file with variables replaced. - fd = open(dest, 'w') - fd.write(lines) - fd.close() - - # Now write out PkgInfo file now that the Info.plist file has been - # "compiled". - self._WritePkgInfo(dest) - - def _WritePkgInfo(self, info_plist): - """This writes the PkgInfo file from the data stored in Info.plist.""" - plist = plistlib.readPlist(info_plist) - if not plist: - return - - # Only create PkgInfo for executable types. - package_type = plist['CFBundlePackageType'] - if package_type != 'APPL': - return - - # The format of PkgInfo is eight characters, representing the bundle type - # and bundle signature, each four characters. If that is missing, four - # '?' characters are used instead. - signature_code = plist['CFBundleSignature'] - if len(signature_code) != 4: - signature_code = '?' * 4 - - dest = os.path.join(os.path.dirname(info_plist), 'PkgInfo') - fp = open(dest, 'w') - fp.write('%s%s' % (package_type, signature_code)) - fp.close() - - def ExecPackageFramework(self, framework, version): - """Takes a path to Something.framework and the Current version of that and - sets up all the symlinks.""" - # Find the name of the binary based on the part before the ".framework". - binary = os.path.basename(framework).split('.')[0] - - CURRENT = 'Current' - RESOURCES = 'Resources' - VERSIONS = 'Versions' - - if not os.path.exists(os.path.join(framework, VERSIONS, version, binary)): - # Binary-less frameworks don't seem to contain symlinks (see e.g. - # chromium's out/Debug/org.chromium.Chromium.manifest/ bundle). - return - - # Move into the framework directory to set the symlinks correctly. - pwd = os.getcwd() - os.chdir(framework) - - # Set up the Current version. - self._Relink(version, os.path.join(VERSIONS, CURRENT)) - - # Set up the root symlinks. - self._Relink(os.path.join(VERSIONS, CURRENT, binary), binary) - self._Relink(os.path.join(VERSIONS, CURRENT, RESOURCES), RESOURCES) - - # Back to where we were before! - os.chdir(pwd) - - def _Relink(self, dest, link): - """Creates a symlink to |dest| named |link|. If |link| already exists, - it is overwritten.""" - if os.path.lexists(link): - os.remove(link) - os.symlink(dest, link) - - def ExecCopyBundleResource(self, source, dest): - """Copies a resource file to the bundle/Resources directory, performing any - necessary compilation on each resource.""" - extension = os.path.splitext(source)[1].lower() - if os.path.isdir(source): - # Copy tree. - if os.path.exists(dest): - shutil.rmtree(dest) - shutil.copytree(source, dest) - elif extension == '.xib': - self._CopyXIBFile(source, dest) - elif extension == '.strings': - self._CopyStringsFile(source, dest) - # TODO: Given that files with arbitrary extensions can be copied to the - # bundle, we will want to get rid of this whitelist eventually. - elif extension in [ - '.icns', '.manifest', '.pak', '.pdf', '.png', '.sb', '.sh', - '.ttf', '.sdef']: - shutil.copyfile(source, dest) - else: - raise NotImplementedError( - "Don't know how to copy bundle resources of type %s while copying " - "%s to %s)" % (extension, source, dest)) - - def _CopyXIBFile(self, source, dest): - """Compiles a XIB file with ibtool into a binary plist in the bundle.""" - args = ['/Developer/usr/bin/ibtool', '--errors', '--warnings', - '--notices', '--output-format', 'human-readable-text', '--compile', - dest, source] - subprocess.call(args) - - def _CopyStringsFile(self, source, dest): - """Copies a .strings file using iconv to reconvert the input into UTF-16.""" - input_code = self._DetectInputEncoding(source) or "UTF-8" - fp = open(dest, 'w') - args = ['/usr/bin/iconv', '--from-code', input_code, '--to-code', - 'UTF-16', source] - subprocess.call(args, stdout=fp) - fp.close() - - def _DetectInputEncoding(self, file_name): - """Reads the first few bytes from file_name and tries to guess the text - encoding. Returns None as a guess if it can't detect it.""" - fp = open(file_name, 'rb') - try: - header = fp.read(3) - except e: - fp.close() - return None - fp.close() - if header.startswith("\xFE\xFF"): - return "UTF-16BE" - elif header.startswith("\xFF\xFE"): - return "UTF-16LE" - elif header.startswith("\xEF\xBB\xBF"): - return "UTF-8" - else: - return None - - -if __name__ == '__main__': - sys.exit(main(sys.argv[1:])) diff --git a/mk/libuv/x86_64/mac/src/libuv/run-benchmarks.target.mk b/mk/libuv/x86_64/mac/src/libuv/run-benchmarks.target.mk deleted file mode 100644 index f5930c9dc564d..0000000000000 --- a/mk/libuv/x86_64/mac/src/libuv/run-benchmarks.target.mk +++ /dev/null @@ -1,149 +0,0 @@ -# This file is generated by gyp; do not edit. - -TOOLSET := target -TARGET := run-benchmarks -DEFS_Debug := '-D_LARGEFILE_SOURCE' \ - '-D_FILE_OFFSET_BITS=64' \ - '-D_GNU_SOURCE' \ - '-DEIO_STACKSIZE=262144' \ - '-DDEBUG' \ - '-D_DEBUG' \ - '-DEV_VERIFY=2' - -# Flags passed to all source files. -CFLAGS_Debug := -Os \ - -gdwarf-2 \ - -fvisibility=hidden \ - -Wnewline-eof \ - -arch x86_64 \ - -fno-strict-aliasing \ - -Wall \ - -Wendif-labels \ - -W \ - -Wno-unused-parameter - -# Flags passed to only C files. -CFLAGS_C_Debug := - -# Flags passed to only C++ files. -CFLAGS_CC_Debug := -fno-rtti \ - -fno-exceptions \ - -fvisibility-inlines-hidden \ - -fno-threadsafe-statics - -# Flags passed to only ObjC files. -CFLAGS_OBJC_Debug := - -# Flags passed to only ObjC++ files. -CFLAGS_OBJCC_Debug := - -INCS_Debug := -I$(srcdir)/src/libuv/include - -DEFS_Release := '-D_LARGEFILE_SOURCE' \ - '-D_FILE_OFFSET_BITS=64' \ - '-D_GNU_SOURCE' \ - '-DEIO_STACKSIZE=262144' \ - '-DNDEBUG' - -# Flags passed to all source files. -CFLAGS_Release := -Os \ - -gdwarf-2 \ - -fvisibility=hidden \ - -Wnewline-eof \ - -arch x86_64 \ - -fno-strict-aliasing \ - -Wall \ - -Wendif-labels \ - -W \ - -Wno-unused-parameter - -# Flags passed to only C files. -CFLAGS_C_Release := - -# Flags passed to only C++ files. -CFLAGS_CC_Release := -fno-rtti \ - -fno-exceptions \ - -fvisibility-inlines-hidden \ - -fno-threadsafe-statics - -# Flags passed to only ObjC files. -CFLAGS_OBJC_Release := - -# Flags passed to only ObjC++ files. -CFLAGS_OBJCC_Release := - -INCS_Release := -I$(srcdir)/src/libuv/include - -OBJS := $(obj).target/$(TARGET)/src/libuv/test/benchmark-ares.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-getaddrinfo.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-ping-pongs.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-pound.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-pump.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-sizes.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-spawn.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-thread.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-tcp-write-batch.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-udp-packet-storm.o \ - $(obj).target/$(TARGET)/src/libuv/test/dns-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/echo-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/blackhole-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/run-benchmarks.o \ - $(obj).target/$(TARGET)/src/libuv/test/runner.o \ - $(obj).target/$(TARGET)/src/libuv/test/runner-unix.o - -# Add to the list of files we specially track dependencies for. -all_deps += $(OBJS) - -# Make sure our dependencies are built before any of us. -$(OBJS): | $(builddir)/libuv.a - -# CFLAGS et al overrides must be target-local. -# See "Target-specific Variable Values" in the GNU Make manual. -$(OBJS): TOOLSET := $(TOOLSET) -$(OBJS): GYP_CFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) -$(OBJS): GYP_CXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) -$(OBJS): GYP_OBJCFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) $(CFLAGS_OBJC_$(BUILDTYPE)) -$(OBJS): GYP_OBJCXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) $(CFLAGS_OBJCC_$(BUILDTYPE)) - -# Suffix rules, putting all outputs into $(obj). - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# Try building from generated source, too. - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# End of this set of suffix rules -### Rules for final target. -LDFLAGS_Debug := -Wl,-search_paths_first \ - -arch x86_64 \ - -L$(builddir) - -LDFLAGS_Release := -Wl,-search_paths_first \ - -arch x86_64 \ - -L$(builddir) - -LIBS := -framework Carbon \ - -framework CoreServices - -$(builddir)/run-benchmarks: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE)) -$(builddir)/run-benchmarks: LIBS := $(LIBS) -$(builddir)/run-benchmarks: LD_INPUTS := $(OBJS) $(builddir)/libuv.a -$(builddir)/run-benchmarks: TOOLSET := $(TOOLSET) -$(builddir)/run-benchmarks: $(OBJS) $(builddir)/libuv.a FORCE_DO_CMD - $(call do_cmd,link) - -all_deps += $(builddir)/run-benchmarks -# Add target alias -.PHONY: run-benchmarks -run-benchmarks: $(builddir)/run-benchmarks - -# Add executable to "all" target. -.PHONY: all -all: $(builddir)/run-benchmarks - diff --git a/mk/libuv/x86_64/mac/src/libuv/run-tests.target.mk b/mk/libuv/x86_64/mac/src/libuv/run-tests.target.mk deleted file mode 100644 index 4694c7cfd4d6a..0000000000000 --- a/mk/libuv/x86_64/mac/src/libuv/run-tests.target.mk +++ /dev/null @@ -1,192 +0,0 @@ -# This file is generated by gyp; do not edit. - -TOOLSET := target -TARGET := run-tests -DEFS_Debug := '-D_LARGEFILE_SOURCE' \ - '-D_FILE_OFFSET_BITS=64' \ - '-D_GNU_SOURCE' \ - '-DEIO_STACKSIZE=262144' \ - '-DDEBUG' \ - '-D_DEBUG' \ - '-DEV_VERIFY=2' - -# Flags passed to all source files. -CFLAGS_Debug := -Os \ - -gdwarf-2 \ - -fvisibility=hidden \ - -Wnewline-eof \ - -arch x86_64 \ - -fno-strict-aliasing \ - -Wall \ - -Wendif-labels \ - -W \ - -Wno-unused-parameter - -# Flags passed to only C files. -CFLAGS_C_Debug := - -# Flags passed to only C++ files. -CFLAGS_CC_Debug := -fno-rtti \ - -fno-exceptions \ - -fvisibility-inlines-hidden \ - -fno-threadsafe-statics - -# Flags passed to only ObjC files. -CFLAGS_OBJC_Debug := - -# Flags passed to only ObjC++ files. -CFLAGS_OBJCC_Debug := - -INCS_Debug := -I$(srcdir)/src/libuv/include - -DEFS_Release := '-D_LARGEFILE_SOURCE' \ - '-D_FILE_OFFSET_BITS=64' \ - '-D_GNU_SOURCE' \ - '-DEIO_STACKSIZE=262144' \ - '-DNDEBUG' - -# Flags passed to all source files. -CFLAGS_Release := -Os \ - -gdwarf-2 \ - -fvisibility=hidden \ - -Wnewline-eof \ - -arch x86_64 \ - -fno-strict-aliasing \ - -Wall \ - -Wendif-labels \ - -W \ - -Wno-unused-parameter - -# Flags passed to only C files. -CFLAGS_C_Release := - -# Flags passed to only C++ files. -CFLAGS_CC_Release := -fno-rtti \ - -fno-exceptions \ - -fvisibility-inlines-hidden \ - -fno-threadsafe-statics - -# Flags passed to only ObjC files. -CFLAGS_OBJC_Release := - -# Flags passed to only ObjC++ files. -CFLAGS_OBJCC_Release := - -INCS_Release := -I$(srcdir)/src/libuv/include - -OBJS := $(obj).target/$(TARGET)/src/libuv/test/blackhole-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/echo-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/run-tests.o \ - $(obj).target/$(TARGET)/src/libuv/test/runner.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-get-loadavg.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-util.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-async.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-callback-stack.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-connection-fail.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-cwd-and-chdir.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-delayed-accept.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-eio-overflow.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-fail-always.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-fs.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-fs-event.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-get-currentexe.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-get-memory.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-getaddrinfo.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-gethostbyname.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-getsockname.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-hrtime.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-idle.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-ipc.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-ipc-threads.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-loop-handles.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-multiple-listen.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-pass-always.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-ping-pong.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-pipe-bind-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-pipe-connect-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-platform-output.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-process-title.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-ref.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-shutdown-eof.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-spawn.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-stdio-over-pipes.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-bind-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-bind6-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-close.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-flags.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-connect-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-connect6-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-write-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-write-to-half-open-connection.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-writealot.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-threadpool.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-mutexes.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-thread.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-timer-again.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-timer.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tty.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-dgram-too-big.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-ipv6.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-options.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-send-and-recv.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-multicast-join.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-counters-init.o \ - $(obj).target/$(TARGET)/src/libuv/test/runner-unix.o - -# Add to the list of files we specially track dependencies for. -all_deps += $(OBJS) - -# Make sure our dependencies are built before any of us. -$(OBJS): | $(builddir)/libuv.a - -# CFLAGS et al overrides must be target-local. -# See "Target-specific Variable Values" in the GNU Make manual. -$(OBJS): TOOLSET := $(TOOLSET) -$(OBJS): GYP_CFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) -$(OBJS): GYP_CXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) -$(OBJS): GYP_OBJCFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) $(CFLAGS_OBJC_$(BUILDTYPE)) -$(OBJS): GYP_OBJCXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) $(CFLAGS_OBJCC_$(BUILDTYPE)) - -# Suffix rules, putting all outputs into $(obj). - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# Try building from generated source, too. - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# End of this set of suffix rules -### Rules for final target. -LDFLAGS_Debug := -Wl,-search_paths_first \ - -arch x86_64 \ - -L$(builddir) - -LDFLAGS_Release := -Wl,-search_paths_first \ - -arch x86_64 \ - -L$(builddir) - -LIBS := -framework Carbon \ - -framework CoreServices - -$(builddir)/run-tests: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE)) -$(builddir)/run-tests: LIBS := $(LIBS) -$(builddir)/run-tests: LD_INPUTS := $(OBJS) $(builddir)/libuv.a -$(builddir)/run-tests: TOOLSET := $(TOOLSET) -$(builddir)/run-tests: $(OBJS) $(builddir)/libuv.a FORCE_DO_CMD - $(call do_cmd,link) - -all_deps += $(builddir)/run-tests -# Add target alias -.PHONY: run-tests -run-tests: $(builddir)/run-tests - -# Add executable to "all" target. -.PHONY: all -all: $(builddir)/run-tests - diff --git a/mk/libuv/x86_64/mac/src/libuv/uv.Makefile b/mk/libuv/x86_64/mac/src/libuv/uv.Makefile deleted file mode 100644 index 48cdc76e17524..0000000000000 --- a/mk/libuv/x86_64/mac/src/libuv/uv.Makefile +++ /dev/null @@ -1,6 +0,0 @@ -# This file is generated by gyp; do not edit. - -export builddir_name ?= mk/libuv/x86_64/mac/./src/libuv/out -.PHONY: all -all: - $(MAKE) -C ../.. uv run-benchmarks run-tests diff --git a/mk/libuv/x86_64/mac/src/libuv/uv.target.mk b/mk/libuv/x86_64/mac/src/libuv/uv.target.mk deleted file mode 100644 index 385a64c9f538b..0000000000000 --- a/mk/libuv/x86_64/mac/src/libuv/uv.target.mk +++ /dev/null @@ -1,202 +0,0 @@ -# This file is generated by gyp; do not edit. - -TOOLSET := target -TARGET := uv -DEFS_Debug := '-D_LARGEFILE_SOURCE' \ - '-D_FILE_OFFSET_BITS=64' \ - '-D_GNU_SOURCE' \ - '-DEIO_STACKSIZE=262144' \ - '-DHAVE_CONFIG_H' \ - '-DEV_CONFIG_H="config_darwin.h"' \ - '-DEIO_CONFIG_H="config_darwin.h"' \ - '-DDEBUG' \ - '-D_DEBUG' \ - '-DEV_VERIFY=2' - -# Flags passed to all source files. -CFLAGS_Debug := -Os \ - -gdwarf-2 \ - -fvisibility=hidden \ - -Wnewline-eof \ - -arch x86_64 \ - -fno-strict-aliasing \ - -Wall \ - -Wendif-labels \ - -W \ - -Wno-unused-parameter - -# Flags passed to only C files. -CFLAGS_C_Debug := - -# Flags passed to only C++ files. -CFLAGS_CC_Debug := -fno-rtti \ - -fno-exceptions \ - -fvisibility-inlines-hidden \ - -fno-threadsafe-statics - -# Flags passed to only ObjC files. -CFLAGS_OBJC_Debug := - -# Flags passed to only ObjC++ files. -CFLAGS_OBJCC_Debug := - -INCS_Debug := -I$(srcdir)/src/libuv/include \ - -I$(srcdir)/src/libuv/include/uv-private \ - -I$(srcdir)/src/libuv/src \ - -I$(srcdir)/src/libuv/src/unix/ev \ - -I$(srcdir)/src/libuv/src/ares/config_darwin - -DEFS_Release := '-D_LARGEFILE_SOURCE' \ - '-D_FILE_OFFSET_BITS=64' \ - '-D_GNU_SOURCE' \ - '-DEIO_STACKSIZE=262144' \ - '-DHAVE_CONFIG_H' \ - '-DEV_CONFIG_H="config_darwin.h"' \ - '-DEIO_CONFIG_H="config_darwin.h"' \ - '-DNDEBUG' - -# Flags passed to all source files. -CFLAGS_Release := -Os \ - -gdwarf-2 \ - -fvisibility=hidden \ - -Wnewline-eof \ - -arch x86_64 \ - -fno-strict-aliasing \ - -Wall \ - -Wendif-labels \ - -W \ - -Wno-unused-parameter - -# Flags passed to only C files. -CFLAGS_C_Release := - -# Flags passed to only C++ files. -CFLAGS_CC_Release := -fno-rtti \ - -fno-exceptions \ - -fvisibility-inlines-hidden \ - -fno-threadsafe-statics - -# Flags passed to only ObjC files. -CFLAGS_OBJC_Release := - -# Flags passed to only ObjC++ files. -CFLAGS_OBJCC_Release := - -INCS_Release := -I$(srcdir)/src/libuv/include \ - -I$(srcdir)/src/libuv/include/uv-private \ - -I$(srcdir)/src/libuv/src \ - -I$(srcdir)/src/libuv/src/unix/ev \ - -I$(srcdir)/src/libuv/src/ares/config_darwin - -OBJS := $(obj).target/$(TARGET)/src/libuv/src/uv-common.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_cancel.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares__close_sockets.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_data.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_destroy.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_expand_name.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_expand_string.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_fds.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_free_hostent.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_free_string.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_gethostbyaddr.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_gethostbyname.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares__get_hostent.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_getnameinfo.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_getopt.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_getsock.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_init.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_library_init.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_llist.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_mkquery.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_nowarn.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_options.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_aaaa_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_a_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_mx_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_ns_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_ptr_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_srv_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_txt_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_process.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_query.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares__read_line.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_search.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_send.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_strcasecmp.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_strdup.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_strerror.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_timeout.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares__timeval.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_version.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_writev.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/bitncmp.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/inet_net_pton.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/inet_ntop.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/windows_port.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/core.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/uv-eio.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/fs.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/udp.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/tcp.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/pipe.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/tty.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/stream.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/cares.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/dl.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/error.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/thread.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/process.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/eio/eio.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/ev/ev.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/darwin.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/kqueue.o - -# Add to the list of files we specially track dependencies for. -all_deps += $(OBJS) - -# CFLAGS et al overrides must be target-local. -# See "Target-specific Variable Values" in the GNU Make manual. -$(OBJS): TOOLSET := $(TOOLSET) -$(OBJS): GYP_CFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) -$(OBJS): GYP_CXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) -$(OBJS): GYP_OBJCFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) $(CFLAGS_OBJC_$(BUILDTYPE)) -$(OBJS): GYP_OBJCXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) $(CFLAGS_OBJCC_$(BUILDTYPE)) - -# Suffix rules, putting all outputs into $(obj). - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# Try building from generated source, too. - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# End of this set of suffix rules -### Rules for final target. -LDFLAGS_Debug := -arch x86_64 \ - -L$(builddir) - -LDFLAGS_Release := -arch x86_64 \ - -L$(builddir) - -LIBS := -lm - -$(builddir)/libuv.a: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE)) -$(builddir)/libuv.a: LIBS := $(LIBS) -$(builddir)/libuv.a: TOOLSET := $(TOOLSET) -$(builddir)/libuv.a: $(OBJS) FORCE_DO_CMD - $(call do_cmd,alink) - -all_deps += $(builddir)/libuv.a -# Add target alias -.PHONY: uv -uv: $(builddir)/libuv.a - -# Add target alias to "all" target. -.PHONY: all -all: uv - diff --git a/mk/libuv/x86_64/unix/freebsd/Makefile b/mk/libuv/x86_64/unix/freebsd/Makefile deleted file mode 100644 index d77345c740e8e..0000000000000 --- a/mk/libuv/x86_64/unix/freebsd/Makefile +++ /dev/null @@ -1,354 +0,0 @@ -# We borrow heavily from the kernel build setup, though we are simpler since -# we don't have Kconfig tweaking settings on us. - -# The implicit make rules have it looking for RCS files, among other things. -# We instead explicitly write all the rules we care about. -# It's even quicker (saves ~200ms) to pass -r on the command line. -MAKEFLAGS=-r - -# The source directory tree. -srcdir := ../../../../.. -abs_srcdir := $(abspath $(srcdir)) - -# The name of the builddir. -builddir_name ?= out - -# The V=1 flag on command line makes us verbosely print command lines. -ifdef V - quiet= -else - quiet=quiet_ -endif - -# Specify BUILDTYPE=Release on the command line for a release build. -BUILDTYPE ?= Debug - -# Directory all our build output goes into. -# Note that this must be two directories beneath src/ for unit tests to pass, -# as they reach into the src/ directory for data with relative paths. -builddir ?= $(builddir_name)/$(BUILDTYPE) -abs_builddir := $(abspath $(builddir)) -depsdir := $(builddir)/.deps - -# Object output directory. -obj := $(builddir)/obj -abs_obj := $(abspath $(obj)) - -# We build up a list of every single one of the targets so we can slurp in the -# generated dependency rule Makefiles in one pass. -all_deps := - - - -# C++ apps need to be linked with g++. -# -# Note: flock is used to seralize linking. Linking is a memory-intensive -# process so running parallel links can often lead to thrashing. To disable -# the serialization, override LINK via an envrionment variable as follows: -# -# export LINK=g++ -# -# This will allow make to invoke N linker processes as specified in -jN. -LINK ?= flock $(builddir)/linker.lock $(CXX) - -CC.target ?= $(CC) -CFLAGS.target ?= $(CFLAGS) -CXX.target ?= $(CXX) -CXXFLAGS.target ?= $(CXXFLAGS) -LINK.target ?= $(LINK) -LDFLAGS.target ?= $(LDFLAGS) -AR.target ?= $(AR) -ARFLAGS.target ?= crs - -# N.B.: the logic of which commands to run should match the computation done -# in gyp's make.py where ARFLAGS.host etc. is computed. -# TODO(evan): move all cross-compilation logic to gyp-time so we don't need -# to replicate this environment fallback in make as well. -CC.host ?= gcc -CFLAGS.host ?= -CXX.host ?= g++ -CXXFLAGS.host ?= -LINK.host ?= g++ -LDFLAGS.host ?= -AR.host ?= ar -ARFLAGS.host := crs - -# Define a dir function that can handle spaces. -# http://www.gnu.org/software/make/manual/make.html#Syntax-of-Functions -# "leading spaces cannot appear in the text of the first argument as written. -# These characters can be put into the argument value by variable substitution." -empty := -space := $(empty) $(empty) - -# http://stackoverflow.com/questions/1189781/using-make-dir-or-notdir-on-a-path-with-spaces -replace_spaces = $(subst $(space),?,$1) -unreplace_spaces = $(subst ?,$(space),$1) -dirx = $(call unreplace_spaces,$(dir $(call replace_spaces,$1))) - -# Flags to make gcc output dependency info. Note that you need to be -# careful here to use the flags that ccache and distcc can understand. -# We write to a dep file on the side first and then rename at the end -# so we can't end up with a broken dep file. -depfile = $(depsdir)/$(call replace_spaces,$@).d -DEPFLAGS = -MMD -MF $(depfile).raw - -# We have to fixup the deps output in a few ways. -# (1) the file output should mention the proper .o file. -# ccache or distcc lose the path to the target, so we convert a rule of -# the form: -# foobar.o: DEP1 DEP2 -# into -# path/to/foobar.o: DEP1 DEP2 -# (2) we want missing files not to cause us to fail to build. -# We want to rewrite -# foobar.o: DEP1 DEP2 \ -# DEP3 -# to -# DEP1: -# DEP2: -# DEP3: -# so if the files are missing, they're just considered phony rules. -# We have to do some pretty insane escaping to get those backslashes -# and dollar signs past make, the shell, and sed at the same time. -# Doesn't work with spaces, but that's fine: .d files have spaces in -# their names replaced with other characters. -define fixup_dep -# The depfile may not exist if the input file didn't have any #includes. -touch $(depfile).raw -# Fixup path as in (1). -sed -e "s|^$(notdir $@)|$@|" $(depfile).raw >> $(depfile) -# Add extra rules as in (2). -# We remove slashes and replace spaces with new lines; -# remove blank lines; -# delete the first line and append a colon to the remaining lines. -sed -e 's|\\||' -e 'y| |\n|' $(depfile).raw |\ - grep -v '^$$' |\ - sed -e 1d -e 's|$$|:|' \ - >> $(depfile) -rm $(depfile).raw -endef - -# Command definitions: -# - cmd_foo is the actual command to run; -# - quiet_cmd_foo is the brief-output summary of the command. - -quiet_cmd_cc = CC($(TOOLSET)) $@ -cmd_cc = $(CC.$(TOOLSET)) $(GYP_CFLAGS) $(DEPFLAGS) $(CFLAGS.$(TOOLSET)) -c -o $@ $< - -quiet_cmd_cxx = CXX($(TOOLSET)) $@ -cmd_cxx = $(CXX.$(TOOLSET)) $(GYP_CXXFLAGS) $(DEPFLAGS) $(CXXFLAGS.$(TOOLSET)) -c -o $@ $< - -quiet_cmd_touch = TOUCH $@ -cmd_touch = touch $@ - -quiet_cmd_copy = COPY $@ -# send stderr to /dev/null to ignore messages when linking directories. -cmd_copy = ln -f "$<" "$@" 2>/dev/null || (rm -rf "$@" && cp -af "$<" "$@") - -quiet_cmd_alink = AR($(TOOLSET)) $@ -cmd_alink = rm -f $@ && $(AR.$(TOOLSET)) $(ARFLAGS.$(TOOLSET)) $@ $(filter %.o,$^) - -# Due to circular dependencies between libraries :(, we wrap the -# special "figure out circular dependencies" flags around the entire -# input list during linking. -quiet_cmd_link = LINK($(TOOLSET)) $@ -cmd_link = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ -Wl,--start-group $(LD_INPUTS) -Wl,--end-group $(LIBS) - -# We support two kinds of shared objects (.so): -# 1) shared_library, which is just bundling together many dependent libraries -# into a link line. -# 2) loadable_module, which is generating a module intended for dlopen(). -# -# They differ only slightly: -# In the former case, we want to package all dependent code into the .so. -# In the latter case, we want to package just the API exposed by the -# outermost module. -# This means shared_library uses --whole-archive, while loadable_module doesn't. -# (Note that --whole-archive is incompatible with the --start-group used in -# normal linking.) - -# Other shared-object link notes: -# - Set SONAME to the library filename so our binaries don't reference -# the local, absolute paths used on the link command-line. -quiet_cmd_solink = SOLINK($(TOOLSET)) $@ -cmd_solink = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -Wl,-soname=$(@F) -o $@ -Wl,--whole-archive $(LD_INPUTS) -Wl,--no-whole-archive $(LIBS) - -quiet_cmd_solink_module = SOLINK_MODULE($(TOOLSET)) $@ -cmd_solink_module = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -Wl,-soname=$(@F) -o $@ -Wl,--start-group $(filter-out FORCE_DO_CMD, $^) -Wl,--end-group $(LIBS) - - -# Define an escape_quotes function to escape single quotes. -# This allows us to handle quotes properly as long as we always use -# use single quotes and escape_quotes. -escape_quotes = $(subst ','\'',$(1)) -# This comment is here just to include a ' to unconfuse syntax highlighting. -# Define an escape_vars function to escape '$' variable syntax. -# This allows us to read/write command lines with shell variables (e.g. -# $LD_LIBRARY_PATH), without triggering make substitution. -escape_vars = $(subst $$,$$$$,$(1)) -# Helper that expands to a shell command to echo a string exactly as it is in -# make. This uses printf instead of echo because printf's behaviour with respect -# to escape sequences is more portable than echo's across different shells -# (e.g., dash, bash). -exact_echo = printf '%s\n' '$(call escape_quotes,$(1))' - -# Helper to compare the command we're about to run against the command -# we logged the last time we ran the command. Produces an empty -# string (false) when the commands match. -# Tricky point: Make has no string-equality test function. -# The kernel uses the following, but it seems like it would have false -# positives, where one string reordered its arguments. -# arg_check = $(strip $(filter-out $(cmd_$(1)), $(cmd_$@)) \ -# $(filter-out $(cmd_$@), $(cmd_$(1)))) -# We instead substitute each for the empty string into the other, and -# say they're equal if both substitutions produce the empty string. -# .d files contain ? instead of spaces, take that into account. -command_changed = $(or $(subst $(cmd_$(1)),,$(cmd_$(call replace_spaces,$@))),\ - $(subst $(cmd_$(call replace_spaces,$@)),,$(cmd_$(1)))) - -# Helper that is non-empty when a prerequisite changes. -# Normally make does this implicitly, but we force rules to always run -# so we can check their command lines. -# $? -- new prerequisites -# $| -- order-only dependencies -prereq_changed = $(filter-out FORCE_DO_CMD,$(filter-out $|,$?)) - -# Helper that executes all postbuilds, and deletes the output file when done -# if any of the postbuilds failed. -define do_postbuilds - @E=0;\ - for p in $(POSTBUILDS); do\ - eval $$p;\ - F=$$?;\ - if [ $$F -ne 0 ]; then\ - E=$$F;\ - fi;\ - done;\ - if [ $$E -ne 0 ]; then\ - rm -rf "$@";\ - exit $$E;\ - fi -endef - -# do_cmd: run a command via the above cmd_foo names, if necessary. -# Should always run for a given target to handle command-line changes. -# Second argument, if non-zero, makes it do asm/C/C++ dependency munging. -# Third argument, if non-zero, makes it do POSTBUILDS processing. -# Note: We intentionally do NOT call dirx for depfile, since it contains ? for -# spaces already and dirx strips the ? characters. -define do_cmd -$(if $(or $(command_changed),$(prereq_changed)), - @$(call exact_echo, $($(quiet)cmd_$(1))) - @mkdir -p "$(call dirx,$@)" "$(dir $(depfile))" - $(if $(findstring flock,$(word 1,$(cmd_$1))), - @$(cmd_$(1)) - @echo " $(quiet_cmd_$(1)): Finished", - @$(cmd_$(1)) - ) - @$(call exact_echo,$(call escape_vars,cmd_$(call replace_spaces,$@) := $(cmd_$(1)))) > $(depfile) - @$(if $(2),$(fixup_dep)) - $(if $(and $(3), $(POSTBUILDS)), - $(call do_postbuilds) - ) -) -endef - -# Declare the "all" target first so it is the default, -# even though we don't have the deps yet. -.PHONY: all -all: - -# Use FORCE_DO_CMD to force a target to run. Should be coupled with -# do_cmd. -.PHONY: FORCE_DO_CMD -FORCE_DO_CMD: - -TOOLSET := target -# Suffix rules, putting all outputs into $(obj). -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.cc FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.cpp FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.cxx FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.S FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.s FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# Try building from generated source, too. -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cc FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cpp FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cxx FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.S FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.s FORCE_DO_CMD - @$(call do_cmd,cc,1) - -$(obj).$(TOOLSET)/%.o: $(obj)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.cc FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.cpp FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.cxx FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.S FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.s FORCE_DO_CMD - @$(call do_cmd,cc,1) - - -ifeq ($(strip $(foreach prefix,$(NO_LOAD),\ - $(findstring $(join ^,$(prefix)),\ - $(join ^,src/libuv/run-benchmarks.target.mk)))),) - include src/libuv/run-benchmarks.target.mk -endif -ifeq ($(strip $(foreach prefix,$(NO_LOAD),\ - $(findstring $(join ^,$(prefix)),\ - $(join ^,src/libuv/run-tests.target.mk)))),) - include src/libuv/run-tests.target.mk -endif -ifeq ($(strip $(foreach prefix,$(NO_LOAD),\ - $(findstring $(join ^,$(prefix)),\ - $(join ^,src/libuv/uv.target.mk)))),) - include src/libuv/uv.target.mk -endif - -#quiet_cmd_regen_makefile = ACTION Regenerating $@ -#cmd_regen_makefile = ./src/libuv/build/gyp/gyp -fmake --ignore-environment "--toplevel-dir=." -Isrc/libuv/common.gypi "--depth=." "--generator-output=mk/libuv/x86_64/unix/freebsd" "-Ddefault_configuration=Default" "-Dcomponent=static_library" "-Dlibrary=static_library" "-Dtarget_arch=x86_64" "-DOS=freebsd" src/libuv/uv.gyp -#Makefile: $(srcdir)/src/libuv/uv.gyp $(srcdir)/src/libuv/common.gypi -# $(call do_cmd,regen_makefile) - -# "all" is a concatenation of the "all" targets from all the included -# sub-makefiles. This is just here to clarify. -all: - -# Add in dependency-tracking rules. $(all_deps) is the list of every single -# target in our tree. Only consider the ones with .d (dependency) info: -d_files := $(wildcard $(foreach f,$(all_deps),$(depsdir)/$(f).d)) -ifneq ($(d_files),) - # Rather than include each individual .d file, concatenate them into a - # single file which make is able to load faster. We split this into - # commands that take 1000 files at a time to avoid overflowing the - # command line. - $(shell cat $(wordlist 1,1000,$(d_files)) > $(depsdir)/all.deps) - - ifneq ($(word 1001,$(d_files)),) - $(error Found unprocessed dependency files (gyp didn't generate enough rules!)) - endif - - # make looks for ways to re-generate included makefiles, but in our case, we - # don't have a direct way. Explicitly telling make that it has nothing to do - # for them makes it go faster. - $(depsdir)/all.deps: ; - - include $(depsdir)/all.deps -endif diff --git a/mk/libuv/x86_64/unix/freebsd/src/libuv/run-benchmarks.target.mk b/mk/libuv/x86_64/unix/freebsd/src/libuv/run-benchmarks.target.mk deleted file mode 100644 index d65e86b00d34b..0000000000000 --- a/mk/libuv/x86_64/unix/freebsd/src/libuv/run-benchmarks.target.mk +++ /dev/null @@ -1,120 +0,0 @@ -# This file is generated by gyp; do not edit. - -TOOLSET := target -TARGET := run-benchmarks -DEFS_Debug := '-D_LARGEFILE_SOURCE' \ - '-D_FILE_OFFSET_BITS=64' \ - '-D_GNU_SOURCE' \ - '-DEIO_STACKSIZE=262144' \ - '-DDEBUG' \ - '-D_DEBUG' \ - '-DEV_VERIFY=2' - -# Flags passed to all source files. -CFLAGS_Debug := -pthread \ - -Wall \ - -pthread \ - -fvisibility=hidden \ - -g \ - -O0 - -# Flags passed to only C files. -CFLAGS_C_Debug := - -# Flags passed to only C++ files. -CFLAGS_CC_Debug := -fno-rtti \ - -fno-exceptions - -INCS_Debug := -I$(srcdir)/src/libuv/include - -DEFS_Release := '-D_LARGEFILE_SOURCE' \ - '-D_FILE_OFFSET_BITS=64' \ - '-D_GNU_SOURCE' \ - '-DEIO_STACKSIZE=262144' \ - '-DNDEBUG' - -# Flags passed to all source files. -CFLAGS_Release := -pthread \ - -Wall \ - -pthread \ - -fvisibility=hidden \ - -O3 \ - -fomit-frame-pointer \ - -fdata-sections \ - -ffunction-sections - -# Flags passed to only C files. -CFLAGS_C_Release := - -# Flags passed to only C++ files. -CFLAGS_CC_Release := -fno-rtti \ - -fno-exceptions - -INCS_Release := -I$(srcdir)/src/libuv/include - -OBJS := $(obj).target/$(TARGET)/src/libuv/test/benchmark-ares.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-getaddrinfo.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-ping-pongs.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-pound.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-pump.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-sizes.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-spawn.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-thread.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-tcp-write-batch.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-udp-packet-storm.o \ - $(obj).target/$(TARGET)/src/libuv/test/dns-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/echo-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/blackhole-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/run-benchmarks.o \ - $(obj).target/$(TARGET)/src/libuv/test/runner.o \ - $(obj).target/$(TARGET)/src/libuv/test/runner-unix.o - -# Add to the list of files we specially track dependencies for. -all_deps += $(OBJS) - -# Make sure our dependencies are built before any of us. -$(OBJS): | $(obj).target/src/libuv/libuv.a - -# CFLAGS et al overrides must be target-local. -# See "Target-specific Variable Values" in the GNU Make manual. -$(OBJS): TOOLSET := $(TOOLSET) -$(OBJS): GYP_CFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) -$(OBJS): GYP_CXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) - -# Suffix rules, putting all outputs into $(obj). - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# Try building from generated source, too. - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# End of this set of suffix rules -### Rules for final target. -LDFLAGS_Debug := -pthread - -LDFLAGS_Release := -pthread - -LIBS := -lkvm - -$(builddir)/run-benchmarks: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE)) -$(builddir)/run-benchmarks: LIBS := $(LIBS) -$(builddir)/run-benchmarks: LD_INPUTS := $(OBJS) $(obj).target/src/libuv/libuv.a -$(builddir)/run-benchmarks: TOOLSET := $(TOOLSET) -$(builddir)/run-benchmarks: $(OBJS) $(obj).target/src/libuv/libuv.a FORCE_DO_CMD - $(call do_cmd,link) - -all_deps += $(builddir)/run-benchmarks -# Add target alias -.PHONY: run-benchmarks -run-benchmarks: $(builddir)/run-benchmarks - -# Add executable to "all" target. -.PHONY: all -all: $(builddir)/run-benchmarks - diff --git a/mk/libuv/x86_64/unix/freebsd/src/libuv/run-tests.target.mk b/mk/libuv/x86_64/unix/freebsd/src/libuv/run-tests.target.mk deleted file mode 100644 index 67f22eabb9323..0000000000000 --- a/mk/libuv/x86_64/unix/freebsd/src/libuv/run-tests.target.mk +++ /dev/null @@ -1,163 +0,0 @@ -# This file is generated by gyp; do not edit. - -TOOLSET := target -TARGET := run-tests -DEFS_Debug := '-D_LARGEFILE_SOURCE' \ - '-D_FILE_OFFSET_BITS=64' \ - '-D_GNU_SOURCE' \ - '-DEIO_STACKSIZE=262144' \ - '-DDEBUG' \ - '-D_DEBUG' \ - '-DEV_VERIFY=2' - -# Flags passed to all source files. -CFLAGS_Debug := -pthread \ - -Wall \ - -pthread \ - -fvisibility=hidden \ - -g \ - -O0 - -# Flags passed to only C files. -CFLAGS_C_Debug := - -# Flags passed to only C++ files. -CFLAGS_CC_Debug := -fno-rtti \ - -fno-exceptions - -INCS_Debug := -I$(srcdir)/src/libuv/include - -DEFS_Release := '-D_LARGEFILE_SOURCE' \ - '-D_FILE_OFFSET_BITS=64' \ - '-D_GNU_SOURCE' \ - '-DEIO_STACKSIZE=262144' \ - '-DNDEBUG' - -# Flags passed to all source files. -CFLAGS_Release := -pthread \ - -Wall \ - -pthread \ - -fvisibility=hidden \ - -O3 \ - -fomit-frame-pointer \ - -fdata-sections \ - -ffunction-sections - -# Flags passed to only C files. -CFLAGS_C_Release := - -# Flags passed to only C++ files. -CFLAGS_CC_Release := -fno-rtti \ - -fno-exceptions - -INCS_Release := -I$(srcdir)/src/libuv/include - -OBJS := $(obj).target/$(TARGET)/src/libuv/test/blackhole-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/echo-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/run-tests.o \ - $(obj).target/$(TARGET)/src/libuv/test/runner.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-get-loadavg.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-util.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-async.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-callback-stack.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-connection-fail.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-cwd-and-chdir.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-delayed-accept.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-eio-overflow.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-fail-always.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-fs.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-fs-event.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-get-currentexe.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-get-memory.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-getaddrinfo.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-gethostbyname.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-getsockname.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-hrtime.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-idle.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-ipc.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-ipc-threads.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-loop-handles.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-multiple-listen.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-pass-always.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-ping-pong.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-pipe-bind-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-pipe-connect-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-platform-output.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-process-title.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-ref.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-shutdown-eof.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-spawn.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-stdio-over-pipes.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-bind-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-bind6-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-close.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-flags.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-connect-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-connect6-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-write-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-write-to-half-open-connection.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-writealot.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-threadpool.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-mutexes.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-thread.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-timer-again.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-timer.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tty.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-dgram-too-big.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-ipv6.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-options.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-send-and-recv.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-multicast-join.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-counters-init.o \ - $(obj).target/$(TARGET)/src/libuv/test/runner-unix.o - -# Add to the list of files we specially track dependencies for. -all_deps += $(OBJS) - -# Make sure our dependencies are built before any of us. -$(OBJS): | $(obj).target/src/libuv/libuv.a - -# CFLAGS et al overrides must be target-local. -# See "Target-specific Variable Values" in the GNU Make manual. -$(OBJS): TOOLSET := $(TOOLSET) -$(OBJS): GYP_CFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) -$(OBJS): GYP_CXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) - -# Suffix rules, putting all outputs into $(obj). - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# Try building from generated source, too. - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# End of this set of suffix rules -### Rules for final target. -LDFLAGS_Debug := -pthread - -LDFLAGS_Release := -pthread - -LIBS := -lkvm - -$(builddir)/run-tests: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE)) -$(builddir)/run-tests: LIBS := $(LIBS) -$(builddir)/run-tests: LD_INPUTS := $(OBJS) $(obj).target/src/libuv/libuv.a -$(builddir)/run-tests: TOOLSET := $(TOOLSET) -$(builddir)/run-tests: $(OBJS) $(obj).target/src/libuv/libuv.a FORCE_DO_CMD - $(call do_cmd,link) - -all_deps += $(builddir)/run-tests -# Add target alias -.PHONY: run-tests -run-tests: $(builddir)/run-tests - -# Add executable to "all" target. -.PHONY: all -all: $(builddir)/run-tests - diff --git a/mk/libuv/x86_64/unix/freebsd/src/libuv/uv.Makefile b/mk/libuv/x86_64/unix/freebsd/src/libuv/uv.Makefile deleted file mode 100644 index f49a7fb5ebf51..0000000000000 --- a/mk/libuv/x86_64/unix/freebsd/src/libuv/uv.Makefile +++ /dev/null @@ -1,6 +0,0 @@ -# This file is generated by gyp; do not edit. - -export builddir_name ?= mk/libuv/x86_64/unix/freebsd/./src/libuv/out -.PHONY: all -all: - $(MAKE) -C ../.. uv run-benchmarks run-tests diff --git a/mk/libuv/x86_64/unix/freebsd/src/libuv/uv.target.mk b/mk/libuv/x86_64/unix/freebsd/src/libuv/uv.target.mk deleted file mode 100644 index 49319f7c02387..0000000000000 --- a/mk/libuv/x86_64/unix/freebsd/src/libuv/uv.target.mk +++ /dev/null @@ -1,188 +0,0 @@ -# This file is generated by gyp; do not edit. - -TOOLSET := target -TARGET := uv -DEFS_Debug := '-D_LARGEFILE_SOURCE' \ - '-D_FILE_OFFSET_BITS=64' \ - '-D_GNU_SOURCE' \ - '-DEIO_STACKSIZE=262144' \ - '-DHAVE_CONFIG_H' \ - '-DEV_CONFIG_H="config_freebsd.h"' \ - '-DEIO_CONFIG_H="config_freebsd.h"' \ - '-DDEBUG' \ - '-D_DEBUG' \ - '-DEV_VERIFY=2' - -# Flags passed to all source files. -CFLAGS_Debug := -pthread \ - -Wall \ - -pthread \ - -fvisibility=hidden \ - -g \ - --std=gnu89 \ - -pedantic \ - -Wall \ - -Wextra \ - -Wno-unused-parameter \ - -g \ - -O0 - -# Flags passed to only C files. -CFLAGS_C_Debug := - -# Flags passed to only C++ files. -CFLAGS_CC_Debug := -fno-rtti \ - -fno-exceptions - -INCS_Debug := -I$(srcdir)/src/libuv/include \ - -I$(srcdir)/src/libuv/include/uv-private \ - -I$(srcdir)/src/libuv/src \ - -I$(srcdir)/src/libuv/src/unix/ev \ - -I$(srcdir)/src/libuv/src/ares/config_freebsd - -DEFS_Release := '-D_LARGEFILE_SOURCE' \ - '-D_FILE_OFFSET_BITS=64' \ - '-D_GNU_SOURCE' \ - '-DEIO_STACKSIZE=262144' \ - '-DHAVE_CONFIG_H' \ - '-DEV_CONFIG_H="config_freebsd.h"' \ - '-DEIO_CONFIG_H="config_freebsd.h"' \ - '-DNDEBUG' - -# Flags passed to all source files. -CFLAGS_Release := -pthread \ - -Wall \ - -pthread \ - -fvisibility=hidden \ - -g \ - --std=gnu89 \ - -pedantic \ - -Wall \ - -Wextra \ - -Wno-unused-parameter \ - -O3 \ - -fomit-frame-pointer \ - -fdata-sections \ - -ffunction-sections - -# Flags passed to only C files. -CFLAGS_C_Release := - -# Flags passed to only C++ files. -CFLAGS_CC_Release := -fno-rtti \ - -fno-exceptions - -INCS_Release := -I$(srcdir)/src/libuv/include \ - -I$(srcdir)/src/libuv/include/uv-private \ - -I$(srcdir)/src/libuv/src \ - -I$(srcdir)/src/libuv/src/unix/ev \ - -I$(srcdir)/src/libuv/src/ares/config_freebsd - -OBJS := $(obj).target/$(TARGET)/src/libuv/src/uv-common.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_cancel.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares__close_sockets.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_data.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_destroy.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_expand_name.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_expand_string.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_fds.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_free_hostent.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_free_string.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_gethostbyaddr.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_gethostbyname.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares__get_hostent.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_getnameinfo.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_getopt.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_getsock.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_init.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_library_init.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_llist.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_mkquery.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_nowarn.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_options.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_aaaa_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_a_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_mx_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_ns_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_ptr_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_srv_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_txt_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_process.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_query.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares__read_line.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_search.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_send.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_strcasecmp.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_strdup.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_strerror.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_timeout.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares__timeval.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_version.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_writev.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/bitncmp.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/inet_net_pton.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/inet_ntop.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/windows_port.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/core.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/uv-eio.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/fs.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/udp.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/tcp.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/pipe.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/tty.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/stream.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/cares.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/dl.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/error.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/thread.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/process.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/eio/eio.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/ev/ev.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/freebsd.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/kqueue.o - -# Add to the list of files we specially track dependencies for. -all_deps += $(OBJS) - -# CFLAGS et al overrides must be target-local. -# See "Target-specific Variable Values" in the GNU Make manual. -$(OBJS): TOOLSET := $(TOOLSET) -$(OBJS): GYP_CFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) -$(OBJS): GYP_CXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) - -# Suffix rules, putting all outputs into $(obj). - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# Try building from generated source, too. - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# End of this set of suffix rules -### Rules for final target. -LDFLAGS_Debug := -pthread - -LDFLAGS_Release := -pthread - -LIBS := -lm - -$(obj).target/src/libuv/libuv.a: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE)) -$(obj).target/src/libuv/libuv.a: LIBS := $(LIBS) -$(obj).target/src/libuv/libuv.a: TOOLSET := $(TOOLSET) -$(obj).target/src/libuv/libuv.a: $(OBJS) FORCE_DO_CMD - $(call do_cmd,alink) - -all_deps += $(obj).target/src/libuv/libuv.a -# Add target alias -.PHONY: uv -uv: $(obj).target/src/libuv/libuv.a - -# Add target alias to "all" target. -.PHONY: all -all: uv - diff --git a/mk/libuv/x86_64/unix/linux/Makefile b/mk/libuv/x86_64/unix/linux/Makefile deleted file mode 100644 index 72da220759968..0000000000000 --- a/mk/libuv/x86_64/unix/linux/Makefile +++ /dev/null @@ -1,354 +0,0 @@ -# We borrow heavily from the kernel build setup, though we are simpler since -# we don't have Kconfig tweaking settings on us. - -# The implicit make rules have it looking for RCS files, among other things. -# We instead explicitly write all the rules we care about. -# It's even quicker (saves ~200ms) to pass -r on the command line. -MAKEFLAGS=-r - -# The source directory tree. -srcdir := ../../../../.. -abs_srcdir := $(abspath $(srcdir)) - -# The name of the builddir. -builddir_name ?= out - -# The V=1 flag on command line makes us verbosely print command lines. -ifdef V - quiet= -else - quiet=quiet_ -endif - -# Specify BUILDTYPE=Release on the command line for a release build. -BUILDTYPE ?= Debug - -# Directory all our build output goes into. -# Note that this must be two directories beneath src/ for unit tests to pass, -# as they reach into the src/ directory for data with relative paths. -builddir ?= $(builddir_name)/$(BUILDTYPE) -abs_builddir := $(abspath $(builddir)) -depsdir := $(builddir)/.deps - -# Object output directory. -obj := $(builddir)/obj -abs_obj := $(abspath $(obj)) - -# We build up a list of every single one of the targets so we can slurp in the -# generated dependency rule Makefiles in one pass. -all_deps := - - - -# C++ apps need to be linked with g++. -# -# Note: flock is used to seralize linking. Linking is a memory-intensive -# process so running parallel links can often lead to thrashing. To disable -# the serialization, override LINK via an envrionment variable as follows: -# -# export LINK=g++ -# -# This will allow make to invoke N linker processes as specified in -jN. -LINK ?= flock $(builddir)/linker.lock $(CXX) - -CC.target ?= $(CC) -CFLAGS.target ?= $(CFLAGS) -CXX.target ?= $(CXX) -CXXFLAGS.target ?= $(CXXFLAGS) -LINK.target ?= $(LINK) -LDFLAGS.target ?= $(LDFLAGS) -AR.target ?= $(AR) -ARFLAGS.target ?= crs - -# N.B.: the logic of which commands to run should match the computation done -# in gyp's make.py where ARFLAGS.host etc. is computed. -# TODO(evan): move all cross-compilation logic to gyp-time so we don't need -# to replicate this environment fallback in make as well. -CC.host ?= gcc -CFLAGS.host ?= -CXX.host ?= g++ -CXXFLAGS.host ?= -LINK.host ?= g++ -LDFLAGS.host ?= -AR.host ?= ar -ARFLAGS.host := crs - -# Define a dir function that can handle spaces. -# http://www.gnu.org/software/make/manual/make.html#Syntax-of-Functions -# "leading spaces cannot appear in the text of the first argument as written. -# These characters can be put into the argument value by variable substitution." -empty := -space := $(empty) $(empty) - -# http://stackoverflow.com/questions/1189781/using-make-dir-or-notdir-on-a-path-with-spaces -replace_spaces = $(subst $(space),?,$1) -unreplace_spaces = $(subst ?,$(space),$1) -dirx = $(call unreplace_spaces,$(dir $(call replace_spaces,$1))) - -# Flags to make gcc output dependency info. Note that you need to be -# careful here to use the flags that ccache and distcc can understand. -# We write to a dep file on the side first and then rename at the end -# so we can't end up with a broken dep file. -depfile = $(depsdir)/$(call replace_spaces,$@).d -DEPFLAGS = -MMD -MF $(depfile).raw - -# We have to fixup the deps output in a few ways. -# (1) the file output should mention the proper .o file. -# ccache or distcc lose the path to the target, so we convert a rule of -# the form: -# foobar.o: DEP1 DEP2 -# into -# path/to/foobar.o: DEP1 DEP2 -# (2) we want missing files not to cause us to fail to build. -# We want to rewrite -# foobar.o: DEP1 DEP2 \ -# DEP3 -# to -# DEP1: -# DEP2: -# DEP3: -# so if the files are missing, they're just considered phony rules. -# We have to do some pretty insane escaping to get those backslashes -# and dollar signs past make, the shell, and sed at the same time. -# Doesn't work with spaces, but that's fine: .d files have spaces in -# their names replaced with other characters. -define fixup_dep -# The depfile may not exist if the input file didn't have any #includes. -touch $(depfile).raw -# Fixup path as in (1). -sed -e "s|^$(notdir $@)|$@|" $(depfile).raw >> $(depfile) -# Add extra rules as in (2). -# We remove slashes and replace spaces with new lines; -# remove blank lines; -# delete the first line and append a colon to the remaining lines. -sed -e 's|\\||' -e 'y| |\n|' $(depfile).raw |\ - grep -v '^$$' |\ - sed -e 1d -e 's|$$|:|' \ - >> $(depfile) -rm $(depfile).raw -endef - -# Command definitions: -# - cmd_foo is the actual command to run; -# - quiet_cmd_foo is the brief-output summary of the command. - -quiet_cmd_cc = CC($(TOOLSET)) $@ -cmd_cc = $(CC.$(TOOLSET)) $(GYP_CFLAGS) $(DEPFLAGS) $(CFLAGS.$(TOOLSET)) -c -o $@ $< - -quiet_cmd_cxx = CXX($(TOOLSET)) $@ -cmd_cxx = $(CXX.$(TOOLSET)) $(GYP_CXXFLAGS) $(DEPFLAGS) $(CXXFLAGS.$(TOOLSET)) -c -o $@ $< - -quiet_cmd_touch = TOUCH $@ -cmd_touch = touch $@ - -quiet_cmd_copy = COPY $@ -# send stderr to /dev/null to ignore messages when linking directories. -cmd_copy = ln -f "$<" "$@" 2>/dev/null || (rm -rf "$@" && cp -af "$<" "$@") - -quiet_cmd_alink = AR($(TOOLSET)) $@ -cmd_alink = rm -f $@ && $(AR.$(TOOLSET)) $(ARFLAGS.$(TOOLSET)) $@ $(filter %.o,$^) - -# Due to circular dependencies between libraries :(, we wrap the -# special "figure out circular dependencies" flags around the entire -# input list during linking. -quiet_cmd_link = LINK($(TOOLSET)) $@ -cmd_link = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ -Wl,--start-group $(LD_INPUTS) -Wl,--end-group $(LIBS) - -# We support two kinds of shared objects (.so): -# 1) shared_library, which is just bundling together many dependent libraries -# into a link line. -# 2) loadable_module, which is generating a module intended for dlopen(). -# -# They differ only slightly: -# In the former case, we want to package all dependent code into the .so. -# In the latter case, we want to package just the API exposed by the -# outermost module. -# This means shared_library uses --whole-archive, while loadable_module doesn't. -# (Note that --whole-archive is incompatible with the --start-group used in -# normal linking.) - -# Other shared-object link notes: -# - Set SONAME to the library filename so our binaries don't reference -# the local, absolute paths used on the link command-line. -quiet_cmd_solink = SOLINK($(TOOLSET)) $@ -cmd_solink = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -Wl,-soname=$(@F) -o $@ -Wl,--whole-archive $(LD_INPUTS) -Wl,--no-whole-archive $(LIBS) - -quiet_cmd_solink_module = SOLINK_MODULE($(TOOLSET)) $@ -cmd_solink_module = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -Wl,-soname=$(@F) -o $@ -Wl,--start-group $(filter-out FORCE_DO_CMD, $^) -Wl,--end-group $(LIBS) - - -# Define an escape_quotes function to escape single quotes. -# This allows us to handle quotes properly as long as we always use -# use single quotes and escape_quotes. -escape_quotes = $(subst ','\'',$(1)) -# This comment is here just to include a ' to unconfuse syntax highlighting. -# Define an escape_vars function to escape '$' variable syntax. -# This allows us to read/write command lines with shell variables (e.g. -# $LD_LIBRARY_PATH), without triggering make substitution. -escape_vars = $(subst $$,$$$$,$(1)) -# Helper that expands to a shell command to echo a string exactly as it is in -# make. This uses printf instead of echo because printf's behaviour with respect -# to escape sequences is more portable than echo's across different shells -# (e.g., dash, bash). -exact_echo = printf '%s\n' '$(call escape_quotes,$(1))' - -# Helper to compare the command we're about to run against the command -# we logged the last time we ran the command. Produces an empty -# string (false) when the commands match. -# Tricky point: Make has no string-equality test function. -# The kernel uses the following, but it seems like it would have false -# positives, where one string reordered its arguments. -# arg_check = $(strip $(filter-out $(cmd_$(1)), $(cmd_$@)) \ -# $(filter-out $(cmd_$@), $(cmd_$(1)))) -# We instead substitute each for the empty string into the other, and -# say they're equal if both substitutions produce the empty string. -# .d files contain ? instead of spaces, take that into account. -command_changed = $(or $(subst $(cmd_$(1)),,$(cmd_$(call replace_spaces,$@))),\ - $(subst $(cmd_$(call replace_spaces,$@)),,$(cmd_$(1)))) - -# Helper that is non-empty when a prerequisite changes. -# Normally make does this implicitly, but we force rules to always run -# so we can check their command lines. -# $? -- new prerequisites -# $| -- order-only dependencies -prereq_changed = $(filter-out FORCE_DO_CMD,$(filter-out $|,$?)) - -# Helper that executes all postbuilds, and deletes the output file when done -# if any of the postbuilds failed. -define do_postbuilds - @E=0;\ - for p in $(POSTBUILDS); do\ - eval $$p;\ - F=$$?;\ - if [ $$F -ne 0 ]; then\ - E=$$F;\ - fi;\ - done;\ - if [ $$E -ne 0 ]; then\ - rm -rf "$@";\ - exit $$E;\ - fi -endef - -# do_cmd: run a command via the above cmd_foo names, if necessary. -# Should always run for a given target to handle command-line changes. -# Second argument, if non-zero, makes it do asm/C/C++ dependency munging. -# Third argument, if non-zero, makes it do POSTBUILDS processing. -# Note: We intentionally do NOT call dirx for depfile, since it contains ? for -# spaces already and dirx strips the ? characters. -define do_cmd -$(if $(or $(command_changed),$(prereq_changed)), - @$(call exact_echo, $($(quiet)cmd_$(1))) - @mkdir -p "$(call dirx,$@)" "$(dir $(depfile))" - $(if $(findstring flock,$(word 1,$(cmd_$1))), - @$(cmd_$(1)) - @echo " $(quiet_cmd_$(1)): Finished", - @$(cmd_$(1)) - ) - @$(call exact_echo,$(call escape_vars,cmd_$(call replace_spaces,$@) := $(cmd_$(1)))) > $(depfile) - @$(if $(2),$(fixup_dep)) - $(if $(and $(3), $(POSTBUILDS)), - $(call do_postbuilds) - ) -) -endef - -# Declare the "all" target first so it is the default, -# even though we don't have the deps yet. -.PHONY: all -all: - -# Use FORCE_DO_CMD to force a target to run. Should be coupled with -# do_cmd. -.PHONY: FORCE_DO_CMD -FORCE_DO_CMD: - -TOOLSET := target -# Suffix rules, putting all outputs into $(obj). -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.cc FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.cpp FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.cxx FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.S FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.s FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# Try building from generated source, too. -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cc FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cpp FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cxx FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.S FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.s FORCE_DO_CMD - @$(call do_cmd,cc,1) - -$(obj).$(TOOLSET)/%.o: $(obj)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.cc FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.cpp FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.cxx FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.S FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.s FORCE_DO_CMD - @$(call do_cmd,cc,1) - - -ifeq ($(strip $(foreach prefix,$(NO_LOAD),\ - $(findstring $(join ^,$(prefix)),\ - $(join ^,src/libuv/run-benchmarks.target.mk)))),) - include src/libuv/run-benchmarks.target.mk -endif -ifeq ($(strip $(foreach prefix,$(NO_LOAD),\ - $(findstring $(join ^,$(prefix)),\ - $(join ^,src/libuv/run-tests.target.mk)))),) - include src/libuv/run-tests.target.mk -endif -ifeq ($(strip $(foreach prefix,$(NO_LOAD),\ - $(findstring $(join ^,$(prefix)),\ - $(join ^,src/libuv/uv.target.mk)))),) - include src/libuv/uv.target.mk -endif - -#quiet_cmd_regen_makefile = ACTION Regenerating $@ -#cmd_regen_makefile = ./src/libuv/build/gyp/gyp -fmake --ignore-environment "--toplevel-dir=." -Isrc/libuv/common.gypi "--depth=." "--generator-output=mk/libuv/x86_64/unix/linux" "-Ddefault_configuration=Default" "-Dcomponent=static_library" "-Dlibrary=static_library" "-Dtarget_arch=x86_64" "-DOS=linux" src/libuv/uv.gyp -#Makefile: $(srcdir)/src/libuv/uv.gyp $(srcdir)/src/libuv/common.gypi -# $(call do_cmd,regen_makefile) - -# "all" is a concatenation of the "all" targets from all the included -# sub-makefiles. This is just here to clarify. -all: - -# Add in dependency-tracking rules. $(all_deps) is the list of every single -# target in our tree. Only consider the ones with .d (dependency) info: -d_files := $(wildcard $(foreach f,$(all_deps),$(depsdir)/$(f).d)) -ifneq ($(d_files),) - # Rather than include each individual .d file, concatenate them into a - # single file which make is able to load faster. We split this into - # commands that take 1000 files at a time to avoid overflowing the - # command line. - $(shell cat $(wordlist 1,1000,$(d_files)) > $(depsdir)/all.deps) - - ifneq ($(word 1001,$(d_files)),) - $(error Found unprocessed dependency files (gyp didn't generate enough rules!)) - endif - - # make looks for ways to re-generate included makefiles, but in our case, we - # don't have a direct way. Explicitly telling make that it has nothing to do - # for them makes it go faster. - $(depsdir)/all.deps: ; - - include $(depsdir)/all.deps -endif diff --git a/mk/libuv/x86_64/unix/linux/src/libuv/run-benchmarks.target.mk b/mk/libuv/x86_64/unix/linux/src/libuv/run-benchmarks.target.mk deleted file mode 100644 index 25b01014e79d4..0000000000000 --- a/mk/libuv/x86_64/unix/linux/src/libuv/run-benchmarks.target.mk +++ /dev/null @@ -1,122 +0,0 @@ -# This file is generated by gyp; do not edit. - -TOOLSET := target -TARGET := run-benchmarks -DEFS_Debug := '-D_LARGEFILE_SOURCE' \ - '-D_FILE_OFFSET_BITS=64' \ - '-D_GNU_SOURCE' \ - '-DEIO_STACKSIZE=262144' \ - '-DDEBUG' \ - '-D_DEBUG' \ - '-DEV_VERIFY=2' - -# Flags passed to all source files. -CFLAGS_Debug := -pthread \ - -Wall \ - -ansi \ - -pthread \ - -fvisibility=hidden \ - -g \ - -O0 - -# Flags passed to only C files. -CFLAGS_C_Debug := - -# Flags passed to only C++ files. -CFLAGS_CC_Debug := -fno-rtti \ - -fno-exceptions - -INCS_Debug := -I$(srcdir)/src/libuv/include - -DEFS_Release := '-D_LARGEFILE_SOURCE' \ - '-D_FILE_OFFSET_BITS=64' \ - '-D_GNU_SOURCE' \ - '-DEIO_STACKSIZE=262144' \ - '-DNDEBUG' - -# Flags passed to all source files. -CFLAGS_Release := -pthread \ - -Wall \ - -ansi \ - -pthread \ - -fvisibility=hidden \ - -O3 \ - -fomit-frame-pointer \ - -fdata-sections \ - -ffunction-sections - -# Flags passed to only C files. -CFLAGS_C_Release := - -# Flags passed to only C++ files. -CFLAGS_CC_Release := -fno-rtti \ - -fno-exceptions - -INCS_Release := -I$(srcdir)/src/libuv/include - -OBJS := $(obj).target/$(TARGET)/src/libuv/test/benchmark-ares.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-getaddrinfo.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-ping-pongs.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-pound.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-pump.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-sizes.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-spawn.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-thread.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-tcp-write-batch.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-udp-packet-storm.o \ - $(obj).target/$(TARGET)/src/libuv/test/dns-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/echo-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/blackhole-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/run-benchmarks.o \ - $(obj).target/$(TARGET)/src/libuv/test/runner.o \ - $(obj).target/$(TARGET)/src/libuv/test/runner-unix.o - -# Add to the list of files we specially track dependencies for. -all_deps += $(OBJS) - -# Make sure our dependencies are built before any of us. -$(OBJS): | $(obj).target/src/libuv/libuv.a - -# CFLAGS et al overrides must be target-local. -# See "Target-specific Variable Values" in the GNU Make manual. -$(OBJS): TOOLSET := $(TOOLSET) -$(OBJS): GYP_CFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) -$(OBJS): GYP_CXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) - -# Suffix rules, putting all outputs into $(obj). - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# Try building from generated source, too. - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# End of this set of suffix rules -### Rules for final target. -LDFLAGS_Debug := -pthread - -LDFLAGS_Release := -pthread - -LIBS := -lrt - -$(builddir)/run-benchmarks: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE)) -$(builddir)/run-benchmarks: LIBS := $(LIBS) -$(builddir)/run-benchmarks: LD_INPUTS := $(OBJS) $(obj).target/src/libuv/libuv.a -$(builddir)/run-benchmarks: TOOLSET := $(TOOLSET) -$(builddir)/run-benchmarks: $(OBJS) $(obj).target/src/libuv/libuv.a FORCE_DO_CMD - $(call do_cmd,link) - -all_deps += $(builddir)/run-benchmarks -# Add target alias -.PHONY: run-benchmarks -run-benchmarks: $(builddir)/run-benchmarks - -# Add executable to "all" target. -.PHONY: all -all: $(builddir)/run-benchmarks - diff --git a/mk/libuv/x86_64/unix/linux/src/libuv/run-tests.target.mk b/mk/libuv/x86_64/unix/linux/src/libuv/run-tests.target.mk deleted file mode 100644 index a2fe0d2065e23..0000000000000 --- a/mk/libuv/x86_64/unix/linux/src/libuv/run-tests.target.mk +++ /dev/null @@ -1,165 +0,0 @@ -# This file is generated by gyp; do not edit. - -TOOLSET := target -TARGET := run-tests -DEFS_Debug := '-D_LARGEFILE_SOURCE' \ - '-D_FILE_OFFSET_BITS=64' \ - '-D_GNU_SOURCE' \ - '-DEIO_STACKSIZE=262144' \ - '-DDEBUG' \ - '-D_DEBUG' \ - '-DEV_VERIFY=2' - -# Flags passed to all source files. -CFLAGS_Debug := -pthread \ - -Wall \ - -ansi \ - -pthread \ - -fvisibility=hidden \ - -g \ - -O0 - -# Flags passed to only C files. -CFLAGS_C_Debug := - -# Flags passed to only C++ files. -CFLAGS_CC_Debug := -fno-rtti \ - -fno-exceptions - -INCS_Debug := -I$(srcdir)/src/libuv/include - -DEFS_Release := '-D_LARGEFILE_SOURCE' \ - '-D_FILE_OFFSET_BITS=64' \ - '-D_GNU_SOURCE' \ - '-DEIO_STACKSIZE=262144' \ - '-DNDEBUG' - -# Flags passed to all source files. -CFLAGS_Release := -pthread \ - -Wall \ - -ansi \ - -pthread \ - -fvisibility=hidden \ - -O3 \ - -fomit-frame-pointer \ - -fdata-sections \ - -ffunction-sections - -# Flags passed to only C files. -CFLAGS_C_Release := - -# Flags passed to only C++ files. -CFLAGS_CC_Release := -fno-rtti \ - -fno-exceptions - -INCS_Release := -I$(srcdir)/src/libuv/include - -OBJS := $(obj).target/$(TARGET)/src/libuv/test/blackhole-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/echo-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/run-tests.o \ - $(obj).target/$(TARGET)/src/libuv/test/runner.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-get-loadavg.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-util.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-async.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-callback-stack.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-connection-fail.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-cwd-and-chdir.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-delayed-accept.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-eio-overflow.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-fail-always.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-fs.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-fs-event.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-get-currentexe.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-get-memory.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-getaddrinfo.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-gethostbyname.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-getsockname.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-hrtime.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-idle.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-ipc.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-ipc-threads.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-loop-handles.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-multiple-listen.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-pass-always.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-ping-pong.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-pipe-bind-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-pipe-connect-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-platform-output.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-process-title.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-ref.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-shutdown-eof.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-spawn.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-stdio-over-pipes.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-bind-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-bind6-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-close.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-flags.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-connect-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-connect6-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-write-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-write-to-half-open-connection.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-writealot.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-threadpool.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-mutexes.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-thread.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-timer-again.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-timer.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tty.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-dgram-too-big.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-ipv6.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-options.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-send-and-recv.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-multicast-join.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-counters-init.o \ - $(obj).target/$(TARGET)/src/libuv/test/runner-unix.o - -# Add to the list of files we specially track dependencies for. -all_deps += $(OBJS) - -# Make sure our dependencies are built before any of us. -$(OBJS): | $(obj).target/src/libuv/libuv.a - -# CFLAGS et al overrides must be target-local. -# See "Target-specific Variable Values" in the GNU Make manual. -$(OBJS): TOOLSET := $(TOOLSET) -$(OBJS): GYP_CFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) -$(OBJS): GYP_CXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) - -# Suffix rules, putting all outputs into $(obj). - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# Try building from generated source, too. - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# End of this set of suffix rules -### Rules for final target. -LDFLAGS_Debug := -pthread - -LDFLAGS_Release := -pthread - -LIBS := -lrt - -$(builddir)/run-tests: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE)) -$(builddir)/run-tests: LIBS := $(LIBS) -$(builddir)/run-tests: LD_INPUTS := $(OBJS) $(obj).target/src/libuv/libuv.a -$(builddir)/run-tests: TOOLSET := $(TOOLSET) -$(builddir)/run-tests: $(OBJS) $(obj).target/src/libuv/libuv.a FORCE_DO_CMD - $(call do_cmd,link) - -all_deps += $(builddir)/run-tests -# Add target alias -.PHONY: run-tests -run-tests: $(builddir)/run-tests - -# Add executable to "all" target. -.PHONY: all -all: $(builddir)/run-tests - diff --git a/mk/libuv/x86_64/unix/linux/src/libuv/uv.Makefile b/mk/libuv/x86_64/unix/linux/src/libuv/uv.Makefile deleted file mode 100644 index bd68c31a92062..0000000000000 --- a/mk/libuv/x86_64/unix/linux/src/libuv/uv.Makefile +++ /dev/null @@ -1,6 +0,0 @@ -# This file is generated by gyp; do not edit. - -export builddir_name ?= mk/libuv/x86_64/unix/linux/./src/libuv/out -.PHONY: all -all: - $(MAKE) -C ../.. uv run-benchmarks run-tests diff --git a/mk/libuv/x86_64/unix/linux/src/libuv/uv.target.mk b/mk/libuv/x86_64/unix/linux/src/libuv/uv.target.mk deleted file mode 100644 index 60e0e8fd2def6..0000000000000 --- a/mk/libuv/x86_64/unix/linux/src/libuv/uv.target.mk +++ /dev/null @@ -1,189 +0,0 @@ -# This file is generated by gyp; do not edit. - -TOOLSET := target -TARGET := uv -DEFS_Debug := '-D_LARGEFILE_SOURCE' \ - '-D_FILE_OFFSET_BITS=64' \ - '-D_GNU_SOURCE' \ - '-DEIO_STACKSIZE=262144' \ - '-DHAVE_CONFIG_H' \ - '-DEV_CONFIG_H="config_linux.h"' \ - '-DEIO_CONFIG_H="config_linux.h"' \ - '-DDEBUG' \ - '-D_DEBUG' \ - '-DEV_VERIFY=2' - -# Flags passed to all source files. -CFLAGS_Debug := -pthread \ - -Wall \ - -ansi \ - -pthread \ - -fvisibility=hidden \ - -g \ - --std=gnu89 \ - -pedantic \ - -Wall \ - -Wextra \ - -Wno-unused-parameter \ - -g \ - -O0 - -# Flags passed to only C files. -CFLAGS_C_Debug := - -# Flags passed to only C++ files. -CFLAGS_CC_Debug := -fno-rtti \ - -fno-exceptions - -INCS_Debug := -I$(srcdir)/src/libuv/include \ - -I$(srcdir)/src/libuv/include/uv-private \ - -I$(srcdir)/src/libuv/src \ - -I$(srcdir)/src/libuv/src/unix/ev \ - -I$(srcdir)/src/libuv/src/ares/config_linux - -DEFS_Release := '-D_LARGEFILE_SOURCE' \ - '-D_FILE_OFFSET_BITS=64' \ - '-D_GNU_SOURCE' \ - '-DEIO_STACKSIZE=262144' \ - '-DHAVE_CONFIG_H' \ - '-DEV_CONFIG_H="config_linux.h"' \ - '-DEIO_CONFIG_H="config_linux.h"' \ - '-DNDEBUG' - -# Flags passed to all source files. -CFLAGS_Release := -pthread \ - -Wall \ - -ansi \ - -pthread \ - -fvisibility=hidden \ - -g \ - --std=gnu89 \ - -pedantic \ - -Wall \ - -Wextra \ - -Wno-unused-parameter \ - -O3 \ - -fomit-frame-pointer \ - -fdata-sections \ - -ffunction-sections - -# Flags passed to only C files. -CFLAGS_C_Release := - -# Flags passed to only C++ files. -CFLAGS_CC_Release := -fno-rtti \ - -fno-exceptions - -INCS_Release := -I$(srcdir)/src/libuv/include \ - -I$(srcdir)/src/libuv/include/uv-private \ - -I$(srcdir)/src/libuv/src \ - -I$(srcdir)/src/libuv/src/unix/ev \ - -I$(srcdir)/src/libuv/src/ares/config_linux - -OBJS := $(obj).target/$(TARGET)/src/libuv/src/uv-common.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_cancel.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares__close_sockets.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_data.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_destroy.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_expand_name.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_expand_string.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_fds.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_free_hostent.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_free_string.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_gethostbyaddr.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_gethostbyname.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares__get_hostent.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_getnameinfo.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_getopt.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_getsock.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_init.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_library_init.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_llist.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_mkquery.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_nowarn.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_options.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_aaaa_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_a_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_mx_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_ns_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_ptr_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_srv_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_txt_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_process.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_query.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares__read_line.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_search.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_send.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_strcasecmp.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_strdup.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_strerror.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_timeout.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares__timeval.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_version.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_writev.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/bitncmp.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/inet_net_pton.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/inet_ntop.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/windows_port.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/core.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/uv-eio.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/fs.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/udp.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/tcp.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/pipe.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/tty.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/stream.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/cares.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/dl.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/error.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/thread.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/process.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/eio/eio.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/ev/ev.o \ - $(obj).target/$(TARGET)/src/libuv/src/unix/linux.o - -# Add to the list of files we specially track dependencies for. -all_deps += $(OBJS) - -# CFLAGS et al overrides must be target-local. -# See "Target-specific Variable Values" in the GNU Make manual. -$(OBJS): TOOLSET := $(TOOLSET) -$(OBJS): GYP_CFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) -$(OBJS): GYP_CXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) - -# Suffix rules, putting all outputs into $(obj). - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# Try building from generated source, too. - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# End of this set of suffix rules -### Rules for final target. -LDFLAGS_Debug := -pthread - -LDFLAGS_Release := -pthread - -LIBS := -lm - -$(obj).target/src/libuv/libuv.a: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE)) -$(obj).target/src/libuv/libuv.a: LIBS := $(LIBS) -$(obj).target/src/libuv/libuv.a: TOOLSET := $(TOOLSET) -$(obj).target/src/libuv/libuv.a: $(OBJS) FORCE_DO_CMD - $(call do_cmd,alink) - -all_deps += $(obj).target/src/libuv/libuv.a -# Add target alias -.PHONY: uv -uv: $(obj).target/src/libuv/libuv.a - -# Add target alias to "all" target. -.PHONY: all -all: uv - diff --git a/mk/libuv/x86_64/win/Makefile b/mk/libuv/x86_64/win/Makefile deleted file mode 100644 index d40391e0f8988..0000000000000 --- a/mk/libuv/x86_64/win/Makefile +++ /dev/null @@ -1,354 +0,0 @@ -# We borrow heavily from the kernel build setup, though we are simpler since -# we don't have Kconfig tweaking settings on us. - -# The implicit make rules have it looking for RCS files, among other things. -# We instead explicitly write all the rules we care about. -# It's even quicker (saves ~200ms) to pass -r on the command line. -MAKEFLAGS=-r - -# The source directory tree. -srcdir := ../../../.. -abs_srcdir := $(abspath $(srcdir)) - -# The name of the builddir. -builddir_name ?= out - -# The V=1 flag on command line makes us verbosely print command lines. -ifdef V - quiet= -else - quiet=quiet_ -endif - -# Specify BUILDTYPE=Release on the command line for a release build. -BUILDTYPE ?= Debug - -# Directory all our build output goes into. -# Note that this must be two directories beneath src/ for unit tests to pass, -# as they reach into the src/ directory for data with relative paths. -builddir ?= $(builddir_name)/$(BUILDTYPE) -abs_builddir := $(abspath $(builddir)) -depsdir := $(builddir)/.deps - -# Object output directory. -obj := $(builddir)/obj -abs_obj := $(abspath $(obj)) - -# We build up a list of every single one of the targets so we can slurp in the -# generated dependency rule Makefiles in one pass. -all_deps := - - - -# C++ apps need to be linked with g++. -# -# Note: flock is used to seralize linking. Linking is a memory-intensive -# process so running parallel links can often lead to thrashing. To disable -# the serialization, override LINK via an envrionment variable as follows: -# -# export LINK=g++ -# -# This will allow make to invoke N linker processes as specified in -jN. -LINK ?= flock $(builddir)/linker.lock $(CXX) - -CC.target ?= $(CC) -CFLAGS.target ?= $(CFLAGS) -CXX.target ?= $(CXX) -CXXFLAGS.target ?= $(CXXFLAGS) -LINK.target ?= $(LINK) -LDFLAGS.target ?= $(LDFLAGS) -AR.target ?= $(AR) -ARFLAGS.target ?= crsT - -# N.B.: the logic of which commands to run should match the computation done -# in gyp's make.py where ARFLAGS.host etc. is computed. -# TODO(evan): move all cross-compilation logic to gyp-time so we don't need -# to replicate this environment fallback in make as well. -CC.host ?= gcc -CFLAGS.host ?= -CXX.host ?= g++ -CXXFLAGS.host ?= -LINK.host ?= g++ -LDFLAGS.host ?= -AR.host ?= ar -ARFLAGS.host := crsT - -# Define a dir function that can handle spaces. -# http://www.gnu.org/software/make/manual/make.html#Syntax-of-Functions -# "leading spaces cannot appear in the text of the first argument as written. -# These characters can be put into the argument value by variable substitution." -empty := -space := $(empty) $(empty) - -# http://stackoverflow.com/questions/1189781/using-make-dir-or-notdir-on-a-path-with-spaces -replace_spaces = $(subst $(space),?,$1) -unreplace_spaces = $(subst ?,$(space),$1) -dirx = $(call unreplace_spaces,$(dir $(call replace_spaces,$1))) - -# Flags to make gcc output dependency info. Note that you need to be -# careful here to use the flags that ccache and distcc can understand. -# We write to a dep file on the side first and then rename at the end -# so we can't end up with a broken dep file. -depfile = $(depsdir)/$(call replace_spaces,$@).d -DEPFLAGS = -MMD -MF $(depfile).raw - -# We have to fixup the deps output in a few ways. -# (1) the file output should mention the proper .o file. -# ccache or distcc lose the path to the target, so we convert a rule of -# the form: -# foobar.o: DEP1 DEP2 -# into -# path/to/foobar.o: DEP1 DEP2 -# (2) we want missing files not to cause us to fail to build. -# We want to rewrite -# foobar.o: DEP1 DEP2 \ -# DEP3 -# to -# DEP1: -# DEP2: -# DEP3: -# so if the files are missing, they're just considered phony rules. -# We have to do some pretty insane escaping to get those backslashes -# and dollar signs past make, the shell, and sed at the same time. -# Doesn't work with spaces, but that's fine: .d files have spaces in -# their names replaced with other characters. -define fixup_dep -# The depfile may not exist if the input file didn't have any #includes. -touch $(depfile).raw -# Fixup path as in (1). -sed -e "s|^$(notdir $@)|$@|" $(depfile).raw >> $(depfile) -# Add extra rules as in (2). -# We remove slashes and replace spaces with new lines; -# remove blank lines; -# delete the first line and append a colon to the remaining lines. -sed -e 's|\\||' -e 'y| |\n|' $(depfile).raw |\ - grep -v '^$$' |\ - sed -e 1d -e 's|$$|:|' \ - >> $(depfile) -rm $(depfile).raw -endef - -# Command definitions: -# - cmd_foo is the actual command to run; -# - quiet_cmd_foo is the brief-output summary of the command. - -quiet_cmd_cc = CC($(TOOLSET)) $@ -cmd_cc = $(CC.$(TOOLSET)) $(GYP_CFLAGS) $(DEPFLAGS) $(CFLAGS.$(TOOLSET)) -c -o $@ $< - -quiet_cmd_cxx = CXX($(TOOLSET)) $@ -cmd_cxx = $(CXX.$(TOOLSET)) $(GYP_CXXFLAGS) $(DEPFLAGS) $(CXXFLAGS.$(TOOLSET)) -c -o $@ $< - -quiet_cmd_touch = TOUCH $@ -cmd_touch = touch $@ - -quiet_cmd_copy = COPY $@ -# send stderr to /dev/null to ignore messages when linking directories. -cmd_copy = ln -f "$<" "$@" 2>/dev/null || (rm -rf "$@" && cp -af "$<" "$@") - -quiet_cmd_alink = AR($(TOOLSET)) $@ -cmd_alink = rm -f $@ && $(AR.$(TOOLSET)) $(ARFLAGS.$(TOOLSET)) $@ $(filter %.o,$^) - -# Due to circular dependencies between libraries :(, we wrap the -# special "figure out circular dependencies" flags around the entire -# input list during linking. -quiet_cmd_link = LINK($(TOOLSET)) $@ -cmd_link = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ -Wl,--start-group $(LD_INPUTS) -Wl,--end-group $(LIBS) - -# We support two kinds of shared objects (.so): -# 1) shared_library, which is just bundling together many dependent libraries -# into a link line. -# 2) loadable_module, which is generating a module intended for dlopen(). -# -# They differ only slightly: -# In the former case, we want to package all dependent code into the .so. -# In the latter case, we want to package just the API exposed by the -# outermost module. -# This means shared_library uses --whole-archive, while loadable_module doesn't. -# (Note that --whole-archive is incompatible with the --start-group used in -# normal linking.) - -# Other shared-object link notes: -# - Set SONAME to the library filename so our binaries don't reference -# the local, absolute paths used on the link command-line. -quiet_cmd_solink = SOLINK($(TOOLSET)) $@ -cmd_solink = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -Wl,-soname=$(@F) -o $@ -Wl,--whole-archive $(LD_INPUTS) -Wl,--no-whole-archive $(LIBS) - -quiet_cmd_solink_module = SOLINK_MODULE($(TOOLSET)) $@ -cmd_solink_module = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -Wl,-soname=$(@F) -o $@ -Wl,--start-group $(filter-out FORCE_DO_CMD, $^) -Wl,--end-group $(LIBS) - - -# Define an escape_quotes function to escape single quotes. -# This allows us to handle quotes properly as long as we always use -# use single quotes and escape_quotes. -escape_quotes = $(subst ','\'',$(1)) -# This comment is here just to include a ' to unconfuse syntax highlighting. -# Define an escape_vars function to escape '$' variable syntax. -# This allows us to read/write command lines with shell variables (e.g. -# $LD_LIBRARY_PATH), without triggering make substitution. -escape_vars = $(subst $$,$$$$,$(1)) -# Helper that expands to a shell command to echo a string exactly as it is in -# make. This uses printf instead of echo because printf's behaviour with respect -# to escape sequences is more portable than echo's across different shells -# (e.g., dash, bash). -exact_echo = printf '%s\n' '$(call escape_quotes,$(1))' - -# Helper to compare the command we're about to run against the command -# we logged the last time we ran the command. Produces an empty -# string (false) when the commands match. -# Tricky point: Make has no string-equality test function. -# The kernel uses the following, but it seems like it would have false -# positives, where one string reordered its arguments. -# arg_check = $(strip $(filter-out $(cmd_$(1)), $(cmd_$@)) \ -# $(filter-out $(cmd_$@), $(cmd_$(1)))) -# We instead substitute each for the empty string into the other, and -# say they're equal if both substitutions produce the empty string. -# .d files contain ? instead of spaces, take that into account. -command_changed = $(or $(subst $(cmd_$(1)),,$(cmd_$(call replace_spaces,$@))),\ - $(subst $(cmd_$(call replace_spaces,$@)),,$(cmd_$(1)))) - -# Helper that is non-empty when a prerequisite changes. -# Normally make does this implicitly, but we force rules to always run -# so we can check their command lines. -# $? -- new prerequisites -# $| -- order-only dependencies -prereq_changed = $(filter-out FORCE_DO_CMD,$(filter-out $|,$?)) - -# Helper that executes all postbuilds, and deletes the output file when done -# if any of the postbuilds failed. -define do_postbuilds - @E=0;\ - for p in $(POSTBUILDS); do\ - eval $$p;\ - F=$$?;\ - if [ $$F -ne 0 ]; then\ - E=$$F;\ - fi;\ - done;\ - if [ $$E -ne 0 ]; then\ - rm -rf "$@";\ - exit $$E;\ - fi -endef - -# do_cmd: run a command via the above cmd_foo names, if necessary. -# Should always run for a given target to handle command-line changes. -# Second argument, if non-zero, makes it do asm/C/C++ dependency munging. -# Third argument, if non-zero, makes it do POSTBUILDS processing. -# Note: We intentionally do NOT call dirx for depfile, since it contains ? for -# spaces already and dirx strips the ? characters. -define do_cmd -$(if $(or $(command_changed),$(prereq_changed)), - @$(call exact_echo, $($(quiet)cmd_$(1))) - @mkdir -p "$(call dirx,$@)" "$(dir $(depfile))" - $(if $(findstring flock,$(word 1,$(cmd_$1))), - @$(cmd_$(1)) - @echo " $(quiet_cmd_$(1)): Finished", - @$(cmd_$(1)) - ) - @$(call exact_echo,$(call escape_vars,cmd_$(call replace_spaces,$@) := $(cmd_$(1)))) > $(depfile) - @$(if $(2),$(fixup_dep)) - $(if $(and $(3), $(POSTBUILDS)), - $(call do_postbuilds) - ) -) -endef - -# Declare the "all" target first so it is the default, -# even though we don't have the deps yet. -.PHONY: all -all: - -# Use FORCE_DO_CMD to force a target to run. Should be coupled with -# do_cmd. -.PHONY: FORCE_DO_CMD -FORCE_DO_CMD: - -TOOLSET := target -# Suffix rules, putting all outputs into $(obj). -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.cc FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.cpp FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.cxx FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.S FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.s FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# Try building from generated source, too. -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cc FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cpp FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cxx FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.S FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.s FORCE_DO_CMD - @$(call do_cmd,cc,1) - -$(obj).$(TOOLSET)/%.o: $(obj)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.cc FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.cpp FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.cxx FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.S FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.s FORCE_DO_CMD - @$(call do_cmd,cc,1) - - -ifeq ($(strip $(foreach prefix,$(NO_LOAD),\ - $(findstring $(join ^,$(prefix)),\ - $(join ^,src/libuv/run-benchmarks.target.mk)))),) - include src/libuv/run-benchmarks.target.mk -endif -ifeq ($(strip $(foreach prefix,$(NO_LOAD),\ - $(findstring $(join ^,$(prefix)),\ - $(join ^,src/libuv/run-tests.target.mk)))),) - include src/libuv/run-tests.target.mk -endif -ifeq ($(strip $(foreach prefix,$(NO_LOAD),\ - $(findstring $(join ^,$(prefix)),\ - $(join ^,src/libuv/uv.target.mk)))),) - include src/libuv/uv.target.mk -endif - -#quiet_cmd_regen_makefile = ACTION Regenerating $@ -#cmd_regen_makefile = ./src/libuv/build/gyp/gyp -fmake --ignore-environment "--toplevel-dir=." -Isrc/libuv/common.gypi "--depth=." "--generator-output=mk/libuv/x86_64/win" "-Ddefault_configuration=Default" "-Dcomponent=static_library" "-Dlibrary=static_library" "-Dtarget_arch=x86_64" "-DOS=win" src/libuv/uv.gyp -#Makefile: $(srcdir)/src/libuv/uv.gyp $(srcdir)/src/libuv/common.gypi -# $(call do_cmd,regen_makefile) - -# "all" is a concatenation of the "all" targets from all the included -# sub-makefiles. This is just here to clarify. -all: - -# Add in dependency-tracking rules. $(all_deps) is the list of every single -# target in our tree. Only consider the ones with .d (dependency) info: -d_files := $(wildcard $(foreach f,$(all_deps),$(depsdir)/$(f).d)) -ifneq ($(d_files),) - # Rather than include each individual .d file, concatenate them into a - # single file which make is able to load faster. We split this into - # commands that take 1000 files at a time to avoid overflowing the - # command line. - $(shell cat $(wordlist 1,1000,$(d_files)) > $(depsdir)/all.deps) - - ifneq ($(word 1001,$(d_files)),) - $(error Found unprocessed dependency files (gyp didn't generate enough rules!)) - endif - - # make looks for ways to re-generate included makefiles, but in our case, we - # don't have a direct way. Explicitly telling make that it has nothing to do - # for them makes it go faster. - $(depsdir)/all.deps: ; - - include $(depsdir)/all.deps -endif diff --git a/mk/libuv/x86_64/win/src/libuv/run-benchmarks.target.mk b/mk/libuv/x86_64/win/src/libuv/run-benchmarks.target.mk deleted file mode 100644 index 25bf58f854886..0000000000000 --- a/mk/libuv/x86_64/win/src/libuv/run-benchmarks.target.mk +++ /dev/null @@ -1,110 +0,0 @@ -# This file is generated by gyp; do not edit. - -TOOLSET := target -TARGET := run-benchmarks -DEFS_Debug := '-DWIN32' \ - '-D_CRT_SECURE_NO_DEPRECATE' \ - '-D_CRT_NONSTDC_NO_DEPRECATE' \ - '-DDEBUG' \ - '-D_DEBUG' - -# Flags passed to all source files. -CFLAGS_Debug := -g \ - -O0 - -# Flags passed to only C files. -CFLAGS_C_Debug := - -# Flags passed to only C++ files. -CFLAGS_CC_Debug := - -INCS_Debug := -I$(srcdir)/src/libuv/include - -DEFS_Release := '-DWIN32' \ - '-D_CRT_SECURE_NO_DEPRECATE' \ - '-D_CRT_NONSTDC_NO_DEPRECATE' \ - '-DNDEBUG' - -# Flags passed to all source files. -CFLAGS_Release := -O3 \ - -fomit-frame-pointer \ - -fdata-sections \ - -ffunction-sections - -# Flags passed to only C files. -CFLAGS_C_Release := - -# Flags passed to only C++ files. -CFLAGS_CC_Release := - -INCS_Release := -I$(srcdir)/src/libuv/include - -OBJS := $(obj).target/$(TARGET)/src/libuv/test/benchmark-ares.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-getaddrinfo.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-ping-pongs.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-pound.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-pump.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-sizes.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-spawn.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-thread.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-tcp-write-batch.o \ - $(obj).target/$(TARGET)/src/libuv/test/benchmark-udp-packet-storm.o \ - $(obj).target/$(TARGET)/src/libuv/test/dns-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/echo-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/blackhole-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/run-benchmarks.o \ - $(obj).target/$(TARGET)/src/libuv/test/runner.o \ - $(obj).target/$(TARGET)/src/libuv/test/runner-win.o - -# Add to the list of files we specially track dependencies for. -all_deps += $(OBJS) - -# Make sure our dependencies are built before any of us. -$(OBJS): | $(obj).target/src/libuv/libuv.a - -# CFLAGS et al overrides must be target-local. -# See "Target-specific Variable Values" in the GNU Make manual. -$(OBJS): TOOLSET := $(TOOLSET) -$(OBJS): GYP_CFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) -$(OBJS): GYP_CXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) - -# Suffix rules, putting all outputs into $(obj). - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# Try building from generated source, too. - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# End of this set of suffix rules -### Rules for final target. -LDFLAGS_Debug := - -LDFLAGS_Release := - -LIBS := ws2_32.lib \ - -lws2_32.lib \ - -lpsapi.lib \ - -liphlpapi.lib - -$(builddir)/run-benchmarks: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE)) -$(builddir)/run-benchmarks: LIBS := $(LIBS) -$(builddir)/run-benchmarks: LD_INPUTS := $(OBJS) $(obj).target/src/libuv/libuv.a -$(builddir)/run-benchmarks: TOOLSET := $(TOOLSET) -$(builddir)/run-benchmarks: $(OBJS) $(obj).target/src/libuv/libuv.a FORCE_DO_CMD - $(call do_cmd,link) - -all_deps += $(builddir)/run-benchmarks -# Add target alias -.PHONY: run-benchmarks -run-benchmarks: $(builddir)/run-benchmarks - -# Add executable to "all" target. -.PHONY: all -all: $(builddir)/run-benchmarks - diff --git a/mk/libuv/x86_64/win/src/libuv/run-tests.target.mk b/mk/libuv/x86_64/win/src/libuv/run-tests.target.mk deleted file mode 100644 index 51b62f7a3e2d5..0000000000000 --- a/mk/libuv/x86_64/win/src/libuv/run-tests.target.mk +++ /dev/null @@ -1,153 +0,0 @@ -# This file is generated by gyp; do not edit. - -TOOLSET := target -TARGET := run-tests -DEFS_Debug := '-DWIN32' \ - '-D_CRT_SECURE_NO_DEPRECATE' \ - '-D_CRT_NONSTDC_NO_DEPRECATE' \ - '-DDEBUG' \ - '-D_DEBUG' - -# Flags passed to all source files. -CFLAGS_Debug := -g \ - -O0 - -# Flags passed to only C files. -CFLAGS_C_Debug := - -# Flags passed to only C++ files. -CFLAGS_CC_Debug := - -INCS_Debug := -I$(srcdir)/src/libuv/include - -DEFS_Release := '-DWIN32' \ - '-D_CRT_SECURE_NO_DEPRECATE' \ - '-D_CRT_NONSTDC_NO_DEPRECATE' \ - '-DNDEBUG' - -# Flags passed to all source files. -CFLAGS_Release := -O3 \ - -fomit-frame-pointer \ - -fdata-sections \ - -ffunction-sections - -# Flags passed to only C files. -CFLAGS_C_Release := - -# Flags passed to only C++ files. -CFLAGS_CC_Release := - -INCS_Release := -I$(srcdir)/src/libuv/include - -OBJS := $(obj).target/$(TARGET)/src/libuv/test/blackhole-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/echo-server.o \ - $(obj).target/$(TARGET)/src/libuv/test/run-tests.o \ - $(obj).target/$(TARGET)/src/libuv/test/runner.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-get-loadavg.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-util.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-async.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-callback-stack.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-connection-fail.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-cwd-and-chdir.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-delayed-accept.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-eio-overflow.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-fail-always.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-fs.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-fs-event.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-get-currentexe.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-get-memory.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-getaddrinfo.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-gethostbyname.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-getsockname.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-hrtime.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-idle.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-ipc.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-ipc-threads.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-loop-handles.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-multiple-listen.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-pass-always.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-ping-pong.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-pipe-bind-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-pipe-connect-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-platform-output.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-process-title.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-ref.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-shutdown-eof.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-spawn.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-stdio-over-pipes.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-bind-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-bind6-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-close.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-flags.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-connect-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-connect6-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-write-error.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-write-to-half-open-connection.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tcp-writealot.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-threadpool.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-mutexes.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-thread.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-timer-again.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-timer.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-tty.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-dgram-too-big.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-ipv6.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-options.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-send-and-recv.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-udp-multicast-join.o \ - $(obj).target/$(TARGET)/src/libuv/test/test-counters-init.o \ - $(obj).target/$(TARGET)/src/libuv/test/runner-win.o - -# Add to the list of files we specially track dependencies for. -all_deps += $(OBJS) - -# Make sure our dependencies are built before any of us. -$(OBJS): | $(obj).target/src/libuv/libuv.a - -# CFLAGS et al overrides must be target-local. -# See "Target-specific Variable Values" in the GNU Make manual. -$(OBJS): TOOLSET := $(TOOLSET) -$(OBJS): GYP_CFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) -$(OBJS): GYP_CXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) - -# Suffix rules, putting all outputs into $(obj). - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# Try building from generated source, too. - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# End of this set of suffix rules -### Rules for final target. -LDFLAGS_Debug := - -LDFLAGS_Release := - -LIBS := ws2_32.lib \ - -lws2_32.lib \ - -lpsapi.lib \ - -liphlpapi.lib - -$(builddir)/run-tests: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE)) -$(builddir)/run-tests: LIBS := $(LIBS) -$(builddir)/run-tests: LD_INPUTS := $(OBJS) $(obj).target/src/libuv/libuv.a -$(builddir)/run-tests: TOOLSET := $(TOOLSET) -$(builddir)/run-tests: $(OBJS) $(obj).target/src/libuv/libuv.a FORCE_DO_CMD - $(call do_cmd,link) - -all_deps += $(builddir)/run-tests -# Add target alias -.PHONY: run-tests -run-tests: $(builddir)/run-tests - -# Add executable to "all" target. -.PHONY: all -all: $(builddir)/run-tests - diff --git a/mk/libuv/x86_64/win/src/libuv/uv.Makefile b/mk/libuv/x86_64/win/src/libuv/uv.Makefile deleted file mode 100644 index 5c4f359e86ad2..0000000000000 --- a/mk/libuv/x86_64/win/src/libuv/uv.Makefile +++ /dev/null @@ -1,6 +0,0 @@ -# This file is generated by gyp; do not edit. - -export builddir_name ?= mk/libuv/x86_64/win/./src/libuv/out -.PHONY: all -all: - $(MAKE) -C ../.. uv run-benchmarks run-tests diff --git a/mk/libuv/x86_64/win/src/libuv/uv.target.mk b/mk/libuv/x86_64/win/src/libuv/uv.target.mk deleted file mode 100644 index 53576a0f93570..0000000000000 --- a/mk/libuv/x86_64/win/src/libuv/uv.target.mk +++ /dev/null @@ -1,171 +0,0 @@ -# This file is generated by gyp; do not edit. - -TOOLSET := target -TARGET := uv -DEFS_Debug := '-DWIN32' \ - '-D_CRT_SECURE_NO_DEPRECATE' \ - '-D_CRT_NONSTDC_NO_DEPRECATE' \ - '-DHAVE_CONFIG_H' \ - '-D_WIN32_WINNT=0x0600' \ - '-DEIO_STACKSIZE=262144' \ - '-D_GNU_SOURCE' \ - '-DDEBUG' \ - '-D_DEBUG' - -# Flags passed to all source files. -CFLAGS_Debug := -g \ - -O0 - -# Flags passed to only C files. -CFLAGS_C_Debug := - -# Flags passed to only C++ files. -CFLAGS_CC_Debug := - -INCS_Debug := -I$(srcdir)/src/libuv/include \ - -I$(srcdir)/src/libuv/include/uv-private \ - -I$(srcdir)/src/libuv/src \ - -I$(srcdir)/src/libuv/src/ares/config_win32 - -DEFS_Release := '-DWIN32' \ - '-D_CRT_SECURE_NO_DEPRECATE' \ - '-D_CRT_NONSTDC_NO_DEPRECATE' \ - '-DHAVE_CONFIG_H' \ - '-D_WIN32_WINNT=0x0600' \ - '-DEIO_STACKSIZE=262144' \ - '-D_GNU_SOURCE' \ - '-DNDEBUG' - -# Flags passed to all source files. -CFLAGS_Release := -O3 \ - -fomit-frame-pointer \ - -fdata-sections \ - -ffunction-sections - -# Flags passed to only C files. -CFLAGS_C_Release := - -# Flags passed to only C++ files. -CFLAGS_CC_Release := - -INCS_Release := -I$(srcdir)/src/libuv/include \ - -I$(srcdir)/src/libuv/include/uv-private \ - -I$(srcdir)/src/libuv/src \ - -I$(srcdir)/src/libuv/src/ares/config_win32 - -OBJS := $(obj).target/$(TARGET)/src/libuv/src/uv-common.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_cancel.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares__close_sockets.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_data.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_destroy.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_expand_name.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_expand_string.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_fds.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_free_hostent.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_free_string.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_gethostbyaddr.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_gethostbyname.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares__get_hostent.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_getnameinfo.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_getopt.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_getsock.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_init.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_library_init.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_llist.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_mkquery.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_nowarn.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_options.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_aaaa_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_a_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_mx_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_ns_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_ptr_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_srv_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_parse_txt_reply.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_process.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_query.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares__read_line.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_search.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_send.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_strcasecmp.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_strdup.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_strerror.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_timeout.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares__timeval.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_version.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_writev.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/bitncmp.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/inet_net_pton.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/inet_ntop.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/windows_port.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_getenv.o \ - $(obj).target/$(TARGET)/src/libuv/src/ares/ares_platform.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/async.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/cares.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/core.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/dl.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/error.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/fs.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/fs-event.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/getaddrinfo.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/handle.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/loop-watcher.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/pipe.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/thread.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/process.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/req.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/stream.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/tcp.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/tty.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/threadpool.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/timer.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/udp.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/util.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/winapi.o \ - $(obj).target/$(TARGET)/src/libuv/src/win/winsock.o - -# Add to the list of files we specially track dependencies for. -all_deps += $(OBJS) - -# CFLAGS et al overrides must be target-local. -# See "Target-specific Variable Values" in the GNU Make manual. -$(OBJS): TOOLSET := $(TOOLSET) -$(OBJS): GYP_CFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) -$(OBJS): GYP_CXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) - -# Suffix rules, putting all outputs into $(obj). - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# Try building from generated source, too. - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# End of this set of suffix rules -### Rules for final target. -LDFLAGS_Debug := - -LDFLAGS_Release := - -LIBS := - -$(obj).target/src/libuv/libuv.a: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE)) -$(obj).target/src/libuv/libuv.a: LIBS := $(LIBS) -$(obj).target/src/libuv/libuv.a: TOOLSET := $(TOOLSET) -$(obj).target/src/libuv/libuv.a: $(OBJS) FORCE_DO_CMD - $(call do_cmd,alink) - -all_deps += $(obj).target/src/libuv/libuv.a -# Add target alias -.PHONY: uv -uv: $(obj).target/src/libuv/libuv.a - -# Add target alias to "all" target. -.PHONY: all -all: uv - diff --git a/mk/platform.mk b/mk/platform.mk index d2f874561b185..0488f2f8cde0e 100644 --- a/mk/platform.mk +++ b/mk/platform.mk @@ -46,6 +46,7 @@ ifneq ($(findstring freebsd,$(CFG_OSTYPE)),) CFG_GCCISH_CFLAGS_x86_64 += -m64 CFG_GCCISH_LINK_FLAGS_x86_64 += -m64 CFG_UNIXY := 1 + CFG_FBSD := 1 CFG_LDENV := LD_LIBRARY_PATH CFG_DEF_SUFFIX := .bsd.def CFG_INSTALL_NAME = @@ -147,6 +148,9 @@ ifdef CFG_UNIXY CFG_RUN_TARG=$(call CFG_RUN,,$(2)) CFG_RUN_TEST=$(call CFG_RUN,,$(CFG_VALGRIND) $(1)) CFG_LIBUV_LINK_FLAGS=-lpthread + ifdef CFG_FBSD + CFG_LIBUV_LINK_FLAGS=-lpthread -lkvm + endif ifdef CFG_ENABLE_MINGW_CROSS CFG_WINDOWSY := 1 @@ -198,7 +202,7 @@ else endif CFG_RUN_TARG=$(call CFG_RUN,$(HLIB$(1)_H_$(CFG_HOST_TRIPLE)),$(2)) CFG_RUN_TEST=$(call CFG_RUN,$(call CFG_TESTLIB,$(1),$(3)),$(1)) - CFG_LIBUV_LINK_FLAGS=-lWs2_32 + CFG_LIBUV_LINK_FLAGS=-lWs2_32 -lpsapi -liphlpapi ifndef CFG_ENABLE_MINGW_CROSS CFG_PATH_MUNGE := $(strip perl -i.bak -p \ @@ -322,4 +326,4 @@ define CFG_MAKE_ASSEMBLER endef $(foreach target,$(CFG_TARGET_TRIPLES),\ - $(eval $(call CFG_MAKE_ASSEMBLER,$(target)))) \ No newline at end of file + $(eval $(call CFG_MAKE_ASSEMBLER,$(target)))) diff --git a/mk/rt.mk b/mk/rt.mk index eff16f510f9ae..23dc64dbca52e 100644 --- a/mk/rt.mk +++ b/mk/rt.mk @@ -88,16 +88,16 @@ endif ifeq ($$(CFG_WINDOWSY), 1) LIBUV_OSTYPE_$(1) := win - LIBUV_LIB_$(1) := rt/$(1)/libuv/Release/obj.target/src/libuv/libuv.a + LIBUV_LIB_$(1) := rt/$(1)/libuv/libuv.a else ifeq ($(CFG_OSTYPE), apple-darwin) LIBUV_OSTYPE_$(1) := mac - LIBUV_LIB_$(1) := rt/$(1)/libuv/Release/libuv.a + LIBUV_LIB_$(1) := rt/$(1)/libuv/libuv.a else ifeq ($(CFG_OSTYPE), unknown-freebsd) LIBUV_OSTYPE_$(1) := unix/freebsd - LIBUV_LIB_$(1) := rt/$(1)/libuv/Release/obj.target/src/libuv/libuv.a + LIBUV_LIB_$(1) := rt/$(1)/libuv/libuv.a else LIBUV_OSTYPE_$(1) := unix/linux - LIBUV_LIB_$(1) := rt/$(1)/libuv/Release/obj.target/src/libuv/libuv.a + LIBUV_LIB_$(1) := rt/$(1)/libuv/libuv.a endif RUNTIME_DEF_$(1) := rt/rustrt$$(CFG_DEF_SUFFIX) @@ -157,16 +157,20 @@ LIBUV_DEPS := $$(wildcard \ $$(S)src/libuv/*/*/*/*) endif +ifdef CFG_WINDOWSY +$$(LIBUV_LIB_$(1)): $$(LIBUV_DEPS) + $$(Q)$$(MAKE) -C $$(S)src/libuv/ \ + builddir_name="$$(CFG_BUILD_DIR)/rt/$(1)/libuv" \ + OS=mingw \ + V=$$(VERBOSE) +else $$(LIBUV_LIB_$(1)): $$(LIBUV_DEPS) - $$(Q)$$(MAKE) -C $$(S)mk/libuv/$$(LIBUV_ARCH_$(1))/$$(LIBUV_OSTYPE_$(1)) \ + $$(Q)$$(MAKE) -C $$(S)src/libuv/ \ CFLAGS="$$(LIBUV_FLAGS_$$(HOST_$(1))) $$(SNAP_DEFINES)" \ - LDFLAGS="$$(LIBUV_FLAGS_$$(HOST_$(1)))" \ - CC="$$(CFG_GCCISH_CROSS)$$(CC)" \ - CXX="$$(CFG_GCCISH_CROSS)$$(CXX)" \ - AR="$$(CFG_GCCISH_CROSS)$$(AR)" \ - BUILDTYPE=Release \ builddir_name="$$(CFG_BUILD_DIR)/rt/$(1)/libuv" \ - V=$$(VERBOSE) FLOCK= uv + V=$$(VERBOSE) +endif + # These could go in rt.mk or rustllvm.mk, they're needed for both. diff --git a/mk/tests.mk b/mk/tests.mk index 2c1b19486af4b..abe9ba60ecda4 100644 --- a/mk/tests.mk +++ b/mk/tests.mk @@ -103,7 +103,8 @@ cleantestlibs: -name '*.dSYM' -o \ -name '*.libaux' -o \ -name '*.out' -o \ - -name '*.err' \ + -name '*.err' -o \ + -name '*.debugger.script' \ | xargs rm -rf @@ -170,6 +171,7 @@ check-stage$(1)-T-$(2)-H-$(3)-exec: \ check-stage$(1)-T-$(2)-H-$(3)-rpass-full-exec \ check-stage$(1)-T-$(2)-H-$(3)-crates-exec \ check-stage$(1)-T-$(2)-H-$(3)-bench-exec \ + check-stage$(1)-T-$(2)-H-$(3)-debuginfo-exec \ check-stage$(1)-T-$(2)-H-$(3)-doc-exec \ check-stage$(1)-T-$(2)-H-$(3)-pretty-exec @@ -284,6 +286,7 @@ CFAIL_RC := $(wildcard $(S)src/test/compile-fail/*.rc) CFAIL_RS := $(wildcard $(S)src/test/compile-fail/*.rs) BENCH_RS := $(wildcard $(S)src/test/bench/*.rs) PRETTY_RS := $(wildcard $(S)src/test/pretty/*.rs) +DEBUGINFO_RS := $(wildcard $(S)src/test/debug-info/*.rs) # perf tests are the same as bench tests only they run under # a performance monitor. @@ -296,6 +299,7 @@ CFAIL_TESTS := $(CFAIL_RC) $(CFAIL_RS) BENCH_TESTS := $(BENCH_RS) PERF_TESTS := $(PERF_RS) PRETTY_TESTS := $(PRETTY_RS) +DEBUGINFO_TESTS := $(DEBUGINFO_RS) CTEST_SRC_BASE_rpass = run-pass CTEST_BUILD_BASE_rpass = run-pass @@ -327,6 +331,15 @@ CTEST_BUILD_BASE_perf = perf CTEST_MODE_perf = run-pass CTEST_RUNTOOL_perf = $(CTEST_PERF_RUNTOOL) +CTEST_SRC_BASE_debuginfo = debug-info +CTEST_BUILD_BASE_debuginfo = debug-info +CTEST_MODE_debuginfo = debug-info +CTEST_RUNTOOL_debuginfo = $(CTEST_RUNTOOL) + +ifeq ($(CFG_GDB),) +CTEST_DISABLE_debuginfo = "no gdb found" +endif + define DEF_CTEST_VARS # All the per-stage build rules you might want to call from the @@ -349,7 +362,7 @@ CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3) := \ --rustc-path $$(HBIN$(1)_H_$(3))/rustc$$(X) \ --aux-base $$(S)src/test/auxiliary/ \ --stage-id stage$(1)-$(2) \ - --rustcflags "$$(CFG_RUSTC_FLAGS) --target=$(2)" \ + --rustcflags "$$(CFG_RUSTC_FLAGS) --target=$(2)" \ $$(CTEST_TESTARGS) CTEST_DEPS_rpass_$(1)-T-$(2)-H-$(3) = $$(RPASS_TESTS) @@ -358,6 +371,7 @@ CTEST_DEPS_rfail_$(1)-T-$(2)-H-$(3) = $$(RFAIL_TESTS) CTEST_DEPS_cfail_$(1)-T-$(2)-H-$(3) = $$(CFAIL_TESTS) CTEST_DEPS_bench_$(1)-T-$(2)-H-$(3) = $$(BENCH_TESTS) CTEST_DEPS_perf_$(1)-T-$(2)-H-$(3) = $$(PERF_TESTS) +CTEST_DEPS_debuginfo_$(1)-T-$(2)-H-$(3) = $$(DEBUGINFO_TESTS) endef @@ -377,6 +391,8 @@ CTEST_ARGS$(1)-T-$(2)-H-$(3)-$(4) := \ check-stage$(1)-T-$(2)-H-$(3)-$(4)-exec: $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)) +ifeq ($$(CTEST_DISABLE_$(4)),) + $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \ $$(TEST_SREQ$(1)_T_$(2)_H_$(3)) \ $$(CTEST_DEPS_$(4)_$(1)-T-$(2)-H-$(3)) @@ -386,9 +402,20 @@ $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \ --logfile $$(call TEST_LOG_FILE,$(1),$(2),$(3),$(4)) \ && touch $$@ +else + +$$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \ + $$(TEST_SREQ$(1)_T_$(2)_H_$(3)) \ + $$(CTEST_DEPS_$(4)_$(1)-T-$(2)-H-$(3)) + @$$(call E, run $(4): $$<) + @$$(call E, warning: tests disabled: $$(CTEST_DISABLE_$(4))) + touch $$@ + +endif + endef -CTEST_NAMES = rpass rpass-full rfail cfail bench perf +CTEST_NAMES = rpass rpass-full rfail cfail bench perf debuginfo $(foreach host,$(CFG_TARGET_TRIPLES), \ $(eval $(foreach target,$(CFG_TARGET_TRIPLES), \ @@ -496,6 +523,7 @@ TEST_GROUPS = \ cfail \ bench \ perf \ + debuginfo \ doc \ $(foreach docname,$(DOC_TEST_NAMES),$(docname)) \ pretty \ diff --git a/src/compiletest/common.rs b/src/compiletest/common.rs index 9d4becd63d390..679f9ab93bf08 100644 --- a/src/compiletest/common.rs +++ b/src/compiletest/common.rs @@ -1,5 +1,5 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at +// Copyright 2012-2013 The Rust Project Developers. See the +// COPYRIGHT file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 mode { ~"run-fail" => mode_run_fail, ~"run-pass" => mode_run_pass, ~"pretty" => mode_pretty, + ~"debug-info" => mode_debug_info, _ => die!(~"invalid mode") } } @@ -140,7 +142,8 @@ pub fn mode_str(mode: mode) -> ~str { mode_compile_fail => ~"compile-fail", mode_run_fail => ~"run-fail", mode_run_pass => ~"run-pass", - mode_pretty => ~"pretty" + mode_pretty => ~"pretty", + mode_debug_info => ~"debug-info", } } diff --git a/src/compiletest/header.rs b/src/compiletest/header.rs index 0b9d67426ae35..5c33c66209a37 100644 --- a/src/compiletest/header.rs +++ b/src/compiletest/header.rs @@ -1,5 +1,5 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at +// Copyright 2012-2013 The Rust Project Developers. See the +// COPYRIGHT file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 TestProps { let mut exec_env = ~[]; let mut compile_flags = None; let mut pp_exact = None; + let mut debugger_cmds = ~[]; + let mut check_lines = ~[]; for iter_header(testfile) |ln| { match parse_error_pattern(ln) { Some(ep) => error_patterns.push(ep), @@ -59,13 +65,25 @@ pub fn load_props(testfile: &Path) -> TestProps { do parse_exec_env(ln).iter |ee| { exec_env.push(*ee); } + + match parse_debugger_cmd(ln) { + Some(dc) => debugger_cmds.push(dc), + None => () + }; + + match parse_check_line(ln) { + Some(cl) => check_lines.push(cl), + None => () + }; }; return TestProps { error_patterns: error_patterns, compile_flags: compile_flags, pp_exact: pp_exact, aux_builds: aux_builds, - exec_env: exec_env + exec_env: exec_env, + debugger_cmds: debugger_cmds, + check_lines: check_lines }; } @@ -112,6 +130,14 @@ fn parse_compile_flags(line: ~str) -> Option<~str> { parse_name_value_directive(line, ~"compile-flags") } +fn parse_debugger_cmd(line: ~str) -> Option<~str> { + parse_name_value_directive(line, ~"debugger") +} + +fn parse_check_line(line: ~str) -> Option<~str> { + parse_name_value_directive(line, ~"check") +} + fn parse_exec_env(line: ~str) -> Option<(~str, ~str)> { do parse_name_value_directive(line, ~"exec-env").map |nv| { // nv is either FOO or FOO=BAR diff --git a/src/compiletest/runtest.rs b/src/compiletest/runtest.rs index a71b8a360a246..0f8c8761c427c 100644 --- a/src/compiletest/runtest.rs +++ b/src/compiletest/runtest.rs @@ -1,5 +1,5 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at +// Copyright 2012-2013 The Rust Project Developers. See the +// COPYRIGHT file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 run_cfail_test(config, props, &testfile), mode_run_fail => run_rfail_test(config, props, &testfile), mode_run_pass => run_rpass_test(config, props, &testfile), - mode_pretty => run_pretty_test(config, props, &testfile) + mode_pretty => run_pretty_test(config, props, &testfile), + mode_debug_info => run_debuginfo_test(config, props, &testfile) } } @@ -224,6 +226,55 @@ actual:\n\ } } +fn run_debuginfo_test(config: config, props: TestProps, testfile: &Path) { + // compile test file (it shoud have 'compile-flags:-g' in the header) + let mut ProcRes = compile_test(config, props, testfile); + if ProcRes.status != 0 { + fatal_ProcRes(~"compilation failed!", ProcRes); + } + + // write debugger script + let script_str = str::append(str::connect(props.debugger_cmds, "\n"), + ~"\nquit\n"); + debug!("script_str = %s", script_str); + dump_output_file(config, testfile, script_str, ~"debugger.script"); + + // run debugger script with gdb + #[cfg(windows)] + fn debugger() -> ~str { ~"gdb.exe" } + #[cfg(unix)] + fn debugger() -> ~str { ~"gdb" } + let debugger_script = make_out_name(config, testfile, ~"debugger.script"); + let debugger_opts = ~[~"-quiet", ~"-batch", ~"-nx", + ~"-command=" + debugger_script.to_str(), + make_exe_name(config, testfile).to_str()]; + let ProcArgs = ProcArgs {prog: debugger(), args: debugger_opts}; + ProcRes = compose_and_run(config, testfile, ProcArgs, ~[], ~"", None); + if ProcRes.status != 0 { + fatal(~"gdb failed to execute"); + } + + let num_check_lines = vec::len(props.check_lines); + if num_check_lines > 0 { + // check if each line in props.check_lines appears in the + // output (in order) + let mut i = 0u; + for str::lines(ProcRes.stdout).each |line| { + if props.check_lines[i].trim() == line.trim() { + i += 1u; + } + if i == num_check_lines { + // all lines checked + break; + } + } + if i != num_check_lines { + fatal(fmt!("line not found in debugger output: %s", + props.check_lines[i])); + } + } +} + fn check_error_patterns(props: TestProps, testfile: &Path, ProcRes: ProcRes) { diff --git a/src/etc/emacs/rust-mode.el b/src/etc/emacs/rust-mode.el index d9ee135ac47b8..ef98fa669e346 100644 --- a/src/etc/emacs/rust-mode.el +++ b/src/etc/emacs/rust-mode.el @@ -7,6 +7,7 @@ (require 'cm-mode) (require 'cc-mode) +(eval-when-compile (require 'cl)) (defun rust-electric-brace (arg) (interactive "*P") diff --git a/src/etc/gyp-uv b/src/etc/gyp-uv deleted file mode 100755 index e64ed4f30597c..0000000000000 --- a/src/etc/gyp-uv +++ /dev/null @@ -1,62 +0,0 @@ -#!/bin/sh - -# This script generates rust compatible makefiles from libuv. When upgrading -# libuv, do: -# -# cd $RUST_DIR -# cd src/libuv -# git checkout master -# git pull -# svn co http://gyp.googlecode.com/svn/trunk build/gyp -# cd ../.. -# rm -r mk/libuv -# ./src/etc/gyp-uv -# -# Note: you must not run gyp on windows. It will get the backslashes -# incorrect in its rules, and not work. - -set -e - -cd `dirname $0` -cd ../.. - -GYPFILE=src/libuv/uv.gyp -INCLUDES="-I src/libuv/common.gypi" - -for ARCH in ia32 x86_64 -do - ARGS="$GYPFILE \ - $INCLUDES \ - --depth . \ - -Dcomponent=static_library \ - -Dlibrary=static_library \ - -Dtarget_arch=$ARCH" - - ./src/libuv/build/gyp/gyp $ARGS \ - -f make-mac \ - --generator-output mk/libuv/$ARCH/mac \ - -DOS=mac - - ./src/libuv/build/gyp/gyp $ARGS \ - -f make-linux \ - --generator-output mk/libuv/$ARCH/unix \ - -DOS=linux - - ./src/libuv/build/gyp/gyp $ARGS \ - -f make-linux \ - --generator-output mk/libuv/$ARCH/win \ - -DOS=win - -done - -# On Mac, GYP hardcodes a -arch i386 into the output. Fix that. -sed -i \ - -e 's/-arch i386/-arch x86_64/' \ - mk/libuv/x86_64/mac/src/libuv/*.mk - -MKFILES=$(find mk/libuv -name \*.mk -o -name Makefile) - -# Comment out the gyp auto regeneration -perl -i -p -e 's@^(Makefile:.*)@#\1@go' $MKFILES -perl -i -p -e 's@^(Makefile:.*)@#\1@go' $MKFILES -perl -i -p -e 's@(.*regen_makefile.*)@#\1@go' $MKFILES diff --git a/src/libcargo/cargo.rc b/src/libcargo/cargo.rc index 79bf85021d88b..db976b580c7f1 100644 --- a/src/libcargo/cargo.rc +++ b/src/libcargo/cargo.rc @@ -730,7 +730,7 @@ pub fn configure(opts: Options) -> Cargo { need_dir(&c.libdir); need_dir(&c.bindir); - for sources.each_key_ref |&k| { + for sources.each_key |&k| { let mut s = sources.get(&k); load_source_packages(&c, s); sources.insert(k, s); @@ -748,7 +748,7 @@ pub fn configure(opts: Options) -> Cargo { } pub fn for_each_package(c: &Cargo, b: fn(s: @Source, p: &Package)) { - for c.sources.each_value_ref |&v| { + for c.sources.each_value |&v| { for v.packages.each |p| { b(v, p); } @@ -1155,7 +1155,7 @@ pub fn cmd_install(c: &mut Cargo) { } pub fn sync(c: &Cargo) { - for c.sources.each_key_ref |&k| { + for c.sources.each_key |&k| { let mut s = c.sources.get(&k); sync_one(c, s); c.sources.insert(k, s); @@ -1569,7 +1569,7 @@ pub fn cmd_list(c: &Cargo) { } } } else { - for c.sources.each_value_ref |&v| { + for c.sources.each_value |&v| { print_source(v); } } @@ -1636,7 +1636,7 @@ pub fn dump_sources(c: &Cargo) { result::Ok(writer) => { let mut hash = ~LinearMap::new(); - for c.sources.each_ref |&k, &v| { + for c.sources.each |&k, &v| { let mut chash = ~LinearMap::new(); chash.insert(~"url", json::String(v.url)); @@ -1675,7 +1675,7 @@ pub fn copy_warn(srcfile: &Path, destfile: &Path) { pub fn cmd_sources(c: &Cargo) { if vec::len(c.opts.free) < 3u { - for c.sources.each_value_ref |&v| { + for c.sources.each_value |&v| { info(fmt!("%s (%s) via %s", v.name, v.url, v.method)); } @@ -1686,7 +1686,7 @@ pub fn cmd_sources(c: &Cargo) { match action { ~"clear" => { - for c.sources.each_key_ref |&k| { + for c.sources.each_key |&k| { c.sources.remove(&k); } @@ -1706,7 +1706,7 @@ pub fn cmd_sources(c: &Cargo) { return; } - if c.sources.contains_key_ref(&name) { + if c.sources.contains_key(&name) { error(fmt!("source already exists: %s", name)); } else { c.sources.insert(name, @Source { @@ -1733,7 +1733,7 @@ pub fn cmd_sources(c: &Cargo) { return; } - if c.sources.contains_key_ref(&name) { + if c.sources.contains_key(&name) { c.sources.remove(&name); info(fmt!("removed source: %s", name)); } else { diff --git a/src/libcore/core.rc b/src/libcore/core.rc index 64b480818b1e7..7bf64d5b6684b 100644 --- a/src/libcore/core.rc +++ b/src/libcore/core.rc @@ -199,7 +199,7 @@ pub use vec::{OwnedVector, OwnedCopyableVector}; pub use iter::{BaseIter, ExtendedIter, EqIter, CopyableIter}; pub use iter::{CopyableOrderedIter, CopyableNonstrictIter, Times}; -pub use num::Num; +pub use num::{Num, NumCast}; pub use ptr::Ptr; pub use to_str::ToStr; pub use clone::Clone; diff --git a/src/libcore/hashmap.rs b/src/libcore/hashmap.rs index a69cf4611bb7f..f8793f7e2aeae 100644 --- a/src/libcore/hashmap.rs +++ b/src/libcore/hashmap.rs @@ -108,19 +108,17 @@ pub mod linear { } #[inline(always)] - pure fn bucket_for_key(&self, buckets: &[Option>], - k: &K) -> SearchResult { + pure fn bucket_for_key(&self, k: &K) -> SearchResult { let hash = k.hash_keyed(self.k0, self.k1) as uint; - self.bucket_for_key_with_hash(buckets, hash, k) + self.bucket_for_key_with_hash(hash, k) } #[inline(always)] pure fn bucket_for_key_with_hash(&self, - buckets: &[Option>], hash: uint, k: &K) -> SearchResult { let _ = for self.bucket_sequence(hash) |i| { - match buckets[i] { + match self.buckets[i] { Some(ref bkt) => if bkt.hash == hash && *k == bkt.key { return FoundEntry(i); }, @@ -157,11 +155,19 @@ pub mod linear { } } + #[inline(always)] + pure fn value_for_bucket(&self, idx: uint) -> &self/V { + match self.buckets[idx] { + Some(ref bkt) => &bkt.value, + None => die!(~"LinearMap::find: internal logic error"), + } + } + /// Inserts the key value pair into the buckets. /// Assumes that there will be a bucket. /// True if there was no previous entry with that key fn insert_internal(&mut self, hash: uint, k: K, v: V) -> bool { - match self.bucket_for_key_with_hash(self.buckets, hash, &k) { + match self.bucket_for_key_with_hash(hash, &k) { TableFull => { die!(~"Internal logic error"); } FoundHole(idx) => { debug!("insert fresh (%?->%?) at idx %?, hash %?", @@ -196,8 +202,7 @@ pub mod linear { // // I found this explanation elucidating: // http://www.maths.lse.ac.uk/Courses/MA407/del-hash.pdf - let mut idx = match self.bucket_for_key_with_hash(self.buckets, - hash, k) { + let mut idx = match self.bucket_for_key_with_hash(hash, k) { TableFull | FoundHole(_) => return None, FoundEntry(idx) => idx }; @@ -273,7 +278,7 @@ pub mod linear { impl LinearMap: Map { /// Return true if the map contains a value for the specified key pure fn contains_key(&self, k: &K) -> bool { - match self.bucket_for_key(self.buckets, k) { + match self.bucket_for_key(k) { FoundEntry(_) => {true} TableFull | FoundHole(_) => {false} } @@ -291,20 +296,9 @@ pub mod linear { /// Return the value corresponding to the key in the map pure fn find(&self, k: &K) -> Option<&self/V> { - match self.bucket_for_key(self.buckets, k) { - FoundEntry(idx) => { - match self.buckets[idx] { - Some(ref bkt) => { - Some(&bkt.value) - } - None => { - die!(~"LinearMap::find: internal logic error") - } - } - } - TableFull | FoundHole(_) => { - None - } + match self.bucket_for_key(k) { + FoundEntry(idx) => Some(self.value_for_bucket(idx)), + TableFull | FoundHole(_) => None, } } @@ -364,6 +358,67 @@ pub mod linear { old_value } + /// Return the value corresponding to the key in the map, or insert + /// and return the value if it doesn't exist. + fn find_or_insert(&mut self, k: K, v: V) -> &self/V { + if self.size >= self.resize_at { + // n.b.: We could also do this after searching, so + // that we do not resize if this call to insert is + // simply going to update a key in place. My sense + // though is that it's worse to have to search through + // buckets to find the right spot twice than to just + // resize in this corner case. + self.expand(); + } + + let hash = k.hash_keyed(self.k0, self.k1) as uint; + let idx = match self.bucket_for_key_with_hash(hash, &k) { + TableFull => die!(~"Internal logic error"), + FoundEntry(idx) => idx, + FoundHole(idx) => { + self.buckets[idx] = Some(Bucket{hash: hash, key: k, + value: v}); + self.size += 1; + idx + }, + }; + + unsafe { // FIXME(#4903)---requires flow-sensitive borrow checker + ::cast::transmute_region(self.value_for_bucket(idx)) + } + } + + /// Return the value corresponding to the key in the map, or create, + /// insert, and return a new value if it doesn't exist. + fn find_or_insert_with(&mut self, k: K, f: fn(&K) -> V) -> &self/V { + if self.size >= self.resize_at { + // n.b.: We could also do this after searching, so + // that we do not resize if this call to insert is + // simply going to update a key in place. My sense + // though is that it's worse to have to search through + // buckets to find the right spot twice than to just + // resize in this corner case. + self.expand(); + } + + let hash = k.hash_keyed(self.k0, self.k1) as uint; + let idx = match self.bucket_for_key_with_hash(hash, &k) { + TableFull => die!(~"Internal logic error"), + FoundEntry(idx) => idx, + FoundHole(idx) => { + let v = f(&k); + self.buckets[idx] = Some(Bucket{hash: hash, key: k, + value: v}); + self.size += 1; + idx + }, + }; + + unsafe { // FIXME(#4903)---requires flow-sensitive borrow checker + ::cast::transmute_region(self.value_for_bucket(idx)) + } + } + fn consume(&mut self, f: fn(K, V)) { let mut buckets = ~[]; self.buckets <-> buckets; @@ -521,7 +576,7 @@ mod test_map { use uint; #[test] - pub fn inserts() { + pub fn test_insert() { let mut m = LinearMap::new(); assert m.insert(1, 2); assert m.insert(2, 4); @@ -530,7 +585,7 @@ mod test_map { } #[test] - pub fn overwrite() { + pub fn test_insert_overwrite() { let mut m = LinearMap::new(); assert m.insert(1, 2); assert *m.get(&1) == 2; @@ -539,7 +594,7 @@ mod test_map { } #[test] - pub fn conflicts() { + pub fn test_insert_conflicts() { let mut m = linear::linear_map_with_capacity(4); assert m.insert(1, 2); assert m.insert(5, 3); @@ -550,7 +605,7 @@ mod test_map { } #[test] - pub fn conflict_remove() { + pub fn test_conflict_remove() { let mut m = linear::linear_map_with_capacity(4); assert m.insert(1, 2); assert m.insert(5, 3); @@ -561,7 +616,7 @@ mod test_map { } #[test] - pub fn empty() { + pub fn test_is_empty() { let mut m = linear::linear_map_with_capacity(4); assert m.insert(1, 2); assert !m.is_empty(); @@ -570,7 +625,7 @@ mod test_map { } #[test] - pub fn pops() { + pub fn test_pop() { let mut m = LinearMap::new(); m.insert(1, 2); assert m.pop(&1) == Some(2); @@ -578,7 +633,7 @@ mod test_map { } #[test] - pub fn swaps() { + pub fn test_swap() { let mut m = LinearMap::new(); assert m.swap(1, 2) == None; assert m.swap(1, 3) == Some(2); @@ -586,7 +641,21 @@ mod test_map { } #[test] - pub fn consumes() { + pub fn test_find_or_insert() { + let mut m = LinearMap::new::(); + assert m.find_or_insert(1, 2) == &2; + assert m.find_or_insert(1, 3) == &2; + } + + #[test] + pub fn test_find_or_insert_with() { + let mut m = LinearMap::new::(); + assert m.find_or_insert_with(1, |_| 2) == &2; + assert m.find_or_insert_with(1, |_| 3) == &2; + } + + #[test] + pub fn test_consume() { let mut m = LinearMap::new(); assert m.insert(1, 2); assert m.insert(2, 3); @@ -601,7 +670,7 @@ mod test_map { } #[test] - pub fn iterate() { + pub fn test_iterate() { let mut m = linear::linear_map_with_capacity(4); for uint::range(0, 32) |i| { assert m.insert(i, i*2); @@ -615,7 +684,7 @@ mod test_map { } #[test] - pub fn find() { + pub fn test_find() { let mut m = LinearMap::new(); assert m.find(&1).is_none(); m.insert(1, 2); diff --git a/src/libcore/num/f32.rs b/src/libcore/num/f32.rs index 738445b5cd946..6bea9e81197d3 100644 --- a/src/libcore/num/f32.rs +++ b/src/libcore/num/f32.rs @@ -14,6 +14,7 @@ use cmath; use cmp; use libc::{c_float, c_int}; use num; +use num::NumCast; use option::Option; use from_str; use to_str; @@ -283,11 +284,6 @@ impl f32: num::Num { pure fn modulo(&self, other: &f32) -> f32 { return *self % *other; } #[inline(always)] pure fn neg(&self) -> f32 { return -*self; } - - #[inline(always)] - pure fn to_int(&self) -> int { return *self as int; } - #[inline(always)] - static pure fn from_int(n: int) -> f32 { return n as f32; } } impl f32: num::Zero { @@ -300,6 +296,30 @@ impl f32: num::One { static pure fn one() -> f32 { 1.0 } } +pub impl f32: NumCast { + /** + * Cast `n` to an `f32` + */ + #[inline(always)] + static pure fn from(n: N) -> f32 { n.to_f32() } + + #[inline(always)] pure fn to_u8(&self) -> u8 { *self as u8 } + #[inline(always)] pure fn to_u16(&self) -> u16 { *self as u16 } + #[inline(always)] pure fn to_u32(&self) -> u32 { *self as u32 } + #[inline(always)] pure fn to_u64(&self) -> u64 { *self as u64 } + #[inline(always)] pure fn to_uint(&self) -> uint { *self as uint } + + #[inline(always)] pure fn to_i8(&self) -> i8 { *self as i8 } + #[inline(always)] pure fn to_i16(&self) -> i16 { *self as i16 } + #[inline(always)] pure fn to_i32(&self) -> i32 { *self as i32 } + #[inline(always)] pure fn to_i64(&self) -> i64 { *self as i64 } + #[inline(always)] pure fn to_int(&self) -> int { *self as int } + + #[inline(always)] pure fn to_f32(&self) -> f32 { *self } + #[inline(always)] pure fn to_f64(&self) -> f64 { *self as f64 } + #[inline(always)] pure fn to_float(&self) -> float { *self as float } +} + #[abi="rust-intrinsic"] pub extern { fn floorf32(val: f32) -> f32; @@ -545,6 +565,63 @@ impl f32: num::FromStrRadix { } } +#[test] +pub fn test_num() { + let ten: f32 = num::cast(10); + let two: f32 = num::cast(2); + + assert (ten.add(&two) == num::cast(12)); + assert (ten.sub(&two) == num::cast(8)); + assert (ten.mul(&two) == num::cast(20)); + assert (ten.div(&two) == num::cast(5)); + assert (ten.modulo(&two) == num::cast(0)); +} + +#[test] +fn test_numcast() { + assert (20u == 20f32.to_uint()); + assert (20u8 == 20f32.to_u8()); + assert (20u16 == 20f32.to_u16()); + assert (20u32 == 20f32.to_u32()); + assert (20u64 == 20f32.to_u64()); + assert (20i == 20f32.to_int()); + assert (20i8 == 20f32.to_i8()); + assert (20i16 == 20f32.to_i16()); + assert (20i32 == 20f32.to_i32()); + assert (20i64 == 20f32.to_i64()); + assert (20f == 20f32.to_float()); + assert (20f32 == 20f32.to_f32()); + assert (20f64 == 20f32.to_f64()); + + assert (20f32 == NumCast::from(20u)); + assert (20f32 == NumCast::from(20u8)); + assert (20f32 == NumCast::from(20u16)); + assert (20f32 == NumCast::from(20u32)); + assert (20f32 == NumCast::from(20u64)); + assert (20f32 == NumCast::from(20i)); + assert (20f32 == NumCast::from(20i8)); + assert (20f32 == NumCast::from(20i16)); + assert (20f32 == NumCast::from(20i32)); + assert (20f32 == NumCast::from(20i64)); + assert (20f32 == NumCast::from(20f)); + assert (20f32 == NumCast::from(20f32)); + assert (20f32 == NumCast::from(20f64)); + + assert (20f32 == num::cast(20u)); + assert (20f32 == num::cast(20u8)); + assert (20f32 == num::cast(20u16)); + assert (20f32 == num::cast(20u32)); + assert (20f32 == num::cast(20u64)); + assert (20f32 == num::cast(20i)); + assert (20f32 == num::cast(20i8)); + assert (20f32 == num::cast(20i16)); + assert (20f32 == num::cast(20i32)); + assert (20f32 == num::cast(20i64)); + assert (20f32 == num::cast(20f)); + assert (20f32 == num::cast(20f32)); + assert (20f32 == num::cast(20f64)); +} + // // Local Variables: // mode: rust diff --git a/src/libcore/num/f64.rs b/src/libcore/num/f64.rs index f09d874803c3d..7cde210265324 100644 --- a/src/libcore/num/f64.rs +++ b/src/libcore/num/f64.rs @@ -15,6 +15,7 @@ use cmp; use libc::{c_double, c_int}; use libc; use num; +use num::NumCast; use option::Option; use to_str; use from_str; @@ -307,11 +308,30 @@ impl f64: num::Num { pure fn modulo(&self, other: &f64) -> f64 { return *self % *other; } #[inline(always)] pure fn neg(&self) -> f64 { return -*self; } +} +pub impl f64: NumCast { + /** + * Cast `n` to an `f64` + */ #[inline(always)] - pure fn to_int(&self) -> int { return *self as int; } - #[inline(always)] - static pure fn from_int(n: int) -> f64 { return n as f64; } + static pure fn from(n: N) -> f64 { n.to_f64() } + + #[inline(always)] pure fn to_u8(&self) -> u8 { *self as u8 } + #[inline(always)] pure fn to_u16(&self) -> u16 { *self as u16 } + #[inline(always)] pure fn to_u32(&self) -> u32 { *self as u32 } + #[inline(always)] pure fn to_u64(&self) -> u64 { *self as u64 } + #[inline(always)] pure fn to_uint(&self) -> uint { *self as uint } + + #[inline(always)] pure fn to_i8(&self) -> i8 { *self as i8 } + #[inline(always)] pure fn to_i16(&self) -> i16 { *self as i16 } + #[inline(always)] pure fn to_i32(&self) -> i32 { *self as i32 } + #[inline(always)] pure fn to_i64(&self) -> i64 { *self as i64 } + #[inline(always)] pure fn to_int(&self) -> int { *self as int } + + #[inline(always)] pure fn to_f32(&self) -> f32 { *self as f32 } + #[inline(always)] pure fn to_f64(&self) -> f64 { *self } + #[inline(always)] pure fn to_float(&self) -> float { *self as float } } impl f64: num::Zero { @@ -569,6 +589,63 @@ impl f64: num::FromStrRadix { } } +#[test] +pub fn test_num() { + let ten: f64 = num::cast(10); + let two: f64 = num::cast(2); + + assert (ten.add(&two) == num::cast(12)); + assert (ten.sub(&two) == num::cast(8)); + assert (ten.mul(&two) == num::cast(20)); + assert (ten.div(&two) == num::cast(5)); + assert (ten.modulo(&two) == num::cast(0)); +} + +#[test] +fn test_numcast() { + assert (20u == 20f64.to_uint()); + assert (20u8 == 20f64.to_u8()); + assert (20u16 == 20f64.to_u16()); + assert (20u32 == 20f64.to_u32()); + assert (20u64 == 20f64.to_u64()); + assert (20i == 20f64.to_int()); + assert (20i8 == 20f64.to_i8()); + assert (20i16 == 20f64.to_i16()); + assert (20i32 == 20f64.to_i32()); + assert (20i64 == 20f64.to_i64()); + assert (20f == 20f64.to_float()); + assert (20f32 == 20f64.to_f32()); + assert (20f64 == 20f64.to_f64()); + + assert (20f64 == NumCast::from(20u)); + assert (20f64 == NumCast::from(20u8)); + assert (20f64 == NumCast::from(20u16)); + assert (20f64 == NumCast::from(20u32)); + assert (20f64 == NumCast::from(20u64)); + assert (20f64 == NumCast::from(20i)); + assert (20f64 == NumCast::from(20i8)); + assert (20f64 == NumCast::from(20i16)); + assert (20f64 == NumCast::from(20i32)); + assert (20f64 == NumCast::from(20i64)); + assert (20f64 == NumCast::from(20f)); + assert (20f64 == NumCast::from(20f32)); + assert (20f64 == NumCast::from(20f64)); + + assert (20f64 == num::cast(20u)); + assert (20f64 == num::cast(20u8)); + assert (20f64 == num::cast(20u16)); + assert (20f64 == num::cast(20u32)); + assert (20f64 == num::cast(20u64)); + assert (20f64 == num::cast(20i)); + assert (20f64 == num::cast(20i8)); + assert (20f64 == num::cast(20i16)); + assert (20f64 == num::cast(20i32)); + assert (20f64 == num::cast(20i64)); + assert (20f64 == num::cast(20f)); + assert (20f64 == num::cast(20f32)); + assert (20f64 == num::cast(20f64)); +} + // // Local Variables: // mode: rust diff --git a/src/libcore/num/float.rs b/src/libcore/num/float.rs index f5ae05ebffb4e..74bf50737f563 100644 --- a/src/libcore/num/float.rs +++ b/src/libcore/num/float.rs @@ -26,7 +26,7 @@ use cmp::{Eq, Ord}; use cmp; use f64; use num; -use num::Num::from_int; +use num::NumCast; use option::{None, Option, Some}; use str; use uint; @@ -417,11 +417,6 @@ impl float: num::Num { pure fn modulo(&self, other: &float) -> float { return *self % *other; } #[inline(always)] pure fn neg(&self) -> float { return -*self; } - - #[inline(always)] - pure fn to_int(&self) -> int { return *self as int; } - #[inline(always)] - static pure fn from_int(&self, n: int) -> float { return n as float; } } impl float: num::Zero { @@ -434,6 +429,30 @@ impl float: num::One { static pure fn one() -> float { 1.0 } } +pub impl float: NumCast { + /** + * Cast `n` to a `float` + */ + #[inline(always)] + static pure fn from(n: N) -> float { n.to_float() } + + #[inline(always)] pure fn to_u8(&self) -> u8 { *self as u8 } + #[inline(always)] pure fn to_u16(&self) -> u16 { *self as u16 } + #[inline(always)] pure fn to_u32(&self) -> u32 { *self as u32 } + #[inline(always)] pure fn to_u64(&self) -> u64 { *self as u64 } + #[inline(always)] pure fn to_uint(&self) -> uint { *self as uint } + + #[inline(always)] pure fn to_i8(&self) -> i8 { *self as i8 } + #[inline(always)] pure fn to_i16(&self) -> i16 { *self as i16 } + #[inline(always)] pure fn to_i32(&self) -> i32 { *self as i32 } + #[inline(always)] pure fn to_i64(&self) -> i64 { *self as i64 } + #[inline(always)] pure fn to_int(&self) -> int { *self as int } + + #[inline(always)] pure fn to_f32(&self) -> f32 { *self as f32 } + #[inline(always)] pure fn to_f64(&self) -> f64 { *self as f64 } + #[inline(always)] pure fn to_float(&self) -> float { *self } +} + impl float: num::Round { #[inline(always)] pure fn round(&self, mode: num::RoundMode) -> float { @@ -657,21 +676,60 @@ pub fn test_round() { } #[test] -pub fn test_traits() { - fn test(ten: &U) { - assert (ten.to_int() == 10); - - let two: U = from_int(2); - assert (two.to_int() == 2); - - assert (ten.add(&two) == from_int(12)); - assert (ten.sub(&two) == from_int(8)); - assert (ten.mul(&two) == from_int(20)); - assert (ten.div(&two) == from_int(5)); - assert (ten.modulo(&two) == from_int(0)); - } +pub fn test_num() { + let ten: float = num::cast(10); + let two: float = num::cast(2); - test(&10.0); + assert (ten.add(&two) == num::cast(12)); + assert (ten.sub(&two) == num::cast(8)); + assert (ten.mul(&two) == num::cast(20)); + assert (ten.div(&two) == num::cast(5)); + assert (ten.modulo(&two) == num::cast(0)); +} + +#[test] +fn test_numcast() { + assert (20u == 20f.to_uint()); + assert (20u8 == 20f.to_u8()); + assert (20u16 == 20f.to_u16()); + assert (20u32 == 20f.to_u32()); + assert (20u64 == 20f.to_u64()); + assert (20i == 20f.to_int()); + assert (20i8 == 20f.to_i8()); + assert (20i16 == 20f.to_i16()); + assert (20i32 == 20f.to_i32()); + assert (20i64 == 20f.to_i64()); + assert (20f == 20f.to_float()); + assert (20f32 == 20f.to_f32()); + assert (20f64 == 20f.to_f64()); + + assert (20f == NumCast::from(20u)); + assert (20f == NumCast::from(20u8)); + assert (20f == NumCast::from(20u16)); + assert (20f == NumCast::from(20u32)); + assert (20f == NumCast::from(20u64)); + assert (20f == NumCast::from(20i)); + assert (20f == NumCast::from(20i8)); + assert (20f == NumCast::from(20i16)); + assert (20f == NumCast::from(20i32)); + assert (20f == NumCast::from(20i64)); + assert (20f == NumCast::from(20f)); + assert (20f == NumCast::from(20f32)); + assert (20f == NumCast::from(20f64)); + + assert (20f == num::cast(20u)); + assert (20f == num::cast(20u8)); + assert (20f == num::cast(20u16)); + assert (20f == num::cast(20u32)); + assert (20f == num::cast(20u64)); + assert (20f == num::cast(20i)); + assert (20f == num::cast(20i8)); + assert (20f == num::cast(20i16)); + assert (20f == num::cast(20i32)); + assert (20f == num::cast(20i64)); + assert (20f == num::cast(20f)); + assert (20f == num::cast(20f32)); + assert (20f == num::cast(20f64)); } diff --git a/src/libcore/num/int-template.rs b/src/libcore/num/int-template.rs index 1856781b1d779..b616a08246b67 100644 --- a/src/libcore/num/int-template.rs +++ b/src/libcore/num/int-template.rs @@ -17,7 +17,6 @@ use to_str::ToStr; use from_str::FromStr; use num::{ToStrRadix, FromStrRadix}; use num; -use num::Num::from_int; use prelude::*; use str; use uint; @@ -184,11 +183,6 @@ impl T: num::Num { pure fn modulo(&self, other: &T) -> T { return *self % *other; } #[inline(always)] pure fn neg(&self) -> T { return -*self; } - - #[inline(always)] - pure fn to_int(&self) -> int { return *self as int; } - #[inline(always)] - static pure fn from_int(n: int) -> T { return n as T; } } impl T: num::Zero { @@ -411,22 +405,15 @@ fn test_int_from_str_overflow() { } #[test] -fn test_interfaces() { - fn test(ten: U) { - assert (ten.to_int() == 10); - - let two: U = from_int(2); - assert (two.to_int() == 2); - - assert (ten.add(&two) == from_int(12)); - assert (ten.sub(&two) == from_int(8)); - assert (ten.mul(&two) == from_int(20)); - assert (ten.div(&two) == from_int(5)); - assert (ten.modulo(&two) == from_int(0)); - assert (ten.neg() == from_int(-10)); - } - - test(10 as T); +pub fn test_num() { + let ten: T = num::cast(10); + let two: T = num::cast(2); + + assert (ten.add(&two) == num::cast(12)); + assert (ten.sub(&two) == num::cast(8)); + assert (ten.mul(&two) == num::cast(20)); + assert (ten.div(&two) == num::cast(5)); + assert (ten.modulo(&two) == num::cast(0)); } #[test] diff --git a/src/libcore/num/int-template/i16.rs b/src/libcore/num/int-template/i16.rs index da60b567f665a..572cce92ea1d7 100644 --- a/src/libcore/num/int-template/i16.rs +++ b/src/libcore/num/int-template/i16.rs @@ -10,7 +10,78 @@ //! Operations and constants for `i16` +use num::NumCast; + mod inst { pub type T = i16; pub const bits: uint = ::u16::bits; } + +pub impl i16: NumCast { + /** + * Cast `n` to a `i16` + */ + #[inline(always)] + static pure fn from(n: N) -> i16 { n.to_i16() } + + #[inline(always)] pure fn to_u8(&self) -> u8 { *self as u8 } + #[inline(always)] pure fn to_u16(&self) -> u16 { *self as u16 } + #[inline(always)] pure fn to_u32(&self) -> u32 { *self as u32 } + #[inline(always)] pure fn to_u64(&self) -> u64 { *self as u64 } + #[inline(always)] pure fn to_uint(&self) -> uint { *self as uint } + + #[inline(always)] pure fn to_i8(&self) -> i8 { *self as i8 } + #[inline(always)] pure fn to_i16(&self) -> i16 { *self } + #[inline(always)] pure fn to_i32(&self) -> i32 { *self as i32 } + #[inline(always)] pure fn to_i64(&self) -> i64 { *self as i64 } + #[inline(always)] pure fn to_int(&self) -> int { *self as int } + + #[inline(always)] pure fn to_f32(&self) -> f32 { *self as f32 } + #[inline(always)] pure fn to_f64(&self) -> f64 { *self as f64 } + #[inline(always)] pure fn to_float(&self) -> float { *self as float } +} + +#[test] +fn test_numcast() { + assert (20u == 20i16.to_uint()); + assert (20u8 == 20i16.to_u8()); + assert (20u16 == 20i16.to_u16()); + assert (20u32 == 20i16.to_u32()); + assert (20u64 == 20i16.to_u64()); + assert (20i == 20i16.to_int()); + assert (20i8 == 20i16.to_i8()); + assert (20i16 == 20i16.to_i16()); + assert (20i32 == 20i16.to_i32()); + assert (20i64 == 20i16.to_i64()); + assert (20f == 20i16.to_float()); + assert (20f32 == 20i16.to_f32()); + assert (20f64 == 20i16.to_f64()); + + assert (20i16 == NumCast::from(20u)); + assert (20i16 == NumCast::from(20u8)); + assert (20i16 == NumCast::from(20u16)); + assert (20i16 == NumCast::from(20u32)); + assert (20i16 == NumCast::from(20u64)); + assert (20i16 == NumCast::from(20i)); + assert (20i16 == NumCast::from(20i8)); + assert (20i16 == NumCast::from(20i16)); + assert (20i16 == NumCast::from(20i32)); + assert (20i16 == NumCast::from(20i64)); + assert (20i16 == NumCast::from(20f)); + assert (20i16 == NumCast::from(20f32)); + assert (20i16 == NumCast::from(20f64)); + + assert (20i16 == num::cast(20u)); + assert (20i16 == num::cast(20u8)); + assert (20i16 == num::cast(20u16)); + assert (20i16 == num::cast(20u32)); + assert (20i16 == num::cast(20u64)); + assert (20i16 == num::cast(20i)); + assert (20i16 == num::cast(20i8)); + assert (20i16 == num::cast(20i16)); + assert (20i16 == num::cast(20i32)); + assert (20i16 == num::cast(20i64)); + assert (20i16 == num::cast(20f)); + assert (20i16 == num::cast(20f32)); + assert (20i16 == num::cast(20f64)); +} \ No newline at end of file diff --git a/src/libcore/num/int-template/i32.rs b/src/libcore/num/int-template/i32.rs index 1bc45bb71af7e..de2e467d02ab1 100644 --- a/src/libcore/num/int-template/i32.rs +++ b/src/libcore/num/int-template/i32.rs @@ -10,7 +10,78 @@ //! Operations and constants for `i32` +use num::NumCast; + mod inst { pub type T = i32; pub const bits: uint = ::u32::bits; } + +pub impl i32: NumCast { + /** + * Cast `n` to a `i32` + */ + #[inline(always)] + static pure fn from(n: N) -> i32 { n.to_i32() } + + #[inline(always)] pure fn to_u8(&self) -> u8 { *self as u8 } + #[inline(always)] pure fn to_u16(&self) -> u16 { *self as u16 } + #[inline(always)] pure fn to_u32(&self) -> u32 { *self as u32 } + #[inline(always)] pure fn to_u64(&self) -> u64 { *self as u64 } + #[inline(always)] pure fn to_uint(&self) -> uint { *self as uint } + + #[inline(always)] pure fn to_i8(&self) -> i8 { *self as i8 } + #[inline(always)] pure fn to_i16(&self) -> i16 { *self as i16 } + #[inline(always)] pure fn to_i32(&self) -> i32 { *self } + #[inline(always)] pure fn to_i64(&self) -> i64 { *self as i64 } + #[inline(always)] pure fn to_int(&self) -> int { *self as int } + + #[inline(always)] pure fn to_f32(&self) -> f32 { *self as f32 } + #[inline(always)] pure fn to_f64(&self) -> f64 { *self as f64 } + #[inline(always)] pure fn to_float(&self) -> float { *self as float } +} + +#[test] +fn test_numcast() { + assert (20u == 20i32.to_uint()); + assert (20u8 == 20i32.to_u8()); + assert (20u16 == 20i32.to_u16()); + assert (20u32 == 20i32.to_u32()); + assert (20u64 == 20i32.to_u64()); + assert (20i == 20i32.to_int()); + assert (20i8 == 20i32.to_i8()); + assert (20i16 == 20i32.to_i16()); + assert (20i32 == 20i32.to_i32()); + assert (20i64 == 20i32.to_i64()); + assert (20f == 20i32.to_float()); + assert (20f32 == 20i32.to_f32()); + assert (20f64 == 20i32.to_f64()); + + assert (20i32 == NumCast::from(20u)); + assert (20i32 == NumCast::from(20u8)); + assert (20i32 == NumCast::from(20u16)); + assert (20i32 == NumCast::from(20u32)); + assert (20i32 == NumCast::from(20u64)); + assert (20i32 == NumCast::from(20i)); + assert (20i32 == NumCast::from(20i8)); + assert (20i32 == NumCast::from(20i16)); + assert (20i32 == NumCast::from(20i32)); + assert (20i32 == NumCast::from(20i64)); + assert (20i32 == NumCast::from(20f)); + assert (20i32 == NumCast::from(20f32)); + assert (20i32 == NumCast::from(20f64)); + + assert (20i32 == num::cast(20u)); + assert (20i32 == num::cast(20u8)); + assert (20i32 == num::cast(20u16)); + assert (20i32 == num::cast(20u32)); + assert (20i32 == num::cast(20u64)); + assert (20i32 == num::cast(20i)); + assert (20i32 == num::cast(20i8)); + assert (20i32 == num::cast(20i16)); + assert (20i32 == num::cast(20i32)); + assert (20i32 == num::cast(20i64)); + assert (20i32 == num::cast(20f)); + assert (20i32 == num::cast(20f32)); + assert (20i32 == num::cast(20f64)); +} \ No newline at end of file diff --git a/src/libcore/num/int-template/i64.rs b/src/libcore/num/int-template/i64.rs index 83d15aa857d95..d7413920a64f1 100644 --- a/src/libcore/num/int-template/i64.rs +++ b/src/libcore/num/int-template/i64.rs @@ -10,7 +10,78 @@ //! Operations and constants for `i64` +use num::NumCast; + mod inst { pub type T = i64; pub const bits: uint = ::u64::bits; } + +pub impl i64: NumCast { + /** + * Cast `n` to a `i64` + */ + #[inline(always)] + static pure fn from(n: N) -> i64 { n.to_i64() } + + #[inline(always)] pure fn to_u8(&self) -> u8 { *self as u8 } + #[inline(always)] pure fn to_u16(&self) -> u16 { *self as u16 } + #[inline(always)] pure fn to_u32(&self) -> u32 { *self as u32 } + #[inline(always)] pure fn to_u64(&self) -> u64 { *self as u64 } + #[inline(always)] pure fn to_uint(&self) -> uint { *self as uint } + + #[inline(always)] pure fn to_i8(&self) -> i8 { *self as i8 } + #[inline(always)] pure fn to_i16(&self) -> i16 { *self as i16 } + #[inline(always)] pure fn to_i32(&self) -> i32 { *self as i32 } + #[inline(always)] pure fn to_i64(&self) -> i64 { *self } + #[inline(always)] pure fn to_int(&self) -> int { *self as int } + + #[inline(always)] pure fn to_f32(&self) -> f32 { *self as f32 } + #[inline(always)] pure fn to_f64(&self) -> f64 { *self as f64 } + #[inline(always)] pure fn to_float(&self) -> float { *self as float } +} + +#[test] +fn test_numcast() { + assert (20u == 20i64.to_uint()); + assert (20u8 == 20i64.to_u8()); + assert (20u16 == 20i64.to_u16()); + assert (20u32 == 20i64.to_u32()); + assert (20u64 == 20i64.to_u64()); + assert (20i == 20i64.to_int()); + assert (20i8 == 20i64.to_i8()); + assert (20i16 == 20i64.to_i16()); + assert (20i32 == 20i64.to_i32()); + assert (20i64 == 20i64.to_i64()); + assert (20f == 20i64.to_float()); + assert (20f32 == 20i64.to_f32()); + assert (20f64 == 20i64.to_f64()); + + assert (20i64 == NumCast::from(20u)); + assert (20i64 == NumCast::from(20u8)); + assert (20i64 == NumCast::from(20u16)); + assert (20i64 == NumCast::from(20u32)); + assert (20i64 == NumCast::from(20u64)); + assert (20i64 == NumCast::from(20i)); + assert (20i64 == NumCast::from(20i8)); + assert (20i64 == NumCast::from(20i16)); + assert (20i64 == NumCast::from(20i32)); + assert (20i64 == NumCast::from(20i64)); + assert (20i64 == NumCast::from(20f)); + assert (20i64 == NumCast::from(20f32)); + assert (20i64 == NumCast::from(20f64)); + + assert (20i64 == num::cast(20u)); + assert (20i64 == num::cast(20u8)); + assert (20i64 == num::cast(20u16)); + assert (20i64 == num::cast(20u32)); + assert (20i64 == num::cast(20u64)); + assert (20i64 == num::cast(20i)); + assert (20i64 == num::cast(20i8)); + assert (20i64 == num::cast(20i16)); + assert (20i64 == num::cast(20i32)); + assert (20i64 == num::cast(20i64)); + assert (20i64 == num::cast(20f)); + assert (20i64 == num::cast(20f32)); + assert (20i64 == num::cast(20f64)); +} diff --git a/src/libcore/num/int-template/i8.rs b/src/libcore/num/int-template/i8.rs index 740442ed725be..f2577020128bd 100644 --- a/src/libcore/num/int-template/i8.rs +++ b/src/libcore/num/int-template/i8.rs @@ -10,7 +10,78 @@ //! Operations and constants for `i8` +use num::NumCast; + mod inst { pub type T = i8; pub const bits: uint = ::u8::bits; } + +pub impl i8: NumCast { + /** + * Cast `n` to a `i8` + */ + #[inline(always)] + static pure fn from(n: N) -> i8 { n.to_i8() } + + #[inline(always)] pure fn to_u8(&self) -> u8 { *self as u8 } + #[inline(always)] pure fn to_u16(&self) -> u16 { *self as u16 } + #[inline(always)] pure fn to_u32(&self) -> u32 { *self as u32 } + #[inline(always)] pure fn to_u64(&self) -> u64 { *self as u64 } + #[inline(always)] pure fn to_uint(&self) -> uint { *self as uint } + + #[inline(always)] pure fn to_i8(&self) -> i8 { *self } + #[inline(always)] pure fn to_i16(&self) -> i16 { *self as i16 } + #[inline(always)] pure fn to_i32(&self) -> i32 { *self as i32 } + #[inline(always)] pure fn to_i64(&self) -> i64 { *self as i64 } + #[inline(always)] pure fn to_int(&self) -> int { *self as int } + + #[inline(always)] pure fn to_f32(&self) -> f32 { *self as f32 } + #[inline(always)] pure fn to_f64(&self) -> f64 { *self as f64 } + #[inline(always)] pure fn to_float(&self) -> float { *self as float } +} + +#[test] +fn test_numcast() { + assert (20u == 20i8.to_uint()); + assert (20u8 == 20i8.to_u8()); + assert (20u16 == 20i8.to_u16()); + assert (20u32 == 20i8.to_u32()); + assert (20u64 == 20i8.to_u64()); + assert (20i == 20i8.to_int()); + assert (20i8 == 20i8.to_i8()); + assert (20i16 == 20i8.to_i16()); + assert (20i32 == 20i8.to_i32()); + assert (20i64 == 20i8.to_i64()); + assert (20f == 20i8.to_float()); + assert (20f32 == 20i8.to_f32()); + assert (20f64 == 20i8.to_f64()); + + assert (20i8 == NumCast::from(20u)); + assert (20i8 == NumCast::from(20u8)); + assert (20i8 == NumCast::from(20u16)); + assert (20i8 == NumCast::from(20u32)); + assert (20i8 == NumCast::from(20u64)); + assert (20i8 == NumCast::from(20i)); + assert (20i8 == NumCast::from(20i8)); + assert (20i8 == NumCast::from(20i16)); + assert (20i8 == NumCast::from(20i32)); + assert (20i8 == NumCast::from(20i64)); + assert (20i8 == NumCast::from(20f)); + assert (20i8 == NumCast::from(20f32)); + assert (20i8 == NumCast::from(20f64)); + + assert (20i8 == num::cast(20u)); + assert (20i8 == num::cast(20u8)); + assert (20i8 == num::cast(20u16)); + assert (20i8 == num::cast(20u32)); + assert (20i8 == num::cast(20u64)); + assert (20i8 == num::cast(20i)); + assert (20i8 == num::cast(20i8)); + assert (20i8 == num::cast(20i16)); + assert (20i8 == num::cast(20i32)); + assert (20i8 == num::cast(20i64)); + assert (20i8 == num::cast(20f)); + assert (20i8 == num::cast(20f32)); + assert (20i8 == num::cast(20f64)); +} diff --git a/src/libcore/num/int-template/int.rs b/src/libcore/num/int-template/int.rs index 224da0dc062d3..4ba1570e1359a 100644 --- a/src/libcore/num/int-template/int.rs +++ b/src/libcore/num/int-template/int.rs @@ -10,6 +10,8 @@ //! Operations and constants for `int` +use num::NumCast; + pub use self::inst::pow; mod inst { @@ -55,3 +57,72 @@ mod inst { assert (::int::min_value + ::int::max_value + 1 == 0); } } + +pub impl int: NumCast { + /** + * Cast `n` to a `int` + */ + #[inline(always)] + static pure fn from(n: N) -> int { n.to_int() } + + #[inline(always)] pure fn to_u8(&self) -> u8 { *self as u8 } + #[inline(always)] pure fn to_u16(&self) -> u16 { *self as u16 } + #[inline(always)] pure fn to_u32(&self) -> u32 { *self as u32 } + #[inline(always)] pure fn to_u64(&self) -> u64 { *self as u64 } + #[inline(always)] pure fn to_uint(&self) -> uint { *self as uint } + + #[inline(always)] pure fn to_i8(&self) -> i8 { *self as i8 } + #[inline(always)] pure fn to_i16(&self) -> i16 { *self as i16 } + #[inline(always)] pure fn to_i32(&self) -> i32 { *self as i32 } + #[inline(always)] pure fn to_i64(&self) -> i64 { *self as i64 } + #[inline(always)] pure fn to_int(&self) -> int { *self } + + #[inline(always)] pure fn to_f32(&self) -> f32 { *self as f32 } + #[inline(always)] pure fn to_f64(&self) -> f64 { *self as f64 } + #[inline(always)] pure fn to_float(&self) -> float { *self as float } +} + +#[test] +fn test_numcast() { + assert (20u == 20i.to_uint()); + assert (20u8 == 20i.to_u8()); + assert (20u16 == 20i.to_u16()); + assert (20u32 == 20i.to_u32()); + assert (20u64 == 20i.to_u64()); + assert (20i == 20i.to_int()); + assert (20i8 == 20i.to_i8()); + assert (20i16 == 20i.to_i16()); + assert (20i32 == 20i.to_i32()); + assert (20i64 == 20i.to_i64()); + assert (20f == 20i.to_float()); + assert (20f32 == 20i.to_f32()); + assert (20f64 == 20i.to_f64()); + + assert (20i == NumCast::from(20u)); + assert (20i == NumCast::from(20u8)); + assert (20i == NumCast::from(20u16)); + assert (20i == NumCast::from(20u32)); + assert (20i == NumCast::from(20u64)); + assert (20i == NumCast::from(20i)); + assert (20i == NumCast::from(20i8)); + assert (20i == NumCast::from(20i16)); + assert (20i == NumCast::from(20i32)); + assert (20i == NumCast::from(20i64)); + assert (20i == NumCast::from(20f)); + assert (20i == NumCast::from(20f32)); + assert (20i == NumCast::from(20f64)); + + assert (20i == num::cast(20u)); + assert (20i == num::cast(20u8)); + assert (20i == num::cast(20u16)); + assert (20i == num::cast(20u32)); + assert (20i == num::cast(20u64)); + assert (20i == num::cast(20i)); + assert (20i == num::cast(20i8)); + assert (20i == num::cast(20i16)); + assert (20i == num::cast(20i32)); + assert (20i == num::cast(20i64)); + assert (20i == num::cast(20f)); + assert (20i == num::cast(20f32)); + assert (20i == num::cast(20f64)); +} diff --git a/src/libcore/num/num.rs b/src/libcore/num/num.rs index 05b03a53dcdea..eb722b441c7a6 100644 --- a/src/libcore/num/num.rs +++ b/src/libcore/num/num.rs @@ -24,9 +24,6 @@ pub trait Num { pure fn div(&self, other: &Self) -> Self; pure fn modulo(&self, other: &Self) -> Self; pure fn neg(&self) -> Self; - - pure fn to_int(&self) -> int; - static pure fn from_int(n: int) -> Self; } pub trait IntConvertible { @@ -50,6 +47,44 @@ pub trait Round { pure fn fract(&self) -> Self; } +/** + * Cast a number the the enclosing type + * + * # Example + * + * ~~~ + * let twenty: f32 = num::cast(0x14); + * assert twenty == 20f32; + * ~~~ + */ +#[inline(always)] +pub pure fn cast(n: T) -> U { + NumCast::from(n) +} + +/** + * An interface for generic numeric type casts + */ +pub trait NumCast { + static pure fn from(n: T) -> Self; + + pure fn to_u8(&self) -> u8; + pure fn to_u16(&self) -> u16; + pure fn to_u32(&self) -> u32; + pure fn to_u64(&self) -> u64; + pure fn to_uint(&self) -> uint; + + pure fn to_i8(&self) -> i8; + pure fn to_i16(&self) -> i16; + pure fn to_i32(&self) -> i32; + pure fn to_i64(&self) -> i64; + pure fn to_int(&self) -> int; + + pure fn to_f32(&self) -> f32; + pure fn to_f64(&self) -> f64; + pure fn to_float(&self) -> float; +} + pub enum RoundMode { RoundDown, RoundUp, @@ -135,8 +170,8 @@ pub pure fn is_neg_zero(num: &T) -> bool { * - If code written to use this function doesn't care about it, it's * probably assuming that `x^0` always equals `1`. */ -pub pure fn pow_with_uint(radix: uint, - pow: uint) -> T { +pub pure fn pow_with_uint(radix: uint, + pow: uint) -> T { let _0: T = Zero::zero(); let _1: T = One::one(); @@ -144,7 +179,7 @@ pub pure fn pow_with_uint(radix: uint, if radix == 0u { return _0; } let mut my_pow = pow; let mut total = _1; - let mut multiplier = Num::from_int(radix as int); + let mut multiplier = cast(radix as int); while (my_pow > 0u) { if my_pow % 2u == 1u { total *= multiplier; @@ -217,7 +252,7 @@ pub enum SignFormat { * those special values, and `special` is `false`, because then the * algorithm just does normal calculations on them. */ -pub pure fn to_str_bytes_common( +pub pure fn to_str_bytes_common( num: &T, radix: uint, special: bool, negative_zero: bool, sign: SignFormat, digits: SignificantDigits) -> (~[u8], bool) { if radix as int < 2 { @@ -250,7 +285,7 @@ pub pure fn to_str_bytes_common( let neg = *num < _0 || (negative_zero && *num == _0 && special && is_neg_zero(num)); let mut buf: ~[u8] = ~[]; - let radix_gen = Num::from_int::(radix as int); + let radix_gen: T = cast(radix as int); let mut deccum; @@ -439,7 +474,7 @@ pub pure fn to_str_bytes_common( * `to_str_bytes_common()`, for details see there. */ #[inline(always)] -pub pure fn to_str_common( +pub pure fn to_str_common( num: &T, radix: uint, special: bool, negative_zero: bool, sign: SignFormat, digits: SignificantDigits) -> (~str, bool) { let (bytes, special) = to_str_bytes_common(num, radix, special, @@ -494,7 +529,7 @@ priv const DIGIT_E_RADIX: uint = ('e' as uint) - ('a' as uint) + 11u; * - Could accept option to allow ignoring underscores, allowing for numbers * formated like `FF_AE_FF_FF`. */ -pub pure fn from_str_bytes_common( +pub pure fn from_str_bytes_common( buf: &[u8], radix: uint, negative: bool, fractional: bool, special: bool, exponent: ExponentFormat, empty_zero: bool ) -> Option { @@ -519,7 +554,7 @@ pub pure fn from_str_bytes_common( let _0: T = Zero::zero(); let _1: T = One::one(); - let radix_gen: T = Num::from_int(radix as int); + let radix_gen: T = cast(radix as int); let len = buf.len(); @@ -570,9 +605,9 @@ pub pure fn from_str_bytes_common( // add/subtract current digit depending on sign if accum_positive { - accum += Num::from_int(digit as int); + accum += cast(digit as int); } else { - accum -= Num::from_int(digit as int); + accum -= cast(digit as int); } // Detect overflow by comparing to last value @@ -609,11 +644,13 @@ pub pure fn from_str_bytes_common( // Decrease power one order of magnitude power /= radix_gen; + let digit_t: T = cast(digit); + // add/subtract current digit depending on sign if accum_positive { - accum += Num::from_int::(digit as int) * power; + accum += digit_t * power; } else { - accum -= Num::from_int::(digit as int) * power; + accum -= digit_t * power; } // Detect overflow by comparing to last value @@ -679,7 +716,7 @@ pub pure fn from_str_bytes_common( * `from_str_bytes_common()`, for details see there. */ #[inline(always)] -pub pure fn from_str_common( +pub pure fn from_str_common( buf: &str, radix: uint, negative: bool, fractional: bool, special: bool, exponent: ExponentFormat, empty_zero: bool ) -> Option { diff --git a/src/libcore/num/uint-template.rs b/src/libcore/num/uint-template.rs index f8bbb35204add..0a219660fb946 100644 --- a/src/libcore/num/uint-template.rs +++ b/src/libcore/num/uint-template.rs @@ -146,11 +146,6 @@ impl T: num::Num { pure fn modulo(&self, other: &T) -> T { return *self % *other; } #[inline(always)] pure fn neg(&self) -> T { return -*self; } - - #[inline(always)] - pure fn to_int(&self) -> int { return *self as int; } - #[inline(always)] - static pure fn from_int(n: int) -> T { return n as T; } } impl T: num::Zero { @@ -409,6 +404,18 @@ pub fn test_ranges() { } } +#[test] +pub fn test_num() { + let ten: T = num::cast(10); + let two: T = num::cast(2); + + assert (ten.add(&two) == num::cast(12)); + assert (ten.sub(&two) == num::cast(8)); + assert (ten.mul(&two) == num::cast(20)); + assert (ten.div(&two) == num::cast(5)); + assert (ten.modulo(&two) == num::cast(0)); +} + #[test] #[should_fail] #[ignore(cfg(windows))] diff --git a/src/libcore/num/uint-template/u16.rs b/src/libcore/num/uint-template/u16.rs index b9a007af2f67a..e2e8e2bc9fce2 100644 --- a/src/libcore/num/uint-template/u16.rs +++ b/src/libcore/num/uint-template/u16.rs @@ -10,9 +10,80 @@ //! Operations and constants for `u16` +use num::NumCast; + mod inst { pub type T = u16; #[allow(non_camel_case_types)] pub type T_SIGNED = i16; pub const bits: uint = 16; } + +pub impl u16: NumCast { + /** + * Cast `n` to a `u16` + */ + #[inline(always)] + static pure fn from(n: N) -> u16 { n.to_u16() } + + #[inline(always)] pure fn to_u8(&self) -> u8 { *self as u8 } + #[inline(always)] pure fn to_u16(&self) -> u16 { *self } + #[inline(always)] pure fn to_u32(&self) -> u32 { *self as u32 } + #[inline(always)] pure fn to_u64(&self) -> u64 { *self as u64 } + #[inline(always)] pure fn to_uint(&self) -> uint { *self as uint } + + #[inline(always)] pure fn to_i8(&self) -> i8 { *self as i8 } + #[inline(always)] pure fn to_i16(&self) -> i16 { *self as i16 } + #[inline(always)] pure fn to_i32(&self) -> i32 { *self as i32 } + #[inline(always)] pure fn to_i64(&self) -> i64 { *self as i64 } + #[inline(always)] pure fn to_int(&self) -> int { *self as int } + + #[inline(always)] pure fn to_f32(&self) -> f32 { *self as f32 } + #[inline(always)] pure fn to_f64(&self) -> f64 { *self as f64 } + #[inline(always)] pure fn to_float(&self) -> float { *self as float } +} + +#[test] +fn test_numcast() { + assert (20u == 20u16.to_uint()); + assert (20u8 == 20u16.to_u8()); + assert (20u16 == 20u16.to_u16()); + assert (20u32 == 20u16.to_u32()); + assert (20u64 == 20u16.to_u64()); + assert (20i == 20u16.to_int()); + assert (20i8 == 20u16.to_i8()); + assert (20i16 == 20u16.to_i16()); + assert (20i32 == 20u16.to_i32()); + assert (20i64 == 20u16.to_i64()); + assert (20f == 20u16.to_float()); + assert (20f32 == 20u16.to_f32()); + assert (20f64 == 20u16.to_f64()); + + assert (20u16 == NumCast::from(20u)); + assert (20u16 == NumCast::from(20u8)); + assert (20u16 == NumCast::from(20u16)); + assert (20u16 == NumCast::from(20u32)); + assert (20u16 == NumCast::from(20u64)); + assert (20u16 == NumCast::from(20i)); + assert (20u16 == NumCast::from(20i8)); + assert (20u16 == NumCast::from(20i16)); + assert (20u16 == NumCast::from(20i32)); + assert (20u16 == NumCast::from(20i64)); + assert (20u16 == NumCast::from(20f)); + assert (20u16 == NumCast::from(20f32)); + assert (20u16 == NumCast::from(20f64)); + + assert (20u16 == num::cast(20u)); + assert (20u16 == num::cast(20u8)); + assert (20u16 == num::cast(20u16)); + assert (20u16 == num::cast(20u32)); + assert (20u16 == num::cast(20u64)); + assert (20u16 == num::cast(20i)); + assert (20u16 == num::cast(20i8)); + assert (20u16 == num::cast(20i16)); + assert (20u16 == num::cast(20i32)); + assert (20u16 == num::cast(20i64)); + assert (20u16 == num::cast(20f)); + assert (20u16 == num::cast(20f32)); + assert (20u16 == num::cast(20f64)); +} \ No newline at end of file diff --git a/src/libcore/num/uint-template/u32.rs b/src/libcore/num/uint-template/u32.rs index 141509c49e555..ac2727bff0996 100644 --- a/src/libcore/num/uint-template/u32.rs +++ b/src/libcore/num/uint-template/u32.rs @@ -10,9 +10,80 @@ //! Operations and constants for `u32` +use num::NumCast; + mod inst { pub type T = u32; #[allow(non_camel_case_types)] pub type T_SIGNED = i32; pub const bits: uint = 32; +} + +pub impl u32: NumCast { + /** + * Cast `n` to a `u32` + */ + #[inline(always)] + static pure fn from(n: N) -> u32 { n.to_u32() } + + #[inline(always)] pure fn to_u8(&self) -> u8 { *self as u8 } + #[inline(always)] pure fn to_u16(&self) -> u16 { *self as u16 } + #[inline(always)] pure fn to_u32(&self) -> u32 { *self } + #[inline(always)] pure fn to_u64(&self) -> u64 { *self as u64 } + #[inline(always)] pure fn to_uint(&self) -> uint { *self as uint } + + #[inline(always)] pure fn to_i8(&self) -> i8 { *self as i8 } + #[inline(always)] pure fn to_i16(&self) -> i16 { *self as i16 } + #[inline(always)] pure fn to_i32(&self) -> i32 { *self as i32 } + #[inline(always)] pure fn to_i64(&self) -> i64 { *self as i64 } + #[inline(always)] pure fn to_int(&self) -> int { *self as int } + + #[inline(always)] pure fn to_f32(&self) -> f32 { *self as f32 } + #[inline(always)] pure fn to_f64(&self) -> f64 { *self as f64 } + #[inline(always)] pure fn to_float(&self) -> float { *self as float } +} + +#[test] +fn test_numcast() { + assert (20u == 20u64.to_uint()); + assert (20u8 == 20u64.to_u8()); + assert (20u16 == 20u64.to_u16()); + assert (20u32 == 20u64.to_u32()); + assert (20u64 == 20u64.to_u64()); + assert (20i == 20u64.to_int()); + assert (20i8 == 20u64.to_i8()); + assert (20i16 == 20u64.to_i16()); + assert (20i32 == 20u64.to_i32()); + assert (20i64 == 20u64.to_i64()); + assert (20f == 20u64.to_float()); + assert (20f32 == 20u64.to_f32()); + assert (20f64 == 20u64.to_f64()); + + assert (20u64 == NumCast::from(20u)); + assert (20u64 == NumCast::from(20u8)); + assert (20u64 == NumCast::from(20u16)); + assert (20u64 == NumCast::from(20u32)); + assert (20u64 == NumCast::from(20u64)); + assert (20u64 == NumCast::from(20i)); + assert (20u64 == NumCast::from(20i8)); + assert (20u64 == NumCast::from(20i16)); + assert (20u64 == NumCast::from(20i32)); + assert (20u64 == NumCast::from(20i64)); + assert (20u64 == NumCast::from(20f)); + assert (20u64 == NumCast::from(20f32)); + assert (20u64 == NumCast::from(20f64)); + + assert (20u64 == num::cast(20u)); + assert (20u64 == num::cast(20u8)); + assert (20u64 == num::cast(20u16)); + assert (20u64 == num::cast(20u32)); + assert (20u64 == num::cast(20u64)); + assert (20u64 == num::cast(20i)); + assert (20u64 == num::cast(20i8)); + assert (20u64 == num::cast(20i16)); + assert (20u64 == num::cast(20i32)); + assert (20u64 == num::cast(20i64)); + assert (20u64 == num::cast(20f)); + assert (20u64 == num::cast(20f32)); + assert (20u64 == num::cast(20f64)); } \ No newline at end of file diff --git a/src/libcore/num/uint-template/u64.rs b/src/libcore/num/uint-template/u64.rs index 35210eae9a75c..345f81c147c77 100644 --- a/src/libcore/num/uint-template/u64.rs +++ b/src/libcore/num/uint-template/u64.rs @@ -10,9 +10,80 @@ //! Operations and constants for `u64` +use num::NumCast; + mod inst { pub type T = u64; #[allow(non_camel_case_types)] pub type T_SIGNED = i64; pub const bits: uint = 64; +} + +pub impl u64: num::NumCast { + /** + * Cast `n` to a `u64` + */ + #[inline(always)] + static pure fn from(n: N) -> u64 { n.to_u64() } + + #[inline(always)] pure fn to_u8(&self) -> u8 { *self as u8 } + #[inline(always)] pure fn to_u16(&self) -> u16 { *self as u16 } + #[inline(always)] pure fn to_u32(&self) -> u32 { *self as u32 } + #[inline(always)] pure fn to_u64(&self) -> u64 { *self } + #[inline(always)] pure fn to_uint(&self) -> uint { *self as uint } + + #[inline(always)] pure fn to_i8(&self) -> i8 { *self as i8 } + #[inline(always)] pure fn to_i16(&self) -> i16 { *self as i16 } + #[inline(always)] pure fn to_i32(&self) -> i32 { *self as i32 } + #[inline(always)] pure fn to_i64(&self) -> i64 { *self as i64 } + #[inline(always)] pure fn to_int(&self) -> int { *self as int } + + #[inline(always)] pure fn to_f32(&self) -> f32 { *self as f32 } + #[inline(always)] pure fn to_f64(&self) -> f64 { *self as f64 } + #[inline(always)] pure fn to_float(&self) -> float { *self as float } +} + +#[test] +fn test_numcast() { + assert (20u == 20u64.to_uint()); + assert (20u8 == 20u64.to_u8()); + assert (20u16 == 20u64.to_u16()); + assert (20u32 == 20u64.to_u32()); + assert (20u64 == 20u64.to_u64()); + assert (20i == 20u64.to_int()); + assert (20i8 == 20u64.to_i8()); + assert (20i16 == 20u64.to_i16()); + assert (20i32 == 20u64.to_i32()); + assert (20i64 == 20u64.to_i64()); + assert (20f == 20u64.to_float()); + assert (20f32 == 20u64.to_f32()); + assert (20f64 == 20u64.to_f64()); + + assert (20u64 == NumCast::from(20u)); + assert (20u64 == NumCast::from(20u8)); + assert (20u64 == NumCast::from(20u16)); + assert (20u64 == NumCast::from(20u32)); + assert (20u64 == NumCast::from(20u64)); + assert (20u64 == NumCast::from(20i)); + assert (20u64 == NumCast::from(20i8)); + assert (20u64 == NumCast::from(20i16)); + assert (20u64 == NumCast::from(20i32)); + assert (20u64 == NumCast::from(20i64)); + assert (20u64 == NumCast::from(20f)); + assert (20u64 == NumCast::from(20f32)); + assert (20u64 == NumCast::from(20f64)); + + assert (20u64 == num::cast(20u)); + assert (20u64 == num::cast(20u8)); + assert (20u64 == num::cast(20u16)); + assert (20u64 == num::cast(20u32)); + assert (20u64 == num::cast(20u64)); + assert (20u64 == num::cast(20i)); + assert (20u64 == num::cast(20i8)); + assert (20u64 == num::cast(20i16)); + assert (20u64 == num::cast(20i32)); + assert (20u64 == num::cast(20i64)); + assert (20u64 == num::cast(20f)); + assert (20u64 == num::cast(20f32)); + assert (20u64 == num::cast(20f64)); } \ No newline at end of file diff --git a/src/libcore/num/uint-template/u8.rs b/src/libcore/num/uint-template/u8.rs index e273a20321326..71be36d901961 100644 --- a/src/libcore/num/uint-template/u8.rs +++ b/src/libcore/num/uint-template/u8.rs @@ -12,6 +12,8 @@ pub use self::inst::is_ascii; +use num::NumCast; + mod inst { pub type T = u8; #[allow(non_camel_case_types)] @@ -23,3 +25,72 @@ mod inst { pub pure fn is_ascii(x: T) -> bool { return 0 as T == x & 128 as T; } } + +pub impl u8: NumCast { + /** + * Cast `n` to a `u8` + */ + #[inline(always)] + static pure fn from(n: N) -> u8 { n.to_u8() } + + #[inline(always)] pure fn to_u8(&self) -> u8 { *self } + #[inline(always)] pure fn to_u16(&self) -> u16 { *self as u16 } + #[inline(always)] pure fn to_u32(&self) -> u32 { *self as u32 } + #[inline(always)] pure fn to_u64(&self) -> u64 { *self as u64 } + #[inline(always)] pure fn to_uint(&self) -> uint { *self as uint } + + #[inline(always)] pure fn to_i8(&self) -> i8 { *self as i8 } + #[inline(always)] pure fn to_i16(&self) -> i16 { *self as i16 } + #[inline(always)] pure fn to_i32(&self) -> i32 { *self as i32 } + #[inline(always)] pure fn to_i64(&self) -> i64 { *self as i64 } + #[inline(always)] pure fn to_int(&self) -> int { *self as int } + + #[inline(always)] pure fn to_f32(&self) -> f32 { *self as f32 } + #[inline(always)] pure fn to_f64(&self) -> f64 { *self as f64 } + #[inline(always)] pure fn to_float(&self) -> float { *self as float } +} + +#[test] +fn test_numcast() { + assert (20u == 20u8.to_uint()); + assert (20u8 == 20u8.to_u8()); + assert (20u16 == 20u8.to_u16()); + assert (20u32 == 20u8.to_u32()); + assert (20u64 == 20u8.to_u64()); + assert (20i == 20u8.to_int()); + assert (20i8 == 20u8.to_i8()); + assert (20i16 == 20u8.to_i16()); + assert (20i32 == 20u8.to_i32()); + assert (20i64 == 20u8.to_i64()); + assert (20f == 20u8.to_float()); + assert (20f32 == 20u8.to_f32()); + assert (20f64 == 20u8.to_f64()); + + assert (20u8 == NumCast::from(20u)); + assert (20u8 == NumCast::from(20u8)); + assert (20u8 == NumCast::from(20u16)); + assert (20u8 == NumCast::from(20u32)); + assert (20u8 == NumCast::from(20u64)); + assert (20u8 == NumCast::from(20i)); + assert (20u8 == NumCast::from(20i8)); + assert (20u8 == NumCast::from(20i16)); + assert (20u8 == NumCast::from(20i32)); + assert (20u8 == NumCast::from(20i64)); + assert (20u8 == NumCast::from(20f)); + assert (20u8 == NumCast::from(20f32)); + assert (20u8 == NumCast::from(20f64)); + + assert (20u8 == num::cast(20u)); + assert (20u8 == num::cast(20u8)); + assert (20u8 == num::cast(20u16)); + assert (20u8 == num::cast(20u32)); + assert (20u8 == num::cast(20u64)); + assert (20u8 == num::cast(20i)); + assert (20u8 == num::cast(20i8)); + assert (20u8 == num::cast(20i16)); + assert (20u8 == num::cast(20i32)); + assert (20u8 == num::cast(20i64)); + assert (20u8 == num::cast(20f)); + assert (20u8 == num::cast(20f32)); + assert (20u8 == num::cast(20f64)); +} \ No newline at end of file diff --git a/src/libcore/num/uint-template/uint.rs b/src/libcore/num/uint-template/uint.rs index 93f59cd2d9f97..66689f18dfe99 100644 --- a/src/libcore/num/uint-template/uint.rs +++ b/src/libcore/num/uint-template/uint.rs @@ -10,6 +10,8 @@ //! Operations and constants for `uint` +use num::NumCast; + pub use self::inst::{ div_ceil, div_round, div_floor, iterate, next_power_of_two @@ -206,3 +208,72 @@ pub mod inst { assert (accum == 10); } } + +pub impl uint: NumCast { + /** + * Cast `n` to a `uint` + */ + #[inline(always)] + static pure fn from(n: N) -> uint { n.to_uint() } + + #[inline(always)] pure fn to_u8(&self) -> u8 { *self as u8 } + #[inline(always)] pure fn to_u16(&self) -> u16 { *self as u16 } + #[inline(always)] pure fn to_u32(&self) -> u32 { *self as u32 } + #[inline(always)] pure fn to_u64(&self) -> u64 { *self as u64 } + #[inline(always)] pure fn to_uint(&self) -> uint { *self } + + #[inline(always)] pure fn to_i8(&self) -> i8 { *self as i8 } + #[inline(always)] pure fn to_i16(&self) -> i16 { *self as i16 } + #[inline(always)] pure fn to_i32(&self) -> i32 { *self as i32 } + #[inline(always)] pure fn to_i64(&self) -> i64 { *self as i64 } + #[inline(always)] pure fn to_int(&self) -> int { *self as int } + + #[inline(always)] pure fn to_f32(&self) -> f32 { *self as f32 } + #[inline(always)] pure fn to_f64(&self) -> f64 { *self as f64 } + #[inline(always)] pure fn to_float(&self) -> float { *self as float } +} + +#[test] +fn test_numcast() { + assert (20u == 20u.to_uint()); + assert (20u8 == 20u.to_u8()); + assert (20u16 == 20u.to_u16()); + assert (20u32 == 20u.to_u32()); + assert (20u64 == 20u.to_u64()); + assert (20i == 20u.to_int()); + assert (20i8 == 20u.to_i8()); + assert (20i16 == 20u.to_i16()); + assert (20i32 == 20u.to_i32()); + assert (20i64 == 20u.to_i64()); + assert (20f == 20u.to_float()); + assert (20f32 == 20u.to_f32()); + assert (20f64 == 20u.to_f64()); + + assert (20u == NumCast::from(20u)); + assert (20u == NumCast::from(20u8)); + assert (20u == NumCast::from(20u16)); + assert (20u == NumCast::from(20u32)); + assert (20u == NumCast::from(20u64)); + assert (20u == NumCast::from(20i)); + assert (20u == NumCast::from(20i8)); + assert (20u == NumCast::from(20i16)); + assert (20u == NumCast::from(20i32)); + assert (20u == NumCast::from(20i64)); + assert (20u == NumCast::from(20f)); + assert (20u == NumCast::from(20f32)); + assert (20u == NumCast::from(20f64)); + + assert (20u == num::cast(20u)); + assert (20u == num::cast(20u8)); + assert (20u == num::cast(20u16)); + assert (20u == num::cast(20u32)); + assert (20u == num::cast(20u64)); + assert (20u == num::cast(20i)); + assert (20u == num::cast(20i8)); + assert (20u == num::cast(20i16)); + assert (20u == num::cast(20i32)); + assert (20u == num::cast(20i64)); + assert (20u == num::cast(20f)); + assert (20u == num::cast(20f32)); + assert (20u == num::cast(20f64)); +} \ No newline at end of file diff --git a/src/libcore/option.rs b/src/libcore/option.rs index cfc2cba922602..c2af5f8b73b1c 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -201,7 +201,7 @@ pub pure fn map_default(opt: &r/Option, def: U, } #[inline(always)] -pub pure fn iter(opt: &Option, f: fn(x: &T)) { +pub pure fn iter(opt: &r/Option, f: fn(x: &r/T)) { //! Performs an operation on the contained value by reference match *opt { None => (), Some(ref t) => f(t) } } @@ -313,7 +313,7 @@ impl Option { /// Performs an operation on the contained value by reference #[inline(always)] - pure fn iter(&self, f: fn(x: &T)) { iter(self, f) } + pure fn iter(&self, f: fn(x: &self/T)) { iter(self, f) } /** Gets an immutable reference to the value inside an option. diff --git a/src/libcore/os.rs b/src/libcore/os.rs index 38469c35cfa6c..0efc17354dd58 100644 --- a/src/libcore/os.rs +++ b/src/libcore/os.rs @@ -62,11 +62,10 @@ extern mod rustrt { unsafe fn rust_path_exists(path: *libc::c_char) -> c_int; unsafe fn rust_list_files2(&&path: ~str) -> ~[~str]; unsafe fn rust_process_wait(handle: c_int) -> c_int; - unsafe fn last_os_error() -> ~str; unsafe fn rust_set_exit_status(code: libc::intptr_t); } -pub const tmpbuf_sz : uint = 1000u; +pub const TMPBUF_SZ : uint = 1000u; pub fn getcwd() -> Path { unsafe { @@ -80,7 +79,7 @@ pub fn as_c_charp(s: &str, f: fn(*c_char) -> T) -> T { pub fn fill_charp_buf(f: fn(*mut c_char, size_t) -> bool) -> Option<~str> { - let buf = vec::cast_to_mut(vec::from_elem(tmpbuf_sz, 0u8 as c_char)); + let buf = vec::cast_to_mut(vec::from_elem(TMPBUF_SZ, 0u8 as c_char)); do vec::as_mut_buf(buf) |b, sz| { if f(b, sz as size_t) { unsafe { @@ -99,19 +98,19 @@ pub mod win32 { use str; use option::{None, Option}; use option; - use os::tmpbuf_sz; + use os::TMPBUF_SZ; use libc::types::os::arch::extra::DWORD; pub fn fill_utf16_buf_and_decode(f: fn(*mut u16, DWORD) -> DWORD) -> Option<~str> { unsafe { - let mut n = tmpbuf_sz as DWORD; + let mut n = TMPBUF_SZ as DWORD; let mut res = None; let mut done = false; while !done { let buf = vec::cast_to_mut(vec::from_elem(n as uint, 0u16)); do vec::as_mut_buf(buf) |b, _sz| { - let k : DWORD = f(b, tmpbuf_sz as DWORD); + let k : DWORD = f(b, TMPBUF_SZ as DWORD); if k == (0 as DWORD) { done = true; } else if (k == n && @@ -387,11 +386,11 @@ pub fn self_exe_path() -> Option { unsafe { use libc::funcs::posix01::unistd::readlink; - let mut path_str = str::with_capacity(tmpbuf_sz); + let mut path_str = str::with_capacity(TMPBUF_SZ); let len = do str::as_c_str(path_str) |buf| { let buf = buf as *mut c_char; do as_c_charp("/proc/self/exe") |proc_self_buf| { - readlink(proc_self_buf, buf, tmpbuf_sz as size_t) + readlink(proc_self_buf, buf, TMPBUF_SZ as size_t) } }; if len == -1 { @@ -766,11 +765,136 @@ pub fn remove_file(p: &Path) -> bool { } } +#[cfg(unix)] +pub fn errno() -> int { + #[cfg(target_os = "macos")] + #[cfg(target_os = "freebsd")] + fn errno_location() -> *c_int { + #[nolink] + extern { + unsafe fn __error() -> *c_int; + } + unsafe { + __error() + } + } + + #[cfg(target_os = "linux")] + #[cfg(target_os = "android")] + fn errno_location() -> *c_int { + #[nolink] + extern { + unsafe fn __errno_location() -> *c_int; + } + unsafe { + __errno_location() + } + } + + unsafe { + (*errno_location()) as int + } +} + +#[cfg(windows)] +pub fn errno() -> uint { + use libc::types::os::arch::extra::DWORD; + + #[link_name = "kernel32"] + #[abi = "stdcall"] + extern { + unsafe fn GetLastError() -> DWORD; + } + + unsafe { + GetLastError() as uint + } +} + /// Get a string representing the platform-dependent last error pub fn last_os_error() -> ~str { - unsafe { - rustrt::last_os_error() + #[cfg(unix)] + fn strerror() -> ~str { + #[cfg(target_os = "macos")] + #[cfg(target_os = "android")] + #[cfg(target_os = "freebsd")] + fn strerror_r(errnum: c_int, buf: *c_char, buflen: size_t) -> c_int { + #[nolink] + extern { + unsafe fn strerror_r(errnum: c_int, buf: *c_char, + buflen: size_t) -> c_int; + } + unsafe { + strerror_r(errnum, buf, buflen) + } + } + + // GNU libc provides a non-compliant version of strerror_r by default + // and requires macros to instead use the POSIX compliant variant. + // So we just use __xpg_strerror_r which is always POSIX compliant + #[cfg(target_os = "linux")] + fn strerror_r(errnum: c_int, buf: *c_char, buflen: size_t) -> c_int { + #[nolink] + extern { + unsafe fn __xpg_strerror_r(errnum: c_int, buf: *c_char, + buflen: size_t) -> c_int; + } + unsafe { + __xpg_strerror_r(errnum, buf, buflen) + } + } + + let mut buf = [0 as c_char, ..TMPBUF_SZ]; + unsafe { + let err = strerror_r(errno() as c_int, &buf[0], + TMPBUF_SZ as size_t); + if err < 0 { + die!(~"strerror_r failure"); + } + + str::raw::from_c_str(&buf[0]) + } + } + + #[cfg(windows)] + fn strerror() -> ~str { + use libc::types::os::arch::extra::DWORD; + use libc::types::os::arch::extra::LPSTR; + use libc::types::os::arch::extra::LPVOID; + + #[link_name = "kernel32"] + #[abi = "stdcall"] + extern { + unsafe fn FormatMessageA(flags: DWORD, lpSrc: LPVOID, + msgId: DWORD, langId: DWORD, + buf: LPSTR, nsize: DWORD, + args: *c_void) -> DWORD; + } + + const FORMAT_MESSAGE_FROM_SYSTEM: DWORD = 0x00001000; + const FORMAT_MESSAGE_IGNORE_INSERTS: DWORD = 0x00000200; + + let mut buf = [0 as c_char, ..TMPBUF_SZ]; + + // This value is calculated from the macro + // MAKELANGID(LANG_SYSTEM_DEFAULT, SUBLANG_SYS_DEFAULT) + let langId = 0x0800 as DWORD; + let err = errno() as DWORD; + unsafe { + let res = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, + ptr::mut_null(), err, langId, + &mut buf[0], TMPBUF_SZ as DWORD, + ptr::null()); + if res == 0 { + die!(fmt!("[%?] FormatMessage failure", errno())); + } + + str::raw::from_c_str(&buf[0]) + } } + + strerror() } /** diff --git a/src/libcore/prelude.rs b/src/libcore/prelude.rs index a798d8c866a3f..5b4726d482d9e 100644 --- a/src/libcore/prelude.rs +++ b/src/libcore/prelude.rs @@ -29,12 +29,11 @@ pub use container::{Container, Mutable, Map, Set}; pub use hash::Hash; pub use iter::{BaseIter, ExtendedIter, EqIter, CopyableIter}; pub use iter::{CopyableOrderedIter, CopyableNonstrictIter, Times}; -pub use num::Num; +pub use num::{Num, NumCast}; pub use path::GenericPath; pub use path::Path; pub use path::PosixPath; pub use path::WindowsPath; -pub use pipes::{GenericChan, GenericPort}; pub use ptr::Ptr; pub use str::{StrSlice, Trimmable, OwnedStr}; pub use to_bytes::IterBytes; diff --git a/src/libcore/private.rs b/src/libcore/private.rs index 56e3325edba3e..038f61350b2ae 100644 --- a/src/libcore/private.rs +++ b/src/libcore/private.rs @@ -14,7 +14,7 @@ use cast; use iter; use libc; use option; -use pipes; +use pipes::{GenericChan, GenericPort}; use prelude::*; use ptr; use result; @@ -256,15 +256,15 @@ pub unsafe fn shared_mutable_state(data: T) -> } #[inline(always)] -pub unsafe fn get_shared_mutable_state(rc: &a/SharedMutableState) - -> &a/mut T { +pub unsafe fn get_shared_mutable_state( + rc: *SharedMutableState) -> *mut T +{ unsafe { let ptr: ~ArcData = cast::reinterpret_cast(&(*rc).data); assert ptr.count > 0; - // Cast us back into the correct region - let r = cast::transmute_region(option::get_ref(&ptr.data)); + let r = cast::transmute(option::get_ref(&ptr.data)); cast::forget(move ptr); - return cast::transmute_mut(r); + return r; } } #[inline(always)] @@ -376,15 +376,17 @@ impl Exclusive { // the exclusive. Supporting that is a work in progress. #[inline(always)] unsafe fn with(f: fn(x: &mut T) -> U) -> U { - let rec = unsafe { get_shared_mutable_state(&self.x) }; - do rec.lock.lock { - if rec.failed { - die!(~"Poisoned exclusive - another task failed inside!"); + unsafe { + let rec = get_shared_mutable_state(&self.x); + do (*rec).lock.lock { + if (*rec).failed { + die!(~"Poisoned exclusive - another task failed inside!"); + } + (*rec).failed = true; + let result = f(&mut (*rec).data); + (*rec).failed = false; + move result } - rec.failed = true; - let result = f(&mut rec.data); - rec.failed = false; - move result } } diff --git a/src/libcore/private/weak_task.rs b/src/libcore/private/weak_task.rs index 9d57cd5a466ac..520d411e4c430 100644 --- a/src/libcore/private/weak_task.rs +++ b/src/libcore/private/weak_task.rs @@ -22,7 +22,8 @@ use option::{Some, None, swap_unwrap}; use private::at_exit::at_exit; use private::global::global_data_clone_create; use private::finally::Finally; -use pipes::{Port, Chan, SharedChan, GenericSmartChan, stream}; +use pipes::{Port, Chan, SharedChan, GenericChan, GenericPort, + GenericSmartChan, stream}; use task::{Task, task, spawn}; use task::rt::{task_id, get_task_id}; use hashmap::linear::LinearMap; @@ -40,12 +41,12 @@ pub unsafe fn weaken_task(f: &fn(Port)) { let task = get_task_id(); // Expect the weak task service to be alive assert service.try_send(RegisterWeakTask(task, shutdown_chan)); - unsafe { rust_inc_weak_task_count(); } + unsafe { rust_dec_kernel_live_count(); } do fn&() { let shutdown_port = swap_unwrap(&mut *shutdown_port); f(shutdown_port) }.finally || { - unsafe { rust_dec_weak_task_count(); } + unsafe { rust_inc_kernel_live_count(); } // Service my have already exited service.send(UnregisterWeakTask(task)); } @@ -78,11 +79,11 @@ fn create_global_service() -> ~WeakTaskService { let port = swap_unwrap(&mut *port); // The weak task service is itself a weak task debug!("weakening the weak service task"); - unsafe { rust_inc_weak_task_count(); } + unsafe { rust_dec_kernel_live_count(); } run_weak_task_service(port); }.finally { debug!("unweakening the weak service task"); - unsafe { rust_dec_weak_task_count(); } + unsafe { rust_inc_kernel_live_count(); } } } @@ -126,8 +127,8 @@ fn run_weak_task_service(port: Port) { } extern { - unsafe fn rust_inc_weak_task_count(); - unsafe fn rust_dec_weak_task_count(); + unsafe fn rust_inc_kernel_live_count(); + unsafe fn rust_dec_kernel_live_count(); } #[test] diff --git a/src/libcore/run.rs b/src/libcore/run.rs index 43ecf350ff3cb..ae5c4d19b1c05 100644 --- a/src/libcore/run.rs +++ b/src/libcore/run.rs @@ -14,7 +14,7 @@ use io; use io::ReaderUtil; use libc; use libc::{pid_t, c_void, c_int}; -use pipes::{stream, SharedChan}; +use pipes::{stream, SharedChan, GenericChan, GenericPort}; use option::{Some, None}; use os; use prelude::*; diff --git a/src/libcore/str.rs b/src/libcore/str.rs index 47e68401485ed..6665ab6c6f7ed 100644 --- a/src/libcore/str.rs +++ b/src/libcore/str.rs @@ -2071,17 +2071,19 @@ pub mod raw { /// Appends a byte to a string. (Not UTF-8 safe). pub unsafe fn push_byte(s: &mut ~str, b: u8) { - reserve_at_least(&mut *s, s.len() + 1); + let new_len = s.len() + 1; + reserve_at_least(&mut *s, new_len); do as_buf(*s) |buf, len| { let buf: *mut u8 = ::cast::reinterpret_cast(&buf); *ptr::mut_offset(buf, len) = b; } - set_len(&mut *s, s.len() + 1); + set_len(&mut *s, new_len); } /// Appends a vector of bytes to a string. (Not UTF-8 safe). unsafe fn push_bytes(s: &mut ~str, bytes: &[u8]) { - reserve_at_least(&mut *s, s.len() + bytes.len()); + let new_len = s.len() + bytes.len(); + reserve_at_least(&mut *s, new_len); for vec::each(bytes) |byte| { push_byte(&mut *s, *byte); } } diff --git a/src/libcore/vec.rs b/src/libcore/vec.rs index 9ad5d9f32da36..16cad87c0603a 100644 --- a/src/libcore/vec.rs +++ b/src/libcore/vec.rs @@ -623,13 +623,15 @@ unsafe fn push_fast(v: &mut ~[T], initval: T) { #[inline(never)] fn push_slow(v: &mut ~[T], initval: T) { - reserve_at_least(&mut *v, v.len() + 1u); + let new_len = v.len() + 1; + reserve_at_least(&mut *v, new_len); unsafe { push_fast(v, initval) } } #[inline(always)] pub fn push_all(v: &mut ~[T], rhs: &[const T]) { - reserve(&mut *v, v.len() + rhs.len()); + let new_len = v.len() + rhs.len(); + reserve(&mut *v, new_len); for uint::range(0u, rhs.len()) |i| { push(&mut *v, unsafe { raw::get(rhs, i) }) @@ -638,7 +640,8 @@ pub fn push_all(v: &mut ~[T], rhs: &[const T]) { #[inline(always)] pub fn push_all_move(v: &mut ~[T], mut rhs: ~[T]) { - reserve(&mut *v, v.len() + rhs.len()); + let new_len = v.len() + rhs.len(); + reserve(&mut *v, new_len); unsafe { do as_mut_buf(rhs) |p, len| { for uint::range(0, len) |i| { @@ -663,9 +666,9 @@ pub fn truncate(v: &mut ~[T], newlen: uint) { let mut dropped = rusti::init(); dropped <-> *ptr::mut_offset(p, i); } - raw::set_len(&mut *v, newlen); } } + unsafe { raw::set_len(&mut *v, newlen); } } /** @@ -740,7 +743,8 @@ pub pure fn append_mut(lhs: ~[mut T], rhs: &[const T]) -> ~[mut T] { * * initval - The value for the new elements */ pub fn grow(v: &mut ~[T], n: uint, initval: &T) { - reserve_at_least(&mut *v, v.len() + n); + let new_len = v.len() + n; + reserve_at_least(&mut *v, new_len); let mut i: uint = 0u; while i < n { @@ -763,7 +767,8 @@ pub fn grow(v: &mut ~[T], n: uint, initval: &T) { * value */ pub fn grow_fn(v: &mut ~[T], n: uint, op: iter::InitOp) { - reserve_at_least(&mut *v, v.len() + n); + let new_len = v.len() + n; + reserve_at_least(&mut *v, new_len); let mut i: uint = 0u; while i < n { v.push(op(i)); diff --git a/src/librustc/back/rpath.rs b/src/librustc/back/rpath.rs index f6a5fec75aded..4cca6757cc394 100644 --- a/src/librustc/back/rpath.rs +++ b/src/librustc/back/rpath.rs @@ -18,8 +18,7 @@ use core::os; use core::uint; use core::util; use core::vec; -use std::oldmap::HashMap; -use std::oldmap; +use core::hashmap::linear::LinearSet; pure fn not_win32(os: session::os) -> bool { match os { @@ -187,16 +186,14 @@ pub fn get_install_prefix_rpath(target_triple: &str) -> Path { } pub fn minimize_rpaths(rpaths: &[Path]) -> ~[Path] { - let set = oldmap::HashMap(); + let mut set = LinearSet::new(); let mut minimized = ~[]; for rpaths.each |rpath| { - let s = rpath.to_str(); - if !set.contains_key_ref(&s) { - minimized.push(/*bad*/copy *rpath); - set.insert(s, ()); + if set.insert(rpath.to_str()) { + minimized.push(copy *rpath); } } - return minimized; + minimized } #[cfg(unix)] diff --git a/src/librustc/metadata/cstore.rs b/src/librustc/metadata/cstore.rs index c144d2d8804ba..73ec872b6a6ec 100644 --- a/src/librustc/metadata/cstore.rs +++ b/src/librustc/metadata/cstore.rs @@ -86,13 +86,13 @@ pub fn set_crate_data(cstore: @mut CStore, } pub fn have_crate_data(cstore: @mut CStore, cnum: ast::crate_num) -> bool { - return cstore.metas.contains_key_ref(&cnum); + cstore.metas.contains_key(&cnum) } pub fn iter_crate_data(cstore: @mut CStore, i: fn(ast::crate_num, crate_metadata)) { let metas = cstore.metas; - for metas.each_ref |&k, &v| { + for metas.each |&k, &v| { i(k, v); } } @@ -148,7 +148,7 @@ pub fn get_dep_hashes(cstore: @mut CStore) -> ~[~str] { let mut result = ~[]; let use_crate_map = cstore.use_crate_map; - for use_crate_map.each_value_ref |&cnum| { + for use_crate_map.each_value |&cnum| { let cdata = cstore::get_crate_data(cstore, cnum); let hash = decoder::get_crate_hash(cdata.data); debug!("Add hash[%s]: %s", cdata.name, hash); diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs index 89b491a867b9a..fcc1a4e806dff 100644 --- a/src/librustc/metadata/encoder.rs +++ b/src/librustc/metadata/encoder.rs @@ -99,7 +99,7 @@ pub enum encode_ctxt = { }; pub fn reachable(ecx: @encode_ctxt, id: node_id) -> bool { - ecx.reachable.contains_key_ref(&id) + ecx.reachable.contains_key(&id) } fn encode_name(ecx: @encode_ctxt, ebml_w: writer::Encoder, name: ident) { diff --git a/src/librustc/middle/borrowck/check_loans.rs b/src/librustc/middle/borrowck/check_loans.rs index 8d439f4ee9ff2..b6b94faa3db7e 100644 --- a/src/librustc/middle/borrowck/check_loans.rs +++ b/src/librustc/middle/borrowck/check_loans.rs @@ -305,22 +305,31 @@ impl CheckLoanCtxt { return; } - match (old_loan.mutbl, new_loan.mutbl) { - (m_const, _) | (_, m_const) | (m_imm, m_imm) => { - /*ok*/ + match (old_loan.kind, new_loan.kind) { + (PartialFreeze, PartialTake) | (PartialTake, PartialFreeze) | + (TotalFreeze, PartialFreeze) | (PartialFreeze, TotalFreeze) | + (Immobile, _) | (_, Immobile) | + (PartialFreeze, PartialFreeze) | + (PartialTake, PartialTake) | + (TotalFreeze, TotalFreeze) => { + /* ok */ } - (m_mutbl, m_mutbl) | (m_mutbl, m_imm) | (m_imm, m_mutbl) => { + (PartialTake, TotalFreeze) | (TotalFreeze, PartialTake) | + (TotalTake, TotalFreeze) | (TotalFreeze, TotalTake) | + (TotalTake, PartialFreeze) | (PartialFreeze, TotalTake) | + (TotalTake, PartialTake) | (PartialTake, TotalTake) | + (TotalTake, TotalTake) => { self.bccx.span_err( new_loan.cmt.span, fmt!("loan of %s as %s \ conflicts with prior loan", self.bccx.cmt_to_str(new_loan.cmt), - self.bccx.mut_to_str(new_loan.mutbl))); + self.bccx.loan_kind_to_str(new_loan.kind))); self.bccx.span_note( old_loan.cmt.span, fmt!("prior loan as %s granted here", - self.bccx.mut_to_str(old_loan.mutbl))); + self.bccx.loan_kind_to_str(old_loan.kind))); } } } @@ -348,13 +357,13 @@ impl CheckLoanCtxt { // are only assigned once } else { match cmt.mutbl { - m_mutbl => { /*ok*/ } - m_const | m_imm => { - self.bccx.span_err( - ex.span, - at.ing_form(self.bccx.cmt_to_str(cmt))); - return; - } + McDeclared | McInherited => { /*ok*/ } + McReadOnly | McImmutable => { + self.bccx.span_err( + ex.span, + at.ing_form(self.bccx.cmt_to_str(cmt))); + return; + } } } @@ -428,19 +437,20 @@ impl CheckLoanCtxt { cmt: cmt, lp: @loan_path) { for self.walk_loans_of(ex.id, lp) |loan| { - match loan.mutbl { - m_const => { /*ok*/ } - m_mutbl | m_imm => { - self.bccx.span_err( - ex.span, - fmt!("%s prohibited due to outstanding loan", - at.ing_form(self.bccx.cmt_to_str(cmt)))); - self.bccx.span_note( - loan.cmt.span, - fmt!("loan of %s granted here", - self.bccx.cmt_to_str(loan.cmt))); - return; - } + match loan.kind { + Immobile => { /* ok */ } + TotalFreeze | PartialFreeze | + TotalTake | PartialTake => { + self.bccx.span_err( + ex.span, + fmt!("%s prohibited due to outstanding loan", + at.ing_form(self.bccx.cmt_to_str(cmt)))); + self.bccx.span_note( + loan.cmt.span, + fmt!("loan of %s granted here", + self.bccx.cmt_to_str(loan.cmt))); + return; + } } } @@ -689,7 +699,7 @@ fn check_loans_in_expr(expr: @ast::expr, self.check_for_conflicting_loans(expr.id); - if self.bccx.moves_map.contains_key_ref(&expr.id) { + if self.bccx.moves_map.contains_key(&expr.id) { self.check_move_out_from_expr(expr); } @@ -710,7 +720,7 @@ fn check_loans_in_expr(expr: @ast::expr, } ast::expr_index(_, rval) | ast::expr_binary(_, _, rval) - if self.bccx.method_map.contains_key_ref(&expr.id) => { + if self.bccx.method_map.contains_key(&expr.id) => { self.check_call(expr, None, expr.callee_id, @@ -718,7 +728,7 @@ fn check_loans_in_expr(expr: @ast::expr, ~[rval]); } ast::expr_unary(*) | ast::expr_index(*) - if self.bccx.method_map.contains_key_ref(&expr.id) => { + if self.bccx.method_map.contains_key(&expr.id) => { self.check_call(expr, None, expr.callee_id, diff --git a/src/librustc/middle/borrowck/gather_loans.rs b/src/librustc/middle/borrowck/gather_loans.rs index 6a61b2e2ee75c..65518398eb752 100644 --- a/src/librustc/middle/borrowck/gather_loans.rs +++ b/src/librustc/middle/borrowck/gather_loans.rs @@ -20,7 +20,10 @@ use core::prelude::*; use middle::borrowck::preserve::{PreserveCondition, PcOk, PcIfPure}; use middle::borrowck::{Loan, bckerr, bckres, BorrowckCtxt, err_mutbl}; +use middle::borrowck::{LoanKind, TotalFreeze, PartialFreeze, + TotalTake, PartialTake, Immobile}; use middle::borrowck::{req_maps}; +use middle::borrowck::loan; use middle::mem_categorization::{cat_binding, cat_discr, cmt, comp_variant}; use middle::mem_categorization::{mem_categorization_ctxt}; use middle::mem_categorization::{opt_deref_kind}; @@ -207,7 +210,7 @@ fn req_loans_in_expr(ex: @ast::expr, ast::expr_binary(_, rcvr, _) | ast::expr_unary(_, rcvr) | ast::expr_assign_op(_, rcvr, _) - if self.bccx.method_map.contains_key_ref(&ex.id) => { + if self.bccx.method_map.contains_key(&ex.id) => { // Receivers in method calls are always passed by ref. // // Here, in an overloaded operator, the call is this expression, @@ -244,7 +247,7 @@ fn req_loans_in_expr(ex: @ast::expr, // } ast::expr_field(rcvr, _, _) - if self.bccx.method_map.contains_key_ref(&ex.id) => { + if self.bccx.method_map.contains_key(&ex.id) => { // Receivers in method calls are always passed by ref. // // Here, the field a.b is in fact a closure. Eventually, this @@ -340,13 +343,22 @@ impl GatherLoanCtxt { fn guarantee_valid(@mut self, cmt: cmt, req_mutbl: ast::mutability, - scope_r: ty::Region) { + scope_r: ty::Region) + { + + let loan_kind = match req_mutbl { + m_mutbl => TotalTake, + m_imm => TotalFreeze, + m_const => Immobile + }; self.bccx.stats.guaranteed_paths += 1; - debug!("guarantee_valid(cmt=%s, req_mutbl=%s, scope_r=%s)", + debug!("guarantee_valid(cmt=%s, req_mutbl=%?, \ + loan_kind=%?, scope_r=%s)", self.bccx.cmt_to_repr(cmt), - self.bccx.mut_to_str(req_mutbl), + req_mutbl, + loan_kind, region_to_str(self.tcx(), scope_r)); let _i = indenter(); @@ -362,10 +374,10 @@ impl GatherLoanCtxt { // it within that scope, the loan will be detected and an // error will be reported. Some(_) => { - match self.bccx.loan(cmt, scope_r, req_mutbl) { + match loan::loan(self.bccx, cmt, scope_r, loan_kind) { Err(ref e) => { self.bccx.report((*e)); } Ok(move loans) => { - self.add_loans(cmt, req_mutbl, scope_r, move loans); + self.add_loans(cmt, loan_kind, scope_r, move loans); } } } @@ -378,7 +390,7 @@ impl GatherLoanCtxt { // pointer is desired, that is ok as long as we are pure) None => { let result: bckres = { - do self.check_mutbl(req_mutbl, cmt).chain |pc1| { + do self.check_mutbl(loan_kind, cmt).chain |pc1| { do self.bccx.preserve(cmt, scope_r, self.item_ub, self.root_ub).chain |pc2| { @@ -446,37 +458,41 @@ impl GatherLoanCtxt { // reqires an immutable pointer, but `f` lives in (aliased) // mutable memory. fn check_mutbl(@mut self, - req_mutbl: ast::mutability, + loan_kind: LoanKind, cmt: cmt) -> bckres { - debug!("check_mutbl(req_mutbl=%?, cmt.mutbl=%?)", - req_mutbl, cmt.mutbl); + debug!("check_mutbl(loan_kind=%?, cmt.mutbl=%?)", + loan_kind, cmt.mutbl); - if req_mutbl == m_const || req_mutbl == cmt.mutbl { - debug!("required is const or they are the same"); - Ok(PcOk) - } else { - let e = bckerr { cmt: cmt, code: err_mutbl(req_mutbl) }; - if req_mutbl == m_imm { - // if this is an @mut box, then it's generally OK to borrow as - // &imm; this will result in a write guard - if cmt.cat.is_mutable_box() { + match loan_kind { + Immobile => Ok(PcOk), + + TotalTake | PartialTake => { + if cmt.mutbl.is_mutable() { Ok(PcOk) } else { - // you can treat mutable things as imm if you are pure - debug!("imm required, must be pure"); + Err(bckerr { cmt: cmt, code: err_mutbl(loan_kind) }) + } + } + TotalFreeze | PartialFreeze => { + if cmt.mutbl.is_immutable() { + Ok(PcOk) + } else if cmt.cat.is_mutable_box() { + Ok(PcOk) + } else { + // Eventually: + let e = bckerr {cmt: cmt, + code: err_mutbl(loan_kind)}; Ok(PcIfPure(e)) } - } else { - Err(e) } } } fn add_loans(@mut self, cmt: cmt, - req_mutbl: ast::mutability, + loan_kind: LoanKind, scope_r: ty::Region, +loans: ~[Loan]) { if loans.len() == 0 { @@ -526,7 +542,7 @@ impl GatherLoanCtxt { self.add_loans_to_scope_id(scope_id, move loans); - if req_mutbl == m_imm && cmt.mutbl != m_imm { + if loan_kind.is_freeze() && !cmt.mutbl.is_immutable() { self.bccx.stats.loaned_paths_imm += 1; if self.tcx().sess.borrowck_note_loan() { @@ -542,7 +558,9 @@ impl GatherLoanCtxt { fn add_loans_to_scope_id(@mut self, scope_id: ast::node_id, +loans: ~[Loan]) { - debug!("adding %u loans to scope_id %?", loans.len(), scope_id); + debug!("adding %u loans to scope_id %?: %s", + loans.len(), scope_id, + str::connect(loans.map(|l| self.bccx.loan_to_repr(l)), ", ")); match self.req_maps.req_loan_map.find(&scope_id) { Some(req_loans) => { req_loans.push_all(loans); diff --git a/src/librustc/middle/borrowck/loan.rs b/src/librustc/middle/borrowck/loan.rs index da22b20fd1daa..3b6d735ae781f 100644 --- a/src/librustc/middle/borrowck/loan.rs +++ b/src/librustc/middle/borrowck/loan.rs @@ -44,6 +44,8 @@ FIXME #4730 --- much more needed, don't have time to write this all up now use core::prelude::*; use middle::borrowck::{Loan, bckerr, bckres, BorrowckCtxt, err_mutbl}; +use middle::borrowck::{LoanKind, TotalFreeze, PartialFreeze, + TotalTake, PartialTake, Immobile}; use middle::borrowck::{err_out_of_scope}; use middle::mem_categorization::{cat_arg, cat_binding, cat_discr, cat_comp}; use middle::mem_categorization::{cat_deref, cat_discr, cat_local, cat_self}; @@ -57,27 +59,26 @@ use core::result::{Err, Ok, Result}; use syntax::ast::{m_const, m_imm, m_mutbl}; use syntax::ast; -impl BorrowckCtxt { - fn loan(&self, +pub fn loan(bccx: @BorrowckCtxt, cmt: cmt, scope_region: ty::Region, - mutbl: ast::mutability) -> bckres<~[Loan]> { - let mut lc = LoanContext { - bccx: self, - scope_region: scope_region, - loans: ~[] - }; - match lc.loan(cmt, mutbl, true) { - Err(ref e) => return Err((*e)), - Ok(()) => {} - } - // XXX: Workaround for borrow check bug. - Ok(copy lc.loans) + loan_kind: LoanKind) -> bckres<~[Loan]> +{ + let mut lc = LoanContext { + bccx: bccx, + scope_region: scope_region, + loans: ~[] + }; + match lc.loan(cmt, loan_kind, true) { + Err(ref e) => return Err((*e)), + Ok(()) => {} } + // XXX: Workaround for borrow check bug. + Ok(copy lc.loans) } struct LoanContext { - bccx: &BorrowckCtxt, + bccx: @BorrowckCtxt, // the region scope for which we must preserve the memory scope_region: ty::Region, @@ -87,12 +88,13 @@ struct LoanContext { } impl LoanContext { - fn tcx(&mut self) -> ty::ctxt { self.bccx.tcx } + fn tcx(&self) -> ty::ctxt { self.bccx.tcx } fn loan(&mut self, cmt: cmt, - req_mutbl: ast::mutability, - owns_lent_data: bool) -> bckres<()> { + loan_kind: LoanKind, + owns_lent_data: bool) -> bckres<()> + { /*! * * The main routine. @@ -107,9 +109,9 @@ impl LoanContext { * discussion in `issue_loan()`. */ - debug!("loan(%s, %s)", + debug!("loan(%s, %?)", self.bccx.cmt_to_repr(cmt), - self.bccx.mut_to_str(req_mutbl)); + loan_kind); let _i = indenter(); // see stable() above; should only be called when `cmt` is lendable @@ -127,15 +129,16 @@ impl LoanContext { ~"rvalue with a non-none lp"); } cat_local(local_id) | cat_arg(local_id) | cat_self(local_id) => { - let local_scope_id = self.tcx().region_map.get(&local_id); - self.issue_loan(cmt, ty::re_scope(local_scope_id), req_mutbl, + // FIXME(#4903) + let local_scope_id = self.bccx.tcx.region_map.get(&local_id); + self.issue_loan(cmt, ty::re_scope(local_scope_id), loan_kind, owns_lent_data) } cat_stack_upvar(cmt) => { - self.loan(cmt, req_mutbl, owns_lent_data) + self.loan(cmt, loan_kind, owns_lent_data) } cat_discr(base, _) => { - self.loan(base, req_mutbl, owns_lent_data) + self.loan(base, loan_kind, owns_lent_data) } cat_comp(cmt_base, comp_field(_, m)) | cat_comp(cmt_base, comp_index(_, m)) => { @@ -145,13 +148,13 @@ impl LoanContext { // that case, it must also be embedded in an immutable // location, or else the whole structure could be // overwritten and the component along with it. - self.loan_stable_comp(cmt, cmt_base, req_mutbl, m, + self.loan_stable_comp(cmt, cmt_base, loan_kind, m, owns_lent_data) } cat_comp(cmt_base, comp_tuple) | cat_comp(cmt_base, comp_anon_field) => { // As above. - self.loan_stable_comp(cmt, cmt_base, req_mutbl, m_imm, + self.loan_stable_comp(cmt, cmt_base, loan_kind, m_imm, owns_lent_data) } cat_comp(cmt_base, comp_variant(enum_did)) => { @@ -159,10 +162,10 @@ impl LoanContext { // variants, because if the enum value is overwritten then // the memory changes type. if ty::enum_is_univariant(self.bccx.tcx, enum_did) { - self.loan_stable_comp(cmt, cmt_base, req_mutbl, m_imm, + self.loan_stable_comp(cmt, cmt_base, loan_kind, m_imm, owns_lent_data) } else { - self.loan_unstable_deref(cmt, cmt_base, req_mutbl, + self.loan_unstable_deref(cmt, cmt_base, loan_kind, owns_lent_data) } } @@ -170,7 +173,7 @@ impl LoanContext { // For unique pointers, the memory being pointed out is // unstable because if the unique pointer is overwritten // then the memory is freed. - self.loan_unstable_deref(cmt, cmt_base, req_mutbl, + self.loan_unstable_deref(cmt, cmt_base, loan_kind, owns_lent_data) } cat_deref(cmt_base, _, region_ptr(ast::m_mutbl, region)) => { @@ -178,8 +181,8 @@ impl LoanContext { // loan out the base as well as the main memory. For example, // if someone borrows `*b`, we want to borrow `b` as immutable // as well. - do self.loan(cmt_base, m_imm, false).chain |_| { - self.issue_loan(cmt, region, m_const, owns_lent_data) + do self.loan(cmt_base, TotalFreeze, false).chain |_| { + self.issue_loan(cmt, region, loan_kind, owns_lent_data) } } cat_deref(_, _, unsafe_ptr) | @@ -199,66 +202,38 @@ impl LoanContext { fn loan_stable_comp(&mut self, cmt: cmt, cmt_base: cmt, - req_mutbl: ast::mutability, + loan_kind: LoanKind, comp_mutbl: ast::mutability, - owns_lent_data: bool) -> bckres<()> { - // Determine the mutability that the base component must have, - // given the required mutability of the pointer (`req_mutbl`) - // and the declared mutability of the component (`comp_mutbl`). - // This is surprisingly subtle. - // - // Note that the *declared* mutability of the component is not - // necessarily the same as cmt.mutbl, since a component - // declared as immutable but embedded in a mutable context - // becomes mutable. It's best to think of comp_mutbl as being - // either MUTABLE or DEFAULT, not MUTABLE or IMMUTABLE. We - // should really patch up the AST to reflect this distinction. - // - // Let's consider the cases below: - // - // 1. mut required, mut declared: In this case, the base - // component must merely be const. The reason is that it - // does not matter if the base component is borrowed as - // mutable or immutable, as the mutability of the base - // component is overridden in the field declaration itself - // (see `compile-fail/borrowck-mut-field-imm-base.rs`) - // - // 2. mut required, imm declared: This would only be legal if - // the component is embeded in a mutable context. However, - // we detect mismatches between the mutability of the value - // as a whole and the required mutability in `issue_loan()` - // above. In any case, presuming that the component IS - // embedded in a mutable context, both the component and - // the base must be loaned as MUTABLE. This is to ensure - // that there is no loan of the base as IMMUTABLE, which - // would imply that the component must be IMMUTABLE too - // (see `compile-fail/borrowck-imm-field-imm-base.rs`). - // - // 3. mut required, const declared: this shouldn't really be - // possible, since I don't think you can declare a const - // field, but I guess if we DID permit such a declaration - // it would be equivalent to the case above? - // - // 4. imm required, * declared: In this case, the base must be - // immutable. This is true regardless of what was declared - // for this subcomponent, this if the base is mutable, the - // subcomponent must be mutable. - // (see `compile-fail/borrowck-imm-field-mut-base.rs`). - // - // 5. const required, * declared: In this case, the base need - // only be const, since we don't ultimately care whether - // the subcomponent is mutable or not. - let base_mutbl = match (req_mutbl, comp_mutbl) { - (m_mutbl, m_mutbl) => m_const, // (1) - (m_mutbl, _) => m_mutbl, // (2, 3) - (m_imm, _) => m_imm, // (4) - (m_const, _) => m_const // (5) + owns_lent_data: bool) -> bckres<()> + { + let base_kind = match (comp_mutbl, loan_kind) { + // Declared as "immutable" means: inherited mutability and + // hence mutable iff parent is mutable. So propagate + // mutability on up. + (m_imm, TotalFreeze) | (m_imm, PartialFreeze) => PartialFreeze, + (m_imm, TotalTake) | (m_imm, PartialTake) => PartialTake, + + // Declared as "mutable" means: always mutable no matter + // what the mutability of the base is. So that means we + // can weaken the condition on the base to PartialFreeze. + // This implies that the user could freeze the base, but + // that is ok since the even with an &T base, the mut + // field will still be considered mutable. + (_, TotalTake) | (_, PartialTake) | + (_, TotalFreeze) | (_, PartialFreeze) => { + PartialFreeze + } + + // If we just need to guarantee the value won't be moved, + // it doesn't matter what mutability the component was + // declared with. + (_, Immobile) => Immobile, }; - do self.loan(cmt_base, base_mutbl, owns_lent_data).chain |_ok| { + do self.loan(cmt_base, base_kind, owns_lent_data).chain |_ok| { // can use static for the scope because the base // determines the lifetime, ultimately - self.issue_loan(cmt, ty::re_static, req_mutbl, + self.issue_loan(cmt, ty::re_static, loan_kind, owns_lent_data) } } @@ -269,23 +244,23 @@ impl LoanContext { fn loan_unstable_deref(&mut self, cmt: cmt, cmt_base: cmt, - req_mutbl: ast::mutability, + loan_kind: LoanKind, owns_lent_data: bool) -> bckres<()> { // Variant components: the base must be immutable, because // if it is overwritten, the types of the embedded data // could change. - do self.loan(cmt_base, m_imm, owns_lent_data).chain |_| { + do self.loan(cmt_base, PartialFreeze, owns_lent_data).chain |_| { // can use static, as in loan_stable_comp() - self.issue_loan(cmt, ty::re_static, req_mutbl, + self.issue_loan(cmt, ty::re_static, loan_kind, owns_lent_data) } } fn issue_loan(&mut self, - cmt: cmt, - scope_ub: ty::Region, - req_mutbl: ast::mutability, - owns_lent_data: bool) -> bckres<()> { + +cmt: cmt, + +scope_ub: ty::Region, + +loan_kind: LoanKind, + +owns_lent_data: bool) -> bckres<()> { // Subtle: the `scope_ub` is the maximal lifetime of `cmt`. // Therefore, if `cmt` owns the data being lent, then the // scope of the loan must be less than `scope_ub`, or else the @@ -297,25 +272,15 @@ impl LoanContext { // reborrowed. if !owns_lent_data || - self.bccx.is_subregion_of(/*bad*/copy self.scope_region, - scope_ub) { - match req_mutbl { - m_mutbl => { - // We do not allow non-mutable data to be loaned - // out as mutable under any circumstances. - if cmt.mutbl != m_mutbl { - return Err(bckerr { - cmt:cmt, - code:err_mutbl(req_mutbl) - }); - } - } - m_const | m_imm => { - // However, mutable data can be loaned out as - // immutable (and any data as const). The - // `check_loans` pass will then guarantee that no - // writes occur for the duration of the loan. - } + self.bccx.is_subregion_of(self.scope_region, scope_ub) + { + if loan_kind.is_take() && !cmt.mutbl.is_mutable() { + // We do not allow non-mutable data to be "taken" + // under any circumstances. + return Err(bckerr { + cmt:cmt, + code:err_mutbl(loan_kind) + }); } self.loans.push(Loan { @@ -323,8 +288,9 @@ impl LoanContext { // loan process does not apply at all. lp: cmt.lp.get(), cmt: cmt, - mutbl: req_mutbl + kind: loan_kind }); + return Ok(()); } else { // The loan being requested lives longer than the data diff --git a/src/librustc/middle/borrowck/mod.rs b/src/librustc/middle/borrowck/mod.rs index 3d45ee461dcb7..dd8f889a05732 100644 --- a/src/librustc/middle/borrowck/mod.rs +++ b/src/librustc/middle/borrowck/mod.rs @@ -368,7 +368,7 @@ pub enum bckerr_code { err_mut_uniq, err_mut_variant, err_root_not_permitted, - err_mutbl(ast::mutability), + err_mutbl(LoanKind), err_out_of_root_scope(ty::Region, ty::Region), // superscope, subscope err_out_of_scope(ty::Region, ty::Region) // superscope, subscope } @@ -390,8 +390,19 @@ pub enum MoveError { // shorthand for something that fails with `bckerr` or succeeds with `T` pub type bckres = Result; +#[deriving_eq] +pub enum LoanKind { + TotalFreeze, // Entire path is frozen (borrowed as &T) + PartialFreeze, // Some subpath is frozen (borrowed as &T) + TotalTake, // Entire path is "taken" (borrowed as &mut T) + PartialTake, // Some subpath is "taken" (borrowed as &mut T) + Immobile // Path cannot be moved (borrowed as &const T) +} + /// a complete record of a loan that was granted -pub struct Loan {lp: @loan_path, cmt: cmt, mutbl: ast::mutability} +pub struct Loan {lp: @loan_path, + cmt: cmt, + kind: LoanKind} /// maps computed by `gather_loans` that are then used by `check_loans` /// @@ -420,6 +431,22 @@ pub fn save_and_restore_managed(save_and_restore_t: @mut T, move u } +impl LoanKind { + fn is_freeze(&self) -> bool { + match *self { + TotalFreeze | PartialFreeze => true, + _ => false + } + } + + fn is_take(&self) -> bool { + match *self { + TotalTake | PartialTake => true, + _ => false + } + } +} + /// Creates and returns a new root_map pub impl root_map_key : to_bytes::IterBytes { @@ -520,9 +547,9 @@ pub impl BorrowckCtxt { fn bckerr_to_str(&self, err: bckerr) -> ~str { match err.code { - err_mutbl(req) => { + err_mutbl(lk) => { fmt!("creating %s alias to %s", - self.mut_to_str(req), + self.loan_kind_to_str(lk), self.cmt_to_str(err.cmt)) } err_mut_uniq => { @@ -599,9 +626,17 @@ pub impl BorrowckCtxt { mc.mut_to_str(mutbl) } + fn loan_kind_to_str(&self, lk: LoanKind) -> ~str { + match lk { + TotalFreeze | PartialFreeze => ~"immutable", + TotalTake | PartialTake => ~"mutable", + Immobile => ~"read-only" + } + } + fn loan_to_repr(&self, loan: &Loan) -> ~str { - fmt!("Loan(lp=%?, cmt=%s, mutbl=%?)", - loan.lp, self.cmt_to_repr(loan.cmt), loan.mutbl) + fmt!("Loan(lp=%?, cmt=%s, kind=%?)", + loan.lp, self.cmt_to_repr(loan.cmt), loan.kind) } } diff --git a/src/librustc/middle/borrowck/preserve.rs b/src/librustc/middle/borrowck/preserve.rs index 1946ba09ec7bf..a123793e20b29 100644 --- a/src/librustc/middle/borrowck/preserve.rs +++ b/src/librustc/middle/borrowck/preserve.rs @@ -190,10 +190,10 @@ impl PreserveCtxt { // otherwise we have no guarantee the pointer will stay // live, so we must root the pointer (i.e., inc the ref // count) for the duration of the loan. - debug!("base.mutbl = %?", self.bccx.mut_to_str(base.mutbl)); + debug!("base.mutbl = %?", base.mutbl); if cmt.cat.derefs_through_mutable_box() { self.attempt_root(cmt, base, derefs) - } else if base.mutbl == m_imm { + } else if base.mutbl.is_immutable() { let non_rooting_ctxt = PreserveCtxt { root_managed_data: false, ..*self @@ -293,14 +293,11 @@ impl PreserveCtxt { // the base is preserved, but if we are not mutable then // purity is required Ok(PcOk) => { - match cmt_base.mutbl { - m_mutbl | m_const => { - Ok(PcIfPure(bckerr {cmt:cmt, code:code})) + if !cmt_base.mutbl.is_immutable() { + Ok(PcIfPure(bckerr {cmt:cmt, code:code})) + } else { + Ok(PcOk) } - m_imm => { - Ok(PcOk) - } - } } // the base requires purity too, that's fine @@ -375,7 +372,7 @@ impl PreserveCtxt { // scope_id;`. Though that would potentially re-introduce // the ICE. See #3511 for more details. let scope_to_use = if - self.bccx.stmt_map.contains_key_ref(&scope_id) { + self.bccx.stmt_map.contains_key(&scope_id) { // Root it in its parent scope, b/c // trans won't introduce a new scope for the // stmt diff --git a/src/librustc/middle/check_const.rs b/src/librustc/middle/check_const.rs index ad46d3b6f4de0..6cca576fa130b 100644 --- a/src/librustc/middle/check_const.rs +++ b/src/librustc/middle/check_const.rs @@ -102,7 +102,7 @@ pub fn check_expr(sess: Session, } expr_lit(@codemap::spanned {node: lit_str(_), _}) => { } expr_binary(_, _, _) | expr_unary(_, _) => { - if method_map.contains_key_ref(&e.id) { + if method_map.contains_key(&e.id) { sess.span_err(e.span, ~"user-defined operators are not \ allowed in constant expressions"); } diff --git a/src/librustc/middle/check_match.rs b/src/librustc/middle/check_match.rs index 6f9fe1edca5be..1a3e42511295e 100644 --- a/src/librustc/middle/check_match.rs +++ b/src/librustc/middle/check_match.rs @@ -59,7 +59,7 @@ pub fn expr_is_non_moving_lvalue(cx: @MatchCheckCtxt, expr: @expr) -> bool { return false; } - !cx.moves_map.contains_key_ref(&expr.id) + !cx.moves_map.contains_key(&expr.id) } pub fn check_expr(cx: @MatchCheckCtxt, ex: @expr, &&s: (), v: visit::vt<()>) { @@ -734,7 +734,7 @@ pub fn check_legality_of_move_bindings(cx: @MatchCheckCtxt, by_ref_span = Some(span); } bind_infer => { - if cx.moves_map.contains_key_ref(&id) { + if cx.moves_map.contains_key(&id) { any_by_move = true; } } @@ -774,7 +774,7 @@ pub fn check_legality_of_move_bindings(cx: @MatchCheckCtxt, if pat_is_binding(def_map, p) { match p.node { pat_ident(_, _, sub) => { - if cx.moves_map.contains_key_ref(&p.id) { + if cx.moves_map.contains_key(&p.id) { check_move(p, sub); } } @@ -800,7 +800,7 @@ pub fn check_legality_of_move_bindings(cx: @MatchCheckCtxt, behind_bad_pointer); if behind_bad_pointer && - cx.moves_map.contains_key_ref(&pat.id) + cx.moves_map.contains_key(&pat.id) { cx.tcx.sess.span_err( pat.span, diff --git a/src/librustc/middle/freevars.rs b/src/librustc/middle/freevars.rs index e609107721048..0d3b7c36f6d92 100644 --- a/src/librustc/middle/freevars.rs +++ b/src/librustc/middle/freevars.rs @@ -69,7 +69,7 @@ fn collect_freevars(def_map: resolve::DefMap, blk: ast::blk) } if i == depth { // Made it to end of loop let dnum = ast_util::def_id_of_def(def).node; - if !seen.contains_key_ref(&dnum) { + if !seen.contains_key(&dnum) { refs.push(@freevar_entry { def: def, span: expr.span, diff --git a/src/librustc/middle/lang_items.rs b/src/librustc/middle/lang_items.rs index b4500f87eb0b9..6bcc71514d4a3 100644 --- a/src/librustc/middle/lang_items.rs +++ b/src/librustc/middle/lang_items.rs @@ -391,7 +391,7 @@ impl LanguageItemCollector { } fn check_completeness() { - for self.item_refs.each_ref |&key, &item_ref| { + for self.item_refs.each |&key, &item_ref| { match self.items.items[item_ref] { None => { self.session.err(fmt!("no item found for `%s`", key)); diff --git a/src/librustc/middle/lint.rs b/src/librustc/middle/lint.rs index 843b01bdb35dc..487148ddd97d7 100644 --- a/src/librustc/middle/lint.rs +++ b/src/librustc/middle/lint.rs @@ -400,7 +400,7 @@ pub fn build_settings_crate(sess: session::Session, crate: @ast::crate) { sess: sess}); // Install defaults. - for cx.dict.each_value_ref |&spec| { + for cx.dict.each_value |&spec| { cx.set_level(spec.lint, spec.default); } diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs index 07de99870964f..c4612e7602417 100644 --- a/src/librustc/middle/mem_categorization.rs +++ b/src/librustc/middle/mem_categorization.rs @@ -108,6 +108,14 @@ pub enum special_kind { sk_heap_upvar } +#[deriving_eq] +pub enum MutabilityCategory { + McImmutable, // Immutable. + McReadOnly, // Read-only (`const`) + McDeclared, // Directly declared as mutable. + McInherited // Inherited from the fact that owner is mutable. +} + // a complete categorization of a value indicating where it originated // and how it is located, as well as the mutability of the memory in // which the value is stored. @@ -115,12 +123,12 @@ pub enum special_kind { // note: cmt stands for "categorized mutable type". #[deriving_eq] pub struct cmt_ { - id: ast::node_id, // id of expr/pat producing this value - span: span, // span of same expr/pat - cat: categorization, // categorization of expr - lp: Option<@loan_path>, // loan path for expr, if any - mutbl: ast::mutability, // mutability of expr as lvalue - ty: ty::t // type of the expr + id: ast::node_id, // id of expr/pat producing this value + span: span, // span of same expr/pat + cat: categorization, // categorization of expr + lp: Option<@loan_path>, // loan path for expr, if any + mutbl: MutabilityCategory, // mutability of expr as lvalue + ty: ty::t // type of the expr } pub type cmt = @cmt_; @@ -298,8 +306,55 @@ pub struct mem_categorization_ctxt { method_map: typeck::method_map, } -pub impl &mem_categorization_ctxt { - fn cat_expr(expr: @ast::expr) -> cmt { +impl ToStr for MutabilityCategory { + pure fn to_str(&self) -> ~str { + fmt!("%?", *self) + } +} + +impl MutabilityCategory { + static fn from_mutbl(m: ast::mutability) -> MutabilityCategory { + match m { + m_imm => McImmutable, + m_const => McReadOnly, + m_mutbl => McDeclared + } + } + + fn inherit(&self) -> MutabilityCategory { + match *self { + McImmutable => McImmutable, + McReadOnly => McReadOnly, + McDeclared => McInherited, + McInherited => McInherited + } + } + + fn is_mutable(&self) -> bool { + match *self { + McImmutable | McReadOnly => false, + McDeclared | McInherited => true + } + } + + fn is_immutable(&self) -> bool { + match *self { + McImmutable => true, + McReadOnly | McDeclared | McInherited => false + } + } + + fn to_user_str(&self) -> ~str { + match *self { + McDeclared | McInherited => ~"mutable", + McImmutable => ~"immutable", + McReadOnly => ~"const" + } + } +} + +pub impl mem_categorization_ctxt { + fn cat_expr(&self, expr: @ast::expr) -> cmt { match self.tcx.adjustments.find(&expr.id) { None => { // No adjustments. @@ -323,7 +378,8 @@ pub impl &mem_categorization_ctxt { } } - fn cat_expr_autoderefd(expr: @ast::expr, + fn cat_expr_autoderefd(&self, + expr: @ast::expr, adjustment: &ty::AutoAdjustment) -> cmt { let mut cmt = self.cat_expr_unadjusted(expr); for uint::range(1, adjustment.autoderefs+1) |deref| { @@ -332,7 +388,7 @@ pub impl &mem_categorization_ctxt { return cmt; } - fn cat_expr_unadjusted(expr: @ast::expr) -> cmt { + fn cat_expr_unadjusted(&self, expr: @ast::expr) -> cmt { debug!("cat_expr: id=%d expr=%s", expr.id, pprust::expr_to_str(expr, self.tcx.sess.intr())); @@ -340,7 +396,7 @@ pub impl &mem_categorization_ctxt { let expr_ty = tcx.ty(expr); match expr.node { ast::expr_unary(ast::deref, e_base) => { - if self.method_map.contains_key_ref(&expr.id) { + if self.method_map.contains_key(&expr.id) { return self.cat_rvalue(expr, expr_ty); } @@ -349,7 +405,7 @@ pub impl &mem_categorization_ctxt { } ast::expr_field(base, f_name, _) => { - if self.method_map.contains_key_ref(&expr.id) { + if self.method_map.contains_key(&expr.id) { return self.cat_method_ref(expr, expr_ty); } @@ -358,7 +414,7 @@ pub impl &mem_categorization_ctxt { } ast::expr_index(base, _) => { - if self.method_map.contains_key_ref(&expr.id) { + if self.method_map.contains_key(&expr.id) { return self.cat_rvalue(expr, expr_ty); } @@ -392,7 +448,8 @@ pub impl &mem_categorization_ctxt { } } - fn cat_def(id: ast::node_id, + fn cat_def(&self, + id: ast::node_id, span: span, expr_ty: ty::t, def: ast::def) -> cmt { @@ -409,7 +466,7 @@ pub impl &mem_categorization_ctxt { span:span, cat:cat_special(sk_static_item), lp:None, - mutbl:m_imm, + mutbl: McImmutable, ty:expr_ty } } @@ -420,7 +477,7 @@ pub impl &mem_categorization_ctxt { // m: mutability of the argument // lp: loan path, must be none for aliasable things - let m = if mutbl {m_mutbl} else {m_imm}; + let m = if mutbl {McDeclared} else {McImmutable}; let lp = match ty::resolved_mode(self.tcx, mode) { ast::by_copy => Some(@lp_arg(vid)), ast::by_ref => None, @@ -438,7 +495,7 @@ pub impl &mem_categorization_ctxt { span:span, cat:cat_arg(vid), lp:lp, - mutbl:m, + mutbl: m, ty:expr_ty } } @@ -458,7 +515,7 @@ pub impl &mem_categorization_ctxt { span:span, cat:cat, lp:loan_path, - mutbl:m_imm, + mutbl: McImmutable, ty:expr_ty } } @@ -485,7 +542,7 @@ pub impl &mem_categorization_ctxt { span:span, cat:cat_special(sk_heap_upvar), lp:None, - mutbl:m_imm, + mutbl:McImmutable, ty:expr_ty } } @@ -493,7 +550,7 @@ pub impl &mem_categorization_ctxt { } ast::def_local(vid, mutbl) => { - let m = if mutbl {m_mutbl} else {m_imm}; + let m = if mutbl {McDeclared} else {McImmutable}; @cmt_ { id:id, span:span, @@ -511,14 +568,15 @@ pub impl &mem_categorization_ctxt { span:span, cat:cat_local(vid), lp:Some(@lp_local(vid)), - mutbl:m_imm, + mutbl:McImmutable, ty:expr_ty } } } } - fn cat_variant(arg: N, + fn cat_variant(&self, + arg: N, enum_did: ast::def_id, cmt: cmt) -> cmt { @cmt_ { @@ -526,18 +584,18 @@ pub impl &mem_categorization_ctxt { span: arg.span(), cat: cat_comp(cmt, comp_variant(enum_did)), lp: cmt.lp.map(|l| @lp_comp(*l, comp_variant(enum_did)) ), - mutbl: cmt.mutbl, // imm iff in an immutable context + mutbl: cmt.mutbl.inherit(), ty: self.tcx.ty(arg) } } - fn cat_rvalue(elt: N, expr_ty: ty::t) -> cmt { + fn cat_rvalue(&self, elt: N, expr_ty: ty::t) -> cmt { @cmt_ { id:elt.id(), span:elt.span(), cat:cat_rvalue, lp:None, - mutbl:m_imm, + mutbl:McImmutable, ty:expr_ty } } @@ -546,17 +604,21 @@ pub impl &mem_categorization_ctxt { /// component is inherited from the base it is a part of. For /// example, a record field is mutable if it is declared mutable /// or if the container is mutable. - fn inherited_mutability(base_m: ast::mutability, - comp_m: ast::mutability) -> ast::mutability { + fn inherited_mutability(&self, + base_m: MutabilityCategory, + comp_m: ast::mutability) -> MutabilityCategory + { match comp_m { - m_imm => {base_m} // imm: as mutable as the container - m_mutbl | m_const => {comp_m} + m_imm => base_m.inherit(), + m_const => McReadOnly, + m_mutbl => McDeclared } } /// The `field_id` parameter is the ID of the enclosing expression or /// pattern. It is used to determine which variant of an enum is in use. - fn cat_field(node: N, + fn cat_field(&self, + node: N, base_cmt: cmt, f_name: ast::ident, field_id: ast::node_id) -> cmt { @@ -584,7 +646,8 @@ pub impl &mem_categorization_ctxt { } } - fn cat_deref_fn(node: N, + fn cat_deref_fn(&self, + node: N, base_cmt: cmt, deref_cnt: uint) -> cmt { @@ -594,11 +657,13 @@ pub impl &mem_categorization_ctxt { // know what type lies at the other end, so we just call it // `()` (the empty tuple). - let mt = ty::mt {ty: ty::mk_tup(self.tcx, ~[]), mutbl: m_imm}; + let mt = ty::mt {ty: ty::mk_tup(self.tcx, ~[]), + mutbl: m_imm}; return self.cat_deref_common(node, base_cmt, deref_cnt, mt); } - fn cat_deref(node: N, + fn cat_deref(&self, + node: N, base_cmt: cmt, deref_cnt: uint) -> cmt { @@ -615,7 +680,8 @@ pub impl &mem_categorization_ctxt { return self.cat_deref_common(node, base_cmt, deref_cnt, mt); } - fn cat_deref_common(node: N, + fn cat_deref_common(&self, + node: N, base_cmt: cmt, deref_cnt: uint, mt: ty::mt) -> cmt @@ -644,7 +710,7 @@ pub impl &mem_categorization_ctxt { self.inherited_mutability(base_cmt.mutbl, mt.mutbl) } gc_ptr(*) | region_ptr(_, _) | unsafe_ptr => { - mt.mutbl + MutabilityCategory::from_mutbl(mt.mutbl) } }; @@ -673,7 +739,9 @@ pub impl &mem_categorization_ctxt { } } - fn cat_index(elt: N, base_cmt: cmt) -> cmt { + fn cat_index(&self, + elt: N, + base_cmt: cmt) -> cmt { let mt = match ty::index(self.tcx, base_cmt.ty) { Some(mt) => mt, None => { @@ -700,7 +768,7 @@ pub impl &mem_categorization_ctxt { self.inherited_mutability(base_cmt.mutbl, mt.mutbl) } gc_ptr(_) | region_ptr(_, _) | unsafe_ptr => { - mt.mutbl + MutabilityCategory::from_mutbl(mt.mutbl) } }; @@ -714,21 +782,21 @@ pub impl &mem_categorization_ctxt { ty:mt.ty }; - comp(elt, deref_cmt, base_cmt.ty, m, mt.ty) + comp(elt, deref_cmt, base_cmt.ty, m, mt) } deref_comp(_) => { // fixed-length vectors have no deref let m = self.inherited_mutability(base_cmt.mutbl, mt.mutbl); - comp(elt, base_cmt, base_cmt.ty, m, mt.ty) + comp(elt, base_cmt, base_cmt.ty, m, mt) } }; fn comp(elt: N, of_cmt: cmt, - vect: ty::t, mutbl: ast::mutability, - ty: ty::t) -> cmt + vect: ty::t, mutbl: MutabilityCategory, + mt: ty::mt) -> cmt { - let comp = comp_index(vect, mutbl); + let comp = comp_index(vect, mt.mutbl); let index_lp = of_cmt.lp.map(|lp| @lp_comp(*lp, comp) ); @cmt_ { id:elt.id(), @@ -736,46 +804,55 @@ pub impl &mem_categorization_ctxt { cat:cat_comp(of_cmt, comp), lp:index_lp, mutbl:mutbl, - ty:ty + ty:mt.ty } } } - fn cat_tuple_elt(elt: N, cmt: cmt) -> cmt { + fn cat_tuple_elt(&self, + elt: N, + cmt: cmt) -> cmt { @cmt_ { id: elt.id(), span: elt.span(), cat: cat_comp(cmt, comp_tuple), lp: cmt.lp.map(|l| @lp_comp(*l, comp_tuple) ), - mutbl: cmt.mutbl, // imm iff in an immutable context + mutbl: cmt.mutbl.inherit(), ty: self.tcx.ty(elt) } } - fn cat_anon_struct_field(elt: N, cmt: cmt) -> cmt { + fn cat_anon_struct_field(&self, + elt: N, + cmt: cmt) -> cmt { @cmt_ { id: elt.id(), span: elt.span(), cat: cat_comp(cmt, comp_anon_field), lp: cmt.lp.map(|l| @lp_comp(*l, comp_anon_field)), - mutbl: cmt.mutbl, // imm iff in an immutable context + mutbl: cmt.mutbl.inherit(), ty: self.tcx.ty(elt) } } - fn cat_method_ref(expr: @ast::expr, expr_ty: ty::t) -> cmt { + fn cat_method_ref(&self, + expr: @ast::expr, + expr_ty: ty::t) -> cmt { @cmt_ { id:expr.id, span:expr.span, cat:cat_special(sk_method), lp:None, - mutbl:m_imm, + mutbl:McImmutable, ty:expr_ty } } - fn cat_pattern(cmt: cmt, pat: @ast::pat, op: fn(cmt, @ast::pat)) { - + fn cat_pattern(&self, + cmt: cmt, + pat: @ast::pat, + op: fn(cmt, @ast::pat)) + { // Here, `cmt` is the categorization for the value being // matched and pat is the pattern it is being matched against. // @@ -901,7 +978,7 @@ pub impl &mem_categorization_ctxt { } } - fn cat_to_repr(cat: categorization) -> ~str { + fn cat_to_repr(&self, cat: categorization) -> ~str { match cat { cat_special(sk_method) => ~"method", cat_special(sk_static_item) => ~"static_item", @@ -924,7 +1001,7 @@ pub impl &mem_categorization_ctxt { } } - fn mut_to_str(mutbl: ast::mutability) -> ~str { + fn mut_to_str(&self, mutbl: ast::mutability) -> ~str { match mutbl { m_mutbl => ~"mutable", m_const => ~"const", @@ -932,7 +1009,7 @@ pub impl &mem_categorization_ctxt { } } - fn ptr_sigil(ptr: ptr_kind) -> ~str { + fn ptr_sigil(&self, ptr: ptr_kind) -> ~str { match ptr { uniq_ptr => ~"~", gc_ptr(_) => ~"@", @@ -941,7 +1018,7 @@ pub impl &mem_categorization_ctxt { } } - fn comp_to_repr(comp: comp_kind) -> ~str { + fn comp_to_repr(&self, comp: comp_kind) -> ~str { match comp { comp_field(fld, _) => self.tcx.sess.str_of(fld), comp_index(*) => ~"[]", @@ -951,7 +1028,7 @@ pub impl &mem_categorization_ctxt { } } - fn lp_to_str(lp: @loan_path) -> ~str { + fn lp_to_str(&self, lp: @loan_path) -> ~str { match *lp { lp_local(node_id) => { fmt!("local(%d)", node_id) @@ -971,17 +1048,17 @@ pub impl &mem_categorization_ctxt { } } - fn cmt_to_repr(cmt: cmt) -> ~str { - fmt!("{%s id:%d m:%s lp:%s ty:%s}", + fn cmt_to_repr(&self, cmt: cmt) -> ~str { + fmt!("{%s id:%d m:%? lp:%s ty:%s}", self.cat_to_repr(cmt.cat), cmt.id, - self.mut_to_str(cmt.mutbl), + cmt.mutbl, cmt.lp.map_default(~"none", |p| self.lp_to_str(*p) ), ty_to_str(self.tcx, cmt.ty)) } - fn cmt_to_str(cmt: cmt) -> ~str { - let mut_str = self.mut_to_str(cmt.mutbl); + fn cmt_to_str(&self, cmt: cmt) -> ~str { + let mut_str = cmt.mutbl.to_user_str(); match cmt.cat { cat_special(sk_method) => ~"method", cat_special(sk_static_item) => ~"static item", @@ -1016,7 +1093,7 @@ pub impl &mem_categorization_ctxt { } } - fn region_to_str(r: ty::Region) -> ~str { + fn region_to_str(&self, r: ty::Region) -> ~str { region_to_str(self.tcx, r) } } diff --git a/src/librustc/middle/moves.rs b/src/librustc/middle/moves.rs index 0d32bb7ecf6d7..b23066c1d9692 100644 --- a/src/librustc/middle/moves.rs +++ b/src/librustc/middle/moves.rs @@ -668,7 +668,7 @@ impl VisitContext { arg_exprs: &[@expr], visitor: vt) -> bool { - if !self.method_map.contains_key_ref(&expr.id) { + if !self.method_map.contains_key(&expr.id) { return false; } @@ -799,7 +799,7 @@ impl VisitContext { for arm.pats.each |pat| { let mut found = false; do pat_bindings(self.tcx.def_map, *pat) |_, node_id, _, _| { - if moves_map.contains_key_ref(&node_id) { + if moves_map.contains_key(&node_id) { found = true; } } diff --git a/src/librustc/middle/region.rs b/src/librustc/middle/region.rs index 49b373fe6b1ae..5b2d3c9bb96cd 100644 --- a/src/librustc/middle/region.rs +++ b/src/librustc/middle/region.rs @@ -296,7 +296,7 @@ pub fn resolve_expr(expr: @ast::expr, cx: ctxt, visitor: visit::vt) { _ => {} }; - if new_cx.root_exprs.contains_key_ref(&expr.id) { + if new_cx.root_exprs.contains_key(&expr.id) { new_cx.parent = Some(expr.id); } @@ -840,7 +840,7 @@ pub fn determine_rp_in_crate(sess: Session, debug!("%s", { debug!("Region variance results:"); let region_paramd_items = cx.region_paramd_items; - for region_paramd_items.each_ref |&key, &value| { + for region_paramd_items.each |&key, &value| { debug!("item %? (%s) is parameterized with variance %?", key, ast_map::node_id_to_str(ast_map, key, diff --git a/src/librustc/middle/resolve.rs b/src/librustc/middle/resolve.rs index 51df1d05d9e0c..ba550dbbde8ed 100644 --- a/src/librustc/middle/resolve.rs +++ b/src/librustc/middle/resolve.rs @@ -1942,7 +1942,7 @@ pub impl Resolver { self.module_to_str(module_)); self.resolve_imports_for_module(module_); - for module_.children.each_value_ref |&child_node| { + for module_.children.each_value |&child_node| { match child_node.get_module_if_available() { None => { // Nothing to do. @@ -1953,7 +1953,7 @@ pub impl Resolver { } } - for module_.anonymous_children.each_value_ref |&child_module| { + for module_.anonymous_children.each_value |&child_module| { self.resolve_imports_for_module_subtree(child_module); } } @@ -2241,7 +2241,7 @@ pub impl Resolver { } // We've successfully resolved the import. Write the results in. - assert module_.import_resolutions.contains_key_ref(&target); + assert module_.import_resolutions.contains_key(&target); let import_resolution = module_.import_resolutions.get(&target); match value_result { @@ -2400,7 +2400,7 @@ pub impl Resolver { } // We've successfully resolved the import. Write the results in. - assert module_.import_resolutions.contains_key_ref(&target); + assert module_.import_resolutions.contains_key(&target); let import_resolution = module_.import_resolutions.get(&target); match module_result { @@ -2461,7 +2461,7 @@ pub impl Resolver { assert containing_module.glob_count == 0; // Add all resolved imports from the containing module. - for containing_module.import_resolutions.each_ref + for containing_module.import_resolutions.each |&ident, &target_import_resolution| { debug!("(resolving glob import) writing module resolution \ @@ -2512,7 +2512,7 @@ pub impl Resolver { } // Add all children from the containing module. - for containing_module.children.each_ref |&ident, &name_bindings| { + for containing_module.children.each |&ident, &name_bindings| { let mut dest_import_resolution; match module_.import_resolutions.find(&ident) { None => { @@ -3182,7 +3182,7 @@ pub impl Resolver { } // Descend into children and anonymous children. - for module_.children.each_value_ref |&child_node| { + for module_.children.each_value |&child_node| { match child_node.get_module_if_available() { None => { // Continue. @@ -3193,7 +3193,7 @@ pub impl Resolver { } } - for module_.anonymous_children.each_value_ref |&module_| { + for module_.anonymous_children.each_value |&module_| { self.report_unresolved_imports(module_); } } @@ -3238,7 +3238,7 @@ pub impl Resolver { self.record_exports_for_module(module_); - for module_.children.each_value_ref |&child_name_bindings| { + for module_.children.each_value |&child_name_bindings| { match child_name_bindings.get_module_if_available() { None => { // Nothing to do. @@ -3249,7 +3249,7 @@ pub impl Resolver { } } - for module_.anonymous_children.each_value_ref |&child_module| { + for module_.anonymous_children.each_value |&child_module| { self.record_exports_for_module_subtree(child_module); } } @@ -3297,7 +3297,7 @@ pub impl Resolver { } fn add_exports_for_module(exports2: &mut ~[Export2], module_: @Module) { - for module_.children.each_ref |ident, namebindings| { + for module_.children.each |ident, namebindings| { debug!("(computing exports) maybe export '%s'", self.session.str_of(*ident)); self.add_exports_of_namebindings(&mut *exports2, @@ -3312,7 +3312,7 @@ pub impl Resolver { false); } - for module_.import_resolutions.each_ref |ident, importresolution| { + for module_.import_resolutions.each |ident, importresolution| { if importresolution.privacy != Public { debug!("(computing exports) not reexporting private `%s`", self.session.str_of(*ident)); @@ -4102,7 +4102,7 @@ pub impl Resolver { for arm.pats.eachi() |i, p| { let map_i = self.binding_mode_map(*p); - for map_0.each_ref |&key, &binding_0| { + for map_0.each |&key, &binding_0| { match map_i.find(&key) { None => { self.session.span_err( @@ -4123,8 +4123,8 @@ pub impl Resolver { } } - for map_i.each_ref |&key, &binding| { - if !map_0.contains_key_ref(&key) { + for map_i.each |&key, &binding| { + if !map_0.contains_key(&key) { self.session.span_err( binding.span, fmt!("variable `%s` from pattern #%u is \ @@ -4353,7 +4353,7 @@ pub impl Resolver { match bindings_list { Some(bindings_list) - if !bindings_list.contains_key_ref(&ident) + if !bindings_list.contains_key(&ident) => { let last_rib = (*self.value_ribs).last(); last_rib.bindings.insert(ident, @@ -4426,18 +4426,18 @@ pub impl Resolver { pat_struct(path, _, _) => { match self.resolve_path(path, TypeNS, false, visitor) { Some(def_ty(class_id)) - if self.structs.contains_key_ref(&class_id) + if self.structs.contains_key(&class_id) => { let class_def = def_struct(class_id); self.record_def(pattern.id, class_def); } Some(definition @ def_struct(class_id)) - if self.structs.contains_key_ref(&class_id) + if self.structs.contains_key(&class_id) => { self.record_def(pattern.id, definition); } Some(definition @ def_variant(_, variant_id)) - if self.structs.contains_key_ref(&variant_id) + if self.structs.contains_key(&variant_id) => { self.record_def(pattern.id, definition); } @@ -4886,12 +4886,12 @@ pub impl Resolver { match self.resolve_path(path, TypeNS, false, visitor) { Some(def_ty(class_id)) | Some(def_struct(class_id)) - if self.structs.contains_key_ref(&class_id) => { + if self.structs.contains_key(&class_id) => { let class_def = def_struct(class_id); self.record_def(expr.id, class_def); } Some(definition @ def_variant(_, class_id)) - if self.structs.contains_key_ref(&class_id) => { + if self.structs.contains_key(&class_id) => { self.record_def(expr.id, definition); } _ => { @@ -5035,7 +5035,7 @@ pub impl Resolver { } // Look for trait children. - for search_module.children.each_value_ref |&child_name_bindings| { + for search_module.children.each_value |&child_name_bindings| { match child_name_bindings.def_for_namespace(TypeNS) { Some(def) => { match def { @@ -5055,7 +5055,7 @@ pub impl Resolver { } // Look for imports. - for search_module.import_resolutions.each_value_ref + for search_module.import_resolutions.each_value |&import_resolution| { match import_resolution.target_for_namespace(TypeNS) { @@ -5115,7 +5115,7 @@ pub impl Resolver { self.session.str_of(name)); match self.trait_info.find(&trait_def_id) { - Some(trait_info) if trait_info.contains_key_ref(&name) => { + Some(trait_info) if trait_info.contains_key(&name) => { debug!("(adding trait info if containing method) found trait \ %d:%d for method '%s'", trait_def_id.crate, @@ -5223,7 +5223,7 @@ pub impl Resolver { self.check_for_unused_imports_in_module(module_); - for module_.children.each_value_ref |&child_name_bindings| { + for module_.children.each_value |&child_name_bindings| { match (*child_name_bindings).get_module_if_available() { None => { // Nothing to do. @@ -5235,13 +5235,13 @@ pub impl Resolver { } } - for module_.anonymous_children.each_value_ref |&child_module| { + for module_.anonymous_children.each_value |&child_module| { self.check_for_unused_imports_in_module_subtree(child_module); } } fn check_for_unused_imports_in_module(module_: @Module) { - for module_.import_resolutions.each_value_ref |&import_resolution| { + for module_.import_resolutions.each_value |&import_resolution| { // Ignore dummy spans for things like automatically injected // imports for the prelude, and also don't warn about the same // import statement being unused more than once. @@ -5306,12 +5306,12 @@ pub impl Resolver { debug!("Dump of module `%s`:", self.module_to_str(module_)); debug!("Children:"); - for module_.children.each_key_ref |&name| { + for module_.children.each_key |&name| { debug!("* %s", self.session.str_of(name)); } debug!("Import resolutions:"); - for module_.import_resolutions.each_ref |&name, &import_resolution| { + for module_.import_resolutions.each |&name, &import_resolution| { let mut value_repr; match (*import_resolution).target_for_namespace(ValueNS) { None => { value_repr = ~""; } diff --git a/src/librustc/middle/trans/_match.rs b/src/librustc/middle/trans/_match.rs index ebd6d9f905642..2369a63e54489 100644 --- a/src/librustc/middle/trans/_match.rs +++ b/src/librustc/middle/trans/_match.rs @@ -1096,7 +1096,7 @@ pub fn store_non_ref_bindings(bcx: block, */ let mut bcx = bcx; - for data.bindings_map.each_value_ref |&binding_info| { + for data.bindings_map.each_value |&binding_info| { match binding_info.trmode { TrByValue(is_move, lldest) => { let llval = Load(bcx, binding_info.llmatch); // get a T* @@ -1130,7 +1130,7 @@ pub fn insert_lllocals(bcx: block, * the `fcx.lllocals` map. If add_cleans is true, then adds cleanups for * the bindings. */ - for data.bindings_map.each_value_ref |&binding_info| { + for data.bindings_map.each_value |&binding_info| { let llval = match binding_info.trmode { // By value bindings: use the stack slot that we // copied/moved the value into @@ -1203,7 +1203,7 @@ pub fn compile_guard(bcx: block, fn drop_bindings(bcx: block, data: &ArmData) -> block { let mut bcx = bcx; - for data.bindings_map.each_value_ref |&binding_info| { + for data.bindings_map.each_value |&binding_info| { match binding_info.trmode { TrByValue(_, llval) => { bcx = glue::drop_ty(bcx, llval, binding_info.ty); @@ -1598,7 +1598,7 @@ pub fn trans_match_inner(scope_cx: block, // but during matching we need to store a *T as explained // above let is_move = - scope_cx.ccx().maps.moves_map.contains_key_ref(&p_id); + scope_cx.ccx().maps.moves_map.contains_key(&p_id); llmatch = alloca(bcx, T_ptr(llvariable_ty)); trmode = TrByValue(is_move, alloca(bcx, llvariable_ty)); } diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs index acf33434b2f8b..93c16b159f5c0 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -169,7 +169,7 @@ pub fn get_extern_fn(externs: ExternMap, name: @str, cc: lib::llvm::CallConv, ty: TypeRef) -> ValueRef { - if externs.contains_key_ref(&name) { return externs.get(&name); } + if externs.contains_key(&name) { return externs.get(&name); } let f = decl_fn(llmod, name, cc, ty); externs.insert(name, f); return f; @@ -178,7 +178,7 @@ pub fn get_extern_fn(externs: ExternMap, pub fn get_extern_const(externs: ExternMap, llmod: ModuleRef, name: @str, ty: TypeRef) -> ValueRef { unsafe { - if externs.contains_key_ref(&name) { return externs.get(&name); } + if externs.contains_key(&name) { return externs.get(&name); } let c = str::as_c_str(name, |buf| { llvm::LLVMAddGlobal(llmod, ty, buf) }); @@ -448,7 +448,7 @@ pub fn set_glue_inlining(f: ValueRef, t: ty::t) { // silently mangles such symbols, breaking our linkage model. pub fn note_unique_llvm_symbol(ccx: @crate_ctxt, +sym: ~str) { // XXX: Bad copy. - if ccx.all_llvm_symbols.contains_key_ref(&sym) { + if ccx.all_llvm_symbols.contains_key(&sym) { ccx.sess.bug(~"duplicate LLVM symbol: " + sym); } ccx.all_llvm_symbols.insert(sym, ()); @@ -1139,7 +1139,9 @@ pub fn trans_stmt(cx: block, s: ast::stmt) -> block { } } } - ast::decl_item(i) => trans_item(cx.fcx.ccx, *i) + ast::decl_item(i) => { + trans_item(cx.fcx.ccx, *i, DontForceInternal) + } } } ast::stmt_mac(*) => cx.tcx().sess.bug(~"unexpanded macro") @@ -1972,10 +1974,14 @@ pub fn trans_struct_dtor(ccx: @crate_ctxt, lldecl } -pub fn trans_enum_def(ccx: @crate_ctxt, enum_definition: ast::enum_def, - id: ast::node_id, degen: bool, - path: @ast_map::path, vi: @~[ty::VariantInfo], - i: &mut uint) { +pub fn trans_enum_def(ccx: @crate_ctxt, + enum_definition: ast::enum_def, + id: ast::node_id, + degen: bool, + path: @ast_map::path, + vi: @~[ty::VariantInfo], + i: &mut uint, + force_internal: ForceInternalFlag) { for vec::each(enum_definition.variants) |variant| { let disr_val = vi[*i].disr_val; *i += 1; @@ -1983,6 +1989,9 @@ pub fn trans_enum_def(ccx: @crate_ctxt, enum_definition: ast::enum_def, match variant.node.kind { ast::tuple_variant_kind(ref args) if args.len() > 0 => { let llfn = get_item_val(ccx, variant.node.id); + if force_internal == ForceInternal { + internalize_item(llfn); + } trans_enum_variant(ccx, id, *variant, /*bad*/copy *args, disr_val, degen, None, llfn); } @@ -1990,8 +1999,11 @@ pub fn trans_enum_def(ccx: @crate_ctxt, enum_definition: ast::enum_def, // Nothing to do. } ast::struct_variant_kind(struct_def) => { - trans_struct_def(ccx, struct_def, path, - variant.node.id); + trans_struct_def(ccx, + struct_def, + path, + variant.node.id, + force_internal); } ast::enum_variant_kind(ref enum_definition) => { trans_enum_def(ccx, @@ -2000,13 +2012,28 @@ pub fn trans_enum_def(ccx: @crate_ctxt, enum_definition: ast::enum_def, degen, path, vi, - &mut *i); + &mut *i, + force_internal); } } } } -pub fn trans_item(ccx: @crate_ctxt, item: ast::item) { +#[deriving_eq] +pub enum ForceInternalFlag { + DontForceInternal, + ForceInternal, +} + +// Marks the LLVM ValueRef corresponding to the given item as internal, so +// that if it gets inlined away LLVM won't bother translating it. +pub fn internalize_item(llval: ValueRef) { + lib::llvm::SetLinkage(llval, lib::llvm::InternalLinkage); +} + +pub fn trans_item(ccx: @crate_ctxt, + item: ast::item, + force_internal: ForceInternalFlag) { let _icx = ccx.insn_ctxt("trans_item"); let path = match ccx.tcx.items.get(&item.id) { ast_map::node_item(_, p) => p, @@ -2017,6 +2044,9 @@ pub fn trans_item(ccx: @crate_ctxt, item: ast::item) { ast::item_fn(ref decl, purity, ref tps, ref body) => { if purity == ast::extern_fn { let llfndecl = get_item_val(ccx, item.id); + if force_internal == ForceInternal { + internalize_item(llfndecl); + } foreign::trans_foreign_fn(ccx, vec::append( /*bad*/copy *path, @@ -2024,6 +2054,9 @@ pub fn trans_item(ccx: @crate_ctxt, item: ast::item) { decl, body, llfndecl, item.id); } else if tps.is_empty() { let llfndecl = get_item_val(ccx, item.id); + if force_internal == ForceInternal { + internalize_item(llfndecl); + } trans_fn(ccx, vec::append(/*bad*/copy *path, ~[path_name(item.ident)]), decl, body, llfndecl, no_self, None, item.id, None); @@ -2032,7 +2065,7 @@ pub fn trans_item(ccx: @crate_ctxt, item: ast::item) { match stmt.node { ast::stmt_decl(@codemap::spanned { node: ast::decl_item(i), _ }, _) => { - trans_item(ccx, *i); + trans_item(ccx, *i, DontForceInternal); } _ => () } @@ -2040,8 +2073,14 @@ pub fn trans_item(ccx: @crate_ctxt, item: ast::item) { } } ast::item_impl(tps, _, _, ms) => { - meth::trans_impl(ccx, /*bad*/copy *path, item.ident, ms, tps, None, - item.id); + meth::trans_impl(ccx, + /*bad*/copy *path, + item.ident, + ms, + tps, + None, + item.id, + force_internal); } ast::item_mod(m) => { trans_mod(ccx, m); @@ -2051,8 +2090,14 @@ pub fn trans_item(ccx: @crate_ctxt, item: ast::item) { let degen = (*enum_definition).variants.len() == 1u; let vi = ty::enum_variants(ccx.tcx, local_def(item.id)); let mut i = 0; - trans_enum_def(ccx, (*enum_definition), item.id, - degen, path, vi, &mut i); + trans_enum_def(ccx, + *enum_definition, + item.id, + degen, + path, + vi, + &mut i, + force_internal); } } ast::item_const(_, expr) => consts::trans_const(ccx, expr, item.id), @@ -2066,16 +2111,22 @@ pub fn trans_item(ccx: @crate_ctxt, item: ast::item) { } ast::item_struct(struct_def, tps) => { if tps.is_empty() { - trans_struct_def(ccx, struct_def, path, item.id); + trans_struct_def(ccx, + struct_def, + path, + item.id, + DontForceInternal); } } _ => {/* fall through */ } } } -pub fn trans_struct_def(ccx: @crate_ctxt, struct_def: @ast::struct_def, +pub fn trans_struct_def(ccx: @crate_ctxt, + struct_def: @ast::struct_def, path: @ast_map::path, - id: ast::node_id) { + id: ast::node_id, + force_internal: ForceInternalFlag) { // Translate the destructor. do option::iter(&struct_def.dtor) |dtor| { trans_struct_dtor(ccx, /*bad*/copy *path, &dtor.node.body, @@ -2088,6 +2139,9 @@ pub fn trans_struct_def(ccx: @crate_ctxt, struct_def: @ast::struct_def, // otherwise this is a unit-like struct. Some(ctor_id) if struct_def.fields.len() > 0 => { let llfndecl = get_item_val(ccx, ctor_id); + if force_internal == ForceInternal { + internalize_item(llfndecl); + } trans_tuple_struct(ccx, /*bad*/copy struct_def.fields, ctor_id, None, llfndecl); } @@ -2103,7 +2157,7 @@ pub fn trans_struct_def(ccx: @crate_ctxt, struct_def: @ast::struct_def, pub fn trans_mod(ccx: @crate_ctxt, m: ast::_mod) { let _icx = ccx.insn_ctxt("trans_mod"); for vec::each(m.items) |item| { - trans_item(ccx, **item); + trans_item(ccx, **item, DontForceInternal); } } @@ -2477,8 +2531,9 @@ pub fn get_item_val(ccx: @crate_ctxt, id: ast::node_id) -> ValueRef { ccx.sess.bug(~"get_item_val(): unexpected variant") } }; - if !(exprt || ccx.reachable.contains_key_ref(&id)) { - lib::llvm::SetLinkage(val, lib::llvm::InternalLinkage); + if !*ccx.sess.building_library || + (!exprt && !ccx.reachable.contains_key(&id)) { + internalize_item(val); } ccx.item_vals.insert(id, val); val @@ -2800,7 +2855,7 @@ pub fn create_module_map(ccx: @crate_ctxt) -> ValueRef { lib::llvm::SetLinkage(map, lib::llvm::InternalLinkage); } let mut elts: ~[ValueRef] = ~[]; - for ccx.module_data.each_ref |&key, &val| { + for ccx.module_data.each |&key, &val| { let elt = C_struct(~[p2i(ccx, C_cstr(ccx, key)), p2i(ccx, val)]); elts.push(elt); @@ -3084,7 +3139,7 @@ pub fn trans_crate(sess: session::Session, } if ccx.sess.count_llvm_insns() { - for ccx.stats.llvm_insns.each_ref |&k, &v| { + for ccx.stats.llvm_insns.each |&k, &v| { io::println(fmt!("%-7u %s", v, k)); } } diff --git a/src/librustc/middle/trans/callee.rs b/src/librustc/middle/trans/callee.rs index 08bab21daaf92..81fa221aac4de 100644 --- a/src/librustc/middle/trans/callee.rs +++ b/src/librustc/middle/trans/callee.rs @@ -674,8 +674,7 @@ pub fn trans_arg_expr(bcx: block, // FIXME(#3548) use the adjustments table match autoref_arg { DoAutorefArg => { - assert !bcx.ccx().maps.moves_map.contains_key_ref( - &arg_expr.id); + assert !bcx.ccx().maps.moves_map.contains_key(&arg_expr.id); val = arg_datum.to_ref_llval(bcx); } DontAutorefArg => { @@ -685,7 +684,7 @@ pub fn trans_arg_expr(bcx: block, // the explicit self code currently passes by-ref, it // does not hold. // - //assert !bcx.ccx().maps.moves_map.contains_key_ref( + //assert !bcx.ccx().maps.moves_map.contains_key( // &arg_expr.id); val = arg_datum.to_ref_llval(bcx); } @@ -693,7 +692,7 @@ pub fn trans_arg_expr(bcx: block, ast::by_val => { // NB: avoid running the take glue. - assert !bcx.ccx().maps.moves_map.contains_key_ref( + assert !bcx.ccx().maps.moves_map.contains_key( &arg_expr.id); val = arg_datum.to_value_llval(bcx); } diff --git a/src/librustc/middle/trans/consts.rs b/src/librustc/middle/trans/consts.rs index 515239883e2d8..d86d4c97c3bed 100644 --- a/src/librustc/middle/trans/consts.rs +++ b/src/librustc/middle/trans/consts.rs @@ -132,7 +132,7 @@ pub fn get_const_val(cx: @crate_ctxt, def_id: ast::def_id) -> ValueRef { if !ast_util::is_local(def_id) { cx.tcx.sess.bug(~"cross-crate constants"); } - if !cx.const_values.contains_key_ref(&def_id.node) { + if !cx.const_values.contains_key(&def_id.node) { match cx.tcx.items.get(&def_id.node) { ast_map::node_item(@ast::item { node: ast::item_const(_, subexpr), _ @@ -407,6 +407,10 @@ pub fn const_expr(cx: @crate_ctxt, e: @ast::expr) -> ValueRef { // variant or we wouldn't have gotten here -- the constant // checker forbids paths that don't map to C-like enum // variants. + if ty::enum_is_univariant(cx.tcx, enum_did) { + // Univariants have no discriminant field. + C_struct(~[]) + } else { let lldiscrim = base::get_discrim_val(cx, e.span, enum_did, variant_did); @@ -418,6 +422,7 @@ pub fn const_expr(cx: @crate_ctxt, e: @ast::expr) -> ValueRef { let padding = C_null(T_array(T_i8(), size)); C_struct(~[lldiscrim, padding]) } + } Some(ast::def_struct(_)) => { let ety = ty::expr_ty(cx.tcx, e); let llty = type_of::type_of(cx, ety); @@ -442,14 +447,14 @@ pub fn const_expr(cx: @crate_ctxt, e: @ast::expr) -> ValueRef { } Some(ast::def_variant(tid, vid)) => { let ety = ty::expr_ty(cx.tcx, e); - let degen = ty::enum_is_univariant(cx.tcx, tid); + let univar = ty::enum_is_univariant(cx.tcx, tid); let size = machine::static_size_of_enum(cx, ety); let discrim = base::get_discrim_val(cx, e.span, tid, vid); let c_args = C_struct(args.map(|a| const_expr(cx, *a))); // FIXME (#1645): enum body alignment is generaly wrong. - if !degen { + if !univar { // Pad out the data to the size of its type_of; // this is necessary if the enum is contained // within an aggregate (tuple, struct, vector) so @@ -464,8 +469,6 @@ pub fn const_expr(cx: @crate_ctxt, e: @ast::expr) -> ValueRef { // without affecting its internal alignment or // changing the alignment of the enum. C_struct(~[discrim, C_packed_struct(~[c_args]), padding]) - } else if size == 0 { - C_struct(~[discrim]) } else { C_struct(~[c_args]) } diff --git a/src/librustc/middle/trans/controlflow.rs b/src/librustc/middle/trans/controlflow.rs index 0933eedd5e4bb..792c5958822e0 100644 --- a/src/librustc/middle/trans/controlflow.rs +++ b/src/librustc/middle/trans/controlflow.rs @@ -186,7 +186,7 @@ pub fn trans_log(log_ex: @ast::expr, // XXX: Bad copy. let modname = path_str(ccx.sess, copy modpath); - let global = if ccx.module_data.contains_key_ref(&modname) { + let global = if ccx.module_data.contains_key(&modname) { ccx.module_data.get(&modname) } else { let s = link::mangle_internal_name_by_path_and_seq( diff --git a/src/librustc/middle/trans/datum.rs b/src/librustc/middle/trans/datum.rs index af966e4df822a..d301a31357be3 100644 --- a/src/librustc/middle/trans/datum.rs +++ b/src/librustc/middle/trans/datum.rs @@ -223,7 +223,7 @@ pub impl Datum { * `id` is located in the move table, but copies otherwise. */ - if bcx.ccx().maps.moves_map.contains_key_ref(&id) { + if bcx.ccx().maps.moves_map.contains_key(&id) { self.move_to(bcx, action, dst) } else { self.copy_to(bcx, action, dst) diff --git a/src/librustc/middle/trans/debuginfo.rs b/src/librustc/middle/trans/debuginfo.rs index 8556bee7e8473..f50cadc967124 100644 --- a/src/librustc/middle/trans/debuginfo.rs +++ b/src/librustc/middle/trans/debuginfo.rs @@ -117,7 +117,7 @@ pub fn mk_ctxt(+crate: ~str, intr: @ident_interner) -> debug_ctxt { } fn update_cache(cache: metadata_cache, mdtag: int, val: debug_metadata) { - let existing = if cache.contains_key_ref(&mdtag) { + let existing = if cache.contains_key(&mdtag) { cache.get(&mdtag) } else { ~[] @@ -176,7 +176,7 @@ fn cached_metadata(cache: metadata_cache, eq_fn: fn(md: T) -> bool) -> Option { unsafe { - if cache.contains_key_ref(&mdtag) { + if cache.contains_key(&mdtag) { let items = cache.get(&mdtag); for items.each |item| { let md: T = md_from_metadata::(*item); diff --git a/src/librustc/middle/trans/expr.rs b/src/librustc/middle/trans/expr.rs index f2da47eb0ecca..30ba0e7feeec8 100644 --- a/src/librustc/middle/trans/expr.rs +++ b/src/librustc/middle/trans/expr.rs @@ -265,7 +265,7 @@ pub fn trans_to_datum(bcx: block, expr: @ast::expr) -> DatumBlock { } pub fn trans_into(bcx: block, expr: @ast::expr, dest: Dest) -> block { - if bcx.tcx().adjustments.contains_key_ref(&expr.id) { + if bcx.tcx().adjustments.contains_key(&expr.id) { // use trans_to_datum, which is mildly less efficient but // which will perform the adjustments: let datumblock = trans_to_datum(bcx, expr); @@ -426,7 +426,7 @@ fn trans_rvalue_datum_unadjusted(bcx: block, expr: @ast::expr) -> DatumBlock { } ast::expr_binary(op, lhs, rhs) => { // if overloaded, would be RvalueDpsExpr - assert !bcx.ccx().maps.method_map.contains_key_ref(&expr.id); + assert !bcx.ccx().maps.method_map.contains_key(&expr.id); return trans_binary(bcx, expr, op, lhs, rhs); } @@ -674,12 +674,15 @@ fn trans_def_dps_unadjusted(bcx: block, ref_expr: @ast::expr, // N-ary variant. let fn_data = callee::trans_fn_ref(bcx, vid, ref_expr.id); return fn_data_to_datum(bcx, vid, fn_data, lldest); - } else { + } else if !ty::enum_is_univariant(ccx.tcx, tid) { // Nullary variant. let lldiscrimptr = GEPi(bcx, lldest, [0u, 0u]); let lldiscrim = C_int(bcx.ccx(), variant_info.disr_val); Store(bcx, lldiscrim, lldiscrimptr); return bcx; + } else { + // Nullary univariant. + return bcx; } } ast::def_struct(*) => { @@ -1215,7 +1218,7 @@ fn trans_unary_datum(bcx: block, assert op != ast::deref; // if overloaded, would be RvalueDpsExpr - assert !bcx.ccx().maps.method_map.contains_key_ref(&un_expr.id); + assert !bcx.ccx().maps.method_map.contains_key(&un_expr.id); let un_ty = expr_ty(bcx, un_expr); let sub_ty = expr_ty(bcx, sub_expr); @@ -1591,10 +1594,22 @@ fn trans_imm_cast(bcx: block, expr: @ast::expr, {in: cast_enum, out: cast_integral} | {in: cast_enum, out: cast_float} => { let bcx = bcx; - let llenumty = T_opaque_enum_ptr(ccx); - let av_enum = PointerCast(bcx, llexpr, llenumty); - let lldiscrim_a_ptr = GEPi(bcx, av_enum, [0u, 0u]); - let lldiscrim_a = Load(bcx, lldiscrim_a_ptr); + let in_tid = match ty::get(t_in).sty { + ty::ty_enum(did, _) => did, + _ => ccx.sess.bug(~"enum cast source is not enum") + }; + let variants = ty::enum_variants(ccx.tcx, in_tid); + let lldiscrim_a = if variants.len() == 1 { + // Univariants don't have a discriminant field, + // because there's only one value it could have: + C_integral(T_enum_discrim(ccx), + variants[0].disr_val as u64, True) + } else { + let llenumty = T_opaque_enum_ptr(ccx); + let av_enum = PointerCast(bcx, llexpr, llenumty); + let lldiscrim_a_ptr = GEPi(bcx, av_enum, [0u, 0u]); + Load(bcx, lldiscrim_a_ptr) + }; match k_out { cast_integral => int_cast(bcx, ll_t_out, val_ty(lldiscrim_a), diff --git a/src/librustc/middle/trans/glue.rs b/src/librustc/middle/trans/glue.rs index 3cbc575b7c11c..08d22a4fbf0e2 100644 --- a/src/librustc/middle/trans/glue.rs +++ b/src/librustc/middle/trans/glue.rs @@ -384,7 +384,7 @@ pub fn make_visit_glue(bcx: block, v: ValueRef, t: ty::t) { let _icx = bcx.insn_ctxt("make_visit_glue"); let mut bcx = bcx; let ty_visitor_name = special_idents::ty_visitor; - assert bcx.ccx().tcx.intrinsic_defs.contains_key_ref(&ty_visitor_name); + assert bcx.ccx().tcx.intrinsic_defs.contains_key(&ty_visitor_name); let (trait_id, ty) = bcx.ccx().tcx.intrinsic_defs.get(&ty_visitor_name); let v = PointerCast(bcx, v, T_ptr(type_of::type_of(bcx.ccx(), ty))); bcx = reflect::emit_calls_to_trait_visit_ty(bcx, t, v, trait_id); @@ -762,7 +762,7 @@ pub fn emit_tydescs(ccx: @crate_ctxt) { let _icx = ccx.insn_ctxt("emit_tydescs"); // As of this point, allow no more tydescs to be created. ccx.finished_tydescs = true; - for ccx.tydescs.each_value_ref |&val| { + for ccx.tydescs.each_value |&val| { let glue_fn_ty = T_ptr(T_generic_glue_fn(ccx)); let ti = val; diff --git a/src/librustc/middle/trans/inline.rs b/src/librustc/middle/trans/inline.rs index c094db4ecca1f..0be8dbe88da4e 100644 --- a/src/librustc/middle/trans/inline.rs +++ b/src/librustc/middle/trans/inline.rs @@ -11,7 +11,7 @@ use core::prelude::*; use middle::astencode; -use middle::trans::base::{get_insn_ctxt}; +use middle::trans::base::{ForceInternal, get_insn_ctxt, internalize_item}; use middle::trans::base::{impl_owned_self, impl_self, no_self}; use middle::trans::base::{trans_item, get_item_val, self_arg, trans_fn}; use middle::trans::common::*; @@ -54,7 +54,7 @@ pub fn maybe_instantiate_inline(ccx: @crate_ctxt, fn_id: ast::def_id, csearch::found(ast::ii_item(item)) => { ccx.external.insert(fn_id, Some(item.id)); ccx.stats.n_inlines += 1; - if translate { trans_item(ccx, *item); } + if translate { trans_item(ccx, *item, ForceInternal); } local_def(item.id) } csearch::found(ast::ii_foreign(item)) => { @@ -64,9 +64,10 @@ pub fn maybe_instantiate_inline(ccx: @crate_ctxt, fn_id: ast::def_id, csearch::found_parent(parent_id, ast::ii_item(item)) => { ccx.external.insert(parent_id, Some(item.id)); let mut my_id = 0; + let vs_here; match item.node { ast::item_enum(_, _) => { - let vs_here = ty::enum_variants(ccx.tcx, local_def(item.id)); + vs_here = ty::enum_variants(ccx.tcx, local_def(item.id)); let vs_there = ty::enum_variants(ccx.tcx, parent_id); for vec::each2(*vs_here, *vs_there) |here, there| { if there.id == fn_id { my_id = here.id.node; } @@ -76,7 +77,7 @@ pub fn maybe_instantiate_inline(ccx: @crate_ctxt, fn_id: ast::def_id, _ => ccx.sess.bug(~"maybe_instantiate_inline: item has a \ non-enum parent") } - if translate { trans_item(ccx, *item); } + if translate { trans_item(ccx, *item, ForceInternal); } local_def(my_id) } csearch::found_parent(_, _) => { @@ -90,6 +91,7 @@ pub fn maybe_instantiate_inline(ccx: @crate_ctxt, fn_id: ast::def_id, ty::lookup_item_type(ccx.tcx, impl_did); if translate && (*impl_bnds).len() + mth.tps.len() == 0u { let llfn = get_item_val(ccx, mth.id); + internalize_item(llfn); let path = vec::append( ty::item_path(ccx.tcx, impl_did), ~[path_name(mth.ident)]); @@ -119,7 +121,7 @@ pub fn maybe_instantiate_inline(ccx: @crate_ctxt, fn_id: ast::def_id, local_def(mth.id) } csearch::found(ast::ii_dtor(ref dtor, _, _, _)) => { - ccx.external.insert(fn_id, Some((*dtor).node.id)); + ccx.external.insert(fn_id, Some(dtor.node.id)); local_def((*dtor).node.id) } } diff --git a/src/librustc/middle/trans/machine.rs b/src/librustc/middle/trans/machine.rs index dfbc75376c7cd..75e494f7bfcd9 100644 --- a/src/librustc/middle/trans/machine.rs +++ b/src/librustc/middle/trans/machine.rs @@ -180,7 +180,7 @@ pub fn llalign_of(cx: @crate_ctxt, t: TypeRef) -> ValueRef { // Computes the size of the data part of an enum. pub fn static_size_of_enum(cx: @crate_ctxt, t: ty::t) -> uint { - if cx.enum_sizes.contains_key_ref(&t) { return cx.enum_sizes.get(&t); } + if cx.enum_sizes.contains_key(&t) { return cx.enum_sizes.get(&t); } match ty::get(t).sty { ty::ty_enum(tid, ref substs) => { // Compute max(variant sizes). diff --git a/src/librustc/middle/trans/meth.rs b/src/librustc/middle/trans/meth.rs index 1d48d2dde6bc5..310409a05ea0c 100644 --- a/src/librustc/middle/trans/meth.rs +++ b/src/librustc/middle/trans/meth.rs @@ -50,15 +50,23 @@ for non-monomorphized methods only. Other methods will be generated once they are invoked with specific type parameters, see `trans::base::lval_static_fn()` or `trans::base::monomorphic_fn()`. */ -pub fn trans_impl(ccx: @crate_ctxt, +path: path, name: ast::ident, - methods: ~[@ast::method], tps: ~[ast::ty_param], - self_ty: Option, id: ast::node_id) { +pub fn trans_impl(ccx: @crate_ctxt, + +path: path, + name: ast::ident, + methods: ~[@ast::method], + tps: ~[ast::ty_param], + self_ty: Option, + id: ast::node_id, + force_internal: ForceInternalFlag) { let _icx = ccx.insn_ctxt("impl::trans_impl"); if tps.len() > 0u { return; } let sub_path = vec::append_one(path, path_name(name)); for vec::each(methods) |method| { if method.tps.len() == 0u { let llfn = get_item_val(ccx, method.id); + if force_internal == ForceInternal { + internalize_item(llfn); + } let path = vec::append_one(/*bad*/copy sub_path, path_name(method.ident)); @@ -871,7 +879,7 @@ pub fn trans_trait_cast(bcx: block, match vstore { ty::vstore_slice(*) | ty::vstore_box => { let mut llboxdest = GEPi(bcx, lldest, [0u, 1u]); - if bcx.tcx().legacy_boxed_traits.contains_key_ref(&id) { + if bcx.tcx().legacy_boxed_traits.contains_key(&id) { // Allocate an @ box and store the value into it let {bcx: new_bcx, box: llbox, body: body} = malloc_boxed(bcx, v_ty); diff --git a/src/librustc/middle/trans/reachable.rs b/src/librustc/middle/trans/reachable.rs index 112b9ac4d0781..f77aa33407d10 100644 --- a/src/librustc/middle/trans/reachable.rs +++ b/src/librustc/middle/trans/reachable.rs @@ -95,7 +95,7 @@ fn traverse_public_mod(cx: ctx, mod_id: node_id, m: _mod) { } fn traverse_public_item(cx: ctx, item: @item) { - if cx.rmap.contains_key_ref(&item.id) { return; } + if cx.rmap.contains_key(&item.id) { return; } cx.rmap.insert(item.id, ()); match /*bad*/copy item.node { item_mod(m) => traverse_public_mod(cx, item.id, m), @@ -145,7 +145,7 @@ fn mk_ty_visitor() -> visit::vt { } fn traverse_ty(ty: @Ty, cx: ctx, v: visit::vt) { - if cx.rmap.contains_key_ref(&ty.id) { return; } + if cx.rmap.contains_key(&ty.id) { return; } cx.rmap.insert(ty.id, ()); match ty.node { diff --git a/src/librustc/middle/trans/reflect.rs b/src/librustc/middle/trans/reflect.rs index 3cd6a5d18364a..83fcc17583703 100644 --- a/src/librustc/middle/trans/reflect.rs +++ b/src/librustc/middle/trans/reflect.rs @@ -116,26 +116,26 @@ pub impl Reflector { fn bracketed(&mut self, bracket_name: ~str, +extra: ~[ValueRef], - inner: &fn()) { + inner: &fn(&mut Reflector)) { // XXX: Bad copy. self.visit(~"enter_" + bracket_name, copy extra); - inner(); + inner(self); self.visit(~"leave_" + bracket_name, extra); } fn vstore_name_and_extra(&mut self, t: ty::t, - vstore: ty::vstore, - f: fn(+s: ~str,+v: ~[ValueRef])) { + vstore: ty::vstore) -> (~str, ~[ValueRef]) + { match vstore { - ty::vstore_fixed(n) => { - let extra = vec::append(~[self.c_uint(n)], - self.c_size_and_align(t)); - f(~"fixed", extra) - } - ty::vstore_slice(_) => f(~"slice", ~[]), - ty::vstore_uniq => f(~"uniq", ~[]), - ty::vstore_box => f(~"box", ~[]) + ty::vstore_fixed(n) => { + let extra = vec::append(~[self.c_uint(n)], + self.c_size_and_align(t)); + (~"fixed", extra) + } + ty::vstore_slice(_) => (~"slice", ~[]), + ty::vstore_uniq => (~"uniq", ~[]), + ty::vstore_box => (~"box", ~[]) } } @@ -168,47 +168,60 @@ pub impl Reflector { ty::ty_float(ast::ty_f32) => self.leaf(~"f32"), ty::ty_float(ast::ty_f64) => self.leaf(~"f64"), - ty::ty_unboxed_vec(mt) => self.visit(~"vec", self.c_mt(mt)), + ty::ty_unboxed_vec(mt) => { + let values = self.c_mt(mt); + self.visit(~"vec", values) + } + ty::ty_estr(vst) => { - do self.vstore_name_and_extra(t, vst) |name, extra| { - self.visit(~"estr_" + name, extra) - } + let (name, extra) = self.vstore_name_and_extra(t, vst); + self.visit(~"estr_" + name, extra) } ty::ty_evec(mt, vst) => { - do self.vstore_name_and_extra(t, vst) |name, extra| { - self.visit(~"evec_" + name, extra + - self.c_mt(mt)) - } + let (name, extra) = self.vstore_name_and_extra(t, vst); + let extra = extra + self.c_mt(mt); + self.visit(~"evec_" + name, extra) + } + ty::ty_box(mt) => { + let extra = self.c_mt(mt); + self.visit(~"box", extra) + } + ty::ty_uniq(mt) => { + let extra = self.c_mt(mt); + self.visit(~"uniq", extra) + } + ty::ty_ptr(mt) => { + let extra = self.c_mt(mt); + self.visit(~"ptr", extra) + } + ty::ty_rptr(_, mt) => { + let extra = self.c_mt(mt); + self.visit(~"rptr", extra) } - ty::ty_box(mt) => self.visit(~"box", self.c_mt(mt)), - ty::ty_uniq(mt) => self.visit(~"uniq", self.c_mt(mt)), - ty::ty_ptr(mt) => self.visit(~"ptr", self.c_mt(mt)), - ty::ty_rptr(_, mt) => self.visit(~"rptr", self.c_mt(mt)), ty::ty_rec(fields) => { - do self.bracketed(~"rec", - ~[self.c_uint(vec::len(fields))] - + self.c_size_and_align(t)) { + let extra = ~[self.c_uint(vec::len(fields))] + + self.c_size_and_align(t); + do self.bracketed(~"rec", extra) |this| { for fields.eachi |i, field| { - self.visit(~"rec_field", - ~[self.c_uint(i), - self.c_slice( - bcx.ccx().sess.str_of(field.ident))] - + self.c_mt(field.mt)); + let extra = ~[this.c_uint(i), + this.c_slice( + bcx.ccx().sess.str_of(field.ident))] + + this.c_mt(field.mt); + this.visit(~"rec_field", extra); } } } ty::ty_tup(tys) => { - do self.bracketed(~"tup", - ~[self.c_uint(vec::len(tys))] - + self.c_size_and_align(t)) { - for tys.eachi |i, t| { - self.visit(~"tup_field", - ~[self.c_uint(i), - self.c_tydesc(*t)]); - } - } + let extra = ~[self.c_uint(vec::len(tys))] + + self.c_size_and_align(t); + do self.bracketed(~"tup", extra) |this| { + for tys.eachi |i, t| { + let extra = ~[this.c_uint(i), this.c_tydesc(*t)]; + this.visit(~"tup_field", extra); + } + } } // FIXME (#2594): fetch constants out of intrinsic @@ -242,20 +255,21 @@ pub impl Reflector { } ty::ty_struct(did, ref substs) => { - let bcx = self.bcx; - let tcx = bcx.ccx().tcx; - let fields = ty::struct_fields(tcx, did, substs); + let bcx = self.bcx; + let tcx = bcx.ccx().tcx; + let fields = ty::struct_fields(tcx, did, substs); - do self.bracketed(~"class", ~[self.c_uint(fields.len())] - + self.c_size_and_align(t)) { - for fields.eachi |i, field| { - self.visit(~"class_field", - ~[self.c_uint(i), - self.c_slice( - bcx.ccx().sess.str_of(field.ident))] - + self.c_mt(field.mt)); - } - } + let extra = ~[self.c_uint(fields.len())] + + self.c_size_and_align(t); + do self.bracketed(~"class", extra) |this| { + for fields.eachi |i, field| { + let extra = ~[this.c_uint(i), + this.c_slice( + bcx.ccx().sess.str_of(field.ident))] + + this.c_mt(field.mt); + this.visit(~"class_field", extra); + } + } } // FIXME (#2595): visiting all the variants in turn is probably @@ -267,20 +281,20 @@ pub impl Reflector { let tcx = bcx.ccx().tcx; let variants = ty::substd_enum_variants(tcx, did, substs); - do self.bracketed(~"enum", - ~[self.c_uint(vec::len(variants))] - + self.c_size_and_align(t)) { + let extra = ~[self.c_uint(vec::len(variants))] + + self.c_size_and_align(t); + do self.bracketed(~"enum", extra) |this| { for variants.eachi |i, v| { - do self.bracketed(~"enum_variant", - ~[self.c_uint(i), - self.c_int(v.disr_val), - self.c_uint(vec::len(v.args)), - self.c_slice( - bcx.ccx().sess.str_of(v.name))]) { + let extra1 = ~[this.c_uint(i), + this.c_int(v.disr_val), + this.c_uint(vec::len(v.args)), + this.c_slice( + bcx.ccx().sess.str_of(v.name))]; + do this.bracketed(~"enum_variant", extra1) |this| { for v.args.eachi |j, a| { - self.visit(~"enum_variant_field", - ~[self.c_uint(j), - self.c_tydesc(*a)]); + let extra = ~[this.c_uint(j), + this.c_tydesc(*a)]; + this.visit(~"enum_variant_field", extra); } } } @@ -291,13 +305,17 @@ pub impl Reflector { ty::ty_trait(_, _, _) => self.leaf(~"trait"), ty::ty_infer(_) => self.leaf(~"infer"), ty::ty_err => self.leaf(~"err"), - ty::ty_param(p) => self.visit(~"param", ~[self.c_uint(p.idx)]), + ty::ty_param(p) => { + let extra = ~[self.c_uint(p.idx)]; + self.visit(~"param", extra) + } ty::ty_self => self.leaf(~"self"), ty::ty_type => self.leaf(~"type"), ty::ty_opaque_box => self.leaf(~"opaque_box"), ty::ty_opaque_closure_ptr(ck) => { - let ckval = ast_sigil_constant(ck); - self.visit(~"closure_ptr", ~[self.c_uint(ckval)]) + let ckval = ast_sigil_constant(ck); + let extra = ~[self.c_uint(ckval)]; + self.visit(~"closure_ptr", extra) } } } @@ -312,14 +330,14 @@ pub impl Reflector { ast::by_copy => 5u } }; - self.visit(~"fn_input", - ~[self.c_uint(i), + let extra = ~[self.c_uint(i), self.c_uint(modeval), - self.c_tydesc(arg.ty)]); + self.c_tydesc(arg.ty)]; + self.visit(~"fn_input", extra); } - self.visit(~"fn_output", - ~[self.c_uint(retval), - self.c_tydesc(sig.output)]); + let extra = ~[self.c_uint(retval), + self.c_tydesc(sig.output)]; + self.visit(~"fn_output", extra); } } @@ -331,7 +349,7 @@ pub fn emit_calls_to_trait_visit_ty(bcx: block, -> block { use syntax::parse::token::special_idents::tydesc; let final = sub_block(bcx, ~"final"); - assert bcx.ccx().tcx.intrinsic_defs.contains_key_ref(&tydesc); + assert bcx.ccx().tcx.intrinsic_defs.contains_key(&tydesc); let (_, tydesc_ty) = bcx.ccx().tcx.intrinsic_defs.get(&tydesc); let tydesc_ty = type_of::type_of(bcx.ccx(), tydesc_ty); let mut r = Reflector { diff --git a/src/librustc/middle/trans/type_of.rs b/src/librustc/middle/trans/type_of.rs index f727b5a2de074..972f702c18a81 100644 --- a/src/librustc/middle/trans/type_of.rs +++ b/src/librustc/middle/trans/type_of.rs @@ -93,7 +93,7 @@ pub fn type_of(cx: @crate_ctxt, t: ty::t) -> TypeRef { debug!("type_of %?: %?", t, ty::get(t)); // Check the cache. - if cx.lltypes.contains_key_ref(&t) { return cx.lltypes.get(&t); } + if cx.lltypes.contains_key(&t) { return cx.lltypes.get(&t); } // Replace any typedef'd types with their equivalent non-typedef // type. This ensures that all LLVM nominal types that contain @@ -242,14 +242,11 @@ pub fn fill_type_of_enum(cx: @crate_ctxt, did: ast::def_id, t: ty::t, debug!("type_of_enum %?: %?", t, ty::get(t)); let lltys = { - let degen = ty::enum_is_univariant(cx.tcx, did); + let univar = ty::enum_is_univariant(cx.tcx, did); let size = machine::static_size_of_enum(cx, t); - if !degen { + if !univar { ~[T_enum_discrim(cx), T_array(T_i8(), size)] } - else if size == 0u { - ~[T_enum_discrim(cx)] - } else { ~[T_array(T_i8(), size)] } diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 2a43fc8a6019d..cef4f9ff1b4b0 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -1932,9 +1932,12 @@ pub fn type_contents(cx: ctxt, ty: t) -> TypeContents { Some(tc) => { return *tc; } None => {} } + match cx.tc_cache.find(&ty_id) { // Must check both caches! + Some(tc) => { return *tc; } + None => {} + } cache.insert(ty_id, TC_NONE); - debug!("computing contents of %s", ty_to_str(cx, ty)); let _i = indenter(); let mut result = match get(ty).sty { @@ -2085,8 +2088,6 @@ pub fn type_contents(cx: ctxt, ty: t) -> TypeContents { result = result + TC_BIG; } - debug!("result = %s", result.to_str()); - cache.insert(ty_id, result); return result; } @@ -2778,7 +2779,7 @@ pub fn node_id_to_type_params(cx: ctxt, id: ast::node_id) -> ~[t] { } fn node_id_has_type_params(cx: ctxt, id: ast::node_id) -> bool { - return cx.node_type_substs.contains_key_ref(&id); + cx.node_type_substs.contains_key(&id) } // Type accessors for substructures of types @@ -3082,7 +3083,7 @@ pub enum ExprKind { pub fn expr_kind(tcx: ctxt, method_map: typeck::method_map, expr: @ast::expr) -> ExprKind { - if method_map.contains_key_ref(&expr.id) { + if method_map.contains_key(&expr.id) { // Overloaded operations are generally calls, and hence they are // generated via DPS. However, assign_op (e.g., `x += y`) is an // exception, as its result is always unit. @@ -4338,7 +4339,7 @@ pub fn iter_bound_traits_and_supertraits(tcx: ctxt, let super_t = supertrait.tpt.ty; let d_id = ty_to_def_id(super_t).expect("supertrait \ should be a trait ty"); - if !supertrait_map.contains_key_ref(&d_id) { + if !supertrait_map.contains_key(&d_id) { supertrait_map.insert(d_id, super_t); trait_ty = super_t; seen_def_ids.push(d_id); diff --git a/src/librustc/middle/typeck/check/_match.rs b/src/librustc/middle/typeck/check/_match.rs index 3cd2be6450de9..95bed1140500d 100644 --- a/src/librustc/middle/typeck/check/_match.rs +++ b/src/librustc/middle/typeck/check/_match.rs @@ -239,7 +239,7 @@ pub fn check_struct_pat_fields(pcx: pat_ctxt, // Report an error if not all the fields were specified. if !etc { for class_fields.eachi |i, field| { - if found_fields.contains_key_ref(&i) { + if found_fields.contains_key(&i) { loop; } tcx.sess.span_err(span, diff --git a/src/librustc/middle/typeck/check/method.rs b/src/librustc/middle/typeck/check/method.rs index 12e3778020a7c..463ae3201a447 100644 --- a/src/librustc/middle/typeck/check/method.rs +++ b/src/librustc/middle/typeck/check/method.rs @@ -1172,12 +1172,11 @@ pub impl LookupContext { match candidate.origin { method_static(method_id) | method_self(method_id, _) | method_super(method_id, _) => { - bad = self.tcx().destructors.contains_key_ref(&method_id); + bad = self.tcx().destructors.contains_key(&method_id); } method_param(method_param { trait_id: trait_id, _ }) | method_trait(trait_id, _, _) => { - bad = self.tcx().destructor_for_type.contains_key_ref( - &trait_id); + bad = self.tcx().destructor_for_type.contains_key(&trait_id); } } diff --git a/src/librustc/middle/typeck/check/mod.rs b/src/librustc/middle/typeck/check/mod.rs index 80be81a33b389..fda9702d58284 100644 --- a/src/librustc/middle/typeck/check/mod.rs +++ b/src/librustc/middle/typeck/check/mod.rs @@ -3208,8 +3208,8 @@ pub fn check_intrinsic_type(ccx: @mut CrateCtxt, it: @ast::foreign_item) { ~"visit_tydesc" => { let tydesc_name = special_idents::tydesc; let ty_visitor_name = tcx.sess.ident_of(~"TyVisitor"); - assert tcx.intrinsic_defs.contains_key_ref(&tydesc_name); - assert ccx.tcx.intrinsic_defs.contains_key_ref(&ty_visitor_name); + assert tcx.intrinsic_defs.contains_key(&tydesc_name); + assert ccx.tcx.intrinsic_defs.contains_key(&ty_visitor_name); let (_, tydesc_ty) = tcx.intrinsic_defs.get(&tydesc_name); let (_, visitor_trait) = tcx.intrinsic_defs.get(&ty_visitor_name); let td_ptr = ty::mk_ptr(ccx.tcx, ty::mt {ty: tydesc_ty, diff --git a/src/librustc/middle/typeck/check/regionck.rs b/src/librustc/middle/typeck/check/regionck.rs index 9ceace0038591..c91607489ecec 100644 --- a/src/librustc/middle/typeck/check/regionck.rs +++ b/src/librustc/middle/typeck/check/regionck.rs @@ -213,7 +213,7 @@ pub fn visit_expr(expr: @ast::expr, &&rcx: @mut Rcx, v: rvt) { // `constrain_auto_ref()` on all exprs. But that causes a // lot of spurious errors because of how the region // hierarchy is setup. - if rcx.fcx.ccx.method_map.contains_key_ref(&callee.id) { + if rcx.fcx.ccx.method_map.contains_key(&callee.id) { match callee.node { ast::expr_field(base, _, _) => { constrain_auto_ref(rcx, base); @@ -749,7 +749,7 @@ pub mod guarantor { let _i = ::util::common::indenter(); let guarantor = { - if rcx.fcx.ccx.method_map.contains_key_ref(&expr.id) { + if rcx.fcx.ccx.method_map.contains_key(&expr.id) { None } else { guarantor(rcx, expr) diff --git a/src/librustc/middle/typeck/check/vtable.rs b/src/librustc/middle/typeck/check/vtable.rs index b72c42f6af73d..410b4a3e33d6e 100644 --- a/src/librustc/middle/typeck/check/vtable.rs +++ b/src/librustc/middle/typeck/check/vtable.rs @@ -268,7 +268,7 @@ pub fn lookup_vtable(vcx: &VtableContext, // im is one specific impl of trait_ty. // First, ensure we haven't processed this impl yet. - if impls_seen.contains_key_ref(&im.did) { + if impls_seen.contains_key(&im.did) { loop; } impls_seen.insert(im.did, ()); diff --git a/src/librustc/middle/typeck/check/writeback.rs b/src/librustc/middle/typeck/check/writeback.rs index 835e0557e2ec9..1b27619938146 100644 --- a/src/librustc/middle/typeck/check/writeback.rs +++ b/src/librustc/middle/typeck/check/writeback.rs @@ -141,7 +141,7 @@ fn maybe_resolve_type_vars_for_node(wbcx: @mut WbCtxt, sp: span, id: ast::node_id) -> Option { - if wbcx.fcx.inh.node_types.contains_key_ref(&id) { + if wbcx.fcx.inh.node_types.contains_key(&id) { resolve_type_vars_for_node(wbcx, sp, id) } else { None diff --git a/src/librustc/middle/typeck/coherence.rs b/src/librustc/middle/typeck/coherence.rs index 1790bd199250b..5e51c21609300 100644 --- a/src/librustc/middle/typeck/coherence.rs +++ b/src/librustc/middle/typeck/coherence.rs @@ -418,7 +418,7 @@ pub impl CoherenceChecker { let coherence_info = &mut self.crate_context.coherence_info; let extension_methods = &coherence_info.extension_methods; - for extension_methods.each_key_ref |&trait_id| { + for extension_methods.each_key |&trait_id| { self.check_implementation_coherence_of(trait_id); } } @@ -503,7 +503,7 @@ pub impl CoherenceChecker { } for ty::trait_methods(tcx, trait_did).each |method| { - if provided_method_idents.contains_key_ref(&method.ident) { + if provided_method_idents.contains_key(&method.ident) { if !f(method) { break; } @@ -911,7 +911,7 @@ pub impl CoherenceChecker { let tcx = self.crate_context.tcx; let pmm = tcx.provided_methods; - if pmm.contains_key_ref(&trait_def_id) { return; } + if pmm.contains_key(&trait_def_id) { return; } debug!("(adding default methods for trait) processing trait"); diff --git a/src/librustc/middle/typeck/collect.rs b/src/librustc/middle/typeck/collect.rs index 68a0ca3890ee8..982a8d7d9574f 100644 --- a/src/librustc/middle/typeck/collect.rs +++ b/src/librustc/middle/typeck/collect.rs @@ -304,7 +304,7 @@ pub fn ensure_supertraits(ccx: @mut CrateCtxt, rp: Option, trait_refs: &[@ast::trait_ref]) { let tcx = ccx.tcx; - if tcx.supertraits.contains_key_ref(&local_def(id)) { return; } + if tcx.supertraits.contains_key(&local_def(id)) { return; } let instantiated = dvec::DVec(); for trait_refs.each |trait_ref| { diff --git a/src/librustc/middle/typeck/infer/lattice.rs b/src/librustc/middle/typeck/infer/lattice.rs index 4bf8a0bae8623..709864c0d13e2 100644 --- a/src/librustc/middle/typeck/infer/lattice.rs +++ b/src/librustc/middle/typeck/infer/lattice.rs @@ -118,11 +118,10 @@ pub impl CombineFields { // A remains a subtype of B. Actually, there are other options, // but that's the route we choose to take. - self.infcx.unify(&node_a, &node_b, |new_root, new_rank| { - self.set_var_to_merged_bounds(new_root, - &a_bounds, &b_bounds, - new_rank) - }) + let (new_root, new_rank) = self.infcx.unify(&node_a, &node_b); + self.set_var_to_merged_bounds(new_root, + &a_bounds, &b_bounds, + new_rank) } /// make variable a subtype of T diff --git a/src/librustc/middle/typeck/infer/region_inference.rs b/src/librustc/middle/typeck/infer/region_inference.rs index 60f5f4406588c..230bfe693e093 100644 --- a/src/librustc/middle/typeck/infer/region_inference.rs +++ b/src/librustc/middle/typeck/infer/region_inference.rs @@ -832,7 +832,7 @@ pub impl RegionVarBindings { (re_infer(ReVar(*)), _) | (_, re_infer(ReVar(*))) => { self.combine_vars( self.lubs, a, b, span, - |old_r, new_r| self.make_subregion(span, old_r, new_r)) + |this, old_r, new_r| this.make_subregion(span, old_r, new_r)) } _ => { @@ -859,7 +859,7 @@ pub impl RegionVarBindings { (re_infer(ReVar(*)), _) | (_, re_infer(ReVar(*))) => { self.combine_vars( self.glbs, a, b, span, - |old_r, new_r| self.make_subregion(span, new_r, old_r)) + |this, old_r, new_r| this.make_subregion(span, new_r, old_r)) } _ => { @@ -915,7 +915,9 @@ pub impl RegionVarBindings { a: Region, b: Region, span: span, - relate: &fn(old_r: Region, new_r: Region) -> cres<()>) + relate: &fn(self: &mut RegionVarBindings, + old_r: Region, + new_r: Region) -> cres<()>) -> cres { let vars = TwoRegions { a: a, b: b }; match combines.find(&vars) { @@ -926,8 +928,8 @@ pub impl RegionVarBindings { if self.in_snapshot() { self.undo_log.push(AddCombination(combines, vars)); } - do relate(a, re_infer(ReVar(c))).then { - do relate(b, re_infer(ReVar(c))).then { + do relate(self, a, re_infer(ReVar(c))).then { + do relate(self, b, re_infer(ReVar(c))).then { debug!("combine_vars() c=%?", c); Ok(re_infer(ReVar(c))) } @@ -1035,7 +1037,8 @@ pub impl RegionVarBindings { */ fn resolve_regions(&mut self) { debug!("RegionVarBindings: resolve_regions()"); - self.values.put_back(self.infer_variable_values()); + let v = self.infer_variable_values(); + self.values.put_back(v); } } @@ -1220,7 +1223,7 @@ impl RegionVarBindings { let mut graph = self.construct_graph(); self.expansion(&mut graph); self.contraction(&mut graph); - self.extract_values_and_report_conflicts(&mut graph) + self.extract_values_and_report_conflicts(&graph) } fn construct_graph(&mut self) -> Graph { @@ -1242,7 +1245,7 @@ impl RegionVarBindings { // It would be nice to write this using map(): let mut edges = vec::with_capacity(num_edges); - for self.constraints.each_ref |constraint, span| { + for self.constraints.each |constraint, span| { edges.push(GraphEdge { next_edge: [uint::max_value, uint::max_value], constraint: *constraint, @@ -1257,14 +1260,14 @@ impl RegionVarBindings { for uint::range(0, num_edges) |edge_idx| { match graph.edges[edge_idx].constraint { - ConstrainVarSubVar(copy a_id, copy b_id) => { + ConstrainVarSubVar(a_id, b_id) => { insert_edge(&mut graph, a_id, Outgoing, edge_idx); insert_edge(&mut graph, b_id, Incoming, edge_idx); } - ConstrainRegSubVar(_, copy b_id) => { + ConstrainRegSubVar(_, b_id) => { insert_edge(&mut graph, b_id, Incoming, edge_idx); } - ConstrainVarSubReg(copy a_id, _) => { + ConstrainVarSubReg(a_id, _) => { insert_edge(&mut graph, a_id, Outgoing, edge_idx); } } @@ -1285,17 +1288,17 @@ impl RegionVarBindings { } fn expansion(&mut self, graph: &mut Graph) { - do self.iterate_until_fixed_point(~"Expansion", graph) |edge| { + do iterate_until_fixed_point(~"Expansion", graph) |nodes, edge| { match edge.constraint { - ConstrainRegSubVar(copy a_region, copy b_vid) => { - let b_node = &mut graph.nodes[*b_vid]; + ConstrainRegSubVar(a_region, b_vid) => { + let b_node = &mut nodes[*b_vid]; self.expand_node(a_region, b_vid, b_node) } - ConstrainVarSubVar(copy a_vid, copy b_vid) => { - match graph.nodes[*a_vid].value { + ConstrainVarSubVar(a_vid, b_vid) => { + match nodes[*a_vid].value { NoValue | ErrorValue => false, - Value(copy a_region) => { - let b_node = &mut graph.nodes[*b_vid]; + Value(a_region) => { + let b_node = &mut nodes[*b_vid]; self.expand_node(a_region, b_vid, b_node) } } @@ -1325,7 +1328,7 @@ impl RegionVarBindings { return true; } - Value(copy cur_region) => { + Value(cur_region) => { let lub = self.lub_concrete_regions(a_region, cur_region); if lub == cur_region { return false; @@ -1345,23 +1348,23 @@ impl RegionVarBindings { } fn contraction(&mut self, graph: &mut Graph) { - do self.iterate_until_fixed_point(~"Contraction", graph) |edge| { + do iterate_until_fixed_point(~"Contraction", graph) |nodes, edge| { match edge.constraint { ConstrainRegSubVar(*) => { // This is an expansion constraint. Ignore. false } - ConstrainVarSubVar(copy a_vid, copy b_vid) => { - match graph.nodes[*b_vid].value { + ConstrainVarSubVar(a_vid, b_vid) => { + match nodes[*b_vid].value { NoValue | ErrorValue => false, - Value(copy b_region) => { - let a_node = &mut graph.nodes[*a_vid]; + Value(b_region) => { + let a_node = &mut nodes[*a_vid]; self.contract_node(a_vid, a_node, b_region) } } } - ConstrainVarSubReg(copy a_vid, copy b_region) => { - let a_node = &mut graph.nodes[*a_vid]; + ConstrainVarSubReg(a_vid, b_region) => { + let a_node = &mut nodes[*a_vid]; self.contract_node(a_vid, a_node, b_region) } } @@ -1387,7 +1390,7 @@ impl RegionVarBindings { false // no change } - Value(copy a_region) => { + Value(a_region) => { match a_node.classification { Expanding => { check_node(self, a_vid, a_node, a_region, b_region) @@ -1438,29 +1441,10 @@ impl RegionVarBindings { } } - fn iterate_until_fixed_point(&mut self, - tag: ~str, - graph: &mut Graph, - body: &fn(edge: &GraphEdge) -> bool) { - let mut iteration = 0; - let mut changed = true; - let num_edges = graph.edges.len(); - while changed { - changed = false; - iteration += 1; - debug!("---- %s Iteration #%u", tag, iteration); - for uint::range(0, num_edges) |edge_idx| { - changed |= body(&graph.edges[edge_idx]); - debug!(" >> Change after edge #%?: %?", - edge_idx, graph.edges[edge_idx]); - } - } - debug!("---- %s Complete after %u iteration(s)", tag, iteration); - } - - fn extract_values_and_report_conflicts(&mut self, - graph: &mut Graph) - -> ~[GraphNodeValue] { + fn extract_values_and_report_conflicts( + &mut self, + graph: &Graph) -> ~[GraphNodeValue] + { let dup_map = TwoRegionsMap(); graph.nodes.mapi(|idx, node| { match node.value { @@ -1525,7 +1509,7 @@ impl RegionVarBindings { } fn report_error_for_expanding_node(&mut self, - graph: &mut Graph, + graph: &Graph, dup_map: TwoRegionsMap, node_idx: RegionVid) { // Errors in expanding nodes result from a lower-bound that is @@ -1578,7 +1562,7 @@ impl RegionVarBindings { } fn report_error_for_contracting_node(&mut self, - graph: &mut Graph, + graph: &Graph, dup_map: TwoRegionsMap, node_idx: RegionVid) { // Errors in contracting nodes result from two upper-bounds @@ -1632,7 +1616,7 @@ impl RegionVarBindings { } fn collect_concrete_regions(&mut self, - graph: &mut Graph, + graph: &Graph, orig_node_idx: RegionVid, dir: Direction) -> ~[SpannedRegion] { @@ -1676,7 +1660,7 @@ impl RegionVarBindings { } fn each_edge(&mut self, - graph: &mut Graph, + graph: &Graph, node_idx: RegionVid, dir: Direction, op: fn(edge: &GraphEdge) -> bool) { @@ -1690,3 +1674,25 @@ impl RegionVarBindings { } } } + +fn iterate_until_fixed_point( + tag: ~str, + graph: &mut Graph, + body: &fn(nodes: &mut [GraphNode], edge: &GraphEdge) -> bool) +{ + let mut iteration = 0; + let mut changed = true; + let num_edges = graph.edges.len(); + while changed { + changed = false; + iteration += 1; + debug!("---- %s Iteration #%u", tag, iteration); + for uint::range(0, num_edges) |edge_idx| { + changed |= body(graph.nodes, &graph.edges[edge_idx]); + debug!(" >> Change after edge #%?: %?", + edge_idx, graph.edges[edge_idx]); + } + } + debug!("---- %s Complete after %u iteration(s)", tag, iteration); +} + diff --git a/src/librustc/middle/typeck/infer/unify.rs b/src/librustc/middle/typeck/infer/unify.rs index 7668388e323a8..69e4f373f9742 100644 --- a/src/librustc/middle/typeck/infer/unify.rs +++ b/src/librustc/middle/typeck/infer/unify.rs @@ -43,9 +43,10 @@ pub trait UnifyVid { } pub impl InferCtxt { - fn get>(&mut self, - +vid: V) - -> Node { + fn get>( + &mut self, + +vid: V) -> Node + { /*! * * Find the root node for `vid`. This uses the standard @@ -53,27 +54,38 @@ pub impl InferCtxt { * http://en.wikipedia.org/wiki/Disjoint-set_data_structure */ + let tcx = self.tcx; let vb = UnifyVid::appropriate_vals_and_bindings(self); - let vid_u = vid.to_uint(); - match vb.vals.find(vid_u) { - None => { - self.tcx.sess.bug(fmt!("failed lookup of vid `%u`", vid_u)); - } - Some(ref var_val) => { - match (*var_val) { - Redirect(vid) => { - let node: Node = self.get(vid); - if node.root != vid { - // Path compression - vb.vals.insert(vid.to_uint(), Redirect(node.root)); + return helper(tcx, vb, vid); + + fn helper( + tcx: ty::ctxt, + vb: &mut ValsAndBindings, + vid: V) -> Node + { + let vid_u = vid.to_uint(); + match vb.vals.find(vid_u) { + None => { + tcx.sess.bug(fmt!( + "failed lookup of vid `%u`", vid_u)); + } + Some(ref var_val) => { + match *var_val { + Redirect(vid) => { + let node: Node = helper(tcx, vb, vid); + if node.root != vid { + // Path compression + vb.vals.insert(vid.to_uint(), + Redirect(node.root)); + } + node + } + Root(ref pt, rk) => { + Node {root: vid, possible_types: *pt, rank: rk} + } + } } - node - } - Root(ref pt, rk) => { - Node {root: vid, possible_types: *pt, rank: rk} - } } - } } } @@ -86,21 +98,22 @@ pub impl InferCtxt { * Sets the value for `vid` to `new_v`. `vid` MUST be a root node! */ - let vb = UnifyVid::appropriate_vals_and_bindings(self); - let old_v = vb.vals.get(vid.to_uint()); - vb.bindings.push((vid, old_v)); - vb.vals.insert(vid.to_uint(), new_v); + debug!("Updating variable %s to %s", + vid.to_str(), new_v.inf_str(self)); - debug!("Updating variable %s from %s to %s", - vid.to_str(), old_v.inf_str(self), new_v.inf_str(self)); + { // FIXME(#4903)---borrow checker is not flow sensitive + let vb = UnifyVid::appropriate_vals_and_bindings(self); + let old_v = vb.vals.get(vid.to_uint()); + vb.bindings.push((vid, old_v)); + vb.vals.insert(vid.to_uint(), new_v); + } } - fn unify, R>( - &mut self, - node_a: &Node, - node_b: &Node, - op: &fn(new_root: V, new_rank: uint) -> R - ) -> R { + fn unify>( + &mut self, + node_a: &Node, + node_b: &Node) -> (V, uint) + { // Rank optimization: if you don't know what it is, check // out @@ -113,17 +126,17 @@ pub impl InferCtxt { // a has greater rank, so a should become b's parent, // i.e., b should redirect to a. self.set(node_b.root, Redirect(node_a.root)); - op(node_a.root, node_a.rank) + (node_a.root, node_a.rank) } else if node_a.rank < node_b.rank { // b has greater rank, so a should redirect to b. self.set(node_a.root, Redirect(node_b.root)); - op(node_b.root, node_b.rank) + (node_b.root, node_b.rank) } else { // If equal, redirect one to the other and increment the // other's rank. assert node_a.rank == node_b.rank; self.set(node_b.root, Redirect(node_a.root)); - op(node_a.root, node_a.rank + 1) + (node_a.root, node_a.rank + 1) } } @@ -183,9 +196,8 @@ pub impl InferCtxt { } }; - self.unify(&node_a, &node_b, |new_root, new_rank| { - self.set(new_root, Root(combined, new_rank)); - }); + let (new_root, new_rank) = self.unify(&node_a, &node_b); + self.set(new_root, Root(combined, new_rank)); return uok(); } diff --git a/src/librustc/rustc.rc b/src/librustc/rustc.rc index e91fd1c31ca0a..5273dbd30492f 100644 --- a/src/librustc/rustc.rc +++ b/src/librustc/rustc.rc @@ -177,7 +177,7 @@ Available lint options: let lint_dict = lint::get_lint_dict(); let mut max_key = 0; - for lint_dict.each_key_ref |&k| { max_key = uint::max(k.len(), max_key); } + for lint_dict.each_key |&k| { max_key = uint::max(k.len(), max_key); } fn padded(max: uint, s: &str) -> ~str { str::from_bytes(vec::from_elem(max - s.len(), ' ' as u8)) + s } @@ -186,7 +186,7 @@ Available lint options: padded(max_key, ~"name"), ~"default", ~"meaning")); io::println(fmt!(" %s %7.7s %s\n", padded(max_key, ~"----"), ~"-------", ~"-------")); - for lint_dict.each_ref |&k, &v| { + for lint_dict.each |&k, &v| { let k = str::replace(k, ~"_", ~"-"); io::println(fmt!(" %s %7.7s %s", padded(max_key, k), diff --git a/src/libstd/arc.rs b/src/libstd/arc.rs index a1fd7a66f7ec8..ff28d2cbebf6f 100644 --- a/src/libstd/arc.rs +++ b/src/libstd/arc.rs @@ -184,25 +184,30 @@ impl &MutexARC { */ #[inline(always)] unsafe fn access(blk: fn(x: &mut T) -> U) -> U { - let state = unsafe { get_shared_mutable_state(&self.x) }; - // Borrowck would complain about this if the function were not already - // unsafe. See borrow_rwlock, far below. - do (&state.lock).lock { - check_poison(true, state.failed); - let _z = PoisonOnFail(&mut state.failed); - blk(&mut state.data) + unsafe { + let state = get_shared_mutable_state(&self.x); + // Borrowck would complain about this if the function were + // not already unsafe. See borrow_rwlock, far below. + do (&(*state).lock).lock { + check_poison(true, (*state).failed); + let _z = PoisonOnFail(&mut (*state).failed); + blk(&mut (*state).data) + } } } /// As access(), but with a condvar, as sync::mutex.lock_cond(). #[inline(always)] unsafe fn access_cond(blk: fn(x: &x/mut T, c: &c/Condvar) -> U) -> U { - let state = unsafe { get_shared_mutable_state(&self.x) }; - do (&state.lock).lock_cond |cond| { - check_poison(true, state.failed); - let _z = PoisonOnFail(&mut state.failed); - blk(&mut state.data, - &Condvar { is_mutex: true, failed: &mut state.failed, - cond: cond }) + unsafe { + let state = get_shared_mutable_state(&self.x); + do (&(*state).lock).lock_cond |cond| { + check_poison(true, (*state).failed); + let _z = PoisonOnFail(&mut (*state).failed); + blk(&mut (*state).data, + &Condvar {is_mutex: true, + failed: &mut (*state).failed, + cond: cond }) + } } } } @@ -285,8 +290,10 @@ pub fn RWARC(user_data: T) -> RWARC { * Create a reader/writer ARC with the supplied data and a specified number * of condvars (as sync::rwlock_with_condvars). */ -pub fn rw_arc_with_condvars(user_data: T, - num_condvars: uint) -> RWARC { +pub fn rw_arc_with_condvars( + user_data: T, + num_condvars: uint) -> RWARC +{ let data = RWARCInner { lock: rwlock_with_condvars(num_condvars), failed: false, data: move user_data }; @@ -315,23 +322,28 @@ impl &RWARC { */ #[inline(always)] fn write(blk: fn(x: &mut T) -> U) -> U { - let state = unsafe { get_shared_mutable_state(&self.x) }; - do borrow_rwlock(state).write { - check_poison(false, state.failed); - let _z = PoisonOnFail(&mut state.failed); - blk(&mut state.data) + unsafe { + let state = get_shared_mutable_state(&self.x); + do (*borrow_rwlock(state)).write { + check_poison(false, (*state).failed); + let _z = PoisonOnFail(&mut (*state).failed); + blk(&mut (*state).data) + } } } /// As write(), but with a condvar, as sync::rwlock.write_cond(). #[inline(always)] fn write_cond(blk: fn(x: &x/mut T, c: &c/Condvar) -> U) -> U { - let state = unsafe { get_shared_mutable_state(&self.x) }; - do borrow_rwlock(state).write_cond |cond| { - check_poison(false, state.failed); - let _z = PoisonOnFail(&mut state.failed); - blk(&mut state.data, - &Condvar { is_mutex: false, failed: &mut state.failed, - cond: cond }) + unsafe { + let state = get_shared_mutable_state(&self.x); + do (*borrow_rwlock(state)).write_cond |cond| { + check_poison(false, (*state).failed); + let _z = PoisonOnFail(&mut (*state).failed); + blk(&mut (*state).data, + &Condvar {is_mutex: false, + failed: &mut (*state).failed, + cond: cond}) + } } } /** @@ -369,11 +381,14 @@ impl &RWARC { * ~~~ */ fn write_downgrade(blk: fn(v: RWWriteMode) -> U) -> U { - let state = unsafe { get_shared_mutable_state(&self.x) }; - do borrow_rwlock(state).write_downgrade |write_mode| { - check_poison(false, state.failed); - blk(RWWriteMode((&mut state.data, move write_mode, - PoisonOnFail(&mut state.failed)))) + unsafe { + let state = get_shared_mutable_state(&self.x); + do (*borrow_rwlock(state)).write_downgrade |write_mode| { + check_poison(false, (*state).failed); + blk(RWWriteMode((&mut (*state).data, + move write_mode, + PoisonOnFail(&mut (*state).failed)))) + } } } @@ -417,8 +432,8 @@ pub fn unwrap_rw_arc(arc: RWARC) -> T { // lock it. This wraps the unsafety, with the justification that the 'lock' // field is never overwritten; only 'failed' and 'data'. #[doc(hidden)] -fn borrow_rwlock(state: &r/mut RWARCInner) -> &r/RWlock { - unsafe { cast::transmute(&mut state.lock) } +fn borrow_rwlock(state: *const RWARCInner) -> *RWlock { + unsafe { cast::transmute(&const (*state).lock) } } // FIXME (#3154) ice with struct/& prevents these from being structs. diff --git a/src/libstd/getopts.rs b/src/libstd/getopts.rs index fa8fdf56428d8..a778649f6f4b0 100644 --- a/src/libstd/getopts.rs +++ b/src/libstd/getopts.rs @@ -29,48 +29,50 @@ * The following example shows simple command line parsing for an application * that requires an input file to be specified, accepts an optional output * file name following -o, and accepts both -h and --help as optional flags. + * extern mod std; + * use std::getopts::*; * - * use std; - * import std::getopts::{optopt,optflag,getopts,opt_present,opt_maybe_str, - * fail_str}; + * fn do_work(in: &str, out: Option<~str>) { + * io::println(in); + * io::println(match out { + * Some(move x) => x, + * None => ~"No Output" + * }); + * } * - * fn do_work(in: str, out: Option) { - * // ... - * } + * fn print_usage(program: &str, _opts: &[std::getopts::Opt]) { + * io::println(fmt!("Usage: %s [options]", program)); + * io::println("-o\t\tOutput"); + * io::println("-h --help\tUsage"); + * } * - * fn print_usage(program: str) { - * io::println("Usage: " + program + " [options]"); - * io::println("-o\t\tOutput"); - * io::println("-h --help\tUsage"); - * } + * fn main() { + * let args = os::args(); * - * fn main(args: ~[str]) { - * check !args.is_empty() + * let program = copy args[0]; * - * let program : str = vec::head(args); - * - * let opts = ~[ - * optopt("o"), - * optflag("h"), - * optflag("help") - * ]; - * let matches = match getopts(vec::tail(args), opts) { - * result::ok(m) { m } - * result::err(f) { die!(fail_str(f)) } - * }; - * if opt_present(matches, "h") || opt_present(matches, "help") { - * print_usage(program); - * return; - * } - * let output = opt_maybe_str(matches, "o"); - * let input = if !matches.free.is_empty() { - * matches.free[0] - * } else { - * print_usage(program); - * return; - * }; - * do_work(input, output); - * } + * let opts = ~[ + * optopt("o"), + * optflag("h"), + * optflag("help") + * ]; + * let matches = match getopts(vec::tail(args), opts) { + * result::Ok(m) => { m } + * result::Err(f) => { fail fail_str(f) } + * }; + * if opt_present(&matches, "h") || opt_present(&matches, "help") { + * print_usage(program, opts); + * return; + * } + * let output = opt_maybe_str(&matches, "o"); + * let input: &str = if !matches.free.is_empty() { + * matches.free[0] + * } else { + * print_usage(program, opts); + * return; + * }; + * do_work(input, output); + * } */ use core::cmp::Eq; diff --git a/src/libstd/oldmap.rs b/src/libstd/oldmap.rs index ad7e8e50e38f0..cea6d17e35d77 100644 --- a/src/libstd/oldmap.rs +++ b/src/libstd/oldmap.rs @@ -76,7 +76,7 @@ pub mod chained { FoundAfter(@Entry, @Entry) } - priv impl T { + priv impl T { pure fn search_rem(k: &K, h: uint, idx: uint, e_root: @Entry) -> SearchResult { let mut e0 = e_root; @@ -90,15 +90,13 @@ pub mod chained { } Some(e1) => { comp += 1u; - unsafe { - if e1.hash == h && e1.key == *k { - debug!("search_tbl: present, comp %u, \ - hash %u, idx %u", - comp, h, idx); - return FoundAfter(e0, e1); - } else { - e0 = e1; - } + if e1.hash == h && e1.key == *k { + debug!( + "search_tbl: present, comp %u, hash %u, idx %u", + comp, h, idx); + return FoundAfter(e0, e1); + } else { + e0 = e1; } } } @@ -114,14 +112,12 @@ pub mod chained { return NotFound; } Some(e) => { - unsafe { - if e.hash == h && e.key == *k { - debug!("search_tbl: present, comp %u, hash %u, \ - idx %u", 1u, h, idx); - return FoundFirst(idx, e); - } else { - return self.search_rem(k, h, idx, e); - } + if e.hash == h && e.key == *k { + debug!("search_tbl: present, comp %u, hash %u, \ + idx %u", 1u, h, idx); + return FoundFirst(idx, e); + } else { + return self.search_rem(k, h, idx, e); } } } @@ -172,8 +168,8 @@ pub mod chained { } } - impl T { - pure fn contains_key_ref(&self, k: &K) -> bool { + impl T { + pure fn contains_key(&self, k: &K) -> bool { let hash = k.hash_keyed(0,0) as uint; match self.search_tbl(k, hash) { NotFound => false, @@ -225,13 +221,43 @@ pub mod chained { } } + fn remove(k: &K) -> bool { + match self.search_tbl(k, k.hash_keyed(0,0) as uint) { + NotFound => false, + FoundFirst(idx, entry) => { + self.count -= 1u; + self.chains[idx] = entry.next; + true + } + FoundAfter(eprev, entry) => { + self.count -= 1u; + eprev.next = entry.next; + true + } + } + } + + pure fn each(&self, blk: fn(key: &K, value: &V) -> bool) { + for self.each_entry |entry| { + if !blk(&entry.key, &entry.value) { break; } + } + } + + pure fn each_key(&self, blk: fn(key: &K) -> bool) { + self.each(|k, _v| blk(k)) + } + + pure fn each_value(&self, blk: fn(value: &V) -> bool) { + self.each(|_k, v| blk(v)) + } + } + + impl T { pure fn find(&self, k: &K) -> Option { - unsafe { - match self.search_tbl(k, k.hash_keyed(0,0) as uint) { - NotFound => None, - FoundFirst(_, entry) => Some(entry.value), - FoundAfter(_, entry) => Some(entry.value) - } + match self.search_tbl(k, k.hash_keyed(0,0) as uint) { + NotFound => None, + FoundFirst(_, entry) => Some(entry.value), + FoundAfter(_, entry) => Some(entry.value) } } @@ -297,36 +323,6 @@ pub mod chained { } option::unwrap(move opt_v) } - - fn remove(k: &K) -> bool { - match self.search_tbl(k, k.hash_keyed(0,0) as uint) { - NotFound => false, - FoundFirst(idx, entry) => { - self.count -= 1u; - self.chains[idx] = entry.next; - true - } - FoundAfter(eprev, entry) => { - self.count -= 1u; - eprev.next = entry.next; - true - } - } - } - - pure fn each_ref(&self, blk: fn(key: &K, value: &V) -> bool) { - for self.each_entry |entry| { - if !blk(&entry.key, &entry.value) { break; } - } - } - - pure fn each_key_ref(&self, blk: fn(key: &K) -> bool) { - self.each_ref(|k, _v| blk(k)) - } - - pure fn each_value_ref(&self, blk: fn(value: &V) -> bool) { - self.each_ref(|_k, v| blk(v)) - } } impl T { @@ -362,9 +358,7 @@ pub mod chained { impl T: ops::Index { pure fn index(&self, k: K) -> V { - unsafe { - self.get(&k) - } + self.get(&k) } } @@ -397,7 +391,7 @@ pub fn set_add(set: Set, key: K) -> bool { /// Convert a set into a vector. pub pure fn vec_from_set(s: Set) -> ~[T] { do vec::build_sized(s.len()) |push| { - for s.each_key_ref() |&k| { + for s.each_key() |&k| { push(k); } } @@ -628,9 +622,9 @@ mod tests { fn test_contains_key() { let key = ~"k"; let map = HashMap::<~str, ~str>(); - assert (!map.contains_key_ref(&key)); + assert (!map.contains_key(&key)); map.insert(key, ~"val"); - assert (map.contains_key_ref(&key)); + assert (map.contains_key(&key)); } #[test] @@ -648,10 +642,10 @@ mod tests { let mut map = HashMap::<~str, ~str>(); map.insert(key, ~"val"); assert (map.len() == 1); - assert (map.contains_key_ref(&key)); + assert (map.contains_key(&key)); map.clear(); assert (map.len() == 0); - assert (!map.contains_key_ref(&key)); + assert (!map.contains_key(&key)); } #[test] diff --git a/src/libstd/priority_queue.rs b/src/libstd/priority_queue.rs index 5248ab1742eb6..a64aa5e968742 100644 --- a/src/libstd/priority_queue.rs +++ b/src/libstd/priority_queue.rs @@ -81,7 +81,8 @@ impl PriorityQueue { /// Push an item onto the queue fn push(&mut self, item: T) { self.data.push(item); - self.siftup(0, self.len() - 1); + let new_len = self.len() - 1; + self.siftup(0, new_len); } /// Optimized version of a push followed by a pop @@ -179,7 +180,8 @@ impl PriorityQueue { } priv fn siftdown(&mut self, pos: uint) { - self.siftdown_range(pos, self.len()); + let len = self.len(); + self.siftdown_range(pos, len); } } diff --git a/src/libstd/smallintmap.rs b/src/libstd/smallintmap.rs index 9642dd0c3dd0f..2e5cd8956cd9d 100644 --- a/src/libstd/smallintmap.rs +++ b/src/libstd/smallintmap.rs @@ -134,10 +134,11 @@ pub impl SmallIntMap { pub impl SmallIntMap { fn update_with_key(&mut self, key: uint, val: V, ff: fn(uint, V, V) -> V) -> bool { - match self.find(&key) { - None => self.insert(key, val), - Some(orig) => self.insert(key, ff(key, copy *orig, val)), - } + let new_val = match self.find(&key) { + None => val, + Some(orig) => ff(key, *orig, val) + }; + self.insert(key, new_val) } fn update(&mut self, key: uint, newval: V, ff: fn(V, V) -> V) -> bool { diff --git a/src/libstd/treemap.rs b/src/libstd/treemap.rs index d8deea60725a0..2fdaeb545a286 100644 --- a/src/libstd/treemap.rs +++ b/src/libstd/treemap.rs @@ -561,78 +561,77 @@ impl TreeNode { pure fn each(node: &r/Option<~TreeNode>, f: fn(&(&r/K, &r/V)) -> bool) { - do node.map |x| { + do node.iter |x| { each(&x.left, f); if f(&(&x.key, &x.value)) { each(&x.right, f) } - }; + } } pure fn each_reverse(node: &r/Option<~TreeNode>, f: fn(&(&r/K, &r/V)) -> bool) { - do node.map |x| { + do node.iter |x| { each_reverse(&x.right, f); if f(&(&x.key, &x.value)) { each_reverse(&x.left, f) } - }; + } } // Remove left horizontal link by rotating right -fn skew(mut node: ~TreeNode) -> ~TreeNode { +fn skew(node: &mut ~TreeNode) { if node.left.map_default(false, |x| x.level == node.level) { let mut save = node.left.swap_unwrap(); node.left <-> save.right; // save.right now None - save.right = Some(node); - save - } else { - node // nothing to do + *node <-> save; + node.right = Some(save); } } // Remove dual horizontal link by rotating left and increasing level of // the parent -fn split(mut node: ~TreeNode) -> ~TreeNode { +fn split(node: &mut ~TreeNode) { if node.right.map_default(false, |x| x.right.map_default(false, |y| y.level == node.level)) { let mut save = node.right.swap_unwrap(); node.right <-> save.left; // save.left now None - save.left = Some(node); save.level += 1; - save - } else { - node // nothing to do + *node <-> save; + node.left = Some(save); } } fn insert(node: &mut Option<~TreeNode>, key: K, value: V) -> bool { - if node.is_none() { - *node = Some(~TreeNode::new(key, value)); - true - } else { - let mut save = node.swap_unwrap(); + match *node { + Some(ref mut save) => { if key < save.key { let inserted = insert(&mut save.left, key, value); - *node = Some(split(skew(save))); // re-balance, if necessary + skew(save); + split(save); inserted } else if save.key < key { let inserted = insert(&mut save.right, key, value); - *node = Some(split(skew(save))); // re-balance, if necessary + skew(save); + split(save); inserted } else { save.key = key; save.value = value; - *node = Some(save); false } + } + None => { + *node = Some(~TreeNode::new(key, value)); + true + } } } fn remove(node: &mut Option<~TreeNode>, key: &K) -> bool { - fn heir_swap(node: &mut TreeNode, + fn heir_swap(node: &mut ~TreeNode, child: &mut Option<~TreeNode>) { // *could* be done without recursion, but it won't borrow check do child.mutate |mut child| { if child.right.is_some() { - heir_swap(&mut *node, &mut child.right); + heir_swap(node, &mut child.right); } else { node.key <-> child.key; node.value <-> child.value; @@ -641,15 +640,15 @@ fn remove(node: &mut Option<~TreeNode>, key: &K) -> bool { } } - if node.is_none() { + match *node { + None => { return false // bottom of tree - } else { - let mut save = node.swap_unwrap(); - - let removed = if save.key < *key { - remove(&mut save.right, key) + } + Some(ref mut save) => { + let (removed, this) = if save.key < *key { + (remove(&mut save.right, key), false) } else if *key < save.key { - remove(&mut save.left, key) + (remove(&mut save.left, key), false) } else { if save.left.is_some() { if save.right.is_some() { @@ -663,41 +662,56 @@ fn remove(node: &mut Option<~TreeNode>, key: &K) -> bool { save.left = Some(left); remove(&mut save.left, key); } else { - save = save.left.swap_unwrap(); + *save = save.left.swap_unwrap(); } + (true, false) } else if save.right.is_some() { - save = save.right.swap_unwrap(); + *save = save.right.swap_unwrap(); + (true, false) } else { - return true // leaf + (true, true) } - true }; - let left_level = save.left.map_default(0, |x| x.level); - let right_level = save.right.map_default(0, |x| x.level); + if !this { + let left_level = save.left.map_default(0, |x| x.level); + let right_level = save.right.map_default(0, |x| x.level); - // re-balance, if necessary - if left_level < save.level - 1 || right_level < save.level - 1 { - save.level -= 1; + // re-balance, if necessary + if left_level < save.level - 1 || right_level < save.level - 1 { + save.level -= 1; - if right_level > save.level { - do save.right.mutate |mut x| { x.level = save.level; x } - } + if right_level > save.level { + do save.right.mutate |mut x| { x.level = save.level; x } + } + + skew(save); - save = skew(save); + match save.right { + Some(ref mut right) => { + skew(right); + match right.right { + Some(ref mut x) => { skew(x) }, + None => () + } + } + None => () + } - do save.right.mutate |mut right| { - right = skew(right); - right.right.mutate(skew); - right + split(save); + match save.right { + Some(ref mut x) => { split(x) }, + None => () + } } - save = split(save); - save.right.mutate(split); - } - *node = Some(save); - removed + return removed; + } + } } + + *node = None; + return true; } #[cfg(test)] diff --git a/src/libstd/uv_iotask.rs b/src/libstd/uv_iotask.rs index a44fef54b726a..ccb3175eef499 100644 --- a/src/libstd/uv_iotask.rs +++ b/src/libstd/uv_iotask.rs @@ -185,15 +185,19 @@ fn begin_teardown(data: *IoTaskLoopData) { ll::close(async_handle as *c_void, tear_down_close_cb); } } +extern fn tear_down_walk_cb(handle: *libc::c_void, arg: *libc::c_void) { + log(debug, ~"IN TEARDOWN WALK CB"); + // pretty much, if we still have an active handle and it is *not* + // the async handle that facilities global loop communication, we + // want to barf out and fail + assert handle == arg; +} extern fn tear_down_close_cb(handle: *ll::uv_async_t) { unsafe { let loop_ptr = ll::get_loop_for_uv_handle(handle); - let loop_refs = ll::loop_refcount(loop_ptr); - log(debug, - fmt!("tear_down_close_cb called, closing handle at %? refs %?", - handle, loop_refs)); - assert loop_refs == 1i32; + log(debug, ~"in tear_down_close_cb"); + ll::walk(loop_ptr, tear_down_walk_cb, handle as *libc::c_void); } } diff --git a/src/libstd/uv_ll.rs b/src/libstd/uv_ll.rs index a3e02ca707066..be6b79059a9f2 100644 --- a/src/libstd/uv_ll.rs +++ b/src/libstd/uv_ll.rs @@ -90,8 +90,8 @@ pub struct uv_stream_t { fields: uv_handle_fields, } -// 64bit unix size: 272 -#[cfg(unix)] +// 64bit unix size: 216 +#[cfg(target_os="macos")] pub struct uv_tcp_t { fields: uv_handle_fields, a00: *u8, a01: *u8, a02: *u8, a03: *u8, @@ -99,10 +99,31 @@ pub struct uv_tcp_t { a08: *u8, a09: *u8, a10: *u8, a11: *u8, a12: *u8, a13: *u8, a14: *u8, a15: *u8, a16: *u8, a17: *u8, a18: *u8, a19: *u8, - a20: *u8, a21: *u8, a22: *u8, a23: *u8, - a24: *u8, a25: *u8, a26: *u8, a27: *u8, - a28: *u8, - a30: uv_tcp_t_32bit_unix_riders, + a20: *u8, a21: *u8, a22: *u8, + a23: uv_tcp_t_osx_riders +} +#[cfg(target_arch="x86_64")] +pub struct uv_tcp_t_osx_riders { + a23: *u8, +} +#[cfg(target_arch="x86")] +#[cfg(target_arch="arm")] +pub struct uv_tcp_t_osx_riders { + a23: *u8, + a24: *u8, a25: *u8, +} +#[cfg(target_os="linux")] +#[cfg(target_os="freebsd")] +#[cfg(target_os="android")] +pub struct uv_tcp_t { + fields: uv_handle_fields, + a00: *u8, a01: *u8, a02: *u8, a03: *u8, + a04: *u8, a05: *u8, a06: *u8, a07: *u8, + a08: *u8, a09: *u8, a10: *u8, a11: *u8, + a12: *u8, a13: *u8, a14: *u8, a15: *u8, + a16: *u8, a17: *u8, a18: *u8, a19: *u8, + a20: *u8, a21: *u8, + a22: uv_tcp_t_32bit_unix_riders, } // 32bit unix size: 328 (164) #[cfg(target_arch="x86_64")] @@ -113,8 +134,6 @@ pub struct uv_tcp_t_32bit_unix_riders { #[cfg(target_arch="arm")] pub struct uv_tcp_t_32bit_unix_riders { a29: *u8, a30: *u8, a31: *u8, - a32: *u8, a33: *u8, a34: *u8, - a35: *u8, a36: *u8, } // 32bit win32 size: 240 (120) @@ -130,11 +149,11 @@ pub struct uv_tcp_t { a24: *u8, a25: *u8, } -// unix size: 48 +// unix size: 64 #[cfg(unix)] pub struct uv_connect_t { a00: *u8, a01: *u8, a02: *u8, a03: *u8, - a04: *u8, a05: *u8, + a04: *u8, a05: *u8, a06: *u8, a07: *u8 } // win32 size: 88 (44) #[cfg(windows)] @@ -152,7 +171,7 @@ pub struct uv_buf_t { // no gen stub method.. should create // it via uv::direct::buf_init() -// unix size: 144 +// unix size: 160 #[cfg(unix)] pub struct uv_write_t { fields: uv_handle_fields, @@ -164,12 +183,13 @@ pub struct uv_write_t { } #[cfg(target_arch="x86_64")] pub struct uv_write_t_32bit_unix_riders { - a13: *u8, + a13: *u8, a14: *u8, a15: *u8 } #[cfg(target_arch="x86")] #[cfg(target_arch="arm")] pub struct uv_write_t_32bit_unix_riders { - a13: *u8, a14: *u8, + a13: *u8, a14: *u8, a15: *u8, + a16: *u8, } // win32 size: 136 (68) #[cfg(windows)] @@ -180,15 +200,14 @@ pub struct uv_write_t { a08: *u8, a09: *u8, a10: *u8, a11: *u8, a12: *u8, } -// 64bit unix size: 120 +// 64bit unix size: 96 // 32bit unix size: 152 (76) #[cfg(unix)] pub struct uv_async_t { fields: uv_handle_fields, a00: *u8, a01: *u8, a02: *u8, a03: *u8, - a04: *u8, a05: *u8, a06: *u8, a07: *u8, - a08: *u8, a09: *u8, - a11: uv_async_t_32bit_unix_riders, + a04: *u8, a05: *u8, a06: *u8, + a07: uv_async_t_32bit_unix_riders, } #[cfg(target_arch="x86_64")] pub struct uv_async_t_32bit_unix_riders { @@ -197,7 +216,7 @@ pub struct uv_async_t_32bit_unix_riders { #[cfg(target_arch="x86")] #[cfg(target_arch="arm")] pub struct uv_async_t_32bit_unix_riders { - a10: *u8, a11: *u8, a12: *u8, a13: *u8, + a10: *u8, } // win32 size 132 (68) #[cfg(windows)] @@ -209,7 +228,7 @@ pub struct uv_async_t { a12: *u8, } -// 64bit unix size: 128 +// 64bit unix size: 120 // 32bit unix size: 84 #[cfg(unix)] pub struct uv_timer_t { @@ -221,13 +240,12 @@ pub struct uv_timer_t { } #[cfg(target_arch="x86_64")] pub struct uv_timer_t_32bit_unix_riders { - a10: *u8, a11: *u8, + a10: *u8, } #[cfg(target_arch="x86")] #[cfg(target_arch="arm")] pub struct uv_timer_t_32bit_unix_riders { - a10: *u8, a11: *u8, a12: *u8, a13: *u8, - a14: *u8, a15: *u8, a16: *u8, + a10: *u8, a11: *u8, a12: *u8 } // win32 size: 64 #[cfg(windows)] @@ -325,7 +343,8 @@ pub mod addrinfo_impl { // unix size: 72 pub struct uv_getaddrinfo_t { a00: *u8, a01: *u8, a02: *u8, a03: *u8, a04: *u8, a05: *u8, - a06: *u8, a07: *u8, a08: *u8, + a06: *u8, a07: *u8, a08: *u8, a09: *u8, + a10: *u8, a11: *u8, a12: *u8, a13: *u8, a14: *u8, a15: *u8 } pub mod uv_ll_struct_stubgen { @@ -356,7 +375,6 @@ pub mod uv_ll_struct_stubgen { return gen_stub_os(); #[cfg(target_os = "linux")] #[cfg(target_os = "android")] - #[cfg(target_os = "macos")] #[cfg(target_os = "freebsd")] pub fn gen_stub_os() -> uv_tcp_t { return gen_stub_arch(); @@ -378,12 +396,8 @@ pub mod uv_ll_struct_stubgen { a15: 0 as *u8, a16: 0 as *u8, a17: 0 as *u8, a18: 0 as *u8, a19: 0 as *u8, - a20: 0 as *u8, a21: 0 as *u8, a22: 0 as *u8, - a23: 0 as *u8, - a24: 0 as *u8, a25: 0 as *u8, a26: 0 as *u8, - a27: 0 as *u8, - a28: 0 as *u8, - a30: uv_tcp_t_32bit_unix_riders { a29: 0 as *u8 }, + a20: 0 as *u8, a21: 0 as *u8, + a22: uv_tcp_t_32bit_unix_riders { a29: 0 as *u8 }, } } #[cfg(target_arch="x86")] @@ -405,15 +419,9 @@ pub mod uv_ll_struct_stubgen { a15: 0 as *u8, a16: 0 as *u8, a17: 0 as *u8, a18: 0 as *u8, a19: 0 as *u8, - a20: 0 as *u8, a21: 0 as *u8, a22: 0 as *u8, - a23: 0 as *u8, - a24: 0 as *u8, a25: 0 as *u8, a26: 0 as *u8, - a27: 0 as *u8, - a28: 0 as *u8, - a30: uv_tcp_t_32bit_unix_riders { + a20: 0 as *u8, a21: 0 as *u8, + a22: uv_tcp_t_32bit_unix_riders { a29: 0 as *u8, a30: 0 as *u8, a31: 0 as *u8, - a32: 0 as *u8, a33: 0 as *u8, a34: 0 as *u8, - a35: 0 as *u8, a36: 0 as *u8, }, } } @@ -441,13 +449,72 @@ pub mod uv_ll_struct_stubgen { a24: 0 as *u8, a25: 0 as *u8, } } + #[cfg(target_os = "macos")] + pub fn gen_stub_os() -> uv_tcp_t { + use super::uv_tcp_t_osx_riders; + + return gen_stub_arch(); + + #[cfg(target_arch = "x86_64")] + fn gen_stub_arch() -> uv_tcp_t { + uv_tcp_t { + fields: uv_handle_fields { + loop_handle: ptr::null(), type_: 0u32, + close_cb: ptr::null(), + data: ptr::null(), + }, + a00: 0 as *u8, a01: 0 as *u8, a02: 0 as *u8, + a03: 0 as *u8, + a04: 0 as *u8, a05: 0 as *u8, a06: 0 as *u8, + a07: 0 as *u8, + a08: 0 as *u8, a09: 0 as *u8, a10: 0 as *u8, + a11: 0 as *u8, + a12: 0 as *u8, a13: 0 as *u8, a14: 0 as *u8, + a15: 0 as *u8, + a16: 0 as *u8, a17: 0 as *u8, a18: 0 as *u8, + a19: 0 as *u8, + a20: 0 as *u8, a21: 0 as *u8, a22: 0 as *u8, + a23: uv_tcp_t_osx_riders { + a23: 0 as *u8, + } + } + } + + #[cfg(target_arch = "x86")] + #[cfg(target_arch = "arm")] + fn gen_stub_arch() -> uv_tcp_t { + uv_tcp_t { + fields: uv_handle_fields { + loop_handle: ptr::null(), type_: 0u32, + close_cb: ptr::null(), + data: ptr::null(), + }, + a00: 0 as *u8, a01: 0 as *u8, a02: 0 as *u8, + a03: 0 as *u8, + a04: 0 as *u8, a05: 0 as *u8, a06: 0 as *u8, + a07: 0 as *u8, + a08: 0 as *u8, a09: 0 as *u8, a10: 0 as *u8, + a11: 0 as *u8, + a12: 0 as *u8, a13: 0 as *u8, a14: 0 as *u8, + a15: 0 as *u8, + a16: 0 as *u8, a17: 0 as *u8, a18: 0 as *u8, + a19: 0 as *u8, + a20: 0 as *u8, a21: 0 as *u8, a22: 0 as *u8, + a23: uv_tcp_t_osx_riders { + a23: 0 as *u8, + a24: 0 as *u8, a25: 0 as *u8, + } + } + } + } } #[cfg(unix)] pub fn gen_stub_uv_connect_t() -> uv_connect_t { uv_connect_t { a00: 0 as *u8, a01: 0 as *u8, a02: 0 as *u8, a03: 0 as *u8, - a04: 0 as *u8, a05: 0 as *u8, + a04: 0 as *u8, a05: 0 as *u8, a06: 0 as *u8, + a07: 0 as *u8 } } #[cfg(windows)] @@ -474,9 +541,7 @@ pub mod uv_ll_struct_stubgen { a00: 0 as *u8, a01: 0 as *u8, a02: 0 as *u8, a03: 0 as *u8, a04: 0 as *u8, a05: 0 as *u8, a06: 0 as *u8, - a07: 0 as *u8, - a08: 0 as *u8, a09: 0 as *u8, - a11: uv_async_t_32bit_unix_riders { a10: 0 as *u8 }, + a07: uv_async_t_32bit_unix_riders { a10: 0 as *u8 }, } } #[cfg(target_arch = "x86")] @@ -491,11 +556,8 @@ pub mod uv_ll_struct_stubgen { a00: 0 as *u8, a01: 0 as *u8, a02: 0 as *u8, a03: 0 as *u8, a04: 0 as *u8, a05: 0 as *u8, a06: 0 as *u8, - a07: 0 as *u8, - a08: 0 as *u8, a09: 0 as *u8, - a11: uv_async_t_32bit_unix_riders { - a10: 0 as *u8, a11: 0 as *u8, - a12: 0 as *u8, a13: 0 as *u8 + a07: uv_async_t_32bit_unix_riders { + a10: 0 as *u8, } } } @@ -534,7 +596,7 @@ pub mod uv_ll_struct_stubgen { a07: 0 as *u8, a08: 0 as *u8, a09: 0 as *u8, a11: uv_timer_t_32bit_unix_riders { - a10: 0 as *u8, a11: 0 as *u8 + a10: 0 as *u8 }, } } @@ -554,9 +616,7 @@ pub mod uv_ll_struct_stubgen { a08: 0 as *u8, a09: 0 as *u8, a11: uv_timer_t_32bit_unix_riders { a10: 0 as *u8, a11: 0 as *u8, - a12: 0 as *u8, a13: 0 as *u8, - a14: 0 as *u8, a15: 0 as *u8, - a16: 0 as *u8, + a12: 0 as *u8, }, } } @@ -595,7 +655,9 @@ pub mod uv_ll_struct_stubgen { a08: 0 as *u8, a09: 0 as *u8, a10: 0 as *u8, a11: 0 as *u8, a12: 0 as *u8, - a14: uv_write_t_32bit_unix_riders { a13: 0 as *u8 }, + a14: uv_write_t_32bit_unix_riders { a13: 0 as *u8, + a14: 0 as *u8, + a15: 0 as *u8}, } } #[cfg(target_arch="x86")] @@ -617,6 +679,8 @@ pub mod uv_ll_struct_stubgen { a14: uv_write_t_32bit_unix_riders { a13: 0 as *u8, a14: 0 as *u8, + a15: 0 as *u8, + a16: 0 as *u8, } } } @@ -642,7 +706,9 @@ pub mod uv_ll_struct_stubgen { uv_getaddrinfo_t { a00: 0 as *u8, a01: 0 as *u8, a02: 0 as *u8, a03: 0 as *u8, a04: 0 as *u8, a05: 0 as *u8, a06: 0 as *u8, a07: 0 as *u8, - a08: 0 as *u8 + a08: 0 as *u8, a09: 0 as *u8, + a10: 1 as *u8, a11: 1 as *u8, a12: 1 as *u8, a13: 1 as *u8, + a14: 1 as *u8, a15: 1 as *u8 } } } @@ -652,9 +718,10 @@ extern mod rustrt { // libuv public API unsafe fn rust_uv_loop_new() -> *libc::c_void; unsafe fn rust_uv_loop_delete(lp: *libc::c_void); - unsafe fn rust_uv_loop_refcount(loop_ptr: *libc::c_void) -> libc::c_int; unsafe fn rust_uv_run(loop_handle: *libc::c_void); unsafe fn rust_uv_close(handle: *libc::c_void, cb: *u8); + unsafe fn rust_uv_walk(loop_handle: *libc::c_void, cb: *u8, + arg: *libc::c_void); unsafe fn rust_uv_async_send(handle: *uv_async_t); unsafe fn rust_uv_async_init(loop_handle: *libc::c_void, async_handle: *uv_async_t, @@ -796,10 +863,6 @@ pub unsafe fn loop_delete(loop_handle: *libc::c_void) { rustrt::rust_uv_loop_delete(loop_handle); } -pub unsafe fn loop_refcount(loop_ptr: *libc::c_void) -> libc::c_int { - return rustrt::rust_uv_loop_refcount(loop_ptr); -} - pub unsafe fn run(loop_handle: *libc::c_void) { rustrt::rust_uv_run(loop_handle); } @@ -808,6 +871,10 @@ pub unsafe fn close(handle: *T, cb: *u8) { rustrt::rust_uv_close(handle as *libc::c_void, cb); } +pub unsafe fn walk(loop_handle: *libc::c_void, cb: *u8, arg: *libc::c_void) { + rustrt::rust_uv_walk(loop_handle, cb, arg); +} + pub unsafe fn tcp_init(loop_handle: *libc::c_void, handle: *uv_tcp_t) -> libc::c_int { return rustrt::rust_uv_tcp_init(loop_handle, handle); @@ -1126,7 +1193,7 @@ pub unsafe fn addrinfo_as_sockaddr_in6(input: *addrinfo) -> *sockaddr_in6 { rustrt::rust_uv_addrinfo_as_sockaddr_in6(input) } -#[cfg(test)] +//#[cfg(test)] pub mod test { use core::prelude::*; @@ -1693,66 +1760,66 @@ pub mod test { } } + fn struct_size_check_common(t_name: ~str, + foreign_size: libc::c_uint) { + unsafe { + let rust_size = sys::size_of::(); + let sizes_match = foreign_size as uint == rust_size; + if !sizes_match { + let output = fmt!( + "STRUCT_SIZE FAILURE: %s -- actual: %u expected: %u", + t_name, rust_size, foreign_size as uint); + log(debug, output); + } + assert sizes_match; + } + } + // struct size tests #[test] fn test_uv_ll_struct_size_uv_tcp_t() { unsafe { - let foreign_handle_size = - ::uv_ll::rustrt::rust_uv_helper_uv_tcp_t_size(); - let rust_handle_size = sys::size_of::(); - let output = fmt!("uv_tcp_t -- foreign: %u rust: %u", - foreign_handle_size as uint, rust_handle_size); - log(debug, output); - assert foreign_handle_size as uint == rust_handle_size; + struct_size_check_common::( + ~"uv_tcp_t", + ::uv_ll::rustrt::rust_uv_helper_uv_tcp_t_size() + ); } } #[test] fn test_uv_ll_struct_size_uv_connect_t() { unsafe { - let foreign_handle_size = - ::uv_ll::rustrt::rust_uv_helper_uv_connect_t_size(); - let rust_handle_size = sys::size_of::(); - let output = fmt!("uv_connect_t -- foreign: %u rust: %u", - foreign_handle_size as uint, rust_handle_size); - log(debug, output); - assert foreign_handle_size as uint == rust_handle_size; + struct_size_check_common::( + ~"uv_connect_t", + ::uv_ll::rustrt::rust_uv_helper_uv_connect_t_size() + ); } } #[test] fn test_uv_ll_struct_size_uv_buf_t() { unsafe { - let foreign_handle_size = - ::uv_ll::rustrt::rust_uv_helper_uv_buf_t_size(); - let rust_handle_size = sys::size_of::(); - let output = fmt!("uv_buf_t -- foreign: %u rust: %u", - foreign_handle_size as uint, rust_handle_size); - log(debug, output); - assert foreign_handle_size as uint == rust_handle_size; + struct_size_check_common::( + ~"uv_buf_t", + ::uv_ll::rustrt::rust_uv_helper_uv_buf_t_size() + ); } } #[test] fn test_uv_ll_struct_size_uv_write_t() { unsafe { - let foreign_handle_size = - ::uv_ll::rustrt::rust_uv_helper_uv_write_t_size(); - let rust_handle_size = sys::size_of::(); - let output = fmt!("uv_write_t -- foreign: %u rust: %u", - foreign_handle_size as uint, rust_handle_size); - log(debug, output); - assert foreign_handle_size as uint == rust_handle_size; + struct_size_check_common::( + ~"uv_write_t", + ::uv_ll::rustrt::rust_uv_helper_uv_write_t_size() + ); } } #[test] fn test_uv_ll_struct_size_sockaddr_in() { unsafe { - let foreign_handle_size = - ::uv_ll::rustrt::rust_uv_helper_sockaddr_in_size(); - let rust_handle_size = sys::size_of::(); - let output = fmt!("sockaddr_in -- foreign: %u rust: %u", - foreign_handle_size as uint, rust_handle_size); - log(debug, output); - assert foreign_handle_size as uint == rust_handle_size; + struct_size_check_common::( + ~"sockaddr_in", + ::uv_ll::rustrt::rust_uv_helper_sockaddr_in_size() + ); } } #[test] @@ -1790,26 +1857,20 @@ pub mod test { #[test] fn test_uv_ll_struct_size_uv_async_t() { unsafe { - let foreign_handle_size = - ::uv_ll::rustrt::rust_uv_helper_uv_async_t_size(); - let rust_handle_size = sys::size_of::(); - let output = fmt!("uv_async_t -- foreign: %u rust: %u", - foreign_handle_size as uint, rust_handle_size); - log(debug, output); - assert foreign_handle_size as uint == rust_handle_size; + struct_size_check_common::( + ~"uv_async_t", + ::uv_ll::rustrt::rust_uv_helper_uv_async_t_size() + ); } } #[test] fn test_uv_ll_struct_size_uv_timer_t() { unsafe { - let foreign_handle_size = - ::uv_ll::rustrt::rust_uv_helper_uv_timer_t_size(); - let rust_handle_size = sys::size_of::(); - let output = fmt!("uv_timer_t -- foreign: %u rust: %u", - foreign_handle_size as uint, rust_handle_size); - log(debug, output); - assert foreign_handle_size as uint == rust_handle_size; + struct_size_check_common::( + ~"uv_timer_t", + ::uv_ll::rustrt::rust_uv_helper_uv_timer_t_size() + ); } } @@ -1817,13 +1878,10 @@ pub mod test { #[ignore(cfg(target_os = "win32"))] fn test_uv_ll_struct_size_uv_getaddrinfo_t() { unsafe { - let foreign_handle_size = - ::uv_ll::rustrt::rust_uv_helper_uv_getaddrinfo_t_size(); - let rust_handle_size = sys::size_of::(); - let output = fmt!("uv_getaddrinfo_t -- foreign: %u rust: %u", - foreign_handle_size as uint, rust_handle_size); - log(debug, output); - assert foreign_handle_size as uint == rust_handle_size; + struct_size_check_common::( + ~"uv_getaddrinfo_t", + ::uv_ll::rustrt::rust_uv_helper_uv_getaddrinfo_t_size() + ); } } #[test] @@ -1831,13 +1889,10 @@ pub mod test { #[ignore(cfg(target_os = "win32"))] fn test_uv_ll_struct_size_addrinfo() { unsafe { - let foreign_handle_size = - ::uv_ll::rustrt::rust_uv_helper_addrinfo_size(); - let rust_handle_size = sys::size_of::(); - let output = fmt!("addrinfo -- foreign: %u rust: %u", - foreign_handle_size as uint, rust_handle_size); - log(debug, output); - assert foreign_handle_size as uint == rust_handle_size; + struct_size_check_common::( + ~"addrinfo", + ::uv_ll::rustrt::rust_uv_helper_uv_timer_t_size() + ); } } } diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index c347c04641f10..d258393e3b954 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -24,8 +24,7 @@ use core::either::Either; use core::either; use core::option; use core::vec; -use std::oldmap::HashMap; -use std::oldmap; +use core::hashmap::linear::LinearSet; use std; /* Constructors */ @@ -358,16 +357,15 @@ pub fn find_inline_attr(attrs: &[ast::attribute]) -> inline_attr { pub fn require_unique_names(diagnostic: span_handler, metas: &[@ast::meta_item]) { - let map = oldmap::HashMap(); + let mut set = LinearSet::new(); for metas.each |meta| { let name = get_meta_item_name(*meta); // FIXME: How do I silence the warnings? --pcw (#2619) - if map.contains_key_ref(&name) { + if !set.insert(name) { diagnostic.span_fatal(meta.span, fmt!("duplicate meta item `%s`", name)); } - map.insert(name, ()); } } diff --git a/src/libsyntax/diagnostic.rs b/src/libsyntax/diagnostic.rs index cd42fc7a95335..51ef085839d6a 100644 --- a/src/libsyntax/diagnostic.rs +++ b/src/libsyntax/diagnostic.rs @@ -250,7 +250,7 @@ fn highlight_lines(cm: @codemap::CodeMap, io::stderr().write_str(out); } - + // FIXME (#3260) // If there's one line at fault we can easily point to the problem if vec::len(lines.lines) == 1u { let lo = cm.lookup_char_pos(sp.lo); @@ -263,14 +263,26 @@ fn highlight_lines(cm: @codemap::CodeMap, // indent past |name:## | and the 0-offset column location let mut left = str::len(fm.name) + digits + lo.col.to_uint() + 3u; let mut s = ~""; - while left > 0u { str::push_char(&mut s, ' '); left -= 1u; } - + // Skip is the number of characters we need to skip because they are + // part of the 'filename:line ' part of the previous line. + let skip = str::len(fm.name) + digits + 3u; + for skip.times() { + s += ~" "; + } + let orig = fm.get_line(lines.lines[0] as int); + for uint::range(0u,left-skip) |pos| { + let curChar = (orig[pos] as char); + s += match curChar { // Whenever a tab occurs on the previous + '\t' => "\t", // line, we insert one on the error-point- + _ => " " // -squigly-line as well (instead of a + }; // space). This way the squigly-line will + } // usually appear in the correct position. s += ~"^"; let hi = cm.lookup_char_pos(sp.hi); if hi.col != lo.col { // the ^ already takes up one space - let mut width = hi.col.to_uint() - lo.col.to_uint() - 1u; - while width > 0u { str::push_char(&mut s, '~'); width -= 1u; } + let num_squiglies = hi.col.to_uint()-lo.col.to_uint()-1u; + for num_squiglies.times() { s += ~"~"; } } io::stderr().write_str(s + ~"\n"); } diff --git a/src/libsyntax/ext/source_util.rs b/src/libsyntax/ext/source_util.rs index 07dacc7c1b3b5..dadc2e527b601 100644 --- a/src/libsyntax/ext/source_util.rs +++ b/src/libsyntax/ext/source_util.rs @@ -1,5 +1,5 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at +// Copyright 2012-2013 The Rust Project Developers. See the +// COPYRIGHT file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 @codemap::ExpnInfo { + let ExpandedFrom({call_site, _}) = *expn_info; + match call_site.expn_info { + Some(next_expn_info) => { + let ExpandedFrom({callie: {name, _}, _}) = *next_expn_info; + // Don't recurse into file using "include!" + if name == ~"include" { return expn_info; } + + topmost_expn_info(next_expn_info) + }, + None => expn_info + } +} + /* line!(): expands to the current line number */ pub fn expand_line(cx: ext_ctxt, sp: span, tts: ~[ast::token_tree]) -> base::MacResult { base::check_zero_tts(cx, sp, tts, "line!"); - let loc = cx.codemap().lookup_char_pos(sp.lo); - base::MRExpr(mk_uint(cx, sp, loc.line)) + + let topmost = topmost_expn_info(cx.backtrace().get()); + let loc = cx.codemap().lookup_char_pos(topmost.call_site.lo); + + base::MRExpr(mk_uint(cx, topmost.call_site, loc.line)) } /* col!(): expands to the current column number */ pub fn expand_col(cx: ext_ctxt, sp: span, tts: ~[ast::token_tree]) -> base::MacResult { base::check_zero_tts(cx, sp, tts, "col!"); - let loc = cx.codemap().lookup_char_pos(sp.lo); - base::MRExpr(mk_uint(cx, sp, loc.col.to_uint())) + + let topmost = topmost_expn_info(cx.backtrace().get()); + let loc = cx.codemap().lookup_char_pos(topmost.call_site.lo); + base::MRExpr(mk_uint(cx, topmost.call_site, loc.col.to_uint())) } /* file!(): expands to the current filename */ @@ -43,9 +62,11 @@ pub fn expand_col(cx: ext_ctxt, sp: span, tts: ~[ast::token_tree]) pub fn expand_file(cx: ext_ctxt, sp: span, tts: ~[ast::token_tree]) -> base::MacResult { base::check_zero_tts(cx, sp, tts, "file!"); + + let topmost = topmost_expn_info(cx.backtrace().get()); let Loc { file: @FileMap { name: filename, _ }, _ } = - cx.codemap().lookup_char_pos(sp.lo); - base::MRExpr(mk_base_str(cx, sp, filename)) + cx.codemap().lookup_char_pos(topmost.call_site.lo); + base::MRExpr(mk_base_str(cx, topmost.call_site, filename)) } pub fn expand_stringify(cx: ext_ctxt, sp: span, tts: ~[ast::token_tree]) diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index 9548db70b94c3..4b1194bb5f174 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -197,7 +197,7 @@ pub fn nameize(p_s: parse_sess, ms: ~[matcher], res: ~[@named_match]) codemap::spanned { node: match_nonterminal(bind_name, _, idx), span: sp } => { - if ret_val.contains_key_ref(&bind_name) { + if ret_val.contains_key(&bind_name) { p_s.span_diagnostic.span_fatal(sp, ~"Duplicated bind name: "+ *p_s.interner.get(bind_name)) } diff --git a/src/libsyntax/parse/common.rs b/src/libsyntax/parse/common.rs index d82a5a1803949..e0d53fadfa0b8 100644 --- a/src/libsyntax/parse/common.rs +++ b/src/libsyntax/parse/common.rs @@ -96,7 +96,7 @@ pub impl Parser { // A sanity check that the word we are asking for is a known keyword fn require_keyword(word: ~str) { - if !self.keywords.contains_key_ref(&word) { + if !self.keywords.contains_key(&word) { self.bug(fmt!("unknown keyword: %s", word)); } } @@ -120,7 +120,7 @@ pub impl Parser { fn is_any_keyword(tok: token::Token) -> bool { match tok { token::IDENT(sid, false) => { - self.keywords.contains_key_ref(self.id_to_str(sid)) + self.keywords.contains_key(self.id_to_str(sid)) } _ => false } @@ -146,7 +146,7 @@ pub impl Parser { } fn is_strict_keyword(word: ~str) -> bool { - self.strict_keywords.contains_key_ref(&word) + self.strict_keywords.contains_key(&word) } fn check_strict_keywords() { @@ -166,7 +166,7 @@ pub impl Parser { } fn is_reserved_keyword(word: ~str) -> bool { - self.reserved_keywords.contains_key_ref(&word) + self.reserved_keywords.contains_key(&word) } fn check_reserved_keywords() { diff --git a/src/libsyntax/parse/obsolete.rs b/src/libsyntax/parse/obsolete.rs index cdde542bb1f32..1b4493b7ec9af 100644 --- a/src/libsyntax/parse/obsolete.rs +++ b/src/libsyntax/parse/obsolete.rs @@ -39,7 +39,6 @@ pub enum ObsoleteSyntax { ObsoleteFieldTerminator, ObsoleteStructCtor, ObsoleteWith, - ObsoleteClassMethod, ObsoleteClassTraits, ObsoletePrivSection, ObsoleteModeInFnType, @@ -85,10 +84,6 @@ pub impl Parser { "record update is done with `..`, e.g. \ `MyStruct { foo: bar, .. baz }`" ), - ObsoleteClassMethod => ( - "class method", - "methods should be defined inside impls" - ), ObsoleteClassTraits => ( "class traits", "implemented traits are specified on the impl, as in \ @@ -137,7 +132,7 @@ pub impl Parser { desc: &str) { self.span_err(sp, fmt!("obsolete syntax: %s", kind_str)); - if !self.obsolete_set.contains_key_ref(&kind) { + if !self.obsolete_set.contains_key(&kind) { self.sess.span_diagnostic.handler().note(fmt!("%s", desc)); self.obsolete_set.insert(kind, ()); } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 7fb3064c388f1..6382413b08169 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -72,7 +72,7 @@ use parse::lexer::TokenAndSpan; use parse::obsolete::{ObsoleteClassTraits, ObsoleteModeInFnType}; use parse::obsolete::{ObsoleteLet, ObsoleteFieldTerminator}; use parse::obsolete::{ObsoleteMoveInit, ObsoleteBinaryMove}; -use parse::obsolete::{ObsoleteStructCtor, ObsoleteWith, ObsoleteClassMethod}; +use parse::obsolete::{ObsoleteStructCtor, ObsoleteWith}; use parse::obsolete::{ObsoleteSyntax, ObsoleteLowerCaseKindBounds}; use parse::obsolete::{ObsoleteUnsafeBlock}; use parse::prec::{as_prec, token_to_binop}; @@ -3002,52 +3002,29 @@ pub impl Parser { } fn parse_single_class_item(vis: visibility) -> @struct_field { - let obsolete_let = self.eat_obsolete_ident("let"); - if obsolete_let { self.obsolete(copy self.last_span, ObsoleteLet) } - - let parse_obsolete_method = - !((obsolete_let || self.is_keyword(~"mut") || - !self.is_any_keyword(copy self.token)) - && !self.token_is_pound_or_doc_comment(copy self.token)); + if self.eat_obsolete_ident("let") { + self.obsolete(copy self.last_span, ObsoleteLet); + } - if !parse_obsolete_method { - let a_var = self.parse_instance_var(vis); - match self.token { - token::SEMI => { - self.obsolete(copy self.span, ObsoleteFieldTerminator); - self.bump(); - } - token::COMMA => { - self.bump(); - } - token::RBRACE => {} - _ => { - self.span_fatal(copy self.span, - fmt!("expected `;`, `,`, or '}' but \ - found `%s`", - token_to_str(self.reader, - self.token))); - } - } - a_var - } else { - self.obsolete(copy self.span, ObsoleteClassMethod); - self.parse_method(); - // bogus value - @spanned( - self.span.lo, - self.span.hi, - ast::struct_field_ { - kind: unnamed_field, - id: self.get_id(), - ty: @ast::Ty { - id: self.get_id(), - node: ty_nil, - span: copy self.span, - } - } - ) + let a_var = self.parse_instance_var(vis); + match self.token { + token::SEMI => { + self.obsolete(copy self.span, ObsoleteFieldTerminator); + self.bump(); + } + token::COMMA => { + self.bump(); + } + token::RBRACE => {} + _ => { + self.span_fatal(copy self.span, + fmt!("expected `;`, `,`, or '}' but \ + found `%s`", + token_to_str(self.reader, + self.token))); + } } + a_var } fn parse_dtor(attrs: ~[attribute]) -> class_contents { @@ -3062,6 +3039,8 @@ pub impl Parser { return members(~[]); } + let attrs = self.parse_outer_attributes(); + if self.eat_keyword(~"priv") { return members(~[self.parse_single_class_item(private)]) } @@ -3070,8 +3049,6 @@ pub impl Parser { return members(~[self.parse_single_class_item(public)]); } - let attrs = self.parse_outer_attributes(); - if self.try_parse_obsolete_struct_ctor() { return members(~[]); } diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index 49de7264d2c5d..b8d756d893adf 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -455,13 +455,13 @@ pub fn mk_fake_ident_interner() -> @ident_interner { */ pub fn keyword_table() -> HashMap<~str, ()> { let keywords = HashMap(); - for temporary_keyword_table().each_key_ref |&word| { + for temporary_keyword_table().each_key |&word| { keywords.insert(word, ()); } - for strict_keyword_table().each_key_ref |&word| { + for strict_keyword_table().each_key |&word| { keywords.insert(word, ()); } - for reserved_keyword_table().each_key_ref |&word| { + for reserved_keyword_table().each_key |&word| { keywords.insert(word, ()); } keywords diff --git a/src/libuv b/src/libuv index 4d392c86feb63..da33bba7c04e0 160000 --- a/src/libuv +++ b/src/libuv @@ -1 +1 @@ -Subproject commit 4d392c86feb6389f550d8110d36fa90d66c09251 +Subproject commit da33bba7c04e0873b457a9a4290bed2adf620154 diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp index e14f62ffae936..86f371a30f3ac 100644 --- a/src/rt/rust_builtin.cpp +++ b/src/rt/rust_builtin.cpp @@ -52,50 +52,6 @@ timegm(struct tm *tm) } #endif - -extern "C" CDECL rust_str* -last_os_error() { - rust_task *task = rust_get_current_task(); - - LOG(task, task, "last_os_error()"); - -#if defined(__WIN32__) - LPTSTR buf; - DWORD err = GetLastError(); - DWORD res = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, err, - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - (LPTSTR) &buf, 0, NULL); - if (!res) { - task->fail(); - return NULL; - } -#elif defined(_GNU_SOURCE) && !defined(__ANDROID__) - char cbuf[BUF_BYTES]; - char *buf = strerror_r(errno, cbuf, sizeof(cbuf)); - if (!buf) { - task->fail(); - return NULL; - } -#else - char buf[BUF_BYTES]; - int err = strerror_r(errno, buf, sizeof(buf)); - if (err) { - task->fail(); - return NULL; - } -#endif - - rust_str * st = make_str(task->kernel, buf, strlen(buf), - "last_os_error"); -#ifdef __WIN32__ - LocalFree((HLOCAL)buf); -#endif - return st; -} - extern "C" CDECL rust_str * rust_getcwd() { rust_task *task = rust_get_current_task(); @@ -939,15 +895,15 @@ rust_get_global_data_ptr() { } extern "C" void -rust_inc_weak_task_count() { +rust_inc_kernel_live_count() { rust_task *task = rust_get_current_task(); - task->kernel->inc_weak_task_count(); + task->kernel->inc_live_count(); } extern "C" void -rust_dec_weak_task_count() { +rust_dec_kernel_live_count() { rust_task *task = rust_get_current_task(); - task->kernel->dec_weak_task_count(); + task->kernel->dec_live_count(); } // diff --git a/src/rt/rust_kernel.cpp b/src/rt/rust_kernel.cpp index e0494c9300bc3..6b7a82414161c 100644 --- a/src/rt/rust_kernel.cpp +++ b/src/rt/rust_kernel.cpp @@ -291,12 +291,20 @@ rust_kernel::set_exit_status(int code) { } void -rust_kernel::register_task() { - KLOG_("Registering task"); +rust_kernel::inc_live_count() { uintptr_t new_non_weak_tasks = sync::increment(non_weak_tasks); KLOG_("New non-weak tasks %" PRIdPTR, new_non_weak_tasks); } +void +rust_kernel::dec_live_count() { + uintptr_t new_non_weak_tasks = sync::decrement(non_weak_tasks); + KLOG_("New non-weak tasks %" PRIdPTR, new_non_weak_tasks); + if (new_non_weak_tasks == 0) { + begin_shutdown(); + } +} + void rust_kernel::allow_scheduler_exit() { scoped_lock with(sched_lock); @@ -315,31 +323,6 @@ rust_kernel::allow_scheduler_exit() { osmain_sched->allow_exit(); } -void -rust_kernel::unregister_task() { - KLOG_("Unregistering task"); - uintptr_t new_non_weak_tasks = sync::decrement(non_weak_tasks); - KLOG_("New non-weak tasks %" PRIdPTR, new_non_weak_tasks); - if (new_non_weak_tasks == 0) { - begin_shutdown(); - } -} - -void -rust_kernel::inc_weak_task_count() { - uintptr_t new_non_weak_tasks = sync::decrement(non_weak_tasks); - KLOG_("New non-weak tasks %" PRIdPTR, new_non_weak_tasks); - if (new_non_weak_tasks == 0) { - begin_shutdown(); - } -} - -void -rust_kernel::dec_weak_task_count() { - uintptr_t new_non_weak_tasks = sync::increment(non_weak_tasks); - KLOG_("New non-weak tasks %" PRIdPTR, new_non_weak_tasks); -} - void rust_kernel::begin_shutdown() { { diff --git a/src/rt/rust_kernel.h b/src/rt/rust_kernel.h index 11af02dace4a0..01ebf5ab57b95 100644 --- a/src/rt/rust_kernel.h +++ b/src/rt/rust_kernel.h @@ -160,10 +160,8 @@ class rust_kernel { rust_sched_id main_sched_id() { return main_scheduler; } rust_sched_id osmain_sched_id() { return osmain_scheduler; } - void register_task(); - void unregister_task(); - void inc_weak_task_count(); - void dec_weak_task_count(); + void inc_live_count(); + void dec_live_count(); void register_exit_function(spawn_fn runner, fn_env_pair *f); }; diff --git a/src/rt/rust_scheduler.cpp b/src/rt/rust_scheduler.cpp index 22dae047e55df..e3a5d9db91ffa 100644 --- a/src/rt/rust_scheduler.cpp +++ b/src/rt/rust_scheduler.cpp @@ -123,7 +123,7 @@ rust_scheduler::create_task(rust_task *spawner, const char *name) { cur_thread = (thread_no + 1) % max_num_threads; } KLOG(kernel, kern, "Creating task %s, on thread %d.", name, thread_no); - kernel->register_task(); + kernel->inc_live_count(); rust_sched_launcher *thread = threads[thread_no]; return thread->get_loop()->create_task(spawner, name); } @@ -138,7 +138,7 @@ rust_scheduler::release_task() { need_exit = true; } } - kernel->unregister_task(); + kernel->dec_live_count(); if (need_exit) { exit(); } diff --git a/src/rt/rust_uv.cpp b/src/rt/rust_uv.cpp index 2dc70088628f6..f08261c336dcd 100644 --- a/src/rt/rust_uv.cpp +++ b/src/rt/rust_uv.cpp @@ -121,11 +121,6 @@ rust_uv_loop_delete(uv_loop_t* loop) { uv_loop_delete(loop); } -extern "C" int -rust_uv_loop_refcount(uv_loop_t* loop) { - return uv_loop_refcount(loop); -} - extern "C" void rust_uv_loop_set_data(uv_loop_t* loop, void* data) { loop->data = data; @@ -151,7 +146,7 @@ rust_uv_stop_op_cb(uv_handle_t* op_handle) { extern "C" void rust_uv_run(uv_loop_t* loop) { - uv_run(loop); + uv_run(loop, UV_RUN_DEFAULT); } extern "C" void @@ -159,6 +154,11 @@ rust_uv_close(uv_handle_t* handle, uv_close_cb cb) { uv_close(handle, cb); } +extern "C" void +rust_uv_walk(uv_loop_t* loop, uv_walk_cb cb, void* arg) { + uv_walk(loop, cb, arg); +} + extern "C" void rust_uv_hilvl_close(uv_handle_t* handle, extern_close_cb cb) { handle_data* data = (handle_data*)handle->data; diff --git a/src/rt/rustrt.def.in b/src/rt/rustrt.def.in index 818eb5f83a7b5..c554489c4b35b 100644 --- a/src/rt/rustrt.def.in +++ b/src/rt/rustrt.def.in @@ -14,7 +14,6 @@ rust_gmtime rust_localtime rust_timegm rust_mktime -last_os_error new_task precise_time_ns rand_free @@ -73,7 +72,7 @@ rust_upcall_free rust_upcall_malloc rust_uv_loop_new rust_uv_loop_delete -rust_uv_loop_refcount +rust_uv_walk rust_uv_loop_set_data rust_uv_bind_op_cb rust_uv_stop_op_cb @@ -188,6 +187,6 @@ rust_raw_thread_start rust_raw_thread_join_delete rust_register_exit_function rust_get_global_data_ptr -rust_inc_weak_task_count -rust_dec_weak_task_count +rust_inc_kernel_live_count +rust_dec_kernel_live_count rust_get_exchange_count_ptr diff --git a/src/test/auxiliary/anon-extern-mod-cross-crate-1.rs b/src/test/auxiliary/anon-extern-mod-cross-crate-1.rs index bbe36f18d6c34..bccbb8173aad1 100644 --- a/src/test/auxiliary/anon-extern-mod-cross-crate-1.rs +++ b/src/test/auxiliary/anon-extern-mod-cross-crate-1.rs @@ -15,5 +15,5 @@ #[crate_type = "lib"]; extern { - fn last_os_error() -> ~str; + fn rust_get_argc() -> libc::c_int; } diff --git a/src/test/auxiliary/foreign_lib.rs b/src/test/auxiliary/foreign_lib.rs index eb3397a8a5f46..1d9c1cdbf83f0 100644 --- a/src/test/auxiliary/foreign_lib.rs +++ b/src/test/auxiliary/foreign_lib.rs @@ -11,5 +11,5 @@ #[link(name="foreign_lib", vers="0.0")]; pub extern mod rustrt { - pub fn last_os_error() -> ~str; + pub fn rust_get_argc() -> libc::c_int; } diff --git a/src/test/bench/shootout-k-nucleotide-pipes.rs b/src/test/bench/shootout-k-nucleotide-pipes.rs index 811f39e4343db..62341f08ce3be 100644 --- a/src/test/bench/shootout-k-nucleotide-pipes.rs +++ b/src/test/bench/shootout-k-nucleotide-pipes.rs @@ -49,7 +49,7 @@ fn sort_and_fmt(mm: HashMap<~[u8], uint>, total: uint) -> ~str { let mut pairs = ~[]; // map -> [(k,%)] - for mm.each_ref |&key, &val| { + for mm.each |&key, &val| { pairs.push((key, pct(val, total))); } diff --git a/src/test/bench/shootout-mandelbrot.rs b/src/test/bench/shootout-mandelbrot.rs index 5888dab3bb923..b19454ec230c2 100644 --- a/src/test/bench/shootout-mandelbrot.rs +++ b/src/test/bench/shootout-mandelbrot.rs @@ -134,7 +134,7 @@ fn writer(path: ~str, pport: pipes::Port, size: uint) done += 1_u; let mut prev = done; while prev <= i { - if lines.contains_key_ref(&prev) { + if lines.contains_key(&prev) { debug!("WS %u", prev); cout.write(lines.get(&prev)); done += 1_u; diff --git a/src/test/compile-fail/borrowck-borrow-from-owned-ptr.rs b/src/test/compile-fail/borrowck-borrow-from-owned-ptr.rs new file mode 100644 index 0000000000000..47b6b4de64281 --- /dev/null +++ b/src/test/compile-fail/borrowck-borrow-from-owned-ptr.rs @@ -0,0 +1,124 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct Foo { + bar1: Bar, + bar2: Bar +} + +struct Bar { + int1: int, + int2: int, +} + +fn make_foo() -> ~Foo { die!() } + +fn borrow_same_field_twice_mut_mut() { + let mut foo = make_foo(); + let _bar1 = &mut foo.bar1; + let _bar2 = &mut foo.bar1; //~ ERROR conflicts with prior loan +} + +fn borrow_same_field_twice_mut_imm() { + let mut foo = make_foo(); + let _bar1 = &mut foo.bar1; + let _bar2 = &foo.bar1; //~ ERROR conflicts with prior loan +} + +fn borrow_same_field_twice_imm_mut() { + let mut foo = make_foo(); + let _bar1 = &foo.bar1; + let _bar2 = &mut foo.bar1; //~ ERROR conflicts with prior loan +} + +fn borrow_same_field_twice_imm_imm() { + let mut foo = make_foo(); + let _bar1 = &foo.bar1; + let _bar2 = &foo.bar1; +} + +fn borrow_both_mut() { + let mut foo = make_foo(); + let _bar1 = &mut foo.bar1; + let _bar2 = &mut foo.bar2; +} + +fn borrow_both_mut_pattern() { + let mut foo = make_foo(); + match *foo { + Foo { bar1: ref mut _bar1, bar2: ref mut _bar2 } => {} + } +} + +fn borrow_var_and_pattern() { + let mut foo = make_foo(); + let _bar1 = &mut foo.bar1; + match *foo { + Foo { bar1: ref mut _bar1, bar2: _ } => {} + //~^ ERROR conflicts with prior loan + } +} + +fn borrow_mut_and_base_imm() { + let mut foo = make_foo(); + let _bar1 = &mut foo.bar1.int1; + let _foo1 = &foo.bar1; //~ ERROR conflicts with prior loan + let _foo2 = &*foo; //~ ERROR conflicts with prior loan +} + +fn borrow_mut_and_base_mut() { + let mut foo = make_foo(); + let _bar1 = &mut foo.bar1.int1; + let _foo1 = &mut foo.bar1; //~ ERROR conflicts with prior loan +} + +fn borrow_mut_and_base_mut2() { + let mut foo = make_foo(); + let _bar1 = &mut foo.bar1.int1; + let _foo2 = &mut *foo; //~ ERROR conflicts with prior loan +} + +fn borrow_imm_and_base_mut() { + let mut foo = make_foo(); + let _bar1 = &foo.bar1.int1; + let _foo1 = &mut foo.bar1; //~ ERROR conflicts with prior loan +} + +fn borrow_imm_and_base_mut2() { + let mut foo = make_foo(); + let _bar1 = &foo.bar1.int1; + let _foo2 = &mut *foo; //~ ERROR conflicts with prior loan +} + +fn borrow_imm_and_base_imm() { + let mut foo = make_foo(); + let _bar1 = &foo.bar1.int1; + let _foo1 = &foo.bar1; + let _foo2 = &*foo; +} + +fn borrow_mut_and_imm() { + let mut foo = make_foo(); + let _bar1 = &mut foo.bar1; + let _foo1 = &foo.bar2; +} + +fn borrow_mut_from_imm() { + let foo = make_foo(); + let _bar1 = &mut foo.bar1; //~ ERROR illegal borrow +} + +fn borrow_long_path_both_mut() { + let mut foo = make_foo(); + let _bar1 = &mut foo.bar1.int1; + let _foo1 = &mut foo.bar2.int2; +} + +fn main() {} diff --git a/src/test/compile-fail/borrowck-borrow-from-stack-variable.rs b/src/test/compile-fail/borrowck-borrow-from-stack-variable.rs new file mode 100644 index 0000000000000..30757cc6e7798 --- /dev/null +++ b/src/test/compile-fail/borrowck-borrow-from-stack-variable.rs @@ -0,0 +1,124 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct Foo { + bar1: Bar, + bar2: Bar +} + +struct Bar { + int1: int, + int2: int, +} + +fn make_foo() -> Foo { die!() } + +fn borrow_same_field_twice_mut_mut() { + let mut foo = make_foo(); + let _bar1 = &mut foo.bar1; + let _bar2 = &mut foo.bar1; //~ ERROR conflicts with prior loan +} + +fn borrow_same_field_twice_mut_imm() { + let mut foo = make_foo(); + let _bar1 = &mut foo.bar1; + let _bar2 = &foo.bar1; //~ ERROR conflicts with prior loan +} + +fn borrow_same_field_twice_imm_mut() { + let mut foo = make_foo(); + let _bar1 = &foo.bar1; + let _bar2 = &mut foo.bar1; //~ ERROR conflicts with prior loan +} + +fn borrow_same_field_twice_imm_imm() { + let mut foo = make_foo(); + let _bar1 = &foo.bar1; + let _bar2 = &foo.bar1; +} + +fn borrow_both_mut() { + let mut foo = make_foo(); + let _bar1 = &mut foo.bar1; + let _bar2 = &mut foo.bar2; +} + +fn borrow_both_mut_pattern() { + let mut foo = make_foo(); + match foo { + Foo { bar1: ref mut _bar1, bar2: ref mut _bar2 } => {} + } +} + +fn borrow_var_and_pattern() { + let mut foo = make_foo(); + let _bar1 = &mut foo.bar1; + match foo { + Foo { bar1: ref mut _bar1, bar2: _ } => {} + //~^ ERROR conflicts with prior loan + } +} + +fn borrow_mut_and_base_imm() { + let mut foo = make_foo(); + let _bar1 = &mut foo.bar1.int1; + let _foo1 = &foo.bar1; //~ ERROR conflicts with prior loan + let _foo2 = &foo; //~ ERROR conflicts with prior loan +} + +fn borrow_mut_and_base_mut() { + let mut foo = make_foo(); + let _bar1 = &mut foo.bar1.int1; + let _foo1 = &mut foo.bar1; //~ ERROR conflicts with prior loan +} + +fn borrow_mut_and_base_mut2() { + let mut foo = make_foo(); + let _bar1 = &mut foo.bar1.int1; + let _foo2 = &mut foo; //~ ERROR conflicts with prior loan +} + +fn borrow_imm_and_base_mut() { + let mut foo = make_foo(); + let _bar1 = &foo.bar1.int1; + let _foo1 = &mut foo.bar1; //~ ERROR conflicts with prior loan +} + +fn borrow_imm_and_base_mut2() { + let mut foo = make_foo(); + let _bar1 = &foo.bar1.int1; + let _foo2 = &mut foo; //~ ERROR conflicts with prior loan +} + +fn borrow_imm_and_base_imm() { + let mut foo = make_foo(); + let _bar1 = &foo.bar1.int1; + let _foo1 = &foo.bar1; + let _foo2 = &foo; +} + +fn borrow_mut_and_imm() { + let mut foo = make_foo(); + let _bar1 = &mut foo.bar1; + let _foo1 = &foo.bar2; +} + +fn borrow_mut_from_imm() { + let foo = make_foo(); + let _bar1 = &mut foo.bar1; //~ ERROR illegal borrow +} + +fn borrow_long_path_both_mut() { + let mut foo = make_foo(); + let _bar1 = &mut foo.bar1.int1; + let _foo1 = &mut foo.bar2.int2; +} + +fn main() {} diff --git a/src/test/compile-fail/borrowck-confuse-region.rs b/src/test/compile-fail/borrowck-confuse-region.rs deleted file mode 100644 index 7b5d9829f5f56..0000000000000 --- a/src/test/compile-fail/borrowck-confuse-region.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Here we are checking that a reasonable error msg is provided. -// -// The current message is not ideal, but we used to say "borrowed -// pointer has lifetime &, but the borrowed value only has lifetime &" -// which is definitely no good. - - -fn get() -> &int { - //~^ NOTE borrowed pointer must be valid for the anonymous lifetime #1 defined on - //~^^ NOTE ...but borrowed value is only valid for the block at - let x = 3; - return &x; - //~^ ERROR illegal borrow -} - -fn main() {} diff --git a/src/test/compile-fail/borrowck-imm-field-mut-base.rs b/src/test/compile-fail/borrowck-imm-field-mut-base.rs deleted file mode 100644 index 5c3fe22960254..0000000000000 --- a/src/test/compile-fail/borrowck-imm-field-mut-base.rs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct Foo { - mut x: uint -} - -struct Bar { - foo: Foo -} - -fn main() { - let mut b = Bar { foo: Foo { x: 3 } }; - let p = &b.foo.x; - let q = &mut b.foo; //~ ERROR loan of mutable field as mutable conflicts with prior loan - //~^ ERROR loan of mutable local variable as mutable conflicts with prior loan - let r = &mut b; //~ ERROR loan of mutable local variable as mutable conflicts with prior loan - //~^ ERROR loan of mutable local variable as mutable conflicts with prior loan - io::println(fmt!("*p = %u", *p)); - q.x += 1; - r.foo.x += 1; - io::println(fmt!("*p = %u", *p)); -} diff --git a/src/test/compile-fail/borrowck-imm-field-imm-base.rs b/src/test/compile-fail/borrowck-insert-during-each.rs similarity index 57% rename from src/test/compile-fail/borrowck-imm-field-imm-base.rs rename to src/test/compile-fail/borrowck-insert-during-each.rs index 0d850fd5cee0f..1dcf8268440eb 100644 --- a/src/test/compile-fail/borrowck-imm-field-imm-base.rs +++ b/src/test/compile-fail/borrowck-insert-during-each.rs @@ -8,20 +8,27 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use core::hashmap::linear::LinearSet; + struct Foo { - x: uint + n: LinearSet, +} + +impl Foo { + fn foo(&mut self, fun: fn(&int)) { + for self.n.each |f| { + fun(f); + } + } } -struct Bar { - foo: Foo +fn bar(f: &mut Foo) { + do f.foo |a| { //~ NOTE prior loan as mutable granted here + f.n.insert(*a); //~ ERROR conflicts with prior loan + } } fn main() { - let mut b = Bar { foo: Foo { x: 3 } }; - let p = &b; //~ NOTE prior loan as immutable granted here - let q = &mut b.foo.x; //~ ERROR loan of mutable local variable as mutable conflicts with prior loan - let r = &p.foo.x; - io::println(fmt!("*r = %u", *r)); - *q += 1; - io::println(fmt!("*r = %u", *r)); + let mut f = Foo { n: LinearSet::new() }; + bar(&mut f); } \ No newline at end of file diff --git a/src/test/compile-fail/borrowck-reborrow-from-mut.rs b/src/test/compile-fail/borrowck-reborrow-from-mut.rs new file mode 100644 index 0000000000000..60f817dee0c54 --- /dev/null +++ b/src/test/compile-fail/borrowck-reborrow-from-mut.rs @@ -0,0 +1,106 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct Foo { + bar1: Bar, + bar2: Bar +} + +struct Bar { + int1: int, + int2: int, +} + +fn borrow_same_field_twice_mut_mut(foo: &mut Foo) { + let _bar1 = &mut foo.bar1; + let _bar2 = &mut foo.bar1; //~ ERROR conflicts with prior loan +} + +fn borrow_same_field_twice_mut_imm(foo: &mut Foo) { + let _bar1 = &mut foo.bar1; + let _bar2 = &foo.bar1; //~ ERROR conflicts with prior loan +} + +fn borrow_same_field_twice_imm_mut(foo: &mut Foo) { + let _bar1 = &foo.bar1; + let _bar2 = &mut foo.bar1; //~ ERROR conflicts with prior loan +} + +fn borrow_same_field_twice_imm_imm(foo: &mut Foo) { + let _bar1 = &foo.bar1; + let _bar2 = &foo.bar1; +} + +fn borrow_both_mut(foo: &mut Foo) { + let _bar1 = &mut foo.bar1; + let _bar2 = &mut foo.bar2; +} + +fn borrow_both_mut_pattern(foo: &mut Foo) { + match *foo { + Foo { bar1: ref mut _bar1, bar2: ref mut _bar2 } => {} + } +} + +fn borrow_var_and_pattern(foo: &mut Foo) { + let _bar1 = &mut foo.bar1; + match *foo { + Foo { bar1: ref mut _bar1, bar2: _ } => {} + //~^ ERROR conflicts with prior loan + } +} + +fn borrow_mut_and_base_imm(foo: &mut Foo) { + let _bar1 = &mut foo.bar1.int1; + let _foo1 = &foo.bar1; //~ ERROR conflicts with prior loan + let _foo2 = &*foo; //~ ERROR conflicts with prior loan +} + +fn borrow_mut_and_base_mut(foo: &mut Foo) { + let _bar1 = &mut foo.bar1.int1; + let _foo1 = &mut foo.bar1; //~ ERROR conflicts with prior loan +} + +fn borrow_mut_and_base_mut2(foo: &mut Foo) { + let _bar1 = &mut foo.bar1.int1; + let _foo2 = &mut *foo; //~ ERROR conflicts with prior loan +} + +fn borrow_imm_and_base_mut(foo: &mut Foo) { + let _bar1 = &foo.bar1.int1; + let _foo1 = &mut foo.bar1; //~ ERROR conflicts with prior loan +} + +fn borrow_imm_and_base_mut2(foo: &mut Foo) { + let _bar1 = &foo.bar1.int1; + let _foo2 = &mut *foo; //~ ERROR conflicts with prior loan +} + +fn borrow_imm_and_base_imm(foo: &mut Foo) { + let _bar1 = &foo.bar1.int1; + let _foo1 = &foo.bar1; + let _foo2 = &*foo; +} + +fn borrow_mut_and_imm(foo: &mut Foo) { + let _bar1 = &mut foo.bar1; + let _foo1 = &foo.bar2; +} + +fn borrow_mut_from_imm(foo: &Foo) { + let _bar1 = &mut foo.bar1; //~ ERROR illegal borrow +} + +fn borrow_long_path_both_mut(foo: &mut Foo) { + let _bar1 = &mut foo.bar1.int1; + let _foo1 = &mut foo.bar2.int2; +} + +fn main() {} diff --git a/src/test/compile-fail/obsolete-syntax.rs b/src/test/compile-fail/obsolete-syntax.rs index 9001ca99ef287..d92b545d1701f 100644 --- a/src/test/compile-fail/obsolete-syntax.rs +++ b/src/test/compile-fail/obsolete-syntax.rs @@ -29,14 +29,6 @@ struct s { //~^ ERROR obsolete syntax: struct constructor } -struct ss { - fn foo() { } - //~^ ERROR obsolete syntax: class method - #[whatever] - fn foo() { } - //~^ ERROR obsolete syntax: class method -} - struct q : r { //~^ ERROR obsolete syntax: class traits } diff --git a/src/test/debug-info/simple.rs b/src/test/debug-info/simple.rs new file mode 100644 index 0000000000000..51bb177601ae1 --- /dev/null +++ b/src/test/debug-info/simple.rs @@ -0,0 +1,21 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// xfail-test +// compile-flags:-g +// debugger:break 20 +// debugger:run +// debugger:print x +// check:$1 = 42 + +fn main() { + let x = 42; + debug!("The answer is %d", x); +} diff --git a/src/test/debug-info/struct.rs b/src/test/debug-info/struct.rs new file mode 100644 index 0000000000000..b313291447794 --- /dev/null +++ b/src/test/debug-info/struct.rs @@ -0,0 +1,33 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// xfail-test +// compile-flags:-g +// debugger:break 32 +// debugger:run +// debugger:print pair +// check:$1 = { +// check:x = 1, +// check:y = 2, +// check:} +// debugger:print pair.x +// check:$2 = 1 +// debugger:print pair.y +// check:$3 = 2 + +struct Pair { + x: int, + y: int +} + +fn main() { + let pair = Pair { x: 1, y: 2 }; + debug!("x = %d, y = %d", pair.x, pair.y); +} diff --git a/src/test/run-fail/morestack2.rs b/src/test/run-fail/morestack2.rs index 58957aac2038a..8236489834d11 100644 --- a/src/test/run-fail/morestack2.rs +++ b/src/test/run-fail/morestack2.rs @@ -18,7 +18,7 @@ extern mod std; extern mod rustrt { - pub fn last_os_error() -> ~str; + pub fn rust_get_argc() -> libc::c_int; } fn getbig_call_c_and_fail(i: int) { @@ -26,7 +26,7 @@ fn getbig_call_c_and_fail(i: int) { getbig_call_c_and_fail(i - 1); } else { unsafe { - rustrt::last_os_error(); + rustrt::rust_get_argc(); die!(); } } diff --git a/src/test/run-pass/anon-extern-mod-cross-crate-2.rs b/src/test/run-pass/anon-extern-mod-cross-crate-2.rs index 939903b3b124a..ed57b32b3d9e5 100644 --- a/src/test/run-pass/anon-extern-mod-cross-crate-2.rs +++ b/src/test/run-pass/anon-extern-mod-cross-crate-2.rs @@ -15,5 +15,5 @@ extern mod anonexternmod; use anonexternmod::*; pub fn main() { - last_os_error(); + rust_get_argc(); } diff --git a/src/test/run-pass/anon-extern-mod.rs b/src/test/run-pass/anon-extern-mod.rs index 525e6b9fbd6d9..6e73022fad2e1 100644 --- a/src/test/run-pass/anon-extern-mod.rs +++ b/src/test/run-pass/anon-extern-mod.rs @@ -11,11 +11,11 @@ #[abi = "cdecl"] #[link_name = "rustrt"] extern { - fn last_os_error() -> ~str; + fn rust_get_argc() -> libc::c_int; } pub fn main() { unsafe { - let _ = last_os_error(); + let _ = rust_get_argc(); } } diff --git a/src/test/run-pass/foreign-dupe.rs b/src/test/run-pass/foreign-dupe.rs index 77ed95a809980..6230fe11363ad 100644 --- a/src/test/run-pass/foreign-dupe.rs +++ b/src/test/run-pass/foreign-dupe.rs @@ -14,18 +14,18 @@ #[abi = "cdecl"] #[link_name = "rustrt"] extern mod rustrt1 { - pub fn last_os_error() -> ~str; + pub fn rust_get_argc() -> libc::c_int; } #[abi = "cdecl"] #[link_name = "rustrt"] extern mod rustrt2 { - pub fn last_os_error() -> ~str; + pub fn rust_get_argc() -> libc::c_int; } pub fn main() { unsafe { - rustrt1::last_os_error(); - rustrt2::last_os_error(); + rustrt1::rust_get_argc(); + rustrt2::rust_get_argc(); } } diff --git a/src/test/run-pass/invoke-external-foreign.rs b/src/test/run-pass/invoke-external-foreign.rs index cc50e06199db4..69fce9e541e06 100644 --- a/src/test/run-pass/invoke-external-foreign.rs +++ b/src/test/run-pass/invoke-external-foreign.rs @@ -18,5 +18,5 @@ extern mod foreign_lib; pub fn main() { - let foo = foreign_lib::rustrt::last_os_error(); + let foo = foreign_lib::rustrt::rust_get_argc(); } diff --git a/src/test/run-pass/issue-4830.rs b/src/test/run-pass/issue-4830.rs new file mode 100644 index 0000000000000..e8147a2ce8237 --- /dev/null +++ b/src/test/run-pass/issue-4830.rs @@ -0,0 +1,16 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub struct Scheduler { + /// The event loop used to drive the scheduler and perform I/O + priv event_loop: ~int +} + +pub fn main() { } diff --git a/src/test/run-pass/morestack6.rs b/src/test/run-pass/morestack6.rs index 9b852cbc635aa..d56d9c30b7066 100644 --- a/src/test/run-pass/morestack6.rs +++ b/src/test/run-pass/morestack6.rs @@ -15,7 +15,7 @@ extern mod rustrt { pub fn debug_get_stk_seg() -> *u8; pub fn rust_get_sched_id() -> libc::intptr_t; - pub fn last_os_error() -> ~str; + pub fn rust_get_argc() -> libc::c_int; pub fn rust_getcwd() -> ~str; pub fn get_task_id() -> libc::intptr_t; pub fn rust_sched_threads(); @@ -23,7 +23,7 @@ extern mod rustrt { } fn calllink01() { unsafe { rustrt::rust_get_sched_id(); } } -fn calllink02() { unsafe { rustrt::last_os_error(); } } +fn calllink02() { unsafe { rustrt::rust_get_argc(); } } fn calllink03() { unsafe { rustrt::rust_getcwd(); } } fn calllink08() { unsafe { rustrt::get_task_id(); } } fn calllink09() { unsafe { rustrt::rust_sched_threads(); } } diff --git a/src/test/run-pass/syntax-extension-source-utils.rs b/src/test/run-pass/syntax-extension-source-utils.rs index 342ee4e351064..65ef3cc4f69fc 100644 --- a/src/test/run-pass/syntax-extension-source-utils.rs +++ b/src/test/run-pass/syntax-extension-source-utils.rs @@ -1,4 +1,4 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -17,9 +17,12 @@ pub mod m1 { } } +macro_rules! indirect_line( () => ( line!() ) ) + pub fn main() { - assert(line!() == 21); + assert(line!() == 23); assert(col!() == 11); + assert(indirect_line!() == 25); assert(file!().to_owned().ends_with(~"syntax-extension-source-utils.rs")); assert(stringify!((2*3) + 5).to_owned() == ~"( 2 * 3 ) + 5"); assert(include!("syntax-extension-source-utils-files/includeme.fragment").to_owned() diff --git a/src/test/run-pass/trait-inheritance-num.rs b/src/test/run-pass/trait-inheritance-num.rs index ca720c27d77ad..c7a049b2f34e0 100644 --- a/src/test/run-pass/trait-inheritance-num.rs +++ b/src/test/run-pass/trait-inheritance-num.rs @@ -11,16 +11,16 @@ // except according to those terms. use cmp::{Eq, Ord}; -use num::Num::from_int; +use num::NumCast::from; extern mod std; use std::cmp::FuzzyEq; -pub trait NumExt: Num Eq Ord {} +pub trait NumExt: Num NumCast Eq Ord {} pub trait FloatExt: NumExt FuzzyEq {} -fn greater_than_one(n: &T) -> bool { *n > from_int(1) } -fn greater_than_one_float(n: &T) -> bool { *n > from_int(1) } +fn greater_than_one(n: &T) -> bool { *n > from(1) } +fn greater_than_one_float(n: &T) -> bool { *n > from(1) } pub fn main() {} diff --git a/src/test/run-pass/trait-inheritance-num0.rs b/src/test/run-pass/trait-inheritance-num0.rs index c7f43e055a4d3..1996e05618a0d 100644 --- a/src/test/run-pass/trait-inheritance-num0.rs +++ b/src/test/run-pass/trait-inheritance-num0.rs @@ -12,17 +12,17 @@ // Extending Num and using inherited static methods -use Num::from_int; +use num::NumCast::from; trait Num { static fn from_int(i: int) -> Self; fn gt(&self, other: &Self) -> bool; } -pub trait NumExt: Num { } +pub trait NumExt: Num NumCast { } fn greater_than_one(n: &T) -> bool { - n.gt(&from_int(1)) + n.gt(&from(1)) } pub fn main() {} diff --git a/src/test/run-pass/trait-inheritance-num1.rs b/src/test/run-pass/trait-inheritance-num1.rs index 7546735993677..a9cbd4e622c40 100644 --- a/src/test/run-pass/trait-inheritance-num1.rs +++ b/src/test/run-pass/trait-inheritance-num1.rs @@ -11,12 +11,12 @@ // Using the real Num from core use cmp::Ord; -use num::Num::from_int; +use num::NumCast::from; -pub trait NumExt: Num Ord { } +pub trait NumExt: Num NumCast Ord { } fn greater_than_one(n: &T) -> bool { - *n > from_int(1) + *n > from(1) } pub fn main() {} diff --git a/src/test/run-pass/trait-inheritance-num2.rs b/src/test/run-pass/trait-inheritance-num2.rs index ecedaac8daaab..6829990bc5acd 100644 --- a/src/test/run-pass/trait-inheritance-num2.rs +++ b/src/test/run-pass/trait-inheritance-num2.rs @@ -13,7 +13,7 @@ // A more complex example of numeric extensions use cmp::{Eq, Ord}; -use num::Num::from_int; +use num::NumCast::from; extern mod std; use std::cmp::FuzzyEq; @@ -38,7 +38,7 @@ pub impl f64: TypeExt {} pub impl float: TypeExt {} -pub trait NumExt: TypeExt Eq Ord Num {} +pub trait NumExt: TypeExt Eq Ord Num NumCast {} pub impl u8: NumExt {} pub impl u16: NumExt {} diff --git a/src/test/run-pass/trait-inheritance-num3.rs b/src/test/run-pass/trait-inheritance-num3.rs index 939b074e2dd54..32775164d35ef 100644 --- a/src/test/run-pass/trait-inheritance-num3.rs +++ b/src/test/run-pass/trait-inheritance-num3.rs @@ -9,13 +9,13 @@ // except according to those terms. use cmp::{Eq, Ord}; -use num::Num::from_int; +use num::NumCast::from; -pub trait NumExt: Eq Ord Num {} +pub trait NumExt: Eq Ord Num NumCast {} pub impl f32: NumExt {} -fn num_eq_one(n: T) { io::println(fmt!("%?", n == from_int(1))) } +fn num_eq_one(n: T) { io::println(fmt!("%?", n == from(1))) } pub fn main() { num_eq_one(1f32); // you need to actually use the function to trigger the ICE diff --git a/src/test/run-pass/trait-inheritance-num5.rs b/src/test/run-pass/trait-inheritance-num5.rs index bb9b57d4afb67..13c75224e5f88 100644 --- a/src/test/run-pass/trait-inheritance-num5.rs +++ b/src/test/run-pass/trait-inheritance-num5.rs @@ -9,15 +9,15 @@ // except according to those terms. use cmp::{Eq, Ord}; -use num::Num::from_int; +use num::NumCast::from; -pub trait NumExt: Eq Num {} +pub trait NumExt: Eq Num NumCast {} pub impl f32: NumExt {} pub impl int: NumExt {} fn num_eq_one() -> T { - from_int(1) + from(1) } pub fn main() {