-
-
Notifications
You must be signed in to change notification settings - Fork 45
/
error.h
195 lines (171 loc) · 4.52 KB
/
error.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
/*
* Defines for the error and message code.
*
* Copyright 2020 by Gray Watson
*
* This file is part of the dmalloc package.
*
* Permission to use, copy, modify, and distribute this software for
* any purpose and without fee is hereby granted, provided that the
* above copyright notice and this permission notice appear in all
* copies, and that the name of Gray Watson not be used in advertising
* or publicity pertaining to distribution of the document or software
* without specific, written prior permission.
*
* Gray Watson makes no representations about the suitability of the
* software described herein for any purpose. It is provided "as is"
* without express or implied warranty.
*
* The author may be contacted via https://dmalloc.com/
*/
#ifndef __ERROR_H__
#define __ERROR_H__
#include <stdarg.h> /* for ... */
#include "conf.h" /* up here for _INCLUDE */
/* for time type -- see settings.h */
#if STORE_TIME
#ifdef TIME_INCLUDE
#include TIME_INCLUDE
#endif
#endif
/* for timeval type -- see settings.h */
#if STORE_TIMEVAL
#ifdef TIMEVAL_INCLUDE
#include TIMEVAL_INCLUDE
#endif
#endif
/*<<<<<<<<<< The below prototypes are auto-generated by fillproto */
/* address to look for. when discovered call dmalloc_error() */
extern
DMALLOC_PNT _dmalloc_address;
/* when to stop at an address */
extern
unsigned long _dmalloc_address_seen_n;
/* global debug flags that are set my DMALLOC_DEBUG environ variable */
extern
unsigned int _dmalloc_flags;
/* global iteration counter for activities */
extern
unsigned long _dmalloc_iter_c;
/* how often to check the heap */
extern
unsigned long _dmalloc_check_interval;
#if LOG_PNT_TIMEVAL
/* overhead information storing when the library started up for elapsed time */
extern
TIMEVAL_TYPE _dmalloc_start;
#endif /* if LOG_PNT_TIMEVAL */
#if LOG_PNT_TIMEVAL == 0
#if HAVE_TIME
/* NOTE: we do the ifdef this way for fillproto */
extern
TIME_TYPE _dmalloc_start;
#endif /* if HAVE_TIME */
#endif /* if LOG_PNT_TIMEVAL == 0 */
/* when we are going to startup our locking subsystem */
extern
int _dmalloc_lock_on;
/* global flag which indicates when we are aborting */
extern
int _dmalloc_aborting_b;
/*
* void _dmalloc_open_log
*
* Open up our log file and write some version of settings information.
*/
extern
void _dmalloc_open_log(void);
/*
* void _dmalloc_reopen_log
*
* Re-open our log file which basically calls close() on the
* logfile-fd. If we change the name of the log-file then we will
* re-open the file.
*/
extern
void _dmalloc_reopen_log(void);
#if LOG_PNT_TIMEVAL
/*
* char *_dmalloc_ptimeval
*
* Print the time into local buffer.
*
* Returns a pointer to the buf argument.
*
* ARGUMENTS:
*
* timeval_p -> Pointer to a time value.
*
* buf -> Internal buffer into which we are writing the time.
*
* buf_size -> Size of the buffer.
*
* elapsed_b -> Set to 1 to dump the elapsed instead of global time.
*/
extern
char *_dmalloc_ptimeval(const TIMEVAL_TYPE *timeval_p, char *buf,
const int buf_size, const int elapsed_b);
#endif /* if LOG_PNT_TIMEVAL */
#if LOG_PNT_TIMEVAL == 0 && HAVE_TIME
/*
* char *_dmalloc_ptime
*
* Print the time into local buffer.
*
* Returns a Pointer to the buf argument.
*
* ARGUMENTS:
*
* time_p -> Pointer to a time value.
*
* buf -> Internal buffer into which we are writing the time.
*
* buf_size -> Size of the buffer.
*
* elapsed_b -> Set to 1 to dump the elapsed instead of global time.
*/
extern
char *_dmalloc_ptime(const TIME_TYPE *time_p, char *buf, const int buf_size,
const int elapsed_b);
#endif /* if LOG_PNT_TIMEVAL == 0 && HAVE_TIME */
/*
* void _dmalloc_vmessage
*
* Message writer with vprintf like arguments which adds a line to the
* dmalloc logfile.
*
* NOTE: An internal snprintf has been implemented which doesn't support all
* formats. This was done to stop dmalloc from going recursive. YMMV.
*
* ARGUMENTS:
*
* format -> Printf-style format statement.
*
* args -> Already converted pointer to a stdarg list.
*/
extern
void _dmalloc_vmessage(const char *format, va_list args);
/*
* void _dmalloc_die
*
* Kill the program because of an internal malloc error.
*
* ARGUMENTS:
*
* silent_b -> Set to 1 to not drop log entries.
*/
extern
void _dmalloc_die(const int silent_b);
/*
* void dmalloc_error
*
* Handler of error codes. The caller should have set the errno already
*
* ARGUMENTS:
*
* func -> Function name for the logs.
*/
extern
void dmalloc_error(const char *func);
/*<<<<<<<<<< This is end of the auto-generated output from fillproto. */
#endif /* ! __ERROR_H__ */