Commit 9930d72a authored by Philip Carns's avatar Philip Carns

fdopen wrapper

parent 11c80b44
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
* - POSIX_FREADS * - POSIX_FREADS
* - POSIX_FWRITES * - POSIX_FWRITES
* - POSIX_FSEEKS * - POSIX_FSEEKS
* - add regression test cases for all functions captured here
*/ */
/* catalog of stdio functions instrumented by this module /* catalog of stdio functions instrumented by this module
...@@ -22,7 +23,7 @@ ...@@ -22,7 +23,7 @@
* functions for opening streams * functions for opening streams
* -------------- * --------------
* FILE *fdopen(int, const char *); DONE * FILE *fdopen(int, const char *); DONE
* FILE *fopen(const char *, const char *); * FILE *fopen(const char *, const char *); DONE
* FILE *freopen(const char *, const char *, FILE *); * FILE *freopen(const char *, const char *, FILE *);
* *
* functions for closing streams * functions for closing streams
...@@ -92,6 +93,7 @@ ...@@ -92,6 +93,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(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));
...@@ -253,6 +255,25 @@ static void stdio_shutdown(void); ...@@ -253,6 +255,25 @@ 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* ret;
double tm1, tm2;
MAP_OR_FAIL(fdopen);
tm1 = darshan_core_wtime();
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(fopen)(const char *path, const char *mode) FILE* DARSHAN_DECL(fopen)(const char *path, const char *mode)
{ {
FILE* ret; FILE* ret;
......
--undefined=__wrap_fopen --undefined=__wrap_fopen
--wrap=fopen --wrap=fopen
--wrap=fopen64 --wrap=fopen64
--wrap=fdopen
--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