Browse Source

Miscellaneous style fixes

cl-refactor
Lefteris Karapetsas 10 years ago
parent
commit
492537b7c4
  1. 30
      endian.h
  2. 7
      fnv.h
  3. 30
      internal.h
  4. 6
      sha3.h
  5. 4
      sha3_cryptopp.cpp
  6. 4
      sha3_cryptopp.h
  7. 4
      util.c
  8. 2
      util.h

30
endian.h

@ -42,11 +42,11 @@
#if LITTLE_ENDIAN == BYTE_ORDER
#define fix_endian32(dst_ ,src_) dst_ = src_
#define fix_endian32_same(val_)
#define fix_endian32_same(val_)
#define fix_endian64(dst_, src_) dst_ = src_
#define fix_endian64_same(val_)
#define fix_endian64_same(val_)
#define fix_endian_arr32(arr_, size_)
#define fix_endian_arr64(arr_, size_)
#define fix_endian_arr64(arr_, size_)
#elif BIG_ENDIAN == BYTE_ORDER
@ -54,18 +54,18 @@
#define fix_endian32_same(val_) val_ = ethash_swap_u32(val_)
#define fix_endian64(dst_, src_) dst_ = ethash_swap_u64(src_
#define fix_endian64_same(val_) val_ = ethash_swap_u64(val_)
#define fix_endian_arr32(arr_, size_) \
do { \
for (unsigned i_ = 0; i_ < (size_), ++i_) { \
arr_[i_] = ethash_swap_u32(arr_[i_]); \
} \
while (0)
#define fix_endian_arr64(arr_, size_) \
do { \
for (unsigned i_ = 0; i_ < (size_), ++i_) { \
arr_[i_] = ethash_swap_u64(arr_[i_]); \
} \
while (0) \
#define fix_endian_arr32(arr_, size_) \
do { \
for (unsigned i_ = 0; i_ < (size_), ++i_) { \
arr_[i_] = ethash_swap_u32(arr_[i_]); \
} \
while (0)
#define fix_endian_arr64(arr_, size_) \
do { \
for (unsigned i_ = 0; i_ < (size_), ++i_) { \
arr_[i_] = ethash_swap_u64(arr_[i_]); \
} \
while (0) \
#else
# error "endian not supported"

7
fnv.h

@ -29,10 +29,11 @@ extern "C" {
#define FNV_PRIME 0x01000193
static inline uint32_t fnv_hash(const uint32_t x, const uint32_t y) {
return x*FNV_PRIME ^ y;
static inline uint32_t fnv_hash(uint32_t const x, uint32_t const y)
{
return x * FNV_PRIME ^ y;
}
#ifdef __cplusplus
}
#endif
#endif

30
internal.h

@ -32,26 +32,30 @@ typedef union node {
} node;
struct ethash_light {
ethash_cache *cache;
ethash_cache* cache;
};
struct ethash_full {
FILE *file;
FILE* file;
size_t file_size;
ethash_cache *cache;
node *data;
ethash_cache* cache;
node* data;
ethash_callback_t callback;
};
void ethash_calculate_dag_item(node *const ret,
const unsigned node_index,
ethash_params const *params,
ethash_cache const *cache);
void ethash_quick_hash(ethash_h256_t *return_hash,
ethash_h256_t const *header_hash,
const uint64_t nonce,
ethash_h256_t const *mix_hash);
void ethash_calculate_dag_item(
node* const ret,
const unsigned node_index,
ethash_params const* params,
ethash_cache const* cache
);
void ethash_quick_hash(
ethash_h256_t* return_hash,
ethash_h256_t const* header_hash,
const uint64_t nonce,
ethash_h256_t const* mix_hash
);
#ifdef __cplusplus
}

6
sha3.h

@ -11,17 +11,17 @@ extern "C" {
struct ethash_h256;
#define decsha3(bits) \
int sha3_##bits(uint8_t*, size_t, const uint8_t*, size_t);
int sha3_##bits(uint8_t*, size_t, uint8_t const*, size_t);
decsha3(256)
decsha3(512)
static inline void SHA3_256(struct ethash_h256 const* ret, uint8_t const *data, const size_t size)
static inline void SHA3_256(struct ethash_h256 const* ret, uint8_t const* data, size_t const size)
{
sha3_256((uint8_t*)ret, 32, data, size);
}
static inline void SHA3_512(uint8_t *ret, uint8_t const *data, const size_t size)
static inline void SHA3_512(uint8_t* ret, uint8_t const* data, size_t const size)
{
sha3_512(ret, 64, data, size);
}

4
sha3_cryptopp.cpp

@ -25,12 +25,12 @@
extern "C" {
struct ethash_h256;
typedef struct ethash_h256 ethash_h256_t;
void SHA3_256(ethash_h256_t const* ret, const uint8_t *data, size_t size)
void SHA3_256(ethash_h256_t const* ret, uint8_t const* data, size_t size)
{
CryptoPP::SHA3_256().CalculateDigest((uint8_t*)ret, data, size);
}
void SHA3_512(uint8_t *const ret, const uint8_t *data, size_t size)
void SHA3_512(uint8_t* const ret, uint8_t const* data, size_t size)
{
CryptoPP::SHA3_512().CalculateDigest(ret, data, size);
}

4
sha3_cryptopp.h

@ -11,8 +11,8 @@ extern "C" {
struct ethash_h256;
typedef struct ethash_h256 ethash_h256_t;
void SHA3_256(ethash_h256_t *const ret, const uint8_t *data, size_t size);
void SHA3_512(uint8_t *const ret, const uint8_t *data, size_t size);
void SHA3_256(ethash_h256_t const* ret, uint8_t const* data, size_t size);
void SHA3_512(uint8_t* const ret, uint8_t const* data, size_t size);
#ifdef __cplusplus
}

4
util.c

@ -25,9 +25,9 @@
#ifdef _MSC_VER
// foward declare without all of Windows.h
__declspec(dllimport) void __stdcall OutputDebugStringA(const char* lpOutputString);
__declspec(dllimport) void __stdcall OutputDebugStringA(char const* lpOutputString);
void debugf(const char *str, ...)
void debugf(char const* str, ...)
{
va_list args;
va_start(args, str);

2
util.h

@ -27,7 +27,7 @@ extern "C" {
#endif
#ifdef _MSC_VER
void debugf(const char *str, ...);
void debugf(char const* str, ...);
#else
#define debugf printf
#endif

Loading…
Cancel
Save