ovni/src/common.h

43 lines
868 B
C
Raw Normal View History

2022-09-19 12:39:02 +02:00
/* Copyright (c) 2021-2022 Barcelona Supercomputing Center (BSC)
* SPDX-License-Identifier: MIT */
#ifndef COMMON_H
#define COMMON_H
2022-08-22 16:02:07 +02:00
#include <stdio.h>
#include <stdlib.h>
/* Debug macros */
2023-01-25 12:01:01 +01:00
void progname_set(char *name);
void verr(const char *func, const char *errstr, ...);
void vdie(const char *func, const char *errstr, ...);
/* clang-format off */
2023-01-27 18:51:18 +01:00
#define err(...) verr(__func__, __VA_ARGS__);
#define die(...) vdie(__func__, __VA_ARGS__);
#ifdef ENABLE_DEBUG
2023-01-27 18:51:18 +01:00
# define dbg(...) verr(__func__, __VA_ARGS__);
#else
# define dbg(...)
#endif
#define likely(x) __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect(!!(x), 0)
#define UNUSED(x) (void)(x)
2021-12-09 16:56:24 +01:00
/* Poison assert */
#pragma GCC poison assert
#define USE_RET __attribute__((warn_unused_result))
2023-01-17 19:25:21 +01:00
#define ARRAYLEN(x) (sizeof(x)/sizeof((x)[0]))
/* clang-format on */
2023-01-25 12:01:01 +01:00
#endif /* COMMON_H */