fundamental: define size_t and memcpy for sd-boot

This commit is contained in:
Luca Boccassi
2021-10-08 13:07:00 +01:00
parent d888ef68d1
commit 5d8a725b08
4 changed files with 9 additions and 8 deletions
+2
View File
@@ -59,6 +59,8 @@
#define assert(expr) ({ _likely_(expr) ? VOID_0 : efi_assert(#expr, __FILE__, __LINE__, __PRETTY_FUNCTION__); })
#define assert_not_reached() efi_assert("Code should not be reached", __FILE__, __LINE__, __PRETTY_FUNCTION__)
#endif
#define memcpy(a, b, c) CopyMem((a), (b), (c))
#endif
#if defined(static_assert)
+4 -4
View File
@@ -8,7 +8,7 @@
#include "string-util-fundamental.h"
sd_char *startswith(const sd_char *s, const sd_char *prefix) {
sd_size_t l;
size_t l;
assert(s);
assert(prefix);
@@ -22,7 +22,7 @@ sd_char *startswith(const sd_char *s, const sd_char *prefix) {
#ifndef SD_BOOT
sd_char *startswith_no_case(const sd_char *s, const sd_char *prefix) {
sd_size_t l;
size_t l;
assert(s);
assert(prefix);
@@ -36,7 +36,7 @@ sd_char *startswith_no_case(const sd_char *s, const sd_char *prefix) {
#endif
sd_char* endswith(const sd_char *s, const sd_char *postfix) {
sd_size_t sl, pl;
size_t sl, pl;
assert(s);
assert(postfix);
@@ -57,7 +57,7 @@ sd_char* endswith(const sd_char *s, const sd_char *postfix) {
}
sd_char* endswith_no_case(const sd_char *s, const sd_char *postfix) {
sd_size_t sl, pl;
size_t sl, pl;
assert(s);
assert(postfix);
+2 -2
View File
@@ -68,10 +68,10 @@ static inline const sd_char *yes_no(sd_bool b) {
sd_int strverscmp_improved(const sd_char *a, const sd_char *b);
/* Like startswith(), but operates on arbitrary memory blocks */
static inline void *memory_startswith(const void *p, sd_size_t sz, const sd_char *token) {
static inline void *memory_startswith(const void *p, size_t sz, const sd_char *token) {
assert(token);
sd_size_t n = strlen(token) * sizeof(sd_char);
size_t n = strlen(token) * sizeof(sd_char);
if (sz < n)
return NULL;
+1 -2
View File
@@ -7,7 +7,7 @@
typedef BOOLEAN sd_bool;
typedef CHAR16 sd_char;
typedef INTN sd_int;
typedef UINTN sd_size_t;
typedef UINTN size_t;
#define true TRUE
#define false FALSE
@@ -18,5 +18,4 @@ typedef UINTN sd_size_t;
typedef bool sd_bool;
typedef char sd_char;
typedef int sd_int;
typedef size_t sd_size_t;
#endif