Fix win32 build.
[mono.git] / mono / utils / mono-counters.h
index f4b2ac1dbc7d226ab2e63eebddac7d80e2f8d21b..20676c2ff114015e8d79a9cb748008816dfea6ba 100644 (file)
@@ -13,10 +13,11 @@ enum {
        MONO_COUNTER_ULONG,   /* 64 bit uint */
        MONO_COUNTER_DOUBLE,
        MONO_COUNTER_STRING, /* char* */
+       MONO_COUNTER_TIME_INTERVAL, /* 64 bits signed int holding usecs. */
        MONO_COUNTER_TYPE_MASK = 0xf,
        MONO_COUNTER_CALLBACK = 128, /* ORed with the other values */
-       MONO_COUNTER_SECTION_MASK = 0xffffff00,
-       /* Sections, bits 8-15  */
+       MONO_COUNTER_SECTION_MASK = 0x00ffff00,
+       /* Sections, bits 8-23 (16 bits) */
        MONO_COUNTER_JIT      = 1 << 8,
        MONO_COUNTER_GC       = 1 << 9,
        MONO_COUNTER_METADATA = 1 << 10,
@@ -26,24 +27,26 @@ enum {
        MONO_COUNTER_SYSTEM   = 1 << 14,
        MONO_COUNTER_LAST_SECTION,
 
-       /* Unit, bits 16-23 */
-       MONO_COUNTER_UNIT_SHIFT = 16,
-       MONO_COUNTER_UNIT_MASK = 0xFFu << MONO_COUNTER_UNIT_SHIFT,
-       MONO_COUNTER_RAW        = 0 << 16,  /* Raw value */
-       MONO_COUNTER_BYTES      = 1 << 16, /* Quantity of bytes. RSS, active heap, etc */
-       MONO_COUNTER_TIME       = 2 << 16,  /* Time interval in 100ns units. Minor pause, JIT compilation*/
-       MONO_COUNTER_EVENTS     = 3 << 16, /* Number of times the given event happens. Major collections, Compiled methods. */
-       MONO_COUNTER_ITEMS      = 4 << 16, /* Current number of things. Threads, queued jobs.*/
-       MONO_COUNTER_PERCENTAGE = 5 << 16, /* [0-1] Fraction Percentage of something. Load average. */
-
-       /* Monotonicity, bits 24-31 */
-       MONO_COUNTER_VARIANCE_SHIFT = 24,
-       MONO_COUNTER_VARIANCE_MASK = 0xFFu << MONO_COUNTER_VARIANCE_SHIFT,
-       MONO_COUNTER_MONOTONIC      = 0 << 24, /* This counter value always increase/decreases over time. Reported by --stat. */
-       MONO_COUNTER_CONSTANT       = 1 << 24, /* Fixed value. Used by configuration data. */
-       MONO_COUNTER_VARIABLE       = 2 << 24, /* This counter value can be anything on each sampling. Only interesting when sampling. */
+       /* Unit, bits 24-27 (4 bits) */
+       MONO_COUNTER_UNIT_SHIFT = 24,
+       MONO_COUNTER_UNIT_MASK = 0xFu << MONO_COUNTER_UNIT_SHIFT,
+       MONO_COUNTER_RAW        = 0 << 24,  /* Raw value */
+       MONO_COUNTER_BYTES      = 1 << 24, /* Quantity of bytes. RSS, active heap, etc */
+       MONO_COUNTER_TIME       = 2 << 24,  /* Time interval in 100ns units. Minor pause, JIT compilation*/
+       MONO_COUNTER_COUNT      = 3 << 24, /*  Number of things (threads, queued jobs) or Number of events triggered (Major collections, Compiled methods).*/
+       MONO_COUNTER_PERCENTAGE = 4 << 24, /* [0-1] Fraction Percentage of something. Load average. */
+
+       /* Monotonicity, bits 28-31 (4 bits) */
+       MONO_COUNTER_VARIANCE_SHIFT = 28,
+       MONO_COUNTER_VARIANCE_MASK = 0xFu << MONO_COUNTER_VARIANCE_SHIFT,
+       MONO_COUNTER_MONOTONIC      = 1 << 28, /* This counter value always increase/decreases over time. Reported by --stat. */
+       MONO_COUNTER_CONSTANT       = 1 << 29, /* Fixed value. Used by configuration data. */
+       MONO_COUNTER_VARIABLE       = 1 << 30, /* This counter value can be anything on each sampling. Only interesting when sampling. */
 };
 
+typedef struct _MonoCounter MonoCounter;
+
+
 MONO_API void mono_counters_enable (int section_mask);
 
 /* 
@@ -52,6 +55,7 @@ MONO_API void mono_counters_enable (int section_mask);
  * the function should return the value and take no arguments.
  */
 MONO_API void mono_counters_register (const char* descr, int type, void *addr);
+MONO_API void mono_counters_register_with_size (const char *name, int type, void *addr, int size);
 
 /* 
  * Create a readable dump of the counters for section_mask sections (ORed section values)
@@ -60,6 +64,19 @@ MONO_API void mono_counters_dump (int section_mask, FILE *outfile);
 
 MONO_API void mono_counters_cleanup (void);
 
+typedef mono_bool (*CountersEnumCallback) (MonoCounter *counter, void *user_data);
+
+MONO_API void mono_counters_foreach (CountersEnumCallback cb, void *user_data);
+
+MONO_API int mono_counters_sample (MonoCounter *counter, void *buffer, int buffer_size);
+
+MONO_API const char* mono_counter_get_name (MonoCounter *name);
+MONO_API int mono_counter_get_type (MonoCounter *counter);
+MONO_API int mono_counter_get_section (MonoCounter *counter);
+MONO_API int mono_counter_get_unit (MonoCounter *counter);
+MONO_API int mono_counter_get_variance (MonoCounter *counter);
+MONO_API size_t mono_counter_get_size (MonoCounter *counter);
+
 typedef enum {
        MONO_RESOURCE_JIT_CODE, /* bytes */
        MONO_RESOURCE_METADATA, /* bytes */