From: Tom Hughes Date: Fri, 29 Oct 2004 18:22:38 +0000 (+0000) Subject: Implement pthread_condattr_setpshared and pthread_condattr_getpshared. X-Git-Tag: svn/VALGRIND_3_0_0~1427 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4afb4d75778c66313ff595420864763b0e451fc7;p=thirdparty%2Fvalgrind.git Implement pthread_condattr_setpshared and pthread_condattr_getpshared. BUG: 92264 git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2877 --- diff --git a/coregrind/vg_libpthread.c b/coregrind/vg_libpthread.c index db6a726b80..bf6d31ead4 100644 --- a/coregrind/vg_libpthread.c +++ b/coregrind/vg_libpthread.c @@ -138,6 +138,11 @@ typedef struct int __vg_mutexkind; } vg_pthread_mutexattr_t; +typedef struct +{ + int __vg_pshared; +} vg_pthread_condattr_t; + typedef struct _vg_pthread_rwlock_t { struct _vg_pthread_fastlock __vg_rw_lock; /* Lock to guarantee mutual exclusion */ @@ -1068,7 +1073,7 @@ pthread_create (pthread_t *__restrict __thredd, info->arg = __arg; sigprocmask(SIG_SETMASK, NULL, &info->sigmask); - if (__vg_attr) { + if (__attr) { si.base = (Addr)__vg_attr->__vg_stackaddr; si.size = __vg_attr->__vg_stacksize; si.guardsize = __vg_attr->__vg_guardsize; @@ -1341,6 +1346,10 @@ int __pthread_mutex_destroy(pthread_mutex_t *mutex) int pthread_condattr_init(pthread_condattr_t *attr) { + vg_pthread_condattr_t* vg_attr; + CONVERT(condattr, attr, vg_attr); + + vg_attr->__vg_pshared = 0; return 0; } @@ -1348,6 +1357,32 @@ int pthread_condattr_destroy(pthread_condattr_t *attr) { return 0; } + +int pthread_condattr_setpshared(pthread_condattr_t *attr, int pshared) +{ + static int moans = N_MOANS; + vg_pthread_condattr_t* vg_attr; + CONVERT(condattr, attr, vg_attr); + + if (pshared != PTHREAD_PROCESS_PRIVATE && + pshared != PTHREAD_PROCESS_SHARED) + return EINVAL; + + if (pshared == PTHREAD_PROCESS_SHARED && moans-- > 0) + kludged("pthread_setschedparam", "(process shared condition variables not supported)"); + + vg_attr->__vg_pshared = pshared; + return 0; +} + +int pthread_condattr_getpshared (const pthread_condattr_t *attr, int *pshared) +{ + vg_pthread_condattr_t* vg_attr; + CONVERT(condattr, attr, vg_attr); + + *pshared = vg_attr->__vg_pshared; + return 0; +} int pthread_cond_init( pthread_cond_t *cond, const pthread_condattr_t *cond_attr) diff --git a/coregrind/vg_libpthread_unimp.c b/coregrind/vg_libpthread_unimp.c index f40c57d9cf..c39a08bed3 100644 --- a/coregrind/vg_libpthread_unimp.c +++ b/coregrind/vg_libpthread_unimp.c @@ -119,9 +119,9 @@ void pthread_barrierattr_setpshared ( void ) { unimp("pthread_barrierattr_setps //void pthread_cond_timedwait ( void ) { unimp("pthread_cond_timedwait"); } //void pthread_cond_wait ( void ) { unimp("pthread_cond_wait"); } //void pthread_condattr_destroy ( void ) { unimp("pthread_condattr_destroy"); } -void pthread_condattr_getpshared ( void ) { unimp("pthread_condattr_getpshared"); } +//void pthread_condattr_getpshared ( void ) { unimp("pthread_condattr_getpshared"); } //void pthread_condattr_init ( void ) { unimp("pthread_condattr_init"); } -void pthread_condattr_setpshared ( void ) { unimp("pthread_condattr_setpshared"); } +//void pthread_condattr_setpshared ( void ) { unimp("pthread_condattr_setpshared"); } //void pthread_detach ( void ) { unimp("pthread_detach"); } //void pthread_equal ( void ) { unimp("pthread_equal"); } //void pthread_exit ( void ) { unimp("pthread_exit"); }