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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
extern crate matrix;
extern crate superlu;
extern crate threed_ice_sys as ffi;
macro_rules! raise(
($message:expr) => (raise!(Other, $message));
($kind:ident, $message:expr) => (
return Err(::std::io::Error::new(::std::io::ErrorKind::$kind, $message))
);
);
macro_rules! ok(
($result:expr) => (match $result {
Ok(ok) => ok,
_ => raise!("something went wrong"),
});
);
macro_rules! some(
($result:expr) => (match $result {
Some(some) => some,
_ => raise!("something went wrong"),
});
);
macro_rules! success(
($result:expr, $message:expr) => (if $result != ::ffi::TDICE_SUCCESS {
raise!(concat!("failed to ", $message));
});
);
macro_rules! c_str_to_string(
($string:expr) => (
String::from_utf8_lossy(::std::ffi::CStr::from_ptr($string as *const _).to_bytes())
.into_owned()
);
);
macro_rules! str_to_cstr(
($str:expr) => (ok!(::std::ffi::CString::new($str)));
);
macro_rules! path_to_cstr(
($path:expr) => (str_to_cstr!(some!($path.to_str())));
);
macro_rules! slice(
($pointer:expr, $size:expr) => (unsafe {
::std::slice::from_raw_parts($pointer, $size)
});
);
pub type Error = std::io::Error;
pub type Result<T> = std::result::Result<T, Error>;
trait Raw {
type Target;
fn raw(&self) -> &Self::Target;
fn raw_mut(&mut self) -> &mut Self::Target;
}
macro_rules! implement_raw(
($kind:ty, $target:ty) => (
impl ::Raw for $kind {
type Target = $target;
#[inline(always)]
fn raw(&self) -> &Self::Target {
&self.raw
}
#[inline(always)]
fn raw_mut(&mut self) -> &mut Self::Target {
&mut self.raw
}
}
);
($kind:ident, $target:ty, l) => (
impl<'l> ::Raw for $kind<'l> {
type Target = $target;
#[inline(always)]
fn raw(&self) -> &Self::Target {
&self.raw
}
#[inline(always)]
fn raw_mut(&mut self) -> &mut Self::Target {
&mut self.raw
}
}
);
);
mod analysis;
mod die;
mod dimensions;
mod floorplan;
mod output;
mod power_grid;
mod stack;
mod system;
mod system_matrix;
mod thermal_grid;
pub use analysis::{Analysis, AnalysisType};
pub use die::Die;
pub use dimensions::Dimensions;
pub use floorplan::{Floorplan, FloorplanElement};
pub use stack::{Stack, StackElement};
pub use system::System;