X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fget-rusage-data.c;h=2ee911cc6e078e4f18daa7f4e999b5bb6b8f4be7;hb=7ef6c64e210ac0979d7e8ac69bc5b5208c2405ab;hp=20c49ce19db3ed68d30484802f3c849224530f48;hpb=b4f285e68da56b110a01b0dce117086f6e829d29;p=gnulib.git diff --git a/lib/get-rusage-data.c b/lib/get-rusage-data.c index 20c49ce19..2ee911cc6 100644 --- a/lib/get-rusage-data.c +++ b/lib/get-rusage-data.c @@ -1,5 +1,5 @@ /* Getter for RLIMIT_DATA. - Copyright (C) 2011 Free Software Foundation, Inc. + Copyright (C) 2011-2014 Free Software Foundation, Inc. Written by Bruno Haible , 2011. This program is free software: you can redistribute it and/or modify @@ -50,7 +50,7 @@ Note that malloc() falls back on mmap() for large allocations and also for small allocations if there is not enough room in the data segment. - MacOS X: + Mac OS X: a) setrlimit with RLIMIT_DATA succeeds but does not really work: The OS ignores RLIMIT_DATA. Therefore get_rusage_data_via_setrlimit() is always 0. @@ -69,7 +69,9 @@ OpenBSD: a) setrlimit with RLIMIT_DATA works. - b) No VMA iteration API exists. + b) mquery() can be used to find out about the virtual memory areas. + get_rusage_data_via_setrlimit() works much better than + get_rusage_data_via_iterator(). Note that malloc() appears to use mmap() for both large and small allocations. @@ -103,7 +105,7 @@ get_rusage_data_via_setrlimit() therefore produces a wrong value. b) The /proc/$pid/maps file lists only the memory areas belonging to the executable and shared libraries, not the anonymous memory. - But the native Win32 API works. + But the native Windows API works. Note that malloc() apparently falls back on mmap() for large allocations. mingw: @@ -148,7 +150,7 @@ # define errno_expected() (errno == EINVAL) # endif -static inline uintptr_t +static uintptr_t get_rusage_data_via_setrlimit (void) { uintptr_t result; @@ -304,7 +306,7 @@ get_rusage_data_via_setrlimit (void) #else -static inline uintptr_t +static uintptr_t get_rusage_data_via_setrlimit (void) { return 0; @@ -335,11 +337,11 @@ vma_iterate_callback (void *data, uintptr_t start, uintptr_t end, return 0; } -static inline uintptr_t +static uintptr_t get_rusage_data_via_iterator (void) { # if ((defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__) || defined __BEOS__ || defined __HAIKU__ - /* On mingw, there is no sbrk() function. + /* On native Windows, there is no sbrk() function. On Haiku, sbrk(0) always returns 0. */ static void *brk_value; @@ -370,7 +372,7 @@ get_rusage_data_via_iterator (void) #else -static inline uintptr_t +static uintptr_t get_rusage_data_via_iterator (void) { return 0; @@ -382,7 +384,7 @@ get_rusage_data_via_iterator (void) uintptr_t get_rusage_data (void) { -#if (defined __APPLE__ && defined __MACH__) || defined __CYGWIN__ /* MacOS X, Cygwin */ +#if (defined __APPLE__ && defined __MACH__) || defined __CYGWIN__ /* Mac OS X, Cygwin */ /* get_rusage_data_via_setrlimit() does not work. Prefer get_rusage_data_via_iterator(). */ return get_rusage_data_via_iterator ();