Fix LooksLikeNumber() macro
[gitmo/Mouse.git] / perlxs.h
CommitLineData
fe5044b1 1/*
2 perlxs.h - Standard XS header file
3 Copyright (c) Fuji, Goro (gfx)
4*/
5
6#ifdef __cplusplus
7extern "C" {
8#endif
9
10#define PERL_NO_GET_CONTEXT /* we want efficiency */
11#include <EXTERN.h>
12
13#include <perl.h>
14#define NO_XSLOCKS /* for exceptions */
15#include <XSUB.h>
16
17#ifdef __cplusplus
18} /* extern "C" */
19#endif
20
21#include "ppport.h"
22
23/* portability stuff not supported by ppport.h yet */
24
25#ifndef STATIC_INLINE /* from 5.13.4 */
26# if defined(__GNUC__) || defined(__cplusplus__) || (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L))
27# define STATIC_INLINE static inline
28# else
29# define STATIC_INLINE static
30# endif
31#endif /* STATIC_INLINE */
32
33#ifndef __attribute__format__
34#define __attribute__format__(a,b,c) /* nothing */
35#endif
36
37#ifndef LIKELY /* they are just a compiler's hint */
38#define LIKELY(x) (x)
39#define UNLIKELY(x) (x)
40#endif
41
42#ifndef newSVpvs_share
43#define newSVpvs_share(s) Perl_newSVpvn_share(aTHX_ STR_WITH_LEN(s), 0U)
44#endif
45
46#ifndef get_cvs
47#define get_cvs(name, flags) get_cv(name, flags)
48#endif
49
50#ifndef GvNAME_get
51#define GvNAME_get GvNAME
52#endif
53#ifndef GvNAMELEN_get
54#define GvNAMELEN_get GvNAMELEN
55#endif
56
57#ifndef CvGV_set
58#define CvGV_set(cv, gv) (CvGV(cv) = (gv))
59#endif
60
61/* general utility */
62
339fdf5b 63#if PERL_BCDVERSION >= 0x5008005
fe5044b1 64#define LooksLikeNumber(x) looks_like_number(x)
339fdf5b 65#else
66#define LooksLikeNumber(x) (SvPOKp(x) ? looks_like_number(x) : (I32)SvNIOKp(x))
fe5044b1 67#endif
68
69#define newAV_mortal() (AV*)sv_2mortal((SV*)newAV())
70#define newHV_mortal() (HV*)sv_2mortal((SV*)newHV())
71
72#define DECL_BOOT(name) EXTERN_C XS(CAT2(boot_, name))
73#define CALL_BOOT(name) STMT_START { \
74 PUSHMARK(SP); \
75 CALL_FPTR(CAT2(boot_, name))(aTHX_ cv); \
76 } STMT_END
77