]> git.alsa-project.org Git - alsa-utils.git/commitdiff
Add OpenBSD support
authorSASANO Takayoshi <uaa@uaa.org.uk>
Sat, 31 Dec 2022 07:03:34 +0000 (16:03 +0900)
committerJaroslav Kysela <perex@perex.cz>
Fri, 3 Feb 2023 12:08:44 +0000 (13:08 +0100)
- 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>
13 files changed:
alsactl/alsactl.c
alsaloop/alsaloop.c
alsaloop/control.c
alsaloop/pcmjob.c
amidi/amidi.c
aplay/aplay.c
aplay/formats.h
axfer/container.h
bat/alsa.c
configure.ac
include/bswap.h [new file with mode: 0644]
include/os_compat.h [new file with mode: 0644]
speaker-test/speaker-test.c

index ae73715e6a695e66f052bedb50227a8dedb218ad..285144174a6ef66a71eedcde7ed9c778f28c0e6e 100644 (file)
@@ -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"
index f5f2e37c05e7e7885f127181c200dae0d775d749..e0f8642bbd8de10cd555587bc7f08c2061c29f56 100644 (file)
@@ -33,6 +33,7 @@
 #include <syslog.h>
 #include <signal.h>
 #include "alsaloop.h"
+#include "os_compat.h"
 
 struct loopback_thread {
        int threaded;
index cf5693b6171193ac76cd54ef4aa9add2e5678c95..ba891fdbce4f983930d0ac42dab7f6f8b90e6212 100644 (file)
@@ -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)
 {
index ef0c3ddf54fb56e2a68c659e95b1569f001137d4..2df7bbdece3f50d01fa05ff825d9efa7a1f4e049 100644 (file)
@@ -33,6 +33,7 @@
 #include <syslog.h>
 #include <pthread.h>
 #include "alsaloop.h"
+#include "os_compat.h"
 
 #define XRUN_PROFILE_UNKNOWN (-10000000)
 
index b7eebdff85e9699f25e3d6fecdc7d5933f198fdb..ae2143c218b9a088c2bf1e9edaf0e5e5b4c2942c 100644 (file)
@@ -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;
index 6c4c67b6ff7a7fb4b28c76a1f9c363906b966e8a..d6b2e80873659ce46ad4c524f36ba91826246edd 100644 (file)
@@ -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)
 
index ac0a2b055269dd7b796d89bb2ed9503104524f65..093ab809382e3df3a7e59bccf8f197f38922ea8b 100644 (file)
@@ -1,8 +1,7 @@
 #ifndef FORMATS_H
 #define FORMATS_H              1
 
-#include <endian.h>
-#include <byteswap.h>
+#include "bswap.h"
 
 /* Definitions for .VOC files */
 
index f6ce689cb32839c1b03d3486307f85893e1958f6..8f7ab2aab91bbe3b75d852435bca0d230a9bcdc6 100644 (file)
@@ -17,6 +17,8 @@
 
 #include <alsa/asoundlib.h>
 
+#include "os_compat.h"
+
 enum container_type {
        CONTAINER_TYPE_PARSER = 0,
        CONTAINER_TYPE_BUILDER,
index 0d0af0d40e182c04f062132d96ba2b681fd21b36..f0adbc3122b9c42e6aa39181f44e647d37467ce0 100644 (file)
@@ -28,6 +28,7 @@
 #include "common.h"
 #include "alsa.h"
 #include "latencytest.h"
+#include "os_compat.h"
 
 struct pcm_container {
        snd_pcm_t *handle;
index de51b78e8c5b67fe88d36b8cf204acaa2aad117f..d3cd904659ac72557fcf08b3f5719fcc8acd9ff6 100644 (file)
@@ -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 (file)
index 0000000..e590124
--- /dev/null
@@ -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 (file)
index 0000000..8d4f041
--- /dev/null
@@ -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
index fd13d883b643d64e5acefc267f45bffd26b2339a..d08893ad17e4bfb4183da6ac488828ebbe25682a 100644 (file)
@@ -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>