summaryrefslogtreecommitdiff
path: root/resolv
diff options
context:
space:
mode:
authorZack Weinberg <zackw@panix.com>2017-06-01 08:50:10 -0400
committerZack Weinberg <zackw@panix.com>2017-07-09 10:03:38 -0400
commitdcd5fa3ba81c9b978a90958838d12af007f7d5bb (patch)
tree5065989189070868f98745d515c9208b138ad45e /resolv
parent218bb835cd0c7b4e3c068d0657efd3dae2551166 (diff)
downloadglibc-zack/jda-hppa-patch.tar.gz
JDA's patches for HPPAzack/jda-hppa-patch
Diffstat (limited to 'resolv')
-rw-r--r--resolv/res_mkquery.c9
-rw-r--r--resolv/res_query.c19
-rw-r--r--resolv/res_send.c9
3 files changed, 32 insertions, 5 deletions
diff --git a/resolv/res_mkquery.c b/resolv/res_mkquery.c
index 59fc5ab28c..8f30973ec7 100644
--- a/resolv/res_mkquery.c
+++ b/resolv/res_mkquery.c
@@ -99,6 +99,15 @@
# define RANDOM_BITS(Var) { uint64_t v64; HP_TIMING_NOW (v64); Var = v64; }
#endif
+/* The structure HEADER is normally aligned to a word boundary and its
+ fields are accessed using word loads and stores. We need to access
+ this structure when it is aligned on a byte boundary. This can cause
+ problems on machines with strict alignment. So, we create a new
+ typedef to reduce its alignment to one. This ensures the fields are
+ accessed with byte loads and stores. */
+typedef HEADER __attribute__ ((__aligned__(1))) UHEADER;
+#define HEADER UHEADER
+
int
__res_context_mkquery (struct resolv_context *ctx, int op, const char *dname,
int class, int type, const unsigned char *data,
diff --git a/resolv/res_query.c b/resolv/res_query.c
index ebbe5a6a4e..6e09257b2f 100644
--- a/resolv/res_query.c
+++ b/resolv/res_query.c
@@ -80,6 +80,15 @@
#include <stdlib.h>
#include <string.h>
#include <shlib-compat.h>
+#include <resolv/resolv-internal.h>
+
+/* The structure HEADER is normally aligned to a word boundary and its
+ fields are accessed using word loads and stores. We need to access
+ this structure when it is aligned on a byte boundary. This can cause
+ problems on machines with strict alignment. So, we create a new
+ typedef to reduce its alignment to one. This ensures the fields are
+ accessed with byte loads and stores. */
+typedef HEADER __attribute__ ((__aligned__(1))) UHEADER;
#if PACKETSZ > 65536
#define MAXPACKET PACKETSZ
@@ -112,8 +121,8 @@ __res_context_query (struct resolv_context *ctx, const char *name,
int *nanswerp2, int *resplen2, int *answerp2_malloced)
{
struct __res_state *statp = ctx->resp;
- HEADER *hp = (HEADER *) answer;
- HEADER *hp2;
+ UHEADER *hp = (UHEADER *) answer;
+ UHEADER *hp2;
int n, use_malloc = 0;
size_t bufsize = (type == T_QUERY_A_AND_AAAA ? 2 : 1) * QUERYSIZE;
@@ -217,7 +226,7 @@ __res_context_query (struct resolv_context *ctx, const char *name,
if (answerp != NULL)
/* __res_context_send might have reallocated the buffer. */
- hp = (HEADER *) *answerp;
+ hp = (UHEADER *) *answerp;
/* We simplify the following tests by assigning HP to HP2 or
vice versa. It is easy to verify that this is the same as
@@ -228,7 +237,7 @@ __res_context_query (struct resolv_context *ctx, const char *name,
}
else
{
- hp2 = (HEADER *) *answerp2;
+ hp2 = (UHEADER *) *answerp2;
if (n < (int) sizeof (HEADER))
{
hp = hp2;
@@ -327,7 +336,7 @@ __res_context_search (struct resolv_context *ctx,
{
struct __res_state *statp = ctx->resp;
const char *cp;
- HEADER *hp = (HEADER *) answer;
+ UHEADER *hp = (UHEADER *) answer;
char tmp[NS_MAXDNAME];
u_int dots;
int trailing_dot, ret, saved_herrno;
diff --git a/resolv/res_send.c b/resolv/res_send.c
index b396aae03c..c83ee860a8 100644
--- a/resolv/res_send.c
+++ b/resolv/res_send.c
@@ -111,6 +111,15 @@
#include <libc-diag.h>
#include <hp-timing.h>
+/* The structure HEADER is normally aligned to a word boundary and its
+ fields are accessed using word loads and stores. We need to access
+ this structure when it is aligned on a byte boundary. This can cause
+ problems on machines with strict alignment. So, we create a new
+ typedef to reduce its alignment to one. This ensures the fields are
+ accessed with byte loads and stores. */
+typedef HEADER __attribute__ ((__aligned__(1))) UHEADER;
+#define HEADER UHEADER
+
#if PACKETSZ > 65536
#define MAXPACKET PACKETSZ
#else