make #includes consistent
[hiphop-php.git] / hphp / hhvm / global_variables.cpp
blob00061ca784839c159cc9ca1d70627f75d923a92e
1 /*
2 +----------------------------------------------------------------------+
3 | HipHop for PHP |
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2010- 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 #include "hphp/runtime/base/hphp.h"
19 namespace HPHP {
21 //////////////////////////////////////////////////////////////////////
23 static __thread GlobalVariables* g_variables;
25 void init_global_variables() {
26 always_assert(false);
29 GlobalVariables* get_global_variables() {
30 assert(g_variables);
31 return g_variables;
34 void free_global_variables() {
35 g_variables = nullptr;
38 void free_global_variables_after_sweep() {
39 g_variables = nullptr;
42 SystemGlobals* get_system_globals() { return get_global_variables(); }
44 GlobalNameValueTableWrapper::GlobalNameValueTableWrapper(
45 NameValueTable* tab) : NameValueTableWrapper(tab) {
47 VarNR arr(HphpArray::GetStaticEmptyArray());
48 #define X(s,v) \
49 tab->migrateSet(StringData::GetStaticString(#s), \
50 gvm_##s.asTypedValue()); \
51 gvm_##s.v;
53 X(argc, setNull());
54 X(argv, setNull());
55 X(_SERVER, assignVal(arr));
56 X(_GET, assignVal(arr));
57 X(_POST, assignVal(arr));
58 X(_COOKIE, assignVal(arr));
59 X(_FILES, assignVal(arr));
60 X(_ENV, assignVal(arr));
61 X(_REQUEST, assignVal(arr));
62 X(_SESSION, assignVal(arr));
63 X(HTTP_RAW_POST_DATA, setNull());
64 X(http_response_header, setNull());
65 #undef X
67 ThreadInfo::s_threadInfo->m_globals = g_variables = this;
70 //////////////////////////////////////////////////////////////////////