OSDN Git Service

* sync.h (new_muto): Just accept an argument which denotes the name of the
[pf3gnuchains/pf3gnuchains3x.git] / winsup / cygwin / debug.h
1 /* debug.h
2
3    Copyright 1998, 1999, 2000, 2001 Red Hat, Inc.
4
5 This software is a copyrighted work licensed under the terms of the
6 Cygwin license.  Please consult the file "CYGWIN_LICENSE" for
7 details. */
8
9 #ifndef MALLOC_DEBUG
10 #define MALLOC_CHECK do {} while (0)
11 #else
12 #include <stdlib.h>
13 #include "dlmalloc.h"
14 #define MALLOC_CHECK ({\
15   debug_printf ("checking malloc pool");\
16   (void)mallinfo ();\
17 })
18 #endif
19
20 extern "C" {
21 DWORD __stdcall WFSO (HANDLE, DWORD) __attribute__ ((regparm(2)));
22 DWORD __stdcall WFMO (DWORD, CONST HANDLE *, BOOL, DWORD) __attribute__ ((regparm(3)));
23 }
24
25 #define WaitForSingleObject WFSO
26 #define WaitForMultipleObject WFMO
27
28 #if !defined(_DEBUG_H_)
29 #define _DEBUG_H_
30
31 void threadname_init ();
32 HANDLE __stdcall makethread (LPTHREAD_START_ROUTINE, LPVOID, DWORD, const char *) __attribute__ ((regparm(3)));
33 const char * __stdcall threadname (DWORD, int lockit = TRUE) __attribute__ ((regparm(2)));
34 void __stdcall regthread (const char *, DWORD) __attribute__ ((regparm(1)));
35 int __stdcall iscygthread ();
36
37 #ifndef DEBUGGING
38 # define cygbench(s)
39 # define ForceCloseHandle CloseHandle
40 # define ForceCloseHandle1(h, n) CloseHandle (h)
41 # define ForceCloseHandle2(h, n) CloseHandle (h)
42 # define ProtectHandle(h) do {} while (0)
43 # define ProtectHandle1(h,n) do {} while (0)
44 # define ProtectHandle2(h,n) do {} while (0)
45 # define debug_init() do {} while (0)
46 # define setclexec_pid(h, nh, b) do {} while (0)
47 # define debug_fixup_after_fork() do {} while (0)
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)
62 # endif
63
64 # define ProtectHandle(h) add_handle (__PRETTY_FUNCTION__, __LINE__, (h), #h)
65 # define ProtectHandle1(h, n) add_handle (__PRETTY_FUNCTION__, __LINE__, (h), #n)
66 # define ProtectHandle2(h, n) add_handle (__PRETTY_FUNCTION__, __LINE__, (h), n)
67
68 void debug_init ();
69 void __stdcall add_handle (const char *, int, HANDLE, const char *)
70   __attribute__ ((regparm (3)));
71 BOOL __stdcall close_handle (const char *, int, HANDLE, const char *, BOOL)
72   __attribute__ ((regparm (3)));
73 void __stdcall cygbench (const char *s) __attribute__ ((regparm (1)));
74 extern "C" void console_printf (const char *fmt,...);
75 void setclexec_pid (HANDLE, HANDLE, bool);
76 void debug_fixup_after_fork ();
77 extern int pinger;
78
79 #endif /*DEBUGGING*/
80 #endif /*_DEBUG_H_*/