From 808406b8247fab36ae3b0ecdb9bdfcce578bad6f Mon Sep 17 00:00:00 2001 From: Sergey Oblomov Date: Wed, 1 Nov 2017 13:39:22 +0200 Subject: [PATCH] UCX/API: external API is wrapped into -=extern "C"=- - added 'extern "C"' wrapper around public functions definitions --- src/ucp/api/ucp.h | 3 +++ src/ucp/api/ucp_compat.h | 3 +++ src/ucs/algorithm/crc.h | 5 +++++ src/ucs/algorithm/qsort_r.h | 4 ++++ src/ucs/arch/aarch64/cpu.h | 10 ++++++++-- src/ucs/arch/ppc64/cpu.h | 4 ++++ src/ucs/arch/x86_64/cpu.h | 3 +++ src/ucs/async/async.h | 4 ++++ src/ucs/async/async_fwd.h | 2 ++ src/ucs/config/global_opts.h | 4 ++++ src/ucs/config/parser.h | 4 ++++ src/ucs/datastruct/callbackq.h | 4 ++++ src/ucs/datastruct/mpool.h | 4 ++++ src/ucs/debug/log.h | 3 +++ src/ucs/debug/memtrack.h | 4 ++++ src/ucs/stats/stats.h | 6 ++++++ src/ucs/stats/stats_fwd.h | 5 +++++ src/ucs/sys/math.h | 2 ++ src/ucs/sys/string.h | 4 ++++ src/ucs/sys/sys.h | 3 +++ src/ucs/time/time.h | 3 +++ src/ucs/type/class.h | 3 +++ src/ucs/type/component.h | 2 ++ src/ucs/type/spinlock.h | 3 +++ src/ucs/type/status.h | 2 ++ src/uct/api/tl.h | 2 ++ src/uct/api/uct.h | 4 ++++ src/uct/ib/ud/base/ud_iface.h | 4 ++++ test/gtest/common/main.cc | 2 -- test/gtest/common/test.cc | 2 -- test/gtest/common/test.h | 2 -- test/gtest/common/test_helpers.cc | 2 -- test/gtest/ucp/ucp_test.cc | 2 -- test/gtest/ucp/ucp_test.h | 2 -- test/gtest/uct/test_rc.h | 7 +++---- test/gtest/uct/uct_test.cc | 3 +-- test/gtest/uct/uct_test.h | 2 -- test/gtest/uct/ud_base.h | 4 +--- 38 files changed, 107 insertions(+), 25 deletions(-) diff --git a/src/ucp/api/ucp.h b/src/ucp/api/ucp.h index 4d24cd68bc2..202dec16eb1 100644 --- a/src/ucp/api/ucp.h +++ b/src/ucp/api/ucp.h @@ -14,8 +14,10 @@ #include #include #include +#include #include +BEGIN_C_DECLS /** * @defgroup UCP_API Unified Communication Protocol (UCP) API @@ -2446,5 +2448,6 @@ ucs_status_t ucp_worker_flush(ucp_worker_h worker); * UCP hello world client / server example utility. */ +END_C_DECLS #endif diff --git a/src/ucp/api/ucp_compat.h b/src/ucp/api/ucp_compat.h index cd0efc24519..7cb577ad8a8 100644 --- a/src/ucp/api/ucp_compat.h +++ b/src/ucp/api/ucp_compat.h @@ -10,7 +10,9 @@ #include +#include +BEGIN_C_DECLS /** * @ingroup UCP_COMM @@ -32,5 +34,6 @@ void ucp_request_release(void *request); */ void ucp_ep_destroy(ucp_ep_h ep); +END_C_DECLS #endif diff --git a/src/ucs/algorithm/crc.h b/src/ucs/algorithm/crc.h index 89535b4ace8..42da1b50a4f 100644 --- a/src/ucs/algorithm/crc.h +++ b/src/ucs/algorithm/crc.h @@ -10,6 +10,10 @@ #include #include +#include + +BEGIN_C_DECLS + /** * Calculate CRC16 of an arbitrary buffer. * @@ -26,5 +30,6 @@ uint16_t ucs_crc16(const void *buffer, size_t size); */ uint16_t ucs_crc16_string(const char *s); +END_C_DECLS #endif diff --git a/src/ucs/algorithm/qsort_r.h b/src/ucs/algorithm/qsort_r.h index 564140ada52..9894c875a2d 100644 --- a/src/ucs/algorithm/qsort_r.h +++ b/src/ucs/algorithm/qsort_r.h @@ -37,6 +37,9 @@ #include +#include + +BEGIN_C_DECLS /** * Compare callback for @ref qsort_r. @@ -59,5 +62,6 @@ typedef int ucs_qsort_r_compare_cb_t(const void *elem1, const void *elem2, void ucs_qsort_r(void *base, size_t nmemb, size_t size, ucs_qsort_r_compare_cb_t *compare, void *arg); +END_C_DECLS #endif diff --git a/src/ucs/arch/aarch64/cpu.h b/src/ucs/arch/aarch64/cpu.h index c40d179a05a..431c02519b2 100644 --- a/src/ucs/arch/aarch64/cpu.h +++ b/src/ucs/arch/aarch64/cpu.h @@ -11,6 +11,7 @@ #include "config.h" #include #include +#include #include #if __ARM_NEON #include @@ -19,6 +20,8 @@ #define UCS_ARCH_CACHE_LINE_SIZE 64 +BEGIN_C_DECLS + /** * Assume the worst - weak memory ordering. */ @@ -63,8 +66,6 @@ static inline int ucs_arch_get_cpu_flag() return UCS_CPU_FLAG_UNKNOWN; } -#endif - static inline void ucs_arch_wait_mem(void *address) { unsigned long tmp; @@ -73,3 +74,8 @@ static inline void ucs_arch_wait_mem(void *address) : "=&r"(tmp) : "r"(address)); } + +END_C_DECLS + +#endif + diff --git a/src/ucs/arch/ppc64/cpu.h b/src/ucs/arch/ppc64/cpu.h index 77ae29f98de..ae067c576ab 100644 --- a/src/ucs/arch/ppc64/cpu.h +++ b/src/ucs/arch/ppc64/cpu.h @@ -13,9 +13,11 @@ #ifdef HAVE_SYS_PLATFORM_PPC_H # include #endif +#include #include #include +BEGIN_C_DECLS #define UCS_ARCH_CACHE_LINE_SIZE 128 @@ -53,4 +55,6 @@ double ucs_arch_get_clocks_per_sec(); #define ucs_arch_wait_mem ucs_arch_generic_wait_mem +END_C_DECLS + #endif diff --git a/src/ucs/arch/x86_64/cpu.h b/src/ucs/arch/x86_64/cpu.h index 8b24b524474..583b06ad80f 100644 --- a/src/ucs/arch/x86_64/cpu.h +++ b/src/ucs/arch/x86_64/cpu.h @@ -10,6 +10,7 @@ #include #include +#include #include #ifdef __SSE4_1__ @@ -19,6 +20,7 @@ # include #endif +BEGIN_C_DECLS #define UCS_ARCH_CACHE_LINE_SIZE 64 @@ -48,6 +50,7 @@ ucs_cpu_flag_t ucs_arch_get_cpu_flag() UCS_F_NOOPTIMIZE; #define ucs_arch_wait_mem ucs_arch_generic_wait_mem +END_C_DECLS #endif diff --git a/src/ucs/async/async.h b/src/ucs/async/async.h index 27278995cd0..5a2115f4f1a 100644 --- a/src/ucs/async/async.h +++ b/src/ucs/async/async.h @@ -11,10 +11,12 @@ #include "signal.h" #include "async_fwd.h" +#include #include #include #include +BEGIN_C_DECLS /** * Async event context. Manages timer and fd notifications. @@ -119,4 +121,6 @@ static inline int ucs_async_check_miss(ucs_async_context_t *async) } while (0) +END_C_DECLS + #endif diff --git a/src/ucs/async/async_fwd.h b/src/ucs/async/async_fwd.h index 281dc0a2347..20732ec29b8 100644 --- a/src/ucs/async/async_fwd.h +++ b/src/ucs/async/async_fwd.h @@ -10,6 +10,7 @@ #include #include +BEGIN_C_DECLS typedef struct ucs_async_context ucs_async_context_t; @@ -121,5 +122,6 @@ void ucs_async_poll(ucs_async_context_t *async); void __ucs_async_poll_missed(ucs_async_context_t *async); +END_C_DECLS #endif diff --git a/src/ucs/config/global_opts.h b/src/ucs/config/global_opts.h index aa82249a2e7..92252e4c249 100644 --- a/src/ucs/config/global_opts.h +++ b/src/ucs/config/global_opts.h @@ -11,9 +11,11 @@ #include #include +#include #include #include +BEGIN_C_DECLS /** @@ -108,4 +110,6 @@ ucs_status_t ucs_global_opts_clone(void *dst); void ucs_global_opts_release(); void ucs_global_opts_print(FILE *stream, ucs_config_print_flags_t print_flags); +END_C_DECLS + #endif diff --git a/src/ucs/config/parser.h b/src/ucs/config/parser.h index 0a3916f1e81..62b95139d35 100644 --- a/src/ucs/config/parser.h +++ b/src/ucs/config/parser.h @@ -11,12 +11,14 @@ #include #include +#include #include #define UCS_CONFIG_PREFIX "UCX_" #define UCS_CONFIG_ARRAY_MAX 128 +BEGIN_C_DECLS /* * Configuration varaibles syntax: @@ -326,4 +328,6 @@ size_t ucs_config_memunits_get(size_t config_size, size_t auto_size, int ucs_config_names_search(ucs_config_names_array_t config_names, const char *str); +END_C_DECLS + #endif diff --git a/src/ucs/datastruct/callbackq.h b/src/ucs/datastruct/callbackq.h index 4c10dd583c2..f36990880a8 100644 --- a/src/ucs/datastruct/callbackq.h +++ b/src/ucs/datastruct/callbackq.h @@ -11,6 +11,9 @@ #include #include #include +#include + +BEGIN_C_DECLS /* * @@ -236,6 +239,7 @@ void ucs_callbackq_add_slow_path(ucs_callbackq_t *cbq, void ucs_callbackq_remove_slow_path(ucs_callbackq_t *cbq, ucs_callbackq_slow_elem_t* elem); +END_C_DECLS /** * Remove all slow path elements with a given callback function from the list. diff --git a/src/ucs/datastruct/mpool.h b/src/ucs/datastruct/mpool.h index e739d762a2b..860d3822395 100644 --- a/src/ucs/datastruct/mpool.h +++ b/src/ucs/datastruct/mpool.h @@ -11,6 +11,9 @@ #include #include #include +#include + +BEGIN_C_DECLS typedef struct ucs_mpool_chunk ucs_mpool_chunk_t; @@ -235,5 +238,6 @@ void ucs_mpool_chunk_munmap(ucs_mpool_t *mp, void *chunk); ucs_status_t ucs_mpool_hugetlb_malloc(ucs_mpool_t *mp, size_t *size_p, void **chunk_p); void ucs_mpool_hugetlb_free(ucs_mpool_t *mp, void *chunk); +END_C_DECLS #endif /* MPOOL_H_ */ diff --git a/src/ucs/debug/log.h b/src/ucs/debug/log.h index 359508b68f5..91ef2461485 100644 --- a/src/ucs/debug/log.h +++ b/src/ucs/debug/log.h @@ -16,6 +16,7 @@ #include #include +BEGIN_C_DECLS #define ucs_log_enabled(_level) \ ucs_unlikely(((_level) <= UCS_MAX_LOG_LEVEL) && ((_level) <= (ucs_global_opts.log_level))) @@ -144,5 +145,7 @@ const char *ucs_log_dump_hex(const void* data, size_t length, char *buf, size_t void ucs_log_push_handler(ucs_log_func_t handler); void ucs_log_pop_handler(); +END_C_DECLS + #endif diff --git a/src/ucs/debug/memtrack.h b/src/ucs/debug/memtrack.h index efc45339838..695620ecbc7 100644 --- a/src/ucs/debug/memtrack.h +++ b/src/ucs/debug/memtrack.h @@ -11,11 +11,14 @@ # include "config.h" #endif +#include + #include #include #include #include +BEGIN_C_DECLS enum { UCS_MEMTRACK_STAT_ALLOCATION_COUNT, @@ -158,5 +161,6 @@ char *ucs_strdup(const char *src, const char *name); #endif /* ENABLE_MEMTRACK */ +END_C_DECLS #endif diff --git a/src/ucs/stats/stats.h b/src/ucs/stats/stats.h index fe339ecc08c..9e9c5fa5144 100644 --- a/src/ucs/stats/stats.h +++ b/src/ucs/stats/stats.h @@ -12,6 +12,10 @@ # include "config.h" #endif +#include + +BEGIN_C_DECLS + void ucs_stats_init(); void ucs_stats_cleanup(); void ucs_stats_dump(); @@ -104,4 +108,6 @@ void ucs_stats_node_free(ucs_stats_node_t *node); #endif +END_C_DECLS + #endif diff --git a/src/ucs/stats/stats_fwd.h b/src/ucs/stats/stats_fwd.h index 0d9fb4d3043..69a0d722013 100644 --- a/src/ucs/stats/stats_fwd.h +++ b/src/ucs/stats/stats_fwd.h @@ -9,6 +9,9 @@ #include +#include + +BEGIN_C_DECLS typedef uint64_t ucs_stats_counter_t; /* Stats counter*/ typedef struct ucs_stats_class ucs_stats_class_t; /* Stats class */ @@ -25,4 +28,6 @@ typedef enum { extern const char *ucs_stats_formats_names[]; ucs_stats_node_t * ucs_stats_get_root(); +END_C_DECLS + #endif /* STATS_FD_H_ */ diff --git a/src/ucs/sys/math.h b/src/ucs/sys/math.h index e22fe352296..14944598455 100644 --- a/src/ucs/sys/math.h +++ b/src/ucs/sys/math.h @@ -15,6 +15,7 @@ #include #include +BEGIN_C_DECLS #define UCS_KBYTE (1ull << 10) #define UCS_MBYTE (1ull << 20) @@ -147,5 +148,6 @@ uint32_t ucs_calc_crc32(uint32_t crc, const void *buf, size_t size); */ uint64_t ucs_get_prime(unsigned index); +END_C_DECLS #endif /* MACROS_H_ */ diff --git a/src/ucs/sys/string.h b/src/ucs/sys/string.h index 6fad8b816ad..8d8a240b804 100644 --- a/src/ucs/sys/string.h +++ b/src/ucs/sys/string.h @@ -11,7 +11,9 @@ #include #include +#include +BEGIN_C_DECLS /** * Expand a partial path to full path. @@ -71,4 +73,6 @@ uint64_t ucs_string_to_id(const char *str); void ucs_memunits_to_str(size_t value, char *buf, size_t max); +END_C_DECLS + #endif diff --git a/src/ucs/sys/sys.h b/src/ucs/sys/sys.h index 3899304e80e..ef2daa83d69 100644 --- a/src/ucs/sys/sys.h +++ b/src/ucs/sys/sys.h @@ -44,6 +44,7 @@ #include #include +BEGIN_C_DECLS /** * @return Host name. @@ -254,4 +255,6 @@ ucs_status_t ucs_empty_function_return_ep_timeout(); ssize_t ucs_empty_function_return_bc_ep_timeout(); ucs_status_t ucs_empty_function_return_busy(); +END_C_DECLS + #endif diff --git a/src/ucs/time/time.h b/src/ucs/time/time.h index 4c154c23091..1725e6f1c18 100644 --- a/src/ucs/time/time.h +++ b/src/ucs/time/time.h @@ -12,6 +12,7 @@ #include #include +BEGIN_C_DECLS /** * Short time type @@ -132,4 +133,6 @@ static inline void ucs_sec_to_timespec(double seconds, struct timespec *ts) ts->tv_nsec = nsec % UCS_NSEC_PER_SEC; } +END_C_DECLS + #endif diff --git a/src/ucs/type/class.h b/src/ucs/type/class.h index 92eda395565..1adffbabbe9 100644 --- a/src/ucs/type/class.h +++ b/src/ucs/type/class.h @@ -11,6 +11,7 @@ #include #include +BEGIN_C_DECLS typedef struct ucs_class ucs_class_t; @@ -302,4 +303,6 @@ void ucs_class_free(void *obj); */ UCS_CLASS_DECLARE(void); +END_C_DECLS + #endif diff --git a/src/ucs/type/component.h b/src/ucs/type/component.h index d0d98f2b1da..6963537a6fd 100644 --- a/src/ucs/type/component.h +++ b/src/ucs/type/component.h @@ -12,6 +12,7 @@ #include #include +BEGIN_C_DECLS /* * Component definition - used internally. @@ -143,6 +144,7 @@ size_t __ucs_components_total_size(ucs_list_link_t *list, size_t base_size); ucs_status_t __ucs_components_init_all(ucs_list_link_t *list, void *base_ptr); void __ucs_components_cleanup_all(ucs_list_link_t *list, void *base_ptr); +END_C_DECLS #endif /* COMPONENT_H_ */ diff --git a/src/ucs/type/spinlock.h b/src/ucs/type/spinlock.h index eabc503770a..2a7d77b55bf 100644 --- a/src/ucs/type/spinlock.h +++ b/src/ucs/type/spinlock.h @@ -10,6 +10,7 @@ #include #include +BEGIN_C_DECLS /** * Reentrant spinlock. @@ -93,4 +94,6 @@ static inline void ucs_spin_unlock(ucs_spinlock_t *lock) } } +END_C_DECLS + #endif diff --git a/src/ucs/type/status.h b/src/ucs/type/status.h index 9107f6e2f7e..85b35ad5795 100644 --- a/src/ucs/type/status.h +++ b/src/ucs/type/status.h @@ -11,6 +11,7 @@ #include +BEGIN_C_DECLS /** * @defgroup UCS_API Unified Communication Services (UCS) API @@ -111,5 +112,6 @@ typedef void *ucs_status_ptr_t; */ const char *ucs_status_string(ucs_status_t status); +END_C_DECLS #endif diff --git a/src/uct/api/tl.h b/src/uct/api/tl.h index 1fc131b20ae..132a0275a80 100644 --- a/src/uct/api/tl.h +++ b/src/uct/api/tl.h @@ -17,6 +17,7 @@ #include #include +BEGIN_C_DECLS /** * Transport iface operations. @@ -226,5 +227,6 @@ struct uct_recv_desc { #define uct_recv_desc(_desc) \ ( *( ( (uct_recv_desc_t**)(_desc) ) - 1) ) +END_C_DECLS #endif diff --git a/src/uct/api/uct.h b/src/uct/api/uct.h index 8633539bfb0..668bd19163e 100644 --- a/src/uct/api/uct.h +++ b/src/uct/api/uct.h @@ -19,11 +19,14 @@ #include #include #include +#include #include #include #include +BEGIN_C_DECLS + /** * @defgroup UCT_API Unified Communication Transport (UCT) API * @{ @@ -2087,5 +2090,6 @@ UCT_INLINE_API ucs_status_t uct_iface_tag_recv_cancel(uct_iface_h iface, * UCT hello world client / server example utility. */ +END_C_DECLS #endif diff --git a/src/uct/ib/ud/base/ud_iface.h b/src/uct/ib/ud/base/ud_iface.h index dda9579401d..82e362e42ed 100644 --- a/src/uct/ib/ud/base/ud_iface.h +++ b/src/uct/ib/ud/base/ud_iface.h @@ -16,10 +16,12 @@ #include #include #include +#include #include "ud_def.h" #include "ud_ep.h" +BEGIN_C_DECLS #define UCT_UD_MIN_INLINE 48 @@ -447,4 +449,6 @@ uct_ud_iface_dispatch_zcopy_comps(uct_ud_iface_t *iface) #define UCT_UD_CHECK_BCOPY_LENGTH(iface, len) #endif +END_C_DECLS + #endif diff --git a/test/gtest/common/main.cc b/test/gtest/common/main.cc index 913d4f53f8d..fe7ca2b50a8 100644 --- a/test/gtest/common/main.cc +++ b/test/gtest/common/main.cc @@ -4,13 +4,11 @@ * See file LICENSE for terms. */ -extern "C" { #ifdef HAVE_CONFIG_H # include "config.h" #endif #include #include -} #include #include "test_helpers.h" #include "tap.h" diff --git a/test/gtest/common/test.cc b/test/gtest/common/test.cc index c9d502180bf..4ad77f337c4 100644 --- a/test/gtest/common/test.cc +++ b/test/gtest/common/test.cc @@ -6,11 +6,9 @@ #include "test.h" -extern "C" { #include #include #include -} namespace ucs { diff --git a/test/gtest/common/test.h b/test/gtest/common/test.h index a7ba0d5e177..b5bbe82b2ca 100644 --- a/test/gtest/common/test.h +++ b/test/gtest/common/test.h @@ -9,11 +9,9 @@ #include "test_helpers.h" -extern "C" { #include #include #include -} #include #include diff --git a/test/gtest/common/test_helpers.cc b/test/gtest/common/test_helpers.cc index 126edba6a84..4b660cc1481 100644 --- a/test/gtest/common/test_helpers.cc +++ b/test/gtest/common/test_helpers.cc @@ -6,11 +6,9 @@ #include "test_helpers.h" -extern "C" { #include #include #include -} namespace ucs { diff --git a/test/gtest/ucp/ucp_test.cc b/test/gtest/ucp/ucp_test.cc index f83a416692e..2cd147f3084 100644 --- a/test/gtest/ucp/ucp_test.cc +++ b/test/gtest/ucp/ucp_test.cc @@ -6,10 +6,8 @@ #include "ucp_test.h" #include -extern "C" { #include #include -} std::string ucp_test::m_last_err_msg; diff --git a/test/gtest/ucp/ucp_test.h b/test/gtest/ucp/ucp_test.h index 069f8e35e36..ddadfae5754 100644 --- a/test/gtest/ucp/ucp_test.h +++ b/test/gtest/ucp/ucp_test.h @@ -6,7 +6,6 @@ #ifndef UCP_TEST_H_ #define UCP_TEST_H_ -extern "C" { #include #include @@ -15,7 +14,6 @@ extern "C" { #error possible bug in UCP version #endif -} #include #define MT_TEST_NUM_THREADS 4 diff --git a/test/gtest/uct/test_rc.h b/test/gtest/uct/test_rc.h index 9743504bec9..c10e9e84798 100644 --- a/test/gtest/uct/test_rc.h +++ b/test/gtest/uct/test_rc.h @@ -7,13 +7,12 @@ #ifndef UCT_RC_TEST_H_ #define UCT_RC_TEST_H_ -extern "C" { +#include +#include + #include #include #include -} -#include -#include "uct_test.h" class test_rc : public uct_test { public: diff --git a/test/gtest/uct/uct_test.cc b/test/gtest/uct/uct_test.cc index 56745600551..3707db4ed80 100644 --- a/test/gtest/uct/uct_test.cc +++ b/test/gtest/uct/uct_test.cc @@ -6,9 +6,8 @@ #include "uct_test.h" -extern "C" { #include -} +#include #include #include #include diff --git a/test/gtest/uct/uct_test.h b/test/gtest/uct/uct_test.h index 569341d8d55..31145c3ef88 100644 --- a/test/gtest/uct/uct_test.h +++ b/test/gtest/uct/uct_test.h @@ -9,11 +9,9 @@ #ifndef UCT_TEST_H_ #define UCT_TEST_H_ -extern "C" { #include #include #include -} #include #include diff --git a/test/gtest/uct/ud_base.h b/test/gtest/uct/ud_base.h index a5f1bd25a17..8f6c33bd8ce 100644 --- a/test/gtest/uct/ud_base.h +++ b/test/gtest/uct/ud_base.h @@ -6,13 +6,11 @@ #ifndef _UD_BASE_TEST #define _UD_BASE_TEST -#include "uct_test.h" -extern "C" { +#include #include #include #include #include -}; #define TEST_UD_PROGRESS_TIMEOUT 300.0 #define TEST_UD_TIMEOUT_IN_SEC 10.0