detect endianness with cmake
This commit is contained in:
parent
6c2226a6d7
commit
f0c8c68592
4 changed files with 28 additions and 24 deletions
|
@ -104,6 +104,15 @@ set(TEST_CFLAGS "${LIB_CFLAGS} -fprofile-arcs -ftest-coverage")
|
|||
set(TEST_LDFLAGS "-fprofile-arcs -ftest-coverage")
|
||||
set(TEST_INCLUDES "${CMAKE_SOURCE_DIR}/test")
|
||||
|
||||
include(TestBigEndian)
|
||||
test_big_endian(IS_BIG_ENDIAN)
|
||||
if(IS_BIG_ENDIAN)
|
||||
set(SOUNDIO_OS_BIG_ENDIAN true)
|
||||
set(SOUNDIO_OS_LITTLE_ENDIAN false)
|
||||
else()
|
||||
set(SOUNDIO_OS_BIG_ENDIAN false)
|
||||
set(SOUNDIO_OS_LITTLE_ENDIAN true)
|
||||
endif()
|
||||
configure_file (
|
||||
"${CMAKE_SOURCE_DIR}/src/config.h.in"
|
||||
${CONFIGURE_OUT_FILE}
|
||||
|
|
|
@ -190,6 +190,13 @@ static void test_fmt_mask(SoundIoDevice *device, const snd_pcm_format_mask_t *fm
|
|||
}
|
||||
}
|
||||
|
||||
// TODO: look at http://www.alsa-project.org/alsa-doc/alsa-lib/_2test_2pcm_8c-example.html#a27
|
||||
// deterimine what do do about:
|
||||
// * hw buffer size
|
||||
// * hw period time
|
||||
// * sw start threshold
|
||||
// * sw avail min
|
||||
|
||||
static int probe_device(SoundIoDevice *device, snd_pcm_chmap_query_t **maps) {
|
||||
int err;
|
||||
snd_pcm_t *handle;
|
||||
|
|
|
@ -1,3 +1,10 @@
|
|||
/*
|
||||
* Copyright (c) 2015 Andrew Kelley
|
||||
*
|
||||
* This file is part of libsoundio, which is MIT licensed.
|
||||
* See http://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#ifndef SOUNDIO_CONFIG_H
|
||||
#define SOUNDIO_CONFIG_H
|
||||
|
||||
|
@ -6,6 +13,9 @@
|
|||
#define SOUNDIO_VERSION_PATCH @LIBSOUNDIO_VERSION_PATCH@
|
||||
#define SOUNDIO_VERSION_STRING "@LIBSOUNDIO_VERSION@"
|
||||
|
||||
#cmakedefine SOUNDIO_OS_BIG_ENDIAN @SOUNDIO_OS_BIG_ENDIAN@
|
||||
#cmakedefine SOUNDIO_OS_LITTLE_ENDIAN @SOUNDIO_OS_LITTLE_ENDIAN@
|
||||
|
||||
#cmakedefine SOUNDIO_HAVE_ALSA
|
||||
#cmakedefine SOUNDIO_HAVE_PULSEAUDIO
|
||||
|
||||
|
|
|
@ -11,30 +11,6 @@
|
|||
#include "config.h"
|
||||
#include <stdbool.h>
|
||||
|
||||
#if (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) || \
|
||||
defined(__BIG_ENDIAN__) || \
|
||||
defined(__ARMEB__) || \
|
||||
defined(__THUMBEB__) || \
|
||||
defined(__AARCH64EB__) || \
|
||||
defined(_MIBSEB) || defined(__MIBSEB) || defined(__MIBSEB__)
|
||||
|
||||
#define SOUNDIO_OS_BIG_ENDIAN
|
||||
|
||||
#elif (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) || \
|
||||
defined(__LITTLE_ENDIAN__) || \
|
||||
defined(__ARMEL__) || \
|
||||
defined(__THUMBEL__) || \
|
||||
defined(__AARCH64EL__) || \
|
||||
defined(_MIPSEL) || defined(__MIPSEL) || defined(__MIPSEL__) || \
|
||||
defined(_WIN32)
|
||||
|
||||
#define SOUNDIO_OS_LITTLE_ENDIAN
|
||||
|
||||
#else
|
||||
#error unknown byte order
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
|
@ -180,6 +156,8 @@ enum SoundIoFormat {
|
|||
#define SoundIoFormatU32NE SoundIoFormatU32LE
|
||||
#define SoundIoFormatFloat32NE SoundIoFormatFloat32LE
|
||||
#define SoundIoFormatFloat64NE SoundIoFormatFloat64LE
|
||||
#else
|
||||
#error unknown byte order
|
||||
#endif
|
||||
|
||||
struct SoundIoDevice {
|
||||
|
|
Loading…
Reference in a new issue