}
+int pthread_detach(pthread_t th)
+{
+ ignored("pthread_detach");
+ return 0;
+}
+
+
/* ---------------------------------------------------
MUTEX ATTRIBUTES
------------------------------------------------ */
CANCELLATION
------------------------------------------------ */
+int pthread_setcancelstate(int state, int *oldstate)
+{
+ ignored("pthread_setcancelstate");
+ return 0;
+}
+
int pthread_setcanceltype(int type, int *oldtype)
{
ignored("pthread_setcanceltype");
return 0;
}
-
int pthread_cancel(pthread_t thread)
{
int res;
return res;
}
+void pthread_testcancel(void)
+{
+}
+
+/*-------------------*/
+static pthread_mutex_t massacre_mx = PTHREAD_MUTEX_INITIALIZER;
+
+void __pthread_kill_other_threads_np ( void )
+{
+ int i, res, me;
+ pthread_mutex_lock(&massacre_mx);
+ me = pthread_self();
+ for (i = 1; i < VG_N_THREADS; i++) {
+ if (i == me) continue;
+ res = pthread_cancel(i);
+ if (res == 0)
+ printf("----------- NUKED %d\n", i);
+ }
+ pthread_mutex_unlock(&massacre_mx);
+}
+
/* ---------------------------------------------------
THREAD-SPECIFICs
}
+/* ---------------------------------------------------
+ MISC
+ ------------------------------------------------ */
+
+int pthread_atfork ( void (*prepare)(void),
+ void (*parent)(void),
+ void (*child)(void) )
+{
+ ignored("pthread_atfork");
+ return 0;
+}
+
+
/* ---------------------------------------------------
LIBRARY-PRIVATE THREAD SPECIFIC STATE
------------------------------------------------ */
extern
-int __libc_open64(const char *pathname, int flags, ...);
-int open64(const char *pathname, int flags, ...)
+int __libc_open64(const char *pathname, int flags, mode_t mode);
+int open64(const char *pathname, int flags, mode_t mode)
{
- return __libc_open64(pathname, flags);
+ return __libc_open64(pathname, flags, mode);
}
extern
-int __libc_open(const char *pathname, int flags);
-int open(const char *pathname, int flags)
+int __libc_open(const char *pathname, int flags, mode_t mode);
+int open(const char *pathname, int flags, mode_t mode)
{
- return __libc_open(pathname, flags);
+ return __libc_open(pathname, flags, mode);
}
extern __typeof (name) aliasname __attribute__ ((alias (#name)));
strong_alias(pthread_mutex_lock, __pthread_mutex_lock)
+strong_alias(pthread_mutex_trylock, __pthread_mutex_trylock)
strong_alias(pthread_mutex_unlock, __pthread_mutex_unlock)
strong_alias(pthread_mutexattr_init, __pthread_mutexattr_init)
strong_alias(pthread_mutexattr_settype, __pthread_mutexattr_settype)
strong_alias(pthread_mutexattr_destroy, __pthread_mutexattr_destroy)
strong_alias(pthread_mutex_destroy, __pthread_mutex_destroy)
strong_alias(pthread_once, __pthread_once)
+strong_alias(pthread_atfork, __pthread_atfork)
+strong_alias(fork, __fork)
strong_alias(close, __close)
strong_alias(write, __write)
strong_alias(read, __read)
#undef _IO_flockfile
void _IO_flockfile ( _IO_FILE * file )
{
- // char* str = "_IO_flockfile\n";
- // write(2, str, strlen(str));
+ //char* str = "_IO_flockfile\n";
+ //write(2, str, strlen(str));
+ pthread_mutex_lock(file->_lock);
// barf("_IO_flockfile");
}
#undef _IO_funlockfile
void _IO_funlockfile ( _IO_FILE * file )
{
- // char* str = "_IO_funlockfile\n";
- // write(2, str, strlen(str));
+ //char* str = "_IO_funlockfile\n";
+ //write(2, str, strlen(str));
+ pthread_mutex_unlock(file->_lock);
// barf("_IO_funlockfile");
}
//void __connect ( void ) { unimp("__connect"); }
//void __errno_location ( void ) { unimp("__errno_location"); }
//void __fcntl ( void ) { unimp("__fcntl"); }
-void __fork ( void ) { unimp("__fork"); }
+//void __fork ( void ) { unimp("__fork"); }
//void __h_errno_location ( void ) { unimp("__h_errno_location"); }
void __libc_allocate_rtsig ( void ) { unimp("__libc_allocate_rtsig"); }
void __libc_current_sigrtmax ( void ) { unimp("__libc_current_sigrtmax"); }
//void __open ( void ) { unimp("__open"); }
//void __open64 ( void ) { unimp("__open64"); }
void __pread64 ( void ) { unimp("__pread64"); }
-void __pthread_atfork ( void ) { unimp("__pthread_atfork"); }
+//void __pthread_atfork ( void ) { unimp("__pthread_atfork"); }
//void __pthread_getspecific ( void ) { unimp("__pthread_getspecific"); }
//void __pthread_key_create ( void ) { unimp("__pthread_key_create"); }
-void __pthread_kill_other_threads_np ( void ) { unimp("__pthread_kill_other_threads_np"); }
+//void __pthread_kill_other_threads_np ( void ) { unimp("__pthread_kill_other_threads_np"); }
//void __pthread_mutex_destroy ( void ) { unimp("__pthread_mutex_destroy"); }
//void __pthread_mutex_init ( void ) { unimp("__pthread_mutex_init"); }
//void __pthread_mutex_lock ( void ) { unimp("__pthread_mutex_lock"); }
-void __pthread_mutex_trylock ( void ) { unimp("__pthread_mutex_trylock"); }
+//void __pthread_mutex_trylock ( void ) { unimp("__pthread_mutex_trylock"); }
//void __pthread_mutex_unlock ( void ) { unimp("__pthread_mutex_unlock"); }
//void __pthread_mutexattr_destroy ( void ) { unimp("__pthread_mutexattr_destroy"); }
//void __pthread_mutexattr_init ( void ) { unimp("__pthread_mutexattr_init"); }
void _pthread_cleanup_push ( void ) { unimp("_pthread_cleanup_push"); }
//void _pthread_cleanup_push_defer ( void ) { unimp("_pthread_cleanup_push_defer"); }
//void longjmp ( void ) { unimp("longjmp"); }
-void pthread_atfork ( void ) { unimp("pthread_atfork"); }
+//void pthread_atfork ( void ) { unimp("pthread_atfork"); }
//void pthread_attr_destroy ( void ) { unimp("pthread_attr_destroy"); }
void pthread_attr_getdetachstate ( void ) { unimp("pthread_attr_getdetachstate"); }
void pthread_attr_getinheritsched ( void ) { unimp("pthread_attr_getinheritsched"); }
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_detach ( void ) { unimp("pthread_detach"); }
+//void pthread_detach ( void ) { unimp("pthread_detach"); }
//void pthread_equal ( void ) { unimp("pthread_equal"); }
//void pthread_exit ( void ) { unimp("pthread_exit"); }
void pthread_getattr_np ( void ) { unimp("pthread_getattr_np"); }
void pthread_rwlockattr_setkind_np ( void ) { unimp("pthread_rwlockattr_setkind_np"); }
void pthread_rwlockattr_setpshared ( void ) { unimp("pthread_rwlockattr_setpshared"); }
//void pthread_self ( void ) { unimp("pthread_self"); }
-void pthread_setcancelstate ( void ) { unimp("pthread_setcancelstate"); }
+//void pthread_setcancelstate ( void ) { unimp("pthread_setcancelstate"); }
//void pthread_setcanceltype ( void ) { unimp("pthread_setcanceltype"); }
//void pthread_setschedparam ( void ) { unimp("pthread_setschedparam"); }
//void pthread_setspecific ( void ) { unimp("pthread_setspecific"); }
void pthread_sigmask ( void ) { unimp("pthread_sigmask"); }
-void pthread_testcancel ( void ) { unimp("pthread_testcancel"); }
+//void pthread_testcancel ( void ) { unimp("pthread_testcancel"); }
void raise ( void ) { unimp("raise"); }
void sem_close ( void ) { unimp("sem_close"); }
void sem_open ( void ) { unimp("sem_open"); }
}
+int pthread_detach(pthread_t th)
+{
+ ignored("pthread_detach");
+ return 0;
+}
+
+
/* ---------------------------------------------------
MUTEX ATTRIBUTES
------------------------------------------------ */
CANCELLATION
------------------------------------------------ */
+int pthread_setcancelstate(int state, int *oldstate)
+{
+ ignored("pthread_setcancelstate");
+ return 0;
+}
+
int pthread_setcanceltype(int type, int *oldtype)
{
ignored("pthread_setcanceltype");
return 0;
}
-
int pthread_cancel(pthread_t thread)
{
int res;
return res;
}
+void pthread_testcancel(void)
+{
+}
+
+/*-------------------*/
+static pthread_mutex_t massacre_mx = PTHREAD_MUTEX_INITIALIZER;
+
+void __pthread_kill_other_threads_np ( void )
+{
+ int i, res, me;
+ pthread_mutex_lock(&massacre_mx);
+ me = pthread_self();
+ for (i = 1; i < VG_N_THREADS; i++) {
+ if (i == me) continue;
+ res = pthread_cancel(i);
+ if (res == 0)
+ printf("----------- NUKED %d\n", i);
+ }
+ pthread_mutex_unlock(&massacre_mx);
+}
+
/* ---------------------------------------------------
THREAD-SPECIFICs
}
+/* ---------------------------------------------------
+ MISC
+ ------------------------------------------------ */
+
+int pthread_atfork ( void (*prepare)(void),
+ void (*parent)(void),
+ void (*child)(void) )
+{
+ ignored("pthread_atfork");
+ return 0;
+}
+
+
/* ---------------------------------------------------
LIBRARY-PRIVATE THREAD SPECIFIC STATE
------------------------------------------------ */
extern
-int __libc_open64(const char *pathname, int flags, ...);
-int open64(const char *pathname, int flags, ...)
+int __libc_open64(const char *pathname, int flags, mode_t mode);
+int open64(const char *pathname, int flags, mode_t mode)
{
- return __libc_open64(pathname, flags);
+ return __libc_open64(pathname, flags, mode);
}
extern
-int __libc_open(const char *pathname, int flags);
-int open(const char *pathname, int flags)
+int __libc_open(const char *pathname, int flags, mode_t mode);
+int open(const char *pathname, int flags, mode_t mode)
{
- return __libc_open(pathname, flags);
+ return __libc_open(pathname, flags, mode);
}
extern __typeof (name) aliasname __attribute__ ((alias (#name)));
strong_alias(pthread_mutex_lock, __pthread_mutex_lock)
+strong_alias(pthread_mutex_trylock, __pthread_mutex_trylock)
strong_alias(pthread_mutex_unlock, __pthread_mutex_unlock)
strong_alias(pthread_mutexattr_init, __pthread_mutexattr_init)
strong_alias(pthread_mutexattr_settype, __pthread_mutexattr_settype)
strong_alias(pthread_mutexattr_destroy, __pthread_mutexattr_destroy)
strong_alias(pthread_mutex_destroy, __pthread_mutex_destroy)
strong_alias(pthread_once, __pthread_once)
+strong_alias(pthread_atfork, __pthread_atfork)
+strong_alias(fork, __fork)
strong_alias(close, __close)
strong_alias(write, __write)
strong_alias(read, __read)
#undef _IO_flockfile
void _IO_flockfile ( _IO_FILE * file )
{
- // char* str = "_IO_flockfile\n";
- // write(2, str, strlen(str));
+ //char* str = "_IO_flockfile\n";
+ //write(2, str, strlen(str));
+ pthread_mutex_lock(file->_lock);
// barf("_IO_flockfile");
}
#undef _IO_funlockfile
void _IO_funlockfile ( _IO_FILE * file )
{
- // char* str = "_IO_funlockfile\n";
- // write(2, str, strlen(str));
+ //char* str = "_IO_funlockfile\n";
+ //write(2, str, strlen(str));
+ pthread_mutex_unlock(file->_lock);
// barf("_IO_funlockfile");
}
//void __connect ( void ) { unimp("__connect"); }
//void __errno_location ( void ) { unimp("__errno_location"); }
//void __fcntl ( void ) { unimp("__fcntl"); }
-void __fork ( void ) { unimp("__fork"); }
+//void __fork ( void ) { unimp("__fork"); }
//void __h_errno_location ( void ) { unimp("__h_errno_location"); }
void __libc_allocate_rtsig ( void ) { unimp("__libc_allocate_rtsig"); }
void __libc_current_sigrtmax ( void ) { unimp("__libc_current_sigrtmax"); }
//void __open ( void ) { unimp("__open"); }
//void __open64 ( void ) { unimp("__open64"); }
void __pread64 ( void ) { unimp("__pread64"); }
-void __pthread_atfork ( void ) { unimp("__pthread_atfork"); }
+//void __pthread_atfork ( void ) { unimp("__pthread_atfork"); }
//void __pthread_getspecific ( void ) { unimp("__pthread_getspecific"); }
//void __pthread_key_create ( void ) { unimp("__pthread_key_create"); }
-void __pthread_kill_other_threads_np ( void ) { unimp("__pthread_kill_other_threads_np"); }
+//void __pthread_kill_other_threads_np ( void ) { unimp("__pthread_kill_other_threads_np"); }
//void __pthread_mutex_destroy ( void ) { unimp("__pthread_mutex_destroy"); }
//void __pthread_mutex_init ( void ) { unimp("__pthread_mutex_init"); }
//void __pthread_mutex_lock ( void ) { unimp("__pthread_mutex_lock"); }
-void __pthread_mutex_trylock ( void ) { unimp("__pthread_mutex_trylock"); }
+//void __pthread_mutex_trylock ( void ) { unimp("__pthread_mutex_trylock"); }
//void __pthread_mutex_unlock ( void ) { unimp("__pthread_mutex_unlock"); }
//void __pthread_mutexattr_destroy ( void ) { unimp("__pthread_mutexattr_destroy"); }
//void __pthread_mutexattr_init ( void ) { unimp("__pthread_mutexattr_init"); }
void _pthread_cleanup_push ( void ) { unimp("_pthread_cleanup_push"); }
//void _pthread_cleanup_push_defer ( void ) { unimp("_pthread_cleanup_push_defer"); }
//void longjmp ( void ) { unimp("longjmp"); }
-void pthread_atfork ( void ) { unimp("pthread_atfork"); }
+//void pthread_atfork ( void ) { unimp("pthread_atfork"); }
//void pthread_attr_destroy ( void ) { unimp("pthread_attr_destroy"); }
void pthread_attr_getdetachstate ( void ) { unimp("pthread_attr_getdetachstate"); }
void pthread_attr_getinheritsched ( void ) { unimp("pthread_attr_getinheritsched"); }
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_detach ( void ) { unimp("pthread_detach"); }
+//void pthread_detach ( void ) { unimp("pthread_detach"); }
//void pthread_equal ( void ) { unimp("pthread_equal"); }
//void pthread_exit ( void ) { unimp("pthread_exit"); }
void pthread_getattr_np ( void ) { unimp("pthread_getattr_np"); }
void pthread_rwlockattr_setkind_np ( void ) { unimp("pthread_rwlockattr_setkind_np"); }
void pthread_rwlockattr_setpshared ( void ) { unimp("pthread_rwlockattr_setpshared"); }
//void pthread_self ( void ) { unimp("pthread_self"); }
-void pthread_setcancelstate ( void ) { unimp("pthread_setcancelstate"); }
+//void pthread_setcancelstate ( void ) { unimp("pthread_setcancelstate"); }
//void pthread_setcanceltype ( void ) { unimp("pthread_setcanceltype"); }
//void pthread_setschedparam ( void ) { unimp("pthread_setschedparam"); }
//void pthread_setspecific ( void ) { unimp("pthread_setspecific"); }
void pthread_sigmask ( void ) { unimp("pthread_sigmask"); }
-void pthread_testcancel ( void ) { unimp("pthread_testcancel"); }
+//void pthread_testcancel ( void ) { unimp("pthread_testcancel"); }
void raise ( void ) { unimp("raise"); }
void sem_close ( void ) { unimp("sem_close"); }
void sem_open ( void ) { unimp("sem_open"); }
/* Awaken any sleeping threads whose sleep has expired. */
for (tid = 1; tid < VG_N_THREADS; tid++)
- if (vg_threads[tid].status == VgTs_Sleeping)
- break;
+ if (vg_threads[tid].status == VgTs_Sleeping)
+ break;
/* Avoid pointless calls to VG_(read_millisecond_timer). */
if (tid < VG_N_THREADS) {
-------------------------------------------------------- */
static
-void do_pthread_cancel ( ThreadId tid_canceller,
+void do_pthread_cancel ( ThreadId tid,
pthread_t tid_cancellee )
{
Char msg_buf[100];
+
+ vg_assert(is_valid_tid(tid));
+ vg_assert(vg_threads[tid].status != VgTs_Empty);
+
+ if (!is_valid_tid(tid_cancellee)
+ || vg_threads[tid_cancellee].status == VgTs_Empty) {
+ vg_threads[tid].m_edx = ESRCH;
+ return;
+ }
+
/* We want make is appear that this thread has returned to
do_pthread_create_bogusRA with PTHREAD_CANCELED as the
return value. So: simple: put PTHREAD_CANCELED into %EAX
and &do_pthread_create_bogusRA into %EIP and keep going! */
if (VG_(clo_trace_sched)) {
- VG_(sprintf)(msg_buf, "cancelled by %d", tid_canceller);
+ VG_(sprintf)(msg_buf, "cancelled by %d", tid);
print_sched_event(tid_cancellee, msg_buf);
}
vg_threads[tid_cancellee].m_eax = (UInt)PTHREAD_CANCELED;
vg_threads[tid_cancellee].m_eip = (UInt)&VG_(pthreadreturn_bogusRA);
vg_threads[tid_cancellee].status = VgTs_Runnable;
+
+ /* We return with success (0). */
+ vg_threads[tid].m_edx = 0;
}
/* return 0 (success). */
mutex->__m_count++;
vg_threads[tid].m_edx = 0;
- VG_(printf)("!!!!!! tid %d, mx %p -> locked %d\n",
- tid, mutex, mutex->__m_count);
+ if (0)
+ VG_(printf)("!!!!!! tid %d, mx %p -> locked %d\n",
+ tid, mutex, mutex->__m_count);
return;
} else {
if (is_trylock)
}
+int pthread_detach(pthread_t th)
+{
+ ignored("pthread_detach");
+ return 0;
+}
+
+
/* ---------------------------------------------------
MUTEX ATTRIBUTES
------------------------------------------------ */
CANCELLATION
------------------------------------------------ */
+int pthread_setcancelstate(int state, int *oldstate)
+{
+ ignored("pthread_setcancelstate");
+ return 0;
+}
+
int pthread_setcanceltype(int type, int *oldtype)
{
ignored("pthread_setcanceltype");
return 0;
}
-
int pthread_cancel(pthread_t thread)
{
int res;
return res;
}
+void pthread_testcancel(void)
+{
+}
+
+/*-------------------*/
+static pthread_mutex_t massacre_mx = PTHREAD_MUTEX_INITIALIZER;
+
+void __pthread_kill_other_threads_np ( void )
+{
+ int i, res, me;
+ pthread_mutex_lock(&massacre_mx);
+ me = pthread_self();
+ for (i = 1; i < VG_N_THREADS; i++) {
+ if (i == me) continue;
+ res = pthread_cancel(i);
+ if (res == 0)
+ printf("----------- NUKED %d\n", i);
+ }
+ pthread_mutex_unlock(&massacre_mx);
+}
+
/* ---------------------------------------------------
THREAD-SPECIFICs
}
+/* ---------------------------------------------------
+ MISC
+ ------------------------------------------------ */
+
+int pthread_atfork ( void (*prepare)(void),
+ void (*parent)(void),
+ void (*child)(void) )
+{
+ ignored("pthread_atfork");
+ return 0;
+}
+
+
/* ---------------------------------------------------
LIBRARY-PRIVATE THREAD SPECIFIC STATE
------------------------------------------------ */
extern
-int __libc_open64(const char *pathname, int flags, ...);
-int open64(const char *pathname, int flags, ...)
+int __libc_open64(const char *pathname, int flags, mode_t mode);
+int open64(const char *pathname, int flags, mode_t mode)
{
- return __libc_open64(pathname, flags);
+ return __libc_open64(pathname, flags, mode);
}
extern
-int __libc_open(const char *pathname, int flags);
-int open(const char *pathname, int flags)
+int __libc_open(const char *pathname, int flags, mode_t mode);
+int open(const char *pathname, int flags, mode_t mode)
{
- return __libc_open(pathname, flags);
+ return __libc_open(pathname, flags, mode);
}
extern __typeof (name) aliasname __attribute__ ((alias (#name)));
strong_alias(pthread_mutex_lock, __pthread_mutex_lock)
+strong_alias(pthread_mutex_trylock, __pthread_mutex_trylock)
strong_alias(pthread_mutex_unlock, __pthread_mutex_unlock)
strong_alias(pthread_mutexattr_init, __pthread_mutexattr_init)
strong_alias(pthread_mutexattr_settype, __pthread_mutexattr_settype)
strong_alias(pthread_mutexattr_destroy, __pthread_mutexattr_destroy)
strong_alias(pthread_mutex_destroy, __pthread_mutex_destroy)
strong_alias(pthread_once, __pthread_once)
+strong_alias(pthread_atfork, __pthread_atfork)
+strong_alias(fork, __fork)
strong_alias(close, __close)
strong_alias(write, __write)
strong_alias(read, __read)
#undef _IO_flockfile
void _IO_flockfile ( _IO_FILE * file )
{
- // char* str = "_IO_flockfile\n";
- // write(2, str, strlen(str));
+ //char* str = "_IO_flockfile\n";
+ //write(2, str, strlen(str));
+ pthread_mutex_lock(file->_lock);
// barf("_IO_flockfile");
}
#undef _IO_funlockfile
void _IO_funlockfile ( _IO_FILE * file )
{
- // char* str = "_IO_funlockfile\n";
- // write(2, str, strlen(str));
+ //char* str = "_IO_funlockfile\n";
+ //write(2, str, strlen(str));
+ pthread_mutex_unlock(file->_lock);
// barf("_IO_funlockfile");
}
//void __connect ( void ) { unimp("__connect"); }
//void __errno_location ( void ) { unimp("__errno_location"); }
//void __fcntl ( void ) { unimp("__fcntl"); }
-void __fork ( void ) { unimp("__fork"); }
+//void __fork ( void ) { unimp("__fork"); }
//void __h_errno_location ( void ) { unimp("__h_errno_location"); }
void __libc_allocate_rtsig ( void ) { unimp("__libc_allocate_rtsig"); }
void __libc_current_sigrtmax ( void ) { unimp("__libc_current_sigrtmax"); }
//void __open ( void ) { unimp("__open"); }
//void __open64 ( void ) { unimp("__open64"); }
void __pread64 ( void ) { unimp("__pread64"); }
-void __pthread_atfork ( void ) { unimp("__pthread_atfork"); }
+//void __pthread_atfork ( void ) { unimp("__pthread_atfork"); }
//void __pthread_getspecific ( void ) { unimp("__pthread_getspecific"); }
//void __pthread_key_create ( void ) { unimp("__pthread_key_create"); }
-void __pthread_kill_other_threads_np ( void ) { unimp("__pthread_kill_other_threads_np"); }
+//void __pthread_kill_other_threads_np ( void ) { unimp("__pthread_kill_other_threads_np"); }
//void __pthread_mutex_destroy ( void ) { unimp("__pthread_mutex_destroy"); }
//void __pthread_mutex_init ( void ) { unimp("__pthread_mutex_init"); }
//void __pthread_mutex_lock ( void ) { unimp("__pthread_mutex_lock"); }
-void __pthread_mutex_trylock ( void ) { unimp("__pthread_mutex_trylock"); }
+//void __pthread_mutex_trylock ( void ) { unimp("__pthread_mutex_trylock"); }
//void __pthread_mutex_unlock ( void ) { unimp("__pthread_mutex_unlock"); }
//void __pthread_mutexattr_destroy ( void ) { unimp("__pthread_mutexattr_destroy"); }
//void __pthread_mutexattr_init ( void ) { unimp("__pthread_mutexattr_init"); }
void _pthread_cleanup_push ( void ) { unimp("_pthread_cleanup_push"); }
//void _pthread_cleanup_push_defer ( void ) { unimp("_pthread_cleanup_push_defer"); }
//void longjmp ( void ) { unimp("longjmp"); }
-void pthread_atfork ( void ) { unimp("pthread_atfork"); }
+//void pthread_atfork ( void ) { unimp("pthread_atfork"); }
//void pthread_attr_destroy ( void ) { unimp("pthread_attr_destroy"); }
void pthread_attr_getdetachstate ( void ) { unimp("pthread_attr_getdetachstate"); }
void pthread_attr_getinheritsched ( void ) { unimp("pthread_attr_getinheritsched"); }
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_detach ( void ) { unimp("pthread_detach"); }
+//void pthread_detach ( void ) { unimp("pthread_detach"); }
//void pthread_equal ( void ) { unimp("pthread_equal"); }
//void pthread_exit ( void ) { unimp("pthread_exit"); }
void pthread_getattr_np ( void ) { unimp("pthread_getattr_np"); }
void pthread_rwlockattr_setkind_np ( void ) { unimp("pthread_rwlockattr_setkind_np"); }
void pthread_rwlockattr_setpshared ( void ) { unimp("pthread_rwlockattr_setpshared"); }
//void pthread_self ( void ) { unimp("pthread_self"); }
-void pthread_setcancelstate ( void ) { unimp("pthread_setcancelstate"); }
+//void pthread_setcancelstate ( void ) { unimp("pthread_setcancelstate"); }
//void pthread_setcanceltype ( void ) { unimp("pthread_setcanceltype"); }
//void pthread_setschedparam ( void ) { unimp("pthread_setschedparam"); }
//void pthread_setspecific ( void ) { unimp("pthread_setspecific"); }
void pthread_sigmask ( void ) { unimp("pthread_sigmask"); }
-void pthread_testcancel ( void ) { unimp("pthread_testcancel"); }
+//void pthread_testcancel ( void ) { unimp("pthread_testcancel"); }
void raise ( void ) { unimp("raise"); }
void sem_close ( void ) { unimp("sem_close"); }
void sem_open ( void ) { unimp("sem_open"); }
/* Awaken any sleeping threads whose sleep has expired. */
for (tid = 1; tid < VG_N_THREADS; tid++)
- if (vg_threads[tid].status == VgTs_Sleeping)
- break;
+ if (vg_threads[tid].status == VgTs_Sleeping)
+ break;
/* Avoid pointless calls to VG_(read_millisecond_timer). */
if (tid < VG_N_THREADS) {
-------------------------------------------------------- */
static
-void do_pthread_cancel ( ThreadId tid_canceller,
+void do_pthread_cancel ( ThreadId tid,
pthread_t tid_cancellee )
{
Char msg_buf[100];
+
+ vg_assert(is_valid_tid(tid));
+ vg_assert(vg_threads[tid].status != VgTs_Empty);
+
+ if (!is_valid_tid(tid_cancellee)
+ || vg_threads[tid_cancellee].status == VgTs_Empty) {
+ vg_threads[tid].m_edx = ESRCH;
+ return;
+ }
+
/* We want make is appear that this thread has returned to
do_pthread_create_bogusRA with PTHREAD_CANCELED as the
return value. So: simple: put PTHREAD_CANCELED into %EAX
and &do_pthread_create_bogusRA into %EIP and keep going! */
if (VG_(clo_trace_sched)) {
- VG_(sprintf)(msg_buf, "cancelled by %d", tid_canceller);
+ VG_(sprintf)(msg_buf, "cancelled by %d", tid);
print_sched_event(tid_cancellee, msg_buf);
}
vg_threads[tid_cancellee].m_eax = (UInt)PTHREAD_CANCELED;
vg_threads[tid_cancellee].m_eip = (UInt)&VG_(pthreadreturn_bogusRA);
vg_threads[tid_cancellee].status = VgTs_Runnable;
+
+ /* We return with success (0). */
+ vg_threads[tid].m_edx = 0;
}
/* return 0 (success). */
mutex->__m_count++;
vg_threads[tid].m_edx = 0;
- VG_(printf)("!!!!!! tid %d, mx %p -> locked %d\n",
- tid, mutex, mutex->__m_count);
+ if (0)
+ VG_(printf)("!!!!!! tid %d, mx %p -> locked %d\n",
+ tid, mutex, mutex->__m_count);
return;
} else {
if (is_trylock)