Skip to contentSkip to conversation

feeding back pkgsrc changs

PATCH New Thomas Klausner 3 participants 30 messages Feb 18, 2016 – Mar 3, 2016 Sound

lore
Share & tools
lore
#0 lore raw

Hi!

I've just updated the pkgsrc packages for alsa-lib, alsa-utils and alsa-plugins to 1.1.0 and noticed that there are quite a number of local patches we have. I'd like to get them integrated.

When I visited the alsa-projects web page, I noticed that the link to the bug tracker is dead.

What is the recommended method to provide the patches?

Thanks,
Thomas

#1 lore raw
Quoted 11 lines · Thomas Klausner

Hi!

I've just updated the pkgsrc packages for alsa-lib, alsa-utils and alsa-plugins to 1.1.0 and noticed that there are quite a number of local patches we have. I'd like to get them integrated.

When I visited the alsa-projects web page, I noticed that the link to the bug tracker is dead.

What is the recommended method to provide the patches?

Just submit your patches to alsa-devel ML. That's the best way to review and get merged.

thanks,

Takashi

#2 lore raw

portability patch: EBADF [was Re: feeding back pkgsrc changs]

Hi Takashi!

Thanks for the answer.

Quoted 6 lines · Takashi Iwai
Quoted 4 lines · Thomas Klausner

I've just updated the pkgsrc packages for alsa-lib, alsa-utils and alsa-plugins to 1.1.0 and noticed that there are quite a number of local patches we have. I'd like to get them integrated.

Quoted 7 lines
Quoted 4 lines

When I visited the alsa-projects web page, I noticed that the link to the bug tracker is dead.

What is the recommended method to provide the patches?

Just submit your patches to alsa-devel ML. That's the best way to review and get merged.

I'll start with a straightforward one. Some operating systems don't provide an errno 'EBADFD'; let's use EBADF there instead.

This patch adds the define in all files that need it, but if you prefer to add it to a central place instead, please suggest one.

Thanks,
Thomas

Quoted 1 line

From e72e16bcb9bd2ddff2624fdb57a96fad6b3cf5bb Mon Sep 17 00:00:00 2001

From: Thomas Klausner <[email protected]>
Date: Tue, 23 Feb 2016 15:05:47 +0100
Subject: [PATCH] Define EBADFD in terms of EBADF if it doesn't exist.

For portability on FreeBSD, NetBSD and probably others.

---
 aserver/aserver.c         | 4 ++++
 src/control/control_shm.c | 4 ++++
 src/pcm/pcm.c             | 4 ++++
 src/pcm/pcm_dmix.c        | 4 ++++
 src/pcm/pcm_dshare.c      | 4 ++++
 src/pcm/pcm_dsnoop.c      | 4 ++++
 src/pcm/pcm_hw.c          | 4 ++++
 src/pcm/pcm_ioplug.c      | 4 ++++
 src/pcm/pcm_null.c        | 4 ++++
 src/pcm/pcm_rate.c        | 4 ++++
 src/pcm/pcm_share.c       | 4 ++++
 src/pcm/pcm_shm.c         | 4 ++++
 src/pcm/pcm_simple.c      | 4 ++++
 13 files changed, 52 insertions(+)
aserver/aserver.c +4 -0
index ac20706..88995cf 100644
@@ -35,6 +35,10 @@
 
 #include "aserver.h"
 
+#ifndef EBADFD
+#define EBADFD EBADF
+#endif
+
 char *command;
 
 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95)
src/control/control_shm.c +4 -0
index bd07d4a..618ef39 100644
@@ -35,6 +35,10 @@
 #include <netdb.h>
 #include "aserver.h"
 
+#ifndef EBADFD
+#define EBADFD EBADF
+#endif
+
 #ifndef PIC
 /* entry for static linking */
 const char *_snd_module_control_shm = "";
src/pcm/pcm.c +4 -0
index 203e7a5..6d40171 100644
@@ -639,6 +639,10 @@ playback devices.
 #include <limits.h>
 #include "pcm_local.h"
 
+#ifndef EBADFD
+#define EBADFD EBADF
+#endif
+
 /**
  * \brief get identifier of PCM handle
  * \param pcm PCM handle
src/pcm/pcm_dmix.c +4 -0
index b26a5c7..ba65cad 100644
@@ -45,6 +45,10 @@
 #include <sys/mman.h>
 #include "pcm_direct.h"
 
+#ifndef EBADFD
+#define EBADFD EBADF
+#endif
+
 #ifndef PIC
 /* entry for static linking */
 const char *_snd_module_pcm_dmix = "";
src/pcm/pcm_dshare.c +4 -0
index 58e47bb..2556a30 100644
@@ -45,6 +45,10 @@
 #include <sys/mman.h>
 #include "pcm_direct.h"
 
+#ifndef EBADFD
+#define EBADFD EBADF
+#endif
+
 #ifndef PIC
 /* entry for static linking */
 const char *_snd_module_pcm_dshare = "";
src/pcm/pcm_dsnoop.c +4 -0
index 576c35b..26b6f5c 100644
@@ -45,6 +45,10 @@
 #include <sys/mman.h>
 #include "pcm_direct.h"
 
+#ifndef EBADFD
+#define EBADFD EBADF
+#endif
+
 #ifndef PIC
 /* entry for static linking */
 const char *_snd_module_pcm_dsnoop = "";
src/pcm/pcm_hw.c +4 -0
index 4f4b84b..de9f9d5 100644
@@ -40,6 +40,10 @@
 #include "../control/control_local.h"
 #include "../timer/timer_local.h"
 
+#ifndef EBADFD
+#define EBADFD EBADF
+#endif
+
 //#define DEBUG_RW		/* use to debug readi/writei/readn/writen */
 //#define DEBUG_MMAP		/* debug mmap_commit */
 
src/pcm/pcm_ioplug.c +4 -0
index 43550c0..bed1c97 100644
@@ -31,6 +31,10 @@
 #include "pcm_ext_parm.h"
 #include "pcm_generic.h"
 
+#ifndef EBADFD
+#define EBADFD EBADF
+#endif
+
 #ifndef PIC
 /* entry for static linking */
 const char *_snd_module_pcm_ioplug = "";
src/pcm/pcm_null.c +4 -0
index 5e63caa..9fe3c82 100644
@@ -31,6 +31,10 @@
 #include "pcm_local.h"
 #include "pcm_plugin.h"
 
+#ifndef EBADFD
+#define EBADFD EBADF
+#endif
+
 #ifndef PIC
 /* entry for static linking */
 const char *_snd_module_pcm_null = "";
src/pcm/pcm_rate.c +4 -0
index c76db25..c08a2e8 100644
@@ -36,6 +36,10 @@
 
 #include "plugin_ops.h"
 
+#ifndef EBADFD
+#define EBADFD EBADF
+#endif
+
 #if 0
 #define DEBUG_REFINE
 #endif
src/pcm/pcm_share.c +4 -0
index 5d8aaf2..9fe8dc1 100644
@@ -38,6 +38,10 @@
 #include <pthread.h>
 #include "pcm_local.h"
 
+#ifndef EBADFD
+#define EBADFD EBADF
+#endif
+
 #ifndef PIC
 /* entry for static linking */
 const char *_snd_module_pcm_share = "";
src/pcm/pcm_shm.c +4 -0
index a815ac6..242b26e 100644
@@ -45,6 +45,10 @@
 #include <netdb.h>
 #include "aserver.h"
 
+#ifndef EBADFD
+#define EBADFD EBADF
+#endif
+
 #ifndef PIC
 /* entry for static linking */
 const char *_snd_module_pcm_shm = "";
src/pcm/pcm_simple.c +4 -0
index ce11083..99ba1c3 100644
@@ -25,6 +25,10 @@
 
 #include "pcm_local.h"
 
+#ifndef EBADFD
+#define EBADFD EBADF
+#endif
+
 static int set_buffer_time(snd_spcm_latency_t latency,
 			   unsigned int *buffer_time)
 {
Signature · 1 line
2.7.1
#3 lore raw

Re: portability patch: EBADF [was Re: feeding back pkgsrc changs]

Quoted 17 lines · Thomas Klausner

Hi Takashi!

Thanks for the answer.

Quoted 11 lines · Takashi Iwai
Quoted 8 lines · Thomas Klausner

I've just updated the pkgsrc packages for alsa-lib, alsa-utils and alsa-plugins to 1.1.0 and noticed that there are quite a number of local patches we have. I'd like to get them integrated.

When I visited the alsa-projects web page, I noticed that the link to the bug tracker is dead.

What is the recommended method to provide the patches?

Quoted 8 lines
Quoted 2 lines

Just submit your patches to alsa-devel ML. That's the best way to review and get merged.

I'll start with a straightforward one. Some operating systems don't provide an errno 'EBADFD'; let's use EBADF there instead.

This patch adds the define in all files that need it, but if you prefer to add it to a central place instead, please suggest one.

How about put this in include/local.h instead? Then we need to put it only in one place, as this is supposed to be included by all codes.

Takashi

Quoted 223 lines

Thanks,
Thomas

Quoted 1 line

From e72e16bcb9bd2ddff2624fdb57a96fad6b3cf5bb Mon Sep 17 00:00:00 2001

From: Thomas Klausner <[email protected]>
Date: Tue, 23 Feb 2016 15:05:47 +0100
Subject: [PATCH] Define EBADFD in terms of EBADF if it doesn't exist.

For portability on FreeBSD, NetBSD and probably others.

---
 aserver/aserver.c         | 4 ++++
 src/control/control_shm.c | 4 ++++
 src/pcm/pcm.c             | 4 ++++
 src/pcm/pcm_dmix.c        | 4 ++++
 src/pcm/pcm_dshare.c      | 4 ++++
 src/pcm/pcm_dsnoop.c      | 4 ++++
 src/pcm/pcm_hw.c          | 4 ++++
 src/pcm/pcm_ioplug.c      | 4 ++++
 src/pcm/pcm_null.c        | 4 ++++
 src/pcm/pcm_rate.c        | 4 ++++
 src/pcm/pcm_share.c       | 4 ++++
 src/pcm/pcm_shm.c         | 4 ++++
 src/pcm/pcm_simple.c      | 4 ++++
 13 files changed, 52 insertions(+)
aserver/aserver.c +4 -0
index ac20706..88995cf 100644
@@ -35,6 +35,10 @@
 
 #include "aserver.h"
 
+#ifndef EBADFD
+#define EBADFD EBADF
+#endif
+
 char *command;
 
 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95)
src/control/control_shm.c +4 -0
index bd07d4a..618ef39 100644
@@ -35,6 +35,10 @@
 #include <netdb.h>
 #include "aserver.h"
 
+#ifndef EBADFD
+#define EBADFD EBADF
+#endif
+
 #ifndef PIC
 /* entry for static linking */
 const char *_snd_module_control_shm = "";
src/pcm/pcm.c +4 -0
index 203e7a5..6d40171 100644
@@ -639,6 +639,10 @@ playback devices.
 #include <limits.h>
 #include "pcm_local.h"
 
+#ifndef EBADFD
+#define EBADFD EBADF
+#endif
+
 /**
  * \brief get identifier of PCM handle
  * \param pcm PCM handle
src/pcm/pcm_dmix.c +4 -0
index b26a5c7..ba65cad 100644
@@ -45,6 +45,10 @@
 #include <sys/mman.h>
 #include "pcm_direct.h"
 
+#ifndef EBADFD
+#define EBADFD EBADF
+#endif
+
 #ifndef PIC
 /* entry for static linking */
 const char *_snd_module_pcm_dmix = "";
src/pcm/pcm_dshare.c +4 -0
index 58e47bb..2556a30 100644
@@ -45,6 +45,10 @@
 #include <sys/mman.h>
 #include "pcm_direct.h"
 
+#ifndef EBADFD
+#define EBADFD EBADF
+#endif
+
 #ifndef PIC
 /* entry for static linking */
 const char *_snd_module_pcm_dshare = "";
src/pcm/pcm_dsnoop.c +4 -0
index 576c35b..26b6f5c 100644
@@ -45,6 +45,10 @@
 #include <sys/mman.h>
 #include "pcm_direct.h"
 
+#ifndef EBADFD
+#define EBADFD EBADF
+#endif
+
 #ifndef PIC
 /* entry for static linking */
 const char *_snd_module_pcm_dsnoop = "";
src/pcm/pcm_hw.c +4 -0
index 4f4b84b..de9f9d5 100644
@@ -40,6 +40,10 @@
 #include "../control/control_local.h"
 #include "../timer/timer_local.h"
 
+#ifndef EBADFD
+#define EBADFD EBADF
+#endif
+
 //#define DEBUG_RW		/* use to debug readi/writei/readn/writen */
 //#define DEBUG_MMAP		/* debug mmap_commit */
 
src/pcm/pcm_ioplug.c +4 -0
index 43550c0..bed1c97 100644
@@ -31,6 +31,10 @@
 #include "pcm_ext_parm.h"
 #include "pcm_generic.h"
 
+#ifndef EBADFD
+#define EBADFD EBADF
+#endif
+
 #ifndef PIC
 /* entry for static linking */
 const char *_snd_module_pcm_ioplug = "";
src/pcm/pcm_null.c +4 -0
index 5e63caa..9fe3c82 100644
@@ -31,6 +31,10 @@
 #include "pcm_local.h"
 #include "pcm_plugin.h"
 
+#ifndef EBADFD
+#define EBADFD EBADF
+#endif
+
 #ifndef PIC
 /* entry for static linking */
 const char *_snd_module_pcm_null = "";
src/pcm/pcm_rate.c +4 -0
index c76db25..c08a2e8 100644
@@ -36,6 +36,10 @@
 
 #include "plugin_ops.h"
 
+#ifndef EBADFD
+#define EBADFD EBADF
+#endif
+
 #if 0
 #define DEBUG_REFINE
 #endif
src/pcm/pcm_share.c +4 -0
index 5d8aaf2..9fe8dc1 100644
@@ -38,6 +38,10 @@
 #include <pthread.h>
 #include "pcm_local.h"
 
+#ifndef EBADFD
+#define EBADFD EBADF
+#endif
+
 #ifndef PIC
 /* entry for static linking */
 const char *_snd_module_pcm_share = "";
src/pcm/pcm_shm.c +4 -0
index a815ac6..242b26e 100644
@@ -45,6 +45,10 @@
 #include <netdb.h>
 #include "aserver.h"
 
+#ifndef EBADFD
+#define EBADFD EBADF
+#endif
+
 #ifndef PIC
 /* entry for static linking */
 const char *_snd_module_pcm_shm = "";
src/pcm/pcm_simple.c +4 -0
index ce11083..99ba1c3 100644
@@ -25,6 +25,10 @@
 
 #include "pcm_local.h"
 
+#ifndef EBADFD
+#define EBADFD EBADF
+#endif
+
 static int set_buffer_time(snd_spcm_latency_t latency,
 			   unsigned int *buffer_time)
 {
Signature · 1 line
2.7.1
#4 lore raw

Re: portability patch: EBADF [was Re: feeding back pkgsrc changs]

Quoted 19 lines · Takashi Iwai
Quoted 17 lines · Thomas Klausner

Thanks for the answer.

Quoted 13 lines · Takashi Iwai
Quoted 8 lines · Thomas Klausner

I've just updated the pkgsrc packages for alsa-lib, alsa-utils and alsa-plugins to 1.1.0 and noticed that there are quite a number of local patches we have. I'd like to get them integrated.

When I visited the alsa-projects web page, I noticed that the link to the bug tracker is dead.

What is the recommended method to provide the patches?

Just submit your patches to alsa-devel ML. That's the best way to review and get merged.

Quoted 8 lines
Quoted 5 lines

I'll start with a straightforward one. Some operating systems don't provide an errno 'EBADFD'; let's use EBADF there instead.

This patch adds the define in all files that need it, but if you prefer to add it to a central place instead, please suggest one.

How about put this in include/local.h instead? Then we need to put it only in one place, as this is supposed to be included by all codes.

Sounds good and works. New patch attached.
Thomas

Quoted 1 line

From ac054d580a774344adf2dcf198b50100a3f2967d Mon Sep 17 00:00:00 2001

From: Thomas Klausner <[email protected]>
Date: Wed, 24 Feb 2016 14:15:10 +0100
Subject: [PATCH] Define EBADFD in terms of EBADF if it doesn't exist.

For portability on FreeBSD, NetBSD and probably others.

---
 include/local.h | 4 ++++
 1 file changed, 4 insertions(+)
include/local.h +4 -0
index b429f5d..28ed106 100644
@@ -53,6 +53,10 @@
 #include <linux/types.h>
 #include <linux/ioctl.h>
 
+#ifndef EBADFD
+#define EBADFD EBADF
+#endif
+
 #ifdef SUPPORT_RESMGR
 #include <resmgr.h>
 #endif
Signature · 1 line
2.7.1
#5 lore raw

Re: portability patch: EBADF [was Re: feeding back pkgsrc changs]

Quoted 24 lines · Thomas Klausner
Quoted 22 lines · Takashi Iwai
Quoted 20 lines · Thomas Klausner

Thanks for the answer.

Quoted 6 lines · Takashi Iwai
Quoted 4 lines · Thomas Klausner

I've just updated the pkgsrc packages for alsa-lib, alsa-utils and alsa-plugins to 1.1.0 and noticed that there are quite a number of local patches we have. I'd like to get them integrated.

Quoted 7 lines
Quoted 4 lines

When I visited the alsa-projects web page, I noticed that the link to the bug tracker is dead.

What is the recommended method to provide the patches?

Just submit your patches to alsa-devel ML. That's the best way to review and get merged.

I'll start with a straightforward one. Some operating systems don't provide an errno 'EBADFD'; let's use EBADF there instead.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

This patch adds the define in all files that need it, but if you prefer to add it to a central place instead, please suggest one.

How about put this in include/local.h instead? Then we need to put it only in one place, as this is supposed to be included by all codes.

Sounds good and works. New patch attached.

Applied now. Thanks.

Takashi

#6 lore raw

portability: types

Quoted 1 line · Takashi Iwai

Applied now. Thanks.

Thank you.

The next big issue is that multiple places include Linux specific header files, easily recognizable by the path linux/*.h.

I think these are used to define unusual types like __u32, __u64, __kernel_off_t, __kernel_pid_t. There are also a number of cases of u_xxx_t (which don't exist on Solaris) vs. the uxxx_t defined in C99.

Many of these types have POSIX equivalents, like uint32_t, uint64_t, off_t, pid_t.

Would it be better to switch to those, or should we define compat #typedefs or #defines in local.h?

Cheers,
Thomas

#7 lore raw

Re: portability: types

Quoted 2 lines · Thomas Klausner

The next big issue is that multiple places include Linux specific header files, easily recognizable by the path linux/*.h.

Once upon a time, alsa-lib was used only on Linux (and also on old versions such as 2.2.x).

Quoted 9 lines

I think these are used to define unusual types like __u32, __u64, __kernel_off_t, __kernel_pid_t. There are also a number of cases of u_xxx_t (which don't exist on Solaris) vs. the uxxx_t defined in C99.

Many of these types have POSIX equivalents, like uint32_t, uint64_t, off_t, pid_t.

Would it be better to switch to those, or should we define compat #typedefs or #defines in local.h?

Linux-specific types should be used only in code that actually is Linux specific (i.e., the xxx_hw plugins).

Regards,
Clemens

#8 lore raw

PATCH 1/3 Use POSIX uint*_t instead of u_int*_t.

From: Thomas Klausner <[email protected]>

This helps in particular for Solaris portability.

---
 include/pcm.h             |   8 +-
 src/pcm/interval.c        |   4 +-
 src/pcm/mask_inline.h     |   6 +-
 src/pcm/pcm.c             |  26 +++----
 src/pcm/pcm_iec958.c      |  12 +--
 src/pcm/pcm_linear.c      |   2 +-
 src/pcm/pcm_misc.c        |  42 +++++------
 src/pcm/pcm_rate_linear.c |   4 +-
 src/pcm/pcm_route.c       |   2 +-
 src/pcm/plugin_ops.h      | 182 +++++++++++++++++++++++-----------------------
 10 files changed, 144 insertions(+), 144 deletions(-)
include/pcm.h +4 -4
index 0be1a32..d4f1543 100644
@@ -1108,10 +1108,10 @@ int snd_pcm_format_width(snd_pcm_format_t format);			/* in bits */
 int snd_pcm_format_physical_width(snd_pcm_format_t format);		/* in bits */
 snd_pcm_format_t snd_pcm_build_linear_format(int width, int pwidth, int unsignd, int big_endian);
 ssize_t snd_pcm_format_size(snd_pcm_format_t format, size_t samples);
-u_int8_t snd_pcm_format_silence(snd_pcm_format_t format);
-u_int16_t snd_pcm_format_silence_16(snd_pcm_format_t format);
-u_int32_t snd_pcm_format_silence_32(snd_pcm_format_t format);
-u_int64_t snd_pcm_format_silence_64(snd_pcm_format_t format);
+uint8_t snd_pcm_format_silence(snd_pcm_format_t format);
+uint16_t snd_pcm_format_silence_16(snd_pcm_format_t format);
+uint32_t snd_pcm_format_silence_32(snd_pcm_format_t format);
+uint64_t snd_pcm_format_silence_64(snd_pcm_format_t format);
 int snd_pcm_format_set_silence(snd_pcm_format_t format, void *buf, unsigned int samples);
 
 snd_pcm_sframes_t snd_pcm_bytes_to_frames(snd_pcm_t *pcm, ssize_t bytes);
src/pcm/interval.c +2 -2
index 6e39808..74ec320 100644
@@ -26,7 +26,7 @@
 #include <limits.h>
 #include "pcm_local.h"
 
-static inline void div64_32(u_int64_t *n, u_int32_t d, u_int32_t *rem)
+static inline void div64_32(uint64_t *n, uint32_t d, uint32_t *rem)
 {
 	*rem = *n % d;
 	*n /= d;
@@ -88,7 +88,7 @@ static inline unsigned int sub(unsigned int a, unsigned int b)
 static inline unsigned int muldiv32(unsigned int a, unsigned int b,
 				    unsigned int c, unsigned int *r)
 {
-	u_int64_t n = (u_int64_t) a * b;
+	uint64_t n = (uint64_t) a * b;
 	if (c == 0) {
 		assert(n > 0);
 		*r = 0;
src/pcm/mask_inline.h +3 -3
index f656568..04c7ee6 100644
@@ -29,7 +29,7 @@
 #define MASK_OFS(i)	((i) >> 5)
 #define MASK_BIT(i)	(1U << ((i) & 31))
 
-MASK_INLINE unsigned int ld2(u_int32_t v)
+MASK_INLINE unsigned int ld2(uint32_t v)
 {
         unsigned r = 0;
 
@@ -54,7 +54,7 @@ MASK_INLINE unsigned int ld2(u_int32_t v)
         return r;
 }
 
-MASK_INLINE unsigned int hweight32(u_int32_t v)
+MASK_INLINE unsigned int hweight32(uint32_t v)
 {
         v = (v & 0x55555555) + ((v >> 1) & 0x55555555);
         v = (v & 0x33333333) + ((v >> 2) & 0x33333333);
@@ -75,7 +75,7 @@ MASK_INLINE void snd_mask_none(snd_mask_t *mask)
 
 MASK_INLINE void snd_mask_any(snd_mask_t *mask)
 {
-	memset(mask, 0xff, MASK_SIZE * sizeof(u_int32_t));
+	memset(mask, 0xff, MASK_SIZE * sizeof(uint32_t));
 }
 
 MASK_INLINE int snd_mask_empty(const snd_mask_t *mask)
src/pcm/pcm.c +13 -13
index 203e7a5..3fe3b39 100644
@@ -2584,7 +2584,7 @@ int snd_pcm_area_silence(const snd_pcm_channel_area_t *dst_area, snd_pcm_uframes
 	char *dst;
 	unsigned int dst_step;
 	int width;
-	u_int64_t silence;
+	uint64_t silence;
 	if (!dst_area->addr)
 		return 0;
 	dst = snd_pcm_channel_area_addr(dst_area, dst_offset);
@@ -2592,7 +2592,7 @@ int snd_pcm_area_silence(const snd_pcm_channel_area_t *dst_area, snd_pcm_uframes
 	silence = snd_pcm_format_silence_64(format);
 	if (dst_area->step == (unsigned int) width) {
 		unsigned int dwords = samples * width / 64;
-		u_int64_t *dstp = (u_int64_t *)dst;
+		uint64_t *dstp = (uint64_t *)dst;
 		samples -= dwords * 64 / width;
 		while (dwords-- > 0)
 			*dstp++ = silence;
@@ -2602,8 +2602,8 @@ int snd_pcm_area_silence(const snd_pcm_channel_area_t *dst_area, snd_pcm_uframes
 	dst_step = dst_area->step / 8;
 	switch (width) {
 	case 4: {
-		u_int8_t s0 = silence & 0xf0;
-		u_int8_t s1 = silence & 0x0f;
+		uint8_t s0 = silence & 0xf0;
+		uint8_t s1 = silence & 0x0f;
 		int dstbit = dst_area->first % 8;
 		int dstbit_step = dst_area->step % 8;
 		while (samples-- > 0) {
@@ -2624,7 +2624,7 @@ int snd_pcm_area_silence(const snd_pcm_channel_area_t *dst_area, snd_pcm_uframes
 		break;
 	}
 	case 8: {
-		u_int8_t sil = silence;
+		uint8_t sil = silence;
 		while (samples-- > 0) {
 			*dst = sil;
 			dst += dst_step;
@@ -2632,9 +2632,9 @@ int snd_pcm_area_silence(const snd_pcm_channel_area_t *dst_area, snd_pcm_uframes
 		break;
 	}
 	case 16: {
-		u_int16_t sil = silence;
+		uint16_t sil = silence;
 		while (samples-- > 0) {
-			*(u_int16_t*)dst = sil;
+			*(uint16_t*)dst = sil;
 			dst += dst_step;
 		}
 		break;
@@ -2651,16 +2651,16 @@ int snd_pcm_area_silence(const snd_pcm_channel_area_t *dst_area, snd_pcm_uframes
 #endif
 		break;
 	case 32: {
-		u_int32_t sil = silence;
+		uint32_t sil = silence;
 		while (samples-- > 0) {
-			*(u_int32_t*)dst = sil;
+			*(uint32_t*)dst = sil;
 			dst += dst_step;
 		}
 		break;
 	}
 	case 64: {
 		while (samples-- > 0) {
-			*(u_int64_t*)dst = silence;
+			*(uint64_t*)dst = silence;
 			dst += dst_step;
 		}
 		break;
@@ -2804,7 +2804,7 @@ int snd_pcm_area_copy(const snd_pcm_channel_area_t *dst_area, snd_pcm_uframes_t
 	}
 	case 16: {
 		while (samples-- > 0) {
-			*(u_int16_t*)dst = *(const u_int16_t*)src;
+			*(uint16_t*)dst = *(const uint16_t*)src;
 			src += src_step;
 			dst += dst_step;
 		}
@@ -2821,7 +2821,7 @@ int snd_pcm_area_copy(const snd_pcm_channel_area_t *dst_area, snd_pcm_uframes_t
 		break;
 	case 32: {
 		while (samples-- > 0) {
-			*(u_int32_t*)dst = *(const u_int32_t*)src;
+			*(uint32_t*)dst = *(const uint32_t*)src;
 			src += src_step;
 			dst += dst_step;
 		}
@@ -2829,7 +2829,7 @@ int snd_pcm_area_copy(const snd_pcm_channel_area_t *dst_area, snd_pcm_uframes_t
 	}
 	case 64: {
 		while (samples-- > 0) {
-			*(u_int64_t*)dst = *(const u_int64_t*)src;
+			*(uint64_t*)dst = *(const uint64_t*)src;
 			src += src_step;
 			dst += dst_step;
 		}
src/pcm/pcm_iec958.c +6 -6
index 38c4ce7..a7fe0d7 100644
@@ -102,7 +102,7 @@ static unsigned int iec958_parity(unsigned int data)
  *     31   = parity
  */
 
-static inline u_int32_t iec958_subframe(snd_pcm_iec958_t *iec, u_int32_t data, int channel)
+static inline uint32_t iec958_subframe(snd_pcm_iec958_t *iec, uint32_t data, int channel)
 {
 	unsigned int byte = iec->counter >> 3;
 	unsigned int mask = 1 << (iec->counter - (byte << 3));
@@ -132,7 +132,7 @@ static inline u_int32_t iec958_subframe(snd_pcm_iec958_t *iec, u_int32_t data, i
 	return data;
 }
 
-static inline int32_t iec958_to_s32(snd_pcm_iec958_t *iec, u_int32_t data)
+static inline int32_t iec958_to_s32(snd_pcm_iec958_t *iec, uint32_t data)
 {
 	if (iec->byteswap)
 		data = bswap_32(data);
@@ -155,7 +155,7 @@ static void snd_pcm_iec958_decode(snd_pcm_iec958_t *iec,
 	void *put = put32_labels[iec->getput_idx];
 	unsigned int channel;
 	for (channel = 0; channel < channels; ++channel) {
-		const u_int32_t *src;
+		const uint32_t *src;
 		char *dst;
 		int src_step, dst_step;
 		snd_pcm_uframes_t frames1;
@@ -163,7 +163,7 @@ static void snd_pcm_iec958_decode(snd_pcm_iec958_t *iec,
 		const snd_pcm_channel_area_t *dst_area = &dst_areas[channel];
 		src = snd_pcm_channel_area_addr(src_area, src_offset);
 		dst = snd_pcm_channel_area_addr(dst_area, dst_offset);
-		src_step = snd_pcm_channel_area_step(src_area) / sizeof(u_int32_t);
+		src_step = snd_pcm_channel_area_step(src_area) / sizeof(uint32_t);
 		dst_step = snd_pcm_channel_area_step(dst_area);
 		frames1 = frames;
 		while (frames1-- > 0) {
@@ -195,7 +195,7 @@ static void snd_pcm_iec958_encode(snd_pcm_iec958_t *iec,
 	int counter = iec->counter;
 	for (channel = 0; channel < channels; ++channel) {
 		const char *src;
-		u_int32_t *dst;
+		uint32_t *dst;
 		int src_step, dst_step;
 		snd_pcm_uframes_t frames1;
 		const snd_pcm_channel_area_t *src_area = &src_areas[channel];
@@ -203,7 +203,7 @@ static void snd_pcm_iec958_encode(snd_pcm_iec958_t *iec,
 		src = snd_pcm_channel_area_addr(src_area, src_offset);
 		dst = snd_pcm_channel_area_addr(dst_area, dst_offset);
 		src_step = snd_pcm_channel_area_step(src_area);
-		dst_step = snd_pcm_channel_area_step(dst_area) / sizeof(u_int32_t);
+		dst_step = snd_pcm_channel_area_step(dst_area) / sizeof(uint32_t);
 		frames1 = frames;
 		iec->counter = counter;
 		while (frames1-- > 0) {
src/pcm/pcm_linear.c +1 -1
index 9a92abd..8b21049 100644
@@ -183,7 +183,7 @@ void snd_pcm_linear_getput(const snd_pcm_channel_area_t *dst_areas, snd_pcm_ufra
 	void *get = get32_labels[get_idx];
 	void *put = put32_labels[put_idx];
 	unsigned int channel;
-	u_int32_t sample = 0;
+	uint32_t sample = 0;
 	for (channel = 0; channel < channels; ++channel) {
 		const char *src;
 		char *dst;
src/pcm/pcm_misc.c +21 -21

130 lines not on this page · raw message

src/pcm/pcm_rate_linear.c +2 -2
index 7481b38..4863938 100644
@@ -346,7 +346,7 @@ static int linear_init(void *obj, snd_pcm_rate_info_t *info)
 			rate->func = linear_shrink;
 		/* pitch is get_increment */
 	}
-	rate->pitch = (((u_int64_t)info->out.rate * LINEAR_DIV) +
+	rate->pitch = (((uint64_t)info->out.rate * LINEAR_DIV) +
 		       (info->in.rate / 2)) / info->in.rate;
 	rate->channels = info->channels;
 
@@ -363,7 +363,7 @@ static int linear_adjust_pitch(void *obj, snd_pcm_rate_info_t *info)
 	struct rate_linear *rate = obj;
 	snd_pcm_uframes_t cframes;
 
-	rate->pitch = (((u_int64_t)info->out.period_size * LINEAR_DIV) +
+	rate->pitch = (((uint64_t)info->out.period_size * LINEAR_DIV) +
 		       (info->in.period_size/2) ) / info->in.period_size;
 			
 	cframes = input_frames(rate, info->out.period_size);
src/pcm/pcm_route.c +1 -1
index 646517d..c8e752f 100644
@@ -190,7 +190,7 @@ static void snd_pcm_route_convert1_one_getput(const snd_pcm_channel_area_t *dst_
 	const char *src;
 	char *dst;
 	int src_step, dst_step;
-	u_int32_t sample = 0;
+	uint32_t sample = 0;
 	for (srcidx = 0; srcidx < ttable->nsrcs && srcidx < src_channels; ++srcidx) {
 		unsigned int channel = ttable->srcs[srcidx].channel;
 		if (channel >= src_channels)
src/pcm/plugin_ops.h +91 -91

305 lines not on this page · raw message

Signature · 1 line
2.7.1
#9 lore raw

PATCH 2/3 Use pid_t, off_t instead of __kernel_*_t for better portability.

From: Thomas Klausner <[email protected]>

---
 include/sound/asound.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
include/sound/asound.h +2 -2
index a82108e..4f2202f 100644
@@ -415,7 +415,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 */
 };
@@ -884,7 +884,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 */
Signature · 1 line
2.7.1
#10 lore raw

Re: [PATCH 2/3] Use pid_t, off_t instead of __kernel_*_t for better portability.

Quoted 5 lines · Thomas Klausner

From: Thomas Klausner <[email protected]>

---
 include/sound/asound.h | 4 ++--

Sorry, this is no-go. The files in include/sound/* are basically copies of Linux ABI. So, all these files must not be modified in alsa-lib side. And, using __kernel_off_t there is in purpose -- to distinguish from the user-space off_t.

That said, the best workaround for these files are to provide the compatible typedefs.

OTOH, the code changes in include/pcm.h and src/pcm/* are acceptable, in general, but I still hesitate to apply it, so far. If it's only about portability, we may wrap it with a few typedefs instead of touching so many lines. And it would bring any other real benefit? It's the question...

thanks,

Takashi

Quoted 32 lines
 1 file changed, 2 insertions(+), 2 deletions(-)
include/sound/asound.h +2 -2
index a82108e..4f2202f 100644
@@ -415,7 +415,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 */
 };
@@ -884,7 +884,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 */
Signature · 6 lines
2.7.1

_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
#11 lore raw

PATCH 1/1 define more missing types for non-Linux

Hi!

Quoted 8 lines · Takashi Iwai
Quoted 5 lines · Thomas Klausner

From: Thomas Klausner <[email protected]>

---
 include/sound/asound.h | 4 ++--
Quoted 7 lines

Sorry, this is no-go. The files in include/sound/* are basically copies of Linux ABI. So, all these files must not be modified in alsa-lib side. And, using __kernel_off_t there is in purpose -- to distinguish from the user-space off_t.

That said, the best workaround for these files are to provide the compatible typedefs.

So how about the attached patch instead?

Quoted 5 lines

OTOH, the code changes in include/pcm.h and src/pcm/* are acceptable, in general, but I still hesitate to apply it, so far. If it's only about portability, we may wrap it with a few typedefs instead of touching so many lines. And it would bring any other real benefit? It's the question...

I still prefer uint* to u_int* because uint* is in POSIX and u_int* is not, but I added the necessary defines in the new patch.
Thomas

Quoted 1 line

From 634255a4d87a12132bb65868f5658fd14cd2bfd7 Mon Sep 17 00:00:00 2001

From: Thomas Klausner <[email protected]>
Date: Wed, 2 Mar 2016 23:11:54 +0100
Subject: [PATCH] Define some types if missing.

For portability with non-Linux.

Include Linux header on Linux only.

---
 include/local.h | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)
include/local.h +39 -0
index 28ed106..9728598 100644
@@ -50,13 +50,52 @@
 #include <sys/poll.h>
 #include <sys/types.h>
 #include <errno.h>
+#if defined(__linux__)
 #include <linux/types.h>
 #include <linux/ioctl.h>
+#endif
 
 #ifndef EBADFD
 #define EBADFD EBADF
 #endif
 
+#ifndef __u16
+#define __u16	uint16_t
+#endif
+#ifndef __u32
+#define __u32	uint32_t
+#endif
+#ifndef __u64
+#define __u64	uint64_t
+#endif
+#ifndef __le16
+#define __le16	uint16_t
+#endif
+#ifndef __le32
+#define __le32	uint32_t
+#endif
+#ifndef __le64
+#define __le64	uint64_t
+#endif
+#ifndef u_int8_t
+#define u_int8_t	uint8_t
+#endif
+#ifndef u_int16_t
+#define u_int16_t	uint16_t
+#endif
+#ifndef u_int32_t
+#define u_int32_t	uint32_t
+#endif
+#ifndef u_int32_t
+#define u_int32_t	uint64_t
+#endif
+#ifndef __kernel_pid_t
+#define __kernel_pid_t	pid_t
+#endif
+#ifndef __kernel_off_t
+#define __kernel_off_t	off_t
+#endif
+
 #ifdef SUPPORT_RESMGR
 #include <resmgr.h>
 #endif
Signature · 1 line
2.7.1
#12 lore raw

Re: [PATCH] define more missing types for non-Linux

Quoted 56 lines · Thomas Klausner
Quoted 2 lines

From 634255a4d87a12132bb65868f5658fd14cd2bfd7 Mon Sep 17 00:00:00 2001

From: Thomas Klausner <[email protected]>
Date: Wed, 2 Mar 2016 23:11:54 +0100
Subject: [PATCH] Define some types if missing.

For portability with non-Linux.

Include Linux header on Linux only.

---
 include/local.h | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)
include/local.h +28 -0
index 28ed106..9728598 100644
@@ -50,13 +50,52 @@
 #include <sys/poll.h>
 #include <sys/types.h>
 #include <errno.h>
+#if defined(__linux__)
 #include <linux/types.h>
 #include <linux/ioctl.h>
+#endif
 
 #ifndef EBADFD
 #define EBADFD EBADF
 #endif
 
+#ifndef __u16
+#define __u16	uint16_t
+#endif
+#ifndef __u32
+#define __u32	uint32_t
+#endif
+#ifndef __u64
+#define __u64	uint64_t
+#endif
+#ifndef __le16
+#define __le16	uint16_t
+#endif
+#ifndef __le32
+#define __le32	uint32_t
+#endif
+#ifndef __le64
+#define __le64	uint64_t
+#endif
+#ifndef u_int8_t
+#define u_int8_t	uint8_t
+#endif
+#ifndef u_int16_t
+#define u_int16_t	uint16_t
+#endif
+#ifndef u_int32_t
+#define u_int32_t	uint32_t

include/local.h line 97

Quoted 10 lines
include/local.h +10 -0
+#endif
+#ifndef u_int32_t
+#define u_int32_t	uint64_t
+#endif
+#ifndef __kernel_pid_t
+#define __kernel_pid_t	pid_t
+#endif
+#ifndef __kernel_off_t
+#define __kernel_off_t	off_t
+#endif

Can we put this in include/type_compat.h or something like that, and include it in #else block of #ifdef __linux__?

As a bonus, the EBADFD definition can also go to there, too.

thanks,

Takashi

#13 lore raw

Re: [PATCH] define more missing types for non-Linux

Quoted 4 lines · Takashi Iwai

Can we put this in include/type_compat.h or something like that, and include it in #else block of #ifdef __linux__?

As a bonus, the EBADFD definition can also go to there, too.

Sure, see attached.
Thomas

Quoted 1 line

From c68bfda4e5198b50b32937de669155afb423d726 Mon Sep 17 00:00:00 2001

From: Thomas Klausner <[email protected]>
Date: Wed, 2 Mar 2016 23:11:54 +0100
Subject: [PATCH] Define some types if missing.

For portability with non-Linux.

Include Linux headers on Linux only.

---
 include/local.h       |  6 ++---
 include/type_compat.h | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 69 insertions(+), 3 deletions(-)
 create mode 100644 include/type_compat.h
include/local.h +3 -3
index 28ed106..317f2e3 100644
@@ -50,11 +50,11 @@
 #include <sys/poll.h>
 #include <sys/types.h>
 #include <errno.h>
+#if defined(__linux__)
 #include <linux/types.h>
 #include <linux/ioctl.h>
-
-#ifndef EBADFD
-#define EBADFD EBADF
+#else
+#include "type_compat.h"
 #endif
 
 #ifdef SUPPORT_RESMGR
include/type_compat.h new file +66 -0

66 lines not on this page · raw message

Signature · 1 line
2.7.1
#14 lore raw

Re: [PATCH] define more missing types for non-Linux

Quoted 14 lines · Thomas Klausner
Quoted 4 lines · Takashi Iwai

Can we put this in include/type_compat.h or something like that, and include it in #else block of #ifdef __linux__?

As a bonus, the EBADFD definition can also go to there, too.

Sure, see attached.
Thomas

Quoted 1 line

From c68bfda4e5198b50b32937de669155afb423d726 Mon Sep 17 00:00:00 2001

From: Thomas Klausner <[email protected]>
Date: Wed, 2 Mar 2016 23:11:54 +0100
Subject: [PATCH] Define some types if missing.

Quoted 8 lines

For portability with non-Linux.

Include Linux headers on Linux only.

---
 include/local.h       |  6 ++---
 include/type_compat.h | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 69 insertions(+), 3 deletions(-)
 create mode 100644 include/type_compat.h

You need to add it in include/Makefile.am, too.
Otherwise it'll slip from the tarball.

Takashi

#15 lore raw

Re: [PATCH] define more missing types for non-Linux

Quoted 26 lines · Takashi Iwai
Quoted 14 lines · Thomas Klausner
Quoted 4 lines · Takashi Iwai

Can we put this in include/type_compat.h or something like that, and include it in #else block of #ifdef __linux__?

As a bonus, the EBADFD definition can also go to there, too.

Sure, see attached.
Thomas

Quoted 1 line

From c68bfda4e5198b50b32937de669155afb423d726 Mon Sep 17 00:00:00 2001

From: Thomas Klausner <[email protected]>
Date: Wed, 2 Mar 2016 23:11:54 +0100
Subject: [PATCH] Define some types if missing.

Quoted 8 lines

For portability with non-Linux.

Include Linux headers on Linux only.

---
 include/local.h       |  6 ++---
 include/type_compat.h | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 69 insertions(+), 3 deletions(-)
 create mode 100644 include/type_compat.h
Quoted 2 lines

You need to add it in include/Makefile.am, too.
Otherwise it'll slip from the tarball.

Oh, also it'd be good if you give your sign-off, too.
For user-space, I accept the patches without sign-off as long as they are trivial enough. But this kind of change is preferred with a proper sign off, of course.

thanks,

Takashi

#16 lore raw

Re: [PATCH] define more missing types for non-Linux

Quoted 4 lines · Takashi Iwai
Quoted 2 lines · Takashi Iwai

You need to add it in include/Makefile.am, too.
Otherwise it'll slip from the tarball.

Good catch, added.

Quoted 4 lines

Oh, also it'd be good if you give your sign-off, too.
For user-space, I accept the patches without sign-off as long as they are trivial enough. But this kind of change is preferred with a proper sign off, of course.

Sure!
Thomas

Quoted 1 line

From 0d0a1408432a27cfa1908373bccbb66ac413fc5d Mon Sep 17 00:00:00 2001

From: Thomas Klausner <[email protected]>
Date: Wed, 2 Mar 2016 23:11:54 +0100
Subject: [PATCH] Define some types if missing.

Include Linux headers on Linux only.
For portability with non-Linux.

---
 include/Makefile.am   |  2 +-
 include/local.h       |  6 ++---
 include/type_compat.h | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 70 insertions(+), 4 deletions(-)
 create mode 100644 include/type_compat.h
include/Makefile.am +1 -1
index ff931fd..8c83c11 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
+	asoundlib-head.h asoundlib-tail.h type_compat.h
 
 DISTCLEANFILES = stamp-vh version.h alsa asoundlib.h
 
include/local.h +3 -3
index 28ed106..317f2e3 100644
@@ -50,11 +50,11 @@
 #include <sys/poll.h>
 #include <sys/types.h>
 #include <errno.h>
+#if defined(__linux__)
 #include <linux/types.h>
 #include <linux/ioctl.h>
-
-#ifndef EBADFD
-#define EBADFD EBADF
+#else
+#include "type_compat.h"
 #endif
 
 #ifdef SUPPORT_RESMGR
include/type_compat.h new file +66 -0

66 lines not on this page · raw message

Signature · 1 line
2.7.1
#17 lore raw

Re: [PATCH] define more missing types for non-Linux

Quoted 7 lines · Thomas Klausner
Quoted 4 lines · Takashi Iwai
Quoted 2 lines · Takashi Iwai

You need to add it in include/Makefile.am, too.
Otherwise it'll slip from the tarball.

Quoted 8 lines

Good catch, added.

Quoted 4 lines

Oh, also it'd be good if you give your sign-off, too.
For user-space, I accept the patches without sign-off as long as they are trivial enough. But this kind of change is preferred with a proper sign off, of course.

Sure!

Applied now. Thanks.

Takashi

#18 lore raw

byteswap.h

Quoted 1 line · Takashi Iwai

Applied now. Thanks.

Thank you!

Next big issue: Many places include byteswap.h to get bswap_16, bswap_32, bswap_64.

This header does not exist on *BSD or Solaris.

However, all of these provide similar macros under different names, from different header files (bswap16 etc, or BSWAP_16).

Do you want a compat header, e.g. include/bswap.h that takes care of this and is included by local.h, or do you prefer a different solution?
Thomas

#19 lore raw

Re: byteswap.h

Quoted 9 lines · Thomas Klausner
Quoted 1 line · Takashi Iwai

Applied now. Thanks.

Thank you!

Next big issue: Many places include byteswap.h to get bswap_16, bswap_32, bswap_64.

Quoted 8 lines

This header does not exist on *BSD or Solaris.

However, all of these provide similar macros under different names, from different header files (bswap16 etc, or BSWAP_16).

Do you want a compat header, e.g. include/bswap.h that takes care of this and is included by local.h, or do you prefer a different solution?

bswap.h looks better ATM. Let's see.

Takashi

#20 lore raw

Re: byteswap.h

Quoted 13 lines · Takashi Iwai
Quoted 11 lines · Thomas Klausner
Quoted 1 line · Takashi Iwai

Applied now. Thanks.

Thank you!

Next big issue: Many places include byteswap.h to get bswap_16, bswap_32, bswap_64.

This header does not exist on *BSD or Solaris.

Quoted 8 lines
Quoted 6 lines

However, all of these provide similar macros under different names, from different header files (bswap16 etc, or BSWAP_16).

Do you want a compat header, e.g. include/bswap.h that takes care of this and is included by local.h, or do you prefer a different solution?

bswap.h looks better ATM. Let's see.

Ok, here's my try for a version of bswap.h. Does it look ok?
Thomas

Quoted 1 line

From 03185793bc290ad2de4506a553f9855ff7241fa0 Mon Sep 17 00:00:00 2001

From: Thomas Klausner <[email protected]>
Date: Thu, 3 Mar 2016 12:16:57 +0100
Subject: [PATCH] Introduce bswap.h for portable definitions of byte swap
macros.

---
 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
#21 lore raw

Re: byteswap.h

Quoted 18 lines · Thomas Klausner
Quoted 16 lines · Takashi Iwai
Quoted 14 lines · Thomas Klausner
Quoted 1 line · Takashi Iwai

Applied now. Thanks.

Thank you!

Next big issue: Many places include byteswap.h to get bswap_16, bswap_32, bswap_64.

This header does not exist on *BSD or Solaris.

However, all of these provide similar macros under different names, from different header files (bswap16 etc, or BSWAP_16).

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

Do you want a compat header, e.g. include/bswap.h that takes care of this and is included by local.h, or do you prefer a different solution?

bswap.h looks better ATM. Let's see.

Ok, here's my try for a version of bswap.h. Does it look ok?

Looks good to me -- supposing you tested it actually :)

Takashi

#22 lore raw

Re: byteswap.h

Quoted 24 lines · Takashi Iwai
Quoted 22 lines · Thomas Klausner
Quoted 20 lines · Takashi Iwai
Quoted 17 lines · Thomas Klausner
Quoted 1 line · Takashi Iwai

Applied now. Thanks.

Thank you!

Next big issue: Many places include byteswap.h to get bswap_16, bswap_32, bswap_64.

This header does not exist on *BSD or Solaris.

However, all of these provide similar macros under different names, from different header files (bswap16 etc, or BSWAP_16).

Do you want a compat header, e.g. include/bswap.h that takes care of this and is included by local.h, or do you prefer a different solution?

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

bswap.h looks better ATM. Let's see.

Ok, here's my try for a version of bswap.h. Does it look ok?

Looks good to me -- supposing you tested it actually :)

This particular patch was only compile-tested on NetBSD, but a quite similar ifdef has been in pkgsrc for years and has survived a number of bulk builds over the years.
Thomas

#23 lore raw

Remaining compatibility patches for NetBSD

Here are the remaining patches to make the build succeed on NetBSD. More patches are needed for FreeBSD and Solaris, but let's take it one at a time :-)

I think the first two (0002 and 0003) should be uncontroversial.

For patch 0004 it would perhaps be good to have versionsort/alphasort in a central place instead of two. Do you have a suggestion where?

I'm not sure what to do about 0005 since you said you don't want to modify include/sound/asound.h.

endian.h seems to be unneeded on src/topology/tplg_local.h; if it's needed, I can move it inside the #ifdef.
Thomas

Quoted 1 line

From b8abae028c02294906e99b1bc66423a89dce54ec Mon Sep 17 00:00:00 2001

From: Thomas Klausner <[email protected]>
Date: Thu, 3 Mar 2016 12:56:58 +0100
Subject: [PATCH 2/5] Add more compatibility defines.

---
 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
Quoted 1 line

From 72ada4937e512055abd39f83f31214d1e7ee4ebe Mon Sep 17 00:00:00 2001

From: Thomas Klausner <[email protected]>
Date: Thu, 3 Mar 2016 12:57:34 +0100
Subject: [PATCH 3/5] Only use F_SETSIG fcntl where it exists.

---
 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
Quoted 1 line

From 23ec0e49db34590c8d74b336d7fe0f97dcf28f26 Mon Sep 17 00:00:00 2001

From: Thomas Klausner <[email protected]>
Date: Thu, 3 Mar 2016 12:58:07 +0100
Subject: [PATCH 4/5] Use alphasort where versionsort is not available.

---
 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
Quoted 1 line

From 678c4fd1ada7fb79988df0431312fcdfac9911f8 Mon Sep 17 00:00:00 2001

From: Thomas Klausner <[email protected]>
Date: Thu, 3 Mar 2016 12:58:30 +0100
Subject: [PATCH 5/5] Wrap linux-specific headers in #ifdef __linux__

---
 include/sound/asound.h    | 4 ++++
 src/topology/tplg_local.h | 3 ++-
 2 files changed, 6 insertions(+), 1 deletion(-)
include/sound/asound.h +4 -0
index a82108e..3d581b5 100644
@@ -23,7 +23,11 @@
 #ifndef _UAPI__SOUND_ASOUND_H
 #define _UAPI__SOUND_ASOUND_H
 
+#ifdef __linux__
 #include <linux/types.h>
+#else
+#include <sys/ioctl.h>
+#endif
 
 #ifndef __KERNEL__
 #include <stdlib.h>
src/topology/tplg_local.h +2 -1
index e66d7f4..2b44edd 100644
@@ -13,8 +13,9 @@
 #include <limits.h>
 #include <stdint.h>
 #include <stdbool.h>
-#include <endian.h>
+#ifdef __linux__
 #include <linux/types.h>
+#endif
 
 #include "local.h"
 #include "list.h"
Signature · 1 line
2.7.1
#24 lore raw

Re: Remaining compatibility patches for NetBSD

Quoted 5 lines · Thomas Klausner

Here are the remaining patches to make the build succeed on NetBSD. More patches are needed for FreeBSD and Solaris, but let's take it one at a time :-)

Quoted 7 lines

I think the first two (0002 and 0003) should be uncontroversial.

For patch 0004 it would perhaps be good to have versionsort/alphasort in a central place instead of two. Do you have a suggestion where?

I'm not sure what to do about 0005 since you said you don't want to modify include/sound/asound.h.

Right. If we need to modify, it must be applied to Linux kernel tree at first, then copy back to alsa-lib.

Quoted 2 lines

endian.h seems to be unneeded on src/topology/tplg_local.h; if it's needed, I can move it inside the #ifdef.

src/topology/parser.c contains the code depending on the endian. The include can be moved there, too.

Takashi

#25 lore raw

Re: Remaining compatibility patches for NetBSD

Quoted 9 lines · Takashi Iwai
Quoted 7 lines · Thomas Klausner

Here are the remaining patches to make the build succeed on NetBSD. More patches are needed for FreeBSD and Solaris, but let's take it one at a time :-)

I think the first two (0002 and 0003) should be uncontroversial.

Quoted 8 lines
Quoted 5 lines

For patch 0004 it would perhaps be good to have versionsort/alphasort in a central place instead of two. Do you have a suggestion where?

I'm not sure what to do about 0005 since you said you don't want to modify include/sound/asound.h.

Right. If we need to modify, it must be applied to Linux kernel tree at first, then copy back to alsa-lib.

I haven't done this before.

I see on https://www.kernel.org/doc/linux/MAINTAINERS

SOUND
M: Jaroslav Kysela <[email protected]>
M: Takashi Iwai <[email protected]>
L: [email protected] (moderated for non-subscribers)
W: http://www.alsa-project.org/
T: git git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git
T: git git://git.alsa-project.org/alsa-kernel.git
Q: http://patchwork.kernel.org/project/alsa-devel/list/
S: Maintained
F: Documentation/sound/
F: include/sound/
F: include/uapi/sound/
F: sound/

Against which of the two git trees should I prepare the patch?

Quoted 5 lines
Quoted 2 lines

endian.h seems to be unneeded on src/topology/tplg_local.h; if it's needed, I can move it inside the #ifdef.

src/topology/parser.c contains the code depending on the endian. The include can be moved there, too.

local.h already handles endianness:

#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

So I think the endian.h include is not necessary and can just be removed.
Thomas

#26 lore raw

Re: Remaining compatibility patches for NetBSD

Quoted 38 lines · Thomas Klausner
Quoted 9 lines · Takashi Iwai
Quoted 7 lines · Thomas Klausner

Here are the remaining patches to make the build succeed on NetBSD. More patches are needed for FreeBSD and Solaris, but let's take it one at a time :-)

I think the first two (0002 and 0003) should be uncontroversial.

Quoted 8 lines
Quoted 5 lines

For patch 0004 it would perhaps be good to have versionsort/alphasort in a central place instead of two. Do you have a suggestion where?

I'm not sure what to do about 0005 since you said you don't want to modify include/sound/asound.h.

Right. If we need to modify, it must be applied to Linux kernel tree at first, then copy back to alsa-lib.

I haven't done this before.

I see on https://www.kernel.org/doc/linux/MAINTAINERS

SOUND
M: Jaroslav Kysela <[email protected]>
M: Takashi Iwai <[email protected]>
L: [email protected] (moderated for non-subscribers)
W: http://www.alsa-project.org/
T: git git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git
T: git git://git.alsa-project.org/alsa-kernel.git
Q: http://patchwork.kernel.org/project/alsa-devel/list/
S: Maintained
F: Documentation/sound/
F: include/sound/
F: include/uapi/sound/
F: sound/

Quoted 1 line

Against which of the two git trees should I prepare the patch?

Use my sound git tree.

Quoted 25 lines
Quoted 5 lines
Quoted 2 lines

endian.h seems to be unneeded on src/topology/tplg_local.h; if it's needed, I can move it inside the #ifdef.

src/topology/parser.c contains the code depending on the endian. The include can be moved there, too.

local.h already handles endianness:

#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

Quoted 1 line

So I think the endian.h include is not necessary and can just be removed.

Yes, looks so.

Takashi

#27 lore raw

Re: Remaining compatibility patches for NetBSD

Quoted 40 lines · Takashi Iwai
Quoted 38 lines · Thomas Klausner
Quoted 9 lines · Takashi Iwai
Quoted 7 lines · Thomas Klausner

Here are the remaining patches to make the build succeed on NetBSD. More patches are needed for FreeBSD and Solaris, but let's take it one at a time :-)

I think the first two (0002 and 0003) should be uncontroversial.

Quoted 8 lines
Quoted 5 lines

For patch 0004 it would perhaps be good to have versionsort/alphasort in a central place instead of two. Do you have a suggestion where?

I'm not sure what to do about 0005 since you said you don't want to modify include/sound/asound.h.

Right. If we need to modify, it must be applied to Linux kernel tree at first, then copy back to alsa-lib.

I haven't done this before.

I see on https://www.kernel.org/doc/linux/MAINTAINERS

SOUND
M: Jaroslav Kysela <[email protected]>
M: Takashi Iwai <[email protected]>
L: [email protected] (moderated for non-subscribers)
W: http://www.alsa-project.org/
T: git git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git
T: git git://git.alsa-project.org/alsa-kernel.git
Q: http://patchwork.kernel.org/project/alsa-devel/list/
S: Maintained
F: Documentation/sound/
F: include/sound/
F: include/uapi/sound/
F: sound/

Quoted 3 lines
Quoted 1 line

Against which of the two git trees should I prepare the patch?

Use my sound git tree.

Ok, I've just sent a patch against that repository to this mailing list.
Thomas

#28 lore raw

PATCH 3/3 Use uint*_t instead of __le*.

In reply to Thomas Klausner

From: Thomas Klausner <[email protected]>

For better portability.

---
 include/sound/asoc.h | 178 +++++++++++++++++++++++++--------------------------
 1 file changed, 89 insertions(+), 89 deletions(-)
include/sound/asoc.h +89 -89
index a29c05c..05bdae7 100644
@@ -112,15 +112,15 @@
  * This header precedes all object and object arrays below.
  */
 struct snd_soc_tplg_hdr {
-	__le32 magic;		/* magic number */
-	__le32 abi;		/* ABI version */
-	__le32 version;		/* optional vendor specific version details */
-	__le32 type;		/* SND_SOC_TPLG_TYPE_ */
-	__le32 size;		/* size of this structure */
-	__le32 vendor_type;	/* optional vendor specific type info */
-	__le32 payload_size;	/* data bytes, excluding this header */
-	__le32 index;		/* identifier for block */
-	__le32 count;		/* number of elements in block */
+	uint32_t magic;		/* magic number */
+	uint32_t abi;		/* ABI version */
+	uint32_t version;		/* optional vendor specific version details */
+	uint32_t type;		/* SND_SOC_TPLG_TYPE_ */
+	uint32_t size;		/* size of this structure */
+	uint32_t vendor_type;	/* optional vendor specific type info */
+	uint32_t payload_size;	/* data bytes, excluding this header */
+	uint32_t index;		/* identifier for block */
+	uint32_t count;		/* number of elements in block */
 } __attribute__((packed));
 
 /*
@@ -129,7 +129,7 @@ struct snd_soc_tplg_hdr {
  * firmware. Core will ignore this data.
  */
 struct snd_soc_tplg_private {
-	__le32 size;	/* in bytes of private data */
+	uint32_t size;	/* in bytes of private data */
 	char data[0];
 } __attribute__((packed));
 
@@ -137,16 +137,16 @@ struct snd_soc_tplg_private {
  * Kcontrol TLV data.
  */
 struct snd_soc_tplg_tlv_dbscale {
-	__le32 min;
-	__le32 step;
-	__le32 mute;
+	uint32_t min;
+	uint32_t step;
+	uint32_t mute;
 } __attribute__((packed));
 
 struct snd_soc_tplg_ctl_tlv {
-	__le32 size;	/* in bytes of this structure */
-	__le32 type;	/* SNDRV_CTL_TLVT_*, type of TLV */
+	uint32_t size;	/* in bytes of this structure */
+	uint32_t type;	/* SNDRV_CTL_TLVT_*, type of TLV */
 	union {
-		__le32 data[SND_SOC_TPLG_TLV_SIZE];
+		uint32_t data[SND_SOC_TPLG_TLV_SIZE];
 		struct snd_soc_tplg_tlv_dbscale scale;
 	};
 } __attribute__((packed));
@@ -155,10 +155,10 @@ struct snd_soc_tplg_ctl_tlv {
  * Kcontrol channel data
  */
 struct snd_soc_tplg_channel {
-	__le32 size;	/* in bytes of this structure */
-	__le32 reg;
-	__le32 shift;
-	__le32 id;	/* ID maps to Left, Right, LFE etc */
+	uint32_t size;	/* in bytes of this structure */
+	uint32_t reg;
+	uint32_t shift;
+	uint32_t id;	/* ID maps to Left, Right, LFE etc */
 } __attribute__((packed));
 
 /*
@@ -167,19 +167,19 @@ struct snd_soc_tplg_channel {
  * Bytes ext ops need get/put.
  */
 struct snd_soc_tplg_io_ops {
-	__le32 get;
-	__le32 put;
-	__le32 info;
+	uint32_t get;
+	uint32_t put;
+	uint32_t info;
 } __attribute__((packed));
 
 /*
  * kcontrol header
  */
 struct snd_soc_tplg_ctl_hdr {
-	__le32 size;	/* in bytes of this structure */
-	__le32 type;
+	uint32_t size;	/* in bytes of this structure */
+	uint32_t type;
 	char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
-	__le32 access;
+	uint32_t access;
 	struct snd_soc_tplg_io_ops ops;
 	struct snd_soc_tplg_ctl_tlv tlv;
 } __attribute__((packed));
@@ -188,33 +188,33 @@ struct snd_soc_tplg_ctl_hdr {
  * Stream Capabilities
  */
 struct snd_soc_tplg_stream_caps {
-	__le32 size;		/* in bytes of this structure */
+	uint32_t size;		/* in bytes of this structure */
 	char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
-	__le64 formats;	/* supported formats SNDRV_PCM_FMTBIT_* */
-	__le32 rates;		/* supported rates SNDRV_PCM_RATE_* */
-	__le32 rate_min;	/* min rate */
-	__le32 rate_max;	/* max rate */
-	__le32 channels_min;	/* min channels */
-	__le32 channels_max;	/* max channels */
-	__le32 periods_min;	/* min number of periods */
-	__le32 periods_max;	/* max number of periods */
-	__le32 period_size_min;	/* min period size bytes */
-	__le32 period_size_max;	/* max period size bytes */
-	__le32 buffer_size_min;	/* min buffer size bytes */
-	__le32 buffer_size_max;	/* max buffer size bytes */
+	uint64_t formats;	/* supported formats SNDRV_PCM_FMTBIT_* */
+	uint32_t rates;		/* supported rates SNDRV_PCM_RATE_* */
+	uint32_t rate_min;	/* min rate */
+	uint32_t rate_max;	/* max rate */
+	uint32_t channels_min;	/* min channels */
+	uint32_t channels_max;	/* max channels */
+	uint32_t periods_min;	/* min number of periods */
+	uint32_t periods_max;	/* max number of periods */
+	uint32_t period_size_min;	/* min period size bytes */
+	uint32_t period_size_max;	/* max period size bytes */
+	uint32_t buffer_size_min;	/* min buffer size bytes */
+	uint32_t buffer_size_max;	/* max buffer size bytes */
 } __attribute__((packed));
 
 /*
  * FE or BE Stream configuration supported by SW/FW
  */
 struct snd_soc_tplg_stream {
-	__le32 size;		/* in bytes of this structure */
+	uint32_t size;		/* in bytes of this structure */
 	char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; /* Name of the stream */
-	__le64 format;		/* SNDRV_PCM_FMTBIT_* */
-	__le32 rate;		/* SNDRV_PCM_RATE_* */
-	__le32 period_bytes;	/* size of period in bytes */
-	__le32 buffer_bytes;	/* size of buffer in bytes */
-	__le32 channels;	/* channels */
+	uint64_t format;		/* SNDRV_PCM_FMTBIT_* */
+	uint32_t rate;		/* SNDRV_PCM_RATE_* */
+	uint32_t period_bytes;	/* size of period in bytes */
+	uint32_t buffer_bytes;	/* size of buffer in bytes */
+	uint32_t channels;	/* channels */
 } __attribute__((packed));
 
 /*
@@ -230,12 +230,12 @@ struct snd_soc_tplg_stream {
  * +-----------------------------------+----+
  */
 struct snd_soc_tplg_manifest {
-	__le32 size;		/* in bytes of this structure */
-	__le32 control_elems;	/* number of control elements */
-	__le32 widget_elems;	/* number of widget elements */
-	__le32 graph_elems;	/* number of graph elements */
-	__le32 pcm_elems;	/* number of PCM elements */
-	__le32 dai_link_elems;	/* number of DAI link elements */
+	uint32_t size;		/* in bytes of this structure */
+	uint32_t control_elems;	/* number of control elements */
+	uint32_t widget_elems;	/* number of widget elements */
+	uint32_t graph_elems;	/* number of graph elements */
+	uint32_t pcm_elems;	/* number of PCM elements */
+	uint32_t dai_link_elems;	/* number of DAI link elements */
 	struct snd_soc_tplg_private priv;
 } __attribute__((packed));
 
@@ -251,12 +251,12 @@ struct snd_soc_tplg_manifest {
  */
 struct snd_soc_tplg_mixer_control {
 	struct snd_soc_tplg_ctl_hdr hdr;
-	__le32 size;	/* in bytes of this structure */
-	__le32 min;
-	__le32 max;
-	__le32 platform_max;
-	__le32 invert;
-	__le32 num_channels;
+	uint32_t size;	/* in bytes of this structure */
+	uint32_t min;
+	uint32_t max;
+	uint32_t platform_max;
+	uint32_t invert;
+	uint32_t num_channels;
 	struct snd_soc_tplg_channel channel[SND_SOC_TPLG_MAX_CHAN];
 	struct snd_soc_tplg_private priv;
 } __attribute__((packed));
@@ -273,14 +273,14 @@ struct snd_soc_tplg_mixer_control {
  */
 struct snd_soc_tplg_enum_control {
 	struct snd_soc_tplg_ctl_hdr hdr;
-	__le32 size;	/* in bytes of this structure */
-	__le32 num_channels;
+	uint32_t size;	/* in bytes of this structure */
+	uint32_t num_channels;
 	struct snd_soc_tplg_channel channel[SND_SOC_TPLG_MAX_CHAN];
-	__le32 items;
-	__le32 mask;
-	__le32 count;
+	uint32_t items;
+	uint32_t mask;
+	uint32_t count;
 	char texts[SND_SOC_TPLG_NUM_TEXTS][SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
-	__le32 values[SND_SOC_TPLG_NUM_TEXTS * SNDRV_CTL_ELEM_ID_NAME_MAXLEN / 4];
+	uint32_t values[SND_SOC_TPLG_NUM_TEXTS * SNDRV_CTL_ELEM_ID_NAME_MAXLEN / 4];
 	struct snd_soc_tplg_private priv;
 } __attribute__((packed));
 
@@ -296,11 +296,11 @@ struct snd_soc_tplg_enum_control {
  */
 struct snd_soc_tplg_bytes_control {
 	struct snd_soc_tplg_ctl_hdr hdr;
-	__le32 size;	/* in bytes of this structure */
-	__le32 max;
-	__le32 mask;
-	__le32 base;
-	__le32 num_regs;
+	uint32_t size;	/* in bytes of this structure */
+	uint32_t max;
+	uint32_t mask;
+	uint32_t base;
+	uint32_t num_regs;
 	struct snd_soc_tplg_io_ops ext_ops;
 	struct snd_soc_tplg_private priv;
 } __attribute__((packed));
@@ -338,20 +338,20 @@ struct snd_soc_tplg_dapm_graph_elem {
  * in the block.
  */
 struct snd_soc_tplg_dapm_widget {
-	__le32 size;		/* in bytes of this structure */
-	__le32 id;		/* SND_SOC_DAPM_CTL */
+	uint32_t size;		/* in bytes of this structure */
+	uint32_t id;		/* SND_SOC_DAPM_CTL */
 	char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
 	char sname[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
 
-	__le32 reg;		/* negative reg = no direct dapm */
-	__le32 shift;		/* bits to shift */
-	__le32 mask;		/* non-shifted mask */
-	__le32 subseq;		/* sort within widget type */
-	__le32 invert;		/* invert the power bit */
-	__le32 ignore_suspend;	/* kept enabled over suspend */
-	__le16 event_flags;
-	__le16 event_type;
-	__le32 num_kcontrols;
+	uint32_t reg;		/* negative reg = no direct dapm */
+	uint32_t shift;		/* bits to shift */
+	uint32_t mask;		/* non-shifted mask */
+	uint32_t subseq;		/* sort within widget type */
+	uint32_t invert;		/* invert the power bit */
+	uint32_t ignore_suspend;	/* kept enabled over suspend */
+	uint16_t event_flags;
+	uint16_t event_type;
+	uint32_t num_kcontrols;
 	struct snd_soc_tplg_private priv;
 	/*
 	 * kcontrols that relate to this widget
@@ -371,16 +371,16 @@ struct snd_soc_tplg_dapm_widget {
  * +-----------------------------------+-----+
  */
 struct snd_soc_tplg_pcm {
-	__le32 size;		/* in bytes of this structure */
+	uint32_t size;		/* in bytes of this structure */
 	char pcm_name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
 	char dai_name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
-	__le32 pcm_id;		/* unique ID - used to match */
-	__le32 dai_id;		/* unique ID - used to match */
-	__le32 playback;	/* supports playback mode */
-	__le32 capture;		/* supports capture mode */
-	__le32 compress;	/* 1 = compressed; 0 = PCM */
+	uint32_t pcm_id;		/* unique ID - used to match */
+	uint32_t dai_id;		/* unique ID - used to match */
+	uint32_t playback;	/* supports playback mode */
+	uint32_t capture;		/* supports capture mode */
+	uint32_t compress;	/* 1 = compressed; 0 = PCM */
 	struct snd_soc_tplg_stream stream[SND_SOC_TPLG_STREAM_CONFIG_MAX]; /* for DAI link */
-	__le32 num_streams;	/* number of streams */
+	uint32_t num_streams;	/* number of streams */
 	struct snd_soc_tplg_stream_caps caps[2]; /* playback and capture for DAI */
 } __attribute__((packed));
 
@@ -396,9 +396,9 @@ struct snd_soc_tplg_pcm {
  * +-----------------------------------+-----+
  */
 struct snd_soc_tplg_link_config {
-	__le32 size;            /* in bytes of this structure */
-	__le32 id;              /* unique ID - used to match */
+	uint32_t size;            /* in bytes of this structure */
+	uint32_t id;              /* unique ID - used to match */
 	struct snd_soc_tplg_stream stream[SND_SOC_TPLG_STREAM_CONFIG_MAX]; /* supported configs playback and captrure */
-	__le32 num_streams;     /* number of streams */
+	uint32_t num_streams;     /* number of streams */
 } __attribute__((packed));
 #endif
Signature · 1 line
2.7.1
#29 lore raw

PATCH 4/4 Replace __u* with uint*_t

And here's a fourth one.

Quoted 1 line

From e98b740f7617830f46e58365f3c0602fcb3ff8c2 Mon Sep 17 00:00:00 2001

From: Thomas Klausner <[email protected]>
Date: Mon, 29 Feb 2016 16:08:54 +0100
Subject: [PATCH 4/4] Replace __u* with uint*_t.

---
 include/sound/asound.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
include/sound/asound.h +4 -4
index 4f2202f..0d30eaa 100644
@@ -370,7 +370,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 {
@@ -447,10 +447,10 @@ 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 audio_tstamp_data;	 /* needed for 64-bit alignment, used for configs/report to/from userspace */
+	uint32_t audio_tstamp_data;	 /* needed for 64-bit alignment, used for configs/report to/from userspace */
 	struct timespec audio_tstamp;	/* sample counter, wall clock, PHC or on-demand sync'ed */
 	struct timespec driver_tstamp;	/* useful in case reference system tstamp is reported with delay */
-	__u32 audio_tstamp_accuracy;	/* in ns units, only valid if indicated in audio_tstamp_data */
+	uint32_t audio_tstamp_accuracy;	/* in ns units, only valid if indicated in audio_tstamp_data */
 	unsigned char reserved[52-2*sizeof(struct timespec)]; /* must be filled with zero */
 };
 
@@ -900,7 +900,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];
Signature · 1 line
2.7.1