p9y: bsd
[m6w6/libmemcached] / src / libmemcached / common.h
1 /*
2 +--------------------------------------------------------------------+
3 | libmemcached - C/C++ Client Library for memcached |
4 +--------------------------------------------------------------------+
5 | Redistribution and use in source and binary forms, with or without |
6 | modification, are permitted under the terms of the BSD license. |
7 | You should have received a copy of the license in a bundled file |
8 | named LICENSE; in case you did not receive a copy you can review |
9 | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
10 +--------------------------------------------------------------------+
11 | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
12 | Copyright (c) 2020 Michael Wallner <mike@php.net> |
13 +--------------------------------------------------------------------+
14 */
15
16 #pragma once
17
18 #include "mem_config.h"
19
20 #ifdef __cplusplus
21 # include <cstddef>
22 # include <cstdio>
23 # include <cstdlib>
24 # include <cstring>
25 # include <ctime>
26 # include <cctype>
27 # include <cerrno>
28 # include <climits>
29 # include <ciso646>
30 #else
31 # include <stddef.h>
32 # include <stdio.h>
33 # include <stdlib.h>
34 # include <string.h>
35 # include <time.h>
36 # include <errno.h>
37 # include <limits.h>
38 # include <iso646.h>
39 #endif
40
41 #include "p9y/socket.hpp"
42
43 #ifdef HAVE_SYS_TIME_H
44 # include <sys/time.h>
45 #endif
46
47 #include <fcntl.h>
48
49 #ifdef HAVE_STRINGS_H
50 # include <strings.h>
51 #endif
52
53 #ifdef HAVE_DLFCN_H
54 # include <dlfcn.h>
55 #endif
56
57 #include "libmemcached-1.0/memcached.h"
58 #include "libmemcached/watchpoint.h"
59 #include "libmemcached/is.h"
60 typedef struct memcached_st Memcached;
61
62 #ifdef __cplusplus
63 memcached_instance_st *memcached_instance_fetch(memcached_st *ptr, uint32_t server_key);
64 #endif
65
66 /* These are private not to be installed headers */
67 #include "libmemcached/error.hpp"
68 #include "libmemcached/memory.h"
69 #include "libmemcached/io.h"
70 #ifdef __cplusplus
71 # include "libmemcached/string.hpp"
72 # include "libmemcachedprotocol-0.0/binary.h"
73 # include "libmemcached/io.hpp"
74 # include "libmemcached/udp.hpp"
75 # include "libmemcached/do.hpp"
76 # include "libmemcached/connect.hpp"
77 # include "libmemcached/allocators.hpp"
78 # include "libmemcached/hash.hpp"
79 # include "libmemcached/quit.hpp"
80 # include "libmemcached/instance.hpp"
81 # include "libmemcached/server_instance.h"
82 # include "libmemcached/server.hpp"
83 # include "libmemcached/flag.hpp"
84 # include "libmemcached/behavior.hpp"
85 # include "libmemcached/sasl.hpp"
86 # include "libmemcached/server_list.hpp"
87 #endif
88
89 #include "libmemcached/internal.h"
90 #include "libmemcached/array.h"
91 #include "libmemcached/libmemcached_probes.h"
92 #include "libmemcached/byteorder.h"
93 #include "libmemcached/initialize_query.h"
94
95 #ifdef __cplusplus
96 # include "libmemcached/response.h"
97 # include "libmemcached/namespace.h"
98 #else
99 # include "libmemcached/virtual_bucket.h"
100 #endif
101
102 #ifdef __cplusplus
103 # include "libmemcached/backtrace.hpp"
104 # include "libmemcached/assert.hpp"
105 # include "libmemcached/server.hpp"
106 # include "libmemcached/key.hpp"
107 # include "libmemcached/result.h"
108 # include "libmemcached/version.hpp"
109 #endif
110
111 #include "libmemcached/continuum.hpp"
112
113 #if !defined(__GNUC__) || (__GNUC__ == 2 && __GNUC_MINOR__ < 96)
114
115 # define likely(x) if ((x))
116 # define unlikely(x) if ((x))
117
118 #else
119
120 # define likely(x) if (__builtin_expect((x) != 0, 1))
121 # define unlikely(x) if (__builtin_expect((x) != 0, 0))
122 #endif
123
124 #define MEMCACHED_BLOCK_SIZE 1024
125 #define MEMCACHED_DEFAULT_COMMAND_SIZE 350
126 #define SMALL_STRING_LEN 1024
127 #define HUGE_STRING_LEN 8196
128
129 #ifdef __cplusplus
130 extern "C" {
131 #endif
132
133 memcached_return_t run_distribution(memcached_st *ptr);
134
135 #ifdef __cplusplus
136 # include "p9y/poll.hpp"
137 static inline void memcached_server_response_increment(memcached_instance_st *instance) {
138 instance->events(POLLIN);
139 instance->cursor_active_++;
140 }
141 #endif
142
143 #define memcached_server_response_decrement(A) (A)->cursor_active_--
144 #define memcached_server_response_reset(A) (A)->cursor_active_ = 0
145
146 #define memcached_instance_response_increment(A) (A)->cursor_active_++
147 #define memcached_instance_response_decrement(A) (A)->cursor_active_--
148 #define memcached_instance_response_reset(A) (A)->cursor_active_ = 0
149
150 #ifdef __cplusplus
151 }
152 #endif
153
154 #ifdef __cplusplus
155 bool memcached_purge(memcached_instance_st *);
156 memcached_instance_st *memcached_instance_by_position(const memcached_st *ptr, uint32_t server_key);
157 #endif