File gasnet-fix-multiple-definitions.patch of Package gasnet

commit 4b6758330c0040281dbbd1c518555d97d4dd3b4b
Author: Nicolas Morey-Chaisemartin <nmoreychaisemartin@suse.com>
Date:   Sun Jun 7 15:08:24 2020 +0200

    gasnet fix multiple definitions
    
    Add missing externs and declations to fix compatibility with GCC10
    
    Signed-off-by: Nicolas Morey-Chaisemartin <nmoreychaisemartin@suse.com>

diff --git gasnet_tools.c gasnet_tools.c
index 3cae0d519114..3551f03c9c6e 100644
--- gasnet_tools.c
+++ gasnet_tools.c
@@ -1432,7 +1432,6 @@ static int gasneti_backtrace_userdisabled = 0;
 static const char *gasneti_backtrace_list = 0;
 GASNETT_TENTATIVE_EXTERN
 const char *(*gasneti_backtraceid_fn)(void); /* allow client override of backtrace line prefix */
-gasnett_backtrace_type_t gasnett_backtrace_user; /* allow client provided backtrace function */
 extern void gasneti_backtrace_init(const char *exename) {
   static int user_is_init = 0;
 
@@ -1457,7 +1456,8 @@ extern void gasneti_backtrace_init(const char *exename) {
     return;
   }
 
-  if (!user_is_init && gasnett_backtrace_user.name && gasnett_backtrace_user.fnp) {
+  if (!user_is_init && &gasnett_backtrace_user &&
+	  gasnett_backtrace_user.name && gasnett_backtrace_user.fnp) {
     memcpy(&gasneti_backtrace_mechanisms[gasneti_backtrace_mechanism_count++], &gasnett_backtrace_user, sizeof(gasnett_backtrace_user));
     user_is_init = 1;
   }
diff --git gasnet_tools.h gasnet_tools.h
index 0331a2b80cfd..5c868ede8608 100644
--- gasnet_tools.h
+++ gasnet_tools.h
@@ -430,7 +430,7 @@ typedef struct {
   int threadsupport; /* does backtrace function handle threads correctly? 
                               -ie backtrace the calling thread and optionally others as well */
 } gasnett_backtrace_type_t;
-extern gasnett_backtrace_type_t gasnett_backtrace_user;
+extern gasnett_backtrace_type_t gasnett_backtrace_user __attribute__((weak));
 
 /* ------------------------------------------------------------------------------------ */
 /* GASNet tracing/stats support (automatically stubbed out when libgasnet absent) */
diff --git ofi-conduit/gasnet_core_internal.h ofi-conduit/gasnet_core_internal.h
index 897d422fb24f..3daa5556a40c 100644
--- ofi-conduit/gasnet_core_internal.h
+++ ofi-conduit/gasnet_core_internal.h
@@ -31,45 +31,6 @@
 #define GASNETC_MAX_NUMHANDLERS   256
 extern gasneti_handler_fn_t gasnetc_handler[GASNETC_MAX_NUMHANDLERS];
 
-/* FI_THREAD_DOMAIN providers in PAR mode */
-#if GASNET_PAR && GASNETC_OFI_USE_THREAD_DOMAIN
-    #define GASNETC_OFI_TRYLOCK(lock) gasneti_spinlock_trylock(&gasnetc_ofi_locks.big_lock)
-    #define GASNETC_OFI_LOCK(lock) gasneti_spinlock_lock(&gasnetc_ofi_locks.big_lock)
-    #define GASNETC_OFI_UNLOCK(lock) gasneti_spinlock_unlock(&gasnetc_ofi_locks.big_lock)
-    /* When using DOMAIN, all locks use the centralized big_lock */
-    #define GASNETC_OFI_PAR_TRYLOCK(lock) GASNETC_OFI_TRYLOCK(lock)
-    #define GASNETC_OFI_PAR_LOCK(lock) GASNETC_OFI_LOCK(lock)
-    #define GASNETC_OFI_PAR_UNLOCK(lock) GASNETC_OFI_UNLOCK(lock)
-/* This is left here for the purpose of supporting future providers that require fine
- * grained locking. For now, all supported providers either support FI_THREAD_DOMAIN or
- * FI_THREAD_SAFE */
-#elif 0 && GASNET_PAR
-    #define GASNETC_OFI_TRYLOCK(lock) gasneti_spinlock_trylock(lock)
-    #define GASNETC_OFI_LOCK(lock) gasneti_spinlock_lock(lock)
-    #define GASNETC_OFI_UNLOCK(lock) gasneti_spinlock_unlock(lock)
-    #define GASNETC_OFI_PAR_TRYLOCK(lock) gasneti_spinlock_trylock(lock)
-    #define GASNETC_OFI_PAR_LOCK(lock) gasneti_spinlock_lock(lock)
-    #define GASNETC_OFI_PAR_UNLOCK(lock) gasneti_spinlock_unlock(lock)
-#elif GASNET_PAR /* For FI_THREAD_SAFE providers in PAR mode*/
-#define GASNETC_OFI_TRYLOCK(lock) 0
-    #define GASNETC_OFI_LOCK(lock) do{} while(0) 
-    #define GASNETC_OFI_UNLOCK(lock) do{} while(0) 
-    #define GASNETC_OFI_PAR_TRYLOCK(lock) gasneti_spinlock_trylock(lock)
-    #define GASNETC_OFI_PAR_LOCK(lock) gasneti_spinlock_lock(lock)
-    #define GASNETC_OFI_PAR_UNLOCK(lock) gasneti_spinlock_unlock(lock)
-#else /* GASNET_SEQ or GASNET_PARSYNC */
-    #define GASNETC_OFI_TRYLOCK(lock) 0
-    #define GASNETC_OFI_LOCK(lock) do{} while(0) 
-    #define GASNETC_OFI_UNLOCK(lock) do{} while(0) 
-    #define GASNETC_OFI_PAR_TRYLOCK(lock) 0
-    #define GASNETC_OFI_PAR_LOCK(lock) do{} while(0) 
-    #define GASNETC_OFI_PAR_UNLOCK(lock) do{} while(0) 
-#endif
-
-#define GASNETC_OFI_LOCK_EXPR(lock, expr) do { GASNETC_OFI_LOCK(lock); \
-                                               expr; \
-                                               GASNETC_OFI_UNLOCK(lock); \
-                                          } while(0)
 
 /* ------------------------------------------------------------------------------------ */
 /* AM category (recommended impl if supporting PSHM) */
@@ -95,37 +56,6 @@ typedef enum {
 #define GASNETC_STAT_EVENT_VAL(name,val) \
     _GASNETI_STAT_EVENT_VAL(C,name,val)
 
-/* Unnamed struct to hold all the locks needed */
-#if GASNET_PAR && GASNETC_OFI_USE_THREAD_DOMAIN
-struct {
-    gasneti_atomic_t big_lock;
-} gasnetc_ofi_locks;
-#elif GASNET_PAR
-struct {
-    gasneti_atomic_t rx_request_cq;
-    char _pad0[GASNETI_CACHE_PAD(sizeof(gasneti_atomic_t))];
-    gasneti_atomic_t rx_reply_cq;
-} gasnetc_ofi_locks;
-/* This is left here for the purpose of supporting future providers that require fine
- * grained locking. For now, all supported providers either support FI_THREAD_DOMAIN or
- * FI_THREAD_SAFE */
-#elif 0 && GASNET_PAR && !GASNETC_OFI_USE_THREAD_DOMAIN
-struct {
-    gasneti_atomic_t rx_cq;
-    char _pad0[GASNETI_CACHE_PAD(sizeof(gasneti_atomic_t))];
-    gasneti_atomic_t tx_cq;
-    char _pad1[GASNETI_CACHE_PAD(sizeof(gasneti_atomic_t))];
-    gasneti_atomic_t rdma_tx;
-    char _pad2[GASNETI_CACHE_PAD(sizeof(gasneti_atomic_t))];
-    gasneti_atomic_t rdma_rx;
-    char _pad3[GASNETI_CACHE_PAD(sizeof(gasneti_atomic_t))];
-    gasneti_atomic_t am_tx;
-    char _pad4[GASNETI_CACHE_PAD(sizeof(gasneti_atomic_t))];
-    gasneti_atomic_t am_rx;
-
-} gasnetc_ofi_locks;
-#endif
-
 /* These definitions are just to make the polling of the two different AM
  * networks easier to read and understand*/
 #define OFI_POLL_ALL   1
diff --git ofi-conduit/gasnet_ofi.c ofi-conduit/gasnet_ofi.c
index 7088d3515263..dde541bb3120 100644
--- ofi-conduit/gasnet_ofi.c
+++ ofi-conduit/gasnet_ofi.c
@@ -21,6 +21,95 @@
 #include <sys/uio.h> /* For struct iovec */
 #endif
 
+
+/* Globals */
+struct fid_fabric*    gasnetc_ofi_fabricfd;
+struct fid_domain*    gasnetc_ofi_domainfd;
+struct fid_av*        gasnetc_ofi_avfd;
+struct fid_cq*        gasnetc_ofi_tx_cqfd; /* CQ for both AM and RDMA tx ops */
+
+struct fid_ep*        gasnetc_ofi_rdma_epfd;
+struct fid_mr*        gasnetc_ofi_rdma_mrfd;
+
+struct fid_ep*        gasnetc_ofi_request_epfd;
+struct fid_ep*        gasnetc_ofi_reply_epfd;
+struct fid_cq*        gasnetc_ofi_request_cqfd;
+struct fid_cq*        gasnetc_ofi_reply_cqfd;
+
+/* The cut off of when to fully block for a non-blocking put*/
+size_t gasnetc_ofi_bbuf_threshold; 
+
+/* FI_THREAD_DOMAIN providers in PAR mode */
+#if GASNET_PAR && GASNETC_OFI_USE_THREAD_DOMAIN
+    #define GASNETC_OFI_TRYLOCK(lock) gasneti_spinlock_trylock(&gasnetc_ofi_locks.big_lock)
+    #define GASNETC_OFI_LOCK(lock) gasneti_spinlock_lock(&gasnetc_ofi_locks.big_lock)
+    #define GASNETC_OFI_UNLOCK(lock) gasneti_spinlock_unlock(&gasnetc_ofi_locks.big_lock)
+    /* When using DOMAIN, all locks use the centralized big_lock */
+    #define GASNETC_OFI_PAR_TRYLOCK(lock) GASNETC_OFI_TRYLOCK(lock)
+    #define GASNETC_OFI_PAR_LOCK(lock) GASNETC_OFI_LOCK(lock)
+    #define GASNETC_OFI_PAR_UNLOCK(lock) GASNETC_OFI_UNLOCK(lock)
+/* This is left here for the purpose of supporting future providers that require fine
+ * grained locking. For now, all supported providers either support FI_THREAD_DOMAIN or
+ * FI_THREAD_SAFE */
+#elif 0 && GASNET_PAR
+    #define GASNETC_OFI_TRYLOCK(lock) gasneti_spinlock_trylock(lock)
+    #define GASNETC_OFI_LOCK(lock) gasneti_spinlock_lock(lock)
+    #define GASNETC_OFI_UNLOCK(lock) gasneti_spinlock_unlock(lock)
+    #define GASNETC_OFI_PAR_TRYLOCK(lock) gasneti_spinlock_trylock(lock)
+    #define GASNETC_OFI_PAR_LOCK(lock) gasneti_spinlock_lock(lock)
+    #define GASNETC_OFI_PAR_UNLOCK(lock) gasneti_spinlock_unlock(lock)
+#elif GASNET_PAR /* For FI_THREAD_SAFE providers in PAR mode*/
+#define GASNETC_OFI_TRYLOCK(lock) 0
+    #define GASNETC_OFI_LOCK(lock) do{} while(0) 
+    #define GASNETC_OFI_UNLOCK(lock) do{} while(0) 
+    #define GASNETC_OFI_PAR_TRYLOCK(lock) gasneti_spinlock_trylock(lock)
+    #define GASNETC_OFI_PAR_LOCK(lock) gasneti_spinlock_lock(lock)
+    #define GASNETC_OFI_PAR_UNLOCK(lock) gasneti_spinlock_unlock(lock)
+#else /* GASNET_SEQ or GASNET_PARSYNC */
+    #define GASNETC_OFI_TRYLOCK(lock) 0
+    #define GASNETC_OFI_LOCK(lock) do{} while(0) 
+    #define GASNETC_OFI_UNLOCK(lock) do{} while(0) 
+    #define GASNETC_OFI_PAR_TRYLOCK(lock) 0
+    #define GASNETC_OFI_PAR_LOCK(lock) do{} while(0) 
+    #define GASNETC_OFI_PAR_UNLOCK(lock) do{} while(0) 
+#endif
+
+#define GASNETC_OFI_LOCK_EXPR(lock, expr) do { GASNETC_OFI_LOCK(lock); \
+                                               expr; \
+                                               GASNETC_OFI_UNLOCK(lock); \
+                                          } while(0)
+
+/* Unnamed struct to hold all the locks needed */
+#if GASNET_PAR && GASNETC_OFI_USE_THREAD_DOMAIN
+struct {
+    gasneti_atomic_t big_lock;
+} gasnetc_ofi_locks;
+#elif GASNET_PAR
+struct {
+    gasneti_atomic_t rx_request_cq;
+    char _pad0[GASNETI_CACHE_PAD(sizeof(gasneti_atomic_t))];
+    gasneti_atomic_t rx_reply_cq;
+} gasnetc_ofi_locks;
+/* This is left here for the purpose of supporting future providers that require fine
+ * grained locking. For now, all supported providers either support FI_THREAD_DOMAIN or
+ * FI_THREAD_SAFE */
+#elif 0 && GASNET_PAR && !GASNETC_OFI_USE_THREAD_DOMAIN
+struct {
+    gasneti_atomic_t rx_cq;
+    char _pad0[GASNETI_CACHE_PAD(sizeof(gasneti_atomic_t))];
+    gasneti_atomic_t tx_cq;
+    char _pad1[GASNETI_CACHE_PAD(sizeof(gasneti_atomic_t))];
+    gasneti_atomic_t rdma_tx;
+    char _pad2[GASNETI_CACHE_PAD(sizeof(gasneti_atomic_t))];
+    gasneti_atomic_t rdma_rx;
+    char _pad3[GASNETI_CACHE_PAD(sizeof(gasneti_atomic_t))];
+    gasneti_atomic_t am_tx;
+    char _pad4[GASNETI_CACHE_PAD(sizeof(gasneti_atomic_t))];
+    gasneti_atomic_t am_rx;
+
+} gasnetc_ofi_locks;
+#endif
+
 typedef struct gasnetc_ofi_recv_metadata {
     struct iovec iov;
     struct fi_msg am_buff_msg;
diff --git ofi-conduit/gasnet_ofi.h ofi-conduit/gasnet_ofi.h
index fc25a260792e..b1d6f74f2672 100644
--- ofi-conduit/gasnet_ofi.h
+++ ofi-conduit/gasnet_ofi.h
@@ -41,21 +41,21 @@ typedef gasnetc_paratomic(t)         gasnetc_paratomic_t;
 #define gasnetc_paratomic_decrement  gasnetc_paratomic(decrement)
 #define gasnetc_paratomic_decrement_and_test  gasnetc_paratomic(decrement_and_test)
 
-struct fid_fabric*    gasnetc_ofi_fabricfd;
-struct fid_domain*    gasnetc_ofi_domainfd;
-struct fid_av*        gasnetc_ofi_avfd;
-struct fid_cq*        gasnetc_ofi_tx_cqfd; /* CQ for both AM and RDMA tx ops */
+extern struct fid_fabric*    gasnetc_ofi_fabricfd;
+extern struct fid_domain*    gasnetc_ofi_domainfd;
+extern struct fid_av*        gasnetc_ofi_avfd;
+extern struct fid_cq*        gasnetc_ofi_tx_cqfd; /* CQ for both AM and RDMA tx ops */
 
-struct fid_ep*        gasnetc_ofi_rdma_epfd;
-struct fid_mr*        gasnetc_ofi_rdma_mrfd;
+extern struct fid_ep*        gasnetc_ofi_rdma_epfd;
+extern struct fid_mr*        gasnetc_ofi_rdma_mrfd;
 
-struct fid_ep*        gasnetc_ofi_request_epfd;
-struct fid_ep*        gasnetc_ofi_reply_epfd;
-struct fid_cq*        gasnetc_ofi_request_cqfd;
-struct fid_cq*        gasnetc_ofi_reply_cqfd;
+extern struct fid_ep*        gasnetc_ofi_request_epfd;
+extern struct fid_ep*        gasnetc_ofi_reply_epfd;
+extern struct fid_cq*        gasnetc_ofi_request_cqfd;
+extern struct fid_cq*        gasnetc_ofi_reply_cqfd;
 
 /* The cut off of when to fully block for a non-blocking put*/
-size_t gasnetc_ofi_bbuf_threshold; 
+extern size_t gasnetc_ofi_bbuf_threshold;
 /* Address table data */
 typedef void*                     conn_entry_t;
 typedef struct
@@ -193,6 +193,6 @@ int gasnetc_rdma_put_non_bulk(gasnet_node_t dest, void* dest_addr, void* src_add
 void gasnetc_rdma_put_wait(gasnet_handle_t op);
 void gasnetc_rdma_get_wait(gasnet_handle_t op);
 
-int gasnetc_exit_in_progress;
+extern int gasnetc_exit_in_progress;
 
 #endif /*GASNET_OFI_H*/
openSUSE Build Service is sponsored by