Add semaphore tests, fix sem_destroy.

Bug: https://code.google.com/p/android/issues/detail?id=76088
Change-Id: I4a0561b23e90312384d40a1c804ca64ee98f4066
diff --git a/libc/include/limits.h b/libc/include/limits.h
index fb09657..f9f0c79 100644
--- a/libc/include/limits.h
+++ b/libc/include/limits.h
@@ -49,6 +49,7 @@
 #define	_POSIX_PATH_MAX		256
 #define _POSIX_PIPE_BUF		512
 #define	_POSIX_RE_DUP_MAX	255
+#define	_POSIX_SEM_VALUE_MAX	32767
 #define _POSIX_SSIZE_MAX	32767
 #define _POSIX_STREAM_MAX	8
 #define _POSIX_SYMLINK_MAX	255
@@ -125,4 +126,7 @@
 /* glibc's PAGE_MASK is the bitwise negation of BSD's! TODO: remove? */
 #define PAGE_MASK (~(PAGE_SIZE - 1))
 
+#define _POSIX_SEMAPHORES 200809L
+#define SEM_VALUE_MAX 0x3fffffff
+
 #endif /* !_LIMITS_H_ */
diff --git a/libc/include/semaphore.h b/libc/include/semaphore.h
index 7ae3c3a..5827870 100644
--- a/libc/include/semaphore.h
+++ b/libc/include/semaphore.h
@@ -25,6 +25,7 @@
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
+
 #ifndef _SEMAPHORE_H
 #define _SEMAPHORE_H
 
@@ -32,6 +33,8 @@
 
 __BEGIN_DECLS
 
+struct timespec;
+
 typedef struct {
   volatile unsigned int count;
 #ifdef __LP64__
@@ -41,20 +44,18 @@
 
 #define SEM_FAILED NULL
 
-extern int sem_init(sem_t *sem, int pshared, unsigned int value);
+int sem_destroy(sem_t*);
+int sem_getvalue(sem_t*, int*);
+int sem_init(sem_t*, int, unsigned int);
+int sem_post(sem_t*);
+int sem_timedwait(sem_t*, const struct timespec*);
+int sem_trywait(sem_t*);
+int sem_wait(sem_t*);
 
-extern int    sem_close(sem_t *);
-extern int    sem_destroy(sem_t *);
-extern int    sem_getvalue(sem_t *, int *);
-extern int    sem_init(sem_t *, int, unsigned int);
-extern sem_t *sem_open(const char *, int, ...);
-extern int    sem_post(sem_t *);
-extern int    sem_trywait(sem_t *);
-extern int    sem_unlink(const char *);
-extern int    sem_wait(sem_t *);
-
-struct timespec;
-extern int    sem_timedwait(sem_t *sem, const struct timespec *abs_timeout);
+/* These aren't actually implemented. */
+sem_t* sem_open(const char*, int, ...);
+int sem_close(sem_t*);
+int sem_unlink(const char*);
 
 __END_DECLS