Change 34095 by [EMAIL PROTECTED] on 2008/06/30 20:18:26

        Integrate:
        [ 34090]
        Upgrade to Win32-0.37
        
        [ 34094]
        Upgrade to Win32-0.38
        (including changes to GetCurrentThreadId.t which should have gone into
        the 0.37 upgrade, but which I missed then)

Affected files ...

... //depot/maint-5.10/perl/ext/Win32/Changes#4 integrate
... //depot/maint-5.10/perl/ext/Win32/Win32.pm#5 integrate
... //depot/maint-5.10/perl/ext/Win32/Win32.xs#6 integrate
... //depot/maint-5.10/perl/ext/Win32/t/GetCurrentThreadId.t#3 integrate

Differences ...

==== //depot/maint-5.10/perl/ext/Win32/Changes#4 (text) ====
Index: perl/ext/Win32/Changes
--- perl/ext/Win32/Changes#3~33755~     2008-04-27 01:54:23.000000000 -0700
+++ perl/ext/Win32/Changes      2008-06-30 13:18:26.000000000 -0700
@@ -1,5 +1,12 @@
 Revision history for the Perl extension Win32.
 
+0.38   [2008-06-27]
+       - Fix Cygwin releated problems in t/GetCurrentThreadId.t
+         (Jerry D. Hedden).
+
+0.37   [2008-06-26]
+       - Add Win32::GetCurrentProcessId() function
+
 0.36   [2008-04-17]
        - Add typecasts for Win64 compilation
 

==== //depot/maint-5.10/perl/ext/Win32/Win32.pm#5 (text) ====
Index: perl/ext/Win32/Win32.pm
--- perl/ext/Win32/Win32.pm#4~33755~    2008-04-27 01:54:23.000000000 -0700
+++ perl/ext/Win32/Win32.pm     2008-06-30 13:18:26.000000000 -0700
@@ -8,7 +8,7 @@
     require DynaLoader;
 
     @ISA = qw|Exporter DynaLoader|;
-    $VERSION = '0.36';
+    $VERSION = '0.38';
     $XS_VERSION = $VERSION;
     $VERSION = eval $VERSION;
 
@@ -403,15 +403,25 @@
 ANSI path name for the current directory if the long pathname cannot
 be represented in the system codepage.
 
+=item Win32::GetCurrentProcessId()
+
+Returns the process identifier of the current process.  Until the
+process terminates, the process identifier uniquely identifies the
+process throughout the system.
+
+The current process identifier is normally also available via the
+predefined $$ variable.  Under fork() emulation however $$ may contain
+a pseudo-process identifier that is only meaningful to the Perl
+kill(), wait() and waitpid() functions.  The
+Win32::GetCurrentProcessId() function will always return the regular
+Windows process id, even when called from inside a pseudo-process.
+
 =item Win32::GetCurrentThreadId()
 
 Returns the thread identifier of the calling thread.  Until the thread
 terminates, the thread identifier uniquely identifies the thread
 throughout the system.
 
-Note: the current process identifier is available via the predefined
-$$ variable.
-
 =item Win32::GetFileVersion(FILENAME)
 
 Returns the file version number from the VERSIONINFO resource of

==== //depot/maint-5.10/perl/ext/Win32/Win32.xs#6 (text) ====
Index: perl/ext/Win32/Win32.xs
--- perl/ext/Win32/Win32.xs#5~33755~    2008-04-27 01:54:23.000000000 -0700
+++ perl/ext/Win32/Win32.xs     2008-06-30 13:18:26.000000000 -0700
@@ -1590,6 +1590,13 @@
     XSRETURN_EMPTY;
 }
 
+XS(w32_GetCurrentProcessId)
+{
+    dXSARGS;
+    EXTEND(SP,1);
+    XSRETURN_IV(GetCurrentProcessId());
+}
+
 XS(w32_GetCurrentThreadId)
 {
     dXSARGS;
@@ -1701,6 +1708,7 @@
     newXS("Win32::CopyFile", w32_CopyFile, file);
     newXS("Win32::Sleep", w32_Sleep, file);
     newXS("Win32::OutputDebugString", w32_OutputDebugString, file);
+    newXS("Win32::GetCurrentProcessId", w32_GetCurrentProcessId, file);
     newXS("Win32::GetCurrentThreadId", w32_GetCurrentThreadId, file);
     newXS("Win32::CreateDirectory", w32_CreateDirectory, file);
     newXS("Win32::CreateFile", w32_CreateFile, file);

==== //depot/maint-5.10/perl/ext/Win32/t/GetCurrentThreadId.t#3 (text) ====
Index: perl/ext/Win32/t/GetCurrentThreadId.t
--- perl/ext/Win32/t/GetCurrentThreadId.t#2~33642~      2008-04-03 
10:06:15.000000000 -0700
+++ perl/ext/Win32/t/GetCurrentThreadId.t       2008-06-30 13:18:26.000000000 
-0700
@@ -3,16 +3,34 @@
 use Test;
 use Win32;
 
-plan tests => 1;
+my $fork_emulation = $Config{ccflags} =~ /PERL_IMPLICIT_SYS/;
 
-# This test relies on the implementation detail that the fork() emulation
-# uses the negative value of the thread id as a pseudo process id.
-if ($Config{ccflags} =~ /PERL_IMPLICIT_SYS/) {
-    if (my $pid = fork) {
-       waitpid($pid, 0);
+my $tests = $fork_emulation ? 4 : 2;
+plan tests => $tests;
+
+my $pid = $$+0; # make sure we don't copy any magic to $pid
+
+if ($^O eq "cygwin") {
+    skip(!defined &Cygwin::pid_to_winpid,
+        Cygwin::pid_to_winpid($pid),
+        Win32::GetCurrentProcessId());
+}
+else {
+    ok($pid, Win32::GetCurrentProcessId());
+}
+
+if ($fork_emulation) {
+    # This test relies on the implementation detail that the fork() emulation
+    # uses the negative value of the thread id as a pseudo process id.
+    if (my $child = fork) {
+       waitpid($child, 0);
        exit 0;
     }
     ok(-$$, Win32::GetCurrentThreadId());
+
+    # GetCurrentProcessId() should still return the real PID
+    ok($pid, Win32::GetCurrentProcessId());
+    ok($$ != Win32::GetCurrentProcessId());
 }
 else {
     # here we just want to see something.
End of Patch.

Reply via email to