commit
0167d56427
25
include/wx/private/glibc.h
Normal file
25
include/wx/private/glibc.h
Normal file
@ -0,0 +1,25 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/private/glibc.h
|
||||
// Purpose: glibc-specific private wx header
|
||||
// Author: Vadim Zeitlin
|
||||
// Created: 2022-06-23
|
||||
// Copyright: (c) 2022 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_PRIVATE_GLIBC_H_
|
||||
#define _WX_PRIVATE_GLIBC_H_
|
||||
|
||||
// Ensure that a header include __GLIBC__ is defined.
|
||||
#include <string.h>
|
||||
|
||||
// Macro for testing glibc version similar to wxCHECK_GCC_VERSION().
|
||||
#if defined(__GLIBC__) && defined(__GLIBC_MINOR__)
|
||||
#define wxCHECK_GLIBC_VERSION( major, minor ) \
|
||||
( ( __GLIBC__ > (major) ) \
|
||||
|| ( __GLIBC__ == (major) && __GLIBC_MINOR__ >= (minor) ) )
|
||||
#else
|
||||
#define wxCHECK_GLIBC_VERSION( major, minor ) 0
|
||||
#endif
|
||||
|
||||
#endif // _WX_PRIVATE_GLIBC_H_
|
@ -594,7 +594,7 @@ WXDLLIMPEXP_BASE size_t wxCRT_StrftimeW(wchar_t *s, size_t max,
|
||||
#define wxCRT_IsxdigitW(c) iswxdigit(c)
|
||||
|
||||
#ifdef __GLIBC__
|
||||
#if defined(__GLIBC__) && (__GLIBC__ == 2) && (__GLIBC_MINOR__ == 0)
|
||||
#if (__GLIBC__ == 2) && (__GLIBC_MINOR__ == 0)
|
||||
/* /usr/include/wctype.h incorrectly declares translations */
|
||||
/* tables which provokes tons of compile-time warnings -- try */
|
||||
/* to correct this */
|
||||
|
@ -38,6 +38,7 @@
|
||||
#ifdef HAVE_ICONV
|
||||
#include <iconv.h>
|
||||
#include "wx/thread.h"
|
||||
#include "wx/private/glibc.h"
|
||||
#endif
|
||||
|
||||
#include "wx/encconv.h"
|
||||
@ -2037,7 +2038,7 @@ wxMBConvUTF32swap::FromWChar(char *dst, size_t dstLen,
|
||||
// bytes-left-in-input buffer is non-zero. Hence, this alternative test for
|
||||
// iconv() failure.
|
||||
// [This bug does not appear in glibc 2.2.]
|
||||
#if defined(__GLIBC__) && __GLIBC__ == 2 && __GLIBC_MINOR__ <= 1
|
||||
#if wxCHECK_GLIBC_VERSION(2, 0) && !wxCHECK_GLIBC_VERSION(2, 2)
|
||||
#define ICONV_FAILED(cres, bufLeft) ((cres == (size_t)-1) && \
|
||||
(errno != E2BIG || bufLeft != 0))
|
||||
#else
|
||||
|
@ -32,9 +32,7 @@
|
||||
# define WX_SOCKLEN_T unsigned int
|
||||
#else
|
||||
# ifdef __GLIBC__
|
||||
# if __GLIBC__ == 2
|
||||
# define WX_SOCKLEN_T socklen_t
|
||||
# endif
|
||||
# define WX_SOCKLEN_T socklen_t
|
||||
# elif defined(__WXMAC__)
|
||||
# define WX_SOCKLEN_T socklen_t
|
||||
# else
|
||||
|
@ -64,6 +64,18 @@
|
||||
// we use wxFFile under Linux in GetCPUCount()
|
||||
#ifdef __LINUX__
|
||||
#include "wx/ffile.h"
|
||||
#include "wx/private/glibc.h"
|
||||
#if wxCHECK_GLIBC_VERSION(2, 12)
|
||||
#define wxHAVE_PTHREAD_SETNAME_NP
|
||||
#define wxCAN_SET_LINUX_THREAD_NAME
|
||||
#else
|
||||
#include <sys/prctl.h>
|
||||
|
||||
// This is only available since Linux 2.6.9
|
||||
#ifdef PR_SET_NAME
|
||||
#define wxCAN_SET_LINUX_THREAD_NAME
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// We don't provide wxAtomicLong and it doesn't seem really useful to add it
|
||||
@ -1696,12 +1708,16 @@ bool wxThread::SetNameForCurrent(const wxString &name)
|
||||
#if defined(__DARWIN__)
|
||||
pthread_setname_np(name.utf8_str());
|
||||
return true;
|
||||
#elif defined(__LINUX__)
|
||||
#elif defined(__LINUX__) && defined(wxCAN_SET_LINUX_THREAD_NAME)
|
||||
// Linux doesn't allow names longer than 15 bytes.
|
||||
char truncatedName[16] = { 0 };
|
||||
strncpy(truncatedName, name.utf8_str(), 15);
|
||||
|
||||
return pthread_setname_np(pthread_self(), truncatedName) == 0;
|
||||
#ifdef wxHAVE_PTHREAD_SETNAME_NP
|
||||
return pthread_setname_np(pthread_self(), truncatedName) == 0;
|
||||
#else
|
||||
return prctl(PR_SET_NAME, (unsigned long)(void*)truncatedName, 0, 0, 0);
|
||||
#endif
|
||||
#else
|
||||
wxUnusedVar(name);
|
||||
wxLogDebug("No implementation for wxThread::SetName() on this OS.");
|
||||
|
@ -54,6 +54,7 @@
|
||||
|
||||
#include "wx/private/selectdispatcher.h"
|
||||
#include "wx/private/fdiodispatcher.h"
|
||||
#include "wx/private/glibc.h"
|
||||
#include "wx/unix/private/execute.h"
|
||||
#include "wx/unix/pipe.h"
|
||||
#include "wx/unix/private.h"
|
||||
@ -216,8 +217,7 @@ void wxMilliSleep(unsigned long milliseconds)
|
||||
|
||||
void wxSecureZeroMemory(void* v, size_t n)
|
||||
{
|
||||
#if (defined(__GLIBC__) && \
|
||||
(__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 25))) || \
|
||||
#if wxCHECK_GLIBC_VERSION(2, 25) || \
|
||||
(defined(__FreeBSD__) && __FreeBSD__ >= 11)
|
||||
// This non-standard function is somewhat widely available elsewhere too,
|
||||
// but may be found in a non-standard header file, or in a library that is
|
||||
|
@ -20,6 +20,8 @@
|
||||
#include "wx/intl.h"
|
||||
#include "wx/uilocale.h"
|
||||
|
||||
#include "wx/private/glibc.h"
|
||||
|
||||
#if wxUSE_INTL
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -175,7 +177,7 @@ void IntlTestCase::DateTimeFmtFrench()
|
||||
#ifdef __GLIBC__
|
||||
// Versions of glibc up to 2.7 wrongly used periods for French locale
|
||||
// separator.
|
||||
#if __GLIBC__ > 2 || __GLIBC_MINOR__ >= 8
|
||||
#if wxCHECK_GLIBC_VERSION(2, 8)
|
||||
static const char *FRENCH_DATE_FMT = "%d/%m/%Y";
|
||||
#else
|
||||
static const char *FRENCH_DATE_FMT = "%d.%m.%Y";
|
||||
|
Loading…
Reference in New Issue
Block a user