1 /* $PostgreSQL: pgsql/src/include/port/win32.h,v 1.43 2005/02/27 00:53:29 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 ftruncate(a,b) chsize(a,b)
24 /* defines for dynamic linking on Win32 platform */
25 #if defined(__MINGW32__) || defined(__CYGWIN__)
27 #if __GNUC__ && ! defined (__declspec)
28 #error You need egcs 1.1 or newer for compiling!
32 #define DLLIMPORT __declspec (dllexport)
33 #else /* not BUILDING_DLL */
34 #define DLLIMPORT __declspec (dllimport)
37 #elif defined(WIN32_CLIENT_ONLY)
40 #define DLLIMPORT __declspec (dllexport)
42 #define DLLIMPORT __declspec (dllimport)
45 #else /* not CYGWIN, not MSVC, not MingW */
53 #undef HAVE_UNION_SEMUN
54 #define HAVE_UNION_SEMUN 1
59 #define IPC_PRIVATE 234564
60 #define IPC_NOWAIT 2048
81 int shmdt(const void *shmaddr);
82 void *shmat(int memId, void *shmaddr, int flag);
83 int shmctl(int shmid, int flag, struct shmid_ds * dummy);
84 int shmget(int memKey, int size, int flag);
94 unsigned short *array;
104 int semctl(int semId, int semNum, int flag, union semun);
105 int semget(int semKey, int semNum, int flags);
106 int semop(int semId, struct sembuf * sops, int flag);
112 #define WEXITSTATUS(w) (((w) >> 8) & 0xff)
113 #define WIFEXITED(w) (((w) & 0xff) == 0)
114 #define WIFSIGNALED(w) (((w) & 0x7f) > 0 && (((w) & 0x7f) < 0x7f))
115 #define WTERMSIG(w) ((w) & 0x7f)
117 #define sigmask(sig) ( 1 << ((sig)-1) )
119 /* Signal function return values */
123 #define SIG_DFL ((pqsigfunc)0)
124 #define SIG_ERR ((pqsigfunc)-1)
125 #define SIG_IGN ((pqsigfunc)1)
127 /* Some extra signals */
131 #define SIGABRT 22 /* Set to match W32 value -- not UNIX
141 #define SIGTTOU 22 /* Same as SIGABRT -- no problem, I hope */
148 int tz_minuteswest; /* Minutes west of GMT. */
149 int tz_dsttime; /* Nonzero if DST is ever in effect. */
152 /* for setitimer in backend/port/win32/timer.c */
153 #define ITIMER_REAL 0
156 struct timeval it_interval;
157 struct timeval it_value;
159 int setitimer(int which, const struct itimerval * value, struct itimerval * ovalue);
163 * Supplement to <sys/types.h>.
165 * Perl already has conflicting defines for uid_t and gid_t.
167 #ifndef PLPERL_HAVE_UID_GID
171 /* These are redefined by perl. */
177 #ifdef WIN32_CLIENT_ONLY
182 * Supplement to <sys/stat.h>.
184 #define lstat(path, sb) stat((path), (sb))
187 * Supplement to <fcntl.h>.
188 * This is the same value as _O_NOINHERIT in the MS header file. This is
189 * to ensure that we don't collide with a future definition. It means
190 * we cannot use _O_NOINHERIT ourselves.
192 #define O_SYNC 0x0080
195 * Supplement to <errno.h>.
199 #define EINTR WSAEINTR
200 #define EAGAIN WSAEWOULDBLOCK
201 #define EMSGSIZE WSAEMSGSIZE
202 #define EAFNOSUPPORT WSAEAFNOSUPPORT
203 #define EWOULDBLOCK WSAEWOULDBLOCK
204 #define ECONNRESET WSAECONNRESET
205 #define EINPROGRESS WSAEINPROGRESS
206 #define ENOBUFS WSAENOBUFS
207 #define EPROTONOSUPPORT WSAEPROTONOSUPPORT
208 #define ECONNREFUSED WSAECONNREFUSED
209 #define EBADFD WSAENOTSOCK
210 #define EOPNOTSUPP WSAEOPNOTSUPP
213 /* In backend/port/win32/signal.c */
214 extern DLLIMPORT HANDLE pgwin32_signal_event;
215 extern HANDLE pgwin32_initial_signal_pipe;
217 void pgwin32_signal_initialize(void);
218 HANDLE pgwin32_create_signal_listener(pid_t pid);
219 void pgwin32_dispatch_queued_signals(void);
220 void pg_queue_signal(int signum);
223 #define pg_usleep(t) pgwin32_backend_usleep(t)
224 void pgwin32_backend_usleep(long microsec);
227 /* In backend/port/win32/socket.c */
229 #define socket(af, type, protocol) pgwin32_socket(af, type, protocol)
230 #define accept(s, addr, addrlen) pgwin32_accept(s, addr, addrlen)
231 #define connect(s, name, namelen) pgwin32_connect(s, name, namelen)
232 #define select(n, r, w, e, timeout) pgwin32_select(n, r, w, e, timeout)
233 #define recv(s, buf, len, flags) pgwin32_recv(s, buf, len, flags)
234 #define send(s, buf, len, flags) pgwin32_send(s, buf, len, flags)
236 SOCKET pgwin32_socket(int af, int type, int protocol);
237 SOCKET pgwin32_accept(SOCKET s, struct sockaddr * addr, int *addrlen);
238 int pgwin32_connect(SOCKET s, const struct sockaddr * name, int namelen);
239 int pgwin32_select(int nfds, fd_set *readfs, fd_set *writefds, fd_set *exceptfds, const struct timeval * timeout);
240 int pgwin32_recv(SOCKET s, char *buf, int len, int flags);
241 int pgwin32_send(SOCKET s, char *buf, int len, int flags);
243 const char *pgwin32_socket_strerror(int err);
244 int pgwin32_waitforsinglesocket(SOCKET s, int what);
246 /* in backend/port/win32/security.c */
247 extern int pgwin32_is_admin(void);
248 extern int pgwin32_is_service(void);
251 /* in backend/port/win32/error.c */
252 extern void _dosmaperr(unsigned long);