[alsa-devel] [PATCH 1/5] Introduce bswap.h for portable definitions of byte swap macros.
From: Thomas Klausner wiz@NetBSD.org
Signed-off-by: Thomas Klausner wiz@NetBSD.org --- 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
diff --git a/include/Makefile.am b/include/Makefile.am index 8c83c11..31a3f74 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 0000000..68adce3 --- /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 wiz@NetBSD.org + * + * + * 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 diff --git a/src/pcm/pcm_adpcm.c b/src/pcm/pcm_adpcm.c index 1a83c5a..1c88c83 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 <byteswap.h> +#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 db759e3..fa58441 100644 --- a/src/pcm/pcm_alaw.c +++ b/src/pcm/pcm_alaw.c @@ -26,7 +26,7 @@ * */
-#include <byteswap.h> +#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 66d3a47..0dbd5bd 100644 --- a/src/pcm/pcm_copy.c +++ b/src/pcm/pcm_copy.c @@ -26,7 +26,7 @@ * */
-#include <byteswap.h> +#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 9e9d3c3..40c0874 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 <byteswap.h> +#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 9ab6964..92eb072 100644 --- a/src/pcm/pcm_file.c +++ b/src/pcm/pcm_file.c @@ -26,7 +26,7 @@ * */
-#include <byteswap.h> +#include "bswap.h" #include <ctype.h> #include <string.h> #include "pcm_local.h" diff --git a/src/pcm/pcm_iec958.c b/src/pcm/pcm_iec958.c index 38c4ce7..86ac9cf 100644 --- a/src/pcm/pcm_iec958.c +++ b/src/pcm/pcm_iec958.c @@ -26,7 +26,7 @@ * */
-#include <byteswap.h> +#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 2f3e578..22201f8 100644 --- a/src/pcm/pcm_lfloat.c +++ b/src/pcm/pcm_lfloat.c @@ -26,7 +26,7 @@ * */
-#include <byteswap.h> +#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 9a92abd..50df779 100644 --- a/src/pcm/pcm_linear.c +++ b/src/pcm/pcm_linear.c @@ -26,7 +26,7 @@ * */
-#include <byteswap.h> +#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 034f582..1b0ccb4 100644 --- a/src/pcm/pcm_meter.c +++ b/src/pcm/pcm_meter.c @@ -27,7 +27,7 @@ */
-#include <byteswap.h> +#include "bswap.h" #include <time.h> #include <pthread.h> #include <dlfcn.h> diff --git a/src/pcm/pcm_misc.c b/src/pcm/pcm_misc.c index 5870f82..7d2b05d 100644 --- a/src/pcm/pcm_misc.c +++ b/src/pcm/pcm_misc.c @@ -23,7 +23,7 @@ #include <stdlib.h> #include <unistd.h> #include <string.h> -#include <byteswap.h> +#include "bswap.h" #include "pcm_local.h"
diff --git a/src/pcm/pcm_mulaw.c b/src/pcm/pcm_mulaw.c index 011b2a5..15dbdc1 100644 --- a/src/pcm/pcm_mulaw.c +++ b/src/pcm/pcm_mulaw.c @@ -26,7 +26,7 @@ * */
-#include <byteswap.h> +#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 5e63caa..685618e 100644 --- a/src/pcm/pcm_null.c +++ b/src/pcm/pcm_null.c @@ -26,7 +26,7 @@ * */
-#include <byteswap.h> +#include "bswap.h" #include <limits.h> #include "pcm_local.h" #include "pcm_plugin.h" diff --git a/src/pcm/pcm_rate.c b/src/pcm/pcm_rate.c index c76db25..41bddac 100644 --- a/src/pcm/pcm_rate.c +++ b/src/pcm/pcm_rate.c @@ -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" diff --git a/src/pcm/pcm_rate_linear.c b/src/pcm/pcm_rate_linear.c index 7481b38..70399e0 100644 --- a/src/pcm/pcm_rate_linear.c +++ b/src/pcm/pcm_rate_linear.c @@ -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" diff --git a/src/pcm/pcm_route.c b/src/pcm/pcm_route.c index 646517d..3611603 100644 --- a/src/pcm/pcm_route.c +++ b/src/pcm/pcm_route.c @@ -26,7 +26,7 @@ * */
-#include <byteswap.h> +#include "bswap.h" #include <math.h> #include "pcm_local.h" #include "pcm_plugin.h" diff --git a/src/pcm/pcm_softvol.c b/src/pcm/pcm_softvol.c index c6cfd88..802aa4b 100644 --- a/src/pcm/pcm_softvol.c +++ b/src/pcm/pcm_softvol.c @@ -26,7 +26,7 @@ * */
-#include <byteswap.h> +#include "bswap.h" #include <math.h> #include "pcm_local.h" #include "pcm_plugin.h"
From: Thomas Klausner wiz@NetBSD.org
--- include/type_compat.h | 7 +++++++ 1 file changed, 7 insertions(+)
diff --git a/include/type_compat.h b/include/type_compat.h index 9cc209f..0c10aed 100644 --- a/include/type_compat.h +++ b/include/type_compat.h @@ -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
From: Thomas Klausner wiz@NetBSD.org
--- src/timer/timer_hw.c | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/src/timer/timer_hw.c b/src/timer/timer_hw.c index e61b994..ddaebd3 100644 --- a/src/timer/timer_hw.c +++ b/src/timer/timer_hw.c @@ -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;
From: Thomas Klausner wiz@NetBSD.org
--- src/conf.c | 2 +- src/ucm/parser.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/conf.c b/src/conf.c index a4f2a4f..f8b7a66 100644 --- a/src/conf.c +++ b/src/conf.c @@ -3549,7 +3549,7 @@ int snd_config_hook_load(snd_config_t *root, snd_config_t *config, snd_config_t int n;
#ifndef DOC_HIDDEN -#ifdef _GNU_SOURCE +#if defined(_GNU_SOURCE) && !defined(__NetBSD__) && !defined(__FreeBSD__) && !defined(__sun) #define SORTFUNC versionsort #else #define SORTFUNC alphasort diff --git a/src/ucm/parser.c b/src/ucm/parser.c index 9e1cb41..8405bd2 100644 --- a/src/ucm/parser.c +++ b/src/ucm/parser.c @@ -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
From: Thomas Klausner wiz@NetBSD.org
Headers are already included in local.h. --- src/topology/tplg_local.h | 2 -- 1 file changed, 2 deletions(-)
diff --git a/src/topology/tplg_local.h b/src/topology/tplg_local.h index e66d7f4..5d0cb91 100644 --- a/src/topology/tplg_local.h +++ b/src/topology/tplg_local.h @@ -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"
participants (1)
-
Thomas Klausner