Skip to content

Commit ba4c5a3

Browse files
feat: suppress unused argument warning when building stubs
1 parent 662fbd3 commit ba4c5a3

3 files changed

Lines changed: 144 additions & 72 deletions

File tree

dist/core.c

Lines changed: 72 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -16,58 +16,94 @@ struct InstrumentHooks {
1616

1717
static struct InstrumentHooks stub_instance = {0};
1818

19-
InstrumentHooks *instrument_hooks_init(void) { return &stub_instance; }
19+
InstrumentHooks* instrument_hooks_init(void) { return &stub_instance; }
2020

21-
void instrument_hooks_deinit(InstrumentHooks *hooks) {}
21+
void instrument_hooks_deinit(InstrumentHooks* hooks) { (void)hooks; }
2222

23-
bool instrument_hooks_is_instrumented(InstrumentHooks *hooks) { return false; }
23+
bool instrument_hooks_is_instrumented(InstrumentHooks* hooks) {
24+
(void)hooks;
25+
return false;
26+
}
2427

25-
uint8_t instrument_hooks_start_benchmark(InstrumentHooks *hooks) { return 0; }
28+
uint8_t instrument_hooks_start_benchmark(InstrumentHooks* hooks) {
29+
(void)hooks;
30+
return 0;
31+
}
2632

27-
uint8_t instrument_hooks_stop_benchmark(InstrumentHooks *hooks) { return 0; }
33+
uint8_t instrument_hooks_stop_benchmark(InstrumentHooks* hooks) {
34+
(void)hooks;
35+
return 0;
36+
}
2837

29-
uint8_t instrument_hooks_set_executed_benchmark(InstrumentHooks *hooks,
30-
uint32_t pid, const char *uri) {
38+
uint8_t instrument_hooks_set_executed_benchmark(InstrumentHooks* hooks,
39+
uint32_t pid, const char* uri) {
40+
(void)hooks;
41+
(void)pid;
42+
(void)uri;
3143
return 0;
3244
}
3345

3446
// Deprecated: use instrument_hooks_set_executed_benchmark instead
35-
uint8_t instrument_hooks_executed_benchmark(InstrumentHooks *hooks,
36-
uint32_t pid, const char *uri) {
47+
uint8_t instrument_hooks_executed_benchmark(InstrumentHooks* hooks,
48+
uint32_t pid, const char* uri) {
49+
(void)hooks;
50+
(void)pid;
51+
(void)uri;
3752
return 0;
3853
}
3954

40-
uint8_t instrument_hooks_set_integration(InstrumentHooks *hooks,
41-
const char *name,
42-
const char *version) {
55+
uint8_t instrument_hooks_set_integration(InstrumentHooks* hooks,
56+
const char* name,
57+
const char* version) {
58+
(void)hooks;
59+
(void)name;
60+
(void)version;
4361
return 0;
4462
}
4563

46-
void instrument_hooks_set_feature(uint64_t feature, bool enabled) {}
64+
void instrument_hooks_set_feature(uint64_t feature, bool enabled) {
65+
(void)feature;
66+
(void)enabled;
67+
}
4768

4869
uint64_t instrument_hooks_current_timestamp(void) { return 0; }
4970

50-
uint8_t instrument_hooks_add_marker(InstrumentHooks *hooks, uint32_t pid,
71+
uint8_t instrument_hooks_add_marker(InstrumentHooks* hooks, uint32_t pid,
5172
uint8_t marker_type, uint64_t timestamp) {
73+
(void)hooks;
74+
(void)pid;
75+
(void)marker_type;
76+
(void)timestamp;
5277
return 0;
5378
}
5479

55-
uint8_t instrument_hooks_set_environment(InstrumentHooks *hooks,
56-
const char *section_name,
57-
const char *key, const char *value) {
80+
uint8_t instrument_hooks_set_environment(InstrumentHooks* hooks,
81+
const char* section_name,
82+
const char* key, const char* value) {
83+
(void)hooks;
84+
(void)section_name;
85+
(void)key;
86+
(void)value;
5887
return 0;
5988
}
6089

61-
uint8_t instrument_hooks_set_environment_list(InstrumentHooks *hooks,
62-
const char *section_name,
63-
const char *key,
64-
const char *const *values,
90+
uint8_t instrument_hooks_set_environment_list(InstrumentHooks* hooks,
91+
const char* section_name,
92+
const char* key,
93+
const char* const* values,
6594
uint32_t count) {
95+
(void)hooks;
96+
(void)section_name;
97+
(void)key;
98+
(void)values;
99+
(void)count;
66100
return 0;
67101
}
68102

69-
uint8_t instrument_hooks_write_environment(InstrumentHooks *hooks,
103+
uint8_t instrument_hooks_write_environment(InstrumentHooks* hooks,
70104
uint32_t pid) {
105+
(void)hooks;
106+
(void)pid;
71107
return 0;
72108
}
73109

@@ -30970,7 +31006,20 @@ static struct Target_Cpu_Model__994 const Target_x86_cpu_tigerlake__4631 = {{(ui
3097031006

3097131007
#include <stdint.h>
3097231008

30973-
#ifndef _WIN32
31009+
#if defined(_WIN32) || defined(__APPLE__)
31010+
// Windows and other platforms - provide no-op implementations
31011+
uint8_t running_on_valgrind() { return 0; }
31012+
31013+
void callgrind_dump_stats() {}
31014+
31015+
void callgrind_dump_stats_at(uint8_t const* pos_str) { (void)pos_str; }
31016+
31017+
void callgrind_zero_stats() {}
31018+
31019+
void callgrind_start_instrumentation() {}
31020+
31021+
void callgrind_stop_instrumentation() {}
31022+
#else
3097431023
#include "callgrind.h"
3097531024
#include "valgrind.h"
3097631025

@@ -30988,19 +31037,6 @@ void callgrind_start_instrumentation() { CALLGRIND_START_INSTRUMENTATION; }
3098831037

3098931038
void callgrind_stop_instrumentation() { CALLGRIND_STOP_INSTRUMENTATION; }
3099031039

30991-
#else
30992-
// Windows and other platforms - provide no-op implementations
30993-
uint8_t running_on_valgrind() { return 0; }
30994-
30995-
void callgrind_dump_stats() {}
30996-
30997-
void callgrind_dump_stats_at(uint8_t const* pos_str) {}
30998-
30999-
void callgrind_zero_stats() {}
31000-
31001-
void callgrind_start_instrumentation() {}
31002-
31003-
void callgrind_stop_instrumentation() {}
3100431040
#endif
3100531041

3100631042
#endif

scripts/stub.c

Lines changed: 58 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,57 +9,93 @@ struct InstrumentHooks {
99

1010
static struct InstrumentHooks stub_instance = {0};
1111

12-
InstrumentHooks *instrument_hooks_init(void) { return &stub_instance; }
12+
InstrumentHooks* instrument_hooks_init(void) { return &stub_instance; }
1313

14-
void instrument_hooks_deinit(InstrumentHooks *hooks) {}
14+
void instrument_hooks_deinit(InstrumentHooks* hooks) { (void)hooks; }
1515

16-
bool instrument_hooks_is_instrumented(InstrumentHooks *hooks) { return false; }
16+
bool instrument_hooks_is_instrumented(InstrumentHooks* hooks) {
17+
(void)hooks;
18+
return false;
19+
}
1720

18-
uint8_t instrument_hooks_start_benchmark(InstrumentHooks *hooks) { return 0; }
21+
uint8_t instrument_hooks_start_benchmark(InstrumentHooks* hooks) {
22+
(void)hooks;
23+
return 0;
24+
}
1925

20-
uint8_t instrument_hooks_stop_benchmark(InstrumentHooks *hooks) { return 0; }
26+
uint8_t instrument_hooks_stop_benchmark(InstrumentHooks* hooks) {
27+
(void)hooks;
28+
return 0;
29+
}
2130

22-
uint8_t instrument_hooks_set_executed_benchmark(InstrumentHooks *hooks,
23-
uint32_t pid, const char *uri) {
31+
uint8_t instrument_hooks_set_executed_benchmark(InstrumentHooks* hooks,
32+
uint32_t pid, const char* uri) {
33+
(void)hooks;
34+
(void)pid;
35+
(void)uri;
2436
return 0;
2537
}
2638

2739
// Deprecated: use instrument_hooks_set_executed_benchmark instead
28-
uint8_t instrument_hooks_executed_benchmark(InstrumentHooks *hooks,
29-
uint32_t pid, const char *uri) {
40+
uint8_t instrument_hooks_executed_benchmark(InstrumentHooks* hooks,
41+
uint32_t pid, const char* uri) {
42+
(void)hooks;
43+
(void)pid;
44+
(void)uri;
3045
return 0;
3146
}
3247

33-
uint8_t instrument_hooks_set_integration(InstrumentHooks *hooks,
34-
const char *name,
35-
const char *version) {
48+
uint8_t instrument_hooks_set_integration(InstrumentHooks* hooks,
49+
const char* name,
50+
const char* version) {
51+
(void)hooks;
52+
(void)name;
53+
(void)version;
3654
return 0;
3755
}
3856

39-
void instrument_hooks_set_feature(uint64_t feature, bool enabled) {}
57+
void instrument_hooks_set_feature(uint64_t feature, bool enabled) {
58+
(void)feature;
59+
(void)enabled;
60+
}
4061

4162
uint64_t instrument_hooks_current_timestamp(void) { return 0; }
4263

43-
uint8_t instrument_hooks_add_marker(InstrumentHooks *hooks, uint32_t pid,
64+
uint8_t instrument_hooks_add_marker(InstrumentHooks* hooks, uint32_t pid,
4465
uint8_t marker_type, uint64_t timestamp) {
66+
(void)hooks;
67+
(void)pid;
68+
(void)marker_type;
69+
(void)timestamp;
4570
return 0;
4671
}
4772

48-
uint8_t instrument_hooks_set_environment(InstrumentHooks *hooks,
49-
const char *section_name,
50-
const char *key, const char *value) {
73+
uint8_t instrument_hooks_set_environment(InstrumentHooks* hooks,
74+
const char* section_name,
75+
const char* key, const char* value) {
76+
(void)hooks;
77+
(void)section_name;
78+
(void)key;
79+
(void)value;
5180
return 0;
5281
}
5382

54-
uint8_t instrument_hooks_set_environment_list(InstrumentHooks *hooks,
55-
const char *section_name,
56-
const char *key,
57-
const char *const *values,
83+
uint8_t instrument_hooks_set_environment_list(InstrumentHooks* hooks,
84+
const char* section_name,
85+
const char* key,
86+
const char* const* values,
5887
uint32_t count) {
88+
(void)hooks;
89+
(void)section_name;
90+
(void)key;
91+
(void)values;
92+
(void)count;
5993
return 0;
6094
}
6195

62-
uint8_t instrument_hooks_write_environment(InstrumentHooks *hooks,
96+
uint8_t instrument_hooks_write_environment(InstrumentHooks* hooks,
6397
uint32_t pid) {
98+
(void)hooks;
99+
(void)pid;
64100
return 0;
65101
}

src/helpers/valgrind_wrapper.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,20 @@
33

44
#include <stdint.h>
55

6-
#ifndef _WIN32
6+
#if defined(_WIN32) || defined(__APPLE__)
7+
// Windows and other platforms - provide no-op implementations
8+
uint8_t running_on_valgrind() { return 0; }
9+
10+
void callgrind_dump_stats() {}
11+
12+
void callgrind_dump_stats_at(uint8_t const* pos_str) { (void)pos_str; }
13+
14+
void callgrind_zero_stats() {}
15+
16+
void callgrind_start_instrumentation() {}
17+
18+
void callgrind_stop_instrumentation() {}
19+
#else
720
#include "callgrind.h"
821
#include "valgrind.h"
922

@@ -21,19 +34,6 @@ void callgrind_start_instrumentation() { CALLGRIND_START_INSTRUMENTATION; }
2134

2235
void callgrind_stop_instrumentation() { CALLGRIND_STOP_INSTRUMENTATION; }
2336

24-
#else
25-
// Windows and other platforms - provide no-op implementations
26-
uint8_t running_on_valgrind() { return 0; }
27-
28-
void callgrind_dump_stats() {}
29-
30-
void callgrind_dump_stats_at(uint8_t const* pos_str) {}
31-
32-
void callgrind_zero_stats() {}
33-
34-
void callgrind_start_instrumentation() {}
35-
36-
void callgrind_stop_instrumentation() {}
3737
#endif
3838

3939
#endif

0 commit comments

Comments
 (0)