xref: /freebsd/lib/libpmc/pmu-events/json.h (revision 315ee00f)
1 #ifndef JSON_H
2 #define JSON_H 1
3 
4 #include "jsmn.h"
5 
6 jsmntok_t *parse_json(const char *fn, char **map, size_t *size, int *len);
7 void free_json(char *map, size_t size, jsmntok_t *tokens);
8 int json_line(char *map, jsmntok_t *t);
9 const char *json_name(jsmntok_t *t);
10 int json_streq(char *map, jsmntok_t *t, const char *s);
11 int json_len(jsmntok_t *t);
12 
13 extern int verbose;
14 
15 #include <stdbool.h>
16 
17 extern int eprintf(int level, int var, const char *fmt, ...);
18 #define pr_fmt(fmt)	fmt
19 
20 #define pr_err(fmt, ...) \
21 	eprintf(0, verbose, pr_fmt(fmt), ##__VA_ARGS__)
22 
23 #define pr_info(fmt, ...) \
24 	eprintf(1, verbose, pr_fmt(fmt), ##__VA_ARGS__)
25 
26 #define pr_debug(fmt, ...) \
27 	eprintf(2, verbose, pr_fmt(fmt), ##__VA_ARGS__)
28 
29 #ifndef roundup
30 #define roundup(x, y) (                                \
31 {                                                      \
32         const typeof(y) __y = y;                       \
33         (((x) + (__y - 1)) / __y) * __y;               \
34 }                                                      \
35 )
36 #endif
37 
38 #endif
39