const char *ovs_get_program_name(void);
const char *ovs_get_program_version(void);
+/* Expands to a string that looks like "<file>:<line>", e.g. "tmp.c:10".
+ *
+ * See http://c-faq.com/ansi/stringize.html for an explanation of OVS_STRINGIZE
+ * and OVS_STRINGIZE2. */
+#define OVS_SOURCE_LOCATOR __FILE__ ":" OVS_STRINGIZE(__LINE__)
+#define OVS_STRINGIZE(ARG) OVS_STRINGIZE2(ARG)
+#define OVS_STRINGIZE2(ARG) #ARG
+
#ifdef __cplusplus
}
#endif
* ??:0
*/
-#define log_backtrace() log_backtrace_at(NULL, SOURCE_LOCATOR);
-#define log_backtrace_msg(msg) log_backtrace_at(msg, SOURCE_LOCATOR);
+#define log_backtrace() log_backtrace_at(NULL, OVS_SOURCE_LOCATOR);
+#define log_backtrace_msg(msg) log_backtrace_at(msg, OVS_SOURCE_LOCATOR);
#define BACKTRACE_MAX_FRAMES 31
/* Adjusting capacity. */
void hmap_expand_at(struct hmap *, const char *where);
-#define hmap_expand(HMAP) hmap_expand_at(HMAP, SOURCE_LOCATOR)
+#define hmap_expand(HMAP) hmap_expand_at(HMAP, OVS_SOURCE_LOCATOR)
void hmap_shrink_at(struct hmap *, const char *where);
-#define hmap_shrink(HMAP) hmap_shrink_at(HMAP, SOURCE_LOCATOR)
+#define hmap_shrink(HMAP) hmap_shrink_at(HMAP, OVS_SOURCE_LOCATOR)
void hmap_reserve_at(struct hmap *, size_t capacity, const char *where);
#define hmap_reserve(HMAP, CAPACITY) \
- hmap_reserve_at(HMAP, CAPACITY, SOURCE_LOCATOR)
+ hmap_reserve_at(HMAP, CAPACITY, OVS_SOURCE_LOCATOR)
/* Insertion and deletion. */
static inline void hmap_insert_at(struct hmap *, struct hmap_node *,
size_t hash, const char *where);
#define hmap_insert(HMAP, NODE, HASH) \
- hmap_insert_at(HMAP, NODE, HASH, SOURCE_LOCATOR)
+ hmap_insert_at(HMAP, NODE, HASH, OVS_SOURCE_LOCATOR)
static inline void hmap_insert_fast(struct hmap *,
struct hmap_node *, size_t hash);
bool latch_is_set(const struct latch *);
void latch_wait_at(const struct latch *, const char *where);
-#define latch_wait(latch) latch_wait_at(latch, SOURCE_LOCATOR)
+#define latch_wait(latch) latch_wait_at(latch, OVS_SOURCE_LOCATOR)
#endif /* latch.h */
void ovs_mutex_lock_at(const struct ovs_mutex *mutex, const char *where)
OVS_ACQUIRES(mutex);
#define ovs_mutex_lock(mutex) \
- ovs_mutex_lock_at(mutex, SOURCE_LOCATOR)
+ ovs_mutex_lock_at(mutex, OVS_SOURCE_LOCATOR)
int ovs_mutex_trylock_at(const struct ovs_mutex *mutex, const char *where)
OVS_TRY_LOCK(0, mutex);
#define ovs_mutex_trylock(mutex) \
- ovs_mutex_trylock_at(mutex, SOURCE_LOCATOR)
+ ovs_mutex_trylock_at(mutex, OVS_SOURCE_LOCATOR)
void ovs_mutex_cond_wait(pthread_cond_t *, const struct ovs_mutex *);
void ovs_rwlock_wrlock_at(const struct ovs_rwlock *rwlock, const char *where)
OVS_ACQ_WRLOCK(rwlock);
#define ovs_rwlock_wrlock(rwlock) \
- ovs_rwlock_wrlock_at(rwlock, SOURCE_LOCATOR)
+ ovs_rwlock_wrlock_at(rwlock, OVS_SOURCE_LOCATOR)
int ovs_rwlock_trywrlock_at(const struct ovs_rwlock *rwlock, const char *where)
OVS_TRY_WRLOCK(0, rwlock);
#define ovs_rwlock_trywrlock(rwlock) \
- ovs_rwlock_trywrlock_at(rwlock, SOURCE_LOCATOR)
+ ovs_rwlock_trywrlock_at(rwlock, OVS_SOURCE_LOCATOR)
void ovs_rwlock_rdlock_at(const struct ovs_rwlock *rwlock, const char *where)
OVS_ACQ_RDLOCK(rwlock);
#define ovs_rwlock_rdlock(rwlock) \
- ovs_rwlock_rdlock_at(rwlock, SOURCE_LOCATOR)
+ ovs_rwlock_rdlock_at(rwlock, OVS_SOURCE_LOCATOR)
int ovs_rwlock_tryrdlock_at(const struct ovs_rwlock *rwlock, const char *where)
OVS_TRY_RDLOCK(0, rwlock);
#define ovs_rwlock_tryrdlock(rwlock) \
- ovs_rwlock_tryrdlock_at(rwlock, SOURCE_LOCATOR)
+ ovs_rwlock_tryrdlock_at(rwlock, OVS_SOURCE_LOCATOR)
/* ovs_barrier functions analogous to pthread_barrier_*() functions. */
void ovs_barrier_init(struct ovs_barrier *, uint32_t count);
bool single_threaded(void);
void assert_single_threaded_at(const char *where);
-#define assert_single_threaded() assert_single_threaded_at(SOURCE_LOCATOR)
+#define assert_single_threaded() assert_single_threaded_at(OVS_SOURCE_LOCATOR)
#ifndef _WIN32
pid_t xfork_at(const char *where);
-#define xfork() xfork_at(SOURCE_LOCATOR)
+#define xfork() xfork_at(OVS_SOURCE_LOCATOR)
#endif
void forbid_forking(const char *reason);
* caller would be more useful in log output. See timer_wait_at() for an
* example. */
void poll_fd_wait_at(int fd, short int events, const char *where);
-#define poll_fd_wait(fd, events) poll_fd_wait_at(fd, events, SOURCE_LOCATOR)
+#define poll_fd_wait(fd, events) poll_fd_wait_at(fd, events, OVS_SOURCE_LOCATOR)
#ifdef _WIN32
-#define poll_wevent_wait(wevent) poll_wevent_wait_at(wevent, SOURCE_LOCATOR)
+#define poll_wevent_wait(wevent) poll_wevent_wait_at(wevent, OVS_SOURCE_LOCATOR)
#endif /* _WIN32 */
void poll_timer_wait_at(long long int msec, const char *where);
-#define poll_timer_wait(msec) poll_timer_wait_at(msec, SOURCE_LOCATOR)
+#define poll_timer_wait(msec) poll_timer_wait_at(msec, OVS_SOURCE_LOCATOR)
void poll_timer_wait_until_at(long long int msec, const char *where);
#define poll_timer_wait_until(msec) \
- poll_timer_wait_until_at(msec, SOURCE_LOCATOR)
+ poll_timer_wait_until_at(msec, OVS_SOURCE_LOCATOR)
void poll_immediate_wake_at(const char *where);
-#define poll_immediate_wake() poll_immediate_wake_at(SOURCE_LOCATOR)
+#define poll_immediate_wake() poll_immediate_wake_at(OVS_SOURCE_LOCATOR)
/* Wait until an event occurs. */
void poll_block(void);
uint64_t seq_read(const struct seq *);
void seq_wait_at(const struct seq *, uint64_t value, const char *where);
-#define seq_wait(seq, value) seq_wait_at(seq, value, SOURCE_LOCATOR)
+#define seq_wait(seq, value) seq_wait_at(seq, value, OVS_SOURCE_LOCATOR)
/* For poll_block() internal use. */
void seq_woke(void);
long long int timer_msecs_until_expired(const struct timer *);
void timer_wait_at(const struct timer *, const char *where);
-#define timer_wait(timer) timer_wait_at(timer, SOURCE_LOCATOR)
+#define timer_wait(timer) timer_wait_at(timer, OVS_SOURCE_LOCATOR)
/* Causes 'timer' to expire when 'duration' milliseconds have passed.
*
#ifndef NDEBUG
#define ovs_assert(CONDITION) \
if (!OVS_LIKELY(CONDITION)) { \
- ovs_assert_failure(SOURCE_LOCATOR, __func__, #CONDITION); \
+ ovs_assert_failure(OVS_SOURCE_LOCATOR, __func__, #CONDITION); \
}
#else
#define ovs_assert(CONDITION) ((void) (CONDITION))
#define OVS_NOT_REACHED() abort()
-/* Expands to a string that looks like "<file>:<line>", e.g. "tmp.c:10".
- *
- * See http://c-faq.com/ansi/stringize.html for an explanation of STRINGIZE and
- * STRINGIZE2. */
-#define SOURCE_LOCATOR __FILE__ ":" STRINGIZE(__LINE__)
-#define STRINGIZE(ARG) STRINGIZE2(ARG)
-#define STRINGIZE2(ARG) #ARG
-
/* Given a pointer-typed lvalue OBJECT, expands to a pointer type that may be
* assigned to OBJECT. */
#ifdef __GNUC__