00001
00002
00003 #if defined(_MSC_VER) || defined(__BORLANDC__)
00004 #define WIN32_ONLY_COMPILER
00005 #endif
00006
00007
00008
00009
00010
00011 #if defined(_WIN32_WINNT) && _WIN32_WINNT < 0x0501
00012 #undef _WIN32_WINNT
00013 #endif
00014 #ifndef _WIN32_WINNT
00015 #define _WIN32_WINNT 0x0501
00016 #endif
00017
00018
00019
00020
00021 #ifndef __BORLANDC__
00022 #define ENABLE_SSPI 1
00023 #endif
00024
00025
00026 #undef mkdir
00027
00028 #undef ERROR
00029
00030
00031
00032
00033
00034 #if !defined(__MINGW64_VERSION_MAJOR) || defined(WIN32_ONLY_COMPILER)
00035 #define _WINSOCKAPI_
00036 #endif
00037 #include <winsock2.h>
00038 #include <ws2tcpip.h>
00039 #include <windows.h>
00040 #undef small
00041 #include <process.h>
00042 #include <signal.h>
00043 #include <errno.h>
00044 #include <direct.h>
00045 #ifndef __BORLANDC__
00046 #include <sys/utime.h>
00047 #endif
00048 #undef near
00049
00050
00051 #define mkdir(a,b) mkdir(a)
00052
00053 #define ftruncate(a,b) chsize(a,b)
00054
00055
00056 #define fsync(fd) _commit(fd)
00057
00058
00059
00060
00061
00062
00063 #define HAVE_FSYNC_WRITETHROUGH
00064 #define FSYNC_WRITETHROUGH_IS_FSYNC
00065
00066 #define USES_WINSOCK
00067
00068
00069
00070
00071
00072
00073
00074
00075 #if defined(WIN32) || defined(__CYGWIN__)
00076
00077 #ifdef BUILDING_DLL
00078 #define PGDLLIMPORT __declspec (dllexport)
00079 #else
00080 #define PGDLLIMPORT __declspec (dllimport)
00081 #endif
00082
00083 #ifdef _MSC_VER
00084 #define PGDLLEXPORT __declspec (dllexport)
00085 #else
00086 #define PGDLLEXPORT
00087 #endif
00088 #else
00089 #define PGDLLIMPORT
00090 #define PGDLLEXPORT
00091 #endif
00092
00093
00094
00095
00096
00097 #undef HAVE_UNION_SEMUN
00098 #define HAVE_UNION_SEMUN 1
00099
00100 #define IPC_RMID 256
00101 #define IPC_CREAT 512
00102 #define IPC_EXCL 1024
00103 #define IPC_PRIVATE 234564
00104 #define IPC_NOWAIT 2048
00105 #define IPC_STAT 4096
00106
00107 #define EACCESS 2048
00108 #ifndef EIDRM
00109 #define EIDRM 4096
00110 #endif
00111
00112 #define SETALL 8192
00113 #define GETNCNT 16384
00114 #define GETVAL 65536
00115 #define SETVAL 131072
00116 #define GETPID 262144
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166 #define WIFEXITED(w) (((w) & 0XFFFFFF00) == 0)
00167 #define WIFSIGNALED(w) (!WIFEXITED(w))
00168 #define WEXITSTATUS(w) (w)
00169 #define WTERMSIG(w) (w)
00170
00171 #define sigmask(sig) ( 1 << ((sig)-1) )
00172
00173
00174 #undef SIG_DFL
00175 #undef SIG_ERR
00176 #undef SIG_IGN
00177 #define SIG_DFL ((pqsigfunc)0)
00178 #define SIG_ERR ((pqsigfunc)-1)
00179 #define SIG_IGN ((pqsigfunc)1)
00180
00181
00182 #define SIGHUP 1
00183 #define SIGQUIT 3
00184 #define SIGTRAP 5
00185 #define SIGABRT 22
00186 #define SIGKILL 9
00187 #define SIGPIPE 13
00188 #define SIGALRM 14
00189 #define SIGSTOP 17
00190 #define SIGTSTP 18
00191 #define SIGCONT 19
00192 #define SIGCHLD 20
00193 #define SIGTTIN 21
00194 #define SIGTTOU 22
00195 #define SIGWINCH 28
00196 #ifndef __BORLANDC__
00197 #define SIGUSR1 30
00198 #define SIGUSR2 31
00199 #endif
00200
00201
00202
00203
00204
00205 #ifndef HAVE_GETTIMEOFDAY
00206 struct timezone
00207 {
00208 int tz_minuteswest;
00209 int tz_dsttime;
00210 };
00211 #endif
00212
00213
00214 #define ITIMER_REAL 0
00215 struct itimerval
00216 {
00217 struct timeval it_interval;
00218 struct timeval it_value;
00219 };
00220
00221 int setitimer(int which, const struct itimerval * value, struct itimerval * ovalue);
00222
00223
00224
00225
00226
00227 #define pgoff_t __int64
00228 #ifdef WIN32_ONLY_COMPILER
00229 #define fseeko(stream, offset, origin) _fseeki64(stream, offset, origin)
00230 #define ftello(stream) _ftelli64(stream)
00231 #else
00232 #ifndef fseeko
00233 #define fseeko(stream, offset, origin) fseeko64(stream, offset, origin)
00234 #endif
00235 #ifndef ftello
00236 #define ftello(stream) ftello64(stream)
00237 #endif
00238 #endif
00239
00240
00241
00242
00243
00244
00245 #ifndef PLPERL_HAVE_UID_GID
00246 typedef int uid_t;
00247 typedef int gid_t;
00248 #endif
00249 typedef long key_t;
00250
00251 #ifdef WIN32_ONLY_COMPILER
00252 typedef int pid_t;
00253 #endif
00254
00255
00256
00257
00258 #define lstat(path, sb) stat((path), (sb))
00259
00260
00261
00262
00263
00264
00265
00266 #define O_DSYNC 0x0080
00267
00268
00269
00270
00271 #undef EAGAIN
00272 #undef EINTR
00273 #define EINTR WSAEINTR
00274 #define EAGAIN WSAEWOULDBLOCK
00275 #ifndef EMSGSIZE
00276 #define EMSGSIZE WSAEMSGSIZE
00277 #endif
00278 #ifndef EAFNOSUPPORT
00279 #define EAFNOSUPPORT WSAEAFNOSUPPORT
00280 #endif
00281 #ifndef EWOULDBLOCK
00282 #define EWOULDBLOCK WSAEWOULDBLOCK
00283 #endif
00284 #ifndef ECONNRESET
00285 #define ECONNRESET WSAECONNRESET
00286 #endif
00287 #ifndef EINPROGRESS
00288 #define EINPROGRESS WSAEINPROGRESS
00289 #endif
00290 #ifndef ENOBUFS
00291 #define ENOBUFS WSAENOBUFS
00292 #endif
00293 #ifndef EPROTONOSUPPORT
00294 #define EPROTONOSUPPORT WSAEPROTONOSUPPORT
00295 #endif
00296 #ifndef ECONNREFUSED
00297 #define ECONNREFUSED WSAECONNREFUSED
00298 #endif
00299 #ifndef EBADFD
00300 #define EBADFD WSAENOTSOCK
00301 #endif
00302 #ifndef EOPNOTSUPP
00303 #define EOPNOTSUPP WSAEOPNOTSUPP
00304 #endif
00305
00306
00307
00308
00309
00310
00311
00312 #if _MSC_VER >= 1600
00313 #pragma warning(disable:4005)
00314 #define EMSGSIZE WSAEMSGSIZE
00315 #define EAFNOSUPPORT WSAEAFNOSUPPORT
00316 #define EWOULDBLOCK WSAEWOULDBLOCK
00317 #define EPROTONOSUPPORT WSAEPROTONOSUPPORT
00318 #define ECONNRESET WSAECONNRESET
00319 #define EINPROGRESS WSAEINPROGRESS
00320 #define ENOBUFS WSAENOBUFS
00321 #define ECONNREFUSED WSAECONNREFUSED
00322 #define EOPNOTSUPP WSAEOPNOTSUPP
00323 #pragma warning(default:4005)
00324 #endif
00325
00326
00327
00328
00329
00330 #define locale_t _locale_t
00331 #define tolower_l _tolower_l
00332 #define toupper_l _toupper_l
00333 #define towlower_l _towlower_l
00334 #define towupper_l _towupper_l
00335 #define isdigit_l _isdigit_l
00336 #define iswdigit_l _iswdigit_l
00337 #define isalpha_l _isalpha_l
00338 #define iswalpha_l _iswalpha_l
00339 #define isalnum_l _isalnum_l
00340 #define iswalnum_l _iswalnum_l
00341 #define isupper_l _isupper_l
00342 #define iswupper_l _iswupper_l
00343 #define islower_l _islower_l
00344 #define iswlower_l _iswlower_l
00345 #define isgraph_l _isgraph_l
00346 #define iswgraph_l _iswgraph_l
00347 #define isprint_l _isprint_l
00348 #define iswprint_l _iswprint_l
00349 #define ispunct_l _ispunct_l
00350 #define iswpunct_l _iswpunct_l
00351 #define isspace_l _isspace_l
00352 #define iswspace_l _iswspace_l
00353 #define strcoll_l _strcoll_l
00354 #define wcscoll_l _wcscoll_l
00355 #define wcstombs_l _wcstombs_l
00356 #define mbstowcs_l _mbstowcs_l
00357
00358
00359
00360 extern PGDLLIMPORT volatile int pg_signal_queue;
00361 extern PGDLLIMPORT int pg_signal_mask;
00362 extern HANDLE pgwin32_signal_event;
00363 extern HANDLE pgwin32_initial_signal_pipe;
00364
00365 #define UNBLOCKED_SIGNAL_QUEUE() (pg_signal_queue & ~pg_signal_mask)
00366
00367
00368 void pgwin32_signal_initialize(void);
00369 HANDLE pgwin32_create_signal_listener(pid_t pid);
00370 void pgwin32_dispatch_queued_signals(void);
00371 void pg_queue_signal(int signum);
00372
00373
00374 #ifndef FRONTEND
00375 #define socket(af, type, protocol) pgwin32_socket(af, type, protocol)
00376 #define accept(s, addr, addrlen) pgwin32_accept(s, addr, addrlen)
00377 #define connect(s, name, namelen) pgwin32_connect(s, name, namelen)
00378 #define select(n, r, w, e, timeout) pgwin32_select(n, r, w, e, timeout)
00379 #define recv(s, buf, len, flags) pgwin32_recv(s, buf, len, flags)
00380 #define send(s, buf, len, flags) pgwin32_send(s, buf, len, flags)
00381
00382 SOCKET pgwin32_socket(int af, int type, int protocol);
00383 SOCKET pgwin32_accept(SOCKET s, struct sockaddr * addr, int *addrlen);
00384 int pgwin32_connect(SOCKET s, const struct sockaddr * name, int namelen);
00385 int pgwin32_select(int nfds, fd_set *readfs, fd_set *writefds, fd_set *exceptfds, const struct timeval * timeout);
00386 int pgwin32_recv(SOCKET s, char *buf, int len, int flags);
00387 int pgwin32_send(SOCKET s, const void *buf, int len, int flags);
00388
00389 const char *pgwin32_socket_strerror(int err);
00390 int pgwin32_waitforsinglesocket(SOCKET s, int what, int timeout);
00391
00392 extern int pgwin32_noblock;
00393
00394
00395 extern int pgwin32_is_admin(void);
00396 extern int pgwin32_is_service(void);
00397 #endif
00398
00399
00400 extern int pgwin32_ReserveSharedMemoryRegion(HANDLE);
00401
00402
00403 extern void pgwin32_install_crashdump_handler(void);
00404
00405
00406 extern void _dosmaperr(unsigned long);
00407
00408
00409 extern int pgwin32_putenv(const char *);
00410 extern void pgwin32_unsetenv(const char *);
00411
00412 #define putenv(x) pgwin32_putenv(x)
00413 #define unsetenv(x) pgwin32_unsetenv(x)
00414
00415
00416 #ifdef WIN32_ONLY_COMPILER
00417
00418 #ifndef _WIN64
00419 typedef long ssize_t;
00420 #else
00421 typedef __int64 ssize_t;
00422 #endif
00423
00424 #ifndef __BORLANDC__
00425 typedef unsigned short mode_t;
00426
00427 #define S_IRUSR _S_IREAD
00428 #define S_IWUSR _S_IWRITE
00429 #define S_IXUSR _S_IEXEC
00430 #define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
00431
00432 #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
00433 #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
00434 #endif
00435
00436 #define F_OK 0
00437 #define W_OK 2
00438 #define R_OK 4
00439
00440 #define isinf(x) ((_fpclass(x) == _FPCLASS_PINF) || (_fpclass(x) == _FPCLASS_NINF))
00441 #define isnan(x) _isnan(x)
00442
00443
00444 #define DLSUFFIX ".dll"
00445
00446 #ifdef __BORLANDC__
00447
00448
00449 #ifndef INVALID_FILE_ATTRIBUTES
00450 #define INVALID_FILE_ATTRIBUTES ((DWORD) -1)
00451 #endif
00452
00453
00454 #ifndef O_RANDOM
00455 #define O_RANDOM 0x0010
00456 #define O_SEQUENTIAL 0x0020
00457 #define O_TEMPORARY 0x0040
00458 #define O_SHORT_LIVED 0x1000
00459 #define _O_SHORT_LIVED O_SHORT_LIVED
00460 #endif
00461 #endif
00462 #endif
00463
00464
00465 #ifndef __BORLANDC__
00466 #define S_IRGRP 0
00467 #define S_IWGRP 0
00468 #define S_IXGRP 0
00469 #define S_IRWXG 0
00470 #define S_IROTH 0
00471 #define S_IWOTH 0
00472 #define S_IXOTH 0
00473 #define S_IRWXO 0
00474
00475 #endif