Skip to content

Commit c580917

Browse files
chore: bump use i32 for pid in instrument-hooks api
1 parent d43ef31 commit c580917

4 files changed

Lines changed: 14 additions & 9 deletions

File tree

crates/codspeed/src/instrument_hooks/bindings.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ pub const MARKER_TYPE_SAMPLE_START: u32 = 0;
44
pub const MARKER_TYPE_SAMPLE_END: u32 = 1;
55
pub const MARKER_TYPE_BENCHMARK_START: u32 = 2;
66
pub const MARKER_TYPE_BENCHMARK_END: u32 = 3;
7-
pub type InstrumentHooks = *mut u64;
7+
#[repr(C)]
8+
#[derive(Debug, Copy, Clone)]
9+
pub struct InstrumentHooks {
10+
_unused: [u8; 0],
11+
}
812
extern "C" {
913
pub fn instrument_hooks_init() -> *mut InstrumentHooks;
1014
}
@@ -44,7 +48,7 @@ extern "C" {
4448
extern "C" {
4549
pub fn instrument_hooks_add_marker(
4650
arg1: *mut InstrumentHooks,
47-
pid: u32,
51+
pid: i32,
4852
marker_type: u8,
4953
timestamp: u64,
5054
) -> u8;
@@ -56,7 +60,7 @@ pub const instrument_hooks_feature_t_FEATURE_DISABLE_CALLGRIND_MARKERS: instrume
5660
0;
5761
pub type instrument_hooks_feature_t = ::std::os::raw::c_uint;
5862
extern "C" {
59-
pub fn instrument_hooks_set_feature(feature: instrument_hooks_feature_t, enabled: bool);
63+
pub fn instrument_hooks_set_feature(feature: u64, enabled: bool);
6064
}
6165
extern "C" {
6266
pub fn instrument_hooks_set_environment(
@@ -76,5 +80,5 @@ extern "C" {
7680
) -> u8;
7781
}
7882
extern "C" {
79-
pub fn instrument_hooks_write_environment(arg1: *mut InstrumentHooks, pid: u32) -> u8;
83+
pub fn instrument_hooks_write_environment(arg1: *mut InstrumentHooks, pid: i32) -> u8;
8084
}

crates/codspeed/src/instrument_hooks/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ mod linux_impl {
129129

130130
#[inline(always)]
131131
pub fn add_benchmark_timestamps(&self, start: u64, end: u64) {
132-
let pid = std::process::id();
132+
let pid = std::process::id() as i32;
133133

134134
unsafe {
135135
ffi::instrument_hooks_add_marker(
@@ -191,7 +191,7 @@ mod linux_impl {
191191
}
192192

193193
pub fn write_environment(&self) -> Result<(), u8> {
194-
let pid = std::process::id();
194+
let pid = std::process::id() as i32;
195195
let result = unsafe { ffi::instrument_hooks_write_environment(self.0, pid) };
196196
if result == 0 {
197197
Ok(())
@@ -203,7 +203,7 @@ mod linux_impl {
203203
pub fn disable_callgrind_markers() {
204204
unsafe {
205205
ffi::instrument_hooks_set_feature(
206-
ffi::instrument_hooks_feature_t_FEATURE_DISABLE_CALLGRIND_MARKERS,
206+
ffi::instrument_hooks_feature_t_FEATURE_DISABLE_CALLGRIND_MARKERS.into(),
207207
true,
208208
)
209209
};

crates/codspeed/src/instrument_hooks/update-bindings.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ bindgen "$SCRIPT_DIR/../../instrument-hooks/includes/core.h" \
77
-o "$SCRIPT_DIR/bindings.rs" \
88
--rust-target 1.74 \
99
--allowlist-function "instrument_hooks_.*" \
10-
--allowlist-var "MARKER_TYPE_.*"
10+
--allowlist-var "MARKER_TYPE_.*" \
11+
--allowlist-type "instrument_hooks_feature_t"

0 commit comments

Comments
 (0)