miner.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #ifndef __MINER_H__
  2. #define __MINER_H__
  3. #include <stdbool.h>
  4. #include <stdint.h>
  5. #include <sys/time.h>
  6. #include <jansson.h>
  7. #include <curl/curl.h>
  8. #ifdef __SSE2__
  9. #define WANT_SSE2_4WAY 1
  10. #endif
  11. #if defined(__i386__) || defined(__x86_64__)
  12. #define WANT_VIA_PADLOCK 1
  13. #endif
  14. #if defined(__i386__)
  15. #define WANT_CRYPTOPP_ASM32
  16. #endif
  17. #ifndef ARRAY_SIZE
  18. #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
  19. #endif
  20. static inline uint32_t swab32(uint32_t v)
  21. {
  22. return __builtin_bswap32(v);
  23. }
  24. static inline void swap256(void *dest_p, const void *src_p)
  25. {
  26. uint32_t *dest = dest_p;
  27. const uint32_t *src = src_p;
  28. dest[0] = src[7];
  29. dest[1] = src[6];
  30. dest[2] = src[5];
  31. dest[3] = src[4];
  32. dest[4] = src[3];
  33. dest[5] = src[2];
  34. dest[6] = src[1];
  35. dest[7] = src[0];
  36. }
  37. extern bool opt_debug;
  38. extern bool opt_protocol;
  39. extern const uint32_t sha256_init_state[];
  40. extern json_t *json_rpc_call(CURL *curl, const char *url, const char *userpass,
  41. const char *rpc_req);
  42. extern char *bin2hex(unsigned char *p, size_t len);
  43. extern bool hex2bin(unsigned char *p, const char *hexstr, size_t len);
  44. extern unsigned int ScanHash_4WaySSE2(const unsigned char *pmidstate,
  45. unsigned char *pdata, unsigned char *phash1, unsigned char *phash,
  46. const unsigned char *ptarget,
  47. uint32_t max_nonce, unsigned long *nHashesDone);
  48. extern bool scanhash_via(unsigned char *data_inout,
  49. const unsigned char *target,
  50. uint32_t max_nonce, unsigned long *hashes_done);
  51. extern bool scanhash_c(const unsigned char *midstate, unsigned char *data,
  52. unsigned char *hash1, unsigned char *hash,
  53. const unsigned char *target,
  54. uint32_t max_nonce, unsigned long *hashes_done);
  55. extern bool scanhash_cryptopp(const unsigned char *midstate,unsigned char *data,
  56. unsigned char *hash1, unsigned char *hash,
  57. const unsigned char *target,
  58. uint32_t max_nonce, unsigned long *hashes_done);
  59. extern bool scanhash_asm32(const unsigned char *midstate,unsigned char *data,
  60. unsigned char *hash1, unsigned char *hash,
  61. const unsigned char *target,
  62. uint32_t max_nonce, unsigned long *hashes_done);
  63. extern int
  64. timeval_subtract (struct timeval *result, struct timeval *x, struct timeval *y);
  65. extern bool fulltest(const unsigned char *hash, const unsigned char *target);
  66. #endif /* __MINER_H__ */