2013-04-29 14:50:42 +01:00
|
|
|
#ifndef PREFETCH_H
|
|
|
|
#define PREFETCH_H
|
|
|
|
|
2014-02-27 14:21:36 +00:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
|
2013-04-29 14:50:42 +01:00
|
|
|
#define PREFETCH_BUFSIZE 4096
|
|
|
|
|
|
|
|
struct prefetch {
|
2014-02-27 14:21:36 +00:00
|
|
|
/* True if there is data in the buffer. */
|
2013-04-29 14:50:42 +01:00
|
|
|
int is_full;
|
2014-02-27 14:21:36 +00:00
|
|
|
/* The start point of the current content of buffer */
|
|
|
|
uint64_t from;
|
|
|
|
/* The length of the current content of buffer */
|
|
|
|
uint32_t len;
|
|
|
|
|
|
|
|
/* The total size of the buffer, in bytes. */
|
|
|
|
size_t size;
|
2013-04-29 14:50:42 +01:00
|
|
|
|
2014-02-27 14:21:36 +00:00
|
|
|
char *buffer;
|
2013-04-29 14:50:42 +01:00
|
|
|
};
|
|
|
|
|
2014-02-27 14:21:36 +00:00
|
|
|
struct prefetch* prefetch_create( size_t size_bytes );
|
|
|
|
void prefetch_destroy( struct prefetch *prefetch );
|
|
|
|
size_t prefetch_size( struct prefetch *);
|
|
|
|
void prefetch_set_is_empty( struct prefetch *prefetch );
|
|
|
|
void prefetch_set_is_full( struct prefetch *prefetch );
|
|
|
|
void prefetch_set_full( struct prefetch *prefetch, int val );
|
|
|
|
int prefetch_is_full( struct prefetch *prefetch );
|
|
|
|
int prefetch_contains( struct prefetch *prefetch, uint64_t from, uint32_t len );
|
|
|
|
char *prefetch_offset( struct prefetch *prefetch, uint64_t from );
|
|
|
|
|
2013-04-29 14:50:42 +01:00
|
|
|
#endif
|