PageRenderTime 70ms CodeModel.GetById 35ms RepoModel.GetById 1ms app.codeStats 0ms

/pypy/translator/c/src/main.h

https://bitbucket.org/rokujyouhitoma/pypy/
C Header | 86 lines | 58 code | 22 blank | 6 comment | 7 complexity | e7e6ffd0c90dc7043cc7a35f90da07b7 MD5 | raw file
  1. #ifndef STANDALONE_ENTRY_POINT
  2. # define STANDALONE_ENTRY_POINT PYPY_STANDALONE
  3. #endif
  4. char *RPython_StartupCode(void); /* forward */
  5. /* prototypes */
  6. int main(int argc, char *argv[]);
  7. /* implementations */
  8. #ifndef PYPY_NOT_MAIN_FILE
  9. #ifndef PYPY_MAIN_FUNCTION
  10. #define PYPY_MAIN_FUNCTION main
  11. #endif
  12. #ifdef __GNUC__
  13. /* Hack to prevent this function from being inlined. Helps asmgcc
  14. because the main() function has often a different prologue/epilogue. */
  15. int pypy_main_function(int argc, char *argv[]) __attribute__((__noinline__));
  16. #endif
  17. int pypy_main_function(int argc, char *argv[])
  18. {
  19. char *errmsg;
  20. int i, exitcode;
  21. RPyListOfString *list;
  22. pypy_asm_stack_bottom();
  23. #ifdef PYPY_X86_CHECK_SSE2_DEFINED
  24. pypy_x86_check_sse2();
  25. #endif
  26. instrument_setup();
  27. #ifndef MS_WINDOWS
  28. /* this message does no longer apply to win64 :-) */
  29. if (sizeof(void*) != SIZEOF_LONG) {
  30. errmsg = "only support platforms where sizeof(void*) == sizeof(long),"
  31. " for now";
  32. goto error;
  33. }
  34. #endif
  35. errmsg = RPython_StartupCode();
  36. if (errmsg) goto error;
  37. list = _RPyListOfString_New(argc);
  38. if (RPyExceptionOccurred()) goto memory_out;
  39. for (i=0; i<argc; i++) {
  40. RPyString *s = RPyString_FromString(argv[i]);
  41. if (RPyExceptionOccurred()) goto memory_out;
  42. _RPyListOfString_SetItem(list, i, s);
  43. }
  44. exitcode = STANDALONE_ENTRY_POINT(list);
  45. #ifdef RPY_ASSERT
  46. pypy_debug_alloc_results();
  47. #endif
  48. if (RPyExceptionOccurred()) {
  49. /* print the RPython traceback */
  50. pypy_debug_catch_fatal_exception();
  51. }
  52. return exitcode;
  53. memory_out:
  54. errmsg = "out of memory";
  55. error:
  56. fprintf(stderr, "Fatal error during initialization: %s\n", errmsg);
  57. abort();
  58. return 1;
  59. }
  60. int PYPY_MAIN_FUNCTION(int argc, char *argv[])
  61. {
  62. return pypy_main_function(argc, argv);
  63. }
  64. #endif /* PYPY_NOT_MAIN_FILE */