From 93a0e7a1ae18cf721646aa14fd55fa7f0321eb33 Mon Sep 17 00:00:00 2001 From: Phil Carns Date: Mon, 23 May 2016 23:20:13 -0400 Subject: [PATCH] fseeko64 wrapper --- darshan-runtime/lib/darshan-stdio.c | 34 ++++++++++++++++++- .../share/ld-opts/darshan-stdio-ld-opts | 1 + 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/darshan-runtime/lib/darshan-stdio.c b/darshan-runtime/lib/darshan-stdio.c index 2f7d143..5243696 100644 --- a/darshan-runtime/lib/darshan-stdio.c +++ b/darshan-runtime/lib/darshan-stdio.c @@ -61,7 +61,7 @@ * -------------- * int fseek(FILE *, long int, int); DONE * int fseeko(FILE *, off_t, int); DONE - * int fseeko64(FILE *, off_t, int); + * int fseeko64(FILE *, off_t, int); DONE * int fsetpos(FILE *, const fpos_t *); * int fsetpos64(FILE *, const fpos_t *); * void rewind(FILE *); @@ -122,6 +122,7 @@ DARSHAN_FORWARD_DECL(vfscanf, int, (FILE *stream, const char *format, va_list ap 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)); /* The stdio_file_runtime structure maintains necessary runtime metadata * for the STDIO file record (darshan_stdio_record structure, defined in @@ -803,6 +804,37 @@ int DARSHAN_DECL(fseeko)(FILE *stream, off_t offset, int whence) return(ret); } +int DARSHAN_DECL(fseeko64)(FILE *stream, off_t offset, int whence) +{ + int ret; + struct stdio_file_runtime* file; + double tm1, tm2; + + MAP_OR_FAIL(fseeko64); + + tm1 = darshan_core_wtime(); + ret = __real_fseeko64(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 * **********************************************************/ diff --git a/darshan-runtime/share/ld-opts/darshan-stdio-ld-opts b/darshan-runtime/share/ld-opts/darshan-stdio-ld-opts index 950e3dd..a8fc2a0 100644 --- a/darshan-runtime/share/ld-opts/darshan-stdio-ld-opts +++ b/darshan-runtime/share/ld-opts/darshan-stdio-ld-opts @@ -17,6 +17,7 @@ --wrap=fgets --wrap=fseek --wrap=fseeko +--wrap=fseeko64 --wrap=fprintf --wrap=vfprintf --wrap=fputc -- 2.26.2