Add sub-controls for Hack array compat runtime checks
[hiphop-php.git] / hphp / runtime / base / program-functions.h
blob9555cdca6b6d2ea6e9f12482d03b58549adc988c
1 /*
2 +----------------------------------------------------------------------+
3 | HipHop for PHP |
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2010-present 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 +----------------------------------------------------------------------+
17 #ifndef incl_HPHP_PROGRAM_FUNCTIONS_H_
18 #define incl_HPHP_PROGRAM_FUNCTIONS_H_
20 #include "hphp/runtime/base/types.h"
21 #include <boost/program_options/parsers.hpp>
23 // Needed for compatibility with oniguruma-5.9.4+
24 #define ONIG_ESCAPE_UCHAR_COLLISION
26 namespace HPHP {
27 ///////////////////////////////////////////////////////////////////////////////
29 struct Transport;
31 #if defined(__APPLE__) || defined(_MSC_VER)
32 extern const void* __hot_start;
33 extern const void* __hot_end;
34 #else
35 extern "C" {
36 void __attribute__((__weak__)) __hot_start();
37 void __attribute__((__weak__)) __hot_end();
39 #endif
41 /**
42 * Main entry point of the entire program.
44 int execute_program(int argc, char **argv);
45 void execute_command_line_begin(int argc, char **argv, int xhprof);
46 void execute_command_line_end(int xhprof, bool coverage, const char *program);
48 void init_command_line_session(int arc, char** argv);
49 void
50 init_command_line_globals(int argc, char** argv, char** envp,
51 int xhprof,
52 std::map<std::string, std::string>& serverVariables,
53 std::map<std::string, std::string>& envVariables);
54 /**
55 * Setting up environment variables.
57 void process_env_variables(Array& variables);
59 /**
60 * Inserting a variable into specified symbol table.
62 * "overwrite" parameter is only for cookies:
63 * According to rfc2965, more specific paths are listed above the less
64 * specific ones. If we encounter a duplicate cookie name, we should
65 * skip it, since it is not possible to have the same (plain text)
66 * cookie name for the same path and we should not overwrite more
67 * specific cookies with the less specific ones.
69 void register_variable(Array& variables,
70 char* name,
71 const Variant& value,
72 bool overwrite = true);
74 String canonicalize_path(const String& path, const char* root, int rootLen);
76 /**
77 * Translate hex encode stack into both C++ and PHP frames.
79 std::string translate_stack(const char *hexencoded,
80 bool with_frame_numbers = true);
82 time_t start_time();
84 // Boost 1.54 has a bug where it doesn't handle options with - in them as
85 // it only gives us the string after the last -
86 // https://github.com/facebook/hhvm/issues/2864
87 // This won't fix the problem in 100% of cases (e.g. two options are
88 // used that both end in the same substring. How do you choose?) But
89 // that should be very rare.
90 #if defined(BOOST_VERSION) && BOOST_VERSION <= 105400
91 std::string get_right_option_name(
92 const boost::program_options::basic_parsed_options<char>& opts,
93 std::string& wrong_name);
94 #endif
96 ///////////////////////////////////////////////////////////////////////////////
98 struct ExecutionContext;
100 void hphp_process_init();
101 void hphp_session_init();
103 bool hphp_invoke_simple(const std::string& filename, bool warmupOnly);
104 bool hphp_invoke(ExecutionContext *context,
105 const std::string &cmd,
106 bool func,
107 const Array& funcParams,
108 VRefParam funcRet,
109 const std::string &reqInitFunc,
110 const std::string &reqInitDoc,
111 bool &error,
112 std::string &errorMsg,
113 bool once,
114 bool warmupOnly,
115 bool richErrorMsg,
116 const std::string& prelude);
117 void hphp_context_shutdown();
118 void hphp_context_exit(bool shutdown = true);
120 void hphp_thread_init();
121 void hphp_thread_exit();
123 void hphp_memory_cleanup();
125 * Tear down various internal state at the very end of a session. If transport
126 * is provided, various statistics about resources consumed by the request will
127 * be logged to ServiceData.
129 void hphp_session_exit(const Transport* transport = nullptr);
130 void hphp_process_exit() noexcept;
131 bool is_hphp_session_initialized();
132 std::string get_systemlib(std::string* hhas = nullptr,
133 const std::string &section = "systemlib",
134 const std::string &filename = "");
136 // Helper function for stats tracking with exceptions.
137 void bump_counter_and_rethrow(bool isPsp);
139 ///////////////////////////////////////////////////////////////////////////////
142 #endif // incl_HPHP_PROGRAM_FUNCTIONS_H_