am a3120aaf: Merge "Add basic tests for posix_memalign."

# Via Elliott Hughes (1) and Gerrit Code Review (1)
* commit 'a3120aaf2f4e20261a2ea9fd8862e2b360183fc5':
  Add basic tests for posix_memalign.
diff --git a/tests/stdlib_test.cpp b/tests/stdlib_test.cpp
index a9c62d4..8735100 100644
--- a/tests/stdlib_test.cpp
+++ b/tests/stdlib_test.cpp
@@ -16,6 +16,8 @@
 
 #include <gtest/gtest.h>
 
+#include <errno.h>
+#include <stdint.h>
 #include <stdlib.h>
 
 TEST(stdlib, drand48) {
@@ -57,3 +59,14 @@
   EXPECT_EQ(1804534249, mrand48());
   EXPECT_EQ(264732262, mrand48());
 }
+
+TEST(stdlib, posix_memalign) {
+  void* p;
+
+  ASSERT_EQ(0, posix_memalign(&p, 512, 128));
+  ASSERT_EQ(0U, reinterpret_cast<uintptr_t>(p) % 512);
+  free(p);
+
+  // Can't align to a non-power of 2.
+  ASSERT_EQ(EINVAL, posix_memalign(&p, 81, 128));
+}