]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
kselftest/arm64: move get_header()
authorJoey Gouly <joey.gouly@arm.com>
Thu, 22 Aug 2024 15:11:07 +0000 (16:11 +0100)
committerWill Deacon <will@kernel.org>
Wed, 4 Sep 2024 11:54:06 +0000 (12:54 +0100)
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 <joey.gouly@arm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
Reviewed-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20240822151113.1479789-25-joey.gouly@arm.com
Signed-off-by: Will Deacon <will@kernel.org>
tools/testing/selftests/arm64/signal/testcases/testcases.c
tools/testing/selftests/arm64/signal/testcases/testcases.h

index 674b88cc8c394f2daa9ba621ba4b243226e6373f..e4331440fed0b9f339f313722dd2c796cb58cffa 100644 (file)
@@ -6,29 +6,6 @@
 
 #include "testcases.h"
 
-struct _aarch64_ctx *get_header(struct _aarch64_ctx *head, uint32_t magic,
-                               size_t resv_sz, size_t *offset)
-{
-       size_t offs = 0;
-       struct _aarch64_ctx *found = NULL;
-
-       if (!head || resv_sz < HDR_SZ)
-               return found;
-
-       while (offs <= resv_sz - HDR_SZ &&
-              head->magic != magic && head->magic) {
-               offs += head->size;
-               head = GET_RESV_NEXT_HEAD(head);
-       }
-       if (head->magic == magic) {
-               found = head;
-               if (offset)
-                       *offset = offs;
-       }
-
-       return found;
-}
-
 bool validate_extra_context(struct extra_context *extra, char **err,
                            void **extra_data, size_t *extra_size)
 {
index 7727126347e0ba45391e33e6ad874a218221a6f9..3185e6875694649adb6c603a9557f43274dcdf20 100644 (file)
@@ -88,8 +88,29 @@ struct fake_sigframe {
 
 bool validate_reserved(ucontext_t *uc, size_t resv_sz, char **err);
 
-struct _aarch64_ctx *get_header(struct _aarch64_ctx *head, uint32_t magic,
-                               size_t resv_sz, size_t *offset);
+static inline struct _aarch64_ctx *get_header(struct _aarch64_ctx *head, uint32_t magic,
+                               size_t resv_sz, size_t *offset)
+{
+       size_t offs = 0;
+       struct _aarch64_ctx *found = NULL;
+
+       if (!head || resv_sz < HDR_SZ)
+               return found;
+
+       while (offs <= resv_sz - HDR_SZ &&
+              head->magic != magic && head->magic) {
+               offs += head->size;
+               head = GET_RESV_NEXT_HEAD(head);
+       }
+       if (head->magic == magic) {
+               found = head;
+               if (offset)
+                       *offset = offs;
+       }
+
+       return found;
+}
+
 
 static inline struct _aarch64_ctx *get_terminator(struct _aarch64_ctx *head,
                                                  size_t resv_sz,