This is the mail archive of the
mailing list for the glibc project.
Re: installing the <atomic.h> header?
- From: "Carlos O'Donell" <carlos at systemhalted dot org>
- To: Petr Baudis <pasky at suse dot cz>
- Cc: Chris Metcalf <cmetcalf at tilera dot com>, GNU C Library <libc-alpha at sourceware dot org>
- Date: Thu, 4 Nov 2010 20:41:13 -0400
- Subject: Re: installing the <atomic.h> header?
- References: <4CD308BB.firstname.lastname@example.org><20101105001159.GL8806@machine.or.cz>
On Thu, Nov 4, 2010 at 8:11 PM, Petr Baudis <email@example.com> wrote:
> ?IMHO most of this stuff is not really a kernel service or worth a
> library routine, but just making use of your instruction set properly.
> So a compiler matter, solved not too badly with
> ? ? ? ?http://gcc.gnu.org/onlinedocs/gcc-4.5.0/gcc/Atomic-Builtins.html
> ?I don't think the extra layer of <atomic.h> convenience routines is
> all that significant; and no kernel calls are wrapped by this, AFAICS.
On a purely techincal note, some architectures do provide wrappers for
kernel helper routines. However, no userspace application should ever
call them, they should use the the GCC atomic builtins as you suggest.
Some architectures require kernel arbitration depending on the way in
which the ISA matches or does not match the implemented atomic
operation. As two examples: On HP PA-RISC the ISA only defines "load
and clear word", and the kernel always arbitrates a compare and swap
using a light-weight syscall mechanism. On ARM for anything older than
ARMv6 you use a kernel helper to complete a compare and exchange
operation (or memory barrier).