[AArch64,ELF] Restrict MOVZ/MOVK to non-PIC large code model (#70178)
[llvm-project.git] / flang / runtime / memory.cpp
blob5ed737905a9cb0be93efa3b7a4be36e933e63eff
1 //===-- runtime/memory.cpp ------------------------------------------------===//
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-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include "flang/Runtime/memory.h"
10 #include "terminator.h"
11 #include <cstdlib>
13 namespace Fortran::runtime {
15 void *AllocateMemoryOrCrash(const Terminator &terminator, std::size_t bytes) {
16 if (void *p{std::malloc(bytes)}) {
17 return p;
19 if (bytes > 0) {
20 terminator.Crash(
21 "Fortran runtime internal error: out of memory, needed %zd bytes",
22 bytes);
24 return nullptr;
27 void FreeMemory(void *p) { std::free(p); }
28 } // namespace Fortran::runtime