Add NetBSD support.
GitOrigin-RevId: 42703ce955a4323757de56d0c012a54246227f70
This commit is contained in:
parent
ec28b6c48b
commit
1a100e1b0f
@ -311,6 +311,10 @@ if (ANDROID)
|
|||||||
target_link_libraries(tdutils PRIVATE log)
|
target_link_libraries(tdutils PRIVATE log)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if (CMAKE_HOST_SYSTEM_NAME MATCHES "NetBSD")
|
||||||
|
target_link_libraries(tdutils PUBLIC /usr/pkg/gcc5/i486--netbsdelf/lib/libatomic.so)
|
||||||
|
endif()
|
||||||
|
|
||||||
install(TARGETS tdutils EXPORT TdTargets
|
install(TARGETS tdutils EXPORT TdTargets
|
||||||
LIBRARY DESTINATION lib
|
LIBRARY DESTINATION lib
|
||||||
ARCHIVE DESTINATION lib
|
ARCHIVE DESTINATION lib
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#if TD_LINUX || TD_ANDROID || TD_TIZEN
|
#if TD_LINUX || TD_ANDROID || TD_TIZEN
|
||||||
#define TD_POLL_EPOLL 1
|
#define TD_POLL_EPOLL 1
|
||||||
#define TD_EVENTFD_LINUX 1
|
#define TD_EVENTFD_LINUX 1
|
||||||
#elif TD_FREEBSD || TD_OPENBSD
|
#elif TD_FREEBSD || TD_OPENBSD || TD_NETBSD
|
||||||
#define TD_POLL_KQUEUE 1
|
#define TD_POLL_KQUEUE 1
|
||||||
#define TD_EVENTFD_BSD 1
|
#define TD_EVENTFD_BSD 1
|
||||||
#elif TD_CYGWIN
|
#elif TD_CYGWIN
|
||||||
|
@ -81,7 +81,12 @@ void KQueue::add_change(std::uintptr_t ident, int16 filter, uint16 flags, uint32
|
|||||||
if (changes_n_ == static_cast<int>(events_.size())) {
|
if (changes_n_ == static_cast<int>(events_.size())) {
|
||||||
flush_changes();
|
flush_changes();
|
||||||
}
|
}
|
||||||
EV_SET(&events_[changes_n_], ident, filter, flags, fflags, data, udata);
|
#if TD_NETBSD
|
||||||
|
auto set_udata = reinterpret_cast<std::intptr_t>(udata);
|
||||||
|
#else
|
||||||
|
auto set_udata = udata;
|
||||||
|
#endif
|
||||||
|
EV_SET(&events_[changes_n_], ident, filter, flags, fflags, data, set_udata);
|
||||||
VLOG(fd) << "Subscribe [fd:" << ident << "] [filter:" << filter << "] [udata: " << udata << "]";
|
VLOG(fd) << "Subscribe [fd:" << ident << "] [filter:" << filter << "] [udata: " << udata << "]";
|
||||||
changes_n_++;
|
changes_n_++;
|
||||||
}
|
}
|
||||||
@ -157,9 +162,14 @@ void KQueue::run(int timeout_ms) {
|
|||||||
if (event->fflags & EV_ERROR) {
|
if (event->fflags & EV_ERROR) {
|
||||||
LOG(FATAL) << "EV_ERROR in kqueue is not supported";
|
LOG(FATAL) << "EV_ERROR in kqueue is not supported";
|
||||||
}
|
}
|
||||||
VLOG(fd) << "Event [fd:" << event->ident << "] [filter:" << event->filter << "] [udata: " << event->udata << "]";
|
#if TD_NETBSD
|
||||||
|
auto udata = reinterpret_cast<void *>(event->udata);
|
||||||
|
#else
|
||||||
|
auto udata = event->udata;
|
||||||
|
#endif
|
||||||
|
VLOG(fd) << "Event [fd:" << event->ident << "] [filter:" << event->filter << "] [udata: " << udata << "]";
|
||||||
// LOG(WARNING) << "Have event->ident = " << event->ident << "event->filter = " << event->filter;
|
// LOG(WARNING) << "Have event->ident = " << event->ident << "event->filter = " << event->filter;
|
||||||
auto pollable_fd = PollableFd::from_list_node(static_cast<ListNode *>(event->udata));
|
auto pollable_fd = PollableFd::from_list_node(static_cast<ListNode *>(udata));
|
||||||
pollable_fd.add_flags(flags);
|
pollable_fd.add_flags(flags);
|
||||||
pollable_fd.release_as_list_node();
|
pollable_fd.release_as_list_node();
|
||||||
}
|
}
|
||||||
|
@ -47,6 +47,8 @@
|
|||||||
#define TD_FREEBSD 1
|
#define TD_FREEBSD 1
|
||||||
#elif defined(__OpenBSD__)
|
#elif defined(__OpenBSD__)
|
||||||
#define TD_OPENBSD 1
|
#define TD_OPENBSD 1
|
||||||
|
#elif defined(__NetBSD__)
|
||||||
|
#define TD_NETBSD 1
|
||||||
#elif defined(__CYGWIN__)
|
#elif defined(__CYGWIN__)
|
||||||
#define TD_CYGWIN 1
|
#define TD_CYGWIN 1
|
||||||
#elif defined(__EMSCRIPTEN__)
|
#elif defined(__EMSCRIPTEN__)
|
||||||
|
@ -664,8 +664,8 @@ TEST(Misc, Bits) {
|
|||||||
ASSERT_EQ(i, count_trailing_zeroes_non_zero64(1ull << i));
|
ASSERT_EQ(i, count_trailing_zeroes_non_zero64(1ull << i));
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT_EQ(0x12345678u, bswap32(0x78563412u));
|
ASSERT_EQ(0x12345678u, td::bswap32(0x78563412u));
|
||||||
ASSERT_EQ(0x12345678abcdef67ull, bswap64(0x67efcdab78563412ull));
|
ASSERT_EQ(0x12345678abcdef67ull, td::bswap64(0x67efcdab78563412ull));
|
||||||
|
|
||||||
ASSERT_EQ(0, count_bits32(0));
|
ASSERT_EQ(0, count_bits32(0));
|
||||||
ASSERT_EQ(0, count_bits64(0));
|
ASSERT_EQ(0, count_bits64(0));
|
||||||
|
Reference in New Issue
Block a user