boot: make several functions inline

Follow-ups for #23512.
This commit is contained in:
Yu Watanabe 2022-06-01 06:25:52 +09:00
parent a54e635d02
commit 42e785d096
2 changed files with 29 additions and 43 deletions

View file

@ -37,14 +37,6 @@
DEFINE_STRNLEN(char, strnlen8);
DEFINE_STRNLEN(char16_t, strnlen16);
size_t strlen8(const char *s) {
return strnlen8(s, SIZE_MAX);
}
size_t strlen16(const char16_t *s) {
return strnlen16(s, SIZE_MAX);
}
#define TOLOWER(c) \
({ \
typeof(c) _c = (c); \
@ -87,26 +79,9 @@ DEFINE_STRTOLOWER(char16_t, strtolower16);
DEFINE_STRNCASECMP(char, strncmp8, false);
DEFINE_STRNCASECMP(char16_t, strncmp16, false);
int strcmp8(const char *s1, const char *s2) {
return strncmp8(s1, s2, SIZE_MAX);
}
int strcmp16(const char16_t *s1, const char16_t *s2) {
return strncmp16(s1, s2, SIZE_MAX);
}
DEFINE_STRNCASECMP(char, strncasecmp8, true);
DEFINE_STRNCASECMP(char16_t, strncasecmp16, true);
int strcasecmp8(const char *s1, const char *s2) {
return strncasecmp8(s1, s2, SIZE_MAX);
}
int strcasecmp16(const char16_t *s1, const char16_t *s2) {
return strncasecmp16(s1, s2, SIZE_MAX);
}
#define DEFINE_STRCPY(type, name) \
type *name(type * restrict dest, const type * restrict src) { \
assert(dest); \
@ -165,14 +140,6 @@ DEFINE_STRCHR(char16_t, strchr16);
DEFINE_STRNDUP(char, xstrndup8, strnlen8);
DEFINE_STRNDUP(char16_t, xstrndup16, strnlen16);
char *xstrdup8(const char *s) {
return xstrndup8(s, SIZE_MAX);
}
char16_t *xstrdup16(const char16_t *s) {
return xstrndup16(s, SIZE_MAX);
}
int efi_memcmp(const void *p1, const void *p2, size_t n) {
if (!p1 || !p2)
return CMP(p1, p2);

View file

@ -10,8 +10,13 @@
size_t strnlen8(const char *s, size_t n);
size_t strnlen16(const char16_t *s, size_t n);
size_t strlen8(const char *s);
size_t strlen16(const char16_t *s);
static inline size_t strlen8(const char *s) {
return strnlen8(s, SIZE_MAX);
}
static inline size_t strlen16(const char16_t *s) {
return strnlen16(s, SIZE_MAX);
}
static inline size_t strsize8(const char *s) {
return s ? (strlen8(s) + 1) * sizeof(*s) : 0;
@ -26,15 +31,24 @@ void strtolower16(char16_t *s);
int strncmp8(const char *s1, const char *s2, size_t n);
int strncmp16(const char16_t *s1, const char16_t *s2, size_t n);
int strcmp8(const char *s1, const char *s2);
int strcmp16(const char16_t *s1, const char16_t *s2);
int strncasecmp8(const char *s1, const char *s2, size_t n);
int strncasecmp16(const char16_t *s1, const char16_t *s2, size_t n);
int strcasecmp8(const char *s1, const char *s2);
int strcasecmp16(const char16_t *s1, const char16_t *s2);
static inline int strcmp8(const char *s1, const char *s2) {
return strncmp8(s1, s2, SIZE_MAX);
}
static inline int strcmp16(const char16_t *s1, const char16_t *s2) {
return strncmp16(s1, s2, SIZE_MAX);
}
static inline int strcasecmp8(const char *s1, const char *s2) {
return strncasecmp8(s1, s2, SIZE_MAX);
}
static inline int strcasecmp16(const char16_t *s1, const char16_t *s2) {
return strncasecmp16(s1, s2, SIZE_MAX);
}
static inline bool strneq8(const char *s1, const char *s2, size_t n) {
return strncmp8(s1, s2, n) == 0;
@ -77,8 +91,13 @@ char16_t *strchr16(const char16_t *s, char16_t c);
char *xstrndup8(const char *s, size_t n);
char16_t *xstrndup16(const char16_t *s, size_t n);
char *xstrdup8(const char *s);
char16_t *xstrdup16(const char16_t *s);
static inline char *xstrdup8(const char *s) {
return xstrndup8(s, SIZE_MAX);
}
static inline char16_t *xstrdup16(const char16_t *s) {
return xstrndup16(s, SIZE_MAX);
}
#ifdef SD_BOOT
/* The compiler normally has knowledge about standard functions such as memcmp, but this is not the case when