Add 'src' dir to global include path
[lttng-ust.git] / include / ust-helper.h
CommitLineData
35897f8b 1/*
c0c0989a 2 * SPDX-License-Identifier: LGPL-2.1-only
35897f8b 3 *
c0c0989a 4 * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
35897f8b
MD
5 */
6
c0c0989a
MJ
7#ifndef _LTTNG_UST_HELPER_H
8#define _LTTNG_UST_HELPER_H
9
35897f8b
MD
10#include <stdlib.h>
11
2eba8e39
MJ
12#include <lttng/ust-arch.h>
13
5f6daaef
MJ
14static inline
15void *zmalloc(size_t len)
16 __attribute__((always_inline));
17static inline
35897f8b
MD
18void *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
fd67a004
MD
37#define LTTNG_ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
38
171fcc6f
MD
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 */
2eba8e39 45#if defined(LTTNG_UST_ARCH_PPC) && !defined(LTTNG_UST_ARCH_PPC64)
171fcc6f 46#define LTTNG_UST_CALLER_IP() NULL
2eba8e39 47#else
171fcc6f 48#define LTTNG_UST_CALLER_IP() __builtin_return_address(0)
2eba8e39 49#endif
171fcc6f 50
35897f8b 51#endif /* _LTTNG_UST_HELPER_H */
This page took 0.03321 seconds and 4 git commands to generate.