Commit 6b4f4109 authored by Shane Snyder's avatar Shane Snyder

more posix wrappers: mmap

parent 1c701eff
......@@ -16,9 +16,7 @@ enum darshan_posix_indices
POSIX_WRITES, /* count of posix writes */
POSIX_SEEKS, /* count of posix seeks */
POSIX_STATS, /* count of posix stat/lstat/fstats */
#if 0
POSIX_MMAPS, /* count of posix mmaps */
#endif
POSIX_FOPENS, /* count of posix fopens */
POSIX_FREADS, /* count of posix freads */
POSIX_FWRITES, /* count of posix fwrites */
......
......@@ -23,6 +23,8 @@
--wrap=__lxstat64
--wrap=__fxstat
--wrap=__fxstat64
--wrap=mmap
--wrap=mmap64
--wrap=fsync
--wrap=fdatasync
--wrap=close
......
......@@ -62,7 +62,8 @@ DARSHAN_FORWARD_DECL(__lxstat, int, (int vers, const char* path, struct stat *bu
DARSHAN_FORWARD_DECL(__lxstat64, int, (int vers, const char* path, struct stat64 *buf));
DARSHAN_FORWARD_DECL(__fxstat, int, (int vers, int fd, struct stat *buf));
DARSHAN_FORWARD_DECL(__fxstat64, int, (int vers, int fd, struct stat64 *buf));
/* TODO mmaps */
DARSHAN_FORWARD_DECL(mmap, void*, (void *addr, size_t length, int prot, int flags, int fd, off_t offset));
DARSHAN_FORWARD_DECL(mmap64, void*, (void *addr, size_t length, int prot, int flags, int fd, off64_t offset));
DARSHAN_FORWARD_DECL(fsync, int, (int fd));
DARSHAN_FORWARD_DECL(fdatasync, int, (int fd));
DARSHAN_FORWARD_DECL(close, int, (int fd));
......@@ -993,6 +994,54 @@ int DARSHAN_DECL(__fxstat64)(int vers, int fd, struct stat64 *buf)
return(ret);
}
void* DARSHAN_DECL(mmap)(void *addr, size_t length, int prot, int flags,
int fd, off_t offset)
{
void* ret;
struct posix_file_runtime* file;
MAP_OR_FAIL(mmap);
ret = __real_mmap(addr, length, prot, flags, fd, offset);
if(ret == MAP_FAILED)
return(ret);
POSIX_LOCK();
posix_runtime_initialize();
file = posix_file_by_fd(fd);
if(file)
{
DARSHAN_COUNTER_INC(file->file_record, POSIX_MMAPS, 1);
}
POSIX_UNLOCK();
return(ret);
}
void* DARSHAN_DECL(mmap64)(void *addr, size_t length, int prot, int flags,
int fd, off64_t offset)
{
void* ret;
struct posix_file_runtime* file;
MAP_OR_FAIL(mmap64);
ret = __real_mmap64(addr, length, prot, flags, fd, offset);
if(ret == MAP_FAILED)
return(ret);
POSIX_LOCK();
posix_runtime_initialize();
file = posix_file_by_fd(fd);
if(file)
{
DARSHAN_COUNTER_INC(file->file_record, POSIX_MMAPS, 1);
}
POSIX_UNLOCK();
return(ret);
}
int DARSHAN_DECL(fsync)(int fd)
{
int ret;
......
......@@ -175,6 +175,7 @@ int main(int argc, char **argv)
"\t\tPOSIX_WRITES:\t%"PRIu64"\n"
"\t\tPOSIX_SEEKS:\t%"PRIu64"\n"
"\t\tPOSIX_STATS:\t%"PRIu64"\n"
"\t\tPOSIX_MMAPS:\t%"PRIu64"\n"
"\t\tPOSIX_FOPENS:\t%"PRIu64"\n"
"\t\tPOSIX_FREADS:\t%"PRIu64"\n"
"\t\tPOSIX_FWRITES:\t%"PRIu64"\n"
......@@ -210,6 +211,7 @@ int main(int argc, char **argv)
next_file.counters[POSIX_WRITES],
next_file.counters[POSIX_SEEKS],
next_file.counters[POSIX_STATS],
next_file.counters[POSIX_MMAPS],
next_file.counters[POSIX_FOPENS],
next_file.counters[POSIX_FREADS],
next_file.counters[POSIX_FWRITES],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment