File Coverage

hax/wrap_keyword_plugin.c.inc
Criterion Covered Total %
statement 4 4 100.0
branch 2 4 50.0
condition n/a
subroutine n/a
pod n/a
total 6 8 75.0


line stmt bran cond sub pod time code
1             /* vi: set ft=c : */
2              
3             #ifndef OP_CHECK_MUTEX_LOCK /* < 5.15.8 */
4             # define OP_CHECK_MUTEX_LOCK ((void)0)
5             # define OP_CHECK_MUTEX_UNLOCK ((void)0)
6             #endif
7              
8             #define wrap_keyword_plugin(func, var) S_wrap_keyword_plugin(aTHX_ func, var)
9              
10             static void S_wrap_keyword_plugin(pTHX_ Perl_keyword_plugin_t func, Perl_keyword_plugin_t *var)
11             {
12             /* BOOT can potentially race with other threads (RT123547) */
13              
14             /* Perl doesn't really provide us a nice mutex for doing this so this is the
15             * best we can find. See also
16             * https://rt.perl.org/Public/Bug/Display.html?id=132413
17             */
18 1 50         if(*var)
19             return;
20              
21             OP_CHECK_MUTEX_LOCK;
22 1 50         if(!*var) {
23 1           *var = PL_keyword_plugin;
24 1           PL_keyword_plugin = func;
25             }
26              
27             OP_CHECK_MUTEX_UNLOCK;
28             }