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 char *(*fun
)(char *dest
, const char *src
);
25 # if __ARM_FEATURE_SVE
26 F(__stpcpy_aarch64_sve
)
33 static int test_status
;
34 #define ERR(...) (test_status=1, printf(__VA_ARGS__))
38 static char dbuf
[LEN
+2*A
];
39 static char sbuf
[LEN
+2*A
];
40 static char wbuf
[LEN
+2*A
];
42 static void *alignup(void *p
)
44 return (void*)(((uintptr_t)p
+ A
-1) & -A
);
47 static void test(const struct fun
*fun
, int dalign
, int salign
, int len
)
49 char *src
= alignup(sbuf
);
50 char *dst
= alignup(dbuf
);
52 char *s
= src
+ salign
;
53 char *d
= dst
+ dalign
;
54 char *w
= want
+ dalign
;
58 if (len
> LEN
|| dalign
>= A
|| salign
>= A
)
60 for (i
= 0; i
< len
+A
; i
++) {
62 want
[i
] = dst
[i
] = '*';
64 for (i
= 0; i
< len
; i
++)
65 s
[i
] = w
[i
] = 'a' + i
%23;
70 ERR("%s(%p,..) returned %p\n", fun
->name
, d
, p
);
71 for (i
= 0; i
< len
+A
; i
++) {
72 if (dst
[i
] != want
[i
]) {
73 ERR("%s(align %d, align %d, %d) failed\n", fun
->name
, dalign
, salign
, len
);
74 ERR("got : %.*s\n", dalign
+len
+1, dst
);
75 ERR("want: %.*s\n", dalign
+len
+1, want
);
84 for (int i
=0; funtab
[i
].name
; i
++) {
86 for (int d
= 0; d
< A
; d
++)
87 for (int s
= 0; s
< A
; s
++) {
89 for (n
= 0; n
< 100; n
++)
90 test(funtab
+i
, d
, s
, n
);
91 for (; n
< LEN
; n
*= 2)
92 test(funtab
+i
, d
, s
, n
);
94 printf("%s %s\n", test_status
? "FAIL" : "PASS", funtab
[i
].name
);