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
31 * Defines GPR_ABSEIL_SYNC to use synchronization features from Abseil
33 #ifndef GPR_ABSEIL_SYNC
34 #if defined(__APPLE__)
35 // This is disabled on Apple platforms because macos/grpc_basictests_c_cpp
36 // fails with this. https://github.com/grpc/grpc/issues/23661
38 #define GPR_ABSEIL_SYNC 1
40 #endif // GPR_ABSEIL_SYNC
43 * Defines GRPC_ERROR_IS_ABSEIL_STATUS to use absl::Status for grpc_error_handle
45 // #define GRPC_ERROR_IS_ABSEIL_STATUS 1
47 /* Get windows.h included everywhere (we need it) */
48 #if defined(_WIN64) || defined(WIN64) || defined(_WIN32) || defined(WIN32)
49 #ifndef WIN32_LEAN_AND_MEAN
50 #define GRPC_WIN32_LEAN_AND_MEAN_WAS_NOT_DEFINED
51 #define WIN32_LEAN_AND_MEAN
52 #endif /* WIN32_LEAN_AND_MEAN */
55 #define GRPC_NOMINMX_WAS_NOT_DEFINED
63 "Please compile grpc with _WIN32_WINNT of at least 0x600 (aka Windows Vista)"
64 #else /* !defined(_WIN32_WINNT) */
65 #if (_WIN32_WINNT < 0x0600)
67 "Please compile grpc with _WIN32_WINNT of at least 0x600 (aka Windows Vista)"
68 #endif /* _WIN32_WINNT < 0x0600 */
69 #endif /* defined(_WIN32_WINNT) */
71 #ifdef GRPC_WIN32_LEAN_AND_MEAN_WAS_NOT_DEFINED
72 #undef GRPC_WIN32_LEAN_AND_MEAN_WAS_NOT_DEFINED
73 #undef WIN32_LEAN_AND_MEAN
74 #endif /* GRPC_WIN32_LEAN_AND_MEAN_WAS_NOT_DEFINED */
76 #ifdef GRPC_NOMINMAX_WAS_NOT_DEFINED
77 #undef GRPC_NOMINMAX_WAS_NOT_DEFINED
79 #endif /* GRPC_WIN32_LEAN_AND_MEAN_WAS_NOT_DEFINED */
80 #endif /* defined(_WIN64) || defined(WIN64) || defined(_WIN32) || \
83 /* Override this file with one for your platform if you need to redefine
86 #if !defined(GPR_NO_AUTODETECT_PLATFORM)
87 #if defined(_WIN64) || defined(WIN64) || defined(_WIN32) || defined(WIN32)
88 #if defined(_WIN64) || defined(WIN64)
93 #define GPR_PLATFORM_STRING "windows"
95 #define GPR_WINDOWS_SUBPROCESS 1
96 #define GPR_WINDOWS_ENV
98 #define GPR_GETPID_IN_UNISTD_H 1
99 #define GPR_MSYS_TMPFILE
100 #define GPR_POSIX_LOG
101 #define GPR_POSIX_STRING
102 #define GPR_POSIX_TIME
104 #define GPR_GETPID_IN_PROCESS_H 1
105 #define GPR_WINDOWS_TMPFILE
106 #define GPR_WINDOWS_LOG
107 #define GPR_WINDOWS_CRASH_HANDLER 1
108 #define GPR_WINDOWS_STAT
109 #define GPR_WINDOWS_STRING
110 #define GPR_WINDOWS_TIME
113 #define GPR_GCC_ATOMIC 1
115 #define GPR_WINDOWS_ATOMIC 1
117 #define GPR_STDCPP_TLS 1
118 #elif defined(ANDROID) || defined(__ANDROID__)
119 #define GPR_PLATFORM_STRING "android"
120 #define GPR_ANDROID 1
121 // TODO(apolcyn): re-evaluate support for c-ares
122 // on android after upgrading our c-ares dependency.
123 // See https://github.com/grpc/grpc/issues/18038.
126 #define GPR_ARCH_64 1
128 #define GPR_ARCH_32 1
130 #define GPR_CPU_POSIX 1
131 #define GPR_GCC_SYNC 1
132 #define GPR_STDCPP_TLS 1
133 #define GPR_POSIX_ENV 1
134 #define GPR_POSIX_TMPFILE 1
135 #define GPR_POSIX_STAT 1
136 #define GPR_ANDROID_LOG 1
137 #define GPR_POSIX_STRING 1
138 #define GPR_POSIX_SUBPROCESS 1
139 #define GPR_POSIX_SYNC 1
140 #define GPR_POSIX_TIME 1
141 #define GPR_HAS_PTHREAD_H 1
142 #define GPR_GETPID_IN_UNISTD_H 1
143 #define GPR_SUPPORT_CHANNELS_FROM_FD 1
144 #elif defined(__linux__)
145 #define GPR_PLATFORM_STRING "linux"
149 #ifndef _DEFAULT_SOURCE
150 #define _DEFAULT_SOURCE
155 #include <features.h>
156 #define GPR_CPU_LINUX 1
157 #define GPR_GCC_ATOMIC 1
158 #define GPR_STDCPP_TLS 1
160 #define GPR_LINUX_LOG
161 #define GPR_SUPPORT_CHANNELS_FROM_FD 1
162 #define GPR_LINUX_ENV 1
163 #define GPR_POSIX_TMPFILE 1
164 #define GPR_POSIX_STAT 1
165 #define GPR_POSIX_STRING 1
166 #define GPR_POSIX_SUBPROCESS 1
167 #define GPR_POSIX_SYNC 1
168 #define GPR_POSIX_TIME 1
169 #define GPR_HAS_PTHREAD_H 1
170 #define GPR_GETPID_IN_UNISTD_H 1
172 #define GPR_ARCH_64 1
174 #define GPR_ARCH_32 1
177 #define GPR_POSIX_CRASH_HANDLER 1
178 #define GPR_LINUX_PTHREAD_NAME 1
179 #include <linux/version.h>
180 #else /* musl libc */
181 #define GPR_MUSL_LIBC_COMPAT 1
183 #elif defined(__ASYLO__)
184 #define GPR_ARCH_64 1
185 #define GPR_CPU_POSIX 1
186 #define GPR_GCC_TLS 1
187 #define GPR_PLATFORM_STRING "asylo"
188 #define GPR_GCC_SYNC 1
189 #define GPR_POSIX_SYNC 1
190 #define GPR_POSIX_STRING 1
191 #define GPR_POSIX_LOG 1
192 #define GPR_POSIX_TIME 1
193 #define GPR_POSIX_ENV 1
195 #define GRPC_POSIX_SOCKET 1
196 #define GRPC_POSIX_SOCKETADDR
197 #define GRPC_POSIX_SOCKETUTILS 1
198 #define GRPC_TIMER_USE_GENERIC 1
199 #define GRPC_POSIX_NO_SPECIAL_WAKEUP_FD 1
200 #define GRPC_POSIX_WAKEUP_FD 1
202 #define GPR_NO_AUTODETECT_PLATFORM 1
203 #elif defined(__APPLE__)
204 #include <Availability.h>
205 #include <TargetConditionals.h>
210 #define GPR_PLATFORM_STRING "ios"
211 #define GPR_CPU_IPHONE 1
212 #define GRPC_CFSTREAM 1
213 /* the c-ares resolver isn't safe to enable on iOS */
215 #else /* TARGET_OS_IPHONE */
216 #define GPR_PLATFORM_STRING "osx"
217 #define GPR_CPU_POSIX 1
218 #define GPR_POSIX_CRASH_HANDLER 1
221 #if __has_feature(cxx_thread_local)
222 #define GPR_STDCPP_TLS 1
225 #ifndef GPR_STDCPP_TLS
226 #define GPR_PTHREAD_TLS 1
229 #define GPR_GCC_ATOMIC 1
230 #define GPR_POSIX_LOG 1
231 #define GPR_POSIX_ENV 1
232 #define GPR_POSIX_TMPFILE 1
233 #define GPR_POSIX_STAT 1
234 #define GPR_POSIX_STRING 1
235 #define GPR_POSIX_SUBPROCESS 1
236 #define GPR_POSIX_SYNC 1
237 #define GPR_POSIX_TIME 1
238 #define GPR_HAS_PTHREAD_H 1
239 #define GPR_GETPID_IN_UNISTD_H 1
240 #ifndef GRPC_CFSTREAM
241 #define GPR_SUPPORT_CHANNELS_FROM_FD 1
244 #define GPR_ARCH_64 1
246 #define GPR_ARCH_32 1
248 #elif defined(__FreeBSD__)
249 #define GPR_PLATFORM_STRING "freebsd"
253 #define GPR_FREEBSD 1
254 #define GPR_CPU_POSIX 1
255 #define GPR_GCC_ATOMIC 1
256 #define GPR_GCC_TLS 1
257 #define GPR_POSIX_LOG 1
258 #define GPR_POSIX_ENV 1
259 #define GPR_POSIX_TMPFILE 1
260 #define GPR_POSIX_STAT 1
261 #define GPR_POSIX_STRING 1
262 #define GPR_POSIX_SUBPROCESS 1
263 #define GPR_POSIX_SYNC 1
264 #define GPR_POSIX_TIME 1
265 #define GPR_HAS_PTHREAD_H 1
266 #define GPR_GETPID_IN_UNISTD_H 1
267 #define GPR_SUPPORT_CHANNELS_FROM_FD 1
269 #define GPR_ARCH_64 1
271 #define GPR_ARCH_32 1
273 #elif defined(__OpenBSD__)
274 #define GPR_PLATFORM_STRING "openbsd"
278 #define GPR_OPENBSD 1
279 #define GPR_CPU_POSIX 1
280 #define GPR_GCC_ATOMIC 1
281 #define GPR_GCC_TLS 1
282 #define GPR_POSIX_LOG 1
283 #define GPR_POSIX_ENV 1
284 #define GPR_POSIX_TMPFILE 1
285 #define GPR_POSIX_STAT 1
286 #define GPR_POSIX_STRING 1
287 #define GPR_POSIX_SUBPROCESS 1
288 #define GPR_POSIX_SYNC 1
289 #define GPR_POSIX_TIME 1
290 #define GPR_HAS_PTHREAD_H 1
291 #define GPR_GETPID_IN_UNISTD_H 1
292 #define GPR_SUPPORT_CHANNELS_FROM_FD 1
294 #define GPR_ARCH_64 1
296 #define GPR_ARCH_32 1
298 #elif defined(__sun) && defined(__SVR4)
299 #define GPR_PLATFORM_STRING "solaris"
300 #define GPR_SOLARIS 1
301 #define GPR_CPU_POSIX 1
302 #define GPR_GCC_ATOMIC 1
303 #define GPR_GCC_TLS 1
304 #define GPR_POSIX_LOG 1
305 #define GPR_POSIX_ENV 1
306 #define GPR_POSIX_TMPFILE 1
307 #define GPR_POSIX_STAT 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_STAT 1
332 #define GPR_POSIX_STRING 1
333 #define GPR_POSIX_SUBPROCESS 1
334 #define GPR_POSIX_SYNC 1
335 #define GPR_POSIX_TIME 1
336 #define GPR_HAS_PTHREAD_H 1
337 #define GPR_GETPID_IN_UNISTD_H 1
339 #define GPR_ARCH_64 1
341 #define GPR_ARCH_32 1
343 #elif defined(__native_client__)
344 #define GPR_PLATFORM_STRING "nacl"
348 #ifndef _DEFAULT_SOURCE
349 #define _DEFAULT_SOURCE
355 #define GPR_CPU_POSIX 1
356 #define GPR_GCC_ATOMIC 1
357 #define GPR_GCC_TLS 1
358 #define GPR_POSIX_LOG 1
359 #define GPR_POSIX_ENV 1
360 #define GPR_POSIX_TMPFILE 1
361 #define GPR_POSIX_STAT 1
362 #define GPR_POSIX_STRING 1
363 #define GPR_POSIX_SUBPROCESS 1
364 #define GPR_POSIX_SYNC 1
365 #define GPR_POSIX_TIME 1
366 #define GPR_HAS_PTHREAD_H 1
367 #define GPR_GETPID_IN_UNISTD_H 1
369 #define GPR_ARCH_64 1
371 #define GPR_ARCH_32 1
373 #elif defined(__Fuchsia__)
375 #define GPR_FUCHSIA 1
376 #define GPR_ARCH_64 1
377 #define GPR_PLATFORM_STRING "fuchsia"
378 #include <features.h>
379 // Specifying musl libc affects wrap_memcpy.c. It causes memmove() to be
381 #define GPR_MUSL_LIBC_COMPAT 1
382 #define GPR_CPU_POSIX 1
383 #define GPR_GCC_ATOMIC 1
384 #define GPR_PTHREAD_TLS 1
385 #define GPR_POSIX_LOG 1
386 #define GPR_POSIX_SYNC 1
387 #define GPR_POSIX_ENV 1
388 #define GPR_POSIX_TMPFILE 1
389 #define GPR_POSIX_STAT 1
390 #define GPR_POSIX_SUBPROCESS 1
391 #define GPR_POSIX_SYNC 1
392 #define GPR_POSIX_STRING 1
393 #define GPR_POSIX_TIME 1
394 #define GPR_HAS_PTHREAD_H 1
395 #define GPR_GETPID_IN_UNISTD_H 1
396 #define GRPC_ROOT_PEM_PATH "/config/ssl/cert.pem"
398 #error "Could not auto-detect platform"
400 #endif /* GPR_NO_AUTODETECT_PLATFORM */
402 #if defined(GPR_BACKWARDS_COMPATIBILITY_MODE)
404 * For backward compatibility mode, reset _FORTIFY_SOURCE to prevent
405 * a library from having non-standard symbols such as __asprintf_chk.
406 * This helps non-glibc systems such as alpine using musl to find symbols.
408 #if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0
409 #undef _FORTIFY_SOURCE
410 #define _FORTIFY_SOURCE 0
414 #if defined(__has_include)
415 #if __has_include(<atomic>)
416 #define GRPC_HAS_CXX11_ATOMIC
417 #endif /* __has_include(<atomic>) */
418 #endif /* defined(__has_include) */
420 #ifndef GPR_PLATFORM_STRING
421 #warning "GPR_PLATFORM_STRING not auto-detected"
422 #define GPR_PLATFORM_STRING "unknown"
426 #undef GPR_FORBID_UNREACHABLE_CODE
427 #define GPR_FORBID_UNREACHABLE_CODE 1
432 typedef __int8 int8_t;
433 typedef __int16 int16_t;
434 typedef __int32 int32_t;
435 typedef __int64 int64_t;
436 typedef unsigned __int8 uint8_t;
437 typedef unsigned __int16 uint16_t;
438 typedef unsigned __int32 uint32_t;
439 typedef unsigned __int64 uint64_t;
442 #endif /* _MSC_VER < 1700 */
445 #endif /* _MSC_VER */
447 /* Type of cycle clock implementation */
449 /* Disable cycle clock by default.
450 TODO(soheil): enable when we support fallback for unstable cycle clocks.
451 #if defined(__i386__)
452 #define GPR_CYCLE_COUNTER_RDTSC_32 1
453 #elif defined(__x86_64__) || defined(__amd64__)
454 #define GPR_CYCLE_COUNTER_RDTSC_64 1
456 #define GPR_CYCLE_COUNTER_FALLBACK 1
459 #define GPR_CYCLE_COUNTER_FALLBACK 1
461 #define GPR_CYCLE_COUNTER_FALLBACK 1
462 #endif /* GPR_LINUX */
464 /* Cache line alignment */
465 #ifndef GPR_CACHELINE_SIZE_LOG
466 #if defined(__i386__) || defined(__x86_64__)
467 #define GPR_CACHELINE_SIZE_LOG 6
469 #ifndef GPR_CACHELINE_SIZE_LOG
470 /* A reasonable default guess. Note that overestimates tend to waste more
471 space, while underestimates tend to waste more time. */
472 #define GPR_CACHELINE_SIZE_LOG 6
473 #endif /* GPR_CACHELINE_SIZE_LOG */
474 #endif /* GPR_CACHELINE_SIZE_LOG */
476 #define GPR_CACHELINE_SIZE (1 << GPR_CACHELINE_SIZE_LOG)
478 /* scrub GCC_ATOMIC if it's not available on this compiler */
479 #if defined(GPR_GCC_ATOMIC) && !defined(__ATOMIC_RELAXED)
480 #undef GPR_GCC_ATOMIC
481 #define GPR_GCC_SYNC 1
484 /* Validate platform combinations */
485 #if defined(GPR_GCC_ATOMIC) + defined(GPR_GCC_SYNC) + \
486 defined(GPR_WINDOWS_ATOMIC) != \
488 #error Must define exactly one of GPR_GCC_ATOMIC, GPR_GCC_SYNC, GPR_WINDOWS_ATOMIC
491 #if defined(GPR_ARCH_32) + defined(GPR_ARCH_64) != 1
492 #error Must define exactly one of GPR_ARCH_32, GPR_ARCH_64
495 #if defined(GPR_CPU_LINUX) + defined(GPR_CPU_POSIX) + defined(GPR_WINDOWS) + \
496 defined(GPR_CPU_IPHONE) + defined(GPR_CPU_CUSTOM) != \
498 #error Must define exactly one of GPR_CPU_LINUX, GPR_CPU_POSIX, GPR_WINDOWS, GPR_CPU_IPHONE, GPR_CPU_CUSTOM
501 #if defined(GPR_MSVC_TLS) + defined(GPR_GCC_TLS) + defined(GPR_PTHREAD_TLS) + \
502 defined(GPR_STDCPP_TLS) + defined(GPR_CUSTOM_TLS) != \
504 #error Must define exactly one of GPR_MSVC_TLS, GPR_GCC_TLS, GPR_PTHREAD_TLS, GPR_STDCPP_TLS, GPR_CUSTOM_TLS
507 /* maximum alignment needed for any type on this platform, rounded up to a
509 #define GPR_MAX_ALIGNMENT 16
515 #ifndef GRPC_IF_NAMETOINDEX
516 #define GRPC_IF_NAMETOINDEX 1
519 #ifndef GRPC_MUST_USE_RESULT
520 #if defined(__GNUC__) && !defined(__MINGW32__)
521 #define GRPC_MUST_USE_RESULT __attribute__((warn_unused_result))
522 #define GPR_ALIGN_STRUCT(n) __attribute__((aligned(n)))
524 #define GRPC_MUST_USE_RESULT
525 #define GPR_ALIGN_STRUCT(n)
530 #if defined(__GNUC__) && !defined(__MINGW32__)
531 #define GRPC_UNUSED __attribute__((unused))
537 #ifndef GPR_PRINT_FORMAT_CHECK
539 #define GPR_PRINT_FORMAT_CHECK(FORMAT_STR, ARGS) \
540 __attribute__((format(printf, FORMAT_STR, ARGS)))
542 #define GPR_PRINT_FORMAT_CHECK(FORMAT_STR, ARGS)
544 #endif /* GPR_PRINT_FORMAT_CHECK */
546 #if GPR_FORBID_UNREACHABLE_CODE
547 #define GPR_UNREACHABLE_CODE(STATEMENT)
549 #define GPR_UNREACHABLE_CODE(STATEMENT) \
551 gpr_log(GPR_ERROR, "Should never reach here."); \
555 #endif /* GPR_FORBID_UNREACHABLE_CODE */
562 #define GRPCAPI GPRAPI
566 #define CENSUSAPI GRPCAPI
569 #ifndef GPR_HAS_ATTRIBUTE
570 #ifdef __has_attribute
571 #define GPR_HAS_ATTRIBUTE(a) __has_attribute(a)
573 #define GPR_HAS_ATTRIBUTE(a) 0
575 #endif /* GPR_HAS_ATTRIBUTE */
577 #ifndef GPR_HAS_FEATURE
579 #define GPR_HAS_FEATURE(a) __has_feature(a)
581 #define GPR_HAS_FEATURE(a) 0
583 #endif /* GPR_HAS_FEATURE */
585 #ifndef GPR_ATTRIBUTE_NOINLINE
586 #if GPR_HAS_ATTRIBUTE(noinline) || (defined(__GNUC__) && !defined(__clang__))
587 #define GPR_ATTRIBUTE_NOINLINE __attribute__((noinline))
588 #define GPR_HAS_ATTRIBUTE_NOINLINE 1
590 #define GPR_ATTRIBUTE_NOINLINE
592 #endif /* GPR_ATTRIBUTE_NOINLINE */
594 #ifndef GPR_ATTRIBUTE_WEAK
595 /* Attribute weak is broken on LLVM/windows:
596 * https://bugs.llvm.org/show_bug.cgi?id=37598 */
597 #if (GPR_HAS_ATTRIBUTE(weak) || (defined(__GNUC__) && !defined(__clang__))) && \
598 !(defined(__llvm__) && defined(_WIN32))
599 #define GPR_ATTRIBUTE_WEAK __attribute__((weak))
600 #define GPR_HAS_ATTRIBUTE_WEAK 1
602 #define GPR_ATTRIBUTE_WEAK
604 #endif /* GPR_ATTRIBUTE_WEAK */
606 #ifndef GPR_ATTRIBUTE_NO_TSAN /* (1) */
607 #if GPR_HAS_FEATURE(thread_sanitizer)
608 #define GPR_ATTRIBUTE_NO_TSAN __attribute__((no_sanitize("thread")))
609 #endif /* GPR_HAS_FEATURE */
610 #ifndef GPR_ATTRIBUTE_NO_TSAN /* (2) */
611 #define GPR_ATTRIBUTE_NO_TSAN
612 #endif /* GPR_ATTRIBUTE_NO_TSAN (2) */
613 #endif /* GPR_ATTRIBUTE_NO_TSAN (1) */
615 /* GRPC_TSAN_ENABLED will be defined, when compiled with thread sanitizer. */
616 #ifndef GRPC_TSAN_SUPPRESSED
617 #if defined(__SANITIZE_THREAD__)
618 #define GRPC_TSAN_ENABLED
619 #elif GPR_HAS_FEATURE(thread_sanitizer)
620 #define GRPC_TSAN_ENABLED
624 /* GRPC_ASAN_ENABLED will be defined, when compiled with address sanitizer. */
625 #ifndef GRPC_ASAN_SUPPRESSED
626 #if defined(__SANITIZE_ADDRESS__)
627 #define GRPC_ASAN_ENABLED
628 #elif GPR_HAS_FEATURE(address_sanitizer)
629 #define GRPC_ASAN_ENABLED
633 /* GRPC_ALLOW_EXCEPTIONS should be 0 or 1 if exceptions are allowed or not */
634 #ifndef GRPC_ALLOW_EXCEPTIONS
636 #if defined(_MSC_VER) && defined(_CPPUNWIND)
637 #define GRPC_ALLOW_EXCEPTIONS 1
638 #elif defined(__EXCEPTIONS)
639 #define GRPC_ALLOW_EXCEPTIONS 1
641 #define GRPC_ALLOW_EXCEPTIONS 0
643 #else /* GPR_WINDOWS */
645 #define GRPC_ALLOW_EXCEPTIONS 1
646 #else /* __EXCEPTIONS */
647 #define GRPC_ALLOW_EXCEPTIONS 0
648 #endif /* __EXCEPTIONS */
649 #endif /* __GPR_WINDOWS */
650 #endif /* GRPC_ALLOW_EXCEPTIONS */
652 /* Use GPR_LIKELY only in cases where you are sure that a certain outcome is the
653 * most likely. Ideally, also collect performance numbers to justify the claim.
656 #define GPR_LIKELY(x) __builtin_expect((x), 1)
657 #define GPR_UNLIKELY(x) __builtin_expect((x), 0)
659 #define GPR_LIKELY(x) (x)
660 #define GPR_UNLIKELY(x) (x)
661 #endif /* __GNUC__ */
663 #ifndef __STDC_FORMAT_MACROS
664 #define __STDC_FORMAT_MACROS
667 #endif /* GRPC_IMPL_CODEGEN_PORT_PLATFORM_H */