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
42 /* Get windows.h included everywhere (we need it) */
43 #if defined(_WIN64) || defined(WIN64) || defined(_WIN32) || defined(WIN32)
44 #ifndef WIN32_LEAN_AND_MEAN
45 #define GRPC_WIN32_LEAN_AND_MEAN_WAS_NOT_DEFINED
46 #define WIN32_LEAN_AND_MEAN
47 #endif /* WIN32_LEAN_AND_MEAN */
50 #define GRPC_NOMINMX_WAS_NOT_DEFINED
58 "Please compile grpc with _WIN32_WINNT of at least 0x600 (aka Windows Vista)"
59 #else /* !defined(_WIN32_WINNT) */
60 #if (_WIN32_WINNT < 0x0600)
62 "Please compile grpc with _WIN32_WINNT of at least 0x600 (aka Windows Vista)"
63 #endif /* _WIN32_WINNT < 0x0600 */
64 #endif /* defined(_WIN32_WINNT) */
66 #ifdef GRPC_WIN32_LEAN_AND_MEAN_WAS_NOT_DEFINED
67 #undef GRPC_WIN32_LEAN_AND_MEAN_WAS_NOT_DEFINED
68 #undef WIN32_LEAN_AND_MEAN
69 #endif /* GRPC_WIN32_LEAN_AND_MEAN_WAS_NOT_DEFINED */
71 #ifdef GRPC_NOMINMAX_WAS_NOT_DEFINED
72 #undef GRPC_NOMINMAX_WAS_NOT_DEFINED
74 #endif /* GRPC_WIN32_LEAN_AND_MEAN_WAS_NOT_DEFINED */
75 #endif /* defined(_WIN64) || defined(WIN64) || defined(_WIN32) || \
78 /* Override this file with one for your platform if you need to redefine
81 #if !defined(GPR_NO_AUTODETECT_PLATFORM)
82 #if defined(_WIN64) || defined(WIN64) || defined(_WIN32) || defined(WIN32)
83 #if defined(_WIN64) || defined(WIN64)
88 #define GPR_PLATFORM_STRING "windows"
90 #define GPR_WINDOWS_SUBPROCESS 1
91 #define GPR_WINDOWS_ENV
93 #define GPR_GETPID_IN_UNISTD_H 1
94 #define GPR_MSYS_TMPFILE
96 #define GPR_POSIX_STRING
97 #define GPR_POSIX_TIME
99 #define GPR_GETPID_IN_PROCESS_H 1
100 #define GPR_WINDOWS_TMPFILE
101 #define GPR_WINDOWS_LOG
102 #define GPR_WINDOWS_CRASH_HANDLER 1
103 #define GPR_WINDOWS_STAT
104 #define GPR_WINDOWS_STRING
105 #define GPR_WINDOWS_TIME
108 #define GPR_GCC_ATOMIC 1
110 #define GPR_WINDOWS_ATOMIC 1
112 #define GPR_STDCPP_TLS 1
113 #elif defined(ANDROID) || defined(__ANDROID__)
114 #define GPR_PLATFORM_STRING "android"
115 #define GPR_ANDROID 1
116 // TODO(apolcyn): re-evaluate support for c-ares
117 // on android after upgrading our c-ares dependency.
118 // See https://github.com/grpc/grpc/issues/18038.
121 #define GPR_ARCH_64 1
123 #define GPR_ARCH_32 1
125 #define GPR_CPU_POSIX 1
126 #define GPR_GCC_SYNC 1
127 #define GPR_STDCPP_TLS 1
128 #define GPR_POSIX_ENV 1
129 #define GPR_POSIX_TMPFILE 1
130 #define GPR_POSIX_STAT 1
131 #define GPR_ANDROID_LOG 1
132 #define GPR_POSIX_STRING 1
133 #define GPR_POSIX_SUBPROCESS 1
134 #define GPR_POSIX_SYNC 1
135 #define GPR_POSIX_TIME 1
136 #define GPR_HAS_PTHREAD_H 1
137 #define GPR_GETPID_IN_UNISTD_H 1
138 #define GPR_SUPPORT_CHANNELS_FROM_FD 1
139 #elif defined(__linux__)
140 #define GPR_PLATFORM_STRING "linux"
144 #ifndef _DEFAULT_SOURCE
145 #define _DEFAULT_SOURCE
150 #include <features.h>
151 #define GPR_CPU_LINUX 1
152 #define GPR_GCC_ATOMIC 1
153 #define GPR_STDCPP_TLS 1
155 #define GPR_LINUX_LOG
156 #define GPR_SUPPORT_CHANNELS_FROM_FD 1
157 #define GPR_LINUX_ENV 1
158 #define GPR_POSIX_TMPFILE 1
159 #define GPR_POSIX_STAT 1
160 #define GPR_POSIX_STRING 1
161 #define GPR_POSIX_SUBPROCESS 1
162 #define GPR_POSIX_SYNC 1
163 #define GPR_POSIX_TIME 1
164 #define GPR_HAS_PTHREAD_H 1
165 #define GPR_GETPID_IN_UNISTD_H 1
167 #define GPR_ARCH_64 1
169 #define GPR_ARCH_32 1
172 #define GPR_POSIX_CRASH_HANDLER 1
173 #define GPR_LINUX_PTHREAD_NAME 1
174 #include <linux/version.h>
175 #else /* musl libc */
176 #define GPR_MUSL_LIBC_COMPAT 1
178 #elif defined(__ASYLO__)
179 #define GPR_ARCH_64 1
180 #define GPR_CPU_POSIX 1
181 #define GPR_GCC_TLS 1
182 #define GPR_PLATFORM_STRING "asylo"
183 #define GPR_GCC_SYNC 1
184 #define GPR_POSIX_SYNC 1
185 #define GPR_POSIX_STRING 1
186 #define GPR_POSIX_LOG 1
187 #define GPR_POSIX_TIME 1
188 #define GPR_POSIX_ENV 1
190 #define GRPC_POSIX_SOCKET 1
191 #define GRPC_POSIX_SOCKETADDR
192 #define GRPC_POSIX_SOCKETUTILS 1
193 #define GRPC_TIMER_USE_GENERIC 1
194 #define GRPC_POSIX_NO_SPECIAL_WAKEUP_FD 1
195 #define GRPC_POSIX_WAKEUP_FD 1
197 #define GPR_NO_AUTODETECT_PLATFORM 1
198 #elif defined(__APPLE__)
199 #include <Availability.h>
200 #include <TargetConditionals.h>
205 #define GPR_PLATFORM_STRING "ios"
206 #define GPR_CPU_IPHONE 1
207 #define GRPC_CFSTREAM 1
208 /* the c-ares resolver isn't safe to enable on iOS */
210 #else /* TARGET_OS_IPHONE */
211 #define GPR_PLATFORM_STRING "osx"
212 #define GPR_CPU_POSIX 1
213 #define GPR_POSIX_CRASH_HANDLER 1
216 #if __has_feature(cxx_thread_local)
217 #define GPR_STDCPP_TLS 1
220 #ifndef GPR_STDCPP_TLS
221 #define GPR_PTHREAD_TLS 1
224 #define GPR_GCC_ATOMIC 1
225 #define GPR_POSIX_LOG 1
226 #define GPR_POSIX_ENV 1
227 #define GPR_POSIX_TMPFILE 1
228 #define GPR_POSIX_STAT 1
229 #define GPR_POSIX_STRING 1
230 #define GPR_POSIX_SUBPROCESS 1
231 #define GPR_POSIX_SYNC 1
232 #define GPR_POSIX_TIME 1
233 #define GPR_HAS_PTHREAD_H 1
234 #define GPR_GETPID_IN_UNISTD_H 1
235 #ifndef GRPC_CFSTREAM
236 #define GPR_SUPPORT_CHANNELS_FROM_FD 1
239 #define GPR_ARCH_64 1
241 #define GPR_ARCH_32 1
243 #elif defined(__FreeBSD__)
244 #define GPR_PLATFORM_STRING "freebsd"
248 #define GPR_FREEBSD 1
249 #define GPR_CPU_POSIX 1
250 #define GPR_GCC_ATOMIC 1
251 #define GPR_GCC_TLS 1
252 #define GPR_POSIX_LOG 1
253 #define GPR_POSIX_ENV 1
254 #define GPR_POSIX_TMPFILE 1
255 #define GPR_POSIX_STAT 1
256 #define GPR_POSIX_STRING 1
257 #define GPR_POSIX_SUBPROCESS 1
258 #define GPR_POSIX_SYNC 1
259 #define GPR_POSIX_TIME 1
260 #define GPR_HAS_PTHREAD_H 1
261 #define GPR_GETPID_IN_UNISTD_H 1
262 #define GPR_SUPPORT_CHANNELS_FROM_FD 1
264 #define GPR_ARCH_64 1
266 #define GPR_ARCH_32 1
268 #elif defined(__OpenBSD__)
269 #define GPR_PLATFORM_STRING "openbsd"
273 #define GPR_OPENBSD 1
274 #define GPR_CPU_POSIX 1
275 #define GPR_GCC_ATOMIC 1
276 #define GPR_GCC_TLS 1
277 #define GPR_POSIX_LOG 1
278 #define GPR_POSIX_ENV 1
279 #define GPR_POSIX_TMPFILE 1
280 #define GPR_POSIX_STAT 1
281 #define GPR_POSIX_STRING 1
282 #define GPR_POSIX_SUBPROCESS 1
283 #define GPR_POSIX_SYNC 1
284 #define GPR_POSIX_TIME 1
285 #define GPR_HAS_PTHREAD_H 1
286 #define GPR_GETPID_IN_UNISTD_H 1
287 #define GPR_SUPPORT_CHANNELS_FROM_FD 1
289 #define GPR_ARCH_64 1
291 #define GPR_ARCH_32 1
293 #elif defined(__sun) && defined(__SVR4)
294 #define GPR_PLATFORM_STRING "solaris"
295 #define GPR_SOLARIS 1
296 #define GPR_CPU_POSIX 1
297 #define GPR_GCC_ATOMIC 1
298 #define GPR_GCC_TLS 1
299 #define GPR_POSIX_LOG 1
300 #define GPR_POSIX_ENV 1
301 #define GPR_POSIX_TMPFILE 1
302 #define GPR_POSIX_STAT 1
303 #define GPR_POSIX_STRING 1
304 #define GPR_POSIX_SUBPROCESS 1
305 #define GPR_POSIX_SYNC 1
306 #define GPR_POSIX_TIME 1
307 #define GPR_HAS_PTHREAD_H 1
308 #define GPR_GETPID_IN_UNISTD_H 1
310 #define GPR_ARCH_64 1
312 #define GPR_ARCH_32 1
315 #define GPR_PLATFORM_STRING "aix"
320 #define GPR_CPU_POSIX 1
321 #define GPR_GCC_ATOMIC 1
322 #define GPR_GCC_TLS 1
323 #define GPR_POSIX_LOG 1
324 #define GPR_POSIX_ENV 1
325 #define GPR_POSIX_TMPFILE 1
326 #define GPR_POSIX_STAT 1
327 #define GPR_POSIX_STRING 1
328 #define GPR_POSIX_SUBPROCESS 1
329 #define GPR_POSIX_SYNC 1
330 #define GPR_POSIX_TIME 1
331 #define GPR_HAS_PTHREAD_H 1
332 #define GPR_GETPID_IN_UNISTD_H 1
334 #define GPR_ARCH_64 1
336 #define GPR_ARCH_32 1
338 #elif defined(__native_client__)
339 #define GPR_PLATFORM_STRING "nacl"
343 #ifndef _DEFAULT_SOURCE
344 #define _DEFAULT_SOURCE
350 #define GPR_CPU_POSIX 1
351 #define GPR_GCC_ATOMIC 1
352 #define GPR_GCC_TLS 1
353 #define GPR_POSIX_LOG 1
354 #define GPR_POSIX_ENV 1
355 #define GPR_POSIX_TMPFILE 1
356 #define GPR_POSIX_STAT 1
357 #define GPR_POSIX_STRING 1
358 #define GPR_POSIX_SUBPROCESS 1
359 #define GPR_POSIX_SYNC 1
360 #define GPR_POSIX_TIME 1
361 #define GPR_HAS_PTHREAD_H 1
362 #define GPR_GETPID_IN_UNISTD_H 1
364 #define GPR_ARCH_64 1
366 #define GPR_ARCH_32 1
368 #elif defined(__Fuchsia__)
370 #define GPR_FUCHSIA 1
371 #define GPR_ARCH_64 1
372 #define GPR_PLATFORM_STRING "fuchsia"
373 #include <features.h>
374 // Specifying musl libc affects wrap_memcpy.c. It causes memmove() to be
376 #define GPR_MUSL_LIBC_COMPAT 1
377 #define GPR_CPU_POSIX 1
378 #define GPR_GCC_ATOMIC 1
379 #define GPR_PTHREAD_TLS 1
380 #define GPR_POSIX_LOG 1
381 #define GPR_POSIX_SYNC 1
382 #define GPR_POSIX_ENV 1
383 #define GPR_POSIX_TMPFILE 1
384 #define GPR_POSIX_STAT 1
385 #define GPR_POSIX_SUBPROCESS 1
386 #define GPR_POSIX_SYNC 1
387 #define GPR_POSIX_STRING 1
388 #define GPR_POSIX_TIME 1
389 #define GPR_HAS_PTHREAD_H 1
390 #define GPR_GETPID_IN_UNISTD_H 1
391 #define GRPC_ROOT_PEM_PATH "/config/ssl/cert.pem"
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
409 #if defined(__has_include)
410 #if __has_include(<atomic>)
411 #define GRPC_HAS_CXX11_ATOMIC
412 #endif /* __has_include(<atomic>) */
413 #endif /* defined(__has_include) */
415 #ifndef GPR_PLATFORM_STRING
416 #warning "GPR_PLATFORM_STRING not auto-detected"
417 #define GPR_PLATFORM_STRING "unknown"
421 #undef GPR_FORBID_UNREACHABLE_CODE
422 #define GPR_FORBID_UNREACHABLE_CODE 1
427 typedef __int8 int8_t;
428 typedef __int16 int16_t;
429 typedef __int32 int32_t;
430 typedef __int64 int64_t;
431 typedef unsigned __int8 uint8_t;
432 typedef unsigned __int16 uint16_t;
433 typedef unsigned __int32 uint32_t;
434 typedef unsigned __int64 uint64_t;
437 #endif /* _MSC_VER < 1700 */
440 #endif /* _MSC_VER */
442 /* Type of cycle clock implementation */
444 /* Disable cycle clock by default.
445 TODO(soheil): enable when we support fallback for unstable cycle clocks.
446 #if defined(__i386__)
447 #define GPR_CYCLE_COUNTER_RDTSC_32 1
448 #elif defined(__x86_64__) || defined(__amd64__)
449 #define GPR_CYCLE_COUNTER_RDTSC_64 1
451 #define GPR_CYCLE_COUNTER_FALLBACK 1
454 #define GPR_CYCLE_COUNTER_FALLBACK 1
456 #define GPR_CYCLE_COUNTER_FALLBACK 1
457 #endif /* GPR_LINUX */
459 /* Cache line alignment */
460 #ifndef GPR_CACHELINE_SIZE_LOG
461 #if defined(__i386__) || defined(__x86_64__)
462 #define GPR_CACHELINE_SIZE_LOG 6
464 #ifndef GPR_CACHELINE_SIZE_LOG
465 /* A reasonable default guess. Note that overestimates tend to waste more
466 space, while underestimates tend to waste more time. */
467 #define GPR_CACHELINE_SIZE_LOG 6
468 #endif /* GPR_CACHELINE_SIZE_LOG */
469 #endif /* GPR_CACHELINE_SIZE_LOG */
471 #define GPR_CACHELINE_SIZE (1 << GPR_CACHELINE_SIZE_LOG)
473 /* scrub GCC_ATOMIC if it's not available on this compiler */
474 #if defined(GPR_GCC_ATOMIC) && !defined(__ATOMIC_RELAXED)
475 #undef GPR_GCC_ATOMIC
476 #define GPR_GCC_SYNC 1
479 /* Validate platform combinations */
480 #if defined(GPR_GCC_ATOMIC) + defined(GPR_GCC_SYNC) + \
481 defined(GPR_WINDOWS_ATOMIC) != \
483 #error Must define exactly one of GPR_GCC_ATOMIC, GPR_GCC_SYNC, GPR_WINDOWS_ATOMIC
486 #if defined(GPR_ARCH_32) + defined(GPR_ARCH_64) != 1
487 #error Must define exactly one of GPR_ARCH_32, GPR_ARCH_64
490 #if defined(GPR_CPU_LINUX) + defined(GPR_CPU_POSIX) + defined(GPR_WINDOWS) + \
491 defined(GPR_CPU_IPHONE) + defined(GPR_CPU_CUSTOM) != \
493 #error Must define exactly one of GPR_CPU_LINUX, GPR_CPU_POSIX, GPR_WINDOWS, GPR_CPU_IPHONE, GPR_CPU_CUSTOM
496 #if defined(GPR_MSVC_TLS) + defined(GPR_GCC_TLS) + defined(GPR_PTHREAD_TLS) + \
497 defined(GPR_STDCPP_TLS) + defined(GPR_CUSTOM_TLS) != \
499 #error Must define exactly one of GPR_MSVC_TLS, GPR_GCC_TLS, GPR_PTHREAD_TLS, GPR_STDCPP_TLS, GPR_CUSTOM_TLS
502 /* maximum alignment needed for any type on this platform, rounded up to a
504 #define GPR_MAX_ALIGNMENT 16
510 #ifndef GRPC_IF_NAMETOINDEX
511 #define GRPC_IF_NAMETOINDEX 1
514 #ifndef GRPC_MUST_USE_RESULT
515 #if defined(__GNUC__) && !defined(__MINGW32__)
516 #define GRPC_MUST_USE_RESULT __attribute__((warn_unused_result))
517 #define GPR_ALIGN_STRUCT(n) __attribute__((aligned(n)))
519 #define GRPC_MUST_USE_RESULT
520 #define GPR_ALIGN_STRUCT(n)
525 #if defined(__GNUC__) && !defined(__MINGW32__)
526 #define GRPC_UNUSED __attribute__((unused))
532 #ifndef GPR_PRINT_FORMAT_CHECK
534 #define GPR_PRINT_FORMAT_CHECK(FORMAT_STR, ARGS) \
535 __attribute__((format(printf, FORMAT_STR, ARGS)))
537 #define GPR_PRINT_FORMAT_CHECK(FORMAT_STR, ARGS)
539 #endif /* GPR_PRINT_FORMAT_CHECK */
541 #if GPR_FORBID_UNREACHABLE_CODE
542 #define GPR_UNREACHABLE_CODE(STATEMENT)
544 #define GPR_UNREACHABLE_CODE(STATEMENT) \
546 gpr_log(GPR_ERROR, "Should never reach here."); \
550 #endif /* GPR_FORBID_UNREACHABLE_CODE */
557 #define GRPCAPI GPRAPI
561 #define CENSUSAPI GRPCAPI
564 #ifndef GPR_HAS_ATTRIBUTE
565 #ifdef __has_attribute
566 #define GPR_HAS_ATTRIBUTE(a) __has_attribute(a)
568 #define GPR_HAS_ATTRIBUTE(a) 0
570 #endif /* GPR_HAS_ATTRIBUTE */
572 #ifndef GPR_HAS_FEATURE
574 #define GPR_HAS_FEATURE(a) __has_feature(a)
576 #define GPR_HAS_FEATURE(a) 0
578 #endif /* GPR_HAS_FEATURE */
580 #ifndef GPR_ATTRIBUTE_NOINLINE
581 #if GPR_HAS_ATTRIBUTE(noinline) || (defined(__GNUC__) && !defined(__clang__))
582 #define GPR_ATTRIBUTE_NOINLINE __attribute__((noinline))
583 #define GPR_HAS_ATTRIBUTE_NOINLINE 1
585 #define GPR_ATTRIBUTE_NOINLINE
587 #endif /* GPR_ATTRIBUTE_NOINLINE */
589 #ifndef GPR_ATTRIBUTE_WEAK
590 /* Attribute weak is broken on LLVM/windows:
591 * https://bugs.llvm.org/show_bug.cgi?id=37598 */
592 #if (GPR_HAS_ATTRIBUTE(weak) || (defined(__GNUC__) && !defined(__clang__))) && \
593 !(defined(__llvm__) && defined(_WIN32))
594 #define GPR_ATTRIBUTE_WEAK __attribute__((weak))
595 #define GPR_HAS_ATTRIBUTE_WEAK 1
597 #define GPR_ATTRIBUTE_WEAK
599 #endif /* GPR_ATTRIBUTE_WEAK */
601 #ifndef GPR_ATTRIBUTE_NO_TSAN /* (1) */
602 #if GPR_HAS_FEATURE(thread_sanitizer)
603 #define GPR_ATTRIBUTE_NO_TSAN __attribute__((no_sanitize("thread")))
604 #endif /* GPR_HAS_FEATURE */
605 #ifndef GPR_ATTRIBUTE_NO_TSAN /* (2) */
606 #define GPR_ATTRIBUTE_NO_TSAN
607 #endif /* GPR_ATTRIBUTE_NO_TSAN (2) */
608 #endif /* GPR_ATTRIBUTE_NO_TSAN (1) */
610 /* GRPC_TSAN_ENABLED will be defined, when compiled with thread sanitizer. */
611 #ifndef GRPC_TSAN_SUPPRESSED
612 #if defined(__SANITIZE_THREAD__)
613 #define GRPC_TSAN_ENABLED
614 #elif GPR_HAS_FEATURE(thread_sanitizer)
615 #define GRPC_TSAN_ENABLED
619 /* GRPC_ASAN_ENABLED will be defined, when compiled with address sanitizer. */
620 #ifndef GRPC_ASAN_SUPPRESSED
621 #if defined(__SANITIZE_ADDRESS__)
622 #define GRPC_ASAN_ENABLED
623 #elif GPR_HAS_FEATURE(address_sanitizer)
624 #define GRPC_ASAN_ENABLED
628 /* GRPC_ALLOW_EXCEPTIONS should be 0 or 1 if exceptions are allowed or not */
629 #ifndef GRPC_ALLOW_EXCEPTIONS
631 #if defined(_MSC_VER) && defined(_CPPUNWIND)
632 #define GRPC_ALLOW_EXCEPTIONS 1
633 #elif defined(__EXCEPTIONS)
634 #define GRPC_ALLOW_EXCEPTIONS 1
636 #define GRPC_ALLOW_EXCEPTIONS 0
638 #else /* GPR_WINDOWS */
640 #define GRPC_ALLOW_EXCEPTIONS 1
641 #else /* __EXCEPTIONS */
642 #define GRPC_ALLOW_EXCEPTIONS 0
643 #endif /* __EXCEPTIONS */
644 #endif /* __GPR_WINDOWS */
645 #endif /* GRPC_ALLOW_EXCEPTIONS */
647 /* Use GPR_LIKELY only in cases where you are sure that a certain outcome is the
648 * most likely. Ideally, also collect performance numbers to justify the claim.
651 #define GPR_LIKELY(x) __builtin_expect((x), 1)
652 #define GPR_UNLIKELY(x) __builtin_expect((x), 0)
654 #define GPR_LIKELY(x) (x)
655 #define GPR_UNLIKELY(x) (x)
656 #endif /* __GNUC__ */
658 #ifndef __STDC_FORMAT_MACROS
659 #define __STDC_FORMAT_MACROS
662 #endif /* GRPC_IMPL_CODEGEN_PORT_PLATFORM_H */