Merge "linker: Fix memory leak for reserved memory"
diff --git a/libc/Android.bp b/libc/Android.bp
index e1803b8..6442bc9 100644
--- a/libc/Android.bp
+++ b/libc/Android.bp
@@ -248,6 +248,7 @@
cc_library_static {
defaults: ["libc_defaults"],
+ tidy_disabled_srcs: ["upstream-*/**/*.c"],
srcs: [
"tzcode/**/*.c",
"tzcode/bionic.cpp",
@@ -291,6 +292,7 @@
cc_library_static {
defaults: ["libc_defaults"],
+ tidy_disabled_srcs: ["upstream-*/**/*.c"],
srcs: [
"dns/**/*.c*",
@@ -326,6 +328,7 @@
cc_library_static {
defaults: ["libc_defaults"],
+ tidy_disabled_srcs: ["upstream-*/**/*.c"],
srcs: [
"upstream-freebsd/lib/libc/gen/ldexp.c",
"upstream-freebsd/lib/libc/stdlib/getopt_long.c",
@@ -392,6 +395,7 @@
cc_library_static {
defaults: ["libc_defaults"],
+ tidy_disabled_srcs: ["upstream-*/**/*.c"],
srcs: [
"upstream-freebsd/lib/libc/gen/glob.c",
],
@@ -419,6 +423,7 @@
cc_library_static {
defaults: ["libc_defaults"],
+ tidy_disabled_srcs: ["upstream-*/**/*.c"],
srcs: [
"upstream-netbsd/common/lib/libc/stdlib/random.c",
"upstream-netbsd/lib/libc/gen/nice.c",
@@ -476,6 +481,7 @@
cc_library_static {
name: "libc_openbsd_ndk",
defaults: ["libc_defaults"],
+ tidy_disabled_srcs: ["upstream-*/**/*.c"],
srcs: [
"upstream-openbsd/lib/libc/gen/alarm.c",
"upstream-openbsd/lib/libc/gen/ctype_.c",
@@ -594,6 +600,7 @@
cc_library_static {
name: "libc_openbsd_large_stack",
defaults: ["libc_defaults"],
+ tidy_disabled_srcs: ["upstream-*/**/*.c"],
srcs: [
"stdio/vfprintf.cpp",
"stdio/vfwprintf.cpp",
@@ -623,6 +630,7 @@
// automatically included.
cc_library_static {
defaults: ["libc_defaults"],
+ tidy_disabled_srcs: ["upstream-*/**/*.c"],
srcs: [
// These two depend on getentropy, which isn't in libc_ndk.a.
"upstream-openbsd/lib/libc/crypt/arc4random.c",
@@ -722,6 +730,7 @@
cc_library_static {
defaults: ["libc_defaults"],
+ tidy_disabled_srcs: ["upstream-*/**/*.c"],
srcs: [
"upstream-openbsd/android/gdtoa_support.cpp",
"upstream-openbsd/lib/libc/gdtoa/dmisc.c",
@@ -2263,8 +2272,8 @@
// libc dependencies for baremetal Rust projects.
// ========================================================
-cc_defaults {
- name: "librust_baremetal_defaults",
+cc_library_static {
+ name: "librust_baremetal",
header_libs: ["libc_headers"],
include_dirs: [
"bionic/libc/async_safe/include",
@@ -2274,17 +2283,12 @@
"-Wall",
"-Werror",
],
- system_shared_libs: [],
- nocrt: true,
- stl: "none",
-}
-
-cc_library_static {
- name: "librust_baremetal",
- defaults: ["librust_baremetal_defaults"],
whole_static_libs: [
"libarm-optimized-routines-mem",
],
+ system_shared_libs: [],
+ nocrt: true,
+ stl: "none",
visibility: [
"//packages/modules/Virtualization/vmbase",
],
@@ -2812,6 +2816,7 @@
cc_library_host_static {
name: "libfts",
+ tidy_disabled_srcs: ["upstream-*/**/*.c"],
srcs: [
"bionic/fts.c",
"upstream-openbsd/lib/libc/stdlib/recallocarray.c",
@@ -2854,6 +2859,7 @@
cc_library_host_static {
name: "libb64",
visibility: ["//external/musl"],
+ tidy_disabled_srcs: ["upstream-*/**/*.c"],
srcs: ["upstream-openbsd/lib/libc/net/base64.c"],
export_include_dirs: ["b64/include"],
local_include_dirs: [
diff --git a/libc/include/langinfo.h b/libc/include/langinfo.h
index d9d8c15..2b43892 100644
--- a/libc/include/langinfo.h
+++ b/libc/include/langinfo.h
@@ -92,8 +92,8 @@
#define NOEXPR 54
#define CRNCYSTR 55
-char* nl_langinfo(nl_item __item) __INTRODUCED_IN(26);
-char* nl_langinfo_l(nl_item __item, locale_t __l) __INTRODUCED_IN(26);
+char* _Nonnull nl_langinfo(nl_item __item) __INTRODUCED_IN(26);
+char* _Nonnull nl_langinfo_l(nl_item __item, locale_t _Nonnull __l) __INTRODUCED_IN(26);
__END_DECLS
diff --git a/libc/include/time.h b/libc/include/time.h
index 0db14ff..4b005c6 100644
--- a/libc/include/time.h
+++ b/libc/include/time.h
@@ -37,7 +37,7 @@
#define CLOCKS_PER_SEC 1000000
-extern char* tzname[];
+extern char* _Nonnull tzname[];
extern int daylight;
extern long int timezone;
@@ -54,62 +54,64 @@
int tm_yday;
int tm_isdst;
long int tm_gmtoff;
- const char* tm_zone;
+ const char* _Nullable tm_zone;
};
#define TM_ZONE tm_zone
-time_t time(time_t* __t);
-int nanosleep(const struct timespec* __request, struct timespec* __remainder);
+time_t time(time_t* _Nullable __t);
+int nanosleep(const struct timespec* _Nonnull __request, struct timespec* _Nullable __remainder);
-char* asctime(const struct tm* __tm);
-char* asctime_r(const struct tm* __tm, char* __buf);
+char* _Nullable asctime(const struct tm* _Nonnull __tm);
+char* _Nullable asctime_r(const struct tm* _Nonnull __tm, char* _Nonnull __buf);
double difftime(time_t __lhs, time_t __rhs);
-time_t mktime(struct tm* __tm);
+time_t mktime(struct tm* _Nonnull __tm);
-struct tm* localtime(const time_t* __t);
-struct tm* localtime_r(const time_t* __t, struct tm* __tm);
+struct tm* _Nullable localtime(const time_t* _Nonnull __t);
+struct tm* _Nullable localtime_r(const time_t* _Nonnull __t, struct tm* _Nonnull __tm);
-struct tm* gmtime(const time_t* __t);
-struct tm* gmtime_r(const time_t* __t, struct tm* __tm);
+struct tm* _Nullable gmtime(const time_t* _Nonnull __t);
+struct tm* _Nullable gmtime_r(const time_t* _Nonnull __t, struct tm* _Nonnull __tm);
-char* strptime(const char* __s, const char* __fmt, struct tm* __tm) __strftimelike(2);
-char* strptime_l(const char* __s, const char* __fmt, struct tm* __tm, locale_t __l) __strftimelike(2) __INTRODUCED_IN(28);
+char* _Nullable strptime(const char* _Nonnull __s, const char* _Nonnull __fmt, struct tm* _Nonnull __tm) __strftimelike(2);
+char* _Nullable strptime_l(const char* _Nonnull __s, const char* _Nonnull __fmt, struct tm* _Nonnull __tm, locale_t _Nonnull __l) __strftimelike(2) __INTRODUCED_IN(28);
-size_t strftime(char* __buf, size_t __n, const char* __fmt, const struct tm* __tm) __strftimelike(3);
+size_t strftime(char* _Nonnull __buf, size_t __n, const char* _Nonnull __fmt, const struct tm* _Nullable __tm) __strftimelike(3);
#if __ANDROID_API__ >= 21
-size_t strftime_l(char* __buf, size_t __n, const char* __fmt, const struct tm* __tm, locale_t __l) __strftimelike(3) __INTRODUCED_IN(21);
+size_t strftime_l(char* _Nonnull __buf, size_t __n, const char* _Nonnull __fmt, const struct tm* _Nullable __tm, locale_t _Nonnull __l) __strftimelike(3) __INTRODUCED_IN(21);
#else
// Implemented as static inline before 21.
#endif
-char* ctime(const time_t* __t);
-char* ctime_r(const time_t* __t, char* __buf);
+
+char* _Nullable ctime(const time_t* _Nonnull __t);
+char* _Nullable ctime_r(const time_t* _Nonnull __t, char* _Nonnull __buf);
void tzset(void);
clock_t clock(void);
-int clock_getcpuclockid(pid_t __pid, clockid_t* __clock) __INTRODUCED_IN(23);
+int clock_getcpuclockid(pid_t __pid, clockid_t* _Nonnull __clock) __INTRODUCED_IN(23);
-int clock_getres(clockid_t __clock, struct timespec* __resolution);
-int clock_gettime(clockid_t __clock, struct timespec* __ts);
-int clock_nanosleep(clockid_t __clock, int __flags, const struct timespec* __request, struct timespec* __remainder);
-int clock_settime(clockid_t __clock, const struct timespec* __ts);
-int timer_create(clockid_t __clock, struct sigevent* __event, timer_t* __timer_ptr);
-int timer_delete(timer_t __timer);
-int timer_settime(timer_t __timer, int __flags, const struct itimerspec* __new_value, struct itimerspec* __old_value);
-int timer_gettime(timer_t __timer, struct itimerspec* __ts);
-int timer_getoverrun(timer_t __timer);
+int clock_getres(clockid_t __clock, struct timespec* _Nullable __resolution);
+int clock_gettime(clockid_t __clock, struct timespec* _Nonnull __ts);
+int clock_nanosleep(clockid_t __clock, int __flags, const struct timespec* _Nonnull __request, struct timespec* _Nullable __remainder);
+int clock_settime(clockid_t __clock, const struct timespec* _Nonnull __ts);
+
+int timer_create(clockid_t __clock, struct sigevent* _Nullable __event, timer_t _Nonnull * _Nonnull __timer_ptr);
+int timer_delete(timer_t _Nonnull __timer);
+int timer_settime(timer_t _Nonnull __timer, int __flags, const struct itimerspec* _Nonnull __new_value, struct itimerspec* _Nullable __old_value);
+int timer_gettime(timer_t _Nonnull _timer, struct itimerspec* _Nonnull __ts);
+int timer_getoverrun(timer_t _Nonnull __timer);
/* Non-standard extensions that are in the BSDs and glibc. */
-time_t timelocal(struct tm* __tm);
-time_t timegm(struct tm* __tm);
+time_t timelocal(struct tm* _Nonnull __tm);
+time_t timegm(struct tm* _Nonnull __tm);
#define TIME_UTC 1
-int timespec_get(struct timespec* __ts, int __base) __INTRODUCED_IN(29);
+int timespec_get(struct timespec* _Nonnull __ts, int __base) __INTRODUCED_IN(29);
__END_DECLS
diff --git a/libc/include/time64.h b/libc/include/time64.h
index 905669d..7d70030 100644
--- a/libc/include/time64.h
+++ b/libc/include/time64.h
@@ -47,17 +47,17 @@
typedef int64_t time64_t;
-char* asctime64(const struct tm*);
-char* asctime64_r(const struct tm*, char*);
-char* ctime64(const time64_t*);
-char* ctime64_r(const time64_t*, char*);
-struct tm* gmtime64(const time64_t*);
-struct tm* gmtime64_r(const time64_t*, struct tm*);
-struct tm* localtime64(const time64_t*);
-struct tm* localtime64_r(const time64_t*, struct tm*);
-time64_t mktime64(const struct tm*);
-time64_t timegm64(const struct tm*);
-time64_t timelocal64(const struct tm*);
+char* _Nullable asctime64(const struct tm* _Nonnull);
+char* _Nullable asctime64_r(const struct tm* _Nonnull, char* _Nonnull);
+char* _Nullable ctime64(const time64_t* _Nonnull);
+char* _Nullable ctime64_r(const time64_t* _Nonnull, char* _Nonnull);
+struct tm* _Nullable gmtime64(const time64_t* _Nonnull);
+struct tm* _Nullable gmtime64_r(const time64_t* _Nonnull, struct tm* _Nonnull);
+struct tm* _Nullable localtime64(const time64_t* _Nonnull);
+struct tm* _Nullable localtime64_r(const time64_t* _Nonnull, struct tm* _Nonnull);
+time64_t mktime64(const struct tm* _Nonnull);
+time64_t timegm64(const struct tm* _Nonnull);
+time64_t timelocal64(const struct tm* _Nonnull);
__END_DECLS
diff --git a/libm/Android.bp b/libm/Android.bp
index 2748871..3e271fa 100644
--- a/libm/Android.bp
+++ b/libm/Android.bp
@@ -29,6 +29,7 @@
whole_static_libs: ["libarm-optimized-routines-math"],
+ tidy_disabled_srcs: ["upstream-*/**/*.c"],
srcs: [
"upstream-freebsd/lib/msun/bsdsrc/b_tgamma.c",
"upstream-freebsd/lib/msun/src/catrig.c",
diff --git a/tests/time_test.cpp b/tests/time_test.cpp
index 40e5c6d..f0ad937 100644
--- a/tests/time_test.cpp
+++ b/tests/time_test.cpp
@@ -998,6 +998,10 @@
ASSERT_EQ(-1, ts.tv_sec);
}
+TEST(time, clock_getres_null_resolution) {
+ ASSERT_EQ(0, clock_getres(CLOCK_REALTIME, nullptr));
+}
+
TEST(time, clock) {
// clock(3) is hard to test, but a 1s sleep should cost less than 10ms on average.
static const clock_t N = 5;