Changeset 3df5b10 in git for omalloc


Ignore:
Timestamp:
Aug 14, 2000, 2:08:48 PM (24 years ago)
Author:
Olaf Bachmann <obachman@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
9d605984360cf5d30bdf13e295d63c41ae1bc952
Parents:
ecf4ca6ad75f235385946daeae249f3bc6fd13c8
Message:
* update


git-svn-id: file:///usr/local/Singular/svn/trunk@4516 2c84dea3-7e68-4137-9b89-c4e89433aadc
Location:
omalloc
Files:
6 added
15 edited

Legend:

Unmodified
Added
Removed
  • omalloc/Makefile.in

    recf4ca6 r3df5b10  
    44### Author:  obachman@mathematik.uni-kl.de (Olaf Bachmann)
    55### Created: 11/99
    6 ### Version: $Id: Makefile.in,v 1.3 2000-05-31 13:34:28 obachman Exp $
     6### Version: $Id: Makefile.in,v 1.4 2000-08-14 12:08:40 obachman Exp $
    77#################################################################
    88
    99SHELL           = /bin/sh
     10VERSION         = @VERSION@
    1011
    1112##
    1213## various paths
    1314##
     15prefix          = @prefix@
     16exec_prefix     = @exec_prefix@
     17
    1418# header file is installed here
    1519includedir      = @includedir@
     
    2630PERL            = @PERL@
    2731LN_S            = @LN_S@
    28 INSTALL         = ../install-sh -c
    29 INSTALL_PROGRAM = ${INSTALL}
    30 INSTALL_DATA    = ${INSTALL} -m 644
    31 MKINSTALLDIRS   = ../mkinstalldirs
     32INSTALL         = @INSTALL@
     33INSTALL_PROGRAM = @INSTALL_PROGRAM@
     34INSTALL_DATA    = @INSTALL_DATA@
     35MKINSTALLDIRS   = ./mkinstalldirs
    3236##
    3337## compiler and linker options
    3438##
    3539CFLAGS          = @CFLAGS@
    36 # CFLAGS                = @CFLAGS@  -Wno-unused
    37 CPPFLAGS        = @CPPFLAGS@
    38 DEFS            = -DNDEBUG @DEFS@
     40CPPFLAGS        = -I. @CPPFLAGS@
     41DEFS            = @DEFS@
    3942
    4043##
    4144## external config and and malloc files
    4245##
    43 
     46EXTERNAL_CONFIG_SOURCE = @EXTERNAL_CONFIG_SOURCE@
    4447EXTERNAL_CONFIG_HEADER = @EXTERNAL_CONFIG_HEADER@
    45 EXTERNAL_CONFIG_SOURCE = @EXTERNAL_CONFIG_SOURCE@
    4648
    4749OM_MALLOC_HEADER = @OM_MALLOC_HEADER@
     
    5658###
    5759
    58 
    5960# normal C source files
    60 CSOURCES=                                                       \
    61 omBinPage.c      omList.c         omAllocEmulate.c              \
    62 omAlloc.c        omCheck.c        omOpts.c         omTrack.c    \
    63 omAllocSystem.c  omError.c        omStats.c                     \
    64 omBin.c          omFindExec.c     omDebug.c
     61CSOURCES=                                                          \
     62omBinPage.c      omList.c         omAllocEmulate.c omDebug.c       \
     63omAlloc.c        omDebugCheck.c   omOpts.c         omGetBackTrace.c\
     64omAllocSystem.c  omError.c        omStats.c        omRet2Info.c   \
     65omBin.c          omFindExec.c     omDebugTrack.c                   \
     66omalloc_provide.c         
    6567
    6668ifdef EXTERNAL_CONFIG_SOURCE
     
    7577
    7678HEADERS=                                                        \
    77 omAlloc.h              omCheck.h              omList.h          \
     79omAlloc.h              omList.h               omDerivedConfig.h \
    7880omAllocDecl.h          omConfig.h             omMemOps.h        \
    79 omDebug.h              omOpts.h                                 \
     81omDebug.h              omOpts.h               omInlineDecl.h    \
    8082omAllocPrivate.h       omError.h              omPage.h          \
    8183omAllocSystem.h        omFindExec.h           omStats.h         \
    8284omBin.h                omDefaultConfig.h      omStructs.h       \
    83 omBinPage.h            omInline.h             omTrack.h         \
    84 
    85 OBJS := $(CSOURCES:.c=.o)  $(GSOURCES:.c=.o)
    86 
     85omBinPage.h            omInline.h             omGetBackTrace.h  \
     86omReturn.h             omRet2Info.h             
     87
     88OBJS := $(CSOURCES:.c=.o)  $(GSOURCES:.c=.o)
     89OBJS_NDEBUG := $(CSOURCES:.c=.o_ndebug) $(GSOURCES:.c=.o_ndebug)
    8790
    8891SOURCES=${CSOURCES} omGetPageSize.h omMallocSystem.h gmalloc.c dlmalloc.h dlmalloc.c \
    89         omMmap.c gmalloc.c omTables.c ommalloc.c pmalloc.h pmalloc.c
     92        omMmap.c gmalloc.c omTables.c pmalloc.h pmalloc.c omalloc.c omalloc_debug.c  \
     93        $(TESTSOURCES) omtTestAlloc.c
    9094
    9195ASO_OBJS := $(ASO_SOURCES:.aso.cc=.aso)
    9296
    93 DISTFILES=$(SOURCES) $(HEADERS) makeheader.pl Makefile.in \
    94            omConfig.h.in
     97DISTFILES=$(SOURCES) $(HEADERS) omtTest.h makeheader.pl Makefile.in \
     98           omConfig.h.in configure.in mkinstalldirs install-sh configure
     99
    95100##
    96101## Build Targets
    97102##
    98 
    99 %.o: %.c omConfig.h omTables.inc
     103%.o: %.c omConfig.h omTables.h omalloc.h omTables.inc
    100104        ${CC} ${CFLAGS} ${CPPFLAGS} ${DEFS} -c $<
     105
     106%.o_ndebug: %.c omConfig.h omTables.h omalloc.h omTables.inc
     107        ${CC} ${CFLAGS} ${CPPFLAGS} ${DEFS} -DOM_NDEBUG -c $< -o $@
    101108
    102109%.aso.o: %.aso.cc mmtables.inc
     
    107114        ./$< > $@
    108115
    109 all:    lib libomalloc.h libg
     116all:    libomalloc.a libomalloc_ndebug.a omalloc.h omalloc.o omalloc_debug.o
    110117
    111118lib: libomalloc.a
     
    116123        $(RANLIB) $@
    117124
    118 libomalloc.h: $(HEADERS)
    119         $(PERL) makeheader.pl omAlloc.h $@
     125libomalloc_ndebug.a: $(OBJS_NDEBUG) Makefile omConfig.h
     126        rm -f $@
     127        $(AR) cr $@ $(OBJS_NDEBUG)
     128        $(RANLIB) $@
     129
     130omalloc.h: $(HEADERS)
     131        $(PERL) makeheader.pl -a omAlloc.h $@
     132
     133omalloc.o: omalloc.c
     134        ${CC} ${CFLAGS} ${CPPFLAGS} ${DEFS} -DOM_NDEBUG -c $< -o $@
     135
     136omalloc_debug.o: omalloc_debug.c
     137        ${CC} ${CFLAGS} ${CPPFLAGS} ${DEFS} -c $< -o $@
    120138
    121139omTables.inc: omTables
    122140        ./omTables > $@
    123141
    124 omTables: omAlloc.h omMalloc.h omConfig.h omTables.c
     142omTables.h: omTables
     143        ./omTables 1 >$@
     144
     145omTables: omAllocPrivate.h omConfig.h omTables.c
    125146        ${CC} ${CFLAGS} ${CPPFLAGS} ${DEFS} -DOM_GENERATE_INC omTables.c -o omTables
    126147
     
    138159        cp $(EXTERNAL_CONFIG_SOURCE) omExternalConfig.c
    139160endif
     161
    140162ifdef EXTERNAL_CONFIG_HEADER
    141 omExternalConfig.h: ${EXTERNAL_CONFIG_HEADER}
    142         rm -f omExternalConfig.h
    143         cp ${EXTERNAL_CONFIG_HEADER} omExternalConfig.h
     163omExternalConfig.h: $(EXTERNAL_CONFIG_HEADER)
     164        cp $(EXTERNAL_CONFIG_HEADER) omExternalConfig.h
     165omDerivedConfig.h: omExternalConfig.h
    144166endif
    145167
     
    166188## install targets
    167189##
    168 install: all
     190install: all libomalloc_p.a
    169191        $(MKINSTALLDIRS) $(libdir)
    170192        $(MKINSTALLDIRS) $(includedir)
    171193        $(INSTALL_DATA) libomalloc.a $(libdir)
    172194        $(RANLIB) $(libdir)/libomalloc.a
    173         $(INSTALL_DATA) libmalloc.h $(includedir)/omAlloc.h
     195        $(INSTALL_DATA) libomalloc_ndebug.a $(libdir)
     196        $(RANLIB) $(libdir)/libomalloc_ndebug.a
     197        $(INSTALL_DATA) libomalloc_p.a $(libdir)
     198        $(RANLIB) $(libdir)/libomalloc_p.a
     199        $(INSTALL_DATA) omalloc.o omalloc_debug.o $(libdir)
     200        $(INSTALL_DATA) omalloc.h omalloc.c $(includedir)
     201
    174202
    175203uninstall:
    176         rm -f $(includedir)/omAlloc.h $(libdir)/libomalloc.a
     204        rm -f $(includedir)/omalloc.h $(includedir)/omalloc.c
     205        rm -f $(libdir)/libomalloc.a $(libdir)/libomalloc_ndebug.a $(libdir)/libomalloc_p.a $(libdir)/omalloc.o $(libdir)/omalloc_debug.o
     206
     207##
     208## dist targets
     209##
     210dist: omalloc-$(VERSION).tgz
     211omalloc-$(VERSION).tgz: $(DISTFILES)
     212        rm -rf omalloc-$(VERSION)
     213        mkdir omalloc-$(VERSION)
     214        cp $(DISTFILES) omalloc-$(VERSION)
     215        tar czf omalloc-$(VERSION).tgz omalloc-$(VERSION)
    177216
    178217##
     
    180219##
    181220mostlyclean:
    182         -rm -f core *.d *.o *.og *.op *_d.c *.ob *.a depend *.out *.tgz omTables
    183         -rm -f omTest omTest_* libomalloc*
    184         -rm -f omMalloc.c omMalloc.h omExternalConfig.h omExternalConfig.c
     221        -rm -f core *.d *.o *.og *.op *_d.c *.ob *.a depend *.out *.tgz omTables *.o_ndebug *.gp *.gprof
     222        -rm -f omtTest omtTest_* libomalloc* *.bprof omtTest omtTest_*
     223        -rm -f omMalloc.c omExternalConfig.h omExternalConfig.c
    185224
    186225clean: mostlyclean
    187226
    188227distclean: clean
    189         -rm -f  *~ .\#*  stamp-h configure
     228        -rm -f  *~ .\#*  stamp-h configure omMalloc.h
     229        rm -rf omalloc-$(VERSION)
    190230        -rm -f omConfig.h Makefile TAGS* tags config.status config.cache config.log
    191231
     
    201241
    202242##
     243## check
     244##
     245
     246check: omtTest omtTest_ndebug
     247        ./omtTest
     248        ./omtTest_ndebug
     249
     250##
    203251## Below here is stuff for developpers
    204252#################################################################
     
    211259CCM             = gcc -MM -DGENERATE_DEPEND
    212260
    213 CFLAGSG         = -g -O -Wall -pipe
     261CFLAGSG         = -g -O -fno-inline-functions -Wall -pipe
    214262DEFSG           =  @DEFS@
    215263
    216264OBJG := $(CSOURCES:.c=.og) $(GSOURCES:.c=.og)
    217265
    218 %.og: %.c
     266%.og: %.c omConfig.h omTables.h omalloc.h
    219267        $(CCG) ${CFLAGSG} ${CPPFLAGS} ${DEFSG} -c $< -o $@
    220268
     
    228276
    229277##
    230 ## expnaded macros
    231 ##
    232 OBJD := $(CSOURCES:%.c=%_d.og)
    233 
    234 %_d.c : %.c omConfig.h
     278## expanded macros
     279##
     280OBJD := $(CSOURCES:%.c=%_d.og) $(GSOURCES:%.c=%_d.og)
     281
     282%_d.c : %.c omConfig.h omTables.h omalloc.h
    235283        $(CCG) -E -P $< | $(PERL) -p -e 's/;/;\n/g' | $(PERL) -p -e 's/\{/\n\{/g' | $(PERL) -p -e 's/\}/\n\}/g' > $@
    236284.PRECIOUS: %_d.c
     
    249297CCP             = gcc
    250298
    251 CFLAGSP         = -g -pg -O3 -a -pipe
     299CFLAGSP         = -g -pg -O3 -a -pipe 
    252300DEFSP           =  @DEFS@
    253301
     
    258306## Profile Targets
    259307##
    260 %.op: %.c
     308%.op: %.c omConfig.h omTables.h omalloc.h
    261309        $(CCP) ${CFLAGSP} ${CPPFLAGS} ${DEFSP} -c $< -o $@
    262310
     
    274322CCB             = gcc
    275323
    276 CFLAGSB         = -g -O3 -pipe
     324CFLAGSB         = -g -O3 -pipe 
    277325DEFSB           =  @DEFS@
    278326
     
    286334## Profile Targets
    287335##
    288 %.ob: %.c
     336%.ob: %.c omConfig.h omTables.h omalloc.h
    289337        $(CCB) ${CFLAGSB} ${CPPFLAGS} ${DEFSB} -c $< -o $@
    290338
     
    299347## Test program
    300348##
    301 
    302 omTest_d: libd omTest_d.c omTest.d
    303         $(CCG) ${CFLAGSG} ${CPPFLAGS} ${DEFSG} omTest_d.c -L. -lomalloc_d -o omTest_d
    304 
    305 omTest_g: libg omTest.c omTest.d
    306         $(CCG) ${CFLAGSG} ${CPPFLAGS} ${DEFSG} omTest.c -L. -lomalloc_g -o omTest_g
    307 
    308 
    309 omTest_p: libp omTest.c omTest.d
    310         $(CCP) ${CFLAGSP} ${CPPFLAGS} ${DEFSP} omTest.c -L. -lomalloc_p -o omTest_p
    311 
    312 omTest_b: libb omTest.c omTest.d
    313         $(CCB) ${CFLAGSB} ${CPPFLAGS} ${DEFSB} omTest.c /usr/lib/bmon.o -L. -lomalloc_b -o omTest_b
    314 
    315 omTest: lib omTest.c omTest.d
    316         $(CC) ${CFLAGS} ${CPPFLAGS} ${DEFS} omTest.c -L. -lomalloc -o omTest
    317 
    318 omTest_m: lib omTest.c omTest.d
    319         $(CC) ${CFLAGS} ${CPPFLAGS} ${DEFS} -DOM_TEST_MALLOC omTest.c -L. -lomalloc -o omTest_m
    320 
    321 ##
    322 ## tar and backup
    323 ##
    324 
    325 tar:
    326         tar czvf omalloc.tgz $(DISTFILES)
    327 
    328 backup: tar
    329         mcopy omalloc.tgz a:
     349TESTSOURCES     = omtTest.c omtTestReal.c omtTestDebug.c omtTestError.c
     350
     351TEST_D := $(TESTSOURCES:.c=_d.og)
     352omtTest_d: libd $(TEST_D)
     353        $(CCG) ${CFLAGSG} ${CPPFLAGS} ${DEFSG} $(TEST_D) -L. -lomalloc_d -o omtTest_d
     354
     355TEST_G := $(TESTSOURCES:.c=.og)
     356omtTest_g: libg $(TEST_G)
     357        $(CCG) ${CFLAGSG} ${CPPFLAGS} ${DEFSG} $(TEST_G) -L. -lomalloc_g -o omtTest_g
     358
     359TEST_P := $(TESTSOURCES:.c=.op)
     360omtTest_p: libp $(TEST_P)
     361        $(CCG) ${CFLAGSP} ${CPPFLAGS} ${DEFSP} $(TEST_P) -L. -lomalloc_p -o omtTest_p
     362
     363TEST_B := $(TESTSOURCES:.c=.ob)
     364omtTest_b: libb $(TEST_B)
     365        $(CCG) ${CFLAGSB} ${CPPFLAGS} ${DEFSB} $(TEST_B) -L. -lomalloc_b  /usr/lib/bmon.o -o omtTest_b
     366
     367TEST_O := $(TESTSOURCES:.c=.o)
     368omtTest: lib  $(TEST_O)
     369        $(CC) ${CFLAGS} ${CPPFLAGS} ${DEFS} $(TEST_O) -L. -lomalloc -o omtTest
     370
     371TEST_NDEBUG_O := $(TESTSOURCES:.c=.o_ndebug)
     372omtTest_ndebug: libomalloc_ndebug.a $(TEST_NDEBUG_O)
     373        $(CC) ${CFLAGS} ${CPPFLAGS} ${DEFS} $(TEST_NDEBUG_O) -DOM_NDEBUG -L. -lomalloc_ndebug -o omtTest_ndebug
     374
     375%.om : %.c omalloc.h
     376        $(CC) ${CFLAGS} ${CPPFLAGS} ${DEFS} -DOM_TEST_MALLOC -c $< -o $@
     377TEST_M := $(TESTSOURCES:.c=.om)
     378omtTest_m: lib $(TEST_M)
     379        $(CC) ${CFLAGS} ${CPPFLAGS} ${DEFS} -DOM_TEST_MALLOC $(TEST_M) -L. -lomalloc -o omtTest_m
     380
     381##
     382## backup
     383##
     384
     385backup: omalloc-$(VERSION).tgz
     386        mcopy -o omalloc-$(VERSION).tgz a:
    330387
    331388##
    332389## Dependencies
    333390##
    334 %.d: %.c omConfig.h Makefile
    335         echo $(@:.d=.og) $(@:.d=.od)  $(@:.d=.ob) $(@:.d=_d.c)" " \\ > $@
     391%.d: %.c omConfig.h Makefile omTables.h omTables.inc omalloc.h
     392        echo $(@:.d=.o_ndebug) $(@:.d=.og) $(@:.d=.od)  $(@:.d=.op) $(@:.d=.ob) $(@:.d=_d.c) $(@:.d=.om)" " \\ > $@
    336393        $(CCM) ${CPPFLAGS} ${DEFSG} $< >> $@
    337394
    338 depend:   omTest.d $(CSOURCES:.c=.d) omConfig.h
     395depend:   $(CSOURCES:.c=.d) omConfig.h $(TESTSOURCES:.c=.d)
    339396        cat *.d >depend
    340397
  • omalloc/configure.in

    recf4ca6 r3df5b10  
    44dnl Author:  obachman@mathematik.uni-kl.de (Olaf Bachmann)
    55dnl Created: 11/99
    6 dnl Version: $Id: configure.in,v 1.3 2000-05-31 13:34:29 obachman Exp $
     6dnl Version: $Id: configure.in,v 1.4 2000-08-14 12:08:42 obachman Exp $
    77dnl lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll
    88
    99AC_INIT(omAlloc.c)
     10
     11VERSION=0.9.5
     12AC_SUBST(VERSION)
    1013
    1114dnl lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll
     
    1316dnl
    1417AC_ARG_WITH(
    15   external_config_h,
     18  external-config_h,
    1619  [ --with-external-config_h=HEADER_FILE
    1720                    use HEADER_FILE for external configuration])
    1821AC_ARG_WITH(
    19   external_config_c,
     22  external-config_c,
    2023  [ --with-external-config_c=C_FILE
    2124                    use C_FILE for external implementations])
     
    2528                    which malloc to use, default: dlmalloc ])
    2629AC_ARG_WITH(
    27   external_malloc_h,
     30  external-malloc_h,
    2831  [ --with-external-malloc-h=HEADER_FILE
    2932                    use HEADER_FILE for external malloc declaration])
    3033AC_ARG_WITH(
    31   external_malloc_c,
    32   [ --with-external-malloc-h=C_FILE
     34  external-malloc_c,
     35  [ --with-external-malloc-c=C_FILE
    3336                    use C_FILE for external malloc implementation])
    3437AC_ARG_WITH(
     
    3740                    how to get page-aligned memory, default: use first possible])
    3841AC_ARG_WITH(
    39   provide_malloc,
    40   [ --with-provide-malloc 
    41                     provide ANSI-C conforming malloc/calloc/realloc/free])
    42 AC_ARG_WITH(
    43   emulate_omalloc,
     42  provide-malloc,
     43  [ --with-provide-malloc=yes|debug|malloc
     44                    provide normal|debug|underlying malloc ANSI-C conforming
     45                    versions of malloc|calloc|realloc|free])
     46AC_ARG_WITH(
     47  emulate-omalloc,
    4448  [ --with-emulate-omalloc
    4549                    provide only omallocs interface, but do not use its features])
     
    5054                    default: if possible sloppy, else strict])
    5155AC_ARG_WITH(
    52   dense_bins,
     56  dense-bins,
    5357  [ --with-dense-bins  use dense bin distribution])
    5458AC_ARG_WITH(
    5559  inline,
    5660  [ --without-inline   do not inline])
     61AC_ARG_WITH(
     62  debug,
     63  [ --without-debug    disable all debugging facilities])
     64AC_ARG_WITH(
     65  track,
     66  [ --without-track    disable debug tracking functionality])
     67AC_ARG_WITH(
     68  track-fl,
     69  [ --with-track-fl    track file and line numbers])
     70AC_ARG_WITH(
     71  track-return,
     72  [ --with-track-return track return addresses])
     73AC_ARG_WITH(
     74  track-backtrace,
     75  [ --with-track-backtrace track stack backtraces])
    5776AC_ARG_WITH(
    5877  internal_debug,
    5978  [ --with-internal-debug       
    6079                       turn on internal debugging])
    61 AC_ARG_WITH(
    62   mtrack,
    63   [ --without-mtrack   disable backtrace and memory track])
    64 AC_ARG_WITH(
    65   frame_addr_func,
    66   [ --with_frame_addr_func=FUNC
    67                     use FUNC as function for determening frame addr
    68                     default: __bultin_frame_address])
    69 AC_ARG_WITH(
    70   return_addr_func,
    71   [ --with_return_addr_func=FUNC
    72                     use FUNC as function for determening return addr
    73                     default: __bultin_return_address])
    74 
    75 dnl lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll
    76 dnl get singuname
    77 dnl
    78 AC_MSG_CHECKING(singuname)
    79 AC_CACHE_VAL(ac_cv_singuname,
    80 ac_cv_singuname="unknown"
    81 if test -r "singuname.sh"; then
    82   if (/bin/sh singuname.sh >/dev/null 2>&1) then
    83     ac_cv_singuname=`/bin/sh singuname.sh`
    84   fi
    85 fi
    86 if test "$ac_cv_singuname" = unknown && test -r "../singuname.sh"; then
    87   if (/bin/sh ../singuname.sh >/dev/null 2>&1) then
    88     ac_cv_singuname=`/bin/sh ../singuname.sh`
    89   fi
    90 fi
    91 )
    92 AC_MSG_RESULT($ac_cv_singuname)
    93 if test "$ac_cv_singuname" = unknown; then
    94   AC_MSG_WARN(Unknown architecture: Check singuname.sh)
    95   ac_cv_singuname="unknown"
    96 fi
    97 
    9880dnl lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll
    9981dnl compiler/make  config
    10082dnl
    101 if test "${CFLAGS+set}" != set; then
    102   CFLAGS="-O"
    103   ac_cflags_set=no
    104 fi
     83dnl I'm not sure why I did this
     84dnl if test "${CFLAGS+set}" != set; then
     85dnl  CFLAGS="-O"
     86dnl  ac_cflags_set=no
     87dnl fi
     88
    10589AC_PROG_MAKE_SET
    10690AC_PROG_CC
    10791AC_PROG_CPP
     92AC_PROG_RANLIB
     93AC_PROG_LN_S
     94AC_PROG_INSTALL
    10895AC_C_CONST
    10996AC_C_INLINE
    110 AC_PROG_RANLIB
    111 AC_PROG_LN_S
    11297
    11398dnl lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll
     
    229214    AC_DEFINE(OM_HAVE_EXTERNAL_CONFIG_H)
    230215    EXTERNAL_CONFIG_HEADER=${with_external_config_h}
     216    rm -f omExternalConfig.h
     217    cp ${with_external_config_h} omExternalConfig.h
    231218fi
    232219if test "${with_external_config_c+set}" = set; then
     
    248235if test "${with_malloc}" = system; then
    249236  OM_MALLOC_HEADER=omMallocSystem.h
    250   if test "${with_provide_malloc}" = yes; then
    251     AC_MSG_ERROR("can not provide malloc for --with_malloc=system")
     237  if test "${with_provide_malloc}" = yes || test "${with_provide_malloc}" = debug; then
     238    AC_MSG_ERROR("can not provide malloc for --with-malloc=system")
    252239  fi
    253240elif test "${with_malloc}" = gmalloc; then
     
    261248    AC_MSG_ERROR(need --with_external_malloc_h for external malloc)
    262249  fi
    263   if test "${with_provide_malloc}" = yes; then
     250  if test "${with_provide_malloc}" = yes || test "${with_provide_malloc}" = debug; then
    264251    AC_MSG_ERROR("can not provide malloc for --with_malloc=external")
    265252  fi
     
    307294AC_DEFINE(OM_MALLOC_PROVIDES_SIZEOF_ADDR)
    308295fi
    309 
    310 if test "${with_provide_malloc}" = yes; then
    311   AC_DEFINE(OM_PROVIDE_MALLOC)
     296 
     297if test "${with_provide_malloc}" = malloc; then
     298   AC_DEFINE(OM_PROVIDE_MALLOC, 3)
     299elif test "${with_provide_malloc}" = debug; then
     300   AC_DEFINE(OM_PROVIDE_MALLOC, 2)
     301elif test "${with_provide_malloc}" = yes; then
     302  AC_DEFINE(OM_PROVIDE_MALLOC, 1)
     303else
     304  AC_DEFINE(OM_PROVIDE_MALLOC, 0)
    312305fi
    313306
     
    406399dnl debug and inline
    407400dnl
     401AC_MSG_CHECKING(whether to disable debugging)
     402if test "$with_debug" != no; then
     403AC_MSG_RESULT(no)
     404else
     405AC_MSG_RESULT(yes)
     406AC_DEFINE(OM_NDEBUG)
     407with_track=no
     408fi
     409
     410AC_MSG_CHECKING(whether to have tracking debug functionality)
     411if test "$with_track" != no; then
     412AC_MSG_RESULT(yes)
     413AC_DEFINE(OM_HAVE_TRACK)
     414else
     415AC_MSG_RESULT(no)
     416fi
     417
    408418AC_MSG_CHECKING(whether to use internal debug)
    409419if test "$with_internal_debug" = yes; then
     
    430440
    431441dnl lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll
    432 dnl mtrack business
    433 dnl
    434 if test "$with_mtrack" != no; then
    435 # get function for return address
    436 if test "${with_return_addr_func+set}" = set; then
    437 if test "${with_return_addr_func}" != no; then
    438   ac_cv_return_addr_func=$with_return_addr_func
    439 fi
    440 else
    441 if test "${GCC}" = yes; then
    442   ac_cv_return_addr_func="__builtin_return_address"
    443 fi
    444 fi
    445 
    446 # test this function
    447 if test "${ac_cv_return_addr_func+set}" = set; then
    448 AC_DEFINE_UNQUOTED(OM_RETURN_ADDR, $ac_cv_return_addr_func)
    449 # first, check whether return addr works
    450 AC_MSG_CHECKING(whether $ac_cv_return_addr_func works)
    451 AC_CACHE_VAL(ac_cv_return_addr_func_works,
     442dnl backtrace business
     443dnl
     444AC_MSG_CHECKING(whether GET_RET_ADDR works)
     445AC_CACHE_VAL(ac_cv_get_return_addr_works,
    452446AC_TRY_RUN([
     447#include "omReturn.h"
    453448int test_return_addr()
    454449{
    455    if (OM_RETURN_ADDR(1)  != 0 && OM_RETURN_ADDR(0) != 0 &&
    456        OM_RETURN_ADDR(1) != OM_RETURN_ADDR(0)) return 0;
    457    return 1;
    458 }
    459 
     450  char* f;
     451  GET_RET_ADDR(f);
     452  return (int) f;
     453}
    460454int main()
    461455{
    462    return test_return_addr();
    463 }
    464 ], ac_cv_return_addr_func_works=yes, 
    465    ac_cv_return_addr_func_works=no,
    466    ac_cv_return_addr_func_works=no))
    467 AC_MSG_RESULT($ac_cv_return_addr_func_works)
    468 
    469 if test "$ac_cv_return_addr_func_works" = yes; then
    470 AC_DEFINE(OM_RETURN_ADDR_WORKS)
    471 # check whether return addr works with rvalues
    472 AC_MSG_CHECKING(whether $ac_cv_return_addr_func takes rvalues)
    473 AC_CACHE_VAL(ac_cv_return_addr_func_rvalue,
     456   exit(! test_return_addr());
     457}
     458], ac_cv_get_return_addr_works=yes, 
     459   ac_cv_get_return_addr_works=no,
     460   ac_cv_get_return_addr_works=no))
     461AC_MSG_RESULT($ac_cv_get_return_addr_works)
     462if test "$ac_cv_get_return_addr_works" = yes; then
     463AC_DEFINE(OM_GET_RETURN_ADDR_WORKS)
     464fi
     465
     466AC_MSG_CHECKING(whether omGetBackTrace works)
     467AC_CACHE_VAL(ac_cv_get_backtrace_works,
    474468AC_TRY_RUN([
    475 int test_return_addr(int f1, int f2)
    476 {
    477    if (OM_RETURN_ADDR(f1)  != 0 && OM_RETURN_ADDR(f0) != 0 &&
    478        OM_RETURN_ADDR(f1) != OM_RETURN_ADDR(f0)) return 0;
    479    return 1;
    480 }
    481 
     469#include "omGetBackTrace.c"
     470#include <stdio.h>
     471int test_backtrace()
     472{
     473  void* bt;
     474  int i = omGetBackTrace(&bt, 0, 10);
     475  return i;
     476}
    482477int main()
    483478{
    484    return test_return_addr(1, 0);
    485 }
    486 ], ac_cv_return_addr_func_rvalue=yes, 
    487    ac_cv_return_addr_func_rvalue=no,
    488    ac_cv_return_addr_func_rvalue=no))
    489 AC_MSG_RESULT($ac_cv_return_addr_func_rvalue)
    490 if test "$ac_cv_return_addr_func_rvalue" = yes; then
    491   AC_DEFINE_UNQUOTED(OM_RETURN_ADDR_RVALUE)
    492 fi
    493 fi # "$ac_cv_return_addr_func_works" = yes;
    494 fi # "${ac_cv_return_addr_func+set}" = set;
    495 
    496 # get function for frame address
    497 if test "${with_frame_addr_func+set}" = set; then
    498 if test "${with_frame_addr_func}" != no; then
    499   ac_cv_frame_addr_func=$with_frame_addr_func
    500 fi
    501 else
    502 if test "${GCC}" = yes; then
    503   ac_cv_frame_addr_func="__builtin_frame_address"
    504 fi
    505 fi
    506 
    507 # test this function
    508 if test "${ac_cv_frame_addr_func+set}" = set; then
    509 AC_DEFINE_UNQUOTED(OM_FRAME_ADDR, $ac_cv_frame_addr_func)
    510 # first, check whether frame addr works
    511 AC_MSG_CHECKING(whether $ac_cv_frame_addr_func works)
    512 AC_CACHE_VAL(ac_cv_frame_addr_func_works,
    513 AC_TRY_RUN([
    514 int test_frame_addr()
    515 {
    516    if (OM_FRAME_ADDR(1)  != 0 && OM_FRAME_ADDR(0) != 0 &&
    517        OM_FRAME_ADDR(1) != OM_FRAME_ADDR(0)) return 0;
    518    return 1;
    519 }
    520 
    521 int main()
    522 {
    523    return test_frame_addr();
    524 }
    525 ], ac_cv_frame_addr_func_works=yes, 
    526    ac_cv_frame_addr_func_works=no,
    527    ac_cv_frame_addr_func_works=no))
    528 AC_MSG_RESULT($ac_cv_frame_addr_func_works)
    529 
    530 if test "$ac_cv_frame_addr_func_works" = yes; then
    531 AC_DEFINE(OM_FRAME_ADDR_WORKS)
    532 # check whether frame addr works with rvalues
    533 AC_MSG_CHECKING(whether $ac_cv_frame_addr_func takes rvalues)
    534 AC_CACHE_VAL(ac_cv_frame_addr_func_rvalue,
    535 AC_TRY_RUN([
    536 int test_frame_addr(int f1, int f2)
    537 {
    538    if (OM_FRAME_ADDR(f1)  != 0 && OM_FRAME_ADDR(f0) != 0 &&
    539        OM_FRAME_ADDR(f1) != OM_FRAME_ADDR(f0)) return 0;
    540    return 1;
    541 }
    542 
    543 int main()
    544 {
    545    return test_frame_addr(1, 0);
    546 }
    547 ], ac_cv_frame_addr_func_rvalue=yes, 
    548    ac_cv_frame_addr_func_rvalue=no,
    549    ac_cv_frame_addr_func_rvalue=no))
    550 AC_MSG_RESULT($ac_cv_frame_addr_func_rvalue)
    551 if test "$ac_cv_frame_addr_func_rvalue" = yes; then
    552   AC_DEFINE_UNQUOTED(OM_FRAME_ADDR_RVALUE)
    553 fi
    554 fi # "$ac_cv_frame_addr_func_works" = yes;
    555 fi # "${ac_cv_frame_addr_func+set}" = set;
    556 
    557 fi  # "$with_mtrack" != no;
    558 
    559 
    560 dnl lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll
    561 dnl last but not least, let's be smart about CFLAGS
    562 dnl
    563 if test "${GCC}" = yes && test "$ac_cflags_set" = no ; then
    564   CFLAGS="-pipe -Wall -O3 -fomit-frame-pointer"
    565 fi
    566 
     479   int i;       
     480   omInitGetBackTrace();
     481   i = test_backtrace();
     482   if (i == 1) exit(0);
     483   else exit(i+1);
     484}
     485], ac_cv_get_backtrace_works=yes, 
     486   ac_cv_get_backtrace_works=no,
     487   ac_cv_get_backtrace_works=no))
     488AC_MSG_RESULT($ac_cv_get_backtrace_works)
     489if test "$ac_cv_get_backtrace_works" = yes; then
     490AC_DEFINE(OM_GET_BACKTRACE_WORKS)
     491fi
     492
     493AC_MSG_CHECKING(whether to track return addresses)
     494if test "$with_track_return" = no || test "$ac_cv_get_return_addr_works" = no; then
     495  with_track_return=no
     496else
     497  AC_DEFINE(OM_TRACK_RETURN)
     498  with_track_return=yes
     499fi
     500AC_MSG_RESULT($with_track_return)
     501
     502AC_MSG_CHECKING(whether to track files and line numbers)
     503if test "$with_track_fl" = no && test "$with_track_return" = no; then
     504  with_track_fl=yes
     505fi
     506if test "${with_track_fl+set}" != set; then
     507  if test "$with_track_return" = yes; then
     508    with_track_fl=no
     509  else
     510    with_track_fl=yes
     511  fi
     512fi
     513AC_MSG_RESULT($with_track_fl)
     514if test "$with_track_fl" = yes; then
     515  AC_DEFINE(OM_TRACK_FILE_LINE)
     516fi
     517
     518AC_MSG_CHECKING(whether to track stack backtraces)
     519if test "$with_track" != no && test "$ac_cv_get_backtrace_works" = yes && test "$with_track_backtrace" != no; then
     520  with_track_backtrace=yes
     521  AC_DEFINE(OM_TRACK_BACKTRACE)
     522else
     523  with_track_backtrace=no
     524fi
     525AC_MSG_RESULT($with_track_backtrace)
     526 
     527dnl lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll
     528dnl wrap it up
     529dnl
    567530AC_CONFIG_HEADER(omConfig.h omMalloc.h:${OM_MALLOC_HEADER})
     531
    568532
    569533AC_OUTPUT(Makefile, \
  • omalloc/makeheader.pl

    recf4ca6 r3df5b10  
    11#!/usr/bin/perl
    2 # $Id: makeheader.pl,v 1.1.1.1 1999-11-18 17:45:53 obachman Exp $
     2# $Id: makeheader.pl,v 1.2 2000-08-14 12:08:43 obachman Exp $
    33#
    44# makeheader.pl - generate a header file out of several header file (ver 1.2).
     
    2020if ( ( $#ARGV == -1 ) || ( $ARGV[0] =~ /-help|-\?/ ) ) {
    2121    die "
    22 usage: makeheader [-?] {-I<includedir>} <templatefile> <outfile>
     22usage: makeheader [-?] [-a] {-I<includedir>} <templatefile> <outfile>
    2323
    2424This is makeheader, a header file generation tool.
     
    3232#include \"<includefile>\"
    3333
    34 in <templatefile>.
     34in <templatefile>. If <includefile> contains sections marked with
     35/*BEGINPRIVATE*/ and /*ENDPRIVATE*/ then these sections are excluded.
    3536
    3637If you use the alternate form
     
    4142only sections marked with /*BEGINPUBLIC*/ and /*ENDPUBLIC*/ are
    4243pasted from <includefile> into <outfile>.
     44
     45Option -a is equivalent to a /*MAKEHEADER*/ marking of all
     46#include \"<includefile>\" of <templatefile>.
    4347
    4448<includefile> is looked up in all <includedir>s, then in the
     
    5458        $includes .= ( $1 ? $1 : shift ) . ":";
    5559    }
     60    $all = 1 if /^-a/;
    5661}
    5762$includes .= ".:";
     
    7681
    7782while( <INFILE> ) {
    78     if ( /^\/\*MAKEHEADER(.*)\*\/$/ ) {
    79         # check whether we have to read public part only
    80         if ( $1 eq " PUBLIC ONLY" ) {
     83    if ( /^\/\*MAKEHEADER(.*)\*\/$/ || ($all && /^\#include \"(.*)\"$/)) {
     84        if (/^\/\*MAKEHEADER(.*)\*\/$/)
     85        {
     86          # check whether we have to read public part only
     87          if ( $1 eq " PUBLIC ONLY" ) {
    8188            $public_only = 1;
    82         } else {
     89          } else {
    8390            $public_only = 0;
     91          }
     92          $_ = <INFILE>; chop;
    8493        }
    8594
    8695        # get name of file to include
    87         $_ = <INFILE>; chop;
    8896        if ( /^\#include \"(.*)\"$/ ) {
    8997            $inclfile = $1;
     
    110118        } else {
    111119            # just paste contents into output
    112             while ( <INCLFILE> ) { print OUTFILE $_; }
     120            while ( <INCLFILE> )
     121            {
     122              $exclude = 1, next if /^\/\*BEGINPRIVATE\*\/\s*$/;
     123              $exclude = 0, next if /^\/\*ENDPRIVATE\*\/\s*$/;
     124              print OUTFILE $_ unless $exclude;
     125            }
    113126        }
    114127        close INCLFILE;
  • omalloc/omAlloc.c

    recf4ca6 r3df5b10  
    44 *  Author:  obachman@mathematik.uni-kl.de (Olaf Bachmann)
    55 *  Created: 11/99
    6  *  Version: $Id: omAlloc.c,v 1.5 2000-05-31 13:34:29 obachman Exp $
     6 *  Version: $Id: omAlloc.c,v 1.6 2000-08-14 12:08:43 obachman Exp $
    77 *******************************************************************/
    88#ifndef OM_ALLOC_C
     
    1010
    1111#include "omAlloc.h"
    12 
    1312/*******************************************************************
    1413 * 
     
    1817
    1918omBinPage_t om_ZeroPage[] = {{0, NULL, NULL, NULL, NULL}};
    20 omBinPage_t om_CheckPage[] = {{0, NULL, NULL, NULL, NULL}};
    21 omBinPage_t om_LargePage[] = {{0, NULL, NULL, NULL, NULL}};
    22 omBin_t     om_LargeBin[] = {{om_LargePage, NULL, NULL, 0, 0, 0}};
    23 omBin_t     om_CheckBin[] = {{om_CheckPage, NULL, NULL, 0, 0, 0}};
    2419omSpecBin om_SpecBin = NULL;
    2520
    26 /*******************************************************************
    27  * 
    28  *  Definition of Func
    29  * 
    30  *******************************************************************/
    31 
    32 #define ALLOCBIN_FUNC_WRAPPER(func)             \
    33 void* omFunc##func (omBin bin)                  \
    34 {                                               \
    35   void* addr;                                   \
    36   __omType##func (void*, addr, bin);            \
    37   return addr;                                  \
    38 }
    39 
    40 #define REALLOCBIN_FUNC_WRAPPER(func)                               \
    41 void* omFunc##func (void* old_addr, omBin old_bin, omBin new_bin)   \
    42 {                                                                   \
    43   void* new_addr;                                                   \
    44   __omType##func (old_addr, old_bin, void*, new_addr, new_bin);     \
    45   return new_addr;                                                  \
    46 }
    47 
    48 #define ALLOCSIZE_FUNC_WRAPPER(func)            \
    49 void* omFunc##func (size_t size)                \
    50 {                                               \
    51   void* addr;                                   \
    52   __omType##func (void*, addr, size);           \
    53   return addr;                                  \
    54 }
    55 
    56 #define REALLOCSIZE_FUNC_WRAPPER(func)                                  \
    57 void* omFunc##func (void* old_addr, size_t old_size, size_t new_size)   \
    58 {                                                                       \
    59   void* new_addr;                                                       \
    60   __omType##func (old_addr, old_size, void*, new_addr, new_size);       \
    61   return new_addr;                                                      \
    62 }
    63 
    64 #define REALLOC_FUNC_WRAPPER(func)                      \
    65 void* omFunc##func (void* old_addr, size_t new_size)    \
    66 {                                                       \
    67   void* new_addr;                                       \
    68   __omType##func (old_addr, void*, new_addr, new_size); \
    69   return new_addr;                                      \
    70 }
    71 
    72 #define FREESIZE_FUNC_WRAPPER(func)             \
    73 void omFunc##func (void* addr, size_t size)     \
    74 {                                               \
    75   __om##func (addr, size);                      \
    76 }
    77 
    78 #define FREEBIN_FUNC_WRAPPER(func)             \
    79 void omFunc##func (void* addr, omBin bin)     \
    80 {                                               \
    81   __om##func (addr, bin);                      \
    82 }
    83 
    84 #define FREE_FUNC_WRAPPER(func)                 \
    85 void omFunc##func (void* addr)                  \
    86 {                                               \
    87   __om##func (addr);                            \
    88 }
    89 
    90 ALLOCBIN_FUNC_WRAPPER(AllocBin)
    91 ALLOCBIN_FUNC_WRAPPER(Alloc0Bin)
    92 REALLOCBIN_FUNC_WRAPPER(ReallocBin)
    93 REALLOCBIN_FUNC_WRAPPER(Realloc0Bin)
    94 FREEBIN_FUNC_WRAPPER(FreeBin)
    95 
    96 ALLOCSIZE_FUNC_WRAPPER(Alloc)
    97 ALLOCSIZE_FUNC_WRAPPER(Alloc0)
    98 REALLOCSIZE_FUNC_WRAPPER(ReallocSize)
    99 REALLOCSIZE_FUNC_WRAPPER(Realloc0Size)
    100 REALLOC_FUNC_WRAPPER(Realloc)
    101 REALLOC_FUNC_WRAPPER(Realloc0)
    102 FREESIZE_FUNC_WRAPPER(FreeSize)
    103 FREE_FUNC_WRAPPER(Free)
    104 
    105 #ifdef OM_ALIGNMENT_NEEDS_WORK
    106 ALLOCSIZE_FUNC_WRAPPER(AllocAligned)
    107 ALLOCSIZE_FUNC_WRAPPER(Alloc0Aligned)
    108 REALLOCSIZE_FUNC_WRAPPER(ReallocAlignedSize)
    109 REALLOCSIZE_FUNC_WRAPPER(Realloc0AlignedSize)
    110 REALLOC_FUNC_WRAPPER(ReallocAligned)
    111 REALLOC_FUNC_WRAPPER(Realloc0Aligned)
    112 #endif /* OM_ALIGNMENT_NEEDS_WORK */
     21#include "omTables.inc"
     22
    11323
    11424/*******************************************************************
     
    215125  {
    216126    omAssume(bin->last_page != NULL);
     127    /* Set this to zero, but preserve the first bit,
     128       so that tracking works */
     129#ifdef OM_HAVE_TRACK
     130    bin->current_page->used_blocks &= (1 << (BIT_SIZEOF_LONG -1));
     131#else   
    217132    bin->current_page->used_blocks = 0;
     133#endif
    218134  }
    219135
     
    238154
    239155
    240 /* page->used_blocks == 0, so, either free page or reallocate to
     156/* page->used_blocks <= 0, so, either free page or reallocate to
    241157   the right of current_page */
    242158/*
     
    253169  omAssume(page->used_blocks <= 0);
    254170
    255 #ifdef OM_HAVE_DEBUG
    256   if (page->used_blocks < 0) omDebugFree(addr, 0);
     171#ifdef OM_HAVE_TRACK
     172  if (page->used_blocks < 0)
     173  {
     174    omFreeTrackAddr(addr);
     175    return;
     176  }
    257177#endif
    258178   
     
    267187    else
    268188      omFreeBinPages(page, - bin->max_blocks);
    269 #ifdef OM_HAVE_DEBUG
     189#ifdef OM_HAVE_TRACK
    270190    om_JustFreedPage = page;
    271191#endif   
     
    297217/*******************************************************************
    298218 * 
    299  *  ANSI-C malloc-conforming functions
    300  * 
    301  *******************************************************************/
    302 
    303 #include "ommalloc.c"
    304 
    305 #ifdef OM_PROVIDE_MALLOC
    306 #undef malloc
    307 #undef realloc
    308 #undef free
    309 #undef calloc
    310 #define ommallocFunc malloc
    311 #define omreallocFunc realloc
    312 #define omfreeFunc free
    313 #define omcallocFunc calloc
    314 #include "ommalloc.c"
    315 #endif
    316 
     219 *  DoRealloc
     220 * 
     221 *******************************************************************/
     222#ifdef OM_ALIGNMNET_NEEDS_WORK
     223#define DO_ZERO(flag) (flag & 1)
     224#else
     225#define DO_ZERO(flag)    flag
     226#endif
     227
     228void* omDoRealloc(void* old_addr, size_t new_size, int flag)
     229{
     230  void* new_addr;
     231 
     232  if (!omIsBinPageAddr(old_addr) && new_size > OM_MAX_BLOCK_SIZE)
     233  {
     234    if (DO_ZERO(flag))
     235      return omRealloc0Large(old_addr, new_size);
     236    else
     237      return omReallocLarge(old_addr, new_size);
     238  }
     239  else
     240  {
     241    size_t old_size = omSizeOfAddr(old_addr);
     242    size_t min_size;
     243   
     244    omAssume(OM_IS_ALIGNED(old_addr));
     245   
     246#ifdef OM_ALIGNMENT_NEEDS_WORK
     247    if (flag & 2)
     248      __omTypeAllocAligned(void*, new_addr, new_size);
     249    else
     250#endif
     251      __omTypeAlloc(void*, new_addr, new_size);
     252   
     253    new_size = omSizeOfAddr(new_addr);
     254    min_size = (old_size < new_size ? old_size : new_size);
     255    omMemcpyW(new_addr, old_addr, min_size >> LOG_SIZEOF_LONG);
     256   
     257    if (DO_ZERO(flag) && (new_size > old_size))
     258      omMemsetW((void*) new_addr + min_size, 0, (new_size - old_size) >> LOG_SIZEOF_LONG);
     259 
     260    __omFreeSize(old_addr, old_size);
     261
     262    return new_addr;
     263  }
     264}
    317265
    318266#endif /* OM_ALLOC_C */
  • omalloc/omAlloc.h

    recf4ca6 r3df5b10  
    44 *  Author:  obachman@mathematik.uni-kl.de (Olaf Bachmann)
    55 *  Created: 11/99
    6  *  Version: $Id: omAlloc.h,v 1.3 2000-05-31 13:34:30 obachman Exp $
     6 *  Version: $Id: omAlloc.h,v 1.4 2000-08-14 12:08:44 obachman Exp $
    77 *******************************************************************/
    88#ifndef OM_ALLOC_H
     
    1313#include <string.h>
    1414
     15#ifdef __cplusplus
     16extern "C" {
     17#endif
     18
    1519#include "omConfig.h"
     20#include "omDerivedConfig.h"
     21#include "omError.h"
    1622#include "omStructs.h"
    17 #include "omError.h"
    1823#include "omAllocDecl.h"
     24#include "omInlineDecl.h"
    1925#include "omBin.h"
    20 #include "omCheck.h"
    2126#include "omMemOps.h"
    2227#include "omList.h"
    23 #include "omTrack.h"
     28#include "omFindExec.h"
     29#include "omGetBackTrace.h"
     30#include "omRet2Info.h"
    2431#include "omStats.h"
    2532#include "omOpts.h"
    2633#include "omBinPage.h"
    2734#include "omAllocSystem.h"
     35#include "omTables.h"
    2836#include "omAllocPrivate.h"
     37#include "omDebug.h"
    2938#include "omInline.h"
    3039
     40#ifdef __cplusplus
     41}
     42#endif
     43
    3144#endif /* OM_ALLOC_H */
  • omalloc/omConfig.h.in

    recf4ca6 r3df5b10  
    55 *  Author:  obachman (Olaf Bachmann)
    66 *  Created: 11/99
    7  *  Version: $Id: omConfig.h.in,v 1.3 2000-05-31 13:34:31 obachman Exp $
     7 *  Version: $Id: omConfig.h.in,v 1.4 2000-08-14 12:08:44 obachman Exp $
    88 *******************************************************************/
    99#ifndef OM_CONFIG_H
     
    1313 * Defines which are set by configure
    1414 ******************************************************************/
     15/* define if you provide an external config file to be included
     16   by omDefaultConfig.h */
     17#ifndef OM_HAVE_EXTERNAL_CONFIG_H
     18#define OM_HAVE_EXTERNAL_CONFIG_H
     19#endif
    1520/* define if you can inline */
    1621#ifndef OM_INLINE
     
    2833#ifndef OM_INLINE_LOCAL
    2934#define OM_INLINE_LOCAL static
     35#endif
     36/* defint to nothing if you do not understand const */
     37#ifndef const
     38#undef const
    3039#endif
    3140/* define to the name of addr2line program, undef otherwise */
     
    7786#define HAVE_SYS_MMAN_H
    7887#endif
    79 /* define to func which returns ith return addr */
    80 #ifndef OM_RETURN_ADDR
    81 #undef OM_RETURN_ADDR
     88/* define if GET_RETURN_ADDR works */
     89#ifndef OM_GET_RETURN_ADDR_WORK
     90#undef OM_GET_RETURN_ADDR_WORKS
    8291#endif
    83 /* define to func which returns ith frame addr */
    84 #ifndef OM_FRAME_ADDR
    85 #undef OM_FRAME_ADDR
    86 #endif
    87 /* define if OM_RETURN_ADDR actually works */
    88 #ifndef OM_RETURN_ADDR_WORKS
    89 #undef OM_RETURN_ADDR_WORKS
    90 #endif
    91 /* define if OM_FRAME_ADDR actually works */
    92 #ifndef OM_FRAME_ADDR_WORKS
    93 #undef OM_FRAME_ADDR_WORKS
    94 #endif
    95 /* define if OM_RETURN_ADDR actually rvalue */
    96 #ifndef OM_RETURN_ADDR_RVALUE
    97 #undef OM_RETURN_ADDR_RVALUE
    98 #endif
    99 /* define if OM_FRAME_ADDR actually rvalue */
    100 #ifndef OM_FRAME_ADDR_RVALUE
    101 #undef OM_FRAME_ADDR_RVALUE
     92/* define if GET_RETURN_ADDR works */
     93#ifndef OM_GET_BACKTRACE_WORK
     94#undef OM_GET_BACKTRACE_WORKS
    10295#endif
    10396/* Define sizeof(long) */
     
    133126#undef OM_MALLOC_PROVIDES_SIZEOF_ADDR
    134127#endif
    135 #ifndef OM_PROVIDE_MALLOC
    136 /* define if you want omalloc to provide ANSI-C conforming
    137    malloc/calloc/realloc/free funcs */
    138 #undef OM_PROVIDE_MALLOC
    139 #endif
    140128#ifndef OM_EMULATE_OMALLOC
    141129/* define if you only want to emulate omalloc, but not actually use it */
     
    154142#undef OM_HAVE_DENSE_BIN_DISTRIBUTION
    155143#endif
     144/* define to disable all debugging stuff */
     145#ifndef OM_NDEBUG
     146#undef OM_NDEBUG
     147#endif
     148/* define to enable debug tracking */
     149#ifndef OM_HAVE_TRACK
     150#undef OM_HAVE_TRACK
     151#endif
     152/* define to enable tracking of files/line numbers */
     153#ifndef OM_TRACK_FILE_LINE
     154#undef OM_TRACK_FILE_LINE
     155#endif
     156/* define to enable tracking of return addresses */
     157#ifndef OM_TRACK_RETURN
     158#undef OM_TRACK_RETURN
     159#endif
     160/* define to enable tracking of stack backtraces */
     161#ifndef OM_TRACK_BACKTRACE
     162#undef OM_TRACK_BACKTRACE
     163#endif
    156164/* define to enable internal debugging */
    157165#ifndef OM_INTERNAL_DEBUG
    158166#undef OM_INTERNAL_DEBUG
    159167#endif
    160 
    161 /*******************************************************************
    162  * Defines which are not set by configure
    163  ******************************************************************/
    164 #ifndef SIZEOF_VOIDP
    165 /* configure makes sure that SIZEOF_VOIDP == SIZEOF_LONG */
    166 #define SIZEOF_VOIDP SIZEOF_LONG
     168/* define to -1/0/1/2/3 if you want omalloc to provide
     169   "underlying malloc"/no/normal/debug ANSI-C conforming 
     170   malloc/calloc/realloc/free funcs */
     171#ifndef OM_PROVIDE_MALLOC
     172#define OM_PROVIDE_MALLOC 0
    167173#endif
    168 
    169 /* SIZEOF_VOIDP == 8 || SIZEOF_VOIDP == 4 checked by configure */
    170 #if SIZEOF_VOIDP == 8
    171 #define LOG_SIZEOF_LONG  3
    172 #define LOG_SIZEOF_VOIDP 3
    173 #define LOG_BIT_SIZEOF_LONG 6
    174 #else
    175 #define LOG_SIZEOF_LONG  2
    176 #define LOG_SIZEOF_VOIDP 2
    177 #define LOG_BIT_SIZEOF_LONG 5
    178 #endif
    179 
    180 /* SIZEOF_SYSTEM_PAGE == 4096 || SIZEOF_SYSTEM_PAGE == 8192 checked by configure */
    181 #if SIZEOF_SYSTEM_PAGE == 8192
    182 #define LOG_BIT_SIZEOF_SYSTEM_PAGE 13
    183 #else
    184 #define LOG_BIT_SIZEOF_SYSTEM_PAGE 12
    185 #endif
    186 
    187 #ifndef CHAR_BIT
    188 #define CHAR_BIT 8
    189 #endif
    190 
    191 #define BIT_SIZEOF_LONG (CHAR_BIT << LOG_SIZEOF_LONG)
    192 
    193 #ifdef OM_ALIGN_8
    194 #define SIZEOF_OM_ALIGNMENT 8
    195 #define SIZEOF_OM_ALIGNMENT_1 7
    196 #define LOG_SIZEOF_OM_ALIGNMENT 3
    197 #define SIZEOF_STRICT_ALIGNMENT 8
    198 #else
    199 #define SIZEOF_OM_ALIGNMENT 4
    200 #define SIZEOF_OM_ALIGNMENT_1 3
    201 #define LOG_SIZEOF_OM_ALIGNMENT 2
    202 #ifdef OM_ALIGNMENT_NEEDS_WORK
    203 #define SIZEOF_STRICT_ALIGNMENT 8
    204 #else
    205 #define SIZEOF_STRICT_ALIGNMENT 4
    206 #endif
    207 #endif
    208 
    209 #define OM_ALIGN_SIZE(size) \
    210    (((size) + SIZEOF_OM_ALIGNMENT_1) & (~SIZEOF_OM_ALIGNMENT_1))
    211 
    212 #define OM_STRICT_ALIGN_SIZE(size)                                          \
    213    (((size) + SIZEOF_STRICT_ALIGNMENT - 1) & (~ (SIZEOF_STRICT_ALIGNMENT - 1)))
    214 
    215 
    216 /* define to enable assume */
    217 #ifndef HAVE_OM_ASSUME
    218 #if !defined(NDEBUG) || defined(OM_INTERNAL_DEBUG)
    219 #define HAVE_OM_ASSUME
    220 #endif
    221 #endif
    222 
    223 /* set to 0 to disable aso memory mamagent */
    224 #ifndef HAVE_ASO
    225 #define HAVE_ASO 1
    226 #endif
    227 #if defined(HAVE_ASO) && HAVE_ASO == 1
    228 /* define to enable ASO debugging */
    229 #undef ASO_DEBUG
    230 #endif
    231 
    232 #ifndef NULL
    233 #define NULL ((void*)0)
    234 #endif
    235 
    236174#endif /* OM_CONFIG_H  */
  • omalloc/omDebug.c

    recf4ca6 r3df5b10  
    11/*******************************************************************
    2  *  File:    omDebug.c
    3  *  Purpose: implementation of main omDebug functions
     2 *  File:    omTest.c
     3 *  Purpose: implementation of main omTest functions
    44 *  Author:  obachman@mathematik.uni-kl.de (Olaf Bachmann)
    5  *  Created: 11/99
    6  *  Version: $Id: omDebug.c,v 1.3 2000-05-31 13:34:31 obachman Exp $
     5 *  Created: 7/00
     6 *  Version: $Id: omDebug.c,v 1.4 2000-08-14 12:08:44 obachman Exp $
    77 *******************************************************************/
     8#include <limits.h>
    89#include "omConfig.h"
    9 
    10 #ifdef OM_HAVE_DEBUG
    11 
    1210#include "omAlloc.h"
    13 
     11#include "omDebug.h"
     12#include "omReturn.h"
     13
     14#ifndef OM_NDEBUG
    1415/*******************************************************************
    1516 * 
     
    1718 * 
    1819 *******************************************************************/
    19 /* number of bytes for padding before addr: needs to > 0 and a multiple of OM_SIZEOF_STRICT_ALIGNMENT */
    20 #ifndef OM_SIZEOF_FRONT_PADDING
    21 #define OM_SIZEOF_FRONT_PADDING SIZEOF_STRICT_ALIGNMENT
    22 #endif
    23 /* number of bytes for padding after addr: needs to be a multiple of OM_SIZEOF_STRICT_ALIGNMENT */
    24 #ifndef OM_SIZEOF_BACK_PADDING
    25 #define OM_SIZEOF_BACK_PADDING SIZEOF_STRICT_ALIGNMENT
    26 #endif
    27 
    28 struct omDebugAddr_s;
    29 typedef struct omDebugAddr_s omDebugAddr_t;
    30 typedef omDebugAddr_t * omDebugAddr;
    31 
    32 struct omDebugAddr_s
    33 {
    34   char              debug;
    35   char              check;
    36   short             alloc_line;
    37   char*             alloc_file;
    38   /* debug > 1 */
    39   void*             alloc_frames[OM_MAX_FRAMES];
    40   /* debug > 2 */
    41   void*             size_bin;
    42   omFlags_t         flags;
    43   omDebugCount_t    debugs;
    44   /* debug > 3 */
    45   short             free_line;
    46   char*             free_file;
    47   /* debug > 4 */
    48   void*             free_frames[OM_MAX_FRAMES];
    49 };
    50 
    51 /* this is only needed to determine SIZEOF_DEBUG_ADDR_i */
    52 static struct omDebugAddr_s debug_addr;
    53 #define OM_SIZEOF_DEBUG_ADDR_1  OM_STRICT_ALIGN_SIZE(((void*)&debug_addr.alloc_frames-(void*)&debug_addr))
    54 #define OM_SIZEOF_DEBUG_ADDR_2  OM_STRICT_ALIGN_SIZE(((void*)&debug_addr.size_bin-(void*)&debug_addr))
    55 #define OM_SIZEOF_DEBUG_ADDR_3  (OM_STRICT_ALIGN_SIZE(((void*)&debug_addr.free_line-(void*)&debug_addr))+SIZEOF_FRONT_PADDING)
    56 #define OM_SIZEOF_DEBUG_ADDR_4  (OM_STRICT_ALIGN_SIZE(((void*)&debug_addr.free_frames-(void*)&debug_addr))+SIZEOF_FRONT_PADDING)
    57 #define OM_SIZEOF_DEBUG_ADDR_5  OM_SIZEOF_DEBUG_ADDR
    58 #define OM_SIZEOF_DEBUG_ADDR    (OM_STRICT_ALIGN_SIZE(sizeof(struct omDebugAddr_s)) + SIZEOF_FRONT_PADDING)
    59 
    60 OM_INLINE_LOCAL omDebugAddr omAddr_2_DebugAddr(void* addr)
    61 {
    62   void* page = omGetPageOfAddr(addr);
    63   size_t size = omGetTopeBinOfPage((omBinPage) page)->sizeW << LOG_SIZEOF_LONG;
    64   page += SIZEOF_OM_BIN_PAGE_HEADER;
    65   return (omDebugAddr) (page + (void*) (((unsigned long)addr - (unsigned long)page) / size)*size);
    66 }
    67 
    68 #define OM_BIN_FLAG     1           /* size_bin is bin, if set, else size */
    69 #define OM_USED_FLAG    2           /* is in use, if set */
    70 #define OM_FREE_FLAG    4           /* had been freed, if set */
    71 #define OM_STATIC_FLAG  8           /* if set, considered to be static, i.e. never be freed */
    72 #define OM_MAX_FLAG             64  /* define, but never use it */
    73 #define SET_FLAG(var, flag)     (var |= (flag))
    74 #define CLEAR_FLAG(var, flag)   (var &= ~(flag))
    75 #define IS_FLAG_SET(var, flag)  (var & (flag))
    76 
    77 
    78 #define _omDebugAddr_2_OutAddr(d_addr)   (((void*) d_addr) + OM_SIZEOF_DEBUG_ADDR_HEADER)
    79 #define _omOutAddr_2_DebugAddr(addr)     ((omDebugAddr) ((void*) addr - OM_SIZEOF_DEBUG_ADDR_HEADER))
    80 #define _omOutSize_2_DebugSize(size)     (size + OM_SIZEOF_DEBUG_ADDR_HEADER + OM_SIZEOF_BACK_PADDING)
    81 #define _omDebugSize_2_OutSize(size)     (size - OM_SIZEOF_DEBUG_ADDR_HEADER - OM_SIZEOF_BACK_PADDING)
    82 
     20
     21static void* __omDebugAlloc(void* size_bin, omTrackFlags_t  flags, char track, OM_FLR_DECL);
     22static void* __omDebugRealloc(void* old_addr, void* old_size_bin, void* new_size_bin,
     23                              omError_t old_status, omTrackFlags_t  old_flags,
     24                              omTrackFlags_t  new_flags,
     25                              char track, OM_FLR_DECL);
     26static void __omDebugFree(void* addr, void* size_bin, omTrackFlags_t  flags, OM_FLR_DECL);
     27
     28void* om_KeptAddr = NULL;
     29static unsigned long om_NumberOfKeptAddrs = 0;
     30static void* om_LastKeptAddr = NULL;
     31
     32/*******************************************************************
     33 * 
     34 * Test routines
     35 * 
     36 *******************************************************************/
     37#define OM_CLFL check_level OM_FL_KOMMA OM_FL
     38omError_t omTestAddrBin(void* addr, omBin bin, int check_level)
     39{
     40  return _omDebugAddr(addr,bin,OM_FBIN,OM_CLFL);
     41}
     42omError_t omTestAddrSize(void* addr, size_t size, int check_level)
     43{
     44  return _omDebugAddr(addr,(void*)(size),OM_FSIZE,OM_CLFL);
     45}
     46omError_t omTestAddr(void* addr, int check_level)
     47{
     48  return _omDebugAddr(addr,NULL, 0, OM_CLFL);
     49}
     50omError_t omtestAddrSize(void* addr, size_t size, int check_level)
     51{
     52  return _omDebugAddr(addr,(void*)(size),OM_FSIZE|OM_FSLOPPY,OM_CLFL);
     53}
     54omError_t omtestAddr(void* addr, int check_level)
     55{
     56  return _omDebugAddr(addr,NULL, OM_FSLOPPY, OM_CLFL);
     57}
     58
     59omError_t omTestAddrAlignedBin(void* addr, omBin bin, int check_level)
     60{
     61  return _omDebugAddr(addr,bin,OM_FBIN|OM_FALIGN,OM_CLFL);
     62}
     63omError_t omTestAddrAlignedSize(void* addr, size_t size, int check_level)
     64{
     65  return _omDebugAddr(addr,(void*)(size),OM_FSIZE|OM_FALIGN,OM_CLFL);
     66}
     67omError_t omTestAddrAligned(void* addr, int check_level)
     68{
     69  return _omDebugAddr(addr,NULL, OM_FALIGN, OM_CLFL);
     70}
     71omError_t omtestAddrAlignedSize(void* addr, size_t size, int check_level)
     72{
     73  return _omDebugAddr(addr,(void*)(size),OM_FSIZE|OM_FSLOPPY|OM_FALIGN,OM_CLFL);
     74}
     75omError_t omtestAddrAligned(void* addr, int check_level)
     76{
     77  return _omDebugAddr(addr,NULL, OM_FSLOPPY|OM_FALIGN, OM_CLFL);
     78}
     79
     80omError_t omTestBin(omBin bin, int check_level)
     81{
     82  return _omDebugBin(bin, OM_CLFL);
     83}
     84omError_t omTestMemory(int check_level)
     85{
     86  return _omDebugMemory(OM_CLFL);
     87}
     88
     89#undef MAX
     90#define MAX(a,b) (a > b ? a : b)
     91/*******************************************************************
     92 * 
     93 * First level _omDebug alloc/free routines: call respective checks and dispatch
     94 * to routines which do the actual work
     95 * 
     96 *******************************************************************/
     97void* _omDebugAlloc(void* size_bin, omTrackFlags_t flags, OM_CTFL_DECL)
     98{
     99  void* addr;
     100  OM_R_DEF;
     101  check = MAX(check, om_Opts.MinCheck);
     102  track = MAX(track, om_Opts.MinTrack);
     103
     104  if (check)
     105  {
     106    if (check > 1)
     107    {
     108      if (flags & OM_FBIN)
     109        (void) _omCheckBin((omBin)size_bin, 1, check-1, omError_MemoryCorrupted, OM_FLR_VAL);
     110      else if (check > 2)
     111      {
     112        omAssume(flags & OM_FSIZE);
     113        (void) _omCheckMemory(check-2, omError_MemoryCorrupted, OM_FLR_VAL);
     114      }
     115    }
     116    if (size_bin == NULL && ! (flags & OM_FSLOPPY))
     117    {
     118      omReportError(omError_NullSizeAlloc, omError_NoError, OM_FLR_VAL, "");
     119    }
     120  }
     121
     122  addr = __omDebugAlloc(size_bin, flags, track, OM_FLR_VAL);
     123 
    83124#ifdef OM_INTERNAL_DEBUG
    84 static void* omDebugAddr_2_OutAddr(void* d_addr) {return _omDebugAddr_2_OutAddr(d_addr);}
    85 static void* omOutAddr_2_DebugAddr(void* addr)   {return _omOutAddr_2_DebugAddr(addr);}
    86 static size_t omOutSize_2_DebugSize(size_t size) {return _omOutSize_2_DebugSize(size);}
    87 static size_t omDebugSize_2_OutSize(size_t size) {return _omOutSize_2_DebugSize(size);}
    88 #else
    89 #define omDebugAddr_2_OutAddr   _omDebugAddr_2_OutAddr
    90 #define omOutAddr_2_DebugAddr   _omOutAddr_2_DebugAddr
    91 #define omOutSize_2_DebugSize   _omOutSize_2_DebugSize
    92 #define omDebugSize_2_OutSize   _omDebugSize_2_OutSize
    93 #endif
    94 
    95 static void* om_Frames[OM_MAX_FRAMES];
    96 
     125  (void) _omCheckAddr(addr, size_bin,flags|OM_FUSED,check, omError_InternalBug, OM_FLR);
     126#endif
     127
     128  return addr;
     129}
     130
     131
     132void* _omDebugRealloc(void* old_addr, void* old_size_bin, void* new_size_bin,
     133                      omTrackFlags_t old_flags, omTrackFlags_t new_flags, OM_CTFL_DECL)
     134{
     135  void* new_addr = NULL;
     136  omError_t status = omError_NoError;
     137  OM_R_DEF;
     138  check = MAX(check, om_Opts.MinCheck);
     139  track = MAX(track, om_Opts.MinTrack);
     140 
     141  if (check)
     142  {
     143    status = _omCheckAddr(old_addr, old_size_bin, old_flags|OM_FUSED, check, omError_NoError, OM_FLR_VAL);
     144
     145    if (status == omError_NoError && check > 1 && new_flags & OM_FBIN)
     146      status = omDoCheckBin((omBin)new_size_bin, 1, check-1, omError_MemoryCorrupted, OM_FLR_VAL);
     147   
     148    if (new_size_bin == NULL && !(new_flags & OM_FSLOPPY))
     149    {
     150      omReportError(omError_NullSizeAlloc, omError_NoError, OM_FLR_VAL, "");
     151      new_size_bin = (void*) 1;
     152    }
     153  }
     154 
     155  new_addr = __omDebugRealloc(old_addr, old_size_bin, new_size_bin,
     156                              status, old_flags, new_flags, track, OM_FLR_VAL);
     157#ifdef OM_INTERNAL_DEBUG
     158  if (status == omError_NoError)
     159    (void) _omCheckAddr(new_addr, new_size_bin,new_flags|OM_FUSED,check, omError_InternalBug, OM_FLR);
     160#endif
     161
     162  return new_addr;
     163}
     164
     165void _omDebugFree(void* addr, void* size_bin,
     166                  omTrackFlags_t flags, OM_CFL_DECL)
     167{
     168  OM_R_DEF;
     169  check = MAX(check, om_Opts.MinCheck);
     170  if (check && _omCheckAddr(addr, size_bin, flags|OM_FUSED, check, omError_NoError, OM_FLR_VAL)) return;
     171 
     172  __omDebugFree(addr,size_bin,flags, OM_FLR_VAL);
     173 
     174#ifdef OM_INTERNAL_DEBUG
     175  if (flags & OM_FBIN)
     176    (void) _omCheckBin((omBin)size_bin, 1, check-1,omError_InternalBug, OM_FLR);
     177  else
     178    (void) _omCheckMemory(check-2,omError_InternalBug,OM_FLR);
     179#endif
     180}
     181
     182void* _omDebugMemDup(void* addr, omTrackFlags_t flags, OM_CTFL_DECL)
     183{
     184  void* ret;
     185  size_t sizeW;
     186  OM_R_DEF;
     187
     188  check = MAX(check, om_Opts.MinCheck);
     189  track = MAX(track, om_Opts.MinTrack);
     190
     191  if (check & _omCheckAddr(addr, 0, OM_FUSED, check, omError_NoError, OM_FLR_VAL))
     192  {
     193    return NULL;
     194  }
     195  else
     196  {
     197    sizeW = omSizeWOfAddr(addr);
     198  }
     199
     200  ret = __omDebugAlloc((void*) (sizeW << LOG_SIZEOF_LONG), OM_FSIZE | flags, track, OM_FLR_VAL);
     201  omMemcpyW(ret, addr, sizeW);
     202
     203#ifdef OM_INTERNAL_DEBUG
     204  (void) _omCheckAddr(ret, (void*) (sizeW << LOG_SIZEOF_LONG),OM_FUSED|OM_FSIZE,
     205                     check, omError_InternalBug, OM_FLR);
     206#endif
     207  return ret;
     208}
     209
     210char* _omDebugStrDup(const char* addr, OM_TFL_DECL)
     211{
     212  unsigned long size, i=0;
     213  char* ret;
     214  OM_R_DEF;
     215
     216  if (addr == NULL)
     217  {
     218    omReportAddrError(omError_NotString, omError_NoError, addr, 0, 0, OM_FLR_VAL, "NULL String");
     219    return NULL;
     220  }
     221  track = MAX(track, om_Opts.MinTrack);
     222
     223  if (omIsBinPageAddr(addr))
     224  {
     225    size = omSizeOfAddr(addr);
     226  }
     227  else
     228  {
     229    size = ULONG_MAX;
     230  }
     231
     232  while (addr[i] != '\0' && i < size) i++;
     233  if (i == size)
     234  {
     235    omReportAddrError(omError_NotString, omError_NoError, addr, 0, 0, OM_FLR_VAL, "Not 0 terminated");
     236    i = size-1;
     237  }
     238  ret = __omDebugAlloc((void*)i+1, OM_FSIZE, track, OM_FLR_VAL);
     239  memcpy(ret, addr, i);
     240  ret[i] = '\0';
     241
     242#ifdef OM_INTERNAL_DEBUG
     243  (void) _omCheckAddr(ret, i+1,OM_FUSED|OM_FSIZE,om_Opts.MinCheck, omError_InternalBug, OM_FLR);
     244#endif
     245  return ret;
     246}
     247
     248omError_t _omDebugAddr(void* addr, void* bin_size, omTrackFlags_t flags, OM_CFL_DECL)
     249{
     250  OM_R_DEF;
     251  return _omCheckAddr(addr, bin_size,
     252                      OM_FUSED|flags,MAX(check,om_Opts.MinCheck),omError_NoError,OM_FLR_VAL);
     253}
     254omError_t _omDebugMemory(OM_CFL_DECL)
     255{
     256  OM_R_DEF;
     257  return _omCheckMemory(MAX(check, om_Opts.MinCheck), omError_NoError,OM_FLR_VAL);
     258}
     259omError_t _omDebugBin(omBin bin, OM_CFL_DECL)
     260{
     261  OM_R_DEF;
     262  return _omCheckBin(bin, 1, MAX(check, om_Opts.MinCheck), omError_NoError,OM_FLR_VAL);
     263}
     264 
    97265/*******************************************************************
    98266 * 
    99  * Public routines --they are just dispatcher to equivalent first-level,
    100  * i.e.,  _om*  routines
     267 * Second level _omDebug alloc/free routines: do the actual work
    101268 * 
    102269 *******************************************************************/
    103 
    104 void* omTestAllocBin(omBin bin, char check, char debug, char* file, int line)
    105 {
    106   return _omTestAlloc(bin,
    107                       OM_BIN_FLAGS,MAX(check,om_Opts.MinCheck),MAX(debug,om_Opts.MinDebug),f,l,OM_DEBUG_RETURN_ADDR);
    108 }
    109 void* omTestAlloc0Bin(omBin bin, char check, char debug, char* file, int line)
    110 {
    111   return _omTestAlloc(bin,
    112                       OM_BIN_FLAG|OM_ZERO_FLAG,MAX(check,om_Opts.MinCheck),MAX(debug,om_Opts.MinDebug),f,l,OM_DEBUG_RETURN_ADDR);
    113 }
    114 void* omTestReallocBin(void* old_addr, omBin old_bin, omBin new_bin, char check, char debug, char* file, int line)
    115 {
    116   return _omTestRealloc(old_addr, old_bin, new_bin,
    117                         OM_BIN_FLAG,OM_BIN_FLAG,MAX(check,om_Opts.MinCheck),MAX(debug,om_Opts.MinDebug),f,l,OM_DEBUG_RETURN_ADDR);
    118 }   
    119 void* omTestRealloc0Bin(void* old_addr, omBin old_bin, omBin new_bin, char check, char debug, char* file, int line)
    120 {
    121   return _omTestRealloc(old_addr, old_bin, new_bin,
    122                         OM_BIN_FLAG,OM_BIN_FLAG|OM_ZERO_FLAG,MAX(check,om_Opts.MinCheck),MAX(debug,om_Opts.MinDebug),f,l,OM_DEBUG_RETURN_ADDR);
    123 }
    124 void omTestFreeBin(void* addr, omBin bin, char check, char* file, int line)
    125 {
    126   _omTestFree(addr, bin,
    127               OM_BIN_FLAG,MAX(check,om_Opts.MinCheck),f,l,OM_DEBUG_RETURN_ADDR);
    128 }
    129 
    130 void* omTestAlloc(size_t size, char check, char debug, char* file, int line)
    131 {
    132   return _omTestAlloc(size,
    133                       OM_SIZE_FLAG,MAX(check,om_Opts.MinCheck),MAX(debug,om_Opts.MinDebug),f,l,OM_DEBUG_RETURN_ADDR);
    134 }
    135 void* omTestAlloc0(size_t size, char check, char debug, char* file, int line)
    136 {
    137   return _omTestAlloc(size,
    138                       OM_SIZE_FLAG|OM_ZERO_FLAG, MAX(check,om_Opts.MinCheck),MAX(debug,om_Opts.MinDebug),f,l,OM_DEBUG_RETURN_ADDR);
    139 }
    140 void* omTestAllocAligned(size_t size, char check, char debug, char* file, int line)
    141 {
    142   return _omTestAlloc(size,
    143                       OM_SIZE_FLAG|OM_ALIGNED_FLAG,MAX(check,om_Opts.MinCheck),MAX(debug,om_Opts.MinDebug),f,l,OM_DEBUG_RETURN_ADDR);
    144 }
    145 void* omTestAlloc0Aligned(size_t size, char check, char debug, char* file, int line)
    146 {
    147   return _omTestAlloc(size,
    148                       OM_SIZE_FLAG|OM_ALIGNED_FLAG|OM_ZERO_FLAG,MAX(check,om_Opts.MinCheck),MAX(debug,om_Opts.MinDebug),f,l,OM_DEBUG_RETURN_ADDR);
    149 }
    150 
    151 void* omTestRealloc(void* addr, size_t new_size, char check, char debug, char* file, int line)
    152 {
    153   return _omTestRealloc(addr, NULL, new_size,
    154                         0,OM_SIZE_FLAG,MAX(check,om_Opts.MinCheck),MAX(debug,om_Opts.MinDebug),f,l,OM_DEBUG_RETURN_ADDR);
    155 }
    156 void* omTestRealloc0(void* addr, size_t new_size, char check, char debug, char* file, int line)
    157 {
    158   return _omTestRealloc(addr, NULL, new_size,
    159                         0, OM_SIZE_FLAG|OM_ZERO_FLAG, MAX(check,om_Opts.MinCheck),MAX(debug,om_Opts.MinDebug),f,l,OM_DEBUG_RETURN_ADDR);
    160 }
    161 void* omTestReallocAligned(void* addr, size_t new_size, char check, char debug, char* file, int line)
    162 {
    163   return _omTestRealloc(addr, NULL, new_size,
    164                         0,OM_SIZE_FLAG|OM_ALIGNED_FLAG,MAX(check,om_Opts.MinCheck),MAX(debug,om_Opts.MinDebug),f,l,OM_DEBUG_RETURN_ADDR);
    165 }
    166 void* omTestRealloc0Aligned(void* addr, size_t new_size, char check, char debug, char* file, int line)
    167 {
    168   return _omTestRealloc(addr, NULL, new_size,
    169                         0,OM_SIZE_FLAG|OM_ZERO_FLAG|OM_ALIGNED_FLAG,MAX(check,om_Opts.MinCheck),MAX(debug,om_Opts.MinDebug),f,l,OM_DEBUG_RETURN_ADDR,OM_REALLOC0_ALIGNED);
    170 }
    171 
    172 void* omTestReallocSize(void* addr, size_t old_size, size_t new_size, char check, char debug, char* file, int line)
    173 {
    174   return _omTestRealloc(addr, old_size, new_size,
    175                         OM_SIZE_FLAG,OM_SIZE_FLAG,MAX(check,om_Opts.MinCheck),MAX(debug,om_Opts.MinDebug),f,l,OM_DEBUG_RETURN_ADDR,OM_REALLOC_SIZE);
    176 }
    177 void* omTestRealloc0Size(void* addr, size_t old_size, size_t new_size, char check, char debug, char* file, int line)
    178 {
    179   return _omTestRealloc(addr, old_size, new_size,
    180                         OM_SIZE_FLAG,OM_SIZE_FLAG|OM_ZERO_FLAG,MAX(check,om_Opts.MinCheck),MAX(debug,om_Opts.MinDebug),f,l,OM_DEBUG_RETURN_ADDR,OM_REALLOC0_SIZE);
    181 }
    182 void* omTestReallocAlignedSize(void* addr, size_t old_size, size_t new_size, char check, char debug, char* file, int line)
    183 {
    184   return _omTestRealloc(addr, old_size, new_size,
    185                         OM_SIZE_FLAG,OM_SIZE_FLAG|OM_ALIGNED_FLAG,MAX(check,om_Opts.MinCheck),MAX(debug,om_Opts.MinDebug),f,l,OM_DEBUG_RETURN_ADDR,OM_REALLOC_ALIGNED_SIZE);
    186 }
    187 void* omTestRealloc0AlignedSize(void* addr, size_t old_size, size_t new_size, char check, char debug, char* file, int line)
    188 {
    189   return _omTestRealloc(addr, old_size, new_size,
    190                         OM_SIZE_FLAG,OM_SIZE_FLAG|OM_ZERO_FLAG|OM_ALIGNED_FLAG,MAX(check,om_Opts.MinCheck),MAX(debug,om_Opts.MinDebug),f,l,OM_DEBUG_RETURN_ADDR,OM_REALLOC0_ALIGNED_SIZE);
    191 }
    192 
    193 void omTestFreeSize(void* addr, size_t size, char check, char* file, int line)
    194 {
    195   _omTestFree(addr, size,
    196               OM_SIZE_FLAG, MAX(check,om_Opts.MinCheck),f,l,OM_DEBUG_RETURN_ADDR,OM_FREE_SIZE);
    197 }
    198 void omTestFree(void* addr, size_t size, char check, char* file, int line)
    199 {
    200   _omTestFree(addr, NULL,
    201               0, MAX(check,om_Opts.MinCheck),f,l,OM_DEBUG_RETURN_ADDR,OM_FREE);
    202 }
    203 
    204 omError_t omTestAddrBin(void* addr, omBin bin, char check, char* file, int line)
    205 {
    206   return _omTestAddr(addr, bin,
    207                      OM_USED_FLAG|OM_BIN_FLAG|OM_COUNT_FLAG, MAX(check,om_Opts.MinCheck),f,l,OM_DEBUG_RETURN_ADDR);
    208 }
    209 omError_t omTestAddrSize(void* addr, size_t size, char check, char* file, int line)
    210 {
    211   return _omTestAddr(addr, size,
    212                      OM_USED_FLAG|OM_SIZE_FLAG|OM_COUNT_FLAG, MAX(check,om_Opts.MinCheck),f,l,OM_DEBUG_RETURN_ADDR);
    213 }
    214 omError_t omTestAddr(void* adr, char check, char* file, int line)
    215 {
    216   return _omTestAddr(addr, NULL,
    217                      OM_USED_FLAG|OM_COUNT_FLAG,MAX(check,om_Opts.MinCheck),f,l,OM_DEBUG_RETURN_ADDR);
    218 }
    219 omError_t omTestAlignedAddrBin(void* addr, omBin bin, char check, char* file, int line)
    220 {
    221   return _omTestAddr(addr, bin,
    222                      OM_USED_FLAG|OM_BIN_FLAG|OM_ALIGNED_FLAG|OM_COUNT_FLAG, MAX(check,om_Opts.MinCheck),f,l,OM_DEBUG_RETURN_ADDR);
    223 }
    224 omError_t omTestAlignedAddr(void* adr, char check, char* file, int line)
    225 {
    226   return _omTestAddr(addr,  bin,
    227                      OM_USED_FLAG|OM_BIN_FLAG|OM_ALIGNED_FLAG|OM_COUNT_FLAG,MAX(check,om_Opts.MinCheck),f,l,OM_DEBUG_RETURN_ADDR);
    228 }
    229 omError_t omTestAlignedAddrSize(void* addr, size_t size, char check, char* file, int line)
    230 {
    231   return _omTestAddr(addr, bin,   
    232                      OM_USED_FLAG|OM_BIN_FLAG|OM_ALIGNED_FLAG|OM_COUNT_FLAG, MAX(check,om_Opts.MinCheck),f,l,OM_DEBUG_RETURN_ADDR);
    233 }
    234 
    235 /* TBC */
    236 omError_t omTestBin(omBin bin, char check, char* file, int line)
    237 {
    238   return omError_NoError;
    239 }
    240 omError_t omTestMemory(char check, char debug)
    241 {
    242   return omError_NoError;
    243 }
    244 
    245 /*******************************************************************
    246  * 
    247  * First level _om* routines: call respective checks and dispatch
    248  * to second level, i.e., __om routines
    249  * 
    250  *******************************************************************/
    251 static void* _omTestAlloc(void* bin_size,
    252                           int flags, char check, char debug,char* f,const int l,void* r)
    253 {
    254   void* addr;
    255  
    256   om_ReportError = omError_MemoryCorrupted;
    257   if (flags & BIN_FLAG)
    258     (void) _omTestBin((omBin)bin_size,check-1,f,l,r);
    259   else
    260     (void) _omTestMemory(check-2,f,l,r);
    261 
    262   addr = __omTestAlloc(bin_size, flags, debug, f, l, r);
    263  
    264 #ifdef OM_INTERNAL_DEBUG
    265   om_ReportError = omError_InternalBug;
    266   (void) _omTestAddr(addr, bin_size,flags|OM_USED_FLAGS,check, __FILE__,__LINE__,0);
    267 #endif
    268 
    269   om_ReportError = omError_NoError;
    270   return new_addr;
    271 }
    272 
    273 
    274 static void* _omTestRealloc(void* old_addr, void* old_bin_size, void* new_bin_size,
    275                             int old_flags, int new_flags, char check, char debug, char* f, const int l, void* r)
    276 {
    277   void* new_addr = NULL;
    278  
    279   (void*) _omTestAddr(old_addr, old_flags|OM_USED_FLAG, old_bin_size, check, f, l, r);
    280 
    281   new_addr = __omTestRealloc(old_addr, old_bin_size, new_bin_size,
    282                              old_flags, new_flags, debug, f, l, r);
    283 #ifdef OM_INTERNAL_DEBUG
    284   om_ReportError = omError_InternalBug;
    285   (void) _omTestAddr(new_addr, bin_size,flags|OM_USED_FLAGS,check, __FILE__,__LINE__,0);
    286   om_ReportError = omError_NoError;
    287 #endif
    288 
    289   return new_addr;
    290 }
    291 
    292 
    293 static void _omTestFree(void* addr, void* size_bin,
    294                         int flags, char check, char* f, const int l, void* r)
    295 {
    296   if (! _omTestAddr(addr, size_bin, flags, check, f, l, r))
    297     __omTestFree(addr,size_bin,flags,f,l,r);
    298  
    299 #ifdef OM_INTERNAL_DEBUG
    300   om_ReportError = omError_InternalBug;
    301   if (flags & BIN_FLAG)
    302     (void) _omTestBin((omBin)bin_size,check-1,__FILE__,__LINE__,0);
    303   else
    304     (void) _omTestMemory(check-2,__FILE__,__LINE__,0);
    305   om_ReportError = omError_NoError;
    306 #endif
    307 }
    308 
    309 
    310 static omError_t _omTestAddr(void* addr, void* size_bin,
    311                         int flags, char check, char* f, const int l, void* r)
    312 {
    313   if (check <= 0) return omError_NoError;
    314  
    315   if (!__omPrimitiveTestAddr(addr, size_bin, flags, f, l, r) ||
    316       !__omTestAddr(addr, size_bin, flags, f, l, r))
    317     return om_ErrorStatus;
    318  
    319   if (check > 1)
    320   {
    321     if (omIsDebugAddr(addr))
    322     {
    323       if (! _omTestBin(omGetBinOfAddr(addr), 1,check-1, f, l, r))
    324         return om_ErrorStatus;
    325       if (flags & OM_BIN_FLAG)
    326         return _omTestBin((omBin) bin_size, 0, check - 1, f, l, r);
    327     }
    328     else
    329     {
    330       if (omIsBinAddr(addr))
    331         return _omTestBin(omGetBinOfAddr(addr), 0, check-1, f, l, r);
    332       else if (check > 2)
    333         return _omTestMemory(check-2, f, l, r);
    334     }
    335   }
    336 
    337   return om_ErrorStatus = omError_NoError;
    338 }
    339 
    340 
    341 static omError_t _omTestBin(omBin bin, char is_debug_bin,
    342                             char check, char* f, const int l, void* r)
    343 {
    344   if (check <= 0) return omError_NoError;
    345  
    346   if (! __omPrimitiveTestBin(bin, f, l, r) ||
    347       ! __omTestBin(bin, is_debug_bin, check - 1, f, l, r))
    348     return om_ErrorStatus;
    349  
    350   if (check > 1)
    351     return _omTestMemory(check - 1, f, l, r);
    352 
    353   return om_ErrorStatus = omError_NoError;
    354 }
    355 
    356 
    357 static omError_t _omTestMemory(char check, char* f, const int l, void* r)
    358 {
    359   int i = 0;
    360   omSpecBin s_bin;
    361   void* addr;
    362  
    363   if (check <= 0) return omError_NoError;
    364  
    365   if (! omTestBinPagesReagions(check, f, l, r)) return om_ErrorStatus;
    366  
    367   for (i=0; i<= OM_MAX_BIN_INDEX; i++)
    368   {
    369     if (! __omTestBin(&om_StaticBin[i], 0, check - 1, f, l, r))
    370       return om_ErrorStatus;
    371   }
    372 
    373   for (i=0; i<= OM_MAX_DEBUG_BIN_INDEX; i++)
    374   {
    375     if (! __omTestBin(&om_StaticDebugBin[i], 1, check -1, f, l, r))
    376       return om_ErrorStatus;
    377   }
    378  
    379   s_bin = om_SpecBin;
    380   while (s_bin != NULL)
    381   {
    382     if (! __omTestBin(s_bin->bin, 0,check - 1, f, l, r))
    383       return om_ErrorStatus;
    384     s_bin = s_bin->next;
    385   }
    386  
    387 
    388   addr = FirstKeptDebugAddr;
    389  
    390   while (addr != NULL)
    391   {
    392     if (! __omTestAddr(addr, NULL, OM_FREE_FLAG, f, l, r))
    393       return om_ErrorStatus;
    394     addr = *((void**) addr);
    395   }
    396    
    397   return om_ErrorStatus = omError_NoError;
    398 }
    399 
    400 /*******************************************************************
    401  * 
    402  * Second level __om* routines: do the actual work, no checks,
    403  * assume that everything is ok
    404  * 
    405  *******************************************************************/
    406 static void* __omTestAlloc(void* bin_size,
    407                            int flags, char check, char debug,char* f,const int l,void* r)
     270static void* __omDebugAlloc(void* size_bin, omTrackFlags_t flags, char track, OM_FLR_DECL)
    408271{
    409272  void* o_addr;
    410   o_size = (flags & OM_BIN_FLAG ? ((omBin)bin)->sizeW << LOG_SIZEOF_LONG : (size_t) bin_size);
    411  
    412   if (debug > 0)
    413   {
    414     omDebugAddr d_addr;
    415     size_t d_size, o_size;
    416 
    417     d_size = omOutSize_2_DebugSize(o_size, debug);
    418    
    419     d_addr = omAllocDebugAddr(d_size);
    420    
    421     d_addr->next = (void*) -1;
    422     d_addr->debug = debug;
    423     d_addr->alloc_file = f;
    424     d_addr->alloc_line = l;
    425    
    426     if (debug > 1)
    427     {
    428       memset(&d_addr->alloc_frames, 0, OM_MAX_FRAMES*SIZEOF_VOIDP);
    429       omGetCurrentBackTrace(&d_addr->alloc_frames, OM_MAX_FRAMES, r);
    430      
    431       if (debug > 2)
    432       {
    433         char* pattern;
    434        
    435         d_addr->size_bin = size_bin;
    436         d_addr->flags = flags | USED_FLAG;
    437         d_addr->debugs = 0;
    438 
    439         if (debug > 3)
    440         {
    441           d_addr->free_line = -1;
    442           d_addr->free_file = (char*) -1;
    443          
    444           if (debug > 4)
    445             memset(&d_addr->free_frames, 0, OM_MAX_FRAMES*SIZEOF_VOIDP);
    446         }
    447 
    448         memset(omDebugAddr_2_FrontPattern(d_addr), OM_FRONT_PATTER, OM_SIZEOF_FRONT_PATTERN);
    449         memset(omDebugAddr_2_BackPattern(d_addr), OM_BACK_PATTER, omDebugAddr_2_BackPatternSize(d_addr));
    450       }
    451     }
    452     o_addr = omDebugAddr_2_OutAddr(d_addr);
    453     if (flags & OM_ZERO_FLAG) memset(o_addr, 0, o_size);
     273  size_t o_size = (flags & OM_FBIN ? ((omBin)size_bin)->sizeW << LOG_SIZEOF_LONG : (size_bin != NULL ? (size_t) size_bin: 1));
     274 
     275#ifdef OM_HAVE_TRACK
     276  if (track > 0)
     277  {
     278    o_addr = omAllocTrackAddr(size_bin, flags, track, OM_FLR_VAL);
    454279  }
    455280  else
    456   {
    457     if (flags & OM_BIN_FLAG)
    458     {
    459       omBin bin = (omBin) bin_size;
    460 
    461       if (flags & ZERO_FLAG)
    462         __omTypeAllo0cBin(void*, o_addr, bin);
     281#endif
     282  {
     283    if (flags & OM_FBIN)
     284    {
     285      omBin bin = (omBin) size_bin;
     286
     287      if (flags & OM_FZERO)
     288        __omTypeAlloc0Bin(void*, o_addr, bin);
    463289      else
    464290        __omTypeAllocBin(void*, o_addr, bin);
     
    466292    else
    467293    {
    468       if (flags & ZERO_FLAG)
     294      if (flags & OM_FZERO)
    469295      {
    470         if (flags & OM_ALIGNED_FLAG)
     296#ifdef OM_ALIGNMENT_NEEDS_WORK
     297        if (flags & OM_FALIGN)
    471298          __omTypeAlloc0Aligned(void*, o_addr, o_size);
    472299        else
     300#endif
    473301          __omTypeAlloc0(void*, o_addr, o_size);
    474302      }
    475303      else
    476304      {
    477         if (flags & OM_ALIGNED_FLAG)
     305#ifdef OM_ALIGNMENT_NEEDS_WORK
     306        if (flags & OM_FALIGN)
    478307          __omTypeAllocAligned(void*, o_addr, o_size);
    479308        else
     309#endif
    480310          __omTypeAlloc(void*, o_addr, o_size);
    481311      }
     
    483313  }
    484314 
    485   if (! (flags & OM_ZERO_FLAG)) memset(o_addr, OM_INIT_PATTERN, o_size);
    486  
    487315  return o_addr;
    488316}
    489 static omDebugAddr omAllocDebugAddr(size_t d_size)
    490 {
    491   omDebugAddr d_addr;
    492   omBin bin;
    493  
    494   if (d_size <= OM_MAX_DEBUG_BLOCK_SIZE)
    495     bin = omSize2DebugBin(d_size);
     317
     318static void* __omDebugRealloc(void* old_addr, void* old_size_bin, void* new_size_bin,
     319                              omError_t old_status, omTrackFlags_t  old_flags, omTrackFlags_t  new_flags,
     320                              char track, OM_FLR_DECL)
     321{
     322  void* new_addr;
     323  size_t old_size = (old_flags & OM_FSIZE ? (size_t) old_size_bin :
     324                     (omSizeOfAddr(old_addr)));
     325  size_t new_size;
     326                 
     327  omAssume(new_flags & OM_FSIZE || new_flags & OM_FBIN);
     328 
     329  if (old_addr == NULL || ((old_flags & OM_FSIZE) && old_size_bin == NULL))
     330  {
     331    new_addr = __omDebugAlloc(new_size_bin, new_flags, track, OM_FLR_VAL);
     332  }
     333  else if (om_Opts.Keep > 0 || track > 0 || omIsTrackAddr(old_addr) || old_status != omError_NoError)
     334  {
     335    new_addr = __omDebugAlloc(new_size_bin, new_flags, track, OM_FLR_VAL);
     336    new_size =  omSizeOfAddr(new_addr);
     337    old_size = omSizeOfAddr(old_addr);
     338   
     339    memcpy(new_addr, old_addr, (old_size < new_size ? old_size : new_size));
     340   
     341    if ((new_flags & OM_FZERO) && new_size > old_size)
     342      memset(new_addr + old_size, 0, new_size - old_size);
     343    if (old_status == omError_NoError) __omDebugFree(old_addr, old_size_bin, old_flags, OM_FLR_VAL);
     344  }
    496345  else
    497     bin = omGetSpecBin(d_size);
    498  
    499   __omTypeAllocBin(omTestAddr, d_addr, bin);
    500  
    501   omAssume(bin->current_page == omGetPageOfAddr(d_addr));
    502 
    503   omSetDebugOfUsedBlocks(bin->current_page->used_blocks);
    504  
    505   return d_addr;
    506 }
    507 
    508 
    509 static void* __omTestRealloc(void* old_addr, void* old_bin_size, void* new_bin_size,
    510                              int old_flags, int new_flags, char debug, char* f,const int l,void* r)
    511 {
    512   void* new_addr;
    513  
    514   if (om_Opts.Keep > 0 || debug > 0 || omIsDebugAddr(old_addr))
    515   {
    516     new_addr = __omTestAlloc(new_bin_size, new_flags, debug, f, l, r);
    517     memcpy(new_addr, old_addr, omSizeOfAddr(old_addr));
    518     __omTestFree(old_addr, old_bin_size, old_flags, f, l, r);
    519   }
    520   else
    521   {
    522     if (new_flags & OM_BIN_FLAG)
    523     {
    524       omBin new_bin = (omBin) new_bin_size;
    525       omBin old_bin = (omBin) old_bin_size;
     346  {
     347    if (new_flags & OM_FBIN)
     348    {
     349      omBin new_bin = (omBin) new_size_bin;
     350      omBin old_bin = (omBin) old_size_bin;
    526351     
    527       omAssume(old_flags & OM_BIN_FLAG);
    528       if (new_flags & OM_ZERO_FLAG)
     352      omAssume(old_flags & OM_FBIN);
     353      if (new_flags & OM_FZERO)
    529354        __omTypeRealloc0Bin(old_addr, old_bin, void*, new_addr, new_bin);
    530355      else
     
    533358    else
    534359    {
    535       size_t new_size = (size_t) new_bin_size;
    536       omAssume(!(new_flags & OM_BIN_FLAG) && !(old_flags & OM_BIN_FLAG));
     360      new_size = (size_t) new_size_bin;
     361      if (new_size == 0) new_size = 1;
     362      omAssume(!(new_flags & OM_FBIN) && !(old_flags & OM_FBIN));
    537363     
    538       if (flags & OM_SIZE_FLAG)
     364      if (old_flags & OM_FSIZE)
    539365      {
    540         size_t old_size = (size_t) old_bin_size;
     366        size_t old_size = (size_t) old_size_bin;
    541367       
    542         if (new_flags & OM_ZERO_FLAG)
     368        if (new_flags & OM_FZERO)
    543369        {
    544           if (new_flags & OM_ALIGNED_FLAG)
    545             __omTypeRealloc0AlignedSize(old_addr, old_size, (void*), new_addr, new_size);
     370#ifdef OM_ALIGNMENT_NEEDS_WORK
     371          if (new_flags & OM_FALIGN)
     372            __omTypeRealloc0AlignedSize(old_addr, old_size, void*, new_addr, new_size);
    546373          else
    547             __omTypeRealloc0Size(old_addr, old_size, (void*), new_addr, new_size);
     374#endif
     375            __omTypeRealloc0Size(old_addr, old_size, void*, new_addr, new_size);
    548376        }
    549377        else
    550378        {
    551           if (new_flags & OM_ALIGNED_FLAG)
    552             __omTypeReallocAlignedSize(old_addr, old_size, (void*), new_addr, new_size);
     379#ifdef OM_ALIGNMENT_NEEDS_WORK
     380          if (new_flags & OM_FALIGN)
     381            __omTypeReallocAlignedSize(old_addr, old_size, void*, new_addr, new_size);
    553382          else
    554             __omTypeReallocSize(old_addr, old_size, (void*), new_addr, new_size);
     383#endif
     384            __omTypeReallocSize(old_addr, old_size, void*, new_addr, new_size);
    555385        }
    556386      }
    557387      else
    558388      {
    559         if (new_flags & OM_ZERO_FLAG)
     389        if (new_flags & OM_FZERO)
    560390        {
    561           if (new_flags & OM_ALIGNED_FLAG)
    562             __omTypeRealloc0Aligned(old_addr, (void*), new_addr, new_size);
     391#ifdef OM_ALIGNMENT_NEEDS_WORK
     392          if (new_flags & OM_FALIGN)
     393            __omTypeRealloc0Aligned(old_addr, void*, new_addr, new_size);
    563394          else
    564             __omTypeRealloc0(old_addr, (void*), new_addr, new_size);
     395#endif
     396            __omTypeRealloc0(old_addr, void*, new_addr, new_size);
    565397        }
    566398        else
    567399        {
    568           if (new_flags & OM_ALIGNED_FLAG)
    569             __omTypeReallocAligned(old_addr, (void*), new_addr, new_size);
     400#ifdef OM_ALIGNMENT_NEEDS_WORK
     401          if (new_flags & OM_FALIGN)
     402            __omTypeReallocAligned(old_addr, void*, new_addr, new_size);
    570403          else
    571             __omTypeRealloc(old_addr, (void*), new_addr, new_size);
     404#endif
     405            __omTypeRealloc(old_addr, void*, new_addr, new_size);
    572406        }
    573407      }
    574408    }
    575409  }
    576 
    577410  return new_addr;
    578411}
    579412
    580 
    581 unsigned long om_NumberOfKeptAddrs = 0;
    582 omDebugAddr om_FirstKeptDebugAddr = NULL;
    583 omDebugAddr om_LastKeptDebugAddr = NULL;
    584 static void __omTestFree(void* addr, void* size_bin, int flags, char* f,const int l,void* r)
    585 {
    586   if (omIsDebugAddr(addr))
    587   {
    588     omDebugAddr d_addr = omOutAddr_2_DebugAddr(addr);
    589    
    590     d_addr->next = NULL;
    591    
    592     if (d_addr->debug > 2)
    593     {
    594       d_addr->flags &= ~OM_USED_FLAG;
    595       d_addr->flags |= OM_FREE_FLAG;
    596      
    597       if (d_addr->debug > 3)
    598       {
    599         d_addr->free_line = l;
    600         d_addr->free_file = f;
    601        
    602         if (d_addr->debug > 4)
    603           omGetCurrentBackTrace(&d_addr->free_frames, OM_MAX_FRAMES, r);
    604       }
    605     }
    606   }
    607  
     413static omBin omGetOrigSpecBinOfAddr(void* addr)
     414{
     415  if (omIsBinPageAddr(addr))
     416  {
     417#ifdef OM_HAVE_TRACK
     418    if (omIsBinAddrTrackAddr(addr)) return omGetOrigSpecBinOfTrackAddr(addr);
     419    else
     420#endif
     421    {
     422      omBin bin = omGetTopBinOfAddr(addr);
     423      if (!omIsStaticNormalBin(bin)) return bin;
     424    }
     425  }
     426  return NULL;
     427}
     428
     429static void __omDebugFree(void* addr, void* size_bin, omTrackFlags_t flags, OM_FLR_DECL)
     430{
     431  omBin bin = NULL;
     432 
     433  if (addr == NULL || ((flags & OM_FSIZE) && size_bin == NULL)) return;
    608434  if (om_Opts.Keep > 0)
    609435  {
     436#ifdef OM_HAVE_TRACK
     437    if (omIsTrackAddr(addr))
     438      addr = omMarkAsFreeTrackAddr(addr, 1, OM_FLR_VAL);
     439#endif
     440    bin = omGetOrigSpecBinOfAddr(addr);
     441    if (bin != NULL)
     442    {
     443      omSpecBin s_bin = omFindInGList(om_SpecBin, next, bin, (unsigned long) bin);
     444      omAssume(s_bin != NULL);
     445      (s_bin->ref)++;
     446    }
     447
    610448    if (om_NumberOfKeptAddrs)
    611449    {
    612       omAssume(om_FirstKeptDebugAddr != NULL && om_LastKeptDebugAddr != NULL &&
    613                ((om_NumberOfKeptAddr == 1 && om_LastKeptDebugAddr == om_FirstKeptDebugAddr) ||
    614                 (om_NumberOfKeptAddr != 1 && om_LastKeptDebugAddr != om_FirstKeptDebugAddr)));
     450      omAssume(om_KeptAddr != NULL && om_LastKeptAddr != NULL &&
     451               ((om_NumberOfKeptAddrs == 1 && om_LastKeptAddr == om_KeptAddr) ||
     452                (om_NumberOfKeptAddrs != 1 && om_LastKeptAddr != om_KeptAddr)));
    615453      om_NumberOfKeptAddrs++;
    616454      *((void**) om_LastKeptAddr) = addr;
    617455      om_LastKeptAddr = addr;
     456      *((void**) addr) = NULL;
    618457    }
    619458    else
     
    621460      om_NumberOfKeptAddrs = 1;
    622461      om_LastKeptAddr = addr;
    623       om_FirstKeptAddr = addr;
     462      om_KeptAddr = addr;
    624463      *((void**) om_LastKeptAddr) = NULL;
    625464    }
     
    627466    if (om_NumberOfKeptAddrs > om_Opts.Keep)
    628467    {
    629       addr = om_FirstKeptAddr;
    630       om_FirstKeptAddr = *((void**) addr);
     468      omError_t status = omDoCheckAddr(om_KeptAddr, NULL, OM_FKEPT, om_Opts.MinCheck, 
     469                                       omError_MemoryCorrupted, OM_FLR_VAL);
     470      addr = om_KeptAddr;
     471      om_KeptAddr = *((void**) addr);
    631472      om_NumberOfKeptAddrs--;
     473      if (status != omError_NoError) return;
    632474    }
    633475    else
    634476      return;
     477
     478    bin = omGetOrigSpecBinOfAddr(addr);
     479  }
     480
     481#ifdef OM_HAVE_TRACK
     482  if (omIsTrackAddr(addr))
     483  {
     484    omMarkAsFreeTrackAddr(addr, 0, OM_FLR_VAL);
     485    omFreeTrackAddr(addr);
    635486  }
    636487  else
    637   {
    638     if (! omIsDebugAddr(addr))
    639     {
    640       if (flags & OM_BIN_FLAG)
    641         ___omFreeBin(addr);
    642       else if (flags & OM_SIZE_FLAG)
    643         __omFreeSize(addr, (size_t) bin_size);
    644       else
    645         __omFree(addr);
    646 
    647       return;
    648     }
    649   }
    650  
    651   if (omIsDebugAddr(addr))
    652     omFreeDebugAddr(addr);
    653   else
    654     __omFree(addr);
    655 }
    656 static void omFreeDebugAddr(void* d_addr)
    657 {
    658   omBinPage page;
    659  
    660   omAssume(d_addr != NULL && omIsDebugAddr(d_addr));
    661 
    662   page = (omBinPage) omGetPageOfAddr((void*) d_addr);
    663   omAssume(omIsBinPage(page));
    664 
    665   omUnsetDebugOfUsedBlocks(page->used_blocks);
    666 
    667   om_JustFreedPage = NULL;
    668 
    669   ___omFreeBin(d_addr);
    670 
    671   if (page != om_JustFreedPage)
    672     omSetDebugOfUsedBlocks(page->used_blocks);
    673 }
    674 
    675 /*******************************************************************
    676  * 
    677  * Second level omCheck routines: do the actual checks
    678  * 
    679  *******************************************************************/
    680 
    681 #define omIsAddrInValidRange(addr) 1
    682 
    683 omError_t omCheckAddr(void* addr, void* bin_size, int flags, char level, char* f, const int l, void* r)
    684 {
    685   if (addr == NULL)
    686     return omReportAddrError(omError_NullAddr, addr, bin_size, flags, f, l, r, "");
    687  
    688   if (((long) addr  & (SIZEOF_OM_ALIGNMENT - 1)))
    689     return omReportAddrError(omError_UnalignedAddr, addr, bin_size, flags, f, l, r,  "");
    690 
    691   if ((flags & OM_ALIGN_FLAG) &&  ((long) addr  & (SIZEOF_OM_STRICT_ALIGNMENT - 1)))
    692     return omReportAddrError(omError_UnalignedAddr, addr, bin_size, flags, f, l, r,  "");
    693 
    694   if (! omIsAddrInValidRange(addr))
    695     return omReportAddrError(omError_InvalidRange, addr, bin_size, flags, f, l, r,  "");
    696 
    697   if (omIsBinPageAddr(addr))
    698   {
    699     if (! omCheckPageHeader(omGetPageOfAddr(addr)))
    700       return omReportAddrError(omError_MemoryCorrupted, addr, bin_size, flags, f, l, r, 
    701                                "Page Header corrupted");
    702 
    703     if (omIsDebugAddr(addr))
    704     {
    705       omDebugAddr d_addr = omAddr_2_DebugAddr(addr);
    706       if (d_addr->debug < 0 || d_addr->debug > OM_DEBUG_MAX)
    707         return omReportAddrError(omError_MemoryCorrupted, addr, bin_size, flags, f, l, r,
    708                                  "debug:%d out of range", d_addr->debug);
    709       if (omDebugAddr_2_OutAddr(d_addr) != addr)
    710         return omReportAddrError(omError_FalseAddr, addr, bin_size, flags, f, l, r,
    711                                  "omDebugAddr_2_OutAddr(d_addr):%d  != addr:%d",
    712                                  omDebugAddr_2_OutAddr(d_addr), addr);
    713       if (! omCheckDebugAddr(d_addr, bin_size, flags, level, f, l, r))
    714         return om_ErrorStatus;
    715      
    716       if (level > 1 &&
    717           !omCheckBinAddr(d_addr, NULL, (flags &~ OM_SIZE_FLAG) &~ OM_BIN_FLAG , level, f, l, r))
    718         return om_ErrorStatus;
    719       else
    720         return om_ErrorStatus = omError_NoError;
    721     }
    722     else
    723     {
    724       return omCheckBinAddr(addr, bin_size, flags, level, f, l, r);
    725     }
    726   }
    727   else
    728   {
    729     return omCheckLargeAddr(addr, bin_size, flags, level, f, l, r);
    730   }
    731 }
    732 
    733 omError_t omCheckLargeAddr(void* addr, void* bin_size, int flags, char level, char* f, const int l, void* r)
    734 {
    735  
    736 
    737 
    738      
    739 #endif /* OM_HAVE_DEBUG */
     488#endif   
     489    if (om_Opts.Keep <= 0 && (flags & OM_FBIN))
     490      ___omFreeBin(addr);
     491    else if (om_Opts.Keep <= 0 && (flags & OM_FSIZE))
     492      __omFreeSize(addr, (size_t) size_bin);
     493    else
     494      __omFree(addr);
     495
     496  if (bin != NULL) omUnGetSpecBin(&bin);
     497}
     498
     499void omFreeKeptAddr()
     500{
     501  void* next;
     502  omBin bin;
     503 
     504  while (om_KeptAddr != NULL)
     505  {
     506    next = *((void**)om_KeptAddr);
     507    bin = omGetOrigSpecBinOfAddr(om_KeptAddr);
     508
     509#ifdef OM_HAVE_TRACK
     510    if (omIsTrackAddr(om_KeptAddr))
     511    {
     512      omMarkAsFreeTrackAddr(om_KeptAddr, 0, OM_FLR);
     513      omFreeTrackAddr(om_KeptAddr);
     514    }
     515    else
     516#endif   
     517      __omFree(om_KeptAddr);
     518
     519    if (bin != NULL) omUnGetSpecBin(&bin);
     520    om_KeptAddr = next;
     521  }
     522  om_NumberOfKeptAddrs = 0;
     523  om_LastKeptAddr = NULL;
     524}
     525
     526#endif /* ! OM_NDEBUG */
  • omalloc/omDebug.h

    recf4ca6 r3df5b10  
    11/*******************************************************************
    22 *  File:    omDebug.h
    3  *  Purpose: declaration of main omDebug functions
     3 *  Purpose: declaration of common Debug/Check/Track stuff
    44 *  Author:  obachman@mathematik.uni-kl.de (Olaf Bachmann)
    5  *  Created: 11/99
    6  *  Version: $Id: omDebug.h,v 1.3 2000-05-31 13:34:31 obachman Exp $
     5 *  Created: 7/00
     6 *  Version: $Id: omDebug.h,v 1.4 2000-08-14 12:08:45 obachman Exp $
    77 *******************************************************************/
    8 #include "omError.h"
    9 
    10 /* Debugging addresses and Bins */
    11 omError_t omDebugAddrBin(void* addr, omBin bin, int level);
    12 omError_t omDebugAddr(void* adr, int level);
    13 omError_t omDebugAddrSize(void* addr, size_t size, int level);
    14 
    15 omError_t omDebugAlignedBinAddr(void* addr, int level);
    16 omError_t omDebugAlignedBinAddrBin(void* addr, omBin bin, int level);
    17 omError_t omDebugAlignedAddr(void* adr, int level);
    18 omError_t omDebugAlignedAddrSize(void* addr, size_t size, int level);
    19 
    20 omError_t omDebugBin(omBin bin, int level);
    21 omError_t omDebugBins(int level);
    22 
    23 /* combining check and alloc/free */
    24 void* omDebugAllocBin(omBin bin, int level);
    25 void* omDebugAlloc0Bin(omBin bin, int level);
    26 void* omDebugReallocBin(void* addr, omBin old_bin, omBin new_bin, int level);
    27 void* omDebugRealloc0Bin(void* addr, omBin old_bin, omBin new_bin, int level);
    28 void  omDebugFreeBin(void* addr, omBin bin, int level);
    29 
    30 void* omDebugAlloc(size_t Size, int level);
    31 void* omDebugAlloc0(size_t Size, int level);
    32 void* omDebugAllocAligned(size_t Size, int level);
    33 void* omDebugAlloc0Aligned(size_t Size, int level);
    34 
    35 void* omDebugRealloc(void* addr, size_t new_Size, int level);
    36 void* omDebugRealloc0(void* addr, size_t new_Size, int level);
    37 void* omDebugReallocAligned(void* addr, size_t new_Size, int level);
    38 void* omDebugRealloc0Aligned(void* addr, size_t new_Size, int level);
    39 
    40 void* omDebugReallocSize(void* addr, size_t old_Size, size_t new_Size, int level);
    41 void* omDebugRealloc0Size(void* addr, size_t old_Size, size_t new_Size, int level);
    42 void* omDebugReallocAlignedSize(void* addr, size_t old_Size, size_t new_Size, int level);
    43 void* omDebugRealloc0AlignedSize(void* addr, size_t old_Size, size_t new_Size, int level);
    44 
    45 void omDebugFreeSize(void* addr, size_t size, int level);
    46 void omDebugFree(void* addr, int level);
    47 
    48 void* omDebugAllocAlignedFunc(size_t size);
    49 void* omDebugReallocAlignedFunc(void* addr, size_t new_size);
    50 void  omDebugFreeFunc(void* addr);
     8#ifndef OM_DEBUG_H
     9#define OM_DEBUG_H
    5110
    5211
     12#if defined(OM_NDEBUG) || ! defined(OM_HAVE_TRACK)
     13#define omIsTrackAddr(addr)             0
     14#define omIsTrackAddrPage(page)         0
     15#define omIsNormalBinPageAddr(addr)     omIsBinPageAddr(addr)
     16#define omIsBinAddrTrackAddr(addr)      0
     17#else
     18#define omIsTrackAddrBinPage(bin_page)  ((bin_page)->used_blocks < 0)
     19#define omIsBinAddrTrackAddr(addr)      omIsTrackAddrBinPage(omGetBinPageOfAddr(addr))
     20#define omIsTrackAddr(addr)             (omIsBinPageAddr(addr) && omIsBinAddrTrackAddr(addr))
     21#define omIsNormalBinPageAddr(addr)     (omIsBinPageAddr(addr) && !omIsBinAddrTrackAddr(addr))
     22#endif
     23
     24#if defined(OM_NDEBUG)
     25#define omMarkAsStaticAddr(addr)    ((void)0)
     26#define omMarkMemoryAsStatic()      ((void)0)
     27#define omUnMarkAsStaticAddr()      ((void)0)
     28#define omUnMarkMemoryAsStatic()    ((void)0)
     29#define omFreeKeptAddr()            ((void)0)
     30#define omPrintUsedAddrs(fd)        ((void)0)
     31#define omPrintUsedTrackAddrs(fd)   ((void)0)
     32#else
     33#define OM_FBIN     1           /* size_bin is bin */
     34#define OM_FSIZE    2           /* size_bin is size */
     35#define OM_FUSED    4           /* is in use, if set */
     36#define OM_FKEPT    8           /* had been freed, if set */
     37#define OM_FSTATIC  16          /* if set, considered to be static, i.e. never be freed */
     38#define OM_FZERO    32          /* for Alloc0 */
     39#define OM_FALIGN   64          /* for AllocAligned */
     40#define OM_FSLOPPY  128         /* be sloppy about arguments */
     41#define OM_FMAX     250         /* maximal flag: OM_FBIN and OM_FSIZE can not be at the same time,
     42                                   and so can't OM_USED and OM_KEPT. Hence 255 - BIN - USED*/
     43typedef unsigned char omTrackFlags_t;
     44
     45void* _omDebugAlloc(void* size_bin, omTrackFlags_t flags, OM_CTFL_DECL);
     46void* _omDebugRealloc(void* old_addr, void* old_size_bin, void* new_size_bin,
     47                      omTrackFlags_t old_flags, omTrackFlags_t new_flags, OM_CTFL_DECL);
     48void  _omDebugFree(void* addr, void* size_bin, omTrackFlags_t flags, OM_CFL_DECL);
     49void* _omDebugMemDup(void* addr, omTrackFlags_t flags, OM_CTFL_DECL);
     50char* _omDebugStrDup(const char* addr, OM_TFL_DECL);
     51
     52omError_t _omDebugBin(omBin bin, OM_CFL_DECL);
     53omError_t _omDebugMemory(OM_CFL_DECL);
     54omError_t _omDebugAddr(void* addr, void* bin_size, omTrackFlags_t flags, OM_CFL_DECL);
     55
     56void omFreeKeptAddr();
     57void omPrintUsedAddrs(FILE* fd);
     58void omPrintUsedTrackAddrs(FILE* fd);
     59
     60void omMarkAsStaticAddr(void* addr);
     61void omMarkMemoryAsStatic();
     62void omUnMarkAsStaticAddr(void* addr);
     63void omUnMarkMemoryAsStatic();
     64#endif /* ! OM_NDEBUG */
     65
     66/*BEGINPRIVATE*/
     67
     68#if defined(OM_NDEBUG) || ! defined(OM_HAVE_TRACK)
     69#define omGetUsedBlocksOfPage(page)     (page->used_blocks)
     70#else
     71#define omGetUsedBlocksOfPage(page)     (page->used_blocks & ~(1 << (BIT_SIZEOF_LONG -1)))
     72#endif
     73
     74#ifndef OM_NDEBUG
    5375
    5476
     77void* om_KeptAddr;
     78unsigned long om_MaxAddr;
     79unsigned long om_MinAddr;
     80
     81/***********************************************************************
     82 *
     83 * omDebugCheck.c
     84 *
     85 **********************************************************************/
     86omError_t omCheckPtr(void* ptr, omError_t report, OM_FLR_DECL);
     87omError_t _omCheckAddr(void* addr, void* size_bin, omTrackFlags_t flags, char check, 
     88                       omError_t report, OM_FLR_DECL);
     89omError_t omDoCheckBinAddr(void* addr, void* bin_size, omTrackFlags_t flags, char level,
     90                           omError_t report, OM_FLR_DECL);
     91omError_t _omCheckBin(omBin bin, int normal_bin, char check,  omError_t report, OM_FLR_DECL);
     92omError_t _omCheckMemory(char check,  omError_t report, OM_FLR_DECL);
     93omError_t omReportAddrError(omError_t error, omError_t report, void* addr, void* bin_size, omTrackFlags_t flags,
     94                            OM_FLR_DECL, const char* fmt, ...);
     95omError_t omDoCheckBin(omBin bin, int normal_bin, char level,
     96                       omError_t report, OM_FLR_DECL);
     97int omIsKnownTopBin(omBin bin, int normal_bin);
     98void omIterateTroughAddrs(int normal, int track, void (*CallBackUsed)(void*), void (*CallBackFree)(void*));
     99void omIterateTroughBinAddrs(omBin bin, void (*CallBackUsed)(void*), void (*CallBackFree)(void*));
     100omError_t omDoCheckAddr(void* addr, void* bin_size, omTrackFlags_t flags, char level,
     101                        omError_t report, OM_FLR_DECL);
    55102
    56103
     104/***********************************************************************
     105 *
     106 * omDebugTrack.c
     107 *
     108 **********************************************************************/
     109#ifdef OM_HAVE_TRACK
     110extern omBin_t om_StaticTrackBin[];
     111extern omBin om_Size2TrackBin[];
     112#define omSmallSize2TrackBin(size)      om_Size2TrackBin[((size) -1)>>LOG_SIZEOF_OM_ALIGNMENT]
     113extern omBinPage om_JustFreedPage;
     114extern void omFreeTrackAddr(void* addr);
     115extern size_t omOutSizeOfTrackAddr(void* addr);
     116extern omSpecBin om_SpecTrackBin;
    57117
     118void* omAllocTrackAddr(void* bin_size, omTrackFlags_t flags, char track, OM_FLR_DECL);
     119void* omMarkAsFreeTrackAddr(void* addr, int keep, OM_FLR_DECL);
     120omError_t omCheckTrackAddr(void* addr, void* bin_size, omTrackFlags_t flags, char level,
     121                           omError_t report_error, OM_FLR_DECL);
     122void omPrintTrackAddrInfo(FILE* fd, void* addr);
     123omBin omGetOrigSpecBinOfTrackAddr(void* addr);
     124size_t omOutSizeOfTrackAddr(void* addr);
     125extern int omIsStaticTrackAddr(void* addr);
     126#define omSetTrackOfUsedBlocks(ub)      (ub |= (1 << (BIT_SIZEOF_LONG -1)))
     127#define omUnsetTrackOfUsedBlocks(ub)    (ub &= ~(1 << (BIT_SIZEOF_LONG -1)))
     128#define omIsSetTrackOfUsedBlocks(ub)    (ub & (1 << (BIT_SIZEOF_LONG -1)))
     129#else
     130#define omIsStaticTrackAddr(addr)   0
     131#endif
     132
     133
     134/***********************************************************************
     135 *
     136 * omBinPage.c
     137 *
     138 **********************************************************************/
     139int omIsKnownMemoryRegion(omBinPageRegion region);
     140omError_t omCheckBinPageRegion(omBinPageRegion region, int level, omError_t report, OM_FLR_DECL);
     141omError_t omCheckBinPageRegions(int level, omError_t report, OM_FLR_DECL);
     142omBinPageRegion omFindRegionOfAddr(void* addr);
     143int omIsAddrOnFreeBinPage(void* addr);
     144
     145/***********************************************************************
     146 *
     147 * Some Handy Macros
     148 *
     149 **********************************************************************/
     150#define omCheckReturn(cond) \
     151  do {omError_t _status = cond; if (_status) return _status;} while (0)
     152#define omCheckReturnError(cond, error) \
     153  do {void* _status = (void*) (cond); if (_status) return omReportError(error, report, OM_FLR_VAL, "");} while (0)
     154#define omCheckReturnCorrupted(cond) \
     155  omCheckReturnError(cond, omError_MemoryCorrupted)
     156#define omAddrCheckReturn(cond)                                               \
     157do                                                                            \
     158{                                                                             \
     159  omError_t _status = cond;                                                   \
     160  if (_status && _status != omError_MaxError)                                 \
     161  {                                                                           \
     162    omPrintAddrInfo(stderr, _status, addr, bin_size, flags, "  occured for"); \
     163    return _status;                                                           \
     164  }                                                                           \
     165} while (0)
     166#define omAddrCheckReturnError(cond, error) \
     167  do {void* _status = (void*) (cond); if (_status) return omReportAddrError(error, report, addr, bin_size, flags, OM_FLR_VAL, "");} while (0)
     168#define omAddrCheckReturnCorrupted(cond) \
     169  omAddrCheckReturnError(cond, omError_MemoryCorrupted)
     170
     171#endif /* ! OM_NDEBUG */
     172/*ENDPRIVATE*/
     173
     174#endif /* OM_DEBUG_H */
  • omalloc/omFindExec.c

    recf4ca6 r3df5b10  
    44 *  Author:  obachman (Olaf Bachmann)
    55 *  Created: 11/99
    6  *  Version: $Id: omFindExec.c,v 1.2 2000-05-31 13:34:31 obachman Exp $
     6 *  Version: $Id: omFindExec.c,v 1.3 2000-08-14 12:08:45 obachman Exp $
    77 *******************************************************************/
    88
     
    2020#define MAXPATHLEN 1024
    2121#endif
    22 
    2322
    2423/* ABSOLUTE_FILENAME_P (fname): True if fname is an absolute filename */
     
    3635char * omFindExec (const char *name, char* executable)
    3736#else
    38 char * omFindExec_link (const char *name, char* executable)
     37static char * omFindExec_link (const char *name, char* executable)
    3938#endif
    4039{
    4140  char *search;
    4241  char *p;
     42#ifdef WINNT
     43  char *extra = NULL;
     44#endif
    4345  char tbuf[MAXPATHLEN];
    4446
     
    8486      char *extra = NULL;
    8587      /* we are under msdos display */
    86       FIX ME
    87         extra = (char*) AllocL((search != NULL ? strlen(search) : 0) + 3);
     88      extra = (char*) omAlloc((search != NULL ? strlen(search) : 0) + 3);
    8889      strcpy(extra, ".:");
    8990      if (search != NULL) strcat(extra, search);
     
    125126#ifdef WINNT
    126127          if (extra != NULL)
    127             FreeL(extra);
     128            omFree(extra);
    128129#endif
    129130          strcpy(executable, tbuf);
     
    142143    }
    143144  }
    144    
    145     return NULL;
    146   }
     145  return NULL;
     146}
    147147
    148148#ifdef HAVE_READLINK
     149/* similar to readlink, but dont' mess up absolute pathnames */
     150static int my_readlink(const char* name, char* buf, size_t bufsize)
     151{
     152  char buf2[MAXPATHLEN];
     153  int ret;
     154 
     155  if ((ret = readlink(name, buf2, bufsize)) > 0)
     156  {
     157    buf2[ret] = 0;
     158    if (*name == '/' && *buf2 != '/')
     159    {
     160      char* last = strrchr(name, '/');
     161      int i = 0;
     162      while (&(name[i]) != last)
     163      {
     164        buf[i] = name[i];
     165        i++;
     166      }
     167      buf[i] = '/';
     168      i++;
     169      strcpy(&(buf[i]), buf2);
     170      return i + ret;
     171    }
     172    else
     173    {
     174      strcpy(buf, buf2);
     175    }
     176  }
     177  return ret;
     178}
    149179
    150180#define MAX_LINK_LEVEL 10
     
    152182   followed up to MAX_LINK_LEVEL
    153183*/
    154 int full_readlink(const char* name, char* buf, size_t bufsize)
     184static int full_readlink(const char* name, char* buf, size_t bufsize)
    155185{
    156186  int ret;
    157187 
    158   if ((ret=readlink(name, buf, bufsize)) > 0)
     188  if ((ret=my_readlink(name, buf, bufsize)) > 0)
    159189  {
    160190    char buf2[MAXPATHLEN];
     
    164194    {
    165195      buf[ret] = '\0';
    166       if ((ret2 = readlink(buf, buf2, MAXPATHLEN)) > 0)
     196      if ((ret2 = my_readlink(buf, buf2, MAXPATHLEN)) > 0)
    167197      {
    168198        i++;
     
    195225  if (link != NULL && (ret=full_readlink(link, buf, MAXPATHLEN)) > 0)
    196226  {
     227    char *p = strrchr(link, '/');
     228
     229
     230    if(p!=NULL) *(p+1)='\0';
    197231    buf[ret]='\0';
    198     return omFindExec_link(buf, exec);
     232
     233    if (buf[0] != '/')
     234    {
     235      strcpy(exec, link);
     236      strcat(exec, buf);
     237    }
     238    else
     239    {
     240      strcpy(exec, buf);
     241    }
     242
     243    return exec;
    199244  }
    200245  return link;
  • omalloc/omFindExec.h

    recf4ca6 r3df5b10  
    44 *  Author:  obachman (Olaf Bachmann)
    55 *  Created: 11/99
    6  *  Version: $Id: omFindExec.h,v 1.1.1.1 1999-11-18 17:45:54 obachman Exp $
     6 *  Version: $Id: omFindExec.h,v 1.2 2000-08-14 12:08:46 obachman Exp $
    77 *******************************************************************/
    88#ifndef OM_FIND_EXEC_H
    99#define OM_FIND_EXEC_H
    1010
    11 #include <stdio.h>
    1211/* determines absolute pathname of program prog, writes it into exec */
    1312/* returns exec on succes, NULL on failure */
  • omalloc/omList.c

    recf4ca6 r3df5b10  
    44 *  Author:  obachman (Olaf Bachmann)
    55 *  Created: 11/99
    6  *  Version: $Id: omList.c,v 1.2 1999-11-22 18:12:59 obachman Exp $
     6 *  Version: $Id: omList.c,v 1.3 2000-08-14 12:08:46 obachman Exp $
    77 *******************************************************************/
     8#include "omConfig.h"
     9
    810#ifndef NULL
    911#define NULL ((void*) 0)
     
    169171
    170172
     173#ifndef OM_NDEBUG
     174#include "omAlloc.h"
     175#include "omDebug.h"
     176
     177omError_t _omCheckList(void* list, int next, int level, omError_t report, OM_FLR_DECL)
     178{
     179  if (level <= 1) return omError_NoError;
     180 
     181  if (level == 1)
     182  {
     183    while (list != NULL)
     184    {
     185      omCheckReturn(omCheckPtr(list, report, OM_FLR_VAL));
     186      ITER(list);
     187    }
     188  }
     189  else
     190  {
     191    void* l1 = list;
     192    void* l2;
     193    int l = 0, i;
     194
     195    l1 = list;
     196    while (l1 != NULL)
     197    {
     198      omCheckReturn(omCheckPtr(l1, report, OM_FLR_VAL));
     199      i = 0;
     200      l2 = list;
     201      while (l1 != l2)
     202      {
     203        i++;
     204        ITER(l2);
     205      }
     206      if (i != l)
     207        return omReportError(omError_ListCycleError, report, OM_FLR_VAL, "");
     208      ITER(l1);
     209      l++;
     210    }
     211  }
     212  return omError_NoError;
     213}
     214
     215omError_t _omCheckSortedList(void* list, int next, int long_field, int level, omError_t report, OM_FLR_DECL)
     216{
     217  void* prev = NULL;
     218 
     219  if (level <= 1) return omError_NoError;
     220 
     221  if (level == 1)
     222  {
     223    while (list != NULL)
     224    {
     225      omCheckReturn(omCheckPtr(list, report, OM_FLR_VAL));
     226      if (prev != NULL && VALUE(prev, long_field) > VALUE(list, long_field))
     227        return omReportError(omError_SortedListError, report, OM_FLR_VAL,
     228                             "%d > %d", VALUE(prev, long_field), VALUE(list, long_field));
     229      prev = list;
     230      ITER(list);
     231    }
     232  }
     233  else
     234  {
     235    void* l1 = list;
     236    void* l2;
     237    int l = 0, i;
     238
     239    while (l1 != NULL)
     240    {
     241      omCheckReturn(omCheckPtr(l1, report, OM_FLR_VAL));
     242      if (prev != NULL && VALUE(prev, long_field) > VALUE(l1, long_field))
     243        return omReportError(omError_SortedListError, report, OM_FLR_VAL,
     244                             "%d > %d", VALUE(prev, long_field), VALUE(l1, long_field));
     245      i = 0;
     246      l2 = list;
     247      while (l1 != l2)
     248      {
     249        i++;
     250        ITER(l2);
     251      }
     252      omCheckReturnError(i != l, omError_ListCycleError);
     253      prev = l1;
     254      ITER(l1);
     255      l++;
     256    }
     257  }
     258  return omError_NoError;
     259}
     260#endif
     261
     262
  • omalloc/omList.h

    recf4ca6 r3df5b10  
    44 *  Author:  obachman (Olaf Bachmann)
    55 *  Created: 11/99
    6  *  Version: $Id: omList.h,v 1.1.1.1 1999-11-18 17:45:53 obachman Exp $
     6 *  Version: $Id: omList.h,v 1.2 2000-08-14 12:08:46 obachman Exp $
    77 *******************************************************************/
    88
    99#ifndef OM_LIST_H
    1010#define OM_LIST_H
    11 
    1211
    1312#define OM_LIST_OFFSET(ptr, name_of_offset_field) \
     
    5049void* _omInsertInSortedList(void* list, int next, int long_field,
    5150                            void* addr);
    52 
     51#ifndef OM_NDEBUG
     52/* Check whether list is ok, i.e. whether addr of lists are aligned and in valid range */
     53omError_t _omCheckList(void* list, int next, int level, omError_t report, OM_FLR_DECL);
     54/* like above, but also check that sorting is ok */
     55omError_t _omCheckSortedList(void* list, int next, int long_field, int level, omError_t report, OM_FLR_DECL);
     56#endif
    5357
    5458/********************************************************************
     
    6872  _omRemoveFromList(ptr, 0, addr)
    6973#define omFindInList(ptr, what, value) \
    70   _omFindInList(ptr, 0, OM_LIST_OFFSET(ptr, what), value)
     74  _omFindInList(ptr, 0, OM_LIST_OFFSET(ptr, what), (unsigned long) value)
    7175#define omInsertInSortedList(ptr, what, addr) \
    7276  _omInsertInSortedList(ptr, 0, OM_LIST_OFFSET(ptr, what), addr)
     
    7579#define omRemoveFromSortedList(ptr, what, addr) \
    7680  _omRemoveFromSortedList(ptr, 0, OM_LIST_OFFSET(ptr, what), addr)
    77 
     81#ifndef OM_NDEBUG
     82#define omCheckList(ptr, level, report, OM_FLR_VAL) \
     83  _omCheckList(ptr, 0, level, report, OM_FLR_VAL)
     84#define omCheckSortedList(ptr, what, level, report, OM_FLR_VAL) \
     85  _omCheckSortedList(ptr, 0, OM_LIST_OFFSET(ptr, what), level, report, OM_FLR_VAL)
     86#endif
    7887
    7988/********************************************************************
     
    93102  _omRemoveFromList(ptr, OM_LIST_OFFSET(ptr, next), addr)
    94103#define omFindInGList(ptr, next, what, value) \
    95   _omFindInList(ptr, OM_LIST_OFFSET(ptr, next), OM_LIST_OFFSET(ptr, what), value)
     104  _omFindInList(ptr, OM_LIST_OFFSET(ptr, next), OM_LIST_OFFSET(ptr, what), (unsigned long) value)
    96105#define omInsertInSortedGList(ptr, next, what, addr) \
    97106  _omInsertInSortedList(ptr, OM_LIST_OFFSET(ptr, next), OM_LIST_OFFSET(ptr, what), addr)
     
    100109#define omRemoveFromSortedGList(ptr, next, what, addr) \
    101110  _omRemoveFromSortedList(ptr, OM_LIST_OFFSET(addr,next),OM_LIST_OFFSET(addr,what),addr)
     111#ifndef OM_NDEBUG
     112#define omCheckGList(ptr, next, level, report, OM_FLR_VAL) \
     113 _omCheckList(ptr, OM_LIST_OFFSET(ptr,next), level, report, OM_FLR_VAL)
     114#define omCheckSortedGList(ptr, next, what, level, report, OM_FLR_VAL) \
     115 _omCheckSortedList(ptr, OM_LIST_OFFSET(ptr,next), OM_LIST_OFFSET(ptr,what), level, report, OM_FLR_VAL)
     116#endif
    102117
    103118#endif /* OM_LIST_H */
  • omalloc/omMemOps.h

    recf4ca6 r3df5b10  
    44 *  Author:  obachman (Olaf Bachmann)
    55 *  Created: 11/99
    6  *  Version: $Id: omMemOps.h,v 1.1.1.1 1999-11-18 17:45:53 obachman Exp $
     6 *  Version: $Id: omMemOps.h,v 1.2 2000-08-14 12:08:46 obachman Exp $
    77 *******************************************************************/
    88
     
    2828#else /* ! DO_DEEP_PROFILE */
    2929
    30 #define omMemcpyW(p1, p2, l)                      \
     30#define omMemcpyW(p1, p2, l)                    \
    3131do                                              \
    3232{                                               \
    3333  long _i = l;                                  \
    34   long* _s1 = (long*) p1;                       \
    35   const long* _s2 = (long*) p2;                 \
     34  long* _s1 = (long*) (p1);                       \
     35  const long* _s2 = (long*) (p2);                 \
    3636                                                \
    3737  for (;;)                                      \
     
    4646while(0)
    4747
    48 #define omMemcpy_nwODD(p1, p2, l)                 \
     48#define omMemcpy_nwODD(p1, p2, l)               \
    4949do                                              \
    5050{                                               \
    51   long _i = l - 1;                              \
    52   long* _s1 = (long*) p1;                       \
    53   const long* _s2 = (long*) p2;                 \
     51  long _i = (l) - 1;                              \
     52  long* _s1 = (long*) (p1);                       \
     53  const long* _s2 = (long*) (p2);                 \
    5454                                                \
    5555  *_s1++ = *_s2++;                              \
     
    6464while(0)
    6565
    66 #define omMemcpy_nwEVEN(p1, p2, l)                \
     66#define omMemcpy_nwEVEN(p1, p2, l)              \
    6767do                                              \
    6868{                                               \
    6969  long _i = l;                                  \
    70   long* _s1 = (long*) p1;                       \
    71   const long* _s2 = (long*) p2;                 \
     70  long* _s1 = (long*) (p1);                       \
     71  const long* _s2 = (long*) (p2);                 \
    7272                                                \
    7373  for (;;)                                      \
     
    8181while(0)
    8282
    83 #define omMemaddW(P1, P2, P3, L)                  \
     83#define omMemaddW(P1, P2, P3, L)                \
    8484do                                              \
    8585{                                               \
     
    9898while(0)
    9999
    100 #define omMemadd_nwODD(P1, P2, P3, L)             \
     100#define omMemadd_nwODD(P1, P2, P3, L)           \
    101101do                                              \
    102102{                                               \
     
    119119while(0)
    120120
    121 #define omMemadd_nwEVEN(P1, P2, P3, L)            \
     121#define omMemadd_nwEVEN(P1, P2, P3, L)          \
    122122do                                              \
    123123{                                               \
     
    137137while(0)
    138138
    139 #define omMemadd_nwONE(P1, P2, P3)                \
     139#define omMemadd_nwONE(P1, P2, P3)              \
    140140do                                              \
    141141{                                               \
     
    148148while(0)
    149149
    150 #define omMemadd_nwTWO(P1, P2, P3)                \
     150#define omMemadd_nwTWO(P1, P2, P3)              \
    151151do                                              \
    152152{                                               \
     
    160160while(0)
    161161
    162 #define omMemsetW(P1, W, L)                       \
     162#define omMemsetW(P1, W, L)                     \
    163163do                                              \
    164164{                                               \
    165   long* _p1 = (long*) P1;                               \
     165  long* _p1 = (long*) (P1);                     \
    166166  unsigned long _l = L;                         \
    167                                                 \
     167  unsigned long _w = W;                         \
    168168  while(_l)                                     \
    169169  {                                             \
    170     *_p1++ = W;                                 \
     170    *_p1++ = _w;                                \
    171171    _l--;                                       \
    172172  }                                             \
  • omalloc/omPage.h

    recf4ca6 r3df5b10  
    44 *  Author:  obachman (Olaf Bachmann)
    55 *  Created: 11/99
    6  *  Version: $Id: omPage.h,v 1.3 2000-05-31 13:34:32 obachman Exp $
     6 *  Version: $Id: omPage.h,v 1.4 2000-08-14 12:08:46 obachman Exp $
    77 *******************************************************************/
    88#ifndef OM_PAGE_H
     
    108108  ((void*) ((long) (addr) & ~(SIZEOF_SYSTEM_PAGE -1)))
    109109
     110#define omGetBinPageOfAddr(addr) \
     111  ((omBinPage) ((long) (addr) & ~(SIZEOF_SYSTEM_PAGE -1)))
     112
    110113#define omIsAddrOnPage(addr, page) (omGetPageOfAddr(addr) == (void*) (page))
    111114
  • omalloc/omTables.c

    recf4ca6 r3df5b10  
    44 *  Author:  obachman (Olaf Bachmann)
    55 *  Created: 11/99
    6  *  Version: $Id: omTables.c,v 1.2 2000-05-31 13:34:32 obachman Exp $
     6 *  Version: $Id: omTables.c,v 1.3 2000-08-14 12:08:47 obachman Exp $
    77 *******************************************************************/
    88
     
    1616#include <string.h>
    1717#include "omConfig.h"
    18 #include "omAlloc.h"
     18#include "omDerivedConfig.h"
     19#include "omStructs.h"
     20#include "omAllocPrivate.h"
    1921
    2022/* Specify the minimal number of blocks which should go into a bin */
     
    6264#endif /* OM_ALIGN_8 */
    6365
    64 void OutputSize2Bin(size_t *binSize, size_t max_block_size)
     66void OutputSize2Bin(size_t *binSize, size_t max_block_size, int track)
    6567{
    6668  int i, j;
    67   printf("omBin om_Size2Bin[/*%d*/] = {\n",
    68          max_block_size / SIZEOF_OM_ALIGNMENT);
     69  printf("omBin om_Size2%sBin[/*%d*/] = {\n",
     70         (track? "Track" : ""), max_block_size / SIZEOF_OM_ALIGNMENT);
    6971  i=0;
    7072  j=SIZEOF_OM_ALIGNMENT;
    7173  while (j < max_block_size)
    7274  {
    73     printf("&om_StaticBin[%d], /* %d */ \n", i, j);
     75    printf("&om_Static%sBin[%d], /* %d */ \n", (track? "Track" : ""), i, j);
    7476    if (binSize[i] == j) i++;
    7577    j += SIZEOF_OM_ALIGNMENT;
    7678  }
    77   printf("&om_StaticBin[%d] /* %d */};\n\n", i, j);
    78 }
    79 
    80 void OutputSize2AlignedBin(size_t *binSize, size_t max_block_size)
     79  printf("&om_Static%sBin[%d] /* %d */};\n\n", (track? "Track" : ""), i, j);
     80}
     81
     82void OutputSize2AlignedBin(size_t *binSize, size_t max_block_size, int track)
    8183{
    8284  int i, j;
     
    8688    _exit(1);
    8789  }
    88   printf("omBin om_Size2AlignedBin[/*%d*/] = {\n",
    89          max_block_size / SIZEOF_OM_ALIGNMENT);
     90  printf("omBin om_Size2%sBin[/*%d*/] = {\n",
     91         (track ? "Track" : "Aligned"), max_block_size / SIZEOF_OM_ALIGNMENT);
    9092  i=0;
    9193  while (binSize[i] % SIZEOF_STRICT_ALIGNMENT != 0) i++;
     
    9395  while (j < max_block_size)
    9496  {
    95     printf("&om_StaticBin[%d], /* %d */ \n", i, j);
     97    printf("&om_Static%sBin[%d], /* %d */ \n", (track ? "Track" : ""), i, j);
    9698    if (binSize[i] == j)
    9799    {
     
    101103    j += SIZEOF_OM_ALIGNMENT;
    102104  }
    103   printf("&om_StaticBin[%d] /* %d */};\n\n", i, j);
    104 }
    105 
    106 void OutputStaticBin(size_t *binSize, int max_bin_index)
     105  printf("&om_Static%sBin[%d] /* %d */};\n\n", (track ? "Track" : ""), i, j);
     106}
     107
     108void OutputStaticBin(size_t *binSize, int max_bin_index, int track)
    107109{
    108110  int i;
    109   printf("omBin_t om_StaticBin[/*%d*/] = {\n", max_bin_index+1);
     111  printf("omBin_t om_Static%sBin[/*%d*/] = {\n", (track ? "Track" : ""), max_bin_index+1);
    110112
    111113  for (i=0;  i< max_bin_index; i++)
     
    162164}
    163165
    164 int main()
     166int main(int argc, char* argv[])
    165167{
    166168  int max_bin_index = 0;
     
    174176    if (om_BinSize[max_bin_index] == OM_MAX_BLOCK_SIZE) break;
    175177  }
    176   /* output what goes into omAllocPrivate.h */
     178  if (argc > 1)
     179  {
     180    /* output what goes into omTables.h */
     181  printf("
     182#ifndef OM_TABLES_H
     183#define OM_TABLES_H
     184#define OM_MAX_BLOCK_SIZE %d
     185#define OM_MAX_BIN_INDEX %d
     186#define OM_SIZEOF_UNIQUE_MAX_BLOCK_THRESHOLD %d
     187#endif /* OM_TABLES_H */
     188",  OM_MAX_BLOCK_SIZE, max_bin_index, GetMaxBlockThreshold());
     189  return 0;
     190  }
     191 
    177192  printf("
    178193#ifndef OM_TABLES_INC
    179194#define OM_TABLES_INC
    180 
    181 #ifdef OM_ALLOC_PRIVATE_H
    182 #define OM_MAX_BLOCK_SIZE %d
    183 #define OM_MAX_BIN_INDEX %d
    184 #define OM_SIZEOF_UNIQUE_MAX_BLOCK_THRESHOLD %d
    185 #endif /* OM_ALLOC_PRIVATE_H */
    186 
    187 #ifdef OM_ALLOC_C
    188 extern omBinPage_t om_ZeroPage[];
    189 ",  OM_MAX_BLOCK_SIZE, max_bin_index, GetMaxBlockThreshold());
     195");
     196 
    190197  /* Output om_StaticBin */
    191   OutputStaticBin(om_BinSize, max_bin_index);
     198  OutputStaticBin(om_BinSize, max_bin_index, 0);
    192199  /* Output om_Size2Bin */
    193   OutputSize2Bin(om_BinSize, OM_MAX_BLOCK_SIZE);
    194 
    195 #ifdef OM_ALIGNMENT_NEEDS_WORK
    196   OutputSize2AlignedBin(om_BinSize, OM_MAX_BLOCK_SIZE);
    197 #endif
    198  
    199   printf("
     200  OutputSize2Bin(om_BinSize, OM_MAX_BLOCK_SIZE, 0);
     201
     202#ifdef OM_ALIGNMENT_NEEDS_WORK
     203  OutputSize2AlignedBin(om_BinSize, OM_MAX_BLOCK_SIZE, 0);
     204#endif
     205 
     206  printf("\n#ifdef OM_HAVE_TRACK\n");
     207  /* Output om_StaticBin */
     208  OutputStaticBin(om_BinSize, max_bin_index, 1);
     209  /* Output om_Size2Bin */
     210#ifdef OM_ALIGNMENT_NEEDS_WORK
     211  OutputSize2AlignedBin(om_BinSize, OM_MAX_BLOCK_SIZE, 1);
    200212#else
    201 extern omBin_t om_StaticBin[];
    202 extern omBin om_Size2Bin[];
    203 extern omBin om_Size2AlignedBin[];
    204 #endif /* OM_ALLOC_C */
    205 #endif /* OM_TABLES_INC */
    206 ");
     213  OutputSize2Bin(om_BinSize, OM_MAX_BLOCK_SIZE, 1);
     214#endif
     215  printf("\n#endif /* OM_HAVE_TRACK */\n");
     216
     217  printf("\n#endif /* OM_TABLES_INC */\n");
    207218  return 0;
    208219}
Note: See TracChangeset for help on using the changeset viewer.