knight/shared/KeCodeAllocator.h
author Kyle Sanderson <kyle.leet@gmail.com>
Mon Aug 12 00:42:56 2013 +0100 (2013-08-12)
changeset 3994 4bc73bac0f4c
parent 3980 dc7dfcd855dc
permissions -rw-r--r--
Added helper stock to check if a command exists. (bug 5510, r=asherkin)
     1 #ifndef _INCLUDE_KNIGHT_KE_CODE_ALLOCATOR_H_
     2 #define _INCLUDE_KNIGHT_KE_CODE_ALLOCATOR_H_
     3 
     4 #include <KeLinking.h>
     5 #include <stddef.h>
     6 #include <stdint.h>
     7 
     8 namespace Knight
     9 {
    10 	class KeCodeCache;
    11 
    12 	/**
    13 	 * @brief Creates a new code cache/allocator.
    14 	 *
    15 	 * @return				New code cache allocator.
    16 	 */
    17 	extern KeCodeCache *KE_CreateCodeCache();
    18 
    19 	/**
    20 	 * @brief Destroys a code cache allocator.
    21 	 *
    22 	 * @param cache			Code cache object.
    23 	 */
    24 	extern void KE_DestroyCodeCache(KeCodeCache *cache);
    25 
    26 	/**
    27 	 * @brief Allocates code memory that is readable, writable, 
    28 	 * and executable.
    29 	 *
    30 	 * The address returned wlil be aligned, minimally, on a 16-byte 
    31 	 * boundary.
    32 	 *
    33 	 * @param cache			Code cache object.
    34 	 * @param size			Amount of memory needed.
    35 	 * @return				Address pointing to the memory.
    36 	 */
    37 	extern void *KE_AllocCode(KeCodeCache *cache, size_t size);
    38 
    39 	/**
    40 	 * @brief Frees code memory.
    41 	 *
    42 	 * @param cache			Code cache object.
    43 	 * @param code			Address of code memory.
    44 	 */
    45 	extern void KE_FreeCode(KeCodeCache *cache, void *code);
    46 }
    47 
    48 #endif //_INCLUDE_KNIGHT_KE_CODE_ALLOCATOR_H_