span: switch to std
Reduce the dependency on stdplus' version of span now that we are using
C++20 and use the one out of the STL instead.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: I040ba1796d6f278353fbc990ea6b62314927951e
diff --git a/tools/p2a.cpp b/tools/p2a.cpp
index db8b75d..3cd641a 100644
--- a/tools/p2a.cpp
+++ b/tools/p2a.cpp
@@ -29,6 +29,7 @@
#include <cstdint>
#include <cstring>
#include <memory>
+#include <span>
#include <string>
namespace host_tool
@@ -105,8 +106,8 @@
bytesRead = sys->read(*inputFd, readBuffer.data(), readBuffer.size());
if (bytesRead > 0)
{
- bridge->write(stdplus::span<const std::uint8_t>(readBuffer.data(),
- bytesRead));
+ bridge->write(
+ std::span<const std::uint8_t>(readBuffer.data(), bytesRead));
/* Ok, so the data is staged, now send the blob write with the
* details.
diff --git a/tools/pci.cpp b/tools/pci.cpp
index 150095f..8403771 100644
--- a/tools/pci.cpp
+++ b/tools/pci.cpp
@@ -30,6 +30,7 @@
#include <stdplus/handle/managed.hpp>
#include <cstring>
+#include <span>
#include <system_error>
namespace host_tool
@@ -104,7 +105,7 @@
}
}
-void PciAccessBridge::write(const stdplus::span<const std::uint8_t> data)
+void PciAccessBridge::write(const std::span<const std::uint8_t> data)
{
if (data.size() > dataLength)
{
diff --git a/tools/pci.hpp b/tools/pci.hpp
index 33878c8..8f40910 100644
--- a/tools/pci.hpp
+++ b/tools/pci.hpp
@@ -22,7 +22,7 @@
#include <linux/pci_regs.h>
-#include <stdplus/types.hpp>
+#include <span>
// Some versions of the linux/pci_regs.h header don't define this
#ifndef PCI_STD_NUM_BARS
@@ -37,7 +37,7 @@
public:
virtual ~PciBridgeIntf() = default;
- virtual void write(const stdplus::span<const std::uint8_t> data) = 0;
+ virtual void write(const std::span<const std::uint8_t> data) = 0;
virtual void configure(const ipmi_flash::PciConfigResponse& config) = 0;
virtual std::size_t getDataLength() = 0;
@@ -48,7 +48,7 @@
public:
virtual ~PciAccessBridge();
- virtual void write(const stdplus::span<const std::uint8_t> data) override;
+ virtual void write(const std::span<const std::uint8_t> data) override;
virtual void configure(const ipmi_flash::PciConfigResponse&) override{};
std::size_t getDataLength() override
diff --git a/tools/test/tools_pci_unittest.cpp b/tools/test/tools_pci_unittest.cpp
index ca6b7ab..c3ce610 100644
--- a/tools/test/tools_pci_unittest.cpp
+++ b/tools/test/tools_pci_unittest.cpp
@@ -23,6 +23,7 @@
#include <algorithm>
#include <cstdlib>
+#include <span>
#include <string>
#include <vector>
@@ -350,8 +351,7 @@
expectSetup(pciMock, dev, &nuvotonDevice, region.data());
std::unique_ptr<PciBridgeIntf> bridge = nuvotonDevice.getBridge(&pciMock);
- EXPECT_THROW(bridge->write(stdplus::span<std::uint8_t>(data)),
- ToolException);
+ EXPECT_THROW(bridge->write(std::span<std::uint8_t>(data)), ToolException);
}
TEST(NuvotonWriteTest, Success)
@@ -366,10 +366,10 @@
expectSetup(pciMock, dev, &nuvotonDevice, region.data());
std::unique_ptr<PciBridgeIntf> bridge = nuvotonDevice.getBridge(&pciMock);
- bridge->write(stdplus::span<std::uint8_t>(data));
+ bridge->write(std::span<std::uint8_t>(data));
- EXPECT_THAT(stdplus::span<uint8_t>(®ion[0], data.size()),
- SpanEq(stdplus::span<uint8_t>(data)));
+ EXPECT_THAT(std::span<uint8_t>(®ion[0], data.size()),
+ SpanEq(std::span<uint8_t>(data)));
}
TEST(NuvotonConfigureTest, Success)
@@ -592,8 +592,7 @@
expectSetup(pciMock, dev, &aspeedDevice, region.data());
std::unique_ptr<PciBridgeIntf> bridge = aspeedDevice.getBridge(&pciMock);
- EXPECT_THROW(bridge->write(stdplus::span<std::uint8_t>(data)),
- ToolException);
+ EXPECT_THROW(bridge->write(std::span<std::uint8_t>(data)), ToolException);
}
TEST(AspeedWriteTest, Success)
@@ -608,10 +607,10 @@
expectSetup(pciMock, dev, &aspeedDevice, region.data());
std::unique_ptr<PciBridgeIntf> bridge = aspeedDevice.getBridge(&pciMock);
- bridge->write(stdplus::span<std::uint8_t>(data));
+ bridge->write(std::span<std::uint8_t>(data));
- EXPECT_THAT(stdplus::span<uint8_t>(®ion[0x10000], data.size()),
- SpanEq(stdplus::span<uint8_t>(data)));
+ EXPECT_THAT(std::span<uint8_t>(®ion[0x10000], data.size()),
+ SpanEq(std::span<uint8_t>(data)));
}
TEST(AspeedConfigureTest, Success)
@@ -628,7 +627,7 @@
auto configSpan = stdplus::raw::asSpan<uint8_t>(config);
EXPECT_THAT(
- stdplus::span<uint8_t>(®ion[AspeedDevice::bridge], sizeof(config)),
+ std::span<uint8_t>(®ion[AspeedDevice::bridge], sizeof(config)),
SpanEq(configSpan));
}