Skip to content

Commit 0730df4

Browse files
nickdesaulniersBaiXilin
authored andcommitted
[libc][test] remove C++ stdlib includes (llvm#122369)
These make cross compiling the test suite more difficult, as you need the sysroot to contain these headers and libraries cross compiled for your target. It's straightforward to stick with the corresponding C headers.
1 parent cd02b86 commit 0730df4

File tree

3 files changed

+12
-14
lines changed

3 files changed

+12
-14
lines changed

libc/test/UnitTest/ExecuteFunctionUnix.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88

99
#include "ExecuteFunction.h"
1010
#include "src/__support/macros/config.h"
11-
#include <cassert>
12-
#include <cstdlib>
13-
#include <cstring>
14-
#include <iostream>
15-
#include <memory>
11+
#include "test/UnitTest/ExecuteFunction.h" // FunctionCaller
12+
#include <assert.h>
1613
#include <poll.h>
1714
#include <signal.h>
15+
#include <stdio.h>
16+
#include <stdlib.h>
17+
#include <string.h>
1818
#include <sys/wait.h>
1919
#include <unistd.h>
2020

@@ -35,21 +35,20 @@ int ProcessStatus::get_fatal_signal() {
3535
}
3636

3737
ProcessStatus invoke_in_subprocess(FunctionCaller *func, unsigned timeout_ms) {
38-
std::unique_ptr<FunctionCaller> X(func);
3938
int pipe_fds[2];
4039
if (::pipe(pipe_fds) == -1)
4140
return ProcessStatus::error("pipe(2) failed");
4241

4342
// Don't copy the buffers into the child process and print twice.
44-
std::cout.flush();
45-
std::cerr.flush();
43+
::fflush(stderr);
44+
::fflush(stdout);
4645
pid_t pid = ::fork();
4746
if (pid == -1)
4847
return ProcessStatus::error("fork(2) failed");
4948

5049
if (!pid) {
5150
(*func)();
52-
std::exit(0);
51+
::exit(0);
5352
}
5453
::close(pipe_fds[1]);
5554

libc/test/UnitTest/FPExceptMatcher.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
#include "FPExceptMatcher.h"
1010

1111
#include "src/__support/macros/config.h"
12+
#include "test/UnitTest/ExecuteFunction.h" // FunctionCaller
1213
#include "test/UnitTest/Test.h"
1314

1415
#include "hdr/types/fenv_t.h"
1516
#include "src/__support/FPUtil/FEnvImpl.h"
16-
#include <memory>
1717
#include <setjmp.h>
1818
#include <signal.h>
1919

@@ -37,14 +37,13 @@ static void sigfpeHandler(int sig) {
3737
}
3838

3939
FPExceptMatcher::FPExceptMatcher(FunctionCaller *func) {
40-
auto oldSIGFPEHandler = signal(SIGFPE, &sigfpeHandler);
41-
std::unique_ptr<FunctionCaller> funcUP(func);
40+
sighandler_t oldSIGFPEHandler = signal(SIGFPE, &sigfpeHandler);
4241

4342
caughtExcept = false;
4443
fenv_t oldEnv;
4544
fputil::get_env(&oldEnv);
4645
if (sigsetjmp(jumpBuffer, 1) == 0)
47-
funcUP->call();
46+
func->call();
4847
// We restore the previous floating point environment after
4948
// the call to the function which can potentially raise SIGFPE.
5049
fputil::set_env(&oldEnv);

libc/test/UnitTest/LibcDeathTestExecutors.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include "test/UnitTest/ExecuteFunction.h"
1313
#include "test/UnitTest/TestLogger.h"
1414

15-
#include <cassert>
15+
#include <assert.h>
1616

1717
namespace {
1818
constexpr unsigned TIMEOUT_MS = 10000;

0 commit comments

Comments
 (0)