I've comes across this patch to handle unpack "d" on an ARM platform. 
It was part of a Tiff library for Perl.  Instead of getting a value 1
returned the value 5.29980882362664e-315 was returned.  The patch is old
from 2005 which makes me think some compiler update may have removed
it.

It is worth nothing that 0x00000ff300000000 is 5.29980882362664e-315 on
some endian configurations.


Code:
--------------------
    
  my $double = pack ("d",1);
  my $hex =  unpack("h*",$double);
  if ( $hex eq "00000ff300000000" ){
  $swapDoubles=1;
  }
  else {
  $swapDoubles=0;
  }
  
  .
  .
  .
  
  sub DoUnpackD(@)
  {
  my ($bytes, $template, $dataPt, $pos) = @_;
  my $val='';
  
  if ($swapBytes) {
  $val = '';
  $val .= substr($$dataPt,$pos+$bytes,1) while $bytes--;
  } else {
  $val = substr($$dataPt,$pos,$bytes);
  }
  
  if ($swapDoubles) {
        my $bot = substr($val,0,4);
        my $top = substr($val,4,4);
        $val=$top.$bot;
  }
  
  defined($val) or return undef;
  return unpack($template,$val);
  }
  
--------------------


-- 
bpa
------------------------------------------------------------------------
bpa's Profile: http://forums.slimdevices.com/member.php?userid=1806
View this thread: http://forums.slimdevices.com/showthread.php?t=70812

_______________________________________________
plugins mailing list
plugins@lists.slimdevices.com
http://lists.slimdevices.com/mailman/listinfo/plugins

Reply via email to