Add support for MidnightBSD

Fix build issue

Fix build issue
This commit is contained in:
Lucas Holt 2022-06-19 14:03:56 -04:00
parent 4922aed6c6
commit 6a15a02ec2
20 changed files with 35 additions and 35 deletions

View file

@ -336,16 +336,16 @@ webrtc_dep = dependency('webrtc-audio-processing',
summary({'WebRTC Echo Canceling': webrtc_dep.found()}, bool_yn: true, section: 'Misc dependencies') summary({'WebRTC Echo Canceling': webrtc_dep.found()}, bool_yn: true, section: 'Misc dependencies')
cdata.set('HAVE_WEBRTC', webrtc_dep.found()) cdata.set('HAVE_WEBRTC', webrtc_dep.found())
# On FreeBSD, epoll-shim library is required for eventfd() and timerfd() # On FreeBSD and MidnightBSD, epoll-shim library is required for eventfd() and timerfd()
epoll_shim_dep = (build_machine.system() == 'freebsd' epoll_shim_dep = (build_machine.system() == 'freebsd' or build_machine.system() == 'midnightbsd'
? dependency('epoll-shim', required: true) ? dependency('epoll-shim', required: true)
: dependency('', required: false)) : 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('libinotify', required: true)
: dependency('', required: false)) : 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) libintl_dep = cc.find_library('intl', required: false)
if not libintl_dep.found() if not libintl_dep.found()
libintl_dep = dependency('intl', required: false) 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) alsa_dep = dependency('alsa', version : '>=1.1.7', required: need_alsa)
summary({'pipewire-alsa': alsa_dep.found()}, bool_yn: true) summary({'pipewire-alsa': alsa_dep.found()}, bool_yn: true)
if build_machine.system() == 'freebsd' if build_machine.system() == 'freebsd' or build_machine.system() == 'midnightbsd'
# On FreeBSD the OpenSSL library may come from base or a package. # 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 # 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) openssl_lib = dependency('openssl', required: false)
if not openssl_lib.found() if not openssl_lib.found()

View file

@ -25,7 +25,7 @@
#define __USE_GNU #define __USE_GNU
#include <limits.h> #include <limits.h>
#ifndef __FreeBSD__ #if !defined(__FreeBSD__) && !defined(__MidnightBSD__)
#include <byteswap.h> #include <byteswap.h>
#endif #endif
#include <sys/shm.h> #include <sys/shm.h>

View file

@ -1756,7 +1756,7 @@ static int v4l2_ioctl(int fd, unsigned long int request, void *arg)
if ((file = find_file(fd)) == NULL) if ((file = find_file(fd)) == NULL)
return globals.old_fops.ioctl(fd, request, arg); return globals.old_fops.ioctl(fd, request, arg);
#ifdef __FreeBSD__ #if defined(__FreeBSD__) || defined(__MidnightBSD__)
if (arg == NULL && (request & IOC_DIRMASK != IOC_VOID)) { if (arg == NULL && (request & IOC_DIRMASK != IOC_VOID)) {
#else #else
if (arg == NULL && (_IOC_DIR(request) & (_IOC_WRITE | _IOC_READ))) { if (arg == NULL && (_IOC_DIR(request) & (_IOC_WRITE | _IOC_READ))) {

View file

@ -29,7 +29,7 @@
extern "C" { extern "C" {
#endif #endif
#ifndef __FreeBSD__ #if !defined(__FreeBSD__) && !defined(__MidnightBSD__)
#include <endian.h> #include <endian.h>
#endif #endif

View file

@ -31,7 +31,7 @@ extern "C" {
#include <stdint.h> #include <stdint.h>
#ifndef __FreeBSD__ #if !defined(__FreeBSD__) && !defined(__MidnightBSD__)
#include <endian.h> #include <endian.h>
#endif #endif

View file

@ -23,7 +23,7 @@
*/ */
#include <math.h> #include <math.h>
#ifdef __FreeBSD__ #if defined(__FreeBSD__) || defined(__MidnightBSD__)
#include <sys/endian.h> #include <sys/endian.h>
#define bswap_16 bswap16 #define bswap_16 bswap16
#define bswap_32 bswap32 #define bswap_32 bswap32

View file

@ -30,7 +30,7 @@
#include <sched.h> #include <sched.h>
#include <fcntl.h> #include <fcntl.h>
#ifdef __FreeBSD__ #if defined(__FreeBSD__) || defined(__MidnightBSD__)
#include <sys/sysctl.h> #include <sys/sysctl.h>
#endif #endif

View file

@ -42,7 +42,7 @@
#include "log-patterns.h" #include "log-patterns.h"
#ifdef __FreeBSD__ #if defined(__FreeBSD__) || defined(__MidnightBSD__)
#define CLOCK_MONOTONIC_RAW CLOCK_MONOTONIC #define CLOCK_MONOTONIC_RAW CLOCK_MONOTONIC
#endif #endif

View file

@ -6,7 +6,7 @@
#include <sys/mman.h> #include <sys/mman.h>
#include <fcntl.h> #include <fcntl.h>
#include <string.h> #include <string.h>
#ifndef __FreeBSD__ #if defined(__FreeBSD__) || defined(__MidnightBSD__)
#include <alloca.h> #include <alloca.h>
#endif #endif
#include <errno.h> #include <errno.h>

View file

@ -11,10 +11,10 @@
#define ARRAY_SIZE 63 #define ARRAY_SIZE 63
#define MAX_VALUE 0x10000 #define MAX_VALUE 0x10000
#ifdef __FreeBSD__ #if defined(__FreeBSD__) || defined(__MidnightBSD__)
#include <sys/param.h> #include <sys/param.h>
#if (__FreeBSD_version >= 1400000 && __FreeBSD_version < 1400043) \ #if (__FreeBSD_version >= 1400000 && __FreeBSD_version < 1400043) \
|| (__FreeBSD_version < 1300523) || (__FreeBSD_version < 1300523) || defined(__MidnightBSD__)
static int sched_getcpu(void) { return -1; }; static int sched_getcpu(void) { return -1; };
#endif #endif
#endif #endif

View file

@ -38,7 +38,7 @@
#ifdef HAVE_PWD_H #ifdef HAVE_PWD_H
#include <pwd.h> #include <pwd.h>
#endif #endif
#if defined(__FreeBSD__) #if defined(__FreeBSD__) || defined(__MidnightBSD__)
#include <sys/ucred.h> #include <sys/ucred.h>
#endif #endif
@ -534,7 +534,7 @@ static struct client_data *client_new(struct server *s, int fd)
struct pw_impl_client *client; struct pw_impl_client *client;
struct pw_protocol *protocol = s->this.protocol; struct pw_protocol *protocol = s->this.protocol;
socklen_t len; socklen_t len;
#if defined(__FreeBSD__) #if defined(__FreeBSD__) || defined(__MidnightBSD__)
struct xucred xucred; struct xucred xucred;
#else #else
struct ucred ucred; struct ucred ucred;
@ -583,7 +583,7 @@ static struct client_data *client_new(struct server *s, int fd)
(int)len, buffer); (int)len, buffer);
} }
} }
#elif defined(__FreeBSD__) #elif defined(__FreeBSD__) || defined(__MidnightBSD__)
len = sizeof(xucred); len = sizeof(xucred);
if (getsockopt(fd, 0, LOCAL_PEERCRED, &xucred, &len) < 0) { if (getsockopt(fd, 0, LOCAL_PEERCRED, &xucred, &len) < 0) {
pw_log_warn("server %p: no peercred: %m", s); pw_log_warn("server %p: no peercred: %m", s);

View file

@ -152,7 +152,7 @@ pid_t get_client_pid(struct client *client, int client_fd)
pw_log_warn("client %p: no peercred: %m", client); pw_log_warn("client %p: no peercred: %m", client);
} else } else
return ucred.pid; return ucred.pid;
#elif defined(__FreeBSD__) #elif defined(__FreeBSD__) || defined(__MidnightBSD__)
struct xucred xucred; struct xucred xucred;
len = sizeof(xucred); len = sizeof(xucred);
if (getsockopt(client_fd, 0, LOCAL_PEERCRED, &xucred, &len) < 0) { if (getsockopt(client_fd, 0, LOCAL_PEERCRED, &xucred, &len) < 0) {

View file

@ -52,7 +52,7 @@
#include <stdio.h> #include <stdio.h>
#include <errno.h> #include <errno.h>
#include <sys/stat.h> #include <sys/stat.h>
#ifdef __FreeBSD__ #if defined(__FreeBSD__) || defined(__MidnightBSD__)
#include <sys/thr.h> #include <sys/thr.h>
#endif #endif
#include <fcntl.h> #include <fcntl.h>
@ -205,7 +205,7 @@ static pid_t _gettid(void)
return (pid_t) gettid(); return (pid_t) gettid();
#elif defined(__linux__) #elif defined(__linux__)
return syscall(SYS_gettid); return syscall(SYS_gettid);
#elif defined(__FreeBSD__) #elif defined(__FreeBSD__) || defined(__MidnightBSD__)
long pid; long pid;
thr_self(&pid); thr_self(&pid);
return (pid_t)pid; return (pid_t)pid;

View file

@ -38,7 +38,7 @@
#ifdef HAVE_PWD_H #ifdef HAVE_PWD_H
#include <pwd.h> #include <pwd.h>
#endif #endif
#ifdef __FreeBSD__ #if defined(__FreeBSD__) || defined(__MidnightBSD__)
#define O_PATH 0 #define O_PATH 0
#endif #endif

View file

@ -44,7 +44,7 @@
PW_LOG_TOPIC_EXTERN(log_mem); PW_LOG_TOPIC_EXTERN(log_mem);
#define PW_LOG_TOPIC_DEFAULT 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. * 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 #define HAVE_MEMFD_CREATE 1
#endif #endif
#ifdef __FreeBSD__ #if defined(__FreeBSD__) || defined(__MidnightBSD__)
#define MAP_LOCKED 0 #define MAP_LOCKED 0
#endif #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); pw_log_error("%p: Failed to create memfd: %m", pool);
goto error_free; 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); b->this.fd = shm_open(SHM_ANON, O_CREAT | O_RDWR | O_CLOEXEC, 0);
if (b->this.fd == -1) { if (b->this.fd == -1) {
res = -errno; res = -errno;

View file

@ -94,7 +94,7 @@ libpipewire_c_args = [
'-DOLD_MEDIA_SESSION_WORKAROUND=1' '-DOLD_MEDIA_SESSION_WORKAROUND=1'
] ]
if build_machine.system() != 'freebsd' if build_machine.system() != 'freebsd' and build_machine.system() != 'midnightbsd'
libpipewire_c_args += [ libpipewire_c_args += [
'-D_POSIX_C_SOURCE' '-D_POSIX_C_SOURCE'
] ]

View file

@ -27,7 +27,7 @@
#include <unistd.h> #include <unistd.h>
#include <limits.h> #include <limits.h>
#include <stdio.h> #include <stdio.h>
#ifndef __FreeBSD__ #if !defined(__FreeBSD__) && !defined(__MidnightBSD__)
#include <sys/prctl.h> #include <sys/prctl.h>
#endif #endif
#include <pwd.h> #include <pwd.h>
@ -746,7 +746,7 @@ static void init_prgname(void)
static char name[PATH_MAX]; static char name[PATH_MAX];
spa_memzero(name, sizeof(name)); 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) { if (readlink("/proc/self/exe", name, sizeof(name)-1) > 0) {
prgname = strrchr(name, '/') + 1; prgname = strrchr(name, '/') + 1;
@ -754,7 +754,7 @@ static void init_prgname(void)
} }
} }
#endif #endif
#if defined __FreeBSD__ #if defined __FreeBSD__ || defined(__MidnightBSD__)
{ {
ssize_t len; ssize_t len;
@ -764,7 +764,7 @@ static void init_prgname(void)
} }
} }
#endif #endif
#ifndef __FreeBSD__ #if !defined(__FreeBSD__) && !defined(__MidnightBSD__)
{ {
if (prctl(PR_GET_NAME, (unsigned long) name, 0, 0, 0) == 0) { if (prctl(PR_GET_NAME, (unsigned long) name, 0, 0, 0) == 0) {
prgname = name; prgname = name;

View file

@ -40,7 +40,7 @@ extern "C" {
#include <spa/utils/result.h> #include <spa/utils/result.h>
#include <spa/utils/type-info.h> #include <spa/utils/type-info.h>
#ifdef __FreeBSD__ #if defined(__FreeBSD__) || defined(__MidnightBSD__)
struct ucred { struct ucred {
}; };
#endif #endif

View file

@ -62,9 +62,9 @@ error:
return NULL; return NULL;
} }
#ifdef __FreeBSD__ #if defined(__FreeBSD__) || defined(__MidnightBSD__)
#include <sys/param.h> #include <sys/param.h>
#if __FreeBSD_version < 1202000 #if __FreeBSD_version < 1202000 || defined(__MidnightBSD__)
int pthread_setname_np(pthread_t thread, const char *name) int pthread_setname_np(pthread_t thread, const char *name)
{ {
pthread_set_name_np(thread, name); pthread_set_name_np(thread, name);

View file

@ -30,7 +30,7 @@
#include <signal.h> #include <signal.h>
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
#ifndef __FreeBSD__ #if !defined(__FreeBSD__) && !defined(__MidnightBSD__)
#include <alloca.h> #include <alloca.h>
#endif #endif
#include <getopt.h> #include <getopt.h>