Index: Makefile.all.am
===================================================================
--- Makefile.all.am	(revision 10888)
+++ Makefile.all.am	(working copy)
@@ -88,6 +88,7 @@
 	-Wpointer-arith \
 	-Wstrict-prototypes \
 	-Wmissing-declarations \
+	-Wno-pointer-sign \
 	@FLAG_W_NO_FORMAT_ZERO_LENGTH@ \
 	-fno-strict-aliasing
 
Index: mpi/Makefile.am
===================================================================
--- mpi/Makefile.am	(revision 10888)
+++ mpi/Makefile.am	(working copy)
@@ -56,15 +56,15 @@
 
 
 if BUILD_MPIWRAP_PRI
-libmpiwrap_@VGCONF_ARCH_PRI@_@VGCONF_OS@_so_SOURCES  = libmpiwrap.c
-libmpiwrap_@VGCONF_ARCH_PRI@_@VGCONF_OS@_so_CPPFLAGS = -I../include
+libmpiwrap_@VGCONF_ARCH_PRI@_@VGCONF_OS@_so_SOURCES  = $(srcdir)/libmpiwrap.c
+libmpiwrap_@VGCONF_ARCH_PRI@_@VGCONF_OS@_so_CPPFLAGS = -I$(srcdir)/../include
 libmpiwrap_@VGCONF_ARCH_PRI@_@VGCONF_OS@_so_CFLAGS   = \
 	$(CFLAGS_MPI) $(MPI_FLAG_M3264_PRI)
 libmpiwrap_@VGCONF_ARCH_PRI@_@VGCONF_OS@_so_LDFLAGS  = $(LDFLAGS_MPI)
 endif
 if BUILD_MPIWRAP_SEC
-libmpiwrap_@VGCONF_ARCH_SEC@_@VGCONF_OS@_so_SOURCES  = libmpiwrap.c
-libmpiwrap_@VGCONF_ARCH_SEC@_@VGCONF_OS@_so_CPPFLAGS = -I../include
+libmpiwrap_@VGCONF_ARCH_SEC@_@VGCONF_OS@_so_SOURCES  = $(srcdir)/libmpiwrap.c
+libmpiwrap_@VGCONF_ARCH_SEC@_@VGCONF_OS@_so_CPPFLAGS = -I$(srcdir)/../include
 libmpiwrap_@VGCONF_ARCH_SEC@_@VGCONF_OS@_so_CFLAGS   = \
 	$(CFLAGS_MPI) $(MPI_FLAG_M3264_SEC)
 libmpiwrap_@VGCONF_ARCH_SEC@_@VGCONF_OS@_so_LDFLAGS  = $(LDFLAGS_MPI)
Index: darwin10-drd.supp
===================================================================
--- darwin10-drd.supp	(revision 0)
+++ darwin10-drd.supp	(revision 0)
@@ -0,0 +1,2 @@
+
+# DRD suppressions for Darwin 10.x / Mac OS X 10.6 Snow Leopard
Index: include/vki/vki-darwin.h
===================================================================
--- include/vki/vki-darwin.h	(revision 10888)
+++ include/vki/vki-darwin.h	(working copy)
@@ -792,6 +792,11 @@
 typedef struct eventreq vki_eventreq;
 
 
+#include <sys/acl.h>
+
+#define vki_kauth_filesec kauth_filesec
+
+
 #include <sys/ptrace.h>
 
 #define VKI_PTRACE_TRACEME   PT_TRACE_ME
@@ -1021,6 +1026,10 @@
 #define	VKI_A_GETPINFO_ADDR	A_GETPINFO_ADDR	
 #define	VKI_A_GETKAUDIT	A_GETKAUDIT	
 #define	VKI_A_SETKAUDIT	A_SETKAUDIT	
+#if DARWIN_VERS >= DARWIN_10_6
+#define VKI_A_SENDTRIGGER A_SENDTRIGGER
+#define VKI_A_GETSINFO_ADDR A_GETSINFO_ADDR
+#endif
 
 
 #include <sys/aio.h>
Index: include/vki/vki-scnums-darwin.h
===================================================================
--- include/vki/vki-scnums-darwin.h	(revision 10888)
+++ include/vki/vki-scnums-darwin.h	(working copy)
@@ -32,6 +32,9 @@
 #define __VKI_SCNUMS_DARWIN_H
 
 
+// need DARWIN_10_x definitions
+#include "config.h"
+
 // osfmk/mach/i386/syscall_sw.h
 
 // There are two syscall number encodings in Darwin.
@@ -376,7 +379,11 @@
 #define __NR_sigreturn      VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(184)
 #define __NR_chud           VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(185)
 			/* 186  */
+#if DARWIN_VERS >= DARWIN_10_6
+#define __NR_fdatasync      VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(187)
+#else
 			/* 187  */
+#endif
 #define	__NR_stat           VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(188)
 #define	__NR_fstat          VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(189)
 #define	__NR_lstat          VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(190)
@@ -403,8 +410,13 @@
 #define	__NR_ATPgetreq      VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(211)
 #define	__NR_ATPgetrsp      VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(212)
 			/* 213  Reserved for AppleTalk */
-#define	__NR_kqueue_from_portset_np VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(214)
-#define	__NR_kqueue_portset_np VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(215)
+#if DARWIN_VERS >= DARWIN_10_6
+                        /* 214  old kqueue_from_portset_np*/
+                        /* 215  old kqueue_portset_np*/
+#else
+#define __NR_kqueue_from_portset_np VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(214)
+#define __NR_kqueue_portset_np VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(215)
+#endif
 #define	__NR_mkcomplex      VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(216)
 #define	__NR_statv          VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(217)
 #define	__NR_lstatv         VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(218)
@@ -413,12 +425,17 @@
 #define	__NR_setattrlist    VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(221)
 #define	__NR_getdirentriesattr VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(222)
 #define	__NR_exchangedata   VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(223)
-			/* 224  checkuseraccess */
+			/* 224  old checkuseraccess */
 #define	__NR_searchfs       VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(225)
 #define	__NR_delete         VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(226)
 #define	__NR_copyfile       VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(227)
+#if DARWIN_VERS >= DARWIN_10_6
+#define __NR_fgetattrlist   VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(228)
+#define __NR_fsetattrlist   VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(229)
+#else
 			/* 228  */
 			/* 229  */
+#endif
 #define	__NR_poll           VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(230)
 #define	__NR_watchevent     VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(231)
 #define	__NR_waitevent      VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(232)
@@ -434,7 +451,11 @@
 #define	__NR_fsctl          VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(242)
 #define	__NR_initgroups     VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(243)
 #define __NR_posix_spawn    VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(244)
+#if DARWIN_VERS >= DARWIN_10_6
+#define __NR_ffsctl         VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(245)
+#else
 			/* 245  */
+#endif
 			/* 246  */
 #define __NR_nfsclnt        VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(247)
 #define __NR_fhopen         VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(248)
@@ -485,23 +506,27 @@
 #define	__NR_identitysvc    VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(293)
 #define	__NR_shared_region_check_np VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(294)
 #define	__NR_shared_region_map_np   VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(295)
+#if DARWIN_VERS >= DARWIN_10_6
+#define __NR_vm_pressure_monitor    VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(296)
+#else
 			/* 296  old load_shared_file */
+#endif
 			/* 297  old reset_shared_file */
 			/* 298  old new_system_shared_regions */
 			/* 299  old shared_region_map_file_np */
 			/* 300  old shared_region_make_private_np */
-#define __NR___pthread_mutex_destroy VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(301)
-#define __NR___pthread_mutex_init VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(302)
-#define __NR___pthread_mutex_lock VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(303)
-#define __NR___pthread_mutex_trylock VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(304)
-#define __NR___pthread_mutex_unlock VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(305)
-#define __NR___pthread_cond_init VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(306)
-#define __NR___pthread_cond_destroy VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(307)
-#define __NR___pthread_cond_broadcast VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(308)
-#define __NR___pthread_cond_signal VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(309)
+			/* 301 */
+			/* 302 */
+			/* 303 */
+			/* 304 */
+			/* 305 */
+			/* 306 */
+			/* 307 */
+			/* 308 */
+			/* 309 */
 #define	__NR_getsid         VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(310)
 #define	__NR_settid_with_pid VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(311)
-#define __NR___pthread_cond_timedwait VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(312)
+			/* 312 */
 #define	__NR_aio_fsync      VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(313)
 #define	__NR_aio_return     VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(314)
 #define	__NR_aio_suspend    VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(315)
@@ -510,7 +535,7 @@
 #define	__NR_aio_read       VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(318)
 #define	__NR_aio_write      VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(319)
 #define	__NR_lio_listio     VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(320)
-#define __NR___pthread_cond_wait VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(321)
+			/* 321 */
 #define __NR_iopolicysys    VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(322)
 			/* 323  */
 #define	__NR_mlockall       VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(324)
@@ -559,10 +584,18 @@
 #define __NR_bsdthread_register VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(366)
 #define __NR_workq_open     VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(367)
 #define __NR_workq_ops      VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(368)
+#if DARWIN_VERS >= DARWIN_10_6
+#define __NR_kevent64       VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(369)
+#else
 			/* 369  */
+#endif
 			/* 370  */
 			/* 371  */
+#if DARWIN_VERS >= DARWIN_10_6
+#define __NR___thread_selfid VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(372)  // was UX64
+#else
 			/* 372  */
+#endif
 			/* 373  */
 			/* 374  */
 			/* 375  */
@@ -617,7 +650,19 @@
 #define __NR___mac_mount            VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(424)
 #define __NR___mac_get_mount        VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(425)
 #define __NR___mac_getfsstat        VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(426)
+#if DARWIN_VERS >= DARWIN_10_6
+#define __NR_fsgetpath              VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(427)
+#define __NR_audit_session_self     VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(428)
+#define __NR_audit_session_join     VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(429)
+#endif
+
+#if DARWIN_VERS <= DARWIN_10_6
 #define	__NR_MAXSYSCALL             VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(427)
+#elif DARWIN_VERSION < DARWIN_10_7
+#define	__NR_MAXSYSCALL             VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(430)
+#else
+#error unknown darwin version
+#endif
 
 #define __NR_DARWIN_FAKE_SIGRETURN (1 + __NR_MAXSYSCALL)
 
Index: configure.in
===================================================================
--- configure.in	(revision 10888)
+++ configure.in	(working copy)
@@ -247,6 +247,9 @@
      *darwin*)
         AC_MSG_RESULT([ok (${host_os})])
         VGCONF_OS="darwin"
+        AC_DEFINE([DARWIN_10_5], 100500, [DARWIN_VERS value for Mac OS X 10.5])
+        AC_DEFINE([DARWIN_10_6], 100600, [DARWIN_VERS value for Mac OS X 10.6])
+        AC_DEFINE([DARWIN_10_7], 100700, [DARWIN_VERS value for Mac OS X 10.7])
 
 	AC_MSG_CHECKING([for the kernel version])
 	kernel=`uname -r`
@@ -254,21 +257,27 @@
         # Nb: for Darwin we set DEFAULT_SUPP here.  That's because Darwin
         # has only one relevant version, the OS version. The `uname` check
         # is a good way to get that version (i.e. "Darwin 9.6.0" is Mac OS
-        # X 10.5.6, and "Darwin 10.x" would presumably be Mac OS X 10.6.x
-        # Snow Leopard and darwin10.supp), and we don't know of an macros
-        # similar to __GLIBC__ to get that info.
+        # X 10.5.6, and "Darwin 10.x" is Mac OS X 10.6.x Snow Leopard), 
+        # and we don't know of an macros similar to __GLIBC__ to get that info.
         #
         # XXX: `uname -r` won't do the right thing for cross-compiles, but
         # that's not a problem yet.
 	case "${kernel}" in
 	     9.*)
 		  AC_MSG_RESULT([Darwin 9.x (${kernel}) / Mac OS X 10.5 Leopard])
+		  AC_DEFINE([DARWIN_VERS], DARWIN_10_5, [Darwin / Mac OS X version])
 		  DEFAULT_SUPP="darwin9.supp ${DEFAULT_SUPP}"
 		  DEFAULT_SUPP="darwin9-drd.supp ${DEFAULT_SUPP}"
 		  ;;
+	     10.*)
+		  AC_MSG_RESULT([Darwin 10.x (${kernel}) / Mac OS X 10.6 Snow Leopard])
+		  AC_DEFINE([DARWIN_VERS], DARWIN_10_6, [Darwin / Mac OS X version])
+		  DEFAULT_SUPP="darwin10.supp ${DEFAULT_SUPP}"
+		  DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
+		  ;;
      *) 
 		  AC_MSG_RESULT([unsupported (${kernel})])
-		  AC_MSG_ERROR([Valgrind works on Darwin 9.x (Mac OS X 10.5)])
+		  AC_MSG_ERROR([Valgrind works on Darwin 9.x and 10.x (Mac OS X 10.5 and 10.6)])
 		  ;;
 	esac
         ;;
@@ -1471,10 +1480,22 @@
 
 #----------------------------------------------------------------------------
 # Check for /proc filesystem
+# This doesn't work when cross-compiling, including Darwin universal builds.
 #----------------------------------------------------------------------------
+if test "x$cross_compiling" = "xno"; then
 AC_CHECK_FILES(/proc/self/fd /proc/self/exe /proc/self/maps, 
     [ AC_DEFINE([HAVE_PROC], 1, [can use /proc filesystem]) ], 
     [])
+else
+     # assume /proc/self/* is available everywhere except Darwin
+     case "$VGCONF_OS" in
+        darwin)
+	      ;;
+        *)
+           AC_DEFINE([HAVE_PROC], 1, [can use /proc filesystem])
+           ;;
+     esac
+fi
 
 
 #----------------------------------------------------------------------------
Index: configure
===================================================================
--- configure.orig	2010-03-17 11:46:28.000000000 +0100
+++ configure	2010-03-17 11:05:53.000000000 +0100
@@ -4296,6 +4296,12 @@
 		  DEFAULT_SUPP="darwin9.supp ${DEFAULT_SUPP}"
 		  DEFAULT_SUPP="darwin9-drd.supp ${DEFAULT_SUPP}"
 		  ;;
+	     10.*)
+		  echo "$as_me:$LINENO: result: Darwin 10.x (${kernel}) / Mac OS X 10.6 Snow Leopard" >&5
+echo "${ECHO_T}Darwin 10.x (${kernel}) / Mac OS X 10.6 Snow Leopard" >&6
+		  DEFAULT_SUPP="darwin10.supp ${DEFAULT_SUPP}"
+		  DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
+		  ;;
      *)
 		  echo "$as_me:$LINENO: result: unsupported (${kernel})" >&5
 echo "${ECHO_T}unsupported (${kernel})" >&6
Index: auxprogs/Makefile.am
===================================================================
--- auxprogs/Makefile.am	(revision 10888)
+++ auxprogs/Makefile.am	(working copy)
@@ -29,4 +29,3 @@
 valgrind_listener_CFLAGS    = $(AM_CFLAGS_PRI)
 valgrind_listener_CCASFLAGS = $(AM_CCASFLAGS_PRI)
 valgrind_listener_LDFLAGS   = $(AM_CFLAGS_PRI)
-
Index: Makefile.am
===================================================================
--- Makefile.am	(revision 10888)
+++ Makefile.am	(working copy)
@@ -26,6 +26,8 @@
 
 # Put docs last because building the HTML is slow and we want to get
 # everything else working before we try it.
+# GrP SnowLeopard:
+#	mpi
 SUBDIRS = \
 	include \
 	VEX \
@@ -36,7 +38,6 @@
 	tests \
 	perf \
 	auxprogs \
-	mpi \
 	docs
 DIST_SUBDIRS  = $(SUBDIRS)
 
@@ -48,7 +49,8 @@
 	glibc-2.2-LinuxThreads-helgrind.supp \
 	glibc-2.X-drd.supp \
 	exp-ptrcheck.supp \
-	darwin9.supp darwin9-drd.supp
+	darwin9.supp darwin9-drd.supp \
+	darwin10.supp darwin10-drd.supp
 DEFAULT_SUPP_FILES = @DEFAULT_SUPP@
 
 # We include all the base .supp files in the distribution, but not
@@ -63,10 +65,10 @@
 BUILT_SOURCES  = default.supp valgrind.pc
 CLEANFILES     = default.supp
 
-default.supp: $(DEFAULT_SUPP_FILES)
+default.supp: $(addprefix $(srcdir)/,$(DEFAULT_SUPP_FILES))
 	echo "# This is a generated file, composed of the following suppression rules:" > default.supp
 	echo "# " $(DEFAULT_SUPP_FILES) >> default.supp
-	cat $(DEFAULT_SUPP_FILES) >> default.supp
+	cat $(addprefix $(srcdir)/,$(DEFAULT_SUPP_FILES)) >> default.supp
 
 ## Preprend @PERL@ because tests/vg_regtest isn't executable
 regtest: check
Index: darwin9-drd.supp
===================================================================
--- darwin9-drd.supp	(revision 10888)
+++ darwin9-drd.supp	(working copy)
@@ -1,3 +1,6 @@
+
+# DRD suppressions for Darwin 9.x / Mac OS X 10.5 Leopard
+
 #
 # Suppression patterns for dyld, the dynamic loader.
 #
Index: Makefile.vex.am
===================================================================
--- Makefile.vex.am	(revision 10888)
+++ Makefile.vex.am	(working copy)
@@ -51,14 +51,11 @@
 # This is very uggerly.  Need to sed out both "xyzzyN" and
 # "xyzzy$N" since gcc on different targets emits the constants
 # differently -- with a leading $ on x86/amd64 but none on ppc32/64.
-pub/libvex_guest_offsets.h:
-	rm -f auxprogs/genoffsets.s
-	$(CC) $(LIBVEX_CFLAGS) -O -S -o auxprogs/genoffsets.s \
-					auxprogs/genoffsets.c
-	grep xyzzy auxprogs/genoffsets.s | grep define \
+pub/libvex_guest_offsets.h: $(srcdir)/auxprogs/genoffsets.c
+	$(CC) $(LIBVEX_CFLAGS) -O -S -o - $(srcdir)/auxprogs/genoffsets.c \
+	   | grep xyzzy | grep define \
 	   | sed "s/xyzzy\\$$//g" | sed "s/xyzzy//g" \
-	   > pub/libvex_guest_offsets.h
-	rm -f auxprogs/genoffsets.s
+	   > $(srcdir)/pub/libvex_guest_offsets.h
 
 #----------------------------------------------------------------------------
 # libvex-<platform>.a
Index: darwin10.supp
===================================================================
--- darwin10.supp	(revision 0)
+++ darwin10.supp	(revision 0)
@@ -0,0 +1,2 @@
+
+# Suppressions for Darwin 10.x / Mac OS X 10.6 Snow Leopard
Index: coregrind/m_syswrap/priv_syswrap-darwin.h
===================================================================
--- coregrind/m_syswrap/priv_syswrap-darwin.h	(revision 10888)
+++ coregrind/m_syswrap/priv_syswrap-darwin.h	(working copy)
@@ -429,7 +429,7 @@
 // 369
 // 370
 // 371
-// 372
+DECL_TEMPLATE(darwin, __thread_selfid);         // 372
 // 373
 // 374
 // 375
@@ -484,6 +484,9 @@
 // NYI __mac_mount 424
 // NYI __mac_get_mount 425
 // NYI __mac_getfsstat 426
+DECL_TEMPLATE(darwin, fsgetpath);           // 427
+// NYI audit_session_self 428
+// NYI audit_session_join 429
 
 // Mach message helpers
 DECL_TEMPLATE(darwin, host_info);
@@ -498,9 +501,11 @@
 DECL_TEMPLATE(darwin, mach_port_get_refs);
 DECL_TEMPLATE(darwin, mach_port_mod_refs);
 DECL_TEMPLATE(darwin, mach_port_get_set_status);
+DECL_TEMPLATE(darwin, mach_port_move_member);
 DECL_TEMPLATE(darwin, mach_port_destroy);
 DECL_TEMPLATE(darwin, mach_port_request_notification);
 DECL_TEMPLATE(darwin, mach_port_insert_right);
+DECL_TEMPLATE(darwin, mach_port_extract_right);
 DECL_TEMPLATE(darwin, mach_port_get_attributes);
 DECL_TEMPLATE(darwin, mach_port_set_attributes);
 DECL_TEMPLATE(darwin, mach_port_insert_member);
@@ -537,6 +542,7 @@
 DECL_TEMPLATE(darwin, thread_suspend);
 DECL_TEMPLATE(darwin, thread_get_state);
 DECL_TEMPLATE(darwin, thread_policy);
+DECL_TEMPLATE(darwin, thread_policy_set);
 DECL_TEMPLATE(darwin, thread_info);
 DECL_TEMPLATE(darwin, bootstrap_register);
 DECL_TEMPLATE(darwin, bootstrap_look_up);
Index: coregrind/m_syswrap/syswrap-amd64-darwin.c
===================================================================
--- coregrind/m_syswrap/syswrap-amd64-darwin.c	(revision 10888)
+++ coregrind/m_syswrap/syswrap-amd64-darwin.c	(working copy)
@@ -378,7 +378,23 @@
    VexGuestAMD64State *vex;
    Addr stack;
    SizeT stacksize;
+   vki_sigset_t blockall;
 
+   /* When we enter here we hold no lock (!), so we better acquire it
+      pronto.  Why do we hold no lock?  Because (presumably) the only
+      way to get here is as a result of a SfMayBlock syscall
+      "workq_ops(WQOPS_THREAD_RETURN)", which will have dropped the
+      lock.  At least that's clear for the 'reuse' case.  The
+      non-reuse case?  Dunno, perhaps it's a new thread the kernel
+      pulled out of a hat.  In any case we still need to take a
+      lock. */
+   VG_(acquire_BigLock_LL)("wqthread_hijack");
+
+   /* Start the thread with all signals blocked.  VG_(scheduler) will
+      set the mask correctly when we finally get there. */
+   VG_(sigfillset)(&blockall);
+   VG_(sigprocmask)(VKI_SIG_SETMASK, &blockall, NULL);
+
    if (reuse) {
        // This thread already exists; we're merely re-entering 
        // after leaving via workq_ops(WQOPS_THREAD_RETURN). 
@@ -418,6 +434,15 @@
    if (reuse) {
       // Continue V's thread back in the scheduler. 
       // The client thread is of course in another location entirely.
+
+      /* Drop the lock before going into
+         ML_(wqthread_continue_NORETURN).  The latter will immediately
+         attempt to reacquire it in non-LL mode, which is a bit
+         wasteful but I don't think is harmful.  A better solution
+         would be to not drop the lock but instead "upgrade" it from a
+         LL lock to a full lock, but that's too much like hard work
+         right now. */
+      VG_(release_BigLock_LL)("wqthread_hijack(1)");
       ML_(wqthread_continue_NORETURN)(tst->tid);
    } 
    else {
@@ -450,6 +475,16 @@
       VG_(am_do_sync_check)("after", "wqthread_hijack", 0);
 
       // Go!
+      /* Same comments as the 'release' in the then-clause.
+         start_thread_NORETURN calls run_thread_NORETURN calls
+         thread_wrapper which acquires the lock before continuing.
+         Let's hope nothing non-thread-local happens until that point.
+
+         DDD: I think this is plain wrong .. if we get to
+         thread_wrapper not holding the lock, and someone has recycled
+         this thread slot in the meantime, we're hosed.  Is that
+         possible, though? */
+      VG_(release_BigLock_LL)("wqthread_hijack(2)");
       call_on_new_stack_0_1(tst->os_state.valgrind_stack_init_SP, 0, 
                             start_thread_NORETURN, (Word)tst);
    }
Index: coregrind/m_syswrap/priv_syswrap-generic.h
===================================================================
--- coregrind/m_syswrap/priv_syswrap-generic.h	(revision 10888)
+++ coregrind/m_syswrap/priv_syswrap-generic.h	(working copy)
@@ -200,7 +200,7 @@
 DECL_TEMPLATE(generic, sys_getrlimit);             // * (?)
 DECL_TEMPLATE(generic, sys_truncate64);            // %% (P?)
 DECL_TEMPLATE(generic, sys_ftruncate64);           // %% (P?)
-DECL_TEMPLATE(generic, sys_lchown);                // * (L?)
+DECL_TEMPLATE(generic, sys_lchown);                // * (L?) FreeBSD 3.0
 DECL_TEMPLATE(generic, sys_mincore);               // * L?
 DECL_TEMPLATE(generic, sys_getdents64);            // * (SVr4,SVID?)
 DECL_TEMPLATE(generic, sys_statfs64);              // * (?)
Index: coregrind/m_syswrap/syswrap-main.c
===================================================================
--- coregrind/m_syswrap/syswrap-main.c	(revision 10888)
+++ coregrind/m_syswrap/syswrap-main.c	(working copy)
@@ -1155,7 +1155,7 @@
 #    error Unknown OS
 #  endif
 
-   return sys == NULL  ? &bad_sys  : sys;
+   return (sys && sys->before) ? sys : &bad_sys;
 }
 
 
Index: coregrind/m_syswrap/syswrap-darwin.c
===================================================================
--- coregrind/m_syswrap/syswrap-darwin.c	(revision 10888)
+++ coregrind/m_syswrap/syswrap-darwin.c	(working copy)
@@ -66,7 +66,6 @@
 #include <mach/mach.h>
 #include <mach/mach_vm.h>
 #include <semaphore.h>
-#include <sys/acl.h>   /* struct kauth_filesec */
 /* --- !!! --- EXTERNAL HEADERS end --- !!! --- */
 
 #define msgh_request_port      msgh_remote_port
@@ -1240,7 +1239,9 @@
 {
    PRINT("futimes ( %ld, %#lx )", ARG1,ARG2);
    PRE_REG_READ2(long, "futimes", int, fd, struct timeval *, tvp);
-   if (ARG2 != 0) {
+   if (!ML_(fd_allowed)(ARG1, "futimes", tid, False)) {
+      SET_STATUS_Failure( VKI_EBADF );
+   } else if (ARG2 != 0) {
       PRE_timeval_READ( "futimes(tvp[0])", ARG2 );
       PRE_timeval_READ( "futimes(tvp[1])", ARG2+sizeof(struct vki_timeval) );
    }
@@ -1635,10 +1636,12 @@
 {
    PRINT("kdebug_trace(%ld, %ld, %ld, %ld, %ld, %ld)", 
          ARG1, ARG2, ARG3, ARG4, ARG5, ARG6);
+   /*
+     Don't check anything - some clients pass fewer arguments.
    PRE_REG_READ6(long, "kdebug_trace", 
                  int,"code", int,"arg1", int,"arg2", 
                  int,"arg3", int,"arg4", int,"arg5");
-   // GrP fixme anything else?
+   */
 }
 
 
@@ -2018,7 +2021,7 @@
       is just way wrong.  [The trouble is with the size, which depends on a
       non-trival kernel computation] */
    PRE_MEM_READ( "fchmod_extended(xsecurity)", ARG5, 
-                 sizeof(struct kauth_filesec) );
+                 sizeof(struct vki_kauth_filesec) );
 }
 
 PRE(chmod_extended)
@@ -2038,7 +2041,7 @@
       is just way wrong.  [The trouble is with the size, which depends on a
       non-trival kernel computation] */
    PRE_MEM_READ( "chmod_extended(xsecurity)", ARG5, 
-                 sizeof(struct kauth_filesec) );
+                 sizeof(struct vki_kauth_filesec) );
 }
 
 
@@ -2241,6 +2244,9 @@
    } attrspec;
    static const attrspec commonattr[] = {
       // This order is important.
+#if DARWIN_VERS >= DARWIN_10_6
+      { ATTR_CMN_RETURNED_ATTRS,  sizeof(attribute_set_t) }, 
+#endif
       { ATTR_CMN_NAME,            -1 }, 
       { ATTR_CMN_DEVID,           sizeof(dev_t) }, 
       { ATTR_CMN_FSID,            sizeof(fsid_t) }, 
@@ -2263,8 +2269,14 @@
       { ATTR_CMN_NAMEDATTRLIST,   -1 }, 
       { ATTR_CMN_FLAGS,           sizeof(uint32_t) }, 
       { ATTR_CMN_USERACCESS,      sizeof(uint32_t) }, 
+      { ATTR_CMN_EXTENDED_SECURITY, -1 }, 
+      { ATTR_CMN_UUID,            sizeof(guid_t) }, 
+      { ATTR_CMN_GRPUUID,         sizeof(guid_t) }, 
       { ATTR_CMN_FILEID,          sizeof(uint64_t) }, 
       { ATTR_CMN_PARENTID,        sizeof(uint64_t) }, 
+#if DARWIN_VERS >= DARWIN_10_6
+      { ATTR_CMN_FULLPATH,        -1 }, 
+#endif
       { 0,                        0 }
    };
    static const attrspec volattr[] = {
@@ -2288,6 +2300,9 @@
       { ATTR_VOL_MOUNTEDDEVICE,   -1 }, 
       { ATTR_VOL_ENCODINGSUSED,   sizeof(uint64_t) }, 
       { ATTR_VOL_CAPABILITIES,    sizeof(vol_capabilities_attr_t) }, 
+#if DARWIN_VERS >= DARWIN_10_6
+      { ATTR_VOL_UUID,            sizeof(uuid_t) }, 
+#endif
       { ATTR_VOL_ATTRIBUTES,      sizeof(vol_attributes_attr_t) }, 
       { 0,                        0 }
    };
@@ -2336,6 +2351,16 @@
    d = attrBuf;
    dend = d + attrBufSize;
 
+#if DARWIN_VERS >= DARWIN_10_6
+   // ATTR_CMN_RETURNED_ATTRS tells us what's really here, if set
+   if (a[0] & ATTR_CMN_RETURNED_ATTRS) {
+       // fixme range check this?
+       a[0] &= ~ATTR_CMN_RETURNED_ATTRS;
+       fn(tid, d, sizeof(attribute_set_t));
+       VG_(memcpy)(a, d, sizeof(a));
+   }
+#endif
+
    for (g = 0; g < 5; g++) {
       for (i = 0; attrdefs[g][i].attrBit; i++) {
          uint32_t bit = attrdefs[g][i].attrBit;
@@ -2398,10 +2423,15 @@
 POST(getattrlist) 
 {
    if (ARG4 > sizeof(vki_uint32_t)) {
-      // attrBuf is uint32_t bytes written followed by attr data
+      // attrBuf is uint32_t size followed by attr data
       vki_uint32_t *sizep = (vki_uint32_t *)ARG3;
       POST_MEM_WRITE(ARG3, sizeof(vki_uint32_t));
-      scan_attrlist(tid, (struct vki_attrlist *)ARG2, sizep+1, *sizep, &get1attr);
+      if (ARG5 & FSOPT_REPORT_FULLSIZE) {
+         // *sizep is bytes required for return value, including *sizep
+      } else {
+         // *sizep is actual bytes returned, including *sizep
+      }
+      scan_attrlist(tid, (struct vki_attrlist *)ARG2, sizep+1, MIN(*sizep, ARG4), &get1attr);
    }
 }
 
@@ -2457,10 +2487,36 @@
 
    POST_MEM_WRITE(ARG3, p - (char *)ARG3);
 
-   PRINT("got %d records, %d/%lu bytes\n", count, p-(char *)ARG3, ARG4);
+   PRINT("got %d records, %ld/%lu bytes\n", count, p-(char *)ARG3, ARG4);
 }
 
 
+PRE(fsgetpath)
+{
+#if VG_WORDSIZE == 4
+   PRINT("fsgetpath(%#lx, %ld, %#lx {%lu,%lu}, %llu)", 
+         ARG1, ARG2, ARG3, ((unsigned int *)ARG3)[0], ((unsigned int *)ARG3)[1], LOHI64(ARG4, ARG5));
+   PRE_REG_READ5(ssize_t, "fsgetpath", 
+                 void*,"buf", size_t,"bufsize", 
+                 fsid_t *,"fsid",
+                 vki_uint32_t, "objid_low32", vki_uint32_t, "objid_high32");
+#else
+   PRINT("fsgetpath(%#lx, %ld, %#lx {%u,%u}, %llu)", 
+         ARG1, ARG2, ARG3, ((unsigned int *)ARG3)[0], ((unsigned int *)ARG3)[1], ARG4);
+   PRE_REG_READ4(ssize_t, "fsgetpath", 
+                 void*,"buf", size_t,"bufsize", 
+                 fsid_t *,"fsid", uint64_t,"objid");
+#endif
+   PRE_MEM_READ("fsgetpath(fsid)", ARG3, sizeof(fsid_t));
+   PRE_MEM_WRITE("fsgetpath(buf)", ARG1, ARG2);
+}
+
+POST(fsgetpath)
+{
+   POST_MEM_WRITE(ARG1, RES);
+}
+
+
 PRE(exchangedata)
 {
    PRINT("exchangedata(%#lx(%s), %#lx(%s), %lu)",
@@ -3242,6 +3298,9 @@
    case VKI_A_SETCLASS:
    case VKI_A_SETPMASK:
    case VKI_A_SETFSIZE:
+#if DARWIN_VERS >= DARWIN_10_6
+   case VKI_A_SENDTRIGGER:
+#endif
       // kernel reads data..data+length
       PRE_MEM_READ("auditon(data)", ARG2, ARG3);
       break;
@@ -3260,6 +3319,9 @@
    case VKI_A_GETCLASS:
    case VKI_A_GETPINFO:
    case VKI_A_GETPINFO_ADDR:
+#if DARWIN_VERS >= DARWIN_10_6
+   case VKI_A_GETSINFO_ADDR:
+#endif
       // kernel reads and writes data..data+length
       // GrP fixme be precise about what gets read and written
       PRE_MEM_READ("auditon(data)", ARG2, ARG3);
@@ -3293,6 +3355,9 @@
    case VKI_A_SETCLASS:
    case VKI_A_SETPMASK:
    case VKI_A_SETFSIZE:
+#if DARWIN_VERS >= DARWIN_10_6
+   case VKI_A_SENDTRIGGER:
+#endif
       // kernel reads data..data+length
       break;
 
@@ -3310,6 +3375,9 @@
    case VKI_A_GETCLASS:
    case VKI_A_GETPINFO:
    case VKI_A_GETPINFO_ADDR:
+#if DARWIN_VERS >= DARWIN_10_6
+   case VKI_A_GETSINFO_ADDR:
+#endif
       // kernel reads and writes data..data+length
       // GrP fixme be precise about what gets read and written
       POST_MEM_WRITE(ARG2, ARG3);
@@ -4378,6 +4446,51 @@
 }
 
 
+PRE(mach_port_move_member)
+{
+#pragma pack(4)
+    typedef struct {
+        mach_msg_header_t Head;
+        NDR_record_t NDR;
+        mach_port_name_t member;
+        mach_port_name_t after;
+    } Request;
+#pragma pack()
+
+    Request *req = (Request *)ARG1;
+
+    PRINT("mach_port_move_member(%s, %s, %s)", 
+          name_for_port(MACH_REMOTE), 
+          name_for_port(req->member), 
+          name_for_port(req->after));
+    /*
+    MACH_ARG(mach_port_move_member.member) = req->member;
+    MACH_ARG(mach_port_move_member.after) = req->after;
+    */
+    AFTER = POST_FN(mach_port_move_member);
+}
+
+POST(mach_port_move_member)
+{
+#pragma pack(4)
+   typedef struct {
+      mach_msg_header_t Head;
+      NDR_record_t NDR;
+      kern_return_t RetCode;
+      mach_msg_trailer_t trailer;
+   } Reply;
+#pragma pack()
+
+   Reply *reply = (Reply *)ARG1;
+
+   if (!reply->RetCode) {
+      // fixme port set tracker?
+   } else {
+      PRINT("mig return %d", reply->RetCode);
+   }
+}
+
+
 PRE(mach_port_destroy)
 {
 #pragma pack(4)
@@ -4498,6 +4611,34 @@
 }
 
 
+PRE(mach_port_extract_right)
+{
+#pragma pack(4)
+   typedef struct {
+      mach_msg_header_t Head;
+      NDR_record_t NDR;
+      mach_port_name_t name;
+      mach_msg_type_name_t msgt_name;
+   } Request;
+#pragma pack()
+
+   Request *req = (Request *)ARG1;
+   
+   PRINT("mach_port_extract_right(%s, %s, %d)", 
+         name_for_port(MACH_REMOTE), 
+         name_for_port(req->name), req->msgt_name);
+   
+   AFTER = POST_FN(mach_port_extract_right);
+   
+   // fixme port tracker?
+}
+
+POST(mach_port_extract_right)
+{
+   // fixme import_complex_message handles the returned result, right?
+}
+
+
 PRE(mach_port_get_attributes)
 {
 #pragma pack(4)
@@ -6086,6 +6227,7 @@
 
    // GrP fixme semaphore destroy needed when thread creation fails
    // GrP fixme probably other cleanup too
+   // GrP fixme spinlocks might be good enough?
 
    // DDD: I'm not at all sure this is the right spot for this.  It probably
    // should be in pthread_hijack instead, just before the call to
@@ -6204,10 +6346,6 @@
 }
 
 
-POST(thread_policy)
-{
-}
-
 PRE(thread_policy)
 {
    mach_msg_header_t *mh = (mach_msg_header_t *)ARG1;
@@ -6222,7 +6360,25 @@
    AFTER = POST_FN(thread_policy);
 }
 
+POST(thread_policy)
+{
+}
 
+
+PRE(thread_policy_set)
+{
+   mach_msg_header_t *mh = (mach_msg_header_t *)ARG1;
+
+   PRINT("thread_policy_set(%s, ...)", name_for_port(mh->msgh_request_port));
+
+   AFTER = POST_FN(thread_policy_set);
+}
+
+POST(thread_policy_set)
+{
+}
+
+
 PRE(thread_info)
 {
    mach_msg_header_t *mh = (mach_msg_header_t *)ARG1;
@@ -6449,12 +6605,18 @@
    case 3211:
       CALL_PRE(mach_port_get_set_status);
       return;
+   case 3212:
+      CALL_PRE(mach_port_move_member);
+      return;
    case 3213:
       CALL_PRE(mach_port_request_notification);
       return;
    case 3214:
       CALL_PRE(mach_port_insert_right);
       return;
+   case 3215:
+      CALL_PRE(mach_port_extract_right);
+      return;
    case 3217:
       CALL_PRE(mach_port_get_attributes);
       return;
@@ -6596,6 +6758,9 @@
    case 3616: 
       CALL_PRE(thread_policy);
       return;
+   case 3617: 
+      CALL_PRE(thread_policy_set);
+      return;
    default:
       // unknown message to a thread
       VG_(printf)("UNKNOWN thread message [id %d, to %s, reply 0x%x]\n", 
@@ -6760,7 +6925,7 @@
 
 POST(mach_msg_unhandled)
 {
-   ML_(sync_mappings)("after", "mach_msg_unhandled", 0);
+   ML_(sync_mappings)("after", "mach_msg_receive (unhandled)", 0);
 }
 
 
@@ -6900,11 +7065,12 @@
 }
 
 
+#if DARWIN_VERS <= DARWIN_10_5
 PRE(__semwait_signal)
 {
-   /* args: int cond_sem, int mutex_sem,
-            int timeout, int relative,
-            time_t tv_sec, time_t tv_nsec */
+   /* 10.5 args: int cond_sem, int mutex_sem,
+                 int timeout, int relative,
+                 time_t tv_sec, time_t tv_nsec */
    PRINT("__semwait_signal(wait %s, signal %s, %ld, %ld, %lds:%ldns)", 
          name_for_port(ARG1), name_for_port(ARG2), ARG3, ARG4, ARG5, ARG6);
    PRE_REG_READ6(long, "__semwait_signal", 
@@ -6914,8 +7080,33 @@
 
    *flags |= SfMayBlock;
 }
+#else
+PRE(__semwait_signal)
+{
+   /* 10.5 args: int cond_sem, int mutex_sem,
+                 int timeout, int relative,
+                 const timespec *ts */
+   PRINT("__semwait_signal(wait %s, signal %s, %ld, %ld, %#lx)", 
+         name_for_port(ARG1), name_for_port(ARG2), ARG3, ARG4, ARG5);
+   PRE_REG_READ5(int, "__semwait_signal", 
+                 int,cond_sem, int,mutex_sem,
+                 int,timeout, int,relative, 
+                 const struct vki_timespec *,ts);
+   
+   if (ARG5) PRE_MEM_READ ("__semwait_signal(ts)", 
+                           ARG5, sizeof(struct vki_timespec));
+   
+   *flags |= SfMayBlock;
+}
+#endif
 
 
+PRE(__thread_selfid)
+{
+   PRINT("__thread_selfid ()");
+   PRE_REG_READ0(vki_uint64_t, "__thread_selfid");
+}
+
 PRE(task_for_pid)
 {
    PRINT("task_for_pid(%s, %ld, %#lx)", name_for_port(ARG1), ARG2, ARG3);
@@ -7468,7 +7659,11 @@
    MACX_(__NR_sigreturn,   sigreturn), 
 // _____(__NR_chud), 
    _____(VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(186)),   // ??? 
+#if DARWIN_VERS >= DARWIN_10_6
+// _____(__NR_fdatasync), 
+#else
    _____(VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(187)),   // ??? 
+#endif
    GENXY(__NR_stat,        sys_newstat), 
    GENXY(__NR_fstat,       sys_newfstat), 
    GENXY(__NR_lstat,       sys_newlstat), 
@@ -7495,8 +7690,13 @@
 // _____(__NR_ATPgetreq), 
 // _____(__NR_ATPgetrsp), 
    _____(VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(213)),   // Reserved for AppleTalk
+#if DARWIN_VERS >= DARWIN_10_6
+   _____(VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(214)),   // old kqueue_from_portset_np
+   _____(VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(215)),   // old kqueue_portset_np
+#else
 // _____(__NR_kqueue_from_portset_np), 
 // _____(__NR_kqueue_portset_np), 
+#endif
 // _____(__NR_mkcomplex), 
 // _____(__NR_statv), 
 // _____(__NR_lstatv), 
@@ -7509,8 +7709,13 @@
 // _____(__NR_searchfs), 
    GENX_(__NR_delete,      sys_unlink), 
 // _____(__NR_copyfile), 
+#if DARWIN_VERS >= DARWIN_10_6
+// _____(__NR_fgetattrlist), 
+// _____(__NR_fsetattrlist), 
+#else
    _____(VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(228)),   // ?? 
    _____(VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(229)),   // ?? 
+#endif
    GENXY(__NR_poll,        sys_poll), 
    MACX_(__NR_watchevent,  watchevent), 
    MACXY(__NR_waitevent,   waitevent), 
@@ -7526,7 +7731,11 @@
    MACXY(__NR_fsctl,       fsctl), 
    MACX_(__NR_initgroups,  initgroups), 
    MACXY(__NR_posix_spawn, posix_spawn), 
+#if DARWIN_VERS >= DARWIN_10_6
+// _____(__NR_ffsctl), 
+#else
    _____(VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(245)),   // ???
+#endif
    _____(VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(246)),   // ???
 // _____(__NR_nfsclnt), 
 // _____(__NR_fhopen), 
@@ -7577,23 +7786,27 @@
 // _____(__NR_identitysvc), 
 // _____(__NR_shared_region_check_np), 
 // _____(__NR_shared_region_map_np), 
+#if DARWIN_VERS >= DARWIN_10_6
+// _____(__NR_vm_pressure_monitor), 
+#else
    _____(VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(296)),   // old load_shared_file 
+#endif
    _____(VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(297)),   // old reset_shared_file 
    _____(VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(298)),   // old new_system_shared_regions 
    _____(VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(299)),   // old shared_region_map_file_np 
    _____(VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(300)),   // old shared_region_make_private_np
-// _____(__NR___pthread_mutex_destroy), 
-// _____(__NR___pthread_mutex_init), 
-// _____(__NR___pthread_mutex_lock), 
-// _____(__NR___pthread_mutex_trylock), 
-// _____(__NR___pthread_mutex_unlock), 
-// _____(__NR___pthread_cond_init), 
-// _____(__NR___pthread_cond_destroy), 
-// _____(__NR___pthread_cond_broadcast), 
-// _____(__NR___pthread_cond_signal), 
+   _____(VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(301)),   // ???
+   _____(VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(302)),   // ???
+   _____(VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(303)),   // ???
+   _____(VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(304)),   // ???
+   _____(VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(305)),   // ???
+   _____(VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(306)),   // ???
+   _____(VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(307)),   // ???
+   _____(VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(308)),   // ???
+   _____(VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(309)),   // ???
 // _____(__NR_getsid), 
 // _____(__NR_settid_with_pid), 
-// _____(__NR___pthread_cond_timedwait), 
+   _____(VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(312)),   // ???
 // _____(__NR_aio_fsync), 
    MACXY(__NR_aio_return,     aio_return), 
    MACX_(__NR_aio_suspend,    aio_suspend), 
@@ -7602,7 +7815,7 @@
    MACXY(__NR_aio_read,       aio_read), 
    MACX_(__NR_aio_write,      aio_write), 
 // _____(__NR_lio_listio),   // 320
-// _____(__NR___pthread_cond_wait), 
+   _____(VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(321)),   // ???
 // _____(__NR_iopolicysys), 
    _____(VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(323)),   // ???
 // _____(__NR_mlockall), 
@@ -7645,15 +7858,23 @@
    MACX_(__NR_bsdthread_terminate,  bsdthread_terminate), 
    MACXY(__NR_kqueue,      kqueue), 
    MACXY(__NR_kevent,      kevent), 
-// _____(__NR_lchown), 
+   GENX_(__NR_lchown,      sys_lchown), 
 // _____(__NR_stack_snapshot), 
    MACX_(__NR_bsdthread_register, bsdthread_register), 
    MACX_(__NR_workq_open,  workq_open), 
    MACXY(__NR_workq_ops,   workq_ops), 
+#if DARWIN_VERS >= DARWIN_10_6
+// _____(__NR_kevent64), 
+#else
    _____(VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(369)),   // ???
+#endif
    _____(VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(370)),   // ???
    _____(VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(371)),   // ???
+#if DARWIN_VERS >= DARWIN_10_6
+   MACX_(__NR___thread_selfid, __thread_selfid), 
+#else
    _____(VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(372)),   // ???
+#endif
    _____(VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(373)),   // ???
    _____(VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(374)),   // ???
    _____(VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(375)),   // ???
@@ -7709,6 +7930,12 @@
 // _____(__NR___mac_mount),
 // _____(__NR___mac_get_mount),
 // _____(__NR___mac_getfsstat),
+#if DARWIN_VERS >= DARWIN_10_6
+   MACXY(__NR_fsgetpath, fsgetpath), 
+// _____(__NR_audit_session_self),
+// _____(__NR_audit_session_join),
+#endif
+
 // _____(__NR_MAXSYSCALL)
    MACX_(__NR_DARWIN_FAKE_SIGRETURN, FAKE_SIGRETURN)
 };
Index: coregrind/m_main.c
===================================================================
--- coregrind/m_main.c	(revision 10888)
+++ coregrind/m_main.c	(working copy)
@@ -1510,7 +1510,7 @@
    VG_(do_syscall2)(__NR_munmap, 0x00000000, 0xf0000000);
 # else
    // open up client space
-   VG_(do_syscall2)(__NR_munmap, 0x100000000, 0x700000000000-0x100000000);
+   VG_(do_syscall2)(__NR_munmap, 0x100000000, 0x7fff50000000-0x100000000);
    // open up client stack and dyld
    VG_(do_syscall2)(__NR_munmap, 0x7fff5c000000, 0x4000000);
 # endif
Index: coregrind/Makefile.am
===================================================================
--- coregrind/Makefile.am	(revision 10888)
+++ coregrind/Makefile.am	(working copy)
@@ -111,9 +111,11 @@
 
 # Be careful w.r.t. parellel builds.  See section 27.9 of the automake info
 # page, "Handling Tools that Produce many Outputs".
-$(mach_user_srcs): $(mach_defs)
+$(abs_builddir)/m_mach: 
+	mkdir -p $@
+$(mach_user_srcs): $(mach_defs) $(abs_builddir)/m_mach
 	(cd m_mach && mig $(mach_defs))
-$(mach_hdrs): $(mach_defs) $(mach_user_srcs)
+$(mach_hdrs): $(mach_defs) $(mach_user_srcs) $(abs_builddir)/m_mach
 	(cd m_mach && mig $(mach_defs))
 
 #----------------------------------------------------------------------------
