mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-11 11:53:51 +00:00
Branches: main, 11.07 Avoid problems with the inclusion of windows.h in the runtime and a few standard library modules. By default, windows.h includes a lot of other header files, some of which conflict with other parts of the Windows API. Such a conflict occurs with G12 tcp module where the inclusion of winsock2.h conflicts with the inclusion of winsock.h by windows.h. We can avoid this by defining the macro WIN32_LEAN_AND_MEAN. It causes winsock.h and some other headers not to be included by windows.h. (Should the other headers actually be required -- the Mercury runtime and standard library do not require them -- then they will need to be included separately.) To make this (and other workarounds for silly things in windows.h) possible this change adds wrapper header for windows.h to the runtime. We now use this wrapper header throughout the rest of the system rather than including windows.h directly. runtime/mercury_windows.h: Add a wrapper around windows.h that allows us to control how windows.h is included in a consistent manner. Define WIN32_LEAN_AND_MEAN in order to avoid problems with code that uses winsock2.h. runtime/Mmakefile: Include the new header. runtime/mercury_memory.c: runtime/mercury_memory_handlers.h runtime/mercury_memory_zones.c: runtime/mercury_timing.c: library/dir.m: library/io.m: library/time.m: Include mercury_windows.h rather than directly including windows.h.
69 lines
1.9 KiB
C
69 lines
1.9 KiB
C
/*
|
|
** Copyright (C) 1998,2000 The University of Melbourne.
|
|
** This file may only be copied under the terms of the GNU Library General
|
|
** Public License - see the file COPYING.LIB in the Mercury distribution.
|
|
*/
|
|
|
|
/*
|
|
** mercury_memory_handlers.h - signal handlers for the memory zones.
|
|
**
|
|
** This defines various signal handlers for memory access violations,
|
|
** including accesses to the redzones at the end of each zone.
|
|
*/
|
|
|
|
#ifndef MERCURY_MEMORY_HANDLERS_H
|
|
#define MERCURY_MEMORY_HANDLERS_H
|
|
|
|
#include "mercury_memory_zones.h"
|
|
|
|
/*
|
|
** MR_default_handler is a function that can be passed to MR_create_zone to
|
|
** unprotect enough of the redzone to allow the access to succeed, or
|
|
** fail if there is no space left in the zone.
|
|
*/
|
|
|
|
extern MR_ZoneHandler MR_default_handler;
|
|
|
|
/*
|
|
** MR_null_handler is a function that can be passed to MR_create_zone
|
|
** which always fails.
|
|
*/
|
|
|
|
extern MR_ZoneHandler MR_null_handler;
|
|
|
|
/*
|
|
**
|
|
** setup_signals() will setup the default signal handlers.
|
|
**
|
|
*/
|
|
|
|
extern void MR_setup_signals(void);
|
|
|
|
#ifdef MR_MSVC_STRUCTURED_EXCEPTIONS
|
|
/*
|
|
** Filter a Win32 exception (to be called in the __except filter
|
|
** part).
|
|
** Possible return values are:
|
|
**
|
|
** EXCEPTION_CONTINUE_EXECUTION (-1)
|
|
** Exception is dismissed. Continue execution at the point where
|
|
** the exception occurred.
|
|
**
|
|
** EXCEPTION_CONTINUE_SEARCH (0)
|
|
** Exception is not recognized. Continue to search up the stack for
|
|
** a handler, first for containing try-except statements, then for
|
|
** handlers with the next highest precedence.
|
|
**
|
|
** EXCEPTION_EXECUTE_HANDLER (1)
|
|
** Exception is recognized. Transfer control to the exception handler
|
|
** by executing the __except compound statement, then continue
|
|
** execution at the assembly instruction that was executing
|
|
** when the exception was raised.
|
|
*/
|
|
#include "mercury_windows.h"
|
|
|
|
int MR_filter_win32_exception(LPEXCEPTION_POINTERS exception_ptrs);
|
|
#endif
|
|
|
|
#endif /* not MERCURY_MEMORY_HANDLERS_H */
|