Embedded Artistry libc
C Standard Library Support for Bare-metal Systems
|
Go to the source code of this file.
Functions | |
int | memcmp (const void *s1, const void *s2, size_t n) |
Compares the first n characters of the two objects pointed to by s1 and s2. More... | |
void * | memset (void *dest, int c, size_t n) |
Copies the value c into each of the first n characters of the object pointed to by dest. More... | |
void * | memcpy (void *__restrict dest, const void *__restrict src, size_t n) |
Copies n characters from the object pointed to by src to the object pointed to by dest. More... | |
void * | memmove (void *dest, const void *src, size_t n) |
Copies n characters from the object pointed to by src to the object pointed to by dest. More... | |
void * | memchr (const void *s, int c, size_t n) |
Finds the first occurrence of c in the initial n characters of the object pointed to by s. More... | |
void * | memmem (const void *l, size_t l_len, const void *s, size_t s_len) |
Find substring s in memory area l. More... | |
size_t | strlen (const char *str) |
Returns the length of the given null-terminated byte string. More... | |
size_t | strnlen (const char *str, size_t maxlen) |
Returns the length of the given null-terminated byte string. More... | |
char * | strcpy (char *__restrict dst, const char *__restrict src) |
Copies the null-terminated byte string pointed to by src to the character array whose first element is pointed to by dest. More... | |
char * | strncpy (char *__restrict dst, const char *__restrict src, size_t maxlen) |
Copies at most maxlen characters of the character array pointed to by src to character array pointed to by dest. More... | |
char * | strstr (const char *string, const char *substring) |
Finds the first occurrence of the substring in the string. More... | |
char * | strnstr (const char *s, const char *find, size_t slen) |
Finds the first occurrence of find in the initial slen characters of the object pointed to by s. More... | |
int | strcmp (const char *s1, const char *s2) |
Compares two null-terminated byte strings lexicographically. More... | |
int | strncmp (const char *s1, const char *s2, size_t n) |
Compares at most n characters of two possibly null-terminated arrays. More... | |
char * | strdup (const char *str) |
Duplicate the passed in string str. More... | |
char * | strndup (const char *str, size_t n) |
Duplicate n bytes of the passed in string str. More... | |
char * | strchr (const char *s, int c) |
Finds the first occurrence of c in the null-terminated byte string pointed to by s. More... | |
char * | strrchr (const char *s, int c) |
Finds the last occurrence of c in the null-terminated byte string pointed to by s. More... | |
char * | strcat (char *__restrict dst, const char *__restrict src) |
Appends a copy of the null-terminated byte string pointed to by src to the end of the null-terminated byte string pointed to by dest. More... | |
char * | strncat (char *__restrict dst, const char *__restrict src, size_t maxlen) |
Appends at most maxlen characters from the character array pointed to by src, to the end of the null-terminated byte string pointed to by dest. More... | |
char * | strtok (char *s, const char *delim) |
Finds the next token in a null-terminated byte string pointed to by s. More... | |
size_t | strxfrm (char *__restrict, const char *__restrict, size_t) |
size_t | strcspn (const char *, const char *) |
size_t | strspn (const char *, const char *) |
char * | strpbrk (const char *, const char *) |
int | strcoll (const char *, const char *) |
char * | strerror (int) |
int | strerror_r (int, char *, size_t) |
void* memchr | ( | const void * | s, |
int | c, | ||
size_t | n | ||
) |
Finds the first occurrence of c in the initial n characters of the object pointed to by s.
Finds the first occurrence of c (after conversion to unsigned char as if by (unsigned char)c ) in the initial n characters (each interpreted as unsigned char) of the object pointed to by s.
The behavior is undefined if access occurs beyond the end of the array (s) searched. The behavior is undefined if s is a null pointer.
s | pointer to the object to be examined |
c | character to search for |
n | max number of characters to examine |
Definition at line 13 of file memchr.c.
References __attribute__(), ALIGN, HASZERO, ONES, and SS.
Referenced by memmem().
int memcmp | ( | const void * | s1, |
const void * | s2, | ||
size_t | n | ||
) |
Compares the first n characters of the two objects pointed to by s1 and s2.
Compares the first n characters of the objects pointed to by s1 and s2. The comparison is done lexicographically.
The behavior is undefined if access occurs beyond the end of either object pointed to by s1 and s2. The behavior is undefined if either s1 or s2 is a null pointer.
s1 | pointers to the objects to compare |
s2 | pointers to the objects to compare |
n | the number of bytes to examine |
Referenced by memmem().
void* memcpy | ( | void *__restrict | dest, |
const void *__restrict | src, | ||
size_t | n | ||
) |
Copies n characters from the object pointed to by src to the object pointed to by dest.
Copies n characters from the object pointed to by src to the object pointed to by dest. Both objects are interpreted as arrays of unsigned char.
The behavior is undefined if access occurs beyond the end of the dest array. If the objects overlap (which is a violation of the restrict contract) (since C99), the behavior is undefined. The behavior is undefined if either dest or src is a null pointer.
dest | pointer to the object to copy to |
src | pointer to the object to copy from |
n | number of bytes to copy |
Referenced by __attribute__(), realloc(), strcat(), strcpy(), strdup(), strerror_r(), strncat(), strncpy(), and strndup().
void* memmem | ( | const void * | l, |
size_t | l_len, | ||
const void * | s, | ||
size_t | s_len | ||
) |
Find substring s in memory area l.
Finds the start of the first occurrence of the substring s of length s_len in the memory area l of length l_len.
The behavior is undefined if access occurs beyond the end of the array (s) searched. The behavior is undefined if s is a null pointer.
l | pointer to the object to be examined |
l_len | number of characters to examine |
s | the substring to search for |
s_len | number of characters to examine |
Definition at line 34 of file memmem.c.
void* memmove | ( | void * | dest, |
const void * | src, | ||
size_t | n | ||
) |
Copies n characters from the object pointed to by src to the object pointed to by dest.
Copies n characters from the object pointed to by src to the object pointed to by dest. Both objects are interpreted as arrays of unsigned char.
The behavior is undefined if access occurs beyond the end of the dest array. The behavior is undefined if either dest or src is a null pointer.
dest | pointer to the object to copy to |
src | pointer to the object to copy from |
n | number of bytes to copy |
void* memset | ( | void * | dest, |
int | c, | ||
size_t | n | ||
) |
Copies the value c into each of the first n characters of the object pointed to by dest.
Copies the value c (after conversion to unsigned char as if by (unsigned char)c ) into each of the first n characters of the object pointed to by dest.
The behavior is undefined if access occurs beyond the end of the dest array. The behavior is undefined if dest is a null pointer.
dest | pointer to the object to fill |
c | fill byte |
n | number of bytes to fill |
Referenced by calloc(), CRTStartup(), strcspn(), and strncpy().
char* strcat | ( | char *__restrict | dst, |
const char *__restrict | src | ||
) |
Appends a copy of the null-terminated byte string pointed to by src to the end of the null-terminated byte string pointed to by dest.
Appends a copy of the null-terminated byte string pointed to by src to the end of the null-terminated byte string pointed to by dest. The character src[0] replaces the null terminator at the end of dest. The resulting byte string is null-terminated.
The behavior is undefined if the destination array is not large enough for the contents of both src and dest and the terminating null character. The behavior is undefined if the strings overlap. The behavior is undefined if either dest or src is not a pointer to a null-terminated byte string.
dst | pointer to the null-terminated byte string to append to |
src | pointer to the null-terminated byte string to copy from |
Definition at line 26 of file strcat.c.
char* strchr | ( | const char * | s, |
int | c | ||
) |
Finds the first occurrence of c in the null-terminated byte string pointed to by s.
Finds the first occurrence of c (after conversion to char as if by (char)c ) in the null-terminated byte string pointed to by s (each character interpreted as unsigned char). The terminating null character is considered to be a part of the string and can be found when searching for '\0'.
The behavior is undefined if s is not a pointer to a null-terminated byte string.
s | pointer to the null-terminated byte string to be analyzed |
c | character to search for |
Definition at line 7 of file strchr.c.
References __strchrnul().
int strcmp | ( | const char * | s1, |
const char * | s2 | ||
) |
Compares two null-terminated byte strings lexicographically.
Compares two null-terminated byte strings lexicographically.
The behavior is undefined if s1 or s2 are not pointers to null-terminated byte strings.
s1 | pointers to the null-terminated byte strings to compare |
s2 | pointers to the null-terminated byte strings to compare |
Definition at line 12 of file strcmp.c.
References NULL.
Referenced by strcoll(), wctrans(), and wctype().
int strcoll | ( | const char * | , |
const char * | |||
) |
char* strcpy | ( | char *__restrict | dst, |
const char *__restrict | src | ||
) |
Copies the null-terminated byte string pointed to by src to the character array whose first element is pointed to by dest.
Copies the null-terminated byte string pointed to by src, including the null terminator, to the character array whose first element is pointed to by dest. It may clobber the rest of the destination array with unspecified values and that the following errors are detected at runtime and call the currently installed constraint handler function: The behavior is undefined if the dest array is not large enough. The behavior is undefined if the strings overlap. The behavior is undefined if either dest is not a pointer to a character array or src is not a pointer to a null-terminated byte string. The behavior is undefined if the size of the character array pointed to by dest <= strlen(src, destsz)
dst | pointer to the character array to write to |
src | pointer to the null-terminated byte string to copy from |
Definition at line 26 of file strcpy.c.
References memcpy(), and strlen().
Referenced by strxfrm().
size_t strcspn | ( | const char * | , |
const char * | |||
) |
char* strdup | ( | const char * | str | ) |
Duplicate the passed in string str.
Returns a pointer to a new string which is a duplicate of the string str. Memory for the new string is obtained with malloc(3), and can be freed with free(3).
str | a pointer to a string to duplicate |
Definition at line 42 of file strdup.c.
char* strerror | ( | int | ) |
Definition at line 17 of file strerror.c.
References errid, errmsg, and NULL.
Referenced by strerror_r().
int strerror_r | ( | int | , |
char * | , | ||
size_t | |||
) |
Definition at line 5 of file strerror_r.c.
References assert, ERANGE, memcpy(), strerror(), and strlen().
size_t strlen | ( | const char * | str | ) |
Returns the length of the given null-terminated byte string.
Returns the length of the given null-terminated byte string, that is, the number of characters in a character array whose first element is pointed to by str up to and not including the first null character.
The behavior is undefined if str is not a pointer to a null-terminated byte string.
str | pointer to the null-terminated byte string to be examined |
Definition at line 77 of file strlen.c.
References LONGPTR_MASK, and testbyte.
Referenced by __strchrnul(), strcat(), strcpy(), strdup(), strerror_r(), strncat(), strnstr(), strrchr(), and strxfrm().
char* strncat | ( | char *__restrict | dst, |
const char *__restrict | src, | ||
size_t | maxlen | ||
) |
Appends at most maxlen characters from the character array pointed to by src, to the end of the null-terminated byte string pointed to by dest.
Appends at most count characters from the character array pointed to by src, stopping if the null character is found, to the end of the null-terminated byte string pointed to by dest. The character src[0] replaces the null terminator at the end of dest. The terminating null character is always appended in the end (so the maximum number of bytes the function may write is maxlen+1).
The behavior is undefined if the destination array is not large enough for the contents of both src and dest and the terminating null character. The behavior is undefined if the strings overlap. The behavior is undefined if either dest or src is not a pointer to a null-terminated byte string.
dst | pointer to the null-terminated byte string to append to |
src | pointer to the null-terminated byte string to copy from |
maxlen | maximum number of characters to copy |
Definition at line 26 of file strncat.c.
int strncmp | ( | const char * | s1, |
const char * | s2, | ||
size_t | n | ||
) |
Compares at most n characters of two possibly null-terminated arrays.
Compares at most count characters of two possibly null-terminated arrays. The comparison is done lexicographically.
The behavior is undefined when access occurs past the end of either array s1 or s2. The behavior is undefined when either s1 or s2 is the null pointer.
s1 | pointers to the null-terminated byte strings to compare |
s2 | pointers to the null-terminated byte strings to compare |
n | maximum number of characters to compare |
Definition at line 12 of file strncmp.c.
References NULL.
Referenced by strnstr().
char* strncpy | ( | char *__restrict | dst, |
const char *__restrict | src, | ||
size_t | maxlen | ||
) |
Copies at most maxlen characters of the character array pointed to by src to character array pointed to by dest.
Copies at most maxlen characters of the character array pointed to by src (including the terminating null character, but not any of the characters that follow the null character) to character array pointed to by dest. If maxlen is reached before the entire array src was copied, the resulting character array is not null-terminated. If, after copying the terminating null character from src, maxlen is not reached, additional null characters are written to dest until the total of maxlen characters have been written.
The behavior is undefined if the character arrays overlap, if either dest or src is not a pointer to a character array (including if dest or src is a null pointer), if the size of the array pointed to by dest is less than maxlen, or if the size of the array pointed to by src is less than maxlen and it does not contain a null character.
dst | pointer to the character array to copy to |
src | pointer to the character array to copy from |
maxlen | maximum number of characters to copy |
Definition at line 26 of file strncpy.c.
char* strndup | ( | const char * | str, |
size_t | n | ||
) |
Duplicate n bytes of the passed in string str.
strndup is similar to
str | a pointer to a string to duplicate |
n | maximum number of bytes to copy |
Definition at line 41 of file strndup.c.
size_t strnlen | ( | const char * | str, |
size_t | maxlen | ||
) |
Returns the length of the given null-terminated byte string.
Same as
The behavior is undefined if str points to a character array which lacks the null character and the size of that character array < maxlen; in other words, an erroneous value of maxlen does not expose impending buffer overflow.
str | pointer to the null-terminated byte string to be examined |
maxlen | maximum number of characters to examine |
Definition at line 21 of file strnlen.c.
Referenced by strncat(), and strncpy().
char* strnstr | ( | const char * | s, |
const char * | find, | ||
size_t | slen | ||
) |
Finds the first occurrence of find in the initial slen characters of the object pointed to by s.
Locates the first occurrence of the null-terminated string find in the string s, where not more than slen characters are searched. Characters that appear after a ‘\0’ character are not searched.
The behavior is undefined if either find or s is not a pointer to a null-terminated byte string.
s | pointer to the null-terminated byte string to examine |
find | pointer to the null-terminated byte string to search for |
slen | maxinum number of characters to search for |
Definition at line 48 of file strnstr.c.
char* strpbrk | ( | const char * | , |
const char * | |||
) |
char* strrchr | ( | const char * | s, |
int | c | ||
) |
Finds the last occurrence of c in the null-terminated byte string pointed to by s.
Finds the last occurrence of c (after conversion to char as if by (char)c ) in the null-terminated byte string pointed to by s (each character interpreted as unsigned char). The terminating null character is considered to be a part of the string and can be found when searching for '\0'.
The behavior is undefined if s is not a pointer to a null-terminated byte string.
s | pointer to the null-terminated byte string to be analyzed |
c | character to search for |
Definition at line 7 of file strrchr.c.
References __memrchr(), and strlen().
size_t strspn | ( | const char * | , |
const char * | |||
) |
char* strstr | ( | const char * | string, |
const char * | substring | ||
) |
Finds the first occurrence of the substring in the string.
Finds the first occurrence of the null-terminated byte string pointed to by substring in the null-terminated byte string pointed to by string. The terminating null characters are not compared.
The behavior is undefined if either stirng or substring is not a pointer to a null-terminated byte string.
string | pointer to the null-terminated byte string to examine |
substring | pointer to the null-terminated byte string to search for |
Definition at line 38 of file strstr.c.
References NULL.
char* strtok | ( | char * | s, |
const char * | delim | ||
) |
Finds the next token in a null-terminated byte string pointed to by s.
Finds the next token in a null-terminated byte string pointed to by s. The separator characters are identified by null-terminated byte string pointed to by delim. This function is designed to be called multiples times to obtain successive tokens from the same string.
The behavior is undefined if either s or delim is not a pointer to a null-terminated byte string.
s | pointer to the null-terminated byte string to tokenize |
delim | pointer to the null-terminated byte string identifying delimiters |
Definition at line 109 of file strtok.c.
References __strtok_r().
size_t strxfrm | ( | char * | __restrict, |
const char * | __restrict, | ||
size_t | |||
) |