cleanup: function attribute 'hidden'
[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
415dfaf7 14static inline __attribute__((always_inline))
35897f8b
MD
15void *zmalloc(size_t len)
16{
17 return calloc(len, 1);
18}
19
20#define max_t(type, x, y) \
21 ({ \
22 type __max1 = (x); \
23 type __max2 = (y); \
24 __max1 > __max2 ? __max1: __max2; \
25 })
26
27#define min_t(type, x, y) \
28 ({ \
29 type __min1 = (x); \
30 type __min2 = (y); \
31 __min1 <= __min2 ? __min1: __min2; \
32 })
33
fd67a004
MD
34#define LTTNG_ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
35
171fcc6f
MD
36/*
37 * Use of __builtin_return_address(0) sometimes seems to cause stack
38 * corruption on 32-bit PowerPC. Disable this feature on that
39 * architecture for now by always using the NULL value for the ip
40 * context.
41 */
2eba8e39 42#if defined(LTTNG_UST_ARCH_PPC) && !defined(LTTNG_UST_ARCH_PPC64)
171fcc6f 43#define LTTNG_UST_CALLER_IP() NULL
2eba8e39 44#else
171fcc6f 45#define LTTNG_UST_CALLER_IP() __builtin_return_address(0)
2eba8e39 46#endif
171fcc6f 47
35897f8b 48#endif /* _LTTNG_UST_HELPER_H */
This page took 0.029888 seconds and 4 git commands to generate.