--- /dev/null
+//===- AIX/Memory.cpp - AIX Memory Implementation ---------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file was developed by Reid Spencer and is distributed under the
+// University of Illinois Open Source License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file provides the AIX specific implementation of various Memory
+// management utilities
+//
+//===----------------------------------------------------------------------===//
+
+// Include the generic unix implementation
+#include "../Unix/Memory.cpp"
+#include "llvm/System/Process.h"
+#include <sys/types.h>
+#include <sys/mman.h>
+
+namespace llvm {
+using namespace sys;
+
+//===----------------------------------------------------------------------===//
+//=== WARNING: Implementation here must contain only AIX specific code
+//=== and must not be generic UNIX code (see ../Unix/Memory.cpp)
+//===----------------------------------------------------------------------===//
+
+void* Memory::AllocateRWX(Memory& M, unsigned NumBytes) {
+ if (NumBytes == 0) return 0;
+
+ static const long pageSize = Process::GetPageSize();
+ unsigned NumPages = (NumBytes+pageSize-1)/pageSize;
+
+ void *pa = mmap(0, pageSize*NumPages, PROT_READ|PROT_WRITE|PROT_EXEC,
+ MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
+ if (pa == (void*)-1) {
+ throw std::string("Can't allocate RWX Memory: ") + strerror(errno);
+ }
+ M.Address = pa;
+ M.AllocSize = NumPages*pageSize;
+ return pa;
+}
+
+void Memory::ReleaseRWX(Memory& M) {
+ if (M.Address == 0 || M.AllocSize == 0) return;
+ if (0 != munmap(M.Address, M.AllocSize)) {
+ throw std::string("Can't release RWX Memory: ") + sterror(errno);
+ }
+}
+
+}
+
+// vim: sw=2 smartindent smarttab tw=80 autoindent expandtab
return result;
}
+std::string
+Path::GetDLLSuffix() {
+ return "so";
+}
+
}
// vim: sw=2 smartindent smarttab tw=80 autoindent expandtab
--- /dev/null
+//===- AIX/Process.cpp - AIX Process Implementation ----------- -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file was developed by Reid Spencer and is distributed under the
+// University of Illinois Open Source License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file provides the AIX specific implementation of the Process class.
+//
+//===----------------------------------------------------------------------===//
+
+// Include the generic Unix implementation
+#include "../Unix/Process.cpp"
+
+//===----------------------------------------------------------------------===//
+//=== WARNING: Implementation here must contain only AIX specific code
+//=== and must not be generic UNIX code (see ../Unix/Process.cpp)
+//===----------------------------------------------------------------------===//
+
+// vim: sw=2 smartindent smarttab tw=80 autoindent expandtab
--- /dev/null
+//===- Cygwin/Memory.cpp - Cygwin Memory Implementation ---------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file was developed by Reid Spencer and is distributed under the
+// University of Illinois Open Source License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file provides the Cygwin specific implementation of various Memory
+// management utilities
+//
+//===----------------------------------------------------------------------===//
+
+// Include the generic unix implementation
+#include "../Unix/Memory.cpp"
+#include "llvm/System/Process.h"
+#include <sys/types.h>
+#include <sys/mman.h>
+
+namespace llvm {
+using namespace sys;
+
+//===----------------------------------------------------------------------===//
+//=== WARNING: Implementation here must contain only Cygwin specific code
+//=== and must not be generic UNIX code (see ../Unix/Memory.cpp)
+//===----------------------------------------------------------------------===//
+
+void* Memory::AllocateRWX(Memory& M, unsigned NumBytes) {
+ if (NumBytes == 0) return 0;
+
+ static const long pageSize = Process::GetPageSize();
+ unsigned NumPages = (NumBytes+pageSize-1)/pageSize;
+
+ void *pa = mmap(0, pageSize*NumPages, PROT_READ|PROT_WRITE|PROT_EXEC,
+ MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
+ if (pa == (void*)-1) {
+ throw std::string("Can't allocate RWX Memory: ") + strerror(errno);
+ }
+ M.Address = pa;
+ M.AllocSize = NumPages*pageSize;
+ return pa;
+}
+
+void Memory::ReleaseRWX(Memory& M) {
+ if (M.Address == 0 || M.AllocSize == 0) return;
+ if (0 != munmap(M.Address, M.AllocSize)) {
+ throw std::string("Can't release RWX Memory: ") + sterror(errno);
+ }
+}
+
+}
+
+// vim: sw=2 smartindent smarttab tw=80 autoindent expandtab
return result;
}
+std::string
+Path::GetDLLSuffix() {
+ return "dll.a";
+}
+
}
// vim: sw=2 smartindent smarttab tw=80 autoindent expandtab
--- /dev/null
+//===- Cygwin/Process.cpp - Cygwin Process Implementation ----- -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file was developed by Reid Spencer and is distributed under the
+// University of Illinois Open Source License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file provides the Cygwin specific implementation of the Process class.
+//
+//===----------------------------------------------------------------------===//
+
+// Include the generic Unix implementation
+#include "../Unix/Process.cpp"
+
+//===----------------------------------------------------------------------===//
+//=== WARNING: Implementation here must contain only Cygwin specific code
+//=== and must not be generic UNIX code (see ../Unix/Process.cpp)
+//===----------------------------------------------------------------------===//
+
+// vim: sw=2 smartindent smarttab tw=80 autoindent expandtab
--- /dev/null
+//===- Darwin/Memory.cpp - Darwin Memory Implementation ---------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file was developed by Reid Spencer and is distributed under the
+// University of Illinois Open Source License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file provides the Darwin specific implementation of various Memory
+// management utilities
+//
+//===----------------------------------------------------------------------===//
+
+// Include the generic unix implementation
+#include "../Unix/Memory.cpp"
+#include "llvm/System/Process.h"
+#include <sys/mman.h>
+
+namespace llvm {
+using namespace sys;
+
+//===----------------------------------------------------------------------===//
+//=== WARNING: Implementation here must contain only Darwin specific code
+//=== and must not be generic UNIX code (see ../Unix/Memory.cpp)
+//===----------------------------------------------------------------------===//
+
+/// AllocateRWXMemory - Allocate a slab of memory with read/write/execute
+/// permissions. This is typically used for JIT applications where we want
+/// to emit code to the memory then jump to it. Getting this type of memory
+/// is very OS specific.
+///
+void* Memory::AllocateRWX(Memory& M, unsigned NumBytes) {
+ if (NumBytes == 0) return 0;
+
+ static const long pageSize = Process::GetPageSize();
+ unsigned NumPages = (NumBytes+pageSize-1)/pageSize;
+
+ void *pa = mmap(0, pageSize*NumPages, PROT_READ|PROT_WRITE|PROT_EXEC,
+ MAP_PRIVATE|MAP_ANON, -1, 0);
+ if (pa == MAP_FAILED) {
+ char msg[MAXPATHLEN];
+ strerror_r(errno, msg, MAXPATHLEN-1);
+ throw std::string("Can't allocate RWX Memory: ") + msg;
+ }
+ M.Address = pa;
+ M.AllocSize = NumPages*pageSize;
+ return pa;
+}
+
+void Memory::ReleaseRWX(Memory& M) {
+ if (M.Address == 0 || M.AllocSize == 0) return;
+ if (0 != munmap(M.Address, M.AllocSize)) {
+ char msg[MAXPATHLEN];
+ strerror_r(errno, msg, MAXPATHLEN-1);
+ throw std::string("Can't release RWX Memory: ") + msg;
+ }
+}
+
+}
+
+// vim: sw=2 smartindent smarttab tw=80 autoindent expandtab
return result;
}
+std::string
+Path::GetDLLSuffix() {
+ return "dyld";
+}
+
}
// vim: sw=2 smartindent smarttab tw=80 autoindent expandtab
--- /dev/null
+//===- Darwin/Process.cpp - Darwin Process Implementation ----- -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file was developed by Reid Spencer and is distributed under the
+// University of Illinois Open Source License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file provides the Darwin specific implementation of the Process class.
+//
+//===----------------------------------------------------------------------===//
+
+// Include the generic Unix implementation
+#include "../Unix/Process.cpp"
+
+//===----------------------------------------------------------------------===//
+//=== WARNING: Implementation here must contain only Darwin specific code
+//=== and must not be generic UNIX code (see ../Unix/Process.cpp)
+//===----------------------------------------------------------------------===//
+
+// vim: sw=2 smartindent smarttab tw=80 autoindent expandtab
--- /dev/null
+//===- FreeBSD/Memory.cpp - FreeBSD Memory Implementation -------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file was developed by Reid Spencer and is distributed under the
+// University of Illinois Open Source License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file provides the FreeBSD specific implementation of various Memory
+// management utilities
+//
+//===----------------------------------------------------------------------===//
+
+// Include the generic unix implementation
+#include "../Unix/Memory.cpp"
+#include "llvm/System/Process.h"
+#include <sys/mman.h>
+
+namespace llvm {
+using namespace sys;
+
+//===----------------------------------------------------------------------===//
+//=== WARNING: Implementation here must contain only FreeBSD specific code
+//=== and must not be generic UNIX code (see ../Unix/Memory.cpp)
+//===----------------------------------------------------------------------===//
+
+void* Memory::AllocateRWX(Memory& M, unsigned NumBytes) {
+ if (NumBytes == 0) return 0;
+
+ static const long pageSize = Process::GetPageSize();
+ unsigned NumPages = (NumBytes+pageSize-1)/pageSize;
+
+ void *pa = mmap(0, pageSize*NumPages, PROT_READ|PROT_WRITE|PROT_EXEC,
+ MAP_PRIVATE|MAP_ANON|MAP_NOCORE, -1, 0);
+ if (pa == (void*)-1) {
+ throw std::string("Can't allocate RWX Memory: ") + strerror(errno);
+ }
+ M.Address = pa;
+ M.AllocSize = NumPages*pageSize;
+ return pa;
+}
+
+void Memory::ReleaseRWX(Memory& M) {
+ if (M.Address == 0 || M.AllocSize == 0) return;
+ if (0 != munmap(M.Address, M.AllocSize)) {
+ throw std::string("Can't release RWX Memory: ") + sterror(errno);
+ }
+}
+
+}
+
+// vim: sw=2 smartindent smarttab tw=80 autoindent expandtab
return result;
}
+std::string
+Path::GetDLLSuffix() {
+ return "so";
+}
+
}
// vim: sw=2 smartindent smarttab tw=80 autoindent expandtab
--- /dev/null
+//===- FreeBSD/Process.cpp - FreeBSD Process Implementation --- -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file was developed by Reid Spencer and is distributed under the
+// University of Illinois Open Source License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file provides the FreeBSD specific implementation of the Process class.
+//
+//===----------------------------------------------------------------------===//
+
+// Include the generic Unix implementation
+#include "../Unix/Process.cpp"
+
+//===----------------------------------------------------------------------===//
+//=== WARNING: Implementation here must contain only FreeBSD specific code
+//=== and must not be generic UNIX code (see ../Unix/Process.cpp)
+//===----------------------------------------------------------------------===//
+
+// vim: sw=2 smartindent smarttab tw=80 autoindent expandtab
--- /dev/null
+//===- Interix/Memory.cpp - Interix Memory Implementation -------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file was developed by Reid Spencer and is distributed under the
+// University of Illinois Open Source License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file provides the Interix specific implementation of various Memory
+// management utilities
+//
+//===----------------------------------------------------------------------===//
+
+// Include the generic unix implementation
+#include "../Unix/Memory.cpp"
+#include "llvm/System/Process.h"
+#include <sys/mman.h>
+
+namespace llvm {
+using namespace sys;
+
+//===----------------------------------------------------------------------===//
+//=== WARNING: Implementation here must contain only Interix specific code
+//=== and must not be generic UNIX code (see ../Unix/Memory.cpp)
+//===----------------------------------------------------------------------===//
+
+void* Memory::AllocateRWX(Memory& M, unsigned NumBytes) {
+ if (NumBytes == 0) return 0;
+
+ static const long pageSize = Process::GetPageSize();
+ unsigned NumPages = (NumBytes+pageSize-1)/pageSize;
+
+ void *pa = mmap(0, pageSize*NumPages, PROT_READ|PROT_WRITE|PROT_EXEC,
+ MAP_PRIVATE|MAP_ANON|MAP_NOCORE, -1, 0);
+ if (pa == (void*)-1) {
+ throw std::string("Can't allocate RWX Memory: ") + strerror(errno);
+ }
+ M.Address = pa;
+ M.AllocSize = NumPages*pageSize;
+ return pa;
+}
+
+void Memory::ReleaseRWX(Memory& M) {
+ if (M.Address == 0 || M.AllocSize == 0) return;
+ if (0 != munmap(M.Address, M.AllocSize)) {
+ throw std::string("Can't release RWX Memory: ") + sterror(errno);
+ }
+}
+
+}
+
+// vim: sw=2 smartindent smarttab tw=80 autoindent expandtab
return result;
}
+std::string
+Path::GetDLLSuffix() {
+ return "dll";
+}
+
}
// vim: sw=2 smartindent smarttab tw=80 autoindent expandtab
--- /dev/null
+//===- Interix/Process.cpp - Interix Process Implementation --- -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file was developed by Reid Spencer and is distributed under the
+// University of Illinois Open Source License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file provides the Interix specific implementation of the Process class.
+//
+//===----------------------------------------------------------------------===//
+
+// Include the generic Unix implementation
+#include "../Unix/Process.cpp"
+
+//===----------------------------------------------------------------------===//
+//=== WARNING: Implementation here must contain only Interix specific code
+//=== and must not be generic UNIX code (see ../Unix/Process.cpp)
+//===----------------------------------------------------------------------===//
+
+// vim: sw=2 smartindent smarttab tw=80 autoindent expandtab
--- /dev/null
+//===- Linux/Memory.cpp - Linux Memory Implementation -----*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file was developed by Reid Spencer and is distributed under the
+// University of Illinois Open Source License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file provides the Linux specific implementation of various Memory
+// management utilities
+//
+//===----------------------------------------------------------------------===//
+
+// Include the generic unix implementation
+#include "../Unix/Memory.cpp"
+#include "llvm/System/Process.h"
+#include <sys/mman.h>
+
+namespace llvm {
+using namespace sys;
+
+//===----------------------------------------------------------------------===//
+//=== WARNING: Implementation here must contain only Linux specific code
+//=== and must not be generic UNIX code (see ../Unix/Memory.cpp)
+//===----------------------------------------------------------------------===//
+
+/// AllocateRWXMemory - Allocate a slab of memory with read/write/execute
+/// permissions. This is typically used for JIT applications where we want
+/// to emit code to the memory then jump to it. Getting this type of memory
+/// is very OS specific.
+///
+void* Memory::AllocateRWX(Memory& M, unsigned NumBytes) {
+ if (NumBytes == 0) return 0;
+
+ static const long pageSize = Process::GetPageSize();
+ unsigned NumPages = (NumBytes+pageSize-1)/pageSize;
+
+ void *pa = mmap(0, pageSize*NumPages, PROT_READ|PROT_WRITE|PROT_EXEC,
+ MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, 0, 0);
+ if (pa == MAP_FAILED) {
+ char msg[MAXPATHLEN];
+ strerror_r(errno, msg, MAXPATHLEN-1);
+ throw std::string("Can't allocate RWX Memory: ") + msg;
+ }
+ M.Address = pa;
+ M.AllocSize = NumPages*pageSize;
+ return pa;
+}
+
+void Memory::ReleaseRWX(Memory& M) {
+ if (M.Address == 0 || M.AllocSize == 0) return;
+ if (0 != munmap(M.Address, M.AllocSize)) {
+ char msg[MAXPATHLEN];
+ strerror_r(errno, msg, MAXPATHLEN-1);
+ throw std::string("Can't release RWX Memory: ") + msg;
+ }
+}
+
+}
+
+// vim: sw=2 smartindent smarttab tw=80 autoindent expandtab
return result;
}
+std::string
+Path::GetDLLSuffix() {
+ return "so";
+}
+
}
// vim: sw=2 smartindent smarttab tw=80 autoindent expandtab
--- /dev/null
+//===- Linux/Process.cpp - Linux Process Implementation ------- -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file was developed by Reid Spencer and is distributed under the
+// University of Illinois Open Source License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file provides the Linux specific implementation of the Process class.
+//
+//===----------------------------------------------------------------------===//
+
+// Include the generic Unix implementation
+#include "../Unix/SUS/Process.cpp"
+
+//===----------------------------------------------------------------------===//
+//=== WARNING: Implementation here must contain only Linux specific code
+//=== and must not be generic UNIX code (see ../Unix/Process.cpp)
+//===----------------------------------------------------------------------===//
+
+// vim: sw=2 smartindent smarttab tw=80 autoindent expandtab
--- /dev/null
+//===- Memory.cpp - Memory Handling Support ---------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file was developed by Reid Spencer and is distributed under the
+// University of Illinois Open Source License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines some helpful functions for allocating memory and dealing
+// with memory mapped files
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/System/Memory.h"
+
+namespace llvm {
+using namespace sys;
+
+//===----------------------------------------------------------------------===//
+//=== WARNING: Implementation here must contain only TRULY operating system
+//=== independent code.
+//===----------------------------------------------------------------------===//
+
+}
+
+// Include the platform-specific parts of this class.
+#include "platform/Memory.cpp"
+
+// vim: sw=2 smartindent smarttab tw=80 autoindent expandtab
//=== independent code.
//===----------------------------------------------------------------------===//
-bool
-Path::is_file() const {
- return (is_valid() && path[path.length()-1] != '/');
-}
-
-bool
-Path::is_directory() const {
- return (is_valid() && path[path.length()-1] == '/');
-}
-
}
// Include the truly platform-specific parts of this class.
--- /dev/null
+//===-- Process.cpp - Implement OS Process Concept --------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file was developed by Reid Spencer and is distributed under the
+// University of Illinois Open Source License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This header file implements the operating system Process concept.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/System/Process.h"
+
+namespace llvm {
+using namespace sys;
+
+//===----------------------------------------------------------------------===//
+//=== WARNING: Implementation here must contain only TRULY operating system
+//=== independent code.
+//===----------------------------------------------------------------------===//
+
+}
+
+// Include the platform-specific parts of this class.
+#include "platform/Process.cpp"
+
+// vim: sw=2 smartindent smarttab tw=80 autoindent expandtab
--- /dev/null
+//===- SunOS/Memory.cpp - SunOS Memory Implementation -----------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file was developed by Reid Spencer and is distributed under the
+// University of Illinois Open Source License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file provides the SunOS specific implementation of various Memory
+// management utilities
+//
+//===----------------------------------------------------------------------===//
+
+// Include the generic unix implementation
+#include "../Unix/Memory.cpp"
+#include "llvm/System/Process.h"
+#include <sys/types.h>
+#include <sys/mman.h>
+
+namespace llvm {
+using namespace sys;
+
+//===----------------------------------------------------------------------===//
+//=== WARNING: Implementation here must contain only SunOS specific code
+//=== and must not be generic UNIX code (see ../Unix/Memory.cpp)
+//===----------------------------------------------------------------------===//
+
+void* Memory::AllocateRWX(Memory& M, unsigned NumBytes) {
+ if (NumBytes == 0) return 0;
+
+ static const long pageSize = Process::GetPageSize();
+ unsigned NumPages = (NumBytes+pageSize-1)/pageSize;
+
+ void *pa = mmap(0, pageSize*NumPages, PROT_READ|PROT_WRITE|PROT_EXEC,
+ MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
+ if (pa == (void*)-1) {
+ throw std::string("Can't allocate RWX Memory: ") + strerror(errno);
+ }
+ M.Address = pa;
+ M.AllocSize = NumPages*pageSize;
+ return pa;
+}
+
+void Memory::ReleaseRWX(Memory& M) {
+ if (M.Address == 0 || M.AllocSize == 0) return;
+ if (0 != munmap(M.Address, M.AllocSize)) {
+ throw std::string("Can't release RWX Memory: ") + sterror(errno);
+ }
+}
+
+}
+
+// vim: sw=2 smartindent smarttab tw=80 autoindent expandtab
return result;
}
+std::string
+Path::GetDLLSuffix() {
+ return "so";
+}
+
}
// vim: sw=2 smartindent smarttab tw=80 autoindent expandtab
--- /dev/null
+//===- SunOS/Process.cpp - SunOS Process Implementation ------- -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file was developed by Reid Spencer and is distributed under the
+// University of Illinois Open Source License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file provides the SunOS specific implementation of the Process class.
+//
+//===----------------------------------------------------------------------===//
+
+// Include the generic Unix implementation
+#include "../Unix/Process.cpp"
+
+//===----------------------------------------------------------------------===//
+//=== WARNING: Implementation here must contain only SunOS specific code
+//=== and must not be generic UNIX code (see ../Unix/Process.cpp)
+//===----------------------------------------------------------------------===//
+
+// vim: sw=2 smartindent smarttab tw=80 autoindent expandtab
--- /dev/null
+//===- Win32/Memory.cpp - Win32 Memory Implementation -----------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file was developed by Reid Spencer and is distributed under the
+// University of Illinois Open Source License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file provides the Win32 specific implementation of various Memory
+// management utilities
+//
+//===----------------------------------------------------------------------===//
+
+#include <llvm/System/Process.h>
+#include "windows.h"
+
+namespace llvm {
+using namespace sys;
+
+//===----------------------------------------------------------------------===//
+//=== WARNING: Implementation here must contain only Win32 specific code.
+//===----------------------------------------------------------------------===//
+
+void* Memory::AllocateRWX(Memory&M, unsigned NumBytes) {
+ if (NumBytes == 0) return 0;
+
+ unsigned pageSize = Process::GetPageSize();
+ unsigned NumPages = (NumBytes+pageSize-1)/pageSize;
+ void *P = VirtualAlloc(0, NumPages*pageSize, MEM_COMMIT,
+ PAGE_EXECUTE_READWRITE);
+ if (P == 0) {
+ throw std::string("Couldn't allocate ") + utostr(NumBytes) +
+ " bytes of executable memory!";
+ }
+ M.Address = P;
+ M.AllocSize = NumBytes;
+ return P;
+}
+
+void Memory::ReleaseRWX(Memory& M) {
+ if (M.Address == 0 ) return;
+ VirtualFree(M.Address, M.AllocSize, MEM_DECOMMIT, PAGE_NOACCESS);
+}
--- /dev/null
+//===- Win32/Memory.cpp - Win32 Memory Implementation -----------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file was developed by Reid Spencer and is distributed under the
+// University of Illinois Open Source License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file provides the Win32 specific implementation of various Memory
+// management utilities
+//
+//===----------------------------------------------------------------------===//
+
+#include <llvm/System/Process.h>
+#include "windows.h"
+
+namespace llvm {
+using namespace sys;
+
+//===----------------------------------------------------------------------===//
+//=== WARNING: Implementation here must contain only Win32 specific code.
+//===----------------------------------------------------------------------===//
+
+void* Memory::AllocateRWX(Memory&M, unsigned NumBytes) {
+ if (NumBytes == 0) return 0;
+
+ unsigned pageSize = Process::GetPageSize();
+ unsigned NumPages = (NumBytes+pageSize-1)/pageSize;
+ void *P = VirtualAlloc(0, NumPages*pageSize, MEM_COMMIT,
+ PAGE_EXECUTE_READWRITE);
+ if (P == 0) {
+ throw std::string("Couldn't allocate ") + utostr(NumBytes) +
+ " bytes of executable memory!";
+ }
+ M.Address = P;
+ M.AllocSize = NumBytes;
+ return P;
+}
+
+void Memory::ReleaseRWX(Memory& M) {
+ if (M.Address == 0 ) return;
+ VirtualFree(M.Address, M.AllocSize, MEM_DECOMMIT, PAGE_NOACCESS);
+}
--- /dev/null
+//===- Win32/Path.cpp - Win32 Path Implementation ---------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file was developed by Reid Spencer and is distributed under the
+// University of Illinois Open Source License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file provides the Win32 specific implementation of the Path class.
+//
+//===----------------------------------------------------------------------===//
+
+//===----------------------------------------------------------------------===//
+//=== WARNING: Implementation here must contain only Win32 specific code
+//=== and must not be generic UNIX code (see ../Unix/Path.cpp)
+//===----------------------------------------------------------------------===//
+
+// Include the generic Unix implementation
+#include "../Unix/Path.cpp"
+
+namespace llvm {
+using namespace sys;
+
+
+std::string
+Path::GetDLLSuffix() {
+ return "dll";
+}
+
+}
+
+// vim: sw=2 smartindent smarttab tw=80 autoindent expandtab
--- /dev/null
+//===- Win32/Path.cpp - Win32 Path Implementation ---------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file was developed by Reid Spencer and is distributed under the
+// University of Illinois Open Source License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file provides the Win32 specific implementation of the Path class.
+//
+//===----------------------------------------------------------------------===//
+
+//===----------------------------------------------------------------------===//
+//=== WARNING: Implementation here must contain only Win32 specific code
+//=== and must not be generic UNIX code (see ../Unix/Path.cpp)
+//===----------------------------------------------------------------------===//
+
+// Include the generic Unix implementation
+#include "../Unix/Path.cpp"
+
+namespace llvm {
+using namespace sys;
+
+
+std::string
+Path::GetDLLSuffix() {
+ return "dll";
+}
+
+}
+
+// vim: sw=2 smartindent smarttab tw=80 autoindent expandtab