develooper Front page | perl.perl5.porters | Postings from November 2005

Re: XS-assisted SWASHGET (esp. for t/uni/class.t speedup)

Thread Previous
From:
SADAHIRO Tomoyuki
Date:
November 24, 2005 07:18
Subject:
Re: XS-assisted SWASHGET (esp. for t/uni/class.t speedup)
Message ID:
20051125001031.24E3.BQW10602@nifty.com

On Wed, 23 Nov 2005 17:08:16 +0100, Rafael Garcia-Suarez <rgarciasuarez@mandriva.com> wrote

> SADAHIRO Tomoyuki wrote:
> > > The patch gzipped (against perl patch 26198) is attached to this mail
> > > as swashget.patch.gz
> > 
> > I must report that this patch has a bug that perl will crash
> > when the last line of $self->{EXTRAS} does not have \n at the end.
> > 
> > The patch following is an additional patch against the previous patch.
> 
> Clever idea; thanks, I applied both patches as change #26199 to
> bleadperl. However, I had to replace some char* by some U8* pointers in
> your code, to get it to compile on my platform (where U8 is an unsigned
> char.)

Surely my code includes numeric difference between char* and U8*
which are not compatible.
A compiler may dislike such a mismatch of signedness.

> Now it compiles, but universal.c spits out some unsigned-related
> warnings :
> 
> `sh  cflags "optimize='-g'" universal.o`  universal.c
>           CCCMD =  cc -DPERL_CORE -c -DDEBUGGING -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm -g  -Wall
> universal.c: In function 'XS_utf8_SWASHGET_heavy':
> universal.c:992: warning: pointer targets in assignment differ in signedness
> universal.c:1051: warning: pointer targets in passing argument 1 of 'Perl_grok_hex' differ in signedness
> universal.c:1067: warning: pointer targets in passing argument 1 of 'Perl_grok_hex' differ in signedness
> universal.c:1079: warning: pointer targets in passing argument 1 of 'Perl_grok_hex' differ in signedness
> universal.c:1222: warning: pointer targets in passing argument 2 of 'Perl_hv_fetch' differ in signedness
> universal.c:1253: warning: pointer targets in assignment differ in signedness
> 
> which need to be silenced.

I think appropriate casts will silence them.
Here is a patch.

Regards,
SADAHIRO Tomoyuki

diff -ur perl~patch26201/universal.c perl/universal.c
--- perl~patch26201/universal.c	Thu Nov 24 01:01:37 2005
+++ perl/universal.c	Thu Nov 24 23:54:32 2005
@@ -989,7 +989,7 @@
 	bitssvp = hv_fetch(hv, "BITS", 4, FALSE);
 	nonesvp = hv_fetch(hv, "NONE", 4, FALSE);
 	extssvp = hv_fetch(hv, "EXTRAS", 6, FALSE);
-	typestr = SvPV_nolen(*typesvp);
+	typestr = (U8*)SvPV_nolen(*typesvp);
 	typeto  = typestr[0] == 'T' && typestr[1] == 'o';
 	bits    = (U32)SvUV(*bitssvp);
 	none    = (U32)SvUV(*nonesvp);
@@ -1048,7 +1048,7 @@
 	    nextline = (U8*)memchr(l, '\n', lend - l);
 
 	    numlen = lend - l;
-	    min = (U32)grok_hex(l, &numlen, &flags, NULL);
+	    min = (U32)grok_hex((char *)l, &numlen, &flags, NULL);
 	    if (numlen)
 		l += numlen;
 	    else if (nextline) {
@@ -1064,7 +1064,7 @@
 		++l;
 		flags = PERL_SCAN_SILENT_ILLDIGIT | PERL_SCAN_DISALLOW_PREFIX;
 		numlen = lend - l;
-		max = (U32)grok_hex(l, &numlen, &flags, NULL);
+		max = (U32)grok_hex((char *)l, &numlen, &flags, NULL);
 		if (numlen)
 		    l += numlen;
 		else
@@ -1076,7 +1076,7 @@
 			flags = PERL_SCAN_SILENT_ILLDIGIT |
 				PERL_SCAN_DISALLOW_PREFIX;
 			numlen = lend - l;
-			val = (U32)grok_hex(l, &numlen, &flags, NULL);
+			val = (U32)grok_hex((char *)l, &numlen, &flags, NULL);
 			if (numlen)
 			    l += numlen;
 			else
@@ -1219,7 +1219,7 @@
 		HV* otherhv;
 		SV **otherbitssvp;
 
-		othersvp = hv_fetch(hv, namestr, namelen, FALSE);
+		othersvp = hv_fetch(hv, (char *)namestr, namelen, FALSE);
 		if (*othersvp && SvROK(*othersvp) &&
 				 SvTYPE(SvRV(*othersvp))==SVt_PVHV)
 		    otherhv = (HV*)SvRV(*othersvp);
@@ -1250,7 +1250,7 @@
 
 		    if (!olen)
 			Perl_croak(aTHX_ "SWASHGET didn't return valid swatch");
-		    s = SvPV(swatch, slen);
+		    s = (U8*)SvPV(swatch, slen);
 		    if (bits == 1 && otherbits == 1) {
 			if (slen != olen)
 			    Perl_croak(aTHX_ "SWASHGET length mismatch");
###End of patch



Thread Previous


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