#ifndef UCX_UTILS_H
#define UCX_UTILS_H
#include "common.h"
#ifdef __cplusplus
extern "C" {
#endif
#define cx_for_n(varname, n)
for (
size_t varname =
0 ; (varname) < (n) ; (varname)++)
#ifdef __cplusplus
#define cx_swap_ptr(left, right)
do {
auto cx_tmp_swap_var = left; left = right; right = cx_tmp_swap_var;}
while(
0)
#else
#define cx_swap_ptr(left, right)
do {
void *cx_tmp_swap_var = left; left = right; right = cx_tmp_swap_var;}
while(
0)
#endif
#if (
__GNUC__ >=
5 || defined(__clang__)) && !defined(
CX_NO_SZMUL_BUILTIN)
#define CX_SZMUL_BUILTIN
#define cx_szmul(a, b, result) __builtin_mul_overflow(a, b, result)
#else
#define cx_szmul(a, b, result) cx_szmul_impl(a, b, result)
int cx_szmul_impl(
size_t a,
size_t b,
size_t *result);
#endif
__attribute__((__nonnull__(
1,
2,
3,
4)))
size_t cx_stream_bncopy(
void *src,
void *dest,
cx_read_func rfnc,
cx_write_func wfnc,
char *buf,
size_t bufsize,
size_t n
);
#define cx_stream_bcopy(src, dest, rfnc, wfnc, buf, bufsize) \
cx_stream_bncopy(src, dest, rfnc, wfnc, buf, bufsize,
SIZE_MAX)
__attribute__((__nonnull__))
size_t cx_stream_ncopy(
void *src,
void *dest,
cx_read_func rfnc,
cx_write_func wfnc,
size_t n
);
#define cx_stream_copy(src, dest, rfnc, wfnc) \
cx_stream_ncopy(src, dest, rfnc, wfnc,
SIZE_MAX)
#ifdef __cplusplus
}
#endif
#endif