PageRenderTime 82ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/hphp/hhvm/process-init.h

https://gitlab.com/Blueprint-Marketing/hhvm
C Header | 60 lines | 30 code | 7 blank | 23 comment | 0 complexity | 1d0dc01caaa51c08aa0be902f285e559 MD5 | raw file
  1. /*
  2. +----------------------------------------------------------------------+
  3. | HipHop for PHP |
  4. +----------------------------------------------------------------------+
  5. | Copyright (c) 2010-2014 Facebook, Inc. (http://www.facebook.com) |
  6. +----------------------------------------------------------------------+
  7. | This source file is subject to version 3.01 of the PHP license, |
  8. | that is bundled with this package in the file LICENSE, and is |
  9. | available through the world-wide-web at the following url: |
  10. | http://www.php.net/license/3_01.txt |
  11. | If you did not receive a copy of the PHP license and are unable to |
  12. | obtain it through the world-wide-web, please send a note to |
  13. | license@php.net so we can mail you a copy immediately. |
  14. +----------------------------------------------------------------------+
  15. */
  16. #ifndef incl_HPHP_HHVM_PROCESS_INIT_H_
  17. #define incl_HPHP_HHVM_PROCESS_INIT_H_
  18. #include "hphp/runtime/base/thread-init-fini.h"
  19. #include "hphp/runtime/vm/runtime.h"
  20. #include "hphp/compiler/analysis/emitter.h"
  21. namespace HPHP {
  22. extern void (*g_vmProcessInit)();
  23. void hphp_process_init();
  24. void ProcessInit();
  25. void initialize_repo();
  26. /*
  27. * This must be called before execute_program_impl in an hhvm build.
  28. */
  29. inline void register_process_init() {
  30. g_vmProcessInit = &ProcessInit;
  31. g_hphp_compiler_parse = &HPHP::Compiler::hphp_compiler_parse;
  32. g_hphp_build_native_func_unit = &HPHP::Compiler::
  33. hphp_build_native_func_unit;
  34. g_hphp_build_native_class_unit = &HPHP::Compiler::
  35. hphp_build_native_class_unit;
  36. }
  37. /*
  38. * Initialize the runtime in a way that's appropriate for unit tests
  39. * that make partial use of libhphp_runtime.a. (There will not be a
  40. * real execution context or anything like that.)
  41. */
  42. inline void init_for_unit_test() {
  43. register_process_init();
  44. initialize_repo();
  45. init_thread_locals();
  46. IniSetting::Map ini = IniSetting::Map::object;
  47. Hdf config;
  48. RuntimeOption::Load(ini, config);
  49. compile_file(0, 0, MD5(), 0);
  50. hphp_process_init();
  51. }
  52. }
  53. #endif