[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[commits] r9224 - in /trunk/libc: ChangeLog.eglibc malloc/Makefile malloc/memusage.c option-groups.def option-groups.defaults



Author: maxim
Date: Tue Nov 10 23:41:09 2009
New Revision: 9224

Log:
	Add OPTION_EGLIBC_MEMUSAGE option group and
	OPTION_EGLIBC_MEMUSAGE_DEFAULT_BUFFER_SIZE option.

	* option-groups.def (OPTION_EGLIBC_MEMUSAGE): Define new option group.
	(OPTION_EGLIBC_MEMUSAGE_DEFAULT_BUFFER_SIZE): Document option.
	* option-groups.defaults (OPTION_EGLIBC_MEMUSAGE): Add.
	* malloc/Makefile (libmemusage): Build if option group is selected.
	(memusage): Update CPPFLAGS.
	(memusagestat): Don't build without OPTION_EGLIBC_MEMUSAGE.
	* malloc/memusage.c (DEFAULT_BUFFER_SIZE): Allow overriding the default.

Modified:
    trunk/libc/ChangeLog.eglibc
    trunk/libc/malloc/Makefile
    trunk/libc/malloc/memusage.c
    trunk/libc/option-groups.def
    trunk/libc/option-groups.defaults

Modified: trunk/libc/ChangeLog.eglibc
==============================================================================
--- trunk/libc/ChangeLog.eglibc (original)
+++ trunk/libc/ChangeLog.eglibc Tue Nov 10 23:41:09 2009
@@ -1,3 +1,16 @@
+2009-11-11  Maxim Kuvyrkov  <maxim@xxxxxxxxxxxxxxxx>
+
+	Add OPTION_EGLIBC_MEMUSAGE option group and
+	OPTION_EGLIBC_MEMUSAGE_DEFAULT_BUFFER_SIZE option.
+
+	* option-groups.def (OPTION_EGLIBC_MEMUSAGE): Define new option group.
+	(OPTION_EGLIBC_MEMUSAGE_DEFAULT_BUFFER_SIZE): Document option.
+	* option-groups.defaults (OPTION_EGLIBC_MEMUSAGE): Add.
+	* malloc/Makefile (libmemusage): Build if option group is selected.
+	(memusage): Update CPPFLAGS.
+	(memusagestat): Don't build without OPTION_EGLIBC_MEMUSAGE.
+	* malloc/memusage.c (DEFAULT_BUFFER_SIZE): Allow overriding the default.
+
 2009-11-09  Maxim Kuvyrkov  <maxim@xxxxxxxxxxxxxxxx>
 	    Peter Seebach  <peter.seebach@xxxxxxxxxxxxx>
 

Modified: trunk/libc/malloc/Makefile
==============================================================================
--- trunk/libc/malloc/Makefile (original)
+++ trunk/libc/malloc/Makefile Tue Nov 10 23:41:09 2009
@@ -20,6 +20,8 @@
 #
 #	Makefile for malloc routines
 #
+include ../option-groups.mak
+
 subdir	:= malloc
 
 all:
@@ -43,8 +45,14 @@
 non-lib.a := libmcheck.a
 
 # Additional library.
+ifeq ($(OPTION_EGLIBC_MEMUSAGE),y)
 extra-libs = libmemusage
 extra-libs-others = $(extra-libs)
+
+ifdef OPTION_EGLIBC_MEMUSAGE_DEFAULT_BUFFER_SIZE
+CPPFLAGS-memusage += -D__OPTION_EGLIBC_MEMUSAGE_DEFAULT_BUFFER_SIZE=$(OPTION_EGLIBC_MEMUSAGE_DEFAULT_BUFFER_SIZE)
+endif
+endif
 
 libmemusage-routines = memusage
 libmemusage-inhibit-o = $(filter-out .os,$(object-suffixes))
@@ -76,7 +84,7 @@
 # Unless we get a test for the availability of libgd which also works
 # for cross-compiling we disable the memusagestat generation in this
 # situation.
-ifneq ($(cross-compiling),yes)
+ifeq ($(cross-compiling)$(OPTION_EGLIBC_MEMUSAGE),noy)
 # If the gd library is available we build the `memusagestat' program.
 ifneq ($(LIBGD),no)
 others: $(objpfx)memusage

Modified: trunk/libc/malloc/memusage.c
==============================================================================
--- trunk/libc/malloc/memusage.c (original)
+++ trunk/libc/malloc/memusage.c Tue Nov 10 23:41:09 2009
@@ -33,6 +33,7 @@
 #include <unistd.h>
 #include <sys/mman.h>
 #include <sys/time.h>
+#include <gnu/option-groups.h>
 
 #include <memusage.h>
 
@@ -93,7 +94,12 @@
 #define peak_stack	peak_use[1]
 #define peak_total	peak_use[2]
 
-#define DEFAULT_BUFFER_SIZE	32768
+#ifndef __OPTION_EGLIBC_MEMUSAGE_DEFAULT_BUFFER_SIZE
+# define DEFAULT_BUFFER_SIZE	32768
+#else
+# define DEFAULT_BUFFER_SIZE	__OPTION_EGLIBC_MEMUSAGE_DEFAULT_BUFFER_SIZE
+#endif
+
 static size_t buffer_size;
 
 static int fd = -1;

Modified: trunk/libc/option-groups.def
==============================================================================
--- trunk/libc/option-groups.def (original)
+++ trunk/libc/option-groups.def Tue Nov 10 23:41:09 2009
@@ -465,6 +465,25 @@
        group; if you disable OPTION_EGLIBC_LOCALE_CODE, you must also
        disable OPTION_EGLIBC_CATGETS.
 
+config OPTION_EGLIBC_MEMUSAGE
+   bool "Memory profiling library"
+   help
+       This option group includes the `libmemusage' library and
+       the `memusage' and `memusagestat' utilities.
+       These components provide memory profiling functions.
+
+     OPTION_EGLIBC_MEMUSAGE_DEFAULT_BUFFER_SIZE
+
+       Libmemusage library buffers the profiling data in memory
+       before writing it out to disk.  By default, the library
+       allocates 1.5M buffer, which can be substantial for some
+       systems.  OPTION_EGLIBC_MEMUSAGE_DEFAULT_BUFFER_SIZE option
+       allows to change the default buffer size.  It specifies
+       the number of entries the buffer should have.
+       On most architectures one buffer entry amounts to 48 bytes,
+       so setting this option to the value of 512 will reduce the size of
+       the memory buffer to 24K.
+
 config OPTION_EGLIBC_NIS
    bool "Support for NIS, NIS+, and the special 'compat' services."
    depends OPTION_EGLIBC_INET

Modified: trunk/libc/option-groups.defaults
==============================================================================
--- trunk/libc/option-groups.defaults (original)
+++ trunk/libc/option-groups.defaults Tue Nov 10 23:41:09 2009
@@ -26,6 +26,7 @@
 OPTION_EGLIBC_LIBM = y
 OPTION_EGLIBC_LOCALES = y
 OPTION_EGLIBC_LOCALE_CODE = y
+OPTION_EGLIBC_MEMUSAGE = y
 OPTION_EGLIBC_NIS = y
 OPTION_EGLIBC_NSSWITCH = y
 OPTION_EGLIBC_RCMD = y