source: git/Singular/omSingularConfig.h @ 0df59c8

spielwiese
Last change on this file since 0df59c8 was e961ee4, checked in by Hans Schoenemann <hannes@…>, 13 years ago
fprinf fixes git-svn-id: file:///usr/local/Singular/svn/trunk@13784 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 2.7 KB
Line 
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
10 *  Version: $Id$
11 *******************************************************************/
12#ifndef OM_SINGULAR_CONFIG_H
13#define OM_SINGULAR_CONFIG_H
14
15#ifdef __cplusplus
16extern "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
29int om_sing_opt_show_mem = 0;
30size_t om_sing_last_reported_size = 0;
31#else
32extern int om_sing_opt_show_mem;
33extern 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                                                        \
39do                                                                            \
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]", (long)(_current_bytes + 1023)/1024);                \
51      fflush(stdout);                                                         \
52      om_sing_last_reported_size = _current_bytes;                            \
53    }                                                                         \
54  }                                                                           \
55}                                                                             \
56while (0)
57
58#ifdef __cplusplus
59}
60#endif
61
62#endif /* OM_SINGULAR_CONFIG_H */
Note: See TracBrowser for help on using the repository browser.