Files
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

167 lines
5.2 KiB
C++

//===-- lib/runtime/pseudo-unit.cpp -----------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// Implemenation of ExternalFileUnit and PseudoOpenFile for
// RT_USE_PSEUDO_FILE_UNIT=1.
//
//===----------------------------------------------------------------------===//
#include "unit.h"
#include "flang-rt/runtime/io-error.h"
#include "flang-rt/runtime/tools.h"
#if defined(RT_USE_PSEUDO_FILE_UNIT)
#include <cstdio>
namespace Fortran::runtime::io {
void FlushOutputOnCrash(const Terminator &) {}
ExternalFileUnit *ExternalFileUnit::LookUp(int, Terminator &terminator) {
terminator.Crash("%s: unsupported", RT_PRETTY_FUNCTION);
}
ExternalFileUnit *ExternalFileUnit::LookUpOrCreate(
int, const Terminator &terminator, bool &) {
terminator.Crash("%s: unsupported", RT_PRETTY_FUNCTION);
}
ExternalFileUnit *ExternalFileUnit::LookUpOrCreateAnonymous(int unit,
Direction direction, common::optional<bool>, IoErrorHandler &handler) {
if (direction != Direction::Output || unit != 6) {
handler.Crash("ExternalFileUnit only supports output to unit 6");
}
// The pseudo-unit allocated here will be released in
// ExternalIoStatementBase::EndIoStatement().
return New<ExternalFileUnit>{handler}(unit).release();
}
ExternalFileUnit *ExternalFileUnit::LookUp(
const char *, std::size_t, Terminator &terminator) {
terminator.Crash("%s: unsupported", RT_PRETTY_FUNCTION);
}
ExternalFileUnit &ExternalFileUnit::CreateNew(
int, const Terminator &terminator) {
terminator.Crash("%s: unsupported", RT_PRETTY_FUNCTION);
}
ExternalFileUnit *ExternalFileUnit::LookUpForClose(
int, Terminator &terminator) {
terminator.Crash("%s: unsupported", RT_PRETTY_FUNCTION);
}
ExternalFileUnit &ExternalFileUnit::NewUnit(
const Terminator &terminator, bool) {
terminator.Crash("%s: unsupported", RT_PRETTY_FUNCTION);
}
bool ExternalFileUnit::OpenUnit(common::optional<OpenStatus> status,
common::optional<Action>, Position, OwningPtr<char> &&, std::size_t,
Convert, IoErrorHandler &handler) {
handler.Crash("%s: unsupported", RT_PRETTY_FUNCTION);
}
bool ExternalFileUnit::OpenAnonymousUnit(common::optional<OpenStatus>,
common::optional<Action>, Position, Convert convert,
IoErrorHandler &handler) {
handler.Crash("%s: unsupported", RT_PRETTY_FUNCTION);
}
void ExternalFileUnit::CloseUnit(CloseStatus, IoErrorHandler &handler) {
handler.Crash("%s: unsupported", RT_PRETTY_FUNCTION);
}
void ExternalFileUnit::DestroyClosed(Terminator &terminator) {
terminator.Crash("%s: unsupported", RT_PRETTY_FUNCTION);
}
Iostat ExternalFileUnit::SetDirection(Direction direction) {
if (direction != Direction::Output) {
return IostatReadFromWriteOnly;
}
direction_ = direction;
return IostatOk;
}
void ExternalFileUnit::CloseAll(IoErrorHandler &) {}
void ExternalFileUnit::FlushAll(IoErrorHandler &) {}
int ExternalFileUnit::GetAsynchronousId(IoErrorHandler &handler) {
handler.Crash("%s: unsupported", RT_PRETTY_FUNCTION);
}
bool ExternalFileUnit::Wait(int) {
Terminator{__FILE__, __LINE__}.Crash("unsupported");
}
void PseudoOpenFile::set_mayAsynchronous(bool yes) {
if (yes) {
Terminator{__FILE__, __LINE__}.Crash("%s: unsupported", RT_PRETTY_FUNCTION);
}
}
common::optional<PseudoOpenFile::FileOffset> PseudoOpenFile::knownSize() const {
Terminator{__FILE__, __LINE__}.Crash("unsupported");
}
void PseudoOpenFile::Open(
OpenStatus, common::optional<Action>, Position, IoErrorHandler &handler) {
handler.Crash("%s: unsupported", RT_PRETTY_FUNCTION);
}
void PseudoOpenFile::Close(CloseStatus, IoErrorHandler &handler) {
handler.Crash("%s: unsupported", RT_PRETTY_FUNCTION);
}
std::size_t PseudoOpenFile::Read(
FileOffset, char *, std::size_t, std::size_t, IoErrorHandler &handler) {
handler.Crash("%s: unsupported", RT_PRETTY_FUNCTION);
}
std::size_t PseudoOpenFile::Write(FileOffset at, const char *buffer,
std::size_t bytes, IoErrorHandler &handler) {
char *mutableBuffer{const_cast<char *>(buffer)};
char save{buffer[bytes]};
mutableBuffer[bytes] = '\0';
std::printf("%s", buffer);
mutableBuffer[bytes] = save;
return bytes;
}
void PseudoOpenFile::Truncate(FileOffset, IoErrorHandler &handler) {
handler.Crash("%s: unsupported", RT_PRETTY_FUNCTION);
}
int PseudoOpenFile::ReadAsynchronously(
FileOffset, char *, std::size_t, IoErrorHandler &handler) {
handler.Crash("%s: unsupported", RT_PRETTY_FUNCTION);
}
int PseudoOpenFile::WriteAsynchronously(
FileOffset, const char *, std::size_t, IoErrorHandler &handler) {
handler.Crash("%s: unsupported", RT_PRETTY_FUNCTION);
}
void PseudoOpenFile::Wait(int, IoErrorHandler &handler) {
handler.Crash("%s: unsupported", RT_PRETTY_FUNCTION);
}
void PseudoOpenFile::WaitAll(IoErrorHandler &handler) {
handler.Crash("%s: unsupported", RT_PRETTY_FUNCTION);
}
Position PseudoOpenFile::InquirePosition(FileOffset) const {
Terminator{__FILE__, __LINE__}.Crash("%s: unsupported", RT_PRETTY_FUNCTION);
}
} // namespace Fortran::runtime::io
#endif // defined(RT_USE_PSEUDO_FILE_UNIT)