Skip to content

Commit

Permalink
Fix pid_t on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
at-wat committed Dec 23, 2020
1 parent 2f122d2 commit 3b530d6
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 13 deletions.
20 changes: 14 additions & 6 deletions include/msq.win32.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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用
Expand Down
19 changes: 12 additions & 7 deletions include/ypparam.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,16 @@ extern "C" {
#endif // __cplusplus

#if defined(_WIN32)
#if !defined(_WIN64)
typedef int pid_t;
#endif // !defined(_WIN64)
#else
#include <unistd.h>

#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)

/* コマンドナンバー */
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 3b530d6

Please sign in to comment.