Add qemu wrappers for pthread_attr_t handling.
Signed-off-by: Gautham R Shenoy <e...@in.ibm.com> --- qemu-thread.c | 34 ++++++++++++++++++++++++++++++++++ qemu-thread.h | 11 +++++++++++ 2 files changed, 45 insertions(+), 0 deletions(-) diff --git a/qemu-thread.c b/qemu-thread.c index 3923db7..524860c 100644 --- a/qemu-thread.c +++ b/qemu-thread.c @@ -142,6 +142,40 @@ void qemu_thread_create(QemuThread *thread, error_exit(err, __func__); } +void qemu_thread_create_attr(QemuThread *thread, QemuThreadAttr *attr1, + void *(*start_routine)(void*), + void *arg) +{ + int err; + + err = pthread_create(&thread->thread, &(attr1->attr), start_routine, + arg); + if (err) + error_exit(err, __func__); +} + +void qemu_thread_attr_init(QemuThreadAttr *attr1) +{ + int err; + + err = pthread_attr_init(&(attr1->attr)); + + if (err) { + error_exit(err, __func__); + } +} + +void qemu_thread_attr_setdetachstate(QemuThreadAttr *attr1, int detachstate) +{ + int err; + + err = pthread_attr_setdetachstate(&(attr1->attr), detachstate); + + if (err) { + error_exit(err, __func__); + } +} + void qemu_thread_signal(QemuThread *thread, int sig) { int err; diff --git a/qemu-thread.h b/qemu-thread.h index 5ef4a3a..361ef19 100644 --- a/qemu-thread.h +++ b/qemu-thread.h @@ -15,9 +15,14 @@ struct QemuThread { pthread_t thread; }; +struct QemuThreadAttr { + pthread_attr_t attr; +}; + typedef struct QemuMutex QemuMutex; typedef struct QemuCond QemuCond; typedef struct QemuThread QemuThread; +typedef struct QemuThreadAttr QemuThreadAttr; void qemu_mutex_init(QemuMutex *mutex); void qemu_mutex_lock(QemuMutex *mutex); @@ -34,7 +39,13 @@ int qemu_cond_timedwait(QemuCond *cond, QemuMutex *mutex, uint64_t msecs); void qemu_thread_create(QemuThread *thread, void *(*start_routine)(void*), void *arg); +void qemu_thread_create_attr(QemuThread *thread, QemuThreadAttr *attr1, + void *(*start_routine)(void*), + void *arg); void qemu_thread_signal(QemuThread *thread, int sig); void qemu_thread_self(QemuThread *thread); int qemu_thread_equal(QemuThread *thread1, QemuThread *thread2); + +void qemu_thread_attr_init(QemuThreadAttr *attr1); +void qemu_thread_attr_setdetachstate(QemuThreadAttr *attr1, int detachstate); #endif