Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
endianness.h File Reference
#include "config.h"
#include <endian.h>
#include <byteswap.h>

Go to the source code of this file.

Macros

#define le32_to_cpu(x)   ( bswap_32( x ) )
 
#define le16_to_cpu(x)   ( bswap_16( x ) )
 
#define le64_to_cpu(x)   ( DONTUSE__NXSwapBigDoubleToLittleEndian( x ) )
 

Functions

double DONTUSE__NXSwapBigDoubleToLittleEndian (double x)
 
float VSSwapHostFloatToLittle (float x)
 
double VSSwapHostDoubleToLittle (double x)
 
unsigned int VSSwapHostIntToLittle (unsigned int x)
 
unsigned short VSSwapHostShortToLittle (unsigned short x)
 

Macro Definition Documentation

#define le16_to_cpu (   x)    ( bswap_16( x ) )

Definition at line 56 of file endianness.h.

Referenced by LoadTex(), reads(), and VSSwapHostShortToLittle().

#define le32_to_cpu (   x)    ( bswap_32( x ) )
#define le64_to_cpu (   x)    ( DONTUSE__NXSwapBigDoubleToLittleEndian( x ) )

Definition at line 57 of file endianness.h.

Referenced by VSSwapHostDoubleToLittle().

Function Documentation

double DONTUSE__NXSwapBigDoubleToLittleEndian ( double  x)
inline

Definition at line 93 of file endianness.h.

References d, i, le32_to_cpu, and x.

94 {
95  union LILdubl
96  {
97  double d;
98  unsigned int i[2];
99  }
100  l;
101  l.d = x;
102  unsigned int tmp = le32_to_cpu( l.i[0] );
103  l.i[0] = le32_to_cpu( l.i[1] );
104  l.i[1] = tmp;
105  return l.d;
106 }
double VSSwapHostDoubleToLittle ( double  x)
inline

Definition at line 78 of file endianness.h.

References le64_to_cpu.

79 {
80  return le64_to_cpu( x );
81 }
float VSSwapHostFloatToLittle ( float  x)
inline

Definition at line 65 of file endianness.h.

References f, i, le32_to_cpu, and x.

Referenced by Mesh::LoadMeshes(), Quaternion::netswap(), Matrix::netswap(), weapon_info::netswap(), and GFXColor::netswap().

66 {
67  union LILfloat
68  {
69  float f;
70  unsigned int i;
71  }
72  l;
73  l.f = x;
74  l.i = le32_to_cpu( l.i );
75  return l.f;
76 }
unsigned int VSSwapHostIntToLittle ( unsigned int  x)
inline

Definition at line 83 of file endianness.h.

References le32_to_cpu.

Referenced by Mesh::LoadMeshes(), and weapon_info::netswap().

84 {
85  return le32_to_cpu( x );
86 }
unsigned short VSSwapHostShortToLittle ( unsigned short  x)
inline

Definition at line 88 of file endianness.h.

References le16_to_cpu.

Referenced by getWeaponInfoFromBuffer().

89 {
90  return le16_to_cpu( x );
91 }