This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Patch to JPL example program
[perl5.git] / globals.c
1 #include "INTERN.h"
2 #define PERL_IN_GLOBALS_C
3 #include "perl.h"
4
5 #ifdef PERL_OBJECT
6
7 #undef PERLVAR
8 #define PERLVAR(x, y)
9 #undef PERLVARI
10 #define PERLVARI(x, y, z) PL_##x = z;
11 #undef PERLVARIC
12 #define PERLVARIC(x, y, z) PL_##x = z;
13
14 CPerlObj::CPerlObj(IPerlMem* ipM, IPerlEnv* ipE, IPerlStdIO* ipStd,
15                    IPerlLIO* ipLIO, IPerlDir* ipD, IPerlSock* ipS,
16                    IPerlProc* ipP)
17 {
18     memset(((char*)this)+sizeof(void*), 0, sizeof(CPerlObj)-sizeof(void*));
19
20 #include "thrdvar.h"
21 #include "intrpvar.h"
22 #include "perlvars.h"
23
24     PL_piMem = ipM;
25     PL_piENV = ipE;
26     PL_piStdIO = ipStd;
27     PL_piLIO = ipLIO;
28     PL_piDir = ipD;
29     PL_piSock = ipS;
30     PL_piProc = ipP;
31 }
32
33 void*
34 CPerlObj::operator new(size_t nSize, IPerlMem *pvtbl)
35 {
36     if(pvtbl != NULL)
37         return pvtbl->pMalloc(pvtbl, nSize);
38
39     return NULL;
40 }
41
42 int&
43 Perl_ErrorNo(void)
44 {
45     return errno;
46 }
47
48 void
49 CPerlObj::Init(void)
50 {
51 }
52
53 int
54 CPerlObj::fprintf(PerlIO *stream, const char *format, ...)
55 {
56     va_list(arglist);
57     va_start(arglist, format);
58     return PerlIO_vprintf(stream, format, arglist);
59 }
60
61 #ifdef WIN32            /* XXX why are these needed? */
62 bool
63 Perl_do_exec(char *cmd)
64 {
65     return PerlProc_Cmd(cmd);
66 }
67
68 int
69 CPerlObj::do_aspawn(void *vreally, void **vmark, void **vsp)
70 {
71     return PerlProc_aspawn(vreally, vmark, vsp);
72 }
73 #endif  /* WIN32 */
74
75 #endif   /* PERL_OBJECT */