7 #if !defined(__ROMCC__)
8 #include <console/vtxprintf.h>
11 /* Stringify a token */
13 #define _STRINGIFY(x) #x
14 #define STRINGIFY(x) _STRINGIFY(x)
17 void *memcpy(void *dest
, const void *src
, size_t n
);
18 void *memmove(void *dest
, const void *src
, size_t n
);
19 void *memset(void *s
, int c
, size_t n
);
20 int memcmp(const void *s1
, const void *s2
, size_t n
);
21 void *memchr(const void *s
, int c
, size_t n
);
22 #if !defined(__ROMCC__)
23 int snprintf(char *buf
, size_t size
, const char *fmt
, ...);
24 int vsnprintf(char *buf
, size_t size
, const char *fmt
, va_list args
);
26 char *strdup(const char *s
);
27 char *strconcat(const char *s1
, const char *s2
);
29 // simple string functions
31 static inline size_t strnlen(const char *src
, size_t max
)
34 while ((*src
++) && (i
< max
))
39 static inline size_t strlen(const char *src
)
47 static inline char *strchr(const char *s
, int c
)
57 * Find a character in a string.
59 * @param s The string.
60 * @param c The character.
61 * @return A pointer to the last occurrence of the character in the
62 * string, or NULL if the character was not encountered within the string.
64 static inline char *strrchr(const char *s
, int c
)
66 char *p
= (char *)s
+ strlen(s
);
76 static inline char *strncpy(char *to
, const char *from
, int count
)
78 register char *ret
= to
;
96 static inline char *strcpy(char *dst
, const char *src
)
107 static inline int strcmp(const char *s1
, const char *s2
)
111 while ((r
= (*s1
- *s2
)) == 0 && *s1
) {
118 static inline int strncmp(const char *s1
, const char *s2
, int maxlen
)
122 for (i
= 0; i
< maxlen
; i
++) {
123 if ((s1
[i
] != s2
[i
]) || (s1
[i
] == '\0'))
124 return s1
[i
] - s2
[i
];
130 static inline int isspace(int c
)
133 case ' ': case '\f': case '\n':
134 case '\r': case '\t': case '\v':
141 static inline int isprint(int c
)
143 return c
>= ' ' && c
<= '~';
146 static inline int isdigit(int c
)
148 return (c
>= '0' && c
<= '9');
151 static inline int isxdigit(int c
)
153 return ((c
>= '0' && c
<= '9') ||
154 (c
>= 'a' && c
<= 'f') ||
155 (c
>= 'A' && c
<= 'F'));
158 static inline int isupper(int c
)
160 return (c
>= 'A' && c
<= 'Z');
163 static inline int islower(int c
)
165 return (c
>= 'a' && c
<= 'z');
168 static inline int toupper(int c
)
175 static inline int tolower(int c
)
183 * Parses an unsigned integer and moves the input pointer forward to the first
184 * character that's not a valid digit. s and *s must not be NULL. Result
185 * undefined if it overruns the return type size.
187 static inline unsigned int skip_atoi(char **s
)
192 i
= i
*10 + *((*s
)++) - '0';
196 #endif /* STRING_H */