X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=win32%2Fperllib.c;h=c24941f11133cce3e0a1bbd98eaf0724702ea83d;hb=bbc8f9de328519d89fa89d8fca21fe808800d6a2;hp=f35d41c8bfa37fbeb2a89f40eb028ae6ce86edde;hpb=0a753a764065f2260004b6e6975085378b850346;p=p5sagit%2Fp5-mst-13.2.git diff --git a/win32/perllib.c b/win32/perllib.c index f35d41c..c24941f 100644 --- a/win32/perllib.c +++ b/win32/perllib.c @@ -1,120 +1,102 @@ -#ifdef ABC -#define WIN32_LEAN_AND_MEAN -#include -#include -#include -#include -#include -#endif - /* * "The Road goes ever on and on, down from the door where it began." */ -#ifdef __cplusplus -extern "C" { -#endif #include "EXTERN.h" #include "perl.h" - -#ifdef __cplusplus -} -# define EXTERN_C extern "C" -#else -# define EXTERN_C extern -#endif +#include "XSUB.h" static void xs_init _((void)); -__declspec(dllexport) int RunPerl(int argc, char **argv, char **env, void *iosubsystem) +__declspec(dllexport) int +RunPerl(int argc, char **argv, char **env, void *iosubsystem) { - int exitstatus; - PerlInterpreter *my_perl; - void *pOldIOSubsystem; + int exitstatus; + PerlInterpreter *my_perl; - pOldIOSubsystem = SetIOSubSystem(iosubsystem); +#ifdef USE_THREADS + MUTEX_INIT(&malloc_mutex); +#endif PERL_SYS_INIT(&argc,&argv); perl_init_i18nl10n(1); - if (!(my_perl = perl_alloc())) return (1); - perl_construct( my_perl ); - perl_destruct_level = 0; - + if (!(my_perl = perl_alloc())) + return (1); + perl_construct( my_perl ); + perl_destruct_level = 0; exitstatus = perl_parse( my_perl, xs_init, argc, argv, env); if (!exitstatus) { exitstatus = perl_run( my_perl ); } - perl_destruct( my_perl ); perl_free( my_perl ); PERL_SYS_TERM(); - SetIOSubSystem(pOldIOSubsystem); - - return (exitstatus); -} - -/* Register any extra external extensions */ - -char *staticlinkmodules[]={ - "DynaLoader", - NULL, - }; - -EXTERN_C void boot_DynaLoader _((CV* cv)); - -static void -xs_init() -{ - dXSUB_SYS; - char *file = __FILE__; - newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file); + return (exitstatus); } extern HANDLE PerlDllHandle; -BOOL APIENTRY DllMain(HANDLE hModule, // DLL module handle - DWORD fdwReason, // reason called - LPVOID lpvReserved) // reserved +BOOL APIENTRY +DllMain(HANDLE hModule, /* DLL module handle */ + DWORD fdwReason, /* reason called */ + LPVOID lpvReserved) /* reserved */ { - switch (fdwReason) - { - // The DLL is attaching to a process due to process - // initialization or a call to LoadLibrary. - case DLL_PROCESS_ATTACH: -//#define DEFAULT_BINMODE + switch (fdwReason) { + /* The DLL is attaching to a process due to process + * initialization or a call to LoadLibrary. + */ + case DLL_PROCESS_ATTACH: +/* #define DEFAULT_BINMODE */ #ifdef DEFAULT_BINMODE - _setmode( _fileno( stdin ), _O_BINARY ); - _setmode( _fileno( stdout ), _O_BINARY ); - _setmode( _fileno( stderr ), _O_BINARY ); - _fmode = _O_BINARY; + setmode( fileno( stdin ), O_BINARY ); + setmode( fileno( stdout ), O_BINARY ); + setmode( fileno( stderr ), O_BINARY ); + _fmode = O_BINARY; #endif + PerlDllHandle = hModule; + break; - PerlDllHandle = hModule; - break; + /* The DLL is detaching from a process due to + * process termination or call to FreeLibrary. + */ + case DLL_PROCESS_DETACH: + break; - // The DLL is detaching from a process due to - // process termination or call to FreeLibrary. - case DLL_PROCESS_DETACH: - break; + /* The attached process creates a new thread. */ + case DLL_THREAD_ATTACH: + break; - // The attached process creates a new thread. - case DLL_THREAD_ATTACH: - break; + /* The thread of the attached process terminates. */ + case DLL_THREAD_DETACH: + break; - // The thread of the attached process terminates. - case DLL_THREAD_DETACH: - break; + default: + break; + } + return TRUE; +} - default: - break; - } - return TRUE; +/* Register any extra external extensions */ + +char *staticlinkmodules[] = { + "DynaLoader", + NULL, +}; + +EXTERN_C void boot_DynaLoader _((CV* cv)); + +static void +xs_init() +{ + char *file = __FILE__; + dXSUB_SYS; + newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file); }