Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix eval_pv for old compilers #217

Closed
wants to merge 2 commits into from
Closed

Fix eval_pv for old compilers #217

wants to merge 2 commits into from

Conversation

pali
Copy link
Contributor

@pali pali commented Feb 9, 2022

  • Backport PERL_STATIC_INLINE macro
  • Fix D_PPP_CROAK_IF_ERROR when compiler does not support gcc brace groups

Fixes: #216

Macro croak_sv() is defined as STMT_START { ... } STMT_END and therefore it
cannot be used in comma operator for control flow.

So its current usage in D_PPP_CROAK_IF_ERROR macro for compilers without
support for gcc brace groups is broken and cause compile errors for code
which uses D_PPP_CROAK_IF_ERROR (e.g. eval_pv macro).

Fix this issue by converting D_PPP_CROAK_IF_ERROR macro to static inline
function. For ancient compilers without inline support, this function would
be only static, which is enough.
@khwilliamson
Copy link
Member

If this is called multiple times in the same compilation unit, it would be defining the same function multiple times. I think that is illegal, but maybe no.

@pali
Copy link
Contributor Author

pali commented Feb 10, 2022

File call is included in file ppport.h only once and ppport.h is guarded by #ifdef` to be processed only once when included in application compilation unit more times. So I think it should be safe.

@@ -51,7 +51,8 @@ __UNDEFINED__ PERL_LOADMOD_IMPORT_OPS 0x4
#if defined(PERL_USE_GCC_BRACE_GROUPS)
# define D_PPP_CROAK_IF_ERROR(cond) ({ SV *_errsv; ((cond) && (_errsv = ERRSV) && (SvROK(_errsv) || SvTRUE(_errsv)) && (croak_sv(_errsv), 1)); })
#else
# define D_PPP_CROAK_IF_ERROR(cond) ((cond) && (SvROK(ERRSV) || SvTRUE(ERRSV)) && (croak_sv(ERRSV), 1))
PERL_STATIC_INLINE void D_PPP_CROAK_IF_ERROR(int cond) { dTHX; SV *errsv; if (!cond) return; errsv = ERRSV; if (SvROK(errsv) || SvTRUE(errsv)) croak_sv(errsv); }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would adding an undef D_PPP_CROAK_IF_ERROR add some extra safety?

@atoomic
Copy link
Member

atoomic commented Feb 10, 2022

@khwilliamson is going to run some additional extensive tests using this patch before we merge and release it in the next days.

Thanks everyone

@khwilliamson
Copy link
Member

khwilliamson commented Feb 11, 2022 via email

@atoomic
Copy link
Member

atoomic commented Mar 2, 2022

This is fixed by #218 we do not need this PR

@atoomic atoomic closed this Mar 2, 2022
@pali pali deleted the eval_pv branch March 7, 2022 12:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

eval_pv fails to compile on non-gcc compilers with Perl < 5.031
3 participants