diff --git a/meson.build b/meson.build index d21fc8f61..d9fead863 100644 --- a/meson.build +++ b/meson.build @@ -336,16 +336,16 @@ webrtc_dep = dependency('webrtc-audio-processing', summary({'WebRTC Echo Canceling': webrtc_dep.found()}, bool_yn: true, section: 'Misc dependencies') cdata.set('HAVE_WEBRTC', webrtc_dep.found()) -# On FreeBSD, epoll-shim library is required for eventfd() and timerfd() -epoll_shim_dep = (build_machine.system() == 'freebsd' +# On FreeBSD and MidnightBSD, epoll-shim library is required for eventfd() and timerfd() +epoll_shim_dep = (build_machine.system() == 'freebsd' or build_machine.system() == 'midnightbsd' ? dependency('epoll-shim', required: true) : dependency('', required: false)) -libinotify_dep = (build_machine.system() == 'freebsd' +libinotify_dep = (build_machine.system() == 'freebsd' or build_machine.system() == 'midnightbsd' ? dependency('libinotify', required: true) : dependency('', required: false)) -# On FreeBSD, libintl library is required for gettext +# On FreeBSD and MidnightBSD, libintl library is required for gettext libintl_dep = cc.find_library('intl', required: false) if not libintl_dep.found() libintl_dep = dependency('intl', required: false) @@ -356,8 +356,8 @@ need_alsa = get_option('pipewire-alsa').enabled() or 'media-session' in get_opti alsa_dep = dependency('alsa', version : '>=1.1.7', required: need_alsa) summary({'pipewire-alsa': alsa_dep.found()}, bool_yn: true) -if build_machine.system() == 'freebsd' -# On FreeBSD the OpenSSL library may come from base or a package. +if build_machine.system() == 'freebsd' or build_machine.system() == 'midnightbsd' +# On FreeBSD and MidnightBSD the OpenSSL library may come from base or a package. # Check for a package first and fallback to the base library if we can't find it via pkgconfig openssl_lib = dependency('openssl', required: false) if not openssl_lib.found() diff --git a/pipewire-alsa/alsa-plugins/pcm_pipewire.c b/pipewire-alsa/alsa-plugins/pcm_pipewire.c index 16940b1fc..9d6a9dc47 100644 --- a/pipewire-alsa/alsa-plugins/pcm_pipewire.c +++ b/pipewire-alsa/alsa-plugins/pcm_pipewire.c @@ -25,7 +25,7 @@ #define __USE_GNU #include -#ifndef __FreeBSD__ +#if !defined(__FreeBSD__) && !defined(__MidnightBSD__) #include #endif #include diff --git a/pipewire-v4l2/src/pipewire-v4l2.c b/pipewire-v4l2/src/pipewire-v4l2.c index 47e1721c2..d2e13dbf7 100644 --- a/pipewire-v4l2/src/pipewire-v4l2.c +++ b/pipewire-v4l2/src/pipewire-v4l2.c @@ -1756,7 +1756,7 @@ static int v4l2_ioctl(int fd, unsigned long int request, void *arg) if ((file = find_file(fd)) == NULL) return globals.old_fops.ioctl(fd, request, arg); -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) || defined(__MidnightBSD__) if (arg == NULL && (request & IOC_DIRMASK != IOC_VOID)) { #else if (arg == NULL && (_IOC_DIR(request) & (_IOC_WRITE | _IOC_READ))) { diff --git a/spa/include/spa/param/audio/layout.h b/spa/include/spa/param/audio/layout.h index 1868144ef..66154bf62 100644 --- a/spa/include/spa/param/audio/layout.h +++ b/spa/include/spa/param/audio/layout.h @@ -29,7 +29,7 @@ extern "C" { #endif -#ifndef __FreeBSD__ +#if !defined(__FreeBSD__) && !defined(__MidnightBSD__) #include #endif diff --git a/spa/include/spa/param/audio/raw.h b/spa/include/spa/param/audio/raw.h index 47fe90dfa..a34915c42 100644 --- a/spa/include/spa/param/audio/raw.h +++ b/spa/include/spa/param/audio/raw.h @@ -31,7 +31,7 @@ extern "C" { #include -#ifndef __FreeBSD__ +#if !defined(__FreeBSD__) && !defined(__MidnightBSD__) #include #endif diff --git a/spa/plugins/audioconvert/fmt-ops.h b/spa/plugins/audioconvert/fmt-ops.h index 3f31e1a47..3016c6752 100644 --- a/spa/plugins/audioconvert/fmt-ops.h +++ b/spa/plugins/audioconvert/fmt-ops.h @@ -23,7 +23,7 @@ */ #include -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) || defined(__MidnightBSD__) #include #define bswap_16 bswap16 #define bswap_32 bswap32 diff --git a/spa/plugins/support/cpu.c b/spa/plugins/support/cpu.c index 01cff4854..67440af16 100644 --- a/spa/plugins/support/cpu.c +++ b/spa/plugins/support/cpu.c @@ -30,7 +30,7 @@ #include #include -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) || defined(__MidnightBSD__) #include #endif diff --git a/spa/plugins/support/logger.c b/spa/plugins/support/logger.c index 4d308fa90..3b854c65e 100644 --- a/spa/plugins/support/logger.c +++ b/spa/plugins/support/logger.c @@ -42,7 +42,7 @@ #include "log-patterns.h" -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) || defined(__MidnightBSD__) #define CLOCK_MONOTONIC_RAW CLOCK_MONOTONIC #endif diff --git a/spa/plugins/vulkan/vulkan-utils.c b/spa/plugins/vulkan/vulkan-utils.c index ff9a51eb3..aa669bc8e 100644 --- a/spa/plugins/vulkan/vulkan-utils.c +++ b/spa/plugins/vulkan/vulkan-utils.c @@ -6,7 +6,7 @@ #include #include #include -#ifndef __FreeBSD__ +#if defined(__FreeBSD__) || defined(__MidnightBSD__) #include #endif #include diff --git a/spa/tests/stress-ringbuffer.c b/spa/tests/stress-ringbuffer.c index 2c3f38af2..6a7e98fb5 100644 --- a/spa/tests/stress-ringbuffer.c +++ b/spa/tests/stress-ringbuffer.c @@ -11,10 +11,10 @@ #define ARRAY_SIZE 63 #define MAX_VALUE 0x10000 -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) || defined(__MidnightBSD__) #include #if (__FreeBSD_version >= 1400000 && __FreeBSD_version < 1400043) \ - || (__FreeBSD_version < 1300523) + || (__FreeBSD_version < 1300523) || defined(__MidnightBSD__) static int sched_getcpu(void) { return -1; }; #endif #endif diff --git a/src/modules/module-protocol-native.c b/src/modules/module-protocol-native.c index 556ee14c0..44a642534 100644 --- a/src/modules/module-protocol-native.c +++ b/src/modules/module-protocol-native.c @@ -38,7 +38,7 @@ #ifdef HAVE_PWD_H #include #endif -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) || defined(__MidnightBSD__) #include #endif @@ -534,7 +534,7 @@ static struct client_data *client_new(struct server *s, int fd) struct pw_impl_client *client; struct pw_protocol *protocol = s->this.protocol; socklen_t len; -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) || defined(__MidnightBSD__) struct xucred xucred; #else struct ucred ucred; @@ -583,7 +583,7 @@ static struct client_data *client_new(struct server *s, int fd) (int)len, buffer); } } -#elif defined(__FreeBSD__) +#elif defined(__FreeBSD__) || defined(__MidnightBSD__) len = sizeof(xucred); if (getsockopt(fd, 0, LOCAL_PEERCRED, &xucred, &len) < 0) { pw_log_warn("server %p: no peercred: %m", s); diff --git a/src/modules/module-protocol-pulse/utils.c b/src/modules/module-protocol-pulse/utils.c index cd96a8dfb..1c9bc1c5f 100644 --- a/src/modules/module-protocol-pulse/utils.c +++ b/src/modules/module-protocol-pulse/utils.c @@ -152,7 +152,7 @@ pid_t get_client_pid(struct client *client, int client_fd) pw_log_warn("client %p: no peercred: %m", client); } else return ucred.pid; -#elif defined(__FreeBSD__) +#elif defined(__FreeBSD__) || defined(__MidnightBSD__) struct xucred xucred; len = sizeof(xucred); if (getsockopt(client_fd, 0, LOCAL_PEERCRED, &xucred, &len) < 0) { diff --git a/src/modules/module-rt.c b/src/modules/module-rt.c index cc87c5f67..869d5c08e 100644 --- a/src/modules/module-rt.c +++ b/src/modules/module-rt.c @@ -52,7 +52,7 @@ #include #include #include -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) || defined(__MidnightBSD__) #include #endif #include @@ -205,7 +205,7 @@ static pid_t _gettid(void) return (pid_t) gettid(); #elif defined(__linux__) return syscall(SYS_gettid); -#elif defined(__FreeBSD__) +#elif defined(__FreeBSD__) || defined(__MidnightBSD__) long pid; thr_self(&pid); return (pid_t)pid; diff --git a/src/pipewire/conf.c b/src/pipewire/conf.c index 4e6fc2ca0..a70b8aa35 100644 --- a/src/pipewire/conf.c +++ b/src/pipewire/conf.c @@ -38,7 +38,7 @@ #ifdef HAVE_PWD_H #include #endif -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) || defined(__MidnightBSD__) #define O_PATH 0 #endif diff --git a/src/pipewire/mem.c b/src/pipewire/mem.c index 42ac7c104..361ee88a2 100644 --- a/src/pipewire/mem.c +++ b/src/pipewire/mem.c @@ -44,7 +44,7 @@ PW_LOG_TOPIC_EXTERN(log_mem); #define PW_LOG_TOPIC_DEFAULT log_mem -#if !defined(__FreeBSD__) && !defined(HAVE_MEMFD_CREATE) +#if !defined(__FreeBSD__) && !defined(__MidnightBSD__) && !defined(HAVE_MEMFD_CREATE) /* * No glibc wrappers exist for memfd_create(2), so provide our own. * @@ -61,7 +61,7 @@ static inline int memfd_create(const char *name, unsigned int flags) #define HAVE_MEMFD_CREATE 1 #endif -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) || defined(__MidnightBSD__) #define MAP_LOCKED 0 #endif @@ -491,7 +491,7 @@ struct pw_memblock * pw_mempool_alloc(struct pw_mempool *pool, enum pw_memblock_ pw_log_error("%p: Failed to create memfd: %m", pool); goto error_free; } -#elif defined(__FreeBSD__) +#elif defined(__FreeBSD__) || defined(__MidnightBSD__) b->this.fd = shm_open(SHM_ANON, O_CREAT | O_RDWR | O_CLOEXEC, 0); if (b->this.fd == -1) { res = -errno; diff --git a/src/pipewire/meson.build b/src/pipewire/meson.build index f96a022bc..f594c55f3 100644 --- a/src/pipewire/meson.build +++ b/src/pipewire/meson.build @@ -94,7 +94,7 @@ libpipewire_c_args = [ '-DOLD_MEDIA_SESSION_WORKAROUND=1' ] -if build_machine.system() != 'freebsd' +if build_machine.system() != 'freebsd' and build_machine.system() != 'midnightbsd' libpipewire_c_args += [ '-D_POSIX_C_SOURCE' ] diff --git a/src/pipewire/pipewire.c b/src/pipewire/pipewire.c index f0edb1867..4561ba7bd 100644 --- a/src/pipewire/pipewire.c +++ b/src/pipewire/pipewire.c @@ -27,7 +27,7 @@ #include #include #include -#ifndef __FreeBSD__ +#if !defined(__FreeBSD__) && !defined(__MidnightBSD__) #include #endif #include @@ -746,7 +746,7 @@ static void init_prgname(void) static char name[PATH_MAX]; spa_memzero(name, sizeof(name)); -#if defined(__linux__) || defined(__FreeBSD_kernel__) +#if defined(__linux__) || defined(__FreeBSD_kernel__) || defined(__MidnightBSD_kernel__) { if (readlink("/proc/self/exe", name, sizeof(name)-1) > 0) { prgname = strrchr(name, '/') + 1; @@ -754,7 +754,7 @@ static void init_prgname(void) } } #endif -#if defined __FreeBSD__ +#if defined __FreeBSD__ || defined(__MidnightBSD__) { ssize_t len; @@ -764,7 +764,7 @@ static void init_prgname(void) } } #endif -#ifndef __FreeBSD__ +#if !defined(__FreeBSD__) && !defined(__MidnightBSD__) { if (prctl(PR_GET_NAME, (unsigned long) name, 0, 0, 0) == 0) { prgname = name; diff --git a/src/pipewire/private.h b/src/pipewire/private.h index 52629f4a3..b892074a6 100644 --- a/src/pipewire/private.h +++ b/src/pipewire/private.h @@ -40,7 +40,7 @@ extern "C" { #include #include -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) || defined(__MidnightBSD__) struct ucred { }; #endif diff --git a/src/pipewire/thread.c b/src/pipewire/thread.c index f699ebf5b..72be387bd 100644 --- a/src/pipewire/thread.c +++ b/src/pipewire/thread.c @@ -62,9 +62,9 @@ error: return NULL; } -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) || defined(__MidnightBSD__) #include -#if __FreeBSD_version < 1202000 +#if __FreeBSD_version < 1202000 || defined(__MidnightBSD__) int pthread_setname_np(pthread_t thread, const char *name) { pthread_set_name_np(thread, name); diff --git a/src/tools/pw-cli.c b/src/tools/pw-cli.c index f45d10887..17ffc4897 100644 --- a/src/tools/pw-cli.c +++ b/src/tools/pw-cli.c @@ -30,7 +30,7 @@ #include #include #include -#ifndef __FreeBSD__ +#if !defined(__FreeBSD__) && !defined(__MidnightBSD__) #include #endif #include