Skip to content

Commit da0d66a

Browse files
committed
---
yaml --- r: 138935 b: refs/heads/try2 c: 4e350c7 h: refs/heads/master i: 138933: 9f8d7c7 138931: 1b324b3 138927: f9f5933 v: v3
1 parent f140d73 commit da0d66a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+3465
-570
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 5d3d0890a7f380a453a6303bb96ba7bef28f6237
8+
refs/heads/try2: 4e350c7ce7574259dd0aad9f981e615b2b917d20
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/libcore/core.rc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ Implicitly, all crates behave as if they included the following prologue:
5858
#[cfg(target_os = "linux")]
5959
pub mod linkhack {
6060
#[link_args="-lrustrt -lrt"]
61+
#[link_args = "-lpthread"]
6162
extern {
6263
}
6364
}
@@ -242,7 +243,8 @@ pub mod unicode;
242243
#[path = "num/cmath.rs"]
243244
pub mod cmath;
244245
pub mod stackwalk;
245-
246+
#[path = "rt/mod.rs"]
247+
pub mod rt;
246248

247249
// A curious inner-module that's not exported that contains the binding
248250
// 'core' so that macro-expanded references to core::error and such

branches/try2/src/libcore/libc.rs

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,8 @@ pub mod types {
534534

535535
pub type LPCWSTR = *WCHAR;
536536
pub type LPCSTR = *CHAR;
537+
pub type LPCTSTR = *CHAR;
538+
pub type LPTCH = *CHAR;
537539

538540
pub type LPWSTR = *mut WCHAR;
539541
pub type LPSTR = *mut CHAR;
@@ -792,6 +794,7 @@ pub mod consts {
792794

793795
pub const ERROR_SUCCESS : int = 0;
794796
pub const ERROR_INSUFFICIENT_BUFFER : int = 122;
797+
pub const INVALID_HANDLE_VALUE: int = -1;
795798
}
796799
}
797800

@@ -1115,6 +1118,7 @@ pub mod funcs {
11151118
pub mod string {
11161119
use libc::types::common::c95::c_void;
11171120
use libc::types::os::arch::c95::{c_char, c_int, size_t};
1121+
use libc::types::os::arch::c95::{wchar_t};
11181122

11191123
pub extern {
11201124
unsafe fn strcpy(dst: *c_char, src: *c_char) -> *c_char;
@@ -1138,6 +1142,7 @@ pub mod funcs {
11381142
unsafe fn strtok(s: *c_char, t: *c_char) -> *c_char;
11391143
unsafe fn strxfrm(s: *c_char, ct: *c_char, n: size_t)
11401144
-> size_t;
1145+
unsafe fn wcslen(buf: *wchar_t) -> size_t;
11411146

11421147
// These are fine to execute on the Rust stack. They must be,
11431148
// in fact, because LLVM generates calls to them!
@@ -1381,9 +1386,28 @@ pub mod funcs {
13811386
use libc::types::os::arch::c95::{c_char, c_int, c_long};
13821387

13831388
pub extern {
1389+
// default bindings for opendir and readdir in
1390+
// non-macos unix
1391+
#[cfg(target_os = "linux")]
1392+
#[cfg(target_os = "android")]
1393+
#[cfg(target_os = "freebsd")]
13841394
unsafe fn opendir(dirname: *c_char) -> *DIR;
1385-
unsafe fn closedir(dirp: *DIR) -> c_int;
1395+
#[cfg(target_os = "linux")]
1396+
#[cfg(target_os = "android")]
1397+
#[cfg(target_os = "freebsd")]
13861398
unsafe fn readdir(dirp: *DIR) -> *dirent_t;
1399+
// on OSX (particularly when running with a
1400+
// 64bit kernel), we have an issue where there
1401+
// are separate bindings for opendir and readdir,
1402+
// which we have to explicitly link, as below.
1403+
#[cfg(target_os = "macos")]
1404+
#[link_name = "opendir$INODE64"]
1405+
unsafe fn opendir(dirname: *c_char) -> *DIR;
1406+
#[cfg(target_os = "macos")]
1407+
#[link_name = "readdir$INODE64"]
1408+
unsafe fn readdir(dirp: *DIR) -> *dirent_t;
1409+
1410+
unsafe fn closedir(dirp: *DIR) -> c_int;
13871411
unsafe fn rewinddir(dirp: *DIR);
13881412
unsafe fn seekdir(dirp: *DIR, loc: c_long);
13891413
unsafe fn telldir(dirp: *DIR) -> c_long;
@@ -1594,8 +1618,9 @@ pub mod funcs {
15941618

15951619
pub mod kernel32 {
15961620
use libc::types::os::arch::extra::{BOOL, DWORD, HMODULE};
1597-
use libc::types::os::arch::extra::{LPCWSTR, LPWSTR};
1621+
use libc::types::os::arch::extra::{LPCWSTR, LPWSTR, LPTCH};
15981622
use libc::types::os::arch::extra::{LPSECURITY_ATTRIBUTES};
1623+
use libc::types::os::arch::extra::{HANDLE};
15991624

16001625
#[abi = "stdcall"]
16011626
pub extern {
@@ -1605,6 +1630,8 @@ pub mod funcs {
16051630
-> DWORD;
16061631
unsafe fn SetEnvironmentVariableW(n: LPCWSTR, v: LPCWSTR)
16071632
-> BOOL;
1633+
unsafe fn GetEnvironmentStringsA() -> LPTCH;
1634+
unsafe fn FreeEnvironmentStringsA(env_ptr: LPTCH) -> BOOL;
16081635

16091636
unsafe fn GetModuleFileNameW(hModule: HMODULE,
16101637
lpFilename: LPWSTR,
@@ -1623,6 +1650,13 @@ pub mod funcs {
16231650
unsafe fn SetCurrentDirectoryW(lpPathName: LPCWSTR) -> BOOL;
16241651

16251652
unsafe fn GetLastError() -> DWORD;
1653+
unsafe fn FindFirstFileW(fileName: *u16,
1654+
findFileData: HANDLE)
1655+
-> HANDLE;
1656+
unsafe fn FindNextFileW(findFile: HANDLE,
1657+
findFileData: HANDLE)
1658+
-> BOOL;
1659+
unsafe fn FindClose(findFile: HANDLE) -> BOOL;
16261660
}
16271661
}
16281662

branches/try2/src/libcore/nil.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Functions for the unit type.
1515
*/
1616

1717
#[cfg(notest)]
18-
use cmp::{Eq, Ord};
18+
use cmp::{Eq, Ord, TotalOrd, Ordering, Equal};
1919

2020
#[cfg(notest)]
2121
impl Eq for () {
@@ -37,3 +37,8 @@ impl Ord for () {
3737
pure fn gt(&self, _other: &()) -> bool { false }
3838
}
3939

40+
#[cfg(notest)]
41+
impl TotalOrd for () {
42+
#[inline(always)]
43+
pure fn cmp(&self, _other: &()) -> Ordering { Equal }
44+
}

branches/try2/src/libcore/option.rs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,27 @@ pub pure fn get_ref<T>(opt: &r/Option<T>) -> &r/T {
130130
}
131131
}
132132
133+
pub pure fn get_mut_ref<T>(opt: &r/mut Option<T>) -> &r/mut T {
134+
/*!
135+
Gets a mutable reference to the value inside an option.
136+
137+
# Failure
138+
139+
Fails if the value equals `None`
140+
141+
# Safety note
142+
143+
In general, because this function may fail, its use is discouraged
144+
(calling `get` on `None` is akin to dereferencing a null pointer).
145+
Instead, prefer to use pattern matching and handle the `None`
146+
case explicitly.
147+
*/
148+
match *opt {
149+
Some(ref mut x) => x,
150+
None => fail!(~"option::get_mut_ref none")
151+
}
152+
}
153+
133154
#[inline(always)]
134155
pub pure fn map<T, U>(opt: &r/Option<T>, f: &fn(x: &r/T) -> U) -> Option<U> {
135156
//! Maps a `some` value by reference from one type to another
@@ -364,6 +385,23 @@ pub impl<T> Option<T> {
364385
#[inline(always)]
365386
pure fn get_ref(&self) -> &self/T { get_ref(self) }
366387
388+
/**
389+
Gets a mutable reference to the value inside an option.
390+
391+
# Failure
392+
393+
Fails if the value equals `None`
394+
395+
# Safety note
396+
397+
In general, because this function may fail, its use is discouraged
398+
(calling `get` on `None` is akin to dereferencing a null pointer).
399+
Instead, prefer to use pattern matching and handle the `None`
400+
case explicitly.
401+
*/
402+
#[inline(always)]
403+
pure fn get_mut_ref(&mut self) -> &self/mut T { get_mut_ref(self) }
404+
367405
/**
368406
* Gets the value out of an option without copying.
369407
*

0 commit comments

Comments
 (0)