revlog parser: use ntohl() instead of ntohll() (fix endianness issues)
authorBenoit Boissinot <benoit.boissinot@ens-lyon.org>
Sat, 18 Oct 2008 20:23:46 +0200
changeset 7133 42db22108d85
parent 7121 b801d6e5dc83
child 7134 cb6395fc16a9
revlog parser: use ntohl() instead of ntohll() (fix endianness issues)
mercurial/parsers.c
--- 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)));