ovs-thread: New function xpthread_setspecific().
authorBen Pfaff <blp@nicira.com>
Tue, 6 Aug 2013 21:30:01 +0000 (14:30 -0700)
committerBen Pfaff <blp@nicira.com>
Thu, 8 Aug 2013 20:18:10 +0000 (13:18 -0700)
Signed-off-by: Ben Pfaff <blp@nicira.com>
lib/ovs-thread.c
lib/ovs-thread.h
lib/poll-loop.c

index 4d64b92..d0ec9ec 100644 (file)
@@ -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)
index 9b8eeef..0d54a43 100644 (file)
@@ -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 *);
 \f
@@ -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;                               \
     }                                                   \
                                                         \
index 0f45d98..5f9b9cd 100644 (file)
@@ -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;
 }