pmaports/main/systemd-boot/0002-fix-wchar-for-compiling-on-musl.patch
Clayton Craft e9ccc5ae23
main/systemd-boot: upgrade to 255 (MR 4651)
- Dropped patch that was merged upstream
- Rebased other patches

[ci:skip-build]: Already built successfully in CI.
2023-12-24 21:20:17 -05:00

97 lines
3.5 KiB
Diff

From 3153e2edb2b97117284e046b9cb9b846569b77df Mon Sep 17 00:00:00 2001
From: Clayton Craft <clayton@craftyguy.net>
Date: Fri, 6 Oct 2023 08:30:52 -0700
Subject: [PATCH 2/2] fix wchar for compiling on musl
---
src/boot/efi/efi-string.c | 10 +++++-----
src/boot/efi/efi.h | 5 +----
2 files changed, 6 insertions(+), 9 deletions(-)
diff --git a/src/boot/efi/efi-string.c b/src/boot/efi/efi-string.c
index 4144c0d497..40e8d1f3b0 100644
--- a/src/boot/efi/efi-string.c
+++ b/src/boot/efi/efi-string.c
@@ -569,7 +569,7 @@ typedef struct {
bool have_field_width;
const char *str;
- const wchar_t *wstr;
+ const uint16_t *wstr;
/* For numbers. */
bool is_signed;
@@ -630,7 +630,7 @@ static bool push_str(FormatContext *ctx, SpecifierContext *sp) {
push_padding(ctx, ' ', sp->padded_len);
/* In userspace unit tests we cannot just memcpy() the wide string. */
- if (sp->wstr && sizeof(wchar_t) == sizeof(char16_t)) {
+ if (sp->wstr && sizeof(uint16_t) == sizeof(char16_t)) {
memcpy(ctx->buf + ctx->n, sp->wstr, sp->len * sizeof(*sp->wstr));
ctx->n += sp->len;
} else {
@@ -724,7 +724,7 @@ static bool handle_format_specifier(FormatContext *ctx, SpecifierContext *sp) {
* int in vararg functions, which is why we fetch only ints for any such types. The compiler would
* otherwise warn about fetching smaller types. */
assert_cc(sizeof(int) == 4);
- assert_cc(sizeof(wchar_t) <= sizeof(int));
+ assert_cc(sizeof(uint16_t) <= sizeof(int));
assert_cc(sizeof(intmax_t) <= sizeof(long long));
assert(ctx);
@@ -819,13 +819,13 @@ static bool handle_format_specifier(FormatContext *ctx, SpecifierContext *sp) {
return push_str(ctx, sp);
case 'c':
- sp->wstr = &(wchar_t){ va_arg(ctx->ap, int) };
+ sp->wstr = &(uint16_t){ va_arg(ctx->ap, int) };
sp->len = 1;
return push_str(ctx, sp);
case 's':
if (sp->long_arg) {
- sp->wstr = va_arg(ctx->ap, const wchar_t *) ?: L"(null)";
+ sp->wstr = va_arg(ctx->ap, const uint16_t *) ?: L"(null)";
sp->len = wcsnlen(sp->wstr, sp->len);
} else {
sp->str = va_arg(ctx->ap, const char *) ?: "(null)";
diff --git a/src/boot/efi/efi.h b/src/boot/efi/efi.h
index fbc5d10565..23ccdc5dd5 100644
--- a/src/boot/efi/efi.h
+++ b/src/boot/efi/efi.h
@@ -10,7 +10,7 @@
#if SD_BOOT
/* uchar.h/wchar.h are not suitable for freestanding environments. */
-typedef __WCHAR_TYPE__ wchar_t;
+typedef __WCHAR_TYPE__ uint16_t;
typedef __CHAR16_TYPE__ char16_t;
typedef __CHAR32_TYPE__ char32_t;
@@ -22,7 +22,6 @@ assert_cc(sizeof(uint8_t) == 1);
assert_cc(sizeof(uint16_t) == 2);
assert_cc(sizeof(uint32_t) == 4);
assert_cc(sizeof(uint64_t) == 8);
-assert_cc(sizeof(wchar_t) == 2);
assert_cc(sizeof(char16_t) == 2);
assert_cc(sizeof(char32_t) == 4);
assert_cc(sizeof(size_t) == sizeof(void *));
@@ -32,7 +31,6 @@ assert_cc(alignof(uint8_t) == 1);
assert_cc(alignof(uint16_t) == 2);
assert_cc(alignof(uint32_t) == 4);
assert_cc(alignof(uint64_t) == 8);
-assert_cc(alignof(wchar_t) == 2);
assert_cc(alignof(char16_t) == 2);
assert_cc(alignof(char32_t) == 4);
@@ -41,7 +39,6 @@ assert_cc(alignof(char32_t) == 4);
# endif
#else
# include <uchar.h>
-# include <wchar.h>
#endif
/* We use size_t/ssize_t to represent UEFI UINTN/INTN. */
--
2.43.0