Header improvements.
Remove some __INTRODUCED_IN(16)s, since we don't support anything lower
than 16, so that's a no-op. And add the missing doc comments to those
headers while we're there.
Test: treehugger
Change-Id: I0328c530675564f0f1124bd483da05ad06df3507
diff --git a/libc/include/fcntl.h b/libc/include/fcntl.h
index 1c5d64c..c45c91f 100644
--- a/libc/include/fcntl.h
+++ b/libc/include/fcntl.h
@@ -26,9 +26,14 @@
* SUCH DAMAGE.
*/
-#ifndef _FCNTL_H
+#pragma once
#define _FCNTL_H
+/**
+ * @file fcntl.h
+ * @brief File control operations.
+ */
+
#include <sys/cdefs.h>
#include <sys/types.h>
#include <linux/fadvise.h>
@@ -48,47 +53,180 @@
#ifdef __LP64__
/* LP64 kernels don't have F_*64 defines because their flock is 64-bit. */
+/** Flag for flock(). */
#define F_GETLK64 F_GETLK
+/** Flag for flock(). */
#define F_SETLK64 F_SETLK
+/** Flag for flock(). */
#define F_SETLKW64 F_SETLKW
#endif
+/** Flag for open(). */
#define O_ASYNC FASYNC
+/** Flag for open(). */
#define O_RSYNC O_SYNC
#if __ANDROID_API__ >= __ANDROID_API_L__
+/** Flag for splice(). */
#define SPLICE_F_MOVE 1
+/** Flag for splice(). */
#define SPLICE_F_NONBLOCK 2
+/** Flag for splice(). */
#define SPLICE_F_MORE 4
+/** Flag for splice(). */
#define SPLICE_F_GIFT 8
#endif
#if __ANDROID_API__ >= __ANDROID_API_O__
+/** Flag for sync_file_range(). */
#define SYNC_FILE_RANGE_WAIT_BEFORE 1
+/** Flag for sync_file_range(). */
#define SYNC_FILE_RANGE_WRITE 2
+/** Flag for sync_file_range(). */
#define SYNC_FILE_RANGE_WAIT_AFTER 4
#endif
+/**
+ * [creat(2)](http://man7.org/linux/man-pages/man2/creat.2.html)
+ * creates a file.
+ *
+ * Returns a new file descriptor on success and returns -1 and sets `errno` on
+ * failure.
+ */
int creat(const char* __path, mode_t __mode);
+/** See creat(). */
int creat64(const char* __path, mode_t __mode) __INTRODUCED_IN(21);
+
+/**
+ * [openat(2)](http://man7.org/linux/man-pages/man2/openat.2.html)
+ * opens (and possibly creates) a file.
+ *
+ * Returns a new file descriptor on success and returns -1 and sets `errno` on
+ * failure.
+ */
int openat(int __dir_fd, const char* __path, int __flags, ...);
+/** See openat(). */
int openat64(int __dir_fd, const char* __path, int __flags, ...) __INTRODUCED_IN(21);
+
+/**
+ * [open(2)](http://man7.org/linux/man-pages/man2/open.2.html)
+ * opens (and possibly creates) a file.
+ *
+ * Returns a new file descriptor on success and returns -1 and sets `errno` on
+ * failure.
+ */
int open(const char* __path, int __flags, ...);
+/** See open(). */
int open64(const char* __path, int __flags, ...) __INTRODUCED_IN(21);
+
+/**
+ * [splice(2)](http://man7.org/linux/man-pages/man2/splice.2.html)
+ * splices data to/from a pipe.
+ *
+ * Valid flags are `SPLICE_F_MOVE`, `SPLICE_F_NONBLOCK`, `SPLICE_F_MORE`, and
+ * `SPLICE_F_GIFT`.
+ *
+ * Returns the number of bytes spliced on success and returns -1 and sets
+ * `errno` on failure.
+ *
+ * Available since API level 21.
+ */
ssize_t splice(int __in_fd, off64_t* __in_offset, int __out_fd, off64_t* __out_offset, size_t __length, unsigned int __flags) __INTRODUCED_IN(21);
+
+/**
+ * [tee(2)](http://man7.org/linux/man-pages/man2/tee.2.html)
+ * duplicates data from one pipe to another.
+ *
+ * Valid flags are `SPLICE_F_MOVE`, `SPLICE_F_NONBLOCK`, `SPLICE_F_MORE`, and
+ * `SPLICE_F_GIFT`.
+ *
+ * Returns the number of bytes duplicated on success and returns -1 and sets
+ * `errno` on failure.
+ *
+ * Available since API level 21.
+ */
ssize_t tee(int __in_fd, int __out_fd, size_t __length, unsigned int __flags) __INTRODUCED_IN(21);
+
+/**
+ * [vmsplice(2)](http://man7.org/linux/man-pages/man2/vmsplice.2.html)
+ * splices data to/from a pipe.
+ *
+ * Valid flags are `SPLICE_F_MOVE`, `SPLICE_F_NONBLOCK`, `SPLICE_F_MORE`, and
+ * `SPLICE_F_GIFT`.
+ *
+ * Returns the number of bytes spliced on success and returns -1 and sets
+ * `errno` on failure.
+ *
+ * Available since API level 21.
+ */
ssize_t vmsplice(int __fd, const struct iovec* __iov, size_t __count, unsigned int __flags) __INTRODUCED_IN(21);
+/**
+ * [fallocate(2)](http://man7.org/linux/man-pages/man2/fallocate.2.html)
+ * is a Linux-specific extension of posix_fallocate().
+ *
+ * Valid flags are `FALLOC_FL_KEEP_SIZE`, `FALLOC_FL_PUNCH_HOLE`,
+ * `FALLOC_FL_NO_HIDE_STALE`, `FALLOC_FL_COLLAPSE_RANGE`,
+ * `FALLOC_FL_ZERO_RANGE`, `FALLOC_FL_INSERT_RANGE`, and
+ * `FALLOC_FL_UNSHARE_RANGE`.
+ *
+ * Returns 0 on success and returns -1 and sets `errno` on failure.
+ *
+ * Available since API level 21.
+ */
int fallocate(int __fd, int __mode, off_t __offset, off_t __length) __RENAME_IF_FILE_OFFSET64(fallocate64) __INTRODUCED_IN(21);
+/** See fallocate(). */
int fallocate64(int __fd, int __mode, off64_t __offset, off64_t __length) __INTRODUCED_IN(21);
+
+/**
+ * [posix_fadvise(2)](http://man7.org/linux/man-pages/man2/posix_fadvise.2.html)
+ * declares an expected access pattern for file data.
+ *
+ * Valid flags are `POSIX_FADV_NORMAL`, `POSIX_FADV_RANDOM`,
+ * `POSIX_FADV_SEQUENTIAL`, `POSIX_FADV_WILLNEED`, `POSIX_FADV_DONTNEED`,
+ * and `POSIX_FADV_NOREUSE`.
+ *
+ * Returns 0 on success and returns an error number on failure.
+ *
+ * Available since API level 21.
+ */
int posix_fadvise(int __fd, off_t __offset, off_t __length, int __advice) __RENAME_IF_FILE_OFFSET64(posix_fadvise64) __INTRODUCED_IN(21);
+/** See posix_fadvise(). */
int posix_fadvise64(int __fd, off64_t __offset, off64_t __length, int __advice) __INTRODUCED_IN(21);
+
+/**
+ * [posix_fallocate(2)](http://man7.org/linux/man-pages/man2/posix_fallocate.2.html)
+ * allocates file space.
+ *
+ * Returns 0 on success and returns an error number on failure.
+ *
+ * Available since API level 21.
+ */
int posix_fallocate(int __fd, off_t __offset, off_t __length) __RENAME_IF_FILE_OFFSET64(posix_fallocate64) __INTRODUCED_IN(21);
+/** See posix_fallocate(). */
int posix_fallocate64(int __fd, off64_t __offset, off64_t __length) __INTRODUCED_IN(21);
#if defined(__USE_GNU)
-ssize_t readahead(int __fd, off64_t __offset, size_t __length) __INTRODUCED_IN(16);
+
+/**
+ * [readahead(2)](http://man7.org/linux/man-pages/man2/readahead.2.html)
+ * initiates readahead for the given file.
+ *
+ * Returns 0 on success and returns -1 and sets `errno` on failure.
+ */
+ssize_t readahead(int __fd, off64_t __offset, size_t __length);
+
+/**
+ * [sync_file_range(2)](http://man7.org/linux/man-pages/man2/sync_file_range.2.html)
+ * syncs part of a file with disk.
+ *
+ * Valid flags are `SYNC_FILE_RANGE_WAIT_BEFORE`, `SYNC_FILE_RANGE_WRITE`, and
+ * `SYNC_FILE_RANGE_WAIT_AFTER`.
+ *
+ * Returns 0 on success and returns -1 and sets `errno` on failure.
+ */
int sync_file_range(int __fd, off64_t __offset, off64_t __length, unsigned int __flags) __INTRODUCED_IN(26);
+
#endif
#if defined(__BIONIC_INCLUDE_FORTIFY_HEADERS)
@@ -96,5 +234,3 @@
#endif
__END_DECLS
-
-#endif