Skip to content

Commit

Permalink
Merge pull request #62 from jcowgill/atomics-cleanup
Browse files Browse the repository at this point in the history
Atomics cleanup
  • Loading branch information
falkTX authored Jan 16, 2017
2 parents 90f9dd3 + ddc60b0 commit 44e2398
Show file tree
Hide file tree
Showing 15 changed files with 23 additions and 247 deletions.
2 changes: 1 addition & 1 deletion config/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# We don't actually build anything in the `cpu' and `os'
# subdirectories.

DIST_SUBDIRS = cpu os sysdeps
DIST_SUBDIRS = os sysdeps

EXTRA_DIST = depcomp
MAINTAINERCLEANFILES = Makefile.in config.guess config.sub \
Expand Down
2 changes: 0 additions & 2 deletions config/cpu/Makefile.am

This file was deleted.

3 changes: 0 additions & 3 deletions config/cpu/generic/Makefile.am

This file was deleted.

39 changes: 0 additions & 39 deletions config/cpu/generic/atomicity.h

This file was deleted.

3 changes: 0 additions & 3 deletions config/cpu/i386/Makefile.am

This file was deleted.

53 changes: 0 additions & 53 deletions config/cpu/i386/atomicity.h

This file was deleted.

3 changes: 0 additions & 3 deletions config/cpu/powerpc/Makefile.am

This file was deleted.

80 changes: 0 additions & 80 deletions config/cpu/powerpc/atomicity.h

This file was deleted.

1 change: 0 additions & 1 deletion config/sysdeps/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ MAINTAINERCLEANFILES = Makefile.in
noinst_HEADERS = \
systemtest.c \
sanitycheck.c \
atomicity.h \
getopt.h \
ipc.h \
mach_port.h \
Expand Down
24 changes: 0 additions & 24 deletions config/sysdeps/atomicity.h

This file was deleted.

4 changes: 0 additions & 4 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -964,10 +964,6 @@ AM_CONDITIONAL(HAVE_ZITA_BRIDGE_DEPS, $HAVE_ZITA_BRIDGE_DEPS)
AC_OUTPUT(
Makefile
config/Makefile
config/cpu/Makefile
config/cpu/generic/Makefile
config/cpu/i386/Makefile
config/cpu/powerpc/Makefile
config/os/Makefile
config/os/generic/Makefile
config/os/gnu-linux/Makefile
Expand Down
19 changes: 0 additions & 19 deletions doc/porting.dox
Original file line number Diff line number Diff line change
Expand Up @@ -88,25 +88,6 @@ Be sure to place any generic implementation alternative in the @c
\#else or use an @c \#ifndef, so no other code needs to know your
conditional labels.

@section portcpu Processor Dependencies

JACK uses some low-level machine operations for thread-safe updates to
shared memory. A low-level implementation of @c <sysdeps/atomicity.h>
is provided for every target processor architecture. There is also a
generic implementation using POSIX spin locks, but that is not a good
enough solution for serious use.

The GCC package provides versions that work on most modern hardware.
We've tried to keep things as close to the original as possible, while
removing a bunch of os-specific files that didn't seem relevant. A
primary goal has been to avoid changing the CPU-dependent @c
<sysdeps/atomicity.h> headers.

The relevant GCC documentation provides some helpful background,
especially the @c atomicity.h discussion at
<http://gcc.gnu.org/onlinedocs/porting/Thread-safety.html>.


@section portissues Issues Not Addressed

- Cross-compilation has not been tested, or even thought through in
Expand Down
33 changes: 20 additions & 13 deletions include/atomicity.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,26 @@
#ifndef __jack_atomicity_h__
#define __jack_atomicity_h__

/*
* Interface with various machine-dependent headers derived from the
* gcc/libstdc++.v3 sources. We try to modify the GCC sources as
* little as possible. The following include is resolved using the
* config/configure.hosts mechanism. It will use an OS-dependent
* version if available, otherwise the one for this CPU. Some of
* these files might not work with older GCC compilers.
*/
#include <sysdeps/atomicity.h>
#if __STDC_VERSION__ >= 201112L && !defined(__STDC_NO_ATOMICS__)

#include <stdatomic.h>

typedef atomic_int _Atomic_word;

static inline int exchange_and_add(volatile _Atomic_word* obj, int value)
{
return atomic_fetch_add_explicit(obj, value, memory_order_relaxed);
}

#else

typedef int _Atomic_word;

static inline int exchange_and_add(volatile _Atomic_word* obj, int value)
{
return __atomic_fetch_add(obj, value, __ATOMIC_RELAXED);
}

/* These functions are defined for each platform. The C++ library
* function names start with "__" to avoid namespace pollution. */
#define exchange_and_add __exchange_and_add
#define atomic_add __atomic_add
#endif

#endif /* __jack_atomicity_h__ */
2 changes: 1 addition & 1 deletion include/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void jack_set_clock_source (jack_timer_type_t);
const char* jack_clock_source_name (jack_timer_type_t);

#include <sysdeps/time.h>
#include <sysdeps/atomicity.h>
#include "atomicity.h"

#ifdef JACK_USE_MACH_THREADS
#include <sysdeps/mach_port.h>
Expand Down
2 changes: 1 addition & 1 deletion libjack/messagebuffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ jack_messagebuffer_add (const char *fmt, ...)
pthread_cond_signal (&mb_ready_cond);
pthread_mutex_unlock (&mb_write_lock);
} else { /* lock collision */
atomic_add (&mb_overruns, 1);
exchange_and_add (&mb_overruns, 1);
}
}

Expand Down

0 comments on commit 44e2398

Please sign in to comment.