Merge "Add check for pthread_self() when looking up a thread"
diff --git a/libc/Android.mk b/libc/Android.mk
index 683dfa9..d94dce2 100644
--- a/libc/Android.mk
+++ b/libc/Android.mk
@@ -39,7 +39,6 @@
# Define the common source files for all the libc instances
# =========================================================
libc_common_src_files := \
- bionic/bindresvport.c \
bionic/ether_aton.c \
bionic/ether_ntoa.c \
bionic/fts.c \
@@ -173,6 +172,7 @@
bionic/mremap.cpp \
bionic/NetdClientDispatch.cpp \
bionic/net_if.cpp \
+ bionic/netinet_in.cpp \
bionic/open.cpp \
bionic/pathconf.cpp \
bionic/pause.cpp \
diff --git a/libc/SYSCALLS.TXT b/libc/SYSCALLS.TXT
index e045049..d5dd206 100644
--- a/libc/SYSCALLS.TXT
+++ b/libc/SYSCALLS.TXT
@@ -224,6 +224,7 @@
int timerfd_settime(int, int, const struct itimerspec*, struct itimerspec*) all
int timerfd_gettime(int, struct itimerspec*) all
int adjtimex(struct timex*) all
+int clock_adjtime(clockid_t, struct timex*) all
# signals
int __sigaction:sigaction(int, const struct sigaction*, struct sigaction*) arm,mips,x86
diff --git a/libc/arch-arm/syscalls/clock_adjtime.S b/libc/arch-arm/syscalls/clock_adjtime.S
new file mode 100644
index 0000000..fa778e1
--- /dev/null
+++ b/libc/arch-arm/syscalls/clock_adjtime.S
@@ -0,0 +1,14 @@
+/* Generated by gensyscalls.py. Do not edit. */
+
+#include <private/bionic_asm.h>
+
+ENTRY(clock_adjtime)
+ mov ip, r7
+ ldr r7, =__NR_clock_adjtime
+ swi #0
+ mov r7, ip
+ cmn r0, #(MAX_ERRNO + 1)
+ bxls lr
+ neg r0, r0
+ b __set_errno_internal
+END(clock_adjtime)
diff --git a/libc/arch-arm64/syscalls/clock_adjtime.S b/libc/arch-arm64/syscalls/clock_adjtime.S
new file mode 100644
index 0000000..c2c191e
--- /dev/null
+++ b/libc/arch-arm64/syscalls/clock_adjtime.S
@@ -0,0 +1,14 @@
+/* Generated by gensyscalls.py. Do not edit. */
+
+#include <private/bionic_asm.h>
+
+ENTRY(clock_adjtime)
+ mov x8, __NR_clock_adjtime
+ svc #0
+
+ cmn x0, #(MAX_ERRNO + 1)
+ cneg x0, x0, hi
+ b.hi __set_errno_internal
+
+ ret
+END(clock_adjtime)
diff --git a/libc/arch-mips/syscalls/clock_adjtime.S b/libc/arch-mips/syscalls/clock_adjtime.S
new file mode 100644
index 0000000..f8a4ce2
--- /dev/null
+++ b/libc/arch-mips/syscalls/clock_adjtime.S
@@ -0,0 +1,19 @@
+/* Generated by gensyscalls.py. Do not edit. */
+
+#include <private/bionic_asm.h>
+
+ENTRY(clock_adjtime)
+ .set noreorder
+ .cpload t9
+ li v0, __NR_clock_adjtime
+ syscall
+ bnez a3, 1f
+ move a0, v0
+ j ra
+ nop
+1:
+ la t9,__set_errno_internal
+ j t9
+ nop
+ .set reorder
+END(clock_adjtime)
diff --git a/libc/arch-mips64/syscalls/clock_adjtime.S b/libc/arch-mips64/syscalls/clock_adjtime.S
new file mode 100644
index 0000000..206e9fd
--- /dev/null
+++ b/libc/arch-mips64/syscalls/clock_adjtime.S
@@ -0,0 +1,25 @@
+/* Generated by gensyscalls.py. Do not edit. */
+
+#include <private/bionic_asm.h>
+
+ENTRY(clock_adjtime)
+ .set push
+ .set noreorder
+ li v0, __NR_clock_adjtime
+ 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(clock_adjtime)
diff --git a/libc/arch-x86/syscalls/clock_adjtime.S b/libc/arch-x86/syscalls/clock_adjtime.S
new file mode 100644
index 0000000..b6e0ac4
--- /dev/null
+++ b/libc/arch-x86/syscalls/clock_adjtime.S
@@ -0,0 +1,26 @@
+/* Generated by gensyscalls.py. Do not edit. */
+
+#include <private/bionic_asm.h>
+
+ENTRY(clock_adjtime)
+ pushl %ebx
+ .cfi_def_cfa_offset 8
+ .cfi_rel_offset ebx, 0
+ pushl %ecx
+ .cfi_adjust_cfa_offset 4
+ .cfi_rel_offset ecx, 0
+ mov 12(%esp), %ebx
+ mov 16(%esp), %ecx
+ movl $__NR_clock_adjtime, %eax
+ int $0x80
+ cmpl $-MAX_ERRNO, %eax
+ jb 1f
+ negl %eax
+ pushl %eax
+ call __set_errno_internal
+ addl $4, %esp
+1:
+ popl %ecx
+ popl %ebx
+ ret
+END(clock_adjtime)
diff --git a/libc/arch-x86_64/syscalls/clock_adjtime.S b/libc/arch-x86_64/syscalls/clock_adjtime.S
new file mode 100644
index 0000000..0601930
--- /dev/null
+++ b/libc/arch-x86_64/syscalls/clock_adjtime.S
@@ -0,0 +1,15 @@
+/* Generated by gensyscalls.py. Do not edit. */
+
+#include <private/bionic_asm.h>
+
+ENTRY(clock_adjtime)
+ movl $__NR_clock_adjtime, %eax
+ syscall
+ cmpq $-MAX_ERRNO, %rax
+ jb 1f
+ negl %eax
+ movl %eax, %edi
+ call __set_errno_internal
+1:
+ ret
+END(clock_adjtime)
diff --git a/libc/bionic/bindresvport.c b/libc/bionic/netinet_in.cpp
similarity index 63%
rename from libc/bionic/bindresvport.c
rename to libc/bionic/netinet_in.cpp
index 5d9ad2b..dfa5d8d 100644
--- a/libc/bionic/bindresvport.c
+++ b/libc/bionic/netinet_in.cpp
@@ -25,48 +25,46 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
+
+#include <netinet/in.h>
+
#include <errno.h>
#include <sys/types.h>
#include <sys/socket.h>
-#include <netinet/in.h>
#include <string.h>
#include <unistd.h>
-#define START_PORT 600
-#define END_PORT IPPORT_RESERVED
-#define NUM_PORTS (END_PORT - START_PORT)
+constexpr int START_PORT = 600;
+constexpr int END_PORT = IPPORT_RESERVED;
+constexpr int NUM_PORTS = (END_PORT - START_PORT);
-int bindresvport(int sd, struct sockaddr_in *sin)
-{
- static short port;
- struct sockaddr_in sin0;
- int nn, ret;
+int bindresvport(int sd, struct sockaddr_in* sin) {
+ sockaddr_in sin0;
+ if (sin == nullptr) {
+ memset(&sin0, 0, sizeof(sin0));
+ sin = &sin0;
+ sin->sin_family = AF_INET;
+ }
- if (sin == NULL) {
- sin = &sin0;
- memset( sin, 0, sizeof *sin );
- sin->sin_family = AF_INET;
- } else if (sin->sin_family != AF_INET) {
- errno = EPFNOSUPPORT;
- return -1;
- }
+ if (sin->sin_family != AF_INET) {
+ errno = EPFNOSUPPORT;
+ return -1;
+ }
- if (port == 0) {
- port = START_PORT + (getpid() % NUM_PORTS);
- }
+ // TODO: thread safety!
+ static short port;
+ if (port == 0) {
+ port = START_PORT + (getpid() % NUM_PORTS);
+ }
- for (nn = NUM_PORTS; nn > 0; nn--, port++)
- {
- if (port == END_PORT)
- port = START_PORT;
-
- sin->sin_port = htons(port);
- do {
- ret = bind(sd, (struct sockaddr*)sin, sizeof(*sin));
- } while (ret < 0 && errno == EINTR);
-
- if (!ret)
- break;
- }
- return ret;
+ for (size_t i = NUM_PORTS; i > 0; i--, port++) {
+ if (port == END_PORT) port = START_PORT;
+ sin->sin_port = htons(port);
+ int rc = TEMP_FAILURE_RETRY(bind(sd, reinterpret_cast<sockaddr*>(sin), sizeof(*sin)));
+ if (rc >= 0) return rc;
+ }
+ return -1;
}
+
+const in6_addr in6addr_any = IN6ADDR_ANY_INIT;
+const in6_addr in6addr_loopback = IN6ADDR_LOOPBACK_INIT;
diff --git a/libc/bionic/tmpfile.cpp b/libc/bionic/tmpfile.cpp
index 602d407..dc142a9 100644
--- a/libc/bionic/tmpfile.cpp
+++ b/libc/bionic/tmpfile.cpp
@@ -112,3 +112,4 @@
}
return fp;
}
+__strong_alias(tmpfile64, tmpfile);
diff --git a/libc/include/netinet/in.h b/libc/include/netinet/in.h
index 44c7fc1..5f3d11f 100644
--- a/libc/include/netinet/in.h
+++ b/libc/include/netinet/in.h
@@ -47,10 +47,10 @@
typedef uint16_t in_port_t;
typedef uint32_t in_addr_t;
-extern int bindresvport (int sd, struct sockaddr_in *sin);
+int bindresvport(int, struct sockaddr_in*);
-static const struct in6_addr in6addr_any = IN6ADDR_ANY_INIT;
-static const struct in6_addr in6addr_loopback = IN6ADDR_LOOPBACK_INIT;
+extern const struct in6_addr in6addr_any;
+extern const struct in6_addr in6addr_loopback;
__END_DECLS
diff --git a/libc/include/stdio.h b/libc/include/stdio.h
index b618091..623995b 100644
--- a/libc/include/stdio.h
+++ b/libc/include/stdio.h
@@ -109,14 +109,11 @@
int fflush(FILE *);
int fgetc(FILE *);
char *fgets(char * __restrict, int, FILE * __restrict);
-FILE *fopen(const char * __restrict , const char * __restrict);
int fprintf(FILE * __restrict , const char * __restrict, ...)
__printflike(2, 3);
int fputc(int, FILE *);
int fputs(const char * __restrict, FILE * __restrict);
size_t fread(void * __restrict, size_t, size_t, FILE * __restrict);
-FILE *freopen(const char * __restrict, const char * __restrict,
- FILE * __restrict);
int fscanf(FILE * __restrict, const char * __restrict, ...)
__scanflike(2, 3);
size_t fwrite(const void * __restrict, size_t, size_t, FILE * __restrict);
@@ -140,7 +137,6 @@
int setvbuf(FILE * __restrict, char * __restrict, int, size_t);
int sscanf(const char * __restrict, const char * __restrict, ...)
__scanflike(2, 3);
-FILE *tmpfile(void);
int ungetc(int, FILE *);
int vfprintf(FILE * __restrict, const char * __restrict, __va_list)
__printflike(2, 0);
@@ -208,6 +204,13 @@
int (*)(void*));
#endif
+FILE* fopen(const char* __restrict, const char* __restrict);
+FILE* fopen64(const char* __restrict, const char* __restrict);
+FILE* freopen(const char* __restrict, const char* __restrict, FILE* __restrict);
+FILE* freopen64(const char* __restrict, const char* __restrict, FILE* __restrict);
+FILE* tmpfile(void);
+FILE* tmpfile64(void);
+
#if __ISO_C_VISIBLE >= 1999 || __BSD_VISIBLE
int snprintf(char * __restrict, size_t, const char * __restrict, ...)
__printflike(3, 4);
diff --git a/libc/include/sys/timex.h b/libc/include/sys/timex.h
index 6138ac4..fade5c3 100644
--- a/libc/include/sys/timex.h
+++ b/libc/include/sys/timex.h
@@ -30,11 +30,13 @@
#define _SYS_TIMEX_H_
#include <sys/cdefs.h>
+#include <sys/types.h>
#include <linux/timex.h>
__BEGIN_DECLS
-extern int adjtimex(struct timex *buf);
+int adjtimex(struct timex*);
+int clock_adjtime(clockid_t, struct timex*);
__END_DECLS
diff --git a/libc/libc.arm.brillo.map b/libc/libc.arm.brillo.map
index 84cd9d1..80a88bd 100644
--- a/libc/libc.arm.brillo.map
+++ b/libc/libc.arm.brillo.map
@@ -1224,9 +1224,13 @@
__pwrite_chk;
__pwrite64_chk;
__write_chk;
+ adjtimex;
+ clock_adjtime;
fgetpos64;
fileno_unlocked;
+ fopen64;
freeifaddrs;
+ freopen64;
fseeko64;
fsetpos64;
ftello64;
@@ -1236,6 +1240,8 @@
getifaddrs;
if_freenameindex;
if_nameindex;
+ in6addr_any;
+ in6addr_loopback;
lockf;
lockf64;
preadv;
@@ -1258,6 +1264,7 @@
scandirat;
scandirat64;
strchrnul;
+ tmpfile64;
} LIBC;
LIBC_PRIVATE {
diff --git a/libc/libc.arm.map b/libc/libc.arm.map
index 001476e..18e51d4 100644
--- a/libc/libc.arm.map
+++ b/libc/libc.arm.map
@@ -1224,9 +1224,13 @@
__pwrite_chk;
__pwrite64_chk;
__write_chk;
+ adjtimex;
+ clock_adjtime;
fgetpos64;
fileno_unlocked;
+ fopen64;
freeifaddrs;
+ freopen64;
fseeko64;
fsetpos64;
ftello64;
@@ -1236,6 +1240,8 @@
getifaddrs;
if_freenameindex;
if_nameindex;
+ in6addr_any;
+ in6addr_loopback;
lockf;
lockf64;
preadv;
@@ -1258,6 +1264,7 @@
scandirat;
scandirat64;
strchrnul;
+ tmpfile64;
} LIBC;
LIBC_PRIVATE {
diff --git a/libc/libc.arm64.map b/libc/libc.arm64.map
index 14f90ad..e1ccd4e 100644
--- a/libc/libc.arm64.map
+++ b/libc/libc.arm64.map
@@ -1147,9 +1147,13 @@
__pwrite_chk;
__pwrite64_chk;
__write_chk;
+ adjtimex;
+ clock_adjtime;
fgetpos64;
fileno_unlocked;
+ fopen64;
freeifaddrs;
+ freopen64;
fseeko64;
fsetpos64;
ftello64;
@@ -1159,6 +1163,8 @@
getifaddrs;
if_freenameindex;
if_nameindex;
+ in6addr_any;
+ in6addr_loopback;
lockf;
lockf64;
preadv;
@@ -1180,6 +1186,7 @@
scandirat;
scandirat64;
strchrnul;
+ tmpfile64;
} LIBC;
LIBC_PRIVATE {
diff --git a/libc/libc.map.txt b/libc/libc.map.txt
index e2aede5..b87a5e3 100644
--- a/libc/libc.map.txt
+++ b/libc/libc.map.txt
@@ -1250,9 +1250,13 @@
__pwrite_chk;
__pwrite64_chk;
__write_chk;
+ adjtimex;
+ clock_adjtime;
fgetpos64;
fileno_unlocked;
+ fopen64;
freeifaddrs;
+ freopen64;
fseeko64;
fsetpos64;
ftello64;
@@ -1262,6 +1266,8 @@
getifaddrs;
if_freenameindex;
if_nameindex;
+ in6addr_any;
+ in6addr_loopback;
lockf;
lockf64;
preadv;
@@ -1284,6 +1290,7 @@
scandirat;
scandirat64;
strchrnul;
+ tmpfile64;
} LIBC;
LIBC_PRIVATE {
diff --git a/libc/libc.mips.brillo.map b/libc/libc.mips.brillo.map
index ee33d0e..57dfd50 100644
--- a/libc/libc.mips.brillo.map
+++ b/libc/libc.mips.brillo.map
@@ -1208,9 +1208,13 @@
__pwrite_chk;
__pwrite64_chk;
__write_chk;
+ adjtimex;
+ clock_adjtime;
fgetpos64;
fileno_unlocked;
+ fopen64;
freeifaddrs;
+ freopen64;
fseeko64;
fsetpos64;
ftello64;
@@ -1220,6 +1224,8 @@
getifaddrs;
if_freenameindex;
if_nameindex;
+ in6addr_any;
+ in6addr_loopback;
lockf;
lockf64;
preadv;
@@ -1242,6 +1248,7 @@
scandirat;
scandirat64;
strchrnul;
+ tmpfile64;
} LIBC;
LIBC_PRIVATE {
diff --git a/libc/libc.mips.map b/libc/libc.mips.map
index c658460..ed72fd4 100644
--- a/libc/libc.mips.map
+++ b/libc/libc.mips.map
@@ -1208,9 +1208,13 @@
__pwrite_chk;
__pwrite64_chk;
__write_chk;
+ adjtimex;
+ clock_adjtime;
fgetpos64;
fileno_unlocked;
+ fopen64;
freeifaddrs;
+ freopen64;
fseeko64;
fsetpos64;
ftello64;
@@ -1220,6 +1224,8 @@
getifaddrs;
if_freenameindex;
if_nameindex;
+ in6addr_any;
+ in6addr_loopback;
lockf;
lockf64;
preadv;
@@ -1242,6 +1248,7 @@
scandirat;
scandirat64;
strchrnul;
+ tmpfile64;
} LIBC;
LIBC_PRIVATE {
diff --git a/libc/libc.mips64.map b/libc/libc.mips64.map
index 14f90ad..e1ccd4e 100644
--- a/libc/libc.mips64.map
+++ b/libc/libc.mips64.map
@@ -1147,9 +1147,13 @@
__pwrite_chk;
__pwrite64_chk;
__write_chk;
+ adjtimex;
+ clock_adjtime;
fgetpos64;
fileno_unlocked;
+ fopen64;
freeifaddrs;
+ freopen64;
fseeko64;
fsetpos64;
ftello64;
@@ -1159,6 +1163,8 @@
getifaddrs;
if_freenameindex;
if_nameindex;
+ in6addr_any;
+ in6addr_loopback;
lockf;
lockf64;
preadv;
@@ -1180,6 +1186,7 @@
scandirat;
scandirat64;
strchrnul;
+ tmpfile64;
} LIBC;
LIBC_PRIVATE {
diff --git a/libc/libc.x86.brillo.map b/libc/libc.x86.brillo.map
index a72fa61..3dcf1ea 100644
--- a/libc/libc.x86.brillo.map
+++ b/libc/libc.x86.brillo.map
@@ -1207,9 +1207,13 @@
__pwrite_chk;
__pwrite64_chk;
__write_chk;
+ adjtimex;
+ clock_adjtime;
fgetpos64;
fileno_unlocked;
+ fopen64;
freeifaddrs;
+ freopen64;
fseeko64;
fsetpos64;
ftello64;
@@ -1219,6 +1223,8 @@
getifaddrs;
if_freenameindex;
if_nameindex;
+ in6addr_any;
+ in6addr_loopback;
lockf;
lockf64;
preadv;
@@ -1241,6 +1247,7 @@
scandirat;
scandirat64;
strchrnul;
+ tmpfile64;
} LIBC;
LIBC_PRIVATE {
diff --git a/libc/libc.x86.map b/libc/libc.x86.map
index 5a7a504..1e44e2a 100644
--- a/libc/libc.x86.map
+++ b/libc/libc.x86.map
@@ -1207,9 +1207,13 @@
__pwrite_chk;
__pwrite64_chk;
__write_chk;
+ adjtimex;
+ clock_adjtime;
fgetpos64;
fileno_unlocked;
+ fopen64;
freeifaddrs;
+ freopen64;
fseeko64;
fsetpos64;
ftello64;
@@ -1219,6 +1223,8 @@
getifaddrs;
if_freenameindex;
if_nameindex;
+ in6addr_any;
+ in6addr_loopback;
lockf;
lockf64;
preadv;
@@ -1241,6 +1247,7 @@
scandirat;
scandirat64;
strchrnul;
+ tmpfile64;
} LIBC;
LIBC_PRIVATE {
diff --git a/libc/libc.x86_64.map b/libc/libc.x86_64.map
index 14f90ad..e1ccd4e 100644
--- a/libc/libc.x86_64.map
+++ b/libc/libc.x86_64.map
@@ -1147,9 +1147,13 @@
__pwrite_chk;
__pwrite64_chk;
__write_chk;
+ adjtimex;
+ clock_adjtime;
fgetpos64;
fileno_unlocked;
+ fopen64;
freeifaddrs;
+ freopen64;
fseeko64;
fsetpos64;
ftello64;
@@ -1159,6 +1163,8 @@
getifaddrs;
if_freenameindex;
if_nameindex;
+ in6addr_any;
+ in6addr_loopback;
lockf;
lockf64;
preadv;
@@ -1180,6 +1186,7 @@
scandirat;
scandirat64;
strchrnul;
+ tmpfile64;
} LIBC;
LIBC_PRIVATE {
diff --git a/libc/stdio/stdio.cpp b/libc/stdio/stdio.cpp
index 16cbd55..1c31a27 100644
--- a/libc/stdio/stdio.cpp
+++ b/libc/stdio/stdio.cpp
@@ -222,6 +222,7 @@
return fp;
}
+__strong_alias(fopen64, fopen);
FILE* fdopen(int fd, const char* mode) {
int oflags;
@@ -358,6 +359,7 @@
if (oflags & O_APPEND) __sseek64(fp, 0, SEEK_END);
return fp;
}
+__strong_alias(freopen64, freopen);
int fclose(FILE* fp) {
if (fp->_flags == 0) {
diff --git a/libc/tools/check-symbols-glibc.py b/libc/tools/check-symbols-glibc.py
index 27b92c4..c5dbdcf 100755
--- a/libc/tools/check-symbols-glibc.py
+++ b/libc/tools/check-symbols-glibc.py
@@ -79,6 +79,7 @@
'fgetln',
'fpurge',
'funopen',
+ 'funopen64',
'gamma_r',
'gammaf_r',
'getprogname',
diff --git a/linker/linker.cpp b/linker/linker.cpp
index 1c1650e..a032068 100644
--- a/linker/linker.cpp
+++ b/linker/linker.cpp
@@ -129,26 +129,26 @@
static const char* const kDefaultLdPaths[] = {
#if defined(__LP64__)
- "/vendor/lib64",
"/system/lib64",
+ "/vendor/lib64",
#else
- "/vendor/lib",
"/system/lib",
+ "/vendor/lib",
#endif
nullptr
};
static const char* const kAsanDefaultLdPaths[] = {
#if defined(__LP64__)
- "/data/vendor/lib64",
- "/vendor/lib64",
"/data/lib64",
"/system/lib64",
+ "/data/vendor/lib64",
+ "/vendor/lib64",
#else
- "/data/vendor/lib",
- "/vendor/lib",
"/data/lib",
"/system/lib",
+ "/data/vendor/lib",
+ "/vendor/lib",
#endif
nullptr
};
diff --git a/tests/Android.mk b/tests/Android.mk
index fb3c254..0db63d9 100644
--- a/tests/Android.mk
+++ b/tests/Android.mk
@@ -65,8 +65,9 @@
malloc_test.cpp \
math_test.cpp \
mntent_test.cpp \
- net_if_test.cpp \
netdb_test.cpp \
+ net_if_test.cpp \
+ netinet_in_test.cpp \
netinet_udp_test.cpp \
pthread_test.cpp \
pty_test.cpp \
@@ -106,6 +107,7 @@
sys_sysinfo_test.cpp \
sys_sysmacros_test.cpp \
sys_time_test.cpp \
+ sys_timex_test.cpp \
sys_types_test.cpp \
sys_uio_test.cpp \
sys_vfs_test.cpp \
diff --git a/tests/netinet_in_test.cpp b/tests/netinet_in_test.cpp
new file mode 100644
index 0000000..a337770
--- /dev/null
+++ b/tests/netinet_in_test.cpp
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <netinet/in.h>
+
+#include <errno.h>
+
+#include <gtest/gtest.h>
+
+TEST(netinet_in, bindresvport) {
+ // This isn't something we can usually test, so just check the symbol's there.
+ ASSERT_EQ(-1, bindresvport(-1, nullptr));
+}
+
+TEST(netinet_in, in6addr_any) {
+ in6_addr any = IN6ADDR_ANY_INIT;
+ ASSERT_EQ(0, memcmp(&any, &in6addr_any, sizeof(in6addr_any)));
+}
+
+TEST(netinet_in, in6addr_loopback) {
+ in6_addr loopback = IN6ADDR_LOOPBACK_INIT;
+ ASSERT_EQ(0, memcmp(&loopback, &in6addr_loopback, sizeof(in6addr_loopback)));
+}
diff --git a/tests/stdio_test.cpp b/tests/stdio_test.cpp
index 0d21dec..2912be4 100644
--- a/tests/stdio_test.cpp
+++ b/tests/stdio_test.cpp
@@ -79,6 +79,12 @@
fclose(fp);
}
+TEST(STDIO_TEST, tmpfile64) {
+ FILE* fp = tmpfile64();
+ ASSERT_TRUE(fp != nullptr);
+ fclose(fp);
+}
+
TEST(STDIO_TEST, dprintf) {
TemporaryFile tf;
@@ -875,6 +881,14 @@
fclose(fp);
}
+TEST(STDIO_TEST, fopen64_freopen64) {
+ FILE* fp = fopen64("/proc/version", "r");
+ ASSERT_TRUE(fp != nullptr);
+ fp = freopen64("/proc/version", "re", fp);
+ ASSERT_TRUE(fp != nullptr);
+ fclose(fp);
+}
+
// https://code.google.com/p/android/issues/detail?id=81155
// http://b/18556607
TEST(STDIO_TEST, fread_unbuffered_pathological_performance) {
diff --git a/tests/sys_timex_test.cpp b/tests/sys_timex_test.cpp
new file mode 100644
index 0000000..1340ea4
--- /dev/null
+++ b/tests/sys_timex_test.cpp
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <sys/timex.h>
+
+#include <errno.h>
+
+#include <gtest/gtest.h>
+
+TEST(sys_timex, adjtimex_smoke) {
+ timex t;
+ memset(&t, 0, sizeof(t));
+ // adjtimex/clock_adjtime return the clock state on success, -1 on failure.
+ ASSERT_NE(-1, adjtimex(&t));
+}
+
+TEST(sys_timex, adjtimex_EFAULT) {
+ errno = 0;
+ ASSERT_EQ(-1, adjtimex(nullptr));
+ ASSERT_EQ(EFAULT, errno);
+}
+
+TEST(sys_timex, clock_adjtime_smoke) {
+ timex t;
+ memset(&t, 0, sizeof(t));
+ // adjtimex/clock_adjtime return the clock state on success, -1 on failure.
+ ASSERT_NE(-1, clock_adjtime(CLOCK_REALTIME, &t));
+}
+
+TEST(sys_timex, clock_adjtime_EFAULT) {
+ errno = 0;
+ ASSERT_EQ(-1, clock_adjtime(CLOCK_REALTIME, nullptr));
+ ASSERT_EQ(EFAULT, errno);
+}