All of lore.kernel.org
 help / color / mirror / Atom feed
From: Patrick Welche <prlw1@cam.ac.uk>
To: Takashi Iwai <tiwai@suse.de>
Cc: alsa-devel@alsa-project.org
Subject: Re: alsa on non-linux
Date: Tue, 14 Jan 2014 10:17:09 +0000	[thread overview]
Message-ID: <20140114101709.GB160@quark.internal.precedence.co.uk> (raw)
In-Reply-To: <s5hwqi4t6zg.wl%tiwai@suse.de>

[-- Attachment #1: Type: text/plain, Size: 1411 bytes --]

On Mon, Jan 13, 2014 at 01:13:23PM +0100, Takashi Iwai wrote:
> At Fri, 10 Jan 2014 15:37:00 +0000,
> Patrick Welche wrote:
> > 
> > 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?
> 
> 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

[-- Attachment #2: 0001-Portability-fix-Use-SND_LITTLE_ENDIAN-SND_BIG_ENDIAN.patch --]
[-- Type: text/plain, Size: 3379 bytes --]

>From c60287a8c5d3175b6df07757241cb59f3b94edb7 Mon Sep 17 00:00:00 2001
From: Patrick Welche <prlw1@cam.ac.uk>
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(-)

diff --git a/configure.in b/configure.in
index 35fd89f..679decd 100644
--- a/configure.in
+++ b/configure.in
@@ -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
-
diff --git a/include/asoundlib-head.h b/include/asoundlib-head.h
index 71b5c29..31408a4 100644
--- a/include/asoundlib-head.h
+++ b/include/asoundlib-head.h
@@ -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>
diff --git a/include/local.h b/include/local.h
index 9464efa..1e7c0dc 100644
--- a/include/local.h
+++ b/include/local.h
@@ -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
diff --git a/src/pcm/pcm_file.c b/src/pcm/pcm_file.c
index 7123025..7ee5c37 100644
--- a/src/pcm/pcm_file.c
+++ b/src/pcm/pcm_file.c
@@ -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
-- 
1.8.5.2


[-- Attachment #3: Type: text/plain, Size: 0 bytes --]



  reply	other threads:[~2014-01-14 10:17 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-10 15:37 alsa on non-linux Patrick Welche
2014-01-13 12:13 ` Takashi Iwai
2014-01-14 10:17   ` Patrick Welche [this message]
2014-01-14 13:23     ` Takashi Iwai
2014-02-21  1:27       ` Patrick Welche
2014-02-21 11:04         ` Takashi Iwai
2014-02-23 11:12           ` Patrick Welche
2014-02-24 10:03             ` Takashi Iwai
2014-02-25 12:40               ` Patrick Welche
2014-02-26  7:17                 ` Takashi Iwai
2014-01-14 14:04     ` Clemens Ladisch
2014-01-16 13:27       ` Patrick Welche
2014-01-16 13:46         ` Takashi Iwai
2014-02-25 12:45           ` Patrick Welche
2014-02-26  7:20             ` Takashi Iwai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140114101709.GB160@quark.internal.precedence.co.uk \
    --to=prlw1@cam.ac.uk \
    --cc=alsa-devel@alsa-project.org \
    --cc=tiwai@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.