Skip to content

Commit

Permalink
remove extern "C" and scanhash_sha256d()
Browse files Browse the repository at this point in the history
  • Loading branch information
KlausT committed Aug 11, 2017
1 parent 1bcd1b9 commit f6d7398
Show file tree
Hide file tree
Showing 22 changed files with 38 additions and 232 deletions.
2 changes: 1 addition & 1 deletion Algo256/blake256.cu
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ extern "C" {
extern "C" int blake256_rounds = 14;

/* hash by cpu with blake 256 */
extern "C" void blake256hash(void *output, const void *input, int8_t rounds = 14)
void blake256hash(void *output, const void *input, int8_t rounds = 14)
{
uchar hash[64];
sph_blake256_context ctx;
Expand Down
2 changes: 1 addition & 1 deletion Algo256/keccak256.cu
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ extern void keccak256_setBlock_80(int thr_id, void *pdata,const void *ptarget);
extern void keccak256_cpu_hash_80(int thr_id, uint32_t threads, uint32_t startNounce, uint32_t *h_nounce);

// CPU Hash
extern "C" void keccak256_hash(void *state, const void *input)
void keccak256_hash(void *state, const void *input)
{
sph_keccak_context ctx_keccak;

Expand Down
2 changes: 1 addition & 1 deletion JHA/jackpotcoin.cu
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ extern void jackpot_compactTest_cpu_hash_64(int thr_id, uint32_t threads, uint32
extern uint32_t cuda_check_hash_branch(int thr_id, uint32_t threads, uint32_t startNounce, uint32_t *d_nonceVector, uint32_t *d_inputHash);

// Original jackpothash Funktion aus einem miner Quelltext
extern "C" unsigned int jackpothash(void *state, const void *input)
unsigned int jackpothash(void *state, const void *input)
{
sph_blake512_context ctx_blake;
sph_groestl512_context ctx_groestl;
Expand Down
2 changes: 1 addition & 1 deletion cuda_nist5.cu
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ extern void quark_skein512_cpu_hash_64_final(int thr_id, uint32_t threads, uint3


// Original nist5hash Funktion aus einem miner Quelltext
extern "C" void nist5hash(void *state, const void *input)
void nist5hash(void *state, const void *input)
{
sph_blake512_context ctx_blake;
sph_groestl512_context ctx_groestl;
Expand Down
2 changes: 1 addition & 1 deletion groestlcoin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ do { \
#define SWAP32(x) swab32(x)

// CPU-groestl
extern "C" void groestlhash(void *state, const void *input)
void groestlhash(void *state, const void *input)
{
sph_groestl512_context ctx_groestl;

Expand Down
64 changes: 18 additions & 46 deletions miner.h
Original file line number Diff line number Diff line change
Expand Up @@ -261,37 +261,18 @@ extern "C" {
void sha256_transform(uint32_t *state, const uint32_t *block, int swap);
void sha256d(unsigned char *hash, const unsigned char *data, int len);

#if defined(__ARM_NEON__) || defined(__i386__) || defined(__x86_64__)
#define HAVE_SHA256_4WAY 0
int sha256_use_4way();
void sha256_init_4way(uint32_t *state);
void sha256_transform_4way(uint32_t *state, const uint32_t *block, int swap);
#endif

#if defined(__x86_64__) && defined(USE_AVX2)
#define HAVE_SHA256_8WAY 0
int sha256_use_8way();
void sha256_init_8way(uint32_t *state);
void sha256_transform_8way(uint32_t *state, const uint32_t *block, int swap);
#endif

extern int scanhash_sha256d(int thr_id, uint32_t *pdata,
uint32_t *ptarget, uint32_t max_nonce, uint32_t *hashes_done);

struct work_restart
{
volatile unsigned long restart;
char padding[128 - sizeof(unsigned long)];
};
extern struct work_restart *work_restart;

extern bool fulltest(const uint32_t *hash, const uint32_t *target);

#ifdef __cplusplus
}
#endif

extern unsigned char *scrypt_buffer_alloc();
struct work_restart
{
volatile unsigned long restart;
char padding[128 - sizeof(unsigned long)];
};
extern struct work_restart *work_restart;

bool fulltest(const uint32_t *hash, const uint32_t *target);

extern int scanhash_deep(int thr_id, uint32_t *pdata,
uint32_t *ptarget, uint32_t max_nonce,
Expand Down Expand Up @@ -549,18 +530,16 @@ extern uint32_t gpus_intensity[MAX_GPUS];

#define CL_WHT "\x1B[01;37m" /* white */

extern void format_hashrate(double hashrate, char *output);
extern void applog(int prio, const char *fmt, ...);
extern json_t *json_rpc_call(CURL *curl, const char *url, const char *userpass,
const char *rpc_req, bool, bool, int *);
extern void cbin2hex(char *out, const char *in, size_t len);
extern char *bin2hex(const unsigned char *in, size_t len);
extern bool hex2bin(unsigned char *p, const char *hexstr, size_t len);
extern int timeval_subtract(struct timeval *result, struct timeval *x,
struct timeval *y);
extern void diff_to_target(uint32_t *target, double diff);
extern void get_currentalgo(char* buf, int sz);
extern uint32_t device_intensity(int thr_id, const char *func, uint32_t defcount);
void format_hashrate(double hashrate, char *output);
void applog(int prio, const char *fmt, ...);
json_t *json_rpc_call(CURL *curl, const char *url, const char *userpass, const char *rpc_req, bool, bool, int *);
void cbin2hex(char *out, const char *in, size_t len);
char *bin2hex(const unsigned char *in, size_t len);
bool hex2bin(unsigned char *p, const char *hexstr, size_t len);
int timeval_subtract(struct timeval *result, struct timeval *x, struct timeval *y);
void diff_to_target(uint32_t *target, double diff);
void get_currentalgo(char* buf, int sz);
uint32_t device_intensity(int thr_id, const char *func, uint32_t defcount);

struct stratum_job {
char *job_id;
Expand Down Expand Up @@ -711,9 +690,6 @@ void applog_hash(unsigned char *hash);
void applog_compare_hash(unsigned char *hash, unsigned char *hash2);

void print_hash_tests(void);
#ifdef __cplusplus
extern "C" {
#endif

void blake256hash(void *output, const void *input, int8_t rounds);
void deephash(void *state, const void *input);
Expand All @@ -737,8 +713,4 @@ void x14hash(void *output, const void *input);
void x15hash(void *output, const void *input);
void x17hash(void *output, const void *input);

#ifdef __cplusplus
}
#endif

#endif /* __MINER_H__ */
2 changes: 1 addition & 1 deletion myriadgroestl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ void myriadgroestl_cpu_init(int thr_id, uint32_t threads);
void myriadgroestl_cpu_setBlock(int thr_id, void *data, void *pTargetIn);
void myriadgroestl_cpu_hash(int thr_id, uint32_t threads, uint32_t startNounce, uint32_t *nounce);

extern "C" void myriadhash(void *state, const void *input)
void myriadhash(void *state, const void *input)
{
uint32_t hashA[16], hashB[16];
sph_groestl512_context ctx_groestl;
Expand Down
2 changes: 1 addition & 1 deletion pentablake.cu
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ extern "C" {
#define TPB 192

/* hash by cpu with blake 256 */
extern "C" void pentablakehash(void *output, const void *input)
void pentablakehash(void *output, const void *input)
{
unsigned char hash[128];
#define hashB hash + 64
Expand Down
2 changes: 1 addition & 1 deletion quark/quarkcoin.cu
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ extern uint32_t cuda_check_hash_branch(int thr_id, uint32_t threads, uint32_t st
extern void cuda_check_quarkcoin(int thr_id, uint32_t threads, uint32_t startNounce, uint32_t *d_nonceVector, uint32_t *d_inputHash, uint32_t *foundnonces);

// Original Quarkhash Funktion aus einem miner Quelltext
extern "C" void quarkhash(void *state, const void *input)
void quarkhash(void *state, const void *input)
{
sph_blake512_context ctx_blake;
sph_bmw512_context ctx_bmw;
Expand Down
2 changes: 1 addition & 1 deletion qubit/deep.cu
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ extern void x11_echo512_cpu_init(int thr_id, uint32_t threads);
extern void x11_echo512_cpu_hash_64(int thr_id, uint32_t threads, uint32_t startNounce, uint32_t *d_hash);
extern void x11_echo512_cpu_hash_64_final(int thr_id, uint32_t threads, uint32_t startNounce, const uint32_t *d_hash, uint32_t target, uint32_t *h_found);

extern "C" void deephash(void *state, const void *input)
void deephash(void *state, const void *input)
{
// luffa1-cubehash2-shavite3-simd4-echo5
sph_luffa512_context ctx_luffa;
Expand Down
2 changes: 1 addition & 1 deletion qubit/qubit.cu
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ extern void quark_compactTest_cpu_init(int thr_id, uint32_t threads);
extern void quark_compactTest_cpu_hash_64(int thr_id, uint32_t threads, uint32_t startNounce, const uint32_t *inpHashes,
const uint32_t *d_noncesTrue, uint32_t *nrmTrue, uint32_t *d_noncesFalse, uint32_t *nrmFalse);

extern "C" void qubithash(void *state, const void *input)
void qubithash(void *state, const void *input)
{
// luffa1-cubehash2-shavite3-simd4-echo5

Expand Down
2 changes: 1 addition & 1 deletion skein.cu
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ extern void skein512_cpu_setBlock_80(int thr_id,void *pdata);
extern void skein512_cpu_hash_80_50(int thr_id, uint32_t threads, uint32_t startNounce, int swapu, uint64_t target, uint32_t *h_found);
extern void skein512_cpu_hash_80_52(int thr_id, uint32_t threads, uint32_t startNounce, int swapu, uint64_t target, uint32_t *h_found);

extern "C" void skeincoinhash(void *output, const void *input)
void skeincoinhash(void *output, const void *input)
{
sph_skein512_context ctx_skein;
SHA256_CTX sha256;
Expand Down
166 changes: 0 additions & 166 deletions sph/sha2.c
Original file line number Diff line number Diff line change
Expand Up @@ -461,169 +461,3 @@ static inline void sha256d_ms(uint32_t *hash, uint32_t *W,
}

#endif /* EXTERN_SHA256 */

#if HAVE_SHA256_4WAY

void sha256d_ms_4way(uint32_t *hash, uint32_t *data,
const uint32_t *midstate, const uint32_t *prehash);

static inline int scanhash_sha256d_4way(int thr_id, uint32_t *pdata,
uint32_t *ptarget, uint32_t max_nonce, uint32_t *hashes_done)
{
uint32_t data[4 * 64] __attribute__((aligned(128)));
uint32_t hash[4 * 8] __attribute__((aligned(32)));
uint32_t midstate[4 * 8] __attribute__((aligned(32)));
uint32_t prehash[4 * 8] __attribute__((aligned(32)));
uint32_t n = pdata[19] - 1;
const uint32_t first_nonce = pdata[19];
const uint32_t Htarg = ptarget[7];
int i, j;

memcpy(data, pdata + 16, 64);
sha256d_preextend(data);
for (i = 31; i >= 0; i--)
for (j = 0; j < 4; j++)
data[i * 4 + j] = data[i];

sha256_init(midstate);
sha256_transform(midstate, pdata, 0);
memcpy(prehash, midstate, 32);
sha256d_prehash(prehash, pdata + 16);
for (i = 7; i >= 0; i--) {
for (j = 0; j < 4; j++) {
midstate[i * 4 + j] = midstate[i];
prehash[i * 4 + j] = prehash[i];
}
}

do {
for (i = 0; i < 4; i++)
data[4 * 3 + i] = ++n;

sha256d_ms_4way(hash, data, midstate, prehash);

for (i = 0; i < 4; i++) {
if (swab32(hash[4 * 7 + i]) <= Htarg) {
pdata[19] = data[4 * 3 + i];
sha256d_80_swap(hash, pdata);
if (fulltest(hash, ptarget)) {
*hashes_done = n - first_nonce + 1;
return 1;
}
}
}
} while (n < max_nonce && !work_restart[thr_id].restart);

*hashes_done = n - first_nonce + 1;
pdata[19] = n;
return 0;
}

#endif /* HAVE_SHA256_4WAY */

#if HAVE_SHA256_8WAY

void sha256d_ms_8way(uint32_t *hash, uint32_t *data,
const uint32_t *midstate, const uint32_t *prehash);

static inline int scanhash_sha256d_8way(int thr_id, uint32_t *pdata,
uint32_t *ptarget, uint32_t max_nonce, uint32_t *hashes_done)
{
uint32_t data[8 * 64] __attribute__((aligned(128)));
uint32_t hash[8 * 8] __attribute__((aligned(32)));
uint32_t midstate[8 * 8] __attribute__((aligned(32)));
uint32_t prehash[8 * 8] __attribute__((aligned(32)));
uint32_t n = pdata[19] - 1;
const uint32_t first_nonce = pdata[19];
const uint32_t Htarg = ptarget[7];
int i, j;

memcpy(data, pdata + 16, 64);
sha256d_preextend(data);
for (i = 31; i >= 0; i--)
for (j = 0; j < 8; j++)
data[i * 8 + j] = data[i];

sha256_init(midstate);
sha256_transform(midstate, pdata, 0);
memcpy(prehash, midstate, 32);
sha256d_prehash(prehash, pdata + 16);
for (i = 7; i >= 0; i--) {
for (j = 0; j < 8; j++) {
midstate[i * 8 + j] = midstate[i];
prehash[i * 8 + j] = prehash[i];
}
}

do {
for (i = 0; i < 8; i++)
data[8 * 3 + i] = ++n;

sha256d_ms_8way(hash, data, midstate, prehash);

for (i = 0; i < 8; i++) {
if (swab32(hash[8 * 7 + i]) <= Htarg) {
pdata[19] = data[8 * 3 + i];
sha256d_80_swap(hash, pdata);
if (fulltest(hash, ptarget)) {
*hashes_done = n - first_nonce + 1;
return 1;
}
}
}
} while (n < max_nonce && !work_restart[thr_id].restart);

*hashes_done = n - first_nonce + 1;
pdata[19] = n;
return 0;
}

#endif /* HAVE_SHA256_8WAY */

int scanhash_sha256d(int thr_id, uint32_t *pdata, uint32_t *ptarget,
uint32_t max_nonce, uint32_t *hashes_done)
{
uint32_t data[64] /* __attribute__((aligned(128))) */;
uint32_t hash[8] /* __attribute__((aligned(32))) */;
uint32_t midstate[8] /* __attribute__((aligned(32))) */;
uint32_t prehash[8] /* __attribute__((aligned(32))) */;
uint32_t n = pdata[19] - 1;
const uint32_t first_nonce = pdata[19];
const uint32_t Htarg = ptarget[7];

#if HAVE_SHA256_8WAY
if (sha256_use_8way())
return scanhash_sha256d_8way(thr_id, pdata, ptarget,
max_nonce, hashes_done);
#endif
#if HAVE_SHA256_4WAY
if (sha256_use_4way())
return scanhash_sha256d_4way(thr_id, pdata, ptarget,
max_nonce, hashes_done);
#endif

memcpy(data, pdata + 16, 64);
sha256d_preextend(data);

sha256_init(midstate);
sha256_transform(midstate, pdata, 0);
memcpy(prehash, midstate, 32);
sha256d_prehash(prehash, pdata + 16);

do {
data[3] = ++n;
sha256d_ms(hash, data, midstate, prehash);
if (swab32(hash[7]) <= Htarg) {
pdata[19] = data[3];
sha256d_80_swap(hash, pdata);
if (fulltest(hash, ptarget)) {
*hashes_done = n - first_nonce + 1;
return 1;
}
}
} while (n < max_nonce && !work_restart[thr_id].restart);

*hashes_done = n - first_nonce + 1;
pdata[19] = n;
return 0;
}
2 changes: 1 addition & 1 deletion util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ struct timeval *y)
return (start > end);
}

extern "C" bool fulltest(const uint32_t *hash, const uint32_t *target)
bool fulltest(const uint32_t *hash, const uint32_t *target)
{
int i;
bool rc = true;
Expand Down
2 changes: 1 addition & 1 deletion x11/fresh.cu
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ extern void quark_compactTest_cpu_hash_64(int thr_id, uint32_t threads, uint32_t
const uint32_t *d_noncesTrue, uint32_t *nrmTrue, uint32_t *d_noncesFalse, uint32_t *nrmFalse);

// CPU Hash
extern "C" void fresh_hash(void *state, const void *input)
void fresh_hash(void *state, const void *input)
{
// shavite-simd-shavite-simd-echo

Expand Down
2 changes: 1 addition & 1 deletion x11/s3.cu
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ extern void quark_skein512_cpu_hash_64(int thr_id, uint32_t threads, uint32_t st
extern void quark_skein512_cpu_hash_64_final(int thr_id, uint32_t threads, uint32_t startNounce, uint32_t *d_nonceVector, uint32_t *d_hash, uint32_t *h_found, uint32_t target);

/* CPU HASH */
extern "C" void s3hash(void *output, const void *input)
void s3hash(void *output, const void *input)
{
sph_shavite512_context ctx_shavite;
sph_simd512_context ctx_simd;
Expand Down
2 changes: 1 addition & 1 deletion x11/x11.cu
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ extern void quark_compactTest_cpu_hash_64(int thr_id, uint32_t threads, uint32_t
const uint32_t *d_noncesTrue, uint32_t *nrmTrue, uint32_t *d_noncesFalse, uint32_t *nrmFalse);

// X11 CPU Hash
extern "C" void x11hash(void *output, const void *input)
void x11hash(void *output, const void *input)
{
// blake1-bmw2-grs3-skein4-jh5-keccak6-luffa7-cubehash8-shavite9-simd10-echo11

Expand Down
Loading

0 comments on commit f6d7398

Please sign in to comment.