[Darshan-commits] [Git][darshan/darshan][dev-stdio] fsetpos and fsetpos64 wrappers

Philip Carns xgitlab at cels.anl.gov
Mon May 23 22:24:28 CDT 2016


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


Commits:
0289d4ab by Phil Carns at 2016-05-23T23:24:12-04:00
fsetpos and fsetpos64 wrappers

- - - - -


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
@@ -62,8 +62,8 @@
  * int      fseek(FILE *, long int, int);                   DONE
  * int      fseeko(FILE *, off_t, int);                     DONE
  * int      fseeko64(FILE *, off_t, int);                   DONE
- * int      fsetpos(FILE *, const fpos_t *);
- * int      fsetpos64(FILE *, const fpos_t *);
+ * int      fsetpos(FILE *, const fpos_t *);                DONE
+ * int      fsetpos64(FILE *, const fpos_t *);              DONE
  * void     rewind(FILE *);
  * int      ungetc(int, FILE *);
  *
@@ -123,6 +123,8 @@ DARSHAN_FORWARD_DECL(fgets, char*, (char *s, int size, FILE *stream));
 DARSHAN_FORWARD_DECL(fseek, int, (FILE *stream, long offset, int whence));
 DARSHAN_FORWARD_DECL(fseeko, int, (FILE *stream, off_t offset, int whence));
 DARSHAN_FORWARD_DECL(fseeko64, int, (FILE *stream, off_t offset, int whence));
+DARSHAN_FORWARD_DECL(fsetpos, int, (FILE *stream, const fpos_t *pos));
+DARSHAN_FORWARD_DECL(fsetpos64, int, (FILE *stream, const fpos_t *pos));
 
 /* The stdio_file_runtime structure maintains necessary runtime metadata
  * for the STDIO file record (darshan_stdio_record structure, defined in
@@ -835,6 +837,69 @@ int DARSHAN_DECL(fseeko64)(FILE *stream, off_t offset, int whence)
     return(ret);
 }
 
+int DARSHAN_DECL(fsetpos)(FILE *stream, const fpos_t *pos)
+{
+    int ret;
+    struct stdio_file_runtime* file;
+    double tm1, tm2;
+
+    MAP_OR_FAIL(fsetpos);
+
+    tm1 = darshan_core_wtime();
+    ret = __real_fsetpos(stream, pos);
+    tm2 = darshan_core_wtime();
+
+    if(ret >= 0)
+    {
+        STDIO_LOCK();
+        stdio_runtime_initialize();
+        file = stdio_file_by_stream(stream);
+        if(file)
+        {
+            file->offset = ftell(stream);
+            DARSHAN_TIMER_INC_NO_OVERLAP(
+                file->file_record->fcounters[STDIO_F_META_TIME],
+                tm1, tm2, file->last_meta_end);
+            file->file_record->counters[STDIO_SEEKS] += 1;
+        }
+        STDIO_UNLOCK();
+    }
+
+    return(ret);
+}
+
+int DARSHAN_DECL(fsetpos64)(FILE *stream, const fpos_t *pos)
+{
+    int ret;
+    struct stdio_file_runtime* file;
+    double tm1, tm2;
+
+    MAP_OR_FAIL(fsetpos64);
+
+    tm1 = darshan_core_wtime();
+    ret = __real_fsetpos64(stream, pos);
+    tm2 = darshan_core_wtime();
+
+    if(ret >= 0)
+    {
+        STDIO_LOCK();
+        stdio_runtime_initialize();
+        file = stdio_file_by_stream(stream);
+        if(file)
+        {
+            file->offset = ftell(stream);
+            DARSHAN_TIMER_INC_NO_OVERLAP(
+                file->file_record->fcounters[STDIO_F_META_TIME],
+                tm1, tm2, file->last_meta_end);
+            file->file_record->counters[STDIO_SEEKS] += 1;
+        }
+        STDIO_UNLOCK();
+    }
+
+    return(ret);
+}
+
+
 /**********************************************************
  * Internal functions for manipulating STDIO module state *
  **********************************************************/


=====================================
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
@@ -23,3 +23,5 @@
 --wrap=fputc
 --wrap=fputs
 --wrap=putw
+--wrap=fsetpos
+--wrap=fsetpos64



View it on GitLab: https://xgitlab.cels.anl.gov/darshan/darshan/commit/0289d4ab80414e46aa0b467a3121ac111651af57
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/darshan-commits/attachments/20160523/56da48b5/attachment-0001.html>


More information about the Darshan-commits mailing list