Update all of the build/spec files.
[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 <ctype.h>
53 #else
54 #include <stdio.h>
55 #include <stdlib.h>
56 #include <string.h>
57 #include <time.h>
58 #endif
59
60 #include <errno.h>
61 #include <fcntl.h>
62 #include <limits.h>
63 #include <sys/types.h>
64 #include <unistd.h>
65
66 #ifdef HAVE_STRINGS_H
67 #include <strings.h>
68 #endif
69
70 #include <libmemcached-1.0/memcached.h>
71 #include <libmemcached/watchpoint.h>
72 #include <libmemcached/is.h>
73
74 #include <libmemcached/server_instance.h>
75
76 #ifdef HAVE_POLL_H
77 #include <poll.h>
78 #else
79 #include "poll/poll.h"
80 #endif
81
82
83 #ifdef __cplusplus
84 extern "C" {
85 #endif
86
87 typedef memcached_return_t (*memcached_server_execute_fn)(memcached_st *ptr, memcached_server_write_instance_st server, void *context);
88
89 LIBMEMCACHED_LOCAL
90 memcached_server_write_instance_st memcached_server_instance_fetch(memcached_st *ptr, uint32_t server_key);
91
92 LIBMEMCACHED_LOCAL
93 memcached_return_t memcached_server_execute(memcached_st *ptr,
94 memcached_server_execute_fn callback,
95 void *context);
96 #ifdef __cplusplus
97 } // extern "C"
98 #endif
99
100
101 /* These are private not to be installed headers */
102 #include <libmemcached/error.hpp>
103 #include <libmemcached/memory.h>
104 #include <libmemcached/io.h>
105 #ifdef __cplusplus
106 #include <libmemcached/string.hpp>
107 #include <libmemcached/io.hpp>
108 #include <libmemcached/do.hpp>
109 #endif
110 #include <libmemcached/internal.h>
111 #include <libmemcached/array.h>
112 #include <libmemcached/libmemcached_probes.h>
113 #include <libmemcached/memcached/protocol_binary.h>
114 #include <libmemcached/byteorder.h>
115 #include <libmemcached/initialize_query.h>
116 #include <libmemcached/response.h>
117 #include <libmemcached/namespace.h>
118 #include <libmemcached/virtual_bucket.h>
119
120 #ifdef __cplusplus
121 #include <libmemcached/backtrace.hpp>
122 #include <libmemcached/assert.hpp>
123 #include <libmemcached/server.hpp>
124 #include <libmemcached/key.hpp>
125 #endif
126
127 #include <libmemcached/continuum.hpp>
128
129 #if !defined(__GNUC__) || (__GNUC__ == 2 && __GNUC_MINOR__ < 96)
130
131 #define likely(x) if((x))
132 #define unlikely(x) if((x))
133
134 #else
135
136 #define likely(x) if(__builtin_expect((x) != 0, 1))
137 #define unlikely(x) if(__builtin_expect((x) != 0, 0))
138 #endif
139
140 #define MEMCACHED_BLOCK_SIZE 1024
141 #define MEMCACHED_DEFAULT_COMMAND_SIZE 350
142 #define SMALL_STRING_LEN 1024
143 #define HUGE_STRING_LEN 8196
144
145 #ifdef __cplusplus
146 extern "C" {
147 #endif
148
149 LIBMEMCACHED_LOCAL
150 memcached_return_t memcached_connect(memcached_server_write_instance_st ptr);
151
152 LIBMEMCACHED_LOCAL
153 memcached_return_t run_distribution(memcached_st *ptr);
154
155 #define memcached_server_response_increment(A) (A)->cursor_active++
156 #define memcached_server_response_decrement(A) (A)->cursor_active--
157 #define memcached_server_response_reset(A) (A)->cursor_active=0
158
159 LIBMEMCACHED_LOCAL
160 memcached_return_t memcached_purge(memcached_server_write_instance_st ptr);
161
162 #ifdef __cplusplus
163 }
164 #endif