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