src/cx/utils.h

changeset 955
18741059da47
parent 759
475335643af4
child 962
cd418898af5c
equal deleted inserted replaced
954:a1d87e8fff6d 955:18741059da47
47 47
48 /** 48 /**
49 * Convenience macro for a for loop that counts from zero to n-1. 49 * Convenience macro for a for loop that counts from zero to n-1.
50 */ 50 */
51 #define cx_for_n(varname, n) for (size_t varname = 0 ; (varname) < (n) ; (varname)++) 51 #define cx_for_n(varname, n) for (size_t varname = 0 ; (varname) < (n) ; (varname)++)
52
53 /**
54 * Convenience macro for swapping two pointers.
55 */
56 #ifdef __cplusplus
57 #define cx_swap_ptr(left, right) do {auto cx_tmp_swap_var = left; left = right; right = cx_tmp_swap_var;} while(0)
58 #else
59 #define cx_swap_ptr(left, right) do {void *cx_tmp_swap_var = left; left = right; right = cx_tmp_swap_var;} while(0)
60 #endif
61 52
62 // cx_szmul() definition 53 // cx_szmul() definition
63 54
64 #if (__GNUC__ >= 5 || defined(__clang__)) && !defined(CX_NO_SZMUL_BUILTIN) 55 #if (__GNUC__ >= 5 || defined(__clang__)) && !defined(CX_NO_SZMUL_BUILTIN)
65 #define CX_SZMUL_BUILTIN 56 #define CX_SZMUL_BUILTIN

mercurial