Minor fixes.

This commit is contained in:
levlam 2022-07-14 18:38:48 +03:00
parent bf80c43c05
commit abc9ed2cd9
18 changed files with 51 additions and 45 deletions

View File

@ -59,11 +59,11 @@ function(get_git_head_revision _refspecvar _hashvar)
_git_find_closest_git_dir("${CMAKE_CURRENT_SOURCE_DIR}" GIT_DIR)
file(RELATIVE_PATH _relative_to_source_dir "${CMAKE_CURRENT_SOURCE_DIR}" "${GIT_DIR}")
if ("${_relative_to_source_dir}" MATCHES "^[.][.]")
if (_relative_to_source_dir MATCHES "^[.][.]")
# We've gone above the CMake root dir.
set(GIT_DIR "")
endif()
if ("${GIT_DIR}" STREQUAL "")
if (GIT_DIR STREQUAL "")
set(${_refspecvar} "GITDIR-NOTFOUND" PARENT_SCOPE)
set(${_hashvar} "GITDIR-NOTFOUND" PARENT_SCOPE)
return()
@ -83,7 +83,7 @@ function(get_git_head_revision _refspecvar _hashvar)
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
OUTPUT_VARIABLE out
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
if (NOT "${out}" STREQUAL "")
if (NOT out STREQUAL "")
# If out is non-empty, GIT_DIR/CMAKE_CURRENT_SOURCE_DIR is in a submodule
file(READ ${GIT_DIR} submodule)
string(REGEX REPLACE "gitdir: (.*)$" "\\1" GIT_DIR_RELATIVE ${submodule})

View File

@ -20,24 +20,24 @@ set(HEAD_HASH)
file(READ "@HEAD_FILE@" HEAD_CONTENTS LIMIT 1024)
string(STRIP "${HEAD_CONTENTS}" HEAD_CONTENTS)
if(HEAD_CONTENTS MATCHES "ref")
# named branch
string(REPLACE "ref: " "" HEAD_REF "${HEAD_CONTENTS}")
if(EXISTS "@GIT_DIR@/${HEAD_REF}")
configure_file("@GIT_DIR@/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY)
else()
configure_file("@GIT_DIR@/packed-refs" "@GIT_DATA@/packed-refs" COPYONLY)
file(READ "@GIT_DATA@/packed-refs" PACKED_REFS)
if(${PACKED_REFS} MATCHES "([0-9a-z]*) ${HEAD_REF}")
set(HEAD_HASH "${CMAKE_MATCH_1}")
endif()
endif()
if (HEAD_CONTENTS MATCHES "ref")
# named branch
string(REPLACE "ref: " "" HEAD_REF "${HEAD_CONTENTS}")
if (EXISTS "@GIT_DIR@/${HEAD_REF}")
configure_file("@GIT_DIR@/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY)
else()
configure_file("@GIT_DIR@/packed-refs" "@GIT_DATA@/packed-refs" COPYONLY)
file(READ "@GIT_DATA@/packed-refs" PACKED_REFS)
if (PACKED_REFS MATCHES "([0-9a-z]*) ${HEAD_REF}")
set(HEAD_HASH "${CMAKE_MATCH_1}")
endif()
endif()
else()
# detached HEAD
configure_file("@GIT_DIR@/HEAD" "@GIT_DATA@/head-ref" COPYONLY)
# detached HEAD
configure_file("@GIT_DIR@/HEAD" "@GIT_DATA@/head-ref" COPYONLY)
endif()
if(NOT HEAD_HASH)
file(READ "@GIT_DATA@/head-ref" HEAD_HASH LIMIT 1024)
string(STRIP "${HEAD_HASH}" HEAD_HASH)
endif()
if (NOT HEAD_HASH)
file(READ "@GIT_DATA@/head-ref" HEAD_HASH LIMIT 1024)
string(STRIP "${HEAD_HASH}" HEAD_HASH)
endif()

View File

@ -73,7 +73,7 @@ at [tdl](https://github.com/Bannerets/tdl), which provides a convenient, fully-a
You can also see [TdNode](https://github.com/puppy0cam/TdNode), [tglib](https://github.com/nodegin/tglib), [node-tdlib](https://github.com/wfjsw/node-tdlib), [tdlnode](https://github.com/fonbah/tdlnode),
[Paper Plane](https://github.com/par6n/paper-plane), or [node-tlg](https://github.com/dilongfa/node-tlg) for other examples of TDLib JSON interface integration with Node.js.
See also the source code of [DIBgram](https://github.com/DIBgram/DIBgram) - an unofficial Telegram web app which looks like Telegram Desktop.
See also the source code of [DIBgram](https://github.com/DIBgram/DIBgram) - an unofficial Telegram web application which looks like Telegram Desktop.
TDLib can be used also from NativeScript through the [JSON](https://github.com/tdlib/td#using-json) interface.
See [nativescript-tglib](https://github.com/arpit2438735/nativescript-tglib) as an example of a NativeScript library for building Telegram clients.

View File

@ -4793,7 +4793,7 @@ searchMessages chat_list:ChatList query:string offset_date:int32 offset_chat_id:
//@filter Additional filter for messages to search; pass null to search for all messages
searchSecretMessages chat_id:int53 query:string offset:string limit:int32 filter:SearchMessagesFilter = FoundMessages;
//@description Searches for call messages. Returns the results in reverse chronological order (i. e., in order of decreasing message_id). For optimal performance, the number of returned messages is chosen by TDLib
//@description Searches for call messages. Returns the results in reverse chronological order (i.e., in order of decreasing message_id). For optimal performance, the number of returned messages is chosen by TDLib
//@from_message_id Identifier of the message from which to search; use 0 to get results from the last message
//@limit The maximum number of messages to be returned; up to 100. For optimal performance, the number of returned messages is chosen by TDLib and can be smaller than the specified limit
//@only_missed Pass true to search only for messages with missed/declined calls
@ -6081,7 +6081,7 @@ getSupergroupMembers supergroup_id:int53 filter:SupergroupMembersFilter offset:i
closeSecretChat secret_chat_id:int32 = Ok;
//@description Returns a list of service actions taken by chat members and administrators in the last 48 hours. Available only for supergroups and channels. Requires administrator rights. Returns results in reverse chronological order (i. e., in order of decreasing event_id)
//@description Returns a list of service actions taken by chat members and administrators in the last 48 hours. Available only for supergroups and channels. Requires administrator rights. Returns results in reverse chronological order (i.e., in order of decreasing event_id)
//@chat_id Chat identifier @query Search query by which to filter events @from_event_id Identifier of an event from which to return results. Use 0 to get results from the latest events @limit The maximum number of events to return; up to 100
//@filters The types of events to return; pass null to get chat events of all types @user_ids User identifiers by which to filter events. By default, events relating to all users will be returned
getChatEventLog chat_id:int53 query:string from_event_id:int64 limit:int32 filters:chatEventLogFilters user_ids:vector<int53> = ChatEvents;

View File

@ -21,7 +21,7 @@ Status check_message_id_duplicates(int64 *saved_message_ids, size_t max_size, si
// In addition, the identifiers (msg_id) of the last N messages received from the other side must be stored, and if
// a message comes in with msg_id lower than all or equal to any of the stored values, that message is to be
// ignored. Otherwise, the new message msg_id is added to the set, and, if the number of stored msg_id values is
// greater than N, the oldest (i. e. the lowest) is forgotten.
// greater than N, the oldest (i.e. the lowest) is forgotten.
if (end_pos == 2 * max_size) {
std::copy_n(&saved_message_ids[max_size], max_size, &saved_message_ids[0]);
end_pos = max_size;

View File

@ -25,7 +25,6 @@
#include "td/utils/logging.h"
#include "td/utils/misc.h"
#include "td/utils/port/sleep.h"
#include "td/utils/port/thread.h"
#include "td/utils/Slice.h"
#include "td/utils/SliceBuilder.h"
@ -195,7 +194,7 @@ Status NetQueryDispatcher::wait_dc_init(DcId dc_id, bool force) {
return Status::Error("Closing");
}
#if !TD_THREAD_UNSUPPORTED
td::usleep_for(1);
usleep_for(1);
#endif
}
}
@ -332,7 +331,7 @@ void NetQueryDispatcher::set_main_dc_id(int32 new_main_dc_id) {
return;
}
// Very rare event. Mutex is ok.
// Very rare event; mutex is ok.
std::lock_guard<std::mutex> guard(main_dc_id_mutex_);
if (new_main_dc_id == main_dc_id_) {
return;

View File

@ -8,6 +8,8 @@
#include "td/actor/actor.h"
#include "td/utils/common.h"
namespace td {
class Timeout final : public Actor {

View File

@ -11,6 +11,7 @@
#include "td/actor/impl/EventFull-decl.h"
#include "td/utils/Closure.h"
#include "td/utils/common.h"
#include "td/utils/FlatHashMap.h"
#include "td/utils/Heap.h"
#include "td/utils/List.h"

View File

@ -21,6 +21,7 @@
#include "td/utils/MpscPollableQueue.h"
#include "td/utils/ObjectPool.h"
#include "td/utils/port/thread_local.h"
#include "td/utils/Promise.h"
#include "td/utils/ScopeGuard.h"
#include "td/utils/Time.h"

View File

@ -25,7 +25,7 @@ add_custom_target(tdmime_auto DEPENDS ${TDMIME_SOURCE})
if (NOT CMAKE_CROSSCOMPILING)
find_program(GPERF_EXECUTABLE gperf)
if (NOT GPERF_EXECUTABLE)
message(FATAL_ERROR "Could NOT find gperf. Add path to gperf executable to PATH environment variable or specify it manually using GPERF_EXECUTABLE option, i. e. 'cmake -DGPERF_EXECUTABLE:FILEPATH=\"<path to gperf executable>\"'.")
message(FATAL_ERROR "Could NOT find gperf. Add path to gperf executable to PATH environment variable or specify it manually using GPERF_EXECUTABLE option, i.e. 'cmake -DGPERF_EXECUTABLE:FILEPATH=\"<path to gperf executable>\"'.")
endif()
set(GPERF_FILES

View File

@ -8,7 +8,6 @@
#include "td/utils/common.h"
#include "td/utils/port/sleep.h"
#include "td/utils/port/thread.h"
#include "td/utils/type_traits.h"
#include <atomic>
@ -21,11 +20,11 @@ template <class T>
class AtomicRead {
public:
void read(T &dest) const {
int it = 0;
const int wait_each_it = 4;
auto wait = [&]() {
it++;
if (it % wait_each_it == 0) {
uint32 counter = 0;
auto wait = [&] {
counter++;
const int wait_each_count = 4;
if (counter % wait_each_count == 0) {
usleep_for(1);
}
};

View File

@ -15,7 +15,6 @@
#include "td/utils/HazardPointers.h"
#include "td/utils/logging.h"
#include "td/utils/port/sleep.h"
#include "td/utils/port/thread.h"
#include "td/utils/ScopeGuard.h"
#include <array>
@ -306,7 +305,7 @@ class MpmcQueueOld {
if (try_pop(value, thread_id)) {
return value;
}
td::usleep_for(1);
usleep_for(1);
}
}
@ -430,7 +429,7 @@ class MpmcQueue {
if (try_pop(value, thread_id)) {
return value;
}
td::usleep_for(1);
usleep_for(1);
}
}

View File

@ -9,7 +9,6 @@
#include "td/utils/common.h"
#include "td/utils/logging.h"
#include "td/utils/port/sleep.h"
#include "td/utils/port/thread.h"
#include <algorithm>
#include <atomic>

View File

@ -7,7 +7,6 @@
#pragma once
#include "td/utils/port/sleep.h"
#include "td/utils/port/thread.h"
#include <atomic>
#include <memory>

View File

@ -1,8 +1,15 @@
//
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#pragma once
#include <mutex>
namespace td {
class Mutex {
public:
struct Guard {
@ -19,4 +26,5 @@ class Mutex {
private:
std::mutex mutex_;
};
} // namespace td

View File

@ -7,7 +7,7 @@
#pragma once
#include "td/utils/port/EventFd.h"
#include "td/utils/port/thread.h"
#include "td/utils/port/sleep.h"
#if !TD_THREAD_UNSUPPORTED && !TD_EVENTFD_UNSUPPORTED
@ -32,7 +32,7 @@ class Backoff {
if (cnt < 1) { // 50
return true;
} else {
td::usleep_for(1);
usleep_for(1);
return cnt < 3; // 500
}
}
@ -47,7 +47,7 @@ class InfBackoff {
if (cnt < 50) {
return true;
} else {
td::usleep_for(1);
usleep_for(1);
return true;
}
}

View File

@ -11,11 +11,11 @@
#include "td/utils/format.h"
#include "td/utils/logging.h"
#include "td/utils/port/sleep.h"
#include "td/utils/port/thread.h"
#include "td/utils/Slice.h"
#include "td/utils/Status.h"
#include <atomic>
#include <condition_variable>
#include <functional>
#include <mutex>
#include <utility>

View File

@ -13,7 +13,6 @@
#include "td/utils/tests.h"
#include <atomic>
#include <mutex>
#if !TD_THREAD_UNSUPPORTED