1 /* $FreeBSD$ */ 2 3 #include "alloca.h" 4 5 #define memalign(align, size) ({ \ 6 void *__ptr; \ 7 if (posix_memalign(&__ptr, (align), (size))) \ 8 __ptr = NULL; \ 9 __ptr; \ 10 }) 11 12 /* 13 * Return true if the snprintf succeeded, false if there was 14 * truncation or error: 15 */ 16 #define check_snprintf(buf, len, fmt, ...) ({ \ 17 int rc = snprintf(buf, len, fmt, ##__VA_ARGS__); \ 18 (rc < len && rc >= 0); \ 19 }) 20 21 #define min_t(type, x, y) ({ \ 22 type __min1 = (x); \ 23 type __min2 = (y); \ 24 __min1 < __min2 ? __min1 : __min2; }) 25 26 #define freeaddrinfo_null(x) do { \ 27 if ((x) != NULL) \ 28 freeaddrinfo(x); \ 29 } while (0) 30 31 #define VALGRIND_MAKE_MEM_DEFINED(...) 0 32 #define s6_addr32 __u6_addr.__u6_addr32 33 #define __sum16 uint16_t 34 #define NRESOLVE_NEIGH 1 35 #define STREAM_CLOEXEC "e" 36 #define VERBS_PROVIDER_DIR "/usr/lib/" 37 #define IBV_CONFIG_DIR "/etc/ibverbs/" 38 #define MADV_DONTFORK MADV_NORMAL 39 #define MADV_DOFORK MADV_NORMAL 40 #define SWITCH_FALLTHROUGH (void)0 41 42