mirror of
https://github.com/AFLplusplus/AFLplusplus.git
synced 2025-06-10 17:21:33 +00:00
code format
This commit is contained in:
parent
38e5c32a55
commit
8f19becb62
@ -880,7 +880,6 @@ void set_nonblocking(int fd) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Wrapper for select() and read(), reading exactly len bytes.
|
/* Wrapper for select() and read(), reading exactly len bytes.
|
||||||
Should be called on non-blocking fds.
|
Should be called on non-blocking fds.
|
||||||
Returns the time passed to read.
|
Returns the time passed to read.
|
||||||
@ -895,24 +894,24 @@ u32 read_timed(s32 fd, void *buf, size_t len, u32 timeout_ms,
|
|||||||
FD_ZERO(&readfds);
|
FD_ZERO(&readfds);
|
||||||
FD_SET(fd, &readfds);
|
FD_SET(fd, &readfds);
|
||||||
|
|
||||||
size_t read_total = 0;
|
size_t read_total = 0;
|
||||||
ssize_t len_read = 0;
|
ssize_t len_read = 0;
|
||||||
|
|
||||||
#if defined(__linux__)
|
#if defined(__linux__)
|
||||||
timeout.tv_sec = (timeout_ms / 1000);
|
timeout.tv_sec = (timeout_ms / 1000);
|
||||||
timeout.tv_usec = (timeout_ms % 1000) * 1000;
|
timeout.tv_usec = (timeout_ms % 1000) * 1000;
|
||||||
#else
|
#else
|
||||||
u64 time_start = get_cur_time_us();
|
u64 time_start = get_cur_time_us();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
while (read_total < len) {
|
while (read_total < len) {
|
||||||
|
|
||||||
#if !defined(__linux__)
|
#if !defined(__linux__)
|
||||||
u64 time_current = get_cur_time_us();
|
u64 time_current = get_cur_time_us();
|
||||||
u64 timeout_current = timeout_ms - (time_current - time_start);
|
u64 timeout_current = timeout_ms - (time_current - time_start);
|
||||||
timeout.tv_sec = (timeout_current / 1000);
|
timeout.tv_sec = (timeout_current / 1000);
|
||||||
timeout.tv_usec = (timeout_current % 1000) * 1000;
|
timeout.tv_usec = (timeout_current % 1000) * 1000;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* set exceptfds as well to return when a child exited/closed the pipe. */
|
/* set exceptfds as well to return when a child exited/closed the pipe. */
|
||||||
int sret = select(fd + 1, &readfds, NULL, NULL, &timeout);
|
int sret = select(fd + 1, &readfds, NULL, NULL, &timeout);
|
||||||
@ -936,13 +935,13 @@ u32 read_timed(s32 fd, void *buf, size_t len, u32 timeout_ms,
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__linux__)
|
#if defined(__linux__)
|
||||||
s32 exec_ms =
|
s32 exec_ms =
|
||||||
MIN(timeout_ms,
|
MIN(timeout_ms,
|
||||||
((u64)timeout_ms - (timeout.tv_sec * 1000 + timeout.tv_usec / 1000)));
|
((u64)timeout_ms - (timeout.tv_sec * 1000 + timeout.tv_usec / 1000)));
|
||||||
#else
|
#else
|
||||||
u32 exec_ms = get_cur_time_us() - time_start;
|
u32 exec_ms = get_cur_time_us() - time_start;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return exec_ms > 0 ? exec_ms
|
return exec_ms > 0 ? exec_ms
|
||||||
: 1; // at least 1 milli must have passed (0 is an error)
|
: 1; // at least 1 milli must have passed (0 is an error)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user