mirror of
https://github.com/morgan9e/systemd
synced 2026-04-15 00:47:10 +09:00
musl: add several missing symbols (#39701)
This commit is contained in:
8
src/include/musl/ftw.h
Normal file
8
src/include/musl/ftw.h
Normal file
@@ -0,0 +1,8 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
#pragma once
|
||||
|
||||
#include_next <ftw.h>
|
||||
|
||||
#ifndef FTW_CONTINUE
|
||||
#define FTW_CONTINUE 0
|
||||
#endif
|
||||
8
src/include/musl/gnu/libc-version.h
Normal file
8
src/include/musl/gnu/libc-version.h
Normal file
@@ -0,0 +1,8 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
#pragma once
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
static inline const char* gnu_get_libc_version(void) {
|
||||
return "";
|
||||
}
|
||||
22
src/include/musl/gshadow.h
Normal file
22
src/include/musl/gshadow.h
Normal file
@@ -0,0 +1,22 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
#pragma once
|
||||
|
||||
#include <errno.h>
|
||||
#include <stddef.h>
|
||||
|
||||
struct sgrp {
|
||||
char *sg_namp;
|
||||
char *sg_passwd;
|
||||
char **sg_adm;
|
||||
char **sg_mem;
|
||||
};
|
||||
|
||||
static inline int getsgnam_r(
|
||||
const char *__name,
|
||||
struct sgrp *__result_buf,
|
||||
char *__buffer,
|
||||
size_t __buflen,
|
||||
struct sgrp **__result) {
|
||||
|
||||
return EOPNOTSUPP; /* this function returns positive errno in case of error. */
|
||||
}
|
||||
39
src/include/musl/malloc.h
Normal file
39
src/include/musl/malloc.h
Normal file
@@ -0,0 +1,39 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
#pragma once
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
|
||||
/* struct mallinfo2 will be defined and struct mallinfo is converted to struct mallinfo2 in
|
||||
* override/malloc.h. Hence, here we define struct mallinfo. */
|
||||
|
||||
struct mallinfo {
|
||||
int arena; /* non-mmapped space allocated from system */
|
||||
int ordblks; /* number of free chunks */
|
||||
int smblks; /* number of fastbin blocks */
|
||||
int hblks; /* number of mmapped regions */
|
||||
int hblkhd; /* space in mmapped regions */
|
||||
int usmblks; /* always 0, preserved for backwards compatibility */
|
||||
int fsmblks; /* space available in freed fastbin blocks */
|
||||
int uordblks; /* total allocated space */
|
||||
int fordblks; /* total free space */
|
||||
int keepcost; /* top-most, releasable (via malloc_trim) space */
|
||||
};
|
||||
|
||||
static inline struct mallinfo mallinfo(void) {
|
||||
return (struct mallinfo) {};
|
||||
}
|
||||
|
||||
static inline int malloc_info(int options, FILE *stream) {
|
||||
if (options != 0)
|
||||
errno = EINVAL;
|
||||
else
|
||||
errno = EOPNOTSUPP;
|
||||
return -1;
|
||||
}
|
||||
|
||||
static inline int malloc_trim(size_t pad) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#include_next <malloc.h>
|
||||
33
src/include/musl/netinet/if_ether.h
Normal file
33
src/include/musl/netinet/if_ether.h
Normal file
@@ -0,0 +1,33 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
#pragma once
|
||||
|
||||
/* glibc's netinet/if_ether.h does the following:
|
||||
* - include linux/if_ether.h, net/ethernet.h, and net/if_arp.h,
|
||||
* - define struct ether_arp, and relevant macros,
|
||||
* - define ETHER_MAP_IP_MULTICAST() macro (currently we do not use it).
|
||||
* However, musl's netinet/if_ether.h conflicts with linux/if_ether.h.
|
||||
* Let's use the same way that glibc uses. */
|
||||
|
||||
#include <linux/if_ether.h> /* IWYU pragma: export */
|
||||
#include <net/ethernet.h> /* IWYU pragma: export */
|
||||
#include <net/if_arp.h> /* IWYU pragma: export */
|
||||
|
||||
/*
|
||||
* Ethernet Address Resolution Protocol.
|
||||
*
|
||||
* See RFC 826 for protocol description. Structure below is adapted
|
||||
* to resolving internet addresses. Field names used correspond to
|
||||
* RFC 826.
|
||||
*/
|
||||
struct ether_arp {
|
||||
struct arphdr ea_hdr; /* fixed-size header */
|
||||
uint8_t arp_sha[ETH_ALEN]; /* sender hardware address */
|
||||
uint8_t arp_spa[4]; /* sender protocol address */
|
||||
uint8_t arp_tha[ETH_ALEN]; /* target hardware address */
|
||||
uint8_t arp_tpa[4]; /* target protocol address */
|
||||
};
|
||||
#define arp_hrd ea_hdr.ar_hrd
|
||||
#define arp_pro ea_hdr.ar_pro
|
||||
#define arp_hln ea_hdr.ar_hln
|
||||
#define arp_pln ea_hdr.ar_pln
|
||||
#define arp_op ea_hdr.ar_op
|
||||
19
src/include/musl/sys/prctl.h
Normal file
19
src/include/musl/sys/prctl.h
Normal file
@@ -0,0 +1,19 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
#pragma once
|
||||
|
||||
#include_next <sys/prctl.h> /* IWYU pragma: export */
|
||||
|
||||
/* musl's sys/prctl.h does not include linux/prctl.h, and also we cannot include with linux/prctl.h.
|
||||
* Hence, we need to provide some missing definitions. */
|
||||
|
||||
#ifndef PR_SET_MDWE
|
||||
#define PR_SET_MDWE 65
|
||||
#endif
|
||||
|
||||
#ifndef PR_MDWE_REFUSE_EXEC_GAIN
|
||||
#define PR_MDWE_REFUSE_EXEC_GAIN (1UL << 0)
|
||||
#endif
|
||||
|
||||
#ifndef PR_SET_MEMORY_MERGE
|
||||
#define PR_SET_MEMORY_MERGE 67
|
||||
#endif
|
||||
66
src/include/musl/sys/stat.h
Normal file
66
src/include/musl/sys/stat.h
Normal file
@@ -0,0 +1,66 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
#pragma once
|
||||
|
||||
#include_next <sys/stat.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <stddef.h>
|
||||
|
||||
/* musl's sys/stat.h does not include linux/stat.h, and unfortunately they conflict with each other.
|
||||
* Hence, some relatively new macros need to be explicitly defined here. */
|
||||
|
||||
/* Before 23ab04a8630225371455d5f4538fd078665bb646, statx.stx_mnt_id is not defined. */
|
||||
#ifndef STATX_MNT_ID
|
||||
static_assert(offsetof(struct statx, __pad1) == offsetof(struct statx, stx_dev_minor) + sizeof(uint32_t), "");
|
||||
#define stx_mnt_id __pad1[0]
|
||||
#endif
|
||||
|
||||
#ifndef STATX_MNT_ID
|
||||
#define STATX_MNT_ID 0x00001000U
|
||||
#endif
|
||||
#ifndef STATX_DIOALIGN
|
||||
#define STATX_DIOALIGN 0x00002000U
|
||||
#endif
|
||||
#ifndef STATX_MNT_ID_UNIQUE
|
||||
#define STATX_MNT_ID_UNIQUE 0x00004000U
|
||||
#endif
|
||||
#ifndef STATX_SUBVOL
|
||||
#define STATX_SUBVOL 0x00008000U
|
||||
#endif
|
||||
#ifndef STATX_WRITE_ATOMIC
|
||||
#define STATX_WRITE_ATOMIC 0x00010000U
|
||||
#endif
|
||||
#ifndef STATX_DIO_READ_ALIGN
|
||||
#define STATX_DIO_READ_ALIGN 0x00020000U
|
||||
#endif
|
||||
|
||||
#ifndef STATX_ATTR_COMPRESSED
|
||||
#define STATX_ATTR_COMPRESSED 0x00000004
|
||||
#endif
|
||||
#ifndef STATX_ATTR_IMMUTABLE
|
||||
#define STATX_ATTR_IMMUTABLE 0x00000010
|
||||
#endif
|
||||
#ifndef STATX_ATTR_APPEND
|
||||
#define STATX_ATTR_APPEND 0x00000020
|
||||
#endif
|
||||
#ifndef STATX_ATTR_NODUMP
|
||||
#define STATX_ATTR_NODUMP 0x00000040
|
||||
#endif
|
||||
#ifndef STATX_ATTR_ENCRYPTED
|
||||
#define STATX_ATTR_ENCRYPTED 0x00000800
|
||||
#endif
|
||||
#ifndef STATX_ATTR_AUTOMOUNT
|
||||
#define STATX_ATTR_AUTOMOUNT 0x00001000
|
||||
#endif
|
||||
#ifndef STATX_ATTR_MOUNT_ROOT
|
||||
#define STATX_ATTR_MOUNT_ROOT 0x00002000
|
||||
#endif
|
||||
#ifndef STATX_ATTR_VERITY
|
||||
#define STATX_ATTR_VERITY 0x00100000
|
||||
#endif
|
||||
#ifndef STATX_ATTR_DAX
|
||||
#define STATX_ATTR_DAX 0x00200000
|
||||
#endif
|
||||
#ifndef STATX_ATTR_WRITE_ATOMIC
|
||||
#define STATX_ATTR_WRITE_ATOMIC 0x00400000
|
||||
#endif
|
||||
@@ -669,12 +669,14 @@ TEST(condition_test_version) {
|
||||
condition_free(condition);
|
||||
|
||||
/* Test glibc version */
|
||||
bool has = !isempty(gnu_get_libc_version());
|
||||
|
||||
ASSERT_NOT_NULL((condition = condition_new(CONDITION_VERSION, "glibc > 1", false, false)));
|
||||
ASSERT_OK_POSITIVE(condition_test(condition, environ));
|
||||
ASSERT_OK_EQ(condition_test(condition, environ), has);
|
||||
condition_free(condition);
|
||||
|
||||
ASSERT_NOT_NULL((condition = condition_new(CONDITION_VERSION, "glibc < 2", false, false)));
|
||||
ASSERT_OK_ZERO(condition_test(condition, environ));
|
||||
ASSERT_OK_EQ(condition_test(condition, environ), !has);
|
||||
condition_free(condition);
|
||||
|
||||
ASSERT_NOT_NULL((condition = condition_new(CONDITION_VERSION, "glibc < 9999", false, false)));
|
||||
@@ -686,15 +688,27 @@ TEST(condition_test_version) {
|
||||
condition_free(condition);
|
||||
|
||||
v = strjoina("glibc = ", gnu_get_libc_version());
|
||||
|
||||
ASSERT_NOT_NULL((condition = condition_new(CONDITION_VERSION, v, false, false)));
|
||||
ASSERT_OK_POSITIVE(condition_test(condition, environ));
|
||||
if (has)
|
||||
ASSERT_OK_POSITIVE(condition_test(condition, environ));
|
||||
else
|
||||
ASSERT_ERROR(condition_test(condition, environ), EINVAL);
|
||||
condition_free(condition);
|
||||
|
||||
v = strjoina("glibc != ", gnu_get_libc_version());
|
||||
|
||||
ASSERT_NOT_NULL((condition = condition_new(CONDITION_VERSION, v, false, false)));
|
||||
ASSERT_OK_ZERO(condition_test(condition, environ));
|
||||
if (has)
|
||||
ASSERT_OK_ZERO(condition_test(condition, environ));
|
||||
else
|
||||
ASSERT_ERROR(condition_test(condition, environ), EINVAL);
|
||||
condition_free(condition);
|
||||
|
||||
ASSERT_NOT_NULL((condition = condition_new(CONDITION_VERSION, "glibc $= ?*", false, false)));
|
||||
ASSERT_OK_EQ(condition_test(condition, environ), has);
|
||||
condition_free(condition);
|
||||
|
||||
ASSERT_NOT_NULL((condition = condition_new(CONDITION_VERSION, "glibc !$= ?*", false, false)));
|
||||
ASSERT_OK_EQ(condition_test(condition, environ), !has);
|
||||
condition_free(condition);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user