Skip to content

Commit 7e7468c

Browse files
authored
Revert "[flang][runtime] Add ACCESS library procedure" (#88507)
Reverts #88395 This broke the powerpc buildbot. That build doesn't support using `std::filesystem` in flang unit tests.
1 parent f220d26 commit 7e7468c

File tree

5 files changed

+0
-479
lines changed

5 files changed

+0
-479
lines changed

flang/docs/Intrinsics.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -657,14 +657,6 @@ CALL CO_REDUCE
657657
CALL CO_SUM
658658
```
659659

660-
### Inquiry Functions
661-
ACCESS (GNU extension) is not supported on Windows. Otherwise:
662-
```
663-
CHARACTER(LEN=*) :: path = 'path/to/file'
664-
IF (ACCESS(path, 'rwx')) &
665-
...
666-
```
667-
668660
## Non-standard intrinsics
669661
### PGI
670662
```

flang/include/flang/Runtime/extensions.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,5 @@ std::int64_t RTNAME(Signal)(std::int64_t number, void (*handler)(int));
4444
// GNU extension subroutine SLEEP(SECONDS)
4545
void RTNAME(Sleep)(std::int64_t seconds);
4646

47-
// GNU extension function ACCESS(NAME, MODE)
48-
// TODO: not supported on Windows
49-
#ifndef _WIN32
50-
std::int64_t FORTRAN_PROCEDURE_NAME(access)(const char *name,
51-
std::int64_t nameLength, const char *mode, std::int64_t modeLength);
52-
#endif
53-
5447
} // extern "C"
5548
#endif // FORTRAN_RUNTIME_EXTENSIONS_H_

flang/runtime/extensions.cpp

Lines changed: 0 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#include "flang/Runtime/entry-names.h"
1818
#include "flang/Runtime/io-api.h"
1919
#include <chrono>
20-
#include <cstring>
2120
#include <ctime>
2221
#include <signal.h>
2322
#include <thread>
@@ -139,77 +138,5 @@ void RTNAME(Sleep)(std::int64_t seconds) {
139138
std::this_thread::sleep_for(std::chrono::seconds(seconds));
140139
}
141140

142-
// TODO: not supported on Windows
143-
#ifndef _WIN32
144-
std::int64_t FORTRAN_PROCEDURE_NAME(access)(const char *name,
145-
std::int64_t nameLength, const char *mode, std::int64_t modeLength) {
146-
std::int64_t ret{-1};
147-
if (nameLength <= 0 || modeLength <= 0 || !name || !mode) {
148-
return ret;
149-
}
150-
151-
// ensure name is null terminated
152-
char *newName{nullptr};
153-
if (name[nameLength - 1] != '\0') {
154-
newName = static_cast<char *>(std::malloc(nameLength + 1));
155-
std::memcpy(newName, name, nameLength);
156-
newName[nameLength] = '\0';
157-
name = newName;
158-
}
159-
160-
// calculate mode
161-
bool read{false};
162-
bool write{false};
163-
bool execute{false};
164-
bool exists{false};
165-
int imode{0};
166-
167-
for (std::int64_t i = 0; i < modeLength; ++i) {
168-
switch (mode[i]) {
169-
case 'r':
170-
read = true;
171-
break;
172-
case 'w':
173-
write = true;
174-
break;
175-
case 'x':
176-
execute = true;
177-
break;
178-
case ' ':
179-
exists = true;
180-
break;
181-
default:
182-
// invalid mode
183-
goto cleanup;
184-
}
185-
}
186-
if (!read && !write && !execute && !exists) {
187-
// invalid mode
188-
goto cleanup;
189-
}
190-
191-
if (!read && !write && !execute) {
192-
imode = F_OK;
193-
} else {
194-
if (read) {
195-
imode |= R_OK;
196-
}
197-
if (write) {
198-
imode |= W_OK;
199-
}
200-
if (execute) {
201-
imode |= X_OK;
202-
}
203-
}
204-
ret = access(name, imode);
205-
206-
cleanup:
207-
if (newName) {
208-
free(newName);
209-
}
210-
return ret;
211-
}
212-
#endif
213-
214141
} // namespace Fortran::runtime
215142
} // extern "C"

0 commit comments

Comments
 (0)