diff options
Diffstat (limited to 'endian.h')
-rw-r--r-- | endian.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/endian.h b/endian.h new file mode 100644 index 0000000..6ebda83 --- /dev/null +++ b/endian.h @@ -0,0 +1,13 @@ +#ifndef SAND_LEEK_ENDIAN_H +#define SAND_LEEK_ENDIAN_H + +#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ +# define sl_htobe32(x) (x) +#else +# define sl_htobe32(x) (((x & 0x000000FF) << 24) | \ + ((x & 0xFF000000) >> 24)) | \ + ((x & 0x0000FF00) << 8) | \ + ((x & 0x00FF0000) >> 8) +#endif + +#endif /* ifndef SAND_LEEK_ENDIAN_H */ |