Benjamin Wilson 9bc0671563
Ultra (#15)
Pull BM1366 work into main
2023-08-20 13:09:55 -04:00

34 lines
745 B
C

#ifndef COMMON_H_
#define COMMON_H_
typedef struct __attribute__((__packed__)) {
uint8_t job_id;
uint32_t nonce;
uint32_t rolled_version;
} task_result;
static unsigned char _reverse_bits(unsigned char num) {
unsigned char reversed = 0;
int i;
for (i = 0; i < 8; i++) {
reversed <<= 1; // Left shift the reversed variable by 1
reversed |= num & 1; // Use bitwise OR to set the rightmost bit of reversed to the current bit of num
num >>= 1; // Right shift num by 1 to get the next bit
}
return reversed;
}
static int _largest_power_of_two(int num) {
int power = 0;
while (num > 1) {
num = num >> 1;
power++;
}
return 1 << power;
}
#endif