Dynamic Load Balance 3.6.1+32-59d1
dlb_common.h
Go to the documentation of this file.
1/*********************************************************************************/
2/* Copyright 2009-2025 Barcelona Supercomputing Center */
3/* */
4/* This file is part of the DLB library. */
5/* */
6/* DLB is free software: you can redistribute it and/or modify */
7/* it under the terms of the GNU Lesser General Public License as published by */
8/* the Free Software Foundation, either version 3 of the License, or */
9/* (at your option) any later version. */
10/* */
11/* DLB is distributed in the hope that it will be useful, */
12/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
13/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
14/* GNU Lesser General Public License for more details. */
15/* */
16/* You should have received a copy of the GNU Lesser General Public License */
17/* along with DLB. If not, see <https://www.gnu.org/licenses/>. */
18/*********************************************************************************/
19
20#ifndef DLB_COMMON_H
21#define DLB_COMMON_H
22
23#ifdef HAVE_CONFIG_H
24#include <config.h>
25#endif
26
27
28#define likely(expr) __builtin_expect(!!(expr), 1)
29#define unlikely(expr) __builtin_expect(!!(expr), 0)
30
31
32#if !defined(__INTEL_COMPILER) && ((defined(__GNUC__) && __GNUC__ >= 7) || (defined(__clang__) && __clang_major__ >= 11))
33#define DLB_FALLTHROUGH __attribute__((__fallthrough__))
34#else
35#define DLB_FALLTHROUGH ((void)0)
36#endif
37
38
39#define DLB_EXPORT_SYMBOL __attribute__((visibility ("default")))
40
41
42#ifdef HAVE_ALIAS_ATTRIBUTE
43# define DLB_ALIAS(ret_type, name, decl_args, call_args, target) \
44 ret_type name decl_args __attribute__((alias(#target)));
45#else
46# define DLB_ALIAS(ret_type, name, decl_args, call_args, target) \
47 ret_type name decl_args { return target call_args; }
48#endif
49
50
51#endif /* DLB_COMMON_H */