Merge "Merge memory checking functionality from sandbox"
diff --git a/libc/bionic/semaphore.c b/libc/bionic/semaphore.c
index 0c94600..84b9314 100644
--- a/libc/bionic/semaphore.c
+++ b/libc/bionic/semaphore.c
@@ -180,7 +180,7 @@
if (sem == NULL)
return EINVAL;
- if (__atomic_inc((volatile int*)&sem->count) == 0)
+ if (__atomic_inc((volatile int*)&sem->count) >= 0)
__futex_wake(&sem->count, 1);
return 0;
@@ -196,7 +196,8 @@
if (__atomic_dec_if_positive(&sem->count) > 0) {
return 0;
} else {
- return EAGAIN;
+ errno = EAGAIN;
+ return -1;
}
}
diff --git a/libc/bionic/stubs.c b/libc/bionic/stubs.c
index 586d497..d495674 100644
--- a/libc/bionic/stubs.c
+++ b/libc/bionic/stubs.c
@@ -185,7 +185,7 @@
goto FAIL;
id = strtoul(name+4, &end, 10);
- if (id == 0 || *end != '\0')
+ if (*end != '\0')
goto FAIL;
id += AID_APP;
diff --git a/libc/docs/CHANGES.TXT b/libc/docs/CHANGES.TXT
index c2655c5..f59cfab 100644
--- a/libc/docs/CHANGES.TXT
+++ b/libc/docs/CHANGES.TXT
@@ -46,7 +46,17 @@
- <wchar.h>: Add mbstowcs() and wcstombs()
-- add clone() implementation for ARM (x86 and SH-4 not working yet)
+- add clone() implementation for ARM (x86 and SH-4 not working yet).
+
+- <sys/epoll.h>: <sys/system_properties.h>: Add missing C++ inclusion guards
+
+- fix getpwnam() and getpwgrp() to accept "app_0" as a valid user name.
+
+- fix sem_trywait() to return -1 and set errno to EAGAIN, instead of
+ returning EAGAIN directly.
+
+- fix sem_post() to wake up multiple threads when called rapidly in
+ succession.
-------------------------------------------------------------------------------
Differences between Android 2.1 and 2.0.1:
diff --git a/libc/include/netdb.h b/libc/include/netdb.h
index b0c3b72..c2e08ea 100644
--- a/libc/include/netdb.h
+++ b/libc/include/netdb.h
@@ -75,10 +75,6 @@
#define MAXHOSTNAMELEN 256
-/* BIONIC-BEGIN */
-#define h_errno (*__get_h_errno())
-extern int* __get_h_errno(void);
-/* BIONIC-END */
/*
* Structures returned by network data base library. All addresses are
@@ -203,6 +199,10 @@
#define SCOPE_DELIMITER '%'
__BEGIN_DECLS
+/* BIONIC-BEGIN */
+#define h_errno (*__get_h_errno())
+int* __get_h_errno(void);
+/* BIONIC-END */
void endhostent(void);
void endnetent(void);
void endnetgrent(void);