This is an archive of the discontinued LLVM Phabricator instance.

[libc] Add POSIX close, fsync, open, read and write functions.
ClosedPublic

Authored by sivachandra on Jan 27 2022, 9:52 AM.

Details

Summary

They are implemented as simple syscall wrappers. The file creation
macros have been put in a header file as a temporary solution until we
have a cleaner approach to listing platform relevant macros.

Diff Detail

Event Timeline

sivachandra created this revision.Jan 27 2022, 9:52 AM
sivachandra requested review of this revision.Jan 27 2022, 9:52 AM
abrachet accepted this revision.Jan 27 2022, 11:03 AM
abrachet added inline comments.
libc/include/llvm-libc-macros/linux/fcntl-macros.h
2

With errno we just include linux/errno.h can we use linux/fcntl.h?

This revision is now accepted and ready to land.Jan 27 2022, 11:03 AM
sivachandra added inline comments.Jan 27 2022, 12:16 PM
libc/include/llvm-libc-macros/linux/fcntl-macros.h
2

I think, including linux headers was an error on our part. Primary reason is that the linux headers bring in more names and pollute the user namespace. I think there are ways to avoid this hard-coding as done in this patch, but I will propose that in a follow up patch.

This revision was landed with ongoing or failed builds.Jan 27 2022, 12:32 PM
This revision was automatically updated to reflect the committed changes.
libc/test/src/unistd/read_write_test.cpp