Skip to content

Commit

Permalink
chore: improve support to s390 and s390x
Browse files Browse the repository at this point in the history
  • Loading branch information
RodrigoDornelles committed Nov 27, 2023
1 parent 75d7bcf commit 122e03a
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 1 deletion.
12 changes: 12 additions & 0 deletions src/detect/detect_cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@
#define TBC_CPU_ARCH_32BITS
#define TBC_CPU_TYPE_RISCV
#define TBC_CPU_BYTE_SEXLE
#elif defined(__s390__)
#define TBC_CPU_NAME "s390"
#define TBC_CPU_ARCH_32BITS
#define TBC_CPU_TYPE_IBMZ
#define TBC_CPU_BYTE_SEXBE
#elif defined(__aarch64__) || defined(_M_ARM64)
#define TBC_CPU_NAME "ARM64"
#define TBC_CPU_ARCH_64BITS
Expand All @@ -88,6 +93,13 @@
#define TBC_CPU_ARCH_32BITS
#define TBC_CPU_TYPE_RISCV
#define TBC_CPU_BYTE_SEXLE
#elif defined(__s390x__)
/** @todo to detect_unsupported.h */
#define TBC_NOT_INT64
#define TBC_CPU_NAME "s390x"
#define TBC_CPU_ARCH_64BITS
#define TBC_CPU_TYPE_IBMZ
#define TBC_CPU_BYTE_SEXBE
#else
#define TBC_CPU_NAME "UNKNOWN"
#define TBC_CPU_ARCH_8BITS
Expand Down
2 changes: 1 addition & 1 deletion src/driver/driver_error.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ void driver_error(struct app_3bc_s* const self)
}
self->cache_l3.buffer.size =
-tbc_i18n_error_arr[self->cache_l1.error].len;
self->cache_l3.buffer.storage =
self->cache_l3.buffer.storage = (char*)
tbc_i18n_error_arr[self->cache_l1.error].ptr;
break;
}
Expand Down
2 changes: 2 additions & 0 deletions tests/unit/error_util_stoi10.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ int main()
assert(util_stoi10(&dest, src, 32, 3) == ERROR_NUMBER_WRONG_BASE);
assert(dest == 800000000lu);
}
#if !defined(TBC_NOT_INT64)
{
tbc_u64_t dest = 102030405060708090llu;
char* src = "foo";
Expand All @@ -52,4 +53,5 @@ int main()
assert(util_stoi10(&dest, src, 64, 3) == ERROR_NUMBER_WRONG_BASE);
assert(dest == 112233445566778899llu);
}
#endif
}
2 changes: 2 additions & 0 deletions tests/unit/error_util_stoi16.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ int main()
assert(util_stoi16(&dest, src, 32, 3) == ERROR_NUMBER_WRONG_BASE);
assert(dest == 1231231231u);
}
#if !defined(TBC_NOT_INT64)
{
tbc_u64_t dest = 12899124812414948523llu;
char* src = "";
Expand All @@ -52,5 +53,6 @@ int main()
assert(util_stoi16(&dest, src, 64, 3) == ERROR_NUMBER_WRONG_BASE);
assert(dest == 12345678912345678912llu);
}
#endif
return 0;
}
3 changes: 3 additions & 0 deletions tests/unit/error_util_stoi2.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ int main()
assert(util_stoi2(&dest, src, 30, sizeof(src)) == ERROR_NUMBER_OVERFLOW);
assert(dest == 1500000000lu);
}
#if !defined(TBC_NOT_INT64)
{
tbc_u64_t dest = 9223492892482944892llu;
char* src = "111";
Expand All @@ -94,6 +95,7 @@ int main()
assert(util_stoi2(&dest, src, 64, 3) == ERROR_NUMBER_WRONG_BASE);
assert(dest == 8500000000llu);
}

{
tbc_u64_t dest = 9223372036852349038llu;
char src[] = "111111111111111111111111111111111111111111111111111111111111111";
Expand All @@ -107,4 +109,5 @@ int main()
assert(dest[0] == 9223372032403940943llu);
assert(dest[1] == 9223372032403924244llu);
}
#endif
}
2 changes: 2 additions & 0 deletions tests/unit/error_util_stoi8.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ int main()
assert(util_stoi8(&dest, src, 32, 12) == ERROR_NUMBER_OVERFLOW);
assert(dest == 1800000001u);
}
#if !defined(TBC_NOT_INT64)
{
tbc_u64_t dest = 291204129041904091llu;
char* src = "";
Expand All @@ -106,4 +107,5 @@ int main()
assert(util_stoi8(&dest, src, 64, 22) == ERROR_NUMBER_OVERFLOW);
assert(dest == 23456789012345678902llu);
}
#endif
}
2 changes: 2 additions & 0 deletions tests/unit/tests_util_stoi10.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ int main()
assert(util_stoi10(&dest, src, 32, sizeof(src)) == ERROR_UNKNOWN);
assert(dest == 99999999u);
}
#if !defined(TBC_NOT_INT64)
{
tbc_u64_t dest = 6666666666666666666llu;
char src[] = "9999999999999999999";
assert(util_stoi10(&dest, src, 64, sizeof(src)) == ERROR_UNKNOWN);
assert(dest == 9999999999999999999llu);
}
#endif
}
2 changes: 2 additions & 0 deletions tests/unit/tests_util_stoi16.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ int main()
assert(util_stoi16(&dest, src, 32, sizeof(src)) == ERROR_UNKNOWN);
assert(dest == 0xBABACA00);
}
#if !defined(TBC_NOT_INT64)
{
tbc_u64_t dest = 666666666666666666llu;
char src[] = "CAFECAFECAFECAFE";
assert(util_stoi16(&dest, src, 64, sizeof(src)) == ERROR_UNKNOWN);
assert(dest == 0xCAFECAFECAFECAFE);
}
#endif
}
3 changes: 3 additions & 0 deletions tests/unit/tests_util_stoi2.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,13 @@ int main()
assert(util_stoi2(&dest, src, 32, 32) == ERROR_UNKNOWN);
assert(dest == 0xCCCCCCCC);
}
#if !defined(TBC_NOT_INT64)
{
tbc_u64_t dest = 999999999999999999llu;
char* src = "1010101010101010101010101010101010101010101010101010101010101010";
assert(util_stoi2(&dest, src, 64, 64) == ERROR_UNKNOWN);
assert(dest == 0xAAAAAAAAAAAAAAAA);
}
#endif
return 0;
}
2 changes: 2 additions & 0 deletions tests/unit/tests_util_stoi8.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ int main()
assert(util_stoi8(&dest, src, 32, sizeof(src)) == ERROR_UNKNOWN);
assert(dest == 0x1f58d1);
}
#if !defined(TBC_NOT_INT64)
{
tbc_u64_t dest = 888888888888888888llu;
char src[] = "707070707070707070707";
assert(util_stoi8(&dest, src, 64, sizeof(src)) == ERROR_UNKNOWN);
assert(dest == 0x71c71c71c71c71c7);
}
#endif
}

0 comments on commit 122e03a

Please sign in to comment.