Skip to content

Commit

Permalink
perl.h: Add #define for gwENVr_LOCALEr_UNLOCK
Browse files Browse the repository at this point in the history
This is for functions that read the locale and environment and write to
some global space.
  • Loading branch information
khwilliamson committed May 6, 2021
1 parent 34027a3 commit 6f25e0f
Showing 1 changed file with 52 additions and 2 deletions.
54 changes: 52 additions & 2 deletions perl.h
Expand Up @@ -6767,7 +6767,31 @@ the plain locale pragma without a parameter (S<C<use locale>>) is in effect.
# define PORCELAIN_SETLOCALE_UNLOCK gwLOCALE_UNLOCK
#endif

/* This was defined above for the case where locales aren't thread safe. */
/* Similar to gwLOCALE_LOCK, there are functions that require both the locale
* and environment to be constant during their execution, and don't change
* either of those things, but do write to some sort of shared global space.
* They require some sort of exclusive lock against similar functions, and a
* read lock on both the locale and environment. However, on systems which
* have per-thread locales, the locale is constant during the execution of
* these functions, and so no locale lock is necssary. For such systems, an
* exclusive ENV lock is necessary and sufficient. On systems where the locale
* could change out from under us, we use an exclusive LOCALE lock to prevent
* that, and a read ENV lock to prevent other threads that have nothing to do
* with locales here from changing the environment. */
#ifdef SETLOCALE_LOCK
# define gwENVr_LOCALEr_LOCK \
STMT_START { SETLOCALE_LOCK; ENV_READ_LOCK; } STMT_END
# define gwENVr_LOCALEr_UNLOCK \
STMT_START { ENV_READ_UNLOCK; SETLOCALE_UNLOCK; } STMT_END
#else
# define gwENVr_LOCALEr_LOCK ENV_LOCK
# define gwENVr_LOCALEr_UNLOCK ENV_UNLOCK
#endif

/* Now that we have defined gwENVr_LOCALEr_LOCK, we can finish defining
* SETLOCALE_LOCK, which we kept undefined until here on a thread-safe system
* so that we could use that fact to calculate what gwENVr_LOCALEr_LOCK should
* be */
#ifndef SETLOCALE_LOCK
# define SETLOCALE_LOCK NOOP
# define SETLOCALE_UNLOCK NOOP
Expand All @@ -6777,12 +6801,38 @@ the plain locale pragma without a parameter (S<C<use locale>>) is in effect.
#define LOCALE_READ_LOCK SETLOCALE_LOCK
#define LOCALE_READ_UNLOCK SETLOCALE_UNLOCK


#ifndef LC_NUMERIC_LOCK
# define LC_NUMERIC_LOCK(cond) NOOP
# define LC_NUMERIC_UNLOCK NOOP
#endif

#ifdef LC_CTYPE_LOCK
# ifdef HAS_MBLEN
# define MBLEN_LOCK_ LC_CTYPE_LOCK
# define MBLEN_UNLOCK_ LC_CTYPE_UNLOCK
# endif
# ifdef HAS_MBRLEN
# define MBRLEN_LOCK_ LC_CTYPE_LOCK
# define MBRLEN_UNLOCK_ LC_CTYPE_UNLOCK
# endif
# ifdef HAS_MBTOWC
# define MBTOWC_LOCK_ LC_CTYPE_LOCK
# define MBTOWC_UNLOCK_ LC_CTYPE_UNLOCK
# endif
# ifdef HAS_MBRTOWC
# define MBRTOWC_LOCK_ LC_CTYPE_LOCK
# define MBRTOWC_UNLOCK_ LC_CTYPE_UNLOCK
# endif
# ifdef HAS_WCTOMB
# define WCTOMB_LOCK_ LC_CTYPE_LOCK
# define WCTOMB_UNLOCK_ LC_CTYPE_UNLOCK
# endif
# ifdef HAS_WCRTOMB
# define WCRTOMB_LOCK_ LC_CTYPE_LOCK
# define WCRTOMB_UNLOCK_ LC_CTYPE_UNLOCK
# endif
#endif

# define MBLEN_LOCK_ gwLOCALE_LOCK
# define MBLEN_UNLOCK_ gwLOCALE_UNLOCK

Expand Down

0 comments on commit 6f25e0f

Please sign in to comment.