From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 77213 invoked by alias); 17 Jul 2018 20:03:18 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 77184 invoked by uid 89); 17 Jul 2018 20:03:17 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,SPF_PASS,URIBL_RED autolearn=ham version=3.3.2 spammy=han, helpers, Han X-HELO: relay1.mentorg.com Date: Tue, 17 Jul 2018 20:03:00 -0000 From: Joseph Myers To: Mao Han CC: , , Subject: Re: [RFC PATCH v3 05/12] C-SKY: Atomic and Locking Routines In-Reply-To: <20180703075629.GA4317@vmh-VirtualBox> Message-ID: References: <52862eb735de64be1bd5a61b21ef9585e665558d.1530246556.git.han_mao@c-sky.com> <20180703075629.GA4317@vmh-VirtualBox> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" X-SW-Source: 2018-07/txt/msg00507.txt.bz2 On Tue, 3 Jul 2018, Mao Han wrote: > The macro seems someting to reduce architecture-specific code > needed to support C11-like atomics? If compiler can expands the > atomic built-in to the correct call, either libgcc or libatomic(inline) > , it is suggested to define USE_ATOMIC_COMPILER_BUILTINS to 1? If the compiler expands the calls inline, defining USE_ATOMIC_COMPILER_BUILTINS to 1 is appropriate unless you have a clear reason not to do so (and such a reason would need to have detailed comments in glibc explaining it). If the compiler generates out-of-line libatomic calls for atomic operations used in glibc, you need to use inline asm there instead of USE_ATOMIC_COMPILER_BUILTINS; glibc is not linked with libatomic. If the compiler generates out-of-line libgcc calls for atomic operations used in glibc, it's possible inline asm will be more efficient. The main reason for the compiler to generate out-of-line calls is if those calls need to use kernel helpers (vDSO / syscalls / etc.). If the processors supported by the port always support suitable atomic instructions that can be called directly without needing such kernel helpers, the compiler should expand the calls inline, and you should define USE_ATOMIC_COMPILER_BUILTINS to 1. > According to comment in pthread_spin_trylock.c ATOMIC_EXCHANGE_USES_CAS > should define to 1 if exchange is not supported? I did not found any Yes. -- Joseph S. Myers joseph@codesourcery.com