about summary refs log tree commit diff
path: root/src/rt
AgeCommit message (Collapse)AuthorLines
2013-12-24Remove rust_globals.hBrian Anderson-143/+37
2013-12-24Stop using C++ exceptions for stack unwinding.Vadim Chugunov-31/+37
2013-12-22uv: Suppress a warning by using an absolute pathAlex Crichton-0/+2
Turns out libuv's build system doesn't like us telling them that the build directory is a relative location, as it always spits out a warning about a circular dependency being dropped. By using an absolute path, turns out the warnings isn't spit out, who knew? Closes #11067
2013-12-07Register new snapshotsAlex Crichton-9/+0
This transitions the snapshot dependency process to understand that our snapshots are now a single static binary rather than an array of files.
2013-12-05Remove unused upcallsAlex Crichton-1/+2
The main one removed is rust_upcall_reset_stack_limit (continuation of #10156), and this also removes the upcall_trace function. The was hidden behind a `-Z trace` flag, but if you attempt to use this now you'll get a linker error because there is no implementation of the 'upcall_trace' function. Due to this no longer working, I decided to remove it entirely from the compiler (I'm also a little unsure on what it did in the first place).
2013-11-29Statically link librustrt to libstdAlex Crichton-51/+0
This commit alters the build process of the compiler to build a static librustrt.a instead of a dynamic version. This means that we can stop distributing librustrt as well as default linking against it in the compiler. This also means that if you attempt to build rust code without libstd, it will no longer work if there are any landing pads in play. The reason for this is that LLVM and rustc will emit calls to the various upcalls in librustrt used to manage exception handling. In theory we could split librustrt into librustrt and librustupcall. We would then distribute librustupcall and link to it for all programs using landing pads, but I would rather see just one librustrt artifact and simplify the build process. The major benefit of doing this is that building a static rust library for use in embedded situations all of a sudden just became a whole lot more feasible. Closes #3361
2013-11-22Remove sjlj stuff from rust_upcall and don't pass -Werror to libuv.Luqman Aden-11/+0
2013-11-22Fix up mingw64 target.Luqman Aden-7/+18
2013-11-19Implement more native file I/OAlex Crichton-63/+0
This implements a fair amount of the unimpl() functionality in io::native relating to filesystem operations. I've also modified all io::fs tests to run in both a native and uv environment (so everything is actually tested). There are a two bits of remaining functionality which I was unable to get working: * change_file_times on windows * lstat on windows I think that change_file_times may just need a better interface, but lstat has a large implementation in libuv which I didn't want to tackle trying to copy.
2013-11-18Move runtime files to C instead of C++Alex Crichton-178/+198
Explicitly have the only C++ portion of the runtime be one file with exception handling. All other runtime files must now live in C and be fully defined in C.
2013-11-18Remove the C++ lock_and_signal typeAlex Crichton-441/+2
A the same time this purges all runtime support needed for statically initialized mutexes, moving all users over to the new Mutex type instead.
2013-11-18Implement a native mutex typeAlex Crichton-2/+24
This mutex is built on top of pthreads for unix and the related windows apis on windows. This is a straight port of the lock_and_signal type from C++ to rust. Almost all operations on the type are unsafe, and it's definitely not recommended for general use. Closes #9105
2013-11-18rt: Namespace all C functions under rust_Brian Anderson-16/+16
2013-11-13add rust_trylock_little_lockJason Toffaletti-0/+33
Try to acquire lock and succeed only if lock is not already held. Uses TryEnterCriticalSection or pthread_mutex_trylock.
2013-11-12rt: Delete more C++Brian Anderson-141/+10
2013-11-11auto merge of #10403 : poiru/rust/issue-2675, r=alexcrichtonbors-9/+11
Closes #2675.
2013-11-11Add asserts to check for faililng QueryPerformance* calls in precise_time_nsBirunthan Mohanathas-7/+9
Closes #2675.
2013-11-11Change use of unsigned integers to signed integers for clarity inBirunthan Mohanathas-5/+5
precise_time_ns The QueryPerformance* functions take a LARGE_INTEGER, which is a signed 64-bit integer rather than an unsigned 64-bit integer. `ts.tv_sec`, too, is a signed integer so `ns_per_s` has been changed to a int64_t.
2013-11-10Another round of test fixes from previous commitsAlex Crichton-4/+2
2013-11-10Update to the latest libuvAlex Crichton-152/+25
At this time, also point the libuv submodule to the official repo instead of my own off to the side. cc #10246 Closes #10329
2013-11-10Work around bugs in 32-bit enum FFIAlex Crichton-0/+5
cc #10308
2013-11-10Migrate uv timer bindings away from ~fn()Alex Crichton-5/+0
2013-11-10uv: Remove lots of uv/C++ wrappersAlex Crichton-352/+0
2013-11-08auto merge of #10348 : ksh8281/rust/fix_android_timegm, r=yichoibors-2/+5
fix timegm bug on android TZ restore not correctly before. and it cause test case fail (time::tests::run_tests::test_convertions) with @sammykim
2013-11-08fix android timegmsh8281.kim-2/+5
2013-11-07auto merge of #10281 : klutzy/rust/rt-timezone, r=alexcrichtonbors-4/+9
Previously #9418 fixed utf-8 assertion issue by wcsftime, but the function didn't work as expected: it follows the locale set by setlocale(), not the system code page. This patch fixes it by manual multibyte-to-unicode conversion.
2013-11-07update for ndk r9bsh8281.kim-4/+0
2013-11-06auto merge of #10227 : kud1ing/rust/ios, r=alexcrichtonbors-5/+17
2013-11-06Fixes for compilation to iOS:kud1ing-5/+17
- remove /usr/include from the include path since the iOS SDK provides the correct version - `_NSGetEnviron()` is private and not available on iOS - `.align` without an argument is not allowed with the Apple tools. 2^2 should be the default alignment - ignore error messages for XCode < 5 - pass include path to libuv
2013-11-05Move implementation for threads to RustDirkjan Bussink-143/+0
This binds to the appropriate pthreads_* and Windows specific functions and calls them from Rust. This allows for removal of the C++ support code for threads. Fixes #10162
2013-11-05rt: Convert timezone to utf-8 on Windowsklutzy-4/+9
Previously #9418 fixed utf-8 assertion issue by wcsftime, but the function didn't work as expected: it follows the locale set by setlocale(), not the system code page. This patch fixes it by manual multibyte-to-unicode conversion.
2013-11-03Fill out the remaining functionality in io::fileAlex Crichton-0/+4
This adds bindings to the remaining functions provided by libuv, all of which are useful operations on files which need to get exposed somehow. Some highlights: * Dropped `FileReader` and `FileWriter` and `FileStream` for one `File` type * Moved all file-related methods to be static methods under `File` * All directory related methods are still top-level functions * Created `io::FilePermission` types (backed by u32) that are what you'd expect * Created `io::FileType` and refactored `FileStat` to use FileType and FilePermission * Removed the expanding matrix of `FileMode` operations. The mode of reading a file will not have the O_CREAT flag, but a write mode will always have the O_CREAT flag. Closes #10130 Closes #10131 Closes #10121
2013-11-03Remove all blocking std::os blocking functionsAlex Crichton-0/+4
This commit moves all thread-blocking I/O functions from the std::os module. Their replacements can be found in either std::rt::io::file or in a hidden "old_os" module inside of native::file. I didn't want to outright delete these functions because they have a lot of special casing learned over time for each OS/platform, and I imagine that these will someday get integrated into a blocking implementation of IoFactory. For now, they're moved to a private module to prevent bitrot and still have tests to ensure that they work. I've also expanded the extensions to a few more methods defined on Path, most of which were previously defined in std::os but now have non-thread-blocking implementations as part of using the current IoFactory. The api of io::file is in flux, but I plan on changing it in the next commit as well. Closes #10057
2013-11-03Modify IoFactory's fs_mkdir, and add fs_renameAlex Crichton-0/+5
The invocation for making a directory should be able to specify a mode to make the directory with (instead of defaulting to one particular mode). Additionally, libuv and various OSes implement efficient versions of renaming files, so this operation is exposed as an IoFactory call.
2013-11-02Statically link libuv to librustuvAlex Crichton-115/+0
Similarly to the previous commit, libuv is only used by this library, so there's no need for it to be linked into librustrt and available to all crates by default.
2013-11-01Statically link sundown to librustdocAlex Crichton-6/+0
Closes #10103
2013-10-29auto merge of #10163 : brson/rust/rtcxx, r=alexcrichtonbors-159/+0
2013-10-29rt: Remove array_list.hBrian Anderson-149/+0
2013-10-29rt: Remove rust_thread::detachBrian Anderson-10/+0
2013-10-29rt: Remove four unused upcallsBrian Anderson-45/+0
2013-10-26Rewrite boxed_region/memory_region in RustAlex Crichton-579/+0
This drops more of the old C++ runtime to rather be written in rust. A few features were lost along the way, but hopefully not too many. The main loss is that there are no longer backtraces associated with allocations (rust doesn't have a way of acquiring those just yet). Other than that though, I believe that the rest of the debugging utilities made their way over into rust. Closes #8704
2013-10-25auto merge of #10060 : alexcrichton/rust/cached-stdout, r=brsonbors-1/+1
Almost all languages provide some form of buffering of the stdout stream, and this commit adds this feature for rust. A handle to stdout is lazily initialized in the Task structure as a buffered owned Writer trait object. The buffer behavior depends on where stdout is directed to. Like C, this line-buffers the stream when the output goes to a terminal (flushes on newlines), and also like C this uses a fixed-size buffer when output is not directed at a terminal. We may decide the fixed-size buffering is overkill, but it certainly does reduce write syscall counts when piping output elsewhere. This is a *huge* benefit to any code using logging macros or the printing macros. Formatting emits calls to `write` very frequently, and to have each of them backed by a write syscall was very expensive. In a local benchmark of printing 10000 lines of "what" to stdout, I got the following timings: when | terminal | redirected ----------|---------------|-------- before | 0.575s | 0.525s after | 0.197s | 0.013s C | 0.019s | 0.004s I can also confirm that we're buffering the output appropriately in both situtations. We're still far slower than C, but I believe much of that has to do with the "homing" that all tasks due, we're still performing an order of magnitude more write syscalls than C does.
2013-10-25Cache and buffer stdout per-task for printingAlex Crichton-1/+1
Almost all languages provide some form of buffering of the stdout stream, and this commit adds this feature for rust. A handle to stdout is lazily initialized in the Task structure as a buffered owned Writer trait object. The buffer behavior depends on where stdout is directed to. Like C, this line-buffers the stream when the output goes to a terminal (flushes on newlines), and also like C this uses a fixed-size buffer when output is not directed at a terminal. We may decide the fixed-size buffering is overkill, but it certainly does reduce write syscall counts when piping output elsewhere. This is a *huge* benefit to any code using logging macros or the printing macros. Formatting emits calls to `write` very frequently, and to have each of them backed by a write syscall was very expensive. In a local benchmark of printing 10000 lines of "what" to stdout, I got the following timings: when | terminal | redirected ---------------------------------- before | 0.575s | 0.525s after | 0.197s | 0.013s C | 0.019s | 0.004s I can also confirm that we're buffering the output appropriately in both situtations. We're still far slower than C, but I believe much of that has to do with the "homing" that all tasks due, we're still performing an order of magnitude more write syscalls than C does.
2013-10-24Implement a basic event loop built on LittleLockAlex Crichton-0/+12
It's not guaranteed that there will always be an event loop to run, and this implementation will serve as an incredibly basic one which does not provide any I/O, but allows the scheduler to still run. cc #9128
2013-10-24Another round of test fixes and merge conflictsAlex Crichton-12/+0
2013-10-24wrapping libuv signal for use in RustDo Nhat Minh-0/+18
descriptive names easier-to-use api reorganize and document
2013-10-24Test fixes and merge conflictsAlex Crichton-25/+0
2013-10-24Move as much I/O as possible off of native::ioAlex Crichton-0/+6
When uv's TTY I/O is used for the stdio streams, the file descriptors are put into a non-blocking mode. This means that other concurrent writes to the same stream can fail with EAGAIN or EWOULDBLOCK. By all I/O to event-loop I/O, we avoid this error. There is one location which cannot move, which is the runtime's dumb_println function. This was implemented to handle the EAGAIN and EWOULDBLOCK errors and simply retry again and again.
2013-10-24Don't attempt to export uv functions directlyAlex Crichton-7/+37
2013-10-24Move rt::io::stdio from FileStream to a TTYAlex Crichton-0/+4
We get a little more functionality from libuv for these kinds of streams (things like terminal dimentions), and it also appears to more gracefully handle the stream being a window. Beforehand, if you used stdio and hit CTRL+d on a process, libuv would continually return 0-length successful reads instead of interpreting that the stream was closed. I was hoping to be able to write tests for this, but currently the testing infrastructure doesn't allow tests with a stdin and a stdout, but this has been manually tested! (not that it means much)