Warning, /include/upb/port/def.inc is written in an unsupported language. File is not indexed.
0001 // Protocol Buffers - Google's data interchange format
0002 // Copyright 2023 Google LLC. All rights reserved.
0003 //
0004 // Use of this source code is governed by a BSD-style
0005 // license that can be found in the LICENSE file or at
0006 // https://developers.google.com/open-source/licenses/bsd
0007
0008 /*
0009 * This is where we define internal portability macros used across upb.
0010 *
0011 * All of these macros are undef'd in undef.inc to avoid leaking them to users.
0012 *
0013 * The correct usage is:
0014 *
0015 * #include "upb/foobar.h"
0016 * #include "upb/baz.h"
0017 *
0018 * // MUST be last included header.
0019 * #include "upb/port/def.inc"
0020 *
0021 * // Code for this file.
0022 * // <...>
0023 *
0024 * // Can be omitted for .c files, required for .h.
0025 * #include "upb/port/undef.inc"
0026 *
0027 * This file is private and must not be included by users!
0028 */
0029
0030 #if !((defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \
0031 (defined(__cplusplus) && __cplusplus >= 201703L) || \
0032 (defined(_MSC_VER) && _MSC_VER >= 1900))
0033 #error upb requires C99 or C++17 or MSVC >= 2015.
0034 #endif
0035
0036 // Portable check for GCC minimum version:
0037 // https://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html
0038 #if defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__)
0039 #define UPB_GNUC_MIN(x, y) \
0040 (__GNUC__ > (x) || __GNUC__ == (x) && __GNUC_MINOR__ >= (y))
0041 #else
0042 #define UPB_GNUC_MIN(x, y) 0
0043 #endif
0044
0045 // Macros for checking for compiler attributes, defined here to avoid the
0046 // problem described in
0047 // https://gcc.gnu.org/onlinedocs/cpp/_005f_005fhas_005fattribute.html.
0048 #ifdef __has_attribute
0049 #define UPB_HAS_ATTRIBUTE(x) __has_attribute(x)
0050 #else
0051 #define UPB_HAS_ATTRIBUTE(x) 0
0052 #endif
0053
0054 #ifdef __has_builtin
0055 #define UPB_HAS_BUILTIN(x) __has_builtin(x)
0056 #else
0057 #define UPB_HAS_BUILTIN(x) 0
0058 #endif
0059
0060 #ifdef __has_extension
0061 #define UPB_HAS_EXTENSION(x) __has_extension(x)
0062 #else
0063 #define UPB_HAS_EXTENSION(x) 0
0064 #endif
0065
0066 #ifdef __has_feature
0067 #define UPB_HAS_FEATURE(x) __has_feature(x)
0068 #else
0069 #define UPB_HAS_FEATURE(x) 0
0070 #endif
0071
0072 #include <assert.h>
0073 #include <setjmp.h>
0074 #include <stdbool.h>
0075 #include <stdint.h>
0076 #include <stdio.h>
0077 #include <stdlib.h>
0078
0079 #ifndef UINTPTR_MAX
0080 Error, UINTPTR_MAX is undefined
0081 #endif
0082
0083 #if UINTPTR_MAX == 0xffffffff
0084 #define UPB_SIZE(size32, size64) size32
0085 #else
0086 #define UPB_SIZE(size32, size64) size64
0087 #endif
0088
0089 /* If we always read/write as a consistent type to each address, this shouldn't
0090 * violate aliasing.
0091 */
0092 #define UPB_PTR_AT(msg, ofs, type) ((type *)((char *)(msg) + (ofs)))
0093
0094 // A flexible array member may have lower alignment requirements than the struct
0095 // overall - in that case, it can overlap with the trailing padding of the rest
0096 // of the struct, and a naive sizeof(base) + sizeof(flex) * count calculation
0097 // will not take into account that overlap, and allocate more than is required.
0098 #define UPB_SIZEOF_FLEX(type, member, count) \
0099 UPB_MAX(sizeof(type), offsetof(type, member[count]))
0100
0101 #define UPB_SIZEOF_FLEX_WOULD_OVERFLOW(type, member, count) \
0102 (((SIZE_MAX - offsetof(type, member[0])) / \
0103 (offsetof(type, member[1]) - offsetof(type, member[0]))) < (size_t)count)
0104
0105 #define UPB_ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0]))
0106
0107 #define UPB_MAPTYPE_STRING 0
0108
0109 // UPB_EXPORT: always generate a public symbol.
0110 #if defined(__GNUC__) || defined(__clang__)
0111 #define UPB_EXPORT __attribute__((visibility("default"))) __attribute__((used))
0112 #else
0113 #define UPB_EXPORT
0114 #endif
0115
0116 // UPB_INLINE: inline if possible, emit standalone code if required.
0117 #ifdef __cplusplus
0118 #define UPB_INLINE inline
0119 #elif defined(__GNUC__) || defined(__clang__)
0120 #define UPB_INLINE static __inline__
0121 #else
0122 #define UPB_INLINE static
0123 #endif
0124
0125 // UPB_INLINE_IF_NOT_GCC: because gcc can be very noisy at times.
0126 #if defined(__GNUC__) && !defined(__clang__)
0127 #define UPB_INLINE_IF_NOT_GCC static
0128 #else
0129 #define UPB_INLINE_IF_NOT_GCC UPB_INLINE
0130 #endif
0131
0132 #ifdef UPB_BUILD_API
0133 #define UPB_API UPB_EXPORT
0134 #define UPB_API_INLINE UPB_EXPORT
0135 #else
0136 #define UPB_API
0137 #define UPB_API_INLINE UPB_INLINE
0138 #endif
0139
0140 #ifdef EXPORT_UPBC
0141 #define UPBC_API UPB_EXPORT
0142 #else
0143 #define UPBC_API
0144 #endif
0145
0146 #if UPB_HAS_FEATURE(address_sanitizer) || defined(__SANITIZE_ADDRESS__)
0147 #define UPB_ASAN 1
0148 #else
0149 #define UPB_ASAN 0
0150 #endif
0151
0152 #if UPB_HAS_FEATURE(hwaddress_sanitizer)
0153 #define UPB_HWASAN 1
0154 #define UPB_HWASAN_POISON_TAG 17
0155 #define UPB_MALLOC_ALIGN 16
0156 #else
0157 #define UPB_HWASAN 0
0158 #define UPB_MALLOC_ALIGN 8
0159 #endif
0160
0161 #if UPB_HAS_FEATURE(thread_sanitizer) || defined(__SANITIZE_THREAD__)
0162 #define UPB_TSAN 1
0163 #else
0164 #define UPB_TSAN 0
0165 #endif
0166
0167 // An unfortunate concession to C++17 and MSVC, which don't support zero-sized
0168 // structs.
0169 #if UPB_ASAN || UPB_HWASAN || UPB_TSAN
0170 #define UPB_XSAN_MEMBER upb_Xsan xsan;
0171 #define UPB_XSAN(st) (&(st)->xsan)
0172 #define UPB_XSAN_STRUCT_SIZE 1
0173 #else
0174 #define UPB_XSAN_MEMBER
0175 #define UPB_XSAN(st) (NULL)
0176 #define UPB_XSAN_STRUCT_SIZE 0
0177 #endif
0178
0179 #define UPB_ALIGN_UP(size, align) (((size) + (align) - 1) / (align) * (align))
0180 #define UPB_ALIGN_DOWN(size, align) ((size) / (align) * (align))
0181 #define UPB_ALIGN_MALLOC(size) UPB_ALIGN_UP(size, UPB_MALLOC_ALIGN)
0182
0183 #if __STDC_VERSION__ >= 202311L || UPB_HAS_EXTENSION(cxx_alignof) || \
0184 defined(__cplusplus)
0185 #define UPB_ALIGN_OF(type) alignof(type)
0186 #elif __STDC_VERSION__ >= 201112L || UPB_HAS_EXTENSION(c_alignof)
0187 #define UPB_ALIGN_OF(type) _Alignof(type)
0188 #elif UPB_GNUC_MIN(2, 95)
0189 #define UPB_ALIGN_OF(type) __alignof__(type)
0190 #elif defined(_MSC_VER)
0191 #define UPB_ALIGN_OF(type) __alignof(type)
0192 #else
0193 #define UPB_ALIGN_OF(type) \
0194 offsetof( \
0195 struct { \
0196 char c; \
0197 type member; \
0198 }, \
0199 member)
0200 #endif
0201
0202 #ifdef _MSC_VER
0203 // Some versions of our Windows compiler don't support the C11 syntax.
0204 #define UPB_ALIGN_AS(x) __declspec(align(x))
0205 #elif defined(__GNUC__)
0206 #define UPB_ALIGN_AS(x) __attribute__((aligned(x)))
0207 #else
0208 #define UPB_ALIGN_AS(x) _Alignas(x)
0209 #endif
0210
0211 #if __STDC_VERSION__ >= 202311L || UPB_HAS_EXTENSION(cxx_static_assert) || \
0212 defined(__cplusplus)
0213 #define UPB_STATIC_ASSERT(val, msg) static_assert((val), msg)
0214 #elif __STDC_VERSION__ >= 201112L || UPB_HAS_EXTENSION(c_static_assert) || \
0215 UPB_GNUC_MIN(4, 6)
0216 #define UPB_STATIC_ASSERT(val, msg) _Static_assert((val), msg)
0217 #else
0218 // Unfortunately this hack doesn't work inside struct declarations, but it works
0219 // everywhere else
0220 #define UPB_STATIC_ASSERT_CONCAT_IMPL(s1, s2) s1##s2
0221 #define UPB_STATIC_ASSERT_CONCAT(s1, s2) UPB_STATIC_ASSERT_CONCAT_IMPL(s1, s2)
0222 #ifdef __COUNTER__
0223 #define UPB_STATIC_ASSERT(condition, message) \
0224 typedef char UPB_STATIC_ASSERT_CONCAT(static_assertion_failure_, \
0225 __COUNTER__)[(condition) ? 1 : -1]
0226 #else
0227 #define UPB_STATIC_ASSERT(condition, message) \
0228 typedef char UPB_STATIC_ASSERT_CONCAT(static_assertion_failure_, \
0229 __LINE__)[(condition) ? 1 : -1]
0230 #endif
0231 #endif
0232
0233 // Hints to the compiler about likely/unlikely branches.
0234 #if defined(__GNUC__) || defined(__clang__)
0235 #define UPB_LIKELY(x) __builtin_expect((bool)(x), 1)
0236 #define UPB_UNLIKELY(x) __builtin_expect((bool)(x), 0)
0237 #else
0238 #define UPB_LIKELY(x) (x)
0239 #define UPB_UNLIKELY(x) (x)
0240 #endif
0241
0242 #if UPB_HAS_BUILTIN(__builtin_expect_with_probability)
0243 #define UPB_UNPREDICTABLE(x) \
0244 __builtin_expect_with_probability((bool)(x), 1, 0.5)
0245 #else
0246 #define UPB_UNPREDICTABLE(x) (x)
0247 #endif
0248
0249 // Macros for function attributes on compilers that support them.
0250 #if defined(__GNUC__) || defined(__clang__)
0251 #define UPB_FORCEINLINE __inline__ __attribute__((always_inline)) static
0252 #define UPB_NOINLINE __attribute__((noinline))
0253 #define UPB_NORETURN __attribute__((__noreturn__))
0254 #define UPB_PRINTF(str, first_vararg) \
0255 __attribute__((format(printf, str, first_vararg)))
0256 #elif defined(_MSC_VER)
0257 #define UPB_NOINLINE
0258 #define UPB_FORCEINLINE static
0259 #define UPB_NORETURN __declspec(noreturn)
0260 #define UPB_PRINTF(str, first_vararg)
0261 #else /* !defined(__GNUC__) */
0262 #define UPB_FORCEINLINE static
0263 #define UPB_NOINLINE
0264 #define UPB_NORETURN
0265 #define UPB_PRINTF(str, first_vararg)
0266 #endif
0267
0268 #if defined(__clang__)
0269 #define UPB_NODEREF __attribute__((noderef))
0270 #else
0271 #define UPB_NODEREF
0272 #endif
0273
0274 #define UPB_MAX(x, y) ((x) > (y) ? (x) : (y))
0275 #define UPB_MIN(x, y) ((x) < (y) ? (x) : (y))
0276
0277 #define UPB_UNUSED(var) (void)(var)
0278
0279 // UPB_ASSUME(): in release mode, we tell the compiler to assume this is true.
0280 #ifdef NDEBUG
0281 #ifdef __GNUC__
0282 #define UPB_ASSUME(expr) \
0283 if (!(expr)) __builtin_unreachable()
0284 #elif defined _MSC_VER
0285 #define UPB_ASSUME(expr) \
0286 if (!(expr)) __assume(0)
0287 #else
0288 #define UPB_ASSUME(expr) \
0289 do { \
0290 } while (false && (expr))
0291 #endif
0292 #else
0293 #define UPB_ASSUME(expr) assert(expr)
0294 #endif
0295
0296 /* UPB_ASSERT(): in release mode, we use the expression without letting it be
0297 * evaluated. This prevents "unused variable" warnings. */
0298 #ifdef NDEBUG
0299 #define UPB_ASSERT(expr) \
0300 do { \
0301 } while (false && (expr))
0302 #else
0303 #define UPB_ASSERT(expr) assert(expr)
0304 #endif
0305
0306 #if defined(__GNUC__) || defined(__clang__)
0307 #define UPB_UNREACHABLE() \
0308 do { \
0309 assert(0); \
0310 __builtin_unreachable(); \
0311 } while (0)
0312 #elif defined(_MSC_VER)
0313 #define UPB_UNREACHABLE() \
0314 do { \
0315 assert(0); \
0316 __assume(0); \
0317 } while (0)
0318 #else
0319 #define UPB_UNREACHABLE() \
0320 do { \
0321 assert(0); \
0322 } while (0)
0323 #endif
0324
0325 #ifdef __ANDROID__
0326 #define UPB_DEFAULT_MAX_BLOCK_SIZE 8192
0327 #else
0328 #define UPB_DEFAULT_MAX_BLOCK_SIZE 32768
0329 #endif
0330
0331 /* UPB_SETJMP() / UPB_LONGJMP() */
0332 // Android uses a custom libc that does not implement all of posix, but it has
0333 // had sigsetjmp/siglongjmp forever on arm and since API 12 on x86. Apple has
0334 // sigsetjmp, but does not define the posix feature test macro.
0335 #if defined(__APPLE__) || defined(_POSIX_C_SOURCE) || defined(__ANDROID__)
0336 // avoid setting/restoring signal mask, which involves costly syscalls
0337 #define UPB_SETJMP(buf) sigsetjmp(buf, 0)
0338 #define UPB_LONGJMP(buf, val) siglongjmp(buf, val)
0339 #elif defined(WASM_WAMR)
0340 #define UPB_SETJMP(buf) 0
0341 #define UPB_LONGJMP(buf, val) abort()
0342 #else
0343 #define UPB_SETJMP(buf) setjmp(buf)
0344 #define UPB_LONGJMP(buf, val) longjmp(buf, val)
0345 #endif
0346
0347 #if ((__STDC_VERSION__ >= 201112L) && !defined(__STDC_NO_ATOMICS__)) || \
0348 UPB_HAS_EXTENSION(c_atomic) || \
0349 defined(__GNUC__) // GCC supported atomics as an extension before it
0350 // supported __has_extension
0351 #define UPB_USE_C11_ATOMICS
0352 #elif defined(_MSC_VER)
0353 #define UPB_USE_MSC_ATOMICS
0354 #endif
0355
0356 #if defined(UPB_USE_C11_ATOMICS)
0357 #define UPB_ATOMIC(T) _Atomic(T)
0358 #elif defined(UPB_USE_MSC_ATOMICS)
0359 #define UPB_ATOMIC(T) volatile T
0360 #else
0361 #define UPB_ATOMIC(T) T
0362 #endif
0363
0364 /* UPB_PTRADD(ptr, ofs): add pointer while avoiding "NULL + 0" UB */
0365 #define UPB_PTRADD(ptr, ofs) ((ofs) ? (ptr) + (ofs) : (ptr))
0366
0367 #define UPB_PRIVATE(x) x##_dont_copy_me__upb_internal_use_only
0368
0369 #ifdef UPB_ALLOW_PRIVATE_ACCESS__FOR_BITS_ONLY
0370 #define UPB_ONLYBITS(x) x
0371 #else
0372 #define UPB_ONLYBITS(x) UPB_PRIVATE(x)
0373 #endif
0374
0375 /* Configure whether fasttable is switched on or not. *************************/
0376
0377 #if UPB_HAS_ATTRIBUTE(musttail)
0378 #define UPB_MUSTTAIL __attribute__((musttail))
0379 #else
0380 #define UPB_MUSTTAIL
0381 #endif
0382
0383 #if UPB_HAS_ATTRIBUTE(preserve_none)
0384 #define UPB_PRESERVE_NONE __attribute__((preserve_none))
0385 #else
0386 #define UPB_PRESERVE_NONE
0387 #endif
0388
0389 /* This check is not fully robust: it does not require that we have "musttail"
0390 * support available. We need tail calls to avoid consuming arbitrary amounts
0391 * of stack space.
0392 *
0393 * GCC/Clang can mostly be trusted to generate tail calls as long as
0394 * optimization is enabled, but, debug builds will not generate tail calls
0395 * unless "musttail" is available.
0396 *
0397 * We should probably either:
0398 * 1. require that the compiler supports musttail.
0399 * 2. add some fallback code for when musttail isn't available (ie. return
0400 * instead of tail calling). This is safe and portable, but this comes at
0401 * a CPU cost.
0402 */
0403 #if (defined(__x86_64__) || defined(__aarch64__)) && defined(__GNUC__)
0404 #define UPB_FASTTABLE_SUPPORTED 1
0405 #else
0406 #define UPB_FASTTABLE_SUPPORTED 0
0407 #endif
0408
0409 /* define UPB_ENABLE_FASTTABLE to force fast table support.
0410 * This is useful when we want to ensure we are really getting fasttable,
0411 * for example for testing or benchmarking. */
0412 #if defined(UPB_ENABLE_FASTTABLE)
0413 #if !UPB_FASTTABLE_SUPPORTED
0414 #error fasttable is x86-64/ARM64 only and requires GCC or Clang.
0415 #endif
0416 #define UPB_FASTTABLE 1
0417 /* Define UPB_TRY_ENABLE_FASTTABLE to use fasttable if possible.
0418 * This is useful for releasing code that might be used on multiple platforms,
0419 * for example the PHP or Ruby C extensions. */
0420 #elif defined(UPB_TRY_ENABLE_FASTTABLE)
0421 #define UPB_FASTTABLE UPB_FASTTABLE_SUPPORTED
0422 #else
0423 #define UPB_FASTTABLE 0
0424 #endif
0425
0426 /* UPB_FASTTABLE_INIT() allows protos compiled for fasttable to gracefully
0427 * degrade to non-fasttable if the runtime or platform do not support it. */
0428 #if !UPB_FASTTABLE
0429 #define UPB_FASTTABLE_INIT(...)
0430 #define UPB_FASTTABLE_MASK(mask) -1
0431 #else
0432 #define UPB_FASTTABLE_INIT(...) __VA_ARGS__
0433 #define UPB_FASTTABLE_MASK(mask) mask
0434 #endif
0435
0436 #undef UPB_FASTTABLE_SUPPORTED
0437
0438 /* Disable proto2 arena behavior (TEMPORARY) **********************************/
0439
0440 #ifdef UPB_DISABLE_CLOSED_ENUM_CHECKING
0441 #define UPB_TREAT_CLOSED_ENUMS_LIKE_OPEN 1
0442 #else
0443 #define UPB_TREAT_CLOSED_ENUMS_LIKE_OPEN 0
0444 #endif
0445
0446 #if defined(__cplusplus)
0447 #if defined(__clang__) || UPB_GNUC_MIN(6, 0)
0448 // https://gcc.gnu.org/gcc-6/changes.html
0449 #if __cplusplus >= 201402L
0450 #define UPB_DEPRECATED [[deprecated]]
0451 #else
0452 #define UPB_DEPRECATED __attribute__((deprecated))
0453 #endif
0454 #else
0455 #define UPB_DEPRECATED
0456 #endif
0457 #else
0458 #define UPB_DEPRECATED
0459 #endif
0460
0461 #if defined(UPB_IS_GOOGLE3) && \
0462 (!defined(UPB_BOOTSTRAP_STAGE) || UPB_BOOTSTRAP_STAGE != 0)
0463 #define UPB_DESC(sym) proto2_##sym
0464 #define UPB_DESC_MINITABLE(sym) &proto2__##sym##_msg_init
0465 #elif defined(UPB_IS_GOOGLE3) && defined(UPB_BOOTSTRAP_STAGE) && \
0466 UPB_BOOTSTRAP_STAGE == 0
0467 #define UPB_DESC(sym) proto2_##sym
0468 #define UPB_DESC_MINITABLE(sym) proto2__##sym##_msg_init()
0469 #elif defined(UPB_BOOTSTRAP_STAGE) && UPB_BOOTSTRAP_STAGE == 0
0470 #define UPB_DESC(sym) google_protobuf_##sym
0471 #define UPB_DESC_MINITABLE(sym) google__protobuf__##sym##_msg_init()
0472 #else
0473 #define UPB_DESC(sym) google_protobuf_##sym
0474 #define UPB_DESC_MINITABLE(sym) &google__protobuf__##sym##_msg_init
0475 #endif
0476
0477 #undef UPB_IS_GOOGLE3
0478
0479 #ifdef __clang__
0480 #define UPB_NO_SANITIZE_ADDRESS __attribute__((no_sanitize("address")))
0481 #else
0482 #define UPB_NO_SANITIZE_ADDRESS
0483 #endif
0484
0485 // Linker arrays combine elements from multiple translation units into a single
0486 // array that can be iterated over at runtime.
0487 //
0488 // It is an alternative to pre-main "registration" functions.
0489 //
0490 // Usage:
0491 //
0492 // // In N translation units.
0493 // UPB_LINKARR_APPEND(foo_array) static int elems[3] = {1, 2, 3};
0494 //
0495 // // At runtime:
0496 // UPB_LINKARR_DECLARE(foo_array, int);
0497 //
0498 // void f() {
0499 // const int* start = UPB_LINKARR_START(foo_array);
0500 // const int* stop = UPB_LINKARR_STOP(foo_array);
0501 // for (const int* p = start; p < stop; p++) {
0502 // // Windows can introduce zero padding, so we have to skip zeroes.
0503 // if (*p != 0) {
0504 // vec.push_back(*p);
0505 // }
0506 // }
0507 // }
0508
0509 #if defined(__ELF__) || defined(__wasm__)
0510
0511 #define UPB_LINKARR_APPEND(name) \
0512 __attribute__((retain, used, \
0513 section("linkarr_" #name))) UPB_NO_SANITIZE_ADDRESS
0514 #define UPB_LINKARR_DECLARE(name, type) \
0515 extern type __start_linkarr_##name; \
0516 extern type __stop_linkarr_##name; \
0517 UPB_LINKARR_APPEND(name) type UPB_linkarr_internal_empty_##name[1]
0518 #define UPB_LINKARR_START(name) (&__start_linkarr_##name)
0519 #define UPB_LINKARR_STOP(name) (&__stop_linkarr_##name)
0520
0521 #elif defined(__MACH__)
0522
0523 /* As described in: https://stackoverflow.com/a/22366882 */
0524 #define UPB_LINKARR_APPEND(name) \
0525 __attribute__((retain, used, \
0526 section("__DATA,__la_" #name))) UPB_NO_SANITIZE_ADDRESS
0527 #define UPB_LINKARR_DECLARE(name, type) \
0528 extern type __start_linkarr_##name __asm( \
0529 "section$start$__DATA$__la_" #name); \
0530 extern type __stop_linkarr_##name __asm( \
0531 "section$end$__DATA$" \
0532 "__la_" #name); \
0533 UPB_LINKARR_APPEND(name) type UPB_linkarr_internal_empty_##name[1]
0534 #define UPB_LINKARR_START(name) (&__start_linkarr_##name)
0535 #define UPB_LINKARR_STOP(name) (&__stop_linkarr_##name)
0536
0537 #elif defined(_MSC_VER) && defined(__clang__)
0538
0539 /* See:
0540 * https://devblogs.microsoft.com/oldnewthing/20181107-00/?p=100155
0541 * https://devblogs.microsoft.com/oldnewthing/20181108-00/?p=100165
0542 * https://devblogs.microsoft.com/oldnewthing/20181109-00/?p=100175 */
0543
0544 // Usage of __attribute__ here probably means this is Clang-specific, and would
0545 // not work on MSVC.
0546 #define UPB_LINKARR_APPEND(name) \
0547 __declspec(allocate("la_" #name "$j")) \
0548 __attribute__((retain, used)) UPB_NO_SANITIZE_ADDRESS
0549 #define UPB_LINKARR_DECLARE(name, type) \
0550 __declspec(allocate("la_" #name "$a")) type __start_linkarr_##name; \
0551 __declspec(allocate("la_" #name "$z")) type __stop_linkarr_##name; \
0552 UPB_LINKARR_APPEND(name) type UPB_linkarr_internal_empty_##name[1] = {0}
0553 #define UPB_LINKARR_START(name) (&__start_linkarr_##name)
0554 #define UPB_LINKARR_STOP(name) (&__stop_linkarr_##name)
0555
0556 #else
0557
0558 // Linker arrays are not supported on this platform. Make appends a no-op but
0559 // don't define the other macros.
0560 #define UPB_LINKARR_APPEND(name)
0561
0562 #endif
0563
0564 // Future versions of upb will include breaking changes to some APIs.
0565 // This macro can be set to enable these API changes ahead of time, so that
0566 // user code can be updated before upgrading versions of protobuf.
0567 #ifdef UPB_FUTURE_BREAKING_CHANGES
0568
0569 #endif