mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-29 02:21:44 +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:
@@ -8,7 +8,7 @@
|
||||
#include "HAL/AnalogInput.h"
|
||||
|
||||
#include <FRC_NetworkCommunication/AICalibration.h>
|
||||
#include <support/mutex.h>
|
||||
#include <wpi/mutex.h>
|
||||
|
||||
#include "AnalogInternal.h"
|
||||
#include "HAL/AnalogAccumulator.h"
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
#include <atomic>
|
||||
|
||||
#include <support/mutex.h>
|
||||
#include <wpi/mutex.h>
|
||||
|
||||
#include "HAL/AnalogInput.h"
|
||||
#include "HAL/ChipObject.h"
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <support/mutex.h>
|
||||
#include <wpi/mutex.h>
|
||||
|
||||
#include "HAL/ChipObject.h"
|
||||
#include "HAL/Ports.h"
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include <thread>
|
||||
|
||||
#include <FRC_NetworkCommunication/LoadOut.h>
|
||||
#include <support/mutex.h>
|
||||
#include <wpi/mutex.h>
|
||||
|
||||
#include "ConstantsInternal.h"
|
||||
#include "HAL/AnalogTrigger.h"
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <support/mutex.h>
|
||||
#include <wpi/mutex.h>
|
||||
|
||||
#include "HAL/AnalogTrigger.h"
|
||||
#include "HAL/ChipObject.h"
|
||||
|
||||
@@ -13,9 +13,9 @@
|
||||
|
||||
#include <FRC_NetworkCommunication/FRCComm.h>
|
||||
#include <FRC_NetworkCommunication/NetCommRPCProxy_Occur.h>
|
||||
#include <llvm/raw_ostream.h>
|
||||
#include <support/condition_variable.h>
|
||||
#include <support/mutex.h>
|
||||
#include <wpi/condition_variable.h>
|
||||
#include <wpi/mutex.h>
|
||||
#include <wpi/raw_ostream.h>
|
||||
|
||||
#include "HAL/DriverStation.h"
|
||||
|
||||
@@ -73,12 +73,12 @@ int32_t HAL_SendError(HAL_Bool isError, int32_t errorCode, HAL_Bool isLVCode,
|
||||
details, location, callStack);
|
||||
if (printMsg) {
|
||||
if (location && location[0] != '\0') {
|
||||
llvm::errs() << (isError ? "Error" : "Warning") << " at " << location
|
||||
<< ": ";
|
||||
wpi::errs() << (isError ? "Error" : "Warning") << " at " << location
|
||||
<< ": ";
|
||||
}
|
||||
llvm::errs() << details << "\n";
|
||||
wpi::errs() << details << "\n";
|
||||
if (callStack && callStack[0] != '\0') {
|
||||
llvm::errs() << callStack << "\n";
|
||||
wpi::errs() << callStack << "\n";
|
||||
}
|
||||
}
|
||||
if (i == KEEP_MSGS) {
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
|
||||
#include <FRC_NetworkCommunication/FRCComm.h>
|
||||
#include <FRC_NetworkCommunication/LoadOut.h>
|
||||
#include <llvm/raw_ostream.h>
|
||||
#include <support/mutex.h>
|
||||
#include <support/timestamp.h>
|
||||
#include <wpi/mutex.h>
|
||||
#include <wpi/raw_ostream.h>
|
||||
#include <wpi/timestamp.h>
|
||||
|
||||
#include "HAL/ChipObject.h"
|
||||
#include "HAL/DriverStation.h"
|
||||
@@ -329,20 +329,20 @@ static bool killExistingProgram(int timeout, int mode) {
|
||||
// see if the pid is around, but we don't want to mess with init id=1, or
|
||||
// ourselves
|
||||
if (pid >= 2 && kill(pid, 0) == 0 && pid != getpid()) {
|
||||
llvm::outs() << "Killing previously running FRC program...\n";
|
||||
wpi::outs() << "Killing previously running FRC program...\n";
|
||||
kill(pid, SIGTERM); // try to kill it
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(timeout));
|
||||
if (kill(pid, 0) == 0) {
|
||||
// still not successfull
|
||||
if (mode == 0) {
|
||||
llvm::outs() << "FRC pid " << pid << " did not die within " << timeout
|
||||
<< "ms. Aborting\n";
|
||||
wpi::outs() << "FRC pid " << pid << " did not die within " << timeout
|
||||
<< "ms. Aborting\n";
|
||||
return 0; // just fail
|
||||
} else if (mode == 1) { // kill -9 it
|
||||
kill(pid, SIGKILL);
|
||||
} else {
|
||||
llvm::outs() << "WARNING: FRC pid " << pid << " did not die within "
|
||||
<< timeout << "ms.\n";
|
||||
wpi::outs() << "WARNING: FRC pid " << pid << " did not die within "
|
||||
<< timeout << "ms.\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -374,7 +374,7 @@ HAL_Bool HAL_Initialize(int32_t timeout, int32_t mode) {
|
||||
|
||||
setlinebuf(stdin);
|
||||
setlinebuf(stdout);
|
||||
llvm::outs().SetUnbuffered();
|
||||
wpi::outs().SetUnbuffered();
|
||||
|
||||
prctl(PR_SET_PDEATHSIG, SIGTERM);
|
||||
|
||||
@@ -401,10 +401,10 @@ HAL_Bool HAL_Initialize(int32_t timeout, int32_t mode) {
|
||||
int32_t status = 0;
|
||||
uint64_t rv = HAL_GetFPGATime(&status);
|
||||
if (status != 0) {
|
||||
llvm::errs()
|
||||
wpi::errs()
|
||||
<< "Call to HAL_GetFPGATime failed."
|
||||
<< "Initialization might have failed. Time will not be correct\n";
|
||||
llvm::errs().flush();
|
||||
wpi::errs().flush();
|
||||
return 0u;
|
||||
}
|
||||
return rv;
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <support/SafeThread.h>
|
||||
#include <wpi/SafeThread.h>
|
||||
|
||||
#include "DigitalInternal.h"
|
||||
#include "HAL/ChipObject.h"
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
#include <cstdlib> // For std::atexit()
|
||||
#include <memory>
|
||||
|
||||
#include <support/condition_variable.h>
|
||||
#include <support/mutex.h>
|
||||
#include <wpi/condition_variable.h>
|
||||
#include <wpi/mutex.h>
|
||||
|
||||
#include "HAL/ChipObject.h"
|
||||
#include "HAL/Errors.h"
|
||||
|
||||
@@ -217,9 +217,9 @@ int32_t HAL_ReadOSSerial(HAL_SerialPort port, char* buffer, int32_t count,
|
||||
std::memcpy(&buffer[bytesRead], buf, rx);
|
||||
bytesRead += rx;
|
||||
if (bytesRead >= count) break;
|
||||
llvm::StringRef tmp(buffer, bytesRead);
|
||||
wpi::StringRef tmp(buffer, bytesRead);
|
||||
auto loc = tmp.find('\n');
|
||||
if (loc != llvm::StringRef::npos) {
|
||||
if (loc != wpi::StringRef::npos) {
|
||||
bytesRead = loc;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
#include <atomic>
|
||||
#include <cstring>
|
||||
|
||||
#include <llvm/raw_ostream.h>
|
||||
#include <support/mutex.h>
|
||||
#include <wpi/raw_ostream.h>
|
||||
#include <wpi/mutex.h>
|
||||
|
||||
#include "DigitalInternal.h"
|
||||
#include "HAL/DIO.h"
|
||||
@@ -196,20 +196,20 @@ void HAL_InitializeSPI(HAL_SPIPort port, int32_t* status) {
|
||||
if ((digitalHandles[5] = HAL_InitializeDIOPort(createPortHandleForSPI(14),
|
||||
false, status)) ==
|
||||
HAL_kInvalidHandle) {
|
||||
llvm::outs() << "Failed to allocate DIO 14\n";
|
||||
wpi::outs() << "Failed to allocate DIO 14\n";
|
||||
return;
|
||||
}
|
||||
if ((digitalHandles[6] = HAL_InitializeDIOPort(createPortHandleForSPI(15),
|
||||
false, status)) ==
|
||||
HAL_kInvalidHandle) {
|
||||
llvm::outs() << "Failed to allocate DIO 15\n";
|
||||
wpi::outs() << "Failed to allocate DIO 15\n";
|
||||
HAL_FreeDIOPort(digitalHandles[5]); // free the first port allocated
|
||||
return;
|
||||
}
|
||||
if ((digitalHandles[7] = HAL_InitializeDIOPort(createPortHandleForSPI(16),
|
||||
false, status)) ==
|
||||
HAL_kInvalidHandle) {
|
||||
llvm::outs() << "Failed to allocate DIO 16\n";
|
||||
wpi::outs() << "Failed to allocate DIO 16\n";
|
||||
HAL_FreeDIOPort(digitalHandles[5]); // free the first port allocated
|
||||
HAL_FreeDIOPort(digitalHandles[6]); // free the second port allocated
|
||||
return;
|
||||
@@ -217,7 +217,7 @@ void HAL_InitializeSPI(HAL_SPIPort port, int32_t* status) {
|
||||
if ((digitalHandles[8] = HAL_InitializeDIOPort(createPortHandleForSPI(17),
|
||||
false, status)) ==
|
||||
HAL_kInvalidHandle) {
|
||||
llvm::outs() << "Failed to allocate DIO 17\n";
|
||||
wpi::outs() << "Failed to allocate DIO 17\n";
|
||||
HAL_FreeDIOPort(digitalHandles[5]); // free the first port allocated
|
||||
HAL_FreeDIOPort(digitalHandles[6]); // free the second port allocated
|
||||
HAL_FreeDIOPort(digitalHandles[7]); // free the third port allocated
|
||||
|
||||
@@ -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()) {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <map>
|
||||
#include <string.h> // memcpy
|
||||
#include <sys/time.h>
|
||||
#include <support/mutex.h>
|
||||
#include <wpi/mutex.h>
|
||||
class CtreCanNode
|
||||
{
|
||||
public:
|
||||
|
||||
Reference in New Issue
Block a user