src/cx/utils.h

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

mercurial