pkgsrc-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[pkgsrc/trunk]: pkgsrc/audio/pulseaudio Implement support for atomic_ops(3) b...
details: https://anonhg.NetBSD.org/pkgsrc/rev/d32324d5110f
branches: trunk
changeset: 551816:d32324d5110f
user: ahoka <ahoka%pkgsrc.org@localhost>
date: Sat Dec 20 16:10:25 2008 +0000
description:
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:
audio/pulseaudio/Makefile | 22 +++++++--
audio/pulseaudio/distinfo | 4 +-
audio/pulseaudio/patches/patch-ba | 57 +++++++++++++++++++++++++
audio/pulseaudio/patches/patch-bb | 86 +++++++++++++++++++++++++++++++++++++++
4 files changed, 162 insertions(+), 7 deletions(-)
diffs (214 lines):
diff -r e3291aad53c6 -r d32324d5110f audio/pulseaudio/Makefile
--- a/audio/pulseaudio/Makefile Sat Dec 20 15:57:02 2008 +0000
+++ b/audio/pulseaudio/Makefile Sat Dec 20 16:10:25 2008 +0000
@@ -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 @@
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 @@
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 -r e3291aad53c6 -r d32324d5110f audio/pulseaudio/distinfo
--- a/audio/pulseaudio/distinfo Sat Dec 20 15:57:02 2008 +0000
+++ b/audio/pulseaudio/distinfo Sat Dec 20 16:10:25 2008 +0000
@@ -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-ad) = 63571597ba707679142b45b2daaffade7f094bb0
SHA1 (patch-ae) = 1cd31d18c133fdd5e8db59be319ba5b7a45fe0fe
SHA1 (patch-af) = 31b8564cb91aabb5de5490659e77de984fd1920b
+SHA1 (patch-ba) = 518d23027fc9467a8bae2385233c2991136ee905
+SHA1 (patch-bb) = 1a9f436c0809af35b4846d09be5ffdc25fa7daeb
diff -r e3291aad53c6 -r d32324d5110f audio/pulseaudio/patches/patch-ba
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/audio/pulseaudio/patches/patch-ba Sat Dec 20 16:10:25 2008 +0000
@@ -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 -r e3291aad53c6 -r d32324d5110f audio/pulseaudio/patches/patch-bb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/audio/pulseaudio/patches/patch-bb Sat Dec 20 16:10:25 2008 +0000
@@ -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."
Home |
Main Index |
Thread Index |
Old Index