summaryrefslogtreecommitdiffstats
path: root/third_party/rust/mach2/src/structs.rs
blob: 75dc0e8dba5fcfa76285004c9aab94b48e072c4e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//! This module corresponds to `mach/_structs.h`.

use mem;
use message::mach_msg_type_number_t;

#[repr(C)]
#[derive(Copy, Clone, Debug, Default, Hash, PartialOrd, PartialEq, Eq, Ord)]
pub struct x86_thread_state64_t {
    pub __rax: u64,
    pub __rbx: u64,
    pub __rcx: u64,
    pub __rdx: u64,
    pub __rdi: u64,
    pub __rsi: u64,
    pub __rbp: u64,
    pub __rsp: u64,
    pub __r8: u64,
    pub __r9: u64,
    pub __r10: u64,
    pub __r11: u64,
    pub __r12: u64,
    pub __r13: u64,
    pub __r14: u64,
    pub __r15: u64,
    pub __rip: u64,
    pub __rflags: u64,
    pub __cs: u64,
    pub __fs: u64,
    pub __gs: u64,
}

impl x86_thread_state64_t {
    pub fn new() -> Self {
        Self {
            __rax: 0,
            __rbx: 0,
            __rcx: 0,
            __rdx: 0,
            __rdi: 0,
            __rsi: 0,
            __rbp: 0,
            __rsp: 0,
            __r8: 0,
            __r9: 0,
            __r10: 0,
            __r11: 0,
            __r12: 0,
            __r13: 0,
            __r14: 0,
            __r15: 0,
            __rip: 0,
            __rflags: 0,
            __cs: 0,
            __fs: 0,
            __gs: 0,
        }
    }

    pub fn count() -> mach_msg_type_number_t {
        (mem::size_of::<Self>() / mem::size_of::<::libc::c_int>()) as mach_msg_type_number_t
    }
}