Skip to content

Commit cbbfed8

Browse files
author
vasko
committed
Add basic FreeRTOS platform support
1 parent d061f5f commit cbbfed8

5 files changed

Lines changed: 24 additions & 2 deletions

File tree

absl/base/internal/sysinfo.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@
5050
#include <zircon/process.h>
5151
#endif
5252

53+
#if defined(__FREERTOS__)
54+
#include <task.h>
55+
#endif
56+
5357
#include <string.h>
5458

5559
#include <cassert>
@@ -465,6 +469,12 @@ pid_t GetTID() {
465469
return static_cast<pid_t>(zx_thread_self());
466470
}
467471

472+
#elif defined(__FREERTOS__)
473+
474+
pid_t GetTID() {
475+
return static_cast<pid_t>(uxTaskGetTaskNumber(xTaskGetCurrentTaskHandle()));
476+
}
477+
468478
#else
469479

470480
// Fallback implementation of `GetTID` using `pthread_self`.

absl/debugging/internal/elf_mem_image.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
#if defined(__ELF__) && !defined(__OpenBSD__) && !defined(__QNX__) && \
3636
!defined(__asmjs__) && !defined(__wasm__) && !defined(__HAIKU__) && \
3737
!defined(__sun) && !defined(__VXWORKS__) && !defined(__hexagon__) && \
38-
!defined(__XTENSA__)
38+
!defined(__XTENSA__) && !defined(__FREERTOS__)
3939
#define ABSL_HAVE_ELF_MEM_IMAGE 1
4040
#endif
4141

absl/log/internal/log_message.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ LogMessage::LogMessageData::LogMessageData(absl::string_view file,
221221
void LogMessage::LogMessageData::InitializeEncodingAndFormat() {
222222
EncodeStringTruncate(EventTag::kFileName, entry.source_filename(),
223223
&encoded_remaining());
224-
EncodeVarint(EventTag::kFileLine, entry.source_line(), &encoded_remaining());
224+
EncodeVarint(EventTag::kFileLine, static_cast<int32_t>(entry.source_line()), &encoded_remaining());
225225
EncodeVarint(EventTag::kTimeNsecs, absl::ToUnixNanos(entry.timestamp()),
226226
&encoded_remaining());
227227
EncodeVarint(EventTag::kSeverity,

absl/log/internal/proto.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ inline bool EncodeVarint(uint64_t tag, uint32_t value, absl::Span<char> *buf) {
7979
inline bool EncodeVarint(uint64_t tag, int32_t value, absl::Span<char> *buf) {
8080
return EncodeVarint(tag, static_cast<uint64_t>(value), buf);
8181
}
82+
inline bool EncodeVarint(uint64_t tag, bool value, absl::Span<char> *buf) {
83+
return EncodeVarint(tag, static_cast<uint64_t>(value), buf);
84+
}
8285

8386
// Encodes the specified integer as a varint field using ZigZag encoding and
8487
// returns true if it fits.

absl/time/internal/cctz/src/time_zone_libc.cc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,15 @@ auto tm_zone(const std::tm& tm) -> decltype(tzname[0]) {
8181
const bool is_dst = tm.tm_isdst > 0;
8282
return tzname[is_dst];
8383
}
84+
#elif defined(__FREERTOS__)
85+
long int tm_gmtoff(const std::tm& tm) {
86+
(void)tm;
87+
return 0;
88+
}
89+
const char* tm_zone(const std::tm& tm) {
90+
(void)tm;
91+
return "UTC";
92+
}
8493
#else
8594
// Adapt to different spellings of the struct std::tm extension fields.
8695
#if defined(tm_gmtoff)

0 commit comments

Comments
 (0)