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_ */
35 #include "compat/initgroups.h"
42 #endif /* HAVE_FCNTL_H */
45 #endif /* HAVE_FCNTL_H */
48 #endif /* HAVE_SYS_STAT_H */
50 #define ACL WindowsACL
51 #if defined(_MSC_VER) /* Microsoft C Compiler ONLY */
53 #define _CRT_SECURE_NO_DEPRECATE
54 #pragma warning( disable : 4290 )
55 #pragma warning( disable : 4996 )
59 /* Some MinGW version defines min() and max() as macros
60 causing the fail of the build process. The following
61 #define will disable that definition
63 #if defined(__GNUC__) && !NOMINMAX
67 /// some builds of MinGW do not define IPV6_V6ONLY socket option
68 #if !defined(IPV6_V6ONLY)
69 #define IPV6_V6ONLY 27
72 #if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64
73 # define __USE_FILE_OFFSET64 1
76 #if defined(_MSC_VER) /* Microsoft C Compiler ONLY */
78 #if defined(__USE_FILE_OFFSET64)
79 typedef uint64_t ino_t
;
81 typedef unsigned long ino_t
;
84 #define INT64_MAX _I64_MAX
85 #define INT64_MIN _I64_MIN
87 #include "default_config_file.h"
88 /* Some tricks for MS Compilers */
90 #define THREADLOCAL __declspec(thread)
92 #elif defined(__GNUC__) /* gcc environment */
94 #define THREADLOCAL __attribute__((section(".tls")))
98 /* ONLY Microsoft C Compiler needs these: */
100 #define alloca _alloca
101 #define fileno _fileno
102 #define fstat _fstati64
103 #define lseek _lseeki64
104 #define memccpy _memccpy
105 #define mktemp _mktemp
106 #define snprintf _snprintf
107 #define stat _stati64
108 #define strcasecmp _stricmp
109 #define strlwr _strlwr
110 #define strncasecmp _strnicmp
111 #define tempnam _tempnam
112 #define vsnprintf _vsnprintf
115 /* Microsoft C Compiler and CygWin need these. MinGW does not */
116 #if defined(_MSC_VER) || _SQUID_CYGWIN_
117 SQUIDCEXTERN
int WIN32_ftruncate(int fd
, off_t size
);
118 #define ftruncate WIN32_ftruncate
119 SQUIDCEXTERN
int WIN32_truncate(const char *pathname
, off_t length
);
120 #define truncate WIN32_truncate
124 /* All three compiler systems need these: */
127 #define fdopen _fdopen
128 #define getcwd _getcwd
129 #define getpid _getpid
130 #define mkdir(p,F) mkdir((p))
131 #define pclose _pclose
133 #define putenv _putenv
134 #define setmode _setmode
135 #define sleep(t) Sleep((t)*1000)
137 #define unlink _unlink
140 #define O_RDONLY _O_RDONLY
143 #define O_WRONLY _O_WRONLY
146 #define O_RDWR _O_RDWR
149 #define O_APPEND _O_APPEND
152 #define O_CREAT _O_CREAT
155 #define O_TRUNC _O_TRUNC
158 #define O_EXCL _O_EXCL
161 #define O_TEXT _O_TEXT
164 #define O_BINARY _O_BINARY
167 #define O_RAW _O_BINARY
170 #define O_TEMPORARY _O_TEMPORARY
173 #define O_NOINHERIT _O_NOINHERIT
176 #define O_SEQUENTIAL _O_SEQUENTIAL
179 #define O_RANDOM _O_RANDOM
186 #define S_IFMT _S_IFMT
189 #define S_IFDIR _S_IFDIR
192 #define S_IFCHR _S_IFCHR
195 #define S_IFREG _S_IFREG
198 #define S_IREAD _S_IREAD
201 #define S_IWRITE _S_IWRITE
204 #define S_IEXEC _S_IEXEC
210 /* There are no group protection bits like these in Windows.
211 * The values are used by umask() to remove permissions so
212 * mapping to user permission bits will break file accesses.
213 * Map group permissions to harmless zero instead.
228 #if defined(_MSC_VER)
229 #define S_ISDIR(m) (((m) & _S_IFDIR) == _S_IFDIR)
232 #define SIGHUP 1 /* hangup */
233 #define SIGKILL 9 /* kill (cannot be caught or ignored) */
234 #define SIGBUS 10 /* bus error */
235 #define SIGPIPE 13 /* write on a pipe with no one to read it */
236 #define SIGCHLD 20 /* to parent on child stop or exit */
237 #define SIGUSR1 30 /* user defined signal 1 */
238 #define SIGUSR2 31 /* user defined signal 2 */
241 typedef unsigned char boolean
;
242 typedef unsigned char u_char
;
243 typedef unsigned int u_int
;
246 #if defined(_MSC_VER)
252 char *pw_name
; /* user name */
253 char *pw_passwd
; /* user password */
254 uid_t pw_uid
; /* user id */
255 gid_t pw_gid
; /* group id */
256 char *pw_gecos
; /* real name */
257 char *pw_dir
; /* home directory */
258 char *pw_shell
; /* shell program */
262 char *gr_name
; /* group name */
263 char *gr_passwd
; /* group password */
264 gid_t gr_gid
; /* group id */
265 char **gr_mem
; /* group members */
268 #if !HAVE_GETTIMEOFDAY
270 int tz_minuteswest
; /* minutes west of Greenwich */
271 int tz_dsttime
; /* type of dst correction */
275 #define CHANGE_FD_SETSIZE 1
276 #if CHANGE_FD_SETSIZE && SQUID_MAXFD > DEFAULT_FD_SETSIZE
277 #define FD_SETSIZE SQUID_MAXFD
283 #include <winsock2.h>
290 #include <ws2tcpip.h>
293 #if (EAI_NODATA == EAI_NONAME)
295 #define EAI_NODATA WSANO_DATA
298 #if defined(_MSC_VER)
299 /* Hack to suppress compiler warnings on FD_SET() & FD_CLR() */
300 #pragma warning (push)
301 #pragma warning (disable:4142)
304 /* prevent inclusion of wingdi.h */
308 #if defined(_MSC_VER)
309 #pragma warning (pop)
314 typedef char * caddr_t
;
316 #ifndef _PATH_DEVNULL
317 #define _PATH_DEVNULL "NUL"
326 #define EISCONN WSAEISCONN
329 #define EINPROGRESS WSAEINPROGRESS
332 #define EWOULDBLOCK WSAEWOULDBLOCK
335 #define EALREADY WSAEALREADY
338 #define ETIMEDOUT WSAETIMEDOUT
341 #define ECONNREFUSED WSAECONNREFUSED
344 #define ECONNRESET WSAECONNRESET
347 #define ENOTCONN WSAENOTCONN
350 #define ERESTART WSATRY_AGAIN
353 #define EAFNOSUPPORT WSAEAFNOSUPPORT
356 #define ENETUNREACH WSAENETUNREACH
359 #define ENOTSUP WSAEOPNOTSUPP
363 #define h_errno errno /* we'll set it ourselves */
366 #define FD_CLR(fd, set) do { \
368 SOCKET __sock = _get_osfhandle(fd); \
369 for (__i = 0; __i < ((fd_set FAR *)(set))->fd_count ; __i++) { \
370 if (((fd_set FAR *)(set))->fd_array[__i] == __sock) { \
371 while (__i < ((fd_set FAR *)(set))->fd_count-1) { \
372 ((fd_set FAR *)(set))->fd_array[__i] = \
373 ((fd_set FAR *)(set))->fd_array[__i+1]; \
376 ((fd_set FAR *)(set))->fd_count--; \
383 #define FD_SET(fd, set) do { \
385 SOCKET __sock = _get_osfhandle(fd); \
386 for (__i = 0; __i < ((fd_set FAR *)(set))->fd_count; __i++) { \
387 if (((fd_set FAR *)(set))->fd_array[__i] == (__sock)) { \
391 if (__i == ((fd_set FAR *)(set))->fd_count) { \
392 if (((fd_set FAR *)(set))->fd_count < FD_SETSIZE) { \
393 ((fd_set FAR *)(set))->fd_array[__i] = (__sock); \
394 ((fd_set FAR *)(set))->fd_count++; \
400 #define FD_ISSET(fd, set) Win32__WSAFDIsSet(fd, (fd_set FAR *)(set))
402 /* internal to Microsoft CRTLIB */
404 long osfhnd
; /* underlying OS file HANDLE */
405 char osfile
; /* attributes of file (e.g., open in text mode?) */
406 char pipech
; /* one char buffer for handles opened on pipes */
409 CRITICAL_SECTION lock
;
413 #define IOINFO_ARRAY_ELTS (1 << IOINFO_L2E)
414 #define _pioinfo(i) ( __pioinfo[(i) >> IOINFO_L2E] + ((i) & (IOINFO_ARRAY_ELTS - 1)) )
415 #define _osfile(i) ( _pioinfo(i)->osfile )
416 #define _osfhnd(i) ( _pioinfo(i)->osfhnd )
418 #define FOPEN 0x01 /* file handle open */
421 #if defined(_MSC_VER)
422 SQUIDCEXTERN _CRTIMP ioinfo
* __pioinfo
[];
423 SQUIDCEXTERN
int __cdecl
_free_osfhnd(int);
427 __MINGW_IMPORT ioinfo
* __pioinfo
[];
428 SQUIDCEXTERN
int _free_osfhnd(int);
431 SQUIDCEXTERN THREADLOCAL
int ws32_result
;
433 #if defined(__cplusplus)
438 char l_so_type
[sizeof(int)];
439 int l_so_type_siz
= sizeof(l_so_type
);
440 SOCKET sock
= _get_osfhandle(fd
);
442 if (::getsockopt(sock
, SOL_SOCKET
, SO_TYPE
, l_so_type
, &l_so_type_siz
) == 0) {
444 if (closesocket(sock
) == SOCKET_ERROR
) {
445 errno
= WSAGetLastError();
455 #if defined(_MSC_VER) /* Microsoft C Compiler ONLY */
458 #define _S_IREAD 0x0100
462 #define _S_IWRITE 0x0080
466 open(const char *filename
, int oflag
, int pmode
= 0)
468 return _open(filename
, oflag
, pmode
& (_S_IREAD
| _S_IWRITE
));
473 read(int fd
, void * buf
, size_t siz
)
475 char l_so_type
[sizeof(int)];
476 int l_so_type_siz
= sizeof(l_so_type
);
477 SOCKET sock
= _get_osfhandle(fd
);
479 if (::getsockopt(sock
, SOL_SOCKET
, SO_TYPE
, l_so_type
, &l_so_type_siz
) == 0)
480 return ::recv(sock
, (char FAR
*) buf
, (int)siz
, 0);
482 return _read(fd
, buf
, (unsigned int)siz
);
486 write(int fd
, const void * buf
, size_t siz
)
488 char l_so_type
[sizeof(int)];
489 int l_so_type_siz
= sizeof(l_so_type
);
490 SOCKET sock
= _get_osfhandle(fd
);
492 if (::getsockopt(sock
, SOL_SOCKET
, SO_TYPE
, l_so_type
, &l_so_type_siz
) == 0)
493 return ::send(sock
, (char FAR
*) buf
, siz
, 0);
495 return _write(fd
, buf
, siz
);
499 index(const char *s
, int c
)
501 return (char *)strchr(s
,c
);
504 // stdlib <functional> definitions are required before std API redefinitions.
505 #include <functional>
507 /** \cond AUTODOCS-IGNORE */
513 * Each of these functions is defined in the Squid namespace so as not to
514 * clash with the winsock.h and winsock2.h definitions.
515 * It is then paired with a #define to cause these wrappers to be used by
516 * the main code instead of those system definitions.
518 * We do this wrapper in order to:
519 * - cast the parameter types in only one place, and
520 * - record errors in POSIX errno variable, and
521 * - map the FD value used by Squid to the socket handes used by Windows.
525 accept(int s
, struct sockaddr
* a
, socklen_t
* l
)
528 if ((result
= ::accept(_get_osfhandle(s
), a
, l
)) == INVALID_SOCKET
) {
529 if (WSAEMFILE
== (errno
= WSAGetLastError()))
533 return _open_osfhandle(result
, 0);
535 #define accept(s,a,l) Squid::accept(s,a,reinterpret_cast<socklen_t*>(l))
538 bind(int s
, const struct sockaddr
* n
, socklen_t l
)
540 if (::bind(_get_osfhandle(s
),n
,l
) == SOCKET_ERROR
) {
541 errno
= WSAGetLastError();
546 #define bind(s,n,l) Squid::bind(s,n,l)
549 connect(int s
, const struct sockaddr
* n
, socklen_t l
)
551 if (::connect(_get_osfhandle(s
),n
,l
) == SOCKET_ERROR
) {
552 if (WSAEMFILE
== (errno
= WSAGetLastError()))
558 #define connect(s,n,l) Squid::connect(s,n,l)
560 inline struct hostent
*
561 gethostbyname(const char *n
) {
562 HOSTENT FAR
* result
;
563 if ((result
= ::gethostbyname(n
)) == NULL
)
564 errno
= WSAGetLastError();
567 #define gethostbyname(n) Squid::gethostbyname(n)
570 getservbyname(const char * n
, const char * p
)
572 SERVENT FAR
* result
;
573 if ((result
= ::getservbyname(n
, p
)) == NULL
)
574 errno
= WSAGetLastError();
577 #define getservbyname(n,p) Squid::getservbyname(n,p)
580 gethostbyaddr(const void * a
, size_t l
, int t
)
582 HOSTENT FAR
* result
;
583 if ((result
= ::gethostbyaddr((const char*)a
, l
, t
)) == NULL
)
584 errno
= WSAGetLastError();
587 #define gethostbyaddr(a,l,t) Squid::gethostbyaddr(a,l,t)
590 getsockname(int s
, struct sockaddr
* n
, socklen_t
* l
)
593 if (::getsockname(_get_osfhandle(s
), n
, &i
) == SOCKET_ERROR
) {
594 errno
= WSAGetLastError();
599 #define getsockname(s,a,l) Squid::getsockname(s,a,reinterpret_cast<socklen_t*>(l))
602 gethostname(char * n
, size_t l
)
604 if ((::gethostname(n
, l
)) == SOCKET_ERROR
) {
605 errno
= WSAGetLastError();
610 #define gethostname(n,l) Squid::gethostname(n,l)
613 getsockopt(int s
, int l
, int o
, void * v
, socklen_t
* n
)
616 if ((::getsockopt(_get_osfhandle(s
), l
, o
,(char *) v
, n
)) == SOCKET_ERROR
) {
617 errno
= WSAGetLastError();
622 #define getsockopt(s,l,o,v,n) Squid::getsockopt(s,l,o,v,n)
624 /* Simple ioctl() emulation */
626 ioctl(int s
, int c
, void * a
)
628 if ((::ioctlsocket(_get_osfhandle(s
), c
, (u_long FAR
*)a
)) == SOCKET_ERROR
) {
629 errno
= WSAGetLastError();
634 #define ioctl(s,c,a) Squid::ioctl(s,c,a)
637 ioctlsocket(int s
, long c
, u_long FAR
* a
)
639 if ((::ioctlsocket(_get_osfhandle(s
), c
, a
)) == SOCKET_ERROR
) {
640 errno
= WSAGetLastError();
645 #define ioctlsocket(s,c,a) Squid::ioctlsocket(s,c,a)
650 if (::listen(_get_osfhandle(s
), b
) == SOCKET_ERROR
) {
651 if (WSAEMFILE
== (errno
= WSAGetLastError()))
657 #define listen(s,b) Squid::listen(s,b)
660 recv(int s
, void * b
, size_t l
, int f
)
663 if ((result
= ::recv(_get_osfhandle(s
), (char *)b
, l
, f
)) == SOCKET_ERROR
) {
664 errno
= WSAGetLastError();
669 #define recv(s,b,l,f) Squid::recv(s,b,l,f)
672 recvfrom(int s
, void * b
, size_t l
, int f
, struct sockaddr
* fr
, socklen_t
* fl
)
676 if ((result
= ::recvfrom(_get_osfhandle(s
), (char *)b
, l
, f
, fr
, &ifl
)) == SOCKET_ERROR
) {
677 errno
= WSAGetLastError();
682 #define recvfrom(s,b,l,f,r,n) Squid::recvfrom(s,b,l,f,r,reinterpret_cast<socklen_t*>(n))
685 select(int n
, fd_set
* r
, fd_set
* w
, fd_set
* e
, struct timeval
* t
)
688 if ((result
= ::select(n
,r
,w
,e
,t
)) == SOCKET_ERROR
) {
689 errno
= WSAGetLastError();
694 #define select(n,r,w,e,t) Squid::select(n,r,w,e,t)
697 send(int s
, const char * b
, size_t l
, int f
)
700 if ((result
= ::send(_get_osfhandle(s
), b
, l
, f
)) == SOCKET_ERROR
) {
701 errno
= WSAGetLastError();
706 #define send(s,b,l,f) Squid::send(s,reinterpret_cast<const char*>(b),l,f)
709 sendto(int s
, const void * b
, size_t l
, int f
, const struct sockaddr
* t
, socklen_t tl
)
712 if ((result
= ::sendto(_get_osfhandle(s
), (char *)b
, l
, f
, t
, tl
)) == SOCKET_ERROR
) {
713 errno
= WSAGetLastError();
718 #define sendto(a,b,l,f,t,n) Squid::sendto(a,b,l,f,t,n)
721 setsockopt(SOCKET s
, int l
, int o
, const void * v
, socklen_t n
)
725 socket
= ((s
== INVALID_SOCKET
) ? s
: (SOCKET
)_get_osfhandle((int)s
));
727 if (::setsockopt(socket
, l
, o
, (const char *)v
, n
) == SOCKET_ERROR
) {
728 errno
= WSAGetLastError();
733 #define setsockopt(s,l,o,v,n) Squid::setsockopt(s,l,o,v,n)
736 shutdown(int s
, int h
)
738 if (::shutdown(_get_osfhandle(s
),h
) == SOCKET_ERROR
) {
739 errno
= WSAGetLastError();
744 #define shutdown(s,h) Squid::shutdown(s,h)
747 socket(int f
, int t
, int p
)
750 if ((result
= ::socket(f
, t
, p
)) == INVALID_SOCKET
) {
751 if (WSAEMFILE
== (errno
= WSAGetLastError()))
755 return _open_osfhandle(result
, 0);
757 #define socket(f,t,p) Squid::socket(f,t,p)
762 return _pipe(pipefd
,4096,_O_BINARY
);
764 #define pipe(a) Squid::pipe(a)
767 WSAAsyncSelect(int s
, HWND h
, unsigned int w
, long e
)
769 if (::WSAAsyncSelect(_get_osfhandle(s
), h
, w
, e
) == SOCKET_ERROR
) {
770 errno
= WSAGetLastError();
775 #define WSAAsyncSelect(s,h,w,e) Squid::WSAAsyncSelect(s,h,w,e)
777 #undef WSADuplicateSocket
779 WSADuplicateSocket(int s
, DWORD n
, LPWSAPROTOCOL_INFO l
)
782 if (::WSADuplicateSocketW(_get_osfhandle(s
), n
, l
) == SOCKET_ERROR
) {
784 if (::WSADuplicateSocketA(_get_osfhandle(s
), n
, l
) == SOCKET_ERROR
) {
786 errno
= WSAGetLastError();
791 #define WSADuplicateSocket(s,n,l) Squid::WSADuplicateSocket(s,n,l)
795 WSASocket(int a
, int t
, int p
, LPWSAPROTOCOL_INFO i
, GROUP g
, DWORD f
)
799 if ((result
= ::WSASocketW(a
, t
, p
, i
, g
, f
)) == INVALID_SOCKET
) {
801 if ((result
= ::WSASocketA(a
, t
, p
, i
, g
, f
)) == INVALID_SOCKET
) {
803 if (WSAEMFILE
== (errno
= WSAGetLastError()))
807 return _open_osfhandle(result
, 0);
809 #define WSASocket(a,t,p,i,g,f) Squid::WSASocket(a,t,p,i,g,f)
811 } /* namespace Squid */
813 #else /* #ifdef __cplusplus */
814 #define connect(s,n,l) \
815 (SOCKET_ERROR == connect(_get_osfhandle(s),n,l) ? \
816 (WSAEMFILE == (errno = WSAGetLastError()) ? errno = EMFILE : -1, -1) : 0)
817 #define gethostbyname(n) \
818 (NULL == ((HOSTENT FAR*)(ws32_result = (int)gethostbyname(n))) ? \
819 (errno = WSAGetLastError()), (HOSTENT FAR*)NULL : (HOSTENT FAR*)ws32_result)
820 #define gethostname(n,l) \
821 (SOCKET_ERROR == gethostname(n,l) ? \
822 (errno = WSAGetLastError()), -1 : 0)
823 #define recv(s,b,l,f) \
824 (SOCKET_ERROR == (ws32_result = recv(_get_osfhandle(s),b,l,f)) ? \
825 (errno = WSAGetLastError()), -1 : ws32_result)
826 #define sendto(s,b,l,f,t,tl) \
827 (SOCKET_ERROR == (ws32_result = sendto(_get_osfhandle(s),b,l,f,t,tl)) ? \
828 (errno = WSAGetLastError()), -1 : ws32_result)
829 #define select(n,r,w,e,t) \
830 (SOCKET_ERROR == (ws32_result = select(n,r,w,e,t)) ? \
831 (errno = WSAGetLastError()), -1 : ws32_result)
832 #define socket(f,t,p) \
833 (INVALID_SOCKET == ((SOCKET)(ws32_result = (int)socket(f,t,p))) ? \
834 ((WSAEMFILE == (errno = WSAGetLastError()) ? errno = EMFILE : -1), -1) : \
835 (SOCKET)_open_osfhandle(ws32_result,0))
836 #define write _write /* Needed in util.c */
837 #define open _open /* Needed in win32lib.c */
838 #endif /* #ifdef __cplusplus */
840 /* provide missing definitions from resoruce.h */
841 /* NP: sys/resource.h and sys/time.h are apparently order-dependant. */
843 #include <sys/time.h>
845 #if HAVE_SYS_RESOURCE_H
846 #include <sys/resource.h>
848 #define RUSAGE_SELF 0 /* calling process */
849 #define RUSAGE_CHILDREN -1 /* terminated child processes */
852 struct timeval ru_utime
; /* user time used */
853 struct timeval ru_stime
; /* system time used */
854 long ru_maxrss
; /* integral max resident set size */
855 long ru_ixrss
; /* integral shared text memory size */
856 long ru_idrss
; /* integral unshared data size */
857 long ru_isrss
; /* integral unshared stack size */
858 long ru_minflt
; /* page reclaims */
859 long ru_majflt
; /* page faults */
860 long ru_nswap
; /* swaps */
861 long ru_inblock
; /* block input operations */
862 long ru_oublock
; /* block output operations */
863 long ru_msgsnd
; /* messages sent */
864 long ru_msgrcv
; /* messages received */
865 long ru_nsignals
; /* signals received */
866 long ru_nvcsw
; /* voluntary context switches */
867 long ru_nivcsw
; /* involuntary context switches */
869 #endif /* HAVE_SYS_RESOURCE_H */
873 SQUIDCEXTERN
int chroot(const char *dirname
);
874 SQUIDCEXTERN
int kill(pid_t
, int);
875 SQUIDCEXTERN
struct passwd
* getpwnam(char *unused
);
876 SQUIDCEXTERN
struct group
* getgrnam(char *unused
);
919 /* for some reason autoconf misdetects getpagesize.. */
920 #if HAVE_GETPAGESIZE && _SQUID_MINGW_
921 #undef HAVE_GETPAGESIZE
924 #if !HAVE_GETPAGESIZE
925 /* And now we define a compatibility layer */
926 size_t getpagesize();
927 #define HAVE_GETPAGESIZE 2
930 SQUIDCEXTERN
void WIN32_ExceptionHandlerInit(void);
931 SQUIDCEXTERN
int Win32__WSAFDIsSet(int fd
, fd_set
* set
);
932 SQUIDCEXTERN DWORD
WIN32_IpAddrChangeMonitorInit();
934 /* gcc doesn't recognize the Windows native 64 bit formatting tags causing
935 * the compile fail, so we must disable the check on native Windows.
938 #define PRINTF_FORMAT_ARG1
939 #define PRINTF_FORMAT_ARG2
940 #define PRINTF_FORMAT_ARG3
943 /* XXX: the logic around this is a bit warped:
944 * we #define ACL unconditionally at the top of this file,
945 * then #undef ACL unconditionally hafway down,
946 * then here re-define ACL to the same value as at the top,
947 * then include windows.h and #undef ACL again.
950 #define ACL WindowsACL
951 #define _MSWIN_ACL_WAS_NOT_DEFINED 1
954 #if _MSWIN_ACL_WAS_NOT_DEFINED
956 #undef _MSWIN_ACL_WAS_NOT_DEFINED
960 /* syslog compatibility layer derives from git */
966 #define LOG_WARNING 4
970 #define LOG_DAEMON (3<<3)
972 void openlog(const char *ident
, int logopt
, int facility
);
973 void syslog(int priority
, const char *fmt
, ...);
977 /* MinGW missing bits from sys/wait.h */
978 /* A status looks like:
979 * <2 bytes info> <2 bytes code>
981 * <code> == 0, child has exited, info is the exit value
982 * <code> == 1..7e, child has exited, info is the signal number.
983 * <code> == 7f, child has stopped, info was the signal number.
984 * <code> == 80, there was a core dump.
986 #define WIFEXITED(w) (((w) & 0xff) == 0)
987 #define WIFSIGNALED(w) (((w) & 0x7f) > 0 && (((w) & 0x7f) < 0x7f))
988 #define WIFSTOPPED(w) (((w) & 0xff) == 0x7f)
989 #define WEXITSTATUS(w) (((w) >> 8) & 0xff)
990 #define WTERMSIG(w) ((w) & 0x7f)
991 #define WSTOPSIG WEXITSTATUS
995 void WIN32_maperror(unsigned long WIN32_oserrno
);
997 #endif /* _SQUID_WINDOWS_ */
998 #endif /* SQUID_OS_MSWINDOWS_H */