Clean up fpathconf(3)/pathconf(3).
fpathconf(3) and pathconf(3) can share code. There's no such
header file as <pathconf.h>. glibc/POSIX and BSD disagree about where
the _POSIX_* definitions should go.
Change-Id: I4a67f1595c9f5fbb26700a131178eedebd6bf712
diff --git a/libc/Android.mk b/libc/Android.mk
index a8778c5..cb55fd4 100644
--- a/libc/Android.mk
+++ b/libc/Android.mk
@@ -49,7 +49,6 @@
bionic/ioctl.c \
bionic/isatty.c \
bionic/memmem.c \
- bionic/pathconf.c \
bionic/pututline.c \
bionic/sched_cpualloc.c \
bionic/sched_cpucount.c \
@@ -142,6 +141,7 @@
bionic/mntent.cpp \
bionic/NetdClientDispatch.cpp \
bionic/open.cpp \
+ bionic/pathconf.cpp \
bionic/pause.cpp \
bionic/pipe.cpp \
bionic/poll.cpp \
diff --git a/libc/bionic/pathconf.c b/libc/bionic/pathconf.c
deleted file mode 100644
index cf81272..0000000
--- a/libc/bionic/pathconf.c
+++ /dev/null
@@ -1,267 +0,0 @@
-/*
- * 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.
- */
-
-#include <pathconf.h>
-#include <sys/vfs.h>
-#include <sys/limits.h>
-#include <errno.h>
-
-/* these may not be defined yet by our headers */
-#ifndef _POSIX_VDISABLE
-#define _POSIX_VDISABLE -1
-#endif
-
-#ifndef _POSIX_SYNC_IO
-#define _POSIX_SYNC_IO -1
-#endif
-
-#ifndef _POSIX_PRIO_IO
-#define _POSIX_PRIO_IO -1
-#endif
-
-#ifndef _POSIX_ASYNC_IO
-#define _POSIX_ASYNC_IO -1
-#endif
-
-
-static long
-__filesizebits( struct statfs* s )
-{
-#define EOL_MAGIC 0x0000U
-
- /* list of known 64-bit aware filesystems */
- static const uint32_t known64[] = {
- EXT2_SUPER_MAGIC,
- UFS_MAGIC,
- REISERFS_SUPER_MAGIC,
- XFS_SUPER_MAGIC,
- SMB_SUPER_MAGIC,
- UDF_SUPER_MAGIC,
- JFS_SUPER_MAGIC,
- NTFS_SB_MAGIC,
- VXFS_SUPER_MAGIC,
- EOL_MAGIC
- };
- int nn = 0;
-
- for (; known64[nn] != EOL_MAGIC; ++nn) {
- if (known64[nn] == s->f_type) {
- return 64;
- }
- }
- return 32;
-}
-
-
-static long
-__link_max( struct statfs* s )
-{
- // These constant values were taken from kernel headers.
- // They're not available in uapi headers.
- static const struct { uint32_t type; int max; } knownMax[] =
- {
- { EXT2_SUPER_MAGIC, 32000 },
- { EXT3_SUPER_MAGIC, 32000 },
- { MINIX_SUPER_MAGIC, 250 },
- { MINIX2_SUPER_MAGIC, 65530 },
- { REISERFS_SUPER_MAGIC, 0xffff - 1000 },
- { UFS_MAGIC, 32000 },
- { EOL_MAGIC, 0 }
- };
- int nn = 0;
-
- for (; knownMax[nn].type != EOL_MAGIC; ++nn) {
- if (knownMax[nn].type == s->f_type) {
- return knownMax[nn].max;
- }
- }
- return LINK_MAX;
-}
-
-static long
-__2_symlinks( struct statfs* s )
-{
- /* list of know filesystems that don't support symlinks */
- static const uint32_t knownNoSymlinks[] = {
- ADFS_SUPER_MAGIC, BFS_MAGIC, CRAMFS_MAGIC,
- EFS_SUPER_MAGIC, MSDOS_SUPER_MAGIC, NTFS_SB_MAGIC,
- QNX4_SUPER_MAGIC,
- EOL_MAGIC
- };
- int nn = 0;
-
- for (; knownNoSymlinks[nn] != EOL_MAGIC; ++nn) {
- if (knownNoSymlinks[nn] == s->f_type) {
- return 0;
- }
- }
- return 1;
-}
-
-static long
-__name_max( struct statfs* s )
-{
- return s->f_namelen;
-}
-
-long
-pathconf(const char *path, int name)
-{
- struct statfs buf;
- int ret = statfs( path, &buf );
-
- if (ret < 0)
- return -1;
-
- switch (name) {
- case _PC_FILESIZEBITS:
- return __filesizebits(&buf);
-
- case _PC_LINK_MAX:
- return __link_max(&buf);
-
- case _PC_MAX_CANON:
- return MAX_CANON;
-
- case _PC_MAX_INPUT:
- return MAX_INPUT;
-
- case _PC_NAME_MAX:
- return __name_max(&buf);
-
- case _PC_PATH_MAX:
- return PATH_MAX;
-
- case _PC_PIPE_BUF:
- return PIPE_BUF;
-
- case _PC_2_SYMLINKS:
- return __2_symlinks(&buf);
-
-#if 0 /* don't know what to do there, the specs are really weird */
- case _PC_ALLOC_SIZE_MIN:
- case _PC_REC_INCR_XFER_SIZE:
- case _PC_REC_MAX_XFER_SIZE:
- case _PC_REC_MIN_XFER_SIZE:
- case _PC_REC_XFER_ALIGN:
-#endif
-
- case _PC_SYMLINK_MAX:
- return -1; /* no limit */
-
- case _PC_CHOWN_RESTRICTED:
- return _POSIX_CHOWN_RESTRICTED;
-
- case _PC_NO_TRUNC:
- return _POSIX_NO_TRUNC;
-
- case _PC_VDISABLE:
- return _POSIX_VDISABLE;
-
- case _PC_ASYNC_IO:
- return _POSIX_ASYNC_IO;
-
- case _PC_PRIO_IO:
- return _POSIX_PRIO_IO;
-
- case _PC_SYNC_IO:
- return _POSIX_SYNC_IO;
-
- default:
- errno = EINVAL;
- return -1;
- }
-}
-
-long fpathconf(int fildes, int name)
-{
- struct statfs buf;
- int ret = fstatfs(fildes, &buf);
-
- if (ret < 0)
- return -1;
-
- switch (name) {
- case _PC_FILESIZEBITS:
- return __filesizebits(&buf);
-
- case _PC_LINK_MAX:
- return __link_max(&buf);
-
- case _PC_MAX_CANON:
- return MAX_CANON;
-
- case _PC_MAX_INPUT:
- return MAX_INPUT;
-
- case _PC_NAME_MAX:
- return __name_max(&buf);
-
- case _PC_PATH_MAX:
- return PATH_MAX;
-
- case _PC_PIPE_BUF:
- return PIPE_BUF;
-
- case _PC_2_SYMLINKS:
- return __2_symlinks(&buf);
-
-#if 0 /* don't know what to do there, the specs are really weird */
- case _PC_ALLOC_SIZE_MIN:
- case _PC_REC_INCR_XFER_SIZE:
- case _PC_REC_MAX_XFER_SIZE:
- case _PC_REC_MIN_XFER_SIZE:
- case _PC_REC_XFER_ALIGN:
-#endif
-
- case _PC_SYMLINK_MAX:
- return -1; /* no limit */
-
- case _PC_CHOWN_RESTRICTED:
- return _POSIX_CHOWN_RESTRICTED;
-
- case _PC_NO_TRUNC:
- return _POSIX_NO_TRUNC;
-
- case _PC_VDISABLE:
- return _POSIX_VDISABLE;
-
- case _PC_ASYNC_IO:
- return _POSIX_ASYNC_IO;
-
- case _PC_PRIO_IO:
- return _POSIX_PRIO_IO;
-
- case _PC_SYNC_IO:
- return _POSIX_SYNC_IO;
-
- default:
- errno = EINVAL;
- return -1;
- }
-}
diff --git a/libc/bionic/pathconf.cpp b/libc/bionic/pathconf.cpp
new file mode 100644
index 0000000..de9e022
--- /dev/null
+++ b/libc/bionic/pathconf.cpp
@@ -0,0 +1,152 @@
+/*
+ * 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.
+ */
+
+#include <unistd.h>
+
+#include <errno.h>
+#include <sys/limits.h>
+#include <sys/vfs.h>
+
+static long __filesizebits(const struct statfs& s) {
+ switch (s.f_type) {
+ case JFFS2_SUPER_MAGIC:
+ case MSDOS_SUPER_MAGIC:
+ case NCP_SUPER_MAGIC:
+ return 32;
+ }
+ // There won't be any new 32-bit file systems.
+ return 64;
+}
+
+static long __link_max(const struct statfs& s) {
+ // These constant values were taken from kernel headers.
+ // They're not available in uapi headers.
+ switch (s.f_type) {
+ case EXT2_SUPER_MAGIC:
+ return 32000;
+ case MINIX_SUPER_MAGIC:
+ return 250;
+ case MINIX2_SUPER_MAGIC:
+ return 65530;
+ case REISERFS_SUPER_MAGIC:
+ return 0xffff - 1000;
+ case UFS_MAGIC:
+ return 32000;
+ }
+ return LINK_MAX;
+}
+
+static long __2_symlinks(const struct statfs& s) {
+ switch (s.f_type) {
+ case ADFS_SUPER_MAGIC:
+ case BFS_MAGIC:
+ case CRAMFS_MAGIC:
+ case EFS_SUPER_MAGIC:
+ case MSDOS_SUPER_MAGIC:
+ case QNX4_SUPER_MAGIC:
+ return 0;
+ }
+ return 1;
+}
+
+static long __pathconf(const struct statfs& s, int name) {
+ switch (name) {
+ case _PC_FILESIZEBITS:
+ return __filesizebits(s);
+
+ case _PC_LINK_MAX:
+ return __link_max(s);
+
+ case _PC_MAX_CANON:
+ return MAX_CANON;
+
+ case _PC_MAX_INPUT:
+ return MAX_INPUT;
+
+ case _PC_NAME_MAX:
+ return s.f_namelen;
+
+ case _PC_PATH_MAX:
+ return PATH_MAX;
+
+ case _PC_PIPE_BUF:
+ return PIPE_BUF;
+
+ case _PC_2_SYMLINKS:
+ return __2_symlinks(s);
+
+#if 0
+ case _PC_ALLOC_SIZE_MIN:
+ case _PC_REC_INCR_XFER_SIZE:
+ case _PC_REC_MAX_XFER_SIZE:
+ case _PC_REC_MIN_XFER_SIZE:
+ case _PC_REC_XFER_ALIGN:
+#endif
+
+ case _PC_SYMLINK_MAX:
+ return -1; /* no limit */
+
+ case _PC_CHOWN_RESTRICTED:
+ return _POSIX_CHOWN_RESTRICTED;
+
+ case _PC_NO_TRUNC:
+ return _POSIX_NO_TRUNC;
+
+ case _PC_VDISABLE:
+ return _POSIX_VDISABLE;
+
+ case _PC_ASYNC_IO:
+ return -1;
+
+ case _PC_PRIO_IO:
+ return -1;
+
+ case _PC_SYNC_IO:
+ return -1;
+
+ default:
+ errno = EINVAL;
+ return -1;
+ }
+}
+
+long pathconf(const char* path, int name) {
+ struct statfs sb;
+ if (statfs(path, &sb) == -1) {
+ return -1;
+ }
+ return __pathconf(sb, name);
+}
+
+long fpathconf(int fd, int name) {
+ struct statfs sb;
+ if (fstatfs(fd, &sb) == -1) {
+ return -1;
+ }
+ return __pathconf(sb, name);
+}
diff --git a/libc/bionic/sysconf.cpp b/libc/bionic/sysconf.cpp
index 24a1ae7..951860d 100644
--- a/libc/bionic/sysconf.cpp
+++ b/libc/bionic/sysconf.cpp
@@ -152,18 +152,12 @@
int sysconf(int name) {
switch (name) {
case _SC_ARG_MAX: return _POSIX_ARG_MAX;
- case _SC_BC_BASE_MAX: return _POSIX2_BC_BASE_MAX;
- case _SC_BC_DIM_MAX: return _POSIX2_BC_DIM_MAX;
- case _SC_BC_SCALE_MAX: return _POSIX2_BC_SCALE_MAX;
- case _SC_BC_STRING_MAX: return _POSIX2_BC_STRING_MAX;
case _SC_CHILD_MAX: return CHILD_MAX;
case _SC_CLK_TCK: return SYSTEM_CLK_TCK;
- case _SC_COLL_WEIGHTS_MAX: return _POSIX2_COLL_WEIGHTS_MAX;
- case _SC_EXPR_NEST_MAX: return _POSIX2_EXPR_NEST_MAX;
case _SC_LINE_MAX: return _POSIX2_LINE_MAX;
case _SC_NGROUPS_MAX: return NGROUPS_MAX;
case _SC_OPEN_MAX: return OPEN_MAX;
- //case _SC_PASS_MAX: return PASS_MAX;
+ case _SC_PASS_MAX: return PASS_MAX;
case _SC_2_C_BIND: return SYSTEM_2_C_BIND;
case _SC_2_C_DEV: return SYSTEM_2_C_DEV;
case _SC_2_C_VERSION: return SYSTEM_2_C_VER;
diff --git a/libc/include/limits.h b/libc/include/limits.h
index f9f0c79..69df082 100644
--- a/libc/include/limits.h
+++ b/libc/include/limits.h
@@ -37,40 +37,6 @@
#include <sys/cdefs.h>
-#if __POSIX_VISIBLE
-#define _POSIX_ARG_MAX 4096
-#define _POSIX_CHILD_MAX 25
-#define _POSIX_LINK_MAX 8
-#define _POSIX_MAX_CANON 255
-#define _POSIX_MAX_INPUT 255
-#define _POSIX_NAME_MAX 14
-#define _POSIX_NGROUPS_MAX 0
-#define _POSIX_OPEN_MAX 16
-#define _POSIX_PATH_MAX 256
-#define _POSIX_PIPE_BUF 512
-#define _POSIX_RE_DUP_MAX 255
-#define _POSIX_SEM_VALUE_MAX 32767
-#define _POSIX_SSIZE_MAX 32767
-#define _POSIX_STREAM_MAX 8
-#define _POSIX_SYMLINK_MAX 255
-#define _POSIX_SYMLOOP_MAX 8
-#define _POSIX_TZNAME_MAX 3
-
-#define _POSIX2_BC_BASE_MAX 99
-#define _POSIX2_BC_DIM_MAX 2048
-#define _POSIX2_BC_SCALE_MAX 99
-#define _POSIX2_BC_STRING_MAX 1000
-#define _POSIX2_COLL_WEIGHTS_MAX 2
-#define _POSIX2_EXPR_NEST_MAX 32
-#define _POSIX2_LINE_MAX 2048
-#define _POSIX2_RE_DUP_MAX _POSIX_RE_DUP_MAX
-
-#if __POSIX_VISIBLE >= 200112
-#define _POSIX_TTY_NAME_MAX 9 /* includes trailing NUL */
-#define _POSIX_LOGIN_NAME_MAX 9 /* includes trailing NUL */
-#endif /* __POSIX_VISIBLE >= 200112 */
-#endif /* __POSIX_VISIBLE */
-
#if __XPG_VISIBLE
#define PASS_MAX 128 /* _PASSWORD_LEN from <pwd.h> */
@@ -126,7 +92,9 @@
/* glibc's PAGE_MASK is the bitwise negation of BSD's! TODO: remove? */
#define PAGE_MASK (~(PAGE_SIZE - 1))
-#define _POSIX_SEMAPHORES 200809L
#define SEM_VALUE_MAX 0x3fffffff
+/* POSIX says these belong in <unistd.h> but BSD has some in <limits.h>. */
+#include <machine/posix_limits.h>
+
#endif /* !_LIMITS_H_ */
diff --git a/libc/include/machine/posix_limits.h b/libc/include/machine/posix_limits.h
new file mode 100644
index 0000000..f906e3b
--- /dev/null
+++ b/libc/include/machine/posix_limits.h
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2014 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 _POSIX_LIMITS_H_
+#define _POSIX_LIMITS_H_
+
+/* TODO: complete and check these. */
+#define _POSIX2_LINE_MAX 2048
+#define _POSIX2_RE_DUP_MAX _POSIX_RE_DUP_MAX
+#define _POSIX_ARG_MAX 4096
+#define _POSIX_CHILD_MAX 25
+#define _POSIX_CHOWN_RESTRICTED 1 /* yes, chown requires appropriate privileges */
+#define _POSIX_FSYNC 1 /* fdatasync() supported */
+#define _POSIX_JOB_CONTROL 1 /* job control is a Linux feature */
+#define _POSIX_LINK_MAX 8
+#define _POSIX_LOGIN_NAME_MAX 9 /* includes trailing NUL */
+#define _POSIX_MAPPED_FILES 1 /* mmap-ed files supported */
+#define _POSIX_MAX_CANON 255
+#define _POSIX_MAX_INPUT 255
+#define _POSIX_MONOTONIC_CLOCK 0 /* the monotonic clock may be available; ask sysconf */
+#define _POSIX_NAME_MAX 14
+#define _POSIX_NGROUPS_MAX 0
+#define _POSIX_NO_TRUNC 1 /* very long pathnames generate an error */
+#define _POSIX_OPEN_MAX 16
+#define _POSIX_PATH_MAX 256
+#define _POSIX_PIPE_BUF 512
+#define _POSIX_PRIORITY_SCHEDULING 1 /* priority scheduling is a Linux feature */
+#define _POSIX_REALTIME_SIGNALS -1 /* for now, this is not supported */
+#define _POSIX_RE_DUP_MAX 255
+#define _POSIX_SAVED_IDS 1 /* saved user ids is a Linux feature */
+#define _POSIX_SEMAPHORES 200809L
+#define _POSIX_SEM_VALUE_MAX 32767
+#define _POSIX_SSIZE_MAX 32767
+#define _POSIX_STREAM_MAX 8
+#define _POSIX_SYMLINK_MAX 255
+#define _POSIX_SYMLOOP_MAX 8
+#define _POSIX_SYNCHRONIZED_IO 1 /* synchronized i/o supported */
+#define _POSIX_THREAD_PRIO_INHERIT 200112L /* linux feature */
+#define _POSIX_THREAD_PRIO_PROTECT 200112L /* linux feature */
+#define _POSIX_THREADS 1 /* we support threads */
+#define _POSIX_THREAD_STACKADDR 1 /* we support thread stack address */
+#define _POSIX_THREAD_STACKSIZE 1 /* we support thread stack size */
+#define _POSIX_TIMERS 1 /* Posix timers are supported */
+#define _POSIX_TTY_NAME_MAX 9 /* includes trailing NUL */
+#define _POSIX_TZNAME_MAX 3
+#define _POSIX_VDISABLE '\0'
+
+#endif /* _POSIX_LIMITS_H_ */
diff --git a/libc/include/pathconf.h b/libc/include/pathconf.h
deleted file mode 100644
index 94f9787..0000000
--- a/libc/include/pathconf.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * 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 _PATHCONF_H_
-#define _PATHCONF_H_
-
-#include <sys/cdefs.h>
-
-__BEGIN_DECLS
-
-/* constants to be used for the 'name' paremeter of pathconf/fpathconf */
-
-#define _PC_FILESIZEBITS 0x0000
-#define _PC_LINK_MAX 0x0001
-#define _PC_MAX_CANON 0x0002
-#define _PC_MAX_INPUT 0x0003
-#define _PC_NAME_MAX 0x0004
-#define _PC_PATH_MAX 0x0005
-#define _PC_PIPE_BUF 0x0006
-#define _PC_2_SYMLINKS 0x0007
-#define _PC_ALLOC_SIZE_MIN 0x0008
-#define _PC_REC_INCR_XFER_SIZE 0x0009
-#define _PC_REC_MAX_XFER_SIZE 0x000a
-#define _PC_REC_MIN_XFER_SIZE 0x000b
-#define _PC_REC_XFER_ALIGN 0x000c
-#define _PC_SYMLINK_MAX 0x000d
-#define _PC_CHOWN_RESTRICTED 0x000e
-#define _PC_NO_TRUNC 0x000f
-#define _PC_VDISABLE 0x0010
-#define _PC_ASYNC_IO 0x0011
-#define _PC_PRIO_IO 0x0012
-#define _PC_SYNC_IO 0x0013
-
-extern long fpathconf(int fildes, int name);
-extern long pathconf(const char *path, int name);
-
-__END_DECLS
-
-#endif /* _PATHCONF_H_ */
-
diff --git a/libc/include/sys/limits.h b/libc/include/sys/limits.h
index c50eb10..edb8c47 100644
--- a/libc/include/sys/limits.h
+++ b/libc/include/sys/limits.h
@@ -135,31 +135,6 @@
#define _XOPEN_REALTIME -1 /* we don't support all these functions */
#define _XOPEN_REALTIME_THREADS -1 /* same here */
-#define _POSIX_REALTIME_SIGNALS -1 /* for now, this is not supported */
-#define _POSIX_PRIORITY_SCHEDULING 1 /* priority scheduling is a Linux feature */
-#define _POSIX_TIMERS 1 /* Posix timers are supported */
-#undef _POSIX_ASYNCHRONOUS_IO /* aio_ functions are not supported */
-#define _POSIX_SYNCHRONIZED_IO 1 /* synchronized i/o supported */
-#define _POSIX_FSYNC 1 /* fdatasync() supported */
-#define _POSIX_MAPPED_FILES 1 /* mmap-ed files supported */
-
-/* XXX: TODO: complete and check list here */
-
-
-#define _POSIX_THREADS 1 /* we support threads */
-#define _POSIX_THREAD_STACKADDR 1 /* we support thread stack address */
-#define _POSIX_THREAD_STACKSIZE 1 /* we support thread stack size */
-#define _POSIX_THREAD_PRIO_INHERIT 200112L /* linux feature */
-#define _POSIX_THREAD_PRIO_PROTECT 200112L /* linux feature */
-
-#undef _POSIX_PROCESS_SHARED /* we don't support process-shared synchronization */
-#undef _POSIX_THREAD_SAFE_FUNCTIONS /* most functions are, but not everything yet */
-#define _POSIX_CHOWN_RESTRICTED 1 /* yes, chown requires appropriate privileges */
-#define _POSIX_MONOTONIC_CLOCK 0 /* the monotonic clock may be available; ask sysconf */
-#define _POSIX_NO_TRUNC 1 /* very long pathnames generate an error */
-#define _POSIX_SAVED_IDS 1 /* saved user ids is a Linux feature */
-#define _POSIX_JOB_CONTROL 1 /* job control is a Linux feature */
-
#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4 /* the minimum mandated by POSIX */
#define PTHREAD_DESTRUCTOR_ITERATIONS _POSIX_THREAD_DESTRUCTOR_ITERATIONS
#define _POSIX_THREAD_KEYS_MAX 128 /* the minimum mandated by POSIX */
@@ -167,5 +142,4 @@
#define _POSIX_THREAD_THREADS_MAX 64 /* the minimum mandated by POSIX */
#define PTHREAD_THREADS_MAX /* bionic has no specific limit */
-
#endif
diff --git a/libc/include/unistd.h b/libc/include/unistd.h
index 34ae2bc..20bc1a3 100644
--- a/libc/include/unistd.h
+++ b/libc/include/unistd.h
@@ -34,7 +34,6 @@
#include <sys/types.h>
#include <sys/select.h>
#include <sys/sysconf.h>
-#include <pathconf.h>
__BEGIN_DECLS
@@ -48,6 +47,29 @@
#define SEEK_CUR 1
#define SEEK_END 2
+#define _PC_FILESIZEBITS 0
+#define _PC_LINK_MAX 1
+#define _PC_MAX_CANON 2
+#define _PC_MAX_INPUT 3
+#define _PC_NAME_MAX 4
+#define _PC_PATH_MAX 5
+#define _PC_PIPE_BUF 6
+#define _PC_2_SYMLINKS 7
+#define _PC_ALLOC_SIZE_MIN 8
+#define _PC_REC_INCR_XFER_SIZE 9
+#define _PC_REC_MAX_XFER_SIZE 10
+#define _PC_REC_MIN_XFER_SIZE 11
+#define _PC_REC_XFER_ALIGN 12
+#define _PC_SYMLINK_MAX 13
+#define _PC_CHOWN_RESTRICTED 14
+#define _PC_NO_TRUNC 15
+#define _PC_VDISABLE 16
+#define _PC_ASYNC_IO 17
+#define _PC_PRIO_IO 18
+#define _PC_SYNC_IO 19
+
+#include <machine/posix_limits.h>
+
extern char** environ;
extern __noreturn void _exit(int);
@@ -96,6 +118,9 @@
extern void endusershell(void);
+extern long fpathconf(int, int);
+extern long pathconf(const char*, int);
+
/* Macros for access() */
#define R_OK 4 /* Read */