Merge lp:~tangent-org/libmemcached/1.0-build/ Build: jenkins-Libmemcached-170
[awesomized/libmemcached] / libmemcached / common.h
1 /* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
2 *
3 * LibMemcached
4 *
5 * Copyright (C) 2011 Data Differential, http://datadifferential.com/
6 * Copyright (C) 2006-2009 Brian Aker
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are
11 * met:
12 *
13 * * Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 *
16 * * Redistributions in binary form must reproduce the above
17 * copyright notice, this list of conditions and the following disclaimer
18 * in the documentation and/or other materials provided with the
19 * distribution.
20 *
21 * * The names of its contributors may not be used to endorse or
22 * promote products derived from this software without specific prior
23 * written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 *
37 */
38
39 /*
40 Common include file for libmemached
41 */
42
43 #pragma once
44
45 #include <mem_config.h>
46
47 #ifdef __cplusplus
48 # include <cstddef>
49 # include <cstdio>
50 # include <cstdlib>
51 # include <cstring>
52 # include <ctime>
53 # include <cctype>
54 # include <cerrno>
55 # include <climits>
56 #else
57 # ifdef HAVE_STDDEF_H
58 # include <stddef.h>
59 # endif
60 # ifdef HAVE_STDLIB_H
61 # include <stdio.h>
62 # endif
63 # ifdef HAVE_STDLIB_H
64 # include <stdlib.h>
65 # endif
66 # include <string.h>
67 # ifdef HAVE_TIME_H
68 # include <time.h>
69 # endif
70 # ifdef HAVE_ERRNO_H
71 # include <errno.h>
72 # endif
73 # ifdef HAVE_LIMITS_H
74 # include <limits.h>
75 # endif
76 #endif
77
78 #ifdef HAVE_SYS_UN_H
79 # include <sys/un.h>
80 #endif
81
82 #ifdef HAVE_SYS_TIME_H
83 # include <sys/time.h>
84 #endif
85
86 #ifdef HAVE_FCNTL_H
87 # include <fcntl.h>
88 #endif
89
90 #ifdef HAVE_SYS_TYPES_H
91 # include <sys/types.h>
92 #endif
93
94 #ifdef HAVE_UNISTD_H
95 # include <unistd.h>
96 #endif
97
98 #ifdef HAVE_SYS_SOCKET_H
99 # include <sys/socket.h>
100 #endif
101
102 #ifdef HAVE_STRINGS_H
103 # include <strings.h>
104 #endif
105
106 #ifdef HAVE_DLFCN_H
107 # include <dlfcn.h>
108 #endif
109
110 #include <libmemcached-1.0/memcached.h>
111 #include <libmemcached/watchpoint.h>
112 #include <libmemcached/is.h>
113
114 #ifdef __cplusplus
115 # include "libmemcached/instance.hpp"
116 #endif
117 #include <libmemcached/server_instance.h>
118
119 #ifdef HAVE_POLL_H
120 # include <poll.h>
121 #else
122 # include "poll/poll.h"
123 #endif
124
125 #ifndef POLLHUP
126 # define POLLHUP 0x0010
127 #endif
128
129 #ifndef POLLNVAL
130 # define POLLNVAL 0x0020
131 #endif
132
133 #ifdef __cplusplus
134 extern "C" {
135 #endif
136
137 typedef memcached_return_t (*memcached_server_execute_fn)(memcached_st *ptr, memcached_server_write_instance_st server, void *context);
138
139 #ifdef __cplusplus
140 } // extern "C"
141 #endif
142
143
144 #ifdef __cplusplus
145 org::libmemcached::Instance* memcached_instance_fetch(memcached_st *ptr, uint32_t server_key);
146 #endif
147
148 memcached_return_t memcached_server_execute(memcached_st *ptr,
149 memcached_server_execute_fn callback,
150 void *context);
151 /* These are private not to be installed headers */
152 #include <libmemcached/error.hpp>
153 #include <libmemcached/memory.h>
154 #include <libmemcached/io.h>
155 #ifdef __cplusplus
156 #include <libmemcached/string.hpp>
157 #include <libmemcached/memcached/protocol_binary.h>
158 #include <libmemcached/io.hpp>
159 #include <libmemcached/udp.hpp>
160 #include <libmemcached/do.hpp>
161 #include <libmemcached/socket.hpp>
162 #include <libmemcached/connect.hpp>
163 #include <libmemcached/allocators.hpp>
164 #include <libmemcached/hash.hpp>
165 #include <libmemcached/quit.hpp>
166 #include <libmemcached/instance.hpp>
167 #include <libmemcached/server.hpp>
168 #include <libmemcached/flag.hpp>
169 #include <libmemcached/behavior.hpp>
170 #include <libmemcached/sasl.hpp>
171 #include <libmemcached/server_list.hpp>
172 #endif
173 #include <libmemcached/internal.h>
174 #include <libmemcached/array.h>
175 #include <libmemcached/libmemcached_probes.h>
176 #include <libmemcached/byteorder.h>
177 #include <libmemcached/initialize_query.h>
178 #ifdef __cplusplus
179 #include <libmemcached/response.h>
180 #endif
181 #include <libmemcached/namespace.h>
182 #include <libmemcached/virtual_bucket.h>
183
184 #ifdef __cplusplus
185 #include <libmemcached/backtrace.hpp>
186 #include <libmemcached/assert.hpp>
187 #include <libmemcached/server.hpp>
188 #include <libmemcached/key.hpp>
189 #include <libmemcached/encoding_key.h>
190 #include <libmemcached/result.h>
191 #include <libmemcached/version.hpp>
192 #endif
193
194 #include <libmemcached/continuum.hpp>
195
196 #if !defined(__GNUC__) || (__GNUC__ == 2 && __GNUC_MINOR__ < 96)
197
198 #define likely(x) if((x))
199 #define unlikely(x) if((x))
200
201 #else
202
203 #define likely(x) if(__builtin_expect((x) != 0, 1))
204 #define unlikely(x) if(__builtin_expect((x) != 0, 0))
205 #endif
206
207 #define MEMCACHED_BLOCK_SIZE 1024
208 #define MEMCACHED_DEFAULT_COMMAND_SIZE 350
209 #define SMALL_STRING_LEN 1024
210 #define HUGE_STRING_LEN 8196
211
212 #ifdef __cplusplus
213 extern "C" {
214 #endif
215
216 memcached_return_t run_distribution(memcached_st *ptr);
217
218 #define memcached_server_response_increment(A) (A)->cursor_active_++
219 #define memcached_server_response_decrement(A) (A)->cursor_active_--
220 #define memcached_server_response_reset(A) (A)->cursor_active_=0
221
222 #define memcached_instance_response_increment(A) (A)->cursor_active_++
223 #define memcached_instance_response_decrement(A) (A)->cursor_active_--
224 #define memcached_instance_response_reset(A) (A)->cursor_active_=0
225
226 #ifdef __cplusplus
227 }
228 #endif
229
230 #ifdef __cplusplus
231 bool memcached_purge(org::libmemcached::Instance*);
232 org::libmemcached::Instance* memcached_instance_by_position(const memcached_st *ptr, uint32_t server_key);
233 #endif