1919// This file contains things that are not used in third_party/absl but needed by
2020// s2geometry. It is structured into the following high-level categories:
2121// - Utility functions
22- // - Endianness
2322// - Performance optimization (alignment)
2423
2524#include < cstdint>
@@ -41,55 +40,6 @@ inline void sized_delete_array(void *ptr, size_t size) {
4140}
4241} // namespace base
4342
44- // -----------------------------------------------------------------------------
45- // Endianness
46- // -----------------------------------------------------------------------------
47-
48- // IS_LITTLE_ENDIAN, IS_BIG_ENDIAN
49- #if defined(__linux__)
50- #include < endian.h>
51-
52- #elif defined(__APPLE__)
53-
54- // BIG_ENDIAN
55- #include < machine/endian.h> // NOLINT(build/include)
56-
57- /* Let's try and follow the Linux convention */
58- #define __BYTE_ORDER BYTE_ORDER
59- #define __LITTLE_ENDIAN LITTLE_ENDIAN
60- #define __BIG_ENDIAN BIG_ENDIAN
61-
62- #endif
63-
64- // defines __BYTE_ORDER
65- #ifdef _WIN32
66- #define __BYTE_ORDER __LITTLE_ENDIAN
67- #define IS_LITTLE_ENDIAN
68- #else // _WIN32
69-
70- // define the macros IS_LITTLE_ENDIAN or IS_BIG_ENDIAN
71- // using the above endian definitions from endian.h if
72- // endian.h was included
73- #ifdef __BYTE_ORDER
74- #if __BYTE_ORDER == __LITTLE_ENDIAN
75- #define IS_LITTLE_ENDIAN
76- #endif
77-
78- #if __BYTE_ORDER == __BIG_ENDIAN
79- #define IS_BIG_ENDIAN
80- #endif
81-
82- #else // __BYTE_ORDER
83-
84- #if defined(__LITTLE_ENDIAN__)
85- #define IS_LITTLE_ENDIAN
86- #elif defined(__BIG_ENDIAN__)
87- #define IS_BIG_ENDIAN
88- #endif
89-
90- #endif // __BYTE_ORDER
91- #endif // _WIN32
92-
9343// -----------------------------------------------------------------------------
9444// Performance Optimization
9545// -----------------------------------------------------------------------------
@@ -100,37 +50,15 @@ inline void sized_delete_array(void *ptr, size_t size) {
10050
10151// Portable handling of unaligned loads, stores, and copies. These are simply
10252// constant-length memcpy calls.
103- //
104- // TODO(user): These APIs are forked in Abseil, see
105- // "third_party/absl/base/internal/unaligned_access.h".
106- //
107- // The unaligned API is C++ only. The declarations use C++ features
108- // (namespaces, inline) which are absent or incompatible in C.
109- #if defined(__cplusplus)
11053
11154namespace base {
112-
113- // Can't use ATTRIBUTE_NO_SANITIZE_MEMORY because this file is included before
114- // attributes.h is.
115- #ifdef __has_attribute
116- #if __has_attribute(no_sanitize_memory)
117- #define NO_SANITIZE_MEMORY __attribute__ ((no_sanitize_memory))
118- #endif // __has_attribute(no_sanitize_memory)
119- #endif // defined __has_attribute
120-
121- #ifndef NO_SANITIZE_MEMORY
122- #define NO_SANITIZE_MEMORY /* */
123- #endif
124-
12555template <typename T>
126- T NO_SANITIZE_MEMORY UnalignedLoad (const void *p) {
56+ T UnalignedLoad (const void *p) {
12757 T t;
12858 memcpy (&t, p, sizeof t);
12959 return t;
13060}
13161
132- #undef NO_SANITIZE_MEMORY
133-
13462template <typename T>
13563void UnalignedStore (void *p, T t) {
13664 memcpy (p, &t, sizeof t);
@@ -161,6 +89,4 @@ inline void UNALIGNED_STORE64(void *p, uint64_t v) {
16189 base::UnalignedStore (p, v);
16290}
16391
164- #endif // defined(__cplusplus), end of unaligned API
165-
16692#endif // S2_BASE_PORT_H_
0 commit comments