This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Use fast SvREFCNT_dec for non-GCC
[perl5.git] / inline.h
CommitLineData
25468daa
FC
1/* inline.h
2 *
3 * Copyright (C) 2012 by Larry Wall and others
4 *
5 * You may distribute under the terms of either the GNU General Public
6 * License or the Artistic License, as specified in the README file.
7 *
8 * This file is a home for static inline functions that cannot go in other
9 * headers files, because they depend on proto.h (included after most other
10 * headers) or struct definitions.
11 *
12 * Each section names the header file that the functions "belong" to.
13 */
27669aa4
FC
14
15/* ------------------------------- sv.h ------------------------------- */
16
17PERL_STATIC_INLINE SV *
18S_SvREFCNT_inc(SV *sv)
19{
20 if (sv)
21 SvREFCNT(sv)++;
22 return sv;
23}
24PERL_STATIC_INLINE SV *
25S_SvREFCNT_inc_NN(SV *sv)
26{
27 SvREFCNT(sv)++;
28 return sv;
29}
30PERL_STATIC_INLINE void
31S_SvREFCNT_inc_void(SV *sv)
32{
33 if (sv)
34 SvREFCNT(sv)++;
35}
75e16a44
FC
36PERL_STATIC_INLINE void
37S_SvREFCNT_dec(pTHX_ SV *sv)
38{
39 if (sv) {
40 if (SvREFCNT(sv)) {
41 if (--(SvREFCNT(sv)) == 0)
42 Perl_sv_free2(aTHX_ sv);
43 } else {
44 sv_free(sv);
45 }
46 }
47}