diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2011-12-06 14:02:32 -0800 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2011-12-06 14:02:32 -0800 |
| commit | 39b1657b2cb17960f72467c4cb31d8ac7969661d (patch) | |
| tree | a7f6997068282f7fa72b95e7165abcb3df18ca0c | |
| parent | 7bf41392b62f8e118ac21842804808c516b953b0 (diff) | |
| parent | 89efb7d9810643eb1b25c04e63203b591915448f (diff) | |
Merge branch 'master' of github.com:graydon/rust
| -rw-r--r-- | Makefile.in | 30 | ||||
| -rwxr-xr-x | configure | 4 | ||||
| -rw-r--r-- | doc/Languages.txt | 1 | ||||
| -rw-r--r-- | doc/lib.css | 8 | ||||
| -rw-r--r-- | doc/std.css | 8 | ||||
| -rw-r--r-- | mk/dist.mk | 1 | ||||
| -rw-r--r-- | mk/docs.mk | 38 | ||||
| -rw-r--r-- | mk/host.mk | 16 | ||||
| -rw-r--r-- | mk/install.mk | 2 | ||||
| -rw-r--r-- | mk/platform.mk | 4 | ||||
| -rw-r--r-- | mk/pp.mk | 3 | ||||
| -rw-r--r-- | mk/rt.mk | 2 | ||||
| -rw-r--r-- | mk/stage0.mk | 9 | ||||
| -rw-r--r-- | mk/target.mk | 7 | ||||
| -rw-r--r-- | mk/tests.mk | 4 | ||||
| -rw-r--r-- | mk/tools.mk | 3 | ||||
| -rw-r--r-- | src/comp/driver/rustc.rs | 6 | ||||
| -rw-r--r-- | src/lib/ctypes.rs | 42 | ||||
| -rw-r--r-- | src/libcore/core.rc | 17 | ||||
| -rw-r--r-- | src/libstd/bitv.rs (renamed from src/lib/bitv.rs) | 0 | ||||
| -rw-r--r-- | src/libstd/bool.rs (renamed from src/lib/bool.rs) | 0 | ||||
| -rw-r--r-- | src/libstd/box.rs (renamed from src/lib/box.rs) | 0 | ||||
| -rw-r--r-- | src/libstd/c_vec.rs (renamed from src/lib/c_vec.rs) | 52 | ||||
| -rw-r--r-- | src/libstd/char.rs (renamed from src/lib/char.rs) | 0 | ||||
| -rw-r--r-- | src/libstd/cmath.rs (renamed from src/lib/cmath.rs) | 0 | ||||
| -rw-r--r-- | src/libstd/comm.rs (renamed from src/lib/comm.rs) | 0 | ||||
| -rw-r--r-- | src/libstd/ctypes.rs | 146 | ||||
| -rw-r--r-- | src/libstd/dbg.rs (renamed from src/lib/dbg.rs) | 0 | ||||
| -rw-r--r-- | src/libstd/deque.rs (renamed from src/lib/deque.rs) | 0 | ||||
| -rw-r--r-- | src/libstd/ebml.rs (renamed from src/lib/ebml.rs) | 0 | ||||
| -rw-r--r-- | src/libstd/either.rs (renamed from src/lib/either.rs) | 0 | ||||
| -rw-r--r-- | src/libstd/extfmt.rs (renamed from src/lib/extfmt.rs) | 0 | ||||
| -rw-r--r-- | src/libstd/float.rs (renamed from src/lib/float.rs) | 13 | ||||
| -rw-r--r-- | src/libstd/four.rs (renamed from src/lib/four.rs) | 0 | ||||
| -rw-r--r-- | src/libstd/fs.rs (renamed from src/lib/fs.rs) | 0 | ||||
| -rw-r--r-- | src/libstd/fun_treemap.rs (renamed from src/lib/fun_treemap.rs) | 0 | ||||
| -rw-r--r-- | src/libstd/generic_os.rs (renamed from src/lib/generic_os.rs) | 0 | ||||
| -rw-r--r-- | src/libstd/getopts.rs (renamed from src/lib/getopts.rs) | 0 | ||||
| -rw-r--r-- | src/libstd/int.rs (renamed from src/lib/int.rs) | 0 | ||||
| -rw-r--r-- | src/libstd/io.rs (renamed from src/lib/io.rs) | 6 | ||||
| -rw-r--r-- | src/libstd/json.rs (renamed from src/lib/json.rs) | 0 | ||||
| -rw-r--r-- | src/libstd/linux_os.rs (renamed from src/lib/linux_os.rs) | 0 | ||||
| -rw-r--r-- | src/libstd/list.rs (renamed from src/lib/list.rs) | 0 | ||||
| -rw-r--r-- | src/libstd/macos_os.rs (renamed from src/lib/macos_os.rs) | 0 | ||||
| -rw-r--r-- | src/libstd/map.rs (renamed from src/lib/map.rs) | 0 | ||||
| -rw-r--r-- | src/libstd/math.rs (renamed from src/lib/math.rs) | 3 | ||||
| -rw-r--r-- | src/libstd/math_f32.rs (renamed from src/lib/math_f32.rs) | 1 | ||||
| -rw-r--r-- | src/libstd/math_f64.rs (renamed from src/lib/math_f64.rs) | 1 | ||||
| -rw-r--r-- | src/libstd/net.rs (renamed from src/lib/net.rs) | 0 | ||||
| -rw-r--r-- | src/libstd/option.rs (renamed from src/lib/option.rs) | 0 | ||||
| -rw-r--r-- | src/libstd/posix_fs.rs (renamed from src/lib/posix_fs.rs) | 0 | ||||
| -rw-r--r-- | src/libstd/ptr.rs (renamed from src/lib/ptr.rs) | 0 | ||||
| -rw-r--r-- | src/libstd/rand.rs (renamed from src/lib/rand.rs) | 0 | ||||
| -rw-r--r-- | src/libstd/result.rs (renamed from src/lib/result.rs) | 0 | ||||
| -rw-r--r-- | src/libstd/rope.rs (renamed from src/lib/rope.rs) | 0 | ||||
| -rw-r--r-- | src/libstd/run_program.rs (renamed from src/lib/run_program.rs) | 0 | ||||
| -rw-r--r-- | src/libstd/sha1.rs (renamed from src/lib/sha1.rs) | 0 | ||||
| -rw-r--r-- | src/libstd/smallintmap.rs (renamed from src/lib/smallintmap.rs) | 0 | ||||
| -rw-r--r-- | src/libstd/sort.rs (renamed from src/lib/sort.rs) | 0 | ||||
| -rw-r--r-- | src/libstd/std.rc (renamed from src/lib/std.rc) | 0 | ||||
| -rw-r--r-- | src/libstd/str.rs (renamed from src/lib/str.rs) | 3 | ||||
| -rw-r--r-- | src/libstd/sys.rs (renamed from src/lib/sys.rs) | 0 | ||||
| -rw-r--r-- | src/libstd/task.rs (renamed from src/lib/task.rs) | 0 | ||||
| -rw-r--r-- | src/libstd/tempfile.rs (renamed from src/lib/tempfile.rs) | 3 | ||||
| -rw-r--r-- | src/libstd/term.rs (renamed from src/lib/term.rs) | 0 | ||||
| -rw-r--r-- | src/libstd/test.rs (renamed from src/lib/test.rs) | 0 | ||||
| -rw-r--r-- | src/libstd/time.rs (renamed from src/lib/time.rs) | 0 | ||||
| -rw-r--r-- | src/libstd/treemap.rs (renamed from src/lib/treemap.rs) | 0 | ||||
| -rw-r--r-- | src/libstd/tri.rs (renamed from src/lib/tri.rs) | 0 | ||||
| -rw-r--r-- | src/libstd/u32.rs (renamed from src/lib/u32.rs) | 0 | ||||
| -rw-r--r-- | src/libstd/u64.rs (renamed from src/lib/u64.rs) | 0 | ||||
| -rw-r--r-- | src/libstd/u8.rs (renamed from src/lib/u8.rs) | 0 | ||||
| -rw-r--r-- | src/libstd/ufind.rs (renamed from src/lib/ufind.rs) | 0 | ||||
| -rw-r--r-- | src/libstd/uint.rs (renamed from src/lib/uint.rs) | 0 | ||||
| -rw-r--r-- | src/libstd/unicode.rs (renamed from src/lib/unicode.rs) | 0 | ||||
| -rw-r--r-- | src/libstd/unsafe.rs (renamed from src/lib/unsafe.rs) | 0 | ||||
| -rw-r--r-- | src/libstd/util.rs (renamed from src/lib/util.rs) | 0 | ||||
| -rw-r--r-- | src/libstd/uv.rs (renamed from src/lib/uv.rs) | 0 | ||||
| -rw-r--r-- | src/libstd/vec.rs (renamed from src/lib/vec.rs) | 0 | ||||
| -rw-r--r-- | src/libstd/win32_fs.rs (renamed from src/lib/win32_fs.rs) | 0 | ||||
| -rw-r--r-- | src/libstd/win32_os.rs (renamed from src/lib/win32_os.rs) | 0 | ||||
| -rw-r--r-- | src/rt/arch/i386/context.h | 4 | ||||
| -rw-r--r-- | src/rt/arch/i386/morestack.S | 9 | ||||
| -rw-r--r-- | src/rt/arch/x86_64/context.h | 6 | ||||
| -rw-r--r-- | src/rt/arch/x86_64/morestack.S | 6 | ||||
| -rw-r--r-- | src/rt/rust_builtin.cpp | 6 | ||||
| -rw-r--r-- | src/rt/rust_task.cpp | 7 | ||||
| -rw-r--r-- | src/rt/rust_timer.cpp | 2 | ||||
| -rw-r--r-- | src/rt/rust_upcall.cpp | 38 | ||||
| -rw-r--r-- | src/rt/rustrt.def.in | 1 | ||||
| -rw-r--r-- | src/rt/vg/memcheck.h (renamed from src/rt/memcheck.h) | 0 | ||||
| -rw-r--r-- | src/rt/vg/valgrind.h (renamed from src/rt/valgrind.h) | 0 | ||||
| -rw-r--r-- | src/test/run-fail/morestack2.rs | 41 | ||||
| -rw-r--r-- | src/test/run-fail/morestack3.rs | 34 | ||||
| -rw-r--r-- | src/test/run-pass/morestack4.rs | 100 | ||||
| -rw-r--r-- | src/test/run-pass/morestack5.rs | 26 | ||||
| -rw-r--r-- | src/test/run-pass/morestack6.rs | 81 |
97 files changed, 677 insertions, 117 deletions
diff --git a/Makefile.in b/Makefile.in index 52ab6d98eda..ec08f124b72 100644 --- a/Makefile.in +++ b/Makefile.in @@ -104,6 +104,7 @@ endif CFG_RUNTIME :=$(call CFG_LIB_NAME,rustrt) CFG_RUSTLLVM :=$(call CFG_LIB_NAME,rustllvm) +CFG_CORELIB :=$(call CFG_LIB_NAME,core) CFG_STDLIB :=$(call CFG_LIB_NAME,ruststd) CFG_LIBRUSTC :=$(call CFG_LIB_NAME,rustc) @@ -144,9 +145,9 @@ else endif ifeq ($(CFG_NATURALDOCS),) - $(info cfg: no naturaldocs found, omitting doc/std/index.html) + $(info cfg: no naturaldocs found, omitting library doc build) else - DOCS += doc/std/index.html + DOCS += doc/core/index.html doc/std/index.html endif ifdef CFG_DISABLE_DOCS @@ -184,11 +185,20 @@ GENERATED := %:: SCCS/s.% ###################################################################### +# Core library variables +###################################################################### + +CORELIB_CRATE := $(S)src/libcore/core.rc +CORELIB_INPUTS := $(wildcard $(addprefix $(S)src/libcore/, \ + core.rc *.rs */*.rs)) + +###################################################################### # Standard library variables ###################################################################### -STDLIB_CRATE := $(S)src/lib/std.rc -STDLIB_INPUTS := $(wildcard $(addprefix $(S)src/lib/,*.rc *.rs */*.rs)) +STDLIB_CRATE := $(S)src/libstd/std.rc +STDLIB_INPUTS := $(wildcard $(addprefix $(S)src/libstd/, \ + std.rc *.rs */*.rs)) ###################################################################### # rustc crate variables @@ -268,13 +278,21 @@ TROOT$(1)_T_$(2)_H_$(3) = $$(HLIB$(1)_H_$(3))/rustc/$(2) TBIN$(1)_T_$(2)_H_$(3) = $$(TROOT$(1)_T_$(2)_H_$(3))/bin TLIB$(1)_T_$(2)_H_$(3) = $$(TROOT$(1)_T_$(2)_H_$(3))/lib -# The name of the standard library used by rustc +# The name of the core and standard libraries used by rustc ifdef CFG_DISABLE_SHAREDSTD + HCORELIB_DEFAULT$(1)_H_$(3) = \ + $$(HLIB$(1)_H_$(3))/libcore.rlib + TCORELIB_DEFAULT$(1)_T_$(2)_H_$(3) = \ + $$(TLIB$(1)_T_$(2)_H_$(3))/libcore.rlib HSTDLIB_DEFAULT$(1)_H_$(3) = \ $$(HLIB$(1)_H_$(3))/libstd.rlib TSTDLIB_DEFAULT$(1)_T_$(2)_H_$(3) = \ $$(TLIB$(1)_T_$(2)_H_$(3))/libstd.rlib else + HCORELIB_DEFAULT$(1)_H_$(3) = \ + $$(HLIB$(1)_H_$(3))/$(CFG_CORELIB) + TCORELIB_DEFAULT$(1)_T_$(2)_H_$(3) = \ + $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_CORELIB) HSTDLIB_DEFAULT$(1)_H_$(3) = \ $$(HLIB$(1)_H_$(3))/$(CFG_STDLIB) TSTDLIB_DEFAULT$(1)_T_$(2)_H_$(3) = \ @@ -286,6 +304,7 @@ HSREQ$(1)_H_$(3) = \ $$(HBIN$(1)_H_$(3))/rustc$$(X) \ $$(HLIB$(1)_H_$(3))/$$(CFG_RUNTIME) \ $$(HLIB$(1)_H_$(3))/$$(CFG_RUSTLLVM) \ + $$(HCORELIB_DEFAULT$(1)_H_$(3)) \ $$(HSTDLIB_DEFAULT$(1)_H_$(3)) \ $$(MKFILE_DEPS) @@ -299,6 +318,7 @@ TSREQ$(1)_T_$(2)_H_$(3) = \ # Prerequisites for complete stageN targets SREQ$(1)_T_$(2)_H_$(3) = \ $$(TSREQ$(1)_T_$(2)_H_$(3)) \ + $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_CORELIB) \ $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_STDLIB) ifeq ($(1),0) diff --git a/configure b/configure index d583e6a4b43..009e24059cf 100755 --- a/configure +++ b/configure @@ -355,8 +355,8 @@ fi step_msg "making directories" for i in \ - doc doc/std \ - nd nd/std \ + doc doc/core doc/std \ + nd nd/core nd/std \ dl tmp do make_dir $i diff --git a/doc/Languages.txt b/doc/Languages.txt index c83e0d86ca9..565e4c27109 100644 --- a/doc/Languages.txt +++ b/doc/Languages.txt @@ -120,6 +120,7 @@ Language: Rust Block Comment: /* */ Package Separator: :: Function Prototype Enders: ; { + Predicate Prototype Enders: ; { Type Prototype Enders: ; } Class Prototype Enders: { Variant Prototype Enders: ; diff --git a/doc/lib.css b/doc/lib.css new file mode 100644 index 00000000000..443f1180584 --- /dev/null +++ b/doc/lib.css @@ -0,0 +1,8 @@ +/* +Custom styles for the library docs generated by naturaldocs +*/ + +p { + text-indent: 0; + margin-bottom: 1em; + } diff --git a/doc/std.css b/doc/std.css deleted file mode 100644 index 9593f25e8f6..00000000000 --- a/doc/std.css +++ /dev/null @@ -1,8 +0,0 @@ -/* -Custom styles for the standard library docs generated by naturaldocs -*/ - -p { - text-indent: 0; - margin-bottom: 1em; - } \ No newline at end of file diff --git a/mk/dist.mk b/mk/dist.mk index 54fcfdeb013..a8df2c28fbe 100644 --- a/mk/dist.mk +++ b/mk/dist.mk @@ -46,6 +46,7 @@ PKG_FILES = \ $(PKG_3RDPARTY)) \ $(PKG_UV) \ $(COMPILER_INPUTS) \ + $(CORELIB_INPUTS) \ $(STDLIB_INPUTS) \ $(ALL_TEST_INPUTS) \ $(FUZZER_CRATE) \ diff --git a/mk/docs.mk b/mk/docs.mk index b4250194c48..4a5821ec2df 100644 --- a/mk/docs.mk +++ b/mk/docs.mk @@ -29,19 +29,25 @@ docsnap: doc/rust.pdf @$(call E, snap: doc/rust-$(shell date +"%Y-%m-%d")-snap.pdf) $(Q)mv $< doc/rust-$(shell date +"%Y-%m-%d")-snap.pdf -doc/std/index.html: nd/std/Languages.txt nd/std/Topics.txt nd/std/std.css \ - $(STDLIB_CRATE) $(STDLIB_INPUTS) - @$(call E, naturaldocs: $@) - naturaldocs -i $(S)src/lib -o HTML doc/std -p nd/std -r -s Default std - -nd/std/Languages.txt: $(S)doc/Languages.txt - @$(call E, cp: $@) - $(Q)cp $< $@ - -nd/std/Topics.txt: $(S)doc/Topics.txt - @$(call E, cp: $@) - $(Q)cp $< $@ - -nd/std/std.css: $(S)doc/std.css - @$(call E, cp: $@) - $(Q)cp $< $@ +define libdoc +doc/$(1)/index.html: nd/$(1)/Languages.txt nd/$(1)/Topics.txt \ + nd/$(1)/lib.css $(2) + @$$(call E, naturaldocs: $$@) + naturaldocs -i $(S)src/lib$(1) -o HTML doc/$(1) -p nd/$(1) -r -s Default lib + +nd/$(1)/Languages.txt: $(S)doc/Languages.txt + @$$(call E, cp: $$@) + $(Q)cp $$< $$@ + +nd/$(1)/Topics.txt: $(S)doc/Topics.txt + @$$(call E, cp: $$@) + $(Q)cp $$< $$@ + +nd/$(1)/lib.css: $(S)doc/lib.css + @$$(call E, cp: $$@) + $(Q)cp $$< $$@ + +endef + +$(eval $(call libdoc,core,$(CORELIB_CRATE) $(CORELIB_INPUTS))) +$(eval $(call libdoc,std,$(STDLIB_CRATE) $(STDLIB_INPUTS))) diff --git a/mk/host.mk b/mk/host.mk index eae38abc64f..add7278dee2 100644 --- a/mk/host.mk +++ b/mk/host.mk @@ -15,6 +15,7 @@ $$(HBIN$(2)_H_$(4))/rustc$$(X): \ $$(TBIN$(1)_T_$(4)_H_$(3))/rustc$$(X) \ $$(HLIB$(2)_H_$(4))/$$(CFG_RUNTIME) \ $$(HLIB$(2)_H_$(4))/$$(CFG_RUSTLLVM) \ + $$(HCORELIB_DEFAULT$(2)_H_$(4)) \ $$(HSTDLIB_DEFAULT$(2)_H_$(4)) @$$(call E, cp: $$@) $$(Q)cp $$< $$@ @@ -25,6 +26,7 @@ $$(HLIB$(2)_H_$(4))/$$(CFG_LIBRUSTC): \ $$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_LIBRUSTC) \ $$(HLIB$(2)_H_$(4))/$$(CFG_RUNTIME) \ $$(HLIB$(2)_H_$(4))/$$(CFG_RUSTLLVM) \ + $$(HCORELIB_DEFAULT$(2)_H_$(3)) \ $$(HSTDLIB_DEFAULT$(2)_H_$(3)) @$$(call E, cp: $$@) $$(Q)cp $$< $$@ @@ -34,14 +36,28 @@ $$(HLIB$(2)_H_$(4))/$$(CFG_RUNTIME): \ @$$(call E, cp: $$@) $$(Q)cp $$< $$@ +$$(HLIB$(2)_H_$(4))/$$(CFG_CORELIB): \ + $$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_CORELIB) \ + $$(HLIB$(2)_H_$(4))/$$(CFG_RUNTIME) + @$$(call E, cp: $$@) + $$(Q)cp $$< $$@ + $$(HLIB$(2)_H_$(4))/$$(CFG_STDLIB): \ $$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_STDLIB) \ + $$(HLIB$(2)_H_$(4))/$$(CFG_CORELIB) \ + $$(HLIB$(2)_H_$(4))/$$(CFG_RUNTIME) + @$$(call E, cp: $$@) + $$(Q)cp $$< $$@ + +$$(HLIB$(2)_H_$(4))/libcore.rlib: \ + $$(TLIB$(1)_T_$(4)_H_$(3))/libcore.rlib \ $$(HLIB$(2)_H_$(4))/$$(CFG_RUNTIME) @$$(call E, cp: $$@) $$(Q)cp $$< $$@ $$(HLIB$(2)_H_$(4))/libstd.rlib: \ $$(TLIB$(1)_T_$(4)_H_$(3))/libstd.rlib \ + $$(HLIB$(2)_H_$(4))/libcore.rlib \ $$(HLIB$(2)_H_$(4))/$$(CFG_RUNTIME) @$$(call E, cp: $$@) $$(Q)cp $$< $$@ diff --git a/mk/install.mk b/mk/install.mk index fc69b7131d7..c22a4a37010 100644 --- a/mk/install.mk +++ b/mk/install.mk @@ -33,6 +33,7 @@ PTL$(1)$(2) = $$(PTR$(1)$(2))/lib install-target-$(1)-host-$(2): $$(SREQ$$(ISTAGE)_T_$(1)_H_$(2)) $$(Q)mkdir -p $$(PTL$(1)$(2)) $$(Q)$$(call INSTALL,$$(TL$(1)$(2)),$$(PTL$(1)$(2)),$$(CFG_RUNTIME)) + $$(Q)$$(call INSTALL,$$(TL$(1)$(2)),$$(PTL$(1)$(2)),$$(CFG_CORELIB)) $$(Q)$$(call INSTALL,$$(TL$(1)$(2)),$$(PTL$(1)$(2)),$$(CFG_STDLIB)) $$(Q)$$(call INSTALL,$$(TL$(1)$(2)),$$(PTL$(1)$(2)),intrinsics.bc) $$(Q)$$(call INSTALL,$$(TL$(1)$(2)),$$(PTL$(1)$(2)),libmorestack.a) @@ -61,6 +62,7 @@ install-host: $(SREQ$(ISTAGE)_T_$(CFG_HOST_TRIPLE)_H_$(CFG_HOST_TRIPLE)) $(Q)mkdir -p $(PREFIX_ROOT)/share/man/man1 $(Q)$(call INSTALL,$(HB),$(PHB),rustc$(X)) $(Q)$(call INSTALL,$(HL),$(PHL),$(CFG_RUNTIME)) + $(Q)$(call INSTALL,$(HL),$(PHL),$(CFG_CORELIB)) $(Q)$(call INSTALL,$(HL),$(PHL),$(CFG_STDLIB)) $(Q)$(call INSTALL,$(HL),$(PHL),$(CFG_RUSTLLVM)) $(Q)$(call INSTALL,$(S)/man, \ diff --git a/mk/platform.mk b/mk/platform.mk index 28ecb0a10e9..430a835ba86 100644 --- a/mk/platform.mk +++ b/mk/platform.mk @@ -17,8 +17,8 @@ CFG_GCCISH_LINK_FLAGS := # embedded into the executable, so use a no-op command. CFG_DSYMUTIL := true -ifneq ($(CFG_VALGRIND),) - CFG_GCCISH_CFLAGS += -DHAVE_VALGRIND +ifeq ($(CFG_VALGRIND),) + CFG_GCCISH_CFLAGS += -DNVALGRIND endif ifneq ($(findstring freebsd,$(CFG_OSTYPE)),) diff --git a/mk/pp.mk b/mk/pp.mk index 7ee3cee8c41..df414901f7f 100644 --- a/mk/pp.mk +++ b/mk/pp.mk @@ -2,7 +2,8 @@ ifdef PPFILES PP_INPUTS_FILTERED := $(wildcard $(PPFILES)) else - PP_INPUTS = $(wildcard $(addprefix $(S)src/lib/,*.rs */*.rs)) \ + PP_INPUTS = $(wildcard $(addprefix $(S)src/libcore/,*.rs */*.rs)) \ + $(wildcard $(addprefix $(S)src/libstd/,*.rs */*.rs)) \ $(wildcard $(addprefix $(S)src/comp/,*.rs */*.rs */*/*.rs)) \ $(wildcard $(S)src/test/*/*.rs \ $(S)src/test/*/*/*.rs) \ diff --git a/mk/rt.mk b/mk/rt.mk index e45430f7690..0d9bb5c3408 100644 --- a/mk/rt.mk +++ b/mk/rt.mk @@ -125,7 +125,7 @@ else endif RUNTIME_DEF_$(1) := rt/rustrt$$(CFG_DEF_SUFFIX) -RUNTIME_INCS_$(1) := -I $$(S)src/rt/isaac -I $$(S)src/rt/uthash \ +RUNTIME_INCS_$(1) := -I $$(S)src/rt -I $$(S)src/rt/isaac -I $$(S)src/rt/uthash \ -I $$(S)src/rt/arch/$$(HOST_$(1)) \ -I $$(S)src/libuv/include RUNTIME_OBJS_$(1) := $$(RUNTIME_CS_$(1):rt/%.cpp=rt/$(1)/%.o) \ diff --git a/mk/stage0.mk b/mk/stage0.mk index a7e2341f654..7614c230406 100644 --- a/mk/stage0.mk +++ b/mk/stage0.mk @@ -13,6 +13,10 @@ $(HLIB0_H_$(CFG_HOST_TRIPLE))/$(CFG_RUNTIME): \ $(HBIN0_H_$(CFG_HOST_TRIPLE))/rustc$(X) $(Q)touch $@ +$(HLIB0_H_$(CFG_HOST_TRIPLE))/$(CFG_CORELIB): \ + $(HBIN0_H_$(CFG_HOST_TRIPLE))/rustc$(X) + $(Q)touch $@ + $(HLIB0_H_$(CFG_HOST_TRIPLE))/$(CFG_STDLIB): \ $(HBIN0_H_$(CFG_HOST_TRIPLE))/rustc$(X) $(Q)touch $@ @@ -38,6 +42,11 @@ $$(HLIB0_H_$(1))/$$(CFG_RUNTIME): \ @$$(call E, cp: $$@) $$(Q)cp $$< $$@ +$$(HLIB0_H_$(1))/$(CFG_CORELIB): \ + $$(TLIB$(2)_T_$(1)_H_$(3))/$$(CFG_CORELIB) + @$$(call E, cp: $$@) + $$(Q)cp $$< $$@ + $$(HLIB0_H_$(1))/$(CFG_STDLIB): \ $$(TLIB$(2)_T_$(1)_H_$(3))/$$(CFG_STDLIB) @$$(call E, cp: $$@) diff --git a/mk/target.mk b/mk/target.mk index 5b91d70ae9a..ecedff1c5d1 100644 --- a/mk/target.mk +++ b/mk/target.mk @@ -22,8 +22,15 @@ $$(TLIB$(1)_T_$(2)_H_$(3))/libmorestack.a: \ @$$(call E, cp: $$@) $$(Q)cp $$< $$@ +$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_CORELIB): \ + $$(CORELIB_CRATE) $$(CORELIB_INPUTS) \ + $$(TSREQ$(1)_T_$(2)_H_$(3)) + @$$(call E, compile_and_link: $$@) + $$(STAGE$(1)_T_$(2)_H_$(3)) --lib -o $$@ $$< + $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_STDLIB): \ $$(STDLIB_CRATE) $$(STDLIB_INPUTS) \ + $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_CORELIB) \ $$(TSREQ$(1)_T_$(2)_H_$(3)) @$$(call E, compile_and_link: $$@) $$(STAGE$(1)_T_$(2)_H_$(3)) --lib -o $$@ $$< diff --git a/mk/tests.mk b/mk/tests.mk index dbda3ecb5cb..e429c8ef98a 100644 --- a/mk/tests.mk +++ b/mk/tests.mk @@ -87,6 +87,8 @@ tidy: $(wildcard $(S)src/etc/*.py) \ $(COMPILER_CRATE) \ $(COMPILER_INPUTS) \ + $(CORELIB_CRATE) \ + $(CORELIB_INPUTS) \ $(STDLIB_CRATE) \ $(STDLIB_INPUTS) \ $(COMPILETEST_CRATE) \ @@ -475,4 +477,4 @@ endef $(foreach stage,$(STAGES), \ $(eval $(call DEF_CHECK_FOR_STAGE,$(stage)))) -check-fast: check-fast-H-$(CFG_HOST_TRIPLE) \ No newline at end of file +check-fast: check-fast-H-$(CFG_HOST_TRIPLE) diff --git a/mk/tools.mk b/mk/tools.mk index 3a944f76f32..84d7c55ac35 100644 --- a/mk/tools.mk +++ b/mk/tools.mk @@ -19,6 +19,7 @@ define TOOLS_STAGE_N $$(TBIN$(1)_T_$(4)_H_$(3))/fuzzer$$(X): \ $$(FUZZER_CRATE) $$(FUZZER_INPUTS) \ $$(TSREQ$(1)_T_$(4)_H_$(3)) \ + $$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_CORELIB) \ $$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_STDLIB) \ $$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_LIBRUSTC) @$$(call E, compile_and_link: $$@) @@ -37,6 +38,7 @@ $$(HBIN$(2)_H_$(4))/fuzzer$$(X): \ $$(TBIN$(1)_T_$(4)_H_$(3))/compiletest$$(X): \ $$(COMPILETEST_CRATE) $$(COMPILETEST_INPUTS) \ $$(TSREQ$(1)_T_$(4)_H_$(3)) \ + $$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_CORELIB) \ $$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_STDLIB) @$$(call E, compile_and_link: $$@) $$(STAGE$(1)_T_$(4)_H_$(3)) -o $$@ $$< @@ -50,6 +52,7 @@ $$(HBIN$(2)_H_$(4))/compiletest$$(X): \ $$(TBIN$(1)_T_$(4)_H_$(3))/cargo$$(X): \ $$(CARGO_CRATE) $$(CARGO_INPUTS) \ $$(TSREQ$(1)_T_$(4)_H_$(3)) \ + $$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_CORELIB) \ $$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_STDLIB) \ $$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_LIBRUSTC) @$$(call E, compile_and_link: $$@) diff --git a/src/comp/driver/rustc.rs b/src/comp/driver/rustc.rs index 7ed81be5eda..95f9f06a994 100644 --- a/src/comp/driver/rustc.rs +++ b/src/comp/driver/rustc.rs @@ -260,7 +260,7 @@ options: --pretty [type] pretty-print the input instead of compiling --ls list the symbols defined by a crate file -L <path> add a directory to the library search path - --noverify suppress LLVM verification step (slight speedup) + --no-verify suppress LLVM verification step (slight speedup) --parse-only parse only; do not compile, assemble, or link --no-trans run all passes except translation; no output -g produce debug info @@ -362,7 +362,7 @@ fn build_session_options(match: getopts::match) } else if opt_present(match, "emit-llvm") { link::output_type_bitcode } else { link::output_type_exe }; - let verify = !opt_present(match, "noverify"); + let verify = !opt_present(match, "no-verify"); let save_temps = opt_present(match, "save-temps"); let debuginfo = opt_present(match, "g"); let stats = opt_present(match, "stats"); @@ -463,7 +463,7 @@ fn opts() -> [getopts::opt] { optflag("c"), optopt("o"), optflag("g"), optflag("save-temps"), optopt("sysroot"), optopt("target"), optflag("stats"), optflag("time-passes"), optflag("time-llvm-passes"), - optflag("noverify"), + optflag("no-verify"), optmulti("cfg"), optflag("test"), optflag("lib"), optflag("static"), optflag("gc"), optflag("stack-growth"), diff --git a/src/lib/ctypes.rs b/src/lib/ctypes.rs deleted file mode 100644 index 82e414a864c..00000000000 --- a/src/lib/ctypes.rs +++ /dev/null @@ -1,42 +0,0 @@ -/* -Module: ctypes - -Definitions useful for C interop -*/ - -type c_int = i32; -type c_uint = u32; - -type void = int; // Not really the same as C -type long = int; -type unsigned = u32; -type ulong = uint; - -type intptr_t = uint; -type uintptr_t = uint; -type uint32_t = u32; - -// machine type equivalents of rust int, uint, float - -#[cfg(target_arch="x86")] -type m_int = i32; -#[cfg(target_arch="x86_64")] -type m_int = i64; - -#[cfg(target_arch="x86")] -type m_uint = u32; -#[cfg(target_arch="x86_64")] -type m_uint = u64; - -// This *must* match with "import m_float = fXX" in std::math per arch -type m_float = f64; - -type size_t = uint; -type ssize_t = int; -type off_t = uint; - -type fd_t = i32; // not actually a C type, but should be. -type pid_t = i32; - -// enum is implementation-defined, but is 32-bits in practice -type enum = u32; diff --git a/src/libcore/core.rc b/src/libcore/core.rc new file mode 100644 index 00000000000..6feaf8fbfab --- /dev/null +++ b/src/libcore/core.rc @@ -0,0 +1,17 @@ +#[link(name = "core", + vers = "0.1", + uuid = "c70c24a7-5551-4f73-8e37-380b11d80be8", + url = "http://rust-lang.org/src/core")]; + +#[comment = "The Rust core library"]; +#[license = "BSD"]; + + +// Local Variables: +// mode: rust; +// fill-column: 78; +// indent-tabs-mode: nil +// c-basic-offset: 4 +// buffer-file-coding-system: utf-8-unix +// compile-command: "make -k -C .. 2>&1 | sed -e 's/\\/x\\//x:\\//g'"; +// End: diff --git a/src/lib/bitv.rs b/src/libstd/bitv.rs index 4b726703085..4b726703085 100644 --- a/src/lib/bitv.rs +++ b/src/libstd/bitv.rs diff --git a/src/lib/bool.rs b/src/libstd/bool.rs index 0fc869d1b41..0fc869d1b41 100644 --- a/src/lib/bool.rs +++ b/src/libstd/bool.rs diff --git a/src/lib/box.rs b/src/libstd/box.rs index 6682fe17284..6682fe17284 100644 --- a/src/lib/box.rs +++ b/src/libstd/box.rs diff --git a/src/lib/c_vec.rs b/src/libstd/c_vec.rs index ff5f636d103..7c2f1be7084 100644 --- a/src/lib/c_vec.rs +++ b/src/libstd/c_vec.rs @@ -57,6 +57,16 @@ resource dtor_res(dtor: option::t<fn@()>) { Section: Introduction forms */ +/* +Function: create + +Create a c_vec::t from a native buffer with a given size. + +Parameters: + +base - A native pointer to a buffer +size - The number of elements in the buffer +*/ unsafe fn create<T>(base: *mutable T, size: uint) -> t<T> { ret t({base: base, size: size, @@ -64,6 +74,19 @@ unsafe fn create<T>(base: *mutable T, size: uint) -> t<T> { }); } +/* +Function: create_with_dtor + +Create a c_vec::t from a native buffer, with a given size, +and a function to run upon destruction. + +Parameters: + +base - A native pointer to a buffer +size - The number of elements in the buffer +dtor - A function to run when the value is destructed, useful + for freeing the buffer, etc. +*/ unsafe fn create_with_dtor<T>(base: *mutable T, size: uint, dtor: fn@()) -> t<T> { ret t({base: base, @@ -76,11 +99,29 @@ unsafe fn create_with_dtor<T>(base: *mutable T, size: uint, dtor: fn@()) Section: Operations */ +/* +Function: get + +Retrieves an element at a given index + +Failure: + +If `ofs` is greater or equal to the length of the vector +*/ fn get<copy T>(t: t<T>, ofs: uint) -> T { assert ofs < (*t).size; ret unsafe { *ptr::mut_offset((*t).base, ofs) }; } +/* +Function: set + +Sets the value of an element at a given index + +Failure: + +If `ofs` is greater or equal to the length of the vector +*/ fn set<copy T>(t: t<T>, ofs: uint, v: T) { assert ofs < (*t).size; unsafe { *ptr::mut_offset((*t).base, ofs) = v }; @@ -90,10 +131,21 @@ fn set<copy T>(t: t<T>, ofs: uint, v: T) { Section: Elimination forms */ +// FIXME: Rename to len +/* +Function: size + +Returns the length of the vector +*/ fn size<T>(t: t<T>) -> uint { ret (*t).size; } +/* +Function: ptr + +Returns a pointer to the first element of the vector +*/ unsafe fn ptr<T>(t: t<T>) -> *mutable T { ret (*t).base; } diff --git a/src/lib/char.rs b/src/libstd/char.rs index bc8e74355c6..bc8e74355c6 100644 --- a/src/lib/char.rs +++ b/src/libstd/char.rs diff --git a/src/lib/cmath.rs b/src/libstd/cmath.rs index 69ecbac3e91..69ecbac3e91 100644 --- a/src/lib/cmath.rs +++ b/src/libstd/cmath.rs diff --git a/src/lib/comm.rs b/src/libstd/comm.rs index e00205a522b..e00205a522b 100644 --- a/src/lib/comm.rs +++ b/src/libstd/comm.rs diff --git a/src/libstd/ctypes.rs b/src/libstd/ctypes.rs new file mode 100644 index 00000000000..509eb3ef057 --- /dev/null +++ b/src/libstd/ctypes.rs @@ -0,0 +1,146 @@ +/* +Module: ctypes + +Definitions useful for C interop +*/ + +/* +FIXME: Add a test that uses some native code to verify these sizes, +which are not obviously correct for all potential platforms. +*/ + +/* +Type: c_int + +A signed integer with the same size as a C `int` +*/ +type c_int = i32; + +/* +Type: c_uint + +An unsigned integer with the same size as a C `unsigned int` +*/ +type c_uint = u32; + +/* +Type: long + +A signed integer with the same size as a C `long` +*/ +type long = int; + +/* +Type: unsigned + +An unsigned integer with the same size as a C `unsigned int` +*/ +type unsigned = u32; + +/* +Type: ulong + +An unsigned integer with the same size as a C `unsigned long` +*/ +type ulong = uint; + +/* +Type: intptr_t + +A signed integer with the same size as a pointer. This is +guaranteed to always be the same type as a Rust `int` +*/ +type intptr_t = uint; // FIXME: int + +/* +Type: uintptr_t + +An unsigned integer with the same size as a pointer. This is +guaranteed to always be the same type as a Rust `uint`. +*/ +type uintptr_t = uint; +type uint32_t = u32; + +/* +Type: void + +A type, a pointer to which can be used as C `void *` + +Note that this does not directly correspond to the C `void` type, +which is an incomplete type. Using pointers to this type +when interoperating with C void pointers can help in documentation. +*/ +type void = int; + +// machine type equivalents of rust int, uint, float + +/* +Type: m_int + +FIXME: What C type does this represent? +*/ +#[cfg(target_arch="x86")] +type m_int = i32; +#[cfg(target_arch="x86_64")] +type m_int = i64; + +/* +Type: m_uint + +FIXME: What C type does this represent? +*/ +#[cfg(target_arch="x86")] +type m_uint = u32; +#[cfg(target_arch="x86_64")] +type m_uint = u64; + +// This *must* match with "import m_float = fXX" in std::math per arch +/* +Type: m_float + +FIXME: What C type does this represent? +*/ +type m_float = f64; + +/* +Type: size_t + +An unsigned integer corresponding to the C `size_t` +*/ +type size_t = uint; + +/* +Type: ssize_t + +A signed integer correpsonding to the C `ssize_t` +*/ +type ssize_t = int; + +/* +Type: off_t + +An unsigned integer corresponding to the C `off_t` +*/ +type off_t = uint; + +/* +Type: fd_t + +A type that can be used for C file descriptors +*/ +type fd_t = i32; // not actually a C type, but should be. + +/* +Type: pid_t + +A type for representing process ID's, corresponding to C `pid_t` +*/ +type pid_t = i32; + +// enum is implementation-defined, but is 32-bits in practice +/* +Type: enum + +An unsigned integer with the same size as a C enum +*/ +type enum = u32; diff --git a/src/lib/dbg.rs b/src/libstd/dbg.rs index ea98150d76a..ea98150d76a 100644 --- a/src/lib/dbg.rs +++ b/src/libstd/dbg.rs diff --git a/src/lib/deque.rs b/src/libstd/deque.rs index 7c0a13bb5f8..7c0a13bb5f8 100644 --- a/src/lib/deque.rs +++ b/src/libstd/deque.rs diff --git a/src/lib/ebml.rs b/src/libstd/ebml.rs index 4a49dd473f4..4a49dd473f4 100644 --- a/src/lib/ebml.rs +++ b/src/libstd/ebml.rs diff --git a/src/lib/either.rs b/src/libstd/either.rs index 89d47b20746..89d47b20746 100644 --- a/src/lib/either.rs +++ b/src/libstd/either.rs diff --git a/src/lib/extfmt.rs b/src/libstd/extfmt.rs index 14a014e891a..14a014e891a 100644 --- a/src/lib/extfmt.rs +++ b/src/libstd/extfmt.rs diff --git a/src/lib/float.rs b/src/libstd/float.rs index f916e97bbf8..015dceb1dc1 100644 --- a/src/lib/float.rs +++ b/src/libstd/float.rs @@ -253,25 +253,18 @@ fn pow_uint_to_uint_as_float(x: uint, pow: uint) -> float { } -/** - * Section: Constants - */ - -//TODO: Once this is possible, replace the body of these functions -//by an actual constant. - /* Const: NaN */ const NaN: float = 0./0.; -/* Predicate: isNaN */ -pure fn isNaN(f: float) -> bool { f != f } - /* Const: infinity */ const infinity: float = 1./0.; /* Const: neg_infinity */ const neg_infinity: float = -1./0.; +/* Predicate: isNaN */ +pure fn isNaN(f: float) -> bool { f != f } + /* Function: add */ pure fn add(x: float, y: float) -> float { ret x + y; } diff --git a/src/lib/four.rs b/src/libstd/four.rs index 11c42fb7018..11c42fb7018 100644 --- a/src/lib/four.rs +++ b/src/libstd/four.rs diff --git a/src/lib/fs.rs b/src/libstd/fs.rs index fcd95040ab0..fcd95040ab0 100644 --- a/src/lib/fs.rs +++ b/src/libstd/fs.rs diff --git a/src/lib/fun_treemap.rs b/src/libstd/fun_treemap.rs index 1f4e6b9491a..1f4e6b9491a 100644 --- a/src/lib/fun_treemap.rs +++ b/src/libstd/fun_treemap.rs diff --git a/src/lib/generic_os.rs b/src/libstd/generic_os.rs index bbbd76f8217..bbbd76f8217 100644 --- a/src/lib/generic_os.rs +++ b/src/libstd/generic_os.rs diff --git a/src/lib/getopts.rs b/src/libstd/getopts.rs index 438bec0a90b..438bec0a90b 100644 --- a/src/lib/getopts.rs +++ b/src/libstd/getopts.rs diff --git a/src/lib/int.rs b/src/libstd/int.rs index 2ab299800ad..2ab299800ad 100644 --- a/src/lib/int.rs +++ b/src/libstd/int.rs diff --git a/src/lib/io.rs b/src/libstd/io.rs index 910ec8bb9ea..06e1be2fc4b 100644 --- a/src/lib/io.rs +++ b/src/libstd/io.rs @@ -1,3 +1,9 @@ +/* +Module: io + +Basic input/output +*/ + import ctypes::fd_t; import ctypes::c_int; diff --git a/src/lib/json.rs b/src/libstd/json.rs index 3f74c55507b..3f74c55507b 100644 --- a/src/lib/json.rs +++ b/src/libstd/json.rs diff --git a/src/lib/linux_os.rs b/src/libstd/linux_os.rs index 7e30088ee3c..7e30088ee3c 100644 --- a/src/lib/linux_os.rs +++ b/src/libstd/linux_os.rs diff --git a/src/lib/list.rs b/src/libstd/list.rs index ab712091819..ab712091819 100644 --- a/src/lib/list.rs +++ b/src/libstd/list.rs diff --git a/src/lib/macos_os.rs b/src/libstd/macos_os.rs index f23e82eaa63..f23e82eaa63 100644 --- a/src/lib/macos_os.rs +++ b/src/libstd/macos_os.rs diff --git a/src/lib/map.rs b/src/libstd/map.rs index c802b5b889f..c802b5b889f 100644 --- a/src/lib/map.rs +++ b/src/libstd/map.rs diff --git a/src/lib/math.rs b/src/libstd/math.rs index 72056548ca5..31bfe2ba3a6 100644 --- a/src/lib/math.rs +++ b/src/libstd/math.rs @@ -23,6 +23,9 @@ import ctypes::c_int; import m_float = math_f64; // FIXME replace with redirect to m_float::consts::FOO as soon as it works +/* +Module: consts +*/ mod consts { /* Const: pi diff --git a/src/lib/math_f32.rs b/src/libstd/math_f32.rs index 2172c9f8a99..6c36db51a67 100644 --- a/src/lib/math_f32.rs +++ b/src/libstd/math_f32.rs @@ -17,6 +17,7 @@ export export consts; +/* Module: consts */ mod consts { /* diff --git a/src/lib/math_f64.rs b/src/libstd/math_f64.rs index 639dc4a29b2..cc8fad9f665 100644 --- a/src/lib/math_f64.rs +++ b/src/libstd/math_f64.rs @@ -17,6 +17,7 @@ export export consts; +/* Module: consts */ mod consts { /* diff --git a/src/lib/net.rs b/src/libstd/net.rs index 5ee7cfa602c..5ee7cfa602c 100644 --- a/src/lib/net.rs +++ b/src/libstd/net.rs diff --git a/src/lib/option.rs b/src/libstd/option.rs index 403cb47f47e..403cb47f47e 100644 --- a/src/lib/option.rs +++ b/src/libstd/option.rs diff --git a/src/lib/posix_fs.rs b/src/libstd/posix_fs.rs index befa4c9829c..befa4c9829c 100644 --- a/src/lib/posix_fs.rs +++ b/src/libstd/posix_fs.rs diff --git a/src/lib/ptr.rs b/src/libstd/ptr.rs index 0372b17cdf1..0372b17cdf1 100644 --- a/src/lib/ptr.rs +++ b/src/libstd/ptr.rs diff --git a/src/lib/rand.rs b/src/libstd/rand.rs index be350baadbe..be350baadbe 100644 --- a/src/lib/rand.rs +++ b/src/libstd/rand.rs diff --git a/src/lib/result.rs b/src/libstd/result.rs index 550f53470bb..550f53470bb 100644 --- a/src/lib/result.rs +++ b/src/libstd/result.rs diff --git a/src/lib/rope.rs b/src/libstd/rope.rs index 19819a968bf..19819a968bf 100644 --- a/src/lib/rope.rs +++ b/src/libstd/rope.rs diff --git a/src/lib/run_program.rs b/src/libstd/run_program.rs index 6f4ad2da3d6..6f4ad2da3d6 100644 --- a/src/lib/run_program.rs +++ b/src/libstd/run_program.rs diff --git a/src/lib/sha1.rs b/src/libstd/sha1.rs index a51cbdc65d1..a51cbdc65d1 100644 --- a/src/lib/sha1.rs +++ b/src/libstd/sha1.rs diff --git a/src/lib/smallintmap.rs b/src/libstd/smallintmap.rs index 4702a2adab4..4702a2adab4 100644 --- a/src/lib/smallintmap.rs +++ b/src/libstd/smallintmap.rs diff --git a/src/lib/sort.rs b/src/libstd/sort.rs index 38ab4f3cfb1..38ab4f3cfb1 100644 --- a/src/lib/sort.rs +++ b/src/libstd/sort.rs diff --git a/src/lib/std.rc b/src/libstd/std.rc index 1f0d1b06093..1f0d1b06093 100644 --- a/src/lib/std.rc +++ b/src/libstd/std.rc diff --git a/src/lib/str.rs b/src/libstd/str.rs index fb24c59f62f..2bae8d699a5 100644 --- a/src/lib/str.rs +++ b/src/libstd/str.rs @@ -174,7 +174,8 @@ fn byte_len_range(s: str, byte_offset: uint, char_len: uint) -> uint { /* Function: bytes -Converts a string to a vector of bytes +Converts a string to a vector of bytes. The result vector is not +null-terminated. */ fn bytes(s: str) -> [u8] unsafe { let v = unsafe::reinterpret_cast(s); diff --git a/src/lib/sys.rs b/src/libstd/sys.rs index 3b4a3b8c643..3b4a3b8c643 100644 --- a/src/lib/sys.rs +++ b/src/libstd/sys.rs diff --git a/src/lib/task.rs b/src/libstd/task.rs index a8765407f3a..a8765407f3a 100644 --- a/src/lib/task.rs +++ b/src/libstd/task.rs diff --git a/src/lib/tempfile.rs b/src/libstd/tempfile.rs index 5f504ba2349..ee7d5e3b2d9 100644 --- a/src/lib/tempfile.rs +++ b/src/libstd/tempfile.rs @@ -9,6 +9,9 @@ import option; import option::{none, some}; import rand; +/* +Function: mkdtemp +*/ fn mkdtemp(prefix: str, suffix: str) -> option::t<str> { let r = rand::mk_rng(); let i = 0u; diff --git a/src/lib/term.rs b/src/libstd/term.rs index 75c35aabd54..75c35aabd54 100644 --- a/src/lib/term.rs +++ b/src/libstd/term.rs diff --git a/src/lib/test.rs b/src/libstd/test.rs index d827d775831..d827d775831 100644 --- a/src/lib/test.rs +++ b/src/libstd/test.rs diff --git a/src/lib/time.rs b/src/libstd/time.rs index 2865666fdc8..2865666fdc8 100644 --- a/src/lib/time.rs +++ b/src/libstd/time.rs diff --git a/src/lib/treemap.rs b/src/libstd/treemap.rs index 35d87cd518f..35d87cd518f 100644 --- a/src/lib/treemap.rs +++ b/src/libstd/treemap.rs diff --git a/src/lib/tri.rs b/src/libstd/tri.rs index fd4456cfde3..fd4456cfde3 100644 --- a/src/lib/tri.rs +++ b/src/libstd/tri.rs diff --git a/src/lib/u32.rs b/src/libstd/u32.rs index be6f649a979..be6f649a979 100644 --- a/src/lib/u32.rs +++ b/src/libstd/u32.rs diff --git a/src/lib/u64.rs b/src/libstd/u64.rs index aacc35a827d..aacc35a827d 100644 --- a/src/lib/u64.rs +++ b/src/libstd/u64.rs diff --git a/src/lib/u8.rs b/src/libstd/u8.rs index eadfcadda4a..eadfcadda4a 100644 --- a/src/lib/u8.rs +++ b/src/libstd/u8.rs diff --git a/src/lib/ufind.rs b/src/libstd/ufind.rs index 7de70526a7f..7de70526a7f 100644 --- a/src/lib/ufind.rs +++ b/src/libstd/ufind.rs diff --git a/src/lib/uint.rs b/src/libstd/uint.rs index ae1ba628aa6..ae1ba628aa6 100644 --- a/src/lib/uint.rs +++ b/src/libstd/uint.rs diff --git a/src/lib/unicode.rs b/src/libstd/unicode.rs index 5038721d26e..5038721d26e 100644 --- a/src/lib/unicode.rs +++ b/src/libstd/unicode.rs diff --git a/src/lib/unsafe.rs b/src/libstd/unsafe.rs index 22cce495649..22cce495649 100644 --- a/src/lib/unsafe.rs +++ b/src/libstd/unsafe.rs diff --git a/src/lib/util.rs b/src/libstd/util.rs index a15b5291546..a15b5291546 100644 --- a/src/lib/util.rs +++ b/src/libstd/util.rs diff --git a/src/lib/uv.rs b/src/libstd/uv.rs index 17916b844e3..17916b844e3 100644 --- a/src/lib/uv.rs +++ b/src/libstd/uv.rs diff --git a/src/lib/vec.rs b/src/libstd/vec.rs index d8f89b3b27b..d8f89b3b27b 100644 --- a/src/lib/vec.rs +++ b/src/libstd/vec.rs diff --git a/src/lib/win32_fs.rs b/src/libstd/win32_fs.rs index 87c97fe35c9..87c97fe35c9 100644 --- a/src/lib/win32_fs.rs +++ b/src/libstd/win32_fs.rs diff --git a/src/lib/win32_os.rs b/src/libstd/win32_os.rs index 9f648ac9721..9f648ac9721 100644 --- a/src/lib/win32_os.rs +++ b/src/libstd/win32_os.rs diff --git a/src/rt/arch/i386/context.h b/src/rt/arch/i386/context.h index fc5eb900a5c..03b97fa7b51 100644 --- a/src/rt/arch/i386/context.h +++ b/src/rt/arch/i386/context.h @@ -7,7 +7,7 @@ #include <inttypes.h> #include <stdint.h> -#include "../../memcheck.h" +#include "vg/memcheck.h" template<typename T> T align_down(T sp) @@ -51,9 +51,7 @@ public: uint32_t bot = regs.esp; uint32_t top = align_down(bot - nbytes); -#ifdef HAVE_VALGRIND (void)VALGRIND_MAKE_MEM_UNDEFINED(top - 4, bot - top + 4); -#endif return reinterpret_cast<void *>(top); } diff --git a/src/rt/arch/i386/morestack.S b/src/rt/arch/i386/morestack.S index 7b5446ae235..30084ec2de0 100644 --- a/src/rt/arch/i386/morestack.S +++ b/src/rt/arch/i386/morestack.S @@ -75,11 +75,12 @@ MORESTACK: // The arguments to rust_new_stack2 movl 40(%esp),%eax // Size of stack arguments - movl %eax,16(%esp) + movl %eax,20(%esp) leal 48(%esp),%eax // Address of stack arguments - movl %eax,12(%esp) + movl %eax,16(%esp) movl 36(%esp),%eax // The amount of stack needed - movl %eax,8(%esp) + movl %eax,12(%esp) + movl $0, 8(%esp) // Out pointer #ifdef __APPLE__ call 1f @@ -97,7 +98,7 @@ MORESTACK: movl 32(%esp),%edx // Grab the return pointer. inc %edx // Skip past the ret instruction in the parent fn - movl %eax,%esp // Switch stacks. + movl 8(%esp),%esp // Switch stacks. call *%edx // Re-enter the function that called us. // Now the function that called us has returned, so we need to delete the diff --git a/src/rt/arch/x86_64/context.h b/src/rt/arch/x86_64/context.h index 11c85092747..59d7bfa51f3 100644 --- a/src/rt/arch/x86_64/context.h +++ b/src/rt/arch/x86_64/context.h @@ -8,9 +8,7 @@ #include <stdint.h> #include <xmmintrin.h> -#ifdef HAVE_VALGRIND -#include <valgrind/memcheck.h> -#endif +#include "vg/memcheck.h" template<typename T> T align_down(T sp) @@ -51,9 +49,7 @@ public: uint64_t bot = regs.data[RUSTRT_RSP]; uint64_t top = align_down(bot - nbytes); -#ifdef HAVE_VALGRIND (void)VALGRIND_MAKE_MEM_UNDEFINED(top - 4, bot - top + 4); -#endif return reinterpret_cast<void *>(top); } diff --git a/src/rt/arch/x86_64/morestack.S b/src/rt/arch/x86_64/morestack.S index 4147052345d..ef0edcee720 100644 --- a/src/rt/arch/x86_64/morestack.S +++ b/src/rt/arch/x86_64/morestack.S @@ -81,9 +81,12 @@ MORESTACK: movq %rbp, %rcx addq $24, %rcx // Base pointer, return address x2 + pushq $0 // Alignment + pushq %r11 // Size of stack arguments pushq %rcx // Address of stack arguments pushq %r10 // The amount of stack needed + pushq $0 // Out pointer movq UPCALL_NEW_STACK@GOTPCREL(%rip), %rsi movq %rsp, %rdi @@ -95,7 +98,8 @@ MORESTACK: #endif // Pop the new_stack_args struct - addq $24, %rsp + popq %rax + addq $32, %rsp // Pop the saved arguments popq %r9 diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp index 41c8bc68d2b..dd5831c2917 100644 --- a/src/rt/rust_builtin.cpp +++ b/src/rt/rust_builtin.cpp @@ -273,6 +273,12 @@ debug_ptrcast(type_desc *from_ty, return ptr; } +extern "C" CDECL void * +debug_get_stk_seg() { + rust_task *task = rust_scheduler::get_task(); + return task->stk; +} + extern "C" CDECL rust_vec* rust_list_files(rust_str *path) { rust_task *task = rust_scheduler::get_task(); diff --git a/src/rt/rust_task.cpp b/src/rt/rust_task.cpp index f0ab8c57c35..b540225243f 100644 --- a/src/rt/rust_task.cpp +++ b/src/rt/rust_task.cpp @@ -2,8 +2,8 @@ #include "rust_internal.h" #include "rust_cc.h" -#include "valgrind.h" -#include "memcheck.h" +#include "vg/valgrind.h" +#include "vg/memcheck.h" #ifndef __WIN32__ #include <execinfo.h> @@ -131,6 +131,9 @@ rust_task::~rust_task() // (ref_count == 1 && this == sched->root_task)); // Delete all the stacks. There may be more than one if the task failed + // FIXME: This is not correct. During unwinding we need to delete + // the stacks and record the stack limit, otherwise the stack + // stack is corrupted when destructors are running. while (stk != NULL) { del_stk(this, stk); } diff --git a/src/rt/rust_timer.cpp b/src/rt/rust_timer.cpp index eb1f30b93ee..ffa98766763 100644 --- a/src/rt/rust_timer.cpp +++ b/src/rt/rust_timer.cpp @@ -1,5 +1,5 @@ #include "rust_internal.h" -#include "valgrind.h" +#include "vg/valgrind.h" // The mechanism in this file is very crude; every domain (thread) spawns its // own secondary timer thread, and that timer thread *never idles*. It diff --git a/src/rt/rust_upcall.cpp b/src/rt/rust_upcall.cpp index a8f39cf91da..653db471fc0 100644 --- a/src/rt/rust_upcall.cpp +++ b/src/rt/rust_upcall.cpp @@ -209,28 +209,48 @@ upcall_dynastack_free(void *ptr) { return rust_scheduler::get_task()->dynastack.free(ptr); } +extern "C" void record_sp(void *limit); + /** - * Allocates |nbytes| bytes in the C stack and returns a pointer to the start - * of the allocated space. + * Switch to the C stack and call the given function, passing a single pointer + * argument. */ extern "C" CDECL void upcall_call_shim_on_c_stack(void *args, void *fn_ptr) { - rust_scheduler *sched = rust_scheduler::get_task()->sched; - sched->c_context.call_shim_on_c_stack(args, fn_ptr); + rust_task *task = rust_scheduler::get_task(); + + // FIXME (1226) - The shim functions generated by rustc contain the + // morestack prologue, so we need to let them know they have enough + // stack. + record_sp(0); + + rust_scheduler *sched = task->sched; + try { + sched->c_context.call_shim_on_c_stack(args, fn_ptr); + } catch (...) { + task = rust_scheduler::get_task(); + task->record_stack_limit(); + throw; + } + task = rust_scheduler::get_task(); + task->record_stack_limit(); } struct rust_new_stack2_args { - size_t stk_sz; - void *args_addr; - size_t args_sz; + void *new_stack; + size_t stk_sz; + void *args_addr; + size_t args_sz; }; // A new stack function suitable for calling through // upcall_call_shim_on_c_stack -extern "C" CDECL void * +extern "C" CDECL void upcall_new_stack(struct rust_new_stack2_args *args) { rust_task *task = rust_scheduler::get_task(); - return task->new_stack(args->stk_sz, args->args_addr, args->args_sz); + args->new_stack = task->new_stack(args->stk_sz, + args->args_addr, + args->args_sz); } extern "C" CDECL void diff --git a/src/rt/rustrt.def.in b/src/rt/rustrt.def.in index de9079800e2..ba1a9c1403d 100644 --- a/src/rt/rustrt.def.in +++ b/src/rt/rustrt.def.in @@ -8,6 +8,7 @@ del_port debug_ptrcast debug_tag debug_tydesc +debug_get_stk_seg do_gc drop_task get_port_id diff --git a/src/rt/memcheck.h b/src/rt/vg/memcheck.h index 58480256e19..58480256e19 100644 --- a/src/rt/memcheck.h +++ b/src/rt/vg/memcheck.h diff --git a/src/rt/valgrind.h b/src/rt/vg/valgrind.h index 737cc2a8b42..737cc2a8b42 100644 --- a/src/rt/valgrind.h +++ b/src/rt/vg/valgrind.h diff --git a/src/test/run-fail/morestack2.rs b/src/test/run-fail/morestack2.rs new file mode 100644 index 00000000000..02b1adae481 --- /dev/null +++ b/src/test/run-fail/morestack2.rs @@ -0,0 +1,41 @@ +// xfail-test +// error-pattern:explicit failure +// compile-flags:--stack-growth + +// This time we're testing that the stack limits are restored +// correctly after calling into the C stack and unwinding. +// See the hack in upcall_call_shim_on_c_stack where it messes +// with the stack limit. + +use std; + +native mod rustrt { + fn set_min_stack(size: uint); + fn pin_task(); +} + +fn getbig_call_c_and_fail(i: int) { + if i != 0 { + getbig_call_c_and_fail(i - 1); + } else { + rustrt::pin_task(); + fail; + } +} + +resource and_then_get_big_again(_i: ()) { + fn getbig(i: int) { + if i != 0 { + getbig(i - 1); + } + } + getbig(10000); +} + +fn main() { + rustrt::set_min_stack(256u); + std::task::spawn((), fn (&&_i: ()) { + let r = and_then_get_big_again(()); + getbig_call_c_and_fail(10000); + }); +} \ No newline at end of file diff --git a/src/test/run-fail/morestack3.rs b/src/test/run-fail/morestack3.rs new file mode 100644 index 00000000000..9fdd0326b66 --- /dev/null +++ b/src/test/run-fail/morestack3.rs @@ -0,0 +1,34 @@ +// xfail-test +// error-pattern:explicit failure +// compile-flags:--stack-growth + +// Just testing unwinding + +use std; + +native mod rustrt { + fn set_min_stack(size: uint); +} + +fn getbig_and_fail(&&i: int) { + let r = and_then_get_big_again(@0); + if i != 0 { + getbig_and_fail(i - 1); + } else { + fail; + } +} + +resource and_then_get_big_again(_i: @int) { + fn getbig(i: int) { + if i != 0 { + getbig(i - 1); + } + } + getbig(1000); +} + +fn main() { + rustrt::set_min_stack(256u); + std::task::spawn(1000, getbig_and_fail); +} \ No newline at end of file diff --git a/src/test/run-pass/morestack4.rs b/src/test/run-pass/morestack4.rs new file mode 100644 index 00000000000..cdba6dd766e --- /dev/null +++ b/src/test/run-pass/morestack4.rs @@ -0,0 +1,100 @@ +// xfail-test +// compile-flags:--stack-growth + +// This is testing for stack frames greater than 256 bytes, +// for which function prologues are generated differently + +type biggy = { + a00: u64, + a01: u64, + a02: u64, + a03: u64, + a04: u64, + a05: u64, + a06: u64, + a07: u64, + a08: u64, + a09: u64, + a10: u64, + a11: u64, + a12: u64, + a13: u64, + a14: u64, + a15: u64, + a16: u64, + a17: u64, + a18: u64, + a19: u64, + a20: u64, + a21: u64, + a22: u64, + a23: u64, + a24: u64, + a25: u64, + a26: u64, + a27: u64, + a28: u64, + a29: u64, + a30: u64, + a31: u64, + a32: u64, + a33: u64, + a34: u64, + a35: u64, + a36: u64, + a37: u64, + a38: u64, + a39: u64, +}; + + +fn getbig(i: biggy) { + if i.a00 != 0u64 { + getbig({a00: i.a00 - 1u64 with i}); + } +} + +fn main() { + getbig({ + a00: 100000u64, + a01: 100000u64, + a02: 100000u64, + a03: 100000u64, + a04: 100000u64, + a05: 100000u64, + a06: 100000u64, + a07: 100000u64, + a08: 100000u64, + a09: 100000u64, + a10: 100000u64, + a11: 100000u64, + a12: 100000u64, + a13: 100000u64, + a14: 100000u64, + a15: 100000u64, + a16: 100000u64, + a17: 100000u64, + a18: 100000u64, + a19: 100000u64, + a20: 100000u64, + a21: 100000u64, + a22: 100000u64, + a23: 100000u64, + a24: 100000u64, + a25: 100000u64, + a26: 100000u64, + a27: 100000u64, + a28: 100000u64, + a29: 100000u64, + a30: 100000u64, + a31: 100000u64, + a32: 100000u64, + a33: 100000u64, + a34: 100000u64, + a35: 100000u64, + a36: 100000u64, + a37: 100000u64, + a38: 100000u64, + a39: 100000u64, + }); +} \ No newline at end of file diff --git a/src/test/run-pass/morestack5.rs b/src/test/run-pass/morestack5.rs new file mode 100644 index 00000000000..bedf3f47ee9 --- /dev/null +++ b/src/test/run-pass/morestack5.rs @@ -0,0 +1,26 @@ +// xfail-test +// compile-flags:--stack-growth + +// This test will call __morestack with various minimum stack sizes + +use std; +import std::task; + +native mod rustrt { + fn set_min_stack(size: uint); +} + +fn getbig(&&i: int) { + if i != 0 { + getbig(i - 1); + } +} + +fn main() { + let sz = 400u; + while sz < 500u { + rustrt::set_min_stack(sz); + task::join(task::spawn_joinable(200, getbig)); + sz += 1u; + } +} \ No newline at end of file diff --git a/src/test/run-pass/morestack6.rs b/src/test/run-pass/morestack6.rs new file mode 100644 index 00000000000..ef1a87aeea6 --- /dev/null +++ b/src/test/run-pass/morestack6.rs @@ -0,0 +1,81 @@ +// xfail-test +// compile-flags:--stack-growth + +// This test attempts to force the dynamic linker to resolve +// external symbols as close to the red zone as possible. + +use std; +import std::task; +import std::rand; + +native mod rustrt { + fn set_min_stack(size: uint); + fn debug_get_stk_seg() -> *u8; + + fn unsupervise(); + fn last_os_error() -> str; + fn rust_getcwd() -> str; + fn refcount(box: @int); + fn do_gc(); + fn pin_task(); + fn unpin_task(); + fn get_task_id(); + fn sched_threads(); + fn rust_get_task(); +} + +fn calllink01() { rustrt::unsupervise(); } +fn calllink02() { rustrt::last_os_error(); } +fn calllink03() { rustrt::rust_getcwd(); } +fn calllink04() { rustrt::refcount(@0); } +fn calllink05() { rustrt::do_gc(); } +fn calllink06() { rustrt::pin_task(); } +fn calllink07() { rustrt::unpin_task(); } +fn calllink08() { rustrt::get_task_id(); } +fn calllink09() { rustrt::sched_threads(); } +fn calllink10() { rustrt::rust_get_task(); } + +fn runtest(&&args:(fn(), u32)) { + let (f, frame_backoff) = args; + runtest2(f, frame_backoff, 0 as *u8); +} + +fn runtest2(f: fn(), frame_backoff: u32, last_stk: *u8) -> u32 { + let curr_stk = rustrt::debug_get_stk_seg(); + if (last_stk != curr_stk && last_stk != 0 as *u8) { + // We switched stacks, go back and try to hit the dynamic linker + frame_backoff + } else { + let frame_backoff = runtest2(f, frame_backoff, curr_stk); + if frame_backoff > 1u32 { + frame_backoff - 1u32 + } else if frame_backoff == 1u32 { + f(); + 0u32 + } else { + 0u32 + } + } +} + +fn main() { + let fns = [ + calllink01, + calllink02, + calllink03, + calllink04, + calllink05, + calllink06, + calllink07, + calllink08, + calllink09, + calllink10 + ]; + let rng = rand::mk_rng(); + for f in fns { + let sz = rng.next() % 256u32 + 256u32; + let frame_backoff = rng.next() % 10u32 + 1u32; + rustrt::set_min_stack(sz as uint); + task::join(task::spawn_joinable((f, frame_backoff), runtest)); + } +} \ No newline at end of file |
