From 3b530d61a80e82ffcfb08308358370e4408dff02 Mon Sep 17 00:00:00 2001 From: Atsushi Watanabe Date: Wed, 23 Dec 2020 15:16:49 +0900 Subject: [PATCH] Fix pid_t on windows --- include/msq.win32.h | 20 ++++++++++++++------ include/ypparam.h | 19 ++++++++++++------- 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/include/msq.win32.h b/include/msq.win32.h index cc9f3a7..aafe46b 100644 --- a/include/msq.win32.h +++ b/include/msq.win32.h @@ -40,17 +40,25 @@ #ifndef __key_t_defined typedef int key_t; #define __key_t_defined -#endif // __key_t_defined +#endif // ! __key_t_defined #ifndef __uid_t_defined typedef int uid_t; #define __uid_t_defined -#endif // __uid_t_defined +#endif // ! __uid_t_defined #ifndef __gid_t_defined typedef int gid_t; #define __gid_t_defined -#endif // __gid_t_defined +#endif // ! __gid_t_defined + +#ifndef __pid_t_defined +#ifndef _PID_T_ +typedef int pid_t; +#define __pid_t_defined +#define _PID_T_ +#endif // ! _PID_T_ +#endif // ! __pid_t_defined typedef unsigned long int msgqnum_t; typedef unsigned long int msglen_t; @@ -88,9 +96,9 @@ struct msqid_ds }; int msgget(key_t key, int msgflg); -int msgsnd(int msqid, const void *msgp, size_t msgsz, int msgflg); -ssize_t msgrcv(int msqid, void *msgp, size_t msgsz, long msgtyp, int msgflg); -int msgctl(int msqid, int cmd, struct msqid_ds *buf); +int msgsnd(int msqid, const void* msgp, size_t msgsz, int msgflg); +ssize_t msgrcv(int msqid, void* msgp, size_t msgsz, long msgtyp, int msgflg); +int msgctl(int msqid, int cmd, struct msqid_ds* buf); #else // Linux用 diff --git a/include/ypparam.h b/include/ypparam.h index e4826e0..79870e3 100644 --- a/include/ypparam.h +++ b/include/ypparam.h @@ -26,11 +26,16 @@ extern "C" { #endif // __cplusplus #if defined(_WIN32) -#if !defined(_WIN64) -typedef int pid_t; -#endif // !defined(_WIN64) -#else #include + +#ifndef __pid_t_defined +#ifndef _PID_T_ +typedef int pid_t; +#define __pid_t_defined +#define _PID_T_ +#endif // ! _PID_T_ +#endif // ! __pid_t_defined + #endif // defined(_WIN32) /* コマンドナンバー */ @@ -525,9 +530,9 @@ struct ipcmd_t int connection_error; pid_t pid; pid_t pids[YPSPUR_MAX_SOCKET]; - int (*send)(struct ipcmd_t *ipcmd, YPSpur_msg *data); - int (*recv)(struct ipcmd_t *ipcmd, YPSpur_msg *data); - void (*flush)(struct ipcmd_t *ipcmd); + int (*send)(struct ipcmd_t* ipcmd, YPSpur_msg* data); + int (*recv)(struct ipcmd_t* ipcmd, YPSpur_msg* data); + void (*flush)(struct ipcmd_t* ipcmd); }; #define YPSPUR_MSQ_KEY 0x7045