Mercurial > hg > octave-nkf > gnulib-hg
changeset 14227:8bb45aca6841
get-rusage-as: Allow for easier testing.
* lib/resource-ext.h (get_rusage_as): Add comment.
* lib/get-rusage-as.c (get_rusage_as_via_setrlimit): Define always.
(main): New function for interactive testing.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Wed, 26 Jan 2011 02:11:18 +0100 |
parents | 7e521272b3c6 |
children | 381ce0fff2fb |
files | ChangeLog lib/get-rusage-as.c lib/resource-ext.h |
diffstat | 3 files changed, 45 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2011-01-25 Bruno Haible <bruno@clisp.org> + + get-rusage-as: Allow for easier testing. + * lib/resource-ext.h (get_rusage_as): Add comment. + * lib/get-rusage-as.c (get_rusage_as_via_setrlimit): Define always. + (main): New function for interactive testing. + 2011-01-25 Bruno Haible <bruno@clisp.org> vma-iter: Treat Haiku like BeOS.
--- a/lib/get-rusage-as.c +++ b/lib/get-rusage-as.c @@ -308,6 +308,14 @@ return result; } +#else + +static inline uintptr_t +get_rusage_as_via_setrlimit (void) +{ + return 0; +} + #endif @@ -364,3 +372,31 @@ return get_rusage_as_via_iterator (); #endif } + + +#ifdef TEST + +#include <stdio.h> + +int +main () +{ + printf ("Initially: 0x%08lX 0x%08lX 0x%08lX\n", + get_rusage_as_via_setrlimit (), get_rusage_as_via_iterator (), + get_rusage_as ()); + malloc (0x88); + printf ("After small malloc: 0x%08lX 0x%08lX 0x%08lX\n", + get_rusage_as_via_setrlimit (), get_rusage_as_via_iterator (), + get_rusage_as ()); + malloc (0x8812); + printf ("After medium malloc: 0x%08lX 0x%08lX 0x%08lX\n", + get_rusage_as_via_setrlimit (), get_rusage_as_via_iterator (), + get_rusage_as ()); + malloc (0x281237); + printf ("After large malloc: 0x%08lX 0x%08lX 0x%08lX\n", + get_rusage_as_via_setrlimit (), get_rusage_as_via_iterator (), + get_rusage_as ()); + return 0; +} + +#endif /* TEST */
--- a/lib/resource-ext.h +++ b/lib/resource-ext.h @@ -27,7 +27,8 @@ /* Returns the amount of address space currently in use by the current process, or zero if unknown. - This is the quantity which is limited by setrlimit(RLIMIT_AS,...). */ + This is the quantity which is limited by setrlimit(RLIMIT_AS,...). + Note: This function always returns zero on OpenBSD and AIX. */ extern uintptr_t get_rusage_as (void);