From: Thomas Klausner Date: Thu, 3 Mar 2016 11:16:57 +0000 (+0100) Subject: Introduce bswap.h for portable definitions of byte swap macros. X-Git-Tag: v1.1.1~13 X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=e0d52fdd8a727ed6271826ebd8f7dbab9a3e83ae;p=alsa-lib.git Introduce bswap.h for portable definitions of byte swap macros. Signed-off-by: Thomas Klausner Signed-off-by: Takashi Iwai --- diff --git a/include/Makefile.am b/include/Makefile.am index 8c83c11d..31a3f748 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -59,7 +59,7 @@ alsainclude_HEADERS += alisp.h endif noinst_HEADERS = alsa sys.h search.h list.h aserver.h local.h alsa-symbols.h \ - asoundlib-head.h asoundlib-tail.h type_compat.h + asoundlib-head.h asoundlib-tail.h bswap.h type_compat.h DISTCLEANFILES = stamp-vh version.h alsa asoundlib.h diff --git a/include/bswap.h b/include/bswap.h new file mode 100644 index 00000000..68adce39 --- /dev/null +++ b/include/bswap.h @@ -0,0 +1,39 @@ +/* + * ALSA lib - compatibility header for providing byte swapping macros + * Copyright (c) 2016 by Thomas Klausner + * + * + * This library is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ifndef __BSWAP_H +#define __BSWAP_H + +#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__) +#include +#define bswap_16 bswap16 +#define bswap_32 bswap32 +#define bswap_64 bswap64 +#elif defined (__sun) +#include +#define bswap_16 BSWAP_16 +#define bswap_32 BSWAP_32 +#define bswap_64 BSWAP_64 +#else +#include +#endif + +#endif diff --git a/src/pcm/pcm_adpcm.c b/src/pcm/pcm_adpcm.c index 1a83c5a0..1c88c837 100644 --- a/src/pcm/pcm_adpcm.c +++ b/src/pcm/pcm_adpcm.c @@ -56,7 +56,7 @@ IMA compatibility project proceedings, Vol 2, Issue 2, May 1992. come across a good description of XA yet. */ -#include +#include "bswap.h" #include "pcm_local.h" #include "pcm_plugin.h" diff --git a/src/pcm/pcm_alaw.c b/src/pcm/pcm_alaw.c index db759e3e..fa58441c 100644 --- a/src/pcm/pcm_alaw.c +++ b/src/pcm/pcm_alaw.c @@ -26,7 +26,7 @@ * */ -#include +#include "bswap.h" #include "pcm_local.h" #include "pcm_plugin.h" diff --git a/src/pcm/pcm_copy.c b/src/pcm/pcm_copy.c index 66d3a471..0dbd5bd0 100644 --- a/src/pcm/pcm_copy.c +++ b/src/pcm/pcm_copy.c @@ -26,7 +26,7 @@ * */ -#include +#include "bswap.h" #include "pcm_local.h" #include "pcm_plugin.h" diff --git a/src/pcm/pcm_dmix_generic.c b/src/pcm/pcm_dmix_generic.c index 9e9d3c3c..40c08747 100644 --- a/src/pcm/pcm_dmix_generic.c +++ b/src/pcm/pcm_dmix_generic.c @@ -125,7 +125,7 @@ static void mix_select_callbacks(snd_pcm_direct_t *dmix) (1ULL << SND_PCM_FORMAT_S24_LE) | (1ULL << SND_PCM_FORMAT_S24_3LE) | \ (1ULL << SND_PCM_FORMAT_U8)) -#include +#include "bswap.h" static void generic_mix_areas_16_native(unsigned int size, volatile signed short *dst, diff --git a/src/pcm/pcm_file.c b/src/pcm/pcm_file.c index 9ab6964d..92eb0724 100644 --- a/src/pcm/pcm_file.c +++ b/src/pcm/pcm_file.c @@ -26,7 +26,7 @@ * */ -#include +#include "bswap.h" #include #include #include "pcm_local.h" diff --git a/src/pcm/pcm_iec958.c b/src/pcm/pcm_iec958.c index 38c4ce7e..86ac9cfd 100644 --- a/src/pcm/pcm_iec958.c +++ b/src/pcm/pcm_iec958.c @@ -26,7 +26,7 @@ * */ -#include +#include "bswap.h" #include "pcm_local.h" #include "pcm_plugin.h" diff --git a/src/pcm/pcm_lfloat.c b/src/pcm/pcm_lfloat.c index 2f3e578f..22201f84 100644 --- a/src/pcm/pcm_lfloat.c +++ b/src/pcm/pcm_lfloat.c @@ -26,7 +26,7 @@ * */ -#include +#include "bswap.h" #include "pcm_local.h" #include "pcm_plugin.h" diff --git a/src/pcm/pcm_linear.c b/src/pcm/pcm_linear.c index 9a92abd0..50df7794 100644 --- a/src/pcm/pcm_linear.c +++ b/src/pcm/pcm_linear.c @@ -26,7 +26,7 @@ * */ -#include +#include "bswap.h" #include "pcm_local.h" #include "pcm_plugin.h" diff --git a/src/pcm/pcm_meter.c b/src/pcm/pcm_meter.c index 034f5825..1b0ccb40 100644 --- a/src/pcm/pcm_meter.c +++ b/src/pcm/pcm_meter.c @@ -27,7 +27,7 @@ */ -#include +#include "bswap.h" #include #include #include diff --git a/src/pcm/pcm_misc.c b/src/pcm/pcm_misc.c index 5870f82c..7d2b05db 100644 --- a/src/pcm/pcm_misc.c +++ b/src/pcm/pcm_misc.c @@ -23,7 +23,7 @@ #include #include #include -#include +#include "bswap.h" #include "pcm_local.h" diff --git a/src/pcm/pcm_mulaw.c b/src/pcm/pcm_mulaw.c index 011b2a51..15dbdc1c 100644 --- a/src/pcm/pcm_mulaw.c +++ b/src/pcm/pcm_mulaw.c @@ -26,7 +26,7 @@ * */ -#include +#include "bswap.h" #include "pcm_local.h" #include "pcm_plugin.h" diff --git a/src/pcm/pcm_null.c b/src/pcm/pcm_null.c index 5e63caae..685618e8 100644 --- a/src/pcm/pcm_null.c +++ b/src/pcm/pcm_null.c @@ -26,7 +26,7 @@ * */ -#include +#include "bswap.h" #include #include "pcm_local.h" #include "pcm_plugin.h" diff --git a/src/pcm/pcm_rate.c b/src/pcm/pcm_rate.c index c76db25b..41bddac1 100644 --- a/src/pcm/pcm_rate.c +++ b/src/pcm/pcm_rate.c @@ -28,7 +28,7 @@ * */ #include -#include +#include "bswap.h" #include "pcm_local.h" #include "pcm_plugin.h" #include "pcm_rate.h" diff --git a/src/pcm/pcm_rate_linear.c b/src/pcm/pcm_rate_linear.c index 7481b389..70399e0d 100644 --- a/src/pcm/pcm_rate_linear.c +++ b/src/pcm/pcm_rate_linear.c @@ -21,7 +21,7 @@ */ #include -#include +#include "bswap.h" #include "pcm_local.h" #include "pcm_plugin.h" #include "pcm_rate.h" diff --git a/src/pcm/pcm_route.c b/src/pcm/pcm_route.c index 646517d2..36116030 100644 --- a/src/pcm/pcm_route.c +++ b/src/pcm/pcm_route.c @@ -26,7 +26,7 @@ * */ -#include +#include "bswap.h" #include #include "pcm_local.h" #include "pcm_plugin.h" diff --git a/src/pcm/pcm_softvol.c b/src/pcm/pcm_softvol.c index c6cfd889..802aa4b7 100644 --- a/src/pcm/pcm_softvol.c +++ b/src/pcm/pcm_softvol.c @@ -26,7 +26,7 @@ * */ -#include +#include "bswap.h" #include #include "pcm_local.h" #include "pcm_plugin.h"