This is an archive of the discontinued LLVM Phabricator instance.

[libc++] Adjust how we guard the inclusion of unistd.h
ClosedPublic

Authored by john.brawn on May 12 2020, 6:58 AM.

Details

Summary

unistd.h isn't guaranteed to exist when the target isn't Windows, in particular if the target is bare-metal (i.e. no operating system). Handle this by using __has_include instead, though in filesystem/operations.cpp we already unconditionally include it so just remove the extra include.

Diff Detail

Event Timeline

john.brawn created this revision.May 12 2020, 6:58 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 12 2020, 6:58 AM
Herald added a reviewer: Restricted Project. · View Herald Transcript
ldionne requested changes to this revision.May 12 2020, 7:39 AM
ldionne added inline comments.
libcxx/include/__config
1556

Naive question: why not use __has_include?

libcxx/src/filesystem/operations.cpp
40

You're not including it anymore?

This revision now requires changes to proceed.May 12 2020, 7:39 AM
LittleFox94 added inline comments.May 12 2020, 7:55 AM
libcxx/src/filesystem/operations.cpp
40

It's done unconditionally in line 22

ldionne added inline comments.May 12 2020, 9:44 AM
libcxx/src/filesystem/operations.cpp
40

Good catch!

john.brawn marked an inline comment as done.May 13 2020, 5:26 AM
john.brawn added inline comments.
libcxx/include/__config
1556

Because I didn't know about it. Looks like all the compiler version we support (in llvm/cmake/modules/CheckCompilerVersion.cmake) implement it, so it makes sense to use it.

john.brawn edited the summary of this revision. (Show Details)
ldionne accepted this revision.May 13 2020, 9:55 AM
This revision is now accepted and ready to land.May 13 2020, 9:55 AM
This revision was automatically updated to reflect the committed changes.