From 39f564ea230b2750b7ca257bf7dc1ca9d01405ba Mon Sep 17 00:00:00 2001
From: Peter Limkilde Svendsen <peter.limkilde@gmail.com>
Date: Mon, 3 Feb 2025 22:37:37 +0100
Subject: [PATCH] Add docs and deprecations for strings.h

---
 src/header/strings/mod.rs | 38 +++++++++++++++++++++++++++++++++++++-
 1 file changed, 37 insertions(+), 1 deletion(-)

diff --git a/src/header/strings/mod.rs b/src/header/strings/mod.rs
index 35377ff8..6b017fe4 100644
--- a/src/header/strings/mod.rs
+++ b/src/header/strings/mod.rs
@@ -1,4 +1,6 @@
-//! strings implementation for Redox, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/strings.h.html
+//! `strings.h` implementation.
+//!
+//! See <https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/strings.h.html>.
 
 // TODO: set this for entire crate when possible
 #![deny(unsafe_op_in_unsafe_fn)]
@@ -15,11 +17,23 @@ use crate::{
     platform::types::*,
 };
 
+/// See <https://pubs.opengroup.org/onlinepubs/009695399/functions/bcmp.html>.
+///
+/// # Deprecation
+/// The `bcmp()` function was marked legacy in the Open Group Base
+/// Specifications Issue 6, and removed in Issue 7.
+#[deprecated]
 #[no_mangle]
 pub unsafe extern "C" fn bcmp(first: *const c_void, second: *const c_void, n: size_t) -> c_int {
     unsafe { string::memcmp(first, second, n) }
 }
 
+/// See <https://pubs.opengroup.org/onlinepubs/009695399/functions/bcopy.html>.
+///
+/// # Deprecation
+/// The `bcopy()` function was marked legacy in the Open Group Base
+/// Specifications Issue 6, and removed in Issue 7.
+#[deprecated]
 #[no_mangle]
 pub unsafe extern "C" fn bcopy(src: *const c_void, dst: *mut c_void, n: size_t) {
     unsafe {
@@ -27,6 +41,12 @@ pub unsafe extern "C" fn bcopy(src: *const c_void, dst: *mut c_void, n: size_t)
     }
 }
 
+/// See <https://pubs.opengroup.org/onlinepubs/009695399/functions/bzero.html>.
+///
+/// # Deprecation
+/// The `bzero()` function was marked legacy in the Open Group Base
+/// Specifications Issue 6, and removed in Issue 7.
+#[deprecated]
 #[no_mangle]
 pub unsafe extern "C" fn bzero(dst: *mut c_void, n: size_t) {
     unsafe {
@@ -34,6 +54,7 @@ pub unsafe extern "C" fn bzero(dst: *mut c_void, n: size_t) {
     }
 }
 
+/// Non-POSIX, see <https://man7.org/linux/man-pages/man3/bzero.3.html>.
 #[no_mangle]
 pub unsafe extern "C" fn explicit_bzero(s: *mut c_void, n: size_t) {
     for i in 0..n {
@@ -46,6 +67,7 @@ pub unsafe extern "C" fn explicit_bzero(s: *mut c_void, n: size_t) {
     }
 }
 
+/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/ffs.html>.
 #[no_mangle]
 pub extern "C" fn ffs(i: c_int) -> c_int {
     if i == 0 {
@@ -54,16 +76,29 @@ pub extern "C" fn ffs(i: c_int) -> c_int {
     1 + i.trailing_zeros() as c_int
 }
 
+/// See <https://pubs.opengroup.org/onlinepubs/009695399/functions/index.html>.
+///
+/// # Deprecation
+/// The `index()` function was marked legacy in the Open Group Base
+/// Specifications Issue 6, and removed in Issue 7.
+#[deprecated]
 #[no_mangle]
 pub unsafe extern "C" fn index(s: *const c_char, c: c_int) -> *mut c_char {
     unsafe { string::strchr(s, c) }
 }
 
+/// See <https://pubs.opengroup.org/onlinepubs/009695399/functions/rindex.html>.
+///
+/// # Deprecation
+/// The `rindex()` function was marked legacy in the Open Group Base
+/// Specifications Issue 6, and removed in Issue 7.
+#[deprecated]
 #[no_mangle]
 pub unsafe extern "C" fn rindex(s: *const c_char, c: c_int) -> *mut c_char {
     unsafe { string::strrchr(s, c) }
 }
 
+/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/strcasecmp.html>.
 #[no_mangle]
 pub unsafe extern "C" fn strcasecmp(s1: *const c_char, s2: *const c_char) -> c_int {
     // SAFETY: the caller must ensure that s1 and s2 point to nul-terminated buffers.
@@ -74,6 +109,7 @@ pub unsafe extern "C" fn strcasecmp(s1: *const c_char, s2: *const c_char) -> c_i
     inner_casecmp(zipped)
 }
 
+/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/strcasecmp.html>.
 #[no_mangle]
 pub unsafe extern "C" fn strncasecmp(s1: *const c_char, s2: *const c_char, n: size_t) -> c_int {
     // SAFETY: the caller must ensure that s1 and s2 point to nul-terminated buffers.
-- 
GitLab