Merge "Remove the always-true __INTRODUCED_IN() annotations."
diff --git a/benchmarks/linker_relocation/gen/Android.bp b/benchmarks/linker_relocation/gen/Android.bp
index c8f0b4a..d07ebf7 100644
--- a/benchmarks/linker_relocation/gen/Android.bp
+++ b/benchmarks/linker_relocation/gen/Android.bp
@@ -1,8 +1,5 @@
// AUTO-GENERATED BY gen_bench.py -- do not edit
-package {
- default_applicable_licenses: ["bionic_benchmarks_license"],
-}
-
+package { default_applicable_licenses: ["bionic_benchmarks_license"], }
cc_defaults {
name: "linker_reloc_bench_all_libs",
runtime_libs: [
diff --git a/benchmarks/linker_relocation/gen/liblinker_reloc_bench_000.S b/benchmarks/linker_relocation/gen/liblinker_reloc_bench_000.S
index c0ad782..f04726f 100644
--- a/benchmarks/linker_relocation/gen/liblinker_reloc_bench_000.S
+++ b/benchmarks/linker_relocation/gen/liblinker_reloc_bench_000.S
@@ -7572,7 +7572,6 @@
CALL(b_wavGuebjRkprcgvbaSzg)
CALL(b__MAX7naqebvq9MvcSvyrEB12trgRagelVasbRCiCgCwF3_CyF3_F3_)
CALL(mktime)
-CALL(lstat64)
CALL(b_pep32)
CALL(read)
CALL(close)
@@ -9757,7 +9756,6 @@
.weak b__MAFg3__16__gerrVAF_12__inyhr_glcrVAF_12onfvp_fgevatVpAF_11pune_genvgfVpRRAF_9nyybpngbeVpRRRRAF_10funerq_cgeVA7zvavxva14SbagPbyyrpgvbaRRRRRAF_19__znc_inyhr_pbzcnerVF7_FP_AF_4yrffVF7_RRYo1RRRAF5_VFP_RRR12__svaq_rdhnyVF7_RRECAF_16__gerr_abqr_onfrVCiRRECAF_15__gerr_raq_abqrVFA_RREXG_
CALL(b__MAFg3__16__gerrVAF_12__inyhr_glcrVAF_12onfvp_fgevatVpAF_11pune_genvgfVpRRAF_9nyybpngbeVpRRRRAF_10funerq_cgeVA7zvavxva14SbagPbyyrpgvbaRRRRRAF_19__znc_inyhr_pbzcnerVF7_FP_AF_4yrffVF7_RRYo1RRRAF5_VFP_RRR12__svaq_rdhnyVF7_RRECAF_16__gerr_abqr_onfrVCiRRECAF_15__gerr_raq_abqrVFA_RREXG_)
CALL(b__MA6FxQngn17ZnxrHavavgvnyvmrqRz)
-CALL(lseek64)
CALL(longjmp)
CALL(b__MA22fxwcrt_qrfgvangvba_zteP1RC9FxJFgernz)
CALL(b_wcrt_fgq_reebe)
diff --git a/benchmarks/linker_relocation/gen/liblinker_reloc_bench_001.S b/benchmarks/linker_relocation/gen/liblinker_reloc_bench_001.S
index c2d5ef2..61b9a55 100644
--- a/benchmarks/linker_relocation/gen/liblinker_reloc_bench_001.S
+++ b/benchmarks/linker_relocation/gen/liblinker_reloc_bench_001.S
@@ -3798,7 +3798,6 @@
CALL(b__MA7naqebvq4onfr10YbtZrffntrQ1Ri)
CALL(b__MA7naqebvq9NcxNffrgf19PerngrNffrgSebzSvyrREXAFg3__112onfvp_fgevatVpAF1_11pune_genvgfVpRRAF1_9nyybpngbeVpRRRR)
CALL(b__MA7naqebvq11YbnqrqVqznc4YbnqREXAF_16OnfvpFgevatCvrprVpRR)
-CALL(lseek64)
CALL(b__MA7naqebvq7SvyrZncP1Ri)
CALL(b__MA7naqebvq7SvyrZnc6perngrRCXpvyzo)
CALL(b__MA7naqebvq5Nffrg25perngrSebzHapbzcerffrqZncRAFg3__110havdhr_cgeVAF_7SvyrZncRAF1_14qrsnhyg_qryrgrVF3_RRRRAF0_10NpprffZbqrR)
@@ -4301,7 +4300,6 @@
CALL(b_pep32)
CALL(b__MA7naqebvq16OnpxhcQngnJevgre17JevgrRagvglUrnqreREXAF_7Fgevat8Rz)
CALL(b__MA7naqebvq16OnpxhcQngnJevgre15JevgrRagvglQngnRCXiz)
-CALL(lstat64)
CALL(b__MA7naqebvq16OnpxhcQngnErnqre16ErnqRagvglUrnqreRCAF_7Fgevat8RCz)
CALL(b__MA7naqebvq16OnpxhcQngnErnqre14ErnqRagvglQngnRCiz)
CALL(open)
diff --git a/benchmarks/linker_relocation/gen/liblinker_reloc_bench_070.S b/benchmarks/linker_relocation/gen/liblinker_reloc_bench_070.S
index 7a8310d..ddfc3d4 100644
--- a/benchmarks/linker_relocation/gen/liblinker_reloc_bench_070.S
+++ b/benchmarks/linker_relocation/gen/liblinker_reloc_bench_070.S
@@ -2299,16 +2299,14 @@
DATA_WORD(local_label)
.space (__SIZEOF_POINTER__ * 2)
DATA_WORD(local_label)
-DATA_WORD(pread64)
-.space (__SIZEOF_POINTER__ * 1)
+.space (__SIZEOF_POINTER__ * 2)
DATA_WORD(local_label)
DATA_WORD(write)
.space (__SIZEOF_POINTER__ * 1)
DATA_WORD(local_label)
.space (__SIZEOF_POINTER__ * 2)
DATA_WORD(local_label)
-DATA_WORD(pwrite64)
-.space (__SIZEOF_POINTER__ * 1)
+.space (__SIZEOF_POINTER__ * 2)
DATA_WORD(local_label)
DATA_WORD(fchmod)
.space (__SIZEOF_POINTER__ * 1)
diff --git a/benchmarks/linker_relocation/gen/liblinker_reloc_bench_074.S b/benchmarks/linker_relocation/gen/liblinker_reloc_bench_074.S
index 340a9cf..471bed0 100644
--- a/benchmarks/linker_relocation/gen/liblinker_reloc_bench_074.S
+++ b/benchmarks/linker_relocation/gen/liblinker_reloc_bench_074.S
@@ -460,7 +460,6 @@
CALL(__stack_chk_fail)
CALL(open)
CALL(strerror)
-CALL(lseek64)
CALL(b__MA10MvcNepuvirQ2Ri)
CALL(memcpy)
CALL(b__MAXFg3__121__onfvp_fgevat_pbzzbaVYo1RR20__guebj_yratgu_reebeRi)
diff --git a/benchmarks/linker_relocation/gen/liblinker_reloc_bench_081.S b/benchmarks/linker_relocation/gen/liblinker_reloc_bench_081.S
index 410c57a..ac7bd42 100644
--- a/benchmarks/linker_relocation/gen/liblinker_reloc_bench_081.S
+++ b/benchmarks/linker_relocation/gen/liblinker_reloc_bench_081.S
@@ -272,11 +272,9 @@
CALL(b__MA7naqebvq4onfr10YbtZrffntrQ1Ri)
CALL(__stack_chk_fail)
CALL(b__MA7naqebvq7zrzvasb8CntrNppg12VavgCntrNppgRo)
-CALL(pread64)
CALL(b__MAFg3__113onfvp_bfgernzVpAF_11pune_genvgfVpRRRyfRz)
CALL(b__MAX7naqebvq7zrzvasb8CntrNppg12ZnexCntrVqyrRz)
CALL(b__MAX7naqebvq7zrzvasb8CntrNppg11TrgCntrVqyrRz)
-CALL(pwrite64)
CALL(b__MAFg3__113onfvp_bfgernzVpAF_11pune_genvgfVpRRR6fragelP1REF3_)
CALL(b__MAXFg3__18vbf_onfr6trgybpRi)
CALL(b__MAXFg3__16ybpnyr9hfr_snprgREAF0_2vqR)
diff --git a/benchmarks/linker_relocation/regen/gen_bench.py b/benchmarks/linker_relocation/regen/gen_bench.py
index 6533189..d34a9a9 100755
--- a/benchmarks/linker_relocation/regen/gen_bench.py
+++ b/benchmarks/linker_relocation/regen/gen_bench.py
@@ -115,9 +115,13 @@
'getprogname',
'gettid',
'isnanf',
+ 'lseek64',
+ 'lstat64',
'mallinfo',
'malloc_info',
+ 'pread64',
'pthread_gettid_np',
+ 'pwrite64',
'res_mkquery',
'strlcpy',
'strtoll_l',
diff --git a/libc/bionic/jemalloc_wrapper.cpp b/libc/bionic/jemalloc_wrapper.cpp
index ce3f314..a2bb1db 100644
--- a/libc/bionic/jemalloc_wrapper.cpp
+++ b/libc/bionic/jemalloc_wrapper.cpp
@@ -19,10 +19,20 @@
#include <sys/param.h>
#include <unistd.h>
+#include <async_safe/log.h>
#include <private/MallocXmlElem.h>
#include "jemalloc.h"
+__BEGIN_DECLS
+
+size_t je_mallinfo_narenas();
+size_t je_mallinfo_nbins();
+struct mallinfo je_mallinfo_arena_info(size_t);
+struct mallinfo je_mallinfo_bin_info(size_t, size_t);
+
+__END_DECLS
+
void* je_pvalloc(size_t bytes) {
size_t pagesize = getpagesize();
size_t size = __BIONIC_ALIGN(bytes, pagesize);
@@ -121,19 +131,36 @@
return 0;
}
return 1;
+ } else if (param == M_LOG_STATS) {
+ for (size_t i = 0; i < je_mallinfo_narenas(); i++) {
+ struct mallinfo mi = je_mallinfo_arena_info(i);
+ if (mi.hblkhd != 0) {
+ async_safe_format_log(ANDROID_LOG_INFO, "jemalloc",
+ "Arena %zu: large bytes %zu huge bytes %zu bin bytes %zu", i,
+ mi.ordblks, mi.uordblks, mi.fsmblks);
+
+ for (size_t j = 0; j < je_mallinfo_nbins(); j++) {
+ struct mallinfo mi = je_mallinfo_bin_info(i, j);
+ if (mi.ordblks != 0) {
+ size_t total_allocs = 1;
+ if (mi.uordblks > mi.fordblks) {
+ total_allocs = mi.uordblks - mi.fordblks;
+ }
+ size_t bin_size = mi.ordblks / total_allocs;
+ async_safe_format_log(
+ ANDROID_LOG_INFO, "jemalloc",
+ " Bin %zu (%zu bytes): allocated bytes %zu nmalloc %zu ndalloc %zu", j, bin_size,
+ mi.ordblks, mi.uordblks, mi.fordblks);
+ }
+ }
+ }
+ }
+ return 1;
}
+
return 0;
}
-__BEGIN_DECLS
-
-size_t je_mallinfo_narenas();
-size_t je_mallinfo_nbins();
-struct mallinfo je_mallinfo_arena_info(size_t);
-struct mallinfo je_mallinfo_bin_info(size_t, size_t);
-
-__END_DECLS
-
int je_malloc_info(int options, FILE* fp) {
if (options != 0) {
errno = EINVAL;
diff --git a/libc/include/arpa/nameser.h b/libc/include/arpa/nameser.h
index 0e2b67e..97109ee 100644
--- a/libc/include/arpa/nameser.h
+++ b/libc/include/arpa/nameser.h
@@ -523,78 +523,30 @@
#if !defined(__LP64__)
/* Annoyingly, LP32 shipped with __ names. */
-#define ns_msg_getflag __ns_msg_getflag
-#define ns_get16 __ns_get16
-#define ns_get32 __ns_get32
-#define ns_put16 __ns_put16
-#define ns_put32 __ns_put32
-#define ns_initparse __ns_initparse
-#define ns_skiprr __ns_skiprr
-#define ns_parserr __ns_parserr
-#define ns_parserr2 __ns_parserr2
-#define ns_sprintrr __ns_sprintrr
-#define ns_sprintrrf __ns_sprintrrf
-#define ns_format_ttl __ns_format_ttl
-#define ns_parse_ttl __ns_parse_ttl
-#define ns_datetosecs __ns_datetosecs
-#define ns_name_ntol __ns_name_ntol
-#define ns_name_ntop __ns_name_ntop
-#define ns_name_pton __ns_name_pton
-#define ns_name_pton2 __ns_name_pton2
-#define ns_name_unpack __ns_name_unpack
-#define ns_name_unpack2 __ns_name_unpack2
-#define ns_name_pack __ns_name_pack
-#define ns_name_compress __ns_name_compress
-#define ns_name_uncompress __ns_name_uncompress
-#define ns_name_skip __ns_name_skip
-#define ns_name_rollback __ns_name_rollback
-#define ns_name_length __ns_name_length
-#define ns_name_eq __ns_name_eq
-#define ns_name_owned __ns_name_owned
-#define ns_name_map __ns_name_map
-#define ns_name_labels __ns_name_labels
-#define ns_sign __ns_sign
-#define ns_sign2 __ns_sign2
-#define ns_sign_tcp __ns_sign_tcp
-#define ns_sign_tcp2 __ns_sign_tcp2
-#define ns_sign_tcp_init __ns_sign_tcp_init
-#define ns_find_tsig __ns_find_tsig
-#define ns_verify __ns_verify
-#define ns_verify_tcp __ns_verify_tcp
-#define ns_verify_tcp_init __ns_verify_tcp_init
-#define ns_samedomain __ns_samedomain
-#define ns_subdomain __ns_subdomain
-#define ns_makecanon __ns_makecanon
-#define ns_samename __ns_samename
+#define ns_format_ttl __ns_format_ttl
+#define ns_get16 __ns_get16
+#define ns_get32 __ns_get32
+#define ns_initparse __ns_initparse
+#define ns_makecanon __ns_makecanon
+#define ns_msg_getflag __ns_msg_getflag
+#define ns_name_compress __ns_name_compress
+#define ns_name_ntol __ns_name_ntol
+#define ns_name_ntop __ns_name_ntop
+#define ns_name_pack __ns_name_pack
+#define ns_name_pton __ns_name_pton
+#define ns_name_rollback __ns_name_rollback
+#define ns_name_skip __ns_name_skip
+#define ns_name_uncompress __ns_name_uncompress
+#define ns_name_unpack __ns_name_unpack
+#define ns_parserr __ns_parserr
+#define ns_put16 __ns_put16
+#define ns_put32 __ns_put32
+#define ns_samename __ns_samename
+#define ns_skiprr __ns_skiprr
+#define ns_sprintrr __ns_sprintrr
+#define ns_sprintrrf __ns_sprintrrf
+#endif
-int ns_msg_getflag(ns_msg __handle, int __flag);
-uint16_t ns_get16(const u_char* _Nonnull __src);
-uint32_t ns_get32(const u_char* _Nonnull __src);
-void ns_put16(uint16_t __src, u_char* _Nonnull __dst);
-void ns_put32(uint32_t __src, u_char* _Nonnull __dst);
-int ns_initparse(const u_char* _Nonnull __msg, int __msg_size, ns_msg* _Nonnull __handle);
-int ns_skiprr(const u_char* _Nonnull __ptr, const u_char* _Nonnull __eom, ns_sect __section, int __count);
-int ns_parserr(ns_msg* _Nonnull __handle, ns_sect __section, int __rr_number, ns_rr* _Nonnull __rr);
-int ns_sprintrr(const ns_msg* _Nonnull __handle, const ns_rr* _Nonnull __rr, const char* _Nullable __name_ctx, const char* _Nullable __origin, char* _Nonnull __buf, size_t __buf_size);
-int ns_sprintrrf(const u_char* _Nonnull __msg, size_t __msg_size, const char* _Nonnull __name, ns_class __class, ns_type __type, u_long __ttl, const u_char* _Nonnull __rdata, size_t __rdata_size, const char* _Nullable __name_ctx, const char* _Nullable __origin, char* _Nonnull __buf, size_t __buf_size);
-int ns_format_ttl(u_long __ttl, char* _Nonnull __dst, size_t __dst_size);
-int ns_name_ntol(const u_char* _Nonnull __src, u_char* _Nonnull __dst, size_t __dst_size);
-int ns_name_ntop(const u_char* _Nonnull __src, char* _Nonnull __dst, size_t __dst_size);
-int ns_name_pton(const char* _Nonnull __src, u_char* _Nonnull __dst, size_t __dst_size);
-int ns_name_unpack(const u_char* _Nonnull __msg, const u_char* _Nonnull __eom, const u_char* _Nonnull __src, u_char* _Nonnull __dst, size_t __dst_size);
-int ns_name_pack(const u_char* _Nonnull __src, u_char* _Nonnull __dst, int __dst_size, const u_char* _Nullable * _Nullable __dn_ptrs, const u_char* _Nullable * _Nullable __last_dn_ptr);
-int ns_name_uncompress(const u_char* _Nonnull __msg, const u_char* _Nonnull __eom, const u_char* _Nonnull __src, char* _Nonnull __dst, size_t __dst_size);
-int ns_name_compress(const char* _Nonnull __src, u_char* _Nonnull __dst, size_t __dst_size, const u_char* _Nullable * _Nullable __dn_ptrs, const u_char* _Nullable * _Nullable __last_dn_ptr);
-int ns_name_skip(const u_char* _Nullable * _Nonnull __ptr_ptr, const u_char* _Nonnull __eom);
-void ns_name_rollback(const u_char* _Nonnull __src, const u_char* _Nullable * _Nonnull __dn_ptrs, const u_char* _Nullable * _Nonnull __last_dn_ptr);
-
-int ns_makecanon(const char* _Nonnull __src, char* _Nonnull __dst, size_t __dst_size);
-int ns_samename(const char* _Nonnull __lhs, const char* _Nonnull __rhs);
-
-#else
-/* The names of these symbols were accidentally prefixed with __ in L. */
-/* The duplication here is intentional to avoid declaring different symbols with the same
- * declaration. */
int ns_msg_getflag(ns_msg __handle, int __flag) __INTRODUCED_IN(22);
uint16_t ns_get16(const u_char* _Nonnull __src) __INTRODUCED_IN(22);
uint32_t ns_get32(const u_char* _Nonnull __src) __INTRODUCED_IN(22);
@@ -618,7 +570,6 @@
int ns_makecanon(const char* _Nonnull __src, char* _Nonnull __dst, size_t __dst_size) __INTRODUCED_IN(22);
int ns_samename(const char* _Nonnull __lhs, const char* _Nonnull __rhs) __INTRODUCED_IN(22);
-#endif /* !defined(__LP64__) */
__END_DECLS
diff --git a/libc/include/bits/lockf.h b/libc/include/bits/lockf.h
index 58ab031..ec6e53c 100644
--- a/libc/include/bits/lockf.h
+++ b/libc/include/bits/lockf.h
@@ -60,7 +60,7 @@
/**
* Like lockf() but allows using a 64-bit length
- * even from a 32-bit process without `__FILE_OFFSET_BITS=64`.
+ * even from a 32-bit process without `_FILE_OFFSET_BITS=64`.
*/
int lockf64(int __fd, int __cmd, off64_t __length) __INTRODUCED_IN(24);
diff --git a/libc/include/malloc.h b/libc/include/malloc.h
index c5d297b..6cd8509 100644
--- a/libc/include/malloc.h
+++ b/libc/include/malloc.h
@@ -318,6 +318,16 @@
};
/**
+ * mallopt() option to print human readable statistics about the memory
+ * allocator to the log. There is no format for this data, each allocator
+ * can use a different format, and the data that is printed can
+ * change at any time. This is expected to be used as a debugging aid.
+ *
+ * Available since API level 35.
+ */
+#define M_LOG_STATS (-205)
+
+/**
* [mallopt(3)](http://man7.org/linux/man-pages/man3/mallopt.3.html) modifies
* heap behavior. Values of `__option` are the `M_` constants from this header.
*
diff --git a/libc/include/sys/sendfile.h b/libc/include/sys/sendfile.h
index e1a34d2..a72091d 100644
--- a/libc/include/sys/sendfile.h
+++ b/libc/include/sys/sendfile.h
@@ -53,7 +53,7 @@
/**
* Like sendfile() but allows using a 64-bit offset
- * even from a 32-bit process without `__FILE_OFFSET_BITS=64`.
+ * even from a 32-bit process without `_FILE_OFFSET_BITS=64`.
*/
ssize_t sendfile64(int __out_fd, int __in_fd, off64_t* _Nullable __offset, size_t __count);
diff --git a/libc/libc.map.txt b/libc/libc.map.txt
index 17141dc..c69e609 100644
--- a/libc/libc.map.txt
+++ b/libc/libc.map.txt
@@ -74,28 +74,28 @@
__memrchr_chk; # introduced=23
__memset_chk; # introduced-arm=17 introduced-arm64=21 introduced-x86=17 introduced-x86_64=21
__mmap2; # arm x86
- __ns_format_ttl; # arm x86
- __ns_get16; # arm x86
- __ns_get32; # arm x86
- __ns_initparse; # arm x86
- __ns_makecanon; # arm x86
- __ns_msg_getflag; # arm x86
- __ns_name_compress; # arm x86
- __ns_name_ntol; # arm x86
- __ns_name_ntop; # arm x86
- __ns_name_pack; # arm x86
- __ns_name_pton; # arm x86
- __ns_name_rollback; # arm x86
- __ns_name_skip; # arm x86
- __ns_name_uncompress; # arm x86
- __ns_name_unpack; # arm x86
- __ns_parserr; # arm x86
- __ns_put16; # arm x86
- __ns_put32; # arm x86
- __ns_samename; # arm x86
- __ns_skiprr; # arm x86
- __ns_sprintrr; # arm x86
- __ns_sprintrrf; # arm x86
+ __ns_format_ttl; # arm x86 introduced=22
+ __ns_get16; # arm x86 introduced=22
+ __ns_get32; # arm x86 introduced=22
+ __ns_initparse; # arm x86 introduced=22
+ __ns_makecanon; # arm x86 introduced=22
+ __ns_msg_getflag; # arm x86 introduced=22
+ __ns_name_compress; # arm x86 introduced=22
+ __ns_name_ntol; # arm x86 introduced=22
+ __ns_name_ntop; # arm x86 introduced=22
+ __ns_name_pack; # arm x86 introduced=22
+ __ns_name_pton; # arm x86 introduced=22
+ __ns_name_rollback; # arm x86 introduced=22
+ __ns_name_skip; # arm x86 introduced=22
+ __ns_name_uncompress; # arm x86 introduced=22
+ __ns_name_unpack; # arm x86 introduced=22
+ __ns_parserr; # arm x86 introduced=22
+ __ns_put16; # arm x86 introduced=22
+ __ns_put32; # arm x86 introduced=22
+ __ns_samename; # arm x86 introduced=22
+ __ns_skiprr; # arm x86 introduced=22
+ __ns_sprintrr; # arm x86 introduced=22
+ __ns_sprintrrf; # arm x86 introduced=22
__open_2; # introduced-arm=17 introduced-arm64=21 introduced-x86=17 introduced-x86_64=21
__openat; # arm x86
__openat_2; # introduced-arm=17 introduced-arm64=21 introduced-x86=17 introduced-x86_64=21
diff --git a/tests/malloc_test.cpp b/tests/malloc_test.cpp
index 22905f4..5df694c 100644
--- a/tests/malloc_test.cpp
+++ b/tests/malloc_test.cpp
@@ -708,6 +708,15 @@
#endif
}
+TEST(malloc, mallopt_log_stats) {
+#if defined(__BIONIC__)
+ SKIP_WITH_HWASAN << "hwasan does not implement mallopt";
+ ASSERT_EQ(1, mallopt(M_LOG_STATS, 0));
+#else
+ GTEST_SKIP() << "bionic-only test";
+#endif
+}
+
// Verify that all of the mallopt values are unique.
TEST(malloc, mallopt_unique_params) {
#if defined(__BIONIC__)
@@ -722,6 +731,7 @@
std::make_pair(M_TSDS_COUNT_MAX, "M_TSDS_COUNT_MAX"),
std::make_pair(M_BIONIC_ZERO_INIT, "M_BIONIC_ZERO_INIT"),
std::make_pair(M_BIONIC_SET_HEAP_TAGGING_LEVEL, "M_BIONIC_SET_HEAP_TAGGING_LEVEL"),
+ std::make_pair(M_LOG_STATS, "M_LOG_STATS"),
};
std::unordered_map<int, std::string> all_params;