[alsa-devel] [PATCH alsa-lib 1/2] pcm: drop unused sys/shm.h inclusion

From: Mike Frysinger vapier@chromium.org
This header isn't used in these files, so stop trying to include it. This helps builds on systems that don't provide the header (such as Android/Bionic).
Signed-off-by: Mike Frysinger vapier@gentoo.org --- src/pcm/pcm.c | 1 - src/pcm/pcm_generic.c | 1 - src/pcm/pcm_hw.c | 1 - src/pcm/pcm_null.c | 1 - src/pcm/pcm_plugin.c | 1 - src/pcm/pcm_share.c | 1 - 6 files changed, 6 deletions(-)
diff --git a/src/pcm/pcm.c b/src/pcm/pcm.c index f5fc728..cbbc55a 100644 --- a/src/pcm/pcm.c +++ b/src/pcm/pcm.c @@ -635,7 +635,6 @@ playback devices. #include <signal.h> #include <ctype.h> #include <sys/poll.h> -#include <sys/shm.h> #include <sys/mman.h> #include <limits.h> #include "pcm_local.h" diff --git a/src/pcm/pcm_generic.c b/src/pcm/pcm_generic.c index 9b60591..4dbef08 100644 --- a/src/pcm/pcm_generic.c +++ b/src/pcm/pcm_generic.c @@ -26,7 +26,6 @@ * */
-#include <sys/shm.h> #include <sys/ioctl.h> #include <limits.h> #include "pcm_local.h" diff --git a/src/pcm/pcm_hw.c b/src/pcm/pcm_hw.c index 232b197..66aec5c 100644 --- a/src/pcm/pcm_hw.c +++ b/src/pcm/pcm_hw.c @@ -36,7 +36,6 @@ #include <fcntl.h> #include <sys/ioctl.h> #include <sys/mman.h> -#include <sys/shm.h> #include "pcm_local.h" #include "../control/control_local.h" #include "../timer/timer_local.h" diff --git a/src/pcm/pcm_null.c b/src/pcm/pcm_null.c index 0529820..5e63caa 100644 --- a/src/pcm/pcm_null.c +++ b/src/pcm/pcm_null.c @@ -28,7 +28,6 @@
#include <byteswap.h> #include <limits.h> -#include <sys/shm.h> #include "pcm_local.h" #include "pcm_plugin.h"
diff --git a/src/pcm/pcm_plugin.c b/src/pcm/pcm_plugin.c index c19e2f1..d007e8c 100644 --- a/src/pcm/pcm_plugin.c +++ b/src/pcm/pcm_plugin.c @@ -82,7 +82,6 @@ pcm.rate44100Hz {
*/
-#include <sys/shm.h> #include <limits.h> #include "pcm_local.h" #include "pcm_plugin.h" diff --git a/src/pcm/pcm_share.c b/src/pcm/pcm_share.c index 4b68f1f..5d8aaf2 100644 --- a/src/pcm/pcm_share.c +++ b/src/pcm/pcm_share.c @@ -35,7 +35,6 @@ #include <math.h> #include <sys/socket.h> #include <sys/poll.h> -#include <sys/shm.h> #include <pthread.h> #include "pcm_local.h"

From: Mike Frysinger vapier@chromium.org
Some systems, like Android/Bionic, do not support SysV at all. Let the configure script detect if the header is available, and if not, automatically disable the pieces that require it.
Signed-off-by: Mike Frysinger vapier@gentoo.org --- configure.ac | 13 ++++++++++++- src/pcm/pcm_mmap.c | 15 ++++++++++++++- src/shmarea.c | 9 ++++++++- 3 files changed, 34 insertions(+), 3 deletions(-)
diff --git a/configure.ac b/configure.ac index 1dcc0a4..9490d39 100644 --- a/configure.ac +++ b/configure.ac @@ -295,7 +295,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 sys/shm.h])
dnl Check for resmgr support... AC_MSG_CHECKING(for resmgr support) @@ -508,6 +508,13 @@ if test "$gcc_have_atomics" != "yes"; then build_pcm_meter="no" fi
+if test "$ac_cv_header_sys_shm_h" != "yes"; then + build_pcm_dmix="no" + build_pcm_dshare="no" + build_pcm_dsnoop="no" + build_pcm_shm="no" +fi + AM_CONDITIONAL([BUILD_PCM_PLUGIN], [test x$build_pcm_plugin = xyes]) AM_CONDITIONAL([BUILD_PCM_PLUGIN_COPY], [test x$build_pcm_copy = xyes]) AM_CONDITIONAL([BUILD_PCM_PLUGIN_LINEAR], [test x$build_pcm_linear = xyes]) @@ -594,6 +601,10 @@ for p in $ctl_plugins; do done done
+if test "$ac_cv_header_sys_shm_h" != "yes"; then + build_ctl_shm="no" +fi + AM_CONDITIONAL([BUILD_CTL_PLUGIN], [test x$build_ctl_plugin = xyes]) AM_CONDITIONAL([BUILD_CTL_PLUGIN_SHM], [test x$build_ctl_shm = xyes]) AM_CONDITIONAL([BUILD_CTL_PLUGIN_EXT], [test x$build_ctl_ext = xyes]) diff --git a/src/pcm/pcm_mmap.c b/src/pcm/pcm_mmap.c index 470bd04..5c4fbe1 100644 --- a/src/pcm/pcm_mmap.c +++ b/src/pcm/pcm_mmap.c @@ -17,13 +17,16 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ - + +#include "config.h" #include <stdio.h> #include <malloc.h> #include <string.h> #include <sys/poll.h> #include <sys/mman.h> +#ifdef HAVE_SYS_SHM_H #include <sys/shm.h> +#endif #include "pcm_local.h"
void snd_pcm_mmap_appl_backward(snd_pcm_t *pcm, snd_pcm_uframes_t frames) @@ -341,6 +344,7 @@ int snd_pcm_mmap(snd_pcm_t *pcm) i->addr = ptr; break; case SND_PCM_AREA_SHM: +#ifdef HAVE_SYS_SHM_H if (i->u.shm.shmid < 0) { int id; /* FIXME: safer permission? */ @@ -385,6 +389,10 @@ int snd_pcm_mmap(snd_pcm_t *pcm) } i->addr = ptr; break; +#else + SYSERR("shm support not available"); + return -ENOSYS; +#endif case SND_PCM_AREA_LOCAL: ptr = malloc(size); if (ptr == NULL) { @@ -466,6 +474,7 @@ int snd_pcm_munmap(snd_pcm_t *pcm) errno = 0; break; case SND_PCM_AREA_SHM: +#ifdef HAVE_SYS_SHM_H if (i->u.shm.area) { snd_shm_area_destroy(i->u.shm.area); i->u.shm.area = NULL; @@ -482,6 +491,10 @@ int snd_pcm_munmap(snd_pcm_t *pcm) } } break; +#else + SYSERR("shm support not available"); + return -ENOSYS; +#endif case SND_PCM_AREA_LOCAL: free(i->addr); break; diff --git a/src/shmarea.c b/src/shmarea.c index 071f9f3..9843aa8 100644 --- a/src/shmarea.c +++ b/src/shmarea.c @@ -17,7 +17,12 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ - + +#include "config.h" + +/* These funcs are only used by pcm_mmap when sys/shm.h is available. */ +#ifdef HAVE_SYS_SHM_H + #include <stdio.h> #include <malloc.h> #include <string.h> @@ -106,3 +111,5 @@ void snd_shm_area_destructor(void) shmdt(area->ptr); } } + +#endif
participants (1)
-
Mike Frysinger