about summary refs log tree commit diff
path: root/src/rt/rust_builtin.c
AgeCommit message (Collapse)AuthorLines
2015-12-21std: Remove rust_builtin C support libraryAlex Crichton-470/+0
All these definitions can now be written in Rust, so do so!
2015-12-17Make runtime function return size_tMichael McConville-1/+1
It returns sizeof(dirent_t), so I'm not sure why its return type is int. It's only used once, and that usage immediately casts it to usize.
2015-09-14Remove a needless memset(). It's okay that we don't append NUL because len ↵Michael McConville-1/+0
is actually one more than the length of argv[0]. However, this is precarious and should probably be replaced with more robust logic.
2015-09-05get_num_cpus function should be staticStepan Koltsov-2/+2
No need to export this symbol. `rust_get_num_cpus` is exported.
2015-08-28Reduce the reliance on `PATH_MAX`Barosl Lee-1/+5
- Rewrite `std::sys::fs::readlink` not to rely on `PATH_MAX` It currently has the following problems: 1. It uses `_PC_NAME_MAX` to query the maximum length of a file path in the underlying system. However, the meaning of the constant is the maximum length of *a path component*, not a full path. The correct constant should be `_PC_PATH_MAX`. 2. `pathconf` *may* fail if the referred file does not exist. This can be problematic if the file which the symbolic link points to does not exist, but the link itself does exist. In this case, the current implementation resorts to the hard-coded value of `1024`, which is not ideal. 3. There may exist a platform where there is no limit on file path lengths in general. That's the reaon why GNU Hurd doesn't define `PATH_MAX` at all, in addition to having `pathconf` always returning `-1`. In these platforms, the content of the symbolic link can be silently truncated if the length exceeds the hard-coded limit mentioned above. 4. The value obtained by `pathconf` may be outdated at the point of actually calling `readlink`. This is inherently racy. This commit introduces a loop that gradually increases the length of the buffer passed to `readlink`, eliminating the need of `pathconf`. - Remove the arbitrary memory limit of `std::sys::fs::realpath` As per POSIX 2013, `realpath` will return a malloc'ed buffer if the second argument is a null pointer.[1] [1] http://pubs.opengroup.org/onlinepubs/9699919799/functions/realpath.html - Comment on functions that are still using `PATH_MAX` There are some functions that only work in terms of `PATH_MAX`, such as `F_GETPATH` in OS X. Comments on them for posterity.
2015-08-23New cross target: i686-linux-androidTim JIANG-0/+7
- All the libstd tests are now passing in the optimized build against a Zenfone2 and the x86 Android simulator.
2015-07-27std: Remove msvc/valgrind headersAlex Crichton-9/+0
These aren't really used for anything any more, so there doesn't seem to be much reason to leave them around in the `rt` directory. There was some limiting of threads spawned or tests when run under valgrind, but very little is run under valgrind nowadays so there's also no real use keeping these around.
2015-07-02windows: Don't link rust_builtinAlex Crichton-31/+5
This library has no shims which are actually needed on Windows now, so translate that last easy one into Rust and then don't link it at all on Windows.
2015-05-23Auto merge of #25632 - alexcrichton:dt-dir, r=brsonbors-1/+2
This "fast path" in `DirEntry::file_type` on Unix wasn't turning out to be so much of a fast path as the `DT_DIR` case wasn't handled, so directories fell back to using `lstat` instead. This commit adds the missing case to return quickly if a path is a directory and `DirEntry::file_type` is used.
2015-05-19std: Handle DT_DIR file types in `dirent` pointersAlex Crichton-1/+2
This "fast path" in `DirEntry::file_type` on Unix wasn't turning out to be so much of a fast path as the `DT_DIR` case wasn't handled, so directories fell back to using `lstat` instead. This commit adds the missing case to return quickly if a path is a directory and `DirEntry::file_type` is used.
2015-05-19std: Mark rust_get_num_cpus as dllexportAlex Crichton-0/+7
This function is imported across the DLL boundary by the libtest dynamic library, so it has to be marked as dllexport somehow, and for now this is done with an attribute on the function specifically.
2015-05-19rt: Clean up to build with cl.exeAlex Crichton-15/+12
* Detect the #define _MSC_VER in addition to __WIN32__ * Don't include valgrind.h for windows * Remove unused `rust_valgrind_stack_{un,}register` functions * Add stub definition for `rust_running_on_valgrind` for windows * Conditionally define `rust_dbg_extern_empty_struct` as empty structures are not allowed by cl.exe apparently.
2015-04-27std: Expand the area of std::fsAlex Crichton-70/+23
This commit is an implementation of [RFC 1044][rfc] which adds additional surface area to the `std::fs` module. All new APIs are `#[unstable]` behind assorted feature names for each one. [rfc]: https://github.com/rust-lang/rfcs/pull/1044 The new APIs added are: * `fs::canonicalize` - bindings to `realpath` on unix and `GetFinalPathNameByHandle` on windows. * `fs::symlink_metadata` - similar to `lstat` on unix * `fs::FileType` and accessor methods as `is_{file,dir,symlink}` * `fs::Metadata::file_type` - accessor for the raw file type * `fs::DirEntry::metadata` - acquisition of metadata which is free on Windows but requires a syscall on unix. * `fs::DirEntry::file_type` - access the file type which may not require a syscall on most platforms. * `fs::DirEntry::file_name` - access just the file name without leading components. * `fs::PathExt::symlink_metadata` - convenience method for the top-level function. * `fs::PathExt::canonicalize` - convenience method for the top-level function. * `fs::PathExt::read_link` - convenience method for the top-level function. * `fs::PathExt::read_dir` - convenience method for the top-level function. * `std::os::raw` - type definitions for raw OS/C types available on all platforms. * `std::os::$platform` - new modules have been added for all currently supported platforms (e.g. those more specific than just `unix`). * `std::os::$platform::raw` - platform-specific type definitions. These modules are populated with the bare essentials necessary for lowing I/O types into their raw representations, and currently largely consist of the `stat` definition for unix platforms. This commit also deprecates `Metadata::{modified, accessed}` in favor of inspecting the raw representations via the lowering methods of `Metadata`.
2015-02-11renaming rust_load_self to rust_current_exeDave Huseby-1/+1
2015-02-11bitrig integrationDave Huseby-3/+279
2015-02-06Rollup merge of #21964 - semarie:openbsd-env, r=alexcrichtonManish Goregaokar-1/+1
- add `_SC_GETPW_R_SIZE_MAX` constant - declare `struct passwd` - convert `load_self` to `current_exe` Note: OpenBSD don't provide system function to return a valuable Path for `env::current_exe`. The implementation is currently based on the value of `argv[0]`, which couldn't be used when executable is called via PATH.
2015-02-05Tidy fixesBrian Anderson-2/+3
2015-02-05unbreak tree for openbsd after #21787Sébastien Marie-1/+1
- add `_SC_GETPW_R_SIZE_MAX` constant - declare `struct passwd` - convert `load_self` to `current_exe` Note: OpenBSD don't provide system function to return a valuable Path for `env::current_exe`. The implementation is currently based on the value of `argv[0]`, which couldn't be used when executable is called via PATH.
2015-02-01openbsd: incoporate remarksSébastien Marie-1/+1
- consolidate target_record_sp_limit and target_get_sp_limit functions for aarch64, powerpc, arm-ios and openbsd as there are all without segmented stacks (no need to duplicate functions). - rename __load_self function to rust_load_self - use a mutex inner load_self() as underline implementation is not thread-safe
2015-02-01openbsd supportSébastien Marie-2/+52
2015-01-19rt: Remove libtime wrappersklutzy-138/+0
They are unused since libtime is gone.
2014-09-06readdir: return error instead of failing on invalid UTF-16Peter Atashian-27/+0
Fixes #15279 Signed-off-by: Peter Atashian <retep998@gmail.com>
2014-08-08Move system header includes above valgrind.h includeChris Nixon-4/+4
This allows rustc to be build under msys2's mingw64 gcc
2014-07-29Port Rust to DragonFlyBSDMichael Neumann-1/+8
Not included are two required patches: * LLVM: segmented stack support for DragonFly [1] * jemalloc: simple configure patches [1]: http://reviews.llvm.org/D4705
2014-05-22libtime: Remove the `tz_zone` field from times.Patrick Walton-36/+6
It depends on `~str`.
2014-05-11make sure jemalloc valgrind support is enabledDaniel Micay-1/+1
This requires pointing it at the valgrind headers we carry in-tree.
2014-03-21rand: Rewrite OsRng in Rust for windowsAlex Crichton-59/+0
This removes even more rust_builtin.c code, and allows us to more gracefully handle errors (not a process panic, but a task failure).
2014-03-12std: Move rand to librand.Huon Wilson-1/+1
This functionality is not super-core and so doesn't need to be included in std. It's possible that std may need rand (it does a little bit now, for io::test) in which case the functionality required could be moved to a secret hidden module and reexposed by librand. Unfortunately, using #[deprecated] here is hard: there's too much to mock to make it feasible, since we have to ensure that programs still typecheck to reach the linting phase.
2014-03-05native: Stop using readdir()Alex Crichton-3/+12
This function is not threadsafe, and is deprecated in favor of the threadsafe readdir_r variant. Closes #12692
2014-02-03std: Hardcode pthread constants and structuresAlex Crichton-20/+0
This allows for easier static initialization of a pthread mutex, although the windows mutexes still sadly suffer. Note that this commit removes the clone() method from a mutex because it no longer makes sense for pthreads mutexes. This also removes the Once type for now, but it'll get added back shortly.
2013-12-30Convert some C functions to rust functionsAlex Crichton-67/+0
Right now on linux, an empty executable with LTO still depends on librt becaues of the clock_gettime function in rust_builtin.o, but this commit moves this dependency into a rust function which is subject to elimination via LTO. At the same time, this also drops libstd's dependency on librt on unices that are not OSX because the library is only used by extra::time (and now the dependency is listed in that module instead).
2013-12-24Remove rust_globals.hBrian Anderson-19/+31
2013-11-19Implement more native file I/OAlex Crichton-56/+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-0/+579
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.