Browse Source

Addressing MSVC compile error and warnings

cl-refactor
Lefteris Karapetsas 10 years ago
parent
commit
df2687e517
  1. 18
      internal.c
  2. 4
      internal.h
  3. 2
      io.c
  4. 2
      io.h

18
internal.c

@ -92,7 +92,7 @@ bool static ethash_compute_cache_nodes(
void ethash_calculate_dag_item( void ethash_calculate_dag_item(
node* const ret, node* const ret,
const unsigned node_index, uint64_t node_index,
ethash_light_t const light ethash_light_t const light
) )
{ {
@ -153,12 +153,12 @@ bool ethash_compute_full_data(
(full_size % sizeof(node)) != 0) { (full_size % sizeof(node)) != 0) {
return false; return false;
} }
unsigned int const max_n = full_size / sizeof(node); uint64_t const max_n = full_size / sizeof(node);
node* full_nodes = mem; node* full_nodes = mem;
double const progress_change = 1.0f / max_n; double const progress_change = 1.0f / max_n;
double progress = 0.0f; double progress = 0.0f;
// now compute full nodes // now compute full nodes
for (unsigned n = 0; n != max_n; ++n) { for (uint64_t n = 0; n != max_n; ++n) {
if (callback && if (callback &&
n % (max_n / 100) == 0 && n % (max_n / 100) == 0 &&
callback((unsigned int)(ceil(progress * 100.0f))) != 0) { callback((unsigned int)(ceil(progress * 100.0f))) != 0) {
@ -203,7 +203,7 @@ static bool ethash_hash(
unsigned const num_full_pages = (unsigned) (full_size / page_size); unsigned const num_full_pages = (unsigned) (full_size / page_size);
for (unsigned i = 0; i != ETHASH_ACCESSES; ++i) { for (unsigned i = 0; i != ETHASH_ACCESSES; ++i) {
uint32_t const index = ((s_mix->words[0] ^ i) * FNV_PRIME ^ mix->words[i % MIX_WORDS]) % num_full_pages; uint64_t const index = ((s_mix->words[0] ^ i) * FNV_PRIME ^ mix->words[i % MIX_WORDS]) % num_full_pages;
for (unsigned n = 0; n != MIX_NODES; ++n) { for (unsigned n = 0; n != MIX_NODES; ++n) {
node const* dag_node; node const* dag_node;
@ -274,7 +274,7 @@ ethash_h256_t ethash_get_seedhash(uint64_t block_number)
{ {
ethash_h256_t ret; ethash_h256_t ret;
ethash_h256_reset(&ret); ethash_h256_reset(&ret);
const uint32_t epochs = block_number / ETHASH_EPOCH_LENGTH; uint64_t const epochs = block_number / ETHASH_EPOCH_LENGTH;
for (uint32_t i = 0; i < epochs; ++i) for (uint32_t i = 0; i < epochs; ++i)
SHA3_256(&ret, (uint8_t*)&ret, 32); SHA3_256(&ret, (uint8_t*)&ret, 32);
return ret; return ret;
@ -356,7 +356,7 @@ bool ethash_light_compute_internal(
ethash_return_value_t ethash_light_compute( ethash_return_value_t ethash_light_compute(
ethash_light_t light, ethash_light_t light,
ethash_h256_t const header_hash, ethash_h256_t const header_hash,
uint64_t const nonce uint64_t nonce
) )
{ {
ethash_return_value_t ret; ethash_return_value_t ret;
@ -373,7 +373,7 @@ ethash_return_value_t ethash_light_compute(
static bool ethash_mmap(struct ethash_full* ret, FILE* f) static bool ethash_mmap(struct ethash_full* ret, FILE* f)
{ {
int fd; int fd;
void* mmapped_data; char* mmapped_data;
ret->file = f; ret->file = f;
if ((fd = ethash_fileno(ret->file)) == -1) { if ((fd = ethash_fileno(ret->file)) == -1) {
return false; return false;
@ -389,7 +389,7 @@ static bool ethash_mmap(struct ethash_full* ret, FILE* f)
if (mmapped_data == MAP_FAILED) { if (mmapped_data == MAP_FAILED) {
return false; return false;
} }
ret->data = mmapped_data + ETHASH_DAG_MAGIC_NUM_SIZE; ret->data = (node*)(mmapped_data + ETHASH_DAG_MAGIC_NUM_SIZE);
return true; return true;
} }
@ -468,7 +468,7 @@ ethash_full_t ethash_full_new(ethash_light_t light, ethash_callback_t callback)
void ethash_full_delete(ethash_full_t full) void ethash_full_delete(ethash_full_t full)
{ {
// could check that munmap(..) == 0 but even if it did not can't really do anything here // could check that munmap(..) == 0 but even if it did not can't really do anything here
munmap(full->data, full->file_size); munmap(full->data, (size_t)full->file_size);
if (full->file) { if (full->file) {
fclose(full->file); fclose(full->file);
} }

4
internal.h

@ -102,7 +102,7 @@ bool ethash_light_compute_internal(
ethash_light_t light, ethash_light_t light,
uint64_t full_size, uint64_t full_size,
ethash_h256_t const header_hash, ethash_h256_t const header_hash,
uint64_t const nonce uint64_t nonce
); );
struct ethash_full { struct ethash_full {
@ -138,7 +138,7 @@ ethash_full_t ethash_full_new_internal(
void ethash_calculate_dag_item( void ethash_calculate_dag_item(
node* const ret, node* const ret,
const unsigned node_index, uint64_t node_index,
ethash_light_t const cache ethash_light_t const cache
); );

2
io.c

@ -26,7 +26,7 @@ enum ethash_io_rc ethash_io_prepare(
char const* dirname, char const* dirname,
ethash_h256_t const seedhash, ethash_h256_t const seedhash,
FILE** output_file, FILE** output_file,
size_t file_size, uint64_t file_size,
bool force_create bool force_create
) )
{ {

2
io.h

@ -77,7 +77,7 @@ enum ethash_io_rc ethash_io_prepare(
char const* dirname, char const* dirname,
ethash_h256_t const seedhash, ethash_h256_t const seedhash,
FILE** output_file, FILE** output_file,
size_t file_size, uint64_t file_size,
bool force_create bool force_create
); );

Loading…
Cancel
Save