X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/0d7b2c96d388f5a9b539df3cb7f4ef115e7010b7..67dbc32afd8af2eaca9fdba9f17680cdcecb178f:/src/profiler.c diff --git a/src/profiler.c b/src/profiler.c index 919aabc92a..d4c98a8265 100644 --- a/src/profiler.c +++ b/src/profiler.c @@ -1,6 +1,6 @@ /* Profiler implementation. -Copyright (C) 2012-2014 Free Software Foundation, Inc. +Copyright (C) 2012-2015 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -35,7 +35,6 @@ saturated_add (EMACS_INT a, EMACS_INT b) typedef struct Lisp_Hash_Table log_t; -static Lisp_Object Qprofiler_backtrace_equal; static struct hash_table_test hashtest_profiler; static Lisp_Object @@ -218,6 +217,12 @@ static EMACS_INT current_sampling_interval; /* Signal handler for sampling profiler. */ +/* timer_getoverrun is not implemented on Cygwin, but the following + seems to be good enough for profiling. */ +#ifdef CYGWIN +#define timer_getoverrun(x) 0 +#endif + static void handle_profiler_signal (int signal) { @@ -251,7 +256,7 @@ deliver_profiler_signal (int signal) deliver_process_signal (signal, handle_profiler_signal); } -static enum profiler_cpu_running +static int setup_cpu_timer (Lisp_Object sampling_interval) { struct sigaction action; @@ -264,7 +269,7 @@ setup_cpu_timer (Lisp_Object sampling_interval) ? ((EMACS_INT) TYPE_MAXIMUM (time_t) * billion + (billion - 1)) : EMACS_INT_MAX))) - return NOT_RUNNING; + return -1; current_sampling_interval = XINT (sampling_interval); interval = make_timespec (current_sampling_interval / billion, @@ -337,9 +342,18 @@ See also `profiler-log-size' and `profiler-max-stack-depth'. */) profiler_max_stack_depth); } - profiler_cpu_running = setup_cpu_timer (sampling_interval); - if (! profiler_cpu_running) - error ("Invalid sampling interval"); + int status = setup_cpu_timer (sampling_interval); + if (status == -1) + { + profiler_cpu_running = NOT_RUNNING; + error ("Invalid sampling interval"); + } + else + { + profiler_cpu_running = status; + if (! profiler_cpu_running) + error ("Unable to start profiler timer"); + } return Qt; }