]> granicus.if.org Git - php/commitdiff
sync shm* implementation signatures with POSIX
authorAnatol Belski <ab@php.net>
Mon, 22 Aug 2016 22:27:17 +0000 (00:27 +0200)
committerAnatol Belski <ab@php.net>
Mon, 22 Aug 2016 22:27:17 +0000 (00:27 +0200)
TSRM/tsrm_win32.c
TSRM/tsrm_win32.h
win32/ftok.c
win32/ipc.h

index e3d311e418dae33a4e9da02c6f4cfd28a6645fa0..271422df42fc38ec6e73954514175abd21e70f53 100644 (file)
@@ -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;
                }
index fbeac07b01fff4baccd52b67b5a27f65a4f1f54e..ae0ea58c9662913de2221eb09366d639a5cf3a44 100644 (file)
 #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);
index 842da781923c373df357e1c650a730f27c606548..4c35017060db18c6cdf24b95096fcf003ddf3ffc 100644 (file)
@@ -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;
index cafcf4f85eb69bb7a3d3199eeeb42fb8881d3389..0d7cc47e8c46db06946201a27443c08f5ca72412 100644 (file)
 #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 */