Merge branch 'main' of https://github.com/alibaba-damo-academy/FunASR into main
| | |
| | | ```text |
| | | `mode`:`offline`,表示推理模式为一句话识别;`online`,表示推理模式为实时语音识别;`2pass`:表示为实时语音识别,并且说话句尾采用离线模型进行纠错。 |
| | | `wav_name`:表示需要推理音频文件名 |
| | | `wav_format`:表示音视频文件后缀名,可选pcm、mp3、mp4等(备注,1.0版本只支持pcm音频流) |
| | | `wav_format`:表示音视频文件后缀名,可选pcm、mp3、mp4等(备注:只支持pcm音频流) |
| | | `is_speaking`:表示断句尾点,例如,vad切割点,或者一条wav结束 |
| | | `chunk_size`:表示流式模型latency配置,`[5,10,5]`,表示当前音频为600ms,并且回看300ms,又看300ms。 |
| | | `audio_fs`:当输入音频为pcm数据是,需要加上音频采样率参数 |
| | |
| | | |
| | | # for onnxruntime |
| | | IF(WIN32) |
| | | # file(REMOVE ${PROJECT_SOURCE_DIR}/third_party/glog/src/config.h |
| | | # ${PROJECT_SOURCE_DIR}/third_party/glog/src/glog/export.h |
| | | # ${PROJECT_SOURCE_DIR}/third_party/glog/src/glog/logging.h |
| | | # ${PROJECT_SOURCE_DIR}/third_party/glog/src/glog/raw_logging.h |
| | | # ${PROJECT_SOURCE_DIR}/third_party/glog/src/glog/stl_logging.h |
| | | # ${PROJECT_SOURCE_DIR}/third_party/glog/src/glog/vlog_is_on.h) |
| | | file(REMOVE ${PROJECT_SOURCE_DIR}/third_party/glog/src/config.h |
| | | ${PROJECT_SOURCE_DIR}/third_party/glog/src/glog/export.h |
| | | ${PROJECT_SOURCE_DIR}/third_party/glog/src/glog/logging.h |
| | | ${PROJECT_SOURCE_DIR}/third_party/glog/src/glog/raw_logging.h |
| | | ${PROJECT_SOURCE_DIR}/third_party/glog/src/glog/stl_logging.h |
| | | ${PROJECT_SOURCE_DIR}/third_party/glog/src/glog/vlog_is_on.h) |
| | | ELSE() |
| | | link_directories(${ONNXRUNTIME_DIR}/lib) |
| | | link_directories(${FFMPEG_DIR}/lib) |
| | |
| | | # with some patch to fix the make errors. |
| | | add_subdirectory(third_party/openfst) |
| | | include_directories(${openfst_SOURCE_DIR}/src/include) |
| | | |
| | | if(WIN32) |
| | | include_directories(${openfst_SOURCE_DIR}/src/lib) |
| | | endif() |
| | | |
| | | endif() |
| | | |
| | | add_subdirectory(third_party/yaml-cpp) |
| | |
| | | if(WIN32) |
| | | add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/execution-charset:utf-8>") |
| | | add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/source-charset:utf-8>") |
| | | add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/bigobj>") |
| | | endif() |
| | | |
| | | add_library(funasr SHARED ${files}) |
| | |
| | | #include "bias-lm.h" |
| | | |
| | | #ifdef _WIN32 |
| | | #include "fst-types.cc" |
| | | #endif |
| | | namespace funasr { |
| | | void print(std::queue<StateId> &q) { |
| | | std::queue<StateId> data = q; |
| | |
| | | cmake_minimum_required (VERSION 3.21) |
| | | cmake_minimum_required (VERSION 3.16) |
| | | project (glog |
| | | VERSION 0.7.0 |
| | | DESCRIPTION "C++ implementation of the Google logging module" |
| | |
| | | check_cxx_symbol_exists (backtrace execinfo.h HAVE_EXECINFO_BACKTRACE) |
| | | check_cxx_symbol_exists (backtrace_symbols execinfo.h |
| | | HAVE_EXECINFO_BACKTRACE_SYMBOLS) |
| | | check_cxx_symbol_exists (_chsize_s io.h HAVE__CHSIZE_S) |
| | | |
| | | # NOTE gcc does not fail if you pass a non-existent -Wno-* option as an |
| | | # argument. However, it will happily fail if you pass the corresponding -W* |
| | |
| | | endif (WITH_TLS) |
| | | |
| | | set (_PC_FIELDS |
| | | "uc_mcontext.gregs[REG_PC]" # Solaris x86 (32 + 64 bit) |
| | | "uc_mcontext.gregs[REG_EIP]" # Linux (i386) |
| | | "uc_mcontext.gregs[REG_RIP]" # Linux (x86_64) |
| | | "uc_mcontext.sc_ip" # Linux (ia64) |
| | | "uc_mcontext.pc" # Linux (mips) |
| | | "uc_mcontext.uc_regs->gregs[PT_NIP]" # Linux (ppc) |
| | | "uc_mcontext.gregs[R15]" # Linux (arm old [untested]) |
| | | "uc_mcontext.arm_pc" # Linux (arm arch 5) |
| | | "uc_mcontext.gp_regs[PT_NIP]" # Suse SLES 11 (ppc64) |
| | | "uc_mcontext.mc_eip" # FreeBSD (i386) |
| | | "uc_mcontext.mc_rip" # FreeBSD (x86_64 [untested]) |
| | | "uc_mcontext.__gregs[_REG_EIP]" # NetBSD (i386) |
| | | "uc_mcontext.__gregs[_REG_RIP]" # NetBSD (x86_64) |
| | | "uc_mcontext->ss.eip" # OS X (i386, <=10.4) |
| | | "uc_mcontext->__ss.__eip" # OS X (i386, >=10.5) |
| | | "uc_mcontext->ss.rip" # OS X (x86_64) |
| | | "uc_mcontext->__ss.__rip" # OS X (>=10.5 [untested]) |
| | | "uc_mcontext->ss.srr0" # OS X (ppc, ppc64 [untested]) |
| | | "uc_mcontext->__ss.__srr0" # OS X (>=10.5 [untested]) |
| | | "gregs[REG_PC]" |
| | | "gregs[REG_EIP]" |
| | | "gregs[REG_RIP]" |
| | | "sc_ip" |
| | | "uc_regs->gregs[PT_NIP]" |
| | | "gregs[R15]" |
| | | "arm_pc" |
| | | "mc_eip" |
| | | "mc_rip" |
| | | "__gregs[REG_EIP]" |
| | | "__gregs[REG_RIP]" |
| | | "ss.eip" |
| | | "__ss.__eip" |
| | | "ss.rip" |
| | | "__ss.__rip" |
| | | "ss.srr0" |
| | | "__ss.__srr0" |
| | | ) |
| | | |
| | | if (HAVE_UCONTEXT_H AND NOT DEFINED PC_FROM_UCONTEXT) |
| | | cmake_push_check_state (RESET) |
| | | set (_PC_HEADERS ucontext.h signal.h) |
| | | |
| | | set (CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE) |
| | | set (_PC_HEADERS ucontext.h signal.h) |
| | | if (HAVE_UCONTEXT_H AND NOT PC_FROM_UCONTEXT) |
| | | foreach (_PC_FIELD ${_PC_FIELDS}) |
| | | foreach (_PC_HEADER ${_PC_HEADERS}) |
| | | set (_TMP |
| | | ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/uctfield.cpp) |
| | | file (WRITE ${_TMP} " |
| | | #define _GNU_SOURCE 1 |
| | | #include <${_PC_HEADER}> |
| | | int main(void) |
| | | { |
| | | ucontext_t u; |
| | | return u.${_PC_FIELD} == 0; |
| | | } |
| | | ") |
| | | try_compile (HAVE_PC_FROM_UCONTEXT ${CMAKE_CURRENT_BINARY_DIR} ${_TMP} |
| | | COMPILE_DEFINITIONS _GNU_SOURCE=1) |
| | | |
| | | foreach (_PC_FIELD IN LISTS _PC_FIELDS) |
| | | foreach (_PC_HEADER IN LISTS _PC_HEADERS) |
| | | # Replace non-alphanumeric characters by underscores since the name will be |
| | | # used as preprocessor definition. |
| | | string (REGEX REPLACE "[^a-zA-Z0-9]" "_" HAVE_UCONTEXT_FIELD_NAME |
| | | "HAVE_PC_FROM_UCONTEXT_${_PC_FIELD}") |
| | | # Strip trailing underscores for readability |
| | | string (REGEX REPLACE "_+$" "" HAVE_UCONTEXT_FIELD_NAME |
| | | "${HAVE_UCONTEXT_FIELD_NAME}") |
| | | |
| | | check_struct_has_member (ucontext_t ${_PC_FIELD} ${_PC_HEADER} |
| | | ${HAVE_UCONTEXT_FIELD_NAME} LANGUAGE CXX) |
| | | |
| | | if (${HAVE_UCONTEXT_FIELD_NAME}) |
| | | set (PC_FROM_UCONTEXT ${_PC_FIELD} CACHE STRING |
| | | "<${_PC_HEADER}> ucontext_t PC member") |
| | | mark_as_advanced (PC_FROM_UCONTEXT) |
| | | break () |
| | | endif (${HAVE_UCONTEXT_FIELD_NAME}) |
| | | if (HAVE_PC_FROM_UCONTEXT) |
| | | set (PC_FROM_UCONTEXT ${_PC_FIELD} CACHE) |
| | | endif (HAVE_PC_FROM_UCONTEXT) |
| | | endforeach (_PC_HEADER) |
| | | |
| | | if (${HAVE_UCONTEXT_FIELD_NAME}) |
| | | break () |
| | | endif (${HAVE_UCONTEXT_FIELD_NAME}) |
| | | endforeach (_PC_FIELD) |
| | | |
| | | cmake_pop_check_state () |
| | | endif (HAVE_UCONTEXT_H AND NOT DEFINED PC_FROM_UCONTEXT) |
| | | endif (HAVE_UCONTEXT_H AND NOT PC_FROM_UCONTEXT) |
| | | |
| | | set (GOOGLE_NAMESPACE google) |
| | | set (_START_GOOGLE_NAMESPACE_ "namespace ${GOOGLE_NAMESPACE} {") |
| | |
| | | src/demangle.h |
| | | src/logging.cc |
| | | src/raw_logging.cc |
| | | src/signalhandler.cc |
| | | src/symbolize.cc |
| | | src/symbolize.h |
| | | src/utilities.cc |
| | | src/utilities.h |
| | | src/vlog_is_on.cc |
| | | ) |
| | | |
| | | if (HAVE_PTHREAD OR WIN32 OR CYGWIN) |
| | | list (APPEND GLOG_SRCS src/signalhandler.cc) |
| | | endif (HAVE_PTHREAD OR WIN32 OR CYGWIN) |
| | | |
| | | if (CYGWIN OR WIN32) |
| | | list (APPEND GLOG_SRCS |
| | |
| | | ${GLOG_SRCS} |
| | | ) |
| | | target_compile_features (glog_internal PUBLIC $<TARGET_PROPERTY:glog,COMPILE_FEATURES>) |
| | | set_target_properties (glog_internal PROPERTIES DEFINE_SYMBOL GOOGLE_GLOG_IS_A_DLL) |
| | | |
| | | # Some generators (such as Xcode) do not generate any output if the target does |
| | | # not reference at least one source file. |
| | | set (_glog_EMPTY_SOURCE ${glog_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/glog.cc) |
| | | |
| | | add_custom_command ( |
| | | OUTPUT ${_glog_EMPTY_SOURCE} |
| | | COMMAND ${CMAKE_COMMAND} -E touch ${_glog_EMPTY_SOURCE} |
| | | ) |
| | | |
| | | add_library (glog |
| | | $<TARGET_OBJECTS:glog_internal> |
| | | ${_glog_EMPTY_SOURCE} |
| | | ) |
| | | target_compile_features (glog PUBLIC cxx_std_14) |
| | | |
| | |
| | | endif (NOT WITH_FUZZING STREQUAL "none") |
| | | |
| | | if (BUILD_TESTING) |
| | | add_library (glog_test INTERFACE) |
| | | target_link_libraries (glog_test INTERFACE $<TARGET_OBJECTS:glog_internal> $<TARGET_PROPERTY:glog,LINK_LIBRARIES>) |
| | | target_compile_definitions (glog_test INTERFACE GLOG_STATIC_DEFINE $<TARGET_PROPERTY:glog,COMPILE_DEFINITIONS>) |
| | | target_include_directories (glog_test INTERFACE $<TARGET_PROPERTY:glog,INCLUDE_DIRECTORIES>) |
| | | add_library (glogtest STATIC |
| | | $<TARGET_OBJECTS:glog_internal> |
| | | ) |
| | | |
| | | target_include_directories (glogtest PUBLIC |
| | | $<TARGET_PROPERTY:glog,INCLUDE_DIRECTORIES>) |
| | | target_compile_definitions (glogtest PUBLIC |
| | | $<TARGET_PROPERTY:glog,COMPILE_DEFINITIONS> GLOG_STATIC_DEFINE) |
| | | target_link_libraries (glogtest PUBLIC |
| | | $<TARGET_PROPERTY:glog,LINK_LIBRARIES>) |
| | | |
| | | set (_GLOG_TEST_LIBS glogtest) |
| | | |
| | | if (HAVE_LIB_GTEST) |
| | | target_link_libraries (glog_test INTERFACE GTest::gtest) |
| | | list (APPEND _GLOG_TEST_LIBS GTest::gtest) |
| | | endif (HAVE_LIB_GTEST) |
| | | |
| | | if (HAVE_LIB_GMOCK) |
| | | target_link_libraries (glog_test INTERFACE GTest::gmock) |
| | | list (APPEND _GLOG_TEST_LIBS GTest::gmock) |
| | | endif (HAVE_LIB_GMOCK) |
| | | |
| | | add_executable (logging_unittest |
| | | src/logging_unittest.cc |
| | | ) |
| | | |
| | | target_link_libraries (logging_unittest PRIVATE glog_test) |
| | | target_link_libraries (logging_unittest PRIVATE ${_GLOG_TEST_LIBS}) |
| | | |
| | | add_executable (stl_logging_unittest |
| | | src/stl_logging_unittest.cc |
| | | ) |
| | | |
| | | target_link_libraries (stl_logging_unittest PRIVATE glog_test) |
| | | target_link_libraries (stl_logging_unittest PRIVATE ${_GLOG_TEST_LIBS}) |
| | | |
| | | if (HAVE_NO_DEPRECATED) |
| | | set_property (TARGET stl_logging_unittest APPEND PROPERTY COMPILE_OPTIONS |
| | |
| | | src/symbolize_unittest.cc |
| | | ) |
| | | |
| | | target_link_libraries (symbolize_unittest PRIVATE glog_test) |
| | | target_link_libraries (symbolize_unittest PRIVATE ${_GLOG_TEST_LIBS}) |
| | | endif (HAVE_SYMBOLIZE) |
| | | |
| | | add_executable (demangle_unittest |
| | | src/demangle_unittest.cc |
| | | ) |
| | | |
| | | target_link_libraries (demangle_unittest PRIVATE glog_test) |
| | | target_link_libraries (demangle_unittest PRIVATE ${_GLOG_TEST_LIBS}) |
| | | |
| | | if (HAVE_STACKTRACE) |
| | | add_executable (stacktrace_unittest |
| | | src/stacktrace_unittest.cc |
| | | ) |
| | | |
| | | target_link_libraries (stacktrace_unittest PRIVATE glog_test) |
| | | target_link_libraries (stacktrace_unittest PRIVATE ${_GLOG_TEST_LIBS}) |
| | | endif (HAVE_STACKTRACE) |
| | | |
| | | add_executable (utilities_unittest |
| | | src/utilities_unittest.cc |
| | | ) |
| | | |
| | | target_link_libraries (utilities_unittest PRIVATE glog_test) |
| | | target_link_libraries (utilities_unittest PRIVATE ${_GLOG_TEST_LIBS}) |
| | | |
| | | if (HAVE_STACKTRACE AND HAVE_SYMBOLIZE) |
| | | add_executable (signalhandler_unittest |
| | | src/signalhandler_unittest.cc |
| | | ) |
| | | |
| | | target_link_libraries (signalhandler_unittest PRIVATE glog_test) |
| | | target_link_libraries (signalhandler_unittest PRIVATE ${_GLOG_TEST_LIBS}) |
| | | endif (HAVE_STACKTRACE AND HAVE_SYMBOLIZE) |
| | | |
| | | add_test (NAME demangle COMMAND demangle_unittest) |
| | |
| | | src/mock-log.h |
| | | ) |
| | | |
| | | target_link_libraries (mock-log_unittest PRIVATE glog_test) |
| | | target_link_libraries (mock-log_unittest PRIVATE ${_GLOG_TEST_LIBS}) |
| | | |
| | | add_test (NAME mock-log COMMAND mock-log_unittest) |
| | | endif (HAVE_LIB_GMOCK) |
| | |
| | | add_executable (cleanup_immediately_unittest |
| | | src/cleanup_immediately_unittest.cc) |
| | | |
| | | target_link_libraries (cleanup_immediately_unittest PRIVATE glog_test) |
| | | target_link_libraries (cleanup_immediately_unittest PRIVATE ${_GLOG_TEST_LIBS}) |
| | | |
| | | add_executable (cleanup_with_absolute_prefix_unittest |
| | | src/cleanup_with_absolute_prefix_unittest.cc) |
| | | |
| | | target_link_libraries (cleanup_with_absolute_prefix_unittest PRIVATE glog_test) |
| | | target_link_libraries (cleanup_with_absolute_prefix_unittest PRIVATE ${_GLOG_TEST_LIBS}) |
| | | |
| | | add_executable (cleanup_with_relative_prefix_unittest |
| | | src/cleanup_with_relative_prefix_unittest.cc) |
| | | |
| | | target_link_libraries (cleanup_with_relative_prefix_unittest PRIVATE glog_test) |
| | | target_link_libraries (cleanup_with_relative_prefix_unittest PRIVATE ${_GLOG_TEST_LIBS}) |
| | | |
| | | set (CLEANUP_LOG_DIR ${CMAKE_CURRENT_BINARY_DIR}/cleanup_tests) |
| | | |
| | |
| | | cmake_policy (PUSH) |
| | | cmake_policy (VERSION 3.16...3.27) |
| | | cmake_policy (VERSION 3.3) |
| | | |
| | | include (CMakeParseArguments) |
| | | |
| | |
| | | # Create the build directory |
| | | execute_process ( |
| | | COMMAND ${CMAKE_COMMAND} -E make_directory ${TEST_BINARY_DIR} |
| | | RESULT_VARIABLE _DIRECTORY_CREATED_SUCCEEDED |
| | | ) |
| | | |
| | | if (NOT _DIRECTORY_CREATED_SUCCEEDED EQUAL 0) |
| | | message (FATAL_ERROR "Failed to create build directory") |
| | | endif (NOT _DIRECTORY_CREATED_SUCCEEDED EQUAL 0) |
| | | |
| | | if (GENERATOR_TOOLSET) |
| | | list (APPEND _ADDITIONAL_ARGS -T ${GENERATOR_TOOLSET}) |
| | | endif (GENERATOR_TOOLSET) |
| | |
| | | # Capture the PATH environment variable content set during project generation |
| | | # stage. This is required because later during the build stage the PATH is |
| | | # modified again (e.g., for MinGW AppVeyor CI builds) by adding back the |
| | | # directory containing git.exe. Incidentally, the Git installation directory |
| | | # directory containing git.exe. Incidently, the Git installation directory |
| | | # also contains sh.exe which causes MinGW Makefile generation to fail. |
| | | COMMAND ${CMAKE_COMMAND} -E env PATH=${PATH} |
| | | ${CMAKE_COMMAND} -C ${INITIAL_CACHE} |
| | |
| | | ${_ADDITIONAL_ARGS} |
| | | -DCMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY=ON |
| | | -DCMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY=ON |
| | | -Dglog_ROOT=${PACKAGE_DIR} |
| | | -S ${SOURCE_DIR} |
| | | -B ${TEST_BINARY_DIR} |
| | | -DCMAKE_PREFIX_PATH=${PACKAGE_DIR} |
| | | ${SOURCE_DIR} |
| | | WORKING_DIRECTORY ${TEST_BINARY_DIR} |
| | | RESULT_VARIABLE _GENERATE_SUCCEEDED |
| | | ) |
| | | |
| | |
| | | |
| | | #else |
| | | |
| | | #include "glog/logging.h" |
| | | #include <glog/logging.h> |
| | | |
| | | #define DECLARE_VARIABLE(type, shorttype, name, tn) \ |
| | | namespace fL##shorttype { \ |
| | |
| | | : memchr("tTyY1\0", getenv(envname)[0], 6) != nullptr) |
| | | |
| | | #define EnvToInt(envname, dflt) \ |
| | | (!getenv(envname) ? (dflt) \ |
| | | : static_cast<int>(strtol(getenv(envname), nullptr, 10))) |
| | | (!getenv(envname) ? (dflt) : strtol(getenv(envname), nullptr, 10)) |
| | | |
| | | #define EnvToUInt(envname, dflt) \ |
| | | (!getenv(envname) \ |
| | | ? (dflt) \ |
| | | : static_cast<unsigned>(strtoul(getenv(envname), nullptr, 10))) |
| | | (!getenv(envname) ? (dflt) : strtoul(getenv(envname), nullptr, 10)) |
| | | |
| | | #endif // BASE_COMMANDLINEFLAGS_H__ |
| | |
| | | /* define if gmtime_r is available in time.h */ |
| | | #cmakedefine HAVE_GMTIME_R |
| | | |
| | | /* define if _chsize_s is available in io.h */ |
| | | #cmakedefine HAVE__CHSIZE_S |
| | | |
| | | /* Define to the sub-directory in which libtool stores uninstalled libraries. |
| | | */ |
| | | #cmakedefine LT_OBJDIR |
| | | |
| | | /* How to access the PC from a struct ucontext */ |
| | | #cmakedefine PC_FROM_UCONTEXT ${PC_FROM_UCONTEXT} |
| | | #cmakedefine PC_FROM_UCONTEXT |
| | | |
| | | /* define if we should print file offsets in traces instead of symbolizing. */ |
| | | #cmakedefine PRINT_UNSYMBOLIZED_STACK_TRACES |
| | |
| | | |
| | | #include "demangle.h" |
| | | |
| | | #include <cstddef> |
| | | #include <cstdio> // for nullptr |
| | | #include <limits> |
| | | |
| | | #include "utilities.h" |
| | | |
| | |
| | | short nest_level; // For nested names. |
| | | bool append; // Append flag. |
| | | bool overflowed; // True if output gets overflowed. |
| | | uint32 local_level; |
| | | uint32 expr_level; |
| | | uint32 arg_level; |
| | | }; |
| | | |
| | | // We don't use strlen() in libc since it's not guaranteed to be async |
| | |
| | | state->nest_level = -1; |
| | | state->append = true; |
| | | state->overflowed = false; |
| | | state->local_level = 0; |
| | | state->expr_level = 0; |
| | | state->arg_level = 0; |
| | | } |
| | | |
| | | // Returns true and advances "mangled_cur" if we find "one_char_token" |
| | |
| | | // is set to true for later use. The output string is ensured to |
| | | // always terminate with '\0' as long as there is no overflow. |
| | | static void Append(State *state, const char * const str, ssize_t length) { |
| | | if (state->out_cur == nullptr) { |
| | | state->overflowed = true; |
| | | return; |
| | | } |
| | | for (ssize_t i = 0; i < length; ++i) { |
| | | if (state->out_cur + 1 < state->out_end) { // +1 for '\0' |
| | | *state->out_cur = str[i]; |
| | |
| | | } |
| | | } |
| | | |
| | | // A convenient wrapper around MaybeAppendWithLength(). |
| | | // A convenient wrapper arount MaybeAppendWithLength(). |
| | | static bool MaybeAppend(State *state, const char * const str) { |
| | | if (state->append) { |
| | | size_t length = StrLen(str); |
| | |
| | | } |
| | | const char *p = state->mangled_cur; |
| | | int number = 0; |
| | | constexpr int int_max_by_10 = std::numeric_limits<int>::max() / 10; |
| | | for (;*p != '\0'; ++p) { |
| | | if (IsDigit(*p)) { |
| | | // Prevent signed integer overflow when multiplying |
| | | if (number > int_max_by_10) { |
| | | return false; |
| | | } |
| | | |
| | | const int digit = *p - '0'; |
| | | const int shifted = number * 10; |
| | | |
| | | // Prevent signed integer overflow when summing |
| | | if (digit > std::numeric_limits<int>::max() - shifted) { |
| | | return false; |
| | | } |
| | | |
| | | number = shifted + digit; |
| | | number = number * 10 + (*p - '0'); |
| | | } else { |
| | | break; |
| | | } |
| | |
| | | MaybeAppend(state, "(anonymous namespace)"); |
| | | } else { |
| | | MaybeAppendWithLength(state, state->mangled_cur, length); |
| | | } |
| | | if (length < 0 || |
| | | static_cast<std::size_t>(length) > StrLen(state->mangled_cur)) { |
| | | return false; |
| | | } |
| | | state->mangled_cur += length; |
| | | return true; |
| | |
| | | // ::= J <template-arg>* E # argument pack |
| | | // ::= X <expression> E |
| | | static bool ParseTemplateArg(State *state) { |
| | | // Avoid recursion above max_levels |
| | | constexpr uint32 max_levels = 5; |
| | | |
| | | if (state->arg_level > max_levels) { |
| | | return false; |
| | | } |
| | | ++state->arg_level; |
| | | |
| | | State copy = *state; |
| | | if ((ParseOneCharToken(state, 'I') || ParseOneCharToken(state, 'J')) && |
| | | ZeroOrMore(ParseTemplateArg, state) && |
| | | ParseOneCharToken(state, 'E')) { |
| | | --state->arg_level; |
| | | return true; |
| | | } |
| | | *state = copy; |
| | | |
| | | if (ParseType(state) || |
| | | ParseExprPrimary(state)) { |
| | | --state->arg_level; |
| | | return true; |
| | | } |
| | | *state = copy; |
| | | |
| | | if (ParseOneCharToken(state, 'X') && ParseExpression(state) && |
| | | ParseOneCharToken(state, 'E')) { |
| | | --state->arg_level; |
| | | return true; |
| | | } |
| | | *state = copy; |
| | |
| | | return true; |
| | | } |
| | | |
| | | // Avoid recursion above max_levels |
| | | constexpr uint32 max_levels = 5; |
| | | |
| | | if (state->expr_level > max_levels) { |
| | | return false; |
| | | } |
| | | ++state->expr_level; |
| | | |
| | | State copy = *state; |
| | | if (ParseOperatorName(state) && |
| | | ParseExpression(state) && |
| | | ParseExpression(state) && |
| | | ParseExpression(state)) { |
| | | --state->expr_level; |
| | | return true; |
| | | } |
| | | *state = copy; |
| | |
| | | if (ParseOperatorName(state) && |
| | | ParseExpression(state) && |
| | | ParseExpression(state)) { |
| | | --state->expr_level; |
| | | return true; |
| | | } |
| | | *state = copy; |
| | | |
| | | if (ParseOperatorName(state) && |
| | | ParseExpression(state)) { |
| | | --state->expr_level; |
| | | return true; |
| | | } |
| | | *state = copy; |
| | | |
| | | if (ParseTwoCharToken(state, "st") && ParseType(state)) { |
| | | return true; |
| | | --state->expr_level; |
| | | } |
| | | *state = copy; |
| | | |
| | | if (ParseTwoCharToken(state, "sr") && ParseType(state) && |
| | | ParseUnqualifiedName(state) && |
| | | ParseTemplateArgs(state)) { |
| | | --state->expr_level; |
| | | return true; |
| | | } |
| | | *state = copy; |
| | | |
| | | if (ParseTwoCharToken(state, "sr") && ParseType(state) && |
| | | ParseUnqualifiedName(state)) { |
| | | --state->expr_level; |
| | | return true; |
| | | } |
| | | *state = copy; |
| | |
| | | // [<discriminator>] |
| | | // := Z <(function) encoding> E s [<discriminator>] |
| | | static bool ParseLocalName(State *state) { |
| | | // Avoid recursion above max_levels |
| | | constexpr uint32 max_levels = 5; |
| | | if (state->local_level > max_levels) { |
| | | return false; |
| | | } |
| | | ++state->local_level; |
| | | |
| | | State copy = *state; |
| | | if (ParseOneCharToken(state, 'Z') && ParseEncoding(state) && |
| | | ParseOneCharToken(state, 'E') && MaybeAppend(state, "::") && |
| | | ParseName(state) && Optional(ParseDiscriminator(state))) { |
| | | --state->local_level; |
| | | return true; |
| | | } |
| | | *state = copy; |
| | | |
| | | if (ParseOneCharToken(state, 'Z') && ParseEncoding(state) && |
| | | ParseTwoCharToken(state, "Es") && Optional(ParseDiscriminator(state))) { |
| | | --state->local_level; |
| | | return true; |
| | | } |
| | | *state = copy; |
| | |
| | | #define BASE_DEMANGLE_H_ |
| | | |
| | | #include "config.h" |
| | | #include "glog/logging.h" |
| | | #include <glog/logging.h> |
| | | |
| | | _START_GOOGLE_NAMESPACE_ |
| | | |
| | |
| | | #define GLOG_MSVC_POP_WARNING() |
| | | #endif |
| | | |
| | | #include "glog/platform.h" |
| | | #include <glog/platform.h> |
| | | |
| | | #if @ac_cv_have_glog_export@ |
| | | #include "glog/export.h" |
| | | #include <glog/export.h> |
| | | #endif |
| | | |
| | | // We care a lot about number of bits things take up. Unfortunately, |
| | |
| | | // "program with --v=1 or more"; |
| | | // VLOG_EVERY_N(1, 10) |
| | | // << "I'm printed every 10th occurrence, and when you run the program " |
| | | // "with --v=1 or more. Present occurrence is " << google::COUNTER; |
| | | // "with --v=1 or more. Present occurence is " << google::COUNTER; |
| | | // VLOG_IF_EVERY_N(1, (size > 1024), 10) |
| | | // << "I'm printed on every 10th occurrence of case when size is more " |
| | | // << "I'm printed on every 10th occurence of case when size is more " |
| | | // " than 1024, when you run the program with --v=1 or more. "; |
| | | // "Present occurrence is " << google::COUNTER; |
| | | // "Present occurence is " << google::COUNTER; |
| | | // |
| | | // The supported severity levels for macros that allow you to specify one |
| | | // are (in increasing order of severity) INFO, WARNING, ERROR, and FATAL. |
| | |
| | | // Use UTC time for logging |
| | | DECLARE_bool(log_utc_time); |
| | | |
| | | // Mailer used to send logging email |
| | | DECLARE_string(logmailer); |
| | | |
| | | // Log messages below the GOOGLE_STRIP_LOG level will be compiled away for |
| | | // security reasons. See LOG(severtiy) below. |
| | | |
| | |
| | | @ac_google_start_namespace@ |
| | | |
| | | // They need the definitions of integer types. |
| | | #include "glog/log_severity.h" |
| | | #include "glog/vlog_is_on.h" |
| | | #include <glog/log_severity.h> |
| | | #include <glog/vlog_is_on.h> |
| | | |
| | | // Initialize google's logging library. You will see the program name |
| | | // specified by argv0 in log outputs. |
| | |
| | | #define CHECK_OP_LOG(name, op, val1, val2, log) CHECK((val1) op (val2)) |
| | | #elif DCHECK_IS_ON() |
| | | // In debug mode, avoid constructing CheckOpStrings if possible, |
| | | // to reduce the overhead of CHECK statements by 2x. |
| | | // to reduce the overhead of CHECK statments by 2x. |
| | | // Real DCHECK-heavy tests have seen 1.5x speedups. |
| | | |
| | | // The meaning of "string" might be different between now and |
| | |
| | | constexpr std::chrono::nanoseconds LOG_TIME_PERIOD = \ |
| | | std::chrono::duration_cast<std::chrono::nanoseconds>( \ |
| | | std::chrono::duration<double>(seconds)); \ |
| | | static std::atomic<@ac_google_namespace@::int64> LOG_PREVIOUS_TIME_RAW; \ |
| | | static std::atomic<@ac_google_namespace@ ::int64> LOG_PREVIOUS_TIME_RAW; \ |
| | | GLOG_IFDEF_THREAD_SANITIZER( \ |
| | | AnnotateBenignRaceSized(__FILE__, __LINE__, &LOG_TIME_PERIOD, \ |
| | | sizeof(@ac_google_namespace@::int64), "")); \ |
| | | sizeof(@ac_google_namespace @ ::int64), "")); \ |
| | | GLOG_IFDEF_THREAD_SANITIZER( \ |
| | | AnnotateBenignRaceSized(__FILE__, __LINE__, &LOG_PREVIOUS_TIME_RAW, \ |
| | | sizeof(@ac_google_namespace@::int64), "")); \ |
| | | sizeof(@ac_google_namespace @ ::int64), "")); \ |
| | | const auto LOG_CURRENT_TIME = \ |
| | | std::chrono::duration_cast<std::chrono::nanoseconds>( \ |
| | | std::chrono::steady_clock::now().time_since_epoch()); \ |
| | |
| | | .count(), \ |
| | | std::memory_order_relaxed); \ |
| | | if (LOG_TIME_DELTA > LOG_TIME_PERIOD) \ |
| | | @ac_google_namespace@::LogMessage( \ |
| | | __FILE__, __LINE__, @ac_google_namespace@::GLOG_##severity) \ |
| | | @ac_google_namespace@ ::LogMessage( \ |
| | | __FILE__, __LINE__, @ac_google_namespace@ ::GLOG_##severity) \ |
| | | .stream() |
| | | |
| | | #define SOME_KIND_OF_LOG_EVERY_N(severity, n, what_to_do) \ |
| | |
| | | class GLOG_EXPORT LogStream : public std::ostream { |
| | | GLOG_MSVC_POP_WARNING() |
| | | public: |
| | | #if defined __has_attribute |
| | | # if __has_attribute (used) |
| | | // In some cases, like when compiling glog as a static library with GCC and |
| | | // linking against a Clang-built executable, this constructor will be |
| | | // removed by the linker. We use this attribute to prevent the linker from |
| | | // discarding it. |
| | | __attribute__ ((used)) |
| | | # endif |
| | | #endif |
| | | LogStream(char *buf, int len, int64 ctr) |
| | | : std::ostream(NULL), |
| | | streambuf_(buf, len), |
| | |
| | | // is so that streaming can be done more efficiently. |
| | | static const size_t kMaxLogMessageLen; |
| | | |
| | | // These should not be called directly outside of logging.*, |
| | | // Theses should not be called directly outside of logging.*, |
| | | // only passed as SendMethod arguments to other LogMessage methods: |
| | | void SendToLog(); // Actually dispatch to the logs |
| | | void SendToSyslogAndLog(); // Actually dispatch to syslog and the logs |
| | |
| | | GLOG_EXPORT void SetEmailLogging(LogSeverity min_severity, |
| | | const char* addresses); |
| | | |
| | | // A simple function that sends email. dest is a comma-separated |
| | | // list of addresses. Thread-safe. |
| | | // A simple function that sends email. dest is a commma-separated |
| | | // list of addressess. Thread-safe. |
| | | GLOG_EXPORT bool SendEmail(const char* dest, const char* subject, |
| | | const char* body); |
| | | |
| | |
| | | // (they'll never be actually displayed). This will be needed if a |
| | | // NullStream& is implicitly converted to LogStream&, in which case |
| | | // the overloaded NullStream::operator<< will not be invoked. |
| | | NullStream(); |
| | | NullStream() : LogMessage::LogStream(message_buffer_, 1, 0) { } |
| | | NullStream(const char* /*file*/, int /*line*/, |
| | | const CheckOpString& /*result*/); |
| | | NullStream& stream(); |
| | | |
| | | const CheckOpString& /*result*/) : |
| | | LogMessage::LogStream(message_buffer_, 1, 0) { } |
| | | NullStream &stream() { return *this; } |
| | | private: |
| | | // A very short buffer for messages (which we discard anyway). This |
| | | // will be needed if NullStream& converted to LogStream& (e.g. as a |
| | |
| | | // trace), like LogMessageFatal. |
| | | class GLOG_EXPORT NullStreamFatal : public NullStream { |
| | | public: |
| | | using NullStream::NullStream; |
| | | [[noreturn]] ~NullStreamFatal(); |
| | | NullStreamFatal() { } |
| | | NullStreamFatal(const char* file, int line, const CheckOpString& result) : |
| | | NullStream(file, line, result) { } |
| | | #if defined(_MSC_VER) |
| | | #pragma warning(push) |
| | | #pragma warning(disable : 4722) |
| | | #endif // _MSC_VER |
| | | [[noreturn]] ~NullStreamFatal() throw() { _exit(EXIT_FAILURE); } |
| | | #if defined(_MSC_VER) |
| | | #pragma warning(pop) |
| | | #endif // _MSC_VER |
| | | }; |
| | | |
| | | // Install a signal handler that will dump signal information and a stack |
| | |
| | | #include <ctime> |
| | | |
| | | @ac_google_start_namespace@ |
| | | #include "glog/log_severity.h" |
| | | #include "glog/logging.h" |
| | | #include "glog/vlog_is_on.h" |
| | | |
| | | #include <glog/log_severity.h> |
| | | #include <glog/logging.h> |
| | | #include <glog/vlog_is_on.h> |
| | | |
| | | #if defined(__GNUC__) |
| | | #pragma GCC diagnostic push |
| | |
| | | #ifndef BASE_VLOG_IS_ON_H_ |
| | | #define BASE_VLOG_IS_ON_H_ |
| | | |
| | | #include <cstddef> |
| | | #include <glog/log_severity.h> |
| | | |
| | | #include "glog/log_severity.h" |
| | | #include <cstddef> |
| | | |
| | | #if defined(__GNUC__) |
| | | // We emit an anonymous static int* variable at every VLOG_IS_ON(n) site. |
| | |
| | | #define VLOG_IS_ON(verboselevel) \ |
| | | __extension__ \ |
| | | ({ static @ac_google_namespace@::SiteFlag vlocal__ = {NULL, NULL, 0, NULL}; \ |
| | | GLOG_IFDEF_THREAD_SANITIZER( \ |
| | | AnnotateBenignRaceSized(__FILE__, __LINE__, &vlocal__, sizeof(@ac_google_namespace@::SiteFlag), "")); \ |
| | | @ac_google_namespace@::int32 verbose_level__ = (verboselevel); \ |
| | | (vlocal__.level == NULL ? @ac_google_namespace@::InitVLOG3__(&vlocal__, &FLAGS_v, \ |
| | | __FILE__, verbose_level__) : *vlocal__.level >= verbose_level__); \ |
| | |
| | | SiteFlag* next; |
| | | }; |
| | | |
| | | // Helper routine which determines the logging info for a particular VLOG site. |
| | | // Helper routine which determines the logging info for a particalur VLOG site. |
| | | // site_flag is the address of the site-local pointer to the controlling |
| | | // verbosity level |
| | | // site_default is the default to use for *site_flag |
| | |
| | | |
| | | #include <algorithm> |
| | | #include <cassert> |
| | | #include <cstddef> |
| | | #include <iomanip> |
| | | #include <iterator> |
| | | #include <string> |
| | | |
| | | #ifdef HAVE_UNISTD_H |
| | | # include <unistd.h> // For _exit. |
| | | #endif |
| | |
| | | #ifdef HAVE_SYSLOG_H |
| | | # include <syslog.h> |
| | | #endif |
| | | #ifdef HAVE__CHSIZE_S |
| | | #include <io.h> // for truncate log file |
| | | #endif |
| | | #include <vector> |
| | | #include <cerrno> // for errno |
| | | #include <sstream> |
| | | #include <regex> |
| | | #include <cctype> // for std::isspace |
| | | #ifdef GLOG_OS_WINDOWS |
| | | #include "windows/dirent.h" |
| | | #else |
| | | #include <dirent.h> // for automatic removal of old logs |
| | | #endif |
| | | #include "base/commandlineflags.h" // to get the program name |
| | | #include "base/commandlineflags.h" // to get the program name |
| | | #include <glog/logging.h> |
| | | #include <glog/raw_logging.h> |
| | | #include "base/googleinit.h" |
| | | #include "glog/logging.h" |
| | | #include "glog/raw_logging.h" |
| | | |
| | | #ifdef HAVE_STACKTRACE |
| | | # include "stacktrace.h" |
| | |
| | | // allocations). |
| | | static thread_local bool thread_data_available = true; |
| | | |
| | | #if defined(__cpp_lib_byte) && __cpp_lib_byte >= 201603L |
| | | // std::aligned_storage is deprecated in C++23 |
| | | alignas(LogMessage::LogMessageData) static thread_local std::byte |
| | | thread_msg_data[sizeof(LogMessage::LogMessageData)]; |
| | | #else // !(defined(__cpp_lib_byte) && __cpp_lib_byte >= 201603L) |
| | | static thread_local std::aligned_storage< |
| | | sizeof(LogMessage::LogMessageData), |
| | | alignof(LogMessage::LogMessageData)>::type thread_msg_data; |
| | | #endif // defined(__cpp_lib_byte) && __cpp_lib_byte >= 201603L |
| | | #endif // defined(GLOG_THREAD_LOCAL_STORAGE) |
| | | |
| | | LogMessage::LogMessageData::LogMessageData() |
| | |
| | | GLOG_EXPORT logging_fail_func_t g_logging_fail_func = |
| | | reinterpret_cast<logging_fail_func_t>(&abort); |
| | | |
| | | NullStream::NullStream() : LogMessage::LogStream(message_buffer_, 1, 0) {} |
| | | NullStream::NullStream(const char* /*file*/, int /*line*/, |
| | | const CheckOpString& /*result*/) |
| | | : LogMessage::LogStream(message_buffer_, 1, 0) {} |
| | | NullStream& NullStream::stream() { return *this; } |
| | | |
| | | NullStreamFatal::~NullStreamFatal() { _exit(EXIT_FAILURE); } |
| | | |
| | | void InstallFailureFunction(logging_fail_func_t fail_func) { |
| | | g_logging_fail_func = fail_func; |
| | | } |
| | |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | // Trim whitespace from both ends of the provided string. |
| | | static inline void trim(std::string &s) { |
| | | const auto toRemove = [](char ch) { return std::isspace(ch) == 0; }; |
| | | s.erase(s.begin(), std::find_if(s.begin(), s.end(), toRemove)); |
| | | s.erase(std::find_if(s.rbegin(), s.rend(), toRemove).base(), s.end()); |
| | | } |
| | | #endif |
| | | |
| | | // use_logging controls whether the logging functions LOG/VLOG are used |
| | |
| | | const char*body, bool use_logging) { |
| | | #ifndef GLOG_OS_EMSCRIPTEN |
| | | if (dest && *dest) { |
| | | // Split the comma-separated list of email addresses, validate each one and |
| | | // build a sanitized new comma-separated string without whitespace. |
| | | std::istringstream ss(dest); |
| | | std::ostringstream sanitized_dests; |
| | | std::string s; |
| | | while (std::getline(ss, s, ',')) { |
| | | trim(s); |
| | | if (s.empty()) { |
| | | continue; |
| | | } |
| | | // We validate the provided email addresses using the same regular |
| | | // expression that HTML5 uses[1], except that we require the address to |
| | | // start with an alpha-numeric character. This is because we don't want to |
| | | // allow email addresses that start with a special character, such as a |
| | | // pipe or dash, which could be misunderstood as a command-line flag by |
| | | // certain versions of `mail` that are vulnerable to command injection.[2] |
| | | // [1] https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address |
| | | // [2] e.g. https://nvd.nist.gov/vuln/detail/CVE-2004-2771 |
| | | if (!std::regex_match( |
| | | s, |
| | | std::regex("^[a-zA-Z0-9]" |
| | | "[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]*@[a-zA-Z0-9]" |
| | | "(?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9]" |
| | | "(?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$"))) { |
| | | if (use_logging) { |
| | | VLOG(1) << "Invalid destination email address:" << s; |
| | | } else { |
| | | fprintf(stderr, "Invalid destination email address: %s\n", |
| | | s.c_str()); |
| | | } |
| | | return false; |
| | | } |
| | | if (!sanitized_dests.str().empty()) { |
| | | sanitized_dests << ","; |
| | | } |
| | | sanitized_dests << s; |
| | | } |
| | | // Avoid dangling reference |
| | | const std::string& tmp = sanitized_dests.str(); |
| | | dest = tmp.c_str(); |
| | | |
| | | if ( use_logging ) { |
| | | VLOG(1) << "Trying to send TITLE:" << subject |
| | | << " BODY:" << body << " to " << dest; |
| | |
| | | |
| | | FILE* pipe = popen(cmd.c_str(), "w"); |
| | | if (pipe != nullptr) { |
| | | // Add the body if we have one |
| | | if (body) { |
| | | // Add the body if we have one |
| | | if (body) { |
| | | fwrite(body, sizeof(char), strlen(body), pipe); |
| | | } |
| | | bool ok = pclose(pipe) != -1; |
| | |
| | | logging_directories_list = new vector<string>; |
| | | |
| | | if ( !FLAGS_log_dir.empty() ) { |
| | | // Ensure the specified path ends with a directory delimiter. |
| | | if (std::find(std::begin(possible_dir_delim), std::end(possible_dir_delim), |
| | | FLAGS_log_dir.back()) == std::end(possible_dir_delim)) { |
| | | logging_directories_list->push_back(FLAGS_log_dir + "/"); |
| | | } else { |
| | | logging_directories_list->push_back(FLAGS_log_dir); |
| | | } |
| | | // A dir was specified, we should use it |
| | | logging_directories_list->push_back(FLAGS_log_dir); |
| | | } else { |
| | | GetTempDirectories(logging_directories_list); |
| | | #ifdef GLOG_OS_WINDOWS |
| | |
| | | } |
| | | |
| | | void TruncateLogFile(const char *path, uint64 limit, uint64 keep) { |
| | | #if defined(HAVE_UNISTD_H) || defined(HAVE__CHSIZE_S) |
| | | #ifdef HAVE_UNISTD_H |
| | | struct stat statbuf; |
| | | const int kCopyBlockSize = 8 << 10; |
| | | char copybuf[kCopyBlockSize]; |
| | |
| | | // all of base/...) with -D_FILE_OFFSET_BITS=64 but that's |
| | | // rather scary. |
| | | // Instead just truncate the file to something we can manage |
| | | #ifdef HAVE__CHSIZE_S |
| | | if (_chsize_s(fd, 0) != 0) { |
| | | #else |
| | | if (truncate(path, 0) == -1) { |
| | | #endif |
| | | PLOG(ERROR) << "Unable to truncate " << path; |
| | | } else { |
| | | LOG(ERROR) << "Truncated " << path << " due to EFBIG error"; |
| | |
| | | // Truncate the remainder of the file. If someone else writes to the |
| | | // end of the file after our last read() above, we lose their latest |
| | | // data. Too bad ... |
| | | #ifdef HAVE__CHSIZE_S |
| | | if (_chsize_s(fd, write_offset) != 0) { |
| | | #else |
| | | if (ftruncate(fd, write_offset) == -1) { |
| | | #endif |
| | | PLOG(ERROR) << "Unable to truncate " << path; |
| | | } |
| | | |
| | |
| | | #define GLOG_SRC_MOCK_LOG_H_ |
| | | |
| | | // For GOOGLE_NAMESPACE. This must go first so we get _XOPEN_SOURCE. |
| | | #include <gmock/gmock.h> |
| | | #include "utilities.h" |
| | | |
| | | #include <string> |
| | | |
| | | #include "glog/logging.h" |
| | | #include "utilities.h" |
| | | #include <gmock/gmock.h> |
| | | |
| | | #include <glog/logging.h> |
| | | |
| | | _START_GOOGLE_NAMESPACE_ |
| | | namespace glog_testing { |
| | |
| | | #ifdef HAVE_UNISTD_H |
| | | # include <unistd.h> // for close() and write() |
| | | #endif |
| | | #include <fcntl.h> // for open() |
| | | |
| | | #include <fcntl.h> // for open() |
| | | #include <ctime> |
| | | |
| | | #include "base/commandlineflags.h" |
| | | #include "config.h" |
| | | #include "glog/logging.h" // To pick up flag settings etc. |
| | | #include "glog/raw_logging.h" |
| | | #include <glog/logging.h> // To pick up flag settings etc. |
| | | #include <glog/raw_logging.h> |
| | | #include "base/commandlineflags.h" |
| | | |
| | | #ifdef HAVE_STACKTRACE |
| | | # include "stacktrace.h" |
| | |
| | | #endif |
| | | |
| | | #if (defined(HAVE_SYSCALL_H) || defined(HAVE_SYS_SYSCALL_H)) && \ |
| | | (!(defined(GLOG_OS_MACOSX)) && !(defined(GLOG_OS_OPENBSD))) && \ |
| | | !defined(GLOG_OS_EMSCRIPTEN) |
| | | (!(defined(GLOG_OS_MACOSX))) && !defined(GLOG_OS_EMSCRIPTEN) |
| | | #define safe_write(fd, s, len) syscall(SYS_write, fd, s, len) |
| | | #else |
| | | // Not so safe, but what can you do? |
| | |
| | | // |
| | | // Implementation of InstallFailureSignalHandler(). |
| | | |
| | | #include <csignal> |
| | | #include <ctime> |
| | | |
| | | #include "glog/logging.h" |
| | | #include "utilities.h" |
| | | #include "stacktrace.h" |
| | | #include "symbolize.h" |
| | | #include "utilities.h" |
| | | #include <glog/logging.h> |
| | | |
| | | #include <csignal> |
| | | #include <ctime> |
| | | #ifdef HAVE_UCONTEXT_H |
| | | # include <ucontext.h> |
| | | #endif |
| | |
| | | #define BASE_STACKTRACE_H_ |
| | | |
| | | #include "config.h" |
| | | #include "glog/logging.h" |
| | | #include <glog/logging.h> |
| | | |
| | | _START_GOOGLE_NAMESPACE_ |
| | | |
| | |
| | | #define UNW_LOCAL_ONLY |
| | | #include <libunwind.h> |
| | | } |
| | | #include "glog/raw_logging.h" |
| | | #include <glog/raw_logging.h> |
| | | #include "stacktrace.h" |
| | | |
| | | _START_GOOGLE_NAMESPACE_ |
| | |
| | | // This check is in case the compiler doesn't define _CALL_SYSV. |
| | | result[n++] = *(sp+1); |
| | | #else |
| | | #error Need to specify the PPC ABI for your architecture. |
| | | #error Need to specify the PPC ABI for your archiecture. |
| | | #endif |
| | | } |
| | | // Use strict unwinding rules. |
| | |
| | | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| | | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| | | |
| | | #include "stacktrace.h" |
| | | #include "utilities.h" |
| | | |
| | | #include <cstdio> |
| | | #include <cstdlib> |
| | | |
| | | #include "base/commandlineflags.h" |
| | | #include "config.h" |
| | | #include "glog/logging.h" |
| | | #include "utilities.h" |
| | | #include "base/commandlineflags.h" |
| | | #include <glog/logging.h> |
| | | #include "stacktrace.h" |
| | | |
| | | #ifdef HAVE_EXECINFO_BACKTRACE_SYMBOLS |
| | | # include <execinfo.h> |
| | |
| | | #include <elf.h> |
| | | #endif |
| | | #include <fcntl.h> |
| | | #include <glog/raw_logging.h> |
| | | #include <sys/stat.h> |
| | | #include <sys/types.h> |
| | | #include <unistd.h> |
| | |
| | | #include <cstring> |
| | | |
| | | #include "config.h" |
| | | #include "glog/raw_logging.h" |
| | | #include "symbolize.h" |
| | | |
| | | // Re-runs fn until it doesn't cause EINTR. |
| | |
| | | // Iterate over maps and look for the map containing the pc. Then |
| | | // look into the symbol tables inside. |
| | | char buf[1024]; // Big enough for line of sane /proc/self/maps |
| | | unsigned num_maps = 0; |
| | | LineReader reader(wrapped_maps_fd.get(), buf, sizeof(buf), 0); |
| | | while (true) { |
| | | num_maps++; |
| | | const char *cursor; |
| | | const char *eol; |
| | | if (!reader.ReadLine(&cursor, &eol)) { // EOF or malformed line. |
| | |
| | | #ifndef BASE_SYMBOLIZE_H_ |
| | | #define BASE_SYMBOLIZE_H_ |
| | | |
| | | #include "config.h" |
| | | #include "glog/logging.h" |
| | | #include "utilities.h" |
| | | #include "config.h" |
| | | #include <glog/logging.h> |
| | | |
| | | #ifdef HAVE_SYMBOLIZE |
| | | |
| | |
| | | return getpid(); // Linux: getpid returns thread ID when gettid is absent |
| | | #elif defined GLOG_OS_WINDOWS && !defined GLOG_OS_CYGWIN |
| | | return static_cast<pid_t>(GetCurrentThreadId()); |
| | | #elif defined GLOG_OS_OPENBSD |
| | | return getthrid(); |
| | | #elif defined(HAVE_PTHREAD) |
| | | // If none of the techniques above worked, we use pthread_self(). |
| | | return (pid_t)(uintptr_t)pthread_self(); |
| | |
| | | // |
| | | // Author: Shinichiro Hamaji |
| | | // |
| | | // Define utilities for glog internal usage. |
| | | // Define utilties for glog internal usage. |
| | | |
| | | #ifndef UTILITIES_H__ |
| | | #define UTILITIES_H__ |
| | |
| | | #define PRIXS __PRIS_PREFIX "X" |
| | | #define PRIoS __PRIS_PREFIX "o" |
| | | |
| | | #include "base/mutex.h" // This must go first so we get _XOPEN_SOURCE |
| | | |
| | | #include <string> |
| | | |
| | | #include "base/mutex.h" // This must go first so we get _XOPEN_SOURCE |
| | | #include "glog/logging.h" |
| | | #include <glog/logging.h> |
| | | |
| | | #if defined(GLOG_OS_WINDOWS) |
| | | # include "port.h" |
| | |
| | | :"=a"(ret) |
| | | // GCC may produces %sil or %dil for |
| | | // constraint "r", but some of apple's gas |
| | | // doesn't know the 8 bit registers. |
| | | // dosn't know the 8 bit registers. |
| | | // We use "q" to avoid these registers. |
| | | :"q"(newval), "q"(ptr), "a"(oldval) |
| | | :"memory", "cc"); |
| | |
| | | // Broken out from logging.cc by Soren Lassen |
| | | // logging_unittest.cc covers the functionality herein |
| | | |
| | | #include "utilities.h" |
| | | |
| | | #include <cstring> |
| | | #include <cstdlib> |
| | | #include <cerrno> |
| | | #include <cstdio> |
| | | #include <cstdlib> |
| | | #include <cstring> |
| | | #include <string> |
| | | |
| | | #include "base/commandlineflags.h" |
| | | #include <glog/logging.h> |
| | | #include <glog/raw_logging.h> |
| | | #include "base/googleinit.h" |
| | | #include "glog/logging.h" |
| | | #include "glog/raw_logging.h" |
| | | #include "utilities.h" |
| | | |
| | | // glog doesn't have annotation |
| | | #define ANNOTATE_BENIGN_RACE(address, description) |
| | |
| | | FILE(GLOB HEADER_FILES ../include/fst/*.h) |
| | | |
| | | |
| | | if(WIN32) |
| | | add_library(fst STATIC |
| | | compat.cc |
| | | flags.cc |
| | | fst-types.cc |
| | | fst.cc |
| | | mapped-file.cc |
| | | properties.cc |
| | | symbol-table.cc |
| | | symbol-table-ops.cc |
| | | util.cc |
| | | weight.cc |
| | | ${HEADER_FILES} |
| | | ) |
| | | else() |
| | | add_library(fst |
| | | compat.cc |
| | | flags.cc |
| | |
| | | weight.cc |
| | | ${HEADER_FILES} |
| | | ) |
| | | endif() |
| | | |
| | | set_target_properties(fst PROPERTIES |
| | | SOVERSION "${SOVERSION}" |
| | | ) |
| | |
| | | # Libtorch-python |
| | | |
| | | ## Export the model |
| | | |
| | | ### Install [modelscope and funasr](https://github.com/alibaba-damo-academy/FunASR#installation) |
| | | |
| | | ```shell |
| | |
| | | python -m funasr.export.export_model --model-name damo/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-pytorch --export-dir ./export --type torch --quantize True |
| | | ``` |
| | | |
| | | ## Install the `funasr_torch`. |
| | | |
| | | ## Install the `funasr_torch` |
| | | |
| | | install from pip |
| | | |
| | | ```shell |
| | | pip install -U funasr_torch |
| | | # For the users in China, you could install with the command: |
| | | # pip install -U funasr_torch -i https://mirror.sjtu.edu.cn/pypi/web/simple |
| | | ``` |
| | | |
| | | or install from source code |
| | | |
| | | ```shell |
| | |
| | | # pip install -e ./ -i https://mirror.sjtu.edu.cn/pypi/web/simple |
| | | ``` |
| | | |
| | | ## Run the demo. |
| | | ## Run the demo |
| | | |
| | | - Model_dir: the model path, which contains `model.torchscripts`, `config.yaml`, `am.mvn`. |
| | | - Input: wav formt file, support formats: `str, np.ndarray, List[str]` |
| | | - Output: `List[str]`: recognition result. |
| | | - Example: |
| | | |
| | | ```python |
| | | from funasr_torch import Paraformer |
| | | |
| | |
| | | |
| | | ## Performance benchmark |
| | | |
| | | Please ref to [benchmark](https://github.com/alibaba-damo-academy/FunASR/blob/main/funasr/runtime/python/benchmark_libtorch.md) |
| | | Please ref to [benchmark](https://github.com/alibaba-damo-academy/FunASR/blob/main/runtime/docs/benchmark_libtorch.md) |
| | | |
| | | ## Speed |
| | | |
| | |
| | | | Onnx | 0.038 | |
| | | |
| | | ## Acknowledge |
| | | |
| | | This project is maintained by [FunASR community](https://github.com/alibaba-damo-academy/FunASR). |
| | |
| | | |
| | | ## Performance benchmark |
| | | |
| | | Please ref to [benchmark](https://github.com/alibaba-damo-academy/FunASR/blob/main/funasr/runtime/docs/benchmark_onnx.md) |
| | | Please ref to [benchmark](https://github.com/alibaba-damo-academy/FunASR/blob/main/runtime/docs/benchmark_onnx.md) |
| | | |
| | | ## Acknowledge |
| | | |
| | |
| | | # with some patch to fix the make errors. |
| | | add_subdirectory(${PROJECT_SOURCE_DIR}/../onnxruntime/third_party/openfst openfst) |
| | | include_directories(${openfst_SOURCE_DIR}/src/include) |
| | | |
| | | if(WIN32) |
| | | include_directories(${openfst_SOURCE_DIR}/src/lib) |
| | | endif() |
| | | endif() |
| | | |
| | | |