From f6d73986a88e3218b124fc55463131aff6dbe84c Mon Sep 17 00:00:00 2001 From: KlausT Date: Fri, 11 Aug 2017 07:25:35 +0200 Subject: [PATCH] remove extern "C" and scanhash_sha256d() --- Algo256/blake256.cu | 2 +- Algo256/keccak256.cu | 2 +- JHA/jackpotcoin.cu | 2 +- cuda_nist5.cu | 2 +- groestlcoin.cpp | 2 +- miner.h | 64 +++++------------ myriadgroestl.cpp | 2 +- pentablake.cu | 2 +- quark/quarkcoin.cu | 2 +- qubit/deep.cu | 2 +- qubit/qubit.cu | 2 +- skein.cu | 2 +- sph/sha2.c | 166 ------------------------------------------- util.cpp | 2 +- x11/fresh.cu | 2 +- x11/s3.cu | 2 +- x11/x11.cu | 2 +- x13/x13.cu | 2 +- x15/whirlpool.cu | 2 +- x15/x14.cu | 2 +- x15/x15.cu | 2 +- x17/x17.cu | 2 +- 22 files changed, 38 insertions(+), 232 deletions(-) diff --git a/Algo256/blake256.cu b/Algo256/blake256.cu index e8bf6688..0cc43ec5 100644 --- a/Algo256/blake256.cu +++ b/Algo256/blake256.cu @@ -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; diff --git a/Algo256/keccak256.cu b/Algo256/keccak256.cu index 80c237ec..cec9ded7 100644 --- a/Algo256/keccak256.cu +++ b/Algo256/keccak256.cu @@ -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; diff --git a/JHA/jackpotcoin.cu b/JHA/jackpotcoin.cu index 94a23bf0..eaa5ea16 100644 --- a/JHA/jackpotcoin.cu +++ b/JHA/jackpotcoin.cu @@ -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; diff --git a/cuda_nist5.cu b/cuda_nist5.cu index 2d55a809..a4270cde 100644 --- a/cuda_nist5.cu +++ b/cuda_nist5.cu @@ -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; diff --git a/groestlcoin.cpp b/groestlcoin.cpp index c466f8cb..9897a668 100644 --- a/groestlcoin.cpp +++ b/groestlcoin.cpp @@ -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; diff --git a/miner.h b/miner.h index 2e0eb900..12fc2f1f 100644 --- a/miner.h +++ b/miner.h @@ -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, @@ -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; @@ -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); @@ -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__ */ diff --git a/myriadgroestl.cpp b/myriadgroestl.cpp index da8f49af..39774c3a 100644 --- a/myriadgroestl.cpp +++ b/myriadgroestl.cpp @@ -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; diff --git a/pentablake.cu b/pentablake.cu index 3c469969..0c791dad 100644 --- a/pentablake.cu +++ b/pentablake.cu @@ -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 diff --git a/quark/quarkcoin.cu b/quark/quarkcoin.cu index 1dfc143d..c63d11fb 100644 --- a/quark/quarkcoin.cu +++ b/quark/quarkcoin.cu @@ -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; diff --git a/qubit/deep.cu b/qubit/deep.cu index 975af981..11d6ad5d 100644 --- a/qubit/deep.cu +++ b/qubit/deep.cu @@ -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; diff --git a/qubit/qubit.cu b/qubit/qubit.cu index 6df6a7d8..0961eac3 100644 --- a/qubit/qubit.cu +++ b/qubit/qubit.cu @@ -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 diff --git a/skein.cu b/skein.cu index f85da12b..8336a91c 100644 --- a/skein.cu +++ b/skein.cu @@ -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; diff --git a/sph/sha2.c b/sph/sha2.c index 19f1eb8b..5780c769 100644 --- a/sph/sha2.c +++ b/sph/sha2.c @@ -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; -} diff --git a/util.cpp b/util.cpp index aeb0ef51..0552c83f 100644 --- a/util.cpp +++ b/util.cpp @@ -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; diff --git a/x11/fresh.cu b/x11/fresh.cu index c665c1a4..959adc6e 100644 --- a/x11/fresh.cu +++ b/x11/fresh.cu @@ -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 diff --git a/x11/s3.cu b/x11/s3.cu index 3991c2b0..39abc03e 100644 --- a/x11/s3.cu +++ b/x11/s3.cu @@ -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; diff --git a/x11/x11.cu b/x11/x11.cu index 3f35cc25..b5aa1159 100644 --- a/x11/x11.cu +++ b/x11/x11.cu @@ -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 diff --git a/x13/x13.cu b/x13/x13.cu index 11899158..1dd3ee23 100644 --- a/x13/x13.cu +++ b/x13/x13.cu @@ -73,7 +73,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); // X13 Hashfunktion -extern "C" void x13hash(void *output, const void *input) +void x13hash(void *output, const void *input) { // blake1-bmw2-grs3-skein4-jh5-keccak6-luffa7-cubehash8-shavite9-simd10-echo11-hamsi12-fugue13 diff --git a/x15/whirlpool.cu b/x15/whirlpool.cu index 4dfe27b8..0f891407 100644 --- a/x15/whirlpool.cu +++ b/x15/whirlpool.cu @@ -17,7 +17,7 @@ extern uint32_t* whirlpool512_cpu_finalhash_64(int thr_id, uint32_t threads, uin // CPU Hash function -extern "C" void wcoinhash(void *state, const void *input) +void wcoinhash(void *state, const void *input) { sph_whirlpool_context ctx_whirlpool; diff --git a/x15/x14.cu b/x15/x14.cu index c4d95e9d..bb22ffe6 100644 --- a/x15/x14.cu +++ b/x15/x14.cu @@ -66,7 +66,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); // X14 CPU Hash function -extern "C" void x14hash(void *output, const void *input) +void x14hash(void *output, const void *input) { unsigned char hash[128]; // uint32_t hashA[16], hashB[16]; #define hashB hash+64 diff --git a/x15/x15.cu b/x15/x15.cu index df0739cb..61611de1 100644 --- a/x15/x15.cu +++ b/x15/x15.cu @@ -73,7 +73,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); // X15 CPU Hash function -extern "C" void x15hash(void *output, const void *input) +void x15hash(void *output, const void *input) { sph_blake512_context ctx_blake; sph_bmw512_context ctx_bmw; diff --git a/x17/x17.cu b/x17/x17.cu index 52048c5a..e9fe13c7 100644 --- a/x17/x17.cu +++ b/x17/x17.cu @@ -83,7 +83,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); // X17 Hashfunktion -extern "C" void x17hash(void *output, const void *input) +void x17hash(void *output, const void *input) { // blake1-bmw2-grs3-skein4-jh5-keccak6-luffa7-cubehash8-shavite9-simd10-echo11-hamsi12-fugue13-shabal14-whirlpool15-sha512-haval17