This repository was archived by the owner on Mar 24, 2022. It is now read-only.
File tree Expand file tree Collapse file tree
lucet-runtime/lucet-runtime-internals/src/sysdeps Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ use libc:: { c_void, ucontext_t} ;
2+
3+ #[ derive( Clone , Copy , Debug ) ]
4+ pub struct UContextPtr ( * const ucontext_t ) ;
5+
6+ impl UContextPtr {
7+ #[ inline]
8+ pub fn new ( ptr : * const c_void ) -> Self {
9+ assert ! ( !ptr. is_null( ) , "non-null context" ) ;
10+ UContextPtr ( ptr as * const ucontext_t )
11+ }
12+
13+ #[ inline]
14+ pub fn get_ip ( self ) -> * const c_void {
15+ let mcontext = & unsafe { * ( self . 0 ) } . uc_mcontext ;
16+ mcontext. mc_rip as * const _
17+ }
18+ }
19+
20+ #[ repr( C ) ]
21+ #[ derive( Clone , Copy ) ]
22+ pub struct UContext {
23+ context : ucontext_t ,
24+ }
25+
26+ impl UContext {
27+ #[ inline]
28+ pub fn new ( ptr : * const c_void ) -> Self {
29+ UContext {
30+ context : * unsafe {
31+ ( ptr as * const ucontext_t )
32+ . as_ref ( )
33+ . expect ( "non-null context" )
34+ } ,
35+ }
36+ }
37+
38+ pub fn as_ptr ( & mut self ) -> UContextPtr {
39+ UContextPtr :: new ( & self . context as * const _ as * const _ )
40+ }
41+ }
42+
43+ impl Into < UContext > for UContextPtr {
44+ #[ inline]
45+ fn into ( self ) -> UContext {
46+ UContext {
47+ context : unsafe { * ( self . 0 ) } ,
48+ }
49+ }
50+ }
Original file line number Diff line number Diff line change @@ -4,8 +4,14 @@ mod macos;
44#[ cfg( target_os = "linux" ) ]
55mod linux;
66
7+ #[ cfg( target_os = "freebsd" ) ]
8+ mod freebsd;
9+
710#[ cfg( target_os = "macos" ) ]
811pub use macos:: * ;
912
1013#[ cfg( target_os = "linux" ) ]
1114pub use linux:: * ;
15+
16+ #[ cfg( target_os = "freebsd" ) ]
17+ pub use freebsd:: * ;
You can’t perform that action at this time.
0 commit comments