Changeset 212fc0 in git
- Timestamp:
- Nov 22, 1999, 7:13:00 PM (24 years ago)
- Branches:
- (u'spielwiese', '0d6b7fcd9813a1ca1ed4220cfa2b104b97a0a003')
- Children:
- 6ea5825fc0e0bfabf56883aee9dac9b5bbe415fe
- Parents:
- e6908a0f43ea328a1aa0c3942e8d309db7de26d5
- Location:
- omalloc
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
omalloc/configure
re6908a0 r212fc0 13 13 # Any additions from configure.in: 14 14 ac_help="$ac_help 15 --with-mtrack use mpr routines for extended memory tracking16 -- works only under ix86-Linux"17 ac_help="$ac_help18 15 --with-align8 only use 8-aligned memory" 19 16 ac_help="$ac_help 20 17 --enable-stat enable memory statistics" 21 18 ac_help="$ac_help 22 --disable-mtrack disable memory track" 19 --disable-mtrack disable backtrace and memory track" 20 ac_help="$ac_help 21 --with_return_addr_func=FUNC 22 use FUNC as function for determening return addr 23 Default: __bultin_return_address" 24 ac_help="$ac_help 25 --with_frame_addr_func=FUNC 26 use FUNC as function for determening frame addr 27 Default: __bultin_frame_address" 23 28 24 29 # Initialize some variables set by options. … … 533 538 534 539 535 # Check whether --with-mtrack or --without-mtrack was given.536 if test "${with_mtrack+set}" = set; then537 withval="$with_mtrack"538 :539 fi540 541 540 # Check whether --with-align8 or --without-align8 was given. 542 541 if test "${with_align8+set}" = set; then … … 551 550 fi 552 551 553 # Check whether -- with-mtrack or --without-mtrack was given.554 if test "${ with_mtrack+set}" = set; then555 withval="$with_mtrack"552 # Check whether --enable-mtrack or --disable-mtrack was given. 553 if test "${enable_mtrack+set}" = set; then 554 enableval="$enable_mtrack" 556 555 : 557 556 fi 558 557 558 # Check whether --with-return_addr_func or --without-return_addr_func was given. 559 if test "${with_return_addr_func+set}" = set; then 560 withval="$with_return_addr_func" 561 : 562 fi 563 564 # Check whether --with-frame_addr_func or --without-frame_addr_func was given. 565 if test "${with_frame_addr_func+set}" = set; then 566 withval="$with_frame_addr_func" 567 : 568 fi 569 570 559 571 560 572 561 573 echo $ac_n "checking singuname""... $ac_c" 1>&6 562 echo "configure:5 63: checking singuname" >&5574 echo "configure:575: checking singuname" >&5 563 575 if eval "test \"`echo '$''{'ac_cv_singuname'+set}'`\" = set"; then 564 576 echo $ac_n "(cached) $ac_c" 1>&6 … … 591 603 592 604 echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6 593 echo "configure: 594: checking whether ${MAKE-make} sets \${MAKE}" >&5605 echo "configure:606: checking whether ${MAKE-make} sets \${MAKE}" >&5 594 606 set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'` 595 607 if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then … … 620 632 set dummy gcc; ac_word=$2 621 633 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 622 echo "configure:6 23: checking for $ac_word" >&5634 echo "configure:635: checking for $ac_word" >&5 623 635 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then 624 636 echo $ac_n "(cached) $ac_c" 1>&6 … … 650 662 set dummy cc; ac_word=$2 651 663 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 652 echo "configure:6 53: checking for $ac_word" >&5664 echo "configure:665: checking for $ac_word" >&5 653 665 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then 654 666 echo $ac_n "(cached) $ac_c" 1>&6 … … 701 713 set dummy cl; ac_word=$2 702 714 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 703 echo "configure:7 04: checking for $ac_word" >&5715 echo "configure:716: checking for $ac_word" >&5 704 716 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then 705 717 echo $ac_n "(cached) $ac_c" 1>&6 … … 733 745 734 746 echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 735 echo "configure:7 36: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5747 echo "configure:748: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 736 748 737 749 ac_ext=c … … 744 756 cat > conftest.$ac_ext << EOF 745 757 746 #line 7 47"configure"758 #line 759 "configure" 747 759 #include "confdefs.h" 748 760 749 761 main(){return(0);} 750 762 EOF 751 if { (eval echo configure:7 52: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then763 if { (eval echo configure:764: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then 752 764 ac_cv_prog_cc_works=yes 753 765 # If we can't run a trivial program, we are probably using a cross compiler. … … 775 787 fi 776 788 echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 777 echo "configure:7 78: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5789 echo "configure:790: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 778 790 echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 779 791 cross_compiling=$ac_cv_prog_cc_cross 780 792 781 793 echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 782 echo "configure:7 83: checking whether we are using GNU C" >&5794 echo "configure:795: checking whether we are using GNU C" >&5 783 795 if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then 784 796 echo $ac_n "(cached) $ac_c" 1>&6 … … 789 801 #endif 790 802 EOF 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; then803 if { 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 792 804 ac_cv_prog_gcc=yes 793 805 else … … 808 820 CFLAGS= 809 821 echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 810 echo "configure:8 11: checking whether ${CC-cc} accepts -g" >&5822 echo "configure:823: checking whether ${CC-cc} accepts -g" >&5 811 823 if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then 812 824 echo $ac_n "(cached) $ac_c" 1>&6 … … 840 852 841 853 echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 842 echo "configure:8 43: checking how to run the C preprocessor" >&5854 echo "configure:855: checking how to run the C preprocessor" >&5 843 855 # On Suns, sometimes $CPP names a directory. 844 856 if test -n "$CPP" && test -d "$CPP"; then … … 855 867 # not just through cpp. 856 868 cat > conftest.$ac_ext <<EOF 857 #line 8 58"configure"869 #line 870 "configure" 858 870 #include "confdefs.h" 859 871 #include <assert.h> … … 861 873 EOF 862 874 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" 863 { (eval echo configure:8 64: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }875 { (eval echo configure:876: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } 864 876 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` 865 877 if test -z "$ac_err"; then … … 872 884 CPP="${CC-cc} -E -traditional-cpp" 873 885 cat > conftest.$ac_ext <<EOF 874 #line 8 75"configure"886 #line 887 "configure" 875 887 #include "confdefs.h" 876 888 #include <assert.h> … … 878 890 EOF 879 891 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" 880 { (eval echo configure:8 81: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }892 { (eval echo configure:893: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } 881 893 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` 882 894 if test -z "$ac_err"; then … … 889 901 CPP="${CC-cc} -nologo -E" 890 902 cat > conftest.$ac_ext <<EOF 891 #line 892"configure"903 #line 904 "configure" 892 904 #include "confdefs.h" 893 905 #include <assert.h> … … 895 907 EOF 896 908 ac_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; } 898 910 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` 899 911 if test -z "$ac_err"; then … … 920 932 921 933 echo $ac_n "checking for working const""... $ac_c" 1>&6 922 echo "configure:9 23: checking for working const" >&5934 echo "configure:935: checking for working const" >&5 923 935 if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then 924 936 echo $ac_n "(cached) $ac_c" 1>&6 925 937 else 926 938 cat > conftest.$ac_ext <<EOF 927 #line 9 28"configure"939 #line 940 "configure" 928 940 #include "confdefs.h" 929 941 … … 974 986 ; return 0; } 975 987 EOF 976 if { (eval echo configure:9 77: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then988 if { (eval echo configure:989: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then 977 989 rm -rf conftest* 978 990 ac_cv_c_const=yes … … 995 1007 996 1008 echo $ac_n "checking for inline""... $ac_c" 1>&6 997 echo "configure: 998: checking for inline" >&51009 echo "configure:1010: checking for inline" >&5 998 1010 if eval "test \"`echo '$''{'ac_cv_c_inline'+set}'`\" = set"; then 999 1011 echo $ac_n "(cached) $ac_c" 1>&6 … … 1002 1014 for ac_kw in inline __inline__ __inline; do 1003 1015 cat > conftest.$ac_ext <<EOF 1004 #line 10 05"configure"1016 #line 1017 "configure" 1005 1017 #include "confdefs.h" 1006 1018 … … 1009 1021 ; return 0; } 1010 1022 EOF 1011 if { (eval echo configure:10 12: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then1023 if { (eval echo configure:1024: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then 1012 1024 rm -rf conftest* 1013 1025 ac_cv_c_inline=$ac_kw; break … … 1043 1055 set dummy ranlib; ac_word=$2 1044 1056 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 1045 echo "configure:10 46: checking for $ac_word" >&51057 echo "configure:1058: checking for $ac_word" >&5 1046 1058 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then 1047 1059 echo $ac_n "(cached) $ac_c" 1>&6 … … 1073 1085 set dummy ar; ac_word=$2 1074 1086 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 1075 echo "configure:10 76: checking for $ac_word" >&51087 echo "configure:1088: checking for $ac_word" >&5 1076 1088 if eval "test \"`echo '$''{'ac_cv_prog_AR'+set}'`\" = set"; then 1077 1089 echo $ac_n "(cached) $ac_c" 1>&6 … … 1106 1118 set dummy perl; ac_word=$2 1107 1119 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 1108 echo "configure:11 09: checking for $ac_word" >&51120 echo "configure:1121: checking for $ac_word" >&5 1109 1121 if eval "test \"`echo '$''{'ac_cv_prog_PERL'+set}'`\" = set"; then 1110 1122 echo $ac_n "(cached) $ac_c" 1>&6 … … 1140 1152 set dummy addr2line; ac_word=$2 1141 1153 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 1142 echo "configure:11 43: checking for $ac_word" >&51154 echo "configure:1155: checking for $ac_word" >&5 1143 1155 if eval "test \"`echo '$''{'ac_cv_prog_ADDR2LINE'+set}'`\" = set"; then 1144 1156 echo $ac_n "(cached) $ac_c" 1>&6 … … 1176 1188 set dummy nm; ac_word=$2 1177 1189 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 1178 echo "configure:11 79: checking for $ac_word" >&51190 echo "configure:1191: checking for $ac_word" >&5 1179 1191 if eval "test \"`echo '$''{'ac_cv_prog_NM'+set}'`\" = set"; then 1180 1192 echo $ac_n "(cached) $ac_c" 1>&6 … … 1212 1224 # header file checks 1213 1225 echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 1214 echo "configure:12 15: checking for ANSI C header files" >&51226 echo "configure:1227: checking for ANSI C header files" >&5 1215 1227 if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then 1216 1228 echo $ac_n "(cached) $ac_c" 1>&6 1217 1229 else 1218 1230 cat > conftest.$ac_ext <<EOF 1219 #line 12 20"configure"1231 #line 1232 "configure" 1220 1232 #include "confdefs.h" 1221 1233 #include <stdlib.h> … … 1225 1237 EOF 1226 1238 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" 1227 { (eval echo configure:12 28: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }1239 { (eval echo configure:1240: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } 1228 1240 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` 1229 1241 if test -z "$ac_err"; then … … 1242 1254 # SunOS 4.x string.h does not declare mem*, contrary to ANSI. 1243 1255 cat > conftest.$ac_ext <<EOF 1244 #line 12 45"configure"1256 #line 1257 "configure" 1245 1257 #include "confdefs.h" 1246 1258 #include <string.h> … … 1260 1272 # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. 1261 1273 cat > conftest.$ac_ext <<EOF 1262 #line 12 63"configure"1274 #line 1275 "configure" 1263 1275 #include "confdefs.h" 1264 1276 #include <stdlib.h> … … 1281 1293 else 1282 1294 cat > conftest.$ac_ext <<EOF 1283 #line 12 84"configure"1295 #line 1296 "configure" 1284 1296 #include "confdefs.h" 1285 1297 #include <ctype.h> … … 1292 1304 1293 1305 EOF 1294 if { (eval echo configure:1 295: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null1306 if { (eval echo configure:1307: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null 1295 1307 then 1296 1308 : … … 1319 1331 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` 1320 1332 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 1321 echo "configure:13 22: checking for $ac_hdr" >&51333 echo "configure:1334: checking for $ac_hdr" >&5 1322 1334 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then 1323 1335 echo $ac_n "(cached) $ac_c" 1>&6 1324 1336 else 1325 1337 cat > conftest.$ac_ext <<EOF 1326 #line 13 27"configure"1338 #line 1339 "configure" 1327 1339 #include "confdefs.h" 1328 1340 #include <$ac_hdr> 1329 1341 EOF 1330 1342 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" 1331 { (eval echo configure:13 32: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }1343 { (eval echo configure:1344: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } 1332 1344 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` 1333 1345 if test -z "$ac_err"; then … … 1360 1372 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` 1361 1373 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 1362 echo "configure:13 63: checking for $ac_hdr" >&51374 echo "configure:1375: checking for $ac_hdr" >&5 1363 1375 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then 1364 1376 echo $ac_n "(cached) $ac_c" 1>&6 1365 1377 else 1366 1378 cat > conftest.$ac_ext <<EOF 1367 #line 13 68"configure"1379 #line 1380 "configure" 1368 1380 #include "confdefs.h" 1369 1381 #include <$ac_hdr> 1370 1382 EOF 1371 1383 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" 1372 { (eval echo configure:13 73: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }1384 { (eval echo configure:1385: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } 1373 1385 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` 1374 1386 if test -z "$ac_err"; then … … 1400 1412 do 1401 1413 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 1402 echo "configure:14 03: checking for $ac_func" >&51414 echo "configure:1415: checking for $ac_func" >&5 1403 1415 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then 1404 1416 echo $ac_n "(cached) $ac_c" 1>&6 1405 1417 else 1406 1418 cat > conftest.$ac_ext <<EOF 1407 #line 14 08"configure"1419 #line 1420 "configure" 1408 1420 #include "confdefs.h" 1409 1421 /* System header to define __stub macros and hopefully few prototypes, … … 1428 1440 ; return 0; } 1429 1441 EOF 1430 if { (eval echo configure:14 31: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then1442 if { (eval echo configure:1443: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then 1431 1443 rm -rf conftest* 1432 1444 eval "ac_cv_func_$ac_func=yes" … … 1455 1467 1456 1468 if test "$enable_mtrack" != no; then 1457 # functions which crawl up the stack from return and frame addr 1469 1470 # get function for return address 1471 if test "${with_return_addr_func+set}" = set; then 1472 if test "${with_return_addr_func}" != no; then 1473 ac_cv_return_addr_func=$with_return_addr_func 1474 fi 1475 else 1458 1476 if 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" 1478 fi 1479 fi 1480 1481 # test this function 1482 if test "${ac_cv_return_addr_func+set}" = set; then 1483 cat >> confdefs.h <<EOF 1484 #define OM_RETURN_ADDR $ac_cv_return_addr_func 1485 EOF 1486 1487 # first, check whether return addr works 1488 echo $ac_n "checking whether $ac_cv_return_addr_func works""... $ac_c" 1>&6 1489 echo "configure:1490: checking whether $ac_cv_return_addr_func works" >&5 1490 if eval "test \"`echo '$''{'ac_cv_return_addr_func_works'+set}'`\" = set"; then 1477 1491 echo $ac_n "(cached) $ac_c" 1>&6 1478 1492 else 1479 1493 if test "$cross_compiling" = yes; then 1480 ac_cv_ func_return_addr_works=no1494 ac_cv_return_addr_func_works=no 1481 1495 else 1482 1496 cat > conftest.$ac_ext <<EOF 1483 #line 14 84"configure"1497 #line 1498 "configure" 1484 1498 #include "confdefs.h" 1485 1499 1486 1500 int test_return_addr() 1487 1501 { 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; 1489 1504 return 1; 1490 1505 } … … 1496 1511 1497 1512 EOF 1498 if { (eval echo configure:1 499: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null1513 if { (eval echo configure:1514: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null 1499 1514 then 1500 ac_cv_ func_return_addr_works=yes1515 ac_cv_return_addr_func_works=yes 1501 1516 else 1502 1517 echo "configure: failed program was:" >&5 1503 1518 cat conftest.$ac_ext >&5 1504 1519 rm -fr conftest* 1505 ac_cv_ func_return_addr_works=no1520 ac_cv_return_addr_func_works=no 1506 1521 fi 1507 1522 rm -fr conftest* … … 1510 1525 fi 1511 1526 1512 echo "$ac_t""$ac_cv_func_return_addr_works" 1>&6 1513 1514 if test "$ac_cv_func_return_addr_works" = yes; then 1527 echo "$ac_t""$ac_cv_return_addr_func_works" 1>&6 1528 1529 if test "$ac_cv_return_addr_func_works" = yes; then 1530 cat >> confdefs.h <<\EOF 1531 #define OM_RETURN_ADDR_WORKS 1 1532 EOF 1533 1534 # check whether return addr works with rvalues 1535 echo $ac_n "checking whether $ac_cv_return_addr_func takes rvalues""... $ac_c" 1>&6 1536 echo "configure:1537: checking whether $ac_cv_return_addr_func takes rvalues" >&5 1537 if eval "test \"`echo '$''{'ac_cv_return_addr_func_rvalue'+set}'`\" = set"; then 1538 echo $ac_n "(cached) $ac_c" 1>&6 1539 else 1540 if test "$cross_compiling" = yes; then 1541 ac_cv_return_addr_func_rvalue=no 1542 else 1543 cat > conftest.$ac_ext <<EOF 1544 #line 1545 "configure" 1545 #include "confdefs.h" 1546 1547 int 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 1554 int main() 1555 { 1556 return test_return_addr(1, 0); 1557 } 1558 1559 EOF 1560 if { (eval echo configure:1561: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null 1561 then 1562 ac_cv_return_addr_func_rvalue=yes 1563 else 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 1568 fi 1569 rm -fr conftest* 1570 fi 1571 1572 fi 1573 1574 echo "$ac_t""$ac_cv_return_addr_func_rvalue" 1>&6 1575 if test "$ac_cv_return_addr_func_rvalue" = yes; then 1576 cat >> confdefs.h <<EOF 1577 #define OM_RETURN_ADDR_RVALUE 1 1578 EOF 1579 1580 fi 1581 fi # "$ac_cv_return_addr_func_works" = yes; 1582 fi # "${ac_cv_return_addr_func+set}" = set; 1583 1584 # get function for frame address 1585 if test "${with_frame_addr_func+set}" = set; then 1586 if test "${with_frame_addr_func}" != no; then 1587 ac_cv_frame_addr_func=$with_frame_addr_func 1588 fi 1589 else 1590 if test "${GCC}" = yes; then 1591 ac_cv_frame_addr_func="__builtin_frame_address" 1592 fi 1593 fi 1594 1595 # test this function 1596 if test "${ac_cv_frame_addr_func+set}" = set; then 1515 1597 cat >> 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 1599 EOF 1600 1601 # first, check whether frame addr works 1602 echo $ac_n "checking whether $ac_cv_frame_addr_func works""... $ac_c" 1>&6 1603 echo "configure:1604: checking whether $ac_cv_frame_addr_func works" >&5 1604 if eval "test \"`echo '$''{'ac_cv_frame_addr_func_works'+set}'`\" = set"; then 1524 1605 echo $ac_n "(cached) $ac_c" 1>&6 1525 1606 else 1526 1607 if test "$cross_compiling" = yes; then 1527 ac_cv_f unc_frame_addr_works=no1608 ac_cv_frame_addr_func_works=no 1528 1609 else 1529 1610 cat > conftest.$ac_ext <<EOF 1530 #line 1 531"configure"1611 #line 1612 "configure" 1531 1612 #include "confdefs.h" 1532 1613 1533 1614 int test_frame_addr() 1534 1615 { 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; 1536 1618 return 1; 1537 1619 } … … 1543 1625 1544 1626 EOF 1545 if { (eval echo configure:1 546: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null1627 if { (eval echo configure:1628: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null 1546 1628 then 1547 ac_cv_f unc_frame_addr_works=yes1629 ac_cv_frame_addr_func_works=yes 1548 1630 else 1549 1631 echo "configure: failed program was:" >&5 1550 1632 cat conftest.$ac_ext >&5 1551 1633 rm -fr conftest* 1552 ac_cv_f unc_frame_addr_works=no1634 ac_cv_frame_addr_func_works=no 1553 1635 fi 1554 1636 rm -fr conftest* … … 1557 1639 fi 1558 1640 1559 echo "$ac_t""$ac_cv_f unc_frame_addr_works" 1>&61560 1561 if test "$ac_cv_f unc_frame_addr_works" = yes; then1562 cat >> confdefs.h << EOF1641 echo "$ac_t""$ac_cv_frame_addr_func_works" 1>&6 1642 1643 if test "$ac_cv_frame_addr_func_works" = yes; then 1644 cat >> confdefs.h <<\EOF 1563 1645 #define OM_FRAME_ADDR_WORKS 1 1564 1646 EOF 1565 1647 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 1649 echo $ac_n "checking whether $ac_cv_frame_addr_func takes rvalues""... $ac_c" 1>&6 1650 echo "configure:1651: checking whether $ac_cv_frame_addr_func takes rvalues" >&5 1651 if eval "test \"`echo '$''{'ac_cv_frame_addr_func_rvalue'+set}'`\" = set"; then 1652 echo $ac_n "(cached) $ac_c" 1>&6 1653 else 1654 if test "$cross_compiling" = yes; then 1655 ac_cv_frame_addr_func_rvalue=no 1656 else 1657 cat > conftest.$ac_ext <<EOF 1658 #line 1659 "configure" 1659 #include "confdefs.h" 1660 1661 int 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 1668 int main() 1669 { 1670 return test_frame_addr(1, 0); 1671 } 1672 1673 EOF 1674 if { (eval echo configure:1675: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null 1675 then 1676 ac_cv_frame_addr_func_rvalue=yes 1677 else 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 1682 fi 1683 rm -fr conftest* 1684 fi 1685 1686 fi 1687 1688 echo "$ac_t""$ac_cv_frame_addr_func_rvalue" 1>&6 1689 if test "$ac_cv_frame_addr_func_rvalue" = yes; then 1690 cat >> confdefs.h <<EOF 1691 #define OM_FRAME_ADDR_RVALUE 1 1692 EOF 1693 1694 fi 1695 fi # "$ac_cv_frame_addr_func_works" = yes; 1696 fi # "${ac_cv_frame_addr_func+set}" = set; 1697 1570 1698 fi # "$enable_mtrack" != no; 1571 1699 … … 1574 1702 # sizes 1575 1703 echo $ac_n "checking size of long""... $ac_c" 1>&6 1576 echo "configure:1 577: checking size of long" >&51704 echo "configure:1705: checking size of long" >&5 1577 1705 if eval "test \"`echo '$''{'ac_cv_sizeof_long'+set}'`\" = set"; then 1578 1706 echo $ac_n "(cached) $ac_c" 1>&6 … … 1582 1710 else 1583 1711 cat > conftest.$ac_ext <<EOF 1584 #line 1 585"configure"1712 #line 1713 "configure" 1585 1713 #include "confdefs.h" 1586 1714 #include <stdio.h> … … 1593 1721 } 1594 1722 EOF 1595 if { (eval echo configure:1 596: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null1723 if { (eval echo configure:1724: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null 1596 1724 then 1597 1725 ac_cv_sizeof_long=`cat conftestval` … … 1613 1741 1614 1742 echo $ac_n "checking size of void*""... $ac_c" 1>&6 1615 echo "configure:1 616: checking size of void*" >&51743 echo "configure:1744: checking size of void*" >&5 1616 1744 if eval "test \"`echo '$''{'ac_cv_sizeof_voidp'+set}'`\" = set"; then 1617 1745 echo $ac_n "(cached) $ac_c" 1>&6 … … 1621 1749 else 1622 1750 cat > conftest.$ac_ext <<EOF 1623 #line 1 624"configure"1751 #line 1752 "configure" 1624 1752 #include "confdefs.h" 1625 1753 #include <stdio.h> … … 1632 1760 } 1633 1761 EOF 1634 if { (eval echo configure:1 635: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null1762 if { (eval echo configure:1763: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null 1635 1763 then 1636 1764 ac_cv_sizeof_voidp=`cat conftestval` … … 1652 1780 1653 1781 echo $ac_n "checking size of double""... $ac_c" 1>&6 1654 echo "configure:1 655: checking size of double" >&51782 echo "configure:1783: checking size of double" >&5 1655 1783 if eval "test \"`echo '$''{'ac_cv_sizeof_double'+set}'`\" = set"; then 1656 1784 echo $ac_n "(cached) $ac_c" 1>&6 … … 1660 1788 else 1661 1789 cat > conftest.$ac_ext <<EOF 1662 #line 1 663"configure"1790 #line 1791 "configure" 1663 1791 #include "confdefs.h" 1664 1792 #include <stdio.h> … … 1671 1799 } 1672 1800 EOF 1673 if { (eval echo configure:1 674: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null1801 if { (eval echo configure:1802: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null 1674 1802 then 1675 1803 ac_cv_sizeof_double=`cat conftestval` … … 1698 1826 1699 1827 echo $ac_n "checking align8""... $ac_c" 1>&6 1700 echo "configure:1 701: checking align8" >&51828 echo "configure:1829: checking align8" >&5 1701 1829 if test "$with_align8" = yes || test "$ac_cv_sizeof_long" = 8; then 1702 1830 $ac_cv_align8 = yes … … 1709 1837 else 1710 1838 cat > conftest.$ac_ext <<EOF 1711 #line 1 712"configure"1839 #line 1840 "configure" 1712 1840 #include "confdefs.h" 1713 1841 … … 1724 1852 1725 1853 EOF 1726 if { (eval echo configure:1 727: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null1854 if { (eval echo configure:1855: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null 1727 1855 then 1728 1856 ac_cv_align8=no … … 1749 1877 1750 1878 echo $ac_n "checking size of system page""... $ac_c" 1>&6 1751 echo "configure:1 752: checking size of system page" >&51879 echo "configure:1880: checking size of system page" >&5 1752 1880 if eval "test \"`echo '$''{'ac_cv_pagesize'+set}'`\" = set"; then 1753 1881 echo $ac_n "(cached) $ac_c" 1>&6 … … 1757 1885 else 1758 1886 cat > conftest.$ac_ext <<EOF 1759 #line 1 760"configure"1887 #line 1888 "configure" 1760 1888 #include "confdefs.h" 1761 1889 #include <stdio.h> … … 1771 1899 } 1772 1900 EOF 1773 if { (eval echo configure:1 774: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null1901 if { (eval echo configure:1902: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null 1774 1902 then 1775 1903 ac_cv_pagesize=`cat conftestval` … … 1795 1923 1796 1924 echo $ac_n "checking for page aligned valloc""... $ac_c" 1>&6 1797 echo "configure:1 798: checking for page aligned valloc" >&51925 echo "configure:1926: checking for page aligned valloc" >&5 1798 1926 if eval "test \"`echo '$''{'ac_cv_have_page_alignment'+set}'`\" = set"; then 1799 1927 echo $ac_n "(cached) $ac_c" 1>&6 … … 1841 1969 else 1842 1970 cat > conftest.$ac_ext <<EOF 1843 #line 1 844"configure"1971 #line 1972 "configure" 1844 1972 #include "confdefs.h" 1845 1973 … … 1848 1976 1849 1977 EOF 1850 if { (eval echo configure:1 851: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null1978 if { (eval echo configure:1979: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null 1851 1979 then 1852 1980 ac_cv_have_page_alignment="ac_cv_usable_pagesize="`cat conftestval` … … 1865 1993 else 1866 1994 cat > conftest.$ac_ext <<EOF 1867 #line 1 868"configure"1995 #line 1996 "configure" 1868 1996 #include "confdefs.h" 1869 1997 … … 1872 2000 1873 2001 EOF 1874 if { (eval echo configure: 1875: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null2002 if { (eval echo configure:2003: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null 1875 2003 then 1876 2004 ac_cv_have_page_alignment="ac_cv_usable_pagesize="`cat conftestval` … … 1892 2020 else 1893 2021 cat > conftest.$ac_ext <<EOF 1894 #line 1895"configure"2022 #line 2023 "configure" 1895 2023 #include "confdefs.h" 1896 2024 … … 1901 2029 1902 2030 EOF 1903 if { (eval echo configure: 1904: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null2031 if { (eval echo configure:2032: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null 1904 2032 then 1905 2033 ac_cv_have_page_alignment="ac_cv_have_gmalloc=yes; ac_cv_usable_pagesize="`cat conftestval` … … 1918 2046 else 1919 2047 cat > conftest.$ac_ext <<EOF 1920 #line 1921"configure"2048 #line 2049 "configure" 1921 2049 #include "confdefs.h" 1922 2050 … … 1927 2055 1928 2056 EOF 1929 if { (eval echo configure: 1930: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null2057 if { (eval echo configure:2058: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null 1930 2058 then 1931 2059 ac_cv_have_page_alignment="ac_cv_have_gmalloc=yes; ac_cv_usable_pagesize="`cat conftestval` … … 1977 2105 1978 2106 echo $ac_n "checking whether to enable statistics""... $ac_c" 1>&6 1979 echo "configure: 1980: checking whether to enable statistics" >&52107 echo "configure:2108: checking whether to enable statistics" >&5 1980 2108 if test "$enable_stat" = yes; then 1981 2109 echo "$ac_t""yes" 1>&6 -
omalloc/configure.in
re6908a0 r212fc0 4 4 dnl Author: obachman@mathematik.uni-kl.de (Olaf Bachmann) 5 5 dnl Created: 11/99 6 dnl Version: $Id: configure.in,v 1. 1.1.1 1999-11-18 17:45:52obachman Exp $6 dnl Version: $Id: configure.in,v 1.2 1999-11-22 18:12:57 obachman Exp $ 7 7 dnl lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll 8 8 … … 13 13 dnl help for configure 14 14 dnl 15 AC_ARG_WITH(16 mtrack,17 [ --with-mtrack use mpr routines for extended memory tracking18 -- works only under ix86-Linux])19 15 AC_ARG_WITH( 20 16 align8, … … 23 19 align8, 24 20 [ --enable-stat enable memory statistics]) 21 AC_ARG_ENABLE( 22 mtrack, 23 [ --disable-mtrack disable backtrace and memory track]) 25 24 AC_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]) 29 AC_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 28 35 29 36 … … 97 104 98 105 if test "$enable_mtrack" != no; then 99 # functions which crawl up the stack from return and frame addr 106 107 # get function for return address 108 if test "${with_return_addr_func+set}" = set; then 109 if test "${with_return_addr_func}" != no; then 110 ac_cv_return_addr_func=$with_return_addr_func 111 fi 112 else 100 113 if 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" 115 fi 116 fi 117 118 # test this function 119 if test "${ac_cv_return_addr_func+set}" = set; then 120 AC_DEFINE_UNQUOTED(OM_RETURN_ADDR, $ac_cv_return_addr_func) 121 # first, check whether return addr works 122 AC_MSG_CHECKING(whether $ac_cv_return_addr_func works) 123 AC_CACHE_VAL(ac_cv_return_addr_func_works, 112 124 AC_TRY_RUN([ 113 125 int test_return_addr() 114 126 { 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; 116 129 return 1; 117 130 } … … 121 134 return test_return_addr(); 122 135 } 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)) 139 AC_MSG_RESULT($ac_cv_return_addr_func_works) 140 141 if test "$ac_cv_return_addr_func_works" = yes; then 142 AC_DEFINE(OM_RETURN_ADDR_WORKS) 143 # check whether return addr works with rvalues 144 AC_MSG_CHECKING(whether $ac_cv_return_addr_func takes rvalues) 145 AC_CACHE_VAL(ac_cv_return_addr_func_rvalue, 146 AC_TRY_RUN([ 147 int 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 154 int 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)) 161 AC_MSG_RESULT($ac_cv_return_addr_func_rvalue) 162 if test "$ac_cv_return_addr_func_rvalue" = yes; then 163 AC_DEFINE_UNQUOTED(OM_RETURN_ADDR_RVALUE) 164 fi 165 fi # "$ac_cv_return_addr_func_works" = yes; 166 fi # "${ac_cv_return_addr_func+set}" = set; 167 168 # get function for frame address 169 if test "${with_frame_addr_func+set}" = set; then 170 if test "${with_frame_addr_func}" != no; then 171 ac_cv_frame_addr_func=$with_frame_addr_func 172 fi 173 else 174 if test "${GCC}" = yes; then 175 ac_cv_frame_addr_func="__builtin_frame_address" 176 fi 177 fi 178 179 # test this function 180 if test "${ac_cv_frame_addr_func+set}" = set; then 181 AC_DEFINE_UNQUOTED(OM_FRAME_ADDR, $ac_cv_frame_addr_func) 182 # first, check whether frame addr works 183 AC_MSG_CHECKING(whether $ac_cv_frame_addr_func works) 184 AC_CACHE_VAL(ac_cv_frame_addr_func_works, 134 185 AC_TRY_RUN([ 135 186 int test_frame_addr() 136 187 { 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; 138 190 return 1; 139 191 } … … 143 195 return test_frame_addr(); 144 196 } 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)) 200 AC_MSG_RESULT($ac_cv_frame_addr_func_works) 201 202 if test "$ac_cv_frame_addr_func_works" = yes; then 203 AC_DEFINE(OM_FRAME_ADDR_WORKS) 204 # check whether frame addr works with rvalues 205 AC_MSG_CHECKING(whether $ac_cv_frame_addr_func takes rvalues) 206 AC_CACHE_VAL(ac_cv_frame_addr_func_rvalue, 207 AC_TRY_RUN([ 208 int 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 215 int 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)) 222 AC_MSG_RESULT($ac_cv_frame_addr_func_rvalue) 223 if test "$ac_cv_frame_addr_func_rvalue" = yes; then 224 AC_DEFINE_UNQUOTED(OM_FRAME_ADDR_RVALUE) 225 fi 226 fi # "$ac_cv_frame_addr_func_works" = yes; 227 fi # "${ac_cv_frame_addr_func+set}" = set; 228 156 229 fi # "$enable_mtrack" != no; 157 230 -
omalloc/omAlloc.c
re6908a0 r212fc0 4 4 * Author: obachman@mathematik.uni-kl.de (Olaf Bachmann) 5 5 * Created: 11/99 6 * Version: $Id: omAlloc.c,v 1. 1.1.1 1999-11-18 17:45:53obachman Exp $6 * Version: $Id: omAlloc.c,v 1.2 1999-11-22 18:12:57 obachman Exp $ 7 7 *******************************************************************/ 8 8 #ifndef OM_ALLOC_C … … 25 25 26 26 27 #if 028 #include "mmemory.h"29 #else30 27 #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) 34 30 35 31 /* Get new page and initialize */ … … 129 125 130 126 /* bin->current_page is empty, get new bin->current_page, return addr*/ 131 void* omAllocBinFromFullPage(omBin Page page, omBinbin)127 void* omAllocBinFromFullPage(omBin bin) 132 128 { 133 129 void* addr; … … 135 131 omAssume(bin->current_page->current == NULL); 136 132 133 if (bin->current_page != om_ZeroPage) 134 { 135 omAssume(bin->last_page != NULL); 136 bin->current_page->used_blocks = 0; 137 } 138 137 139 if (bin->current_page->next != NULL) 138 140 { … … 154 156 } 155 157 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 else168 {169 addr = omAllocBinFromFullPage(page, bin);170 if (zero) omMemsetW(addr, 0, bin->sizeW);171 return addr;172 }173 }174 158 175 159 /* page->used_blocks == 0, so, either free page or reallocate to … … 194 178 else 195 179 { 196 bin = om BinOfPage(page);180 bin = omGetBinOfPage(page); 197 181 if (page->current != NULL || bin->max_blocks <= 1) 198 182 { … … 277 261 s_bin->bin->current_page = om_ZeroPage; 278 262 s_bin->bin->last_page = NULL; 263 s_bin->bin->next = NULL; 279 264 s_bin->bin->sizeW = sizeW; 280 265 s_bin->bin->max_blocks = max_blocks; … … 396 381 } 397 382 398 staticvoid omPrintBinStat(FILE * fd, omBin bin)383 void omPrintBinStat(FILE * fd, omBin bin) 399 384 { 400 385 int pages = 0, used_blocks = 0, free_blocks = 0; … … 432 417 } 433 418 434 #if 0435 419 /***************************************************************** 436 420 * … … 485 469 { 486 470 omBin s_bin; 487 omCheckBin(bin);488 471 s_bin = omGetStickyBin(bin, sticky_tag); 489 472 … … 506 489 } 507 490 508 void omUn setStickyBinTag(omBin bin, unsigned long sticky)491 void omUnSetStickyBinTag(omBin bin, unsigned long sticky) 509 492 { 510 493 omAssume(omGetStickyBin(bin, 0) != NULL); … … 515 498 static void omMergeStickyPages(omBin to_bin, omBin from_bin) 516 499 { 500 #ifdef HAVE_OM_ASSUME 501 int length = omGListLength(to_bin->last_page, prev) + 502 omGListLength(from_bin->last_page, prev); 503 #endif 504 517 505 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)); 518 512 519 513 if (page == NULL) return; … … 528 522 if (to_bin->last_page == NULL) 529 523 { 524 omAssume(to_bin->current_page == om_ZeroPage); 530 525 to_bin->last_page = from_bin->last_page; 531 526 to_bin->current_page = from_bin->current_page; … … 533 528 } 534 529 530 omAssume(to_bin->current_page != om_ZeroPage && 531 to_bin->current_page != NULL); 532 535 533 if (to_bin->current_page->current != NULL) 536 534 { … … 544 542 to_bin->current_page = to_bin->current_page->prev; 545 543 } 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; 554 567 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" 556 575 557 576 void omDeleteStickyBinTag(omBin bin, unsigned long sticky) … … 559 578 omBin no_sticky_bin = NULL; 560 579 omBin sticky_bin = NULL; 561 580 581 omdCheckBin(bin, 10); 562 582 if (sticky == 0) 563 583 { … … 566 586 } 567 587 568 omCheckBin(bin);569 570 588 sticky_bin = omGetStickyBin(bin, sticky); 571 589 if (sticky_bin != NULL) … … 575 593 576 594 omMergeStickyPages(no_sticky_bin, sticky_bin); 577 omCheckBin(no_sticky_bin);578 595 579 596 if (bin == sticky_bin) … … 585 602 FreeSizeOf(sticky_bin, omBin_t); 586 603 } 587 om CheckBin(bin);604 omdCheckBin(bin, 10); 588 605 } 589 606 … … 595 612 * 596 613 *****************************************************************/ 597 598 #ifdef BIN_DEBUG599 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 #endif635 636 637 614 unsigned long omGetNewStickyAllBinTag() 638 615 { … … 641 618 omSpecBin s_bin; 642 619 // first, find new sticky tag 643 for (i=0; i<= MAX_BIN_INDEX; i++)620 for (i=0; i<=OM_MAX_BIN_INDEX; i++) 644 621 { 645 622 new_sticky = omGetMaxStickyBinTag(&(om_StaticBin[i])); 646 623 if (new_sticky > sticky) sticky = new_sticky; 647 624 } 625 s_bin = om_SpecBin; 648 626 while (s_bin != NULL) 649 627 { … … 655 633 { 656 634 sticky++; 657 for (i=0; i<= MAX_BIN_INDEX; i++)635 for (i=0; i<=OM_MAX_BIN_INDEX; i++) 658 636 { 659 637 omCreateStickyBin(&(om_StaticBin[i]), sticky); … … 671 649 omBin bin; 672 650 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++) 674 652 { 675 653 bin = &om_StaticBin[i]; … … 692 670 omSpecBin s_bin = om_SpecBin; 693 671 int i; 694 for (i=0; i<= MAX_BIN_INDEX; i++)672 for (i=0; i<=OM_MAX_BIN_INDEX; i++) 695 673 { 696 674 omSetStickyBinTag(&(om_StaticBin[i]), sticky); … … 707 685 omSpecBin s_bin = om_SpecBin; 708 686 int i; 709 for (i=0; i<= MAX_BIN_INDEX; i++)687 for (i=0; i<=OM_MAX_BIN_INDEX; i++) 710 688 { 711 689 omUnSetStickyBinTag(&(om_StaticBin[i]), sticky); … … 722 700 omSpecBin s_bin = om_SpecBin; 723 701 int i; 724 for (i=0; i<= MAX_BIN_INDEX; i++)702 for (i=0; i<=OM_MAX_BIN_INDEX; i++) 725 703 { 726 704 omDeleteStickyBinTag(&(om_StaticBin[i]), sticky); … … 733 711 } 734 712 735 #endif736 737 713 #endif /* OM_ALLOC_C */ -
omalloc/omConfig.h.in
re6908a0 r212fc0 4 4 * Author: obachman (Olaf Bachmann) 5 5 * Created: 11/99 6 * Version: $Id: omConfig.h.in,v 1. 1.1.1 1999-11-18 17:45:52obachman Exp $6 * Version: $Id: omConfig.h.in,v 1.2 1999-11-22 18:12:58 obachman Exp $ 7 7 *******************************************************************/ 8 8 #ifndef OM_CONFIG_H … … 61 61 #ifndef OM_FRAME_ADDR_WORKS 62 62 #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 63 71 #endif 64 72 /* Define sizeof(long) */ -
omalloc/omDebug.c
re6908a0 r212fc0 4 4 * Author: obachman@mathematik.uni-kl.de (Olaf Bachmann) 5 5 * Created: 11/99 6 * Version: $Id: omDebug.c,v 1. 1.1.1 1999-11-18 17:45:53obachman Exp $6 * Version: $Id: omDebug.c,v 1.2 1999-11-22 18:12:58 obachman Exp $ 7 7 *******************************************************************/ 8 8 #include "omConfig.h" … … 12 12 #include "omDebug.h" 13 13 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); 14 static int omdCheckBinAddrSize(void* addr, size_t size, int level); 15 static int omdPrintBinError(const char* msg, void* addr, size_t size, 16 omBin bin); 17 static const char* omdTestBinAddrSize(void* addr, size_t size, int level, 18 omBin *bin); 20 19 static const char* omdTestBin(omBin bin, int level); 21 20 static const char* omdTestBinPage(omBinPage page, int level); 22 static int omdIsKnown Bin(omBin bin);21 static int omdIsKnownTopBin(omBin bin); 23 22 24 23 /******************************************************************* … … 27 26 * 28 27 *******************************************************************/ 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)) 28 int omdCheckBinAddr(void* addr, int level) 29 { 30 return omdCheckBinAddrSize(addr, 0, level); 31 } 32 33 int omdCheckBlockAddr(void* addr, size_t size, int level) 34 { 35 if (size == 0) 36 { 37 omError("0 size"); 33 38 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 46 int omdCheckChunkAddr(void* addr, int level) 48 47 { 49 48 omBinPage page; 50 49 addr = addr - SIZEOF_OM_ALIGNMENT; 51 50 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; 56 55 } 57 56 … … 61 60 * 62 61 *******************************************************************/ 63 static int omdIsKnown Bin(omBin bin)62 static int omdIsKnownTopBin(omBin bin) 64 63 { 65 64 int i = 0; … … 81 80 } 82 81 83 int omdCheckBin(omBin bin, int level , const char* fn, const int l)82 int omdCheckBin(omBin bin, int level) 84 83 { 85 84 const char* msg = omdTestBin(bin, level); 86 85 if (msg != NULL) 87 86 { 88 if (fn != NULL) omdPrintBinError(msg, NULL, 0, bin, fn, l);87 omdPrintBinError(msg, NULL, 0, bin); 89 88 return 0; 90 89 } … … 92 91 } 93 92 94 int omdCheckBins(int level , const char* fn, const int l)93 int omdCheckBins(int level) 95 94 { 96 95 if (level <= 0) … … 106 105 for (i=0; i<= OM_MAX_BIN_INDEX; i++) 107 106 { 108 if (! omdCheckBin(&om_StaticBin[i], level , fn, l)) return 0;107 if (! omdCheckBin(&om_StaticBin[i], level)) return 0; 109 108 } 110 109 s_bin = om_SpecBin; 111 110 while (s_bin != NULL) 112 111 { 113 if (! omdCheckBin(s_bin->bin, level , fn, l)) return 0;112 if (! omdCheckBin(s_bin->bin, level)) return 0; 114 113 s_bin = s_bin->next; 115 114 } … … 124 123 *******************************************************************/ 125 124 126 void* omdCheckAllocBin(omBin bin, const int zero, int level, 127 const char* fn, const int l) 125 void* omdCheckAllocBin(omBin bin, const int zero, int level) 128 126 { 129 127 void* res; 130 128 131 omdCheckBins(level-2 , fn, l);129 omdCheckBins(level-2); 132 130 133 131 if (zero) … … 136 134 __omTypeAllocBin(void*, res, bin); 137 135 138 omdCheckBinAddr(res, bin, level-1,fn, l);139 omdCheckBins(level-2 , fn, l);136 omdCheckBinAddr(res, level-1); 137 omdCheckBins(level-2); 140 138 141 139 return res; 142 140 } 143 141 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)) 142 void omdCheckFreeBin(void* addr, int level) 143 { 144 omdCheckBins(level-2); 145 146 if (omdCheckBinAddr(addr, level)) 150 147 __omFreeBin(addr); 151 148 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 152 void* omdCheckAllocBlock(size_t size, const int zero, int level) 158 153 { 159 154 void* res; … … 161 156 if (level > 0 && size <= 0) 162 157 { 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); 165 160 size = 1; 166 161 } 167 162 168 omdCheckBins(level-2 , fn, l);163 omdCheckBins(level-2); 169 164 170 165 if (zero) … … 173 168 __omTypeAllocBlock(void*, res, size); 174 169 175 omdCheckBlockAddr(res, size, level - 1 , fn, l);176 omdCheckBins(level - 2 , fn, l);170 omdCheckBlockAddr(res, size, level - 1); 171 omdCheckBins(level - 2); 177 172 178 173 return res; 179 174 } 180 175 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; 176 void omdCheckFreeBlock(void* addr, size_t size, int level) 177 { 178 omdCheckBins(level - 2); 179 if (! omdCheckBlockAddr(addr, size, level)) return; 186 180 187 181 __omFreeBlock(addr, size); 188 182 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 187 void* omdCheckAllocChunk(size_t size, const int zero, int level) 195 188 { 196 189 void* res; … … 198 191 if (level > 0 && size <= 0) 199 192 { 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); 202 195 size = 1; 203 196 } 204 omdCheckBins(level - 2 , fn, l);197 omdCheckBins(level - 2); 205 198 206 199 if (zero) … … 209 202 __omTypeAllocChunk(void*, res, size); 210 203 211 omdCheckChunkAddr(res, level - 1 , fn, l);212 omdCheckBins(level - 2 , fn, l);204 omdCheckChunkAddr(res, level - 1); 205 omdCheckBins(level - 2); 213 206 214 207 return res; 215 208 } 216 209 217 void omdCheckFreeChunk(void* addr, int level , const char* fn, const int l)218 { 219 if (! omdCheckChunkAddr(addr, level , fn, l)) return;210 void omdCheckFreeChunk(void* addr, int level) 211 { 212 if (! omdCheckChunkAddr(addr, level)) return; 220 213 221 214 __omFreeChunk(addr); 222 215 223 omdCheckBins(level - 2 , fn, l);216 omdCheckBins(level - 2); 224 217 } 225 218 … … 230 223 * 231 224 *******************************************************************/ 232 static int omdPrintBinError(const char* msg, void* addr, size_t size,omBin bin, 233 const char* fn, const int l) 225 static int omdPrintBinError(const char* msg, void* addr, size_t size,omBin bin) 234 226 { 235 227 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, 239 230 (bin != NULL ? bin->max_blocks : 0), 240 (bin != NULL ? bin->sizeW : 0), fn, l); 231 (bin != NULL ? bin->sizeW : 0)); 232 fflush(stderr); 241 233 return 0; 242 234 } 243 235 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);236 static int omdCheckBinAddrSize(void* addr, size_t size, int level) 237 { 238 omBin bin = NULL; 239 const char* msg = omdTestBinAddrSize(addr, size, level, &bin); 248 240 if (msg != NULL) 249 return omdPrintBinError(msg, addr, size, bin , fn, l);241 return omdPrintBinError(msg, addr, size, bin); 250 242 else 251 243 return 1; … … 255 247 /* Check that addr is activ (used) adr of bin */ 256 248 static const char* 257 omdTestBinAddrSize(void* addr, omBin bin, size_t size, int level) 258 { 249 omdTestBinAddrSize(void* addr, size_t size, int level, omBin* r_bin) 250 { 251 omBin bin; 259 252 omBinPage page; 260 253 omBin h_bin; 261 254 const char* msg; 262 255 263 264 256 if (level <= 0) return NULL; 265 257 266 258 if (addr == NULL) return omError("NULL addr"); 259 260 if (size > OM_MAX_BLOCK_SIZE) return NULL; 261 262 bin = omGetTopBinOfAddr(addr); 263 267 264 if (bin == NULL) return omError("NULL Bin"); 268 265 269 if (! omdIsKnown Bin(bin))266 if (! omdIsKnownTopBin(bin)) 270 267 return omError("Addr not from Bin (Bin unknown)"); 268 *r_bin = bin; 271 269 272 270 if ((msg = omdTestBin(bin, level - 1)) != NULL) return msg; 273 271 274 272 // 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 } 281 282 282 283 // check page … … 285 286 286 287 // 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; 288 290 if ( ! omIsOnGList(h_bin->last_page, prev, page)) 289 291 return omError("page of addr not from this Bin"); … … 347 349 { 348 350 void* current = page->current; 351 int i = 1; 349 352 if (current != NULL && 350 353 omListLength(current) != bin->max_blocks - page->used_blocks - 1) … … 362 365 != 0) 363 366 return omError("current has unaligned adress"); 364 current = *((void**) (current + SIZEOF_VOIDP)); 367 current = *((void**) current); 368 i++; 365 369 } 366 370 } … … 379 383 if (bin == NULL) return omError("NULL Bin"); 380 384 381 if (! omdIsKnown Bin(bin)) return omError("Bin unknown");385 if (! omdIsKnownTopBin(bin)) return omError("TopBin unknown"); 382 386 383 387 if (level > 2 && … … 440 444 return omError("Sticky of page wrong"); 441 445 442 if (om BinOfPage(page) != bin)446 if (omGetBinOfPage(page) != bin) 443 447 return omError("Bin of Page wrong"); 444 448 … … 457 461 { 458 462 if (page->current == NULL || 459 page->used_blocks ==0 ||463 page->used_blocks < 0 || 460 464 page->used_blocks == bin->max_blocks - 1) 461 465 return omError("used_blocks and current of upage out of sync"); -
omalloc/omDebug.h
re6908a0 r212fc0 4 4 * Author: obachman@mathematik.uni-kl.de (Olaf Bachmann) 5 5 * Created: 11/99 6 * Version: $Id: omDebug.h,v 1. 1.1.1 1999-11-18 17:45:53obachman Exp $6 * Version: $Id: omDebug.h,v 1.2 1999-11-22 18:12:58 obachman Exp $ 7 7 *******************************************************************/ 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); 8 int omdCheckBinAddr(void* addr, int level); 9 int omdCheckBlockAddr(void* addr, size_t size, int level); 10 int omdCheckChunkAddr(void* adr, int level); 13 11 14 int omdCheckBin(omBin bin, int level , const char* fn, const int l);15 int omdCheckBins(int level , const char* fn, const int l);12 int omdCheckBin(omBin bin, int level); 13 int omdCheckBins(int level); 16 14 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); 15 void* omdCheckAllocBin(omBin bin, int zero,int level); 16 void omdCheckFreeBin(void* addr, int level); 17 void* omdCheckAllocBlock(size_t size, int zero, int level); 18 void omdCheckFreeBlock(void* addr, size_t size, int level); 19 void* omdCheckAllocChunk(size_t size, int zero, int level); 20 void omdCheckFreeChunk(void* addr, int level); 28 21 29 22 -
omalloc/omList.c
re6908a0 r212fc0 4 4 * Author: obachman (Olaf Bachmann) 5 5 * Created: 11/99 6 * Version: $Id: omList.c,v 1. 1.1.1 1999-11-18 17:45:53obachman Exp $6 * Version: $Id: omList.c,v 1.2 1999-11-22 18:12:59 obachman Exp $ 7 7 *******************************************************************/ 8 8 #ifndef NULL … … 157 157 void* curr = NEXT(list); 158 158 159 while (curr != NULL && VALUE( list, long_field) < what)159 while (curr != NULL && VALUE(curr, long_field) < what) 160 160 { 161 161 prev = curr; -
omalloc/omLocal.c
re6908a0 r212fc0 5 5 * Author: obachman (Olaf Bachmann) 6 6 * Created: 11/99 7 * Version: $Id: omLocal.c,v 1. 1.1.1 1999-11-18 17:45:53obachman Exp $7 * Version: $Id: omLocal.c,v 1.2 1999-11-22 18:12:59 obachman Exp $ 8 8 *******************************************************************/ 9 9 … … 13 13 #include "omLocal.h" 14 14 #include "omPage.h" 15 #include "omTrack.h" 15 16 16 const char* omReportError(const char* msg , const char* file, const int line)17 const char* omReportError(const char* msg) 17 18 { 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); 19 21 return msg; 20 22 } -
omalloc/omLocal.h
re6908a0 r212fc0 5 5 * Author: obachman (Olaf Bachmann) 6 6 * Created: 11/99 7 * Version: $Id: omLocal.h,v 1. 1.1.1 1999-11-18 17:45:52obachman Exp $7 * Version: $Id: omLocal.h,v 1.2 1999-11-22 18:12:59 obachman Exp $ 8 8 *******************************************************************/ 9 9 #ifndef OM_LOCAL_H … … 44 44 (page)->bin_sticky= (void*)((unsigned long)sticky + (unsigned long)bin) 45 45 46 #define omGetTopBinOfAddr(addr) \ 47 omGetTopBinOfPage(((omBinPage) omGetPageOfAddr(addr))) 46 48 47 49 #if defined(OM_INLINE) || defined(OM_ALLOC_C) 48 OM_INLINE omBin om BinOfPage(omBinPage page)50 OM_INLINE omBin omGetBinOfPage(omBinPage page) 49 51 { 50 52 unsigned long sticky = omGetStickyOfPage(page); … … 57 59 return bin; 58 60 } 61 OM_INLINE omBin omGetBinOfAddr(void* addr) 62 { 63 return omGetBinOfPage(omGetPageOfAddr(addr)); 64 } 59 65 #else 60 extern omBin omBinOfPage(omBinPage page); 66 extern omBin omGetBinOfPage(omBinPage page); 67 extern omBin omGetBinOfAddr(void* addr); 61 68 #endif /* defined(OM_INLINE) || defined(OM_ALLOC_C) */ 62 69 … … 69 76 extern int omIsStaticBin(omBin bin); 70 77 extern void omPrintBinStats(FILE* fd); 78 extern void omPrintBinStat(FILE * fd, omBin bin); 71 79 72 80 /******************************************************************* … … 77 85 #ifndef HAVE_OM_ASSUME 78 86 79 #define omError(msg) (msg)80 87 #define omAssume(x) ((void) 0) 81 88 82 89 #else /* ! HAVE_OM_ASSUME */ 83 90 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) \ 91 92 do \ 92 93 { \ 93 94 if (! (x)) \ 94 95 { \ 95 omReportError("omAssume violation" , f, l);\96 omReportError("omAssume violation"); \ 96 97 } \ 97 98 } \ … … 99 100 100 101 #endif /* HAVE_OM_ASSUME */ 102 103 extern const char* omReportError(const char* msg); 104 #define omError(msg) omReportError(msg) 101 105 102 106 /******************************************************************* -
omalloc/omPrivate.h
re6908a0 r212fc0 5 5 * Author: obachman (Olaf Bachmann) 6 6 * Created: 11/99 7 * Version: $Id: omPrivate.h,v 1. 1.1.1 1999-11-18 17:45:53obachman Exp $7 * Version: $Id: omPrivate.h,v 1.2 1999-11-22 18:12:59 obachman Exp $ 8 8 *******************************************************************/ 9 9 #ifndef OM_PRIVATE_H … … 11 11 12 12 #include <stdlib.h> 13 #include <string.h> 14 13 15 /******************************************************************* 14 16 * … … 100 102 101 103 102 #define omSize2Bin(size) \103 ((size) <= OM_MAX_BLOCK_SIZE ? \104 om_Size2Bin[((size) -1) >> LOG_SIZEOF_OM_ALIGNMENT] : \105 om_LargeBin)106 104 107 105 /******************************************************************* … … 110 108 * 111 109 *******************************************************************/ 112 extern void* omAllocBinFromFullPage(omBinPage page, omBin bin); 113 extern void* omAllocBlockFromFullPage(omBinPage page, omBin bin, 114 const size_t size, const int zero); 110 extern void* omAllocBinFromFullPage(omBin bin); 115 111 extern void omFreeToPageFault(omBinPage page, void* addr); 116 112 … … 133 129 do \ 134 130 { \ 135 if ((page)->used_blocks > 0) \131 if ((page)->used_blocks > 0) \ 136 132 { \ 137 133 *((void**)addr) = (page)->current; \ … … 148 144 149 145 /*******************************************************************/ 150 /* Bin */151 #define __omTypeAllocBin(type, addr, bin) \146 /* Bin */ 147 #define __omTypeAllocBin(type, addr, bin) \ 152 148 do \ 153 149 { \ 154 register omBinPage __om_page = (bin)->current_page; \150 register omBinPage __om_page = (bin)->current_page; \ 155 151 if (__om_page->current != NULL) \ 156 152 __omTypeAllocFromPage(type, addr, __om_page); \ 157 153 else \ 158 addr = (type) omAllocBinFromFullPage( __om_page, bin);\154 addr = (type) omAllocBinFromFullPage(bin); \ 159 155 } \ 160 156 while (0) 161 157 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) \ 159 do \ 160 { \ 161 __omTypeAllocBin(type, addr, bin); \ 162 omMemsetW(addr, 0, (bin)->sizeW); \ 163 } \ 164 while (0) 165 166 #define __omFreeBin(addr) \ 171 167 do \ 172 168 { \ 173 169 register void* __om_addr = (void*) (addr); \ 174 register omBinPage __om_page = omGetPageOfAddr(__om_addr); \170 register omBinPage __om_page = omGetPageOfAddr(__om_addr); \ 175 171 __omFreeToPage(__om_addr, __om_page); \ 176 172 } \ … … 180 176 /*******************************************************************/ 181 177 /* 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) 199 183 200 184 #define __omTypeAllocBlock(type, addr, size) \ 201 185 do \ 202 186 { \ 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 } \ 197 while(0) 198 199 #define __omTypeAlloc0Block(type, addr, size) \ 200 do \ 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 } \ 213 213 while (0) 214 214 … … 216 216 do \ 217 217 { \ 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 } \ 227 while (0) 224 228 225 229 /*******************************************************************/ 226 230 /* 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) \ 235 do \ 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 } \ 252 while (0) 253 254 #define __omTypeAlloc0Chunk(type, addr, size) \ 255 do \ 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 } \ 273 while (0) 244 274 245 275 #define __omFreeChunk(addr) \ … … 247 277 { \ 248 278 void* __addr = ((void*) (addr)) - SIZEOF_OM_ALIGNMENT; \ 249 omBinPage __om_page = *((omBinPage*) __addr); 279 omBinPage __om_page = *((omBinPage*) __addr); \ 250 280 __omFreeToPage(__addr, __om_page); \ 251 281 } \ … … 314 344 omBin omGetSpecBin(size_t size); 315 345 void omUnGetSpecBin(omBin *bin); 346 unsigned long omGetNewStickyAllBinTag(); 347 void omSetStickyAllBinTag(unsigned long sticky); 348 void omUnSetStickyAllBinTag(unsigned long sticky); 349 void omDeleteStickyAllBinTag(unsigned long sticky); 316 350 317 351 #endif /* ! OM_GENERATE_INC */ -
omalloc/omTest.c
re6908a0 r212fc0 7 7 #include "omFindExec.h" 8 8 9 #define MAX_SIZE 1024 10 #define D_LEVEL 10 11 9 12 struct TestAddr_s; 10 13 typedef struct TestAddr_s TestAddr_t; … … 17 20 }; 18 21 19 #define D_LEVEL 10 20 TestAddr bin_addr_list = NULL; 21 TestAddr block_addr_list = NULL; 22 TestAddr chunk_addr_list = NULL; 23 22 TestAddr bin_addr_list[MAX_SIZE >> 2]; 23 TestAddr block_addr_list[MAX_SIZE >> 2]; 24 TestAddr chunk_addr_list[MAX_SIZE >> 2]; 25 omBin bin_list[MAX_SIZE >> 2]; 26 27 void 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 65 void 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 24 99 void TestAllocChunk(size_t size) 25 100 { 26 101 TestAddr addr = 27 (TestAddr) omdCheckAllocChunk(size, 0, D_LEVEL, __FILE__, __LINE__);102 (TestAddr) ALLOC_CHUNK(size); 28 103 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; 30 106 } 31 107 32 108 void TestFreeChunk(size_t size) 33 109 { 34 TestAddr addr = omFindInSortedList(chunk_addr_list, size, size); 110 TestAddr addr = chunk_addr_list[size >> 2]; 111 TestAddr a2; 35 112 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 } 38 127 } 39 128 40 129 void FreeAllChunk() 41 130 { 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 138 void TestAllAddrs() 139 { 140 int i; 42 141 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 51 155 void TestAllocBlock(size_t size) 52 156 { 53 157 TestAddr addr = 54 (TestAddr) omdCheckAllocBlock(size, 0, D_LEVEL, __FILE__, __LINE__);158 (TestAddr) ALLOC_BLOCK(size); 55 159 addr->size = size; 56 160 block_addr_list = omInsertInSortedList(block_addr_list, size, addr); … … 61 165 TestAddr addr = omFindInSortedList(block_addr_list, size, size); 62 166 if (addr != NULL) 167 { 63 168 block_addr_list = omRemoveFromList(block_addr_list, addr); 64 omdCheckFreeBlock(addr, addr->size,D_LEVEL, __FILE__, __LINE__); 169 FREE_BLOCK(addr, addr->size); 170 } 65 171 } 66 172 … … 72 178 addr = block_addr_list; 73 179 block_addr_list = block_addr_list->next; 74 omdCheckFreeBlock(addr, addr->size, D_LEVEL, __FILE__, __LINE__);180 FREE_BLOCK(addr, addr->size); 75 181 } 76 182 } … … 78 184 void TestAllocBin(size_t size) 79 185 { 80 omBin bin = omGetSpecBin(size<5?5:size);81 186 TestAddr addr = 82 (TestAddr) omdCheckAllocBin(bin, 0, D_LEVEL, __FILE__, __LINE__);187 (TestAddr) ALLOC_BIN(size); 83 188 addr->size = size; 84 189 bin_addr_list = omInsertInSortedList(bin_addr_list, size, addr); … … 87 192 void TestFreeBin(size_t size) 88 193 { 89 omBin bin;90 194 TestAddr addr = omFindInSortedList(bin_addr_list, size, size); 91 195 if (addr != NULL) 196 { 92 197 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 } 95 200 } 96 201 … … 98 203 { 99 204 TestAddr addr; 100 omBin bin;101 205 while (bin_addr_list != NULL) 102 206 { 103 207 addr = bin_addr_list; 104 208 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 111 223 int InitSizeGen(int i) 112 224 { 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; 114 230 } 115 231 116 232 int NextSizeGen(int prev) 117 233 { 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; 119 242 } 120 243 121 244 void PrintTest() 122 245 { 123 om PrintCurrentBackTrace(0, 10, stdout);246 omError("sub"); 124 247 } 125 248 126 249 int main(int argc, char* argv[]) 127 250 { 128 int limit, i, size ;251 int limit, i, size, free_all; 129 252 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(); 135 279 if (argc > 1) 136 280 sscanf(argv[1], "%d", &limit); 137 281 else 138 282 limit = 200; 283 284 if (argc > 2) 285 sscanf(argv[2], "%d", &free_all); 286 else 287 free_all = 10000; 139 288 140 289 size = InitSizeGen(limit); 141 290 i = 0; 142 291 143 for (i= 0; i<= limit; i++)292 for (i=1; i<= limit; i++) 144 293 { 145 294 size = NextSizeGen(size); 146 295 TestAllocBin(size); 296 TestAddrs(); 147 297 TestAllocBlock(size); 298 TestAddrs(); 148 299 TestAllocChunk(size); 300 TestAddrs(); 149 301 size = NextSizeGen(size); 150 302 TestAllocBin(size); 303 TestAddrs(); 151 304 TestAllocBlock(size); 305 TestAddrs(); 152 306 TestAllocChunk(size); 307 TestAddrs(); 153 308 TestFreeBin(size); 309 TestAddrs(); 154 310 TestFreeBlock(size); 311 TestAddrs(); 155 312 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 } 156 342 157 343 if (i % 100 == 0) … … 159 345 printf("i=%d\n",i); 160 346 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(); 163 373 omPrintBinStats(stdout); 164 374 FreeAllBin(); 165 375 omPrintBinStats(stdout); 166 FreeAllBlock();167 omPrintBinStats(stdout);168 FreeAllChunk();169 omPrintBinStats(stdout);170 376 return 0; 171 377 } -
omalloc/omTrack.c
re6908a0 r212fc0 4 4 * Author: obachman (Olaf Bachmann) 5 5 * Created: 11/99 6 * Version: $Id: omTrack.c,v 1. 1.1.1 1999-11-18 17:45:53obachman Exp $6 * Version: $Id: omTrack.c,v 1.2 1999-11-22 18:13:00 obachman Exp $ 7 7 *******************************************************************/ 8 8 #include <limits.h> … … 16 16 #endif 17 17 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 82 27 #define OM_GET_RETURN_ADDR(addr, i) \ 83 28 switch(i) \ … … 108 53 addr = NULL; \ 109 54 } 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 111 60 #define OM_GET_FRAME_ADDR(addr, i) \ 112 61 switch(i) \ … … 137 86 addr = NULL; \ 138 87 } 88 #endif /* OM_FRAME_ADDR_RVALUE */ 89 90 static char* om_this_prog = NULL; 91 static void* om_this_main_frame_addr = NULL; 92 static void* om_this_prog_min_return_addr = ((void*) 1023); 93 static void* om_this_prog_max_return_addr = ((void*) ULONG_MAX -1); 94 95 96 void 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 } 139 152 140 153 141 154 int omGetCurrentBackTrace(void** addr, int max_frames) 142 155 { 156 int i = 0; 143 157 #if defined(OM_RETURN_ADDR_WORKS) 144 158 #if defined(OM_FRAME_ADDR_WORKS) … … 150 164 { 151 165 #endif /* ! defined(OM_RETURN_ADDR_WORKS) */ 152 int i;153 166 void* r_addr; 167 if (max_frames > OM_MAX_BT_FRAMES) max_frames = OM_MAX_BT_FRAMES; 154 168 for (i=0; i< max_frames; i++) 155 169 { … … 178 192 #endif /* OM_FRAME_ADDR_WORKS */ 179 193 } 180 return max_frames;181 194 #endif /* defined(OM_RETURN_ADDR_WORKS) */ 182 return 0;195 return i; 183 196 } 184 197 … … 186 199 { 187 200 int i = 0; 201 if (max_frames > OM_MAX_BT_FRAMES) max_frames = OM_MAX_BT_FRAMES; 188 202 #if defined(HAVE_POPEN) && defined(OM_PROG_ADDR2LINE) 189 203 if (om_this_prog != NULL) 190 204 { 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)]; 192 206 FILE *pipe; 193 207 int l; 194 195 208 l = sprintf(command, "%s -s -C -f -e %s", 196 209 OM_PROG_ADDR2LINE, om_this_prog); … … 202 215 } 203 216 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); 226 259 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 233 267 while (i<max_frames && addr[i] != NULL) 234 268 { 235 fprintf(fd, " %p#", addr[i]);269 fprintf(fd, " #%d %p in ??\n", i, addr[i]); 236 270 i++; 237 271 } 238 if (i > 0) 239 { 272 #endif 273 if (i == 0) 274 { 275 fprintf(fd, "??"); 240 276 fputc('\n', fd); 241 fflush(fd);242 }277 } 278 fflush(fd); 243 279 return i; 244 280 } … … 246 282 int omPrintCurrentBackTrace(int from_frame, int max_frames, FILE *fd) 247 283 { 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); 257 288 } 258 289
Note: See TracChangeset
for help on using the changeset viewer.