Skip to content

Commit 70edb94

Browse files
committed
---
yaml --- r: 277043 b: refs/heads/try c: abc3777 h: refs/heads/master i: 277041: 5844ab5 277039: e13429e
1 parent 26619db commit 70edb94

File tree

3 files changed

+46
-3
lines changed

3 files changed

+46
-3
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 6dbb0e86aec11050480beb76eade6fb805010ba7
33
refs/heads/snap-stage3: 235d77457d80b549dad3ac36d94f235208a1eafb
4-
refs/heads/try: bbe8e3502c8c67d9f17d56764031ff3b28206935
4+
refs/heads/try: abc3777c06abced90b415b920082a4814d9051d7
55
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
66
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
77
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try/src/libstd/sys/unix/stack_overflow.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ mod imp {
6464
unsafe fn siginfo_si_addr(info: *mut libc::siginfo_t) -> usize {
6565
#[repr(C)]
6666
struct siginfo_t {
67-
a: [libc::c_int; 3], // si_signo, si_code, si_errno,
67+
a: [libc::c_int; 3], // si_signo, si_errno, si_code
6868
si_addr: *mut libc::c_void,
6969
}
7070

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

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ impl Drop for Thread {
164164
}
165165

166166
#[cfg(all(not(all(target_os = "linux", not(target_env = "musl"))),
167+
not(target_os = "freebsd"),
167168
not(target_os = "macos"),
168169
not(target_os = "bitrig"),
169170
not(all(target_os = "netbsd", not(target_vendor = "rumprun"))),
@@ -177,6 +178,7 @@ pub mod guard {
177178

178179

179180
#[cfg(any(all(target_os = "linux", not(target_env = "musl")),
181+
target_os = "freebsd",
180182
target_os = "macos",
181183
target_os = "bitrig",
182184
all(target_os = "netbsd", not(target_vendor = "rumprun")),
@@ -199,6 +201,22 @@ pub mod guard {
199201
current().map(|s| s as *mut libc::c_void)
200202
}
201203

204+
#[cfg(target_os = "freebsd")]
205+
unsafe fn get_stack_start() -> Option<*mut libc::c_void> {
206+
let mut ret = None;
207+
let mut attr: libc::pthread_attr_t = ::mem::zeroed();
208+
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+
202220
#[cfg(any(target_os = "linux", target_os = "android", target_os = "netbsd"))]
203221
unsafe fn get_stack_start() -> Option<*mut libc::c_void> {
204222
let mut ret = None;
@@ -248,7 +266,11 @@ pub mod guard {
248266
panic!("failed to allocate a guard page");
249267
}
250268

251-
let offset = if cfg!(target_os = "linux") {2} else {1};
269+
let offset = if cfg!(any(target_os = "linux", target_os = "freebsd")) {
270+
2
271+
} else {
272+
1
273+
};
252274

253275
Some(stackaddr as usize + offset * psize)
254276
}
@@ -282,6 +304,27 @@ pub mod guard {
282304
})
283305
}
284306

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+
285328
#[cfg(any(target_os = "linux", target_os = "android", target_os = "netbsd"))]
286329
pub unsafe fn current() -> Option<usize> {
287330
let mut ret = None;

0 commit comments

Comments
 (0)