9#ifndef FORTRAN_RUNTIME_ALLOCATOR_REGISTRY_H_
10#define FORTRAN_RUNTIME_ALLOCATOR_REGISTRY_H_
12#include "flang/Common/api-attrs.h"
13#include "flang/Runtime/allocator-registry-consts.h"
17#define MAX_ALLOCATOR 7
19namespace Fortran::runtime {
21using AllocFct =
void *(*)(std::size_t);
22using FreeFct = void (*)(
void *);
25 AllocFct alloc{
nullptr};
26 FreeFct free{
nullptr};
29#ifdef RT_DEVICE_COMPILATION
30static RT_API_ATTRS
void *MallocWrapper(std::size_t size) {
31 return std::malloc(size);
33static RT_API_ATTRS
void FreeWrapper(
void *p) {
return std::free(p); }
37#ifdef RT_DEVICE_COMPILATION
39 : allocators{{&MallocWrapper, &FreeWrapper}} {}
42 allocators[kDefaultAllocator] = {&std::malloc, &std::free};
46 RT_API_ATTRS AllocFct GetAllocator(
int pos);
47 RT_API_ATTRS FreeFct GetDeallocator(
int pos);
52RT_OFFLOAD_VAR_GROUP_BEGIN
54RT_OFFLOAD_VAR_GROUP_END
Definition: allocator-registry.h:36
Definition: allocator-registry.h:24