mirror of
https://bitbucket.org/smil3y/katie.git
synced 2025-02-23 10:22:55 +00:00
implement thread name setting for NetBSD
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
b74d450eb7
commit
d8c160363b
3 changed files with 109 additions and 117 deletions
159
CMakeLists.txt
159
CMakeLists.txt
|
@ -50,6 +50,7 @@ include(CheckTypeSize)
|
|||
include(FeatureSummary)
|
||||
include(KatieMacros)
|
||||
include(KatieBuildMacros)
|
||||
include(mkspecs/mkspecs.cmake)
|
||||
|
||||
# mostly relevant to the build process, also stored in the version file for CMake and in qconfig.h.cmake
|
||||
set(KATIE_MAJOR "4")
|
||||
|
@ -154,85 +155,6 @@ add_feature_info(allinone KATIE_ALLINONE "build targets from single source file"
|
|||
option(WITH_ACCESSIBILITY "Build accessibility support" ON)
|
||||
add_feature_info(accessibility WITH_ACCESSIBILITY "build accessibility support")
|
||||
|
||||
include(mkspecs/mkspecs.cmake)
|
||||
|
||||
add_definitions(
|
||||
# these conditionals are probably going to become default in the future
|
||||
-DQT_POSIX_IPC
|
||||
-DQT_USE_SYSTEM_PROXIES
|
||||
# -DQT_STRICT_ITERATORS
|
||||
# -DQT_ASCII_CAST_WARNINGS
|
||||
# maybe one day, this forces it onto other projects which (most likely)
|
||||
# means source code adjustments!
|
||||
# -DQT_NO_CAST_FROM_ASCII
|
||||
# -DQT_NO_CAST_TO_ASCII
|
||||
)
|
||||
|
||||
# for symbols mangling while unwinding in core component
|
||||
check_include_file_cxx(cxxabi.h HAVE_CXXABI)
|
||||
|
||||
# for 3rd party source used in test component
|
||||
check_include_file(sys/time.h HAVE_SYS_TIME_H)
|
||||
|
||||
# stored in qconfig.h.cmake
|
||||
check_type_size(size_t QT_POINTER_SIZE)
|
||||
|
||||
# POSIX.1-2001
|
||||
katie_check_function(getpwnam_r "pwd.h")
|
||||
katie_check_function(getpwuid_r "pwd.h")
|
||||
katie_check_function(getgrgid_r "grp.h")
|
||||
katie_check_function(nl_langinfo "langinfo.h")
|
||||
# XSI/POSIX.1-2001
|
||||
katie_check_function(strerror_r "string.h")
|
||||
# SUSv2
|
||||
katie_check_function(localtime_r "time.h")
|
||||
katie_check_function(gmtime_r "time.h")
|
||||
# SVr2, removed in POSIX.1-2008
|
||||
katie_check_function(fcvt "stdlib.h")
|
||||
katie_check_function(ecvt "stdlib.h")
|
||||
# NetBSD 1.6 and FreeBSD 4.4
|
||||
katie_check_function(getprogname "stdlib.h")
|
||||
# GNU
|
||||
katie_check_function(get_current_dir_name "unistd.h")
|
||||
# ISO/IEC 9899:1999
|
||||
katie_check_function(fegetenv "fenv.h")
|
||||
katie_check_function(fesetenv "fenv.h")
|
||||
katie_check_function(feclearexcept "fenv.h")
|
||||
katie_check_function(feenableexcept "fenv.h")
|
||||
# none
|
||||
katie_check_struct(sockaddr_ll sll_addr "netpacket/packet.h")
|
||||
katie_check_struct(sockaddr_dl sdl_index "net/if_dl.h")
|
||||
katie_check_struct(dirent d_type "dirent.h")
|
||||
|
||||
# 64-bit offset alternatives, if any of the functions is not found it will set
|
||||
# QT_LARGEFILE_SUPPORT to FALSE. QT_LARGEFILE_SUPPORT is used in qconfig.h
|
||||
set(QT_LARGEFILE_SUPPORT TRUE)
|
||||
katie_check_function64(stat64 "sys/stat.h")
|
||||
katie_check_function64(lstat64 "sys/stat.h")
|
||||
katie_check_function64(fstat64 "sys/stat.h")
|
||||
katie_check_function64(open64 "fcntl.h")
|
||||
katie_check_function64(creat64 "fcntl.h")
|
||||
katie_check_function64(lseek64 "unistd.h")
|
||||
katie_check_function64(truncate64 "unistd.h")
|
||||
katie_check_function64(ftruncate64 "unistd.h")
|
||||
katie_check_function64(fopen64 "stdio.h")
|
||||
katie_check_function64(fseeko64 "stdio.h")
|
||||
katie_check_function64(ftello64 "stdio.h")
|
||||
katie_check_function64(fgetpos64 "stdio.h")
|
||||
katie_check_function64(fsetpos64 "stdio.h")
|
||||
katie_check_function64(mmap64 "sys/mman.h")
|
||||
katie_check_function64(readdir64 "dirent.h")
|
||||
katie_check_function64(readdir64_r "dirent.h")
|
||||
|
||||
configure_file(
|
||||
${CMAKE_SOURCE_DIR}/src/core/global/qconfig.h.cmake
|
||||
${CMAKE_BINARY_DIR}/include/QtCore/qconfig.h
|
||||
)
|
||||
configure_file(
|
||||
${CMAKE_SOURCE_DIR}/src/core/global/qconfig.cpp.cmake
|
||||
${CMAKE_BINARY_DIR}/include/qconfig.cpp
|
||||
)
|
||||
|
||||
# v1.2.0+ required for compressBound()
|
||||
find_package(ZLIB 1.2.0)
|
||||
set_package_properties(ZLIB PROPERTIES
|
||||
|
@ -415,6 +337,85 @@ set_package_properties(Unwind PROPERTIES
|
|||
TYPE OPTIONAL
|
||||
)
|
||||
|
||||
add_definitions(
|
||||
# these conditionals are probably going to become default in the future
|
||||
-DQT_POSIX_IPC
|
||||
-DQT_USE_SYSTEM_PROXIES
|
||||
# -DQT_STRICT_ITERATORS
|
||||
# -DQT_ASCII_CAST_WARNINGS
|
||||
# maybe one day, this forces it onto other projects which (most likely)
|
||||
# means source code adjustments!
|
||||
# -DQT_NO_CAST_FROM_ASCII
|
||||
# -DQT_NO_CAST_TO_ASCII
|
||||
)
|
||||
|
||||
# for symbols mangling while unwinding in core component
|
||||
check_include_file_cxx(cxxabi.h HAVE_CXXABI)
|
||||
|
||||
# for 3rd party source used in test component
|
||||
check_include_file(sys/time.h HAVE_SYS_TIME_H)
|
||||
|
||||
# stored in qconfig.h.cmake
|
||||
check_type_size(size_t QT_POINTER_SIZE)
|
||||
|
||||
# POSIX.1-2001
|
||||
katie_check_function(getpwnam_r "pwd.h")
|
||||
katie_check_function(getpwuid_r "pwd.h")
|
||||
katie_check_function(getgrgid_r "grp.h")
|
||||
katie_check_function(nl_langinfo "langinfo.h")
|
||||
# XSI/POSIX.1-2001
|
||||
katie_check_function(strerror_r "string.h")
|
||||
# SUSv2
|
||||
katie_check_function(localtime_r "time.h")
|
||||
katie_check_function(gmtime_r "time.h")
|
||||
# SVr2, removed in POSIX.1-2008
|
||||
katie_check_function(fcvt "stdlib.h")
|
||||
katie_check_function(ecvt "stdlib.h")
|
||||
# NetBSD 1.6 and FreeBSD 4.4
|
||||
katie_check_function(getprogname "stdlib.h")
|
||||
# GNU
|
||||
katie_check_function(get_current_dir_name "unistd.h")
|
||||
katie_check_function(prctl "sys/prctl.h")
|
||||
katie_check_function(pthread_setname_np "pthread.h" "${CMAKE_THREAD_LIBS_INIT}")
|
||||
# ISO/IEC 9899:1999
|
||||
katie_check_function(fegetenv "fenv.h")
|
||||
katie_check_function(fesetenv "fenv.h")
|
||||
katie_check_function(feclearexcept "fenv.h")
|
||||
katie_check_function(feenableexcept "fenv.h")
|
||||
# none
|
||||
katie_check_struct(sockaddr_ll sll_addr "netpacket/packet.h")
|
||||
katie_check_struct(sockaddr_dl sdl_index "net/if_dl.h")
|
||||
katie_check_struct(dirent d_type "dirent.h")
|
||||
|
||||
# 64-bit offset alternatives, if any of the functions is not found it will set
|
||||
# QT_LARGEFILE_SUPPORT to FALSE. QT_LARGEFILE_SUPPORT is used in qconfig.h
|
||||
set(QT_LARGEFILE_SUPPORT TRUE)
|
||||
katie_check_function64(stat64 "sys/stat.h")
|
||||
katie_check_function64(lstat64 "sys/stat.h")
|
||||
katie_check_function64(fstat64 "sys/stat.h")
|
||||
katie_check_function64(open64 "fcntl.h")
|
||||
katie_check_function64(creat64 "fcntl.h")
|
||||
katie_check_function64(lseek64 "unistd.h")
|
||||
katie_check_function64(truncate64 "unistd.h")
|
||||
katie_check_function64(ftruncate64 "unistd.h")
|
||||
katie_check_function64(fopen64 "stdio.h")
|
||||
katie_check_function64(fseeko64 "stdio.h")
|
||||
katie_check_function64(ftello64 "stdio.h")
|
||||
katie_check_function64(fgetpos64 "stdio.h")
|
||||
katie_check_function64(fsetpos64 "stdio.h")
|
||||
katie_check_function64(mmap64 "sys/mman.h")
|
||||
katie_check_function64(readdir64 "dirent.h")
|
||||
katie_check_function64(readdir64_r "dirent.h")
|
||||
|
||||
configure_file(
|
||||
${CMAKE_SOURCE_DIR}/src/core/global/qconfig.h.cmake
|
||||
${CMAKE_BINARY_DIR}/include/QtCore/qconfig.h
|
||||
)
|
||||
configure_file(
|
||||
${CMAKE_SOURCE_DIR}/src/core/global/qconfig.cpp.cmake
|
||||
${CMAKE_BINARY_DIR}/include/qconfig.cpp
|
||||
)
|
||||
|
||||
if(KATIE_TESTS OR KATIE_BENCHMARKS)
|
||||
message(WARNING
|
||||
"\nUnless it is intentionall you should not enable testing, deploying tests builds"
|
||||
|
|
|
@ -18,45 +18,33 @@ macro(KATIE_WARNING MESSAGESTR)
|
|||
endif()
|
||||
endmacro()
|
||||
|
||||
# a function to check for C function/definition, works for external functions
|
||||
# too. note that check_symbol_exists() and check_function_exists() cache the
|
||||
# result variables so they can be used anywhere
|
||||
# a function to check for C function/definition, works for external functions.
|
||||
function(KATIE_CHECK_DEFINED FORDEFINITION FROMHEADER)
|
||||
cmake_reset_check_state()
|
||||
set(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} ${ARGN})
|
||||
check_symbol_exists("${FORDEFINITION}" "${FROMHEADER}" HAVE_${FORDEFINITION})
|
||||
if(NOT HAVE_${FORDEFINITION})
|
||||
check_function_exists("${FORDEFINITION}" HAVE_${FORDEFINITION})
|
||||
endif()
|
||||
cmake_pop_check_state()
|
||||
|
||||
if(NOT HAVE_${FORDEFINITION})
|
||||
set(compileout "${CMAKE_BINARY_DIR}/${FORDEFINITION}.cpp")
|
||||
configure_file(
|
||||
"${CMAKE_SOURCE_DIR}/cmake/modules/katie_check_defined.cpp.cmake"
|
||||
"${compileout}"
|
||||
@ONLY
|
||||
)
|
||||
try_compile(${FORDEFINITION}_test
|
||||
"${CMAKE_BINARY_DIR}"
|
||||
"${compileout}"
|
||||
COMPILE_DEFINITIONS ${ARGN}
|
||||
OUTPUT_VARIABLE ${FORDEFINITION}_test_output
|
||||
)
|
||||
if(${FORDEFINITION}_test)
|
||||
message(STATUS "Found ${FORDEFINITION} in: <${FROMHEADER}>")
|
||||
set(HAVE_${FORDEFINITION} TRUE PARENT_SCOPE)
|
||||
else()
|
||||
message(STATUS "Could not find ${FORDEFINITION} in: <${FROMHEADER}>")
|
||||
set(HAVE_${FORDEFINITION} FALSE PARENT_SCOPE)
|
||||
endif()
|
||||
set(compileout "${CMAKE_BINARY_DIR}/${FORDEFINITION}.cpp")
|
||||
configure_file(
|
||||
"${CMAKE_SOURCE_DIR}/cmake/modules/katie_check_defined.cpp.cmake"
|
||||
"${compileout}"
|
||||
@ONLY
|
||||
)
|
||||
try_compile(${FORDEFINITION}_test
|
||||
"${CMAKE_BINARY_DIR}"
|
||||
"${compileout}"
|
||||
COMPILE_DEFINITIONS ${ARGN}
|
||||
OUTPUT_VARIABLE ${FORDEFINITION}_test_output
|
||||
)
|
||||
if(${FORDEFINITION}_test)
|
||||
message(STATUS "Found ${FORDEFINITION} in: <${FROMHEADER}>")
|
||||
set(HAVE_${FORDEFINITION} TRUE PARENT_SCOPE)
|
||||
else()
|
||||
message(STATUS "Could not find ${FORDEFINITION} in: <${FROMHEADER}>")
|
||||
set(HAVE_${FORDEFINITION} FALSE PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# a macro to check for C function presence in header, if function is found a
|
||||
# definition is added.
|
||||
macro(KATIE_CHECK_FUNCTION FORFUNCTION FROMHEADER)
|
||||
katie_check_defined("${FORFUNCTION}" "${FROMHEADER}")
|
||||
katie_check_defined("${FORFUNCTION}" "${FROMHEADER}" ${ARGN})
|
||||
|
||||
if(HAVE_${FORFUNCTION})
|
||||
string(TOUPPER "${FORFUNCTION}" upperfunction)
|
||||
|
@ -67,7 +55,7 @@ endmacro()
|
|||
# a function to check for C function with 64-bit offset alternative, sets
|
||||
# QT_LARGEFILE_SUPPORT to FALSE if not available
|
||||
function(KATIE_CHECK_FUNCTION64 FORFUNCTION FROMHEADER)
|
||||
katie_check_defined("${FORFUNCTION}" "${FROMHEADER}" -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE)
|
||||
katie_check_defined("${FORFUNCTION}" "${FROMHEADER}" -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE ${ARGN})
|
||||
|
||||
if(NOT HAVE_${FORFUNCTION})
|
||||
set(QT_LARGEFILE_SUPPORT FALSE PARENT_SCOPE)
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
#include <sched.h>
|
||||
#include <errno.h>
|
||||
|
||||
#if defined(Q_OS_LINUX) && !defined(QT_LINUXBASE)
|
||||
#if defined(QT_HAVE_PRCTL)
|
||||
#include <sys/prctl.h>
|
||||
#endif
|
||||
|
||||
|
@ -211,14 +211,17 @@ void *QThreadPrivate::start(void *arg)
|
|||
// ### TODO: allow the user to create a custom event dispatcher
|
||||
createEventDispatcher(data);
|
||||
|
||||
#if defined(Q_OS_LINUX)
|
||||
#if defined(QT_HAVE_PRCTL) || defined(QT_HAVE_PTHREAD_SETNAME_NP)
|
||||
// sets the name of the current thread.
|
||||
QString objectName = thr->objectName();
|
||||
|
||||
if (Q_LIKELY(objectName.isEmpty()))
|
||||
setCurrentThreadName(thr->metaObject()->className());
|
||||
else
|
||||
setCurrentThreadName(objectName.toLocal8Bit().constData());
|
||||
objectName = thr->metaObject()->className();
|
||||
#if defined(QT_HAVE_PRCTL)
|
||||
::prctl(PR_SET_NAME, (unsigned long)objectName.toLocal8Bit().constData(), 0, 0, 0);
|
||||
#elif defined(QT_HAVE_PTHREAD_SETNAME_NP)
|
||||
pthread_setname_np(thr->d_func()->thread_id, objectName.toLocal8Bit().constData());
|
||||
#endif
|
||||
#endif
|
||||
|
||||
emit thr->started();
|
||||
|
|
Loading…
Add table
Reference in a new issue