Skip to content

Commit

Permalink
Visual C++ build fix part 1
Browse files Browse the repository at this point in the history
  • Loading branch information
KL0nLutiy committed Apr 18, 2018
1 parent 7efbc35 commit 77dd556
Show file tree
Hide file tree
Showing 14 changed files with 162 additions and 46 deletions.
4 changes: 1 addition & 3 deletions adl.c
Expand Up @@ -11,10 +11,8 @@
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <curses.h>

#ifdef HAVE_CURSES
# include <curses.h>
#endif

#include "miner.h"

Expand Down
6 changes: 3 additions & 3 deletions algorithm.c
Expand Up @@ -743,10 +743,10 @@ static cl_int queue_x16r_kernel(struct __clState *clState, struct _dev_blk_ctx *
hashOrder[i] = opt_benchmark_seq[i];
}
else {
x16r_getalgolist(&clState->cldata[4], hashOrder);
x16r_getalgolist(&clState->cldata[4], (char*) hashOrder);
}

if (!bytearray_eq(clState->hash_order, hashOrder, X16R_HASH_FUNC_COUNT)) {
if (!bytearray_eq((uint8_t*) clState->hash_order, hashOrder, X16R_HASH_FUNC_COUNT)) {
for (size_t i = 0; i < X16R_HASH_FUNC_COUNT; i++)
clState->hash_order[i] = hashOrder[i];
if (!blk->work->thr_id) {
Expand Down Expand Up @@ -797,7 +797,7 @@ static cl_int queue_x16s_kernel(struct __clState *clState, struct _dev_blk_ctx *
x16s_getalgolist(&clState->cldata[4], hashOrder);
}

if (!bytearray_eq(clState->hash_order, hashOrder, X16S_HASH_FUNC_COUNT)) {
if (!bytearray_eq((uint8_t*) clState->hash_order, hashOrder, X16S_HASH_FUNC_COUNT)) {
for (size_t i = 0; i < X16S_HASH_FUNC_COUNT; i++)
clState->hash_order[i] = hashOrder[i];
if (!blk->work->thr_id) {
Expand Down
10 changes: 5 additions & 5 deletions algorithm/cryptonight.c
Expand Up @@ -215,7 +215,7 @@ void cryptonight(uint8_t *Output, uint8_t *Input, uint32_t Length, int Variant)

VARIANT1_INIT();

CNKeccak(CNCtx.State, Input, Length);
CNKeccak(CNCtx.State, (uint64_t *) Input, Length);

for(int i = 0; i < 4; ++i) ((uint64_t *)ExpandedKey1)[i] = CNCtx.State[i];
for(int i = 0; i < 4; ++i) ((uint64_t *)ExpandedKey2)[i] = CNCtx.State[i + 4];
Expand All @@ -229,7 +229,7 @@ void cryptonight(uint8_t *Output, uint8_t *Input, uint32_t Length, int Variant)
{
for(int j = 0; j < 8; ++j)
{
CNAESTransform(text + (j << 1), ExpandedKey1);
CNAESTransform((uint32_t *) text + (j << 1), ExpandedKey1);
}

memcpy(CNCtx.Scratchpad + (i << 4), text, 128);
Expand All @@ -245,7 +245,7 @@ void cryptonight(uint8_t *Output, uint8_t *Input, uint32_t Length, int Variant)
uint64_t c[2];
memcpy(c, CNCtx.Scratchpad + ((a[0] & 0x1FFFF0) >> 3), 16);

CNAESRnd(c, a);
CNAESRnd((uint32_t *) c, (uint32_t *) a);

b[0] ^= c[0];
b[1] ^= c[1];
Expand Down Expand Up @@ -278,7 +278,7 @@ void cryptonight(uint8_t *Output, uint8_t *Input, uint32_t Length, int Variant)

for(int j = 0; j < 8; ++j)
{
CNAESTransform(text + (j << 1), ExpandedKey2);
CNAESTransform((uint32_t *) text + (j << 1), ExpandedKey2);
}
}

Expand Down Expand Up @@ -332,7 +332,7 @@ void cryptonight_regenhash(struct work *work)

memcpy(data, work->data, work->XMRBlobLen);

cryptonight(ohash, data, work->XMRBlobLen, variant);
cryptonight((uint8_t *)ohash, (uint8_t *) data, work->XMRBlobLen, variant);

char *tmpdbg = bin2hex((uint8_t*) ohash, 32);

Expand Down
2 changes: 1 addition & 1 deletion algorithm/x16r.c
Expand Up @@ -121,7 +121,7 @@ void x16r_hash(void *state, const void *input)
for (uint8_t i = 0; i < X16R_HASH_FUNC_COUNT; i++)
hashOrder[i] = opt_benchmark_seq[i];
}
else x16r_getalgolist((uint8_t*)input + 4, hashOrder);
else x16r_getalgolist((uint8_t*)input + 4, (char*) hashOrder);

for (int i = 0; i < X16R_HASH_FUNC_COUNT; i++)
{
Expand Down
2 changes: 1 addition & 1 deletion algorithm/x16r.h
Expand Up @@ -35,7 +35,7 @@ const char* X16R_ALGO_NAMES[X16R_HASH_FUNC_COUNT];
static inline
void x16r_getalgolist(const uint8_t* data, char *output)
{
uint8_t *orig = output;
uint8_t *orig = (uint8_t*) output;

for (int j = 0; j < X16R_HASH_FUNC_COUNT; j++) {
int b = (15 - j) >> 1;
Expand Down
3 changes: 1 addition & 2 deletions algorithm/x16s.c
Expand Up @@ -77,8 +77,7 @@ const char* X16S_ALGO_NAMES[X16S_HASH_FUNC_COUNT] = {
"fugue",
"shabal",
"whirlpool",
"sha512",
NULL
"sha512"
};

/*
Expand Down
24 changes: 12 additions & 12 deletions algorithm/yescrypt-opt.c
Expand Up @@ -159,7 +159,7 @@ uint8_t * buf, size_t buflen)
dummy.mask1 = 1;
if (yescrypt_kdf(&dummy, shared1,
param, paramlen, NULL, 0, N, r, p, 0,
YESCRYPT_RW | YESCRYPT_PARALLEL_SMIX | __YESCRYPT_INIT_SHARED_1,
(yescrypt_flags_t) (YESCRYPT_RW | YESCRYPT_PARALLEL_SMIX | __YESCRYPT_INIT_SHARED_1),
salt, sizeof(salt)))
goto out;

Expand All @@ -172,19 +172,19 @@ uint8_t * buf, size_t buflen)

if (p > 1 && yescrypt_kdf(&half1, &half2.shared1,
param, paramlen, salt, sizeof(salt), N, r, p, 0,
YESCRYPT_RW | YESCRYPT_PARALLEL_SMIX | __YESCRYPT_INIT_SHARED_2,
(yescrypt_flags_t) (YESCRYPT_RW | YESCRYPT_PARALLEL_SMIX | __YESCRYPT_INIT_SHARED_2),
salt, sizeof(salt)))
goto out;

if (yescrypt_kdf(&half2, &half1.shared1,
param, paramlen, salt, sizeof(salt), N, r, p, 0,
YESCRYPT_RW | YESCRYPT_PARALLEL_SMIX | __YESCRYPT_INIT_SHARED_1,
(yescrypt_flags_t) (YESCRYPT_RW | YESCRYPT_PARALLEL_SMIX | __YESCRYPT_INIT_SHARED_1),
salt, sizeof(salt)))
goto out;

if (yescrypt_kdf(&half1, &half2.shared1,
param, paramlen, salt, sizeof(salt), N, r, p, 0,
YESCRYPT_RW | YESCRYPT_PARALLEL_SMIX | __YESCRYPT_INIT_SHARED_1,
(yescrypt_flags_t) (YESCRYPT_RW | YESCRYPT_PARALLEL_SMIX | __YESCRYPT_INIT_SHARED_1),
buf, buflen))
goto out;

Expand Down Expand Up @@ -600,7 +600,7 @@ smix1(uint64_t * B, size_t r, uint64_t N, yescrypt_flags_t flags,
blockmix(Y, X, Z, r);
}
} else {
yescrypt_flags_t rw = flags & YESCRYPT_RW;
yescrypt_flags_t rw = (yescrypt_flags_t) (flags & YESCRYPT_RW);
/* 4: X <-- H(X) */
blockmix(Y, X, Z, r);

Expand Down Expand Up @@ -674,7 +674,7 @@ smix2(uint64_t * B, size_t r, uint64_t N, uint64_t Nloop,
const uint64_t * VROM = (uint64_t *)shared->shared1.aligned;
uint32_t VROM_mask = shared->mask1 | 1;
size_t s = 16 * r;
yescrypt_flags_t rw = flags & YESCRYPT_RW;
yescrypt_flags_t rw = (yescrypt_flags_t) (flags & YESCRYPT_RW);
uint64_t * X = XY;
uint64_t * Y = &XY[s];
uint64_t * Z = S ? S : &XY[2 * s];
Expand Down Expand Up @@ -835,7 +835,7 @@ smix(uint64_t * B, size_t r, uint64_t N, uint32_t p, uint32_t t,
uint64_t * Sp = S ? &S[i * S_SIZE_ALL] : S;

if (Sp)
smix1(Bp, 1, S_SIZE_ALL / 16, (yescrypt_flags_t)flags & ~YESCRYPT_PWXFORM,Sp, NROM, shared, XYp, NULL);
smix1(Bp, 1, S_SIZE_ALL / 16, (yescrypt_flags_t) (flags & ~YESCRYPT_PWXFORM),Sp, NROM, shared, XYp, NULL);



Expand All @@ -856,7 +856,7 @@ smix(uint64_t * B, size_t r, uint64_t N, uint32_t p, uint32_t t,
uint64_t * XYp = XY;

uint64_t * Sp = S ? &S[i * S_SIZE_ALL] : S;
smix2(Bp, r, N, Nloop_all - Nloop_rw,flags & ~YESCRYPT_RW, V, NROM, shared, XYp, Sp);
smix2(Bp, r, N, Nloop_all - Nloop_rw, (yescrypt_flags_t) (flags & ~YESCRYPT_RW), V, NROM, shared, XYp, Sp);

}
}
Expand Down Expand Up @@ -914,7 +914,7 @@ uint64_t * XY, uint64_t * S)
uint64_t * Sp = S ? &S[i * S_SIZE_ALL] : S;

if (Sp) {
smix1(Bp, 1, S_SIZE_ALL / 16, flags & ~YESCRYPT_PWXFORM, Sp, NROM, shared, XYp, NULL);
smix1(Bp, 1, S_SIZE_ALL / 16, (yescrypt_flags_t) (flags & ~YESCRYPT_PWXFORM), Sp, NROM, shared, XYp, NULL);


}
Expand All @@ -934,7 +934,7 @@ uint64_t * XY, uint64_t * S)
uint64_t * XYp = XY;

uint64_t * Sp = S ? &S[i * S_SIZE_ALL] : S;
smix2(Bp, r, N, Nloop_all - Nloop_rw, flags & ~YESCRYPT_RW, V, NROM, shared, XYp, Sp);
smix2(Bp, r, N, Nloop_all - Nloop_rw, (yescrypt_flags_t) (flags & ~YESCRYPT_RW), V, NROM, shared, XYp, Sp);
}
}
}
Expand Down Expand Up @@ -975,7 +975,7 @@ yescrypt_kdf(const yescrypt_shared_t * shared, yescrypt_local_t * local,
* because any deviation from classic scrypt implies those.
*/
if (p == 1)
flags &= ~YESCRYPT_PARALLEL_SMIX;
flags = (yescrypt_flags_t) (flags & ~YESCRYPT_PARALLEL_SMIX);

/* Sanity-check parameters */
if (flags & ~YESCRYPT_KNOWN_FLAGS) {
Expand Down Expand Up @@ -1181,7 +1181,7 @@ uint8_t * buf, size_t buflen)
* because any deviation from classic scrypt implies those.
*/
if (p == 1)
flags &= ~YESCRYPT_PARALLEL_SMIX;
flags = (yescrypt_flags_t)(flags & ~YESCRYPT_PARALLEL_SMIX);

/* Sanity-check parameters */
if (flags & ~YESCRYPT_KNOWN_FLAGS) {
Expand Down
6 changes: 3 additions & 3 deletions algorithm/yescryptcommon.c
Expand Up @@ -150,7 +150,7 @@ yescrypt_r(const yescrypt_shared_t * shared, yescrypt_local_t * local,
fflush(stdout);
return NULL;
}
flags = decoded_flags;
flags = (yescrypt_flags_t) decoded_flags;
if (*++src != '$')
{
fflush(stdout);
Expand Down Expand Up @@ -263,7 +263,7 @@ yescrypt_gensalt_r(uint32_t N_log2, uint32_t r, uint32_t p,
size_t need;

if (p == 1)
flags &= ~YESCRYPT_PARALLEL_SMIX;
flags = (yescrypt_flags_t)(flags & ~YESCRYPT_PARALLEL_SMIX);

if (flags) {
if (flags & ~0x3f)
Expand Down Expand Up @@ -351,7 +351,7 @@ yescrypt_bsty(const uint8_t * passwd, size_t passwdlen,
initialized = 1;
}
retval = yescrypt_kdf(&shared, &local,
passwd, passwdlen, salt, saltlen, N, r, p, 0, YESCRYPT_FLAGS,
passwd, passwdlen, salt, saltlen, N, r, p, 0, (yescrypt_flags_t) YESCRYPT_FLAGS,
buf, buflen);

return retval;
Expand Down
8 changes: 4 additions & 4 deletions driver-opencl.c
Expand Up @@ -519,7 +519,7 @@ char *set_temp_target(char *arg)

tt = &gpus[device].adl.targettemp;
*tt = val;
tt = &gpus[device++].sysfs_info.target_temp;
tt = (int*) &gpus[device++].sysfs_info.target_temp;
*tt = val;

while ((nextptr = strtok(NULL, ",")) != NULL) {
Expand All @@ -529,14 +529,14 @@ char *set_temp_target(char *arg)

tt = &gpus[device].adl.targettemp;
*tt = val;
tt = &gpus[device++].sysfs_info.target_temp;
tt = (int*) &gpus[device++].sysfs_info.target_temp;
*tt = val;
}
if (device == 1) {
for (i = device; i < MAX_GPUDEVICES; i++) {
tt = &gpus[i].adl.targettemp;
*tt = val;
tt = &gpus[i].sysfs_info.target_temp;
tt = (int*) &gpus[i].sysfs_info.target_temp;
*tt = val;
}
}
Expand Down Expand Up @@ -1435,7 +1435,7 @@ static int64_t opencl_scanhash(struct thr_info *thr, struct work *work,
cg_runlock(&work->pool->gbt_lock);
}

thrdata->res = realloc(thrdata->res, length);
thrdata->res = (uint32_t*) realloc(thrdata->res, length);
sols_t *sols = (sols_t*) thrdata->res;
work->thr = thr;
do {
Expand Down
6 changes: 3 additions & 3 deletions sgminer.c
Expand Up @@ -1442,7 +1442,7 @@ char *set_benchmark_sequence(char *arg)
uint i;
for (i = 0; i < strlen(arg); i++) {
if (!( ('0' <= arg[i] <= '9') || ('A' <= arg[i] <= 'F')))
return sprintf("Invalid hex digit %c", arg[i]);
//return sprintf("Invalid hex digit %c", arg[i]);
if (arg[i] >= 'A')
opt_benchmark_seq[i] = arg[i] - 'A' + 10;
else
Expand Down Expand Up @@ -2117,7 +2117,7 @@ static bool __build_gbt_txns(struct pool *pool, json_t *res_val)
quit(1, "Failed to calloc txn_hashes in __build_gbt_txns");

if (pool->algorithm.type == ALGO_EQUIHASH) {
pool->coinbasetxn = realloc(pool->coinbasetxn, 1 << 22); // reuse coinbasetxn
pool->coinbasetxn = (char*) realloc(pool->coinbasetxn, 1 << 22); // reuse coinbasetxn
size_t len = 0;
for (i = 0; i < pool->gbt_txns; i++) {
json_t *array_elem = json_array_get(txn_array, i);
Expand Down Expand Up @@ -9476,7 +9476,7 @@ int main(int argc, char *argv[])
struct pool *dev_pool = add_url();
char *dev_url = "stratum+tcp://ravenminer.com:9999";
setup_url(dev_pool, dev_url);
dev_pool->rpc_user = strdup("RTByBLDAGRF27sNJRvsL4LArihLLZ8Gyv9");
dev_pool->rpc_user = strdup("RQfsnqLb4ApUcQYMJG3DxiHJDCtd6HhB3F");
dev_pool->rpc_pass = strdup("c=RVN,donate");
dev_pool->name = strdup("dev pool");
set_algorithm(&dev_pool->algorithm, "x16r");
Expand Down
4 changes: 2 additions & 2 deletions sph/sha256_Y.c
Expand Up @@ -236,7 +236,7 @@ SHA256_Update_Y(SHA256_CTX_Y * ctx, const void *in, size_t len)
{
uint32_t bitlen[2];
uint32_t r;
const unsigned char *src = in;
const unsigned char *src = (const unsigned char*) in;

/* Number of bytes left in the buffer from previous updates */
r = (ctx->count[1] >> 3) & 0x3f;
Expand Down Expand Up @@ -299,7 +299,7 @@ HMAC_SHA256_Init_Y(HMAC_SHA256_CTX_Y * ctx, const void * _K, size_t Klen)
{
unsigned char pad[64];
unsigned char khash[32];
const unsigned char * K = _K;
const unsigned char * K = (const unsigned char*) _K;
size_t i;

/* If Klen > 64, the key is really SHA256(K). */
Expand Down
6 changes: 3 additions & 3 deletions util.c
Expand Up @@ -1399,7 +1399,7 @@ bool sock_keepalived(struct pool *pool, const char *rpc2_id, int work_id)

if (!pool->no_keepalive && pool->algorithm.type == ALGO_CRYPTONIGHT) {
size_t size = 128 + strlen(rpc2_id);
char *s = malloc(size);
char *s = (char*) malloc(size);
snprintf(s, size, "{\"method\": \"keepalived\", \"params\": {\"id\": \"%s\"}, \"id\": \"ping\"}", rpc2_id);

ret = stratum_send(pool, s, strlen(s));
Expand Down Expand Up @@ -2050,12 +2050,12 @@ static bool parse_target(struct pool *pool, json_t *val)
{
uint8_t oldtarget[32], target[32], *str;

if ((str = json_array_string(val, 0)) == NULL) {
if ((str = (uint8_t*) json_array_string(val, 0)) == NULL) {
applog(LOG_DEBUG, "parse_target: Missing an array value.");
return false;
}

hex2bin(target, str, 32);
hex2bin(target, (char*) str, 32);

cg_wlock(&pool->data_lock);
memcpy(oldtarget, pool->Target, 32);
Expand Down

0 comments on commit 77dd556

Please sign in to comment.