Commit 0b450025 authored by Rich Prohaska's avatar Rich Prohaska Committed by Yoni Fogel

use toku_htonl. closes #1247

git-svn-id: file:///svn/toku/tokudb.1032b@7850 c7de825b-a66e-492c-adef-691d508d4ae1
parent 9a42f8fa
......@@ -296,8 +296,8 @@ void toku_serialize_brtnode_to (int fd, BLOCKNUM blocknum, BRTNODE node, struct
if (0) printf("Block %" PRId64 " Size before compressing %u, after compression %lu\n", blocknum.b, calculated_size-uncompressed_magic_len, compressed_len);
((int32_t*)(compressed_buf+uncompressed_magic_len))[0] = htonl(compressed_len);
((int32_t*)(compressed_buf+uncompressed_magic_len))[1] = htonl(uncompressed_len);
((int32_t*)(compressed_buf+uncompressed_magic_len))[0] = toku_htonl(compressed_len);
((int32_t*)(compressed_buf+uncompressed_magic_len))[1] = toku_htonl(uncompressed_len);
//write_now: printf("%s:%d Writing %d bytes\n", __FILE__, __LINE__, w.ndone);
{
......@@ -352,15 +352,15 @@ int toku_deserialize_brtnode_from (int fd, BLOCKNUM blocknum, u_int32_t fullhash
{
// get the compressed size
r = pread(fd, uncompressed_header, sizeof(uncompressed_header), offset);
//printf("%s:%d r=%d the datasize=%d\n", __FILE__, __LINE__, r, ntohl(datasize_n));
//printf("%s:%d r=%d the datasize=%d\n", __FILE__, __LINE__, r, toku_ntohl(datasize_n));
if (r!=(int)sizeof(uncompressed_header)) {
if (r==-1) r=errno;
else r = DB_BADFORMAT;
goto died0;
}
compressed_size = ntohl(*(u_int32_t*)(&uncompressed_header[uncompressed_magic_len]));
compressed_size = toku_ntohl(*(u_int32_t*)(&uncompressed_header[uncompressed_magic_len]));
if (compressed_size<=0 || compressed_size>(1<<30)) { r = DB_BADFORMAT; goto died0; }
uncompressed_size = ntohl(*(u_int32_t*)(&uncompressed_header[uncompressed_magic_len+4]));
uncompressed_size = toku_ntohl(*(u_int32_t*)(&uncompressed_header[uncompressed_magic_len+4]));
if (0) printf("Block %" PRId64 " Compressed size = %u, uncompressed size=%u\n", blocknum.b, compressed_size, uncompressed_size);
if (uncompressed_size<=0 || uncompressed_size>(1<<30)) { r = DB_BADFORMAT; goto died0; }
}
......@@ -767,7 +767,7 @@ deserialize_brtheader (u_int32_t size, int fd, DISKOFF off, struct brt_header **
u_int32_t x1764 = x1764_memory(tbuf, h->block_translation_size_on_disk - 4);
u_int64_t offset = h->block_translation_size_on_disk - 4;
//printf("%s:%d read from %ld (x1764 offset=%ld) size=%ld\n", __FILE__, __LINE__, h->block_translation_address_on_disk, offset, h->block_translation_size_on_disk);
u_int32_t stored_x1764 = ntohl(*(int*)(tbuf + offset));
u_int32_t stored_x1764 = toku_ntohl(*(int*)(tbuf + offset));
assert(x1764 == stored_x1764);
}
// now read all that data.
......@@ -838,7 +838,7 @@ int toku_deserialize_brtheader_from (int fd, BLOCKNUM blocknum, struct brt_heade
if (r!=12) return EINVAL;
assert(memcmp(magic,"tokudata",8)==0);
// It's version 7 or later, and the magi clooks OK
return deserialize_brtheader(ntohl(*(int*)(&magic[8])), fd, offset, brth);
return deserialize_brtheader(toku_ntohl(*(int*)(&magic[8])), fd, offset, brth);
}
unsigned int toku_brt_pivot_key_len (BRT brt, struct kv_pair *pk) {
......@@ -907,7 +907,7 @@ read_int (int fd, toku_off_t *at, u_int32_t *result) {
ssize_t r = pread(fd, &v, 4, *at);
if (r<0) return errno;
assert(r==4);
*result = ntohl(v);
*result = toku_ntohl(v);
(*at) += 4;
return 0;
}
......
......@@ -4164,7 +4164,7 @@ toku_dump_brtnode (FILE *file, BRT brt, BLOCKNUM blocknum, int depth, bytevec lo
FIFO_ITERATE(BNC_BUFFER(node,i), key, keylen, data, datalen, type, xid,
{
data=data; datalen=datalen; keylen=keylen;
fprintf(file, "%*s xid=%"PRIu64" %u (type=%d)\n", depth+2, "", xid, (unsigned)ntohl(*(int*)key), type);
fprintf(file, "%*s xid=%"PRIu64" %u (type=%d)\n", depth+2, "", xid, (unsigned)toku_ntohl(*(int*)key), type);
//assert(strlen((char*)key)+1==keylen);
//assert(strlen((char*)data)+1==datalen);
});
......@@ -4172,7 +4172,7 @@ toku_dump_brtnode (FILE *file, BRT brt, BLOCKNUM blocknum, int depth, bytevec lo
for (i=0; i<node->u.n.n_children; i++) {
fprintf(file, "%*schild %d\n", depth, "", i);
if (i>0) {
fprintf(file, "%*spivot %d len=%u %u\n", depth+1, "", i-1, node->u.n.childkeys[i-1]->keylen, (unsigned)ntohl(*(int*)&node->u.n.childkeys[i-1]->key));
fprintf(file, "%*spivot %d len=%u %u\n", depth+1, "", i-1, node->u.n.childkeys[i-1]->keylen, (unsigned)toku_ntohl(*(int*)&node->u.n.childkeys[i-1]->key));
}
toku_dump_brtnode(file, brt, BNC_BLOCKNUM(node, i), depth+4,
(i==0) ? lorange : node->u.n.childkeys[i-1]->key,
......
......@@ -6,10 +6,10 @@
// Calculate the fingerprint for a kvpair
static void toku_calc_more_murmur_kvpair (struct x1764 *mm, const void *key, int keylen, const void *val, int vallen) {
int i;
i = htonl(keylen);
i = toku_htonl(keylen);
x1764_add(mm, (void*)&i, 4);
x1764_add(mm, key, keylen);
i = htonl(vallen);
i = toku_htonl(vallen);
x1764_add(mm, (void*)&i, 4);
x1764_add(mm, val, vallen);
}
......@@ -27,8 +27,8 @@ u_int32_t toku_calccrc32_kvpair_struct (const struct kv_pair *kvp) {
u_int32_t toku_calc_fingerprint_cmd (u_int32_t type, TXNID xid, const void *key, u_int32_t keylen, const void *val, u_int32_t vallen) {
unsigned char type_c = (unsigned char)type;
unsigned int a = htonl(xid>>32);
unsigned int b = htonl(xid&0xffffffff);
unsigned int a = toku_htonl(xid>>32);
unsigned int b = toku_htonl(xid&0xffffffff);
struct x1764 mm;
x1764_init(&mm);
x1764_add(&mm, &type_c, 1);
......
......@@ -54,7 +54,7 @@ static inline enum le_state get_le_state(LEAFENTRY le) {
static inline void putint (unsigned char *p, u_int32_t i) {
#if 1
*(u_int32_t*)p = htonl(i);
*(u_int32_t*)p = toku_htonl(i);
#else
p[0]=(i>>24)&0xff;
p[1]=(i>>16)&0xff;
......@@ -68,7 +68,7 @@ static inline void putint64 (unsigned char *p, u_int64_t i) {
}
static inline u_int32_t getint (unsigned char *p) {
#if 1
return ntohl(*(u_int32_t*)p);
return toku_ntohl(*(u_int32_t*)p);
#else
return (p[0]<<24)+(p[1]<<16)+(p[2]<<8)+(p[3]);
#endif
......
......@@ -144,7 +144,7 @@ static int open_logfile (TOKULOGGER logger) {
if (logger->fd==-1) return errno;
}
logger->next_log_file_number++;
int version_l = htonl(log_format_version);
int version_l = toku_htonl(log_format_version);
r = write_it(logger->fd, "tokulogg", 8); if (r!=8) return errno;
r = write_it(logger->fd, &version_l, 4); if (r!=4) return errno;
logger->fsynced_lsn = logger->written_lsn;
......@@ -780,8 +780,8 @@ int toku_read_and_print_logmagic (FILE *f, u_int32_t *versionp) {
if (r!=4) {
return DB_BADFORMAT;
}
//printf("tokulog v.%d\n", ntohl(version));
*versionp=ntohl(version);
//printf("tokulog v.%d\n", toku_ntohl(version));
*versionp=toku_ntohl(version);
}
return 0;
}
......@@ -1004,7 +1004,7 @@ int toku_maybe_spill_rollbacks (TOKUTXN txn) {
int toku_read_rollback_backwards(BREAD br, struct roll_entry **item, MEMARENA ma) {
u_int32_t nbytes_n; ssize_t sr;
if ((sr=bread_backwards(br, &nbytes_n, 4))!=4) { assert(sr<0); return errno; }
u_int32_t n_bytes=ntohl(nbytes_n);
u_int32_t n_bytes=toku_ntohl(nbytes_n);
unsigned char *buf = malloc_in_memarena(ma, n_bytes);
if (buf==0) return errno;
if ((sr=bread_backwards(br, buf, n_bytes-4))!=(ssize_t)n_bytes-4) { assert(sr<0); return errno; }
......
......@@ -28,7 +28,7 @@ test (int seed) {
assert(fd>=0);
for (i=0; i<RECORDS; i++) {
sizes[i] = random()%100;
sizesn[i] = htonl(sizes[i]);
sizesn[i] = toku_htonl(sizes[i]);
int j;
for (j=0; j<sizes[i]; j++) {
buf[i][j]=(char)random();
......@@ -50,7 +50,7 @@ test (int seed) {
i--;
int sizen;
{ int r = bread_backwards(br, &sizen, 4); assert(r==4); }
int sizeh=ntohl(sizen);
int sizeh=toku_ntohl(sizen);
assert(sizeh==sizes[i]);
assert(0<=sizeh && sizeh<100);
{
......
......@@ -391,7 +391,7 @@ static void test_brt_cursor_rwalk(int n, DB *db) {
int k; long long v;
DBT kbt, vbt;
k = htonl(i);
k = toku_htonl(i);
toku_fill_dbt(&kbt, &k, sizeof k);
v = i;
toku_fill_dbt(&vbt, &v, sizeof v);
......@@ -655,7 +655,7 @@ static void test_multiple_brt_cursor_walk(int n, DB *db) {
/* insert keys 0, 1, 2, ... n-1 */
int i;
for (i=0; i<n; i++) {
k = htonl(i);
k = toku_htonl(i);
v = i;
toku_fill_dbt(&key, &k, sizeof k);
toku_fill_dbt(&val, &v, sizeof v);
......@@ -729,7 +729,7 @@ static void test_brt_cursor_set(int n, int cursor_op, DB *db) {
/* insert keys 0, 10, 20 .. 10*(n-1) */
for (i=0; i<n; i++) {
k = htonl(10*i);
k = toku_htonl(10*i);
v = 10*i;
toku_fill_dbt(&key, &k, sizeof k);
toku_fill_dbt(&val, &v, sizeof v);
......@@ -745,7 +745,7 @@ static void test_brt_cursor_set(int n, int cursor_op, DB *db) {
int vv;
v = 10*(random() % n);
k = htonl(v);
k = toku_htonl(v);
toku_fill_dbt(&key, &k, sizeof k);
toku_init_dbt(&val); val.flags = DB_DBT_MALLOC;
r = toku_brt_cursor_get(cursor, &key, &val, cursor_op, null_txn);
......@@ -761,7 +761,7 @@ static void test_brt_cursor_set(int n, int cursor_op, DB *db) {
for (i=0; i<10*n; i++) {
if (i % 10 == 0)
continue;
k = htonl(i);
k = toku_htonl(i);
toku_fill_dbt(&key, &k, sizeof k);
toku_init_dbt(&val); val.flags = DB_DBT_MALLOC;
r = toku_brt_cursor_get(cursor, &key, &val, DB_SET, null_txn);
......@@ -802,7 +802,7 @@ static void test_brt_cursor_set_range(int n, DB *db) {
/* insert keys 0, 10, 20 .. 10*(n-1) */
int max_key = 10*(n-1);
for (i=0; i<n; i++) {
k = htonl(10*i);
k = toku_htonl(10*i);
v = 10*i;
toku_fill_dbt(&key, &k, sizeof k);
toku_fill_dbt(&val, &v, sizeof v);
......@@ -819,7 +819,7 @@ static void test_brt_cursor_set_range(int n, DB *db) {
int vv;
v = random() % (10*n);
k = htonl(v);
k = toku_htonl(v);
toku_fill_dbt(&key, &k, sizeof k);
toku_init_dbt(&val); val.flags = DB_DBT_MALLOC;
r = toku_brt_cursor_get(cursor, &key, &val, DB_SET_RANGE, null_txn);
......@@ -870,7 +870,7 @@ static void test_brt_cursor_delete(int n, DB *db) {
int i;
/* insert keys 0, 1, 2, .. (n-1) */
for (i=0; i<n; i++) {
k = htonl(i);
k = toku_htonl(i);
v = i;
toku_fill_dbt(&key, &k, sizeof k);
toku_fill_dbt(&val, &v, sizeof v);
......@@ -929,7 +929,7 @@ static void test_brt_cursor_get_both(int n, DB *db) {
int k, v;
/* verify get_both on an empty tree fails */
k = htonl(n+1);
k = toku_htonl(n+1);
v = n+1;
toku_fill_dbt(&key, &k, sizeof k);
toku_fill_dbt(&val, &v, sizeof v);
......@@ -939,7 +939,7 @@ static void test_brt_cursor_get_both(int n, DB *db) {
int i;
/* insert keys 0, 1, 2, .. (n-1) */
for (i=0; i<n; i++) {
k = htonl(i);
k = toku_htonl(i);
v = i;
toku_fill_dbt(&key, &k, sizeof k);
toku_fill_dbt(&val, &v, sizeof v);
......@@ -948,7 +948,7 @@ static void test_brt_cursor_get_both(int n, DB *db) {
}
/* verify that keys not in the tree fail */
k = htonl(n+1);
k = toku_htonl(n+1);
v = n-1;
toku_fill_dbt(&key, &k, sizeof k);
toku_fill_dbt(&val, &v, sizeof v);
......@@ -957,7 +957,7 @@ static void test_brt_cursor_get_both(int n, DB *db) {
/* verify that key match but data mismatch fails */
for (i=0; i<n; i++) {
k = htonl(i);
k = toku_htonl(i);
v = i+1;
toku_fill_dbt(&key, &k, sizeof k);
toku_fill_dbt(&val, &v, sizeof v);
......@@ -967,7 +967,7 @@ static void test_brt_cursor_get_both(int n, DB *db) {
/* verify that key and data matches succeeds */
for (i=0; i<n; i++) {
k = htonl(i);
k = toku_htonl(i);
v = i;
toku_fill_dbt(&key, &k, sizeof k);
toku_fill_dbt(&val, &v, sizeof v);
......@@ -988,7 +988,7 @@ static void test_brt_cursor_get_both(int n, DB *db) {
error = toku_brt_cursor_delete(cursor, 0, null_txn);
assert(error == 0);
k = htonl(i);
k = toku_htonl(i);
v = i;
toku_fill_dbt(&key, &k, sizeof k);
toku_fill_dbt(&val, &v, sizeof v);
......
......@@ -630,7 +630,7 @@ static void test_brt_delete_empty() {
assert(r==0);
DBT key;
int k = htonl(1);
int k = toku_htonl(1);
toku_fill_dbt(&key, &k, sizeof k);
r = toku_brt_delete(t, &key, null_txn);
assert(r == 0);
......@@ -662,7 +662,7 @@ static void test_brt_delete_present(int n) {
/* insert 0 .. n-1 */
for (i=0; i<n; i++) {
k = htonl(i); v = i;
k = toku_htonl(i); v = i;
toku_fill_dbt(&key, &k, sizeof k);
toku_fill_dbt(&val, &v, sizeof v);
r = toku_brt_insert(t, &key, &val, 0);
......@@ -671,7 +671,7 @@ static void test_brt_delete_present(int n) {
/* delete 0 .. n-1 */
for (i=0; i<n; i++) {
k = htonl(i);
k = toku_htonl(i);
toku_fill_dbt(&key, &k, sizeof k);
r = toku_brt_delete(t, &key, null_txn);
assert(r == 0);
......@@ -679,7 +679,7 @@ static void test_brt_delete_present(int n) {
/* lookups should all fail */
for (i=0; i<n; i++) {
k = htonl(i);
k = toku_htonl(i);
toku_fill_dbt(&key, &k, sizeof k);
toku_init_dbt(&val); val.flags = DB_DBT_MALLOC;
r = toku_brt_lookup(t, &key, &val);
......@@ -723,7 +723,7 @@ static void test_brt_delete_not_present(int n) {
/* insert 0 .. n-1 */
for (i=0; i<n; i++) {
k = htonl(i); v = i;
k = toku_htonl(i); v = i;
toku_fill_dbt(&key, &k, sizeof k);
toku_fill_dbt(&val, &v, sizeof v);
r = toku_brt_insert(t, &key, &val, 0);
......@@ -732,14 +732,14 @@ static void test_brt_delete_not_present(int n) {
/* delete 0 .. n-1 */
for (i=0; i<n; i++) {
k = htonl(i);
k = toku_htonl(i);
toku_fill_dbt(&key, &k, sizeof k);
r = toku_brt_delete(t, &key, null_txn);
assert(r == 0);
}
/* try to delete key n+1 not in the tree */
k = htonl(n+1);
k = toku_htonl(n+1);
toku_fill_dbt(&key, &k, sizeof k);
r = toku_brt_delete(t, &key, null_txn);
/* the delete may be buffered or may be executed on a leaf node, so the
......@@ -769,7 +769,7 @@ static void test_brt_delete_cursor_first(int n) {
/* insert 0 .. n-1 */
for (i=0; i<n; i++) {
k = htonl(i); v = i;
k = toku_htonl(i); v = i;
toku_fill_dbt(&key, &k, sizeof k);
toku_fill_dbt(&val, &v, sizeof v);
r = toku_brt_insert(t, &key, &val, 0);
......@@ -778,7 +778,7 @@ static void test_brt_delete_cursor_first(int n) {
/* lookups 0 .. n-1 should succeed */
for (i=0; i<n; i++) {
k = htonl(i);
k = toku_htonl(i);
toku_fill_dbt(&key, &k, sizeof k);
toku_init_dbt(&val); val.flags = DB_DBT_MALLOC;
r = toku_brt_lookup(t, &key, &val);
......@@ -792,7 +792,7 @@ static void test_brt_delete_cursor_first(int n) {
/* delete 0 .. n-2 */
for (i=0; i<n-1; i++) {
k = htonl(i);
k = toku_htonl(i);
toku_fill_dbt(&key, &k, sizeof k);
r = toku_brt_delete(t, &key, null_txn);
assert(r == 0);
......@@ -804,7 +804,7 @@ static void test_brt_delete_cursor_first(int n) {
/* lookup of 0 .. n-2 should all fail */
for (i=0; i<n-1; i++) {
k = htonl(i);
k = toku_htonl(i);
toku_fill_dbt(&key, &k, sizeof k);
toku_init_dbt(&val); val.flags = DB_DBT_MALLOC;
r = toku_brt_lookup(t, &key, &val);
......@@ -860,7 +860,7 @@ static void test_insert_delete_lookup(int n) {
/* insert 0 .. n-1 */
for (i=0; i<n; i++) {
k = htonl(i); v = i;
k = toku_htonl(i); v = i;
toku_fill_dbt(&key, &k, sizeof k);
toku_fill_dbt(&val, &v, sizeof v);
r = toku_brt_insert(t, &key, &val, 0);
......@@ -868,12 +868,12 @@ static void test_insert_delete_lookup(int n) {
}
if (n > 0) {
k = htonl(n-1);
k = toku_htonl(n-1);
toku_fill_dbt(&key, &k, sizeof k);
r = toku_brt_delete(t, &key, null_txn);
assert(r == 0);
k = htonl(n-1);
k = toku_htonl(n-1);
toku_fill_dbt(&key, &k, sizeof k);
toku_init_dbt(&val); val.flags = DB_DBT_MALLOC;
r = toku_brt_lookup(t, &key, &val);
......@@ -908,26 +908,26 @@ static void test_brt_delete_both(int n) {
int k, v;
for (i=0; i<n; i++) {
k = htonl(0); v = htonl(i);
k = toku_htonl(0); v = toku_htonl(i);
r = toku_brt_insert(t, toku_fill_dbt(&key, &k, sizeof k), toku_fill_dbt(&val, &v, sizeof v), 0);
assert(r == 0);
}
for (i=0; i<n; i += 2) {
k = htonl(0); v = htonl(i);
k = toku_htonl(0); v = toku_htonl(i);
r = toku_brt_delete_both(t, toku_fill_dbt(&key, &k, sizeof k), toku_fill_dbt(&val, &v, sizeof v), null_txn); assert(r == 0);
}
#if 0
for (i=1; i<n; i += 2) {
k = htonl(0);
k = toku_htonl(0);
toku_fill_dbt(&key, &k, sizeof k);
toku_init_dbt(&val); val.flags = DB_DBT_MALLOC;
r = toku_brt_lookup(t, &key, &val); assert(r == 0);
int vv;
assert(val.size == sizeof vv);
memcpy(&vv, val.data, val.size);
assert(vv == (int) htonl(i));
assert(vv == (int) toku_htonl(i));
if (val.data) free(val.data);
r = toku_brt_delete_both(t, toku_fill_dbt(&key, &k, sizeof k), toku_fill_dbt(&val, &vv, sizeof vv), null_txn); assert(r == 0);
}
......@@ -946,7 +946,7 @@ static void test_brt_delete_both(int n) {
int vv;
assert(val.size == sizeof vv);
memcpy(&vv, val.data, val.size);
assert(vv == (int) htonl(i));
assert(vv == (int) toku_htonl(i));
toku_free(key.data);
toku_free(val.data);
}
......@@ -1012,7 +1012,7 @@ static void test_new_brt_cursor_first(int n, int dup_mode) {
int k, v;
for (i=0; i<n; i++) {
k = htonl(i); v = htonl(i);
k = toku_htonl(i); v = toku_htonl(i);
r = toku_brt_insert(t, toku_fill_dbt(&key, &k, sizeof k), toku_fill_dbt(&val, &v, sizeof v), 0); assert(r == 0);
}
......@@ -1029,11 +1029,11 @@ static void test_new_brt_cursor_first(int n, int dup_mode) {
int kk;
assert(key.size == sizeof kk);
memcpy(&kk, key.data, key.size);
assert(kk == (int) htonl(i));
assert(kk == (int) toku_htonl(i));
int vv;
assert(val.size == sizeof vv);
memcpy(&vv, val.data, val.size);
assert(vv == (int) htonl(i));
assert(vv == (int) toku_htonl(i));
r = toku_brt_cursor_delete(cursor, 0, null_txn); assert(r == 0);
}
......@@ -1066,7 +1066,7 @@ static void test_new_brt_cursor_last(int n, int dup_mode) {
int k, v;
for (i=0; i<n; i++) {
k = htonl(i); v = htonl(i);
k = toku_htonl(i); v = toku_htonl(i);
r = toku_brt_insert(t, toku_fill_dbt(&key, &k, sizeof k), toku_fill_dbt(&val, &v, sizeof v), 0); assert(r == 0);
}
......@@ -1083,11 +1083,11 @@ static void test_new_brt_cursor_last(int n, int dup_mode) {
int kk;
assert(key.size == sizeof kk);
memcpy(&kk, key.data, key.size);
assert(kk == (int) htonl(i));
assert(kk == (int) toku_htonl(i));
int vv;
assert(val.size == sizeof vv);
memcpy(&vv, val.data, val.size);
assert(vv == (int) htonl(i));
assert(vv == (int) toku_htonl(i));
//if (n==512 && i<=360) { printf("i=%d\n", i); toku_dump_brt(stdout, t); }
r = toku_brt_cursor_delete(cursor, 0, null_txn); assert(r == 0);
......@@ -1121,7 +1121,7 @@ static void test_new_brt_cursor_next(int n, int dup_mode) {
int k, v;
for (i=0; i<n; i++) {
k = htonl(i); v = htonl(i);
k = toku_htonl(i); v = toku_htonl(i);
r = toku_brt_insert(t, toku_fill_dbt(&key, &k, sizeof k), toku_fill_dbt(&val, &v, sizeof v), 0); assert(r == 0);
}
......@@ -1138,11 +1138,11 @@ static void test_new_brt_cursor_next(int n, int dup_mode) {
int kk;
assert(key.size == sizeof kk);
memcpy(&kk, key.data, key.size);
assert(kk == (int) htonl(i));
assert(kk == (int) toku_htonl(i));
int vv;
assert(val.size == sizeof vv);
memcpy(&vv, val.data, val.size);
assert(vv == (int) htonl(i));
assert(vv == (int) toku_htonl(i));
}
assert(i == n);
......@@ -1173,7 +1173,7 @@ static void test_new_brt_cursor_prev(int n, int dup_mode) {
int k, v;
for (i=0; i<n; i++) {
k = htonl(i); v = htonl(i);
k = toku_htonl(i); v = toku_htonl(i);
r = toku_brt_insert(t, toku_fill_dbt(&key, &k, sizeof k), toku_fill_dbt(&val, &v, sizeof v), 0); assert(r == 0);
}
......@@ -1190,11 +1190,11 @@ static void test_new_brt_cursor_prev(int n, int dup_mode) {
int kk;
assert(key.size == sizeof kk);
memcpy(&kk, key.data, key.size);
assert(kk == (int) htonl(i));
assert(kk == (int) toku_htonl(i));
int vv;
assert(val.size == sizeof vv);
memcpy(&vv, val.data, val.size);
assert(vv == (int) htonl(i));
assert(vv == (int) toku_htonl(i));
}
assert(i == -1);
......@@ -1225,7 +1225,7 @@ static void test_new_brt_cursor_current(int n, int dup_mode) {
int k, v;
for (i=0; i<n; i++) {
k = htonl(i); v = htonl(i);
k = toku_htonl(i); v = toku_htonl(i);
r = toku_brt_insert(t, toku_fill_dbt(&key, &k, sizeof k), toku_fill_dbt(&val, &v, sizeof v), 0); assert(r == 0);
}
......@@ -1242,27 +1242,27 @@ static void test_new_brt_cursor_current(int n, int dup_mode) {
int kk;
assert(key.size == sizeof kk);
memcpy(&kk, key.data, key.size);
assert(kk == (int) htonl(i));
assert(kk == (int) toku_htonl(i));
int vv;
assert(val.size == sizeof vv);
memcpy(&vv, val.data, val.size);
assert(vv == (int) htonl(i));
assert(vv == (int) toku_htonl(i));
r = toku_brt_cursor_get(cursor, &key, &val, DB_CURRENT, null_txn); assert(r == 0);
assert(key.size == sizeof kk);
memcpy(&kk, key.data, key.size);
assert(kk == (int) htonl(i));
assert(kk == (int) toku_htonl(i));
assert(val.size == sizeof vv);
memcpy(&vv, val.data, val.size);
assert(vv == (int) htonl(i));
assert(vv == (int) toku_htonl(i));
r = toku_brt_cursor_get(cursor, &key, &val, DB_CURRENT_BINDING, null_txn); assert(r == 0);
assert(key.size == sizeof kk);
memcpy(&kk, key.data, key.size);
assert(kk == (int) htonl(i));
assert(kk == (int) toku_htonl(i));
assert(val.size == sizeof vv);
memcpy(&vv, val.data, val.size);
assert(vv == (int) htonl(i));
assert(vv == (int) toku_htonl(i));
r = toku_brt_cursor_delete(cursor, 0, null_txn); assert(r == 0);
......@@ -1271,10 +1271,10 @@ static void test_new_brt_cursor_current(int n, int dup_mode) {
r = toku_brt_cursor_get(cursor, &key, &val, DB_CURRENT_BINDING, null_txn); assert(r == 0);
assert(key.size == sizeof kk);
memcpy(&kk, key.data, key.size);
assert(kk == (int) htonl(i));
assert(kk == (int) toku_htonl(i));
assert(val.size == sizeof vv);
memcpy(&vv, val.data, val.size);
assert(vv == (int) htonl(i));
assert(vv == (int) toku_htonl(i));
}
assert(i == n);
......@@ -1308,7 +1308,7 @@ static void test_new_brt_cursor_set_range(int n, int dup_mode) {
/* insert keys 0, 10, 20 .. 10*(n-1) */
int max_key = 10*(n-1);
for (i=0; i<n; i++) {
k = htonl(10*i);
k = toku_htonl(10*i);
v = 10*i;
r = toku_brt_insert(brt, toku_fill_dbt(&key, &k, sizeof k), toku_fill_dbt(&val, &v, sizeof v), 0); assert(r == 0);
}
......@@ -1321,7 +1321,7 @@ static void test_new_brt_cursor_set_range(int n, int dup_mode) {
int vv;
v = random() % (10*n);
k = htonl(v);
k = toku_htonl(v);
toku_fill_dbt(&key, &k, sizeof k);
toku_init_dbt(&val); val.flags = DB_DBT_MALLOC;
r = toku_brt_cursor_get(cursor, &key, &val, DB_SET_RANGE, null_txn);
......@@ -1364,7 +1364,7 @@ static void test_new_brt_cursor_set(int n, int cursor_op, DB *db) {
/* insert keys 0, 10, 20 .. 10*(n-1) */
for (i=0; i<n; i++) {
k = htonl(10*i);
k = toku_htonl(10*i);
v = 10*i;
r = toku_brt_insert(brt, toku_fill_dbt(&key, &k, sizeof k), toku_fill_dbt(&val, &v, sizeof v), 0); assert(r == 0);
}
......@@ -1376,7 +1376,7 @@ static void test_new_brt_cursor_set(int n, int cursor_op, DB *db) {
int vv;
v = 10*(random() % n);
k = htonl(v);
k = toku_htonl(v);
toku_fill_dbt(&key, &k, sizeof k);
toku_init_dbt(&val); val.flags = DB_DBT_MALLOC;
r = toku_brt_cursor_get(cursor, &key, &val, cursor_op, null_txn);
......@@ -1392,7 +1392,7 @@ static void test_new_brt_cursor_set(int n, int cursor_op, DB *db) {
for (i=0; i<10*n; i++) {
if (i % 10 == 0)
continue;
k = htonl(i);
k = toku_htonl(i);
toku_fill_dbt(&key, &k, sizeof k);
toku_init_dbt(&val); val.flags = DB_DBT_MALLOC;
r = toku_brt_cursor_get(cursor, &key, &val, DB_SET, null_txn);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment