Merge "Switch x86 begin.c to asm; align ESP correctly"
diff --git a/libc/Android.bp b/libc/Android.bp
index 13e17fe..f5491f5 100644
--- a/libc/Android.bp
+++ b/libc/Android.bp
@@ -33,6 +33,7 @@
libc_common_flags = [
"-D_LIBC=1",
+ "-D__BIONIC_LP32_USE_STAT64",
"-Wall",
"-Wextra",
"-Wunused",
diff --git a/libc/include/ftw.h b/libc/include/ftw.h
index 300f624..a289643 100644
--- a/libc/include/ftw.h
+++ b/libc/include/ftw.h
@@ -56,11 +56,9 @@
__BEGIN_DECLS
int ftw(const char* __dir_path, int (*__callback)(const char*, const struct stat*, int), int __max_fd_count) __INTRODUCED_IN(17);
-int nftw(const char* __dir_path, int (*__callback)(const char*, const struct stat*, int, struct FTW*), int __max_fd_count, int __flags)
- __INTRODUCED_IN(17);
-int ftw64(const char* __dir_path, int (*__callback)(const char*, const struct stat64*, int), int __max_fd_count) __INTRODUCED_IN(21);
-int nftw64(const char* __dir_path, int (*__callback)(const char*, const struct stat64*, int, struct FTW*), int __max_fd_count, int __flags)
- __INTRODUCED_IN(21);
+int nftw(const char* __dir_path, int (*__callback)(const char*, const struct stat*, int, struct FTW*), int __max_fd_count, int __flags) __INTRODUCED_IN(17);
+int ftw64(const char* __dir_path, int (*__callback)(const char*, const struct stat64*, int), int __max_fd_count) __RENAME_STAT64(ftw, 17, 21);
+int nftw64(const char* __dir_path, int (*__callback)(const char*, const struct stat64*, int, struct FTW*), int __max_fd_count, int __flags) __RENAME_STAT64(nftw, 17, 21);
__END_DECLS
#endif
diff --git a/libc/include/sys/cdefs.h b/libc/include/sys/cdefs.h
index 27952b9..26dd9a2 100644
--- a/libc/include/sys/cdefs.h
+++ b/libc/include/sys/cdefs.h
@@ -245,6 +245,16 @@
#define __RENAME_LDBL(rewrite,rewrite_api_level,regular_api_level) __RENAME(rewrite) __INTRODUCED_IN(rewrite_api_level)
#endif
+/*
+ * On all architectures, `struct stat` == `struct stat64`, but LP32 didn't gain the *64 functions
+ * until API level 21.
+ */
+#if defined(__LP64__) || defined(__BIONIC_LP32_USE_STAT64)
+#define __RENAME_STAT64(rewrite,rewrite_api_level,regular_api_level) __INTRODUCED_IN(regular_api_level)
+#else
+#define __RENAME_STAT64(rewrite,rewrite_api_level,regular_api_level) __RENAME(rewrite) __INTRODUCED_IN(rewrite_api_level)
+#endif
+
/* glibc compatibility. */
#if defined(__LP64__)
#define __WORDSIZE 64
diff --git a/libc/include/sys/stat.h b/libc/include/sys/stat.h
index 6fce0a5..84a5015 100644
--- a/libc/include/sys/stat.h
+++ b/libc/include/sys/stat.h
@@ -156,13 +156,13 @@
int mkdir(const char* __path, mode_t __mode);
int fstat(int __fd, struct stat* __buf);
-int fstat64(int __fd, struct stat64* __buf) __INTRODUCED_IN(21);
+int fstat64(int __fd, struct stat64* __buf) __RENAME_STAT64(fstat, 3, 21);
int fstatat(int __dir_fd, const char* __path, struct stat* __buf, int __flags);
-int fstatat64(int __dir_fd, const char* __path, struct stat64* __buf, int __flags) __INTRODUCED_IN(21);
+int fstatat64(int __dir_fd, const char* __path, struct stat64* __buf, int __flags) __RENAME_STAT64(fstatat, 3, 21);
int lstat(const char* __path, struct stat* __buf);
-int lstat64(const char* __path, struct stat64* __buf) __INTRODUCED_IN(21);
+int lstat64(const char* __path, struct stat64* __buf) __RENAME_STAT64(lstat, 3, 21);
int stat(const char* __path, struct stat* __buf);
-int stat64(const char* __path, struct stat64* __buf) __INTRODUCED_IN(21);
+int stat64(const char* __path, struct stat64* __buf) __RENAME_STAT64(stat, 3, 21);
int mknod(const char* __path, mode_t __mode, dev_t __dev);
mode_t umask(mode_t __mask);
diff --git a/tests/grp_pwd_test.cpp b/tests/grp_pwd_test.cpp
index 61748c8..a905fae 100644
--- a/tests/grp_pwd_test.cpp
+++ b/tests/grp_pwd_test.cpp
@@ -257,14 +257,7 @@
EXPECT_STREQ("/data", pwd->pw_dir) << "pwd->pw_uid: " << pwd->pw_uid;
}
- // TODO(b/27999086): fix this check with the OEM range
- // If OEMs add their own AIDs to private/android_filesystem_config.h, this check will fail.
- // Long term we want to create a better solution for OEMs adding AIDs, but we're not there
- // yet, so therefore we do not check for uid's in the OEM range.
- if (!(pwd->pw_uid >= 2900 && pwd->pw_uid <= 2999) &&
- !(pwd->pw_uid >= 5000 && pwd->pw_uid <= 5999)) {
- EXPECT_EQ(0U, uids.count(pwd->pw_uid)) << "pwd->pw_uid: " << pwd->pw_uid;
- }
+ EXPECT_EQ(0U, uids.count(pwd->pw_uid)) << "pwd->pw_uid: " << pwd->pw_uid;
uids.emplace(pwd->pw_uid);
}
endpwent();
@@ -494,14 +487,7 @@
EXPECT_STREQ(grp->gr_name, grp->gr_mem[0]) << "grp->gr_gid: " << grp->gr_gid;
EXPECT_TRUE(grp->gr_mem[1] == NULL) << "grp->gr_gid: " << grp->gr_gid;
- // TODO(b/27999086): fix this check with the OEM range
- // If OEMs add their own AIDs to private/android_filesystem_config.h, this check will fail.
- // Long term we want to create a better solution for OEMs adding AIDs, but we're not there
- // yet, so therefore we do not check for gid's in the OEM range.
- if (!(grp->gr_gid >= 2900 && grp->gr_gid <= 2999) &&
- !(grp->gr_gid >= 5000 && grp->gr_gid <= 5999)) {
- EXPECT_EQ(0U, gids.count(grp->gr_gid)) << "grp->gr_gid: " << grp->gr_gid;
- }
+ EXPECT_EQ(0U, gids.count(grp->gr_gid)) << "grp->gr_gid: " << grp->gr_gid;
gids.emplace(grp->gr_gid);
}
endgrent();