summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makerules3
-rw-r--r--source/tools/mutool.c18
2 files changed, 21 insertions, 0 deletions
diff --git a/Makerules b/Makerules
index f9f2b06f..c73d8242 100644
--- a/Makerules
+++ b/Makerules
@@ -32,6 +32,9 @@ ifeq "$(HAVE_LIBDL)" "yes"
CFLAGS += -DHAVE_LIBDL
LIBS += -ldl
endif
+else ifeq "$(build)" "gperf"
+CFLAGS += -pipe -O2 -DNDEBUG -fomit-frame-pointer -DGPERF
+LIBS += -lprofiler
else
$(error unknown build setting: '$(build)')
endif
diff --git a/source/tools/mutool.c b/source/tools/mutool.c
index 6d2cfa40..1f163b21 100644
--- a/source/tools/mutool.c
+++ b/source/tools/mutool.c
@@ -41,12 +41,30 @@ namematch(const char *end, const char *start, const char *match)
return ((end-len >= start) && (strncmp(end-len, match, len) == 0));
}
+#ifdef GPERF
+#include "gperftools/profiler.h"
+
+static int profiled_main(int argc, char **argv);
+
+int main(int argc, char **argv)
+{
+ int ret;
+ ProfilerStart("mutool.prof");
+ ret = profiled_main(argc, argv);
+ ProfilerStop();
+ return ret;
+}
+
+static int profiled_main(int argc, char **argv)
+#else
int main(int argc, char **argv)
+#endif
{
char *start, *end;
char buf[32];
int i;
+
if (argc == 0)
{
fprintf(stderr, "No command name found!\n");