Internal Runtime Utility Functions
SHA1 Signatures
    mono_sha1_init
    
        
        
            
            Syntax
            void
mono_sha1_init (MonoSHA1Context* context)
            
         
     
  
    mono_sha1_update
    
        
        
            
            Syntax
            void
mono_sha1_update (MonoSHA1Context* context, const guchar* data, guint32 len)
            
         
     
  
    mono_sha1_get_digest_from_file
    
        
        
            
            Syntax
            void
mono_sha1_get_digest_from_file (const gchar *filename, guchar digest [20])
	
            
            Parameters
            | filename | file name | 
| digest | 20-byte buffer receiving the hash code. | 
             Description
              	 	 Get the SHA-1 hash of a file. The result is put in  	 the 20-byte buffer 
digest. 	
 	 If an IO error happens the value in 
digest is not updated.
 
         
     
  
    mono_sha1_get_digest
    
        
        
            
            Syntax
            void
mono_sha1_get_digest (const guchar *buffer, gint buffer_size, guchar digest [20])
	
            
         
     
  
    mono_sha1_final
    
        
        
            
            Syntax
            void
mono_sha1_final (MonoSHA1Context* context, unsigned char digest[20])
            
         
     
MD5 Signatures
  
    mono_md5_init
    
        
        
            
            Syntax
            void
mono_md5_init (MonoMD5Context *ctx)
            
         
     
  
    mono_md5_update
    
        
        
            
            Syntax
            void
mono_md5_update (MonoMD5Context *ctx, const guchar *buf, guint32 len)
            
         
     
  
    mono_md5_get_digest_from_file
    
        
        
            
            Syntax
            void
mono_md5_get_digest_from_file (const gchar *filename, guchar digest[16])
	
            
            Parameters
            | filename | file name | 
| digest | 16-byte buffer receiving the hash code. | 
             Description
              	 	 Get the MD5 hash of a file. The result is put in  	 the 16-byte buffer 
digest. 	
 	 If an IO error happens the value in 
digest is not updated.
 
         
     
  
    mono_md5_get_digest
    
        
        
            
            Syntax
            void
mono_md5_get_digest (const guchar *buffer, gint buffer_size, guchar digest[16])
	
            
            Parameters
            | buffer | byte buffer | 
| buffer_size | buffer size (in bytes) | 
| digest | 16-byte buffer receiving the hash code. | 
             Description
              	 	 Get the MD5 hash of a buffer. The result is put in  	 the 16-byte buffer 
digest.
 
         
     
  
    mono_md5_final
    
        
        
            
            Syntax
            void
mono_md5_final (MonoMD5Context *ctx, guchar digest[16])
            
         
     
  
    mono_digest_get_public_token
    
        
        
            
            Syntax
            void 
mono_digest_get_public_token (guchar* token, const guchar *pubkey, guint32 len)
            
             Description
              	 	 Get the public token from public key data. 	 
token must point to at least 8 bytes of storage.
 
         
     
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
    
        
        
            
            Syntax
            void
mono_g_hash_table_destroy (MonoGHashTable *hash)
            
         
     
  
    mono_g_hash_table_foreach
    
        
        
            
            Syntax
            void
mono_g_hash_table_foreach (MonoGHashTable *hash, GHFunc func, gpointer user_data)
            
         
     
  
    mono_g_hash_table_foreach_remove
    
        
        
            
            Syntax
            guint
mono_g_hash_table_foreach_remove (MonoGHashTable *hash, GHRFunc func, gpointer user_data)
            
         
     
  
    mono_g_hash_table_insert
    
        
        
            
            Syntax
            void
mono_g_hash_table_insert (MonoGHashTable *h, gpointer k, gpointer v)
            
         
     
  
    mono_g_hash_table_lookup
    
        
        
            
            Syntax
            gpointer
mono_g_hash_table_lookup (MonoGHashTable *hash, gconstpointer key)
            
         
     
  
    mono_g_hash_table_lookup_extended
    
        
        
            
            Syntax
            gboolean
mono_g_hash_table_lookup_extended (MonoGHashTable *hash, gconstpointer key, gpointer *orig_key, gpointer *value)
            
         
     
  
    mono_g_hash_table_remove
    
        
        
            
            Syntax
            gboolean
mono_g_hash_table_remove (MonoGHashTable *hash, gconstpointer key)
            
         
     
  
    mono_g_hash_table_replace
    
        
        
            
            Syntax
            void
mono_g_hash_table_replace(MonoGHashTable *h, gpointer k, gpointer v)
            
         
     
  
    mono_g_hash_table_size
    
        
        
            
            Syntax
            guint
mono_g_hash_table_size (MonoGHashTable *hash)
            
         
     
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
    
        
        
            
            Syntax
            MonoMemPool*
mono_mempool_new (void)
            
             Return value
             	 a new memory pool.
             Description
             
         
     
  
    mono_mempool_destroy
    
        
        
            
            Syntax
            void
mono_mempool_destroy (MonoMemPool *pool)
            
            Parameters
            | pool | the memory pool to destroy | 
             Description
              	 	 Free all memory associated with this pool.
 
         
     
  
    mono_mempool_alloc
    
        
        
            
            Syntax
            gpointer
mono_mempool_alloc (MonoMemPool *pool, guint size)
            
            Parameters
            | pool | the memory pool to use | 
| size | size of the memory block | 
             Return value
             	 the address of a newly allocated memory block.
             Description
              	 	 Allocates a new block of memory in 
pool . 	
 
         
     
  
    mono_mempool_alloc0
    
        
        
            
            Syntax
            gpointer
mono_mempool_alloc0 (MonoMemPool *pool, guint size)
            
             Description
              	 	 same as 
mono_mempool_alloc, but fills memory with zero.
 
         
     
  
    mono_mempool_invalidate
    
        
        
            
            Syntax
            void
mono_mempool_invalidate (MonoMemPool *pool)
            
            Parameters
            | pool | the memory pool to invalidate | 
             Description
              	 	 Fill the memory associated with this pool to 0x2a (42). Useful for debugging.
 
         
     
  
    mono_mempool_stats
    
        
        
            
            Syntax
            void
mono_mempool_stats (MonoMemPool *pool)
            
            Parameters
            | pool | the memory pool we need stats for | 
             Description
              	 	 Print a few stats about the mempool: 	 - Total memory allocated (malloced) by mem pool 	 - Number of chunks/blocks memory is allocated in 	 - How much memory is available to dispense before a new malloc must occur?
 
         
     
  
    mono_mempool_contains_addr
    
        
        
            
            Syntax
            gboolean
mono_mempool_contains_addr (MonoMemPool *pool,
							gpointer addr)
            
             Description
              	 	 Determines whether 
addr is inside the memory used by the mempool.
 
         
     
 
Bitsets
	MonoBitsets are a set of routines used to manipulate sets
	of bits.
	
  
    mono_bitset_alloc_size
    
        
        
            
            Syntax
            guint32
mono_bitset_alloc_size (guint32 max_size, guint32 flags)
            
            Parameters
            | max_size | The number of bits you want to hold | 
| flags | unused | 
             Return value
             	 the number of bytes required to hold the bitset.
	 Useful to allocate it on the stack or with mempool.
	 Use with mono_bitset_mem_new.
         
     
  
    mono_bitset_clear
    
        
        
            
            Syntax
            void
mono_bitset_clear (MonoBitSet *set, guint32 pos)
            
            Parameters
            | set | bitset ptr | 
| pos | unset bit at this pos | 
             Description
              	 	 Unset bit at 
pos, counting from 0.
 
         
     
  
    mono_bitset_clear_all
    
        
        
            
            Syntax
            void
mono_bitset_clear_all (MonoBitSet *set)
            
            Parameters
                         Description
             
         
     
  
    mono_bitset_clone
    
        
        
            
            Syntax
            MonoBitSet*
mono_bitset_clone (const MonoBitSet *set, guint32 new_size)
            
            Parameters
            | set | bitset ptr to clone | 
| new_size | number of bits the cloned bitset can hold | 
             Return value
             	 a cloned bitset of size new_size. MONO_BITSET_DONT_FREE
	 unset in cloned bitset. If new_size is 0, the cloned object is just
	 as big.
         
     
  
    mono_bitset_copyto
    
        
        
            
            Syntax
            void
mono_bitset_copyto (const MonoBitSet *src, MonoBitSet *dest)
            
            Parameters
            | src | bitset ptr to copy from | 
| dest | bitset ptr to copy to | 
             Description
              	 	 Copy one bitset to another.
 
         
     
  
    mono_bitset_count
    
        
        
            
            Syntax
            guint32
mono_bitset_count (const MonoBitSet *set)
            
            Parameters
                         Return value
             	 number of bits that are set.
         
     
  
    mono_bitset_equal
    
        
        
            
            Syntax
            gboolean
mono_bitset_equal (const MonoBitSet *src, const MonoBitSet *src1)
            
            Parameters
            | src | bitset ptr | 
| src1 | bitset ptr | 
             Return value
             	 TRUE if their size are the same and the same bits are set in
	 both bitsets.
         
     
  
    mono_bitset_find_first
    
        
        
            
            Syntax
            int
mono_bitset_find_first (const MonoBitSet *set, gint pos)
            
            Parameters
            | set | bitset ptr | 
| pos | pos to search after (not including) | 
             Return value
             	 position of first set bit after pos. If pos -1 if no bit set is found.
         
     
  
    mono_bitset_find_last
    
        
        
            
            Syntax
            int
mono_bitset_find_last (const MonoBitSet *set, gint pos)
            
            Parameters
            | set | bitset ptr | 
| pos | pos to search before (not including) | 
             Return value
             	 position of last set bit before pos. If pos -1 if no set bit is found.
         
     
  
    mono_bitset_find_start
    
        
        
            
            Syntax
            int
mono_bitset_find_start   (const MonoBitSet *set)
            
            Parameters
                         Description
              	 Equivalent to mono_bitset_find_first (set, -1) but faster.
         
     
  
    mono_bitset_foreach
    
        
        
            
            Syntax
            void
mono_bitset_foreach (MonoBitSet *set, MonoBitSetFunc func, gpointer data)
            
            Parameters
            | set | bitset ptr | 
| func | Function to call for every set bit | 
| data | pass this as second arg to func | 
             Description
              	 Calls func for every bit set in bitset. Argument 1 is the number of 	 the bit set, argument 2 is data
         
     
  
 
    mono_bitset_intersection
    
        
        
            
            Syntax
            void
mono_bitset_intersection (MonoBitSet *dest, const MonoBitSet *src)
            
            Parameters
            | dest | bitset ptr to hold intersection | 
| src | bitset ptr to copy | 
             Description
              	 	 Make intersection of one bitset and another.
 
         
     
  
    mono_bitset_invert
    
        
        
            
            Syntax
            void
mono_bitset_invert (MonoBitSet *set)
            
            Parameters
                         Description
             
         
     
  
    mono_bitset_mem_new
    
        
        
            
            Syntax
            MonoBitSet*
mono_bitset_mem_new (gpointer mem, guint32 max_size, guint32 flags)
            
            Parameters
            | mem | The location the bitset is stored | 
| max_size | The number of bits you want to hold | 
| flags | bitfield of flags | 
             Description
              	 	 Return 
mem, which is now a initialized bitset of size 
max_size. It is 	 not freed even if called with 
mono_bitset_free. 
mem must be at least 	 as big as 
mono_bitset_alloc_size returns for the same 
max_size.
 
         
     
  
    mono_bitset_new
    
        
        
            
            Syntax
            MonoBitSet*
mono_bitset_new (guint32 max_size, guint32 flags)
            
            Parameters
            | max_size | The numer of bits you want to hold | 
| flags | bitfield of flags | 
             Return value
             	 a bitset of size max_size. It must be freed using
	 mono_bitset_free.
         
     
  
    mono_bitset_set
    
        
        
            
            Syntax
            void
mono_bitset_set (MonoBitSet *set, guint32 pos)
            
            Parameters
            | set | bitset ptr | 
| pos | set bit at this pos | 
             Description
              	 	 Set bit at 
pos, counting from 0.
 
         
     
  
    mono_bitset_set_all
    
        
        
            
            Syntax
            void
mono_bitset_set_all (MonoBitSet *set)
            
            Parameters
                         Description
             
         
     
  
    mono_bitset_size
    
        
        
            
            Syntax
            guint32
mono_bitset_size (const MonoBitSet *set)
            
            Parameters
                         Return value
             	 the number of bits this bitset can hold.
         
     
  
    mono_bitset_sub
    
        
        
            
            Syntax
            void
mono_bitset_sub (MonoBitSet *dest, const MonoBitSet *src)
            
            Parameters
            | dest | bitset ptr to hold bitset - src | 
| src | bitset ptr to copy | 
             Description
              	 	 Unset all bits in 
dest that are set in 
src.
 
         
     
  
    mono_bitset_test
    
        
        
            
            Syntax
            int
mono_bitset_test (const MonoBitSet *set, guint32 pos)
            
            Parameters
            | set | bitset ptr | 
| pos | test bit at this pos | 
             Return value
             	 a nonzero value if set, 0 otherwise.
             Description
              	 Test bit at pos, counting from 0.
         
     
  
    mono_bitset_test_bulk
    
        
        
            
            Syntax
            gsize
mono_bitset_test_bulk (const MonoBitSet *set, guint32 pos)
            
            Parameters
            | set | bitset ptr | 
| pos | test bit at this pos | 
             Return value
             	 32/64 bits from the bitset, starting from pos, which must be 
	 divisible with 32/64.
         
     
  
    mono_bitset_union
    
        
        
            
            Syntax
            void
mono_bitset_union (MonoBitSet *dest, const MonoBitSet *src)
            
            Parameters
            | dest | bitset ptr to hold union | 
| src | bitset ptr to copy | 
             Description
              	 	 Make union of one bitset and another.
 
         
     
  
    mono_bitset_find_first_unset
    
        
        
            
            Syntax
            int
mono_bitset_find_first_unset (const MonoBitSet *set, gint pos)
            
            Parameters
            | set | bitset ptr | 
| pos | pos to search after (not including) | 
             Return value
             	 position of first unset bit after pos. If pos -1 if no bit set is found.
         
     
  
    mono_bitset_intersection_2
    
        
        
            
            Syntax
            void
mono_bitset_intersection_2 (MonoBitSet *dest, const MonoBitSet *src1, const MonoBitSet *src2)
            
            Parameters
            | dest | bitset ptr to hold intersection | 
| src1 | first bitset | 
| src2 | second bitset | 
             Description
              	 	 Make intersection of two bitsets
 
         
     
JIT utilities
  
    mono_signbit_double
    
        
        
            
            Syntax
            int
mono_signbit_double (double x)
            
         
     
  
    mono_signbit_float
    
        
        
            
            Syntax
            int
mono_signbit_float (float x)
            
         
     
Function Pointers
	To wrap a function pointer into something that the Mono
	runtime can consume, you should use the mono_create_ftnptr.
	This is only important if you plan on running on the IA64
	architecture.   Otherwise you can just use the function
	pointer address.
	
  
    mono_create_ftnptr
    
        
        
            
            Syntax
            gpointer
mono_create_ftnptr (MonoDomain *domain, gpointer addr)
            
             Description
              	 	 Given a function address, create a function descriptor for it. 	 This is only needed on some platforms.
 
         
     
Notification Interface
	This is an internal profiler interface.   In general, users
	would not be using this interface, but would be using the
	profiler interface. 
	
These methods must be called to notify the profiler of an
	event that must be recorded.   Mono's JIT engine currently
	calls these routines, but if you are extending Mono in some
	way these are the methods that you might invoke to notify the
	profiler of an event.
  
    mono_profiler_load
    
        
        
            
            Syntax
            void 
mono_profiler_load (const char *desc)
            
            Parameters
            | desc | arguments to configure the profiler | 
             Description
              	 	 Invoke this method to initialize the profiler.   This will drive the 	 loading of the internal ("default") or any external profilers. 	
 	 This routine is invoked by Mono's driver, but must be called manually 	 if you embed Mono into your application.
 
         
     
  
    mono_profiler_allocation
    
        
        
            
            Syntax
            void 
mono_profiler_allocation (MonoObject *obj)
            
         
     
  
    mono_profiler_stat_hit
    
        
        
            
            Syntax
            void
mono_profiler_stat_hit (guchar *ip, void *context)
            
         
     
  
    mono_profiler_thread_start
    
        
        
            
            Syntax
            void
mono_profiler_thread_start (gsize tid)
            
         
     
  
    mono_profiler_thread_end
    
        
        
            
            Syntax
            void 
mono_profiler_thread_end (gsize tid)
            
         
     
  
    mono_profiler_appdomain_event
    
        
        
            
            Syntax
            void 
mono_profiler_appdomain_event  (MonoDomain *domain, int code)
            
         
     
  
    mono_profiler_appdomain_loaded
    
        
        
            
            Syntax
            void 
mono_profiler_appdomain_loaded (MonoDomain *domain, int result)
            
         
     
  
    mono_profiler_assembly_event
    
        
        
            
            Syntax
            void 
mono_profiler_assembly_event  (MonoAssembly *assembly, int code)
            
         
     
  
    mono_profiler_assembly_loaded
    
        
        
            
            Syntax
            void 
mono_profiler_assembly_loaded (MonoAssembly *assembly, int result)
            
         
     
  
    mono_profiler_class_event
    
        
        
            
            Syntax
            void 
mono_profiler_class_event  (MonoClass *klass, int code)
            
         
     
  
    mono_profiler_class_loaded
    
        
        
            
            Syntax
            void 
mono_profiler_class_loaded (MonoClass *klass, int result)
            
         
     
  
    mono_profiler_code_transition
    
        
        
            
            Syntax
            void 
mono_profiler_code_transition (MonoMethod *method, int result)
            
         
     
  
    mono_profiler_method_end_jit
    
        
        
            
            Syntax
            void 
mono_profiler_method_end_jit (MonoMethod *method, MonoJitInfo* jinfo, int result)
            
         
     
  
    mono_profiler_method_enter
    
        
        
            
            Syntax
            void
mono_profiler_method_enter (MonoMethod *method)
            
         
     
  
    mono_profiler_method_jit
    
        
        
            
            Syntax
            void 
mono_profiler_method_jit (MonoMethod *method)
            
         
     
  
    mono_profiler_method_leave
    
        
        
            
            Syntax
            void
mono_profiler_method_leave (MonoMethod *method)
            
         
     
  
    mono_profiler_module_event
    
        
        
            
            Syntax
            void 
mono_profiler_module_event  (MonoImage *module, int code)
            
         
     
  
    mono_profiler_module_loaded
    
        
        
            
            Syntax
            void 
mono_profiler_module_loaded (MonoImage *module, int result)
            
         
     
  
    mono_profiler_shutdown
    
        
        
            
            Syntax
            void 
mono_profiler_shutdown (void)
            
         
     
  
    mono_profiler_startup
    
        
        
            
            Syntax
            void
mono_profiler_startup (const char *desc)
            
             Description
              	 the entry point
         
     
  
    mono_profiler_gc_event
    
        
        
            
            Syntax
            void
mono_profiler_gc_event (MonoGCEvent event, int generation)
            
         
     
  
    mono_profiler_gc_heap_resize
    
        
        
            
            Syntax
            void
mono_profiler_gc_heap_resize (gint64 new_size)