Changeset 212fc04 in git


Ignore:
Timestamp:
Nov 22, 1999, 7:13:00 PM (24 years ago)
Author:
Olaf Bachmann <obachman@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', '38dfc5131670d387a89455159ed1e071997eec94')
Children:
6ea5825fc0e0bfabf56883aee9dac9b5bbe415fe
Parents:
e6908a0f43ea328a1aa0c3942e8d309db7de26d5
Message:
* as we go along


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

Legend:

Unmodified
Added
Removed
  • omalloc/configure

    re6908a0 r212fc04  
    1313# Any additions from configure.in:
    1414ac_help="$ac_help
    15   --with-mtrack           use mpr routines for extended memory tracking
    16                              -- works only under ix86-Linux"
    17 ac_help="$ac_help
    1815  --with-align8           only use 8-aligned memory"
    1916ac_help="$ac_help
    2017  --enable-stat           enable memory statistics"
    2118ac_help="$ac_help
    22   --disable-mtrack        disable memory track"
     19  --disable-mtrack        disable backtrace and memory track"
     20ac_help="$ac_help
     21  --with_return_addr_func=FUNC
     22                             use FUNC as function for determening return addr
     23                             Default: __bultin_return_address"
     24ac_help="$ac_help
     25  --with_frame_addr_func=FUNC
     26                             use FUNC as function for determening frame addr
     27                             Default: __bultin_frame_address"
    2328
    2429# Initialize some variables set by options.
     
    533538
    534539
    535 # Check whether --with-mtrack or --without-mtrack was given.
    536 if test "${with_mtrack+set}" = set; then
    537   withval="$with_mtrack"
    538   :
    539 fi
    540 
    541540# Check whether --with-align8 or --without-align8 was given.
    542541if test "${with_align8+set}" = set; then
     
    551550fi
    552551
    553 # Check whether --with-mtrack or --without-mtrack was given.
    554 if test "${with_mtrack+set}" = set; then
    555   withval="$with_mtrack"
     552# Check whether --enable-mtrack or --disable-mtrack was given.
     553if test "${enable_mtrack+set}" = set; then
     554  enableval="$enable_mtrack"
    556555  :
    557556fi
    558557
     558# Check whether --with-return_addr_func or --without-return_addr_func was given.
     559if test "${with_return_addr_func+set}" = set; then
     560  withval="$with_return_addr_func"
     561  :
     562fi
     563
     564# Check whether --with-frame_addr_func or --without-frame_addr_func was given.
     565if test "${with_frame_addr_func+set}" = set; then
     566  withval="$with_frame_addr_func"
     567  :
     568fi
     569
     570
    559571                             
    560572
    561573echo $ac_n "checking singuname""... $ac_c" 1>&6
    562 echo "configure:563: checking singuname" >&5
     574echo "configure:575: checking singuname" >&5
    563575if eval "test \"`echo '$''{'ac_cv_singuname'+set}'`\" = set"; then
    564576  echo $ac_n "(cached) $ac_c" 1>&6
     
    591603
    592604echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6
    593 echo "configure:594: checking whether ${MAKE-make} sets \${MAKE}" >&5
     605echo "configure:606: checking whether ${MAKE-make} sets \${MAKE}" >&5
    594606set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'`
    595607if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then
     
    620632set dummy gcc; ac_word=$2
    621633echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
    622 echo "configure:623: checking for $ac_word" >&5
     634echo "configure:635: checking for $ac_word" >&5
    623635if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
    624636  echo $ac_n "(cached) $ac_c" 1>&6
     
    650662set dummy cc; ac_word=$2
    651663echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
    652 echo "configure:653: checking for $ac_word" >&5
     664echo "configure:665: checking for $ac_word" >&5
    653665if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
    654666  echo $ac_n "(cached) $ac_c" 1>&6
     
    701713set dummy cl; ac_word=$2
    702714echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
    703 echo "configure:704: checking for $ac_word" >&5
     715echo "configure:716: checking for $ac_word" >&5
    704716if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
    705717  echo $ac_n "(cached) $ac_c" 1>&6
     
    733745
    734746echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
    735 echo "configure:736: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
     747echo "configure:748: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
    736748
    737749ac_ext=c
     
    744756cat > conftest.$ac_ext << EOF
    745757
    746 #line 747 "configure"
     758#line 759 "configure"
    747759#include "confdefs.h"
    748760
    749761main(){return(0);}
    750762EOF
    751 if { (eval echo configure:752: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
     763if { (eval echo configure:764: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
    752764  ac_cv_prog_cc_works=yes
    753765  # If we can't run a trivial program, we are probably using a cross compiler.
     
    775787fi
    776788echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
    777 echo "configure:778: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
     789echo "configure:790: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
    778790echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6
    779791cross_compiling=$ac_cv_prog_cc_cross
    780792
    781793echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
    782 echo "configure:783: checking whether we are using GNU C" >&5
     794echo "configure:795: checking whether we are using GNU C" >&5
    783795if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
    784796  echo $ac_n "(cached) $ac_c" 1>&6
     
    789801#endif
    790802EOF
    791 if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:792: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
     803if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:804: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
    792804  ac_cv_prog_gcc=yes
    793805else
     
    808820CFLAGS=
    809821echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
    810 echo "configure:811: checking whether ${CC-cc} accepts -g" >&5
     822echo "configure:823: checking whether ${CC-cc} accepts -g" >&5
    811823if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then
    812824  echo $ac_n "(cached) $ac_c" 1>&6
     
    840852
    841853echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
    842 echo "configure:843: checking how to run the C preprocessor" >&5
     854echo "configure:855: checking how to run the C preprocessor" >&5
    843855# On Suns, sometimes $CPP names a directory.
    844856if test -n "$CPP" && test -d "$CPP"; then
     
    855867  # not just through cpp.
    856868  cat > conftest.$ac_ext <<EOF
    857 #line 858 "configure"
     869#line 870 "configure"
    858870#include "confdefs.h"
    859871#include <assert.h>
     
    861873EOF
    862874ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
    863 { (eval echo configure:864: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
     875{ (eval echo configure:876: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
    864876ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
    865877if test -z "$ac_err"; then
     
    872884  CPP="${CC-cc} -E -traditional-cpp"
    873885  cat > conftest.$ac_ext <<EOF
    874 #line 875 "configure"
     886#line 887 "configure"
    875887#include "confdefs.h"
    876888#include <assert.h>
     
    878890EOF
    879891ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
    880 { (eval echo configure:881: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
     892{ (eval echo configure:893: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
    881893ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
    882894if test -z "$ac_err"; then
     
    889901  CPP="${CC-cc} -nologo -E"
    890902  cat > conftest.$ac_ext <<EOF
    891 #line 892 "configure"
     903#line 904 "configure"
    892904#include "confdefs.h"
    893905#include <assert.h>
     
    895907EOF
    896908ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
    897 { (eval echo configure:898: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
     909{ (eval echo configure:910: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
    898910ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
    899911if test -z "$ac_err"; then
     
    920932
    921933echo $ac_n "checking for working const""... $ac_c" 1>&6
    922 echo "configure:923: checking for working const" >&5
     934echo "configure:935: checking for working const" >&5
    923935if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then
    924936  echo $ac_n "(cached) $ac_c" 1>&6
    925937else
    926938  cat > conftest.$ac_ext <<EOF
    927 #line 928 "configure"
     939#line 940 "configure"
    928940#include "confdefs.h"
    929941
     
    974986; return 0; }
    975987EOF
    976 if { (eval echo configure:977: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
     988if { (eval echo configure:989: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
    977989  rm -rf conftest*
    978990  ac_cv_c_const=yes
     
    9951007
    9961008echo $ac_n "checking for inline""... $ac_c" 1>&6
    997 echo "configure:998: checking for inline" >&5
     1009echo "configure:1010: checking for inline" >&5
    9981010if eval "test \"`echo '$''{'ac_cv_c_inline'+set}'`\" = set"; then
    9991011  echo $ac_n "(cached) $ac_c" 1>&6
     
    10021014for ac_kw in inline __inline__ __inline; do
    10031015  cat > conftest.$ac_ext <<EOF
    1004 #line 1005 "configure"
     1016#line 1017 "configure"
    10051017#include "confdefs.h"
    10061018
     
    10091021; return 0; }
    10101022EOF
    1011 if { (eval echo configure:1012: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
     1023if { (eval echo configure:1024: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
    10121024  rm -rf conftest*
    10131025  ac_cv_c_inline=$ac_kw; break
     
    10431055set dummy ranlib; ac_word=$2
    10441056echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
    1045 echo "configure:1046: checking for $ac_word" >&5
     1057echo "configure:1058: checking for $ac_word" >&5
    10461058if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
    10471059  echo $ac_n "(cached) $ac_c" 1>&6
     
    10731085set dummy ar; ac_word=$2
    10741086echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
    1075 echo "configure:1076: checking for $ac_word" >&5
     1087echo "configure:1088: checking for $ac_word" >&5
    10761088if eval "test \"`echo '$''{'ac_cv_prog_AR'+set}'`\" = set"; then
    10771089  echo $ac_n "(cached) $ac_c" 1>&6
     
    11061118set dummy perl; ac_word=$2
    11071119echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
    1108 echo "configure:1109: checking for $ac_word" >&5
     1120echo "configure:1121: checking for $ac_word" >&5
    11091121if eval "test \"`echo '$''{'ac_cv_prog_PERL'+set}'`\" = set"; then
    11101122  echo $ac_n "(cached) $ac_c" 1>&6
     
    11401152set dummy addr2line; ac_word=$2
    11411153echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
    1142 echo "configure:1143: checking for $ac_word" >&5
     1154echo "configure:1155: checking for $ac_word" >&5
    11431155if eval "test \"`echo '$''{'ac_cv_prog_ADDR2LINE'+set}'`\" = set"; then
    11441156  echo $ac_n "(cached) $ac_c" 1>&6
     
    11761188set dummy nm; ac_word=$2
    11771189echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
    1178 echo "configure:1179: checking for $ac_word" >&5
     1190echo "configure:1191: checking for $ac_word" >&5
    11791191if eval "test \"`echo '$''{'ac_cv_prog_NM'+set}'`\" = set"; then
    11801192  echo $ac_n "(cached) $ac_c" 1>&6
     
    12121224# header file checks
    12131225echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
    1214 echo "configure:1215: checking for ANSI C header files" >&5
     1226echo "configure:1227: checking for ANSI C header files" >&5
    12151227if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
    12161228  echo $ac_n "(cached) $ac_c" 1>&6
    12171229else
    12181230  cat > conftest.$ac_ext <<EOF
    1219 #line 1220 "configure"
     1231#line 1232 "configure"
    12201232#include "confdefs.h"
    12211233#include <stdlib.h>
     
    12251237EOF
    12261238ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
    1227 { (eval echo configure:1228: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
     1239{ (eval echo configure:1240: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
    12281240ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
    12291241if test -z "$ac_err"; then
     
    12421254  # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
    12431255cat > conftest.$ac_ext <<EOF
    1244 #line 1245 "configure"
     1256#line 1257 "configure"
    12451257#include "confdefs.h"
    12461258#include <string.h>
     
    12601272  # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
    12611273cat > conftest.$ac_ext <<EOF
    1262 #line 1263 "configure"
     1274#line 1275 "configure"
    12631275#include "confdefs.h"
    12641276#include <stdlib.h>
     
    12811293else
    12821294  cat > conftest.$ac_ext <<EOF
    1283 #line 1284 "configure"
     1295#line 1296 "configure"
    12841296#include "confdefs.h"
    12851297#include <ctype.h>
     
    12921304
    12931305EOF
    1294 if { (eval echo configure:1295: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
     1306if { (eval echo configure:1307: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
    12951307then
    12961308  :
     
    13191331ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
    13201332echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
    1321 echo "configure:1322: checking for $ac_hdr" >&5
     1333echo "configure:1334: checking for $ac_hdr" >&5
    13221334if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
    13231335  echo $ac_n "(cached) $ac_c" 1>&6
    13241336else
    13251337  cat > conftest.$ac_ext <<EOF
    1326 #line 1327 "configure"
     1338#line 1339 "configure"
    13271339#include "confdefs.h"
    13281340#include <$ac_hdr>
    13291341EOF
    13301342ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
    1331 { (eval echo configure:1332: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
     1343{ (eval echo configure:1344: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
    13321344ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
    13331345if test -z "$ac_err"; then
     
    13601372ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
    13611373echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
    1362 echo "configure:1363: checking for $ac_hdr" >&5
     1374echo "configure:1375: checking for $ac_hdr" >&5
    13631375if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
    13641376  echo $ac_n "(cached) $ac_c" 1>&6
    13651377else
    13661378  cat > conftest.$ac_ext <<EOF
    1367 #line 1368 "configure"
     1379#line 1380 "configure"
    13681380#include "confdefs.h"
    13691381#include <$ac_hdr>
    13701382EOF
    13711383ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
    1372 { (eval echo configure:1373: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
     1384{ (eval echo configure:1385: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
    13731385ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
    13741386if test -z "$ac_err"; then
     
    14001412do
    14011413echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
    1402 echo "configure:1403: checking for $ac_func" >&5
     1414echo "configure:1415: checking for $ac_func" >&5
    14031415if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
    14041416  echo $ac_n "(cached) $ac_c" 1>&6
    14051417else
    14061418  cat > conftest.$ac_ext <<EOF
    1407 #line 1408 "configure"
     1419#line 1420 "configure"
    14081420#include "confdefs.h"
    14091421/* System header to define __stub macros and hopefully few prototypes,
     
    14281440; return 0; }
    14291441EOF
    1430 if { (eval echo configure:1431: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
     1442if { (eval echo configure:1443: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
    14311443  rm -rf conftest*
    14321444  eval "ac_cv_func_$ac_func=yes"
     
    14551467
    14561468if test "$enable_mtrack" != no; then
    1457 # functions which crawl up the stack from return and frame addr
     1469
     1470# get function for return address
     1471if test "${with_return_addr_func+set}" = set; then
     1472if test "${with_return_addr_func}" != no; then
     1473  ac_cv_return_addr_func=$with_return_addr_func
     1474fi
     1475else
    14581476if test "${GCC}" = yes; then
    1459   ac_cv_func_return_addr="__builtin_return_address"
    1460   cat >> confdefs.h <<EOF
    1461 #define OM_RETURN_ADDR __builtin_return_address
    1462 EOF
    1463 
    1464   ac_cv_func_frame_addr="__builtin_frame_address"
    1465   cat >> confdefs.h <<EOF
    1466 #define OM_FRAME_ADDR __builtin_frame_address
    1467 EOF
    1468 
    1469 fi
    1470 
    1471 # test them
    1472 if test "${ac_cv_func_return_addr+set}" = set; then
    1473 # first, check whether return addr
    1474 echo $ac_n "checking whether $ac_cv_func_return_addr works""... $ac_c" 1>&6
    1475 echo "configure:1476: checking whether $ac_cv_func_return_addr works" >&5
    1476 if eval "test \"`echo '$''{'ac_cv_func_return_addr_works'+set}'`\" = set"; then
     1477  ac_cv_return_addr_func="__builtin_return_address"
     1478fi
     1479fi
     1480
     1481# test this function
     1482if test "${ac_cv_return_addr_func+set}" = set; then
     1483cat >> confdefs.h <<EOF
     1484#define OM_RETURN_ADDR $ac_cv_return_addr_func
     1485EOF
     1486
     1487# first, check whether return addr works
     1488echo $ac_n "checking whether $ac_cv_return_addr_func works""... $ac_c" 1>&6
     1489echo "configure:1490: checking whether $ac_cv_return_addr_func works" >&5
     1490if eval "test \"`echo '$''{'ac_cv_return_addr_func_works'+set}'`\" = set"; then
    14771491  echo $ac_n "(cached) $ac_c" 1>&6
    14781492else
    14791493  if test "$cross_compiling" = yes; then
    1480   ac_cv_func_return_addr_works=no
     1494  ac_cv_return_addr_func_works=no
    14811495else
    14821496  cat > conftest.$ac_ext <<EOF
    1483 #line 1484 "configure"
     1497#line 1498 "configure"
    14841498#include "confdefs.h"
    14851499
    14861500int test_return_addr()
    14871501{
    1488    if (OM_RETURN_ADDR(1)  != 0 && OM_RETURN_ADDR(0) != 0) return 0;
     1502   if (OM_RETURN_ADDR(1)  != 0 && OM_RETURN_ADDR(0) != 0 &&
     1503       OM_RETURN_ADDR(1) != OM_RETURN_ADDR(0)) return 0;
    14891504   return 1;
    14901505}
     
    14961511
    14971512EOF
    1498 if { (eval echo configure:1499: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
     1513if { (eval echo configure:1514: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
    14991514then
    1500   ac_cv_func_return_addr_works=yes
     1515  ac_cv_return_addr_func_works=yes
    15011516else
    15021517  echo "configure: failed program was:" >&5
    15031518  cat conftest.$ac_ext >&5
    15041519  rm -fr conftest*
    1505   ac_cv_func_return_addr_works=no
     1520  ac_cv_return_addr_func_works=no
    15061521fi
    15071522rm -fr conftest*
     
    15101525fi
    15111526
    1512 echo "$ac_t""$ac_cv_func_return_addr_works" 1>&6
    1513 
    1514 if test "$ac_cv_func_return_addr_works" = yes; then
     1527echo "$ac_t""$ac_cv_return_addr_func_works" 1>&6
     1528
     1529if test "$ac_cv_return_addr_func_works" = yes; then
     1530cat >> confdefs.h <<\EOF
     1531#define OM_RETURN_ADDR_WORKS 1
     1532EOF
     1533
     1534# check whether return addr works with rvalues
     1535echo $ac_n "checking whether $ac_cv_return_addr_func takes rvalues""... $ac_c" 1>&6
     1536echo "configure:1537: checking whether $ac_cv_return_addr_func takes rvalues" >&5
     1537if eval "test \"`echo '$''{'ac_cv_return_addr_func_rvalue'+set}'`\" = set"; then
     1538  echo $ac_n "(cached) $ac_c" 1>&6
     1539else
     1540  if test "$cross_compiling" = yes; then
     1541  ac_cv_return_addr_func_rvalue=no
     1542else
     1543  cat > conftest.$ac_ext <<EOF
     1544#line 1545 "configure"
     1545#include "confdefs.h"
     1546
     1547int test_return_addr(int f1, int f2)
     1548{
     1549   if (OM_RETURN_ADDR(f1)  != 0 && OM_RETURN_ADDR(f0) != 0 &&
     1550       OM_RETURN_ADDR(f1) != OM_RETURN_ADDR(f0)) return 0;
     1551   return 1;
     1552}
     1553
     1554int main()
     1555{
     1556   return test_return_addr(1, 0);
     1557}
     1558
     1559EOF
     1560if { (eval echo configure:1561: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
     1561then
     1562  ac_cv_return_addr_func_rvalue=yes
     1563else
     1564  echo "configure: failed program was:" >&5
     1565  cat conftest.$ac_ext >&5
     1566  rm -fr conftest*
     1567  ac_cv_return_addr_func_rvalue=no
     1568fi
     1569rm -fr conftest*
     1570fi
     1571
     1572fi
     1573
     1574echo "$ac_t""$ac_cv_return_addr_func_rvalue" 1>&6
     1575if test "$ac_cv_return_addr_func_rvalue" = yes; then
     1576  cat >> confdefs.h <<EOF
     1577#define OM_RETURN_ADDR_RVALUE 1
     1578EOF
     1579
     1580fi
     1581fi # "$ac_cv_return_addr_func_works" = yes;
     1582fi # "${ac_cv_return_addr_func+set}" = set;
     1583
     1584# get function for frame address
     1585if test "${with_frame_addr_func+set}" = set; then
     1586if test "${with_frame_addr_func}" != no; then
     1587  ac_cv_frame_addr_func=$with_frame_addr_func
     1588fi
     1589else
     1590if test "${GCC}" = yes; then
     1591  ac_cv_frame_addr_func="__builtin_frame_address"
     1592fi
     1593fi
     1594
     1595# test this function
     1596if test "${ac_cv_frame_addr_func+set}" = set; then
    15151597cat >> confdefs.h <<EOF
    1516 #define OM_RETURN_ADDR_WORKS 1
    1517 EOF
    1518 
    1519 if test "${ac_cv_func_frame_addr+set}" = set; then
    1520 # first, check whether return addr
    1521 echo $ac_n "checking whether $ac_cv_func_frame_addr works""... $ac_c" 1>&6
    1522 echo "configure:1523: checking whether $ac_cv_func_frame_addr works" >&5
    1523 if eval "test \"`echo '$''{'ac_cv_func_frame_addr_works'+set}'`\" = set"; then
     1598#define OM_FRAME_ADDR $ac_cv_frame_addr_func
     1599EOF
     1600
     1601# first, check whether frame addr works
     1602echo $ac_n "checking whether $ac_cv_frame_addr_func works""... $ac_c" 1>&6
     1603echo "configure:1604: checking whether $ac_cv_frame_addr_func works" >&5
     1604if eval "test \"`echo '$''{'ac_cv_frame_addr_func_works'+set}'`\" = set"; then
    15241605  echo $ac_n "(cached) $ac_c" 1>&6
    15251606else
    15261607  if test "$cross_compiling" = yes; then
    1527   ac_cv_func_frame_addr_works=no
     1608  ac_cv_frame_addr_func_works=no
    15281609else
    15291610  cat > conftest.$ac_ext <<EOF
    1530 #line 1531 "configure"
     1611#line 1612 "configure"
    15311612#include "confdefs.h"
    15321613
    15331614int test_frame_addr()
    15341615{
    1535    if (OM_FRAME_ADDR(1)  != 0 && OM_FRAME_ADDR(0) != 0) return 0;
     1616   if (OM_FRAME_ADDR(1)  != 0 && OM_FRAME_ADDR(0) != 0 &&
     1617       OM_FRAME_ADDR(1) != OM_FRAME_ADDR(0)) return 0;
    15361618   return 1;
    15371619}
     
    15431625
    15441626EOF
    1545 if { (eval echo configure:1546: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
     1627if { (eval echo configure:1628: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
    15461628then
    1547   ac_cv_func_frame_addr_works=yes
     1629  ac_cv_frame_addr_func_works=yes
    15481630else
    15491631  echo "configure: failed program was:" >&5
    15501632  cat conftest.$ac_ext >&5
    15511633  rm -fr conftest*
    1552   ac_cv_func_frame_addr_works=no
     1634  ac_cv_frame_addr_func_works=no
    15531635fi
    15541636rm -fr conftest*
     
    15571639fi
    15581640
    1559 echo "$ac_t""$ac_cv_func_frame_addr_works" 1>&6
    1560 
    1561 if test "$ac_cv_func_frame_addr_works" = yes; then
    1562 cat >> confdefs.h <<EOF
     1641echo "$ac_t""$ac_cv_frame_addr_func_works" 1>&6
     1642
     1643if test "$ac_cv_frame_addr_func_works" = yes; then
     1644cat >> confdefs.h <<\EOF
    15631645#define OM_FRAME_ADDR_WORKS 1
    15641646EOF
    15651647
    1566 fi
    1567 fi  # "${ac_cv_func_frame_addr+set}" = set
    1568 fi  # "$ac_cv_func_return_addr_works" = yes
    1569 fi  # "${ac_cv_func_return_addr+set}" = set
     1648# check whether frame addr works with rvalues
     1649echo $ac_n "checking whether $ac_cv_frame_addr_func takes rvalues""... $ac_c" 1>&6
     1650echo "configure:1651: checking whether $ac_cv_frame_addr_func takes rvalues" >&5
     1651if eval "test \"`echo '$''{'ac_cv_frame_addr_func_rvalue'+set}'`\" = set"; then
     1652  echo $ac_n "(cached) $ac_c" 1>&6
     1653else
     1654  if test "$cross_compiling" = yes; then
     1655  ac_cv_frame_addr_func_rvalue=no
     1656else
     1657  cat > conftest.$ac_ext <<EOF
     1658#line 1659 "configure"
     1659#include "confdefs.h"
     1660
     1661int test_frame_addr(int f1, int f2)
     1662{
     1663   if (OM_FRAME_ADDR(f1)  != 0 && OM_FRAME_ADDR(f0) != 0 &&
     1664       OM_FRAME_ADDR(f1) != OM_FRAME_ADDR(f0)) return 0;
     1665   return 1;
     1666}
     1667
     1668int main()
     1669{
     1670   return test_frame_addr(1, 0);
     1671}
     1672
     1673EOF
     1674if { (eval echo configure:1675: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
     1675then
     1676  ac_cv_frame_addr_func_rvalue=yes
     1677else
     1678  echo "configure: failed program was:" >&5
     1679  cat conftest.$ac_ext >&5
     1680  rm -fr conftest*
     1681  ac_cv_frame_addr_func_rvalue=no
     1682fi
     1683rm -fr conftest*
     1684fi
     1685
     1686fi
     1687
     1688echo "$ac_t""$ac_cv_frame_addr_func_rvalue" 1>&6
     1689if test "$ac_cv_frame_addr_func_rvalue" = yes; then
     1690  cat >> confdefs.h <<EOF
     1691#define OM_FRAME_ADDR_RVALUE 1
     1692EOF
     1693
     1694fi
     1695fi # "$ac_cv_frame_addr_func_works" = yes;
     1696fi # "${ac_cv_frame_addr_func+set}" = set;
     1697
    15701698fi  # "$enable_mtrack" != no;
    15711699
     
    15741702# sizes
    15751703echo $ac_n "checking size of long""... $ac_c" 1>&6
    1576 echo "configure:1577: checking size of long" >&5
     1704echo "configure:1705: checking size of long" >&5
    15771705if eval "test \"`echo '$''{'ac_cv_sizeof_long'+set}'`\" = set"; then
    15781706  echo $ac_n "(cached) $ac_c" 1>&6
     
    15821710else
    15831711  cat > conftest.$ac_ext <<EOF
    1584 #line 1585 "configure"
     1712#line 1713 "configure"
    15851713#include "confdefs.h"
    15861714#include <stdio.h>
     
    15931721}
    15941722EOF
    1595 if { (eval echo configure:1596: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
     1723if { (eval echo configure:1724: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
    15961724then
    15971725  ac_cv_sizeof_long=`cat conftestval`
     
    16131741
    16141742echo $ac_n "checking size of void*""... $ac_c" 1>&6
    1615 echo "configure:1616: checking size of void*" >&5
     1743echo "configure:1744: checking size of void*" >&5
    16161744if eval "test \"`echo '$''{'ac_cv_sizeof_voidp'+set}'`\" = set"; then
    16171745  echo $ac_n "(cached) $ac_c" 1>&6
     
    16211749else
    16221750  cat > conftest.$ac_ext <<EOF
    1623 #line 1624 "configure"
     1751#line 1752 "configure"
    16241752#include "confdefs.h"
    16251753#include <stdio.h>
     
    16321760}
    16331761EOF
    1634 if { (eval echo configure:1635: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
     1762if { (eval echo configure:1763: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
    16351763then
    16361764  ac_cv_sizeof_voidp=`cat conftestval`
     
    16521780
    16531781echo $ac_n "checking size of double""... $ac_c" 1>&6
    1654 echo "configure:1655: checking size of double" >&5
     1782echo "configure:1783: checking size of double" >&5
    16551783if eval "test \"`echo '$''{'ac_cv_sizeof_double'+set}'`\" = set"; then
    16561784  echo $ac_n "(cached) $ac_c" 1>&6
     
    16601788else
    16611789  cat > conftest.$ac_ext <<EOF
    1662 #line 1663 "configure"
     1790#line 1791 "configure"
    16631791#include "confdefs.h"
    16641792#include <stdio.h>
     
    16711799}
    16721800EOF
    1673 if { (eval echo configure:1674: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
     1801if { (eval echo configure:1802: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
    16741802then
    16751803  ac_cv_sizeof_double=`cat conftestval`
     
    16981826
    16991827echo $ac_n "checking align8""... $ac_c" 1>&6
    1700 echo "configure:1701: checking align8" >&5
     1828echo "configure:1829: checking align8" >&5
    17011829if test "$with_align8" = yes || test "$ac_cv_sizeof_long" = 8; then
    17021830  $ac_cv_align8 = yes
     
    17091837else
    17101838  cat > conftest.$ac_ext <<EOF
    1711 #line 1712 "configure"
     1839#line 1840 "configure"
    17121840#include "confdefs.h"
    17131841 
     
    17241852
    17251853EOF
    1726 if { (eval echo configure:1727: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
     1854if { (eval echo configure:1855: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
    17271855then
    17281856  ac_cv_align8=no
     
    17491877
    17501878echo $ac_n "checking size of system page""... $ac_c" 1>&6
    1751 echo "configure:1752: checking size of system page" >&5
     1879echo "configure:1880: checking size of system page" >&5
    17521880if eval "test \"`echo '$''{'ac_cv_pagesize'+set}'`\" = set"; then
    17531881  echo $ac_n "(cached) $ac_c" 1>&6
     
    17571885else
    17581886  cat > conftest.$ac_ext <<EOF
    1759 #line 1760 "configure"
     1887#line 1888 "configure"
    17601888#include "confdefs.h"
    17611889#include <stdio.h>
     
    17711899}
    17721900EOF
    1773 if { (eval echo configure:1774: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
     1901if { (eval echo configure:1902: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
    17741902then
    17751903  ac_cv_pagesize=`cat conftestval`
     
    17951923
    17961924echo $ac_n "checking for page aligned valloc""... $ac_c" 1>&6
    1797 echo "configure:1798: checking for page aligned valloc" >&5
     1925echo "configure:1926: checking for page aligned valloc" >&5
    17981926if eval "test \"`echo '$''{'ac_cv_have_page_alignment'+set}'`\" = set"; then
    17991927  echo $ac_n "(cached) $ac_c" 1>&6
     
    18411969else
    18421970  cat > conftest.$ac_ext <<EOF
    1843 #line 1844 "configure"
     1971#line 1972 "configure"
    18441972#include "confdefs.h"
    18451973
     
    18481976
    18491977EOF
    1850 if { (eval echo configure:1851: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
     1978if { (eval echo configure:1979: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
    18511979then
    18521980  ac_cv_have_page_alignment="ac_cv_usable_pagesize="`cat  conftestval`
     
    18651993else
    18661994  cat > conftest.$ac_ext <<EOF
    1867 #line 1868 "configure"
     1995#line 1996 "configure"
    18681996#include "confdefs.h"
    18691997
     
    18722000
    18732001EOF
    1874 if { (eval echo configure:1875: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
     2002if { (eval echo configure:2003: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
    18752003then
    18762004  ac_cv_have_page_alignment="ac_cv_usable_pagesize="`cat  conftestval`
     
    18922020else
    18932021  cat > conftest.$ac_ext <<EOF
    1894 #line 1895 "configure"
     2022#line 2023 "configure"
    18952023#include "confdefs.h"
    18962024
     
    19012029
    19022030EOF
    1903 if { (eval echo configure:1904: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
     2031if { (eval echo configure:2032: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
    19042032then
    19052033  ac_cv_have_page_alignment="ac_cv_have_gmalloc=yes; ac_cv_usable_pagesize="`cat  conftestval`
     
    19182046else
    19192047  cat > conftest.$ac_ext <<EOF
    1920 #line 1921 "configure"
     2048#line 2049 "configure"
    19212049#include "confdefs.h"
    19222050
     
    19272055
    19282056EOF
    1929 if { (eval echo configure:1930: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
     2057if { (eval echo configure:2058: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
    19302058then
    19312059  ac_cv_have_page_alignment="ac_cv_have_gmalloc=yes; ac_cv_usable_pagesize="`cat  conftestval`
     
    19772105
    19782106echo $ac_n "checking whether to enable statistics""... $ac_c" 1>&6
    1979 echo "configure:1980: checking whether to enable statistics" >&5
     2107echo "configure:2108: checking whether to enable statistics" >&5
    19802108if test "$enable_stat" = yes; then
    19812109  echo "$ac_t""yes" 1>&6
  • omalloc/configure.in

    re6908a0 r212fc04  
    44dnl Author:  obachman@mathematik.uni-kl.de (Olaf Bachmann)
    55dnl Created: 11/99
    6 dnl Version: $Id: configure.in,v 1.1.1.1 1999-11-18 17:45:52 obachman Exp $
     6dnl Version: $Id: configure.in,v 1.2 1999-11-22 18:12:57 obachman Exp $
    77dnl lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll
    88
     
    1313dnl help for configure
    1414dnl
    15 AC_ARG_WITH(
    16   mtrack,
    17   [  --with-mtrack           use mpr routines for extended memory tracking
    18                              -- works only under ix86-Linux])
    1915AC_ARG_WITH(
    2016  align8,
     
    2319  align8,
    2420  [  --enable-stat           enable memory statistics])
     21AC_ARG_ENABLE(
     22  mtrack,
     23  [  --disable-mtrack        disable backtrace and memory track])
    2524AC_ARG_WITH(
    26   mtrack,
    27   [  --disable-mtrack        disable memory track])
     25  return_addr_func,
     26  [  --with_return_addr_func=FUNC
     27                             use FUNC as function for determening return addr
     28                             Default: __bultin_return_address])
     29AC_ARG_WITH(
     30  frame_addr_func,
     31  [  --with_frame_addr_func=FUNC
     32                             use FUNC as function for determening frame addr
     33                             Default: __bultin_frame_address])
     34
    2835                             
    2936
     
    97104
    98105if test "$enable_mtrack" != no; then
    99 # functions which crawl up the stack from return and frame addr
     106
     107# get function for return address
     108if test "${with_return_addr_func+set}" = set; then
     109if test "${with_return_addr_func}" != no; then
     110  ac_cv_return_addr_func=$with_return_addr_func
     111fi
     112else
    100113if test "${GCC}" = yes; then
    101   ac_cv_func_return_addr="__builtin_return_address"
    102   AC_DEFINE_UNQUOTED(OM_RETURN_ADDR, __builtin_return_address)
    103   ac_cv_func_frame_addr="__builtin_frame_address"
    104   AC_DEFINE_UNQUOTED(OM_FRAME_ADDR, __builtin_frame_address)
    105 fi
    106 
    107 # test them
    108 if test "${ac_cv_func_return_addr+set}" = set; then
    109 # first, check whether return addr
    110 AC_MSG_CHECKING(whether $ac_cv_func_return_addr works)
    111 AC_CACHE_VAL(ac_cv_func_return_addr_works,
     114  ac_cv_return_addr_func="__builtin_return_address"
     115fi
     116fi
     117
     118# test this function
     119if test "${ac_cv_return_addr_func+set}" = set; then
     120AC_DEFINE_UNQUOTED(OM_RETURN_ADDR, $ac_cv_return_addr_func)
     121# first, check whether return addr works
     122AC_MSG_CHECKING(whether $ac_cv_return_addr_func works)
     123AC_CACHE_VAL(ac_cv_return_addr_func_works,
    112124AC_TRY_RUN([
    113125int test_return_addr()
    114126{
    115    if (OM_RETURN_ADDR(1)  != 0 && OM_RETURN_ADDR(0) != 0) return 0;
     127   if (OM_RETURN_ADDR(1)  != 0 && OM_RETURN_ADDR(0) != 0 &&
     128       OM_RETURN_ADDR(1) != OM_RETURN_ADDR(0)) return 0;
    116129   return 1;
    117130}
     
    121134   return test_return_addr();
    122135}
    123 ], ac_cv_func_return_addr_works=yes, 
    124    ac_cv_func_return_addr_works=no,
    125    ac_cv_func_return_addr_works=no))
    126 AC_MSG_RESULT($ac_cv_func_return_addr_works)
    127 
    128 if test "$ac_cv_func_return_addr_works" = yes; then
    129 AC_DEFINE_UNQUOTED(OM_RETURN_ADDR_WORKS)
    130 if test "${ac_cv_func_frame_addr+set}" = set; then
    131 # first, check whether return addr
    132 AC_MSG_CHECKING(whether $ac_cv_func_frame_addr works)
    133 AC_CACHE_VAL(ac_cv_func_frame_addr_works,
     136], ac_cv_return_addr_func_works=yes, 
     137   ac_cv_return_addr_func_works=no,
     138   ac_cv_return_addr_func_works=no))
     139AC_MSG_RESULT($ac_cv_return_addr_func_works)
     140
     141if test "$ac_cv_return_addr_func_works" = yes; then
     142AC_DEFINE(OM_RETURN_ADDR_WORKS)
     143# check whether return addr works with rvalues
     144AC_MSG_CHECKING(whether $ac_cv_return_addr_func takes rvalues)
     145AC_CACHE_VAL(ac_cv_return_addr_func_rvalue,
     146AC_TRY_RUN([
     147int test_return_addr(int f1, int f2)
     148{
     149   if (OM_RETURN_ADDR(f1)  != 0 && OM_RETURN_ADDR(f0) != 0 &&
     150       OM_RETURN_ADDR(f1) != OM_RETURN_ADDR(f0)) return 0;
     151   return 1;
     152}
     153
     154int main()
     155{
     156   return test_return_addr(1, 0);
     157}
     158], ac_cv_return_addr_func_rvalue=yes, 
     159   ac_cv_return_addr_func_rvalue=no,
     160   ac_cv_return_addr_func_rvalue=no))
     161AC_MSG_RESULT($ac_cv_return_addr_func_rvalue)
     162if test "$ac_cv_return_addr_func_rvalue" = yes; then
     163  AC_DEFINE_UNQUOTED(OM_RETURN_ADDR_RVALUE)
     164fi
     165fi # "$ac_cv_return_addr_func_works" = yes;
     166fi # "${ac_cv_return_addr_func+set}" = set;
     167
     168# get function for frame address
     169if test "${with_frame_addr_func+set}" = set; then
     170if test "${with_frame_addr_func}" != no; then
     171  ac_cv_frame_addr_func=$with_frame_addr_func
     172fi
     173else
     174if test "${GCC}" = yes; then
     175  ac_cv_frame_addr_func="__builtin_frame_address"
     176fi
     177fi
     178
     179# test this function
     180if test "${ac_cv_frame_addr_func+set}" = set; then
     181AC_DEFINE_UNQUOTED(OM_FRAME_ADDR, $ac_cv_frame_addr_func)
     182# first, check whether frame addr works
     183AC_MSG_CHECKING(whether $ac_cv_frame_addr_func works)
     184AC_CACHE_VAL(ac_cv_frame_addr_func_works,
    134185AC_TRY_RUN([
    135186int test_frame_addr()
    136187{
    137    if (OM_FRAME_ADDR(1)  != 0 && OM_FRAME_ADDR(0) != 0) return 0;
     188   if (OM_FRAME_ADDR(1)  != 0 && OM_FRAME_ADDR(0) != 0 &&
     189       OM_FRAME_ADDR(1) != OM_FRAME_ADDR(0)) return 0;
    138190   return 1;
    139191}
     
    143195   return test_frame_addr();
    144196}
    145 ], ac_cv_func_frame_addr_works=yes, 
    146    ac_cv_func_frame_addr_works=no,
    147    ac_cv_func_frame_addr_works=no))
    148 AC_MSG_RESULT($ac_cv_func_frame_addr_works)
    149 
    150 if test "$ac_cv_func_frame_addr_works" = yes; then
    151 AC_DEFINE_UNQUOTED(OM_FRAME_ADDR_WORKS)
    152 fi
    153 fi  # "${ac_cv_func_frame_addr+set}" = set
    154 fi  # "$ac_cv_func_return_addr_works" = yes
    155 fi  # "${ac_cv_func_return_addr+set}" = set
     197], ac_cv_frame_addr_func_works=yes, 
     198   ac_cv_frame_addr_func_works=no,
     199   ac_cv_frame_addr_func_works=no))
     200AC_MSG_RESULT($ac_cv_frame_addr_func_works)
     201
     202if test "$ac_cv_frame_addr_func_works" = yes; then
     203AC_DEFINE(OM_FRAME_ADDR_WORKS)
     204# check whether frame addr works with rvalues
     205AC_MSG_CHECKING(whether $ac_cv_frame_addr_func takes rvalues)
     206AC_CACHE_VAL(ac_cv_frame_addr_func_rvalue,
     207AC_TRY_RUN([
     208int test_frame_addr(int f1, int f2)
     209{
     210   if (OM_FRAME_ADDR(f1)  != 0 && OM_FRAME_ADDR(f0) != 0 &&
     211       OM_FRAME_ADDR(f1) != OM_FRAME_ADDR(f0)) return 0;
     212   return 1;
     213}
     214
     215int main()
     216{
     217   return test_frame_addr(1, 0);
     218}
     219], ac_cv_frame_addr_func_rvalue=yes, 
     220   ac_cv_frame_addr_func_rvalue=no,
     221   ac_cv_frame_addr_func_rvalue=no))
     222AC_MSG_RESULT($ac_cv_frame_addr_func_rvalue)
     223if test "$ac_cv_frame_addr_func_rvalue" = yes; then
     224  AC_DEFINE_UNQUOTED(OM_FRAME_ADDR_RVALUE)
     225fi
     226fi # "$ac_cv_frame_addr_func_works" = yes;
     227fi # "${ac_cv_frame_addr_func+set}" = set;
     228
    156229fi  # "$enable_mtrack" != no;
    157230
  • omalloc/omAlloc.c

    re6908a0 r212fc04  
    44 *  Author:  obachman@mathematik.uni-kl.de (Olaf Bachmann)
    55 *  Created: 11/99
    6  *  Version: $Id: omAlloc.c,v 1.1.1.1 1999-11-18 17:45:53 obachman Exp $
     6 *  Version: $Id: omAlloc.c,v 1.2 1999-11-22 18:12:57 obachman Exp $
    77 *******************************************************************/
    88#ifndef OM_ALLOC_C
     
    2525
    2626
    27 #if 0
    28 #include "mmemory.h"
    29 #else
    3027#include <stdlib.h>
    31 #define AllocSizeOf(x) malloc(sizeof(x))
    32 #define FreeSizeOf(addr, x) free(addr)
    33 #endif
     28#define AllocSizeOf(x) _omAllocBlock(sizeof(x))
     29#define FreeSizeOf(addr, x) _omFreeBin(addr)
    3430
    3531/* Get new page and initialize */
     
    129125
    130126/* bin->current_page is empty, get new bin->current_page, return addr*/
    131 void* omAllocBinFromFullPage(omBinPage page, omBin bin)
     127void* omAllocBinFromFullPage(omBin bin)
    132128{
    133129  void* addr;
     
    135131  omAssume(bin->current_page->current == NULL);
    136132 
     133  if (bin->current_page != om_ZeroPage)
     134  {
     135    omAssume(bin->last_page != NULL);
     136    bin->current_page->used_blocks = 0;
     137  }
     138
    137139  if (bin->current_page->next != NULL)
    138140  {
     
    154156}
    155157
    156 void* omAllocBlockFromFullPage(omBinPage page, omBin bin,
    157                                const size_t size, const int zero)
    158 {
    159   void* addr;
    160  
    161   if (bin == om_LargeBin)
    162   {
    163     addr = omMallocFromSystem(size + SIZEOF_OM_ALIGNMENT);
    164     if (zero) memset(addr, 0, size);
    165     return addr;
    166   }
    167   else
    168   {
    169     addr = omAllocBinFromFullPage(page, bin);
    170     if (zero) omMemsetW(addr, 0, bin->sizeW);
    171     return addr;
    172   }
    173 }
    174158
    175159/* page->used_blocks == 0, so, either free page or reallocate to
     
    194178  else
    195179  {
    196     bin = omBinOfPage(page);
     180    bin = omGetBinOfPage(page);
    197181    if (page->current != NULL || bin->max_blocks <= 1)
    198182    {
     
    277261    s_bin->bin->current_page = om_ZeroPage;
    278262    s_bin->bin->last_page = NULL;
     263    s_bin->bin->next = NULL;
    279264    s_bin->bin->sizeW = sizeW;
    280265    s_bin->bin->max_blocks = max_blocks;
     
    396381}
    397382
    398 static void omPrintBinStat(FILE * fd, omBin bin)
     383void omPrintBinStat(FILE * fd, omBin bin)
    399384{
    400385  int pages = 0, used_blocks = 0, free_blocks = 0;
     
    432417}
    433418 
    434 #if 0   
    435419/*****************************************************************
    436420 *
     
    485469{
    486470  omBin s_bin;
    487   omCheckBin(bin);
    488471  s_bin = omGetStickyBin(bin, sticky_tag);
    489472 
     
    506489}
    507490
    508 void omUnsetStickyBinTag(omBin bin, unsigned long sticky)
     491void omUnSetStickyBinTag(omBin bin, unsigned long sticky)
    509492{
    510493  omAssume(omGetStickyBin(bin, 0) != NULL);
     
    515498static void omMergeStickyPages(omBin to_bin, omBin from_bin)
    516499{
     500#ifdef HAVE_OM_ASSUME
     501  int length = omGListLength(to_bin->last_page, prev) +
     502    omGListLength(from_bin->last_page, prev);
     503#endif 
     504 
    517505  omBinPage page = from_bin->last_page;
     506  omAssume(to_bin->sticky == 0);
     507  omAssume(to_bin->sizeW == from_bin->sizeW);
     508  omAssume(to_bin != from_bin);
     509  omAssume(omIsOnGList(to_bin->next, next, from_bin)
     510           ||
     511           omIsOnGList(from_bin->next, next, to_bin));
    518512
    519513  if (page == NULL) return;
     
    528522  if (to_bin->last_page == NULL)
    529523  {
     524    omAssume(to_bin->current_page == om_ZeroPage);
    530525    to_bin->last_page = from_bin->last_page;
    531526    to_bin->current_page = from_bin->current_page;
     
    533528  }
    534529 
     530  omAssume(to_bin->current_page != om_ZeroPage &&
     531           to_bin->current_page != NULL);
     532
    535533  if (to_bin->current_page->current != NULL)
    536534  {
     
    544542    to_bin->current_page = to_bin->current_page->prev;
    545543  }
    546  
    547   if (to_bin->current_page->prev != NULL)
    548   {
    549     to_bin->current_page->prev->next = page;
    550     page->prev = to_bin->current_page->prev;
    551   }
    552   from_bin->last_page->next = to_bin->current_page;
    553   to_bin->current_page->prev = from_bin->last_page;
     544  else
     545  {
     546    /* need to reset this here, since new current_page is going to be
     547       from_bin->current_page, and only for current_page may we have
     548       used_blocks != 0 && current == NULL */
     549    to_bin->current_page->used_blocks = 0;
     550  }
     551 
     552
     553  omAssume(to_bin->current_page != NULL &&
     554           to_bin->current_page->current == NULL &&
     555           to_bin->current_page->used_blocks == 0);
     556
     557  from_bin->last_page->next = to_bin->current_page->next;
     558  if (to_bin->current_page->next != NULL)
     559    to_bin->current_page->next->prev =  from_bin->last_page;
     560  else
     561  {
     562    omAssume(to_bin->current_page == to_bin->last_page);
     563    to_bin->last_page = from_bin->last_page;
     564  }
     565  to_bin->current_page->next = page;
     566  page->prev = to_bin->current_page;
    554567  to_bin->current_page = from_bin->current_page;
    555 }
     568 
     569#ifdef HAVE_OM_ASSUME
     570  omAssume(omGListLength(to_bin->last_page, prev) == length);
     571#endif
     572}
     573
     574#include "omDebug.h"
    556575 
    557576void omDeleteStickyBinTag(omBin bin, unsigned long sticky)
     
    559578  omBin no_sticky_bin = NULL;
    560579  omBin sticky_bin = NULL;
    561  
     580
     581  omdCheckBin(bin, 10);
    562582  if (sticky == 0)
    563583  {
     
    566586  }
    567587 
    568   omCheckBin(bin);
    569  
    570588  sticky_bin = omGetStickyBin(bin, sticky);
    571589  if (sticky_bin != NULL)
     
    575593
    576594    omMergeStickyPages(no_sticky_bin, sticky_bin);
    577     omCheckBin(no_sticky_bin);
    578595
    579596    if (bin == sticky_bin)
     
    585602    FreeSizeOf(sticky_bin, omBin_t);
    586603  }
    587   omCheckBin(bin);
     604  omdCheckBin(bin, 10);
    588605}
    589606
     
    595612*
    596613*****************************************************************/
    597 
    598 #ifdef BIN_DEBUG
    599 static BOOLEAN omIsKnownBin(omBin bin)
    600 {
    601   int i;
    602   mem_SpecBin s_bin;
    603  
    604   for (i=0; i<=MAX_BIN_INDEX; i++)
    605   {
    606     if (bin == &om_StaticBin[i]) return TRUE;
    607   }
    608  
    609   mem_SpecBin s_bin = om_SpecBins;
    610   while (s_bin != NULL)
    611   {
    612     if (s_bin->bin == bin) return TRUE;
    613     s_bin = s_bin->next;
    614   }
    615   return FALSE;
    616 }
    617 
    618 static BOOLEAN omDebugCheckAllBins(const char* fn, int l)
    619 {
    620   int i;
    621   mem_SpecBin s_bin = om_SpecBins;
    622   BOOLEAN return = TRUE;
    623   for (i=0; i<=MAX_BIN_INDEX; i++)
    624   {
    625     ret = ret && omDebugCheckBin(&(om_StaticBin[i]), fn, l);
    626   }
    627   while (s_bin != NULL)
    628   {
    629     ret = ret && omDebugCheckBin(s_bin->bin, fn, l);
    630     s_bin = s_bin->next;
    631   }
    632   return ret;
    633 }
    634 #endif
    635 
    636 
    637614unsigned long omGetNewStickyAllBinTag()
    638615{
     
    641618  omSpecBin s_bin;
    642619  // first, find new sticky tag
    643   for (i=0; i<=MAX_BIN_INDEX; i++)
     620  for (i=0; i<=OM_MAX_BIN_INDEX; i++)
    644621  {
    645622    new_sticky = omGetMaxStickyBinTag(&(om_StaticBin[i]));
    646623    if (new_sticky > sticky) sticky = new_sticky;
    647624  }
     625  s_bin = om_SpecBin;
    648626  while (s_bin != NULL)
    649627  {
     
    655633  {
    656634    sticky++;
    657     for (i=0; i<=MAX_BIN_INDEX; i++)
     635    for (i=0; i<=OM_MAX_BIN_INDEX; i++)
    658636    {
    659637      omCreateStickyBin(&(om_StaticBin[i]), sticky);
     
    671649    omBin bin;
    672650    omAssume(sticky == BIT_SIZEOF_LONG - 1);
    673     for (i=0; i<=MAX_BIN_INDEX; i++)
     651    for (i=0; i<=OM_MAX_BIN_INDEX; i++)
    674652    {
    675653      bin = &om_StaticBin[i];
     
    692670  omSpecBin s_bin = om_SpecBin;
    693671  int i;
    694   for (i=0; i<=MAX_BIN_INDEX; i++)
     672  for (i=0; i<=OM_MAX_BIN_INDEX; i++)
    695673  {
    696674    omSetStickyBinTag(&(om_StaticBin[i]), sticky);
     
    707685  omSpecBin s_bin = om_SpecBin;
    708686  int i;
    709   for (i=0; i<=MAX_BIN_INDEX; i++)
     687  for (i=0; i<=OM_MAX_BIN_INDEX; i++)
    710688  {
    711689    omUnSetStickyBinTag(&(om_StaticBin[i]), sticky);
     
    722700  omSpecBin s_bin = om_SpecBin;
    723701  int i;
    724   for (i=0; i<=MAX_BIN_INDEX; i++)
     702  for (i=0; i<=OM_MAX_BIN_INDEX; i++)
    725703  {
    726704    omDeleteStickyBinTag(&(om_StaticBin[i]), sticky);
     
    733711}
    734712
    735 #endif                       
    736 
    737713#endif /* OM_ALLOC_C */
  • omalloc/omConfig.h.in

    re6908a0 r212fc04  
    44 *  Author:  obachman (Olaf Bachmann)
    55 *  Created: 11/99
    6  *  Version: $Id: omConfig.h.in,v 1.1.1.1 1999-11-18 17:45:52 obachman Exp $
     6 *  Version: $Id: omConfig.h.in,v 1.2 1999-11-22 18:12:58 obachman Exp $
    77 *******************************************************************/
    88#ifndef OM_CONFIG_H
     
    6161#ifndef OM_FRAME_ADDR_WORKS
    6262#undef OM_FRAME_ADDR_WORKS
     63#endif
     64/* define if OM_RETURN_ADDR actually rvalue */
     65#ifndef OM_RETURN_ADDR_RVALUE
     66#undef OM_RETURN_ADDR_RVALUE
     67#endif
     68/* define if OM_FRAME_ADDR actually rvalue */
     69#ifndef OM_FRAME_ADDR_RVALUE
     70#undef OM_FRAME_ADDR_RVALUE
    6371#endif
    6472/* Define sizeof(long) */
  • omalloc/omDebug.c

    re6908a0 r212fc04  
    44 *  Author:  obachman@mathematik.uni-kl.de (Olaf Bachmann)
    55 *  Created: 11/99
    6  *  Version: $Id: omDebug.c,v 1.1.1.1 1999-11-18 17:45:53 obachman Exp $
     6 *  Version: $Id: omDebug.c,v 1.2 1999-11-22 18:12:58 obachman Exp $
    77 *******************************************************************/
    88#include "omConfig.h"
     
    1212#include "omDebug.h"
    1313
    14 static int omdCheckBinAddrSize(void* addr, omBin bin, size_t size,
    15                                int level, const char* fn, const int l);
    16 static int omdPrintBinError(const char* msg, void* addr, size_t size,omBin bin,
    17                             const char* fn, const int l);
    18 static const char* omdTestBinAddrSize(void* addr, omBin bin, size_t size,
    19                                       int level);
     14static int omdCheckBinAddrSize(void* addr, size_t size, int level);
     15static int omdPrintBinError(const char* msg, void* addr, size_t size,
     16                            omBin bin);
     17static const char* omdTestBinAddrSize(void* addr, size_t size, int level,
     18                                      omBin *bin);
    2019static const char* omdTestBin(omBin bin, int level);
    2120static const char* omdTestBinPage(omBinPage page, int level);
    22 static int   omdIsKnownBin(omBin bin);
     21static int   omdIsKnownTopBin(omBin bin);
    2322
    2423/*******************************************************************
     
    2726 * 
    2827 *******************************************************************/
    29 int omdCheckBinAddr(void* addr, omBin bin, int level,
    30                     const char* fn, const int l)
    31 {
    32   if (! omdCheckBinAddrSize(addr, bin, bin->sizeW*SIZEOF_LONG, level, fn, l))
     28int omdCheckBinAddr(void* addr, int level)
     29{
     30  return omdCheckBinAddrSize(addr, 0, level);
     31}
     32
     33int omdCheckBlockAddr(void* addr, size_t size, int level)
     34{
     35  if (size == 0)
     36  {
     37    omError("0 size");
    3338    return 0;
    34   return omdCheckBins(level - 2, fn, l);
    35 }
    36 
    37 int omdCheckBlockAddr(void* addr, size_t size, int level,
    38                       const char* fn, const int l)
    39 {
    40   omBin bin = omSize2Bin(size);
    41   if (bin != om_LargeBin &&
    42       ! omdCheckBinAddrSize(addr, bin, size, level, fn, l))
    43     return 0;
    44   return omdCheckBins(level - 2, fn, l);
    45 }
    46 
    47 int omdCheckChunkAddr(void* addr, int level, const char* fn, const int l)
     39  }
     40  if (size <= OM_MAX_BLOCK_SIZE)
     41    return omdCheckBinAddrSize(addr, size, level);
     42  else
     43    return 1;
     44}
     45
     46int omdCheckChunkAddr(void* addr, int level)
    4847{
    4948  omBinPage page;
    5049  addr = addr - SIZEOF_OM_ALIGNMENT;
    5150  page = *((omBinPage*) addr);
    52   if (page != om_LargePage &&
    53       ! omdCheckBinAddr(addr, omBinOfPage(page), level, fn, l))
    54     return 0;
    55   return omdCheckBins(level - 2, fn, l);
     51  if (page != om_LargePage)
     52    return omdCheckBinAddrSize(addr, -1, level);
     53  else
     54    return 1;
    5655}
    5756   
     
    6160 * 
    6261 *******************************************************************/
    63 static int omdIsKnownBin(omBin bin)
     62static int omdIsKnownTopBin(omBin bin)
    6463{
    6564  int i = 0;
     
    8180}
    8281
    83 int omdCheckBin(omBin bin, int level, const char* fn, const int l)
     82int omdCheckBin(omBin bin, int level)
    8483{
    8584  const char* msg = omdTestBin(bin, level);
    8685  if (msg != NULL)
    8786  {
    88     if (fn != NULL) omdPrintBinError(msg, NULL, 0, bin, fn, l);
     87    omdPrintBinError(msg, NULL, 0, bin);
    8988    return 0;
    9089  }
     
    9291}
    9392
    94 int omdCheckBins(int level, const char* fn, const int l)
     93int omdCheckBins(int level)
    9594{
    9695  if (level <= 0)
     
    106105    for (i=0; i<= OM_MAX_BIN_INDEX; i++)
    107106    {
    108       if (! omdCheckBin(&om_StaticBin[i], level, fn, l)) return 0;
     107      if (! omdCheckBin(&om_StaticBin[i], level)) return 0;
    109108    }
    110109    s_bin = om_SpecBin;
    111110    while (s_bin != NULL)
    112111    {
    113       if (! omdCheckBin(s_bin->bin, level, fn, l)) return 0;
     112      if (! omdCheckBin(s_bin->bin, level)) return 0;
    114113      s_bin = s_bin->next;
    115114    }
     
    124123 *******************************************************************/
    125124
    126 void* omdCheckAllocBin(omBin bin, const int zero, int level,
    127                        const char* fn, const int l)
     125void* omdCheckAllocBin(omBin bin, const int zero, int level)
    128126{
    129127  void* res;
    130128 
    131   omdCheckBins(level-2, fn, l);
     129  omdCheckBins(level-2);
    132130
    133131  if (zero)
     
    136134    __omTypeAllocBin(void*, res, bin);
    137135
    138   omdCheckBinAddr(res, bin, level-1,fn, l);
    139   omdCheckBins(level-2, fn, l);
     136  omdCheckBinAddr(res, level-1);
     137  omdCheckBins(level-2);
    140138
    141139  return res;
    142140}
    143141 
    144 void  omdCheckFreeBin(void* addr, omBin bin,
    145                       int level, const char* fn, const int l)
    146 {
    147   omdCheckBins(level-2, fn, l);
    148 
    149   if (omdCheckBinAddr(addr, bin, level, fn, l))
     142void  omdCheckFreeBin(void* addr, int level)
     143{
     144  omdCheckBins(level-2);
     145
     146  if (omdCheckBinAddr(addr, level))
    150147    __omFreeBin(addr);
    151148
    152   omdCheckBin(bin, level - 1, fn, l);
    153   omdCheckBins(level - 2, fn, l);
    154 }
    155 
    156 void* omdCheckAllocBlock(size_t size, const int zero,
    157                         int level, const char* fn, const int l)
     149  omdCheckBins(level - 2);
     150}
     151
     152void* omdCheckAllocBlock(size_t size, const int zero, int level)
    158153{
    159154  void* res;
     
    161156  if (level > 0 && size <= 0)
    162157  {
    163     if (fn != NULL) omdPrintBinError("requested AllocBlock size <= 0",
    164                                      NULL, size, NULL, fn, l);
     158    omdPrintBinError("requested AllocBlock size <= 0",
     159                     NULL, size, NULL);
    165160    size = 1;
    166161  }
    167162
    168   omdCheckBins(level-2, fn, l);
     163  omdCheckBins(level-2);
    169164
    170165  if (zero)
     
    173168    __omTypeAllocBlock(void*, res, size);
    174169 
    175   omdCheckBlockAddr(res, size, level - 1, fn, l);
    176   omdCheckBins(level - 2, fn, l);
     170  omdCheckBlockAddr(res, size, level - 1);
     171  omdCheckBins(level - 2);
    177172
    178173  return res;
    179174}
    180175
    181 void omdCheckFreeBlock(void* addr, size_t size,
    182                        int level, const char* fn, const int l)
    183 {
    184   omdCheckBins(level - 2, fn, l);
    185   if (! omdCheckBlockAddr(addr, size, level, fn, l)) return;
     176void omdCheckFreeBlock(void* addr, size_t size, int level)
     177{
     178  omdCheckBins(level - 2);
     179  if (! omdCheckBlockAddr(addr, size, level)) return;
    186180 
    187181  __omFreeBlock(addr, size);
    188182 
    189   omdCheckBins(level - 2, fn, l);
    190 }
    191 
    192 
    193 void* omdCheckAllocChunk(size_t size, const int zero,
    194                         int level, const char* fn, const int l)
     183  omdCheckBins(level - 2);
     184}
     185
     186
     187void* omdCheckAllocChunk(size_t size, const int zero, int level)
    195188{
    196189  void* res;
     
    198191  if (level > 0 && size <= 0)
    199192  {
    200     if (fn != NULL) omdPrintBinError("requested AllocBlock size <= 0",
    201                                      NULL, size, NULL, fn, l);
     193    omdPrintBinError("requested AllocBlock size <= 0",
     194                     NULL, size, NULL);
    202195    size = 1;
    203196  }
    204   omdCheckBins(level - 2, fn, l);
     197  omdCheckBins(level - 2);
    205198
    206199  if (zero)
     
    209202    __omTypeAllocChunk(void*, res, size);
    210203 
    211   omdCheckChunkAddr(res, level - 1, fn, l);
    212   omdCheckBins(level - 2, fn, l);
     204  omdCheckChunkAddr(res, level - 1);
     205  omdCheckBins(level - 2);
    213206
    214207  return res;
    215208}
    216209
    217 void omdCheckFreeChunk(void* addr, int level, const char* fn, const int l)
    218 {
    219   if (! omdCheckChunkAddr(addr, level, fn, l)) return;
     210void omdCheckFreeChunk(void* addr, int level)
     211{
     212  if (! omdCheckChunkAddr(addr, level)) return;
    220213 
    221214  __omFreeChunk(addr);
    222215 
    223   omdCheckBins(level - 2, fn, l);
     216  omdCheckBins(level - 2);
    224217}
    225218
     
    230223 * 
    231224 *******************************************************************/
    232 static int omdPrintBinError(const char* msg, void* addr, size_t size,omBin bin,
    233                             const char* fn, const int l)
     225static int omdPrintBinError(const char* msg, void* addr, size_t size,omBin bin)
    234226{
    235227  fprintf(stderr,
    236           "***BinError:
    237 %s: occured for addr:%p (%d) bin:%p (%ld:%ld) in %s:%d\n",
    238           msg, addr, size, (void*) bin,
     228          "for addr:%p (%d) bin:%p (%ld:%ld)\n",
     229          addr, size, (void*) bin,
    239230          (bin != NULL ? bin->max_blocks : 0),
    240           (bin != NULL ? bin->sizeW : 0), fn, l);
     231          (bin != NULL ? bin->sizeW : 0));
     232  fflush(stderr);
    241233  return 0;
    242234}
    243235
    244 static int omdCheckBinAddrSize(void* addr, omBin bin, size_t size,
    245                                int level, const char* fn, const int l)
    246 {
    247   const char* msg = omdTestBinAddrSize(addr, bin, size, level);
     236static int omdCheckBinAddrSize(void* addr, size_t size, int level)
     237{
     238  omBin bin = NULL;
     239  const char* msg = omdTestBinAddrSize(addr, size, level, &bin);
    248240  if (msg != NULL)
    249     return omdPrintBinError(msg, addr, size, bin, fn, l);
     241    return omdPrintBinError(msg, addr, size, bin);
    250242  else
    251243    return 1;
     
    255247/* Check that addr is activ (used) adr of bin */
    256248static const char*
    257 omdTestBinAddrSize(void* addr, omBin bin, size_t size, int level)
    258 {
     249omdTestBinAddrSize(void* addr, size_t size, int level, omBin* r_bin)
     250{
     251  omBin bin;
    259252  omBinPage page;
    260253  omBin h_bin;
    261254  const char* msg;
    262255 
    263 
    264256  if (level <= 0) return NULL;
    265257 
    266258  if (addr == NULL) return omError("NULL addr");
     259
     260  if (size > OM_MAX_BLOCK_SIZE) return NULL;
     261
     262  bin = omGetTopBinOfAddr(addr);
     263 
    267264  if (bin == NULL) return omError("NULL Bin");
    268265
    269   if (! omdIsKnownBin(bin))
     266  if (! omdIsKnownTopBin(bin))
    270267    return omError("Addr not from Bin (Bin unknown)");
     268  *r_bin = bin;
    271269 
    272270  if ((msg = omdTestBin(bin, level - 1)) != NULL) return msg;
    273271
    274272  // check for right bin
    275   if (omIsStaticBin(bin))
    276     h_bin = omSize2Bin(size);
    277   else
    278     h_bin = omGetSpecBin(size);
    279   if (bin != h_bin) return omError("size is wrong");
    280   if (! omIsStaticBin(bin)) omUnGetSpecBin(&h_bin);
     273  if (size > 0)
     274  {
     275    if (omIsStaticBin(bin))
     276      h_bin = omSize2Bin(size);
     277    else
     278      h_bin = omGetSpecBin(size);
     279    if (bin != h_bin) return omError("size is wrong");
     280    if (! omIsStaticBin(bin)) omUnGetSpecBin(&h_bin);
     281  }
    281282
    282283  // check page
     
    285286 
    286287  // look that page is in queue of pages of this Bin
    287   h_bin = omBinOfPage(page);
     288  h_bin = omGetBinOfPage(page);
     289  *r_bin = h_bin;
    288290  if ( ! omIsOnGList(h_bin->last_page, prev, page))
    289291    return omError("page of addr not from this Bin");
     
    347349  {
    348350    void* current = page->current;
     351    int i = 1;
    349352    if (current != NULL &&
    350353        omListLength(current) != bin->max_blocks - page->used_blocks - 1)
     
    362365           != 0)
    363366        return omError("current has unaligned adress");
    364       current = *((void**) (current + SIZEOF_VOIDP));
     367      current = *((void**) current);
     368      i++;
    365369    }
    366370  }
     
    379383  if (bin == NULL) return omError("NULL Bin");
    380384
    381   if (! omdIsKnownBin(bin)) return omError("Bin unknown");
     385  if (! omdIsKnownTopBin(bin)) return omError("TopBin unknown");
    382386 
    383387  if (level > 2 &&
     
    440444        return omError("Sticky of page wrong");
    441445
    442       if (omBinOfPage(page) != bin)
     446      if (omGetBinOfPage(page) != bin)
    443447        return omError("Bin of Page wrong");
    444448       
     
    457461        {
    458462          if (page->current == NULL ||
    459               page->used_blocks == 0 ||
     463              page->used_blocks < 0 ||
    460464              page->used_blocks == bin->max_blocks - 1)
    461465            return omError("used_blocks and current of upage out of sync");
  • omalloc/omDebug.h

    re6908a0 r212fc04  
    44 *  Author:  obachman@mathematik.uni-kl.de (Olaf Bachmann)
    55 *  Created: 11/99
    6  *  Version: $Id: omDebug.h,v 1.1.1.1 1999-11-18 17:45:53 obachman Exp $
     6 *  Version: $Id: omDebug.h,v 1.2 1999-11-22 18:12:58 obachman Exp $
    77 *******************************************************************/
    8 int omdCheckBinAddr(void* addr, omBin bin,
    9                     int level, const char* fn, const int l);
    10 int omdCheckBlockAddr(void* addr, size_t size, 
    11                       int level, const char* fn, const int l);
    12 int omCheckChunkAddr(void* adr, const char* fn, const int l);
     8int omdCheckBinAddr(void* addr, int level);
     9int omdCheckBlockAddr(void* addr, size_t size, int level);
     10int omdCheckChunkAddr(void* adr, int level);
    1311
    14 int omdCheckBin(omBin bin, int level, const char* fn, const int l);
    15 int omdCheckBins(int level, const char* fn, const int l);
     12int omdCheckBin(omBin bin, int level);
     13int omdCheckBins(int level);
    1614
    17 void* omdCheckAllocBin(omBin bin, int zero,
    18                        int level, const char* fn, const int l);
    19 void  omdCheckFreeBin(void* addr,  omBin bin,
    20                       int level, const char* fn, int l);
    21 void* omdCheckAllocBlock(size_t size, int zero, 
    22                          int level, const char* fn, const int l);
    23 void  omdCheckFreeBlock(void* addr, size_t size, 
    24                         int level, const char* fn, const int l);
    25 void* omdCheckAllocChunk(size_t size, int zero, 
    26                          int level, const char* fn, const int l);
    27 void omdCheckFreeChunk(void* addr, int level, const char* fn, const int l);
     15void* omdCheckAllocBin(omBin bin, int zero,int level);
     16void  omdCheckFreeBin(void* addr,  int level);
     17void* omdCheckAllocBlock(size_t size, int zero, int level);
     18void  omdCheckFreeBlock(void* addr, size_t size, int level);
     19void* omdCheckAllocChunk(size_t size, int zero, int level);
     20void omdCheckFreeChunk(void* addr, int level);
    2821
    2922
  • omalloc/omList.c

    re6908a0 r212fc04  
    44 *  Author:  obachman (Olaf Bachmann)
    55 *  Created: 11/99
    6  *  Version: $Id: omList.c,v 1.1.1.1 1999-11-18 17:45:53 obachman Exp $
     6 *  Version: $Id: omList.c,v 1.2 1999-11-22 18:12:59 obachman Exp $
    77 *******************************************************************/
    88#ifndef NULL
     
    157157    void* curr = NEXT(list);
    158158   
    159     while (curr != NULL && VALUE(list, long_field) < what)
     159    while (curr != NULL && VALUE(curr, long_field) < what)
    160160    {
    161161      prev = curr;
  • omalloc/omLocal.c

    re6908a0 r212fc04  
    55 *  Author:  obachman (Olaf Bachmann)
    66 *  Created: 11/99
    7  *  Version: $Id: omLocal.c,v 1.1.1.1 1999-11-18 17:45:53 obachman Exp $
     7 *  Version: $Id: omLocal.c,v 1.2 1999-11-22 18:12:59 obachman Exp $
    88 *******************************************************************/
    99
     
    1313#include "omLocal.h"
    1414#include "omPage.h"
     15#include "omTrack.h"
    1516
    16 const char* omReportError(const char* msg, const char* file, const int line)
     17const char* omReportError(const char* msg)
    1718{
    18   fprintf(stderr, "***Error: %s in %s:%d\n", msg, file, line);
     19  fprintf(stderr, "***Error: %s: occured at \n", msg);
     20  omPrintCurrentBackTrace(1, 20, stderr);
    1921  return msg;
    2022}
  • omalloc/omLocal.h

    re6908a0 r212fc04  
    55 *  Author:  obachman (Olaf Bachmann)
    66 *  Created: 11/99
    7  *  Version: $Id: omLocal.h,v 1.1.1.1 1999-11-18 17:45:52 obachman Exp $
     7 *  Version: $Id: omLocal.h,v 1.2 1999-11-22 18:12:59 obachman Exp $
    88 *******************************************************************/
    99#ifndef OM_LOCAL_H
     
    4444  (page)->bin_sticky= (void*)((unsigned long)sticky + (unsigned long)bin)
    4545
     46#define omGetTopBinOfAddr(addr) \
     47  omGetTopBinOfPage(((omBinPage) omGetPageOfAddr(addr)))
    4648
    4749#if defined(OM_INLINE) || defined(OM_ALLOC_C)
    48 OM_INLINE omBin omBinOfPage(omBinPage page)
     50OM_INLINE omBin omGetBinOfPage(omBinPage page)
    4951{
    5052  unsigned long sticky = omGetStickyOfPage(page);
     
    5759  return bin;
    5860}
     61OM_INLINE omBin omGetBinOfAddr(void* addr)
     62{
     63  return omGetBinOfPage(omGetPageOfAddr(addr));
     64}
    5965#else
    60 extern omBin omBinOfPage(omBinPage page);
     66extern omBin omGetBinOfPage(omBinPage page);
     67extern omBin omGetBinOfAddr(void* addr);
    6168#endif /* defined(OM_INLINE) || defined(OM_ALLOC_C) */
    6269
     
    6976extern int omIsStaticBin(omBin bin);
    7077extern void omPrintBinStats(FILE* fd);
     78extern void omPrintBinStat(FILE * fd, omBin bin);
    7179
    7280/*******************************************************************
     
    7785#ifndef HAVE_OM_ASSUME
    7886
    79 #define omError(msg)    (msg)
    8087#define omAssume(x) ((void) 0)
    8188
    8289#else /* ! HAVE_OM_ASSUME */
    8390
    84 extern const char* omReportError(const char* msg,
    85                                  const char* file, const int line);
    86 
    87 #define omError(msg)  omReportError(msg, __FILE__, __LINE__)
    88 #define omAssume(x)   _omAssume(x, __FILE__, __LINE__) 
    89 
    90 #define _omAssume(x, f, l)                      \
     91#define omAssume(x)                             \
    9192do                                              \
    9293{                                               \
    9394  if (! (x))                                    \
    9495  {                                             \
    95     omReportError("omAssume violation", f, l);  \
     96    omReportError("omAssume violation");        \
    9697  }                                             \
    9798}                                               \
     
    99100
    100101#endif /* HAVE_OM_ASSUME */
     102
     103extern const char* omReportError(const char* msg);
     104#define omError(msg)  omReportError(msg)
    101105
    102106/*******************************************************************
  • omalloc/omPrivate.h

    re6908a0 r212fc04  
    55 *  Author:  obachman (Olaf Bachmann)
    66 *  Created: 11/99
    7  *  Version: $Id: omPrivate.h,v 1.1.1.1 1999-11-18 17:45:53 obachman Exp $
     7 *  Version: $Id: omPrivate.h,v 1.2 1999-11-22 18:12:59 obachman Exp $
    88 *******************************************************************/
    99#ifndef OM_PRIVATE_H
     
    1111
    1212#include <stdlib.h>
     13#include <string.h>
     14
    1315/*******************************************************************
    1416 * 
     
    100102 
    101103
    102 #define omSize2Bin(size) \
    103   ((size) <= OM_MAX_BLOCK_SIZE ? \
    104    om_Size2Bin[((size) -1) >> LOG_SIZEOF_OM_ALIGNMENT] : \
    105    om_LargeBin)
    106104
    107105/*******************************************************************
     
    110108 * 
    111109 *******************************************************************/
    112 extern void* omAllocBinFromFullPage(omBinPage page, omBin bin);
    113 extern void* omAllocBlockFromFullPage(omBinPage page, omBin bin,
    114                                       const size_t size, const int zero);
     110extern void* omAllocBinFromFullPage(omBin bin);
    115111extern void  omFreeToPageFault(omBinPage page, void* addr);
    116112
     
    133129do                                              \
    134130{                                               \
    135   if ((page)->used_blocks > 0)                 \
     131  if ((page)->used_blocks > 0)                  \
    136132  {                                             \
    137133    *((void**)addr) = (page)->current;          \
     
    148144
    149145/*******************************************************************/
    150 /* Bin                                                            */
    151 #define __omTypeAllocBin(type, addr, bin)             \
     146/* Bin                                                             */
     147#define __omTypeAllocBin(type, addr, bin)               \
    152148do                                                      \
    153149{                                                       \
    154   register omBinPage __om_page = (bin)->current_page; \
     150  register omBinPage __om_page = (bin)->current_page;   \
    155151  if (__om_page->current != NULL)                       \
    156152    __omTypeAllocFromPage(type, addr, __om_page);       \
    157153  else                                                  \
    158     addr = (type) omAllocBinFromFullPage(__om_page, bin); \
     154    addr = (type) omAllocBinFromFullPage(bin);          \
    159155}                                                       \
    160156while (0)
    161157
    162 #define __omTypeAlloc0Bin(type, addr, bin)    \
    163 do                                              \
    164 {                                               \
    165   __omTypeAllocBin(type, addr, bin);          \
    166   omMemsetW(addr, 0, (bin)->sizeW);            \
    167 }                                               \
    168 while (0)
    169 
    170 #define __omFreeBin(addr)                                      \
     158#define __omTypeAlloc0Bin(type, addr, bin)      \
     159do                                              \
     160{                                               \
     161  __omTypeAllocBin(type, addr, bin);            \
     162  omMemsetW(addr, 0, (bin)->sizeW);             \
     163}                                               \
     164while (0)
     165
     166#define __omFreeBin(addr)                                       \
    171167do                                                              \
    172168{                                                               \
    173169  register void* __om_addr = (void*) (addr);                    \
    174   register omBinPage __om_page = omGetPageOfAddr(__om_addr);   \
     170  register omBinPage __om_page = omGetPageOfAddr(__om_addr);    \
    175171  __omFreeToPage(__om_addr, __om_page);                         \
    176172}                                                               \
     
    180176/*******************************************************************/
    181177/* Block                                                           */
    182 #define ___omTypeAllocBlock(type, addr, size, init, action_zero, action_init)   \
    183 do                                                                              \
    184 {                                                                               \
    185   omBin ___om_bin = omSize2Bin(size);                                           \
    186   register omBinPage ___om_page = ___om_bin->current_page;                      \
    187   if (___om_page->current != NULL)                                              \
    188   {                                                                             \
    189     __omTypeAllocFromPage(type, addr, ___om_page);                              \
    190     action_zero                                                                 \
    191   }                                                                             \
    192   else                                                                          \
    193   {                                                                             \
    194     addr = (type) omAllocBlockFromFullPage(___om_page, ___om_bin, size, init);  \
    195   }                                                                             \
    196   action_init                                                                   \
    197 }                                                                               \
    198 while (0)
     178#define omSmallSize2Bin(size) om_Size2Bin[((size) -1) >> LOG_SIZEOF_OM_ALIGNMENT]
     179#define omSize2Bin(size) ((size) <= OM_MAX_BLOCK_SIZE ? omSmallSize2Bin(size) : om_LargeBin)
     180
     181#define omAllocLargeBlock(size)       OM_MALLOC(size)
     182#define omFreeLargeBlock(addr, size)  OM_FREE(addr)
    199183
    200184#define __omTypeAllocBlock(type, addr, size)    \
    201185do                                              \
    202186{                                               \
    203   ___omTypeAllocBlock(type, addr, size, 0, ,);   \
    204 }                                               \
    205 while (0)
    206 
    207 #define __omTypeAlloc0Block(type, addr, size)                   \
    208 do                                                              \
    209 {                                                               \
    210   ___omTypeAllocBlock(type, addr, size, 1,                      \
    211                       omMemsetW(addr, 0, ___om_bin->sizeW);, );   \
    212 }                                                               \
     187  if (size <= OM_MAX_BLOCK_SIZE)                \
     188  {                                             \
     189    omBin __om_bin = omSmallSize2Bin(size);     \
     190    __omTypeAllocBin(type, addr, __om_bin);     \
     191  }                                             \
     192  else                                          \
     193  {                                             \
     194    addr = (type) omAllocLargeBlock(size);      \
     195  }                                             \
     196}                                               \
     197while(0)
     198
     199#define __omTypeAlloc0Block(type, addr, size)   \
     200do                                              \
     201{                                               \
     202  if (size <= OM_MAX_BLOCK_SIZE)                \
     203  {                                             \
     204    omBin __om_bin = omSmallSize2Bin(size);     \
     205    __omTypeAlloc0Bin(type, addr, __om_bin);    \
     206  }                                             \
     207  else                                          \
     208  {                                             \
     209    addr = (type) omAllocLargeBlock(size);      \
     210    memset(addr, 0, size);                      \
     211  }                                             \
     212}                                               \
    213213while (0)
    214214
     
    216216do                                              \
    217217{                                               \
    218   omBin _om_bin = omSize2Bin(size);          \
    219   omBinPage _om_page = _om_bin->current_page; \
    220   __omFreeToPage(addr, _om_page);               \
    221 }                                               \
    222 while (0)
    223 
     218  if (size <= OM_MAX_BLOCK_SIZE)                \
     219  {                                             \
     220    __omFreeBin(addr);                          \
     221  }                                             \
     222  else                                          \
     223  {                                             \
     224    omFreeLargeBlock(addr, size);               \
     225  }                                             \
     226}                                               \
     227while (0)
    224228
    225229/*******************************************************************/
    226230/* Chunk                                                           */
    227 #define ___omTypeAllocChunk(type, addr, size, init, action_init)                    \
    228 do                                                                                  \
    229 {                                                                                   \
    230   void* ___om_addr;                                                                 \
    231   size_t ___om_size = (size) + SIZEOF_OM_ALIGNMENT;                                 \
    232   ___omTypeAllocBlock(void*, ___om_addr, ___om_size, init,                          \
    233                       action_init,                                                  \
    234                       *((void**) ___om_addr) = (void*) ___om_bin->current_page;);   \
    235   addr = (type) (___om_addr + SIZEOF_OM_ALIGNMENT);                                 \
    236 }                                                                                   \
    237 while (0)
    238 
    239 #define __omTypeAllocChunk(type, addr, size) \
    240   ___omTypeAllocChunk(type, addr, size, 0,)
    241 
    242 #define __omTypeAlloc0Chunk(type, addr, size) \
    243   ___omTypeAllocChunk(type, addr, size, 1, omMemsetW(___om_addr, 0, ___om_bin->sizeW);)
     231#define omAllocLargeChunk(size)  OM_MALLOC(size)
     232#define omFreeLargeChunk(addr)   OM_FREE(addr)
     233 
     234#define __omTypeAllocChunk(type, addr, size)                \
     235do                                                          \
     236{                                                           \
     237  void* __om_addr;                                          \
     238  size_t __om_size = (size) + SIZEOF_OM_ALIGNMENT;          \
     239  if (__om_size <= OM_MAX_BLOCK_SIZE)                       \
     240  {                                                         \
     241    omBin __om_bin = omSmallSize2Bin(__om_size);                 \
     242    __omTypeAllocBin(void*, __om_addr, __om_bin);           \
     243    *((void**) __om_addr) = (void*) __om_bin->current_page; \
     244  }                                                         \
     245  else                                                      \
     246  {                                                         \
     247    __om_addr = omAllocLargeChunk(__om_size);               \
     248    *((void**) __om_addr) = om_LargePage;                   \
     249  }                                                         \
     250  addr = (type) (__om_addr + SIZEOF_OM_ALIGNMENT);          \
     251}                                                           \
     252while (0)
     253
     254#define __omTypeAlloc0Chunk(type, addr, size)               \
     255do                                                          \
     256{                                                           \
     257  void* __om_addr;                                          \
     258  size_t __om_size = (size) + SIZEOF_OM_ALIGNMENT;          \
     259  if (__om_size <= OM_MAX_BLOCK_SIZE)                       \
     260  {                                                         \
     261    omBin __om_bin = omSmallSize2Bin(__om_size);            \
     262    __omTypeAlloc0Bin(void*, __om_addr, __om_bin);          \
     263    *((void**) __om_addr) = (void*) __om_bin->current_page; \
     264  }                                                         \
     265  else                                                      \
     266  {                                                         \
     267    __om_addr = omAllocLargeChunk(__om_size);               \
     268    memset(__om_addr, 0, __om_size);                        \
     269    *((void**) __om_addr) = om_LargePage;                   \
     270  }                                                         \
     271  addr = (type) (__om_addr + SIZEOF_OM_ALIGNMENT);          \
     272}                                                           \
     273while (0)
    244274
    245275#define __omFreeChunk(addr)                                 \
     
    247277{                                                           \
    248278  void* __addr = ((void*) (addr)) - SIZEOF_OM_ALIGNMENT;    \
    249   omBinPage __om_page = *((omBinPage*) __addr);               \
     279  omBinPage __om_page = *((omBinPage*) __addr);             \
    250280  __omFreeToPage(__addr, __om_page);                        \
    251281}                                                           \
     
    314344omBin omGetSpecBin(size_t size);
    315345void  omUnGetSpecBin(omBin *bin);
     346unsigned long omGetNewStickyAllBinTag();
     347void omSetStickyAllBinTag(unsigned long sticky);
     348void omUnSetStickyAllBinTag(unsigned long sticky);
     349void omDeleteStickyAllBinTag(unsigned long sticky);
    316350
    317351#endif /* ! OM_GENERATE_INC */
  • omalloc/omTest.c

    re6908a0 r212fc04  
    77#include "omFindExec.h"
    88
     9#define MAX_SIZE 1024
     10#define D_LEVEL 10
     11
    912struct TestAddr_s;
    1013typedef struct TestAddr_s TestAddr_t;
     
    1720};
    1821
    19 #define D_LEVEL 10
    20 TestAddr bin_addr_list = NULL;
    21 TestAddr block_addr_list = NULL;
    22 TestAddr chunk_addr_list = NULL;
    23 
     22TestAddr bin_addr_list[MAX_SIZE >> 2];
     23TestAddr block_addr_list[MAX_SIZE >> 2];
     24TestAddr chunk_addr_list[MAX_SIZE >> 2];
     25omBin    bin_list[MAX_SIZE >> 2];
     26
     27void InitLists()
     28{
     29  int i;
     30  for (i=0; i<MAX_SIZE >> 2; i++)
     31  {
     32    bin_addr_list[i] = NULL;
     33    block_addr_list[i] = NULL;
     34    chunk_addr_list[i] = NULL;
     35/*    bin_list[i] = omGetSpecHeap(i*4); */
     36  }
     37}
     38 
     39#if D_LEVEL == 0
     40#define ALLOC_CHUNK(size)       _omAllocChunk(size)
     41#define ALLOC_BLOCK(size)       _omAllocBlock(size)
     42#define ALLOC_BIN(size)         _omAllocBin(omGetSpecBin(size))
     43#define FREE_BIN(addr)          _omFreeBin(addr)
     44#define FREE_BLOCK(addr, size)  _omFreeBlock(addr, size)
     45#define FREE_CHUNK(addr)        _omFreeChunk(addr)
     46#define omPrintBinStats(fd)     ((void)0)
     47#elif D_LEVEL > 0
     48#define ALLOC_CHUNK(size)       omdCheckAllocChunk(size, 0, D_LEVEL)
     49#define ALLOC_BLOCK(size)       omdCheckAllocBlock(size, 0, D_LEVEL)
     50#define ALLOC_BIN(size)         omdCheckAllocBin(omGetSpecBin(size), 0, D_LEVEL)
     51#define FREE_BIN(addr)          omdCheckFreeBin(addr, D_LEVEL)
     52#define FREE_BLOCK(addr, size)  omdCheckFreeBlock(addr, size, D_LEVEL)
     53#define FREE_CHUNK(addr)        omdCheckFreeChunk(addr, D_LEVEL)
     54#else
     55#define ALLOC_CHUNK(size)       malloc(size)
     56#define ALLOC_BLOCK(size)       malloc(size)
     57#define ALLOC_BIN(size)         malloc(size)
     58#define FREE_BIN(addr)          free(addr)
     59#define FREE_BLOCK(addr, size)  free(addr)
     60#define FREE_CHUNK(addr)        free(addr)
     61#define omPrintBinStats(fd)     ((void)0)
     62#endif
     63
     64#if 0
     65void TestAddrs()
     66{
     67  TestAddr addr;
     68 
     69  addr = bin_addr_list;
     70  while (addr != NULL)
     71  {
     72    omdCheckBinAddr(addr, omGetSpecBin(addr->size), 2);
     73    if (omIsOnList(addr->next, addr)) omError("addr on own list");
     74    if (omIsOnList(block_addr_list, addr)) omError("addr on block_list");
     75    if (omIsOnList(chunk_addr_list, addr)) omError("addr on chunck_list");
     76    addr = addr->next;
     77  }
     78  addr = block_addr_list;
     79  while (addr != NULL)
     80  {
     81    omdCheckBlockAddr(addr, addr->size, 2);
     82    if (omIsOnList(addr->next, addr)) omError("addr on own list");
     83    if (omIsOnList(chunk_addr_list, addr)) omError("addr on chunck_list");
     84    addr = addr->next;
     85  }
     86  addr = chunk_addr_list;
     87  while (addr != NULL)
     88  {
     89    omdCheckChunkAddr(addr, 2);
     90    if (omIsOnList(addr->next, addr)) omError("addr on own list");
     91    addr = addr->next;
     92  }
     93}
     94#else
     95#define TestAddrs() ((void)0)
     96#endif
     97 
     98 
    2499void TestAllocChunk(size_t size)
    25100{
    26101  TestAddr addr =
    27     (TestAddr) omdCheckAllocChunk(size, 0, D_LEVEL, __FILE__, __LINE__);
     102    (TestAddr) ALLOC_CHUNK(size);
    28103  addr->size = size;
    29   chunk_addr_list = omInsertInSortedList(chunk_addr_list, size, addr);
     104  addr->next = chunk_addr_list[size >> 2];
     105  chunk_addr_list[size >> 2] = addr;
    30106}
    31107
    32108void TestFreeChunk(size_t size)
    33109{
    34   TestAddr addr = omFindInSortedList(chunk_addr_list, size, size);
     110  TestAddr addr = chunk_addr_list[size >> 2];
     111  TestAddr a2;
    35112  if (addr != NULL)
    36     chunk_addr_list = omRemoveFromList(chunk_addr_list, addr);
    37   omdCheckFreeChunk(addr, D_LEVEL, __FILE__, __LINE__);
     113  {
     114    if (addr->next != NULL)
     115    {
     116      while (addr->next->next != NULL) addr = addr->next;
     117      a2 = addr->next;
     118      addr->next = NULL;
     119      FREE_CHUNK((void*)a2);
     120    }
     121    else
     122    {
     123      FREE_CHUNK(addr);
     124      chunk_addr_list[size >> 2] = NULL;
     125    }
     126  }
    38127}
    39128
    40129void FreeAllChunk()
    41130{
     131  int i;
     132  for (i=0; i<MAX_SIZE >> 2; i++)
     133  {
     134    while (chunk_addr_list[i] != NULL) TestFreeChunk(i*4);
     135  }
     136}
     137
     138void TestAllAddrs()
     139{
     140  int i;
    42141  TestAddr addr;
    43   while (chunk_addr_list != NULL)
    44   {
    45     addr = chunk_addr_list;
    46     chunk_addr_list = chunk_addr_list->next;
    47     omdCheckFreeChunk(addr, D_LEVEL, __FILE__, __LINE__);
    48   }
    49 }
    50 
     142  for (i=0; i<MAX_SIZE >> 2; i++)
     143  {
     144    addr = chunk_addr_list[i];
     145    while (addr != NULL)
     146    {
     147      omdCheckChunkAddr(addr, D_LEVEL);
     148      addr = addr->next;
     149    }
     150  }
     151}
     152 
     153 
     154#if 0
    51155void TestAllocBlock(size_t size)
    52156{
    53157  TestAddr addr =
    54     (TestAddr) omdCheckAllocBlock(size, 0, D_LEVEL, __FILE__, __LINE__);
     158    (TestAddr) ALLOC_BLOCK(size);
    55159  addr->size = size;
    56160  block_addr_list = omInsertInSortedList(block_addr_list, size, addr);
     
    61165  TestAddr addr = omFindInSortedList(block_addr_list, size, size);
    62166  if (addr != NULL)
     167  {
    63168    block_addr_list = omRemoveFromList(block_addr_list, addr);
    64   omdCheckFreeBlock(addr, addr->size,D_LEVEL, __FILE__, __LINE__);
     169    FREE_BLOCK(addr, addr->size);
     170  }
    65171}
    66172
     
    72178    addr = block_addr_list;
    73179    block_addr_list = block_addr_list->next;
    74     omdCheckFreeBlock(addr, addr->size, D_LEVEL, __FILE__, __LINE__);
     180    FREE_BLOCK(addr, addr->size);
    75181  }
    76182}
     
    78184void TestAllocBin(size_t size)
    79185{
    80   omBin bin = omGetSpecBin(size<5?5:size);
    81186  TestAddr addr =
    82     (TestAddr) omdCheckAllocBin(bin, 0, D_LEVEL, __FILE__, __LINE__);
     187    (TestAddr) ALLOC_BIN(size);
    83188  addr->size = size;
    84189  bin_addr_list = omInsertInSortedList(bin_addr_list, size, addr);
     
    87192void TestFreeBin(size_t size)
    88193{
    89   omBin bin;
    90194  TestAddr addr = omFindInSortedList(bin_addr_list, size, size);
    91195  if (addr != NULL)
     196  {
    92197    bin_addr_list = omRemoveFromList(bin_addr_list, addr);
    93   bin = omGetSpecBin(addr->size);
    94   omdCheckFreeBin(addr, bin, D_LEVEL, __FILE__, __LINE__);
     198    FREE_BIN(addr);
     199  }
    95200}
    96201 
     
    98203{
    99204  TestAddr addr;
    100   omBin bin;
    101205  while (bin_addr_list != NULL)
    102206  {
    103207    addr = bin_addr_list;
    104208    bin_addr_list = bin_addr_list->next;
    105     bin = omGetSpecBin(addr->size);
    106     omdCheckFreeBin(addr, bin, D_LEVEL, __FILE__, __LINE__);
    107   }
    108 }
    109 
    110 int count = 0;
     209    FREE_BIN(addr);
     210  }
     211}
     212#else
     213#define TestAllocBin(p) TestAllocChunk(p)
     214#define TestFreeBin(p)  TestFreeChunk(p)
     215#define FreeAllBin() FreeAllChunk()
     216
     217#define TestAllocBlock(p) TestAllocChunk(p)
     218#define TestFreeBlock(p)  TestFreeChunk(p)
     219#define FreeAllBlock() FreeAllChunk()
     220#endif
     221
     222
    111223int InitSizeGen(int i)
    112224{
    113   return 0;
     225  int size;
     226  srand(1);
     227  size = 1 + (int) ( ((double) MAX_SIZE)* rand()/(RAND_MAX + 1.0));
     228  if (size < 8) return 8;
     229  return size;
    114230}
    115231
    116232int NextSizeGen(int prev)
    117233{
    118   return ++count % 1024;
     234  int size;
     235  size = 1 + (int) ( ((double) MAX_SIZE) * rand()/(RAND_MAX + 1.0));
     236#if D_LEVEL > 4
     237  printf("%d:", size);
     238#endif
     239  fflush(stdout);
     240  if (size < 8) return 8;
     241  return size;
    119242}
    120243
    121244void PrintTest()
    122245{
    123   omPrintCurrentBackTrace(0, 10, stdout);
     246  omError("sub");
    124247}
    125248
    126249int main(int argc, char* argv[])
    127250{
    128   int limit, i, size;
     251  int limit, i, size, free_all;
    129252  omInitTrack(argv[0]);
    130  
    131   omPrintCurrentBackTrace(0, 10, stdout);
    132   PrintTest();
    133   return 0;
    134  
     253#if 0
     254  void *a1, *a2, *a3, *a4, *a5;
     255  omBin bin = omGetSpecBin(5000);
     256 
     257 
     258  a1 = omdCheckAllocBin(bin, 0, D_LEVEL);
     259  a2 = omdCheckAllocBin(bin, 0, D_LEVEL);
     260  a3 = omdCheckAllocBin(bin, 0, D_LEVEL);
     261  a4 = omdCheckAllocBin(bin, 0, D_LEVEL);
     262  a5 = omdCheckAllocBin(bin, 0, D_LEVEL);
     263 
     264  omPrintBinStats(stdout);
     265  omdCheckFreeBin(a1, bin, D_LEVEL);
     266  omPrintBinStats(stdout);
     267  omdCheckFreeBin(a5, bin, D_LEVEL);
     268  omPrintBinStats(stdout);
     269  omdCheckFreeBin(a2, bin, D_LEVEL);
     270  omPrintBinStats(stdout);
     271  omdCheckFreeBin(a3, bin, D_LEVEL);
     272  omPrintBinStats(stdout);
     273  omdCheckFreeBin(a4, bin, D_LEVEL);
     274  omPrintBinStats(stdout);
     275
     276  return(0);
     277#endif
     278  InitLists();
    135279  if (argc > 1)
    136280    sscanf(argv[1], "%d", &limit);
    137281  else
    138282    limit = 200;
     283
     284  if (argc > 2)
     285    sscanf(argv[2], "%d", &free_all);
     286  else
     287    free_all = 10000;
    139288 
    140289  size = InitSizeGen(limit);
    141290  i = 0;
    142291 
    143   for (i=0; i<= limit; i++)
     292  for (i=1; i<= limit; i++)
    144293  {
    145294    size = NextSizeGen(size);
    146295    TestAllocBin(size);
     296    TestAddrs();
    147297    TestAllocBlock(size);
     298    TestAddrs();
    148299    TestAllocChunk(size);
     300    TestAddrs();
    149301    size = NextSizeGen(size);
    150302    TestAllocBin(size);
     303    TestAddrs();
    151304    TestAllocBlock(size);
     305    TestAddrs();
    152306    TestAllocChunk(size);
     307    TestAddrs();
    153308    TestFreeBin(size);
     309    TestAddrs();
    154310    TestFreeBlock(size);
     311    TestAddrs();
    155312    TestFreeChunk(size);
     313    TestAddrs();
     314   
     315    if (i % 300 == 0)
     316    {
     317      omdCheckBins(D_LEVEL);
     318      TestAllAddrs();
     319      omDeleteStickyAllBinTag(1);
     320      printf("DeleteSticky\n");
     321      omdCheckBins(D_LEVEL);
     322      TestAllAddrs();
     323    }
     324    else if (i % 200 == 0)
     325    {
     326      omdCheckBins(D_LEVEL);
     327      TestAllAddrs();
     328      omUnSetStickyAllBinTag(1);
     329      printf("UnSetSticky");
     330      TestAllAddrs();
     331      omdCheckBins(D_LEVEL);
     332    }
     333    else if (i % 100 == 0)
     334    {
     335      omdCheckBins(D_LEVEL);
     336      TestAllAddrs();
     337      omSetStickyAllBinTag(1);
     338      printf("SetSticky");
     339      omdCheckBins(D_LEVEL);
     340      TestAllAddrs();
     341    }
    156342   
    157343    if (i % 100 == 0)
     
    159345      printf("i=%d\n",i);
    160346      omPrintBinStats(stdout);
    161     }
    162   }
     347      if (i % free_all == 0)
     348      {
     349        printf("\nFreeAllChunk\n");
     350        FreeAllChunk();
     351#if 0
     352        omPrintBinStats(stdout);
     353        if (i % 20000 == 0)
     354        {
     355          printf("\nFreeAllBlock\n");
     356          FreeAllBlock();
     357          omPrintBinStats(stdout);
     358          if (i % 40000 == 0)
     359          {
     360            printf("\nFreeAllBin\n");
     361            FreeAllBin();
     362            omPrintBinStats(stdout);
     363          }
     364        }
     365#endif
     366      }
     367    }
     368  }
     369  omPrintBinStats(stdout);
     370  FreeAllBlock();
     371  omPrintBinStats(stdout);
     372  FreeAllChunk();
    163373  omPrintBinStats(stdout);
    164374  FreeAllBin();
    165375  omPrintBinStats(stdout);
    166   FreeAllBlock();
    167   omPrintBinStats(stdout);
    168   FreeAllChunk();
    169   omPrintBinStats(stdout);
    170376  return 0;
    171377}
  • omalloc/omTrack.c

    re6908a0 r212fc04  
    44 *  Author:  obachman (Olaf Bachmann)
    55 *  Created: 11/99
    6  *  Version: $Id: omTrack.c,v 1.1.1.1 1999-11-18 17:45:53 obachman Exp $
     6 *  Version: $Id: omTrack.c,v 1.2 1999-11-22 18:13:00 obachman Exp $
    77 *******************************************************************/
    88#include <limits.h>
     
    1616#endif
    1717
    18 static char* om_this_prog = NULL;
    19 static void* om_this_main_frame_addr = NULL;
    20 static void* om_this_prog_min_return_addr = ((void*) 1023);
    21 static void* om_this_prog_max_return_addr = ((void*) ULONG_MAX -1);
    22 
    23 
    24 void omInitTrack(const char* argv0)
    25 {
    26   char buf[MAXPATHLEN];
    27  
    28   if (argv0 != NULL && omFindExec(argv0, buf))
    29   {
    30     __omTypeAllocChunk(char*, om_this_prog, strlen(buf));
    31     strcpy(om_this_prog, buf);
    32   }
    33 #if defined(OM_FRAME_ADDR_WORKS)
    34   om_this_main_frame_addr = OM_FRAME_ADDR(1);
    35 #endif
    36 #if defined(OM_PROG_NM) && defined(HAVE_POPEN)
    37   if (om_this_prog != NULL)
    38   {
    39     char command[MAXPATHLEN + 30];
    40     FILE *pipe;
    41     sprintf(command, "%s -n %s", OM_PROG_NM, om_this_prog);
    42    
    43     pipe = popen(command, "r");
    44     if (pipe != NULL)
    45     {
    46       /* serach for first address */
    47       int c;
    48       void* nm_addr;
    49       while ( (c=fgetc(pipe)) !=  EOF)
    50       {
    51         if (c == '\n')
    52         {
    53           if (fscanf(pipe, "%p", &nm_addr) &&
    54               (unsigned long) nm_addr >
    55               (unsigned long) om_this_prog_min_return_addr)
    56           {
    57             om_this_prog_min_return_addr = nm_addr;
    58             break;
    59           }
    60         }
    61       }
    62       om_this_prog_max_return_addr = nm_addr;
    63       while ( (c=fgetc(pipe)) !=  EOF)
    64       {
    65         if (c == '\n')
    66         {
    67           if (fscanf(pipe, "%p", &nm_addr) && nm_addr != NULL &&
    68               (unsigned long) nm_addr  >
    69               (unsigned long) om_this_prog_max_return_addr)
    70           {
    71             om_this_prog_max_return_addr = nm_addr;
    72           }
    73         }
    74       }
    75       pclose(pipe);
    76     }
    77   }
    78 #endif /* defined(OM_NM) && defined(HAVE_POPEN) */
    79 }
    80 
    81 #define OM_MAX_TRACK_FRAMES 11
     18/* This is for nice alignment of omPrintBackTrace */
     19#define OM_MAX_PROC_NAME_LENGTH 20
     20/* if you make this larger than 11, extend OM_GET_RETURN_ADDR and
     21   OM_GET_FRAME_ADDR */
     22#define OM_MAX_BT_FRAMES 11
     23
     24#ifdef OM_RETURN_ADDR_RVALUE
     25#define OM_GET_RETURN_ADDR OM_RETURN_ADDR
     26#else
    8227#define OM_GET_RETURN_ADDR(addr, i)             \
    8328switch(i)                                       \
     
    10853      addr = NULL;                              \
    10954}
    110 
     55#endif /* OM_RETURN_ADDR_RVALUE */
     56
     57#ifdef OM_FRAME_ADDR_RVALUE
     58#define OM_GET_FRAME_ADDR OM_FRAME_ADDR
     59#else
    11160#define OM_GET_FRAME_ADDR(addr, i)              \
    11261switch(i)                                       \
     
    13786      addr = NULL;                              \
    13887}
     88#endif /* OM_FRAME_ADDR_RVALUE */
     89
     90static char* om_this_prog = NULL;
     91static void* om_this_main_frame_addr = NULL;
     92static void* om_this_prog_min_return_addr = ((void*) 1023);
     93static void* om_this_prog_max_return_addr = ((void*) ULONG_MAX -1);
     94
     95
     96void omInitTrack(const char* argv0)
     97{
     98  char buf[MAXPATHLEN];
     99 
     100  if (argv0 != NULL && omFindExec(argv0, buf))
     101  {
     102    __omTypeAllocChunk(char*, om_this_prog, strlen(buf));
     103    strcpy(om_this_prog, buf);
     104  }
     105#if defined(OM_FRAME_ADDR_WORKS)
     106  om_this_main_frame_addr = OM_FRAME_ADDR(1);
     107#endif
     108#if defined(OM_PROG_NM) && defined(HAVE_POPEN)
     109  if (om_this_prog != NULL)
     110  {
     111    char command[MAXPATHLEN + 30];
     112    FILE *pipe;
     113    sprintf(command, "%s -n %s", OM_PROG_NM, om_this_prog);
     114   
     115    pipe = popen(command, "r");
     116    if (pipe != NULL)
     117    {
     118      /* serach for first address */
     119      int c;
     120      void* nm_addr;
     121      while ( (c=fgetc(pipe)) !=  EOF)
     122      {
     123        if (c == '\n')
     124        {
     125          if (fscanf(pipe, "%p", &nm_addr) &&
     126              (unsigned long) nm_addr >
     127              (unsigned long) om_this_prog_min_return_addr)
     128          {
     129            om_this_prog_min_return_addr = nm_addr;
     130            break;
     131          }
     132        }
     133      }
     134      om_this_prog_max_return_addr = nm_addr;
     135      while ( (c=fgetc(pipe)) !=  EOF)
     136      {
     137        if (c == '\n')
     138        {
     139          if (fscanf(pipe, "%p", &nm_addr) && nm_addr != NULL &&
     140              (unsigned long) nm_addr  >
     141              (unsigned long) om_this_prog_max_return_addr)
     142          {
     143            om_this_prog_max_return_addr = nm_addr;
     144          }
     145        }
     146      }
     147      pclose(pipe);
     148    }
     149  }
     150#endif /* defined(OM_NM) && defined(HAVE_POPEN) */
     151}
    139152
    140153
    141154int omGetCurrentBackTrace(void** addr, int max_frames)
    142155{
     156  int i = 0;
    143157#if defined(OM_RETURN_ADDR_WORKS)
    144158#if defined(OM_FRAME_ADDR_WORKS)
     
    150164    {
    151165#endif /* ! defined(OM_RETURN_ADDR_WORKS) */
    152       int i;
    153166      void* r_addr;
     167      if (max_frames > OM_MAX_BT_FRAMES) max_frames = OM_MAX_BT_FRAMES;
    154168      for (i=0; i< max_frames; i++)
    155169      {
     
    178192#endif /* OM_FRAME_ADDR_WORKS */
    179193  }
    180   return max_frames;
    181194#endif /* defined(OM_RETURN_ADDR_WORKS) */
    182   return 0;
     195  return i;
    183196}
    184197
     
    186199{
    187200  int i = 0;
     201  if (max_frames > OM_MAX_BT_FRAMES) max_frames = OM_MAX_BT_FRAMES;
    188202#if defined(HAVE_POPEN) && defined(OM_PROG_ADDR2LINE)
    189203  if (om_this_prog != NULL)
    190204  {
    191     char command[2*MAXPATHLEN + 15 + OM_MAX_TRACK_FRAMES*(2*SIZEOF_VOIDP + 4)];
     205    char command[2*MAXPATHLEN + 15 + OM_MAX_BT_FRAMES*(2*SIZEOF_VOIDP + 4)];
    192206    FILE *pipe;
    193207    int l;
    194 
    195208    l = sprintf(command, "%s -s -C -f -e %s",
    196209                     OM_PROG_ADDR2LINE, om_this_prog);
     
    202215    }
    203216   
    204     if (i==0) return 0;
    205     pipe = popen(command, "r");
    206     if (pipe != NULL)
    207     {
    208       int nl = '@';
    209       while ((l=fgetc(pipe)) != EOF)
    210       {
    211         if (l == '\n')
    212         {
    213           l =fgetc(pipe);
    214           if (l == EOF) break;
    215           fputc(nl, fd);
    216           if (nl == '@') nl = '#';
    217           else nl = '@';
    218         }
    219         fputc(l, fd);
    220       }
    221       pclose(pipe);
    222       if (i > 0)
    223       {
    224         fprintf(fd, "%d", i);
    225         fputc('\n', fd);
     217    if (i > 0)
     218    {
     219      pipe = popen(command, "r");
     220      if (pipe != NULL)
     221      {
     222        int nl = 0;
     223        int j = 0;
     224        int k=0;
     225        while ((l=fgetc(pipe)) != EOF)
     226        {
     227          if (nl == 0)
     228          {
     229            fprintf(fd, "  #%d %p in ", j, addr[j]);
     230            nl = 1;
     231            j++;
     232            k=0;
     233          }
     234          if (l == '\n')
     235          {
     236            if (nl == 1)
     237            {
     238              while (k<OM_MAX_PROC_NAME_LENGTH)
     239              {
     240                fprintf(fd, " ");
     241                k++;
     242              }
     243              fprintf(fd, " at ");
     244              nl = 2;
     245            }
     246            else
     247            {
     248              fputc('\n', fd);
     249              nl = 0;
     250            }
     251          }
     252          else
     253          {
     254            k++;
     255            fputc(l, fd);
     256          }
     257        }
     258        pclose(pipe);
    226259        fflush(fd);
    227       }
    228       return i;
    229     }
    230     i=0;
    231   }
    232 #endif
     260        return i;
     261      }
     262      i=0;
     263    }
     264  }
     265#endif
     266#if OM_RETURN_ADDR_WORKS
    233267  while (i<max_frames && addr[i] != NULL)
    234268  {
    235     fprintf(fd, "%p#", addr[i]);
     269    fprintf(fd, "  #%d %p in ??\n", i, addr[i]);
    236270    i++;
    237271  }
    238   if (i > 0)
    239   {
     272#endif
     273  if (i == 0)
     274  {
     275    fprintf(fd, "??");
    240276    fputc('\n', fd);
    241     fflush(fd);
    242   }
     277  }
     278  fflush(fd);
    243279  return i;
    244280}
     
    246282int omPrintCurrentBackTrace(int from_frame, int max_frames, FILE *fd)
    247283{
    248 #if defined(OM_RETURN_ADDR_WORKS)
    249   if (from_frame >= 0)
    250   {
    251     void* addr[OM_MAX_TRACK_FRAMES];
    252     int got_frames = omGetCurrentBackTrace(addr, from_frame + max_frames + 1);
    253     return omPrintBackTrace(&addr[from_frame + 1], got_frames, fd);
    254   }
    255 #endif
    256   return 0;
     284  void* addr[OM_MAX_BT_FRAMES];
     285  int got_frames = omGetCurrentBackTrace(addr, from_frame + max_frames + 1);
     286  return omPrintBackTrace(&addr[from_frame + 1],
     287                          got_frames - from_frame + 1, fd);
    257288}
    258289
Note: See TracChangeset for help on using the changeset viewer.