Fix compilation for Termux.

GitOrigin-RevId: d6ef97baaf2f48846189f89bc5c0c8ec824a2990
This commit is contained in:
levlam 2018-05-10 10:49:47 +03:00
parent 70438d829a
commit 9579edbd04
2 changed files with 26 additions and 0 deletions

View File

@ -5,23 +5,28 @@
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#pragma once
#include "td/utils/common.h"
namespace td {
class DhConfig {
public:
int32 version = 0;
string prime;
int32 g = 0;
bool empty() const {
return prime.empty();
}
template <class StorerT>
void store(StorerT &storer) const {
storer.store_int(version);
storer.store_string(prime);
storer.store_int(g);
}
template <class ParserT>
void parse(ParserT &parser) {
version = parser.fetch_int();
@ -29,4 +34,5 @@ class DhConfig {
g = parser.fetch_int();
}
};
} // namespace td

View File

@ -56,6 +56,19 @@ struct TimeNsec {
}
};
// remove libc compatibility hacks if any: we have our own hacks
#ifdef st_atimespec
#undef st_atimespec
#endif
#ifdef st_atimensec
#undef st_atimensec
#endif
#ifdef st_atime_nsec
#undef st_atime_nsec
#endif
template <class T>
struct TimeNsec<T, void_t<char, decltype(T::st_atimespec), decltype(T::st_mtimespec)>> {
static std::pair<decltype(decltype(T::st_atimespec)::tv_nsec), decltype(decltype(T::st_mtimespec)::tv_nsec)> get(
@ -78,6 +91,13 @@ struct TimeNsec<T, void_t<int, decltype(T::st_atim), decltype(T::st_mtim)>> {
}
};
template <class T>
struct TimeNsec<T, void_t<long, decltype(T::st_atime_nsec), decltype(T::st_mtime_nsec)>> {
static std::pair<decltype(T::st_atime_nsec), decltype(T::st_mtime_nsec)> get(const T &s) {
return {s.st_atime_nsec, s.st_mtime_nsec};
}
};
Stat from_native_stat(const struct ::stat &buf) {
auto time_nsec = TimeNsec<struct ::stat>::get(buf);