Skip to content

Commit

Permalink
Address reviewer suggestions.
Browse files Browse the repository at this point in the history
  • Loading branch information
virajbshah committed Feb 8, 2025
1 parent f53a5fb commit be2c757
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions gematria/datasets/annotating_importer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,16 @@
#include "quipper/perf_parser.h"
#include "quipper/perf_reader.h"

namespace gematria {
#if __has_include(<sys/mman.h>)
#include <sys/mman.h>
#else
// Memory mapping protection flag bits from `sys/mman.h`.
constexpr int PROT_READ = 0x1;
constexpr int PROT_WRITE = 0x2;
constexpr int PROT_EXEC = 0x4;
#endif

// Memory mapping protection flag bits on Linux, from `sys/mman.h`.
constexpr int kProtRead = 0b001; /* PROT_READ */
constexpr int kProtWrite = 0b010; /* PROT_WRITE */
constexpr int kProtExec = 0b100; /* PROT_EXEC */
namespace gematria {

AnnotatingImporter::AnnotatingImporter(const Canonicalizer *canonicalizer)
: importer_(canonicalizer) {}
Expand Down Expand Up @@ -103,8 +107,8 @@ AnnotatingImporter::GetMainMapping(
for (const auto &event : perf_data->events()) {
if (event.has_mmap_event() &&
GetBasenameFromPath(event.mmap_event().filename()) == file_name &&
event.mmap_event().prot() & kProtRead &&
event.mmap_event().prot() & kProtExec) {
event.mmap_event().prot() & PROT_READ &&
event.mmap_event().prot() & PROT_EXEC) {
return &event.mmap_event();
}
}
Expand Down

0 comments on commit be2c757

Please sign in to comment.