This is an archive of the discontinued LLVM Phabricator instance.

[Support][AIX] Implement wait4 wrapper to fix build
ClosedPublic

Authored by hubert.reinterpretcast on Jun 21 2020, 9:24 PM.

Details

Summary

While wait4 is not documented for AIX, it is available; however, even on systems where it is available, the system headers do not always provide a declaration of the function.

This patch firstly provides a declaration of wait4 for AIX. Secondly, it provides a wrapper for wait4 to work around issues that occur when using it directly with WNOHANG.

Diff Detail

Event Timeline

sepavloff created this revision.Jun 21 2020, 9:24 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 21 2020, 9:24 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
llvm/lib/Support/Unix/Program.inc
332

Is this meant to protect against wait4 as a function-like macro or also as an object-like macro? If the former, an alternate approach (see comment below) would work.

333

I asked around and the kwaitpid interface may be subject to change.

I was told that wait4 is actually available (just not listed in the documentation), and I was able to find the symbol in the system libc. Declaring the signature below with extern "C" should be enough.

If you prefer, I will put that fix in. Please let me know; thanks.

335

To avoid interpretation of wait4 as a function-like macro, it can be placed in parentheses: (wait4).

sepavloff marked 3 inline comments as done.Jun 22 2020, 10:40 AM

Could you please select 'Commandeer Revision' in the 'Add Action' field? You will be able to rule this patch.

llvm/lib/Support/Unix/Program.inc
332

Yes, it is protection against definition of wait4 as a macro. Such conflicts may give weird diagnostics.

333

Yes, please. I don't have access to AIX and cannot check patch.

335

Interesting solution, thank you!

hubert.reinterpretcast edited reviewers, added: sepavloff; removed: hubert.reinterpretcast.
hubert.reinterpretcast marked an inline comment as done.
hubert.reinterpretcast added inline comments.
llvm/lib/Support/Unix/Program.inc
333

Got it; working on it.

Add declaration of wait4 to fix AIX build

hubert.reinterpretcast marked 3 inline comments as done.Jun 22 2020, 1:39 PM
hubert.reinterpretcast retitled this revision from [AIX] Implement wait4 to [Support][AIX] Add declaration of wait4 to fix build.
hubert.reinterpretcast edited the summary of this revision. (Show Details)
daltenty accepted this revision.Jun 22 2020, 4:13 PM

LGTM apart from minor nit

llvm/lib/Support/Unix/Program.inc
332

nit: should this be #if defined(_AIX) && !defined(_ALL_SOURCE), we'd actually get this definition if we weren't in a POSIX compliant mode

This revision is now accepted and ready to land.Jun 22 2020, 4:13 PM
llvm/lib/Support/Unix/Program.inc
374

Got a build, but it hangs. Will need to check this loop.

[ RUN      ] ProgramEnvTest.TestExecuteNoWait
Note: Google Test filter = ProgramEnvTest.TestExecuteNoWait
[==========] Running 1 test from 1 test case.
[----------] Global test environment set-up.
[----------] 1 test from ProgramEnvTest
[ RUN      ] ProgramEnvTest.TestExecuteNoWait
Note: Google Test filter = ProgramEnvTest.TestExecuteNoWait
[==========] Running 1 test from 1 test case.
[----------] Global test environment set-up.
[----------] 1 test from ProgramEnvTest
[ RUN      ] ProgramEnvTest.TestExecuteNoWait
hubert.reinterpretcast marked an inline comment as done.Jun 22 2020, 9:45 PM
hubert.reinterpretcast added inline comments.
llvm/lib/Support/Unix/Program.inc
374

AIX wait4 does not seem to work with WNOHANG. Attempting workaround...

hubert.reinterpretcast planned changes to this revision.Jun 23 2020, 6:09 AM
hubert.reinterpretcast marked an inline comment as done.
hubert.reinterpretcast marked 2 inline comments as done.
hubert.reinterpretcast edited the summary of this revision. (Show Details)
  • Implement wait4 wrapper for WNOHANG
This revision is now accepted and ready to land.Jun 25 2020, 5:53 AM
daltenty accepted this revision.Jun 25 2020, 7:50 AM

Confirming wrapper LGTM

This revision was automatically updated to reflect the committed changes.
hubert.reinterpretcast retitled this revision from [Support][AIX] Add declaration of wait4 to fix build to [Support][AIX] Implement wait4 wrapper to fix build.Jun 25 2020, 1:23 PM
hubert.reinterpretcast edited the summary of this revision. (Show Details)