Merge changes Ife4692e4,I7304cc1d,If19653d0,I769ca792,I93625d19, ...
* changes:
Move <sys/sysconf.h> to <bits/sysconf.h>.
Remove mbstowcs from <wchar.h>.
Extract getopt and friends to <bits/getopt.h>
Remove declaration of unlinkat from <fcntl.h>.
Extract ioctl to <bits/ioctl.h>.
Extract fcntl to <bits/fcntl.h>.
Extract strcasecmp and friends to <bits/strcasecmp.h>.
Make <bits/lockf.h> compile standalone.
Make <android/dlext.h> compile standalone.
Make the network headers compile standalone.
Remove duplicate declaration of mlock, munlock.
diff --git a/libc/bionic/clock.cpp b/libc/bionic/clock.cpp
index 053e9e7..fda0708 100644
--- a/libc/bionic/clock.cpp
+++ b/libc/bionic/clock.cpp
@@ -26,9 +26,9 @@
* SUCH DAMAGE.
*/
-#include <time.h>
-#include <sys/sysconf.h>
#include <sys/times.h>
+#include <time.h>
+#include <unistd.h>
#include "private/bionic_constants.h"
diff --git a/libc/bionic/sysconf.cpp b/libc/bionic/sysconf.cpp
index cff6288..7be0ab7 100644
--- a/libc/bionic/sysconf.cpp
+++ b/libc/bionic/sysconf.cpp
@@ -34,7 +34,6 @@
#include <stdio.h> // For FOPEN_MAX.
#include <sys/auxv.h>
#include <sys/resource.h>
-#include <sys/sysconf.h>
#include <sys/sysinfo.h>
#include <time.h>
#include <unistd.h>
diff --git a/libc/include/android/dlext.h b/libc/include/android/dlext.h
index d5ec386..6e32b68 100644
--- a/libc/include/android/dlext.h
+++ b/libc/include/android/dlext.h
@@ -17,6 +17,7 @@
#ifndef __ANDROID_DLEXT_H__
#define __ANDROID_DLEXT_H__
+#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <sys/cdefs.h>
diff --git a/libc/include/bits/fcntl.h b/libc/include/bits/fcntl.h
new file mode 100644
index 0000000..90f933c
--- /dev/null
+++ b/libc/include/bits/fcntl.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2016 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 _BITS_FCNTL_H_
+#define _BITS_FCNTL_H_
+
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+
+extern int fcntl(int, int, ...);
+
+__END_DECLS
+
+#endif
diff --git a/libc/include/bits/getopt.h b/libc/include/bits/getopt.h
new file mode 100644
index 0000000..7153d48
--- /dev/null
+++ b/libc/include/bits/getopt.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2016 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 _BITS_GETOPT_H_
+#define _BITS_GETOPT_H_
+
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+
+int getopt(int, char * const [], const char *);
+
+extern char *optarg; /* getopt(3) external variables */
+extern int optind, opterr, optopt;
+
+__END_DECLS
+
+#endif
diff --git a/libc/include/bits/ioctl.h b/libc/include/bits/ioctl.h
new file mode 100644
index 0000000..788a4f7
--- /dev/null
+++ b/libc/include/bits/ioctl.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2016 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 _BITS_IOCTL_H_
+#define _BITS_IOCTL_H_
+
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+
+extern int ioctl(int, int, ...);
+
+__END_DECLS
+
+#endif
diff --git a/libc/include/bits/lockf.h b/libc/include/bits/lockf.h
index d814807..a0ba19d 100644
--- a/libc/include/bits/lockf.h
+++ b/libc/include/bits/lockf.h
@@ -30,6 +30,7 @@
#define _BITS_LOCKF_H_
#include <sys/cdefs.h>
+#include <sys/types.h>
#define F_ULOCK 0
#define F_LOCK 1
diff --git a/libc/include/bits/strcasecmp.h b/libc/include/bits/strcasecmp.h
new file mode 100644
index 0000000..124f5cd
--- /dev/null
+++ b/libc/include/bits/strcasecmp.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2016 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 _BITS_STRCASECMP_H_
+#define _BITS_STRCASECMP_H_
+
+#include <sys/cdefs.h>
+#include <sys/types.h>
+#include <xlocale.h>
+
+__BEGIN_DECLS
+
+int strcasecmp(const char*, const char*) __purefunc;
+int strcasecmp_l(const char*, const char*, locale_t) __purefunc;
+int strncasecmp(const char*, const char*, size_t) __purefunc;
+int strncasecmp_l(const char*, const char*, size_t, locale_t) __purefunc;
+
+__END_DECLS
+
+#endif
diff --git a/libc/include/bits/sysconf.h b/libc/include/bits/sysconf.h
new file mode 100644
index 0000000..2cbbb11
--- /dev/null
+++ b/libc/include/bits/sysconf.h
@@ -0,0 +1,196 @@
+/*
+ * Copyright (C) 2008 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 _BITS_SYSCONF_H_
+#define _BITS_SYSCONF_H_
+
+#include <sys/cdefs.h>
+
+/* as listed by Posix sysconf() description */
+/* most of these will return -1 and ENOSYS */
+
+#define _SC_ARG_MAX 0x0000
+#define _SC_BC_BASE_MAX 0x0001
+#define _SC_BC_DIM_MAX 0x0002
+#define _SC_BC_SCALE_MAX 0x0003
+#define _SC_BC_STRING_MAX 0x0004
+#define _SC_CHILD_MAX 0x0005
+#define _SC_CLK_TCK 0x0006
+#define _SC_COLL_WEIGHTS_MAX 0x0007
+#define _SC_EXPR_NEST_MAX 0x0008
+#define _SC_LINE_MAX 0x0009
+#define _SC_NGROUPS_MAX 0x000a
+#define _SC_OPEN_MAX 0x000b
+#define _SC_PASS_MAX 0x000c
+#define _SC_2_C_BIND 0x000d
+#define _SC_2_C_DEV 0x000e
+#define _SC_2_C_VERSION 0x000f /* Obsolescent in POSIX.1-2008, TODO: remove it. */
+#define _SC_2_CHAR_TERM 0x0010
+#define _SC_2_FORT_DEV 0x0011
+#define _SC_2_FORT_RUN 0x0012
+#define _SC_2_LOCALEDEF 0x0013
+#define _SC_2_SW_DEV 0x0014
+#define _SC_2_UPE 0x0015
+#define _SC_2_VERSION 0x0016
+#define _SC_JOB_CONTROL 0x0017
+#define _SC_SAVED_IDS 0x0018
+#define _SC_VERSION 0x0019
+#define _SC_RE_DUP_MAX 0x001a
+#define _SC_STREAM_MAX 0x001b
+#define _SC_TZNAME_MAX 0x001c
+#define _SC_XOPEN_CRYPT 0x001d
+#define _SC_XOPEN_ENH_I18N 0x001e
+#define _SC_XOPEN_SHM 0x001f
+#define _SC_XOPEN_VERSION 0x0020
+#define _SC_XOPEN_XCU_VERSION 0x0021 /* Obsolescent in POSIX.1-2008, TODO: remove it. */
+#define _SC_XOPEN_REALTIME 0x0022
+#define _SC_XOPEN_REALTIME_THREADS 0x0023
+#define _SC_XOPEN_LEGACY 0x0024
+#define _SC_ATEXIT_MAX 0x0025
+#define _SC_IOV_MAX 0x0026
+#define _SC_PAGESIZE 0x0027
+#define _SC_PAGE_SIZE 0x0028
+#define _SC_XOPEN_UNIX 0x0029
+#define _SC_XBS5_ILP32_OFF32 0x002a /* Obsolescent in POSIX.1-2008, TODO: remove it. */
+#define _SC_XBS5_ILP32_OFFBIG 0x002b /* Obsolescent in POSIX.1-2008, TODO: remove it. */
+#define _SC_XBS5_LP64_OFF64 0x002c /* Obsolescent in POSIX.1-2008, TODO: remove it. */
+#define _SC_XBS5_LPBIG_OFFBIG 0x002d /* Obsolescent in POSIX.1-2008, TODO: remove it. */
+#define _SC_AIO_LISTIO_MAX 0x002e
+#define _SC_AIO_MAX 0x002f
+#define _SC_AIO_PRIO_DELTA_MAX 0x0030
+#define _SC_DELAYTIMER_MAX 0x0031
+#define _SC_MQ_OPEN_MAX 0x0032
+#define _SC_MQ_PRIO_MAX 0x0033
+#define _SC_RTSIG_MAX 0x0034
+#define _SC_SEM_NSEMS_MAX 0x0035
+#define _SC_SEM_VALUE_MAX 0x0036
+#define _SC_SIGQUEUE_MAX 0x0037
+#define _SC_TIMER_MAX 0x0038
+#define _SC_ASYNCHRONOUS_IO 0x0039
+#define _SC_FSYNC 0x003a
+#define _SC_MAPPED_FILES 0x003b
+#define _SC_MEMLOCK 0x003c
+#define _SC_MEMLOCK_RANGE 0x003d
+#define _SC_MEMORY_PROTECTION 0x003e
+#define _SC_MESSAGE_PASSING 0x003f
+#define _SC_PRIORITIZED_IO 0x0040
+#define _SC_PRIORITY_SCHEDULING 0x0041
+#define _SC_REALTIME_SIGNALS 0x0042
+#define _SC_SEMAPHORES 0x0043
+#define _SC_SHARED_MEMORY_OBJECTS 0x0044
+#define _SC_SYNCHRONIZED_IO 0x0045
+#define _SC_TIMERS 0x0046
+#define _SC_GETGR_R_SIZE_MAX 0x0047
+#define _SC_GETPW_R_SIZE_MAX 0x0048
+#define _SC_LOGIN_NAME_MAX 0x0049
+#define _SC_THREAD_DESTRUCTOR_ITERATIONS 0x004a
+#define _SC_THREAD_KEYS_MAX 0x004b
+#define _SC_THREAD_STACK_MIN 0x004c
+#define _SC_THREAD_THREADS_MAX 0x004d
+#define _SC_TTY_NAME_MAX 0x004e
+
+#define _SC_THREADS 0x004f
+#define _SC_THREAD_ATTR_STACKADDR 0x0050
+#define _SC_THREAD_ATTR_STACKSIZE 0x0051
+#define _SC_THREAD_PRIORITY_SCHEDULING 0x0052
+#define _SC_THREAD_PRIO_INHERIT 0x0053
+#define _SC_THREAD_PRIO_PROTECT 0x0054
+#define _SC_THREAD_SAFE_FUNCTIONS 0x0055
+
+#define _SC_NPROCESSORS_CONF 0x0060
+#define _SC_NPROCESSORS_ONLN 0x0061
+#define _SC_PHYS_PAGES 0x0062
+#define _SC_AVPHYS_PAGES 0x0063
+#define _SC_MONOTONIC_CLOCK 0x0064
+
+#define _SC_2_PBS 0x0065
+#define _SC_2_PBS_ACCOUNTING 0x0066
+#define _SC_2_PBS_CHECKPOINT 0x0067
+#define _SC_2_PBS_LOCATE 0x0068
+#define _SC_2_PBS_MESSAGE 0x0069
+#define _SC_2_PBS_TRACK 0x006a
+#define _SC_ADVISORY_INFO 0x006b
+#define _SC_BARRIERS 0x006c
+#define _SC_CLOCK_SELECTION 0x006d
+#define _SC_CPUTIME 0x006e
+#define _SC_HOST_NAME_MAX 0x006f
+#define _SC_IPV6 0x0070
+#define _SC_RAW_SOCKETS 0x0071
+#define _SC_READER_WRITER_LOCKS 0x0072
+#define _SC_REGEXP 0x0073
+#define _SC_SHELL 0x0074
+#define _SC_SPAWN 0x0075
+#define _SC_SPIN_LOCKS 0x0076
+#define _SC_SPORADIC_SERVER 0x0077
+#define _SC_SS_REPL_MAX 0x0078
+#define _SC_SYMLOOP_MAX 0x0079
+#define _SC_THREAD_CPUTIME 0x007a
+#define _SC_THREAD_PROCESS_SHARED 0x007b
+#define _SC_THREAD_ROBUST_PRIO_INHERIT 0x007c
+#define _SC_THREAD_ROBUST_PRIO_PROTECT 0x007d
+#define _SC_THREAD_SPORADIC_SERVER 0x007e
+#define _SC_TIMEOUTS 0x007f
+#define _SC_TRACE 0x0080
+#define _SC_TRACE_EVENT_FILTER 0x0081
+#define _SC_TRACE_EVENT_NAME_MAX 0x0082
+#define _SC_TRACE_INHERIT 0x0083
+#define _SC_TRACE_LOG 0x0084
+#define _SC_TRACE_NAME_MAX 0x0085
+#define _SC_TRACE_SYS_MAX 0x0086
+#define _SC_TRACE_USER_EVENT_MAX 0x0087
+#define _SC_TYPED_MEMORY_OBJECTS 0x0088
+#define _SC_V7_ILP32_OFF32 0x0089
+#define _SC_V7_ILP32_OFFBIG 0x008a
+#define _SC_V7_LP64_OFF64 0x008b
+#define _SC_V7_LPBIG_OFFBIG 0x008c
+#define _SC_XOPEN_STREAMS 0x008d
+#define _SC_XOPEN_UUCP 0x008e
+
+#define _SC_LEVEL1_ICACHE_SIZE 0x008f
+#define _SC_LEVEL1_ICACHE_ASSOC 0x0090
+#define _SC_LEVEL1_ICACHE_LINESIZE 0x0091
+#define _SC_LEVEL1_DCACHE_SIZE 0x0092
+#define _SC_LEVEL1_DCACHE_ASSOC 0x0093
+#define _SC_LEVEL1_DCACHE_LINESIZE 0x0094
+#define _SC_LEVEL2_CACHE_SIZE 0x0095
+#define _SC_LEVEL2_CACHE_ASSOC 0x0096
+#define _SC_LEVEL2_CACHE_LINESIZE 0x0097
+#define _SC_LEVEL3_CACHE_SIZE 0x0098
+#define _SC_LEVEL3_CACHE_ASSOC 0x0099
+#define _SC_LEVEL3_CACHE_LINESIZE 0x009a
+#define _SC_LEVEL4_CACHE_SIZE 0x009b
+#define _SC_LEVEL4_CACHE_ASSOC 0x009c
+#define _SC_LEVEL4_CACHE_LINESIZE 0x009d
+
+__BEGIN_DECLS
+
+long sysconf(int __name);
+
+__END_DECLS
+
+#endif /* _SYS_SYSCONF_H_ */
diff --git a/libc/include/fcntl.h b/libc/include/fcntl.h
index 9d15e92..013d72c 100644
--- a/libc/include/fcntl.h
+++ b/libc/include/fcntl.h
@@ -36,6 +36,8 @@
#include <linux/stat.h>
#include <linux/uio.h>
+#include <bits/fcntl.h>
+
#if defined(__USE_GNU) || defined(__USE_BSD)
#include <bits/lockf.h>
#endif
@@ -63,14 +65,12 @@
extern int creat(const char*, mode_t);
extern int creat64(const char*, mode_t);
-extern int fcntl(int, int, ...);
extern int openat(int, const char*, int, ...);
extern int openat64(int, const char*, int, ...);
extern int open(const char*, int, ...);
extern int open64(const char*, int, ...);
extern ssize_t splice(int, off64_t*, int, off64_t*, size_t, unsigned int);
extern ssize_t tee(int, int, size_t, unsigned int);
-extern int unlinkat(int, const char*, int);
extern ssize_t vmsplice(int, const struct iovec*, size_t, unsigned int);
#if defined(__USE_FILE_OFFSET64)
diff --git a/libc/include/getopt.h b/libc/include/getopt.h
index 4451941..46d2eb7 100644
--- a/libc/include/getopt.h
+++ b/libc/include/getopt.h
@@ -35,9 +35,10 @@
#include <sys/cdefs.h>
+#include <bits/getopt.h>
+
/*
* GNU-like getopt_long()/getopt_long_only() with 4.4BSD optreset extension.
- * getopt() is declared here too for GNU programs.
*/
#define no_argument 0
#define required_argument 1
@@ -62,13 +63,7 @@
const struct option *, int *);
int getopt_long_only(int, char * const *, const char *,
const struct option *, int *);
-#ifndef _GETOPT_DECLARED
-#define _GETOPT_DECLARED
-int getopt(int, char * const [], const char *);
-extern char *optarg; /* getopt(3) external variables */
-extern int optind, opterr, optopt;
-#endif
#ifndef _OPTRESET_DECLARED
#define _OPTRESET_DECLARED
extern int optreset; /* getopt(3) external variable */
diff --git a/libc/include/net/if_ieee1394.h b/libc/include/net/if_ieee1394.h
index 5a61581..2f8a7c3 100644
--- a/libc/include/net/if_ieee1394.h
+++ b/libc/include/net/if_ieee1394.h
@@ -39,6 +39,8 @@
#ifndef _NET_IF_IEEE1394_H_
#define _NET_IF_IEEE1394_H_
+#include <sys/types.h>
+
/* hardware address information for arp / nd */
struct ieee1394_hwaddr {
u_int8_t iha_uid[8]; /* node unique ID */
diff --git a/libc/include/netinet/in_systm.h b/libc/include/netinet/in_systm.h
index ff53fb7..7e474ba 100644
--- a/libc/include/netinet/in_systm.h
+++ b/libc/include/netinet/in_systm.h
@@ -34,6 +34,8 @@
#ifndef _NETINET_IN_SYSTM_H_
#define _NETINET_IN_SYSTM_H_
+#include <sys/types.h>
+
/*
* Miscellaneous internetwork
* definitions for kernel.
diff --git a/libc/include/netinet/ip6.h b/libc/include/netinet/ip6.h
index aa816c2..aa89186 100644
--- a/libc/include/netinet/ip6.h
+++ b/libc/include/netinet/ip6.h
@@ -64,6 +64,10 @@
#ifndef _NETINET_IP6_H_
#define _NETINET_IP6_H_
+#include <sys/types.h>
+
+#include <linux/in6.h>
+
/*
* Definition for internet protocol version 6.
* RFC 2460
diff --git a/libc/include/netinet/tcp.h b/libc/include/netinet/tcp.h
index 5601645..e95cc09 100644
--- a/libc/include/netinet/tcp.h
+++ b/libc/include/netinet/tcp.h
@@ -29,6 +29,8 @@
#ifndef _NETINET_TCP_H
#define _NETINET_TCP_H
+#include <sys/cdefs.h>
+
#include <linux/tcp.h>
__BEGIN_DECLS
diff --git a/libc/include/string.h b/libc/include/string.h
index 32d4a18..dada52b 100644
--- a/libc/include/string.h
+++ b/libc/include/string.h
@@ -33,6 +33,8 @@
#include <stddef.h>
#include <xlocale.h>
+#include <bits/strcasecmp.h>
+
__BEGIN_DECLS
#if defined(__USE_BSD)
@@ -72,11 +74,6 @@
extern char* strcpy(char* __restrict, const char* __restrict);
extern char* strcat(char* __restrict, const char* __restrict);
-int strcasecmp(const char*, const char*) __purefunc;
-int strcasecmp_l(const char*, const char*, locale_t) __purefunc;
-int strncasecmp(const char*, const char*, size_t) __purefunc;
-int strncasecmp_l(const char*, const char*, size_t, locale_t) __purefunc;
-
extern char* strdup(const char *);
extern char* strstr(const char *, const char *) __purefunc;
diff --git a/libc/include/strings.h b/libc/include/strings.h
index 1253006..1200e77 100644
--- a/libc/include/strings.h
+++ b/libc/include/strings.h
@@ -43,6 +43,8 @@
#include <sys/cdefs.h>
#include <xlocale.h>
+#include <bits/strcasecmp.h>
+
__BEGIN_DECLS
#if defined(__BIONIC_FORTIFY)
#define bcopy(b1, b2, len) (void)(__builtin___memmove_chk((b2), (b1), (len), __bos0(b2)))
@@ -54,11 +56,6 @@
int ffs(int);
-int strcasecmp(const char*, const char*) __purefunc;
-int strcasecmp_l(const char*, const char*, locale_t) __purefunc;
-int strncasecmp(const char*, const char*, size_t) __purefunc;
-int strncasecmp_l(const char*, const char*, size_t, locale_t) __purefunc;
-
__END_DECLS
#endif /* !defined(_STRINGS_H_) */
diff --git a/libc/include/sys/ioctl.h b/libc/include/sys/ioctl.h
index a1014dc..ed261f2 100644
--- a/libc/include/sys/ioctl.h
+++ b/libc/include/sys/ioctl.h
@@ -40,10 +40,6 @@
#include <sys/ioctl_compat.h>
#include <linux/tty.h>
-__BEGIN_DECLS
-
-extern int ioctl(int, int, ...);
-
-__END_DECLS
+#include <bits/ioctl.h>
#endif /* _SYS_IOCTL_H_ */
diff --git a/libc/include/sys/mman.h b/libc/include/sys/mman.h
index a19ceb5..170300a 100644
--- a/libc/include/sys/mman.h
+++ b/libc/include/sys/mman.h
@@ -65,13 +65,10 @@
extern int munlockall(void);
extern int mlock(const void*, size_t);
extern int munlock(const void*, size_t);
-extern int madvise(void*, size_t, int);
-
-extern int mlock(const void*, size_t);
-extern int munlock(const void*, size_t);
extern int mincore(void*, size_t, unsigned char*);
+extern int madvise(void*, size_t, int);
extern int posix_madvise(void*, size_t, int);
__END_DECLS
diff --git a/libc/include/sys/sysconf.h b/libc/include/sys/sysconf.h
index ca32132..c9895f2 100644
--- a/libc/include/sys/sysconf.h
+++ b/libc/include/sys/sysconf.h
@@ -25,171 +25,9 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-#ifndef _SYS_SYSCONF_H_
-#define _SYS_SYSCONF_H_
-#include <sys/cdefs.h>
+// This file used to contain the declarations of sysconf and its associated constants.
+// No standard mentions a <sys/sysconf.h>, but there are enough users in vendor (and potential ones
+// in the NDK) to warrant not breaking source compatibility.
-__BEGIN_DECLS
-
-/* as listed by Posix sysconf() description */
-/* most of these will return -1 and ENOSYS */
-
-#define _SC_ARG_MAX 0x0000
-#define _SC_BC_BASE_MAX 0x0001
-#define _SC_BC_DIM_MAX 0x0002
-#define _SC_BC_SCALE_MAX 0x0003
-#define _SC_BC_STRING_MAX 0x0004
-#define _SC_CHILD_MAX 0x0005
-#define _SC_CLK_TCK 0x0006
-#define _SC_COLL_WEIGHTS_MAX 0x0007
-#define _SC_EXPR_NEST_MAX 0x0008
-#define _SC_LINE_MAX 0x0009
-#define _SC_NGROUPS_MAX 0x000a
-#define _SC_OPEN_MAX 0x000b
-#define _SC_PASS_MAX 0x000c
-#define _SC_2_C_BIND 0x000d
-#define _SC_2_C_DEV 0x000e
-#define _SC_2_C_VERSION 0x000f /* Obsolescent in POSIX.1-2008, TODO: remove it. */
-#define _SC_2_CHAR_TERM 0x0010
-#define _SC_2_FORT_DEV 0x0011
-#define _SC_2_FORT_RUN 0x0012
-#define _SC_2_LOCALEDEF 0x0013
-#define _SC_2_SW_DEV 0x0014
-#define _SC_2_UPE 0x0015
-#define _SC_2_VERSION 0x0016
-#define _SC_JOB_CONTROL 0x0017
-#define _SC_SAVED_IDS 0x0018
-#define _SC_VERSION 0x0019
-#define _SC_RE_DUP_MAX 0x001a
-#define _SC_STREAM_MAX 0x001b
-#define _SC_TZNAME_MAX 0x001c
-#define _SC_XOPEN_CRYPT 0x001d
-#define _SC_XOPEN_ENH_I18N 0x001e
-#define _SC_XOPEN_SHM 0x001f
-#define _SC_XOPEN_VERSION 0x0020
-#define _SC_XOPEN_XCU_VERSION 0x0021 /* Obsolescent in POSIX.1-2008, TODO: remove it. */
-#define _SC_XOPEN_REALTIME 0x0022
-#define _SC_XOPEN_REALTIME_THREADS 0x0023
-#define _SC_XOPEN_LEGACY 0x0024
-#define _SC_ATEXIT_MAX 0x0025
-#define _SC_IOV_MAX 0x0026
-#define _SC_PAGESIZE 0x0027
-#define _SC_PAGE_SIZE 0x0028
-#define _SC_XOPEN_UNIX 0x0029
-#define _SC_XBS5_ILP32_OFF32 0x002a /* Obsolescent in POSIX.1-2008, TODO: remove it. */
-#define _SC_XBS5_ILP32_OFFBIG 0x002b /* Obsolescent in POSIX.1-2008, TODO: remove it. */
-#define _SC_XBS5_LP64_OFF64 0x002c /* Obsolescent in POSIX.1-2008, TODO: remove it. */
-#define _SC_XBS5_LPBIG_OFFBIG 0x002d /* Obsolescent in POSIX.1-2008, TODO: remove it. */
-#define _SC_AIO_LISTIO_MAX 0x002e
-#define _SC_AIO_MAX 0x002f
-#define _SC_AIO_PRIO_DELTA_MAX 0x0030
-#define _SC_DELAYTIMER_MAX 0x0031
-#define _SC_MQ_OPEN_MAX 0x0032
-#define _SC_MQ_PRIO_MAX 0x0033
-#define _SC_RTSIG_MAX 0x0034
-#define _SC_SEM_NSEMS_MAX 0x0035
-#define _SC_SEM_VALUE_MAX 0x0036
-#define _SC_SIGQUEUE_MAX 0x0037
-#define _SC_TIMER_MAX 0x0038
-#define _SC_ASYNCHRONOUS_IO 0x0039
-#define _SC_FSYNC 0x003a
-#define _SC_MAPPED_FILES 0x003b
-#define _SC_MEMLOCK 0x003c
-#define _SC_MEMLOCK_RANGE 0x003d
-#define _SC_MEMORY_PROTECTION 0x003e
-#define _SC_MESSAGE_PASSING 0x003f
-#define _SC_PRIORITIZED_IO 0x0040
-#define _SC_PRIORITY_SCHEDULING 0x0041
-#define _SC_REALTIME_SIGNALS 0x0042
-#define _SC_SEMAPHORES 0x0043
-#define _SC_SHARED_MEMORY_OBJECTS 0x0044
-#define _SC_SYNCHRONIZED_IO 0x0045
-#define _SC_TIMERS 0x0046
-#define _SC_GETGR_R_SIZE_MAX 0x0047
-#define _SC_GETPW_R_SIZE_MAX 0x0048
-#define _SC_LOGIN_NAME_MAX 0x0049
-#define _SC_THREAD_DESTRUCTOR_ITERATIONS 0x004a
-#define _SC_THREAD_KEYS_MAX 0x004b
-#define _SC_THREAD_STACK_MIN 0x004c
-#define _SC_THREAD_THREADS_MAX 0x004d
-#define _SC_TTY_NAME_MAX 0x004e
-
-#define _SC_THREADS 0x004f
-#define _SC_THREAD_ATTR_STACKADDR 0x0050
-#define _SC_THREAD_ATTR_STACKSIZE 0x0051
-#define _SC_THREAD_PRIORITY_SCHEDULING 0x0052
-#define _SC_THREAD_PRIO_INHERIT 0x0053
-#define _SC_THREAD_PRIO_PROTECT 0x0054
-#define _SC_THREAD_SAFE_FUNCTIONS 0x0055
-
-#define _SC_NPROCESSORS_CONF 0x0060
-#define _SC_NPROCESSORS_ONLN 0x0061
-#define _SC_PHYS_PAGES 0x0062
-#define _SC_AVPHYS_PAGES 0x0063
-#define _SC_MONOTONIC_CLOCK 0x0064
-
-#define _SC_2_PBS 0x0065
-#define _SC_2_PBS_ACCOUNTING 0x0066
-#define _SC_2_PBS_CHECKPOINT 0x0067
-#define _SC_2_PBS_LOCATE 0x0068
-#define _SC_2_PBS_MESSAGE 0x0069
-#define _SC_2_PBS_TRACK 0x006a
-#define _SC_ADVISORY_INFO 0x006b
-#define _SC_BARRIERS 0x006c
-#define _SC_CLOCK_SELECTION 0x006d
-#define _SC_CPUTIME 0x006e
-#define _SC_HOST_NAME_MAX 0x006f
-#define _SC_IPV6 0x0070
-#define _SC_RAW_SOCKETS 0x0071
-#define _SC_READER_WRITER_LOCKS 0x0072
-#define _SC_REGEXP 0x0073
-#define _SC_SHELL 0x0074
-#define _SC_SPAWN 0x0075
-#define _SC_SPIN_LOCKS 0x0076
-#define _SC_SPORADIC_SERVER 0x0077
-#define _SC_SS_REPL_MAX 0x0078
-#define _SC_SYMLOOP_MAX 0x0079
-#define _SC_THREAD_CPUTIME 0x007a
-#define _SC_THREAD_PROCESS_SHARED 0x007b
-#define _SC_THREAD_ROBUST_PRIO_INHERIT 0x007c
-#define _SC_THREAD_ROBUST_PRIO_PROTECT 0x007d
-#define _SC_THREAD_SPORADIC_SERVER 0x007e
-#define _SC_TIMEOUTS 0x007f
-#define _SC_TRACE 0x0080
-#define _SC_TRACE_EVENT_FILTER 0x0081
-#define _SC_TRACE_EVENT_NAME_MAX 0x0082
-#define _SC_TRACE_INHERIT 0x0083
-#define _SC_TRACE_LOG 0x0084
-#define _SC_TRACE_NAME_MAX 0x0085
-#define _SC_TRACE_SYS_MAX 0x0086
-#define _SC_TRACE_USER_EVENT_MAX 0x0087
-#define _SC_TYPED_MEMORY_OBJECTS 0x0088
-#define _SC_V7_ILP32_OFF32 0x0089
-#define _SC_V7_ILP32_OFFBIG 0x008a
-#define _SC_V7_LP64_OFF64 0x008b
-#define _SC_V7_LPBIG_OFFBIG 0x008c
-#define _SC_XOPEN_STREAMS 0x008d
-#define _SC_XOPEN_UUCP 0x008e
-
-#define _SC_LEVEL1_ICACHE_SIZE 0x008f
-#define _SC_LEVEL1_ICACHE_ASSOC 0x0090
-#define _SC_LEVEL1_ICACHE_LINESIZE 0x0091
-#define _SC_LEVEL1_DCACHE_SIZE 0x0092
-#define _SC_LEVEL1_DCACHE_ASSOC 0x0093
-#define _SC_LEVEL1_DCACHE_LINESIZE 0x0094
-#define _SC_LEVEL2_CACHE_SIZE 0x0095
-#define _SC_LEVEL2_CACHE_ASSOC 0x0096
-#define _SC_LEVEL2_CACHE_LINESIZE 0x0097
-#define _SC_LEVEL3_CACHE_SIZE 0x0098
-#define _SC_LEVEL3_CACHE_ASSOC 0x0099
-#define _SC_LEVEL3_CACHE_LINESIZE 0x009a
-#define _SC_LEVEL4_CACHE_SIZE 0x009b
-#define _SC_LEVEL4_CACHE_ASSOC 0x009c
-#define _SC_LEVEL4_CACHE_LINESIZE 0x009d
-
-long sysconf(int);
-
-__END_DECLS
-
-#endif /* _SYS_SYSCONF_H_ */
+#include <bits/sysconf.h>
diff --git a/libc/include/unistd.h b/libc/include/unistd.h
index 2d62c1f..ea6c8a1 100644
--- a/libc/include/unistd.h
+++ b/libc/include/unistd.h
@@ -33,10 +33,13 @@
#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/select.h>
-#include <sys/sysconf.h>
+#include <bits/fcntl.h>
+#include <bits/getopt.h>
+#include <bits/ioctl.h>
#include <bits/lockf.h>
#include <bits/posix_limits.h>
+#include <bits/sysconf.h>
__BEGIN_DECLS
@@ -161,8 +164,6 @@
extern int dup(int __oldfd);
extern int dup2(int __oldfd, int __newfd);
extern int dup3(int __oldfd, int __newfd, int __flags) __INTRODUCED_IN(21);
-extern int fcntl(int __fd, int __cmd, ...);
-extern int ioctl(int __fd, int __request, ...);
extern int fsync(int __fd);
extern int fdatasync(int __fd) __INTRODUCED_IN(9);
@@ -207,18 +208,12 @@
extern int brk(void* __addr);
extern void* sbrk(ptrdiff_t __increment);
-extern int getopt(int __argc, char* const* __argv, const char* __argstring);
-extern char* optarg;
-extern int optind, opterr, optopt;
-
extern int isatty(int __fd);
extern char* ttyname(int __fd);
extern int ttyname_r(int __fd, char* __buf, size_t __buflen) __INTRODUCED_IN(8);
extern int acct(const char* __filepath);
-long sysconf(int __name);
-
#if __ANDROID_API__ >= 21
int getpagesize(void);
#else
diff --git a/libc/include/wchar.h b/libc/include/wchar.h
index 0a94cee..fe068be 100644
--- a/libc/include/wchar.h
+++ b/libc/include/wchar.h
@@ -97,7 +97,6 @@
extern size_t mbrtowc(wchar_t *, const char *, size_t, mbstate_t *);
extern size_t mbsrtowcs(wchar_t*, const char**, size_t, mbstate_t*);
extern size_t mbsnrtowcs(wchar_t*, const char**, size_t, size_t, mbstate_t*);
-extern size_t mbstowcs(wchar_t *, const char *, size_t);
extern wint_t putwc(wchar_t, FILE *);
extern wint_t putwchar(wchar_t);
extern int swprintf(wchar_t *, size_t, const wchar_t *, ...);