This is the mail archive of the
libc-ports@sources.redhat.com
mailing list for the libc-ports project.
Re: ARM atomic_full_barrier implementation question
- From: "Carlos O'Donell" <carlos at systemhalted dot org>
- To: Lael Jones <lael dot jones at gmail dot com>
- Cc: libc-ports at sourceware dot org
- Date: Thu, 28 Apr 2011 17:46:08 -0400
- Subject: Re: ARM atomic_full_barrier implementation question
- References: <BANLkTimf3=zz22HOAb1ZjapXwnBMMrcSLg@mail.gmail.com>
On Thu, Apr 28, 2011 at 4:37 PM, Lael Jones <lael.jones@gmail.com> wrote:
> Recently I was searching for a barrier type instruction for use on ARM
> when working on a project and came across the implementation used in
> the glibc ports directory in atomic.h for the ARM:
>
> #ifdef __thumb2__
> #define atomic_full_barrier() \
> ? ? __asm__ __volatile__ ? ? ? ? ? ? ? ? ? ? ? ? ? ? \
> ? ? ? ? ("movw\tip, #0x0fa0\n\t" ? ? ? ? ? ? ? ? ? ? ? ? \
> ? ? ? ? ?"movt\tip, #0xffff\n\t" ? ? ? ? ? ? ? ? ? ? ? ? \
> ? ? ? ? ?"blx\tip" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? \
> ? ? ? ? ?: : : "ip", "lr", "cc", "memory");
> #else
> #define atomic_full_barrier() \
> ? ? __asm__ __volatile__ ? ? ? ? ? ? ? ? ? ? ? ? ? ? \
> ? ? ? ? ("mov\tip, #0xffff0fff\n\t" ? ? ? ? ? ? ? ? ? ? ?\
> ? ? ? ? ?"mov\tlr, pc\n\t" ? ? ? ? ? ? ? ? ? ? ? ? ? \
> ? ? ? ? ?"add\tpc, ip, #(0xffff0fa0 - 0xffff0fff)" ? ? ? ? ? ? ? \
> ? ? ? ? ?: : : "ip", "lr", "cc", "memory");
> #endif
>
> This looks to me like it is making a function call to a fixed address.
> ?Can someone explain exactly how this implements a barrier? ?Does the
> Linux kernel install some code at that specific address?
Use GCC's atomic builtins, don't write this stuff yourself.
GLIBC probably calls the kernel vDSO to implement a full barrier for
whatever machine you've booted on.
Cheers,
Carlos.