Add memory optimize and memory stats methods

This commit is contained in:
Andrea Cavalli 2020-10-25 03:20:24 +02:00
parent 11332192a0
commit 017073e0a2
38 changed files with 2373 additions and 16 deletions

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "td/generate/tl-parser"]
path = td/generate/tl-parser
url = https://github.com/vysheng/tl-parser

View File

@ -501,6 +501,7 @@ set(TDLIB_SOURCE
td/telegram/StateManager.cpp
td/telegram/StickersManager.cpp
td/telegram/StorageManager.cpp
td/telegram/MemoryManager.cpp
td/telegram/SuggestedAction.cpp
td/telegram/Td.cpp
td/telegram/TdDb.cpp
@ -696,6 +697,7 @@ set(TDLIB_SOURCE
td/telegram/StickerSetId.h
td/telegram/StickersManager.h
td/telegram/StorageManager.h
td/telegram/MemoryManager.h
td/telegram/SuggestedAction.h
td/telegram/Td.h
td/telegram/TdCallback.h

View File

@ -112,7 +112,7 @@ if (NOT CMAKE_CROSSCOMPILING)
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND ${GENERATE_COMMON_CMD}
COMMENT "Generate common tl source files"
DEPENDS generate_common scheme/mtproto_api.tlo scheme/telegram_api.tlo scheme/secret_api.tlo ${TL_TD_API_TLO} DoxygenTlDocumentationGenerator.php
DEPENDS generate_common scheme/telegram_api.tlo scheme/secret_api.tlo ${TL_TD_API_TLO} DoxygenTlDocumentationGenerator.php
)
if (TD_ENABLE_JNI)
target_compile_definitions(generate_common PRIVATE TD_ENABLE_JNI=1)
@ -121,6 +121,57 @@ if (NOT CMAKE_CROSSCOMPILING)
target_compile_definitions(generate_common PRIVATE DISABLE_HPP_DOCUMENTATION=1)
endif()
# Start of .tlo update
add_custom_target(configure_tl_parser
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tl-parser
COMMAND "./configure"
COMMENT "Configure tl-parser"
DEPENDS scheme/mtproto_api.tl scheme/telegram_api.tl scheme/secret_api.tl scheme/td_api.tl
)
add_custom_target(build_tl_parser
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tl-parser
COMMAND "make"
COMMENT "Build tl-parser"
DEPENDS scheme/mtproto_api.tl scheme/telegram_api.tl scheme/secret_api.tl scheme/td_api.tl
)
add_dependencies(build_tl_parser configure_tl_parser)
add_custom_target(generate_mtproto_api_tlo
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND "./tl-parser/bin/tl-parser" -v scheme/mtproto_api.tl -e scheme/mtproto_api.tlo
COMMENT "Build tl-parser"
DEPENDS scheme/mtproto_api.tl
)
add_dependencies(generate_mtproto_api_tlo build_tl_parser)
add_custom_target(generate_secret_api_tlo
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND "./tl-parser/bin/tl-parser" -v scheme/secret_api.tl -e scheme/secret_api.tlo
COMMENT "Build tl-parser"
DEPENDS scheme/secret_api.tl
)
add_dependencies(generate_secret_api_tlo build_tl_parser)
add_custom_target(generate_telegram_api_tlo
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND "./tl-parser/bin/tl-parser" -v scheme/telegram_api.tl -e scheme/telegram_api.tlo
COMMENT "Build tl-parser"
DEPENDS scheme/telegram_api.tl
)
add_dependencies(generate_telegram_api_tlo build_tl_parser)
add_custom_target(generate_td_api_tlo
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND "./tl-parser/bin/tl-parser" -v scheme/td_api.tl -e scheme/td_api.tlo
COMMENT "Build tl-parser"
DEPENDS scheme/td_api.tl
)
add_dependencies(generate_td_api_tlo build_tl_parser)
add_dependencies(tl_generate_common generate_mtproto_api_tlo generate_secret_api_tlo generate_telegram_api_tlo generate_td_api_tlo)
# End of .tlo update
add_executable(generate_c ${TL_GENERATE_C_SOURCE})
target_link_libraries(generate_c PRIVATE tdtl)
add_custom_target(tl_generate_c

48
td/generate/Makefile Normal file
View File

@ -0,0 +1,48 @@
srcdir=./tl-parser
CFLAGS=-g -O2
LDFLAGS=
CPPFLAGS=
COMPILE_FLAGS=${CFLAGS} ${CPFLAGS} ${CPPFLAGS} ${DEFS} -Wall -Wextra -Werror -Wno-deprecated-declarations -fno-strict-aliasing -fno-omit-frame-pointer -ggdb -Wno-unused-parameter -fPIC
EXTRA_LIBS=-lz
LOCAL_LDFLAGS=-rdynamic -ggdb ${EXTRA_LIBS}
LINK_FLAGS=${LDFLAGS} ${LOCAL_LDFLAGS}
DEP=dep
EXE=bin
OBJ=objs
DIR_LIST=${DEP} ${EXE} ${OBJ}
EXE_LIST=${EXE}/tl-parser
OBJECTS=${OBJ}/tl-parser.o ${OBJ}/tlc.o
DEPENDENCE=$(subst ${OBJ}/,${DEP}/,$(patsubst %.o,%.d,${OBJECTS}))
DEPENDENCE_LIST=${DEPENDENCE}
INCLUDE=-I. -I${srcdir}
CC=gcc
.SUFFIXES:
.SUFFIXES: .c .h .o
all: ${EXE_LIST} ${DIR_LIST} ${LIB_LIST}
create_dirs_and_headers: ${DIR_LIST}
create_dirs: ${DIR_LIST}
${DIR_LIST}:
@test -d $@ || mkdir -p $@
-include ${DEPENDENCE_LIST}
${OBJECTS}: ${OBJ}/%.o: ${srcdir}/%.c | create_dirs_and_headers
${CC} ${INCLUDE} ${COMPILE_FLAGS} -c -MP -MD -MF ${DEP}/$*.d -MQ ${OBJ}/$*.o -o $@ $<
${EXE}/tl-parser: ${OBJECTS}
${CC} $^ ${LINK_FLAGS} -o $@
clean:
rm -rf ${DIR_LIST} config.log config.status > /dev/null || echo "all clean"

97
td/generate/config.h Normal file
View File

@ -0,0 +1,97 @@
/* config.h. Generated from config.h.in by configure. */
/* config.h.in. Generated from configure.ac by autoheader. */
/* Define to 1 if you have the `clock_gettime' function. */
#define HAVE_CLOCK_GETTIME 1
/* Define to 1 if you have the <fcntl.h> header file. */
#define HAVE_FCNTL_H 1
/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1
/* Define to 1 if you have the `z' library (-lz). */
#define HAVE_LIBZ 1
/* Define to 1 if you have the <mach/mach.h> header file. */
/* #undef HAVE_MACH_MACH_H */
/* Define to 1 if your system has a GNU libc compatible `malloc' function, and
to 0 otherwise. */
#define HAVE_MALLOC 1
/* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1
/* Define to 1 if you have the `memset' function. */
#define HAVE_MEMSET 1
/* Define to 1 if your system has a GNU libc compatible `realloc' function,
and to 0 otherwise. */
#define HAVE_REALLOC 1
/* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1
/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1
/* Define to 1 if you have the `strdup' function. */
#define HAVE_STRDUP 1
/* Define to 1 if you have the <strings.h> header file. */
#define HAVE_STRINGS_H 1
/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1
/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1
/* Define to 1 if you have the <sys/time.h> header file. */
#define HAVE_SYS_TIME_H 1
/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1
/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
/* Define to 1 if the system has the `__builtin_bswap32' built-in function */
#define HAVE___BUILTIN_BSWAP32 1
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT ""
/* Define to the full name of this package. */
#define PACKAGE_NAME "tl-parser"
/* Define to the full name and version of this package. */
#define PACKAGE_STRING "tl-parser 1.0"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "tl-parser"
/* Define to the home page for this package. */
#define PACKAGE_URL ""
/* Define to the version of this package. */
#define PACKAGE_VERSION "1.0"
/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Define to `__inline__' or `__inline' if that's what the C compiler
calls it, or to nothing if 'inline' is not supported under any name. */
#ifndef __cplusplus
/* #undef inline */
#endif
/* Define to rpl_malloc if the replacement function should be used. */
/* #undef malloc */
/* Define to rpl_realloc if the replacement function should be used. */
/* #undef realloc */
/* Define to `unsigned int' if <sys/types.h> does not define. */
/* #undef size_t */

613
td/generate/config.log Normal file
View File

@ -0,0 +1,613 @@
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by tl-parser configure 1.0, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ ./tl-parser/configure
## --------- ##
## Platform. ##
## --------- ##
hostname = ubuntu-virtual-machine
uname -m = x86_64
uname -r = 5.8.1-050801-generic
uname -s = Linux
uname -v = #202008111432 SMP Tue Aug 11 14:34:42 UTC 2020
/usr/bin/uname -p = unknown
/bin/uname -X = unknown
/bin/arch = unknown
/usr/bin/arch -k = unknown
/usr/convex/getsysinfo = unknown
/usr/bin/hostinfo = unknown
/bin/machine = unknown
/usr/bin/oslevel = unknown
/bin/universe = unknown
PATH: /home/ubuntu/.npm-global/bin
PATH: /home/ubuntu/.cargo/bin
PATH: /home/ubuntu/.local/bin
PATH: /usr/local/sbin
PATH: /usr/local/bin
PATH: /usr/sbin
PATH: /usr/bin
PATH: /sbin
PATH: /bin
PATH: /usr/games
PATH: /usr/local/games
PATH: /snap/bin
PATH: /usr/lib/jvm/zulu13/bin
PATH: /usr/lib/jvm/zulu13/db/bin
## ----------- ##
## Core tests. ##
## ----------- ##
configure:2290: checking for gcc
configure:2306: found /usr/bin/gcc
configure:2317: result: gcc
configure:2546: checking for C compiler version
configure:2555: gcc --version >&5
gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
configure:2566: $? = 0
configure:2555: gcc -v >&5
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:hsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 9.3.0-17ubuntu1~20.04' --with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,gm2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-9 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-9-HskZEa/gcc-9-9.3.0/debian/tmp-nvptx/usr,hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04)
configure:2566: $? = 0
configure:2555: gcc -V >&5
gcc: error: unrecognized command line option '-V'
gcc: fatal error: no input files
compilation terminated.
configure:2566: $? = 1
configure:2555: gcc -qversion >&5
gcc: error: unrecognized command line option '-qversion'; did you mean '--version'?
gcc: fatal error: no input files
compilation terminated.
configure:2566: $? = 1
configure:2586: checking whether the C compiler works
configure:2608: gcc conftest.c >&5
configure:2612: $? = 0
configure:2660: result: yes
configure:2663: checking for C compiler default output file name
configure:2665: result: a.out
configure:2671: checking for suffix of executables
configure:2678: gcc -o conftest conftest.c >&5
configure:2682: $? = 0
configure:2704: result:
configure:2726: checking whether we are cross compiling
configure:2734: gcc -o conftest conftest.c >&5
configure:2738: $? = 0
configure:2745: ./conftest
configure:2749: $? = 0
configure:2737: result: no
configure:2742: checking for suffix of object files
configure:2764: gcc -c conftest.c >&5
configure:2768: $? = 0
configure:2789: result: o
configure:2793: checking whether we are using the GNU C compiler
configure:2812: gcc -c conftest.c >&5
configure:2812: $? = 0
configure:2821: result: yes
configure:2830: checking whether gcc accepts -g
configure:2850: gcc -c -g conftest.c >&5
configure:2850: $? = 0
configure:2891: result: yes
configure:2908: checking for gcc option to accept ISO C89
configure:2971: gcc -c -g -O2 conftest.c >&5
configure:2971: $? = 0
configure:2984: result: none needed
configure:3008: checking for crc32_combine in -lz
configure:3033: gcc -o conftest -g -O2 conftest.c -lz >&5
configure:3033: $? = 0
configure:3042: result: yes
configure:3060: checking how to run the C preprocessor
configure:3091: gcc -E conftest.c
configure:3091: $? = 0
configure:3105: gcc -E conftest.c
conftest.c:10:10: fatal error: ac_nonexistent.h: No such file or directory
10 | #include <ac_nonexistent.h>
| ^~~~~~~~~~~~~~~~~~
compilation terminated.
configure:3105: $? = 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "tl-parser"
| #define PACKAGE_TARNAME "tl-parser"
| #define PACKAGE_VERSION "1.0"
| #define PACKAGE_STRING "tl-parser 1.0"
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL ""
| #define HAVE_LIBZ 1
| /* end confdefs.h. */
| #include <ac_nonexistent.h>
configure:3130: result: gcc -E
configure:3150: gcc -E conftest.c
configure:3150: $? = 0
configure:3164: gcc -E conftest.c
conftest.c:10:10: fatal error: ac_nonexistent.h: No such file or directory
10 | #include <ac_nonexistent.h>
| ^~~~~~~~~~~~~~~~~~
compilation terminated.
configure:3164: $? = 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "tl-parser"
| #define PACKAGE_TARNAME "tl-parser"
| #define PACKAGE_VERSION "1.0"
| #define PACKAGE_STRING "tl-parser 1.0"
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL ""
| #define HAVE_LIBZ 1
| /* end confdefs.h. */
| #include <ac_nonexistent.h>
configure:3193: checking for grep that handles long lines and -e
configure:3251: result: /bin/grep
configure:3256: checking for egrep
configure:3318: result: /bin/grep -E
configure:3323: checking for ANSI C header files
configure:3343: gcc -c -g -O2 conftest.c >&5
configure:3343: $? = 0
configure:3416: gcc -o conftest -g -O2 conftest.c -lz >&5
configure:3416: $? = 0
configure:3416: ./conftest
configure:3416: $? = 0
configure:3427: result: yes
configure:3440: checking for sys/types.h
configure:3440: gcc -c -g -O2 conftest.c >&5
configure:3440: $? = 0
configure:3440: result: yes
configure:3440: checking for sys/stat.h
configure:3440: gcc -c -g -O2 conftest.c >&5
configure:3440: $? = 0
configure:3440: result: yes
configure:3440: checking for stdlib.h
configure:3440: gcc -c -g -O2 conftest.c >&5
configure:3440: $? = 0
configure:3440: result: yes
configure:3440: checking for string.h
configure:3440: gcc -c -g -O2 conftest.c >&5
configure:3440: $? = 0
configure:3440: result: yes
configure:3440: checking for memory.h
configure:3440: gcc -c -g -O2 conftest.c >&5
configure:3440: $? = 0
configure:3440: result: yes
configure:3440: checking for strings.h
configure:3440: gcc -c -g -O2 conftest.c >&5
configure:3440: $? = 0
configure:3440: result: yes
configure:3440: checking for inttypes.h
configure:3440: gcc -c -g -O2 conftest.c >&5
configure:3440: $? = 0
configure:3440: result: yes
configure:3440: checking for stdint.h
configure:3440: gcc -c -g -O2 conftest.c >&5
configure:3440: $? = 0
configure:3440: result: yes
configure:3440: checking for unistd.h
configure:3440: gcc -c -g -O2 conftest.c >&5
configure:3440: $? = 0
configure:3440: result: yes
configure:3455: checking fcntl.h usability
configure:3455: gcc -c -g -O2 conftest.c >&5
configure:3455: $? = 0
configure:3455: result: yes
configure:3455: checking fcntl.h presence
configure:3455: gcc -E conftest.c
configure:3455: $? = 0
configure:3455: result: yes
configure:3455: checking for fcntl.h
configure:3455: result: yes
configure:3455: checking mach/mach.h usability
configure:3455: gcc -c -g -O2 conftest.c >&5
conftest.c:54:10: fatal error: mach/mach.h: No such file or directory
54 | #include <mach/mach.h>
| ^~~~~~~~~~~~~
compilation terminated.
configure:3455: $? = 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "tl-parser"
| #define PACKAGE_TARNAME "tl-parser"
| #define PACKAGE_VERSION "1.0"
| #define PACKAGE_STRING "tl-parser 1.0"
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL ""
| #define HAVE_LIBZ 1
| #define STDC_HEADERS 1
| #define HAVE_SYS_TYPES_H 1
| #define HAVE_SYS_STAT_H 1
| #define HAVE_STDLIB_H 1
| #define HAVE_STRING_H 1
| #define HAVE_MEMORY_H 1
| #define HAVE_STRINGS_H 1
| #define HAVE_INTTYPES_H 1
| #define HAVE_STDINT_H 1
| #define HAVE_UNISTD_H 1
| #define HAVE_FCNTL_H 1
| /* end confdefs.h. */
| #include <stdio.h>
| #ifdef HAVE_SYS_TYPES_H
| # include <sys/types.h>
| #endif
| #ifdef HAVE_SYS_STAT_H
| # include <sys/stat.h>
| #endif
| #ifdef STDC_HEADERS
| # include <stdlib.h>
| # include <stddef.h>
| #else
| # ifdef HAVE_STDLIB_H
| # include <stdlib.h>
| # endif
| #endif
| #ifdef HAVE_STRING_H
| # if !defined STDC_HEADERS && defined HAVE_MEMORY_H
| # include <memory.h>
| # endif
| # include <string.h>
| #endif
| #ifdef HAVE_STRINGS_H
| # include <strings.h>
| #endif
| #ifdef HAVE_INTTYPES_H
| # include <inttypes.h>
| #endif
| #ifdef HAVE_STDINT_H
| # include <stdint.h>
| #endif
| #ifdef HAVE_UNISTD_H
| # include <unistd.h>
| #endif
| #include <mach/mach.h>
configure:3455: result: no
configure:3455: checking mach/mach.h presence
configure:3455: gcc -E conftest.c
conftest.c:21:10: fatal error: mach/mach.h: No such file or directory
21 | #include <mach/mach.h>
| ^~~~~~~~~~~~~
compilation terminated.
configure:3455: $? = 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "tl-parser"
| #define PACKAGE_TARNAME "tl-parser"
| #define PACKAGE_VERSION "1.0"
| #define PACKAGE_STRING "tl-parser 1.0"
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL ""
| #define HAVE_LIBZ 1
| #define STDC_HEADERS 1
| #define HAVE_SYS_TYPES_H 1
| #define HAVE_SYS_STAT_H 1
| #define HAVE_STDLIB_H 1
| #define HAVE_STRING_H 1
| #define HAVE_MEMORY_H 1
| #define HAVE_STRINGS_H 1
| #define HAVE_INTTYPES_H 1
| #define HAVE_STDINT_H 1
| #define HAVE_UNISTD_H 1
| #define HAVE_FCNTL_H 1
| /* end confdefs.h. */
| #include <mach/mach.h>
configure:3455: result: no
configure:3455: checking for mach/mach.h
configure:3455: result: no
configure:3455: checking for stdlib.h
configure:3455: result: yes
configure:3455: checking for string.h
configure:3455: result: yes
configure:3455: checking sys/time.h usability
configure:3455: gcc -c -g -O2 conftest.c >&5
configure:3455: $? = 0
configure:3455: result: yes
configure:3455: checking sys/time.h presence
configure:3455: gcc -E conftest.c
configure:3455: $? = 0
configure:3455: result: yes
configure:3455: checking for sys/time.h
configure:3455: result: yes
configure:3455: checking for unistd.h
configure:3455: result: yes
configure:3467: checking for inline
configure:3483: gcc -c -g -O2 conftest.c >&5
configure:3483: $? = 0
configure:3491: result: inline
configure:3509: checking for size_t
configure:3509: gcc -c -g -O2 conftest.c >&5
configure:3509: $? = 0
configure:3509: gcc -c -g -O2 conftest.c >&5
conftest.c: In function 'main':
conftest.c:61:21: error: expected expression before ')' token
61 | if (sizeof ((size_t)))
| ^
configure:3509: $? = 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "tl-parser"
| #define PACKAGE_TARNAME "tl-parser"
| #define PACKAGE_VERSION "1.0"
| #define PACKAGE_STRING "tl-parser 1.0"
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL ""
| #define HAVE_LIBZ 1
| #define STDC_HEADERS 1
| #define HAVE_SYS_TYPES_H 1
| #define HAVE_SYS_STAT_H 1
| #define HAVE_STDLIB_H 1
| #define HAVE_STRING_H 1
| #define HAVE_MEMORY_H 1
| #define HAVE_STRINGS_H 1
| #define HAVE_INTTYPES_H 1
| #define HAVE_STDINT_H 1
| #define HAVE_UNISTD_H 1
| #define HAVE_FCNTL_H 1
| #define HAVE_STDLIB_H 1
| #define HAVE_STRING_H 1
| #define HAVE_SYS_TIME_H 1
| #define HAVE_UNISTD_H 1
| /* end confdefs.h. */
| #include <stdio.h>
| #ifdef HAVE_SYS_TYPES_H
| # include <sys/types.h>
| #endif
| #ifdef HAVE_SYS_STAT_H
| # include <sys/stat.h>
| #endif
| #ifdef STDC_HEADERS
| # include <stdlib.h>
| # include <stddef.h>
| #else
| # ifdef HAVE_STDLIB_H
| # include <stdlib.h>
| # endif
| #endif
| #ifdef HAVE_STRING_H
| # if !defined STDC_HEADERS && defined HAVE_MEMORY_H
| # include <memory.h>
| # endif
| # include <string.h>
| #endif
| #ifdef HAVE_STRINGS_H
| # include <strings.h>
| #endif
| #ifdef HAVE_INTTYPES_H
| # include <inttypes.h>
| #endif
| #ifdef HAVE_STDINT_H
| # include <stdint.h>
| #endif
| #ifdef HAVE_UNISTD_H
| # include <unistd.h>
| #endif
| int
| main ()
| {
| if (sizeof ((size_t)))
| return 0;
| ;
| return 0;
| }
configure:3509: result: yes
configure:3524: checking for stdlib.h
configure:3524: result: yes
configure:3534: checking for GNU libc compatible malloc
configure:3558: gcc -o conftest -g -O2 conftest.c -lz >&5
configure:3558: $? = 0
configure:3558: ./conftest
configure:3558: $? = 0
configure:3568: result: yes
configure:3591: checking for stdlib.h
configure:3591: result: yes
configure:3601: checking for GNU libc compatible realloc
configure:3625: gcc -o conftest -g -O2 conftest.c -lz >&5
configure:3625: $? = 0
configure:3625: ./conftest
configure:3625: $? = 0
configure:3635: result: yes
configure:3659: checking for clock_gettime
configure:3659: gcc -o conftest -g -O2 conftest.c -lz >&5
configure:3659: $? = 0
configure:3659: result: yes
configure:3659: checking for memset
configure:3659: gcc -o conftest -g -O2 conftest.c -lz >&5
conftest.c:53:6: warning: conflicting types for built-in function 'memset'; expected 'void *(void *, int, long unsigned int)' [-Wbuiltin-declaration-mismatch]
53 | char memset ();
| ^~~~~~
conftest.c:41:1: note: 'memset' is declared in header '<string.h>'
40 | # include <limits.h>
41 | #else
configure:3659: $? = 0
configure:3659: result: yes
configure:3659: checking for strdup
configure:3659: gcc -o conftest -g -O2 conftest.c -lz >&5
conftest.c:54:6: warning: conflicting types for built-in function 'strdup'; expected 'char *(const char *)' [-Wbuiltin-declaration-mismatch]
54 | char strdup ();
| ^~~~~~
configure:3659: $? = 0
configure:3659: result: yes
configure:3672: checking for __builtin_bswap32
configure:3691: gcc -o conftest -g -O2 conftest.c -lz >&5
configure:3691: $? = 0
configure:3700: result: yes
configure:3822: creating ./config.status
## ---------------------- ##
## Running config.status. ##
## ---------------------- ##
This file was extended by tl-parser config.status 1.0, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES =
CONFIG_HEADERS =
CONFIG_LINKS =
CONFIG_COMMANDS =
$ ./config.status
on ubuntu-virtual-machine
config.status:808: creating Makefile
config.status:808: creating config.h
## ---------------- ##
## Cache variables. ##
## ---------------- ##
ac_cv_c_compiler_gnu=yes
ac_cv_c_inline=inline
ac_cv_env_CC_set=
ac_cv_env_CC_value=
ac_cv_env_CFLAGS_set=
ac_cv_env_CFLAGS_value=
ac_cv_env_CPPFLAGS_set=
ac_cv_env_CPPFLAGS_value=
ac_cv_env_CPP_set=
ac_cv_env_CPP_value=
ac_cv_env_LDFLAGS_set=
ac_cv_env_LDFLAGS_value=
ac_cv_env_LIBS_set=
ac_cv_env_LIBS_value=
ac_cv_env_build_alias_set=
ac_cv_env_build_alias_value=
ac_cv_env_host_alias_set=
ac_cv_env_host_alias_value=
ac_cv_env_target_alias_set=
ac_cv_env_target_alias_value=
ac_cv_func_clock_gettime=yes
ac_cv_func_malloc_0_nonnull=yes
ac_cv_func_memset=yes
ac_cv_func_realloc_0_nonnull=yes
ac_cv_func_strdup=yes
ac_cv_header_fcntl_h=yes
ac_cv_header_inttypes_h=yes
ac_cv_header_mach_mach_h=no
ac_cv_header_memory_h=yes
ac_cv_header_stdc=yes
ac_cv_header_stdint_h=yes
ac_cv_header_stdlib_h=yes
ac_cv_header_string_h=yes
ac_cv_header_strings_h=yes
ac_cv_header_sys_stat_h=yes
ac_cv_header_sys_time_h=yes
ac_cv_header_sys_types_h=yes
ac_cv_header_unistd_h=yes
ac_cv_lib_z_crc32_combine=yes
ac_cv_objext=o
ac_cv_path_EGREP='/bin/grep -E'
ac_cv_path_GREP=/bin/grep
ac_cv_prog_CPP='gcc -E'
ac_cv_prog_ac_ct_CC=gcc
ac_cv_prog_cc_c89=
ac_cv_prog_cc_g=yes
ac_cv_type_size_t=yes
ax_cv_have___builtin_bswap32=yes
## ----------------- ##
## Output variables. ##
## ----------------- ##
CC='gcc'
CFLAGS='-g -O2'
CPP='gcc -E'
CPPFLAGS=''
DEFS='-DHAVE_CONFIG_H'
ECHO_C=''
ECHO_N='-n'
ECHO_T=''
EGREP='/bin/grep -E'
EXEEXT=''
GREP='/bin/grep'
LDFLAGS=''
LIBOBJS=''
LIBS='-lz '
LTLIBOBJS=''
OBJEXT='o'
PACKAGE_BUGREPORT=''
PACKAGE_NAME='tl-parser'
PACKAGE_STRING='tl-parser 1.0'
PACKAGE_TARNAME='tl-parser'
PACKAGE_URL=''
PACKAGE_VERSION='1.0'
PATH_SEPARATOR=':'
SHELL='/bin/bash'
ac_ct_CC='gcc'
bindir='${exec_prefix}/bin'
build_alias=''
datadir='${datarootdir}'
datarootdir='${prefix}/share'
docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
dvidir='${docdir}'
exec_prefix='${prefix}'
host_alias=''
htmldir='${docdir}'
includedir='${prefix}/include'
infodir='${datarootdir}/info'
libdir='${exec_prefix}/lib'
libexecdir='${exec_prefix}/libexec'
localedir='${datarootdir}/locale'
localstatedir='${prefix}/var'
mandir='${datarootdir}/man'
oldincludedir='/usr/include'
pdfdir='${docdir}'
prefix='/usr/local'
program_transform_name='s,x,x,'
psdir='${docdir}'
runstatedir='${localstatedir}/run'
sbindir='${exec_prefix}/sbin'
sharedstatedir='${prefix}/com'
sysconfdir='${prefix}/etc'
target_alias=''
## ----------- ##
## confdefs.h. ##
## ----------- ##
/* confdefs.h */
#define PACKAGE_NAME "tl-parser"
#define PACKAGE_TARNAME "tl-parser"
#define PACKAGE_VERSION "1.0"
#define PACKAGE_STRING "tl-parser 1.0"
#define PACKAGE_BUGREPORT ""
#define PACKAGE_URL ""
#define HAVE_LIBZ 1
#define STDC_HEADERS 1
#define HAVE_SYS_TYPES_H 1
#define HAVE_SYS_STAT_H 1
#define HAVE_STDLIB_H 1
#define HAVE_STRING_H 1
#define HAVE_MEMORY_H 1
#define HAVE_STRINGS_H 1
#define HAVE_INTTYPES_H 1
#define HAVE_STDINT_H 1
#define HAVE_UNISTD_H 1
#define HAVE_FCNTL_H 1
#define HAVE_STDLIB_H 1
#define HAVE_STRING_H 1
#define HAVE_SYS_TIME_H 1
#define HAVE_UNISTD_H 1
#define HAVE_STDLIB_H 1
#define HAVE_MALLOC 1
#define HAVE_STDLIB_H 1
#define HAVE_REALLOC 1
#define HAVE_CLOCK_GETTIME 1
#define HAVE_MEMSET 1
#define HAVE_STRDUP 1
#define HAVE___BUILTIN_BSWAP32 1
configure: exit 0

987
td/generate/config.status Executable file
View File

@ -0,0 +1,987 @@
#! /bin/bash
# Generated by configure.
# Run this file to recreate the current configuration.
# Compiler output produced by configure, useful for debugging
# configure, is in config.log if it exists.
debug=false
ac_cs_recheck=false
ac_cs_silent=false
SHELL=${CONFIG_SHELL-/bin/bash}
export SHELL
## -------------------- ##
## M4sh Initialization. ##
## -------------------- ##
# Be more Bourne compatible
DUALCASE=1; export DUALCASE # for MKS sh
if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
emulate sh
NULLCMD=:
# Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
# is contrary to our usage. Disable this feature.
alias -g '${1+"$@"}'='"$@"'
setopt NO_GLOB_SUBST
else
case `(set -o) 2>/dev/null` in #(
*posix*) :
set -o posix ;; #(
*) :
;;
esac
fi
as_nl='
'
export as_nl
# Printing a long string crashes Solaris 7 /usr/bin/printf.
as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
# Prefer a ksh shell builtin over an external printf program on Solaris,
# but without wasting forks for bash or zsh.
if test -z "$BASH_VERSION$ZSH_VERSION" \
&& (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
as_echo='print -r --'
as_echo_n='print -rn --'
elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
as_echo='printf %s\n'
as_echo_n='printf %s'
else
if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
as_echo_n='/usr/ucb/echo -n'
else
as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
as_echo_n_body='eval
arg=$1;
case $arg in #(
*"$as_nl"*)
expr "X$arg" : "X\\(.*\\)$as_nl";
arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
esac;
expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
'
export as_echo_n_body
as_echo_n='sh -c $as_echo_n_body as_echo'
fi
export as_echo_body
as_echo='sh -c $as_echo_body as_echo'
fi
# The user is always right.
if test "${PATH_SEPARATOR+set}" != set; then
PATH_SEPARATOR=:
(PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
(PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
PATH_SEPARATOR=';'
}
fi
# IFS
# We need space, tab and new line, in precisely that order. Quoting is
# there to prevent editors from complaining about space-tab.
# (If _AS_PATH_WALK were called with IFS unset, it would disable word
# splitting by setting IFS to empty value.)
IFS=" "" $as_nl"
# Find who we are. Look in the path if we contain no directory separator.
as_myself=
case $0 in #((
*[\\/]* ) as_myself=$0 ;;
*) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
done
IFS=$as_save_IFS
;;
esac
# We did not find ourselves, most probably we were run as `sh COMMAND'
# in which case we are not to be found in the path.
if test "x$as_myself" = x; then
as_myself=$0
fi
if test ! -f "$as_myself"; then
$as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
exit 1
fi
# Unset variables that we do not need and which cause bugs (e.g. in
# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1"
# suppresses any "Segmentation fault" message there. '((' could
# trigger a bug in pdksh 5.2.14.
for as_var in BASH_ENV ENV MAIL MAILPATH
do eval test x\${$as_var+set} = xset \
&& ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
done
PS1='$ '
PS2='> '
PS4='+ '
# NLS nuisances.
LC_ALL=C
export LC_ALL
LANGUAGE=C
export LANGUAGE
# CDPATH.
(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
# as_fn_error STATUS ERROR [LINENO LOG_FD]
# ----------------------------------------
# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
# provided, also output the error to LOG_FD, referencing LINENO. Then exit the
# script with STATUS, using 1 if that was 0.
as_fn_error ()
{
as_status=$1; test $as_status -eq 0 && as_status=1
if test "$4"; then
as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
$as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
fi
$as_echo "$as_me: error: $2" >&2
as_fn_exit $as_status
} # as_fn_error
# as_fn_set_status STATUS
# -----------------------
# Set $? to STATUS, without forking.
as_fn_set_status ()
{
return $1
} # as_fn_set_status
# as_fn_exit STATUS
# -----------------
# Exit the shell with STATUS, even in a "trap 0" or "set -e" context.
as_fn_exit ()
{
set +e
as_fn_set_status $1
exit $1
} # as_fn_exit
# as_fn_unset VAR
# ---------------
# Portably unset VAR.
as_fn_unset ()
{
{ eval $1=; unset $1;}
}
as_unset=as_fn_unset
# as_fn_append VAR VALUE
# ----------------------
# Append the text in VALUE to the end of the definition contained in VAR. Take
# advantage of any shell optimizations that allow amortized linear growth over
# repeated appends, instead of the typical quadratic growth present in naive
# implementations.
if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then :
eval 'as_fn_append ()
{
eval $1+=\$2
}'
else
as_fn_append ()
{
eval $1=\$$1\$2
}
fi # as_fn_append
# as_fn_arith ARG...
# ------------------
# Perform arithmetic evaluation on the ARGs, and store the result in the
# global $as_val. Take advantage of shells that can avoid forks. The arguments
# must be portable across $(()) and expr.
if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then :
eval 'as_fn_arith ()
{
as_val=$(( $* ))
}'
else
as_fn_arith ()
{
as_val=`expr "$@" || test $? -eq 1`
}
fi # as_fn_arith
if expr a : '\(a\)' >/dev/null 2>&1 &&
test "X`expr 00001 : '.*\(...\)'`" = X001; then
as_expr=expr
else
as_expr=false
fi
if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
as_basename=basename
else
as_basename=false
fi
if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
as_dirname=dirname
else
as_dirname=false
fi
as_me=`$as_basename -- "$0" ||
$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
X"$0" : 'X\(//\)$' \| \
X"$0" : 'X\(/\)' \| . 2>/dev/null ||
$as_echo X/"$0" |
sed '/^.*\/\([^/][^/]*\)\/*$/{
s//\1/
q
}
/^X\/\(\/\/\)$/{
s//\1/
q
}
/^X\/\(\/\).*/{
s//\1/
q
}
s/.*/./; q'`
# Avoid depending upon Character Ranges.
as_cr_letters='abcdefghijklmnopqrstuvwxyz'
as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
as_cr_Letters=$as_cr_letters$as_cr_LETTERS
as_cr_digits='0123456789'
as_cr_alnum=$as_cr_Letters$as_cr_digits
ECHO_C= ECHO_N= ECHO_T=
case `echo -n x` in #(((((
-n*)
case `echo 'xy\c'` in
*c*) ECHO_T=' ';; # ECHO_T is single tab character.
xy) ECHO_C='\c';;
*) echo `echo ksh88 bug on AIX 6.1` > /dev/null
ECHO_T=' ';;
esac;;
*)
ECHO_N='-n';;
esac
rm -f conf$$ conf$$.exe conf$$.file
if test -d conf$$.dir; then
rm -f conf$$.dir/conf$$.file
else
rm -f conf$$.dir
mkdir conf$$.dir 2>/dev/null
fi
if (echo >conf$$.file) 2>/dev/null; then
if ln -s conf$$.file conf$$ 2>/dev/null; then
as_ln_s='ln -s'
# ... but there are two gotchas:
# 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
# 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
# In both cases, we have to default to `cp -pR'.
ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
as_ln_s='cp -pR'
elif ln conf$$.file conf$$ 2>/dev/null; then
as_ln_s=ln
else
as_ln_s='cp -pR'
fi
else
as_ln_s='cp -pR'
fi
rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
rmdir conf$$.dir 2>/dev/null
# as_fn_mkdir_p
# -------------
# Create "$as_dir" as a directory, including parents if necessary.
as_fn_mkdir_p ()
{
case $as_dir in #(
-*) as_dir=./$as_dir;;
esac
test -d "$as_dir" || eval $as_mkdir_p || {
as_dirs=
while :; do
case $as_dir in #(
*\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
*) as_qdir=$as_dir;;
esac
as_dirs="'$as_qdir' $as_dirs"
as_dir=`$as_dirname -- "$as_dir" ||
$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
X"$as_dir" : 'X\(//\)[^/]' \| \
X"$as_dir" : 'X\(//\)$' \| \
X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
$as_echo X"$as_dir" |
sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
s//\1/
q
}
/^X\(\/\/\)[^/].*/{
s//\1/
q
}
/^X\(\/\/\)$/{
s//\1/
q
}
/^X\(\/\).*/{
s//\1/
q
}
s/.*/./; q'`
test -d "$as_dir" && break
done
test -z "$as_dirs" || eval "mkdir $as_dirs"
} || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"
} # as_fn_mkdir_p
if mkdir -p . 2>/dev/null; then
as_mkdir_p='mkdir -p "$as_dir"'
else
test -d ./-p && rmdir ./-p
as_mkdir_p=false
fi
# as_fn_executable_p FILE
# -----------------------
# Test if FILE is an executable regular file.
as_fn_executable_p ()
{
test -f "$1" && test -x "$1"
} # as_fn_executable_p
as_test_x='test -x'
as_executable_p=as_fn_executable_p
# Sed expression to map a string onto a valid CPP name.
as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
# Sed expression to map a string onto a valid variable name.
as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
exec 6>&1
## ----------------------------------- ##
## Main body of $CONFIG_STATUS script. ##
## ----------------------------------- ##
# Save the log message, to keep $0 and so on meaningful, and to
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by tl-parser $as_me 1.0, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
CONFIG_HEADERS = $CONFIG_HEADERS
CONFIG_LINKS = $CONFIG_LINKS
CONFIG_COMMANDS = $CONFIG_COMMANDS
$ $0 $@
on `(hostname || uname -n) 2>/dev/null | sed 1q`
"
# Files that config.status was made for.
config_files=" Makefile"
config_headers=" config.h"
ac_cs_usage="\
\`$as_me' instantiates files and other configuration actions
from templates according to the current configuration. Unless the files
and actions are specified as TAGs, all are instantiated by default.
Usage: $0 [OPTION]... [TAG]...
-h, --help print this help, then exit
-V, --version print version number and configuration settings, then exit
--config print configuration, then exit
-q, --quiet, --silent
do not print progress messages
-d, --debug don't remove temporary files
--recheck update $as_me by reconfiguring in the same conditions
--file=FILE[:TEMPLATE]
instantiate the configuration file FILE
--header=FILE[:TEMPLATE]
instantiate the configuration header FILE
Configuration files:
$config_files
Configuration headers:
$config_headers
Report bugs to the package provider."
ac_cs_config=""
ac_cs_version="\
tl-parser config.status 1.0
configured by ./tl-parser/configure, generated by GNU Autoconf 2.69,
with options \"$ac_cs_config\"
Copyright (C) 2012 Free Software Foundation, Inc.
This config.status script is free software; the Free Software Foundation
gives unlimited permission to copy, distribute and modify it."
ac_pwd='/home/ubuntu/CLionProjects/tdlight/td/generate'
srcdir='./tl-parser'
test -n "$AWK" || AWK=awk
# The default lists apply if the user does not specify any file.
ac_need_defaults=:
while test $# != 0
do
case $1 in
--*=?*)
ac_option=`expr "X$1" : 'X\([^=]*\)='`
ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'`
ac_shift=:
;;
--*=)
ac_option=`expr "X$1" : 'X\([^=]*\)='`
ac_optarg=
ac_shift=:
;;
*)
ac_option=$1
ac_optarg=$2
ac_shift=shift
;;
esac
case $ac_option in
# Handling of the options.
-recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
ac_cs_recheck=: ;;
--version | --versio | --versi | --vers | --ver | --ve | --v | -V )
$as_echo "$ac_cs_version"; exit ;;
--config | --confi | --conf | --con | --co | --c )
$as_echo "$ac_cs_config"; exit ;;
--debug | --debu | --deb | --de | --d | -d )
debug=: ;;
--file | --fil | --fi | --f )
$ac_shift
case $ac_optarg in
*\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
'') as_fn_error $? "missing file argument" ;;
esac
as_fn_append CONFIG_FILES " '$ac_optarg'"
ac_need_defaults=false;;
--header | --heade | --head | --hea )
$ac_shift
case $ac_optarg in
*\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
esac
as_fn_append CONFIG_HEADERS " '$ac_optarg'"
ac_need_defaults=false;;
--he | --h)
# Conflict between --help and --header
as_fn_error $? "ambiguous option: \`$1'
Try \`$0 --help' for more information.";;
--help | --hel | -h )
$as_echo "$ac_cs_usage"; exit ;;
-q | -quiet | --quiet | --quie | --qui | --qu | --q \
| -silent | --silent | --silen | --sile | --sil | --si | --s)
ac_cs_silent=: ;;
# This is an error.
-*) as_fn_error $? "unrecognized option: \`$1'
Try \`$0 --help' for more information." ;;
*) as_fn_append ac_config_targets " $1"
ac_need_defaults=false ;;
esac
shift
done
ac_configure_extra_args=
if $ac_cs_silent; then
exec 6>/dev/null
ac_configure_extra_args="$ac_configure_extra_args --silent"
fi
if $ac_cs_recheck; then
set X /bin/bash './tl-parser/configure' $ac_configure_extra_args --no-create --no-recursion
shift
$as_echo "running CONFIG_SHELL=/bin/bash $*" >&6
CONFIG_SHELL='/bin/bash'
export CONFIG_SHELL
exec "$@"
fi
exec 5>>config.log
{
echo
sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
## Running $as_me. ##
_ASBOX
$as_echo "$ac_log"
} >&5
# Handling of arguments.
for ac_config_target in $ac_config_targets
do
case $ac_config_target in
"config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;;
"Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
*) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
esac
done
# If the user did not use the arguments to specify the items to instantiate,
# then the envvar interface is used. Set only those that are not.
# We use the long form for the default assignment because of an extremely
# bizarre bug on SunOS 4.1.3.
if $ac_need_defaults; then
test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers
fi
# Have a temporary directory for convenience. Make it in the build tree
# simply because there is no reason against having it here, and in addition,
# creating and moving files from /tmp can sometimes cause problems.
# Hook for its removal unless debugging.
# Note that there is a small window in which the directory will not be cleaned:
# after its creation but before its name has been assigned to `$tmp'.
$debug ||
{
tmp= ac_tmp=
trap 'exit_status=$?
: "${ac_tmp:=$tmp}"
{ test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status
' 0
trap 'as_fn_exit 1' 1 2 13 15
}
# Create a (secure) tmp directory for tmp files.
{
tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` &&
test -d "$tmp"
} ||
{
tmp=./conf$$-$RANDOM
(umask 077 && mkdir "$tmp")
} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5
ac_tmp=$tmp
# Set up the scripts for CONFIG_FILES section.
# No need to generate them if there are no CONFIG_FILES.
# This happens for instance with `./config.status config.h'.
if test -n "$CONFIG_FILES"; then
ac_cr=`echo X | tr X '\015'`
# On cygwin, bash can eat \r inside `` if the user requested igncr.
# But we know of no other shell where ac_cr would be empty at this
# point, so we can use a bashism as a fallback.
if test "x$ac_cr" = x; then
eval ac_cr=\$\'\\r\'
fi
ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' </dev/null 2>/dev/null`
if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then
ac_cs_awk_cr='\\r'
else
ac_cs_awk_cr=$ac_cr
fi
echo 'BEGIN {' >"$ac_tmp/subs1.awk" &&
cat >>"$ac_tmp/subs1.awk" <<\_ACAWK &&
S["LTLIBOBJS"]=""
S["LIBOBJS"]=""
S["EGREP"]="/bin/grep -E"
S["GREP"]="/bin/grep"
S["CPP"]="gcc -E"
S["OBJEXT"]="o"
S["EXEEXT"]=""
S["ac_ct_CC"]="gcc"
S["CPPFLAGS"]=""
S["LDFLAGS"]=""
S["CFLAGS"]="-g -O2"
S["CC"]="gcc"
S["target_alias"]=""
S["host_alias"]=""
S["build_alias"]=""
S["LIBS"]="-lz "
S["ECHO_T"]=""
S["ECHO_N"]="-n"
S["ECHO_C"]=""
S["DEFS"]="-DHAVE_CONFIG_H"
S["mandir"]="${datarootdir}/man"
S["localedir"]="${datarootdir}/locale"
S["libdir"]="${exec_prefix}/lib"
S["psdir"]="${docdir}"
S["pdfdir"]="${docdir}"
S["dvidir"]="${docdir}"
S["htmldir"]="${docdir}"
S["infodir"]="${datarootdir}/info"
S["docdir"]="${datarootdir}/doc/${PACKAGE_TARNAME}"
S["oldincludedir"]="/usr/include"
S["includedir"]="${prefix}/include"
S["runstatedir"]="${localstatedir}/run"
S["localstatedir"]="${prefix}/var"
S["sharedstatedir"]="${prefix}/com"
S["sysconfdir"]="${prefix}/etc"
S["datadir"]="${datarootdir}"
S["datarootdir"]="${prefix}/share"
S["libexecdir"]="${exec_prefix}/libexec"
S["sbindir"]="${exec_prefix}/sbin"
S["bindir"]="${exec_prefix}/bin"
S["program_transform_name"]="s,x,x,"
S["prefix"]="/usr/local"
S["exec_prefix"]="${prefix}"
S["PACKAGE_URL"]=""
S["PACKAGE_BUGREPORT"]=""
S["PACKAGE_STRING"]="tl-parser 1.0"
S["PACKAGE_VERSION"]="1.0"
S["PACKAGE_TARNAME"]="tl-parser"
S["PACKAGE_NAME"]="tl-parser"
S["PATH_SEPARATOR"]=":"
S["SHELL"]="/bin/bash"
_ACAWK
cat >>"$ac_tmp/subs1.awk" <<_ACAWK &&
for (key in S) S_is_set[key] = 1
FS = ""
}
{
line = $ 0
nfields = split(line, field, "@")
substed = 0
len = length(field[1])
for (i = 2; i < nfields; i++) {
key = field[i]
keylen = length(key)
if (S_is_set[key]) {
value = S[key]
line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3)
len += length(value) + length(field[++i])
substed = 1
} else
len += 1 + keylen
}
print line
}
_ACAWK
if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then
sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g"
else
cat
fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \
|| as_fn_error $? "could not setup config files machinery" "$LINENO" 5
fi # test -n "$CONFIG_FILES"
# Set up the scripts for CONFIG_HEADERS section.
# No need to generate them if there are no CONFIG_HEADERS.
# This happens for instance with `./config.status Makefile'.
if test -n "$CONFIG_HEADERS"; then
cat >"$ac_tmp/defines.awk" <<\_ACAWK ||
BEGIN {
D["PACKAGE_NAME"]=" \"tl-parser\""
D["PACKAGE_TARNAME"]=" \"tl-parser\""
D["PACKAGE_VERSION"]=" \"1.0\""
D["PACKAGE_STRING"]=" \"tl-parser 1.0\""
D["PACKAGE_BUGREPORT"]=" \"\""
D["PACKAGE_URL"]=" \"\""
D["HAVE_LIBZ"]=" 1"
D["STDC_HEADERS"]=" 1"
D["HAVE_SYS_TYPES_H"]=" 1"
D["HAVE_SYS_STAT_H"]=" 1"
D["HAVE_STDLIB_H"]=" 1"
D["HAVE_STRING_H"]=" 1"
D["HAVE_MEMORY_H"]=" 1"
D["HAVE_STRINGS_H"]=" 1"
D["HAVE_INTTYPES_H"]=" 1"
D["HAVE_STDINT_H"]=" 1"
D["HAVE_UNISTD_H"]=" 1"
D["HAVE_FCNTL_H"]=" 1"
D["HAVE_STDLIB_H"]=" 1"
D["HAVE_STRING_H"]=" 1"
D["HAVE_SYS_TIME_H"]=" 1"
D["HAVE_UNISTD_H"]=" 1"
D["HAVE_STDLIB_H"]=" 1"
D["HAVE_MALLOC"]=" 1"
D["HAVE_STDLIB_H"]=" 1"
D["HAVE_REALLOC"]=" 1"
D["HAVE_CLOCK_GETTIME"]=" 1"
D["HAVE_MEMSET"]=" 1"
D["HAVE_STRDUP"]=" 1"
D["HAVE___BUILTIN_BSWAP32"]=" 1"
for (key in D) D_is_set[key] = 1
FS = ""
}
/^[\t ]*#[\t ]*(define|undef)[\t ]+[_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ][_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789]*([\t (]|$)/ {
line = $ 0
split(line, arg, " ")
if (arg[1] == "#") {
defundef = arg[2]
mac1 = arg[3]
} else {
defundef = substr(arg[1], 2)
mac1 = arg[2]
}
split(mac1, mac2, "(") #)
macro = mac2[1]
prefix = substr(line, 1, index(line, defundef) - 1)
if (D_is_set[macro]) {
# Preserve the white space surrounding the "#".
print prefix "define", macro P[macro] D[macro]
next
} else {
# Replace #undef with comments. This is necessary, for example,
# in the case of _POSIX_SOURCE, which is predefined and required
# on some systems where configure will not decide to define it.
if (defundef == "undef") {
print "/*", prefix defundef, macro, "*/"
next
}
}
}
{ print }
_ACAWK
as_fn_error $? "could not setup config headers machinery" "$LINENO" 5
fi # test -n "$CONFIG_HEADERS"
eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS "
shift
for ac_tag
do
case $ac_tag in
:[FHLC]) ac_mode=$ac_tag; continue;;
esac
case $ac_mode$ac_tag in
:[FHL]*:*);;
:L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;;
:[FH]-) ac_tag=-:-;;
:[FH]*) ac_tag=$ac_tag:$ac_tag.in;;
esac
ac_save_IFS=$IFS
IFS=:
set x $ac_tag
IFS=$ac_save_IFS
shift
ac_file=$1
shift
case $ac_mode in
:L) ac_source=$1;;
:[FH])
ac_file_inputs=
for ac_f
do
case $ac_f in
-) ac_f="$ac_tmp/stdin";;
*) # Look for the file first in the build tree, then in the source tree
# (if the path is not absolute). The absolute path cannot be DOS-style,
# because $ac_f cannot contain `:'.
test -f "$ac_f" ||
case $ac_f in
[\\/$]*) false;;
*) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";;
esac ||
as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;;
esac
case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac
as_fn_append ac_file_inputs " '$ac_f'"
done
# Let's still pretend it is `configure' which instantiates (i.e., don't
# use $as_me), people would be surprised to read:
# /* config.h. Generated by config.status. */
configure_input='Generated from '`
$as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g'
`' by configure.'
if test x"$ac_file" != x-; then
configure_input="$ac_file. $configure_input"
{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5
$as_echo "$as_me: creating $ac_file" >&6;}
fi
# Neutralize special characters interpreted by sed in replacement strings.
case $configure_input in #(
*\&* | *\|* | *\\* )
ac_sed_conf_input=`$as_echo "$configure_input" |
sed 's/[\\\\&|]/\\\\&/g'`;; #(
*) ac_sed_conf_input=$configure_input;;
esac
case $ac_tag in
*:-:* | *:-) cat >"$ac_tmp/stdin" \
|| as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;;
esac
;;
esac
ac_dir=`$as_dirname -- "$ac_file" ||
$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
X"$ac_file" : 'X\(//\)[^/]' \| \
X"$ac_file" : 'X\(//\)$' \| \
X"$ac_file" : 'X\(/\)' \| . 2>/dev/null ||
$as_echo X"$ac_file" |
sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
s//\1/
q
}
/^X\(\/\/\)[^/].*/{
s//\1/
q
}
/^X\(\/\/\)$/{
s//\1/
q
}
/^X\(\/\).*/{
s//\1/
q
}
s/.*/./; q'`
as_dir="$ac_dir"; as_fn_mkdir_p
ac_builddir=.
case "$ac_dir" in
.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
*)
ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
# A ".." for each directory in $ac_dir_suffix.
ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
case $ac_top_builddir_sub in
"") ac_top_builddir_sub=. ac_top_build_prefix= ;;
*) ac_top_build_prefix=$ac_top_builddir_sub/ ;;
esac ;;
esac
ac_abs_top_builddir=$ac_pwd
ac_abs_builddir=$ac_pwd$ac_dir_suffix
# for backward compatibility:
ac_top_builddir=$ac_top_build_prefix
case $srcdir in
.) # We are building in place.
ac_srcdir=.
ac_top_srcdir=$ac_top_builddir_sub
ac_abs_top_srcdir=$ac_pwd ;;
[\\/]* | ?:[\\/]* ) # Absolute name.
ac_srcdir=$srcdir$ac_dir_suffix;
ac_top_srcdir=$srcdir
ac_abs_top_srcdir=$srcdir ;;
*) # Relative name.
ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
ac_top_srcdir=$ac_top_build_prefix$srcdir
ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
esac
ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
case $ac_mode in
:F)
#
# CONFIG_FILE
#
# If the template does not know about datarootdir, expand it.
# FIXME: This hack should be removed a few years after 2.60.
ac_datarootdir_hack=; ac_datarootdir_seen=
ac_sed_dataroot='
/datarootdir/ {
p
q
}
/@datadir@/p
/@docdir@/p
/@infodir@/p
/@localedir@/p
/@mandir@/p'
case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in
*datarootdir*) ac_datarootdir_seen=yes;;
*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*)
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5
$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;}
ac_datarootdir_hack='
s&@datadir@&${datarootdir}&g
s&@docdir@&${datarootdir}/doc/${PACKAGE_TARNAME}&g
s&@infodir@&${datarootdir}/info&g
s&@localedir@&${datarootdir}/locale&g
s&@mandir@&${datarootdir}/man&g
s&\${datarootdir}&${prefix}/share&g' ;;
esac
ac_sed_extra="
:t
/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
s|@configure_input@|$ac_sed_conf_input|;t t
s&@top_builddir@&$ac_top_builddir_sub&;t t
s&@top_build_prefix@&$ac_top_build_prefix&;t t
s&@srcdir@&$ac_srcdir&;t t
s&@abs_srcdir@&$ac_abs_srcdir&;t t
s&@top_srcdir@&$ac_top_srcdir&;t t
s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t
s&@builddir@&$ac_builddir&;t t
s&@abs_builddir@&$ac_abs_builddir&;t t
s&@abs_top_builddir@&$ac_abs_top_builddir&;t t
$ac_datarootdir_hack
"
eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \
>$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5
test -z "$ac_datarootdir_hack$ac_datarootdir_seen" &&
{ ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } &&
{ ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \
"$ac_tmp/out"`; test -z "$ac_out"; } &&
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir'
which seems to be undefined. Please make sure it is defined" >&5
$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir'
which seems to be undefined. Please make sure it is defined" >&2;}
rm -f "$ac_tmp/stdin"
case $ac_file in
-) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";;
*) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";;
esac \
|| as_fn_error $? "could not create $ac_file" "$LINENO" 5
;;
:H)
#
# CONFIG_HEADER
#
if test x"$ac_file" != x-; then
{
$as_echo "/* $configure_input */" \
&& eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs"
} >"$ac_tmp/config.h" \
|| as_fn_error $? "could not create $ac_file" "$LINENO" 5
if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5
$as_echo "$as_me: $ac_file is unchanged" >&6;}
else
rm -f "$ac_file"
mv "$ac_tmp/config.h" "$ac_file" \
|| as_fn_error $? "could not create $ac_file" "$LINENO" 5
fi
else
$as_echo "/* $configure_input */" \
&& eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \
|| as_fn_error $? "could not create -" "$LINENO" 5
fi
;;
esac
done # for ac_tag
as_fn_exit 0

1
td/generate/scheme/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
*.tlo

View File

@ -2829,6 +2829,10 @@ storageStatisticsFast files_size:int53 file_count:int32 database_size:int53 lang
//@statistics Database statistics in an unspecified human-readable format
databaseStatistics statistics:string = DatabaseStatistics;
//@description Contains memory statistics
//@statistics Memory statistics in an unspecified human-readable format
memoryStatistics statistics:string = MemoryStatistics;
//@class NetworkType @description Represents the type of a network
@ -4586,6 +4590,14 @@ getStorageStatisticsFast = StorageStatisticsFast;
//@description Returns database statistics
getDatabaseStatistics = DatabaseStatistics;
//@description Returns memory statistics
//@full Full memory statistics calculation
getMemoryStatistics full:Bool = MemoryStatistics;
//@description Optimize memory
//@full Full memory optimization
optimizeMemory full:Bool = Ok;
//@description Optimizes storage usage, i.e. deletes some files and returns new storage usage statistics. Secret thumbnails can't be deleted
//@size Limit on the total size of files after deletion. Pass -1 to use the default limit
//@ttl Limit on the time that has passed since the last time a file was accessed (or creation time for some filesystems). Pass -1 to use the default limit

Binary file not shown.

1
td/generate/tl-parser Submodule

@ -0,0 +1 @@
Subproject commit f49077de7f7aa5721483c5686182deebad5e78dd

View File

@ -964,5 +964,10 @@ void AnimationsManager::memory_cleanup() {
animations_.clear();
animations_.rehash(0);
}
void AnimationsManager::memory_stats(vector<string> &output) {
output.push_back("animations_:"); output.push_back(std::to_string(animations_.size()));
output.push_back(",");
output.push_back("saved_animation_file_ids_:"); output.push_back(std::to_string(this->saved_animation_file_ids_.size()));
}
} // namespace td

View File

@ -33,6 +33,8 @@ class AnimationsManager : public Actor {
void memory_cleanup();
void memory_stats(vector<string> &output);
int32 get_animation_duration(FileId file_id) const;
tl_object_ptr<td_api::animation> get_animation_object(FileId file_id, const char *source);

View File

@ -279,5 +279,9 @@ void AudiosManager::memory_cleanup() {
audios_.clear();
audios_.rehash(0);
}
void AudiosManager::memory_stats(vector<string> &output) {
output.push_back("animations_:"); output.push_back(std::to_string(audios_.size()));
}
} // namespace td

View File

@ -28,6 +28,8 @@ class AudiosManager {
void memory_cleanup();
void memory_stats(vector<string> &output);
int32 get_audio_duration(FileId file_id) const;
tl_object_ptr<td_api::audio> get_audio_object(FileId file_id);

View File

@ -14689,4 +14689,110 @@ void ContactsManager::memory_cleanup() {
imported_contact_user_ids_.clear();
unimported_contact_invites_.clear();
}
void ContactsManager::memory_stats(vector<string> &output) {
output.push_back("users_:"); output.push_back(std::to_string(users_.size()));
output.push_back(",");
output.push_back("users_full_:"); output.push_back(std::to_string(users_full_.size()));
output.push_back(",");
output.push_back("bot_infos_:"); output.push_back(std::to_string(bot_infos_.size()));
output.push_back(",");
output.push_back("user_photos_:"); output.push_back(std::to_string(user_photos_.size()));
output.push_back(",");
output.push_back("unknown_users_:"); output.push_back(std::to_string(unknown_users_.size()));
output.push_back(",");
output.push_back("pending_user_photos_:"); output.push_back(std::to_string(pending_user_photos_.size()));
output.push_back(",");
output.push_back("user_profile_photo_file_source_ids_:"); output.push_back(std::to_string(user_profile_photo_file_source_ids_.size()));
output.push_back(",");
output.push_back("my_photo_file_id_:"); output.push_back(std::to_string(my_photo_file_id_.size()));
output.push_back(",");
output.push_back("chats_:"); output.push_back(std::to_string(chats_.size()));
output.push_back(",");
output.push_back("chats_full_:"); output.push_back(std::to_string(chats_full_.size()));
output.push_back(",");
output.push_back("unknown_chats_:"); output.push_back(std::to_string(unknown_chats_.size()));
output.push_back(",");
output.push_back("chat_full_file_source_ids_:"); output.push_back(std::to_string(chat_full_file_source_ids_.size()));
output.push_back(",");
output.push_back("min_channels_:"); output.push_back(std::to_string(min_channels_.size()));
output.push_back(",");
output.push_back("channels_:"); output.push_back(std::to_string(channels_.size()));
output.push_back(",");
output.push_back("channels_full_:"); output.push_back(std::to_string(channels_full_.size()));
output.push_back(",");
output.push_back("unknown_channels_:"); output.push_back(std::to_string(unknown_channels_.size()));
output.push_back(",");
output.push_back("channel_full_file_source_ids_:"); output.push_back(std::to_string(channel_full_file_source_ids_.size()));
output.push_back(",");
output.push_back("secret_chats_:"); output.push_back(std::to_string(secret_chats_.size()));
output.push_back(",");
output.push_back("unknown_secret_chats_:"); output.push_back(std::to_string(unknown_secret_chats_.size()));
output.push_back(",");
output.push_back("secret_chats_with_user_:"); output.push_back(std::to_string(secret_chats_with_user_.size()));
output.push_back(",");
output.push_back("dialog_invite_links_:"); output.push_back(std::to_string(dialog_invite_links_.size()));
output.push_back(",");
output.push_back("invite_link_infos_:"); output.push_back(std::to_string(invite_link_infos_.size()));
output.push_back(",");
output.push_back("dialog_access_by_invite_link_:"); output.push_back(std::to_string(dialog_access_by_invite_link_.size()));
output.push_back(",");
output.push_back("load_user_from_database_queries_:"); output.push_back(std::to_string(load_user_from_database_queries_.size()));
output.push_back(",");
output.push_back("loaded_from_database_users_:"); output.push_back(std::to_string(loaded_from_database_users_.size()));
output.push_back(",");
output.push_back("unavailable_user_fulls_:"); output.push_back(std::to_string(unavailable_user_fulls_.size()));
output.push_back(",");
output.push_back("unavailable_bot_infos_:"); output.push_back(std::to_string(unavailable_bot_infos_.size()));
output.push_back(",");
output.push_back("load_chat_from_database_queries_:"); output.push_back(std::to_string(load_chat_from_database_queries_.size()));
output.push_back(",");
output.push_back("loaded_from_database_chats_:"); output.push_back(std::to_string(loaded_from_database_chats_.size()));
output.push_back(",");
output.push_back("unavailable_chat_fulls_:"); output.push_back(std::to_string(unavailable_chat_fulls_.size()));
output.push_back(",");
output.push_back("load_channel_from_database_queries_:"); output.push_back(std::to_string(load_channel_from_database_queries_.size()));
output.push_back(",");
output.push_back("loaded_from_database_channels_:"); output.push_back(std::to_string(loaded_from_database_channels_.size()));
output.push_back(",");
output.push_back("unavailable_channel_fulls_:"); output.push_back(std::to_string(unavailable_channel_fulls_.size()));
output.push_back(",");
output.push_back("load_secret_chat_from_database_queries_:"); output.push_back(std::to_string(load_secret_chat_from_database_queries_.size()));
output.push_back(",");
output.push_back("loaded_from_database_secret_chats_:"); output.push_back(std::to_string(loaded_from_database_secret_chats_.size()));
output.push_back(",");
output.push_back("dialog_administrators_:"); output.push_back(std::to_string(dialog_administrators_.size()));
output.push_back(",");
output.push_back("uploaded_profile_photos_:"); output.push_back(std::to_string(uploaded_profile_photos_.size()));
output.push_back(",");
output.push_back("imported_contacts_:"); output.push_back(std::to_string(imported_contacts_.size()));
output.push_back(",");
output.push_back("received_channel_participant_:"); output.push_back(std::to_string(received_channel_participant_.size()));
output.push_back(",");
output.push_back("received_channel_participants_:"); output.push_back(std::to_string(received_channel_participants_.size()));
output.push_back(",");
output.push_back("cached_channel_participants_:"); output.push_back(std::to_string(cached_channel_participants_.size()));
output.push_back(",");
output.push_back("load_contacts_queries_:"); output.push_back(std::to_string(load_contacts_queries_.size()));
output.push_back(",");
output.push_back("load_imported_contacts_queries_:"); output.push_back(std::to_string(load_imported_contacts_queries_.size()));
output.push_back(",");
output.push_back("all_imported_contacts_:"); output.push_back(std::to_string(all_imported_contacts_.size()));
output.push_back(",");
output.push_back("users_nearby_:"); output.push_back(std::to_string(users_nearby_.size()));
output.push_back(",");
output.push_back("channels_nearby_:"); output.push_back(std::to_string(channels_nearby_.size()));
output.push_back(",");
output.push_back("all_users_nearby_:"); output.push_back(std::to_string(all_users_nearby_.size()));
output.push_back(",");
output.push_back("linked_channel_ids_:"); output.push_back(std::to_string(linked_channel_ids_.size()));
output.push_back(",");
output.push_back("restricted_user_ids_:"); output.push_back(std::to_string(restricted_user_ids_.size()));
output.push_back(",");
output.push_back("restricted_channel_ids_:"); output.push_back(std::to_string(restricted_channel_ids_.size()));
output.push_back(",");
output.push_back("next_all_imported_contacts_:"); output.push_back(std::to_string(next_all_imported_contacts_.size()));
output.push_back("imported_contact_user_ids_:"); output.push_back(std::to_string(imported_contact_user_ids_.size()));
output.push_back("unimported_contact_invites_:"); output.push_back(std::to_string(unimported_contact_invites_.size()));
}
} // namespace td

View File

@ -82,6 +82,8 @@ class ContactsManager : public Actor {
void memory_cleanup();
void memory_stats(vector<string> &output);
static UserId get_user_id(const tl_object_ptr<telegram_api::User> &user);
static ChatId get_chat_id(const tl_object_ptr<telegram_api::Chat> &chat);
static ChannelId get_channel_id(const tl_object_ptr<telegram_api::Chat> &chat);

View File

@ -695,6 +695,9 @@ void DocumentsManager::memory_cleanup() {
documents_.clear();
documents_.rehash(0);
}
void DocumentsManager::memory_stats(vector<string> &output) {
output.push_back("documents_:"); output.push_back(std::to_string(documents_.size()));
}
string DocumentsManager::get_document_search_text(FileId file_id) const {
auto document = get_document(file_id);

View File

@ -78,6 +78,8 @@ class DocumentsManager {
void memory_cleanup();
void memory_stats(vector<string> &output);
Document on_get_document(RemoteDocument remote_document, DialogId owner_dialog_id,
MultiPromiseActor *load_data_multipromise_ptr = nullptr,
Document::Type default_document_type = Document::Type::General, bool is_background = false,

View File

@ -48,6 +48,7 @@ class SecretChatsManager;
class StateManager;
class StickersManager;
class StorageManager;
class MemoryManager;
class Td;
class TdDb;
class TempAuthKeyWatchdog;
@ -264,6 +265,13 @@ class Global : public ActorContext {
storage_manager_ = storage_manager;
}
ActorId<MemoryManager> memory_manager() const {
return memory_manager_;
}
void set_memory_manager(ActorId<MemoryManager> memory_manager) {
memory_manager_ = memory_manager;
}
ActorId<TopDialogManager> top_dialog_manager() const {
return top_dialog_manager_;
}
@ -392,6 +400,7 @@ class Global : public ActorContext {
ActorId<SecretChatsManager> secret_chats_manager_;
ActorId<StickersManager> stickers_manager_;
ActorId<StorageManager> storage_manager_;
ActorId<MemoryManager> memory_manager_;
ActorId<TopDialogManager> top_dialog_manager_;
ActorId<UpdatesManager> updates_manager_;
ActorId<WebPagesManager> web_pages_manager_;

View File

@ -0,0 +1,157 @@
//
// Copyright Andrea Cavalli (nospam@warp.ovh) 2020
//
// 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)
//
#include "td/telegram/MemoryManager.h"
#include "td/telegram/secret_api.h"
#include "td/telegram/td_api.h"
#include "td/telegram/telegram_api.h"
#include "td/telegram/AccessRights.h"
#include "td/telegram/AuthManager.h"
#include "td/telegram/ConfigManager.h"
#include "td/telegram/ConfigShared.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/DialogId.h"
#include "td/telegram/Document.h"
#include "td/telegram/DocumentsManager.h"
#include "td/telegram/FileReferenceManager.h"
#include "td/telegram/files/FileLocation.h"
#include "td/telegram/files/FileManager.h"
#include "td/telegram/WebPagesManager.h"
#include "td/telegram/StickersManager.h"
#include "td/telegram/VideoNotesManager.h"
#include "td/telegram/VideosManager.h"
#include "td/telegram/AudiosManager.h"
#include "td/telegram/AnimationsManager.h"
#include "td/telegram/files/FileType.h"
#include "td/telegram/Global.h"
#include "td/telegram/LanguagePackManager.h"
#include "td/telegram/logevent/LogEvent.h"
#include "td/telegram/MessagesManager.h"
#include "td/telegram/misc.h"
#include "td/telegram/net/DcId.h"
#include "td/telegram/net/MtprotoHeader.h"
#include "td/telegram/Td.h"
#include "td/telegram/TdDb.h"
#include "td/actor/MultiPromise.h"
#include "td/actor/PromiseFuture.h"
#include "td/actor/SleepActor.h"
#include "td/db/SqliteKeyValue.h"
#include "td/db/SqliteKeyValueAsync.h"
#include "td/utils/format.h"
#include "td/utils/logging.h"
#include "td/utils/misc.h"
#include "td/utils/PathView.h"
#include "td/utils/Random.h"
#include "td/utils/Slice.h"
#include "td/utils/Time.h"
#include "td/utils/tl_helpers.h"
#include "td/utils/utf8.h"
#include <algorithm>
#include <limits>
#include <type_traits>
#include <unordered_set>
#include <numeric>
namespace td {
tl_object_ptr<td_api::memoryStatistics> MemoryStats::get_memory_statistics_object() const {
return make_tl_object<td_api::memoryStatistics>(debug);
}
MemoryManager::MemoryManager(Td *td, ActorShared<> parent) : td_(td), parent_(std::move(parent)) {
}
void MemoryManager::start_up() {
init();
}
void MemoryManager::tear_down() {
parent_.reset();
}
void MemoryManager::init() {
if (!td_->auth_manager_->is_authorized() || td_->auth_manager_->is_bot() || G()->close_flag()) {
return;
}
LOG(INFO) << "Init MemoryManager";
is_inited_ = true;
}
void MemoryManager::get_memory_stats(bool full, Promise<MemoryStats> promise) const {
if (!is_inited_) {
promise.set_error(Status::Error(500, "Request aborted"));
return;
}
vector<string> output = {"{memory_stats:["};
td_->messages_manager_->memory_stats(output);
output.push_back(",");
td_->contacts_manager_->memory_stats(output);
output.push_back(",");
td_->web_pages_manager_->memory_stats(output);
output.push_back(",");
td_->stickers_manager_->memory_stats(output);
output.push_back(",");
td_->documents_manager_->memory_stats(output);
output.push_back(",");
td_->video_notes_manager_->memory_stats(output);
output.push_back(",");
td_->videos_manager_->memory_stats(output);
output.push_back(",");
td_->audios_manager_->memory_stats(output);
output.push_back(",");
td_->animations_manager_->memory_stats(output);
output.push_back(",");
td_->file_manager_->memory_stats(output);
output.push_back("]}");
string s = accumulate(output.begin(), output.end(), s);
auto value = MemoryStats(s);
promise.set_value(std::move(value));
}
void MemoryManager::clean_memory(bool full, Promise<Unit> promise) const {
if (!is_inited_) {
promise.set_error(Status::Error(500, "Request aborted"));
return;
}
td_->messages_manager_->memory_cleanup();
td_->contacts_manager_->memory_cleanup();
td_->web_pages_manager_->memory_cleanup();
td_->stickers_manager_->memory_cleanup();
td_->documents_manager_->memory_cleanup();
td_->video_notes_manager_->memory_cleanup();
td_->videos_manager_->memory_cleanup();
td_->audios_manager_->memory_cleanup();
td_->animations_manager_->memory_cleanup();
td_->file_manager_->memory_cleanup();
#ifdef __linux__
malloc_trim(0);
#endif
promise.set_value(Unit());
}
void MemoryManager::get_current_state(vector<td_api::object_ptr<td_api::Update>> &updates) const {
if (td_->auth_manager_->is_bot()) {
return;
}
// Never return updates
}
} // namespace td

View File

@ -0,0 +1,70 @@
//
// Copyright Andrea Cavalli (nospam@warp.ovh) 2020
//
// 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 "td/actor/actor.h"
#include "td/actor/MultiPromise.h"
#include "td/actor/PromiseFuture.h"
#include "td/actor/Timeout.h"
#include "td/telegram/files/FileId.h"
#include "td/telegram/files/FileSourceId.h"
#include "td/telegram/FullMessageId.h"
#include "td/telegram/Photo.h"
#include "td/telegram/SecretInputMedia.h"
#include "td/utils/buffer.h"
#include "td/utils/common.h"
#include "td/utils/Hints.h"
#include "td/utils/Slice.h"
#include "td/utils/Status.h"
#include "td/telegram/td_api.h"
#include "td/telegram/telegram_api.h"
#include <memory>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
namespace td {
class Td;
struct MemoryStats {
string debug;
MemoryStats() = default;
explicit MemoryStats(string debug) : debug(debug) {
}
tl_object_ptr<td_api::memoryStatistics> get_memory_statistics_object() const;
};
class MemoryManager : public Actor {
public:
MemoryManager(Td *td, ActorShared<> parent);
void init();
void get_memory_stats(bool full, Promise<MemoryStats> promise) const;
void clean_memory(bool full, Promise<Unit> promise) const;
void get_current_state(vector<td_api::object_ptr<td_api::Update>> &updates) const;
private:
void start_up() override;
void tear_down() override;
Td *td_;
ActorShared<> parent_;
bool is_inited_ = false;
};
} // namespace td

View File

@ -5758,6 +5758,83 @@ void MessagesManager::memory_cleanup() {
found_on_server_dialogs_.clear();
found_on_server_dialogs_.rehash(0);
}
void MessagesManager::memory_stats(vector<string> &output) {
output.push_back("being_sent_messages_:"); output.push_back(std::to_string(this->being_sent_messages_.size()));
output.push_back(",");
output.push_back("being_loaded_secret_thumbnails_:"); output.push_back(std::to_string(this->being_loaded_secret_thumbnails_.size()));
output.push_back(",");
output.push_back("being_uploaded_dialog_photos_:"); output.push_back(std::to_string(this->being_uploaded_dialog_photos_.size()));
output.push_back(",");
output.push_back("being_uploaded_files_:"); output.push_back(std::to_string(this->being_uploaded_files_.size()));
output.push_back(",");
output.push_back("being_uploaded_thumbnails_:"); output.push_back(std::to_string(this->being_uploaded_thumbnails_.size()));
output.push_back(",");
output.push_back("active_dialog_actions_:"); output.push_back(std::to_string(this->active_dialog_actions_.size()));
output.push_back(",");
output.push_back("created_dialogs_:"); output.push_back(std::to_string(this->created_dialogs_.size()));
output.push_back(",");
output.push_back("dialog_filter_reload_queries_:"); output.push_back(std::to_string(this->dialog_filter_reload_queries_.size()));
output.push_back(",");
output.push_back("dialog_filters_:"); output.push_back(std::to_string(this->dialog_filters_.size()));
output.push_back(",");
output.push_back("dialog_folders_:"); output.push_back(std::to_string(this->dialog_folders_.size()));
output.push_back(",");
output.push_back("dialog_lists_:"); output.push_back(std::to_string(this->dialog_lists_.size()));
output.push_back(",");
output.push_back("dialog_online_member_counts_:"); output.push_back(std::to_string(this->dialog_online_member_counts_.size()));
output.push_back(",");
output.push_back("dialogs_:"); output.push_back(std::to_string(this->dialogs_.size()));
output.push_back(",");
output.push_back("found_blocked_dialogs_:"); output.push_back(std::to_string(this->found_blocked_dialogs_.size()));
output.push_back(",");
output.push_back("found_call_messages_:"); output.push_back(std::to_string(this->found_call_messages_.size()));
output.push_back(",");
output.push_back("found_common_dialogs_:"); output.push_back(std::to_string(this->found_common_dialogs_.size()));
output.push_back(",");
output.push_back("found_dialog_messages_:"); output.push_back(std::to_string(this->found_dialog_messages_.size()));
output.push_back(",");
output.push_back("found_dialog_messages_dialog_id_:"); output.push_back(std::to_string(this->found_dialog_messages_dialog_id_.size()));
output.push_back(",");
output.push_back("found_dialog_recent_location_messages_:"); output.push_back(std::to_string(this->found_dialog_recent_location_messages_.size()));
output.push_back(",");
output.push_back("found_fts_messages_:"); output.push_back(std::to_string(this->found_fts_messages_.size()));
output.push_back(",");
output.push_back("found_message_public_forwards_:"); output.push_back(std::to_string(this->found_message_public_forwards_.size()));
output.push_back(",");
output.push_back("found_messages_:"); output.push_back(std::to_string(this->found_messages_.size()));
output.push_back(",");
output.push_back("found_on_server_dialogs_:"); output.push_back(std::to_string(this->found_on_server_dialogs_.size()));
output.push_back(",");
output.push_back("found_public_dialogs_:"); output.push_back(std::to_string(this->found_public_dialogs_.size()));
output.push_back(",");
output.push_back("loaded_dialogs_:"); output.push_back(std::to_string(this->loaded_dialogs_.size()));
output.push_back(",");
output.push_back("search_public_dialogs_queries_:"); output.push_back(std::to_string(this->search_public_dialogs_queries_.size()));
output.push_back(",");
output.push_back("public_message_links_:"); output.push_back(std::to_string(this->public_message_links_->size()));
output.push_back(",");
output.push_back("full_message_id_to_file_source_id_:"); output.push_back(std::to_string(this->full_message_id_to_file_source_id_.size()));
output.push_back(",");
output.push_back("get_dialog_message_by_date_results_:"); output.push_back(std::to_string(this->get_dialog_message_by_date_results_.size()));
output.push_back(",");
output.push_back("get_dialog_query_log_event_id_:"); output.push_back(std::to_string(this->get_dialog_query_log_event_id_.size()));
output.push_back(",");
output.push_back("get_channel_difference_to_log_event_id_:"); output.push_back(std::to_string(this->get_channel_difference_to_log_event_id_.size()));
output.push_back(",");
output.push_back("last_clear_history_message_id_to_dialog_id_:"); output.push_back(std::to_string(this->last_clear_history_message_id_to_dialog_id_.size()));
output.push_back(",");
output.push_back("last_outgoing_forwarded_message_date_:"); output.push_back(std::to_string(this->last_outgoing_forwarded_message_date_.size()));
output.push_back(",");
output.push_back("load_active_live_location_messages_queries_:"); output.push_back(std::to_string(this->load_active_live_location_messages_queries_.size()));
output.push_back(",");
output.push_back("message_id_to_dialog_id_:"); output.push_back(std::to_string(this->message_id_to_dialog_id_.size()));
output.push_back(",");
output.push_back("message_random_ids_:"); output.push_back(std::to_string(this->message_random_ids_.size()));
output.push_back(",");
output.push_back("notification_group_id_to_dialog_id_:"); output.push_back(std::to_string(this->notification_group_id_to_dialog_id_.size()));
output.push_back(",");
output.push_back("previous_repaired_read_inbox_max_message_id_:"); output.push_back(std::to_string(this->previous_repaired_read_inbox_max_message_id_.size()));
}
tl_object_ptr<telegram_api::InputPeer> MessagesManager::get_input_peer(DialogId dialog_id,
AccessRights access_rights) const {

View File

@ -192,6 +192,8 @@ class MessagesManager : public Actor {
void memory_cleanup();
void memory_stats(vector<string> &output);
static vector<MessageId> get_message_ids(const vector<int64> &input_message_ids);
static vector<int32> get_server_message_ids(const vector<MessageId> &message_ids);

View File

@ -6316,5 +6316,34 @@ void StickersManager::memory_cleanup() {
dice_messages_.clear();
dice_messages_.rehash(0);
}
void StickersManager::memory_stats(vector<string> &output) {
output.push_back("found_stickers_:"); output.push_back(std::to_string(found_stickers_.size()));
output.push_back(",");
output.push_back("found_sticker_sets_:"); output.push_back(std::to_string(found_sticker_sets_.size()));
output.push_back(",");
output.push_back("archived_sticker_set_ids_:"); output.push_back(std::to_string(archived_sticker_set_ids_->size()));
output.push_back(",");
output.push_back("attached_sticker_sets_:"); output.push_back(std::to_string(attached_sticker_sets_.size()));
output.push_back(",");
output.push_back("favorite_sticker_file_ids_:"); output.push_back(std::to_string(favorite_sticker_file_ids_.size()));
output.push_back(",");
output.push_back("favorite_sticker_ids_:"); output.push_back(std::to_string(favorite_sticker_ids_.size()));
output.push_back(",");
output.push_back("featured_sticker_set_ids_:"); output.push_back(std::to_string(featured_sticker_set_ids_.size()));
output.push_back(",");
output.push_back("installed_sticker_set_ids_:"); output.push_back(std::to_string(installed_sticker_set_ids_->size()));
output.push_back(",");
output.push_back("recent_sticker_file_ids_:"); output.push_back(std::to_string(recent_sticker_file_ids_->size()));
output.push_back(",");
output.push_back("recent_sticker_ids_:"); output.push_back(std::to_string(recent_sticker_ids_->size()));
output.push_back(",");
output.push_back("short_name_to_sticker_set_id_:"); output.push_back(std::to_string(short_name_to_sticker_set_id_.size()));
output.push_back(",");
output.push_back("special_sticker_sets_:"); output.push_back(std::to_string(special_sticker_sets_.size()));
output.push_back(",");
output.push_back("sticker_sets_:"); output.push_back(std::to_string(sticker_sets_.size()));
output.push_back(",");
output.push_back("stickers_:"); output.push_back(std::to_string(stickers_.size()));
}
} // namespace td

View File

@ -44,6 +44,8 @@ class StickersManager : public Actor {
void memory_cleanup();
void memory_stats(vector<string> &output);
static vector<StickerSetId> convert_sticker_set_ids(const vector<int64> &sticker_set_ids);
static vector<int64> convert_sticker_set_ids(const vector<StickerSetId> &sticker_set_ids);

View File

@ -87,6 +87,7 @@
#include "td/telegram/StickerSetId.h"
#include "td/telegram/StickersManager.h"
#include "td/telegram/StorageManager.h"
#include "td/telegram/MemoryManager.h"
#include "td/telegram/SuggestedAction.h"
#include "td/telegram/TdDb.h"
#include "td/telegram/TopDialogCategory.h"
@ -3347,6 +3348,8 @@ bool Td::is_preauthentication_request(int32 id) {
case td_api::getStorageStatistics::ID:
case td_api::getStorageStatisticsFast::ID:
case td_api::getDatabaseStatistics::ID:
case td_api::getMemoryStatistics::ID:
case td_api::optimizeMemory::ID:
case td_api::setNetworkType::ID:
case td_api::getNetworkStatistics::ID:
case td_api::addNetworkStatistics::ID:
@ -3872,6 +3875,8 @@ void Td::dec_actor_refcnt() {
LOG(DEBUG) << "PollManager was cleared" << timer;
stickers_manager_.reset();
LOG(DEBUG) << "StickersManager was cleared" << timer;
memory_manager_.reset();
LOG(DEBUG) << "MemoryManager was cleared" << timer;
updates_manager_.reset();
LOG(DEBUG) << "UpdatesManager was cleared" << timer;
video_notes_manager_.reset();
@ -4056,6 +4061,8 @@ void Td::clear() {
LOG(DEBUG) << "PollManager actor was cleared" << timer;
stickers_manager_actor_.reset();
LOG(DEBUG) << "StickersManager actor was cleared" << timer;
memory_manager_actor_.reset();
LOG(DEBUG) << "MemoryManager actor was cleared" << timer;
updates_manager_actor_.reset();
LOG(DEBUG) << "UpdatesManager actor was cleared" << timer;
web_pages_manager_actor_.reset();
@ -4496,6 +4503,9 @@ void Td::init_managers() {
stickers_manager_ = make_unique<StickersManager>(this, create_reference());
stickers_manager_actor_ = register_actor("StickersManager", stickers_manager_.get());
G()->set_stickers_manager(stickers_manager_actor_.get());
memory_manager_ = make_unique<MemoryManager>(this, create_reference());
memory_manager_actor_ = register_actor("MemoryManager", memory_manager_.get());
G()->set_memory_manager(memory_manager_actor_.get());
updates_manager_ = make_unique<UpdatesManager>(this, create_reference());
updates_manager_actor_ = register_actor("UpdatesManager", updates_manager_.get());
G()->set_updates_manager(updates_manager_actor_.get());
@ -4890,6 +4900,8 @@ void Td::on_request(uint64 id, const td_api::getCurrentState &request) {
stickers_manager_->get_current_state(updates);
memory_manager_->get_current_state(updates);
messages_manager_->get_current_state(updates);
notification_manager_->get_current_state(updates);
@ -5232,23 +5244,32 @@ void Td::on_request(uint64 id, td_api::getDatabaseStatistics &request) {
});
send_closure(storage_manager_, &StorageManager::get_database_stats, std::move(query_promise));
}
void Td::on_request(uint64 id, td_api::getMemoryStatistics &request) {
CREATE_REQUEST_PROMISE();
auto query_promise = PromiseCreator::lambda([promise = std::move(promise)](Result<MemoryStats> result) mutable {
if (result.is_error()) {
promise.set_error(result.move_as_error());
} else {
promise.set_value(result.ok().get_memory_statistics_object());
}
});
memory_manager_->get_memory_stats(request.full_, std::move(query_promise));
}
void Td::on_request(uint64 id, td_api::optimizeMemory &request) {
CREATE_REQUEST_PROMISE();
auto query_promise = PromiseCreator::lambda([promise = std::move(promise)](Result<Unit> result) mutable {
if (result.is_error()) {
promise.set_error(result.move_as_error());
} else {
promise.set_value(make_tl_object<td_api::ok>());
}
});
memory_manager_->clean_memory(request.full_, std::move(query_promise));
}
void Td::on_request(uint64 id, td_api::optimizeStorage &request) {
messages_manager_->memory_cleanup();
contacts_manager_->memory_cleanup();
web_pages_manager_->memory_cleanup();
stickers_manager_->memory_cleanup();
documents_manager_->memory_cleanup();
video_notes_manager_->memory_cleanup();
videos_manager_->memory_cleanup();
audios_manager_->memory_cleanup();
animations_manager_->memory_cleanup();
file_manager_->memory_cleanup();
#ifdef __linux__
malloc_trim(0);
#endif
std::vector<FileType> file_types;
for (auto &file_type : request.file_types_) {
if (file_type == nullptr) {

View File

@ -71,6 +71,7 @@ class SecureManager;
class SecretChatsManager;
class StickersManager;
class StorageManager;
class MemoryManager;
class TopDialogManager;
class UpdatesManager;
class VideoNotesManager;
@ -175,6 +176,8 @@ class Td final : public NetQueryCallback {
ActorOwn<StickersManager> stickers_manager_actor_;
unique_ptr<UpdatesManager> updates_manager_;
ActorOwn<UpdatesManager> updates_manager_actor_;
unique_ptr<MemoryManager> memory_manager_;
ActorOwn<MemoryManager> memory_manager_actor_;
unique_ptr<WebPagesManager> web_pages_manager_;
ActorOwn<WebPagesManager> web_pages_manager_actor_;
@ -519,6 +522,10 @@ class Td final : public NetQueryCallback {
void on_request(uint64 id, td_api::getDatabaseStatistics &request);
void on_request(uint64 id, td_api::getMemoryStatistics &request);
void on_request(uint64 id, td_api::optimizeMemory &request);
void on_request(uint64 id, td_api::optimizeStorage &request);
void on_request(uint64 id, td_api::getNetworkStatistics &request);

View File

@ -250,5 +250,8 @@ void VideoNotesManager::memory_cleanup() {
video_notes_.clear();
video_notes_.rehash(0);
}
void VideoNotesManager::memory_stats(vector<string> &output) {
output.push_back("video_notes_:"); output.push_back(std::to_string(video_notes_.size()));
}
} // namespace td

View File

@ -28,6 +28,8 @@ class VideoNotesManager {
void memory_cleanup();
void memory_stats(vector<string> &output);
int32 get_video_note_duration(FileId file_id) const;
tl_object_ptr<td_api::videoNote> get_video_note_object(FileId file_id);

View File

@ -329,5 +329,8 @@ void VideosManager::memory_cleanup() {
videos_.clear();
videos_.rehash(0);
}
void VideosManager::memory_stats(vector<string> &output) {
output.push_back("videos_:"); output.push_back(std::to_string(videos_.size()));
}
} // namespace td

View File

@ -28,6 +28,8 @@ class VideosManager {
void memory_cleanup();
void memory_stats(vector<string> &output);
int32 get_video_duration(FileId file_id) const;
tl_object_ptr<td_api::video> get_video_object(FileId file_id);

View File

@ -1775,4 +1775,18 @@ void WebPagesManager::memory_cleanup() {
url_to_file_source_id_.clear();
url_to_file_source_id_.rehash(0);
}
void WebPagesManager::memory_stats(vector<string> &output) {
output.push_back("web_pages_:"); output.push_back(std::to_string(web_pages_.size()));
output.push_back(",");
output.push_back("loaded_from_database_web_pages_:"); output.push_back(std::to_string(loaded_from_database_web_pages_.size()));
output.push_back(",");
output.push_back("web_page_messages_:"); output.push_back(std::to_string(web_page_messages_.size()));
output.push_back(",");
output.push_back("got_web_page_previews_:"); output.push_back(std::to_string(got_web_page_previews_.size()));
output.push_back(",");
output.push_back("url_to_web_page_id_:"); output.push_back(std::to_string(url_to_web_page_id_.size()));
output.push_back(",");
output.push_back("url_to_file_source_id_:"); output.push_back(std::to_string(url_to_file_source_id_.size()));
}
} // namespace td

View File

@ -39,6 +39,8 @@ class WebPagesManager : public Actor {
void memory_cleanup();
void memory_stats(vector<string> &output);
WebPagesManager(const WebPagesManager &) = delete;
WebPagesManager &operator=(const WebPagesManager &) = delete;
WebPagesManager(WebPagesManager &&) = delete;

View File

@ -2365,6 +2365,8 @@ class CliClient final : public Actor {
send_request(td_api::make_object<td_api::getStorageStatisticsFast>());
} else if (op == "database") {
send_request(td_api::make_object<td_api::getDatabaseStatistics>());
} else if (op == "memory") {
send_request(td_api::make_object<td_api::getMemoryStatistics>());
} else if (op == "optimize_storage" || op == "optimize_storage_all") {
string chat_ids;
string exclude_chat_ids;

View File

@ -4149,6 +4149,17 @@ void FileManager::memory_cleanup() {
LOG(ERROR) << "Final registered ids: " << file_id_info_.size() << " registered nodes: " << file_nodes_.size();
}
void FileManager::memory_stats(vector<string> &output) {
output.push_back("file_id_info_:"); output.push_back(std::to_string(file_id_info_.size()));
output.push_back(",");
output.push_back("file_nodes_:"); output.push_back(std::to_string(file_nodes_.size()));
output.push_back(",");
output.push_back("file_hash_to_file_id_:"); output.push_back(std::to_string(file_hash_to_file_id_.size()));
output.push_back(",");
output.push_back("file_id_seqno:"); output.push_back(std::to_string(file_id_seqno));
output.push_back(",");
output.push_back("file_node_seqno:"); output.push_back(std::to_string(file_node_seqno));
}
void FileManager::tear_down() {
parent_.reset();

View File

@ -349,6 +349,8 @@ class FileManager : public FileLoadManager::Callback {
public:
void memory_cleanup();
void memory_stats(vector<string> &output);
class DownloadCallback {
public:
DownloadCallback() = default;

1
tl-parser Submodule

@ -0,0 +1 @@
Subproject commit f49077de7f7aa5721483c5686182deebad5e78dd