]> git.ipfire.org Git - thirdparty/squid.git/blame - src/win32.cc
SourceFormat Enforcement
[thirdparty/squid.git] / src / win32.cc
CommitLineData
3b1797bd 1/*
4ac4a490 2 * Copyright (C) 1996-2017 The Squid Software Foundation and contributors
3b1797bd 3 *
bbc27441
AJ
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.
3b1797bd 7 */
8
bbc27441
AJ
9/* Inspired by previous work by Romeo Anghelache & Eric Stern. */
10
582c2af2 11#include "squid.h"
3b1797bd 12
7aa9bb3e 13#if _SQUID_WINDOWS_
16f2e361
AJ
14
15#include "fde.h"
16#include "win32.h"
17
18#include <csignal>
485a0d3f 19#if HAVE_WIN32_PSAPI
20#include <psapi.h>
21#endif
16f2e361 22#if HAVE_MSWSOCK_H
11871e3c 23#include <mswsock.h>
24#endif
06648839 25
1bc874d7 26SQUIDCEXTERN LPCRITICAL_SECTION dbg_mutex;
06648839 27void WIN32_ExceptionHandlerCleanup(void);
28static LPTOP_LEVEL_EXCEPTION_FILTER Win32_Old_ExceptionHandler = NULL;
62e76326 29
65d448bc
AJ
30int
31Win32__WSAFDIsSet(int fd, fd_set FAR * set)
485a0d3f 32{
33 fde *F = &fd_table[fd];
34 SOCKET s = F->win32.handle;
35
cc192b50 36 return __WSAFDIsSet(s, set);
485a0d3f 37}
38
06648839 39LONG CALLBACK WIN32_ExceptionHandler(EXCEPTION_POINTERS* ep)
40{
41 EXCEPTION_RECORD* er;
42
43 er = ep->ExceptionRecord;
44
45 switch (er->ExceptionCode) {
46
47 case EXCEPTION_ACCESS_VIOLATION:
48 raise(SIGSEGV);
49 break;
50
51 case EXCEPTION_DATATYPE_MISALIGNMENT:
52
53 case EXCEPTION_ARRAY_BOUNDS_EXCEEDED:
54
55 case EXCEPTION_IN_PAGE_ERROR:
16f2e361 56 raise(SIGBUS);
06648839 57 break;
58
59 default:
60 break;
61 }
62
63 return EXCEPTION_CONTINUE_SEARCH;
64}
65
06648839 66void WIN32_ExceptionHandlerInit()
67{
68#if !defined(_DEBUG)
69
70 if (Win32_Old_ExceptionHandler == NULL)
71 Win32_Old_ExceptionHandler = SetUnhandledExceptionFilter(WIN32_ExceptionHandler);
72
73#endif
74}
75
76void WIN32_ExceptionHandlerCleanup()
77{
78 if (Win32_Old_ExceptionHandler != NULL)
79 SetUnhandledExceptionFilter(Win32_Old_ExceptionHandler);
80}
81
5def7931 82#endif /* SQUID_WINDOWS_ */
f53969cc 83