Browse Source

Provide endian_flipX functions to avoid special casing big endian in cgminer.c

nfactor-troky
Con Kolivas 12 years ago
parent
commit
4597c0a17e
  1. 8
      cgminer.c
  2. 23
      miner.h

8
cgminer.c

@ -1481,9 +1481,7 @@ static void calc_midstate(struct work *work)
sha2_starts(&ctx); sha2_starts(&ctx);
sha2_update(&ctx, data, 64); sha2_update(&ctx, data, 64);
memcpy(work->midstate, ctx.state, 32); memcpy(work->midstate, ctx.state, 32);
#if defined(__BIG_ENDIAN__) || defined(MIPSEB) endian_flip32(work->midstate, work->midstate);
flip32(work->midstate, work->midstate);
#endif
} }
static struct work *make_work(void) static struct work *make_work(void)
@ -2439,9 +2437,7 @@ static bool submit_upstream_work(struct work *work, CURL *curl, bool resubmit)
cgpu = get_thr_cgpu(thr_id); cgpu = get_thr_cgpu(thr_id);
#ifdef __BIG_ENDIAN__ endian_flip128(work->data, work->data);
flip128(work->data, work->data);
#endif
/* build hex string */ /* build hex string */
hexstr = bin2hex(work->data, sizeof(work->data)); hexstr = bin2hex(work->data, sizeof(work->data));

23
miner.h

@ -670,6 +670,29 @@ static inline void flip128(void *dest_p, const void *src_p)
dest[i] = swab32(src[i]); dest[i] = swab32(src[i]);
} }
/* For flipping to the correct endianness if necessary */
#if defined(__BIG_ENDIAN__) || defined(MIPSEB)
static inline void endian_flip32(void *dest_p, const void *src_p)
{
flip32(dest_p, src_p);
}
static inline void endian_flip128(void *dest_p, const void *src_p)
{
flip128(dest_p, src_p);
}
#else
static inline void
endian_flip32(void __maybe_unused *dest_p, const void __maybe_unused *src_p)
{
}
static inline void
endian_flip128(void __maybe_unused *dest_p, const void __maybe_unused *src_p)
{
}
#endif
extern void quit(int status, const char *format, ...); extern void quit(int status, const char *format, ...);
static inline void mutex_lock(pthread_mutex_t *lock) static inline void mutex_lock(pthread_mutex_t *lock)

Loading…
Cancel
Save