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
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  */
14
15 /* ------------------------------- sv.h ------------------------------- */
16
17 PERL_STATIC_INLINE SV *
18 S_SvREFCNT_inc(SV *sv)
19 {
20     if (sv)
21         SvREFCNT(sv)++;
22     return sv;
23 }
24 PERL_STATIC_INLINE SV *
25 S_SvREFCNT_inc_NN(SV *sv)
26 {
27     SvREFCNT(sv)++;
28     return sv;
29 }
30 PERL_STATIC_INLINE void
31 S_SvREFCNT_inc_void(SV *sv)
32 {
33     if (sv)
34         SvREFCNT(sv)++;
35 }
36 PERL_STATIC_INLINE void
37 S_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 }