[Darshan-commits] [Git][darshan/darshan][dev-stdio] fgets wrapper

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


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


Commits:
da08451f by Phil Carns at 2016-05-23T20:57:07-04:00
fgets 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
@@ -37,7 +37,7 @@
  * functions for reading data
  * --------------
  * int      fgetc(FILE *);                                  DONE
- * char    *fgets(char *, int, FILE *);
+ * char    *fgets(char *, int, FILE *);                     DONE
  * size_t   fread(void *, size_t, size_t, FILE *);          DONE
  * int      fscanf(FILE *, const char *, ...);
  * int      getc(FILE *);
@@ -100,6 +100,7 @@ DARSHAN_FORWARD_DECL(fflush, 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(fgetc, int, (FILE *stream));
+DARSHAN_FORWARD_DECL(fgets, char*, (char *s, int size, FILE *stream));
 DARSHAN_FORWARD_DECL(fseek, int, (FILE *stream, long offset, int whence));
 
 /* The stdio_file_runtime structure maintains necessary runtime metadata
@@ -448,6 +449,27 @@ size_t DARSHAN_DECL(fgetc)(FILE *stream)
     return(ret);
 }
 
+char* DARSHAN_DECL(fgets)(char *s, int size, FILE *stream)
+{
+    char *ret;
+    double tm1, tm2;
+
+    MAP_OR_FAIL(fgets);
+
+    tm1 = darshan_core_wtime();
+    ret = __real_fgets(s, size, stream);
+    tm2 = darshan_core_wtime();
+
+    STDIO_LOCK();
+    stdio_runtime_initialize();
+    if(ret != NULL)
+        STDIO_RECORD_READ(stream, strlen(ret), tm1, tm2);
+    STDIO_UNLOCK();
+
+    return(ret);
+}
+
+
 int DARSHAN_DECL(fseek)(FILE *stream, long offset, int whence)
 {
     int ret;


=====================================
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
@@ -8,4 +8,5 @@
 --wrap=fwrite
 --wrap=fread
 --wrap=fgetc
+--wrap=fgets
 --wrap=fseek



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


More information about the Darshan-commits mailing list