Fix a lot of man7 links to be more specific.
Bug: https://github.com/android/ndk/issues/2113
Change-Id: Ifc3add91c39422985c63e895dc32443b8f736c9d
diff --git a/libc/include/bits/sockaddr_storage.h b/libc/include/bits/sockaddr_storage.h
index effafab..4b3bfb6 100644
--- a/libc/include/bits/sockaddr_storage.h
+++ b/libc/include/bits/sockaddr_storage.h
@@ -40,7 +40,7 @@
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wnullability-completeness"
/**
- * [sockaddr_storage](https://man7.org/linux/man-pages/man3/sockaddr.3type.html)
+ * [sockaddr_storage](https://man7.org/linux/man-pages/man3/sockaddr_storage.3type.html)
* is a structure large enough to contain any other `sockaddr_*` type, used to
* pass socket addresses without needing to know what kind of socket address
* you're passing.
diff --git a/libc/include/dirent.h b/libc/include/dirent.h
index 8058cfb..aecaca6 100644
--- a/libc/include/dirent.h
+++ b/libc/include/dirent.h
@@ -87,7 +87,7 @@
#define d_fileno d_ino
-/** The structure returned by opendir()/fopendir(). */
+/** The structure returned by opendir()/fdopendir(). */
typedef struct DIR DIR;
/**
@@ -99,7 +99,7 @@
DIR* _Nullable opendir(const char* _Nonnull __path);
/**
- * [fopendir(3)](https://man7.org/linux/man-pages/man3/opendir.3.html)
+ * [fdopendir(3)](https://man7.org/linux/man-pages/man3/fdopendir.3.html)
* opens a directory stream for the directory at `__dir_fd`.
*
* Returns null and sets `errno` on failure.
diff --git a/libc/include/err.h b/libc/include/err.h
index 4a1841b..81b11e3 100644
--- a/libc/include/err.h
+++ b/libc/include/err.h
@@ -74,7 +74,7 @@
__noreturn void errx(int __status, const char* _Nullable __fmt, ...) __printflike(2, 3);
/**
- * [verrx(3)](https://man7.org/linux/man-pages/man3/err.3.html) outputs the program name, and
+ * [verrx(3)](https://man7.org/linux/man-pages/man3/verrx.3.html) outputs the program name, and
* the vprintf()-like formatted message.
*
* Calls exit() with `__status`.
@@ -108,7 +108,7 @@
void warnx(const char* _Nullable __fmt, ...) __printflike(1, 2);
/**
- * [vwarnx(3)](https://man7.org/linux/man-pages/man3/warn.3.html) outputs the program name, and
+ * [vwarnx(3)](https://man7.org/linux/man-pages/man3/vwarnx.3.html) outputs the program name, and
* the vprintf()-like formatted message.
*
* New code should consider error() in `<error.h>`.
diff --git a/libc/include/getopt.h b/libc/include/getopt.h
index 1a30eb7..56892aa 100644
--- a/libc/include/getopt.h
+++ b/libc/include/getopt.h
@@ -70,12 +70,12 @@
__BEGIN_DECLS
/**
- * [getopt_long(3)](https://man7.org/linux/man-pages/man3/getopt.3.html) parses command-line options.
+ * [getopt_long(3)](https://man7.org/linux/man-pages/man3/getopt_long.3.html) parses command-line options.
*/
int getopt_long(int __argc, char* _Nonnull const* _Nonnull __argv, const char* _Nonnull __options, const struct option* _Nonnull __long_options, int* _Nullable __long_index);
/**
- * [getopt_long_only(3)](https://man7.org/linux/man-pages/man3/getopt.3.html) parses command-line options.
+ * [getopt_long_only(3)](https://man7.org/linux/man-pages/man3/getopt_long_only.3.html) parses command-line options.
*/
int getopt_long_only(int __argc, char* _Nonnull const* _Nonnull __argv, const char* _Nonnull __options, const struct option* _Nonnull __long_options, int* _Nullable __long_index);
diff --git a/libc/include/malloc.h b/libc/include/malloc.h
index ac27467..ba68401 100644
--- a/libc/include/malloc.h
+++ b/libc/include/malloc.h
@@ -77,8 +77,8 @@
__nodiscard void* _Nullable realloc(void* _Nullable __ptr, size_t __byte_count) __BIONIC_ALLOC_SIZE(2);
/**
- * [reallocarray(3)](https://man7.org/linux/man-pages/man3/realloc.3.html) resizes
- * allocated memory on the heap.
+ * [reallocarray(3)](https://man7.org/linux/man-pages/man3/reallocarray.3.html)
+ * resizes allocated memory on the heap.
*
* Equivalent to `realloc(__ptr, __item_count * __item_size)` but fails if the
* multiplication overflows.
diff --git a/libc/include/sched.h b/libc/include/sched.h
index 7a2dcad..58dd9a6 100644
--- a/libc/include/sched.h
+++ b/libc/include/sched.h
@@ -236,12 +236,12 @@
int sched_getaffinity(pid_t __pid, size_t __set_size, cpu_set_t* _Nonnull __set);
/**
- * [CPU_ZERO](https://man7.org/linux/man-pages/man3/CPU_SET.3.html) clears all
+ * [CPU_ZERO](https://man7.org/linux/man-pages/man3/CPU_ZERO.3.html) clears all
* bits in a static CPU set.
*/
#define CPU_ZERO(set) CPU_ZERO_S(sizeof(cpu_set_t), set)
/**
- * [CPU_ZERO_S](https://man7.org/linux/man-pages/man3/CPU_SET.3.html) clears all
+ * [CPU_ZERO_S](https://man7.org/linux/man-pages/man3/CPU_ZERO_S.3.html) clears all
* bits in a dynamic CPU set allocated by `CPU_ALLOC`.
*/
#define CPU_ZERO_S(setsize, set) __builtin_memset(set, 0, setsize)
@@ -252,7 +252,7 @@
*/
#define CPU_SET(cpu, set) CPU_SET_S(cpu, sizeof(cpu_set_t), set)
/**
- * [CPU_SET_S](https://man7.org/linux/man-pages/man3/CPU_SET.3.html) sets one
+ * [CPU_SET_S](https://man7.org/linux/man-pages/man3/CPU_SET_S.3.html) sets one
* bit in a dynamic CPU set allocated by `CPU_ALLOC`.
*/
#define CPU_SET_S(cpu, setsize, set) \
@@ -263,12 +263,12 @@
} while (0)
/**
- * [CPU_CLR](https://man7.org/linux/man-pages/man3/CPU_SET.3.html) clears one
+ * [CPU_CLR](https://man7.org/linux/man-pages/man3/CPU_CLR.3.html) clears one
* bit in a static CPU set.
*/
#define CPU_CLR(cpu, set) CPU_CLR_S(cpu, sizeof(cpu_set_t), set)
/**
- * [CPU_CLR_S](https://man7.org/linux/man-pages/man3/CPU_SET.3.html) clears one
+ * [CPU_CLR_S](https://man7.org/linux/man-pages/man3/CPU_CLR_S.3.html) clears one
* bit in a dynamic CPU set allocated by `CPU_ALLOC`.
*/
#define CPU_CLR_S(cpu, setsize, set) \
@@ -279,12 +279,12 @@
} while (0)
/**
- * [CPU_ISSET](https://man7.org/linux/man-pages/man3/CPU_SET.3.html) tests
+ * [CPU_ISSET](https://man7.org/linux/man-pages/man3/CPU_ISSET.3.html) tests
* whether the given bit is set in a static CPU set.
*/
#define CPU_ISSET(cpu, set) CPU_ISSET_S(cpu, sizeof(cpu_set_t), set)
/**
- * [CPU_ISSET_S](https://man7.org/linux/man-pages/man3/CPU_SET.3.html) tests
+ * [CPU_ISSET_S](https://man7.org/linux/man-pages/man3/CPU_ISSET_S.3.html) tests
* whether the given bit is set in a dynamic CPU set allocated by `CPU_ALLOC`.
*/
#define CPU_ISSET_S(cpu, setsize, set) \
@@ -296,58 +296,58 @@
}))
/**
- * [CPU_COUNT](https://man7.org/linux/man-pages/man3/CPU_SET.3.html) counts
+ * [CPU_COUNT](https://man7.org/linux/man-pages/man3/CPU_COUNT.3.html) counts
* how many bits are set in a static CPU set.
*/
#define CPU_COUNT(set) CPU_COUNT_S(sizeof(cpu_set_t), set)
/**
- * [CPU_COUNT_S](https://man7.org/linux/man-pages/man3/CPU_SET.3.html) counts
+ * [CPU_COUNT_S](https://man7.org/linux/man-pages/man3/CPU_COUNT_S.3.html) counts
* how many bits are set in a dynamic CPU set allocated by `CPU_ALLOC`.
*/
#define CPU_COUNT_S(setsize, set) __sched_cpucount((setsize), (set))
int __sched_cpucount(size_t __set_size, const cpu_set_t* _Nonnull __set);
/**
- * [CPU_EQUAL](https://man7.org/linux/man-pages/man3/CPU_SET.3.html) tests
+ * [CPU_EQUAL](https://man7.org/linux/man-pages/man3/CPU_EQUAL.3.html) tests
* whether two static CPU sets have the same bits set and cleared as each other.
*/
#define CPU_EQUAL(set1, set2) CPU_EQUAL_S(sizeof(cpu_set_t), set1, set2)
/**
- * [CPU_EQUAL_S](https://man7.org/linux/man-pages/man3/CPU_SET.3.html) tests
+ * [CPU_EQUAL_S](https://man7.org/linux/man-pages/man3/CPU_EQUAL_S.3.html) tests
* whether two dynamic CPU sets allocated by `CPU_ALLOC` have the same bits
* set and cleared as each other.
*/
#define CPU_EQUAL_S(setsize, set1, set2) (__builtin_memcmp(set1, set2, setsize) == 0)
/**
- * [CPU_AND](https://man7.org/linux/man-pages/man3/CPU_SET.3.html) ands two
+ * [CPU_AND](https://man7.org/linux/man-pages/man3/CPU_AND.3.html) ands two
* static CPU sets.
*/
#define CPU_AND(dst, set1, set2) __CPU_OP(dst, set1, set2, &)
/**
- * [CPU_AND_S](https://man7.org/linux/man-pages/man3/CPU_SET.3.html) ands two
+ * [CPU_AND_S](https://man7.org/linux/man-pages/man3/CPU_AND_S.3.html) ands two
* dynamic CPU sets allocated by `CPU_ALLOC`.
*/
#define CPU_AND_S(setsize, dst, set1, set2) __CPU_OP_S(setsize, dst, set1, set2, &)
/**
- * [CPU_OR](https://man7.org/linux/man-pages/man3/CPU_SET.3.html) ors two
+ * [CPU_OR](https://man7.org/linux/man-pages/man3/CPU_OR.3.html) ors two
* static CPU sets.
*/
#define CPU_OR(dst, set1, set2) __CPU_OP(dst, set1, set2, |)
/**
- * [CPU_OR_S](https://man7.org/linux/man-pages/man3/CPU_SET.3.html) ors two
+ * [CPU_OR_S](https://man7.org/linux/man-pages/man3/CPU_OR_S.3.html) ors two
* dynamic CPU sets allocated by `CPU_ALLOC`.
*/
#define CPU_OR_S(setsize, dst, set1, set2) __CPU_OP_S(setsize, dst, set1, set2, |)
/**
- * [CPU_XOR](https://man7.org/linux/man-pages/man3/CPU_SET.3.html)
+ * [CPU_XOR](https://man7.org/linux/man-pages/man3/CPU_XOR.3.html)
* exclusive-ors two static CPU sets.
*/
#define CPU_XOR(dst, set1, set2) __CPU_OP(dst, set1, set2, ^)
/**
- * [CPU_XOR_S](https://man7.org/linux/man-pages/man3/CPU_SET.3.html)
+ * [CPU_XOR_S](https://man7.org/linux/man-pages/man3/CPU_XOR_S.3.html)
* exclusive-ors two dynamic CPU sets allocated by `CPU_ALLOC`.
*/
#define CPU_XOR_S(setsize, dst, set1, set2) __CPU_OP_S(setsize, dst, set1, set2, ^)
@@ -365,21 +365,21 @@
} while (0)
/**
- * [CPU_ALLOC_SIZE](https://man7.org/linux/man-pages/man3/CPU_SET.3.html)
+ * [CPU_ALLOC_SIZE](https://man7.org/linux/man-pages/man3/CPU_ALLOC_SIZE.3.html)
* returns the size of a CPU set large enough for CPUs in the range 0..count-1.
*/
#define CPU_ALLOC_SIZE(count) \
__CPU_ELT((count) + (__CPU_BITS - 1)) * sizeof(__CPU_BITTYPE)
/**
- * [CPU_ALLOC](https://man7.org/linux/man-pages/man3/CPU_SET.3.html)
+ * [CPU_ALLOC](https://man7.org/linux/man-pages/man3/CPU_ALLOC.3.html)
* allocates a CPU set large enough for CPUs in the range 0..count-1.
*/
#define CPU_ALLOC(count) __sched_cpualloc((count))
cpu_set_t* _Nullable __sched_cpualloc(size_t __count);
/**
- * [CPU_FREE](https://man7.org/linux/man-pages/man3/CPU_SET.3.html)
+ * [CPU_FREE](https://man7.org/linux/man-pages/man3/CPU_FREE.3.html)
* deallocates a CPU set allocated by `CPU_ALLOC`.
*/
#define CPU_FREE(set) __sched_cpufree((set))
diff --git a/libc/include/string.h b/libc/include/string.h
index 79aac91..a0a7cc4 100644
--- a/libc/include/string.h
+++ b/libc/include/string.h
@@ -160,7 +160,7 @@
#endif
/**
- * [strerrorname_np(3)](https://man7.org/linux/man-pages/man3/strerrordesc_np.3.html)
+ * [strerrorname_np(3)](https://man7.org/linux/man-pages/man3/strerrorname_np.3.html)
* returns the name of the errno constant corresponding to its argument.
* `strerrorname_np(38)` would return "ENOSYS", because `ENOSYS` is errno 38. This
* is mostly useful for error reporting in cases where a string like "ENOSYS" is
diff --git a/libc/include/sys/klog.h b/libc/include/sys/klog.h
index 237d2e2..6ee410f 100644
--- a/libc/include/sys/klog.h
+++ b/libc/include/sys/klog.h
@@ -61,7 +61,7 @@
#define KLOG_SIZE_BUFFER 10
/**
- * [klogctl(2)](https://man7.org/linux/man-pages/man2/syslog.2.html) operates on the kernel log.
+ * [klogctl(3)](https://man7.org/linux/man-pages/man2/klogctl.3.html) operates on the kernel log.
*
* This system call is not available to applications.
* Use syslog() or `<android/log.h>` instead.
diff --git a/libc/include/sys/mman.h b/libc/include/sys/mman.h
index 38cbf2f..3fe1f9c 100644
--- a/libc/include/sys/mman.h
+++ b/libc/include/sys/mman.h
@@ -126,7 +126,7 @@
int mlock(const void* _Nonnull __addr, size_t __size);
/**
- * [mlock2(2)](https://man7.org/linux/man-pages/man2/mlock.2.html)
+ * [mlock2(2)](https://man7.org/linux/man-pages/man2/mlock2.2.html)
* locks pages (preventing swapping), with optional flags.
*
* Available since API level 30.
diff --git a/libc/include/sys/select.h b/libc/include/sys/select.h
index 4183d90..685e6ac 100644
--- a/libc/include/sys/select.h
+++ b/libc/include/sys/select.h
@@ -137,7 +137,7 @@
int select(int __max_fd_plus_one, fd_set* _Nullable __read_fds, fd_set* _Nullable __write_fds, fd_set* _Nullable __exception_fds, struct timeval* _Nullable __timeout);
/**
- * [pselect(2)](https://man7.org/linux/man-pages/man2/select.2.html) waits on a
+ * [pselect(2)](https://man7.org/linux/man-pages/man2/pselect.2.html) waits on a
* set of file descriptors.
*
* New code should prefer ppoll() from <poll.h> instead,
diff --git a/libc/include/sys/stat.h b/libc/include/sys/stat.h
index 0b4b248..b6cdb14 100644
--- a/libc/include/sys/stat.h
+++ b/libc/include/sys/stat.h
@@ -320,7 +320,7 @@
int utimensat(int __dir_fd, const char* __BIONIC_COMPLICATED_NULLNESS __path, const struct timespec __times[_Nullable 2], int __flags);
/**
- * [futimens(2)](https://man7.org/linux/man-pages/man2/utimensat.2.html) sets
+ * [futimens(3)](https://man7.org/linux/man-pages/man3/futimens.3.html) sets
* the given file descriptor's timestamp.
*
* `__times[0]` is the access time (atime), and `__times[1]` the last modification time (mtime).
diff --git a/libc/include/time.h b/libc/include/time.h
index 6c9b761..777e648 100644
--- a/libc/include/time.h
+++ b/libc/include/time.h
@@ -281,7 +281,7 @@
char* _Nullable ctime(const time_t* _Nonnull __t);
/**
- * [ctime_r(3)](https://man7.org/linux/man-pages/man3/ctime.3p.html) formats
+ * [ctime_r(3)](https://man7.org/linux/man-pages/man3/ctime_r.3p.html) formats
* the time `tm` as a string in the given buffer `buf`.
*
* Returns a pointer to a string on success, and returns NULL on failure.
diff --git a/libc/include/unistd.h b/libc/include/unistd.h
index e623339..808568a 100644
--- a/libc/include/unistd.h
+++ b/libc/include/unistd.h
@@ -283,7 +283,7 @@
int chdir(const char* _Nonnull __path);
/**
- * [fchdir(2)](https://man7.org/linux/man-pages/man2/chdir.2.html) changes
+ * [fchdir(2)](https://man7.org/linux/man-pages/man2/fchdir.2.html) changes
* the current working directory to the given fd.
*
* This function affects all threads in the process, so is generally a bad idea