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 
12 #include <stddef.h>
13 
14 extern void * generic_memset ( void *dest, int character,
15  size_t len ) __nonnull;
16 extern void * generic_memcpy ( void *dest, const void *src,
17  size_t len ) __nonnull;
18 extern void * generic_memcpy_reverse ( void *dest, const void *src,
19  size_t len ) __nonnull;
20 extern void * generic_memmove ( void *dest, const void *src,
21  size_t len ) __nonnull;
22 
23 #include <bits/string.h>
24 
25 /* Architecture-specific code is expected to provide these functions,
26  * but may instead explicitly choose to use the generic versions.
27  */
28 void * memset ( void *dest, int character, size_t len ) __nonnull;
29 void * memcpy ( void *dest, const void *src, size_t len ) __nonnull;
30 void * memmove ( void *dest, const void *src, size_t len ) __nonnull;
31 
32 extern int __pure memcmp ( const void *first, const void *second,
33  size_t len ) __nonnull;
34 extern void * __pure memchr ( const void *src, int character,
35  size_t len ) __nonnull;
36 extern void * memswap ( void *dest, void *src, size_t len ) __nonnull;
37 extern int __pure strcmp ( const char *first, const char *second ) __nonnull;
38 extern int __pure strncmp ( const char *first, const char *second,
39  size_t max ) __nonnull;
40 extern size_t __pure strlen ( const char *src ) __nonnull;
41 extern size_t __pure strnlen ( const char *src, size_t max ) __nonnull;
42 extern char * __pure strchr ( const char *src, int character ) __nonnull;
43 extern char * __pure strrchr ( const char *src, int character ) __nonnull;
44 extern char * __pure strstr ( const char *haystack,
45  const char *needle ) __nonnull;
46 extern char * strcpy ( char *dest, const char *src ) __nonnull;
47 extern char * strncpy ( char *dest, const char *src, size_t max ) __nonnull;
48 extern char * strcat ( char *dest, const char *src ) __nonnull;
49 extern char * __malloc strdup ( const char *src ) __nonnull;
50 extern char * __malloc strndup ( const char *src, size_t max ) __nonnull;
51 extern char * __pure strpbrk ( const char *string,
52  const char *delim ) __nonnull;
53 extern char * strsep ( char **string, const char *delim ) __nonnull;
54 
55 extern char * __pure strerror ( int errno );
56 
57 #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:135
int __pure memcmp(const void *first, const void *second, size_t len) __nonnull
Compare memory regions.
Definition: string.c:114
char *__malloc strndup(const char *src, size_t max) __nonnull
Duplicate string.
Definition: string.c:392
char *__pure strchr(const char *src, int character) __nonnull
Find character within a string.
Definition: string.c:271
#define max(x, y)
Definition: ath.h:39
int __pure strcmp(const char *first, const char *second) __nonnull
Compare strings.
Definition: string.c:173
static const void size_t len
Definition: string.h:47
size_t __pure strlen(const char *src) __nonnull
Get length of string.
Definition: string.c:243
static __always_inline int off_t userptr_t second
Definition: efi_uaccess.h:80
void * generic_memcpy_reverse(void *dest, const void *src, size_t len) __nonnull
Copy memory region (backwards)
Definition: string.c:80
char * strncpy(char *dest, const char *src, size_t max) __nonnull
Copy string.
Definition: string.c:347
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:150
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
char * strcat(char *dest, const char *src) __nonnull
Concatenate string.
Definition: string.c:368
int __pure strncmp(const char *first, const char *second, size_t max) __nonnull
Compare strings.
Definition: string.c:186
char * strcpy(char *dest, const char *src) __nonnull
Copy string.
Definition: string.c:326
static const void * src
Definition: string.h:47
#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
char *__pure strstr(const char *haystack, const char *needle) __nonnull
Find substring.
Definition: string.c:309
void * generic_memset(void *dest, int character, size_t len) __nonnull
Fill memory region.
Definition: string.c:47
int errno
Global "last error" number.
Definition: errno.c:20
char *__pure strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
void * generic_memcpy(void *dest, const void *src, size_t len) __nonnull
Copy memory region (forwards)
Definition: string.c:63
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:97
void * memmove(void *dest, const void *src, size_t len) __nonnull
char *__malloc strdup(const char *src) __nonnull
Duplicate string.
Definition: string.c:380
#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:255
Optimised string operations.
void * memswap(void *dest, void *src, size_t len) __nonnull
Swap memory regions.
Definition: string.c:153
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:289
uint32_t first
Length to skip in first segment.
Definition: pccrc.h:23
void * memset(void *dest, int character, size_t len) __nonnull