mirror of
https://github.com/thepigeongenerator/mcaselector-lite.git
synced 2025-12-17 09:35:46 +01:00
make compat/endian.h use different methods for swapping bytes depending on what is available
This commit is contained in:
@@ -2,11 +2,22 @@
|
||||
// Licensed under the MIT Licence. See LICENSE for details
|
||||
#pragma once
|
||||
|
||||
#include <byteswap.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "../atrb.h"
|
||||
|
||||
#if __has_include(<byteswap.h>)
|
||||
#include <byteswap.h>
|
||||
#elif defined(__GNUC__) || defined(__clang__)
|
||||
#define bswap_16 __builtin_bswap16
|
||||
#define bswap_32 __builtin_bswap32
|
||||
#define bswap_64 __builtin_bswap64
|
||||
#else
|
||||
// TODO: use custom bswap bacros
|
||||
#error WIP, no support
|
||||
#endif
|
||||
|
||||
|
||||
/* little endian */
|
||||
atrb_const static inline uint16_t le16ton(uint16_t); // converts little-endian (LE) encoding to native for a 16 bit integer. (NOOP if native is LE)
|
||||
atrb_const static inline uint32_t le32ton(uint32_t); // converts little-endian (LE) encoding to native for a 32 bit integer. (NOOP if native is LE)
|
||||
|
||||
Reference in New Issue
Block a user