Introduce bswap.h for portable definitions of byte swap macros.
PATCH 1/5 Introduce bswap.h for portable definitions of byte swap macros.
From: Thomas Klausner <[email protected]>
Signed-off-by Thomas Klausner <[email protected]>
--- include/Makefile.am | 2 +- include/bswap.h | 39 +++++++++++++++++++++++++++++++++++++++ src/pcm/pcm_adpcm.c | 2 +- src/pcm/pcm_alaw.c | 2 +- src/pcm/pcm_copy.c | 2 +- src/pcm/pcm_dmix_generic.c | 2 +- src/pcm/pcm_file.c | 2 +- src/pcm/pcm_iec958.c | 2 +- src/pcm/pcm_lfloat.c | 2 +- src/pcm/pcm_linear.c | 2 +- src/pcm/pcm_meter.c | 2 +- src/pcm/pcm_misc.c | 2 +- src/pcm/pcm_mulaw.c | 2 +- src/pcm/pcm_null.c | 2 +- src/pcm/pcm_rate.c | 2 +- src/pcm/pcm_rate_linear.c | 2 +- src/pcm/pcm_route.c | 2 +- src/pcm/pcm_softvol.c | 2 +- 18 files changed, 56 insertions(+), 17 deletions(-) create mode 100644 include/bswap.h
include/Makefile.am +1 -1
@@ -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
include/bswap.h new file +39 -0
@@ -0,0 +1,39 @@ +/* +* ALSA lib - compatibility header for providing byte swapping macros +* Copyright (c) 2016 by Thomas Klausner <[email protected]> +* +* +* 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 <sys/endian.h> +#define bswap_16 bswap16 +#define bswap_32 bswap32 +#define bswap_64 bswap64 +#elif defined (__sun) +#include <sys/byteorder.h> +#define bswap_16 BSWAP_16 +#define bswap_32 BSWAP_32 +#define bswap_64 BSWAP_64 +#else +#include <byteswap.h> +#endif + +#endif
src/pcm/pcm_adpcm.c +1 -1
@@ -56,7 +56,7 @@ IMA compatibility project proceedings, Vol 2, Issue 2, May 1992.come across a good description of XA yet. */ -#include <byteswap.h> +#include "bswap.h" #include "pcm_local.h" #include "pcm_plugin.h"
src/pcm/pcm_alaw.c +1 -1
@@ -26,7 +26,7 @@* */ -#include <byteswap.h> +#include "bswap.h" #include "pcm_local.h" #include "pcm_plugin.h"
src/pcm/pcm_copy.c +1 -1
@@ -26,7 +26,7 @@* */ -#include <byteswap.h> +#include "bswap.h" #include "pcm_local.h" #include "pcm_plugin.h"
src/pcm/pcm_dmix_generic.c +1 -1
@@ -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 <byteswap.h> +#include "bswap.h" static void generic_mix_areas_16_native(unsigned int size, volatile signed short *dst,
src/pcm/pcm_file.c +1 -1
@@ -26,7 +26,7 @@* */ -#include <byteswap.h> +#include "bswap.h" #include <ctype.h> #include <string.h> #include "pcm_local.h"
src/pcm/pcm_iec958.c +1 -1
@@ -26,7 +26,7 @@* */ -#include <byteswap.h> +#include "bswap.h" #include "pcm_local.h" #include "pcm_plugin.h"
src/pcm/pcm_lfloat.c +1 -1
@@ -26,7 +26,7 @@* */ -#include <byteswap.h> +#include "bswap.h" #include "pcm_local.h" #include "pcm_plugin.h"
src/pcm/pcm_linear.c +1 -1
@@ -26,7 +26,7 @@* */ -#include <byteswap.h> +#include "bswap.h" #include "pcm_local.h" #include "pcm_plugin.h"
src/pcm/pcm_meter.c +1 -1
@@ -27,7 +27,7 @@*/ -#include <byteswap.h> +#include "bswap.h" #include <time.h> #include <pthread.h> #include <dlfcn.h>
src/pcm/pcm_misc.c +1 -1
@@ -23,7 +23,7 @@#include <stdlib.h> #include <unistd.h> #include <string.h> -#include <byteswap.h> +#include "bswap.h" #include "pcm_local.h"
src/pcm/pcm_mulaw.c +1 -1
@@ -26,7 +26,7 @@* */ -#include <byteswap.h> +#include "bswap.h" #include "pcm_local.h" #include "pcm_plugin.h"
src/pcm/pcm_null.c +1 -1
@@ -26,7 +26,7 @@* */ -#include <byteswap.h> +#include "bswap.h" #include <limits.h> #include "pcm_local.h" #include "pcm_plugin.h"
src/pcm/pcm_rate.c +1 -1
@@ -28,7 +28,7 @@* */ #include <inttypes.h> -#include <byteswap.h> +#include "bswap.h" #include "pcm_local.h" #include "pcm_plugin.h" #include "pcm_rate.h"
src/pcm/pcm_rate_linear.c +1 -1
@@ -21,7 +21,7 @@*/ #include <inttypes.h> -#include <byteswap.h> +#include "bswap.h" #include "pcm_local.h" #include "pcm_plugin.h" #include "pcm_rate.h"
src/pcm/pcm_route.c +1 -1
@@ -26,7 +26,7 @@* */ -#include <byteswap.h> +#include "bswap.h" #include <math.h> #include "pcm_local.h" #include "pcm_plugin.h"
src/pcm/pcm_softvol.c +1 -1
@@ -26,7 +26,7 @@* */ -#include <byteswap.h> +#include "bswap.h" #include <math.h> #include "pcm_local.h" #include "pcm_plugin.h"
Signature · 1 line
2.7.1
PATCH 2/5 Add more compatibility defines.
From: Thomas Klausner <[email protected]>
--- include/type_compat.h | 7 +++++++ 1 file changed, 7 insertions(+)
include/type_compat.h +7 -0
@@ -25,6 +25,9 @@#ifndef EBADFD #define EBADFD EBADF#endif +#ifndef ESTRPIPE +#define ESTRPIPE EPIPE +#endif #ifndef __u16#define __u16 uint16_t
@@ -63,4 +66,8 @@#define __kernel_off_t off_t#endif +#ifndef __bitwise +#define __bitwise +#endif +#endif
Signature · 1 line
2.7.1
PATCH 3/5 Only use F_SETSIG fcntl where it exists.
In reply to Thomas KlausnerFrom: Thomas Klausner <[email protected]>
--- src/timer/timer_hw.c | 2 ++ 1 file changed, 2 insertions(+)
src/timer/timer_hw.c +2 -0
@@ -85,10 +85,12 @@ static int snd_timer_hw_async(snd_timer_t *timer, int sig, pid_t pid) }if (sig <0 )return 0 ; +#ifdef F_SETSIG if (fcntl (fd,F_SETSIG , (long )sig) <0 ) {SYSERR ("F_SETSIG failed" );return -errno; } +#endif if (fcntl (fd,F_SETOWN , (long )pid) <0 ) {SYSERR ("F_SETOWN failed" );return -errno;
Signature · 1 line
2.7.1
PATCH 4/5 Use alphasort where versionsort is not available.
In reply to Thomas KlausnerFrom: Thomas Klausner <[email protected]>
--- src/conf.c | 2 +- src/ucm/parser.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
src/conf.c +1 -1
@@ -3549,7 +3549,7 @@ int snd_config_hook_load(snd_config_t *root, snd_config_t *config, snd_config_tint n;#ifndef DOC_HIDDEN -#ifdef _GNU_SOURCE +#if defined(_GNU_SOURCE) && !defined(__NetBSD__) && !defined(__FreeBSD__) && !defined(__sun)#define SORTFUNC versionsort#else #define SORTFUNC alphasort
src/ucm/parser.c +1 -1
@@ -1264,7 +1264,7 @@ int uc_mgr_scan_master_configs(const char **_list[]) "%s", env ? env : ALSA_USE_CASE_DIR); filename[MAX_FILE -1 ] ='\0' ; -#ifdef _GNU_SOURCE +#if defined(_GNU_SOURCE) && !defined(__NetBSD__) && !defined(__FreeBSD__) && !defined(__sun)#define SORTFUNC versionsort#else #define SORTFUNC alphasort
Signature · 1 line
2.7.1
PATCH 5/5 Remove unnecessary includes.
In reply to Thomas KlausnerFrom: Thomas Klausner <[email protected]>
Headers are already included in local.h.
--- src/topology/tplg_local.h | 2 -- 1 file changed, 2 deletions(-)
src/topology/tplg_local.h +0 -2
@@ -13,8 +13,6 @@#include <limits.h> #include <stdint.h> #include <stdbool.h> -#include <endian.h> -#include <linux/types.h> #include "local.h" #include "list.h"
Signature · 1 line
2.7.1