| 1 |
// SPDX-License-Identifier: BSD-2-Clause-Patent |
| 2 |
/** |
| 3 |
* macros to build function declarations with the same types as builtins |
| 4 |
* that we apparently really cannot depend on. |
| 5 |
*/ |
| 6 |
|
| 7 |
/* |
| 8 |
* Clang's __builtin_whatever and __typeof__ are broken thusly: |
| 9 |
* In file included from MokManager.c:2: |
| 10 |
* In file included from shim.h:47: |
| 11 |
* include/system/string.h:29:1: error: builtin functions must be directly called |
| 12 |
* mkbi1_(long int, ffsl, long int, x) |
| 13 |
* ^ |
| 14 |
*/ |
| 15 |
#if defined(__clang__) |
| 16 |
|
| 17 |
#ifndef mkbi1_ |
| 18 |
#define mkbi1_(rtype, x, typea, a) rtype x(typea a); |
| 19 |
#endif |
| 20 |
|
| 21 |
#ifndef mkbi2_ |
| 22 |
#define mkbi2_(rtype, x, typea, a, typeb, b) rtype x(typea a, typeb b); |
| 23 |
#endif |
| 24 |
|
| 25 |
#ifndef mkbi3_ |
| 26 |
#define mkbi3_(rtype, x, typea, a, typeb, b, typec, c) rtype x(typea a, typeb b, typec c); |
| 27 |
#endif |
| 28 |
|
| 29 |
#ifndef mkdepbi1_ |
| 30 |
#define mkdepbi1_(rtype, x, typea, a) rtype x(typea a); |
| 31 |
#endif |
| 32 |
|
| 33 |
#ifndef mkdepbi2_ |
| 34 |
#define mkdepbi2_(rtype, x, typea, a, typeb, b) rtype x(typea a, typeb b); |
| 35 |
#endif |
| 36 |
|
| 37 |
#else /* !__clang__ */ |
| 38 |
|
| 39 |
#ifndef mkbi_cat_ |
| 40 |
#define mkbi_cat_(a, b) a##b |
| 41 |
#endif |
| 42 |
|
| 43 |
#ifndef mkbi1_ |
| 44 |
#define mkbi1_(rtype, x, typea, a) __typeof__(mkbi_cat_(__builtin_, x)) x; |
| 45 |
#endif |
| 46 |
|
| 47 |
#ifndef mkbi2_ |
| 48 |
#define mkbi2_(rtype, x, typea, a, typeb, b) __typeof__(mkbi_cat_(__builtin_, x)) x; |
| 49 |
#endif |
| 50 |
|
| 51 |
#ifndef mkbi3_ |
| 52 |
#define mkbi3_(rtype, x, typea, a, typeb, b, typec, c) __typeof__(mkbi_cat_(__builtin_, x)) x; |
| 53 |
#endif |
| 54 |
|
| 55 |
#ifndef mkdepbi1_ |
| 56 |
#define mkdepbi1_(rtype, x, typea, a) __typeof__(mkbi_cat_(__builtin_, x)) x; |
| 57 |
#endif |
| 58 |
|
| 59 |
#ifndef mkdepbi2_ |
| 60 |
#define mkdepbi2_(rtype, x, typea, a, typeb, b) __typeof__(mkbi_cat_(__builtin_, x)) x; |
| 61 |
#endif |
| 62 |
|
| 63 |
#endif /* !__clang__ */ |
| 64 |
|
| 65 |
// vim:fenc=utf-8:tw=75:noet |