brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.5 KiB · f1ba2d0 Raw
53 lines · cpp
1//===- Memory.cpp - Memory Handling Support ---------------------*- C++ -*-===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8//9// This file defines some helpful functions for allocating memory and dealing10// with memory mapped files11//12//===----------------------------------------------------------------------===//13 14#include "llvm/Support/Memory.h"15#include "llvm/Config/llvm-config.h"16 17#ifndef NDEBUG18#include "llvm/Support/raw_ostream.h"19#endif // ifndef NDEBUG20 21// Include the platform-specific parts of this class.22#ifdef LLVM_ON_UNIX23#include "Unix/Memory.inc"24#endif25#ifdef _WIN3226#include "Windows/Memory.inc"27#endif28 29#ifndef NDEBUG30 31namespace llvm {32namespace sys {33 34raw_ostream &operator<<(raw_ostream &OS, const Memory::ProtectionFlags &PF) {35  assert((PF & ~(Memory::MF_READ | Memory::MF_WRITE | Memory::MF_EXEC)) == 0 &&36         "Unrecognized flags");37 38  return OS << (PF & Memory::MF_READ ? 'R' : '-')39            << (PF & Memory::MF_WRITE ? 'W' : '-')40            << (PF & Memory::MF_EXEC ? 'X' : '-');41}42 43raw_ostream &operator<<(raw_ostream &OS, const MemoryBlock &MB) {44  return OS << "[ " << MB.base() << " .. "45            << (void *)((char *)MB.base() + MB.allocatedSize()) << " ] ("46            << MB.allocatedSize() << " bytes)";47}48 49} // end namespace sys50} // end namespace llvm51 52#endif // ifndef NDEBUG53