Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Annotation of /sml/trunk/src/runtime/c-libs/smlnj-prof/setpref.c
ViewVC logotype

Annotation of /sml/trunk/src/runtime/c-libs/smlnj-prof/setpref.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 249 - (view) (download) (as text)
Original Path: sml/branches/SMLNJ/src/runtime/c-libs/smlnj-prof/setpref.c

1 : monnier 249 /* setpref.c
2 :     *
3 :     * COPYRIGHT (c) 1996 AT&T Research.
4 :     */
5 :    
6 :     #include "ml-base.h"
7 :     #include "ml-c.h"
8 :     #include "ml-values.h"
9 :     #include "ml-objects.h"
10 :     #include "ml-globals.h"
11 :     #include "cfun-proto-list.h"
12 :     #include "profile.h"
13 :    
14 :     /* _ml_Prof_setpref : word array option -> unit
15 :     *
16 :     * Set the profile array reference; NONE means that there is no array.
17 :     */
18 :     ml_val_t _ml_Prof_setpref (ml_state_t *msp, ml_val_t arg)
19 :     {
20 :     #ifdef OPSYS_UNIX
21 :     bool_t enabled = (ProfCntArray != ML_unit);
22 :     int i;
23 :    
24 :     if (arg != OPTION_NONE) {
25 :     ProfCntArray = OPTION_get(arg);
26 :     if (! enabled) {
27 :     /* add ProfCntArray to the C roots */
28 :     CRoots[NumCRoots++] = &ProfCntArray;
29 :     /* enable profiling signals */
30 :     EnableProfSignals ();
31 :     }
32 :     }
33 :     else if (enabled) {
34 :     /* remove ProfCntArray from the C roots */
35 :     for (i = 0; i < NumCRoots; i++) {
36 :     if (CRoots[i] == &ProfCntArray) {
37 :     CRoots[i] = CRoots[--NumCRoots];
38 :     break;
39 :     }
40 :     }
41 :     /* disable profiling signals */
42 :     DisableProfSignals ();
43 :     ProfCntArray = ML_unit;
44 :     }
45 :    
46 :     return ML_unit;
47 :     #else
48 :     return RAISE_ERROR(msp, "time profiling not supported");
49 :     #endif
50 :    
51 :     } /* end of _ml_Prof_setpref */
52 :    

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0