runtime: allow arbitrary return type in SetFinalizer.
	finalize chan, to free OS X semaphore inside Lock.
os: finalize File, to close fd.

Fixes #503.

R=ken2
CC=golang-dev
https://golang.org/cl/204065
diff --git a/src/pkg/runtime/darwin/thread.c b/src/pkg/runtime/darwin/thread.c
index 56c9d17..38e3c23 100644
--- a/src/pkg/runtime/darwin/thread.c
+++ b/src/pkg/runtime/darwin/thread.c
@@ -48,10 +48,6 @@
 // be >0, so it will increment the semaphore to wake up
 // one of the others.  This is the same algorithm used
 // in Plan 9's user-level locks.
-//
-// Note that semaphores are never destroyed (the kernel
-// will clean up when the process exits).  We assume for now
-// that Locks are only used for long-lived structures like M and G.
 
 void
 lock(Lock *l)
@@ -83,6 +79,14 @@
 	}
 }
 
+void
+destroylock(Lock *l)
+{
+	if(l->sema != 0) {
+		mach_semdestroy(l->sema);
+		l->sema = 0;
+	}
+}
 
 // User-level semaphore implementation:
 // try to do the operations in user space on u,