Commit 39d3494c authored by Yoni Fogel's avatar Yoni Fogel

Addresses #1032

Standardize unsigned ints:
uint8_t -> u_int8_t
uint32_t -> u_int32_t
uint64_t ->u_int64_t
Windows seems to differentiate between the two, linux does not.

git-svn-id: file:///svn/tokudb@5239 c7de825b-a66e-492c-adef-691d508d4ae1
parent 5b88d2c4
......@@ -128,7 +128,7 @@ struct brt_header {
FIFO fifo; // all the abort and commit commands. If the header gets flushed to disk, we write the fifo contents beyond the unused_memory.
uint64_t root_put_counter;
u_int64_t root_put_counter;
};
struct brt {
......@@ -211,7 +211,7 @@ struct brt_cursor {
int is_temporary_cursor; // If it is a temporary cursor then use the following skey and sval to return tokudb-managed values in dbts. Otherwise use the brt's skey and skval.
void *skey, *sval;
OMTCURSOR omtcursor;
uint64_t root_put_counter; // what was the count on the BRT when we validated the cursor?
u_int64_t root_put_counter; // what was the count on the BRT when we validated the cursor?
};
// logs the memory allocation, but not the creation of the new node
......
......@@ -430,8 +430,8 @@ int toku_deserialize_brtnode_from (int fd, DISKOFF off, u_int32_t fullhash, BRTN
if (n_read_so_far+4!=rc.size) {
r = DB_BADFORMAT; goto died_21;
}
uint32_t crc = murmur_string(rc.buf, n_read_so_far);
uint32_t storedcrc = rbuf_int(&rc);
u_int32_t crc = murmur_string(rc.buf, n_read_so_far);
u_int32_t storedcrc = rbuf_int(&rc);
if (crc!=storedcrc) {
printf("Bad CRC\n");
printf("%s:%d crc=%08x stored=%08x\n", __FILE__, __LINE__, crc, storedcrc);
......@@ -698,7 +698,7 @@ int read_char (int fd, off_t *at, char *result) {
return 0;
}
int read_uint64_t (int fd, off_t *at, u_int64_t *result) {
int read_u_int64_t (int fd, off_t *at, u_int64_t *result) {
u_int32_t v1=0,v2=0;
int r;
if ((r = read_int(fd, at, &v1))) return r;
......@@ -732,7 +732,7 @@ int toku_deserialize_fifo_at (int fd, off_t at, FIFO *fifo) {
u_int32_t keylen=0, vallen=0;
char *key=0, *val=0;
if ((r=read_char(fd, &at, &type))) return r;
if ((r=read_uint64_t(fd, &at, &xid))) return r;
if ((r=read_u_int64_t(fd, &at, &xid))) return r;
if ((r=read_int(fd, &at, &keylen))) return r;
if ((r=read_nbytes(fd, &at, &key, keylen))) return r;
if ((r=read_int(fd, &at, &vallen))) return r;
......
......@@ -59,7 +59,7 @@ static void verify_local_fingerprint_nonleaf (BRTNODE node);
// then we lose that counter. So we also keep a global counter.
// An alternative would be to keep only the global counter. But that would invalidate all OMTCURSORS
// even from unrelated BRTs. This way we only invalidate an OMTCURSOR if
static uint64_t global_root_put_counter = 0;
static u_int64_t global_root_put_counter = 0;
/* Frees a node, including all the stuff in the hash table. */
void toku_brtnode_free (BRTNODE *nodep) {
......@@ -309,18 +309,18 @@ u_int32_t mp_pool_size_for_nodesize (u_int32_t nodesize) {
// Simple LCG random number generator. Not high quality, but good enough.
static int r_seeded=0;
static uint32_t rstate=1;
static u_int32_t rstate=1;
static inline void mysrandom (int s) {
rstate=s;
r_seeded=1;
}
static inline uint32_t myrandom (void) {
static inline u_int32_t myrandom (void) {
if (!r_seeded) {
struct timeval tv;
gettimeofday(&tv, 0);
mysrandom(tv.tv_sec);
}
rstate = (279470275ull*(uint64_t)rstate)%4294967291ull;
rstate = (279470275ull*(u_int64_t)rstate)%4294967291ull;
return rstate;
}
......@@ -3034,7 +3034,7 @@ static int brt_search_node(BRT brt, BRTNODE node, brt_search_t *search, DBT *new
return brt_search_leaf_node(brt, node, search, newkey, newval, logger, omtcursor);
}
int toku_brt_search(BRT brt, brt_search_t *search, DBT *newkey, DBT *newval, TOKULOGGER logger, OMTCURSOR omtcursor, uint64_t *root_put_counter)
int toku_brt_search(BRT brt, brt_search_t *search, DBT *newkey, DBT *newval, TOKULOGGER logger, OMTCURSOR omtcursor, u_int64_t *root_put_counter)
// Effect: Perform a search. Associate cursor with a leaf if possible.
{
int r, rr;
......@@ -3409,7 +3409,7 @@ static int brt_cursor_next_shortcut (BRT_CURSOR cursor, DBT *outkey, DBT *outval
{
int rr = toku_read_and_pin_brt_header(cursor->brt->cf, &cursor->brt->h);
if (rr!=0) return rr;
uint64_t h_counter = cursor->brt->h->root_put_counter;
u_int64_t h_counter = cursor->brt->h->root_put_counter;
rr = toku_unpin_brt_header(cursor->brt);
assert(rr==0);
if (h_counter != cursor->root_put_counter) return -1;
......@@ -3450,7 +3450,7 @@ int toku_brt_cursor_peek_prev(BRT_CURSOR cursor, DBT *outkey, DBT *outval) {
{
int rr = toku_read_and_pin_brt_header(cursor->brt->cf, &cursor->brt->h);
if (rr!=0) return rr;
uint64_t h_counter = cursor->brt->h->root_put_counter;
u_int64_t h_counter = cursor->brt->h->root_put_counter;
rr = toku_unpin_brt_header(cursor->brt);
assert(rr==0);
if (h_counter != cursor->root_put_counter) return -1;
......@@ -3479,7 +3479,7 @@ int toku_brt_cursor_peek_next(BRT_CURSOR cursor, DBT *outkey, DBT *outval) {
{
int rr = toku_read_and_pin_brt_header(cursor->brt->cf, &cursor->brt->h);
if (rr!=0) return rr;
uint64_t h_counter = cursor->brt->h->root_put_counter;
u_int64_t h_counter = cursor->brt->h->root_put_counter;
rr = toku_unpin_brt_header(cursor->brt);
assert(rr==0);
if (h_counter != cursor->root_put_counter) return -1;
......@@ -3572,7 +3572,7 @@ static int brt_cursor_prev_shortcut (BRT_CURSOR cursor, DBT *outkey, DBT *outval
{
int rr = toku_read_and_pin_brt_header(cursor->brt->cf, &cursor->brt->h);
if (rr!=0) return rr;
uint64_t h_counter = cursor->brt->h->root_put_counter;
u_int64_t h_counter = cursor->brt->h->root_put_counter;
rr = toku_unpin_brt_header(cursor->brt);
assert(rr==0);
if (h_counter != cursor->root_put_counter) return -1;
......
......@@ -1074,7 +1074,7 @@ static void note_txn_closing (TOKUTXN txn) {
int toku_txn_find_by_xid (BRT brt, TXNID xid, TOKUTXN *txnptr) {
struct tokutxn fake_txn; fake_txn.txnid64 = xid;
uint32_t index;
u_int32_t index;
OMTVALUE txnv;
int r = toku_omt_find_zero(brt->txns, find_xid, &fake_txn, &txnv, &index, NULL);
if (r == 0) *txnptr = txnv;
......
......@@ -74,12 +74,12 @@ void parse_args (int argc, const char *argv[]) {
}
// Simle LCG random number generator. Not high quality, but good enough.
static uint32_t rstate=1;
static u_int32_t rstate=1;
static inline void mysrandom (int s) {
rstate=s;
}
static inline uint32_t myrandom (void) {
rstate = (279470275ull*(uint64_t)rstate)%4294967291ull;
static inline u_int32_t myrandom (void) {
rstate = (279470275ull*(u_int64_t)rstate)%4294967291ull;
return rstate;
}
......
......@@ -31,12 +31,12 @@ void parse_args (int argc, const char *argv[]) {
}
// Simle LCG random number generator. Not high quality, but good enough.
static uint32_t rstate=1;
static u_int32_t rstate=1;
static inline void mysrandom (int s) {
rstate=s;
}
static inline uint32_t myrandom (void) {
rstate = (279470275ull*(uint64_t)rstate)%4294967291ull;
static inline u_int32_t myrandom (void) {
rstate = (279470275ull*(u_int64_t)rstate)%4294967291ull;
return rstate;
}
......
......@@ -218,9 +218,9 @@ int main(int argc, const char *argv[]) {
assert(bufsize >= 2);
verify_all_overlap(&find_range, buf, found);
uint32_t inserted = 2;
const uint32_t start_loop = 100;
const uint32_t end_loop = 200;
u_int32_t inserted = 2;
const u_int32_t start_loop = 100;
const u_int32_t end_loop = 200;
for (i = start_loop; i < end_loop; i += 4) {
range.ends.left = (toku_point*)&nums[i];
range.ends.right = (toku_point*)&nums[i+2];
......
......@@ -63,12 +63,12 @@ DBT *dbt_init_malloc(DBT *dbt) {
}
// Simple LCG random number generator. Not high quality, but good enough.
static uint32_t rstate=1;
static u_int32_t rstate=1;
static inline void mysrandom (int s) {
rstate=s;
}
static inline uint32_t myrandom (void) {
rstate = (279470275ull*(uint64_t)rstate)%4294967291ull;
static inline u_int32_t myrandom (void) {
rstate = (279470275ull*(u_int64_t)rstate)%4294967291ull;
return rstate;
}
......
......@@ -12,8 +12,8 @@
#include "test.h"
uint64_t lorange = 0;
uint64_t hirange = 1<<24;
u_int64_t lorange = 0;
u_int64_t hirange = 1<<24;
void test_key_size_limit(int dup_mode) {
if (verbose > 1) printf("%s:%d\n", __FUNCTION__, dup_mode);
......@@ -37,17 +37,17 @@ void test_key_size_limit(int dup_mode) {
void *k = 0;
void *v = 0;
uint32_t lo = lorange, mi = 0, hi = hirange;
uint32_t bigest = 0;
u_int32_t lo = lorange, mi = 0, hi = hirange;
u_int32_t bigest = 0;
while (lo <= hi) {
mi = lo + (hi - lo) / 2;
assert(lo <= mi && mi <= hi);
uint32_t ks = mi;
u_int32_t ks = mi;
if (verbose > 1) printf("trying %u %u %u ks=%u\n", lo, mi, hi, ks);
k = realloc(k, ks); assert(k);
memset(k, 0, ks);
memcpy(k, &ks, sizeof ks);
uint32_t vs = sizeof (uint32_t);
u_int32_t vs = sizeof (u_int32_t);
v = realloc(v, vs); assert(v);
memset(v, 0, vs);
memcpy(v, &vs, sizeof vs);
......@@ -92,17 +92,17 @@ void test_data_size_limit(int dup_mode) {
void *k = 0;
void *v = 0;
uint32_t lo = lorange, mi = 0, hi = hirange;
uint32_t bigest = 0;
u_int32_t lo = lorange, mi = 0, hi = hirange;
u_int32_t bigest = 0;
while (lo <= hi) {
mi = lo + (hi - lo) / 2;
assert(lo <= mi && mi <= hi);
uint32_t ks = sizeof (uint32_t);
u_int32_t ks = sizeof (u_int32_t);
if (verbose > 1) printf("trying %u %u %u ks=%u\n", lo, mi, hi, ks);
k = realloc(k, ks); assert(k);
memset(k, 0, ks);
memcpy(k, &ks, sizeof ks);
uint32_t vs = mi;
u_int32_t vs = mi;
v = realloc(v, vs); assert(v);
memset(v, 0, vs);
memcpy(v, &vs, sizeof vs);
......
......@@ -11,7 +11,7 @@
#include <inttypes.h>
#include <signal.h>
typedef uint8_t bool;
typedef u_int8_t bool;
#define true ((bool)1)
#define false ((bool)0)
......
......@@ -25,9 +25,9 @@ else { \
}
int strtoint32 (char* str, int32_t* num, int32_t min, int32_t max, int base);
int strtouint32 (char* str, uint32_t* num, uint32_t min, uint32_t max, int base);
int strtouint32 (char* str, u_int32_t* num, u_int32_t min, u_int32_t max, int base);
int strtoint64 (char* str, int64_t* num, int64_t min, int64_t max, int base);
int strtouint64 (char* str, uint64_t* num, uint64_t min, uint64_t max, int base);
int strtouint64 (char* str, u_int64_t* num, u_int64_t min, u_int64_t max, int base);
/*
* Convert a string to an integer of type "type".
......@@ -79,11 +79,11 @@ error: \
}
DEF_STR_TO(strtoint32, int32_t, int64_t, strtoll, PRId32);
DEF_STR_TO(strtouint32, uint32_t, uint64_t, strtoull, PRIu32);
DEF_STR_TO(strtouint32, u_int32_t, u_int64_t, strtoull, PRIu32);
DEF_STR_TO(strtoint64, int64_t, int64_t, strtoll, PRId64);
DEF_STR_TO(strtouint64, uint64_t, uint64_t, strtoull, PRIu64);
DEF_STR_TO(strtouint64, u_int64_t, u_int64_t, strtoull, PRIu64);
void outputbyte(uint8_t ch)
void outputbyte(u_int8_t ch)
{
if (g.plaintext) {
if (ch == '\\') printf("\\\\");
......@@ -98,7 +98,7 @@ void outputstring(char* str)
char* p;
for (p = str; *p != '\0'; p++) {
outputbyte((uint8_t)*p);
outputbyte((u_int8_t)*p);
}
}
......
......@@ -377,7 +377,7 @@ error:
int dump_dbt(DBT* dbt)
{
char* str;
uint32_t index;
u_int32_t index;
assert(dbt);
str = (char*)dbt->data;
......
......@@ -30,18 +30,18 @@ int get_delimiter(char* str);
char dbt_delimiter = '\n';
char sort_delimiter[2];
uint32_t lengthmin = 0;
u_int32_t lengthmin = 0;
bool set_lengthmin = false;
uint32_t lengthlimit = 0;
u_int32_t lengthlimit = 0;
bool set_lengthlimit= false;
uint64_t numkeys = 0;
u_int64_t numkeys = 0;
bool set_numkeys = false;
bool header = true;
bool footer = true;
bool justheader = false;
bool justfooter = false;
bool outputkeys = true;
uint32_t seed = 1;
u_int32_t seed = 1;
bool set_seed = false;
bool printableonly = false;
bool leadingspace = true;
......@@ -269,14 +269,14 @@ int usage()
return EXIT_FAILURE;
}
uint8_t randbyte()
u_int8_t randbyte()
{
static uint32_t numsavedbits = 0;
static uint64_t savedbits = 0;
uint8_t retval;
static u_int32_t numsavedbits = 0;
static u_int64_t savedbits = 0;
u_int8_t retval;
if (numsavedbits < 8) {
savedbits |= ((uint64_t)random()) << numsavedbits;
savedbits |= ((u_int64_t)random()) << numsavedbits;
numsavedbits += 31; /* Random generates 31 random bits. */
}
retval = savedbits & 0xff;
......@@ -295,12 +295,12 @@ int32_t random_below(int32_t limit)
void generate_keys()
{
bool usedemptykey = false;
uint64_t numgenerated = 0;
uint64_t totalsize = 0;
u_int64_t numgenerated = 0;
u_int64_t totalsize = 0;
char identifier[24]; /* 8 bytes * 2 = 16; 16+1=17; 17+null terminator = 18. Extra padding. */
int length;
int i;
uint8_t ch;
u_int8_t ch;
srandom(seed);
while (numgenerated < numkeys) {
......
......@@ -27,7 +27,7 @@ typedef struct {
char** config_options;
int32_t version;
int exitcode;
uint64_t linenumber;
u_int64_t linenumber;
DBTYPE dbtype;
DB* db;
DB_ENV* dbenv;
......@@ -51,7 +51,7 @@ int open_database ();
int read_keys ();
int apply_commandline_options();
int close_database ();
int doublechararray(char** pmem, uint64_t* size);
int doublechararray(char** pmem, u_int64_t* size);
int main(int argc, char *argv[]) {
int ch;
......@@ -384,8 +384,8 @@ if (!strcmp(field, match)) { \
int read_header()
{
static uint64_t datasize = 1 << 10;
uint64_t index = 0;
static u_int64_t datasize = 1 << 10;
u_int64_t index = 0;
char* field;
char* value;
int ch;
......@@ -635,7 +635,7 @@ error:
return EXIT_FAILURE;
}
int doublechararray(char** pmem, uint64_t* size)
int doublechararray(char** pmem, u_int64_t* size)
{
DB_ENV* dbenv = g.dbenv;
......@@ -645,7 +645,7 @@ int doublechararray(char** pmem, uint64_t* size)
*size <<= 1;
if (*size == 0) {
/* Overflowed uint64_t. */
/* Overflowed u_int64_t. */
ERRORX("Line %"PRIu64": Line too long.\n", g.linenumber);
goto error;
}
......@@ -663,10 +663,10 @@ int get_dbt(DBT* pdbt)
{
DB_ENV* dbenv = g.dbenv;
/* Need to store a key and value. */
static uint64_t datasize[2] = {1 << 10, 1 << 10};
static u_int64_t datasize[2] = {1 << 10, 1 << 10};
static int which = 0;
char* datum;
uint64_t index = 0;
u_int64_t index = 0;
int highch;
int lowch;
DB* db = g.db;
......
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