Re: cpu_to_le16 and le16_to_cpu
Re: cpu_to_le16 and le16_to_cpu
- Subject: Re: cpu_to_le16 and le16_to_cpu
- From: Michael Cashwell <email@hidden>
- Date: Thu, 27 May 2004 15:18:43 -0400
On May 27, 2004, at 4:08 AM, Dan Christiansen wrote:
Lalit Chandivade wrote:
What is the equivalent of Linux apis cpu_to_le16 and le16_to_cpu on
Mac OS X?
I believe they are in <architecture/byte_order.h> and are called
NXSwapHostShortToLittle() and NXSwapLittleShortToHost().
(Sorry for the repeat Dan. I meant to send this to the list too so here
goes...)
The Swap functions are useful when the data are already in host memory.
But if I recall the behavior of the cpu_to and to_cpu functions on
Linux, a closer match would be functions like OSWriteLittleInt32().
These boil down to the PPC instructions to do the swap as part of the
reads and writes and offer other useful things like byte offsets via an
argument.
They are in <libkern/OSByteOrder.h> but I don't explicitly include
that. You probably can, but I get it due to some higher-level include
from IOKit apparently though I don't know which one. Perhaps
<IOKit/system.h>?
-Mike
_______________________________________________
darwin-kernel mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/darwin-kernel
Do not post admin requests to the list. They will be ignored.