improve `SWAP' macro
This commit is contained in:
parent
f84d2d4e44
commit
b36385e333
|
|
@ -36,7 +36,12 @@
|
|||
#define ABS(a) ((a) < 0.0 ? -(a) : (a))
|
||||
#define SGN(a) ((a) < 0.0 ? -(1.0) : (1.0))
|
||||
#define SIGN(a,b) ( b >= 0 ? (a >= 0 ? a : - a) : (a >= 0 ? - a : a))
|
||||
#define SWAP(type, a, b) {type swapx; swapx = a; a = b; b = swapx;}
|
||||
#define SWAP(type, a, b) \
|
||||
do { \
|
||||
type SWAP_macro_local = a; \
|
||||
a = b; \
|
||||
b = SWAP_macro_local; \
|
||||
} while(0)
|
||||
|
||||
|
||||
#define ABORT() \
|
||||
|
|
|
|||
|
|
@ -78,7 +78,12 @@
|
|||
#define SQR(a) ((a)*(a))
|
||||
|
||||
/* Macro procedure that swaps two entities. */
|
||||
#define SWAP(type, a, b) {type swapx; swapx = a; a = b; b = swapx;}
|
||||
#define SWAP(type, a, b) \
|
||||
do { \
|
||||
type SWAP_macro_local = a; \
|
||||
a = b; \
|
||||
b = SWAP_macro_local; \
|
||||
} while(0)
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue