]> git.alsa-project.org Git - alsa-lib.git/commitdiff
add NetBSD/OpenBSD build support (except test/)
authorSASANO Takayoshi <uaa@uaa.org.uk>
Sun, 10 Jul 2022 02:03:00 +0000 (11:03 +0900)
committerJaroslav Kysela <perex@perex.cz>
Mon, 17 Oct 2022 11:11:29 +0000 (13:11 +0200)
Fixes: https://github.com/alsa-project/alsa-lib/pull/250
Signed-off-by: SASANO Takayoshi <uaa@uaa.org.uk>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
14 files changed:
configure.ac
include/bswap.h
include/local.h
include/sound/type_compat.h
include/sound/uapi/asoc.h
src/async.c
src/conf.c
src/pcm/pcm.c
src/pcm/pcm_direct.c
src/pcm/pcm_mmap.c
src/seq/seq_midi_event.c
src/shmarea.c
src/ucm/parser.c
src/ucm/ucm_exec.c

index 864df1d0203912a4f3c4edc2b1f860c56751ebff..9a9eda9b79c8b93e41b164f59fff94e0fd677036 100644 (file)
@@ -335,7 +335,7 @@ else
 fi
 
 dnl Check for headers
-AC_CHECK_HEADERS([endian.h sys/endian.h sys/shm.h])
+AC_CHECK_HEADERS([endian.h sys/endian.h sys/shm.h malloc.h])
 
 dnl Check for resmgr support...
 AC_MSG_CHECKING(for resmgr support)
index 4e5b3e2a6cbb1de96cbb92fb96031141e41da1cc..e590124c384e8ae40271327b86dd23041c63298c 100644 (file)
 #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
index 268a9ff1200e2c93d09a344b73af0dc916cd4c6e..151e3fd4d39b5b1dbc65850a408837d2aafbb889 100644 (file)
@@ -34,6 +34,9 @@
 #include <endian.h>
 #elif defined(HAVE_SYS_ENDIAN_H)
 #include <sys/endian.h>
+#else
+#error Header defining endianness not defined
+#endif
 #ifndef __BYTE_ORDER
 #define __BYTE_ORDER BYTE_ORDER
 #endif
@@ -43,9 +46,6 @@
 #ifndef __BIG_ENDIAN
 #define __BIG_ENDIAN BIG_ENDIAN
 #endif
-#else
-#error Header defining endianness not defined
-#endif
 #include <stdarg.h>
 #include <poll.h>
 #include <sys/types.h>
@@ -85,6 +85,8 @@
 #define versionsort64 versionsort
 #define alphasort64 alphasort
 #define ino64_t ino_t
+#define fstat64 fstat
+#define stat64 stat
 #endif
 
 #define _snd_config_iterator list_head
index b994ccfe48be7ae356904c9d1c1294964575f337..0c424efcf9f6f1d6c64d3a34d0475c808d67150c 100644 (file)
@@ -3,7 +3,7 @@
 
 #ifndef DOC_HIDDEN
 #include <stdint.h>
-#ifdef __linux__
+#if defined(__linux__)
 #include <linux/types.h>
 #else
 typedef uint8_t __u8;
@@ -15,8 +15,14 @@ typedef int16_t __s16;
 typedef int32_t __s32;
 typedef int64_t __s64;
 
+#if defined(__sun)
+#include <sys/byteorder.h>
+#define __cpu_to_le32 LE_32(x)
+#define __cpu_to_be32 BE_32(x)
+#define __cpu_to_le16 LE_16(x)
+#define __cpu_to_be16 BE_16(x)
+#else
 #include <endian.h>
-#include <byteswap.h>
 #if __BYTE_ORDER == __LITTLE_ENDIAN
 #define __cpu_to_le32(x) (x)
 #define __cpu_to_be32(x) bswap_32(x)
@@ -28,20 +34,12 @@ typedef int64_t __s64;
 #define __cpu_to_le16(x) bswap_16(x)
 #define __cpu_to_be16(x) (x)
 #endif
+#endif
 
 #define __le32_to_cpu __cpu_to_le32
 #define __be32_to_cpu __cpu_to_be32
 #define __le16_to_cpu __cpu_to_le16
 #define __be16_to_cpu __cpu_to_be16
-
-#define __le64 __u64
-#define __le32 __u32
-#define __le16 __u16
-#define __le8  __u8
-#define __be64 __u64
-#define __be32 __u32
-#define __be16 __u16
-#define __be8  __u8
 #endif
 
 #ifndef __kernel_long_t
index f32c56972d3f01fe178304d81144a848f6885f0d..3903f2f4bbf15077378692c51e9f3c499cc6b243 100644 (file)
@@ -16,7 +16,9 @@
 #ifndef __LINUX_UAPI_SND_ASOC_H
 #define __LINUX_UAPI_SND_ASOC_H
 
+#if defined(__linux__)
 #include <linux/types.h>
+#endif
 
 /*
  * Maximum number of channels topology kcontrol can represent.
index e6a8b5f2a07330b6baf72be60acb7b4a36af8dce..8e8481b58885f2e846f6f0f699e351a947b44474 100644 (file)
@@ -54,6 +54,15 @@ static LIST_HEAD(snd_async_handlers);
 
 static void snd_async_handler(int signo ATTRIBUTE_UNUSED, siginfo_t *siginfo, void *context ATTRIBUTE_UNUSED)
 {
+#if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__OpenBSD__)
+       /* siginfo_t does not have si_fd */
+       struct list_head *i;
+       list_for_each(i, &snd_async_handlers) {
+               snd_async_handler_t *h = list_entry(i, snd_async_handler_t, glist);
+               if (h->callback)
+                       h->callback(h);
+       }
+#else
        int fd;
        struct list_head *i;
        //assert(siginfo->si_code == SI_SIGIO);
@@ -66,6 +75,7 @@ static void snd_async_handler(int signo ATTRIBUTE_UNUSED, siginfo_t *siginfo, vo
                if (h->fd == fd && h->callback)
                        h->callback(h);
        }
+#endif
 }
 
 /**
index a996e5f9f9be018d75604793a726279e23e9e8d2..029a0db41654dd165466a1f5eba4284630677326 100644 (file)
@@ -4115,7 +4115,7 @@ static int config_file_load(snd_config_t *root, const char *fn, int errors)
        if (!S_ISDIR(st.st_mode))
                return config_file_open(root, fn);
 #ifndef DOC_HIDDEN
-#if defined(_GNU_SOURCE) && !defined(__NetBSD__) && !defined(__FreeBSD__) && !defined(__sun) && !defined(ANDROID)
+#if defined(_GNU_SOURCE) && !defined(__NetBSD__) && !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__sun) && !defined(ANDROID)
 #define SORTFUNC       versionsort64
 #else
 #define SORTFUNC       alphasort64
index 9aec52d104506632fce4fe5a6915bcb25479af6d..927aa055d30eac145b49427a120fe218a0735baf 100644 (file)
@@ -660,7 +660,9 @@ playback devices.
 
 #include <stdio.h>
 #include <string.h>
+#if HAVE_MALLOC_H
 #include <malloc.h>
+#endif
 #include <stdarg.h>
 #include <signal.h>
 #include <ctype.h>
index 39b82b96596ee4e26da0557ae18297b86243a730..c16956f10873db9809f7b7cafcc542b771ab7b01 100644 (file)
  *
  */
  
+#if !defined(__OpenBSD__)
 union semun {
        int              val;    /* Value for SETVAL */
        struct semid_ds *buf;    /* Buffer for IPC_STAT, IPC_SET */
        unsigned short  *array;  /* Array for GETALL, SETALL */
+#if defined(__linux__)
        struct seminfo  *__buf;  /* Buffer for IPC_INFO (Linux specific) */
+#endif
 };
+#endif
  
 /*
  * FIXME:
index 9cbaae05250ac17ff13b5d5f17e8e1e909c3e84d..dcd5c77e20e4fa2f249021b921f4929489b95cfd 100644 (file)
@@ -20,7 +20,9 @@
 
 #include "config.h"
 #include <stdio.h>
+#if HAVE_MALLOC_H
 #include <malloc.h>
+#endif
 #include <string.h>
 #include <poll.h>
 #include <sys/mman.h>
index 5a12a18ce7810b100b45858851c7bc291fa52cc2..df09bde30eea90e8e55cf59a0db68ea283bf20cf 100644 (file)
@@ -28,7 +28,9 @@
  *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
+#if HAVE_MALLOC_H
 #include <malloc.h>
+#endif
 #include "local.h"
 
 #ifndef DOC_HIDDEN
index 18937d9eef68e940751c5f8a05fcea2a0c4a4b04..b566c79e7506e1af619a9ffc984fdb6534aa5bf1 100644 (file)
 #ifdef HAVE_SYS_SHM_H
 
 #include <stdio.h>
+#include <stdlib.h>
+#if HAVE_MALLOC_H
 #include <malloc.h>
+#endif
 #include <string.h>
 #include <errno.h>
 #include <poll.h>
index 9e62fa9fa9922d12aee5c6db7838c9a758d989d7..56d67e500ad095aba8127349092f9ade7be728d1 100644 (file)
@@ -2907,7 +2907,7 @@ int uc_mgr_scan_master_configs(const char **_list[])
                snprintf(filename, sizeof(filename), "%s/ucm2/conf.virt.d",
                         snd_config_topdir());
 
-#if defined(_GNU_SOURCE) && !defined(__NetBSD__) && !defined(__FreeBSD__) && !defined(__sun) && !defined(ANDROID)
+#if defined(_GNU_SOURCE) && !defined(__NetBSD__) && !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__sun) && !defined(ANDROID)
 #define SORTFUNC       versionsort64
 #else
 #define SORTFUNC       alphasort64
index fffff55c2cc4af855a6373bc0ae9aefe414c9a1d..d5251fabebfabe6f4e7d95cdf785e05fb8187996 100644 (file)
 #include <limits.h>
 #include <dirent.h>
 
+#if defined(__NetBSD__) || defined(__OpenBSD__)
+#include <signal.h>
+extern char **environ;
+#endif
+
 static pthread_mutex_t fork_lock = PTHREAD_MUTEX_INITIALIZER;
 
 /*