1 | /******************************************************************* |
---|
2 | * File: omSingularConfig.h |
---|
3 | * Purpose: declaration of External Config stuff for omalloc |
---|
4 | * Author: obachman@mathematik.uni-kl.de (Olaf Bachmann) |
---|
5 | * Created: 8/00 |
---|
6 | * Version: $Id: omSingularConfig.h,v 1.1 2000-08-14 12:57:49 obachman Exp $ |
---|
7 | *******************************************************************/ |
---|
8 | #ifndef OM_SINGULAR_CONFIG_H |
---|
9 | #define OM_SINGULAR_CONFIG_H |
---|
10 | |
---|
11 | #ifdef __cplusplus |
---|
12 | extern "C" |
---|
13 | { |
---|
14 | #endif |
---|
15 | |
---|
16 | #include <stdlib.h> |
---|
17 | #include <stdio.h> |
---|
18 | |
---|
19 | #define OM_MALLOC_HOOK(size) OM_SINGULAR_HOOK |
---|
20 | #define OM_FREE_HOOK(size) OM_SINGULAR_HOOK |
---|
21 | #define OM_ALLOC_BINPAGE_HOOK OM_SINGULAR_HOOK |
---|
22 | #define OM_FREE_BINPAGE_HOOK OM_SINGULAR_HOOK |
---|
23 | |
---|
24 | #ifdef OM_ALLOC_SYSTEM_C |
---|
25 | int om_sing_opt_show_mem = 0; |
---|
26 | size_t om_sing_last_reported_size = 0; |
---|
27 | #else |
---|
28 | extern int om_sing_opt_show_mem; |
---|
29 | extern size_t om_sing_last_reported_size; |
---|
30 | #endif |
---|
31 | |
---|
32 | /* number of bytes for difference to report */ |
---|
33 | #define SING_REPORT_THRESHOLD 100*1024 |
---|
34 | #define OM_SINGULAR_HOOK \ |
---|
35 | do \ |
---|
36 | { \ |
---|
37 | if (om_sing_opt_show_mem) \ |
---|
38 | { \ |
---|
39 | size_t _current_bytes = om_Info.CurrentBytesFromMalloc + \ |
---|
40 | (om_Info.UsedPages << LOG_BIT_SIZEOF_SYSTEM_PAGE); \ |
---|
41 | size_t _diff = (_current_bytes > om_sing_last_reported_size ? \ |
---|
42 | _current_bytes - om_sing_last_reported_size : \ |
---|
43 | om_sing_last_reported_size - _current_bytes); \ |
---|
44 | if (_diff >= SING_REPORT_THRESHOLD) \ |
---|
45 | { \ |
---|
46 | fprintf(stdout, "[%dk]", (_current_bytes + 1023)/1024); \ |
---|
47 | fflush(stdout); \ |
---|
48 | om_sing_last_reported_size = _current_bytes; \ |
---|
49 | } \ |
---|
50 | } \ |
---|
51 | } \ |
---|
52 | while (0) |
---|
53 | |
---|
54 | #ifdef __cplusplus |
---|
55 | } |
---|
56 | #endif |
---|
57 | |
---|
58 | #endif /* OM_SINGULAR_CONFIG_H */ |
---|