Skip to content

Commit

Permalink
fix; option(mem)
Browse files Browse the repository at this point in the history
  • Loading branch information
hannes14 committed Jul 7, 2015
1 parent 3d2cb9e commit c0bd770
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 68 deletions.
1 change: 0 additions & 1 deletion Singular/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ SingularHEADERS = \
misc_ip.h \
mmalloc.h \
mod_lib.h \
omSingularConfig.h \
links/ndbm.h \
newstruct.h \
number2.h \
Expand Down
2 changes: 0 additions & 2 deletions Singular/misc_ip.cc
Original file line number Diff line number Diff line change
Expand Up @@ -715,12 +715,10 @@ BOOLEAN setOption(leftv res, leftv v)
v=v->next;
} while (v!=NULL);

#ifdef OM_SINGULAR_CONFIG_H
// set global variable to show memory usage
extern int om_sing_opt_show_mem;
if (BVERBOSE(V_SHOW_MEM)) om_sing_opt_show_mem = 1;
else om_sing_opt_show_mem = 0;
#endif

return FALSE;
}
Expand Down
61 changes: 0 additions & 61 deletions Singular/omSingularConfig.h

This file was deleted.

1 change: 0 additions & 1 deletion Singular/test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@
#include <Singular/misc_ip.h>
#include <Singular/links/ndbm.h>
#include <Singular/newstruct.h>
#include <Singular/omSingularConfig.h>
#include <Singular/pcv.h>
#include <Singular/links/pipeLink.h>
#include <Singular/run.h>
Expand Down
3 changes: 0 additions & 3 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,6 @@ SING_CHECK_PLURAL

SING_BUILTIN_MODULES

### the following is needed due to the use of om_sing_opt_show_mem in misc_ip.cc...
#ac_configure_args="$ac_configure_args --with-external-config_h=../Singular/omSingularConfig.h"

AC_ARG_ENABLE(countedref, AS_HELP_STRING([--enable-countedref], [Enable autoloading of reference counted types]),
[if test "x$enableval" = "xyes"; then
ENABLE_COUNTEDREF_AUTOLOAD=yes
Expand Down
57 changes: 57 additions & 0 deletions omalloc/omDefaultConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,4 +198,61 @@ while(0)
#endif
#ifndef OM_FREE_PATTERN
#define OM_FREE_PATTERN 0xfb
/*******************************************************************
* File: omSingularConfig.h
* Purpose: declaration of External Config stuff for omalloc
* This file is part of omDefaultConfig.h, i.e., at the the time
* the omalloc library is built. Any changes to the default config
* of omalloc should be done here (and, of course, you need to
* rebuilt the library).
* Author: obachman@mathematik.uni-kl.de (Olaf Bachmann)
* Created: 8/00
*******************************************************************/
#ifdef __cplusplus
extern "C"
{
#endif

#include <stdlib.h>
#include <stdio.h>

#define OM_MALLOC_HOOK(size) OM_SINGULAR_HOOK
#define OM_FREE_HOOK(size) OM_SINGULAR_HOOK
#define OM_ALLOC_BINPAGE_HOOK OM_SINGULAR_HOOK
#define OM_FREE_BINPAGE_HOOK OM_SINGULAR_HOOK

#ifdef OM_ALLOC_SYSTEM_C
int om_sing_opt_show_mem = 0;
size_t om_sing_last_reported_size = 0;
#else
extern int om_sing_opt_show_mem;
extern size_t om_sing_last_reported_size;
#endif

/* number of bytes for difference to report: every 1 MByte */
#define SING_REPORT_THRESHOLD 1000*1024
#define OM_SINGULAR_HOOK \
do \
{ \
if (om_sing_opt_show_mem) \
{ \
size_t _current_bytes = om_Info.CurrentBytesFromMalloc + \
(om_Info.UsedPages << LOG_BIT_SIZEOF_SYSTEM_PAGE);\
size_t _diff = (_current_bytes > om_sing_last_reported_size ? \
_current_bytes - om_sing_last_reported_size : \
om_sing_last_reported_size - _current_bytes); \
if (_diff >= SING_REPORT_THRESHOLD) \
{ \
fprintf(stdout, "[%ldk]", (long)(_current_bytes + 1023)/1024); \
fflush(stdout); \
om_sing_last_reported_size = _current_bytes; \
} \
} \
} \
while (0)

#ifdef __cplusplus
}
#endif

#endif

0 comments on commit c0bd770

Please sign in to comment.