X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flib%2Fendian.h;fp=src%2Flib%2Fendian.h;h=7e5fc32bbbecbfe71383d0d4e5b7ea1090404462;hb=b4e9c266d656c6b595cc57920a34937776acc300;hp=0000000000000000000000000000000000000000;hpb=6ffbc2b68c34c2d1e42d5f6bcd8f2b94b82d05d7;p=pintos-anon diff --git a/src/lib/endian.h b/src/lib/endian.h new file mode 100644 index 0000000..7e5fc32 --- /dev/null +++ b/src/lib/endian.h @@ -0,0 +1,19 @@ +#ifndef __LIB_ENDIAN_H +#define __LIB_ENDIAN_H + + +#define endian_swap32(x) ((((x) & 0xff000000) >> 24) | \ + (((x) & 0x00ff0000) >> 8) | \ + (((x) & 0x0000ff00) << 8) | \ + (((x) & 0x000000ff) << 24)) +#define endian_swap16(x) ((((x) & 0xff00)>> 8) | (((x) & 0x00ff) << 8)) +#define endian_swap24(x) (((x) >> 16) & 0xff) | (((x) & 0xff) << 16) | ((x) & 0xff00) + +#define be32_to_machine(x) endian_swap32(x) +#define be16_to_machine(x) endian_swap16(x) +#define be24_to_machine(x) endian_swap24(x) +#define machine_to_be32(x) endian_swap32(x) +#define machine_to_be16(x) endian_swap16(x) +#define machine_to_be24(x) endian_swap24(x) + +#endif