Ryujinx/Ryujinx.HLE/Utilities/EndianSwap.cs
emmauss da7e702751 Update BSD service implementation (#363)
* Update BSD service to handle libnx's 'smart IPC buffers' for address info

* Use existing "GetBufferType0x21" for certain BSD socket methods

* Parse address port as unsigned short

* Fix bounds check on reading the IPC buffer

* Implement Read, Write methods

* rebased and cleaned

* addressed nits

* remove unused swap method

* fixed alignments
2018-08-24 14:20:42 -03:00

18 lines
518 B
C#

namespace Ryujinx.HLE.Utilities
{
static class EndianSwap
{
public static ushort Swap16(ushort Value) => (ushort)(((Value >> 8) & 0xff) | (Value << 8));
public static int Swap32(int Value)
{
uint UintVal = (uint)Value;
return (int)(((UintVal >> 24) & 0x000000ff) |
((UintVal >> 8) & 0x0000ff00) |
((UintVal << 8) & 0x00ff0000) |
((UintVal << 24) & 0xff000000));
}
}
}