From 534edd4d1caae64126825743ec6227aadb239ae3 Mon Sep 17 00:00:00 2001 From: Alexandre Duret-Lutz Date: Wed, 15 Jan 2014 14:40:27 +0100 Subject: [PATCH] bitvect: Fix compilation on 32-bits hosts. * src/misc/bitvect.cc: Conditionally declare fnv<8>, so that the C++ parser does not choke on 14695981039346656037UL when compiling on a 32bit host. Problem observed with g++ 4.0.1 and 4.2.1 on Darwin. --- src/misc/bitvect.cc | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/src/misc/bitvect.cc b/src/misc/bitvect.cc index e84928bb1..51ab7109e 100644 --- a/src/misc/bitvect.cc +++ b/src/misc/bitvect.cc @@ -1,5 +1,5 @@ // -*- coding: utf-8 -*- -// Copyright (C) 2013 Laboratoire de Recherche et Développement +// Copyright (C) 2013, 2014 Laboratoire de Recherche et Développement // de l'Epita (LRDE). // // This file is part of Spot, a model checking library. @@ -26,6 +26,7 @@ #include #include #include +#include namespace spot { @@ -42,9 +43,20 @@ namespace spot return n; } - // Fowler–Noll–Vo hash parameters for 64bits + // Fowler-Noll-Vo hash parameters. + // Add specializations as needed. template struct fnv + { + }; + + // Do not define the following if ULONG_MAX cannot + // hold a 64-bit value, otherwise the parser will + // choke when parsing the constants. +#if ULONG_MAX >> 31 >> 31 >> 1 > 0 + // Fowler-Noll-Vo hash parameters for 64bits + template<> + struct fnv<8> { static unsigned long init() { @@ -56,19 +68,20 @@ namespace spot return 1099511628211UL; } }; +#endif - // Fowler–Noll–Vo hash parameters for 32bits + // Fowler-Noll-Vo hash parameters for 32bits template<> struct fnv<4> { - static unsigned int init() + static unsigned long init() { - return 2166136261U; + return 2166136261UL; } - static unsigned int prime() + static unsigned long prime() { - return 16777619U; + return 16777619UL; } };