~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to m4/pandora_stl_hash.m4

  • Committer: Brian Aker
  • Date: 2009-12-18 18:31:01 UTC
  • mfrom: (1241.2.7 build)
  • Revision ID: brian@gaz-20091218183101-igqg1dtowpa0o70s
Fixed from Monty.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2008 Sun Microsystems, Inc.
2
 
# This file is free software; Sun Microsystems, Inc.
3
 
# gives unlimited permission to copy and/or distribute it,
4
 
# with or without modifications, as long as this notice is preserved.
5
 
 
6
 
# We check two things: where the include file is for unordered_map, and
7
 
# what namespace unordered_map lives in within that include file.  We
 
1
# We check two things: where the include file is for hash_map, and
 
2
# what namespace hash_map lives in within that include file.  We
8
3
# include AC_COMPILE_IFELSE for all the combinations we've seen in the
9
 
# wild.  We define HAVE_UNORDERED_MAP and HAVE_UNORDERED_SET if we have
10
 
# them, UNORDERED_MAP_H and UNORDERED_SET_H to their location and
11
 
# UNORDERED_NAMESPACE to be the namespace unordered_map is defined in.
12
 
 
13
 
AC_DEFUN([PANDORA_CXX_STL_UNORDERED],[
14
 
  save_CXXFLAGS="${CXXFLAGS}"
15
 
  CXXFLAGS="${AM_CXXFLAGS} ${CXXFLAGS}"
16
 
  AC_LANG_PUSH(C++)
17
 
  AC_CACHE_CHECK([for STL unordered_map],
18
 
    [pandora_cv_stl_unordered],[
19
 
      AC_COMPILE_IFELSE(
20
 
        [AC_LANG_PROGRAM([[#include <unordered_map>]],
21
 
                         [[std::unordered_map<int, int> t]])],
22
 
        [pandora_cv_stl_unordered="yes"],
23
 
        [pandora_cv_stl_unordered="no"])])
24
 
 
25
 
  AS_IF([test "x${pandora_cv_stl_unordered}" != "xyes"],[
26
 
    AC_CACHE_CHECK([for tr1 unordered_map],
27
 
      [pandora_cv_tr1_unordered],[
28
 
        AC_COMPILE_IFELSE(
29
 
          [AC_LANG_PROGRAM([[
30
 
/* We put in this define because of a YACC symbol clash in Drizzle.
31
 
   Seriously... I cannot believe the GCC guys defined a piece of the internals
32
 
   of this named IF - and I can't believe that YACC generates a token define
33
 
   called IF. Really?
34
 
*/
35
 
#define IF 21;
36
 
#include <tr1/unordered_map>
37
 
            ]],[[
38
 
std::tr1::unordered_map<int, int> t
39
 
          ]])],
40
 
          [pandora_cv_tr1_unordered="yes"],
41
 
          [pandora_cv_tr1_unordered="no"])])
42
 
  ])
43
 
 
44
 
  AS_IF([test "x${pandora_cv_stl_unordered}" != "xyes" -a "x${pandora_cv_tr1_unordered}" != "xyes"],[
45
 
    AC_CACHE_CHECK([for boost unordered_map],
46
 
      [pandora_cv_boost_unordered],[
47
 
        AC_COMPILE_IFELSE(
48
 
          [AC_LANG_PROGRAM([[#include <boost/unordered_map.hpp>]],
49
 
                           [[boost::unordered_map<int, int> t]])],
50
 
          [pandora_cv_boost_unordered="yes"],
51
 
          [pandora_cv_boost_unordered="no"])])
52
 
  ])
53
 
 
54
 
  CXXFLAGS="${save_CXXFLAGS}"
55
 
  AC_LANG_POP()
56
 
 
57
 
  AS_IF([test "x${pandora_cv_stl_unordered}" = "xyes"],[
58
 
    AC_DEFINE(HAVE_STD_UNORDERED_MAP, 1,
59
 
              [if the compiler has std::unordered_map])
60
 
    AC_DEFINE(HAVE_STD_UNORDERED_SET, 1,
61
 
              [if the compiler has std::unordered_set])
62
 
    pandora_has_unordered=yes
63
 
  ])
64
 
  AS_IF([test "x${pandora_cv_tr1_unordered}" = "xyes"],[
65
 
    AC_DEFINE(HAVE_TR1_UNORDERED_MAP, 1,
66
 
              [if the compiler has std::tr1::unordered_map])
67
 
    AC_DEFINE(HAVE_TR1_UNORDERED_SET, 1,
68
 
              [if the compiler has std::tr1::unordered_set])
69
 
    pandora_has_unordered=yes
70
 
  ])
71
 
  AS_IF([test "x${pandora_cv_boost_unordered}" = "xyes"],[
72
 
    AC_DEFINE(HAVE_BOOST_UNORDERED_MAP, 1,
73
 
              [if the compiler has boost::unordered_map])
74
 
    AC_DEFINE(HAVE_BOOST_UNORDERED_SET, 1,
75
 
              [if the compiler has boost::unordered_set])
76
 
    pandora_has_unordered=yes
77
 
  ])
78
 
    
79
 
  AS_IF([test "x${pandora_has_unordered}" != "xyes"],[
80
 
    AC_MSG_WARN([could not find an STL unordered_map])
81
 
  ])
82
 
])
83
 
 
84
 
AC_DEFUN([PANDORA_HAVE_CXX_UNORDERED],[
85
 
  AC_REQUIRE([PANDORA_CXX_STL_UNORDERED])
86
 
])
87
 
 
88
 
AC_DEFUN([PANDORA_REQUIRE_CXX_UNORDERED],[
89
 
  AC_REQUIRE([PANDORA_HAVE_CXX_UNORDERED])
90
 
  AS_IF([test "x${pandora_has_unordered}" != "xyes"],[
91
 
    AC_MSG_ERROR([An STL compliant unordered_map is required for ${PACKAGE}.
92
 
    Implementations can be found in Recent versions of gcc and in boost])
93
 
  ])
 
4
# wild.  We define one of HAVE_HASH_MAP or HAVE_EXT_HASH_MAP depending
 
5
# on location, and HASH_NAMESPACE to be the namespace hash_map is
 
6
# defined in.
 
7
#
 
8
# Ideally we'd use AC_CACHE_CHECK, but that only lets us store one value
 
9
# at a time, and we need to store two (filename and namespace).
 
10
# prints messages itself, so we have to do the message-printing ourselves
 
11
# via AC_MSG_CHECKING + AC_MSG_RESULT.  (TODO(csilvers): can we cache?)
 
12
 
 
13
AC_DEFUN([PANDORA_CXX_STL_HASH],
 
14
  [AC_MSG_CHECKING(the location of hash_map)
 
15
   AC_LANG_PUSH(C++)
 
16
   ac_cv_cxx_hash_map=""
 
17
   for location in "" "ext/" "tr1/" ; do
 
18
     for namespace in __gnu_cxx "" std stdext; do
 
19
       for classprefix in unordered hash; do
 
20
         if test -z "$ac_cv_cxx_hash_map"; then
 
21
           AC_COMPILE_IFELSE(
 
22
             [AC_LANG_PROGRAM([[#include <${location}${classprefix}_map>]],
 
23
                           [[${namespace}::${classprefix}_map<int, int> t]])],
 
24
             [ac_cv_cxx_hash_map="<${location}${classprefix}_map>";
 
25
              ac_cv_cxx_hash_set="<${location}${classprefix}_set>";
 
26
              ac_cv_cxx_hash_namespace="$namespace";
 
27
              ac_cv_cxx_hash_map_class="${classprefix}_map";
 
28
              ac_cv_cxx_hash_set_class="${classprefix}_set"])
 
29
 
 
30
         fi
 
31
       done
 
32
     done
 
33
   done
 
34
 
 
35
   if test -n "$ac_cv_cxx_hash_map"; then
 
36
      AC_DEFINE(HAVE_HASH_MAP, 1, [define if the compiler has hash_map])
 
37
      AC_DEFINE(HAVE_HASH_SET, 1, [define if the compiler has hash_set])
 
38
      AC_DEFINE_UNQUOTED(HASH_MAP_H,$ac_cv_cxx_hash_map,
 
39
                         [the location of <hash_map>])
 
40
      AC_DEFINE_UNQUOTED(HASH_SET_H,$ac_cv_cxx_hash_set,
 
41
                         [the location of <hash_set>])
 
42
      AC_DEFINE_UNQUOTED(HASH_NAMESPACE,$ac_cv_cxx_hash_namespace,
 
43
                         [the namespace of hash_map/hash_set])
 
44
      AC_DEFINE_UNQUOTED(HASH_MAP_CLASS,$ac_cv_cxx_hash_map_class,
 
45
                         [the classname of hash_map])
 
46
      AC_DEFINE_UNQUOTED(HASH_SET_CLASS,$ac_cv_cxx_hash_set_class,
 
47
                         [the classname of hash_set])
 
48
      AC_MSG_RESULT([$ac_cv_cxx_hash_map])
 
49
   else
 
50
      AC_MSG_RESULT()
 
51
      AC_MSG_WARN([could not find an STL hash_map])
 
52
   fi
 
53
   AC_CACHE_CHECK(
 
54
     [whether hash_map has rehash method],
 
55
     [ac_cv_hash_map_has_rehash],
 
56
     [AC_COMPILE_IFELSE(
 
57
       [AC_LANG_PROGRAM([[
 
58
#include HASH_MAP_H
 
59
using namespace HASH_NAMESPACE;
 
60
       ]],[[
 
61
HASH_MAP_CLASS<int, int> test_hash;
 
62
test_hash.rehash(100);
 
63
          ]])],
 
64
       [ac_cv_hash_map_has_rehash=yes],
 
65
       [ac_cv_hash_map_has_rehash=no])])
 
66
   AS_IF([test $ac_cv_hash_map_has_rehash = yes],[
 
67
      AC_DEFINE(HASH_MAP_HAS_REHASH, 1, [if hash_map<> hash rehash method])
 
68
   ])
 
69
   AC_CACHE_CHECK(
 
70
     [whether hash_map has resize method],
 
71
     [ac_cv_hash_map_has_resize],
 
72
     [AC_COMPILE_IFELSE(
 
73
       [AC_LANG_PROGRAM([[
 
74
#include HASH_MAP_H
 
75
using namespace HASH_NAMESPACE;
 
76
       ]],[[
 
77
HASH_MAP_CLASS<int, int> test_hash;
 
78
test_hash.resize(100);
 
79
          ]])],
 
80
       [ac_cv_hash_map_has_resize=yes],
 
81
       [ac_cv_hash_map_has_resize=no])])
 
82
   AS_IF([test $ac_cv_hash_map_has_resize = yes],[
 
83
      AC_DEFINE(HASH_MAP_HAS_RESIZE, 1, [if hash_map<> hash resize method])
 
84
   ])
 
85
   AC_CACHE_CHECK(
 
86
     [whether to redefine hash<string>],
 
87
     [ac_cv_redefine_hash_string],
 
88
     [AC_COMPILE_IFELSE(
 
89
       [AC_LANG_PROGRAM([[
 
90
#include HASH_SET_H
 
91
#include <string>
 
92
using namespace HASH_NAMESPACE;
 
93
using namespace std;
 
94
          ]],[[
 
95
string teststr("test");
 
96
HASH_SET_CLASS<string> test_hash;
 
97
HASH_SET_CLASS<string>::iterator iter= test_hash.find(teststr);
 
98
if (iter != test_hash.end())
 
99
  return 1;
 
100
          ]])],
 
101
       [ac_cv_redefine_hash_string=no],
 
102
       [ac_cv_redefine_hash_string=yes])])
 
103
   AS_IF([test $ac_cv_redefine_hash_string = yes],[
 
104
      AC_DEFINE(REDEFINE_HASH_STRING, 1, [if hash<string> needs to be defined])
 
105
   ])
 
106
   AC_LANG_POP()
94
107
])