Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GNU/Hurd support #993

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add GNU/Hurd support
Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
sthibaul committed Dec 30, 2024
commit 6da0a87eeb8094ae2cb7506a806c0bbf1fb19f79
2 changes: 1 addition & 1 deletion common/JackAudioAdapterFactory.cpp
Original file line number Diff line number Diff line change
@@ -35,7 +35,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#define JackPlatformAdapter JackAlsaAdapter
#endif

#if defined(__sun__) || defined(sun) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
#if defined(__sun__) || defined(sun) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__GNU__)
#include "JackOSSAdapter.h"
#define JackPlatformAdapter JackOSSAdapter
#endif
10 changes: 5 additions & 5 deletions common/JackMetadata.cpp
Original file line number Diff line number Diff line change
@@ -55,7 +55,7 @@ JackMetadata::JackMetadata(bool isEngine)
JackMetadata::~JackMetadata()
{
#if HAVE_DB
char dbpath[PATH_MAX + 1];
char dbpath[JACK_PATH_MAX + 1];

if (fDB) {
fDB->close (fDB, 0);
@@ -93,16 +93,16 @@ int JackMetadata::PropertyInit()
#if HAVE_DB

int ret;
char dbpath[PATH_MAX + 1];
char dbpath[JACK_PATH_MAX + 1];

#ifdef WIN32
ret = GetTempPathA (PATH_MAX, fDBFilesDir);
if ((ret > PATH_MAX) || (ret == 0)) {
ret = GetTempPathA (JACK_PATH_MAX, fDBFilesDir);
if ((ret > JACK_PATH_MAX) || (ret == 0)) {
jack_error ("cannot get path for temp files");
return -1;
}
#else
strncpy (fDBFilesDir, jack_server_dir, PATH_MAX);
strncpy (fDBFilesDir, jack_server_dir, JACK_PATH_MAX);
#endif

/* idempotent */
4 changes: 3 additions & 1 deletion common/JackMetadata.h
Original file line number Diff line number Diff line change
@@ -39,6 +39,8 @@

#include <jack/uuid.h>

#include "driver_interface.h"

#ifdef __cplusplus
extern "C" {
#endif
@@ -89,7 +91,7 @@ class JackMetadata
DB* fDB;
DB_ENV* fDBenv;
const bool fIsEngine;
char fDBFilesDir[PATH_MAX + 1];
char fDBFilesDir[JACK_PATH_MAX + 1];
#endif

int PropertyInit();
46 changes: 44 additions & 2 deletions common/wscript
Original file line number Diff line number Diff line change
@@ -33,6 +33,8 @@ def create_jack_process_obj(bld, target, sources, uselib=None, framework=None):
env_includes = ['../linux', '../posix', '../linux/alsa']
if bld.env['IS_FREEBSD']:
env_includes = ['../freebsd', '../posix', '../solaris/oss']
if bld.env['IS_HURD']:
env_includes = ['../gnu', '../posix', '../solaris/oss']
if bld.env['IS_SUN']:
env_includes = ['../solaris', '../posix', '../solaris/oss']
if bld.env['IS_WINDOWS']:
@@ -41,7 +43,7 @@ def create_jack_process_obj(bld, target, sources, uselib=None, framework=None):
process.name = target
process.target = target
process.source = sources
if bld.env['IS_LINUX'] or bld.env['IS_MACOSX'] or bld.env['IS_FREEBSD']:
if bld.env['IS_LINUX'] or bld.env['IS_MACOSX'] or bld.env['IS_FREEBSD'] or bld.env['IS_HURD']:
process.env.append_value('CPPFLAGS', '-fvisibility=hidden')
process.install_path = '${ADDON_DIR}/'
process.use = [uselib.name]
@@ -112,6 +114,20 @@ def build(bld):
]
includes = ['../freebsd', '../posix'] + includes

if bld.env['IS_HURD']:
common_libsources += [
'JackDebugClient.cpp',
'timestamps.c',
'promiscuous.c',
'../posix/JackPosixThread.cpp',
'../posix/JackPosixProcessSync.cpp',
'../posix/JackPosixMutex.cpp',
'../posix/JackPosixSemaphore.cpp',
'../posix/JackSocket.cpp',
'../posix/JackPosixTime.c',
]
includes = ['../gnu', '../posix'] + includes

if bld.env['IS_SUN']:
common_libsources += [
'JackDebugClient.cpp',
@@ -202,6 +218,12 @@ def build(bld):
'../posix/JackPosixServerLaunch.cpp',
]

if bld.env['IS_HURD']:
clientlib.source += [
'../posix/JackSocketClientChannel.cpp',
'../posix/JackPosixServerLaunch.cpp',
]

if bld.env['IS_SUN']:
clientlib.source += [
'../posix/JackSocketClientChannel.cpp',
@@ -234,6 +256,9 @@ def build(bld):
if bld.env['IS_FREEBSD']:
clientlib.env.append_value('CPPFLAGS', '-fvisibility=hidden')

if bld.env['IS_HURD']:
clientlib.env.append_value('CPPFLAGS', '-fvisibility=hidden')

if bld.env['IS_MACOSX']:
clientlib.env.append_value('CPPFLAGS', '-fvisibility=hidden')
clientlib.env.append_value('LINKFLAGS', '-single_module')
@@ -318,6 +343,14 @@ def build(bld):
'../posix/JackNetUnixSocket.cpp',
]

if bld.env['IS_HURD']:
serverlib.source += [
'../posix/JackSocketServerChannel.cpp',
'../posix/JackSocketNotifyChannel.cpp',
'../posix/JackSocketServerNotifyChannel.cpp',
'../posix/JackNetUnixSocket.cpp',
]

if bld.env['IS_SUN']:
serverlib.source += [
'../posix/JackSocketServerChannel.cpp',
@@ -411,6 +444,15 @@ def build(bld):
]
netlib.env.append_value('CPPFLAGS', '-fvisibility=hidden')

if bld.env['IS_HURD']:
netlib.source += [
'../posix/JackNetUnixSocket.cpp',
'../posix/JackPosixThread.cpp',
'../posix/JackPosixMutex.cpp',
'../linux/JackLinuxTime.c',
]
netlib.env.append_value('CPPFLAGS', '-fvisibility=hidden')

if bld.env['IS_SUN']:
netlib.source += [
'../posix/JackNetUnixSocket.cpp',
@@ -489,7 +531,7 @@ def build(bld):
process = create_jack_process_obj(bld, 'audioadapter', audio_adapter_sources, serverlib)
process.use += ['ALSA', 'SAMPLERATE']

if bld.env['BUILD_ADAPTER'] and (bld.env['IS_SUN'] or bld.env['IS_FREEBSD']):
if bld.env['BUILD_ADAPTER'] and (bld.env['IS_SUN'] or bld.env['IS_FREEBSD'] or bld.env['IS_HURD']):
audio_adapter_sources += ['../solaris/oss/JackOSSAdapter.cpp', 'memops.c']
process = create_jack_process_obj(bld, 'audioadapter', audio_adapter_sources, serverlib)
process.use += 'SAMPLERATE'
7 changes: 7 additions & 0 deletions dbus/wscript
Original file line number Diff line number Diff line change
@@ -53,6 +53,8 @@ def build(bld):
sysdeps_dbus_include = ['../linux', '../posix']
if bld.env['IS_FREEBSD']:
sysdeps_dbus_include = ['../freebsd', '../posix']
if bld.env['IS_HURD']:
sysdeps_dbus_include = ['../gnu', '../posix']
if bld.env['IS_MACOSX']:
sysdeps_dbus_include = ['../macosx', '../posix']

@@ -85,6 +87,11 @@ def build(bld):
'../linux/uptime.c',
]
obj.use += ['PTHREAD', 'EXECINFO', 'LIBSYSINFO', 'DBUS-1', 'EXPAT']
if bld.env['IS_HURD']:
obj.source += [
'../linux/uptime.c',
]
obj.use += ['PTHREAD', 'DL', 'RT', 'DBUS-1', 'EXPAT', 'STDC++']
if bld.env['IS_MACOSX']:
obj.source += [
'../macosx/uptime.c',
32 changes: 32 additions & 0 deletions gnu/JackAtomic_os.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
Copyright (C) 2004-2008 Grame

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

*/

#ifndef __JackAtomic_gnu__
#define __JackAtomic_gnu__

#include "JackTypes.h"

static inline char CAS(volatile UInt32 value, UInt32 newvalue, volatile void* addr)
{
UInt32 val = value;
return __atomic_compare_exchange_n ((UInt32*)addr, &val, newvalue, 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
}

#endif

85 changes: 85 additions & 0 deletions gnu/JackPlatformPlug_os.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/*
Copyright (C) 2004-2008 Grame
Copyright (C) 2018 Greg V

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

*/

#ifndef __JackPlatformPlug_gnu__
#define __JackPlatformPlug_gnu__

#define jack_server_dir "/tmp"
#define jack_client_dir "/tmp"
#define JACK_DEFAULT_DRIVER "oss"

namespace Jack
{
struct JackRequest;
struct JackResult;

class JackPosixMutex;
class JackPosixThread;
class JackPosixSemaphore;

class JackSocketServerChannel;
class JackSocketClientChannel;
class JackSocketServerNotifyChannel;
class JackSocketNotifyChannel;
class JackClientSocket;
class JackNetUnixSocket;
}

/* __JackPlatformMutex__ */
#include "JackPosixMutex.h"
namespace Jack {typedef JackPosixMutex JackMutex; }

/* __JackPlatformThread__ */
#include "JackPosixThread.h"
namespace Jack { typedef JackPosixThread JackThread; }

/* __JackPlatformSynchro__ client activation */
#include "JackPosixSemaphore.h"
namespace Jack { typedef JackPosixSemaphore JackSynchro; }

/* __JackPlatformChannelTransaction__ */
#include "JackSocket.h"
namespace Jack { typedef JackClientSocket JackChannelTransaction; }

/* __JackPlatformProcessSync__ */
#include "JackPosixProcessSync.h"
namespace Jack { typedef JackPosixProcessSync JackProcessSync; }

/* __JackPlatformServerChannel__ */
#include "JackSocketServerChannel.h"
namespace Jack { typedef JackSocketServerChannel JackServerChannel; }

/* __JackPlatformClientChannel__ */
#include "JackSocketClientChannel.h"
namespace Jack { typedef JackSocketClientChannel JackClientChannel; }

/* __JackPlatformServerNotifyChannel__ */
#include "JackSocketServerNotifyChannel.h"
namespace Jack { typedef JackSocketServerNotifyChannel JackServerNotifyChannel; }

/* __JackPlatformNotifyChannel__ */
#include "JackSocketNotifyChannel.h"
namespace Jack { typedef JackSocketNotifyChannel JackNotifyChannel; }

/* __JackPlatformNetSocket__ */
#include "JackNetUnixSocket.h"
namespace Jack { typedef JackNetUnixSocket JackNetSocket; }

#endif
1 change: 1 addition & 0 deletions gnu/driver.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "../linux/driver.h"
1 change: 1 addition & 0 deletions gnu/uptime.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "../linux/uptime.h"
8 changes: 8 additions & 0 deletions solaris/oss/JackOSSAdapter.cpp
Original file line number Diff line number Diff line change
@@ -197,7 +197,9 @@ JackOSSAdapter::JackOSSAdapter(jack_nframes_t buffer_size, jack_nframes_t sample
void JackOSSAdapter::DisplayDeviceInfo()
{
audio_buf_info info;
#ifdef SNDCTL_AUDIOINFO
oss_audioinfo ai_in, ai_out;
#endif
memset(&info, 0, sizeof(audio_buf_info));
int cap = 0;

@@ -208,6 +210,7 @@ void JackOSSAdapter::DisplayDeviceInfo()

if (fRWMode & kWrite) {

#ifdef OSS_SYSINFO
oss_sysinfo si;
if (ioctl(fOutFD, OSS_SYSINFO, &si) == -1) {
jack_error("JackOSSAdapter::DisplayDeviceInfo OSS_SYSINFO failed : %s@%i, errno = %d", __FILE__, __LINE__, errno);
@@ -219,6 +222,7 @@ void JackOSSAdapter::DisplayDeviceInfo()
jack_info("OSS numaudioengines %d", si.numaudioengines);
jack_info("OSS numcards %d", si.numcards);
}
#endif

jack_info("Output capabilities - %d channels : ", fPlaybackChannels);
jack_info("Output block size = %d", fOutputBufferSize);
@@ -246,6 +250,7 @@ void JackOSSAdapter::DisplayDeviceInfo()

if (fRWMode & kRead) {

#ifdef OSS_SYSINFO
oss_sysinfo si;
if (ioctl(fInFD, OSS_SYSINFO, &si) == -1) {
jack_error("JackOSSAdapter::DisplayDeviceInfo OSS_SYSINFO failed : %s@%i, errno = %d", __FILE__, __LINE__, errno);
@@ -257,6 +262,7 @@ void JackOSSAdapter::DisplayDeviceInfo()
jack_info("OSS numaudioengines %d", si.numaudioengines);
jack_info("OSS numcards %d", si.numcards);
}
#endif

jack_info("Input capabilities - %d channels : ", fCaptureChannels);
jack_info("Input block size = %d", fInputBufferSize);
@@ -282,6 +288,7 @@ void JackOSSAdapter::DisplayDeviceInfo()
}
}

#ifdef SNDCTL_AUDIOINFO
if (ioctl(fInFD, SNDCTL_AUDIOINFO, &ai_in) != -1) {
jack_info("Using audio engine %d = %s for input", ai_in.dev, ai_in.name);
}
@@ -293,6 +300,7 @@ void JackOSSAdapter::DisplayDeviceInfo()
if (ai_in.rate_source != ai_out.rate_source) {
jack_info("Warning : input and output are not necessarily driven by the same clock!");
}
#endif
}

int JackOSSAdapter::OpenInput()
4 changes: 4 additions & 0 deletions solaris/oss/JackOSSDriver.cpp
Original file line number Diff line number Diff line change
@@ -150,6 +150,7 @@ void JackOSSDriver::DisplayDeviceInfo()

if (fRWMode & kWrite) {

#ifdef OSS_SYSINFO
oss_sysinfo si;
if (ioctl(fOutFD, OSS_SYSINFO, &si) == -1) {
jack_error("JackOSSDriver::DisplayDeviceInfo OSS_SYSINFO failed : %s@%i, errno = %d", __FILE__, __LINE__, errno);
@@ -161,6 +162,7 @@ void JackOSSDriver::DisplayDeviceInfo()
jack_info("OSS numaudioengines %d", si.numaudioengines);
jack_info("OSS numcards %d", si.numcards);
}
#endif

jack_info("Output capabilities - %d channels : ", fPlaybackChannels);
jack_info("Output block size = %d", fOutputBufferSize);
@@ -188,6 +190,7 @@ void JackOSSDriver::DisplayDeviceInfo()

if (fRWMode & kRead) {

#ifdef OSS_SYSINFO
oss_sysinfo si;
if (ioctl(fInFD, OSS_SYSINFO, &si) == -1) {
jack_error("JackOSSDriver::DisplayDeviceInfo OSS_SYSINFO failed : %s@%i, errno = %d", __FILE__, __LINE__, errno);
@@ -199,6 +202,7 @@ void JackOSSDriver::DisplayDeviceInfo()
jack_info("OSS numaudioengines %d", si.numaudioengines);
jack_info("OSS numcards %d", si.numcards);
}
#endif

jack_info("Input capabilities - %d channels : ", fCaptureChannels);
jack_info("Input block size = %d", fInputBufferSize);
2 changes: 2 additions & 0 deletions tests/wscript
Original file line number Diff line number Diff line change
@@ -23,6 +23,8 @@ def build(bld):
prog.includes = ['..', '../linux', '../posix', '../common/jack', '../common']
if bld.env['IS_FREEBSD']:
prog.includes = ['..', '../freebsd', '../posix', '../common/jack', '../common']
if bld.env['IS_HURD']:
prog.includes = ['..', '../gnu', '../posix', '../common/jack', '../common']
if bld.env['IS_SUN']:
prog.includes = ['..', '../solaris', '../posix', '../common/jack', '../common']
prog.source = test_program_sources
17 changes: 15 additions & 2 deletions wscript
Original file line number Diff line number Diff line change
@@ -221,8 +221,9 @@ def detect_platform(conf):
# GNU/kFreeBSD and GNU/Hurd are treated as Linux
platforms = [
# ('KEY, 'Human readable name', ['strings', 'to', 'check', 'for'])
('IS_LINUX', 'Linux', ['gnu0', 'gnukfreebsd', 'linux', 'posix']),
('IS_LINUX', 'Linux', ['gnukfreebsd', 'linux', 'posix']),
('IS_FREEBSD', 'FreeBSD', ['freebsd']),
('IS_HURD', 'GNU/Hurd',['gnu0']),
('IS_MACOSX', 'MacOS X', ['darwin']),
('IS_SUN', 'SunOS', ['sunos']),
('IS_WINDOWS', 'Windows', ['cygwin', 'msys', 'win32'])
@@ -548,6 +549,9 @@ def obj_add_includes(bld, obj):
if bld.env['IS_FREEBSD']:
obj.includes += ['freebsd', 'posix']

if bld.env['IS_HURD']:
obj.includes += ['gnu', 'posix']

if bld.env['IS_MACOSX']:
obj.includes += ['macosx', 'posix']

@@ -579,6 +583,9 @@ def build_jackd(bld):
if bld.env['IS_FREEBSD']:
jackd.use += ['M', 'PTHREAD']

if bld.env['IS_HURD']:
jackd.use += ['DL', 'M', 'PTHREAD', 'RT', 'STDC++']

if bld.env['IS_MACOSX']:
jackd.use += ['DL', 'PTHREAD']
jackd.framework = ['CoreFoundation']
@@ -810,6 +817,12 @@ def build_drivers(bld):
target='oss',
source=freebsd_oss_src)

if bld.env['IS_HURD']:
create_driver_obj(
bld,
target='oss',
source=oss_src)

if bld.env['IS_SUN']:
create_driver_obj(
bld,
@@ -839,7 +852,7 @@ def build(bld):

build_drivers(bld)

if bld.env['IS_LINUX'] or bld.env['IS_FREEBSD']:
if bld.env['IS_LINUX'] or bld.env['IS_FREEBSD'] or bld.env['IS_HURD']:
bld.recurse('man')
bld.recurse('systemd')
if not bld.env['IS_WINDOWS'] and bld.env['BUILD_TESTS']: