Merge "Make inline tcsetattr definition match constants."
diff --git a/libc/NOTICE b/libc/NOTICE
index 82df90a..c74811c 100644
--- a/libc/NOTICE
+++ b/libc/NOTICE
@@ -1267,35 +1267,6 @@
-------------------------------------------------------------------
-Copyright (c) 1983, 1993
- The Regents of the University of California. All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-4. Neither the name of the University nor the names of its contributors
- may be used to endorse or promote products derived from this software
- without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGE.
-
--------------------------------------------------------------------
-
Copyright (c) 1985
The Regents of the University of California. All rights reserved.
diff --git a/libc/include/android/legacy_strings_inlines.h b/libc/include/android/legacy_strings_inlines.h
new file mode 100644
index 0000000..6679c30
--- /dev/null
+++ b/libc/include/android/legacy_strings_inlines.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _ANDROID_LEGACY_STRINGS_INLINES_H_
+#define _ANDROID_LEGACY_STRINGS_INLINES_H_
+
+#include <strings.h>
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+
+#if defined(__i386__) && __ANDROID_API__ < __ANDROID_API_J_MR2__
+/* Everyone except x86 had ffs since the beginning. */
+static __inline int ffs(int __n) { return __builtin_ffs(__n); }
+#endif
+
+__END_DECLS
+
+#endif
diff --git a/libc/include/arpa/ftp.h b/libc/include/arpa/ftp.h
new file mode 100644
index 0000000..081c037
--- /dev/null
+++ b/libc/include/arpa/ftp.h
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 1983, 1989, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)ftp.h 8.1 (Berkeley) 6/2/93
+ *
+ * $FreeBSD$
+ */
+
+#ifndef _ARPA_FTP_H_
+#define _ARPA_FTP_H_
+
+/* Definitions for FTP; see RFC-765. */
+
+/*
+ * Reply codes.
+ */
+#define PRELIM 1 /* positive preliminary */
+#define COMPLETE 2 /* positive completion */
+#define CONTINUE 3 /* positive intermediate */
+#define TRANSIENT 4 /* transient negative completion */
+#define ERROR 5 /* permanent negative completion */
+
+/*
+ * Type codes
+ */
+#define TYPE_A 1 /* ASCII */
+#define TYPE_E 2 /* EBCDIC */
+#define TYPE_I 3 /* image */
+#define TYPE_L 4 /* local byte size */
+
+#ifdef FTP_NAMES
+char *typenames[] = {"0", "ASCII", "EBCDIC", "Image", "Local" };
+#endif
+
+/*
+ * Form codes
+ */
+#define FORM_N 1 /* non-print */
+#define FORM_T 2 /* telnet format effectors */
+#define FORM_C 3 /* carriage control (ASA) */
+#ifdef FTP_NAMES
+char *formnames[] = {"0", "Nonprint", "Telnet", "Carriage-control" };
+#endif
+
+/*
+ * Structure codes
+ */
+#define STRU_F 1 /* file (no record structure) */
+#define STRU_R 2 /* record structure */
+#define STRU_P 3 /* page structure */
+#ifdef FTP_NAMES
+char *strunames[] = {"0", "File", "Record", "Page" };
+#endif
+
+/*
+ * Mode types
+ */
+#define MODE_S 1 /* stream */
+#define MODE_B 2 /* block */
+#define MODE_C 3 /* compressed */
+#ifdef FTP_NAMES
+char *modenames[] = {"0", "Stream", "Block", "Compressed" };
+#endif
+
+/*
+ * Record Tokens
+ */
+#define REC_ESC '\377' /* Record-mode Escape */
+#define REC_EOR '\001' /* Record-mode End-of-Record */
+#define REC_EOF '\002' /* Record-mode End-of-File */
+
+/*
+ * Block Header
+ */
+#define BLK_EOR 0x80 /* Block is End-of-Record */
+#define BLK_EOF 0x40 /* Block is End-of-File */
+#define BLK_ERRORS 0x20 /* Block is suspected of containing errors */
+#define BLK_RESTART 0x10 /* Block is Restart Marker */
+
+#define BLK_BYTECOUNT 2 /* Bytes in this block */
+
+#endif /* !_FTP_H_ */
diff --git a/libc/include/arpa/telnet.h b/libc/include/arpa/telnet.h
index 594dc7a..758e9b8 100644
--- a/libc/include/arpa/telnet.h
+++ b/libc/include/arpa/telnet.h
@@ -10,7 +10,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -27,12 +27,11 @@
* SUCH DAMAGE.
*
* @(#)telnet.h 8.2 (Berkeley) 12/15/93
+ * $FreeBSD$
*/
-#ifndef _ARPA_TELNET_H
-#define _ARPA_TELNET_H 1
-
-#include <sys/cdefs.h>
+#ifndef _ARPA_TELNET_H_
+#define _ARPA_TELNET_H_
/*
* Definitions for the TELNET protocol.
@@ -61,11 +60,14 @@
#define SYNCH 242 /* for telfunc calls */
#ifdef TELCMDS
-char *telcmds[] = {
+const char *telcmds[] = {
"EOF", "SUSP", "ABORT", "EOR",
"SE", "NOP", "DMARK", "BRK", "IP", "AO", "AYT", "EC",
- "EL", "GA", "SB", "WILL", "WONT", "DO", "DONT", "IAC", 0,
+ "EL", "GA", "SB", "WILL", "WONT", "DO", "DONT", "IAC",
+ 0
};
+#else
+extern char *telcmds[];
#endif
#define TELCMD_FIRST xEOF
@@ -92,7 +94,7 @@
#define TELOPT_NAOVTS 14 /* negotiate about vertical tab stops */
#define TELOPT_NAOVTD 15 /* negotiate about vertical tab disposition */
#define TELOPT_NAOLFD 16 /* negotiate about output LF disposition */
-#define TELOPT_XASCII 17 /* extended ascii character set */
+#define TELOPT_XASCII 17 /* extended ascic character set */
#define TELOPT_LOGOUT 18 /* force logout */
#define TELOPT_BM 19 /* byte macro */
#define TELOPT_DET 20 /* data entry terminal */
@@ -115,10 +117,14 @@
#define TELOPT_AUTHENTICATION 37/* Authenticate */
#define TELOPT_ENCRYPT 38 /* Encryption option */
#define TELOPT_NEW_ENVIRON 39 /* New - Environment variables */
+#define TELOPT_TN3270E 40 /* RFC2355 - TN3270 Enhancements */
+#define TELOPT_CHARSET 42 /* RFC2066 - Charset */
+#define TELOPT_COMPORT 44 /* RFC2217 - Com Port Control */
+#define TELOPT_KERMIT 47 /* RFC2840 - Kermit */
#define TELOPT_EXOPL 255 /* extended-options-list */
-#define NTELOPTS (1+TELOPT_NEW_ENVIRON)
+#define NTELOPTS (1+TELOPT_KERMIT)
#ifdef TELOPTS
const char *telopts[NTELOPTS+1] = {
"BINARY", "ECHO", "RCP", "SUPPRESS GO AHEAD", "NAME",
@@ -130,11 +136,12 @@
"TACACS UID", "OUTPUT MARKING", "TTYLOC",
"3270 REGIME", "X.3 PAD", "NAWS", "TSPEED", "LFLOW",
"LINEMODE", "XDISPLOC", "OLD-ENVIRON", "AUTHENTICATION",
- "ENCRYPT", "NEW-ENVIRON",
- 0,
+ "ENCRYPT", "NEW-ENVIRON", "TN3270E", "XAUTH", "CHARSET",
+ "RSP", "COM-PORT", "SLE", "STARTTLS", "KERMIT",
+ 0
};
#define TELOPT_FIRST TELOPT_BINARY
-#define TELOPT_LAST TELOPT_NEW_ENVIRON
+#define TELOPT_LAST TELOPT_KERMIT
#define TELOPT_OK(x) ((unsigned int)(x) <= TELOPT_LAST)
#define TELOPT(x) telopts[(x)-TELOPT_FIRST]
#endif
@@ -192,20 +199,39 @@
#define SLC_XOFF 16
#define SLC_FORW1 17
#define SLC_FORW2 18
+#define SLC_MCL 19
+#define SLC_MCR 20
+#define SLC_MCWL 21
+#define SLC_MCWR 22
+#define SLC_MCBOL 23
+#define SLC_MCEOL 24
+#define SLC_INSRT 25
+#define SLC_OVER 26
+#define SLC_ECR 27
+#define SLC_EWR 28
+#define SLC_EBOL 29
+#define SLC_EEOL 30
-#define NSLC 18
+#define NSLC 30
/*
* For backwards compatibility, we define SLC_NAMES to be the
* list of names if SLC_NAMES is not defined.
*/
-#define SLC_NAMELIST "0", "SYNCH", "BRK", "IP", "AO", "AYT", "EOR", \
- "ABORT", "EOF", "SUSP", "EC", "EL", "EW", "RP", \
- "LNEXT", "XON", "XOFF", "FORW1", "FORW2", 0,
+#define SLC_NAMELIST "0", "SYNCH", "BRK", "IP", "AO", "AYT", "EOR", \
+ "ABORT", "EOF", "SUSP", "EC", "EL", "EW", "RP", \
+ "LNEXT", "XON", "XOFF", "FORW1", "FORW2", \
+ "MCL", "MCR", "MCWL", "MCWR", "MCBOL", \
+ "MCEOL", "INSRT", "OVER", "ECR", "EWR", \
+ "EBOL", "EEOL", \
+ 0
+
#ifdef SLC_NAMES
const char *slc_names[] = {
SLC_NAMELIST
};
+#else
+extern char *slc_names[];
#define SLC_NAMES SLC_NAMELIST
#endif
@@ -256,14 +282,18 @@
#define AUTHTYPE_KERBEROS_V5 2
#define AUTHTYPE_SPX 3
#define AUTHTYPE_MINK 4
-#define AUTHTYPE_CNT 5
+#define AUTHTYPE_SRA 6
+#define AUTHTYPE_CNT 7
#define AUTHTYPE_TEST 99
#ifdef AUTH_NAMES
const char *authtype_names[] = {
- "NULL", "KERBEROS_V4", "KERBEROS_V5", "SPX", "MINK", 0,
+ "NULL", "KERBEROS_V4", "KERBEROS_V5", "SPX", "MINK", NULL, "SRA",
+ 0
};
+#else
+extern char *authtype_names[];
#endif
#define AUTHTYPE_NAME_OK(x) ((unsigned int)(x) < AUTHTYPE_CNT)
@@ -278,7 +308,7 @@
#define ENCRYPT_START 3 /* Am starting to send encrypted */
#define ENCRYPT_END 4 /* Am ending encrypted */
#define ENCRYPT_REQSTART 5 /* Request you start encrypting */
-#define ENCRYPT_REQEND 6 /* Request you send encrypting */
+#define ENCRYPT_REQEND 6 /* Request you end encrypting */
#define ENCRYPT_ENC_KEYID 7
#define ENCRYPT_DEC_KEYID 8
#define ENCRYPT_CNT 9
@@ -292,11 +322,15 @@
const char *encrypt_names[] = {
"IS", "SUPPORT", "REPLY", "START", "END",
"REQUEST-START", "REQUEST-END", "ENC-KEYID", "DEC-KEYID",
- 0,
+ 0
};
const char *enctype_names[] = {
- "ANY", "DES_CFB64", "DES_OFB64", 0,
+ "ANY", "DES_CFB64", "DES_OFB64",
+ 0
};
+#else
+extern char *encrypt_names[];
+extern char *enctype_names[];
#endif
@@ -306,4 +340,4 @@
#define ENCTYPE_NAME_OK(x) ((unsigned int)(x) < ENCTYPE_CNT)
#define ENCTYPE_NAME(x) enctype_names[x]
-#endif /* arpa/telnet.h */
+#endif /* !_TELNET_H_ */
diff --git a/libc/include/arpa/tftp.h b/libc/include/arpa/tftp.h
new file mode 100644
index 0000000..20733ec
--- /dev/null
+++ b/libc/include/arpa/tftp.h
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 1983, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)tftp.h 8.1 (Berkeley) 6/2/93
+ * $FreeBSD$
+ */
+
+#ifndef _ARPA_TFTP_H_
+#define _ARPA_TFTP_H_
+
+#include <sys/cdefs.h>
+
+/*
+ * Trivial File Transfer Protocol (IEN-133)
+ */
+#define SEGSIZE 512 /* data segment size */
+
+/*
+ * Packet types.
+ */
+#define RRQ 01 /* read request */
+#define WRQ 02 /* write request */
+#define DATA 03 /* data packet */
+#define ACK 04 /* acknowledgement */
+#define ERROR 05 /* error code */
+#define OACK 06 /* option acknowledgement */
+
+struct tftphdr {
+ unsigned short th_opcode; /* packet type */
+ union {
+ unsigned short tu_block; /* block # */
+ unsigned short tu_code; /* error code */
+ char tu_stuff[1]; /* request packet stuff */
+ } __packed th_u;
+ char th_data[1]; /* data or error string */
+} __packed;
+
+#define th_block th_u.tu_block
+#define th_code th_u.tu_code
+#define th_stuff th_u.tu_stuff
+#define th_msg th_data
+
+/*
+ * Error codes.
+ */
+#define EUNDEF 0 /* not defined */
+#define ENOTFOUND 1 /* file not found */
+#define EACCESS 2 /* access violation */
+#define ENOSPACE 3 /* disk full or allocation exceeded */
+#define EBADOP 4 /* illegal TFTP operation */
+#define EBADID 5 /* unknown transfer ID */
+#define EEXISTS 6 /* file already exists */
+#define ENOUSER 7 /* no such user */
+#define EOPTNEG 8 /* option negotiation failed */
+
+#endif /* !_TFTP_H_ */
diff --git a/libc/include/bits/lockf.h b/libc/include/bits/lockf.h
index 655514d..c24f18b 100644
--- a/libc/include/bits/lockf.h
+++ b/libc/include/bits/lockf.h
@@ -40,7 +40,7 @@
__BEGIN_DECLS
#if defined(__USE_FILE_OFFSET64)
-int lockf(int, int, off_t) __RENAME(lockf64);
+int lockf(int, int, off_t) __RENAME(lockf64) __INTRODUCED_IN(24);
#else
int lockf(int, int, off_t) __INTRODUCED_IN(24);
#endif
diff --git a/libc/include/dirent.h b/libc/include/dirent.h
index 3f9ad18..ebcf085 100644
--- a/libc/include/dirent.h
+++ b/libc/include/dirent.h
@@ -31,6 +31,7 @@
#include <stdint.h>
#include <sys/cdefs.h>
+#include <sys/types.h>
__BEGIN_DECLS
@@ -46,17 +47,24 @@
#define DT_WHT 14
#endif
+#if defined(__LP64__)
+#define __DIRENT64_INO_T ino_t
+#else
+#define __DIRENT64_INO_T uint64_t /* Historical accident. */
+#endif
+
#define __DIRENT64_BODY \
- uint64_t d_ino; \
- int64_t d_off; \
- unsigned short d_reclen; \
- unsigned char d_type; \
- char d_name[256]; \
+ __DIRENT64_INO_T d_ino; \
+ off64_t d_off; \
+ unsigned short d_reclen; \
+ unsigned char d_type; \
+ char d_name[256]; \
struct dirent { __DIRENT64_BODY };
struct dirent64 { __DIRENT64_BODY };
#undef __DIRENT64_BODY
+#undef __DIRENT64_INO_T
/* glibc compatibility. */
#undef _DIRENT_HAVE_D_NAMLEN /* Linux doesn't have a d_namlen field. */
diff --git a/libc/include/fcntl.h b/libc/include/fcntl.h
index 652430c..c98022c 100644
--- a/libc/include/fcntl.h
+++ b/libc/include/fcntl.h
@@ -56,14 +56,18 @@
#define O_ASYNC FASYNC
#define O_RSYNC O_SYNC
+#if __ANDROID_API__ >= __ANDROID_API_L__
#define SPLICE_F_MOVE 1
#define SPLICE_F_NONBLOCK 2
#define SPLICE_F_MORE 4
#define SPLICE_F_GIFT 8
+#endif
+#if __ANDROID_API__ >= __ANDROID_API_O__
#define SYNC_FILE_RANGE_WAIT_BEFORE 1
#define SYNC_FILE_RANGE_WRITE 2
#define SYNC_FILE_RANGE_WAIT_AFTER 4
+#endif
int creat(const char*, mode_t);
int creat64(const char*, mode_t) __INTRODUCED_IN(21);
diff --git a/libc/include/limits.h b/libc/include/limits.h
index a25eb65..157f7a6 100644
--- a/libc/include/limits.h
+++ b/libc/include/limits.h
@@ -138,9 +138,9 @@
#define HOST_NAME_MAX _POSIX_HOST_NAME_MAX
-#define _POSIX_VERSION 200809L /* Posix C language bindings version */
-#define _POSIX2_VERSION -1 /* we don't support Posix command-line tools */
-#define _XOPEN_VERSION 700 /* by Posix definition */
+#define _POSIX_VERSION 200809L
+#define _POSIX2_VERSION _POSIX_VERSION
+#define _XOPEN_VERSION 700 /* by Posix definition */
/* >= _POSIX_THREAD_DESTRUCTOR_ITERATIONS */
#define PTHREAD_DESTRUCTOR_ITERATIONS 4
diff --git a/libc/include/stdio.h b/libc/include/stdio.h
index 24916d6..ca56437 100644
--- a/libc/include/stdio.h
+++ b/libc/include/stdio.h
@@ -176,17 +176,17 @@
int fseek(FILE*, long, int);
long ftell(FILE*);
-#if defined(__USE_FILE_OFFSET64) && __ANDROID_API__ >= __ANDROID_API_N__
-int fgetpos(FILE*, fpos_t*) __RENAME(fgetpos64);
-int fsetpos(FILE*, const fpos_t*) __RENAME(fsetpos64);
-int fseeko(FILE*, off_t, int) __RENAME(fseeko64);
-off_t ftello(FILE*) __RENAME(ftello64);
+#if defined(__USE_FILE_OFFSET64)
+int fgetpos(FILE*, fpos_t*) __RENAME(fgetpos64) __INTRODUCED_IN(24);
+int fsetpos(FILE*, const fpos_t*) __RENAME(fsetpos64) __INTRODUCED_IN(24);
+int fseeko(FILE*, off_t, int) __RENAME(fseeko64) __INTRODUCED_IN(24);
+off_t ftello(FILE*) __RENAME(ftello64) __INTRODUCED_IN(24);
# if defined(__USE_BSD)
FILE* funopen(const void*,
int (*)(void*, char*, int),
int (*)(void*, const char*, int),
fpos_t (*)(void*, fpos_t, int),
- int (*)(void*)) __RENAME(funopen64);
+ int (*)(void*)) __RENAME(funopen64) __INTRODUCED_IN(24);
# endif
#else
int fgetpos(FILE*, fpos_t*);
diff --git a/libc/include/strings.h b/libc/include/strings.h
index 021e2b4..11f3213 100644
--- a/libc/include/strings.h
+++ b/libc/include/strings.h
@@ -54,8 +54,12 @@
#define bzero(b, len) (void)(__builtin_memset((b), '\0', (len)))
#endif
+#if !defined(__i386__) || __ANDROID_API__ >= __ANDROID_API_J_MR2__
int ffs(int) __INTRODUCED_IN_X86(18);
+#endif
__END_DECLS
+#include <android/legacy_strings_inlines.h>
+
#endif /* !defined(_STRINGS_H_) */
diff --git a/libc/include/sys/mman.h b/libc/include/sys/mman.h
index 9a2ec35..1440dc6 100644
--- a/libc/include/sys/mman.h
+++ b/libc/include/sys/mman.h
@@ -43,7 +43,7 @@
#define MREMAP_MAYMOVE 1
#define MREMAP_FIXED 2
-#if defined(__USE_FILE_OFFSET64) && __ANDROID_API__ >= __ANDROID_API_L__
+#if defined(__USE_FILE_OFFSET64)
void* mmap(void*, size_t, int, int, int, off_t) __RENAME(mmap64) __INTRODUCED_IN(21);
#else
void* mmap(void*, size_t, int, int, int, off_t);
@@ -71,7 +71,7 @@
* Some third-party code uses the existence of POSIX_MADV_NORMAL to detect the
* availability of posix_madvise. This is not correct, since having up-to-date
* UAPI headers says nothing about the C library, but for the time being we
- * don't want to harm adoption to the unified headers.
+ * don't want to harm adoption of the unified headers.
*
* https://github.com/android-ndk/ndk/issues/395
*/
diff --git a/libc/include/sys/procfs.h b/libc/include/sys/procfs.h
index 7ef5023..eff39e2 100644
--- a/libc/include/sys/procfs.h
+++ b/libc/include/sys/procfs.h
@@ -49,6 +49,14 @@
typedef pid_t lwpid_t;
typedef void* psaddr_t;
+struct elf_siginfo {
+ int si_signo;
+ int si_code;
+ int si_errno;
+};
+
+#define ELF_PRARGSZ 80
+
__END_DECLS
#endif /* _SYS_PROCFS_H_ */
diff --git a/libc/include/sys/sendfile.h b/libc/include/sys/sendfile.h
index dccdec5..43b334c 100644
--- a/libc/include/sys/sendfile.h
+++ b/libc/include/sys/sendfile.h
@@ -34,9 +34,8 @@
__BEGIN_DECLS
-#if defined(__USE_FILE_OFFSET64) && __ANDROID_API__ >= __ANDROID_API_L__
-ssize_t sendfile(int out_fd, int in_fd, off_t* offset, size_t count) __RENAME(sendfile64)
- __INTRODUCED_IN(21);
+#if defined(__USE_FILE_OFFSET64)
+ssize_t sendfile(int out_fd, int in_fd, off_t* offset, size_t count) __RENAME(sendfile64) __INTRODUCED_IN(21);
#else
ssize_t sendfile(int out_fd, int in_fd, off_t* offset, size_t count);
#endif
diff --git a/libc/include/sys/ttydefaults.h b/libc/include/sys/ttydefaults.h
index 62af84b..4dcc649 100644
--- a/libc/include/sys/ttydefaults.h
+++ b/libc/include/sys/ttydefaults.h
@@ -48,7 +48,7 @@
* Defaults on "first" open.
*/
#define TTYDEF_IFLAG (BRKINT | ICRNL | IMAXBEL | IXON | IXANY)
-#define TTYDEF_OFLAG (OPOST | ONLCR | OXTABS)
+#define TTYDEF_OFLAG (OPOST | ONLCR | XTABS)
#define TTYDEF_LFLAG (ECHO | ICANON | ISIG | IEXTEN | ECHOE|ECHOKE|ECHOCTL)
#define TTYDEF_CFLAG (CREAD | CS8 | HUPCL)
#define TTYDEF_SPEED (B9600)
@@ -58,7 +58,7 @@
*/
#define CTRL(x) (x&037)
#define CEOF CTRL('d')
-#define CEOL ((unsigned char)'\377') /* XXX avoid _POSIX_VDISABLE */
+#define CEOL '\0' /* XXX avoid _POSIX_VDISABLE */
#define CERASE 0177
#define CINTR CTRL('c')
#define CSTATUS CTRL('t')
@@ -80,34 +80,4 @@
#define CRPRNT CREPRINT
#define CFLUSH CDISCARD
-/* PROTECTED INCLUSION ENDS HERE */
#endif /* !_SYS_TTYDEFAULTS_H_ */
-
-/*
- * #define TTYDEFCHARS to include an array of default control characters.
- */
-#ifdef TTYDEFCHARS
-const cc_t ttydefchars[NCCS] = {
- [VEOF] = CEOF,
- [VEOL] = CEOL,
- [VEOL2] = CEOL,
- [VERASE] = CERASE,
- [VWERASE] = CWERASE,
- [VKILL] = CKILL,
- [VREPRINT] = CREPRINT,
- [7] = _POSIX_VDISABLE, /* spare */
- [VINTR] = CINTR,
- [VQUIT] = CQUIT,
- [VSUSP] = CSUSP,
- [VDSUSP] = CDSUSP,
- [VSTART] = CSTART,
- [VSTOP] = CSTOP,
- [VLNEXT] = CLNEXT,
- [VDISCARD] = CDISCARD,
- [VMIN] = CMIN,
- [VTIME] = CTIME,
- [VSTATUS] = CSTATUS,
- [19] = _POSIX_VDISABLE, /* spare */
-};
-#undef TTYDEFCHARS
-#endif
diff --git a/libc/include/sys/uio.h b/libc/include/sys/uio.h
index 0e56d7d..2611774 100644
--- a/libc/include/sys/uio.h
+++ b/libc/include/sys/uio.h
@@ -39,8 +39,8 @@
#if defined(__USE_GNU)
#if defined(__USE_FILE_OFFSET64)
-ssize_t preadv(int, const struct iovec*, int, off_t) __RENAME(preadv64);
-ssize_t pwritev(int, const struct iovec*, int, off_t) __RENAME(pwritev64);
+ssize_t preadv(int, const struct iovec*, int, off_t) __RENAME(preadv64) __INTRODUCED_IN(24);
+ssize_t pwritev(int, const struct iovec*, int, off_t) __RENAME(pwritev64) __INTRODUCED_IN(24);
#else
ssize_t preadv(int, const struct iovec*, int, off_t) __INTRODUCED_IN(24);
ssize_t pwritev(int, const struct iovec*, int, off_t) __INTRODUCED_IN(24);
diff --git a/libc/include/sys/user.h b/libc/include/sys/user.h
index f9ad956..ed3e10a 100644
--- a/libc/include/sys/user.h
+++ b/libc/include/sys/user.h
@@ -102,6 +102,10 @@
int u_debugreg[8];
};
+#define UPAGES 1
+#define HOST_TEXT_START_ADDR (u.start_code)
+#define HOST_STACK_END_ADDR (u.start_stack + u.u_ssize * PAGE_SIZE)
+
#elif defined(__x86_64__)
struct user_fpregs_struct {
diff --git a/libc/include/unistd.h b/libc/include/unistd.h
index ff2e9f6..e024527 100644
--- a/libc/include/unistd.h
+++ b/libc/include/unistd.h
@@ -173,7 +173,7 @@
off64_t lseek64(int __fd, off64_t __offset, int __whence);
-#if defined(__USE_FILE_OFFSET64) && __ANDROID_API__ >= __ANDROID_API_L__
+#if defined(__USE_FILE_OFFSET64)
int truncate(const char* __path, off_t __length) __RENAME(truncate64) __INTRODUCED_IN(21);
ssize_t pread(int __fd, void* __buf, size_t __count, off_t __offset)
__overloadable __RENAME(pread64) __INTRODUCED_IN(12);
diff --git a/libm/Android.bp b/libm/Android.bp
index 07d4261..8947f4d 100644
--- a/libm/Android.bp
+++ b/libm/Android.bp
@@ -529,6 +529,7 @@
sanitize: {
address: false,
coverage: false,
+ integer_overflow: false,
},
stl: "none",
}
diff --git a/linker/linker_main.cpp b/linker/linker_main.cpp
index db36976..3f7795b 100644
--- a/linker/linker_main.cpp
+++ b/linker/linker_main.cpp
@@ -138,8 +138,7 @@
// An empty list of soinfos
static soinfo_list_t g_empty_list;
-static void add_vdso(KernelArgumentBlock& args __unused) {
-#if defined(AT_SYSINFO_EHDR)
+static void add_vdso(KernelArgumentBlock& args) {
ElfW(Ehdr)* ehdr_vdso = reinterpret_cast<ElfW(Ehdr)*>(args.getauxval(AT_SYSINFO_EHDR));
if (ehdr_vdso == nullptr) {
return;
@@ -155,7 +154,6 @@
si->prelink_image();
si->link_image(g_empty_list, soinfo_list_t::make_list(si), nullptr);
-#endif
}
/* gdb expects the linker to be in the debug shared object list.
diff --git a/tests/Android.bp b/tests/Android.bp
index 2a5b47e..d4027b3 100644
--- a/tests/Android.bp
+++ b/tests/Android.bp
@@ -134,6 +134,7 @@
"sys_sysmacros_test.cpp",
"sys_time_test.cpp",
"sys_timex_test.cpp",
+ "sys_ttydefaults_test.cpp",
"sys_types_test.cpp",
"sys_uio_test.cpp",
"sys_vfs_test.cpp",
@@ -288,6 +289,7 @@
],
static_libs: [
"libpagemap",
+ "libziparchive",
"libLLVMObject",
"libLLVMBitReader",
"libLLVMMC",
diff --git a/tests/sys_ttydefaults_test.cpp b/tests/sys_ttydefaults_test.cpp
new file mode 100644
index 0000000..fa4f7c7
--- /dev/null
+++ b/tests/sys_ttydefaults_test.cpp
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2017 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 <gtest/gtest.h>
+
+#include <sys/ttydefaults.h>
+#include <termios.h>
+
+TEST(sys_ttydefaults, flags) {
+ int i;
+ i = TTYDEF_IFLAG;
+ i = TTYDEF_OFLAG;
+ i = TTYDEF_LFLAG;
+ i = TTYDEF_CFLAG;
+ i = TTYDEF_SPEED;
+}
+
+TEST(sys_ttydefaults, correct_CEOL) {
+ ASSERT_EQ(_POSIX_VDISABLE, CEOL);
+}