miner.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. #ifdef __SSE2__
  8. #define WANT_SSE2_4WAY 1
  9. #endif
  10. #if defined(__i386__) || defined(__x86_64__)
  11. #define WANT_VIA_PADLOCK 1
  12. #endif
  13. #if defined(__i386__)
  14. #define WANT_CRYPTOPP_ASM32
  15. #endif
  16. #ifndef ARRAY_SIZE
  17. #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
  18. #endif
  19. #define ___constant_swab32(x) ((uint32_t)( \
  20. (((uint32_t)(x) & (uint32_t)0x000000ffUL) << 24) | \
  21. (((uint32_t)(x) & (uint32_t)0x0000ff00UL) << 8) | \
  22. (((uint32_t)(x) & (uint32_t)0x00ff0000UL) >> 8) | \
  23. (((uint32_t)(x) & (uint32_t)0xff000000UL) >> 24)))
  24. static inline uint32_t swab32(uint32_t v)
  25. {
  26. return ___constant_swab32(v);
  27. }
  28. extern bool opt_debug;
  29. extern bool opt_protocol;
  30. extern const uint32_t sha256_init_state[];
  31. extern json_t *json_rpc_call(const char *url, const char *userpass,
  32. const char *rpc_req);
  33. extern char *bin2hex(unsigned char *p, size_t len);
  34. extern bool hex2bin(unsigned char *p, const char *hexstr, size_t len);
  35. extern unsigned int ScanHash_4WaySSE2(const unsigned char *pmidstate,
  36. unsigned char *pdata, unsigned char *phash1, unsigned char *phash,
  37. unsigned long *nHashesDone);
  38. extern bool scanhash_via(unsigned char *data_inout, unsigned long *hashes_done);
  39. extern bool scanhash_c(const unsigned char *midstate, unsigned char *data,
  40. unsigned char *hash1, unsigned char *hash,
  41. unsigned long *hashes_done);
  42. extern bool scanhash_cryptopp(const unsigned char *midstate,unsigned char *data,
  43. unsigned char *hash1, unsigned char *hash,
  44. unsigned long *hashes_done);
  45. extern bool scanhash_asm32(const unsigned char *midstate,unsigned char *data,
  46. unsigned char *hash1, unsigned char *hash,
  47. unsigned long *hashes_done);
  48. extern int
  49. timeval_subtract (struct timeval *result, struct timeval *x, struct timeval *y);
  50. #endif /* __MINER_H__ */