cmake: Disable C++ GNU extensions. (#3446)
[cvc5.git] / src / util / gmp_util.h
1 /********************* */
2 /*! \file gmp_util.h
3 ** \verbatim
4 ** Top contributors (to current version):
5 ** Tim King, Andres Noetzli, Morgan Deters
6 ** This file is part of the CVC4 project.
7 ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS
8 ** in the top-level source directory) and their institutional affiliations.
9 ** All rights reserved. See the file COPYING in the top-level source
10 ** directory for licensing information.\endverbatim
11 **
12 ** \brief [[ Add one-line brief description here ]]
13 **
14 ** [[ Add lengthier description here ]]
15 ** \todo document this file
16 **/
17
18 #include "cvc4_public.h"
19
20 #ifndef CVC4__GMP_UTIL_H
21 #define CVC4__GMP_UTIL_H
22
23 /*
24 * Older versions of GMP in combination with newer versions of GCC and C++11
25 * cause errors: https://gcc.gnu.org/gcc-4.9/porting_to.html
26 * Including <cstddef> is a workaround for this issue.
27 */
28 #include <cstddef>
29
30 #include <gmpxx.h>
31
32 namespace CVC4 {
33
34 /** Hashes the gmp integer primitive in a word by word fashion. */
35 inline size_t gmpz_hash(const mpz_t toHash) {
36 size_t hash = 0;
37 for (int i = 0, n = mpz_size(toHash); i < n; ++i){
38 mp_limb_t limb = mpz_getlimbn(toHash, i);
39 hash = hash * 2;
40 hash = hash xor limb;
41 }
42 return hash;
43 }/* gmpz_hash() */
44
45 }/* CVC4 namespace */
46
47 #endif /* CVC4__GMP_UTIL_H */