Unverified Commit 0301bfdd authored by Sergiu Deitsch's avatar Sergiu Deitsch Committed by GitHub

Merge pull request #324 from NeroBurner/fix_mingw_cross_compile

Fix mingw cross compile
parents abce7880 364fad56
...@@ -115,7 +115,7 @@ check_cxx_compiler_flag (-Wunnamed-type-template-args ...@@ -115,7 +115,7 @@ check_cxx_compiler_flag (-Wunnamed-type-template-args
check_symbol_exists (snprintf stdio.h HAVE_SNPRINTF) check_symbol_exists (snprintf stdio.h HAVE_SNPRINTF)
check_library_exists (unwind get_static_proc_name "" HAVE_LIB_UNWIND) check_library_exists (unwind get_static_proc_name "" HAVE_LIB_UNWIND)
check_library_exists (DbgHelp UnDecorateSymbolName "" HAVE_DBGHELP) check_library_exists (dbghelp UnDecorateSymbolName "" HAVE_DBGHELP)
find_library (UNWIND_LIBRARY NAMES unwind DOC "unwind library") find_library (UNWIND_LIBRARY NAMES unwind DOC "unwind library")
mark_as_advanced (UNWIND_LIBRARY) mark_as_advanced (UNWIND_LIBRARY)
...@@ -386,6 +386,18 @@ elseif (UNIX OR (APPLE AND HAVE_DLADDR)) ...@@ -386,6 +386,18 @@ elseif (UNIX OR (APPLE AND HAVE_DLADDR))
set (HAVE_SYMBOLIZE 1) set (HAVE_SYMBOLIZE 1)
endif (WIN32 OR CYGWIN) endif (WIN32 OR CYGWIN)
check_cxx_source_compiles ("
#include <cstdlib>
#include <time.h>
int main()
{
time_t timep;
struct tm result;
localtime_r(&timep, &result);
return EXIT_SUCCESS;
}
" HAVE_LOCALTIME_R)
set (SIZEOF_VOID_P ${CMAKE_SIZEOF_VOID_P}) set (SIZEOF_VOID_P ${CMAKE_SIZEOF_VOID_P})
if (WITH_THREADS AND Threads_FOUND) if (WITH_THREADS AND Threads_FOUND)
...@@ -456,7 +468,7 @@ if (UNWIND_LIBRARY) ...@@ -456,7 +468,7 @@ if (UNWIND_LIBRARY)
endif (UNWIND_LIBRARY) endif (UNWIND_LIBRARY)
if (HAVE_DBGHELP) if (HAVE_DBGHELP)
target_link_libraries (glog PUBLIC DbgHelp) target_link_libraries (glog PUBLIC dbghelp)
endif (HAVE_DBGHELP) endif (HAVE_DBGHELP)
if (HAVE_PTHREAD) if (HAVE_PTHREAD)
......
...@@ -136,6 +136,9 @@ ...@@ -136,6 +136,9 @@
/* define if symbolize support is available */ /* define if symbolize support is available */
#cmakedefine HAVE_SYMBOLIZE #cmakedefine HAVE_SYMBOLIZE
/* define if localtime_r is available in time.h */
#cmakedefine HAVE_LOCALTIME_R
/* Define to the sub-directory in which libtool stores uninstalled libraries. /* Define to the sub-directory in which libtool stores uninstalled libraries.
*/ */
#cmakedefine LT_OBJDIR #cmakedefine LT_OBJDIR
......
...@@ -39,8 +39,8 @@ ...@@ -39,8 +39,8 @@
#include "demangle.h" #include "demangle.h"
#if defined(OS_WINDOWS) #if defined(OS_WINDOWS)
#include <DbgHelp.h> #include <dbghelp.h>
#pragma comment(lib, "DbgHelp") #pragma comment(lib, "dbghelp")
#endif #endif
_START_GOOGLE_NAMESPACE_ _START_GOOGLE_NAMESPACE_
......
...@@ -183,7 +183,7 @@ GLOG_DEFINE_string(log_backtrace_at, "", ...@@ -183,7 +183,7 @@ GLOG_DEFINE_string(log_backtrace_at, "",
#ifndef HAVE_PREAD #ifndef HAVE_PREAD
#if defined(OS_WINDOWS) #if defined(OS_WINDOWS)
#include <BaseTsd.h> #include <basetsd.h>
#define ssize_t SSIZE_T #define ssize_t SSIZE_T
#endif #endif
static ssize_t pread(int fd, void* buf, size_t count, off_t offset) { static ssize_t pread(int fd, void* buf, size_t count, off_t offset) {
......
...@@ -847,10 +847,10 @@ _END_GOOGLE_NAMESPACE_ ...@@ -847,10 +847,10 @@ _END_GOOGLE_NAMESPACE_
#elif defined(OS_WINDOWS) || defined(OS_CYGWIN) #elif defined(OS_WINDOWS) || defined(OS_CYGWIN)
#include <windows.h> #include <windows.h>
#include <DbgHelp.h> #include <dbghelp.h>
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma comment(lib, "DbgHelp") #pragma comment(lib, "dbghelp")
#endif #endif
_START_GOOGLE_NAMESPACE_ _START_GOOGLE_NAMESPACE_
......
...@@ -38,15 +38,8 @@ ...@@ -38,15 +38,8 @@
#include "config.h" #include "config.h"
#include <stdarg.h> // for va_list, va_start, va_end #include <stdarg.h> // for va_list, va_start, va_end
#include <string.h> // for strstr()
#include <assert.h>
#include <string>
#include <vector>
#include "port.h" #include "port.h"
using std::string;
using std::vector;
// These call the windows _vsnprintf, but always NUL-terminate. // These call the windows _vsnprintf, but always NUL-terminate.
int safe_vsnprintf(char *str, size_t size, const char *format, va_list ap) { int safe_vsnprintf(char *str, size_t size, const char *format, va_list ap) {
if (size == 0) // not even room for a \0? if (size == 0) // not even room for a \0?
...@@ -55,6 +48,12 @@ int safe_vsnprintf(char *str, size_t size, const char *format, va_list ap) { ...@@ -55,6 +48,12 @@ int safe_vsnprintf(char *str, size_t size, const char *format, va_list ap) {
return _vsnprintf(str, size-1, format, ap); return _vsnprintf(str, size-1, format, ap);
} }
#ifndef HAVE_LOCALTIME_R
struct tm* localtime_r(const time_t* timep, struct tm* result) {
localtime_s(result, timep);
return result;
}
#endif // not HAVE_LOCALTIME_R
#ifndef HAVE_SNPRINTF #ifndef HAVE_SNPRINTF
int snprintf(char *str, size_t size, const char *format, ...) { int snprintf(char *str, size_t size, const char *format, ...) {
va_list ap; va_list ap;
......
...@@ -136,19 +136,20 @@ typedef int pid_t; ...@@ -136,19 +136,20 @@ typedef int pid_t;
#endif // _MSC_VER #endif // _MSC_VER
// ----------------------------------- THREADS // ----------------------------------- THREADS
#ifndef __MINGW32__ #if defined(HAVE_PTHREAD)
# include <pthread.h>
#else // no PTHREAD
typedef DWORD pthread_t; typedef DWORD pthread_t;
typedef DWORD pthread_key_t; typedef DWORD pthread_key_t;
typedef LONG pthread_once_t; typedef LONG pthread_once_t;
enum { PTHREAD_ONCE_INIT = 0 }; // important that this be 0! for SpinLock enum { PTHREAD_ONCE_INIT = 0 }; // important that this be 0! for SpinLock
#define pthread_self GetCurrentThreadId #define pthread_self GetCurrentThreadId
#define pthread_equal(pthread_t_1, pthread_t_2) ((pthread_t_1)==(pthread_t_2)) #define pthread_equal(pthread_t_1, pthread_t_2) ((pthread_t_1)==(pthread_t_2))
#endif // HAVE_PTHREAD
inline struct tm* localtime_r(const time_t* timep, struct tm* result) { #ifndef HAVE_LOCALTIME_R
localtime_s(result, timep); extern struct tm* GOOGLE_GLOG_DLL_DECL localtime_r(const time_t* timep, struct tm* result);
return result; #endif // not HAVE_LOCALTIME_R
}
#endif
inline char* strerror_r(int errnum, char* buf, size_t buflen) { inline char* strerror_r(int errnum, char* buf, size_t buflen) {
strerror_s(buf, buflen, errnum); strerror_s(buf, buflen, errnum);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment