1 //===-- mem_map_linux.h -----------------------------------------*- 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 #ifndef SCUDO_MEM_MAP_LINUX_H_
10 #define SCUDO_MEM_MAP_LINUX_H_
17 #include "mem_map_base.h"
21 class MemMapLinux final
: public MemMapBase
<MemMapLinux
> {
23 constexpr MemMapLinux() = default;
24 MemMapLinux(uptr Base
, uptr Capacity
)
25 : MapBase(Base
), MapCapacity(Capacity
) {}
27 // Impls for base functions.
28 bool mapImpl(uptr Addr
, uptr Size
, const char *Name
, uptr Flags
= 0);
29 void unmapImpl(uptr Addr
, uptr Size
);
30 bool remapImpl(uptr Addr
, uptr Size
, const char *Name
, uptr Flags
= 0);
31 void setMemoryPermissionImpl(uptr Addr
, uptr Size
, uptr Flags
);
32 void releasePagesToOSImpl(uptr From
, uptr Size
) {
33 return releaseAndZeroPagesToOSImpl(From
, Size
);
35 void releaseAndZeroPagesToOSImpl(uptr From
, uptr Size
);
36 uptr
getBaseImpl() { return MapBase
; }
37 uptr
getCapacityImpl() { return MapCapacity
; }
44 // This will be deprecated when every allocator has been supported by each
45 // platform's `MemMap` implementation.
46 class ReservedMemoryLinux final
47 : public ReservedMemory
<ReservedMemoryLinux
, MemMapLinux
> {
49 // The following two are the Impls for function in `MemMapBase`.
50 uptr
getBaseImpl() { return MapBase
; }
51 uptr
getCapacityImpl() { return MapCapacity
; }
53 // These threes are specific to `ReservedMemory`.
54 bool createImpl(uptr Addr
, uptr Size
, const char *Name
, uptr Flags
);
56 MemMapT
dispatchImpl(uptr Addr
, uptr Size
);
67 #endif // SCUDO_MEM_MAP_LINUX_H_