prior to version 1.1.0, the difference between pthread_self (the
public function) and __pthread_self (the internal macro or inline
function) was that the former would lazily initialize the thread
pointer if it was not already initialized, whereas the latter would
crash in this case. since lazy initialization is no longer supported,
use of pthread_self no longer makes sense; it simply generates larger,
slower code.
locale_t uselocale(locale_t l)
{
locale_t uselocale(locale_t l)
{
- pthread_t self = pthread_self();
+ pthread_t self = __pthread_self();
locale_t old = self->locale;
if (l) self->locale = l;
return old;
locale_t old = self->locale;
if (l) self->locale = l;
return old;
int ftrylockfile(FILE *f)
{
int ftrylockfile(FILE *f)
{
- int tid = pthread_self()->tid;
+ int tid = __pthread_self()->tid;
if (f->lock == tid) {
if (f->lockcount == LONG_MAX)
return -1;
if (f->lock == tid) {
if (f->lockcount == LONG_MAX)
return -1;
void __testcancel()
{
if (!libc.has_thread_pointer) return;
void __testcancel()
{
if (!libc.has_thread_pointer) return;
- pthread_t self = pthread_self();
+ pthread_t self = __pthread_self();
if (self->cancel && !self->canceldisable)
__cancel();
}
if (self->cancel && !self->canceldisable)
__cancel();
}
/* Perform the futex requeue, waking one waiter unless we know
* that the calling thread holds the mutex. */
__syscall(SYS_futex, &c->_c_seq, FUTEX_REQUEUE,
/* Perform the futex requeue, waking one waiter unless we know
* that the calling thread holds the mutex. */
__syscall(SYS_futex, &c->_c_seq, FUTEX_REQUEUE,
- !m->_m_type || (m->_m_lock&INT_MAX)!=pthread_self()->tid,
+ !m->_m_type || (m->_m_lock&INT_MAX)!=__pthread_self()->tid,
INT_MAX, &m->_m_lock);
out:
INT_MAX, &m->_m_lock);
out:
struct cm cm = { .c=c, .m=m };
int r, e=0, seq;
struct cm cm = { .c=c, .m=m };
int r, e=0, seq;
- if (m->_m_type && (m->_m_lock&INT_MAX) != pthread_self()->tid)
+ if (m->_m_type && (m->_m_lock&INT_MAX) != __pthread_self()->tid)
return EPERM;
if (ts && ts->tv_nsec >= 1000000000UL)
return EPERM;
if (ts && ts->tv_nsec >= 1000000000UL)
_Noreturn void pthread_exit(void *result)
{
_Noreturn void pthread_exit(void *result)
{
- pthread_t self = pthread_self();
+ pthread_t self = __pthread_self();
sigset_t set;
self->result = result;
sigset_t set;
self->result = result;
void __do_cleanup_push(struct __ptcb *cb)
{
if (!libc.has_thread_pointer) return;
void __do_cleanup_push(struct __ptcb *cb)
{
if (!libc.has_thread_pointer) return;
- struct pthread *self = pthread_self();
+ struct pthread *self = __pthread_self();
cb->__next = self->cancelbuf;
self->cancelbuf = cb;
}
cb->__next = self->cancelbuf;
self->cancelbuf = cb;
}
int pthread_mutex_consistent(pthread_mutex_t *m)
{
if (m->_m_type < 8) return EINVAL;
int pthread_mutex_consistent(pthread_mutex_t *m)
{
if (m->_m_type < 8) return EINVAL;
- if ((m->_m_lock & 0x3fffffff) != pthread_self()->tid)
+ if ((m->_m_lock & 0x3fffffff) != __pthread_self()->tid)
return EPERM;
m->_m_type -= 8;
return 0;
return EPERM;
m->_m_type -= 8;
return 0;
while ((r=pthread_mutex_trylock(m)) == EBUSY) {
if (!(r=m->_m_lock) || (r&0x40000000)) continue;
if ((m->_m_type&3) == PTHREAD_MUTEX_ERRORCHECK
while ((r=pthread_mutex_trylock(m)) == EBUSY) {
if (!(r=m->_m_lock) || (r&0x40000000)) continue;
if ((m->_m_type&3) == PTHREAD_MUTEX_ERRORCHECK
- && (r&0x1fffffff) == pthread_self()->tid)
+ && (r&0x1fffffff) == __pthread_self()->tid)
return EDEADLK;
a_inc(&m->_m_waiters);
return EDEADLK;
a_inc(&m->_m_waiters);
if (m->_m_type == PTHREAD_MUTEX_NORMAL)
return a_cas(&m->_m_lock, 0, EBUSY) & EBUSY;
if (m->_m_type == PTHREAD_MUTEX_NORMAL)
return a_cas(&m->_m_lock, 0, EBUSY) & EBUSY;
+ self = __pthread_self();
tid = self->tid;
if (m->_m_type >= 4) {
tid = self->tid;
if (m->_m_type >= 4) {
if (m->_m_type != PTHREAD_MUTEX_NORMAL) {
if (!m->_m_lock)
return EPERM;
if (m->_m_type != PTHREAD_MUTEX_NORMAL) {
if (!m->_m_lock)
return EPERM;
+ self = __pthread_self();
if ((m->_m_lock&0x1fffffff) != self->tid)
return EPERM;
if ((m->_m_type&3) == PTHREAD_MUTEX_RECURSIVE && m->_m_count)
if ((m->_m_lock&0x1fffffff) != self->tid)
return EPERM;
if ((m->_m_type&3) == PTHREAD_MUTEX_RECURSIVE && m->_m_count)
int pthread_setcanceltype(int new, int *old)
{
int pthread_setcanceltype(int new, int *old)
{
- struct pthread *self = pthread_self();
+ struct pthread *self = __pthread_self();
if (new > 1U) return EINVAL;
if (old) *old = self->cancelasync;
self->cancelasync = new;
if (new > 1U) return EINVAL;
if (old) *old = self->cancelasync;
self->cancelasync = new;