Gabe Black has uploaded this change for review. (
https://gem5-review.googlesource.com/c/public/gem5/+/31834 )
Change subject: util: Use the std namespace for memcpy and memset in the m5
util.
......................................................................
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
---
M util/m5/src/args.cc
M util/m5/src/command/readfile.cc
M util/m5/src/command/readfile.test.cc
M util/m5/src/command/writefile.cc
M util/m5/src/command/writefile.test.cc
5 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/util/m5/src/args.cc b/util/m5/src/args.cc
index 1caad43..83dd3d5 100644
--- a/util/m5/src/args.cc
+++ b/util/m5/src/args.cc
@@ -49,7 +49,7 @@
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 92c39e2..8cd5203 100644
--- a/util/m5/src/command/readfile.cc
+++ b/util/m5/src/command/readfile.cc
@@ -44,7 +44,7 @@
// 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 d5ffe1d..435b54e 100644
--- a/util/m5/src/command/readfile.test.cc
+++ b/util/m5/src/command/readfile.test.cc
@@ -27,6 +27,7 @@
#include <gtest/gtest.h>
+#include <cstring>
#include <sstream>
#include "args.hh"
@@ -85,7 +86,7 @@
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 7771dfe..41596bc 100644
--- a/util/m5/src/command/writefile.cc
+++ b/util/m5/src/command/writefile.cc
@@ -55,7 +55,7 @@
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 a1adf5c..41d70d4 100644
--- a/util/m5/src/command/writefile.test.cc
+++ b/util/m5/src/command/writefile.test.cc
@@ -67,7 +67,7 @@
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 @@
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);
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/31834
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: Ib53a7f0c41d7f5776221e7661c616ea51e8ed528
Gerrit-Change-Number: 31834
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s