File openucx-s390x-support.patch of Package openucx

From: Nicolas Morey-Chaisemartin <nmoreychaisemartin@suse.com>
Date: 2017-06-29 08:09:49 +0000

---
 src/ucs/Makefile.am         |    2 +
 src/ucs/arch/atomic.h       |    2 +
 src/ucs/arch/bitops.h       |    2 +
 src/ucs/arch/cpu.h          |    2 +
 src/ucs/arch/s390x/bitops.h |   32 +++++++++++++++++++++++++++
 src/ucs/arch/s390x/cpu.h    |   51 ++++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 91 insertions(+)

Index: ucx-1.2.1/src/ucs/Makefile.am
===================================================================
--- ucx-1.2.1.orig/src/ucs/Makefile.am
+++ ucx-1.2.1/src/ucs/Makefile.am
@@ -26,6 +26,8 @@ nobase_dist_libucs_la_HEADERS = \
 	arch/generic/cpu.h \
 	arch/ppc64/bitops.h \
 	arch/ppc64/cpu.h \
+	arch/s390x/bitops.h \
+	arch/s390x/cpu.h \
 	arch/x86_64/atomic.h \
 	arch/x86_64/bitops.h \
 	arch/x86_64/cpu.h \
Index: ucx-1.2.1/src/ucs/arch/atomic.h
===================================================================
--- ucx-1.2.1.orig/src/ucs/arch/atomic.h
+++ ucx-1.2.1/src/ucs/arch/atomic.h
@@ -15,6 +15,8 @@
 #  include "generic/atomic.h"
 #elif defined(__aarch64__)
 #  include "generic/atomic.h"
+#elif defined(__s390x__)
+#  include "generic/atomic.h"
 #else
 #  error "Unsupported architecture"
 #endif
Index: ucx-1.2.1/src/ucs/arch/bitops.h
===================================================================
--- ucx-1.2.1.orig/src/ucs/arch/bitops.h
+++ ucx-1.2.1/src/ucs/arch/bitops.h
@@ -14,6 +14,8 @@
 #  include "ppc64/bitops.h"
 #elif defined(__aarch64__)
 #  include "aarch64/bitops.h"
+#elif defined(__s390x__)
+#  include "s390x/bitops.h"
 #else
 #  error "Unsupported architecture"
 #endif
Index: ucx-1.2.1/src/ucs/arch/cpu.h
===================================================================
--- ucx-1.2.1.orig/src/ucs/arch/cpu.h
+++ ucx-1.2.1/src/ucs/arch/cpu.h
@@ -52,6 +52,8 @@ typedef enum ucs_cpu_flag {
 #  include "ppc64/cpu.h"
 #elif defined(__aarch64__)
 #  include "aarch64/cpu.h"
+#elif defined(__s390x__)
+#  include "s390x/cpu.h"
 #else
 #  error "Unsupported architecture"
 #endif
Index: ucx-1.2.1/src/ucs/arch/s390x/bitops.h
===================================================================
--- /dev/null
+++ ucx-1.2.1/src/ucs/arch/s390x/bitops.h
@@ -0,0 +1,32 @@
+/**
+* Copyright (C) Mellanox Technologies Ltd. 2001-2015.  ALL RIGHTS RESERVED.
+*
+* See file LICENSE for terms.
+*/
+
+#ifndef UCS_S390X_BITOPS_H_
+#define UCS_S390X_BITOPS_H_
+
+#include <stdint.h>
+
+
+static inline unsigned __ucs_ilog2_u32(uint32_t n)
+{
+	if (!n)
+		return 0;
+	return 31 - __builtin_clz(n);
+}
+
+static inline unsigned __ucs_ilog2_u64(uint64_t n)
+{
+	if (!n)
+		return 0;
+	return 63 - __builtin_clz(n);
+}
+
+static inline unsigned ucs_ffs64(uint64_t n)
+{
+    return __ucs_ilog2_u64(n & -n);
+}
+
+#endif
Index: ucx-1.2.1/src/ucs/arch/s390x/cpu.h
===================================================================
--- /dev/null
+++ ucx-1.2.1/src/ucs/arch/s390x/cpu.h
@@ -0,0 +1,51 @@
+/**
+* Copyright (C) Mellanox Technologies Ltd. 2001-2013.  ALL RIGHTS RESERVED.
+* Copyright (C) ARM Ltd. 2016-2017.  ALL RIGHTS RESERVED.
+*
+* See file LICENSE for terms.
+*/
+
+
+#ifndef UCS_S390X_CPU_H_
+#define UCS_S390X_CPU_H_
+
+#include <ucs/sys/compiler.h>
+#include <ucs/arch/generic/cpu.h>
+#include <stdint.h>
+
+
+#define UCS_ARCH_CACHE_LINE_SIZE 256
+
+/* Assume the worst - weak memory ordering */
+#define ucs_memory_bus_fence()        asm volatile (""::: "memory")
+#define ucs_memory_bus_store_fence()  ucs_memory_bus_fence()
+#define ucs_memory_bus_load_fence()   ucs_memory_bus_fence()
+#define ucs_memory_cpu_fence()        ucs_memory_bus_fence()
+#define ucs_memory_cpu_store_fence()  ucs_memory_bus_fence()
+#define ucs_memory_cpu_load_fence()   ucs_memory_bus_fence()
+
+
+static inline uint64_t ucs_arch_read_hres_clock()
+{
+    unsigned long  clk;
+    asm volatile("stck %0" : "=Q" (clk) : : "cc");
+    return clk >> 2;
+}
+#define ucs_arch_get_clocks_per_sec ucs_arch_generic_get_clocks_per_sec
+
+
+static inline ucs_cpu_model_t ucs_arch_get_cpu_model()
+{
+    return UCS_CPU_MODEL_UNKNOWN;
+}
+
+static inline int ucs_arch_get_cpu_flag()
+{
+    return UCS_CPU_FLAG_UNKNOWN;
+}
+
+double ucs_arch_get_clocks_per_sec();
+
+#define ucs_arch_wait_mem ucs_arch_generic_wait_mem
+
+#endif
openSUSE Build Service is sponsored by