From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qk1-x729.google.com (mail-qk1-x729.google.com [IPv6:2607:f8b0:4864:20::729]) by sourceware.org (Postfix) with ESMTPS id 6220D3858D28 for ; Thu, 16 Dec 2021 12:52:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6220D3858D28 Received: by mail-qk1-x729.google.com with SMTP id de30so23206459qkb.0 for ; Thu, 16 Dec 2021 04:52:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=UuH1oZBzJFB9j0ATPunmhGoFi417fZpfqH1mv3SXRrY=; b=Up8vm98AZc/gz9Jo1JPAz9Pf/xlD7COjTiv6RCi6gIzcc6BryvTQOSYai7EuRRCT7s ZWxJs4+BljIXquDkZA7QqVu0oVTzGRWiPdDqg4cs8MMW+4LXlaodq896Ba6ekNNagM0/ WBmkhhgGq8Z0si/QDPDvdI/HBPruiCZCFeWgUD0+GRd45En7y24Twtdo8j1n4ifhMSGc HsePVJx+e2C2l0+JKp/L4Zrzyge2pUB/IoItl/EJR6SbNt6Z7zv+QpGM7nKcZEAhO9yN 9B4ZcuV9t4TSySyth+bRLWxC+2oaXIih+88ZW/1l6o9ju2mOuU70+gFGpzWbAiqunMzK 6DtA== X-Gm-Message-State: AOAM5339mEeI+SlnW64ypW3E7JJ1GLvMRH6BJS3Fgc/hLKQXMHjIn1jM f4vvNIEEo5d6tIpM/bk5s/fiSw== X-Google-Smtp-Source: ABdhPJx5scRpaLpMYZgrcvpxdJe3dOVkfw+4geHCy9EghxBcBe0AMLCC1BGW46mIC6lkf8G1BJZe2g== X-Received: by 2002:a05:620a:f12:: with SMTP id v18mr12119589qkl.720.1639659166852; Thu, 16 Dec 2021 04:52:46 -0800 (PST) Received: from ?IPV6:2804:431:c7ca:103f:96e9:fe91:2aff:a44d? ([2804:431:c7ca:103f:96e9:fe91:2aff:a44d]) by smtp.gmail.com with ESMTPSA id w13sm2735849qko.20.2021.12.16.04.52.45 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 16 Dec 2021 04:52:46 -0800 (PST) Message-ID: <39803fe3-ab39-524a-c678-1b74d092c436@linaro.org> Date: Thu, 16 Dec 2021 09:52:44 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.4.0 Subject: Re: [PATCH v3 06/13] or1k: Atomics and Locking primitives Content-Language: en-US To: Stafford Horne , GLIBC patches Cc: Openrisc References: <20211210233456.4146479-1-shorne@gmail.com> <20211210233456.4146479-7-shorne@gmail.com> From: Adhemerval Zanella In-Reply-To: <20211210233456.4146479-7-shorne@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 Dec 2021 12:52:49 -0000 LGTM, thanks. On 10/12/2021 20:34, Stafford Horne via Libc-alpha wrote: > --- > sysdeps/or1k/atomic-machine.h | 79 +++++++++++++++++++++++++++++++++++ > 1 file changed, 79 insertions(+) > create mode 100644 sysdeps/or1k/atomic-machine.h > > diff --git a/sysdeps/or1k/atomic-machine.h b/sysdeps/or1k/atomic-machine.h > new file mode 100644 > index 0000000000..1e306ae4ef > --- /dev/null > +++ b/sysdeps/or1k/atomic-machine.h > @@ -0,0 +1,79 @@ > +/* Atomic operations. OpenRISC version. > + Copyright (C) 2021 Free Software Foundation, Inc. > + This file is part of the GNU C Library. > + > + The GNU C Library is free software; you can redistribute it and/or > + modify it under the terms of the GNU Lesser General Public > + License as published by the Free Software Foundation; either > + version 2.1 of the License, or (at your option) any later version. > + > + The GNU C Library is distributed in the hope that it will be useful, > + but WITHOUT ANY WARRANTY; without even the implied warranty of > + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > + Lesser General Public License for more details. > + > + You should have received a copy of the GNU Lesser General Public > + License along with the GNU C Library. If not, see > + . */ > + > +#ifndef __OR1K_ATOMIC_H_ > +#define __OR1K_ATOMIC_H_ > + > +#include > + > +typedef int32_t atomic32_t; > +typedef uint32_t uatomic32_t; > + > +typedef intptr_t atomicptr_t; > +typedef uintptr_t uatomicptr_t; > +typedef intmax_t atomic_max_t; > +typedef uintmax_t uatomic_max_t; Sigh, these definition are used solely in only file, memusage.c. Another thing I will cleanup. > + > +#define __HAVE_64B_ATOMICS 0 > +#define USE_ATOMIC_COMPILER_BUILTINS 1 > +#define ATOMIC_EXCHANGE_USES_CAS 1 > + > +#define __arch_compare_and_exchange_bool_8_int(mem, newval, oldval, model) \ > + (abort (), 0) > + > +#define __arch_compare_and_exchange_bool_16_int(mem, newval, oldval, model) \ > + (abort (), 0) > + > +#define __arch_compare_and_exchange_bool_32_int(mem, newval, oldval, model) \ > + ({ \ > + typeof (*mem) __oldval = (oldval); \ > + !__atomic_compare_exchange_n (mem, (void *) &__oldval, newval, 0, \ > + model, __ATOMIC_RELAXED); \ > + }) > + > +#define __arch_compare_and_exchange_bool_64_int(mem, newval, oldval, model) \ > + (abort (), 0) > + > +#define __arch_compare_and_exchange_val_8_int(mem, newval, oldval, model) \ > + (abort (), (__typeof (*mem)) 0) > + > +#define __arch_compare_and_exchange_val_16_int(mem, newval, oldval, model) \ > + (abort (), (__typeof (*mem)) 0) > + > +#define __arch_compare_and_exchange_val_32_int(mem, newval, oldval, model) \ > + ({ \ > + typeof (*mem) __oldval = (oldval); \ > + __atomic_compare_exchange_n (mem, (void *) &__oldval, newval, 0, \ > + model, __ATOMIC_RELAXED); \ > + __oldval; \ > + }) > + > +#define __arch_compare_and_exchange_val_64_int(mem, newval, oldval, model) \ > + (abort (), (__typeof (*mem)) 0) > + > +#define atomic_compare_and_exchange_bool_acq(mem, new, old) \ > + __atomic_bool_bysize (__arch_compare_and_exchange_bool, int, \ > + mem, new, old, __ATOMIC_ACQUIRE) > + > +#define atomic_compare_and_exchange_val_acq(mem, new, old) \ > + __atomic_val_bysize (__arch_compare_and_exchange_val, int, \ > + mem, new, old, __ATOMIC_ACQUIRE) > + > +#define atomic_full_barrier() ({ asm volatile ("l.msync" ::: "memory"); }) And I think we can also clean this up as well. > + > +#endif /* atomic-machine.h */