2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2019-01-14 17:55:22 +08:00
|
|
|
* Copyright (C) 2017-2019 Intel Corporation
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
2019-01-14 17:55:22 +08:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
#include "runtime/utilities/heap_allocator.h"
|
2019-02-27 18:39:32 +08:00
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
#include <memory>
|
2019-02-27 18:39:32 +08:00
|
|
|
#include <stdint.h>
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
namespace NEO {
|
2017-12-21 07:45:38 +08:00
|
|
|
const uintptr_t max32BitAddress = 0xffffffff;
|
|
|
|
extern bool is32BitOsAllocatorAvailable;
|
|
|
|
class Allocator32bit {
|
|
|
|
protected:
|
|
|
|
class OsInternals;
|
|
|
|
|
|
|
|
public:
|
|
|
|
Allocator32bit(uint64_t base, uint64_t size);
|
|
|
|
Allocator32bit(Allocator32bit::OsInternals *osInternals);
|
|
|
|
Allocator32bit();
|
2019-01-14 17:55:22 +08:00
|
|
|
MOCKABLE_VIRTUAL ~Allocator32bit();
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-03-27 22:43:47 +08:00
|
|
|
uint64_t allocate(size_t &size);
|
2019-01-14 17:55:22 +08:00
|
|
|
uintptr_t getBase() const;
|
2018-03-27 22:43:47 +08:00
|
|
|
int free(uint64_t ptr, size_t size);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
protected:
|
|
|
|
std::unique_ptr<OsInternals> osInternals;
|
|
|
|
std::unique_ptr<HeapAllocator> heapAllocator;
|
|
|
|
uint64_t base = 0;
|
|
|
|
uint64_t size = 0;
|
|
|
|
};
|
2019-03-26 18:59:46 +08:00
|
|
|
} // namespace NEO
|