summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSASANO Takayoshi <uaa@uaa.org.uk>2022-12-31 16:03:34 +0900
committerJaroslav Kysela <perex@perex.cz>2023-02-03 13:08:44 +0100
commit613372dc7c50b1ddc64c79040e8e1ea7c57a3198 (patch)
treed7dd1ee8e3a3e0e918814c9bbaf5b25cc06e962d
parent1350900246e0462b584331be0df24e177e7b25be (diff)
downloadalsa-utils-613372dc7c50b1ddc64c79040e8e1ea7c57a3198.tar.gz
Add OpenBSD support
- ERESTART not supported platform: use EINTR instead - add include/os_compat.h, well-used OS specific definition - copied include/bswap.h from alsa-lib - EPIPE and ESTRPIPE are different usage, but currently EPIPE is used when ESTRPIPE is not defined. To fix this problem, assign ESPIPE instead. Fixes: https://github.com/alsa-project/alsa-utils/pull/186 Signed-off-by: SASANO Takayoshi <uaa@uaa.org.uk> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
-rw-r--r--alsactl/alsactl.c1
-rw-r--r--alsaloop/alsaloop.c1
-rw-r--r--alsaloop/control.c2
-rw-r--r--alsaloop/pcmjob.c1
-rw-r--r--amidi/amidi.c4
-rw-r--r--aplay/aplay.c3
-rw-r--r--aplay/formats.h3
-rw-r--r--axfer/container.h2
-rw-r--r--bat/alsa.c1
-rw-r--r--configure.ac2
-rw-r--r--include/bswap.h44
-rw-r--r--include/os_compat.h43
-rw-r--r--speaker-test/speaker-test.c3
13 files changed, 106 insertions, 4 deletions
diff --git a/alsactl/alsactl.c b/alsactl/alsactl.c
index ae73715..2851441 100644
--- a/alsactl/alsactl.c
+++ b/alsactl/alsactl.c
@@ -30,6 +30,7 @@
#include <syslog.h>
#include <sched.h>
#include "alsactl.h"
+#include "os_compat.h"
#ifndef SYS_ASOUND_DIR
#define SYS_ASOUND_DIR "/var/lib/alsa"
diff --git a/alsaloop/alsaloop.c b/alsaloop/alsaloop.c
index f5f2e37..e0f8642 100644
--- a/alsaloop/alsaloop.c
+++ b/alsaloop/alsaloop.c
@@ -33,6 +33,7 @@
#include <syslog.h>
#include <signal.h>
#include "alsaloop.h"
+#include "os_compat.h"
struct loopback_thread {
int threaded;
diff --git a/alsaloop/control.c b/alsaloop/control.c
index cf5693b..ba891fd 100644
--- a/alsaloop/control.c
+++ b/alsaloop/control.c
@@ -24,7 +24,9 @@
#include <ctype.h>
#include <syslog.h>
#include <alsa/asoundlib.h>
+#include <sys/time.h>
#include "alsaloop.h"
+#include "os_compat.h"
static char *id_str(snd_ctl_elem_id_t *id)
{
diff --git a/alsaloop/pcmjob.c b/alsaloop/pcmjob.c
index ef0c3dd..2df7bbd 100644
--- a/alsaloop/pcmjob.c
+++ b/alsaloop/pcmjob.c
@@ -33,6 +33,7 @@
#include <syslog.h>
#include <pthread.h>
#include "alsaloop.h"
+#include "os_compat.h"
#define XRUN_PROFILE_UNKNOWN (-10000000)
diff --git a/amidi/amidi.c b/amidi/amidi.c
index b7eebdf..ae2143c 100644
--- a/amidi/amidi.c
+++ b/amidi/amidi.c
@@ -85,7 +85,9 @@ static void usage(void)
"-T, --timestamp=... adds a timestamp in front of each dumped message\n"
" realtime\n"
" monotonic\n"
+#ifdef CLOCK_MONOTONIC_RAW
" raw\n"
+#endif
"-t, --timeout=seconds exits when no data has been received\n"
" for the specified duration\n"
"-a, --active-sensing include active sensing bytes\n"
@@ -534,8 +536,10 @@ int main(int argc, char *argv[])
cid = CLOCK_REALTIME;
else if (strcasecmp(optarg, "monotonic") == 0)
cid = CLOCK_MONOTONIC;
+#ifdef CLOCK_MONOTONIC_RAW
else if (strcasecmp(optarg, "raw") == 0)
cid = CLOCK_MONOTONIC_RAW;
+#endif
else
error("Clock type not known");
break;
diff --git a/aplay/aplay.c b/aplay/aplay.c
index 6c4c67b..d6b2e80 100644
--- a/aplay/aplay.c
+++ b/aplay/aplay.c
@@ -29,7 +29,9 @@
#define _GNU_SOURCE
#include "aconfig.h"
#include <stdio.h>
+#if HAVE_MALLOC_H
#include <malloc.h>
+#endif
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
@@ -53,6 +55,7 @@
#include "gettext.h"
#include "formats.h"
#include "version.h"
+#include "os_compat.h"
#define ABS(a) (a) < 0 ? -(a) : (a)
diff --git a/aplay/formats.h b/aplay/formats.h
index ac0a2b0..093ab80 100644
--- a/aplay/formats.h
+++ b/aplay/formats.h
@@ -1,8 +1,7 @@
#ifndef FORMATS_H
#define FORMATS_H 1
-#include <endian.h>
-#include <byteswap.h>
+#include "bswap.h"
/* Definitions for .VOC files */
diff --git a/axfer/container.h b/axfer/container.h
index f6ce689..8f7ab2a 100644
--- a/axfer/container.h
+++ b/axfer/container.h
@@ -17,6 +17,8 @@
#include <alsa/asoundlib.h>
+#include "os_compat.h"
+
enum container_type {
CONTAINER_TYPE_PARSER = 0,
CONTAINER_TYPE_BUILDER,
diff --git a/bat/alsa.c b/bat/alsa.c
index 0d0af0d..f0adbc3 100644
--- a/bat/alsa.c
+++ b/bat/alsa.c
@@ -28,6 +28,7 @@
#include "common.h"
#include "alsa.h"
#include "latencytest.h"
+#include "os_compat.h"
struct pcm_container {
snd_pcm_t *handle;
diff --git a/configure.ac b/configure.ac
index de51b78..d3cd904 100644
--- a/configure.ac
+++ b/configure.ac
@@ -28,7 +28,7 @@ AC_CHECK_FUNC([snd_ctl_elem_add_enumerated],
fi
-AC_CHECK_HEADERS([dlfcn.h])
+AC_CHECK_HEADERS([dlfcn.h malloc.h])
dnl Check components
AC_CHECK_HEADERS([alsa/pcm.h], [have_pcm="yes"], [have_pcm="no"],
diff --git a/include/bswap.h b/include/bswap.h
new file mode 100644
index 0000000..e590124
--- /dev/null
+++ b/include/bswap.h
@@ -0,0 +1,44 @@
+/*
+ * ALSA lib - compatibility header for providing byte swapping macros
+ * Copyright (c) 2016 by Thomas Klausner <wiz@NetBSD.org>
+ *
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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(__OpenBSD__)
+#include <sys/endian.h>
+#define bswap_16 swap16
+#define bswap_32 swap32
+#define bswap_64 swap64
+#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
diff --git a/include/os_compat.h b/include/os_compat.h
new file mode 100644
index 0000000..8d4f041
--- /dev/null
+++ b/include/os_compat.h
@@ -0,0 +1,43 @@
+/*
+ * ALSA lib - compatibility header for supporting various OSes
+ * Copyright (C) 2022 by Takayoshi SASANO <uaa@cvs.openbsd.org>
+ *
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#ifndef __OS_COMPAT_H
+#define __OS_COMPAT_H
+
+#ifndef ESTRPIPE
+#define ESTRPIPE ESPIPE
+#endif
+
+#ifndef ERESTART
+#define ERESTART EINTR
+#endif
+
+#ifndef SCHED_IDLE
+#define SCHED_IDLE SCHED_OTHER
+#endif
+
+#if defined(__OpenBSD__)
+/* these functions in <sched.h> are not implemented */
+#define sched_getparam(pid, param) (-1)
+#define sched_setscheduler(pid, policy, param) (-1)
+#endif
+
+#endif
diff --git a/speaker-test/speaker-test.c b/speaker-test/speaker-test.c
index fd13d88..d08893a 100644
--- a/speaker-test/speaker-test.c
+++ b/speaker-test/speaker-test.c
@@ -44,7 +44,7 @@
#include <getopt.h>
#include <inttypes.h>
#include <ctype.h>
-#include <byteswap.h>
+#include "bswap.h"
#include <signal.h>
#define ALSA_PCM_NEW_HW_PARAMS_API
@@ -56,6 +56,7 @@
#include "aconfig.h"
#include "gettext.h"
#include "version.h"
+#include "os_compat.h"
#ifdef ENABLE_NLS
#include <locale.h>