~ubuntu-branches/ubuntu/vivid/php-apcu/vivid

« back to all changes in this revision

Viewing changes to apcu-4.0.6/apc.h

  • Committer: Package Import Robot
  • Author(s): Ondřej Surý
  • Date: 2014-06-24 10:52:52 UTC
  • mfrom: (7.1.4 sid)
  • Revision ID: package-import@ubuntu.com-20140624105252-vsqs1r4og4ykucqg
Tags: 4.0.6-1
* New upstream version 4.0.6
* Remove PHP 5.6 support patch - merged upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
  +----------------------------------------------------------------------+
 
3
  | APC                                                                  |
 
4
  +----------------------------------------------------------------------+
 
5
  | Copyright (c) 2006-2011 The PHP Group                                |
 
6
  +----------------------------------------------------------------------+
 
7
  | This source file is subject to version 3.01 of the PHP license,      |
 
8
  | that is bundled with this package in the file LICENSE, and is        |
 
9
  | available through the world-wide-web at the following url:           |
 
10
  | http://www.php.net/license/3_01.txt                                  |
 
11
  | If you did not receive a copy of the PHP license and are unable to   |
 
12
  | obtain it through the world-wide-web, please send a note to          |
 
13
  | license@php.net so we can mail you a copy immediately.               |
 
14
  +----------------------------------------------------------------------+
 
15
  | Authors: Daniel Cowgill <dcowgill@communityconnect.com>              |
 
16
  |          George Schlossnagle <george@omniti.com>                     |
 
17
  |          Rasmus Lerdorf <rasmus@php.net>                             |
 
18
  |          Arun C. Murthy <arunc@yahoo-inc.com>                        |
 
19
  |          Gopal Vijayaraghavan <gopalv@yahoo-inc.com>                 |
 
20
  +----------------------------------------------------------------------+
 
21
 
 
22
   This software was contributed to PHP by Community Connect Inc. in 2002
 
23
   and revised in 2005 by Yahoo! Inc. to add support for PHP 5.1.
 
24
   Future revisions and derivatives of this source code must acknowledge
 
25
   Community Connect Inc. as the original contributor of this module by
 
26
   leaving this note intact in the source code.
 
27
 
 
28
   All other licensing and usage conditions are those of the PHP Group.
 
29
 
 
30
 */
 
31
 
 
32
/* $Id: apc.h 328292 2012-11-09 07:05:17Z laruence $ */
 
33
 
 
34
#ifndef APC_H
 
35
#define APC_H
 
36
 
 
37
/*
 
38
 * This module defines utilities and helper functions used elsewhere in APC.
 
39
 */
 
40
#ifdef PHP_WIN32
 
41
# define PHP_APCU_API __declspec(dllexport)
 
42
#elif defined(__GNUC__) && __GNUC__ >= 4
 
43
# define PHP_APCU_API __attribute__ ((visibility("default")))
 
44
#else
 
45
# define PHP_APCU_API
 
46
#endif
 
47
 
 
48
/* Commonly needed C library headers. */
 
49
#include <assert.h>
 
50
#include <errno.h>
 
51
#include <stdarg.h>
 
52
#include <stddef.h>
 
53
#include <stdio.h>
 
54
#include <stdlib.h>
 
55
#include <string.h>
 
56
#include <time.h>
 
57
 
 
58
/* UNIX headers (needed for struct stat) */
 
59
#include <sys/types.h>
 
60
#include <sys/stat.h>
 
61
#ifndef PHP_WIN32
 
62
#include <unistd.h>
 
63
#endif
 
64
 
 
65
#ifdef HAVE_CONFIG_H
 
66
#include <config.h>
 
67
#endif
 
68
 
 
69
#include "php.h"
 
70
#include "main/php_streams.h"
 
71
 
 
72
/* typedefs for extensible memory allocators */
 
73
typedef void* (*apc_malloc_t)(size_t TSRMLS_DC);
 
74
typedef void  (*apc_free_t)  (void * TSRMLS_DC);
 
75
 
 
76
/* wrappers for memory allocation routines */
 
77
PHP_APCU_API void* apc_emalloc(size_t n TSRMLS_DC);
 
78
PHP_APCU_API void* apc_erealloc(void* p, size_t n TSRMLS_DC);
 
79
PHP_APCU_API void* apc_php_malloc(size_t n TSRMLS_DC);
 
80
PHP_APCU_API void  apc_php_free(void* p TSRMLS_DC);
 
81
PHP_APCU_API void  apc_efree(void* p TSRMLS_DC);
 
82
PHP_APCU_API char* apc_estrdup(const char* s TSRMLS_DC);
 
83
PHP_APCU_API void* apc_xstrdup(const char* s, apc_malloc_t f TSRMLS_DC);
 
84
PHP_APCU_API void* apc_xmemcpy(const void* p, size_t n, apc_malloc_t f TSRMLS_DC);
 
85
 
 
86
/* console display functions */
 
87
PHP_APCU_API void apc_error(const char *format TSRMLS_DC, ...);
 
88
PHP_APCU_API void apc_warning(const char *format TSRMLS_DC, ...);
 
89
PHP_APCU_API void apc_notice(const char *format TSRMLS_DC, ...);
 
90
PHP_APCU_API void apc_debug(const char *format TSRMLS_DC, ...);
 
91
 
 
92
/* string and text manipulation */
 
93
PHP_APCU_API char* apc_append(const char* s, const char* t TSRMLS_DC);
 
94
PHP_APCU_API char* apc_substr(const char* s, int start, int length TSRMLS_DC);
 
95
PHP_APCU_API char** apc_tokenize(const char* s, char delim TSRMLS_DC);
 
96
 
 
97
/* apc_crc32: returns the CRC-32 checksum of the first len bytes in buf */
 
98
PHP_APCU_API unsigned int apc_crc32(const unsigned char* buf, unsigned int len);
 
99
 
 
100
/* apc_flip_hash flips keys and values for faster searching */
 
101
PHP_APCU_API HashTable* apc_flip_hash(HashTable *hash);
 
102
 
 
103
#define APC_NEGATIVE_MATCH 1
 
104
#define APC_POSITIVE_MATCH 2
 
105
 
 
106
#define apc_time() \
 
107
    (APCG(use_request_time) ? (time_t) sapi_get_request_time(TSRMLS_C) : time(0));
 
108
 
 
109
#if defined(__GNUC__)
 
110
# define APC_UNUSED __attribute__((unused))
 
111
# define APC_USED __attribute__((used))
 
112
# define APC_ALLOC __attribute__((malloc))
 
113
# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__  > 2)
 
114
#  define APC_HOTSPOT __attribute__((hot))
 
115
# else 
 
116
#  define APC_HOTSPOT
 
117
# endif
 
118
#else 
 
119
# define APC_UNUSED
 
120
# define APC_USED
 
121
# define APC_ALLOC 
 
122
# define APC_HOTSPOT 
 
123
#endif
 
124
 
 
125
/*
 
126
* Serializer API
 
127
*/
 
128
#define APC_SERIALIZER_ABI "0"
 
129
#define APC_SERIALIZER_CONSTANT "\000apc_register_serializer-" APC_SERIALIZER_ABI
 
130
 
 
131
#define APC_SERIALIZER_NAME(module) module##_apc_serializer
 
132
#define APC_UNSERIALIZER_NAME(module) module##_apc_unserializer
 
133
 
 
134
#define APC_SERIALIZER_ARGS unsigned char **buf, size_t *buf_len, const zval *value, void *config TSRMLS_DC
 
135
#define APC_UNSERIALIZER_ARGS zval **value, unsigned char *buf, size_t buf_len, void *config TSRMLS_DC
 
136
 
 
137
typedef int (*apc_serialize_t)(APC_SERIALIZER_ARGS);
 
138
typedef int (*apc_unserialize_t)(APC_UNSERIALIZER_ARGS);
 
139
 
 
140
/* {{{ struct definition: apc_serializer_t */
 
141
typedef struct apc_serializer_t {
 
142
    const char*        name;
 
143
    apc_serialize_t    serialize;
 
144
    apc_unserialize_t  unserialize;
 
145
    void*              config;
 
146
} apc_serializer_t;
 
147
/* }}} */
 
148
 
 
149
/* {{{ _apc_register_serializer
 
150
 registers the serializer using the given name and paramters */
 
151
PHP_APCU_API int _apc_register_serializer(const char* name,
 
152
                                               apc_serialize_t serialize,
 
153
                                               apc_unserialize_t unserialize,
 
154
                                               void *config TSRMLS_DC); /* }}} */
 
155
 
 
156
/* {{{ apc_get_serializers 
 
157
 fetches the list of serializers */
 
158
PHP_APCU_API apc_serializer_t* apc_get_serializers(TSRMLS_D); /* }}} */
 
159
 
 
160
/* {{{ apc_find_serializer
 
161
 finds a previously registered serializer by name */
 
162
PHP_APCU_API apc_serializer_t* apc_find_serializer(const char* name TSRMLS_DC); /* }}} */
 
163
 
 
164
/* {{{ default serializers */
 
165
PHP_APCU_API int APC_SERIALIZER_NAME(php) (APC_SERIALIZER_ARGS);
 
166
PHP_APCU_API int APC_UNSERIALIZER_NAME(php) (APC_UNSERIALIZER_ARGS); /* }}} */
 
167
 
 
168
/* {{{ eval serializers */
 
169
PHP_APCU_API int APC_SERIALIZER_NAME(eval) (APC_SERIALIZER_ARGS);
 
170
PHP_APCU_API int APC_UNSERIALIZER_NAME(eval) (APC_UNSERIALIZER_ARGS); /* }}} */
 
171
 
 
172
#endif
 
173
 
 
174
/*
 
175
 * Local variables:
 
176
 * tab-width: 4
 
177
 * c-basic-offset: 4
 
178
 * End:
 
179
 * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker
 
180
 * vim<600: expandtab sw=4 ts=4 sts=4
 
181
 */