1 /* $PostgreSQL: pgsql/src/include/port/win32.h,v 1.44 2005/03/24 04:36:19 momjian Exp $ */
3 /* undefine and redefine after #include */
15 /* Must be here to avoid conflicting with prototype in windows.h */
16 #define mkdir(a,b) mkdir(a)
19 #define fsync(a) _commit(a)
20 #define FSYNC_IS_WRITE_THROUGH
21 #define ftruncate(a,b) chsize(a,b)
25 /* defines for dynamic linking on Win32 platform */
26 #if defined(__MINGW32__) || defined(__CYGWIN__)
28 #if __GNUC__ && ! defined (__declspec)
29 #error You need egcs 1.1 or newer for compiling!
33 #define DLLIMPORT __declspec (dllexport)
34 #else /* not BUILDING_DLL */
35 #define DLLIMPORT __declspec (dllimport)
38 #elif defined(WIN32_CLIENT_ONLY)
41 #define DLLIMPORT __declspec (dllexport)
43 #define DLLIMPORT __declspec (dllimport)
46 #else /* not CYGWIN, not MSVC, not MingW */
54 #undef HAVE_UNION_SEMUN
55 #define HAVE_UNION_SEMUN 1
60 #define IPC_PRIVATE 234564
61 #define IPC_NOWAIT 2048
82 int shmdt(const void *shmaddr);
83 void *shmat(int memId, void *shmaddr, int flag);
84 int shmctl(int shmid, int flag, struct shmid_ds * dummy);
85 int shmget(int memKey, int size, int flag);
95 unsigned short *array;
105 int semctl(int semId, int semNum, int flag, union semun);
106 int semget(int semKey, int semNum, int flags);
107 int semop(int semId, struct sembuf * sops, int flag);
113 #define WEXITSTATUS(w) (((w) >> 8) & 0xff)
114 #define WIFEXITED(w) (((w) & 0xff) == 0)
115 #define WIFSIGNALED(w) (((w) & 0x7f) > 0 && (((w) & 0x7f) < 0x7f))
116 #define WTERMSIG(w) ((w) & 0x7f)
118 #define sigmask(sig) ( 1 << ((sig)-1) )
120 /* Signal function return values */
124 #define SIG_DFL ((pqsigfunc)0)
125 #define SIG_ERR ((pqsigfunc)-1)
126 #define SIG_IGN ((pqsigfunc)1)
128 /* Some extra signals */
132 #define SIGABRT 22 /* Set to match W32 value -- not UNIX
142 #define SIGTTOU 22 /* Same as SIGABRT -- no problem, I hope */
149 int tz_minuteswest; /* Minutes west of GMT. */
150 int tz_dsttime; /* Nonzero if DST is ever in effect. */
153 /* for setitimer in backend/port/win32/timer.c */
154 #define ITIMER_REAL 0
157 struct timeval it_interval;
158 struct timeval it_value;
160 int setitimer(int which, const struct itimerval * value, struct itimerval * ovalue);
164 * Supplement to <sys/types.h>.
166 * Perl already has conflicting defines for uid_t and gid_t.
168 #ifndef PLPERL_HAVE_UID_GID
172 /* These are redefined by perl. */
178 #ifdef WIN32_CLIENT_ONLY
183 * Supplement to <sys/stat.h>.
185 #define lstat(path, sb) stat((path), (sb))
188 * Supplement to <fcntl.h>.
189 * This is the same value as _O_NOINHERIT in the MS header file. This is
190 * to ensure that we don't collide with a future definition. It means
191 * we cannot use _O_NOINHERIT ourselves.
193 #define O_DSYNC 0x0080
196 * Supplement to <errno.h>.
200 #define EINTR WSAEINTR
201 #define EAGAIN WSAEWOULDBLOCK
202 #define EMSGSIZE WSAEMSGSIZE
203 #define EAFNOSUPPORT WSAEAFNOSUPPORT
204 #define EWOULDBLOCK WSAEWOULDBLOCK
205 #define ECONNRESET WSAECONNRESET
206 #define EINPROGRESS WSAEINPROGRESS
207 #define ENOBUFS WSAENOBUFS
208 #define EPROTONOSUPPORT WSAEPROTONOSUPPORT
209 #define ECONNREFUSED WSAECONNREFUSED
210 #define EBADFD WSAENOTSOCK
211 #define EOPNOTSUPP WSAEOPNOTSUPP
214 /* In backend/port/win32/signal.c */
215 extern DLLIMPORT HANDLE pgwin32_signal_event;
216 extern HANDLE pgwin32_initial_signal_pipe;
218 void pgwin32_signal_initialize(void);
219 HANDLE pgwin32_create_signal_listener(pid_t pid);
220 void pgwin32_dispatch_queued_signals(void);
221 void pg_queue_signal(int signum);
224 #define pg_usleep(t) pgwin32_backend_usleep(t)
225 void pgwin32_backend_usleep(long microsec);
228 /* In backend/port/win32/socket.c */
230 #define socket(af, type, protocol) pgwin32_socket(af, type, protocol)
231 #define accept(s, addr, addrlen) pgwin32_accept(s, addr, addrlen)
232 #define connect(s, name, namelen) pgwin32_connect(s, name, namelen)
233 #define select(n, r, w, e, timeout) pgwin32_select(n, r, w, e, timeout)
234 #define recv(s, buf, len, flags) pgwin32_recv(s, buf, len, flags)
235 #define send(s, buf, len, flags) pgwin32_send(s, buf, len, flags)
237 SOCKET pgwin32_socket(int af, int type, int protocol);
238 SOCKET pgwin32_accept(SOCKET s, struct sockaddr * addr, int *addrlen);
239 int pgwin32_connect(SOCKET s, const struct sockaddr * name, int namelen);
240 int pgwin32_select(int nfds, fd_set *readfs, fd_set *writefds, fd_set *exceptfds, const struct timeval * timeout);
241 int pgwin32_recv(SOCKET s, char *buf, int len, int flags);
242 int pgwin32_send(SOCKET s, char *buf, int len, int flags);
244 const char *pgwin32_socket_strerror(int err);
245 int pgwin32_waitforsinglesocket(SOCKET s, int what);
247 /* in backend/port/win32/security.c */
248 extern int pgwin32_is_admin(void);
249 extern int pgwin32_is_service(void);
252 /* in backend/port/win32/error.c */
253 extern void _dosmaperr(unsigned long);