Reformat
[clav.git] / macros.h
blob4b8b61394b3f8437225aaa3519e467a5dadb2e21
1 /*
2 * Copyright (c) 2016-2019, S. Gilles <sgilles@math.umd.edu>
4 * Permission to use, copy, modify, and/or distribute this software
5 * for any purpose with or without fee is hereby granted, provided
6 * that the above copyright notice and this permission notice appear
7 * in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
13 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
14 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
15 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
16 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 #define UNUSED(x) (void) (sizeof(x))
20 #define STR2(x) #x
21 #define STR(x) STR2(x)
23 #define L(x) __FILE__ ":" STR(__LINE__) ": " x
25 #define MAX(x, y) (((x) > (y)) ? (x) : (y))
26 #define SGN(x) ((x) > 0) ? 1 : ((x) < 0 ? -1 : 0)
27 #define UBSAFES(s) ((s) ? (s) : "[None]")
29 #define IF_NZ_SET(s, v) if (s) { *(s) = (v); }