Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simd: prevent SIGILL with armv6 #184

Merged
merged 1 commit into from
Aug 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions regex_src/regexMain.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,9 @@ static void run_tests(struct test_case* test, int verbose, int silent)

printf("REGEX tests: ");
if (fail == 0)
printf("all tests are " COLOR_GREEN "PASSED" COLOR_DEFAULT " ");
printf("all tests " COLOR_GREEN "PASSED" COLOR_DEFAULT " ");
else
printf(COLOR_RED "%d" COLOR_DEFAULT " (" COLOR_RED "%d%%" COLOR_DEFAULT ") tests are failed ", fail, fail * 100 / (success + fail));
printf(COLOR_RED "%d" COLOR_DEFAULT " (" COLOR_RED "%d%%" COLOR_DEFAULT ") tests failed ", fail, fail * 100 / (success + fail));
printf("on " COLOR_ARCH "%s" COLOR_DEFAULT "\n", regex_get_platform_name());
}

Expand Down
14 changes: 12 additions & 2 deletions sljit_src/sljitNativeARM_32.c
Original file line number Diff line number Diff line change
Expand Up @@ -974,15 +974,25 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_has_cpu_feature(sljit_s32 feature_type)
{
switch (feature_type) {
case SLJIT_HAS_FPU:
#ifdef SLJIT_IS_FPU_AVAILABLE
return SLJIT_IS_FPU_AVAILABLE;
#else
/* Available by default. */
return 1;
#endif /* SLJIT_IS_FPU_AVAILABLE */
case SLJIT_HAS_SIMD:
case SLJIT_SIMD_REGS_ARE_PAIRS:
#ifdef SLJIT_IS_FPU_AVAILABLE
return SLJIT_IS_FPU_AVAILABLE;
#else
#if (defined SLJIT_CONFIG_ARM_V6 && SLJIT_CONFIG_ARM_V6)
return 0;
#else
/* Available by default. */
return 1;
#endif
#endif /* SLJIT_CONFIG_ARM_V6 */
#endif /* SLJIT_IS_FPU_AVAILABLE */

case SLJIT_SIMD_REGS_ARE_PAIRS:
case SLJIT_HAS_CLZ:
case SLJIT_HAS_CTZ:
case SLJIT_HAS_ROT:
Expand Down
2 changes: 1 addition & 1 deletion sljit_src/sljitNativeARM_T2_32.c
Original file line number Diff line number Diff line change
Expand Up @@ -511,14 +511,14 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_has_cpu_feature(sljit_s32 feature_type)
switch (feature_type) {
case SLJIT_HAS_FPU:
case SLJIT_HAS_SIMD:
case SLJIT_SIMD_REGS_ARE_PAIRS:
#ifdef SLJIT_IS_FPU_AVAILABLE
return SLJIT_IS_FPU_AVAILABLE;
#else
/* Available by default. */
return 1;
#endif

case SLJIT_SIMD_REGS_ARE_PAIRS:
case SLJIT_HAS_CLZ:
case SLJIT_HAS_CTZ:
case SLJIT_HAS_REV:
Expand Down
28 changes: 23 additions & 5 deletions test_src/sljitTest.c
Original file line number Diff line number Diff line change
Expand Up @@ -11276,7 +11276,7 @@ static void test90(void)
sljit_s32 i;

if (verbose)
printf("Run test89\n");
printf("Run test90\n");

FAILED(!compiler, "cannot create compiler\n");

Expand Down Expand Up @@ -11378,7 +11378,7 @@ static void test91(void)
sljit_s32 i;

if (verbose)
printf("Run test13\n");
printf("Run test91\n");

if (!sljit_has_cpu_feature(SLJIT_HAS_FPU)) {
if (verbose)
Expand Down Expand Up @@ -12244,6 +12244,9 @@ static void test96(void)
sljit_u8 data[63 + 680];
sljit_s32 fs0 = SLJIT_NUMBER_OF_SAVED_FLOAT_REGISTERS > 0 ? SLJIT_FS0 : SLJIT_FR5;

if (verbose)
printf("Run test96\n");

if (!sljit_has_cpu_feature(SLJIT_HAS_SIMD)) {
if (verbose)
printf("no simd available, test96 skipped\n");
Expand Down Expand Up @@ -12442,6 +12445,9 @@ static void test97(void)
sljit_s32 result32[5];
sljit_s32 fs0 = SLJIT_NUMBER_OF_SAVED_FLOAT_REGISTERS > 0 ? SLJIT_FS0 : SLJIT_FR5;

if (verbose)
printf("Run test97\n");

if (!sljit_has_cpu_feature(SLJIT_HAS_SIMD)) {
if (verbose)
printf("no simd available, test97 skipped\n");
Expand Down Expand Up @@ -12774,6 +12780,9 @@ static void test98(void)
sljit_u8 data[63 + 544];
sljit_s32 fs0 = SLJIT_NUMBER_OF_SAVED_FLOAT_REGISTERS > 0 ? SLJIT_FS0 : SLJIT_FR5;

if (verbose)
printf("Run test98\n");

if (!sljit_has_cpu_feature(SLJIT_HAS_SIMD)) {
if (verbose)
printf("no simd available, test98 skipped\n");
Expand Down Expand Up @@ -13021,6 +13030,9 @@ static void test99(void)
sljit_u8 data[63 + 464];
sljit_s32 fs0 = SLJIT_NUMBER_OF_SAVED_FLOAT_REGISTERS > 0 ? SLJIT_FS0 : SLJIT_FR5;

if (verbose)
printf("Run test99\n");

if (!sljit_has_cpu_feature(SLJIT_HAS_SIMD)) {
if (verbose)
printf("no simd available, test99 skipped\n");
Expand Down Expand Up @@ -13236,6 +13248,9 @@ static void test100(void)
sljit_u8 data[63 + 368];
sljit_s32 fs0 = SLJIT_NUMBER_OF_SAVED_FLOAT_REGISTERS > 0 ? SLJIT_FS0 : SLJIT_FR5;

if (verbose)
printf("Run test100\n");

if (!sljit_has_cpu_feature(SLJIT_HAS_SIMD)) {
if (verbose)
printf("no simd available, test100 skipped\n");
Expand Down Expand Up @@ -13523,6 +13538,9 @@ static void test101(void)
sljit_u8 data[63 + 544];
sljit_s32 fs0 = SLJIT_NUMBER_OF_SAVED_FLOAT_REGISTERS > 0 ? SLJIT_FS0 : SLJIT_FR5;

if (verbose)
printf("Run test101\n");

if (!sljit_has_cpu_feature(SLJIT_HAS_SIMD)) {
if (verbose)
printf("no simd available, test101 skipped\n");
Expand Down Expand Up @@ -13847,10 +13865,10 @@ int sljit_test(int argc, char* argv[])

printf("SLJIT tests: ");
if (successful_tests == TEST_COUNT)
printf("all tests are " COLOR_GREEN "PASSED" COLOR_DEFAULT " ");
printf("all tests " COLOR_GREEN "PASSED" COLOR_DEFAULT " ");
else
printf(COLOR_RED "%d" COLOR_DEFAULT " (" COLOR_RED "%d%%" COLOR_DEFAULT ") tests are " COLOR_RED "FAILED" COLOR_DEFAULT " ", TEST_COUNT - successful_tests, (TEST_COUNT - successful_tests) * 100 / TEST_COUNT);
printf("on " COLOR_ARCH "%s" COLOR_DEFAULT "%s\n", sljit_get_platform_name(), sljit_has_cpu_feature(SLJIT_HAS_FPU) ? " (with fpu)" : " (without fpu)");
printf(COLOR_RED "%d" COLOR_DEFAULT " (" COLOR_RED "%d%%" COLOR_DEFAULT ") tests " COLOR_RED "FAILED" COLOR_DEFAULT " ", TEST_COUNT - successful_tests, (TEST_COUNT - successful_tests) * 100 / TEST_COUNT);
printf("on " COLOR_ARCH "%s" COLOR_DEFAULT " (%s)\n", sljit_get_platform_name(), sljit_has_cpu_feature(SLJIT_HAS_SIMD) ? "with simd" : (sljit_has_cpu_feature(SLJIT_HAS_FPU) ? "with fpu" : "basic"));

return TEST_COUNT - successful_tests;

Expand Down