comparison src/profile.c @ 185:3d6bfa290dbd r20-3b19

Import from CVS: tag r20-3b19
author cvs
date Mon, 13 Aug 2007 09:55:28 +0200
parents 538048ae2ab8
children 169c0442b401
comparison
equal deleted inserted replaced
184:bcd2674570bf 185:3d6bfa290dbd
102 102
103 { 103 {
104 /* #### see comment about memory allocation in start-profiling. 104 /* #### see comment about memory allocation in start-profiling.
105 Allocating memory in a signal handler is BAD BAD BAD. 105 Allocating memory in a signal handler is BAD BAD BAD.
106 If you are using the non-mmap rel-alloc code, you might 106 If you are using the non-mmap rel-alloc code, you might
107 lose because of this. Even worse, if the memory allocation 107 lose because of this. Even worse, if the memory allocation
108 fails, the `error' generated whacks everything hard. */ 108 fails, the `error' generated whacks everything hard. */
109 long count; 109 long count;
110 CONST void *vval; 110 CONST void *vval;
111 111
112 if (gethash (LISP_TO_VOID (fun), big_profile_table, &vval)) 112 if (gethash (LISP_TO_VOID (fun), big_profile_table, &vval))
113 count = (long) vval; 113 count = (long) vval;
114 else 114 else
115 count = 0; 115 count = 0;
116 count++; 116 count++;
117 vval = (CONST void *) count; 117 vval = (CONST void *) count;
118 puthash (LISP_TO_VOID (fun), (void *) vval, big_profile_table); 118 puthash (LISP_TO_VOID (fun), (void *) vval, big_profile_table);
119 } 119 }
120 120
121 inside_profiling = 0; 121 inside_profiling = 0;
122 } 122 }
123 } 123 }
124 124
125 DEFUN ("start-profiling", Fstart_profiling, 0, 1, 0, /* 125 DEFUN ("start-profiling", Fstart_profiling, 0, 1, 0, /*
185 } 185 }
186 186
187 static Lisp_Object 187 static Lisp_Object
188 profile_lock_unwind (Lisp_Object ignore) 188 profile_lock_unwind (Lisp_Object ignore)
189 { 189 {
190 inside_profiling = 0; 190 inside_profiling = 0;
191 return Qnil; 191 return Qnil;
192 } 192 }
193 193
194 struct get_profiling_info_closure 194 struct get_profiling_info_closure
195 { 195 {
201 void *void_val, 201 void *void_val,
202 void *void_closure) 202 void *void_closure)
203 { 203 {
204 /* This function does not GC */ 204 /* This function does not GC */
205 Lisp_Object key; 205 Lisp_Object key;
206 struct get_profiling_info_closure *closure = void_closure; 206 struct get_profiling_info_closure *closure
207 = (struct get_profiling_info_closure *) void_closure;
207 EMACS_INT val; 208 EMACS_INT val;
208 209
209 CVOID_TO_LISP (key, void_key); 210 CVOID_TO_LISP (key, void_key);
210 val = (EMACS_INT) void_val; 211 val = (EMACS_INT) void_val;
211 212
212 closure->accum = Fcons (Fcons (key, make_int (val)), 213 closure->accum = Fcons (Fcons (key, make_int (val)), closure->accum);
213 closure->accum);
214 } 214 }
215 215
216 DEFUN ("get-profiling-info", Fget_profiling_info, 0, 0, 0, /* 216 DEFUN ("get-profiling-info", Fget_profiling_info, 0, 0, 0, /*
217 Return the profiling info as an alist. 217 Return the profiling info as an alist.
218 */ 218 */
242 mark_profiling_info_maphash (CONST void *void_key, 242 mark_profiling_info_maphash (CONST void *void_key,
243 void *void_val, 243 void *void_val,
244 void *void_closure) 244 void *void_closure)
245 { 245 {
246 Lisp_Object key; 246 Lisp_Object key;
247 struct mark_profiling_info_closure *closure = void_closure;
248 247
249 CVOID_TO_LISP (key, void_key); 248 CVOID_TO_LISP (key, void_key);
250 (closure->markfun) (key); 249 (((struct mark_profiling_info_closure *) void_closure)->markfun) (key);
251 } 250 }
252 251
253 void 252 void
254 mark_profiling_info (void (*markfun) (Lisp_Object)) 253 mark_profiling_info (void (*markfun) (Lisp_Object))
255 { 254 {