check for getpwuid_r() and getgrgid_r() functions

Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
This commit is contained in:
Ivailo Monev 2020-01-07 14:27:48 +00:00
parent 6943b3bb4a
commit c7b36ea3ea
5 changed files with 22 additions and 23 deletions

View file

@ -219,11 +219,14 @@ check_include_file(sys/time.h HAVE_SYS_TIME_H)
# used in qconfig.h
check_type_size(size_t QT_POINTER_SIZE)
# POSIX.1-2001
katie_optional_function(getpwuid_r "pwd.h")
katie_optional_function(getgrgid_r "grp.h")
# XSI POSIX.1-2001 functions
katie_check_function(strerror_r "string.h")
katie_optional_function(strerror_r "string.h")
# POSIX.1-2008 functions
katie_check_function(realpath "stdlib.h")
katie_check_function(unsetenv "stdlib.h")
katie_require_function(realpath "stdlib.h")
katie_require_function(unsetenv "stdlib.h")
if(KATIE_COMPILER MATCHES "(gcc|clang)")
set(QT_VISIBILITY_AVAILABLE TRUE)

View file

@ -16,13 +16,24 @@ macro(KATIE_WARNING MESSAGESTR)
endif()
endmacro()
macro(KATIE_CHECK_FUNCTION FORFUNCTION FROMHEADER)
# a macro to check for function presence in header, if function is found a
# definition is added
macro(KATIE_OPTIONAL_FUNCTION FORFUNCTION FROMHEADER)
check_symbol_exists("${FORFUNCTION}" "${FROMHEADER}" HAVE_${FORFUNCTION})
if(NOT HAVE_${FORFUNCTION})
check_function_exists("${FORFUNCTION}" HAVE_${FORFUNCTION})
endif()
if(HAVE_${FORFUNCTION})
string(TOUPPER "${FORFUNCTION}" upperfunction)
add_definitions(-DQT_HAVE_${upperfunction})
endif()
endmacro()
# same as katie_optional_function(), however if not found an error is send
macro(KATIE_REQUIRE_FUNCTION FORFUNCTION FROMHEADER)
katie_optional_function("${FORFUNCTION}" "${FROMHEADER}" HAVE_${FORFUNCTION})
if(NOT HAVE_${FORFUNCTION})
message(SEND_ERROR "check_function_exists(${FORFUNCTION}) failed")
message(SEND_ERROR "katie_require_function(${FORFUNCTION}, ${FROMHEADER}) failed")
endif()
endmacro()

View file

@ -47,21 +47,6 @@
# endif
#elif defined(__OpenBSD__)
// 1003.1c-1995 says on page 38 (2.9.3, paragraph 3) that if _POSIX_THREADS
// is defined, then _POSIX_THREAD_SAFE_FUNCTIONS must also be defined.
// However this looks like a well-known typo (reversed dependency).
//
// On the other hand _POSIX_THREAD_SAFE_FUNCTIONS should be defined only
// if the Thread-Safe Functions option is implemented. OpenBSD does not
// support all of the required _r() interfaces, especially getpwuid_r(),
// which means it should not define _POSIX_THREAD_SAFE_FUNCTIONS.
//
// Since OpenBSD does define _POSIX_THREAD_SAFE_FUNCTIONS, we have to
// undefine it behind its back.
# ifdef _POSIX_THREAD_SAFE_FUNCTIONS
# undef _POSIX_THREAD_SAFE_FUNCTIONS
# endif
// Older OpenBSD versions may still use the a.out format instead of ELF.
# ifndef __ELF__
# define QT_AOUT_UNDERSCORE

View file

@ -172,7 +172,7 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry)
QString QFileSystemEngine::resolveUserName(uint userId)
{
struct passwd *pw = 0;
#if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_OPENBSD)
#if !defined(QT_NO_THREAD) && defined(QT_HAVE_GETPWUID_R)
int size_max = sysconf(_SC_GETPW_R_SIZE_MAX);
if (size_max == -1)
size_max = 1024;
@ -191,7 +191,7 @@ QString QFileSystemEngine::resolveUserName(uint userId)
QString QFileSystemEngine::resolveGroupName(uint groupId)
{
struct group *gr = 0;
#if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_OPENBSD)
#if !defined(QT_NO_THREAD) && defined(QT_HAVE_GETGRGID_R)
int size_max = sysconf(_SC_GETGR_R_SIZE_MAX);
if (size_max == -1)
size_max = 1024;

View file

@ -23,7 +23,7 @@ QT_BEGIN_NAMESPACE
// version in portable code.
static inline QString fromstrerror_helper(const int errorcode)
{
#if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS)
#if !defined(QT_NO_THREAD) && defined(QT_HAVE_STRERROR_R)
char errbuf[1024];
::memset(errbuf, '\0', sizeof(errbuf));
if (Q_LIKELY(::strerror_r(errorcode, errbuf, sizeof(errbuf)))) {