Skip to content

Commit 6354a01

Browse files
jgoulywilldeacon
authored andcommitted
kselftest/arm64: move get_header()
Put this function in the header so that it can be used by other tests, without needing to link to testcases.c. This will be used by selftest/mm/protection_keys.c Signed-off-by: Joey Gouly <[email protected]> Cc: Catalin Marinas <[email protected]> Cc: Will Deacon <[email protected]> Cc: Andrew Morton <[email protected]> Cc: Shuah Khan <[email protected]> Cc: Dave Hansen <[email protected]> Cc: Aneesh Kumar K.V <[email protected]> Reviewed-by: Mark Brown <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]>
1 parent b9b9d72 commit 6354a01

File tree

2 files changed

+23
-25
lines changed

2 files changed

+23
-25
lines changed

tools/testing/selftests/arm64/signal/testcases/testcases.c

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,6 @@
66

77
#include "testcases.h"
88

9-
struct _aarch64_ctx *get_header(struct _aarch64_ctx *head, uint32_t magic,
10-
size_t resv_sz, size_t *offset)
11-
{
12-
size_t offs = 0;
13-
struct _aarch64_ctx *found = NULL;
14-
15-
if (!head || resv_sz < HDR_SZ)
16-
return found;
17-
18-
while (offs <= resv_sz - HDR_SZ &&
19-
head->magic != magic && head->magic) {
20-
offs += head->size;
21-
head = GET_RESV_NEXT_HEAD(head);
22-
}
23-
if (head->magic == magic) {
24-
found = head;
25-
if (offset)
26-
*offset = offs;
27-
}
28-
29-
return found;
30-
}
31-
329
bool validate_extra_context(struct extra_context *extra, char **err,
3310
void **extra_data, size_t *extra_size)
3411
{

tools/testing/selftests/arm64/signal/testcases/testcases.h

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,29 @@ struct fake_sigframe {
8888

8989
bool validate_reserved(ucontext_t *uc, size_t resv_sz, char **err);
9090

91-
struct _aarch64_ctx *get_header(struct _aarch64_ctx *head, uint32_t magic,
92-
size_t resv_sz, size_t *offset);
91+
static inline struct _aarch64_ctx *get_header(struct _aarch64_ctx *head, uint32_t magic,
92+
size_t resv_sz, size_t *offset)
93+
{
94+
size_t offs = 0;
95+
struct _aarch64_ctx *found = NULL;
96+
97+
if (!head || resv_sz < HDR_SZ)
98+
return found;
99+
100+
while (offs <= resv_sz - HDR_SZ &&
101+
head->magic != magic && head->magic) {
102+
offs += head->size;
103+
head = GET_RESV_NEXT_HEAD(head);
104+
}
105+
if (head->magic == magic) {
106+
found = head;
107+
if (offset)
108+
*offset = offs;
109+
}
110+
111+
return found;
112+
}
113+
93114

94115
static inline struct _aarch64_ctx *get_terminator(struct _aarch64_ctx *head,
95116
size_t resv_sz,

0 commit comments

Comments
 (0)