+(defvar elp-not-profilable
+ ;; First, the functions used inside each instrumented function:
+ '(elp-wrapper called-interactively-p
+ ;; Then the functions used by the above functions. I used
+ ;; (delq nil (mapcar (lambda (x) (and (symbolp x) (fboundp x) x))
+ ;; (aref (symbol-function 'elp-wrapper) 2)))
+ ;; to help me find this list.
+ error call-interactively apply current-time)
+ "List of functions that cannot be profiled.
+Those functions are used internally by the profiling code and profiling
+them would thus lead to infinite recursion.")
+
+(defun elp-profilable-p (fun)
+ (and (symbolp fun)
+ (fboundp fun)
+ (not (or (memq fun elp-not-profilable)
+ (keymapp fun)
+ (memq (car-safe (symbol-function fun)) '(autoload macro))
+ (condition-case nil
+ (when (subrp (indirect-function fun))
+ (eq 'unevalled
+ (cdr (subr-arity (indirect-function fun)))))
+ (error nil))))))
+