Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/pytorch/cpuinfo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarat Dukhan <maratek@google.com>2022-07-08 01:25:53 +0300
committerGitHub <noreply@github.com>2022-07-08 01:25:53 +0300
commit4b5a76c4de21265ddba98fc8f259e136ad11411b (patch)
treec2bb3177abbb6b0ea4b61ab9132d262ecb9bdca1
parent44d0af8714b00ece01195153364f442cb64fa44d (diff)
Make clog compatible with Hexagon toolchain (#95)
Hexagon OS (QuOS) doesn't support POSIX write API, but expose a printf-like API for error logging. Switch to use it on Hexagon targets.
-rw-r--r--deps/clog/src/clog.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/deps/clog/src/clog.c b/deps/clog/src/clog.c
index fe5d43e..27658f9 100644
--- a/deps/clog/src/clog.c
+++ b/deps/clog/src/clog.c
@@ -10,6 +10,9 @@
#ifdef __ANDROID__
#include <android/log.h>
#endif
+#ifdef __hexagon__
+ #include <qurt_printf.h>
+#endif
#ifndef CLOG_LOG_TO_STDIO
#ifdef __ANDROID__
@@ -102,12 +105,14 @@ void clog_vlog_fatal(const char* module, const char* format, va_list args) {
out_buffer = heap_buffer;
}
out_buffer[prefix_chars + format_chars] = '\n';
- #ifdef _WIN32
+ #if defined(_WIN32)
DWORD bytes_written;
WriteFile(
GetStdHandle(STD_ERROR_HANDLE),
out_buffer, prefix_chars + format_chars + CLOG_SUFFIX_LENGTH,
&bytes_written, NULL);
+ #elif defined(__hexagon__)
+ qurt_printf("%s", out_buffer);
#else
write(STDERR_FILENO, out_buffer, prefix_chars + format_chars + CLOG_SUFFIX_LENGTH);
#endif
@@ -178,12 +183,14 @@ void clog_vlog_error(const char* module, const char* format, va_list args) {
out_buffer = heap_buffer;
}
out_buffer[prefix_chars + format_chars] = '\n';
- #ifdef _WIN32
+ #if defined(_WIN32)
DWORD bytes_written;
WriteFile(
GetStdHandle(STD_ERROR_HANDLE),
out_buffer, prefix_chars + format_chars + CLOG_SUFFIX_LENGTH,
&bytes_written, NULL);
+ #elif defined(__hexagon__)
+ qurt_printf("%s", out_buffer);
#else
write(STDERR_FILENO, out_buffer, prefix_chars + format_chars + CLOG_SUFFIX_LENGTH);
#endif
@@ -254,12 +261,14 @@ void clog_vlog_warning(const char* module, const char* format, va_list args) {
out_buffer = heap_buffer;
}
out_buffer[prefix_chars + format_chars] = '\n';
- #ifdef _WIN32
+ #if defined(_WIN32)
DWORD bytes_written;
WriteFile(
GetStdHandle(STD_ERROR_HANDLE),
out_buffer, prefix_chars + format_chars + CLOG_SUFFIX_LENGTH,
&bytes_written, NULL);
+ #elif defined(__hexagon__)
+ qurt_printf("%s", out_buffer);
#else
write(STDERR_FILENO, out_buffer, prefix_chars + format_chars + CLOG_SUFFIX_LENGTH);
#endif
@@ -330,12 +339,14 @@ void clog_vlog_info(const char* module, const char* format, va_list args) {
out_buffer = heap_buffer;
}
out_buffer[prefix_chars + format_chars] = '\n';
- #ifdef _WIN32
+ #if defined(_WIN32)
DWORD bytes_written;
WriteFile(
GetStdHandle(STD_OUTPUT_HANDLE),
out_buffer, prefix_chars + format_chars + CLOG_SUFFIX_LENGTH,
&bytes_written, NULL);
+ #elif defined(__hexagon__)
+ qurt_printf("%s", out_buffer);
#else
write(STDOUT_FILENO, out_buffer, prefix_chars + format_chars + CLOG_SUFFIX_LENGTH);
#endif
@@ -406,12 +417,14 @@ void clog_vlog_debug(const char* module, const char* format, va_list args) {
out_buffer = heap_buffer;
}
out_buffer[prefix_chars + format_chars] = '\n';
- #ifdef _WIN32
+ #if defined(_WIN32)
DWORD bytes_written;
WriteFile(
GetStdHandle(STD_OUTPUT_HANDLE),
out_buffer, prefix_chars + format_chars + CLOG_SUFFIX_LENGTH,
&bytes_written, NULL);
+ #elif defined(__hexagon__)
+ qurt_printf("%s", out_buffer);
#else
write(STDOUT_FILENO, out_buffer, prefix_chars + format_chars + CLOG_SUFFIX_LENGTH);
#endif