tapdisk_driver_debug(driver);
}
-void
+__noreturn void
td_panic(void)
{
tlog_precious();
long long, td_queue_callback_t, void *);
void td_prep_write(struct tiocb *, int, char *, size_t,
long long, td_queue_callback_t, void *);
-void td_panic(void) __attribute__((noreturn));
+void td_panic(void) __noreturn;
#endif
tapdisk_logfile_vprintf(&tapdisk_log.logfile, fmt, ap);
}
-static void
-__attribute__((format(printf, 1, 2)))
+static void __printf(1, 2)
tlog_logfile_print(const char *fmt, ...)
{
va_list ap;
#define TLOG_DIR "/var/log/blktap"
#include <stdarg.h>
+#include "compiler.h"
int tlog_open(const char *, int, int);
void tlog_close(void);
void tlog_precious(void);
void tlog_vsyslog(int, const char *, va_list);
-void tlog_syslog(int, const char *, ...);
+void tlog_syslog(int, const char *, ...) __printf(2, 3);
#include <syslog.h>
#define DPRINTF(_f, _a...) syslog(LOG_INFO, _f, ##_a)
#define PERROR(_f, _a...) EPRINTF(_f ": %s", ##_a, strerror(errno))
-void __tlog_write(int, const char *, ...)
- __attribute__((format(printf, 2, 3)));
-
-void __tlog_error(const char *fmt, ...)
- __attribute__((format(printf, 1, 2)));
+void __tlog_write(int, const char *, ...) __printf(2, 3);
+void __tlog_error(const char *fmt, ...) __printf(1, 2);
#define tlog_write(_level, _f, _a...) \
__tlog_write(_level, "%s: " _f, __func__, ##_a)
st->pos += vsnprintf(st->pos, size, fmt, ap);
}
-static void __attribute__((format (printf, 2, 3)))
+static void __printf(2, 3)
__stats_sprintf(td_stats_t *st,
const char *fmt, ...)
{
#include <stdint.h>
#include "list.h"
+#include "compiler.h"
#include "tapdisk-log.h"
#include "tapdisk-utils.h"
#include "tapdisk-stats.h"
--- /dev/null
+#ifndef _BLKTAP_COMPILER_H
+#define _BLKTAP_COMPILER_H
+
+#ifdef __GNUC__
+#define likely(_cond) __builtin_expect(!!(_cond), 1)
+#define unlikely(_cond) __builtin_expect(!!(_cond), 0)
+#endif
+
+#ifndef likely
+#define likely(_cond) (_cond)
+#endif
+
+#ifndef unlikely
+#define unlikely(_cond) (_cond)
+#endif
+
+#ifdef __GNUC__
+#define __printf(_f, _a) __attribute__((format (printf, _f, _a)))
+#define __scanf(_f, _a) __attribute__((format (scanf, _f, _a)))
+#define __noreturn __attribute__((noreturn))
+#endif
+
+#ifndef __printf
+#define __printf(_f, _a)
+#endif
+
+#ifndef __scanf
+#define __scanf(_f, _a)
+#endif
+
+#ifndef __noreturn
+#define __noreturn
+#endif
+
+#endif /* _BLKTAP_COMPILER_H */