Rename crc functions to private namespace
Apparently we overlap with some gtk (?) crc32() functions, causing
ours to be called and subsequently crashing since the arguments
aren't the same.
Move everything to a fio_ protected namespace.
Signed-off-by: Jens Axboe <axboe@kernel.dk>
diff --git a/crc/crc16.c b/crc/crc16.c
index d9c4e49..f593f71 100644
--- a/crc/crc16.c
+++ b/crc/crc16.c
@@ -43,7 +43,7 @@
0x8201, 0x42C0, 0x4380, 0x8341, 0x4100, 0x81C1, 0x8081, 0x4040
};
-unsigned short crc16(const void *buffer, unsigned int len)
+unsigned short fio_crc16(const void *buffer, unsigned int len)
{
const unsigned char *cp = (const unsigned char *) buffer;
unsigned short crc = 0;
diff --git a/crc/crc16.h b/crc/crc16.h
index 6c078a4..433a7b1 100644
--- a/crc/crc16.h
+++ b/crc/crc16.h
@@ -17,7 +17,7 @@
extern unsigned short const crc16_table[256];
-extern unsigned short crc16(const void *buffer, unsigned int len);
+extern unsigned short fio_crc16(const void *buffer, unsigned int len);
static inline unsigned short crc16_byte(unsigned short crc,
const unsigned char data)
diff --git a/crc/crc32.c b/crc/crc32.c
index 4afed1a..657031d 100644
--- a/crc/crc32.c
+++ b/crc/crc32.c
@@ -73,7 +73,7 @@
0xA2F33668, 0xBCB4666D, 0xB8757BDA, 0xB5365D03, 0xB1F740B4
};
-uint32_t crc32(const void *buffer, unsigned long length)
+uint32_t fio_crc32(const void *buffer, unsigned long length)
{
const unsigned char *cp = (const unsigned char *) buffer;
uint32_t crc = 0;
diff --git a/crc/crc32.h b/crc/crc32.h
index d59a560..674057b 100644
--- a/crc/crc32.h
+++ b/crc/crc32.h
@@ -18,6 +18,6 @@
#ifndef CRC32_H
#define CRC32_H
-extern uint32_t crc32(const void * const, unsigned long);
+extern uint32_t fio_crc32(const void * const, unsigned long);
#endif
diff --git a/crc/crc32c.h b/crc/crc32c.h
index 46c1063..11bcf9c 100644
--- a/crc/crc32c.h
+++ b/crc/crc32c.h
@@ -33,7 +33,7 @@
}
#endif
-static inline uint32_t crc32c(unsigned char const *buf, unsigned long len)
+static inline uint32_t fio_crc32c(unsigned char const *buf, unsigned long len)
{
if (crc32c_intel_available)
return crc32c_intel(buf, len);
diff --git a/crc/crc64.c b/crc/crc64.c
index a61d432..bf24a97 100644
--- a/crc/crc64.c
+++ b/crc/crc64.c
@@ -92,7 +92,7 @@
0x29b7d047efec8728ULL
};
-unsigned long long crc64(const unsigned char *buffer, unsigned long length)
+unsigned long long fio_crc64(const unsigned char *buffer, unsigned long length)
{
unsigned long long crc = 0;
diff --git a/crc/crc64.h b/crc/crc64.h
index e4310c2..fe9cad3 100644
--- a/crc/crc64.h
+++ b/crc/crc64.h
@@ -1,6 +1,6 @@
#ifndef CRC64_H
#define CRC64_H
-unsigned long long crc64(const unsigned char *, unsigned long);
+unsigned long long fio_crc64(const unsigned char *, unsigned long);
#endif
diff --git a/crc/crc7.c b/crc/crc7.c
index 47aa332..bf7fd1c 100644
--- a/crc/crc7.c
+++ b/crc/crc7.c
@@ -43,7 +43,7 @@
0x46, 0x4f, 0x54, 0x5d, 0x62, 0x6b, 0x70, 0x79
};
-unsigned char crc7(const unsigned char *buffer, unsigned int len)
+unsigned char fio_crc7(const unsigned char *buffer, unsigned int len)
{
unsigned char crc = 0;
diff --git a/crc/crc7.h b/crc/crc7.h
index 6ff3cd8..5d5d188 100644
--- a/crc/crc7.h
+++ b/crc/crc7.h
@@ -8,6 +8,6 @@
return crc7_syndrome_table[(crc << 1) ^ data];
}
-extern unsigned char crc7(const unsigned char *buffer, unsigned int len);
+extern unsigned char fio_crc7(const unsigned char *buffer, unsigned int len);
#endif
diff --git a/crc/md5.c b/crc/md5.c
index 8f9adb2..0da85e4 100644
--- a/crc/md5.c
+++ b/crc/md5.c
@@ -88,7 +88,7 @@
hash[3] += d;
}
-void md5_init(struct md5_ctx *mctx)
+void fio_md5_init(struct fio_md5_ctx *mctx)
{
mctx->hash[0] = 0x67452301;
mctx->hash[1] = 0xefcdab89;
@@ -96,7 +96,8 @@
mctx->hash[3] = 0x10325476;
}
-void md5_update(struct md5_ctx *mctx, const uint8_t *data, unsigned int len)
+void fio_md5_update(struct fio_md5_ctx *mctx, const uint8_t *data,
+ unsigned int len)
{
const uint32_t avail = sizeof(mctx->block) - (mctx->byte_count & 0x3f);
diff --git a/crc/md5.h b/crc/md5.h
index 6747d30..668f0e9 100644
--- a/crc/md5.h
+++ b/crc/md5.h
@@ -16,13 +16,13 @@
#define MD5STEP(f, w, x, y, z, in, s) \
(w += f(x, y, z) + in, w = (w<<s | w>>(32-s)) + x)
-struct md5_ctx {
+struct fio_md5_ctx {
uint32_t *hash;
uint32_t block[MD5_BLOCK_WORDS];
uint64_t byte_count;
};
-extern void md5_update(struct md5_ctx *, const uint8_t *, unsigned int);
-extern void md5_init(struct md5_ctx *);
+extern void fio_md5_update(struct fio_md5_ctx *, const uint8_t *, unsigned int);
+extern void fio_md5_init(struct fio_md5_ctx *);
#endif
diff --git a/crc/sha1.c b/crc/sha1.c
index 6206797..117fbd9 100644
--- a/crc/sha1.c
+++ b/crc/sha1.c
@@ -10,9 +10,9 @@
#include "sha1.h"
/* Hash one 64-byte block of data */
-static void blk_SHA1Block(struct sha1_ctx *ctx, const unsigned int *data);
+static void blk_SHA1Block(struct fio_sha1_ctx *ctx, const unsigned int *data);
-void sha1_init(struct sha1_ctx *ctx)
+void fio_sha1_init(struct fio_sha1_ctx *ctx)
{
ctx->size = 0;
@@ -25,7 +25,8 @@
ctx->H[4] = 0xc3d2e1f0;
}
-void sha1_update(struct sha1_ctx *ctx, const void *data, unsigned long len)
+void fio_sha1_update(struct fio_sha1_ctx *ctx, const void *data,
+ unsigned long len)
{
int lenW = ctx->size & 63;
@@ -54,7 +55,7 @@
memcpy(ctx->W, data, len);
}
-void sha1_final(unsigned char hashout[20], struct sha1_ctx *ctx)
+void fio_sha1_final(unsigned char hashout[20], struct fio_sha1_ctx *ctx)
{
static const unsigned char pad[64] = { 0x80 };
unsigned int padlen[2];
@@ -66,8 +67,8 @@
padlen[1] = htonl(ctx->size << 3);
i = ctx->size & 63;
- sha1_update(ctx, pad, 1+ (63 & (55 - i)));
- sha1_update(ctx, padlen, 8);
+ fio_sha1_update(ctx, pad, 1+ (63 & (55 - i)));
+ fio_sha1_update(ctx, padlen, 8);
/* Output hash
*/
@@ -111,7 +112,7 @@
#define T_40_59(t, A, B, C, D, E) SHA_ROUND(t, SHA_MIX, ((B&C)+(D&(B^C))) , 0x8f1bbcdc, A, B, C, D, E )
#define T_60_79(t, A, B, C, D, E) SHA_ROUND(t, SHA_MIX, (B^C^D) , 0xca62c1d6, A, B, C, D, E )
-static void blk_SHA1Block(struct sha1_ctx *ctx, const unsigned int *data)
+static void blk_SHA1Block(struct fio_sha1_ctx *ctx, const unsigned int *data)
{
unsigned int A,B,C,D,E;
unsigned int array[16];
diff --git a/crc/sha1.h b/crc/sha1.h
index af4165a..14af44a 100644
--- a/crc/sha1.h
+++ b/crc/sha1.h
@@ -7,14 +7,14 @@
* and to avoid unnecessary copies into the context array.
*/
-struct sha1_ctx {
+struct fio_sha1_ctx {
uint32_t *H;
unsigned int W[16];
unsigned long long size;
};
-void sha1_init(struct sha1_ctx *);
-void sha1_update(struct sha1_ctx *, const void *dataIn, unsigned long len);
-void sha1_final(unsigned char hashout[20], struct sha1_ctx *);
+void fio_sha1_init(struct fio_sha1_ctx *);
+void fio_sha1_update(struct fio_sha1_ctx *, const void *dataIn, unsigned long len);
+void fio_sha1_final(unsigned char hashout[20], struct fio_sha1_ctx *);
#endif
diff --git a/crc/sha256.c b/crc/sha256.c
index dcb1677..3a72a5b 100644
--- a/crc/sha256.c
+++ b/crc/sha256.c
@@ -227,7 +227,7 @@
memset(W, 0, 64 * sizeof(uint32_t));
}
-void sha256_init(struct sha256_ctx *sctx)
+void fio_sha256_init(struct fio_sha256_ctx *sctx)
{
sctx->state[0] = H0;
sctx->state[1] = H1;
@@ -240,8 +240,8 @@
sctx->count[0] = sctx->count[1] = 0;
}
-void sha256_update(struct sha256_ctx *sctx, const uint8_t *data,
- unsigned int len)
+void fio_sha256_update(struct fio_sha256_ctx *sctx, const uint8_t *data,
+ unsigned int len)
{
unsigned int i, idx, part_len;
diff --git a/crc/sha256.h b/crc/sha256.h
index a3ca0e6..c7aa28f 100644
--- a/crc/sha256.h
+++ b/crc/sha256.h
@@ -1,13 +1,13 @@
#ifndef FIO_SHA256_H
#define FIO_SHA256_H
-struct sha256_ctx {
+struct fio_sha256_ctx {
uint32_t count[2];
uint32_t state[8];
uint8_t *buf;
};
-void sha256_init(struct sha256_ctx *);
-void sha256_update(struct sha256_ctx *, const uint8_t *, unsigned int);
+void fio_sha256_init(struct fio_sha256_ctx *);
+void fio_sha256_update(struct fio_sha256_ctx *, const uint8_t *, unsigned int);
#endif
diff --git a/crc/sha512.c b/crc/sha512.c
index 9268a49..e069a44 100644
--- a/crc/sha512.c
+++ b/crc/sha512.c
@@ -146,7 +146,7 @@
a = b = c = d = e = f = g = h = t1 = t2 = 0;
}
-void sha512_init(struct sha512_ctx *sctx)
+void fio_sha512_init(struct fio_sha512_ctx *sctx)
{
sctx->state[0] = H0;
sctx->state[1] = H1;
@@ -159,8 +159,8 @@
sctx->count[0] = sctx->count[1] = sctx->count[2] = sctx->count[3] = 0;
}
-void sha512_update(struct sha512_ctx *sctx, const uint8_t *data,
- unsigned int len)
+void fio_sha512_update(struct fio_sha512_ctx *sctx, const uint8_t *data,
+ unsigned int len)
{
unsigned int i, idx, part_len;
diff --git a/crc/sha512.h b/crc/sha512.h
index 46e10cb..f8b2112 100644
--- a/crc/sha512.h
+++ b/crc/sha512.h
@@ -1,14 +1,14 @@
#ifndef FIO_SHA512_H
#define FIO_SHA512_H
-struct sha512_ctx {
+struct fio_sha512_ctx {
uint64_t state[8];
uint32_t count[4];
uint8_t *buf;
uint64_t W[80];
};
-void sha512_init(struct sha512_ctx *);
-void sha512_update(struct sha512_ctx *, const uint8_t *, unsigned int);
+void fio_sha512_init(struct fio_sha512_ctx *);
+void fio_sha512_update(struct fio_sha512_ctx *, const uint8_t *, unsigned int);
#endif
diff --git a/server.c b/server.c
index 84b106e..5e94696 100644
--- a/server.c
+++ b/server.c
@@ -124,7 +124,7 @@
cmd->cmd_crc16 = le16_to_cpu(cmd->cmd_crc16);
cmd->pdu_crc16 = le16_to_cpu(cmd->pdu_crc16);
- crc = crc16(cmd, FIO_NET_CMD_CRC_SZ);
+ crc = fio_crc16(cmd, FIO_NET_CMD_CRC_SZ);
if (crc != cmd->cmd_crc16) {
log_err("fio: server bad crc on command (got %x, wanted %x)\n",
cmd->cmd_crc16, crc);
@@ -202,7 +202,7 @@
break;
/* Verify payload crc */
- crc = crc16(pdu, cmd.pdu_len);
+ crc = fio_crc16(pdu, cmd.pdu_len);
if (crc != cmd.pdu_crc16) {
log_err("fio: server bad crc on payload ");
log_err("(got %x, wanted %x)\n", cmd.pdu_crc16, crc);
@@ -238,11 +238,11 @@
{
uint32_t pdu_len;
- cmd->cmd_crc16 = __cpu_to_le16(crc16(cmd, FIO_NET_CMD_CRC_SZ));
+ cmd->cmd_crc16 = __cpu_to_le16(fio_crc16(cmd, FIO_NET_CMD_CRC_SZ));
pdu_len = le32_to_cpu(cmd->pdu_len);
if (pdu_len)
- cmd->pdu_crc16 = __cpu_to_le16(crc16(cmd->payload, pdu_len));
+ cmd->pdu_crc16 = __cpu_to_le16(fio_crc16(cmd->payload, pdu_len));
}
int fio_net_send_cmd(int fd, uint16_t opcode, const void *buf, off_t size,
diff --git a/verify.c b/verify.c
index 0a504de..5621db2 100644
--- a/verify.c
+++ b/verify.c
@@ -389,14 +389,14 @@
void *p = io_u_verify_off(hdr, vc);
struct vhdr_sha512 *vh = hdr_priv(hdr);
uint8_t sha512[128];
- struct sha512_ctx sha512_ctx = {
+ struct fio_sha512_ctx sha512_ctx = {
.buf = sha512,
};
dprint(FD_VERIFY, "sha512 verify io_u %p, len %u\n", vc->io_u, hdr->len);
- sha512_init(&sha512_ctx);
- sha512_update(&sha512_ctx, p, hdr->len - hdr_size(hdr));
+ fio_sha512_init(&sha512_ctx);
+ fio_sha512_update(&sha512_ctx, p, hdr->len - hdr_size(hdr));
if (!memcmp(vh->sha512, sha512_ctx.buf, sizeof(sha512)))
return 0;
@@ -414,14 +414,14 @@
void *p = io_u_verify_off(hdr, vc);
struct vhdr_sha256 *vh = hdr_priv(hdr);
uint8_t sha256[64];
- struct sha256_ctx sha256_ctx = {
+ struct fio_sha256_ctx sha256_ctx = {
.buf = sha256,
};
dprint(FD_VERIFY, "sha256 verify io_u %p, len %u\n", vc->io_u, hdr->len);
- sha256_init(&sha256_ctx);
- sha256_update(&sha256_ctx, p, hdr->len - hdr_size(hdr));
+ fio_sha256_init(&sha256_ctx);
+ fio_sha256_update(&sha256_ctx, p, hdr->len - hdr_size(hdr));
if (!memcmp(vh->sha256, sha256_ctx.buf, sizeof(sha256)))
return 0;
@@ -439,14 +439,14 @@
void *p = io_u_verify_off(hdr, vc);
struct vhdr_sha1 *vh = hdr_priv(hdr);
uint32_t sha1[5];
- struct sha1_ctx sha1_ctx = {
+ struct fio_sha1_ctx sha1_ctx = {
.H = sha1,
};
dprint(FD_VERIFY, "sha1 verify io_u %p, len %u\n", vc->io_u, hdr->len);
- sha1_init(&sha1_ctx);
- sha1_update(&sha1_ctx, p, hdr->len - hdr_size(hdr));
+ fio_sha1_init(&sha1_ctx);
+ fio_sha1_update(&sha1_ctx, p, hdr->len - hdr_size(hdr));
if (!memcmp(vh->sha1, sha1_ctx.H, sizeof(sha1)))
return 0;
@@ -467,7 +467,7 @@
dprint(FD_VERIFY, "crc7 verify io_u %p, len %u\n", vc->io_u, hdr->len);
- c = crc7(p, hdr->len - hdr_size(hdr));
+ c = fio_crc7(p, hdr->len - hdr_size(hdr));
if (c == vh->crc7)
return 0;
@@ -488,7 +488,7 @@
dprint(FD_VERIFY, "crc16 verify io_u %p, len %u\n", vc->io_u, hdr->len);
- c = crc16(p, hdr->len - hdr_size(hdr));
+ c = fio_crc16(p, hdr->len - hdr_size(hdr));
if (c == vh->crc16)
return 0;
@@ -509,7 +509,7 @@
dprint(FD_VERIFY, "crc64 verify io_u %p, len %u\n", vc->io_u, hdr->len);
- c = crc64(p, hdr->len - hdr_size(hdr));
+ c = fio_crc64(p, hdr->len - hdr_size(hdr));
if (c == vh->crc64)
return 0;
@@ -530,7 +530,7 @@
dprint(FD_VERIFY, "crc32 verify io_u %p, len %u\n", vc->io_u, hdr->len);
- c = crc32(p, hdr->len - hdr_size(hdr));
+ c = fio_crc32(p, hdr->len - hdr_size(hdr));
if (c == vh->crc32)
return 0;
@@ -551,7 +551,7 @@
dprint(FD_VERIFY, "crc32c verify io_u %p, len %u\n", vc->io_u, hdr->len);
- c = crc32c(p, hdr->len - hdr_size(hdr));
+ c = fio_crc32c(p, hdr->len - hdr_size(hdr));
if (c == vh->crc32)
return 0;
@@ -569,14 +569,14 @@
void *p = io_u_verify_off(hdr, vc);
struct vhdr_md5 *vh = hdr_priv(hdr);
uint32_t hash[MD5_HASH_WORDS];
- struct md5_ctx md5_ctx = {
+ struct fio_md5_ctx md5_ctx = {
.hash = hash,
};
dprint(FD_VERIFY, "md5 verify io_u %p, len %u\n", vc->io_u, hdr->len);
- md5_init(&md5_ctx);
- md5_update(&md5_ctx, p, hdr->len - hdr_size(hdr));
+ fio_md5_init(&md5_ctx);
+ fio_md5_update(&md5_ctx, p, hdr->len - hdr_size(hdr));
if (!memcmp(vh->md5_digest, md5_ctx.hash, sizeof(hash)))
return 0;
@@ -654,7 +654,7 @@
if (hdr->magic != FIO_HDR_MAGIC)
return 0;
- crc = crc32c(p, offsetof(struct verify_header, crc32));
+ crc = fio_crc32c(p, offsetof(struct verify_header, crc32));
if (crc == hdr->crc32)
return 1;
@@ -770,80 +770,80 @@
static void fill_sha512(struct verify_header *hdr, void *p, unsigned int len)
{
struct vhdr_sha512 *vh = hdr_priv(hdr);
- struct sha512_ctx sha512_ctx = {
+ struct fio_sha512_ctx sha512_ctx = {
.buf = vh->sha512,
};
- sha512_init(&sha512_ctx);
- sha512_update(&sha512_ctx, p, len);
+ fio_sha512_init(&sha512_ctx);
+ fio_sha512_update(&sha512_ctx, p, len);
}
static void fill_sha256(struct verify_header *hdr, void *p, unsigned int len)
{
struct vhdr_sha256 *vh = hdr_priv(hdr);
- struct sha256_ctx sha256_ctx = {
+ struct fio_sha256_ctx sha256_ctx = {
.buf = vh->sha256,
};
- sha256_init(&sha256_ctx);
- sha256_update(&sha256_ctx, p, len);
+ fio_sha256_init(&sha256_ctx);
+ fio_sha256_update(&sha256_ctx, p, len);
}
static void fill_sha1(struct verify_header *hdr, void *p, unsigned int len)
{
struct vhdr_sha1 *vh = hdr_priv(hdr);
- struct sha1_ctx sha1_ctx = {
+ struct fio_sha1_ctx sha1_ctx = {
.H = vh->sha1,
};
- sha1_init(&sha1_ctx);
- sha1_update(&sha1_ctx, p, len);
+ fio_sha1_init(&sha1_ctx);
+ fio_sha1_update(&sha1_ctx, p, len);
}
static void fill_crc7(struct verify_header *hdr, void *p, unsigned int len)
{
struct vhdr_crc7 *vh = hdr_priv(hdr);
- vh->crc7 = crc7(p, len);
+ vh->crc7 = fio_crc7(p, len);
}
static void fill_crc16(struct verify_header *hdr, void *p, unsigned int len)
{
struct vhdr_crc16 *vh = hdr_priv(hdr);
- vh->crc16 = crc16(p, len);
+ vh->crc16 = fio_crc16(p, len);
}
static void fill_crc32(struct verify_header *hdr, void *p, unsigned int len)
{
struct vhdr_crc32 *vh = hdr_priv(hdr);
- vh->crc32 = crc32(p, len);
+ vh->crc32 = fio_crc32(p, len);
}
static void fill_crc32c(struct verify_header *hdr, void *p, unsigned int len)
{
struct vhdr_crc32 *vh = hdr_priv(hdr);
- vh->crc32 = crc32c(p, len);
+ vh->crc32 = fio_crc32c(p, len);
}
static void fill_crc64(struct verify_header *hdr, void *p, unsigned int len)
{
struct vhdr_crc64 *vh = hdr_priv(hdr);
- vh->crc64 = crc64(p, len);
+ vh->crc64 = fio_crc64(p, len);
}
static void fill_md5(struct verify_header *hdr, void *p, unsigned int len)
{
struct vhdr_md5 *vh = hdr_priv(hdr);
- struct md5_ctx md5_ctx = {
+ struct fio_md5_ctx md5_ctx = {
.hash = (uint32_t *) vh->md5_digest,
};
- md5_init(&md5_ctx);
- md5_update(&md5_ctx, p, len);
+ fio_md5_init(&md5_ctx);
+ fio_md5_update(&md5_ctx, p, len);
}
static void populate_hdr(struct thread_data *td, struct io_u *io_u,
@@ -859,7 +859,7 @@
hdr->verify_type = td->o.verify;
hdr->len = header_len;
hdr->rand_seed = io_u->rand_seed;
- hdr->crc32 = crc32c(p, offsetof(struct verify_header, crc32));
+ hdr->crc32 = fio_crc32c(p, offsetof(struct verify_header, crc32));
data_len = header_len - hdr_size(hdr);