T_IEEE_PROGS = t/ieee754
T_ZIPF_OBS = t/genzipf.o
-T_ZIPF_OBJS += t/log.o lib/ieee754.o lib/rand.o lib/zipf.o lib/gauss.o t/genzipf.o
+T_ZIPF_OBJS += t/log.o lib/ieee754.o lib/rand.o lib/pattern.o lib/zipf.o \
+ lib/strntol.o lib/gauss.o t/genzipf.o
T_ZIPF_PROGS = t/fio-genzipf
T_AXMAP_OBJS = t/axmap.o
#include <string.h>
#include <assert.h>
#include "rand.h"
+#include "lib/pattern.h"
#include "../hash.h"
int arch_random;
return r;
}
-void fill_pattern(void *p, unsigned int len, char *pattern,
- unsigned int pattern_bytes)
-{
- switch (pattern_bytes) {
- case 0:
- assert(0);
- break;
- case 1:
- memset(p, pattern[0], len);
- break;
- default: {
- unsigned int i = 0, size = 0;
- unsigned char *b = p;
-
- while (i < len) {
- size = pattern_bytes;
- if (size > (len - i))
- size = len - i;
- memcpy(b+i, pattern, size);
- i += size;
- }
- break;
- }
- }
-}
-
void __fill_random_buf_percentage(unsigned long seed, void *buf,
unsigned int percentage,
unsigned int segment, unsigned int len,
if (percentage == 100) {
if (pbytes)
- fill_pattern(buf, len, pattern, pbytes);
+ (void)cpy_pattern(pattern, pbytes, buf, len);
else
memset(buf, 0, len);
return;
this_len = len;
if (pbytes)
- fill_pattern(buf, this_len, pattern, pbytes);
+ (void)cpy_pattern(pattern, pbytes, buf, this_len);
else
memset(buf, 0, this_len);
extern unsigned long fill_random_buf(struct frand_state *, void *buf, unsigned int len);
extern void __fill_random_buf_percentage(unsigned long, void *, unsigned int, unsigned int, unsigned int, char *, unsigned int);
extern unsigned long fill_random_buf_percentage(struct frand_state *, void *, unsigned int, unsigned int, unsigned int, char *, unsigned int);
-extern void fill_pattern(void *p, unsigned int len, char *pattern, unsigned int pattern_bytes);
#endif
#include "trim.h"
#include "lib/rand.h"
#include "lib/hweight.h"
+#include "lib/pattern.h"
#include "crc/md5.h"
#include "crc/crc64.h"
void fill_buffer_pattern(struct thread_data *td, void *p, unsigned int len)
{
- fill_pattern(p, len, td->o.buffer_pattern, td->o.buffer_pattern_bytes);
+ (void)cpy_pattern(td->o.buffer_pattern, td->o.buffer_pattern_bytes, p, len);
}
void __fill_buffer(struct thread_options *o, unsigned long seed, void *p,
return;
}
- fill_pattern(p, len, o->verify_pattern, o->verify_pattern_bytes);
+ (void)cpy_pattern(td->o.verify_pattern, td->o.verify_pattern_bytes, p, len);
io_u->buf_filled_len = len;
}