诸暨麻将添加redis
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 
 

413 行
14 KiB

  1. // Protocol Buffers - Google's data interchange format
  2. // Copyright 2008 Google Inc. All rights reserved.
  3. // https://developers.google.com/protocol-buffers/
  4. //
  5. // Redistribution and use in source and binary forms, with or without
  6. // modification, are permitted provided that the following conditions are
  7. // met:
  8. //
  9. // * Redistributions of source code must retain the above copyright
  10. // notice, this list of conditions and the following disclaimer.
  11. // * Redistributions in binary form must reproduce the above
  12. // copyright notice, this list of conditions and the following disclaimer
  13. // in the documentation and/or other materials provided with the
  14. // distribution.
  15. // * Neither the name of Google Inc. nor the names of its
  16. // contributors may be used to endorse or promote products derived from
  17. // this software without specific prior written permission.
  18. //
  19. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  20. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  21. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  22. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  23. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  24. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  25. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  26. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  27. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  28. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  29. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30. // This file defines common macros that are used in protobuf.
  31. //
  32. // To hide these definitions from the outside world (and to prevent collisions
  33. // if more than one version of protobuf is #included in the same project) you
  34. // must follow this pattern when #including port_def.inc in a header file:
  35. //
  36. // #include "other_header.h"
  37. // #include "message.h"
  38. // // etc.
  39. //
  40. // #include "port_def.inc" // MUST be last header included
  41. //
  42. // // Definitions for this header.
  43. //
  44. // #include "port_undef.inc"
  45. //
  46. // This is a textual header with no include guard, because we want to
  47. // detect/prohibit anytime it is #included twice without a corresponding
  48. // #undef.
  49. // These macros are private and should always be
  50. // ::util::RetrieveErrorSpace(*this) headers. If any of these errors fire, you
  51. // should either properly #include port_undef.h at the end of your header that
  52. // #includes port.h, or don't #include port.h twice in a .cc file.
  53. #ifdef PROTOBUF_NAMESPACE
  54. #error PROTOBUF_NAMESPACE was previously defined
  55. #endif
  56. #ifdef PROTOBUF_NAMESPACE_ID
  57. #error PROTOBUF_NAMESPACE_ID was previously defined
  58. #endif
  59. #ifdef PROTOBUF_ALWAYS_INLINE
  60. #error PROTOBUF_ALWAYS_INLINE was previously defined
  61. #endif
  62. #ifdef PROTOBUF_COLD
  63. #error PROTOBUF_COLD was previously defined
  64. #endif
  65. #ifdef PROTOBUF_NOINLINE
  66. #error PROTOBUF_NOINLINE was previously defined
  67. #endif
  68. #ifdef PROTOBUF_SECTION_VARIABLE
  69. #error PROTOBUF_SECTION_VARIABLE was previously defined
  70. #endif
  71. #ifdef PROTOBUF_DEPRECATED
  72. #error PROTOBUF_DEPRECATED was previously defined
  73. #endif
  74. #ifdef PROTOBUF_DEPRECATED_MSG
  75. #error PROTOBUF_DEPRECATED_MSG was previously defined
  76. #endif
  77. #ifdef PROTOBUF_FUNC_ALIGN
  78. #error PROTOBUF_FUNC_ALIGN was previously defined
  79. #endif
  80. #ifdef PROTOBUF_RETURNS_NONNULL
  81. #error PROTOBUF_RETURNS_NONNULL was previously defined
  82. #endif
  83. #ifdef PROTOBUF_ATTRIBUTE_REINITIALIZES
  84. #error PROTOBUF_ATTRIBUTE_REINITIALIZES was previously defined
  85. #endif
  86. #ifdef PROTOBUF_RTTI
  87. #error PROTOBUF_RTTI was previously defined
  88. #endif
  89. #ifdef PROTOBUF_VERSION
  90. #error PROTOBUF_VERSION was previously defined
  91. #endif
  92. #ifdef PROTOBUF_VERSION_SUFFIX
  93. #error PROTOBUF_VERSION_SUFFIX was previously defined
  94. #endif
  95. #ifdef PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC
  96. #error PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC was previously defined
  97. #endif
  98. #ifdef PROTOBUF_MIN_PROTOC_VERSION
  99. #error PROTOBUF_MIN_PROTOC_VERSION was previously defined
  100. #endif
  101. #ifdef PROTOBUF_PREDICT_TRUE
  102. #error PROTOBUF_PREDICT_TRUE was previously defined
  103. #endif
  104. #ifdef PROTOBUF_PREDICT_FALSE
  105. #error PROTOBUF_PREDICT_FALSE was previously defined
  106. #endif
  107. #ifdef PROTOBUF_FIELD_OFFSET
  108. #error PROTOBUF_FIELD_OFFSET was previously defined
  109. #endif
  110. #ifdef PROTOBUF_LL_FORMAT
  111. #error PROTOBUF_LL_FORMAT was previously defined
  112. #endif
  113. #ifdef PROTOBUF_GUARDED_BY
  114. #error PROTOBUF_GUARDED_BY was previously defined
  115. #endif
  116. #ifdef PROTOBUF_LONGLONG
  117. #error PROTOBUF_LONGLONG was previously defined
  118. #endif
  119. #ifdef PROTOBUF_ULONGLONG
  120. #error PROTOBUF_ULONGLONG was previously defined
  121. #endif
  122. #ifdef PROTOBUF_FALLTHROUGH_INTENDED
  123. #error PROTOBUF_FALLTHROUGH_INTENDED was previously defined
  124. #endif
  125. #ifdef PROTOBUF_EXPORT
  126. #error PROTOBUF_EXPORT was previously defined
  127. #endif
  128. #ifdef PROTOC_EXPORT
  129. #error PROTOC_EXPORT was previously defined
  130. #endif
  131. #ifdef PROTOBUF_MUST_USE_RESULT
  132. #error PROTOBUF_MUST_USE_RESULT was previously defined
  133. #endif
  134. #ifdef PROTOBUF_UNUSED
  135. #error PROTOBUF_UNUSED was previously defined
  136. #endif
  137. #define PROTOBUF_NAMESPACE "google::protobuf"
  138. #define PROTOBUF_NAMESPACE_ID google::protobuf
  139. #define PROTOBUF_NAMESPACE_OPEN \
  140. namespace google { \
  141. namespace protobuf {
  142. #define PROTOBUF_NAMESPACE_CLOSE \
  143. } /* namespace protobuf */ \
  144. } /* namespace google */
  145. #if defined(__GNUC__) || defined(__clang__)
  146. #define PROTOBUF_DEPRECATED __attribute__((deprecated))
  147. #define PROTOBUF_DEPRECATED_MSG(msg) __attribute__((deprecated(msg)))
  148. #elif defined(_MSC_VER)
  149. #define PROTOBUF_DEPRECATED __declspec(deprecated)
  150. #define PROTOBUF_DEPRECATED_MSG(msg) __declspec(deprecated(msg))
  151. #endif
  152. #define PROTOBUF_SECTION_VARIABLE(x)
  153. #define PROTOBUF_MUST_USE_RESULT
  154. // ----------------------------------------------------------------------------
  155. // Annotations: Some parts of the code have been annotated in ways that might
  156. // be useful to some compilers or tools, but are not supported universally.
  157. // You can #define these annotations yourself if the default implementation
  158. // is not right for you.
  159. #ifdef GOOGLE_ATTRIBUTE_ALWAYS_INLINE
  160. #define PROTOBUF_ALWAYS_INLINE GOOGLE_ATTRIBUTE_ALWAYS_INLINE
  161. #else
  162. #if defined(__GNUC__) && \
  163. (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
  164. // For functions we want to force inline.
  165. // Introduced in gcc 3.1.
  166. #define PROTOBUF_ALWAYS_INLINE __attribute__((always_inline))
  167. #else
  168. // Other compilers will have to figure it out for themselves.
  169. #define PROTOBUF_ALWAYS_INLINE
  170. #endif
  171. #endif
  172. #ifdef GOOGLE_ATTRIBUTE_NOINLINE
  173. #define PROTOBUF_NOINLINE GOOGLE_ATTRIBUTE_NOINLINE
  174. #else
  175. #if defined(__GNUC__) && \
  176. (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
  177. // For functions we want to force not inline.
  178. // Introduced in gcc 3.1.
  179. #define PROTOBUF_NOINLINE __attribute__((noinline))
  180. #elif defined(_MSC_VER) && (_MSC_VER >= 1400)
  181. // Seems to have been around since at least Visual Studio 2005
  182. #define PROTOBUF_NOINLINE __declspec(noinline)
  183. #else
  184. // Other compilers will have to figure it out for themselves.
  185. #define PROTOBUF_NOINLINE
  186. #endif
  187. #endif
  188. #ifdef GOOGLE_ATTRIBUTE_FUNC_ALIGN
  189. #define PROTOBUF_FUNC_ALIGN GOOGLE_ATTRIBUTE_FUNC_ALIGN
  190. #else
  191. #if defined(__clang__) || \
  192. defined(__GNUC__) && \
  193. (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
  194. // Function alignment attribute introduced in gcc 4.3
  195. #define PROTOBUF_FUNC_ALIGN(bytes) __attribute__((aligned(bytes)))
  196. #else
  197. #define PROTOBUF_FUNC_ALIGN(bytes)
  198. #endif
  199. #endif
  200. #ifdef GOOGLE_PREDICT_TRUE
  201. #define PROTOBUF_PREDICT_TRUE GOOGLE_PREDICT_TRUE
  202. #else
  203. #ifdef __GNUC__
  204. // Provided at least since GCC 3.0.
  205. #define PROTOBUF_PREDICT_TRUE(x) (__builtin_expect(!!(x), 1))
  206. #else
  207. #define PROTOBUF_PREDICT_TRUE(x) (x)
  208. #endif
  209. #endif
  210. #ifdef GOOGLE_PREDICT_FALSE
  211. #define PROTOBUF_PREDICT_FALSE GOOGLE_PREDICT_FALSE
  212. #else
  213. #ifdef __GNUC__
  214. // Provided at least since GCC 3.0.
  215. #define PROTOBUF_PREDICT_FALSE(x) (__builtin_expect(x, 0))
  216. #else
  217. #define PROTOBUF_PREDICT_FALSE(x) (x)
  218. #endif
  219. #endif
  220. #ifdef GOOGLE_PROTOBUF_ATTRIBUTE_RETURNS_NONNULL
  221. #define PROTOBUF_RETURNS_NONNULL GOOGLE_PROTOBUF_ATTRIBUTE_RETURNS_NONNULL
  222. #else
  223. #ifdef __GNUC__
  224. #define PROTOBUF_RETURNS_NONNULL __attribute__((returns_nonnull))
  225. #else
  226. #define PROTOBUF_RETURNS_NONNULL
  227. #endif
  228. #endif
  229. #if defined(__has_cpp_attribute)
  230. #if __has_cpp_attribute(clang::reinitializes)
  231. #define PROTOBUF_ATTRIBUTE_REINITIALIZES [[clang::reinitializes]]
  232. #endif
  233. #endif
  234. #ifndef PROTOBUF_ATTRIBUTE_REINITIALIZES
  235. #define PROTOBUF_ATTRIBUTE_REINITIALIZES
  236. #endif
  237. #define PROTOBUF_GUARDED_BY(x)
  238. #define PROTOBUF_COLD
  239. // Copied from ABSL.
  240. #if defined(__clang__) && defined(__has_warning)
  241. #if __has_feature(cxx_attributes) && __has_warning("-Wimplicit-fallthrough")
  242. #define PROTOBUF_FALLTHROUGH_INTENDED [[clang::fallthrough]]
  243. #endif
  244. #elif defined(__GNUC__) && __GNUC__ >= 7
  245. #define PROTOBUF_FALLTHROUGH_INTENDED [[gnu::fallthrough]]
  246. #endif
  247. #ifndef PROTOBUF_FALLTHROUGH_INTENDED
  248. #define PROTOBUF_FALLTHROUGH_INTENDED
  249. #endif
  250. #if defined(__has_cpp_attribute)
  251. #define HAS_ATTRIBUTE(attr) __has_cpp_attribute(attr)
  252. #else
  253. #define HAS_ATTRIBUTE(attr) 0
  254. #endif
  255. #if HAS_ATTRIBUTE(unused) || (defined(__GNUC__) && !defined(__clang__))
  256. #define PROTOBUF_UNUSED __attribute__((__unused__))
  257. #else
  258. #define PROTOBUF_UNUSED
  259. #endif
  260. #undef HAS_ATTRIBUTE
  261. #ifdef _MSC_VER
  262. #define PROTOBUF_LONGLONG(x) x##I64
  263. #define PROTOBUF_ULONGLONG(x) x##UI64
  264. #define PROTOBUF_LL_FORMAT "I64" // As in printf("%I64d", ...)
  265. #else
  266. // By long long, we actually mean int64.
  267. #define PROTOBUF_LONGLONG(x) x##LL
  268. #define PROTOBUF_ULONGLONG(x) x##ULL
  269. // Used to format real long long integers.
  270. #define PROTOBUF_LL_FORMAT \
  271. "ll" // As in "%lld". Note that "q" is poor form also.
  272. #endif
  273. // Shared google3/opensource definitions. //////////////////////////////////////
  274. #define PROTOBUF_VERSION 3011000
  275. #define PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC 3011000
  276. #define PROTOBUF_MIN_PROTOC_VERSION 3011000
  277. #define PROTOBUF_VERSION_SUFFIX ""
  278. // The minimum library version which works with the current version of the
  279. // headers.
  280. #define GOOGLE_PROTOBUF_MIN_LIBRARY_VERSION 3011000
  281. #if defined(GOOGLE_PROTOBUF_NO_RTTI) && GOOGLE_PROTOBUF_NO_RTTI
  282. #define PROTOBUF_RTTI 0
  283. #else
  284. #define PROTOBUF_RTTI 1
  285. #endif
  286. // Returns the offset of the given field within the given aggregate type.
  287. // This is equivalent to the ANSI C offsetof() macro. However, according
  288. // to the C++ standard, offsetof() only works on POD types, and GCC
  289. // enforces this requirement with a warning. In practice, this rule is
  290. // unnecessarily strict; there is probably no compiler or platform on
  291. // which the offsets of the direct fields of a class are non-constant.
  292. // Fields inherited from superclasses *can* have non-constant offsets,
  293. // but that's not what this macro will be used for.
  294. #if defined(__clang__)
  295. // For Clang we use __builtin_offsetof() and suppress the warning,
  296. // to avoid Control Flow Integrity and UBSan vptr sanitizers from
  297. // crashing while trying to validate the invalid reinterpet_casts.
  298. #define PROTOBUF_FIELD_OFFSET(TYPE, FIELD) \
  299. _Pragma("clang diagnostic push") \
  300. _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
  301. __builtin_offsetof(TYPE, FIELD) \
  302. _Pragma("clang diagnostic pop")
  303. #else
  304. // Note that we calculate relative to the pointer value 16 here since if we
  305. // just use zero, GCC complains about dereferencing a NULL pointer. We
  306. // choose 16 rather than some other number just in case the compiler would
  307. // be confused by an unaligned pointer.
  308. #define PROTOBUF_FIELD_OFFSET(TYPE, FIELD) \
  309. static_cast< ::google::protobuf::uint32>(reinterpret_cast<const char*>( \
  310. &reinterpret_cast<const TYPE*>(16)->FIELD) - \
  311. reinterpret_cast<const char*>(16))
  312. #endif
  313. #if defined(PROTOBUF_USE_DLLS)
  314. #if defined(_MSC_VER)
  315. #ifdef LIBPROTOBUF_EXPORTS
  316. #define PROTOBUF_EXPORT __declspec(dllexport)
  317. #define PROTOBUF_EXPORT_TEMPLATE_DECLARE
  318. #define PROTOBUF_EXPORT_TEMPLATE_DEFINE __declspec(dllexport)
  319. #else
  320. #define PROTOBUF_EXPORT __declspec(dllimport)
  321. #define PROTOBUF_EXPORT_TEMPLATE_DECLARE
  322. #define PROTOBUF_EXPORT_TEMPLATE_DEFINE __declspec(dllimport)
  323. #endif
  324. #ifdef LIBPROTOC_EXPORTS
  325. #define PROTOC_EXPORT __declspec(dllexport)
  326. #else
  327. #define PROTOC_EXPORT __declspec(dllimport)
  328. #endif
  329. #else // defined(_MSC_VER)
  330. #ifdef LIBPROTOBUF_EXPORTS
  331. #define PROTOBUF_EXPORT __attribute__((visibility("default")))
  332. #define PROTOBUF_EXPORT_TEMPLATE_DECLARE __attribute__((visibility("default")))
  333. #define PROTOBUF_EXPORT_TEMPLATE_DEFINE
  334. #else
  335. #define PROTOBUF_EXPORT
  336. #define PROTOBUF_EXPORT_TEMPLATE_DECLARE
  337. #define PROTOBUF_EXPORT_TEMPLATE_DEFINE
  338. #endif
  339. #ifdef LIBPROTOC_EXPORTS
  340. #define PROTOC_EXPORT __attribute__((visibility("default")))
  341. #else
  342. #define PROTOC_EXPORT
  343. #endif
  344. #endif
  345. #else // defined(PROTOBUF_USE_DLLS)
  346. #define PROTOBUF_EXPORT
  347. #define PROTOC_EXPORT
  348. #define PROTOBUF_EXPORT_TEMPLATE_DECLARE
  349. #define PROTOBUF_EXPORT_TEMPLATE_DEFINE
  350. #endif
  351. // Windows declares several inconvenient macro names. We #undef them and then
  352. // restore them in port_undef.inc.
  353. #ifdef _MSC_VER
  354. #pragma push_macro("GetMessage")
  355. #undef GetMessage
  356. #pragma push_macro("IGNORE")
  357. #undef IGNORE
  358. #pragma push_macro("IN")
  359. #undef IN
  360. #endif // _MSC_VER
  361. #if defined(__clang__)
  362. #pragma clang diagnostic push
  363. // TODO(gerbens) ideally we cleanup the code. But a cursory try shows many
  364. // violations. So let's ignore for now.
  365. #pragma clang diagnostic ignored "-Wshorten-64-to-32"
  366. #endif
  367. // PROTOBUF_ASSUME(pred) tells the compiler that it can assume pred is true. To
  368. // be safe, we also validate the assumption with a GOOGLE_DCHECK in unoptimized
  369. // builds. The macro does not do anything useful if the compiler does not
  370. // support __builtin_assume.
  371. #ifdef __has_builtin
  372. #if __has_builtin(__builtin_assume)
  373. #define PROTOBUF_ASSUME(pred) \
  374. GOOGLE_DCHECK(pred); \
  375. __builtin_assume(pred)
  376. #else
  377. #define PROTOBUF_ASSUME(pred) GOOGLE_DCHECK(pred)
  378. #endif
  379. #else
  380. #define PROTOBUF_ASSUME(pred) GOOGLE_DCHECK(pred)
  381. #endif