Kon,
I see you are making some speed optimizations to cgminer constantly. Here are two commonly used functions (utils.c) which are speeding things up. I am running them for a week with latest cgminer git on openwrt host and i386 just fine.
Adopted from:
http://www.autohotkey.com/board/topic/19483-machine-code-functions-bit-wizardry/page-8Thanks to Laszlo
bool hex2bin(unsigned char *p, const char *hexstr, size_t len)
{
bool ret = false;
unsigned char b, c, d;
for(;
{
c = *hexstr++; if (c == 0) break;
b = c >> 6;
*p = ((c & 15) + b + (b << 3)) << 4;
d = *hexstr++; if (d == 0) break;
b = d >> 6;
*p++ |= (d & 15) + b + (b << 3);
len--;
}
if (likely(len == 0 && *hexstr == 0))
ret = true;
return ret;
}
Adopted from ToHex:
http://nefigtut.ru/wp-content/uploads/2011/08/bitcoin-4diff.txtThanks to davids
char *bin2hex(const unsigned char *p, size_t len)
{
unsigned int i = (unsigned int) len;
unsigned char *iptr = (unsigned char *) p;
static char hexmap[16] = { '0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
ssize_t slen;
char *s;
slen = len * 2 + 1;
if (slen % 4)
slen += 4 - (slen % 4);
s = calloc(slen, 1);
if (unlikely(!s))
quit(1, "Failed to calloc in bin2hex");
int mm = 0;
while (i--> 0)
{
s[mm++] = hexmap[*iptr>>4];
s[mm++] = hexmap[*iptr&15];
iptr++;
}
//s is calloced already - filled with zeros no need to terminate char
//s[mm]=0;
return s;
}