From patchwork Tue Jan 4 03:14:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stafford Horne X-Patchwork-Id: 49508 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 8F8ED385840E for ; Tue, 4 Jan 2022 03:19:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8F8ED385840E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1641266366; bh=SvVfQ/MLE5SuNcFxbosA+9aIEgMn1LxPIyigY4N2+vM=; 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=AXTbSYmI/5hIz2EEBZCutpgj9w6ICKSp+6bdJW6wZvnIIMAqZGmjG6mibEomwODYR aSajO0ZIJXUORgf2xi7cMOW+p3VHK+6QwfJ2ajNurnuF+/jsazwAccTvsasHQosmnc kWrz5XDxD6zbS2EfzDjlr9ZOAWaJlaxQO3BphA74= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by sourceware.org (Postfix) with ESMTPS id 9C637385842C for ; Tue, 4 Jan 2022 03:14:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9C637385842C Received: by mail-pf1-x430.google.com with SMTP id m1so30971131pfk.8 for ; Mon, 03 Jan 2022 19:14:34 -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=SvVfQ/MLE5SuNcFxbosA+9aIEgMn1LxPIyigY4N2+vM=; b=qLf11d+F4+z71pbqW2fpaW28uXH4XD155VWmtCd+BEWkjjqN0v4fm7LdCXquq3FuGM 5i9ZoJcVwO5xTtTO9eX/747ntJEnbuxKoynq2HU2fSO7GOGbOyeVbHJsUYszWdn2vk9D 4p1yPF3AHDI+93WJoUDRkMeJAoMpM3XPyC+oXHaO2o7UEi7N1y1idzOboDJ7nbxN3MHx pc6wanyxjAKU/r7hFsNsa2jzZpeexi2EAdf+MZweRl/ELIHPEzD+x4LF3c2jdA2v4VMB bibekgXvEhW3czVVDSnSDYSCFKJpPQ3Dzp7myd8mzvpe7WmjzPsHLYyZZGwKKZQkRWgT 1s4g== X-Gm-Message-State: AOAM531H5IZruRCOmV81ZgCkvlNLYSEorGM+Y/hHY6n8wDzMDoq+SEI8 b428FVMbz7qoDT7JsXDrOglbpzNqizw= X-Google-Smtp-Source: ABdhPJywzDHWwYbyQIrsFwWnO6ETc32onJqMeNVyf9bqAwrMvbuezeWOyNPMKe2qIiUSDeNJOMBh/w== X-Received: by 2002:a63:6a49:: with SMTP id f70mr42974294pgc.244.1641266072569; Mon, 03 Jan 2022 19:14:32 -0800 (PST) Received: from localhost ([2409:10:24a0:4700:e8ad:216a:2a9d:6d0c]) by smtp.gmail.com with ESMTPSA id e15sm40697343pfv.23.2022.01.03.19.14.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jan 2022 19:14:32 -0800 (PST) To: GLIBC patches Subject: [PATCH v5 06/13] or1k: Atomics and Locking primitives Date: Tue, 4 Jan 2022 12:14:07 +0900 Message-Id: <20220104031414.2416928-7-shorne@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220104031414.2416928-1-shorne@gmail.com> References: <20220104031414.2416928-1-shorne@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-10.9 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" Reviewed-by: Adhemerval Zanella --- sysdeps/or1k/atomic-machine.h | 71 +++++++++++++++++++++++++++++++++++ 1 file changed, 71 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..0d27298d70 --- /dev/null +++ b/sysdeps/or1k/atomic-machine.h @@ -0,0 +1,71 @@ +/* Atomic operations. OpenRISC version. + Copyright (C) 2022 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 + +#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 */