Merge branch 'verify-string-includes' into 'master'
verify string header includes See merge request redox-os/relibc!1231
This commit is contained in:
@@ -1,12 +1,20 @@
|
||||
sys_includes = ["stddef.h", "stdint.h", "strings.h"]
|
||||
# POSIX header spec: https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/string.h.html
|
||||
#
|
||||
# Spec quotations relating to includes:
|
||||
# - "The <string.h> header shall define NULL and size_t as described in <stddef.h>."
|
||||
# - "The <string.h> header shall define the locale_t type as described in <locale.h>."
|
||||
# - "Inclusion of the <string.h> header may also make visible all symbols from <stddef.h>."
|
||||
sys_includes = ["stddef.h"]
|
||||
include_guard = "_RELIBC_STRING_H"
|
||||
after_includes = """
|
||||
#include <bits/locale-t.h> // for locale_t
|
||||
#include <bits/locale-t.h> // for locale_t from locale.h
|
||||
"""
|
||||
language = "C"
|
||||
style = "Tag"
|
||||
no_includes = true
|
||||
cpp_compat = true
|
||||
# make size_t actually size_t instead of uintptr_t (which would require stdint.h)
|
||||
usize_is_size_t = true
|
||||
|
||||
[enum]
|
||||
prefix_with_name = true
|
||||
|
||||
@@ -62,8 +62,8 @@ pub unsafe extern "C" fn memchr(
|
||||
|
||||
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/memcmp.html>.
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn memcmp(s1: *const c_void, s2: *const c_void, n: usize) -> c_int {
|
||||
let (div, rem) = (n / mem::size_of::<usize>(), n % mem::size_of::<usize>());
|
||||
pub unsafe extern "C" fn memcmp(s1: *const c_void, s2: *const c_void, n: size_t) -> c_int {
|
||||
let (div, rem) = (n / mem::size_of::<size_t>(), n % mem::size_of::<size_t>());
|
||||
let mut a = s1.cast::<usize>();
|
||||
let mut b = s2.cast::<usize>();
|
||||
for _ in 0..div {
|
||||
@@ -405,6 +405,7 @@ pub unsafe extern "C" fn strlcat(dst: *mut c_char, src: *const c_char, dstsize:
|
||||
src_len + if dst_len > dstsize { dstsize } else { dst_len }
|
||||
}
|
||||
|
||||
/// Non-POSIX, see <https://www.man7.org/linux/man-pages/man3/strsep.3.html>.
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn strsep(str_: *mut *mut c_char, sep: *const c_char) -> *mut c_char {
|
||||
let s = unsafe { *str_ };
|
||||
|
||||
Reference in New Issue
Block a user