Added SILC Thread Queue API
[silc.git] / lib / silcutil / stacktrace.h
1 /*
2
3   stacktrace.h 
4
5   Author: Pekka Riikonen <priikone@silcnet.org>
6
7   Copyright (C) 2002 Pekka Riikonen
8
9   This program is free software; you can redistribute it and/or modify
10   it under the terms of the GNU General Public License as published by
11   the Free Software Foundation; version 2 of the License.
12
13   This program is distributed in the hope that it will be useful,
14   but WITHOUT ANY WARRANTY; without even the implied warranty of
15   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16   GNU General Public License for more details.
17
18 */
19
20 #ifndef STACKTRACE_H
21 #define STACKTRACE_H
22
23 #ifndef SILCMEMORY_H
24 #error "Do not include internal header file directly"
25 #endif
26
27 #if defined(__GNUC__) && defined(__i386__)
28
29 #undef strdup
30 #define silc_malloc(s)      silc_st_malloc((s), __FILE__, __LINE__)
31 #define silc_calloc(i, s)   silc_st_calloc((i), (s), __FILE__, __LINE__)
32 #define silc_realloc(p, s)  silc_st_realloc((p), (s), __FILE__, __LINE__)
33 #define silc_free(p)        silc_st_free((p), __FILE__, __LINE__)
34 #define silc_memdup(p, s)   silc_st_memdup((p), (s), __FILE__, __LINE__)
35 #define strdup(s)           silc_st_strdup((s), __FILE__, __LINE__)
36
37 void *silc_st_malloc(size_t size, const char *file, int line);
38 void *silc_st_calloc(size_t items, size_t size, const char *file, int line);
39 void *silc_st_realloc(void *ptr, size_t size, const char *file, int line);
40 void silc_st_free(void *ptr, const char *file, int line);
41 void *silc_st_memdup(const void *ptr, size_t size, const char *file, int line);
42 void *silc_st_strdup(const char *string, const char *file, int line);
43 void silc_st_dump(void);
44
45 #else
46 #error "memory allocation stack trace not supported on this platform"
47 #endif /* __GNUC__ && __i386__ */
48
49 #endif /* STACKTRACE_H */