Skip to contentSkip to conversation

Introduce bswap.h for portable definitions of byte swap macros.

PATCH New Thomas Klausner 1 participant 5 messages Mar 3, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/5 Introduce bswap.h for portable definitions of byte swap macros.

From: 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
index 8c83c11..31a3f74 100644
@@ -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
new file mode 100644
index 0000000..68adce3
@@ -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
index 1a83c5a..1c88c83 100644
@@ -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
index db759e3..fa58441 100644
@@ -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
index 66d3a47..0dbd5bd 100644
@@ -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
index 9e9d3c3..40c0874 100644
@@ -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
index 9ab6964..92eb072 100644
@@ -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
index 38c4ce7..86ac9cf 100644
@@ -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
index 2f3e578..22201f8 100644
@@ -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
index 9a92abd..50df779 100644
@@ -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
index 034f582..1b0ccb4 100644
@@ -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
index 5870f82..7d2b05d 100644
@@ -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
index 011b2a5..15dbdc1 100644
@@ -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
index 5e63caa..685618e 100644
@@ -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
index c76db25..41bddac 100644
@@ -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
index 7481b38..70399e0 100644
@@ -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
index 646517d..3611603 100644
@@ -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
index c6cfd88..802aa4b 100644
@@ -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
#1 lore raw

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
index 9cc209f..0c10aed 100644
@@ -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
#2 lore raw

PATCH 3/5 Only use F_SETSIG fcntl where it exists.

In reply to Thomas Klausner

From: Thomas Klausner <[email protected]>

---
 src/timer/timer_hw.c | 2 ++
 1 file changed, 2 insertions(+)
src/timer/timer_hw.c +2 -0
index e61b994..ddaebd3 100644
@@ -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
#3 lore raw

PATCH 4/5 Use alphasort where versionsort is not available.

In reply to Thomas Klausner

From: 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
index a4f2a4f..f8b7a66 100644
@@ -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
src/ucm/parser.c +1 -1
index 9e1cb41..8405bd2 100644
@@ -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
#4 lore raw

PATCH 5/5 Remove unnecessary includes.

In reply to Thomas Klausner

From: 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
index e66d7f4..5d0cb91 100644
@@ -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