Branch: refs/heads/blead
  Home:   https://github.com/Perl/perl5
  Commit: 2f6713056a560b96c82f8545e773ac467ec3822f
      
https://github.com/Perl/perl5/commit/2f6713056a560b96c82f8545e773ac467ec3822f
  Author: Lukas Mai <lukasmai....@gmail.com>
  Date:   2025-03-18 (Tue, 18 Mar 2025)

  Changed paths:
    M malloc.c
    M pod/perldiag.pod

  Log Message:
  -----------
  malloc.c: fix compilation error, clean up more

When configured with -DEBUGGING -Dusethreads -Dusemymalloc, malloc.c
didn't compile anymore (see below for the full error message). This was
probably broken by commits 8e3a36a4b3 and 13e5ba49b2. What they missed
was that all uses of warn/croak in this file were supposed to have no
context parameter (aTHX/pTHX) and the only reason croak2 was introduced
was that C89 didn't have variable-argument macros, so croak() was
hardcoded with one argument and croak2() with two arguments.

Instead, we can simply replace all uses of croak/croak2 with
Perl_croak_nocontext. On threaded builds, this is a function with no
extra pTHX_ parameter; on non-threaded builds, this just turns into
regular croak. Now we don't need to manually check for MULTIPLICITY
ourselves.

Back in the day (perl 5.005), malloc.c was supposed to be usable outside
of perl, so it had checks for PERL_CORE being defined. These were
removed in b9e5552c5b, but some vestiges remained: PERL_CORE was still
mentioned as a configuration option in a comment and Perl_mfree (but
none of the other functions) tagged its warning messages with the
configuration options in play ("PERL_CORE", "RMAGIC", or "RMAGIC,
PERL_CORE", added in commit 52c6645e67). With the removal of
non-PERL_CORE support, these don't make much sense anymore, so I removed
them.

This change in turn enables further improvements: Common code in the
RCHECK and non-RCHECK branches can be extracted, making the "#ifdef
RCHECK" conditional sections smaller and eliminating the "#else"
sections entirely.

------------------------------------------------------------------------

    In file included from malloc.c:240:
    malloc.c: In function ‘Perl_malloc’:
    perl.h:225:17: error: ‘my_perl’ undeclared (first use in this function)
      225 | #  define aTHX  my_perl
          |                 ^~~~~~~
    perl.h:230:25: note: in expansion of macro ‘aTHX’
      230 | #  define aTHX_         aTHX,
          |                         ^~~~
    embed.h:966:60: note: in expansion of macro ‘aTHX_’
      966 | #   define croak(...)                           Perl_croak(aTHX_ 
__VA_ARGS__)
          |                                                            ^~~~~
    malloc.c:1254:13: note: in expansion of macro ‘croak’
     1254 |             croak("panic: malloc");
          |             ^~~~~
    perl.h:225:17: note: each undeclared identifier is reported only once for 
each function it appears in
      225 | #  define aTHX  my_perl
          |                 ^~~~~~~
    perl.h:230:25: note: in expansion of macro ‘aTHX’
      230 | #  define aTHX_         aTHX,
          |                         ^~~~
    embed.h:966:60: note: in expansion of macro ‘aTHX_’
      966 | #   define croak(...)                           Perl_croak(aTHX_ 
__VA_ARGS__)
          |                                                            ^~~~~
    malloc.c:1254:13: note: in expansion of macro ‘croak’
     1254 |             croak("panic: malloc");
          |             ^~~~~
    malloc.c: In function ‘Perl_mfree’:
    perl.h:225:17: error: ‘my_perl’ undeclared (first use in this function)
      225 | #  define aTHX  my_perl
          |                 ^~~~~~~
    perl.h:230:25: note: in expansion of macro ‘aTHX’
      230 | #  define aTHX_         aTHX,
          |                         ^~~~
    embed.h:966:60: note: in expansion of macro ‘aTHX_’
      966 | #   define croak(...)                           Perl_croak(aTHX_ 
__VA_ARGS__)
          |                                                            ^~~~~
    malloc.c:1820:13: note: in expansion of macro ‘croak’
     1820 |             croak("wrong alignment in free()");
          |             ^~~~~
    malloc.c: In function ‘Perl_realloc’:
    perl.h:225:17: error: ‘my_perl’ undeclared (first use in this function)
      225 | #  define aTHX  my_perl
          |                 ^~~~~~~
    perl.h:230:25: note: in expansion of macro ‘aTHX’
      230 | #  define aTHX_         aTHX,
          |                         ^~~~
    embed.h:966:60: note: in expansion of macro ‘aTHX_’
      966 | #   define croak(...)                           Perl_croak(aTHX_ 
__VA_ARGS__)
          |                                                            ^~~~~
    malloc.c:1925:13: note: in expansion of macro ‘croak’
     1925 |             croak("panic: realloc");
          |             ^~~~~
    make: *** [makefile:265: malloc.o] Error 1



To unsubscribe from these emails, change your notification settings at 
https://github.com/Perl/perl5/settings/notifications

Reply via email to