Merge "Add a basic NDK compatibility library."
diff --git a/libc/bionic/stubs.cpp b/libc/bionic/stubs.cpp
index 1e487b4..1264fd7 100644
--- a/libc/bionic/stubs.cpp
+++ b/libc/bionic/stubs.cpp
@@ -207,7 +207,7 @@
 // u2_i1000 -> 2 * AID_USER + AID_ISOLATED_START + 1000
 // u1_system -> 1 * AID_USER + android_ids['system']
 // returns 0 and sets errno to ENOENT in case of error
-static unsigned app_id_from_name(const char* name, bool is_group) {
+static id_t app_id_from_name(const char* name, bool is_group) {
   char* end;
   unsigned long userid;
   bool is_shared_gid = false;
@@ -272,7 +272,7 @@
     return 0;
   }
 
-  return static_cast<unsigned>(appid + userid*AID_USER);
+  return (appid + userid*AID_USER);
 }
 
 static void print_app_name_from_uid(const uid_t uid, char* buffer, const int bufferlen) {
diff --git a/tests/Android.mk b/tests/Android.mk
index 3150655..11fb2c8 100644
--- a/tests/Android.mk
+++ b/tests/Android.mk
@@ -369,7 +369,7 @@
 
 LOCAL_CLANG := false
 LOCAL_MODULE := bionic-compile-time-tests-g++
-LOCAL_CXXFLAGS := -Wall
+LOCAL_CPPFLAGS := -Wall
 LOCAL_SRC_FILES := fortify_sprintf_warnings.cpp
 include $(BUILD_STATIC_LIBRARY)
 
@@ -386,7 +386,7 @@
 
 LOCAL_CLANG := true
 LOCAL_MODULE := bionic-compile-time-tests-clang++
-LOCAL_CXXFLAGS := -Wall
+LOCAL_CPPFLAGS := -Wall
 # FileCheck will error if there aren't any CLANG: lines in the file, but there
 # don't appear to be any cases where clang _does_ emit warnings for sn?printf :(
 LOCAL_SRC_FILES :=
diff --git a/tests/stdio_test.cpp b/tests/stdio_test.cpp
index 6d7e72b..0e24325 100644
--- a/tests/stdio_test.cpp
+++ b/tests/stdio_test.cpp
@@ -107,7 +107,7 @@
     ASSERT_FALSE(feof(fp));
     ASSERT_EQ(getdelim(&word_read, &allocated_length, ' ', fp), static_cast<int>(strlen(expected[i])));
     ASSERT_GE(allocated_length, strlen(expected[i]));
-    ASSERT_STREQ(word_read, expected[i]);
+    ASSERT_STREQ(expected[i], word_read);
   }
   // The last read should have set the end-of-file indicator for the stream.
   ASSERT_TRUE(feof(fp));
@@ -171,7 +171,7 @@
   while ((read_char_count = getline(&line_read, &allocated_length, fp)) != -1) {
     ASSERT_EQ(read_char_count, static_cast<int>(strlen(line_written)));
     ASSERT_GE(allocated_length, strlen(line_written));
-    ASSERT_STREQ(line_read, line_written);
+    ASSERT_STREQ(line_written, line_read);
     ++read_line_count;
   }
   ASSERT_EQ(read_line_count, line_count);
@@ -889,23 +889,24 @@
   }
 }
 
-TEST(fread, fread_EOF) {
-  const char* digits = "0123456789";
-  FILE* fp = fmemopen((char*) digits, sizeof(digits), "r");
+TEST(stdio, fread_EOF) {
+  std::string digits("0123456789");
+  FILE* fp = fmemopen(&digits[0], digits.size(), "r");
 
   // Try to read too much, but little enough that it still fits in the FILE's internal buffer.
   char buf1[4 * 4];
   memset(buf1, 0, sizeof(buf1));
   ASSERT_EQ(2U, fread(buf1, 4, 4, fp));
-  ASSERT_STREQ(buf1, "01234567");
+  ASSERT_STREQ("0123456789", buf1);
   ASSERT_TRUE(feof(fp));
 
   rewind(fp);
 
-  char buf2[4 * 4];
+  // Try to read way too much so stdio tries to read more direct from the stream.
+  char buf2[4 * 4096];
   memset(buf2, 0, sizeof(buf2));
   ASSERT_EQ(2U, fread(buf2, 4, 4096, fp));
-  ASSERT_STREQ(buf2, "01234567");
+  ASSERT_STREQ("0123456789", buf2);
   ASSERT_TRUE(feof(fp));
 
   fclose(fp);
diff --git a/tools/bionicbb/gmail_listener.py b/tools/bionicbb/gmail_listener.py
index f4936d6..0cd31c9 100644
--- a/tools/bionicbb/gmail_listener.py
+++ b/tools/bionicbb/gmail_listener.py
@@ -140,7 +140,7 @@
     return True
 
 
-def build_project(gerrit_info, dry_run):
+def build_project(gerrit_info, dry_run, lunch_target=None):
     project_to_jenkins_map = {
         'platform/bionic': 'bionic-presubmit',
         'platform/build': 'bionic-presubmit',
@@ -187,6 +187,8 @@
             'CHANGE_ID': change_id,
             'PROJECT': project_path
         }
+        if lunch_target is not None:
+            params['LUNCH_TARGET'] = lunch_target
         if not dry_run:
             job = jenkins[build].invoke(build_params=params)
             url = job.get_build().baseurl
@@ -249,6 +251,19 @@
     command_map = {
         'clean': lambda: clean_project(gerrit_info, dry_run),
         'retry': lambda: build_project(gerrit_info, dry_run),
+
+        'arm': lambda: build_project(gerrit_info, dry_run,
+                                     lunch_target='aosp_arm-eng'),
+        'aarch64': lambda: build_project(gerrit_info, dry_run,
+                                         lunch_target='aosp_arm64-eng'),
+        'mips': lambda: build_project(gerrit_info, dry_run,
+                                      lunch_target='aosp_mips-eng'),
+        'mips64': lambda: build_project(gerrit_info, dry_run,
+                                        lunch_target='aosp_mips64-eng'),
+        'x86': lambda: build_project(gerrit_info, dry_run,
+                                     lunch_target='aosp_x86-eng'),
+        'x86_64': lambda: build_project(gerrit_info, dry_run,
+                                        lunch_target='aosp_x86_64-eng'),
     }
 
     def handle_unknown_command():