Skip to contentSkip to conversation

alsa on non-linux

DISCUSSION Applied Patrick Welche 3 participants 15 messages Jan 10, 2014 – Feb 26, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

I am currently successfully running alsa-lib 1.0.22 with oss plugins on a non-linux box. The advantage is that programs written to use libasound work.

I just tried to update alsa-lib, and see that now alsa-lib directly includes headers like linux/types.h, and all protection, such as

  #if defined(LINUX) || defined(__LINUX__) || defined(__linux__)

has been removed. This means that compilation on non-linux is essentially impossible.

Is it that there is now a different way of obtaining that alsa lib front end / oss back end layer?

Cheers,

Patrick

#1 lore raw

At Fri, 10 Jan 2014 15:37:00 +0000,

Quoted 8 lines · Patrick Welche

I am currently successfully running alsa-lib 1.0.22 with oss plugins on a non-linux box. The advantage is that programs written to use libasound work.

I just tried to update alsa-lib, and see that now alsa-lib directly includes headers like linux/types.h, and all protection, such as

Quoted 7 lines
  #if defined(LINUX) || defined(__LINUX__) || defined(__linux__)

has been removed. This means that compilation on non-linux is essentially impossible.

Is it that there is now a different way of obtaining that alsa lib front end / oss back end layer?

Feel free to submit a fix patch :)

The inclusions of linux/*.h are mostly due to laziness. If a patch is confirmed to work on both Linux glibc and others, we'll happily take that patch.

Takashi

#2 lore raw
Quoted 15 lines · Takashi Iwai

At Fri, 10 Jan 2014 15:37:00 +0000,

Quoted 13 lines · Patrick Welche

I am currently successfully running alsa-lib 1.0.22 with oss plugins on a non-linux box. The advantage is that programs written to use libasound work.

I just tried to update alsa-lib, and see that now alsa-lib directly includes headers like linux/types.h, and all protection, such as

  #if defined(LINUX) || defined(__LINUX__) || defined(__linux__)

has been removed. This means that compilation on non-linux is essentially impossible.

Quoted 8 lines
Quoted 2 lines

Is it that there is now a different way of obtaining that alsa lib front end / oss back end layer?

Feel free to submit a fix patch :)

The inclusions of linux/*.h are mostly due to laziness. If a patch is confirmed to work on both Linux glibc and others, we'll happily take that patch.

I started out, writing the attached patch in November, but then it looked as though the boundaries of application library interface and linux sound chip driver had become so blurred that I thought that a decision had been taken to bin all OSes bar linux, hence the question. Can you give me a hint on how you think it is supposed to work? (Which bits you know are meant to be linux only, as they are the actual drivers, which bits you think should be OS agnositic...)

Cheers,

Patrick

Quoted 1 line

From c60287a8c5d3175b6df07757241cb59f3b94edb7 Mon Sep 17 00:00:00 2001

From: Patrick Welche <[email protected]>
Date: Tue, 12 Nov 2013 14:25:05 +0000
Subject: [PATCH] Portability fix: Use SND_LITTLE_ENDIAN / SND_BIG_ENDIAN
instead of endian.h

The header file which defines __BYTE_ORDER varies wildly between OSes, so give autoconf the job of detecting endianness. Use the answer by defining SND_LITTLE_ENDIAN / SND_BIG_ENDIAN and using them. (This may require teaching alsa-utilities expecting asoundlib.h to include endian.h for them to use SND_LITTLE_ENDIAN instead.)

---
 configure.in             | 7 ++++++-
 include/asoundlib-head.h | 1 -
 include/local.h          | 9 +++------
 src/pcm/pcm_file.c       | 3 +--
 4 files changed, 10 insertions(+), 10 deletions(-)
configure.in +6 -1
index 35fd89f..679decd 100644
@@ -61,6 +61,7 @@ dnl Checks for typedefs, structures, and compiler characteristics.
 AC_C_CONST
 AC_C_INLINE
 AC_HEADER_TIME
+AC_C_BIGENDIAN
 
 dnl Checks for library functions.
 AC_PROG_GCC_TRADITIONAL
@@ -685,5 +686,9 @@ test "$build_seq" = "yes" && echo "#include <alsa/seq_event.h>" >> include/asoun
 test "$build_seq" = "yes" && echo "#include <alsa/seq.h>" >> include/asoundlib.h
 test "$build_seq" = "yes" && echo "#include <alsa/seqmid.h>" >> include/asoundlib.h
 test "$build_seq" = "yes" && echo "#include <alsa/seq_midi_event.h>" >> include/asoundlib.h
+echo "" >> include/asoundlib.h
+test "$ac_cv_c_bigendian" = "yes" && echo "#define SND_BIG_ENDIAN" >> include/asoundlib.h
+test "$ac_cv_c_bigendian" = "yes" && echo "#define SNDRV_BIG_ENDIAN" >> include/asoundlib.h
+test "$ac_cv_c_bigendian" = "no" && echo "#define SND_LITTLE_ENDIAN" >> include/asoundlib.h
+test "$ac_cv_c_bigendian" = "no" && echo "#define SNDRV_LITTLE_ENDIAN" >> include/asoundlib.h
 cat "$srcdir"/include/asoundlib-tail.h >> include/asoundlib.h
-
include/asoundlib-head.h +0 -1
index 71b5c29..31408a4 100644
@@ -35,7 +35,6 @@
 #include <string.h>
 #include <fcntl.h>
 #include <assert.h>
-#include <endian.h>
 #include <sys/poll.h>
 #include <errno.h>
 #include <stdarg.h>
include/local.h +3 -6
index 9464efa..1e7c0dc 100644
@@ -28,7 +28,6 @@
 #include <string.h>
 #include <fcntl.h>
 #include <assert.h>
-#include <endian.h>
 #include <stdarg.h>
 #include <sys/poll.h>
 #include <sys/types.h>
@@ -46,14 +45,12 @@
 #define RTLD_NOW	0
 #endif
 
-#if __BYTE_ORDER == __LITTLE_ENDIAN
-#define SND_LITTLE_ENDIAN
-#define SNDRV_LITTLE_ENDIAN
-#elif __BYTE_ORDER == __BIG_ENDIAN
+#ifdef WORDS_BIGENDIAN
 #define SND_BIG_ENDIAN
 #define SNDRV_BIG_ENDIAN
 #else
-#error "Unsupported endian..."
+#define SND_LITTLE_ENDIAN
+#define SNDRV_LITTLE_ENDIAN
 #endif
 
 #define _snd_config_iterator list_head
src/pcm/pcm_file.c +1 -2
index 7123025..7ee5c37 100644
@@ -26,7 +26,6 @@
  *
  */
   
-#include <endian.h>
 #include <byteswap.h>
 #include <ctype.h>
 #include <string.h>
@@ -90,7 +89,7 @@ typedef struct {
 	size_t filelen;
 } snd_pcm_file_t;
 
-#if __BYTE_ORDER == __LITTLE_ENDIAN
+#ifdef SND_LITTLE_ENDIAN
 #define TO_LE32(x)	(x)
 #define TO_LE16(x)	(x)
 #else
Signature · 1 line
1.8.5.2
#3 lore raw

At Tue, 14 Jan 2014 10:17:09 +0000,

Quoted 26 lines · Patrick Welche
Quoted 15 lines · Takashi Iwai

At Fri, 10 Jan 2014 15:37:00 +0000,

Quoted 13 lines · Patrick Welche

I am currently successfully running alsa-lib 1.0.22 with oss plugins on a non-linux box. The advantage is that programs written to use libasound work.

I just tried to update alsa-lib, and see that now alsa-lib directly includes headers like linux/types.h, and all protection, such as

  #if defined(LINUX) || defined(__LINUX__) || defined(__linux__)

has been removed. This means that compilation on non-linux is essentially impossible.

Quoted 8 lines
Quoted 2 lines

Is it that there is now a different way of obtaining that alsa lib front end / oss back end layer?

Feel free to submit a fix patch :)

The inclusions of linux/*.h are mostly due to laziness. If a patch is confirmed to work on both Linux glibc and others, we'll happily take that patch.

Quoted 7 lines

I started out, writing the attached patch in November, but then it looked as though the boundaries of application library interface and linux sound chip driver had become so blurred that I thought that a decision had been taken to bin all OSes bar linux, hence the question. Can you give me a hint on how you think it is supposed to work? (Which bits you know are meant to be linux only, as they are the actual drivers, which bits you think should be OS agnositic...)

The Linux-specific part is only the type definitions. There are a few Linux-kernel specific types and modifiers like __kernel_off_t or __bitwise, which are provided in linux/types.h. This is the only reason of linux/types.h inclusion. The inclusion of linux/ioct.h. can be well replaced with sys/ioctl.h, I guess.

BTW, about your patch: I don't think it's good to embed the endianness in asoundlib.h. It makes the header file appearing differently, depending on the architecture, which is rather confusing.

Takashi

#4 lore raw
Quoted 3 lines · Takashi Iwai

BTW, about your patch: I don't think it's good to embed the endianness in asoundlib.h. It makes the header file appearing differently, depending on the architecture, which is rather confusing.

Is this more what you have in mind? (Less portable than autoconf, but not set at configure time.)

The four files which included endian.h were:

- include/asoundlib-head.h
- include/local.h
- include/sound/type_compat.h
- src/pcm/pcm_file.c

The endian.h line(s) in asoundlib.h is now generated by configure.

local.h includes the appropriate endian.h vs sys/endian.h file & defines the relevant macros.

type_compat.h doesn't seem to be used anywhere? So I left it alone.

pcm_file.c includes pcm_local.h which includes local.h, so I removed the #include <endian.h>

(Still far from being able to compile alsa-lib, but it's a start...)

Cheers,

Patrick

Quoted 1 line

From 5885d2e79dfd8f788177a95c70967d9a3c9a2cb6 Mon Sep 17 00:00:00 2001

From: Patrick Welche <[email protected]>
Date: Fri, 21 Feb 2014 01:18:01 +0000
Subject: [PATCH] Portability fix: look for sys/endian.h as well as endian.h

- define __BYTE_ORDER and friends.
- adjust asoundlib.h accordingly.

---
 configure.in             | 19 +++++++++++++++++--
 include/asoundlib-head.h |  1 -
 include/local.h          | 18 +++++++++++++++++-
 src/pcm/pcm_file.c       |  1 -
 4 files changed, 34 insertions(+), 5 deletions(-)
configure.in +17 -2
index bb56eb6..60d4ae1 100644
@@ -309,8 +309,8 @@ fi
 
 AC_SUBST(ALSA_DEPLIBS)
 
-dnl Check for wordexp.h
-AC_CHECK_HEADERS([wordexp.h])
+dnl Check for headers
+AC_CHECK_HEADERS([wordexp.h endian.h sys/endian.h])
 
 dnl Check for resmgr support...
 AC_MSG_CHECKING(for resmgr support)
@@ -660,6 +660,21 @@ AC_OUTPUT(Makefile doc/Makefile doc/pictures/Makefile doc/doxygen.cfg \
 dnl Create asoundlib.h dynamically according to configure options
 echo "Creating asoundlib.h..."
 cp "$srcdir"/include/asoundlib-head.h include/asoundlib.h
+test "$ac_cv_header_endian_h" = "yes" && echo "#include <endian.h>" >> include/asoundlib.h
+if test "$ac_cv_header_sys_endian_h" = "yes"; then
+cat >> include/asoundlib.h <<EOF
+#include <sys/endian.h>
+#ifndef __BYTE_ORDER
+#define __BYTE_ORDER BYTE_ORDER
+#endif
+#ifndef __LITTLE_ENDIAN
+#define __LITTLE_ENDIAN LITTLE_ENDIAN
+#endif
+#ifndef __BIG_ENDIAN
+#define __BIG_ENDIAN BIG_ENDIAN
+#endif
+EOF
+fi
 test "$build_pcm" = "yes" && echo "#include <alsa/pcm.h>" >> include/asoundlib.h
 test "$build_rawmidi" = "yes" && echo "#include <alsa/rawmidi.h>" >> include/asoundlib.h
 test "$build_pcm" = "yes" && echo "#include <alsa/timer.h>" >> include/asoundlib.h
include/asoundlib-head.h +0 -1
index 71b5c29..31408a4 100644
@@ -35,7 +35,6 @@
 #include <string.h>
 #include <fcntl.h>
 #include <assert.h>
-#include <endian.h>
 #include <sys/poll.h>
 #include <errno.h>
 #include <stdarg.h>
include/local.h +17 -1
index 9464efa..2fe9a27 100644
@@ -22,13 +22,30 @@
 #ifndef __LOCAL_H
 #define __LOCAL_H
 
+#include "config.h"
+
 #include <unistd.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <fcntl.h>
 #include <assert.h>
+#ifdef HAVE_ENDIAN_H
 #include <endian.h>
+#elif defined(HAVE_SYS_ENDIAN_H)
+#include <sys/endian.h>
+#ifndef __BYTE_ORDER
+#define __BYTE_ORDER BYTE_ORDER
+#endif
+#ifndef __LITTLE_ENDIAN
+#define __LITTLE_ENDIAN LITTLE_ENDIAN
+#endif
+#ifndef __BIG_ENDIAN
+#define __BIG_ENDIAN BIG_ENDIAN
+#endif
+#else
+#error Header defining endianness not defined
+#endif
 #include <stdarg.h>
 #include <sys/poll.h>
 #include <sys/types.h>
@@ -36,7 +53,6 @@
 #include <linux/types.h>
 #include <linux/ioctl.h>
 
-#include "config.h"
 #ifdef SUPPORT_RESMGR
 #include <resmgr.h>
 #endif
src/pcm/pcm_file.c +0 -1
index 7123025..b1f2330 100644
@@ -26,7 +26,6 @@
  *
  */
   
-#include <endian.h>
 #include <byteswap.h>
 #include <ctype.h>
 #include <string.h>
Signature · 1 line
1.8.5.4
#5 lore raw

At Fri, 21 Feb 2014 01:27:04 +0000,

Quoted 8 lines · Patrick Welche
Quoted 3 lines · Takashi Iwai

BTW, about your patch: I don't think it's good to embed the endianness in asoundlib.h. It makes the header file appearing differently, depending on the architecture, which is rather confusing.

Is this more what you have in mind? (Less portable than autoconf, but not set at configure time.)

Yes, I supposed something like that.

Quoted 9 lines

The four files which included endian.h were:

- include/asoundlib-head.h
- include/local.h
- include/sound/type_compat.h
- src/pcm/pcm_file.c

The endian.h line(s) in asoundlib.h is now generated by configure.

Looks almost good, but I prefer seeing it just after #include <stdarg.h> instead of the middle in alsa/* inclusions.

Other than that, all look good to me.
Could you fix and resubmit with your sign-off?

thanks,

Takashi

Quoted 134 lines

local.h includes the appropriate endian.h vs sys/endian.h file & defines the relevant macros.

type_compat.h doesn't seem to be used anywhere? So I left it alone.

pcm_file.c includes pcm_local.h which includes local.h, so I removed the #include <endian.h>

(Still far from being able to compile alsa-lib, but it's a start...)

Cheers,

Patrick

Quoted 1 line

From 5885d2e79dfd8f788177a95c70967d9a3c9a2cb6 Mon Sep 17 00:00:00 2001

From: Patrick Welche <[email protected]>
Date: Fri, 21 Feb 2014 01:18:01 +0000
Subject: [PATCH] Portability fix: look for sys/endian.h as well as endian.h

- define __BYTE_ORDER and friends.
- adjust asoundlib.h accordingly.

---
 configure.in             | 19 +++++++++++++++++--
 include/asoundlib-head.h |  1 -
 include/local.h          | 18 +++++++++++++++++-
 src/pcm/pcm_file.c       |  1 -
 4 files changed, 34 insertions(+), 5 deletions(-)
configure.in +17 -2
index bb56eb6..60d4ae1 100644
@@ -309,8 +309,8 @@ fi
 
 AC_SUBST(ALSA_DEPLIBS)
 
-dnl Check for wordexp.h
-AC_CHECK_HEADERS([wordexp.h])
+dnl Check for headers
+AC_CHECK_HEADERS([wordexp.h endian.h sys/endian.h])
 
 dnl Check for resmgr support...
 AC_MSG_CHECKING(for resmgr support)
@@ -660,6 +660,21 @@ AC_OUTPUT(Makefile doc/Makefile doc/pictures/Makefile doc/doxygen.cfg \
 dnl Create asoundlib.h dynamically according to configure options
 echo "Creating asoundlib.h..."
 cp "$srcdir"/include/asoundlib-head.h include/asoundlib.h
+test "$ac_cv_header_endian_h" = "yes" && echo "#include <endian.h>" >> include/asoundlib.h
+if test "$ac_cv_header_sys_endian_h" = "yes"; then
+cat >> include/asoundlib.h <<EOF
+#include <sys/endian.h>
+#ifndef __BYTE_ORDER
+#define __BYTE_ORDER BYTE_ORDER
+#endif
+#ifndef __LITTLE_ENDIAN
+#define __LITTLE_ENDIAN LITTLE_ENDIAN
+#endif
+#ifndef __BIG_ENDIAN
+#define __BIG_ENDIAN BIG_ENDIAN
+#endif
+EOF
+fi
 test "$build_pcm" = "yes" && echo "#include <alsa/pcm.h>" >> include/asoundlib.h
 test "$build_rawmidi" = "yes" && echo "#include <alsa/rawmidi.h>" >> include/asoundlib.h
 test "$build_pcm" = "yes" && echo "#include <alsa/timer.h>" >> include/asoundlib.h
include/asoundlib-head.h +0 -1
index 71b5c29..31408a4 100644
@@ -35,7 +35,6 @@
 #include <string.h>
 #include <fcntl.h>
 #include <assert.h>
-#include <endian.h>
 #include <sys/poll.h>
 #include <errno.h>
 #include <stdarg.h>
include/local.h +17 -1
index 9464efa..2fe9a27 100644
@@ -22,13 +22,30 @@
 #ifndef __LOCAL_H
 #define __LOCAL_H
 
+#include "config.h"
+
 #include <unistd.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <fcntl.h>
 #include <assert.h>
+#ifdef HAVE_ENDIAN_H
 #include <endian.h>
+#elif defined(HAVE_SYS_ENDIAN_H)
+#include <sys/endian.h>
+#ifndef __BYTE_ORDER
+#define __BYTE_ORDER BYTE_ORDER
+#endif
+#ifndef __LITTLE_ENDIAN
+#define __LITTLE_ENDIAN LITTLE_ENDIAN
+#endif
+#ifndef __BIG_ENDIAN
+#define __BIG_ENDIAN BIG_ENDIAN
+#endif
+#else
+#error Header defining endianness not defined
+#endif
 #include <stdarg.h>
 #include <sys/poll.h>
 #include <sys/types.h>
@@ -36,7 +53,6 @@
 #include <linux/types.h>
 #include <linux/ioctl.h>
 
-#include "config.h"
 #ifdef SUPPORT_RESMGR
 #include <resmgr.h>
 #endif
src/pcm/pcm_file.c +0 -1
index 7123025..b1f2330 100644
@@ -26,7 +26,6 @@
  *
  */
 
-#include <endian.h>
 #include <byteswap.h>
 #include <ctype.h>
 #include <string.h>
Signature · 1 line
1.8.5.4
#6 lore raw
Quoted 21 lines · Takashi Iwai

At Fri, 21 Feb 2014 01:27:04 +0000,

Quoted 8 lines · Patrick Welche
Quoted 3 lines · Takashi Iwai

BTW, about your patch: I don't think it's good to embed the endianness in asoundlib.h. It makes the header file appearing differently, depending on the architecture, which is rather confusing.

Is this more what you have in mind? (Less portable than autoconf, but not set at configure time.)

Yes, I supposed something like that.

Quoted 8 lines

The four files which included endian.h were:

- include/asoundlib-head.h
- include/local.h
- include/sound/type_compat.h
- src/pcm/pcm_file.c

Quoted 7 lines
Quoted 1 line

The endian.h line(s) in asoundlib.h is now generated by configure.

Looks almost good, but I prefer seeing it just after #include <stdarg.h> instead of the middle in alsa/* inclusions.

Other than that, all look good to me.
Could you fix and resubmit with your sign-off?

Version 2 with some of asoundlib-head.h moved to configure.in. (Fancy a patch to rename configure.in configure.ac, s/INCLUDES/AM_CPPFLAGS/?)

Cheers,

Patrick

Quoted 1 line

From b14f62d1345b563e9b8f525efb00f30312b17cc2 Mon Sep 17 00:00:00 2001

From: Patrick Welche <[email protected]>
Date: Sun, 23 Feb 2014 11:02:28 +0000
Subject: [PATCH] Portability fix: look for sys/endian.h as well as endian.h

- define __BYTE_ORDER and friends.
- adjust asoundlib.h accordingly.

---
 configure.in             | 33 +++++++++++++++++++++++++++++++--
 include/asoundlib-head.h | 13 -------------
 include/local.h          | 18 +++++++++++++++++-
 src/pcm/pcm_file.c       |  1 -
 4 files changed, 48 insertions(+), 17 deletions(-)
configure.in +31 -2
index bb56eb6..9463b5a 100644
@@ -309,8 +309,8 @@ fi
 
 AC_SUBST(ALSA_DEPLIBS)
 
-dnl Check for wordexp.h
-AC_CHECK_HEADERS([wordexp.h])
+dnl Check for headers
+AC_CHECK_HEADERS([wordexp.h endian.h sys/endian.h])
 
 dnl Check for resmgr support...
 AC_MSG_CHECKING(for resmgr support)
@@ -660,6 +660,35 @@ AC_OUTPUT(Makefile doc/Makefile doc/pictures/Makefile doc/doxygen.cfg \
 dnl Create asoundlib.h dynamically according to configure options
 echo "Creating asoundlib.h..."
 cp "$srcdir"/include/asoundlib-head.h include/asoundlib.h
+test "$ac_cv_header_endian_h" = "yes" && echo "#include <endian.h>" >> include/asoundlib.h
+if test "$ac_cv_header_sys_endian_h" = "yes"; then
+cat >> include/asoundlib.h <<EOF
+#include <sys/endian.h>
+#ifndef __BYTE_ORDER
+#define __BYTE_ORDER BYTE_ORDER
+#endif
+#ifndef __LITTLE_ENDIAN
+#define __LITTLE_ENDIAN LITTLE_ENDIAN
+#endif
+#ifndef __BIG_ENDIAN
+#define __BIG_ENDIAN BIG_ENDIAN
+#endif
+EOF
+fi
+cat >> include/asoundlib.h <<EOF
+
+#ifndef __GNUC__
+#define __inline__ inline
+#endif
+
+#include <alsa/asoundef.h>
+#include <alsa/version.h>
+#include <alsa/global.h>
+#include <alsa/input.h>
+#include <alsa/output.h>
+#include <alsa/error.h>
+#include <alsa/conf.h>
+EOF
 test "$build_pcm" = "yes" && echo "#include <alsa/pcm.h>" >> include/asoundlib.h
 test "$build_rawmidi" = "yes" && echo "#include <alsa/rawmidi.h>" >> include/asoundlib.h
 test "$build_pcm" = "yes" && echo "#include <alsa/timer.h>" >> include/asoundlib.h
include/asoundlib-head.h +0 -13
index 71b5c29..1ec611e 100644
@@ -35,19 +35,6 @@
 #include <string.h>
 #include <fcntl.h>
 #include <assert.h>
-#include <endian.h>
 #include <sys/poll.h>
 #include <errno.h>
 #include <stdarg.h>
-
-#ifndef __GNUC__
-#define __inline__ inline
-#endif
-
-#include <alsa/asoundef.h>
-#include <alsa/version.h>
-#include <alsa/global.h>
-#include <alsa/input.h>
-#include <alsa/output.h>
-#include <alsa/error.h>
-#include <alsa/conf.h>
include/local.h +17 -1
index 9464efa..2fe9a27 100644
@@ -22,13 +22,30 @@
 #ifndef __LOCAL_H
 #define __LOCAL_H
 
+#include "config.h"
+
 #include <unistd.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <fcntl.h>
 #include <assert.h>
+#ifdef HAVE_ENDIAN_H
 #include <endian.h>
+#elif defined(HAVE_SYS_ENDIAN_H)
+#include <sys/endian.h>
+#ifndef __BYTE_ORDER
+#define __BYTE_ORDER BYTE_ORDER
+#endif
+#ifndef __LITTLE_ENDIAN
+#define __LITTLE_ENDIAN LITTLE_ENDIAN
+#endif
+#ifndef __BIG_ENDIAN
+#define __BIG_ENDIAN BIG_ENDIAN
+#endif
+#else
+#error Header defining endianness not defined
+#endif
 #include <stdarg.h>
 #include <sys/poll.h>
 #include <sys/types.h>
@@ -36,7 +53,6 @@
 #include <linux/types.h>
 #include <linux/ioctl.h>
 
-#include "config.h"
 #ifdef SUPPORT_RESMGR
 #include <resmgr.h>
 #endif
src/pcm/pcm_file.c +0 -1
index 7123025..b1f2330 100644
@@ -26,7 +26,6 @@
  *
  */
   
-#include <endian.h>
 #include <byteswap.h>
 #include <ctype.h>
 #include <string.h>
Signature · 1 line
1.8.5.4
Applied
#7 lore raw

At Sun, 23 Feb 2014 11:12:48 +0000,

Quoted 25 lines · Patrick Welche
Quoted 23 lines · Takashi Iwai

At Fri, 21 Feb 2014 01:27:04 +0000,

Quoted 8 lines · Patrick Welche
Quoted 3 lines · Takashi Iwai

BTW, about your patch: I don't think it's good to embed the endianness in asoundlib.h. It makes the header file appearing differently, depending on the architecture, which is rather confusing.

Is this more what you have in mind? (Less portable than autoconf, but not set at configure time.)

Yes, I supposed something like that.

Quoted 9 lines

The four files which included endian.h were:

- include/asoundlib-head.h
- include/local.h
- include/sound/type_compat.h
- src/pcm/pcm_file.c

The endian.h line(s) in asoundlib.h is now generated by configure.

Quoted 7 lines
Quoted 5 lines

Looks almost good, but I prefer seeing it just after #include <stdarg.h> instead of the middle in alsa/* inclusions.

Other than that, all look good to me.
Could you fix and resubmit with your sign-off?

Version 2 with some of asoundlib-head.h moved to configure.in.

Thanks, applied now.

Quoted 1 line

(Fancy a patch to rename configure.in configure.ac, s/INCLUDES/AM_CPPFLAGS/?)

Not bad, but I'm too tired to follow stupid policy changes of auto-tools, so basically I don't care much unless the upstream really breaks it :)

Takashi

Quoted 152 lines

Cheers,

Patrick

Quoted 1 line

From b14f62d1345b563e9b8f525efb00f30312b17cc2 Mon Sep 17 00:00:00 2001

From: Patrick Welche <[email protected]>
Date: Sun, 23 Feb 2014 11:02:28 +0000
Subject: [PATCH] Portability fix: look for sys/endian.h as well as endian.h

- define __BYTE_ORDER and friends.
- adjust asoundlib.h accordingly.

---
 configure.in             | 33 +++++++++++++++++++++++++++++++--
 include/asoundlib-head.h | 13 -------------
 include/local.h          | 18 +++++++++++++++++-
 src/pcm/pcm_file.c       |  1 -
 4 files changed, 48 insertions(+), 17 deletions(-)
configure.in +31 -2
index bb56eb6..9463b5a 100644
@@ -309,8 +309,8 @@ fi
 
 AC_SUBST(ALSA_DEPLIBS)
 
-dnl Check for wordexp.h
-AC_CHECK_HEADERS([wordexp.h])
+dnl Check for headers
+AC_CHECK_HEADERS([wordexp.h endian.h sys/endian.h])
 
 dnl Check for resmgr support...
 AC_MSG_CHECKING(for resmgr support)
@@ -660,6 +660,35 @@ AC_OUTPUT(Makefile doc/Makefile doc/pictures/Makefile doc/doxygen.cfg \
 dnl Create asoundlib.h dynamically according to configure options
 echo "Creating asoundlib.h..."
 cp "$srcdir"/include/asoundlib-head.h include/asoundlib.h
+test "$ac_cv_header_endian_h" = "yes" && echo "#include <endian.h>" >> include/asoundlib.h
+if test "$ac_cv_header_sys_endian_h" = "yes"; then
+cat >> include/asoundlib.h <<EOF
+#include <sys/endian.h>
+#ifndef __BYTE_ORDER
+#define __BYTE_ORDER BYTE_ORDER
+#endif
+#ifndef __LITTLE_ENDIAN
+#define __LITTLE_ENDIAN LITTLE_ENDIAN
+#endif
+#ifndef __BIG_ENDIAN
+#define __BIG_ENDIAN BIG_ENDIAN
+#endif
+EOF
+fi
+cat >> include/asoundlib.h <<EOF
+
+#ifndef __GNUC__
+#define __inline__ inline
+#endif
+
+#include <alsa/asoundef.h>
+#include <alsa/version.h>
+#include <alsa/global.h>
+#include <alsa/input.h>
+#include <alsa/output.h>
+#include <alsa/error.h>
+#include <alsa/conf.h>
+EOF
 test "$build_pcm" = "yes" && echo "#include <alsa/pcm.h>" >> include/asoundlib.h
 test "$build_rawmidi" = "yes" && echo "#include <alsa/rawmidi.h>" >> include/asoundlib.h
 test "$build_pcm" = "yes" && echo "#include <alsa/timer.h>" >> include/asoundlib.h
include/asoundlib-head.h +0 -13
index 71b5c29..1ec611e 100644
@@ -35,19 +35,6 @@
 #include <string.h>
 #include <fcntl.h>
 #include <assert.h>
-#include <endian.h>
 #include <sys/poll.h>
 #include <errno.h>
 #include <stdarg.h>
-
-#ifndef __GNUC__
-#define __inline__ inline
-#endif
-
-#include <alsa/asoundef.h>
-#include <alsa/version.h>
-#include <alsa/global.h>
-#include <alsa/input.h>
-#include <alsa/output.h>
-#include <alsa/error.h>
-#include <alsa/conf.h>
include/local.h +17 -1
index 9464efa..2fe9a27 100644
@@ -22,13 +22,30 @@
 #ifndef __LOCAL_H
 #define __LOCAL_H
 
+#include "config.h"
+
 #include <unistd.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <fcntl.h>
 #include <assert.h>
+#ifdef HAVE_ENDIAN_H
 #include <endian.h>
+#elif defined(HAVE_SYS_ENDIAN_H)
+#include <sys/endian.h>
+#ifndef __BYTE_ORDER
+#define __BYTE_ORDER BYTE_ORDER
+#endif
+#ifndef __LITTLE_ENDIAN
+#define __LITTLE_ENDIAN LITTLE_ENDIAN
+#endif
+#ifndef __BIG_ENDIAN
+#define __BIG_ENDIAN BIG_ENDIAN
+#endif
+#else
+#error Header defining endianness not defined
+#endif
 #include <stdarg.h>
 #include <sys/poll.h>
 #include <sys/types.h>
@@ -36,7 +53,6 @@
 #include <linux/types.h>
 #include <linux/ioctl.h>
 
-#include "config.h"
 #ifdef SUPPORT_RESMGR
 #include <resmgr.h>
 #endif
src/pcm/pcm_file.c +0 -1
index 7123025..b1f2330 100644
@@ -26,7 +26,6 @@
  *
  */
 
-#include <endian.h>
 #include <byteswap.h>
 #include <ctype.h>
 #include <string.h>
Signature · 1 line
1.8.5.4
#8 lore raw
Quoted 5 lines · Takashi Iwai

At Sun, 23 Feb 2014 11:12:48 +0000,

Quoted 1 line · Patrick Welche

Version 2 with some of asoundlib-head.h moved to configure.in.

Thanks, applied now.

Thank you!

Quoted 5 lines
Quoted 1 line

(Fancy a patch to rename configure.in configure.ac, s/INCLUDES/AM_CPPFLAGS/?)

Not bad, but I'm too tired to follow stupid policy changes of auto-tools, so basically I don't care much unless the upstream really breaks it :)

It turns out that most of the warnings come from m4/attributes.m4 which seems to have been taken from xine-lib...

Here is a patch for some minor cleanup (not touching m4/attributes.m4)

Cheers,

Patrick

Quoted 1 line

From 84b60b941862f2c065bcb31811675e714fe6027e Mon Sep 17 00:00:00 2001

From: Patrick Welche <[email protected]>
Date: Tue, 25 Feb 2014 10:35:02 +0000
Subject: [PATCH 1/2] autotools: update style

- rename configure.in to configure.ac
- replace INCLUDES with AM_CPPFLAGS
- modernize AM_INIT_AUTOMAKE invocation

---
 Makefile.am                      |   2 +-
 alsalisp/Makefile.am             |   2 +-
 aserver/Makefile.am              |   2 +-
 configure.ac                     | 704 +++++++++++++++++++++++++++++++++++++++
 configure.in                     | 703 --------------------------------------
 doc/Makefile.am                  |   2 +-
 include/Makefile.am              |   4 +-
 modules/mixer/simple/Makefile.am |   2 +-
 src/Makefile.am                  |   2 +-
 src/alisp/Makefile.am            |   2 +-
 src/control/Makefile.am          |   2 +-
 src/hwdep/Makefile.am            |   2 +-
 src/mixer/Makefile.am            |   2 +-
 src/pcm/Makefile.am              |   2 +-
 src/rawmidi/Makefile.am          |   2 +-
 src/seq/Makefile.am              |   2 +-
 src/timer/Makefile.am            |   2 +-
 src/ucm/Makefile.am              |   2 +-
 test/Makefile.am                 |   2 +-
 utils/Makefile.am                |   2 +-
 20 files changed, 723 insertions(+), 722 deletions(-)
 create mode 100644 configure.ac
 delete mode 100644 configure.in
Makefile.am +1 -1
index f0c39c1..52f7654 100644
@@ -17,7 +17,7 @@ EXTRA_DIST=ChangeLog INSTALL TODO NOTES configure gitcompile libtool \
 	   depcomp version MEMORY-LEAK m4/attributes.m4
 AUTOMAKE_OPTIONS=foreign
 
-INCLUDES=-I$(top_srcdir)/include
+AM_CPPFLAGS=-I$(top_srcdir)/include
 
 rpm: dist
 	$(MAKE) -C utils rpm
alsalisp/Makefile.am +1 -1
index 6df915a..8e3e015 100644
@@ -5,4 +5,4 @@ alsalisp_LDADD = ../src/libasound.la
 
 all: alsalisp
 
-INCLUDES=-I$(top_srcdir)/include -I$(top_srcdir)/src/alisp
+AM_CPPFLAGS=-I$(top_srcdir)/include -I$(top_srcdir)/src/alisp
aserver/Makefile.am +1 -1
index 116f578..fbdb94c 100644
@@ -5,7 +5,7 @@ aserver_LDADD = ../src/libasound.la
 
 all: aserver
 
-INCLUDES=-I$(top_srcdir)/include -I$(top_srcdir)/src/pcm
+AM_CPPFLAGS=-I$(top_srcdir)/include -I$(top_srcdir)/src/pcm
 
 ../src/libasound.la:
 	$(MAKE) -C ../src libasound.la
configure.ac new file +704 -0

704 lines not on this page · raw message

configure.in deleted +0 -703

703 lines not on this page · raw message

doc/Makefile.am +1 -1
index 406fde7..e087f42 100644
@@ -2,7 +2,7 @@ SUBDIRS=pictures
 
 EXTRA_DIST=README.1st asoundrc.txt doxygen.cfg index.doxygen
 
-INCLUDES=-I$(top_srcdir)/include
+AM_CPPFLAGS=-I$(top_srcdir)/include
 
 doc:
 	test -e doxygen.cfg || sed s:[@]top_srcdir[@]:..:g doxygen.cfg.in > doxygen.cfg
include/Makefile.am +2 -2
index de37f2c..0127d5c 100644
@@ -61,7 +61,7 @@ alsa:
 version.h: stamp-vh alsa
 	@:
 
-stamp-vh: $(top_builddir)/configure.in
+stamp-vh: $(top_builddir)/configure.ac
 	@echo "/*" > ver.tmp
 	@echo " *  version.h" >> ver.tmp
 	@echo " */" >> ver.tmp
@@ -83,7 +83,7 @@ stamp-vh: $(top_builddir)/configure.in
               echo timestamp > stamp-vh)
 	-@rm -f ver.tmp
 
-INCLUDES=-I$(top_srcdir)/include
+AM_CPPFLAGS=-I$(top_srcdir)/include
 
 install-data-hook:
 	test -d $(DESTDIR)$(sysincludedir) || mkdir -p $(DESTDIR)$(sysincludedir)
modules/mixer/simple/Makefile.am +1 -1
index bad0944..cb64ee8 100644
@@ -3,7 +3,7 @@ pkglibdir = $(alsaplugindir)/smixer
 
 AM_CFLAGS = -g -O2 -W -Wall
 
-INCLUDES=-I$(top_srcdir)/include
+AM_CPPFLAGS=-I$(top_srcdir)/include
 
 pkglib_LTLIBRARIES = smixer-sbase.la \
 		     smixer-ac97.la \
src/Makefile.am +1 -1
index 8f789fe..fa255ff 100644
@@ -87,4 +87,4 @@ instr/libinstr.la:
 alisp/libalisp.la:
 	$(MAKE) -C alisp libalisp.la
 
-INCLUDES=-I$(top_srcdir)/include
+AM_CPPFLAGS=-I$(top_srcdir)/include
src/alisp/Makefile.am +1 -1
index e6d4ac5..1234e11 100644
@@ -8,4 +8,4 @@ noinst_HEADERS = alisp_local.h
 
 all: libalisp.la
 
-INCLUDES=-I$(top_srcdir)/include
+AM_CPPFLAGS=-I$(top_srcdir)/include
src/control/Makefile.am +1 -1
index 8076c73..3d476a2 100644
@@ -15,4 +15,4 @@ noinst_HEADERS = control_local.h
 all: libcontrol.la
 
 
-INCLUDES=-I$(top_srcdir)/include
+AM_CPPFLAGS=-I$(top_srcdir)/include
src/hwdep/Makefile.am +1 -1
index 0b626b9..b543e58 100644
@@ -5,4 +5,4 @@ noinst_HEADERS = hwdep_local.h
 all: libhwdep.la
 
 
-INCLUDES=-I$(top_srcdir)/include
+AM_CPPFLAGS=-I$(top_srcdir)/include
src/mixer/Makefile.am +1 -1
index c0749a4..6eeff8a 100644
@@ -11,4 +11,4 @@ noinst_HEADERS = mixer_local.h mixer_simple.h
 all: libmixer.la
 
 
-INCLUDES=-I$(top_srcdir)/include
+AM_CPPFLAGS=-I$(top_srcdir)/include
src/pcm/Makefile.am +1 -1
index 28faa54..81598f6 100644
@@ -114,4 +114,4 @@ alsadir = $(datadir)/alsa
 
 all: libpcm.la
 
-INCLUDES=-I$(top_srcdir)/include
+AM_CPPFLAGS=-I$(top_srcdir)/include
src/rawmidi/Makefile.am +1 -1
index 2470c7a..41858a1 100644
@@ -9,4 +9,4 @@ noinst_HEADERS = rawmidi_local.h
 all: librawmidi.la
 
 
-INCLUDES=-I$(top_srcdir)/include
+AM_CPPFLAGS=-I$(top_srcdir)/include
src/seq/Makefile.am +1 -1
index 1ea92f0..6cefe39 100644
@@ -10,4 +10,4 @@ noinst_HEADERS = seq_local.h
 all: libseq.la
 
 
-INCLUDES=-I$(top_srcdir)/include
+AM_CPPFLAGS=-I$(top_srcdir)/include
src/timer/Makefile.am +1 -1
index e7cf77b..7cfbe45 100644
@@ -6,4 +6,4 @@ noinst_HEADERS = timer_local.h
 all: libtimer.la
 
 
-INCLUDES=-I$(top_srcdir)/include
+AM_CPPFLAGS=-I$(top_srcdir)/include
src/ucm/Makefile.am +1 -1
index 7435d90..9d66b24 100644
@@ -7,4 +7,4 @@ noinst_HEADERS = ucm_local.h
 all: libucm.la
 
 
-INCLUDES=-I$(top_srcdir)/include
+AM_CPPFLAGS=-I$(top_srcdir)/include
test/Makefile.am +1 -1
index 8705402..a06e79b 100644
@@ -22,7 +22,7 @@ code_CFLAGS=-Wall -pipe -g -O2
 chmap_LDADD=../src/libasound.la
 audio_time_LDADD=../src/libasound.la
 
-INCLUDES=-I$(top_srcdir)/include
+AM_CPPFLAGS=-I$(top_srcdir)/include
 AM_CFLAGS=-Wall -pipe -g
 
 EXTRA_DIST=seq-decoder.c seq-sender.c midifile.h midifile.c midifile.3
utils/Makefile.am +1 -1
index 447d525..7220c02 100644
@@ -11,4 +11,4 @@ pkgconfig_DATA = alsa.pc
 rpm: buildrpm alsa-lib.spec
 	VERSION=$(VERSION) $(srcdir)/buildrpm
 
-INCLUDES=-I$(top_srcdir)/include
+AM_CPPFLAGS=-I$(top_srcdir)/include
Signature · 1 line
1.9.0
Applied
#9 lore raw

At Tue, 25 Feb 2014 12:40:21 +0000,

Quoted 12 lines · Patrick Welche
Quoted 5 lines · Takashi Iwai

At Sun, 23 Feb 2014 11:12:48 +0000,

Quoted 1 line · Patrick Welche

Version 2 with some of asoundlib-head.h moved to configure.in.

Thanks, applied now.

Thank you!

Quoted 2 lines
Quoted 1 line

(Fancy a patch to rename configure.in configure.ac, s/INCLUDES/AM_CPPFLAGS/?)

Quoted 8 lines
Quoted 3 lines

Not bad, but I'm too tired to follow stupid policy changes of auto-tools, so basically I don't care much unless the upstream really breaks it :)

It turns out that most of the warnings come from m4/attributes.m4 which seems to have been taken from xine-lib...

Here is a patch for some minor cleanup (not touching m4/attributes.m4)

Thanks, applied.

Takashi

#10 lore raw
In reply to Patrick Welche
Quoted 5 lines · Patrick Welche

I started out, writing the attached patch in November, but then it looked as though the boundaries of application library interface and linux sound chip driver had become so blurred that I thought that a decision had been taken to bin all OSes bar linux, hence the question. Can you give me a hint on how you think it is supposed to work?

Only the "hw" plugins access the Linux kernel drivers. Anything else should be portable (with the exception of plugins like "dmix" that require a "hw" plugin as their slave).

For most device types (hwdep/seq/rawmidi/timer), the hw plugin is the only implementation, so a portable alsa-lib has only control and pcm devices at the moment.

Regards,
Clemens

#11 lore raw
Quoted 7 lines · Clemens Ladisch
Quoted 5 lines · Patrick Welche

I started out, writing the attached patch in November, but then it looked as though the boundaries of application library interface and linux sound chip driver had become so blurred that I thought that a decision had been taken to bin all OSes bar linux, hence the question. Can you give me a hint on how you think it is supposed to work?

Quoted 7 lines

Only the "hw" plugins access the Linux kernel drivers. Anything else should be portable (with the exception of plugins like "dmix" that require a "hw" plugin as their slave).

For most device types (hwdep/seq/rawmidi/timer), the hw plugin is the only implementation, so a portable alsa-lib has only control and pcm devices at the moment.

So, rephrasing for the novice that I am, e.g., include/local.h contains

#include <endian.h>
...
#if __BYTE_ORDER == __LITTLE_ENDIAN
...
#include <linux/types.h>
#include <linux/ioctl.h>

which are portability headaches. local.h is included by

src/alisp/alisp.c:#include "local.h"
src/conf.c:#include "local.h"
src/confmisc.c:#include "local.h"
src/control/control_local.h:#include "local.h"
src/control/namehint.c:#include "local.h"
src/control/setup.c:#include "local.h"
src/dlmisc.c:#include "local.h"
src/error.c:#include "local.h"
src/hwdep/hwdep_local.h:#include "local.h"
src/input.c:#include "local.h"
src/mixer/mixer_local.h:#include "local.h"
src/names.c:#include "local.h"
src/output.c:#include "local.h"
src/pcm/pcm_local.h:#include "local.h"
src/rawmidi/rawmidi_local.h:#include "local.h"
src/seq/seq_event.c:#include "local.h"
src/seq/seq_local.h:#include "local.h"
src/seq/seq_midi_event.c:#include "local.h"
src/seq/seq_old.c:#include "local.h"
src/socket.c:#include "local.h"
src/timer/timer_local.h:#include "local.h"
src/ucm/ucm_local.h:#include "local.h"

That is fine except for files under directories src/control and src/pcm which ought to be portable? Or is it stronger, and everything should be portable except files under directory src/hwdep?

Cheers,

Patrick

#12 lore raw

At Thu, 16 Jan 2014 13:27:17 +0000,

Quoted 51 lines · Patrick Welche
Quoted 7 lines · Clemens Ladisch
Quoted 5 lines · Patrick Welche

I started out, writing the attached patch in November, but then it looked as though the boundaries of application library interface and linux sound chip driver had become so blurred that I thought that a decision had been taken to bin all OSes bar linux, hence the question. Can you give me a hint on how you think it is supposed to work?

Quoted 7 lines

Only the "hw" plugins access the Linux kernel drivers. Anything else should be portable (with the exception of plugins like "dmix" that require a "hw" plugin as their slave).

For most device types (hwdep/seq/rawmidi/timer), the hw plugin is the only implementation, so a portable alsa-lib has only control and pcm devices at the moment.

So, rephrasing for the novice that I am, e.g., include/local.h contains

#include <endian.h>
...
#if __BYTE_ORDER == __LITTLE_ENDIAN
...
#include <linux/types.h>
#include <linux/ioctl.h>

which are portability headaches. local.h is included by

src/alisp/alisp.c:#include "local.h"
src/conf.c:#include "local.h"
src/confmisc.c:#include "local.h"
src/control/control_local.h:#include "local.h"
src/control/namehint.c:#include "local.h"
src/control/setup.c:#include "local.h"
src/dlmisc.c:#include "local.h"
src/error.c:#include "local.h"
src/hwdep/hwdep_local.h:#include "local.h"
src/input.c:#include "local.h"
src/mixer/mixer_local.h:#include "local.h"
src/names.c:#include "local.h"
src/output.c:#include "local.h"
src/pcm/pcm_local.h:#include "local.h"
src/rawmidi/rawmidi_local.h:#include "local.h"
src/seq/seq_event.c:#include "local.h"
src/seq/seq_local.h:#include "local.h"
src/seq/seq_midi_event.c:#include "local.h"
src/seq/seq_old.c:#include "local.h"
src/socket.c:#include "local.h"
src/timer/timer_local.h:#include "local.h"
src/ucm/ucm_local.h:#include "local.h"

Quoted 3 lines

That is fine except for files under directories src/control and src/pcm which ought to be portable? Or is it stronger, and everything should be portable except files under directory src/hwdep?

Why excluding hwdep...? And, no, the codes have been written to be portable, but the primary goal is a thin layer for Linux kernel ABI, thus its support is the highest priority.

The linux/*.h file inclusions are basically for allowing to include sound/asound.h as is. It's a part of the Linux kernel code, and I don't think we'd add any extra ifdefs there just for non-Linux.

IOW, you'd need to prepare some compatible defines before including sound/asound.h if you need to compile for non-Linux systems.

Takashi

#13 lore raw
Quoted 6 lines · Takashi Iwai

At Thu, 16 Jan 2014 13:27:17 +0000,
Patrick Welche wrote:
Why excluding hwdep...? And, no, the codes have been written to be portable, but the primary goal is a thin layer for Linux kernel ABI, thus its support is the highest priority.

Quoted 6 lines

The linux/*.h file inclusions are basically for allowing to include sound/asound.h as is. It's a part of the Linux kernel code, and I don't think we'd add any extra ifdefs there just for non-Linux.

IOW, you'd need to prepare some compatible defines before including sound/asound.h if you need to compile for non-Linux systems.

I should have read this more carefully before preparing the attached patch... I changed asound.h.

The attached is what I needed to be able to build with

../configure --prefix=/tmp \

--enable-debug          \
--disable-resmgr        \
--disable-aload         \
--disable-mixer         \
--disable-pcm           \
--disable-rawmidi       \
--disable-hwdep         \
--disable-seq           \
--disable-ucm           \
--disable-alisp         \
--disable-old-symbols   \
--disable-python        \
--with-debug            \
--without-libdl         \

--without-librt

so not very useful, but at least it compiles. (This is on top of 0001-autotools-update-style.patch)

Suggestions on what to try to make it acceptable?

(byteswap.h needs tackling next...)

Cheers,

Patrick

Quoted 1 line

From f4ddc106fc53ec950ec8b6f2b0bfe3e1677c959f Mon Sep 17 00:00:00 2001

From: Patrick Welche <[email protected]>
Date: Tue, 25 Feb 2014 12:25:48 +0000
Subject: [PATCH 2/2] Portability fixes - mainly asound.h

- replace linux/types.h with types from sys/types.h and stdint.h:
__kerne_off_t (long) -> off_t (matches mmap())
__kernel_pid_t (int) -> pid_t
__u32 -> uint32_t
__u64 -> uint64_t
- protect possibly now unnessary #include <linux/...> in local.h with ifdefs
- map extended error numbers to (not quite equivalent) posix numbers ifndef:
ESTRPIPE Streams pipe error -> EPIPE Broken pipe
EBADFD File descriptor in bad state -> EBADF Bad file descriptor
- test for versionsort() and only use if we have it
- LIST_HEAD can be defined in sys/queue.h, so undefine before defining

---
 configure.ac           |  4 ++--
 include/list.h         |  3 +++
 include/local.h        | 10 ++++++++++
 include/sound/asound.h | 24 ++++++++++++++++++------
 src/conf.c             |  2 +-
 5 files changed, 34 insertions(+), 9 deletions(-)
configure.ac +2 -2
index d744867..979764b 100644
@@ -65,7 +65,7 @@ AC_HEADER_TIME
 
 dnl Checks for library functions.
 AC_PROG_GCC_TRADITIONAL
-AC_CHECK_FUNCS([uselocale])
+AC_CHECK_FUNCS([uselocale versionsort])
 
 SAVE_LIBRARY_VERSION
 AC_SUBST(LIBTOOL_VERSION_INFO)
@@ -311,7 +311,7 @@ fi
 AC_SUBST(ALSA_DEPLIBS)
 
 dnl Check for headers
-AC_CHECK_HEADERS([wordexp.h endian.h sys/endian.h])
+AC_CHECK_HEADERS([wordexp.h endian.h sys/endian.h linux/types.h linux/ioctl.h])
 
 dnl Check for resmgr support...
 AC_MSG_CHECKING(for resmgr support)
include/list.h +3 -0
index 4d9895f..6cf0753 100644
@@ -23,6 +23,9 @@ struct list_head {
 
 #define LIST_HEAD_INIT(name) { &(name), &(name) }
 
+#ifdef LIST_HEAD
+#undef LIST_HEAD
+#endif
 #define LIST_HEAD(name) \
 	struct list_head name = LIST_HEAD_INIT(name)
 
include/local.h +10 -0
index 2fe9a27..f1abfef 100644
@@ -50,8 +50,18 @@
 #include <sys/poll.h>
 #include <sys/types.h>
 #include <errno.h>
+#ifndef ESTRPIPE
+#define ESTRPIPE EPIPE
+#endif
+#ifndef EBADFD
+#define EBADFD EBADF
+#endif
+#if HAVE_LINUX_TYPES_H
 #include <linux/types.h>
+#endif
+#if HAVE_LINUX_IOCTL_H
 #include <linux/ioctl.h>
+#endif
 
 #ifdef SUPPORT_RESMGR
 #include <resmgr.h>
include/sound/asound.h +18 -6
index 1774a5c..102bc50 100644
@@ -23,7 +23,19 @@
 #ifndef _UAPI__SOUND_ASOUND_H
 #define _UAPI__SOUND_ASOUND_H
 
-#include <linux/types.h>
+#include <sys/ioctl.h>
+#include <sys/types.h>
+#include <stdint.h>
+#ifdef __CHECKER__
+#define __bitwise__ __attribute__((bitwise))
+#else
+#define __bitwise__
+#endif
+#ifdef __CHECK_ENDIAN__
+#define __bitwise __bitwise__
+#else
+#define __bitwise
+#endif
 
 
 /*
@@ -348,7 +360,7 @@ struct snd_interval {
 #define SNDRV_MASK_MAX	256
 
 struct snd_mask {
-	__u32 bits[(SNDRV_MASK_MAX+31)/32];
+	uint32_t bits[(SNDRV_MASK_MAX+31)/32];
 };
 
 struct snd_pcm_hw_params {
@@ -391,7 +403,7 @@ struct snd_pcm_sw_params {
 
 struct snd_pcm_channel_info {
 	unsigned int channel;
-	__kernel_off_t offset;		/* mmap offset */
+	off_t offset;			/* mmap offset */
 	unsigned int first;		/* offset to first sample in bits */
 	unsigned int step;		/* samples distance in bits */
 };
@@ -407,7 +419,7 @@ struct snd_pcm_status {
 	snd_pcm_uframes_t avail_max;	/* max frames available on hw since last status */
 	snd_pcm_uframes_t overrange;	/* count of ADC (capture) overrange detections from last status */
 	snd_pcm_state_t suspended_state; /* suspended stream state */
-	__u32 reserved_alignment;	/* must be filled with zero */
+	uint32_t reserved_alignment;	/* must be filled with zero */
 	struct timespec audio_tstamp;	/* from sample counter or wall clock */
 	unsigned char reserved[56-sizeof(struct timespec)]; /* must be filled with zero */
 };
@@ -838,7 +850,7 @@ struct snd_ctl_elem_info {
 	snd_ctl_elem_type_t type;	/* R: value type - SNDRV_CTL_ELEM_TYPE_* */
 	unsigned int access;		/* R: value access (bitmask) - SNDRV_CTL_ELEM_ACCESS_* */
 	unsigned int count;		/* count of values */
-	__kernel_pid_t owner;		/* owner's PID of this control */
+	pid_t owner;			/* owner's PID of this control */
 	union {
 		struct {
 			long min;		/* R: minimum value */
@@ -854,7 +866,7 @@ struct snd_ctl_elem_info {
 			unsigned int items;	/* R: number of items */
 			unsigned int item;	/* W: item number */
 			char name[64];		/* R: value name */
-			__u64 names_ptr;	/* W: names list (ELEM_ADD only) */
+			uint64_t names_ptr;	/* W: names list (ELEM_ADD only) */
 			unsigned int names_length;
 		} enumerated;
 		unsigned char reserved[128];
src/conf.c +1 -1
index 5ccc8e1..2a39d60 100644
@@ -3517,7 +3517,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(HAVE_VERSIONSORT) && defined(_GNU_SOURCE)
 #define SORTFUNC	versionsort
 #else
 #define SORTFUNC	alphasort
Signature · 1 line
1.9.0
#14 lore raw

At Tue, 25 Feb 2014 12:45:14 +0000,

Quoted 35 lines · Patrick Welche
Quoted 6 lines · Takashi Iwai

At Thu, 16 Jan 2014 13:27:17 +0000,
Patrick Welche wrote:
Why excluding hwdep...? And, no, the codes have been written to be portable, but the primary goal is a thin layer for Linux kernel ABI, thus its support is the highest priority.

Quoted 6 lines

The linux/*.h file inclusions are basically for allowing to include sound/asound.h as is. It's a part of the Linux kernel code, and I don't think we'd add any extra ifdefs there just for non-Linux.

IOW, you'd need to prepare some compatible defines before including sound/asound.h if you need to compile for non-Linux systems.

I should have read this more carefully before preparing the attached patch... I changed asound.h.

The attached is what I needed to be able to build with

../configure --prefix=/tmp \

--enable-debug          \
--disable-resmgr        \
--disable-aload         \
--disable-mixer         \
--disable-pcm           \
--disable-rawmidi       \
--disable-hwdep         \
--disable-seq           \
--disable-ucm           \
--disable-alisp         \
--disable-old-symbols   \
--disable-python        \
--with-debug            \
--without-libdl         \
Quoted 4 lines

--without-librt

so not very useful, but at least it compiles. (This is on top of 0001-autotools-update-style.patch)

This isn't a way I supposed. In principle, you must not touch include/sound/*.h files. These are just copies from Linux kernel tree, thus they are managed there.

For any lacking linux/*.h files, you can create the own in somewhere locally by detecting in configure script. For example, keep a directory include-compat/linux/types.h, and add -Iinclude-compat for non-Linux systems.

Takashi