Add 'src' dir to global include path
[lttng-ust.git] / include / ust-helper.h
1 /*
2 * SPDX-License-Identifier: LGPL-2.1-only
3 *
4 * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
5 */
6
7 #ifndef _LTTNG_UST_HELPER_H
8 #define _LTTNG_UST_HELPER_H
9
10 #include <stdlib.h>
11
12 #include <lttng/ust-arch.h>
13
14 static inline
15 void *zmalloc(size_t len)
16 __attribute__((always_inline));
17 static inline
18 void *zmalloc(size_t len)
19 {
20 return calloc(len, 1);
21 }
22
23 #define max_t(type, x, y) \
24 ({ \
25 type __max1 = (x); \
26 type __max2 = (y); \
27 __max1 > __max2 ? __max1: __max2; \
28 })
29
30 #define min_t(type, x, y) \
31 ({ \
32 type __min1 = (x); \
33 type __min2 = (y); \
34 __min1 <= __min2 ? __min1: __min2; \
35 })
36
37 #define LTTNG_ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
38
39 /*
40 * Use of __builtin_return_address(0) sometimes seems to cause stack
41 * corruption on 32-bit PowerPC. Disable this feature on that
42 * architecture for now by always using the NULL value for the ip
43 * context.
44 */
45 #if defined(LTTNG_UST_ARCH_PPC) && !defined(LTTNG_UST_ARCH_PPC64)
46 #define LTTNG_UST_CALLER_IP() NULL
47 #else
48 #define LTTNG_UST_CALLER_IP() __builtin_return_address(0)
49 #endif
50
51 #endif /* _LTTNG_UST_HELPER_H */
This page took 0.030343 seconds and 4 git commands to generate.