From 4cdf8a06da2dc6bbaf4b19045d77f698ed972cff Mon Sep 17 00:00:00 2001 From: Phil Carns Date: Mon, 23 May 2016 20:53:18 -0400 Subject: [PATCH] fgetc wrapper --- darshan-runtime/lib/darshan-stdio.c | 23 ++++++++++++++++++- .../share/ld-opts/darshan-stdio-ld-opts | 1 + 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/darshan-runtime/lib/darshan-stdio.c b/darshan-runtime/lib/darshan-stdio.c index c548108..435930f 100644 --- a/darshan-runtime/lib/darshan-stdio.c +++ b/darshan-runtime/lib/darshan-stdio.c @@ -36,7 +36,7 @@ * * functions for reading data * -------------- - * int fgetc(FILE *); + * int fgetc(FILE *); DONE * char *fgets(char *, int, FILE *); * size_t fread(void *, size_t, size_t, FILE *); DONE * int fscanf(FILE *, const char *, ...); @@ -99,6 +99,7 @@ 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)); 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(fseek, int, (FILE *stream, long offset, int whence)); /* The stdio_file_runtime structure maintains necessary runtime metadata @@ -427,6 +428,26 @@ size_t DARSHAN_DECL(fread)(void *ptr, size_t size, size_t nmemb, FILE *stream) return(ret); } +size_t DARSHAN_DECL(fgetc)(FILE *stream) +{ + int ret; + double tm1, tm2; + + MAP_OR_FAIL(fgetc); + + tm1 = darshan_core_wtime(); + ret = __real_fgetc(stream); + tm2 = darshan_core_wtime(); + + STDIO_LOCK(); + stdio_runtime_initialize(); + if(ret != EOF) + STDIO_RECORD_READ(stream, 1, tm1, tm2); + STDIO_UNLOCK(); + + return(ret); +} + int DARSHAN_DECL(fseek)(FILE *stream, long offset, int whence) { int ret; diff --git a/darshan-runtime/share/ld-opts/darshan-stdio-ld-opts b/darshan-runtime/share/ld-opts/darshan-stdio-ld-opts index 01f036b..4459a95 100644 --- a/darshan-runtime/share/ld-opts/darshan-stdio-ld-opts +++ b/darshan-runtime/share/ld-opts/darshan-stdio-ld-opts @@ -7,4 +7,5 @@ --wrap=fclose --wrap=fwrite --wrap=fread +--wrap=fgetc --wrap=fseek -- 2.26.2