Backed out changeset 30dec3c6ac99 (bug 1468544) for breaking at least MSVC build. CLOSED TREE
authorSebastian Hengst <archaeopteryx@coole-files.de>
Thu, 01 Nov 2018 20:31:40 +0200
changeset 443942 9c00b907189039fdf10b0b3f431f65e2da5e1687
parent 443941 f391ab62002bc2a28968696ee35eaf3a30ef372f
child 443943 ef53052535067df8a9eee34d65e25d6fadac8911
push id109488
push userarchaeopteryx@coole-files.de
push dateThu, 01 Nov 2018 18:31:59 +0000
treeherdermozilla-inbound@9c00b9071890 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1468544
milestone65.0a1
backs out30dec3c6ac99c13c5a887441e17efa8a821009a6
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out changeset 30dec3c6ac99 (bug 1468544) for breaking at least MSVC build. CLOSED TREE
modules/libmar/src/mar_read.c
modules/libmar/src/moz.build
modules/libmar/tool/moz.build
other-licenses/nsis/Contrib/CityHash/cityhash/city.h
--- a/modules/libmar/src/mar_read.c
+++ b/modules/libmar/src/mar_read.c
@@ -3,22 +3,35 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include <sys/types.h>
 #include <fcntl.h>
 #include <stdlib.h>
 #include <string.h>
-#include "city.h"
 #include "mar_private.h"
 #include "mar.h"
 
+#ifdef XP_WIN
+#include <winsock2.h>
+#else
+#include <netinet/in.h>
+#endif
+
+
+/* this is the same hash algorithm used by nsZipArchive.cpp */
 static uint32_t mar_hash_name(const char *name) {
-  return CityHash64(name, strlen(name)) % TABLESIZE;
+  uint32_t val = 0;
+  unsigned char* c;
+
+  for (c = (unsigned char *) name; *c; ++c)
+    val = val*37 + *c;
+
+  return val % TABLESIZE;
 }
 
 static int mar_insert_item(MarFile *mar, const char *name, int namelen,
                            uint32_t offset, uint32_t length, uint32_t flags) {
   MarItem *item, *root;
   uint32_t hash;
 
   item = (MarItem *) malloc(sizeof(MarItem) + namelen);
--- a/modules/libmar/src/moz.build
+++ b/modules/libmar/src/moz.build
@@ -19,16 +19,12 @@ HostLibrary('hostmar')
 Library('mar')
 
 UNIFIED_SOURCES += [
     'mar_create.c',
     'mar_extract.c',
     'mar_read.c',
 ]
 
-LOCAL_INCLUDES += [
-    '../../../other-licenses/nsis/Contrib/CityHash/cityhash',
-]
-
 FORCE_STATIC_LIB = True
 
 if CONFIG['OS_ARCH'] == 'WINNT':
     USE_STATIC_LIBS = True
--- a/modules/libmar/tool/moz.build
+++ b/modules/libmar/tool/moz.build
@@ -1,16 +1,15 @@
 # -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=python:
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 HOST_SOURCES += [
-    '/other-licenses/nsis/Contrib/CityHash/cityhash/city.cpp',
     'mar.c',
 ]
 
 HostProgram('mar')
 
 HOST_USE_LIBS += [
     'hostmar',
 ]
--- a/other-licenses/nsis/Contrib/CityHash/cityhash/city.h
+++ b/other-licenses/nsis/Contrib/CityHash/cityhash/city.h
@@ -45,49 +45,44 @@
 
 #include <stdlib.h>  // for size_t.
 #include <stdint.h>
 
 typedef uint8_t uint8;
 typedef uint32_t uint32;
 typedef uint64_t uint64;
 
-#ifdef __cplusplus
 // The standard <utility> header doesn't compile, apparently it conflicts
 // with... some Mozilla something or other. But all that's used from it
 // is std::pair, so we can just replace that with mozilla::Pair.
 #ifndef MOZILLA_CLIENT
 #include <utility>
 typedef std::pair<uint64, uint64> uint128;
 inline uint64 Uint128Low64(const uint128& x) { return x.first; }
 inline uint64 Uint128High64(const uint128& x) { return x.second; }
 #else
 #include "mozilla/Pair.h"
 typedef mozilla::Pair<uint64, uint64> uint128;
 inline uint64 Uint128Low64(const uint128& x) { return x.first(); }
 inline uint64 Uint128High64(const uint128& x) { return x.second(); }
 #endif
 
-extern "C" {
-#endif
 
 // Hash function for a byte array.
 uint64 CityHash64(const char *buf, size_t len);
 
 // Hash function for a byte array.  For convenience, a 64-bit seed is also
 // hashed into the result.
 uint64 CityHash64WithSeed(const char *buf, size_t len, uint64 seed);
 
 // Hash function for a byte array.  For convenience, two seeds are also
 // hashed into the result.
 uint64 CityHash64WithSeeds(const char *buf, size_t len,
                            uint64 seed0, uint64 seed1);
 
-#ifdef __cplusplus
-}
 // Hash function for a byte array.
 uint128 CityHash128(const char *s, size_t len);
 
 // Hash function for a byte array.  For convenience, a 128-bit seed is also
 // hashed into the result.
 uint128 CityHash128WithSeed(const char *s, size_t len, uint128 seed);
 
 // Hash 128 input bits down to 64 bits of output.
@@ -97,11 +92,10 @@ inline uint64 Hash128to64(const uint128&
   const uint64 kMul = 0x9ddfea08eb382d69;
   uint64 a = (Uint128Low64(x) ^ Uint128High64(x)) * kMul;
   a ^= (a >> 47);
   uint64 b = (Uint128High64(x) ^ a) * kMul;
   b ^= (b >> 47);
   b *= kMul;
   return b;
 }
-#endif
 
 #endif  // CITY_HASH_H_