OpenSWMM Engine
6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
macros.h
Go to the documentation of this file.
1
//-----------------------------------------------------------------------------
2
// macros.h
3
//
4
// Project: EPA SWMM5
5
// Version: 5.2
6
// Date: 11/01/21 (Build 5.2.0)
7
// Author: L. Rossman
8
//-----------------------------------------------------------------------------
9
19
20
#ifndef MACROS_H
21
#define MACROS_H
22
23
//--------------------------------------------------
24
// Macro to test for successful allocation of memory
25
//--------------------------------------------------
26
#define MEMCHECK(x) (((x) == NULL) ? 101 : 0)
27
28
//--------------------------------------------------
29
// Macro to free a non-null pointer
30
//--------------------------------------------------
31
#define FREE(x) \
32
{ \
33
if (x) { \
34
free(x); \
35
x = NULL; \
36
} \
37
}
38
39
//---------------------------------------------------
40
// Conversion macros to be used in place of functions
41
//---------------------------------------------------
42
#define ABS(x) (((x) < 0) ? -(x) : (x))
/* absolute value of x */
43
#define MIN(x, y) (((x) <= (y)) ? (x) : (y))
/* minimum of x and y */
44
#define MAX(x, y) (((x) >= (y)) ? (x) : (y))
/* maximum of x and y */
45
#define MOD(x, y) ((x) % (y))
/* x modulus y */
46
#define LOG10(x) ((x) > 0.0 ? log10((x)) : (x))
/* safe log10 of x */
47
#define SQR(x) ((x) * (x))
/* x-squared */
48
#define SGN(x) (((x) < 0) ? (-1) : (1))
/* sign of x */
49
#define SIGN(x, y) ((y) >= 0.0 ? fabs(x) : -fabs(x))
50
#define UCHAR(x) (((x) >= 'a' && (x) <= 'z') ? ((x) & ~32) : (x))
51
/* uppercase char of x */
52
#define ARRAY_LENGTH(x) (sizeof(x) / sizeof(x[0]))
/* length of array x */
53
54
//-------------------------------------------------
55
// Macro to evaluate function x with error checking
56
//-------------------------------------------------
57
#define CALL(x) (ErrorCode = ((ErrorCode > 0) ? (ErrorCode) : (x)))
58
59
#endif
//MACROS_H
src
legacy
engine
macros.h
Generated by
1.13.2