summaryrefslogtreecommitdiff
path: root/src/profiler.c
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2012-09-24 17:15:53 -0400
committerStefan Monnier <monnier@iro.umontreal.ca>2012-09-24 17:15:53 -0400
commitad942b63d7a9b984752f46bc2049fe10e488230d (patch)
tree71e47ecb9d1e00b996a7e291fef9d4dda1f82386 /src/profiler.c
parent3d80c99f3817bf5eccd6acc6a79498a4fde979a4 (diff)
downloademacs-ad942b63d7a9b984752f46bc2049fe10e488230d.tar.gz
Try to let it compile on other platforms
* src/profiler.c (evict_lower_half): Fix typo. (PROFILER_CPU_SUPPORT): Check and define if cpu-profiler is supported. Don't compile the cpu-profiler code, if not supported. (malloc_probe): Presume memory_log is non-nil. (syms_of_profiler): Don't defsubr functions when they aren't defined. * src/lisp.h (sample_profiler_running, gc_probe): Don't declare.
Diffstat (limited to 'src/profiler.c')
-rw-r--r--src/profiler.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/profiler.c b/src/profiler.c
index 5eaaaf3330f..d22ab14e7ce 100644
--- a/src/profiler.c
+++ b/src/profiler.c
@@ -126,7 +126,7 @@ static void evict_lower_half (log_t *log)
int j;
eassert (VECTORP (key));
for (j = 0; j < ASIZE (key); j++)
- ASET (key, i, Qnil);
+ ASET (key, j, Qnil);
}
set_hash_key_slot (log, i, key);
}
@@ -190,6 +190,9 @@ record_backtrace (log_t *log, size_t count)
/* Sample profiler. */
+#if defined SIGPROF && defined HAVE_SETITIMER
+#define PROFILER_CPU_SUPPORT
+
static Lisp_Object cpu_log;
/* Separate counter for the time spent in the GC. */
static EMACS_INT cpu_gc_count;
@@ -279,7 +282,7 @@ log is collected and SLOTS is a list of slots. */)
cpu_gc_count = 0;
return result;
}
-
+#endif
/* Memory profiler. */
@@ -365,12 +368,11 @@ sigprof_handler (int signal, siginfo_t *info, void *ctx)
}
/* Record that the current backtrace allocated SIZE bytes. */
-/* FIXME: Inline it everywhere! */
void
malloc_probe (size_t size)
{
- if (HASH_TABLE_P (memory_log))
- record_backtrace (XHASH_TABLE (memory_log), size);
+ eassert (HASH_TABLE_P (memory_log));
+ record_backtrace (XHASH_TABLE (memory_log), size);
}
void
@@ -383,17 +385,18 @@ syms_of_profiler (void)
doc: /* FIXME */);
profiler_slot_heap_size = 10000;
- cpu_log = memory_log = Qnil;
- staticpro (&cpu_log);
- staticpro (&memory_log);
-
/* FIXME: Rename things to start with "profiler-", to use "cpu" instead of
"sample", and to make them sound like they're internal or something. */
+#ifdef PROFILER_CPU_SUPPORT
+ cpu_log = Qnil;
+ staticpro (&cpu_log);
defsubr (&Ssample_profiler_start);
defsubr (&Ssample_profiler_stop);
defsubr (&Ssample_profiler_running_p);
defsubr (&Ssample_profiler_log);
-
+#endif
+ memory_log = Qnil;
+ staticpro (&memory_log);
defsubr (&Smemory_profiler_start);
defsubr (&Smemory_profiler_stop);
defsubr (&Smemory_profiler_running_p);