Skip to content

Commit 6e617c1

Browse files
committed
perflib/err.h: add WARN/WARNX/ERR/ERRX
Signed-off-by: Eugene Syromiatnikov <[email protected]>
1 parent 1f334d1 commit 6e617c1

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

source/perflib/err.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
# define OSSL_PERFLIB_ERR_H
1212
# pragma once
1313

14+
# include <stdio.h>
15+
1416
# if !defined(_WIN32)
1517

1618
# include <err.h>
@@ -32,5 +34,26 @@ extern void warn(const char *, ...);
3234

3335
# endif /* !_WIN32 */
3436

37+
# define WARN(...) \
38+
do { \
39+
fprintf(stderr, "%s:%d(%s): ", __FILE__, __LINE__, __FUNCTION__); \
40+
warn(__VA_ARGS__); \
41+
} while (0)
42+
# define WARNX(...) \
43+
do { \
44+
fprintf(stderr, "%s:%d(%s): ", __FILE__, __LINE__, __FUNCTION__); \
45+
warnx(__VA_ARGS__); \
46+
} while (0)
47+
# define ERR(...) \
48+
do { \
49+
fprintf(stderr, "%s:%d(%s): ", __FILE__, __LINE__, __FUNCTION__); \
50+
err(__VA_ARGS__); \
51+
} while (0)
52+
# define ERRX(...) \
53+
do { \
54+
fprintf(stderr, "%s:%d(%s): ", __FILE__, __LINE__, __FUNCTION__); \
55+
errx(__VA_ARGS__); \
56+
} while (0)
57+
3558
#endif
3659

0 commit comments

Comments
 (0)