Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Shane Snyder
darshan
Commits
91092ee1
Commit
91092ee1
authored
May 01, 2016
by
Philip Carns
Browse files
move fseek wrapper to stdio module
parent
da685755
Changes
7
Hide whitespace changes
Inline
Side-by-side
darshan-runtime/lib/darshan-posix.c
View file @
91092ee1
...
...
@@ -57,7 +57,6 @@ DARSHAN_FORWARD_DECL(readv, ssize_t, (int fd, const struct iovec *iov, int iovcn
DARSHAN_FORWARD_DECL
(
writev
,
ssize_t
,
(
int
fd
,
const
struct
iovec
*
iov
,
int
iovcnt
));
DARSHAN_FORWARD_DECL
(
lseek
,
off_t
,
(
int
fd
,
off_t
offset
,
int
whence
));
DARSHAN_FORWARD_DECL
(
lseek64
,
off64_t
,
(
int
fd
,
off64_t
offset
,
int
whence
));
DARSHAN_FORWARD_DECL
(
fseek
,
int
,
(
FILE
*
stream
,
long
offset
,
int
whence
));
DARSHAN_FORWARD_DECL
(
__xstat
,
int
,
(
int
vers
,
const
char
*
path
,
struct
stat
*
buf
));
DARSHAN_FORWARD_DECL
(
__xstat64
,
int
,
(
int
vers
,
const
char
*
path
,
struct
stat64
*
buf
));
DARSHAN_FORWARD_DECL
(
__lxstat
,
int
,
(
int
vers
,
const
char
*
path
,
struct
stat
*
buf
));
...
...
@@ -787,37 +786,6 @@ off_t DARSHAN_DECL(lseek64)(int fd, off_t offset, int whence)
return
(
ret
);
}
int
DARSHAN_DECL
(
fseek
)(
FILE
*
stream
,
long
offset
,
int
whence
)
{
int
ret
;
struct
posix_file_runtime
*
file
;
double
tm1
,
tm2
;
MAP_OR_FAIL
(
fseek
);
tm1
=
darshan_core_wtime
();
ret
=
__real_fseek
(
stream
,
offset
,
whence
);
tm2
=
darshan_core_wtime
();
if
(
ret
>=
0
)
{
POSIX_LOCK
();
posix_runtime_initialize
();
file
=
posix_file_by_fd
(
fileno
(
stream
));
if
(
file
)
{
file
->
offset
=
ftell
(
stream
);
DARSHAN_TIMER_INC_NO_OVERLAP
(
file
->
file_record
->
fcounters
[
POSIX_F_META_TIME
],
tm1
,
tm2
,
file
->
last_meta_end
);
file
->
file_record
->
counters
[
POSIX_FSEEKS
]
+=
1
;
}
POSIX_UNLOCK
();
}
return
(
ret
);
}
int
DARSHAN_DECL
(
__xstat
)(
int
vers
,
const
char
*
path
,
struct
stat
*
buf
)
{
int
ret
;
...
...
darshan-runtime/lib/darshan-stdio.c
View file @
91092ee1
...
...
@@ -36,6 +36,7 @@ DARSHAN_FORWARD_DECL(fopen64, FILE*, (const char *path, const char *mode));
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
(
fread
,
size_t
,
(
void
*
ptr
,
size_t
size
,
size_t
nmemb
,
FILE
*
stream
));
DARSHAN_FORWARD_DECL
(
fseek
,
int
,
(
FILE
*
stream
,
long
offset
,
int
whence
));
/* The stdio_file_runtime structure maintains necessary runtime metadata
* for the STDIO file record (darshan_stdio_record structure, defined in
...
...
@@ -306,6 +307,37 @@ size_t DARSHAN_DECL(fread)(void *ptr, size_t size, size_t nmemb, FILE *stream)
return
(
ret
);
}
int
DARSHAN_DECL
(
fseek
)(
FILE
*
stream
,
long
offset
,
int
whence
)
{
int
ret
;
struct
stdio_file_runtime
*
file
;
double
tm1
,
tm2
;
MAP_OR_FAIL
(
fseek
);
tm1
=
darshan_core_wtime
();
ret
=
__real_fseek
(
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 *
**********************************************************/
...
...
darshan-runtime/share/ld-opts/darshan-posix-ld-opts
View file @
91092ee1
...
...
@@ -16,7 +16,6 @@
--wrap=writev
--wrap=lseek
--wrap=lseek64
--wrap=fseek
--wrap=__xstat
--wrap=__xstat64
--wrap=__lxstat
...
...
darshan-runtime/share/ld-opts/darshan-stdio-ld-opts
View file @
91092ee1
...
...
@@ -4,3 +4,4 @@
--wrap=fclose
--wrap=fwrite
--wrap=fread
--wrap=fseek
darshan-stdio-log-format.h
View file @
91092ee1
...
...
@@ -48,7 +48,7 @@
*
* functions for changing file position
* --------------
* int fseek(FILE *, long int, int);
* int fseek(FILE *, long int, int);
DONE
* int fseeko(FILE *, off_t, int);
* int fsetpos(FILE *, const fpos_t *);
* void rewind(FILE *);
...
...
@@ -64,12 +64,14 @@
X(STDIO_BYTES_WRITTEN) \
/* number of writes */
\
X(STDIO_WRITES) \
/* maximum byte (offset)
written
*/
\
/* maximum byte (offset)
read
*/
\
X(STDIO_MAX_BYTE_READ) \
/* total bytes
written
*/
\
/* total bytes
read
*/
\
X(STDIO_BYTES_READ) \
/* number of
write
s */
\
/* number of
read
s */
\
X(STDIO_READS) \
/* count of seeks */
\
X(STDIO_SEEKS) \
/* end of counters */
\
X(STDIO_NUM_INDICES)
...
...
darshan-test/regression/test-cases/stdio-test.sh
View file @
91092ee1
...
...
@@ -33,12 +33,18 @@ fi
# check results
# in this case we want to confirm that the STDIO counters were triggered
# check at least one counter from each general open/read/write/seek category
STDIO_OPENS
=
`
grep
STDIO_OPENS
$DARSHAN_TMP
/
${
PROG
}
.darshan.txt |head
-n
1 |cut
-f
5
`
if
[
!
"
$STDIO_OPENS
"
-gt
0
]
;
then
echo
"Error: STDIO open count of
$STDIO_OPENS
is incorrect"
1>&2
exit
1
fi
STDIO_SEEKS
=
`
grep
STDIO_SEEKS
$DARSHAN_TMP
/
${
PROG
}
.darshan.txt |head
-n
1 |cut
-f
5
`
if
[
!
"
$STDIO_SEEKS
"
-gt
0
]
;
then
echo
"Error: STDIO open count of
$STDIO_SEEKS
is incorrect"
1>&2
exit
1
fi
STDIO_BYTES_WRITTEN
=
`
grep
STDIO_BYTES_WRITTEN
$DARSHAN_TMP
/
${
PROG
}
.darshan.txt |head
-n
1 |cut
-f
5
`
if
[
!
"
$STDIO_BYTES_WRITTEN
"
-eq
6
]
;
then
echo
"Error: STDIO open count of
$STDIO_BYTES_WRITTEN
is incorrect"
1>&2
...
...
darshan-util/darshan-stdio-logutils.c
View file @
91092ee1
...
...
@@ -143,7 +143,7 @@ static void darshan_log_print_stdio_record(void *file_rec, char *file_name,
static
void
darshan_log_print_stdio_description
()
{
printf
(
"
\n
# description of STDIO counters:
\n
"
);
printf
(
"# STDIO_{OPENS|WRITES|READS} are types of operations.
\n
"
);
printf
(
"# STDIO_{OPENS|WRITES|READS
|SEEKS
} are types of operations.
\n
"
);
printf
(
"# STDIO_BYTES_*: total bytes read and written.
\n
"
);
printf
(
"# STDIO_MAX_BYTE_*: highest offset byte read and written.
\n
"
);
printf
(
"# STDIO_F_*_START_TIMESTAMP: timestamp of the first call to that type of function.
\n
"
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment