aboutsummaryrefslogtreecommitdiff
path: root/arch/all/core/include/string.h
blob: c5efe853b8ec19083493a2e2c0e0efed7e246560 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/* ****************************************************************************
 * string.h -- String utilities.
 *
 * Copyright (C) 2017 Thomas "Cakeisalie5" Touhey <thomas@touhey.fr>
 *
 * This file is part of the 'all/core' module in libcarrot, an experimental
 * modular libc project.
 *
 * This file is free software: you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation, either version 3 of the License, or (at your option)
 * any later version.
 *
 * This file is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Lesser Public License
 * for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this file. If not, see <http://www.gnu.org/licenses/>.
 * ************************************************************************* */
#include <cdefs.h>
#include <stddef.h>
__BEGIN_DECLS
__BEGIN_NAMESPACE_STD

/* ************************************************************************* */
/*  Raw memory related functions                                             */
/* ************************************************************************* */
/* copy memory */
extern __nonnull(1, __dst) __nonnull(2, __src)
void *memcpy  _OF((void *__restrict __dst, const void *__restrict __src,
	size_t __n)) __THROW;
extern __nonnull(1, __dst) __nonnull(2, __src)
void *memmove _OF((void *__restrict __dst, const void *__restrict __src,
	size_t __n)) __THROW;
extern __nonnull(1, __dst) __nonnull(2, __src)
void *memccpy _OF((void *__restrict __dst, const void *__restrict __src,
	int __c, size_t __n)) __THROW;

/* compare memory */
extern __nonnull(1, __s) __nonnull(2, __t) __pure
int memcmp _OF((const void *__s, const void *__t, size_t __n)) __THROW;

/* look for a character in a memory area */
extern __nonnull(1, __s) __pure
void *memchr _OF((const void *__s, int __c, size_t __n)) __THROW;

/* initialize a memory area with a character */
extern __nonnull(1, __s)
void *memset _OF((void *__s, int __c, size_t __n)) __THROW;
/* ************************************************************************* */
/*  String-related functions                                                 */
/* ************************************************************************* */
/* find out the length of a string */
extern __nonnull(1, __s) __pure
size_t strlen  _OF((const char __s[__notnull])) __THROW;
extern __nonnull(1, __s) __pure
size_t strnlen _OF((const char __s[__notnull], size_t __maxlen)) __THROW;

/* copy a string */
extern __nonnull(1, __dst) __nonnull(2, __src)
char *strcpy  _OF((char __dst[__notnull], const char __src[__notnull]))
	__THROW;
extern __nonnull(1, __dst) __nonnull(2, __src)
char *strncpy _OF((char *__dst, const char __src[__notnull], size_t __n))
	__THROW;

/* catenate a string */
extern __nonnull(1, __str) __nonnull(2, __src)
char *strcat  _OF((char *__str, const char *__src)) __THROW;
extern __nonnull(1, __str) __nonnull(2, __src)
char *strncat _OF((char *__str, const char *__src, size_t __n)) __THROW;

/* compare strings */
extern __nonnull(1, __s) __nonnull(2, __t) __wur
int strcmp  _OF((const char *__s, const char *__t)) __THROW;
extern __nonnull(1, __s) __nonnull(2, __t) __wur
int strncmp _OF((const char *__s, const char *__t, size_t __n)) __THROW;

/* look for a characters in a string */
extern __nonnull(1, __s) __pure
char *strchr  _OF((const char *__s, int __c)) __THROW;
extern __nonnull(1, __s) __pure
char *strrchr _OF((const char *__s, int __c)) __THROW;
extern __nonnull(1, __s) __nonnull(2, __accept) __pure
char *strpbrk _OF((const char *__s, const char *__accept)) __THROW;

/* look for a string in another string */
extern __nonnull(1, __haystack) __nonnull(2, __needle) __pure
char *strstr _OF((const char *__haystack, const char *__needle)) __THROW;

/* check the length of a prefix */
extern __nonnull(1, __s) __nonnull(2, __accept) __pure
size_t strspn  _OF((const char *__s, const char *__accept)) __THROW;
extern __nonnull(1, __s) __nonnull(2, __reject) __pure
size_t strcspn _OF((const char *__s, const char *__reject)) __THROW;

__END_NAMESPACE_STD
__END_DECLS