Summary: This, as far as I am aware, has mostly been superceded by the runtimes build that's built on top of libc. This build links 30% faster, supports more functionality, and uses 95% less disk space, so it seems to be the direction we want to go. CUDA support remains, this is not needed urgently.
167 lines
5.2 KiB
C++
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)
|