mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
Move entirety of llvm namespace to wpi namespace.
During shared library loading, a different libLLVM can be pulled in, causing llvm symbols from dependent libraries to resolve to that library instead of this one. This has been seen in the wild with the Mesa OpenGL implementation in JavaFX applications (see wpilibsuite/shuffleboard#361). This is clearly a very breaking change. For some level of backwards compatibility, a namespace alias from llvm to wpi is performed in the "llvm" headers. Unfortunately, forward declarations of llvm classes will still break, but compilers seem to generate clear error messages in those cases ("namespace alias 'llvm' not allowed here, assuming 'wpi'"). This change also moves all the wpiutil headers to a single "wpi" subdirectory from the previously split "llvm", "support", "tcpsockets", and "udpsockets". Shim headers will be added for backwards compatibility in a later commit.
This commit is contained in:
@@ -13,8 +13,8 @@
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
#include <llvm/MathExtras.h>
|
||||
#include <support/leb128.h>
|
||||
#include <wpi/MathExtras.h>
|
||||
#include <wpi/leb128.h>
|
||||
|
||||
using namespace nt;
|
||||
|
||||
@@ -25,7 +25,7 @@ WireEncoder::WireEncoder(unsigned int proto_rev) {
|
||||
|
||||
void WireEncoder::WriteDouble(double val) {
|
||||
// The highest performance way to do this, albeit non-portable.
|
||||
uint64_t v = llvm::DoubleToBits(val);
|
||||
uint64_t v = wpi::DoubleToBits(val);
|
||||
m_data.append(
|
||||
{static_cast<char>((v >> 56) & 0xff), static_cast<char>((v >> 48) & 0xff),
|
||||
static_cast<char>((v >> 40) & 0xff), static_cast<char>((v >> 32) & 0xff),
|
||||
@@ -175,7 +175,7 @@ void WireEncoder::WriteValue(const Value& value) {
|
||||
}
|
||||
}
|
||||
|
||||
size_t WireEncoder::GetStringSize(llvm::StringRef str) const {
|
||||
size_t WireEncoder::GetStringSize(wpi::StringRef str) const {
|
||||
if (m_proto_rev < 0x0300u) {
|
||||
size_t len = str.size();
|
||||
if (len > 0xffff) len = 0xffff; // Limited to 64K length; truncate
|
||||
@@ -184,7 +184,7 @@ size_t WireEncoder::GetStringSize(llvm::StringRef str) const {
|
||||
return wpi::SizeUleb128(str.size()) + str.size();
|
||||
}
|
||||
|
||||
void WireEncoder::WriteString(llvm::StringRef str) {
|
||||
void WireEncoder::WriteString(wpi::StringRef str) {
|
||||
// length
|
||||
size_t len = str.size();
|
||||
if (m_proto_rev < 0x0300u) {
|
||||
|
||||
Reference in New Issue
Block a user