Skip to content

Commit

Permalink
lib: Expose SOURCE_LOCATOR as OVS_SOURCE_LOACATOR
Browse files Browse the repository at this point in the history
Required to expose headers which depend on SOURCE_LOCATOR

Signed-off-by: Thomas Graf <[email protected]>
Acked-by: Ben Pfaff <[email protected]>
  • Loading branch information
Thomas Graf committed Dec 15, 2014
1 parent cab5044 commit 8f3676c
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 31 deletions.
8 changes: 8 additions & 0 deletions include/openvswitch/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ void ovs_set_program_name__(const char *name, const char *version,
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
Expand Down
4 changes: 2 additions & 2 deletions lib/backtrace.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@
* ??: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

Expand Down
8 changes: 4 additions & 4 deletions lib/hmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,20 +80,20 @@ static inline bool hmap_is_empty(const struct hmap *);

/* 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);
Expand Down
2 changes: 1 addition & 1 deletion lib/latch.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ void latch_set(struct latch *);

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 */
16 changes: 8 additions & 8 deletions lib/ovs-thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ void ovs_mutex_unlock(const struct ovs_mutex *mutex) OVS_RELEASES(mutex);
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 *);

Expand Down Expand Up @@ -130,22 +130,22 @@ void xpthread_rwlockattr_setkind_np(pthread_rwlockattr_t *, int kind);
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);
Expand Down Expand Up @@ -620,11 +620,11 @@ size_t ovs_thread_stats_next_bucket(const struct ovsthread_stats *, size_t);
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);
Expand Down
10 changes: 5 additions & 5 deletions lib/poll-loop.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,21 +51,21 @@ extern "C" {
* 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);
Expand Down
2 changes: 1 addition & 1 deletion lib/seq.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ void seq_change(struct seq *);
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);
Expand Down
2 changes: 1 addition & 1 deletion lib/timer.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ struct timer {

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.
*
Expand Down
10 changes: 1 addition & 9 deletions lib/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
#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))
Expand Down Expand Up @@ -175,14 +175,6 @@ ovs_prefetch_range(const void *start, size_t size)

#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__
Expand Down

0 comments on commit 8f3676c

Please sign in to comment.