hton long long
I need some suggestions. What would be the best way to make an hton for data stored as a long long? Should I make a brand new function or use a type of manipulation of the already made hton's? I have been attempting to write my own function but I am having a tough time.
Well, I finally found something to do it? Is this some decent code?
unsigned long long htonll (unsigned long long hostlonglong)
unsigned long long retval;
retval = hostlonglong;
retval = ((unsigned long long) htonl(hostlonglong & 0xFFFFFFFF)) << 32;
retval |= htonl((hostlonglong & 0xFFFFFFFF00000000) >> 32);
I use one almost exactly like your code. Haven't encountered problems so far.