In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/903f2d7006dbd87b9347acb742b9d7848f566aed?hp=1799399c45baa7e5af45db33567d2a2de629d5e0>

- Log -----------------------------------------------------------------
commit 903f2d7006dbd87b9347acb742b9d7848f566aed
Author: Steve Hay <[email protected]>
Date:   Fri Jun 7 23:47:12 2013 +0100

    Include the Win32 extension in the ALL_STATIC build on Win32
    
    Many of Win32's Perl level functions are pre-defined (even without a "use
    Win32" statement), while the implementation is in a dynamically linked
    module. This is done via the statically linked Win32CORE wrapper that will
    load Win32 on demand. The initialization of Win32CORE (init_Win32CORE()) is
    called -- dynamically, via GetProcAddress(), since miniperl.exe doesn't
    include it -- from Perl_init_os_extras() and normally relies on the DLL's
    HANDLE having been set in the DLL_PROCESS_ATTACH case of DllMain() in
    perllib.c. We must use a different HANDLE when the functions are located in
    perl-static.exe since DllMain() is not called in that case, and, in fact,
    it is sensible to consider other parts of DllMain() which
    Perl_init_os_extras() might also need to do...
    
    The #ifdef DEFAULT_BINMODE section can be scrapped completely since the
    symbol is not defined, never mentioned anywhere else and not documented.
    The DisableThreadLibraryCalls() call is not applicable for code that
    doesn't reside in a DLL. That just leaves set_w32_module_name(), but that
    is not required either, and may actually be redundant in the DllMain() case
    too (maybe I will remove it later).
    
    The last-but-one thing to do is to arrange for init_Win32CORE to be
    exported from perl-static.exe (as it already is from perl519.dll, courtesy
    of makedef.pl) otherwise GetProcAddress() won't find it. I see no harm in
    always specifying __declspec(dllexport) in Win32CORE.c (except in one
    existing Cygwin case which doesn't want it, which I'm not touching to
    minimize regression risk). I thought that the .def file entry written by
    makedef.pl for perl519.dll would then become redundant, and whilst the VC++
    build worked fine without it, the MinGW build didn't: init_Win32CORE no
    longer got exported from perl519.dll, thus breaking the normal build, so
    I've therefore left makedef.pl alone.
    
    The very last thing to do in some future change is to improve the
    ALL_STATIC build so that Win32 functions like CopyFile() do not go
    through Win32CORE's w32_CORE_all forwarding function as they currently do:
    it isn't necessary when Win32 is statically linked as well! I will revisit
    this part very soon...
    
    Thanks to Jan Dubois and all the others in the following thread for
    invaluable assistance in this and other recent changes in this area:
    http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2013-06/msg00016.html
-----------------------------------------------------------------------

Summary of changes:
 ext/Win32CORE/Win32CORE.c |    2 +-
 win32/Makefile            |    5 ++---
 win32/makefile.mk         |    5 ++---
 win32/perllib.c           |    8 --------
 win32/win32.c             |    5 ++++-
 5 files changed, 9 insertions(+), 16 deletions(-)

diff --git a/ext/Win32CORE/Win32CORE.c b/ext/Win32CORE/Win32CORE.c
index 22f6adf..b318fcc 100644
--- a/ext/Win32CORE/Win32CORE.c
+++ b/ext/Win32CORE/Win32CORE.c
@@ -44,7 +44,7 @@ XS_EXTERNAL(boot_Win32CORE)
      * should never be called though, as Win32CORE.pm doesn't use DynaLoader.
      */
 }
-#if defined(__CYGWIN__) && defined(USEIMPORTLIB)
+#if !defined(__CYGWIN__) || defined(USEIMPORTLIB)
 __declspec(dllexport)
 #endif
 void
diff --git a/win32/Makefile b/win32/Makefile
index 309ff19..545dc92 100644
--- a/win32/Makefile
+++ b/win32/Makefile
@@ -771,10 +771,9 @@ SETARGV_OBJ        = setargv$(o)
 
 !IF "$(ALL_STATIC)" == "define"
 # some exclusions, unfortunately, until fixed:
-#  - Win32 extension contains overlapped symbols with win32.c (BUG!)
-#  - MakeMaker isn't capable enough for SDBM_File (smaller bug)
+#  - MakeMaker isn't capable enough for SDBM_File (small bug)
 #  - Encode (encoding search algorithm relies on shared library?)
-STATIC_EXT     = * !Win32 !SDBM_File !Encode
+STATIC_EXT     = * !SDBM_File !Encode
 !ELSE
 # specify static extensions here, for example:
 # (be sure to include Win32CORE to load Win32 on demand)
diff --git a/win32/makefile.mk b/win32/makefile.mk
index 401fee5..0e383cd 100644
--- a/win32/makefile.mk
+++ b/win32/makefile.mk
@@ -874,11 +874,10 @@ SETARGV_OBJ       = setargv$(o)
 
 .IF "$(ALL_STATIC)" == "define"
 # some exclusions, unfortunately, until fixed:
-#  - Win32 extension contains overlapped symbols with win32.c (BUG!)
-#  - MakeMaker isn't capable enough for SDBM_File (smaller bug)
+#  - MakeMaker isn't capable enough for SDBM_File (small bug)
 #  - Encode (encoding search algorithm relies on shared library?)
 #  - GCC's linker gets undefined reference to _BZ2_compressBlock
-STATIC_EXT     = * !Win32 !SDBM_File !Encode
+STATIC_EXT     = * !SDBM_File !Encode
 .IF "$(CCTYPE)" == "GCC"
 STATIC_EXT     += !Compress/Raw/Bzip2
 .ENDIF
diff --git a/win32/perllib.c b/win32/perllib.c
index 22e8923..428ebad 100644
--- a/win32/perllib.c
+++ b/win32/perllib.c
@@ -311,14 +311,6 @@ DllMain(HANDLE hModule,            /* DLL module handle */
         * 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;
-#endif
-
 #ifndef UNDER_CE
        DisableThreadLibraryCalls((HMODULE)hModule);
 #endif
diff --git a/win32/win32.c b/win32/win32.c
index bda5356..c31e3a2 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -4152,7 +4152,10 @@ Perl_init_os_extras(void)
     /* Initialize Win32CORE if it has been statically linked. */
 #ifndef PERL_IS_MINIPERL
     void (*pfn_init)(pTHX);
-    pfn_init = (void (*)(pTHX))GetProcAddress((HMODULE)w32_perldll_handle, 
"init_Win32CORE");
+    HMODULE module = (HMODULE)((w32_perldll_handle == INVALID_HANDLE_VALUE)
+                               ? GetModuleHandle(NULL)
+                               : w32_perldll_handle);
+    pfn_init = (void (*)(pTHX))GetProcAddress(module, "init_Win32CORE");
     aTHXa(PERL_GET_THX);
     if (pfn_init)
         pfn_init(aTHX);

--
Perl5 Master Repository

Reply via email to