nolibc.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #include "../config-host.h"
  2. /* SPDX-License-Identifier: MIT */
  3. /*
  4. * Test liburing nolibc functionality.
  5. *
  6. * Currently, supported architectures are:
  7. * 1) x86
  8. * 2) x86-64
  9. * 3) aarch64
  10. * 4) riscv64
  11. *
  12. */
  13. #include "helpers.h"
  14. #if !defined(__x86_64__) && !defined(__i386__) && !defined(__aarch64__) && (!defined(__riscv) && __riscv_xlen != 64)
  15. /*
  16. * This arch doesn't support nolibc.
  17. */
  18. int main(void)
  19. {
  20. return T_EXIT_SKIP;
  21. }
  22. #else /* #if !defined(__x86_64__) && !defined(__i386__) && !defined(__aarch64__) && (!defined(__riscv) && __riscv_xlen != 64) */
  23. #ifndef CONFIG_NOLIBC
  24. #define CONFIG_NOLIBC
  25. #endif
  26. #include <stdio.h>
  27. #include <unistd.h>
  28. #include "../src/lib.h"
  29. static int test_get_page_size(void)
  30. {
  31. long a, b;
  32. a = sysconf(_SC_PAGESIZE);
  33. b = get_page_size();
  34. if (a != b) {
  35. fprintf(stderr, "get_page_size() fails, %ld != %ld", a, b);
  36. return -1;
  37. }
  38. return 0;
  39. }
  40. int main(int argc, char *argv[])
  41. {
  42. int ret;
  43. if (argc > 1)
  44. return T_EXIT_SKIP;
  45. ret = test_get_page_size();
  46. if (ret)
  47. return T_EXIT_FAIL;
  48. return T_EXIT_PASS;
  49. }
  50. #endif /* #if !defined(__x86_64__) && !defined(__i386__) && !defined(__aarch64__) && (!defined(__riscv) && __riscv_xlen != 64) */