Remove another chunck of Pandora.
[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 <config.h>
46
47 #ifdef __cplusplus
48 # include <cstdio>
49 # include <cstdlib>
50 # include <cstring>
51 # include <ctime>
52 # include <cctype>
53 # include <cerrno>
54 # include <climits>
55 #else
56 # ifdef HAVE_STDLIB_H
57 # include <stdio.h>
58 # endif
59 # ifdef HAVE_STDLIB_H
60 # include <stdlib.h>
61 # endif
62 # include <string.h>
63 # include <time.h>
64 # ifdef HAVE_ERRNO_H
65 # include <errno.h>
66 # endif
67 # ifdef HAVE_LIMITS_H
68 # include <limits.h>
69 # endif
70 #endif
71
72 #ifdef HAVE_FCNTL_H
73 # include <fcntl.h>
74 #endif
75
76 #ifdef HAVE_SYS_TYPES_H
77 # include <sys/types.h>
78 #endif
79
80 #ifdef HAVE_UNISTD_H
81 # include <unistd.h>
82 #endif
83
84 #ifdef HAVE_STRINGS_H
85 # include <strings.h>
86 #endif
87
88 #ifdef HAVE_DLFCN_H
89 # include <dlfcn.h>
90 #endif
91
92 #include <libmemcached-1.0/memcached.h>
93 #include <libmemcached/watchpoint.h>
94 #include <libmemcached/is.h>
95
96 #include <libmemcached/instance.h>
97 #include <libmemcached/server_instance.h>
98
99 #ifdef HAVE_POLL_H
100 # include <poll.h>
101 #else
102 # include "poll/poll.h"
103 #endif
104
105 #ifdef __cplusplus
106 extern "C" {
107 #endif
108
109 typedef memcached_return_t (*memcached_server_execute_fn)(memcached_st *ptr, memcached_server_write_instance_st server, void *context);
110
111 #ifdef __cplusplus
112 } // extern "C"
113 #endif
114
115
116 #ifdef __cplusplus
117 org::libmemcached::Instance* memcached_instance_fetch(memcached_st *ptr, uint32_t server_key);
118 #endif
119
120 memcached_return_t memcached_server_execute(memcached_st *ptr,
121 memcached_server_execute_fn callback,
122 void *context);
123 /* These are private not to be installed headers */
124 #include <libmemcached/error.hpp>
125 #include <libmemcached/memory.h>
126 #include <libmemcached/io.h>
127 #ifdef __cplusplus
128 #include <libmemcached/string.hpp>
129 #include <libmemcached/memcached/protocol_binary.h>
130 #include <libmemcached/io.hpp>
131 #include <libmemcached/udp.hpp>
132 #include <libmemcached/do.hpp>
133 #include <libmemcached/socket.hpp>
134 #include <libmemcached/connect.hpp>
135 #include <libmemcached/allocators.hpp>
136 #include <libmemcached/hash.hpp>
137 #include <libmemcached/quit.hpp>
138 #include <libmemcached/instance.hpp>
139 #include <libmemcached/server.hpp>
140 #include <libmemcached/flag.hpp>
141 #include <libmemcached/behavior.hpp>
142 #include <libmemcached/sasl.hpp>
143 #include <libmemcached/server_list.hpp>
144 #endif
145 #include <libmemcached/internal.h>
146 #include <libmemcached/array.h>
147 #include <libmemcached/libmemcached_probes.h>
148 #include <libmemcached/byteorder.h>
149 #include <libmemcached/initialize_query.h>
150 #ifdef __cplusplus
151 #include <libmemcached/response.h>
152 #endif
153 #include <libmemcached/namespace.h>
154 #include <libmemcached/virtual_bucket.h>
155
156 #ifdef __cplusplus
157 #include <libmemcached/backtrace.hpp>
158 #include <libmemcached/assert.hpp>
159 #include <libmemcached/server.hpp>
160 #include <libmemcached/key.hpp>
161 #include <libmemcached/encoding_key.h>
162 #include <libmemcached/result.h>
163 #include <libmemcached/version.hpp>
164 #endif
165
166 #include <libmemcached/continuum.hpp>
167
168 #if !defined(__GNUC__) || (__GNUC__ == 2 && __GNUC_MINOR__ < 96)
169
170 #define likely(x) if((x))
171 #define unlikely(x) if((x))
172
173 #else
174
175 #define likely(x) if(__builtin_expect((x) != 0, 1))
176 #define unlikely(x) if(__builtin_expect((x) != 0, 0))
177 #endif
178
179 #define MEMCACHED_BLOCK_SIZE 1024
180 #define MEMCACHED_DEFAULT_COMMAND_SIZE 350
181 #define SMALL_STRING_LEN 1024
182 #define HUGE_STRING_LEN 8196
183
184 #ifdef __cplusplus
185 extern "C" {
186 #endif
187
188 memcached_return_t run_distribution(memcached_st *ptr);
189
190 #define memcached_server_response_increment(A) (A)->cursor_active_++
191 #define memcached_server_response_decrement(A) (A)->cursor_active_--
192 #define memcached_server_response_reset(A) (A)->cursor_active_=0
193
194 #define memcached_instance_response_increment(A) (A)->cursor_active_++
195 #define memcached_instance_response_decrement(A) (A)->cursor_active_--
196 #define memcached_instance_response_reset(A) (A)->cursor_active_=0
197
198 #ifdef __cplusplus
199 }
200 #endif
201
202 #ifdef __cplusplus
203 bool memcached_purge(org::libmemcached::Instance*);
204 org::libmemcached::Instance* memcached_instance_by_position(const memcached_st *ptr, uint32_t server_key);
205 #endif