1 | /** |
2 | * Licensed to the Apache Software Foundation (ASF) under one |
3 | * or more contributor license agreements. See the NOTICE file |
4 | * distributed with this work for additional information |
5 | * regarding copyright ownership. The ASF licenses this file |
6 | * to you under the Apache License, Version 2.0 (the |
7 | * "License"); you may not use this file except in compliance |
8 | * with the License. You may obtain a copy of the License at |
9 | * |
10 | * http://www.apache.org/licenses/LICENSE-2.0 |
11 | * |
12 | * Unless required by applicable law or agreed to in writing, software |
13 | * distributed under the License is distributed on an "AS IS" BASIS, |
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
15 | * See the License for the specific language governing permissions and |
16 | * limitations under the License. |
17 | */ |
18 | |
19 | #ifndef ADAPTER_HH |
20 | #define ADAPTER_HH |
21 | |
22 | #define INT64_IS_LL |
23 | #define HAS_PREAD |
24 | #define HAS_STRPTIME |
25 | #define HAS_STOLL |
26 | #define HAS_DIAGNOSTIC_PUSH |
27 | #define HAS_PRE_1970 |
28 | /* #undef HAS_POST_2038 */ |
29 | #define HAS_STD_ISNAN |
30 | #define HAS_STD_MUTEX |
31 | #define NEEDS_REDUNDANT_MOVE |
32 | /* #undef NEEDS_Z_PREFIX */ |
33 | |
34 | #include "orc/orc-config.hh" |
35 | #include <string> |
36 | |
37 | #ifndef HAS_STOLL |
38 | // A poor man's stoll that converts str to a long long int base 10 |
39 | namespace std { |
40 | int64_t stoll(std::string str); |
41 | } |
42 | #endif |
43 | |
44 | #ifndef HAS_STRPTIME |
45 | char* strptime(const char* buf, const char* format, struct tm* tm); |
46 | #endif |
47 | |
48 | #ifndef HAS_PREAD |
49 | ssize_t pread(int fd, void* buf, size_t count, off_t offset); |
50 | #endif |
51 | |
52 | #ifdef INT64_IS_LL |
53 | #define INT64_FORMAT_STRING "ll" |
54 | #else |
55 | #define INT64_FORMAT_STRING "l" |
56 | #endif |
57 | |
58 | #ifndef ORC_CXX_HAS_NOEXCEPT |
59 | #define noexcept ORC_NOEXCEPT |
60 | #endif |
61 | |
62 | #ifndef ORC_CXX_HAS_OVERRIDE |
63 | #define override ORC_OVERRIDE |
64 | #endif |
65 | |
66 | #ifdef HAS_DIAGNOSTIC_PUSH |
67 | #ifdef __clang__ |
68 | #define DIAGNOSTIC_PUSH _Pragma("clang diagnostic push") |
69 | #define DIAGNOSTIC_POP _Pragma("clang diagnostic pop") |
70 | #elif defined(__GNUC__) |
71 | #define DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push") |
72 | #define DIAGNOSTIC_POP _Pragma("GCC diagnostic pop") |
73 | #elif defined(_MSC_VER) |
74 | #define DIAGNOSTIC_PUSH __pragma(warning(push)) |
75 | #define DIAGNOSTIC_POP __pragma(warning(pop)) |
76 | #else |
77 | #error("Unknown compiler") |
78 | #endif |
79 | #else |
80 | #define DIAGNOSTIC_PUSH |
81 | #define DIAGNOSTIC_POP |
82 | #endif |
83 | |
84 | #define PRAGMA(TXT) _Pragma(#TXT) |
85 | |
86 | #ifdef __clang__ |
87 | #define DIAGNOSTIC_IGNORE(XXX) PRAGMA(clang diagnostic ignored XXX) |
88 | #elif defined(__GNUC__) |
89 | #define DIAGNOSTIC_IGNORE(XXX) PRAGMA(GCC diagnostic ignored XXX) |
90 | #elif defined(_MSC_VER) |
91 | #define DIAGNOSTIC_IGNORE(XXX) __pragma(warning(disable : XXX)) |
92 | #else |
93 | #define DIAGNOSTIC_IGNORE(XXX) |
94 | #endif |
95 | |
96 | #ifndef ORC_CXX_HAS_UNIQUE_PTR |
97 | #define unique_ptr auto_ptr |
98 | #endif |
99 | |
100 | #ifndef UINT32_MAX |
101 | #define UINT32_MAX 0xffffffff |
102 | #endif |
103 | |
104 | #ifndef INT64_MAX |
105 | #define INT64_MAX 0x7fffffffffffffff |
106 | #endif |
107 | |
108 | #ifndef INT64_MIN |
109 | #define INT64_MIN (-0x7fffffffffffffff - 1) |
110 | #endif |
111 | |
112 | #define GTEST_LANG_CXX11 0 |
113 | |
114 | #ifdef NEEDS_REDUNDANT_MOVE |
115 | #define REDUNDANT_MOVE(XXX) std::move(XXX) |
116 | #else |
117 | #define REDUNDANT_MOVE(XXX) XXX |
118 | #endif |
119 | |
120 | #ifndef HAS_STD_ISNAN |
121 | #include <math.h> |
122 | #define std::isnan(XXX) isnan(XXX) |
123 | #else |
124 | #include <cmath> |
125 | #endif |
126 | |
127 | #ifndef HAS_STD_MUTEX |
128 | #include <pthread.h> |
129 | namespace orc { |
130 | /** |
131 | * Lock guard for pthread_mutex_t object using RAII |
132 | * The Lock is automatically release when exiting current scope. |
133 | */ |
134 | class LockORC { |
135 | public: |
136 | explicit LockORC(pthread_mutex_t& mutex) : mutex_ref_(mutex) { |
137 | pthread_mutex_lock(&mutex_ref_); |
138 | } |
139 | ~LockORC() { pthread_mutex_unlock(&mutex_ref_); } |
140 | private: |
141 | // no default constructor |
142 | LockORC(); |
143 | // prohibit copying |
144 | LockORC(const LockORC&); |
145 | LockORC& operator=(const LockORC&); |
146 | |
147 | pthread_mutex_t& mutex_ref_; |
148 | }; |
149 | } |
150 | #define std::mutex pthread_mutex_t |
151 | #define std::lock_guard<std::mutex> LockORC |
152 | #else |
153 | #include <mutex> |
154 | #endif |
155 | |
156 | #ifdef NEEDS_Z_PREFIX |
157 | #define Z_PREFIX 1 |
158 | #endif |
159 | |
160 | #endif /* ADAPTER_HH */ |
161 | |