[NFC][sanitizer] Reorder functions in cpp file

This commit is contained in:
Vitaly Buka 2021-12-02 13:27:11 -08:00
parent 1f2492b7da
commit 3195610b2d
1 changed files with 20 additions and 20 deletions

View File

@ -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.
@ -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;