diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2012-09-29 23:19:33 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2012-09-29 23:19:33 -0700 |
commit | d89460ed93e67852a95a597a7a1a7983e8828fb9 (patch) | |
tree | 349021cb4c7dd7546ae3e354bee1ab2d0b4b48a5 /src/syssignal.h | |
parent | 65788e2e93a48015493514b7e8b712700d31a7a2 (diff) | |
download | emacs-d89460ed93e67852a95a597a7a1a7983e8828fb9.tar.gz |
Profiler improvements: more-accurate timers, overflow checks.
* profiler.c: Don't include stdio.h, limits.h, sys/time.h,
signal.h, setjmp.h. Include systime.h instead.
(saturated_add): New function.
(record_backtrace, current_sample_interval): Use EMACS_INT, not size_t.
(record_backtrace, handle_profiler_signal): Saturate on fixnum overflow.
(profiler_timer, profiler_timer_ok) [HAVE_TIMER_SETTIME]:
New static vars.
(enum profiler_cpu_running): New enumn.
(profiler_cpu_running): Now of that enum type, not bool.
All uses changed to store the new value.
(handle_profiler_signal): Rename from sigprof_handler_1,
for consistency with other handlers. Do not check whether
cpu_log is a hash-table if garbage collecting, since it
doesn't matter in that case.
(deliver_profiler_signal): Rename from sigprof_handler,
for consistency with other handlers.
(setup_cpu_timer): New function, with much of what used to be in
Fprofiler_cpu_start. Check for out-of-range argument.
Prefer timer_settime if available, and prefer
thread cputime clocks, then process cputime clocks, then
monotonic clocks, to the old realtime clock. Use make_timeval
to round more-correctly when falling back to setitimer.
(Fprofiler_cpu_start): Use it.
(Fprofiler_cpu_stop): Prefer timer_settime if available.
Don't assume that passing NULL as the 2nd argument of setitimer
is the same as passing a pointer to all-zero storage.
Ignore SIGPROF afterwards.
(malloc_probe): Saturate at MOST_POSITIVE_FIXNUM.
* sysdep.c (emacs_sigaction_init): Also mask out SIGPROF in
non-fatal signal handlers. Ignore SIGPROF on startup.
* syssignal.h (PROFILER_CPU_SUPPORT): Define this macro here, not
in profiler.c, since sysdep.c now uses it.
Diffstat (limited to 'src/syssignal.h')
-rw-r--r-- | src/syssignal.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/syssignal.h b/src/syssignal.h index 5c0edaa591d..0bc856769ba 100644 --- a/src/syssignal.h +++ b/src/syssignal.h @@ -29,6 +29,10 @@ extern void init_signals (bool); #define FORWARD_SIGNAL_TO_MAIN_THREAD #endif +#if defined SIGPROF && (defined HAVE_TIMER_SETTIME || defined HAVE_SETITIMER) +# define PROFILER_CPU_SUPPORT +#endif + extern sigset_t empty_mask; typedef void (*signal_handler_t) (int); |