From 9c4c45edc36b88bcb2956140965dbde9224ff967 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Tue, 6 Aug 2013 14:30:01 -0700 Subject: [PATCH] ovs-thread: New function xpthread_setspecific(). Signed-off-by: Ben Pfaff --- lib/ovs-thread.c | 1 + lib/ovs-thread.h | 5 +++-- lib/poll-loop.c | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/ovs-thread.c b/lib/ovs-thread.c index 4d64b9284..d0ec9ec6c 100644 --- a/lib/ovs-thread.c +++ b/lib/ovs-thread.c @@ -128,6 +128,7 @@ XPTHREAD_FUNC1(pthread_cond_broadcast, pthread_cond_t *); typedef void destructor_func(void *); XPTHREAD_FUNC2(pthread_key_create, pthread_key_t *, destructor_func *); +XPTHREAD_FUNC2(pthread_setspecific, pthread_key_t, const void *); void ovs_mutex_init(const struct ovs_mutex *l_, int type) diff --git a/lib/ovs-thread.h b/lib/ovs-thread.h index 9b8eeef37..0d54a43fb 100644 --- a/lib/ovs-thread.h +++ b/lib/ovs-thread.h @@ -153,6 +153,7 @@ void xpthread_cond_broadcast(pthread_cond_t *); #endif void xpthread_key_create(pthread_key_t *, void (*destructor)(void *)); +void xpthread_setspecific(pthread_key_t, const void *); void xpthread_create(pthread_t *, pthread_attr_t *, void *(*)(void *), void *); @@ -277,7 +278,7 @@ void xpthread_create(pthread_t *, pthread_attr_t *, void *(*)(void *), void *); \ value = xmalloc(sizeof *value); \ *value = initial_value; \ - pthread_setspecific(NAME##_key, value); \ + xpthread_setspecific(NAME##_key, value); \ } \ return value; \ } @@ -348,7 +349,7 @@ void xpthread_create(pthread_t *, pthread_attr_t *, void *(*)(void *), void *); NAME##_set_unsafe(TYPE value) \ { \ TYPE old_value = NAME##_get_unsafe(); \ - pthread_setspecific(NAME##_key, value); \ + xpthread_setspecific(NAME##_key, value); \ return old_value; \ } \ \ diff --git a/lib/poll-loop.c b/lib/poll-loop.c index 0f45d9835..5f9b9cdfd 100644 --- a/lib/poll-loop.c +++ b/lib/poll-loop.c @@ -275,7 +275,7 @@ poll_loop(void) loop = pthread_getspecific(key); if (!loop) { loop = xzalloc(sizeof *loop); - pthread_setspecific(key, loop); + xpthread_setspecific(key, loop); } return loop; } -- 2.43.0