Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
relibc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
redox-os
relibc
Commits
39f564ea
Commit
39f564ea
authored
1 month ago
by
Peter Limkilde Svendsen
Browse files
Options
Downloads
Patches
Plain Diff
Add docs and deprecations for strings.h
parent
7edc231f
No related branches found
Branches containing commit
No related tags found
1 merge request
!611
Add docs, missing functions for strings.h
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/header/strings/mod.rs
+37
-1
37 additions, 1 deletion
src/header/strings/mod.rs
with
37 additions
and
1 deletion
src/header/strings/mod.rs
+
37
−
1
View file @
39f564ea
//! 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.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment