From e6db597b915bd473f00919526164ff585384e704 Mon Sep 17 00:00:00 2001 From: Yuriy Chernyshov Date: Sat, 17 Apr 2021 01:54:20 +0300 Subject: [PATCH] Use byteswap.h when building against musl libc (#8503) --- .../protobuf/internal/python_protobuf.cc | 59 ------------------- python/google/protobuf/python_protobuf.h | 57 ------------------ src/google/protobuf/stubs/port.h | 4 +- 3 files changed, 2 insertions(+), 118 deletions(-) delete mode 100644 python/google/protobuf/internal/python_protobuf.cc delete mode 100644 python/google/protobuf/python_protobuf.h diff --git a/python/google/protobuf/internal/python_protobuf.cc b/python/google/protobuf/internal/python_protobuf.cc deleted file mode 100644 index e823bf228ca2..000000000000 --- a/python/google/protobuf/internal/python_protobuf.cc +++ /dev/null @@ -1,59 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: qrczak@google.com (Marcin Kowalczyk) - -#include - -namespace google { -namespace protobuf { -namespace python { - -static const Message* GetCProtoInsidePyProtoStub(PyObject* msg) { return NULL; } -static Message* MutableCProtoInsidePyProtoStub(PyObject* msg) { return NULL; } - -// This is initialized with a default, stub implementation. -// If python-google.protobuf.cc is loaded, the function pointer is overridden -// with a full implementation. -const Message* (*GetCProtoInsidePyProtoPtr)(PyObject* msg) = - GetCProtoInsidePyProtoStub; -Message* (*MutableCProtoInsidePyProtoPtr)(PyObject* msg) = - MutableCProtoInsidePyProtoStub; - -const Message* GetCProtoInsidePyProto(PyObject* msg) { - return GetCProtoInsidePyProtoPtr(msg); -} -Message* MutableCProtoInsidePyProto(PyObject* msg) { - return MutableCProtoInsidePyProtoPtr(msg); -} - -} // namespace python -} // namespace protobuf -} // namespace google diff --git a/python/google/protobuf/python_protobuf.h b/python/google/protobuf/python_protobuf.h deleted file mode 100644 index 8db1ffb7503b..000000000000 --- a/python/google/protobuf/python_protobuf.h +++ /dev/null @@ -1,57 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: qrczak@google.com (Marcin Kowalczyk) -// -// This module exposes the C proto inside the given Python proto, in -// case the Python proto is implemented with a C proto. - -#ifndef GOOGLE_PROTOBUF_PYTHON_PYTHON_PROTOBUF_H__ -#define GOOGLE_PROTOBUF_PYTHON_PYTHON_PROTOBUF_H__ - -#include - -namespace google { -namespace protobuf { - -class Message; - -namespace python { - -// Return the pointer to the C proto inside the given Python proto, -// or NULL when this is not a Python proto implemented with a C proto. -const Message* GetCProtoInsidePyProto(PyObject* msg); -Message* MutableCProtoInsidePyProto(PyObject* msg); - -} // namespace python -} // namespace protobuf -} // namespace google - -#endif // GOOGLE_PROTOBUF_PYTHON_PYTHON_PROTOBUF_H__ diff --git a/src/google/protobuf/stubs/port.h b/src/google/protobuf/stubs/port.h index 0f3b5aa628cf..6badd3ff631d 100644 --- a/src/google/protobuf/stubs/port.h +++ b/src/google/protobuf/stubs/port.h @@ -78,7 +78,7 @@ #include #elif defined(__APPLE__) #include -#elif defined(__GLIBC__) || defined(__BIONIC__) || defined(__CYGWIN__) +#elif defined(__linux__) || defined(__ANDROID__) || defined(__CYGWIN__) #include // IWYU pragma: export #endif @@ -242,7 +242,7 @@ inline void GOOGLE_UNALIGNED_STORE64(void *p, uint64 v) { #define bswap_32(x) OSSwapInt32(x) #define bswap_64(x) OSSwapInt64(x) -#elif !defined(__GLIBC__) && !defined(__BIONIC__) && !defined(__CYGWIN__) +#elif !defined(__linux__) && !defined(__ANDROID__) && !defined(__CYGWIN__) #ifndef bswap_16 static inline uint16 bswap_16(uint16 x) {