1 //===- Memory.cpp - Memory Handling Support ---------------------*- C++ -*-===//
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-exception
7 //===----------------------------------------------------------------------===//
9 // This file defines some helpful functions for allocating memory and dealing
10 // with memory mapped files
12 //===----------------------------------------------------------------------===//
14 #include "llvm/Support/Memory.h"
15 #include "llvm/Config/llvm-config.h"
16 #include "llvm/Support/Valgrind.h"
19 #include "llvm/Support/raw_ostream.h"
20 #endif // ifndef NDEBUG
22 // Include the platform-specific parts of this class.
24 #include "Unix/Memory.inc"
27 #include "Windows/Memory.inc"
35 raw_ostream
&operator<<(raw_ostream
&OS
, const Memory::ProtectionFlags
&PF
) {
36 assert((PF
& ~(Memory::MF_READ
| Memory::MF_WRITE
| Memory::MF_EXEC
)) == 0 &&
37 "Unrecognized flags");
39 return OS
<< (PF
& Memory::MF_READ
? 'R' : '-')
40 << (PF
& Memory::MF_WRITE
? 'W' : '-')
41 << (PF
& Memory::MF_EXEC
? 'X' : '-');
44 raw_ostream
&operator<<(raw_ostream
&OS
, const MemoryBlock
&MB
) {
45 return OS
<< "[ " << MB
.base() << " .. "
46 << (void *)((char *)MB
.base() + MB
.allocatedSize()) << " ] ("
47 << MB
.allocatedSize() << " bytes)";
50 } // end namespace sys
51 } // end namespace llvm
53 #endif // ifndef NDEBUG