Retired Document
Important: This sample code may not represent best practices for current development. The project may use deprecated symbols and illustrate technologies and techniques that are no longer recommended.
Relevant replacement documents include:
PublicUtility/CAByteOrder.h
/* |
<codex> |
<abstract>Part of CoreAudio Utility Classes</abstract> |
<\codex> |
*/ |
#if !defined(__CAByteOrder_h__) |
#define __CAByteOrder_h__ |
//============================================================================= |
// Includes |
//============================================================================= |
// System Includes |
#if !defined(__COREAUDIO_USE_FLAT_INCLUDES__) |
#include <CoreFoundation/CoreFoundation.h> |
#else |
#include "CoreFoundation.h" |
#endif |
#if defined(__cplusplus) |
extern "C" { |
#endif |
CF_INLINE Float32 CASwapFloat32 (Float32 arg) { |
union { |
Float32 f; |
UInt32 i; |
} flip; |
flip.f = arg; |
flip.i = CFSwapInt32 (flip.i); |
return flip.f; |
} |
CF_INLINE Float64 CASwapFloat64 (Float64 arg) { |
union { |
Float64 f; |
UInt64 i; |
} flip; |
flip.f = arg; |
flip.i = CFSwapInt64 (flip.i); |
return flip.f; |
} |
#pragma mark -Flippers |
CF_INLINE Float32 CASwapFloat32BigToHost(Float32 arg) { |
#if defined(__BIG_ENDIAN__) |
return arg; |
#else |
return CASwapFloat32(arg); |
#endif |
} |
CF_INLINE Float64 CASwapFloat64BigToHost(Float64 arg) { |
#if defined(__BIG_ENDIAN__) |
return arg; |
#else |
return CASwapFloat64(arg); |
#endif |
} |
CF_INLINE Float32 CASwapFloat32HostToBig(Float32 arg) { |
#if defined(__BIG_ENDIAN__) |
return arg; |
#else |
return CASwapFloat32(arg); |
#endif |
} |
CF_INLINE Float64 CASwapFloat64HostToBig(Float64 arg) { |
#if defined(__BIG_ENDIAN__) |
return arg; |
#else |
return CASwapFloat64(arg); |
#endif |
} |
CF_INLINE Float32 CASwapFloat32LittleToHost(Float32 arg) { |
#if defined(__LITTLE_ENDIAN__) |
return arg; |
#else |
return CASwapFloat32(arg); |
#endif |
} |
CF_INLINE Float64 CASwapFloat64LittleToHost(Float64 arg) { |
#if defined(__LITTLE_ENDIAN__) |
return arg; |
#else |
return CASwapFloat64(arg); |
#endif |
} |
CF_INLINE Float32 CASwapFloat32HostToLittle(Float32 arg) { |
#if defined(__LITTLE_ENDIAN__) |
return arg; |
#else |
return CASwapFloat32(arg); |
#endif |
} |
CF_INLINE Float64 CASwapFloat64HostToLittle(Float64 arg) { |
#if defined(__LITTLE_ENDIAN__) |
return arg; |
#else |
return CASwapFloat64(arg); |
#endif |
} |
#if defined(__cplusplus) |
} |
#endif |
#endif |
Copyright © 2012 Apple Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2012-10-08