From: Mathieu Desnoyers Date: Fri, 10 Jun 2011 19:48:01 +0000 (-0400) Subject: Headers: move arch_*.h to urcu/arch/*.h X-Git-Tag: v0.6.0~13 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=1b9119f8d4c3f40a61d4ee5403f0e7e5967c33d8;p=userspace-rcu.git Headers: move arch_*.h to urcu/arch/*.h Signed-off-by: Mathieu Desnoyers --- diff --git a/Makefile.am b/Makefile.am index 5723b21..e85c924 100644 --- a/Makefile.am +++ b/Makefile.am @@ -8,12 +8,12 @@ SUBDIRS = . tests include_HEADERS = urcu.h $(top_srcdir)/urcu-*.h nobase_dist_include_HEADERS = urcu/compiler.h urcu/hlist.h urcu/list.h \ urcu/rculist.h urcu/rcuhlist.h urcu/system.h urcu/urcu-futex.h \ - urcu/uatomic_generic.h urcu/arch_generic.h urcu/wfstack.h \ + urcu/uatomic_generic.h urcu/arch/generic.h urcu/wfstack.h \ urcu/wfqueue.h urcu/rculfstack.h urcu/rculfqueue.h \ urcu/urcu_ref.h urcu/map/*.h urcu/static/*.h nobase_nodist_include_HEADERS = urcu/arch.h urcu/uatomic_arch.h urcu/config.h -EXTRA_DIST = $(top_srcdir)/urcu/arch_*.h $(top_srcdir)/urcu/uatomic_arch_*.h \ +EXTRA_DIST = $(top_srcdir)/urcu/arch/*.h $(top_srcdir)/urcu/uatomic_arch_*.h \ gpl-2.0.txt lgpl-2.1.txt lgpl-relicensing.txt \ README LICENSE compat_arch_x86.c diff --git a/configure.ac b/configure.ac index 179cb7d..85123a1 100644 --- a/configure.ac +++ b/configure.ac @@ -82,7 +82,7 @@ asm volatile("dmb":::"memory"); fi UATOMICSRC=urcu/uatomic_arch_$ARCHTYPE.h -ARCHSRC=urcu/arch_$ARCHTYPE.h +ARCHSRC=urcu/arch/$ARCHTYPE.h if test "x$ARCHTYPE" != xx86 -a "x$ARCHTYPE" != xppc; then APISRC=tests/api_gcc.h else diff --git a/urcu/arch/alpha.h b/urcu/arch/alpha.h new file mode 100644 index 0000000..300213e --- /dev/null +++ b/urcu/arch/alpha.h @@ -0,0 +1,48 @@ +#ifndef _URCU_ARCH_ALPHA_H +#define _URCU_ARCH_ALPHA_H + +/* + * arch_alpha.h: trivial definitions for the Alpha architecture. + * + * Copyright (c) 2010 Paolo Bonzini + * + * This 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. + * + * This 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 this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define cmm_mb() asm volatile("mb":::"memory") +#define cmm_wmb() asm volatile("wmb":::"memory") +#define cmm_read_barrier_depends() asm volatile("mb":::"memory") + +typedef unsigned long long cycles_t; + +static inline cycles_t caa_get_cycles (void) +{ + return 0; /* not supported */ +} + +#ifdef __cplusplus +} +#endif + +#include + +#endif /* _URCU_ARCH_ALPHA_H */ diff --git a/urcu/arch/arm.h b/urcu/arch/arm.h new file mode 100644 index 0000000..b49f782 --- /dev/null +++ b/urcu/arch/arm.h @@ -0,0 +1,60 @@ +#ifndef _URCU_ARCH_ARM_H +#define _URCU_ARCH_ARM_H + +/* + * arch_arm.h: trivial definitions for the ARM architecture. + * + * Copyright (c) 2010 Paul E. McKenney, IBM Corporation. + * Copyright (c) 2009 Mathieu Desnoyers + * + * This 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. + * + * This 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 this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef CONFIG_RCU_ARM_HAVE_DMB +#define cmm_mb() asm volatile("dmb":::"memory") +#define cmm_rmb() asm volatile("dmb":::"memory") +#define cmm_wmb() asm volatile("dmb":::"memory") +#endif /* CONFIG_RCU_ARM_HAVE_DMB */ + +#include +#include + +typedef unsigned long long cycles_t; + +static inline cycles_t caa_get_cycles (void) +{ + cycles_t thetime; + struct timeval tv; + + if (gettimeofday(&tv, NULL) != 0) + return 0; + thetime = ((cycles_t)tv.tv_sec) * 1000000ULL + ((cycles_t)tv.tv_usec); + return (cycles_t)thetime; +} + +#ifdef __cplusplus +} +#endif + +#include + +#endif /* _URCU_ARCH_ARM_H */ diff --git a/urcu/arch/gcc.h b/urcu/arch/gcc.h new file mode 100644 index 0000000..0c83c23 --- /dev/null +++ b/urcu/arch/gcc.h @@ -0,0 +1,54 @@ +#ifndef _URCU_ARCH_GCC_H +#define _URCU_ARCH_GCC_H + +/* + * arch_gcc.h: trivial definitions for architectures using gcc __sync_ + * + * Copyright (c) 2010 Paul E. McKenney, IBM Corporation. + * Copyright (c) 2009 Mathieu Desnoyers + * + * This 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. + * + * This 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 this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +typedef unsigned long long cycles_t; + +static inline cycles_t caa_get_cycles (void) +{ + cycles_t thetime; + struct timeval tv; + + if (gettimeofday(&tv, NULL) != 0) + return 0; + thetime = ((cycles_t)tv.tv_sec) * 1000000ULL + ((cycles_t)tv.tv_usec); + return (cycles_t)thetime; +} + +#ifdef __cplusplus +} +#endif + +#include + +#endif /* _URCU_ARCH_GCC_H */ diff --git a/urcu/arch/generic.h b/urcu/arch/generic.h new file mode 100644 index 0000000..100d3c6 --- /dev/null +++ b/urcu/arch/generic.h @@ -0,0 +1,128 @@ +#ifndef _URCU_ARCH_GENERIC_H +#define _URCU_ARCH_GENERIC_H + +/* + * arch_generic.h: common definitions for multiple architectures. + * + * Copyright (c) 2010 Paolo Bonzini + * + * This 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. + * + * This 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 this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef CAA_CACHE_LINE_SIZE +#define CAA_CACHE_LINE_SIZE 64 +#endif + +#if !defined(cmm_mc) && !defined(cmm_rmc) && !defined(cmm_wmc) +#define CONFIG_HAVE_MEM_COHERENCY +/* + * Architectures with cache coherency must _not_ define cmm_mc/cmm_rmc/cmm_wmc. + * + * For them, cmm_mc/cmm_rmc/cmm_wmc are implemented with a * simple compiler barrier; + * in addition, we provide defaults for cmm_mb (using GCC builtins) as well as + * cmm_rmb and cmm_wmb (defaulting to cmm_mb). + */ + +#ifndef cmm_mb +#define cmm_mb() __sync_synchronize() +#endif + +#ifndef cmm_rmb +#define cmm_rmb() cmm_mb() +#endif + +#ifndef cmm_wmb +#define cmm_wmb() cmm_mb() +#endif + +#define cmm_mc() cmm_barrier() +#define cmm_rmc() cmm_barrier() +#define cmm_wmc() cmm_barrier() +#else +/* + * Architectures without cache coherency need something like the following: + * + * #define cmm_mc() arch_cache_flush() + * #define cmm_rmc() arch_cache_flush_read() + * #define cmm_wmc() arch_cache_flush_write() + * + * Of these, only cmm_mc is mandatory. cmm_rmc and cmm_wmc default to cmm_mc. + * cmm_mb/cmm_rmb/cmm_wmb use these definitions by default: + * + * #define cmm_mb() cmm_mc() + * #define cmm_rmb() cmm_rmc() + * #define cmm_wmb() cmm_wmc() + */ + +#ifndef cmm_mb +#define cmm_mb() cmm_mc() +#endif + +#ifndef cmm_rmb +#define cmm_rmb() cmm_rmc() +#endif + +#ifndef cmm_wmb +#define cmm_wmb() cmm_wmc() +#endif + +#ifndef cmm_rmc +#define cmm_rmc() cmm_mc() +#endif + +#ifndef cmm_wmc +#define cmm_wmc() cmm_mc() +#endif +#endif + +/* Nop everywhere except on alpha. */ +#ifndef cmm_read_barrier_depends +#define cmm_read_barrier_depends() +#endif + +#ifdef CONFIG_RCU_SMP +#define cmm_smp_mb() cmm_mb() +#define cmm_smp_rmb() cmm_rmb() +#define cmm_smp_wmb() cmm_wmb() +#define cmm_smp_mc() cmm_mc() +#define cmm_smp_rmc() cmm_rmc() +#define cmm_smp_wmc() cmm_wmc() +#define cmm_smp_read_barrier_depends() cmm_read_barrier_depends() +#else +#define cmm_smp_mb() cmm_barrier() +#define cmm_smp_rmb() cmm_barrier() +#define cmm_smp_wmb() cmm_barrier() +#define cmm_smp_mc() cmm_barrier() +#define cmm_smp_rmc() cmm_barrier() +#define cmm_smp_wmc() cmm_barrier() +#define cmm_smp_read_barrier_depends() +#endif + +#ifndef caa_cpu_relax +#define caa_cpu_relax() cmm_barrier() +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _URCU_ARCH_GENERIC_H */ diff --git a/urcu/arch/ppc.h b/urcu/arch/ppc.h new file mode 100644 index 0000000..d7317bb --- /dev/null +++ b/urcu/arch/ppc.h @@ -0,0 +1,73 @@ +#ifndef _URCU_ARCH_PPC_H +#define _URCU_ARCH_PPC_H + +/* + * arch_ppc.h: trivial definitions for the powerpc architecture. + * + * Copyright (c) 2009 Paul E. McKenney, IBM Corporation. + * Copyright (c) 2009 Mathieu Desnoyers + * + * This 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. + * + * This 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 this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Include size of POWER5+ L3 cache lines: 256 bytes */ +#define CAA_CACHE_LINE_SIZE 256 + +#define cmm_mb() asm volatile("sync":::"memory") + +#define mftbl() \ + ({ \ + unsigned long rval; \ + asm volatile("mftbl %0" : "=r" (rval)); \ + rval; \ + }) + +#define mftbu() \ + ({ \ + unsigned long rval; \ + asm volatile("mftbu %0" : "=r" (rval)); \ + rval; \ + }) + +typedef unsigned long long cycles_t; + +static inline cycles_t caa_get_cycles (void) +{ + long h, l; + + for (;;) { + h = mftbu(); + cmm_barrier(); + l = mftbl(); + cmm_barrier(); + if (mftbu() == h) + return (((cycles_t) h) << 32) + l; + } +} + +#ifdef __cplusplus +} +#endif + +#include + +#endif /* _URCU_ARCH_PPC_H */ diff --git a/urcu/arch/s390.h b/urcu/arch/s390.h new file mode 100644 index 0000000..5985b20 --- /dev/null +++ b/urcu/arch/s390.h @@ -0,0 +1,59 @@ +#ifndef _URCU_ARCH_S390_H +#define _URCU_ARCH_S390_H + +/* + * Trivial definitions for the S390 architecture based on information from the + * Principles of Operation "CPU Serialization" (5-91), "BRANCH ON CONDITION" + * (7-25) and "STORE CLOCK" (7-169). + * + * Copyright (c) 2009 Novell, Inc. + * Author: Jan Blunck + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define CAA_CACHE_LINE_SIZE 128 + +#define cmm_mb() __asm__ __volatile__("bcr 15,0" : : : "memory") + +typedef unsigned long long cycles_t; + +static inline cycles_t caa_get_cycles (void) +{ + cycles_t cycles; + + __asm__ __volatile__("stck %0" : "=m" (cycles) : : "cc", "memory" ); + + return cycles; +} + +#ifdef __cplusplus +} +#endif + +#include + +#endif /* _URCU_ARCH_S390_H */ diff --git a/urcu/arch/sparc64.h b/urcu/arch/sparc64.h new file mode 100644 index 0000000..46e2665 --- /dev/null +++ b/urcu/arch/sparc64.h @@ -0,0 +1,60 @@ +#ifndef _URCU_ARCH_SPARC64_H +#define _URCU_ARCH_SPARC64_H + +/* + * arch_sparc64.h: trivial definitions for the Sparc64 architecture. + * + * Copyright (c) 2009 Paul E. McKenney, IBM Corporation. + * Copyright (c) 2009 Mathieu Desnoyers + * + * This 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. + * + * This 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 this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define CAA_CACHE_LINE_SIZE 256 + +/* + * Inspired from the Linux kernel. Workaround Spitfire bug #51. + */ +#define membar_safe(type) \ +__asm__ __volatile__("ba,pt %%xcc, 1f\n\t" \ + "membar " type "\n" \ + "1:\n" \ + : : : "memory") + +#define cmm_mb() membar_safe("#LoadLoad | #LoadStore | #StoreStore | #StoreLoad") +#define cmm_rmb() membar_safe("#LoadLoad") +#define cmm_wmb() membar_safe("#StoreStore") + +typedef unsigned long long cycles_t; + +static inline cycles_t caa_get_cycles (void) +{ + return 0; /* unimplemented */ +} + +#ifdef __cplusplus +} +#endif + +#include + +#endif /* _URCU_ARCH_SPARC64_H */ diff --git a/urcu/arch/unknown.h b/urcu/arch/unknown.h new file mode 100644 index 0000000..701575d --- /dev/null +++ b/urcu/arch/unknown.h @@ -0,0 +1,28 @@ +#ifndef _URCU_ARCH_UNKNOWN_H +#define _URCU_ARCH_UNKNOWN_H + +/* + * arch_unknown.h: #error to prevent build on unknown architectures. + * + * Copyright (c) 2010 Paul E. McKenney, IBM Corporation. + * Copyright (c) 2009 Mathieu Desnoyers + * + * This 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. + * + * This 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 this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/* See configure.ac for the list of recognized architectures. */ +#error "Cannot build: unrecognized architecture detected." + +#endif /* _URCU_ARCH_UNKNOWN_H */ diff --git a/urcu/arch/x86.h b/urcu/arch/x86.h new file mode 100644 index 0000000..9e5411f --- /dev/null +++ b/urcu/arch/x86.h @@ -0,0 +1,74 @@ +#ifndef _URCU_ARCH_X86_H +#define _URCU_ARCH_X86_H + +/* + * arch_x86.h: trivial definitions for the x86 architecture. + * + * Copyright (c) 2009 Paul E. McKenney, IBM Corporation. + * Copyright (c) 2009 Mathieu Desnoyers + * + * This 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. + * + * This 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 this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define CAA_CACHE_LINE_SIZE 128 + +#ifdef CONFIG_RCU_HAVE_FENCE +#define cmm_mb() asm volatile("mfence":::"memory") +#define cmm_rmb() asm volatile("lfence":::"memory") +#define cmm_wmb() asm volatile("sfence"::: "memory") +#else +/* + * Some non-Intel clones support out of order store. cmm_wmb() ceases to be a + * nop for these. + */ +#define cmm_mb() asm volatile("lock; addl $0,0(%%esp)":::"memory") +#define cmm_rmb() asm volatile("lock; addl $0,0(%%esp)":::"memory") +#define cmm_wmb() asm volatile("lock; addl $0,0(%%esp)"::: "memory") +#endif + +#define caa_cpu_relax() asm volatile("rep; nop" : : : "memory"); + +#define rdtscll(val) \ + do { \ + unsigned int __a, __d; \ + asm volatile("rdtsc" : "=a" (__a), "=d" (__d)); \ + (val) = ((unsigned long long)__a) \ + | (((unsigned long long)__d) << 32); \ + } while(0) + +typedef unsigned long long cycles_t; + +static inline cycles_t caa_get_cycles(void) +{ + cycles_t ret = 0; + + rdtscll(ret); + return ret; +} + +#ifdef __cplusplus +} +#endif + +#include + +#endif /* _URCU_ARCH_X86_H */ diff --git a/urcu/arch_alpha.h b/urcu/arch_alpha.h deleted file mode 100644 index d62ac17..0000000 --- a/urcu/arch_alpha.h +++ /dev/null @@ -1,48 +0,0 @@ -#ifndef _URCU_ARCH_ALPHA_H -#define _URCU_ARCH_ALPHA_H - -/* - * arch_alpha.h: trivial definitions for the Alpha architecture. - * - * Copyright (c) 2010 Paolo Bonzini - * - * This 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. - * - * This 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 this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#define cmm_mb() asm volatile("mb":::"memory") -#define cmm_wmb() asm volatile("wmb":::"memory") -#define cmm_read_barrier_depends() asm volatile("mb":::"memory") - -typedef unsigned long long cycles_t; - -static inline cycles_t caa_get_cycles (void) -{ - return 0; /* not supported */ -} - -#ifdef __cplusplus -} -#endif - -#include - -#endif /* _URCU_ARCH_ALPHA_H */ diff --git a/urcu/arch_arm.h b/urcu/arch_arm.h deleted file mode 100644 index 92df8e9..0000000 --- a/urcu/arch_arm.h +++ /dev/null @@ -1,60 +0,0 @@ -#ifndef _URCU_ARCH_ARM_H -#define _URCU_ARCH_ARM_H - -/* - * arch_arm.h: trivial definitions for the ARM architecture. - * - * Copyright (c) 2010 Paul E. McKenney, IBM Corporation. - * Copyright (c) 2009 Mathieu Desnoyers - * - * This 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. - * - * This 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 this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef CONFIG_RCU_ARM_HAVE_DMB -#define cmm_mb() asm volatile("dmb":::"memory") -#define cmm_rmb() asm volatile("dmb":::"memory") -#define cmm_wmb() asm volatile("dmb":::"memory") -#endif /* CONFIG_RCU_ARM_HAVE_DMB */ - -#include -#include - -typedef unsigned long long cycles_t; - -static inline cycles_t caa_get_cycles (void) -{ - cycles_t thetime; - struct timeval tv; - - if (gettimeofday(&tv, NULL) != 0) - return 0; - thetime = ((cycles_t)tv.tv_sec) * 1000000ULL + ((cycles_t)tv.tv_usec); - return (cycles_t)thetime; -} - -#ifdef __cplusplus -} -#endif - -#include - -#endif /* _URCU_ARCH_ARM_H */ diff --git a/urcu/arch_gcc.h b/urcu/arch_gcc.h deleted file mode 100644 index 96efa0d..0000000 --- a/urcu/arch_gcc.h +++ /dev/null @@ -1,54 +0,0 @@ -#ifndef _URCU_ARCH_GCC_H -#define _URCU_ARCH_GCC_H - -/* - * arch_gcc.h: trivial definitions for architectures using gcc __sync_ - * - * Copyright (c) 2010 Paul E. McKenney, IBM Corporation. - * Copyright (c) 2009 Mathieu Desnoyers - * - * This 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. - * - * This 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 this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include - -typedef unsigned long long cycles_t; - -static inline cycles_t caa_get_cycles (void) -{ - cycles_t thetime; - struct timeval tv; - - if (gettimeofday(&tv, NULL) != 0) - return 0; - thetime = ((cycles_t)tv.tv_sec) * 1000000ULL + ((cycles_t)tv.tv_usec); - return (cycles_t)thetime; -} - -#ifdef __cplusplus -} -#endif - -#include - -#endif /* _URCU_ARCH_GCC_H */ diff --git a/urcu/arch_generic.h b/urcu/arch_generic.h deleted file mode 100644 index 100d3c6..0000000 --- a/urcu/arch_generic.h +++ /dev/null @@ -1,128 +0,0 @@ -#ifndef _URCU_ARCH_GENERIC_H -#define _URCU_ARCH_GENERIC_H - -/* - * arch_generic.h: common definitions for multiple architectures. - * - * Copyright (c) 2010 Paolo Bonzini - * - * This 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. - * - * This 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 this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef CAA_CACHE_LINE_SIZE -#define CAA_CACHE_LINE_SIZE 64 -#endif - -#if !defined(cmm_mc) && !defined(cmm_rmc) && !defined(cmm_wmc) -#define CONFIG_HAVE_MEM_COHERENCY -/* - * Architectures with cache coherency must _not_ define cmm_mc/cmm_rmc/cmm_wmc. - * - * For them, cmm_mc/cmm_rmc/cmm_wmc are implemented with a * simple compiler barrier; - * in addition, we provide defaults for cmm_mb (using GCC builtins) as well as - * cmm_rmb and cmm_wmb (defaulting to cmm_mb). - */ - -#ifndef cmm_mb -#define cmm_mb() __sync_synchronize() -#endif - -#ifndef cmm_rmb -#define cmm_rmb() cmm_mb() -#endif - -#ifndef cmm_wmb -#define cmm_wmb() cmm_mb() -#endif - -#define cmm_mc() cmm_barrier() -#define cmm_rmc() cmm_barrier() -#define cmm_wmc() cmm_barrier() -#else -/* - * Architectures without cache coherency need something like the following: - * - * #define cmm_mc() arch_cache_flush() - * #define cmm_rmc() arch_cache_flush_read() - * #define cmm_wmc() arch_cache_flush_write() - * - * Of these, only cmm_mc is mandatory. cmm_rmc and cmm_wmc default to cmm_mc. - * cmm_mb/cmm_rmb/cmm_wmb use these definitions by default: - * - * #define cmm_mb() cmm_mc() - * #define cmm_rmb() cmm_rmc() - * #define cmm_wmb() cmm_wmc() - */ - -#ifndef cmm_mb -#define cmm_mb() cmm_mc() -#endif - -#ifndef cmm_rmb -#define cmm_rmb() cmm_rmc() -#endif - -#ifndef cmm_wmb -#define cmm_wmb() cmm_wmc() -#endif - -#ifndef cmm_rmc -#define cmm_rmc() cmm_mc() -#endif - -#ifndef cmm_wmc -#define cmm_wmc() cmm_mc() -#endif -#endif - -/* Nop everywhere except on alpha. */ -#ifndef cmm_read_barrier_depends -#define cmm_read_barrier_depends() -#endif - -#ifdef CONFIG_RCU_SMP -#define cmm_smp_mb() cmm_mb() -#define cmm_smp_rmb() cmm_rmb() -#define cmm_smp_wmb() cmm_wmb() -#define cmm_smp_mc() cmm_mc() -#define cmm_smp_rmc() cmm_rmc() -#define cmm_smp_wmc() cmm_wmc() -#define cmm_smp_read_barrier_depends() cmm_read_barrier_depends() -#else -#define cmm_smp_mb() cmm_barrier() -#define cmm_smp_rmb() cmm_barrier() -#define cmm_smp_wmb() cmm_barrier() -#define cmm_smp_mc() cmm_barrier() -#define cmm_smp_rmc() cmm_barrier() -#define cmm_smp_wmc() cmm_barrier() -#define cmm_smp_read_barrier_depends() -#endif - -#ifndef caa_cpu_relax -#define caa_cpu_relax() cmm_barrier() -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* _URCU_ARCH_GENERIC_H */ diff --git a/urcu/arch_ppc.h b/urcu/arch_ppc.h deleted file mode 100644 index b0f5030..0000000 --- a/urcu/arch_ppc.h +++ /dev/null @@ -1,73 +0,0 @@ -#ifndef _URCU_ARCH_PPC_H -#define _URCU_ARCH_PPC_H - -/* - * arch_ppc.h: trivial definitions for the powerpc architecture. - * - * Copyright (c) 2009 Paul E. McKenney, IBM Corporation. - * Copyright (c) 2009 Mathieu Desnoyers - * - * This 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. - * - * This 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 this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* Include size of POWER5+ L3 cache lines: 256 bytes */ -#define CAA_CACHE_LINE_SIZE 256 - -#define cmm_mb() asm volatile("sync":::"memory") - -#define mftbl() \ - ({ \ - unsigned long rval; \ - asm volatile("mftbl %0" : "=r" (rval)); \ - rval; \ - }) - -#define mftbu() \ - ({ \ - unsigned long rval; \ - asm volatile("mftbu %0" : "=r" (rval)); \ - rval; \ - }) - -typedef unsigned long long cycles_t; - -static inline cycles_t caa_get_cycles (void) -{ - long h, l; - - for (;;) { - h = mftbu(); - cmm_barrier(); - l = mftbl(); - cmm_barrier(); - if (mftbu() == h) - return (((cycles_t) h) << 32) + l; - } -} - -#ifdef __cplusplus -} -#endif - -#include - -#endif /* _URCU_ARCH_PPC_H */ diff --git a/urcu/arch_s390.h b/urcu/arch_s390.h deleted file mode 100644 index 1f03c78..0000000 --- a/urcu/arch_s390.h +++ /dev/null @@ -1,59 +0,0 @@ -#ifndef _URCU_ARCH_S390_H -#define _URCU_ARCH_S390_H - -/* - * Trivial definitions for the S390 architecture based on information from the - * Principles of Operation "CPU Serialization" (5-91), "BRANCH ON CONDITION" - * (7-25) and "STORE CLOCK" (7-169). - * - * Copyright (c) 2009 Novell, Inc. - * Author: Jan Blunck - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#define CAA_CACHE_LINE_SIZE 128 - -#define cmm_mb() __asm__ __volatile__("bcr 15,0" : : : "memory") - -typedef unsigned long long cycles_t; - -static inline cycles_t caa_get_cycles (void) -{ - cycles_t cycles; - - __asm__ __volatile__("stck %0" : "=m" (cycles) : : "cc", "memory" ); - - return cycles; -} - -#ifdef __cplusplus -} -#endif - -#include - -#endif /* _URCU_ARCH_S390_H */ diff --git a/urcu/arch_sparc64.h b/urcu/arch_sparc64.h deleted file mode 100644 index 283a8f4..0000000 --- a/urcu/arch_sparc64.h +++ /dev/null @@ -1,60 +0,0 @@ -#ifndef _URCU_ARCH_SPARC64_H -#define _URCU_ARCH_SPARC64_H - -/* - * arch_sparc64.h: trivial definitions for the Sparc64 architecture. - * - * Copyright (c) 2009 Paul E. McKenney, IBM Corporation. - * Copyright (c) 2009 Mathieu Desnoyers - * - * This 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. - * - * This 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 this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#define CAA_CACHE_LINE_SIZE 256 - -/* - * Inspired from the Linux kernel. Workaround Spitfire bug #51. - */ -#define membar_safe(type) \ -__asm__ __volatile__("ba,pt %%xcc, 1f\n\t" \ - "membar " type "\n" \ - "1:\n" \ - : : : "memory") - -#define cmm_mb() membar_safe("#LoadLoad | #LoadStore | #StoreStore | #StoreLoad") -#define cmm_rmb() membar_safe("#LoadLoad") -#define cmm_wmb() membar_safe("#StoreStore") - -typedef unsigned long long cycles_t; - -static inline cycles_t caa_get_cycles (void) -{ - return 0; /* unimplemented */ -} - -#ifdef __cplusplus -} -#endif - -#include - -#endif /* _URCU_ARCH_SPARC64_H */ diff --git a/urcu/arch_unknown.h b/urcu/arch_unknown.h deleted file mode 100644 index 701575d..0000000 --- a/urcu/arch_unknown.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef _URCU_ARCH_UNKNOWN_H -#define _URCU_ARCH_UNKNOWN_H - -/* - * arch_unknown.h: #error to prevent build on unknown architectures. - * - * Copyright (c) 2010 Paul E. McKenney, IBM Corporation. - * Copyright (c) 2009 Mathieu Desnoyers - * - * This 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. - * - * This 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 this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/* See configure.ac for the list of recognized architectures. */ -#error "Cannot build: unrecognized architecture detected." - -#endif /* _URCU_ARCH_UNKNOWN_H */ diff --git a/urcu/arch_x86.h b/urcu/arch_x86.h deleted file mode 100644 index 20db5cf..0000000 --- a/urcu/arch_x86.h +++ /dev/null @@ -1,74 +0,0 @@ -#ifndef _URCU_ARCH_X86_H -#define _URCU_ARCH_X86_H - -/* - * arch_x86.h: trivial definitions for the x86 architecture. - * - * Copyright (c) 2009 Paul E. McKenney, IBM Corporation. - * Copyright (c) 2009 Mathieu Desnoyers - * - * This 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. - * - * This 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 this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#define CAA_CACHE_LINE_SIZE 128 - -#ifdef CONFIG_RCU_HAVE_FENCE -#define cmm_mb() asm volatile("mfence":::"memory") -#define cmm_rmb() asm volatile("lfence":::"memory") -#define cmm_wmb() asm volatile("sfence"::: "memory") -#else -/* - * Some non-Intel clones support out of order store. cmm_wmb() ceases to be a - * nop for these. - */ -#define cmm_mb() asm volatile("lock; addl $0,0(%%esp)":::"memory") -#define cmm_rmb() asm volatile("lock; addl $0,0(%%esp)":::"memory") -#define cmm_wmb() asm volatile("lock; addl $0,0(%%esp)"::: "memory") -#endif - -#define caa_cpu_relax() asm volatile("rep; nop" : : : "memory"); - -#define rdtscll(val) \ - do { \ - unsigned int __a, __d; \ - asm volatile("rdtsc" : "=a" (__a), "=d" (__d)); \ - (val) = ((unsigned long long)__a) \ - | (((unsigned long long)__d) << 32); \ - } while(0) - -typedef unsigned long long cycles_t; - -static inline cycles_t caa_get_cycles(void) -{ - cycles_t ret = 0; - - rdtscll(ret); - return ret; -} - -#ifdef __cplusplus -} -#endif - -#include - -#endif /* _URCU_ARCH_X86_H */