]> code.delx.au - gnu-emacs/blobdiff - src/profiler.c
Fix C99 incompatibilities in Cairo code
[gnu-emacs] / src / profiler.c
index 919aabc92af16d710b2ab853975a99d3ec45737a..d4c98a8265753c628b1cb95d0e28d6717c1a2fd5 100644 (file)
@@ -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;
 }