diff options
Diffstat (limited to 'vendor/modernc.org/libc/pthread.go')
-rw-r--r-- | vendor/modernc.org/libc/pthread.go | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/vendor/modernc.org/libc/pthread.go b/vendor/modernc.org/libc/pthread.go index 528b83f9c..f47156a80 100644 --- a/vendor/modernc.org/libc/pthread.go +++ b/vendor/modernc.org/libc/pthread.go @@ -83,10 +83,16 @@ func (t *TLS) FreeAlloca() func() { } func Xalloca(tls *TLS, size size_t) uintptr { + if __ccgo_strace { + trc("tls=%v size=%v, (%v:)", tls, size, origin(2)) + } return tls.alloca(size) } func X__builtin_alloca(tls *TLS, size size_t) uintptr { + if __ccgo_strace { + trc("tls=%v size=%v, (%v:)", tls, size, origin(2)) + } return Xalloca(tls, size) } @@ -126,11 +132,17 @@ func (d *pthreadData) close(t *TLS) { // int pthread_attr_destroy(pthread_attr_t *attr); func Xpthread_attr_destroy(t *TLS, pAttr uintptr) int32 { + if __ccgo_strace { + trc("t=%v pAttr=%v, (%v:)", t, pAttr, origin(2)) + } return 0 } // int pthread_attr_setscope(pthread_attr_t *attr, int contentionscope); func Xpthread_attr_setscope(t *TLS, pAttr uintptr, contentionScope int32) int32 { + if __ccgo_strace { + trc("t=%v pAttr=%v contentionScope=%v, (%v:)", t, pAttr, contentionScope, origin(2)) + } switch contentionScope { case pthread.PTHREAD_SCOPE_SYSTEM: return 0 @@ -141,6 +153,9 @@ func Xpthread_attr_setscope(t *TLS, pAttr uintptr, contentionScope int32) int32 // int pthread_attr_setstacksize(pthread_attr_t *attr, size_t stacksize); func Xpthread_attr_setstacksize(t *TLS, attr uintptr, stackSize types.Size_t) int32 { + if __ccgo_strace { + trc("t=%v attr=%v stackSize=%v, (%v:)", t, attr, stackSize, origin(2)) + } panic(todo("")) } @@ -190,6 +205,9 @@ func (c *cond) signal(all bool) int32 { // // int pthread_cond_init(pthread_cond_t *restrict cond, const pthread_condattr_t *restrict attr); func Xpthread_cond_init(t *TLS, pCond, pAttr uintptr) int32 { + if __ccgo_strace { + trc("t=%v pAttr=%v, (%v:)", t, pAttr, origin(2)) + } if pCond == 0 { return errno.EINVAL } @@ -208,6 +226,9 @@ func Xpthread_cond_init(t *TLS, pCond, pAttr uintptr) int32 { // int pthread_cond_destroy(pthread_cond_t *cond); func Xpthread_cond_destroy(t *TLS, pCond uintptr) int32 { + if __ccgo_strace { + trc("t=%v pCond=%v, (%v:)", t, pCond, origin(2)) + } if pCond == 0 { return errno.EINVAL } @@ -235,11 +256,17 @@ func Xpthread_cond_destroy(t *TLS, pCond uintptr) int32 { // int pthread_cond_signal(pthread_cond_t *cond); func Xpthread_cond_signal(t *TLS, pCond uintptr) int32 { + if __ccgo_strace { + trc("t=%v pCond=%v, (%v:)", t, pCond, origin(2)) + } return condSignal(pCond, false) } // int pthread_cond_broadcast(pthread_cond_t *cond); func Xpthread_cond_broadcast(t *TLS, pCond uintptr) int32 { + if __ccgo_strace { + trc("t=%v pCond=%v, (%v:)", t, pCond, origin(2)) + } return condSignal(pCond, true) } @@ -257,6 +284,9 @@ func condSignal(pCond uintptr, all bool) int32 { // int pthread_cond_wait(pthread_cond_t *restrict cond, pthread_mutex_t *restrict mutex); func Xpthread_cond_wait(t *TLS, pCond, pMutex uintptr) int32 { + if __ccgo_strace { + trc("t=%v pMutex=%v, (%v:)", t, pMutex, origin(2)) + } if pCond == 0 { return errno.EINVAL } @@ -286,6 +316,9 @@ func Xpthread_cond_wait(t *TLS, pCond, pMutex uintptr) int32 { // int pthread_cond_timedwait(pthread_cond_t *restrict cond, pthread_mutex_t *restrict mutex, const struct timespec *restrict abstime); func Xpthread_cond_timedwait(t *TLS, pCond, pMutex, pAbsTime uintptr) int32 { + if __ccgo_strace { + trc("t=%v pAbsTime=%v, (%v:)", t, pAbsTime, origin(2)) + } if pCond == 0 { return errno.EINVAL } @@ -457,6 +490,9 @@ func (m *mutex) unlock() int32 { // int pthread_mutex_destroy(pthread_mutex_t *mutex); func Xpthread_mutex_destroy(t *TLS, pMutex uintptr) int32 { + if __ccgo_strace { + trc("t=%v pMutex=%v, (%v:)", t, pMutex, origin(2)) + } mutexesMu.Lock() defer mutexesMu.Unlock() @@ -467,6 +503,9 @@ func Xpthread_mutex_destroy(t *TLS, pMutex uintptr) int32 { // int pthread_mutex_lock(pthread_mutex_t *mutex); func Xpthread_mutex_lock(t *TLS, pMutex uintptr) int32 { + if __ccgo_strace { + trc("t=%v pMutex=%v, (%v:)", t, pMutex, origin(2)) + } mutexesMu.Lock() mu := mutexes[pMutex] if mu == nil { // static initialized mutexes are valid @@ -479,6 +518,9 @@ func Xpthread_mutex_lock(t *TLS, pMutex uintptr) int32 { // int pthread_mutex_trylock(pthread_mutex_t *mutex); func Xpthread_mutex_trylock(t *TLS, pMutex uintptr) int32 { + if __ccgo_strace { + trc("t=%v pMutex=%v, (%v:)", t, pMutex, origin(2)) + } mutexesMu.Lock() mu := mutexes[pMutex] if mu == nil { // static initialized mutexes are valid @@ -491,6 +533,9 @@ func Xpthread_mutex_trylock(t *TLS, pMutex uintptr) int32 { // int pthread_mutex_unlock(pthread_mutex_t *mutex); func Xpthread_mutex_unlock(t *TLS, pMutex uintptr) int32 { + if __ccgo_strace { + trc("t=%v pMutex=%v, (%v:)", t, pMutex, origin(2)) + } mutexesMu.Lock() defer mutexesMu.Unlock() @@ -515,6 +560,9 @@ func Xpthread_key_create(t *TLS, pKey, destructor uintptr) int32 { // int pthread_key_delete(pthread_key_t key); func Xpthread_key_delete(t *TLS, key pthread.Pthread_key_t) int32 { + if __ccgo_strace { + trc("t=%v key=%v, (%v:)", t, key, origin(2)) + } if _, ok := t.kv[key]; ok { delete(t.kv, key) return 0 @@ -526,11 +574,17 @@ func Xpthread_key_delete(t *TLS, key pthread.Pthread_key_t) int32 { // void *pthread_getspecific(pthread_key_t key); func Xpthread_getspecific(t *TLS, key pthread.Pthread_key_t) uintptr { + if __ccgo_strace { + trc("t=%v key=%v, (%v:)", t, key, origin(2)) + } return t.kv[key] } // int pthread_setspecific(pthread_key_t key, const void *value); func Xpthread_setspecific(t *TLS, key pthread.Pthread_key_t, value uintptr) int32 { + if __ccgo_strace { + trc("t=%v key=%v value=%v, (%v:)", t, key, value, origin(2)) + } if t.kv == nil { t.kv = map[pthread.Pthread_key_t]uintptr{} } @@ -540,6 +594,9 @@ func Xpthread_setspecific(t *TLS, key pthread.Pthread_key_t, value uintptr) int3 // int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine) (void *), void *arg); func Xpthread_create(t *TLS, pThread, pAttr, startRoutine, arg uintptr) int32 { + if __ccgo_strace { + trc("t=%v arg=%v, (%v:)", t, arg, origin(2)) + } fn := (*struct { f func(*TLS, uintptr) uintptr })(unsafe.Pointer(&struct{ uintptr }{startRoutine})).f @@ -556,6 +613,9 @@ func Xpthread_create(t *TLS, pThread, pAttr, startRoutine, arg uintptr) int32 { // int pthread_detach(pthread_t thread); func Xpthread_detach(t *TLS, thread pthread.Pthread_t) int32 { + if __ccgo_strace { + trc("t=%v thread=%v, (%v:)", t, thread, origin(2)) + } threadsMu.Lock() threads[int32(thread)].detached = true threadsMu.Unlock() @@ -564,11 +624,17 @@ func Xpthread_detach(t *TLS, thread pthread.Pthread_t) int32 { // int pthread_equal(pthread_t t1, pthread_t t2); func Xpthread_equal(t *TLS, t1, t2 pthread.Pthread_t) int32 { + if __ccgo_strace { + trc("t=%v t2=%v, (%v:)", t, t2, origin(2)) + } return Bool32(t1 == t2) } // void pthread_exit(void *value_ptr); func Xpthread_exit(t *TLS, value uintptr) { + if __ccgo_strace { + trc("t=%v value=%v, (%v:)", t, value, origin(2)) + } t.retVal = value // At thread exit, if a key value has a non-NULL destructor pointer, and the @@ -605,6 +671,9 @@ func Xpthread_exit(t *TLS, value uintptr) { // int pthread_join(pthread_t thread, void **value_ptr); func Xpthread_join(t *TLS, thread pthread.Pthread_t, pValue uintptr) int32 { + if __ccgo_strace { + trc("t=%v thread=%v pValue=%v, (%v:)", t, thread, pValue, origin(2)) + } threadsMu.Lock() tls := threads[int32(thread)] delete(threads, int32(thread)) @@ -618,5 +687,8 @@ func Xpthread_join(t *TLS, thread pthread.Pthread_t, pValue uintptr) int32 { // pthread_t pthread_self(void); func Xpthread_self(t *TLS) pthread.Pthread_t { + if __ccgo_strace { + trc("t=%v, (%v:)", t, origin(2)) + } return pthread.Pthread_t(t.ID) } |