- use alternative to MAP_ANONYMOUS for allocating mapped memory if it isn't available
- Use strtok_r instead of strsep as part of getting program path
- Don't try to find the width of a terminal using "struct winsize" and TIOCGWINSZ on POSIX builds. These aren't defined under POSIX (even though some platforms make them available when they shouldn't), so just check if we are doing a X/Open or POSIX compliant build first.
Details
- Reviewers
hubert.reinterpretcast xingxue andusy - Commits
- rZORG9e28ecc634bc: Fixes for builds that require strict X/Open and POSIX compatiblity
rG9e28ecc634bc: Fixes for builds that require strict X/Open and POSIX compatiblity
rG2dee094a08ff: Fixes for builds that require strict X/Open and POSIX compatiblity
rL360898: Fixes for builds that require strict X/Open and POSIX compatiblity
Diff Detail
- Repository
- rL LLVM
Event Timeline
These are defined under POSIX
Do you mean that these aren't defined under POSIX?
llvm/lib/Support/Unix/Memory.inc | ||
---|---|---|
94 ↗ | (On Diff #197371) | <ins>On</ins><del>on</del> platforms that have it<ins>,</ins> we can use MAP_ANONYMOUS to get a memory<ins>-</ins>mapped page without file backing, but we need a fallback <del>by</del><ins>of</ins> opening /dev/zero for strictly POSIX platforms instead<ins>.</ins> |
97 ↗ | (On Diff #197371) | I would rather have fd assigned separately on each branch of the #if than to have the rest of the statement inside conditional inclusion blocks. |
102 ↗ | (On Diff #197371) | Add a space after ==. |
112 ↗ | (On Diff #197371) | To be consistent with the ifdef, this should be #elif defined(MAP_ANON). |
135 ↗ | (On Diff #197371) | The file descriptor returned by open and stored in fd is not closed on this path. |
llvm/lib/Support/Unix/Path.inc | ||
157 ↗ | (On Diff #197371) | Once assigned, s always has the same value as pv. Do we need s? |
161 ↗ | (On Diff #197371) | Add spaces after the commas in the argument list. |
167 ↗ | (On Diff #197371) | Add spaces after the commas in the argument list. |
llvm/lib/Support/Unix/Memory.inc | ||
---|---|---|
110 ↗ | (On Diff #197371) | I think you can just keep MAP_ANON and remove MAP_ANONYMOUS. Though marked as deprecated in Linux manpages, it is most widely used. It is also used by compiler-rt. |
llvm/lib/Support/Unix/Memory.inc | ||
---|---|---|
110 ↗ | (On Diff #197371) | You may need to rebase. I've deleted MAP_ANONYMOUS. |
- Address formatting comments
- Revert to using MAP_ANON
- Close the file descriptor on all return paths in Memory::allocateMappedMemory
- Cleanup the pointers we keep in getprogpath
llvm/lib/Support/Unix/Memory.inc | ||
---|---|---|
111 ↗ | (On Diff #197875) | I think using MMFlags |= MAP_ANON; will help readability/maintainability. |
146 ↗ | (On Diff #197875) | If it's okay to close the file here, then it is okay to close the file right after the call to mmap before checking whether mmap failed. We would only need to add one call to close (instead of three). |
llvm/lib/Support/Unix/Path.inc | ||
156 ↗ | (On Diff #197875) | If we're going to move where the pv, etc. is declared, then we might as well move the declaration of s to this line... |
160 ↗ | (On Diff #197875) | ... and declare t in the if: if (char *t = strtok_r(s, ":", &state)) { |
llvm/lib/Support/Unix/Memory.inc | ||
---|---|---|
146 ↗ | (On Diff #197875) | If we close right after mmap, that would technically render the value of errno undefined or clobber it, and we may need to inspect it if the mmap failed (and according to spec we should only manipulate it if mmap failed) |
llvm/lib/Support/Unix/Path.inc | ||
---|---|---|
160 ↗ | (On Diff #199115) | Yes it does. Can you clarify? |