Use <endian.h>
Change-Id: I1eb73afb0580064e5abc592f8235cc882e5dd6be
diff --git a/audio_utils/channels.c b/audio_utils/channels.c
index 0a80ede..16dbd2a 100644
--- a/audio_utils/channels.c
+++ b/audio_utils/channels.c
@@ -14,6 +14,7 @@
* limitations under the License.
*/
+#include <endian.h>
#include <string.h>
#include <audio_utils/channels.h>
#include "private/private.h"
@@ -33,7 +34,7 @@
* Converts a uint8x3_t into an int32_t
*/
inline int32_t uint8x3_to_int32(uint8x3_t val) {
-#ifdef HAVE_BIG_ENDIAN
+#if _BYTE_ORDER == _BIG_ENDIAN
int32_t temp = (val.c[0] << 24 | val.c[1] << 16 | val.c[2] << 8) >> 8;
#else
int32_t temp = (val.c[2] << 24 | val.c[1] << 16 | val.c[0] << 8) >> 8;
@@ -46,7 +47,7 @@
*/
inline uint8x3_t int32_to_uint8x3(int32_t in) {
uint8x3_t out;
-#ifdef HAVE_BIG_ENDIAN
+#if _BYTE_ORDER == _BIG_ENDIAN
out.c[2] = in;
out.c[1] = in >> 8;
out.c[0] = in >> 16;
diff --git a/audio_utils/primitives.c b/audio_utils/primitives.c
index 254f3af..664c095 100644
--- a/audio_utils/primitives.c
+++ b/audio_utils/primitives.c
@@ -14,6 +14,7 @@
* limitations under the License.
*/
+#include <endian.h>
#include <cutils/bitops.h> /* for popcount() */
#include <audio_utils/primitives.h>
#include "private/private.h"
@@ -101,7 +102,7 @@
void memcpy_to_i16_from_p24(int16_t *dst, const uint8_t *src, size_t count)
{
while (count--) {
-#ifdef HAVE_BIG_ENDIAN
+#if _BYTE_ORDER == _BIG_ENDIAN
*dst++ = src[1] | (src[0] << 8);
#else
*dst++ = src[1] | (src[2] << 8);
@@ -113,7 +114,7 @@
void memcpy_to_i32_from_p24(int32_t *dst, const uint8_t *src, size_t count)
{
while (count--) {
-#ifdef HAVE_BIG_ENDIAN
+#if _BYTE_ORDER == _BIG_ENDIAN
*dst++ = (src[2] << 8) | (src[1] << 16) | (src[0] << 24);
#else
*dst++ = (src[0] << 8) | (src[1] << 16) | (src[2] << 24);
@@ -125,7 +126,7 @@
void memcpy_to_p24_from_i16(uint8_t *dst, const int16_t *src, size_t count)
{
while (count--) {
-#ifdef HAVE_BIG_ENDIAN
+#if _BYTE_ORDER == _BIG_ENDIAN
*dst++ = *src >> 8;
*dst++ = *src++;
*dst++ = 0;
@@ -142,7 +143,7 @@
while (count--) {
int32_t ival = clamp24_from_float(*src++);
-#ifdef HAVE_BIG_ENDIAN
+#if _BYTE_ORDER == _BIG_ENDIAN
*dst++ = ival >> 16;
*dst++ = ival >> 8;
*dst++ = ival;
@@ -159,7 +160,7 @@
while (count--) {
int32_t ival = clamp24_from_q8_23(*src++);
-#ifdef HAVE_BIG_ENDIAN
+#if _BYTE_ORDER == _BIG_ENDIAN
*dst++ = ival >> 16;
*dst++ = ival >> 8;
*dst++ = ival;
@@ -176,7 +177,7 @@
while (count--) {
int32_t ival = *src++ >> 8;
-#ifdef HAVE_BIG_ENDIAN
+#if _BYTE_ORDER == _BIG_ENDIAN
*dst++ = ival >> 16;
*dst++ = ival >> 8;
*dst++ = ival;
@@ -205,7 +206,7 @@
void memcpy_to_q8_23_from_p24(int32_t *dst, const uint8_t *src, size_t count)
{
while (count--) {
-#ifdef HAVE_BIG_ENDIAN
+#if _BYTE_ORDER == _BIG_ENDIAN
*dst++ = (int8_t)src[0] << 16 | src[1] << 8 | src[2];
#else
*dst++ = (int8_t)src[2] << 16 | src[1] << 8 | src[0];