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_ */
37 #endif /* HAVE_FCNTL_H */
40 #endif /* HAVE_FCNTL_H */
43 #endif /* HAVE_SYS_STAT_H */
45 #define ACL WindowsACL
46 #if defined(_MSC_VER) /* Microsoft C Compiler ONLY */
48 #define _CRT_SECURE_NO_DEPRECATE
49 #pragma warning( disable : 4290 )
50 #pragma warning( disable : 4996 )
54 /* Some MinGW version defines min() and max() as macros
55 causing the fail of the build process. The following
56 #define will disable that definition
58 #if defined(__GNUC__) && !NOMINMAX
62 /// some builds of MinGW do not define IPV6_V6ONLY socket option
63 #if !defined(IPV6_V6ONLY)
64 #define IPV6_V6ONLY 27
67 #if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64
68 # define __USE_FILE_OFFSET64 1
71 #if defined(_MSC_VER) /* Microsoft C Compiler ONLY */
73 #if defined(__USE_FILE_OFFSET64)
74 typedef uint64_t ino_t
;
76 typedef unsigned long ino_t
;
79 #define INT64_MAX _I64_MAX
80 #define INT64_MIN _I64_MIN
82 #include "default_config_file.h"
83 /* Some tricks for MS Compilers */
85 #define THREADLOCAL __declspec(thread)
87 #elif defined(__GNUC__) /* gcc environment */
89 #define THREADLOCAL __attribute__((section(".tls")))
93 /* ONLY Microsoft C Compiler needs these: */
95 #define alloca _alloca
96 #define fileno _fileno
97 #define fstat _fstati64
98 #define lseek _lseeki64
99 #define memccpy _memccpy
100 #define mkdir(p,F) _mkdir((p))
101 #define mktemp _mktemp
102 #define snprintf _snprintf
103 #define stat _stati64
104 #define strcasecmp _stricmp
105 #define strlwr _strlwr
106 #define strncasecmp _strnicmp
107 #define tempnam _tempnam
108 #define vsnprintf _vsnprintf
111 /* CygWin and MinGW compilers need these. Microsoft C Compiler does not. */
112 #if _SQUID_MINGW_ || _SQUID_CYGWIN_
113 #define mkdir(p,F) mkdir((p))
116 /* Microsoft C Compiler and CygWin need these. MinGW does not */
117 #if defined(_MSC_VER) || _SQUID_CYGWIN_
118 SQUIDCEXTERN
int WIN32_ftruncate(int fd
, off_t size
);
119 #define ftruncate WIN32_ftruncate
120 SQUIDCEXTERN
int WIN32_truncate(const char *pathname
, off_t length
);
121 #define truncate WIN32_truncate
124 /* All three compiler systems need these: */
128 #define fdopen _fdopen
129 #define getcwd _getcwd
130 #define getpid _getpid
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 #if defined(_MSC_VER)
211 #define S_ISDIR(m) (((m) & _S_IFDIR) == _S_IFDIR)
214 #define SIGHUP 1 /* hangup */
215 #define SIGKILL 9 /* kill (cannot be caught or ignored) */
216 #define SIGBUS 10 /* bus error */
217 #define SIGPIPE 13 /* write on a pipe with no one to read it */
218 #define SIGCHLD 20 /* to parent on child stop or exit */
219 #define SIGUSR1 30 /* user defined signal 1 */
220 #define SIGUSR2 31 /* user defined signal 2 */
223 typedef unsigned char boolean
;
224 typedef unsigned char u_char
;
225 typedef unsigned int u_int
;
228 #if defined(_MSC_VER)
234 char *pw_name
; /* user name */
235 char *pw_passwd
; /* user password */
236 uid_t pw_uid
; /* user id */
237 gid_t pw_gid
; /* group id */
238 char *pw_gecos
; /* real name */
239 char *pw_dir
; /* home directory */
240 char *pw_shell
; /* shell program */
244 char *gr_name
; /* group name */
245 char *gr_passwd
; /* group password */
246 gid_t gr_gid
; /* group id */
247 char **gr_mem
; /* group members */
252 long f_type
; /* type of filesystem (see below) */
253 long f_bsize
; /* optimal transfer block size */
254 long f_blocks
; /* total data blocks in file system */
255 long f_bfree
; /* free blocks in fs */
256 long f_bavail
; /* free blocks avail to non-superuser */
257 long f_files
; /* total file nodes in file system */
258 long f_ffree
; /* free file nodes in fs */
259 long f_fsid
; /* file system id */
260 long f_namelen
; /* maximum length of filenames */
261 long f_spare
[6]; /* spare for later */
265 #if !HAVE_GETTIMEOFDAY
267 int tz_minuteswest
; /* minutes west of Greenwich */
268 int tz_dsttime
; /* type of dst correction */
272 #define CHANGE_FD_SETSIZE 1
273 #if CHANGE_FD_SETSIZE && SQUID_MAXFD > DEFAULT_FD_SETSIZE
274 #define FD_SETSIZE SQUID_MAXFD
280 #include <winsock2.h>
287 #include <ws2tcpip.h>
290 #if (EAI_NODATA == EAI_NONAME)
292 #define EAI_NODATA WSANO_DATA
295 #if defined(_MSC_VER)
296 /* Hack to suppress compiler warnings on FD_SET() & FD_CLR() */
297 #pragma warning (push)
298 #pragma warning (disable:4142)
301 /* prevent inclusion of wingdi.h */
305 #if defined(_MSC_VER)
306 #pragma warning (pop)
311 typedef char * caddr_t
;
313 #ifndef _PATH_DEVNULL
314 #define _PATH_DEVNULL "NUL"
323 #define EISCONN WSAEISCONN
326 #define EINPROGRESS WSAEINPROGRESS
329 #define EWOULDBLOCK WSAEWOULDBLOCK
332 #define EALREADY WSAEALREADY
335 #define ETIMEDOUT WSAETIMEDOUT
338 #define ECONNREFUSED WSAECONNREFUSED
341 #define ECONNRESET WSAECONNRESET
344 #define ENOTCONN WSAENOTCONN
347 #define ERESTART WSATRY_AGAIN
350 #define EAFNOSUPPORT WSAEAFNOSUPPORT
353 #define ENETUNREACH WSAENETUNREACH
356 #define ENOTSUP WSAEOPNOTSUPP
360 #define h_errno errno /* we'll set it ourselves */
363 #define FD_CLR(fd, set) do { \
365 SOCKET __sock = _get_osfhandle(fd); \
366 for (__i = 0; __i < ((fd_set FAR *)(set))->fd_count ; __i++) { \
367 if (((fd_set FAR *)(set))->fd_array[__i] == __sock) { \
368 while (__i < ((fd_set FAR *)(set))->fd_count-1) { \
369 ((fd_set FAR *)(set))->fd_array[__i] = \
370 ((fd_set FAR *)(set))->fd_array[__i+1]; \
373 ((fd_set FAR *)(set))->fd_count--; \
380 #define FD_SET(fd, set) do { \
382 SOCKET __sock = _get_osfhandle(fd); \
383 for (__i = 0; __i < ((fd_set FAR *)(set))->fd_count; __i++) { \
384 if (((fd_set FAR *)(set))->fd_array[__i] == (__sock)) { \
388 if (__i == ((fd_set FAR *)(set))->fd_count) { \
389 if (((fd_set FAR *)(set))->fd_count < FD_SETSIZE) { \
390 ((fd_set FAR *)(set))->fd_array[__i] = (__sock); \
391 ((fd_set FAR *)(set))->fd_count++; \
397 #define FD_ISSET(fd, set) Win32__WSAFDIsSet(fd, (fd_set FAR *)(set))
399 /* internal to Microsoft CRTLIB */
401 long osfhnd
; /* underlying OS file HANDLE */
402 char osfile
; /* attributes of file (e.g., open in text mode?) */
403 char pipech
; /* one char buffer for handles opened on pipes */
406 CRITICAL_SECTION lock
;
410 #define IOINFO_ARRAY_ELTS (1 << IOINFO_L2E)
411 #define _pioinfo(i) ( __pioinfo[(i) >> IOINFO_L2E] + ((i) & (IOINFO_ARRAY_ELTS - 1)) )
412 #define _osfile(i) ( _pioinfo(i)->osfile )
413 #define _osfhnd(i) ( _pioinfo(i)->osfhnd )
414 #define FOPEN 0x01 /* file handle open */
416 #if defined(_MSC_VER)
417 SQUIDCEXTERN _CRTIMP ioinfo
* __pioinfo
[];
418 SQUIDCEXTERN
int __cdecl
_free_osfhnd(int);
422 __MINGW_IMPORT ioinfo
* __pioinfo
[];
423 SQUIDCEXTERN
int _free_osfhnd(int);
426 SQUIDCEXTERN THREADLOCAL
int ws32_result
;
428 #if defined(__cplusplus)
433 char l_so_type
[sizeof(int)];
434 int l_so_type_siz
= sizeof(l_so_type
);
435 SOCKET sock
= _get_osfhandle(fd
);
437 if (::getsockopt(sock
, SOL_SOCKET
, SO_TYPE
, l_so_type
, &l_so_type_siz
) == 0) {
439 if (closesocket(sock
) == SOCKET_ERROR
) {
440 errno
= WSAGetLastError();
450 #if defined(_MSC_VER) /* Microsoft C Compiler ONLY */
453 #define _S_IREAD 0x0100
457 #define _S_IWRITE 0x0080
461 open(const char *filename
, int oflag
, int pmode
= 0)
463 return _open(filename
, oflag
, pmode
& (_S_IREAD
| _S_IWRITE
));
468 read(int fd
, void * buf
, size_t siz
)
470 char l_so_type
[sizeof(int)];
471 int l_so_type_siz
= sizeof(l_so_type
);
472 SOCKET sock
= _get_osfhandle(fd
);
474 if (::getsockopt(sock
, SOL_SOCKET
, SO_TYPE
, l_so_type
, &l_so_type_siz
) == 0)
475 return ::recv(sock
, (char FAR
*) buf
, (int)siz
, 0);
477 return _read(fd
, buf
, (unsigned int)siz
);
481 write(int fd
, const void * buf
, size_t siz
)
483 char l_so_type
[sizeof(int)];
484 int l_so_type_siz
= sizeof(l_so_type
);
485 SOCKET sock
= _get_osfhandle(fd
);
487 if (::getsockopt(sock
, SOL_SOCKET
, SO_TYPE
, l_so_type
, &l_so_type_siz
) == 0)
488 return ::send(sock
, (char FAR
*) buf
, siz
, 0);
490 return _write(fd
, buf
, siz
);
494 index(const char *s
, int c
)
496 return (char *)strchr(s
,c
);
499 // stdlib <functional> definitions are required before std API redefinitions.
500 #include <functional>
502 /** \cond AUTODOCS-IGNORE */
508 * Each of these functions is defined in the Squid namespace so as not to
509 * clash with the winsock.h and winsock2.h definitions.
510 * It is then paired with a #define to cause these wrappers to be used by
511 * the main code instead of those system definitions.
513 * We do this wrapper in order to:
514 * - cast the parameter types in only one place, and
515 * - record errors in POSIX errno variable, and
516 * - map the FD value used by Squid to the socket handes used by Windows.
520 accept(int s
, struct sockaddr
* a
, socklen_t
* l
)
523 if ((result
= ::accept(_get_osfhandle(s
), a
, l
)) == INVALID_SOCKET
) {
524 if (WSAEMFILE
== (errno
= WSAGetLastError()))
528 return _open_osfhandle(result
, 0);
530 #define accept(s,a,l) Squid::accept(s,a,l)
533 bind(int s
, const struct sockaddr
* n
, socklen_t l
)
535 if (::bind(_get_osfhandle(s
),n
,l
) == SOCKET_ERROR
) {
536 errno
= WSAGetLastError();
541 #define bind(s,n,l) Squid::bind(s,n,l)
544 connect(int s
, const struct sockaddr
* n
, socklen_t l
)
546 if (::connect(_get_osfhandle(s
),n
,l
) == SOCKET_ERROR
) {
547 if (WSAEMFILE
== (errno
= WSAGetLastError()))
553 #define connect(s,n,l) Squid::connect(s,n,l)
555 inline struct hostent
*
556 gethostbyname(const char *n
) {
557 HOSTENT FAR
* result
;
558 if ((result
= ::gethostbyname(n
)) == NULL
)
559 errno
= WSAGetLastError();
562 #define gethostbyname(n) Squid::gethostbyname(n)
565 getservbyname(const char * n
, const char * p
)
567 SERVENT FAR
* result
;
568 if ((result
= ::getservbyname(n
, p
)) == NULL
)
569 errno
= WSAGetLastError();
572 #define getservbyname(n,p) Squid::getservbyname(n,p)
575 gethostbyaddr(const void * a
, size_t l
, int t
)
577 HOSTENT FAR
* result
;
578 if ((result
= ::gethostbyaddr((const char*)a
, l
, t
)) == NULL
)
579 errno
= WSAGetLastError();
582 #define gethostbyaddr(a,l,t) Squid::gethostbyaddr(a,l,t)
585 getsockname(int s
, struct sockaddr
* n
, socklen_t
* l
)
588 if (::getsockname(_get_osfhandle(s
), n
, &i
) == SOCKET_ERROR
) {
589 errno
= WSAGetLastError();
594 #define getsockname(s,a,l) Squid::getsockname(s,a,l)
597 gethostname(char * n
, size_t l
)
599 if ((::gethostname(n
, l
)) == SOCKET_ERROR
) {
600 errno
= WSAGetLastError();
605 #define gethostname(n,l) Squid::gethostname(n,l)
608 getsockopt(int s
, int l
, int o
, void * v
, socklen_t
* n
)
611 if ((::getsockopt(_get_osfhandle(s
), l
, o
,(char *) v
, n
)) == SOCKET_ERROR
) {
612 errno
= WSAGetLastError();
617 #define getsockopt(s,l,o,v,n) Squid::getsockopt(s,l,o,v,n)
619 /* Simple ioctl() emulation */
621 ioctl(int s
, int c
, void * a
)
623 if ((::ioctlsocket(_get_osfhandle(s
), c
, (u_long FAR
*)a
)) == SOCKET_ERROR
) {
624 errno
= WSAGetLastError();
629 #define ioctl(s,c,a) Squid::ioctl(s,c,a)
632 ioctlsocket(int s
, long c
, u_long FAR
* a
)
634 if ((::ioctlsocket(_get_osfhandle(s
), c
, a
)) == SOCKET_ERROR
) {
635 errno
= WSAGetLastError();
640 #define ioctlsocket(s,c,a) Squid::ioctlsocket(s,c,a)
645 if (::listen(_get_osfhandle(s
), b
) == SOCKET_ERROR
) {
646 if (WSAEMFILE
== (errno
= WSAGetLastError()))
652 #define listen(s,b) Squid::listen(s,b)
655 recv(int s
, void * b
, size_t l
, int f
)
658 if ((result
= ::recv(_get_osfhandle(s
), (char *)b
, l
, f
)) == SOCKET_ERROR
) {
659 errno
= WSAGetLastError();
664 #define recv(s,b,l,f) Squid::recv(s,b,l,f)
667 recvfrom(int s
, void * b
, size_t l
, int f
, struct sockaddr
* fr
, socklen_t
* fl
)
671 if ((result
= ::recvfrom(_get_osfhandle(s
), (char *)b
, l
, f
, fr
, &ifl
)) == SOCKET_ERROR
) {
672 errno
= WSAGetLastError();
677 #define recvfrom(s,b,l,f,r,n) Squid::recvfrom(s,b,l,f,r,n)
680 select(int n
, fd_set
* r
, fd_set
* w
, fd_set
* e
, struct timeval
* t
)
683 if ((result
= ::select(n
,r
,w
,e
,t
)) == SOCKET_ERROR
) {
684 errno
= WSAGetLastError();
689 #define select(n,r,w,e,t) Squid::select(n,r,w,e,t)
692 send(int s
, const char * b
, size_t l
, int f
)
695 if ((result
= ::send(_get_osfhandle(s
), b
, l
, f
)) == SOCKET_ERROR
) {
696 errno
= WSAGetLastError();
701 #define send(s,b,l,f) Squid::send(s,b,l,f)
704 sendto(int s
, const void * b
, size_t l
, int f
, const struct sockaddr
* t
, socklen_t tl
)
707 if ((result
= ::sendto(_get_osfhandle(s
), (char *)b
, l
, f
, t
, tl
)) == SOCKET_ERROR
) {
708 errno
= WSAGetLastError();
713 #define sendto(a,b,l,f,t,n) Squid::sendto(a,b,l,f,t,n)
716 setsockopt(SOCKET s
, int l
, int o
, const void * v
, socklen_t n
)
720 socket
= ((s
== INVALID_SOCKET
) ? s
: (SOCKET
)_get_osfhandle((int)s
));
722 if (::setsockopt(socket
, l
, o
, (const char *)v
, n
) == SOCKET_ERROR
) {
723 errno
= WSAGetLastError();
728 #define setsockopt(s,l,o,v,n) Squid::setsockopt(s,l,o,v,n)
731 shutdown(int s
, int h
)
733 if (::shutdown(_get_osfhandle(s
),h
) == SOCKET_ERROR
) {
734 errno
= WSAGetLastError();
739 #define shutdown(s,h) Squid::shutdown(s,h)
742 socket(int f
, int t
, int p
)
745 if ((result
= ::socket(f
, t
, p
)) == INVALID_SOCKET
) {
746 if (WSAEMFILE
== (errno
= WSAGetLastError()))
750 return _open_osfhandle(result
, 0);
752 #define socket(f,t,p) Squid::socket(f,t,p)
757 return _pipe(pipefd
,4096,_O_BINARY
);
759 #define pipe(a) Squid::pipe(a)
762 WSAAsyncSelect(int s
, HWND h
, unsigned int w
, long e
)
764 if (::WSAAsyncSelect(_get_osfhandle(s
), h
, w
, e
) == SOCKET_ERROR
) {
765 errno
= WSAGetLastError();
770 #define WSAAsyncSelect(s,h,w,e) Squid::WSAAsyncSelect(s,h,w,e)
772 #undef WSADuplicateSocket
774 WSADuplicateSocket(int s
, DWORD n
, LPWSAPROTOCOL_INFO l
)
777 if (::WSADuplicateSocketW(_get_osfhandle(s
), n
, l
) == SOCKET_ERROR
) {
779 if (::WSADuplicateSocketA(_get_osfhandle(s
), n
, l
) == SOCKET_ERROR
) {
781 errno
= WSAGetLastError();
786 #define WSADuplicateSocket(s,n,l) Squid::WSADuplicateSocket(s,n,l)
790 WSASocket(int a
, int t
, int p
, LPWSAPROTOCOL_INFO i
, GROUP g
, DWORD f
)
794 if ((result
= ::WSASocketW(a
, t
, p
, i
, g
, f
)) == INVALID_SOCKET
) {
796 if ((result
= ::WSASocketA(a
, t
, p
, i
, g
, f
)) == INVALID_SOCKET
) {
798 if (WSAEMFILE
== (errno
= WSAGetLastError()))
802 return _open_osfhandle(result
, 0);
804 #define WSASocket(a,t,p,i,g,f) Squid::WSASocket(a,t,p,i,g,f)
806 } /* namespace Squid */
808 #else /* #ifdef __cplusplus */
809 #define connect(s,n,l) \
810 (SOCKET_ERROR == connect(_get_osfhandle(s),n,l) ? \
811 (WSAEMFILE == (errno = WSAGetLastError()) ? errno = EMFILE : -1, -1) : 0)
812 #define gethostbyname(n) \
813 (NULL == ((HOSTENT FAR*)(ws32_result = (int)gethostbyname(n))) ? \
814 (errno = WSAGetLastError()), (HOSTENT FAR*)NULL : (HOSTENT FAR*)ws32_result)
815 #define gethostname(n,l) \
816 (SOCKET_ERROR == gethostname(n,l) ? \
817 (errno = WSAGetLastError()), -1 : 0)
818 #define recv(s,b,l,f) \
819 (SOCKET_ERROR == (ws32_result = recv(_get_osfhandle(s),b,l,f)) ? \
820 (errno = WSAGetLastError()), -1 : ws32_result)
821 #define sendto(s,b,l,f,t,tl) \
822 (SOCKET_ERROR == (ws32_result = sendto(_get_osfhandle(s),b,l,f,t,tl)) ? \
823 (errno = WSAGetLastError()), -1 : ws32_result)
824 #define select(n,r,w,e,t) \
825 (SOCKET_ERROR == (ws32_result = select(n,r,w,e,t)) ? \
826 (errno = WSAGetLastError()), -1 : ws32_result)
827 #define socket(f,t,p) \
828 (INVALID_SOCKET == ((SOCKET)(ws32_result = (int)socket(f,t,p))) ? \
829 ((WSAEMFILE == (errno = WSAGetLastError()) ? errno = EMFILE : -1), -1) : \
830 (SOCKET)_open_osfhandle(ws32_result,0))
831 #define write _write /* Needed in util.c */
832 #define open _open /* Needed in win32lib.c */
833 #endif /* #ifdef __cplusplus */
835 /* provide missing definitions from resoruce.h */
836 /* NP: sys/resource.h and sys/time.h are apparently order-dependant. */
838 #include <sys/time.h>
840 #if HAVE_SYS_RESOURCE_H
841 #include <sys/resource.h>
843 #define RUSAGE_SELF 0 /* calling process */
844 #define RUSAGE_CHILDREN -1 /* terminated child processes */
847 struct timeval ru_utime
; /* user time used */
848 struct timeval ru_stime
; /* system time used */
849 long ru_maxrss
; /* integral max resident set size */
850 long ru_ixrss
; /* integral shared text memory size */
851 long ru_idrss
; /* integral unshared data size */
852 long ru_isrss
; /* integral unshared stack size */
853 long ru_minflt
; /* page reclaims */
854 long ru_majflt
; /* page faults */
855 long ru_nswap
; /* swaps */
856 long ru_inblock
; /* block input operations */
857 long ru_oublock
; /* block output operations */
858 long ru_msgsnd
; /* messages sent */
859 long ru_msgrcv
; /* messages received */
860 long ru_nsignals
; /* signals received */
861 long ru_nvcsw
; /* voluntary context switches */
862 long ru_nivcsw
; /* involuntary context switches */
864 #endif /* HAVE_SYS_RESOURCE_H */
868 SQUIDCEXTERN
int chroot(const char *dirname
);
869 SQUIDCEXTERN
int kill(pid_t
, int);
871 SQUIDCEXTERN
int statfs(const char *, struct statfs
*);
873 SQUIDCEXTERN
struct passwd
* getpwnam(char *unused
);
874 SQUIDCEXTERN
struct group
* getgrnam(char *unused
);
917 /* for some reason autoconf misdetects getpagesize.. */
918 #if HAVE_GETPAGESIZE && _SQUID_MINGW_
919 #undef HAVE_GETPAGESIZE
922 #if !HAVE_GETPAGESIZE
923 /* And now we define a compatibility layer */
924 size_t getpagesize();
925 #define HAVE_GETPAGESIZE 2
928 SQUIDCEXTERN
void WIN32_ExceptionHandlerInit(void);
929 SQUIDCEXTERN
int Win32__WSAFDIsSet(int fd
, fd_set
* set
);
930 SQUIDCEXTERN DWORD
WIN32_IpAddrChangeMonitorInit();
932 /* gcc doesn't recognize the Windows native 64 bit formatting tags causing
933 * the compile fail, so we must disable the check on native Windows.
936 #define PRINTF_FORMAT_ARG1
937 #define PRINTF_FORMAT_ARG2
938 #define PRINTF_FORMAT_ARG3
941 /* XXX: the logic around this is a bit warped:
942 * we #define ACL unconditionally at the top of this file,
943 * then #undef ACL unconditionally hafway down,
944 * then here re-define ACL to the same value as at the top,
945 * then include windows.h and #undef ACL again.
948 #define ACL WindowsACL
949 #define _MSWIN_ACL_WAS_NOT_DEFINED 1
952 #if _MSWIN_ACL_WAS_NOT_DEFINED
954 #undef _MSWIN_ACL_WAS_NOT_DEFINED
958 /* syslog compatibility layer derives from git */
964 #define LOG_WARNING 4
968 #define LOG_DAEMON (3<<3)
970 void openlog(const char *ident
, int logopt
, int facility
);
971 void syslog(int priority
, const char *fmt
, ...);
975 /* MinGW missing bits from sys/wait.h */
976 /* A status looks like:
977 * <2 bytes info> <2 bytes code>
979 * <code> == 0, child has exited, info is the exit value
980 * <code> == 1..7e, child has exited, info is the signal number.
981 * <code> == 7f, child has stopped, info was the signal number.
982 * <code> == 80, there was a core dump.
984 #define WIFEXITED(w) (((w) & 0xff) == 0)
985 #define WIFSIGNALED(w) (((w) & 0x7f) > 0 && (((w) & 0x7f) < 0x7f))
986 #define WIFSTOPPED(w) (((w) & 0xff) == 0x7f)
987 #define WEXITSTATUS(w) (((w) >> 8) & 0xff)
988 #define WTERMSIG(w) ((w) & 0x7f)
989 #define WSTOPSIG WEXITSTATUS
993 void WIN32_maperror(unsigned long WIN32_oserrno
);
995 #endif /* _SQUID_WINDOWS_ */
996 #endif /* SQUID_OS_MSWINDOWS_H */