Browse Source

improve `SWAP' macro

pre-master-46
rlar 10 years ago
parent
commit
b36385e333
  1. 7
      src/include/ngspice/macros.h
  2. 7
      src/maths/sparse/spdefs.h

7
src/include/ngspice/macros.h

@ -36,7 +36,12 @@
#define ABS(a) ((a) < 0.0 ? -(a) : (a)) #define ABS(a) ((a) < 0.0 ? -(a) : (a))
#define SGN(a) ((a) < 0.0 ? -(1.0) : (1.0)) #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 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() \ #define ABORT() \

7
src/maths/sparse/spdefs.h

@ -78,7 +78,12 @@
#define SQR(a) ((a)*(a)) #define SQR(a) ((a)*(a))
/* Macro procedure that swaps two entities. */ /* 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…
Cancel
Save