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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
use super::*;
use crate::error::SgxStatus;
impl_enum! {
#[repr(u32)]
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum SwitchlessWokerType {
Untrusted = 0,
Trusted = 1,
}
}
impl_enum! {
#[repr(u32)]
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum SwitchlessWokerEvent {
Start = 0,
Idel = 1,
Miss = 2,
Exit = 3,
Num = 4,
}
}
impl_struct! {
#[repr(C)]
#[derive(Debug, Eq, PartialEq)]
pub struct SwitchlessWokerStats {
pub processed: u64,
pub missed: u64,
}
}
impl_asref_array! {
SwitchlessWokerStats;
}
impl_asmut_array! {
SwitchlessWokerStats;
}
impl_from_array! {
SwitchlessWokerStats;
}
pub type SwitchlessWokerCallback = extern "C" fn(
typ: SwitchlessWokerType,
event: SwitchlessWokerEvent,
stats: *const SwitchlessWokerStats,
) -> SgxStatus;
pub const SL_DEFAULT_FALLBACK_RETRIES: u32 = 20000;
pub const SL_DEFAULT_SLEEP_RETRIES: u32 = 20000;
pub const SL_DEFUALT_MAX_TASKS_QWORDS: u32 = 1;
pub const SL_MAX_TASKS_MAX_QWORDS: u32 = 8;
#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct SwitchlessConfig {
pub pool_size_qwords: u32,
pub uworkers: u32,
pub tworkers: u32,
pub retries_before_fallback: u32,
pub retries_before_sleep: u32,
pub callback: [Option<SwitchlessWokerCallback>; 4],
}
impl Default for SwitchlessConfig {
fn default() -> SwitchlessConfig {
SwitchlessConfig {
pool_size_qwords: 0,
uworkers: 1,
tworkers: 1,
retries_before_fallback: 0,
retries_before_sleep: 0,
callback: [None; 4],
}
}
}