Skip to content

Commit

Permalink
fix sys/soundcard.h related build failure on FreeBSD
Browse files Browse the repository at this point in the history
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
fad6a3e, 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`.)
  • Loading branch information
mmitch committed Jan 30, 2024
1 parent b4eb66a commit e59ba36
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
5 changes: 5 additions & 0 deletions HISTORY
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ gbsplay HISTORY
202x/xx/xx - unreleased
~~~~~~~~~~~~~~~~~~~~~~~~~

Bugfixes:

- build process:
- fix build errors of devdsp plugout on FreeBSD

Enhancements:

- build process:
Expand Down
33 changes: 33 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -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" <<EOF; then
#include <sys/soundcard.h>
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" <<EOF; then
#include <sys/soundcard.h>
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

Expand Down

0 comments on commit e59ba36

Please sign in to comment.