Skip to content

Commit 8ebb6a2

Browse files
committed
---
yaml --- r: 272622 b: refs/heads/auto c: 112463a h: refs/heads/master
1 parent 2cff138 commit 8ebb6a2

File tree

2 files changed

+19
-43
lines changed

2 files changed

+19
-43
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
88
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
99
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1010
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
11-
refs/heads/auto: abc3777c06abced90b415b920082a4814d9051d7
11+
refs/heads/auto: 112463a3b1b1fc30c8f407e50e9ef692034ccb37
1212
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1313
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336
1414
refs/tags/0.2: 1754d02027f2924bed83b0160ee340c7f41d5ea1

branches/auto/src/libstd/sys/unix/thread.rs

Lines changed: 18 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -201,28 +201,17 @@ pub mod guard {
201201
current().map(|s| s as *mut libc::c_void)
202202
}
203203

204-
#[cfg(target_os = "freebsd")]
204+
#[cfg(any(target_os = "android", target_os = "freebsd",
205+
target_os = "linux", target_os = "netbsd"))]
205206
unsafe fn get_stack_start() -> Option<*mut libc::c_void> {
206207
let mut ret = None;
207208
let mut attr: libc::pthread_attr_t = ::mem::zeroed();
208209
assert_eq!(libc::pthread_attr_init(&mut attr), 0);
209-
if libc::pthread_attr_get_np(libc::pthread_self(), &mut attr) == 0 {
210-
let mut stackaddr = ::ptr::null_mut();
211-
let mut stacksize = 0;
212-
assert_eq!(libc::pthread_attr_getstack(&attr, &mut stackaddr,
213-
&mut stacksize), 0);
214-
ret = Some(stackaddr);
215-
}
216-
assert_eq!(libc::pthread_attr_destroy(&mut attr), 0);
217-
ret
218-
}
219-
220-
#[cfg(any(target_os = "linux", target_os = "android", target_os = "netbsd"))]
221-
unsafe fn get_stack_start() -> Option<*mut libc::c_void> {
222-
let mut ret = None;
223-
let mut attr: libc::pthread_attr_t = ::mem::zeroed();
224-
assert_eq!(libc::pthread_attr_init(&mut attr), 0);
225-
if libc::pthread_getattr_np(libc::pthread_self(), &mut attr) == 0 {
210+
#[cfg(target_os = "freebsd")]
211+
let e = libc::pthread_attr_get_np(libc::pthread_self(), &mut attr);
212+
#[cfg(not(target_os = "freebsd"))]
213+
let e = libc::pthread_getattr_np(libc::pthread_self(), &mut attr);
214+
if e == 0 {
226215
let mut stackaddr = ::ptr::null_mut();
227216
let mut stacksize = 0;
228217
assert_eq!(libc::pthread_attr_getstack(&attr, &mut stackaddr,
@@ -304,33 +293,18 @@ pub mod guard {
304293
})
305294
}
306295

307-
#[cfg(target_os = "freebsd")]
308-
pub unsafe fn current() -> Option<usize> {
309-
let mut ret = None;
310-
let mut attr: libc::pthread_attr_t = ::mem::zeroed();
311-
assert_eq!(libc::pthread_attr_init(&mut attr), 0);
312-
if libc::pthread_attr_get_np(libc::pthread_self(), &mut attr) == 0 {
313-
let mut guardsize = 0;
314-
assert_eq!(libc::pthread_attr_getguardsize(&attr, &mut guardsize), 0);
315-
if guardsize == 0 {
316-
panic!("there is no guard page");
317-
}
318-
let mut stackaddr = ::ptr::null_mut();
319-
let mut size = 0;
320-
assert_eq!(libc::pthread_attr_getstack(&attr, &mut stackaddr,
321-
&mut size), 0);
322-
ret = Some(stackaddr as usize - guardsize as usize);
323-
}
324-
assert_eq!(libc::pthread_attr_destroy(&mut attr), 0);
325-
ret
326-
}
327-
328-
#[cfg(any(target_os = "linux", target_os = "android", target_os = "netbsd"))]
296+
#[cfg(any(target_os = "android", target_os = "freebsd",
297+
target_os = "linux", target_os = "netbsd"))]
329298
pub unsafe fn current() -> Option<usize> {
330299
let mut ret = None;
331300
let mut attr: libc::pthread_attr_t = ::mem::zeroed();
332301
assert_eq!(libc::pthread_attr_init(&mut attr), 0);
333-
if libc::pthread_getattr_np(libc::pthread_self(), &mut attr) == 0 {
302+
#[cfg(target_os = "freebsd")]
303+
let e = libc::pthread_attr_get_np(libc::pthread_self(), &mut attr);
304+
#[cfg(not(target_os = "freebsd"))]
305+
let e = libc::pthread_getattr_np(libc::pthread_self(), &mut attr);
306+
if e == 0 {
307+
//if libc::pthread_getattr_np(libc::pthread_self(), &mut attr) == 0 {
334308
let mut guardsize = 0;
335309
assert_eq!(libc::pthread_attr_getguardsize(&attr, &mut guardsize), 0);
336310
if guardsize == 0 {
@@ -341,7 +315,9 @@ pub mod guard {
341315
assert_eq!(libc::pthread_attr_getstack(&attr, &mut stackaddr,
342316
&mut size), 0);
343317

344-
ret = if cfg!(target_os = "netbsd") {
318+
ret = if cfg!(target_os = "freebsd") {
319+
Some(stackaddr as usize - guardsize as usize)
320+
} else if cfg!(target_os = "netbsd") {
345321
Some(stackaddr as usize)
346322
} else {
347323
Some(stackaddr as usize + guardsize as usize)

0 commit comments

Comments
 (0)