[libc-commits] [PATCH] D151282: [libc] Add initial support for 'puts' and 'fputs' to the GPU
Siva Chandra via Phabricator via libc-commits
libc-commits at lists.llvm.org
Fri Jun 2 17:23:15 PDT 2023
sivachandra added inline comments.
================
Comment at: libc/src/__support/File/file.cpp:28
- if (bufmode == _IOFBF) { // fully buffered
+ if (ENABLE_BUFFER && bufmode == _IOFBF) { // fully buffered
return write_unlocked_fbf(static_cast<const uint8_t *>(data), len);
----------------
Can we repeat the order of conditionals so that the `ENABLE_BUFFER` is checked only once:
```
if (!ENABLE_BUFFER || bufmode == _IONBF) {
...
} else if (bufmode =_ _IOFBF) {
...
} else { // if (bufmode == _IOLBF)
...
}
```
================
Comment at: libc/src/__support/File/file.cpp:327
int File::flush_unlocked() {
+ if (ENABLE_BUFFER && prev_op == FileOp::WRITE && pos > 0) {
----------------
Can we do an early return:
```
if constexpr (!ENABLE_BUFFER)
return;
```
================
Comment at: libc/src/__support/File/file.cpp:341
int File::set_buffer(void *buffer, size_t size, int buffer_mode) {
// We do not need to lock the file as this method should be called before
----------------
Same here:
```
if constexpr (!ENABLE_BUFFER)
return;
```
================
Comment at: libc/src/__support/File/gpu/dir.cpp:16
+ErrorOr<int> platform_opendir(const char *name) {
+ return __llvm_libc::Error(-1);
+}
----------------
If they are just erroring out, why are they required?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D151282/new/
https://reviews.llvm.org/D151282
More information about the libc-commits
mailing list