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/setptimer.c
ViewVC logotype

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

Parent Directory Parent Directory | Revision Log Revision Log


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

1 : monnier 2 /* setptimer.c
2 :     *
3 :     * COPYRIGHT (c) 1995 AT&T Bell Laboratories.
4 :     *
5 :     * NOTE: this implementation is UNIX specific right now; I would like to
6 :     * define an OS abstraction layer for interval timers, which would cover
7 :     * both alarm timers and profiling, but I need to look at what other systems
8 :     * do first.
9 :     */
10 :    
11 :     #ifdef OPSYS_UNIX
12 :     # include "ml-unixdep.h"
13 :     # include <sys/time.h>
14 :     #endif
15 :     #include "ml-base.h"
16 :     #include "ml-c.h"
17 :     #include "ml-values.h"
18 :     #include "ml-objects.h"
19 :     #include "cfun-proto-list.h"
20 :     #include "profile.h"
21 :    
22 :     /* _ml_Prof_setptimer : bool -> unit
23 :     *
24 :     * Turn the profile timer on/off.
25 :     */
26 :     ml_val_t _ml_Prof_setptimer (ml_state_t *msp, ml_val_t arg)
27 :     {
28 :     #ifdef HAS_SETITIMER
29 :     struct itimerval new_itv;
30 :     int sts;
31 :    
32 :     if (ProfCntArray == ML_unit) {
33 :     return RAISE_ERROR(msp, "no count array set");
34 :     }
35 :    
36 :     if (arg == ML_false) {
37 :     new_itv.it_interval.tv_sec =
38 :     new_itv.it_value.tv_sec =
39 :     new_itv.it_interval.tv_usec =
40 :     new_itv.it_value.tv_usec = 0;
41 :     }
42 :     else {
43 :     new_itv.it_interval.tv_sec =
44 :     new_itv.it_value.tv_sec = 0;
45 :     new_itv.it_interval.tv_usec =
46 :     new_itv.it_value.tv_usec = PROFILE_QUANTUM_US;
47 :     }
48 :    
49 :     sts = setitimer (ITIMER_VIRTUAL, &new_itv, NIL(struct itimerval *));
50 :    
51 :     CHK_RETURN_UNIT(msp, sts);
52 :    
53 :     #else
54 :     return RAISE_ERROR(msp, "time profiling not supported");
55 :     #endif
56 :    
57 :     } /* end of _ml_Prof_setptimer */
58 :    

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