diff options
author | Karl Williamson <khw@cpan.org> | 2021-03-08 05:21:32 -0700 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2022-09-21 14:34:41 -0600 |
commit | 1118ec15947427988784e2ab16171203db9b9d3f (patch) | |
tree | c5e02999784342a7ead370223561fd631a024add /perl.h | |
parent | dff607ef35caa67235b1379fe58f6c48b130faa6 (diff) | |
download | perl-1118ec15947427988784e2ab16171203db9b9d3f.tar.gz |
Add POSIX_SETLOCALE_LOCK/UNLOCK
This macro is used to surround raw setlocale() calls so that the return
value in a global static buffer can be saved without interference with
other threads.
Diffstat (limited to 'perl.h')
-rw-r--r-- | perl.h | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -7223,6 +7223,24 @@ the plain locale pragma without a parameter (S<C<use locale>>) is in effect. #define gwLOCALE_LOCK LOCALE_LOCK_(0) #define gwLOCALE_UNLOCK LOCALE_UNLOCK_ +/* setlocale() generally returns in a global static buffer, but not on Windows + * when operating in thread-safe mode */ +#if defined(WIN32) && defined(USE_THREAD_SAFE_LOCALE) +# define POSIX_SETLOCALE_LOCK \ + STMT_START { \ + if (_configthreadlocale(0) == _DISABLE_PER_THREAD_LOCALE) \ + gwLOCALE_LOCK; \ + } STMT_END +# define POSIX_SETLOCALE_UNLOCK \ + STMT_START { \ + if (_configthreadlocale(0) == _DISABLE_PER_THREAD_LOCALE) \ + gwLOCALE_UNLOCK; \ + } STMT_END +#else +# define POSIX_SETLOCALE_LOCK gwLOCALE_LOCK +# define POSIX_SETLOCALE_UNLOCK gwLOCALE_UNLOCK +#endif + #ifndef LC_NUMERIC_LOCK # define LC_NUMERIC_LOCK(cond) NOOP # define LC_NUMERIC_UNLOCK NOOP |