[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r3807 - in GNUnet/src: applications/fs/ecrs applications/tr
From: |
grothoff |
Subject: |
[GNUnet-SVN] r3807 - in GNUnet/src: applications/fs/ecrs applications/traffic include server |
Date: |
Tue, 21 Nov 2006 21:06:18 -0800 (PST) |
Author: grothoff
Date: 2006-11-21 21:06:13 -0800 (Tue, 21 Nov 2006)
New Revision: 3807
Modified:
GNUnet/src/applications/fs/ecrs/meta.c
GNUnet/src/applications/traffic/traffic.c
GNUnet/src/include/platform.h
GNUnet/src/server/connection.c
Log:
misalignment issues on sparc
Modified: GNUnet/src/applications/fs/ecrs/meta.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/meta.c 2006-11-21 03:30:21 UTC (rev
3806)
+++ GNUnet/src/applications/fs/ecrs/meta.c 2006-11-22 05:06:13 UTC (rev
3807)
@@ -576,12 +576,12 @@
if (size < sizeof(MetaDataHeader))
return NULL;
hdr = (const MetaDataHeader*) input;
- if ( (ntohl(hdr->version) & HEADER_VERSION_MASK) != 0)
+ if ( (ntohl(UNALIGNED(hdr->version)) & HEADER_VERSION_MASK) != 0)
return NULL; /* unsupported version */
- ic = ntohl(hdr->entries);
- compressed = (ntohl(hdr->version) & HEADER_COMPRESSED) != 0;
+ ic = ntohl(UNALIGNED(hdr->entries));
+ compressed = (ntohl(UNALIGNED(hdr->version)) & HEADER_COMPRESSED) != 0;
if (compressed) {
- dataSize = ntohl(hdr->size) - sizeof(MetaDataHeader);
+ dataSize = ntohl(UNALIGNED(hdr->size)) - sizeof(MetaDataHeader);
if (dataSize > 2 * 1042 * 1024) {
GE_BREAK(ectx, 0);
return NULL; /* only 2 MB allowed [to make sure we don't blow
@@ -598,7 +598,7 @@
} else {
data = (char*) &hdr[1];
dataSize = size - sizeof(MetaDataHeader);
- if (size != ntohl(hdr->size)) {
+ if (size != ntohl(UNALIGNED(hdr->size))) {
GE_BREAK(ectx, 0);
return NULL;
}
@@ -623,7 +623,8 @@
while ( (pos < dataSize) &&
(i < ic) ) {
len = strlen(&data[pos])+1;
- md->items[i].type = (EXTRACTOR_KeywordType) ntohl(((unsigned
int*)data)[i]);
+ md->items[i].type = (EXTRACTOR_KeywordType)
+ ntohl(UNALIGNED(((unsigned int*)data)[i]));
md->items[i].data = STRDUP(&data[pos]);
pos += len;
i++;
Modified: GNUnet/src/applications/traffic/traffic.c
===================================================================
--- GNUnet/src/applications/traffic/traffic.c 2006-11-21 03:30:21 UTC (rev
3806)
+++ GNUnet/src/applications/traffic/traffic.c 2006-11-22 05:06:13 UTC (rev
3807)
@@ -508,13 +508,13 @@
const MESSAGE_HEADER * header) {
unsigned short port;
- port = ntohs(header->type);
+ port = ntohs(UNALIGNED(header->type));
updateTrafficSendCounter(port,
- ntohs(header->size));
+ ntohs(UNALIGNED(header->size)));
MUTEX_LOCK(lock);
checkPort(port);
updateUse(&counters[port]->send,
- ntohs(header->size),
+ ntohs(UNALIGNED(header->size)),
receiver->hashPubKey.bits[0],
NO);
MUTEX_UNLOCK(lock);
Modified: GNUnet/src/include/platform.h
===================================================================
--- GNUnet/src/include/platform.h 2006-11-21 03:30:21 UTC (rev 3806)
+++ GNUnet/src/include/platform.h 2006-11-22 05:06:13 UTC (rev 3807)
@@ -182,4 +182,10 @@
#define O_LARGEFILE 0
#endif
+#if defined(__sparc__)
+#define UNALIGNED(val) ({ __typeof__((val)) __tmp; memmove(&__tmp, &(val),
sizeof((val))); __tmp; })
+#else
+#define UNALIGNED(val) val
#endif
+
+#endif
Modified: GNUnet/src/server/connection.c
===================================================================
--- GNUnet/src/server/connection.c 2006-11-21 03:30:21 UTC (rev 3806)
+++ GNUnet/src/server/connection.c 2006-11-22 05:06:13 UTC (rev 3807)
@@ -1530,7 +1530,7 @@
j = sizeof(P2P_PACKET_HEADER);
while (j < p) {
MESSAGE_HEADER * part = (MESSAGE_HEADER *) &plaintextMsg[j];
- unsigned short plen = htons(part->size);
+ unsigned short plen = htons(UNALIGNED(part->size));
if (plen < sizeof(MESSAGE_HEADER)) {
GE_BREAK(ectx, 0);
break;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r3807 - in GNUnet/src: applications/fs/ecrs applications/traffic include server,
grothoff <=