mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
sync shm* implementation signatures with POSIX
This commit is contained in:
@@ -426,7 +426,7 @@ static process_pair *process_get(FILE *stream)
|
||||
return ptr;
|
||||
}
|
||||
|
||||
static shm_pair *shm_get(int key, void *addr)
|
||||
static shm_pair *shm_get(key_t key, void *addr)
|
||||
{
|
||||
shm_pair *ptr;
|
||||
shm_pair *newptr;
|
||||
@@ -639,17 +639,13 @@ TSRM_API int pclose(FILE *stream)
|
||||
return termstat;
|
||||
}
|
||||
|
||||
TSRM_API int shmget(int key, int size, int flags)
|
||||
TSRM_API int shmget(key_t key, size_t size, int flags)
|
||||
{
|
||||
shm_pair *shm;
|
||||
char shm_segment[26], shm_info[29];
|
||||
HANDLE shm_handle, info_handle;
|
||||
BOOL created = FALSE;
|
||||
|
||||
if (size < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
snprintf(shm_segment, sizeof(shm_segment), "TSRM_SHM_SEGMENT:%d", key);
|
||||
snprintf(shm_info, sizeof(shm_info), "TSRM_SHM_DESCRIPTOR:%d", key);
|
||||
|
||||
@@ -658,7 +654,14 @@ TSRM_API int shmget(int key, int size, int flags)
|
||||
|
||||
if (!shm_handle && !info_handle) {
|
||||
if (flags & IPC_CREAT) {
|
||||
shm_handle = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, size, shm_segment);
|
||||
#if SIZEOF_SIZE_T == 8
|
||||
DWORD high = size >> 32;
|
||||
DWORD low = (DWORD)size;
|
||||
#else
|
||||
DWORD high = 0;
|
||||
DWORD low = size;
|
||||
#endif
|
||||
shm_handle = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, high, low, shm_segment);
|
||||
info_handle = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, sizeof(shm->descriptor), shm_info);
|
||||
created = TRUE;
|
||||
}
|
||||
|
||||
@@ -26,9 +26,10 @@
|
||||
#if HAVE_UTIME
|
||||
# include <sys/utime.h>
|
||||
#endif
|
||||
#include "win32/ipc.h"
|
||||
|
||||
struct ipc_perm {
|
||||
int key;
|
||||
key_t key;
|
||||
unsigned short uid;
|
||||
unsigned short gid;
|
||||
unsigned short cuid;
|
||||
@@ -39,7 +40,7 @@ struct ipc_perm {
|
||||
|
||||
struct shmid_ds {
|
||||
struct ipc_perm shm_perm;
|
||||
int shm_segsz;
|
||||
size_t shm_segsz;
|
||||
time_t shm_atime;
|
||||
time_t shm_dtime;
|
||||
time_t shm_ctime;
|
||||
@@ -105,7 +106,7 @@ TSRM_API int pclose(FILE *stream);
|
||||
TSRM_API int tsrm_win32_access(const char *pathname, int mode);
|
||||
TSRM_API int win32_utime(const char *filename, struct utimbuf *buf);
|
||||
|
||||
TSRM_API int shmget(int key, int size, int flags);
|
||||
TSRM_API int shmget(key_t key, size_t size, int flags);
|
||||
TSRM_API void *shmat(int key, const void *shmaddr, int flags);
|
||||
TSRM_API int shmdt(const void *shmaddr);
|
||||
TSRM_API int shmctl(int key, int cmd, struct shmid_ds *buf);
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#include <sys/stat.h>
|
||||
|
||||
|
||||
PHPAPI key_t
|
||||
PHP_WIN32_IPC_API key_t
|
||||
ftok(const char *pathname, int proj_id)
|
||||
{
|
||||
HANDLE fh;
|
||||
|
||||
@@ -19,11 +19,15 @@
|
||||
#ifndef PHP_WIN32_IPC_H
|
||||
#define PHP_WIN32_IPC_H 1
|
||||
|
||||
#include "php.h"
|
||||
#ifdef PHP_EXPORTS
|
||||
# define PHP_WIN32_IPC_API __declspec(dllexport)
|
||||
#else
|
||||
# define PHP_WIN32_IPC_API __declspec(dllimport)
|
||||
#endif
|
||||
|
||||
typedef int key_t;
|
||||
|
||||
PHPAPI key_t ftok(const char *path, int id);
|
||||
PHP_WIN32_IPC_API key_t ftok(const char *path, int id);
|
||||
|
||||
|
||||
#endif /* PHP_WIN32_IPC_H */
|
||||
|
||||
Reference in New Issue
Block a user