20
20
#include < cstdlib>
21
21
#include < cstring>
22
22
23
+ #include " absl/base/attributes.h"
23
24
#include " absl/base/config.h"
24
25
#include " absl/base/internal/atomic_hook.h"
25
26
#include " absl/base/log_severity.h"
35
36
// This preprocessor token is also defined in raw_io.cc. If you need to copy
36
37
// this, consider moving both to config.h instead.
37
38
#if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || \
38
- defined (__Fuchsia__)
39
+ defined (__Fuchsia__) || defined(__native_client__)
39
40
#include < unistd.h>
40
41
41
42
@@ -81,6 +82,8 @@ static const char kTruncated[] = " ... (message truncated)\n";
81
82
// consumed bytes, and return whether the message fit without truncation. If
82
83
// truncation occurred, if possible leave room in the buffer for the message
83
84
// kTruncated[].
85
+ inline static bool VADoRawLog (char ** buf, int * size, const char * format,
86
+ va_list ap) ABSL_PRINTF_ATTRIBUTE(3 , 0 );
84
87
inline static bool VADoRawLog (char ** buf, int * size,
85
88
const char * format, va_list ap) {
86
89
int n = vsnprintf (*buf, *size, format, ap);
@@ -101,12 +104,6 @@ inline static bool VADoRawLog(char** buf, int* size,
101
104
102
105
static constexpr int kLogBufSize = 3000 ;
103
106
104
- namespace absl {
105
- namespace raw_logging_internal {
106
- void SafeWriteToStderr (const char *s, size_t len);
107
- } // namespace raw_logging_internal
108
- } // namespace absl
109
-
110
107
namespace {
111
108
112
109
// CAVEAT: vsnprintf called from *DoRawLog below has some (exotic) code paths
@@ -128,6 +125,8 @@ bool DoRawLog(char** buf, int* size, const char* format, ...) {
128
125
return true ;
129
126
}
130
127
128
+ void RawLogVA (absl::LogSeverity severity, const char * file, int line,
129
+ const char * format, va_list ap) ABSL_PRINTF_ATTRIBUTE(4 , 0 );
131
130
void RawLogVA (absl::LogSeverity severity, const char * file, int line,
132
131
const char * format, va_list ap) {
133
132
char buffer[kLogBufSize ];
@@ -183,12 +182,6 @@ void RawLogVA(absl::LogSeverity severity, const char* file, int line,
183
182
184
183
namespace absl {
185
184
namespace raw_logging_internal {
186
-
187
- // Writes the provided buffer directly to stderr, in a safe, low-level manner.
188
- //
189
- // In POSIX this means calling write(), which is async-signal safe and does
190
- // not malloc. If the platform supports the SYS_write syscall, we invoke that
191
- // directly to side-step any libc interception.
192
185
void SafeWriteToStderr (const char *s, size_t len) {
193
186
#if defined(ABSL_HAVE_SYSCALL_WRITE)
194
187
syscall (SYS_write, STDERR_FILENO, s, len);
@@ -203,6 +196,8 @@ void SafeWriteToStderr(const char *s, size_t len) {
203
196
#endif
204
197
}
205
198
199
+ void RawLog (absl::LogSeverity severity, const char * file, int line,
200
+ const char * format, ...) ABSL_PRINTF_ATTRIBUTE(4 , 5 );
206
201
void RawLog (absl::LogSeverity severity, const char * file, int line,
207
202
const char * format, ...) {
208
203
va_list ap;
0 commit comments