-
Notifications
You must be signed in to change notification settings - Fork 681
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
22 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,3 +84,4 @@ pub mod statfs; | |
target_arch = "arm")), | ||
)] | ||
pub mod statvfs; | ||
pub mod pthread; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
use libc::{self, pthread_t}; | ||
|
||
/// Obtain ID of the calling thread (see | ||
/// [pthread_self(3)](http://man7.org/linux/man-pages/man3/pthread_self.3.html) | ||
/// | ||
/// The thread ID returned by pthread_self() is not the same thing as | ||
/// the kernel thread ID returned by a call to gettid(2). | ||
#[inline] | ||
pub fn pthread_self() -> pthread_t { | ||
unsafe { libc::pthread_self() } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,3 +12,4 @@ mod test_uio; | |
|
||
#[cfg(target_os = "linux")] | ||
mod test_epoll; | ||
mod test_pthread; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
use nix::sys::pthread::*; | ||
|
||
#[test] | ||
fn test_pthread_self() { | ||
let tid = pthread_self(); | ||
assert!(tid > 0); | ||
} |