1#ifdef __cplusplus
2/* Needed on some windows machines---since MS plays funny games with the header files under C++ */
3#include <math.h>
4#include <stdlib.h>
5extern "C" {
6#endif
7#include "EXTERN.h"
8#include "perl.h"
9#include "XSUB.h"
10
11/* Add in functionality missing in older versions of Perl. Much of this is based on Devel-PPPort on cpan. */
12
13/* Add PERL_REVISION, PERL_VERSION, PERL_SUBVERSION if missing */
14#ifndef PERL_REVISION
15#  if !defined(__PATCHLEVEL_H_INCLUDED__) && !(defined(PATCHLEVEL) && defined(SUBVERSION))
16#    define PERL_PATCHLEVEL_H_IMPLICIT
17#    include <patchlevel.h>
18#  endif
19#  if !(defined(PERL_VERSION) || (defined(SUBVERSION) && defined(PATCHLEVEL)))
20#    include <could_not_find_Perl_patchlevel.h>
21#  endif
22#  ifndef PERL_REVISION
23#    define PERL_REVISION       (5)
24#    define PERL_VERSION        PATCHLEVEL
25#    define PERL_SUBVERSION     SUBVERSION
26#  endif
27#endif
28
29#if defined(WIN32) && defined(PERL_OBJECT) && !defined(PerlIO_exportFILE)
30#define PerlIO_exportFILE(fh,fl) (FILE*)(fh)
31#endif
32
33#ifndef SvIOK_UV
34# define SvIOK_UV(sv)       (SvIOK(sv) && (SvUVX(sv) == SvIVX(sv)))
35#endif
36
37#ifndef SvUOK
38# define SvUOK(sv)           SvIOK_UV(sv)
39#endif
40
41#if ((PERL_VERSION < 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION <= 5)))
42#  define PL_sv_undef               sv_undef
43#  define PL_na	                    na
44#  define PL_errgv                  errgv
45#  define PL_sv_no                  sv_no
46#  define PL_sv_yes                 sv_yes
47#  define PL_markstack_ptr          markstack_ptr
48#endif
49
50#ifndef IVSIZE
51#  ifdef LONGSIZE
52#    define IVSIZE LONGSIZE
53#  else
54#    define IVSIZE 4 /* A bold guess, but the best we can make. */
55#  endif
56#endif
57
58#ifndef INT2PTR
59#  if (IVSIZE == PTRSIZE) && (UVSIZE == PTRSIZE)
60#    define PTRV                  UV
61#    define INT2PTR(any,d)        (any)(d)
62#  else
63#    if PTRSIZE == LONGSIZE
64#      define PTRV                unsigned long
65#    else
66#      define PTRV                unsigned
67#    endif
68#    define INT2PTR(any,d)        (any)(PTRV)(d)
69#  endif
70
71#  define NUM2PTR(any,d)  (any)(PTRV)(d)
72#  define PTR2IV(p)       INT2PTR(IV,p)
73#  define PTR2UV(p)       INT2PTR(UV,p)
74#  define PTR2NV(p)       NUM2PTR(NV,p)
75
76#  if PTRSIZE == LONGSIZE
77#    define PTR2ul(p)     (unsigned long)(p)
78#  else
79#    define PTR2ul(p)     INT2PTR(unsigned long,p)
80#  endif
81#endif /* !INT2PTR */
82
83#ifndef SvPV_nolen
84# define SvPV_nolen(x) SvPV(x,PL_na)
85#endif
86
87#ifndef get_sv
88#  define get_sv perl_get_sv
89#endif
90
91#ifndef ERRSV
92#  define ERRSV get_sv("@",FALSE)
93#endif
94
95#ifndef pTHX_
96#define pTHX_
97#endif   
98
99#include <string.h>
100#ifdef __cplusplus
101}
102#endif
103