| 1 | use std::marker::PhantomData; |
| 2 | |
| 3 | /// `JmpBufFields` are the accessible fields when viewed via a JmpBuf pointer. |
| 4 | /// But also: You shouldn't be poking at these! |
| 5 | #[repr(C)] |
| 6 | pub struct JmpBufFields { |
| 7 | _buf: [u64; 8], |
| 8 | _neither_send_nor_sync: PhantomData<*const u8>, |
| 9 | } |
| 10 | |
| 11 | /// `SigJmpBufFields` are the accessible fields when viewed via a SigJmpBuf pointer. |
| 12 | /// But also: You shouldn't be poking at these! |
| 13 | #[repr(C)] |
| 14 | pub struct SigJmpBufFields { |
| 15 | // This *must* be the first field. We allow `SigJmpBuf` to be transmuted to |
| 16 | // a `JmpBuf` and then back again depending on the host libc. (e.g. glibc |
| 17 | // has setjmp as a shallow wrapper around sigsetjmp, and will write to |
| 18 | // fields past the `__jmp_buf`). |
| 19 | __jmp_buf: JmpBufFields, |
| 20 | __mask_was_saved: isize, |
| 21 | __saved_mask: libc::sigset_t, |
| 22 | } |
| 23 | |
| 24 | /// This is the type you use to allocate a JmpBuf on the stack. |
| 25 | /// (Glibc puns the two.) |
| 26 | pub type JmpBufStruct = SigJmpBufFields; |
| 27 | |
| 28 | /// This is the type you use to allocate a SigJmpBuf on the stack. |
| 29 | pub type SigJmpBufStruct = SigJmpBufFields; |