From 8bf62cd82c600fc8a454183b3181e50cf67e7596 Mon Sep 17 00:00:00 2001 From: Brad Smith Date: Wed, 10 May 2023 13:29:07 -0400 Subject: [PATCH] Glog: fixed OpenBSD support - Usage of syscall() is not allowed - Use getthrid() to retreive the thread ID --- extern/glog/README.blender | 2 + extern/glog/src/config.h | 2 + extern/glog/src/config_openbsd.h | 192 +++++++++++++++++++++++++++++++ extern/glog/src/raw_logging.cc | 3 +- extern/glog/src/utilities.cc | 2 + 5 files changed, 200 insertions(+), 1 deletion(-) create mode 100644 extern/glog/src/config_openbsd.h diff --git a/extern/glog/README.blender b/extern/glog/README.blender index bc2ca9f958e..fc3d8da0806 100644 --- a/extern/glog/README.blender +++ b/extern/glog/README.blender @@ -8,3 +8,5 @@ Local modifications: * Added special definitions of HAVE_SNPRINTF and HAVE_LIB_GFLAGS in Windows' specific config.h. * Silenced syscall deprecation warnings on macOS >= 10.12. +* Usage of syscall() is not allowed and use getthrid() to + retreive the thread ID on OpenBSD diff --git a/extern/glog/src/config.h b/extern/glog/src/config.h index e4cde736d65..fa704c912b1 100644 --- a/extern/glog/src/config.h +++ b/extern/glog/src/config.h @@ -2,6 +2,8 @@ #include "config_mac.h" #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) #include "config_freebsd.h" +#elif defined(__OpenBSD__) + #include "config_openbsd.h" #elif defined(__MINGW32__) #include "windows/config.h" #elif defined(__linux__) diff --git a/extern/glog/src/config_openbsd.h b/extern/glog/src/config_openbsd.h new file mode 100644 index 00000000000..03c044e4ec4 --- /dev/null +++ b/extern/glog/src/config_openbsd.h @@ -0,0 +1,192 @@ +/* define if glog doesn't use RTTI */ +/* #undef DISABLE_RTTI */ + +/* Namespace for Google classes */ +#define GOOGLE_NAMESPACE google + +/* Define if you have the `dladdr' function */ +/* #undef HAVE_DLADDR */ + +/* Define if you have the `snprintf' function */ +#define HAVE_SNPRINTF + +/* Define to 1 if you have the header file. */ +#define HAVE_DLFCN_H + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_EXECINFO_H */ + +/* Define if you have the `fcntl' function */ +#define HAVE_FCNTL + +/* Define to 1 if you have the header file. */ +#define HAVE_GLOB_H + +/* Define to 1 if you have the header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the `pthread' library (-lpthread). */ +#define HAVE_LIBPTHREAD + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LIBUNWIND_H */ + +/* define if you have google gflags library */ +#define 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 libunwind */ +/* #undef HAVE_LIB_UNWIND */ + +/* Define to 1 if you have the header file. */ +#define HAVE_MEMORY_H + +/* define to disable multithreading support. */ +/* #undef NO_THREADS */ + +/* define if the compiler implements namespaces */ +#define HAVE_NAMESPACES + +/* 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 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 1 + +/* Define if you have the 'sigaction' function */ +#define HAVE_SIGACTION + +/* Define if you have the `sigaltstack' function */ +#define HAVE_SIGALTSTACK 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H + +/* Define to 1 if you have the header file. */ +#define HAVE_STRINGS_H + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYSCALL_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYSLOG_H + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SYSCALL_H + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TIME_H + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_UCONTEXT_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_UTSNAME_H + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_UCONTEXT_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UNWIND_H 1 + +/* define if the compiler supports using expression for operator */ +#define HAVE_USING_OPERATOR + +/* 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 to the sub-directory in which libtool stores uninstalled libraries. + */ +/* #undef LT_OBJDIR */ + +/* Name of package */ +/* #undef PACKAGE */ + +/* Define to the address where bug reports for this package should be sent. */ +/* #undef PACKAGE_BUGREPORT */ + +/* Define to the full name of this package. */ +/* #undef PACKAGE_NAME */ + +/* Define to the full name and version of this package. */ +/* #undef PACKAGE_STRING */ + +/* Define to the one symbol short name of this package. */ +/* #undef PACKAGE_TARNAME */ + +/* Define to the home page for this package. */ +/* #undef PACKAGE_URL */ + +/* Define to the version of this package. */ +/* #undef PACKAGE_VERSION */ + +/* How to access the PC from a struct ucontext */ +/* #undef PC_FROM_UCONTEXT */ + +/* 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 + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* the namespace where STL code like vector<> is defined */ +#define STL_NAMESPACE std + +/* location of source code */ +#define TEST_SRC_DIR "." + +/* Version number of package */ +/* #undef VERSION */ + +/* 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 { + +#define GOOGLE_GLOG_DLL_DECL + +/* isn't getting defined by configure script when clang compilers are used + and cuases compilation errors in stactrace/unwind modules */ +#ifdef __clang__ +# define NO_FRAME_POINTER +#endif diff --git a/extern/glog/src/raw_logging.cc b/extern/glog/src/raw_logging.cc index 15d14f6e4f5..329b0063c08 100644 --- a/extern/glog/src/raw_logging.cc +++ b/extern/glog/src/raw_logging.cc @@ -59,7 +59,8 @@ # include #endif -#if (defined(HAVE_SYSCALL_H) || defined(HAVE_SYS_SYSCALL_H)) && (!(defined OS_MACOSX)) +#if (defined(HAVE_SYSCALL_H) || defined(HAVE_SYS_SYSCALL_H)) && \ + (!(defined OS_MACOSX) && !(defined OS_OPENBSD)) # define safe_write(fd, s, len) syscall(SYS_write, fd, s, len) #else // Not so safe, but what can you do? diff --git a/extern/glog/src/utilities.cc b/extern/glog/src/utilities.cc index 6387e14e123..4bdeaf18910 100644 --- a/extern/glog/src/utilities.cc +++ b/extern/glog/src/utilities.cc @@ -282,6 +282,8 @@ pid_t GetTID() { return getpid(); // Linux: getpid returns thread ID when gettid is absent #elif defined OS_WINDOWS && !defined OS_CYGWIN return GetCurrentThreadId(); +#elif defined OS_OPENBSD + return getthrid(); #else // If none of the techniques above worked, we use pthread_self(). return (pid_t)(uintptr_t)pthread_self(); -- 2.30.2