Debian Codegraph @

Xpjproject/pjlib/include/pj/compat/cc_clang.h

raw symbols SCIP
1 /*
2 * Copyright (C) 2023 Teluu Inc. (http://www.teluu.com)
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18 #ifndef __PJ_COMPAT_CC_CLANG_H__
19 #define __PJ_COMPAT_CC_CLANG_H__
20
21 /**
22 * @file cc_clang.h
23 * @brief Describes CLANG compiler specifics.
24 */
25
26 #ifndef __clang__
27 # error "This file is only for clang!"
28 #endif
29
30 #define PJ_CC_NAME "clang"
31 #define PJ_CC_VER_1 __clang_major__
32 #define PJ_CC_VER_2 __clang_minor__
33 #define PJ_CC_VER_3 __clang_patchlevel__
34
35 #define PJ_THREAD_FUNC
36 #define PJ_NORETURN
37
38 #define PJ_HAS_INT64 1
39
40 #ifdef __STRICT_ANSI__
41 #include <inttypes.h>
42 typedef int64_t pj_int64_t;
43 typedef uint64_t pj_uint64_t;
44 #define PJ_INLINE_SPECIFIER static __inline
45 #define PJ_ATTR_NORETURN
46 #define PJ_ATTR_MAY_ALIAS
47 #else
48 typedef long long pj_int64_t;
49 typedef unsigned long long pj_uint64_t;
50 #define PJ_INLINE_SPECIFIER static inline
51 /* Apple Clang ASan crashes on longjmp/noreturn, see #4846 */
52 #if defined(__has_feature) && __has_feature(address_sanitizer) && \
53 defined(__APPLE__) && defined(__aarch64__)
54 #define PJ_ATTR_NORETURN
55 #else
56 #define PJ_ATTR_NORETURN __attribute__ ((noreturn))
57 #endif
58 #define PJ_ATTR_MAY_ALIAS __attribute__((__may_alias__))
59 #endif
60
61 #define PJ_INT64(val) val##LL
62 #define PJ_UINT64(val) val##ULL
63 #define PJ_INT64_FMT "L"
64
65
66 #define PJ_UNREACHED(x)
67
68 /*
69 * Usage example:
70 *
71 * typedef struct PJ_ALIGN_DATA_PREFIX(8) a { int value; } PJ_ALIGN_DATA_SUFFIX(8) a;
72 * typedef struct PJ_ALIGN_DATA(a{ int value; }, 8) a;
73 *
74 * Both options are equivalent, but perhaps the first is a little more readable than the second.
75 */
76 #define PJ_ALIGN_DATA_PREFIX(alignment)
77 #define PJ_ALIGN_DATA_SUFFIX(alignment) __attribute__((aligned (alignment)))
78 #define PJ_ALIGN_DATA(declaration, alignment) PJ_ALIGN_DATA_PREFIX(alignment) declaration PJ_ALIGN_DATA_SUFFIX(alignment)
79
80 #endif /* __PJ_COMPAT_CC_CLANG_H__ */