1 /***************************************************************************
3 TextEditor.mcc - Textediting MUI Custom Class
4 Copyright (C) 1997-2000 Allan Odgaard
5 Copyright (C) 2005-2014 TextEditor.mcc Open Source Team
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
17 TextEditor class Support Site: http://www.sf.net/projects/texteditor-mcc
21 ***************************************************************************/
26 // first we make sure all previously defined symbols are undefined now so
27 // that no other debug system interferes with ours.
52 #define DBC_CTRACE (1<<0) // call tracing (ENTER/LEAVE etc.)
53 #define DBC_REPORT (1<<1) // reports (SHOWVALUE/SHOWSTRING etc.)
54 #define DBC_ASSERT (1<<2) // asserts (ASSERT)
55 #define DBC_TIMEVAL (1<<3) // time evaluations (STARTCLOCK/STOPCLOCK)
56 #define DBC_DEBUG (1<<4) // debugging output D()
57 #define DBC_ERROR (1<<5) // error output E()
58 #define DBC_WARNING (1<<6) // warning output W()
59 #define DBC_MTRACK (1<<7) // memory tracking MEMTRACK/UNMEMTRACK()
60 #define DBC_ALL 0xffffffff
63 #define DBF_ALWAYS (1<<0)
64 #define DBF_STARTUP (1<<1) // for startup/shutdown events
65 #define DBF_ALL 0xffffffff
67 void SetupDebug(void);
68 void CleanupDebug(void);
69 void DumpDbgMalloc(void);
71 void _ENTER(unsigned long dclass
, const char *file
, int line
, const char *function
);
72 void _LEAVE(unsigned long dclass
, const char *file
, int line
, const char *function
);
73 void _RETURN(unsigned long dclass
, const char *file
, int line
, const char *function
, unsigned long result
);
74 void _SHOWVALUE(unsigned long dclass
, unsigned long dflags
, unsigned long value
, int size
, const char *name
, const char *file
, int line
);
75 void _SHOWPOINTER(unsigned long dclass
, unsigned long dflags
, const void *p
, const char *name
, const char *file
, int line
);
76 void _SHOWSTRING(unsigned long dclass
, unsigned long dflags
, const char *string
, const char *name
, const char *file
, int line
);
77 void _SHOWMSG(unsigned long dclass
, unsigned long dflags
, const char *msg
, const char *file
, int line
);
78 void _DPRINTF(unsigned long dclass
, unsigned long dflags
, const char *file
, unsigned long line
, const char *format
, ...);
79 void _VDPRINTF(unsigned long dclass
, unsigned long dflags
, const char *file
, unsigned long line
, const char *format
, va_list args
);
80 void _MEMTRACK(const char *file
, const int line
, const char *func
, void *ptr
, size_t size
);
81 void _UNMEMTRACK(const char *file
, const int line
, const char *func
, const void *ptr
);
83 // Core class information class messages
84 #define ENTER() _ENTER(DBC_CTRACE, __FILE__, __LINE__, __FUNCTION__)
85 #define LEAVE() _LEAVE(DBC_CTRACE, __FILE__, __LINE__, __FUNCTION__)
86 #define RETURN(r) _RETURN(DBC_CTRACE, __FILE__, __LINE__, __FUNCTION__, (long)r)
87 #define SHOWVALUE(f, v) _SHOWVALUE(DBC_REPORT, f, (long)v, sizeof(v), #v, __FILE__, __LINE__)
88 #define SHOWPOINTER(f, p) _SHOWPOINTER(DBC_REPORT, f, p, #p, __FILE__, __LINE__)
89 #define SHOWSTRING(f, s) _SHOWSTRING(DBC_REPORT, f, s, #s, __FILE__, __LINE__)
90 #define SHOWMSG(f, m) _SHOWMSG(DBC_REPORT, f, m, __FILE__, __LINE__)
91 #define MEMTRACK(f, p, s) _MEMTRACK(__FILE__, __LINE__, f, p, s)
92 #define UNMEMTRACK(f, p) _UNMEMTRACK(__FILE__, __LINE__, f, p)
93 #define D(f, ...) _DPRINTF(DBC_DEBUG, f, __FILE__, __LINE__, __VA_ARGS__)
94 #define E(f, ...) _DPRINTF(DBC_ERROR, f, __FILE__, __LINE__, __VA_ARGS__)
95 #define W(f, ...) _DPRINTF(DBC_WARNING, f, __FILE__, __LINE__, __VA_ARGS__)
96 #define ASSERT(expression) \
100 _DPRINTF(DBC_ASSERT, \
104 "failed assertion '%s'", \
106 assert(#expression), \
112 #if !defined(DEBUG_USE_MALLOC_REDEFINE) && !defined(__SASC) && !defined(__VBCC__)
114 // standard C-library memory functions
115 #define malloc(s) ({void *P = malloc(s); _MEMTRACK(__FILE__, __LINE__, "malloc", P, s); P;})
116 #define calloc(n, s) ({void *P = calloc(n, s); _MEMTRACK(__FILE__, __LINE__, "calloc", P, s); P;})
117 #define realloc(p, s) ({void *P; _UNMEMTRACK(__FILE__, __LINE__, "malloc|calloc|strdup|memdup|asprintf", p); P = realloc(p, s); _MEMTRACK(__FILE__, __LINE__, "realloc", P, s); P;})
118 #define strdup(s) ({char *P = strdup(s); _MEMTRACK(__FILE__, __LINE__, "strdup", P, strlen(s)+1); P;})
119 #define memdup(p, s) ({void *P = memdup(p, s); _MEMTRACK(__FILE__, __LINE__, "memdup", P, s); P;})
120 #define asprintf(p, f, ...) ({int P = asprintf(p, f, __VA_ARGS__); _MEMTRACK(__FILE__, __LINE__, "asprintf", *(p), 1); P;})
121 #define free(p) ({_UNMEMTRACK(__FILE__, __LINE__, "malloc|calloc|strdup|memdup|asprintf", p); free(p);})
123 // standard C-library IO functions
124 #define fopen(f, m) ({FILE *P = fopen(f, m); _MEMTRACK(__FILE__, __LINE__, "fopen", P, 1); P;})
125 #define fclose(p) ({int P; _UNMEMTRACK(__FILE__, __LINE__, "fopen", p); P = fclose(p); P;})
127 #include <proto/dos.h>
128 #include <proto/exec.h>
129 #include <proto/graphics.h>
131 // memory tracking of internal AmigaOS functions
132 #if !defined(__AROS__)
135 #undef AllocVecPooled
137 #undef AllocDosObject
138 #undef AllocDosObjectTags
140 #undef AllocSysObject
141 #undef AllocSysObjectTags
144 #undef ExamineObjectTags
147 #undef ObtainDirContext
148 #undef ObtainDirContextTags
149 #undef ReleaseDirContext
156 #if defined(__amigaos4__)
158 #define AllocPooled(p, s) ({APTR P = IExec->AllocPooled(p, s); _MEMTRACK(__FILE__, __LINE__, "AllocPooled", P, s); P;})
159 #define FreePooled(p, m, s) ({_UNMEMTRACK(__FILE__, __LINE__, "AllocPooled", m); IExec->FreePooled(p, m, s);})
160 #define AllocVecPooled(p, s) ({APTR P = IExec->AllocVecPooled(p, s); _MEMTRACK(__FILE__, __LINE__, "AllocVecPooled", P, s); P;})
161 #define FreeVecPooled(p, m) ({_UNMEMTRACK(__FILE__, __LINE__, "AllocVecPooled", m); IExec->FreeVecPooled(p, m);})
162 #define AllocDosObject(t, p) ({APTR P = IDOS->AllocDosObject(t, p); _MEMTRACK(__FILE__, __LINE__, "AllocDosObject", P, t+1); P;})
163 #define AllocDosObjectTags(t, ...) ({APTR P = IDOS->AllocDosObjectTags(t, __VA_ARGS__); _MEMTRACK(__FILE__, __LINE__, "AllocDosObjectTags", P, t+1); P;})
164 #define ExamineObject(t) ({APTR P = IDOS->ExamineObject(t); _MEMTRACK(__FILE__, __LINE__, "ExamineObject", P, 1); P;})
165 #define ExamineObjectTags(t, ...) ({APTR P = IDOS->ExamineObjectTags(t, __VA_ARGS__); _MEMTRACK(__FILE__, __LINE__, "ExamineObjectTags", P, 1); P;})
166 #define FreeDosObject(t, p) ({_UNMEMTRACK(__FILE__, __LINE__, "AllocDosObject|AllocDosObjectTags|ExamineObject|ExamineObjectTags", p); IDOS->FreeDosObject(t, p);})
167 #define AllocSysObject(t, p) ({APTR P = IExec->AllocSysObject(t, p); _MEMTRACK(__FILE__, __LINE__, "AllocSysObject", P, t+1); P;})
168 #define AllocSysObjectTags(t, ...) ({APTR P = IExec->AllocSysObjectTags(t, __VA_ARGS__); _MEMTRACK(__FILE__, __LINE__, "AllocSysObjectTags", P, t+1); P;})
169 #define FreeSysObject(t, p) ({_UNMEMTRACK(__FILE__, __LINE__, "AllocSysObject|AllocSysObjectTags", p); IExec->FreeSysObject(t, p);})
170 #define AllocBitMap(sx, sy, d, f, bm) ({APTR P = IGraphics->AllocBitMap(sx, sy, d, f, bm); _MEMTRACK(__FILE__, __LINE__, "AllocBitMap", P, sx); P;})
171 #define FreeBitMap(p) ({_UNMEMTRACK(__FILE__, __LINE__, "AllocBitMap", p); IGraphics->FreeBitMap(p);})
172 #define ObtainDirContext(t) ({APTR P = IDOS->ObtainDirContext(t); _MEMTRACK(__FILE__, __LINE__, "ObtainDirContextTags", P, 1); P;})
173 #define ObtainDirContextTags(...) ({APTR P = IDOS->ObtainDirContextTags(__VA_ARGS__); _MEMTRACK(__FILE__, __LINE__, "ObtainDirContextTags", P, 1); P;})
174 #define ReleaseDirContext(p) ({_UNMEMTRACK(__FILE__, __LINE__, "ObtainDirContext|ObtainDirContextTags", p); IDOS->ReleaseDirContext(p);})
175 #define AllocSignal(s) ({BYTE P = IExec->AllocSignal(s); _MEMTRACK(__FILE__, __LINE__, "AllocSignal", (APTR)(LONG)P, (size_t)s); P;})
176 #define FreeSignal(s) ({_UNMEMTRACK(__FILE__, __LINE__, "AllocSignal", (APTR)s); IExec->FreeSignal(s);})
177 #define StartNotify(p) ({LONG P = IDOS->StartNotify(p); _MEMTRACK(__FILE__, __LINE__, "StartNotify", p, (size_t)p); P;})
178 #define EndNotify(p) ({_UNMEMTRACK(__FILE__, __LINE__, "StartNotify", p); IDOS->EndNotify(p);})
180 #elif defined(__MORPHOS__)
182 #define AllocPooled(__p0, __p1) ({ \
183 APTR P = LP2(708, APTR , AllocPooled, \
186 , EXEC_BASE_NAME, 0, 0, 0, 0, 0, 0); \
187 _MEMTRACK(__FILE__, __LINE__, "AllocPooled", P, __p1); \
191 #define FreePooled(__p0, __p1, __p2) ({ \
192 _UNMEMTRACK(__FILE__, __LINE__, "AllocPooled", __p1); \
193 LP3NR(714, FreePooled, \
197 , EXEC_BASE_NAME, 0, 0, 0, 0, 0, 0); \
200 #define AllocVecPooled(__p0, __p1) ({ \
201 APTR P = LP2(894, APTR , AllocVecPooled, \
204 , EXEC_BASE_NAME, 0, 0, 0, 0, 0, 0); \
205 _MEMTRACK(__FILE__, __LINE__, "AllocVecPooled", P, __p1); \
209 #define FreeVecPooled(__p0, __p1) ({ \
210 _UNMEMTRACK(__FILE__, __LINE__, "AllocVecPooled", __p1); \
211 LP2NR(900, FreeVecPooled, \
214 , EXEC_BASE_NAME, 0, 0, 0, 0, 0, 0); \
217 #define AllocDosObject(__p0, __p1) ({ \
218 APTR P = LP2(228, APTR , AllocDosObject, \
220 CONST struct TagItem *, __p1, d2, \
221 , DOS_BASE_NAME, 0, 0, 0, 0, 0, 0); \
222 _MEMTRACK(__FILE__, __LINE__, "AllocDosObject", P, __p0); \
226 #define FreeDosObject(__p0, __p1) ({ \
227 _UNMEMTRACK(__FILE__, __LINE__, "AllocDosObject|AllocDosObjectTags", __p1); \
228 LP2NR(234, FreeDosObject, \
231 , DOS_BASE_NAME, 0, 0, 0, 0, 0, 0); \
234 #define AllocSysObject(t, p) ({APTR P = AllocSysObject(t, p); _MEMTRACK(__FILE__, __LINE__, "AllocSysObject", P, t+1); P;})
236 #define AllocSysObjectTags(t, ...) ({ \
237 ULONG _tags[] = { __VA_ARGS__ }; \
238 APTR P = AllocSysObject(t, (struct TagItem *)_tags); \
239 _MEMTRACK(__FILE__, __LINE__, "AllocSysObjectTags", P, t+1); \
243 #define FreeSysObject(t, p) ({_UNMEMTRACK(__FILE__, __LINE__, "AllocSysObject|AllocSysObjectTags", p); FreeSysObject(t, p);})
245 #define AllocBitMap(__p0, __p1, __p2, __p3, __p4) ({ \
246 APTR P = LP5(918, struct BitMap *, AllocBitMap, \
251 CONST struct BitMap *, __p4, a0, \
252 , GRAPHICS_BASE_NAME, 0, 0, 0, 0, 0, 0); \
253 _MEMTRACK(__FILE__, __LINE__, "AllocBitMap", P, __p0); \
257 #define FreeBitMap(__p0) ({ \
258 _UNMEMTRACK(__FILE__, __LINE__, "AllocBitMap", __p0); \
259 LP1NR(924, FreeBitMap, \
260 struct BitMap *, __p0, a0, \
261 , GRAPHICS_BASE_NAME, 0, 0, 0, 0, 0, 0); \
264 #define ObtainDirContext(t) ({APTR P = ObtainDirContext(t); _MEMTRACK(__FILE__, __LINE__, "ObtainDirContextTags", P, 1); P;})
266 #define ObtainDirContextTags(...) ({ \
267 ULONG _tags[] = { __VA_ARGS__ }; \
268 APTR P = ObtainDirContext((struct TagItem *)_tags); \
269 _MEMTRACK(__FILE__, __LINE__, "ObtainDirContextTags", P, 1); \
273 #define ReleaseDirContext(p) ({_UNMEMTRACK(__FILE__, __LINE__, "ObtainDirContext|ObtainDirContextTags", p); ReleaseDirContext(p);})
275 #define AllocSignal(__p0) ({ \
276 BYTE P = LP1(330, BYTE , AllocSignal, \
278 , EXEC_BASE_NAME, 0, 0, 0, 0, 0, 0); \
279 _MEMTRACK(__FILE__, __LINE__, "AllocSignal", (APTR)(LONG)P, (size_t)__p0); \
283 #define FreeSignal(__p0) ({ \
284 _UNMEMTRACK(__FILE__, __LINE__, "AllocSignal", (APTR)__p0); \
285 LP1NR(336, FreeSignal, \
287 , EXEC_BASE_NAME, 0, 0, 0, 0, 0, 0); \
290 #define StartNotify(__p0) ({ \
291 BOOL P = LP1(888, BOOL , StartNotify, \
292 struct NotifyRequest *, __p0, d1, \
293 , DOS_BASE_NAME, 0, 0, 0, 0, 0, 0); \
294 _MEMTRACK(__FILE__, __LINE__, "StartNotify", __p0, (size_t)__p0); \
298 #define EndNotify(__p0) ({ \
299 _UNMEMTRACK(__FILE__, __LINE__, "StartNotify", __p0); \
300 LP1NR(894, EndNotify, \
301 struct NotifyRequest *, __p0, d1, \
302 , DOS_BASE_NAME, 0, 0, 0, 0, 0, 0); \
305 #elif !defined(__AROS__) // AmigaOS 3
307 #define AllocPooled(poolHeader, memSize) ({ \
308 APTR _AllocPooled_poolHeader = (poolHeader); \
309 ULONG _AllocPooled_memSize = (memSize); \
310 APTR _AllocPooled__re = \
312 register struct ExecBase * const __AllocPooled__bn __asm("a6") = (struct ExecBase *) (EXEC_BASE_NAME);\
313 register APTR __AllocPooled__re __asm("d0"); \
314 register APTR __AllocPooled_poolHeader __asm("a0") = (_AllocPooled_poolHeader); \
315 register ULONG __AllocPooled_memSize __asm("d0") = (_AllocPooled_memSize); \
316 __asm volatile ("jsr a6@(-708:W)" \
317 : "=r"(__AllocPooled__re) \
318 : "r"(__AllocPooled__bn), "r"(__AllocPooled_poolHeader), "r"(__AllocPooled_memSize) \
319 : "d1", "a0", "a1", "fp0", "fp1", "cc", "memory"); \
322 _MEMTRACK(__FILE__, __LINE__, "AllocPooled", _AllocPooled__re, memSize); \
326 #define FreePooled(poolHeader, memory, memSize) ({ \
327 _UNMEMTRACK(__FILE__, __LINE__, "AllocPooled", memory); { \
328 APTR _FreePooled_poolHeader = (poolHeader); \
329 APTR _FreePooled_memory = (memory); \
330 ULONG _FreePooled_memSize = (memSize); \
332 register struct ExecBase * const __FreePooled__bn __asm("a6") = (struct ExecBase *) (EXEC_BASE_NAME);\
333 register APTR __FreePooled_poolHeader __asm("a0") = (_FreePooled_poolHeader); \
334 register APTR __FreePooled_memory __asm("a1") = (_FreePooled_memory); \
335 register ULONG __FreePooled_memSize __asm("d0") = (_FreePooled_memSize); \
336 __asm volatile ("jsr a6@(-714:W)" \
338 : "r"(__FreePooled__bn), "r"(__FreePooled_poolHeader), "r"(__FreePooled_memory), "r"(__FreePooled_memSize) \
339 : "d0", "d1", "a0", "a1", "fp0", "fp1", "cc", "memory"); \
343 #define AllocVecPooled(p, s) ({APTR P = AllocVecPooled(p, s); _MEMTRACK(__FILE__, __LINE__, "AllocVecPooled", P, s); P;})
344 #define FreeVecPooled(p, m) ({_UNMEMTRACK(__FILE__, __LINE__, "AllocVecPooled", m); FreeVecPooled(p, m);})
346 #define AllocDosObject(type, tags) ({ \
347 ULONG _AllocDosObject_type = (type); \
348 const struct TagItem * _AllocDosObject_tags = (tags); \
349 APTR _AllocDosObject__re = \
351 register struct DosLibrary * const __AllocDosObject__bn __asm("a6") = (struct DosLibrary *) (DOS_BASE_NAME);\
352 register APTR __AllocDosObject__re __asm("d0"); \
353 register ULONG __AllocDosObject_type __asm("d1") = (_AllocDosObject_type); \
354 register const struct TagItem * __AllocDosObject_tags __asm("d2") = (_AllocDosObject_tags); \
355 __asm volatile ("jsr a6@(-228:W)" \
356 : "=r"(__AllocDosObject__re) \
357 : "r"(__AllocDosObject__bn), "r"(__AllocDosObject_type), "r"(__AllocDosObject_tags) \
358 : "d1", "a0", "a1", "fp0", "fp1", "cc", "memory"); \
359 __AllocDosObject__re; \
361 _MEMTRACK(__FILE__, __LINE__, "AllocDosObject", _AllocDosObject__re, type); \
362 _AllocDosObject__re; \
365 #define FreeDosObject(type, ptr) ({ _UNMEMTRACK(__FILE__, __LINE__, "AllocDosObject|AllocDosObjectTags", ptr); { \
366 ULONG _FreeDosObject_type = (type); \
367 APTR _FreeDosObject_ptr = (ptr); \
369 register struct DosLibrary * const __FreeDosObject__bn __asm("a6") = (struct DosLibrary *) (DOS_BASE_NAME);\
370 register ULONG __FreeDosObject_type __asm("d1") = (_FreeDosObject_type); \
371 register APTR __FreeDosObject_ptr __asm("d2") = (_FreeDosObject_ptr); \
372 __asm volatile ("jsr a6@(-234:W)" \
374 : "r"(__FreeDosObject__bn), "r"(__FreeDosObject_type), "r"(__FreeDosObject_ptr) \
375 : "d0", "d1", "a0", "a1", "fp0", "fp1", "cc", "memory"); \
379 #define AllocSysObject(t, p) ({APTR P = AllocSysObject(t, p); _MEMTRACK(__FILE__, __LINE__, "AllocSysObject", P, t+1); P;})
381 #define AllocSysObjectTags(t, ...) ({APTR P = AllocSysObjectTags(t, __VA_ARGS__); _MEMTRACK(__FILE__, __LINE__, "AllocSysObjectTags", P, t+1); P;})
383 #define FreeSysObject(t, p) ({_UNMEMTRACK(__FILE__, __LINE__, "AllocSysObject|AllocSysObjectTags", p); FreeSysObject(t, p);})
385 #define AllocBitMap(sizex, sizey, depth, flags, friend_bitmap) ({ \
386 ULONG _AllocBitMap_sizex = (sizex); \
387 ULONG _AllocBitMap_sizey = (sizey); \
388 ULONG _AllocBitMap_depth = (depth); \
389 ULONG _AllocBitMap_flags = (flags); \
390 CONST struct BitMap * _AllocBitMap_friend_bitmap = (friend_bitmap); \
391 struct BitMap * _AllocBitMap__re = \
393 register struct GfxBase * const __AllocBitMap__bn __asm("a6") = (struct GfxBase *) (GRAPHICS_BASE_NAME);\
394 register struct BitMap * __AllocBitMap__re __asm("d0"); \
395 register ULONG __AllocBitMap_sizex __asm("d0") = (_AllocBitMap_sizex); \
396 register ULONG __AllocBitMap_sizey __asm("d1") = (_AllocBitMap_sizey); \
397 register ULONG __AllocBitMap_depth __asm("d2") = (_AllocBitMap_depth); \
398 register ULONG __AllocBitMap_flags __asm("d3") = (_AllocBitMap_flags); \
399 register CONST struct BitMap * __AllocBitMap_friend_bitmap __asm("a0") = (_AllocBitMap_friend_bitmap); \
400 __asm volatile ("jsr a6@(-918:W)" \
401 : "=r"(__AllocBitMap__re) \
402 : "r"(__AllocBitMap__bn), "r"(__AllocBitMap_sizex), "r"(__AllocBitMap_sizey), "r"(__AllocBitMap_depth), "r"(__AllocBitMap_flags), "r"(__AllocBitMap_friend_bitmap) \
403 : "d1", "a0", "a1", "fp0", "fp1", "cc", "memory"); \
406 _MEMTRACK(__FILE__, __LINE__, "AllocBitMap", _AllocBitMap__re, sizex); \
410 #define FreeBitMap(bm) ({ _UNMEMTRACK(__FILE__, __LINE__, "AllocBitMap", bm); { \
411 struct BitMap * _FreeBitMap_bm = (bm); \
413 register struct GfxBase * const __FreeBitMap__bn __asm("a6") = (struct GfxBase *) (GRAPHICS_BASE_NAME);\
414 register struct BitMap * __FreeBitMap_bm __asm("a0") = (_FreeBitMap_bm); \
415 __asm volatile ("jsr a6@(-924:W)" \
417 : "r"(__FreeBitMap__bn), "r"(__FreeBitMap_bm) \
418 : "d0", "d1", "a0", "a1", "fp0", "fp1", "cc", "memory"); \
422 #define ObtainDirContext(t) ({APTR P = ObtainDirContext(t); _MEMTRACK(__FILE__, __LINE__, "ObtainDirContextTags", P, 1); P;})
423 #define ObtainDirContextTags(...) ({APTR P = ObtainDirContextTags(__VA_ARGS__); _MEMTRACK(__FILE__, __LINE__, "ObtainDirContextTags", P, 1); P;})
424 #define ReleaseDirContext(p) ({_UNMEMTRACK(__FILE__, __LINE__, "ObtainDirContext|ObtainDirContextTags", p); ReleaseDirContext(p);})
426 #define AllocSignal(signalNum) ({ \
427 LONG _AllocSignal_signalNum = (signalNum); \
428 BYTE _AllocSignal__re = \
430 register struct ExecBase * const __AllocSignal__bn __asm("a6") = (struct ExecBase *) (EXEC_BASE_NAME);\
431 register BYTE __AllocSignal__re __asm("d0"); \
432 register LONG __AllocSignal_signalNum __asm("d0") = (_AllocSignal_signalNum); \
433 __asm volatile ("jsr a6@(-330:W)" \
434 : "=r"(__AllocSignal__re) \
435 : "r"(__AllocSignal__bn), "r"(__AllocSignal_signalNum) \
436 : "d1", "a0", "a1", "fp0", "fp1", "cc", "memory"); \
439 _MEMTRACK(__FILE__, __LINE__, "AllocSignal", (APTR)(LONG)_AllocSignal__re, (size_t)signalNum); \
443 #define FreeSignal(signalNum) ({ _UNMEMTRACK(__FILE__, __LINE__, "AllocSignal", (APTR)signalNum); { \
444 LONG _FreeSignal_signalNum = (signalNum); \
446 register struct ExecBase * const __FreeSignal__bn __asm("a6") = (struct ExecBase *) (EXEC_BASE_NAME);\
447 register LONG __FreeSignal_signalNum __asm("d0") = (_FreeSignal_signalNum); \
448 __asm volatile ("jsr a6@(-336:W)" \
450 : "r"(__FreeSignal__bn), "r"(__FreeSignal_signalNum) \
451 : "d0", "d1", "a0", "a1", "fp0", "fp1", "cc", "memory"); \
455 #define StartNotify(notify) ({ \
456 struct NotifyRequest * _StartNotify_notify = (notify); \
457 BOOL _StartNotify__re = \
459 register struct DosLibrary * const __StartNotify__bn __asm("a6") = (struct DosLibrary *) (DOS_BASE_NAME);\
460 register BOOL __StartNotify__re __asm("d0"); \
461 register struct NotifyRequest * __StartNotify_notify __asm("d1") = (_StartNotify_notify); \
462 __asm volatile ("jsr a6@(-888:W)" \
463 : "=r"(__StartNotify__re) \
464 : "r"(__StartNotify__bn), "r"(__StartNotify_notify) \
465 : "d1", "a0", "a1", "fp0", "fp1", "cc", "memory"); \
468 _MEMTRACK(__FILE__, __LINE__, "StartNotify", _StartNotify_notify, (size_t)_StartNotify_notify); \
472 #define EndNotify(notify) ({ _UNMEMTRACK(__FILE__, __LINE__, "StartNotify", notify); { \
473 struct NotifyRequest * _EndNotify_notify = (notify); \
475 register struct DosLibrary * const __EndNotify__bn __asm("a6") = (struct DosLibrary *) (DOS_BASE_NAME);\
476 register struct NotifyRequest * __EndNotify_notify __asm("d1") = (_EndNotify_notify); \
477 __asm volatile ("jsr a6@(-894:W)" \
479 : "r"(__EndNotify__bn), "r"(__EndNotify_notify) \
480 : "d0", "d1", "a0", "a1", "fp0", "fp1", "cc", "memory"); \
486 #endif // !DEBUG_USE_MALLOC_REDEFINE
490 // to replace with NOPs is important here!
491 #define ENTER() ((void)0)
492 #define LEAVE() ((void)0)
493 #define RETURN(r) ((void)0)
494 #define SHOWVALUE(f, v) ((void)0)
495 #define SHOWPOINTER(f, p) ((void)0)
496 #define SHOWSTRING(f, s) ((void)0)
497 #define SHOWMSG(f, m) ((void)0)
498 #define MEMTRACK(f, p, s) ((void)0)
499 #define UNMEMTRACK(f, p) ((void)0)
500 #define D(f, ...) ((void)0)
501 #define E(f, ...) ((void)0)
502 #define W(f, ...) ((void)0)
503 #define ASSERT(expression) ((void)0)
505 #define DumpDbgMalloc() ((void)0)