I wonder what's the recommended way to convert integer to/from little-endian in a portable way.

Is there any library for that?

We can use [htonl and ntohl](http://linux.die.net/man/3/htonl) and then do another big-endian to (from) little-endian conversion, but it's not efficient.