[Darshan-commits] [Git][darshan/darshan][dev-stdio] 2 commits: fdopen wrapper

Philip Carns xgitlab at cels.anl.gov
Mon May 23 19:42:08 CDT 2016


Philip Carns pushed to branch dev-stdio at darshan / darshan


Commits:
9930d72a by Phil Carns at 2016-05-23T20:38:32-04:00
fdopen wrapper

- - - - -
e025a97f by Phil Carns at 2016-05-23T20:42:01-04:00
freopen wrapper

- - - - -


2 changed files:

- darshan-runtime/lib/darshan-stdio.c
- darshan-runtime/share/ld-opts/darshan-stdio-ld-opts


Changes:

=====================================
darshan-runtime/lib/darshan-stdio.c
=====================================
--- a/darshan-runtime/lib/darshan-stdio.c
+++ b/darshan-runtime/lib/darshan-stdio.c
@@ -15,6 +15,7 @@
  *     - POSIX_FREADS
  *     - POSIX_FWRITES
  *     - POSIX_FSEEKS
+ * - add regression test cases for all functions captured here
  */
 
 /* catalog of stdio functions instrumented by this module
@@ -22,8 +23,8 @@
  * functions for opening streams
  * --------------
  * FILE    *fdopen(int, const char *);                      DONE
- * FILE    *fopen(const char *, const char *);
- * FILE    *freopen(const char *, const char *, FILE *);
+ * FILE    *fopen(const char *, const char *);              DONE
+ * FILE    *freopen(const char *, const char *, FILE *);    DONE
  *
  * functions for closing streams
  * --------------
@@ -92,6 +93,8 @@
 
 DARSHAN_FORWARD_DECL(fopen, FILE*, (const char *path, const char *mode));
 DARSHAN_FORWARD_DECL(fopen64, FILE*, (const char *path, const char *mode));
+DARSHAN_FORWARD_DECL(fdopen, FILE*, (int fd, const char *mode));
+DARSHAN_FORWARD_DECL(freopen, FILE*, (const char *path, const char *mode, FILE *stream));
 DARSHAN_FORWARD_DECL(fclose, int, (FILE *fp));
 DARSHAN_FORWARD_DECL(fwrite, size_t, (const void *ptr, size_t size, size_t nmemb, FILE *stream));
 DARSHAN_FORWARD_DECL(fread, size_t, (void *ptr, size_t size, size_t nmemb, FILE *stream));
@@ -291,6 +294,44 @@ FILE* DARSHAN_DECL(fopen64)(const char *path, const char *mode)
     return(ret);
 }
 
+FILE* DARSHAN_DECL(fdopen)(int fd, const char *mode)
+{
+    FILE* ret;
+    double tm1, tm2;
+
+    MAP_OR_FAIL(fdopen);
+
+    tm1 = darshan_core_wtime();
+    ret = __real_fdopen(fd, mode);
+    tm2 = darshan_core_wtime();
+
+    STDIO_LOCK();
+    stdio_runtime_initialize();
+    STDIO_RECORD_OPEN(ret, "UNKNOWN-FDOPEN", tm1, tm2);
+    STDIO_UNLOCK();
+
+    return(ret);
+}
+
+FILE* DARSHAN_DECL(freopen)(const char *path, const char *mode, FILE *stream)
+{
+    FILE* ret;
+    double tm1, tm2;
+
+    MAP_OR_FAIL(freopen);
+
+    tm1 = darshan_core_wtime();
+    ret = __real_freopen(path, mode, stream);
+    tm2 = darshan_core_wtime();
+
+    STDIO_LOCK();
+    stdio_runtime_initialize();
+    STDIO_RECORD_OPEN(ret, path, tm1, tm2);
+    STDIO_UNLOCK();
+
+    return(ret);
+}
+
 int DARSHAN_DECL(fclose)(FILE *fp)
 {
     struct stdio_file_runtime* file;


=====================================
darshan-runtime/share/ld-opts/darshan-stdio-ld-opts
=====================================
--- a/darshan-runtime/share/ld-opts/darshan-stdio-ld-opts
+++ b/darshan-runtime/share/ld-opts/darshan-stdio-ld-opts
@@ -1,6 +1,8 @@
 --undefined=__wrap_fopen
 --wrap=fopen
 --wrap=fopen64
+--wrap=fdopen
+--wrap=freopen
 --wrap=fclose
 --wrap=fwrite
 --wrap=fread



View it on GitLab: https://xgitlab.cels.anl.gov/darshan/darshan/compare/11c80b443cafe3486518ae37b944470ef27a238a...e025a97f1a3ecae760b265992356b3977199ec67
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/darshan-commits/attachments/20160523/ef995484/attachment.html>


More information about the Darshan-commits mailing list