From: Gerd Hoffmann Date: Fri, 18 Dec 2009 11:16:03 +0000 (+0100) Subject: move htonl() + friends to util.h X-Git-Url: http://wien.tomnetworks.com/gitweb/?p=seabios.git;a=commitdiff_plain;h=02e60532453d18eafcd5e00f3383ae29f7c468f9 move htonl() + friends to util.h As the next patch will add one more user of the macros move them to util.h. Also add the 16bit variants. Signed-off-by: Gerd Hoffmann Signed-off-by: Anthony Liguori --- diff --git a/src/coreboot.c b/src/coreboot.c index 7fa18e4..3dc6a7f 100644 --- a/src/coreboot.c +++ b/src/coreboot.c @@ -351,11 +351,6 @@ ulzma(u8 *dst, u32 maxlen, const u8 *src, u32 srclen) * Coreboot flash format ****************************************************************/ -// XXX - optimize -#define ntohl(x) ((((x)&0xff)<<24) | (((x)&0xff00)<<8) | \ - (((x)&0xff0000) >> 8) | (((x)&0xff000000) >> 24)) -#define htonl(x) ntohl(x) - #define CBFS_HEADER_MAGIC 0x4F524243 #define CBFS_HEADPTR_ADDR 0xFFFFFFFc #define CBFS_VERSION1 0x31313131 diff --git a/src/util.h b/src/util.h index 1eafce0..24e39d1 100644 --- a/src/util.h +++ b/src/util.h @@ -367,4 +367,11 @@ extern u8 BiosChecksum; // version (auto generated file out/version.c) extern const char VERSION[]; +// XXX - optimize +#define ntohl(x) ((((x)&0xff)<<24) | (((x)&0xff00)<<8) | \ + (((x)&0xff0000) >> 8) | (((x)&0xff000000) >> 24)) +#define htonl(x) ntohl(x) +#define ntohs(x) ((((x)&0xff)<<8) | (((x)&0xff00)>>8)) +#define htons(x) ntohs(x) + #endif // util.h