From 697e162863c5e32a5de03688d47151851ab21eb9 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Sat, 6 May 2006 08:03:24 +0000 Subject: * include/arpa/nameser.h: Add optimizations for NS_GET16 and NS_GET32. * resolv/res_send.c (res_nameinquery): Use NS_GET16 directly instead of ns_get16. (res_queriesmatch): Likewise. Minor optimization. --- include/arpa/nameser.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'include/arpa') diff --git a/include/arpa/nameser.h b/include/arpa/nameser.h index 944fe732a6..09bd504754 100644 --- a/include/arpa/nameser.h +++ b/include/arpa/nameser.h @@ -1 +1,28 @@ #include + +/* If the machine allows unaligned access we can do better than using + the NS_GET16, NS_GET32, NS_PUT16, and NS_PUT32 macros from the + installed header. */ +#include +#include +#include + +#if _STRING_ARCH_unaligned + +# undef NS_GET16 +# define NS_GET16(s, cp) \ + do { \ + uint16_t *t_cp = (uint16_t *) (cp); \ + (s) = ntohs (*t_cp); \ + (cp) += NS_INT16SZ; \ + } while (0) + +# undef NS_GET32 +# define NS_GET32(s, cp) \ + do { \ + uint32_t *t_cp = (uint32_t *) (cp); \ + (s) = ntohl (*t_cp); \ + (cp) += NS_INT32SZ; \ + } while (0) + +#endif -- cgit 1.4.1