Skip to content

[compiler-rt] Use signal on Windows #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions compiler-rt/lib/profile/InstrProfilingFile.c
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,18 @@ static void exitSignalHandler(int sig) {
exit(0);
}

#if defined(_WIN32)
// sigaction isn't available on Windows, so just use signal.
static void installExitSignalHandlers(void) {
unsigned I;
for (I = 0; I < lprofCurFilename.NumExitSignals; ++I) {
if (signal(lprofCurFilename.ExitOnSignals[I], exitSignalHandler) == SIG_ERR)
PROF_WARN(
"Unable to install an exit signal handler for %d (errno = %d).\n",
lprofCurFilename.ExitOnSignals[I], errno);
}
}
#else
static void installExitSignalHandlers(void) {
unsigned I;
struct sigaction sigact;
Expand All @@ -380,6 +392,7 @@ static void installExitSignalHandlers(void) {
lprofCurFilename.ExitOnSignals[I], err);
}
}
#endif

static const char *DefaultProfileName = "default.profraw";
static void resetFilenameToDefault(void) {
Expand Down