This is the mail archive of the libc-ports@sources.redhat.com mailing list for the libc-ports project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: ARM atomic_full_barrier implementation question


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]