summaryrefslogtreecommitdiff
path: root/audio
diff options
context:
space:
mode:
authorahoka <ahoka@pkgsrc.org>2008-12-20 16:10:25 +0000
committerahoka <ahoka@pkgsrc.org>2008-12-20 16:10:25 +0000
commitd62bb247652a5cfb91cb7a1cb1a072fb0320c449 (patch)
tree95bbda0eb614fe5b89b3d7cb435cfddb5202fe62 /audio
parentdfbd71e29faffa2a31a1b845de2f14dff9ba425d (diff)
downloadpkgsrc-d62bb247652a5cfb91cb7a1cb1a072fb0320c449.tar.gz
Implement support for atomic_ops(3) backend.
This gives us native atomic operations on NetBSD 5.0 and later systems. Use GCC's builtin atomic operations when possible and libatomic_ops as a last case fallback.
Diffstat (limited to 'audio')
-rw-r--r--audio/pulseaudio/Makefile22
-rw-r--r--audio/pulseaudio/distinfo4
-rw-r--r--audio/pulseaudio/patches/patch-ba57
-rw-r--r--audio/pulseaudio/patches/patch-bb86
4 files changed, 162 insertions, 7 deletions
diff --git a/audio/pulseaudio/Makefile b/audio/pulseaudio/Makefile
index b7e81b3d19a..54159a9c482 100644
--- a/audio/pulseaudio/Makefile
+++ b/audio/pulseaudio/Makefile
@@ -1,8 +1,8 @@
-# $NetBSD: Makefile,v 1.3 2008/12/20 11:00:43 ahoka Exp $
+# $NetBSD: Makefile,v 1.4 2008/12/20 16:10:25 ahoka Exp $
#
DISTNAME= pulseaudio-0.9.13
-PKGREVISION= 1
+PKGREVISION= 2
CATEGORIES= audio
MASTER_SITES= http://0pointer.de/lennart/projects/pulseaudio/
@@ -12,7 +12,8 @@ COMMENT= Sound server for POSIX and Win32 systems
GNU_CONFIGURE= yes
USE_LIBTOOL= yes
-USE_TOOLS+= pkg-config gmake msgfmt intltool perl
+USE_TOOLS+= pkg-config gmake msgfmt intltool perl \
+ autoconf automake
USE_DIRS+= xdg-1.4
PKGCONFIG_OVERRIDE+= libpulse-browse.pc.in
@@ -61,11 +62,20 @@ PKG_USERS= ${PULSE_USER}:${PULSE_GROUP}
BUILDLINK_TRANSFORM+= rm:-Wl,--gc-sections
# Needs libatomic_ops if the compiler is not >=GCC4.1
-.include "../../mk/compiler.mk"
-.if empty(CC_VERSION:Mgcc-4.[1-9]*) && empty(CC_VERSION:Mgcc-[5-9]*)
-. include "../../devel/libatomic_ops/buildlink3.mk"
+# We can use native atomic operation on 5.0 and newer.
+#
+.if exists(/include/sys/atomic.h) # NetBSD >=5.0
+ CONFIGURE_ARGS+= --enable-netbsd-atomic-ops
+.else # NetBSD <5.0 and other OS
+. include "../../mk/compiler.mk"
+. if empty(CC_VERSION:Mgcc-4.[1-9]*) && empty(CC_VERSION:Mgcc-[5-9]*)
+. include "../../devel/libatomic_ops/buildlink3.mk"
+. endif
.endif
+pre-configure:
+ cd ${WRKSRC} && autoreconf -f
+
.include "../../audio/libsamplerate/buildlink3.mk"
.include "../../audio/libsndfile/buildlink3.mk"
.include "../../audio/speex/buildlink3.mk"
diff --git a/audio/pulseaudio/distinfo b/audio/pulseaudio/distinfo
index 15eec53b798..c76b858eda3 100644
--- a/audio/pulseaudio/distinfo
+++ b/audio/pulseaudio/distinfo
@@ -1,4 +1,4 @@
-$NetBSD: distinfo,v 1.2 2008/12/18 18:43:52 jmcneill Exp $
+$NetBSD: distinfo,v 1.3 2008/12/20 16:10:25 ahoka Exp $
SHA1 (pulseaudio-0.9.13.tar.gz) = c8482f1bb42d5213bfdbe2154e1a55b7bc04c915
RMD160 (pulseaudio-0.9.13.tar.gz) = 07cea9939dfb4fc76f13bf01dfe22ab6d0fd8459
@@ -9,3 +9,5 @@ SHA1 (patch-ac) = 8f61cf7c4a6681ab53c9ddf1007acb1bf524fe15
SHA1 (patch-ad) = 63571597ba707679142b45b2daaffade7f094bb0
SHA1 (patch-ae) = 1cd31d18c133fdd5e8db59be319ba5b7a45fe0fe
SHA1 (patch-af) = 31b8564cb91aabb5de5490659e77de984fd1920b
+SHA1 (patch-ba) = 518d23027fc9467a8bae2385233c2991136ee905
+SHA1 (patch-bb) = 1a9f436c0809af35b4846d09be5ffdc25fa7daeb
diff --git a/audio/pulseaudio/patches/patch-ba b/audio/pulseaudio/patches/patch-ba
new file mode 100644
index 00000000000..3fa22358ce5
--- /dev/null
+++ b/audio/pulseaudio/patches/patch-ba
@@ -0,0 +1,57 @@
+$NetBSD: patch-ba,v 1.1 2008/12/20 16:10:25 ahoka Exp $
+
+--- configure.ac.orig 2008-10-06 02:39:37.000000000 +0200
++++ configure.ac
+@@ -125,6 +125,16 @@ AC_ARG_ENABLE([atomic-arm-memory-barrier
+ no) ;;
+ *) AC_MSG_ERROR(bad value ${enableval} for --disable-atomic-arm-linux-helpers) ;;
+ esac
++ ],)
++
++AC_ARG_ENABLE([netbsd-atomic-ops],
++ AS_HELP_STRING([--enable-netbsd-atomic-ops],[Use the native NetBSD atomic_ops implementation]),
++ [
++ case "${enableval}" in
++ yes) AC_DEFINE_UNQUOTED(NETBSD_ATOMIC_OPS_ENABLED, 1, [Enable NetBSD atomic_ops]) ;;
++ no) ;;
++ *) AC_MSG_ERROR(bad value ${enableval} for --enable-netbsd-atomic-ops) ;;
++ esac
+ ],)
+
+ AC_MSG_CHECKING([target operating system])
+@@ -133,6 +143,10 @@ case $host in
+ AC_MSG_RESULT([linux])
+ pulse_target_os=linux
+ ;;
++ *-*-netbsd*)
++ AC_MSG_RESULT([netbsd])
++ pulse_target_os=netbsd
++ ;;
+ *)
+ AC_MSG_RESULT([unknown])
+ pulse_target_os=unknown
+@@ -193,7 +207,13 @@ else
+ fi
+ ;;
+ *)
+- AC_MSG_RESULT([unknown])
++ if test "x$pulse_target_os" = "xnetbsd" && test "x$ac_cv_header_sys_atomic_h" != "xno"; then
++ AC_MSG_RESULT([yes])
++ AC_DEFINE_UNQUOTED(NETBSD_ATOMIC_OPS, 1, [netbsd implementation])
++ need_libatomic_ops=no
++ else
++ AC_MSG_RESULT([unknown])
++ fi
+ ;;
+ esac
+ fi
+@@ -292,6 +312,9 @@ AC_CHECK_HEADERS([sys/filio.h])
+ # Windows
+ AC_CHECK_HEADERS([windows.h winsock2.h ws2tcpip.h])
+
++# NetBSD
++AC_CHECK_HEADERS([sys/atomic.h])
++
+ # Other
+ AC_CHECK_HEADERS([sys/ioctl.h])
+ AC_CHECK_HEADERS([byteswap.h])
diff --git a/audio/pulseaudio/patches/patch-bb b/audio/pulseaudio/patches/patch-bb
new file mode 100644
index 00000000000..653d7bcaca3
--- /dev/null
+++ b/audio/pulseaudio/patches/patch-bb
@@ -0,0 +1,86 @@
+$NetBSD: patch-bb,v 1.1 2008/12/20 16:10:25 ahoka Exp $
+
+--- src/pulsecore/atomic.h.orig 2008-09-03 23:13:44.000000000 +0200
++++ src/pulsecore/atomic.h
+@@ -107,6 +107,81 @@ static inline pa_bool_t pa_atomic_ptr_cm
+ return __sync_bool_compare_and_swap(&a->value, (long) old_p, (long) new_p);
+ }
+
++#elif defined(NETBSD_ATOMIC_OPS)
++
++/* NetBSD 5.0+ atomic_ops(3) implementation */
++
++#include <sys/atomic.h>
++
++typedef struct pa_atomic {
++ volatile unsigned int value;
++} pa_atomic_t;
++
++#define PA_ATOMIC_INIT(v) { .value = (unsigned int) (v) }
++
++static inline int pa_atomic_load(const pa_atomic_t *a) {
++ membar_sync();
++ return (int) a->value;
++}
++
++static inline void pa_atomic_store(pa_atomic_t *a, int i) {
++ a->value = (unsigned int) i;
++ membar_sync();
++}
++
++/* Returns the previously set value */
++static inline int pa_atomic_add(pa_atomic_t *a, int i) {
++ return (int) atomic_add_int_nv(&a->value, i);
++}
++
++/* Returns the previously set value */
++static inline int pa_atomic_sub(pa_atomic_t *a, int i) {
++ return (int) atomic_add_int_nv(&a->value, -i);
++}
++
++/* Returns the previously set value */
++static inline int pa_atomic_inc(pa_atomic_t *a) {
++ return (int) atomic_inc_uint_nv(&a->value);
++}
++
++/* Returns the previously set value */
++static inline int pa_atomic_dec(pa_atomic_t *a) {
++ return (int) atomic_dec_uint_nv(&a->value);
++}
++
++/* Returns TRUE when the operation was successful. */
++static inline pa_bool_t pa_atomic_cmpxchg(pa_atomic_t *a, int old_i, int new_i) {
++ unsigned int r = atomic_cas_uint(&a->value, (unsigned int) old_i, (unsigned int) new_i);
++ if ((int) r == old_i)
++ return TRUE;
++ else
++ return FALSE;
++}
++
++typedef struct pa_atomic_ptr {
++ volatile void *value;
++} pa_atomic_ptr_t;
++
++#define PA_ATOMIC_PTR_INIT(v) { .value = (v) }
++
++static inline void* pa_atomic_ptr_load(const pa_atomic_ptr_t *a) {
++ membar_sync();
++ return (void *) a->value;
++}
++
++static inline void pa_atomic_ptr_store(pa_atomic_ptr_t *a, void *p) {
++ a->value = p;
++ membar_sync();
++}
++
++static inline pa_bool_t pa_atomic_ptr_cmpxchg(pa_atomic_ptr_t *a, void *old_p, void* new_p) {
++ void *r = atomic_cas_ptr(&a->value, old_p, new_p);
++ if (r == old_p)
++ return TRUE;
++ else
++ return FALSE;
++}
++
+ #elif defined(__GNUC__) && (defined(__amd64__) || defined(__x86_64__))
+
+ #warn "The native atomic operations implementation for AMD64 has not been tested thoroughly. libatomic_ops is known to not work properly on AMD64 and your gcc version is too old for the gcc-builtin atomic ops support. You have three options now: test the native atomic operations implementation for AMD64, fix libatomic_ops, or upgrade your GCC."