From e59ba362f103c0cbd0a23a9cd8dd3949c0f49099 Mon Sep 17 00:00:00 2001 From: Christian Garbs Date: Mon, 29 Jan 2024 23:51:40 +0100 Subject: [PATCH] fix sys/soundcard.h related build failure on FreeBSD The FreeBSD build was broken because special typedefs like `u_long` and `u_char` weren't known when including `sys/soundcard.h` during compile. When we introduced some strict POSIX/C11 flags with commit fad6a3e3b951, this seems to have disabled the __BSD_VISIBLE flag on FreeBSD which made these typedefs disappear (there is a `#if __BSD_VISIBLE` guard in `sys/types.h`). We don't know the reason for disabling `__BSD_VISIBLE` (perhaps it is along the line of "if you want POSIX, you don't get BSD enhancements") and we don't know if there are adverse side-effects to manually enabling `__BSD_VISIBLE`, but for now it works. If anybody has deeper understanding of this and a better way to fix this, please speak up :) This fixes issue #105. (n.b.: `sys/soundcard.h` contains two sound systems: AIO and OSS. The missing typedefs are only used for AIO while we only need OSS. So if that header file would have been split into two seperate files, we would not have run into this problem. The OSS part should work fine with the POSIX/C11 flags without setting `__BSD_VISIBLE`.) --- HISTORY | 5 +++++ configure | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/HISTORY b/HISTORY index 24d480a..ced6f8e 100644 --- a/HISTORY +++ b/HISTORY @@ -5,6 +5,11 @@ gbsplay HISTORY 202x/xx/xx - unreleased ~~~~~~~~~~~~~~~~~~~~~~~~~ +Bugfixes: + +- build process: + - fix build errors of devdsp plugout on FreeBSD + Enhancements: - build process: diff --git a/configure b/configure index deed848..2773b3f 100755 --- a/configure +++ b/configure @@ -762,6 +762,39 @@ if [ "$use_devdsp" != no ]; then remember_use devdsp check_include sys/soundcard.h use_devdsp="$have_sys_soundcard_h" + # this check is needed for FreeBSD but it only works when the C11 flags are used + C11_FLAGS="-D_XOPEN_SOURCE=500 -D_POSIX_C_SOURCE=200809L" + if [ "$have_sys_soundcard_h" = yes ]; then + if ! cc_check "checking if we need additional flags for sys/soundcard.h" "" "$C11_FLAGS" "no" "yes" < +int main(int argc, char **argv) +{ + #ifdef OPEN_SOUND_SYSTEM + return 0; + #else + return 1; + #endif +} +EOF + + if cc_check "checking if we need __BSD_VISIBLE for sys/soundcard.h" "" "$C11_FLAGS -D__BSD_VISIBLE" "yes" "no" < +int main(int argc, char **argv) +{ + #ifdef OPEN_SOUND_SYSTEM + return 0; + #else + return 1; + #endif +} +EOF + append_nodupe CFLAGS "-D__BSD_VISIBLE" + else + echo "no way found to make sys/soundcard.h work" + use_devdsp=no + fi + fi + fi recheck_use devdsp fi