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 23:31:04 +0200
From: Jens Gustedt <jens.gustedt@...ia.fr>
To: musl@...ts.openwall.com
Subject: Re: [PATCH] unify the use of FUTEX_PRIVATE

Hello,

On Sat, 24 Jun 2017 19:51:27 +0200 Jens Gustedt <jens.gustedt@...ia.fr>
wrote:

> Am 24. Juni 2017 18:40:26 MESZ schrieb Szabolcs Nagy <nsz@...t70.net>:
> >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.

We could do something like

/* Shared and private flags for different control structures use the
same bit to favor optimization. */
/* for mutex, mutexattr and rwlock */
#define PSHARED FUTEX_PRIVATE
/* for sem */
#define PRIVATE FUTEX_PRIVATE

But then it could also be confusing that condattr uses bit 31 for the
same purpose, and pthread_cond_t uses a pointer type. This could lead
to

/* Some shared and private flags for different control structures use
the same bit to favor optimization. */
#define MTX_SHARED   FUTEX_PRIVATE
#define MATR_SHARED  FUTEX_PRIVATE
#define RWL_SHARED   FUTEX_PRIVATE
#define RWATR_SHARED 1
#define CND_SHARED   (void*)-1
#define CATR_SHARED  (1<<31)
/* Maybe replace by 1? */
#define SEM_PRIVATE  FUTEX_PRIVATE

To set the bit, in some places we use bit shift, in some
multiplication with 128 or 128U. To read the bit some do just masking
and then use the result as a "Boolean", some use bit shift and then
%2 to filter out the bit.

Probably I still overlooked some usages, and the naming could still be
improved.

I could try to produce a patch in that sense, if there is consensus to
go in that direction.

Thanks
Jens

-- 
:: INRIA Nancy Grand Est ::: Camus ::::::: ICube/ICPS :::
:: ::::::::::::::: office Strasbourg : +33 368854536   ::
:: :::::::::::::::::::::: gsm France : +33 651400183   ::
:: ::::::::::::::: gsm international : +49 15737185122 ::
:: http://icube-icps.unistra.fr/index.php/Jens_Gustedt ::

Content of type "application/pgp-signature" skipped

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.