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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(win32) Re: Build Curses for Perl 5.8.0
by PodMaster (Abbot) on Jul 31, 2002 at 07:40 UTC | |
by Cmdr_Tofu (Scribe) on Dec 01, 2002 at 16:44 UTC | |
|
Re: Build Curses for Perl 5.8.0
by Cmdr_Tofu (Scribe) on Dec 01, 2002 at 15:41 UTC | |
|
Re: Build Curses for Perl 5.8.0
by warren (Initiate) on Apr 14, 2003 at 22:57 UTC | |
|
Thanks
by Anonymous Monk on Mar 13, 2004 at 00:11 UTC | |
|
Re: Build Curses for Perl 5.8.0
by cheval_bleu (Initiate) on Sep 07, 2004 at 02:00 UTC |