Merge pull request #733 from amoiseev-softheme/bugfix/monofix
[mono.git] / mono / utils / mono-counters.h
1 #ifndef __MONO_COUNTERS_H__
2 #define __MONO_COUNTERS_H__
3
4 #include <stdio.h>
5 #include <mono/utils/mono-publib.h>
6
7 enum {
8         MONO_COUNTER_INT,    /* 32 bit int */
9         MONO_COUNTER_UINT,    /* 32 bit uint */
10         MONO_COUNTER_WORD,   /* pointer-sized int */
11         MONO_COUNTER_LONG,   /* 64 bit int */
12         MONO_COUNTER_ULONG,   /* 64 bit uint */
13         MONO_COUNTER_DOUBLE,
14         MONO_COUNTER_STRING, /* char* */
15         MONO_COUNTER_TIME_INTERVAL, /* 64 bits signed int holding usecs. */
16         MONO_COUNTER_TYPE_MASK = 0xf,
17         MONO_COUNTER_CALLBACK = 128, /* ORed with the other values */
18         MONO_COUNTER_SECTION_MASK = 0xffffff00,
19         /* sections */
20         MONO_COUNTER_JIT      = 1 << 8,
21         MONO_COUNTER_GC       = 1 << 9,
22         MONO_COUNTER_METADATA = 1 << 10,
23         MONO_COUNTER_GENERICS = 1 << 11,
24         MONO_COUNTER_SECURITY = 1 << 12,
25         MONO_COUNTER_LAST_SECTION
26 };
27
28 MONO_API void mono_counters_enable (int section_mask);
29
30 /* 
31  * register addr as the address of a counter of type type.
32  * It may be a function pointer if MONO_COUNTER_CALLBACK is specified:
33  * the function should return the value and take no arguments.
34  */
35 MONO_API void mono_counters_register (const char* descr, int type, void *addr);
36
37 /* 
38  * Create a readable dump of the counters for section_mask sections (ORed section values)
39  */
40 MONO_API void mono_counters_dump (int section_mask, FILE *outfile);
41
42 MONO_API void mono_counters_cleanup (void);
43
44 typedef enum {
45         MONO_RESOURCE_JIT_CODE, /* bytes */
46         MONO_RESOURCE_METADATA, /* bytes */
47         MONO_RESOURCE_GC_HEAP,  /* bytes */
48         MONO_RESOURCE_COUNT /* non-ABI value */
49 } MonoResourceType;
50
51 typedef void (*MonoResourceCallback) (int resource_type, uintptr_t value, int is_soft);
52
53 MONO_API int  mono_runtime_resource_limit        (int resource_type, uintptr_t soft_limit, uintptr_t hard_limit);
54 MONO_API void mono_runtime_resource_set_callback (MonoResourceCallback callback);
55 MONO_API void mono_runtime_resource_check_limit  (int resource_type, uintptr_t value);
56
57 #endif /* __MONO_COUNTERS_H__ */
58