mirror of
https://github.com/systemd/systemd
synced 2024-10-15 04:24:19 +00:00
meson: use 0|1 for SD_BOOT
We converted to not using #ifdef for most of our defines because the syntax is nicer and we are protected against typos and can set -Werror=undef. Let's do the same for SD_BOOT. The define is nicely hidden in build.h for normal builds, and for EFI builds we were already setting SD_BOOT on the commandline.
This commit is contained in:
parent
5deb391c6e
commit
493cd5034c
|
@ -55,6 +55,9 @@ fuzzer_build = want_ossfuzz or want_libfuzzer
|
||||||
# limits).
|
# limits).
|
||||||
conf.set10('FUZZ_USE_SIZE_LIMIT', fuzzer_build)
|
conf.set10('FUZZ_USE_SIZE_LIMIT', fuzzer_build)
|
||||||
|
|
||||||
|
# We'll set this to '1' for EFI builds in a different place.
|
||||||
|
conf.set10('SD_BOOT', false)
|
||||||
|
|
||||||
# Create a title-less summary section early, so it ends up first in the output.
|
# Create a title-less summary section early, so it ends up first in the output.
|
||||||
# More items are added later after they have been detected.
|
# More items are added later after they have been detected.
|
||||||
summary({'build mode' : get_option('mode')})
|
summary({'build mode' : get_option('mode')})
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
#include "efi-string.h"
|
#include "efi-string.h"
|
||||||
|
|
||||||
#ifdef SD_BOOT
|
#if SD_BOOT
|
||||||
# include "util.h"
|
# include "util.h"
|
||||||
#else
|
#else
|
||||||
# include <stdlib.h>
|
# include <stdlib.h>
|
||||||
|
@ -378,7 +378,7 @@ bool efi_fnmatch(const char16_t *pattern, const char16_t *haystack) {
|
||||||
DEFINE_PARSE_NUMBER(char, parse_number8);
|
DEFINE_PARSE_NUMBER(char, parse_number8);
|
||||||
DEFINE_PARSE_NUMBER(char16_t, parse_number16);
|
DEFINE_PARSE_NUMBER(char16_t, parse_number16);
|
||||||
|
|
||||||
#ifdef SD_BOOT
|
#if SD_BOOT
|
||||||
/* To provide the actual implementation for these we need to remove the redirection to the builtins. */
|
/* To provide the actual implementation for these we need to remove the redirection to the builtins. */
|
||||||
# undef memcmp
|
# undef memcmp
|
||||||
# undef memcpy
|
# undef memcpy
|
||||||
|
@ -414,7 +414,7 @@ _used_ _weak_ void *memcpy(void * restrict dest, const void * restrict src, size
|
||||||
if (!dest || !src || n == 0)
|
if (!dest || !src || n == 0)
|
||||||
return dest;
|
return dest;
|
||||||
|
|
||||||
#ifdef SD_BOOT
|
#if SD_BOOT
|
||||||
/* The firmware-provided memcpy is likely optimized, so use that. The function is guaranteed to be
|
/* The firmware-provided memcpy is likely optimized, so use that. The function is guaranteed to be
|
||||||
* available by the UEFI spec. We still make it depend on the boot services pointer being set just in
|
* available by the UEFI spec. We still make it depend on the boot services pointer being set just in
|
||||||
* case the compiler emits a call before it is available. */
|
* case the compiler emits a call before it is available. */
|
||||||
|
@ -441,7 +441,7 @@ _used_ _weak_ void *memset(void *p, int c, size_t n) {
|
||||||
if (!p || n == 0)
|
if (!p || n == 0)
|
||||||
return p;
|
return p;
|
||||||
|
|
||||||
#ifdef SD_BOOT
|
#if SD_BOOT
|
||||||
/* See comment in efi_memcpy. Note that the signature has c and n swapped! */
|
/* See comment in efi_memcpy. Note that the signature has c and n swapped! */
|
||||||
if (_likely_(BS)) {
|
if (_likely_(BS)) {
|
||||||
BS->SetMem(p, n, c);
|
BS->SetMem(p, n, c);
|
||||||
|
|
|
@ -109,7 +109,7 @@ bool efi_fnmatch(const char16_t *pattern, const char16_t *haystack);
|
||||||
bool parse_number8(const char *s, uint64_t *ret_u, const char **ret_tail);
|
bool parse_number8(const char *s, uint64_t *ret_u, const char **ret_tail);
|
||||||
bool parse_number16(const char16_t *s, uint64_t *ret_u, const char16_t **ret_tail);
|
bool parse_number16(const char16_t *s, uint64_t *ret_u, const char16_t **ret_tail);
|
||||||
|
|
||||||
#ifdef SD_BOOT
|
#if SD_BOOT
|
||||||
/* The compiler normally has knowledge about standard functions such as memcmp, but this is not the case when
|
/* The compiler normally has knowledge about standard functions such as memcmp, but this is not the case when
|
||||||
* compiling with -ffreestanding. By referring to builtins, the compiler can check arguments and do
|
* compiling with -ffreestanding. By referring to builtins, the compiler can check arguments and do
|
||||||
* optimizations again. Note that we still need to provide implementations as the compiler is free to not
|
* optimizations again. Note that we still need to provide implementations as the compiler is free to not
|
||||||
|
|
|
@ -175,7 +175,7 @@ efi_config_h = configure_file(
|
||||||
|
|
||||||
efi_cflags = [
|
efi_cflags = [
|
||||||
'-DGNU_EFI_USE_MS_ABI',
|
'-DGNU_EFI_USE_MS_ABI',
|
||||||
'-DSD_BOOT',
|
'-DSD_BOOT=1',
|
||||||
'-ffreestanding',
|
'-ffreestanding',
|
||||||
'-fshort-wchar',
|
'-fshort-wchar',
|
||||||
'-fvisibility=hidden',
|
'-fvisibility=hidden',
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#ifndef SD_BOOT
|
#if !SD_BOOT
|
||||||
# include <assert.h>
|
# include <assert.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@
|
||||||
#define XCONCATENATE(x, y) x ## y
|
#define XCONCATENATE(x, y) x ## y
|
||||||
#define CONCATENATE(x, y) XCONCATENATE(x, y)
|
#define CONCATENATE(x, y) XCONCATENATE(x, y)
|
||||||
|
|
||||||
#ifdef SD_BOOT
|
#if SD_BOOT
|
||||||
_noreturn_ void efi_assert(const char *expr, const char *file, unsigned line, const char *function);
|
_noreturn_ void efi_assert(const char *expr, const char *file, unsigned line, const char *function);
|
||||||
|
|
||||||
#ifdef NDEBUG
|
#ifdef NDEBUG
|
||||||
|
@ -334,7 +334,7 @@ static inline size_t ALIGN_TO(size_t l, size_t ali) {
|
||||||
#define ALIGN2_PTR(p) ((void*) ALIGN2((uintptr_t) p))
|
#define ALIGN2_PTR(p) ((void*) ALIGN2((uintptr_t) p))
|
||||||
#define ALIGN4_PTR(p) ((void*) ALIGN4((uintptr_t) p))
|
#define ALIGN4_PTR(p) ((void*) ALIGN4((uintptr_t) p))
|
||||||
#define ALIGN8_PTR(p) ((void*) ALIGN8((uintptr_t) p))
|
#define ALIGN8_PTR(p) ((void*) ALIGN8((uintptr_t) p))
|
||||||
#ifndef SD_BOOT
|
#if !SD_BOOT
|
||||||
/* libefi also provides ALIGN, and we do not use them in sd-boot explicitly. */
|
/* libefi also provides ALIGN, and we do not use them in sd-boot explicitly. */
|
||||||
#define ALIGN(l) ALIGN_TO(l, sizeof(void*))
|
#define ALIGN(l) ALIGN_TO(l, sizeof(void*))
|
||||||
#define ALIGN_PTR(p) ((void*) ALIGN((uintptr_t) (p)))
|
#define ALIGN_PTR(p) ((void*) ALIGN((uintptr_t) (p)))
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
#ifdef SD_BOOT
|
#if SD_BOOT
|
||||||
# include "efi-string.h"
|
# include "efi-string.h"
|
||||||
#else
|
#else
|
||||||
# include <string.h>
|
# include <string.h>
|
||||||
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
#include "macro-fundamental.h"
|
#include "macro-fundamental.h"
|
||||||
|
|
||||||
#if !defined(SD_BOOT) && HAVE_EXPLICIT_BZERO
|
#if !SD_BOOT && HAVE_EXPLICIT_BZERO
|
||||||
static inline void *explicit_bzero_safe(void *p, size_t l) {
|
static inline void *explicit_bzero_safe(void *p, size_t l) {
|
||||||
if (p && l > 0)
|
if (p && l > 0)
|
||||||
explicit_bzero(p, l);
|
explicit_bzero(p, l);
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
<https://www.gnu.org/licenses/>. */
|
<https://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#ifdef SD_BOOT
|
#if SD_BOOT
|
||||||
# include "efi-string.h"
|
# include "efi-string.h"
|
||||||
#else
|
#else
|
||||||
# include <string.h>
|
# include <string.h>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||||
|
|
||||||
#ifndef SD_BOOT
|
#if !SD_BOOT
|
||||||
# include <ctype.h>
|
# include <ctype.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ sd_char *startswith(const sd_char *s, const sd_char *prefix) {
|
||||||
return (sd_char*) s + l;
|
return (sd_char*) s + l;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef SD_BOOT
|
#if !SD_BOOT
|
||||||
sd_char *startswith_no_case(const sd_char *s, const sd_char *prefix) {
|
sd_char *startswith_no_case(const sd_char *s, const sd_char *prefix) {
|
||||||
size_t l;
|
size_t l;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#ifdef SD_BOOT
|
#if SD_BOOT
|
||||||
# include <efi.h>
|
# include <efi.h>
|
||||||
# include <efilib.h>
|
# include <efilib.h>
|
||||||
# include "efi-string.h"
|
# include "efi-string.h"
|
||||||
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
#include "macro-fundamental.h"
|
#include "macro-fundamental.h"
|
||||||
|
|
||||||
#ifdef SD_BOOT
|
#if SD_BOOT
|
||||||
# define strlen strlen16
|
# define strlen strlen16
|
||||||
# define strcmp strcmp16
|
# define strcmp strcmp16
|
||||||
# define strncmp strncmp16
|
# define strncmp strncmp16
|
||||||
|
@ -59,7 +59,7 @@ static inline size_t strlen_ptr(const sd_char *s) {
|
||||||
}
|
}
|
||||||
|
|
||||||
sd_char *startswith(const sd_char *s, const sd_char *prefix) _pure_;
|
sd_char *startswith(const sd_char *s, const sd_char *prefix) _pure_;
|
||||||
#ifndef SD_BOOT
|
#if !SD_BOOT
|
||||||
sd_char *startswith_no_case(const sd_char *s, const sd_char *prefix) _pure_;
|
sd_char *startswith_no_case(const sd_char *s, const sd_char *prefix) _pure_;
|
||||||
#endif
|
#endif
|
||||||
sd_char *endswith(const sd_char *s, const sd_char *postfix) _pure_;
|
sd_char *endswith(const sd_char *s, const sd_char *postfix) _pure_;
|
||||||
|
|
Loading…
Reference in a new issue