Skip to content

Commit

Permalink
[NFC][sanitizer] Reorder functions in cpp file
Browse files Browse the repository at this point in the history
  • Loading branch information
vitalybuka committed Dec 2, 2021
1 parent 1f2492b commit 3195610
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cpp
Expand Up @@ -86,26 +86,6 @@ void *BackgroundThread(void *arg) {
}
#endif

void WriteToSyslog(const char *msg) {
InternalScopedString msg_copy;
msg_copy.append("%s", msg);
const char *p = msg_copy.data();

// Print one line at a time.
// syslog, at least on Android, has an implicit message length limit.
while (char* q = internal_strchr(p, '\n')) {
*q = '\0';
WriteOneLineToSyslog(p);
p = q + 1;
}
// Print remaining characters, if there are any.
// Note that this will add an extra newline at the end.
// FIXME: buffer extra output. This would need a thread-local buffer, which
// on Android requires plugging into the tools (ex. ASan's) Thread class.
if (*p)
WriteOneLineToSyslog(p);
}

void MaybeStartBackgroudThread() {
#if (SANITIZER_LINUX || SANITIZER_NETBSD) && \
!SANITIZER_GO // Need to implement/test on other platforms.
Expand All @@ -126,6 +106,26 @@ void MaybeStartBackgroudThread() {
#endif
}

void WriteToSyslog(const char *msg) {
InternalScopedString msg_copy;
msg_copy.append("%s", msg);
const char *p = msg_copy.data();

// Print one line at a time.
// syslog, at least on Android, has an implicit message length limit.
while (char* q = internal_strchr(p, '\n')) {
*q = '\0';
WriteOneLineToSyslog(p);
p = q + 1;
}
// Print remaining characters, if there are any.
// Note that this will add an extra newline at the end.
// FIXME: buffer extra output. This would need a thread-local buffer, which
// on Android requires plugging into the tools (ex. ASan's) Thread class.
if (*p)
WriteOneLineToSyslog(p);
}

static void (*sandboxing_callback)();
void SetSandboxingCallback(void (*f)()) {
sandboxing_callback = f;
Expand Down

0 comments on commit 3195610

Please sign in to comment.