Skip to content

Commit

Permalink
rust: silence warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Ravenslofty authored and gatecat committed Jan 3, 2024
1 parent e12ab86 commit 50d4374
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions rust/rust.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
namespace {
USING_NEXTPNR_NAMESPACE;

// `memcpy` is used here to avoid strict-aliasing problems, but GCC dislikes it.
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wclass-memaccess"
template<typename T>
uint64_t wrap(T thing) {
static_assert(sizeof(T) <= 8, "T is too big for FFI");
Expand Down Expand Up @@ -50,6 +53,7 @@ namespace {
memcpy(&w, &wire, sizeof(WireId));
return w;
}
#pragma GCC diagnostic pop
}

using DownhillIter = decltype(Context(ArchArgs()).getPipsDownhill(WireId()).begin());
Expand Down Expand Up @@ -99,8 +103,10 @@ extern "C" {

uint64_t npnr_context_get_pips_leak(const Context *ctx, uint64_t **pips) {
auto size = size_t{};
for (auto _pip : ctx->getPips())
for (auto _pip : ctx->getPips()) {
NPNR_UNUSED(_pip);
size++;
}
*pips = new uint64_t[size];
auto idx = 0;
for (auto pip : ctx->getPips()) {
Expand All @@ -113,8 +119,10 @@ extern "C" {

uint64_t npnr_context_get_wires_leak(const Context *ctx, uint64_t **wires) {
auto size = size_t{};
for (auto _wire : ctx->getWires())
for (auto _wire : ctx->getWires()) {
NPNR_UNUSED(_wire);
size++;
}
*wires = new uint64_t[size];
auto idx = 0;
for (auto wire : ctx->getWires()) {
Expand Down

0 comments on commit 50d4374

Please sign in to comment.