12a4214028eb45a1f9d5b8a1c27d8bfb752d4e5e
6 #include <sys/syscall.h>
14 //#error UST_COMPONENT is undefined
15 #define UST_COMPONENT libust
18 /* To stringify the expansion of a define */
19 #define XSTR(d) STR(d)
22 /* We sometimes print in the tracing path, and tracing can occur in
23 * signal handlers, so we must use a print method which is signal safe.
26 #define sigsafe_print_err(fmt, args...) \
28 /* Can't use dynamic allocation. Limit ourselves to 250 chars. */ \
30 int ____saved_errno; \
32 /* Save the errno. */ \
33 ____saved_errno = errno; \
35 snprintf(____buf, sizeof(____buf), fmt, ## args); \
37 /* Add end of string in case of buffer overflow. */ \
38 ____buf[sizeof(____buf)-1] = 0; \
40 patient_write(STDERR_FILENO, ____buf, strlen(____buf)); \
41 /* Can't print errors because we are in the error printing code path. */ \
43 /* Restore errno, in order to be async-signal safe. */ \
44 errno = ____saved_errno; \
47 #define UST_STR_COMPONENT XSTR(UST_COMPONENT)
49 #define ERRMSG(fmt, args...) do { sigsafe_print_err(UST_STR_COMPONENT "[%ld/%ld]: " fmt " (" __FILE__ ":" XSTR(__LINE__) ")\n", (long) getpid(), (long) syscall(SYS_gettid), ## args); fflush(stderr); } while(0)
52 # define DBG(fmt, args...) ERRMSG(fmt, ## args)
54 # define DBG(fmt, args...) do {} while(0)
56 #define WARN(fmt, args...) ERRMSG("Warning: " fmt, ## args)
57 #define ERR(fmt, args...) ERRMSG("Error: " fmt, ## args)
58 #define BUG(fmt, args...) ERRMSG("BUG: " fmt, ## args)
60 #if (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !defined(_GNU_SOURCE)
61 #define PERROR(call, args...)\
63 char buf[200] = "Error in strerror_r()"; \
64 strerror_r(errno, buf, sizeof(buf)); \
65 ERRMSG("Error: " call ": %s", ## args, buf); \
68 #define PERROR(call, args...)\
72 buf = strerror_r(errno, tmp, sizeof(tmp)); \
73 ERRMSG("Error: " call ": %s", ## args, buf); \
77 #define BUG_ON(condition) do { if (unlikely(condition)) ERR("condition not respected (BUG)"); } while(0)
78 #define WARN_ON(condition) do { if (unlikely(condition)) WARN("condition not respected on line %s:%d", __FILE__, __LINE__); } while(0)
This page took 0.032495 seconds and 4 git commands to generate.