Clean up turn_back_am(), panic on unknown arity.
[libfirm] / include / libfirm / timing.h
1 /*
2  * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
3  *
4  * This file is part of libFirm.
5  *
6  * This file may be distributed and/or modified under the terms of the
7  * GNU General Public License version 2 as published by the Free Software
8  * Foundation and appearing in the file LICENSE.GPL included in the
9  * packaging of this file.
10  *
11  * Licensees holding valid libFirm Professional Edition licenses may use
12  * this file in accordance with the libFirm Commercial License.
13  * Agreement provided with the Software.
14  *
15  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17  * PURPOSE.
18  */
19
20 /**
21  * @file
22  * @brief    platform neutral timing utilities
23  * @version  $Id: tv.h 17143 2008-01-02 20:56:33Z beck $
24  */
25 #ifndef FIRM_TIMING_H
26 #define FIRM_TIMING_H
27
28 #include <stdlib.h>
29
30 typedef struct _ir_timer_t ir_timer_t;
31
32 /**
33  * Switch to real-time scheduling.
34  * This shall make measurements more precise.
35  * @note Does not work for all operating systems.
36  * @note You could need special user privileges.
37  * @return 0 on success, else UNIX error code.
38  */
39 int ir_timer_enter_high_priority(void);
40
41 /**
42  * Leave the high priority mode.
43  * @see ir_timer_enter_high_priority()
44  * @return 0 on success, else UNIX error code.
45  */
46 int ir_timer_leave_high_priority(void);
47
48 /**
49  * Get the amount of bytes allocated on the heap.
50  * @return The number of bytes allocated on the heap.
51  */
52 size_t ir_get_heap_used_bytes(void);
53
54 /**
55  * Register a new timer.
56  * If the timer was registered before, the registered timer is returned.
57  * @param name  The name of the timer.
58  * @param desc  The description of the timer.
59  * @return The timer.
60  */
61 ir_timer_t *ir_timer_register(const char *name, const char *desc);
62
63 /**
64  * Start a timer.
65  * @param timer The timer.
66  */
67 void ir_timer_start(ir_timer_t *timer);
68
69 /**
70  * Reset a timer and start it.
71  * @param timer The timer.
72  */
73 void ir_timer_reset_and_start(ir_timer_t *timer);
74
75 /**
76  * Reset a timer.
77  * @param timer The timer.
78  */
79 void ir_timer_reset(ir_timer_t *timer);
80
81 /**
82  * Stop a timer.
83  * Stopping a stopped timer has no effect.
84  * @param timer The timer.
85  */
86 void ir_timer_stop(ir_timer_t *timer);
87
88 /**
89  * Push a timer of the timer stack. This automatically
90  * stop the previous timer on tos and start the new one.
91  *
92  * @param timer   The timer to push on stack.
93  * @return non-zero on succes, zero if the timer is already on the stack.
94  */
95 int ir_timer_push(ir_timer_t *timer);
96
97 /**
98  * Pop the current timer. This automatically stops it and
99  * start the timer that is now on the stack.
100  * @return the popped timer
101  */
102 ir_timer_t *ir_timer_pop(void);
103
104 /**
105  * Get the number of milliseconds, the timer has elapsed.
106  * @param timer The timer.
107  * @return The number of milliseconds the timer is (was) running.
108  */
109 unsigned long ir_timer_elapsed_msec(const ir_timer_t *timer);
110
111 /**
112  * Get the number of microseconds, the timer has elapsed.
113  * @param timer The timer.
114  * @return The number of milliseconds the timer is (was) running.
115  */
116 unsigned long ir_timer_elapsed_usec(const ir_timer_t *timer);
117
118 /**
119  * Get name of given timer.
120  * @param timer The timer.
121  * @return The name of the timer.
122  */
123 const char *ir_timer_get_name(const ir_timer_t *timer);
124
125 /**
126  * Get description of given timer.
127  * @param timer The timer.
128  * @return The description of the timer.
129  */
130 const char *ir_timer_get_description(const ir_timer_t *timer);
131
132 #endif