A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
simgrid.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Rewrite/simplify the C++ flag declaration
[simgrid.git]
/
src
/
xbt
/
memory_map.cpp
diff --git
a/src/xbt/memory_map.cpp
b/src/xbt/memory_map.cpp
index
0fc10cb
..
0f7cc0f
100644
(file)
--- a/
src/xbt/memory_map.cpp
+++ b/
src/xbt/memory_map.cpp
@@
-9,7
+9,9
@@
#include <cstring>
#include <sys/types.h>
#include <cstring>
#include <sys/types.h>
-#include <sys/mman.h>
+#ifdef __linux__
+# include <sys/mman.h>
+#endif
#include <xbt/sysdep.h>
#include <xbt/base.h>
#include <xbt/sysdep.h>
#include <xbt/base.h>
@@
-19,10
+21,7
@@
#include "memory_map.hpp"
extern "C" {
#include "memory_map.hpp"
extern "C" {
-
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(xbt_memory_map, xbt,
- "Logging specific to algorithms for memory_map");
-
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(xbt_memory_map, xbt, "Logging specific to algorithms for memory_map");
}
namespace simgrid {
}
namespace simgrid {
@@
-37,8
+36,7
@@
XBT_PRIVATE std::vector<VmMap> get_memory_map(pid_t pid)
FILE *fp = std::fopen(path, "r");
if(fp == NULL)
std::perror("fopen failed");
FILE *fp = std::fopen(path, "r");
if(fp == NULL)
std::perror("fopen failed");
- xbt_assert(fp,
- "Cannot open %s to investigate the memory map of the process.", path);
+ xbt_assert(fp, "Cannot open %s to investigate the memory map of the process.", path);
free(path);
setbuf(fp, NULL);
free(path);
setbuf(fp, NULL);
@@
-55,8
+53,7
@@
XBT_PRIVATE std::vector<VmMap> get_memory_map(pid_t pid)
/* Wipeout the new line character */
line[read - 1] = '\0';
/* Wipeout the new line character */
line[read - 1] = '\0';
- /* Tokenize the line using spaces as delimiters and store each token */
- /* in lfields array. We expect 5 tokens/fields */
+ /* Tokenize the line using spaces as delimiters and store each token in lfields array. We expect 5 tokens/fields */
char* lfields[6];
lfields[0] = strtok(line, " ");
char* lfields[6];
lfields[0] = strtok(line, " ");
@@
-117,7
+114,6
@@
XBT_PRIVATE std::vector<VmMap> get_memory_map(pid_t pid)
if (lfields[1][4] == 'p')
memreg.flags |= MAP_PRIVATE;
if (lfields[1][4] == 'p')
memreg.flags |= MAP_PRIVATE;
-
else if (lfields[1][4] == 's')
memreg.flags |= MAP_SHARED;
else if (lfields[1][4] == 's')
memreg.flags |= MAP_SHARED;
@@
-157,18
+153,16
@@
XBT_PRIVATE std::vector<VmMap> get_memory_map(pid_t pid)
/* Create space for a new map region in the region's array and copy the */
/* parsed stuff from the temporal memreg variable */
/* Create space for a new map region in the region's array and copy the */
/* parsed stuff from the temporal memreg variable */
- XBT_DEBUG("Found region for %s",
- !memreg.pathname.empty() ? memreg.pathname.c_str() : "(null)");
+ XBT_DEBUG("Found region for %s", !memreg.pathname.empty() ? memreg.pathname.c_str() : "(null)");
ret.push_back(std::move(memreg));
}
std::free(line);
std::fclose(fp);
ret.push_back(std::move(memreg));
}
std::free(line);
std::fclose(fp);
- return
std::move(ret)
;
+ return
ret
;
#else
#else
- /* On FreeBSD, kinfo_getvmmap() could be used but mmap() support is disabled
- anyway. */
+ /* On FreeBSD, kinfo_getvmmap() could be used but mmap() support is disabled anyway. */
xbt_die("Could not get memory map from process %lli", (long long int) pid);
#endif
}
xbt_die("Could not get memory map from process %lli", (long long int) pid);
#endif
}