We were warned that lots of modules would need modification to build for threads and PerlIO. Curses has proved to be one. I did a little source diving, and came up with patches for Curses.c and CursesFun.c which work for me. I built for Linux-2.4, gcc3, glibc-2.2.5, libncurses.so.5.2, perl-5.8.0(i686-linux-thread-multi)

The first patch is needed for ithreads. The Perl_sv_isa() function of perl has a wrapper macro, sv_isa(), which takes care of adding the interpreter state argument to the function call, if needed. Curses.c nearly always uses the macro, but it was omitted in one place it is needed.

The other patch is to repair 'incompatible pointer type' warnings in CursesFun.c. Those are related to PerlIO. To get a native FILE * pointer from a handle (transparent to the IO model), the PerlIO_findFILE() wrapper must be called. There are four locations in CursesFun.c which need this applied.

I don't know very much about maintaining backward compatibility so I'll welcome comments on whether these patches are the most correct way to update Curses. I'll send them on to the author once I'm satisfied that they're correct.

Threading patch:

--- Curses-1.06/Curses.c.orig Tue Jul 30 02:42:30 2002 +++ Curses-1.06/Curses.c Tue Jul 30 03:09:25 2002 @@ -272,7 +272,7 @@ SV *sv; int argnum; { - if (Perl_sv_isa(sv, "Curses::Window")) { + if (sv_isa( sv, "Curses::Window")) { WINDOW *ret = (WINDOW *)SvIV((SV*)SvRV(sv)); return ret; }

PerlIO patch:

--- Curses-1.06/CursesFun.c.orig Tue Jul 30 04:04:30 2002 +++ Curses-1.06/CursesFun.c Tue Jul 30 07:23:06 2002 @@ -1276,8 +1276,8 @@ c_exactargs("newterm", items, 3); { char * type = ST(0) != &PL_sv_undef ? (char *)SvPV(ST(0),PL +_na) : NULL; - FILE * outfd = IoIFP(sv_2io(ST(1))); - FILE * infd = IoIFP(sv_2io(ST(2))); + FILE * outfd = PerlIO_findFILE(IoIFP(sv_2io(ST(1)))); + FILE * infd = PerlIO_findFILE(IoIFP(sv_2io(ST(2)))); SCREEN * ret = newterm(type, outfd, infd); ST(0) = sv_newmortal(); @@ -3450,7 +3450,7 @@ c_exactargs("putwin", items, 2); { WINDOW *win = c_sv2window(ST(0), 0); - FILE * filep = IoIFP(sv_2io(ST(1))); + FILE * filep = PerlIO_findFILE(IoIFP(sv_2io(ST(1)))); int ret = putwin(win, filep); ST(0) = sv_newmortal(); @@ -3469,7 +3469,7 @@ #ifdef C_GETWIN c_exactargs("getwin", items, 1); { - FILE * filep = IoIFP(sv_2io(ST(0))); + FILE * filep = PerlIO_findFILE(IoIFP(sv_2io(ST(0)))); WINDOW * ret = getwin(filep); ST(0) = sv_newmortal();

After Compline,
Zaxo


In reply to Build Curses for Perl 5.8.0 by Zaxo

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.