porting.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /* SPDX-License-Identifier: MIT */
  2. /* Copyright (c) 2013-2024 The SRS Authors */
  3. #include <stdio.h>
  4. #include <setjmp.h>
  5. #include <execinfo.h>
  6. #include <stdlib.h>
  7. void bar()
  8. {
  9. }
  10. void foo()
  11. {
  12. bar();
  13. }
  14. int main(int argc, char** argv)
  15. {
  16. printf("OS specs:\n");
  17. #ifdef __linux__
  18. printf("__linux__: %d\n", __linux__);
  19. #endif
  20. #ifdef __APPLE__
  21. printf("__APPLE__: %d\n", __APPLE__);
  22. #endif
  23. #ifdef __CYGWIN__
  24. printf("__CYGWIN__: %d\n", __CYGWIN__);
  25. #endif
  26. #ifdef _WIN32
  27. printf("_WIN32: %d\n", _WIN32);
  28. #endif
  29. printf("\nCPU specs:\n");
  30. #ifdef __mips__
  31. // https://s3-eu-west-1.amazonaws.com/downloads-mips/documents/MD00565-2B-MIPS32-QRC-01.01.pdf
  32. printf("__mips__: %d, __mips: %d, _MIPSEL: %d\n", __mips__, __mips, _MIPSEL);
  33. #endif
  34. #ifdef __mips64
  35. printf("__mips64: %d\n", __mips64);
  36. #endif
  37. #ifdef __x86_64__
  38. printf("__x86_64__: %d\n", __x86_64__);
  39. #endif
  40. #ifdef __loongarch64
  41. printf("__loongarch__: %d __loongarch64: %d\n", __loongarch__, __loongarch64);
  42. #endif
  43. #ifdef __riscv
  44. printf("__riscv: %d\n", __riscv);
  45. #endif
  46. #ifdef __arm__
  47. printf("__arm__: %d\n", __arm__);
  48. #endif
  49. #ifdef __aarch64__
  50. printf("__aarch64__: %d\n", __aarch64__);
  51. #endif
  52. printf("\nCompiler specs:\n");
  53. #ifdef __GLIBC__
  54. printf("__GLIBC__: %d\n", __GLIBC__);
  55. #endif
  56. printf("\nCalling conventions:\n");
  57. foo();
  58. printf("\nCall setjmp:\n");
  59. jmp_buf ctx;
  60. if (!setjmp(ctx)) {
  61. printf("Call longjmp with return=1\n");
  62. longjmp(ctx, 1);
  63. // Not reachable code.
  64. printf("Should never be here.\n");
  65. }
  66. printf("\nDone\n");
  67. return 0;
  68. }