mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +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:
@@ -11,8 +11,8 @@
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
|
||||
#include <llvm/FileSystem.h>
|
||||
#include <llvm/StringRef.h>
|
||||
#include <wpi/FileSystem.h>
|
||||
#include <wpi/StringRef.h>
|
||||
|
||||
#include "../visa/visa.h"
|
||||
#include "HAL/Errors.h"
|
||||
@@ -137,22 +137,22 @@ void SerialHelper::SortHubPathVector() {
|
||||
m_sortedHubPath.clear();
|
||||
m_sortedHubPath = m_unsortedHubPath;
|
||||
std::sort(m_sortedHubPath.begin(), m_sortedHubPath.end(),
|
||||
[](const llvm::SmallVectorImpl<char>& lhs,
|
||||
const llvm::SmallVectorImpl<char>& rhs) -> int {
|
||||
llvm::StringRef lhsRef(lhs.begin(), lhs.size());
|
||||
llvm::StringRef rhsRef(rhs.begin(), rhs.size());
|
||||
[](const wpi::SmallVectorImpl<char>& lhs,
|
||||
const wpi::SmallVectorImpl<char>& rhs) -> int {
|
||||
wpi::StringRef lhsRef(lhs.begin(), lhs.size());
|
||||
wpi::StringRef rhsRef(rhs.begin(), rhs.size());
|
||||
return lhsRef.compare(rhsRef);
|
||||
});
|
||||
}
|
||||
|
||||
void SerialHelper::CoiteratedSort(
|
||||
llvm::SmallVectorImpl<llvm::SmallString<16>>& vec) {
|
||||
llvm::SmallVector<llvm::SmallString<16>, 4> sortedVec;
|
||||
wpi::SmallVectorImpl<wpi::SmallString<16>>& vec) {
|
||||
wpi::SmallVector<wpi::SmallString<16>, 4> sortedVec;
|
||||
for (auto& str : m_sortedHubPath) {
|
||||
for (size_t i = 0; i < m_unsortedHubPath.size(); i++) {
|
||||
if (llvm::StringRef{m_unsortedHubPath[i].begin(),
|
||||
if (wpi::StringRef{m_unsortedHubPath[i].begin(),
|
||||
m_unsortedHubPath[i].size()}
|
||||
.equals(llvm::StringRef{str.begin(), str.size()})) {
|
||||
.equals(wpi::StringRef{str.begin(), str.size()})) {
|
||||
sortedVec.push_back(vec[i]);
|
||||
break;
|
||||
}
|
||||
@@ -206,26 +206,26 @@ void SerialHelper::QueryHubPaths(int32_t* status) {
|
||||
*status = 0;
|
||||
|
||||
// split until (/dev/
|
||||
llvm::StringRef devNameRef = llvm::StringRef{osName}.split("(/dev/").second;
|
||||
wpi::StringRef devNameRef = wpi::StringRef{osName}.split("(/dev/").second;
|
||||
// String not found, continue
|
||||
if (devNameRef.equals("")) continue;
|
||||
|
||||
// Split at )
|
||||
llvm::StringRef matchString = devNameRef.split(')').first;
|
||||
wpi::StringRef matchString = devNameRef.split(')').first;
|
||||
if (matchString.equals(devNameRef)) continue;
|
||||
|
||||
// Search directories to get a list of system accessors
|
||||
std::error_code ec;
|
||||
for (auto p = llvm::sys::fs::recursive_directory_iterator(
|
||||
for (auto p = wpi::sys::fs::recursive_directory_iterator(
|
||||
"/sys/devices/soc0", ec);
|
||||
p != llvm::sys::fs::recursive_directory_iterator(); p.increment(ec)) {
|
||||
p != wpi::sys::fs::recursive_directory_iterator(); p.increment(ec)) {
|
||||
if (ec) break;
|
||||
llvm::StringRef path{p->path()};
|
||||
if (path.find("amba") == llvm::StringRef::npos) continue;
|
||||
if (path.find("usb") == llvm::StringRef::npos) continue;
|
||||
if (path.find(matchString) == llvm::StringRef::npos) continue;
|
||||
wpi::StringRef path{p->path()};
|
||||
if (path.find("amba") == wpi::StringRef::npos) continue;
|
||||
if (path.find("usb") == wpi::StringRef::npos) continue;
|
||||
if (path.find(matchString) == wpi::StringRef::npos) continue;
|
||||
|
||||
llvm::SmallVector<llvm::StringRef, 16> pathSplitVec;
|
||||
wpi::SmallVector<wpi::StringRef, 16> pathSplitVec;
|
||||
// Split path into individual directories
|
||||
path.split(pathSplitVec, '/', -1, false);
|
||||
|
||||
@@ -255,10 +255,10 @@ void SerialHelper::QueryHubPaths(int32_t* status) {
|
||||
|
||||
// Add our devices to our list
|
||||
m_unsortedHubPath.emplace_back(
|
||||
llvm::StringRef{pathSplitVec[hubIndex - 2]});
|
||||
wpi::StringRef{pathSplitVec[hubIndex - 2]});
|
||||
m_visaResource.emplace_back(desc);
|
||||
m_osResource.emplace_back(
|
||||
llvm::StringRef{osName}.split("(").second.split(")").first);
|
||||
wpi::StringRef{osName}.split("(").second.split(")").first);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -277,7 +277,7 @@ int32_t SerialHelper::GetIndexForPort(HAL_SerialPort port, int32_t* status) {
|
||||
|
||||
std::string portString = m_usbNames[port - 2];
|
||||
|
||||
llvm::SmallVector<int32_t, 4> indices;
|
||||
wpi::SmallVector<int32_t, 4> indices;
|
||||
|
||||
// If port has not been assigned, find the one to assign
|
||||
if (portString.empty()) {
|
||||
|
||||
Reference in New Issue
Block a user