changeset 7133:42db22108d85

revlog parser: use ntohl() instead of ntohll() (fix endianness issues)
author Benoit Boissinot <benoit.boissinot@ens-lyon.org>
date Sat, 18 Oct 2008 20:23:46 +0200
parents b801d6e5dc83
children cb6395fc16a9
files mercurial/parsers.c
diffstat 1 files changed, 8 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/parsers.c	Sat Oct 18 04:26:09 2008 -0500
+++ b/mercurial/parsers.c	Sat Oct 18 20:23:46 2008 +0200
@@ -234,13 +234,6 @@
 	return ret;
 }
 
-
-static inline uint64_t ntohll(uint64_t x)
-{
-	return (((uint64_t)ntohl((uint32_t)x)) << 32) |
-		(uint64_t)ntohl((uint32_t)(x >> 32));
-}
-
 const char nullid[20];
 const int nullrev = -1;
 
@@ -266,9 +259,14 @@
 	const char *end = data + size;
 
 	while (data < end) {
-		offset_flags = ntohll(*((uint64_t *) data));
-		if (n == 0) /* mask out version number for the first entry */
-			offset_flags &= 0xFFFF;
+                offset_flags = ntohl(*((uint32_t *) (data + 4)));
+                if (n == 0) /* mask out version number for the first entry */
+                        offset_flags &= 0xFFFF;
+                else {
+			uint32_t offset_high =  ntohl(*((uint32_t *) data));
+                        offset_flags |= ((uint64_t) offset_high) << 32;
+		}
+
 
 		comp_len = ntohl(*((uint32_t *) (data + 8)));
 		uncomp_len = ntohl(*((uint32_t *) (data + 12)));