>From f4ddc106fc53ec950ec8b6f2b0bfe3e1677c959f Mon Sep 17 00:00:00 2001 From: Patrick Welche 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 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 Signed-off-by: Patrick Welche --- 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(-) diff --git a/configure.ac b/configure.ac index d744867..979764b 100644 --- a/configure.ac +++ b/configure.ac @@ -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) diff --git a/include/list.h b/include/list.h index 4d9895f..6cf0753 100644 --- a/include/list.h +++ b/include/list.h @@ -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) diff --git a/include/local.h b/include/local.h index 2fe9a27..f1abfef 100644 --- a/include/local.h +++ b/include/local.h @@ -50,8 +50,18 @@ #include #include #include +#ifndef ESTRPIPE +#define ESTRPIPE EPIPE +#endif +#ifndef EBADFD +#define EBADFD EBADF +#endif +#if HAVE_LINUX_TYPES_H #include +#endif +#if HAVE_LINUX_IOCTL_H #include +#endif #ifdef SUPPORT_RESMGR #include diff --git a/include/sound/asound.h b/include/sound/asound.h index 1774a5c..102bc50 100644 --- a/include/sound/asound.h +++ b/include/sound/asound.h @@ -23,7 +23,19 @@ #ifndef _UAPI__SOUND_ASOUND_H #define _UAPI__SOUND_ASOUND_H -#include +#include +#include +#include +#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]; diff --git a/src/conf.c b/src/conf.c index 5ccc8e1..2a39d60 100644 --- a/src/conf.c +++ b/src/conf.c @@ -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 -- 1.9.0