[35aab3] | 1 | /******************************************************************* |
---|
| 2 | * File: omSingularConfig.h |
---|
| 3 | * Purpose: declaration of External Config stuff for omalloc |
---|
| 4 | * This file is inlcuded by omDefaultConfig.h, i.e., at the the time |
---|
| 5 | * the omalloc library is built. Any changes to the default config |
---|
| 6 | * of omalloc should be done here (and, of course, you need to |
---|
| 7 | * rebuilt the library). |
---|
| 8 | * Author: obachman@mathematik.uni-kl.de (Olaf Bachmann) |
---|
| 9 | * Created: 8/00 |
---|
[341696] | 10 | * Version: $Id$ |
---|
[35aab3] | 11 | *******************************************************************/ |
---|
| 12 | #ifndef OM_SINGULAR_CONFIG_H |
---|
| 13 | #define OM_SINGULAR_CONFIG_H |
---|
| 14 | |
---|
| 15 | #ifdef __cplusplus |
---|
| 16 | extern "C" |
---|
| 17 | { |
---|
| 18 | #endif |
---|
| 19 | |
---|
| 20 | #include <stdlib.h> |
---|
| 21 | #include <stdio.h> |
---|
| 22 | |
---|
| 23 | #define OM_MALLOC_HOOK(size) OM_SINGULAR_HOOK |
---|
| 24 | #define OM_FREE_HOOK(size) OM_SINGULAR_HOOK |
---|
| 25 | #define OM_ALLOC_BINPAGE_HOOK OM_SINGULAR_HOOK |
---|
| 26 | #define OM_FREE_BINPAGE_HOOK OM_SINGULAR_HOOK |
---|
| 27 | |
---|
| 28 | #ifdef OM_ALLOC_SYSTEM_C |
---|
| 29 | int om_sing_opt_show_mem = 0; |
---|
| 30 | size_t om_sing_last_reported_size = 0; |
---|
| 31 | #else |
---|
| 32 | extern int om_sing_opt_show_mem; |
---|
| 33 | extern size_t om_sing_last_reported_size; |
---|
| 34 | #endif |
---|
| 35 | |
---|
| 36 | /* number of bytes for difference to report: every 1 MByte */ |
---|
| 37 | #define SING_REPORT_THRESHOLD 1000*1024 |
---|
| 38 | #define OM_SINGULAR_HOOK \ |
---|
| 39 | do \ |
---|
| 40 | { \ |
---|
| 41 | if (om_sing_opt_show_mem) \ |
---|
| 42 | { \ |
---|
| 43 | size_t _current_bytes = om_Info.CurrentBytesFromMalloc + \ |
---|
| 44 | (om_Info.UsedPages << LOG_BIT_SIZEOF_SYSTEM_PAGE); \ |
---|
| 45 | size_t _diff = (_current_bytes > om_sing_last_reported_size ? \ |
---|
| 46 | _current_bytes - om_sing_last_reported_size : \ |
---|
| 47 | om_sing_last_reported_size - _current_bytes); \ |
---|
| 48 | if (_diff >= SING_REPORT_THRESHOLD) \ |
---|
| 49 | { \ |
---|
| 50 | fprintf(stdout, "[%ldk]", (_current_bytes + 1023)/1024); \ |
---|
| 51 | fflush(stdout); \ |
---|
| 52 | om_sing_last_reported_size = _current_bytes; \ |
---|
| 53 | } \ |
---|
| 54 | } \ |
---|
| 55 | } \ |
---|
| 56 | while (0) |
---|
| 57 | |
---|
| 58 | #ifdef __cplusplus |
---|
| 59 | } |
---|
| 60 | #endif |
---|
| 61 | |
---|
| 62 | #endif /* OM_SINGULAR_CONFIG_H */ |
---|