Merge "Add better free tracking."
diff --git a/libc/SYSCALLS.TXT b/libc/SYSCALLS.TXT
index 526b6d0..e045049 100644
--- a/libc/SYSCALLS.TXT
+++ b/libc/SYSCALLS.TXT
@@ -223,6 +223,7 @@
 int           timerfd_create(clockid_t, int)   all
 int           timerfd_settime(int, int, const struct itimerspec*, struct itimerspec*)   all
 int           timerfd_gettime(int, struct itimerspec*)   all
+int           adjtimex(struct timex*)   all
 
 # signals
 int     __sigaction:sigaction(int, const struct sigaction*, struct sigaction*)  arm,mips,x86
diff --git a/libc/arch-arm/syscalls/adjtimex.S b/libc/arch-arm/syscalls/adjtimex.S
new file mode 100644
index 0000000..614036e
--- /dev/null
+++ b/libc/arch-arm/syscalls/adjtimex.S
@@ -0,0 +1,14 @@
+/* Generated by gensyscalls.py. Do not edit. */
+
+#include <private/bionic_asm.h>
+
+ENTRY(adjtimex)
+    mov     ip, r7
+    ldr     r7, =__NR_adjtimex
+    swi     #0
+    mov     r7, ip
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno_internal
+END(adjtimex)
diff --git a/libc/arch-arm64/syscalls/adjtimex.S b/libc/arch-arm64/syscalls/adjtimex.S
new file mode 100644
index 0000000..712e468
--- /dev/null
+++ b/libc/arch-arm64/syscalls/adjtimex.S
@@ -0,0 +1,14 @@
+/* Generated by gensyscalls.py. Do not edit. */
+
+#include <private/bionic_asm.h>
+
+ENTRY(adjtimex)
+    mov     x8, __NR_adjtimex
+    svc     #0
+
+    cmn     x0, #(MAX_ERRNO + 1)
+    cneg    x0, x0, hi
+    b.hi    __set_errno_internal
+
+    ret
+END(adjtimex)
diff --git a/libc/arch-mips/syscalls/adjtimex.S b/libc/arch-mips/syscalls/adjtimex.S
new file mode 100644
index 0000000..fef215f
--- /dev/null
+++ b/libc/arch-mips/syscalls/adjtimex.S
@@ -0,0 +1,19 @@
+/* Generated by gensyscalls.py. Do not edit. */
+
+#include <private/bionic_asm.h>
+
+ENTRY(adjtimex)
+    .set noreorder
+    .cpload t9
+    li v0, __NR_adjtimex
+    syscall
+    bnez a3, 1f
+    move a0, v0
+    j ra
+    nop
+1:
+    la t9,__set_errno_internal
+    j t9
+    nop
+    .set reorder
+END(adjtimex)
diff --git a/libc/arch-mips64/syscalls/adjtimex.S b/libc/arch-mips64/syscalls/adjtimex.S
new file mode 100644
index 0000000..57b012c
--- /dev/null
+++ b/libc/arch-mips64/syscalls/adjtimex.S
@@ -0,0 +1,25 @@
+/* Generated by gensyscalls.py. Do not edit. */
+
+#include <private/bionic_asm.h>
+
+ENTRY(adjtimex)
+    .set push
+    .set noreorder
+    li v0, __NR_adjtimex
+    syscall
+    bnez a3, 1f
+    move a0, v0
+    j ra
+    nop
+1:
+    move t0, ra
+    bal     2f
+    nop
+2:
+    .cpsetup ra, t1, 2b
+    LA t9,__set_errno_internal
+    .cpreturn
+    j t9
+    move ra, t0
+    .set pop
+END(adjtimex)
diff --git a/libc/arch-x86/syscalls/adjtimex.S b/libc/arch-x86/syscalls/adjtimex.S
new file mode 100644
index 0000000..2a91f90
--- /dev/null
+++ b/libc/arch-x86/syscalls/adjtimex.S
@@ -0,0 +1,21 @@
+/* Generated by gensyscalls.py. Do not edit. */
+
+#include <private/bionic_asm.h>
+
+ENTRY(adjtimex)
+    pushl   %ebx
+    .cfi_def_cfa_offset 8
+    .cfi_rel_offset ebx, 0
+    mov     8(%esp), %ebx
+    movl    $__NR_adjtimex, %eax
+    int     $0x80
+    cmpl    $-MAX_ERRNO, %eax
+    jb      1f
+    negl    %eax
+    pushl   %eax
+    call    __set_errno_internal
+    addl    $4, %esp
+1:
+    popl    %ebx
+    ret
+END(adjtimex)
diff --git a/libc/arch-x86_64/syscalls/adjtimex.S b/libc/arch-x86_64/syscalls/adjtimex.S
new file mode 100644
index 0000000..292b9f3
--- /dev/null
+++ b/libc/arch-x86_64/syscalls/adjtimex.S
@@ -0,0 +1,15 @@
+/* Generated by gensyscalls.py. Do not edit. */
+
+#include <private/bionic_asm.h>
+
+ENTRY(adjtimex)
+    movl    $__NR_adjtimex, %eax
+    syscall
+    cmpq    $-MAX_ERRNO, %rax
+    jb      1f
+    negl    %eax
+    movl    %eax, %edi
+    call    __set_errno_internal
+1:
+    ret
+END(adjtimex)
diff --git a/libc/crt.mk b/libc/crt.mk
index 6365332..7b96bf2 100644
--- a/libc/crt.mk
+++ b/libc/crt.mk
@@ -40,7 +40,7 @@
 	$(hide) $(PRIVATE_CC) $(PRIVATE_CFLAGS) \
 		-MD -MF $(@:%.o=%.d) -o $@ -c $<
 	$(transform-d-to-p)
--include $(GEN:%.o=%.P)
+$(call include-depfile,$(GEN:%.o=%.P),$(GEN))
 
 # crtbegin_so.c -> crtbegin_so1.o
 GEN := $($(my_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_so1.o
@@ -51,7 +51,7 @@
 	$(hide) $(PRIVATE_CC) $(PRIVATE_CFLAGS) \
 		-MD -MF $(@:%.o=%.d) -o $@ -c $<
 	$(transform-d-to-p)
--include $(GEN:%.o=%.P)
+$(call include-depfile,$(GEN:%.o=%.P),$(GEN))
 
 # crtbegin_so1.o + crtbrand.o -> crtbegin_so.o
 GEN := $($(my_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_so.o
@@ -71,7 +71,7 @@
 	$(hide) $(PRIVATE_CC) $(PRIVATE_CFLAGS) \
 		-MD -MF $(@:%.o=%.d) -o $@ -c $<
 	$(transform-d-to-p)
--include $(GEN:%.o=%.P)
+$(call include-depfile,$(GEN:%.o=%.P),$(GEN))
 
 # crtbegin_so.o and crtend_so.o are installed to device
 GEN := $($(my_2nd_arch_prefix)TARGET_OUT_SHARED_LIBRARIES)/crtbegin_so.o
@@ -93,7 +93,7 @@
 	$(hide) $(PRIVATE_CC) $(PRIVATE_CFLAGS) \
 		-MD -MF $(@:%.o=%.d) -o $@ -c $<
 	$(transform-d-to-p)
--include $(GEN:%.o=%.P)
+$(call include-depfile,$(GEN:%.o=%.P),$(GEN))
 
 # crtbegin_static1.o + crtbrand.o -> crtbegin_static.o
 GEN := $($(my_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_static.o
@@ -113,7 +113,7 @@
 	$(hide) $(PRIVATE_CC) $(PRIVATE_CFLAGS) \
 		-MD -MF $(@:%.o=%.d) -o $@ -c $<
 	$(transform-d-to-p)
--include $(GEN:%.o=%.P)
+$(call include-depfile,$(GEN:%.o=%.P),$(GEN))
 
 # crtbegin_dynamic1.o + crtbrand.o -> crtbegin_dynamic.o
 GEN := $($(my_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_dynamic.o
@@ -135,7 +135,7 @@
 	$(hide) $(PRIVATE_CC) $(PRIVATE_CFLAGS) \
 		-MD -MF $(@:%.o=%.d) -o $@ -c $<
 	$(transform-d-to-p)
--include $(GEN:%.o=%.P)
+$(call include-depfile,$(GEN:%.o=%.P),$(GEN))
 
 # Clear temp vars
 my_libc_crt_target_ldflags :=
diff --git a/libc/include/sys/socket.h b/libc/include/sys/socket.h
index c0720b8..c7e9acc 100644
--- a/libc/include/sys/socket.h
+++ b/libc/include/sys/socket.h
@@ -164,7 +164,9 @@
 #define AF_IEEE802154 36
 #define AF_CAIF 37
 #define AF_ALG 38
-#define AF_MAX 39
+#define AF_NFC 39
+#define AF_VSOCK 40
+#define AF_MAX 41
 
 #define PF_UNSPEC AF_UNSPEC
 #define PF_UNIX AF_UNIX
@@ -205,6 +207,8 @@
 #define PF_IEEE802154 AF_IEEE802154
 #define PF_CAIF AF_CAIF
 #define PF_ALG AF_ALG
+#define PF_NFC AF_NFC
+#define PF_VSOCK AF_VSOCK
 #define PF_MAX AF_MAX
 
 #define SOMAXCONN 128
diff --git a/libc/include/sys/timex.h b/libc/include/sys/timex.h
index 4096e7d..6138ac4 100644
--- a/libc/include/sys/timex.h
+++ b/libc/include/sys/timex.h
@@ -29,6 +29,13 @@
 #ifndef _SYS_TIMEX_H_
 #define _SYS_TIMEX_H_
 
+#include <sys/cdefs.h>
 #include <linux/timex.h>
 
+__BEGIN_DECLS
+
+extern int adjtimex(struct timex *buf);
+
+__END_DECLS
+
 #endif /* _SYS_TIMEX_H_ */