mailing list of musl libc
 help / color / mirror / code / Atom feed
* Feature request: stdatomic.h and threads.h
@ 2013-11-21 10:31 Daniel Cegiełka
  2013-11-21 14:16 ` Szabolcs Nagy
  2013-11-21 16:42 ` Rich Felker
  0 siblings, 2 replies; 7+ messages in thread
From: Daniel Cegiełka @ 2013-11-21 10:31 UTC (permalink / raw)
  To: musl

Hi,

http://www.openwall.com/lists/musl/2013/06/29/17

Is there a plan to add support for stdatomic.h and threads.h?

Daniel


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Feature request: stdatomic.h and threads.h
  2013-11-21 10:31 Feature request: stdatomic.h and threads.h Daniel Cegiełka
@ 2013-11-21 14:16 ` Szabolcs Nagy
  2013-11-21 14:44   ` Jens Gustedt
  2013-11-21 16:42 ` Rich Felker
  1 sibling, 1 reply; 7+ messages in thread
From: Szabolcs Nagy @ 2013-11-21 14:16 UTC (permalink / raw)
  To: musl

* Daniel Cegie?ka <daniel.cegielka@gmail.com> [2013-11-21 11:31:35 +0100]:
> Is there a plan to add support for stdatomic.h and threads.h?

how would that work?
there is still no c11 atomic support in gcc

(there is an experimental c11 atomic branch with a gcc
provided stdatomic.h which uses some gcc extensions,
but there are still compiler issues eg there is no
solution for _Atomic float yet because x+=0.1 requires
fenv manipulation without libc support and that means
new asm for all archs, meanwhile wg14 and wg21 are still
busy filling the holes in the specs..)


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Feature request: stdatomic.h and threads.h
  2013-11-21 14:16 ` Szabolcs Nagy
@ 2013-11-21 14:44   ` Jens Gustedt
  2013-11-21 16:16     ` Daniel Cegiełka
  0 siblings, 1 reply; 7+ messages in thread
From: Jens Gustedt @ 2013-11-21 14:44 UTC (permalink / raw)
  To: musl

[-- Attachment #1: Type: text/plain, Size: 2228 bytes --]

Hi,

Am Donnerstag, den 21.11.2013, 15:16 +0100 schrieb Szabolcs Nagy:
> * Daniel Cegie?ka <daniel.cegielka@gmail.com> [2013-11-21 11:31:35 +0100]:
> > Is there a plan to add support for stdatomic.h and threads.h?
> 
> how would that work?
> there is still no c11 atomic support in gcc
> (there is an experimental c11 atomic branch with a gcc
> provided stdatomic.h which uses some gcc extensions,
> but there are still compiler issues eg there is no
> solution for _Atomic float yet because x+=0.1 requires
> fenv manipulation without libc support and that means
> new asm for all archs,

As far as I understood this will be merged in the next gcc version

> meanwhile wg14 and wg21 are still busy filling the holes in the
> specs..)

I haven't seen much about atomics discussed there.

For all that is integer type atomics at least the support in gcc is
sufficient to implement everything that is function call based (so not
the operations like += etc).

In P99 I have a shallow wrapper on top of the __sync_ builtins that
implements all type generic macros in atomic.h. It works fine for
everyday's use and efficiently produces optimal assembler, AFAIKS.

Restriction besides the operations mentioned above are

 -  variable declaration. Out of the two forms

    _Atomic int toto;
    _Atomic(int) toto;

    I only support the later (as a macro) if the compiler doesn't
    implement the first.

 - the different modes of memory consistency are not supported and
   always resolve to the strongest possible consistency

So yes a good deal of the *library* support is possible directly, even
with oldish versions of gcc, and can be implemented conforming to the
specs.

Also, I discovered recently that icc now has full support for
atomic.h, so definitively this is something that will see increased
use in a relatively near future.

Jens


-- 
:: INRIA Nancy Grand Est :: http://www.loria.fr/~gustedt/   ::
:: AlGorille ::::::::::::::: office Nancy : +33 383593090   ::
:: ICube :::::::::::::: office Strasbourg : +33 368854536   ::
:: ::::::::::::::::::::::::::: gsm France : +33 651400183   ::
:: :::::::::::::::::::: gsm international : +49 15737185122 ::



[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Feature request: stdatomic.h and threads.h
  2013-11-21 14:44   ` Jens Gustedt
@ 2013-11-21 16:16     ` Daniel Cegiełka
  0 siblings, 0 replies; 7+ messages in thread
From: Daniel Cegiełka @ 2013-11-21 16:16 UTC (permalink / raw)
  To: musl

Jens, I know your P99 :) I even have to mention it, but you were faster.

I was convinced that the work on this are much more advanced, but it
seems that we have to wait for gcc-4.9:

http://gcc.gnu.org/ml/gcc-patches/2013-11/msg00493.html


2013/11/21 Jens Gustedt <jens.gustedt@inria.fr>:

> Also, I discovered recently that icc now has full support for
> atomic.h, so definitively this is something that will see increased
> use in a relatively near future.
>
> Jens

btw. I changed glibc to musl libc in icc... using symlink or
permanently with hex editor.. +small patches :) It works very well. I
even built a system base in this way (but compiled code is a bit
larger compared to gcc).

thx,
Daniel


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Feature request: stdatomic.h and threads.h
  2013-11-21 10:31 Feature request: stdatomic.h and threads.h Daniel Cegiełka
  2013-11-21 14:16 ` Szabolcs Nagy
@ 2013-11-21 16:42 ` Rich Felker
  2013-11-21 17:19   ` Daniel Cegiełka
  2013-11-24 11:52   ` Daniel Cegiełka
  1 sibling, 2 replies; 7+ messages in thread
From: Rich Felker @ 2013-11-21 16:42 UTC (permalink / raw)
  To: musl

On Thu, Nov 21, 2013 at 11:31:35AM +0100, Daniel Cegiełka wrote:
> Hi,
> 
> http://www.openwall.com/lists/musl/2013/06/29/17
> 
> Is there a plan to add support for stdatomic.h and threads.h?

Yes, but not before 1.0. stdatomic.h is probably not hard if you
assume GCC __sync_* builtins (or it could be written in an
arch-specific way), but threads.h is much more complicated and
involves ABI decisions where I'm partly waiting to see what glibc
does.

Rich


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Feature request: stdatomic.h and threads.h
  2013-11-21 16:42 ` Rich Felker
@ 2013-11-21 17:19   ` Daniel Cegiełka
  2013-11-24 11:52   ` Daniel Cegiełka
  1 sibling, 0 replies; 7+ messages in thread
From: Daniel Cegiełka @ 2013-11-21 17:19 UTC (permalink / raw)
  To: musl

2013/11/21 Rich Felker <dalias@aerifal.cx>:
> On Thu, Nov 21, 2013 at 11:31:35AM +0100, Daniel Cegiełka wrote:
>> Hi,
>>
>> http://www.openwall.com/lists/musl/2013/06/29/17
>>
>> Is there a plan to add support for stdatomic.h and threads.h?
>
> Yes, but not before 1.0. stdatomic.h is probably not hard if you
> assume GCC __sync_* builtins (or it could be written in an
> arch-specific way),

like for stdalign.h

http://git.musl-libc.org/cgit/musl/tree/include/stdalign.h

I use a few tricks to support atomic operations (with __sync_*), but
C(11) has a huge backlog vs c++.

> but threads.h is much more complicated and
> involves ABI decisions where I'm partly waiting to see what glibc
> does.
>
> Rich

thx,
Daniel


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Feature request: stdatomic.h and threads.h
  2013-11-21 16:42 ` Rich Felker
  2013-11-21 17:19   ` Daniel Cegiełka
@ 2013-11-24 11:52   ` Daniel Cegiełka
  1 sibling, 0 replies; 7+ messages in thread
From: Daniel Cegiełka @ 2013-11-24 11:52 UTC (permalink / raw)
  To: musl

2013/11/21 Rich Felker <dalias@aerifal.cx>:
> On Thu, Nov 21, 2013 at 11:31:35AM +0100, Daniel Cegiełka wrote:
>> Hi,
>>
>> http://www.openwall.com/lists/musl/2013/06/29/17
>>
>> Is there a plan to add support for stdatomic.h and threads.h?
>
> Yes, but not before 1.0. stdatomic.h is probably not hard if you
> assume GCC __sync_* builtins (or it could be written in an
> arch-specific way)

this may be helpful: stdatomic.h from FreeBSD.

http://svnweb.freebsd.org/base/head/include/stdatomic.h?revision=234958&view=co&pathrev=234958

Support for gcc and cflang. This has been added to newlib:

https://sourceware.org/ml/newlib/2013/msg00436.html

Daniel


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2013-11-24 11:52 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-21 10:31 Feature request: stdatomic.h and threads.h Daniel Cegiełka
2013-11-21 14:16 ` Szabolcs Nagy
2013-11-21 14:44   ` Jens Gustedt
2013-11-21 16:16     ` Daniel Cegiełka
2013-11-21 16:42 ` Rich Felker
2013-11-21 17:19   ` Daniel Cegiełka
2013-11-24 11:52   ` Daniel Cegiełka

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).