Commit e459c4b1 authored by John Esmet's avatar John Esmet Committed by Yoni Fogel

refs #5629 get rid of some unneeded byte flipping. stick to little endian...

refs #5629 get rid of some unneeded byte flipping. stick to little endian witha little endian comparison function.


git-svn-id: file:///svn/toku/tokudb@50327 c7de825b-a66e-492c-adef-691d508d4ae1
parent 7653a816
/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4:
#ident "$Id: test-pagesize.cc 45903 2012-07-19 13:06:39Z leifwalsh $"
#ident "Copyright (c) 2007-2012 Tokutek Inc. All rights reserved."
#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it."
#include <toku_assert.h>
#include <portability/toku_htonl.h>
static void test32(void) {
uint32_t k = 0xDEADBEEF;
uint32_t n_k = toku_htonl(k);
const int num_bytes = 4;
for (int i = 0; i < num_bytes; i++) {
unsigned char *c = (unsigned char *) &k;
unsigned char *n_c = (unsigned char *) &n_k;
invariant(c[i] == n_c[(num_bytes - 1) - i]);
}
}
static void test64(void) {
uint64_t k = 0xDEADBEEFABCDBADC;
uint64_t n_k = toku_htonl64(k);
const int num_bytes = 8;
for (int i = 0; i < num_bytes; i++) {
unsigned char *c = (unsigned char *) &k;
unsigned char *n_c = (unsigned char *) &n_k;
invariant(c[i] == n_c[(num_bytes - 1)- i]);
}
}
int main(void) {
test32();
test64();
return 0;
}
...@@ -22,24 +22,4 @@ static inline uint32_t toku_ntohl(uint32_t i) { ...@@ -22,24 +22,4 @@ static inline uint32_t toku_ntohl(uint32_t i) {
return ntohl(i); return ntohl(i);
} }
static inline uint64_t toku_htonl64(uint64_t i) {
#if HOST_BYTE_ORDER != NETWORK_BYTE_ORDER
uint64_t a = ((uint64_t) htonl(i & 0xFFFFFFFF)) << 32;
uint64_t b = htonl(i >> 32);
return a | b;
#else
return i;
#endif
}
static inline uint64_t toku_ntohl64(uint64_t i) {
#if HOST_BYTE_ORDER != NETWORK_BYTE_ORDER
uint64_t a = ((uint64_t) ntohl(i & 0xFFFFFFFF)) << 32;
uint64_t b = ntohl(i >> 32);
return a | b;
#else
return i;
#endif
}
#endif #endif
...@@ -19,11 +19,6 @@ struct iibench_op_extra { ...@@ -19,11 +19,6 @@ struct iibench_op_extra {
uint64_t autoincrement; uint64_t autoincrement;
}; };
static uint64_t next_autoincrement_network_order(struct iibench_op_extra *info) {
uint64_t k = toku_sync_fetch_and_add(&info->autoincrement, 1);
return toku_htonl64(k);
}
static int UU() iibench_put_op(DB_TXN *txn, ARG arg, void *operation_extra, void *stats_extra) { static int UU() iibench_put_op(DB_TXN *txn, ARG arg, void *operation_extra, void *stats_extra) {
const int num_dbs = arg->cli->num_DBs; const int num_dbs = arg->cli->num_DBs;
DB **dbs = arg->dbp; DB **dbs = arg->dbp;
...@@ -50,7 +45,7 @@ static int UU() iibench_put_op(DB_TXN *txn, ARG arg, void *operation_extra, void ...@@ -50,7 +45,7 @@ static int UU() iibench_put_op(DB_TXN *txn, ARG arg, void *operation_extra, void
fill_zeroed_array(valbuf, arg->cli->val_size, fill_zeroed_array(valbuf, arg->cli->val_size,
arg->random_data, arg->cli->compressibility); arg->random_data, arg->cli->compressibility);
struct iibench_op_extra *CAST_FROM_VOIDP(info, operation_extra); struct iibench_op_extra *CAST_FROM_VOIDP(info, operation_extra);
uint64_t pk = next_autoincrement_network_order(info); uint64_t pk = toku_sync_fetch_and_add(&info->autoincrement, 1);
dbt_init(&mult_key_dbt[0], &pk, sizeof pk); dbt_init(&mult_key_dbt[0], &pk, sizeof pk);
dbt_init(&mult_val_dbt[0], valbuf, sizeof valbuf); dbt_init(&mult_val_dbt[0], valbuf, sizeof valbuf);
r = env->put_multiple( r = env->put_multiple(
......
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