00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef LLVM_SYSTEM_MEMORY_H
00015 #define LLVM_SYSTEM_MEMORY_H
00016
00017 #include "llvm/Support/DataTypes.h"
00018 #include <string>
00019
00020 namespace llvm {
00021 namespace sys {
00022
00028 class MemoryBlock {
00029 public:
00030 MemoryBlock() : Address(0), Size(0) { }
00031 MemoryBlock(void *addr, size_t size) : Address(addr), Size(size) { }
00032 void *base() const { return Address; }
00033 size_t size() const { return Size; }
00034 private:
00035 void *Address;
00036 size_t Size;
00037 friend class Memory;
00038 };
00039
00044 class Memory {
00045 public:
00056 static MemoryBlock AllocateRWX(size_t NumBytes,
00057 const MemoryBlock *NearBlock,
00058 std::string *ErrMsg = 0);
00059
00067 static bool ReleaseRWX(MemoryBlock &block, std::string *ErrMsg = 0);
00068
00069
00073 static void InvalidateInstructionCache(const void *Addr, size_t Len);
00074
00078 static bool setExecutable(MemoryBlock &M, std::string *ErrMsg = 0);
00079
00083 static bool setWritable(MemoryBlock &M, std::string *ErrMsg = 0);
00084
00087 static bool setRangeExecutable(const void *Addr, size_t Size);
00088
00091 static bool setRangeWritable(const void *Addr, size_t Size);
00092 };
00093 }
00094 }
00095
00096 #endif