summaryrefslogtreecommitdiffstats
path: root/gnu/usr.bin/perl/ext/XS-APItest/core_or_not.inc
blob: 074fe60d310fde5ff522ea9fb88e48c1a8c31ea5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/* This code is compiled twice, once with -DPERL_CORE defined, once without */

#include "EXTERN.h"
#include "perl.h"

#ifdef PERL_CORE
#  define SUFFIX core
#else
#  define SUFFIX notcore
#endif

bool
CAT2(sv_setsv_cow_hashkey_, SUFFIX) () {
    dTHX;
    SV *source = newSVpvn_share("pie", 3, 0);
    SV *destination = newSV(0);
    bool result;

    if(!SvIsCOW(source)) {
	SvREFCNT_dec(source);
	Perl_croak(aTHX_ "Creating a shared hash key scalar failed when "
	       STRINGIFY(SUFFIX) " got flags %" UVxf, (UV)SvFLAGS(source));
    }

    sv_setsv(destination, source);

    result = !!SvIsCOW(destination);

    SvREFCNT_dec(source);
    SvREFCNT_dec(destination);

    return result;
}

/*
 * Local variables:
 * mode: c
 * End:
 *
 * ex: set ts=8 sts=4 sw=4 et:
 */