tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: pthread_setname_np API is bad



On 03.08.2019 06:29, Matt Turner wrote:
> My recent commit [0] in Mesa spawned a discussion [1] about why
> pthread_setname_np()'s parameter 'void *args' is not 'const void *args'.
> 

I defer myself from evaluating this proposal, just adding few words:

> Looking in your CVS history, I see that pthread_setname_np() and friends
> were added in 2003 and claim to use an API compatible with Tru64 UNIX
> API.

I always treated the 3rd argument of pthread_setname_np(3) as a kind of
C-style pseudo TOP-type [1] or old-VAX-style va_list.

This allows to specify:

for (intptr_t i = 0; i < N; i++) {
  pthread_setname_np(thrd[i], "thread%" PRIdPTR, (void*)i);
}

In the old VAX style programming there is an option to pass a list of
arguments pointed with void* into var arg function and get it to work.

[1] https://en.wikipedia.org/wiki/Top_type


> Worse it's incompatible from that of FreeBSD, OpenBSD, and glibc in a
> useless way.

Just a remind that *_np stands for non-portable so it's not expected to
be compatible.

If there would be a change, I would prompt for replacing void* with ...
and decorating the function with printf-like attribute. With some sort
of luck we could do it now keeping existing software to build, but I
don't make any statements about ABI compat (except on probably VAX).

Attachment: signature.asc
Description: OpenPGP digital signature



Home | Main Index | Thread Index | Old Index