develooper Front page | perl.perl5.porters | Postings from October 2008

Re: [PATCH] Haiku Port

Thread Previous | Thread Next
From:
H.Merijn Brand
Date:
October 29, 2008 01:39
Subject:
Re: [PATCH] Haiku Port
Message ID:
20081029093920.42fdcf23@pc09.procura.nl
On Wed, 29 Oct 2008 02:25:44 +0100, Ingo Weinhold
<ingo_weinhold@gmx.de> wrote:

> Howdy,
> 
> attached is a patch introducing support for Haiku, created against 
> perl-current @34615. Most changes are pretty straight-forward. Noteworthy 
> are the following two:

The patch is very complete and looks also pretty sane. Thanks!

1. Applied the Configure changes to the metaconfig branch and
   regenerated Configure

2. Applied all but the ext/POSIX part in a series of changes, as I
   managed to trick perforce into adding the wrong files and had to
   correct that. Changes #34630, #34631, #34632, and #34634 should
   bring you to where you want to be. Sorry for the noise.

> * ext/Haiku/...: Adds a module Haiku which provides access to a few Haiku 
>   specific API functions, which I found very helpful while debugging the port.

I moved that to haiku/Haiku, as everything in ext/ is for all OS's

> * ext/POSIX/POSIX.xs: I re-introduced the use of the WMUNGE() macro, which 
>   was (accidentally?) removed after 5.10.0. The macro is still a hack. As my 
>   added comment explains the use of the OS's W*() macros in this context is 
>   simply not correct and should probably better be fixed.

That is beyond my scope, and I leave that to other magicians

diff -urN perl/ext/POSIX/POSIX.xs perl/ext/POSIX/POSIX.xs
--- perl/ext/POSIX/POSIX.xs     2008-09-19 21:04:09.000000000 +0000
+++ perl/ext/POSIX/POSIX.xs     2008-10-28 15:22:24.000000000 +0000
@@ -379,7 +379,17 @@
  * to follow the traditional.  However, to make the POSIX
  * wait W*() macros to work in BeOS, we need to unbend the
  * reality back in place. --jhi */
-#ifdef __BEOS__
+/* In actual fact the code below is to blame here. Perl has an internal
+ * representation of the exit status ($?), which it re-composes from the
+ * OS's representation using the W*() POSIX macros. The code below
+ * incorrectly uses the W*() macros on the internal representation,
+ * which fails for OSs that have a different representation (namely BeOS
+ * and Haiku). WMUNGE() is a hack that converts the internal
+ * representation into the OS specific one, so that the W*() macros work
+ * as expected. The better solution would be not to use the W*() macros
+ * in the first place, though. -- Ingo Weinhold
+ */
+#if defined(__BEOS__) || defined(__HAIKU__)
 #    define WMUNGE(x) (((x) & 0xFF00) >> 8 | ((x) & 0x00FF) << 8)
 #else
 #    define WMUNGE(x) (x)
@@ -664,42 +674,42 @@
        switch(ix) {
        case 0:
 #ifdef WEXITSTATUS
-           RETVAL = WEXITSTATUS(status);
+           RETVAL = WEXITSTATUS(WMUNGE(status));
 #else
            not_here("WEXITSTATUS");
 #endif
            break;
        case 1:
 #ifdef WIFEXITED
-           RETVAL = WIFEXITED(status);
+           RETVAL = WIFEXITED(WMUNGE(status));
 #else
            not_here("WIFEXITED");
 #endif
            break;
        case 2:
 #ifdef WIFSIGNALED
-           RETVAL = WIFSIGNALED(status);
+           RETVAL = WIFSIGNALED(WMUNGE(status));
 #else
            not_here("WIFSIGNALED");
 #endif
            break;
        case 3:
 #ifdef WIFSTOPPED
-           RETVAL = WIFSTOPPED(status);
+           RETVAL = WIFSTOPPED(WMUNGE(status));
 #else
            not_here("WIFSTOPPED");
 #endif
            break;
        case 4:
 #ifdef WSTOPSIG
-           RETVAL = WSTOPSIG(status);
+           RETVAL = WSTOPSIG(WMUNGE(status));
 #else
            not_here("WSTOPSIG");
 #endif
            break;
        case 5:
 #ifdef WTERMSIG
-           RETVAL = WTERMSIG(status);
+           RETVAL = WTERMSIG(WMUNGE(status));
 #else
            not_here("WTERMSIG");
 #endif

-- 
H.Merijn Brand          Amsterdam Perl Mongers  http://amsterdam.pm.org/
using & porting perl 5.6.2, 5.8.x, 5.10.x, 5.11.x on HP-UX 10.20, 11.00,
11.11, 11.23, and 11.31, SuSE 10.1, 10.2, and 10.3, AIX 5.2, and Cygwin.
http://mirrors.develooper.com/hpux/           http://www.test-smoke.org/
http://qa.perl.org      http://www.goldmark.org/jeff/stupid-disclaimers/

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About