New PHP5 APC - version 3.0.19, using PHP5 5.2.0-8+etch11,
[php5-apc.git] / apc_sma.h
1 /*
2   +----------------------------------------------------------------------+
3   | APC                                                                  |
4   +----------------------------------------------------------------------+
5   | Copyright (c) 2008 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   +----------------------------------------------------------------------+
17
18    This software was contributed to PHP by Community Connect Inc. in 2002
19    and revised in 2005 by Yahoo! Inc. to add support for PHP 5.1.
20    Future revisions and derivatives of this source code must acknowledge
21    Community Connect Inc. as the original contributor of this module by
22    leaving this note intact in the source code.
23
24    All other licensing and usage conditions are those of the PHP Group.
25
26  */
27
28 /* $Id: apc_sma.h,v 1.18.2.2 2008/05/11 18:57:00 rasmus Exp $ */
29
30 #ifndef APC_SMA_H
31 #define APC_SMA_H
32
33 #define ALLOC_DISTRIBUTION 0
34
35 #include "apc.h"
36
37 /* Simple shared memory allocator */
38
39 extern void apc_sma_init(int numseg, size_t segsize, char *mmap_file_mask);
40 extern void apc_sma_cleanup();
41 extern void* apc_sma_malloc(size_t size);
42 extern void* apc_sma_realloc(void* p, size_t size);
43 extern char* apc_sma_strdup(const char *s);
44 extern void apc_sma_free(void* p);
45 #if ALLOC_DISTRIBUTION 
46 extern size_t *apc_sma_get_alloc_distribution();
47 #endif
48
49 /* {{{ struct definition: apc_sma_link_t */
50 typedef struct apc_sma_link_t apc_sma_link_t;
51 struct apc_sma_link_t {
52     long size;               /* size of this free block */
53     long offset;             /* offset in segment of this block */
54     apc_sma_link_t* next;   /* link to next free block */
55 };
56 /* }}} */
57
58 /* {{{ struct definition: apc_sma_info_t */
59 typedef struct apc_sma_info_t apc_sma_info_t;
60 struct apc_sma_info_t {
61     int num_seg;            /* number of shared memory segments */
62     long seg_size;           /* size of each shared memory segment */
63     apc_sma_link_t** list;  /* there is one list per segment */
64 };
65 /* }}} */
66
67 extern apc_sma_info_t* apc_sma_info(zend_bool limited);
68 extern void apc_sma_free_info(apc_sma_info_t* info);
69
70 extern size_t apc_sma_get_avail_mem();
71 extern void apc_sma_check_integrity();
72
73 /* {{{ ALIGNWORD: pad up x, aligned to the system's word boundary */
74 typedef union { void* p; int i; long l; double d; void (*f)(); } apc_word_t;
75 #define ALIGNSIZE(x, size) ((size) * (1 + (((x)-1)/(size))))
76 #define ALIGNWORD(x) ALIGNSIZE(x, sizeof(apc_word_t))
77 /* }}} */
78
79 #endif
80
81 /*
82  * Local variables:
83  * tab-width: 4
84  * c-basic-offset: 4
85  * End:
86  * vim600: expandtab sw=4 ts=4 sts=4 fdm=marker
87  * vim<600: expandtab sw=4 ts=4 sts=4
88  */