From: Vineet Gupta <vineet.gupta1@synopsys.com>
To: <libc-alpha@sourceware.org>
Cc: <linux-snps-arc@lists.infradead.org>,
Vineet Gupta <vineet.gupta1@synopsys.com>
Subject: [PATCH 06/21] ARC: Atomics and Locking primitives
Date: Tue, 18 Dec 2018 13:04:28 -0800 [thread overview]
Message-ID: <1545167083-16764-7-git-send-email-vgupta@synopsys.com> (raw)
In-Reply-To: <1545167083-16764-1-git-send-email-vgupta@synopsys.com>
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
---
ChangeLog | 3 ++
sysdeps/arc/atomic-machine.h | 89 +++++++++++++++++++++++++++++++
sysdeps/arc/nptl/bits/pthreadtypes-arch.h | 72 +++++++++++++++++++++++++
sysdeps/arc/nptl/bits/semaphore.h | 32 +++++++++++
4 files changed, 196 insertions(+)
create mode 100644 sysdeps/arc/atomic-machine.h
create mode 100644 sysdeps/arc/nptl/bits/pthreadtypes-arch.h
create mode 100644 sysdeps/arc/nptl/bits/semaphore.h
diff --git a/ChangeLog b/ChangeLog
index 6e53b171a72d..d2f6cd2d0d09 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -35,6 +35,9 @@
* sysdeps/arc/nptl/tcb-offsets.sym: New file.
* sysdeps/arc/nptl/tls.h: New file.
* sysdeps/arc/stackinfo.h: New file.
+ * sysdeps/arc/atomic-machine.h: New file.
+ * sysdeps/arc/nptl/bits/pthreadtypes-arch.h: New file.
+ * sysdeps/arc/nptl/bits/semaphore.h: New file.
2018-12-17 Joseph Myers <joseph@codesourcery.com>
diff --git a/sysdeps/arc/atomic-machine.h b/sysdeps/arc/atomic-machine.h
new file mode 100644
index 000000000000..1a8d976794d0
--- /dev/null
+++ b/sysdeps/arc/atomic-machine.h
@@ -0,0 +1,89 @@
+/* Low-level functions for atomic operations. ARC version.
+ Copyright (C) 2012-2018 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
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _ARC_BITS_ATOMIC_H
+#define _ARC_BITS_ATOMIC_H 1
+
+#include <stdint.h>
+
+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 0
+#define ATOMIC_EXCHANGE_USES_CAS 1
+
+#define __arch_compare_and_exchange_val_8_acq(mem, newval, oldval) \
+ (abort (), (__typeof (*mem)) 0)
+#define __arch_compare_and_exchange_val_16_acq(mem, newval, oldval) \
+ (abort (), (__typeof (*mem)) 0)
+#define __arch_compare_and_exchange_val_64_acq(mem, newval, oldval) \
+ (abort (), (__typeof (*mem)) 0)
+
+#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_32_acq(mem, newval, oldval) \
+ ({ \
+ __typeof(*(mem)) prev; \
+ \
+ __asm__ __volatile__( \
+ "1: llock %0, [%1] \n" \
+ " brne %0, %2, 2f \n" \
+ " scond %3, [%1] \n" \
+ " bnz 1b \n" \
+ "2: \n" \
+ : "=&r"(prev) \
+ : "r"(mem), "ir"(oldval), \
+ "r"(newval) /* can't be "ir". scond can't take limm for "b" */\
+ : "cc", "memory"); \
+ \
+ prev; \
+ })
+
+# define atomic_exchange_acq(mem, newvalue) \
+ ({ \
+ __typeof(*(mem)) __val = (newvalue); \
+ \
+ __asm__ __volatile__( \
+ "1: ex %0, [%1] \n" \
+ : "+r"(__val) \
+ : "r"(mem) \
+ : "memory"); \
+ \
+ __val; \
+ })
+
+#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/pthreadtypes-arch.h b/sysdeps/arc/nptl/bits/pthreadtypes-arch.h
new file mode 100644
index 000000000000..473d9ec2bf0d
--- /dev/null
+++ b/sysdeps/arc/nptl/bits/pthreadtypes-arch.h
@@ -0,0 +1,72 @@
+/* Machine-specific pthread type layouts. ARC version.
+ Copyright (C) 2012-2018 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
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _BITS_PTHREADTYPES_ARCH_H
+#define _BITS_PTHREADTYPES_ARCH_H 1
+
+#include <endian.h>
+
+#define __SIZEOF_PTHREAD_ATTR_T 36
+#define __SIZEOF_PTHREAD_MUTEX_T 24
+#define __SIZEOF_PTHREAD_MUTEXATTR_T 4
+#define __SIZEOF_PTHREAD_COND_T 48
+#define __SIZEOF_PTHREAD_CONDATTR_T 4
+#define __SIZEOF_PTHREAD_RWLOCK_T 32
+#define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
+#define __SIZEOF_PTHREAD_BARRIER_T 20
+#define __SIZEOF_PTHREAD_BARRIERATTR_T 4
+
+/* Data structure for mutex handling. */
+#define __PTHREAD_COMPAT_PADDING_MID
+#define __PTHREAD_COMPAT_PADDING_END
+#define __PTHREAD_MUTEX_LOCK_ELISION 0
+#define __PTHREAD_MUTEX_NUSERS_AFTER_KIND 1
+#define __PTHREAD_MUTEX_USE_UNION 1
+
+#define __LOCK_ALIGNMENT
+#define __ONCE_ALIGNMENT
+
+struct __pthread_rwlock_arch_t
+{
+ unsigned int __readers;
+ unsigned int __writers;
+ unsigned int __wrphase_futex;
+ unsigned int __writers_futex;
+ unsigned int __pad3;
+ unsigned int __pad4;
+#if __BYTE_ORDER == __BIG_ENDIAN
+ unsigned char __pad1;
+ unsigned char __pad2;
+ unsigned char __shared;
+ /* FLAGS must stay at this position in the structure to maintain
+ binary compatibility. */
+ unsigned char __flags;
+#else
+ /* FLAGS must stay at this position in the structure to maintain
+ binary compatibility. */
+ unsigned char __flags;
+ unsigned char __shared;
+ unsigned char __pad1;
+ unsigned char __pad2;
+#endif
+ int __cur_writer;
+};
+
+#define __PTHREAD_RWLOCK_ELISION_EXTRA 0
+
+#endif /* bits/pthreadtypes-arch.h */
diff --git a/sysdeps/arc/nptl/bits/semaphore.h b/sysdeps/arc/nptl/bits/semaphore.h
new file mode 100644
index 000000000000..1ecc8ab8a65b
--- /dev/null
+++ b/sysdeps/arc/nptl/bits/semaphore.h
@@ -0,0 +1,32 @@
+/* Machine-specific POSIX semaphore type layouts. ARC version.
+ Copyright (C) 2002-2018 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
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _SEMAPHORE_H
+# error "Never use <bits/semaphore.h> directly; include <semaphore.h> 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.7.4
next prev parent reply other threads:[~2018-12-18 21:05 UTC|newest]
Thread overview: 99+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-18 21:04 [PATCH 00/21] glibc port to ARC processors Vineet Gupta
2018-12-18 21:04 ` [PATCH 01/21] longlong.h: sync from gcc to fix ARC inline asm constraints Vineet Gupta
2018-12-18 22:56 ` Joseph Myers
2018-12-18 23:11 ` Vineet Gupta
2018-12-21 18:46 ` Joseph Myers
2018-12-21 19:07 ` Vineet Gupta
2018-12-18 21:04 ` [PATCH 02/21] ARC: add definitions to elf/elf.h Vineet Gupta
2018-12-18 21:04 ` [PATCH 03/21] ARC: ABI Implementation Vineet Gupta
2018-12-18 23:09 ` Joseph Myers
2018-12-19 2:00 ` Vineet Gupta
2018-12-19 17:40 ` Joseph Myers
2018-12-19 20:20 ` Vineet Gupta
2018-12-19 20:37 ` Joseph Myers
2019-01-28 23:03 ` ARC binutils init/fini (was Re: [PATCH 03/21] ARC: ABI Implementation) Vineet Gupta
2019-01-28 23:13 ` Joseph Myers
2019-01-28 23:42 ` Vineet Gupta
2018-12-18 21:04 ` [PATCH 04/21] ARC: startup and dynamic linking code Vineet Gupta
2018-12-18 23:24 ` Joseph Myers
2018-12-19 0:52 ` Vineet Gupta
2018-12-18 21:04 ` [PATCH 05/21] ARC: Thread Local Storage support Vineet Gupta
2018-12-18 21:04 ` Vineet Gupta [this message]
2018-12-18 23:15 ` [PATCH 06/21] ARC: Atomics and Locking primitives Joseph Myers
2019-01-15 0:40 ` Vineet Gupta
2018-12-18 21:04 ` [PATCH 07/21] ARC: math soft float support Vineet Gupta
2018-12-18 23:23 ` Joseph Myers
2018-12-19 0:01 ` Joseph Myers
2018-12-20 21:35 ` Vineet Gupta
2018-12-21 1:08 ` Vineet Gupta
2018-12-21 1:19 ` Joseph Myers
2018-12-18 21:04 ` [PATCH 08/21] ARC: Linux Syscall Interface Vineet Gupta
2018-12-18 23:30 ` Joseph Myers
2018-12-19 2:39 ` Vineet Gupta
2018-12-19 17:58 ` ARC vs. generic sigaction (was Re: [PATCH 08/21] ARC: Linux Syscall Interface) Vineet Gupta
2018-12-19 18:07 ` Joseph Myers
2018-12-19 22:00 ` Adhemerval Zanella
2018-12-19 22:23 ` Vineet Gupta
2018-12-20 11:19 ` Adhemerval Zanella
2018-12-20 12:06 ` Arnd Bergmann
2018-12-20 19:25 ` Vineet Gupta
2018-12-20 12:40 ` Florian Weimer
2018-12-20 18:48 ` Vineet Gupta
2019-01-03 13:10 ` Florian Weimer
2018-12-20 19:23 ` Vineet Gupta
2018-12-20 20:06 ` Adhemerval Zanella
2018-12-20 20:46 ` Vineet Gupta
2018-12-21 12:05 ` Adhemerval Zanella
2019-01-09 21:49 ` Vineet Gupta
2018-12-18 21:04 ` [PATCH 09/21] ARC: Linux ABI Vineet Gupta
2018-12-18 23:38 ` Joseph Myers
2018-12-19 19:57 ` Vineet Gupta
2018-12-19 20:36 ` Joseph Myers
2018-12-21 23:06 ` Vineet Gupta
2018-12-18 21:04 ` [PATCH 10/21] ARC: Linux Startup and Dynamic Loading Vineet Gupta
2018-12-18 23:49 ` Joseph Myers
2018-12-19 20:26 ` Vineet Gupta
2018-12-18 21:04 ` [PATCH 11/21] ARC: ABI lists Vineet Gupta
2018-12-18 22:31 ` Andreas Schwab
2018-12-18 22:32 ` Vineet Gupta
2018-12-18 21:04 ` [PATCH 12/21] ARC: Update syscall-names.list for ARC specific syscalls Vineet Gupta
2018-12-18 21:26 ` Florian Weimer
2018-12-18 21:29 ` Vineet Gupta
2018-12-19 8:16 ` Florian Weimer
2018-12-18 21:04 ` [PATCH 13/21] ARC: Build Infrastructure Vineet Gupta
2018-12-18 23:44 ` Joseph Myers
2018-12-19 21:58 ` Vineet Gupta
2018-12-19 22:17 ` Joseph Myers
2018-12-20 23:21 ` Vineet Gupta
2018-12-20 23:24 ` Joseph Myers
2019-01-29 23:36 ` Vineet Gupta
2018-12-18 21:04 ` [PATCH 14/21] ARC: Enable __start as entry point vs. canonical _start Vineet Gupta
2018-12-18 21:28 ` Florian Weimer
2018-12-18 21:31 ` Vineet Gupta
2018-12-18 22:59 ` Joseph Myers
2018-12-18 23:08 ` Vineet Gupta
2018-12-19 20:36 ` Vineet Gupta
2018-12-18 21:04 ` [PATCH 15/21] ARC: testsuite fix: elf/check-initfini Vineet Gupta
2018-12-18 21:04 ` [PATCH 16/21] ARC: testsuite fix: sysvipc/* Vineet Gupta
2018-12-19 22:10 ` Adhemerval Zanella
2018-12-18 21:04 ` [PATCH 17/21] ARC: testsuite fix: stdlib/tst-makecontext Vineet Gupta
2018-12-18 22:36 ` Andreas Schwab
2019-01-21 22:32 ` Vineet Gupta
2018-12-18 21:04 ` [PATCH 18/21] ARC: testsuite fix: GD TLS issue Vineet Gupta
2018-12-18 21:04 ` [PATCH 19/21] ARC: fix several unwining and cancelation tests Vineet Gupta
2018-12-18 21:04 ` [PATCH 20/21] build-many-glibcs.py: Enable ARC builds Vineet Gupta
2018-12-18 21:04 ` [PATCH 21/21] NEWS: mention ARC port Vineet Gupta
2018-12-18 23:45 ` Joseph Myers
2018-12-19 18:30 ` Vineet Gupta
2018-12-18 22:52 ` [PATCH 00/21] glibc port to ARC processors Joseph Myers
2018-12-18 23:07 ` Vineet Gupta
2018-12-18 23:52 ` Joseph Myers
2018-12-21 1:55 ` Vineet Gupta
2018-12-21 14:32 ` Joseph Myers
2018-12-21 17:36 ` Vineet Gupta
2018-12-18 23:11 ` Joseph Myers
2018-12-19 23:45 ` Vineet Gupta
2018-12-20 0:14 ` Joseph Myers
2018-12-20 0:51 ` Vineet Gupta
2018-12-20 21:22 ` test related questions (was Re: [PATCH 00/21] glibc port to ARC processors) Vineet Gupta
2018-12-20 21:59 ` Joseph Myers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/libc/involved.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1545167083-16764-7-git-send-email-vgupta@synopsys.com \
--to=vineet.gupta1@synopsys.com \
--cc=libc-alpha@sourceware.org \
--cc=linux-snps-arc@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).