mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-14 06:59:57 -05:00
Add spa/utils/endian.h
This provides access to GNU C library-style endian and byteswap functions. Windows doesn't provide pre-processor defines for endianness, but all current Windows architectures (X32, X64, ARM) are little-endian.
This commit is contained in:
parent
a97e8b6d1f
commit
5d7624001d
10 changed files with 35 additions and 30 deletions
|
|
@ -9,9 +9,7 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if !defined(__FreeBSD__) && !defined(__MidnightBSD__)
|
||||
#include <endian.h>
|
||||
#endif
|
||||
#include <spa/utils/endian.h>
|
||||
|
||||
/**
|
||||
* \addtogroup spa_param
|
||||
|
|
|
|||
|
|
@ -11,9 +11,7 @@ extern "C" {
|
|||
|
||||
#include <stdint.h>
|
||||
|
||||
#if !defined(__FreeBSD__) && !defined(__MidnightBSD__)
|
||||
#include <endian.h>
|
||||
#endif
|
||||
#include <spa/utils/endian.h>
|
||||
|
||||
/**
|
||||
* \addtogroup spa_param
|
||||
|
|
|
|||
26
spa/include/spa/utils/endian.h
Normal file
26
spa/include/spa/utils/endian.h
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
/* Spa */
|
||||
/* SPDX-FileCopyrightText: Copyright © 2019 Wim Taymans */
|
||||
/* SPDX-License-Identifier: MIT */
|
||||
|
||||
#ifndef SPA_ENDIAN_H
|
||||
#define SPA_ENDIAN_H
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__MidnightBSD__)
|
||||
#include <sys/endian.h>
|
||||
#define bswap_16 bswap16
|
||||
#define bswap_32 bswap32
|
||||
#define bswap_64 bswap64
|
||||
#elif defined(_MSC_VER) && defined(_WIN32)
|
||||
#include <stdlib.h>
|
||||
#define __LITTLE_ENDIAN 1234
|
||||
#define __BIG_ENDIAN 4321
|
||||
#define __BYTE_ORDER __LITTLE_ENDIAN
|
||||
#define bswap_16 _byteswap_ushort
|
||||
#define bswap_32 _byteswap_ulong
|
||||
#define bswap_64 _byteswap_uint64
|
||||
#else
|
||||
#include <endian.h>
|
||||
#include <byteswap.h>
|
||||
#endif
|
||||
|
||||
#endif /* SPA_ENDIAN_H */
|
||||
Loading…
Add table
Add a link
Reference in a new issue