mirror of
https://github.com/AltraMayor/f3.git
synced 2025-08-03 18:46:00 -04:00
libflow: avoid types size_t and ssize_t in libflow.h
Those types are not included in libflow.h and including them is overwhelming.
This commit is contained in:
parent
099eb7fd42
commit
5ac9551d87
2
f3read.c
2
f3read.c
@ -192,7 +192,7 @@ static ssize_t read_all(int fd, char *buf, size_t count)
|
||||
}
|
||||
|
||||
static ssize_t check_chunk(int fd, uint64_t *p_expected_offset,
|
||||
size_t chunk_size, struct file_stats *stats)
|
||||
uint64_t chunk_size, struct file_stats *stats)
|
||||
{
|
||||
char buf[MAX_BUFFER_SIZE];
|
||||
ssize_t tot_bytes_read = 0;
|
||||
|
@ -203,7 +203,7 @@ static int create_and_fill_file(const char *path, long number, size_t size,
|
||||
remaining = size;
|
||||
start_measurement(fw);
|
||||
while (remaining > 0) {
|
||||
size_t write_size = get_rem_chunk_size(fw);
|
||||
uint64_t write_size = get_rem_chunk_size(fw);
|
||||
if (write_size > remaining)
|
||||
write_size = remaining;
|
||||
saved_errno = write_chunk(fd, write_size, &offset);
|
||||
|
@ -244,7 +244,7 @@ static inline uint64_t diff_timeval_us(const struct timeval *t1,
|
||||
t2->tv_usec - t1->tv_usec;
|
||||
}
|
||||
|
||||
int measure(int fd, struct flow *fw, ssize_t processed)
|
||||
int measure(int fd, struct flow *fw, long processed)
|
||||
{
|
||||
ldiv_t result = ldiv(processed, fw->block_size);
|
||||
struct timeval t2;
|
||||
|
10
libflow.h
10
libflow.h
@ -63,7 +63,7 @@ void init_flow(struct flow *fw, uint64_t total_size,
|
||||
flow_func_flush_chunk_t func_flush_chunk);
|
||||
|
||||
void start_measurement(struct flow *fw);
|
||||
int measure(int fd, struct flow *fw, ssize_t processed);
|
||||
int measure(int fd, struct flow *fw, long processed);
|
||||
int end_measurement(int fd, struct flow *fw);
|
||||
|
||||
static inline int has_enough_measurements(const struct flow *fw)
|
||||
@ -84,12 +84,10 @@ static inline double get_avg_speed(struct flow *fw)
|
||||
return get_avg_speed_given_time(fw, fw->measured_time_ms);
|
||||
}
|
||||
|
||||
static inline size_t get_rem_chunk_size(struct flow *fw)
|
||||
static inline uint64_t get_rem_chunk_size(struct flow *fw)
|
||||
{
|
||||
ssize_t ret = (fw->blocks_per_delay - fw->processed_blocks) *
|
||||
fw->block_size;
|
||||
assert(ret > 0);
|
||||
return ret;
|
||||
assert(fw->blocks_per_delay > fw->processed_blocks);
|
||||
return (fw->blocks_per_delay - fw->processed_blocks) * fw->block_size;
|
||||
}
|
||||
|
||||
#define MAX_BUFFER_SIZE (1<<21) /* 2MB */
|
||||
|
Loading…
x
Reference in New Issue
Block a user