4 * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 * See https://llvm.org/LICENSE.txt for license information.
6 * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
14 #include "stringlib.h"
16 static const struct fun
19 size_t (*fun
)(const char *s
);
25 F(__strlen_aarch64_mte
)
26 # if __ARM_FEATURE_SVE
27 F(__strlen_aarch64_sve
)
30 # if __ARM_ARCH >= 6 && __ARM_ARCH_ISA_THUMB == 2
38 static int test_status
;
39 #define ERR(...) (test_status=1, printf(__VA_ARGS__))
44 static char sbuf
[LEN
+2*A
];
46 static void *alignup(void *p
)
48 return (void*)(((uintptr_t)p
+ A
-1) & -A
);
51 static void test(const struct fun
*fun
, int align
, int len
)
53 char *src
= alignup(sbuf
);
54 char *s
= src
+ align
;
57 if (len
> LEN
|| align
>= A
)
60 for (int i
= 0; i
< len
+ A
; i
++)
62 for (int i
= 0; i
< len
- 2; i
++)
68 ERR("%s(%p) returned %zu\n", fun
->name
, s
, r
);
69 ERR("input: %.*s\n", align
+len
+1, src
);
70 ERR("expected: %d\n", len
);
78 for (int i
=0; funtab
[i
].name
; i
++) {
80 for (int a
= 0; a
< A
; a
++) {
82 for (n
= 1; n
< 100; n
++)
84 for (; n
< LEN
; n
*= 2)
87 printf("%s %s\n", test_status
? "FAIL" : "PASS", funtab
[i
].name
);