[Darshan-commits] [Git][darshan/darshan][dev-stdio] move fseek wrapper to stdio module

Philip Carns xgitlab at cels.anl.gov
Sun May 1 09:32:31 CDT 2016


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


Commits:
91092ee1 by Phil Carns at 2016-05-01T10:32:14-04:00
move fseek wrapper to stdio module

- - - - -


7 changed files:

- darshan-runtime/lib/darshan-posix.c
- darshan-runtime/lib/darshan-stdio.c
- darshan-runtime/share/ld-opts/darshan-posix-ld-opts
- darshan-runtime/share/ld-opts/darshan-stdio-ld-opts
- darshan-stdio-log-format.h
- darshan-test/regression/test-cases/stdio-test.sh
- darshan-util/darshan-stdio-logutils.c


Changes:

=====================================
darshan-runtime/lib/darshan-posix.c
=====================================
--- a/darshan-runtime/lib/darshan-posix.c
+++ b/darshan-runtime/lib/darshan-posix.c
@@ -57,7 +57,6 @@ DARSHAN_FORWARD_DECL(readv, ssize_t, (int fd, const struct iovec *iov, int iovcn
 DARSHAN_FORWARD_DECL(writev, ssize_t, (int fd, const struct iovec *iov, int iovcnt));
 DARSHAN_FORWARD_DECL(lseek, off_t, (int fd, off_t offset, int whence));
 DARSHAN_FORWARD_DECL(lseek64, off64_t, (int fd, off64_t offset, int whence));
-DARSHAN_FORWARD_DECL(fseek, int, (FILE *stream, long offset, int whence));
 DARSHAN_FORWARD_DECL(__xstat, int, (int vers, const char* path, struct stat *buf));
 DARSHAN_FORWARD_DECL(__xstat64, int, (int vers, const char* path, struct stat64 *buf));
 DARSHAN_FORWARD_DECL(__lxstat, int, (int vers, const char* path, struct stat *buf));
@@ -787,37 +786,6 @@ off_t DARSHAN_DECL(lseek64)(int fd, off_t offset, int whence)
     return(ret);
 }
 
-int DARSHAN_DECL(fseek)(FILE *stream, long offset, int whence)
-{
-    int ret;
-    struct posix_file_runtime* file;
-    double tm1, tm2;
-
-    MAP_OR_FAIL(fseek);
-
-    tm1 = darshan_core_wtime();
-    ret = __real_fseek(stream, offset, whence);
-    tm2 = darshan_core_wtime();
-
-    if(ret >= 0)
-    {
-        POSIX_LOCK();
-        posix_runtime_initialize();
-        file = posix_file_by_fd(fileno(stream));
-        if(file)
-        {
-            file->offset = ftell(stream);
-            DARSHAN_TIMER_INC_NO_OVERLAP(
-                file->file_record->fcounters[POSIX_F_META_TIME],
-                tm1, tm2, file->last_meta_end);
-            file->file_record->counters[POSIX_FSEEKS] += 1;
-        }
-        POSIX_UNLOCK();
-    }
-
-    return(ret);
-}
-
 int DARSHAN_DECL(__xstat)(int vers, const char *path, struct stat *buf)
 {
     int ret;


=====================================
darshan-runtime/lib/darshan-stdio.c
=====================================
--- a/darshan-runtime/lib/darshan-stdio.c
+++ b/darshan-runtime/lib/darshan-stdio.c
@@ -36,6 +36,7 @@ DARSHAN_FORWARD_DECL(fopen64, FILE*, (const char *path, const char *mode));
 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));
+DARSHAN_FORWARD_DECL(fseek, int, (FILE *stream, long offset, int whence));
 
 /* The stdio_file_runtime structure maintains necessary runtime metadata
  * for the STDIO file record (darshan_stdio_record structure, defined in
@@ -306,6 +307,37 @@ size_t DARSHAN_DECL(fread)(void *ptr, size_t size, size_t nmemb, FILE *stream)
     return(ret);
 }
 
+int DARSHAN_DECL(fseek)(FILE *stream, long offset, int whence)
+{
+    int ret;
+    struct stdio_file_runtime* file;
+    double tm1, tm2;
+
+    MAP_OR_FAIL(fseek);
+
+    tm1 = darshan_core_wtime();
+    ret = __real_fseek(stream, offset, whence);
+    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-posix-ld-opts
=====================================
--- a/darshan-runtime/share/ld-opts/darshan-posix-ld-opts
+++ b/darshan-runtime/share/ld-opts/darshan-posix-ld-opts
@@ -16,7 +16,6 @@
 --wrap=writev
 --wrap=lseek
 --wrap=lseek64
---wrap=fseek
 --wrap=__xstat
 --wrap=__xstat64
 --wrap=__lxstat


=====================================
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
@@ -4,3 +4,4 @@
 --wrap=fclose
 --wrap=fwrite
 --wrap=fread
+--wrap=fseek


=====================================
darshan-stdio-log-format.h
=====================================
--- a/darshan-stdio-log-format.h
+++ b/darshan-stdio-log-format.h
@@ -48,7 +48,7 @@
  *
  * functions for changing file position
  * --------------
- * int      fseek(FILE *, long int, int);
+ * int      fseek(FILE *, long int, int);                   DONE
  * int      fseeko(FILE *, off_t, int);
  * int      fsetpos(FILE *, const fpos_t *);
  * void     rewind(FILE *);
@@ -64,12 +64,14 @@
     X(STDIO_BYTES_WRITTEN) \
     /* number of writes */ \
     X(STDIO_WRITES) \
-    /* maximum byte (offset) written */\
+    /* maximum byte (offset) read */\
     X(STDIO_MAX_BYTE_READ) \
-    /* total bytes written */ \
+    /* total bytes read */ \
     X(STDIO_BYTES_READ) \
-    /* number of writes */ \
+    /* number of reads */ \
     X(STDIO_READS) \
+    /* count of seeks */\
+    X(STDIO_SEEKS) \
     /* end of counters */\
     X(STDIO_NUM_INDICES)
 


=====================================
darshan-test/regression/test-cases/stdio-test.sh
=====================================
--- a/darshan-test/regression/test-cases/stdio-test.sh
+++ b/darshan-test/regression/test-cases/stdio-test.sh
@@ -33,12 +33,18 @@ fi
 
 # check results
 
-# in this case we want to confirm that the STDIO counters were triggered
+# check at least one counter from each general open/read/write/seek category
+
 STDIO_OPENS=`grep STDIO_OPENS $DARSHAN_TMP/${PROG}.darshan.txt |head -n 1 |cut -f 5`
 if [ ! "$STDIO_OPENS" -gt 0 ]; then
     echo "Error: STDIO open count of $STDIO_OPENS is incorrect" 1>&2
     exit 1
 fi
+STDIO_SEEKS=`grep STDIO_SEEKS $DARSHAN_TMP/${PROG}.darshan.txt |head -n 1 |cut -f 5`
+if [ ! "$STDIO_SEEKS" -gt 0 ]; then
+    echo "Error: STDIO open count of $STDIO_SEEKS is incorrect" 1>&2
+    exit 1
+fi
 STDIO_BYTES_WRITTEN=`grep STDIO_BYTES_WRITTEN $DARSHAN_TMP/${PROG}.darshan.txt |head -n 1 |cut -f 5`
 if [ ! "$STDIO_BYTES_WRITTEN" -eq 6 ]; then
     echo "Error: STDIO open count of $STDIO_BYTES_WRITTEN is incorrect" 1>&2


=====================================
darshan-util/darshan-stdio-logutils.c
=====================================
--- a/darshan-util/darshan-stdio-logutils.c
+++ b/darshan-util/darshan-stdio-logutils.c
@@ -143,7 +143,7 @@ static void darshan_log_print_stdio_record(void *file_rec, char *file_name,
 static void darshan_log_print_stdio_description()
 {
     printf("\n# description of STDIO counters:\n");
-    printf("#   STDIO_{OPENS|WRITES|READS} are types of operations.\n");
+    printf("#   STDIO_{OPENS|WRITES|READS|SEEKS} are types of operations.\n");
     printf("#   STDIO_BYTES_*: total bytes read and written.\n");
     printf("#   STDIO_MAX_BYTE_*: highest offset byte read and written.\n");
     printf("#   STDIO_F_*_START_TIMESTAMP: timestamp of the first call to that type of function.\n");



View it on GitLab: https://xgitlab.cels.anl.gov/darshan/darshan/commit/91092ee14a7a54a97b6622602893ea05170a58c3
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/darshan-commits/attachments/20160501/7596dd90/attachment.html>


More information about the Darshan-commits mailing list