heartbeats_simple_sys/
hbs_pow_sys.rs1#![allow(non_camel_case_types)]
2
3use libc::{uint64_t, c_double, c_int};
4use hbs_common_sys::{heartbeat_udata, heartbeat_rates, heartbeat_window_state};
5
6pub type heartbeat_pow_window_complete = Option<extern "C" fn(*const heartbeat_pow_context)>;
8
9#[repr(C)]
11pub struct heartbeat_pow_record {
12 pub id: uint64_t,
13 pub user_tag: uint64_t,
14
15 pub work: uint64_t,
16 pub wd: heartbeat_udata,
17 pub start_time: uint64_t,
18 pub end_time: uint64_t,
19 pub td: heartbeat_udata,
20 pub perf: heartbeat_rates,
21
22 pub start_energy: uint64_t,
23 pub end_energy: uint64_t,
24 pub ed: heartbeat_udata,
25 pub pwr: heartbeat_rates,
26}
27
28#[repr(C)]
30pub struct heartbeat_pow_context {
31 pub ws: heartbeat_window_state,
32 pub window_buffer: *mut heartbeat_pow_record,
33 pub counter: uint64_t,
34 pub lock: c_int,
35 pub hwc_callback: heartbeat_pow_window_complete,
36
37 pub td: heartbeat_udata,
38 pub wd: heartbeat_udata,
39 pub ed: heartbeat_udata,
40}
41
42extern "C" {
43 pub fn heartbeat_pow_init(hb: *mut heartbeat_pow_context,
46 window_size: uint64_t,
47 window_buffer: *mut heartbeat_pow_record,
48 log_fd: c_int,
49 hwc_callback: heartbeat_pow_window_complete) -> c_int;
50
51 pub fn heartbeat_pow(hb: *mut heartbeat_pow_context,
52 user_tag: uint64_t,
53 work: uint64_t,
54 start_time: uint64_t,
55 end_time: uint64_t,
56 start_energy: uint64_t,
57 end_energy: uint64_t);
58
59 pub fn hb_pow_log_header(fd: c_int) -> c_int;
60
61 pub fn hb_pow_log_window_buffer(hb: *const heartbeat_pow_context,
62 fd: c_int) -> c_int;
63
64 pub fn hb_pow_get_window_size(hb: *const heartbeat_pow_context) -> uint64_t;
67 pub fn hb_pow_get_log_fd(hb: *const heartbeat_pow_context) -> c_int;
68
69 pub fn hb_pow_get_user_tag(hb: *const heartbeat_pow_context) -> uint64_t;
70
71 pub fn hb_pow_get_global_time(hb: *const heartbeat_pow_context) -> uint64_t;
72 pub fn hb_pow_get_window_time(hb: *const heartbeat_pow_context) -> uint64_t;
73 pub fn hb_pow_get_global_work(hb: *const heartbeat_pow_context) -> uint64_t;
74 pub fn hb_pow_get_window_work(hb: *const heartbeat_pow_context) -> uint64_t;
75
76 pub fn hb_pow_get_global_perf(hb: *const heartbeat_pow_context) -> c_double;
77 pub fn hb_pow_get_window_perf(hb: *const heartbeat_pow_context) -> c_double;
78 pub fn hb_pow_get_instant_perf(hb: *const heartbeat_pow_context) -> c_double;
79
80 pub fn hb_pow_get_global_energy(hb: *const heartbeat_pow_context) -> uint64_t;
81 pub fn hb_pow_get_window_energy(hb: *const heartbeat_pow_context) -> uint64_t;
82
83 pub fn hb_pow_get_global_power(hb: *const heartbeat_pow_context) -> c_double;
84 pub fn hb_pow_get_window_power(hb: *const heartbeat_pow_context) -> c_double;
85 pub fn hb_pow_get_instant_power(hb: *const heartbeat_pow_context) -> c_double;
86}