X-Git-Url: http://plrg.eecs.uci.edu/git/?p=folly.git;a=blobdiff_plain;f=folly%2FFingerprint.h;h=74302093b5a58e42bc0d99e37d11426376289566;hp=f1980ae215aa2b35afe248ad0e60b762fcad7b66;hb=60b2478a8e299bbae257a5fe69837696c0950ee5;hpb=0f2aacae3d558f5cf54751b170c4e50d5483cc29 diff --git a/folly/Fingerprint.h b/folly/Fingerprint.h index f1980ae2..74302093 100644 --- a/folly/Fingerprint.h +++ b/folly/Fingerprint.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Facebook, Inc. + * Copyright 2017 Facebook, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -51,12 +51,37 @@ namespace folly { namespace detail { + template struct FingerprintTable { - static const uint64_t poly[1 + (BITS-1)/64]; - static const uint64_t table[8][256][1 + (BITS-1)/64]; + static const uint64_t poly[1 + (BITS - 1) / 64]; + static const uint64_t table[8][256][1 + (BITS - 1) / 64]; }; -} // namespace detail + +template +const uint64_t FingerprintTable::poly[1 + (BITS - 1) / 64] = {}; +template +const uint64_t FingerprintTable::table[8][256][1 + (BITS - 1) / 64] = {}; + +#ifndef _MSC_VER +// MSVC 2015 can't handle these extern specialization declarations, +// but they aren't needed for things to work right, so we just don't +// declare them in the header for MSVC. + +#define FOLLY_DECLARE_FINGERPRINT_TABLES(BITS) \ + template <> \ + const uint64_t FingerprintTable::poly[1 + (BITS - 1) / 64]; \ + template <> \ + const uint64_t FingerprintTable::table[8][256][1 + (BITS - 1) / 64] + +FOLLY_DECLARE_FINGERPRINT_TABLES(64); +FOLLY_DECLARE_FINGERPRINT_TABLES(96); +FOLLY_DECLARE_FINGERPRINT_TABLES(128); + +#undef FOLLY_DECLARE_FINGERPRINT_TABLES +#endif + +} // namespace detail /** * Compute the Rabin fingerprint.