From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A8552C10DCE for ; Fri, 13 Mar 2020 03:04:40 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4956920716 for ; Fri, 13 Mar 2020 03:04:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="baD40noG"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=synopsys.com header.i=@synopsys.com header.b="ln/bH/m+" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4956920716 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=synopsys.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-snps-arc-bounces+linux-snps-arc=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=NRsZhRU8ddkgFj8G4r7UaEVeyg3y4+HE37wL7o9Ifio=; b=baD40noGuT0Aib RKNE77Qk8QHb+1SaLqhaKlIXYWOvvepDKqLnV1mtO3rIq/e2SiMSaDClLmkUpnus2tTRuRQnwmZyH OsqtiLVT7J7s0n4QzFkY0UZQRCNxtTvIgTveuC4QdWCQJrPeInqG8dNWCv0vOWHjfEyjm0MSaWRXl c8E+v2jTTmqDyfbSnG2y0nqysX38QcjReTtWI5bNbUlZomi/3qXAkIWihQ/hZcx/6O8pRGnZSZyLa 0tohOCclLbUFy9MlvkCobNPVVkkvh3wOCIITiNUn9ufGzzhjkpxvv8lVt0JBDoQiYKGUP6JlMzvLd HI2mFROgAPLiogDn58BQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jCacn-0003Vw-Mq; Fri, 13 Mar 2020 03:04:37 +0000 Received: from smtprelay-out1.synopsys.com ([149.117.87.133]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jCaci-0003RV-1X for linux-snps-arc@lists.infradead.org; Fri, 13 Mar 2020 03:04:35 +0000 Received: from mailhost.synopsys.com (sv1-mailhost2.synopsys.com [10.205.2.132]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by smtprelay-out1.synopsys.com (Postfix) with ESMTPS id 90289C0F93; Fri, 13 Mar 2020 03:04:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1584068670; bh=XzFb4IuvvCGoe9eR97CdUcms/QcI3Ijj19X3a+vZnB8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ln/bH/m+/vZEpiayKE+Hscd7F+m9wU/Z92k0knFWCx8Sv/y6wUWtMZnJhMxK1N10G ger1qZZZdchTa3x3MjRqVvho5/tCeRtlu3t3wDE/xg8wwDI6jk+msd29imClOQarVd KO0AaM5hCbcU6BCw2F1nShsQJ21fqsxF/td/C6HRneIpKCrV8axwBIVD9RBQnOfBHx xyBvEoDTwJ/wR9Y6UTnjmCHCs15FiW5J383NsSm5aLeVszIFMIAV0I6a3yMrhXu98o I6jMCSNh4QXwXiZUmNGCaDnb9ryvrs6FMlxgizHc+ZImEh0DhoJ5DKt6XgoHIgimx8 JQbXp657Yvl4w== Received: from vineetg-Latitude-E7450.internal.synopsys.com (unknown [10.13.182.230]) by mailhost.synopsys.com (Postfix) with ESMTP id 4AB72A007D; Fri, 13 Mar 2020 03:04:30 +0000 (UTC) From: Vineet Gupta To: libc-alpha@sourceware.org Subject: [PATCH v4 05/15] ARC: Atomics and Locking primitives Date: Thu, 12 Mar 2020 20:04:09 -0700 Message-Id: <20200313030419.15843-6-vgupta@synopsys.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200313030419.15843-1-vgupta@synopsys.com> References: <20200313030419.15843-1-vgupta@synopsys.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200312_200432_162374_B83E145D X-CRM114-Status: GOOD ( 12.72 ) X-BeenThere: linux-snps-arc@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on Synopsys ARC Processors List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Vineet Gupta , linux-snps-arc@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-snps-arc" Errors-To: linux-snps-arc-bounces+linux-snps-arc=archiver.kernel.org@lists.infradead.org Signed-off-by: Vineet Gupta --- sysdeps/arc/atomic-machine.h | 73 +++++++++++++++++++++++++++++++ sysdeps/arc/nptl/bits/semaphore.h | 32 ++++++++++++++ 2 files changed, 105 insertions(+) create mode 100644 sysdeps/arc/atomic-machine.h create mode 100644 sysdeps/arc/nptl/bits/semaphore.h diff --git a/sysdeps/arc/atomic-machine.h b/sysdeps/arc/atomic-machine.h new file mode 100644 index 000000000000..ae16c607dcc4 --- /dev/null +++ b/sysdeps/arc/atomic-machine.h @@ -0,0 +1,73 @@ +/* Low-level functions for atomic operations. ARC version. + Copyright (C) 2012-2020 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 _ARC_BITS_ATOMIC_H +#define _ARC_BITS_ATOMIC_H 1 + +#include + +typedef int32_t atomic32_t; +typedef uint32_t uatomic32_t; +typedef int_fast32_t atomic_fast32_t; +typedef uint_fast32_t uatomic_fast32_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 + +/* ARC does have legacy atomic EX reg, [mem] instruction but the micro-arch + is not as optimal as LLOCK/SCOND specially for SMP. */ +#define ATOMIC_EXCHANGE_USES_CAS 1 + +#define __arch_compare_and_exchange_bool_8_acq(mem, newval, oldval) \ + (abort (), 0) +#define __arch_compare_and_exchange_bool_16_acq(mem, newval, oldval) \ + (abort (), 0) +#define __arch_compare_and_exchange_bool_64_acq(mem, newval, oldval) \ + (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_64_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 atomic_compare_and_exchange_val_acq(mem, new, old) \ + __atomic_val_bysize (__arch_compare_and_exchange_val, int, \ + mem, new, old, __ATOMIC_ACQUIRE) + +#ifdef __ARC700__ +#define atomic_full_barrier() ({ asm volatile ("sync":::"memory"); }) +#else +#define atomic_full_barrier() ({ asm volatile ("dmb 3":::"memory"); }) +#endif + +#endif /* _ARC_BITS_ATOMIC_H */ diff --git a/sysdeps/arc/nptl/bits/semaphore.h b/sysdeps/arc/nptl/bits/semaphore.h new file mode 100644 index 000000000000..772dc4cb9b01 --- /dev/null +++ b/sysdeps/arc/nptl/bits/semaphore.h @@ -0,0 +1,32 @@ +/* Machine-specific POSIX semaphore type layouts. ARC version. + Copyright (C) 2002-2020 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 _SEMAPHORE_H +# error "Never use directly; include instead." +#endif + +#define __SIZEOF_SEM_T 16 + +/* Value returned if `sem_open' failed. */ +#define SEM_FAILED ((sem_t *) 0) + +typedef union +{ + char __size[__SIZEOF_SEM_T]; + long int __align; +} sem_t; -- 2.20.1 _______________________________________________ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc