 |
OR-Tools
8.1
|
Go to the documentation of this file.
18 #if !defined(_MSC_VER)
24 #if defined(_MSC_VER) // windows compatibility layer.
25 #ifndef WIN32_LEAN_AND_MEAN
26 #define WIN32_LEAN_AND_MEAN
51 #pragma warning(disable : 4244 4251 4355 4715 4800 4996 4267 4312 4722)
55 #define access _access
56 #define getcwd _getcwd
63 #define pclose _pclose
65 #define S_ISDIR(m) (((m)&_S_IFMT) == _S_IFDIR)
67 #define O_WRONLY _O_WRONLY
68 #define O_CREAT _O_CREAT
69 #define O_EXCL _O_EXCL
72 enum { STDIN_FILENO = 0, STDOUT_FILENO = 1, STDERR_FILENO = 2 };
74 #define S_IRUSR S_IREAD
75 #define S_IWUSR S_IWRITE
78 #define link(oldpath, newpath) CopyFileA(oldpath, newpath, false)
80 #define strcasecmp _stricmp
81 #define strncasecmp _strnicmp
85 #if defined(_MSC_VER) && (_MSC_VER < 1700)
86 #define hash hash_compare
95 int safe_vsnprintf(
char* str,
size_t size,
const char* format, va_list ap) {
99 return _vsnprintf(str, size - 1, format, ap);
102 #define vsnprintf(str, size, format, ap) safe_vsnprintf(str, size, format, ap)
104 #define va_copy(dst, src) (dst) = (src)
110 #define CTEMPLATE_SMALL_HASHTABLE
111 #define DEFAULT_TEMPLATE_ROOTDIR ".."
115 #define getpid _getpid
118 typedef DWORD pthread_t;
119 #define pthread_self GetCurrentThreadId
121 inline struct tm* localtime_r(
const time_t* timep,
struct tm* result) {
122 localtime_s(result, timep);
126 inline char* strerror_r(
int errnum,
char* buf,
size_t buflen) {
127 strerror_s(buf, buflen, errnum);
141 #include "absl/debugging/failure_signal_handler.h"
142 #include "absl/debugging/stacktrace.h"
143 #include "absl/debugging/symbolize.h"
144 #include "absl/time/time.h"
148 "Symbolize the stack trace in the tombstone");
160 if (write(STDERR_FILENO, data, strlen(data)) < 0) {
166 reinterpret_cast<std::string*
>(arg)->append(data);
171 const char*
const prefix) {
173 const char* symbol =
"(unknown)";
177 if (absl::Symbolize(
reinterpret_cast<char*
>(pc) - 1, tmp,
sizeof(tmp))) {
187 const char*
const prefix) {
197 int depth = absl::GetStackTrace(stack, ABSL_ARRAYSIZE(stack), skip_count + 1);
198 for (
int i = 0; i < depth; i++) {
199 if (absl::GetFlag(FLAGS_symbolize_stacktrace)) {
202 DumpPC(writerfn, arg, stack[i],
" ");
212 namespace logging_internal {
239 const char* base = strrchr(filepath,
'/');
240 #ifdef _MSC_VER // Look for either path separator in Windows
241 if (!base) base = strrchr(filepath,
'\\');
243 return base ? (base + 1) : filepath;
249 #if defined(_MSC_VER)
250 const char* user = getenv(
"USERNAME");
252 const char* user = getenv(
"USER");
257 #if !defined(_MSC_VER) // Not windows.
259 struct passwd* result = NULL;
260 char buffer[1024] = {
'\0'};
261 uid_t uid = geteuid();
262 int pwuid_res = getpwuid_r(uid, &pwd, buffer,
sizeof(buffer), &result);
263 if (pwuid_res == 0) {
266 snprintf(buffer,
sizeof(buffer),
"uid%d", uid);
269 #endif // _defined(_MSC_VER)
282 #define REGISTER_MODULE_INITIALIZER(name, body) \
284 static void google_init_module_##name() { body; } \
285 GoogleInitializer google_initializer_module_##name( \
286 #name, google_init_module_##name); \
306 <<
"You called InitGoogleLogging() twice!";
307 const char* slash = strrchr(argv0,
'/');
309 if (!slash) slash = strrchr(argv0,
'\\');
319 <<
"You called ShutdownGoogleLogging() without calling "
320 "InitGoogleLogging() first!";
322 #if !defined(_MSC_VER)
324 #endif // !defined(_MSC_VER)
void(* void_function)(void)
static const CrashReason * g_reason
void DebugWriter(const char *, void *)
bool IsGoogleLoggingInitialized()
static void DumpStackTraceAndExit()
const char * ProgramInvocationShortName()
ABSL_FLAG(bool, symbolize_stacktrace, true, "Symbolize the stack trace in the tombstone")
T sync_val_compare_and_swap(T *ptr, T oldval, T newval)
static const char * g_program_invocation_short_name
static void DebugWriteToStderr(const char *data, void *)
const std::string & MyUserName()
static void MyUserNameInitializer()
static void DumpPC(DebugWriter *writerfn, void *arg, void *pc, const char *const prefix)
void SetCrashReason(const CrashReason *r)
static void DebugWriteToString(const char *data, void *arg)
static std::string g_my_user_name
REGISTER_MODULE_INITIALIZER(logging_utilities, MyUserNameInitializer())
static void DumpStackTrace(int skip_count, DebugWriter *writerfn, void *arg)
void DumpStackTraceToString(std::string *stacktrace)
static pthread_t g_main_thread_id
GoogleInitializer(const char *, void_function f)
void InstallFailureFunction(void(*fail_func)())
void ShutdownGoogleLoggingUtilities()
static int32 g_main_thread_pid
const char * const_basename(const char *filepath)
static void DumpPCAndSymbol(DebugWriter *writerfn, void *arg, void *pc, const char *const prefix)
static const int kPrintfPointerFieldWidth
int64 UsecToCycles(int64 usec)
void InitGoogleLoggingUtilities(const char *argv0)