[flang-commits] [flang] [llvm] [Flang][OpenMP][Runtime] Minor Flang runtime for OpenMP AMDGPU (PR #152631)
via flang-commits
flang-commits at lists.llvm.org
Thu Aug 14 08:01:06 PDT 2025
https://github.com/agozillon updated https://github.com/llvm/llvm-project/pull/152631
>From f37aaed531dd6ab2b324781831a746b67865f288 Mon Sep 17 00:00:00 2001
From: agozillon <Andrew.Gozillon at amd.com>
Date: Thu, 7 Aug 2025 12:20:30 -0500
Subject: [PATCH 1/6] [Flang][OpenMP] Minor Flang runtime for OpenMP AMDGPU
We have some modifications downstream to compile the flang runtime for amdgpu using clang OpenMP, some more
hacky than others to workaround (hopefully temporary) compiler issues. The additions here are the non-hacky
alterations.
Main changes:
* Create freestanding versions of memcpy, strlen and memmove, and replace std:: references with
these so that we can default to std:: when it's available, or our own Flang implementation when
it's not.
* Wrap more bits and pieces of the library in declare target wrappers (RT_* macros).
* Fix some warnings that'll pose issues with werror on, in this case having the namespace infront
of variables passed to templates.
Another minor issues that'll likely still pop up depending on the program you're linking with is that abort will be
undefined, it is perhaps possible to solve it with a freestanding implementation as with memcpy etc. but we end up
with multiple definitions in this case. An alternative is to create an empty extern "c" version (which can be empty
or forwrd on to the builtin).
Co-author: Dan Palermo Dan.Palermo at amd.com
---
flang-rt/include/flang-rt/runtime/buffer.h | 4 +-
.../include/flang-rt/runtime/descriptor.h | 2 +
.../flang-rt/runtime/format-implementation.h | 3 +-
flang-rt/include/flang-rt/runtime/tools.h | 5 +-
.../include/flang-rt/runtime/work-queue.h | 14 +--
flang-rt/lib/runtime/array-constructor.cpp | 3 +-
flang-rt/lib/runtime/assign.cpp | 6 +-
flang-rt/lib/runtime/character.cpp | 11 +--
flang-rt/lib/runtime/command.cpp | 2 +-
flang-rt/lib/runtime/copy.cpp | 5 +-
flang-rt/lib/runtime/derived.cpp | 8 +-
flang-rt/lib/runtime/descriptor-io.cpp | 2 +-
flang-rt/lib/runtime/descriptor.cpp | 3 +-
flang-rt/lib/runtime/edit-input.cpp | 14 +--
flang-rt/lib/runtime/extensions.cpp | 12 +--
flang-rt/lib/runtime/external-unit.cpp | 6 +-
flang-rt/lib/runtime/extrema.cpp | 6 +-
flang-rt/lib/runtime/internal-unit.cpp | 2 +-
flang-rt/lib/runtime/io-api-minimal.cpp | 2 +-
flang-rt/lib/runtime/io-error.cpp | 2 +-
flang-rt/lib/runtime/matmul-transpose.cpp | 4 +-
flang-rt/lib/runtime/matmul.cpp | 6 +-
flang-rt/lib/runtime/misc-intrinsic.cpp | 4 +-
flang-rt/lib/runtime/pseudo-unit.cpp | 2 +-
flang-rt/lib/runtime/ragged.cpp | 2 +-
flang-rt/lib/runtime/reduce.cpp | 6 +-
flang-rt/lib/runtime/stat.cpp | 7 +-
flang-rt/lib/runtime/temporary-stack.cpp | 2 +-
flang-rt/lib/runtime/time-intrinsic.cpp | 12 +--
flang-rt/lib/runtime/tools.cpp | 28 +++---
flang-rt/lib/runtime/transformational.cpp | 2 +-
flang-rt/lib/runtime/unit-map.cpp | 2 +-
flang-rt/lib/runtime/unit.cpp | 13 +--
flang-rt/lib/runtime/work-queue.cpp | 8 +-
flang/include/flang/Common/constexpr-bitset.h | 3 +-
.../flang/Decimal/binary-floating-point.h | 5 +-
.../flang/Runtime/allocator-registry-consts.h | 4 +
.../flang/Runtime/freestanding-tools.h | 85 ++++++++++++++++++-
flang/include/flang/Runtime/stop.h | 2 +
39 files changed, 205 insertions(+), 104 deletions(-)
diff --git a/flang-rt/include/flang-rt/runtime/buffer.h b/flang-rt/include/flang-rt/runtime/buffer.h
index b5a9ce9e35e91..2791ac3ce728a 100644
--- a/flang-rt/include/flang-rt/runtime/buffer.h
+++ b/flang-rt/include/flang-rt/runtime/buffer.h
@@ -158,8 +158,8 @@ template <typename STORE, std::size_t minBuffer = 65536> class FileFrame {
// Avoid passing a null pointer, since it would result in an undefined
// behavior.
if (old != nullptr) {
- std::memcpy(buffer_, old + start_, chunk);
- std::memcpy(buffer_ + chunk, old, length_ - chunk);
+ Fortran::runtime::memcpy(buffer_, old + start_, chunk);
+ Fortran::runtime::memcpy(buffer_ + chunk, old, length_ - chunk);
FreeMemory(old);
}
start_ = 0;
diff --git a/flang-rt/include/flang-rt/runtime/descriptor.h b/flang-rt/include/flang-rt/runtime/descriptor.h
index e440690e40286..4c65abce782d3 100644
--- a/flang-rt/include/flang-rt/runtime/descriptor.h
+++ b/flang-rt/include/flang-rt/runtime/descriptor.h
@@ -32,8 +32,10 @@
#include <cstdlib>
#include <cstring>
+RT_OFFLOAD_VAR_GROUP_BEGIN
/// Value used for asyncObject when no specific stream is specified.
static constexpr std::int64_t *kNoAsyncObject = nullptr;
+RT_OFFLOAD_VAR_GROUP_END
namespace Fortran::runtime {
diff --git a/flang-rt/include/flang-rt/runtime/format-implementation.h b/flang-rt/include/flang-rt/runtime/format-implementation.h
index 85dc922bc31bc..0d0972313b87a 100644
--- a/flang-rt/include/flang-rt/runtime/format-implementation.h
+++ b/flang-rt/include/flang-rt/runtime/format-implementation.h
@@ -49,7 +49,8 @@ RT_API_ATTRS FormatControl<CONTEXT>::FormatControl(const Terminator &terminator,
SubscriptValue at[maxRank];
formatDescriptor->GetLowerBounds(at);
for (std::size_t j{0}; j < elements; ++j) {
- std::memcpy(p, formatDescriptor->Element<char>(at), elementBytes);
+ Fortran::runtime::memcpy(
+ p, formatDescriptor->Element<char>(at), elementBytes);
p += elementBytes;
formatDescriptor->IncrementSubscripts(at);
}
diff --git a/flang-rt/include/flang-rt/runtime/tools.h b/flang-rt/include/flang-rt/runtime/tools.h
index a1b96f41f4936..1697c9416bed4 100644
--- a/flang-rt/include/flang-rt/runtime/tools.h
+++ b/flang-rt/include/flang-rt/runtime/tools.h
@@ -559,9 +559,10 @@ RT_API_ATTRS void CopyAndPad(
to[j] = static_cast<TO>(' ');
}
} else if (toChars <= fromChars) {
- std::memcpy(to, from, toChars * sizeof(TO));
+ Fortran::runtime::memcpy(to, from, toChars * sizeof(TO));
} else {
- std::memcpy(to, from, std::min(toChars, fromChars) * sizeof(TO));
+ Fortran::runtime::memcpy(
+ to, from, std::min(toChars, fromChars) * sizeof(TO));
for (std::size_t j{fromChars}; j < toChars; ++j) {
to[j] = static_cast<TO>(' ');
}
diff --git a/flang-rt/include/flang-rt/runtime/work-queue.h b/flang-rt/include/flang-rt/runtime/work-queue.h
index 7d7f8ad991a57..d1ea036a8fc0a 100644
--- a/flang-rt/include/flang-rt/runtime/work-queue.h
+++ b/flang-rt/include/flang-rt/runtime/work-queue.h
@@ -127,8 +127,8 @@ class Elementwise {
const Descriptor &instance_, *from_{nullptr};
std::size_t elements_{instance_.InlineElements()};
std::size_t elementAt_{0};
- SubscriptValue subscripts_[common::maxRank];
- SubscriptValue fromSubscripts_[common::maxRank];
+ SubscriptValue subscripts_[maxRank];
+ SubscriptValue fromSubscripts_[maxRank];
};
// Base class for ticket workers that operate over derived type components.
@@ -162,7 +162,7 @@ class Componentwise {
const typeInfo::DerivedType &derived_;
std::size_t components_{0}, componentAt_{0};
const typeInfo::Component *component_{nullptr};
- StaticDescriptor<common::maxRank, true, 0> componentDescriptor_;
+ StaticDescriptor<maxRank, true, 0> componentDescriptor_;
private:
RT_API_ATTRS void GetFirstComponent() {
@@ -275,7 +275,7 @@ class InitializeCloneTicket
const Descriptor &clone_;
bool hasStat_{false};
const Descriptor *errMsg_{nullptr};
- StaticDescriptor<common::maxRank, true, 0> cloneComponentDescriptor_;
+ StaticDescriptor<maxRank, true, 0> cloneComponentDescriptor_;
};
// Implements derived type instance finalization
@@ -331,7 +331,7 @@ class AssignTicket : public ImmediateTicketRunner<AssignTicket> {
const Descriptor *from_{nullptr};
int flags_{0}; // enum AssignFlags
MemmoveFct memmoveFct_{nullptr};
- StaticDescriptor<common::maxRank, true, 0> tempDescriptor_;
+ StaticDescriptor<maxRank, true, 0> tempDescriptor_;
const typeInfo::DerivedType *declaredType_{nullptr};
const typeInfo::DerivedType *toDerived_{nullptr};
Descriptor *toDeallocate_{nullptr};
@@ -364,7 +364,7 @@ class DerivedAssignTicket
int flags_{0};
MemmoveFct memmoveFct_{nullptr};
Descriptor *deallocateAfter_{nullptr};
- StaticDescriptor<common::maxRank, true, 0> fromComponentDescriptor_;
+ StaticDescriptor<maxRank, true, 0> fromComponentDescriptor_;
};
namespace io::descr {
@@ -392,7 +392,7 @@ class DescriptorIoTicket
common::optional<typeInfo::SpecialBinding> nonTbpSpecial_;
const typeInfo::DerivedType *derived_{nullptr};
const typeInfo::SpecialBinding *special_{nullptr};
- StaticDescriptor<common::maxRank, true, 0> elementDescriptor_;
+ StaticDescriptor<maxRank, true, 0> elementDescriptor_;
};
template <io::Direction DIR>
diff --git a/flang-rt/lib/runtime/array-constructor.cpp b/flang-rt/lib/runtime/array-constructor.cpp
index 858fac7bf2b39..a83e66cb678e4 100644
--- a/flang-rt/lib/runtime/array-constructor.cpp
+++ b/flang-rt/lib/runtime/array-constructor.cpp
@@ -173,7 +173,8 @@ void RTDEF(PushArrayConstructorSimpleScalar)(
AllocateOrReallocateVectorIfNeeded(vector, terminator, to.Elements(), 1);
SubscriptValue subscript[1]{
to.GetDimension(0).LowerBound() + vector.nextValuePosition};
- std::memcpy(to.Element<char>(subscript), from, to.ElementBytes());
+ Fortran::runtime::memcpy(
+ to.Element<char>(subscript), from, to.ElementBytes());
++vector.nextValuePosition;
}
diff --git a/flang-rt/lib/runtime/assign.cpp b/flang-rt/lib/runtime/assign.cpp
index 6aeb103208785..9c1aa365ed838 100644
--- a/flang-rt/lib/runtime/assign.cpp
+++ b/flang-rt/lib/runtime/assign.cpp
@@ -15,6 +15,7 @@
#include "flang-rt/runtime/tools.h"
#include "flang-rt/runtime/type-info.h"
#include "flang-rt/runtime/work-queue.h"
+#include "flang/Runtime/stop.h"
namespace Fortran::runtime {
@@ -279,7 +280,7 @@ RT_API_ATTRS int AssignTicket::Begin(WorkQueue &workQueue) {
if (mustDeallocateLHS) {
// Convert the LHS into a temporary, then make it look deallocated.
toDeallocate_ = &tempDescriptor_.descriptor();
- std::memcpy(
+ Fortran::runtime::memcpy(
reinterpret_cast<void *>(toDeallocate_), &to_, to_.SizeInBytes());
to_.set_base_addr(nullptr);
if (toDerived_ && (flags_ & NeedFinalization)) {
@@ -298,7 +299,8 @@ RT_API_ATTRS int AssignTicket::Begin(WorkQueue &workQueue) {
auto descBytes{from_->SizeInBytes()};
Descriptor &newFrom{tempDescriptor_.descriptor()};
persist_ = true; // tempDescriptor_ state must outlive child tickets
- std::memcpy(reinterpret_cast<void *>(&newFrom), from_, descBytes);
+ Fortran::runtime::memcpy(
+ reinterpret_cast<void *>(&newFrom), from_, descBytes);
// Pretend the temporary descriptor is for an ALLOCATABLE
// entity, otherwise, the Deallocate() below will not
// free the descriptor memory.
diff --git a/flang-rt/lib/runtime/character.cpp b/flang-rt/lib/runtime/character.cpp
index f140d202e118e..1c889293881cd 100644
--- a/flang-rt/lib/runtime/character.cpp
+++ b/flang-rt/lib/runtime/character.cpp
@@ -616,8 +616,9 @@ void RTDEF(CharacterConcatenate)(Descriptor &accumulator,
from.GetLowerBounds(fromAt);
for (; elements-- > 0;
to += newBytes, p += oldBytes, from.IncrementSubscripts(fromAt)) {
- std::memcpy(to, p, oldBytes);
- std::memcpy(to + oldBytes, from.Element<char>(fromAt), fromBytes);
+ Fortran::runtime::memcpy(to, p, oldBytes);
+ Fortran::runtime::memcpy(
+ to + oldBytes, from.Element<char>(fromAt), fromBytes);
}
FreeMemory(old);
}
@@ -698,7 +699,7 @@ void RTDEF(CharacterCompare)(
std::size_t RTDEF(CharacterAppend1)(char *lhs, std::size_t lhsBytes,
std::size_t offset, const char *rhs, std::size_t rhsBytes) {
if (auto n{std::min(lhsBytes - offset, rhsBytes)}) {
- std::memcpy(lhs + offset, rhs, n);
+ Fortran::runtime::memcpy(lhs + offset, rhs, n);
offset += n;
}
return offset;
@@ -706,7 +707,7 @@ std::size_t RTDEF(CharacterAppend1)(char *lhs, std::size_t lhsBytes,
void RTDEF(CharacterPad1)(char *lhs, std::size_t bytes, std::size_t offset) {
if (bytes > offset) {
- std::memset(lhs + offset, ' ', bytes - offset);
+ Fortran::runtime::memset(lhs + offset, ' ', bytes - offset);
}
}
@@ -838,7 +839,7 @@ void RTDEF(Repeat)(Descriptor &result, const Descriptor &string,
}
const char *from{string.OffsetElement()};
for (char *to{result.OffsetElement()}; ncopies-- > 0; to += origBytes) {
- std::memcpy(to, from, origBytes);
+ Fortran::runtime::memcpy(to, from, origBytes);
}
}
diff --git a/flang-rt/lib/runtime/command.cpp b/flang-rt/lib/runtime/command.cpp
index a4e8e31ad0274..a60eee3841bd3 100644
--- a/flang-rt/lib/runtime/command.cpp
+++ b/flang-rt/lib/runtime/command.cpp
@@ -58,7 +58,7 @@ static std::int64_t StringLength(const char *string) {
static void FillWithSpaces(const Descriptor &value, std::size_t offset = 0) {
if (offset < value.ElementBytes()) {
- std::memset(
+ Fortran::runtime::memset(
value.OffsetElement(offset), ' ', value.ElementBytes() - offset);
}
}
diff --git a/flang-rt/lib/runtime/copy.cpp b/flang-rt/lib/runtime/copy.cpp
index f990f46e0be66..8ed6c27bcd062 100644
--- a/flang-rt/lib/runtime/copy.cpp
+++ b/flang-rt/lib/runtime/copy.cpp
@@ -10,6 +10,7 @@
#include "stack.h"
#include "flang-rt/runtime/descriptor.h"
#include "flang-rt/runtime/terminator.h"
+#include "flang-rt/runtime/tools.h"
#include "flang-rt/runtime/type-info.h"
#include "flang/Runtime/allocatable.h"
#include <cstring>
@@ -101,7 +102,7 @@ RT_API_ATTRS void CopyElement(const Descriptor &to, const SubscriptValue toAt[],
char *toPtr{to.Element<char>(toAt)};
char *fromPtr{from.Element<char>(fromAt)};
RUNTIME_CHECK(terminator, to.ElementBytes() == from.ElementBytes());
- std::memcpy(toPtr, fromPtr, to.ElementBytes());
+ Fortran::runtime::memcpy(toPtr, fromPtr, to.ElementBytes());
return;
}
@@ -148,7 +149,7 @@ RT_API_ATTRS void CopyElement(const Descriptor &to, const SubscriptValue toAt[],
// Moreover, if we came here from an Component::Genre::Data component,
// all the per-element copies are redundant, because the parent
// has already been copied as a whole.
- std::memcpy(toPtr, fromPtr, curTo.ElementBytes());
+ Fortran::runtime::memcpy(toPtr, fromPtr, curTo.ElementBytes());
--elements;
if (elements != 0) {
currentCopy.IncrementSubscripts(terminator);
diff --git a/flang-rt/lib/runtime/derived.cpp b/flang-rt/lib/runtime/derived.cpp
index 2dddf079f91db..92e1b00810890 100644
--- a/flang-rt/lib/runtime/derived.cpp
+++ b/flang-rt/lib/runtime/derived.cpp
@@ -71,7 +71,7 @@ RT_API_ATTRS int InitializeTicket::Continue(WorkQueue &workQueue) {
// Explicit initialization of data pointers and
// non-allocatable non-automatic components
std::size_t bytes{component_->SizeInBytes(instance_)};
- std::memcpy(rawComponent, init, bytes);
+ Fortran::runtime::memcpy(rawComponent, init, bytes);
} else if (component_->genre() == typeInfo::Component::Genre::Pointer) {
// Data pointers without explicit initialization are established
// so that they are valid right-hand side targets of pointer
@@ -108,20 +108,20 @@ RT_API_ATTRS int InitializeTicket::Continue(WorkQueue &workQueue) {
chunk = done;
}
char *uninitialized{rawInstance + done * *stride};
- std::memcpy(uninitialized, rawInstance, chunk * *stride);
+ Fortran::runtime::memcpy(uninitialized, rawInstance, chunk * *stride);
done += chunk;
}
} else {
for (std::size_t done{1}; done < elements_; ++done) {
char *uninitialized{rawInstance + done * *stride};
- std::memcpy(uninitialized, rawInstance, elementBytes);
+ Fortran::runtime::memcpy(uninitialized, rawInstance, elementBytes);
}
}
} else { // one at a time with subscription
for (Elementwise::Advance(); !Elementwise::IsComplete();
Elementwise::Advance()) {
char *element{instance_.Element<char>(subscripts_)};
- std::memcpy(element, rawInstance, elementBytes);
+ Fortran::runtime::memcpy(element, rawInstance, elementBytes);
}
}
}
diff --git a/flang-rt/lib/runtime/descriptor-io.cpp b/flang-rt/lib/runtime/descriptor-io.cpp
index a60d0b90da467..bb5e46bf2c2a0 100644
--- a/flang-rt/lib/runtime/descriptor-io.cpp
+++ b/flang-rt/lib/runtime/descriptor-io.cpp
@@ -65,7 +65,7 @@ static RT_API_ATTRS Fortran::common::optional<bool> DefinedFormattedIo(
if (edit.descriptor == DataEdit::DefinedDerivedType) {
ioType[0] = 'D';
ioType[1] = 'T';
- std::memcpy(ioType + 2, edit.ioType, edit.ioTypeChars);
+ Fortran::runtime::memcpy(ioType + 2, edit.ioType, edit.ioTypeChars);
} else {
runtime::strcpy(
ioType, io.mutableModes().inNamelist ? "NAMELIST" : "LISTDIRECTED");
diff --git a/flang-rt/lib/runtime/descriptor.cpp b/flang-rt/lib/runtime/descriptor.cpp
index 882870a570428..d7d8692cc7e94 100644
--- a/flang-rt/lib/runtime/descriptor.cpp
+++ b/flang-rt/lib/runtime/descriptor.cpp
@@ -15,6 +15,7 @@
#include "flang-rt/runtime/terminator.h"
#include "flang-rt/runtime/type-info.h"
#include "flang/Common/type-kinds.h"
+#include "flang/Runtime/freestanding-tools.h"
#include <cassert>
#include <cstdlib>
#include <cstring>
@@ -26,7 +27,7 @@ RT_OFFLOAD_API_GROUP_BEGIN
RT_API_ATTRS Descriptor::Descriptor(const Descriptor &that) { *this = that; }
RT_API_ATTRS Descriptor &Descriptor::operator=(const Descriptor &that) {
- std::memcpy(reinterpret_cast<void *>(this), &that, that.SizeInBytes());
+ Fortran::runtime::memcpy(this, &that, that.SizeInBytes());
return *this;
}
diff --git a/flang-rt/lib/runtime/edit-input.cpp b/flang-rt/lib/runtime/edit-input.cpp
index 4f01623c6cf19..f557e3e530735 100644
--- a/flang-rt/lib/runtime/edit-input.cpp
+++ b/flang-rt/lib/runtime/edit-input.cpp
@@ -110,7 +110,7 @@ static RT_API_ATTRS bool EditBOZInput(
io.HandleAbsolutePosition(start);
remaining.reset();
// Make a second pass now that the digit count is known
- std::memset(n, 0, bytes);
+ Fortran::runtime::memset(n, 0, bytes);
int increment{isHostLittleEndian ? -1 : 1};
auto *data{reinterpret_cast<unsigned char *>(n) +
(isHostLittleEndian ? significantBytes - 1 : bytes - significantBytes)};
@@ -283,18 +283,18 @@ RT_API_ATTRS bool EditIntegerInput(IoStatementState &io, const DataEdit &edit,
auto shft{static_cast<int>(sizeof value - kind)};
if (!isHostLittleEndian && shft >= 0) {
auto shifted{value << (8 * shft)};
- std::memcpy(n, &shifted, kind);
+ Fortran::runtime::memcpy(n, &shifted, kind);
} else {
- std::memcpy(n, &value, kind); // a blank field means zero
+ Fortran::runtime::memcpy(n, &value, kind); // a blank field means zero
}
#else
auto shft{static_cast<int>(sizeof(value.low())) - kind};
// For kind==8 (i.e. shft==0), the value is stored in low_ in big endian.
if (!isHostLittleEndian && shft >= 0) {
auto l{value.low() << (8 * shft)};
- std::memcpy(n, &l, kind);
+ Fortran::runtime::memcpy(n, &l, kind);
} else {
- std::memcpy(n, &value, kind); // a blank field means zero
+ Fortran::runtime::memcpy(n, &value, kind); // a blank field means zero
}
#endif
io.GotChar(fastField.got());
@@ -1120,7 +1120,7 @@ RT_API_ATTRS bool EditCharacterInput(IoStatementState &io, const DataEdit &edit,
--skipChars;
} else {
char32_t buffer{0};
- std::memcpy(&buffer, input, chunkBytes);
+ Fortran::runtime::memcpy(&buffer, input, chunkBytes);
if ((sizeof *x == 1 && buffer > 0xff) ||
(sizeof *x == 2 && buffer > 0xffff)) {
*x++ = '?';
@@ -1147,7 +1147,7 @@ RT_API_ATTRS bool EditCharacterInput(IoStatementState &io, const DataEdit &edit,
chunkBytes = std::min<std::size_t>(remainingChars, readyBytes);
chunkBytes = std::min<std::size_t>(lengthChars, chunkBytes);
chunkChars = chunkBytes;
- std::memcpy(x, input, chunkBytes);
+ Fortran::runtime::memcpy(x, input, chunkBytes);
x += chunkBytes;
lengthChars -= chunkChars;
}
diff --git a/flang-rt/lib/runtime/extensions.cpp b/flang-rt/lib/runtime/extensions.cpp
index a24810b4f344a..91ce2f5ae9522 100644
--- a/flang-rt/lib/runtime/extensions.cpp
+++ b/flang-rt/lib/runtime/extensions.cpp
@@ -147,8 +147,8 @@ uid_t RTNAME(GetUID)() {
}
void GetUsernameEnvVar(const char *envName, char *arg, std::int64_t length) {
- Descriptor name{*Descriptor::Create(
- 1, std::strlen(envName) + 1, const_cast<char *>(envName), 0)};
+ Descriptor name{*Descriptor::Create(1, Fortran::runtime::strlen(envName) + 1,
+ const_cast<char *>(envName), 0)};
Descriptor value{*Descriptor::Create(1, length, arg, 0)};
RTNAME(GetEnvVariable)
@@ -172,7 +172,7 @@ void FORTRAN_PROCEDURE_NAME(fdate)(char *arg, std::int64_t length) {
char str[26];
// Insufficient space, fill with spaces and return.
if (length < 24) {
- std::memset(arg, ' ', length);
+ Fortran::runtime::memset(arg, ' ', length);
return;
}
@@ -204,8 +204,8 @@ void FORTRAN_PROCEDURE_NAME(getarg)(
void FORTRAN_PROCEDURE_NAME(getlog)(char *arg, std::int64_t length) {
#if _REENTRANT || _POSIX_C_SOURCE >= 199506L
if (length >= 1 && getlogin_r(arg, length) == 0) {
- auto loginLen{std::strlen(arg)};
- std::memset(
+ auto loginLen{Fortran::runtime::strlen(arg)};
+ Fortran::runtime::memset(
arg + loginLen, ' ', static_cast<std::size_t>(length) - loginLen);
return;
}
@@ -259,7 +259,7 @@ std::int64_t FORTRAN_PROCEDURE_NAME(access)(const char *name,
char *newName{nullptr};
if (name[nameLength - 1] != '\0') {
newName = static_cast<char *>(std::malloc(nameLength + 1));
- std::memcpy(newName, name, nameLength);
+ Fortran::runtime::memcpy(newName, name, nameLength);
newName[nameLength] = '\0';
name = newName;
}
diff --git a/flang-rt/lib/runtime/external-unit.cpp b/flang-rt/lib/runtime/external-unit.cpp
index b8004d6315994..df07c2b72d8d4 100644
--- a/flang-rt/lib/runtime/external-unit.cpp
+++ b/flang-rt/lib/runtime/external-unit.cpp
@@ -122,7 +122,7 @@ bool ExternalFileUnit::OpenUnit(Fortran::common::optional<OpenStatus> status,
bool impliedClose{false};
if (IsConnected()) {
bool isSamePath{newPath.get() && path() && pathLength() == newPathLength &&
- std::memcmp(path(), newPath.get(), newPathLength) == 0};
+ Fortran::runtime::memcmp(path(), newPath.get(), newPathLength) == 0};
if (status && *status != OpenStatus::Old && isSamePath) {
handler.SignalError("OPEN statement for connected unit may not have "
"explicit STATUS= other than 'OLD'");
@@ -202,8 +202,8 @@ bool ExternalFileUnit::OpenAnonymousUnit(
std::size_t pathMaxLen{32};
auto path{SizedNew<char>{handler}(pathMaxLen)};
std::snprintf(path.get(), pathMaxLen, "fort.%d", unitNumber_);
- OpenUnit(status, action, position, std::move(path), std::strlen(path.get()),
- convert, handler);
+ OpenUnit(status, action, position, std::move(path),
+ Fortran::runtime::strlen(path.get()), convert, handler);
return IsConnected();
}
diff --git a/flang-rt/lib/runtime/extrema.cpp b/flang-rt/lib/runtime/extrema.cpp
index 03e574a8fbff1..35db72a5a2f66 100644
--- a/flang-rt/lib/runtime/extrema.cpp
+++ b/flang-rt/lib/runtime/extrema.cpp
@@ -428,7 +428,7 @@ inline RT_API_ATTRS void TypedPartialMaxOrMinLoc(const char *intrinsic,
CreatePartialReductionResult(result, x,
Descriptor::BytesFor(TypeCategory::Integer, kind), dim, terminator,
intrinsic, TypeCode{TypeCategory::Integer, kind});
- std::memset(
+ Fortran::runtime::memset(
result.OffsetElement(), 0, result.Elements() * result.ElementBytes());
return;
}
@@ -584,11 +584,11 @@ template <int KIND, bool IS_MAXVAL> class CharacterExtremumAccumulator {
static_assert(std::is_same_v<A, Type>);
std::size_t byteSize{array_.ElementBytes()};
if (extremum_) {
- std::memcpy(p, extremum_, byteSize);
+ Fortran::runtime::memcpy(p, extremum_, byteSize);
} else {
// Empty array; fill with character 0 for MAXVAL.
// For MINVAL, set all of the bits.
- std::memset(p, IS_MAXVAL ? 0 : 255, byteSize);
+ Fortran::runtime::memset(p, IS_MAXVAL ? 0 : 255, byteSize);
}
}
RT_API_ATTRS bool Accumulate(const Type *x) {
diff --git a/flang-rt/lib/runtime/internal-unit.cpp b/flang-rt/lib/runtime/internal-unit.cpp
index e344b01e8b34e..1258e814c2285 100644
--- a/flang-rt/lib/runtime/internal-unit.cpp
+++ b/flang-rt/lib/runtime/internal-unit.cpp
@@ -72,7 +72,7 @@ RT_API_ATTRS bool InternalDescriptorUnit<DIR>::Emit(
BlankFill(record + furthestPositionInRecord,
positionInRecord - furthestPositionInRecord);
}
- std::memcpy(record + positionInRecord, data, bytes);
+ Fortran::runtime::memcpy(record + positionInRecord, data, bytes);
positionInRecord += bytes;
furthestPositionInRecord = furthestAfter;
return ok;
diff --git a/flang-rt/lib/runtime/io-api-minimal.cpp b/flang-rt/lib/runtime/io-api-minimal.cpp
index fdf7183ed5176..c3c7e40529928 100644
--- a/flang-rt/lib/runtime/io-api-minimal.cpp
+++ b/flang-rt/lib/runtime/io-api-minimal.cpp
@@ -161,4 +161,4 @@ void std::__libcpp_verbose_abort(char const *format, ...) noexcept(
}
#endif
-RT_EXT_API_GROUP_END
+RT_EXT_API_GROUP_END
\ No newline at end of file
diff --git a/flang-rt/lib/runtime/io-error.cpp b/flang-rt/lib/runtime/io-error.cpp
index b350fb66fc25b..1a49a4f077f97 100644
--- a/flang-rt/lib/runtime/io-error.cpp
+++ b/flang-rt/lib/runtime/io-error.cpp
@@ -153,7 +153,7 @@ bool IoErrorHandler::GetIoMsg(char *buffer, std::size_t bufferLength) {
} else if (ok) {
std::size_t copied{Fortran::runtime::strlen(buffer)};
if (copied < bufferLength) {
- std::memset(buffer + copied, ' ', bufferLength - copied);
+ Fortran::runtime::memset(buffer + copied, ' ', bufferLength - copied);
}
return true;
} else {
diff --git a/flang-rt/lib/runtime/matmul-transpose.cpp b/flang-rt/lib/runtime/matmul-transpose.cpp
index c9e21502b629e..789f13c585ec5 100644
--- a/flang-rt/lib/runtime/matmul-transpose.cpp
+++ b/flang-rt/lib/runtime/matmul-transpose.cpp
@@ -62,7 +62,7 @@ inline static RT_API_ATTRS void MatrixTransposedTimesMatrix(
std::size_t yColumnByteStride = 0) {
using ResultType = CppTypeFor<RCAT, RKIND>;
- std::memset(product, 0, rows * cols * sizeof *product);
+ Fortran::runtime::memset(product, 0, rows * cols * sizeof *product);
for (SubscriptValue j{0}; j < cols; ++j) {
for (SubscriptValue i{0}; i < rows; ++i) {
for (SubscriptValue k{0}; k < n; ++k) {
@@ -132,7 +132,7 @@ inline static RT_API_ATTRS void MatrixTransposedTimesVector(
SubscriptValue n, const XT *RESTRICT x, const YT *RESTRICT y,
std::size_t xColumnByteStride = 0) {
using ResultType = CppTypeFor<RCAT, RKIND>;
- std::memset(product, 0, rows * sizeof *product);
+ Fortran::runtime::memset(product, 0, rows * sizeof *product);
for (SubscriptValue i{0}; i < rows; ++i) {
for (SubscriptValue k{0}; k < n; ++k) {
ResultType x_ki;
diff --git a/flang-rt/lib/runtime/matmul.cpp b/flang-rt/lib/runtime/matmul.cpp
index 5acb345725212..d409cb1458c90 100644
--- a/flang-rt/lib/runtime/matmul.cpp
+++ b/flang-rt/lib/runtime/matmul.cpp
@@ -81,7 +81,7 @@ inline RT_API_ATTRS void MatrixTimesMatrix(
SubscriptValue n, std::size_t xColumnByteStride = 0,
std::size_t yColumnByteStride = 0) {
using ResultType = CppTypeFor<RCAT, RKIND>;
- std::memset(product, 0, rows * cols * sizeof *product);
+ Fortran::runtime::memset(product, 0, rows * cols * sizeof *product);
const XT *RESTRICT xp0{x};
for (SubscriptValue k{0}; k < n; ++k) {
ResultType *RESTRICT p{product};
@@ -153,7 +153,7 @@ inline RT_API_ATTRS void MatrixTimesVector(
SubscriptValue n, const XT *RESTRICT x, const YT *RESTRICT y,
std::size_t xColumnByteStride = 0) {
using ResultType = CppTypeFor<RCAT, RKIND>;
- std::memset(product, 0, rows * sizeof *product);
+ Fortran::runtime::memset(product, 0, rows * sizeof *product);
[[maybe_unused]] const XT *RESTRICT xp0{x};
for (SubscriptValue k{0}; k < n; ++k) {
ResultType *RESTRICT p{product};
@@ -203,7 +203,7 @@ inline RT_API_ATTRS void VectorTimesMatrix(
SubscriptValue cols, const XT *RESTRICT x, const YT *RESTRICT y,
std::size_t yColumnByteStride = 0) {
using ResultType = CppTypeFor<RCAT, RKIND>;
- std::memset(product, 0, cols * sizeof *product);
+ Fortran::runtime::memset(product, 0, cols * sizeof *product);
for (SubscriptValue k{0}; k < n; ++k) {
ResultType *RESTRICT p{product};
auto xv{static_cast<ResultType>(*x++)};
diff --git a/flang-rt/lib/runtime/misc-intrinsic.cpp b/flang-rt/lib/runtime/misc-intrinsic.cpp
index a8797f48fa667..535fbc35c326a 100644
--- a/flang-rt/lib/runtime/misc-intrinsic.cpp
+++ b/flang-rt/lib/runtime/misc-intrinsic.cpp
@@ -42,14 +42,14 @@ static RT_API_ATTRS void TransferImpl(Descriptor &result,
source.GetLowerBounds(sourceAt);
while (resultBytes > 0 && sourceElements > 0) {
std::size_t toMove{std::min(resultBytes, sourceElementBytes)};
- std::memcpy(to, source.Element<char>(sourceAt), toMove);
+ Fortran::runtime::memcpy(to, source.Element<char>(sourceAt), toMove);
to += toMove;
resultBytes -= toMove;
--sourceElements;
source.IncrementSubscripts(sourceAt);
}
if (resultBytes > 0) {
- std::memset(to, 0, resultBytes);
+ Fortran::runtime::memset(to, 0, resultBytes);
}
}
diff --git a/flang-rt/lib/runtime/pseudo-unit.cpp b/flang-rt/lib/runtime/pseudo-unit.cpp
index 7e1f3bc86b294..b0019200b74d0 100644
--- a/flang-rt/lib/runtime/pseudo-unit.cpp
+++ b/flang-rt/lib/runtime/pseudo-unit.cpp
@@ -132,7 +132,7 @@ std::size_t PseudoOpenFile::Write(FileOffset at, const char *buffer,
// TODO: use persistent string buffer that can be reallocated
// as needed, and only freed at destruction of *this.
auto string{SizedNew<char>{handler}(bytes + 1)};
- std::memcpy(string.get(), buffer, bytes);
+ Fortran::runtime::memcpy(string.get(), buffer, bytes);
string.get()[bytes] = '\0';
std::printf("%s", string.get());
return bytes;
diff --git a/flang-rt/lib/runtime/ragged.cpp b/flang-rt/lib/runtime/ragged.cpp
index dddc3ccdfd858..bd0644a101fca 100644
--- a/flang-rt/lib/runtime/ragged.cpp
+++ b/flang-rt/lib/runtime/ragged.cpp
@@ -40,7 +40,7 @@ RT_API_ATTRS RaggedArrayHeader *RaggedArrayAllocate(RaggedArrayHeader *header,
std::size_t bytes{static_cast<std::size_t>(elementSize * size)};
header->bufferPointer = AllocateMemoryOrCrash(terminator, bytes);
if (header->bufferPointer) {
- std::memset(header->bufferPointer, 0, bytes);
+ Fortran::runtime::memset(header->bufferPointer, 0, bytes);
}
return header;
} else {
diff --git a/flang-rt/lib/runtime/reduce.cpp b/flang-rt/lib/runtime/reduce.cpp
index 3c5e815e32d2b..54fd1d88c4d02 100644
--- a/flang-rt/lib/runtime/reduce.cpp
+++ b/flang-rt/lib/runtime/reduce.cpp
@@ -79,16 +79,16 @@ class BufferedReduceAccumulator {
activeTemp_ = 1 - activeTemp_;
} else {
activeTemp_ = 0;
- std::memcpy(&*temp_[activeTemp_], operand, elementBytes_);
+ Fortran::runtime::memcpy(&*temp_[activeTemp_], operand, elementBytes_);
}
return true;
}
template <typename A>
RT_API_ATTRS void GetResult(A *to, int /*zeroBasedDim*/ = -1) {
if (activeTemp_ >= 0) {
- std::memcpy(to, &*temp_[activeTemp_], elementBytes_);
+ Fortran::runtime::memcpy(to, &*temp_[activeTemp_], elementBytes_);
} else if (identity_) {
- std::memcpy(to, identity_, elementBytes_);
+ Fortran::runtime::memcpy(to, identity_, elementBytes_);
} else {
terminator_.Crash("REDUCE() without IDENTITY= has no result");
}
diff --git a/flang-rt/lib/runtime/stat.cpp b/flang-rt/lib/runtime/stat.cpp
index 322b7282b7024..dcc4dbafc1e76 100644
--- a/flang-rt/lib/runtime/stat.cpp
+++ b/flang-rt/lib/runtime/stat.cpp
@@ -84,10 +84,11 @@ RT_API_ATTRS int ToErrmsg(const Descriptor *errmsg, int stat) {
std::size_t bufferLength{errmsg->ElementBytes()};
std::size_t msgLength{Fortran::runtime::strlen(msg)};
if (msgLength >= bufferLength) {
- std::memcpy(buffer, msg, bufferLength);
+ Fortran::runtime::memcpy(buffer, msg, bufferLength);
} else {
- std::memcpy(buffer, msg, msgLength);
- std::memset(buffer + msgLength, ' ', bufferLength - msgLength);
+ Fortran::runtime::memcpy(buffer, msg, msgLength);
+ Fortran::runtime::memset(
+ buffer + msgLength, ' ', bufferLength - msgLength);
}
}
}
diff --git a/flang-rt/lib/runtime/temporary-stack.cpp b/flang-rt/lib/runtime/temporary-stack.cpp
index 3f6fd8ee15a80..50270d797dbf0 100644
--- a/flang-rt/lib/runtime/temporary-stack.cpp
+++ b/flang-rt/lib/runtime/temporary-stack.cpp
@@ -97,7 +97,7 @@ void DescriptorStorage<COPY_VALUES>::resize(size_type newCapacity) {
// Avoid passing a null pointer, since it would result in an undefined
// behavior.
if (data_ != nullptr) {
- memcpy(newData, data_, capacity_ * sizeof(Descriptor *));
+ Fortran::runtime::memcpy(newData, data_, capacity_ * sizeof(Descriptor *));
FreeMemory(data_);
}
data_ = newData;
diff --git a/flang-rt/lib/runtime/time-intrinsic.cpp b/flang-rt/lib/runtime/time-intrinsic.cpp
index 8988817a40064..67729d00685e1 100644
--- a/flang-rt/lib/runtime/time-intrinsic.cpp
+++ b/flang-rt/lib/runtime/time-intrinsic.cpp
@@ -276,13 +276,13 @@ static void DateAndTimeUnavailable(Fortran::runtime::Terminator &terminator,
char *zone, std::size_t zoneChars,
const Fortran::runtime::Descriptor *values) {
if (date) {
- std::memset(date, static_cast<int>(' '), dateChars);
+ Fortran::runtime::memset(date, static_cast<int>(' '), dateChars);
}
if (time) {
- std::memset(time, static_cast<int>(' '), timeChars);
+ Fortran::runtime::memset(time, static_cast<int>(' '), timeChars);
}
if (zone) {
- std::memset(zone, static_cast<int>(' '), zoneChars);
+ Fortran::runtime::memset(zone, static_cast<int>(' '), zoneChars);
}
if (values) {
auto typeCode{values->type().GetCategoryAndKind()};
@@ -420,7 +420,7 @@ static void GetDateAndTime(Fortran::runtime::Terminator &terminator, char *date,
auto copyBufferAndPad{
[&](char *dest, std::size_t destChars, std::size_t len) {
auto copyLen{std::min(len, destChars)};
- std::memcpy(dest, buffer, copyLen);
+ Fortran::runtime::memcpy(dest, buffer, copyLen);
for (auto i{copyLen}; i < destChars; ++i) {
dest[i] = ' ';
}
@@ -525,8 +525,8 @@ void RTNAME(Etime)(const Descriptor *values, const Descriptor *time,
ULARGE_INTEGER userSystemTime;
ULARGE_INTEGER kernelSystemTime;
- memcpy(&userSystemTime, &userTime, sizeof(FILETIME));
- memcpy(&kernelSystemTime, &kernelTime, sizeof(FILETIME));
+ Fortran::runtime::memcpy(&userSystemTime, &userTime, sizeof(FILETIME));
+ Fortran::runtime::memcpy(&kernelSystemTime, &kernelTime, sizeof(FILETIME));
usrTime = ((double)(userSystemTime.QuadPart)) / 10000000.0;
sysTime = ((double)(kernelSystemTime.QuadPart)) / 10000000.0;
diff --git a/flang-rt/lib/runtime/tools.cpp b/flang-rt/lib/runtime/tools.cpp
index 24d05f369fcbe..5fe28dc382f62 100644
--- a/flang-rt/lib/runtime/tools.cpp
+++ b/flang-rt/lib/runtime/tools.cpp
@@ -28,7 +28,7 @@ RT_API_ATTRS OwningPtr<char> SaveDefaultCharacter(
const char *s, std::size_t length, const Terminator &terminator) {
if (s) {
auto *p{static_cast<char *>(AllocateMemoryOrCrash(terminator, length + 1))};
- std::memcpy(p, s, length);
+ Fortran::runtime::memcpy(p, s, length);
p[length] = '\0';
return OwningPtr<char>{p};
} else {
@@ -75,10 +75,10 @@ RT_API_ATTRS void ToFortranDefaultCharacter(
char *to, std::size_t toLength, const char *from) {
std::size_t len{Fortran::runtime::strlen(from)};
if (len < toLength) {
- std::memcpy(to, from, len);
- std::memset(to + len, ' ', toLength - len);
+ Fortran::runtime::memcpy(to, from, len);
+ Fortran::runtime::memset(to + len, ' ', toLength - len);
} else {
- std::memcpy(to, from, toLength);
+ Fortran::runtime::memcpy(to, from, toLength);
}
}
@@ -127,10 +127,10 @@ RT_API_ATTRS void ShallowCopyDiscontiguousToDiscontiguous(
toIt.Advance(), fromIt.Advance()) {
// typeElementBytes == 1 when P is a char - the non-specialised case
if constexpr (typeElementBytes != 1) {
- std::memcpy(
+ Fortran::runtime::memcpy(
toIt.template Get<P>(), fromIt.template Get<P>(), typeElementBytes);
} else {
- std::memcpy(
+ Fortran::runtime::memcpy(
toIt.template Get<P>(), fromIt.template Get<P>(), elementBytes);
}
}
@@ -150,9 +150,10 @@ RT_API_ATTRS void ShallowCopyDiscontiguousToContiguous(
for (std::size_t n{to.Elements()}; n-- > 0;
toAt += elementBytes, fromIt.Advance()) {
if constexpr (typeElementBytes != 1) {
- std::memcpy(toAt, fromIt.template Get<P>(), typeElementBytes);
+ Fortran::runtime::memcpy(
+ toAt, fromIt.template Get<P>(), typeElementBytes);
} else {
- std::memcpy(toAt, fromIt.template Get<P>(), elementBytes);
+ Fortran::runtime::memcpy(toAt, fromIt.template Get<P>(), elementBytes);
}
}
}
@@ -170,9 +171,10 @@ RT_API_ATTRS void ShallowCopyContiguousToDiscontiguous(
for (std::size_t n{to.Elements()}; n-- > 0;
toIt.Advance(), fromAt += elementBytes) {
if constexpr (typeElementBytes != 1) {
- std::memcpy(toIt.template Get<P>(), fromAt, typeElementBytes);
+ Fortran::runtime::memcpy(
+ toIt.template Get<P>(), fromAt, typeElementBytes);
} else {
- std::memcpy(toIt.template Get<P>(), fromAt, elementBytes);
+ Fortran::runtime::memcpy(toIt.template Get<P>(), fromAt, elementBytes);
}
}
}
@@ -187,7 +189,7 @@ RT_API_ATTRS void ShallowCopyInner(const Descriptor &to, const Descriptor &from,
bool toIsContiguous, bool fromIsContiguous) {
if (toIsContiguous) {
if (fromIsContiguous) {
- std::memcpy(to.OffsetElement(), from.OffsetElement(),
+ Fortran::runtime::memcpy(to.OffsetElement(), from.OffsetElement(),
to.Elements() * to.ElementBytes());
} else {
ShallowCopyDiscontiguousToContiguous<P, RANK>(to, from);
@@ -277,7 +279,7 @@ RT_API_ATTRS char *EnsureNullTerminated(
char *str, std::size_t length, Terminator &terminator) {
if (runtime::memchr(str, '\0', length) == nullptr) {
char *newCmd{(char *)AllocateMemoryOrCrash(terminator, length + 1)};
- std::memcpy(newCmd, str, length);
+ Fortran::runtime::memcpy(newCmd, str, length);
newCmd[length] = '\0';
return newCmd;
} else {
@@ -309,7 +311,7 @@ RT_API_ATTRS std::int32_t CopyCharsToDescriptor(const Descriptor &value,
return ToErrmsg(errmsg, StatValueTooShort);
}
- std::memcpy(value.OffsetElement(offset), rawValue, toCopy);
+ Fortran::runtime::memcpy(value.OffsetElement(offset), rawValue, toCopy);
if (static_cast<std::int64_t>(rawValueLength) > toCopy) {
return ToErrmsg(errmsg, StatValueTooShort);
diff --git a/flang-rt/lib/runtime/transformational.cpp b/flang-rt/lib/runtime/transformational.cpp
index 3df314a4e966b..7db273f3f22a5 100644
--- a/flang-rt/lib/runtime/transformational.cpp
+++ b/flang-rt/lib/runtime/transformational.cpp
@@ -115,7 +115,7 @@ static RT_API_ATTRS void DefaultInitialize(
"not yet implemented: CHARACTER(KIND=%d) in EOSHIFT intrinsic", kind);
}
} else {
- std::memset(result.raw().base_addr, 0, bytes);
+ Fortran::runtime::memset(result.raw().base_addr, 0, bytes);
}
}
diff --git a/flang-rt/lib/runtime/unit-map.cpp b/flang-rt/lib/runtime/unit-map.cpp
index 41a03f3319d64..e9cddff81a91c 100644
--- a/flang-rt/lib/runtime/unit-map.cpp
+++ b/flang-rt/lib/runtime/unit-map.cpp
@@ -118,7 +118,7 @@ ExternalFileUnit *UnitMap::Find(const char *path, std::size_t pathLen) {
for (int j{0}; j < buckets_; ++j) {
for (Chain *p{bucket_[j].get()}; p; p = p->next.get()) {
if (p->unit.path() && p->unit.pathLength() == pathLen &&
- std::memcmp(p->unit.path(), path, pathLen) == 0) {
+ Fortran::runtime::memcmp(p->unit.path(), path, pathLen) == 0) {
return &p->unit;
}
}
diff --git a/flang-rt/lib/runtime/unit.cpp b/flang-rt/lib/runtime/unit.cpp
index 5f52fa2781db5..a99f19a08db92 100644
--- a/flang-rt/lib/runtime/unit.cpp
+++ b/flang-rt/lib/runtime/unit.cpp
@@ -90,11 +90,12 @@ bool ExternalFileUnit::Emit(const char *data, std::size_t bytes,
CheckDirectAccess(handler);
WriteFrame(frameOffsetInFile_, recordOffsetInFrame_ + furthestAfter, handler);
if (positionInRecord > furthestPositionInRecord) {
- std::memset(Frame() + recordOffsetInFrame_ + furthestPositionInRecord, ' ',
+ Fortran::runtime::memset(
+ Frame() + recordOffsetInFrame_ + furthestPositionInRecord, ' ',
positionInRecord - furthestPositionInRecord);
}
char *to{Frame() + recordOffsetInFrame_ + positionInRecord};
- std::memcpy(to, data, bytes);
+ Fortran::runtime::memcpy(to, data, bytes);
if (swapEndianness_) {
SwapEndianness(to, bytes, elementBytes);
}
@@ -119,7 +120,8 @@ bool ExternalFileUnit::Receive(char *data, std::size_t bytes,
auto need{recordOffsetInFrame_ + furthestAfter};
auto got{ReadFrame(frameOffsetInFile_, need, handler)};
if (got >= need) {
- std::memcpy(data, Frame() + recordOffsetInFrame_ + positionInRecord, bytes);
+ Fortran::runtime::memcpy(
+ data, Frame() + recordOffsetInFrame_ + positionInRecord, bytes);
if (swapEndianness_) {
SwapEndianness(data, bytes, elementBytes);
}
@@ -310,7 +312,8 @@ bool ExternalFileUnit::AdvanceRecord(IoErrorHandler &handler) {
// Pad remainder of fixed length record
WriteFrame(
frameOffsetInFile_, recordOffsetInFrame_ + *openRecl, handler);
- std::memset(Frame() + recordOffsetInFrame_ + furthestPositionInRecord,
+ Fortran::runtime::memset(
+ Frame() + recordOffsetInFrame_ + furthestPositionInRecord,
isUnformatted.value_or(false) ? 0 : ' ',
*openRecl - furthestPositionInRecord);
furthestPositionInRecord = *openRecl;
@@ -839,7 +842,7 @@ void ExternalFileUnit::PopChildIo(ChildIo &child) {
std::uint32_t ExternalFileUnit::ReadHeaderOrFooter(std::int64_t frameOffset) {
std::uint32_t word;
char *wordPtr{reinterpret_cast<char *>(&word)};
- std::memcpy(wordPtr, Frame() + frameOffset, sizeof word);
+ Fortran::runtime::memcpy(wordPtr, Frame() + frameOffset, sizeof word);
if (swapEndianness_) {
SwapEndianness(wordPtr, sizeof word, sizeof word);
}
diff --git a/flang-rt/lib/runtime/work-queue.cpp b/flang-rt/lib/runtime/work-queue.cpp
index 42dbc9064b03b..9ae751ae3367a 100644
--- a/flang-rt/lib/runtime/work-queue.cpp
+++ b/flang-rt/lib/runtime/work-queue.cpp
@@ -14,7 +14,7 @@
namespace Fortran::runtime {
-#if !defined(RT_DEVICE_COMPILATION)
+#if !defined(RT_DEVICE_COMPILATION) && !defined(OMP_OFFLOAD_BUILD)
// FLANG_RT_DEBUG code is disabled when false.
static constexpr bool enableDebugOutput{false};
#endif
@@ -79,7 +79,7 @@ RT_API_ATTRS Ticket &WorkQueue::StartTicket() {
last_ = newTicket;
}
newTicket->ticket.begun = false;
-#if !defined(RT_DEVICE_COMPILATION)
+#if !defined(RT_DEVICE_COMPILATION) && !defined(OMP_OFFLOAD_BUILD)
if (enableDebugOutput &&
(executionEnvironment.internalDebugging &
ExecutionEnvironment::WorkQueue)) {
@@ -93,7 +93,7 @@ RT_API_ATTRS int WorkQueue::Run() {
while (last_) {
TicketList *at{last_};
insertAfter_ = last_;
-#if !defined(RT_DEVICE_COMPILATION)
+#if !defined(RT_DEVICE_COMPILATION) && !defined(OMP_OFFLOAD_BUILD)
if (enableDebugOutput &&
(executionEnvironment.internalDebugging &
ExecutionEnvironment::WorkQueue)) {
@@ -102,7 +102,7 @@ RT_API_ATTRS int WorkQueue::Run() {
}
#endif
int stat{at->ticket.Continue(*this)};
-#if !defined(RT_DEVICE_COMPILATION)
+#if !defined(RT_DEVICE_COMPILATION) && !defined(OMP_OFFLOAD_BUILD)
if (enableDebugOutput &&
(executionEnvironment.internalDebugging &
ExecutionEnvironment::WorkQueue)) {
diff --git a/flang/include/flang/Common/constexpr-bitset.h b/flang/include/flang/Common/constexpr-bitset.h
index 1aafb6eff84c6..e60ff520ec63a 100644
--- a/flang/include/flang/Common/constexpr-bitset.h
+++ b/flang/include/flang/Common/constexpr-bitset.h
@@ -21,7 +21,7 @@
#include <type_traits>
namespace Fortran::common {
-
+RT_OFFLOAD_VAR_GROUP_BEGIN
template <int BITS> class BitSet {
static_assert(BITS > 0 && BITS <= 128);
using Word = HostUnsignedIntType<(BITS <= 32 ? 32 : BITS)>;
@@ -143,5 +143,6 @@ template <int BITS> class BitSet {
private:
Word bits_{0};
};
+RT_OFFLOAD_VAR_GROUP_END
} // namespace Fortran::common
#endif // FORTRAN_COMMON_CONSTEXPR_BITSET_H_
diff --git a/flang/include/flang/Decimal/binary-floating-point.h b/flang/include/flang/Decimal/binary-floating-point.h
index 1e0cde97d98e6..b69ae66c2b290 100644
--- a/flang/include/flang/Decimal/binary-floating-point.h
+++ b/flang/include/flang/Decimal/binary-floating-point.h
@@ -15,6 +15,7 @@
#include "flang/Common/api-attrs.h"
#include "flang/Common/real.h"
#include "flang/Common/uint128.h"
+#include "flang/Runtime/freestanding-tools.h"
#include <cinttypes>
#include <climits>
#include <cstring>
@@ -32,6 +33,7 @@ enum FortranRounding {
template <int BINARY_PRECISION> class BinaryFloatingPointNumber {
public:
+ RT_OFFLOAD_VAR_GROUP_BEGIN
static constexpr common::RealCharacteristics realChars{BINARY_PRECISION};
static constexpr int binaryPrecision{BINARY_PRECISION};
static constexpr int bits{realChars.bits};
@@ -47,7 +49,6 @@ template <int BINARY_PRECISION> class BinaryFloatingPointNumber {
using RawType = common::HostUnsignedIntType<bits>;
static_assert(CHAR_BIT * sizeof(RawType) >= bits);
- RT_OFFLOAD_VAR_GROUP_BEGIN
static constexpr RawType significandMask{(RawType{1} << significandBits) - 1};
constexpr RT_API_ATTRS BinaryFloatingPointNumber() {} // zero
@@ -68,7 +69,7 @@ template <int BINARY_PRECISION> class BinaryFloatingPointNumber {
template <typename A>
explicit constexpr RT_API_ATTRS BinaryFloatingPointNumber(A x) {
static_assert(sizeof raw_ <= sizeof x);
- std::memcpy(reinterpret_cast<void *>(&raw_),
+ Fortran::runtime::memcpy(reinterpret_cast<void *>(&raw_),
reinterpret_cast<const void *>(&x), sizeof raw_);
}
diff --git a/flang/include/flang/Runtime/allocator-registry-consts.h b/flang/include/flang/Runtime/allocator-registry-consts.h
index 70735c2fc7a71..a5f52749e945d 100644
--- a/flang/include/flang/Runtime/allocator-registry-consts.h
+++ b/flang/include/flang/Runtime/allocator-registry-consts.h
@@ -9,6 +9,8 @@
#ifndef FORTRAN_RUNTIME_ALLOCATOR_REGISTRY_CONSTS_H_
#define FORTRAN_RUNTIME_ALLOCATOR_REGISTRY_CONSTS_H_
+RT_OFFLOAD_VAR_GROUP_BEGIN
+
static constexpr unsigned kDefaultAllocator = 0;
// Allocator used for CUF
@@ -17,4 +19,6 @@ static constexpr unsigned kDeviceAllocatorPos = 2;
static constexpr unsigned kManagedAllocatorPos = 3;
static constexpr unsigned kUnifiedAllocatorPos = 4;
+RT_OFFLOAD_VAR_GROUP_END
+
#endif /* FORTRAN_RUNTIME_ALLOCATOR_REGISTRY_CONSTS_H_ */
diff --git a/flang/include/flang/Runtime/freestanding-tools.h b/flang/include/flang/Runtime/freestanding-tools.h
index 3a492c1f320d0..fb161b8002fa5 100644
--- a/flang/include/flang/Runtime/freestanding-tools.h
+++ b/flang/include/flang/Runtime/freestanding-tools.h
@@ -23,6 +23,16 @@
#define STD_FILL_N_UNSUPPORTED 1
#endif
+#if !defined(STD_MEMSET_UNSUPPORTED) && \
+ (defined(__CUDACC__) || defined(__CUDA__)) && defined(__CUDA_ARCH__)
+#define STD_MEMSET_UNSUPPORTED 1
+#endif
+
+#if !defined(STD_MEMCPY_UNSUPPORTED) && \
+ (defined(__CUDACC__) || defined(__CUDA__)) && defined(__CUDA_ARCH__)
+#define STD_MEMCPY_UNSUPPORTED 1
+#endif
+
#if !defined(STD_MEMMOVE_UNSUPPORTED) && \
(defined(__CUDACC__) || defined(__CUDA__)) && defined(__CUDA_ARCH__)
#define STD_MEMMOVE_UNSUPPORTED 1
@@ -63,6 +73,24 @@
#define STD_TOUPPER_UNSUPPORTED 1
#endif
+#if defined(OMP_OFFLOAD_BUILD) || defined(OMP_NOHOST_BUILD)
+#define STD_FILL_N_UNSUPPORTED 1
+#define STD_MEMSET_USE_BUILTIN 1
+#define STD_MEMSET_UNSUPPORTED 1
+#define STD_MEMCPY_USE_BUILTIN 1
+#define STD_MEMCPY_UNSUPPORTED 1
+#define STD_MEMMOVE_UNSUPPORTED 1
+#define STD_STRLEN_UNSUPPORTED 1
+#define STD_MEMCMP_UNSUPPORTED 1
+#define STD_REALLOC_UNSUPPORTED 1
+#define STD_MEMCHR_UNSUPPORTED 1
+#define STD_STRCPY_UNSUPPORTED 1
+#define STD_STRCMP_UNSUPPORTED 1
+#define STD_TOUPPER_UNSUPPORTED 1
+#define STD_ABORT_USE_BUILTIN 1
+#define STD_ABORT_UNSUPPORTED 1
+#endif
+
namespace Fortran::runtime {
#if STD_FILL_N_UNSUPPORTED
@@ -79,7 +107,52 @@ fill_n(A *start, std::size_t count, const B &value) {
using std::fill_n;
#endif // !STD_FILL_N_UNSUPPORTED
-#if STD_MEMMOVE_UNSUPPORTED
+#if STD_MEMSET_USE_BUILTIN
+static inline RT_API_ATTRS void memset(
+ void *dest, unsigned char value, std::size_t count) {
+ __builtin_memset(dest, value, count);
+}
+#elif STD_MEMSET_UNSUPPORTED
+static inline RT_API_ATTRS void memset(
+ void *dest, unsigned char value, std::size_t count) {
+ char *to{reinterpret_cast<char *>(dest)};
+ while (count--) {
+ *to++ = value;
+ }
+ return;
+}
+#else
+using std::memset;
+#endif
+
+#if STD_MEMCPY_USE_BUILTIN
+static inline RT_API_ATTRS void memcpy(
+ void *dest, const void *src, std::size_t count) {
+ __builtin_memcpy(dest, src, count);
+}
+#elif STD_MEMCPY_UNSUPPORTED
+static inline RT_API_ATTRS void memcpy(
+ void *dest, const void *src, std::size_t count) {
+ char *to{reinterpret_cast<char *>(dest)};
+ const char *from{reinterpret_cast<const char *>(src)};
+ if (to == from) {
+ return;
+ }
+ while (count--) {
+ *to++ = *from++;
+ }
+ return;
+}
+#else
+using std::memcpy;
+#endif
+
+#if STD_MEMMOVE_USE_BUILTIN
+static inline RT_API_ATTRS void memmove(
+ void *dest, const void *src, std::size_t count) {
+ __builtin_memmove(dest, src, count);
+}
+#elif STD_MEMMOVE_UNSUPPORTED
// Provides alternative implementation for std::memmove(), if
// it is not supported.
static inline RT_API_ATTRS void *memmove(
@@ -91,7 +164,7 @@ static inline RT_API_ATTRS void *memmove(
return dest;
}
if (to + count <= from || from + count <= to) {
- std::memcpy(dest, src, count);
+ memcpy(dest, src, count);
} else if (to < from) {
while (count--) {
*to++ = *from++;
@@ -112,13 +185,17 @@ using std::memmove;
using MemmoveFct = void *(*)(void *, const void *, std::size_t);
#ifdef RT_DEVICE_COMPILATION
-static RT_API_ATTRS void *MemmoveWrapper(
+[[maybe_unused]] static RT_API_ATTRS void *MemmoveWrapper(
void *dest, const void *src, std::size_t count) {
return Fortran::runtime::memmove(dest, src, count);
}
#endif
-#if STD_STRLEN_UNSUPPORTED
+#if STD_STRLEN_USE_BUILTIN
+static inline RT_API_ATTRS std::size_t strlen(const char *str) {
+ return __builtin_strlen(str);
+}
+#elif STD_STRLEN_UNSUPPORTED
// Provides alternative implementation for std::strlen(), if
// it is not supported.
static inline RT_API_ATTRS std::size_t strlen(const char *str) {
diff --git a/flang/include/flang/Runtime/stop.h b/flang/include/flang/Runtime/stop.h
index 4ddc5cf49ec8f..81c28904efcbe 100644
--- a/flang/include/flang/Runtime/stop.h
+++ b/flang/include/flang/Runtime/stop.h
@@ -30,7 +30,9 @@ NORETURN void RTNAME(ProgramEndStatement)(NO_ARGUMENTS);
// Extensions
NORETURN void RTNAME(Exit)(int status DEFAULT_VALUE(EXIT_SUCCESS));
+RT_OFFLOAD_API_GROUP_BEGIN
NORETURN void RTNAME(Abort)(NO_ARGUMENTS);
+RT_OFFLOAD_API_GROUP_END
void FORTRAN_PROCEDURE_NAME(backtrace)(NO_ARGUMENTS);
// Crash with an error message when the program dynamically violates a Fortran
>From 0ddacd5962c541c9356e87e5ce75c8761d731d3d Mon Sep 17 00:00:00 2001
From: agozillon <Andrew.Gozillon at amd.com>
Date: Mon, 11 Aug 2025 11:35:41 -0500
Subject: [PATCH 2/6] [Flang][Runtime][OpenMP] Make requested modifications to
PR
---
flang-rt/include/flang-rt/runtime/buffer.h | 4 +--
.../flang-rt/runtime/format-implementation.h | 2 +-
flang-rt/include/flang-rt/runtime/tools.h | 4 +--
.../include/flang-rt/runtime/work-queue.h | 14 +++++-----
flang-rt/lib/runtime/array-constructor.cpp | 2 +-
flang-rt/lib/runtime/assign.cpp | 4 +--
flang-rt/lib/runtime/character.cpp | 10 +++----
flang-rt/lib/runtime/command.cpp | 2 +-
flang-rt/lib/runtime/copy.cpp | 4 +--
flang-rt/lib/runtime/derived.cpp | 8 +++---
flang-rt/lib/runtime/descriptor-io.cpp | 2 +-
flang-rt/lib/runtime/descriptor.cpp | 2 +-
flang-rt/lib/runtime/edit-input.cpp | 14 +++++-----
flang-rt/lib/runtime/extensions.cpp | 8 +++---
flang-rt/lib/runtime/external-unit.cpp | 4 +--
flang-rt/lib/runtime/extrema.cpp | 6 ++---
flang-rt/lib/runtime/internal-unit.cpp | 2 +-
flang-rt/lib/runtime/io-api-minimal.cpp | 2 +-
flang-rt/lib/runtime/io-error.cpp | 2 +-
flang-rt/lib/runtime/misc-intrinsic.cpp | 4 +--
flang-rt/lib/runtime/pseudo-unit.cpp | 2 +-
flang-rt/lib/runtime/ragged.cpp | 2 +-
flang-rt/lib/runtime/reduce.cpp | 6 ++---
flang-rt/lib/runtime/stat.cpp | 6 ++---
flang-rt/lib/runtime/time-intrinsic.cpp | 4 +--
flang-rt/lib/runtime/tools.cpp | 26 +++++++++----------
flang-rt/lib/runtime/transformational.cpp | 2 +-
flang-rt/lib/runtime/unit-map.cpp | 2 +-
flang-rt/lib/runtime/unit.cpp | 10 +++----
flang/include/flang/Common/Fortran-consts.h | 3 +++
.../flang/Decimal/binary-floating-point.h | 2 +-
.../flang/Runtime/freestanding-tools.h | 13 ++--------
32 files changed, 86 insertions(+), 92 deletions(-)
diff --git a/flang-rt/include/flang-rt/runtime/buffer.h b/flang-rt/include/flang-rt/runtime/buffer.h
index 2791ac3ce728a..4339213488e22 100644
--- a/flang-rt/include/flang-rt/runtime/buffer.h
+++ b/flang-rt/include/flang-rt/runtime/buffer.h
@@ -158,8 +158,8 @@ template <typename STORE, std::size_t minBuffer = 65536> class FileFrame {
// Avoid passing a null pointer, since it would result in an undefined
// behavior.
if (old != nullptr) {
- Fortran::runtime::memcpy(buffer_, old + start_, chunk);
- Fortran::runtime::memcpy(buffer_ + chunk, old, length_ - chunk);
+ runtime::memcpy(buffer_, old + start_, chunk);
+ runtime::memcpy(buffer_ + chunk, old, length_ - chunk);
FreeMemory(old);
}
start_ = 0;
diff --git a/flang-rt/include/flang-rt/runtime/format-implementation.h b/flang-rt/include/flang-rt/runtime/format-implementation.h
index 0d0972313b87a..1275b4016d040 100644
--- a/flang-rt/include/flang-rt/runtime/format-implementation.h
+++ b/flang-rt/include/flang-rt/runtime/format-implementation.h
@@ -49,7 +49,7 @@ RT_API_ATTRS FormatControl<CONTEXT>::FormatControl(const Terminator &terminator,
SubscriptValue at[maxRank];
formatDescriptor->GetLowerBounds(at);
for (std::size_t j{0}; j < elements; ++j) {
- Fortran::runtime::memcpy(
+ runtime::memcpy(
p, formatDescriptor->Element<char>(at), elementBytes);
p += elementBytes;
formatDescriptor->IncrementSubscripts(at);
diff --git a/flang-rt/include/flang-rt/runtime/tools.h b/flang-rt/include/flang-rt/runtime/tools.h
index 1697c9416bed4..97ef95298cfcf 100644
--- a/flang-rt/include/flang-rt/runtime/tools.h
+++ b/flang-rt/include/flang-rt/runtime/tools.h
@@ -559,9 +559,9 @@ RT_API_ATTRS void CopyAndPad(
to[j] = static_cast<TO>(' ');
}
} else if (toChars <= fromChars) {
- Fortran::runtime::memcpy(to, from, toChars * sizeof(TO));
+ runtime::memcpy(to, from, toChars * sizeof(TO));
} else {
- Fortran::runtime::memcpy(
+ runtime::memcpy(
to, from, std::min(toChars, fromChars) * sizeof(TO));
for (std::size_t j{fromChars}; j < toChars; ++j) {
to[j] = static_cast<TO>(' ');
diff --git a/flang-rt/include/flang-rt/runtime/work-queue.h b/flang-rt/include/flang-rt/runtime/work-queue.h
index d1ea036a8fc0a..7d7f8ad991a57 100644
--- a/flang-rt/include/flang-rt/runtime/work-queue.h
+++ b/flang-rt/include/flang-rt/runtime/work-queue.h
@@ -127,8 +127,8 @@ class Elementwise {
const Descriptor &instance_, *from_{nullptr};
std::size_t elements_{instance_.InlineElements()};
std::size_t elementAt_{0};
- SubscriptValue subscripts_[maxRank];
- SubscriptValue fromSubscripts_[maxRank];
+ SubscriptValue subscripts_[common::maxRank];
+ SubscriptValue fromSubscripts_[common::maxRank];
};
// Base class for ticket workers that operate over derived type components.
@@ -162,7 +162,7 @@ class Componentwise {
const typeInfo::DerivedType &derived_;
std::size_t components_{0}, componentAt_{0};
const typeInfo::Component *component_{nullptr};
- StaticDescriptor<maxRank, true, 0> componentDescriptor_;
+ StaticDescriptor<common::maxRank, true, 0> componentDescriptor_;
private:
RT_API_ATTRS void GetFirstComponent() {
@@ -275,7 +275,7 @@ class InitializeCloneTicket
const Descriptor &clone_;
bool hasStat_{false};
const Descriptor *errMsg_{nullptr};
- StaticDescriptor<maxRank, true, 0> cloneComponentDescriptor_;
+ StaticDescriptor<common::maxRank, true, 0> cloneComponentDescriptor_;
};
// Implements derived type instance finalization
@@ -331,7 +331,7 @@ class AssignTicket : public ImmediateTicketRunner<AssignTicket> {
const Descriptor *from_{nullptr};
int flags_{0}; // enum AssignFlags
MemmoveFct memmoveFct_{nullptr};
- StaticDescriptor<maxRank, true, 0> tempDescriptor_;
+ StaticDescriptor<common::maxRank, true, 0> tempDescriptor_;
const typeInfo::DerivedType *declaredType_{nullptr};
const typeInfo::DerivedType *toDerived_{nullptr};
Descriptor *toDeallocate_{nullptr};
@@ -364,7 +364,7 @@ class DerivedAssignTicket
int flags_{0};
MemmoveFct memmoveFct_{nullptr};
Descriptor *deallocateAfter_{nullptr};
- StaticDescriptor<maxRank, true, 0> fromComponentDescriptor_;
+ StaticDescriptor<common::maxRank, true, 0> fromComponentDescriptor_;
};
namespace io::descr {
@@ -392,7 +392,7 @@ class DescriptorIoTicket
common::optional<typeInfo::SpecialBinding> nonTbpSpecial_;
const typeInfo::DerivedType *derived_{nullptr};
const typeInfo::SpecialBinding *special_{nullptr};
- StaticDescriptor<maxRank, true, 0> elementDescriptor_;
+ StaticDescriptor<common::maxRank, true, 0> elementDescriptor_;
};
template <io::Direction DIR>
diff --git a/flang-rt/lib/runtime/array-constructor.cpp b/flang-rt/lib/runtime/array-constructor.cpp
index a83e66cb678e4..6c79b7b4bf3a7 100644
--- a/flang-rt/lib/runtime/array-constructor.cpp
+++ b/flang-rt/lib/runtime/array-constructor.cpp
@@ -173,7 +173,7 @@ void RTDEF(PushArrayConstructorSimpleScalar)(
AllocateOrReallocateVectorIfNeeded(vector, terminator, to.Elements(), 1);
SubscriptValue subscript[1]{
to.GetDimension(0).LowerBound() + vector.nextValuePosition};
- Fortran::runtime::memcpy(
+ runtime::memcpy(
to.Element<char>(subscript), from, to.ElementBytes());
++vector.nextValuePosition;
}
diff --git a/flang-rt/lib/runtime/assign.cpp b/flang-rt/lib/runtime/assign.cpp
index 9c1aa365ed838..460d85bdde81e 100644
--- a/flang-rt/lib/runtime/assign.cpp
+++ b/flang-rt/lib/runtime/assign.cpp
@@ -280,7 +280,7 @@ RT_API_ATTRS int AssignTicket::Begin(WorkQueue &workQueue) {
if (mustDeallocateLHS) {
// Convert the LHS into a temporary, then make it look deallocated.
toDeallocate_ = &tempDescriptor_.descriptor();
- Fortran::runtime::memcpy(
+ runtime::memcpy(
reinterpret_cast<void *>(toDeallocate_), &to_, to_.SizeInBytes());
to_.set_base_addr(nullptr);
if (toDerived_ && (flags_ & NeedFinalization)) {
@@ -299,7 +299,7 @@ RT_API_ATTRS int AssignTicket::Begin(WorkQueue &workQueue) {
auto descBytes{from_->SizeInBytes()};
Descriptor &newFrom{tempDescriptor_.descriptor()};
persist_ = true; // tempDescriptor_ state must outlive child tickets
- Fortran::runtime::memcpy(
+ runtime::memcpy(
reinterpret_cast<void *>(&newFrom), from_, descBytes);
// Pretend the temporary descriptor is for an ALLOCATABLE
// entity, otherwise, the Deallocate() below will not
diff --git a/flang-rt/lib/runtime/character.cpp b/flang-rt/lib/runtime/character.cpp
index 1c889293881cd..f66d413d37b99 100644
--- a/flang-rt/lib/runtime/character.cpp
+++ b/flang-rt/lib/runtime/character.cpp
@@ -616,8 +616,8 @@ void RTDEF(CharacterConcatenate)(Descriptor &accumulator,
from.GetLowerBounds(fromAt);
for (; elements-- > 0;
to += newBytes, p += oldBytes, from.IncrementSubscripts(fromAt)) {
- Fortran::runtime::memcpy(to, p, oldBytes);
- Fortran::runtime::memcpy(
+ runtime::memcpy(to, p, oldBytes);
+ runtime::memcpy(
to + oldBytes, from.Element<char>(fromAt), fromBytes);
}
FreeMemory(old);
@@ -699,7 +699,7 @@ void RTDEF(CharacterCompare)(
std::size_t RTDEF(CharacterAppend1)(char *lhs, std::size_t lhsBytes,
std::size_t offset, const char *rhs, std::size_t rhsBytes) {
if (auto n{std::min(lhsBytes - offset, rhsBytes)}) {
- Fortran::runtime::memcpy(lhs + offset, rhs, n);
+ runtime::memcpy(lhs + offset, rhs, n);
offset += n;
}
return offset;
@@ -707,7 +707,7 @@ std::size_t RTDEF(CharacterAppend1)(char *lhs, std::size_t lhsBytes,
void RTDEF(CharacterPad1)(char *lhs, std::size_t bytes, std::size_t offset) {
if (bytes > offset) {
- Fortran::runtime::memset(lhs + offset, ' ', bytes - offset);
+ runtime::memset(lhs + offset, ' ', bytes - offset);
}
}
@@ -839,7 +839,7 @@ void RTDEF(Repeat)(Descriptor &result, const Descriptor &string,
}
const char *from{string.OffsetElement()};
for (char *to{result.OffsetElement()}; ncopies-- > 0; to += origBytes) {
- Fortran::runtime::memcpy(to, from, origBytes);
+ runtime::memcpy(to, from, origBytes);
}
}
diff --git a/flang-rt/lib/runtime/command.cpp b/flang-rt/lib/runtime/command.cpp
index a60eee3841bd3..6b5d7722d9ebf 100644
--- a/flang-rt/lib/runtime/command.cpp
+++ b/flang-rt/lib/runtime/command.cpp
@@ -58,7 +58,7 @@ static std::int64_t StringLength(const char *string) {
static void FillWithSpaces(const Descriptor &value, std::size_t offset = 0) {
if (offset < value.ElementBytes()) {
- Fortran::runtime::memset(
+ runtime::memset(
value.OffsetElement(offset), ' ', value.ElementBytes() - offset);
}
}
diff --git a/flang-rt/lib/runtime/copy.cpp b/flang-rt/lib/runtime/copy.cpp
index 8ed6c27bcd062..545f31d3ee137 100644
--- a/flang-rt/lib/runtime/copy.cpp
+++ b/flang-rt/lib/runtime/copy.cpp
@@ -102,7 +102,7 @@ RT_API_ATTRS void CopyElement(const Descriptor &to, const SubscriptValue toAt[],
char *toPtr{to.Element<char>(toAt)};
char *fromPtr{from.Element<char>(fromAt)};
RUNTIME_CHECK(terminator, to.ElementBytes() == from.ElementBytes());
- Fortran::runtime::memcpy(toPtr, fromPtr, to.ElementBytes());
+ runtime::memcpy(toPtr, fromPtr, to.ElementBytes());
return;
}
@@ -149,7 +149,7 @@ RT_API_ATTRS void CopyElement(const Descriptor &to, const SubscriptValue toAt[],
// Moreover, if we came here from an Component::Genre::Data component,
// all the per-element copies are redundant, because the parent
// has already been copied as a whole.
- Fortran::runtime::memcpy(toPtr, fromPtr, curTo.ElementBytes());
+ runtime::memcpy(toPtr, fromPtr, curTo.ElementBytes());
--elements;
if (elements != 0) {
currentCopy.IncrementSubscripts(terminator);
diff --git a/flang-rt/lib/runtime/derived.cpp b/flang-rt/lib/runtime/derived.cpp
index 92e1b00810890..6abeb2edd1da7 100644
--- a/flang-rt/lib/runtime/derived.cpp
+++ b/flang-rt/lib/runtime/derived.cpp
@@ -71,7 +71,7 @@ RT_API_ATTRS int InitializeTicket::Continue(WorkQueue &workQueue) {
// Explicit initialization of data pointers and
// non-allocatable non-automatic components
std::size_t bytes{component_->SizeInBytes(instance_)};
- Fortran::runtime::memcpy(rawComponent, init, bytes);
+ runtime::memcpy(rawComponent, init, bytes);
} else if (component_->genre() == typeInfo::Component::Genre::Pointer) {
// Data pointers without explicit initialization are established
// so that they are valid right-hand side targets of pointer
@@ -108,20 +108,20 @@ RT_API_ATTRS int InitializeTicket::Continue(WorkQueue &workQueue) {
chunk = done;
}
char *uninitialized{rawInstance + done * *stride};
- Fortran::runtime::memcpy(uninitialized, rawInstance, chunk * *stride);
+ runtime::memcpy(uninitialized, rawInstance, chunk * *stride);
done += chunk;
}
} else {
for (std::size_t done{1}; done < elements_; ++done) {
char *uninitialized{rawInstance + done * *stride};
- Fortran::runtime::memcpy(uninitialized, rawInstance, elementBytes);
+ runtime::memcpy(uninitialized, rawInstance, elementBytes);
}
}
} else { // one at a time with subscription
for (Elementwise::Advance(); !Elementwise::IsComplete();
Elementwise::Advance()) {
char *element{instance_.Element<char>(subscripts_)};
- Fortran::runtime::memcpy(element, rawInstance, elementBytes);
+ runtime::memcpy(element, rawInstance, elementBytes);
}
}
}
diff --git a/flang-rt/lib/runtime/descriptor-io.cpp b/flang-rt/lib/runtime/descriptor-io.cpp
index bb5e46bf2c2a0..2912053f109c5 100644
--- a/flang-rt/lib/runtime/descriptor-io.cpp
+++ b/flang-rt/lib/runtime/descriptor-io.cpp
@@ -65,7 +65,7 @@ static RT_API_ATTRS Fortran::common::optional<bool> DefinedFormattedIo(
if (edit.descriptor == DataEdit::DefinedDerivedType) {
ioType[0] = 'D';
ioType[1] = 'T';
- Fortran::runtime::memcpy(ioType + 2, edit.ioType, edit.ioTypeChars);
+ runtime::memcpy(ioType + 2, edit.ioType, edit.ioTypeChars);
} else {
runtime::strcpy(
ioType, io.mutableModes().inNamelist ? "NAMELIST" : "LISTDIRECTED");
diff --git a/flang-rt/lib/runtime/descriptor.cpp b/flang-rt/lib/runtime/descriptor.cpp
index d7d8692cc7e94..e4b5bd2e74dbf 100644
--- a/flang-rt/lib/runtime/descriptor.cpp
+++ b/flang-rt/lib/runtime/descriptor.cpp
@@ -27,7 +27,7 @@ RT_OFFLOAD_API_GROUP_BEGIN
RT_API_ATTRS Descriptor::Descriptor(const Descriptor &that) { *this = that; }
RT_API_ATTRS Descriptor &Descriptor::operator=(const Descriptor &that) {
- Fortran::runtime::memcpy(this, &that, that.SizeInBytes());
+ runtime::memcpy(this, &that, that.SizeInBytes());
return *this;
}
diff --git a/flang-rt/lib/runtime/edit-input.cpp b/flang-rt/lib/runtime/edit-input.cpp
index f557e3e530735..6409c4b8fa912 100644
--- a/flang-rt/lib/runtime/edit-input.cpp
+++ b/flang-rt/lib/runtime/edit-input.cpp
@@ -110,7 +110,7 @@ static RT_API_ATTRS bool EditBOZInput(
io.HandleAbsolutePosition(start);
remaining.reset();
// Make a second pass now that the digit count is known
- Fortran::runtime::memset(n, 0, bytes);
+ runtime::memset(n, 0, bytes);
int increment{isHostLittleEndian ? -1 : 1};
auto *data{reinterpret_cast<unsigned char *>(n) +
(isHostLittleEndian ? significantBytes - 1 : bytes - significantBytes)};
@@ -283,18 +283,18 @@ RT_API_ATTRS bool EditIntegerInput(IoStatementState &io, const DataEdit &edit,
auto shft{static_cast<int>(sizeof value - kind)};
if (!isHostLittleEndian && shft >= 0) {
auto shifted{value << (8 * shft)};
- Fortran::runtime::memcpy(n, &shifted, kind);
+ runtime::memcpy(n, &shifted, kind);
} else {
- Fortran::runtime::memcpy(n, &value, kind); // a blank field means zero
+ runtime::memcpy(n, &value, kind); // a blank field means zero
}
#else
auto shft{static_cast<int>(sizeof(value.low())) - kind};
// For kind==8 (i.e. shft==0), the value is stored in low_ in big endian.
if (!isHostLittleEndian && shft >= 0) {
auto l{value.low() << (8 * shft)};
- Fortran::runtime::memcpy(n, &l, kind);
+ runtime::memcpy(n, &l, kind);
} else {
- Fortran::runtime::memcpy(n, &value, kind); // a blank field means zero
+ runtime::memcpy(n, &value, kind); // a blank field means zero
}
#endif
io.GotChar(fastField.got());
@@ -1120,7 +1120,7 @@ RT_API_ATTRS bool EditCharacterInput(IoStatementState &io, const DataEdit &edit,
--skipChars;
} else {
char32_t buffer{0};
- Fortran::runtime::memcpy(&buffer, input, chunkBytes);
+ runtime::memcpy(&buffer, input, chunkBytes);
if ((sizeof *x == 1 && buffer > 0xff) ||
(sizeof *x == 2 && buffer > 0xffff)) {
*x++ = '?';
@@ -1147,7 +1147,7 @@ RT_API_ATTRS bool EditCharacterInput(IoStatementState &io, const DataEdit &edit,
chunkBytes = std::min<std::size_t>(remainingChars, readyBytes);
chunkBytes = std::min<std::size_t>(lengthChars, chunkBytes);
chunkChars = chunkBytes;
- Fortran::runtime::memcpy(x, input, chunkBytes);
+ runtime::memcpy(x, input, chunkBytes);
x += chunkBytes;
lengthChars -= chunkChars;
}
diff --git a/flang-rt/lib/runtime/extensions.cpp b/flang-rt/lib/runtime/extensions.cpp
index 91ce2f5ae9522..7410ef2e4b6cd 100644
--- a/flang-rt/lib/runtime/extensions.cpp
+++ b/flang-rt/lib/runtime/extensions.cpp
@@ -147,7 +147,7 @@ uid_t RTNAME(GetUID)() {
}
void GetUsernameEnvVar(const char *envName, char *arg, std::int64_t length) {
- Descriptor name{*Descriptor::Create(1, Fortran::runtime::strlen(envName) + 1,
+ Descriptor name{*Descriptor::Create(1, runtime::strlen(envName) + 1,
const_cast<char *>(envName), 0)};
Descriptor value{*Descriptor::Create(1, length, arg, 0)};
@@ -172,7 +172,7 @@ void FORTRAN_PROCEDURE_NAME(fdate)(char *arg, std::int64_t length) {
char str[26];
// Insufficient space, fill with spaces and return.
if (length < 24) {
- Fortran::runtime::memset(arg, ' ', length);
+ runtime::memset(arg, ' ', length);
return;
}
@@ -205,7 +205,7 @@ void FORTRAN_PROCEDURE_NAME(getlog)(char *arg, std::int64_t length) {
#if _REENTRANT || _POSIX_C_SOURCE >= 199506L
if (length >= 1 && getlogin_r(arg, length) == 0) {
auto loginLen{Fortran::runtime::strlen(arg)};
- Fortran::runtime::memset(
+ runtime::memset(
arg + loginLen, ' ', static_cast<std::size_t>(length) - loginLen);
return;
}
@@ -259,7 +259,7 @@ std::int64_t FORTRAN_PROCEDURE_NAME(access)(const char *name,
char *newName{nullptr};
if (name[nameLength - 1] != '\0') {
newName = static_cast<char *>(std::malloc(nameLength + 1));
- Fortran::runtime::memcpy(newName, name, nameLength);
+ runtime::memcpy(newName, name, nameLength);
newName[nameLength] = '\0';
name = newName;
}
diff --git a/flang-rt/lib/runtime/external-unit.cpp b/flang-rt/lib/runtime/external-unit.cpp
index df07c2b72d8d4..779b806b0003f 100644
--- a/flang-rt/lib/runtime/external-unit.cpp
+++ b/flang-rt/lib/runtime/external-unit.cpp
@@ -122,7 +122,7 @@ bool ExternalFileUnit::OpenUnit(Fortran::common::optional<OpenStatus> status,
bool impliedClose{false};
if (IsConnected()) {
bool isSamePath{newPath.get() && path() && pathLength() == newPathLength &&
- Fortran::runtime::memcmp(path(), newPath.get(), newPathLength) == 0};
+ runtime::memcmp(path(), newPath.get(), newPathLength) == 0};
if (status && *status != OpenStatus::Old && isSamePath) {
handler.SignalError("OPEN statement for connected unit may not have "
"explicit STATUS= other than 'OLD'");
@@ -203,7 +203,7 @@ bool ExternalFileUnit::OpenAnonymousUnit(
auto path{SizedNew<char>{handler}(pathMaxLen)};
std::snprintf(path.get(), pathMaxLen, "fort.%d", unitNumber_);
OpenUnit(status, action, position, std::move(path),
- Fortran::runtime::strlen(path.get()), convert, handler);
+ runtime::strlen(path.get()), convert, handler);
return IsConnected();
}
diff --git a/flang-rt/lib/runtime/extrema.cpp b/flang-rt/lib/runtime/extrema.cpp
index 35db72a5a2f66..9846529665e8b 100644
--- a/flang-rt/lib/runtime/extrema.cpp
+++ b/flang-rt/lib/runtime/extrema.cpp
@@ -428,7 +428,7 @@ inline RT_API_ATTRS void TypedPartialMaxOrMinLoc(const char *intrinsic,
CreatePartialReductionResult(result, x,
Descriptor::BytesFor(TypeCategory::Integer, kind), dim, terminator,
intrinsic, TypeCode{TypeCategory::Integer, kind});
- Fortran::runtime::memset(
+ runtime::memset(
result.OffsetElement(), 0, result.Elements() * result.ElementBytes());
return;
}
@@ -584,11 +584,11 @@ template <int KIND, bool IS_MAXVAL> class CharacterExtremumAccumulator {
static_assert(std::is_same_v<A, Type>);
std::size_t byteSize{array_.ElementBytes()};
if (extremum_) {
- Fortran::runtime::memcpy(p, extremum_, byteSize);
+ runtime::memcpy(p, extremum_, byteSize);
} else {
// Empty array; fill with character 0 for MAXVAL.
// For MINVAL, set all of the bits.
- Fortran::runtime::memset(p, IS_MAXVAL ? 0 : 255, byteSize);
+ runtime::memset(p, IS_MAXVAL ? 0 : 255, byteSize);
}
}
RT_API_ATTRS bool Accumulate(const Type *x) {
diff --git a/flang-rt/lib/runtime/internal-unit.cpp b/flang-rt/lib/runtime/internal-unit.cpp
index 1258e814c2285..cdcee2daaec45 100644
--- a/flang-rt/lib/runtime/internal-unit.cpp
+++ b/flang-rt/lib/runtime/internal-unit.cpp
@@ -72,7 +72,7 @@ RT_API_ATTRS bool InternalDescriptorUnit<DIR>::Emit(
BlankFill(record + furthestPositionInRecord,
positionInRecord - furthestPositionInRecord);
}
- Fortran::runtime::memcpy(record + positionInRecord, data, bytes);
+ runtime::memcpy(record + positionInRecord, data, bytes);
positionInRecord += bytes;
furthestPositionInRecord = furthestAfter;
return ok;
diff --git a/flang-rt/lib/runtime/io-api-minimal.cpp b/flang-rt/lib/runtime/io-api-minimal.cpp
index c3c7e40529928..fdf7183ed5176 100644
--- a/flang-rt/lib/runtime/io-api-minimal.cpp
+++ b/flang-rt/lib/runtime/io-api-minimal.cpp
@@ -161,4 +161,4 @@ void std::__libcpp_verbose_abort(char const *format, ...) noexcept(
}
#endif
-RT_EXT_API_GROUP_END
\ No newline at end of file
+RT_EXT_API_GROUP_END
diff --git a/flang-rt/lib/runtime/io-error.cpp b/flang-rt/lib/runtime/io-error.cpp
index 1a49a4f077f97..0774b014e98fd 100644
--- a/flang-rt/lib/runtime/io-error.cpp
+++ b/flang-rt/lib/runtime/io-error.cpp
@@ -153,7 +153,7 @@ bool IoErrorHandler::GetIoMsg(char *buffer, std::size_t bufferLength) {
} else if (ok) {
std::size_t copied{Fortran::runtime::strlen(buffer)};
if (copied < bufferLength) {
- Fortran::runtime::memset(buffer + copied, ' ', bufferLength - copied);
+ runtime::memset(buffer + copied, ' ', bufferLength - copied);
}
return true;
} else {
diff --git a/flang-rt/lib/runtime/misc-intrinsic.cpp b/flang-rt/lib/runtime/misc-intrinsic.cpp
index 535fbc35c326a..5f39d3e30e112 100644
--- a/flang-rt/lib/runtime/misc-intrinsic.cpp
+++ b/flang-rt/lib/runtime/misc-intrinsic.cpp
@@ -42,14 +42,14 @@ static RT_API_ATTRS void TransferImpl(Descriptor &result,
source.GetLowerBounds(sourceAt);
while (resultBytes > 0 && sourceElements > 0) {
std::size_t toMove{std::min(resultBytes, sourceElementBytes)};
- Fortran::runtime::memcpy(to, source.Element<char>(sourceAt), toMove);
+ runtime::memcpy(to, source.Element<char>(sourceAt), toMove);
to += toMove;
resultBytes -= toMove;
--sourceElements;
source.IncrementSubscripts(sourceAt);
}
if (resultBytes > 0) {
- Fortran::runtime::memset(to, 0, resultBytes);
+ runtime::memset(to, 0, resultBytes);
}
}
diff --git a/flang-rt/lib/runtime/pseudo-unit.cpp b/flang-rt/lib/runtime/pseudo-unit.cpp
index b0019200b74d0..104a6554a717e 100644
--- a/flang-rt/lib/runtime/pseudo-unit.cpp
+++ b/flang-rt/lib/runtime/pseudo-unit.cpp
@@ -132,7 +132,7 @@ std::size_t PseudoOpenFile::Write(FileOffset at, const char *buffer,
// TODO: use persistent string buffer that can be reallocated
// as needed, and only freed at destruction of *this.
auto string{SizedNew<char>{handler}(bytes + 1)};
- Fortran::runtime::memcpy(string.get(), buffer, bytes);
+ runtime::memcpy(string.get(), buffer, bytes);
string.get()[bytes] = '\0';
std::printf("%s", string.get());
return bytes;
diff --git a/flang-rt/lib/runtime/ragged.cpp b/flang-rt/lib/runtime/ragged.cpp
index bd0644a101fca..f28e9b5222fca 100644
--- a/flang-rt/lib/runtime/ragged.cpp
+++ b/flang-rt/lib/runtime/ragged.cpp
@@ -40,7 +40,7 @@ RT_API_ATTRS RaggedArrayHeader *RaggedArrayAllocate(RaggedArrayHeader *header,
std::size_t bytes{static_cast<std::size_t>(elementSize * size)};
header->bufferPointer = AllocateMemoryOrCrash(terminator, bytes);
if (header->bufferPointer) {
- Fortran::runtime::memset(header->bufferPointer, 0, bytes);
+ runtime::memset(header->bufferPointer, 0, bytes);
}
return header;
} else {
diff --git a/flang-rt/lib/runtime/reduce.cpp b/flang-rt/lib/runtime/reduce.cpp
index 54fd1d88c4d02..778600b4b4fa8 100644
--- a/flang-rt/lib/runtime/reduce.cpp
+++ b/flang-rt/lib/runtime/reduce.cpp
@@ -79,16 +79,16 @@ class BufferedReduceAccumulator {
activeTemp_ = 1 - activeTemp_;
} else {
activeTemp_ = 0;
- Fortran::runtime::memcpy(&*temp_[activeTemp_], operand, elementBytes_);
+ runtime::memcpy(&*temp_[activeTemp_], operand, elementBytes_);
}
return true;
}
template <typename A>
RT_API_ATTRS void GetResult(A *to, int /*zeroBasedDim*/ = -1) {
if (activeTemp_ >= 0) {
- Fortran::runtime::memcpy(to, &*temp_[activeTemp_], elementBytes_);
+ runtime::memcpy(to, &*temp_[activeTemp_], elementBytes_);
} else if (identity_) {
- Fortran::runtime::memcpy(to, identity_, elementBytes_);
+ runtime::memcpy(to, identity_, elementBytes_);
} else {
terminator_.Crash("REDUCE() without IDENTITY= has no result");
}
diff --git a/flang-rt/lib/runtime/stat.cpp b/flang-rt/lib/runtime/stat.cpp
index dcc4dbafc1e76..285fc21972d8f 100644
--- a/flang-rt/lib/runtime/stat.cpp
+++ b/flang-rt/lib/runtime/stat.cpp
@@ -84,10 +84,10 @@ RT_API_ATTRS int ToErrmsg(const Descriptor *errmsg, int stat) {
std::size_t bufferLength{errmsg->ElementBytes()};
std::size_t msgLength{Fortran::runtime::strlen(msg)};
if (msgLength >= bufferLength) {
- Fortran::runtime::memcpy(buffer, msg, bufferLength);
+ runtime::memcpy(buffer, msg, bufferLength);
} else {
- Fortran::runtime::memcpy(buffer, msg, msgLength);
- Fortran::runtime::memset(
+ runtime::memcpy(buffer, msg, msgLength);
+ runtime::memset(
buffer + msgLength, ' ', bufferLength - msgLength);
}
}
diff --git a/flang-rt/lib/runtime/time-intrinsic.cpp b/flang-rt/lib/runtime/time-intrinsic.cpp
index 67729d00685e1..de4cd5d198f16 100644
--- a/flang-rt/lib/runtime/time-intrinsic.cpp
+++ b/flang-rt/lib/runtime/time-intrinsic.cpp
@@ -525,8 +525,8 @@ void RTNAME(Etime)(const Descriptor *values, const Descriptor *time,
ULARGE_INTEGER userSystemTime;
ULARGE_INTEGER kernelSystemTime;
- Fortran::runtime::memcpy(&userSystemTime, &userTime, sizeof(FILETIME));
- Fortran::runtime::memcpy(&kernelSystemTime, &kernelTime, sizeof(FILETIME));
+ runtime::memcpy(&userSystemTime, &userTime, sizeof(FILETIME));
+ runtime::memcpy(&kernelSystemTime, &kernelTime, sizeof(FILETIME));
usrTime = ((double)(userSystemTime.QuadPart)) / 10000000.0;
sysTime = ((double)(kernelSystemTime.QuadPart)) / 10000000.0;
diff --git a/flang-rt/lib/runtime/tools.cpp b/flang-rt/lib/runtime/tools.cpp
index 5fe28dc382f62..7f0fb4c3ac479 100644
--- a/flang-rt/lib/runtime/tools.cpp
+++ b/flang-rt/lib/runtime/tools.cpp
@@ -28,7 +28,7 @@ RT_API_ATTRS OwningPtr<char> SaveDefaultCharacter(
const char *s, std::size_t length, const Terminator &terminator) {
if (s) {
auto *p{static_cast<char *>(AllocateMemoryOrCrash(terminator, length + 1))};
- Fortran::runtime::memcpy(p, s, length);
+ runtime::memcpy(p, s, length);
p[length] = '\0';
return OwningPtr<char>{p};
} else {
@@ -75,10 +75,10 @@ RT_API_ATTRS void ToFortranDefaultCharacter(
char *to, std::size_t toLength, const char *from) {
std::size_t len{Fortran::runtime::strlen(from)};
if (len < toLength) {
- Fortran::runtime::memcpy(to, from, len);
- Fortran::runtime::memset(to + len, ' ', toLength - len);
+ runtime::memcpy(to, from, len);
+ runtime::memset(to + len, ' ', toLength - len);
} else {
- Fortran::runtime::memcpy(to, from, toLength);
+ runtime::memcpy(to, from, toLength);
}
}
@@ -127,10 +127,10 @@ RT_API_ATTRS void ShallowCopyDiscontiguousToDiscontiguous(
toIt.Advance(), fromIt.Advance()) {
// typeElementBytes == 1 when P is a char - the non-specialised case
if constexpr (typeElementBytes != 1) {
- Fortran::runtime::memcpy(
+ runtime::memcpy(
toIt.template Get<P>(), fromIt.template Get<P>(), typeElementBytes);
} else {
- Fortran::runtime::memcpy(
+ runtime::memcpy(
toIt.template Get<P>(), fromIt.template Get<P>(), elementBytes);
}
}
@@ -150,10 +150,10 @@ RT_API_ATTRS void ShallowCopyDiscontiguousToContiguous(
for (std::size_t n{to.Elements()}; n-- > 0;
toAt += elementBytes, fromIt.Advance()) {
if constexpr (typeElementBytes != 1) {
- Fortran::runtime::memcpy(
+ runtime::memcpy(
toAt, fromIt.template Get<P>(), typeElementBytes);
} else {
- Fortran::runtime::memcpy(toAt, fromIt.template Get<P>(), elementBytes);
+ runtime::memcpy(toAt, fromIt.template Get<P>(), elementBytes);
}
}
}
@@ -171,10 +171,10 @@ RT_API_ATTRS void ShallowCopyContiguousToDiscontiguous(
for (std::size_t n{to.Elements()}; n-- > 0;
toIt.Advance(), fromAt += elementBytes) {
if constexpr (typeElementBytes != 1) {
- Fortran::runtime::memcpy(
+ runtime::memcpy(
toIt.template Get<P>(), fromAt, typeElementBytes);
} else {
- Fortran::runtime::memcpy(toIt.template Get<P>(), fromAt, elementBytes);
+ runtime::memcpy(toIt.template Get<P>(), fromAt, elementBytes);
}
}
}
@@ -189,7 +189,7 @@ RT_API_ATTRS void ShallowCopyInner(const Descriptor &to, const Descriptor &from,
bool toIsContiguous, bool fromIsContiguous) {
if (toIsContiguous) {
if (fromIsContiguous) {
- Fortran::runtime::memcpy(to.OffsetElement(), from.OffsetElement(),
+ runtime::memcpy(to.OffsetElement(), from.OffsetElement(),
to.Elements() * to.ElementBytes());
} else {
ShallowCopyDiscontiguousToContiguous<P, RANK>(to, from);
@@ -279,7 +279,7 @@ RT_API_ATTRS char *EnsureNullTerminated(
char *str, std::size_t length, Terminator &terminator) {
if (runtime::memchr(str, '\0', length) == nullptr) {
char *newCmd{(char *)AllocateMemoryOrCrash(terminator, length + 1)};
- Fortran::runtime::memcpy(newCmd, str, length);
+ runtime::memcpy(newCmd, str, length);
newCmd[length] = '\0';
return newCmd;
} else {
@@ -311,7 +311,7 @@ RT_API_ATTRS std::int32_t CopyCharsToDescriptor(const Descriptor &value,
return ToErrmsg(errmsg, StatValueTooShort);
}
- Fortran::runtime::memcpy(value.OffsetElement(offset), rawValue, toCopy);
+ runtime::memcpy(value.OffsetElement(offset), rawValue, toCopy);
if (static_cast<std::int64_t>(rawValueLength) > toCopy) {
return ToErrmsg(errmsg, StatValueTooShort);
diff --git a/flang-rt/lib/runtime/transformational.cpp b/flang-rt/lib/runtime/transformational.cpp
index 7db273f3f22a5..1869bfeb077aa 100644
--- a/flang-rt/lib/runtime/transformational.cpp
+++ b/flang-rt/lib/runtime/transformational.cpp
@@ -115,7 +115,7 @@ static RT_API_ATTRS void DefaultInitialize(
"not yet implemented: CHARACTER(KIND=%d) in EOSHIFT intrinsic", kind);
}
} else {
- Fortran::runtime::memset(result.raw().base_addr, 0, bytes);
+ runtime::memset(result.raw().base_addr, 0, bytes);
}
}
diff --git a/flang-rt/lib/runtime/unit-map.cpp b/flang-rt/lib/runtime/unit-map.cpp
index e9cddff81a91c..5d815efb76b00 100644
--- a/flang-rt/lib/runtime/unit-map.cpp
+++ b/flang-rt/lib/runtime/unit-map.cpp
@@ -118,7 +118,7 @@ ExternalFileUnit *UnitMap::Find(const char *path, std::size_t pathLen) {
for (int j{0}; j < buckets_; ++j) {
for (Chain *p{bucket_[j].get()}; p; p = p->next.get()) {
if (p->unit.path() && p->unit.pathLength() == pathLen &&
- Fortran::runtime::memcmp(p->unit.path(), path, pathLen) == 0) {
+ runtime::memcmp(p->unit.path(), path, pathLen) == 0) {
return &p->unit;
}
}
diff --git a/flang-rt/lib/runtime/unit.cpp b/flang-rt/lib/runtime/unit.cpp
index a99f19a08db92..efab5b6e1ba13 100644
--- a/flang-rt/lib/runtime/unit.cpp
+++ b/flang-rt/lib/runtime/unit.cpp
@@ -90,12 +90,12 @@ bool ExternalFileUnit::Emit(const char *data, std::size_t bytes,
CheckDirectAccess(handler);
WriteFrame(frameOffsetInFile_, recordOffsetInFrame_ + furthestAfter, handler);
if (positionInRecord > furthestPositionInRecord) {
- Fortran::runtime::memset(
+ runtime::memset(
Frame() + recordOffsetInFrame_ + furthestPositionInRecord, ' ',
positionInRecord - furthestPositionInRecord);
}
char *to{Frame() + recordOffsetInFrame_ + positionInRecord};
- Fortran::runtime::memcpy(to, data, bytes);
+ runtime::memcpy(to, data, bytes);
if (swapEndianness_) {
SwapEndianness(to, bytes, elementBytes);
}
@@ -120,7 +120,7 @@ bool ExternalFileUnit::Receive(char *data, std::size_t bytes,
auto need{recordOffsetInFrame_ + furthestAfter};
auto got{ReadFrame(frameOffsetInFile_, need, handler)};
if (got >= need) {
- Fortran::runtime::memcpy(
+ runtime::memcpy(
data, Frame() + recordOffsetInFrame_ + positionInRecord, bytes);
if (swapEndianness_) {
SwapEndianness(data, bytes, elementBytes);
@@ -312,7 +312,7 @@ bool ExternalFileUnit::AdvanceRecord(IoErrorHandler &handler) {
// Pad remainder of fixed length record
WriteFrame(
frameOffsetInFile_, recordOffsetInFrame_ + *openRecl, handler);
- Fortran::runtime::memset(
+ runtime::memset(
Frame() + recordOffsetInFrame_ + furthestPositionInRecord,
isUnformatted.value_or(false) ? 0 : ' ',
*openRecl - furthestPositionInRecord);
@@ -842,7 +842,7 @@ void ExternalFileUnit::PopChildIo(ChildIo &child) {
std::uint32_t ExternalFileUnit::ReadHeaderOrFooter(std::int64_t frameOffset) {
std::uint32_t word;
char *wordPtr{reinterpret_cast<char *>(&word)};
- Fortran::runtime::memcpy(wordPtr, Frame() + frameOffset, sizeof word);
+ runtime::memcpy(wordPtr, Frame() + frameOffset, sizeof word);
if (swapEndianness_) {
SwapEndianness(wordPtr, sizeof word, sizeof word);
}
diff --git a/flang/include/flang/Common/Fortran-consts.h b/flang/include/flang/Common/Fortran-consts.h
index 74ef1c85d2c86..466fc8a5cf4bb 100644
--- a/flang/include/flang/Common/Fortran-consts.h
+++ b/flang/include/flang/Common/Fortran-consts.h
@@ -9,6 +9,7 @@
#ifndef FORTRAN_COMMON_FORTRAN_CONSTS_H_
#define FORTRAN_COMMON_FORTRAN_CONSTS_H_
+#include "api-attrs.h"
#include "enum-class.h"
#include <cstdint>
@@ -27,8 +28,10 @@ ENUM_CLASS(IoStmtKind, None, Backspace, Close, Endfile, Flush, Inquire, Open,
ENUM_CLASS(
DefinedIo, ReadFormatted, ReadUnformatted, WriteFormatted, WriteUnformatted)
+RT_OFFLOAD_VAR_GROUP_BEGIN
// Fortran arrays may have up to 15 dimensions (See Fortran 2018 section 5.4.6).
static constexpr int maxRank{15};
+RT_OFFLOAD_VAR_GROUP_END
// Floating-point rounding modes; these are packed into a byte to save
// room in the runtime's format processing context structure. These
diff --git a/flang/include/flang/Decimal/binary-floating-point.h b/flang/include/flang/Decimal/binary-floating-point.h
index b69ae66c2b290..380ba958eae62 100644
--- a/flang/include/flang/Decimal/binary-floating-point.h
+++ b/flang/include/flang/Decimal/binary-floating-point.h
@@ -69,7 +69,7 @@ template <int BINARY_PRECISION> class BinaryFloatingPointNumber {
template <typename A>
explicit constexpr RT_API_ATTRS BinaryFloatingPointNumber(A x) {
static_assert(sizeof raw_ <= sizeof x);
- Fortran::runtime::memcpy(reinterpret_cast<void *>(&raw_),
+ runtime::memcpy(reinterpret_cast<void *>(&raw_),
reinterpret_cast<const void *>(&x), sizeof raw_);
}
diff --git a/flang/include/flang/Runtime/freestanding-tools.h b/flang/include/flang/Runtime/freestanding-tools.h
index fb161b8002fa5..0d48da9c1798f 100644
--- a/flang/include/flang/Runtime/freestanding-tools.h
+++ b/flang/include/flang/Runtime/freestanding-tools.h
@@ -23,16 +23,6 @@
#define STD_FILL_N_UNSUPPORTED 1
#endif
-#if !defined(STD_MEMSET_UNSUPPORTED) && \
- (defined(__CUDACC__) || defined(__CUDA__)) && defined(__CUDA_ARCH__)
-#define STD_MEMSET_UNSUPPORTED 1
-#endif
-
-#if !defined(STD_MEMCPY_UNSUPPORTED) && \
- (defined(__CUDACC__) || defined(__CUDA__)) && defined(__CUDA_ARCH__)
-#define STD_MEMCPY_UNSUPPORTED 1
-#endif
-
#if !defined(STD_MEMMOVE_UNSUPPORTED) && \
(defined(__CUDACC__) || defined(__CUDA__)) && defined(__CUDA_ARCH__)
#define STD_MEMMOVE_UNSUPPORTED 1
@@ -73,7 +63,8 @@
#define STD_TOUPPER_UNSUPPORTED 1
#endif
-#if defined(OMP_OFFLOAD_BUILD) || defined(OMP_NOHOST_BUILD)
+#if defined(OMP_OFFLOAD_BUILD) && \
+ defined(OMP_NOHOST_BUILD) && defined(__clang__)
#define STD_FILL_N_UNSUPPORTED 1
#define STD_MEMSET_USE_BUILTIN 1
#define STD_MEMSET_UNSUPPORTED 1
>From 4c7e386753b5ca9dd7f1656936c6ad8fd7520fcc Mon Sep 17 00:00:00 2001
From: agozillon <Andrew.Gozillon at amd.com>
Date: Mon, 11 Aug 2025 13:38:20 -0500
Subject: [PATCH 3/6] [Flang][Runtime] Remove unrequired include
---
flang-rt/lib/runtime/assign.cpp | 1 -
1 file changed, 1 deletion(-)
diff --git a/flang-rt/lib/runtime/assign.cpp b/flang-rt/lib/runtime/assign.cpp
index 460d85bdde81e..1eeb70f4b7820 100644
--- a/flang-rt/lib/runtime/assign.cpp
+++ b/flang-rt/lib/runtime/assign.cpp
@@ -15,7 +15,6 @@
#include "flang-rt/runtime/tools.h"
#include "flang-rt/runtime/type-info.h"
#include "flang-rt/runtime/work-queue.h"
-#include "flang/Runtime/stop.h"
namespace Fortran::runtime {
>From 6eeb10fcee7719bc45dd7090161a16e8904d693c Mon Sep 17 00:00:00 2001
From: agozillon <Andrew.Gozillon at amd.com>
Date: Mon, 11 Aug 2025 14:39:38 -0500
Subject: [PATCH 4/6] [Flang][Runtime] Fix the tools include header to
freestanding-tools
---
flang-rt/lib/runtime/copy.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/flang-rt/lib/runtime/copy.cpp b/flang-rt/lib/runtime/copy.cpp
index 545f31d3ee137..1db8962dad0d3 100644
--- a/flang-rt/lib/runtime/copy.cpp
+++ b/flang-rt/lib/runtime/copy.cpp
@@ -10,9 +10,10 @@
#include "stack.h"
#include "flang-rt/runtime/descriptor.h"
#include "flang-rt/runtime/terminator.h"
-#include "flang-rt/runtime/tools.h"
#include "flang-rt/runtime/type-info.h"
#include "flang/Runtime/allocatable.h"
+#include "flang/Runtime/freestanding-tools.h"
+
#include <cstring>
namespace Fortran::runtime {
>From 8d564a6b68d284e77fc87836be4f521d7794b2e6 Mon Sep 17 00:00:00 2001
From: agozillon <Andrew.Gozillon at amd.com>
Date: Thu, 14 Aug 2025 09:17:17 -0500
Subject: [PATCH 5/6] [Flang][OpenMP][Runtime] Add additional
RT_OFFLOAD_API_GROUP macros
---
flang-rt/lib/runtime/temporary-stack.cpp | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/flang-rt/lib/runtime/temporary-stack.cpp b/flang-rt/lib/runtime/temporary-stack.cpp
index 50270d797dbf0..49913f1252d8d 100644
--- a/flang-rt/lib/runtime/temporary-stack.cpp
+++ b/flang-rt/lib/runtime/temporary-stack.cpp
@@ -20,6 +20,8 @@ namespace {
using namespace Fortran::runtime;
+RT_OFFLOAD_API_GROUP_BEGIN
+
// the number of elements to allocate when first creating the vector
constexpr size_t INITIAL_ALLOC = 8;
@@ -181,8 +183,11 @@ inline static DescriptorStack *getDescriptorStorage(void *opaquePtr) {
return static_cast<DescriptorStack *>(opaquePtr);
}
+RT_OFFLOAD_API_GROUP_END
+
namespace Fortran::runtime {
extern "C" {
+RT_EXT_API_GROUP_BEGIN
void *RTNAME(CreateValueStack)(const char *sourceFile, int line) {
return ValueStack::allocate(sourceFile, line);
}
@@ -222,6 +227,6 @@ void RTNAME(DescriptorAt)(void *opaquePtr, uint64_t i, Descriptor &value) {
void RTNAME(DestroyDescriptorStack)(void *opaquePtr) {
DescriptorStack::destroy(getDescriptorStorage(opaquePtr));
}
-
+RT_EXT_API_GROUP_END
} // extern "C"
} // namespace Fortran::runtime
>From 0416575ba9ada7dd00e09c0fafc5339a88a32758 Mon Sep 17 00:00:00 2001
From: agozillon <Andrew.Gozillon at amd.com>
Date: Thu, 14 Aug 2025 09:21:15 -0500
Subject: [PATCH 6/6] [Flang][Runtime] Run Clang-format to reformat
---
flang-rt/include/flang-rt/runtime/format-implementation.h | 3 +--
flang-rt/include/flang-rt/runtime/tools.h | 3 +--
flang-rt/lib/runtime/array-constructor.cpp | 3 +--
flang-rt/lib/runtime/assign.cpp | 3 +--
flang-rt/lib/runtime/character.cpp | 3 +--
flang-rt/lib/runtime/extensions.cpp | 4 ++--
flang-rt/lib/runtime/stat.cpp | 3 +--
flang-rt/lib/runtime/tools.cpp | 6 ++----
flang-rt/lib/runtime/unit.cpp | 5 ++---
flang/include/flang/Runtime/freestanding-tools.h | 4 ++--
10 files changed, 14 insertions(+), 23 deletions(-)
diff --git a/flang-rt/include/flang-rt/runtime/format-implementation.h b/flang-rt/include/flang-rt/runtime/format-implementation.h
index 1275b4016d040..1c419b6c92a54 100644
--- a/flang-rt/include/flang-rt/runtime/format-implementation.h
+++ b/flang-rt/include/flang-rt/runtime/format-implementation.h
@@ -49,8 +49,7 @@ RT_API_ATTRS FormatControl<CONTEXT>::FormatControl(const Terminator &terminator,
SubscriptValue at[maxRank];
formatDescriptor->GetLowerBounds(at);
for (std::size_t j{0}; j < elements; ++j) {
- runtime::memcpy(
- p, formatDescriptor->Element<char>(at), elementBytes);
+ runtime::memcpy(p, formatDescriptor->Element<char>(at), elementBytes);
p += elementBytes;
formatDescriptor->IncrementSubscripts(at);
}
diff --git a/flang-rt/include/flang-rt/runtime/tools.h b/flang-rt/include/flang-rt/runtime/tools.h
index 97ef95298cfcf..60f0535f83bdf 100644
--- a/flang-rt/include/flang-rt/runtime/tools.h
+++ b/flang-rt/include/flang-rt/runtime/tools.h
@@ -561,8 +561,7 @@ RT_API_ATTRS void CopyAndPad(
} else if (toChars <= fromChars) {
runtime::memcpy(to, from, toChars * sizeof(TO));
} else {
- runtime::memcpy(
- to, from, std::min(toChars, fromChars) * sizeof(TO));
+ runtime::memcpy(to, from, std::min(toChars, fromChars) * sizeof(TO));
for (std::size_t j{fromChars}; j < toChars; ++j) {
to[j] = static_cast<TO>(' ');
}
diff --git a/flang-rt/lib/runtime/array-constructor.cpp b/flang-rt/lib/runtime/array-constructor.cpp
index 6c79b7b4bf3a7..9838c69ff1f9e 100644
--- a/flang-rt/lib/runtime/array-constructor.cpp
+++ b/flang-rt/lib/runtime/array-constructor.cpp
@@ -173,8 +173,7 @@ void RTDEF(PushArrayConstructorSimpleScalar)(
AllocateOrReallocateVectorIfNeeded(vector, terminator, to.Elements(), 1);
SubscriptValue subscript[1]{
to.GetDimension(0).LowerBound() + vector.nextValuePosition};
- runtime::memcpy(
- to.Element<char>(subscript), from, to.ElementBytes());
+ runtime::memcpy(to.Element<char>(subscript), from, to.ElementBytes());
++vector.nextValuePosition;
}
diff --git a/flang-rt/lib/runtime/assign.cpp b/flang-rt/lib/runtime/assign.cpp
index 1eeb70f4b7820..8773ae49c7b7f 100644
--- a/flang-rt/lib/runtime/assign.cpp
+++ b/flang-rt/lib/runtime/assign.cpp
@@ -298,8 +298,7 @@ RT_API_ATTRS int AssignTicket::Begin(WorkQueue &workQueue) {
auto descBytes{from_->SizeInBytes()};
Descriptor &newFrom{tempDescriptor_.descriptor()};
persist_ = true; // tempDescriptor_ state must outlive child tickets
- runtime::memcpy(
- reinterpret_cast<void *>(&newFrom), from_, descBytes);
+ runtime::memcpy(reinterpret_cast<void *>(&newFrom), from_, descBytes);
// Pretend the temporary descriptor is for an ALLOCATABLE
// entity, otherwise, the Deallocate() below will not
// free the descriptor memory.
diff --git a/flang-rt/lib/runtime/character.cpp b/flang-rt/lib/runtime/character.cpp
index f66d413d37b99..98a225dbec9f9 100644
--- a/flang-rt/lib/runtime/character.cpp
+++ b/flang-rt/lib/runtime/character.cpp
@@ -617,8 +617,7 @@ void RTDEF(CharacterConcatenate)(Descriptor &accumulator,
for (; elements-- > 0;
to += newBytes, p += oldBytes, from.IncrementSubscripts(fromAt)) {
runtime::memcpy(to, p, oldBytes);
- runtime::memcpy(
- to + oldBytes, from.Element<char>(fromAt), fromBytes);
+ runtime::memcpy(to + oldBytes, from.Element<char>(fromAt), fromBytes);
}
FreeMemory(old);
}
diff --git a/flang-rt/lib/runtime/extensions.cpp b/flang-rt/lib/runtime/extensions.cpp
index 7410ef2e4b6cd..4ccedc6d155c7 100644
--- a/flang-rt/lib/runtime/extensions.cpp
+++ b/flang-rt/lib/runtime/extensions.cpp
@@ -147,8 +147,8 @@ uid_t RTNAME(GetUID)() {
}
void GetUsernameEnvVar(const char *envName, char *arg, std::int64_t length) {
- Descriptor name{*Descriptor::Create(1, runtime::strlen(envName) + 1,
- const_cast<char *>(envName), 0)};
+ Descriptor name{*Descriptor::Create(
+ 1, runtime::strlen(envName) + 1, const_cast<char *>(envName), 0)};
Descriptor value{*Descriptor::Create(1, length, arg, 0)};
RTNAME(GetEnvVariable)
diff --git a/flang-rt/lib/runtime/stat.cpp b/flang-rt/lib/runtime/stat.cpp
index 285fc21972d8f..1d4aae2e49736 100644
--- a/flang-rt/lib/runtime/stat.cpp
+++ b/flang-rt/lib/runtime/stat.cpp
@@ -87,8 +87,7 @@ RT_API_ATTRS int ToErrmsg(const Descriptor *errmsg, int stat) {
runtime::memcpy(buffer, msg, bufferLength);
} else {
runtime::memcpy(buffer, msg, msgLength);
- runtime::memset(
- buffer + msgLength, ' ', bufferLength - msgLength);
+ runtime::memset(buffer + msgLength, ' ', bufferLength - msgLength);
}
}
}
diff --git a/flang-rt/lib/runtime/tools.cpp b/flang-rt/lib/runtime/tools.cpp
index 7f0fb4c3ac479..03ee982d913bb 100644
--- a/flang-rt/lib/runtime/tools.cpp
+++ b/flang-rt/lib/runtime/tools.cpp
@@ -150,8 +150,7 @@ RT_API_ATTRS void ShallowCopyDiscontiguousToContiguous(
for (std::size_t n{to.Elements()}; n-- > 0;
toAt += elementBytes, fromIt.Advance()) {
if constexpr (typeElementBytes != 1) {
- runtime::memcpy(
- toAt, fromIt.template Get<P>(), typeElementBytes);
+ runtime::memcpy(toAt, fromIt.template Get<P>(), typeElementBytes);
} else {
runtime::memcpy(toAt, fromIt.template Get<P>(), elementBytes);
}
@@ -171,8 +170,7 @@ RT_API_ATTRS void ShallowCopyContiguousToDiscontiguous(
for (std::size_t n{to.Elements()}; n-- > 0;
toIt.Advance(), fromAt += elementBytes) {
if constexpr (typeElementBytes != 1) {
- runtime::memcpy(
- toIt.template Get<P>(), fromAt, typeElementBytes);
+ runtime::memcpy(toIt.template Get<P>(), fromAt, typeElementBytes);
} else {
runtime::memcpy(toIt.template Get<P>(), fromAt, elementBytes);
}
diff --git a/flang-rt/lib/runtime/unit.cpp b/flang-rt/lib/runtime/unit.cpp
index efab5b6e1ba13..da3783417f234 100644
--- a/flang-rt/lib/runtime/unit.cpp
+++ b/flang-rt/lib/runtime/unit.cpp
@@ -90,9 +90,8 @@ bool ExternalFileUnit::Emit(const char *data, std::size_t bytes,
CheckDirectAccess(handler);
WriteFrame(frameOffsetInFile_, recordOffsetInFrame_ + furthestAfter, handler);
if (positionInRecord > furthestPositionInRecord) {
- runtime::memset(
- Frame() + recordOffsetInFrame_ + furthestPositionInRecord, ' ',
- positionInRecord - furthestPositionInRecord);
+ runtime::memset(Frame() + recordOffsetInFrame_ + furthestPositionInRecord,
+ ' ', positionInRecord - furthestPositionInRecord);
}
char *to{Frame() + recordOffsetInFrame_ + positionInRecord};
runtime::memcpy(to, data, bytes);
diff --git a/flang/include/flang/Runtime/freestanding-tools.h b/flang/include/flang/Runtime/freestanding-tools.h
index 0d48da9c1798f..c91f6d910c1c6 100644
--- a/flang/include/flang/Runtime/freestanding-tools.h
+++ b/flang/include/flang/Runtime/freestanding-tools.h
@@ -63,8 +63,8 @@
#define STD_TOUPPER_UNSUPPORTED 1
#endif
-#if defined(OMP_OFFLOAD_BUILD) && \
- defined(OMP_NOHOST_BUILD) && defined(__clang__)
+#if defined(OMP_OFFLOAD_BUILD) && defined(OMP_NOHOST_BUILD) && \
+ defined(__clang__)
#define STD_FILL_N_UNSUPPORTED 1
#define STD_MEMSET_USE_BUILTIN 1
#define STD_MEMSET_UNSUPPORTED 1
More information about the flang-commits
mailing list