Commit e025a97f authored by Philip Carns's avatar Philip Carns

freopen wrapper

parent 9930d72a
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
* -------------- * --------------
* FILE *fdopen(int, const char *); DONE * FILE *fdopen(int, const char *); DONE
* FILE *fopen(const char *, const char *); DONE * FILE *fopen(const char *, const char *); DONE
* FILE *freopen(const char *, const char *, FILE *); * FILE *freopen(const char *, const char *, FILE *); DONE
* *
* functions for closing streams * functions for closing streams
* -------------- * --------------
...@@ -94,6 +94,7 @@ ...@@ -94,6 +94,7 @@
DARSHAN_FORWARD_DECL(fopen, FILE*, (const char *path, const char *mode)); DARSHAN_FORWARD_DECL(fopen, FILE*, (const char *path, const char *mode));
DARSHAN_FORWARD_DECL(fopen64, FILE*, (const char *path, const char *mode)); DARSHAN_FORWARD_DECL(fopen64, FILE*, (const char *path, const char *mode));
DARSHAN_FORWARD_DECL(fdopen, FILE*, (int fd, const char *mode)); DARSHAN_FORWARD_DECL(fdopen, FILE*, (int fd, const char *mode));
DARSHAN_FORWARD_DECL(freopen, FILE*, (const char *path, const char *mode, FILE *stream));
DARSHAN_FORWARD_DECL(fclose, int, (FILE *fp)); 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(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(fread, size_t, (void *ptr, size_t size, size_t nmemb, FILE *stream));
...@@ -255,26 +256,26 @@ static void stdio_shutdown(void); ...@@ -255,26 +256,26 @@ static void stdio_shutdown(void);
DARSHAN_TIMER_INC_NO_OVERLAP(file->file_record->fcounters[STDIO_F_WRITE_TIME], __tm1, __tm2, file->last_write_end); \ DARSHAN_TIMER_INC_NO_OVERLAP(file->file_record->fcounters[STDIO_F_WRITE_TIME], __tm1, __tm2, file->last_write_end); \
} while(0) } while(0)
FILE* DARSHAN_DECL(fdopen)(int fd, const char *mode) FILE* DARSHAN_DECL(fopen)(const char *path, const char *mode)
{ {
FILE* ret; FILE* ret;
double tm1, tm2; double tm1, tm2;
MAP_OR_FAIL(fdopen); MAP_OR_FAIL(fopen);
tm1 = darshan_core_wtime(); tm1 = darshan_core_wtime();
ret = __real_fdopen(fd, mode); ret = __real_fopen(path, mode);
tm2 = darshan_core_wtime(); tm2 = darshan_core_wtime();
STDIO_LOCK(); STDIO_LOCK();
stdio_runtime_initialize(); stdio_runtime_initialize();
STDIO_RECORD_OPEN(ret, "UNKNOWN-FDOPEN", tm1, tm2); STDIO_RECORD_OPEN(ret, path, tm1, tm2);
STDIO_UNLOCK(); STDIO_UNLOCK();
return(ret); return(ret);
} }
FILE* DARSHAN_DECL(fopen)(const char *path, const char *mode) FILE* DARSHAN_DECL(fopen64)(const char *path, const char *mode)
{ {
FILE* ret; FILE* ret;
double tm1, tm2; double tm1, tm2;
...@@ -282,7 +283,7 @@ FILE* DARSHAN_DECL(fopen)(const char *path, const char *mode) ...@@ -282,7 +283,7 @@ FILE* DARSHAN_DECL(fopen)(const char *path, const char *mode)
MAP_OR_FAIL(fopen); MAP_OR_FAIL(fopen);
tm1 = darshan_core_wtime(); tm1 = darshan_core_wtime();
ret = __real_fopen(path, mode); ret = __real_fopen64(path, mode);
tm2 = darshan_core_wtime(); tm2 = darshan_core_wtime();
STDIO_LOCK(); STDIO_LOCK();
...@@ -293,15 +294,34 @@ FILE* DARSHAN_DECL(fopen)(const char *path, const char *mode) ...@@ -293,15 +294,34 @@ FILE* DARSHAN_DECL(fopen)(const char *path, const char *mode)
return(ret); return(ret);
} }
FILE* DARSHAN_DECL(fopen64)(const char *path, const char *mode) FILE* DARSHAN_DECL(fdopen)(int fd, const char *mode)
{ {
FILE* ret; FILE* ret;
double tm1, tm2; double tm1, tm2;
MAP_OR_FAIL(fopen); MAP_OR_FAIL(fdopen);
tm1 = darshan_core_wtime(); tm1 = darshan_core_wtime();
ret = __real_fopen64(path, mode); ret = __real_fdopen(fd, mode);
tm2 = darshan_core_wtime();
STDIO_LOCK();
stdio_runtime_initialize();
STDIO_RECORD_OPEN(ret, "UNKNOWN-FDOPEN", tm1, tm2);
STDIO_UNLOCK();
return(ret);
}
FILE* DARSHAN_DECL(freopen)(const char *path, const char *mode, FILE *stream)
{
FILE* ret;
double tm1, tm2;
MAP_OR_FAIL(freopen);
tm1 = darshan_core_wtime();
ret = __real_freopen(path, mode, stream);
tm2 = darshan_core_wtime(); tm2 = darshan_core_wtime();
STDIO_LOCK(); STDIO_LOCK();
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
--wrap=fopen --wrap=fopen
--wrap=fopen64 --wrap=fopen64
--wrap=fdopen --wrap=fdopen
--wrap=freopen
--wrap=fclose --wrap=fclose
--wrap=fwrite --wrap=fwrite
--wrap=fread --wrap=fread
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment