1
0
mirror of https://github.com/systemd/systemd synced 2026-04-11 17:44:58 +02:00

Compare commits

..

8 Commits

Author SHA1 Message Date
Yu Watanabe
a9cab9f5cf
Merge pull request #21848 from yuwata/errno-name-drop-aliases
errno-name: drop aliases defined for specific arch
2021-12-22 17:27:12 +09:00
Yu Watanabe
5bdeedb342 test: add test for errno-list.[ch] 2021-12-22 15:29:55 +09:00
Yu Watanabe
95d88436ea errno-name: drop aliases defined for specific arch
In kernel's arch/parisc/include/uapi/asm/errno.h, ECANCELLED and
EREFUSED are defined as aliases of ECANCELED and ECONNREFUSED,
respectively. Let's drop them.

Fixes #21844.
2021-12-22 15:29:55 +09:00
Yu Watanabe
c99d5efc2d
Merge pull request #21857 from loongarch64/dev-pr1
LoongArch: dmi, virt detection and testcase
2021-12-22 15:20:20 +09:00
Jan Janssen
a3aff1c47f test,static-destruct: Use retain attribute to prevent linker garbage collection
Fixes: #21847
2021-12-22 12:14:08 +09:00
Xiaotian Wu
646b01121a test: add LoongArch 64bit testcase 2021-12-22 11:07:56 +08:00
Xiaotian Wu
eebbd595f0 virt: add detection for LoongArch 64bit 2021-12-22 11:07:55 +08:00
Xiaotian Wu
ff6d286902 dmi: add LoongArch 64bit support 2021-12-22 11:07:54 +08:00
11 changed files with 61 additions and 6 deletions

View File

@ -3,5 +3,9 @@
set -eu
set -o pipefail
# In kernel's arch/parisc/include/uapi/asm/errno.h, ECANCELLED and EREFUSED are defined as aliases of
# ECANCELED and ECONNREFUSED, respectively. Let's drop them.
${1:?} -dM -include errno.h - </dev/null | \
grep -Ev '^#define[[:space:]]+(ECANCELLED|EREFUSED)' | \
awk '/^#define[ \t]+E[^ _]+[ \t]+/ { print $2; }'

View File

@ -24,12 +24,16 @@ typedef struct StaticDestructor {
typeof(variable) *q = p; \
func(q); \
} \
/* Older compilers don't know retain attribute. */ \
_Pragma("GCC diagnostic ignored \"-Wattributes\"") \
/* The actual destructor structure we place in a special section to find it */ \
_section_("SYSTEMD_STATIC_DESTRUCT") \
/* We pick pointer alignment, since that is apparently what gcc does for static variables */ \
_alignptr_ \
/* Make sure this is not dropped from the image because not explicitly referenced */ \
_used_ \
/* Prevent linker from garbage collection. */ \
_retain_ \
/* Make sure that AddressSanitizer doesn't pad this variable: we want everything in this section
* packed next to each other so that we can enumerate it. */ \
_variable_no_sanitize_address_ \

View File

@ -139,7 +139,7 @@ static int detect_vm_device_tree(void) {
#endif
}
#if defined(__i386__) || defined(__x86_64__) || defined(__arm__) || defined(__aarch64__)
#if defined(__i386__) || defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) || defined(__loongarch64)
static int detect_vm_dmi_vendor(void) {
static const char *const dmi_vendors[] = {
"/sys/class/dmi/id/product_name", /* Test this before sys_vendor to detect KVM over QEMU */
@ -226,10 +226,10 @@ static int detect_vm_smbios(void) {
log_debug("DMI BIOS Extension table does not indicate virtualization.");
return SMBIOS_VM_BIT_UNSET;
}
#endif /* defined(__i386__) || defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) */
#endif /* defined(__i386__) || defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) || defined(__loongarch64) */
static int detect_vm_dmi(void) {
#if defined(__i386__) || defined(__x86_64__) || defined(__arm__) || defined(__aarch64__)
#if defined(__i386__) || defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) || defined(__loongarch64)
int r;
r = detect_vm_dmi_vendor();

View File

@ -13,6 +13,7 @@
#define _pure_ __attribute__((__pure__))
#define _section_(x) __attribute__((__section__(x)))
#define _packed_ __attribute__((__packed__))
#define _retain_ __attribute__((__retain__))
#define _used_ __attribute__((__used__))
#define _unused_ __attribute__((__unused__))
#define _cleanup_(x) __attribute__((__cleanup__(x)))

View File

@ -38,7 +38,7 @@ int bus_error_set_errnofv(sd_bus_error *e, int error, const char *format, va_lis
_Pragma("GCC diagnostic ignored \"-Wattributes\"") \
_section_("SYSTEMD_BUS_ERROR_MAP") \
_used_ \
__attribute__((retain)) \
_retain_ \
_alignptr_ \
_variable_no_sanitize_address_

View File

@ -57,7 +57,8 @@ typedef struct TestFunc {
/* See static-destruct.h for an explanation of how this works. */
#define REGISTER_TEST(func, ...) \
_section_("SYSTEMD_TEST_TABLE") _alignptr_ _used_ _variable_no_sanitize_address_ \
_Pragma("GCC diagnostic ignored \"-Wattributes\"") \
_section_("SYSTEMD_TEST_TABLE") _alignptr_ _used_ _retain_ _variable_no_sanitize_address_ \
static const TestFunc UNIQ_T(static_test_table_entry, UNIQ) = { \
.f = (union f) &(func), \
.name = STRINGIFY(func), \

View File

@ -574,6 +574,9 @@ tests += [
[['src/test/test-arphrd-util.c',
generated_gperf_headers]],
[['src/test/test-errno-list.c',
generated_gperf_headers]],
[['src/test/test-ip-protocol-list.c',
shared_generated_gperf_headers]],

View File

@ -0,0 +1,33 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <errno.h>
#include "errno-list.h"
#include "errno-to-name.h"
#include "macro.h"
#include "string-util.h"
#include "tests.h"
#include "util.h"
TEST(errno_list) {
for (size_t i = 0; i < ELEMENTSOF(errno_names); i++) {
if (errno_names[i]) {
assert_se(streq(errno_to_name(i), errno_names[i]));
assert_se(errno_from_name(errno_names[i]) == (int) i);
}
}
#ifdef ECANCELLED
/* ECANCELLED is an alias of ECANCELED. */
assert_se(streq(errno_to_name(ECANCELLED), "ECANCELED"));
#endif
assert_se(streq(errno_to_name(ECANCELED), "ECANCELED"));
#ifdef EREFUSED
/* EREFUSED is an alias of ECONNREFUSED. */
assert_se(streq(errno_to_name(EREFUSED), "ECONNREFUSED"));
#endif
assert_se(streq(errno_to_name(ECONNREFUSED), "ECONNREFUSED"));
}
DEFINE_TEST_MAIN(LOG_INFO);

View File

@ -381,6 +381,8 @@ static void test_exec_personality(Manager *m) {
#elif defined(__i386__)
test(m, "exec-personality-x86.service", 0, CLD_EXITED);
#elif defined(__loongarch64)
test(m, "exec-personality-loongarch64.service", 0, CLD_EXITED);
#else
log_notice("Unknown personality, skipping %s", __func__);
#endif

View File

@ -133,7 +133,7 @@ udev_progs = [['ata_id/ata_id.c'],
'mtd_probe/mtd_probe.h',
'mtd_probe/probe_smartmedia.c']]
dmi_arches = ['x86', 'x86_64', 'aarch64', 'arm', 'ia64', 'mips']
dmi_arches = ['x86', 'x86_64', 'aarch64', 'arm', 'ia64', 'loongarch64', 'mips']
if dmi_arches.contains(host_machine.cpu_family())
udev_progs += [['dmi_memory_id/dmi_memory_id.c']]
endif

View File

@ -0,0 +1,7 @@
[Unit]
Description=Test for Personality=loongarch64
[Service]
ExecStart=/bin/sh -c 'echo $(uname -m); exit $(test $(uname -m) = "loongarch64")'
Type=oneshot
Personality=loongarch64