Merge commit 'a7f976c9de3c20cc8cdde4f3dfeeb48a1a89adb7' into honeycomb-mr2-release-to-dalvik-dev
diff --git a/libc/arch-arm/include/machine/cpu-features.h b/libc/arch-arm/include/machine/cpu-features.h
index 80d3fda..f737f92 100644
--- a/libc/arch-arm/include/machine/cpu-features.h
+++ b/libc/arch-arm/include/machine/cpu-features.h
@@ -185,7 +185,7 @@
#endif
/* Assembly-only macros */
-#ifdef __ASSEMBLY__
+//#ifdef __ASSEMBLY__
/* define a handy PLD(address) macro since the cache preload
* is an optional opcode
@@ -196,6 +196,6 @@
# define PLD(reg,offset) /* nothing */
#endif
-#endif /* ! __ASSEMBLY__ */
+//#endif /* ! __ASSEMBLY__ */
#endif /* _ARM_MACHINE_CPU_FEATURES_H */
diff --git a/libc/bionic/stubs.c b/libc/bionic/stubs.c
index a01d64c..5f63427 100644
--- a/libc/bionic/stubs.c
+++ b/libc/bionic/stubs.c
@@ -37,6 +37,78 @@
#include <errno.h>
#include <ctype.h>
+static int do_getpw_r(int by_name, const char* name, uid_t uid,
+ struct passwd* dst, char* buf, size_t byte_count, struct passwd** result)
+{
+ /*
+ * getpwnam_r and getpwuid_r don't modify errno, but library calls we
+ * make might.
+ */
+ int old_errno = errno;
+ int rc = 0;
+ *result = NULL;
+
+ const struct passwd* src = by_name ? getpwnam(name) : getpwuid(uid);
+
+ /*
+ * POSIX allows failure to find a match to be considered a non-error.
+ * Reporting success (0) but with *result NULL is glibc's behavior.
+ */
+ if (src == NULL) {
+ rc = (errno == ENOENT) ? 0 : errno;
+ goto failure;
+ }
+
+ /*
+ * Work out where our strings will go in 'buf', and whether we've got
+ * enough space.
+ */
+ size_t required_byte_count = 0;
+ dst->pw_name = buf;
+ required_byte_count += strlen(src->pw_name) + 1;
+ dst->pw_dir = buf + required_byte_count;
+ required_byte_count += strlen(src->pw_dir) + 1;
+ dst->pw_shell = buf + required_byte_count;
+ required_byte_count += strlen(src->pw_shell) + 1;
+ if (byte_count < required_byte_count) {
+ rc = ERANGE;
+ goto failure;
+ }
+
+ /* Copy the strings. */
+ snprintf(buf, byte_count, "%s%c%s%c%s",
+ src->pw_name, 0, src->pw_dir, 0, src->pw_shell);
+
+ /*
+ * pw_passwd is non-POSIX and unused (always NULL) in bionic.
+ * pw_gecos is non-POSIX and missing in bionic.
+ */
+ dst->pw_passwd = NULL;
+
+ /* Copy the integral fields. */
+ dst->pw_gid = src->pw_gid;
+ dst->pw_uid = src->pw_uid;
+
+success:
+ rc = 0;
+ *result = dst;
+failure:
+ errno = old_errno;
+ return rc;
+}
+
+int getpwnam_r(const char* name, struct passwd* pwd,
+ char* buf, size_t byte_count, struct passwd** result)
+{
+ return do_getpw_r(1, name, -1, pwd, buf, byte_count, result);
+}
+
+int getpwuid_r(uid_t uid, struct passwd* pwd,
+ char* buf, size_t byte_count, struct passwd** result)
+{
+ return do_getpw_r(0, NULL, uid, pwd, buf, byte_count, result);
+}
+
/** Thread-specific state for the stubs functions
**/
@@ -400,4 +472,3 @@
{
fprintf(stderr, "FIX ME! implement %s() %s:%d\n", __FUNCTION__, __FILE__, __LINE__);
}
-
diff --git a/libc/include/sys/_errdefs.h b/libc/include/sys/_errdefs.h
index e27ab7a..51d921b 100644
--- a/libc/include/sys/_errdefs.h
+++ b/libc/include/sys/_errdefs.h
@@ -36,6 +36,7 @@
#ifndef __BIONIC_ERRDEF
#error "__BIONIC_ERRDEF must be defined before including this file"
#endif
+__BIONIC_ERRDEF( 0 , 0, "Success" )
__BIONIC_ERRDEF( EPERM , 1, "Operation not permitted" )
__BIONIC_ERRDEF( ENOENT , 2, "No such file or directory" )
__BIONIC_ERRDEF( ESRCH , 3, "No such process" )
diff --git a/libc/string/strerror_r.c b/libc/string/strerror_r.c
index f43d417..2f26f17 100644
--- a/libc/string/strerror_r.c
+++ b/libc/string/strerror_r.c
@@ -21,7 +21,7 @@
for (;;)
{
- if (strings[nn].code == 0)
+ if (strings[nn].msg == NULL)
break;
if (strings[nn].code == code)