[libc-commits] [PATCH] D77626: [libc] Add very basic stdio FILE and fwrite

Siva Chandra via Phabricator via libc-commits libc-commits at lists.llvm.org
Mon Apr 13 22:46:59 PDT 2020


sivachandra accepted this revision.
sivachandra marked an inline comment as done.
sivachandra added inline comments.
This revision is now accepted and ready to land.


================
Comment at: libc/src/stdio/FILE.h:17
+
+// TOOD: This should return ssize_t but it's defined in sys/types.h
+using write_function_t = size_t(void *, const char *, size_t);
----------------
abrachet wrote:
> sivachandra wrote:
> > We probably want to avoid dependence on `sys/types.h` here to keep the definition of `FILE` platform independent. See my other comment below.
> `ssize_t` is what `cookie_write_function_t` returns and this is defined in sys/types.h. The idea is that `write(2)` returns that I believe. I've removed that TODO for now.
SG. AFAIK, `write` is not a std C function so handling all such functions outside of this common struct SGTM.


================
Comment at: libc/src/stdio/fwrite.h:17
+
+size_t fwrite_unlocked(const void *__restrict ptr, size_t size, size_t nmeb,
+                       FILE *__restrict stream);
----------------
abrachet wrote:
> sivachandra wrote:
> > Asking for my own knowledge: when/where would an internal unlock version be useful?
> Possibly in functions like `printf` which might have separated writes but the stream would need to remain locked to make sure it is written continuously. This may not be ever called internally though. Should I remove its prototype from the internal header?
Sorry, I missed this previously. Going by the spirit of "unless required", probably a good idea to take this and the implementation off?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D77626/new/

https://reviews.llvm.org/D77626





More information about the libc-commits mailing list