Index: PDL-2.4.1/Basic/Core/Core.xs.PL =================================================================== --- PDL-2.4.1.orig/Basic/Core/Core.xs.PL 2003-05-04 10:26:36.000000000 +0200 +++ PDL-2.4.1/Basic/Core/Core.xs.PL 2004-12-06 00:32:06.000000000 +0100 @@ -1303,6 +1303,7 @@ pdl_make_physical(pdls[i]); realdims[i] = 0; } + PDL_THR_CLRMAGIC(&pdl_thr); pdl_initthreadstruct(0,pdls,realdims,realdims,npdls,NULL,&pdl_thr,NULL); pdl_startthreadloop(&pdl_thr,NULL,NULL); sd = pdl_thr.ndims; @@ -1378,6 +1379,7 @@ printf("]\n"); } #endif + PDL_THR_CLRMAGIC(&pdl_thr); pdl_initthreadstruct(0,pdls,realdims,creating,npdls, NULL,&pdl_thr,NULL); for(i=0, nc=npdls; imagicno = PDL_THR_MAGICNO -#define PDL_THR_CLRMAGIC(it) it->magicno = 0x99876134 +#define PDL_THR_CLRMAGIC(it) (it)->magicno = 0x99876134 +#else +#define PDL_THR_CLRMAGIC(it) (void)0 #endif /* XXX To avoid mallocs, these should also have "default" values */ Index: PDL-2.4.1/Basic/Gen/PP.pm =================================================================== --- PDL-2.4.1.orig/Basic/Gen/PP.pm 2004-12-06 00:51:58.000000000 +0100 +++ PDL-2.4.1/Basic/Gen/PP.pm 2004-12-06 23:39:18.000000000 +0100 @@ -552,6 +552,7 @@ [[NewXSCHdrs], [NewXSName,NewXSArgs,GlobalNew], "XSCHdrs"], [[NewXSLocals], [NewXSSymTab], "Sym2Loc"], [[IsAffineFlag], [], sub {return "0"}], + [[NoPdlThread], [], sub {0}], # need special cases for # a) bad values @@ -560,7 +561,7 @@ # - perhaps I should have separate rules (but b and c produce the # same output...) # - [[NewXSStructInit0], [NewXSSymTab,VTableName,IsAffineFlag], + [[NewXSStructInit0], [NewXSSymTab,VTableName,IsAffineFlag,NoPdlThread], "MkPrivStructInit", "Rule to create and initialise the private trans structure"], [[NewXSMakeNow], [ParNames,NewXSSymTab], "MakeNows"], @@ -659,9 +660,10 @@ [[NewXSStructInit2], [MakeCompiledRepr, NewXSSymTab,Name], sub {"{".dosubst(@_)."}"}], - [[CopyCodeNS], [PrivCopyCode,CompCopyCode,StructName], sub {"$_[2] *__copy - = malloc(sizeof($_[2])); - PDL_TR_CLRMAGIC(__copy); + [[CopyCodeNS], [PrivCopyCode,CompCopyCode,StructName,NoPdlThread], sub {return "$_[2] *__copy + = malloc(sizeof($_[2]));" . + ($_[3] ? "" : "PDL_THR_CLRMAGIC(&__copy->__pdlthread);") . +" PDL_TR_CLRMAGIC(__copy); __copy->flags = \$PRIV(flags); __copy->vtable = \$PRIV(vtable); __copy->__datatype = \$PRIV(__datatype); @@ -1623,12 +1625,13 @@ sub defvtablename {return "pdl_$_[0]_vtable"} sub MkPrivStructInit { - my( $symtab, $vtable, $affflag ) = @_; + my( $symtab, $vtable, $affflag, $nopdlthread ) = @_; my $sname = $symtab->get_symname('_PDL_ThisTrans'); my $ci = ' '; return "\n${ci}$sname = malloc(sizeof(*$sname));\n" . + ($nopdlthread ? "" : "${ci}PDL_THR_CLRMAGIC(&$sname->__pdlthread);\n") . "${ci}PDL_TR_SETMAGIC($sname);\n" . "${ci}$sname->flags = $affflag;\n" . "${ci}$sname->__ddone = 0;\n" . Index: PDL-2.4.1/Basic/Slices/slices.pd =================================================================== --- PDL-2.4.1.orig/Basic/Slices/slices.pd 2004-12-06 12:35:38.000000000 +0100 +++ PDL-2.4.1/Basic/Slices/slices.pd 2004-12-09 00:09:45.000000000 +0100 @@ -103,6 +103,7 @@ AffinePriv => 1, DefaultFlow => 1, P2Child => 1, + NoPdlThread => 1, ReadDataFuncName => "pdl_readdata_affineinternal", WriteBackDataFuncName => "pdl_writebackdata_affineinternal", MakeComp => '$CROAK("AFMC MUSTNT BE CALLED");', @@ -128,6 +129,7 @@ 's_identity', HandleBad => 1, P2Child => 1, + NoPdlThread => 1, DefaultFlow => 1, OtherPars => '', Reversible => 1, @@ -579,6 +581,7 @@ DefaultFlow => 1, Reversible => 1, P2Child => 1, + NoPdlThread => 1, OtherPars => 'SV *index; SV *size; SV *boundary', @@ -1137,6 +1140,7 @@ GlobalNew => 'converttypei_new', OtherPars => 'int totype;', P2Child => 1, + NoPdlThread => 1, Identity => 1, Reversible => 1, # Forced types @@ -1197,6 +1201,7 @@ pp_def( '_clump_int', P2Child => 1, + NoPdlThread => 1, DefaultFlow => 1, Reversible => 1, AffinePriv => 1, @@ -1250,6 +1255,7 @@ DefaultFlow => 1, Reversible => 1, P2Child => 1, + NoPdlThread => 1, XCHGOnly => 1, EquivDimCheck => 'if ($COMP(n1) <0) $COMP(n1) += $PARENT(threadids[0]); @@ -1395,6 +1401,7 @@ DefaultFlow => 1, Reversible => 1, P2Child => 1, + NoPdlThread => 1, XCHGOnly => 1, EquivDimCheck => 'if ($COMP(n1) <0) $COMP(n1) += $PARENT(threadids[0]); @@ -1459,6 +1466,7 @@ EOD P2Child => 1, + NoPdlThread => 1, DefaultFlow => 1, Reversible => 1, OtherPars => 'int nth; int from; int step; int nsteps;', @@ -1601,6 +1609,7 @@ =cut EOD P2Child => 1, + NoPdlThread => 1, DefaultFlow => 1, OtherPars => 'char* str', Comp => 'int nnew; int nthintact; int intactnew; int ndum; @@ -1884,6 +1893,7 @@ pp_def( 'affine', P2Child => 1, + NoPdlThread => 1, DefaultFlow => 1, Reversible => 1, AffinePriv => 1, @@ -1925,6 +1935,7 @@ pp_def( 'diagonalI', P2Child => 1, + NoPdlThread => 1, DefaultFlow => 1, Reversible => 1, AffinePriv => 1, @@ -2037,6 +2048,7 @@ EOD P2Child => 1, + NoPdlThread => 1, DefaultFlow => 1, Reversible => 1, # XXX Not really AffinePriv => 1, @@ -2096,6 +2108,7 @@ EOD P2Child => 1, + NoPdlThread => 1, DefaultFlow => 1, Reversible => 1, # XXX Not really OtherPars => 'int nthdim; int nsp;', @@ -2186,6 +2199,7 @@ EOD P2Child => 1, + NoPdlThread => 1, DefaultFlow => 1, Reversible => 1, AffinePriv => 1, @@ -2222,7 +2236,7 @@ nthc=0; for(i=0; i<$PARENT(ndims); i++) { flag=0; - if($PARENT(nthreadids) > $COMP(id) && + if($PARENT(nthreadids) > $COMP(id) && $COMP(id) >= 0 && i == $PARENT(threadids[$COMP(id)])) { nthc += $COMP(nwhichdims); } @@ -2239,7 +2253,7 @@ for(i=0; i<$COMP(nwhichdims); i++) { int cdim,pdim; cdim = i + - ($PARENT(nthreadids) > $COMP(id) ? + ($PARENT(nthreadids) > $COMP(id) && $COMP(id) >= 0? $PARENT(threadids[$COMP(id)]) : $PARENT(ndims)) - $COMP(nrealwhichdims); pdim = $COMP(whichdims[i]); @@ -2271,6 +2285,7 @@ # a ->threadI(-1,[]) pp_def('identvaff', P2Child => 1, + NoPdlThread => 1, DefaultFlow => 1, Reversible => 1, AffinePriv => 1, @@ -2309,6 +2324,7 @@ EOD P2Child => 1, + NoPdlThread => 1, DefaultFlow => 1, Reversible => 1, AffinePriv => 1,