Skip to content

Commit

Permalink
Merge pull request #10456 from evgeny-leksikov/ucx_strict_headers
Browse files Browse the repository at this point in the history
CONTRIB: check install headers with -Werror=strict-prototypes
  • Loading branch information
yosefe authored Jan 31, 2025
2 parents 27a36ed + be7dd0b commit dda920b
Show file tree
Hide file tree
Showing 58 changed files with 328 additions and 275 deletions.
2 changes: 1 addition & 1 deletion contrib/check_inst_headers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ do
fi

# try to compile a test program (from stdin) which includes hfile
for compile in "${CC} -x c" "${CXX} -x c++"
for compile in "${CC} -Werror=strict-prototypes -x c" "${CXX} -x c++"
do
${compile} -I. -c - -o /dev/null -DHAVE_CONFIG_H=1 <<EOF
#include "${hfile}"
Expand Down
4 changes: 2 additions & 2 deletions src/tools/perf/lib/libperf_memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -340,15 +340,15 @@ void ucx_perf_global_init()
{
static ucx_perf_allocator_t host_allocator = {
.mem_type = UCS_MEMORY_TYPE_HOST,
.init = ucs_empty_function_return_success,
.init = (ucx_perf_init_func_t)ucs_empty_function_return_success,
.uct_alloc = uct_perf_test_alloc_host,
.uct_free = uct_perf_test_free_host,
.memcpy = ucx_perf_test_memcpy_host,
.memset = memset
};
static ucx_perf_allocator_t rdma_allocator = {
.mem_type = UCS_MEMORY_TYPE_RDMA,
.init = ucs_empty_function_return_success,
.init = (ucx_perf_init_func_t)ucs_empty_function_return_success,
.uct_alloc = (ucx_perf_uct_alloc_func_t)ucs_empty_function_do_assert,
.uct_free = (ucx_perf_uct_free_func_t)ucs_empty_function_do_assert,
.memcpy = (ucx_perf_memcpy_func_t)ucs_empty_function_do_assert,
Expand Down
11 changes: 7 additions & 4 deletions src/ucp/core/ucp_mm.c
Original file line number Diff line number Diff line change
Expand Up @@ -907,8 +907,9 @@ ucp_memh_find_slow(ucp_context_h context, void *address, size_t length,
uct_flags |= UCP_MM_UCT_ACCESS_FLAGS(memh->uct_flags);

/* Invalidate the mismatching region and get a new one */
ucs_rcache_region_invalidate(context->rcache, &memh->super,
ucs_empty_function, NULL);
ucs_rcache_region_invalidate(
context->rcache, &memh->super,
(ucs_rcache_invalidate_comp_func_t)ucs_empty_function, NULL);
ucp_memh_put(memh);
}
}
Expand Down Expand Up @@ -1974,8 +1975,10 @@ ucp_memh_import(ucp_context_h context, const void *export_mkey_buffer,
"This may indicate that exported memory handle was "
"destroyed, but imported memory handle was not",
rregion->refcount);
ucs_rcache_region_invalidate(rcache, rregion,
ucs_empty_function, NULL);
ucs_rcache_region_invalidate(
rcache, rregion,
(ucs_rcache_invalidate_comp_func_t)ucs_empty_function,
NULL);
ucs_rcache_region_put_unsafe(rcache, rregion);
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/ucp/core/ucp_worker.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,16 +109,16 @@ static void ucp_am_mpool_obj_str(ucs_mpool_t *mp, void *obj,
ucs_mpool_ops_t ucp_am_mpool_ops = {
.chunk_alloc = ucs_mpool_hugetlb_malloc,
.chunk_release = ucs_mpool_hugetlb_free,
.obj_init = ucs_empty_function,
.obj_cleanup = ucs_empty_function,
.obj_init = (ucs_mpool_obj_init_func_t)ucs_empty_function,
.obj_cleanup = (ucs_mpool_obj_cleanup_func_t)ucs_empty_function,
.obj_str = ucp_am_mpool_obj_str
};

ucs_mpool_ops_t ucp_reg_mpool_ops = {
.chunk_alloc = ucp_reg_mpool_malloc,
.chunk_release = ucp_reg_mpool_free,
.obj_init = ucp_mpool_obj_init,
.obj_cleanup = ucs_empty_function,
.obj_cleanup = (ucs_mpool_obj_cleanup_func_t)ucs_empty_function,
.obj_str = NULL
};

Expand Down
2 changes: 1 addition & 1 deletion src/ucp/rndv/rndv.c
Original file line number Diff line number Diff line change
Expand Up @@ -1129,7 +1129,7 @@ ucs_mpool_ops_t ucp_frag_mpool_ops = {
.chunk_alloc = ucp_frag_mpool_malloc,
.chunk_release = ucp_frag_mpool_free,
.obj_init = ucp_frag_mpool_obj_init,
.obj_cleanup = ucs_empty_function
.obj_cleanup = (ucs_mpool_obj_cleanup_func_t)ucs_empty_function
};

ucp_mem_desc_t *
Expand Down
10 changes: 5 additions & 5 deletions src/ucs/async/async.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,14 @@ static ucs_async_ops_t ucs_async_poll_ops = {
.block = ucs_empty_function,
.unblock = ucs_empty_function,
.context_init = ucs_async_poll_init,
.context_cleanup = ucs_empty_function,
.context_cleanup = (ucs_async_context_cleanup_t)ucs_empty_function,
.context_try_block = ucs_async_poll_tryblock,
.context_unblock = ucs_empty_function,
.context_unblock = (ucs_async_context_unblock_t)ucs_empty_function,
.add_event_fd = (ucs_async_add_event_fd_t)ucs_empty_function_return_success,
.remove_event_fd = ucs_empty_function_return_success,
.remove_event_fd = (ucs_async_remove_event_fd_t)ucs_empty_function_return_success,
.modify_event_fd = (ucs_async_modify_event_fd_t)ucs_empty_function_return_success,
.add_timer = ucs_empty_function_return_success,
.remove_timer = ucs_empty_function_return_success,
.add_timer = (ucs_async_add_timer_t)ucs_empty_function_return_success,
.remove_timer = (ucs_async_remove_timer_t)ucs_empty_function_return_success,
};

static inline khiter_t ucs_async_handler_kh_get(int id)
Expand Down
2 changes: 1 addition & 1 deletion src/ucs/async/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ ucs_async_ops_t ucs_async_signal_ops = {
.block = ucs_async_signal_block_all,
.unblock = ucs_async_signal_unblock_all,
.context_init = ucs_async_signal_init,
.context_cleanup = ucs_async_signal_cleanup,
.context_cleanup = (ucs_async_context_cleanup_t)ucs_async_signal_cleanup,
.context_try_block = ucs_async_signal_try_block,
.context_unblock = ucs_async_signal_unblock,
.add_event_fd = ucs_async_signal_add_event_fd,
Expand Down
6 changes: 3 additions & 3 deletions src/ucs/config/global_opts.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,15 @@ typedef struct {

extern ucs_global_opts_t ucs_global_opts;

void ucs_global_opts_init();
void ucs_global_opts_cleanup();
void ucs_global_opts_init(void);
void ucs_global_opts_cleanup(void);
ucs_status_t ucs_global_opts_set_value(const char *name, const char *value);
ucs_status_t ucs_global_opts_set_value_modifiable(const char *name,
const char *value);
ucs_status_t ucs_global_opts_get_value(const char *name, char *value,
size_t max);
ucs_status_t ucs_global_opts_clone(void *dst);
void ucs_global_opts_release();
void ucs_global_opts_release(void);
void ucs_global_opts_print(FILE *stream, ucs_config_print_flags_t print_flags);

END_C_DECLS
Expand Down
4 changes: 2 additions & 2 deletions src/ucs/config/parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ void ucs_config_parse_config_file(const char *dir_path, const char *file_name,
* Parse configuration files. This function searches for config in several
* locations and parses them in order of precedence.
*/
void ucs_config_parse_config_files();
void ucs_config_parse_config_files(void);


/**
Expand Down Expand Up @@ -632,7 +632,7 @@ void ucs_config_parser_get_env_vars(ucs_string_buffer_t *env_strb,
/**
* Global cleanup of the configuration parser.
*/
void ucs_config_parser_cleanup();
void ucs_config_parser_cleanup(void);


END_C_DECLS
Expand Down
92 changes: 64 additions & 28 deletions src/ucs/datastruct/mpool.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,60 +89,96 @@ struct ucs_mpool_data {
};


/**
* Allocate a chunk of memory to be used by the mpool.
*
* @param mp Memory pool structure.
* @param size_p Points to minimal size to allocate. The function may
* modify it to the actual allocated size. which must be
* larger or equal.
* @param chunk_p Filled with a pointer to the allocated chunk.
*
* @return Error status.
*/
typedef ucs_status_t (*ucs_mpool_chunk_alloc_func_t)(ucs_mpool_t *mp,
size_t *size_p,
void **chunk_p);


/**
* Release previously allocated chunk of memory.
*
* @param mp Memory pool structure.
* @param chunk Chunk to release.
*/
typedef void (*ucs_mpool_chunk_release_func_t)(ucs_mpool_t *mp, void *chunk);


/**
* Initialize an object in the memory pool on the first time it's allocated.
* May be NULL.
*
* @param mp Memory pool structure.
* @param obj Object to initialize.
* @param chunk The chunk on which the object was allocated, as returned
* from chunk_alloc().
*/
typedef void (*ucs_mpool_obj_init_func_t)(ucs_mpool_t *mp, void *obj, void *chunk);


/**
* Cleanup an object in the memory pool just before its memory is released.
* May be NULL.
*
* @param mp Memory pool structure.
* @param obj Object to initialize.
*/
typedef void (*ucs_mpool_obj_cleanup_func_t)(ucs_mpool_t *mp, void *obj);


/**
* Return a string representing the object, used for debug.
* May be NULL.
*
* @param mp Memory pool structure.
* @param obj Object to show.
* @param strb String buffer to fill with object information.
*/
typedef void (*ucs_mpool_obj_str_func_t)(ucs_mpool_t *mp, void *obj,
ucs_string_buffer_t *strb);


/**
* Defines callbacks for memory pool operations.
*/
struct ucs_mpool_ops {
/**
* Allocate a chunk of memory to be used by the mpool.
*
* @param mp Memory pool structure.
* @param size_p Points to minimal size to allocate. The function may
* modify it to the actual allocated size. which must be
* larger or equal.
* @param chunk_p Filled with a pointer to the allocated chunk.
*
* @return Error status.
*/
ucs_status_t (*chunk_alloc)(ucs_mpool_t *mp, size_t *size_p, void **chunk_p);
ucs_mpool_chunk_alloc_func_t chunk_alloc;

/**
* Release previously allocated chunk of memory.
*
* @param mp Memory pool structure.
* @param chunk Chunk to release.
*/
void (*chunk_release)(ucs_mpool_t *mp, void *chunk);
ucs_mpool_chunk_release_func_t chunk_release;

/**
* Initialize an object in the memory pool on the first time it's allocated.
* May be NULL.
*
* @param mp Memory pool structure.
* @param obj Object to initialize.
* @param chunk The chunk on which the object was allocated, as returned
* from chunk_alloc().
*/
void (*obj_init)(ucs_mpool_t *mp, void *obj, void *chunk);
ucs_mpool_obj_init_func_t obj_init;

/**
* Cleanup an object in the memory pool just before its memory is released.
* May be NULL.
*
* @param mp Memory pool structure.
* @param obj Object to initialize.
*/
void (*obj_cleanup)(ucs_mpool_t *mp, void *obj);
ucs_mpool_obj_cleanup_func_t obj_cleanup;

/**
* Return a string representing the object, used for debug.
* May be NULL.
*
* @param mp Memory pool structure.
* @param obj Object to show.
* @param strb String buffer to fill with object information.
*/
void (*obj_str)(ucs_mpool_t *mp, void *obj, ucs_string_buffer_t *strb);
ucs_mpool_obj_str_func_t obj_str;
};


Expand Down
18 changes: 9 additions & 9 deletions src/ucs/debug/log_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,13 @@ void ucs_log_dispatch(const char *file, unsigned line, const char *function,
/**
* Flush logging output.
*/
void ucs_log_flush();
void ucs_log_flush(void);


/**
* @return Configured log buffer size
*/
size_t ucs_log_get_buffer_size();
size_t ucs_log_get_buffer_size(void);


/**
Expand Down Expand Up @@ -169,10 +169,10 @@ void ucs_log_fatal_error(const char *format, ...) UCS_F_PRINTF(1, 2);
/**
* Initialize/cleanup logging subsystem.
*/
void ucs_log_early_init();
void ucs_log_init();
void ucs_component_log_init();
void ucs_log_cleanup();
void ucs_log_early_init(void);
void ucs_log_init(void);
void ucs_component_log_init(void);
void ucs_log_cleanup(void);


const char *ucs_log_bitmap_to_str(unsigned n, uint8_t *bitmap, size_t length);
Expand All @@ -181,8 +181,8 @@ const char *ucs_log_bitmap_to_str(unsigned n, uint8_t *bitmap, size_t length);
* Add/remove logging handlers
*/
void ucs_log_push_handler(ucs_log_func_t handler);
void ucs_log_pop_handler();
unsigned ucs_log_num_handlers();
void ucs_log_pop_handler(void);
unsigned ucs_log_num_handlers(void);


/**
Expand All @@ -198,7 +198,7 @@ void ucs_log_indent(int delta);
/**
* @return Current log indent level.
*/
int ucs_log_get_current_indent();
int ucs_log_get_current_indent(void);


/**
Expand Down
6 changes: 3 additions & 3 deletions src/ucs/memory/memtype_cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ struct ucs_memtype_cache {
};


void ucs_memtype_cache_global_init();
void ucs_memtype_cache_cleanup();
void ucs_memtype_cache_global_init(void);
void ucs_memtype_cache_cleanup(void);


/**
Expand Down Expand Up @@ -96,7 +96,7 @@ void ucs_memtype_cache_remove(const void *address, size_t size);
*
* @return 1 if empty 0 if otherwise.
*/
static UCS_F_ALWAYS_INLINE int ucs_memtype_cache_is_empty()
static UCS_F_ALWAYS_INLINE int ucs_memtype_cache_is_empty(void)
{
return (ucs_memtype_cache_global_instance != NULL) &&
(ucs_memtype_cache_global_instance->pgtable.num_regions == 0);
Expand Down
8 changes: 4 additions & 4 deletions src/ucs/memory/numa.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,22 @@ typedef int16_t ucs_numa_node_t;
extern const char *ucs_numa_policy_names[];


void ucs_numa_init();
void ucs_numa_init(void);


void ucs_numa_cleanup();
void ucs_numa_cleanup(void);


/**
* @return The number of CPU cores in the system.
*/
unsigned ucs_numa_num_configured_cpus();
unsigned ucs_numa_num_configured_cpus(void);


/**
* @return The number of memory nodes in the system.
*/
unsigned ucs_numa_num_configured_nodes();
unsigned ucs_numa_num_configured_nodes(void);


/**
Expand Down
4 changes: 2 additions & 2 deletions src/ucs/sys/math.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,13 @@ uint64_t ucs_get_prime(unsigned index);
/*
* Generate a random seed
*/
void ucs_rand_seed_init();
void ucs_rand_seed_init(void);


/*
* Generate a random number in the range 0..RAND_MAX
*/
int ucs_rand();
int ucs_rand(void);


/*
Expand Down
2 changes: 1 addition & 1 deletion src/ucs/sys/sock.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ ucs_status_t ucs_socket_server_init(const struct sockaddr *saddr, socklen_t sock
* @return The queue length for completely established sockets
* waiting to be accepted.
*/
int ucs_socket_max_conn();
int ucs_socket_max_conn(void);


/**
Expand Down
Loading

0 comments on commit dda920b

Please sign in to comment.