libinterfork: fix warnings
[ust.git] / share / usterr.h
CommitLineData
59b161cd
PMF
1#ifndef USTERR_H
2#define USTERR_H
3
2028e7fd
PMF
4#ifndef UST_COMPONENT
5//#error UST_COMPONENT is undefined
6#define UST_COMPONENT libust
7#endif
8
9/* To stringify the expansion of a define */
10#define XSTR(d) STR(d)
11#define STR(s) #s
12
13#define UST_STR_COMPONENT XSTR(UST_COMPONENT)
14
15#define DEBUG
17674885 16#ifdef DEBUG
2028e7fd 17# define DBG(fmt, args...) do { fprintf(stderr, UST_STR_COMPONENT ": " fmt "(" __FILE__ ":" XSTR(__LINE__) ")\n", ## args); fflush(stderr); } while(0)
17674885
PMF
18#else
19# define DBG(fmt, args...) do {} while(0)
20#endif
2028e7fd
PMF
21#define WARN(fmt, args...) fprintf(stderr, UST_STR_COMPONENT ": Warning: " fmt "\n", ## args); fflush(stderr)
22#define ERR(fmt, args...) fprintf(stderr, UST_STR_COMPONENT ": Error: " fmt "\n", ## args); fflush(stderr)
23#define BUG(fmt, args...) fprintf(stderr, UST_STR_COMPONENT ": BUG: " fmt "\n", ## args); fflush(stderr)
e91e64b6 24#define PERROR(call) perror(UST_STR_COMPONENT ": Error: " call)
c9b64079
PMF
25
26#define BUG_ON(condition) do { if (unlikely(condition)) ERR("condition not respected (BUG)"); } while(0)
5f54827b 27#define WARN_ON(condition) do { if (unlikely(condition)) WARN("condition not respected on line %s:%d", __FILE__, __LINE__); } while(0)
c9b64079 28
59b161cd 29#endif /* USTERR_H */
This page took 0.022858 seconds and 4 git commands to generate.