Cleanup: move generic caa_get_cycles to arch/generic.h
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 28 Sep 2015 15:44:49 +0000 (11:44 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 28 Sep 2015 15:44:49 +0000 (11:44 -0400)
Eliminate some code duplication. It also implements a "generic"
caa_get_cycles() on architectures where its support is not implemented.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
13 files changed:
urcu/arch/aarch64.h
urcu/arch/alpha.h
urcu/arch/arm.h
urcu/arch/gcc.h
urcu/arch/generic.h
urcu/arch/hppa.h
urcu/arch/ia64.h
urcu/arch/mips.h
urcu/arch/ppc.h
urcu/arch/s390.h
urcu/arch/sparc64.h
urcu/arch/tile.h
urcu/arch/x86.h

index 946e1c64699f8a97e7d5d18de5b2e02aa8aed7eb..a68813d14cd9074017bde2620a89edac9afa5a83 100644 (file)
@@ -33,19 +33,6 @@ extern "C" {
 #include <stdlib.h>
 #include <sys/time.h>
 
-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;
-}
-
 /*
  * Define the membarrier system call number if not yet available in the
  * system headers. aarch64 implements asm-generic/unistd.h system call
index f4ef3d7d7fed66578011bc4e3700dfca0c0f219c..e61f82c0728047528acf484d74cf7011a892914c 100644 (file)
@@ -33,13 +33,6 @@ extern "C" {
 #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
index 1457166270314653f9564cdaf99e6c6a598e7e9b..9483bab0e23761a8f6e853dfbe9258b73adb8256 100644 (file)
@@ -39,19 +39,6 @@ extern "C" {
 #include <stdlib.h>
 #include <sys/time.h>
 
-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;
-}
-
 /*
  * Define the membarrier system call number if not yet available in the
  * system headers.
index 5638f3667a69b50ceb38d4ecbb19214d21879642..8684a16f92638f0a0f8f5ef08d85ca2b90dbaa10 100644 (file)
@@ -33,19 +33,6 @@ extern "C" {
 #include <stdlib.h>
 #include <sys/time.h>
 
-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
index 3f7521ebdd820261b7b2b43b328692a6186319f7..a80b3d6c13c1bb0e015837181d1e312380601c53 100644 (file)
@@ -150,6 +150,22 @@ extern "C" {
 #define caa_cpu_relax()                cmm_barrier()
 #endif
 
+#ifndef HAS_CAA_GET_CYCLES
+#define HAS_CAA_GET_CYCLES
+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;
+}
+#endif /* HAS_CAA_GET_CYCLES */
+
 #ifdef __cplusplus
 }
 #endif
index 61e8283886db941a9d0f48965ece1f25a0efc3c9..82d2a426b330869054043681ee4d281b1e85d59e 100644 (file)
@@ -1,6 +1,26 @@
 #ifndef _URCU_ARCH_HPPA_H
 #define _URCU_ARCH_HPPA_H
 
+/*
+ * arch/hppa.h: definitions for hppa architecture
+ *
+ * Copyright (c) 2014 Helge Deller <deller@gmx.de>
+ *
+ * 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 <urcu/compiler.h>
 #include <urcu/config.h>
 #include <urcu/syscall-compat.h>
@@ -12,6 +32,7 @@ extern "C" {
 #include <stdlib.h>
 #include <sys/time.h>
 
+#define HAS_CAA_GET_CYCLES
 typedef unsigned long cycles_t;
 
 static inline cycles_t caa_get_cycles(void)
index 79576851b553de92f4608090603560ba4122ccdc..12834f36f1f7cbf673f2d52b47ef1cbb6c3a4806 100644 (file)
@@ -33,19 +33,6 @@ extern "C" {
 #include <stdlib.h>
 #include <sys/time.h>
 
-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;
-}
-
 /*
  * Define the membarrier system call number if not yet available in the
  * system headers.
index 4ecdc37c52439799c666810598d475db670ab6a1..ea5b7e9539d8449b4297135a2fd41cf53ea93c03 100644 (file)
@@ -36,13 +36,6 @@ extern "C" {
                                        "       .set    mips0           \n" \
                                        :::"memory")
 
-typedef unsigned long long cycles_t;
-
-static inline cycles_t caa_get_cycles(void)
-{
-       return 0;       /* not supported */
-}
-
 #ifdef __cplusplus
 }
 #endif
index 1784ccdfe4aed8663e9706dc99e3ff0833f509eb..0bef952ccd20095714bcb96839464a7fdf8681ff 100644 (file)
@@ -82,6 +82,8 @@ extern "C" {
                rval;                                   \
        })
 
+#define HAS_CAA_GET_CYCLES
+
 typedef unsigned long long cycles_t;
 
 #ifdef __powerpc64__
index 6dc09a3e76c9d48963a5ddc185f07bb84a4f3eae..86a0a3689244b1ec2f9772fcda5a1093138aec2f 100644 (file)
@@ -40,6 +40,8 @@ extern "C" {
 
 #define cmm_mb()    __asm__ __volatile__("bcr 15,0" : : : "memory")
 
+#define HAS_CAA_GET_CYCLES
+
 typedef unsigned long long cycles_t;
 
 static inline cycles_t caa_get_cycles (void)
index 2ccb86fc357c27f9dcda255088bd4336b42f21a5..fb99450d36fd0521d1fcb9de72f97cd229cab579 100644 (file)
@@ -45,13 +45,6 @@ __asm__ __volatile__("ba,pt %%xcc, 1f\n\t"   \
 #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
index 2787ac75ab8ba8835290cacbfccc6b0c78978748..94dad4057b963c9ce7ef63d32baa9ce065311a64 100644 (file)
@@ -33,19 +33,6 @@ extern "C" {
 #include <stdlib.h>
 #include <sys/time.h>
 
-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;
-}
-
 /*
  * Define the membarrier system call number if not yet available in the
  * system headers. tile implements asm-generic/unistd.h system call
index ecc4b2d39b4133cb026fbe98be6cace2c5c3e223..afbf4fad37b68b8cb18f2eccb15f8c308e1eb02d 100644 (file)
@@ -69,6 +69,8 @@ extern "C" {
 
 #define caa_cpu_relax()        __asm__ __volatile__ ("rep; nop" : : : "memory")
 
+#define HAS_CAA_GET_CYCLES
+
 #define rdtscll(val)                                                     \
        do {                                                              \
             unsigned int __a, __d;                                       \
This page took 0.030247 seconds and 4 git commands to generate.