Skip to content

Commit a5c1ffe

Browse files
author
Henry Qin
committed
Make StatsMinimal.h directly compatible with C
1 parent 0e16cb5 commit a5c1ffe

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

cwrapper/perf_wrapper_test.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,14 @@ void fiveHundredCycles() {
2929
fixedCycles(500);
3030
}
3131

32+
uint64_t half(uint64_t n) {
33+
return n / 2;
34+
}
35+
3236
int
3337
main() {
3438
Statistics stats = bench(fiveHundredCycles, 100000);
39+
stats = transformStatistics(stats, half);
3540
if (stats.count == 100000 && stats.count > stats.min) {
3641
puts(GREEN("perf_wrapper_test PASSED"));
3742
} else {

src/StatsMinimal.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
#include <stddef.h>
2020
#include <stdbool.h>
2121

22+
#ifdef __cplusplus
23+
extern "C" {
24+
#endif
25+
2226
/**
2327
* This file exists to make the computeStatistics function available from C
2428
* without an extra wrapper around the stats component of PerfUtils.
@@ -59,4 +63,8 @@ struct Statistics transformStatistics(struct Statistics stats, uint64_t (*functi
5963
*/
6064
void printStatistics(struct Statistics stats, const char* label);
6165

66+
#ifdef __cplusplus
67+
}
68+
#endif
69+
6270
#endif // PERFUTILS_STATS_MINIMAL_H

0 commit comments

Comments
 (0)