[libc-commits] [libc] [libc] Support _IONBF buffering for read_unlocked (PR #120677)

Michael Jones via libc-commits libc-commits at lists.llvm.org
Mon Jan 6 14:34:44 PST 2025


================
@@ -190,6 +190,17 @@ FileIOResult File::read_unlocked(void *data, size_t len) {
 
   prev_op = FileOp::READ;
 
+  if (bufmode == _IONBF) { // unbuffered.
+    return read_unlocked_nbf(static_cast<uint8_t *>(data), len);
+  } else if (bufmode == _IOFBF) { // fully buffered
+    return read_unlocked_fbf(static_cast<uint8_t *>(data), len);
+  } else /*if (bufmode == _IOLBF) */ { // line buffered
+    // There is no line buffered mode for read. Use fully buffer instead.
+    return read_unlocked_fbf(static_cast<uint8_t *>(data), len);
+  }
+}
+
+FileIOResult File::copy_data_from_buf(uint8_t *data, size_t len) {
----------------
michaelrj-google wrote:

since this can't ever return an error, this should return `size_t` instead of `FileIOResult`.

https://github.com/llvm/llvm-project/pull/120677


More information about the libc-commits mailing list