From patchwork Sat Nov 13 03:16:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stafford Horne X-Patchwork-Id: 47590 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 6D5F33858435 for ; Sat, 13 Nov 2021 03:21:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6D5F33858435 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1636773695; bh=puuQpsXKE8SctMHqUqWmdKNAxQff5+a3ySZrGzDuKJY=; 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=I4VOJ8LaB15JnZEoBVoyQbNHE2sf4U3PS6fOv5FXFneL05cSUPlBWBa8j+FUN/BiT 0ko+JuiSTsJBE0sEyFpvMvdlScAMqw1BWNa5jPrU+dPiIRQYzjgEBOMH0ZlY9jcsdT BHhhGAflIzZLYt09dHJE0qKLZzFVIK7Y/7yYbYs0= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by sourceware.org (Postfix) with ESMTPS id 2B135385843F for ; Sat, 13 Nov 2021 03:17:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2B135385843F Received: by mail-pj1-x102b.google.com with SMTP id np6-20020a17090b4c4600b001a90b011e06so7930983pjb.5 for ; Fri, 12 Nov 2021 19:17:02 -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=puuQpsXKE8SctMHqUqWmdKNAxQff5+a3ySZrGzDuKJY=; b=reH4JrcGebo4g+IeUruABuQG16oGrzSvpPEv3sQNPQn/WJG9AlZeJRCywsMw3nXYCI JFZ7whkLoWgzqn/oY916B76hVQmkhlwKFgbYhsC4apxEEfe8KQIAuqvJA3tloy0sDtun 4uwdZfsL+GoJqemVrOiLbsE7IerYfw40ILzijMNRc9fcLOmXI+gsxwMtYnIwXkn836sf VcHv5f09ZHYT+AncstcwxZJPad5lKsCPhU7dv+pAQRia0vScS4OI9LfvHSoqCKFJvjjI CDFlmo3YPxtHRA763nozzJPX5/LfHdr6MmovzyU+yPSwUN9zAkz+H2lamDZ8yeD78igF pvMQ== X-Gm-Message-State: AOAM530TdPPaoKcaAwUaWjI4s8cuJuAnGEVYw5ndsnKbcIxMBpV21jvs kcdBgqGk1B04xk/K09iAh5QhSyRn3Wo= X-Google-Smtp-Source: ABdhPJzBV/R3wEa9E5VUkFlJmH0zxsGV6Duo5igUuYLNMlPYQ2ZkXKv4GkK+dwpz7dkbLRcRJiTf2g== X-Received: by 2002:a17:90a:8c0a:: with SMTP id a10mr41434767pjo.58.1636773420950; Fri, 12 Nov 2021 19:17:00 -0800 (PST) Received: from localhost ([2409:10:24a0:4700:e8ad:216a:2a9d:6d0c]) by smtp.gmail.com with ESMTPSA id mg12sm12197792pjb.10.2021.11.12.19.16.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Nov 2021 19:17:00 -0800 (PST) To: GLIBC patches Subject: [PATCH v2 06/13] or1k: Atomics and Locking primitives Date: Sat, 13 Nov 2021 12:16:32 +0900 Message-Id: <20211113031639.2402161-7-shorne@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211113031639.2402161-1-shorne@gmail.com> References: <20211113031639.2402161-1-shorne@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-10.3 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..813bbf35cc --- /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 */