mirror of
https://github.com/YosysHQ/yosys
synced 2025-04-13 04:28:18 +00:00
Cover __APPLE__ too for little to big endian
This commit is contained in:
parent
a632799d5b
commit
7876b5b8be
|
@ -18,6 +18,15 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// https://stackoverflow.com/a/46137633
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#include <stdlib.h>
|
||||||
|
#define __builtin_bswap32 _byteswap_ulong
|
||||||
|
#elif defined(__APPLE__)
|
||||||
|
#include <libkern/OSByteOrder.h>
|
||||||
|
#define __builtin_bswap32 OSSwapInt32
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "kernel/yosys.h"
|
#include "kernel/yosys.h"
|
||||||
#include "kernel/sigtools.h"
|
#include "kernel/sigtools.h"
|
||||||
#include "kernel/utils.h"
|
#include "kernel/utils.h"
|
||||||
|
@ -27,11 +36,7 @@ PRIVATE_NAMESPACE_BEGIN
|
||||||
|
|
||||||
inline int32_t to_big_endian(int32_t i32) {
|
inline int32_t to_big_endian(int32_t i32) {
|
||||||
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
||||||
#ifdef _WIN32
|
|
||||||
return _byteswap_ulong(i32);
|
|
||||||
#else
|
|
||||||
return __builtin_bswap32(i32);
|
return __builtin_bswap32(i32);
|
||||||
#endif
|
|
||||||
#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
||||||
return i32;
|
return i32;
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -24,7 +24,14 @@
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <libgen.h>
|
#include <libgen.h>
|
||||||
|
#endif
|
||||||
|
// https://stackoverflow.com/a/46137633
|
||||||
|
#ifdef _MSC_VER
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#define __builtin_bswap32 _byteswap_ulong
|
||||||
|
#elif defined(__APPLE__)
|
||||||
|
#include <libkern/OSByteOrder.h>
|
||||||
|
#define __builtin_bswap32 OSSwapInt32
|
||||||
#endif
|
#endif
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
|
||||||
|
@ -37,11 +44,7 @@ YOSYS_NAMESPACE_BEGIN
|
||||||
|
|
||||||
inline int32_t from_big_endian(int32_t i32) {
|
inline int32_t from_big_endian(int32_t i32) {
|
||||||
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
||||||
#ifdef _WIN32
|
|
||||||
return _byteswap_ulong(i32);
|
|
||||||
#else
|
|
||||||
return __builtin_bswap32(i32);
|
return __builtin_bswap32(i32);
|
||||||
#endif
|
|
||||||
#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
||||||
return i32;
|
return i32;
|
||||||
#else
|
#else
|
||||||
|
|
Loading…
Reference in a new issue