Skip to content

Commit 65be4a0

Browse files
committed
Fix PerlEnv_putenv threaded compilation on Windows
A second compilation of a workspace would fail. The first one would succeed because miniperl was being used, which isn't threaded.
1 parent 2dc676e commit 65be4a0

File tree

5 files changed

+33
-8
lines changed

5 files changed

+33
-8
lines changed

embed.fnc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3940,6 +3940,9 @@ CTo |PerlInterpreter *|perl_clone_using \
39403940
Adp |I32 |my_pclose |NULLOK PerlIO *ptr
39413941
Adp |PerlIO *|my_popen |NN const char *cmd \
39423942
|NN const char *mode
3943+
# if defined(USE_ITHREADS)
3944+
si |bool |PerlEnv_putenv |NN char *str
3945+
# endif /* defined(USE_ITHREADS) */
39433946
#endif /* !defined(PERL_IMPLICIT_SYS) */
39443947
#if defined(PERL_IN_AV_C)
39453948
S |MAGIC *|get_aux_mg |NN AV *av

embed.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1645,6 +1645,9 @@
16451645
# define padlist_dup(a,b) Perl_padlist_dup(aTHX_ a,b)
16461646
# define padname_dup(a,b) Perl_padname_dup(aTHX_ a,b)
16471647
# define padnamelist_dup(a,b) Perl_padnamelist_dup(aTHX_ a,b)
1648+
# if !defined(PERL_IMPLICIT_SYS)
1649+
# define PerlEnv_putenv(a) Perl_PerlEnv_putenv(aTHX_ a)
1650+
# endif /* !defined(PERL_IMPLICIT_SYS) */
16481651
# endif /* defined(USE_ITHREADS) */
16491652
# if defined(USE_LOCALE_COLLATE)
16501653
# define magic_freecollxfrm(a,b) Perl_magic_freecollxfrm(aTHX_ a,b)

inline.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,25 @@ S_strip_spaces(pTHX_ const char * orig, STRLEN * const len)
281281
}
282282
#endif
283283

284+
/* ------------------------------- iperlsys.h ------------------------------- */
285+
#if ! defined(PERL_IMPLICIT_SYS) && defined(USE_ITHREADS)
286+
287+
/* Otherwise this function is implemented as macros in iperlsys.h */
288+
289+
PERL_STATIC_INLINE bool
290+
Perl_PerlEnv_putenv(pTHX_ char * str)
291+
{
292+
PERL_ARGS_ASSERT_PERLENV_PUTENV;
293+
294+
ENV_LOCK;
295+
bool retval = putenv(str);
296+
ENV_UNLOCK;
297+
298+
return retval;
299+
}
300+
301+
#endif
302+
284303
/* ------------------------------- mg.h ------------------------------- */
285304

286305
#if defined(PERL_CORE) || defined(PERL_EXT)

iperlsys.h

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -559,14 +559,7 @@ struct IPerlEnvInfo
559559
# endif
560560

561561
#else /* below is ! PERL_IMPLICIT_SYS */
562-
# ifdef USE_ITHREADS
563-
564-
/* Use the comma operator to return 0/non-zero, while avoiding putting
565-
* this in an inline function */
566-
# define PerlEnv_putenv(str) (ENV_LOCK, (putenv(str) \
567-
? (ENV_UNLOCK, 1) \
568-
: (ENV_UNLOCK, 0)))
569-
# else
562+
# ifndef USE_ITHREADS /* Threaded is an inline function in inline.h */
570563
# define PerlEnv_putenv(str) putenv(str)
571564
# endif
572565
# define PerlEnv_getenv(str) mortal_getenv(str)

proto.h

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)