Browse Source

sync shm* implementation signatures with POSIX

pull/2059/merge
Anatol Belski 10 years ago
parent
commit
becc5cd11b
  1. 17
      TSRM/tsrm_win32.c
  2. 7
      TSRM/tsrm_win32.h
  3. 2
      win32/ftok.c
  4. 8
      win32/ipc.h

17
TSRM/tsrm_win32.c

@ -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;
}

7
TSRM/tsrm_win32.h

@ -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);

2
win32/ftok.c

@ -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;

8
win32/ipc.h

@ -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 */
Loading…
Cancel
Save