mirror of
https://github.com/modelscope/FunASR
synced 2025-09-15 14:48:36 +08:00
add glog/*.h for ios
This commit is contained in:
parent
be7ddfc4cd
commit
bf35a4a4e7
@ -323,7 +323,7 @@ initConfiguration(){
|
||||
$DEFAULT_FUNASR_CONFIG_DIR=$DEFAULT_FUNASR_CONFIG_DIR_BAK
|
||||
fi
|
||||
fi
|
||||
DEFAULT_FUNASR_CONFIG_DIR=${DEFAULT_FUNASR_CONFIG_DIR}/.funasr
|
||||
DEFAULT_FUNASR_CONFIG_DIR=${DEFAULT_FUNASR_CONFIG_DIR}/.funasr_en
|
||||
fi
|
||||
|
||||
if [ ! -z "$DEFAULT_FUNASR_CONFIG_DIR" ]; then
|
||||
|
||||
@ -324,7 +324,7 @@ initConfiguration(){
|
||||
$DEFAULT_FUNASR_CONFIG_DIR=$DEFAULT_FUNASR_CONFIG_DIR_BAK
|
||||
fi
|
||||
fi
|
||||
DEFAULT_FUNASR_CONFIG_DIR=${DEFAULT_FUNASR_CONFIG_DIR}/.funasr
|
||||
DEFAULT_FUNASR_CONFIG_DIR=${DEFAULT_FUNASR_CONFIG_DIR}/.funasr_offline
|
||||
fi
|
||||
|
||||
if [ ! -z "$DEFAULT_FUNASR_CONFIG_DIR" ]; then
|
||||
|
||||
177
runtime/onnxruntime/third_party/glog/src/config.h
vendored
Normal file
177
runtime/onnxruntime/third_party/glog/src/config.h
vendored
Normal file
@ -0,0 +1,177 @@
|
||||
#ifndef GLOG_CONFIG_H
|
||||
#define GLOG_CONFIG_H
|
||||
|
||||
/* Namespace for Google classes */
|
||||
#define GOOGLE_NAMESPACE google
|
||||
|
||||
/* Define if you have the `dladdr' function */
|
||||
#define HAVE_DLADDR
|
||||
|
||||
/* Define if you have the `snprintf' function */
|
||||
#define HAVE_SNPRINTF
|
||||
|
||||
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||
#define HAVE_DLFCN_H
|
||||
|
||||
/* Define if you have the `backtrace' function in <execinfo.h> */
|
||||
#define HAVE_EXECINFO_BACKTRACE
|
||||
|
||||
/* Define if you have the `backtrace_symbols' function in <execinfo.h> */
|
||||
#define HAVE_EXECINFO_BACKTRACE_SYMBOLS
|
||||
|
||||
/* Define if you have the `fcntl' function */
|
||||
#define HAVE_FCNTL
|
||||
|
||||
/* Define to 1 if you have the <glob.h> header file. */
|
||||
#define HAVE_GLOB_H
|
||||
|
||||
/* Define to 1 if you have the `pthread' library (-lpthread). */
|
||||
/* #undef HAVE_LIBPTHREAD */
|
||||
|
||||
/* define if you have google gflags library */
|
||||
/* #undef HAVE_LIB_GFLAGS */
|
||||
|
||||
/* define if you have google gmock library */
|
||||
/* #undef HAVE_LIB_GMOCK */
|
||||
|
||||
/* define if you have google gtest library */
|
||||
/* #undef HAVE_LIB_GTEST */
|
||||
|
||||
/* define if you have dbghelp library */
|
||||
/* #undef HAVE_DBGHELP */
|
||||
|
||||
/* define if you have libunwind */
|
||||
/* #undef HAVE_LIB_UNWIND */
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#define HAVE_MEMORY_H
|
||||
|
||||
/* define to disable multithreading support. */
|
||||
/* #undef NO_THREADS */
|
||||
|
||||
/* Define if you have the 'pread' function */
|
||||
#define HAVE_PREAD
|
||||
|
||||
/* Define if you have POSIX threads libraries and header files. */
|
||||
#define HAVE_PTHREAD
|
||||
|
||||
/* Define to 1 if you have the <pwd.h> header file. */
|
||||
#define HAVE_PWD_H
|
||||
|
||||
/* Define if you have the 'pwrite' function */
|
||||
#define HAVE_PWRITE
|
||||
|
||||
/* define if the compiler implements pthread_rwlock_* */
|
||||
#define HAVE_RWLOCK
|
||||
|
||||
/* Define if you have the 'sigaction' function */
|
||||
#define HAVE_SIGACTION
|
||||
|
||||
/* Define if you have the `sigaltstack' function */
|
||||
#define HAVE_SIGALTSTACK
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#define HAVE_STRINGS_H
|
||||
|
||||
/* Define to 1 if you have the <syscall.h> header file. */
|
||||
/* #undef HAVE_SYSCALL_H */
|
||||
|
||||
/* Define to 1 if you have the <syslog.h> header file. */
|
||||
#define HAVE_SYSLOG_H
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#define HAVE_SYS_STAT_H
|
||||
|
||||
/* Define to 1 if you have the <sys/syscall.h> header file. */
|
||||
#define HAVE_SYS_SYSCALL_H
|
||||
|
||||
/* Define to 1 if you have the <sys/time.h> header file. */
|
||||
#define HAVE_SYS_TIME_H
|
||||
|
||||
/* 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 <sys/ucontext.h> header file. */
|
||||
/* #undef HAVE_SYS_UCONTEXT_H */
|
||||
|
||||
/* Define to 1 if you have the <sys/utsname.h> header file. */
|
||||
#define HAVE_SYS_UTSNAME_H
|
||||
|
||||
/* Define to 1 if you have the <sys/wait.h> header file. */
|
||||
#define HAVE_SYS_WAIT_H
|
||||
|
||||
/* Define to 1 if you have the <ucontext.h> header file. */
|
||||
/* #undef HAVE_UCONTEXT_H */
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#define HAVE_UNISTD_H 1
|
||||
|
||||
/* Define if you linking to _Unwind_Backtrace is possible. */
|
||||
#define HAVE__UNWIND_BACKTRACE
|
||||
|
||||
/* Define if you linking to _Unwind_GetIP is possible. */
|
||||
#define HAVE__UNWIND_GETIP
|
||||
|
||||
/* define if your compiler has __attribute__ */
|
||||
#define HAVE___ATTRIBUTE__
|
||||
|
||||
/* define if your compiler has __builtin_expect */
|
||||
#define HAVE___BUILTIN_EXPECT 1
|
||||
|
||||
/* define if your compiler has __sync_val_compare_and_swap */
|
||||
#define HAVE___SYNC_VAL_COMPARE_AND_SWAP
|
||||
|
||||
/* define if symbolize support is available */
|
||||
/* #undef HAVE_SYMBOLIZE */
|
||||
|
||||
/* define if localtime_r is available in time.h */
|
||||
#define HAVE_LOCALTIME_R
|
||||
|
||||
/* define if gmtime_r is available in time.h */
|
||||
/* #undef HAVE_GMTIME_R */
|
||||
|
||||
/* Define to the sub-directory in which libtool stores uninstalled libraries.
|
||||
*/
|
||||
/* #undef LT_OBJDIR */
|
||||
|
||||
/* How to access the PC from a struct ucontext */
|
||||
/* #undef PC_FROM_UCONTEXT */
|
||||
|
||||
/* define if we should print file offsets in traces instead of symbolizing. */
|
||||
/* #undef PRINT_UNSYMBOLIZED_STACK_TRACES */
|
||||
|
||||
/* Define to necessary symbol if this constant uses a non-standard name on
|
||||
your system. */
|
||||
/* #undef PTHREAD_CREATE_JOINABLE */
|
||||
|
||||
/* The size of `void *', as computed by sizeof. */
|
||||
#define SIZEOF_VOID_P 8
|
||||
|
||||
/* location of source code */
|
||||
#define TEST_SRC_DIR "/Users/qiuwei/Documents/邱威/语音识别-asr/to_alibaba-damo-academy/FunASR/funasr/runtime/onnxruntime/third_party/glog"
|
||||
|
||||
/* Define if thread-local storage is enabled. */
|
||||
#define GLOG_THREAD_LOCAL_STORAGE
|
||||
|
||||
#ifdef GLOG_BAZEL_BUILD
|
||||
|
||||
/* TODO(rodrigoq): remove this workaround once bazel#3979 is resolved:
|
||||
* https://github.com/bazelbuild/bazel/issues/3979 */
|
||||
#define _START_GOOGLE_NAMESPACE_ namespace GOOGLE_NAMESPACE {
|
||||
|
||||
#define _END_GOOGLE_NAMESPACE_ }
|
||||
|
||||
#else
|
||||
|
||||
/* Stops putting the code inside the Google namespace */
|
||||
#define _END_GOOGLE_NAMESPACE_ }
|
||||
|
||||
/* Puts following code inside the Google namespace */
|
||||
#define _START_GOOGLE_NAMESPACE_ namespace google {
|
||||
|
||||
#endif
|
||||
|
||||
/* Replacement for deprecated syscall(SYS_gettid) on macOS. */
|
||||
#define HAVE_PTHREAD_THREADID_NP 1
|
||||
|
||||
#endif // GLOG_CONFIG_H
|
||||
42
runtime/onnxruntime/third_party/glog/src/glog/export.h
vendored
Normal file
42
runtime/onnxruntime/third_party/glog/src/glog/export.h
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
|
||||
#ifndef GLOG_EXPORT_H
|
||||
#define GLOG_EXPORT_H
|
||||
|
||||
#ifdef GLOG_STATIC_DEFINE
|
||||
# define GLOG_EXPORT
|
||||
# define GLOG_NO_EXPORT
|
||||
#else
|
||||
# ifndef GLOG_EXPORT
|
||||
# ifdef GOOGLE_GLOG_IS_A_DLL
|
||||
/* We are building this library */
|
||||
# define GLOG_EXPORT __attribute__((visibility("default")))
|
||||
# else
|
||||
/* We are using this library */
|
||||
# define GLOG_EXPORT __attribute__((visibility("default")))
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# ifndef GLOG_NO_EXPORT
|
||||
# define GLOG_NO_EXPORT __attribute__((visibility("hidden")))
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef GLOG_DEPRECATED
|
||||
# define GLOG_DEPRECATED __attribute__ ((__deprecated__))
|
||||
#endif
|
||||
|
||||
#ifndef GLOG_DEPRECATED_EXPORT
|
||||
# define GLOG_DEPRECATED_EXPORT GLOG_EXPORT GLOG_DEPRECATED
|
||||
#endif
|
||||
|
||||
#ifndef GLOG_DEPRECATED_NO_EXPORT
|
||||
# define GLOG_DEPRECATED_NO_EXPORT GLOG_NO_EXPORT GLOG_DEPRECATED
|
||||
#endif
|
||||
|
||||
#if 0 /* DEFINE_NO_DEPRECATED */
|
||||
# ifndef GLOG_NO_DEPRECATED
|
||||
# define GLOG_NO_DEPRECATED
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#endif /* GLOG_EXPORT_H */
|
||||
1842
runtime/onnxruntime/third_party/glog/src/glog/logging.h
vendored
Normal file
1842
runtime/onnxruntime/third_party/glog/src/glog/logging.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
179
runtime/onnxruntime/third_party/glog/src/glog/raw_logging.h
vendored
Normal file
179
runtime/onnxruntime/third_party/glog/src/glog/raw_logging.h
vendored
Normal file
@ -0,0 +1,179 @@
|
||||
// Copyright (c) 2006, Google Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Author: Maxim Lifantsev
|
||||
//
|
||||
// Thread-safe logging routines that do not allocate any memory or
|
||||
// acquire any locks, and can therefore be used by low-level memory
|
||||
// allocation and synchronization code.
|
||||
|
||||
#ifndef GLOG_RAW_LOGGING_H
|
||||
#define GLOG_RAW_LOGGING_H
|
||||
|
||||
#include <ctime>
|
||||
|
||||
namespace google {
|
||||
|
||||
#include <glog/log_severity.h>
|
||||
#include <glog/logging.h>
|
||||
#include <glog/vlog_is_on.h>
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wvariadic-macros"
|
||||
#endif
|
||||
|
||||
// This is similar to LOG(severity) << format... and VLOG(level) << format..,
|
||||
// but
|
||||
// * it is to be used ONLY by low-level modules that can't use normal LOG()
|
||||
// * it is desiged to be a low-level logger that does not allocate any
|
||||
// memory and does not need any locks, hence:
|
||||
// * it logs straight and ONLY to STDERR w/o buffering
|
||||
// * it uses an explicit format and arguments list
|
||||
// * it will silently chop off really long message strings
|
||||
// Usage example:
|
||||
// RAW_LOG(ERROR, "Failed foo with %i: %s", status, error);
|
||||
// RAW_VLOG(3, "status is %i", status);
|
||||
// These will print an almost standard log lines like this to stderr only:
|
||||
// E20200821 211317 file.cc:123] RAW: Failed foo with 22: bad_file
|
||||
// I20200821 211317 file.cc:142] RAW: status is 20
|
||||
#define RAW_LOG(severity, ...) \
|
||||
do { \
|
||||
switch (google::GLOG_ ## severity) { \
|
||||
case 0: \
|
||||
RAW_LOG_INFO(__VA_ARGS__); \
|
||||
break; \
|
||||
case 1: \
|
||||
RAW_LOG_WARNING(__VA_ARGS__); \
|
||||
break; \
|
||||
case 2: \
|
||||
RAW_LOG_ERROR(__VA_ARGS__); \
|
||||
break; \
|
||||
case 3: \
|
||||
RAW_LOG_FATAL(__VA_ARGS__); \
|
||||
break; \
|
||||
default: \
|
||||
break; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
// The following STRIP_LOG testing is performed in the header file so that it's
|
||||
// possible to completely compile out the logging code and the log messages.
|
||||
#if !defined(STRIP_LOG) || STRIP_LOG == 0
|
||||
#define RAW_VLOG(verboselevel, ...) \
|
||||
do { \
|
||||
if (VLOG_IS_ON(verboselevel)) { \
|
||||
RAW_LOG_INFO(__VA_ARGS__); \
|
||||
} \
|
||||
} while (0)
|
||||
#else
|
||||
#define RAW_VLOG(verboselevel, ...) RawLogStub__(0, __VA_ARGS__)
|
||||
#endif // STRIP_LOG == 0
|
||||
|
||||
#if !defined(STRIP_LOG) || STRIP_LOG == 0
|
||||
#define RAW_LOG_INFO(...) google::RawLog__(google::GLOG_INFO, \
|
||||
__FILE__, __LINE__, __VA_ARGS__)
|
||||
#else
|
||||
#define RAW_LOG_INFO(...) google::RawLogStub__(0, __VA_ARGS__)
|
||||
#endif // STRIP_LOG == 0
|
||||
|
||||
#if !defined(STRIP_LOG) || STRIP_LOG <= 1
|
||||
#define RAW_LOG_WARNING(...) google::RawLog__(google::GLOG_WARNING, \
|
||||
__FILE__, __LINE__, __VA_ARGS__)
|
||||
#else
|
||||
#define RAW_LOG_WARNING(...) google::RawLogStub__(0, __VA_ARGS__)
|
||||
#endif // STRIP_LOG <= 1
|
||||
|
||||
#if !defined(STRIP_LOG) || STRIP_LOG <= 2
|
||||
#define RAW_LOG_ERROR(...) google::RawLog__(google::GLOG_ERROR, \
|
||||
__FILE__, __LINE__, __VA_ARGS__)
|
||||
#else
|
||||
#define RAW_LOG_ERROR(...) google::RawLogStub__(0, __VA_ARGS__)
|
||||
#endif // STRIP_LOG <= 2
|
||||
|
||||
#if !defined(STRIP_LOG) || STRIP_LOG <= 3
|
||||
#define RAW_LOG_FATAL(...) google::RawLog__(google::GLOG_FATAL, \
|
||||
__FILE__, __LINE__, __VA_ARGS__)
|
||||
#else
|
||||
#define RAW_LOG_FATAL(...) \
|
||||
do { \
|
||||
google::RawLogStub__(0, __VA_ARGS__); \
|
||||
exit(EXIT_FAILURE); \
|
||||
} while (0)
|
||||
#endif // STRIP_LOG <= 3
|
||||
|
||||
// Similar to CHECK(condition) << message,
|
||||
// but for low-level modules: we use only RAW_LOG that does not allocate memory.
|
||||
// We do not want to provide args list here to encourage this usage:
|
||||
// if (!cond) RAW_LOG(FATAL, "foo ...", hard_to_compute_args);
|
||||
// so that the args are not computed when not needed.
|
||||
#define RAW_CHECK(condition, message) \
|
||||
do { \
|
||||
if (!(condition)) { \
|
||||
RAW_LOG(FATAL, "Check %s failed: %s", #condition, message); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
// Debug versions of RAW_LOG and RAW_CHECK
|
||||
#ifndef NDEBUG
|
||||
|
||||
#define RAW_DLOG(severity, ...) RAW_LOG(severity, __VA_ARGS__)
|
||||
#define RAW_DCHECK(condition, message) RAW_CHECK(condition, message)
|
||||
|
||||
#else // NDEBUG
|
||||
|
||||
#define RAW_DLOG(severity, ...) \
|
||||
while (false) \
|
||||
RAW_LOG(severity, __VA_ARGS__)
|
||||
#define RAW_DCHECK(condition, message) \
|
||||
while (false) \
|
||||
RAW_CHECK(condition, message)
|
||||
|
||||
#endif // NDEBUG
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
// Stub log function used to work around for unused variable warnings when
|
||||
// building with STRIP_LOG > 0.
|
||||
static inline void RawLogStub__(int /* ignored */, ...) {
|
||||
}
|
||||
|
||||
// Helper function to implement RAW_LOG and RAW_VLOG
|
||||
// Logs format... at "severity" level, reporting it
|
||||
// as called from file:line.
|
||||
// This does not allocate memory or acquire locks.
|
||||
GLOG_EXPORT void RawLog__(LogSeverity severity, const char* file, int line,
|
||||
const char* format, ...)
|
||||
__attribute__((__format__(__printf__, 4, 5)));
|
||||
|
||||
}
|
||||
|
||||
#endif // GLOG_RAW_LOGGING_H
|
||||
177
runtime/onnxruntime/third_party/glog/src/glog/stl_logging.h
vendored
Normal file
177
runtime/onnxruntime/third_party/glog/src/glog/stl_logging.h
vendored
Normal file
@ -0,0 +1,177 @@
|
||||
// Copyright (c) 2003, Google Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Stream output operators for STL containers; to be used for logging *only*.
|
||||
// Inclusion of this file lets you do:
|
||||
//
|
||||
// list<string> x;
|
||||
// LOG(INFO) << "data: " << x;
|
||||
// vector<int> v1, v2;
|
||||
// CHECK_EQ(v1, v2);
|
||||
//
|
||||
// If you want to use this header file with hash maps or slist, you
|
||||
// need to define macros before including this file:
|
||||
//
|
||||
// - GLOG_STL_LOGGING_FOR_UNORDERED - <unordered_map> and <unordered_set>
|
||||
// - GLOG_STL_LOGGING_FOR_TR1_UNORDERED - <tr1/unordered_(map|set)>
|
||||
// - GLOG_STL_LOGGING_FOR_EXT_HASH - <ext/hash_(map|set)>
|
||||
// - GLOG_STL_LOGGING_FOR_EXT_SLIST - <ext/slist>
|
||||
//
|
||||
|
||||
#ifndef UTIL_GTL_STL_LOGGING_INL_H_
|
||||
#define UTIL_GTL_STL_LOGGING_INL_H_
|
||||
|
||||
#include <deque>
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <ostream>
|
||||
#include <set>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
// Forward declare these two, and define them after all the container streams
|
||||
// operators so that we can recurse from pair -> container -> container -> pair
|
||||
// properly.
|
||||
template<class First, class Second>
|
||||
std::ostream& operator<<(std::ostream& out, const std::pair<First, Second>& p);
|
||||
|
||||
namespace google {
|
||||
|
||||
template<class Iter>
|
||||
void PrintSequence(std::ostream& out, Iter begin, Iter end);
|
||||
|
||||
}
|
||||
#define OUTPUT_TWO_ARG_CONTAINER(Sequence) \
|
||||
template<class T1, class T2> \
|
||||
inline std::ostream& operator<<(std::ostream& out, \
|
||||
const Sequence<T1, T2>& seq) { \
|
||||
google::PrintSequence(out, seq.begin(), seq.end()); \
|
||||
return out; \
|
||||
}
|
||||
|
||||
OUTPUT_TWO_ARG_CONTAINER(std::vector) OUTPUT_TWO_ARG_CONTAINER(std::deque)
|
||||
OUTPUT_TWO_ARG_CONTAINER(std::list)
|
||||
|
||||
#undef OUTPUT_TWO_ARG_CONTAINER
|
||||
|
||||
#define OUTPUT_THREE_ARG_CONTAINER(Sequence) \
|
||||
template<class T1, class T2, class T3> \
|
||||
inline std::ostream& operator<<(std::ostream& out, \
|
||||
const Sequence<T1, T2, T3>& seq) { \
|
||||
google::PrintSequence(out, seq.begin(), seq.end()); \
|
||||
return out; \
|
||||
}
|
||||
|
||||
OUTPUT_THREE_ARG_CONTAINER(std::set) OUTPUT_THREE_ARG_CONTAINER(
|
||||
std::multiset)
|
||||
|
||||
#undef OUTPUT_THREE_ARG_CONTAINER
|
||||
|
||||
#define OUTPUT_FOUR_ARG_CONTAINER(Sequence) \
|
||||
template<class T1, class T2, class T3, class T4> \
|
||||
inline std::ostream& operator<<(std::ostream& out, \
|
||||
const Sequence<T1, T2, T3, T4>& seq) { \
|
||||
google::PrintSequence(out, seq.begin(), seq.end()); \
|
||||
return out; \
|
||||
}
|
||||
|
||||
OUTPUT_FOUR_ARG_CONTAINER(std::map) OUTPUT_FOUR_ARG_CONTAINER(
|
||||
std::multimap) OUTPUT_FOUR_ARG_CONTAINER(std::unordered_set)
|
||||
OUTPUT_FOUR_ARG_CONTAINER(std::unordered_multiset)
|
||||
|
||||
#undef OUTPUT_FOUR_ARG_CONTAINER
|
||||
|
||||
#define OUTPUT_FIVE_ARG_CONTAINER(Sequence) \
|
||||
template<class T1, class T2, class T3, class T4, class T5> \
|
||||
inline std::ostream& operator<<(std::ostream& out, \
|
||||
const Sequence<T1, T2, T3, T4, T5>& seq) { \
|
||||
google::PrintSequence(out, seq.begin(), seq.end()); \
|
||||
return out; \
|
||||
}
|
||||
|
||||
#if defined(GLOG_STL_LOGGING_FOR_UNORDERED) && __cplusplus >= 201103L
|
||||
OUTPUT_FIVE_ARG_CONTAINER(std::unordered_map)
|
||||
OUTPUT_FIVE_ARG_CONTAINER(std::unordered_multimap)
|
||||
#endif
|
||||
|
||||
#undef OUTPUT_FIVE_ARG_CONTAINER
|
||||
|
||||
template <class First, class Second>
|
||||
inline std::ostream& operator<<(
|
||||
std::ostream& out,
|
||||
const std::pair<First, Second>& p) {
|
||||
out << '(' << p.first << ", " << p.second << ')';
|
||||
return out;
|
||||
}
|
||||
|
||||
namespace google {
|
||||
|
||||
template<class Iter>
|
||||
inline void PrintSequence(std::ostream& out, Iter begin, Iter end) {
|
||||
// Output at most 100 elements -- appropriate if used for logging.
|
||||
for (int i = 0; begin != end && i < 100; ++i, ++begin) {
|
||||
if (i > 0) out << ' ';
|
||||
out << *begin;
|
||||
}
|
||||
if (begin != end) {
|
||||
out << " ...";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Note that this is technically undefined behavior! We are adding things into
|
||||
// the std namespace for a reason though -- we are providing new operations on
|
||||
// types which are themselves defined with this namespace. Without this, these
|
||||
// operator overloads cannot be found via ADL. If these definitions are not
|
||||
// found via ADL, they must be #included before they're used, which requires
|
||||
// this header to be included before apparently independent other headers.
|
||||
//
|
||||
// For example, base/logging.h defines various template functions to implement
|
||||
// CHECK_EQ(x, y) and stream x and y into the log in the event the check fails.
|
||||
// It does so via the function template MakeCheckOpValueString:
|
||||
// template<class T>
|
||||
// void MakeCheckOpValueString(strstream* ss, const T& v) {
|
||||
// (*ss) << v;
|
||||
// }
|
||||
// Because 'glog/logging.h' is included before 'glog/stl_logging.h',
|
||||
// subsequent CHECK_EQ(v1, v2) for vector<...> typed variable v1 and v2 can only
|
||||
// find these operator definitions via ADL.
|
||||
//
|
||||
// Even this solution has problems -- it may pull unintended operators into the
|
||||
// namespace as well, allowing them to also be found via ADL, and creating code
|
||||
// that only works with a particular order of includes. Long term, we need to
|
||||
// move all of the *definitions* into namespace std, bet we need to ensure no
|
||||
// one references them first. This lets us take that step. We cannot define them
|
||||
// in both because that would create ambiguous overloads when both are found.
|
||||
namespace std { using ::operator<<; }
|
||||
|
||||
#endif // UTIL_GTL_STL_LOGGING_INL_H_
|
||||
120
runtime/onnxruntime/third_party/glog/src/glog/vlog_is_on.h
vendored
Normal file
120
runtime/onnxruntime/third_party/glog/src/glog/vlog_is_on.h
vendored
Normal file
@ -0,0 +1,120 @@
|
||||
// Copyright (c) 2023, Google Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Author: Ray Sidney and many others
|
||||
//
|
||||
// Defines the VLOG_IS_ON macro that controls the variable-verbosity
|
||||
// conditional logging.
|
||||
//
|
||||
// It's used by VLOG and VLOG_IF in logging.h
|
||||
// and by RAW_VLOG in raw_logging.h to trigger the logging.
|
||||
//
|
||||
// It can also be used directly e.g. like this:
|
||||
// if (VLOG_IS_ON(2)) {
|
||||
// // do some logging preparation and logging
|
||||
// // that can't be accomplished e.g. via just VLOG(2) << ...;
|
||||
// }
|
||||
//
|
||||
// The truth value that VLOG_IS_ON(level) returns is determined by
|
||||
// the three verbosity level flags:
|
||||
// --v=<n> Gives the default maximal active V-logging level;
|
||||
// 0 is the default.
|
||||
// Normally positive values are used for V-logging levels.
|
||||
// --vmodule=<str> Gives the per-module maximal V-logging levels to override
|
||||
// the value given by --v.
|
||||
// E.g. "my_module=2,foo*=3" would change the logging level
|
||||
// for all code in source files "my_module.*" and "foo*.*"
|
||||
// ("-inl" suffixes are also disregarded for this matching).
|
||||
//
|
||||
// SetVLOGLevel helper function is provided to do limited dynamic control over
|
||||
// V-logging by overriding the per-module settings given via --vmodule flag.
|
||||
//
|
||||
// CAVEAT: --vmodule functionality is not available in non gcc compilers.
|
||||
//
|
||||
|
||||
#ifndef BASE_VLOG_IS_ON_H_
|
||||
#define BASE_VLOG_IS_ON_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.
|
||||
// (Normally) the first time every VLOG_IS_ON(n) site is hit,
|
||||
// we determine what variable will dynamically control logging at this site:
|
||||
// it's either FLAGS_v or an appropriate internal variable
|
||||
// matching the current source file that represents results of
|
||||
// parsing of --vmodule flag and/or SetVLOGLevel calls.
|
||||
#define VLOG_IS_ON(verboselevel) \
|
||||
__extension__ \
|
||||
({ static google::SiteFlag vlocal__ = {NULL, NULL, 0, NULL}; \
|
||||
google::int32 verbose_level__ = (verboselevel); \
|
||||
(vlocal__.level == NULL ? google::InitVLOG3__(&vlocal__, &FLAGS_v, \
|
||||
__FILE__, verbose_level__) : *vlocal__.level >= verbose_level__); \
|
||||
})
|
||||
#else
|
||||
// GNU extensions not available, so we do not support --vmodule.
|
||||
// Dynamic value of FLAGS_v always controls the logging level.
|
||||
#define VLOG_IS_ON(verboselevel) (FLAGS_v >= (verboselevel))
|
||||
#endif
|
||||
|
||||
// Set VLOG(_IS_ON) level for module_pattern to log_level.
|
||||
// This lets us dynamically control what is normally set by the --vmodule flag.
|
||||
// Returns the level that previously applied to module_pattern.
|
||||
// NOTE: To change the log level for VLOG(_IS_ON) sites
|
||||
// that have already executed after/during InitGoogleLogging,
|
||||
// one needs to supply the exact --vmodule pattern that applied to them.
|
||||
// (If no --vmodule pattern applied to them
|
||||
// the value of FLAGS_v will continue to control them.)
|
||||
extern GLOG_EXPORT int SetVLOGLevel(const char* module_pattern, int log_level);
|
||||
|
||||
// Various declarations needed for VLOG_IS_ON above: =========================
|
||||
|
||||
struct SiteFlag {
|
||||
google::int32* level;
|
||||
const char* base_name;
|
||||
std::size_t base_len;
|
||||
SiteFlag* next;
|
||||
};
|
||||
|
||||
// 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
|
||||
// fname is the current source file name
|
||||
// verbose_level is the argument to VLOG_IS_ON
|
||||
// We will return the return value for VLOG_IS_ON
|
||||
// and if possible set *site_flag appropriately.
|
||||
extern GLOG_EXPORT bool InitVLOG3__(
|
||||
google::SiteFlag* site_flag,
|
||||
google::int32* site_default, const char* fname,
|
||||
google::int32 verbose_level);
|
||||
|
||||
#endif // BASE_VLOG_IS_ON_H_
|
||||
Loading…
Reference in New Issue
Block a user