port.h 2.93 KB
Newer Older
Robert Ricci's avatar
Robert Ricci committed
1
/*
Robert Ricci's avatar
Robert Ricci committed
2
 * Copyright (c) 2002-2010 University of Utah and the Flux Group.
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
 * 
 * {{{EMULAB-LICENSE
 * 
 * This file is part of the Emulab network testbed software.
 * 
 * This file is free software: you can redistribute it and/or modify it
 * under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or (at
 * your option) any later version.
 * 
 * This file is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public
 * License for more details.
 * 
 * You should have received a copy of the GNU Affero General Public License
 * along with this file.  If not, see <http://www.gnu.org/licenses/>.
 * 
 * }}}
Robert Ricci's avatar
Robert Ricci committed
22 23
 */

24
// This file may need to be changed depending on the architecture.
25
#ifndef __PORT_H
26
#define __PORT_H
27 28
#include <limits.h>

29
#ifndef WCHAR_MIN
30 31
#define WCHAR_MIN INT_MIN
#define WCHAR_MAX INT_MAX
32
#endif
33 34 35 36

/*
 * We have to do these includes differently depending on which version of gcc
 * we're compiling with
37 38 39 40 41 42 43 44 45 46
 *
 * In G++ 4.3, hash_set and hash_map were formally deprecated and
 * moved from ext/ to backward/.  Well, that's what the release notes
 * claim.  In fact, on my system, hash_set and hash_map appear in both
 * ext/ and backward/.  But, hash_fun.h is only in backward/, necessi-
 * tating the NEWER_GCC macro.
 *
 * The real fix is to replace
 *   hash_set with tr1::unordered_set in <tr1/unordered_set>
 *   hash_map with tr1::unordered_map in <tr1/unordered_map>
47
 */
48
#if (__GNUC__ == 3 && __GNUC_MINOR__ > 0) || (__GNUC__ > 3)
49
#ifndef __clang__
50 51
#define NEW_GCC
#endif
52
#endif
53

54
#if (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) || (__GNUC__ > 4)
55
#ifndef __clang__
56 57
#define NEWER_GCC
#endif
58 59 60 61 62 63 64 65 66
#endif

#ifdef __clang__
#undef NEW_GCC
#undef NEWER_GCC
#include <forward_list>
template<typename T>
using slist = std::forward_list<T>;
#endif
67

68
#ifdef NEW_GCC
69
#include <ext/slist>
70
using namespace __gnu_cxx;
71
#elif ! defined __clang__
72
#include <slist>
73 74
#endif

75 76 77 78 79 80
#ifdef NEWER_BOOST
#define BOOST_PMAP_HEADER <boost/property_map/property_map.hpp>
#else
#define BOOST_PMAP_HEADER <boost/property_map.hpp>
#endif

81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
/*
 * We have to do these includes differently depending on which version of gcc
 * we're compiling with
 */
#ifdef NEW_GCC
#include <ext/hash_map>
#include <ext/hash_set>
#ifdef NEWER_GCC
  #include <backward/hash_fun.h>
#else
  #include <ext/hash_fun.h>
#endif

using namespace __gnu_cxx;
#define RANDOM() random()
#elif ! defined __clang__
#include <hash_map>
#include <hash_set>
#define RANDOM() std::random()
#endif

#ifdef __clang__

#include <functional>
#include <unordered_map>
#include <unordered_set>

template < typename T, typename U, typename F=std::hash<T> >
using hash_map = std::unordered_map<T, U, F>;

template < typename T, typename F=std::hash<T> >
using hash_set = std::unordered_set<T, F>;
#define RANDOM() std::rand()

#endif

117 118
#else
#endif