mono-api-utils.html
Utility Methods
Bitsets
MonoBitsets are a set of routines used to manipulate sets
of bits.
mono_bitset_alloc_size
Prototype: mono_bitset_alloc_size
mono_bitset_clear
Prototype: mono_bitset_clear
mono_bitset_clear_all
Prototype: mono_bitset_clear_all
mono_bitset_clone
Prototype: mono_bitset_clone
mono_bitset_copyto
Prototype: mono_bitset_copyto
mono_bitset_count
Prototype: mono_bitset_count
mono_bitset_equal
Prototype: mono_bitset_equal
mono_bitset_find_first
Prototype: mono_bitset_find_first
mono_bitset_find_last
Prototype: mono_bitset_find_last
mono_bitset_find_start
Prototype: mono_bitset_find_start
mono_bitset_foreach
Prototype: mono_bitset_foreach
mono_bitset_free
Prototype: mono_bitset_free
mono_bitset_intersection
Prototype: mono_bitset_intersection
mono_bitset_invert
Prototype: mono_bitset_invert
mono_bitset_mem_new
Prototype: mono_bitset_mem_new
mono_bitset_new
Prototype: mono_bitset_new
mono_bitset_set
Prototype: mono_bitset_set
mono_bitset_set_all
Prototype: mono_bitset_set_all
mono_bitset_size
Prototype: mono_bitset_size
mono_bitset_sub
Prototype: mono_bitset_sub
mono_bitset_test
Prototype: mono_bitset_test
mono_bitset_test_bulk
Prototype: mono_bitset_test_bulk
mono_bitset_union
Prototype: mono_bitset_union
mono_bitset_find_first_unset
Prototype: mono_bitset_find_first_unset
mono_bitset_intersection_2
Prototype: mono_bitset_intersection_2
Hashtables
GHashTable is used when you need to store object
references into a hashtable, objects stored in a
MonoGHashTable are properly tracked by the garbage
collector.
The MonoGHashTable data type has the same API as
the GLIB.
mono_g_hash_table_destroy
Prototype: mono_g_hash_table_destroy
mono_g_hash_table_foreach
Prototype: mono_g_hash_table_foreach
mono_g_hash_table_foreach_remove
Prototype: mono_g_hash_table_foreach_remove
mono_g_hash_table_foreach_steal
Prototype: mono_g_hash_table_foreach_steal
mono_g_hash_table_insert
Prototype: mono_g_hash_table_insert
mono_g_hash_table_lookup
Prototype: mono_g_hash_table_lookup
mono_g_hash_table_lookup_extended
Prototype: mono_g_hash_table_lookup_extended
mono_g_hash_table_new
Prototype: mono_g_hash_table_new
mono_g_hash_table_new_full
Prototype: mono_g_hash_table_new_full
mono_g_hash_table_remap
void
mono_g_hash_table_remap (MonoGHashTable *hash_table,
MonoGRemapperFunc func,
gpointer user_data)
Remarks
Calls the given function for each key-value pair in the hash table,
and replaces the value stored in the hash table by the value returned by
the function.
mono_g_hash_table_remove
Prototype: mono_g_hash_table_remove
mono_g_hash_table_replace
Prototype: mono_g_hash_table_replace
mono_g_hash_table_size
Prototype: mono_g_hash_table_size
mono_g_hash_table_steal
Prototype: mono_g_hash_table_steal
Raw buffer
Raw buffers provide an abstraction to load segments of
files into memory. If the operating system supports it, the
files are not loaded, but are mapped into the address space of
the process (On Unix, this is done using the mmap(2)
system call).
mono_raw_buffer_load
Prototype: mono_raw_buffer_load
mono_raw_buffer_update
Prototype: mono_raw_buffer_update
mono_raw_buffer_free
Prototype: mono_raw_buffer_free
SHA1 Signatures
mono_sha1_init
Prototype: mono_sha1_init
mono_sha1_update
Prototype: mono_sha1_update
mono_sha1_get_digest_from_file
Prototype: mono_sha1_get_digest_from_file
mono_sha1_get_digest
Prototype: mono_sha1_get_digest
mono_sha1_final
Prototype: mono_sha1_final
MD5 Signatures
mono_md5_init
Prototype: mono_md5_init
mono_md5_update
Prototype: mono_md5_update
mono_md5_get_digest_from_file
Prototype: mono_md5_get_digest_from_file
mono_md5_get_digest
Prototype: mono_md5_get_digest
mono_md5_final
Prototype: mono_md5_final
mono_digest_get_public_token
Prototype: mono_digest_get_public_token
Memory Pools
Memory pools are a convenient way of tracking memory
allocations that are used for one specific task, they are also
faster than using the standard memory allocation procedures,
as they are designed to be used only by a single thread at a
time.
MonoMemPool objects are not thread safe, which
means that you should not share the objects across multiple
threads without providing proper locking around it (unlike
malloc and free which are thread safe).
When a MonoMemPool is released with
mono_mempool_destroy all of the of the memory
allocated from that memory pool with
mono_mempool_alloc and mono_mempool_alloc0
is released.
mono_mempool_new
MonoMemPool*
mono_mempool_new (void)
Returns
a new memory pool.
mono_mempool_destroy
void
mono_mempool_destroy (MonoMemPool *pool)
Parameters
pool: the memory pool to destroy
Remarks
Free all memory associated with this pool.
mono_mempool_alloc
gpointer
mono_mempool_alloc (MonoMemPool *pool, guint size)
Parameters
pool: the momory pool to usesize: size of the momory block
Returns
the address of a newly allocated memory block.
Remarks
Allocates a new block of memory in
pool.
mono_mempool_alloc0
gpointer
mono_mempool_alloc0 (MonoMemPool *pool, guint size)
Remarks
same as mono_mempool_alloc, but fills memory with zero.
mono_mempool_empty
Prototype: mono_mempool_empty
mono_mempool_invalidate
void
mono_mempool_invalidate (MonoMemPool *pool)
Parameters
pool: the memory pool to invalidate
Remarks
Fill the memory associated with this pool to 0x2a (42). Useful for debugging.
mono_mempool_stats
void
mono_mempool_stats (MonoMemPool *pool)
Parameters
pool: the momory pool we need stats for
Remarks
Print a few stats about the mempool
mono_mempool_contains_addr
gboolean
mono_mempool_contains_addr (MonoMemPool *pool,
gpointer addr)
Remarks
Determines whenever ADDR is inside the memory used by the mempool.
JIT utilities
mono_is_power_of_two
Prototype: mono_is_power_of_two
mono_signbit_double
Prototype: mono_signbit_double
mono_signbit_float
Prototype: mono_signbit_float
Disassembling Generated Code
Routines used to debug the JIT-produced code.
mono_disasm_code
Prototype: mono_disasm_code
mono_disasm_code_one
Prototype: mono_disasm_code_one
mono_disassemble_code
void
mono_disassemble_code (MonoCompile *cfg, guint8 *code, int size, char *id)
Parameters
cfg: compilation contextcode: a pointer to the codesize: the code size in bytes
Remarks
Disassemble to code to stdout.
Walking the Stack
mono_walk_stack
void
mono_walk_stack (MonoDomain *domain, MonoJitTlsData *jit_tls, MonoContext *start_ctx, MonoStackFrameWalk func, gpointer user_data)
Parameters
domain: starting appdomainjit_tls: JIT data for the threadstart_ctx: starting state of the stack framefunc: callback to call for each stack frameuser_data: data passed to the callback
Remarks
This function walks the stack of a thread, starting from the state
represented by jit_tls and start_ctx. For each frame the callback
function is called with the relevant info. The walk ends when no more
managed stack frames are found or when the callback returns a TRUE value.
Note that the function can be used to walk the stack of a thread
different from the current.
mono_stack_walk_no_il
Prototype: mono_stack_walk_no_il
Others
mono_escape_uri_string
Prototype: mono_escape_uri_string