]> granicus.if.org Git - postgresql/blob - src/include/port/win32.h
Win32 signals cleanup. Patch by Magnus Hagander, with input from Claudio
[postgresql] / src / include / port / win32.h
1 /* $PostgreSQL: pgsql/src/include/port/win32.h,v 1.17 2004/02/08 22:28:57 neilc Exp $ */
2
3 /* undefine and redefine after #include */
4 #undef mkdir
5
6 #undef ERROR
7 #include <windows.h>
8 #include <winsock.h>
9 #undef near
10
11 /* Must be here to avoid conflicting with prototype in windows.h */
12 #define mkdir(a,b)      mkdir(a)
13
14
15 #define USES_WINSOCK
16 #define NOFILE            100
17
18 /* defines for dynamic linking on Win32 platform */
19 #if defined(__CYGWIN__) || defined(__MINGW32__)
20
21 #if __GNUC__ && ! defined (__declspec)
22 #error You need egcs 1.1 or newer for compiling!
23 #endif
24
25 #ifdef BUILDING_DLL
26 #define DLLIMPORT __declspec (dllexport)
27 #else                                                   /* not BUILDING_DLL */
28 #define DLLIMPORT __declspec (dllimport)
29 #endif
30
31 #elif defined(WIN32) && defined(_MSC_VER)               /* not CYGWIN or MingW */
32
33 #if defined(_DLL)
34 #define DLLIMPORT __declspec (dllexport)
35 #else                                                   /* not _DLL */
36 #define DLLIMPORT __declspec (dllimport)
37 #endif
38
39 #else                                                   /* not CYGWIN, not MSVC, not MingW */
40
41 #define DLLIMPORT
42 #endif
43
44 /*
45  *      IPC defines
46  */
47 #undef HAVE_UNION_SEMUN
48 #define HAVE_UNION_SEMUN 1
49
50 #define IPC_RMID 256
51 #define IPC_CREAT 512
52 #define IPC_EXCL 1024
53 #define IPC_PRIVATE 234564
54 #define IPC_NOWAIT      2048
55 #define IPC_STAT 4096
56
57 #define EACCESS 2048
58 #define EIDRM 4096
59
60 #define SETALL 8192
61 #define GETNCNT 16384
62 #define GETVAL 65536
63 #define SETVAL 131072
64 #define GETPID 262144
65
66 /*
67  *      Shared memory
68  */
69 struct shmid_ds
70 {
71         int                     dummy;
72         int                     shm_nattch;
73 };
74
75 int                     shmdt(const void *shmaddr);
76 void       *shmat(int memId, void *shmaddr, int flag);
77 int                     shmctl(int shmid, int flag, struct shmid_ds * dummy);
78 int                     shmget(int memKey, int size, int flag);
79
80
81 /*
82  *      Semaphores
83  */
84 union semun
85 {
86         int                     val;
87         struct semid_ds *buf;
88         unsigned short *array;
89 };
90
91 struct sembuf
92 {
93         int                     sem_flg;
94         int                     sem_op;
95         int                     sem_num;
96 };
97
98 int                     semctl(int semId, int semNum, int flag, union semun);
99 int                     semget(int semKey, int semNum, int flags);
100 int                     semop(int semId, struct sembuf * sops, int flag);
101
102 #define sleep(sec)      (Sleep(sec * 1000), /* no return value */ 0)
103
104
105 #ifndef FRONTEND
106 /* In libpq/pqsignal.c */
107 #define kill(pid,sig)   pqkill(pid,sig)
108 int pqkill(int pid, int sig);
109 #endif
110
111 /* Some extra signals */
112 #define SIGHUP                          1
113 #define SIGQUIT                         3
114 #define SIGTRAP                         5
115 #define SIGABRT                         22      /* Set to match W32 value -- not UNIX
116                                                                  * value */
117 #define SIGKILL                         9
118 #define SIGPIPE                         13
119 #define SIGALRM                         14
120 #define SIGSTOP                         17
121 #define SIGCONT                         19
122 #define SIGCHLD                         20
123 #define SIGTTIN                         21
124 #define SIGTTOU                         22      /* Same as SIGABRT -- no problem, I hope */
125 #define SIGWINCH                        28
126 #define SIGUSR1                         30
127 #define SIGUSR2                         31
128
129 struct timezone
130 {
131         int                     tz_minuteswest; /* Minutes west of GMT.  */
132         int                     tz_dsttime;             /* Nonzero if DST is ever in effect.  */
133 };
134
135 /* FROM SRA */
136
137 /*
138  * Supplement to <sys/types.h>.
139  */
140 #define uid_t int
141 #define gid_t int
142 #define pid_t unsigned long
143 #define ssize_t int
144 #define mode_t int
145 #define key_t long
146 #define ushort unsigned short
147
148 /*
149  * Supplement to <sys/stat.h>.
150  */
151 #define lstat slat
152
153 #define S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR)
154 #define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG)
155
156 #define S_IRUSR _S_IREAD
157 #define S_IWUSR _S_IWRITE
158 #define S_IXUSR _S_IEXEC
159 #define S_IRWXU (_S_IREAD | _S_IWRITE | _S_IEXEC)
160
161 /*
162  * Supplement to <errno.h>.
163  */
164 #include <errno.h>
165 #undef EAGAIN
166 #undef EINTR
167 #define EINTR WSAEINTR
168 #define EAGAIN WSAEWOULDBLOCK
169 #define EMSGSIZE WSAEMSGSIZE
170 #define EAFNOSUPPORT WSAEAFNOSUPPORT
171 #define EWOULDBLOCK WSAEWOULDBLOCK
172 #define ECONNRESET WSAECONNRESET
173 #define EINPROGRESS WSAEINPROGRESS