|
| 1 | +/*===---- availability_domain.h - Availability Domain -----------------------=== |
| 2 | + * |
| 3 | + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | + * See https://llvm.org/LICENSE.txt for license information. |
| 5 | + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | + * |
| 7 | + *===-----------------------------------------------------------------------=== |
| 8 | + */ |
| 9 | + |
| 10 | +#ifndef __AVAILABILITY_DOMAIN_H |
| 11 | +#define __AVAILABILITY_DOMAIN_H |
| 12 | + |
| 13 | +#include <stdint.h> |
| 14 | + |
| 15 | +#define __AVAILABILITY_DOMAIN_ENABLED 0 |
| 16 | +#define __AVAILABILITY_DOMAIN_DISABLED 1 |
| 17 | +#define __AVAILABILITY_DOMAIN_DYNAMIC 2 |
| 18 | + |
| 19 | +/// Describes the fields of a Clang availability domain. This struct is an |
| 20 | +/// implementation detail of the compiler and is subject to change so don't |
| 21 | +/// reference `__AvailabilityDomain` directly. Instead, use the provided macros: |
| 22 | +/// |
| 23 | +/// CLANG_DYNAMIC_AVAILABILITY_DOMAIN(MyDomain, query); |
| 24 | +/// |
| 25 | +struct __AvailabilityDomain { |
| 26 | + /// The state of the domain (AVAILABLE, UNAVAILABLE, DYNAMIC, etc.). |
| 27 | + intptr_t state; |
| 28 | + /// An optional function pointer to call to query the availability of a domain |
| 29 | + /// at runtime. This should only be non-null for domains in the DYNAMIC state. |
| 30 | + int (*const runtimeQuery)(void); |
| 31 | +}; |
| 32 | + |
| 33 | +#define CLANG_DYNAMIC_AVAILABILITY_DOMAIN(domain, query) \ |
| 34 | + static struct __AvailabilityDomain domain __attribute__(( \ |
| 35 | + availability_domain(domain))) = {__AVAILABILITY_DOMAIN_DYNAMIC, query} |
| 36 | + |
| 37 | +#define CLANG_ENABLED_AVAILABILITY_DOMAIN(domain) \ |
| 38 | + static struct __AvailabilityDomain domain __attribute__(( \ |
| 39 | + availability_domain(domain))) = {__AVAILABILITY_DOMAIN_ENABLED, 0} |
| 40 | + |
| 41 | +#define CLANG_DISABLED_AVAILABILITY_DOMAIN(domain) \ |
| 42 | + static struct __AvailabilityDomain domain __attribute__(( \ |
| 43 | + availability_domain(domain))) = {__AVAILABILITY_DOMAIN_DISABLED, 0} |
| 44 | + |
| 45 | +#define CLANG_ALWAYS_ENABLED_AVAILABILITY_DOMAIN(domain) \ |
| 46 | + static struct __AvailabilityDomain domain __attribute__(( \ |
| 47 | + availability_domain(domain))) = {__AVAILABILITY_DOMAIN_ENABLED, 0} |
| 48 | + |
| 49 | +#define CLANG_ALWAYS_DISABLED_AVAILABILITY_DOMAIN(domain) \ |
| 50 | + static struct __AvailabilityDomain domain __attribute__(( \ |
| 51 | + availability_domain(domain))) = {__AVAILABILITY_DOMAIN_DISABLED, 0} |
| 52 | + |
| 53 | +#endif /* __AVAILABILITY_DOMAIN_H */ |
0 commit comments