2 * Copyright (C) 1996-2014 The Squid Software Foundation and contributors
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
10 * AUTHOR: Andrey Shorin <tolsty@tushino.com>
11 * AUTHOR: Guido Serassio <serassio@squid-cache.org>
14 #ifndef SQUID_OS_MSWINDOWS_H
15 #define SQUID_OS_MSWINDOWS_H
19 /****************************************************************************
20 *--------------------------------------------------------------------------*
21 * DO *NOT* MAKE ANY CHANGES below here unless you know what you're doing...*
22 *--------------------------------------------------------------------------*
23 ****************************************************************************/
25 /* we target Windows XP and later - some API are missing otherwise */
31 #define _WIN32_WINNT WINVER
33 #endif /* _SQUID_MINGW_ */
40 #endif /* HAVE_FCNTL_H */
43 #endif /* HAVE_FCNTL_H */
46 #endif /* HAVE_SYS_STAT_H */
48 #define ACL WindowsACL
49 #if defined(_MSC_VER) /* Microsoft C Compiler ONLY */
51 #define _CRT_SECURE_NO_DEPRECATE
52 #pragma warning( disable : 4290 )
53 #pragma warning( disable : 4996 )
57 /* Some MinGW version defines min() and max() as macros
58 causing the fail of the build process. The following
59 #define will disable that definition
61 #if defined(__GNUC__) && !NOMINMAX
65 /// some builds of MinGW do not define IPV6_V6ONLY socket option
66 #if !defined(IPV6_V6ONLY)
67 #define IPV6_V6ONLY 27
70 #if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64
71 # define __USE_FILE_OFFSET64 1
74 #if defined(_MSC_VER) /* Microsoft C Compiler ONLY */
76 #if defined(__USE_FILE_OFFSET64)
77 typedef uint64_t ino_t
;
79 typedef unsigned long ino_t
;
82 #define INT64_MAX _I64_MAX
83 #define INT64_MIN _I64_MIN
85 #include "default_config_file.h"
86 /* Some tricks for MS Compilers */
88 #define THREADLOCAL __declspec(thread)
90 #elif defined(__GNUC__) /* gcc environment */
92 #define THREADLOCAL __attribute__((section(".tls")))
96 /* ONLY Microsoft C Compiler needs these: */
98 #define alloca _alloca
99 #define fileno _fileno
100 #define fstat _fstati64
101 #define lseek _lseeki64
102 #define memccpy _memccpy
103 #define mktemp _mktemp
104 #define snprintf _snprintf
105 #define stat _stati64
106 #define strcasecmp _stricmp
107 #define strlwr _strlwr
108 #define strncasecmp _strnicmp
109 #define tempnam _tempnam
110 #define vsnprintf _vsnprintf
113 /* Microsoft C Compiler and CygWin need these. MinGW does not */
114 #if defined(_MSC_VER) || _SQUID_CYGWIN_
115 SQUIDCEXTERN
int WIN32_ftruncate(int fd
, off_t size
);
116 #define ftruncate WIN32_ftruncate
117 SQUIDCEXTERN
int WIN32_truncate(const char *pathname
, off_t length
);
118 #define truncate WIN32_truncate
122 /* All three compiler systems need these: */
125 #define fdopen _fdopen
126 #define getcwd _getcwd
127 #define getpid _getpid
128 #define mkdir(p,F) mkdir((p))
129 #define pclose _pclose
131 #define putenv _putenv
132 #define setmode _setmode
133 #define sleep(t) Sleep((t)*1000)
135 #define unlink _unlink
138 #define O_RDONLY _O_RDONLY
141 #define O_WRONLY _O_WRONLY
144 #define O_RDWR _O_RDWR
147 #define O_APPEND _O_APPEND
150 #define O_CREAT _O_CREAT
153 #define O_TRUNC _O_TRUNC
156 #define O_EXCL _O_EXCL
159 #define O_TEXT _O_TEXT
162 #define O_BINARY _O_BINARY
165 #define O_RAW _O_BINARY
168 #define O_TEMPORARY _O_TEMPORARY
171 #define O_NOINHERIT _O_NOINHERIT
174 #define O_SEQUENTIAL _O_SEQUENTIAL
177 #define O_RANDOM _O_RANDOM
184 #define S_IFMT _S_IFMT
187 #define S_IFDIR _S_IFDIR
190 #define S_IFCHR _S_IFCHR
193 #define S_IFREG _S_IFREG
196 #define S_IREAD _S_IREAD
199 #define S_IWRITE _S_IWRITE
202 #define S_IEXEC _S_IEXEC
208 #if defined(_MSC_VER)
209 #define S_ISDIR(m) (((m) & _S_IFDIR) == _S_IFDIR)
212 #define SIGHUP 1 /* hangup */
213 #define SIGKILL 9 /* kill (cannot be caught or ignored) */
214 #define SIGBUS 10 /* bus error */
215 #define SIGPIPE 13 /* write on a pipe with no one to read it */
216 #define SIGCHLD 20 /* to parent on child stop or exit */
217 #define SIGUSR1 30 /* user defined signal 1 */
218 #define SIGUSR2 31 /* user defined signal 2 */
221 typedef unsigned char boolean
;
222 typedef unsigned char u_char
;
223 typedef unsigned int u_int
;
226 #if defined(_MSC_VER)
232 char *pw_name
; /* user name */
233 char *pw_passwd
; /* user password */
234 uid_t pw_uid
; /* user id */
235 gid_t pw_gid
; /* group id */
236 char *pw_gecos
; /* real name */
237 char *pw_dir
; /* home directory */
238 char *pw_shell
; /* shell program */
242 char *gr_name
; /* group name */
243 char *gr_passwd
; /* group password */
244 gid_t gr_gid
; /* group id */
245 char **gr_mem
; /* group members */
250 long f_type
; /* type of filesystem (see below) */
251 long f_bsize
; /* optimal transfer block size */
252 long f_blocks
; /* total data blocks in file system */
253 long f_bfree
; /* free blocks in fs */
254 long f_bavail
; /* free blocks avail to non-superuser */
255 long f_files
; /* total file nodes in file system */
256 long f_ffree
; /* free file nodes in fs */
257 long f_fsid
; /* file system id */
258 long f_namelen
; /* maximum length of filenames */
259 long f_spare
[6]; /* spare for later */
263 #if !HAVE_GETTIMEOFDAY
265 int tz_minuteswest
; /* minutes west of Greenwich */
266 int tz_dsttime
; /* type of dst correction */
270 #define CHANGE_FD_SETSIZE 1
271 #if CHANGE_FD_SETSIZE && SQUID_MAXFD > DEFAULT_FD_SETSIZE
272 #define FD_SETSIZE SQUID_MAXFD
278 #include <winsock2.h>
285 #include <ws2tcpip.h>
288 #if (EAI_NODATA == EAI_NONAME)
290 #define EAI_NODATA WSANO_DATA
293 #if defined(_MSC_VER)
294 /* Hack to suppress compiler warnings on FD_SET() & FD_CLR() */
295 #pragma warning (push)
296 #pragma warning (disable:4142)
299 /* prevent inclusion of wingdi.h */
303 #if defined(_MSC_VER)
304 #pragma warning (pop)
309 typedef char * caddr_t
;
311 #ifndef _PATH_DEVNULL
312 #define _PATH_DEVNULL "NUL"
321 #define EISCONN WSAEISCONN
324 #define EINPROGRESS WSAEINPROGRESS
327 #define EWOULDBLOCK WSAEWOULDBLOCK
330 #define EALREADY WSAEALREADY
333 #define ETIMEDOUT WSAETIMEDOUT
336 #define ECONNREFUSED WSAECONNREFUSED
339 #define ECONNRESET WSAECONNRESET
342 #define ENOTCONN WSAENOTCONN
345 #define ERESTART WSATRY_AGAIN
348 #define EAFNOSUPPORT WSAEAFNOSUPPORT
351 #define ENETUNREACH WSAENETUNREACH
354 #define ENOTSUP WSAEOPNOTSUPP
358 #define h_errno errno /* we'll set it ourselves */
361 #define FD_CLR(fd, set) do { \
363 SOCKET __sock = _get_osfhandle(fd); \
364 for (__i = 0; __i < ((fd_set FAR *)(set))->fd_count ; __i++) { \
365 if (((fd_set FAR *)(set))->fd_array[__i] == __sock) { \
366 while (__i < ((fd_set FAR *)(set))->fd_count-1) { \
367 ((fd_set FAR *)(set))->fd_array[__i] = \
368 ((fd_set FAR *)(set))->fd_array[__i+1]; \
371 ((fd_set FAR *)(set))->fd_count--; \
378 #define FD_SET(fd, set) do { \
380 SOCKET __sock = _get_osfhandle(fd); \
381 for (__i = 0; __i < ((fd_set FAR *)(set))->fd_count; __i++) { \
382 if (((fd_set FAR *)(set))->fd_array[__i] == (__sock)) { \
386 if (__i == ((fd_set FAR *)(set))->fd_count) { \
387 if (((fd_set FAR *)(set))->fd_count < FD_SETSIZE) { \
388 ((fd_set FAR *)(set))->fd_array[__i] = (__sock); \
389 ((fd_set FAR *)(set))->fd_count++; \
395 #define FD_ISSET(fd, set) Win32__WSAFDIsSet(fd, (fd_set FAR *)(set))
397 /* internal to Microsoft CRTLIB */
399 long osfhnd
; /* underlying OS file HANDLE */
400 char osfile
; /* attributes of file (e.g., open in text mode?) */
401 char pipech
; /* one char buffer for handles opened on pipes */
404 CRITICAL_SECTION lock
;
408 #define IOINFO_ARRAY_ELTS (1 << IOINFO_L2E)
409 #define _pioinfo(i) ( __pioinfo[(i) >> IOINFO_L2E] + ((i) & (IOINFO_ARRAY_ELTS - 1)) )
410 #define _osfile(i) ( _pioinfo(i)->osfile )
411 #define _osfhnd(i) ( _pioinfo(i)->osfhnd )
412 #define FOPEN 0x01 /* file handle open */
414 #if defined(_MSC_VER)
415 SQUIDCEXTERN _CRTIMP ioinfo
* __pioinfo
[];
416 SQUIDCEXTERN
int __cdecl
_free_osfhnd(int);
420 __MINGW_IMPORT ioinfo
* __pioinfo
[];
421 SQUIDCEXTERN
int _free_osfhnd(int);
424 SQUIDCEXTERN THREADLOCAL
int ws32_result
;
426 #if defined(__cplusplus)
431 char l_so_type
[sizeof(int)];
432 int l_so_type_siz
= sizeof(l_so_type
);
433 SOCKET sock
= _get_osfhandle(fd
);
435 if (::getsockopt(sock
, SOL_SOCKET
, SO_TYPE
, l_so_type
, &l_so_type_siz
) == 0) {
437 if (closesocket(sock
) == SOCKET_ERROR
) {
438 errno
= WSAGetLastError();
448 #if defined(_MSC_VER) /* Microsoft C Compiler ONLY */
451 #define _S_IREAD 0x0100
455 #define _S_IWRITE 0x0080
459 open(const char *filename
, int oflag
, int pmode
= 0)
461 return _open(filename
, oflag
, pmode
& (_S_IREAD
| _S_IWRITE
));
466 read(int fd
, void * buf
, size_t siz
)
468 char l_so_type
[sizeof(int)];
469 int l_so_type_siz
= sizeof(l_so_type
);
470 SOCKET sock
= _get_osfhandle(fd
);
472 if (::getsockopt(sock
, SOL_SOCKET
, SO_TYPE
, l_so_type
, &l_so_type_siz
) == 0)
473 return ::recv(sock
, (char FAR
*) buf
, (int)siz
, 0);
475 return _read(fd
, buf
, (unsigned int)siz
);
479 write(int fd
, const void * buf
, size_t siz
)
481 char l_so_type
[sizeof(int)];
482 int l_so_type_siz
= sizeof(l_so_type
);
483 SOCKET sock
= _get_osfhandle(fd
);
485 if (::getsockopt(sock
, SOL_SOCKET
, SO_TYPE
, l_so_type
, &l_so_type_siz
) == 0)
486 return ::send(sock
, (char FAR
*) buf
, siz
, 0);
488 return _write(fd
, buf
, siz
);
492 index(const char *s
, int c
)
494 return (char *)strchr(s
,c
);
497 // stdlib <functional> definitions are required before std API redefinitions.
498 #include <functional>
500 /** \cond AUTODOCS-IGNORE */
506 * Each of these functions is defined in the Squid namespace so as not to
507 * clash with the winsock.h and winsock2.h definitions.
508 * It is then paired with a #define to cause these wrappers to be used by
509 * the main code instead of those system definitions.
511 * We do this wrapper in order to:
512 * - cast the parameter types in only one place, and
513 * - record errors in POSIX errno variable, and
514 * - map the FD value used by Squid to the socket handes used by Windows.
518 accept(int s
, struct sockaddr
* a
, socklen_t
* l
)
521 if ((result
= ::accept(_get_osfhandle(s
), a
, l
)) == INVALID_SOCKET
) {
522 if (WSAEMFILE
== (errno
= WSAGetLastError()))
526 return _open_osfhandle(result
, 0);
528 #define accept(s,a,l) Squid::accept(s,a,reinterpret_cast<socklen_t*>(l))
531 bind(int s
, const struct sockaddr
* n
, socklen_t l
)
533 if (::bind(_get_osfhandle(s
),n
,l
) == SOCKET_ERROR
) {
534 errno
= WSAGetLastError();
539 #define bind(s,n,l) Squid::bind(s,n,l)
542 connect(int s
, const struct sockaddr
* n
, socklen_t l
)
544 if (::connect(_get_osfhandle(s
),n
,l
) == SOCKET_ERROR
) {
545 if (WSAEMFILE
== (errno
= WSAGetLastError()))
551 #define connect(s,n,l) Squid::connect(s,n,l)
553 inline struct hostent
*
554 gethostbyname(const char *n
) {
555 HOSTENT FAR
* result
;
556 if ((result
= ::gethostbyname(n
)) == NULL
)
557 errno
= WSAGetLastError();
560 #define gethostbyname(n) Squid::gethostbyname(n)
563 getservbyname(const char * n
, const char * p
)
565 SERVENT FAR
* result
;
566 if ((result
= ::getservbyname(n
, p
)) == NULL
)
567 errno
= WSAGetLastError();
570 #define getservbyname(n,p) Squid::getservbyname(n,p)
573 gethostbyaddr(const void * a
, size_t l
, int t
)
575 HOSTENT FAR
* result
;
576 if ((result
= ::gethostbyaddr((const char*)a
, l
, t
)) == NULL
)
577 errno
= WSAGetLastError();
580 #define gethostbyaddr(a,l,t) Squid::gethostbyaddr(a,l,t)
583 getsockname(int s
, struct sockaddr
* n
, socklen_t
* l
)
586 if (::getsockname(_get_osfhandle(s
), n
, &i
) == SOCKET_ERROR
) {
587 errno
= WSAGetLastError();
592 #define getsockname(s,a,l) Squid::getsockname(s,a,reinterpret_cast<socklen_t*>(l))
595 gethostname(char * n
, size_t l
)
597 if ((::gethostname(n
, l
)) == SOCKET_ERROR
) {
598 errno
= WSAGetLastError();
603 #define gethostname(n,l) Squid::gethostname(n,l)
606 getsockopt(int s
, int l
, int o
, void * v
, socklen_t
* n
)
609 if ((::getsockopt(_get_osfhandle(s
), l
, o
,(char *) v
, n
)) == SOCKET_ERROR
) {
610 errno
= WSAGetLastError();
615 #define getsockopt(s,l,o,v,n) Squid::getsockopt(s,l,o,v,n)
617 /* Simple ioctl() emulation */
619 ioctl(int s
, int c
, void * a
)
621 if ((::ioctlsocket(_get_osfhandle(s
), c
, (u_long FAR
*)a
)) == SOCKET_ERROR
) {
622 errno
= WSAGetLastError();
627 #define ioctl(s,c,a) Squid::ioctl(s,c,a)
630 ioctlsocket(int s
, long c
, u_long FAR
* a
)
632 if ((::ioctlsocket(_get_osfhandle(s
), c
, a
)) == SOCKET_ERROR
) {
633 errno
= WSAGetLastError();
638 #define ioctlsocket(s,c,a) Squid::ioctlsocket(s,c,a)
643 if (::listen(_get_osfhandle(s
), b
) == SOCKET_ERROR
) {
644 if (WSAEMFILE
== (errno
= WSAGetLastError()))
650 #define listen(s,b) Squid::listen(s,b)
653 recv(int s
, void * b
, size_t l
, int f
)
656 if ((result
= ::recv(_get_osfhandle(s
), (char *)b
, l
, f
)) == SOCKET_ERROR
) {
657 errno
= WSAGetLastError();
662 #define recv(s,b,l,f) Squid::recv(s,b,l,f)
665 recvfrom(int s
, void * b
, size_t l
, int f
, struct sockaddr
* fr
, socklen_t
* fl
)
669 if ((result
= ::recvfrom(_get_osfhandle(s
), (char *)b
, l
, f
, fr
, &ifl
)) == SOCKET_ERROR
) {
670 errno
= WSAGetLastError();
675 #define recvfrom(s,b,l,f,r,n) Squid::recvfrom(s,b,l,f,r,reinterpret_cast<socklen_t*>(n))
678 select(int n
, fd_set
* r
, fd_set
* w
, fd_set
* e
, struct timeval
* t
)
681 if ((result
= ::select(n
,r
,w
,e
,t
)) == SOCKET_ERROR
) {
682 errno
= WSAGetLastError();
687 #define select(n,r,w,e,t) Squid::select(n,r,w,e,t)
690 send(int s
, const char * b
, size_t l
, int f
)
693 if ((result
= ::send(_get_osfhandle(s
), b
, l
, f
)) == SOCKET_ERROR
) {
694 errno
= WSAGetLastError();
699 #define send(s,b,l,f) Squid::send(s,reinterpret_cast<const char*>(b),l,f)
702 sendto(int s
, const void * b
, size_t l
, int f
, const struct sockaddr
* t
, socklen_t tl
)
705 if ((result
= ::sendto(_get_osfhandle(s
), (char *)b
, l
, f
, t
, tl
)) == SOCKET_ERROR
) {
706 errno
= WSAGetLastError();
711 #define sendto(a,b,l,f,t,n) Squid::sendto(a,b,l,f,t,n)
714 setsockopt(SOCKET s
, int l
, int o
, const void * v
, socklen_t n
)
718 socket
= ((s
== INVALID_SOCKET
) ? s
: (SOCKET
)_get_osfhandle((int)s
));
720 if (::setsockopt(socket
, l
, o
, (const char *)v
, n
) == SOCKET_ERROR
) {
721 errno
= WSAGetLastError();
726 #define setsockopt(s,l,o,v,n) Squid::setsockopt(s,l,o,v,n)
729 shutdown(int s
, int h
)
731 if (::shutdown(_get_osfhandle(s
),h
) == SOCKET_ERROR
) {
732 errno
= WSAGetLastError();
737 #define shutdown(s,h) Squid::shutdown(s,h)
740 socket(int f
, int t
, int p
)
743 if ((result
= ::socket(f
, t
, p
)) == INVALID_SOCKET
) {
744 if (WSAEMFILE
== (errno
= WSAGetLastError()))
748 return _open_osfhandle(result
, 0);
750 #define socket(f,t,p) Squid::socket(f,t,p)
755 return _pipe(pipefd
,4096,_O_BINARY
);
757 #define pipe(a) Squid::pipe(a)
760 WSAAsyncSelect(int s
, HWND h
, unsigned int w
, long e
)
762 if (::WSAAsyncSelect(_get_osfhandle(s
), h
, w
, e
) == SOCKET_ERROR
) {
763 errno
= WSAGetLastError();
768 #define WSAAsyncSelect(s,h,w,e) Squid::WSAAsyncSelect(s,h,w,e)
770 #undef WSADuplicateSocket
772 WSADuplicateSocket(int s
, DWORD n
, LPWSAPROTOCOL_INFO l
)
775 if (::WSADuplicateSocketW(_get_osfhandle(s
), n
, l
) == SOCKET_ERROR
) {
777 if (::WSADuplicateSocketA(_get_osfhandle(s
), n
, l
) == SOCKET_ERROR
) {
779 errno
= WSAGetLastError();
784 #define WSADuplicateSocket(s,n,l) Squid::WSADuplicateSocket(s,n,l)
788 WSASocket(int a
, int t
, int p
, LPWSAPROTOCOL_INFO i
, GROUP g
, DWORD f
)
792 if ((result
= ::WSASocketW(a
, t
, p
, i
, g
, f
)) == INVALID_SOCKET
) {
794 if ((result
= ::WSASocketA(a
, t
, p
, i
, g
, f
)) == INVALID_SOCKET
) {
796 if (WSAEMFILE
== (errno
= WSAGetLastError()))
800 return _open_osfhandle(result
, 0);
802 #define WSASocket(a,t,p,i,g,f) Squid::WSASocket(a,t,p,i,g,f)
804 } /* namespace Squid */
806 #else /* #ifdef __cplusplus */
807 #define connect(s,n,l) \
808 (SOCKET_ERROR == connect(_get_osfhandle(s),n,l) ? \
809 (WSAEMFILE == (errno = WSAGetLastError()) ? errno = EMFILE : -1, -1) : 0)
810 #define gethostbyname(n) \
811 (NULL == ((HOSTENT FAR*)(ws32_result = (int)gethostbyname(n))) ? \
812 (errno = WSAGetLastError()), (HOSTENT FAR*)NULL : (HOSTENT FAR*)ws32_result)
813 #define gethostname(n,l) \
814 (SOCKET_ERROR == gethostname(n,l) ? \
815 (errno = WSAGetLastError()), -1 : 0)
816 #define recv(s,b,l,f) \
817 (SOCKET_ERROR == (ws32_result = recv(_get_osfhandle(s),b,l,f)) ? \
818 (errno = WSAGetLastError()), -1 : ws32_result)
819 #define sendto(s,b,l,f,t,tl) \
820 (SOCKET_ERROR == (ws32_result = sendto(_get_osfhandle(s),b,l,f,t,tl)) ? \
821 (errno = WSAGetLastError()), -1 : ws32_result)
822 #define select(n,r,w,e,t) \
823 (SOCKET_ERROR == (ws32_result = select(n,r,w,e,t)) ? \
824 (errno = WSAGetLastError()), -1 : ws32_result)
825 #define socket(f,t,p) \
826 (INVALID_SOCKET == ((SOCKET)(ws32_result = (int)socket(f,t,p))) ? \
827 ((WSAEMFILE == (errno = WSAGetLastError()) ? errno = EMFILE : -1), -1) : \
828 (SOCKET)_open_osfhandle(ws32_result,0))
829 #define write _write /* Needed in util.c */
830 #define open _open /* Needed in win32lib.c */
831 #endif /* #ifdef __cplusplus */
833 /* provide missing definitions from resoruce.h */
834 /* NP: sys/resource.h and sys/time.h are apparently order-dependant. */
836 #include <sys/time.h>
838 #if HAVE_SYS_RESOURCE_H
839 #include <sys/resource.h>
841 #define RUSAGE_SELF 0 /* calling process */
842 #define RUSAGE_CHILDREN -1 /* terminated child processes */
845 struct timeval ru_utime
; /* user time used */
846 struct timeval ru_stime
; /* system time used */
847 long ru_maxrss
; /* integral max resident set size */
848 long ru_ixrss
; /* integral shared text memory size */
849 long ru_idrss
; /* integral unshared data size */
850 long ru_isrss
; /* integral unshared stack size */
851 long ru_minflt
; /* page reclaims */
852 long ru_majflt
; /* page faults */
853 long ru_nswap
; /* swaps */
854 long ru_inblock
; /* block input operations */
855 long ru_oublock
; /* block output operations */
856 long ru_msgsnd
; /* messages sent */
857 long ru_msgrcv
; /* messages received */
858 long ru_nsignals
; /* signals received */
859 long ru_nvcsw
; /* voluntary context switches */
860 long ru_nivcsw
; /* involuntary context switches */
862 #endif /* HAVE_SYS_RESOURCE_H */
866 SQUIDCEXTERN
int chroot(const char *dirname
);
867 SQUIDCEXTERN
int kill(pid_t
, int);
869 SQUIDCEXTERN
int statfs(const char *, struct statfs
*);
871 SQUIDCEXTERN
struct passwd
* getpwnam(char *unused
);
872 SQUIDCEXTERN
struct group
* getgrnam(char *unused
);
915 /* for some reason autoconf misdetects getpagesize.. */
916 #if HAVE_GETPAGESIZE && _SQUID_MINGW_
917 #undef HAVE_GETPAGESIZE
920 #if !HAVE_GETPAGESIZE
921 /* And now we define a compatibility layer */
922 size_t getpagesize();
923 #define HAVE_GETPAGESIZE 2
926 SQUIDCEXTERN
void WIN32_ExceptionHandlerInit(void);
927 SQUIDCEXTERN
int Win32__WSAFDIsSet(int fd
, fd_set
* set
);
928 SQUIDCEXTERN DWORD
WIN32_IpAddrChangeMonitorInit();
930 /* gcc doesn't recognize the Windows native 64 bit formatting tags causing
931 * the compile fail, so we must disable the check on native Windows.
934 #define PRINTF_FORMAT_ARG1
935 #define PRINTF_FORMAT_ARG2
936 #define PRINTF_FORMAT_ARG3
939 /* XXX: the logic around this is a bit warped:
940 * we #define ACL unconditionally at the top of this file,
941 * then #undef ACL unconditionally hafway down,
942 * then here re-define ACL to the same value as at the top,
943 * then include windows.h and #undef ACL again.
946 #define ACL WindowsACL
947 #define _MSWIN_ACL_WAS_NOT_DEFINED 1
950 #if _MSWIN_ACL_WAS_NOT_DEFINED
952 #undef _MSWIN_ACL_WAS_NOT_DEFINED
956 /* syslog compatibility layer derives from git */
962 #define LOG_WARNING 4
966 #define LOG_DAEMON (3<<3)
968 void openlog(const char *ident
, int logopt
, int facility
);
969 void syslog(int priority
, const char *fmt
, ...);
973 /* MinGW missing bits from sys/wait.h */
974 /* A status looks like:
975 * <2 bytes info> <2 bytes code>
977 * <code> == 0, child has exited, info is the exit value
978 * <code> == 1..7e, child has exited, info is the signal number.
979 * <code> == 7f, child has stopped, info was the signal number.
980 * <code> == 80, there was a core dump.
982 #define WIFEXITED(w) (((w) & 0xff) == 0)
983 #define WIFSIGNALED(w) (((w) & 0x7f) > 0 && (((w) & 0x7f) < 0x7f))
984 #define WIFSTOPPED(w) (((w) & 0xff) == 0x7f)
985 #define WEXITSTATUS(w) (((w) >> 8) & 0xff)
986 #define WTERMSIG(w) ((w) & 0x7f)
987 #define WSTOPSIG WEXITSTATUS
991 void WIN32_maperror(unsigned long WIN32_oserrno
);
993 #endif /* _SQUID_WINDOWS_ */
994 #endif /* SQUID_OS_MSWINDOWS_H */