xref: /PHP-7.1/ext/sysvshm/php_sysvshm.h (revision ccd4716e)
1 /*
2    +----------------------------------------------------------------------+
3    | PHP Version 7                                                        |
4    +----------------------------------------------------------------------+
5    | Copyright (c) 1997-2018 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    | Author: Christian Cartus <cartus@atrior.de>                          |
16    +----------------------------------------------------------------------+
17 */
18 
19 /* $Id$ */
20 
21 #ifndef PHP_SYSVSHM_H
22 #define PHP_SYSVSHM_H
23 
24 #if HAVE_SYSVSHM
25 
26 extern zend_module_entry sysvshm_module_entry;
27 #define sysvshm_module_ptr &sysvshm_module_entry
28 
29 #include "php_version.h"
30 #define PHP_SYSVSHM_VERSION PHP_VERSION
31 
32 #include <sys/types.h>
33 
34 #ifdef PHP_WIN32
35 # include <TSRM/tsrm_win32.h>
36 # include "win32/ipc.h"
37 # ifndef THREAD_LS
38 #  define THREAD_LS
39 # endif
40 #else
41 # include <sys/ipc.h>
42 # include <sys/shm.h>
43 #endif
44 
45 #define PHP_SHM_RSRC_NAME "sysvshm"
46 
47 typedef struct {
48 	int le_shm;
49 	zend_long init_mem;
50 } sysvshm_module;
51 
52 typedef struct {
53 	zend_long key;
54 	zend_long length;
55 	zend_long next;
56 	char mem;
57 } sysvshm_chunk;
58 
59 typedef struct {
60 	char magic[8];
61 	zend_long start;
62 	zend_long end;
63 	zend_long free;
64 	zend_long total;
65 } sysvshm_chunk_head;
66 
67 typedef struct {
68 	key_t key;               /* key set by user */
69 	zend_long id;                 /* returned by shmget */
70 	sysvshm_chunk_head *ptr; /* memory address of shared memory */
71 } sysvshm_shm;
72 
73 PHP_MINIT_FUNCTION(sysvshm);
74 PHP_FUNCTION(shm_attach);
75 PHP_FUNCTION(shm_detach);
76 PHP_FUNCTION(shm_remove);
77 PHP_FUNCTION(shm_put_var);
78 PHP_FUNCTION(shm_get_var);
79 PHP_FUNCTION(shm_has_var);
80 PHP_FUNCTION(shm_remove_var);
81 
82 extern sysvshm_module php_sysvshm;
83 
84 #else
85 
86 #define sysvshm_module_ptr NULL
87 
88 #endif
89 
90 #define phpext_sysvshm_ptr sysvshm_module_ptr
91 
92 #endif /* PHP_SYSVSHM_H */
93