3 * Copyright 2015 gRPC authors.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
19 #ifndef GRPC_IMPL_CODEGEN_PORT_PLATFORM_H
20 #define GRPC_IMPL_CODEGEN_PORT_PLATFORM_H
23 * Define GPR_BACKWARDS_COMPATIBILITY_MODE to try harder to be ABI
24 * compatible with older platforms (currently only on Linux)
26 * - some libc calls to be gotten via dlsym
27 * - some syscalls to be made directly
30 /* Get windows.h included everywhere (we need it) */
31 #if defined(_WIN64) || defined(WIN64) || defined(_WIN32) || defined(WIN32)
32 #ifndef WIN32_LEAN_AND_MEAN
33 #define GRPC_WIN32_LEAN_AND_MEAN_WAS_NOT_DEFINED
34 #define WIN32_LEAN_AND_MEAN
35 #endif /* WIN32_LEAN_AND_MEAN */
38 #define GRPC_NOMINMX_WAS_NOT_DEFINED
44 "Please compile grpc with _WIN32_WINNT of at least 0x600 (aka Windows Vista)"
45 #else /* !defined(_WIN32_WINNT) */
46 #if (_WIN32_WINNT < 0x0600)
48 "Please compile grpc with _WIN32_WINNT of at least 0x600 (aka Windows Vista)"
49 #endif /* _WIN32_WINNT < 0x0600 */
50 #endif /* defined(_WIN32_WINNT) */
54 #ifdef GRPC_WIN32_LEAN_AND_MEAN_WAS_NOT_DEFINED
55 #undef GRPC_WIN32_LEAN_AND_MEAN_WAS_NOT_DEFINED
56 #undef WIN32_LEAN_AND_MEAN
57 #endif /* GRPC_WIN32_LEAN_AND_MEAN_WAS_NOT_DEFINED */
59 #ifdef GRPC_NOMINMAX_WAS_NOT_DEFINED
60 #undef GRPC_NOMINMAX_WAS_NOT_DEFINED
62 #endif /* GRPC_WIN32_LEAN_AND_MEAN_WAS_NOT_DEFINED */
63 #endif /* defined(_WIN64) || defined(WIN64) || defined(_WIN32) || \
66 /* Override this file with one for your platform if you need to redefine
69 #if !defined(GPR_NO_AUTODETECT_PLATFORM)
70 #if defined(_WIN64) || defined(WIN64) || defined(_WIN32) || defined(WIN32)
71 #if defined(_WIN64) || defined(WIN64)
76 #define GPR_PLATFORM_STRING "windows"
78 #define GPR_WINDOWS_SUBPROCESS 1
79 #define GPR_WINDOWS_ENV
81 #define GPR_GETPID_IN_UNISTD_H 1
82 #define GPR_MSYS_TMPFILE
84 #define GPR_POSIX_STRING
85 #define GPR_POSIX_TIME
87 #define GPR_GETPID_IN_PROCESS_H 1
88 #define GPR_WINDOWS_TMPFILE
89 #define GPR_WINDOWS_LOG
90 #define GPR_WINDOWS_CRASH_HANDLER 1
91 #define GPR_WINDOWS_STRING
92 #define GPR_WINDOWS_TIME
95 #define GPR_GCC_ATOMIC 1
98 #define GPR_WINDOWS_ATOMIC 1
99 #define GPR_MSVC_TLS 1
101 #elif defined(GPR_MANYLINUX1)
102 // TODO(atash): manylinux1 is just another __linux__ but with ancient
103 // libraries; it should be integrated with the `__linux__` definitions below.
104 #define GPR_PLATFORM_STRING "manylinux"
105 #define GPR_POSIX_CRASH_HANDLER 1
106 #define GPR_CPU_POSIX 1
107 #define GPR_GCC_ATOMIC 1
108 #define GPR_GCC_TLS 1
110 #define GPR_LINUX_LOG 1
111 #define GPR_SUPPORT_CHANNELS_FROM_FD 1
112 #define GPR_LINUX_ENV 1
113 #define GPR_POSIX_TMPFILE 1
114 #define GPR_POSIX_STRING 1
115 #define GPR_POSIX_SUBPROCESS 1
116 #define GPR_POSIX_SYNC 1
117 #define GPR_POSIX_TIME 1
118 #define GPR_HAS_PTHREAD_H 1
119 #define GPR_GETPID_IN_UNISTD_H 1
121 #define GPR_ARCH_64 1
123 #define GPR_ARCH_32 1
125 #include <linux/version.h>
126 #elif defined(ANDROID) || defined(__ANDROID__)
127 #define GPR_PLATFORM_STRING "android"
128 #define GPR_ANDROID 1
129 // TODO(apolcyn): re-evaluate support for c-ares
130 // on android after upgrading our c-ares dependency.
131 // See https://github.com/grpc/grpc/issues/18038.
134 #define GPR_ARCH_64 1
136 #define GPR_ARCH_32 1
138 #define GPR_CPU_POSIX 1
139 #define GPR_GCC_SYNC 1
140 #define GPR_GCC_TLS 1
141 #define GPR_POSIX_ENV 1
142 #define GPR_POSIX_TMPFILE 1
143 #define GPR_ANDROID_LOG 1
144 #define GPR_POSIX_STRING 1
145 #define GPR_POSIX_SUBPROCESS 1
146 #define GPR_POSIX_SYNC 1
147 #define GPR_POSIX_TIME 1
148 #define GPR_HAS_PTHREAD_H 1
149 #define GPR_GETPID_IN_UNISTD_H 1
150 #define GPR_SUPPORT_CHANNELS_FROM_FD 1
151 #elif defined(__linux__)
152 #define GPR_PLATFORM_STRING "linux"
156 #ifndef _DEFAULT_SOURCE
157 #define _DEFAULT_SOURCE
162 #include <features.h>
163 #define GPR_CPU_LINUX 1
164 #define GPR_GCC_ATOMIC 1
165 #define GPR_GCC_TLS 1
167 #define GPR_LINUX_LOG
168 #define GPR_SUPPORT_CHANNELS_FROM_FD 1
169 #define GPR_LINUX_ENV 1
170 #define GPR_POSIX_TMPFILE 1
171 #define GPR_POSIX_STRING 1
172 #define GPR_POSIX_SUBPROCESS 1
173 #define GPR_POSIX_SYNC 1
174 #define GPR_POSIX_TIME 1
175 #define GPR_HAS_PTHREAD_H 1
176 #define GPR_GETPID_IN_UNISTD_H 1
178 #define GPR_ARCH_64 1
180 #define GPR_ARCH_32 1
183 #define GPR_POSIX_CRASH_HANDLER 1
184 #define GPR_LINUX_PTHREAD_NAME 1
185 #include <linux/version.h>
186 #else /* musl libc */
187 #define GPR_MUSL_LIBC_COMPAT 1
189 #elif defined(__APPLE__)
190 #include <Availability.h>
191 #include <TargetConditionals.h>
196 #define GPR_PLATFORM_STRING "ios"
197 #define GPR_CPU_IPHONE 1
198 #define GPR_PTHREAD_TLS 1
199 #define GRPC_CFSTREAM 1
200 /* the c-ares resolver isnt safe to enable on iOS */
202 #else /* TARGET_OS_IPHONE */
203 #define GPR_PLATFORM_STRING "osx"
204 #ifdef __MAC_OS_X_VERSION_MIN_REQUIRED
205 #if __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_7
206 #define GPR_CPU_IPHONE 1
207 #define GPR_PTHREAD_TLS 1
208 #else /* __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_7 */
209 #define GPR_CPU_POSIX 1
210 /* TODO(vjpai): there is a reported issue in bazel build for Mac where __thread
211 in a header is currently not working (bazelbuild/bazel#4341). Remove
212 the following conditional and use GPR_GCC_TLS when that is fixed */
213 #ifndef GRPC_BAZEL_BUILD
214 #define GPR_GCC_TLS 1
215 #else /* GRPC_BAZEL_BUILD */
216 #define GPR_PTHREAD_TLS 1
217 #endif /* GRPC_BAZEL_BUILD */
218 #define GPR_APPLE_PTHREAD_NAME 1
220 #else /* __MAC_OS_X_VERSION_MIN_REQUIRED */
221 #define GPR_CPU_POSIX 1
222 /* TODO(vjpai): Remove the following conditional and use only GPR_GCC_TLS
223 when bazelbuild/bazel#4341 is fixed */
224 #ifndef GRPC_BAZEL_BUILD
225 #define GPR_GCC_TLS 1
226 #else /* GRPC_BAZEL_BUILD */
227 #define GPR_PTHREAD_TLS 1
228 #endif /* GRPC_BAZEL_BUILD */
230 #define GPR_POSIX_CRASH_HANDLER 1
233 #define GPR_GCC_ATOMIC 1
234 #define GPR_POSIX_LOG 1
235 #define GPR_POSIX_ENV 1
236 #define GPR_POSIX_TMPFILE 1
237 #define GPR_POSIX_STRING 1
238 #define GPR_POSIX_SUBPROCESS 1
239 #define GPR_POSIX_SYNC 1
240 #define GPR_POSIX_TIME 1
241 #define GPR_HAS_PTHREAD_H 1
242 #define GPR_GETPID_IN_UNISTD_H 1
243 #ifndef GRPC_CFSTREAM
244 #define GPR_SUPPORT_CHANNELS_FROM_FD 1
247 #define GPR_ARCH_64 1
249 #define GPR_ARCH_32 1
251 #elif defined(__FreeBSD__)
252 #define GPR_PLATFORM_STRING "freebsd"
256 #define GPR_FREEBSD 1
257 #define GPR_CPU_POSIX 1
258 #define GPR_GCC_ATOMIC 1
259 #define GPR_GCC_TLS 1
260 #define GPR_POSIX_LOG 1
261 #define GPR_POSIX_ENV 1
262 #define GPR_POSIX_TMPFILE 1
263 #define GPR_POSIX_STRING 1
264 #define GPR_POSIX_SUBPROCESS 1
265 #define GPR_POSIX_SYNC 1
266 #define GPR_POSIX_TIME 1
267 #define GPR_HAS_PTHREAD_H 1
268 #define GPR_GETPID_IN_UNISTD_H 1
269 #define GPR_SUPPORT_CHANNELS_FROM_FD 1
271 #define GPR_ARCH_64 1
273 #define GPR_ARCH_32 1
275 #elif defined(__OpenBSD__)
276 #define GPR_PLATFORM_STRING "openbsd"
280 #define GPR_OPENBSD 1
281 #define GPR_CPU_POSIX 1
282 #define GPR_GCC_ATOMIC 1
283 #define GPR_GCC_TLS 1
284 #define GPR_POSIX_LOG 1
285 #define GPR_POSIX_ENV 1
286 #define GPR_POSIX_TMPFILE 1
287 #define GPR_POSIX_STRING 1
288 #define GPR_POSIX_SUBPROCESS 1
289 #define GPR_POSIX_SYNC 1
290 #define GPR_POSIX_TIME 1
291 #define GPR_HAS_PTHREAD_H 1
292 #define GPR_GETPID_IN_UNISTD_H 1
293 #define GPR_SUPPORT_CHANNELS_FROM_FD 1
295 #define GPR_ARCH_64 1
297 #define GPR_ARCH_32 1
299 #elif defined(__sun) && defined(__SVR4)
300 #define GPR_PLATFORM_STRING "solaris"
301 #define GPR_SOLARIS 1
302 #define GPR_CPU_POSIX 1
303 #define GPR_GCC_ATOMIC 1
304 #define GPR_GCC_TLS 1
305 #define GPR_POSIX_LOG 1
306 #define GPR_POSIX_ENV 1
307 #define GPR_POSIX_TMPFILE 1
308 #define GPR_POSIX_STRING 1
309 #define GPR_POSIX_SUBPROCESS 1
310 #define GPR_POSIX_SYNC 1
311 #define GPR_POSIX_TIME 1
312 #define GPR_HAS_PTHREAD_H 1
313 #define GPR_GETPID_IN_UNISTD_H 1
315 #define GPR_ARCH_64 1
317 #define GPR_ARCH_32 1
320 #define GPR_PLATFORM_STRING "aix"
325 #define GPR_CPU_POSIX 1
326 #define GPR_GCC_ATOMIC 1
327 #define GPR_GCC_TLS 1
328 #define GPR_POSIX_LOG 1
329 #define GPR_POSIX_ENV 1
330 #define GPR_POSIX_TMPFILE 1
331 #define GPR_POSIX_STRING 1
332 #define GPR_POSIX_SUBPROCESS 1
333 #define GPR_POSIX_SYNC 1
334 #define GPR_POSIX_TIME 1
335 #define GPR_HAS_PTHREAD_H 1
336 #define GPR_GETPID_IN_UNISTD_H 1
338 #define GPR_ARCH_64 1
340 #define GPR_ARCH_32 1
342 #elif defined(__native_client__)
343 #define GPR_PLATFORM_STRING "nacl"
347 #ifndef _DEFAULT_SOURCE
348 #define _DEFAULT_SOURCE
354 #define GPR_CPU_POSIX 1
355 #define GPR_GCC_ATOMIC 1
356 #define GPR_GCC_TLS 1
357 #define GPR_POSIX_LOG 1
358 #define GPR_POSIX_ENV 1
359 #define GPR_POSIX_TMPFILE 1
360 #define GPR_POSIX_STRING 1
361 #define GPR_POSIX_SUBPROCESS 1
362 #define GPR_POSIX_SYNC 1
363 #define GPR_POSIX_TIME 1
364 #define GPR_HAS_PTHREAD_H 1
365 #define GPR_GETPID_IN_UNISTD_H 1
367 #define GPR_ARCH_64 1
369 #define GPR_ARCH_32 1
371 #elif defined(__Fuchsia__)
372 #define GPR_FUCHSIA 1
373 #define GPR_ARCH_64 1
374 #define GPR_PLATFORM_STRING "fuchsia"
375 #include <features.h>
376 // Specifying musl libc affects wrap_memcpy.c. It causes memmove() to be
378 #define GPR_MUSL_LIBC_COMPAT 1
379 #define GPR_CPU_POSIX 1
380 #define GPR_GCC_ATOMIC 1
381 #define GPR_PTHREAD_TLS 1
382 #define GPR_POSIX_LOG 1
383 #define GPR_POSIX_SYNC 1
384 #define GPR_POSIX_ENV 1
385 #define GPR_POSIX_TMPFILE 1
386 #define GPR_POSIX_SUBPROCESS 1
387 #define GPR_POSIX_SYNC 1
388 #define GPR_POSIX_STRING 1
389 #define GPR_POSIX_TIME 1
390 #define GPR_HAS_PTHREAD_H 1
391 #define GPR_GETPID_IN_UNISTD_H 1
393 #error "Could not auto-detect platform"
395 #endif /* GPR_NO_AUTODETECT_PLATFORM */
397 #if defined(GPR_BACKWARDS_COMPATIBILITY_MODE)
399 * For backward compatibility mode, reset _FORTIFY_SOURCE to prevent
400 * a library from having non-standard symbols such as __asprintf_chk.
401 * This helps non-glibc systems such as alpine using musl to find symbols.
403 #if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0
404 #undef _FORTIFY_SOURCE
405 #define _FORTIFY_SOURCE 0
410 * There are platforms for which TLS should not be used even though the
411 * compiler makes it seem like it's supported (Android NDK < r12b for example).
412 * This is primarily because of linker problems and toolchain misconfiguration:
413 * TLS isn't supported until NDK r12b per
414 * https://developer.android.com/ndk/downloads/revision_history.html
415 * TLS also does not work with Android NDK if GCC is being used as the compiler
417 * Since NDK r16, `__NDK_MAJOR__` and `__NDK_MINOR__` are defined in
418 * <android/ndk-version.h>. For NDK < r16, users should define these macros,
419 * e.g. `-D__NDK_MAJOR__=11 -D__NKD_MINOR__=0` for NDK r11. */
420 #if defined(__ANDROID__) && defined(GPR_GCC_TLS)
421 #if __has_include(<android/ndk-version.h>)
422 #include <android/ndk-version.h>
423 #endif /* __has_include(<android/ndk-version.h>) */
424 #if (defined(__clang__) && defined(__NDK_MAJOR__) && defined(__NDK_MINOR__) && \
425 ((__NDK_MAJOR__ < 12) || \
426 ((__NDK_MAJOR__ == 12) && (__NDK_MINOR__ < 1)))) || \
427 (defined(__GNUC__) && !defined(__clang__))
429 #define GPR_PTHREAD_TLS 1
431 #endif /*defined(__ANDROID__) && defined(GPR_GCC_TLS) */
433 #if defined(__has_include)
434 #if __has_include(<atomic>)
435 #define GRPC_HAS_CXX11_ATOMIC
436 #endif /* __has_include(<atomic>) */
437 #endif /* defined(__has_include) */
439 #ifndef GPR_PLATFORM_STRING
440 #warning "GPR_PLATFORM_STRING not auto-detected"
441 #define GPR_PLATFORM_STRING "unknown"
445 #undef GPR_FORBID_UNREACHABLE_CODE
446 #define GPR_FORBID_UNREACHABLE_CODE 1
451 typedef __int8 int8_t;
452 typedef __int16 int16_t;
453 typedef __int32 int32_t;
454 typedef __int64 int64_t;
455 typedef unsigned __int8 uint8_t;
456 typedef unsigned __int16 uint16_t;
457 typedef unsigned __int32 uint32_t;
458 typedef unsigned __int64 uint64_t;
461 #endif /* _MSC_VER < 1700 */
464 #endif /* _MSC_VER */
466 /* Cache line alignment */
467 #ifndef GPR_CACHELINE_SIZE_LOG
468 #if defined(__i386__) || defined(__x86_64__)
469 #define GPR_CACHELINE_SIZE_LOG 6
471 #ifndef GPR_CACHELINE_SIZE_LOG
472 /* A reasonable default guess. Note that overestimates tend to waste more
473 space, while underestimates tend to waste more time. */
474 #define GPR_CACHELINE_SIZE_LOG 6
475 #endif /* GPR_CACHELINE_SIZE_LOG */
476 #endif /* GPR_CACHELINE_SIZE_LOG */
478 #define GPR_CACHELINE_SIZE (1 << GPR_CACHELINE_SIZE_LOG)
480 /* scrub GCC_ATOMIC if it's not available on this compiler */
481 #if defined(GPR_GCC_ATOMIC) && !defined(__ATOMIC_RELAXED)
482 #undef GPR_GCC_ATOMIC
483 #define GPR_GCC_SYNC 1
486 /* Validate platform combinations */
487 #if defined(GPR_GCC_ATOMIC) + defined(GPR_GCC_SYNC) + \
488 defined(GPR_WINDOWS_ATOMIC) != \
490 #error Must define exactly one of GPR_GCC_ATOMIC, GPR_GCC_SYNC, GPR_WINDOWS_ATOMIC
493 #if defined(GPR_ARCH_32) + defined(GPR_ARCH_64) != 1
494 #error Must define exactly one of GPR_ARCH_32, GPR_ARCH_64
497 #if defined(GPR_CPU_LINUX) + defined(GPR_CPU_POSIX) + defined(GPR_WINDOWS) + \
498 defined(GPR_CPU_IPHONE) + defined(GPR_CPU_CUSTOM) != \
500 #error Must define exactly one of GPR_CPU_LINUX, GPR_CPU_POSIX, GPR_WINDOWS, GPR_CPU_IPHONE, GPR_CPU_CUSTOM
503 #if defined(GPR_MSVC_TLS) + defined(GPR_GCC_TLS) + defined(GPR_PTHREAD_TLS) + \
504 defined(GPR_CUSTOM_TLS) != \
506 #error Must define exactly one of GPR_MSVC_TLS, GPR_GCC_TLS, GPR_PTHREAD_TLS, GPR_CUSTOM_TLS
509 /* maximum alignment needed for any type on this platform, rounded up to a
511 #define GPR_MAX_ALIGNMENT 16
517 #ifndef GRPC_IF_NAMETOINDEX
518 #define GRPC_IF_NAMETOINDEX 1
521 #ifndef GRPC_MUST_USE_RESULT
522 #if defined(__GNUC__) && !defined(__MINGW32__)
523 #define GRPC_MUST_USE_RESULT __attribute__((warn_unused_result))
524 #define GPR_ALIGN_STRUCT(n) __attribute__((aligned(n)))
526 #define GRPC_MUST_USE_RESULT
527 #define GPR_ALIGN_STRUCT(n)
532 #if defined(__GNUC__) && !defined(__MINGW32__)
533 #define GRPC_UNUSED __attribute__((unused))
539 #ifndef GPR_PRINT_FORMAT_CHECK
541 #define GPR_PRINT_FORMAT_CHECK(FORMAT_STR, ARGS) \
542 __attribute__((format(printf, FORMAT_STR, ARGS)))
544 #define GPR_PRINT_FORMAT_CHECK(FORMAT_STR, ARGS)
546 #endif /* GPR_PRINT_FORMAT_CHECK */
548 #if GPR_FORBID_UNREACHABLE_CODE
549 #define GPR_UNREACHABLE_CODE(STATEMENT)
551 #define GPR_UNREACHABLE_CODE(STATEMENT) \
553 gpr_log(GPR_ERROR, "Should never reach here."); \
557 #endif /* GPR_FORBID_UNREACHABLE_CODE */
564 #define GRPCAPI GPRAPI
568 #define CENSUSAPI GRPCAPI
571 #ifndef GPR_HAS_ATTRIBUTE
572 #ifdef __has_attribute
573 #define GPR_HAS_ATTRIBUTE(a) __has_attribute(a)
575 #define GPR_HAS_ATTRIBUTE(a) 0
577 #endif /* GPR_HAS_ATTRIBUTE */
579 #ifndef GPR_HAS_FEATURE
581 #define GPR_HAS_FEATURE(a) __has_feature(a)
583 #define GPR_HAS_FEATURE(a) 0
585 #endif /* GPR_HAS_FEATURE */
587 #ifndef GPR_ATTRIBUTE_NOINLINE
588 #if GPR_HAS_ATTRIBUTE(noinline) || (defined(__GNUC__) && !defined(__clang__))
589 #define GPR_ATTRIBUTE_NOINLINE __attribute__((noinline))
590 #define GPR_HAS_ATTRIBUTE_NOINLINE 1
592 #define GPR_ATTRIBUTE_NOINLINE
594 #endif /* GPR_ATTRIBUTE_NOINLINE */
596 #ifndef GPR_ATTRIBUTE_WEAK
597 /* Attribute weak is broken on LLVM/windows:
598 * https://bugs.llvm.org/show_bug.cgi?id=37598 */
599 #if (GPR_HAS_ATTRIBUTE(weak) || (defined(__GNUC__) && !defined(__clang__))) && \
600 !(defined(__llvm__) && defined(_WIN32))
601 #define GPR_ATTRIBUTE_WEAK __attribute__((weak))
602 #define GPR_HAS_ATTRIBUTE_WEAK 1
604 #define GPR_ATTRIBUTE_WEAK
606 #endif /* GPR_ATTRIBUTE_WEAK */
608 #ifndef GPR_ATTRIBUTE_NO_TSAN /* (1) */
609 #if GPR_HAS_FEATURE(thread_sanitizer)
610 #define GPR_ATTRIBUTE_NO_TSAN __attribute__((no_sanitize("thread")))
611 #endif /* GPR_HAS_FEATURE */
612 #ifndef GPR_ATTRIBUTE_NO_TSAN /* (2) */
613 #define GPR_ATTRIBUTE_NO_TSAN
614 #endif /* GPR_ATTRIBUTE_NO_TSAN (2) */
615 #endif /* GPR_ATTRIBUTE_NO_TSAN (1) */
617 /* GRPC_TSAN_ENABLED will be defined, when compiled with thread sanitizer. */
618 #if defined(__SANITIZE_THREAD__)
619 #define GRPC_TSAN_ENABLED
620 #elif GPR_HAS_FEATURE(thread_sanitizer)
621 #define GRPC_TSAN_ENABLED
624 /* GRPC_ASAN_ENABLED will be defined, when compiled with address sanitizer. */
625 #if defined(__SANITIZE_ADDRESS__)
626 #define GRPC_ASAN_ENABLED
627 #elif GPR_HAS_FEATURE(address_sanitizer)
628 #define GRPC_ASAN_ENABLED
631 /* GRPC_ALLOW_EXCEPTIONS should be 0 or 1 if exceptions are allowed or not */
632 #ifndef GRPC_ALLOW_EXCEPTIONS
633 /* If not already set, set to 1 on Windows (style guide standard) but to
634 * 0 on non-Windows platforms unless the compiler defines __EXCEPTIONS */
636 #define GRPC_ALLOW_EXCEPTIONS 1
637 #else /* GPR_WINDOWS */
639 #define GRPC_ALLOW_EXCEPTIONS 1
640 #else /* __EXCEPTIONS */
641 #define GRPC_ALLOW_EXCEPTIONS 0
642 #endif /* __EXCEPTIONS */
643 #endif /* __GPR_WINDOWS */
644 #endif /* GRPC_ALLOW_EXCEPTIONS */
646 /* Use GPR_LIKELY only in cases where you are sure that a certain outcome is the
647 * most likely. Ideally, also collect performance numbers to justify the claim.
650 #define GPR_LIKELY(x) __builtin_expect((x), 1)
651 #define GPR_UNLIKELY(x) __builtin_expect((x), 0)
653 #define GPR_LIKELY(x) (x)
654 #define GPR_UNLIKELY(x) (x)
655 #endif /* __GNUC__ */
657 #ifndef __STDC_FORMAT_MACROS
658 #define __STDC_FORMAT_MACROS
661 #endif /* GRPC_IMPL_CODEGEN_PORT_PLATFORM_H */