Skip to content

Commit

Permalink
Add bsd implementations over from ps4.
Browse files Browse the repository at this point in the history
  • Loading branch information
Wolf3s committed Jun 12, 2024
1 parent ca4851a commit 9d1cc17
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 36 deletions.
57 changes: 29 additions & 28 deletions include/portable-endian.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,13 @@
#define htole64(x) (x)
#define le64toh(x) (x)

#elif defined(__linux__) || defined(__CYGWIN__) || defined(PS4_PLATFORM) || defined(ESP_PLATFORM)
#elif defined(__linux__) || defined(__CYGWIN__) || defined(ESP_PLATFORM) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__) || defined(__OpenBSD__)

#if defined(__linux__) || defined(__CYGWIN__) || defined(PS4_PLATFORM) || defined(ESP_PLATFORM)
#include <endian.h>
#else
#include <sys/endian.h>
#endif

/* These 4 #defines may be needed with older esp-idf environments */
#ifndef _LITTLE_ENDIAN
Expand All @@ -77,33 +81,6 @@
#define __bswap64 __bswap_64
#endif

#elif defined(__APPLE__)

#include <libkern/OSByteOrder.h>

#define htobe16(x) OSSwapHostToBigInt16(x)
#define htole16(x) OSSwapHostToLittleInt16(x)
#define be16toh(x) OSSwapBigToHostInt16(x)
#define le16toh(x) OSSwapLittleToHostInt16(x)

#define htobe32(x) OSSwapHostToBigInt32(x)
#define htole32(x) OSSwapHostToLittleInt32(x)
#define be32toh(x) OSSwapBigToHostInt32(x)
#define le32toh(x) OSSwapLittleToHostInt32(x)

#define htobe64(x) OSSwapHostToBigInt64(x)
#define htole64(x) OSSwapHostToLittleInt64(x)
#define be64toh(x) OSSwapBigToHostInt64(x)
#define le64toh(x) OSSwapLittleToHostInt64(x)

#define __BYTE_ORDER BYTE_ORDER
#define __BIG_ENDIAN BIG_ENDIAN
#define __LITTLE_ENDIAN LITTLE_ENDIAN
#define __PDP_ENDIAN PDP_ENDIAN

#elif defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__) || defined(__OpenBSD__)

#include <sys/endian.h>
#ifndef be16toh
#define be16toh(x) betoh16(x)
#endif
Expand All @@ -128,6 +105,30 @@
#define le64toh(x) letoh64(x)
#endif

#elif defined(__APPLE__)

#include <libkern/OSByteOrder.h>

#define htobe16(x) OSSwapHostToBigInt16(x)
#define htole16(x) OSSwapHostToLittleInt16(x)
#define be16toh(x) OSSwapBigToHostInt16(x)
#define le16toh(x) OSSwapLittleToHostInt16(x)

#define htobe32(x) OSSwapHostToBigInt32(x)
#define htole32(x) OSSwapHostToLittleInt32(x)
#define be32toh(x) OSSwapBigToHostInt32(x)
#define le32toh(x) OSSwapLittleToHostInt32(x)

#define htobe64(x) OSSwapHostToBigInt64(x)
#define htole64(x) OSSwapHostToLittleInt64(x)
#define be64toh(x) OSSwapBigToHostInt64(x)
#define le64toh(x) OSSwapLittleToHostInt64(x)

#define __BYTE_ORDER BYTE_ORDER
#define __BIG_ENDIAN BIG_ENDIAN
#define __LITTLE_ENDIAN LITTLE_ENDIAN
#define __PDP_ENDIAN PDP_ENDIAN

#elif defined(PS3_PPU_PLATFORM)

#define htobe16(x) (x)
Expand Down
8 changes: 0 additions & 8 deletions lib/compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -597,18 +597,10 @@ struct sockaddr_storage {

#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__) || defined(__OpenBSD__)

#ifdef PS4_PLATFORM
#ifndef ENODATA
#define ENODATA 98
#endif
#else
#undef ENODATA
#ifndef ENODATA
#define ENODATA ENOATTR
#endif

#endif

#endif /* PS4_PLATFORM */

#if defined(__SWITCH__) || defined(__3DS__) || defined(__WII__) || defined(__GC__) || defined(__WIIU__) || defined(__NDS__)
Expand Down

0 comments on commit 9d1cc17

Please sign in to comment.