miniperl build fixes for NeXTstep and cygwin (from Hans Mulder
[p5sagit/p5-mst-13.2.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 PERLVARA
10 #define PERLVARA(x, n, y)
11 #undef PERLVARI
12 #define PERLVARI(x, y, z) interp.x = z;
13 #undef PERLVARIC
14 #define PERLVARIC(x, y, z) interp.x = z;
15
16 CPerlObj::CPerlObj(IPerlMem* ipM, IPerlMem* ipMS, IPerlMem* ipMP,
17                    IPerlEnv* ipE, IPerlStdIO* ipStd,
18                    IPerlLIO* ipLIO, IPerlDir* ipD, IPerlSock* ipS,
19                    IPerlProc* ipP)
20 {
21     memset(((char*)this)+sizeof(void*), 0, sizeof(CPerlObj)-sizeof(void*));
22
23 #include "thrdvar.h"
24 #include "intrpvar.h"
25
26     PL_Mem = ipM;
27     PL_MemShared = ipMS;
28     PL_MemParse = ipMP;
29     PL_Env = ipE;
30     PL_StdIO = ipStd;
31     PL_LIO = ipLIO;
32     PL_Dir = ipD;
33     PL_Sock = ipS;
34     PL_Proc = ipP;
35 }
36
37 void*
38 CPerlObj::operator new(size_t nSize, IPerlMem *pvtbl)
39 {
40     if(pvtbl)
41         return pvtbl->pMalloc(pvtbl, nSize);
42 #ifndef __MINGW32__
43     /* operator new is supposed to throw std::bad_alloc */
44     return NULL;
45 #endif
46 }
47
48 void
49 CPerlObj::operator delete(void *pPerl, IPerlMem *pvtbl)
50 {
51     if(pvtbl)
52         pvtbl->pFree(pvtbl, pPerl);
53 }
54
55 #ifdef WIN32            /* XXX why are these needed? */
56 bool
57 Perl_do_exec(char *cmd)
58 {
59     return PerlProc_Cmd(cmd);
60 }
61
62 int
63 CPerlObj::do_aspawn(void *vreally, void **vmark, void **vsp)
64 {
65     return PerlProc_aspawn(vreally, vmark, vsp);
66 }
67 #endif  /* WIN32 */
68
69 #endif   /* PERL_OBJECT */
70
71 int
72 Perl_fprintf_nocontext(PerlIO *stream, const char *format, ...)
73 {
74     dTHX;
75     va_list(arglist);
76     va_start(arglist, format);
77     return PerlIO_vprintf(stream, format, arglist);
78 }