From: Erik Rozendaal Date: Thu, 16 Dec 2004 08:50:59 +0000 (+0000) Subject: configure.ac: (AC_C_CONST, AC_C_INLINE) Check for const and inline X-Git-Tag: release-0.50~669 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d5c4e2d04f0ceb25bdc89380b989bd51eff6e16b;p=thirdparty%2Fldns.git configure.ac: (AC_C_CONST, AC_C_INLINE) Check for const and inline keywords. (OURCPPFLAGS) New. (OURCFLAGS) Moved from Makefile.in. Makefile.in: Removed OURCFLAGS. util.h: (read_uint16, read_uint32) Copied from NSD. rr.c: Use read_uint16 and read_uint32. --- diff --git a/util.h b/util.h index 759496f6..49585e2e 100644 --- a/util.h +++ b/util.h @@ -32,6 +32,36 @@ #define DEP printf("DEPRICATED FUNCTION!\n"); +/* TODO: is this a good way? */ +/* + * Copy data allowing for unaligned accesses in network byte order + * (big endian). + */ +static inline uint16_t +read_uint16(const void *src) +{ +#ifdef ALLOW_UNALIGNED_ACCESSES + return ntohs(*(uint16_t *) src); +#else + uint8_t *p = (uint8_t *) src; + return ((uint16_t) p[0] << 8) | (uint16_t) p[1]; +#endif +} + +static inline uint32_t +read_uint32(const void *src) +{ +#ifdef ALLOW_UNALIGNED_ACCESSES + return ntohl(*(uint32_t *) src); +#else + uint8_t *p = (uint8_t *) src; + return (((uint32_t) p[0] << 24) + | ((uint32_t) p[1] << 16) + | ((uint32_t) p[2] << 8) + | (uint32_t) p[3]); +#endif +} + /* prototypes */ void xprintf_rd_field(t_rdata_field *); void xprintf_rr(ldns_rr_type *);