]> sourceware.org Git - newlib-cygwin.git/blame - winsup/cygwin/debug.h
* environ.cc (environ_init): Avoid a compiler warning.
[newlib-cygwin.git] / winsup / cygwin / debug.h
CommitLineData
1fd5e000
CF
1/* debug.h
2
b6bd7037 3 Copyright 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
1fd5e000
CF
4
5This software is a copyrighted work licensed under the terms of the
6Cygwin license. Please consult the file "CYGWIN_LICENSE" for
7details. */
8
9#ifndef MALLOC_DEBUG
10#define MALLOC_CHECK do {} while (0)
11#else
8db71e01
ED
12#include <stdlib.h>
13#include "dlmalloc.h"
1fd5e000
CF
14#define MALLOC_CHECK ({\
15 debug_printf ("checking malloc pool");\
16 (void)mallinfo ();\
17})
18#endif
19
20extern "C" {
166b2571
CF
21DWORD __stdcall WFSO (HANDLE, DWORD) __attribute__ ((regparm(2)));
22DWORD __stdcall WFMO (DWORD, CONST HANDLE *, BOOL, DWORD) __attribute__ ((regparm(3)));
1fd5e000
CF
23}
24
25#define WaitForSingleObject WFSO
245e4e87 26#define WaitForMultipleObjects WFMO
1fd5e000
CF
27
28#if !defined(_DEBUG_H_)
29#define _DEBUG_H_
30
918a268c 31#define being_debugged() \
2402700d 32 (IsDebuggerPresent () /* || GetLastError () == ERROR_PROC_NOT_FOUND*/)
918a268c 33
1fd5e000 34#ifndef DEBUGGING
166b2571 35# define cygbench(s)
1fd5e000
CF
36# define ForceCloseHandle CloseHandle
37# define ForceCloseHandle1(h, n) CloseHandle (h)
38# define ForceCloseHandle2(h, n) CloseHandle (h)
39# define ProtectHandle(h) do {} while (0)
40# define ProtectHandle1(h,n) do {} while (0)
41# define ProtectHandle2(h,n) do {} while (0)
0301bfd0
CF
42# define ProtectHandleINH(h) do {} while (0)
43# define ProtectHandle1INH(h,n) do {} while (0)
44# define ProtectHandle2INH(h,n) do {} while (0)
1fd5e000 45# define debug_init() do {} while (0)
0301bfd0
CF
46# define setclexec(h, nh, b) do {} while (0)
47# define debug_fixup_after_fork_exec() do {} while (0)
1fd5e000
CF
48
49#else
50
51# ifdef NO_DEBUG_DEFINES
52# undef NO_DEBUG_DEFINES
53# else
54# define CloseHandle(h) \
55 close_handle (__PRETTY_FUNCTION__, __LINE__, (h), #h, FALSE)
56# define ForceCloseHandle(h) \
57 close_handle (__PRETTY_FUNCTION__, __LINE__, (h), #h, TRUE)
58# define ForceCloseHandle1(h,n) \
59 close_handle (__PRETTY_FUNCTION__, __LINE__, (h), #n, TRUE)
60# define ForceCloseHandle2(h,n) \
61 close_handle (__PRETTY_FUNCTION__, __LINE__, (h), n, TRUE)
1fd5e000
CF
62# endif
63
64# define ProtectHandle(h) add_handle (__PRETTY_FUNCTION__, __LINE__, (h), #h)
e62ac9e8
CF
65# define ProtectHandle1(h, n) add_handle (__PRETTY_FUNCTION__, __LINE__, (h), #n)
66# define ProtectHandle2(h, n) add_handle (__PRETTY_FUNCTION__, __LINE__, (h), n)
0301bfd0
CF
67# define ProtectHandleINH(h) add_handle (__PRETTY_FUNCTION__, __LINE__, (h), #h, 1)
68# define ProtectHandle1INH(h, n) add_handle (__PRETTY_FUNCTION__, __LINE__, (h), #n, 1)
69# define ProtectHandle2INH(h, n) add_handle (__PRETTY_FUNCTION__, __LINE__, (h), n, 1)
1fd5e000
CF
70
71void debug_init ();
0301bfd0 72void __stdcall add_handle (const char *, int, HANDLE, const char *, bool = false)
e62ac9e8
CF
73 __attribute__ ((regparm (3)));
74BOOL __stdcall close_handle (const char *, int, HANDLE, const char *, BOOL)
75 __attribute__ ((regparm (3)));
76void __stdcall cygbench (const char *s) __attribute__ ((regparm (1)));
0a047e8f 77extern "C" void console_printf (const char *fmt,...);
0301bfd0
CF
78void setclexec (HANDLE, HANDLE, bool);
79void debug_fixup_after_fork_exec ();
e62ac9e8 80extern int pinger;
1fd5e000 81
0301bfd0
CF
82struct handle_list
83 {
0301bfd0
CF
84 HANDLE h;
85 const char *name;
86 const char *func;
87 int ln;
3d0ba393 88 bool inherited;
0301bfd0
CF
89 DWORD pid;
90 struct handle_list *next;
91 };
92
1fd5e000
CF
93#endif /*DEBUGGING*/
94#endif /*_DEBUG_H_*/
This page took 0.1113 seconds and 5 git commands to generate.