xref: /php-src/ext/sysvshm/php_sysvshm.h (revision a4db7436)
1 /*
2    +----------------------------------------------------------------------+
3    | Copyright (c) The PHP Group                                          |
4    +----------------------------------------------------------------------+
5    | This source file is subject to version 3.01 of the PHP license,      |
6    | that is bundled with this package in the file LICENSE, and is        |
7    | available through the world-wide-web at the following url:           |
8    | https://www.php.net/license/3_01.txt                                 |
9    | If you did not receive a copy of the PHP license and are unable to   |
10    | obtain it through the world-wide-web, please send a note to          |
11    | license@php.net so we can mail you a copy immediately.               |
12    +----------------------------------------------------------------------+
13    | Author: Christian Cartus <cartus@atrior.de>                          |
14    +----------------------------------------------------------------------+
15 */
16 
17 #ifndef PHP_SYSVSHM_H
18 #define PHP_SYSVSHM_H
19 
20 #ifdef HAVE_SYSVSHM
21 
22 extern zend_module_entry sysvshm_module_entry;
23 #define sysvshm_module_ptr &sysvshm_module_entry
24 
25 #include "php_version.h"
26 #define PHP_SYSVSHM_VERSION PHP_VERSION
27 
28 #include <sys/types.h>
29 
30 #ifdef PHP_WIN32
31 # include <TSRM/tsrm_win32.h>
32 # include "win32/ipc.h"
33 #else
34 # include <sys/ipc.h>
35 # include <sys/shm.h>
36 #endif
37 
38 typedef struct {
39 	zend_long init_mem;
40 } sysvshm_module;
41 
42 typedef struct {
43 	zend_long key;
44 	zend_long length;
45 	zend_long next;
46 	char mem;
47 } sysvshm_chunk;
48 
49 typedef struct {
50 	char magic[8];
51 	zend_long start;
52 	zend_long end;
53 	zend_long free;
54 	zend_long total;
55 } sysvshm_chunk_head;
56 
57 typedef struct {
58 	key_t key;               /* key set by user */
59 	zend_long id;                 /* returned by shmget */
60 	sysvshm_chunk_head *ptr; /* memory address of shared memory */
61 	zend_object std;
62 } sysvshm_shm;
63 
64 PHP_MINIT_FUNCTION(sysvshm);
65 PHP_MINFO_FUNCTION(sysvshm);
66 
67 extern sysvshm_module php_sysvshm;
68 
69 #else
70 
71 #define sysvshm_module_ptr NULL
72 
73 #endif
74 
75 #define phpext_sysvshm_ptr sysvshm_module_ptr
76 
77 #endif /* PHP_SYSVSHM_H */
78