com php-src: sync shm* implementation signatures with POSIX: TSRM/tsrm_win32.c TSRM/tsrm_win32.h win3 2/ftok.c win32/ipc.h
| From: | Anatol Belski | Date: | Mon, 22 Aug 2016 22:27:17 +0000 |
| Subject: | com php-src: sync shm* implementation signatures with POSIX: TSRM/tsrm_win32.c TSRM/tsrm_win32.h win3 2/ftok.c win32/ipc.h | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-94044@lists.php.net to get a copy of this message | ||
Commit: becc5cd11bbd7ffca365e28d48eeff450e141493
Author: Anatol Belski <ab@php.net> Tue, 23 Aug 2016 00:27:17 +0200
Parents: 6790932eaa8c4dce21080c4094301829fd1f0053
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=becc5cd11bbd7ffca365e28d48eeff450e141493
Log:
sync shm* implementation signatures with POSIX
Changed paths:
M TSRM/tsrm_win32.c
M TSRM/tsrm_win32.h
M win32/ftok.c
M win32/ipc.h
Diff:
diff --git a/TSRM/tsrm_win32.c b/TSRM/tsrm_win32.c
index e3d311e..271422d 100644
--- a/TSRM/tsrm_win32.c
+++ b/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;
}
diff --git a/TSRM/tsrm_win32.h b/TSRM/tsrm_win32.h
index fbeac07..ae0ea58 100644
--- a/TSRM/tsrm_win32.h
+++ b/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);
diff --git a/win32/ftok.c b/win32/ftok.c
index 842da78..4c35017 100644
--- a/win32/ftok.c
+++ b/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;
diff --git a/win32/ipc.h b/win32/ipc.h
index cafcf4f..0d7cc47 100644
--- a/win32/ipc.h
+++ b/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 */