Add wxCHECK_GLIBC_VERSION() and cleanup glibc version checks
Use this macro where possible and simplify the checks in a couple of places where it isn't (because we're checking for an exact glibc version). No real changes.
This commit is contained in:
parent
bf6fe7f949
commit
d74a4ea30d
6 changed files with 34 additions and 8 deletions
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
|
||||
|
|
|
|||
|
|
@ -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…
Add table
Add a link
Reference in a new issue