From patchwork Fri Dec 10 23:34:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stafford Horne X-Patchwork-Id: 48818 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E2BA73857C72 for ; Fri, 10 Dec 2021 23:38:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E2BA73857C72 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1639179503; bh=qVssAnCqizWMYNetFxK/R2/Ds3SH8AMEJdUOHUOrQNU=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=tIxwfvKnKh8EBUKkjXvgE1dvunwk4GnleR5PUUIV9Bmsrk4PmkyLlTtTO5oh9HR9+ E9ZUciSwUq3U8eEYuIe3wNiZ+HSviuzGpChrGw7Kb/djXxcHeqXs++5yMQyk3yS0CQ JfbuvEjH+G0ZKG2/DCfRjZ1KvD9/6vlNtdq+IyAo= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) by sourceware.org (Postfix) with ESMTPS id 0F8AB3857C64 for ; Fri, 10 Dec 2021 23:35:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0F8AB3857C64 Received: by mail-pf1-x434.google.com with SMTP id x5so9862866pfr.0 for ; Fri, 10 Dec 2021 15:35:24 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qVssAnCqizWMYNetFxK/R2/Ds3SH8AMEJdUOHUOrQNU=; b=0MAj6kxtkfD0dxEdm5qN57RI0bdy+UDLyjNJVkwjZYURMNQFDsWNrh7HjAXx50PD5V 8oowc9Iijvn8rrKs4hrTNqv0eLLIgUegk/42K3BBFtF/16rID7Pd3xRCTQhQNWaZq+Ch N5ZxAUx63UnRtaR80BG31X/p67lVaojrr7reTBU4jkNhdOZ4oPl0pP+o5EwlpLUcVA55 rJUTTNSZD8rreA74aWWgTFSKuJaXdeZiuPfXsj9Ka3MZNyaHG6icoU03NStuwZe+dMQW QIychbITxoV+M7EJYi2cXLy87siXf2qUuMvNJ/yY+c1d4XVIwbWvsnRuBCuriGzTiTkc V2vw== X-Gm-Message-State: AOAM532KkSHmh0DyDKm1F22P4uJB8NofWsxSaRMiz4imeV+v5j5frVOL ccDxq2YrPLRjXxhhUUdXOjahHxnFVp4= X-Google-Smtp-Source: ABdhPJw5bxQxCMi3C/UJtNdqOo7GNHvGfU5pt65DUZqLo4kfMjAtyhK2uWyw5c4+wLDh4POiBWiB5Q== X-Received: by 2002:a63:d054:: with SMTP id s20mr41111124pgi.565.1639179322772; Fri, 10 Dec 2021 15:35:22 -0800 (PST) Received: from localhost ([2409:10:24a0:4700:e8ad:216a:2a9d:6d0c]) by smtp.gmail.com with ESMTPSA id d185sm3573941pgc.58.2021.12.10.15.35.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Dec 2021 15:35:22 -0800 (PST) To: GLIBC patches Subject: [PATCH v3 06/13] or1k: Atomics and Locking primitives Date: Sat, 11 Dec 2021 08:34:49 +0900 Message-Id: <20211210233456.4146479-7-shorne@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211210233456.4146479-1-shorne@gmail.com> References: <20211210233456.4146479-1-shorne@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_SHORT, 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-Patchwork-Original-From: Stafford Horne via Libc-alpha From: Stafford Horne Reply-To: Stafford Horne Cc: Openrisc Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" --- 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; + +#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"); }) + +#endif /* atomic-machine.h */