Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mpim-sw
libcdi
Commits
b776fbc1
Commit
b776fbc1
authored
Feb 26, 2010
by
Uwe Schulzweida
Browse files
dmemory update
parent
eea38794
Changes
5
Hide whitespace changes
Inline
Side-by-side
configure
View file @
b776fbc1
...
...
@@ -5993,9 +5993,9 @@ rm -f conftest.mmap
# Checks for library malloc.
{
echo
"
$as_me
:
$LINENO
: checking for mall
inf
o in -lmalloc"
>
&5
echo
$ECHO_N
"checking for mall
inf
o in -lmalloc...
$ECHO_C
"
>
&6
;
}
if
test
"
${
ac_cv_lib_malloc_mall
inf
o
+set
}
"
=
set
;
then
{
echo
"
$as_me
:
$LINENO
: checking for mallo
c
in -lmalloc"
>
&5
echo
$ECHO_N
"checking for mallo
c
in -lmalloc...
$ECHO_C
"
>
&6
;
}
if
test
"
${
ac_cv_lib_malloc_mallo
c
+set
}
"
=
set
;
then
echo
$ECHO_N
"(cached)
$ECHO_C
"
>
&6
else
ac_check_lib_save_LIBS
=
$LIBS
...
...
@@ -6013,11 +6013,11 @@ cat >>conftest.$ac_ext <<_ACEOF
#ifdef __cplusplus
extern "C"
#endif
char mall
inf
o ();
char mallo
c
();
int
main ()
{
return mall
inf
o ();
return mallo
c
();
;
return 0;
}
...
...
@@ -6040,21 +6040,21 @@ eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
test
!
-s
conftest.err
}
&&
test
-s
conftest
$ac_exeext
&&
$as_test_x
conftest
$ac_exeext
;
then
ac_cv_lib_malloc_mall
inf
o
=
yes
ac_cv_lib_malloc_mallo
c
=
yes
else
echo
"
$as_me
: failed program was:"
>
&5
sed
's/^/| /'
conftest.
$ac_ext
>
&5
ac_cv_lib_malloc_mall
inf
o
=
no
ac_cv_lib_malloc_mallo
c
=
no
fi
rm
-f
core conftest.err conftest.
$ac_objext
conftest_ipa8_conftest.oo
\
conftest
$ac_exeext
conftest.
$ac_ext
LIBS
=
$ac_check_lib_save_LIBS
fi
{
echo
"
$as_me
:
$LINENO
: result:
$ac_cv_lib_malloc_mall
inf
o
"
>
&5
echo
"
${
ECHO_T
}
$ac_cv_lib_malloc_mall
inf
o
"
>
&6
;
}
if
test
$ac_cv_lib_malloc_mall
inf
o
=
yes
;
then
{
echo
"
$as_me
:
$LINENO
: result:
$ac_cv_lib_malloc_mallo
c
"
>
&5
echo
"
${
ECHO_T
}
$ac_cv_lib_malloc_mallo
c
"
>
&6
;
}
if
test
$ac_cv_lib_malloc_mallo
c
=
yes
;
then
cat
>>
confdefs.h
<<
_ACEOF
#define HAVE_LIBMALLOC 1
_ACEOF
...
...
@@ -6168,6 +6168,249 @@ _ACEOF
fi
# Checks for header files
for
ac_header
in
malloc.h
do
as_ac_Header
=
`
echo
"ac_cv_header_
$ac_header
"
|
$as_tr_sh
`
if
{
as_var
=
$as_ac_Header
;
eval
"test
\"\$
{
$as_var
+set}
\"
= set"
;
}
;
then
{
echo
"
$as_me
:
$LINENO
: checking for
$ac_header
"
>
&5
echo
$ECHO_N
"checking for
$ac_header
...
$ECHO_C
"
>
&6
;
}
if
{
as_var
=
$as_ac_Header
;
eval
"test
\"\$
{
$as_var
+set}
\"
= set"
;
}
;
then
echo
$ECHO_N
"(cached)
$ECHO_C
"
>
&6
fi
ac_res
=
`
eval echo
'${'
$as_ac_Header
'}'
`
{
echo
"
$as_me
:
$LINENO
: result:
$ac_res
"
>
&5
echo
"
${
ECHO_T
}
$ac_res
"
>
&6
;
}
else
# Is the header compilable?
{
echo
"
$as_me
:
$LINENO
: checking
$ac_header
usability"
>
&5
echo
$ECHO_N
"checking
$ac_header
usability...
$ECHO_C
"
>
&6
;
}
cat
>
conftest.
$ac_ext
<<
_ACEOF
/* confdefs.h. */
_ACEOF
cat
confdefs.h
>>
conftest.
$ac_ext
cat
>>
conftest.
$ac_ext
<<
_ACEOF
/* end confdefs.h. */
$ac_includes_default
#include <
$ac_header
>
_ACEOF
rm
-f
conftest.
$ac_objext
if
{
(
ac_try
=
"
$ac_compile
"
case
"((
$ac_try
"
in
*
\"
*
|
*
\`
*
|
*
\\
*
)
ac_try_echo
=
\$
ac_try
;;
*
)
ac_try_echo
=
$ac_try
;;
esac
eval
"echo
\"\$
as_me:
$LINENO
:
$ac_try_echo
\"
"
)
>
&5
(
eval
"
$ac_compile
"
)
2>conftest.er1
ac_status
=
$?
grep
-v
'^ *+'
conftest.er1
>
conftest.err
rm
-f
conftest.er1
cat
conftest.err
>
&5
echo
"
$as_me
:
$LINENO
:
\$
? =
$ac_status
"
>
&5
(
exit
$ac_status
)
;
}
&&
{
test
-z
"
$ac_c_werror_flag
"
||
test
!
-s
conftest.err
}
&&
test
-s
conftest.
$ac_objext
;
then
ac_header_compiler
=
yes
else
echo
"
$as_me
: failed program was:"
>
&5
sed
's/^/| /'
conftest.
$ac_ext
>
&5
ac_header_compiler
=
no
fi
rm
-f
core conftest.err conftest.
$ac_objext
conftest.
$ac_ext
{
echo
"
$as_me
:
$LINENO
: result:
$ac_header_compiler
"
>
&5
echo
"
${
ECHO_T
}
$ac_header_compiler
"
>
&6
;
}
# Is the header present?
{
echo
"
$as_me
:
$LINENO
: checking
$ac_header
presence"
>
&5
echo
$ECHO_N
"checking
$ac_header
presence...
$ECHO_C
"
>
&6
;
}
cat
>
conftest.
$ac_ext
<<
_ACEOF
/* confdefs.h. */
_ACEOF
cat
confdefs.h
>>
conftest.
$ac_ext
cat
>>
conftest.
$ac_ext
<<
_ACEOF
/* end confdefs.h. */
#include <
$ac_header
>
_ACEOF
if
{
(
ac_try
=
"
$ac_cpp
conftest.
$ac_ext
"
case
"((
$ac_try
"
in
*
\"
*
|
*
\`
*
|
*
\\
*
)
ac_try_echo
=
\$
ac_try
;;
*
)
ac_try_echo
=
$ac_try
;;
esac
eval
"echo
\"\$
as_me:
$LINENO
:
$ac_try_echo
\"
"
)
>
&5
(
eval
"
$ac_cpp
conftest.
$ac_ext
"
)
2>conftest.er1
ac_status
=
$?
grep
-v
'^ *+'
conftest.er1
>
conftest.err
rm
-f
conftest.er1
cat
conftest.err
>
&5
echo
"
$as_me
:
$LINENO
:
\$
? =
$ac_status
"
>
&5
(
exit
$ac_status
)
;
}
>
/dev/null
&&
{
test
-z
"
$ac_c_preproc_warn_flag$ac_c_werror_flag
"
||
test
!
-s
conftest.err
}
;
then
ac_header_preproc
=
yes
else
echo
"
$as_me
: failed program was:"
>
&5
sed
's/^/| /'
conftest.
$ac_ext
>
&5
ac_header_preproc
=
no
fi
rm
-f
conftest.err conftest.
$ac_ext
{
echo
"
$as_me
:
$LINENO
: result:
$ac_header_preproc
"
>
&5
echo
"
${
ECHO_T
}
$ac_header_preproc
"
>
&6
;
}
# So? What about this header?
case
$ac_header_compiler
:
$ac_header_preproc
:
$ac_c_preproc_warn_flag
in
yes
:no:
)
{
echo
"
$as_me
:
$LINENO
: WARNING:
$ac_header
: accepted by the compiler, rejected by the preprocessor!"
>
&5
echo
"
$as_me
: WARNING:
$ac_header
: accepted by the compiler, rejected by the preprocessor!"
>
&2
;
}
{
echo
"
$as_me
:
$LINENO
: WARNING:
$ac_header
: proceeding with the compiler's result"
>
&5
echo
"
$as_me
: WARNING:
$ac_header
: proceeding with the compiler's result"
>
&2
;
}
ac_header_preproc
=
yes
;;
no:yes:
*
)
{
echo
"
$as_me
:
$LINENO
: WARNING:
$ac_header
: present but cannot be compiled"
>
&5
echo
"
$as_me
: WARNING:
$ac_header
: present but cannot be compiled"
>
&2
;
}
{
echo
"
$as_me
:
$LINENO
: WARNING:
$ac_header
: check for missing prerequisite headers?"
>
&5
echo
"
$as_me
: WARNING:
$ac_header
: check for missing prerequisite headers?"
>
&2
;
}
{
echo
"
$as_me
:
$LINENO
: WARNING:
$ac_header
: see the Autoconf documentation"
>
&5
echo
"
$as_me
: WARNING:
$ac_header
: see the Autoconf documentation"
>
&2
;
}
{
echo
"
$as_me
:
$LINENO
: WARNING:
$ac_header
: section
\"
Present But Cannot Be Compiled
\"
"
>
&5
echo
"
$as_me
: WARNING:
$ac_header
: section
\"
Present But Cannot Be Compiled
\"
"
>
&2
;
}
{
echo
"
$as_me
:
$LINENO
: WARNING:
$ac_header
: proceeding with the preprocessor's result"
>
&5
echo
"
$as_me
: WARNING:
$ac_header
: proceeding with the preprocessor's result"
>
&2
;
}
{
echo
"
$as_me
:
$LINENO
: WARNING:
$ac_header
: in the future, the compiler will take precedence"
>
&5
echo
"
$as_me
: WARNING:
$ac_header
: in the future, the compiler will take precedence"
>
&2
;
}
(
cat
<<
\
_ASBOX
## -------------------------------------- ##
## Report this to Uwe.Schulzweida@zmaw.de ##
## -------------------------------------- ##
_ASBOX
)
|
sed
"s/^/
$as_me
: WARNING: /"
>
&2
;;
esac
{
echo
"
$as_me
:
$LINENO
: checking for
$ac_header
"
>
&5
echo
$ECHO_N
"checking for
$ac_header
...
$ECHO_C
"
>
&6
;
}
if
{
as_var
=
$as_ac_Header
;
eval
"test
\"\$
{
$as_var
+set}
\"
= set"
;
}
;
then
echo
$ECHO_N
"(cached)
$ECHO_C
"
>
&6
else
eval
"
$as_ac_Header
=
\$
ac_header_preproc"
fi
ac_res
=
`
eval echo
'${'
$as_ac_Header
'}'
`
{
echo
"
$as_me
:
$LINENO
: result:
$ac_res
"
>
&5
echo
"
${
ECHO_T
}
$ac_res
"
>
&6
;
}
fi
if
test
`
eval echo
'${'
$as_ac_Header
'}'
`
=
yes
;
then
cat
>>
confdefs.h
<<
_ACEOF
#define `echo "HAVE_
$ac_header
" |
$as_tr_cpp
` 1
_ACEOF
fi
done
# Checks for the availability of functions
for
ac_func
in
mallinfo
do
as_ac_var
=
`
echo
"ac_cv_func_
$ac_func
"
|
$as_tr_sh
`
{
echo
"
$as_me
:
$LINENO
: checking for
$ac_func
"
>
&5
echo
$ECHO_N
"checking for
$ac_func
...
$ECHO_C
"
>
&6
;
}
if
{
as_var
=
$as_ac_var
;
eval
"test
\"\$
{
$as_var
+set}
\"
= set"
;
}
;
then
echo
$ECHO_N
"(cached)
$ECHO_C
"
>
&6
else
cat
>
conftest.
$ac_ext
<<
_ACEOF
/* confdefs.h. */
_ACEOF
cat
confdefs.h
>>
conftest.
$ac_ext
cat
>>
conftest.
$ac_ext
<<
_ACEOF
/* end confdefs.h. */
/* Define
$ac_func
to an innocuous variant, in case <limits.h> declares
$ac_func
.
For example, HP-UX 11i <limits.h> declares gettimeofday. */
#define
$ac_func
innocuous_
$ac_func
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char
$ac_func
(); below.
Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
<limits.h> exists even on freestanding compilers. */
#ifdef __STDC__
# include <limits.h>
#else
# include <assert.h>
#endif
#undef
$ac_func
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char
$ac_func
();
/* The GNU C library defines this for functions which it implements
to always fail with ENOSYS. Some functions are actually named
something starting with __ and the normal name is an alias. */
#if defined __stub_
$ac_func
|| defined __stub___
$ac_func
choke me
#endif
int
main ()
{
return
$ac_func
();
;
return 0;
}
_ACEOF
rm
-f
conftest.
$ac_objext
conftest
$ac_exeext
if
{
(
ac_try
=
"
$ac_link
"
case
"((
$ac_try
"
in
*
\"
*
|
*
\`
*
|
*
\\
*
)
ac_try_echo
=
\$
ac_try
;;
*
)
ac_try_echo
=
$ac_try
;;
esac
eval
"echo
\"\$
as_me:
$LINENO
:
$ac_try_echo
\"
"
)
>
&5
(
eval
"
$ac_link
"
)
2>conftest.er1
ac_status
=
$?
grep
-v
'^ *+'
conftest.er1
>
conftest.err
rm
-f
conftest.er1
cat
conftest.err
>
&5
echo
"
$as_me
:
$LINENO
:
\$
? =
$ac_status
"
>
&5
(
exit
$ac_status
)
;
}
&&
{
test
-z
"
$ac_c_werror_flag
"
||
test
!
-s
conftest.err
}
&&
test
-s
conftest
$ac_exeext
&&
$as_test_x
conftest
$ac_exeext
;
then
eval
"
$as_ac_var
=yes"
else
echo
"
$as_me
: failed program was:"
>
&5
sed
's/^/| /'
conftest.
$ac_ext
>
&5
eval
"
$as_ac_var
=no"
fi
rm
-f
core conftest.err conftest.
$ac_objext
conftest_ipa8_conftest.oo
\
conftest
$ac_exeext
conftest.
$ac_ext
fi
ac_res
=
`
eval echo
'${'
$as_ac_var
'}'
`
{
echo
"
$as_me
:
$LINENO
: result:
$ac_res
"
>
&5
echo
"
${
ECHO_T
}
$ac_res
"
>
&6
;
}
if
test
`
eval echo
'${'
$as_ac_var
'}'
`
=
yes
;
then
cat
>>
confdefs.h
<<
_ACEOF
#define `echo "HAVE_
$ac_func
" |
$as_tr_cpp
` 1
_ACEOF
fi
done
# Checks for the availability of ANSI-C99 functions
for
ac_func
in
isnan
...
...
configure.ac
View file @
b776fbc1
...
...
@@ -33,11 +33,17 @@ AC_SYS_LARGEFILE
AC_FUNC_MMAP
# Checks for library malloc.
AC_CHECK_LIB(malloc, mall
inf
o)
AC_CHECK_LIB(malloc, mallo
c
)
# Checks for structures.
AC_CHECK_MEMBERS([struct stat.st_blksize])
# Checks for header files
AC_CHECK_HEADERS(malloc.h)
# Checks for the availability of functions
AC_CHECK_FUNCS(mallinfo)
# Checks for the availability of ANSI-C99 functions
AC_CHECK_FUNCS(isnan)
...
...
src/config.h.in
View file @
b776fbc1
...
...
@@ -54,6 +54,12 @@
/* Define to 1 if you have the `sz' library (-lsz). */
#undef HAVE_LIBSZ
/* Define to 1 if you have the `mallinfo' function. */
#undef HAVE_MALLINFO
/* Define to 1 if you have the <malloc.h> header file. */
#undef HAVE_MALLOC_H
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
...
...
src/dmemory.c
View file @
b776fbc1
...
...
@@ -58,19 +58,20 @@ static MemTable *memTable;
static
int
memTableSize
=
0
;
static
long
memAccess
=
0
;
static
size_t
MemObjs
=
0
;
static
size_t
MaxMemObjs
=
0
;
static
size_t
MemUsed
=
0
;
static
size_t
MaxMemUsed
=
0
;
static
size_t
MemObjs
=
0
;
static
size_t
MaxMemObjs
=
0
;
static
size_t
MemUsed
=
0
;
static
size_t
MaxMemUsed
=
0
;
static
int
MEM_Debug
=
0
;
/* If set to 1, debugging */
static
int
MEM_Debug
=
0
;
/* If set to 1, debugging */
void
memDebug
(
int
debug
)
{
MEM_Debug
=
debug
;
}
static
void
memInternalProblem
(
const
char
*
caller
,
const
char
*
fmt
,
...)
static
void
memInternalProblem
(
const
char
*
caller
,
const
char
*
fmt
,
...)
{
va_list
args
;
...
...
@@ -86,8 +87,8 @@ static void memInternalProblem(const char *caller, const char *fmt, ...)
exit
(
EXIT_FAILURE
);
}
static
void
memError
(
const
char
*
caller
,
const
char
*
file
,
int
line
,
size_t
size
)
static
void
memError
(
const
char
*
caller
,
const
char
*
file
,
int
line
,
size_t
size
)
{
printf
(
"
\n
"
);
fprintf
(
stderr
,
"Error (%s) : Allocation of %lu bytes failed. [ line %d file %s ]
\n
"
,
...
...
@@ -99,9 +100,9 @@ static void memError(const char *caller, const char *file, int line, size_t size
exit
(
EXIT_FAILURE
);
}
static
void
memListPrintEntry
(
int
mtype
,
int
item
,
size_t
size
,
void
*
ptr
,
const
char
*
caller
,
const
char
*
file
,
int
line
)
static
void
memListPrintEntry
(
int
mtype
,
int
item
,
size_t
size
,
void
*
ptr
,
const
char
*
caller
,
const
char
*
file
,
int
line
)
{
switch
(
mtype
)
{
...
...
@@ -132,8 +133,8 @@ static void memListPrintEntry(int mtype, int item, size_t size, void *ptr,
fprintf
(
stderr
,
"]
\n
"
);
}
static
void
memListPrintTable
(
void
)
static
void
memListPrintTable
(
void
)
{
int
memID
,
item
,
item1
,
item2
=
0
;
...
...
@@ -191,8 +192,8 @@ static void memListPrintTable(void)
}
}
static
void
memGetDebugLevel
(
void
)
static
void
memGetDebugLevel
(
void
)
{
char
*
debugLevel
;
...
...
@@ -208,8 +209,8 @@ static void memGetDebugLevel(void)
}
}
static
void
memInit
(
void
)
static
void
memInit
(
void
)
{
static
int
initDebugLevel
=
0
;
...
...
@@ -220,8 +221,8 @@ static void memInit(void)
}
}
static
int
memListDeleteEntry
(
void
*
ptr
,
size_t
*
size
)
static
int
memListDeleteEntry
(
void
*
ptr
,
size_t
*
size
)
{
int
memID
=
0
;
int
item
=
UNDEFID
;
...
...
@@ -244,8 +245,8 @@ static int memListDeleteEntry(void *ptr, size_t *size)
return
(
item
);
}
static
void
memTableInitEntry
(
int
memID
)
static
void
memTableInitEntry
(
int
memID
)
{
static
char
func
[]
=
"memTableInitEntry"
;
...
...
@@ -260,9 +261,9 @@ static void memTableInitEntry(int memID)
memTable
[
memID
].
line
=
UNDEFID
;
}
static
int
memListNewEntry
(
int
mtype
,
void
*
ptr
,
size_t
size
,
size_t
nobj
,
const
char
*
caller
,
const
char
*
file
,
int
line
)
static
int
memListNewEntry
(
int
mtype
,
void
*
ptr
,
size_t
size
,
size_t
nobj
,
const
char
*
caller
,
const
char
*
file
,
int
line
)
{
static
char
func
[]
=
"memListNewEntry"
;
static
int
item
=
0
;
...
...
@@ -348,9 +349,9 @@ static int memListNewEntry(int mtype, void *ptr, size_t size, size_t nobj,
return
(
item
++
);
}
static
int
memListChangeEntry
(
void
*
ptrold
,
void
*
ptr
,
size_t
size
,
const
char
*
caller
,
const
char
*
file
,
int
line
)
static
int
memListChangeEntry
(
void
*
ptrold
,
void
*
ptr
,
size_t
size
,
const
char
*
caller
,
const
char
*
file
,
int
line
)
{
static
char
func
[]
=
"memListChangeEntry"
;
int
item
=
UNDEFID
;
...
...
@@ -546,17 +547,22 @@ size_t memTotal(void)
size_t
memtotal
=
0
;
#if defined (HAVE_MALLINFO)
struct
mallinfo
meminfo
=
mallinfo
();
/*
printf("arena %d\n", meminfo.arena);
printf("ordblks %d\n", meminfo.ordblks);
printf("smblks %d\n", meminfo.smblks);
printf("usmblks %d\n", meminfo.usmblks);
printf("fsmblks %d\n", meminfo.fsmblks);
printf("uordblks %d\n", meminfo.uordblks);
printf("fordblks %d\n", meminfo.fordblks);
printf("Memory in use: %d bytes\n", meminfo.usmblks + meminfo.uordblks);
printf("Total heap size: %d bytes\n", meminfo.arena);
*/
if
(
MEM_Debug
)
{
fprintf
(
stderr
,
"arena %8ld (non-mmapped space allocated from system)
\n
"
,
(
unsigned
long
)
meminfo
.
arena
);
fprintf
(
stderr
,
"ordblks %8ld (number of free chunks)
\n
"
,
(
unsigned
long
)
meminfo
.
ordblks
);
fprintf
(
stderr
,
"smblks %8ld (number of fastbin blocks)
\n
"
,
(
unsigned
long
)
meminfo
.
smblks
);
fprintf
(
stderr
,
"hblks %8ld (number of mmapped regions)
\n
"
,
(
unsigned
long
)
meminfo
.
hblks
);
fprintf
(
stderr
,
"hblkhd %8ld (space in mmapped regions)
\n
"
,
(
unsigned
long
)
meminfo
.
hblkhd
);
fprintf
(
stderr
,
"usmblks %8ld (maximum total allocated space)
\n
"
,
(
unsigned
long
)
meminfo
.
usmblks
);
fprintf
(
stderr
,
"fsmblks %8ld (maximum total allocated space)
\n
"
,
(
unsigned
long
)
meminfo
.
fsmblks
);
fprintf
(
stderr
,
"uordblks %8ld (total allocated space)
\n
"
,
(
unsigned
long
)
meminfo
.
uordblks
);
fprintf
(
stderr
,
"fordblks %8ld (total free space)
\n
"
,
(
unsigned
long
)
meminfo
.
fordblks
);
fprintf
(
stderr
,
"Memory in use: %8ld bytes
\n
"
,
(
unsigned
long
)
meminfo
.
usmblks
+
meminfo
.
uordblks
);
fprintf
(
stderr
,
"Total heap size: %8ld bytes
\n
"
,
(
unsigned
long
)
meminfo
.
arena
);
/* malloc_stats(); */
}
memtotal
=
meminfo
.
arena
;
#endif
...
...
src/dmemory.h
View file @
b776fbc1
...
...
@@ -3,7 +3,6 @@
#include
<stdlib.h>
/*
* if DEBUG_MEMORY is defined setenv MEMORY_DEBUG to debug memory
*/
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment