Mercurial > hg > xemacs-beta
annotate src/profile.h @ 5602:c9e5612f5424
Support the MP library on recent FreeBSD, have it pass relevant tests.
src/ChangeLog addition:
2011-11-26 Aidan Kehoe <kehoea@parhasard.net>
* number-mp.c (bignum_to_string):
Don't overwrite the accumulator we've just set up for this
function.
* number-mp.c (BIGNUM_TO_TYPE):
mp_itom() doesn't necessarily do what this code used to think with
negative numbers, it can treat them as unsigned ints. Subtract
numbers from bignum_zero instead of multiplying them by -1 to
convert them to their negative equivalents.
* number-mp.c (bignum_to_int):
* number-mp.c (bignum_to_uint):
* number-mp.c (bignum_to_long):
* number-mp.c (bignum_to_ulong):
* number-mp.c (bignum_to_double):
Use the changed BIGNUM_TO_TYPE() in these functions.
* number-mp.c (bignum_ceil):
* number-mp.c (bignum_floor):
In these functions, be more careful about rounding to positive and
negative infinity, respectively. Don't use the sign of QUOTIENT
when working out out whether to add or subtract one, rather use
the sign QUOTIENT would have if arbitrary-precision division were
done.
* number-mp.h:
* number-mp.h (MP_GCD):
Wrap #include <mp.h> in BEGIN_C_DECLS/END_C_DECLS.
* number.c (Fbigfloat_get_precision):
* number.c (Fbigfloat_set_precision):
Don't attempt to call XBIGFLOAT_GET_PREC if this build doesn't
support big floats.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Sat, 26 Nov 2011 17:59:14 +0000 |
parents | 308d34e9f07d |
children |
rev | line source |
---|---|
1292 | 1 /* Profiling. |
3025 | 2 Copyright (C) 2003, 2005 Ben Wing. |
1292 | 3 |
4 This file is part of XEmacs. | |
5 | |
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
4162
diff
changeset
|
6 XEmacs is free software: you can redistribute it and/or modify it |
1292 | 7 under the terms of the GNU General Public License as published by the |
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
4162
diff
changeset
|
8 Free Software Foundation, either version 3 of the License, or (at your |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
4162
diff
changeset
|
9 option) any later version. |
1292 | 10 |
11 XEmacs is distributed in the hope that it will be useful, but WITHOUT | |
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
14 for more details. | |
15 | |
16 You should have received a copy of the GNU General Public License | |
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
4162
diff
changeset
|
17 along with XEmacs. If not, see <http://www.gnu.org/licenses/>. */ |
1292 | 18 |
19 /* Synched up with: Not in FSF. */ | |
20 | |
21 /* Authorship: | |
22 | |
23 Ben Wing: Feb 2003. | |
24 */ | |
25 | |
26 #include "backtrace.h" | |
27 | |
28 void mark_profiling_info (void); | |
29 void profile_record_unwind (struct backtrace *); | |
30 void profile_record_about_to_call (struct backtrace *); | |
31 void profile_record_just_called (struct backtrace *); | |
32 void profile_record_consing (EMACS_INT size); | |
33 void profile_record_unconsing (EMACS_INT size); | |
34 extern int profiling_active; | |
35 | |
36 /* We call about_to_call() and just_called() depending on the current | |
37 *dynamic* value of profiling_active (which could change as a result of | |
38 calling the function) but if we push a backtrace, we must pop it later, | |
39 so we need to remember the status of this. */ | |
40 #define PROFILE_DECLARE() \ | |
41 int do_backtrace = profiling_active || backtrace_with_internal_sections; \ | |
42 struct backtrace backtrace | |
43 | |
44 /* As just mentioned, we rely on the dynamic value of profiling_active. | |
45 This ensures correct behavior (e.g. we never modify the profiling info | |
46 when profiling is not active) because we seed and reap all functions | |
47 currently on the stack when starting and stopping. See | |
4162 | 48 `start-profiling'. |
49 | |
50 We check do_backtrace to make sure that the backtrace structure is | |
51 initialised. If it isn't, we can enter a function with profiling turned | |
52 off, and exit it with it turned on, with the consequence that an | |
53 unitialised backtrace structure is passed to | |
54 profile_record_just_called. Since do_backtrace is function-local (apart | |
55 from in the garbage collector) this avoids that. */ | |
1292 | 56 #define PROFILE_ENTER_FUNCTION() \ |
57 do \ | |
58 { \ | |
4162 | 59 if (profiling_active && do_backtrace) \ |
1292 | 60 profile_record_about_to_call (&backtrace); \ |
61 } \ | |
62 while (0) | |
63 | |
64 #define PROFILE_EXIT_FUNCTION() \ | |
65 do \ | |
66 { \ | |
4162 | 67 if (profiling_active && do_backtrace) \ |
1292 | 68 profile_record_just_called (&backtrace); \ |
69 } \ | |
70 while (0) | |
71 | |
72 /* We are entering a section that we would like to record profile information | |
73 about. We put this information into the backtrace list, just like | |
74 normal functions do. That is one easy way to make sure that we always | |
75 record info on the innermost section or function, whether section or | |
76 function. (To do this, we always need some sort of collusion between | |
77 profile and eval; this is one way.) */ | |
78 | |
3025 | 79 /* Or, we could call xzero() to zero the whole thing, and avoid four |
80 of the statements below; or we could create a global backtrace object, | |
81 uninitialized (i.e. it will be initialized to all 0), and do structure | |
82 copy to initialize. It's not clear it will make much difference here, | |
83 but someone who really cared about counting cycles could implement it. */ | |
1292 | 84 #define PROFILE_RECORD_ENTERING_SECTION(var) \ |
85 do \ | |
86 { \ | |
87 if (do_backtrace) \ | |
88 { \ | |
89 backtrace.function = &var; \ | |
90 backtrace.args = NULL; \ | |
91 backtrace.nargs = UNEVALLED; \ | |
92 backtrace.evalargs = 0; \ | |
93 backtrace.pdlcount = specpdl_depth (); \ | |
94 backtrace.debug_on_exit = 0; \ | |
95 backtrace.function_being_called = 0; \ | |
96 PUSH_BACKTRACE (backtrace); \ | |
97 } \ | |
98 PROFILE_ENTER_FUNCTION (); \ | |
99 } while (0) | |
100 | |
101 #define PROFILE_RECORD_EXITING_SECTION(var) \ | |
102 do \ | |
103 { \ | |
104 PROFILE_EXIT_FUNCTION (); \ | |
105 if (do_backtrace) \ | |
106 POP_BACKTRACE (backtrace); \ | |
107 } while (0) | |
2514 | 108 |
109 #define RETURN_EXIT_PROFILING(tag, type, expr) \ | |
110 do \ | |
111 { \ | |
112 type _ret_exitpr_ = (expr); \ | |
113 PROFILE_RECORD_EXITING_SECTION (tag); \ | |
114 RETURN_SANS_WARNINGS _ret_exitpr_; \ | |
115 } while (0) | |
116 | |
117 #define RETURN_LISP_EXIT_PROFILING(tag, expr) \ | |
118 RETURN_EXIT_PROFILING (tag, Lisp_Object, expr) | |
119 | |
120 #define RETURN_UNGCPRO_EXIT_PROFILING(tag, expr) \ | |
3282 | 121 do \ |
2514 | 122 { \ |
123 Lisp_Object ret_ungc_val = (expr); \ | |
124 UNGCPRO; \ | |
125 PROFILE_RECORD_EXITING_SECTION (tag); \ | |
126 RETURN_SANS_WARNINGS ret_ungc_val; \ | |
127 } while (0) | |
128 | |
129 #ifdef DEBUG_XEMACS | |
130 extern Lisp_Object QSin_temp_spot_1; | |
131 extern Lisp_Object QSin_temp_spot_2; | |
132 extern Lisp_Object QSin_temp_spot_3; | |
133 extern Lisp_Object QSin_temp_spot_4; | |
134 extern Lisp_Object QSin_temp_spot_5; | |
135 #endif /* DEBUG_XEMACS */ |