2 * Copyright 2013 Facebook, Inc.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef FOLLY_PORTABILITY_H_
18 #define FOLLY_PORTABILITY_H_
20 #include "folly-config.h"
22 #ifdef FOLLY_HAVE_FEATURES_H
27 #ifdef FOLLY_HAVE_SCHED_H
29 #ifndef FOLLY_HAVE_PTHREAD_YIELD
30 #define pthread_yield sched_yield
35 // MaxAlign: max_align_t isn't supported by gcc
37 struct MaxAlign { char c; } __attribute__((aligned));
39 # error Cannot define MaxAlign on this platform
44 #if defined(__clang__) || defined(__GNUC__)
45 # define FOLLY_NORETURN __attribute__((noreturn))
47 # define FOLLY_NORETURN
51 /* Define macro wrappers for C++11's "final" and "override" keywords, which
52 * are supported in gcc 4.7 but not gcc 4.6. */
53 #if !defined(FOLLY_FINAL) && !defined(FOLLY_OVERRIDE)
54 # if defined(__clang__) || \
55 (defined(__GNUC__) && defined(__GNUC_MINOR__) && \
56 ((__GNUC__ << 16) + __GNUC_MINOR__) >= ((4 << 16) + 7))
57 # define FOLLY_FINAL final
58 # define FOLLY_OVERRIDE override
60 # define FOLLY_FINAL /**/
61 # define FOLLY_OVERRIDE /**/
66 // Define to 1 if you have the `preadv' and `pwritev' functions, respectively
67 #if !defined(FOLLY_HAVE_PREADV) && !defined(FOLLY_HAVE_PWRITEV)
68 # if defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 10)
69 # define FOLLY_HAVE_PREADV 1
70 # define FOLLY_HAVE_PWRITEV 1
74 #endif // FOLLY_PORTABILITY_H_