Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Sat, 24 Jun 2017 19:51:27 +0200
From: Jens Gustedt <jens.gustedt@...ia.fr>
To: musl@...ts.openwall.com
Subject: Re: [PATCH] unify the use of FUTEX_PRIVATE

Am 24. Juni 2017 18:40:26 MESZ schrieb Szabolcs Nagy <nsz@...t70.net>:
>* Jens Gustedt <Jens.Gustedt@...ia.fr> [2017-06-24 10:18:05 +0200]:
>> The flag 1<<7 is used in several places for different purposes that
>are
>> not always easy to distinguish. Mark those usages that correspond to
>the
>> flag that is used by the kernel for futexes.
>> ---
>>  src/internal/pthread_impl.h         | 2 +-
>>  src/thread/__timedwait.c            | 2 +-
>>  src/thread/pthread_barrier_wait.c   | 2 +-
>>  src/thread/pthread_cond_timedwait.c | 2 +-
>>  4 files changed, 4 insertions(+), 4 deletions(-)
>> 
>
>i see further use of 128
>
>src/thread/pthread_attr_get.c:  *pshared = a->__attr / 128U % 2;
>src/thread/pthread_cond_timedwait.c:           
>unlock_requeue(&node.prev->barrier, &m->_m_lock, m->_m_type & 128);
>src/thread/pthread_create.c:            int priv = (m->_m_type & 128) ^
>128;
>src/thread/pthread_mutex_timedlock.c:   int r, t, priv = (m->_m_type &
>128) ^ 128;
>src/thread/pthread_mutex_trylock.c:     if (m->_m_type & 128) {
>src/thread/pthread_mutex_unlock.c:      int priv = (m->_m_type & 128) ^
>128;
>src/thread/pthread_mutexattr_setpshared.c:      a->__attr &= ~128U;
>src/thread/pthread_rwlock_init.c:       if (a) rw->_rw_shared =
>a->__attr[0]*128;
>src/thread/pthread_rwlock_timedrdlock.c:                r =
>__timedwait(&rw->_rw_lock, t, CLOCK_REALTIME, at, rw->_rw_shared^128);
>src/thread/pthread_rwlock_timedwrlock.c:                r =
>__timedwait(&rw->_rw_lock, t, CLOCK_REALTIME, at, rw->_rw_shared^128);
>src/thread/pthread_rwlock_unlock.c:     int val, cnt, waiters, new,
>priv = rw->_rw_shared^128;
>src/thread/sem_init.c:  sem->__val[2] = pshared ? 0 : 128;
>
>i think some of these are the same flag

I don't think so. 
For mutexes the sense is "shared" so just the opposite meaning, and for rwlock,  too, it seems. 
For sem it is just a screwed Boolean..

I would merely tend to have different names for them, but that's a bit invasive.

Jens 


-- 
Jens Gustedt - INRIA & ICube, Strasbourg, France 

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.