From: Gabe Black Date: Fri, 23 Oct 2020 03:01:10 +0000 (-0700) Subject: util: Use the std namespace for memcpy and memset in the m5 util. X-Git-Tag: develop-gem5-snapshot~342 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c110695a44c17f3860b3593734a97056c2872684;p=gem5.git util: Use the std namespace for memcpy and memset in the m5 util. The C++ versions of those functions are technically in the std namespace, and while they may work without it (the C version leaking through from somewhere?), they should still use it. Change-Id: Ib53a7f0c41d7f5776221e7661c616ea51e8ed528 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/31834 Tested-by: kokoro Maintainer: Bobby R. Bruce Reviewed-by: Daniel Carvalho --- diff --git a/util/m5/src/args.cc b/util/m5/src/args.cc index 1caad4394..83dd3d535 100644 --- a/util/m5/src/args.cc +++ b/util/m5/src/args.cc @@ -49,7 +49,7 @@ Args::pack(const std::string &str, uint64_t regs[], int num_regs) const size_t MaxLen = num_regs * RegSize; const char *arg = str.c_str(); - memset(regs, 0, MaxLen); + std::memset(regs, 0, MaxLen); size_t len = str.size(); diff --git a/util/m5/src/command/readfile.cc b/util/m5/src/command/readfile.cc index 92c39e25f..8cd520338 100644 --- a/util/m5/src/command/readfile.cc +++ b/util/m5/src/command/readfile.cc @@ -44,7 +44,7 @@ read_file(const DispatchTable &dt, std::ostream &os) // Touch all buffer pages to ensure they are mapped in the // page table. This is required in the case of X86_FS, where // Linux does demand paging. - memset(buf, 0, sizeof(buf)); + std::memset(buf, 0, sizeof(buf)); int len; int offset = 0; diff --git a/util/m5/src/command/readfile.test.cc b/util/m5/src/command/readfile.test.cc index d5ffe1d01..435b54e38 100644 --- a/util/m5/src/command/readfile.test.cc +++ b/util/m5/src/command/readfile.test.cc @@ -27,6 +27,7 @@ #include +#include #include #include "args.hh" @@ -85,7 +86,7 @@ test_m5_read_file(void *buffer, uint64_t len, uint64_t offset) chunks[i] = chunk_idx++; // Copy out to the requested buffer. - memcpy(buffer, ((uint8_t *)chunks) + (chunk_size - at_start), len); + std::memcpy(buffer, ((uint8_t *)chunks) + (chunk_size - at_start), len); // Clean up. delete [] chunks; diff --git a/util/m5/src/command/writefile.cc b/util/m5/src/command/writefile.cc index 7771dfe03..41596bc67 100644 --- a/util/m5/src/command/writefile.cc +++ b/util/m5/src/command/writefile.cc @@ -55,7 +55,7 @@ write_file(const DispatchTable &dt, const std::string &filename, char buf[256 * 1024]; int offset = 0; - memset(buf, 0, sizeof(buf)); + std::memset(buf, 0, sizeof(buf)); while (true) { src.seekg(offset); diff --git a/util/m5/src/command/writefile.test.cc b/util/m5/src/command/writefile.test.cc index a1adf5c4f..41d70d472 100644 --- a/util/m5/src/command/writefile.test.cc +++ b/util/m5/src/command/writefile.test.cc @@ -67,7 +67,7 @@ test_m5_write_file(void *buffer, uint64_t len, uint64_t offset, if (test_written_data.size() < required_size) test_written_data.resize(required_size); - memcpy(test_written_data.data() + offset, buffer, len); + std::memcpy(test_written_data.data() + offset, buffer, len); return len; } @@ -133,7 +133,7 @@ class TempFile for (size_t i = 0; i < num_chunks; i++) *buf32++ = val++; if (leftovers) - memcpy(buf32, &val, leftovers); + std::memcpy(buf32, &val, leftovers); // Make sure our new contents are out there. msync(_buf, _size, MS_SYNC | MS_INVALIDATE);