12#ifndef FORTRAN_RUNTIME_UNIT_MAP_H_
13#define FORTRAN_RUNTIME_UNIT_MAP_H_
17#include "flang/Common/fast-int-set.h"
18#include "flang/Runtime/memory.h"
22namespace Fortran::runtime::io {
32 int n,
const Terminator &terminator,
bool &wasExtant) {
34 if (
auto *p{Find(n)}) {
39 return n >= 0 ? &Create(n, terminator) :
nullptr;
46 return Find(path, pathLen);
61 explicit Chain(
int n) : unit{n} {}
66 static constexpr int buckets_{1031};
70 static constexpr int maxNewUnits_{129};
72 int Hash(
int n) {
return std::abs(n) % buckets_; }
77 Chain *previous{
nullptr};
79 for (Chain *p{bucket_[hash].get()}; p; previous = p, p = p->next.get()) {
80 if (p->unit.unitNumber() == n) {
83 previous->next.swap(p->next);
84 bucket_[hash].swap(p->next);
96 bool isInitialized_{
false};
100 int emergencyNewUnit_{maxNewUnits_};
Definition: fast-int-set.h:31
Definition: terminator.h:23
Definition: io-error.h:26
Definition: unit-map.h:24