source: git/Singular/omSingularConfig.h @ 30d8a1

spielwiese
Last change on this file since 30d8a1 was c232af, checked in by Olaf Bachmann <obachman@…>, 24 years ago
* omalloc stuff git-svn-id: file:///usr/local/Singular/svn/trunk@4524 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 2.5 KB
Line 
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
12extern "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
25int om_sing_opt_show_mem = 0;
26size_t om_sing_last_reported_size = 0;
27#else
28extern int om_sing_opt_show_mem;
29extern 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                                                        \
35do                                                                              \
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}                                                                               \
52while (0)
53
54#ifdef __cplusplus
55}
56#endif
57
58#endif /* OM_SINGULAR_CONFIG_H */
Note: See TracBrowser for help on using the repository browser.