xref: /PHP-8.0/ext/sysvshm/php_sysvshm.h (revision 2e18b30d)
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    | http://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 # ifndef THREAD_LS
34 #  define THREAD_LS
35 # endif
36 #else
37 # include <sys/ipc.h>
38 # include <sys/shm.h>
39 #endif
40 
41 typedef struct {
42 	zend_long init_mem;
43 } sysvshm_module;
44 
45 typedef struct {
46 	zend_long key;
47 	zend_long length;
48 	zend_long next;
49 	char mem;
50 } sysvshm_chunk;
51 
52 typedef struct {
53 	char magic[8];
54 	zend_long start;
55 	zend_long end;
56 	zend_long free;
57 	zend_long total;
58 } sysvshm_chunk_head;
59 
60 typedef struct {
61 	key_t key;               /* key set by user */
62 	zend_long id;                 /* returned by shmget */
63 	sysvshm_chunk_head *ptr; /* memory address of shared memory */
64 	zend_object std;
65 } sysvshm_shm;
66 
67 PHP_MINIT_FUNCTION(sysvshm);
68 PHP_MINFO_FUNCTION(sysvshm);
69 
70 extern sysvshm_module php_sysvshm;
71 
72 #else
73 
74 #define sysvshm_module_ptr NULL
75 
76 #endif
77 
78 #define phpext_sysvshm_ptr sysvshm_module_ptr
79 
80 #endif /* PHP_SYSVSHM_H */
81