• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: EndianU32_NtoB
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: EndianU32_NtoB


  • Subject: Re: EndianU32_NtoB
  • From: "Sean McBride" <email@hidden>
  • Date: Fri, 30 Oct 2009 13:51:18 -0400
  • Organization: Rogue Research Inc.

On 10/30/09 6:29 PM, gMail.com said:

>Cool. Thanks. I did the following, either when I read from the disk and when
>I write to the disk
>
>Read unsigned int in case of PPC
>        outValue[i] = EndianU32_NtoB(inValue[i]);
>
>Write unsigned int in case of PPC
>        outValue[i] = EndianU32_BtoN(inValue[i]);
>
>Read float in case of PPC
>        EndianDouble_NtoB(outValue[i], inValue[i]);
>
>Write float in case of PPC
>        EndianDouble_BtoN(outValue[i], inValue[i]);

That's fine.

>#define EndianDouble_BtoN(o,i)
>((Float64*)&o)[0]=CFConvertFloat64SwappedToHost(((CFSwappedFloat64*)&i)[0]);
>
>#define EndianDouble_NtoB(o,i)
>((CFSwappedFloat64*)&o)[0]=CFConvertFloat64HostToSwapped(((Float64*)&i)[0]);

Not sure about that.  I think you might be breaking 'struct aliasing
rules'.  What happens if you add the -Wstrict-aliasing warning flag?
That's why I suggested using a union.  See also:
<http://cellperformance.beyond3d.com/articles/2006/06/understanding-
strict-aliasing.html>

--
____________________________________________________________
Sean McBride, B. Eng                 email@hidden
Rogue Research                        www.rogue-research.com
Mac Software Developer              Montréal, Québec, Canada


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: EndianU32_NtoB
      • From: "gMail.com" <email@hidden>
References: 
 >Re: EndianU32_NtoB (From: "gMail.com" <email@hidden>)

  • Prev by Date: Re: EndianU32_NtoB
  • Next by Date: Re: Help debugging "Dangling reference to an invalid object." Core Data error
  • Previous by thread: Re: EndianU32_NtoB
  • Next by thread: Re: EndianU32_NtoB
  • Index(es):
    • Date
    • Thread