GFXprim
2D bitmap graphics library with emphasis on speed and correctness
Loading...
Searching...
No Matches
gp_compiler.h
Go to the documentation of this file.
1// SPDX-License-Identifier: LGPL-2.1-or-later
2/*
3 * Copyright (C) 2024 Cyril Hrubis <metan@ucw.cz>
4 */
5
11#ifndef CORE_GP_COMPILER_H
12#define CORE_GP_COMPILER_H
13
14#if __DOXYGEN__
15# define GP_ALIGNED
16#else
17# define GP_ALIGNED __attribute__((aligned (sizeof(void*))))
18#endif /* __DOXYGEN__ */
19
20#if __GNUC__
21# define GP_IS_CONSTANT(x) __builtin_constant_p(x)
22# define GP_WUR __attribute__((warn_unused_result))
23# define GP_FMT_PRINTF(fmt, list) __attribute__((format(printf, fmt, list)))
24# define GP_FMT_SCANF(fmt, list) __attribute__((format(scanf, fmt, list)))
25# define GP_LIKELY(cond) __builtin_expect(!!(cond), 1)
26# define GP_UNLIKELY(cond) __builtin_expect(!!(cond), 0)
27# define GP_UNUSED(x) (x)__attribute__ ((unused))
28# define GP_PACKED __attribute__ ((packed))
29#else
33# define GP_WUR
37# define GP_FMT_PRINTF(fmt, list)
41# define GP_FMT_SCANF(fmt, list)
45# define GP_IS_CONSTANT(x) 0
49# define GP_LIKELY(cond) (cond)
53# define GP_UNLIKELY(cond) (cond)
57# define GP_UNUSED(x) x
61# define GP_PACKED
62#endif
63
64/* Make sure typeof() is defined even with ISO C */
65#define typeof(x) __typeof__(x)
66
67#endif /* CORE_GP_COMPILER_H */