iPXE
string.h
Go to the documentation of this file.
1 #ifndef _STRING_H
2 #define _STRING_H
3 
4 /** @file
5  *
6  * String functions
7  *
8  */
9 
10 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11 FILE_SECBOOT ( PERMITTED );
12 
13 #include <stddef.h>
14 
15 extern void * generic_memset ( void *dest, int character,
16  size_t len ) __nonnull;
17 extern void * generic_memcpy ( void *dest, const void *src,
18  size_t len ) __nonnull;
19 extern void * generic_memcpy_reverse ( void *dest, const void *src,
20  size_t len ) __nonnull;
21 extern void * generic_memmove ( void *dest, const void *src,
22  size_t len ) __nonnull;
23 
24 #include <bits/string.h>
25 
26 /* Architecture-specific code is expected to provide these functions,
27  * but may instead explicitly choose to use the generic versions.
28  */
29 void * memset ( void *dest, int character, size_t len ) __nonnull;
30 void * memcpy ( void *dest, const void *src, size_t len ) __nonnull;
31 void * memmove ( void *dest, const void *src, size_t len ) __nonnull;
32 
33 extern int __pure memcmp ( const void *first, const void *second,
34  size_t len ) __nonnull;
35 extern void * __pure memchr ( const void *src, int character,
36  size_t len ) __nonnull;
37 extern void * memswap ( void *dest, void *src, size_t len ) __nonnull;
38 extern int __pure strcmp ( const char *first, const char *second ) __nonnull;
39 extern int __pure strncmp ( const char *first, const char *second,
40  size_t max ) __nonnull;
41 extern size_t __pure strlen ( const char *src ) __nonnull;
42 extern size_t __pure strnlen ( const char *src, size_t max ) __nonnull;
43 extern char * __pure strchr ( const char *src, int character ) __nonnull;
44 extern char * __pure strrchr ( const char *src, int character ) __nonnull;
45 extern char * __pure strstr ( const char *haystack,
46  const char *needle ) __nonnull;
47 extern char * stpcpy ( char *dest, const char *src ) __nonnull;
48 extern char * strcpy ( char *dest, const char *src ) __nonnull;
49 extern char * strncpy ( char *dest, const char *src, size_t max ) __nonnull;
50 extern char * strcat ( char *dest, const char *src ) __nonnull;
51 extern char * __malloc strdup ( const char *src ) __nonnull;
52 extern char * __malloc strndup ( const char *src, size_t max ) __nonnull;
53 extern char * __pure strpbrk ( const char *string,
54  const char *delim ) __nonnull;
55 extern char * strsep ( char **string, const char *delim ) __nonnull;
56 
57 extern char * __pure strerror ( int errno );
58 
59 #endif /* _STRING_H */
#define __pure
Declare a function as pure - i.e.
Definition: compiler.h:578
void *__pure memchr(const void *src, int character, size_t len) __nonnull
Find character within a memory region.
Definition: string.c:136
int __pure memcmp(const void *first, const void *second, size_t len) __nonnull
Compare memory regions.
Definition: string.c:115
char *__malloc strndup(const char *src, size_t max) __nonnull
Duplicate string.
Definition: string.c:406
char *__pure strchr(const char *src, int character) __nonnull
Find character within a string.
Definition: string.c:272
#define max(x, y)
Definition: ath.h:41
int __pure strcmp(const char *first, const char *second) __nonnull
Compare strings.
Definition: string.c:174
static const void size_t len
Definition: string.h:48
uint32_t first
First block in range.
Definition: pccrr.h:15
size_t __pure strlen(const char *src) __nonnull
Get length of string.
Definition: string.c:244
void * generic_memcpy_reverse(void *dest, const void *src, size_t len) __nonnull
Copy memory region (backwards)
Definition: string.c:81
char * strncpy(char *dest, const char *src, size_t max) __nonnull
Copy string.
Definition: string.c:361
char * strcat(char *dest, const char *src) __nonnull
Concatenate string.
Definition: string.c:382
int __pure strncmp(const char *first, const char *second, size_t max) __nonnull
Compare strings.
Definition: string.c:187
char * strcpy(char *dest, const char *src) __nonnull
Copy string.
Definition: string.c:347
char * stpcpy(char *dest, const char *src) __nonnull
Copy string.
Definition: string.c:327
#define __nonnull
Declare a function's pointer parameters as non-null - i.e.
Definition: compiler.h:592
void * memcpy(void *dest, const void *src, size_t len) __nonnull
static const void * src
Definition: string.h:48
char *__pure strstr(const char *haystack, const char *needle) __nonnull
Find substring.
Definition: string.c:310
void * generic_memset(void *dest, int character, size_t len) __nonnull
Fill memory region.
Definition: string.c:48
int errno
Global "last error" number.
Definition: errno.c:21
char *__pure strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:79
void * generic_memcpy(void *dest, const void *src, size_t len) __nonnull
Copy memory region (forwards)
Definition: string.c:64
char * strsep(char **string, const char *delim) __nonnull
strsep - Split a string into tokens @s: The string to be searched @ct: The characters to search for
Definition: stringextra.c:73
void * generic_memmove(void *dest, const void *src, size_t len) __nonnull
Copy (possibly overlapping) memory region.
Definition: string.c:98
void * memmove(void *dest, const void *src, size_t len) __nonnull
char *__malloc strdup(const char *src) __nonnull
Duplicate string.
Definition: string.c:394
#define __malloc
Declare a pointer returned by a function as a unique memory address as returned by malloc-type functi...
Definition: compiler.h:598
size_t __pure strnlen(const char *src, size_t max) __nonnull
Get length of string.
Definition: string.c:256
if(len >=6 *4) __asm__ __volatile__("movsl" if(len >=5 *4) __asm__ __volatile__("movsl" if(len >=4 *4) __asm__ __volatile__("movsl" if(len >=3 *4) __asm__ __volatile__("movsl" if(len >=2 *4) __asm__ __volatile__("movsl" if(len >=1 *4) __asm__ __volatile__("movsl" if((len % 4) >=2) __asm__ __volatile__("movsw" if((len % 2) >=1) __asm__ __volatile__("movsb" return dest
Definition: string.h:151
Optimised string operations.
void * memswap(void *dest, void *src, size_t len) __nonnull
Swap memory regions.
Definition: string.c:154
FILE_SECBOOT(PERMITTED)
char *__pure strpbrk(const char *string, const char *delim) __nonnull
strpbrk - Find the first occurrence of a set of characters @cs: The string to be searched @ct: The ch...
Definition: stringextra.c:47
char *__pure strrchr(const char *src, int character) __nonnull
Find rightmost character within a string.
Definition: string.c:290
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
void * memset(void *dest, int character, size_t len) __nonnull