<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html lang="en">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>
GitLab
</title>

</head>
<body>
<style type="text/css">
img {
max-width: 100%; height: auto;
}
</style>
<div class="content">
<h3>
Philip Carns pushed to branch dev-stdio
at <a href="https://xgitlab.cels.anl.gov/darshan/darshan">darshan / darshan</a>
</h3>
<h4>
Commits:
</h4>
<ul>
<li>
<strong><a href="https://xgitlab.cels.anl.gov/darshan/darshan/commit/c2a087402c0e0c646034d51ab69866710180c0aa">c2a08740</a></strong>
<div>
<span>by Phil Carns</span>
<i>at 2016-05-23T22:37:10-04:00</i>
</div>
<pre class="commit-message" style="white-space: pre-wrap">fprintf wrapper</pre>
</li>
</ul>
<h4>2 changed files:</h4>
<ul>
<li class="file-stats">
<a href="#620f2ecad2bb6f74b2fcd0134963a841" style="text-decoration: none">
darshan-runtime/lib/darshan-stdio.c
</a>
</li>
<li class="file-stats">
<a href="#ad29afc395839758d41094872298bd0d" style="text-decoration: none">
darshan-runtime/share/ld-opts/darshan-stdio-ld-opts
</a>
</li>
</ul>
<h4>Changes:</h4>
<li id="620f2ecad2bb6f74b2fcd0134963a841">
<a href="https://xgitlab.cels.anl.gov/darshan/darshan/commit/c2a087402c0e0c646034d51ab69866710180c0aa#diff-0">
<strong>
darshan-runtime/lib/darshan-stdio.c
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="background: #ffdddd; color: #000000">--- a/darshan-runtime/lib/darshan-stdio.c
</span><span style="background: #ddffdd; color: #000000">+++ b/darshan-runtime/lib/darshan-stdio.c
</span><span style="color: #aaaaaa">@@ -47,13 +47,13 @@
</span>  *
  * functions for writing data
  * --------------
<span style="background: #ffdddd; color: #000000">- * int      fprintf(FILE *, const char *, ...);
</span><span style="background: #ddffdd; color: #000000">+ * int      fprintf(FILE *, const char *, ...);             DONE
+ * int      vfprintf(FILE *, const char *, va_list);        DONE
</span>  * int      fputc(int, FILE *);
  * int      fputs(const char *, FILE *);
  * size_t   fwrite(const void *, size_t, size_t, FILE *);   DONE
  * int      putc(int, FILE *);
  * int      putw(int, FILE *);
<span style="background: #ffdddd; color: #000000">- * int      vfprintf(FILE *, const char *, va_list);
</span>  *
  * functions for changing file position
  * --------------
<span style="color: #aaaaaa">@@ -102,6 +102,8 @@ DARSHAN_FORWARD_DECL(freopen, FILE*, (const char *path, const char *mode, FILE *
</span> DARSHAN_FORWARD_DECL(fclose, int, (FILE *fp));
 DARSHAN_FORWARD_DECL(fflush, int, (FILE *fp));
 DARSHAN_FORWARD_DECL(fwrite, size_t, (const void *ptr, size_t size, size_t nmemb, FILE *stream));
<span style="background: #ddffdd; color: #000000">+DARSHAN_FORWARD_DECL(fprintf, int, (FILE *stream, const char *format, ...));
+DARSHAN_FORWARD_DECL(vfprintf, int, (FILE *stream, const char *format, va_list));
</span> DARSHAN_FORWARD_DECL(fread, size_t, (void *ptr, size_t size, size_t nmemb, FILE *stream));
 DARSHAN_FORWARD_DECL(fgetc, int, (FILE *stream));
 DARSHAN_FORWARD_DECL(getw, int, (FILE *stream));
<span style="color: #aaaaaa">@@ -417,6 +419,59 @@ size_t DARSHAN_DECL(fwrite)(const void *ptr, size_t size, size_t nmemb, FILE *st
</span>     return(ret);
 }
 
<span style="background: #ddffdd; color: #000000">+int DARSHAN_DECL(vfprintf)(FILE *stream, const char *format, va_list ap)
+{
+    int ret;
+    double tm1, tm2;
+    long start_off, end_off;
+
+    MAP_OR_FAIL(vfprintf);
+
+    tm1 = darshan_core_wtime();
+    start_off = ftell(stream);
+    ret = __real_vfprintf(stream, format, ap);
+    end_off = ftell(stream);
+    tm2 = darshan_core_wtime();
+
+    STDIO_LOCK();
+    stdio_runtime_initialize();
+    if(ret > 0)
+        STDIO_RECORD_WRITE(stream, (end_off-start_off), tm1, tm2, 0);
+    STDIO_UNLOCK();
+
+    return(ret);
+}
+
+
+int DARSHAN_DECL(fprintf)(FILE *stream, const char *format, ...)
+{
+    int ret;
+    double tm1, tm2;
+    va_list ap;
+    long start_off, end_off;
+
+    MAP_OR_FAIL(vfprintf);
+
+    tm1 = darshan_core_wtime();
+    /* NOTE: we intentionally switch to vfprintf here to handle the variable
+     * length arguments.
+     */
+    start_off = ftell(stream);
+    va_start(ap, format);
+    ret = __real_vfprintf(stream, format, ap);
+    va_end(ap);
+    end_off = ftell(stream);
+    tm2 = darshan_core_wtime();
+
+    STDIO_LOCK();
+    stdio_runtime_initialize();
+    if(ret > 0)
+        STDIO_RECORD_WRITE(stream, (end_off-start_off), tm1, tm2, 0);
+    STDIO_UNLOCK();
+
+    return(ret);
+}
+
</span> size_t DARSHAN_DECL(fread)(void *ptr, size_t size, size_t nmemb, FILE *stream)
 {
     size_t ret;
<span style="color: #aaaaaa">@@ -522,7 +577,7 @@ int DARSHAN_DECL(fscanf)(FILE *stream, const char *format, ...)
</span>     STDIO_LOCK();
     stdio_runtime_initialize();
     if(ret != 0)
<span style="background: #ffdddd; color: #000000">-        STDIO_RECORD_READ(stream, end_off-start_off, tm1, tm2);
</span><span style="background: #ddffdd; color: #000000">+        STDIO_RECORD_READ(stream, (end_off-start_off), tm1, tm2);
</span>     STDIO_UNLOCK();
 
     return(ret);
</code></pre>

<br>
</li>
<li id="ad29afc395839758d41094872298bd0d">
<a href="https://xgitlab.cels.anl.gov/darshan/darshan/commit/c2a087402c0e0c646034d51ab69866710180c0aa#diff-1">
<strong>
darshan-runtime/share/ld-opts/darshan-stdio-ld-opts
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="background: #ffdddd; color: #000000">--- a/darshan-runtime/share/ld-opts/darshan-stdio-ld-opts
</span><span style="background: #ddffdd; color: #000000">+++ b/darshan-runtime/share/ld-opts/darshan-stdio-ld-opts
</span><span style="color: #aaaaaa">@@ -14,3 +14,5 @@
</span> --wrap=getw
 --wrap=fgets
 --wrap=fseek
<span style="background: #ddffdd; color: #000000">+--wrap=fprintf
+--wrap=vfprintf
</span></code></pre>

<br>
</li>

</div>
<div class="footer" style="margin-top: 10px">
<p style="color: #777; font-size: small">

<br>
<a href="https://xgitlab.cels.anl.gov/darshan/darshan/commit/c2a087402c0e0c646034d51ab69866710180c0aa">View it on GitLab</a>.
<br>
You're receiving this email because of your account on xgitlab.cels.anl.gov.
If you'd like to receive fewer emails, you can
adjust your notification settings.

</p>
</div>
</body>
</html>