Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Fri, 25 Jul 2014 12:40:57 +0200
From: Szabolcs Nagy <>
To: Jens Gustedt <>
Subject: Re: C11 threads

* Jens Gustedt <> [2014-07-25 12:00:37 +0200]:
>  after I have seen that gcc since 4.9 has a working implementation of
> atomics, I convinced myself to implement C11 threads within musl.

the conclusion about threads.h was that it should be
abi compatible with glibc so we are waiting for them

so i think you should coordinate with libc-alpha too

> Choices :
>  - all types are just the corresponding POSIX types

if glibc does the same then it's ok

> Issues :
>  - a lot of C11 are just weak symbols. to avoid polluting the link
>    space of a C11 application, I had to transform a lot of POSIX
>    function symbols into weak symbols, too.

i think this not ok: posix usually requires inequal
function pointers for all public functions

>  - the include file threads.h includes pthread.h, so the namespace of
>    the C11 implementation is poluted with the pthreads stuff

i think this is not ok in the final version

>  - pthread_create and thrd_create are still too tightly linked
>    together. It would be good to split the corresponding file in two,
>    but this would make maintenance a bit more difficult.
>  - there are still some symbols missing, for some of the functions
>    that I implemented as macro. work for a winter day

i assume you just have to add a ptototype before the macro
definition and provide a trivial wrapper implementation

>  - I don't have much tests for all of this

> /* Don't create just additional symbols for the simple reason that the
>    return type of the POSIX and C11 functions are different. */
> int __pthread_once(once_flag *, void (*)(void));
> // void call_once(once_flag *flag, void (*func)(void));
> #define _call_once(FL, FU) (void)__pthread_once((FL), (FU))
> #define call_once _call_once

the additional symbols are necessary

and _[a-z] is not reserved for arbitrary usage for
the implementation (only for file scope identifiers)

> /* Best of all worlds, these are just weak aliases */
> int cnd_broadcast(cnd_t *);                   // pthread_cond_broadcast

posix is not yet aligned with c11, but i think they will
require inequal function pointers for these functions

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.