memcached 1.2.6 → 1.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (225) hide show
  1. data/CHANGELOG +2 -0
  2. data/Manifest +206 -12
  3. data/Rakefile +32 -1
  4. data/ext/extconf.rb +10 -35
  5. data/ext/libmemcached-0.32/AUTHORS +7 -0
  6. data/ext/libmemcached-0.32/COPYING +32 -0
  7. data/ext/libmemcached-0.32/ChangeLog +303 -0
  8. data/ext/libmemcached-0.32/INSTALL +302 -0
  9. data/ext/libmemcached-0.32/Makefile.am +36 -0
  10. data/ext/libmemcached-0.32/Makefile.in +828 -0
  11. data/ext/libmemcached-0.32/NEWS +1 -0
  12. data/ext/libmemcached-0.32/README +33 -0
  13. data/ext/libmemcached-0.32/THANKS +14 -0
  14. data/ext/libmemcached-0.32/TODO +11 -0
  15. data/ext/libmemcached-0.32/aclocal.m4 +1852 -0
  16. data/ext/libmemcached-0.32/clients/Makefile.am +73 -0
  17. data/ext/libmemcached-0.32/clients/Makefile.in +770 -0
  18. data/ext/libmemcached-0.32/clients/client_options.h +32 -0
  19. data/ext/libmemcached-0.32/clients/execute.c +64 -0
  20. data/ext/libmemcached-0.32/clients/execute.h +5 -0
  21. data/ext/libmemcached-0.32/clients/generator.c +74 -0
  22. data/ext/libmemcached-0.32/clients/generator.h +20 -0
  23. data/ext/libmemcached-0.32/clients/memcat.c +178 -0
  24. data/ext/libmemcached-0.32/clients/memcp.c +251 -0
  25. data/ext/libmemcached-0.32/clients/memdump.c +170 -0
  26. data/ext/libmemcached-0.32/clients/memerror.c +80 -0
  27. data/ext/libmemcached-0.32/clients/memflush.c +143 -0
  28. data/ext/libmemcached-0.32/clients/memrm.c +160 -0
  29. data/ext/libmemcached-0.32/clients/memslap.c +441 -0
  30. data/ext/libmemcached-0.32/clients/memstat.c +326 -0
  31. data/ext/libmemcached-0.32/clients/utilities.c +207 -0
  32. data/ext/libmemcached-0.32/clients/utilities.h +41 -0
  33. data/ext/libmemcached-0.32/config.h.in +252 -0
  34. data/ext/libmemcached-0.32/config/compile +143 -0
  35. data/ext/libmemcached-0.32/config/config.guess +1561 -0
  36. data/ext/libmemcached-0.32/config/config.rpath +666 -0
  37. data/ext/libmemcached-0.32/config/config.sub +1686 -0
  38. data/ext/libmemcached-0.32/config/depcomp +630 -0
  39. data/ext/libmemcached-0.32/config/install-sh +520 -0
  40. data/ext/libmemcached-0.32/config/ltmain.sh +8406 -0
  41. data/ext/libmemcached-0.32/config/missing +376 -0
  42. data/ext/libmemcached-0.32/configure +23048 -0
  43. data/ext/libmemcached-0.32/configure.ac +122 -0
  44. data/ext/libmemcached-0.32/docs/Makefile.am +415 -0
  45. data/ext/libmemcached-0.32/docs/Makefile.in +918 -0
  46. data/ext/libmemcached-0.32/docs/libmemcached.pod +123 -0
  47. data/ext/libmemcached-0.32/docs/libmemcached_examples.pod +115 -0
  48. data/ext/libmemcached-0.32/docs/libmemcachedutil.pod +40 -0
  49. data/ext/libmemcached-0.32/docs/memcached_analyze.pod +52 -0
  50. data/ext/libmemcached-0.32/docs/memcached_auto.pod +97 -0
  51. data/ext/libmemcached-0.32/docs/memcached_behavior.pod +224 -0
  52. data/ext/libmemcached-0.32/docs/memcached_callback.pod +123 -0
  53. data/ext/libmemcached-0.32/docs/memcached_create.pod +61 -0
  54. data/ext/libmemcached-0.32/docs/memcached_delete.pod +54 -0
  55. data/ext/libmemcached-0.32/docs/memcached_dump.pod +53 -0
  56. data/ext/libmemcached-0.32/docs/memcached_flush.pod +46 -0
  57. data/ext/libmemcached-0.32/docs/memcached_flush_buffers.pod +42 -0
  58. data/ext/libmemcached-0.32/docs/memcached_generate_hash_value.pod +57 -0
  59. data/ext/libmemcached-0.32/docs/memcached_get.pod +161 -0
  60. data/ext/libmemcached-0.32/docs/memcached_memory_allocators.pod +73 -0
  61. data/ext/libmemcached-0.32/docs/memcached_pool.pod +77 -0
  62. data/ext/libmemcached-0.32/docs/memcached_quit.pod +47 -0
  63. data/ext/libmemcached-0.32/docs/memcached_sasl.pod +63 -0
  64. data/ext/libmemcached-0.32/docs/memcached_server_st.pod +75 -0
  65. data/ext/libmemcached-0.32/docs/memcached_servers.pod +102 -0
  66. data/ext/libmemcached-0.32/docs/memcached_set.pod +187 -0
  67. data/ext/libmemcached-0.32/docs/memcached_stats.pod +82 -0
  68. data/ext/libmemcached-0.32/docs/memcached_strerror.pod +46 -0
  69. data/ext/libmemcached-0.32/docs/memcached_user_data.pod +49 -0
  70. data/ext/libmemcached-0.32/docs/memcached_verbosity.pod +41 -0
  71. data/ext/libmemcached-0.32/docs/memcached_version.pod +56 -0
  72. data/ext/libmemcached-0.32/docs/memcat.pod +37 -0
  73. data/ext/libmemcached-0.32/docs/memcp.pod +40 -0
  74. data/ext/libmemcached-0.32/docs/memdump.pod +31 -0
  75. data/ext/libmemcached-0.32/docs/memerror.pod +30 -0
  76. data/ext/libmemcached-0.32/docs/memflush.pod +35 -0
  77. data/ext/libmemcached-0.32/docs/memrm.pod +34 -0
  78. data/ext/libmemcached-0.32/docs/memslap.pod +33 -0
  79. data/ext/libmemcached-0.32/docs/memstat.pod +35 -0
  80. data/ext/libmemcached-0.32/libmemcached/Makefile.am +107 -0
  81. data/ext/libmemcached-0.32/libmemcached/Makefile.in +1050 -0
  82. data/ext/libmemcached-0.32/libmemcached/byteorder.c +31 -0
  83. data/ext/libmemcached-0.32/libmemcached/common.h +183 -0
  84. data/ext/libmemcached-0.32/libmemcached/crc.c +86 -0
  85. data/ext/libmemcached-0.32/libmemcached/hsieh_hash.c +68 -0
  86. data/ext/libmemcached-0.32/libmemcached/jenkins_hash.c +213 -0
  87. data/ext/libmemcached-0.32/libmemcached/libmemcached.ver +1 -0
  88. data/ext/libmemcached-0.32/libmemcached/libmemcached_probes.d +28 -0
  89. data/ext/libmemcached-0.32/libmemcached/libmemcached_probes.h +78 -0
  90. data/ext/libmemcached-0.32/libmemcached/md5.c +354 -0
  91. data/ext/libmemcached-0.32/libmemcached/memcached.c +152 -0
  92. data/ext/libmemcached-0.32/libmemcached/memcached.h +302 -0
  93. data/ext/libmemcached-0.32/libmemcached/memcached.hpp +799 -0
  94. data/ext/libmemcached-0.32/libmemcached/memcached/README.txt +7 -0
  95. data/ext/libmemcached-0.32/libmemcached/memcached/protocol_binary.h +366 -0
  96. data/ext/libmemcached-0.32/libmemcached/memcached_allocators.c +72 -0
  97. data/ext/libmemcached-0.32/libmemcached/memcached_analyze.c +100 -0
  98. data/ext/libmemcached-0.32/libmemcached/memcached_auto.c +207 -0
  99. data/ext/libmemcached-0.32/libmemcached/memcached_behavior.c +285 -0
  100. data/ext/libmemcached-0.32/libmemcached/memcached_callback.c +175 -0
  101. data/ext/libmemcached-0.32/libmemcached/memcached_configure.h.in +23 -0
  102. data/ext/libmemcached-0.32/libmemcached/memcached_connect.c +361 -0
  103. data/ext/libmemcached-0.32/libmemcached/memcached_constants.h +145 -0
  104. data/ext/libmemcached-0.32/libmemcached/memcached_delete.c +0 -0
  105. data/ext/libmemcached-0.32/libmemcached/memcached_do.c +34 -0
  106. data/ext/libmemcached-0.32/libmemcached/memcached_dump.c +79 -0
  107. data/ext/libmemcached-0.32/libmemcached/memcached_fetch.c +102 -0
  108. data/ext/libmemcached-0.32/libmemcached/memcached_flush.c +89 -0
  109. data/ext/libmemcached-0.32/libmemcached/memcached_flush_buffers.c +22 -0
  110. data/ext/libmemcached-0.32/libmemcached/memcached_get.c +495 -0
  111. data/ext/libmemcached-0.32/libmemcached/memcached_get.h +87 -0
  112. data/ext/libmemcached-0.32/libmemcached/memcached_hash.c +252 -0
  113. data/ext/libmemcached-0.32/libmemcached/memcached_hosts.c +510 -0
  114. data/ext/libmemcached-0.32/libmemcached/memcached_internal.h +31 -0
  115. data/ext/libmemcached-0.32/libmemcached/memcached_io.c +547 -0
  116. data/ext/libmemcached-0.32/libmemcached/memcached_io.h +59 -0
  117. data/ext/libmemcached-0.32/libmemcached/memcached_key.c +28 -0
  118. data/ext/libmemcached-0.32/libmemcached/memcached_parse.c +74 -0
  119. data/ext/libmemcached-0.32/libmemcached/memcached_pool.h +38 -0
  120. data/ext/libmemcached-0.32/libmemcached/memcached_purge.c +76 -0
  121. data/ext/libmemcached-0.32/libmemcached/memcached_quit.c +75 -0
  122. data/ext/libmemcached-0.32/libmemcached/memcached_response.c +528 -0
  123. data/ext/libmemcached-0.32/libmemcached/memcached_result.c +57 -0
  124. data/ext/libmemcached-0.32/libmemcached/memcached_result.h +59 -0
  125. data/ext/libmemcached-0.32/libmemcached/memcached_sasl.c +225 -0
  126. data/ext/libmemcached-0.32/libmemcached/memcached_sasl.h +44 -0
  127. data/ext/libmemcached-0.32/libmemcached/memcached_server.c +159 -0
  128. data/ext/libmemcached-0.32/libmemcached/memcached_server.h +93 -0
  129. data/ext/libmemcached-0.32/libmemcached/memcached_stats.c +454 -0
  130. data/ext/libmemcached-0.32/libmemcached/memcached_storage.c +514 -0
  131. data/ext/libmemcached-0.32/libmemcached/memcached_storage.h +107 -0
  132. data/ext/libmemcached-0.32/libmemcached/memcached_strerror.c +92 -0
  133. data/ext/libmemcached-0.32/libmemcached/memcached_string.c +138 -0
  134. data/ext/libmemcached-0.32/libmemcached/memcached_string.h +53 -0
  135. data/ext/libmemcached-0.32/libmemcached/memcached_types.h +44 -0
  136. data/ext/libmemcached-0.32/libmemcached/memcached_util.h +15 -0
  137. data/ext/libmemcached-0.32/libmemcached/memcached_verbosity.c +36 -0
  138. data/ext/libmemcached-0.32/libmemcached/memcached_version.c +112 -0
  139. data/ext/libmemcached-0.32/libmemcached/memcached_watchpoint.h +38 -0
  140. data/ext/libmemcached-0.32/libmemcached/murmur_hash.c +76 -0
  141. data/ext/libmemcached-0.32/libmemcached/visibility.h +51 -0
  142. data/ext/libmemcached-0.32/libmemcachedutil/Makefile.am +11 -0
  143. data/ext/libmemcached-0.32/libmemcachedutil/Makefile.in +602 -0
  144. data/ext/libmemcached-0.32/libmemcachedutil/libmemcachedutil.ver +1 -0
  145. data/ext/libmemcached-0.32/libmemcachedutil/memcached_pool.c +170 -0
  146. data/ext/libmemcached-0.32/m4/ac_cxx_compile_stdcxx_0x.m4 +103 -0
  147. data/ext/libmemcached-0.32/m4/ac_cxx_header_stdcxx_98.m4 +67 -0
  148. data/ext/libmemcached-0.32/m4/acx_pthread.m4 +276 -0
  149. data/ext/libmemcached-0.32/m4/byteorder.m4 +40 -0
  150. data/ext/libmemcached-0.32/m4/deprecated.m4 +17 -0
  151. data/ext/libmemcached-0.32/m4/enable_utillib.m4 +16 -0
  152. data/ext/libmemcached-0.32/m4/extensions.m4 +94 -0
  153. data/ext/libmemcached-0.32/m4/hsieh.m4 +18 -0
  154. data/ext/libmemcached-0.32/m4/lib-prefix.m4 +221 -0
  155. data/ext/libmemcached-0.32/m4/libtool.m4 +7360 -0
  156. data/ext/libmemcached-0.32/m4/ltoptions.m4 +368 -0
  157. data/ext/libmemcached-0.32/m4/ltsugar.m4 +123 -0
  158. data/ext/libmemcached-0.32/m4/ltversion.m4 +23 -0
  159. data/ext/libmemcached-0.32/m4/lt~obsolete.m4 +92 -0
  160. data/ext/libmemcached-0.32/m4/memcached.m4 +30 -0
  161. data/ext/libmemcached-0.32/m4/pandora_64bit.m4 +55 -0
  162. data/ext/libmemcached-0.32/m4/pandora_canonical.m4 +151 -0
  163. data/ext/libmemcached-0.32/m4/pandora_check_compiler_version.m4 +37 -0
  164. data/ext/libmemcached-0.32/m4/pandora_check_cxx_standard.m4 +16 -0
  165. data/ext/libmemcached-0.32/m4/pandora_enable_dtrace.m4 +41 -0
  166. data/ext/libmemcached-0.32/m4/pandora_ensure_gcc_version.m4 +36 -0
  167. data/ext/libmemcached-0.32/m4/pandora_have_better_malloc.m4 +54 -0
  168. data/ext/libmemcached-0.32/m4/pandora_have_sasl.m4 +133 -0
  169. data/ext/libmemcached-0.32/m4/pandora_header_assert.m4 +23 -0
  170. data/ext/libmemcached-0.32/m4/pandora_libtool.m4 +15 -0
  171. data/ext/libmemcached-0.32/m4/pandora_optimize.m4 +79 -0
  172. data/ext/libmemcached-0.32/m4/pandora_shared_ptr.m4 +56 -0
  173. data/ext/libmemcached-0.32/m4/pandora_vc_build.m4 +32 -0
  174. data/ext/libmemcached-0.32/m4/pandora_warnings.m4 +262 -0
  175. data/ext/libmemcached-0.32/m4/pod2man.m4 +7 -0
  176. data/ext/libmemcached-0.32/m4/protocol_binary.m4 +23 -0
  177. data/ext/libmemcached-0.32/m4/setsockopt.m4 +57 -0
  178. data/ext/libmemcached-0.32/m4/visibility.m4 +52 -0
  179. data/ext/libmemcached-0.32/support/Makefile.am +4 -0
  180. data/ext/libmemcached-0.32/support/Makefile.in +485 -0
  181. data/ext/libmemcached-0.32/support/libmemcached-fc.spec.in +105 -0
  182. data/ext/libmemcached-0.32/support/libmemcached.pc.in +10 -0
  183. data/ext/libmemcached-0.32/support/libmemcached.spec +105 -0
  184. data/ext/libmemcached-0.32/support/libmemcached.spec.in +105 -0
  185. data/ext/libmemcached-0.32/support/set_benchmark.sh +5 -0
  186. data/ext/libmemcached-0.32/tests/Makefile.am +105 -0
  187. data/ext/libmemcached-0.32/tests/Makefile.in +748 -0
  188. data/ext/libmemcached-0.32/tests/atomsmasher.c +245 -0
  189. data/ext/libmemcached-0.32/tests/function.c +4781 -0
  190. data/ext/libmemcached-0.32/tests/ketama_test_cases.h +108 -0
  191. data/ext/libmemcached-0.32/tests/output.cmp +7 -0
  192. data/ext/libmemcached-0.32/tests/output.res +7 -0
  193. data/ext/libmemcached-0.32/tests/output2.res +46 -0
  194. data/ext/libmemcached-0.32/tests/plus.cpp +293 -0
  195. data/ext/libmemcached-0.32/tests/r/memcat.res +19 -0
  196. data/ext/libmemcached-0.32/tests/r/memcp.res +27 -0
  197. data/ext/libmemcached-0.32/tests/r/memrm.res +19 -0
  198. data/ext/libmemcached-0.32/tests/r/memslap.res +33 -0
  199. data/ext/libmemcached-0.32/tests/r/memstat.res +33 -0
  200. data/ext/libmemcached-0.32/tests/server.c +118 -0
  201. data/ext/libmemcached-0.32/tests/server.h +25 -0
  202. data/ext/libmemcached-0.32/tests/start.c +16 -0
  203. data/ext/libmemcached-0.32/tests/t/memcat.test +4 -0
  204. data/ext/libmemcached-0.32/tests/t/memcp.test +3 -0
  205. data/ext/libmemcached-0.32/tests/t/memrm.test +3 -0
  206. data/ext/libmemcached-0.32/tests/t/memslap.test +5 -0
  207. data/ext/libmemcached-0.32/tests/t/memstat.test +3 -0
  208. data/ext/libmemcached-0.32/tests/test.c +137 -0
  209. data/ext/libmemcached-0.32/tests/test.h +46 -0
  210. data/ext/libmemcached-0.32/tests/udp.c +76 -0
  211. data/memcached.gemspec +4 -4
  212. data/test/unit/memcached_test.rb +30 -0
  213. metadata +213 -16
  214. data/ext/libmemcached-0.32.tar.gz +0 -0
  215. data/ext/libmemcached-1.patch +0 -270
  216. data/ext/libmemcached-10.patch +0 -12
  217. data/ext/libmemcached-2.patch +0 -116
  218. data/ext/libmemcached-3.patch +0 -8
  219. data/ext/libmemcached-4.patch +0 -40
  220. data/ext/libmemcached-5.patch +0 -832
  221. data/ext/libmemcached-6.patch +0 -20
  222. data/ext/libmemcached-7.patch +0 -2989
  223. data/ext/libmemcached-8.patch +0 -137
  224. data/ext/libmemcached-9.patch +0 -13
  225. data/ext/sasl.patch +0 -29283
@@ -0,0 +1 @@
1
+ libmemcachedutil_0 { global: *; };
@@ -0,0 +1,170 @@
1
+ #include "libmemcached/common.h"
2
+ #include "libmemcached/memcached_pool.h"
3
+
4
+ #include <errno.h>
5
+ #include <pthread.h>
6
+
7
+ struct memcached_pool_st
8
+ {
9
+ pthread_mutex_t mutex;
10
+ pthread_cond_t cond;
11
+ memcached_st *master;
12
+ memcached_st **mmc;
13
+ int firstfree;
14
+ uint32_t size;
15
+ uint32_t current_size;
16
+ };
17
+
18
+ static memcached_return mutex_enter(pthread_mutex_t *mutex)
19
+ {
20
+ int ret;
21
+ do
22
+ ret= pthread_mutex_lock(mutex);
23
+ while (ret == -1 && errno == EINTR);
24
+
25
+ return (ret == -1) ? MEMCACHED_ERRNO : MEMCACHED_SUCCESS;
26
+ }
27
+
28
+ static memcached_return mutex_exit(pthread_mutex_t *mutex) {
29
+ int ret;
30
+ do
31
+ ret= pthread_mutex_unlock(mutex);
32
+ while (ret == -1 && errno == EINTR);
33
+
34
+ return (ret == -1) ? MEMCACHED_ERRNO : MEMCACHED_SUCCESS;
35
+ }
36
+
37
+ /**
38
+ * Grow the connection pool by creating a connection structure and clone the
39
+ * original memcached handle.
40
+ */
41
+ static int grow_pool(memcached_pool_st* pool) {
42
+ memcached_st *obj= calloc(1, sizeof(*obj));
43
+ if (obj == NULL)
44
+ return -1;
45
+
46
+ if (memcached_clone(obj, pool->master) == NULL)
47
+ {
48
+ free(obj);
49
+ return -1;
50
+ }
51
+
52
+ pool->mmc[++pool->firstfree] = obj;
53
+ pool->current_size++;
54
+
55
+ return 0;
56
+ }
57
+
58
+ memcached_pool_st *memcached_pool_create(memcached_st* mmc,
59
+ uint32_t initial, uint32_t max)
60
+ {
61
+ memcached_pool_st* ret = NULL;
62
+ memcached_pool_st object = { .mutex = PTHREAD_MUTEX_INITIALIZER,
63
+ .cond = PTHREAD_COND_INITIALIZER,
64
+ .master = mmc,
65
+ .mmc = calloc(max, sizeof(memcached_st*)),
66
+ .firstfree = -1,
67
+ .size = max,
68
+ .current_size = 0 };
69
+
70
+ if (object.mmc != NULL)
71
+ {
72
+ ret= calloc(1, sizeof(*ret));
73
+ if (ret == NULL)
74
+ {
75
+ free(object.mmc);
76
+ return NULL;
77
+ }
78
+
79
+ *ret = object;
80
+
81
+ /* Try to create the initial size of the pool. An allocation failure at
82
+ * this time is not fatal..
83
+ */
84
+ for (unsigned int ii=0; ii < initial; ++ii)
85
+ if (grow_pool(ret) == -1)
86
+ break;
87
+ }
88
+
89
+ return ret;
90
+ }
91
+
92
+ memcached_st* memcached_pool_destroy(memcached_pool_st* pool)
93
+ {
94
+ memcached_st *ret = pool->master;
95
+
96
+ for (int xx= 0; xx <= pool->firstfree; ++xx)
97
+ {
98
+ memcached_free(pool->mmc[xx]);
99
+ free(pool->mmc[xx]);
100
+ pool->mmc[xx] = NULL;
101
+ }
102
+
103
+ pthread_mutex_destroy(&pool->mutex);
104
+ pthread_cond_destroy(&pool->cond);
105
+ free(pool->mmc);
106
+ free(pool);
107
+
108
+ return ret;
109
+ }
110
+
111
+ memcached_st* memcached_pool_pop(memcached_pool_st* pool,
112
+ bool block,
113
+ memcached_return *rc)
114
+ {
115
+ memcached_st *ret= NULL;
116
+ if ((*rc= mutex_enter(&pool->mutex)) != MEMCACHED_SUCCESS)
117
+ return NULL;
118
+
119
+ do
120
+ {
121
+ if (pool->firstfree > -1)
122
+ ret= pool->mmc[pool->firstfree--];
123
+ else if (pool->current_size == pool->size)
124
+ {
125
+ if (!block)
126
+ {
127
+ *rc= mutex_exit(&pool->mutex);
128
+ return NULL;
129
+ }
130
+
131
+ if (pthread_cond_wait(&pool->cond, &pool->mutex) == -1)
132
+ {
133
+ int err = errno;
134
+ mutex_exit(&pool->mutex);
135
+ errno = err;
136
+ *rc= MEMCACHED_ERRNO;
137
+ return NULL;
138
+ }
139
+ }
140
+ else if (grow_pool(pool) == -1)
141
+ {
142
+ *rc= mutex_exit(&pool->mutex);
143
+ return NULL;
144
+ }
145
+ }
146
+ while (ret == NULL);
147
+
148
+ *rc= mutex_exit(&pool->mutex);
149
+
150
+ return ret;
151
+ }
152
+
153
+ memcached_return memcached_pool_push(memcached_pool_st* pool,
154
+ memcached_st *mmc)
155
+ {
156
+ memcached_return rc= mutex_enter(&pool->mutex);
157
+
158
+ if (rc != MEMCACHED_SUCCESS)
159
+ return rc;
160
+
161
+ pool->mmc[++pool->firstfree]= mmc;
162
+
163
+ if (pool->firstfree == 0 && pool->current_size == pool->size)
164
+ {
165
+ /* we might have people waiting for a connection.. wake them up :-) */
166
+ pthread_cond_broadcast(&pool->cond);
167
+ }
168
+
169
+ return mutex_exit(&pool->mutex);
170
+ }
@@ -0,0 +1,103 @@
1
+ # ===========================================================================
2
+ # http://autoconf-archive.cryp.to/ac_cxx_compile_stdcxx_0x.html
3
+ # ===========================================================================
4
+ #
5
+ # SYNOPSIS
6
+ #
7
+ # AC_CXX_COMPILE_STDCXX_0X
8
+ #
9
+ # DESCRIPTION
10
+ #
11
+ # Check for baseline language coverage in the compiler for the C++0x
12
+ # standard.
13
+ #
14
+ # LICENSE
15
+ #
16
+ # Copyright (c) 2008 Benjamin Kosnik <bkoz@redhat.com>
17
+ #
18
+ # Copying and distribution of this file, with or without modification, are
19
+ # permitted in any medium without royalty provided the copyright notice
20
+ # and this notice are preserved.
21
+
22
+ AC_DEFUN([AC_CXX_COMPILE_STDCXX_0X], [
23
+ AC_CACHE_CHECK(if g++ supports C++0x features without additional flags,
24
+ ac_cv_cxx_compile_cxx0x_native,
25
+ [AC_LANG_SAVE
26
+ AC_LANG_CPLUSPLUS
27
+ AC_TRY_COMPILE([
28
+ template <typename T>
29
+ struct check
30
+ {
31
+ static_assert(sizeof(int) <= sizeof(T), "not big enough");
32
+ };
33
+
34
+ typedef check<check<bool>> right_angle_brackets;
35
+
36
+ int a;
37
+ decltype(a) b;
38
+
39
+ typedef check<int> check_type;
40
+ check_type c;
41
+ check_type&& cr = c;],,
42
+ ac_cv_cxx_compile_cxx0x_native=yes, ac_cv_cxx_compile_cxx0x_native=no)
43
+ AC_LANG_RESTORE
44
+ ])
45
+
46
+ AC_CACHE_CHECK(if g++ supports C++0x features with -std=c++0x,
47
+ ac_cv_cxx_compile_cxx0x_cxx,
48
+ [AC_LANG_SAVE
49
+ AC_LANG_CPLUSPLUS
50
+ ac_save_CXXFLAGS="$CXXFLAGS"
51
+ CXXFLAGS="$CXXFLAGS -std=c++0x"
52
+ AC_TRY_COMPILE([
53
+ template <typename T>
54
+ struct check
55
+ {
56
+ static_assert(sizeof(int) <= sizeof(T), "not big enough");
57
+ };
58
+
59
+ typedef check<check<bool>> right_angle_brackets;
60
+
61
+ int a;
62
+ decltype(a) b;
63
+
64
+ typedef check<int> check_type;
65
+ check_type c;
66
+ check_type&& cr = c;],,
67
+ ac_cv_cxx_compile_cxx0x_cxx=yes, ac_cv_cxx_compile_cxx0x_cxx=no)
68
+ CXXFLAGS="$ac_save_CXXFLAGS"
69
+ AC_LANG_RESTORE
70
+ ])
71
+
72
+ AC_CACHE_CHECK(if g++ supports C++0x features with -std=gnu++0x,
73
+ ac_cv_cxx_compile_cxx0x_gxx,
74
+ [AC_LANG_SAVE
75
+ AC_LANG_CPLUSPLUS
76
+ ac_save_CXXFLAGS="$CXXFLAGS"
77
+ CXXFLAGS="$CXXFLAGS -std=gnu++0x"
78
+ AC_TRY_COMPILE([
79
+ template <typename T>
80
+ struct check
81
+ {
82
+ static_assert(sizeof(int) <= sizeof(T), "not big enough");
83
+ };
84
+
85
+ typedef check<check<bool>> right_angle_brackets;
86
+
87
+ int a;
88
+ decltype(a) b;
89
+
90
+ typedef check<int> check_type;
91
+ check_type c;
92
+ check_type&& cr = c;],,
93
+ ac_cv_cxx_compile_cxx0x_gxx=yes, ac_cv_cxx_compile_cxx0x_gxx=no)
94
+ CXXFLAGS="$ac_save_CXXFLAGS"
95
+ AC_LANG_RESTORE
96
+ ])
97
+
98
+ if test "$ac_cv_cxx_compile_cxx0x_native" = yes ||
99
+ test "$ac_cv_cxx_compile_cxx0x_cxx" = yes ||
100
+ test "$ac_cv_cxx_compile_cxx0x_gxx" = yes; then
101
+ AC_DEFINE(HAVE_STDCXX_0X,,[Define if g++ supports C++0x features. ])
102
+ fi
103
+ ])
@@ -0,0 +1,67 @@
1
+ dnl Copyright © 2008 Benjamin Kosnik <bkoz@redhat.com>
2
+
3
+ dnl Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved.
4
+
5
+
6
+ AC_DEFUN([AC_CXX_HEADER_STDCXX_98], [
7
+ AC_CACHE_CHECK(for ISO C++ 98 include files,
8
+ ac_cv_cxx_stdcxx_98,
9
+ [AC_LANG_PUSH(C++)
10
+ AC_TRY_COMPILE([
11
+ #include <cassert>
12
+ #include <cctype>
13
+ #include <cerrno>
14
+ #include <cfloat>
15
+ #include <ciso646>
16
+ #include <climits>
17
+ #include <clocale>
18
+ #include <cmath>
19
+ #include <csetjmp>
20
+ #include <csignal>
21
+ #include <cstdarg>
22
+ #include <cstddef>
23
+ #include <cstdio>
24
+ #include <cstdlib>
25
+ #include <cstring>
26
+ #include <ctime>
27
+
28
+ #include <algorithm>
29
+ #include <bitset>
30
+ #include <complex>
31
+ #include <deque>
32
+ #include <exception>
33
+ #include <fstream>
34
+ #include <functional>
35
+ #include <iomanip>
36
+ #include <ios>
37
+ #include <iosfwd>
38
+ #include <iostream>
39
+ #include <istream>
40
+ #include <iterator>
41
+ #include <limits>
42
+ #include <list>
43
+ #include <locale>
44
+ #include <map>
45
+ #include <memory>
46
+ #include <new>
47
+ #include <numeric>
48
+ #include <ostream>
49
+ #include <queue>
50
+ #include <set>
51
+ #include <sstream>
52
+ #include <stack>
53
+ #include <stdexcept>
54
+ #include <streambuf>
55
+ #include <string>
56
+ #include <typeinfo>
57
+ #include <utility>
58
+ #include <valarray>
59
+ #include <vector>
60
+ ],,
61
+ ac_cv_cxx_stdcxx_98=yes, ac_cv_cxx_stdcxx_98=no)
62
+ AC_LANG_POP()
63
+ ])
64
+ if test "$ac_cv_cxx_stdcxx_98" = yes; then
65
+ AC_DEFINE(STDCXX_98_HEADERS,,[Define if ISO C++ 1998 header files are present. ])
66
+ fi
67
+ ])
@@ -0,0 +1,276 @@
1
+ ##### http://autoconf-archive.cryp.to/acx_pthread.html
2
+ #
3
+ # SYNOPSIS
4
+ #
5
+ # ACX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
6
+ #
7
+ # DESCRIPTION
8
+ #
9
+ # This macro figures out how to build C programs using POSIX threads.
10
+ # It sets the PTHREAD_LIBS output variable to the threads library and
11
+ # linker flags, and the PTHREAD_CFLAGS output variable to any special
12
+ # C compiler flags that are needed. (The user can also force certain
13
+ # compiler flags/libs to be tested by setting these environment
14
+ # variables.)
15
+ #
16
+ # Also sets PTHREAD_CC to any special C compiler that is needed for
17
+ # multi-threaded programs (defaults to the value of CC otherwise).
18
+ # (This is necessary on AIX to use the special cc_r compiler alias.)
19
+ #
20
+ # NOTE: You are assumed to not only compile your program with these
21
+ # flags, but also link it with them as well. e.g. you should link
22
+ # with $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS
23
+ # $LIBS
24
+ #
25
+ # If you are only building threads programs, you may wish to use
26
+ # these variables in your default LIBS, CFLAGS, and CC:
27
+ #
28
+ # LIBS="$PTHREAD_LIBS $LIBS"
29
+ # CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
30
+ # CC="$PTHREAD_CC"
31
+ #
32
+ # In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute
33
+ # constant has a nonstandard name, defines PTHREAD_CREATE_JOINABLE to
34
+ # that name (e.g. PTHREAD_CREATE_UNDETACHED on AIX).
35
+ #
36
+ # ACTION-IF-FOUND is a list of shell commands to run if a threads
37
+ # library is found, and ACTION-IF-NOT-FOUND is a list of commands to
38
+ # run it if it is not found. If ACTION-IF-FOUND is not specified, the
39
+ # default action will define HAVE_PTHREAD.
40
+ #
41
+ # Please let the authors know if this macro fails on any platform, or
42
+ # if you have any other suggestions or comments. This macro was based
43
+ # on work by SGJ on autoconf scripts for FFTW (http://www.fftw.org/)
44
+ # (with help from M. Frigo), as well as ac_pthread and hb_pthread
45
+ # macros posted by Alejandro Forero Cuervo to the autoconf macro
46
+ # repository. We are also grateful for the helpful feedback of
47
+ # numerous users.
48
+ #
49
+ # LAST MODIFICATION
50
+ #
51
+ # 2006-05-29
52
+ #
53
+ # COPYLEFT
54
+ #
55
+ # Copyright (c) 2006 Steven G. Johnson <stevenj@alum.mit.edu>
56
+ #
57
+ # This program is free software; you can redistribute it and/or
58
+ # modify it under the terms of the GNU General Public License as
59
+ # published by the Free Software Foundation; either version 2 of the
60
+ # License, or (at your option) any later version.
61
+ #
62
+ # This program is distributed in the hope that it will be useful, but
63
+ # WITHOUT ANY WARRANTY; without even the implied warranty of
64
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
65
+ # General Public License for more details.
66
+ #
67
+ # You should have received a copy of the GNU General Public License
68
+ # along with this program; if not, write to the Free Software
69
+ # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
70
+ # 02111-1307, USA.
71
+ #
72
+ # As a special exception, the respective Autoconf Macro's copyright
73
+ # owner gives unlimited permission to copy, distribute and modify the
74
+ # configure scripts that are the output of Autoconf when processing
75
+ # the Macro. You need not follow the terms of the GNU General Public
76
+ # License when using or distributing such scripts, even though
77
+ # portions of the text of the Macro appear in them. The GNU General
78
+ # Public License (GPL) does govern all other use of the material that
79
+ # constitutes the Autoconf Macro.
80
+ #
81
+ # This special exception to the GPL applies to versions of the
82
+ # Autoconf Macro released by the Autoconf Macro Archive. When you
83
+ # make and distribute a modified version of the Autoconf Macro, you
84
+ # may extend this special exception to the GPL to apply to your
85
+ # modified version as well.
86
+
87
+ AC_DEFUN([ACX_PTHREAD], [
88
+ AC_REQUIRE([AC_CANONICAL_HOST])
89
+ AC_LANG_PUSH([C])
90
+ acx_pthread_ok=no
91
+
92
+ # We used to check for pthread.h first, but this fails if pthread.h
93
+ # requires special compiler flags (e.g. on True64 or Sequent).
94
+ # It gets checked for in the link test anyway.
95
+
96
+ # First of all, check if the user has set any of the PTHREAD_LIBS,
97
+ # etcetera environment variables, and if threads linking works using
98
+ # them:
99
+ if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then
100
+ save_CFLAGS="$CFLAGS"
101
+ CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
102
+ save_LIBS="$LIBS"
103
+ LIBS="$PTHREAD_LIBS $LIBS"
104
+ AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS])
105
+ AC_TRY_LINK_FUNC(pthread_join, acx_pthread_ok=yes)
106
+ AC_MSG_RESULT($acx_pthread_ok)
107
+ if test x"$acx_pthread_ok" = xno; then
108
+ PTHREAD_LIBS=""
109
+ PTHREAD_CFLAGS=""
110
+ fi
111
+ LIBS="$save_LIBS"
112
+ CFLAGS="$save_CFLAGS"
113
+ fi
114
+
115
+ # We must check for the threads library under a number of different
116
+ # names; the ordering is very important because some systems
117
+ # (e.g. DEC) have both -lpthread and -lpthreads, where one of the
118
+ # libraries is broken (non-POSIX).
119
+
120
+ # Create a list of thread flags to try. Items starting with a "-" are
121
+ # C compiler flags, and other items are library names, except for "none"
122
+ # which indicates that we try without any flags at all, and "pthread-config"
123
+ # which is a program returning the flags for the Pth emulation library.
124
+
125
+ acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config"
126
+
127
+ # The ordering *is* (sometimes) important. Some notes on the
128
+ # individual items follow:
129
+
130
+ # pthreads: AIX (must check this before -lpthread)
131
+ # none: in case threads are in libc; should be tried before -Kthread and
132
+ # other compiler flags to prevent continual compiler warnings
133
+ # -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
134
+ # -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
135
+ # lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
136
+ # -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads)
137
+ # -pthreads: Solaris/gcc
138
+ # -mthreads: Mingw32/gcc, Lynx/gcc
139
+ # -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
140
+ # doesn't hurt to check since this sometimes defines pthreads too;
141
+ # also defines -D_REENTRANT)
142
+ # ... -mt is also the pthreads flag for HP/aCC
143
+ # pthread: Linux, etcetera
144
+ # --thread-safe: KAI C++
145
+ # pthread-config: use pthread-config program (for GNU Pth library)
146
+
147
+ case "${host_cpu}-${host_os}" in
148
+ *solaris*)
149
+
150
+ # On Solaris (at least, for some versions), libc contains stubbed
151
+ # (non-functional) versions of the pthreads routines, so link-based
152
+ # tests will erroneously succeed. (We need to link with -pthreads/-mt/
153
+ # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather
154
+ # a function called by this macro, so we could check for that, but
155
+ # who knows whether they'll stub that too in a future libc.) So,
156
+ # we'll just look for -pthreads and -lpthread first:
157
+
158
+ acx_pthread_flags="-pthreads pthread -mt -pthread $acx_pthread_flags"
159
+ ;;
160
+ esac
161
+
162
+ if test x"$acx_pthread_ok" = xno; then
163
+ for flag in $acx_pthread_flags; do
164
+
165
+ case $flag in
166
+ none)
167
+ AC_MSG_CHECKING([whether pthreads work without any flags])
168
+ ;;
169
+
170
+ -*)
171
+ AC_MSG_CHECKING([whether pthreads work with $flag])
172
+ PTHREAD_CFLAGS="$flag"
173
+ ;;
174
+
175
+ pthread-config)
176
+ AC_CHECK_PROG(acx_pthread_config, pthread-config, yes, no)
177
+ if test x"$acx_pthread_config" = xno; then continue; fi
178
+ PTHREAD_CFLAGS="`pthread-config --cflags`"
179
+ PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
180
+ ;;
181
+
182
+ *)
183
+ AC_MSG_CHECKING([for the pthreads library -l$flag])
184
+ PTHREAD_LIBS="-l$flag"
185
+ ;;
186
+ esac
187
+
188
+ save_LIBS="$LIBS"
189
+ save_CFLAGS="$CFLAGS"
190
+ LIBS="$PTHREAD_LIBS $LIBS"
191
+ CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
192
+
193
+ # Check for various functions. We must include pthread.h,
194
+ # since some functions may be macros. (On the Sequent, we
195
+ # need a special flag -Kthread to make this header compile.)
196
+ # We check for pthread_join because it is in -lpthread on IRIX
197
+ # while pthread_create is in libc. We check for pthread_attr_init
198
+ # due to DEC craziness with -lpthreads. We check for
199
+ # pthread_cleanup_push because it is one of the few pthread
200
+ # functions on Solaris that doesn't have a non-functional libc stub.
201
+ # We try pthread_create on general principles.
202
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <pthread.h>]], [[pthread_t th; pthread_join(th, 0);
203
+ pthread_attr_init(0); pthread_cleanup_push(0, 0);
204
+ pthread_create(0,0,0,0); pthread_cleanup_pop(0); ]])],[acx_pthread_ok=yes],[])
205
+
206
+ LIBS="$save_LIBS"
207
+ CFLAGS="$save_CFLAGS"
208
+
209
+ AC_MSG_RESULT($acx_pthread_ok)
210
+ if test "x$acx_pthread_ok" = xyes; then
211
+ break;
212
+ fi
213
+
214
+ PTHREAD_LIBS=""
215
+ PTHREAD_CFLAGS=""
216
+ done
217
+ fi
218
+
219
+ # Various other checks:
220
+ if test "x$acx_pthread_ok" = xyes; then
221
+ save_LIBS="$LIBS"
222
+ LIBS="$PTHREAD_LIBS $LIBS"
223
+ save_CFLAGS="$CFLAGS"
224
+ CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
225
+
226
+ # Detect AIX lossage: JOINABLE attribute is called UNDETACHED.
227
+ AC_MSG_CHECKING([for joinable pthread attribute])
228
+ attr_name=unknown
229
+ for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
230
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <pthread.h>]], [[int attr=$attr; return attr;]])],[attr_name=$attr; break],[])
231
+ done
232
+ AC_MSG_RESULT($attr_name)
233
+ if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then
234
+ AC_DEFINE_UNQUOTED(PTHREAD_CREATE_JOINABLE, $attr_name,
235
+ [Define to necessary symbol if this constant
236
+ uses a non-standard name on your system.])
237
+ fi
238
+
239
+ AC_MSG_CHECKING([if more special flags are required for pthreads])
240
+ flag=no
241
+ case "${host_cpu}-${host_os}" in
242
+ *-aix* | *-freebsd* | *-darwin*) flag="-D_THREAD_SAFE";;
243
+ *solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";;
244
+ esac
245
+ AC_MSG_RESULT(${flag})
246
+ if test "x$flag" != xno; then
247
+ PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS"
248
+ fi
249
+
250
+ LIBS="$save_LIBS"
251
+ CFLAGS="$save_CFLAGS"
252
+
253
+ # More AIX lossage: must compile with xlc_r or cc_r
254
+ if test x"$GCC" != xyes; then
255
+ AC_CHECK_PROGS(PTHREAD_CC, xlc_r cc_r, ${CC})
256
+ else
257
+ PTHREAD_CC=$CC
258
+ fi
259
+ else
260
+ PTHREAD_CC="$CC"
261
+ fi
262
+
263
+ AC_SUBST(PTHREAD_LIBS)
264
+ AC_SUBST(PTHREAD_CFLAGS)
265
+ AC_SUBST(PTHREAD_CC)
266
+
267
+ # Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
268
+ if test x"$acx_pthread_ok" = xyes; then
269
+ ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1])
270
+ :
271
+ else
272
+ acx_pthread_ok=no
273
+ $2
274
+ fi
275
+ AC_LANG_POP([])
276
+ ])dnl ACX_PTHREAD