├── winbuild ├── dist │ └── include │ │ ├── libgen.h │ │ ├── sys │ │ └── time.h │ │ ├── CL │ │ └── .gitignore │ │ ├── curl │ │ └── .gitignore │ │ ├── stdbool.h │ │ ├── unistd.h │ │ ├── jansson_private_config.h │ │ ├── jansson_config.h │ │ ├── config.h │ │ └── winbuild.h ├── .gitignore ├── jansson │ ├── jansson_private_config.h │ ├── jansson_config.h │ └── jansson.vcxproj.filters └── sgminer.sln ├── submodules └── Makefile.am ├── ADL_SDK ├── .gitignore └── readme.txt ├── API.class ├── MCast.class ├── kernel ├── whirlpoolx.cl ├── x11evo │ ├── x11evo_footer.cl │ ├── x11evo_skein.cl │ ├── x11evo_keccak.cl │ ├── x11evo_bmw.cl │ ├── x11evo_groestl.cl │ ├── x11evo_blake.cl │ ├── x11evo_jh.cl │ ├── x11evo_echo.cl │ ├── x11evo_shavite.cl │ ├── x11evo_cubehash.cl │ ├── x11evo_luffa.cl │ ├── x11evo_header.cl │ └── x11evo_simd.cl ├── wolf-skein.cl ├── keccak1600.cl ├── blake256.cl ├── cubehash256.cl └── skein256.cl ├── .gitmodules ├── gbt-util.h ├── autogen.sh ├── pool.h ├── ccan ├── Makefile.am ├── opt │ ├── test │ │ ├── compile_ok-const-arg.c │ │ ├── utils.h │ │ ├── run-no-options.c │ │ ├── run-correct-reporting.c │ │ ├── run-iter.c │ │ ├── utils.c │ │ ├── run-checkopt.c │ │ └── run-usage.c │ ├── private.h │ ├── _info │ ├── usage.c │ └── parse.c ├── compiler │ ├── test │ │ ├── run-is_compile_constant.c │ │ └── compile_fail-printf.c │ └── _info └── typesafe_cb │ └── test │ ├── compile_ok-typesafe_cb-NULL.c │ ├── compile_fail-cast_if_type-promotable.c │ ├── compile_fail-typesafe_cb_cast.c │ ├── compile_fail-typesafe_cb-int.c │ ├── compile_fail-typesafe_cb_postargs.c │ ├── compile_fail-typesafe_cb_preargs.c │ ├── compile_fail-typesafe_cb_cast-multi.c │ ├── compile_fail-typesafe_cb.c │ ├── compile_ok-typesafe_cb_cast.c │ ├── compile_ok-typesafe_cb-undefined.c │ ├── compile_ok-typesafe_cb-vars.c │ └── run.c ├── sph ├── Makefile.am └── sha256_Y.h ├── algorithm ├── fresh.h ├── x14.h ├── whirlcoin.h ├── maxcoin.h ├── credits.h ├── inkcoin.h ├── lyra2re.h ├── sifcoin.h ├── talkcoin.h ├── twecoin.h ├── bitblock.h ├── darkcoin.h ├── marucoin.h ├── scrypt.h ├── animecoin.h ├── fuguecoin.h ├── quarkcoin.h ├── qubitcoin.h ├── groestlcoin.h ├── x16r.h ├── x16s.h ├── myriadcoin-groestl.h ├── evocoin.h ├── pluck.h ├── blake256.h ├── blakecoin.h ├── yescrypt.h ├── timetravel10.h ├── lyra2rev2.h ├── cryptonight.h ├── neoscrypt.h ├── equihash.h ├── eth-sha3.h ├── ethgencache.c └── lyra2.h ├── ocl ├── binary_kernel.h ├── build_kernel.h └── binary_kernel.c ├── example.bat ├── tools └── update_changelog.sh ├── findnonce.h ├── lib ├── memchr.valgrind ├── dummy.c ├── sig-handler.h ├── stddef.in.h └── memmem.c ├── adl.h ├── .gitignore ├── events.h ├── sysfs-gpu-controls.h ├── m4 ├── wchar_t.m4 ├── sigaction.m4 ├── 00gnulib.m4 ├── gnulib-cache.m4 ├── signalblocking.m4 ├── gnulib-tool.m4 ├── stddef_h.m4 ├── mmap-anon.m4 ├── multiarch.m4 ├── warn-on-use.m4 ├── signal_h.m4 ├── memchr.m4 └── onceonly.m4 ├── mknsis.sh ├── ocl.h ├── driver-opencl.h ├── arg-nonnull.h ├── doc ├── coding.md ├── BUGS.md └── kernel.md ├── api-example.py ├── roadmap.md ├── pool.c ├── hexdump.c ├── example.conf ├── sha2.h ├── logging.h ├── api-example.php ├── compat.h ├── algorithm.h ├── bench_block.h └── API.java /winbuild/dist/include/libgen.h: -------------------------------------------------------------------------------- 1 | #pragma once -------------------------------------------------------------------------------- /winbuild/dist/include/sys/time.h: -------------------------------------------------------------------------------- 1 | #pragma once -------------------------------------------------------------------------------- /submodules/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | SUBDIRS = jansson 3 | 4 | -------------------------------------------------------------------------------- /winbuild/dist/include/CL/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /winbuild/dist/include/curl/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /ADL_SDK/.gitignore: -------------------------------------------------------------------------------- 1 | adl_defines.h 2 | adl_sdk.h 3 | adl_structures.h 4 | -------------------------------------------------------------------------------- /API.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brian112358/sgminer-x16r/HEAD/API.class -------------------------------------------------------------------------------- /MCast.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brian112358/sgminer-x16r/HEAD/MCast.class -------------------------------------------------------------------------------- /kernel/whirlpoolx.cl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brian112358/sgminer-x16r/HEAD/kernel/whirlpoolx.cl -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "jansson"] 2 | path = submodules/jansson 3 | url = https://github.com/akheron/jansson.git 4 | -------------------------------------------------------------------------------- /kernel/x11evo/x11evo_footer.cl: -------------------------------------------------------------------------------- 1 | 2 | bool result = (hash.h8[3] <= target); 3 | if (result) 4 | output[output[0xFF]++] = SWAP4(gid); 5 | } 6 | 7 | #endif // X11EVO_CL 8 | -------------------------------------------------------------------------------- /gbt-util.h: -------------------------------------------------------------------------------- 1 | #ifndef __GBT_UTIL_H 2 | #define __GBT_UTIL_H 3 | 4 | 5 | int add_var_int(uint8_t*, uint64_t); 6 | bool set_coinbasetxn(struct pool *, uint32_t, uint64_t, uint64_t, const char *); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /ADL_SDK/readme.txt: -------------------------------------------------------------------------------- 1 | Please insert AMD ADL files adl_defines.h adl_sdk.h adl_structures.h here. 2 | 3 | They can be found at 4 | http://developer.amd.com/tools-and-sdks/graphics-development/display-library-adl-sdk/ 5 | -------------------------------------------------------------------------------- /autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | bs_dir="$(dirname $(readlink -f $0))" 3 | 4 | #Some versions of libtoolize don't like there being no ltmain.sh file already 5 | touch "${bs_dir}"/ltmain.sh 6 | autoreconf -fi "${bs_dir}" 7 | -------------------------------------------------------------------------------- /pool.h: -------------------------------------------------------------------------------- 1 | #ifndef POOL_H 2 | #define POOL_H 3 | 4 | #include "miner.h" 5 | 6 | extern char* get_pool_name(struct pool *pool); 7 | extern char* get_pool_user(struct pool *pool); 8 | 9 | #endif /* POOL_H */ 10 | -------------------------------------------------------------------------------- /ccan/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_LIBRARIES = libccan.a 2 | 3 | libccan_a_SOURCES = compiler/compiler.h opt/helpers.c opt/opt.c opt/opt.h opt/parse.c opt/private.h opt/usage.c typesafe_cb/typesafe_cb.h 4 | libccan_a_CPPFLAGS = -I$(top_srcdir) 5 | -------------------------------------------------------------------------------- /sph/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_LIBRARIES = libsph.a 2 | 3 | libsph_a_SOURCES = bmw.c echo.c jh.c luffa.c simd.c blake.c cubehash.c groestl.c keccak.c shavite.c skein.c sha2.c sha2big.c fugue.c hamsi.c panama.c shabal.c whirlpool.c sha256_Y.c 4 | -------------------------------------------------------------------------------- /algorithm/fresh.h: -------------------------------------------------------------------------------- 1 | #ifndef FRESHH_H 2 | #define FRESHH_H 3 | 4 | #include "miner.h" 5 | 6 | extern int fresh_test(unsigned char *pdata, const unsigned char *ptarget, uint32_t nonce); 7 | extern void fresh_regenhash(struct work *work); 8 | 9 | #endif /* FRESHH_H */ -------------------------------------------------------------------------------- /algorithm/x14.h: -------------------------------------------------------------------------------- 1 | #ifndef X14_H 2 | #define X14_H 3 | 4 | #include "miner.h" 5 | 6 | extern int x14_test(unsigned char *pdata, const unsigned char *ptarget, 7 | uint32_t nonce); 8 | extern void x14_regenhash(struct work *work); 9 | 10 | #endif /* X14_H */ -------------------------------------------------------------------------------- /algorithm/whirlcoin.h: -------------------------------------------------------------------------------- 1 | #ifndef WHIRLCOIN_H 2 | #define WHIRLCOIN_H 3 | 4 | #include "miner.h" 5 | 6 | extern int whirlcoin_test(unsigned char *pdata, const unsigned char *ptarget, uint32_t nonce); 7 | extern void whirlcoin_regenhash(struct work *work); 8 | 9 | #endif /* W_H */ -------------------------------------------------------------------------------- /algorithm/maxcoin.h: -------------------------------------------------------------------------------- 1 | #ifndef MAXCOIN_H 2 | #define MAXCOIN_H 3 | 4 | #include "miner.h" 5 | 6 | // extern int maxcoin_test(unsigned char *pdata, const unsigned char *ptarget, uint32_t nonce); 7 | extern void maxcoin_regenhash(struct work *work); 8 | 9 | #endif /* MAXCOIN_H */ 10 | -------------------------------------------------------------------------------- /algorithm/credits.h: -------------------------------------------------------------------------------- 1 | #ifndef CREDITS_H 2 | #define CREDITS_H 3 | 4 | #include "miner.h" 5 | 6 | 7 | extern int credits_test(unsigned char *pdata, const unsigned char *ptarget, uint32_t nonce); 8 | extern void credits_regenhash(struct work *work); 9 | 10 | #endif /* CREDITS_H */ 11 | -------------------------------------------------------------------------------- /algorithm/inkcoin.h: -------------------------------------------------------------------------------- 1 | #ifndef INKCOIN_H 2 | #define INKCOIN_H 3 | 4 | #include "miner.h" 5 | 6 | extern int inkcoin_test(unsigned char *pdata, const unsigned char *ptarget, 7 | uint32_t nonce); 8 | extern void inkcoin_regenhash(struct work *work); 9 | 10 | #endif /* INKCOIN_H */ 11 | -------------------------------------------------------------------------------- /algorithm/lyra2re.h: -------------------------------------------------------------------------------- 1 | #ifndef LYRA2RE_H 2 | #define LYRA2RE_H 3 | 4 | #include "miner.h" 5 | 6 | extern int lyra2re_test(unsigned char *pdata, const unsigned char *ptarget, 7 | uint32_t nonce); 8 | extern void lyra2re_regenhash(struct work *work); 9 | 10 | #endif /* LYRA2RE_H */ 11 | -------------------------------------------------------------------------------- /algorithm/sifcoin.h: -------------------------------------------------------------------------------- 1 | #ifndef SIFCOIN_H 2 | #define SIFCOIN_H 3 | 4 | #include "miner.h" 5 | 6 | extern int sifcoin_test(unsigned char *pdata, const unsigned char *ptarget, 7 | uint32_t nonce); 8 | extern void sifcoin_regenhash(struct work *work); 9 | 10 | #endif /* SIFCOIN_H */ 11 | -------------------------------------------------------------------------------- /algorithm/talkcoin.h: -------------------------------------------------------------------------------- 1 | #ifndef TALKCOIN_H 2 | #define TALKCOIN_H 3 | 4 | #include "miner.h" 5 | 6 | extern int talkcoin_test(unsigned char *pdata, const unsigned char *ptarget, uint32_t nonce); 7 | extern void talkcoin_regenhash(struct work *work); 8 | 9 | #endif /* TALKCOIN_H */ 10 | -------------------------------------------------------------------------------- /algorithm/twecoin.h: -------------------------------------------------------------------------------- 1 | #ifndef TWECOIN_H 2 | #define TWECOIN_H 3 | 4 | #include "miner.h" 5 | 6 | extern int twecoin_test(unsigned char *pdata, const unsigned char *ptarget, 7 | uint32_t nonce); 8 | extern void twecoin_regenhash(struct work *work); 9 | 10 | #endif /* TWECOIN_H */ 11 | -------------------------------------------------------------------------------- /algorithm/bitblock.h: -------------------------------------------------------------------------------- 1 | #ifndef BITBLOCK_H 2 | #define BITBLOCK_H 3 | 4 | #include "miner.h" 5 | 6 | extern int bitblock_test(unsigned char *pdata, const unsigned char *ptarget, 7 | uint32_t nonce); 8 | extern void bitblock_regenhash(struct work *work); 9 | 10 | #endif /* BITBLOCK_H */ 11 | -------------------------------------------------------------------------------- /algorithm/darkcoin.h: -------------------------------------------------------------------------------- 1 | #ifndef DARKCOIN_H 2 | #define DARKCOIN_H 3 | 4 | #include "miner.h" 5 | 6 | extern int darkcoin_test(unsigned char *pdata, const unsigned char *ptarget, 7 | uint32_t nonce); 8 | extern void darkcoin_regenhash(struct work *work); 9 | 10 | #endif /* DARKCOIN_H */ 11 | -------------------------------------------------------------------------------- /algorithm/marucoin.h: -------------------------------------------------------------------------------- 1 | #ifndef MARUCOIN_H 2 | #define MARUCOIN_H 3 | 4 | #include "miner.h" 5 | 6 | extern int marucoin_test(unsigned char *pdata, const unsigned char *ptarget, 7 | uint32_t nonce); 8 | extern void marucoin_regenhash(struct work *work); 9 | 10 | #endif /* MARUCOIN_H */ 11 | -------------------------------------------------------------------------------- /algorithm/scrypt.h: -------------------------------------------------------------------------------- 1 | #ifndef SCRYPT_H 2 | #define SCRYPT_H 3 | 4 | #include "miner.h" 5 | 6 | /* extern int scrypt_test(unsigned char *pdata, const unsigned char *ptarget, */ 7 | /* uint32_t nonce); */ 8 | extern void scrypt_regenhash(struct work *work); 9 | 10 | #endif /* SCRYPT_H */ 11 | -------------------------------------------------------------------------------- /algorithm/animecoin.h: -------------------------------------------------------------------------------- 1 | #ifndef ANIMECOIN_H 2 | #define ANIMECOIN_H 3 | 4 | #include "miner.h" 5 | 6 | extern int animecoin_test(unsigned char *pdata, const unsigned char *ptarget, 7 | uint32_t nonce); 8 | extern void animecoin_regenhash(struct work *work); 9 | 10 | #endif /* ANIMECOIN_H */ 11 | -------------------------------------------------------------------------------- /algorithm/fuguecoin.h: -------------------------------------------------------------------------------- 1 | #ifndef FUGUECOIN_H 2 | #define FUGUECOIN_H 3 | 4 | #include "miner.h" 5 | 6 | extern int fuguecoin_test(unsigned char *pdata, const unsigned char *ptarget, 7 | uint32_t nonce); 8 | extern void fuguecoin_regenhash(struct work *work); 9 | 10 | #endif /* FUGUECOIN_H */ 11 | -------------------------------------------------------------------------------- /algorithm/quarkcoin.h: -------------------------------------------------------------------------------- 1 | #ifndef QUARKCOIN_H 2 | #define QUARKCOIN_H 3 | 4 | #include "miner.h" 5 | 6 | extern int quarkcoin_test(unsigned char *pdata, const unsigned char *ptarget, 7 | uint32_t nonce); 8 | extern void quarkcoin_regenhash(struct work *work); 9 | 10 | #endif /* QUARKCOIN_H */ 11 | -------------------------------------------------------------------------------- /algorithm/qubitcoin.h: -------------------------------------------------------------------------------- 1 | #ifndef QUBITCOIN_H 2 | #define QUBITCOIN_H 3 | 4 | #include "miner.h" 5 | 6 | extern int qubitcoin_test(unsigned char *pdata, const unsigned char *ptarget, 7 | uint32_t nonce); 8 | extern void qubitcoin_regenhash(struct work *work); 9 | 10 | #endif /* QUBITCOIN_H */ 11 | -------------------------------------------------------------------------------- /algorithm/groestlcoin.h: -------------------------------------------------------------------------------- 1 | #ifndef GROESTLCOIN_H 2 | #define GROESTLCOIN_H 3 | 4 | #include "miner.h" 5 | 6 | extern int groestlcoin_test(unsigned char *pdata, const unsigned char *ptarget, 7 | uint32_t nonce); 8 | extern void groestlcoin_regenhash(struct work *work); 9 | 10 | #endif /* GROESTLCOIN_H */ 11 | -------------------------------------------------------------------------------- /ocl/binary_kernel.h: -------------------------------------------------------------------------------- 1 | #ifndef BINARY_KERNEL_H 2 | #define BINARY_KERNEL_H 3 | 4 | #ifdef __APPLE_CC__ 5 | #include 6 | #else 7 | #include 8 | #endif 9 | 10 | #include "build_kernel.h" 11 | 12 | cl_program load_opencl_binary_kernel(build_kernel_data *data); 13 | 14 | #endif /* BINARY_KERNEL_H */ 15 | -------------------------------------------------------------------------------- /algorithm/x16r.h: -------------------------------------------------------------------------------- 1 | #ifndef X16R_H 2 | #define X16R_H 3 | 4 | #include "miner.h" 5 | 6 | extern int x16r_test(unsigned char *pdata, const unsigned char *ptarget, uint32_t nonce); 7 | extern void x16r_regenhash(struct work *work); 8 | extern void x16r_twisted_code(const uint32_t* prevblock, char *code); 9 | 10 | #endif /* X16R_H */ 11 | -------------------------------------------------------------------------------- /algorithm/x16s.h: -------------------------------------------------------------------------------- 1 | #ifndef X16S_H 2 | #define X16S_H 3 | 4 | #include "miner.h" 5 | 6 | extern int x16s_test(unsigned char *pdata, const unsigned char *ptarget, uint32_t nonce); 7 | extern void x16s_regenhash(struct work *work); 8 | extern void x16s_twisted_code(const uint32_t* prevblock, char *code); 9 | 10 | #endif /* X16S_H */ 11 | -------------------------------------------------------------------------------- /example.bat: -------------------------------------------------------------------------------- 1 | setx GPU_FORCE_64BIT_PTR 0 2 | 3 | setx GPU_MAX_HEAP_SIZE 100 4 | 5 | setx GPU_USE_SYNC_OBJECTS 1 6 | 7 | setx GPU_MAX_ALLOC_PERCENT 100 8 | 9 | del *.bin 10 | 11 | 12 | sgminer.exe --no-submit-stale --kernel Lyra2RE -o stratum+tcp://92.27.201.170:9174 -u m -p 1 --gpu-platform 2 -I 19 --shaders 2816 -w 64 -g 2 13 | 14 | pause -------------------------------------------------------------------------------- /algorithm/myriadcoin-groestl.h: -------------------------------------------------------------------------------- 1 | #ifndef MYRIADCOIN_GROESTL_H 2 | #define MYRIADCOIN_GROESTL_H 3 | 4 | #include "miner.h" 5 | 6 | extern int myriadcoin_groestl_test(unsigned char *pdata, const unsigned char *ptarget, 7 | uint32_t nonce); 8 | extern void myriadcoin_groestl_regenhash(struct work *work); 9 | 10 | #endif /* MYRIADCOIN_GROESTL_H */ 11 | -------------------------------------------------------------------------------- /algorithm/evocoin.h: -------------------------------------------------------------------------------- 1 | #ifndef EVOCOIN_H 2 | #define EVOCOIN_H 3 | 4 | #include "miner.h" 5 | 6 | extern int evocoin_test(unsigned char *pdata, const unsigned char *ptarget, uint32_t nonce); 7 | extern void evocoin_regenhash(struct work *work); 8 | extern void evocoin_twisted_code(char *result, char *ntime, char *code); 9 | 10 | #endif /* EVOCOIN_H */ 11 | -------------------------------------------------------------------------------- /algorithm/pluck.h: -------------------------------------------------------------------------------- 1 | #ifndef PLUCK_H 2 | #define PLUCK_H 3 | 4 | #include "miner.h" 5 | #define PLUCK_SCRATCHBUF_SIZE (128 * 1024) 6 | #define PLUCK_SECBUF_SIZE (64 * 1024) 7 | 8 | extern int pluck_test(unsigned char *pdata, const unsigned char *ptarget, 9 | uint32_t nonce); 10 | extern void pluck_regenhash(struct work *work); 11 | 12 | #endif /* PLUCK_H */ 13 | -------------------------------------------------------------------------------- /algorithm/blake256.h: -------------------------------------------------------------------------------- 1 | #ifndef BLAKE256_H 2 | #define BLAKE256_H 3 | 4 | #include "miner.h" 5 | 6 | extern int blake256_test(unsigned char *pdata, const unsigned char *ptarget, uint32_t nonce); 7 | extern void precalc_hash_blake256(dev_blk_ctx *blk, uint32_t *state, uint32_t *pdata); 8 | extern void blake256_regenhash(struct work *work); 9 | 10 | #endif /* BLAKE256_H */ -------------------------------------------------------------------------------- /tools/update_changelog.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | FILE="$(dirname "$0")/../ChangeLog" 4 | UPDATECMD="git log --oneline --decorate" 5 | 6 | echo "Updated on `date`." > $FILE 7 | echo "If working with git, use \`$UPDATECMD\` for latest change log." >> $FILE 8 | echo "------------------------------------------------------------------------" >> $FILE 9 | $UPDATECMD >> $FILE 10 | -------------------------------------------------------------------------------- /algorithm/blakecoin.h: -------------------------------------------------------------------------------- 1 | #ifndef BLAKECOIN_H 2 | #define BLAKECOIN_H 3 | 4 | #include "miner.h" 5 | 6 | extern int blakecoin_test(unsigned char *pdata, const unsigned char *ptarget, uint32_t nonce); 7 | extern void precalc_hash_blakecoin(dev_blk_ctx *blk, uint32_t *state, uint32_t *data); 8 | extern void blakecoin_regenhash(struct work *work); 9 | 10 | #endif /* BLAKECOIN_H */ -------------------------------------------------------------------------------- /algorithm/yescrypt.h: -------------------------------------------------------------------------------- 1 | #ifndef YESCRYPT_H 2 | #define YESCRYPT_H 3 | 4 | #include "miner.h" 5 | #define YESCRYPT_SCRATCHBUF_SIZE (128 * 2048 * 8 ) //uchar 6 | #define YESCRYP_SECBUF_SIZE (128*64*8) 7 | extern int yescrypt_test(unsigned char *pdata, const unsigned char *ptarget, uint32_t nonce); 8 | extern void yescrypt_regenhash(struct work *work); 9 | 10 | #endif /* YESCRYPT_H */ 11 | -------------------------------------------------------------------------------- /algorithm/timetravel10.h: -------------------------------------------------------------------------------- 1 | #ifndef TIMETRAVEL10_H 2 | #define TIMETRAVEL10_H 3 | 4 | #include "miner.h" 5 | 6 | extern int timetravel10_test(unsigned char *pdata, const unsigned char *ptarget, uint32_t nonce); 7 | extern void timetravel10_regenhash(struct work *work); 8 | extern void timetravel10_twisted_code(char *result, char *ntime, char *code); 9 | 10 | #endif /* TIMETRAVEL10_H */ 11 | -------------------------------------------------------------------------------- /ccan/opt/test/compile_ok-const-arg.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | int main(int argc, char *argv[]) 8 | { 9 | opt_register_noarg("-v", opt_version_and_exit, 10 | (const char *)"1.2.3", 11 | (const char *)"Print version"); 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /ccan/compiler/test/run-is_compile_constant.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | plan_tests(2); 7 | 8 | ok1(!IS_COMPILE_CONSTANT(argc)); 9 | #if HAVE_BUILTIN_CONSTANT_P 10 | ok1(IS_COMPILE_CONSTANT(7)); 11 | #else 12 | pass("If !HAVE_BUILTIN_CONSTANT_P, IS_COMPILE_CONSTANT always false"); 13 | #endif 14 | return exit_status(); 15 | } 16 | -------------------------------------------------------------------------------- /algorithm/lyra2rev2.h: -------------------------------------------------------------------------------- 1 | #ifndef LYRA2REV2_H 2 | #define LYRA2REV2_H 3 | 4 | #include "miner.h" 5 | #define LYRA_SCRATCHBUF_SIZE (1536) // matrix size [12][4][4] uint64_t or equivalent 6 | #define LYRA_SECBUF_SIZE (4) // (not used) 7 | extern int lyra2rev2_test(unsigned char *pdata, const unsigned char *ptarget, 8 | uint32_t nonce); 9 | extern void lyra2rev2_regenhash(struct work *work); 10 | 11 | #endif /* LYRA2REV2_H */ 12 | -------------------------------------------------------------------------------- /algorithm/cryptonight.h: -------------------------------------------------------------------------------- 1 | #ifndef __CRYPTONIGHT_H 2 | #define __CRYPTONIGHT_H 3 | 4 | typedef struct _CryptonightCtx 5 | { 6 | uint64_t State[25]; 7 | uint64_t Scratchpad[1 << 18]; 8 | } CryptonightCtx; 9 | 10 | static inline int monero_variant(struct work *work) { 11 | return (work->is_monero && work->data[0] >= 7) ? work->data[0] - 6 : 0; 12 | } 13 | 14 | void cryptonight_regenhash(struct work *work); 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /algorithm/neoscrypt.h: -------------------------------------------------------------------------------- 1 | #ifndef NEOSCRYPT_H 2 | #define NEOSCRYPT_H 3 | 4 | #include "miner.h" 5 | 6 | /* The neoscrypt scratch buffer needs 32kBytes memory. */ 7 | #define NEOSCRYPT_SCRATCHBUF_SIZE (32 * 1024) 8 | /* These routines are always available. */ 9 | extern void neoscrypt_regenhash(struct work *work); 10 | extern void neoscrypt(const unsigned char *input, unsigned char *output, unsigned int profile); 11 | 12 | #endif /* NEOSCRYPT_H */ -------------------------------------------------------------------------------- /findnonce.h: -------------------------------------------------------------------------------- 1 | #ifndef FINDNONCE_H 2 | #define FINDNONCE_H 3 | 4 | #include "miner.h" 5 | #include "config.h" 6 | 7 | #define MAXTHREADS (0xFFFFFFFEULL) 8 | #define MAXBUFFERS (0x100) 9 | #define BUFFERSIZE (sizeof(uint32_t) * MAXBUFFERS) 10 | 11 | extern void precalc_hash(dev_blk_ctx *blk, uint32_t *state, uint32_t *data); 12 | extern void postcalc_hash_async(struct thr_info *thr, struct work *work, uint32_t *res); 13 | 14 | #endif /*FINDNONCE_H*/ 15 | -------------------------------------------------------------------------------- /ccan/compiler/test/compile_fail-printf.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | static void PRINTF_FMT(2,3) my_printf(int x, const char *fmt, ...) 4 | { 5 | } 6 | 7 | int main(int argc, char *argv[]) 8 | { 9 | unsigned int i = 0; 10 | 11 | my_printf(1, "Not a pointer " 12 | #ifdef FAIL 13 | "%p", 14 | #if !HAVE_ATTRIBUTE_PRINTF 15 | #error "Unfortunately we don't fail if !HAVE_ATTRIBUTE_PRINTF." 16 | #endif 17 | #else 18 | "%i", 19 | #endif 20 | i); 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /lib/memchr.valgrind: -------------------------------------------------------------------------------- 1 | # Suppress a valgrind message about use of uninitialized memory in memchr(). 2 | # POSIX states that when the character is found, memchr must not read extra 3 | # bytes in an overestimated length (for example, where memchr is used to 4 | # implement strnlen). However, we use a safe word read to provide a speedup. 5 | { 6 | memchr-value4 7 | Memcheck:Value4 8 | fun:rpl_memchr 9 | } 10 | { 11 | memchr-value8 12 | Memcheck:Value8 13 | fun:rpl_memchr 14 | } 15 | -------------------------------------------------------------------------------- /winbuild/dist/include/stdbool.h: -------------------------------------------------------------------------------- 1 | /* stdbool.h standard header */ 2 | 3 | #ifndef _STDBOOL 4 | #define _STDBOOL 5 | 6 | #define __bool_true_false_are_defined 1 7 | 8 | #ifndef __cplusplus 9 | 10 | #define bool _Bool 11 | #define false 0 12 | #define true 1 13 | 14 | #endif /* __cplusplus */ 15 | 16 | #endif /* _STDBOOL */ 17 | 18 | /* 19 | * Copyright (c) 1992-2010 by P.J. Plauger. ALL RIGHTS RESERVED. 20 | * Consult your license regarding permissions and restrictions. 21 | V5.30:0009 */ 22 | -------------------------------------------------------------------------------- /algorithm/equihash.h: -------------------------------------------------------------------------------- 1 | #ifndef __EQUIHASH_H 2 | #define __EQUIHASH_H 3 | 4 | #include 5 | #include "miner.h" 6 | #include "kernel/equihash-param.h" 7 | 8 | uint32_t equihash_verify_sol(struct work *work, sols_t *sols, int sol_i); 9 | void equihash_calc_mid_hash(uint64_t[8], uint8_t*); 10 | void equihash_regenhash(struct work *work); 11 | int64_t equihash_scanhash(struct thr_info *thr, struct work *work, int64_t *last_nonce, int64_t __maybe_unused max_nonce); 12 | 13 | #endif // __EQUIHASH_H 14 | -------------------------------------------------------------------------------- /ccan/typesafe_cb/test/compile_ok-typesafe_cb-NULL.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | /* NULL args for callback function should be OK for normal and _def. */ 5 | 6 | static void _register_callback(void (*cb)(const void *arg), const void *arg) 7 | { 8 | } 9 | 10 | #define register_callback(cb, arg) \ 11 | _register_callback(typesafe_cb(void, const void *, (cb), (arg)), (arg)) 12 | 13 | int main(int argc, char *argv[]) 14 | { 15 | register_callback(NULL, "hello world"); 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /algorithm/eth-sha3.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | 7 | #include 8 | #include 9 | 10 | #define decsha3(bits) \ 11 | int sha3_##bits(uint8_t*, size_t, uint8_t const*, size_t); 12 | 13 | decsha3(256) 14 | decsha3(512) 15 | 16 | static inline void SHA3_256(uint8_t* ret, uint8_t const* data, size_t const size) 17 | { 18 | sha3_256(ret, 32, data, size); 19 | } 20 | 21 | static inline void SHA3_512(uint8_t* ret, uint8_t const* data, size_t const size) 22 | { 23 | sha3_512(ret, 64, data, size); 24 | } 25 | 26 | #ifdef __cplusplus 27 | } 28 | #endif 29 | -------------------------------------------------------------------------------- /ccan/typesafe_cb/test/compile_fail-cast_if_type-promotable.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | static void _set_some_value(void *val) 5 | { 6 | } 7 | 8 | #define set_some_value(expr) \ 9 | _set_some_value(typesafe_cb_cast(void *, long, (expr))) 10 | 11 | int main(int argc, char *argv[]) 12 | { 13 | #ifdef FAIL 14 | bool x = 0; 15 | #if !HAVE_TYPEOF||!HAVE_BUILTIN_CHOOSE_EXPR||!HAVE_BUILTIN_TYPES_COMPATIBLE_P 16 | #error "Unfortunately we don't fail if typesafe_cb_cast is a noop." 17 | #endif 18 | #else 19 | long x = 0; 20 | #endif 21 | set_some_value(x); 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /adl.h: -------------------------------------------------------------------------------- 1 | #ifndef ADL_H 2 | #define ADL_H 3 | 4 | extern bool adl_active; 5 | extern bool opt_reorder; 6 | extern int opt_hysteresis; 7 | extern int opt_targettemp; 8 | extern int opt_overheattemp; 9 | 10 | #ifdef HAVE_ADL 11 | 12 | void init_adl(int nDevs); 13 | void change_gpusettings(int gpu); 14 | void clear_adl(int nDevs); 15 | 16 | #else /* HAVE_ADL */ 17 | 18 | #define adl_active (0) 19 | static inline void init_adl(__maybe_unused int nDevs) {} 20 | static inline void change_gpusettings(__maybe_unused int gpu) { } 21 | static inline void clear_adl(__maybe_unused int nDevs) {} 22 | 23 | #endif /* HAVE_ADL */ 24 | 25 | #endif /* ADL_H */ 26 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | cgminer 2 | cgminer.exe 3 | minerd 4 | minerd.exe 5 | *.o 6 | *.lo 7 | *.bin 8 | 9 | autom4te.cache 10 | .deps 11 | 12 | Makefile 13 | Makefile.in 14 | INSTALL 15 | aclocal.m4 16 | configure 17 | depcomp 18 | missing 19 | install-sh 20 | stamp-h1 21 | cpuminer-config.h* 22 | compile 23 | config.log 24 | config.status 25 | config.guess 26 | config.sub 27 | 28 | mingw32-config.cache 29 | 30 | *~ 31 | 32 | ext_deps 33 | config.h.in 34 | config.h 35 | 36 | ccan/libccan.a 37 | lib/arg-nonnull.h 38 | lib/c++defs.h 39 | lib/libgnu.a 40 | lib/signal.h 41 | lib/string.h 42 | lib/stdint.h 43 | lib/warn-on-use.h 44 | 45 | mkinstalldirs 46 | 47 | *.swp 48 | -------------------------------------------------------------------------------- /ccan/typesafe_cb/test/compile_fail-typesafe_cb_cast.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void _set_some_value(void *val); 4 | 5 | void _set_some_value(void *val) 6 | { 7 | } 8 | 9 | #define set_some_value(expr) \ 10 | _set_some_value(typesafe_cb_cast(void *, unsigned long, (expr))) 11 | 12 | int main(int argc, char *argv[]) 13 | { 14 | #ifdef FAIL 15 | int x = 0; 16 | set_some_value(x); 17 | #if !HAVE_TYPEOF||!HAVE_BUILTIN_CHOOSE_EXPR||!HAVE_BUILTIN_TYPES_COMPATIBLE_P 18 | #error "Unfortunately we don't fail if typesafe_cb_cast is a noop." 19 | #endif 20 | #else 21 | void *p = 0; 22 | set_some_value(p); 23 | #endif 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /ccan/opt/test/utils.h: -------------------------------------------------------------------------------- 1 | #ifndef CCAN_OPT_TEST_UTILS_H 2 | #define CCAN_OPT_TEST_UTILS_H 3 | #include 4 | #include 5 | 6 | bool parse_args(int *argc, char ***argv, ...); 7 | extern char *err_output; 8 | void save_err_output(const char *fmt, ...); 9 | 10 | extern unsigned int test_cb_called; 11 | char *test_noarg(void *arg); 12 | char *test_arg(const char *optarg, const char *arg); 13 | void show_arg(char buf[OPT_SHOW_LEN], const char *arg); 14 | 15 | extern struct opt_table short_table[]; 16 | extern struct opt_table long_table[]; 17 | extern struct opt_table long_and_short_table[]; 18 | extern struct opt_table subtables[]; 19 | #endif /* CCAN_OPT_TEST_UTILS_H */ 20 | -------------------------------------------------------------------------------- /ccan/opt/private.h: -------------------------------------------------------------------------------- 1 | #ifndef CCAN_OPT_PRIVATE_H 2 | #define CCAN_OPT_PRIVATE_H 3 | 4 | extern struct opt_table *opt_table; 5 | extern unsigned int opt_count, opt_num_short, opt_num_short_arg, opt_num_long; 6 | 7 | extern const char *opt_argv0; 8 | 9 | #define subtable_of(entry) ((struct opt_table *)((entry)->names)) 10 | 11 | const char *first_sopt(unsigned *i); 12 | const char *next_sopt(const char *names, unsigned *i); 13 | const char *first_lopt(unsigned *i, unsigned *len); 14 | const char *next_lopt(const char *p, unsigned *i, unsigned *len); 15 | 16 | int parse_one(int *argc, char *argv[], unsigned *offset, 17 | void (*errlog)(const char *fmt, ...)); 18 | 19 | #endif /* CCAN_OPT_PRIVATE_H */ 20 | -------------------------------------------------------------------------------- /events.h: -------------------------------------------------------------------------------- 1 | #ifndef EVENTS_H 2 | #define EVENTS_H 3 | 4 | typedef struct event { 5 | unsigned int id; 6 | const char *event_type; 7 | const char *runcmd; 8 | bool reboot; 9 | unsigned int reboot_delay; 10 | bool quit; 11 | const char *quit_msg; 12 | struct event *prev, *next; 13 | } event_t; 14 | 15 | extern char *set_event_type(const char *event_type); 16 | extern char *set_event_runcmd(const char *cmd); 17 | extern char *set_event_reboot(const char *arg); 18 | extern char *set_event_reboot_delay(const char *delay); 19 | extern char *set_event_quit(const char *arg); 20 | extern char *set_event_quit_message(const char *msg); 21 | extern void event_notify(const char *event_type); 22 | 23 | #endif /* EVENTS_H */ -------------------------------------------------------------------------------- /ccan/typesafe_cb/test/compile_fail-typesafe_cb-int.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void _callback(void (*fn)(void *arg), void *arg); 5 | void _callback(void (*fn)(void *arg), void *arg) 6 | { 7 | fn(arg); 8 | } 9 | 10 | /* Callback is set up to warn if arg isn't a pointer (since it won't 11 | * pass cleanly to _callback's second arg. */ 12 | #define callback(fn, arg) \ 13 | _callback(typesafe_cb(void, (fn), (arg)), (arg)) 14 | 15 | void my_callback(int something); 16 | void my_callback(int something) 17 | { 18 | } 19 | 20 | int main(int argc, char *argv[]) 21 | { 22 | #ifdef FAIL 23 | /* This fails due to arg, not due to cast. */ 24 | callback(my_callback, 100); 25 | #endif 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /ccan/typesafe_cb/test/compile_fail-typesafe_cb_postargs.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | static void _register_callback(void (*cb)(void *arg, int x), void *arg) 5 | { 6 | } 7 | #define register_callback(cb, arg) \ 8 | _register_callback(typesafe_cb_postargs(void, void *, (cb), (arg), int), (arg)) 9 | 10 | static void my_callback(char *p, int x) 11 | { 12 | } 13 | 14 | int main(int argc, char *argv[]) 15 | { 16 | #ifdef FAIL 17 | int *p; 18 | #if !HAVE_TYPEOF||!HAVE_BUILTIN_CHOOSE_EXPR||!HAVE_BUILTIN_TYPES_COMPATIBLE_P 19 | #error "Unfortunately we don't fail if typesafe_cb_cast is a noop." 20 | #endif 21 | #else 22 | char *p; 23 | #endif 24 | p = NULL; 25 | register_callback(my_callback, p); 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /ccan/typesafe_cb/test/compile_fail-typesafe_cb_preargs.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | static void _register_callback(void (*cb)(int x, void *arg), void *arg) 5 | { 6 | } 7 | 8 | #define register_callback(cb, arg) \ 9 | _register_callback(typesafe_cb_preargs(void, void *, (cb), (arg), int), (arg)) 10 | 11 | static void my_callback(int x, char *p) 12 | { 13 | } 14 | 15 | int main(int argc, char *argv[]) 16 | { 17 | #ifdef FAIL 18 | int *p; 19 | #if !HAVE_TYPEOF||!HAVE_BUILTIN_CHOOSE_EXPR||!HAVE_BUILTIN_TYPES_COMPATIBLE_P 20 | #error "Unfortunately we don't fail if typesafe_cb_cast is a noop." 21 | #endif 22 | #else 23 | char *p; 24 | #endif 25 | p = NULL; 26 | register_callback(my_callback, p); 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /sysfs-gpu-controls.h: -------------------------------------------------------------------------------- 1 | #ifndef __SYSFS_GPU_CONTROLS_H 2 | #define __SYSFS_GPU_CONTROLS_H 3 | 4 | extern bool has_sysfs_hwcontrols; 5 | 6 | void sysfs_cleanup(int); 7 | bool init_sysfs_hwcontrols(int nDevs); 8 | float sysfs_gpu_temp(int gpu); 9 | int sysfs_gpu_engineclock(int gpu); 10 | int sysfs_gpu_memclock(int gpu); 11 | float sysfs_gpu_vddc(int gpu); 12 | int sysfs_gpu_activity(int gpu); 13 | int sysfs_gpu_fanspeed(int gpu); 14 | float sysfs_gpu_fanpercent(int gpu); 15 | int sysfs_set_powertune(int gpu, int iPercentage); 16 | 17 | bool sysfs_gpu_stats(int gpu, float *temp, int *engineclock, int *memclock, float *vddc, 18 | int *activity, int *fanspeed, int *fanpercent, int *powertune); 19 | void sysfs_gpu_autotune(int gpu, enum dev_enable *denable); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /ccan/typesafe_cb/test/compile_fail-typesafe_cb_cast-multi.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | struct foo { 5 | int x; 6 | }; 7 | 8 | struct bar { 9 | int x; 10 | }; 11 | 12 | struct baz { 13 | int x; 14 | }; 15 | 16 | struct any { 17 | int x; 18 | }; 19 | 20 | struct other { 21 | int x; 22 | }; 23 | 24 | static void take_any(struct any *any) 25 | { 26 | } 27 | 28 | int main(int argc, char *argv[]) 29 | { 30 | #ifdef FAIL 31 | struct other 32 | #if !HAVE_TYPEOF||!HAVE_BUILTIN_CHOOSE_EXPR||!HAVE_BUILTIN_TYPES_COMPATIBLE_P 33 | #error "Unfortunately we don't fail if typesafe_cb_cast is a noop." 34 | #endif 35 | #else 36 | struct foo 37 | #endif 38 | *arg = NULL; 39 | take_any(typesafe_cb_cast3(struct any *, 40 | struct foo *, struct bar *, struct baz *, 41 | arg)); 42 | return 0; 43 | } 44 | -------------------------------------------------------------------------------- /ccan/typesafe_cb/test/compile_fail-typesafe_cb.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | static void _register_callback(void (*cb)(void *arg), void *arg) 5 | { 6 | } 7 | 8 | #define register_callback(cb, arg) \ 9 | _register_callback(typesafe_cb(void, void *, (cb), (arg)), (arg)) 10 | 11 | static void my_callback(char *p) 12 | { 13 | } 14 | 15 | int main(int argc, char *argv[]) 16 | { 17 | char str[] = "hello world"; 18 | #ifdef FAIL 19 | int *p; 20 | #if !HAVE_TYPEOF||!HAVE_BUILTIN_CHOOSE_EXPR||!HAVE_BUILTIN_TYPES_COMPATIBLE_P 21 | #error "Unfortunately we don't fail if typesafe_cb_cast is a noop." 22 | #endif 23 | #else 24 | char *p; 25 | #endif 26 | p = NULL; 27 | 28 | /* This should work always. */ 29 | register_callback(my_callback, str); 30 | 31 | /* This will fail with FAIL defined */ 32 | register_callback(my_callback, p); 33 | return 0; 34 | } 35 | -------------------------------------------------------------------------------- /ccan/opt/test/run-no-options.c: -------------------------------------------------------------------------------- 1 | /* Make sure we still work with no options registered */ 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "utils.h" 9 | 10 | int main(int argc, char *argv[]) 11 | { 12 | const char *myname = argv[0]; 13 | 14 | plan_tests(7); 15 | 16 | /* Simple short arg.*/ 17 | ok1(!parse_args(&argc, &argv, "-a", NULL)); 18 | /* Simple long arg.*/ 19 | ok1(!parse_args(&argc, &argv, "--aaa", NULL)); 20 | 21 | /* Extra arguments preserved. */ 22 | ok1(parse_args(&argc, &argv, "extra", "args", NULL)); 23 | ok1(argc == 3); 24 | ok1(argv[0] == myname); 25 | ok1(strcmp(argv[1], "extra") == 0); 26 | ok1(strcmp(argv[2], "args") == 0); 27 | 28 | /* parse_args allocates argv */ 29 | free(argv); 30 | 31 | return exit_status(); 32 | } 33 | 34 | -------------------------------------------------------------------------------- /winbuild/dist/include/unistd.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* Values for the second argument to access. 4 | These may be OR'd together. */ 5 | #define R_OK 4 /* Test for read permission. */ 6 | #define W_OK 2 /* Test for write permission. */ 7 | #define F_OK 0 /* Test for existence. */ 8 | 9 | // POSIX open,read,write... deprecated as of VC++ 2005. 10 | // Use ISO conformant _open,_read,_write instead. 11 | #define access _access 12 | #define dup2 _dup2 13 | #define execve _execve 14 | #define ftruncate _chsize 15 | #define unlink _unlink 16 | #define fileno _fileno 17 | #define getcwd _getcwd 18 | #define chdir _chdir 19 | #define isatty _isatty 20 | #define lseek _lseek 21 | #define open _open 22 | #define write _write 23 | #define close _close 24 | #define read _read 25 | #define snprintf _snprintf 26 | 27 | #define STDIN_FILENO 0 28 | #define STDOUT_FILENO 1 29 | #define STDERR_FILENO 2 -------------------------------------------------------------------------------- /m4/wchar_t.m4: -------------------------------------------------------------------------------- 1 | # wchar_t.m4 serial 4 (gettext-0.18.2) 2 | dnl Copyright (C) 2002-2003, 2008-2011 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | dnl From Bruno Haible. 8 | dnl Test whether has the 'wchar_t' type. 9 | dnl Prerequisite: AC_PROG_CC 10 | 11 | AC_DEFUN([gt_TYPE_WCHAR_T], 12 | [ 13 | AC_CACHE_CHECK([for wchar_t], [gt_cv_c_wchar_t], 14 | [AC_COMPILE_IFELSE( 15 | [AC_LANG_PROGRAM( 16 | [[#include 17 | wchar_t foo = (wchar_t)'\0';]], 18 | [[]])], 19 | [gt_cv_c_wchar_t=yes], 20 | [gt_cv_c_wchar_t=no])]) 21 | if test $gt_cv_c_wchar_t = yes; then 22 | AC_DEFINE([HAVE_WCHAR_T], [1], [Define if you have the 'wchar_t' type.]) 23 | fi 24 | ]) 25 | -------------------------------------------------------------------------------- /ccan/typesafe_cb/test/compile_ok-typesafe_cb_cast.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | struct foo { 5 | int x; 6 | }; 7 | 8 | struct bar { 9 | int x; 10 | }; 11 | 12 | struct baz { 13 | int x; 14 | }; 15 | 16 | struct any { 17 | int x; 18 | }; 19 | 20 | static void take_any(struct any *any) 21 | { 22 | } 23 | 24 | int main(int argc, char *argv[]) 25 | { 26 | /* Otherwise we get unused warnings for these. */ 27 | struct foo *foo = NULL; 28 | struct bar *bar = NULL; 29 | struct baz *baz = NULL; 30 | 31 | take_any(typesafe_cb_cast3(struct any *, 32 | struct foo *, struct bar *, struct baz *, 33 | foo)); 34 | take_any(typesafe_cb_cast3(struct any *, 35 | struct foo *, struct bar *, struct baz *, 36 | bar)); 37 | take_any(typesafe_cb_cast3(struct any *, 38 | struct foo *, struct bar *, struct baz *, 39 | baz)); 40 | return 0; 41 | } 42 | -------------------------------------------------------------------------------- /mknsis.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | MINGW_PATH=/usr/i686-pc-mingw32/sys-root/mingw/bin 4 | 5 | OUT_BASE="cpuminer-installer" 6 | OUT_EXE="$OUT_BASE.exe" 7 | 8 | PATH=$PATH:$MINGW_PATH \ 9 | nsiswrapper --run \ 10 | --name "CPU miner" \ 11 | --outfile "$OUT_EXE" \ 12 | minerd.exe \ 13 | $MINGW_PATH/libcurl-4.dll=libcurl-4.dll \ 14 | $MINGW_PATH/pthreadgc2.dll=pthreadgc2.dll \ 15 | $MINGW_PATH/libidn-11.dll=libidn-11.dll \ 16 | $MINGW_PATH/libssh2-1.dll=libssh2-1.dll \ 17 | $MINGW_PATH/libssl-10.dll=libssl-10.dll \ 18 | $MINGW_PATH/zlib1.dll=zlib1.dll \ 19 | $MINGW_PATH/libcrypto-10.dll=libcrypto-10.dll \ 20 | $MINGW_PATH/libiconv-2.dll=libiconv-2.dll \ 21 | $MINGW_PATH/libintl-8.dll=libintl-8.dll 22 | 23 | chmod 0755 "$OUT_EXE" 24 | zip -9 "$OUT_BASE" "$OUT_EXE" 25 | rm -f "$OUT_EXE" 26 | 27 | chmod 0644 "$OUT_BASE.zip" 28 | 29 | echo -n "SHA1: " 30 | sha1sum "$OUT_BASE.zip" 31 | 32 | echo -n "MD5: " 33 | md5sum "$OUT_BASE.zip" 34 | 35 | -------------------------------------------------------------------------------- /ocl/build_kernel.h: -------------------------------------------------------------------------------- 1 | #ifndef BUILD_KERNEL_H 2 | #define BUILD_KERNEL_H 3 | 4 | #include 5 | #include "logging.h" 6 | 7 | #ifdef __APPLE_CC__ 8 | #include 9 | #else 10 | #include 11 | #endif 12 | 13 | typedef struct _build_kernel_data { 14 | char source_filename[255]; 15 | char binary_filename[255]; 16 | char compiler_options[512]; 17 | 18 | cl_context context; 19 | cl_device_id *device; 20 | 21 | // for compiler options 22 | char platform[64]; 23 | char sgminer_path[255]; 24 | const char *kernel_path; 25 | size_t work_size; 26 | float opencl_version; 27 | } build_kernel_data; 28 | 29 | bool needs_bfi_patch(build_kernel_data *data); 30 | cl_program build_opencl_kernel(build_kernel_data *data, const char *filename, const char *x11EvoCode); 31 | bool save_opencl_kernel(build_kernel_data *data, cl_program program); 32 | void set_base_compiler_options(build_kernel_data *data); 33 | 34 | #endif /* BUILD_KERNEL_H */ 35 | -------------------------------------------------------------------------------- /kernel/x11evo/x11evo_skein.cl: -------------------------------------------------------------------------------- 1 | 2 | // skein 3 | { 4 | sph_u64 h0 = SPH_C64(0x4903ADFF749C51CE), h1 = SPH_C64(0x0D95DE399746DF03), h2 = SPH_C64(0x8FD1934127C79BCE), h3 = SPH_C64(0x9A255629FF352CB1), h4 = SPH_C64(0x5DB62599DF6CA7B0), h5 = SPH_C64(0xEABE394CA9D5C3F4), h6 = SPH_C64(0x991112C71A75B523), h7 = SPH_C64(0xAE18A40B660FCC33); 5 | sph_u64 m0, m1, m2, m3, m4, m5, m6, m7; 6 | sph_u64 bcount = 0; 7 | 8 | m0 = SWAP8(hash.h8[0]); 9 | m1 = SWAP8(hash.h8[1]); 10 | m2 = SWAP8(hash.h8[2]); 11 | m3 = SWAP8(hash.h8[3]); 12 | m4 = SWAP8(hash.h8[4]); 13 | m5 = SWAP8(hash.h8[5]); 14 | m6 = SWAP8(hash.h8[6]); 15 | m7 = SWAP8(hash.h8[7]); 16 | UBI_BIG(480, 64); 17 | bcount = 0; 18 | m0 = m1 = m2 = m3 = m4 = m5 = m6 = m7 = 0; 19 | UBI_BIG(510, 8); 20 | 21 | 22 | hash.h8[0] = SWAP8(h0); 23 | hash.h8[1] = SWAP8(h1); 24 | hash.h8[2] = SWAP8(h2); 25 | hash.h8[3] = SWAP8(h3); 26 | hash.h8[4] = SWAP8(h4); 27 | hash.h8[5] = SWAP8(h5); 28 | hash.h8[6] = SWAP8(h6); 29 | hash.h8[7] = SWAP8(h7); 30 | 31 | } 32 | -------------------------------------------------------------------------------- /winbuild/.gitignore: -------------------------------------------------------------------------------- 1 | #OS junk files 2 | [Tt]humbs.db 3 | *.DS_Store 4 | 5 | #Visual Studio files 6 | *.[Oo]bj 7 | *.user 8 | *.aps 9 | *.pch 10 | *.vspscc 11 | *.vssscc 12 | *_i.c 13 | *_p.c 14 | *.ncb 15 | *.suo 16 | *.tlb 17 | *.tlh 18 | *.bak 19 | *.[Cc]ache 20 | *.ilk 21 | *.log 22 | *.lib 23 | *.sbr 24 | *.sdf 25 | *.opensdf 26 | *.unsuccessfulbuild 27 | ipch/ 28 | [Oo]bj/ 29 | [Bb]in 30 | [Dd]ebug*/ 31 | [Rr]elease*/ 32 | Ankh.NoLoad 33 | 34 | #MonoDevelop 35 | *.pidb 36 | *.userprefs 37 | 38 | #Tooling 39 | _ReSharper*/ 40 | *.resharper 41 | [Tt]est[Rr]esult* 42 | *.sass-cache 43 | 44 | #Project files 45 | [Bb]uild/ 46 | 47 | #Subversion files 48 | .svn 49 | 50 | # Office Temp Files 51 | ~$* 52 | 53 | # vim Temp Files 54 | *~ 55 | 56 | #NuGet 57 | packages/ 58 | *.nupkg 59 | 60 | #ncrunch 61 | *ncrunch* 62 | *crunch*.local.xml 63 | 64 | # visual studio database projects 65 | *.dbmdl 66 | 67 | #Test files 68 | *.testsettings 69 | 70 | #Config 71 | !dist/include/config.h 72 | 73 | #Library archives 74 | *.zip 75 | *.rar 76 | 77 | #Library binaries 78 | *.dll 79 | *.a 80 | 81 | #Git version file 82 | gitversion.h 83 | 84 | -------------------------------------------------------------------------------- /ocl.h: -------------------------------------------------------------------------------- 1 | #ifndef OCL_H 2 | #define OCL_H 3 | 4 | #include "config.h" 5 | 6 | #include 7 | #ifdef __APPLE_CC__ 8 | #include 9 | #else 10 | #include 11 | #endif 12 | 13 | #include "algorithm.h" 14 | 15 | typedef struct __clState { 16 | cl_context context; 17 | cl_kernel kernel; 18 | cl_kernel *extra_kernels; 19 | cl_kernel GenerateDAG; 20 | size_t n_extra_kernels; 21 | cl_command_queue commandQueue; 22 | cl_program program; 23 | cl_mem outputBuffer; 24 | cl_mem CLbuffer0; 25 | cl_mem MidstateBuf; 26 | cl_mem padbuffer8; 27 | cl_mem BranchBuffer[4]; 28 | cl_mem Scratchpads; 29 | cl_mem States; 30 | cl_mem buffer1; 31 | cl_mem buffer2; 32 | cl_mem buffer3; 33 | cl_mem index_buf[9]; 34 | unsigned char cldata[168]; 35 | bool goffset; 36 | cl_uint vwidth; 37 | int devid; 38 | int monero_variant; 39 | char algo_sequence[17]; 40 | size_t max_work_size; 41 | size_t wsize; 42 | size_t compute_shaders; 43 | } _clState; 44 | 45 | extern int clDevicesNum(void); 46 | extern _clState *initCl(unsigned int gpu, char *name, size_t nameSize, algorithm_t *algorithm, struct thr_info *thr); 47 | 48 | #endif /* OCL_H */ 49 | -------------------------------------------------------------------------------- /driver-opencl.h: -------------------------------------------------------------------------------- 1 | #ifndef DEVICE_GPU_H 2 | #define DEVICE_GPU_H 3 | 4 | #include "miner.h" 5 | 6 | 7 | extern void print_ndevs(int *ndevs); 8 | extern void *reinit_gpu(void *userdata); 9 | extern char *set_gpu_map(char *arg); 10 | extern char *set_gpu_threads(const char *arg); 11 | extern char *set_gpu_engine(const char *arg); 12 | extern char *set_gpu_fan(const char *arg); 13 | extern char *set_gpu_memclock(const char *arg); 14 | extern char *set_gpu_memdiff(char *arg); 15 | extern char *set_gpu_powertune(char *arg); 16 | extern char *set_gpu_vddc(char *arg); 17 | extern char *set_temp_overheat(char *arg); 18 | extern char *set_temp_target(char *arg); 19 | extern char *set_intensity(const char *arg); 20 | extern char *set_xintensity(const char *arg); 21 | extern char *set_rawintensity(const char *arg); 22 | extern char *set_vector(char *arg); 23 | extern char *set_worksize(const char *arg); 24 | extern char *set_shaders(char *arg); 25 | extern char *set_lookup_gap(char *arg); 26 | extern char *set_thread_concurrency(const char *arg); 27 | void manage_gpu(void); 28 | extern void pause_dynamic_threads(int gpu); 29 | 30 | extern int opt_platform_id; 31 | 32 | extern struct device_drv opencl_drv; 33 | 34 | #endif /* DEVICE_GPU_H */ 35 | -------------------------------------------------------------------------------- /kernel/x11evo/x11evo_keccak.cl: -------------------------------------------------------------------------------- 1 | 2 | // keccak 3 | { 4 | sph_u64 a00 = 0, a01 = 0, a02 = 0, a03 = 0, a04 = 0; 5 | sph_u64 a10 = 0, a11 = 0, a12 = 0, a13 = 0, a14 = 0; 6 | sph_u64 a20 = 0, a21 = 0, a22 = 0, a23 = 0, a24 = 0; 7 | sph_u64 a30 = 0, a31 = 0, a32 = 0, a33 = 0, a34 = 0; 8 | sph_u64 a40 = 0, a41 = 0, a42 = 0, a43 = 0, a44 = 0; 9 | 10 | a10 = SPH_C64(0xFFFFFFFFFFFFFFFF); 11 | a20 = SPH_C64(0xFFFFFFFFFFFFFFFF); 12 | a31 = SPH_C64(0xFFFFFFFFFFFFFFFF); 13 | a22 = SPH_C64(0xFFFFFFFFFFFFFFFF); 14 | a23 = SPH_C64(0xFFFFFFFFFFFFFFFF); 15 | a04 = SPH_C64(0xFFFFFFFFFFFFFFFF); 16 | 17 | a00 ^= SWAP8(hash.h8[0]); 18 | a10 ^= SWAP8(hash.h8[1]); 19 | a20 ^= SWAP8(hash.h8[2]); 20 | a30 ^= SWAP8(hash.h8[3]); 21 | a40 ^= SWAP8(hash.h8[4]); 22 | a01 ^= SWAP8(hash.h8[5]); 23 | a11 ^= SWAP8(hash.h8[6]); 24 | a21 ^= SWAP8(hash.h8[7]); 25 | a31 ^= 0x8000000000000001; 26 | KECCAK_F_1600; 27 | // Finalize the "lane complement" 28 | a10 = ~a10; 29 | a20 = ~a20; 30 | 31 | hash.h8[0] = SWAP8(a00); 32 | hash.h8[1] = SWAP8(a10); 33 | hash.h8[2] = SWAP8(a20); 34 | hash.h8[3] = SWAP8(a30); 35 | hash.h8[4] = SWAP8(a40); 36 | hash.h8[5] = SWAP8(a01); 37 | hash.h8[6] = SWAP8(a11); 38 | hash.h8[7] = SWAP8(a21); 39 | 40 | 41 | 42 | 43 | } 44 | -------------------------------------------------------------------------------- /kernel/x11evo/x11evo_bmw.cl: -------------------------------------------------------------------------------- 1 | 2 | // bmw 3 | { 4 | sph_u64 BMW_H[16]; 5 | for (unsigned u = 0; u < 16; u++) 6 | BMW_H[u] = BMW_IV512[u]; 7 | 8 | sph_u64 BMW_h1[16], BMW_h2[16]; 9 | sph_u64 mv[16]; 10 | 11 | mv[0] = SWAP8(hash.h8[0]); 12 | mv[1] = SWAP8(hash.h8[1]); 13 | mv[2] = SWAP8(hash.h8[2]); 14 | mv[3] = SWAP8(hash.h8[3]); 15 | mv[4] = SWAP8(hash.h8[4]); 16 | mv[5] = SWAP8(hash.h8[5]); 17 | mv[6] = SWAP8(hash.h8[6]); 18 | mv[7] = SWAP8(hash.h8[7]); 19 | mv[8] = 0x80; 20 | mv[9] = 0; 21 | mv[10] = 0; 22 | mv[11] = 0; 23 | mv[12] = 0; 24 | mv[13] = 0; 25 | mv[14] = 0; 26 | mv[15] = 0x200; 27 | #define M(x) (mv[x]) 28 | #define H(x) (BMW_H[x]) 29 | #define dH(x) (BMW_h2[x]) 30 | 31 | FOLDb; 32 | 33 | #undef M 34 | #undef H 35 | #undef dH 36 | 37 | #define M(x) (BMW_h2[x]) 38 | #define H(x) (final_b[x]) 39 | #define dH(x) (BMW_h1[x]) 40 | 41 | FOLDb; 42 | 43 | #undef M 44 | #undef H 45 | #undef dH 46 | 47 | hash.h8[0] = SWAP8(BMW_h1[8]); 48 | hash.h8[1] = SWAP8(BMW_h1[9]); 49 | hash.h8[2] = SWAP8(BMW_h1[10]); 50 | hash.h8[3] = SWAP8(BMW_h1[11]); 51 | hash.h8[4] = SWAP8(BMW_h1[12]); 52 | hash.h8[5] = SWAP8(BMW_h1[13]); 53 | hash.h8[6] = SWAP8(BMW_h1[14]); 54 | hash.h8[7] = SWAP8(BMW_h1[15]); 55 | 56 | } 57 | -------------------------------------------------------------------------------- /arg-nonnull.h: -------------------------------------------------------------------------------- 1 | /* A C macro for declaring that specific arguments must not be NULL. 2 | Copyright (C) 2009-2011 Free Software Foundation, Inc. 3 | 4 | This program is free software: you can redistribute it and/or modify it 5 | under the terms of the GNU General Public License as published 6 | by the Free Software Foundation; either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . */ 16 | 17 | /* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools 18 | that the values passed as arguments n, ..., m must be non-NULL pointers. 19 | n = 1 stands for the first argument, n = 2 for the second argument etc. */ 20 | #ifndef _GL_ARG_NONNULL 21 | # if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3 22 | # define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params)) 23 | # else 24 | # define _GL_ARG_NONNULL(params) 25 | # endif 26 | #endif 27 | -------------------------------------------------------------------------------- /doc/coding.md: -------------------------------------------------------------------------------- 1 | Coding style 2 | ==================== 3 | 4 | - K&R Stroustrup variant 5 | - 2 space indenting, no tabs 6 | - Each function has its opening brace at the next line on the same indentation level as its header, the statements within the braces are indented, and the closing brace at the end is on the same indentation level as the header of the function at a line of its own. The blocks inside a function, however, have their opening braces at the same line as their respective control statements; closing braces remain in a line of their own. 7 | - Else is on the same indentation level as its accompanying ```if``` statement at a line of its own. 8 | - Curly brackets even for one-line blocks 9 | - No extra spaces inside parenthesis; please don't do ```( this )``` 10 | - No space after function names, one space after ```if```, ```for``` and ```while``` 11 | 12 | ```c++ 13 | int main(int argc, char *argv[]) 14 | { 15 | ... 16 | while (x == y) { 17 | something(); 18 | somethingelse(); 19 | 20 | if (some_error) { 21 | do_correct(); 22 | } 23 | else { 24 | continue_as_usual(); 25 | return false; 26 | } 27 | } 28 | 29 | finalthing(); 30 | ... 31 | } 32 | ``` 33 | 34 | A-Style example command line: 35 | ``` 36 | --style=stroustrup --indent=spaces=2 --break-closing-brackets --add-brackets --convert-tabs --mode=c 37 | ``` 38 | -------------------------------------------------------------------------------- /kernel/x11evo/x11evo_groestl.cl: -------------------------------------------------------------------------------- 1 | 2 | // groestl 3 | { 4 | sph_u64 H[16]; 5 | for (unsigned int u = 0; u < 15; u++) 6 | H[u] = 0; 7 | #if USE_LE 8 | H[15] = ((sph_u64)(512 & 0xFF) << 56) | ((sph_u64)(512 & 0xFF00) << 40); 9 | #else 10 | H[15] = (sph_u64)512; 11 | #endif 12 | 13 | sph_u64 g[16], m[16]; 14 | m[0] = DEC64E(hash.h8[0]); 15 | m[1] = DEC64E(hash.h8[1]); 16 | m[2] = DEC64E(hash.h8[2]); 17 | m[3] = DEC64E(hash.h8[3]); 18 | m[4] = DEC64E(hash.h8[4]); 19 | m[5] = DEC64E(hash.h8[5]); 20 | m[6] = DEC64E(hash.h8[6]); 21 | m[7] = DEC64E(hash.h8[7]); 22 | for (unsigned int u = 0; u < 16; u++) 23 | g[u] = m[u] ^ H[u]; 24 | m[8] = 0x80; g[8] = m[8] ^ H[8]; 25 | m[9] = 0; g[9] = m[9] ^ H[9]; 26 | m[10] = 0; g[10] = m[10] ^ H[10]; 27 | m[11] = 0; g[11] = m[11] ^ H[11]; 28 | m[12] = 0; g[12] = m[12] ^ H[12]; 29 | m[13] = 0; g[13] = m[13] ^ H[13]; 30 | m[14] = 0; g[14] = m[14] ^ H[14]; 31 | m[15] = 0x100000000000000; g[15] = m[15] ^ H[15]; 32 | PERM_BIG_P(g); 33 | PERM_BIG_Q(m); 34 | for (unsigned int u = 0; u < 16; u++) 35 | H[u] ^= g[u] ^ m[u]; 36 | sph_u64 xH[16]; 37 | for (unsigned int u = 0; u < 16; u++) 38 | xH[u] = H[u]; 39 | PERM_BIG_P(xH); 40 | for (unsigned int u = 0; u < 16; u++) 41 | H[u] ^= xH[u]; 42 | for (unsigned int u = 0; u < 8; u++) 43 | hash.h8[u] = DEC64E(H[u + 8]); 44 | 45 | } 46 | -------------------------------------------------------------------------------- /winbuild/jansson/jansson_private_config.h: -------------------------------------------------------------------------------- 1 | /* #undef HAVE_ENDIAN_H */ 2 | #define HAVE_FCNTL_H 1 3 | /* #undef HAVE_SCHED_H */ 4 | /* #undef HAVE_UNISTD_H */ 5 | /* #undef HAVE_SYS_PARAM_H */ 6 | #define HAVE_SYS_STAT_H 1 7 | /* #undef HAVE_SYS_TIME_H */ 8 | /* #undef HAVE_SYS_TYPES_H */ 9 | #define HAVE_STDINT_H 1 10 | 11 | #define HAVE_CLOSE 1 12 | #define HAVE_GETPID 1 13 | /* #undef HAVE_GETTIMEOFDAY */ 14 | #define HAVE_OPEN 1 15 | #define HAVE_READ 1 16 | /* #undef HAVE_SCHED_YIELD */ 17 | 18 | /* #undef HAVE_SYNC_BUILTINS */ 19 | /* #undef HAVE_ATOMIC_BUILTINS */ 20 | 21 | #define HAVE_LOCALE_H 1 22 | /* #undef HAVE_SETLOCALE */ 23 | 24 | #define HAVE_INT32_T 1 25 | #ifndef HAVE_INT32_T 26 | # define int32_t int32_t 27 | #endif 28 | 29 | #define HAVE_UINT32_T 1 30 | #ifndef HAVE_UINT32_T 31 | # define uint32_t uint32_t 32 | #endif 33 | 34 | #define HAVE_UINT16_T 1 35 | #ifndef HAVE_UINT16_T 36 | # define uint16_t uint16_t 37 | #endif 38 | 39 | #define HAVE_UINT8_T 1 40 | #ifndef HAVE_UINT8_T 41 | # define uint8_t uint8_t 42 | #endif 43 | 44 | /* #undef HAVE_SSIZE_T */ 45 | 46 | #ifndef HAVE_SSIZE_T 47 | # define ssize_t int 48 | #endif 49 | 50 | /* #undef HAVE_SNPRINTF */ 51 | 52 | #ifndef HAVE_SNPRINTF 53 | # define snprintf _snprintf 54 | #endif 55 | 56 | /* #undef HAVE_VSNPRINTF */ 57 | 58 | #define USE_URANDOM 1 59 | #define USE_WINDOWS_CRYPTOAPI 1 60 | -------------------------------------------------------------------------------- /winbuild/dist/include/jansson_private_config.h: -------------------------------------------------------------------------------- 1 | /* #undef HAVE_ENDIAN_H */ 2 | #define HAVE_FCNTL_H 1 3 | /* #undef HAVE_SCHED_H */ 4 | /* #undef HAVE_UNISTD_H */ 5 | /* #undef HAVE_SYS_PARAM_H */ 6 | #define HAVE_SYS_STAT_H 1 7 | /* #undef HAVE_SYS_TIME_H */ 8 | /* #undef HAVE_SYS_TYPES_H */ 9 | #define HAVE_STDINT_H 1 10 | 11 | #define HAVE_CLOSE 1 12 | #define HAVE_GETPID 1 13 | /* #undef HAVE_GETTIMEOFDAY */ 14 | #define HAVE_OPEN 1 15 | #define HAVE_READ 1 16 | /* #undef HAVE_SCHED_YIELD */ 17 | 18 | /* #undef HAVE_SYNC_BUILTINS */ 19 | /* #undef HAVE_ATOMIC_BUILTINS */ 20 | 21 | #define HAVE_LOCALE_H 1 22 | /* #undef HAVE_SETLOCALE */ 23 | 24 | #define HAVE_INT32_T 1 25 | #ifndef HAVE_INT32_T 26 | # define int32_t int32_t 27 | #endif 28 | 29 | #define HAVE_UINT32_T 1 30 | #ifndef HAVE_UINT32_T 31 | # define uint32_t uint32_t 32 | #endif 33 | 34 | #define HAVE_UINT16_T 1 35 | #ifndef HAVE_UINT16_T 36 | # define uint16_t uint16_t 37 | #endif 38 | 39 | #define HAVE_UINT8_T 1 40 | #ifndef HAVE_UINT8_T 41 | # define uint8_t uint8_t 42 | #endif 43 | 44 | /* #undef HAVE_SSIZE_T */ 45 | 46 | #ifndef HAVE_SSIZE_T 47 | # define ssize_t int 48 | #endif 49 | 50 | /* #undef HAVE_SNPRINTF */ 51 | 52 | #ifndef HAVE_SNPRINTF 53 | # define snprintf _snprintf 54 | #endif 55 | 56 | /* #undef HAVE_VSNPRINTF */ 57 | 58 | #define USE_URANDOM 1 59 | #define USE_WINDOWS_CRYPTOAPI 1 60 | -------------------------------------------------------------------------------- /ccan/typesafe_cb/test/compile_ok-typesafe_cb-undefined.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | /* const args in callbacks should be OK. */ 5 | 6 | static void _register_callback(void (*cb)(void *arg), void *arg) 7 | { 8 | } 9 | 10 | #define register_callback(cb, arg) \ 11 | _register_callback(typesafe_cb(void, void *, (cb), (arg)), (arg)) 12 | 13 | static void _register_callback_pre(void (*cb)(int x, void *arg), void *arg) 14 | { 15 | } 16 | 17 | #define register_callback_pre(cb, arg) \ 18 | _register_callback_pre(typesafe_cb_preargs(void, void *, (cb), (arg), int), (arg)) 19 | 20 | static void _register_callback_post(void (*cb)(void *arg, int x), void *arg) 21 | { 22 | } 23 | 24 | #define register_callback_post(cb, arg) \ 25 | _register_callback_post(typesafe_cb_postargs(void, void *, (cb), (arg), int), (arg)) 26 | 27 | struct undefined; 28 | 29 | static void my_callback(struct undefined *undef) 30 | { 31 | } 32 | 33 | static void my_callback_pre(int x, struct undefined *undef) 34 | { 35 | } 36 | 37 | static void my_callback_post(struct undefined *undef, int x) 38 | { 39 | } 40 | 41 | int main(int argc, char *argv[]) 42 | { 43 | struct undefined *handle = NULL; 44 | 45 | register_callback(my_callback, handle); 46 | register_callback_pre(my_callback_pre, handle); 47 | register_callback_post(my_callback_post, handle); 48 | return 0; 49 | } 50 | -------------------------------------------------------------------------------- /m4/sigaction.m4: -------------------------------------------------------------------------------- 1 | # sigaction.m4 serial 6 2 | dnl Copyright (C) 2008-2011 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | # Determine if sigaction interface is present. 8 | AC_DEFUN([gl_SIGACTION], 9 | [ 10 | AC_REQUIRE([gl_SIGNAL_H_DEFAULTS]) 11 | AC_CHECK_FUNCS_ONCE([sigaction]) 12 | if test $ac_cv_func_sigaction = yes; then 13 | AC_CHECK_MEMBERS([struct sigaction.sa_sigaction], , , 14 | [[#include ]]) 15 | if test $ac_cv_member_struct_sigaction_sa_sigaction = no; then 16 | HAVE_STRUCT_SIGACTION_SA_SIGACTION=0 17 | fi 18 | else 19 | HAVE_SIGACTION=0 20 | fi 21 | ]) 22 | 23 | # Prerequisites of the part of lib/signal.in.h and of lib/sigaction.c. 24 | AC_DEFUN([gl_PREREQ_SIGACTION], 25 | [ 26 | AC_REQUIRE([gl_SIGNAL_H_DEFAULTS]) 27 | AC_REQUIRE([AC_C_RESTRICT]) 28 | AC_REQUIRE([AC_TYPE_UID_T]) 29 | AC_REQUIRE([gl_PREREQ_SIG_HANDLER_H]) 30 | AC_CHECK_FUNCS_ONCE([sigaltstack siginterrupt]) 31 | AC_CHECK_TYPES([siginfo_t], [], [], [[ 32 | #include 33 | ]]) 34 | if test $ac_cv_type_siginfo_t = no; then 35 | HAVE_SIGINFO_T=0 36 | fi 37 | ]) 38 | 39 | # Prerequisites of lib/sig-handler.h. 40 | AC_DEFUN([gl_PREREQ_SIG_HANDLER_H], 41 | [ 42 | AC_REQUIRE([AC_C_INLINE]) 43 | ]) 44 | -------------------------------------------------------------------------------- /m4/00gnulib.m4: -------------------------------------------------------------------------------- 1 | # 00gnulib.m4 serial 2 2 | dnl Copyright (C) 2009-2011 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | dnl This file must be named something that sorts before all other 8 | dnl gnulib-provided .m4 files. It is needed until such time as we can 9 | dnl assume Autoconf 2.64, with its improved AC_DEFUN_ONCE semantics. 10 | 11 | # AC_DEFUN_ONCE([NAME], VALUE) 12 | # ---------------------------- 13 | # Define NAME to expand to VALUE on the first use (whether by direct 14 | # expansion, or by AC_REQUIRE), and to nothing on all subsequent uses. 15 | # Avoid bugs in AC_REQUIRE in Autoconf 2.63 and earlier. This 16 | # definition is slower than the version in Autoconf 2.64, because it 17 | # can only use interfaces that existed since 2.59; but it achieves the 18 | # same effect. Quoting is necessary to avoid confusing Automake. 19 | m4_version_prereq([2.63.263], [], 20 | [m4_define([AC][_DEFUN_ONCE], 21 | [AC][_DEFUN([$1], 22 | [AC_REQUIRE([_gl_DEFUN_ONCE([$1])], 23 | [m4_indir([_gl_DEFUN_ONCE([$1])])])])]dnl 24 | [AC][_DEFUN([_gl_DEFUN_ONCE([$1])], [$2])])]) 25 | 26 | # gl_00GNULIB 27 | # ----------- 28 | # Witness macro that this file has been included. Needed to force 29 | # Automake to include this file prior to all other gnulib .m4 files. 30 | AC_DEFUN([gl_00GNULIB]) 31 | -------------------------------------------------------------------------------- /kernel/x11evo/x11evo_blake.cl: -------------------------------------------------------------------------------- 1 | 2 | // blake 3 | { 4 | sph_u64 H0 = SPH_C64(0x6A09E667F3BCC908), H1 = SPH_C64(0xBB67AE8584CAA73B); 5 | sph_u64 H2 = SPH_C64(0x3C6EF372FE94F82B), H3 = SPH_C64(0xA54FF53A5F1D36F1); 6 | sph_u64 H4 = SPH_C64(0x510E527FADE682D1), H5 = SPH_C64(0x9B05688C2B3E6C1F); 7 | sph_u64 H6 = SPH_C64(0x1F83D9ABFB41BD6B), H7 = SPH_C64(0x5BE0CD19137E2179); 8 | sph_u64 S0 = 0, S1 = 0, S2 = 0, S3 = 0; 9 | sph_u64 T0 = SPH_C64(0xFFFFFFFFFFFFFC00) + (80 << 3), T1 = 0xFFFFFFFFFFFFFFFF;; 10 | 11 | if ((T0 = SPH_T64(T0 + 1024)) < 1024) 12 | { 13 | T1 = SPH_T64(T1 + 1); 14 | } 15 | sph_u64 M0, M1, M2, M3, M4, M5, M6, M7; 16 | sph_u64 M8, M9, MA, MB, MC, MD, ME, MF; 17 | sph_u64 V0, V1, V2, V3, V4, V5, V6, V7; 18 | sph_u64 V8, V9, VA, VB, VC, VD, VE, VF; 19 | M0 = DEC64BE(block + 0); 20 | M1 = DEC64BE(block + 8); 21 | M2 = DEC64BE(block + 16); 22 | M3 = DEC64BE(block + 24); 23 | M4 = DEC64BE(block + 32); 24 | M5 = DEC64BE(block + 40); 25 | M6 = DEC64BE(block + 48); 26 | M7 = DEC64BE(block + 56); 27 | M8 = DEC64BE(block + 64); 28 | M9 = DEC64BE(block + 72); 29 | M9 &= 0xFFFFFFFF00000000; 30 | M9 ^= SWAP4(gid); 31 | MA = 0x8000000000000000; 32 | MB = 0; 33 | MC = 0; 34 | MD = 1; 35 | ME = 0; 36 | MF = 0x280; 37 | 38 | COMPRESS64; 39 | 40 | hash.h8[0] = H0; 41 | hash.h8[1] = H1; 42 | hash.h8[2] = H2; 43 | hash.h8[3] = H3; 44 | hash.h8[4] = H4; 45 | hash.h8[5] = H5; 46 | hash.h8[6] = H6; 47 | hash.h8[7] = H7; 48 | } 49 | -------------------------------------------------------------------------------- /m4/gnulib-cache.m4: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2002-2011 Free Software Foundation, Inc. 2 | # 3 | # This file is free software, distributed under the terms of the GNU 4 | # General Public License. As a special exception to the GNU General 5 | # Public License, this file may be distributed as part of a program 6 | # that contains a configuration script generated by Autoconf, under 7 | # the same distribution terms as the rest of that program. 8 | # 9 | # Generated by gnulib-tool. 10 | # 11 | # This file represents the specification of how gnulib-tool is used. 12 | # It acts as a cache: It is written and read by gnulib-tool. 13 | # In projects that use version control, this file is meant to be put under 14 | # version control, like the configure.ac and various Makefile.am files. 15 | 16 | 17 | # Specification in the form of a command-line invocation: 18 | # gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=. --no-conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files memmem sigaction signal 19 | 20 | # Specification in the form of a few gnulib-tool.m4 macro invocations: 21 | gl_LOCAL_DIR([]) 22 | gl_MODULES([ 23 | memmem 24 | sigaction 25 | signal 26 | ]) 27 | gl_AVOID([]) 28 | gl_SOURCE_BASE([lib]) 29 | gl_M4_BASE([m4]) 30 | gl_PO_BASE([]) 31 | gl_DOC_BASE([doc]) 32 | gl_TESTS_BASE([tests]) 33 | gl_LIB([libgnu]) 34 | gl_MAKEFILE_NAME([]) 35 | gl_MACRO_PREFIX([gl]) 36 | gl_PO_DOMAIN([]) 37 | gl_WITNESS_C_DOMAIN([]) 38 | gl_VC_FILES([false]) 39 | -------------------------------------------------------------------------------- /ccan/typesafe_cb/test/compile_ok-typesafe_cb-vars.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | /* const args in callbacks should be OK. */ 5 | 6 | static void _register_callback(void (*cb)(void *arg), void *arg) 7 | { 8 | } 9 | 10 | #define register_callback(cb, arg) \ 11 | _register_callback(typesafe_cb(void, void *, (cb), (arg)), (arg)) 12 | 13 | static void _register_callback_pre(void (*cb)(int x, void *arg), void *arg) 14 | { 15 | } 16 | 17 | #define register_callback_pre(cb, arg) \ 18 | _register_callback_pre(typesafe_cb_preargs(void, void *, (cb), (arg), int), (arg)) 19 | 20 | static void _register_callback_post(void (*cb)(void *arg, int x), void *arg) 21 | { 22 | } 23 | 24 | #define register_callback_post(cb, arg) \ 25 | _register_callback_post(typesafe_cb_postargs(void, void *, (cb), (arg), int), (arg)) 26 | 27 | struct undefined; 28 | 29 | static void my_callback(struct undefined *undef) 30 | { 31 | } 32 | 33 | static void my_callback_pre(int x, struct undefined *undef) 34 | { 35 | } 36 | 37 | static void my_callback_post(struct undefined *undef, int x) 38 | { 39 | } 40 | 41 | int main(int argc, char *argv[]) 42 | { 43 | struct undefined *handle = NULL; 44 | void (*cb)(struct undefined *undef) = my_callback; 45 | void (*pre)(int x, struct undefined *undef) = my_callback_pre; 46 | void (*post)(struct undefined *undef, int x) = my_callback_post; 47 | 48 | register_callback(cb, handle); 49 | register_callback_pre(pre, handle); 50 | register_callback_post(post, handle); 51 | return 0; 52 | } 53 | -------------------------------------------------------------------------------- /api-example.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python2.7 2 | 3 | # Copyright 2013 Setkeh Mkfr 4 | # 5 | # This program is free software; you can redistribute it and/or modify it under 6 | # the terms of the GNU General Public License as published by the Free Software 7 | # Foundation; either version 3 of the License, or (at your option) any later 8 | # version. See COPYING for more details. 9 | 10 | #Short Python Example for connecting to The sgminer API 11 | #Written By: setkeh 12 | #Thanks to Jezzz for all his Support. 13 | #NOTE: When adding a param with a pipe | in bash or ZSH you must wrap the arg in quotes 14 | #E.G "pga|0" 15 | 16 | import socket 17 | import json 18 | import sys 19 | 20 | def linesplit(socket): 21 | buffer = socket.recv(4096) 22 | done = False 23 | while not done: 24 | more = socket.recv(4096) 25 | if not more: 26 | done = True 27 | else: 28 | buffer = buffer+more 29 | if buffer: 30 | return buffer 31 | 32 | api_command = sys.argv[1].split('|') 33 | 34 | if len(sys.argv) < 3: 35 | api_ip = '127.0.0.1' 36 | api_port = 4028 37 | else: 38 | api_ip = sys.argv[2] 39 | api_port = sys.argv[3] 40 | 41 | s = socket.socket(socket.AF_INET,socket.SOCK_STREAM) 42 | s.connect((api_ip,int(api_port))) 43 | if len(api_command) == 2: 44 | s.send(json.dumps({"command":api_command[0],"parameter":api_command[1]})) 45 | else: 46 | s.send(json.dumps({"command":api_command[0]})) 47 | 48 | response = linesplit(s) 49 | response = response.replace('\x00','') 50 | response = json.loads(response) 51 | print response 52 | s.close() 53 | -------------------------------------------------------------------------------- /doc/BUGS.md: -------------------------------------------------------------------------------- 1 | # Bug reporting 2 | 3 | First and foremost, see `README.md` and other documentation in `doc`. 4 | Although the documentation might be outdated, a lot of it is still 5 | relevant. 6 | 7 | The [issue tracker](https://github.com/veox/sgminer/issues) is there 8 | specifically for reporting bugs, issues and proposed improvements. Other 9 | communication channels are not necessarily monitored. 10 | 11 | Search the issue list to see if it has already been reported. 12 | 13 | Make the title of your report informative. 14 | 15 | Information that may be relevant, depending on the nature of your issue: 16 | 17 | * OS version; 18 | * Catalyst driver version; 19 | * AMD APP SDK version; 20 | * AMD ADL version; 21 | * GPUs used (`sgminer --ndevs`); 22 | * whether you're using a pre-compiled binary or built from source; 23 | * `sgminer` version (`sgminer --version` and/or `git describe`); 24 | * contents of the configuration file and pool connection info; 25 | * launch procedure (manual or via script); 26 | * steps to repeat; 27 | * expected result; 28 | * actual result; 29 | * debug output (`sgminer --text-only --debug --verbose`). 30 | 31 | Be careful when posting the contents of your configuration file: although 32 | pool connection and protocol information is relevant in a certain sub-class 33 | of issues, login credentials (username and password) are most often not. Run 34 | with `--incognito` if possible. 35 | 36 | If there is a need to provide more than a screenfull of log 37 | data, it is preferred that a link is given instead. Try 38 | [gist](https://gist.github.com). 39 | -------------------------------------------------------------------------------- /roadmap.md: -------------------------------------------------------------------------------- 1 | This project is being *actively* developed by Genesis Mining. Here's our projected timeline - this is not set in stone, and will be updated to keep the community updated. 2 | 3 | ### November, 2016 4 | 5 | + Integrate Zcash miner with Stratum support 6 | + Polish and optimize SilentArmy kernel. 7 | + Add fan control and temperature monitoring. 8 | + Clean up, and combine, the ZCash, Ethereum and XMR branches. 9 | 10 | ### December, 2016 11 | 12 | + Integrate optimized kernels for AES, Shabal, Groestl and Echo. 13 | + Performance increases for ZCash, and XMR. 14 | + Bug Fixes. 15 | 16 | ### January, 2017 17 | 18 | + Integrate optimized kernels for Cubehash, Fugue, Hamsi. 19 | + Integrate HODLCoin, Espers and LBRY. 20 | + Look into integrating community requests. 21 | 22 | ### February, 2017 23 | 24 | + Integrate optimized kernels for JH, Luffa, Shavite. 25 | + Performance increases for various miners. 26 | + Integrate control and finetuning for memory clocks for GPUs. 27 | + Add CPU mining 28 | 29 | ### March, 2017 30 | 31 | + Integrate optimized kernels for SIMD, Skein, Whirlpool. 32 | + Performance increases and bug fixes. 33 | + Slow rewrite of SGMiner, replacing else/if statements with function pointers (in scanhash_opencl) and removing the various goto statements. 34 | 35 | ### April, 2017 36 | 37 | + Create an updated manual for SGMiner-GM, including a detailed walkthrough of setting it up on various systems (Arch Linux, Linux Mint, Ubuntu, PiMP and EthOS). 38 | + Addition of a GUI for those who prefer it. 39 | + Performance increases for various kernels and coins. 40 | -------------------------------------------------------------------------------- /kernel/x11evo/x11evo_jh.cl: -------------------------------------------------------------------------------- 1 | 2 | // jh 3 | { 4 | sph_u64 h0h = C64e(0x6fd14b963e00aa17), h0l = C64e(0x636a2e057a15d543), h1h = C64e(0x8a225e8d0c97ef0b), h1l = C64e(0xe9341259f2b3c361), h2h = C64e(0x891da0c1536f801e), h2l = C64e(0x2aa9056bea2b6d80), h3h = C64e(0x588eccdb2075baa6), h3l = C64e(0xa90f3a76baf83bf7); 5 | sph_u64 h4h = C64e(0x0169e60541e34a69), h4l = C64e(0x46b58a8e2e6fe65a), h5h = C64e(0x1047a7d0c1843c24), h5l = C64e(0x3b6e71b12d5ac199), h6h = C64e(0xcf57f6ec9db1f856), h6l = C64e(0xa706887c5716b156), h7h = C64e(0xe3c2fcdfe68517fb), h7l = C64e(0x545a4678cc8cdd4b); 6 | sph_u64 tmp; 7 | 8 | for (int i = 0; i < 2; i++) 9 | { 10 | if (i == 0) { 11 | h0h ^= DEC64BE(hash.h8[0]); 12 | h0l ^= DEC64BE(hash.h8[1]); 13 | h1h ^= DEC64BE(hash.h8[2]); 14 | h1l ^= DEC64BE(hash.h8[3]); 15 | h2h ^= DEC64BE(hash.h8[4]); 16 | h2l ^= DEC64BE(hash.h8[5]); 17 | h3h ^= DEC64BE(hash.h8[6]); 18 | h3l ^= DEC64BE(hash.h8[7]); 19 | } 20 | else if (i == 1) { 21 | h4h ^= DEC64BE(hash.h8[0]); 22 | h4l ^= DEC64BE(hash.h8[1]); 23 | h5h ^= DEC64BE(hash.h8[2]); 24 | h5l ^= DEC64BE(hash.h8[3]); 25 | h6h ^= DEC64BE(hash.h8[4]); 26 | h6l ^= DEC64BE(hash.h8[5]); 27 | h7h ^= DEC64BE(hash.h8[6]); 28 | h7l ^= DEC64BE(hash.h8[7]); 29 | 30 | h0h ^= 0x80; 31 | h3l ^= 0x2000000000000; 32 | } 33 | E8; 34 | } 35 | 36 | h4h ^= 0x80; 37 | h7l ^= 0x2000000000000; 38 | 39 | hash.h8[0] = h4h; 40 | hash.h8[1] = h4l; 41 | hash.h8[2] = h5h; 42 | hash.h8[3] = h5l; 43 | hash.h8[4] = h6h; 44 | hash.h8[5] = h6l; 45 | hash.h8[6] = h7h; 46 | hash.h8[7] = h7l; 47 | } 48 | -------------------------------------------------------------------------------- /m4/signalblocking.m4: -------------------------------------------------------------------------------- 1 | # signalblocking.m4 serial 11 2 | dnl Copyright (C) 2001-2002, 2006-2011 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | # Determine available signal blocking primitives. Three different APIs exist: 8 | # 1) POSIX: sigemptyset, sigaddset, sigprocmask 9 | # 2) SYSV: sighold, sigrelse 10 | # 3) BSD: sigblock, sigsetmask 11 | # For simplicity, here we check only for the POSIX signal blocking. 12 | AC_DEFUN([gl_SIGNALBLOCKING], 13 | [ 14 | AC_REQUIRE([gl_SIGNAL_H_DEFAULTS]) 15 | signals_not_posix= 16 | AC_EGREP_HEADER([sigset_t], [signal.h], , [signals_not_posix=1]) 17 | if test -z "$signals_not_posix"; then 18 | AC_CHECK_FUNC([sigprocmask], [gl_cv_func_sigprocmask=1]) 19 | fi 20 | if test -z "$gl_cv_func_sigprocmask"; then 21 | HAVE_POSIX_SIGNALBLOCKING=0 22 | fi 23 | ]) 24 | 25 | # Prerequisites of the part of lib/signal.in.h and of lib/sigprocmask.c. 26 | AC_DEFUN([gl_PREREQ_SIGPROCMASK], 27 | [ 28 | AC_REQUIRE([gl_SIGNAL_H_DEFAULTS]) 29 | AC_CHECK_TYPES([sigset_t], 30 | [gl_cv_type_sigset_t=yes], [gl_cv_type_sigset_t=no], 31 | [#include 32 | /* Mingw defines sigset_t not in , but in . */ 33 | #include ]) 34 | if test $gl_cv_type_sigset_t != yes; then 35 | HAVE_SIGSET_T=0 36 | fi 37 | dnl HAVE_SIGSET_T is 1 if the system lacks the sigprocmask function but has 38 | dnl the sigset_t type. 39 | AC_SUBST([HAVE_SIGSET_T]) 40 | ]) 41 | -------------------------------------------------------------------------------- /ccan/opt/test/run-correct-reporting.c: -------------------------------------------------------------------------------- 1 | /* Make sure when multiple equivalent options, correct one is used for errors */ 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include "utils.h" 10 | 11 | int main(int argc, char *argv[]) 12 | { 13 | plan_tests(12); 14 | 15 | /* --aaa without args. */ 16 | opt_register_arg("-a|--aaa", test_arg, NULL, "aaa", ""); 17 | ok1(!parse_args(&argc, &argv, "--aaa", NULL)); 18 | ok1(strstr(err_output, ": --aaa: requires an argument")); 19 | free(err_output); 20 | err_output = NULL; 21 | ok1(!parse_args(&argc, &argv, "-a", NULL)); 22 | ok1(strstr(err_output, ": -a: requires an argument")); 23 | free(err_output); 24 | err_output = NULL; 25 | 26 | /* Multiple */ 27 | opt_register_arg("--bbb|-b|-c|--ccc", test_arg, NULL, "aaa", ""); 28 | ok1(!parse_args(&argc, &argv, "--bbb", NULL)); 29 | ok1(strstr(err_output, ": --bbb: requires an argument")); 30 | free(err_output); 31 | err_output = NULL; 32 | ok1(!parse_args(&argc, &argv, "-b", NULL)); 33 | ok1(strstr(err_output, ": -b: requires an argument")); 34 | free(err_output); 35 | err_output = NULL; 36 | ok1(!parse_args(&argc, &argv, "-c", NULL)); 37 | ok1(strstr(err_output, ": -c: requires an argument")); 38 | free(err_output); 39 | err_output = NULL; 40 | ok1(!parse_args(&argc, &argv, "--ccc", NULL)); 41 | ok1(strstr(err_output, ": --ccc: requires an argument")); 42 | free(err_output); 43 | err_output = NULL; 44 | 45 | /* parse_args allocates argv */ 46 | free(argv); 47 | return exit_status(); 48 | } 49 | 50 | -------------------------------------------------------------------------------- /algorithm/ethgencache.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "miner.h" 4 | #include "sph/sph_keccak.h" 5 | #include "algorithm/ethash.h" 6 | #include "algorithm/eth-sha3.h" 7 | 8 | typedef union node 9 | { 10 | uint8_t bytes[16 * 4]; 11 | uint32_t words[16]; 12 | uint64_t double_words[16 / 2]; 13 | } node; 14 | 15 | // Output (cache_nodes) MUST have at least cache_size bytes 16 | static void EthGenerateCache(uint8_t *cache_nodes_in, const uint8_t *seedhash, uint64_t cache_size) 17 | { 18 | uint32_t const num_nodes = (uint32_t)(cache_size / sizeof(node)); 19 | node *cache_nodes = (node *)cache_nodes_in; 20 | 21 | SHA3_512(cache_nodes[0].bytes, seedhash, 32); 22 | 23 | for(uint32_t i = 1; i != num_nodes; ++i) { 24 | SHA3_512(cache_nodes[i].bytes, cache_nodes[i - 1].bytes, 64); 25 | } 26 | 27 | for(uint32_t j = 0; j < 3; j++) { // this one can be unrolled entirely, ETHASH_CACHE_ROUNDS is constant 28 | for(uint32_t i = 0; i != num_nodes; i++) { 29 | uint32_t const idx = cache_nodes[i].words[0] % num_nodes; 30 | node data; 31 | data = cache_nodes[(num_nodes - 1 + i) % num_nodes]; 32 | for(uint32_t w = 0; w != 16; ++w) { // this one can be unrolled entirely as well 33 | data.words[w] ^= cache_nodes[idx].words[w]; 34 | } 35 | 36 | SHA3_512(cache_nodes[i].bytes, data.bytes, sizeof(data)); 37 | } 38 | } 39 | } 40 | 41 | 42 | void eth_gen_cache(struct pool *pool) { 43 | size_t cache_size = EthGetCacheSize(pool->eth_cache.current_epoch); 44 | pool->eth_cache.dag_cache = realloc(pool->eth_cache.dag_cache, cache_size); 45 | EthGenerateCache(pool->eth_cache.dag_cache, pool->eth_cache.seed_hash, cache_size); 46 | } 47 | -------------------------------------------------------------------------------- /m4/gnulib-tool.m4: -------------------------------------------------------------------------------- 1 | # gnulib-tool.m4 serial 2 2 | dnl Copyright (C) 2004-2005, 2009-2011 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | dnl The following macros need not be invoked explicitly. 8 | dnl Invoking them does nothing except to declare default arguments 9 | dnl for "gnulib-tool --import". 10 | 11 | dnl Usage: gl_LOCAL_DIR([DIR]) 12 | AC_DEFUN([gl_LOCAL_DIR], []) 13 | 14 | dnl Usage: gl_MODULES([module1 module2 ...]) 15 | AC_DEFUN([gl_MODULES], []) 16 | 17 | dnl Usage: gl_AVOID([module1 module2 ...]) 18 | AC_DEFUN([gl_AVOID], []) 19 | 20 | dnl Usage: gl_SOURCE_BASE([DIR]) 21 | AC_DEFUN([gl_SOURCE_BASE], []) 22 | 23 | dnl Usage: gl_M4_BASE([DIR]) 24 | AC_DEFUN([gl_M4_BASE], []) 25 | 26 | dnl Usage: gl_PO_BASE([DIR]) 27 | AC_DEFUN([gl_PO_BASE], []) 28 | 29 | dnl Usage: gl_DOC_BASE([DIR]) 30 | AC_DEFUN([gl_DOC_BASE], []) 31 | 32 | dnl Usage: gl_TESTS_BASE([DIR]) 33 | AC_DEFUN([gl_TESTS_BASE], []) 34 | 35 | dnl Usage: gl_WITH_TESTS 36 | AC_DEFUN([gl_WITH_TESTS], []) 37 | 38 | dnl Usage: gl_LIB([LIBNAME]) 39 | AC_DEFUN([gl_LIB], []) 40 | 41 | dnl Usage: gl_LGPL or gl_LGPL([VERSION]) 42 | AC_DEFUN([gl_LGPL], []) 43 | 44 | dnl Usage: gl_MAKEFILE_NAME([FILENAME]) 45 | AC_DEFUN([gl_MAKEFILE_NAME], []) 46 | 47 | dnl Usage: gl_LIBTOOL 48 | AC_DEFUN([gl_LIBTOOL], []) 49 | 50 | dnl Usage: gl_MACRO_PREFIX([PREFIX]) 51 | AC_DEFUN([gl_MACRO_PREFIX], []) 52 | 53 | dnl Usage: gl_PO_DOMAIN([DOMAIN]) 54 | AC_DEFUN([gl_PO_DOMAIN], []) 55 | 56 | dnl Usage: gl_VC_FILES([BOOLEAN]) 57 | AC_DEFUN([gl_VC_FILES], []) 58 | -------------------------------------------------------------------------------- /m4/stddef_h.m4: -------------------------------------------------------------------------------- 1 | dnl A placeholder for POSIX 2008 , for platforms that have issues. 2 | # stddef_h.m4 serial 4 3 | dnl Copyright (C) 2009-2011 Free Software Foundation, Inc. 4 | dnl This file is free software; the Free Software Foundation 5 | dnl gives unlimited permission to copy and/or distribute it, 6 | dnl with or without modifications, as long as this notice is preserved. 7 | 8 | AC_DEFUN([gl_STDDEF_H], 9 | [ 10 | AC_REQUIRE([gl_STDDEF_H_DEFAULTS]) 11 | AC_REQUIRE([gt_TYPE_WCHAR_T]) 12 | STDDEF_H= 13 | if test $gt_cv_c_wchar_t = no; then 14 | HAVE_WCHAR_T=0 15 | STDDEF_H=stddef.h 16 | fi 17 | AC_CACHE_CHECK([whether NULL can be used in arbitrary expressions], 18 | [gl_cv_decl_null_works], 19 | [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include 20 | int test[2 * (sizeof NULL == sizeof (void *)) -1]; 21 | ]])], 22 | [gl_cv_decl_null_works=yes], 23 | [gl_cv_decl_null_works=no])]) 24 | if test $gl_cv_decl_null_works = no; then 25 | REPLACE_NULL=1 26 | STDDEF_H=stddef.h 27 | fi 28 | AC_SUBST([STDDEF_H]) 29 | AM_CONDITIONAL([GL_GENERATE_STDDEF_H], [test -n "$STDDEF_H"]) 30 | if test -n "$STDDEF_H"; then 31 | gl_NEXT_HEADERS([stddef.h]) 32 | fi 33 | ]) 34 | 35 | AC_DEFUN([gl_STDDEF_MODULE_INDICATOR], 36 | [ 37 | dnl Use AC_REQUIRE here, so that the default settings are expanded once only. 38 | AC_REQUIRE([gl_STDDEF_H_DEFAULTS]) 39 | gl_MODULE_INDICATOR_SET_VARIABLE([$1]) 40 | ]) 41 | 42 | AC_DEFUN([gl_STDDEF_H_DEFAULTS], 43 | [ 44 | dnl Assume proper GNU behavior unless another module says otherwise. 45 | REPLACE_NULL=0; AC_SUBST([REPLACE_NULL]) 46 | HAVE_WCHAR_T=1; AC_SUBST([HAVE_WCHAR_T]) 47 | ]) 48 | -------------------------------------------------------------------------------- /kernel/x11evo/x11evo_echo.cl: -------------------------------------------------------------------------------- 1 | 2 | // echo 3 | { 4 | sph_u64 W00, W01, W10, W11, W20, W21, W30, W31, W40, W41, W50, W51, W60, W61, W70, W71, W80, W81, W90, W91, WA0, WA1, WB0, WB1, WC0, WC1, WD0, WD1, WE0, WE1, WF0, WF1; 5 | sph_u64 Vb00, Vb01, Vb10, Vb11, Vb20, Vb21, Vb30, Vb31, Vb40, Vb41, Vb50, Vb51, Vb60, Vb61, Vb70, Vb71; 6 | Vb00 = Vb10 = Vb20 = Vb30 = Vb40 = Vb50 = Vb60 = Vb70 = 512UL; 7 | Vb01 = Vb11 = Vb21 = Vb31 = Vb41 = Vb51 = Vb61 = Vb71 = 0; 8 | 9 | sph_u32 K0 = 512; 10 | sph_u32 K1 = 0; 11 | sph_u32 K2 = 0; 12 | sph_u32 K3 = 0; 13 | 14 | W00 = Vb00; 15 | W01 = Vb01; 16 | W10 = Vb10; 17 | W11 = Vb11; 18 | W20 = Vb20; 19 | W21 = Vb21; 20 | W30 = Vb30; 21 | W31 = Vb31; 22 | W40 = Vb40; 23 | W41 = Vb41; 24 | W50 = Vb50; 25 | W51 = Vb51; 26 | W60 = Vb60; 27 | W61 = Vb61; 28 | W70 = Vb70; 29 | W71 = Vb71; 30 | W80 = hash.h8[0]; 31 | W81 = hash.h8[1]; 32 | W90 = hash.h8[2]; 33 | W91 = hash.h8[3]; 34 | WA0 = hash.h8[4]; 35 | WA1 = hash.h8[5]; 36 | WB0 = hash.h8[6]; 37 | WB1 = hash.h8[7]; 38 | WC0 = 0x80; 39 | WC1 = 0; 40 | WD0 = 0; 41 | WD1 = 0; 42 | WE0 = 0; 43 | WE1 = 0x200000000000000; 44 | WF0 = 0x200; 45 | WF1 = 0; 46 | 47 | for (unsigned u = 0; u < 10; u++) { 48 | BIG_ROUND; 49 | } 50 | 51 | Vb00 ^= hash.h8[0] ^ W00 ^ W80; 52 | Vb01 ^= hash.h8[1] ^ W01 ^ W81; 53 | Vb10 ^= hash.h8[2] ^ W10 ^ W90; 54 | Vb11 ^= hash.h8[3] ^ W11 ^ W91; 55 | Vb20 ^= hash.h8[4] ^ W20 ^ WA0; 56 | Vb21 ^= hash.h8[5] ^ W21 ^ WA1; 57 | Vb30 ^= hash.h8[6] ^ W30 ^ WB0; 58 | Vb31 ^= hash.h8[7] ^ W31 ^ WB1; 59 | 60 | hash.h8[0] = Vb00; 61 | hash.h8[1] = Vb01; 62 | hash.h8[2] = Vb10; 63 | hash.h8[3] = Vb11; 64 | hash.h8[4] = Vb20; 65 | hash.h8[5] = Vb21; 66 | hash.h8[6] = Vb30; 67 | hash.h8[7] = Vb31; 68 | 69 | } 70 | -------------------------------------------------------------------------------- /ccan/compiler/_info: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "config.h" 4 | 5 | /** 6 | * compiler - macros for common compiler extensions 7 | * 8 | * Abstracts away some compiler hints. Currently these include: 9 | * - COLD 10 | * For functions not called in fast paths (aka. cold functions) 11 | * - PRINTF_FMT 12 | * For functions which take printf-style parameters. 13 | * - IDEMPOTENT 14 | * For functions which return the same value for same parameters. 15 | * - NEEDED 16 | * For functions and variables which must be emitted even if unused. 17 | * - UNNEEDED 18 | * For functions and variables which need not be emitted if unused. 19 | * - UNUSED 20 | * For parameters which are not used. 21 | * - IS_COMPILE_CONSTANT 22 | * For using different tradeoffs for compiletime vs runtime evaluation. 23 | * 24 | * License: LGPL (3 or any later version) 25 | * Author: Rusty Russell 26 | * 27 | * Example: 28 | * #include 29 | * #include 30 | * #include 31 | * 32 | * // Example of a (slow-path) logging function. 33 | * static int log_threshold = 2; 34 | * static void COLD PRINTF_FMT(2,3) 35 | * logger(int level, const char *fmt, ...) 36 | * { 37 | * va_list ap; 38 | * va_start(ap, fmt); 39 | * if (level >= log_threshold) 40 | * vfprintf(stderr, fmt, ap); 41 | * va_end(ap); 42 | * } 43 | * 44 | * int main(int argc, char *argv[]) 45 | * { 46 | * if (argc != 1) { 47 | * logger(3, "Don't want %i arguments!\n", argc-1); 48 | * return 1; 49 | * } 50 | * return 0; 51 | * } 52 | */ 53 | int main(int argc, char *argv[]) 54 | { 55 | /* Expect exactly one argument */ 56 | if (argc != 2) 57 | return 1; 58 | 59 | if (strcmp(argv[1], "depends") == 0) { 60 | return 0; 61 | } 62 | 63 | return 1; 64 | } 65 | -------------------------------------------------------------------------------- /winbuild/dist/include/jansson_config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2014 Petri Lehtinen 3 | * 4 | * Jansson is free software; you can redistribute it and/or modify 5 | * it under the terms of the MIT license. See LICENSE for details. 6 | * 7 | * 8 | * This file specifies a part of the site-specific configuration for 9 | * Jansson, namely those things that affect the public API in 10 | * jansson.h. 11 | * 12 | * The CMake system will generate the jansson_config.h file and 13 | * copy it to the build and install directories. 14 | */ 15 | 16 | #ifndef JANSSON_CONFIG_H 17 | #define JANSSON_CONFIG_H 18 | 19 | /* Define this so that we can disable scattered automake configuration in source files */ 20 | #ifndef JANSSON_USING_CMAKE 21 | #define JANSSON_USING_CMAKE 22 | #endif 23 | 24 | /* Note: when using cmake, JSON_INTEGER_IS_LONG_LONG is not defined nor used, 25 | * as we will also check for __int64 etc types. 26 | * (the definition was used in the automake system) */ 27 | 28 | /* Include our standard type header for the integer typedef */ 29 | 30 | #if defined(HAVE_STDINT_H) 31 | # include 32 | #elif defined(HAVE_INTTYPES_H) 33 | # include 34 | #elif defined(HAVE_SYS_TYPES_H) 35 | # include 36 | #endif 37 | 38 | 39 | /* If your compiler supports the inline keyword in C, JSON_INLINE is 40 | defined to `inline', otherwise empty. In C++, the inline is always 41 | supported. */ 42 | #ifdef __cplusplus 43 | #define JSON_INLINE inline 44 | #else 45 | #define JSON_INLINE __inline 46 | #endif 47 | 48 | 49 | #define json_int_t long long 50 | #define json_strtoint _strtoi64 51 | #define JSON_INTEGER_FORMAT "I64d" 52 | 53 | 54 | /* If locale.h and localeconv() are available, define to 1, otherwise to 0. */ 55 | #define JSON_HAVE_LOCALECONV 1 56 | 57 | 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /winbuild/jansson/jansson_config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2014 Petri Lehtinen 3 | * 4 | * Jansson is free software; you can redistribute it and/or modify 5 | * it under the terms of the MIT license. See LICENSE for details. 6 | * 7 | * 8 | * This file specifies a part of the site-specific configuration for 9 | * Jansson, namely those things that affect the public API in 10 | * jansson.h. 11 | * 12 | */ 13 | 14 | #ifndef JANSSON_CONFIG_H 15 | #define JANSSON_CONFIG_H 16 | 17 | /* Define this so that we can disable scattered automake configuration in source files */ 18 | #ifndef JANSSON_USING_CMAKE 19 | #define JANSSON_USING_CMAKE 20 | #endif 21 | 22 | /* Note: when using cmake, JSON_INTEGER_IS_LONG_LONG is not defined nor used, 23 | * as we will also check for __int64 etc types. 24 | * (the definition was used in the automake system) */ 25 | 26 | /* Bring in the cmake-detected defines */ 27 | #define HAVE_STDINT_H 1 28 | /* #undef HAVE_INTTYPES_H */ 29 | /* #undef HAVE_SYS_TYPES_H */ 30 | 31 | /* Include our standard type header for the integer typedef */ 32 | 33 | #if defined(HAVE_STDINT_H) 34 | # include 35 | #elif defined(HAVE_INTTYPES_H) 36 | # include 37 | #elif defined(HAVE_SYS_TYPES_H) 38 | # include 39 | #endif 40 | 41 | 42 | /* If your compiler supports the inline keyword in C, JSON_INLINE is 43 | defined to `inline', otherwise empty. In C++, the inline is always 44 | supported. */ 45 | #ifdef __cplusplus 46 | #define JSON_INLINE inline 47 | #else 48 | #define JSON_INLINE __inline 49 | #endif 50 | 51 | 52 | #define json_int_t long long 53 | #define json_strtoint _strtoi64 54 | #define JSON_INTEGER_FORMAT "I64d" 55 | 56 | 57 | /* If locale.h and localeconv() are available, define to 1, otherwise to 0. */ 58 | #define JSON_HAVE_LOCALECONV 1 59 | 60 | 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /lib/dummy.c: -------------------------------------------------------------------------------- 1 | /* A dummy file, to prevent empty libraries from breaking builds. 2 | Copyright (C) 2004, 2007, 2009-2011 Free Software Foundation, Inc. 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . */ 16 | 17 | /* Some systems, reportedly OpenBSD and Mac OS X, refuse to create 18 | libraries without any object files. You might get an error like: 19 | 20 | > ar cru .libs/libgl.a 21 | > ar: no archive members specified 22 | 23 | Compiling this file, and adding its object file to the library, will 24 | prevent the library from being empty. */ 25 | 26 | /* Some systems, such as Solaris with cc 5.0, refuse to work with libraries 27 | that don't export any symbol. You might get an error like: 28 | 29 | > cc ... libgnu.a 30 | > ild: (bad file) garbled symbol table in archive ../gllib/libgnu.a 31 | 32 | Compiling this file, and adding its object file to the library, will 33 | prevent the library from exporting no symbols. */ 34 | 35 | #ifdef __sun 36 | /* This declaration ensures that the library will export at least 1 symbol. */ 37 | int gl_dummy_symbol; 38 | #else 39 | /* This declaration is solely to ensure that after preprocessing 40 | this file is never empty. */ 41 | typedef int dummy; 42 | #endif 43 | -------------------------------------------------------------------------------- /lib/sig-handler.h: -------------------------------------------------------------------------------- 1 | /* Convenience declarations when working with . 2 | 3 | Copyright (C) 2008-2011 Free Software Foundation, Inc. 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . */ 17 | 18 | #ifndef _GL_SIG_HANDLER_H 19 | #define _GL_SIG_HANDLER_H 20 | 21 | #include 22 | 23 | /* Convenience type when working with signal handlers. */ 24 | typedef void (*sa_handler_t) (int); 25 | 26 | /* Return the handler of a signal, as a sa_handler_t value regardless 27 | of its true type. The resulting function can be compared to 28 | special values like SIG_IGN but it is not portable to call it. */ 29 | static inline sa_handler_t 30 | get_handler (struct sigaction const *a) 31 | { 32 | #ifdef SA_SIGINFO 33 | /* POSIX says that special values like SIG_IGN can only occur when 34 | action.sa_flags does not contain SA_SIGINFO. But in Linux 2.4, 35 | for example, sa_sigaction and sa_handler are aliases and a signal 36 | is ignored if sa_sigaction (after casting) equals SIG_IGN. So 37 | use (and cast) sa_sigaction in that case. */ 38 | if (a->sa_flags & SA_SIGINFO) 39 | return (sa_handler_t) a->sa_sigaction; 40 | #endif 41 | return a->sa_handler; 42 | } 43 | 44 | #endif /* _GL_SIG_HANDLER_H */ 45 | -------------------------------------------------------------------------------- /kernel/x11evo/x11evo_shavite.cl: -------------------------------------------------------------------------------- 1 | 2 | 3 | // shavite 4 | { 5 | // IV 6 | sph_u32 h0 = SPH_C32(0x72FCCDD8), h1 = SPH_C32(0x79CA4727), h2 = SPH_C32(0x128A077B), h3 = SPH_C32(0x40D55AEC); 7 | sph_u32 h4 = SPH_C32(0xD1901A06), h5 = SPH_C32(0x430AE307), h6 = SPH_C32(0xB29F5CD1), h7 = SPH_C32(0xDF07FBFC); 8 | sph_u32 h8 = SPH_C32(0x8E45D73D), h9 = SPH_C32(0x681AB538), hA = SPH_C32(0xBDE86578), hB = SPH_C32(0xDD577E47); 9 | sph_u32 hC = SPH_C32(0xE275EADE), hD = SPH_C32(0x502D9FCD), hE = SPH_C32(0xB9357178), hF = SPH_C32(0x022A4B9A); 10 | 11 | // state 12 | sph_u32 rk00, rk01, rk02, rk03, rk04, rk05, rk06, rk07; 13 | sph_u32 rk08, rk09, rk0A, rk0B, rk0C, rk0D, rk0E, rk0F; 14 | sph_u32 rk10, rk11, rk12, rk13, rk14, rk15, rk16, rk17; 15 | sph_u32 rk18, rk19, rk1A, rk1B, rk1C, rk1D, rk1E, rk1F; 16 | 17 | sph_u32 sc_count0 = (64 << 3), sc_count1 = 0, sc_count2 = 0, sc_count3 = 0; 18 | 19 | rk00 = hash.h4[0]; 20 | rk01 = hash.h4[1]; 21 | rk02 = hash.h4[2]; 22 | rk03 = hash.h4[3]; 23 | rk04 = hash.h4[4]; 24 | rk05 = hash.h4[5]; 25 | rk06 = hash.h4[6]; 26 | rk07 = hash.h4[7]; 27 | rk08 = hash.h4[8]; 28 | rk09 = hash.h4[9]; 29 | rk0A = hash.h4[10]; 30 | rk0B = hash.h4[11]; 31 | rk0C = hash.h4[12]; 32 | rk0D = hash.h4[13]; 33 | rk0E = hash.h4[14]; 34 | rk0F = hash.h4[15]; 35 | rk10 = 0x80; 36 | rk11 = rk12 = rk13 = rk14 = rk15 = rk16 = rk17 = rk18 = rk19 = rk1A = 0; 37 | rk1B = 0x2000000; 38 | rk1C = rk1D = rk1E = 0; 39 | rk1F = 0x2000000; 40 | 41 | c512(buf); 42 | 43 | hash.h4[0] = h0; 44 | hash.h4[1] = h1; 45 | hash.h4[2] = h2; 46 | hash.h4[3] = h3; 47 | hash.h4[4] = h4; 48 | hash.h4[5] = h5; 49 | hash.h4[6] = h6; 50 | hash.h4[7] = h7; 51 | hash.h4[8] = h8; 52 | hash.h4[9] = h9; 53 | hash.h4[10] = hA; 54 | hash.h4[11] = hB; 55 | hash.h4[12] = hC; 56 | hash.h4[13] = hD; 57 | hash.h4[14] = hE; 58 | hash.h4[15] = hF; 59 | 60 | } 61 | -------------------------------------------------------------------------------- /ccan/opt/_info: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "config.h" 4 | 5 | /** 6 | * opt - simple command line parsing 7 | * 8 | * Simple but powerful command line parsing. 9 | * 10 | * Example: 11 | * #include 12 | * #include 13 | * #include 14 | * 15 | * static bool someflag; 16 | * static int verbose; 17 | * static char *somestring; 18 | * 19 | * static struct opt_table opts[] = { 20 | * OPT_WITHOUT_ARG("--verbose|-v", opt_inc_intval, &verbose, 21 | * "Verbose mode (can be specified more than once)"), 22 | * OPT_WITHOUT_ARG("--someflag", opt_set_bool, &someflag, 23 | * "Set someflag"), 24 | * OPT_WITH_ARG("--somefile=", opt_set_charp, opt_show_charp, 25 | * &somestring, "Set somefile to "), 26 | * OPT_WITHOUT_ARG("--usage|--help|-h", opt_usage_and_exit, 27 | * "args...\nA silly test program.", 28 | * "Print this message."), 29 | * OPT_ENDTABLE 30 | * }; 31 | * 32 | * int main(int argc, char *argv[]) 33 | * { 34 | * int i; 35 | * 36 | * opt_register_table(opts, NULL); 37 | * // For fun, register an extra one. 38 | * opt_register_noarg("--no-someflag", opt_set_invbool, &someflag, 39 | * "Unset someflag"); 40 | * if (!opt_parse(&argc, argv, opt_log_stderr)) 41 | * exit(1); 42 | * 43 | * printf("someflag = %i, verbose = %i, somestring = %s\n", 44 | * someflag, verbose, somestring); 45 | * printf("%u args left over:", argc - 1); 46 | * for (i = 1; i < argc; i++) 47 | * printf(" %s", argv[i]); 48 | * printf("\n"); 49 | * return 0; 50 | * } 51 | * 52 | * License: GPL (2 or any later version) 53 | * Author: Rusty Russell 54 | */ 55 | int main(int argc, char *argv[]) 56 | { 57 | if (argc != 2) 58 | return 1; 59 | 60 | if (strcmp(argv[1], "depends") == 0) { 61 | printf("ccan/typesafe_cb\n"); 62 | printf("ccan/compiler\n"); 63 | return 0; 64 | } 65 | 66 | return 1; 67 | } 68 | -------------------------------------------------------------------------------- /pool.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright 2014 sgminer developers. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | */ 26 | 27 | #include "config.h" 28 | #include "miner.h" 29 | #include "pool.h" 30 | 31 | #include 32 | #include 33 | #include 34 | 35 | char* get_pool_name(struct pool *pool) { 36 | if (opt_incognito) { 37 | return ""; 38 | } 39 | 40 | if (empty_string(pool->name)) { 41 | return pool->sockaddr_url; 42 | } 43 | 44 | return pool->name; 45 | } 46 | 47 | char* get_pool_user(struct pool *pool) { 48 | if (opt_incognito) { 49 | return ""; 50 | } 51 | 52 | return pool->rpc_user; 53 | } 54 | -------------------------------------------------------------------------------- /kernel/x11evo/x11evo_cubehash.cl: -------------------------------------------------------------------------------- 1 | 2 | // cubehash.h1 3 | { 4 | sph_u32 x0 = SPH_C32(0x2AEA2A61), x1 = SPH_C32(0x50F494D4), x2 = SPH_C32(0x2D538B8B), x3 = SPH_C32(0x4167D83E); 5 | sph_u32 x4 = SPH_C32(0x3FEE2313), x5 = SPH_C32(0xC701CF8C), x6 = SPH_C32(0xCC39968E), x7 = SPH_C32(0x50AC5695); 6 | sph_u32 x8 = SPH_C32(0x4D42C787), x9 = SPH_C32(0xA647A8B3), xa = SPH_C32(0x97CF0BEF), xb = SPH_C32(0x825B4537); 7 | sph_u32 xc = SPH_C32(0xEEF864D2), xd = SPH_C32(0xF22090C4), xe = SPH_C32(0xD0E5CD33), xf = SPH_C32(0xA23911AE); 8 | sph_u32 xg = SPH_C32(0xFCD398D9), xh = SPH_C32(0x148FE485), xi = SPH_C32(0x1B017BEF), xj = SPH_C32(0xB6444532); 9 | sph_u32 xk = SPH_C32(0x6A536159), xl = SPH_C32(0x2FF5781C), xm = SPH_C32(0x91FA7934), xn = SPH_C32(0x0DBADEA9); 10 | sph_u32 xo = SPH_C32(0xD65C8A2B), xp = SPH_C32(0xA5A70E75), xq = SPH_C32(0xB1C62456), xr = SPH_C32(0xBC796576); 11 | sph_u32 xs = SPH_C32(0x1921C8F7), xt = SPH_C32(0xE7989AF1), xu = SPH_C32(0x7795D246), xv = SPH_C32(0xD43E3B44); 12 | 13 | x0 ^= SWAP4(hash.h4[1]); 14 | x1 ^= SWAP4(hash.h4[0]); 15 | x2 ^= SWAP4(hash.h4[3]); 16 | x3 ^= SWAP4(hash.h4[2]); 17 | x4 ^= SWAP4(hash.h4[5]); 18 | x5 ^= SWAP4(hash.h4[4]); 19 | x6 ^= SWAP4(hash.h4[7]); 20 | x7 ^= SWAP4(hash.h4[6]); 21 | 22 | for (int i = 0; i < 13; i++) { 23 | SIXTEEN_ROUNDS; 24 | 25 | if (i == 0) { 26 | x0 ^= SWAP4(hash.h4[9]); 27 | x1 ^= SWAP4(hash.h4[8]); 28 | x2 ^= SWAP4(hash.h4[11]); 29 | x3 ^= SWAP4(hash.h4[10]); 30 | x4 ^= SWAP4(hash.h4[13]); 31 | x5 ^= SWAP4(hash.h4[12]); 32 | x6 ^= SWAP4(hash.h4[15]); 33 | x7 ^= SWAP4(hash.h4[14]); 34 | } 35 | else if (i == 1) { 36 | x0 ^= 0x80; 37 | } 38 | else if (i == 2) { 39 | xv ^= SPH_C32(1); 40 | } 41 | } 42 | 43 | hash.h4[0] = x0; 44 | hash.h4[1] = x1; 45 | hash.h4[2] = x2; 46 | hash.h4[3] = x3; 47 | hash.h4[4] = x4; 48 | hash.h4[5] = x5; 49 | hash.h4[6] = x6; 50 | hash.h4[7] = x7; 51 | hash.h4[8] = x8; 52 | hash.h4[9] = x9; 53 | hash.h4[10] = xa; 54 | hash.h4[11] = xb; 55 | hash.h4[12] = xc; 56 | hash.h4[13] = xd; 57 | hash.h4[14] = xe; 58 | hash.h4[15] = xf; 59 | 60 | } 61 | -------------------------------------------------------------------------------- /algorithm/lyra2.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Header file for the Lyra2 Password Hashing Scheme (PHS). 3 | * 4 | * Author: The Lyra PHC team (http://www.lyra-kdf.net/) -- 2014. 5 | * 6 | * This software is hereby placed in the public domain. 7 | * 8 | * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''AS IS'' AND ANY EXPRESS 9 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 10 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 11 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE 12 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 13 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 14 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 15 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 16 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 17 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 18 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 19 | */ 20 | #ifndef LYRA2_H_ 21 | #define LYRA2_H_ 22 | 23 | #include 24 | 25 | typedef unsigned char byte; 26 | 27 | //Block length required so Blake2's Initialization Vector (IV) is not overwritten (THIS SHOULD NOT BE MODIFIED) 28 | #define BLOCK_LEN_BLAKE2_SAFE_INT64 8 //512 bits (=64 bytes, =8 uint64_t) 29 | #define BLOCK_LEN_BLAKE2_SAFE_BYTES (BLOCK_LEN_BLAKE2_SAFE_INT64 * 8) //same as above, in bytes 30 | 31 | 32 | #ifdef BLOCK_LEN_BITS 33 | #define BLOCK_LEN_INT64 (BLOCK_LEN_BITS/64) //Block length: 768 bits (=96 bytes, =12 uint64_t) 34 | #define BLOCK_LEN_BYTES (BLOCK_LEN_BITS/8) //Block length, in bytes 35 | #else //default block lenght: 768 bits 36 | #define BLOCK_LEN_INT64 12 //Block length: 768 bits (=96 bytes, =12 uint64_t) 37 | #define BLOCK_LEN_BYTES (BLOCK_LEN_INT64 * 8) //Block length, in bytes 38 | #endif 39 | 40 | int LYRA2(void *K, uint64_t kLen, const void *pwd, uint64_t pwdlen, const void *salt, uint64_t saltlen, uint64_t timeCost, uint64_t nRows, uint64_t nCols); 41 | 42 | #endif /* LYRA2_H_ */ 43 | -------------------------------------------------------------------------------- /winbuild/dist/include/config.h: -------------------------------------------------------------------------------- 1 | #ifndef __CONFIG_H__ 2 | #define __CONFIG_H__ 3 | 4 | #define HAVE_STDINT_H 5 | 6 | #if defined(_MSC_VER) 7 | 8 | #define HAVE_LIBCURL 1 9 | #define CURL_HAS_KEEPALIVE 1 10 | #define HAVE_CURSES 1 11 | #define HAVE_ADL 1 12 | 13 | #define STDC_HEADERS 1 14 | #define EXECV_2ND_ARG_TYPE char* const* 15 | 16 | #define HAVE_ALLOCA 1 17 | #define HAVE_ATTRIBUTE_COLD 1 18 | #define HAVE_ATTRIBUTE_CONST 1 19 | #define HAVE_ATTRIBUTE_NORETURN 1 20 | #define HAVE_ATTRIBUTE_PRINTF 1 21 | #define HAVE_ATTRIBUTE_UNUSED 1 22 | #define HAVE_ATTRIBUTE_USED 1 23 | #define HAVE_BUILTIN_CONSTANT_P 1 24 | #define HAVE_BUILTIN_TYPES_COMPATIBLE_P 1 25 | #define HAVE_DECL_MEMMEM 0 26 | #define HAVE_INTTYPES_H 1 27 | #define HAVE_LONG_LONG_INT 1 28 | #define HAVE_MEMORY_H 1 29 | #define HAVE_MPROTECT 1 30 | #define HAVE_RAW_DECL_MEMPCPY 1 31 | #define HAVE_RAW_DECL_STRNCAT 1 32 | #define HAVE_RAW_DECL_STRNLEN 1 33 | #define HAVE_RAW_DECL_STRPBRK 1 34 | #define HAVE_STDLIB_H 1 35 | #define HAVE_STRINGS_H 1 36 | #define HAVE_STRING_H 1 37 | #define HAVE_SYS_STAT_H 1 38 | #define HAVE_SYS_TYPES_H 1 39 | #define HAVE_UNISTD_H 1 40 | #define HAVE_UNSIGNED_LONG_LONG_INT 1 41 | #define HAVE_WARN_UNUSED_RESULT 1 42 | #define HAVE_WCHAR_H 1 43 | #define HAVE_WCHAR_T 1 44 | 45 | #define PRIi64 "I64d" 46 | #define PRIi32 "I32d" 47 | #define PRIu32 "I32u" 48 | #define PRIu64 "I64u" 49 | 50 | #define PATH_MAX MAX_PATH 51 | 52 | // Libraries to include 53 | #pragma comment(lib, "winmm.lib") 54 | #pragma comment(lib, "wsock32.lib") 55 | #pragma comment(lib, "pthreadVC2.lib") 56 | #pragma comment(lib, "OpenCL.lib") 57 | #pragma comment(lib, "jansson.lib") 58 | 59 | #ifdef HAVE_LIBCURL 60 | #define CURL_STATICLIB 1 61 | #pragma comment(lib, "libcurl_a.lib") 62 | #endif 63 | 64 | #ifdef HAVE_CURSES 65 | #pragma comment(lib, "pdcurses.lib") 66 | #endif 67 | 68 | #endif 69 | 70 | #define VERSION "v5.2.0" 71 | #define PACKAGE_NAME "sgminer" 72 | #define PACKAGE_TARNAME "sgminer" 73 | #define PACKAGE_VERSION "5.2.0" 74 | #define PACKAGE_STRING "sgminer 5.2.0" 75 | #define PACKAGE "sgminer" 76 | 77 | #define SGMINER_PREFIX "" 78 | 79 | #include "gitversion.h" 80 | #include "winbuild.h" 81 | 82 | #endif 83 | -------------------------------------------------------------------------------- /m4/mmap-anon.m4: -------------------------------------------------------------------------------- 1 | # mmap-anon.m4 serial 9 2 | dnl Copyright (C) 2005, 2007, 2009-2011 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | # Detect how mmap can be used to create anonymous (not file-backed) memory 8 | # mappings. 9 | # - On Linux, AIX, OSF/1, Solaris, Cygwin, Interix, Haiku, both MAP_ANONYMOUS 10 | # and MAP_ANON exist and have the same value. 11 | # - On HP-UX, only MAP_ANONYMOUS exists. 12 | # - On MacOS X, FreeBSD, NetBSD, OpenBSD, only MAP_ANON exists. 13 | # - On IRIX, neither exists, and a file descriptor opened to /dev/zero must be 14 | # used. 15 | 16 | AC_DEFUN([gl_FUNC_MMAP_ANON], 17 | [ 18 | dnl Persuade glibc to define MAP_ANONYMOUS. 19 | AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) 20 | 21 | # Check for mmap(). Don't use AC_FUNC_MMAP, because it checks too much: it 22 | # fails on HP-UX 11, because MAP_FIXED mappings do not work. But this is 23 | # irrelevant for anonymous mappings. 24 | AC_CHECK_FUNC([mmap], [gl_have_mmap=yes], [gl_have_mmap=no]) 25 | 26 | # Try to allow MAP_ANONYMOUS. 27 | gl_have_mmap_anonymous=no 28 | if test $gl_have_mmap = yes; then 29 | AC_MSG_CHECKING([for MAP_ANONYMOUS]) 30 | AC_EGREP_CPP([I cant identify this map.], [ 31 | #include 32 | #ifdef MAP_ANONYMOUS 33 | I cant identify this map. 34 | #endif 35 | ], 36 | [gl_have_mmap_anonymous=yes]) 37 | if test $gl_have_mmap_anonymous != yes; then 38 | AC_EGREP_CPP([I cant identify this map.], [ 39 | #include 40 | #ifdef MAP_ANON 41 | I cant identify this map. 42 | #endif 43 | ], 44 | [AC_DEFINE([MAP_ANONYMOUS], [MAP_ANON], 45 | [Define to a substitute value for mmap()'s MAP_ANONYMOUS flag.]) 46 | gl_have_mmap_anonymous=yes]) 47 | fi 48 | AC_MSG_RESULT([$gl_have_mmap_anonymous]) 49 | if test $gl_have_mmap_anonymous = yes; then 50 | AC_DEFINE([HAVE_MAP_ANONYMOUS], [1], 51 | [Define to 1 if mmap()'s MAP_ANONYMOUS flag is available after including 52 | config.h and .]) 53 | fi 54 | fi 55 | ]) 56 | -------------------------------------------------------------------------------- /m4/multiarch.m4: -------------------------------------------------------------------------------- 1 | # multiarch.m4 serial 6 2 | dnl Copyright (C) 2008-2011 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | # Determine whether the compiler is or may be producing universal binaries. 8 | # 9 | # On MacOS X 10.5 and later systems, the user can create libraries and 10 | # executables that work on multiple system types--known as "fat" or 11 | # "universal" binaries--by specifying multiple '-arch' options to the 12 | # compiler but only a single '-arch' option to the preprocessor. Like 13 | # this: 14 | # 15 | # ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ 16 | # CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ 17 | # CPP="gcc -E" CXXCPP="g++ -E" 18 | # 19 | # Detect this situation and set APPLE_UNIVERSAL_BUILD accordingly. 20 | 21 | AC_DEFUN_ONCE([gl_MULTIARCH], 22 | [ 23 | dnl Code similar to autoconf-2.63 AC_C_BIGENDIAN. 24 | gl_cv_c_multiarch=no 25 | AC_COMPILE_IFELSE( 26 | [AC_LANG_SOURCE( 27 | [[#ifndef __APPLE_CC__ 28 | not a universal capable compiler 29 | #endif 30 | typedef int dummy; 31 | ]])], 32 | [ 33 | dnl Check for potential -arch flags. It is not universal unless 34 | dnl there are at least two -arch flags with different values. 35 | arch= 36 | prev= 37 | for word in ${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS}; do 38 | if test -n "$prev"; then 39 | case $word in 40 | i?86 | x86_64 | ppc | ppc64) 41 | if test -z "$arch" || test "$arch" = "$word"; then 42 | arch="$word" 43 | else 44 | gl_cv_c_multiarch=yes 45 | fi 46 | ;; 47 | esac 48 | prev= 49 | else 50 | if test "x$word" = "x-arch"; then 51 | prev=arch 52 | fi 53 | fi 54 | done 55 | ]) 56 | if test $gl_cv_c_multiarch = yes; then 57 | APPLE_UNIVERSAL_BUILD=1 58 | else 59 | APPLE_UNIVERSAL_BUILD=0 60 | fi 61 | AC_SUBST([APPLE_UNIVERSAL_BUILD]) 62 | ]) 63 | -------------------------------------------------------------------------------- /m4/warn-on-use.m4: -------------------------------------------------------------------------------- 1 | # warn-on-use.m4 serial 2 2 | dnl Copyright (C) 2010-2011 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | # gl_WARN_ON_USE_PREPARE(INCLUDES, NAMES) 8 | # --------------------------------------- 9 | # For each whitespace-separated element in the list of NAMES, define 10 | # HAVE_RAW_DECL_name if the function has a declaration among INCLUDES 11 | # even after being undefined as a macro. 12 | # 13 | # See warn-on-use.h for some hints on how to poison function names, as 14 | # well as ideas on poisoning global variables and macros. NAMES may 15 | # include global variables, but remember that only functions work with 16 | # _GL_WARN_ON_USE. Typically, INCLUDES only needs to list a single 17 | # header, but if the replacement header pulls in other headers because 18 | # some systems declare functions in the wrong header, then INCLUDES 19 | # should do likewise. 20 | # 21 | # If you assume C89, then it is generally safe to assume declarations 22 | # for functions declared in that standard (such as gets) without 23 | # needing gl_WARN_ON_USE_PREPARE. 24 | AC_DEFUN([gl_WARN_ON_USE_PREPARE], 25 | [ 26 | m4_foreach_w([gl_decl], [$2], 27 | [AH_TEMPLATE([HAVE_RAW_DECL_]AS_TR_CPP(m4_defn([gl_decl])), 28 | [Define to 1 if ]m4_defn([gl_decl])[ is declared even after 29 | undefining macros.])])dnl 30 | for gl_func in m4_flatten([$2]); do 31 | AS_VAR_PUSHDEF([gl_Symbol], [gl_cv_have_raw_decl_$gl_func])dnl 32 | AC_CACHE_CHECK([whether $gl_func is declared without a macro], 33 | gl_Symbol, 34 | [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$1], 35 | [@%:@undef $gl_func 36 | (void) $gl_func;])], 37 | [AS_VAR_SET(gl_Symbol, [yes])], [AS_VAR_SET(gl_Symbol, [no])])]) 38 | AS_VAR_IF(gl_Symbol, [yes], 39 | [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_RAW_DECL_$gl_func]), [1]) 40 | dnl shortcut - if the raw declaration exists, then set a cache 41 | dnl variable to allow skipping any later AC_CHECK_DECL efforts 42 | eval ac_cv_have_decl_$gl_func=yes]) 43 | AS_VAR_POPDEF([gl_Symbol])dnl 44 | done 45 | ]) 46 | -------------------------------------------------------------------------------- /winbuild/sgminer.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.31101.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sgminer", "sgminer.vcxproj", "{CCA64DCD-6401-42A3-ABC3-89E48A36D239}" 7 | EndProject 8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "jansson", "jansson\jansson.vcxproj", "{AFE7D2AA-025C-4837-B4B2-81117E010B3B}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Win32 = Debug|Win32 13 | Debug|x64 = Debug|x64 14 | Release|Win32 = Release|Win32 15 | Release|x64 = Release|x64 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {CCA64DCD-6401-42A3-ABC3-89E48A36D239}.Debug|Win32.ActiveCfg = Debug|Win32 19 | {CCA64DCD-6401-42A3-ABC3-89E48A36D239}.Debug|Win32.Build.0 = Debug|Win32 20 | {CCA64DCD-6401-42A3-ABC3-89E48A36D239}.Debug|x64.ActiveCfg = Debug|x64 21 | {CCA64DCD-6401-42A3-ABC3-89E48A36D239}.Debug|x64.Build.0 = Debug|x64 22 | {CCA64DCD-6401-42A3-ABC3-89E48A36D239}.Debug|x64.Deploy.0 = Debug|x64 23 | {CCA64DCD-6401-42A3-ABC3-89E48A36D239}.Release|Win32.ActiveCfg = Release|Win32 24 | {CCA64DCD-6401-42A3-ABC3-89E48A36D239}.Release|Win32.Build.0 = Release|Win32 25 | {CCA64DCD-6401-42A3-ABC3-89E48A36D239}.Release|x64.ActiveCfg = Release|x64 26 | {CCA64DCD-6401-42A3-ABC3-89E48A36D239}.Release|x64.Build.0 = Release|x64 27 | {AFE7D2AA-025C-4837-B4B2-81117E010B3B}.Debug|Win32.ActiveCfg = Debug|Win32 28 | {AFE7D2AA-025C-4837-B4B2-81117E010B3B}.Debug|Win32.Build.0 = Debug|Win32 29 | {AFE7D2AA-025C-4837-B4B2-81117E010B3B}.Debug|x64.ActiveCfg = Debug|x64 30 | {AFE7D2AA-025C-4837-B4B2-81117E010B3B}.Debug|x64.Build.0 = Debug|x64 31 | {AFE7D2AA-025C-4837-B4B2-81117E010B3B}.Release|Win32.ActiveCfg = Release|Win32 32 | {AFE7D2AA-025C-4837-B4B2-81117E010B3B}.Release|Win32.Build.0 = Release|Win32 33 | {AFE7D2AA-025C-4837-B4B2-81117E010B3B}.Release|x64.ActiveCfg = Release|x64 34 | {AFE7D2AA-025C-4837-B4B2-81117E010B3B}.Release|x64.Build.0 = Release|x64 35 | EndGlobalSection 36 | GlobalSection(SolutionProperties) = preSolution 37 | HideSolutionNode = FALSE 38 | EndGlobalSection 39 | EndGlobal 40 | -------------------------------------------------------------------------------- /ccan/opt/test/run-iter.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "utils.h" 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | static void reset_options(void) 13 | { 14 | free(opt_table); 15 | opt_table = NULL; 16 | opt_count = opt_num_short = opt_num_short_arg = opt_num_long = 0; 17 | } 18 | 19 | /* Test iterators. */ 20 | int main(int argc, char *argv[]) 21 | { 22 | unsigned j, i, len = 0; 23 | const char *p; 24 | 25 | plan_tests(37 * 2); 26 | for (j = 0; j < 2; j ++) { 27 | reset_options(); 28 | /* Giving subtable a title makes an extra entry! */ 29 | opt_register_table(subtables, j == 0 ? NULL : "subtable"); 30 | 31 | p = first_lopt(&i, &len); 32 | ok1(i == j + 0); 33 | ok1(len == 3); 34 | ok1(strncmp(p, "jjj", len) == 0); 35 | p = next_lopt(p, &i, &len); 36 | ok1(i == j + 0); 37 | ok1(len == 3); 38 | ok1(strncmp(p, "lll", len) == 0); 39 | p = next_lopt(p, &i, &len); 40 | ok1(i == j + 1); 41 | ok1(len == 3); 42 | ok1(strncmp(p, "mmm", len) == 0); 43 | p = next_lopt(p, &i, &len); 44 | ok1(i == j + 5); 45 | ok1(len == 3); 46 | ok1(strncmp(p, "ddd", len) == 0); 47 | p = next_lopt(p, &i, &len); 48 | ok1(i == j + 6); 49 | ok1(len == 3); 50 | ok1(strncmp(p, "eee", len) == 0); 51 | p = next_lopt(p, &i, &len); 52 | ok1(i == j + 7); 53 | ok1(len == 3); 54 | ok1(strncmp(p, "ggg", len) == 0); 55 | p = next_lopt(p, &i, &len); 56 | ok1(i == j + 8); 57 | ok1(len == 3); 58 | ok1(strncmp(p, "hhh", len) == 0); 59 | p = next_lopt(p, &i, &len); 60 | ok1(!p); 61 | 62 | p = first_sopt(&i); 63 | ok1(i == j + 0); 64 | ok1(*p == 'j'); 65 | p = next_sopt(p, &i); 66 | ok1(i == j + 0); 67 | ok1(*p == 'l'); 68 | p = next_sopt(p, &i); 69 | ok1(i == j + 1); 70 | ok1(*p == 'm'); 71 | p = next_sopt(p, &i); 72 | ok1(i == j + 2); 73 | ok1(*p == 'a'); 74 | p = next_sopt(p, &i); 75 | ok1(i == j + 3); 76 | ok1(*p == 'b'); 77 | p = next_sopt(p, &i); 78 | ok1(i == j + 7); 79 | ok1(*p == 'g'); 80 | p = next_sopt(p, &i); 81 | ok1(i == j + 8); 82 | ok1(*p == 'h'); 83 | p = next_sopt(p, &i); 84 | ok1(!p); 85 | } 86 | 87 | return exit_status(); 88 | } 89 | -------------------------------------------------------------------------------- /hexdump.c: -------------------------------------------------------------------------------- 1 | /* 2 | * hexdump implementation without depenecies to *printf() 3 | * output is equal to 'hexdump -C' 4 | * should be compatible to 64bit architectures 5 | * 6 | * Copyright (c) 2009 Daniel Mack 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program. If not, see . 20 | */ 21 | #include "miner.h" 22 | #define hex_print(p) applog(LOG_DEBUG, "%s", p) 23 | 24 | static char nibble[] = { 25 | '0', '1', '2', '3', '4', '5', '6', '7', 26 | '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; 27 | 28 | #define BYTES_PER_LINE 0x10 29 | 30 | void hexdump(const uint8_t *p, unsigned int len) 31 | { 32 | unsigned int i, addr; 33 | unsigned int wordlen = sizeof(void*); 34 | unsigned char v, line[BYTES_PER_LINE * 5]; 35 | 36 | for (addr = 0; addr < len; addr += BYTES_PER_LINE) { 37 | /* clear line */ 38 | for (i = 0; i < sizeof(line); i++) { 39 | if (i == wordlen * 2 + 52 || 40 | i == wordlen * 2 + 69) { 41 | line[i] = '|'; 42 | continue; 43 | } 44 | 45 | if (i == wordlen * 2 + 70) { 46 | line[i] = '\0'; 47 | continue; 48 | } 49 | 50 | line[i] = ' '; 51 | } 52 | 53 | /* print address */ 54 | for (i = 0; i < wordlen * 2; i++) { 55 | v = addr >> ((wordlen * 2 - i - 1) * 4); 56 | line[i] = nibble[v & 0xf]; 57 | } 58 | 59 | /* dump content */ 60 | for (i = 0; i < BYTES_PER_LINE; i++) { 61 | int pos = (wordlen * 2) + 3 + (i / 8); 62 | 63 | if (addr + i >= len) 64 | break; 65 | 66 | v = p[addr + i]; 67 | line[pos + (i * 3) + 0] = nibble[v >> 4]; 68 | line[pos + (i * 3) + 1] = nibble[v & 0xf]; 69 | 70 | /* character printable? */ 71 | line[(wordlen * 2) + 53 + i] = 72 | (v >= ' ' && v <= '~') ? v : '.'; 73 | } 74 | 75 | hex_print(line); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /m4/signal_h.m4: -------------------------------------------------------------------------------- 1 | # signal_h.m4 serial 12 2 | dnl Copyright (C) 2007-2011 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | AC_DEFUN([gl_SIGNAL_H], 8 | [ 9 | AC_REQUIRE([gl_SIGNAL_H_DEFAULTS]) 10 | gl_NEXT_HEADERS([signal.h]) 11 | 12 | # AIX declares sig_atomic_t to already include volatile, and C89 compilers 13 | # then choke on 'volatile sig_atomic_t'. C99 requires that it compile. 14 | AC_CHECK_TYPE([volatile sig_atomic_t], [], 15 | [HAVE_TYPE_VOLATILE_SIG_ATOMIC_T=0], [[ 16 | #include 17 | ]]) 18 | 19 | AC_REQUIRE([AC_TYPE_UID_T]) 20 | 21 | dnl Persuade glibc to define sighandler_t. 22 | AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) 23 | AC_CHECK_TYPE([sighandler_t], [], [HAVE_SIGHANDLER_T=0], [[ 24 | #include 25 | ]]) 26 | 27 | dnl Check for declarations of anything we want to poison if the 28 | dnl corresponding gnulib module is not in use. 29 | gl_WARN_ON_USE_PREPARE([[#include 30 | ]], [sigaction sigaddset sigdelset sigemptyset sigfillset sigismember 31 | sigpending sigprocmask]) 32 | ]) 33 | 34 | AC_DEFUN([gl_SIGNAL_MODULE_INDICATOR], 35 | [ 36 | dnl Use AC_REQUIRE here, so that the default settings are expanded once only. 37 | AC_REQUIRE([gl_SIGNAL_H_DEFAULTS]) 38 | gl_MODULE_INDICATOR_SET_VARIABLE([$1]) 39 | dnl Define it also as a C macro, for the benefit of the unit tests. 40 | gl_MODULE_INDICATOR_FOR_TESTS([$1]) 41 | ]) 42 | 43 | AC_DEFUN([gl_SIGNAL_H_DEFAULTS], 44 | [ 45 | GNULIB_SIGNAL_H_SIGPIPE=0; AC_SUBST([GNULIB_SIGNAL_H_SIGPIPE]) 46 | GNULIB_SIGPROCMASK=0; AC_SUBST([GNULIB_SIGPROCMASK]) 47 | GNULIB_SIGACTION=0; AC_SUBST([GNULIB_SIGACTION]) 48 | dnl Assume proper GNU behavior unless another module says otherwise. 49 | HAVE_POSIX_SIGNALBLOCKING=1; AC_SUBST([HAVE_POSIX_SIGNALBLOCKING]) 50 | HAVE_SIGSET_T=1; AC_SUBST([HAVE_SIGSET_T]) 51 | HAVE_SIGINFO_T=1; AC_SUBST([HAVE_SIGINFO_T]) 52 | HAVE_SIGACTION=1; AC_SUBST([HAVE_SIGACTION]) 53 | HAVE_STRUCT_SIGACTION_SA_SIGACTION=1; 54 | AC_SUBST([HAVE_STRUCT_SIGACTION_SA_SIGACTION]) 55 | HAVE_TYPE_VOLATILE_SIG_ATOMIC_T=1; 56 | AC_SUBST([HAVE_TYPE_VOLATILE_SIG_ATOMIC_T]) 57 | HAVE_SIGHANDLER_T=1; AC_SUBST([HAVE_SIGHANDLER_T]) 58 | ]) 59 | -------------------------------------------------------------------------------- /example.conf: -------------------------------------------------------------------------------- 1 | { 2 | "pools": [ 3 | { 4 | "name":"Testpool X11", 5 | "url": "stratum+tcp://url1:4440", 6 | "user": "user", 7 | "pass": "x", 8 | "priority": "1", 9 | "profile": "x11" 10 | }, 11 | { 12 | "name":"Testpool Scrypt", 13 | "url": "stratum+tcp://url2:3339", 14 | "user": "user", 15 | "pass": "x", 16 | "priority": "2", 17 | "profile": "scrypt" 18 | }, 19 | { 20 | "name":"Testpool X11 with other profile", 21 | "url": "stratum+tcp://url3:4440", 22 | "user": "user", 23 | "pass": "x", 24 | "priority": "0", 25 | "profile": "x11test" 26 | }, 27 | { 28 | "name":"Testpool Using default profile", 29 | "url": "stratum+tcp://url4:3333", 30 | "user": "user", 31 | "pass": "x" 32 | } 33 | ], 34 | "profiles": [ 35 | { 36 | "name": "x11", 37 | "algorithm": "darkcoin-mod", 38 | "intensity": "19", 39 | "thread-concurrency": "10696,8192", 40 | "worksize": "128", 41 | "gpu-engine": "1100", 42 | "gpu-threads": "2", 43 | "gpu-fan": "75" 44 | }, 45 | { 46 | "name": "scrypt", 47 | "algorithm": "ckolivas", 48 | "lookup-gap": "2", 49 | "intensity": "19,13", 50 | "thread-concurrency": "19656,8192", 51 | "worksize": "256", 52 | "gpu-engine": "1000,1065", 53 | "gpu-memclock": "1500", 54 | "gpu-threads": "1,2", 55 | "gpu-fan": "85", 56 | "gpu-powertune": "20" 57 | }, 58 | { 59 | "name": "x11test", 60 | "algorithm": "darkcoin-mod", 61 | "device": "1", 62 | "intensity": "19", 63 | "thread-concurrency": "10696,8192", 64 | "worksize": "512", 65 | "gpu-engine": "1100", 66 | "gpu-threads": "2", 67 | "gpu-fan": "75" 68 | } 69 | ], 70 | "failover-only": true, 71 | "default-profile": "scrypt", 72 | "temp-cutoff": "95,95", 73 | "temp-overheat": "90,90", 74 | "temp-target": "80,80", 75 | "gpu-memdiff": "0,0", 76 | "shares": "0", 77 | "kernel-path": "/usr/local/bin", 78 | "api-allow": "W:127.0.0.1", 79 | "api-listen": true, 80 | "api-mcast-port": "4028", 81 | "api-port": "4028", 82 | "expiry": "1", 83 | "failover-switch-delay": "60", 84 | "gpu-dyninterval": "7", 85 | "gpu-platform": "-1", 86 | "hamsi-expand-big": "4", 87 | "log": "5", 88 | "no-pool-disable": true, 89 | "no-client-reconnect": true, 90 | "queue": "0", 91 | "scan-time": "1", 92 | "tcp-keepalive": "30", 93 | "temp-hysteresis": "3" 94 | } -------------------------------------------------------------------------------- /ocl/binary_kernel.c: -------------------------------------------------------------------------------- 1 | #include "binary_kernel.h" 2 | #include "miner.h" 3 | #include 4 | #include 5 | 6 | cl_program load_opencl_binary_kernel(build_kernel_data *data) 7 | { 8 | FILE *binaryfile = NULL; 9 | size_t binary_size; 10 | char **binaries = (char **)calloc(MAX_GPUDEVICES * 4, sizeof(char *)); 11 | cl_int status; 12 | cl_program program; 13 | cl_program ret = NULL; 14 | 15 | binaryfile = fopen(data->binary_filename, "rb"); 16 | if (!binaryfile) { 17 | applog(LOG_DEBUG, "No binary found, generating from source"); 18 | goto out; 19 | } else { 20 | struct stat binary_stat; 21 | 22 | if (unlikely(stat(data->binary_filename, &binary_stat))) { 23 | applog(LOG_DEBUG, "Unable to stat binary, generating from source"); 24 | goto out; 25 | } 26 | if (!binary_stat.st_size) 27 | goto out; 28 | 29 | binary_size = binary_stat.st_size; 30 | binaries[0] = (char *)calloc(binary_size, 1); 31 | if (unlikely(!binaries[0])) { 32 | quit(1, "Unable to calloc binaries"); 33 | } 34 | 35 | if (fread(binaries[0], 1, binary_size, binaryfile) != binary_size) { 36 | applog(LOG_ERR, "Unable to fread binary"); 37 | goto out; 38 | } 39 | 40 | program = clCreateProgramWithBinary(data->context, 1, data->device, &binary_size, (const unsigned char **)binaries, &status, NULL); 41 | if (status != CL_SUCCESS) { 42 | applog(LOG_ERR, "Error %d: Loading Binary into cl_program (clCreateProgramWithBinary)", status); 43 | goto out; 44 | } 45 | 46 | applog(LOG_DEBUG, "Loaded binary image %s", data->binary_filename); 47 | 48 | /* create a cl program executable for all the devices specified */ 49 | status = clBuildProgram(program, 1, data->device, NULL, NULL, NULL); 50 | if (status != CL_SUCCESS) { 51 | applog(LOG_ERR, "Error %d: Building Program (clBuildProgram)", status); 52 | size_t log_size; 53 | status = clGetProgramBuildInfo(program, *data->device, CL_PROGRAM_BUILD_LOG, 0, NULL, &log_size); 54 | 55 | char *sz_log = (char *)malloc(log_size + 1); 56 | status = clGetProgramBuildInfo(program, *data->device, CL_PROGRAM_BUILD_LOG, log_size, sz_log, NULL); 57 | sz_log[log_size] = '\0'; 58 | applog(LOG_ERR, "%s", sz_log); 59 | free(sz_log); 60 | clReleaseProgram(program); 61 | goto out; 62 | } 63 | 64 | ret = program; 65 | } 66 | out: 67 | if (binaryfile) fclose(binaryfile); 68 | if (binaries[0]) free(binaries[0]); 69 | if (binaries) free(binaries); 70 | return ret; 71 | } 72 | -------------------------------------------------------------------------------- /sha2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FIPS 180-2 SHA-224/256/384/512 implementation 3 | * Last update: 02/02/2007 4 | * Issue date: 04/30/2005 5 | * 6 | * Copyright (C) 2013, Con Kolivas 7 | * Copyright (C) 2005, 2007 Olivier Gay 8 | * All rights reserved. 9 | * 10 | * Redistribution and use in source and binary forms, with or without 11 | * modification, are permitted provided that the following conditions 12 | * are met: 13 | * 1. Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in the 17 | * documentation and/or other materials provided with the distribution. 18 | * 3. Neither the name of the project nor the names of its contributors 19 | * may be used to endorse or promote products derived from this software 20 | * without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 23 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 | * SUCH DAMAGE. 33 | */ 34 | 35 | #include "config.h" 36 | #include "miner.h" 37 | 38 | #ifndef SHA2_H 39 | #define SHA2_H 40 | 41 | #define SHA256_DIGEST_SIZE ( 256 / 8) 42 | #define SHA256_BLOCK_SIZE ( 512 / 8) 43 | 44 | typedef struct { 45 | unsigned int tot_len; 46 | unsigned int len; 47 | unsigned char block[2 * SHA256_BLOCK_SIZE]; 48 | uint32_t h[8]; 49 | } sha256_ctx; 50 | 51 | void sha256_init(sha256_ctx * ctx); 52 | void sha256_update(sha256_ctx *ctx, const unsigned char *message, 53 | unsigned int len); 54 | void sha256_final(sha256_ctx *ctx, unsigned char *digest); 55 | void sha256(const unsigned char *message, unsigned int len, 56 | unsigned char *digest); 57 | 58 | #endif /* !SHA2_H */ 59 | -------------------------------------------------------------------------------- /logging.h: -------------------------------------------------------------------------------- 1 | #ifndef LOGGING_H 2 | #define LOGGING_H 3 | 4 | #include "config.h" 5 | #include 6 | #include 7 | 8 | #ifdef HAVE_SYSLOG_H 9 | #include 10 | #else 11 | enum { 12 | LOG_ERR, 13 | LOG_WARNING, 14 | LOG_NOTICE, 15 | LOG_INFO, 16 | LOG_DEBUG, 17 | }; 18 | #endif 19 | 20 | /* debug flags */ 21 | extern bool opt_debug; 22 | extern bool opt_debug_console; 23 | extern bool opt_verbose; 24 | extern bool opt_realquiet; 25 | extern bool want_per_device_stats; 26 | 27 | /* global log_level, messages with lower or equal prio are logged */ 28 | extern int opt_log_level; 29 | 30 | extern int opt_log_show_date; 31 | 32 | #define LOGBUFSIZ 8192 33 | 34 | void applog(int prio, const char* fmt, ...); 35 | void applogsiz(int prio, int size, const char* fmt, ...); 36 | void vapplogsiz(int prio, int size, const char* fmt, va_list args); 37 | 38 | extern void _applog(int prio, const char *str, bool force); 39 | 40 | #define IN_FMT_FFL " in %s %s():%d" 41 | 42 | #define forcelog(prio, fmt, ...) do { \ 43 | if (opt_debug || prio != LOG_DEBUG) { \ 44 | char tmp42[LOGBUFSIZ]; \ 45 | snprintf(tmp42, sizeof(tmp42), fmt, ##__VA_ARGS__); \ 46 | _applog(prio, tmp42, true); \ 47 | } \ 48 | } while (0) 49 | 50 | #define quit(status, fmt, ...) do { \ 51 | if (fmt) { \ 52 | char tmp42[LOGBUFSIZ]; \ 53 | snprintf(tmp42, sizeof(tmp42), fmt, ##__VA_ARGS__); \ 54 | _applog(LOG_ERR, tmp42, true); \ 55 | } \ 56 | _quit(status); \ 57 | } while (0) 58 | 59 | #define quithere(status, fmt, ...) do { \ 60 | if (fmt) { \ 61 | char tmp42[LOGBUFSIZ]; \ 62 | snprintf(tmp42, sizeof(tmp42), fmt IN_FMT_FFL, \ 63 | ##__VA_ARGS__, __FILE__, __func__, __LINE__); \ 64 | _applog(LOG_ERR, tmp42, true); \ 65 | } \ 66 | _quit(status); \ 67 | } while (0) 68 | 69 | #define quitfrom(status, _file, _func, _line, fmt, ...) do { \ 70 | if (fmt) { \ 71 | char tmp42[LOGBUFSIZ]; \ 72 | snprintf(tmp42, sizeof(tmp42), fmt IN_FMT_FFL, \ 73 | ##__VA_ARGS__, _file, _func, _line); \ 74 | _applog(LOG_ERR, tmp42, true); \ 75 | } \ 76 | _quit(status); \ 77 | } while (0) 78 | 79 | #ifdef HAVE_CURSES 80 | 81 | #define wlog(fmt, ...) do { \ 82 | char tmp42[LOGBUFSIZ]; \ 83 | snprintf(tmp42, sizeof(tmp42), fmt, ##__VA_ARGS__); \ 84 | _wlog(tmp42); \ 85 | } while (0) 86 | 87 | #define wlogprint(fmt, ...) do { \ 88 | char tmp42[LOGBUFSIZ]; \ 89 | snprintf(tmp42, sizeof(tmp42), fmt, ##__VA_ARGS__); \ 90 | _wlogprint(tmp42); \ 91 | } while (0) 92 | 93 | #endif 94 | 95 | extern void __debug(const char *filename, const char *fmt, ...); 96 | 97 | 98 | #endif /* LOGGING_H */ 99 | -------------------------------------------------------------------------------- /api-example.php: -------------------------------------------------------------------------------- 1 | 0) 71 | { 72 | $items = explode(',', $obj); 73 | $item = $items[0]; 74 | $id = explode('=', $items[0], 2); 75 | if (count($id) == 1 or !ctype_digit($id[1])) 76 | $name = $id[0]; 77 | else 78 | $name = $id[0].$id[1]; 79 | 80 | if (strlen($name) == 0) 81 | $name = 'null'; 82 | 83 | if (isset($data[$name])) 84 | { 85 | $num = 1; 86 | while (isset($data[$name.$num])) 87 | $num++; 88 | $name .= $num; 89 | } 90 | 91 | $counter = 0; 92 | foreach ($items as $item) 93 | { 94 | $id = explode('=', $item, 2); 95 | if (count($id) == 2) 96 | $data[$name][$id[0]] = $id[1]; 97 | else 98 | $data[$name][$counter] = $id[0]; 99 | 100 | $counter++; 101 | } 102 | } 103 | } 104 | 105 | return $data; 106 | } 107 | 108 | return null; 109 | } 110 | # 111 | if (isset($argv) and count($argv) > 1) 112 | $r = request($argv[1]); 113 | else 114 | $r = request('summary'); 115 | # 116 | echo print_r($r, true)."\n"; 117 | # 118 | ?> 119 | -------------------------------------------------------------------------------- /sph/sha256_Y.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright 2005,2007,2009 Colin Percival 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | * 26 | * $FreeBSD: src/lib/libmd/sha256_Y.h,v 1.2 2006/01/17 15:35:56 phk Exp $ 27 | */ 28 | 29 | #ifndef _SHA256_H_ 30 | #define _SHA256_H_ 31 | 32 | #include 33 | 34 | #include 35 | 36 | typedef struct SHA256Context { 37 | uint32_t state[8]; 38 | uint32_t count[2]; 39 | unsigned char buf[64]; 40 | } SHA256_CTX_Y; 41 | 42 | typedef struct HMAC_SHA256Context { 43 | SHA256_CTX_Y ictx; 44 | SHA256_CTX_Y octx; 45 | } HMAC_SHA256_CTX_Y; 46 | 47 | void SHA256_Init_Y(SHA256_CTX_Y *); 48 | void SHA256_Update_Y(SHA256_CTX_Y *, const void *, size_t); 49 | void SHA256_Final_Y(unsigned char [32], SHA256_CTX_Y *); 50 | void HMAC_SHA256_Init_Y(HMAC_SHA256_CTX_Y *, const void *, size_t); 51 | void HMAC_SHA256_Update_Y(HMAC_SHA256_CTX_Y *, const void *, size_t); 52 | void HMAC_SHA256_Final_Y(unsigned char [32], HMAC_SHA256_CTX_Y *); 53 | 54 | /** 55 | * PBKDF2_SHA256(passwd, passwdlen, salt, saltlen, c, buf, dkLen): 56 | * Compute PBKDF2(passwd, salt, c, dkLen) using HMAC-SHA256 as the PRF, and 57 | * write the output to buf. The value dkLen must be at most 32 * (2^32 - 1). 58 | */ 59 | void PBKDF2_SHA256(const uint8_t *, size_t, const uint8_t *, size_t, 60 | uint64_t, uint8_t *, size_t); 61 | 62 | 63 | #endif /* !_SHA256_H_ */ 64 | -------------------------------------------------------------------------------- /kernel/x11evo/x11evo_luffa.cl: -------------------------------------------------------------------------------- 1 | 2 | // luffa 3 | { 4 | sph_u32 V00 = SPH_C32(0x6d251e69), V01 = SPH_C32(0x44b051e0), V02 = SPH_C32(0x4eaa6fb4), V03 = SPH_C32(0xdbf78465), V04 = SPH_C32(0x6e292011), V05 = SPH_C32(0x90152df4), V06 = SPH_C32(0xee058139), V07 = SPH_C32(0xdef610bb); 5 | sph_u32 V10 = SPH_C32(0xc3b44b95), V11 = SPH_C32(0xd9d2f256), V12 = SPH_C32(0x70eee9a0), V13 = SPH_C32(0xde099fa3), V14 = SPH_C32(0x5d9b0557), V15 = SPH_C32(0x8fc944b3), V16 = SPH_C32(0xcf1ccf0e), V17 = SPH_C32(0x746cd581); 6 | sph_u32 V20 = SPH_C32(0xf7efc89d), V21 = SPH_C32(0x5dba5781), V22 = SPH_C32(0x04016ce5), V23 = SPH_C32(0xad659c05), V24 = SPH_C32(0x0306194f), V25 = SPH_C32(0x666d1836), V26 = SPH_C32(0x24aa230a), V27 = SPH_C32(0x8b264ae7); 7 | sph_u32 V30 = SPH_C32(0x858075d5), V31 = SPH_C32(0x36d79cce), V32 = SPH_C32(0xe571f7d7), V33 = SPH_C32(0x204b1f67), V34 = SPH_C32(0x35870c6a), V35 = SPH_C32(0x57e9e923), V36 = SPH_C32(0x14bcb808), V37 = SPH_C32(0x7cde72ce); 8 | sph_u32 V40 = SPH_C32(0x6c68e9be), V41 = SPH_C32(0x5ec41e22), V42 = SPH_C32(0xc825b7c7), V43 = SPH_C32(0xaffb4363), V44 = SPH_C32(0xf5df3999), V45 = SPH_C32(0x0fc688f1), V46 = SPH_C32(0xb07224cc), V47 = SPH_C32(0x03e86cea); 9 | 10 | DECL_TMP8(M); 11 | 12 | M0 = hash.h4[1]; 13 | M1 = hash.h4[0]; 14 | M2 = hash.h4[3]; 15 | M3 = hash.h4[2]; 16 | M4 = hash.h4[5]; 17 | M5 = hash.h4[4]; 18 | M6 = hash.h4[7]; 19 | M7 = hash.h4[6]; 20 | 21 | for (uint i = 0; i < 5; i++) 22 | { 23 | MI5; 24 | LUFFA_P5; 25 | 26 | if (i == 0) { 27 | M0 = hash.h4[9]; 28 | M1 = hash.h4[8]; 29 | M2 = hash.h4[11]; 30 | M3 = hash.h4[10]; 31 | M4 = hash.h4[13]; 32 | M5 = hash.h4[12]; 33 | M6 = hash.h4[15]; 34 | M7 = hash.h4[14]; 35 | } 36 | else if (i == 1) { 37 | M0 = 0x80000000; 38 | M1 = M2 = M3 = M4 = M5 = M6 = M7 = 0; 39 | } 40 | else if (i == 2) { 41 | M0 = M1 = M2 = M3 = M4 = M5 = M6 = M7 = 0; 42 | } 43 | else if (i == 3) { 44 | hash.h4[1] = V00 ^ V10 ^ V20 ^ V30 ^ V40; 45 | hash.h4[0] = V01 ^ V11 ^ V21 ^ V31 ^ V41; 46 | hash.h4[3] = V02 ^ V12 ^ V22 ^ V32 ^ V42; 47 | hash.h4[2] = V03 ^ V13 ^ V23 ^ V33 ^ V43; 48 | hash.h4[5] = V04 ^ V14 ^ V24 ^ V34 ^ V44; 49 | hash.h4[4] = V05 ^ V15 ^ V25 ^ V35 ^ V45; 50 | hash.h4[7] = V06 ^ V16 ^ V26 ^ V36 ^ V46; 51 | hash.h4[6] = V07 ^ V17 ^ V27 ^ V37 ^ V47; 52 | } 53 | } 54 | hash.h4[9] = V00 ^ V10 ^ V20 ^ V30 ^ V40; 55 | hash.h4[8] = V01 ^ V11 ^ V21 ^ V31 ^ V41; 56 | hash.h4[11] = V02 ^ V12 ^ V22 ^ V32 ^ V42; 57 | hash.h4[10] = V03 ^ V13 ^ V23 ^ V33 ^ V43; 58 | hash.h4[13] = V04 ^ V14 ^ V24 ^ V34 ^ V44; 59 | hash.h4[12] = V05 ^ V15 ^ V25 ^ V35 ^ V45; 60 | hash.h4[15] = V06 ^ V16 ^ V26 ^ V36 ^ V46; 61 | hash.h4[14] = V07 ^ V17 ^ V27 ^ V37 ^ V47; 62 | 63 | } 64 | -------------------------------------------------------------------------------- /ccan/typesafe_cb/test/run.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | static char dummy = 0; 7 | 8 | /* The example usage. */ 9 | static void _set_some_value(void *val) 10 | { 11 | ok1(val == &dummy); 12 | } 13 | 14 | #define set_some_value(expr) \ 15 | _set_some_value(typesafe_cb_cast(void *, unsigned long, (expr))) 16 | 17 | static void _callback_onearg(void (*fn)(void *arg), void *arg) 18 | { 19 | fn(arg); 20 | } 21 | 22 | static void _callback_preargs(void (*fn)(int a, int b, void *arg), void *arg) 23 | { 24 | fn(1, 2, arg); 25 | } 26 | 27 | static void _callback_postargs(void (*fn)(void *arg, int a, int b), void *arg) 28 | { 29 | fn(arg, 1, 2); 30 | } 31 | 32 | #define callback_onearg(cb, arg) \ 33 | _callback_onearg(typesafe_cb(void, void *, (cb), (arg)), (arg)) 34 | 35 | #define callback_preargs(cb, arg) \ 36 | _callback_preargs(typesafe_cb_preargs(void, void *, (cb), (arg), int, int), (arg)) 37 | 38 | #define callback_postargs(cb, arg) \ 39 | _callback_postargs(typesafe_cb_postargs(void, void *, (cb), (arg), int, int), (arg)) 40 | 41 | static void my_callback_onearg(char *p) 42 | { 43 | ok1(strcmp(p, "hello world") == 0); 44 | } 45 | 46 | static void my_callback_preargs(int a, int b, char *p) 47 | { 48 | ok1(a == 1); 49 | ok1(b == 2); 50 | ok1(strcmp(p, "hello world") == 0); 51 | } 52 | 53 | static void my_callback_postargs(char *p, int a, int b) 54 | { 55 | ok1(a == 1); 56 | ok1(b == 2); 57 | ok1(strcmp(p, "hello world") == 0); 58 | } 59 | 60 | /* This is simply a compile test; we promised typesafe_cb_cast can be in a 61 | * static initializer. */ 62 | struct callback_onearg 63 | { 64 | void (*fn)(void *arg); 65 | const void *arg; 66 | }; 67 | 68 | struct callback_onearg cb_onearg 69 | = { typesafe_cb(void, void *, my_callback_onearg, (char *)(intptr_t)"hello world"), 70 | "hello world" }; 71 | 72 | struct callback_preargs 73 | { 74 | void (*fn)(int a, int b, void *arg); 75 | const void *arg; 76 | }; 77 | 78 | struct callback_preargs cb_preargs 79 | = { typesafe_cb_preargs(void, void *, my_callback_preargs, 80 | (char *)(intptr_t)"hi", int, int), "hi" }; 81 | 82 | struct callback_postargs 83 | { 84 | void (*fn)(void *arg, int a, int b); 85 | const void *arg; 86 | }; 87 | 88 | struct callback_postargs cb_postargs 89 | = { typesafe_cb_postargs(void, void *, my_callback_postargs, 90 | (char *)(intptr_t)"hi", int, int), "hi" }; 91 | 92 | int main(int argc, char *argv[]) 93 | { 94 | void *p = &dummy; 95 | unsigned long l = (unsigned long)p; 96 | char str[] = "hello world"; 97 | 98 | plan_tests(2 + 1 + 3 + 3); 99 | set_some_value(p); 100 | set_some_value(l); 101 | 102 | callback_onearg(my_callback_onearg, str); 103 | 104 | callback_preargs(my_callback_preargs, str); 105 | 106 | callback_postargs(my_callback_postargs, str); 107 | 108 | return exit_status(); 109 | } 110 | -------------------------------------------------------------------------------- /ccan/opt/test/utils.c: -------------------------------------------------------------------------------- 1 | #include "config.h" 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include "utils.h" 10 | 11 | unsigned int test_cb_called; 12 | char *test_noarg(void *arg) 13 | { 14 | test_cb_called++; 15 | return NULL; 16 | } 17 | 18 | char *test_arg(const char *optarg, const char *arg) 19 | { 20 | test_cb_called++; 21 | ok1(strcmp(optarg, arg) == 0); 22 | return NULL; 23 | } 24 | 25 | void show_arg(char buf[OPT_SHOW_LEN], const char *arg) 26 | { 27 | strncpy(buf, arg, OPT_SHOW_LEN); 28 | } 29 | 30 | char *err_output = NULL; 31 | 32 | void save_err_output(const char *fmt, ...) 33 | { 34 | va_list ap; 35 | char *p; 36 | 37 | va_start(ap, fmt); 38 | /* Check return, for fascist gcc */ 39 | if (vasprintf(&p, fmt, ap) == -1) 40 | p = NULL; 41 | va_end(ap); 42 | 43 | if (err_output) { 44 | err_output = realloc(err_output, 45 | strlen(err_output) + strlen(p) + 1); 46 | strcat(err_output, p); 47 | free(p); 48 | } else 49 | err_output = p; 50 | } 51 | 52 | static bool allocated = false; 53 | 54 | bool parse_args(int *argc, char ***argv, ...) 55 | { 56 | char **a; 57 | va_list ap; 58 | 59 | va_start(ap, argv); 60 | *argc = 1; 61 | a = malloc(sizeof(*a) * (*argc + 1)); 62 | a[0] = (*argv)[0]; 63 | while ((a[*argc] = va_arg(ap, char *)) != NULL) { 64 | (*argc)++; 65 | a = realloc(a, sizeof(*a) * (*argc + 1)); 66 | } 67 | 68 | if (allocated) 69 | free(*argv); 70 | 71 | *argv = a; 72 | allocated = true; 73 | /* Re-set before parsing. */ 74 | optind = 0; 75 | 76 | return opt_parse(argc, *argv, save_err_output); 77 | } 78 | 79 | struct opt_table short_table[] = { 80 | /* Short opts, different args. */ 81 | OPT_WITHOUT_ARG("-a", test_noarg, "a", "Description of a"), 82 | OPT_WITH_ARG("-b", test_arg, show_arg, "b", "Description of b"), 83 | OPT_ENDTABLE 84 | }; 85 | 86 | struct opt_table long_table[] = { 87 | /* Long opts, different args. */ 88 | OPT_WITHOUT_ARG("--ddd", test_noarg, "ddd", "Description of ddd"), 89 | OPT_WITH_ARG("--eee ", test_arg, show_arg, "eee", ""), 90 | OPT_ENDTABLE 91 | }; 92 | 93 | struct opt_table long_and_short_table[] = { 94 | /* Short and long, different args. */ 95 | OPT_WITHOUT_ARG("--ggg|-g", test_noarg, "ggg", "Description of ggg"), 96 | OPT_WITH_ARG("-h|--hhh", test_arg, NULL, "hhh", "Description of hhh"), 97 | OPT_ENDTABLE 98 | }; 99 | 100 | /* Sub-table test. */ 101 | struct opt_table subtables[] = { 102 | /* Two short, and two long long, no description */ 103 | OPT_WITH_ARG("--jjj|-j|--lll|-l", test_arg, show_arg, "jjj", ""), 104 | /* Hidden option */ 105 | OPT_WITH_ARG("--mmm|-m", test_arg, show_arg, "mmm", opt_hidden), 106 | OPT_SUBTABLE(short_table, NULL), 107 | OPT_SUBTABLE(long_table, "long table options"), 108 | OPT_SUBTABLE(long_and_short_table, NULL), 109 | OPT_ENDTABLE 110 | }; 111 | -------------------------------------------------------------------------------- /lib/stddef.in.h: -------------------------------------------------------------------------------- 1 | /* A substitute for POSIX 2008 , for platforms that have issues. 2 | 3 | Copyright (C) 2009-2011 Free Software Foundation, Inc. 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 3, or (at your option) 8 | any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software Foundation, 17 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ 18 | 19 | /* Written by Eric Blake. */ 20 | 21 | /* 22 | * POSIX 2008 for platforms that have issues. 23 | * 24 | */ 25 | 26 | #if __GNUC__ >= 3 27 | @PRAGMA_SYSTEM_HEADER@ 28 | #endif 29 | @PRAGMA_COLUMNS@ 30 | 31 | #if defined __need_wchar_t || defined __need_size_t \ 32 | || defined __need_ptrdiff_t || defined __need_NULL \ 33 | || defined __need_wint_t 34 | /* Special invocation convention inside gcc header files. In 35 | particular, gcc provides a version of that blindly 36 | redefines NULL even when __need_wint_t was defined, even though 37 | wint_t is not normally provided by . Hence, we must 38 | remember if special invocation has ever been used to obtain wint_t, 39 | in which case we need to clean up NULL yet again. */ 40 | 41 | # if !(defined _@GUARD_PREFIX@_STDDEF_H && defined _GL_STDDEF_WINT_T) 42 | # ifdef __need_wint_t 43 | # undef _@GUARD_PREFIX@_STDDEF_H 44 | # define _GL_STDDEF_WINT_T 45 | # endif 46 | # @INCLUDE_NEXT@ @NEXT_STDDEF_H@ 47 | # endif 48 | 49 | #else 50 | /* Normal invocation convention. */ 51 | 52 | # ifndef _@GUARD_PREFIX@_STDDEF_H 53 | 54 | /* The include_next requires a split double-inclusion guard. */ 55 | 56 | # @INCLUDE_NEXT@ @NEXT_STDDEF_H@ 57 | 58 | # ifndef _@GUARD_PREFIX@_STDDEF_H 59 | # define _@GUARD_PREFIX@_STDDEF_H 60 | 61 | /* On NetBSD 5.0, the definition of NULL lacks proper parentheses. */ 62 | #if @REPLACE_NULL@ 63 | # undef NULL 64 | # ifdef __cplusplus 65 | /* ISO C++ says that the macro NULL must expand to an integer constant 66 | expression, hence '((void *) 0)' is not allowed in C++. */ 67 | # if __GNUG__ >= 3 68 | /* GNU C++ has a __null macro that behaves like an integer ('int' or 69 | 'long') but has the same size as a pointer. Use that, to avoid 70 | warnings. */ 71 | # define NULL __null 72 | # else 73 | # define NULL 0L 74 | # endif 75 | # else 76 | # define NULL ((void *) 0) 77 | # endif 78 | #endif 79 | 80 | /* Some platforms lack wchar_t. */ 81 | #if !@HAVE_WCHAR_T@ 82 | # define wchar_t int 83 | #endif 84 | 85 | # endif /* _@GUARD_PREFIX@_STDDEF_H */ 86 | # endif /* _@GUARD_PREFIX@_STDDEF_H */ 87 | #endif /* __need_XXX */ 88 | -------------------------------------------------------------------------------- /m4/memchr.m4: -------------------------------------------------------------------------------- 1 | # memchr.m4 serial 12 2 | dnl Copyright (C) 2002-2004, 2009-2011 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | AC_DEFUN_ONCE([gl_FUNC_MEMCHR], 8 | [ 9 | dnl Check for prerequisites for memory fence checks. 10 | gl_FUNC_MMAP_ANON 11 | AC_CHECK_HEADERS_ONCE([sys/mman.h]) 12 | AC_CHECK_FUNCS_ONCE([mprotect]) 13 | 14 | AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) 15 | m4_ifdef([gl_FUNC_MEMCHR_OBSOLETE], [ 16 | dnl These days, we assume memchr is present. But if support for old 17 | dnl platforms is desired: 18 | AC_CHECK_FUNCS_ONCE([memchr]) 19 | if test $ac_cv_func_memchr = no; then 20 | HAVE_MEMCHR=0 21 | fi 22 | ]) 23 | if test $HAVE_MEMCHR = 1; then 24 | # Detect platform-specific bugs in some versions of glibc: 25 | # memchr should not dereference anything with length 0 26 | # http://bugzilla.redhat.com/499689 27 | # memchr should not dereference overestimated length after a match 28 | # http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=521737 29 | # http://sourceware.org/bugzilla/show_bug.cgi?id=10162 30 | # Assume that memchr works on platforms that lack mprotect. 31 | AC_CACHE_CHECK([whether memchr works], [gl_cv_func_memchr_works], 32 | [AC_RUN_IFELSE([AC_LANG_PROGRAM([[ 33 | #include 34 | #if HAVE_SYS_MMAN_H 35 | # include 36 | # include 37 | # include 38 | # include 39 | # ifndef MAP_FILE 40 | # define MAP_FILE 0 41 | # endif 42 | #endif 43 | ]], [[ 44 | int result = 0; 45 | char *fence = NULL; 46 | #if HAVE_SYS_MMAN_H && HAVE_MPROTECT 47 | # if HAVE_MAP_ANONYMOUS 48 | const int flags = MAP_ANONYMOUS | MAP_PRIVATE; 49 | const int fd = -1; 50 | # else /* !HAVE_MAP_ANONYMOUS */ 51 | const int flags = MAP_FILE | MAP_PRIVATE; 52 | int fd = open ("/dev/zero", O_RDONLY, 0666); 53 | if (fd >= 0) 54 | # endif 55 | { 56 | int pagesize = getpagesize (); 57 | char *two_pages = 58 | (char *) mmap (NULL, 2 * pagesize, PROT_READ | PROT_WRITE, 59 | flags, fd, 0); 60 | if (two_pages != (char *)(-1) 61 | && mprotect (two_pages + pagesize, pagesize, PROT_NONE) == 0) 62 | fence = two_pages + pagesize; 63 | } 64 | #endif 65 | if (fence) 66 | { 67 | if (memchr (fence, 0, 0)) 68 | result |= 1; 69 | strcpy (fence - 9, "12345678"); 70 | if (memchr (fence - 9, 0, 79) != fence - 1) 71 | result |= 2; 72 | if (memchr (fence - 1, 0, 3) != fence - 1) 73 | result |= 4; 74 | } 75 | return result; 76 | ]])], [gl_cv_func_memchr_works=yes], [gl_cv_func_memchr_works=no], 77 | [dnl Be pessimistic for now. 78 | gl_cv_func_memchr_works="guessing no"])]) 79 | if test "$gl_cv_func_memchr_works" != yes; then 80 | REPLACE_MEMCHR=1 81 | fi 82 | fi 83 | ]) 84 | 85 | # Prerequisites of lib/memchr.c. 86 | AC_DEFUN([gl_PREREQ_MEMCHR], [ 87 | AC_CHECK_HEADERS([bp-sym.h]) 88 | ]) 89 | -------------------------------------------------------------------------------- /lib/memmem.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1991-1994, 1996-1998, 2000, 2004, 2007-2011 Free Software 2 | Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 3, or (at your option) 8 | any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, 17 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ 18 | 19 | /* This particular implementation was written by Eric Blake, 2008. */ 20 | 21 | #ifndef _LIBC 22 | # include 23 | #endif 24 | 25 | /* Specification of memmem. */ 26 | #include 27 | 28 | #ifndef _LIBC 29 | # define __builtin_expect(expr, val) (expr) 30 | #endif 31 | 32 | #define RETURN_TYPE void * 33 | #define AVAILABLE(h, h_l, j, n_l) ((j) <= (h_l) - (n_l)) 34 | #include "str-two-way.h" 35 | 36 | /* Return the first occurrence of NEEDLE in HAYSTACK. Return HAYSTACK 37 | if NEEDLE_LEN is 0, otherwise NULL if NEEDLE is not found in 38 | HAYSTACK. */ 39 | void * 40 | memmem (const void *haystack_start, size_t haystack_len, 41 | const void *needle_start, size_t needle_len) 42 | { 43 | /* Abstract memory is considered to be an array of 'unsigned char' values, 44 | not an array of 'char' values. See ISO C 99 section 6.2.6.1. */ 45 | const unsigned char *haystack = (const unsigned char *) haystack_start; 46 | const unsigned char *needle = (const unsigned char *) needle_start; 47 | 48 | if (needle_len == 0) 49 | /* The first occurrence of the empty string is deemed to occur at 50 | the beginning of the string. */ 51 | return (void *) haystack; 52 | 53 | /* Sanity check, otherwise the loop might search through the whole 54 | memory. */ 55 | if (__builtin_expect (haystack_len < needle_len, 0)) 56 | return NULL; 57 | 58 | /* Use optimizations in memchr when possible, to reduce the search 59 | size of haystack using a linear algorithm with a smaller 60 | coefficient. However, avoid memchr for long needles, since we 61 | can often achieve sublinear performance. */ 62 | if (needle_len < LONG_NEEDLE_THRESHOLD) 63 | { 64 | haystack = memchr (haystack, *needle, haystack_len); 65 | if (!haystack || __builtin_expect (needle_len == 1, 0)) 66 | return (void *) haystack; 67 | haystack_len -= haystack - (const unsigned char *) haystack_start; 68 | if (haystack_len < needle_len) 69 | return NULL; 70 | return two_way_short_needle (haystack, haystack_len, needle, needle_len); 71 | } 72 | else 73 | return two_way_long_needle (haystack, haystack_len, needle, needle_len); 74 | } 75 | 76 | #undef LONG_NEEDLE_THRESHOLD 77 | -------------------------------------------------------------------------------- /doc/kernel.md: -------------------------------------------------------------------------------- 1 | # Kernels 2 | 3 | ## Available OpenCL kernels 4 | 5 | See directory `kernel`. 6 | 7 | ## Parameter configuration 8 | 9 | ### Common 10 | 11 | In general, switching kernels requires reconfiguring mining parameters, 12 | such as (but not necessarily limited to) `thread-concurrency`, `intensity`, 13 | `gpu-engine` and `gpu-memclock`. 14 | 15 | A description of how to do this is available in `doc/MINING.md`. 16 | 17 | 18 | ### Scrypt kernels 19 | 20 | #### alexkarnew 21 | 22 | Alexey Karimov's optimised kernel, based on `ckolivas`. For Catalyst >=13.4. 23 | 24 | Only supports `vectors=1`. 25 | 26 | [Announcement](https://litecointalk.org/index.php?topic=4082.0). 27 | 28 | 29 | #### alexkarold 30 | 31 | Alexey Karimov's optimised kernel, based on `ckolivas`. For Catalyst <13.4. 32 | 33 | Only supports `vectors=1`. 34 | 35 | [Announcement](https://litecointalk.org/index.php?topic=4082.0). 36 | 37 | 38 | #### bufius 39 | 40 | Bufius' optimised kernel, based on `ckolivas`. Merged from vertminer. 41 | 42 | Only supports `vectors=1` and `lookup-gap` 2, 4 or 8. 43 | 44 | 45 | #### ckolivas 46 | 47 | The original Colin Percival `scrypt` kernel, maintained for a long time by 48 | Con Kolivas in `cgminer` and renamed to reflect the fact. 49 | 50 | Only supports `vectors=1`. 51 | 52 | 53 | #### psw 54 | 55 | Pavel Semjanov optimised kernel, SHA256 speedups. 56 | 57 | [Announcement](https://bitcointalk.org/index.php?topic=369858.0). 58 | 59 | 60 | #### zuikkis 61 | 62 | Zuikkis' optimised kernel, based on `ckolivas`. 63 | 64 | Only supports `vectors=1` and `lookup-gap=2`. 65 | 66 | [Announcement](https://litecointalk.org/index.php?topic=6058.msg90873#msg90873). 67 | 68 | ### Other kernels 69 | 70 | #### darkcoin 71 | #### darkcoin-mod 72 | #### animecoin 73 | #### fuguecoin 74 | #### groestlcoin 75 | #### inkcoin 76 | #### marucoin 77 | #### marucoin-mod 78 | #### myriadcoin-groestl 79 | #### quarkcoin 80 | #### qubitcoin 81 | #### sifcoin 82 | #### twecoin 83 | #### maxcoin 84 | 85 | ## Submitting new kernels 86 | 87 | ### Requirements 88 | 89 | * OpenCL source code only, licenced under GPLv3 (or later). 90 | * Not hard-coded for a specific GPU model or manufacturer. 91 | * Known limitations and any specific configuration quirks must be 92 | mentioned. 93 | 94 | 95 | ### Procedure 96 | 97 | * Copy the kernel you wish to modify, make sure the character encoding is 98 | UTF-8 and commit it without any further modifications. 99 | 100 | This way, it is easy to verify that there are no hidden changes. Note in 101 | the commit message which kernel is used as a base. 102 | 103 | * Make changes to the kernel. Commit them. 104 | 105 | This allows to produce a diff that makes sense. 106 | 107 | * Recompile and test that the kernel actually works. 108 | 109 | * Add yourself to the "kernels" section in `AUTHORS.md`. Keep it short. 110 | 111 | * Submit a pull request on GitHub, file it at the issue tracker, or mail 112 | it. 113 | 114 | Outline the changes made, known limitations, and tested GPUs. List 115 | your git repository and branch name. The current repository and issue 116 | tracker links should be in `README.md`. 117 | -------------------------------------------------------------------------------- /ccan/opt/usage.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "private.h" 7 | 8 | /* We only use this for pointer comparisons. */ 9 | const char opt_hidden[1] = { 0 }; 10 | 11 | static unsigned write_short_options(char *str) 12 | { 13 | unsigned int i, num = 0; 14 | const char *p; 15 | 16 | for (p = first_sopt(&i); p; p = next_sopt(p, &i)) { 17 | if (opt_table[i].desc != opt_hidden) 18 | str[num++] = *p; 19 | } 20 | return num; 21 | } 22 | 23 | #define OPT_SPACE_PAD " " 24 | 25 | /* FIXME: Get all purdy. */ 26 | char *opt_usage(const char *argv0, const char *extra) 27 | { 28 | unsigned int i, num, len; 29 | char *ret, *p; 30 | 31 | if (!extra) { 32 | extra = ""; 33 | for (i = 0; i < opt_count; i++) { 34 | if (opt_table[i].cb == (void *)opt_usage_and_exit 35 | && opt_table[i].u.carg) { 36 | extra = (const char *)opt_table[i].u.carg; 37 | break; 38 | } 39 | } 40 | } 41 | 42 | /* An overestimate of our length. */ 43 | len = strlen("Usage: %s ") + strlen(argv0) 44 | + strlen("[-%.*s]") + opt_num_short + 1 45 | + strlen(" ") + strlen(extra) 46 | + strlen("\n"); 47 | 48 | for (i = 0; i < opt_count; i++) { 49 | if (opt_table[i].type == OPT_SUBTABLE) { 50 | len += strlen("\n") + strlen(opt_table[i].desc) 51 | + strlen(":\n"); 52 | } else if (opt_table[i].desc != opt_hidden) { 53 | len += strlen(opt_table[i].names) + strlen(" "); 54 | len += strlen(OPT_SPACE_PAD) 55 | + strlen(opt_table[i].desc) + 1; 56 | if (opt_table[i].show) { 57 | len += strlen("(default: %s)") 58 | + OPT_SHOW_LEN + sizeof("..."); 59 | } 60 | len += strlen("\n"); 61 | } 62 | } 63 | 64 | p = ret = (char *)malloc(len); 65 | if (!ret) 66 | return NULL; 67 | 68 | p += sprintf(p, "Usage: %s", argv0); 69 | p += sprintf(p, " [-"); 70 | num = write_short_options(p); 71 | if (num) { 72 | p += num; 73 | p += sprintf(p, "]"); 74 | } else { 75 | /* Remove start of single-entry options */ 76 | p -= 3; 77 | } 78 | if (extra) 79 | p += sprintf(p, " %s", extra); 80 | p += sprintf(p, "\n"); 81 | 82 | for (i = 0; i < opt_count; i++) { 83 | if (opt_table[i].desc == opt_hidden) 84 | continue; 85 | if (opt_table[i].type == OPT_SUBTABLE) { 86 | p += sprintf(p, "%s:\n", opt_table[i].desc); 87 | continue; 88 | } 89 | len = sprintf(p, "%s", opt_table[i].names); 90 | if (opt_table[i].type == OPT_HASARG 91 | && !strchr(opt_table[i].names, ' ') 92 | && !strchr(opt_table[i].names, '=')) 93 | len += sprintf(p + len, " "); 94 | len += sprintf(p + len, "%.*s", 95 | len < strlen(OPT_SPACE_PAD) 96 | ? (unsigned)strlen(OPT_SPACE_PAD) - len : 1, 97 | OPT_SPACE_PAD); 98 | 99 | len += sprintf(p + len, "%s", opt_table[i].desc); 100 | if (opt_table[i].show) { 101 | char buf[OPT_SHOW_LEN + sizeof("...")]; 102 | strcpy(buf + OPT_SHOW_LEN, "..."); 103 | opt_table[i].show(buf, opt_table[i].u.arg); 104 | len += sprintf(p + len, " (default: %s)", buf); 105 | } 106 | p += len; 107 | p += sprintf(p, "\n"); 108 | } 109 | *p = '\0'; 110 | return ret; 111 | } 112 | -------------------------------------------------------------------------------- /winbuild/jansson/jansson.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | Source Files 26 | 27 | 28 | Source Files 29 | 30 | 31 | Source Files 32 | 33 | 34 | Source Files 35 | 36 | 37 | Source Files 38 | 39 | 40 | Source Files 41 | 42 | 43 | Source Files 44 | 45 | 46 | Source Files 47 | 48 | 49 | Source Files 50 | 51 | 52 | 53 | 54 | Header Files 55 | 56 | 57 | Header Files 58 | 59 | 60 | Header Files 61 | 62 | 63 | Header Files 64 | 65 | 66 | Header Files 67 | 68 | 69 | Header Files 70 | 71 | 72 | Header Files 73 | 74 | 75 | -------------------------------------------------------------------------------- /compat.h: -------------------------------------------------------------------------------- 1 | #ifndef COMPAT_H 2 | #define COMPAT_H 3 | 4 | #ifdef WIN32 5 | #include "config.h" 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include "miner.h" // for timersub 13 | #include "util.h" 14 | 15 | #include 16 | 17 | 18 | #if !defined S_ISDIR && defined S_IFDIR 19 | # define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR) 20 | #endif 21 | #if !S_IRUSR && S_IREAD 22 | # define S_IRUSR S_IREAD 23 | #endif 24 | #if !S_IRUSR 25 | # define S_IRUSR 00400 26 | #endif 27 | #if !S_IWUSR && S_IWRITE 28 | # define S_IWUSR S_IWRITE 29 | #endif 30 | #if !S_IWUSR 31 | # define S_IWUSR 00200 32 | #endif 33 | #if !S_IXUSR && S_IEXEC 34 | # define S_IXUSR S_IEXEC 35 | #endif 36 | #if !S_IXUSR 37 | # define S_IXUSR 00100 38 | #endif 39 | 40 | #ifndef HAVE_LIBWINPTHREAD 41 | static inline int nanosleep(const struct timespec *req, struct timespec *rem) 42 | { 43 | struct timeval tstart; 44 | DWORD msecs; 45 | 46 | cgtime(&tstart); 47 | msecs = (req->tv_sec * 1000) + ((999999 + req->tv_nsec) / 1000000); 48 | 49 | if (SleepEx(msecs, true) == WAIT_IO_COMPLETION) { 50 | if (rem) { 51 | struct timeval tdone, tnow, tleft; 52 | tdone.tv_sec = tstart.tv_sec + req->tv_sec; 53 | tdone.tv_usec = tstart.tv_usec + ((999 + req->tv_nsec) / 1000); 54 | if (tdone.tv_usec > 1000000) { 55 | tdone.tv_usec -= 1000000; 56 | ++tdone.tv_sec; 57 | } 58 | 59 | cgtime(&tnow); 60 | if (timercmp(&tnow, &tdone, >)) 61 | return 0; 62 | timersub(&tdone, &tnow, &tleft); 63 | 64 | rem->tv_sec = tleft.tv_sec; 65 | rem->tv_nsec = tleft.tv_usec * 1000; 66 | } 67 | errno = EINTR; 68 | return -1; 69 | } 70 | return 0; 71 | } 72 | #endif 73 | 74 | #if defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR) 75 | // Reported unneded in https://github.com/veox/sgminer/issues/37 */ 76 | static inline int sleep(unsigned int secs) 77 | { 78 | struct timespec req, rem; 79 | req.tv_sec = secs; 80 | req.tv_nsec = 0; 81 | if (!nanosleep(&req, &rem)) 82 | return 0; 83 | return rem.tv_sec + (rem.tv_nsec ? 1 : 0); 84 | } 85 | #endif 86 | 87 | enum { 88 | PRIO_PROCESS = 0, 89 | }; 90 | 91 | static inline int setpriority(__maybe_unused int which, __maybe_unused int who, __maybe_unused int prio) 92 | { 93 | /* FIXME - actually do something */ 94 | return 0; 95 | } 96 | 97 | #ifndef HAVE_STRSEP 98 | static inline char *strsep(char **stringp, const char *delim) 99 | { 100 | char *res; 101 | 102 | if (!stringp || !*stringp || !**stringp) { 103 | return NULL; 104 | } 105 | 106 | res = *stringp; 107 | while(**stringp && !strchr(delim, **stringp)) { 108 | ++(*stringp); 109 | } 110 | 111 | if (**stringp) { 112 | **stringp = '\0'; 113 | ++(*stringp); 114 | } 115 | 116 | return res; 117 | } 118 | #endif 119 | 120 | 121 | typedef unsigned long int ulong; 122 | typedef unsigned short int ushort; 123 | typedef unsigned int uint; 124 | 125 | #ifndef __SUSECONDS_T_TYPE 126 | typedef long suseconds_t; 127 | #endif 128 | 129 | #ifdef HAVE_LIBWINPTHREAD 130 | #define PTH(thr) ((thr)->pth) 131 | #else 132 | #define PTH(thr) ((thr)->pth.p) 133 | #endif 134 | 135 | #else 136 | #define PTH(thr) ((thr)->pth) 137 | #endif /* WIN32 */ 138 | 139 | #endif /* COMPAT_H */ 140 | -------------------------------------------------------------------------------- /kernel/wolf-skein.cl: -------------------------------------------------------------------------------- 1 | #ifndef WOLF_SKEIN_CL 2 | #define WOLF_SKEIN_CL 3 | 4 | // Vectorized Skein implementation macros and functions by Wolf 5 | 6 | #define SKEIN_KS_PARITY 0x1BD11BDAA9FC1A22 7 | 8 | static const __constant ulong SKEIN256_IV[8] = 9 | { 10 | 0xCCD044A12FDB3E13UL, 0xE83590301A79A9EBUL, 11 | 0x55AEA0614F816E6FUL, 0x2A2767A4AE9B94DBUL, 12 | 0xEC06025E74DD7683UL, 0xE7A436CDC4746251UL, 13 | 0xC36FBAF9393AD185UL, 0x3EEDBA1833EDFC13UL 14 | }; 15 | 16 | static const __constant ulong SKEIN512_256_IV[8] = 17 | { 18 | 0xCCD044A12FDB3E13UL, 0xE83590301A79A9EBUL, 19 | 0x55AEA0614F816E6FUL, 0x2A2767A4AE9B94DBUL, 20 | 0xEC06025E74DD7683UL, 0xE7A436CDC4746251UL, 21 | 0xC36FBAF9393AD185UL, 0x3EEDBA1833EDFC13UL 22 | }; 23 | 24 | #define SKEIN_INJECT_KEY(p, s) do { \ 25 | p += h; \ 26 | p.s5 += t[s % 3]; \ 27 | p.s6 += t[(s + 1) % 3]; \ 28 | p.s7 += s; \ 29 | } while(0) 30 | 31 | ulong SKEIN_ROT(const uint2 x, const uint y) 32 | { 33 | if(y < 32) return(as_ulong(amd_bitalign(x, x.s10, 32 - y))); 34 | else return(as_ulong(amd_bitalign(x.s10, x, 32 - (y - 32)))); 35 | } 36 | 37 | void SkeinMix8(ulong4 *pv0, ulong4 *pv1, const uint rc0, const uint rc1, const uint rc2, const uint rc3) 38 | { 39 | *pv0 += *pv1; 40 | (*pv1).s0 = SKEIN_ROT(as_uint2((*pv1).s0), rc0); 41 | (*pv1).s1 = SKEIN_ROT(as_uint2((*pv1).s1), rc1); 42 | (*pv1).s2 = SKEIN_ROT(as_uint2((*pv1).s2), rc2); 43 | (*pv1).s3 = SKEIN_ROT(as_uint2((*pv1).s3), rc3); 44 | *pv1 ^= *pv0; 45 | } 46 | 47 | ulong8 SkeinEvenRound(ulong8 p, const ulong8 h, const ulong *t, const uint s) 48 | { 49 | SKEIN_INJECT_KEY(p, s); 50 | ulong4 pv0 = p.even, pv1 = p.odd; 51 | 52 | SkeinMix8(&pv0, &pv1, 46, 36, 19, 37); 53 | pv0 = shuffle(pv0, (ulong4)(1, 2, 3, 0)); 54 | pv1 = shuffle(pv1, (ulong4)(0, 3, 2, 1)); 55 | 56 | SkeinMix8(&pv0, &pv1, 33, 27, 14, 42); 57 | pv0 = shuffle(pv0, (ulong4)(1, 2, 3, 0)); 58 | pv1 = shuffle(pv1, (ulong4)(0, 3, 2, 1)); 59 | 60 | SkeinMix8(&pv0, &pv1, 17, 49, 36, 39); 61 | pv0 = shuffle(pv0, (ulong4)(1, 2, 3, 0)); 62 | pv1 = shuffle(pv1, (ulong4)(0, 3, 2, 1)); 63 | 64 | SkeinMix8(&pv0, &pv1, 44, 9, 54, 56); 65 | return(shuffle2(pv0, pv1, (ulong8)(1, 4, 2, 7, 3, 6, 0, 5))); 66 | } 67 | 68 | ulong8 SkeinOddRound(ulong8 p, const ulong8 h, const ulong *t, const uint s) 69 | { 70 | SKEIN_INJECT_KEY(p, s); 71 | ulong4 pv0 = p.even, pv1 = p.odd; 72 | 73 | SkeinMix8(&pv0, &pv1, 39, 30, 34, 24); 74 | pv0 = shuffle(pv0, (ulong4)(1, 2, 3, 0)); 75 | pv1 = shuffle(pv1, (ulong4)(0, 3, 2, 1)); 76 | 77 | SkeinMix8(&pv0, &pv1, 13, 50, 10, 17); 78 | pv0 = shuffle(pv0, (ulong4)(1, 2, 3, 0)); 79 | pv1 = shuffle(pv1, (ulong4)(0, 3, 2, 1)); 80 | 81 | SkeinMix8(&pv0, &pv1, 25, 29, 39, 43); 82 | pv0 = shuffle(pv0, (ulong4)(1, 2, 3, 0)); 83 | pv1 = shuffle(pv1, (ulong4)(0, 3, 2, 1)); 84 | 85 | SkeinMix8(&pv0, &pv1, 8, 35, 56, 22); 86 | return(shuffle2(pv0, pv1, (ulong8)(1, 4, 2, 7, 3, 6, 0, 5))); 87 | } 88 | 89 | ulong8 Skein512Block(ulong8 p, ulong8 h, ulong h8, const ulong *t) 90 | { 91 | #pragma unroll 92 | for(int i = 0; i < 18; ++i) 93 | { 94 | p = SkeinEvenRound(p, h, t, i); 95 | ++i; 96 | ulong tmp = h.s0; 97 | h = shuffle(h, (ulong8)(1, 2, 3, 4, 5, 6, 7, 0)); 98 | h.s7 = h8; 99 | h8 = tmp; 100 | p = SkeinOddRound(p, h, t, i); 101 | tmp = h.s0; 102 | h = shuffle(h, (ulong8)(1, 2, 3, 4, 5, 6, 7, 0)); 103 | h.s7 = h8; 104 | h8 = tmp; 105 | } 106 | 107 | SKEIN_INJECT_KEY(p, 18); 108 | return(p); 109 | } 110 | 111 | #endif 112 | -------------------------------------------------------------------------------- /kernel/x11evo/x11evo_header.cl: -------------------------------------------------------------------------------- 1 | #ifndef X11EVO_CL 2 | #define X11EVO_CL 3 | 4 | #if __ENDIAN_LITTLE__ 5 | #define SPH_LITTLE_ENDIAN 1 6 | #else 7 | #define SPH_BIG_ENDIAN 1 8 | #endif 9 | 10 | #define SPH_UPTR sph_u64 11 | 12 | typedef unsigned int sph_u32; 13 | typedef int sph_s32; 14 | #ifndef __OPENCL_VERSION__ 15 | typedef unsigned long long sph_u64; 16 | typedef long long sph_s64; 17 | #else 18 | typedef unsigned long sph_u64; 19 | typedef long sph_s64; 20 | #endif 21 | 22 | #define SPH_64 1 23 | #define SPH_64_TRUE 1 24 | 25 | #define SPH_C32(x) ((sph_u32)(x ## U)) 26 | #define SPH_T32(x) ((x) & SPH_C32(0xFFFFFFFF)) 27 | #define SPH_ROTL32(x, n) SPH_T32(((x) << (n)) | ((x) >> (32 - (n)))) 28 | #define SPH_ROTR32(x, n) SPH_ROTL32(x, (32 - (n))) 29 | 30 | #define SPH_C64(x) ((sph_u64)(x ## UL)) 31 | #define SPH_T64(x) ((x) & SPH_C64(0xFFFFFFFFFFFFFFFF)) 32 | #define SPH_ROTL64(x, n) SPH_T64(((x) << (n)) | ((x) >> (64 - (n)))) 33 | #define SPH_ROTR64(x, n) SPH_ROTL64(x, (64 - (n))) 34 | 35 | #define SPH_ECHO_64 1 36 | #define SPH_KECCAK_64 1 37 | #define SPH_JH_64 1 38 | #define SPH_SIMD_NOCOPY 0 39 | #define SPH_KECCAK_NOCOPY 0 40 | #define SPH_SMALL_FOOTPRINT_GROESTL 0 41 | #define SPH_GROESTL_BIG_ENDIAN 0 42 | #define SPH_CUBEHASH_UNROLL 0 43 | #define SPH_COMPACT_BLAKE_64 0 44 | #define SPH_LUFFA_PARALLEL 0 45 | #define SPH_KECCAK_UNROLL 0 46 | 47 | #define SWAP_RESULT do { \ 48 | hash.h8[0] = SWAP8(hash.h8[0]); \ 49 | hash.h8[1] = SWAP8(hash.h8[1]); \ 50 | hash.h8[2] = SWAP8(hash.h8[2]); \ 51 | hash.h8[3] = SWAP8(hash.h8[3]); \ 52 | hash.h8[4] = SWAP8(hash.h8[4]); \ 53 | hash.h8[5] = SWAP8(hash.h8[5]); \ 54 | hash.h8[6] = SWAP8(hash.h8[6]); \ 55 | hash.h8[7] = SWAP8(hash.h8[7]); \ 56 | } while (0) 57 | 58 | 59 | #include "blake.cl" 60 | #include "bmw.cl" 61 | #include "groestl.cl" 62 | #include "jh.cl" 63 | #include "keccak.cl" 64 | #include "skein.cl" 65 | #include "luffa.cl" 66 | #include "cubehash.cl" 67 | #include "shavite.cl" 68 | #include "simd.cl" 69 | #include "echo.cl" 70 | #include "fugue.cl" 71 | #include "hamsi.cl" 72 | #include "shabal.cl" 73 | #include "whirlpool.cl" 74 | #include "wolf-sha512.cl" 75 | 76 | #define SWAP4(x) as_uint(as_uchar4(x).wzyx) 77 | #define SWAP8(x) as_ulong(as_uchar8(x).s76543210) 78 | 79 | #if SPH_BIG_ENDIAN 80 | #define DEC32BE(x) (*(const __global sph_u32 *) (x)) 81 | #define DEC64E(x) (x) 82 | #define DEC64BE(x) (*(const __global sph_u64 *) (x)) 83 | #else 84 | #define DEC32BE(x) SWAP4(*(const __global sph_u32 *) (x)) 85 | #define DEC64E(x) SWAP8(x) 86 | #define DEC64BE(x) SWAP8(*(const __global sph_u64 *) (x)) 87 | #endif 88 | 89 | __attribute__((reqd_work_group_size(WORKSIZE, 1, 1))) 90 | __kernel void search(__global unsigned char* block, volatile __global uint* output, const ulong target) 91 | { 92 | uint gid = get_global_id(0); 93 | union { 94 | unsigned char h1[64]; 95 | uint h4[16]; 96 | ulong h8[8]; 97 | } hash; 98 | 99 | __local sph_u32 AES0[256], AES1[256], AES2[256], AES3[256]; 100 | __local sph_u32 mixtab0[256], mixtab1[256], mixtab2[256], mixtab3[256]; 101 | int init = get_local_id(0); 102 | int step = get_local_size(0); 103 | for (int i = init; i < 256; i += step) 104 | { 105 | AES0[i] = AES0_C[i]; 106 | AES1[i] = AES1_C[i]; 107 | AES2[i] = AES2_C[i]; 108 | AES3[i] = AES3_C[i]; 109 | mixtab0[i] = mixtab0_c[i]; 110 | mixtab1[i] = mixtab1_c[i]; 111 | mixtab2[i] = mixtab2_c[i]; 112 | mixtab3[i] = mixtab3_c[i]; 113 | } 114 | barrier(CLK_LOCAL_MEM_FENCE); 115 | -------------------------------------------------------------------------------- /kernel/keccak1600.cl: -------------------------------------------------------------------------------- 1 | /* 2 | * keccak_1600 function 3 | * C. Buchner 2014 4 | * 5 | */ 6 | 7 | __constant static const sph_u64 RC[] = { 8 | SPH_C64(0x0000000000000001), SPH_C64(0x0000000000008082), 9 | SPH_C64(0x800000000000808A), SPH_C64(0x8000000080008000), 10 | SPH_C64(0x000000000000808B), SPH_C64(0x0000000080000001), 11 | SPH_C64(0x8000000080008081), SPH_C64(0x8000000000008009), 12 | SPH_C64(0x000000000000008A), SPH_C64(0x0000000000000088), 13 | SPH_C64(0x0000000080008009), SPH_C64(0x000000008000000A), 14 | SPH_C64(0x000000008000808B), SPH_C64(0x800000000000008B), 15 | SPH_C64(0x8000000000008089), SPH_C64(0x8000000000008003), 16 | SPH_C64(0x8000000000008002), SPH_C64(0x8000000000000080), 17 | SPH_C64(0x000000000000800A), SPH_C64(0x800000008000000A), 18 | SPH_C64(0x8000000080008081), SPH_C64(0x8000000000008080), 19 | SPH_C64(0x0000000080000001), SPH_C64(0x8000000080008008) 20 | }; 21 | 22 | 23 | inline void keccak_block(ulong *s) { 24 | size_t i; 25 | ulong t[5], u[5], v, w; 26 | 27 | for (i = 0; i < 24; i++) { 28 | /* theta: c = a[0,i] ^ a[1,i] ^ .. a[4,i] */ 29 | t[0] = s[0] ^ s[5] ^ s[10] ^ s[15] ^ s[20]; 30 | t[1] = s[1] ^ s[6] ^ s[11] ^ s[16] ^ s[21]; 31 | t[2] = s[2] ^ s[7] ^ s[12] ^ s[17] ^ s[22]; 32 | t[3] = s[3] ^ s[8] ^ s[13] ^ s[18] ^ s[23]; 33 | t[4] = s[4] ^ s[9] ^ s[14] ^ s[19] ^ s[24]; 34 | 35 | /* theta: d[i] = c[i+4] ^ rotl(c[i+1],1) */ 36 | u[0] = t[4] ^ SPH_ROTL64(t[1], 1); 37 | u[1] = t[0] ^ SPH_ROTL64(t[2], 1); 38 | u[2] = t[1] ^ SPH_ROTL64(t[3], 1); 39 | u[3] = t[2] ^ SPH_ROTL64(t[4], 1); 40 | u[4] = t[3] ^ SPH_ROTL64(t[0], 1); 41 | 42 | /* theta: a[0,i], a[1,i], .. a[4,i] ^= d[i] */ 43 | s[0] ^= u[0]; s[5] ^= u[0]; s[10] ^= u[0]; s[15] ^= u[0]; s[20] ^= u[0]; 44 | s[1] ^= u[1]; s[6] ^= u[1]; s[11] ^= u[1]; s[16] ^= u[1]; s[21] ^= u[1]; 45 | s[2] ^= u[2]; s[7] ^= u[2]; s[12] ^= u[2]; s[17] ^= u[2]; s[22] ^= u[2]; 46 | s[3] ^= u[3]; s[8] ^= u[3]; s[13] ^= u[3]; s[18] ^= u[3]; s[23] ^= u[3]; 47 | s[4] ^= u[4]; s[9] ^= u[4]; s[14] ^= u[4]; s[19] ^= u[4]; s[24] ^= u[4]; 48 | 49 | /* rho pi: b[..] = rotl(a[..], ..) */ 50 | v = s[1]; 51 | s[1] = SPH_ROTL64(s[6], 44); 52 | s[6] = SPH_ROTL64(s[9], 20); 53 | s[9] = SPH_ROTL64(s[22], 61); 54 | s[22] = SPH_ROTL64(s[14], 39); 55 | s[14] = SPH_ROTL64(s[20], 18); 56 | s[20] = SPH_ROTL64(s[2], 62); 57 | s[2] = SPH_ROTL64(s[12], 43); 58 | s[12] = SPH_ROTL64(s[13], 25); 59 | s[13] = SPH_ROTL64(s[19], 8); 60 | s[19] = SPH_ROTL64(s[23], 56); 61 | s[23] = SPH_ROTL64(s[15], 41); 62 | s[15] = SPH_ROTL64(s[4], 27); 63 | s[4] = SPH_ROTL64(s[24], 14); 64 | s[24] = SPH_ROTL64(s[21], 2); 65 | s[21] = SPH_ROTL64(s[8], 55); 66 | s[8] = SPH_ROTL64(s[16], 45); 67 | s[16] = SPH_ROTL64(s[5], 36); 68 | s[5] = SPH_ROTL64(s[3], 28); 69 | s[3] = SPH_ROTL64(s[18], 21); 70 | s[18] = SPH_ROTL64(s[17], 15); 71 | s[17] = SPH_ROTL64(s[11], 10); 72 | s[11] = SPH_ROTL64(s[7], 6); 73 | s[7] = SPH_ROTL64(s[10], 3); 74 | s[10] = SPH_ROTL64(v, 1); 75 | 76 | v = s[0]; w = s[1]; s[0] ^= (~w) & s[2]; s[1] ^= (~s[2]) & s[3]; s[2] ^= (~s[3]) & s[4]; s[3] ^= (~s[4]) & v; s[4] ^= (~v) & w; 77 | v = s[5]; w = s[6]; s[5] ^= (~w) & s[7]; s[6] ^= (~s[7]) & s[8]; s[7] ^= (~s[8]) & s[9]; s[8] ^= (~s[9]) & v; s[9] ^= (~v) & w; 78 | v = s[10]; w = s[11]; s[10] ^= (~w) & s[12]; s[11] ^= (~s[12]) & s[13]; s[12] ^= (~s[13]) & s[14]; s[13] ^= (~s[14]) & v; s[14] ^= (~v) & w; 79 | v = s[15]; w = s[16]; s[15] ^= (~w) & s[17]; s[16] ^= (~s[17]) & s[18]; s[17] ^= (~s[18]) & s[19]; s[18] ^= (~s[19]) & v; s[19] ^= (~v) & w; 80 | v = s[20]; w = s[21]; s[20] ^= (~w) & s[22]; s[21] ^= (~s[22]) & s[23]; s[22] ^= (~s[23]) & s[24]; s[23] ^= (~s[24]) & v; s[24] ^= (~v) & w; 81 | 82 | s[0] ^= RC[i]; 83 | } 84 | }; -------------------------------------------------------------------------------- /kernel/blake256.cl: -------------------------------------------------------------------------------- 1 | /* 2 | * blake256 kernel implementation. 3 | * 4 | * ==========================(LICENSE BEGIN)============================ 5 | * Copyright (c) 2014 djm34 6 | * Copyright (c) 2014 tpruvot 7 | * Permission is hereby granted, free of charge, to any person obtaining 8 | * a copy of this software and associated documentation files (the 9 | * "Software"), to deal in the Software without restriction, including 10 | * without limitation the rights to use, copy, modify, merge, publish, 11 | * distribute, sublicense, and/or sell copies of the Software, and to 12 | * permit persons to whom the Software is furnished to do so, subject to 13 | * the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be 16 | * included in all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 21 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 22 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 23 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 24 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 | * 26 | * ===========================(LICENSE END)============================= 27 | * 28 | * @author djm34 29 | */ 30 | __constant static const int sigma[16][16] = { 31 | { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }, 32 | { 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 }, 33 | { 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4 }, 34 | { 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8 }, 35 | { 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13 }, 36 | { 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9 }, 37 | { 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11 }, 38 | { 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10 }, 39 | { 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5 }, 40 | { 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0 }, 41 | { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }, 42 | { 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 }, 43 | { 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4 }, 44 | { 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8 }, 45 | { 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13 }, 46 | { 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9 } 47 | }; 48 | 49 | 50 | __constant static const sph_u32 c_IV256[8] = { 51 | 0x6A09E667, 0xBB67AE85, 52 | 0x3C6EF372, 0xA54FF53A, 53 | 0x510E527F, 0x9B05688C, 54 | 0x1F83D9AB, 0x5BE0CD19 55 | }; 56 | 57 | /* Second part (64-80) msg never change, store it */ 58 | __constant static const sph_u32 c_Padding[16] = { 59 | 0, 0, 0, 0, 60 | 0x80000000, 0, 0, 0, 61 | 0, 0, 0, 0, 62 | 0, 1, 0, 640, 63 | }; 64 | __constant static const sph_u32 c_u256[16] = { 65 | 0x243F6A88, 0x85A308D3, 66 | 0x13198A2E, 0x03707344, 67 | 0xA4093822, 0x299F31D0, 68 | 0x082EFA98, 0xEC4E6C89, 69 | 0x452821E6, 0x38D01377, 70 | 0xBE5466CF, 0x34E90C6C, 71 | 0xC0AC29B7, 0xC97C50DD, 72 | 0x3F84D5B5, 0xB5470917 73 | }; 74 | 75 | #define GS(a,b,c,d,x) { \ 76 | const sph_u32 idx1 = sigma[r][x]; \ 77 | const sph_u32 idx2 = sigma[r][x+1]; \ 78 | v[a] += (m[idx1] ^ c_u256[idx2]) + v[b]; \ 79 | v[d] ^= v[a]; \ 80 | v[d] = rotate(v[d], 16U); \ 81 | v[c] += v[d]; \ 82 | v[b] ^= v[c]; \ 83 | v[b] = rotate(v[b], 20U); \ 84 | \ 85 | v[a] += (m[idx2] ^ c_u256[idx1]) + v[b]; \ 86 | v[d] ^= v[a]; \ 87 | v[d] = rotate(v[d], 24U); \ 88 | v[c] += v[d]; \ 89 | v[b] ^= v[c]; \ 90 | v[b] = rotate(v[b], 25U); \ 91 | } 92 | 93 | 94 | 95 | 96 | 97 | -------------------------------------------------------------------------------- /kernel/cubehash256.cl: -------------------------------------------------------------------------------- 1 | // cubehash256 2 | // djm34 2015 based on ccminer cubehash512 3 | 4 | #define CUBEHASH_ROUNDS 16 /* this is r for CubeHashr/b */ 5 | #define CUBEHASH_BLOCKBYTES 32 /* this is b for CubeHashr/b */ 6 | 7 | 8 | #define LROT(x, bits) rotate( x,(uint) bits) 9 | 10 | 11 | #define ROTATEUPWARDS7(a) LROT(a,7) 12 | #define ROTATEUPWARDS11(a) LROT(a,11) 13 | 14 | #define SWAP(a,b) { uint u = a; a = b; b = u; } 15 | 16 | inline void rrounds(uint x[2][2][2][2][2]) 17 | { 18 | int r; 19 | int j; 20 | int k; 21 | int l; 22 | int m; 23 | 24 | //#pragma unroll 2 25 | for (r = 0; r < CUBEHASH_ROUNDS; ++r) { 26 | 27 | /* "add x_0jklm into x_1jklmn modulo 2^32" */ 28 | //#pragma unroll 2 29 | for (j = 0; j < 2; ++j) 30 | //#pragma unroll 2 31 | for (k = 0; k < 2; ++k) 32 | //#pragma unroll 2 33 | for (l = 0; l < 2; ++l) 34 | //#pragma unroll 2 35 | for (m = 0; m < 2; ++m) 36 | x[1][j][k][l][m] += x[0][j][k][l][m]; 37 | 38 | /* "rotate x_0jklm upwards by 7 bits" */ 39 | //#pragma unroll 2 40 | for (j = 0; j < 2; ++j) 41 | //#pragma unroll 2 42 | for (k = 0; k < 2; ++k) 43 | //#pragma unroll 2 44 | for (l = 0; l < 2; ++l) 45 | //#pragma unroll 2 46 | for (m = 0; m < 2; ++m) 47 | x[0][j][k][l][m] = ROTATEUPWARDS7(x[0][j][k][l][m]); 48 | 49 | /* "swap x_00klm with x_01klm" */ 50 | //#pragma unroll 2 51 | for (k = 0; k < 2; ++k) 52 | //#pragma unroll 2 53 | for (l = 0; l < 2; ++l) 54 | //#pragma unroll 2 55 | for (m = 0; m < 2; ++m) 56 | SWAP(x[0][0][k][l][m], x[0][1][k][l][m]) 57 | 58 | /* "xor x_1jklm into x_0jklm" */ 59 | //#pragma unroll 2 60 | for (j = 0; j < 2; ++j) 61 | //#pragma unroll 2 62 | for (k = 0; k < 2; ++k) 63 | //#pragma unroll 2 64 | for (l = 0; l < 2; ++l) 65 | //#pragma unroll 2 66 | for (m = 0; m < 2; ++m) 67 | x[0][j][k][l][m] ^= x[1][j][k][l][m]; 68 | 69 | /* "swap x_1jk0m with x_1jk1m" */ 70 | //#pragma unroll 2 71 | for (j = 0; j < 2; ++j) 72 | //#pragma unroll 2 73 | for (k = 0; k < 2; ++k) 74 | //#pragma unroll 2 75 | for (m = 0; m < 2; ++m) 76 | SWAP(x[1][j][k][0][m], x[1][j][k][1][m]) 77 | 78 | /* "add x_0jklm into x_1jklm modulo 2^32" */ 79 | //#pragma unroll 2 80 | for (j = 0; j < 2; ++j) 81 | //#pragma unroll 2 82 | for (k = 0; k < 2; ++k) 83 | //#pragma unroll 2 84 | for (l = 0; l < 2; ++l) 85 | //#pragma unroll 2 86 | for (m = 0; m < 2; ++m) 87 | x[1][j][k][l][m] += x[0][j][k][l][m]; 88 | 89 | /* "rotate x_0jklm upwards by 11 bits" */ 90 | //#pragma unroll 2 91 | for (j = 0; j < 2; ++j) 92 | //#pragma unroll 2 93 | for (k = 0; k < 2; ++k) 94 | //#pragma unroll 2 95 | for (l = 0; l < 2; ++l) 96 | //#pragma unroll 2 97 | for (m = 0; m < 2; ++m) 98 | x[0][j][k][l][m] = ROTATEUPWARDS11(x[0][j][k][l][m]); 99 | 100 | /* "swap x_0j0lm with x_0j1lm" */ 101 | //#pragma unroll 2 102 | for (j = 0; j < 2; ++j) 103 | //#pragma unroll 2 104 | for (l = 0; l < 2; ++l) 105 | //#pragma unroll 2 106 | for (m = 0; m < 2; ++m) 107 | SWAP(x[0][j][0][l][m], x[0][j][1][l][m]) 108 | 109 | /* "xor x_1jklm into x_0jklm" */ 110 | //#pragma unroll 2 111 | for (j = 0; j < 2; ++j) 112 | //#pragma unroll 2 113 | for (k = 0; k < 2; ++k) 114 | //#pragma unroll 2 115 | for (l = 0; l < 2; ++l) 116 | //#pragma unroll 2 117 | for (m = 0; m < 2; ++m) 118 | x[0][j][k][l][m] ^= x[1][j][k][l][m]; 119 | 120 | /* "swap x_1jkl0 with x_1jkl1" */ 121 | //#pragma unroll 2 122 | for (j = 0; j < 2; ++j) 123 | //#pragma unroll 2 124 | for (k = 0; k < 2; ++k) 125 | //#pragma unroll 2 126 | for (l = 0; l < 2; ++l) 127 | SWAP(x[1][j][k][l][0], x[1][j][k][l][1]) 128 | 129 | } 130 | } 131 | 132 | 133 | -------------------------------------------------------------------------------- /ccan/opt/test/run-checkopt.c: -------------------------------------------------------------------------------- 1 | #include "config.h" 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "utils.h" 9 | 10 | /* We don't actually want it to exit... */ 11 | static jmp_buf exited; 12 | #define errx save_and_jump 13 | 14 | static void save_and_jump(int ecode, const char *fmt, ...); 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | static char *output = NULL; 22 | 23 | static int saved_vprintf(const char *fmt, va_list ap) 24 | { 25 | char *p; 26 | int ret = vasprintf(&p, fmt, ap); 27 | 28 | if (output) { 29 | output = realloc(output, strlen(output) + strlen(p) + 1); 30 | strcat(output, p); 31 | free(p); 32 | } else 33 | output = p; 34 | return ret; 35 | } 36 | 37 | static void save_and_jump(int ecode, const char *fmt, ...) 38 | { 39 | va_list ap; 40 | 41 | va_start(ap, fmt); 42 | saved_vprintf(fmt, ap); 43 | va_end(ap); 44 | longjmp(exited, ecode + 1); 45 | } 46 | 47 | static void reset(void) 48 | { 49 | free(output); 50 | output = NULL; 51 | free(opt_table); 52 | opt_table = NULL; 53 | opt_count = opt_num_short = opt_num_short_arg = opt_num_long = 0; 54 | } 55 | 56 | int main(int argc, char *argv[]) 57 | { 58 | int exitval; 59 | 60 | plan_tests(14); 61 | 62 | exitval = setjmp(exited); 63 | if (exitval == 0) { 64 | /* Bad type. */ 65 | _opt_register("-a", OPT_SUBTABLE, (void *)opt_version_and_exit, 66 | NULL, NULL, "1.2.3", ""); 67 | fail("_opt_register returned?"); 68 | } else { 69 | ok1(exitval - 1 == 1); 70 | ok1(strstr(output, "Option -a: unknown entry type")); 71 | } 72 | reset(); 73 | 74 | exitval = setjmp(exited); 75 | if (exitval == 0) { 76 | /* NULL description. */ 77 | opt_register_noarg("-a", test_noarg, "", NULL); 78 | fail("_opt_register returned?"); 79 | } else { 80 | ok1(exitval - 1 == 1); 81 | ok1(strstr(output, "Option -a: description cannot be NULL")); 82 | } 83 | reset(); 84 | 85 | exitval = setjmp(exited); 86 | if (exitval == 0) { 87 | /* Bad option name. */ 88 | opt_register_noarg("a", test_noarg, "", ""); 89 | fail("_opt_register returned?"); 90 | } else { 91 | ok1(exitval - 1 == 1); 92 | ok1(strstr(output, "Option a: does not begin with '-'")); 93 | } 94 | 95 | reset(); 96 | 97 | exitval = setjmp(exited); 98 | if (exitval == 0) { 99 | /* Bad option name. */ 100 | opt_register_noarg("--", test_noarg, "", ""); 101 | fail("_opt_register returned?"); 102 | } else { 103 | ok1(exitval - 1 == 1); 104 | ok1(strstr(output, "Option --: invalid long option '--'")); 105 | } 106 | 107 | reset(); 108 | 109 | exitval = setjmp(exited); 110 | if (exitval == 0) { 111 | /* Bad option name. */ 112 | opt_register_noarg("--a|-aaa", test_noarg, "", ""); 113 | fail("_opt_register returned?"); 114 | } else { 115 | ok1(exitval - 1 == 1); 116 | ok1(strstr(output, 117 | "Option --a|-aaa: invalid short option '-aaa'")); 118 | } 119 | reset(); 120 | 121 | exitval = setjmp(exited); 122 | if (exitval == 0) { 123 | /* Documentation for non-optios. */ 124 | opt_register_noarg("--a foo", test_noarg, "", ""); 125 | fail("_opt_register returned?"); 126 | } else { 127 | ok1(exitval - 1 == 1); 128 | ok1(strstr(output, 129 | "Option --a foo: does not take arguments 'foo'")); 130 | } 131 | reset(); 132 | 133 | exitval = setjmp(exited); 134 | if (exitval == 0) { 135 | /* Documentation for non-optios. */ 136 | opt_register_noarg("--a=foo", test_noarg, "", ""); 137 | fail("_opt_register returned?"); 138 | } else { 139 | ok1(exitval - 1 == 1); 140 | ok1(strstr(output, 141 | "Option --a=foo: does not take arguments 'foo'")); 142 | } 143 | return exit_status(); 144 | } 145 | -------------------------------------------------------------------------------- /winbuild/dist/include/winbuild.h: -------------------------------------------------------------------------------- 1 | #ifndef WINBUILD_H 2 | #define WINBUILD_H 3 | 4 | #if defined(_MSC_VER) 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | typedef intptr_t ssize_t; 20 | 21 | #define snprintf _snprintf 22 | #define strdup _strdup 23 | #define execv _execv 24 | #define access _access 25 | #define fdopen _fdopen 26 | 27 | #define inline __inline 28 | 29 | struct timezone2 30 | { 31 | __int32 tz_minuteswest; /* minutes W of Greenwich */ 32 | __int32 tz_dsttime; /* type of dst correction */ 33 | }; 34 | 35 | 36 | const __int64 DELTA_EPOCH_IN_MICROSECS= 11644473600000000; 37 | 38 | /* IN UNIX the use of the timezone struct is obsolete; 39 | I don't know why you use it. See http://linux.about.com/od/commands/l/blcmdl2_gettime.htm 40 | But if you want to use this structure to know about GMT(UTC) diffrence from your local time 41 | it will be next: tz_minuteswest is the real diffrence in minutes from GMT(UTC) and a tz_dsttime is a flag 42 | indicates whether daylight is now in use 43 | */ 44 | 45 | inline int gettimeofday(struct timeval *tv/*in*/, struct timezone2 *tz/*in*/) 46 | { 47 | FILETIME ft; 48 | __int64 tmpres = 0; 49 | TIME_ZONE_INFORMATION tz_winapi; 50 | int rez=0; 51 | 52 | ZeroMemory(&ft,sizeof(ft)); 53 | ZeroMemory(&tz_winapi,sizeof(tz_winapi)); 54 | 55 | GetSystemTimeAsFileTime(&ft); 56 | 57 | tmpres = ft.dwHighDateTime; 58 | tmpres <<= 32; 59 | tmpres |= ft.dwLowDateTime; 60 | 61 | /*converting file time to unix epoch*/ 62 | tmpres /= 10; /*convert into microseconds*/ 63 | tmpres -= DELTA_EPOCH_IN_MICROSECS; 64 | tv->tv_sec = (__int32)(tmpres*0.000001); 65 | tv->tv_usec =(tmpres%1000000); 66 | 67 | if( tz ) 68 | { 69 | //_tzset(),don't work properly, so we use GetTimeZoneInformation 70 | rez=GetTimeZoneInformation(&tz_winapi); 71 | tz->tz_dsttime=(rez==2)?true:false; 72 | tz->tz_minuteswest = tz_winapi.Bias + ((rez==2)?tz_winapi.DaylightBias:0); 73 | } 74 | 75 | return 0; 76 | } 77 | 78 | inline int strcasecmp(const char *s1, const char *s2) 79 | { 80 | unsigned char c1,c2; 81 | do { 82 | c1 = *s1++; 83 | c2 = *s2++; 84 | c1 = (unsigned char) tolower( (unsigned char) c1); 85 | c2 = (unsigned char) tolower( (unsigned char) c2); 86 | } 87 | while((c1 == c2) && (c1 != '\0')); 88 | return (int) c1-c2; 89 | } 90 | 91 | inline int strncasecmp(const char *s1, const char *s2, size_t n) 92 | { 93 | if (n == 0) 94 | return 0; 95 | 96 | while (n-- != 0 && tolower(*s1) == tolower(*s2)) 97 | { 98 | if (n == 0 || *s1 == '\0' || *s2 == '\0') 99 | break; 100 | s1++; 101 | s2++; 102 | } 103 | 104 | return tolower(*(unsigned char *) s1) - tolower(*(unsigned char *) s2); 105 | } 106 | 107 | inline long double roundl(long double r) 108 | { 109 | return (r>0.0) ? floor(r+0.5f) : ceil(r-0.5); 110 | } 111 | 112 | #if (_MSC_VER < 1800) 113 | #define round (int)roundl 114 | inline long long int lround(double r) 115 | { 116 | return (r>0.0) ? floor(r+0.5f) : ceil(r-0.5); 117 | } 118 | #endif 119 | 120 | inline void* memmem (void* buf, size_t buflen, void* pat, size_t patlen) 121 | { 122 | void* end = (char *) buf+buflen-patlen; 123 | while (buf=memchr (buf, ((char *) pat) [0], buflen)) 124 | { 125 | if (buf> end) 126 | return 0; 127 | if (memcmp (buf, pat, patlen) == 0) 128 | return buf; 129 | buf = (char *) buf+1; 130 | } 131 | return 0; 132 | } 133 | 134 | #define usleep(x) Sleep((x)/1000) 135 | #define sleep(x) Sleep((x)*1000) 136 | 137 | #define __func__ __FUNCTION__ 138 | #define __attribute__(x) 139 | 140 | #endif /* _MSC_VER */ 141 | #endif /* WINBUILD_H */ 142 | -------------------------------------------------------------------------------- /algorithm.h: -------------------------------------------------------------------------------- 1 | #ifndef ALGORITHM_H 2 | #define ALGORITHM_H 3 | 4 | #ifdef __APPLE_CC__ 5 | #include 6 | #else 7 | #include 8 | #endif 9 | 10 | #include 11 | #include 12 | #include "ocl/build_kernel.h" // For the build_kernel_data type 13 | 14 | typedef enum { 15 | ALGO_UNK, 16 | ALGO_CRE, 17 | ALGO_SCRYPT, 18 | ALGO_NSCRYPT, 19 | ALGO_X11, 20 | ALGO_X11EVO, 21 | ALGO_X13, 22 | ALGO_X14, 23 | ALGO_X15, 24 | ALGO_X16R, 25 | ALGO_X16S, 26 | ALGO_KECCAK, 27 | ALGO_QUARK, 28 | ALGO_TWE, 29 | ALGO_FUGUE, 30 | ALGO_NIST, 31 | ALGO_FRESH, 32 | ALGO_WHIRL, 33 | ALGO_NEOSCRYPT, 34 | ALGO_WHIRLPOOLX, 35 | ALGO_LYRA2RE, 36 | ALGO_LYRA2REV2, 37 | ALGO_PLUCK, 38 | ALGO_YESCRYPT, 39 | ALGO_YESCRYPT_MULTI, 40 | ALGO_BLAKECOIN, 41 | ALGO_BLAKE, 42 | ALGO_VANILLA, 43 | ALGO_ETHASH, 44 | ALGO_CRYPTONIGHT, 45 | ALGO_EQUIHASH, 46 | ALGO_TIMETRAVEL10 47 | } algorithm_type_t; 48 | 49 | extern const char *algorithm_type_str[]; 50 | 51 | extern void sha256(const unsigned char *message, unsigned int len, unsigned char *digest); 52 | extern void gen_hash(const unsigned char *data, unsigned int len, unsigned char *hash); 53 | 54 | struct __clState; 55 | struct _dev_blk_ctx; 56 | struct _build_kernel_data; 57 | struct cgpu_info; 58 | struct work; 59 | 60 | /* Describes the Scrypt parameters and hashing functions used to mine 61 | * a specific coin. 62 | */ 63 | typedef struct _algorithm_t { 64 | char name[20]; /* Human-readable identifier */ 65 | algorithm_type_t type; //algorithm type 66 | const char *kernelfile; /* alternate kernel file */ 67 | uint32_t n; /* N (CPU/Memory tradeoff parameter) */ 68 | uint8_t nfactor; /* Factor of N above (n = 2^nfactor) */ 69 | double diff_multiplier1; 70 | double diff_multiplier2; 71 | double share_diff_multiplier; 72 | uint32_t xintensity_shift; 73 | uint32_t intensity_shift; 74 | uint32_t found_idx; 75 | unsigned long long diff_numerator; 76 | uint32_t diff1targ; 77 | size_t n_extra_kernels; 78 | long rw_buffer_size; 79 | cl_command_queue_properties cq_properties; 80 | void(*regenhash)(struct work *); 81 | void(*precalc_hash)(struct _dev_blk_ctx *, uint32_t *, uint32_t *); 82 | cl_int(*queue_kernel)(struct __clState *, struct _dev_blk_ctx *, cl_uint); 83 | void(*gen_hash)(const unsigned char *, unsigned int, unsigned char *); 84 | void(*set_compile_options)(struct _build_kernel_data *, struct cgpu_info *, struct _algorithm_t *); 85 | } algorithm_t; 86 | 87 | typedef struct _algorithm_settings_t 88 | { 89 | const char *name; 90 | algorithm_type_t type; 91 | const char *kernelfile; 92 | double diff_multiplier1; 93 | double diff_multiplier2; 94 | double share_diff_multiplier; 95 | uint32_t xintensity_shift; 96 | uint32_t intensity_shift; 97 | uint32_t found_idx; 98 | unsigned long long diff_numerator; 99 | uint32_t diff1targ; 100 | size_t n_extra_kernels; 101 | long rw_buffer_size; 102 | cl_command_queue_properties cq_properties; 103 | void (*regenhash)(struct work *); 104 | void (*precalc_hash)(struct _dev_blk_ctx *, uint32_t *, uint32_t *); 105 | cl_int (*queue_kernel)(struct __clState *, struct _dev_blk_ctx *, cl_uint); 106 | void (*gen_hash)(const unsigned char *, unsigned int, unsigned char *); 107 | void (*set_compile_options)(build_kernel_data *, struct cgpu_info *, algorithm_t *); 108 | } algorithm_settings_t; 109 | 110 | /* Set default parameters based on name. */ 111 | void set_algorithm(algorithm_t* algo, const char* name); 112 | 113 | /* Set to specific N factor. */ 114 | void set_algorithm_nfactor(algorithm_t* algo, const uint8_t nfactor); 115 | 116 | /* Compare two algorithm parameters */ 117 | bool cmp_algorithm(const algorithm_t* algo1, const algorithm_t* algo2); 118 | 119 | #endif /* ALGORITHM_H */ 120 | -------------------------------------------------------------------------------- /ccan/opt/parse.c: -------------------------------------------------------------------------------- 1 | /* Actual code to parse commandline. */ 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "private.h" 7 | 8 | /* glibc does this as: 9 | /tmp/opt-example: invalid option -- 'x' 10 | /tmp/opt-example: unrecognized option '--long' 11 | /tmp/opt-example: option '--someflag' doesn't allow an argument 12 | /tmp/opt-example: option '--s' is ambiguous 13 | /tmp/opt-example: option requires an argument -- 's' 14 | */ 15 | static int parse_err(void (*errlog)(const char *fmt, ...), 16 | const char *argv0, const char *arg, unsigned len, 17 | const char *problem) 18 | { 19 | errlog("%s: %.*s: %s", argv0, len, arg, problem); 20 | return -1; 21 | } 22 | 23 | static void consume_option(int *argc, char *argv[], unsigned optnum) 24 | { 25 | memmove(&argv[optnum], &argv[optnum+1], 26 | sizeof(argv[optnum]) * (*argc-optnum)); 27 | (*argc)--; 28 | } 29 | 30 | /* Returns 1 if argument consumed, 0 if all done, -1 on error. */ 31 | int parse_one(int *argc, char *argv[], unsigned *offset, 32 | void (*errlog)(const char *fmt, ...)) 33 | { 34 | unsigned i, arg, len; 35 | const char *o, *optarg = NULL; 36 | char *problem; 37 | 38 | if (getenv("POSIXLY_CORRECT")) { 39 | /* Don't find options after non-options. */ 40 | arg = 1; 41 | } else { 42 | for (arg = 1; argv[arg]; arg++) { 43 | if (argv[arg][0] == '-') 44 | break; 45 | } 46 | } 47 | 48 | if (!argv[arg] || argv[arg][0] != '-') 49 | return 0; 50 | 51 | /* Special arg terminator option. */ 52 | if (strcmp(argv[arg], "--") == 0) { 53 | consume_option(argc, argv, arg); 54 | return 0; 55 | } 56 | 57 | /* Long options start with -- */ 58 | if (argv[arg][1] == '-') { 59 | assert(*offset == 0); 60 | for (o = first_lopt(&i, &len); o; o = next_lopt(o, &i, &len)) { 61 | if (strncmp(argv[arg] + 2, o, len) != 0) 62 | continue; 63 | if (argv[arg][2 + len] == '=') 64 | optarg = argv[arg] + 2 + len + 1; 65 | else if (argv[arg][2 + len] != '\0') 66 | continue; 67 | break; 68 | } 69 | if (!o) 70 | return parse_err(errlog, argv[0], 71 | argv[arg], strlen(argv[arg]), 72 | "unrecognized option"); 73 | /* For error messages, we include the leading '--' */ 74 | o -= 2; 75 | len += 2; 76 | } else { 77 | /* offset allows us to handle -abc */ 78 | for (o = first_sopt(&i); o; o = next_sopt(o, &i)) { 79 | if (argv[arg][*offset + 1] != *o) 80 | continue; 81 | (*offset)++; 82 | break; 83 | } 84 | if (!o) 85 | return parse_err(errlog, argv[0], 86 | argv[arg], strlen(argv[arg]), 87 | "unrecognized option"); 88 | /* For error messages, we include the leading '-' */ 89 | o--; 90 | len = 2; 91 | } 92 | 93 | if (opt_table[i].type == OPT_NOARG) { 94 | if (optarg) 95 | return parse_err(errlog, argv[0], o, len, 96 | "doesn't allow an argument"); 97 | problem = opt_table[i].cb(opt_table[i].u.arg); 98 | } else { 99 | if (!optarg) { 100 | /* Swallow any short options as optarg, eg -afile */ 101 | if (*offset && argv[arg][*offset + 1]) { 102 | optarg = argv[arg] + *offset + 1; 103 | *offset = 0; 104 | } else 105 | optarg = argv[arg+1]; 106 | } 107 | if (!optarg) 108 | return parse_err(errlog, argv[0], o, len, 109 | "requires an argument"); 110 | problem = opt_table[i].cb_arg(optarg, opt_table[i].u.arg); 111 | } 112 | 113 | if (problem) { 114 | parse_err(errlog, argv[0], o, len, problem); 115 | free(problem); 116 | return -1; 117 | } 118 | 119 | /* If no more letters in that short opt, reset offset. */ 120 | if (*offset && !argv[arg][*offset + 1]) 121 | *offset = 0; 122 | 123 | /* All finished with that option? */ 124 | if (*offset == 0) { 125 | consume_option(argc, argv, arg); 126 | if (optarg && optarg == argv[arg]) 127 | consume_option(argc, argv, arg); 128 | } 129 | return 1; 130 | } 131 | -------------------------------------------------------------------------------- /bench_block.h: -------------------------------------------------------------------------------- 1 | #if !defined(__BENCH_BLOCK_H__) 2 | #define __BENCH_BLOCK_H__ 1 3 | 4 | // Random work pulled from a pool 5 | #define SGMINER_BENCHMARK_BLOCK \ 6 | 0x00, 0x00, 0x00, 0x01, 0x20, 0x00, 0xD8, 0x07, 0x17, 0xC9, 0x13, 0x6F, 0xDC, 0xBE, 0xDE, 0xB7, \ 7 | 0xB2, 0x14, 0xEF, 0xD1, 0x72, 0x7F, 0xA3, 0x72, 0xB2, 0x5D, 0x88, 0xF0, 0x00, 0x00, 0x05, 0xAA, \ 8 | 0x00, 0x00, 0x00, 0x00, 0x92, 0x8B, 0x4C, 0x77, 0xF5, 0xB2, 0xE6, 0x56, 0x96, 0x27, 0xE0, 0x66, \ 9 | 0x3C, 0x5B, 0xDD, 0xDC, 0x88, 0x6A, 0x7D, 0x7C, 0x7B, 0x8C, 0xE4, 0x92, 0x38, 0x92, 0x58, 0x2E, \ 10 | 0x18, 0x4D, 0x95, 0x9E, 0x4E, 0x44, 0xF1, 0x5F, 0x1A, 0x08, 0xE1, 0xE5, 0x00, 0x00, 0x00, 0x00, \ 11 | 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 12 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 13 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x02, 0x00, 0x00, \ 14 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 15 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 16 | 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 17 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, \ 18 | 0x86, 0x7E, 0x3A, 0xAF, 0x37, 0x83, 0xAF, 0xA0, 0xB5, 0x33, 0x2C, 0x28, 0xED, 0xA9, 0x89, 0x3E, \ 19 | 0x0A, 0xB6, 0x46, 0x81, 0xC2, 0x71, 0x4F, 0x34, 0x5A, 0x74, 0x89, 0x0E, 0x2B, 0x04, 0xB3, 0x16, \ 20 | 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \ 21 | 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, \ 22 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 23 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 24 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 25 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 26 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 27 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 28 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 29 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 30 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 31 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 32 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 33 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 34 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 35 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA0, 0xF6, 0x09, 0x02, 0x00, 0x00, 0x00, 0x00, \ 36 | 0x55, 0xF1, 0x44, 0x4E, 0x00, 0x00, 0x00, 0x00, 0x79, 0x63, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, \ 37 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 38 | 39 | #endif // !defined(__BENCH_BLOCK_H__) 40 | -------------------------------------------------------------------------------- /kernel/skein256.cl: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * skein256 kernel implementation. 4 | * 5 | * ==========================(LICENSE BEGIN)============================ 6 | * Copyright (c) 2014 djm34 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files (the 10 | * "Software"), to deal in the Software without restriction, including 11 | * without limitation the rights to use, copy, modify, merge, publish, 12 | * distribute, sublicense, and/or sell copies of the Software, and to 13 | * permit persons to whom the Software is furnished to do so, subject to 14 | * the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be 17 | * included in all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 22 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 23 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 25 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | * 27 | * ===========================(LICENSE END)============================= 28 | * 29 | * @author djm34 30 | */ 31 | 32 | 33 | __constant static const sph_u64 SKEIN_IV512[] = { 34 | SPH_C64(0x4903ADFF749C51CE), SPH_C64(0x0D95DE399746DF03), 35 | SPH_C64(0x8FD1934127C79BCE), SPH_C64(0x9A255629FF352CB1), 36 | SPH_C64(0x5DB62599DF6CA7B0), SPH_C64(0xEABE394CA9D5C3F4), 37 | SPH_C64(0x991112C71A75B523), SPH_C64(0xAE18A40B660FCC33) 38 | }; 39 | 40 | __constant static const sph_u64 SKEIN_IV512_256[8] = { 41 | 0xCCD044A12FDB3E13UL, 0xE83590301A79A9EBUL, 42 | 0x55AEA0614F816E6FUL, 0x2A2767A4AE9B94DBUL, 43 | 0xEC06025E74DD7683UL, 0xE7A436CDC4746251UL, 44 | 0xC36FBAF9393AD185UL, 0x3EEDBA1833EDFC13UL 45 | }; 46 | 47 | 48 | 49 | __constant static const int ROT256[8][4] = 50 | { 51 | 46, 36, 19, 37, 52 | 33, 27, 14, 42, 53 | 17, 49, 36, 39, 54 | 44, 9, 54, 56, 55 | 39, 30, 34, 24, 56 | 13, 50, 10, 17, 57 | 25, 29, 39, 43, 58 | 8, 35, 56, 22, 59 | }; 60 | 61 | __constant static const sph_u64 skein_ks_parity = 0x1BD11BDAA9FC1A22; 62 | 63 | __constant static const sph_u64 t12[6] = 64 | { 0x20UL, 65 | 0xf000000000000000UL, 66 | 0xf000000000000020UL, 67 | 0x08UL, 68 | 0xff00000000000000UL, 69 | 0xff00000000000008UL 70 | }; 71 | 72 | 73 | #define Round512(p0,p1,p2,p3,p4,p5,p6,p7,ROT) { \ 74 | p0 += p1; p1 = SPH_ROTL64(p1, ROT256[ROT][0]); p1 ^= p0; \ 75 | p2 += p3; p3 = SPH_ROTL64(p3, ROT256[ROT][1]); p3 ^= p2; \ 76 | p4 += p5; p5 = SPH_ROTL64(p5, ROT256[ROT][2]); p5 ^= p4; \ 77 | p6 += p7; p7 = SPH_ROTL64(p7, ROT256[ROT][3]); p7 ^= p6; \ 78 | } 79 | 80 | #define Round_8_512(p0, p1, p2, p3, p4, p5, p6, p7, R) { \ 81 | Round512(p0, p1, p2, p3, p4, p5, p6, p7, 0); \ 82 | Round512(p2, p1, p4, p7, p6, p5, p0, p3, 1); \ 83 | Round512(p4, p1, p6, p3, p0, p5, p2, p7, 2); \ 84 | Round512(p6, p1, p0, p7, p2, p5, p4, p3, 3); \ 85 | p0 += h[((R)+0) % 9]; \ 86 | p1 += h[((R)+1) % 9]; \ 87 | p2 += h[((R)+2) % 9]; \ 88 | p3 += h[((R)+3) % 9]; \ 89 | p4 += h[((R)+4) % 9]; \ 90 | p5 += h[((R)+5) % 9] + t[((R)+0) % 3]; \ 91 | p6 += h[((R)+6) % 9] + t[((R)+1) % 3]; \ 92 | p7 += h[((R)+7) % 9] + R; \ 93 | Round512(p0, p1, p2, p3, p4, p5, p6, p7, 4); \ 94 | Round512(p2, p1, p4, p7, p6, p5, p0, p3, 5); \ 95 | Round512(p4, p1, p6, p3, p0, p5, p2, p7, 6); \ 96 | Round512(p6, p1, p0, p7, p2, p5, p4, p3, 7); \ 97 | p0 += h[((R)+1) % 9]; \ 98 | p1 += h[((R)+2) % 9]; \ 99 | p2 += h[((R)+3) % 9]; \ 100 | p3 += h[((R)+4) % 9]; \ 101 | p4 += h[((R)+5) % 9]; \ 102 | p5 += h[((R)+6) % 9] + t[((R)+1) % 3]; \ 103 | p6 += h[((R)+7) % 9] + t[((R)+2) % 3]; \ 104 | p7 += h[((R)+8) % 9] + (R+1); \ 105 | } -------------------------------------------------------------------------------- /API.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (C) Andrew Smith 2012-2013 4 | * 5 | * Usage: java API command ip port 6 | * 7 | * If any are missing or blank they use the defaults: 8 | * 9 | * command = 'summary' 10 | * ip = '127.0.0.1' 11 | * port = '4028' 12 | * 13 | */ 14 | 15 | import java.net.*; 16 | import java.io.*; 17 | 18 | class API 19 | { 20 | static private final int MAXRECEIVESIZE = 65535; 21 | 22 | static private Socket socket = null; 23 | 24 | private void closeAll() throws Exception 25 | { 26 | if (socket != null) 27 | { 28 | socket.close(); 29 | socket = null; 30 | } 31 | } 32 | 33 | public void display(String result) throws Exception 34 | { 35 | String value; 36 | String name; 37 | String[] sections = result.split("\\|", 0); 38 | 39 | for (int i = 0; i < sections.length; i++) 40 | { 41 | if (sections[i].trim().length() > 0) 42 | { 43 | String[] data = sections[i].split(",", 0); 44 | 45 | for (int j = 0; j < data.length; j++) 46 | { 47 | String[] nameval = data[j].split("=", 2); 48 | 49 | if (j == 0) 50 | { 51 | if (nameval.length > 1 52 | && Character.isDigit(nameval[1].charAt(0))) 53 | name = nameval[0] + nameval[1]; 54 | else 55 | name = nameval[0]; 56 | 57 | System.out.println("[" + name + "] =>"); 58 | System.out.println("("); 59 | } 60 | 61 | if (nameval.length > 1) 62 | { 63 | name = nameval[0]; 64 | value = nameval[1]; 65 | } 66 | else 67 | { 68 | name = "" + j; 69 | value = nameval[0]; 70 | } 71 | 72 | System.out.println(" ["+name+"] => "+value); 73 | } 74 | System.out.println(")"); 75 | } 76 | } 77 | } 78 | 79 | public void process(String cmd, InetAddress ip, int port) throws Exception 80 | { 81 | StringBuffer sb = new StringBuffer(); 82 | char buf[] = new char[MAXRECEIVESIZE]; 83 | int len = 0; 84 | 85 | System.out.println("Attempting to send '"+cmd+"' to "+ip.getHostAddress()+":"+port); 86 | 87 | try 88 | { 89 | socket = new Socket(ip, port); 90 | PrintStream ps = new PrintStream(socket.getOutputStream()); 91 | ps.print(cmd.toLowerCase().toCharArray()); 92 | ps.flush(); 93 | 94 | InputStreamReader isr = new InputStreamReader(socket.getInputStream()); 95 | while (0x80085 > 0) 96 | { 97 | len = isr.read(buf, 0, MAXRECEIVESIZE); 98 | if (len < 1) 99 | break; 100 | sb.append(buf, 0, len); 101 | if (buf[len-1] == '\0') 102 | break; 103 | } 104 | 105 | closeAll(); 106 | } 107 | catch (IOException ioe) 108 | { 109 | System.err.println(ioe.toString()); 110 | closeAll(); 111 | return; 112 | } 113 | 114 | String result = sb.toString(); 115 | 116 | System.out.println("Answer='"+result+"'"); 117 | 118 | display(result); 119 | } 120 | 121 | public API(String command, String _ip, String _port) throws Exception 122 | { 123 | InetAddress ip; 124 | int port; 125 | 126 | try 127 | { 128 | ip = InetAddress.getByName(_ip); 129 | } 130 | catch (UnknownHostException uhe) 131 | { 132 | System.err.println("Unknown host " + _ip + ": " + uhe); 133 | return; 134 | } 135 | 136 | try 137 | { 138 | port = Integer.parseInt(_port); 139 | } 140 | catch (NumberFormatException nfe) 141 | { 142 | System.err.println("Invalid port " + _port + ": " + nfe); 143 | return; 144 | } 145 | 146 | process(command, ip, port); 147 | } 148 | 149 | public static void main(String[] params) throws Exception 150 | { 151 | String command = "summary"; 152 | String ip = "127.0.0.1"; 153 | String port = "4028"; 154 | 155 | if (params.length > 0 && params[0].trim().length() > 0) 156 | command = params[0].trim(); 157 | 158 | if (params.length > 1 && params[1].trim().length() > 0) 159 | ip = params[1].trim(); 160 | 161 | if (params.length > 2 && params[2].trim().length() > 0) 162 | port = params[2].trim(); 163 | 164 | new API(command, ip, port); 165 | } 166 | } 167 | -------------------------------------------------------------------------------- /ccan/opt/test/run-usage.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "utils.h" 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | static char *my_cb(void *p) 13 | { 14 | return NULL; 15 | } 16 | 17 | static void reset_options(void) 18 | { 19 | free(opt_table); 20 | opt_table = NULL; 21 | opt_count = opt_num_short = opt_num_short_arg = opt_num_long = 0; 22 | } 23 | 24 | /* Test helpers. */ 25 | int main(int argc, char *argv[]) 26 | { 27 | char *output; 28 | char *longname = strdup("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); 29 | char *shortname = strdup("shortname"); 30 | 31 | plan_tests(48); 32 | opt_register_table(subtables, NULL); 33 | opt_register_noarg("--kkk|-k", my_cb, NULL, "magic kkk option"); 34 | opt_register_noarg("-?", opt_usage_and_exit, "...", 35 | "This message"); 36 | opt_register_arg("--longname", opt_set_charp, opt_show_charp, 37 | &longname, "a really long option default"); 38 | opt_register_arg("--shortname", opt_set_charp, opt_show_charp, 39 | &shortname, "a short option default"); 40 | output = opt_usage("my name", "ExTrA Args"); 41 | diag("%s", output); 42 | ok1(strstr(output, "Usage: my name")); 43 | ok1(strstr(output, "--jjj|-j|--lll|-l ")); 44 | ok1(strstr(output, "ExTrA Args")); 45 | ok1(strstr(output, "-a ")); 46 | ok1(strstr(output, " Description of a\n")); 47 | ok1(strstr(output, "-b ")); 48 | ok1(strstr(output, " Description of b (default: b)\n")); 49 | ok1(strstr(output, "--ddd ")); 50 | ok1(strstr(output, " Description of ddd\n")); 51 | ok1(strstr(output, "--eee ")); 52 | ok1(strstr(output, " (default: eee)\n")); 53 | ok1(strstr(output, "long table options:\n")); 54 | ok1(strstr(output, "--ggg|-g ")); 55 | ok1(strstr(output, " Description of ggg\n")); 56 | ok1(strstr(output, "-h|--hhh ")); 57 | ok1(strstr(output, " Description of hhh\n")); 58 | ok1(strstr(output, "--kkk|-k")); 59 | ok1(strstr(output, "magic kkk option")); 60 | /* This entry is hidden. */ 61 | ok1(!strstr(output, "--mmm|-m")); 62 | free(output); 63 | 64 | /* NULL should use string from registered options. */ 65 | output = opt_usage("my name", NULL); 66 | diag("%s", output); 67 | ok1(strstr(output, "Usage: my name")); 68 | ok1(strstr(output, "--jjj|-j|--lll|-l ")); 69 | ok1(strstr(output, "...")); 70 | ok1(strstr(output, "-a ")); 71 | ok1(strstr(output, " Description of a\n")); 72 | ok1(strstr(output, "-b ")); 73 | ok1(strstr(output, " Description of b (default: b)\n")); 74 | ok1(strstr(output, "--ddd ")); 75 | ok1(strstr(output, " Description of ddd\n")); 76 | ok1(strstr(output, "--eee ")); 77 | ok1(strstr(output, " (default: eee)\n")); 78 | ok1(strstr(output, "long table options:\n")); 79 | ok1(strstr(output, "--ggg|-g ")); 80 | ok1(strstr(output, " Description of ggg\n")); 81 | ok1(strstr(output, "-h|--hhh ")); 82 | ok1(strstr(output, " Description of hhh\n")); 83 | ok1(strstr(output, "--kkk|-k")); 84 | ok1(strstr(output, "magic kkk option")); 85 | ok1(strstr(output, "--longname")); 86 | ok1(strstr(output, "a really long option default")); 87 | ok1(strstr(output, "(default: \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"...)")); 88 | ok1(strstr(output, "--shortname")); 89 | ok1(strstr(output, "a short option default")); 90 | ok1(strstr(output, "(default: \"shortname\")")); 91 | /* This entry is hidden. */ 92 | ok1(!strstr(output, "--mmm|-m")); 93 | free(output); 94 | 95 | reset_options(); 96 | /* Empty table test. */ 97 | output = opt_usage("nothing", NULL); 98 | ok1(strstr(output, "Usage: nothing \n")); 99 | free(output); 100 | 101 | /* No short args. */ 102 | opt_register_noarg("--aaa", test_noarg, NULL, "AAAAll"); 103 | output = opt_usage("onearg", NULL); 104 | ok1(strstr(output, "Usage: onearg \n")); 105 | ok1(strstr(output, "--aaa")); 106 | ok1(strstr(output, "AAAAll")); 107 | free(output); 108 | 109 | free(shortname); 110 | free(longname); 111 | return exit_status(); 112 | } 113 | -------------------------------------------------------------------------------- /m4/onceonly.m4: -------------------------------------------------------------------------------- 1 | # onceonly.m4 serial 7 2 | dnl Copyright (C) 2002-2003, 2005-2006, 2008-2011 Free Software Foundation, 3 | dnl Inc. 4 | dnl This file is free software, distributed under the terms of the GNU 5 | dnl General Public License. As a special exception to the GNU General 6 | dnl Public License, this file may be distributed as part of a program 7 | dnl that contains a configuration script generated by Autoconf, under 8 | dnl the same distribution terms as the rest of that program. 9 | 10 | dnl This file defines some "once only" variants of standard autoconf macros. 11 | dnl AC_CHECK_HEADERS_ONCE like AC_CHECK_HEADERS 12 | dnl AC_CHECK_FUNCS_ONCE like AC_CHECK_FUNCS 13 | dnl AC_CHECK_DECLS_ONCE like AC_CHECK_DECLS 14 | dnl AC_REQUIRE([AC_FUNC_STRCOLL]) like AC_FUNC_STRCOLL 15 | dnl The advantage is that the check for each of the headers/functions/decls 16 | dnl will be put only once into the 'configure' file. It keeps the size of 17 | dnl the 'configure' file down, and avoids redundant output when 'configure' 18 | dnl is run. 19 | dnl The drawback is that the checks cannot be conditionalized. If you write 20 | dnl if some_condition; then gl_CHECK_HEADERS(stdlib.h); fi 21 | dnl inside an AC_DEFUNed function, the gl_CHECK_HEADERS macro call expands to 22 | dnl empty, and the check will be inserted before the body of the AC_DEFUNed 23 | dnl function. 24 | 25 | dnl The original code implemented AC_CHECK_HEADERS_ONCE and AC_CHECK_FUNCS_ONCE 26 | dnl in terms of AC_DEFUN and AC_REQUIRE. This implementation uses diversions to 27 | dnl named sections DEFAULTS and INIT_PREPARE in order to check all requested 28 | dnl headers at once, thus reducing the size of 'configure'. It is known to work 29 | dnl with autoconf 2.57..2.62 at least . The size reduction is ca. 9%. 30 | 31 | dnl Autoconf version 2.59 plus gnulib is required; this file is not needed 32 | dnl with Autoconf 2.60 or greater. But note that autoconf's implementation of 33 | dnl AC_CHECK_DECLS_ONCE expects a comma-separated list of symbols as first 34 | dnl argument! 35 | AC_PREREQ([2.59]) 36 | 37 | # AC_CHECK_HEADERS_ONCE(HEADER1 HEADER2 ...) is a once-only variant of 38 | # AC_CHECK_HEADERS(HEADER1 HEADER2 ...). 39 | AC_DEFUN([AC_CHECK_HEADERS_ONCE], [ 40 | : 41 | m4_foreach_w([gl_HEADER_NAME], [$1], [ 42 | AC_DEFUN([gl_CHECK_HEADER_]m4_quote(m4_translit(gl_HEADER_NAME, 43 | [./-], [___])), [ 44 | m4_divert_text([INIT_PREPARE], 45 | [gl_header_list="$gl_header_list gl_HEADER_NAME"]) 46 | gl_HEADERS_EXPANSION 47 | AH_TEMPLATE(AS_TR_CPP([HAVE_]m4_defn([gl_HEADER_NAME])), 48 | [Define to 1 if you have the <]m4_defn([gl_HEADER_NAME])[> header file.]) 49 | ]) 50 | AC_REQUIRE([gl_CHECK_HEADER_]m4_quote(m4_translit(gl_HEADER_NAME, 51 | [./-], [___]))) 52 | ]) 53 | ]) 54 | m4_define([gl_HEADERS_EXPANSION], [ 55 | m4_divert_text([DEFAULTS], [gl_header_list=]) 56 | AC_CHECK_HEADERS([$gl_header_list]) 57 | m4_define([gl_HEADERS_EXPANSION], []) 58 | ]) 59 | 60 | # AC_CHECK_FUNCS_ONCE(FUNC1 FUNC2 ...) is a once-only variant of 61 | # AC_CHECK_FUNCS(FUNC1 FUNC2 ...). 62 | AC_DEFUN([AC_CHECK_FUNCS_ONCE], [ 63 | : 64 | m4_foreach_w([gl_FUNC_NAME], [$1], [ 65 | AC_DEFUN([gl_CHECK_FUNC_]m4_defn([gl_FUNC_NAME]), [ 66 | m4_divert_text([INIT_PREPARE], 67 | [gl_func_list="$gl_func_list gl_FUNC_NAME"]) 68 | gl_FUNCS_EXPANSION 69 | AH_TEMPLATE(AS_TR_CPP([HAVE_]m4_defn([gl_FUNC_NAME])), 70 | [Define to 1 if you have the `]m4_defn([gl_FUNC_NAME])[' function.]) 71 | ]) 72 | AC_REQUIRE([gl_CHECK_FUNC_]m4_defn([gl_FUNC_NAME])) 73 | ]) 74 | ]) 75 | m4_define([gl_FUNCS_EXPANSION], [ 76 | m4_divert_text([DEFAULTS], [gl_func_list=]) 77 | AC_CHECK_FUNCS([$gl_func_list]) 78 | m4_define([gl_FUNCS_EXPANSION], []) 79 | ]) 80 | 81 | # AC_CHECK_DECLS_ONCE(DECL1 DECL2 ...) is a once-only variant of 82 | # AC_CHECK_DECLS(DECL1, DECL2, ...). 83 | AC_DEFUN([AC_CHECK_DECLS_ONCE], [ 84 | : 85 | m4_foreach_w([gl_DECL_NAME], [$1], [ 86 | AC_DEFUN([gl_CHECK_DECL_]m4_defn([gl_DECL_NAME]), [ 87 | AC_CHECK_DECLS(m4_defn([gl_DECL_NAME])) 88 | ]) 89 | AC_REQUIRE([gl_CHECK_DECL_]m4_defn([gl_DECL_NAME])) 90 | ]) 91 | ]) 92 | -------------------------------------------------------------------------------- /kernel/x11evo/x11evo_simd.cl: -------------------------------------------------------------------------------- 1 | 2 | // simd 3 | { 4 | s32 q[256]; 5 | unsigned char x[128]; 6 | for (unsigned int i = 0; i < 64; i++) 7 | x[i] = hash.h1[i]; 8 | for (unsigned int i = 64; i < 128; i++) 9 | x[i] = 0; 10 | 11 | u32 A0 = C32(0x0BA16B95), A1 = C32(0x72F999AD), A2 = C32(0x9FECC2AE), A3 = C32(0xBA3264FC), A4 = C32(0x5E894929), A5 = C32(0x8E9F30E5), A6 = C32(0x2F1DAA37), A7 = C32(0xF0F2C558); 12 | u32 B0 = C32(0xAC506643), B1 = C32(0xA90635A5), B2 = C32(0xE25B878B), B3 = C32(0xAAB7878F), B4 = C32(0x88817F7A), B5 = C32(0x0A02892B), B6 = C32(0x559A7550), B7 = C32(0x598F657E); 13 | u32 C0 = C32(0x7EEF60A1), C1 = C32(0x6B70E3E8), C2 = C32(0x9C1714D1), C3 = C32(0xB958E2A8), C4 = C32(0xAB02675E), C5 = C32(0xED1C014F), C6 = C32(0xCD8D65BB), C7 = C32(0xFDB7A257); 14 | u32 D0 = C32(0x09254899), D1 = C32(0xD699C7BC), D2 = C32(0x9019B6DC), D3 = C32(0x2B9022E4), D4 = C32(0x8FA14956), D5 = C32(0x21BF9BD3), D6 = C32(0xB94D0943), D7 = C32(0x6FFDDC22); 15 | 16 | FFT256(0, 1, 0, ll1); 17 | for (int i = 0; i < 256; i++) { 18 | s32 tq; 19 | 20 | tq = q[i] + yoff_b_n[i]; 21 | tq = REDS2(tq); 22 | tq = REDS1(tq); 23 | tq = REDS1(tq); 24 | q[i] = (tq <= 128 ? tq : tq - 257); 25 | } 26 | 27 | A0 ^= hash.h4[0]; 28 | A1 ^= hash.h4[1]; 29 | A2 ^= hash.h4[2]; 30 | A3 ^= hash.h4[3]; 31 | A4 ^= hash.h4[4]; 32 | A5 ^= hash.h4[5]; 33 | A6 ^= hash.h4[6]; 34 | A7 ^= hash.h4[7]; 35 | B0 ^= hash.h4[8]; 36 | B1 ^= hash.h4[9]; 37 | B2 ^= hash.h4[10]; 38 | B3 ^= hash.h4[11]; 39 | B4 ^= hash.h4[12]; 40 | B5 ^= hash.h4[13]; 41 | B6 ^= hash.h4[14]; 42 | B7 ^= hash.h4[15]; 43 | 44 | ONE_ROUND_BIG(0_, 0, 3, 23, 17, 27); 45 | ONE_ROUND_BIG(1_, 1, 28, 19, 22, 7); 46 | ONE_ROUND_BIG(2_, 2, 29, 9, 15, 5); 47 | ONE_ROUND_BIG(3_, 3, 4, 13, 10, 25); 48 | 49 | STEP_BIG( 50 | C32(0x0BA16B95), C32(0x72F999AD), C32(0x9FECC2AE), C32(0xBA3264FC), 51 | C32(0x5E894929), C32(0x8E9F30E5), C32(0x2F1DAA37), C32(0xF0F2C558), 52 | IF, 4, 13, PP8_4_); 53 | STEP_BIG( 54 | C32(0xAC506643), C32(0xA90635A5), C32(0xE25B878B), C32(0xAAB7878F), 55 | C32(0x88817F7A), C32(0x0A02892B), C32(0x559A7550), C32(0x598F657E), 56 | IF, 13, 10, PP8_5_); 57 | STEP_BIG( 58 | C32(0x7EEF60A1), C32(0x6B70E3E8), C32(0x9C1714D1), C32(0xB958E2A8), 59 | C32(0xAB02675E), C32(0xED1C014F), C32(0xCD8D65BB), C32(0xFDB7A257), 60 | IF, 10, 25, PP8_6_); 61 | STEP_BIG( 62 | C32(0x09254899), C32(0xD699C7BC), C32(0x9019B6DC), C32(0x2B9022E4), 63 | C32(0x8FA14956), C32(0x21BF9BD3), C32(0xB94D0943), C32(0x6FFDDC22), 64 | IF, 25, 4, PP8_0_); 65 | 66 | u32 COPY_A0 = A0, COPY_A1 = A1, COPY_A2 = A2, COPY_A3 = A3, COPY_A4 = A4, COPY_A5 = A5, COPY_A6 = A6, COPY_A7 = A7; 67 | u32 COPY_B0 = B0, COPY_B1 = B1, COPY_B2 = B2, COPY_B3 = B3, COPY_B4 = B4, COPY_B5 = B5, COPY_B6 = B6, COPY_B7 = B7; 68 | u32 COPY_C0 = C0, COPY_C1 = C1, COPY_C2 = C2, COPY_C3 = C3, COPY_C4 = C4, COPY_C5 = C5, COPY_C6 = C6, COPY_C7 = C7; 69 | u32 COPY_D0 = D0, COPY_D1 = D1, COPY_D2 = D2, COPY_D3 = D3, COPY_D4 = D4, COPY_D5 = D5, COPY_D6 = D6, COPY_D7 = D7; 70 | 71 | #define q SIMD_Q 72 | 73 | A0 ^= 0x200; 74 | 75 | ONE_ROUND_BIG(0_, 0, 3, 23, 17, 27); 76 | ONE_ROUND_BIG(1_, 1, 28, 19, 22, 7); 77 | ONE_ROUND_BIG(2_, 2, 29, 9, 15, 5); 78 | ONE_ROUND_BIG(3_, 3, 4, 13, 10, 25); 79 | STEP_BIG( 80 | COPY_A0, COPY_A1, COPY_A2, COPY_A3, 81 | COPY_A4, COPY_A5, COPY_A6, COPY_A7, 82 | IF, 4, 13, PP8_4_); 83 | STEP_BIG( 84 | COPY_B0, COPY_B1, COPY_B2, COPY_B3, 85 | COPY_B4, COPY_B5, COPY_B6, COPY_B7, 86 | IF, 13, 10, PP8_5_); 87 | STEP_BIG( 88 | COPY_C0, COPY_C1, COPY_C2, COPY_C3, 89 | COPY_C4, COPY_C5, COPY_C6, COPY_C7, 90 | IF, 10, 25, PP8_6_); 91 | STEP_BIG( 92 | COPY_D0, COPY_D1, COPY_D2, COPY_D3, 93 | COPY_D4, COPY_D5, COPY_D6, COPY_D7, 94 | IF, 25, 4, PP8_0_); 95 | #undef q 96 | 97 | hash.h4[0] = A0; 98 | hash.h4[1] = A1; 99 | hash.h4[2] = A2; 100 | hash.h4[3] = A3; 101 | hash.h4[4] = A4; 102 | hash.h4[5] = A5; 103 | hash.h4[6] = A6; 104 | hash.h4[7] = A7; 105 | hash.h4[8] = B0; 106 | hash.h4[9] = B1; 107 | hash.h4[10] = B2; 108 | hash.h4[11] = B3; 109 | hash.h4[12] = B4; 110 | hash.h4[13] = B5; 111 | hash.h4[14] = B6; 112 | hash.h4[15] = B7; 113 | 114 | } 115 | --------------------------------------------------------------------------------