Skip to content

Commit

Permalink
perl.h: Move some code around
Browse files Browse the repository at this point in the history
This is purely to make future commits have smaller real difference
listings, and involves a temporary (complemented) copy of a preprocessor
conditional.
  • Loading branch information
khwilliamson committed Apr 29, 2021
1 parent 362ebbd commit ee615bd
Showing 1 changed file with 39 additions and 27 deletions.
66 changes: 39 additions & 27 deletions perl.h
Expand Up @@ -6651,6 +6651,45 @@ the plain locale pragma without a parameter (S<C<use locale>>) is in effect.
#define locale_panic_(m) Perl_locale_panic((m), __FILE__, __LINE__, errno)

/* Locale/thread synchronization macros. */
#if ( defined(USE_LOCALE) \
&& defined(USE_LOCALE_THREADS) \
&& ( ! defined(USE_THREAD_SAFE_LOCALE) \
|| ( defined(HAS_LOCALECONV) \
&& ( ! defined(HAS_LOCALECONV_L) \
|| defined(TS_W32_BROKEN_LOCALECONV))) \
|| ( defined(HAS_NL_LANGINFO) \
&& ! defined(HAS_THREAD_SAFE_NL_LANGINFO_L)) \
|| (defined(HAS_MBLEN) && ! defined(HAS_MBRLEN)) \
|| (defined(HAS_MBTOWC) && ! defined(HAS_MBRTOWC)) \
|| (defined(HAS_WCTOMB) && ! defined(HAS_WCRTOMB))))

# ifdef USE_POSIX_2008_LOCALE
/* We have a locale object holding the 'C' locale for Posix 2008 */
# define LOCALE_TERM_POSIX_2008_ \
STMT_START { \
if (PL_C_locale_obj) { \
/* Make sure we aren't using the locale \
* space we are about to free */ \
uselocale(LC_GLOBAL_LOCALE); \
freelocale(PL_C_locale_obj); \
PL_C_locale_obj = (locale_t) NULL; \
} \
} STMT_END
# else
# define LOCALE_TERM_POSIX_2008_ NOOP
# endif

# define LOCALE_INIT STMT_START { \
MUTEX_INIT(&PL_locale_mutex); \
LOCALE_INIT_LC_NUMERIC_; \
} STMT_END

# define LOCALE_TERM STMT_START { \
MUTEX_DESTROY(&PL_locale_mutex); \
LOCALE_TERM_LC_NUMERIC_; \
LOCALE_TERM_POSIX_2008_; \
} STMT_END
#endif
#if ! ( defined(USE_LOCALE) \
&& defined(USE_LOCALE_THREADS) \
&& ( ! defined(USE_THREAD_SAFE_LOCALE) \
Expand Down Expand Up @@ -6841,33 +6880,6 @@ the plain locale pragma without a parameter (S<C<use locale>>) is in effect.
# define LOCALE_INIT_LC_NUMERIC_ MUTEX_INIT(&PL_lc_numeric_mutex)
# define LOCALE_TERM_LC_NUMERIC_ MUTEX_DESTROY(&PL_lc_numeric_mutex)
# endif

# ifdef USE_POSIX_2008_LOCALE
/* We have a locale object holding the 'C' locale for Posix 2008 */
# define LOCALE_TERM_POSIX_2008_ \
STMT_START { \
if (PL_C_locale_obj) { \
/* Make sure we aren't using the locale \
* space we are about to free */ \
uselocale(LC_GLOBAL_LOCALE); \
freelocale(PL_C_locale_obj); \
PL_C_locale_obj = (locale_t) NULL; \
} \
} STMT_END
# else
# define LOCALE_TERM_POSIX_2008_ NOOP
# endif

# define LOCALE_INIT STMT_START { \
MUTEX_INIT(&PL_locale_mutex); \
LOCALE_INIT_LC_NUMERIC_; \
} STMT_END

# define LOCALE_TERM STMT_START { \
MUTEX_DESTROY(&PL_locale_mutex); \
LOCALE_TERM_LC_NUMERIC_; \
LOCALE_TERM_POSIX_2008_; \
} STMT_END
#endif

#ifdef USE_LOCALE_NUMERIC
Expand Down

0 comments on commit ee615bd

Please sign in to comment.